From 246c49621c30f1fb66fb328045934a8a0234855e Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Wed, 20 Dec 2023 12:51:47 +0100 Subject: [PATCH 1/4] docs: embassy-net-adin1110 --- embassy-net-adin1110/Cargo.toml | 3 +-- embassy-net-adin1110/src/crc32.rs | 7 +++++++ embassy-net-adin1110/src/lib.rs | 2 ++ embassy-net-adin1110/src/mdio.rs | 1 + embassy-net-adin1110/src/phy.rs | 5 +++++ embassy-net-adin1110/src/regs.rs | 1 + 6 files changed, 17 insertions(+), 2 deletions(-) diff --git a/embassy-net-adin1110/Cargo.toml b/embassy-net-adin1110/Cargo.toml index b1582ac9b..f1be52da5 100644 --- a/embassy-net-adin1110/Cargo.toml +++ b/embassy-net-adin1110/Cargo.toml @@ -6,8 +6,7 @@ keywords = ["embedded", "ADIN1110", "embassy-net", "embedded-hal-async", "ethern categories = ["embedded", "hardware-support", "no-std", "network-programming", "async"] license = "MIT OR Apache-2.0" edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +repository = "https://github.com/embassy-rs/embassy" [dependencies] heapless = "0.8" diff --git a/embassy-net-adin1110/src/crc32.rs b/embassy-net-adin1110/src/crc32.rs index ec020b70c..d7c8346aa 100644 --- a/embassy-net-adin1110/src/crc32.rs +++ b/embassy-net-adin1110/src/crc32.rs @@ -1,3 +1,4 @@ +/// CRC32 lookup table. pub const CRC32R_LOOKUP_TABLE: [u32; 256] = [ 0x0000_0000, 0x7707_3096, @@ -263,8 +264,10 @@ pub const CRC32R_LOOKUP_TABLE: [u32; 256] = [ pub struct ETH_FCS(pub u32); impl ETH_FCS { + /// CRC32_OK pub const CRC32_OK: u32 = 0x2144_df1c; + /// Create a new frame check sequence from `data`. #[must_use] pub fn new(data: &[u8]) -> Self { let fcs = data.iter().fold(u32::MAX, |crc, byte| { @@ -274,6 +277,7 @@ impl ETH_FCS { Self(fcs) } + /// Update the frame check sequence with `data`. #[must_use] pub fn update(self, data: &[u8]) -> Self { let fcs = data.iter().fold(self.0 ^ u32::MAX, |crc, byte| { @@ -283,16 +287,19 @@ impl ETH_FCS { Self(fcs) } + /// Check if the frame check sequence is correct. #[must_use] pub fn crc_ok(&self) -> bool { self.0 == Self::CRC32_OK } + /// Switch byte order. #[must_use] pub fn hton_bytes(&self) -> [u8; 4] { self.0.to_le_bytes() } + /// Switch byte order as a u32. #[must_use] pub fn hton(&self) -> u32 { self.0.to_le() diff --git a/embassy-net-adin1110/src/lib.rs b/embassy-net-adin1110/src/lib.rs index 080b3f94d..4dafc8b0f 100644 --- a/embassy-net-adin1110/src/lib.rs +++ b/embassy-net-adin1110/src/lib.rs @@ -5,6 +5,7 @@ #![allow(clippy::missing_errors_doc)] #![allow(clippy::missing_panics_doc)] #![doc = include_str!("../README.md")] +#![warn(missing_docs)] // must go first! mod fmt; @@ -446,6 +447,7 @@ pub struct Runner<'d, SPI, INT, RST> { } impl<'d, SPI: SpiDevice, INT: Wait, RST: OutputPin> Runner<'d, SPI, INT, RST> { + /// Run the driver. #[allow(clippy::too_many_lines)] pub async fn run(mut self) -> ! { loop { diff --git a/embassy-net-adin1110/src/mdio.rs b/embassy-net-adin1110/src/mdio.rs index 1ae5f0043..6fea9370e 100644 --- a/embassy-net-adin1110/src/mdio.rs +++ b/embassy-net-adin1110/src/mdio.rs @@ -39,6 +39,7 @@ enum Reg13Op { /// /// Clause 45 methodes are bases on pub trait MdioBus { + /// Error type. type Error; /// Read, Clause 22 diff --git a/embassy-net-adin1110/src/phy.rs b/embassy-net-adin1110/src/phy.rs index d54d843d2..a37b2baa3 100644 --- a/embassy-net-adin1110/src/phy.rs +++ b/embassy-net-adin1110/src/phy.rs @@ -30,6 +30,7 @@ pub mod RegsC45 { } impl DA1 { + /// Convert. #[must_use] pub fn into(self) -> (u8, u16) { (0x01, self as u16) @@ -49,6 +50,7 @@ pub mod RegsC45 { } impl DA3 { + /// Convert. #[must_use] pub fn into(self) -> (u8, u16) { (0x03, self as u16) @@ -64,6 +66,7 @@ pub mod RegsC45 { } impl DA7 { + /// Convert. #[must_use] pub fn into(self) -> (u8, u16) { (0x07, self as u16) @@ -87,6 +90,7 @@ pub mod RegsC45 { } impl DA1E { + /// Convert. #[must_use] pub fn into(self) -> (u8, u16) { (0x1e, self as u16) @@ -104,6 +108,7 @@ pub mod RegsC45 { } impl DA1F { + /// Convert. #[must_use] pub fn into(self) -> (u8, u16) { (0x1f, self as u16) diff --git a/embassy-net-adin1110/src/regs.rs b/embassy-net-adin1110/src/regs.rs index beaf9466e..8780c2b9d 100644 --- a/embassy-net-adin1110/src/regs.rs +++ b/embassy-net-adin1110/src/regs.rs @@ -2,6 +2,7 @@ use core::fmt::{Debug, Display}; use bitfield::{bitfield, bitfield_bitrange, bitfield_fields}; +#[allow(missing_docs)] #[allow(non_camel_case_types)] #[derive(Debug, Copy, Clone)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] From b0583b17cbbf13988c37dcb1291d3acf6a78977c Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Wed, 20 Dec 2023 13:08:06 +0100 Subject: [PATCH 2/4] fix: make non-public instead --- embassy-net-adin1110/src/crc32.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/embassy-net-adin1110/src/crc32.rs b/embassy-net-adin1110/src/crc32.rs index d7c8346aa..4b3c69f23 100644 --- a/embassy-net-adin1110/src/crc32.rs +++ b/embassy-net-adin1110/src/crc32.rs @@ -264,8 +264,7 @@ pub const CRC32R_LOOKUP_TABLE: [u32; 256] = [ pub struct ETH_FCS(pub u32); impl ETH_FCS { - /// CRC32_OK - pub const CRC32_OK: u32 = 0x2144_df1c; + const CRC32_OK: u32 = 0x2144_df1c; /// Create a new frame check sequence from `data`. #[must_use] From b8777eaea2e2f7966c1c0789e261bffcdc2a1be4 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Wed, 20 Dec 2023 13:12:32 +0100 Subject: [PATCH 3/4] better keep missing docs for into --- embassy-net-adin1110/src/phy.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/embassy-net-adin1110/src/phy.rs b/embassy-net-adin1110/src/phy.rs index a37b2baa3..9966e1f6a 100644 --- a/embassy-net-adin1110/src/phy.rs +++ b/embassy-net-adin1110/src/phy.rs @@ -30,7 +30,7 @@ pub mod RegsC45 { } impl DA1 { - /// Convert. + #[allow(missing_docs)] #[must_use] pub fn into(self) -> (u8, u16) { (0x01, self as u16) @@ -50,7 +50,7 @@ pub mod RegsC45 { } impl DA3 { - /// Convert. + #[allow(missing_docs)] #[must_use] pub fn into(self) -> (u8, u16) { (0x03, self as u16) @@ -66,7 +66,7 @@ pub mod RegsC45 { } impl DA7 { - /// Convert. + #[allow(missing_docs)] #[must_use] pub fn into(self) -> (u8, u16) { (0x07, self as u16) @@ -90,7 +90,7 @@ pub mod RegsC45 { } impl DA1E { - /// Convert. + #[allow(missing_docs)] #[must_use] pub fn into(self) -> (u8, u16) { (0x1e, self as u16) @@ -108,7 +108,7 @@ pub mod RegsC45 { } impl DA1F { - /// Convert. + #[allow(missing_docs)] #[must_use] pub fn into(self) -> (u8, u16) { (0x1f, self as u16) From 51a67cb69ab72e44c6cbeea677c4c6bd1e5c2550 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Wed, 20 Dec 2023 13:34:34 +0100 Subject: [PATCH 4/4] fix: expose less --- embassy-net-adin1110/src/lib.rs | 5 +++-- embassy-net-adin1110/src/phy.rs | 5 ----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/embassy-net-adin1110/src/lib.rs b/embassy-net-adin1110/src/lib.rs index 4dafc8b0f..6ecfa587d 100644 --- a/embassy-net-adin1110/src/lib.rs +++ b/embassy-net-adin1110/src/lib.rs @@ -27,8 +27,9 @@ use embedded_hal_async::digital::Wait; use embedded_hal_async::spi::{Error, Operation, SpiDevice}; use heapless::Vec; pub use mdio::MdioBus; -pub use phy::{Phy10BaseT1x, RegsC22, RegsC45}; -pub use regs::{Config0, Config2, SpiRegisters as sr, Status0, Status1}; +pub use phy::Phy10BaseT1x; +use phy::{RegsC22, RegsC45}; +use regs::{Config0, Config2, SpiRegisters as sr, Status0, Status1}; use crate::fmt::Bytes; use crate::regs::{LedCntrl, LedFunc, LedPol, LedPolarity, SpiHeader}; diff --git a/embassy-net-adin1110/src/phy.rs b/embassy-net-adin1110/src/phy.rs index 9966e1f6a..d54d843d2 100644 --- a/embassy-net-adin1110/src/phy.rs +++ b/embassy-net-adin1110/src/phy.rs @@ -30,7 +30,6 @@ pub mod RegsC45 { } impl DA1 { - #[allow(missing_docs)] #[must_use] pub fn into(self) -> (u8, u16) { (0x01, self as u16) @@ -50,7 +49,6 @@ pub mod RegsC45 { } impl DA3 { - #[allow(missing_docs)] #[must_use] pub fn into(self) -> (u8, u16) { (0x03, self as u16) @@ -66,7 +64,6 @@ pub mod RegsC45 { } impl DA7 { - #[allow(missing_docs)] #[must_use] pub fn into(self) -> (u8, u16) { (0x07, self as u16) @@ -90,7 +87,6 @@ pub mod RegsC45 { } impl DA1E { - #[allow(missing_docs)] #[must_use] pub fn into(self) -> (u8, u16) { (0x1e, self as u16) @@ -108,7 +104,6 @@ pub mod RegsC45 { } impl DA1F { - #[allow(missing_docs)] #[must_use] pub fn into(self) -> (u8, u16) { (0x1f, self as u16)