Struct stm32_eth::dma::EthernetDMA
source · pub struct EthernetDMA<'rx, 'tx> { /* private fields */ }
Expand description
Ethernet DMA.
Implementations§
source§impl<'rx, 'tx> EthernetDMA<'rx, 'tx>
impl<'rx, 'tx> EthernetDMA<'rx, 'tx>
sourcepub fn enable_interrupt(&self)
pub fn enable_interrupt(&self)
Enable RX and TX interrupts
In your handler you must call
eth_interrupt_handler()
to
clear interrupt pending bits. Otherwise the interrupt will
reoccur immediately.
sourcepub fn interrupt_handler(&mut self) -> InterruptReasonSummary
pub fn interrupt_handler(&mut self) -> InterruptReasonSummary
Calls eth_interrupt_handler()
and collects/caches TX timestamps. (See EthernetDMA::get_timestamp_for_id
for retrieval)
sourcepub fn rx_is_running(&self) -> bool
pub fn rx_is_running(&self) -> bool
Is Rx DMA currently running?
It stops if the ring is full. Call recv_next()
to free an
entry and to demand poll from the hardware.
sourcepub fn recv_next(
&mut self,
packet_id: Option<PacketId>
) -> Result<RxPacket<'_>, RxError>
pub fn recv_next(
&mut self,
packet_id: Option<PacketId>
) -> Result<RxPacket<'_>, RxError>
Receive the next packet (if any is ready), or return None
immediately.
sourcepub fn tx_is_running(&self) -> bool
pub fn tx_is_running(&self) -> bool
Is Tx DMA currently running?
sourcepub fn send<F: FnOnce(&mut [u8]) -> R, R>(
&mut self,
length: usize,
packet_id: Option<PacketId>,
f: F
) -> Result<R, TxError>
pub fn send<F: FnOnce(&mut [u8]) -> R, R>(
&mut self,
length: usize,
packet_id: Option<PacketId>,
f: F
) -> Result<R, TxError>
Send a packet
sourcepub fn get_timestamp_for_id<'a, PKT>(
&mut self,
packet_id: PKT
) -> Result<Timestamp, TimestampError>where
PKT: Into<PacketId>,
pub fn get_timestamp_for_id<'a, PKT>(
&mut self,
packet_id: PKT
) -> Result<Timestamp, TimestampError>where
PKT: Into<PacketId>,
Get a timestamp for the given ID
Both RX and TX timestamps can be obtained reliably as follows:
- When an ethernet interrupt occurs, call
EthernetDMA::interrupt_handler
(noteth_interrupt_handler
). - Before calling
interrupt_handler
again, retrieve timestamps of sent and received frames using this function.
Retrieving RX timestamps can also be done using RxPacket::timestamp
.
Trait Implementations§
source§impl<'a, 'rx, 'tx, 'b> Device<'a> for &'b mut EthernetDMA<'rx, 'tx>
impl<'a, 'rx, 'tx, 'b> Device<'a> for &'b mut EthernetDMA<'rx, 'tx>
Use this Ethernet driver with smoltcp
type RxToken = EthRxToken<'a>
type TxToken = EthTxToken<'a>
source§fn capabilities(&self) -> DeviceCapabilities
fn capabilities(&self) -> DeviceCapabilities
Get a description of device capabilities.