added all

This commit is contained in:
Jonah Dahlquist 2020-11-05 21:51:06 -08:00
commit 41cd42eabf
5 changed files with 17 additions and 3 deletions

View file

@ -943,7 +943,7 @@ impl Default for Mode {
pub mod bus; pub mod bus;
mod inactive_w5500; mod inactive_w5500;
mod network; mod network;
mod register; pub mod register;
mod socket; mod socket;
mod udp; mod udp;
pub mod uninitialized_w5500; pub mod uninitialized_w5500;

View file

@ -52,11 +52,13 @@ pub mod socketn {
Open = 0x01, Open = 0x01,
Send = 0x20, Send = 0x20,
Receive = 0x40, Receive = 0x40,
Close = 0x10,
} }
pub const INTERRUPT: u16 = 0x02; pub const INTERRUPT: u16 = 0x02;
#[repr(u8)] #[repr(u8)]
pub enum Interrupt { pub enum Interrupt {
All = 0b11111111u8,
SendOk = 0b010000u8, SendOk = 0b010000u8,
Receive = 0b00100u8, Receive = 0b00100u8,
} }

View file

@ -26,7 +26,8 @@ impl<SpiBus: ActiveBus, NetworkImpl: Network, SocketImpl: Socket>
mut w5500: W5500<SpiBus, NetworkImpl>, mut w5500: W5500<SpiBus, NetworkImpl>,
socket: SocketImpl, socket: SocketImpl,
) -> Result<Self, SpiBus::Error> { ) -> Result<Self, SpiBus::Error> {
socket.reset_interrupt(&mut w5500.bus, socketn::Interrupt::SendOk)?; socket.command(&mut w5500.bus, socketn::Command::Close)?;
socket.reset_interrupt(&mut w5500.bus, socketn::Interrupt::All)?;
socket.set_source_port(&mut w5500.bus, port)?; socket.set_source_port(&mut w5500.bus, port)?;
socket.set_mode(&mut w5500.bus, socketn::Protocol::Udp)?; socket.set_mode(&mut w5500.bus, socketn::Protocol::Udp)?;
socket.command(&mut w5500.bus, socketn::Command::Open)?; socket.command(&mut w5500.bus, socketn::Command::Open)?;

View file

@ -6,7 +6,7 @@ use crate::udp::UdpSocket;
use crate::IpAddress; use crate::IpAddress;
pub struct OutgoingPacket<UdpSocket> { pub struct OutgoingPacket<UdpSocket> {
udp_socket: UdpSocket, pub udp_socket: UdpSocket,
data_length: u16, data_length: u16,
} }

View file

@ -62,6 +62,17 @@ impl<SpiBus: ActiveBus> UninitializedW5500<SpiBus> {
mode_options: Mode, mode_options: Mode,
) -> Result<(W5500<SpiBus, NetworkImpl>, OwnedSockets), InitializeError<SpiBus::Error>> { ) -> Result<(W5500<SpiBus, NetworkImpl>, OwnedSockets), InitializeError<SpiBus::Error>> {
self.assert_chip_version(0x4)?; self.assert_chip_version(0x4)?;
// RESET
/*
let mut mode = [0b10000000];
self
.bus
.transfer_frame(register::COMMON, register::common::MODE, true, &mut mode)
.map_err(|e| InitializeError::SpiError(e))?;
*/
self.set_mode(mode_options) self.set_mode(mode_options)
.map_err(|e| InitializeError::SpiError(e))?; .map_err(|e| InitializeError::SpiError(e))?;
network network