Struct EthernetDMA

Source
pub struct EthernetDMA<'rx, 'tx> { /* private fields */ }
Expand description

Ethernet DMA.

Implementations§

Source§

impl<'rx, 'tx> EthernetDMA<'rx, 'tx>

Source

pub fn split(&mut self) -> (&mut RxRing<'rx>, &mut TxRing<'tx>)

Split the EthernetDMA into concurrently operating send and receive parts.

Source

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.

Source

pub fn interrupt_handler() -> InterruptReasonSummary

Handle the DMA parts of the ETH interrupt.

Source

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.

Source

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.

Source

pub fn tx_is_running(&self) -> bool

Is Tx DMA currently running?

Source

pub fn send<F>( &mut self, length: usize, packet_id: Option<PacketId>, f: F, ) -> Result<(), TxError>
where F: FnOnce(&mut [u8]),

Try to send a packet with data.

If there are no free TX slots, this function will return Err(TxError::WouldBlock).

Source

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.

Source

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>

Source

pub async fn recv(&mut self, packet_id: Option<PacketId>) -> RxPacket<'_>

Receive a packet.

See RxRing::recv.

Source

pub async fn prepare_packet<'borrow>( &'borrow mut self, length: usize, packet_id: Option<PacketId>, ) -> TxPacket<'borrow, 'tx>

Prepare a packet for sending.

See TxRing::prepare_packet.

Source

pub async fn rx_or_tx(&mut self)

Wait for an RX or TX interrupt to have occured.

Source§

impl EthernetDMA<'_, '_>

Source

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.

Source

pub fn rx_timestamp( &self, packet_id: &PacketId, ) -> Result<Option<Timestamp>, PacketIdNotFound>

Get the RX timestamp for the given packet ID.

Source

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.

Source

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.

Source

pub async fn tx_timestamp( &mut self, packet_id: &PacketId, ) -> Result<Option<Timestamp>, PacketIdNotFound>

Get the TX timestamp for the given ID.

Source

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

Source§

type RxToken<'token> = EthRxToken<'token, 'rx> where Self: 'token

Source§

type TxToken<'token> = EthTxToken<'token, 'tx> where Self: 'token

Source§

fn capabilities(&self) -> DeviceCapabilities

Get a description of device capabilities.
Source§

fn receive( &mut self, _timestamp: Instant, ) -> Option<(Self::RxToken<'_>, Self::TxToken<'_>)>

Construct a token pair consisting of one receive token and one transmit token. Read more
Source§

fn transmit(&mut self, _timestamp: Instant) -> Option<Self::TxToken<'_>>

Construct a transmit token. Read more
Source§

impl Drop for EthernetDMA<'_, '_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'rx, 'tx> Freeze for EthernetDMA<'rx, 'tx>

§

impl<'rx, 'tx> RefUnwindSafe for EthernetDMA<'rx, 'tx>

§

impl<'rx, 'tx> Send for EthernetDMA<'rx, 'tx>

§

impl<'rx, 'tx> !Sync for EthernetDMA<'rx, 'tx>

§

impl<'rx, 'tx> Unpin for EthernetDMA<'rx, 'tx>

§

impl<'rx, 'tx> !UnwindSafe for EthernetDMA<'rx, 'tx>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.