pub struct Ethernet<'d, T: Instance, const TX: usize, const RX: usize, P: Phy> { /* private fields */ }Expand description
Ethernet MAC driver.
TX and RX are the number of DMA descriptors (and buffers) in each ring.
Implementations§
Source§impl<'d, T: Instance, const TX: usize, const RX: usize> Ethernet<'d, T, TX, RX, InternalPhy>
impl<'d, T: Instance, const TX: usize, const RX: usize> Ethernet<'d, T, TX, RX, InternalPhy>
Sourcepub fn new_internal(
peri: Peri<'d, T>,
irqs: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
queue: &'d mut PacketQueue<TX, RX>,
mac_addr: [u8; 6],
) -> Result<Self, InitError>
pub fn new_internal( peri: Peri<'d, T>, irqs: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, queue: &'d mut PacketQueue<TX, RX>, mac_addr: [u8; 6], ) -> Result<Self, InitError>
Initialize Ethernet using the built-in 10M PHY at its fixed SMI address. No external MII/RMII pins are needed. The PHY is clocked from the HSE through PLL3.
§Errors
Returns an error if PLL3 does not lock, or if DMA reset or a PHY management transaction times out.
Source§impl<'d, T: Instance, const TX: usize, const RX: usize, P: Phy> Ethernet<'d, T, TX, RX, P>
impl<'d, T: Instance, const TX: usize, const RX: usize, P: Phy> Ethernet<'d, T, TX, RX, P>
Sourcepub fn new_rmii(
peri: Peri<'d, T>,
irqs: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
queue: &'d mut PacketQueue<TX, RX>,
pins: RmiiPins<'d, impl RefClkPin<T>, impl MdioPin<T>, impl MdcPin<T>, impl CrsDvPin<T>, impl Rxd0Pin<T>, impl Rxd1Pin<T>, impl TxEnPin<T>, impl Txd0Pin<T>, impl Txd1Pin<T>>,
phy: P,
mac_addr: [u8; 6],
) -> Result<Self, InitError>
pub fn new_rmii( peri: Peri<'d, T>, irqs: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, queue: &'d mut PacketQueue<TX, RX>, pins: RmiiPins<'d, impl RefClkPin<T>, impl MdioPin<T>, impl MdcPin<T>, impl CrsDvPin<T>, impl Rxd0Pin<T>, impl Rxd1Pin<T>, impl TxEnPin<T>, impl Txd0Pin<T>, impl Txd1Pin<T>>, phy: P, mac_addr: [u8; 6], ) -> Result<Self, InitError>
Initialize Ethernet using an external PHY connected through RMII. The driver configures and retains the supplied pins using the default mapping.
§Errors
Returns an error if DMA reset or a PHY management transaction times out.
Sourcepub fn new_rmii_without_smi(
peri: Peri<'d, T>,
irqs: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
queue: &'d mut PacketQueue<TX, RX>,
pins: RmiiDataPins<'d, impl RefClkPin<T>, impl CrsDvPin<T>, impl Rxd0Pin<T>, impl Rxd1Pin<T>, impl TxEnPin<T>, impl Txd0Pin<T>, impl Txd1Pin<T>>,
phy: P,
mac_addr: [u8; 6],
) -> Result<Self, InitError>
pub fn new_rmii_without_smi( peri: Peri<'d, T>, irqs: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, queue: &'d mut PacketQueue<TX, RX>, pins: RmiiDataPins<'d, impl RefClkPin<T>, impl CrsDvPin<T>, impl Rxd0Pin<T>, impl Rxd1Pin<T>, impl TxEnPin<T>, impl Txd0Pin<T>, impl Txd1Pin<T>>, phy: P, mac_addr: [u8; 6], ) -> Result<Self, InitError>
Initialize Ethernet using an external PHY connected through RMII, without MDIO and MDC: the application manages the PHY on a bus of its own (for example MDIO driven by GPIO, as it may need to keep managing the PHY across a MAC reset). The driver configures and retains the seven data pins using the default mapping.
The driver does not configure or retain MDIO and MDC, but still calls every
Phy method: the implementation must ignore the Smi it gets and report
what the application learnt from the PHY. GenericPhy and InternalPhy
are not suitable.
§Errors
Returns an error if DMA reset times out or a phy method returns an error.
Sourcepub fn set_promiscuous(&mut self, on: bool)
pub fn set_promiscuous(&mut self, on: bool)
Receive frames for every destination address, not only this MAC’s, its multicast and broadcast: what a bridge needs. The setting survives the driver’s own MAC/DMA resets.
Sourcepub fn receive_frame(
&mut self,
cx: &mut Context<'_>,
) -> Option<RxToken<'_, 'd, T, RX>>
pub fn receive_frame( &mut self, cx: &mut Context<'_>, ) -> Option<RxToken<'_, 'd, T, RX>>
Receive one frame whatever the transmit ring holds.
receive() of embassy_net_driver::Driver also needs a free transmit
descriptor, as the stack may answer at once. A bridge forwards frames to
another interface instead: it must keep receiving while its own transmit
ring is full. The token tells the frame’s length before it is consumed,
so a frame with nowhere to go yet can be left in the ring.