@@ -23,24 +23,26 @@ pub use pins::{setup_pins, Gpio};
2323use fugit:: RateExtU32 ;
2424use stm32_eth:: hal:: rcc:: RccExt ;
2525
26+ const NUM_DESCRIPTORS : usize = 4 ;
27+
2628/// On H7s, the ethernet DMA does not have access to the normal ram
2729/// so we must explicitly put them in SRAM.
2830#[ cfg_attr( feature = "stm32h7xx-hal" , link_section = ".sram1.eth" ) ]
29- static mut TX_DESCRIPTORS : MaybeUninit < [ TxDescriptor ; 4 ] > = MaybeUninit :: uninit ( ) ;
31+ static mut TX_DESCRIPTORS : MaybeUninit < [ TxDescriptor ; NUM_DESCRIPTORS ] > = MaybeUninit :: uninit ( ) ;
32+ #[ cfg_attr( feature = "stm32h7xx-hal" , link_section = ".sram1.eth" ) ]
33+ static mut TX_BUFFERS : MaybeUninit < [ [ u8 ; MTU + 2 ] ; NUM_DESCRIPTORS ] > = MaybeUninit :: uninit ( ) ;
34+ #[ cfg_attr( feature = "stm32h7xx-hal" , link_section = ".sram1.eth" ) ]
35+ static mut RX_DESCRIPTORS : MaybeUninit < [ RxDescriptor ; NUM_DESCRIPTORS ] > = MaybeUninit :: uninit ( ) ;
3036#[ cfg_attr( feature = "stm32h7xx-hal" , link_section = ".sram1.eth" ) ]
31- static mut TX_BUFFERS : MaybeUninit < [ [ u8 ; MTU + 2 ] ; 4 ] > = MaybeUninit :: uninit ( ) ;
32- #[ cfg_attr( feature = "stm32h7xx-hal" , link_section = ".sram1.eth2" ) ]
33- static mut RX_DESCRIPTORS : MaybeUninit < [ RxDescriptor ; 4 ] > = MaybeUninit :: uninit ( ) ;
34- #[ cfg_attr( feature = "stm32h7xx-hal" , link_section = ".sram1.eth2" ) ]
35- static mut RX_BUFFERS : MaybeUninit < [ [ u8 ; MTU + 2 ] ; 4 ] > = MaybeUninit :: uninit ( ) ;
37+ static mut RX_BUFFERS : MaybeUninit < [ [ u8 ; MTU + 2 ] ; NUM_DESCRIPTORS ] > = MaybeUninit :: uninit ( ) ;
3638
3739/// Set up the buffers to be used
3840pub fn setup_rings ( ) -> ( TxDescriptorRing < ' static > , RxDescriptorRing < ' static > ) {
39- let tx_desc = unsafe { TX_DESCRIPTORS . write ( [ TxDescriptor :: new ( ) ; 4 ] ) } ;
40- let tx_buf = unsafe { TX_BUFFERS . write ( [ [ 0u8 ; MTU + 2 ] ; 4 ] ) } ;
41+ let tx_desc = unsafe { TX_DESCRIPTORS . write ( [ TxDescriptor :: new ( ) ; NUM_DESCRIPTORS ] ) } ;
42+ let tx_buf = unsafe { TX_BUFFERS . write ( [ [ 0u8 ; MTU + 2 ] ; NUM_DESCRIPTORS ] ) } ;
4143
42- let rx_desc = unsafe { RX_DESCRIPTORS . write ( [ RxDescriptor :: new ( ) ; 4 ] ) } ;
43- let rx_buf = unsafe { RX_BUFFERS . write ( [ [ 0u8 ; MTU + 2 ] ; 4 ] ) } ;
44+ let rx_desc = unsafe { RX_DESCRIPTORS . write ( [ RxDescriptor :: new ( ) ; NUM_DESCRIPTORS ] ) } ;
45+ let rx_buf = unsafe { RX_BUFFERS . write ( [ [ 0u8 ; MTU + 2 ] ; NUM_DESCRIPTORS ] ) } ;
4446
4547 (
4648 TxDescriptorRing :: new ( tx_desc, tx_buf) ,
0 commit comments