Enum w5500_ll::Sn

source ·
#[repr(u8)]
pub enum Sn { Sn0 = 0, Sn1 = 1, Sn2 = 2, Sn3 = 3, Sn4 = 4, Sn5 = 5, Sn6 = 6, Sn7 = 7, }
Expand description

W5500 socket numbers.

Variants§

§

Sn0 = 0

Socket 0.

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

§

Sn1 = 1

Socket 1.

§

Sn2 = 2

Socket 2.

§

Sn3 = 3

Socket 3.

§

Sn4 = 4

Socket 4.

§

Sn5 = 5

Socket 5.

§

Sn6 = 6

Socket 6.

§

Sn7 = 7

Socket 7.

Implementations§

source§

impl Sn

source

pub const fn block(self) -> u8

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);
source

pub const fn tx_block(self) -> u8

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);
source

pub const fn rx_block(self) -> u8

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);
source

pub const fn bitmask(self) -> u8

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::{
    eh1::vdm::W5500,
    Registers,
    Sn::{Sn1, Sn3},
};

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

pub fn iter() -> Iter<'static, Self>

Iterate over all sockets.

Example

Check all sockets for a pending interrupt.

use w5500_ll::{eh1::vdm::W5500, Registers, Sn, SocketCommand};

let mut w5500 = W5500::new(spi);

let sir: u8 = w5500.sir()?;
for sn in Sn::iter() {
    let mask: u8 = sn.bitmask();
    if sir & sn.bitmask() != 0 {
        // handle socket interrupt
    }
}

Trait Implementations§

source§

impl Clone for Sn

source§

fn clone(&self) -> Sn

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Sn

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Format for Sn

source§

fn format(&self, f: Formatter<'_>)

Writes the defmt representation of self to fmt.
source§

impl From<Sn> for i128

source§

fn from(s: Sn) -> Self

Converts to this type from the input type.
source§

impl From<Sn> for i16

source§

fn from(s: Sn) -> Self

Converts to this type from the input type.
source§

impl From<Sn> for i32

source§

fn from(s: Sn) -> Self

Converts to this type from the input type.
source§

impl From<Sn> for i64

source§

fn from(s: Sn) -> Self

Converts to this type from the input type.
source§

impl From<Sn> for i8

source§

fn from(s: Sn) -> Self

Converts to this type from the input type.
source§

impl From<Sn> for isize

source§

fn from(s: Sn) -> Self

Converts to this type from the input type.
source§

impl From<Sn> for u128

source§

fn from(s: Sn) -> Self

Converts to this type from the input type.
source§

impl From<Sn> for u16

source§

fn from(s: Sn) -> Self

Converts to this type from the input type.
source§

impl From<Sn> for u32

source§

fn from(s: Sn) -> Self

Converts to this type from the input type.
source§

impl From<Sn> for u64

source§

fn from(s: Sn) -> Self

Converts to this type from the input type.
source§

impl From<Sn> for u8

source§

fn from(s: Sn) -> Self

Converts to this type from the input type.
source§

impl From<Sn> for usize

source§

fn from(s: Sn) -> Self

Converts to this type from the input type.
source§

impl Hash for Sn

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

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

impl Ord for Sn

source§

fn cmp(&self, other: &Sn) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Sn

source§

fn eq(&self, other: &Sn) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Sn

source§

fn partial_cmp(&self, other: &Sn) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

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

fn le(&self, other: &Rhs) -> bool

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

fn gt(&self, other: &Rhs) -> bool

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

fn ge(&self, other: &Rhs) -> bool

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

impl TryFrom<i128> for Sn

§

type Error = i128

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

fn try_from(val: i128) -> Result<Sn, i128>

Performs the conversion.
source§

impl TryFrom<i16> for Sn

§

type Error = i16

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

fn try_from(val: i16) -> Result<Sn, i16>

Performs the conversion.
source§

impl TryFrom<i32> for Sn

§

type Error = i32

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

fn try_from(val: i32) -> Result<Sn, i32>

Performs the conversion.
source§

impl TryFrom<i64> for Sn

§

type Error = i64

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

fn try_from(val: i64) -> Result<Sn, i64>

Performs the conversion.
source§

impl TryFrom<i8> for Sn

§

type Error = i8

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

fn try_from(val: i8) -> Result<Sn, i8>

Performs the conversion.
source§

impl TryFrom<isize> for Sn

§

type Error = isize

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

fn try_from(val: isize) -> Result<Sn, isize>

Performs the conversion.
source§

impl TryFrom<u128> for Sn

§

type Error = u128

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

fn try_from(val: u128) -> Result<Sn, u128>

Performs the conversion.
source§

impl TryFrom<u16> for Sn

§

type Error = u16

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

fn try_from(val: u16) -> Result<Sn, u16>

Performs the conversion.
source§

impl TryFrom<u32> for Sn

§

type Error = u32

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

fn try_from(val: u32) -> Result<Sn, u32>

Performs the conversion.
source§

impl TryFrom<u64> for Sn

§

type Error = u64

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

fn try_from(val: u64) -> Result<Sn, u64>

Performs the conversion.
source§

impl TryFrom<u8> for Sn

§

type Error = u8

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

fn try_from(val: u8) -> Result<Sn, u8>

Performs the conversion.
source§

impl TryFrom<usize> for Sn

§

type Error = usize

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

fn try_from(val: usize) -> Result<Sn, usize>

Performs the conversion.
source§

impl Copy for Sn

source§

impl Eq for Sn

source§

impl StructuralEq for Sn

source§

impl StructuralPartialEq for Sn

Auto Trait Implementations§

§

impl RefUnwindSafe for Sn

§

impl Send for Sn

§

impl Sync for Sn

§

impl Unpin for Sn

§

impl UnwindSafe for Sn

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

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

§

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 Twhere U: TryFrom<T>,

§

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.