pub struct Ethernet<'d, DM: DriverMode, P: Phy> { /* private fields */ }Expand description
EMAC Ethernet driver.
Implementations§
Source§impl<'d, P: Phy> Ethernet<'d, Blocking, P>
impl<'d, P: Phy> Ethernet<'d, Blocking, P>
Sourcepub fn new<const RX: usize, const TX: usize>(
eth: ETH<'d>,
storage: &'d mut EthernetDmaStorage<RX, TX>,
mac_addr: [u8; 6],
phy: P,
pins: impl EthernetPinBundle + 'd,
) -> Result<Self, Error>
pub fn new<const RX: usize, const TX: usize>( eth: ETH<'d>, storage: &'d mut EthernetDmaStorage<RX, TX>, mac_addr: [u8; 6], phy: P, pins: impl EthernetPinBundle + 'd, ) -> Result<Self, Error>
Creates an Ethernet driver using RMII (RmiiPinBundle) or MII (MiiPinBundle).
Sourcepub fn receive(&mut self) -> Result<&mut [u8], Error>
pub fn receive(&mut self) -> Result<&mut [u8], Error>
Returns the received frame data if one is ready.
Call pop_rx after processing the frame.
Sourcepub fn into_async(self) -> Ethernet<'d, Async, P>
pub fn into_async(self) -> Ethernet<'d, Async, P>
Converts to async mode, enabling DMA interrupts and binding the ISR.
Source§impl<'d, Dm: DriverMode, P: Phy> Ethernet<'d, Dm, P>
impl<'d, Dm: DriverMode, P: Phy> Ethernet<'d, Dm, P>
Sourcepub fn set_duplex(&mut self, duplex: Duplex)
pub fn set_duplex(&mut self, duplex: Duplex)
Configures the MAC for the given duplex mode.
Sourcepub fn transmit(&mut self, frame: &[u8]) -> Result<(), Error>
pub fn transmit(&mut self, frame: &[u8]) -> Result<(), Error>
Copies frame into the next TX slot and initiates transmission.
Source§impl<'d, P: Phy> Ethernet<'d, Async, P>
impl<'d, P: Phy> Ethernet<'d, Async, P>
Sourcepub async fn transmit_async(&mut self, frame: &[u8]) -> Result<(), Error>
pub async fn transmit_async(&mut self, frame: &[u8]) -> Result<(), Error>
Asynchronously waits for a TX slot and transmits frame.
Sourcepub async fn receive_async(&mut self, buf: &mut [u8]) -> Result<usize, Error>
pub async fn receive_async(&mut self, buf: &mut [u8]) -> Result<usize, Error>
Asynchronously waits for a frame and copies it into buf.
Sourcepub fn into_blocking(self) -> Ethernet<'d, Blocking, P>
pub fn into_blocking(self) -> Ethernet<'d, Blocking, P>
Converts back to blocking mode, disabling all DMA interrupts.
Sourcepub fn tx_has_capacity(&self) -> bool
pub fn tx_has_capacity(&self) -> bool
Returns true if there is at least one free TX descriptor slot.
Sourcepub fn peek_rx(&mut self) -> Option<&mut [u8]>
pub fn peek_rx(&mut self) -> Option<&mut [u8]>
Peeks at the next received frame without consuming it.
Returns Some(data_slice) if a valid frame is ready, or None.
The caller must call release_rx after processing.
Sourcepub fn release_rx(&mut self)
pub fn release_rx(&mut self)
Releases the current RX descriptor back to the DMA engine.
Trait Implementations§
Source§impl<'d, P: Phy> Driver for Ethernet<'d, Async, P>
Available on crate feature unstable only.
impl<'d, P: Phy> Driver for Ethernet<'d, Async, P>
unstable only.