Enum w5500_ll::Sn[][src]

#[repr(u8)]
pub enum Sn {
    Sn0,
    Sn1,
    Sn2,
    Sn3,
    Sn4,
    Sn5,
    Sn6,
    Sn7,
}
Expand description

W5500 socket numbers.

Variants

Sn0

Socket 0.

This is the only socket that can be used in the Macraw mode.

Sn1

Socket 1.

Sn2

Socket 2.

Sn3

Socket 3.

Sn4

Socket 4.

Sn5

Socket 5.

Sn6

Socket 6.

Sn7

Socket 7.

Implementations

Get the socket register block select bits.

Example
use w5500_ll::Sn;

assert_eq!(Sn::Sn0.block(), 0b00001);
assert_eq!(Sn::Sn1.block(), 0b00101);
assert_eq!(Sn::Sn2.block(), 0b01001);
assert_eq!(Sn::Sn3.block(), 0b01101);
assert_eq!(Sn::Sn4.block(), 0b10001);
assert_eq!(Sn::Sn5.block(), 0b10101);
assert_eq!(Sn::Sn6.block(), 0b11001);
assert_eq!(Sn::Sn7.block(), 0b11101);

Get the socket TX buffer block select bits.

Example
use w5500_ll::Sn;

assert_eq!(Sn::Sn0.tx_block(), 0b00010);
assert_eq!(Sn::Sn1.tx_block(), 0b00110);
assert_eq!(Sn::Sn2.tx_block(), 0b01010);
assert_eq!(Sn::Sn3.tx_block(), 0b01110);
assert_eq!(Sn::Sn4.tx_block(), 0b10010);
assert_eq!(Sn::Sn5.tx_block(), 0b10110);
assert_eq!(Sn::Sn6.tx_block(), 0b11010);
assert_eq!(Sn::Sn7.tx_block(), 0b11110);

Get the socket RX buffer block select bits.

Example
use w5500_ll::Sn;

assert_eq!(Sn::Sn0.rx_block(), 0b00011);
assert_eq!(Sn::Sn1.rx_block(), 0b00111);
assert_eq!(Sn::Sn2.rx_block(), 0b01011);
assert_eq!(Sn::Sn3.rx_block(), 0b01111);
assert_eq!(Sn::Sn4.rx_block(), 0b10011);
assert_eq!(Sn::Sn5.rx_block(), 0b10111);
assert_eq!(Sn::Sn6.rx_block(), 0b11011);
assert_eq!(Sn::Sn7.rx_block(), 0b11111);

Socket bitmask.

This is useful for masking socket interrupts with set_simr.

Examples

Demonstration:

use w5500_ll::Sn;

assert_eq!(Sn::Sn0.bitmask(), 0x01);
assert_eq!(Sn::Sn1.bitmask(), 0x02);
assert_eq!(Sn::Sn2.bitmask(), 0x04);
assert_eq!(Sn::Sn3.bitmask(), 0x08);
assert_eq!(Sn::Sn4.bitmask(), 0x10);
assert_eq!(Sn::Sn5.bitmask(), 0x20);
assert_eq!(Sn::Sn6.bitmask(), 0x40);
assert_eq!(Sn::Sn7.bitmask(), 0x80);

As an argument of set_simr:

use w5500_ll::{
    blocking::vdm::W5500,
    Registers,
    Sn::{Sn1, Sn3},
};

let mut w5500 = W5500::new(spi, pin);
// enable socket 1 and socket 3 interrupts
const SOCKET_INTERRUPT_MASK: u8 = Sn1.bitmask() | Sn3.bitmask();
w5500.set_simr(SOCKET_INTERRUPT_MASK)?;

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Writes the defmt representation of self to fmt.

Performs the conversion.

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

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

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.