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<B: EthernetPinBundle + 'd, const RX: usize, const TX: usize>(
eth: ETH<'d>,
storage: &'d mut EthernetDmaStorage<RX, TX>,
mac_addr: [u8; 6],
phy: P,
pins: B,
) -> Result<Self, Error>
pub fn new<B: EthernetPinBundle + 'd, const RX: usize, const TX: usize>( eth: ETH<'d>, storage: &'d mut EthernetDmaStorage<RX, TX>, mac_addr: [u8; 6], phy: P, pins: B, ) -> Result<Self, Error>
Creates an Ethernet driver using RMII (RmiiPinBundle) or MII (MiiPinBundle).
On chips with RGMII, use RgmiiPinBundle. RGMII is limited to 100 Mbps when the
MPLL does not divide to its 125 MHz transmit clock.
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.
The DMA ISR is bound and its interrupts enabled on the first link-up, not here: without a link there is no RX clock and the DMA would only report errors.
Source§impl<'d, Dm: DriverMode, P: Phy> Ethernet<'d, Dm, P>
impl<'d, Dm: DriverMode, P: Phy> Ethernet<'d, Dm, P>
Sourcepub fn set_speed(&mut self, speed: Speed)
pub fn set_speed(&mut self, speed: Speed)
Configures the MAC for the given speed.
The speed must be one the wired interface can carry: MII and RMII top out at 100 Mbps, only RGMII reaches 1000 Mbps.
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 whether 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.Source§fn link_state(&mut self, cx: &mut Context<'_>) -> LinkState
fn link_state(&mut self, cx: &mut Context<'_>) -> LinkState
Polls the PHY and tracks the DMA interrupt state with the link.
DMA interrupts are only enabled while the link is up: with no link there is no RX clock, and error interrupts would otherwise fire continuously.
Source§type RxToken<'a> = EthernetRxToken<'a, 'd>
where
Self: 'a
type RxToken<'a> = EthernetRxToken<'a, 'd> where Self: 'a
Source§type TxToken<'a> = EthernetTxToken<'a, 'd>
where
Self: 'a
type TxToken<'a> = EthernetTxToken<'a, 'd> where Self: 'a
Source§fn receive(
&mut self,
cx: &mut Context<'_>,
) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)>
fn receive( &mut self, cx: &mut Context<'_>, ) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)>
Source§fn transmit(&mut self, cx: &mut Context<'_>) -> Option<Self::TxToken<'_>>
fn transmit(&mut self, cx: &mut Context<'_>) -> Option<Self::TxToken<'_>>
Source§fn capabilities(&self) -> Capabilities
fn capabilities(&self) -> Capabilities
Source§fn hardware_address(&self) -> HardwareAddress
fn hardware_address(&self) -> HardwareAddress
Source§impl<'d, Dm: DriverMode + 'static, P: Phy> Driver for Ethernet<'d, Dm, P>
Available on crate feature unstable only.
impl<'d, Dm: DriverMode + 'static, P: Phy> Driver for Ethernet<'d, Dm, P>
unstable only.Source§fn capabilities(&self) -> Capabilities
fn capabilities(&self) -> Capabilities
Source§fn hardware_address(&self) -> HardwareAddress
fn hardware_address(&self) -> HardwareAddress
Source§fn link_state(&mut self) -> LinkState
fn link_state(&mut self) -> LinkState
Source§fn register_waker(&mut self, waker: &Waker) -> Result<(), NotSupported>
fn register_waker(&mut self, waker: &Waker) -> Result<(), NotSupported>
async only.