embassy-net-enc28j60

Crates

git

Versions

default

Flavors

embassy_net_enc28j60

Struct Enc28j60

Source
pub struct Enc28j60<S, O> { /* private fields */ }
Expand description

ENC28J60 embassy-net driver

Implementations§

Source§

impl<S, O> Enc28j60<S, O>
where S: SpiDevice, O: OutputPin,

Source

pub fn new(spi: S, rst: Option<O>, mac_addr: [u8; 6]) -> Self

Create a new ENC28J60 driver instance.

The RST pin is optional. If None, reset will be done with a SPI soft reset command, instead of via the RST pin.

Source

pub fn address(&self) -> [u8; 6]

Returns the device’s MAC address

Source

pub fn receive(&mut self, buf: &mut [u8]) -> Option<usize>

Flushes the transmit buffer, ensuring all pending transmissions have completed NOTE: The returned packet must be read or ignore-d, otherwise this method will always return None on subsequent invocations

Source

pub fn transmit(&mut self, bytes: &[u8])

Starts the transmission of bytes

It’s up to the caller to ensure that bytes is a valid Ethernet frame. The interface will take care of appending a (4 byte) CRC to the frame and of padding the frame to the minimum size allowed by the Ethernet specification (64 bytes, or 46 bytes of payload).

NOTE This method will flush any previous transmission that’s in progress

§Panics

If bytes length is greater than 1514, the maximum frame length allowed by the interface, or greater than the transmit buffer

Get whether the link is up

Source

pub fn mtu(&self) -> u16

Returns the interface Maximum Transmission Unit (MTU)

The value returned by this function will never exceed 1514 bytes. The actual value depends on the memory assigned to the transmission buffer when initializing the device

Source

pub fn pending_packets(&mut self) -> u8

Returns the number of packets that have been received but have not been processed yet

Source

pub fn accept(&mut self, packets: &[Packet])

Adjusts the receive filter to accept these packet types

Source

pub fn ignore(&mut self, packets: &[Packet])

Adjusts the receive filter to ignore these packet types

Trait Implementations§

Source§

impl<S, O> Driver for Enc28j60<S, O>
where S: SpiDevice, O: OutputPin,

Source§

type RxToken<'a> = RxToken<'a> where Self: 'a

A token to receive a single network packet.
Source§

type TxToken<'a> = TxToken<'a, S, O> where Self: 'a

A token to transmit a single network packet.
Source§

fn receive( &mut self, cx: &mut Context<'_>, ) -> 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, _cx: &mut Context<'_>) -> Option<Self::TxToken<'_>>

Construct a transmit token. Read more
Get the link state. Read more
Source§

fn capabilities(&self) -> Capabilities

Get a description of device capabilities.
Source§

fn hardware_address(&self) -> HardwareAddress

Get the device’s hardware address. Read more

Auto Trait Implementations§

§

impl<S, O> Freeze for Enc28j60<S, O>
where S: Freeze, O: Freeze,

§

impl<S, O> RefUnwindSafe for Enc28j60<S, O>

§

impl<S, O> Send for Enc28j60<S, O>
where S: Send, O: Send,

§

impl<S, O> Sync for Enc28j60<S, O>
where S: Sync, O: Sync,

§

impl<S, O> Unpin for Enc28j60<S, O>
where S: Unpin, O: Unpin,

§

impl<S, O> UnwindSafe for Enc28j60<S, O>
where S: UnwindSafe, O: UnwindSafe,

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.