4
4
#![ allow( clippy:: module_name_repetitions) ]
5
5
#![ allow( clippy:: missing_errors_doc) ]
6
6
#![ allow( clippy:: missing_panics_doc) ]
7
+ #![ doc = include_str ! ( "../README.md" ) ]
7
8
8
9
mod crc32;
9
10
mod crc8;
@@ -43,7 +44,7 @@ pub enum AdinError<E> {
43
44
MDIO_ACC_TIMEOUT ,
44
45
}
45
46
46
- pub type AEResult < T , SPIE > = core:: result:: Result < T , AdinError < SPIE > > ;
47
+ pub type AEResult < T , SPIError > = core:: result:: Result < T , AdinError < SPIError > > ;
47
48
pub const MDIO_PHY_ADDR : u8 = 0x01 ;
48
49
49
50
/// Maximum Transmission Unit
@@ -99,16 +100,12 @@ pub(crate) fn size_align_u32(size: u32) -> u32 {
99
100
( size + 3 ) & 0xFFFF_FFFC
100
101
}
101
102
102
- impl < SpiE , SPI > ADIN1110 < SPI >
103
- where
104
- SPI : SpiDevice < u8 , Error = SpiE > ,
105
- SpiE : core:: fmt:: Debug ,
106
- {
103
+ impl < SPI : SpiDevice > ADIN1110 < SPI > {
107
104
pub fn new ( spi : SPI , crc : bool ) -> Self {
108
105
Self { spi, crc }
109
106
}
110
107
111
- pub async fn read_reg ( & mut self , reg : sr ) -> AEResult < u32 , SpiE > {
108
+ pub async fn read_reg ( & mut self , reg : sr ) -> AEResult < u32 , SPI :: Error > {
112
109
let mut tx_buf = Vec :: < u8 , 16 > :: new ( ) ;
113
110
114
111
let mut spi_hdr = SpiHeader ( 0 ) ;
@@ -147,7 +144,7 @@ where
147
144
Ok ( value)
148
145
}
149
146
150
- pub async fn write_reg ( & mut self , reg : sr , value : u32 ) -> AEResult < ( ) , SpiE > {
147
+ pub async fn write_reg ( & mut self , reg : sr , value : u32 ) -> AEResult < ( ) , SPI :: Error > {
151
148
let mut tx_buf = Vec :: < u8 , 16 > :: new ( ) ;
152
149
153
150
let mut spi_hdr = SpiHeader ( 0 ) ;
@@ -176,7 +173,7 @@ where
176
173
}
177
174
178
175
/// helper function for write to `MDIO_ACC` register and wait for ready!
179
- async fn write_mdio_acc_reg ( & mut self , mdio_acc_val : u32 ) -> AEResult < u32 , SpiE > {
176
+ async fn write_mdio_acc_reg ( & mut self , mdio_acc_val : u32 ) -> AEResult < u32 , SPI :: Error > {
180
177
self . write_reg ( sr:: MDIO_ACC , mdio_acc_val) . await ?;
181
178
182
179
// TODO: Add proper timeout!
@@ -191,7 +188,7 @@ where
191
188
}
192
189
193
190
/// Read out fifo ethernet packet memory received via the wire.
194
- pub async fn read_fifo ( & mut self , packet : & mut [ u8 ] ) -> AEResult < usize , SpiE > {
191
+ pub async fn read_fifo ( & mut self , packet : & mut [ u8 ] ) -> AEResult < usize , SPI :: Error > {
195
192
let mut tx_buf = Vec :: < u8 , 16 > :: new ( ) ;
196
193
197
194
// Size of the frame, also includes the appednded header.
@@ -237,7 +234,7 @@ where
237
234
}
238
235
239
236
/// Write to fifo ethernet packet memory send over the wire.
240
- pub async fn write_fifo ( & mut self , frame : & [ u8 ] ) -> AEResult < ( ) , SpiE > {
237
+ pub async fn write_fifo ( & mut self , frame : & [ u8 ] ) -> AEResult < ( ) , SPI :: Error > {
241
238
let header_len = self . header_write_len ( ) ;
242
239
243
240
let mut packet = Packet :: new ( ) ;
@@ -317,7 +314,7 @@ where
317
314
/// Programs the mac address in the mac filters.
318
315
/// Also set the boardcast address.
319
316
/// The chip supports 2 priority queues but current code doesn't support this mode.
320
- pub async fn set_mac_addr ( & mut self , mac : & [ u8 ; 6 ] ) -> AEResult < ( ) , SpiE > {
317
+ pub async fn set_mac_addr ( & mut self , mac : & [ u8 ; 6 ] ) -> AEResult < ( ) , SPI :: Error > {
321
318
let mac_high_part = u16:: from_be_bytes ( mac[ 0 ..2 ] . try_into ( ) . unwrap ( ) ) ;
322
319
let mac_low_part = u32:: from_be_bytes ( mac[ 2 ..6 ] . try_into ( ) . unwrap ( ) ) ;
323
320
@@ -340,12 +337,8 @@ where
340
337
}
341
338
}
342
339
343
- impl < SpiE , SPI > mdio:: MdioBus for ADIN1110 < SPI >
344
- where
345
- SPI : SpiDevice < u8 , Error = SpiE > ,
346
- SpiE : core:: fmt:: Debug ,
347
- {
348
- type Error = AdinError < SpiE > ;
340
+ impl < SPI : SpiDevice > mdio:: MdioBus for ADIN1110 < SPI > {
341
+ type Error = AdinError < SPI :: Error > ;
349
342
350
343
/// Read from the PHY Registers as Clause 22.
351
344
async fn read_cl22 ( & mut self , phy_id : u8 , reg : u8 ) -> Result < u16 , Self :: Error > {
@@ -379,7 +372,7 @@ where
379
372
}
380
373
381
374
/// Write to the PHY Registers as Clause 45.
382
- async fn write_cl45 ( & mut self , phy_id : u8 , regc45 : ( u8 , u16 ) , value : u16 ) -> AEResult < ( ) , SpiE > {
375
+ async fn write_cl45 ( & mut self , phy_id : u8 , regc45 : ( u8 , u16 ) , value : u16 ) -> AEResult < ( ) , SPI :: Error > {
383
376
let phy_id = u32:: from ( phy_id & 0x1F ) << 21 ;
384
377
let dev_addr = u32:: from ( regc45. 0 & 0x1F ) << 16 ;
385
378
let reg = u32:: from ( regc45. 1 ) ;
0 commit comments