Skip to content

Commit 886c6ba

Browse files
committed
Small fixes
1 parent 14a2f31 commit 886c6ba

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

examples/common.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,26 @@ pub use pins::{setup_pins, Gpio};
2323
use fugit::RateExtU32;
2424
use 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
3840
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]) };
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),

src/ptp/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl EthernetPTP {
136136
mac.macssir
137137
.write(|w| unsafe { w.ssinc().bits(stssi.raw() as u8) });
138138

139-
Self {}
139+
me
140140
};
141141

142142
me.set_addend(tsa);

0 commit comments

Comments
 (0)