Minor typo fixes, clean-up of the public interface

This commit is contained in:
Jonah Dahlquist 2021-02-15 21:52:35 -08:00
commit a3e0911c5b
8 changed files with 17 additions and 11 deletions

View file

@ -8,6 +8,7 @@ use crate::bus::Bus;
const WRITE_MODE_MASK: u8 = 0b00000_1_00; const WRITE_MODE_MASK: u8 = 0b00000_1_00;
// TODO This name is not ideal, should be renamed to VDM
pub struct FourWire<Spi: Transfer<u8> + Write<u8>, ChipSelect: OutputPin> { pub struct FourWire<Spi: Transfer<u8> + Write<u8>, ChipSelect: OutputPin> {
cs: ChipSelect, cs: ChipSelect,
spi: Spi, spi: Spi,

View file

@ -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_2: u8 = 0b000000_10;
const FIXED_DATA_LENGTH_MODE_4: u8 = 0b000000_11; const FIXED_DATA_LENGTH_MODE_4: u8 = 0b000000_11;
// TODO This name is not ideal, should be renamed to FDM
pub struct ThreeWire<Spi: Transfer<u8> + Write<u8>> { pub struct ThreeWire<Spi: Transfer<u8> + Write<u8>> {
spi: Spi, spi: Spi,
} }

View file

@ -28,7 +28,7 @@ impl<E> From<E> for ResetError<E> {
} }
impl<SpiBus: Bus, HostImpl: Host> Device<SpiBus, HostImpl> { impl<SpiBus: Bus, HostImpl: Host> Device<SpiBus, HostImpl> {
pub fn new(bus: SpiBus, host: HostImpl) -> Self { pub(crate) fn new(bus: SpiBus, host: HostImpl) -> Self {
Device { Device {
bus, bus,
host, host,
@ -53,7 +53,7 @@ impl<SpiBus: Bus, HostImpl: Host> Device<SpiBus, HostImpl> {
Ok(()) Ok(())
} }
pub fn take_socket(&mut self) -> Option<Socket> { pub(crate) fn take_socket(&mut self) -> Option<Socket> {
// TODO maybe return Future that resolves when release_socket invoked // TODO maybe return Future that resolves when release_socket invoked
for index in 0..8 { for index in 0..8 {
if self.sockets.get_bit(index) { if self.sockets.get_bit(index) {
@ -71,7 +71,7 @@ impl<SpiBus: Bus, HostImpl: Host> Device<SpiBus, HostImpl> {
Ok(phy[0].into()) 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); self.sockets.set_bit(socket.index.into(), true);
} }

View file

@ -4,7 +4,7 @@ use crate::MacAddress;
pub struct Dhcp { pub struct Dhcp {
// settings: HostConfig, // settings: HostConfig,
// current: HostConfig, // current: HostConfig,
} }
impl Dhcp { impl Dhcp {

View file

@ -73,10 +73,13 @@ impl Default for Mode {
pub mod bus; pub mod bus;
mod device; mod device;
mod host; mod host;
pub mod net; mod net;
pub mod register; pub mod register;
mod socket; mod socket;
mod udp; 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 net::MacAddress;
pub use uninitialized_device::UninitializedDevice;

View file

@ -102,7 +102,7 @@ impl MacAddress {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// use w5500::net::MacAddress; /// use w5500::MacAddress;
/// ///
/// let addr = MacAddress::new(0x00, 0x00, 0x5E, 0x00, 0x00, 0x00); /// let addr = MacAddress::new(0x00, 0x00, 0x5E, 0x00, 0x00, 0x00);
/// ``` /// ```
@ -119,7 +119,7 @@ impl MacAddress {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// use w5500::net::MacAddress; /// use w5500::MacAddress;
/// ///
/// let addr = MacAddress::UNSPECIFIED; /// let addr = MacAddress::UNSPECIFIED;
/// assert_eq!(addr, MacAddress::new(0x00, 0x00, 0x00, 0x00, 0x00, 0x00)); /// assert_eq!(addr, MacAddress::new(0x00, 0x00, 0x00, 0x00, 0x00, 0x00));

View file

@ -1,5 +1,6 @@
#![allow(clippy::inconsistent_digit_grouping, clippy::unusual_byte_groupings)] #![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 const COMMON: u8 = 0;
pub mod common { pub mod common {
use bit_field::BitArray; use bit_field::BitArray;

View file

@ -11,11 +11,11 @@ pub struct UdpSocket {
} }
impl UdpSocket { impl UdpSocket {
pub fn new(socket: Socket) -> Self { fn new(socket: Socket) -> Self {
UdpSocket { socket } UdpSocket { socket }
} }
pub fn open<SpiBus: Bus>( fn open<SpiBus: Bus>(
&mut self, &mut self,
bus: &mut SpiBus, bus: &mut SpiBus,
local_port: u16, 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 -->| * |<-- read_pointer read_pointer + received_size -->|
* | Destination IP Address | Destination Port | Byte Size of DATA | Actual DATA ... | * | Destination IP Address | Destination Port | Byte Size of DATA | Actual DATA ... |
* | --- 4 Bytes --- | --- 2 Bytes --- | --- 2 Bytes --- | .... | * | --- 4 Bytes --- | --- 2 Bytes --- | --- 2 Bytes --- | .... |