Struct w5500_ll::SocketMode

source ·
pub struct SocketMode(/* private fields */);
Expand description

Socket Mode Register (Sn_MR).

This is used by the Registers::sn_mr and Registers::set_sn_mr methods.

Implementations§

source§

impl SocketMode

source

pub const RESET: u8 = 0u8

Reset value of the socket mode register.

source

pub const DEFAULT: Self = _

Default value.

This is the same as default, but as a const value.

Example
use w5500_ll::SocketMode;

assert_eq!(SocketMode::DEFAULT, SocketMode::default());
source

pub const MULTI_OFFSET: u8 = 7u8

Bit offset for the MULTI field.

source

pub const MFEN_OFFSET: u8 = 7u8

Bit offset for the MFEN field.

source

pub const BCASTB_OFFSET: u8 = 6u8

Bit offset for the BCASTB field.

source

pub const ND_OFFSET: u8 = 5u8

Bit offset for the ND field.

source

pub const MC_OFFSET: u8 = 5u8

Bit offset for the MC field.

source

pub const MMB_OFFSET: u8 = 5u8

Bit offset for the MMB field.

source

pub const UCASTB_OFFSET: u8 = 4u8

Bit offset for the UCASTB field.

source

pub const MIP6B_OFFSET: u8 = 4u8

Bit offset for the MIP6B field.

source

pub const MULTI_MASK: u8 = 128u8

Bit mask for the MULTI field.

source

pub const MFEN_MASK: u8 = 128u8

Bit mask for the MFEN field.

source

pub const BCASTB_MASK: u8 = 64u8

Bit mask for the BCASTB field.

source

pub const ND_MASK: u8 = 32u8

Bit mask for the ND field.

source

pub const MC_MASK: u8 = 32u8

Bit mask for the MC field.

source

pub const MMB_MASK: u8 = 32u8

Bit mask for the MMB field.

source

pub const UCASTB_MASK: u8 = 16u8

Bit mask for the UCASTB field.

source

pub const MIP6B_MASK: u8 = 16u8

Bit mask for the MIP6B field.

source

pub const PROTOCOL_MASK: u8 = 15u8

Bit mask for the PROTOCOL field.

source

pub const fn protocol(&self) -> Result<Protocol, u8>

Get the protocol.

This returns an Err(u8) with the protocol bits if the protocol bits do not match a valid protocol.

Example
use w5500_ll::{Protocol, SocketMode};

let sn_mr: SocketMode = SocketMode::DEFAULT;
assert_eq!(sn_mr.protocol(), Ok(Protocol::Closed));
source

pub const fn set_protocol(self, protocol: Protocol) -> Self

Set the protocol.

Example
use w5500_ll::{Protocol, SocketMode};

const SN_MR: SocketMode = SocketMode::DEFAULT.set_protocol(Protocol::Tcp);
assert_eq!(SN_MR.protocol(), Ok(Protocol::Tcp));
source

pub const fn multi_enabled(&self) -> bool

Multicasting.

This applies only for a socket with the UDP protocol.

To use multicasting Registers::sn_dipr and Registers::sn_dport should be configured with the multicast group IP and port number before the socket is opened.

Example
use w5500_ll::SocketMode;

let sn_mr: SocketMode = SocketMode::DEFAULT;
assert!(!sn_mr.multi_enabled());
let sn_mr: SocketMode = sn_mr.enable_multi();
assert!(sn_mr.multi_enabled());
let sn_mr: SocketMode = sn_mr.disable_multi();
assert!(!sn_mr.multi_enabled());
source

pub const fn enable_multi(self) -> Self

Enable multicasting.

source

pub const fn disable_multi(self) -> Self

Disable multicasting.

source

pub const fn mfen_enabled(&self) -> bool

MAC filter.

This applies only for a socket with the MACRAW protocol.

When enabled the W5500 can only receive broadcasting packets sent to itself. When disabled the W5500 can receive all packets. If you want to implement a hybrid TCP/IP stack it is recommended that this is enabled for reducing host overhead to process all the received packets.

Example
use w5500_ll::SocketMode;

let sn_mr: SocketMode = SocketMode::DEFAULT;
assert!(!sn_mr.mfen_enabled());
let sn_mr: SocketMode = sn_mr.enable_mfen();
assert!(sn_mr.mfen_enabled());
let sn_mr: SocketMode = sn_mr.disable_mfen();
assert!(!sn_mr.mfen_enabled());
source

pub const fn enable_mfen(self) -> Self

Enable MAC filter.

source

pub const fn disable_mfen(self) -> Self

Disable MAC filter.

source

pub const fn bcastb_enabled(&self) -> bool

Broadcast blocking.

This applies only for a socket with the MACRAW or UDP protocol.

Example
use w5500_ll::SocketMode;

let sn_mr: SocketMode = SocketMode::DEFAULT;
assert!(!sn_mr.bcastb_enabled());
let sn_mr: SocketMode = sn_mr.enable_bcastb();
assert!(sn_mr.bcastb_enabled());
let sn_mr: SocketMode = sn_mr.disable_bcastb();
assert!(!sn_mr.bcastb_enabled());
source

pub const fn enable_bcastb(self) -> Self

Enable broadcast blocking.

source

pub const fn disable_bcastb(self) -> Self

Disable broadcast blocking.

source

pub const fn nd_enabled(&self) -> bool

Use no delayed ACK.

This applies only for a socket with the TCP protocol.

When enabled the ACK packet is sent without delay as soon as a data packet is received from a peer. When disabled the ACK packet is sent after waiting for the time configured by rtr.

Example
use w5500_ll::SocketMode;

let sn_mr: SocketMode = SocketMode::DEFAULT;
assert!(!sn_mr.nd_enabled());
let sn_mr: SocketMode = sn_mr.enable_nd();
assert!(sn_mr.nd_enabled());
let sn_mr: SocketMode = sn_mr.disable_nd();
assert!(!sn_mr.nd_enabled());
source

pub const fn disable_nd(self) -> Self

Disable no delayed ACK.

source

pub const fn enable_nd(self) -> Self

Enable no delayed ACK.

source

pub const fn mc(&self) -> bool

Multicast IGMP version.

This applies only for a socket with the UDP protocol.

This field configures the version for IGMP messages (join/leave/report).

  • false IGMP version 2
  • true IGMP version 1
Example
use w5500_ll::SocketMode;

let sn_mr: SocketMode = SocketMode::DEFAULT;
assert!(!sn_mr.mc());
let sn_mr: SocketMode = sn_mr.set_igmp_v1();
assert!(sn_mr.mc());
let sn_mr: SocketMode = sn_mr.set_igmp_v2();
assert!(!sn_mr.mc());
source

pub const fn set_igmp_v1(self) -> Self

Set IGMP version 1.

source

pub const fn set_igmp_v2(self) -> Self

Set IGMP version 2.

source

pub const fn mmb_enabled(&self) -> bool

Multicast blocking.

This applies only for a socket with the MACRAW protocol.

Example
use w5500_ll::SocketMode;

let sn_mr: SocketMode = SocketMode::DEFAULT;
assert!(!sn_mr.mmb_enabled());
let sn_mr: SocketMode = sn_mr.enable_mmb();
assert!(sn_mr.mmb_enabled());
let sn_mr: SocketMode = sn_mr.disable_mmb();
assert!(!sn_mr.mmb_enabled());
source

pub const fn enable_mmb(self) -> Self

Enable multicast blocking.

source

pub const fn disable_mmb(self) -> Self

Disable multicast blocking.

source

pub const fn ucastb_enabled(&self) -> bool

Unicast blocking enabled.

This applies only for a socket with the UDP protocol.

Example
use w5500_ll::SocketMode;

let sn_mr: SocketMode = SocketMode::DEFAULT;
assert!(!sn_mr.ucastb_enabled());
let sn_mr: SocketMode = sn_mr.enable_ucastb();
assert!(sn_mr.ucastb_enabled());
let sn_mr: SocketMode = sn_mr.disable_ucastb();
assert!(!sn_mr.ucastb_enabled());
source

pub const fn enable_ucastb(self) -> Self

Enable unicast blocking.

source

pub const fn disable_ucastb(self) -> Self

Disable unicast blocking.

source

pub const fn mip6b_enabled(&self) -> bool

IPV6 packet blocking.

This applies only for a socket with the MACRAW protocol.

Example
use w5500_ll::SocketMode;

let sn_mr: SocketMode = SocketMode::DEFAULT;
assert!(!sn_mr.mip6b_enabled());
let sn_mr: SocketMode = sn_mr.enable_mip6b();
assert!(sn_mr.mip6b_enabled());
let sn_mr: SocketMode = sn_mr.disable_mip6b();
assert!(!sn_mr.mip6b_enabled());
source

pub const fn enable_mip6b(self) -> Self

Enable IPV6 packet blocking.

source

pub const fn disable_mip6b(self) -> Self

Disable IPV6 packet blocking.

Trait Implementations§

source§

impl Clone for SocketMode

source§

fn clone(&self) -> SocketMode

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 SocketMode

source§

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

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

impl Default for SocketMode

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Display for SocketMode

source§

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

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

impl Format for SocketMode

Available on crate feature defmt only.
source§

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

Writes the defmt representation of self to fmt.
source§

impl From<SocketMode> for u8

source§

fn from(val: SocketMode) -> u8

Converts to this type from the input type.
source§

impl From<u8> for SocketMode

source§

fn from(val: u8) -> Self

Converts to this type from the input type.
source§

impl PartialEq for SocketMode

source§

fn eq(&self, other: &SocketMode) -> 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 Copy for SocketMode

source§

impl Eq for SocketMode

source§

impl StructuralEq for SocketMode

source§

impl StructuralPartialEq for SocketMode

Auto Trait Implementations§

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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. 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.