From a3e0911c5bbf61a8821932dc32758ef5c3bb1cb2 Mon Sep 17 00:00:00 2001 From: Jonah Dahlquist Date: Mon, 15 Feb 2021 21:52:35 -0800 Subject: [PATCH] Minor typo fixes, clean-up of the public interface --- src/bus/four_wire.rs | 1 + src/bus/three_wire.rs | 1 + src/device.rs | 6 +++--- src/host/dhcp.rs | 2 +- src/lib.rs | 7 +++++-- src/net.rs | 4 ++-- src/register.rs | 1 + src/udp.rs | 6 +++--- 8 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/bus/four_wire.rs b/src/bus/four_wire.rs index 2e19b25..43bba2c 100644 --- a/src/bus/four_wire.rs +++ b/src/bus/four_wire.rs @@ -8,6 +8,7 @@ use crate::bus::Bus; const WRITE_MODE_MASK: u8 = 0b00000_1_00; +// TODO This name is not ideal, should be renamed to VDM pub struct FourWire + Write, ChipSelect: OutputPin> { cs: ChipSelect, spi: Spi, diff --git a/src/bus/three_wire.rs b/src/bus/three_wire.rs index f7b59bb..c9c0dc2 100644 --- a/src/bus/three_wire.rs +++ b/src/bus/three_wire.rs @@ -11,6 +11,7 @@ const FIXED_DATA_LENGTH_MODE_1: u8 = 0b000000_01; const FIXED_DATA_LENGTH_MODE_2: u8 = 0b000000_10; const FIXED_DATA_LENGTH_MODE_4: u8 = 0b000000_11; +// TODO This name is not ideal, should be renamed to FDM pub struct ThreeWire + Write> { spi: Spi, } diff --git a/src/device.rs b/src/device.rs index f1629a5..29f20a1 100644 --- a/src/device.rs +++ b/src/device.rs @@ -28,7 +28,7 @@ impl From for ResetError { } impl Device { - pub fn new(bus: SpiBus, host: HostImpl) -> Self { + pub(crate) fn new(bus: SpiBus, host: HostImpl) -> Self { Device { bus, host, @@ -53,7 +53,7 @@ impl Device { Ok(()) } - pub fn take_socket(&mut self) -> Option { + pub(crate) fn take_socket(&mut self) -> Option { // TODO maybe return Future that resolves when release_socket invoked for index in 0..8 { if self.sockets.get_bit(index) { @@ -71,7 +71,7 @@ impl Device { Ok(phy[0].into()) } - pub fn release_socket(&mut self, socket: Socket) { + pub(crate) fn release_socket(&mut self, socket: Socket) { self.sockets.set_bit(socket.index.into(), true); } diff --git a/src/host/dhcp.rs b/src/host/dhcp.rs index f792736..521a831 100644 --- a/src/host/dhcp.rs +++ b/src/host/dhcp.rs @@ -4,7 +4,7 @@ use crate::MacAddress; pub struct Dhcp { // settings: HostConfig, -// current: HostConfig, + // current: HostConfig, } impl Dhcp { diff --git a/src/lib.rs b/src/lib.rs index 74267a0..5031f87 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -73,10 +73,13 @@ impl Default for Mode { pub mod bus; mod device; mod host; -pub mod net; +mod net; pub mod register; mod socket; mod udp; -pub mod uninitialized_device; +mod uninitialized_device; +pub use device::Device; +pub use host::{Dhcp,HostConfig,Manual}; pub use net::MacAddress; +pub use uninitialized_device::UninitializedDevice; diff --git a/src/net.rs b/src/net.rs index b8a9c1a..e74a158 100644 --- a/src/net.rs +++ b/src/net.rs @@ -102,7 +102,7 @@ impl MacAddress { /// # Examples /// /// ``` - /// use w5500::net::MacAddress; + /// use w5500::MacAddress; /// /// let addr = MacAddress::new(0x00, 0x00, 0x5E, 0x00, 0x00, 0x00); /// ``` @@ -119,7 +119,7 @@ impl MacAddress { /// # Examples /// /// ``` - /// use w5500::net::MacAddress; + /// use w5500::MacAddress; /// /// let addr = MacAddress::UNSPECIFIED; /// assert_eq!(addr, MacAddress::new(0x00, 0x00, 0x00, 0x00, 0x00, 0x00)); diff --git a/src/register.rs b/src/register.rs index 5a05207..d3145a9 100644 --- a/src/register.rs +++ b/src/register.rs @@ -1,5 +1,6 @@ #![allow(clippy::inconsistent_digit_grouping, clippy::unusual_byte_groupings)] +// TODO change from u8 to a custom struct implementing a trait. pub const COMMON: u8 = 0; pub mod common { use bit_field::BitArray; diff --git a/src/udp.rs b/src/udp.rs index 345e584..1ed740c 100644 --- a/src/udp.rs +++ b/src/udp.rs @@ -11,11 +11,11 @@ pub struct UdpSocket { } impl UdpSocket { - pub fn new(socket: Socket) -> Self { + fn new(socket: Socket) -> Self { UdpSocket { socket } } - pub fn open( + fn open( &mut self, bus: &mut SpiBus, local_port: u16, @@ -97,7 +97,7 @@ impl UdpSocket { } /* - * Packet frame, as described in W5200 docs sectino 5.2.2.1 + * Packet frame, as described in W5200 docs section 5.2.2.1 * |<-- read_pointer read_pointer + received_size -->| * | Destination IP Address | Destination Port | Byte Size of DATA | Actual DATA ... | * | --- 4 Bytes --- | --- 2 Bytes --- | --- 2 Bytes --- | .... |