@@ -23,24 +23,26 @@ pub use pins::{setup_pins, Gpio};
23
23
use fugit:: RateExtU32 ;
24
24
use stm32_eth:: hal:: rcc:: RccExt ;
25
25
26
+ const NUM_DESCRIPTORS : usize = 4 ;
27
+
26
28
/// On H7s, the ethernet DMA does not have access to the normal ram
27
29
/// so we must explicitly put them in SRAM.
28
30
#[ 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 ( ) ;
30
36
#[ 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 ( ) ;
36
38
37
39
/// Set up the buffers to be used
38
40
pub 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 ] ) } ;
41
43
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 ] ) } ;
44
46
45
47
(
46
48
TxDescriptorRing :: new ( tx_desc, tx_buf) ,
0 commit comments