[][src]Struct w5500_ll::SocketMode

pub struct SocketMode(_);

Socket Mode Register (Sn_MR).

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

Implementations

impl SocketMode[src]

pub const RESET: u8[src]

Reset value of the socket mode register.

pub const MULTI_OFFSET: u8[src]

Bit offset for the MULTI field.

pub const MFEN_OFFSET: u8[src]

Bit offset for the MFEN field.

pub const BCASTB_OFFSET: u8[src]

Bit offset for the BCASTB field.

pub const ND_OFFSET: u8[src]

Bit offset for the ND field.

pub const MC_OFFSET: u8[src]

Bit offset for the MC field.

pub const MMB_OFFSET: u8[src]

Bit offset for the MMB field.

pub const UCASTB_OFFSET: u8[src]

Bit offset for the UCASTB field.

pub const MIP6B_OFFSET: u8[src]

Bit offset for the MIP6B field.

pub const MULTI_MASK: u8[src]

Bit mask for the MULTI field.

pub const MFEN_MASK: u8[src]

Bit mask for the MFEN field.

pub const BCASTB_MASK: u8[src]

Bit mask for the BCASTB field.

pub const ND_MASK: u8[src]

Bit mask for the ND field.

pub const MC_MASK: u8[src]

Bit mask for the MC field.

pub const MMB_MASK: u8[src]

Bit mask for the MMB field.

pub const UCASTB_MASK: u8[src]

Bit mask for the UCASTB field.

pub const MIP6B_MASK: u8[src]

Bit mask for the MIP6B field.

pub const PROTOCOL_MASK: u8[src]

Bit mask for the PROTOCOL field.

pub fn protocol(&self) -> Result<Protocol, u8>[src]

Get the protocol.

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

Example

use w5500_ll::{Protocol, SocketMode};

let mode: SocketMode = SocketMode::default();
assert_eq!(mode.protocol(), Ok(Protocol::Closed));

pub fn set_protocol(&mut self, protocol: Protocol)[src]

Set the protocol.

Example

use w5500_ll::{Protocol, SocketMode};

let mut mode: SocketMode = SocketMode::default();
mode.set_protocol(Protocol::Tcp);
assert_eq!(mode.protocol(), Ok(Protocol::Tcp));

pub const fn multi_enabled(&self) -> bool[src]

Multicasting.

This applies only for a socket with the UDP protocol.

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

Example

let mut sn_mr = w5500_ll::SocketMode::default();
assert!(!sn_mr.multi_enabled());
sn_mr.enable_multi();
assert!(sn_mr.multi_enabled());
sn_mr.disable_multi();
assert!(!sn_mr.multi_enabled());

pub fn enable_multi(&mut self)[src]

Enable multicasting.

See SocketMode::multi_enabled for more information.

pub fn disable_multi(&mut self)[src]

Disable multicasting.

See SocketMode::multi_enabled for more information.

pub const fn mfen_enabled(&self) -> bool[src]

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

let mut sn_mr = w5500_ll::SocketMode::default();
assert!(!sn_mr.mfen_enabled());
sn_mr.enable_mfen();
assert!(sn_mr.mfen_enabled());
sn_mr.disable_mfen();
assert!(!sn_mr.mfen_enabled());

pub fn enable_mfen(&mut self)[src]

Enable MAC filter.

See SocketMode::mfen_enabled for more information.

pub fn disable_mfen(&mut self)[src]

Disable MAC filter.

See SocketMode::mfen_enabled for more information.

pub const fn bcastb_enabled(&self) -> bool[src]

Broadcast blocking.

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

Example

let mut sn_mr = w5500_ll::SocketMode::default();
assert!(!sn_mr.bcastb_enabled());
sn_mr.enable_bcastb();
assert!(sn_mr.bcastb_enabled());
sn_mr.disable_bcastb();
assert!(!sn_mr.bcastb_enabled());

pub fn enable_bcastb(&mut self)[src]

Enable broadcast blocking.

See SocketMode::bcastb_enabled for more information.

pub fn disable_bcastb(&mut self)[src]

Disable broadcast blocking.

See SocketMode::bcastb_enabled for more information.

pub const fn nd_enabled(&self) -> bool[src]

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 crate::Registers::rtr.

Example

let mut sn_mr = w5500_ll::SocketMode::default();
assert!(!sn_mr.nd_enabled());
sn_mr.enable_nd();
assert!(sn_mr.nd_enabled());
sn_mr.disable_nd();
assert!(!sn_mr.nd_enabled());

pub fn disable_nd(&mut self)[src]

Disable no delayed ACK.

See SocketMode::nd_enabled for more information.

pub fn enable_nd(&mut self)[src]

Enable no delayed ACK.

See SocketMode::nd_enabled for more information.

pub const fn mc(&self) -> bool[src]

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

let mut sn_mr = w5500_ll::SocketMode::default();
assert!(!sn_mr.mc());
sn_mr.set_igmp_v1();
assert!(sn_mr.mc());
sn_mr.set_igmp_v2();
assert!(!sn_mr.mc());

pub fn set_igmp_v1(&mut self)[src]

Set IGMP version 1.

See SocketMode::mc for more information.

pub fn set_igmp_v2(&mut self)[src]

Set IGMP version 2.

See SocketMode::mc for more information.

pub const fn mmb_enabled(&self) -> bool[src]

Multicast blocking.

This applies only for a socket with the MACRAW protocol.

Example

let mut sn_mr = w5500_ll::SocketMode::default();
assert!(!sn_mr.mmb_enabled());
sn_mr.enable_mmb();
assert!(sn_mr.mmb_enabled());
sn_mr.disable_mmb();
assert!(!sn_mr.mmb_enabled());

pub fn enable_mmb(&mut self)[src]

Enable multicast blocking.

See SocketMode::mmb_enabled for more information.

pub fn disable_mmb(&mut self)[src]

Disable multicast blocking.

See SocketMode::mmb_enabled for more information.

pub const fn ucastb_enabled(&self) -> bool[src]

Unicast blocking enabled.

This applies only for a socket with the UDP protocol.

Example

let mut sn_mr = w5500_ll::SocketMode::default();
assert!(!sn_mr.ucastb_enabled());
sn_mr.enable_ucastb();
assert!(sn_mr.ucastb_enabled());
sn_mr.disable_ucastb();
assert!(!sn_mr.ucastb_enabled());

pub fn enable_ucastb(&mut self)[src]

Enable unicast blocking.

See SocketMode::ucastb_enabled for more information.

pub fn disable_ucastb(&mut self)[src]

Disable unicast blocking.

See SocketMode::ucastb_enabled for more information.

pub const fn mip6b_enabled(&self) -> bool[src]

IPV6 packet blocking.

This applies only for a socket with the MACRAW protocol.

Example

let mut sn_mr = w5500_ll::SocketMode::default();
assert!(!sn_mr.mip6b_enabled());
sn_mr.enable_mip6b();
assert!(sn_mr.mip6b_enabled());
sn_mr.disable_mip6b();
assert!(!sn_mr.mip6b_enabled());

pub fn enable_mip6b(&mut self)[src]

Enable unicast blocking.

See SocketMode::mip6b_enabled for more information.

pub fn disable_mip6b(&mut self)[src]

Disable unicast blocking.

See SocketMode::mip6b_enabled for more information.

Trait Implementations

impl Clone for SocketMode[src]

impl Copy for SocketMode[src]

impl Debug for SocketMode[src]

impl Default for SocketMode[src]

impl Eq for SocketMode[src]

impl From<u8> for SocketMode[src]

impl PartialEq<SocketMode> for SocketMode[src]

impl StructuralEq for SocketMode[src]

impl StructuralPartialEq for SocketMode[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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

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

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.

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.