diff options
| -rw-r--r-- | embassy-net-adin1110/Cargo.toml | 3 | ||||
| -rw-r--r-- | embassy-net-adin1110/src/crc32.rs | 7 | ||||
| -rw-r--r-- | embassy-net-adin1110/src/lib.rs | 2 | ||||
| -rw-r--r-- | embassy-net-adin1110/src/mdio.rs | 1 | ||||
| -rw-r--r-- | embassy-net-adin1110/src/phy.rs | 5 | ||||
| -rw-r--r-- | 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 | |||
| 6 | categories = ["embedded", "hardware-support", "no-std", "network-programming", "async"] | 6 | categories = ["embedded", "hardware-support", "no-std", "network-programming", "async"] |
| 7 | license = "MIT OR Apache-2.0" | 7 | license = "MIT OR Apache-2.0" |
| 8 | edition = "2021" | 8 | edition = "2021" |
| 9 | 9 | repository = "https://github.com/embassy-rs/embassy" | |
| 10 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
| 11 | 10 | ||
| 12 | [dependencies] | 11 | [dependencies] |
| 13 | heapless = "0.8" | 12 | 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 @@ | |||
| 1 | /// CRC32 lookup table. | ||
| 1 | pub const CRC32R_LOOKUP_TABLE: [u32; 256] = [ | 2 | pub const CRC32R_LOOKUP_TABLE: [u32; 256] = [ |
| 2 | 0x0000_0000, | 3 | 0x0000_0000, |
| 3 | 0x7707_3096, | 4 | 0x7707_3096, |
| @@ -263,8 +264,10 @@ pub const CRC32R_LOOKUP_TABLE: [u32; 256] = [ | |||
| 263 | pub struct ETH_FCS(pub u32); | 264 | pub struct ETH_FCS(pub u32); |
| 264 | 265 | ||
| 265 | impl ETH_FCS { | 266 | impl ETH_FCS { |
| 267 | /// CRC32_OK | ||
| 266 | pub const CRC32_OK: u32 = 0x2144_df1c; | 268 | pub const CRC32_OK: u32 = 0x2144_df1c; |
| 267 | 269 | ||
| 270 | /// Create a new frame check sequence from `data`. | ||
| 268 | #[must_use] | 271 | #[must_use] |
| 269 | pub fn new(data: &[u8]) -> Self { | 272 | pub fn new(data: &[u8]) -> Self { |
| 270 | let fcs = data.iter().fold(u32::MAX, |crc, byte| { | 273 | let fcs = data.iter().fold(u32::MAX, |crc, byte| { |
| @@ -274,6 +277,7 @@ impl ETH_FCS { | |||
| 274 | Self(fcs) | 277 | Self(fcs) |
| 275 | } | 278 | } |
| 276 | 279 | ||
| 280 | /// Update the frame check sequence with `data`. | ||
| 277 | #[must_use] | 281 | #[must_use] |
| 278 | pub fn update(self, data: &[u8]) -> Self { | 282 | pub fn update(self, data: &[u8]) -> Self { |
| 279 | let fcs = data.iter().fold(self.0 ^ u32::MAX, |crc, byte| { | 283 | let fcs = data.iter().fold(self.0 ^ u32::MAX, |crc, byte| { |
| @@ -283,16 +287,19 @@ impl ETH_FCS { | |||
| 283 | Self(fcs) | 287 | Self(fcs) |
| 284 | } | 288 | } |
| 285 | 289 | ||
| 290 | /// Check if the frame check sequence is correct. | ||
| 286 | #[must_use] | 291 | #[must_use] |
| 287 | pub fn crc_ok(&self) -> bool { | 292 | pub fn crc_ok(&self) -> bool { |
| 288 | self.0 == Self::CRC32_OK | 293 | self.0 == Self::CRC32_OK |
| 289 | } | 294 | } |
| 290 | 295 | ||
| 296 | /// Switch byte order. | ||
| 291 | #[must_use] | 297 | #[must_use] |
| 292 | pub fn hton_bytes(&self) -> [u8; 4] { | 298 | pub fn hton_bytes(&self) -> [u8; 4] { |
| 293 | self.0.to_le_bytes() | 299 | self.0.to_le_bytes() |
| 294 | } | 300 | } |
| 295 | 301 | ||
| 302 | /// Switch byte order as a u32. | ||
| 296 | #[must_use] | 303 | #[must_use] |
| 297 | pub fn hton(&self) -> u32 { | 304 | pub fn hton(&self) -> u32 { |
| 298 | self.0.to_le() | 305 | 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 @@ | |||
| 5 | #![allow(clippy::missing_errors_doc)] | 5 | #![allow(clippy::missing_errors_doc)] |
| 6 | #![allow(clippy::missing_panics_doc)] | 6 | #![allow(clippy::missing_panics_doc)] |
| 7 | #![doc = include_str!("../README.md")] | 7 | #![doc = include_str!("../README.md")] |
| 8 | #![warn(missing_docs)] | ||
| 8 | 9 | ||
| 9 | // must go first! | 10 | // must go first! |
| 10 | mod fmt; | 11 | mod fmt; |
| @@ -446,6 +447,7 @@ pub struct Runner<'d, SPI, INT, RST> { | |||
| 446 | } | 447 | } |
| 447 | 448 | ||
| 448 | impl<'d, SPI: SpiDevice, INT: Wait, RST: OutputPin> Runner<'d, SPI, INT, RST> { | 449 | impl<'d, SPI: SpiDevice, INT: Wait, RST: OutputPin> Runner<'d, SPI, INT, RST> { |
| 450 | /// Run the driver. | ||
| 449 | #[allow(clippy::too_many_lines)] | 451 | #[allow(clippy::too_many_lines)] |
| 450 | pub async fn run(mut self) -> ! { | 452 | pub async fn run(mut self) -> ! { |
| 451 | loop { | 453 | 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 { | |||
| 39 | /// | 39 | /// |
| 40 | /// Clause 45 methodes are bases on <https://www.ieee802.org/3/efm/public/nov02/oam/pannell_oam_1_1102.pdf> | 40 | /// Clause 45 methodes are bases on <https://www.ieee802.org/3/efm/public/nov02/oam/pannell_oam_1_1102.pdf> |
| 41 | pub trait MdioBus { | 41 | pub trait MdioBus { |
| 42 | /// Error type. | ||
| 42 | type Error; | 43 | type Error; |
| 43 | 44 | ||
| 44 | /// Read, Clause 22 | 45 | /// 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 { | |||
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | impl DA1 { | 32 | impl DA1 { |
| 33 | /// Convert. | ||
| 33 | #[must_use] | 34 | #[must_use] |
| 34 | pub fn into(self) -> (u8, u16) { | 35 | pub fn into(self) -> (u8, u16) { |
| 35 | (0x01, self as u16) | 36 | (0x01, self as u16) |
| @@ -49,6 +50,7 @@ pub mod RegsC45 { | |||
| 49 | } | 50 | } |
| 50 | 51 | ||
| 51 | impl DA3 { | 52 | impl DA3 { |
| 53 | /// Convert. | ||
| 52 | #[must_use] | 54 | #[must_use] |
| 53 | pub fn into(self) -> (u8, u16) { | 55 | pub fn into(self) -> (u8, u16) { |
| 54 | (0x03, self as u16) | 56 | (0x03, self as u16) |
| @@ -64,6 +66,7 @@ pub mod RegsC45 { | |||
| 64 | } | 66 | } |
| 65 | 67 | ||
| 66 | impl DA7 { | 68 | impl DA7 { |
| 69 | /// Convert. | ||
| 67 | #[must_use] | 70 | #[must_use] |
| 68 | pub fn into(self) -> (u8, u16) { | 71 | pub fn into(self) -> (u8, u16) { |
| 69 | (0x07, self as u16) | 72 | (0x07, self as u16) |
| @@ -87,6 +90,7 @@ pub mod RegsC45 { | |||
| 87 | } | 90 | } |
| 88 | 91 | ||
| 89 | impl DA1E { | 92 | impl DA1E { |
| 93 | /// Convert. | ||
| 90 | #[must_use] | 94 | #[must_use] |
| 91 | pub fn into(self) -> (u8, u16) { | 95 | pub fn into(self) -> (u8, u16) { |
| 92 | (0x1e, self as u16) | 96 | (0x1e, self as u16) |
| @@ -104,6 +108,7 @@ pub mod RegsC45 { | |||
| 104 | } | 108 | } |
| 105 | 109 | ||
| 106 | impl DA1F { | 110 | impl DA1F { |
| 111 | /// Convert. | ||
| 107 | #[must_use] | 112 | #[must_use] |
| 108 | pub fn into(self) -> (u8, u16) { | 113 | pub fn into(self) -> (u8, u16) { |
| 109 | (0x1f, self as u16) | 114 | (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}; | |||
| 2 | 2 | ||
| 3 | use bitfield::{bitfield, bitfield_bitrange, bitfield_fields}; | 3 | use bitfield::{bitfield, bitfield_bitrange, bitfield_fields}; |
| 4 | 4 | ||
| 5 | #[allow(missing_docs)] | ||
| 5 | #[allow(non_camel_case_types)] | 6 | #[allow(non_camel_case_types)] |
| 6 | #[derive(Debug, Copy, Clone)] | 7 | #[derive(Debug, Copy, Clone)] |
| 7 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 8 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
