Added register_dump function to show the contents of a socket register

This commit is contained in:
Jonah Dahlquist 2020-01-19 23:49:46 -08:00 committed by Jonah Dahlquist
commit 4ff4bc95c9
2 changed files with 15 additions and 0 deletions

View file

@ -168,6 +168,17 @@ pub trait Socket {
} }
} }
} }
fn dump_register<SpiBus: ActiveBus>(&self, bus: &mut SpiBus) -> Result<[u8; 0x30], SpiBus::Error> {
let mut register = [0u8; 0x30];
block!(bus.transfer_frame(
self.register(),
0u16,
false,
&mut register
))?;
Ok(register)
}
} }
pub type OwnedSockets = ( pub type OwnedSockets = (

View file

@ -34,6 +34,10 @@ impl<SpiBus: ActiveBus, NetworkImpl: Network, SocketImpl: Socket>
Ok(UdpSocket { w5500, socket }) Ok(UdpSocket { w5500, socket })
} }
pub fn dump_register(&mut self) -> Result<[u8; 0x30], SpiBus::Error> {
Ok(self.socket.dump_register(&mut self.w5500.bus)?)
}
/// Returns a UDP packet if one is available. Will return `None` if no UDP packets are in the socket's buffer /// Returns a UDP packet if one is available. Will return `None` if no UDP packets are in the socket's buffer
pub fn receive(mut self) -> Result<Option<IncomingPacket<Self>>, SpiBus::Error> { pub fn receive(mut self) -> Result<Option<IncomingPacket<Self>>, SpiBus::Error> {
if !self if !self