[][src]Struct enc28j60::Enc28j60

pub struct Enc28j60<SPI, NCS, INT, RESET> { /* fields omitted */ }

ENC28J60 driver

Methods

impl<E, SPI, NCS, INT, RESET> Enc28j60<SPI, NCS, INT, RESET> where
    SPI: Transfer<u8, Error = E> + Write<u8, Error = E>,
    NCS: OutputPin,
    INT: IntPin,
    RESET: ResetPin
[src]

pub fn new<D>(
    spi: SPI,
    ncs: NCS,
    int: INT,
    reset: RESET,
    delay: &mut D,
    rx_buf_sz: u16,
    src: [u8; 6]
) -> Result<Self, E> where
    D: DelayMs<u8>,
    RESET: ResetPin,
    INT: IntPin
[src]

Creates a new driver from a SPI peripheral, a NCS pin, a RESET pin and an INT (interrupt) pin

If you haven't physically connected the RESET and / or the INT pin(s) pass the Unconnected value as the reset and / or int argument(s), respectively.

rx_buf_sz is the size of the ENC28J60 RX buffer in bytes. Note that if rx_buf_sz is odd it will be rounded to an even number.

src is the MAC address to associate to this interface. Note that this MAC address is only used to decide which frames will be ignored; frames that don't have their destination address set to broadcast (ff:ff:ff:ff:ff:ff) or to src will be ignored by the interface.

Panics

If rx_buf_sz is greater than 8192 (8 Kibibytes); that's the size of the ENC28J60 internal memory.

pub fn flush(&mut self) -> Result<(), Error<E>>[src]

Flushes the transmit buffer, ensuring all pending transmissions have completed

pub fn receive(&mut self, buffer: &mut [u8]) -> Result<u16, E>[src]

Copies a received frame into the specified buffer

Returns the size of the frame

NOTE If there's no pending packet this method will block until a new packet arrives

pub fn transmit(&mut self, bytes: &[u8]) -> Result<(), Error<E>>[src]

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.

pub fn free(self) -> (SPI, NCS, INT, RESET)[src]

Destroys the driver and returns all the hardware resources that were owned by it

pub fn pending_packets(&mut self) -> Result<u8, E>[src]

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

impl<E, SPI, NCS, INT, RESET> Enc28j60<SPI, NCS, INT, RESET> where
    SPI: Transfer<u8, Error = E> + Write<u8, Error = E>,
    NCS: OutputPin,
    INT: IntPin + InputPin,
    RESET: ResetPin
[src]

pub fn listen(&mut self, event: Event) -> Result<(), E>[src]

Starts listening for the specified event

pub fn interrupt_pending(&mut self) -> bool[src]

Checks if there's any interrupt pending to be processed by polling the INT pin

pub fn unlisten(&mut self, event: Event) -> Result<(), E>[src]

Stops listening for the specified event

Auto Trait Implementations

impl<SPI, NCS, INT, RESET> Send for Enc28j60<SPI, NCS, INT, RESET> where
    INT: Send,
    NCS: Send,
    RESET: Send,
    SPI: Send

impl<SPI, NCS, INT, RESET> Sync for Enc28j60<SPI, NCS, INT, RESET> where
    INT: Sync,
    NCS: Sync,
    RESET: Sync,
    SPI: Sync

Blanket Implementations

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]