docs: embassy-net-adin1110
This commit is contained in:
parent
52a801fdb7
commit
246c49621c
@ -6,8 +6,7 @@ keywords = ["embedded", "ADIN1110", "embassy-net", "embedded-hal-async", "ethern
|
|||||||
categories = ["embedded", "hardware-support", "no-std", "network-programming", "async"]
|
categories = ["embedded", "hardware-support", "no-std", "network-programming", "async"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
repository = "https://github.com/embassy-rs/embassy"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
heapless = "0.8"
|
heapless = "0.8"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
/// CRC32 lookup table.
|
||||||
pub const CRC32R_LOOKUP_TABLE: [u32; 256] = [
|
pub const CRC32R_LOOKUP_TABLE: [u32; 256] = [
|
||||||
0x0000_0000,
|
0x0000_0000,
|
||||||
0x7707_3096,
|
0x7707_3096,
|
||||||
@ -263,8 +264,10 @@ pub const CRC32R_LOOKUP_TABLE: [u32; 256] = [
|
|||||||
pub struct ETH_FCS(pub u32);
|
pub struct ETH_FCS(pub u32);
|
||||||
|
|
||||||
impl ETH_FCS {
|
impl ETH_FCS {
|
||||||
|
/// CRC32_OK
|
||||||
pub const CRC32_OK: u32 = 0x2144_df1c;
|
pub const CRC32_OK: u32 = 0x2144_df1c;
|
||||||
|
|
||||||
|
/// Create a new frame check sequence from `data`.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(data: &[u8]) -> Self {
|
pub fn new(data: &[u8]) -> Self {
|
||||||
let fcs = data.iter().fold(u32::MAX, |crc, byte| {
|
let fcs = data.iter().fold(u32::MAX, |crc, byte| {
|
||||||
@ -274,6 +277,7 @@ impl ETH_FCS {
|
|||||||
Self(fcs)
|
Self(fcs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Update the frame check sequence with `data`.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn update(self, data: &[u8]) -> Self {
|
pub fn update(self, data: &[u8]) -> Self {
|
||||||
let fcs = data.iter().fold(self.0 ^ u32::MAX, |crc, byte| {
|
let fcs = data.iter().fold(self.0 ^ u32::MAX, |crc, byte| {
|
||||||
@ -283,16 +287,19 @@ impl ETH_FCS {
|
|||||||
Self(fcs)
|
Self(fcs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check if the frame check sequence is correct.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn crc_ok(&self) -> bool {
|
pub fn crc_ok(&self) -> bool {
|
||||||
self.0 == Self::CRC32_OK
|
self.0 == Self::CRC32_OK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Switch byte order.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn hton_bytes(&self) -> [u8; 4] {
|
pub fn hton_bytes(&self) -> [u8; 4] {
|
||||||
self.0.to_le_bytes()
|
self.0.to_le_bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Switch byte order as a u32.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn hton(&self) -> u32 {
|
pub fn hton(&self) -> u32 {
|
||||||
self.0.to_le()
|
self.0.to_le()
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#![allow(clippy::missing_errors_doc)]
|
#![allow(clippy::missing_errors_doc)]
|
||||||
#![allow(clippy::missing_panics_doc)]
|
#![allow(clippy::missing_panics_doc)]
|
||||||
#![doc = include_str!("../README.md")]
|
#![doc = include_str!("../README.md")]
|
||||||
|
#![warn(missing_docs)]
|
||||||
|
|
||||||
// must go first!
|
// must go first!
|
||||||
mod fmt;
|
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> {
|
impl<'d, SPI: SpiDevice, INT: Wait, RST: OutputPin> Runner<'d, SPI, INT, RST> {
|
||||||
|
/// Run the driver.
|
||||||
#[allow(clippy::too_many_lines)]
|
#[allow(clippy::too_many_lines)]
|
||||||
pub async fn run(mut self) -> ! {
|
pub async fn run(mut self) -> ! {
|
||||||
loop {
|
loop {
|
||||||
|
@ -39,6 +39,7 @@ enum Reg13Op {
|
|||||||
///
|
///
|
||||||
/// Clause 45 methodes are bases on <https://www.ieee802.org/3/efm/public/nov02/oam/pannell_oam_1_1102.pdf>
|
/// Clause 45 methodes are bases on <https://www.ieee802.org/3/efm/public/nov02/oam/pannell_oam_1_1102.pdf>
|
||||||
pub trait MdioBus {
|
pub trait MdioBus {
|
||||||
|
/// Error type.
|
||||||
type Error;
|
type Error;
|
||||||
|
|
||||||
/// Read, Clause 22
|
/// Read, Clause 22
|
||||||
|
@ -30,6 +30,7 @@ pub mod RegsC45 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DA1 {
|
impl DA1 {
|
||||||
|
/// Convert.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn into(self) -> (u8, u16) {
|
pub fn into(self) -> (u8, u16) {
|
||||||
(0x01, self as u16)
|
(0x01, self as u16)
|
||||||
@ -49,6 +50,7 @@ pub mod RegsC45 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DA3 {
|
impl DA3 {
|
||||||
|
/// Convert.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn into(self) -> (u8, u16) {
|
pub fn into(self) -> (u8, u16) {
|
||||||
(0x03, self as u16)
|
(0x03, self as u16)
|
||||||
@ -64,6 +66,7 @@ pub mod RegsC45 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DA7 {
|
impl DA7 {
|
||||||
|
/// Convert.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn into(self) -> (u8, u16) {
|
pub fn into(self) -> (u8, u16) {
|
||||||
(0x07, self as u16)
|
(0x07, self as u16)
|
||||||
@ -87,6 +90,7 @@ pub mod RegsC45 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DA1E {
|
impl DA1E {
|
||||||
|
/// Convert.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn into(self) -> (u8, u16) {
|
pub fn into(self) -> (u8, u16) {
|
||||||
(0x1e, self as u16)
|
(0x1e, self as u16)
|
||||||
@ -104,6 +108,7 @@ pub mod RegsC45 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DA1F {
|
impl DA1F {
|
||||||
|
/// Convert.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn into(self) -> (u8, u16) {
|
pub fn into(self) -> (u8, u16) {
|
||||||
(0x1f, self as u16)
|
(0x1f, self as u16)
|
||||||
|
@ -2,6 +2,7 @@ use core::fmt::{Debug, Display};
|
|||||||
|
|
||||||
use bitfield::{bitfield, bitfield_bitrange, bitfield_fields};
|
use bitfield::{bitfield, bitfield_bitrange, bitfield_fields};
|
||||||
|
|
||||||
|
#[allow(missing_docs)]
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||||
|
Loading…
Reference in New Issue
Block a user