Trait w5500_ll::Registers [−][src]
pub trait Registers { type Error;}Show methods
fn read(
&mut self,
address: u16,
block: u8,
data: &mut [u8]
) -> Result<(), Self::Error>; fn write(
&mut self,
address: u16,
block: u8,
data: &[u8]
) -> Result<(), Self::Error>; fn mr(&mut self) -> Result<Mode, Self::Error> { ... } fn set_mr(&mut self, mode: Mode) -> Result<(), Self::Error> { ... } fn gar(&mut self) -> Result<Ipv4Addr, Self::Error> { ... } fn set_gar(&mut self, gar: &Ipv4Addr) -> Result<(), Self::Error> { ... } fn subr(&mut self) -> Result<Ipv4Addr, Self::Error> { ... } fn set_subr(&mut self, subr: &Ipv4Addr) -> Result<(), Self::Error> { ... } fn shar(&mut self) -> Result<Eui48Addr, Self::Error> { ... } fn set_shar(&mut self, shar: &Eui48Addr) -> Result<(), Self::Error> { ... } fn sipr(&mut self) -> Result<Ipv4Addr, Self::Error> { ... } fn set_sipr(&mut self, sipr: &Ipv4Addr) -> Result<(), Self::Error> { ... } fn intlevel(&mut self) -> Result<u16, Self::Error> { ... } fn set_intlevel(&mut self, intlevel: u16) -> Result<(), Self::Error> { ... } fn ir(&mut self) -> Result<Interrupt, Self::Error> { ... } fn set_ir(&mut self, interrupt: Interrupt) -> Result<(), Self::Error> { ... } fn imr(&mut self) -> Result<Interrupt, Self::Error> { ... } fn set_imr(&mut self, mask: Interrupt) -> Result<(), Self::Error> { ... } fn sir(&mut self) -> Result<u8, Self::Error> { ... } fn simr(&mut self) -> Result<u8, Self::Error> { ... } fn set_simr(&mut self, simr: u8) -> Result<(), Self::Error> { ... } fn rtr(&mut self) -> Result<u16, Self::Error> { ... } fn set_rtr(&mut self, rtr: u16) -> Result<(), Self::Error> { ... } fn rcr(&mut self) -> Result<u8, Self::Error> { ... } fn set_rcr(&mut self, rcr: u8) -> Result<(), Self::Error> { ... } fn ptimer(&mut self) -> Result<u8, Self::Error> { ... } fn set_ptimer(&mut self, ptimer: u8) -> Result<(), Self::Error> { ... } fn pmagic(&mut self) -> Result<u8, Self::Error> { ... } fn set_pmagic(&mut self, pmagic: u8) -> Result<(), Self::Error> { ... } fn phar(&mut self) -> Result<Eui48Addr, Self::Error> { ... } fn set_phar(&mut self, phar: &Eui48Addr) -> Result<(), Self::Error> { ... } fn psid(&mut self) -> Result<u16, Self::Error> { ... } fn set_psid(&mut self, psid: u16) -> Result<(), Self::Error> { ... } fn pmru(&mut self) -> Result<u16, Self::Error> { ... } fn set_pmru(&mut self, pmru: u16) -> Result<(), Self::Error> { ... } fn uipr(&mut self) -> Result<Ipv4Addr, Self::Error> { ... } fn uportr(&mut self) -> Result<u16, Self::Error> { ... } fn phycfgr(&mut self) -> Result<PhyCfg, Self::Error> { ... } fn set_phycfgr(&mut self, phycfg: PhyCfg) -> Result<(), Self::Error> { ... } fn version(&mut self) -> Result<u8, Self::Error> { ... } fn sn_mr(&mut self, socket: Socket) -> Result<SocketMode, Self::Error> { ... } fn set_sn_mr(
&mut self,
socket: Socket,
mode: SocketMode
) -> Result<(), Self::Error> { ... } fn sn_cr(&mut self, socket: Socket) -> Result<u8, Self::Error> { ... } fn set_sn_cr(
&mut self,
socket: Socket,
cmd: SocketCommand
) -> Result<(), Self::Error> { ... } fn sn_ir(&mut self, socket: Socket) -> Result<SocketInterrupt, Self::Error> { ... } fn set_sn_ir<T: Into<u8>>(
&mut self,
socket: Socket,
sn_ir: T
) -> Result<(), Self::Error> { ... } fn sn_sr(
&mut self,
socket: Socket
) -> Result<Result<SocketStatus, u8>, Self::Error> { ... } fn sn_port(&mut self, socket: Socket) -> Result<u16, Self::Error> { ... } fn set_sn_port(
&mut self,
socket: Socket,
port: u16
) -> Result<(), Self::Error> { ... } fn sn_dhar(&mut self, socket: Socket) -> Result<Eui48Addr, Self::Error> { ... } fn set_sn_dhar(
&mut self,
socket: Socket,
dhar: &Eui48Addr
) -> Result<(), Self::Error> { ... } fn sn_dipr(&mut self, socket: Socket) -> Result<Ipv4Addr, Self::Error> { ... } fn set_sn_dipr(
&mut self,
socket: Socket,
dipr: &Ipv4Addr
) -> Result<(), Self::Error> { ... } fn sn_dport(&mut self, socket: Socket) -> Result<u16, Self::Error> { ... } fn set_sn_dport(
&mut self,
socket: Socket,
port: u16
) -> Result<(), Self::Error> { ... } fn sn_dest(&mut self, socket: Socket) -> Result<SocketAddrV4, Self::Error> { ... } fn set_sn_dest(
&mut self,
socket: Socket,
addr: &SocketAddrV4
) -> Result<(), Self::Error> { ... } fn sn_mssr(&mut self, socket: Socket) -> Result<u16, Self::Error> { ... } fn set_sn_mssr(
&mut self,
socket: Socket,
mssr: u16
) -> Result<(), Self::Error> { ... } fn sn_tos(&mut self, socket: Socket) -> Result<u8, Self::Error> { ... } fn set_sn_tos(&mut self, socket: Socket, tos: u8) -> Result<(), Self::Error> { ... } fn sn_ttl(&mut self, socket: Socket) -> Result<u8, Self::Error> { ... } fn set_sn_ttl(&mut self, socket: Socket, ttl: u8) -> Result<(), Self::Error> { ... } fn sn_rxbuf_size(
&mut self,
socket: Socket
) -> Result<Result<BufferSize, u8>, Self::Error> { ... } fn set_sn_rxbuf_size(
&mut self,
socket: Socket,
size: BufferSize
) -> Result<(), Self::Error> { ... } fn sn_txbuf_size(
&mut self,
socket: Socket
) -> Result<Result<BufferSize, u8>, Self::Error> { ... } fn set_sn_txbuf_size(
&mut self,
socket: Socket,
size: BufferSize
) -> Result<(), Self::Error> { ... } fn sn_tx_fsr(&mut self, socket: Socket) -> Result<u16, Self::Error> { ... } fn sn_tx_rd(&mut self, socket: Socket) -> Result<u16, Self::Error> { ... } fn sn_tx_wr(&mut self, socket: Socket) -> Result<u16, Self::Error> { ... } fn set_sn_tx_wr(
&mut self,
socket: Socket,
ptr: u16
) -> Result<(), Self::Error> { ... } fn sn_rx_rsr(&mut self, socket: Socket) -> Result<u16, Self::Error> { ... } fn sn_rx_rd(&mut self, socket: Socket) -> Result<u16, Self::Error> { ... } fn set_sn_rx_rd(
&mut self,
socket: Socket,
ptr: u16
) -> Result<(), Self::Error> { ... } fn sn_rx_wr(&mut self, socket: Socket) -> Result<u16, Self::Error> { ... } fn sn_imr(
&mut self,
socket: Socket
) -> Result<SocketInterruptMask, Self::Error> { ... } fn set_sn_imr(
&mut self,
socket: Socket,
mask: SocketInterruptMask
) -> Result<(), Self::Error> { ... } fn sn_frag(&mut self, socket: Socket) -> Result<u16, Self::Error> { ... } fn set_sn_frag(
&mut self,
socket: Socket,
frag: u16
) -> Result<(), Self::Error> { ... } fn sn_kpalvtr(&mut self, socket: Socket) -> Result<u8, Self::Error> { ... } fn set_sn_kpalvtr(
&mut self,
socket: Socket,
kpalvtr: u8
) -> Result<(), Self::Error> { ... } fn set_sn_tx_buf(
&mut self,
socket: Socket,
ptr: u16,
buf: &[u8]
) -> Result<(), Self::Error> { ... } fn sn_rx_buf(
&mut self,
socket: Socket,
ptr: u16,
buf: &mut [u8]
) -> Result<(), Self::Error> { ... }
W5500 register setters and getters.
- All register getters are simply the name of the register.
- All register setters are the name of the register prefixed with
set_
.
Most of the register documentation is taken from the data sheet.
Associated Types
Loading content...Required methods
fn read(
&mut self,
address: u16,
block: u8,
data: &mut [u8]
) -> Result<(), Self::Error>
[src]
&mut self,
address: u16,
block: u8,
data: &mut [u8]
) -> Result<(), Self::Error>
Read from the W5500.
Arguments
address
- Starting address of the memory being read.block
- W5500 block select bitsdata
- Buffer to read data into. The number of bytes read is equal to the length of this buffer.
fn write(
&mut self,
address: u16,
block: u8,
data: &[u8]
) -> Result<(), Self::Error>
[src]
&mut self,
address: u16,
block: u8,
data: &[u8]
) -> Result<(), Self::Error>
Write to the W5500.
Arguments
address
- Starting address of the memory being written.block
- W5500 block select bitsdata
- Buffer of data to write. The number of bytes written is equal to the length of this buffer.
Provided methods
fn mr(&mut self) -> Result<Mode, Self::Error>
[src]
Get the mode register.
Example
use w5500_ll::{blocking::vdm::W5500, Mode, Registers}; let mut w5500 = W5500::new(spi, pin); let mode: Mode = w5500.mr()?; assert_eq!(mode, Mode::default());
fn set_mr(&mut self, mode: Mode) -> Result<(), Self::Error>
[src]
Set the mode register.
Example
use w5500_ll::{blocking::vdm::W5500, Mode, Registers}; let mut mode: Mode = Mode::default(); mode.enable_wol(); let mut w5500 = W5500::new(spi, pin); w5500.set_mr(mode)?;
fn gar(&mut self) -> Result<Ipv4Addr, Self::Error>
[src]
Get the gateway IP address.
Example
use w5500_ll::{blocking::vdm::W5500, net::Ipv4Addr, Registers}; let mut w5500 = W5500::new(spi, pin); let gar = w5500.gar()?; assert_eq!(gar, Ipv4Addr::UNSPECIFIED);
fn set_gar(&mut self, gar: &Ipv4Addr) -> Result<(), Self::Error>
[src]
Set the gateway IP address.
Example
use w5500_ll::{blocking::vdm::W5500, net::Ipv4Addr, Registers}; let mut w5500 = W5500::new(spi, pin); w5500.set_gar(&Ipv4Addr::new(192, 168, 0, 1))?;
fn subr(&mut self) -> Result<Ipv4Addr, Self::Error>
[src]
Get the subnet mask.
Example
use w5500_ll::{blocking::vdm::W5500, net::Ipv4Addr, Registers}; let mut w5500 = W5500::new(spi, pin); let subr = w5500.subr()?; assert_eq!(subr, Ipv4Addr::UNSPECIFIED);
fn set_subr(&mut self, subr: &Ipv4Addr) -> Result<(), Self::Error>
[src]
Set the subnet mask.
Example
use w5500_ll::{blocking::vdm::W5500, net::Ipv4Addr, Registers}; let mut w5500 = W5500::new(spi, pin); w5500.set_subr(&Ipv4Addr::new(255, 255, 255, 0))?;
fn shar(&mut self) -> Result<Eui48Addr, Self::Error>
[src]
Get the source hardware address.
Example
use w5500_ll::{blocking::vdm::W5500, net::Eui48Addr, Registers}; let mut w5500 = W5500::new(spi, pin); let shar = w5500.shar()?; assert_eq!(shar, Eui48Addr::UNSPECIFIED);
fn set_shar(&mut self, shar: &Eui48Addr) -> Result<(), Self::Error>
[src]
Set the source hardware address.
Example
use w5500_ll::{blocking::vdm::W5500, net::Eui48Addr, Registers}; let mut w5500 = W5500::new(spi, pin); w5500.set_shar(&Eui48Addr::new(0x12, 0x34, 0x00, 0x00, 0x00, 0x00))?;
fn sipr(&mut self) -> Result<Ipv4Addr, Self::Error>
[src]
Get the source (client) IP address.
Example
use w5500_ll::{blocking::vdm::W5500, net::Ipv4Addr, Registers}; let mut w5500 = W5500::new(spi, pin); let sipr = w5500.sipr()?; assert_eq!(sipr, Ipv4Addr::UNSPECIFIED);
fn set_sipr(&mut self, sipr: &Ipv4Addr) -> Result<(), Self::Error>
[src]
Set the source (client) IP address.
Example
use w5500_ll::{blocking::vdm::W5500, net::Ipv4Addr, Registers}; let mut w5500 = W5500::new(spi, pin); w5500.set_sipr(&Ipv4Addr::new(192, 168, 0, 150))?;
fn intlevel(&mut self) -> Result<u16, Self::Error>
[src]
Get the interrupt low level time.
INTLEVEL configures the assert wait time (IAWT).
When the next interrupt occurs, the interrupt in (INTn) will assert to low after INTLEVEL time.
The equation is:
IAWT = (INTLEVEL + 1) * PLLCLK * 4
When INTLEVEL > 0.
You might want to take a look at the data sheet, there is a handy timing diagram there.
Example
use w5500_ll::{blocking::vdm::W5500, Registers}; let mut w5500 = W5500::new(spi, pin); let intlevel: u16 = w5500.intlevel()?; assert_eq!(intlevel, 0x00);
fn set_intlevel(&mut self, intlevel: u16) -> Result<(), Self::Error>
[src]
Set the interrupt low level time.
See Registers::intlevel
for more information.
Example
use w5500_ll::{blocking::vdm::W5500, Registers}; let mut w5500 = W5500::new(spi, pin); w5500.set_intlevel(0x1234)?;
fn ir(&mut self) -> Result<Interrupt, Self::Error>
[src]
Get the interrupt status.
1
indicates the interrupt is raised.
Example
use w5500_ll::{blocking::vdm::W5500, Interrupt, Registers}; let mut w5500 = W5500::new(spi, pin); let ir: Interrupt = w5500.ir()?; assert_eq!(ir, Interrupt::default());
fn set_ir(&mut self, interrupt: Interrupt) -> Result<(), Self::Error>
[src]
Set the interrupt status.
Setting an interrupt bit to 1
will clear the interrupt.
Example
use w5500_ll::{blocking::vdm::W5500, Interrupt, Registers}; let mut w5500 = W5500::new(spi, pin); let ir: Interrupt = w5500.ir()?; w5500.set_ir(ir)?;
fn imr(&mut self) -> Result<Interrupt, Self::Error>
[src]
Get the interrupt mask.
0
indicates the interrupt is masked.
Example
use w5500_ll::{blocking::vdm::W5500, Interrupt, Registers}; let mut w5500 = W5500::new(spi, pin); let imr: Interrupt = w5500.imr()?; assert_eq!(imr, Interrupt::default());
fn set_imr(&mut self, mask: Interrupt) -> Result<(), Self::Error>
[src]
Set the interrupt mask.
Setting an interrupt bit to 1
will mask the interrupt.
When a bit of IMR is 1
and the corresponding interrupt is 1
an
interrupt will be issued.
If a bit of IMR is 0
, and interrupt will not be issued even if the
corresponding IR bit is 1
.
Example
use w5500_ll::{blocking::vdm::W5500, Interrupt, Registers}; let mut imr: Interrupt = Interrupt::default(); // enable the magic packet interrupt imr.set_mp(); let mut w5500 = W5500::new(spi, pin); w5500.set_imr(imr)?;
fn sir(&mut self) -> Result<u8, Self::Error>
[src]
Get the socket interrupt status.
SIMR indicated the interrupt status of all sockets.
Each bit of SIR will be 1
until Registers::sn_ir
is cleared.
If Registers::sn_ir
is not equal to 0x00
the nth
bit of sir
is 1
and the INTn pin is asserted until SIR is 0x00
.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, SOCKETS}; let mut w5500 = W5500::new(spi, pin); let sir = w5500.sir()?; // clear all socket interrupts for socket in SOCKETS.iter() { if 1 << (*socket as u8) & sir != 0 { let sn_ir = w5500.sn_ir(*socket)?; w5500.set_sn_ir(*socket, sn_ir)?; } }
fn simr(&mut self) -> Result<u8, Self::Error>
[src]
Get the socket interrupt mask.
Each bit of SIMR corresponds to each bit of Registers::sir
.
When a bit of SIMR is 1
and the corresponding bit of SIR is 1
and interrupt will be issued.
If a bit of SIMR is 0
an interrupt will be not issued even if the
corresponding bit of SIR is 1
.
Example
use w5500_ll::{blocking::vdm::W5500, Registers}; let mut w5500 = W5500::new(spi, pin); let simr: u8 = w5500.simr()?;
fn set_simr(&mut self, simr: u8) -> Result<(), Self::Error>
[src]
Set the socket interrupt mask.
See Registers::simr
for more information.
Example
use w5500_ll::{blocking::vdm::W5500, Registers}; let mut w5500 = W5500::new(spi, pin); // enable all socket interrupts w5500.set_simr(0xFF)?;
fn rtr(&mut self) -> Result<u16, Self::Error>
[src]
Get the retry time.
RTR configures the re-transmission timeout period.
The unit of timeout period is 100us and the default of RTR is 0x07D0
or 2000
.
And so the default timeout period is 200ms (100us X 2000).
During the time configured by RTR, the W5500 waits for the peer response
to the packet that is transmitted by Sn_CR (CONNECT, DISCON, CLOSE,
SEND, SEND_MAC, SEND_KEEP command).
If the peer does not respond within the RTR time, the W5500 re-transmits
the packet or issues a timeout.
Example
use w5500_ll::{blocking::vdm::W5500, Registers}; let mut w5500 = W5500::new(spi, pin); let rtr: u16 = w5500.rtr()?; assert_eq!(rtr, 0x07D0);
fn set_rtr(&mut self, rtr: u16) -> Result<(), Self::Error>
[src]
Set the retry time.
See Registers::rtr
for more information.
Example
use w5500_ll::{blocking::vdm::W5500, Registers}; let mut w5500 = W5500::new(spi, pin); w5500.set_rtr(0x1234)?;
fn rcr(&mut self) -> Result<u8, Self::Error>
[src]
Get the retry count.
RCR configured the number of re-transmission attempts. When the number of re-transmission equals RCR + 1 the socket timeout interrupt is raised.
There is a LOT more information in the data sheet, including some equations that would be very annoying to input.
Example
use w5500_ll::{blocking::vdm::W5500, Registers}; let mut w5500 = W5500::new(spi, pin); let rcr: u8 = w5500.rcr()?;
fn set_rcr(&mut self, rcr: u8) -> Result<(), Self::Error>
[src]
Set the retry count.
See Registers::rcr
for more information.
Example
use w5500_ll::{blocking::vdm::W5500, Registers}; let mut w5500 = W5500::new(spi, pin); w5500.set_rcr(0x0A)?;
fn ptimer(&mut self) -> Result<u8, Self::Error>
[src]
Get the PPP link control protocol request timer.
PTIMER configures the time for sending LCP echo request.
The unit of time is 25ms, for a register value of 200 the timer is 5 seconds.
Example
use w5500_ll::{blocking::vdm::W5500, Registers}; let mut w5500 = W5500::new(spi, pin); let ptimer: u8 = w5500.ptimer()?;
fn set_ptimer(&mut self, ptimer: u8) -> Result<(), Self::Error>
[src]
Set the PPP link control protocol request timer.
See Registers::ptimer
for more information.
Example
use w5500_ll::{blocking::vdm::W5500, Registers}; let mut w5500 = W5500::new(spi, pin); w5500.set_ptimer(200)?;
fn pmagic(&mut self) -> Result<u8, Self::Error>
[src]
Get the PPP link control protocol magic number.
PMAGIC configures the 4 byte magic number used in the LCP echo request.
For a register value of 0x01
the magic number is 0x01010101
.
Example
use w5500_ll::{blocking::vdm::W5500, Registers}; let mut w5500 = W5500::new(spi, pin); let pmagic: u8 = w5500.pmagic()?;
fn set_pmagic(&mut self, pmagic: u8) -> Result<(), Self::Error>
[src]
Set the PPP link control protocol magic number.
See Registers::pmagic
for more information.
Example
use w5500_ll::{blocking::vdm::W5500, Registers}; let mut w5500 = W5500::new(spi, pin); w5500.set_pmagic(0x01)?;
fn phar(&mut self) -> Result<Eui48Addr, Self::Error>
[src]
Get the destination hardware address in PPPoE mode.
Example
use w5500_ll::{blocking::vdm::W5500, net::Eui48Addr, Registers}; let mut w5500 = W5500::new(spi, pin); let phar = w5500.phar()?; assert_eq!(phar, Eui48Addr::UNSPECIFIED);
fn set_phar(&mut self, phar: &Eui48Addr) -> Result<(), Self::Error>
[src]
Set the destination hardware address in PPPoE mode.
Example
use w5500_ll::{blocking::vdm::W5500, net::Eui48Addr, Registers}; let mut w5500 = W5500::new(spi, pin); w5500.set_phar(&Eui48Addr::new(0x12, 0x34, 0x00, 0x00, 0x00, 0x00))?;
fn psid(&mut self) -> Result<u16, Self::Error>
[src]
Get the session ID in PPPoE mode.
PSID should be written to the PPPoE server session ID acquired in the PPPoE connection process.
Example
use w5500_ll::{blocking::vdm::W5500, Registers}; let mut w5500 = W5500::new(spi, pin); let psid: u16 = w5500.psid()?; assert_eq!(psid, 0x0000);
fn set_psid(&mut self, psid: u16) -> Result<(), Self::Error>
[src]
Set the session ID in PPPoE mode.
See Registers::psid
for more information.
Example
use w5500_ll::{blocking::vdm::W5500, Registers}; let mut w5500 = W5500::new(spi, pin); w5500.set_psid(0x1234)?;
fn pmru(&mut self) -> Result<u16, Self::Error>
[src]
Get the maximum receive unit in PPPoE mode.
PMRU configures the maximum receive unit of PPPoE.
Example
use w5500_ll::{blocking::vdm::W5500, Registers}; let mut w5500 = W5500::new(spi, pin); let pmru: u16 = w5500.pmru()?; assert_eq!(pmru, 0x0000);
fn set_pmru(&mut self, pmru: u16) -> Result<(), Self::Error>
[src]
Set the maximum receive unit in PPPoE mode.
See Registers::pmru
for more information.
Example
use w5500_ll::{blocking::vdm::W5500, Registers}; let mut w5500 = W5500::new(spi, pin); w5500.set_pmru(0x1234)?;
fn uipr(&mut self) -> Result<Ipv4Addr, Self::Error>
[src]
Get the unreachable IP address.
This awkward wording is taken directly from the data-sheet:
W5500 receives an ICMP packet (destination port unreachable)
when data is sent to a port number which socket is not open and
the UNREACH bit of Registers::ir
becomes 1
and UIPR and UPORTR
indicates the destination IP address and port number respectively.
Example
use w5500_ll::{blocking::vdm::W5500, net::Ipv4Addr, Registers}; let mut w5500 = W5500::new(spi, pin); let uipr = w5500.uipr()?; assert_eq!(uipr, Ipv4Addr::UNSPECIFIED);
fn uportr(&mut self) -> Result<u16, Self::Error>
[src]
Get the unreachable port.
See Registers::uipr
for more information.
Example
use w5500_ll::{blocking::vdm::W5500, Registers}; let mut w5500 = W5500::new(spi, pin); let uportr = w5500.uportr()?;
fn phycfgr(&mut self) -> Result<PhyCfg, Self::Error>
[src]
Get the PHY configuration.
Example
use w5500_ll::{blocking::vdm::W5500, PhyCfg, Registers}; let mut w5500 = W5500::new(spi, pin); let phy_cfg: PhyCfg = w5500.phycfgr()?; assert_eq!(phy_cfg, PhyCfg::default());
fn set_phycfgr(&mut self, phycfg: PhyCfg) -> Result<(), Self::Error>
[src]
Set the PHY configuration.
Example
use w5500_ll::{blocking::vdm::W5500, OperationMode, PhyCfg, Registers}; let mut phy_cfg: PhyCfg = PhyCfg::default(); phy_cfg.set_opmdc(OperationMode::Auto); let mut w5500 = W5500::new(spi, pin); w5500.set_phycfgr(phy_cfg)?;
fn version(&mut self) -> Result<u8, Self::Error>
[src]
Get the version.
The value returned is always 0x04
.
This register is extremely useful as a sanity check to ensure SPI communications are working with the W5500.
Example
use w5500_ll::{blocking::vdm::W5500, Registers}; let mut w5500 = W5500::new(spi, pin); let version = w5500.version()?; assert_eq!(version, 0x04);
fn sn_mr(&mut self, socket: Socket) -> Result<SocketMode, Self::Error>
[src]
Get the socket mode.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket, SocketMode}; let mut w5500 = W5500::new(spi, pin); let socket_mode = w5500.sn_mr(Socket::Socket0)?; assert_eq!(socket_mode, SocketMode::default());
fn set_sn_mr(
&mut self,
socket: Socket,
mode: SocketMode
) -> Result<(), Self::Error>
[src]
&mut self,
socket: Socket,
mode: SocketMode
) -> Result<(), Self::Error>
Set the socket mode.
Example
use w5500_ll::{blocking::vdm::W5500, Protocol, Registers, Socket, SocketMode}; let mut socket_mode = SocketMode::default(); socket_mode.set_protocol(Protocol::Tcp); let mut w5500 = W5500::new(spi, pin); w5500.set_sn_mr(Socket::Socket0, socket_mode)?;
fn sn_cr(&mut self, socket: Socket) -> Result<u8, Self::Error>
[src]
Get the socket command.
The only use for reading this register is to check if a socket command has been accepted.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket, SocketCommand}; let mut w5500 = W5500::new(spi, pin); w5500.set_sn_cr(Socket::Socket0, SocketCommand::Open)?; loop { if w5500.sn_cr(Socket::Socket0)? == SocketCommand::Accepted.into() { break; } }
fn set_sn_cr(
&mut self,
socket: Socket,
cmd: SocketCommand
) -> Result<(), Self::Error>
[src]
&mut self,
socket: Socket,
cmd: SocketCommand
) -> Result<(), Self::Error>
Set the socket command.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket, SocketCommand}; let mut w5500 = W5500::new(spi, pin); w5500.set_sn_cr(Socket::Socket0, SocketCommand::Open)?;
fn sn_ir(&mut self, socket: Socket) -> Result<SocketInterrupt, Self::Error>
[src]
Get the socket interrupt status.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); let socket_interrupts = w5500.sn_ir(Socket::Socket0)?;
fn set_sn_ir<T: Into<u8>>(
&mut self,
socket: Socket,
sn_ir: T
) -> Result<(), Self::Error>
[src]
&mut self,
socket: Socket,
sn_ir: T
) -> Result<(), Self::Error>
Set the socket interrupt status.
This is a write 1 to clear register.
Examples
Clearing all raised interrupts.
use w5500_ll::{blocking::vdm::W5500, Registers, Socket, SocketInterrupt}; let mut w5500 = W5500::new(spi, pin); let socket_interrupts: SocketInterrupt = w5500.sn_ir(Socket::Socket0)?; w5500.set_sn_ir(Socket::Socket0, socket_interrupts)?;
Clearing only the SENDOK interrupt.
use w5500_ll::{blocking::vdm::W5500, Registers, Socket, SocketInterrupt}; let mut w5500 = W5500::new(spi, pin); w5500.set_sn_ir(Socket::Socket0, SocketInterrupt::SENDOK_MASK)?;
fn sn_sr(
&mut self,
socket: Socket
) -> Result<Result<SocketStatus, u8>, Self::Error>
[src]
&mut self,
socket: Socket
) -> Result<Result<SocketStatus, u8>, Self::Error>
Get the socket status.
Note: This method returns a nested core::result::Result
.
The outermost Result
is for handling bus errors, similar to most of
the other methods in this trait.
The innermost Result<SocketStatus, u8>
is the result of a u8
to
SocketStatus
conversion because not every value of u8
corresponds
to a valid SocketStatus
.
u8
values that have a correspondingSocketStatus
will be converted and returned in theOk
variant of the innerResult
.u8
values that do not correspondingSocketStatus
will have the rawu8
byte returned in theErr
variant of the innerResult
.
Example
use core::convert::TryFrom; use w5500_ll::{blocking::vdm::W5500, Registers, Socket, SocketStatus}; let mut w5500 = W5500::new(spi, pin); let sn_sr = w5500.sn_sr(Socket::Socket0)?; assert_eq!(sn_sr, Ok(SocketStatus::Closed));
fn sn_port(&mut self, socket: Socket) -> Result<u16, Self::Error>
[src]
Get the socket source port.
This is only valid in TCP/UDP mode. This should be set before sending the OPEN command.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket, SocketMode}; let mut w5500 = W5500::new(spi, pin); let socket_port: u16 = w5500.sn_port(Socket::Socket0)?;
fn set_sn_port(&mut self, socket: Socket, port: u16) -> Result<(), Self::Error>
[src]
Set the socket source port.
See Registers::sn_port
for more information.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); w5500.set_sn_port(Socket::Socket0, 68)?;
fn sn_dhar(&mut self, socket: Socket) -> Result<Eui48Addr, Self::Error>
[src]
Get the socket destination hardware address.
Sn_DHAR configures the destination hardware address of Socket n when using SEND_MAC command in UDP mode or it indicates that it is acquired in ARP-process by CONNECT/SEND command.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); let dhar = w5500.sn_dhar(Socket::Socket0)?;
fn set_sn_dhar(
&mut self,
socket: Socket,
dhar: &Eui48Addr
) -> Result<(), Self::Error>
[src]
&mut self,
socket: Socket,
dhar: &Eui48Addr
) -> Result<(), Self::Error>
Set the socket destination hardware address.
See Registers::sn_dhar
for more information.
Example
use w5500_ll::{blocking::vdm::W5500, net::Eui48Addr, Registers, Socket}; let dhar = Eui48Addr::new(0x12, 0x34, 0x00, 0x00, 0x00, 0x00); let mut w5500 = W5500::new(spi, pin); w5500.set_sn_dhar(Socket::Socket0, &dhar)?;
fn sn_dipr(&mut self, socket: Socket) -> Result<Ipv4Addr, Self::Error>
[src]
Get the socket destination IP address.
This register configures or indicates the destination IP address. It it valid when the socket is in TCP/UDP mode.
In TCP client mode it configures the TCP server address before the
SocketCommand::Connect
command.
In TCP server mode it indicates the IP address of the TCP client after successfully establishing a connection.
In UDP mode it configures an IP address of the peer to receive the UDP
packet send by the SocketCommand::Send
or SocketCommand::SendMac
command.
Example
use w5500_ll::{blocking::vdm::W5500, net::Ipv4Addr, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); let dipr = w5500.sn_dipr(Socket::Socket0)?; assert_eq!(dipr, Ipv4Addr::UNSPECIFIED);
fn set_sn_dipr(
&mut self,
socket: Socket,
dipr: &Ipv4Addr
) -> Result<(), Self::Error>
[src]
&mut self,
socket: Socket,
dipr: &Ipv4Addr
) -> Result<(), Self::Error>
Set the socket destination IP address.
See Registers::sn_dipr
for more information.
Example
use w5500_ll::{blocking::vdm::W5500, net::Ipv4Addr, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); w5500.set_sn_dipr(Socket::Socket0, &Ipv4Addr::new(192, 168, 0, 11))?;
fn sn_dport(&mut self, socket: Socket) -> Result<u16, Self::Error>
[src]
Get the socket destination port.
This register configures or indicates the destination port number of the socket. It is valid when the socket is used in TCP/UDP mode.
In TCP client mode, it configures the listen port number of the TCP
server before the SocketCommand::Send
command.
In TCP server mode, it indicates the port number of the TCP client after successfully establishing connection.
In UDP mode, it configures the port number of the peer to be transmitted
in the UDP packet by the SocketCommand::Send
or
SocketCommand::SendMac
command.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket, SocketMode}; let mut w5500 = W5500::new(spi, pin); let socket_destination_port: u16 = w5500.sn_dport(Socket::Socket0)?;
fn set_sn_dport(&mut self, socket: Socket, port: u16) -> Result<(), Self::Error>
[src]
Set the socket destination port.
See Registers::sn_dport
for more information.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); w5500.set_sn_dport(Socket::Socket0, 67)?;
fn sn_dest(&mut self, socket: Socket) -> Result<SocketAddrV4, Self::Error>
[src]
Get the socket destination IPv4 and port.
This is a compound which performs Registers::sn_dipr
and
Registers::sn_dport
together.
The sn_dipr
and sn_dport
registers are contiguous in memory, which
allows this function to do one read transfer to read both registers.
Example
use w5500_ll::{blocking::vdm::W5500, net::SocketAddrV4, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); let addr = w5500.sn_dest(Socket::Socket0)?; assert_eq!(addr, SocketAddrV4::default());
fn set_sn_dest(
&mut self,
socket: Socket,
addr: &SocketAddrV4
) -> Result<(), Self::Error>
[src]
&mut self,
socket: Socket,
addr: &SocketAddrV4
) -> Result<(), Self::Error>
Set the socket destination IPv4 and port.
This is a compound operation which performs
Registers::set_sn_dipr
and Registers::set_sn_dport
together.
The sn_dipr
and sn_dport
registers are contiguous in memory, which
allows this function to do one write transfer to write both registers.
Example
use w5500_ll::{ blocking::vdm::W5500, net::{Ipv4Addr, SocketAddrV4}, Registers, Socket, }; let addr: SocketAddrV4 = SocketAddrV4::new(Ipv4Addr::new(192, 168, 0, 11), 67); let mut w5500 = W5500::new(spi, pin); w5500.set_sn_dest(Socket::Socket0, &addr)?;
fn sn_mssr(&mut self, socket: Socket) -> Result<u16, Self::Error>
[src]
Get the socket maximum segment size.
This register configures or indicates the MTU (Maximum Transfer Unit) of the socket.
The default MTU is valid when the socket is used in TCP / UDP mode. However, when used in PPPoE mode it is determined within the PPPoE MTU.
Mode | Normal Default | Normal Range | PPPoE Default | PPPoE Range |
---|---|---|---|---|
TCP | 1460 | 1 - 1460 | 1452 | 1 - 1452 |
UDP | 1472 | 1 - 1472 | 1464 | 1 - 1464 |
MACRAW | 1514 | 1514 | 1514 | 1514 |
When socket n is used in MACRAW mode, the default MTU is applied because the MTU is not processed internally. Therefore, when transmitting the data bigger than default MTU, the host should manually divide the data into the unit of default MTU. When socket n is used in TCP/UDP mode, and transmitting data bigger than the MTU, the data is automatically divided into the unit of MTU.
In UDP mode, the configured MTU is used.
When transmitting data to a peer with the different MTU size,
the ICMP (Fragment MTU) packet might be received.
In this case, IR(FMTU) becomes 1
and the peer information such as the
MTU size and IP address is indicated from FMTUR and UIPR respectively.
If IR[MTU] = 1
, the user cannot transmit data to the peer.
To resume the communication with peer, do as followed.
- Close socket n with the
SocketCommand::Close
command. - Set Sn_MSS to the indicated MTU from FMTUR
- Open socket n with the
SocketCommand::Open
command. - Resume the communication with the peer.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); let sn__mssr: u16 = w5500.sn_mssr(Socket::Socket0)?;
fn set_sn_mssr(&mut self, socket: Socket, mssr: u16) -> Result<(), Self::Error>
[src]
Set the socket maximum segment size.
See Registers::sn_mssr
for lots more information.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); w5500.set_sn_mssr(Socket::Socket0, 1460)?;
fn sn_tos(&mut self, socket: Socket) -> Result<u8, Self::Error>
[src]
Get the IP type of service.
This register configures the TOS (Type of service field in IP header)
for socket n.
Configure this field before sending the SocketCommand::Open
command.
For more details see iana.org/assignments/ip-parameters.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); let tos: u8 = w5500.sn_tos(Socket::Socket0)?;
fn set_sn_tos(&mut self, socket: Socket, tos: u8) -> Result<(), Self::Error>
[src]
Set the IP type of service.
For more information see Registers::sn_tos
.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); w5500.set_sn_tos(Socket::Socket0, 1)?;
fn sn_ttl(&mut self, socket: Socket) -> Result<u8, Self::Error>
[src]
Get the time to live.
This register configures the TTL (Time to Live field in the IP header) for socket n.
For more details see iana.org/assignments/ip-parameters.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); let ttl: u8 = w5500.sn_ttl(Socket::Socket0)?;
fn set_sn_ttl(&mut self, socket: Socket, ttl: u8) -> Result<(), Self::Error>
[src]
Set the time to live.
For more information see Registers::sn_ttl
.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); w5500.set_sn_ttl(Socket::Socket0, 0x80)?;
fn sn_rxbuf_size(
&mut self,
socket: Socket
) -> Result<Result<BufferSize, u8>, Self::Error>
[src]
&mut self,
socket: Socket
) -> Result<Result<BufferSize, u8>, Self::Error>
Get the socket RX buffer size.
The buffer size can be configured to any of the sizes in BufferSize
.
The sum of all the socket RX buffers cannot exceed 16 KiB.
Note: This method returns a nested core::result::Result
.
The outermost Result
is for handling bus errors, similar to most of
the other methods in this trait.
The innermost Result<BufferSize, u8>
is the result of a u8
to
BufferSize
conversion because not every value of u8
corresponds
to a valid BufferSize
.
u8
values that have a correspondingBufferSize
will be converted and returned in theOk
variant of the innerResult
.u8
values that do not correspondingBufferSize
will have the rawu8
byte returned in theErr
variant of the innerResult
.
Example
use core::convert::TryFrom; use w5500_ll::{blocking::vdm::W5500, BufferSize, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); let sn_rxbuf_size = w5500.sn_rxbuf_size(Socket::Socket0)?; assert_eq!(sn_rxbuf_size, Ok(BufferSize::KB2));
fn set_sn_rxbuf_size(
&mut self,
socket: Socket,
size: BufferSize
) -> Result<(), Self::Error>
[src]
&mut self,
socket: Socket,
size: BufferSize
) -> Result<(), Self::Error>
Set the socket RX buffer size.
See Registers::sn_rxbuf_size
for more information.
Example
use core::convert::TryFrom; use w5500_ll::{blocking::vdm::W5500, BufferSize, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); w5500.set_sn_rxbuf_size(Socket::Socket0, BufferSize::KB1)?;
fn sn_txbuf_size(
&mut self,
socket: Socket
) -> Result<Result<BufferSize, u8>, Self::Error>
[src]
&mut self,
socket: Socket
) -> Result<Result<BufferSize, u8>, Self::Error>
Get the socket TX buffer size.
The buffer size can be configured to any of the sizes in BufferSize
.
The sum of all the socket TX buffers cannot exceed 16 KiB.
Note: This method returns a nested core::result::Result
.
The outermost Result
is for handling bus errors, similar to most of
the other methods in this trait.
The innermost Result<BufferSize, u8>
is the result of a u8
to
BufferSize
conversion because not every value of u8
corresponds
to a valid BufferSize
.
u8
values that have a correspondingBufferSize
will be converted and returned in theOk
variant of the innerResult
.u8
values that do not correspondingBufferSize
will have the rawu8
byte returned in theErr
variant of the innerResult
.
Example
use core::convert::TryFrom; use w5500_ll::{blocking::vdm::W5500, BufferSize, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); let sn_txbuf_size = w5500.sn_txbuf_size(Socket::Socket0)?; assert_eq!(sn_txbuf_size, Ok(BufferSize::KB2));
fn set_sn_txbuf_size(
&mut self,
socket: Socket,
size: BufferSize
) -> Result<(), Self::Error>
[src]
&mut self,
socket: Socket,
size: BufferSize
) -> Result<(), Self::Error>
Set the socket TX buffer size.
See Registers::sn_rxbuf_size
for more information.
Example
use core::convert::TryFrom; use w5500_ll::{blocking::vdm::W5500, BufferSize, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); w5500.set_sn_txbuf_size(Socket::Socket0, BufferSize::KB1)?;
fn sn_tx_fsr(&mut self, socket: Socket) -> Result<u16, Self::Error>
[src]
Get transmit buffer free size.
This register indicates the free size of socket n TX buffer.
It is initialized to the configured size by Registers::sn_txbuf_size
.
Data bigger than Sn_TX_FSR should not be written to the TX buffer to
prevent buffer overflow.
Check this register before writing data to the socket TX buffer,
and if data is equal or smaller than its checked size, transmit the data
with the SocketCommand::Send
or SocketCommand::SendMac
command
after saving the data in Socket n TX buffer.
If data is bigger than its checked size, transmit the data after dividing into the checked size and saving in the socket TX buffer.
If Registers::sn_mr
is not in TCP mode, this register is
automatically calculated as the difference between
Registers::sn_tx_wr
and Registers::sn_tx_rd
.
If Registers::sn_mr
is in TCP mode, this register is automatically
calculated as the difference between the internal ACK pointer which
indicates the point of data is received already by the connected
peer.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket, SocketMode}; let mut w5500 = W5500::new(spi, pin); let sn_tx_fsr: u16 = w5500.sn_tx_fsr(Socket::Socket0)?;
fn sn_tx_rd(&mut self, socket: Socket) -> Result<u16, Self::Error>
[src]
Get the socket TX read pointer.
This register is initialized by the SocketCommand::Open
command.
However, in TCP mode, this is re-initialized while connecting with TCP.
After initialization, this is auto-increased by the
SocketCommand::Send
command.
The SocketCommand::Send
command transmits the saved data from the
current Registers::sn_tx_rd
to the Registers::sn_tx_wr
in the
socket n TX buffer.
After transmitting the saved data, the SocketCommand::Send
command
increases Registers::sn_tx_rd
the as same as
Registers::sn_tx_wr
.
If its increment value exceeds the maximum value 0xFFFF, (greater than 0x10000 and the carry bit occurs), then the carry bit is ignored and will automatically update with the lower 16bits value.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket, SocketMode}; let mut w5500 = W5500::new(spi, pin); let sn_tx_rd: u16 = w5500.sn_tx_rd(Socket::Socket0)?;
fn sn_tx_wr(&mut self, socket: Socket) -> Result<u16, Self::Error>
[src]
Get the socket TX write pointer.
This register is initialized by the SocketCommand::Open
command.
However, in TCP mode, this is re-initialized while connecting with TCP.
This should be updated as follows:
- Read the starting address for transmitting data.
- Write data to the socket TX buffer buffer.
- Update this register by the number of bytes written to the TX buffer.
Allow wrapping to occur upon
u16
overflow. - Transmit the saved data in the socket TX buffer by using the
SocketCommand::Send
command.
See Registers::set_sn_tx_buf
for an additional example.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); let sn_tx_wr: u16 = w5500.sn_tx_wr(Socket::Socket0)?;
fn set_sn_tx_wr(&mut self, socket: Socket, ptr: u16) -> Result<(), Self::Error>
[src]
Set the socket TX write pointer.
See Registers::sn_tx_wr
for more information.
See Registers::set_sn_tx_buf
for an example.
fn sn_rx_rsr(&mut self, socket: Socket) -> Result<u16, Self::Error>
[src]
Get the socket received data size.
This register indicates the data size received and saved in the socket
RX buffer.
This register does not exceed the configured size
(Registers::set_sn_rxbuf_size
) and is calculated as the difference
between Registers::sn_rx_wr
and Registers::sn_rx_rd
.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); let sn_rx_rsr: u16 = w5500.sn_rx_rsr(Socket::Socket0)?;
fn sn_rx_rd(&mut self, socket: Socket) -> Result<u16, Self::Error>
[src]
Get the socket read data pointer.
This register is initialized by the SocketCommand::Open
command.
This should be updated as follows:
- Read the starting address for reading data.
- Read from the socket RX buffer.
- Update this register by the number of bytes read from the RX buffer.
Allow wrapping to occur upon
u16
overflow. - Send a
SocketCommand::Recv
command to notify the W5500 of the retrieved data.
See Registers::sn_rx_buf
for an additional example.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); let sn_rx_rd: u16 = w5500.sn_rx_rd(Socket::Socket0)?;
fn set_sn_rx_rd(&mut self, socket: Socket, ptr: u16) -> Result<(), Self::Error>
[src]
Set the socket read data pointer.
See Registers::sn_rx_rd
for more information.
See Registers::sn_rx_buf
for an example.
fn sn_rx_wr(&mut self, socket: Socket) -> Result<u16, Self::Error>
[src]
Get the socket RX write pointer.
This register is initialized by the SocketCommand::Open
command, and
it is auto-incremented by hardware.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); let sn_rx_wr: u16 = w5500.sn_rx_wr(Socket::Socket0)?;
fn sn_imr(&mut self, socket: Socket) -> Result<SocketInterruptMask, Self::Error>
[src]
Get the socket interrupt mask.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket, SocketInterruptMask}; let mut w5500 = W5500::new(spi, pin); let sn_imr: SocketInterruptMask = w5500.sn_imr(Socket::Socket0)?; assert_eq!(sn_imr, SocketInterruptMask::default());
fn set_sn_imr(
&mut self,
socket: Socket,
mask: SocketInterruptMask
) -> Result<(), Self::Error>
[src]
&mut self,
socket: Socket,
mask: SocketInterruptMask
) -> Result<(), Self::Error>
Set the socket interrupt mask.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket, SocketInterruptMask}; let mut w5500 = W5500::new(spi, pin); w5500.set_sn_imr(Socket::Socket0, SocketInterruptMask::ALL_MASKED)?;
fn sn_frag(&mut self, socket: Socket) -> Result<u16, Self::Error>
[src]
Get the socket fragment.
This configures the fragment field in the IP header.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); let frag: u16 = w5500.sn_frag(Socket::Socket0)?; assert_eq!(frag, 0x4000);
fn set_sn_frag(&mut self, socket: Socket, frag: u16) -> Result<(), Self::Error>
[src]
Set the socket fragment.
See Registers::sn_frag
for more information.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); w5500.set_sn_frag(Socket::Socket0, 0)?;
fn sn_kpalvtr(&mut self, socket: Socket) -> Result<u8, Self::Error>
[src]
Get the socket keep alive time.
This register configures the transmitting timer of the keep alive (KA) packet for the socket. This is valid only in TCP mode, and is ignored in all other modes.
The time unit is 5s.
The KA packet is transmittable after Registers::sn_sr
is changed to
SocketStatus::Established
and after the data is transmitted or
received to/from a peer at least once.
In the case of a non-zero keep alive value the W5500 automatically transmits a KA packet after time-period for checking the TCP connection (automatic-keepalive-process).
In case of a zero keep alive value, the keep alive packet can be
transmitted with SocketCommand::SendKeep
. This command is ignored
for non-zero keep alive values.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); let sn_kpalvtr: u8 = w5500.sn_kpalvtr(Socket::Socket0)?;
fn set_sn_kpalvtr(
&mut self,
socket: Socket,
kpalvtr: u8
) -> Result<(), Self::Error>
[src]
&mut self,
socket: Socket,
kpalvtr: u8
) -> Result<(), Self::Error>
Set the socket keep alive time.
See Registers::sn_kpalvtr
for more information.
Example
use w5500_ll::{blocking::vdm::W5500, Registers, Socket}; let mut w5500 = W5500::new(spi, pin); // 50s keep alive timer w5500.set_sn_kpalvtr(Socket::Socket0, 10)?;
fn set_sn_tx_buf(
&mut self,
socket: Socket,
ptr: u16,
buf: &[u8]
) -> Result<(), Self::Error>
[src]
&mut self,
socket: Socket,
ptr: u16,
buf: &[u8]
) -> Result<(), Self::Error>
Write the socket TX buffer.
Example
use core::cmp::min; use core::convert::TryFrom; use w5500_ll::{blocking::vdm::W5500, Registers, Socket, SocketCommand}; // the socket should already be opened at this point const THE_SOCKET: Socket = Socket::Socket0; let buf: [u8; 5] = [0x12, 0x34, 0x56, 0x78, 0x9A]; // transmit as many bytes as possible // for large buffers this may not transmit all the available data let tx_bytes: u16 = { min(w5500.sn_tx_fsr(THE_SOCKET)?, u16::try_from(buf.len()).unwrap_or(u16::MAX)) }; if tx_bytes == 0 { return Ok(()); } let ptr: u16 = w5500.sn_tx_wr(THE_SOCKET)?; w5500.set_sn_tx_buf(THE_SOCKET, ptr, &buf[..usize::from(tx_bytes)])?; w5500.set_sn_tx_wr(THE_SOCKET, ptr.wrapping_add(tx_bytes))?; w5500.set_sn_cr(THE_SOCKET, SocketCommand::Send)?;
fn sn_rx_buf(
&mut self,
socket: Socket,
ptr: u16,
buf: &mut [u8]
) -> Result<(), Self::Error>
[src]
&mut self,
socket: Socket,
ptr: u16,
buf: &mut [u8]
) -> Result<(), Self::Error>
Read the socket RX buffer.
Example
use core::cmp::min; use core::convert::TryFrom; use w5500_ll::{blocking::vdm::W5500, Registers, Socket, SocketCommand}; // the socket should already be opened at this point // a socket interrupt will indicate there is data to be retrieved const THE_SOCKET: Socket = Socket::Socket0; // in reality you will need a larger buffer for most protocols const BUF_LEN: usize = 16; let mut buf: [u8; BUF_LEN] = [0; BUF_LEN]; let rx_bytes: u16 = { min(w5500.sn_rx_rsr(THE_SOCKET)?, u16::try_from(buf.len()).unwrap_or(u16::MAX)) }; if rx_bytes == 0 { return Ok(()); } let ptr: u16 = w5500.sn_rx_rd(THE_SOCKET)?; w5500.sn_rx_buf(THE_SOCKET, ptr, &mut buf[..usize::from(rx_bytes)])?; w5500.set_sn_rx_rd(THE_SOCKET, ptr.wrapping_add(rx_bytes))?; w5500.set_sn_cr(THE_SOCKET, SocketCommand::Recv)?;
Implementors
impl<SPI, CS, SpiError, PinError> Registers for w5500_ll::blocking::vdm::W5500<SPI, CS> where
SPI: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
CS: OutputPin<Error = PinError>,
[src]
impl<SPI, CS, SpiError, PinError> Registers for w5500_ll::blocking::vdm::W5500<SPI, CS> where
SPI: Transfer<u8, Error = SpiError> + Write<u8, Error = SpiError>,
CS: OutputPin<Error = PinError>,
[src]embedded-hal
only.