Enum w5500_ll::Socket[][src]

#[repr(u8)]
pub enum Socket {
    Socket0,
    Socket1,
    Socket2,
    Socket3,
    Socket4,
    Socket5,
    Socket6,
    Socket7,
}

W5500 sockets.

Variants

Socket0

Socket 0.

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

Socket1

Socket 1.

Socket2

Socket 2.

Socket3

Socket 3.

Socket4

Socket 4.

Socket5

Socket 5.

Socket6

Socket 6.

Socket7

Socket 7.

Implementations

impl Socket[src]

pub const fn block(self) -> u8[src]

Get the socket register block select bits.

Example

use w5500_ll::Socket;

assert_eq!(Socket::Socket0.block(), 0b00001);
assert_eq!(Socket::Socket1.block(), 0b00101);
assert_eq!(Socket::Socket2.block(), 0b01001);
assert_eq!(Socket::Socket3.block(), 0b01101);
assert_eq!(Socket::Socket4.block(), 0b10001);
assert_eq!(Socket::Socket5.block(), 0b10101);
assert_eq!(Socket::Socket6.block(), 0b11001);
assert_eq!(Socket::Socket7.block(), 0b11101);

pub const fn tx_block(self) -> u8[src]

Get the socket TX buffer block select bits.

Example

use w5500_ll::Socket;

assert_eq!(Socket::Socket0.tx_block(), 0b00010);
assert_eq!(Socket::Socket1.tx_block(), 0b00110);
assert_eq!(Socket::Socket2.tx_block(), 0b01010);
assert_eq!(Socket::Socket3.tx_block(), 0b01110);
assert_eq!(Socket::Socket4.tx_block(), 0b10010);
assert_eq!(Socket::Socket5.tx_block(), 0b10110);
assert_eq!(Socket::Socket6.tx_block(), 0b11010);
assert_eq!(Socket::Socket7.tx_block(), 0b11110);

pub const fn rx_block(self) -> u8[src]

Get the socket RX buffer block select bits.

Example

use w5500_ll::Socket;

assert_eq!(Socket::Socket0.rx_block(), 0b00011);
assert_eq!(Socket::Socket1.rx_block(), 0b00111);
assert_eq!(Socket::Socket2.rx_block(), 0b01011);
assert_eq!(Socket::Socket3.rx_block(), 0b01111);
assert_eq!(Socket::Socket4.rx_block(), 0b10011);
assert_eq!(Socket::Socket5.rx_block(), 0b10111);
assert_eq!(Socket::Socket6.rx_block(), 0b11011);
assert_eq!(Socket::Socket7.rx_block(), 0b11111);

pub const fn bitmask(self) -> u8[src]

Socket bitmask.

This is useful for masking socket interrupts with set_simr.

Examples

Demonstration:

use w5500_ll::Socket;

assert_eq!(Socket::Socket0.bitmask(), 0x01);
assert_eq!(Socket::Socket1.bitmask(), 0x02);
assert_eq!(Socket::Socket2.bitmask(), 0x04);
assert_eq!(Socket::Socket3.bitmask(), 0x08);
assert_eq!(Socket::Socket4.bitmask(), 0x10);
assert_eq!(Socket::Socket5.bitmask(), 0x20);
assert_eq!(Socket::Socket6.bitmask(), 0x40);
assert_eq!(Socket::Socket7.bitmask(), 0x80);

As an argument of set_simr:

use w5500_ll::{
    blocking::vdm::W5500,
    Registers,
    Socket::{Socket1, Socket3},
};

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

Trait Implementations

impl Clone for Socket[src]

fn clone(&self) -> Socket[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Socket[src]

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

Formats the value using the given formatter. Read more

impl Hash for Socket[src]

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

Feeds this value into the given Hasher. Read more

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

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

impl Ord for Socket[src]

fn cmp(&self, other: &Socket) -> Ordering[src]

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

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl PartialEq<Socket> for Socket[src]

fn eq(&self, other: &Socket) -> bool[src]

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

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl PartialOrd<Socket> for Socket[src]

fn partial_cmp(&self, other: &Socket) -> Option<Ordering>[src]

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

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

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

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

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

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

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

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

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

impl TryFrom<u8> for Socket[src]

type Error = u8

The type returned in the event of a conversion error.

fn try_from(val: u8) -> Result<Socket, u8>[src]

Performs the conversion.

impl Copy for Socket[src]

impl Eq for Socket[src]

impl StructuralEq for Socket[src]

impl StructuralPartialEq for Socket[src]

Auto Trait Implementations

impl RefUnwindSafe for Socket

impl Send for Socket

impl Sync for Socket

impl Unpin for Socket

impl UnwindSafe for Socket

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

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

recently added

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

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

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

The type returned in the event of a conversion error.

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

Performs the conversion.