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 split(&mut self) -> (&mut RxRing<'rx>, &mut TxRing<'tx>)
pub fn split(&mut self) -> (&mut RxRing<'rx>, &mut TxRing<'tx>)
Split the EthernetDMA
into concurrently operating send and
receive parts.
Sourcepub fn enable_interrupt(&self)
pub fn enable_interrupt(&self)
Enable RX and TX interrupts
In your handler you must call
EthernetDMA::interrupt_handler()
or stm32_eth::eth_interrupt_handler
to clear interrupt pending bits. Otherwise the interrupt will reoccur immediately.
If you have PTP enabled, you must also call EthernetPTP::interrupt_handler()
if you wish to make use of the PTP timestamp trigger feature.
Sourcepub fn interrupt_handler() -> InterruptReasonSummary
pub fn interrupt_handler() -> InterruptReasonSummary
Handle the DMA parts of the ETH
interrupt.
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>
Try to receive a packet.
If no packet is available, this function returns Err(RxError::WouldBlock)
.
It may also return another kind of RxError
.
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 EthernetDMA::recv_next()
to free an
entry and to demand poll from the hardware.
Sourcepub fn tx_is_running(&self) -> bool
pub fn tx_is_running(&self) -> bool
Is Tx DMA currently running?
Sourcepub fn send<F>(
&mut self,
length: usize,
packet_id: Option<PacketId>,
f: F,
) -> Result<(), TxError>
pub fn send<F>( &mut self, length: usize, packet_id: Option<PacketId>, f: F, ) -> Result<(), TxError>
Try to send a packet with data.
If there are no free TX slots, this function will
return Err(TxError::WouldBlock)
.
Sourcepub fn rx_available(&mut self) -> bool
pub fn rx_available(&mut self) -> bool
Check if there is a packet available for reading.
If this function returns true, it is guaranteed that the
next call to EthernetDMA::recv_next
will return Ok
.
Sourcepub fn tx_available(&mut self) -> bool
pub fn tx_available(&mut self) -> bool
Check if sending a packet now would succeed.
If this function returns true, it is guaranteed that
the next call to EthernetDMA::send
will return Ok
Source§impl<'rx, 'tx> EthernetDMA<'rx, 'tx>
impl<'rx, 'tx> EthernetDMA<'rx, 'tx>
Source§impl EthernetDMA<'_, '_>
impl EthernetDMA<'_, '_>
Sourcepub fn poll_timestamp(
&self,
packet_id: &PacketId,
) -> Poll<Result<Option<Timestamp>, PacketIdNotFound>>
pub fn poll_timestamp( &self, packet_id: &PacketId, ) -> Poll<Result<Option<Timestamp>, PacketIdNotFound>>
Try to get the timestamp for the given packet ID.
This function will attempt to find both RX and TX timestamps, so make sure that the provided packet ID is unique between the two.
Sourcepub fn rx_timestamp(
&self,
packet_id: &PacketId,
) -> Result<Option<Timestamp>, PacketIdNotFound>
pub fn rx_timestamp( &self, packet_id: &PacketId, ) -> Result<Option<Timestamp>, PacketIdNotFound>
Get the RX timestamp for the given packet ID.
Sourcepub fn wait_for_tx_timestamp(
&self,
packet_id: &PacketId,
) -> Result<Option<Timestamp>, PacketIdNotFound>
pub fn wait_for_tx_timestamp( &self, packet_id: &PacketId, ) -> Result<Option<Timestamp>, PacketIdNotFound>
Blockingly wait until the TX timestamp for the given ID is available.
Sourcepub fn poll_tx_timestamp(
&self,
packet_id: &PacketId,
) -> Poll<Result<Option<Timestamp>, PacketIdNotFound>>
pub fn poll_tx_timestamp( &self, packet_id: &PacketId, ) -> Poll<Result<Option<Timestamp>, PacketIdNotFound>>
Poll to check if the TX timestamp for the given ID is available.
Sourcepub async fn tx_timestamp(
&mut self,
packet_id: &PacketId,
) -> Result<Option<Timestamp>, PacketIdNotFound>
pub async fn tx_timestamp( &mut self, packet_id: &PacketId, ) -> Result<Option<Timestamp>, PacketIdNotFound>
Get the TX timestamp for the given ID.
Sourcepub fn next_packet_id(&mut self) -> PacketId
pub fn next_packet_id(&mut self) -> PacketId
Get the next packet ID.
Trait Implementations§
Source§impl<'a, 'rx, 'tx> Device for &'a mut EthernetDMA<'rx, 'tx>
Use this Ethernet driver with smoltcp
impl<'a, 'rx, 'tx> Device for &'a mut EthernetDMA<'rx, 'tx>
Use this Ethernet driver with smoltcp