Skip to content

Commit e6766ed

Browse files
committed
Remove ordering requirements for DMA and MAC. They were likely a manifestation of #57
1 parent b7511d7 commit e6766ed

File tree

3 files changed

+7
-25
lines changed

3 files changed

+7
-25
lines changed

src/dma/mod.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ use core::borrow::Borrow;
44

55
use cortex_m::peripheral::NVIC;
66

7-
use crate::{
8-
peripherals::{ETHERNET_DMA, ETHERNET_MAC},
9-
stm32::Interrupt,
10-
};
7+
use crate::{peripherals::ETHERNET_DMA, stm32::Interrupt};
118

129
#[cfg(feature = "smoltcp-phy")]
1310
mod smoltcp_phy;
@@ -45,11 +42,6 @@ impl<'rx, 'tx> EthernetDMA<'rx, 'tx> {
4542
/// usually not accessible.
4643
pub(crate) fn new(
4744
eth_dma: ETHERNET_DMA,
48-
// Take a reference to ETHERNET_MAC to ensure that
49-
// this function cannot be called before `EthernetMAC::new`.
50-
// If we do that, shenanigans ensues (presumably clock and wait
51-
// condition mismatch)
52-
#[allow(unused_variables)] eth_mac: &ETHERNET_MAC,
5345
rx_buffer: &'rx mut [RxRingEntry],
5446
tx_buffer: &'tx mut [TxRingEntry],
5547
) -> Self {

src/lib.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,10 @@ where
107107
let eth_mac = eth_mac.into();
108108

109109
// Congfigure and start up the ethernet DMA.
110-
// Note: this _must_ happen before configuring the MAC.
111-
// It's not entirely clear why, but no interrupts are
112-
// generated if the order is reversed.
113-
let dma = EthernetDMA::new(eth_dma.into(), &eth_mac, rx_buffer, tx_buffer);
110+
let dma = EthernetDMA::new(eth_dma.into(), rx_buffer, tx_buffer);
114111

115112
// Configure the ethernet MAC
116-
let mac = EthernetMAC::new(eth_mac, eth_mmc, &dma, clocks, Speed::FullDuplexBase100Tx)?;
113+
let mac = EthernetMAC::new(eth_mac, eth_mmc, clocks, Speed::FullDuplexBase100Tx)?;
117114

118115
Ok((dma, mac))
119116
}
@@ -170,14 +167,11 @@ where
170167
let eth_mac = eth_mac.into();
171168

172169
// Congfigure and start up the ethernet DMA.
173-
// Note: this _must_ happen before configuring the MAC.
174-
// It's not entirely clear why, but no interrupts are
175-
// generated if the order is reversed.
176-
let dma = EthernetDMA::new(eth_dma.into(), &eth_mac, rx_buffer, tx_buffer);
170+
let dma = EthernetDMA::new(eth_dma.into(), rx_buffer, tx_buffer);
177171

178172
// Configure the ethernet MAC
179-
let mac = EthernetMAC::new(eth_mac, eth_mmc, &dma, clocks, Speed::FullDuplexBase100Tx)?
180-
.with_mii(mdio, mdc);
173+
let mac =
174+
EthernetMAC::new(eth_mac, eth_mmc, clocks, Speed::FullDuplexBase100Tx)?.with_mii(mdio, mdc);
181175

182176
Ok((dma, mac))
183177
}

src/mac/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use core::ops::{Deref, DerefMut};
44

5-
use crate::{hal::rcc::Clocks, peripherals::ETHERNET_MAC, stm32::ETHERNET_MMC, EthernetDMA};
5+
use crate::{hal::rcc::Clocks, peripherals::ETHERNET_MAC, stm32::ETHERNET_MMC};
66

77
mod miim;
88
pub use miim::*;
@@ -59,10 +59,6 @@ impl EthernetMAC {
5959
pub(crate) fn new(
6060
eth_mac: ETHERNET_MAC,
6161
eth_mmc: ETHERNET_MMC,
62-
// Take a reference to EthernetDMA to ensure
63-
// that `EthernetDMA` has been called before
64-
// this function.
65-
#[allow(unused)] eth_dma: &EthernetDMA,
6662
clocks: Clocks,
6763
initial_speed: Speed,
6864
) -> Result<Self, WrongClock> {

0 commit comments

Comments
 (0)