added all
This commit is contained in:
parent
074e01e3a0
commit
41cd42eabf
5 changed files with 17 additions and 3 deletions
|
|
@ -943,7 +943,7 @@ impl Default for Mode {
|
|||
pub mod bus;
|
||||
mod inactive_w5500;
|
||||
mod network;
|
||||
mod register;
|
||||
pub mod register;
|
||||
mod socket;
|
||||
mod udp;
|
||||
pub mod uninitialized_w5500;
|
||||
|
|
|
|||
|
|
@ -52,11 +52,13 @@ pub mod socketn {
|
|||
Open = 0x01,
|
||||
Send = 0x20,
|
||||
Receive = 0x40,
|
||||
Close = 0x10,
|
||||
}
|
||||
|
||||
pub const INTERRUPT: u16 = 0x02;
|
||||
#[repr(u8)]
|
||||
pub enum Interrupt {
|
||||
All = 0b11111111u8,
|
||||
SendOk = 0b010000u8,
|
||||
Receive = 0b00100u8,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ impl<SpiBus: ActiveBus, NetworkImpl: Network, SocketImpl: Socket>
|
|||
mut w5500: W5500<SpiBus, NetworkImpl>,
|
||||
socket: SocketImpl,
|
||||
) -> 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_mode(&mut w5500.bus, socketn::Protocol::Udp)?;
|
||||
socket.command(&mut w5500.bus, socketn::Command::Open)?;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use crate::udp::UdpSocket;
|
|||
use crate::IpAddress;
|
||||
|
||||
pub struct OutgoingPacket<UdpSocket> {
|
||||
udp_socket: UdpSocket,
|
||||
pub udp_socket: UdpSocket,
|
||||
data_length: u16,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,17 @@ impl<SpiBus: ActiveBus> UninitializedW5500<SpiBus> {
|
|||
mode_options: Mode,
|
||||
) -> Result<(W5500<SpiBus, NetworkImpl>, OwnedSockets), InitializeError<SpiBus::Error>> {
|
||||
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)
|
||||
.map_err(|e| InitializeError::SpiError(e))?;
|
||||
network
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue