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>

source

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.

source

pub fn interrupt_handler(&mut self) -> InterruptReasonSummary

Calls eth_interrupt_handler() and collects/caches TX timestamps. (See EthernetDMA::get_timestamp_for_id for retrieval)

source

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.

source

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.

source

pub fn tx_is_running(&self) -> bool

Is Tx DMA currently running?

source

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

source

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:

  1. When an ethernet interrupt occurs, call EthernetDMA::interrupt_handler (not eth_interrupt_handler).
  2. 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>

Use this Ethernet driver with smoltcp

§

type RxToken = EthRxToken<'a>

§

type TxToken = EthTxToken<'a>

source§

fn capabilities(&self) -> DeviceCapabilities

Get a description of device capabilities.
source§

fn receive(&mut self) -> 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) -> Option<Self::TxToken>

Construct a transmit token.

Auto Trait Implementations§

§

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 Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.