diff options
Diffstat (limited to 'embassy-net-adin1110')
| -rw-r--r-- | embassy-net-adin1110/src/lib.rs | 7 | ||||
| -rw-r--r-- | embassy-net-adin1110/src/phy.rs | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/embassy-net-adin1110/src/lib.rs b/embassy-net-adin1110/src/lib.rs index 78bf9fb8c..53f361284 100644 --- a/embassy-net-adin1110/src/lib.rs +++ b/embassy-net-adin1110/src/lib.rs | |||
| @@ -32,6 +32,7 @@ pub use regs::{Config0, Config2, SpiRegisters as sr, Status0, Status1}; | |||
| 32 | use crate::fmt::Bytes; | 32 | use crate::fmt::Bytes; |
| 33 | use crate::regs::{LedCntrl, LedFunc, LedPol, LedPolarity, SpiHeader}; | 33 | use crate::regs::{LedCntrl, LedFunc, LedPol, LedPolarity, SpiHeader}; |
| 34 | 34 | ||
| 35 | /// ADIN1110 intern PHY ID | ||
| 35 | pub const PHYID: u32 = 0x0283_BC91; | 36 | pub const PHYID: u32 = 0x0283_BC91; |
| 36 | 37 | ||
| 37 | /// Error values ADIN1110 | 38 | /// Error values ADIN1110 |
| @@ -53,7 +54,9 @@ pub enum AdinError<E> { | |||
| 53 | MDIO_ACC_TIMEOUT, | 54 | MDIO_ACC_TIMEOUT, |
| 54 | } | 55 | } |
| 55 | 56 | ||
| 57 | /// Type alias `Result` type with `AdinError` as error type. | ||
| 56 | pub type AEResult<T, SPIError> = core::result::Result<T, AdinError<SPIError>>; | 58 | pub type AEResult<T, SPIError> = core::result::Result<T, AdinError<SPIError>>; |
| 59 | |||
| 57 | /// Internet PHY address | 60 | /// Internet PHY address |
| 58 | pub const MDIO_PHY_ADDR: u8 = 0x01; | 61 | pub const MDIO_PHY_ADDR: u8 = 0x01; |
| 59 | 62 | ||
| @@ -104,6 +107,7 @@ impl<const N_RX: usize, const N_TX: usize> State<N_RX, N_TX> { | |||
| 104 | } | 107 | } |
| 105 | } | 108 | } |
| 106 | 109 | ||
| 110 | /// ADIN1110 embassy-net driver | ||
| 107 | #[derive(Debug)] | 111 | #[derive(Debug)] |
| 108 | pub struct ADIN1110<SPI> { | 112 | pub struct ADIN1110<SPI> { |
| 109 | /// SPI bus | 113 | /// SPI bus |
| @@ -116,6 +120,7 @@ pub struct ADIN1110<SPI> { | |||
| 116 | } | 120 | } |
| 117 | 121 | ||
| 118 | impl<SPI: SpiDevice> ADIN1110<SPI> { | 122 | impl<SPI: SpiDevice> ADIN1110<SPI> { |
| 123 | /// Create a new ADIN1110 instance. | ||
| 119 | pub fn new(spi: SPI, spi_crc: bool, append_fcs_on_tx: bool) -> Self { | 124 | pub fn new(spi: SPI, spi_crc: bool, append_fcs_on_tx: bool) -> Self { |
| 120 | Self { | 125 | Self { |
| 121 | spi, | 126 | spi, |
| @@ -124,6 +129,7 @@ impl<SPI: SpiDevice> ADIN1110<SPI> { | |||
| 124 | } | 129 | } |
| 125 | } | 130 | } |
| 126 | 131 | ||
| 132 | /// Read a SPI register | ||
| 127 | pub async fn read_reg(&mut self, reg: sr) -> AEResult<u32, SPI::Error> { | 133 | pub async fn read_reg(&mut self, reg: sr) -> AEResult<u32, SPI::Error> { |
| 128 | let mut tx_buf = Vec::<u8, 16>::new(); | 134 | let mut tx_buf = Vec::<u8, 16>::new(); |
| 129 | 135 | ||
| @@ -162,6 +168,7 @@ impl<SPI: SpiDevice> ADIN1110<SPI> { | |||
| 162 | Ok(value) | 168 | Ok(value) |
| 163 | } | 169 | } |
| 164 | 170 | ||
| 171 | /// Write a SPI register | ||
| 165 | pub async fn write_reg(&mut self, reg: sr, value: u32) -> AEResult<(), SPI::Error> { | 172 | pub async fn write_reg(&mut self, reg: sr, value: u32) -> AEResult<(), SPI::Error> { |
| 166 | let mut tx_buf = Vec::<u8, 16>::new(); | 173 | let mut tx_buf = Vec::<u8, 16>::new(); |
| 167 | 174 | ||
diff --git a/embassy-net-adin1110/src/phy.rs b/embassy-net-adin1110/src/phy.rs index 176ad019b..d54d843d2 100644 --- a/embassy-net-adin1110/src/phy.rs +++ b/embassy-net-adin1110/src/phy.rs | |||
| @@ -111,6 +111,7 @@ pub mod RegsC45 { | |||
| 111 | } | 111 | } |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | /// 10-BASE-T1x PHY functions. | ||
| 114 | pub struct Phy10BaseT1x(u8); | 115 | pub struct Phy10BaseT1x(u8); |
| 115 | 116 | ||
| 116 | impl Default for Phy10BaseT1x { | 117 | impl Default for Phy10BaseT1x { |
