Add TCP-based NAL implementation (#24)
* Adding TCP-based NAL implementation * Updating NAL dependency * Updating connect to handle network errors * Adding support for getting IP and MAC, allowing transparent access to the W5500 in the interface. * Fixing TCP connect when not in INIT * Adding wait after reset * Reverting changes * More delta reductions * Fixing format * Updating changelog * Fixing docs * Updating NAL version * Adding debug derive * fixing TCP write * Updating RX receive size to allow less than 8 bytes * Fixing clippy lints
This commit is contained in:
parent
2f4603d0bc
commit
9327809fe7
9 changed files with 362 additions and 13 deletions
|
|
@ -50,6 +50,12 @@ impl Socket {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn get_status<SpiBus: Bus>(&self, bus: &mut SpiBus) -> Result<u8, SpiBus::Error> {
|
||||
let mut data = [0u8];
|
||||
bus.read_frame(self.register(), socketn::STATUS, &mut data)?;
|
||||
Ok(data[0])
|
||||
}
|
||||
|
||||
pub fn reset_interrupt<SpiBus: Bus>(
|
||||
&self,
|
||||
bus: &mut SpiBus,
|
||||
|
|
@ -178,9 +184,15 @@ impl Socket {
|
|||
bus.read_frame(self.register(), socketn::RECEIVED_SIZE, &mut sample_0)?;
|
||||
let mut sample_1 = [0u8; 2];
|
||||
bus.read_frame(self.register(), socketn::RECEIVED_SIZE, &mut sample_1)?;
|
||||
if sample_0 == sample_1 && sample_0[0] >= 8 {
|
||||
if sample_0 == sample_1 {
|
||||
break Ok(u16::from_be_bytes(sample_0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_tx_free_size<SpiBus: Bus>(&self, bus: &mut SpiBus) -> Result<u16, SpiBus::Error> {
|
||||
let mut data = [0; 2];
|
||||
bus.read_frame(self.register(), socketn::TX_FREE_SIZE, &mut data)?;
|
||||
Ok(u16::from_be_bytes(data))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue