Skip to content

Commit 27d68d1

Browse files
committed
Remove the SPI::Error as a generic parameter.
1 parent 9f25836 commit 27d68d1

File tree

1 file changed

+12
-19
lines changed
  • embassy-net-adin1110/src

1 file changed

+12
-19
lines changed

embassy-net-adin1110/src/lib.rs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![allow(clippy::module_name_repetitions)]
55
#![allow(clippy::missing_errors_doc)]
66
#![allow(clippy::missing_panics_doc)]
7+
#![doc = include_str!("../README.md")]
78

89
mod crc32;
910
mod crc8;
@@ -43,7 +44,7 @@ pub enum AdinError<E> {
4344
MDIO_ACC_TIMEOUT,
4445
}
4546

46-
pub type AEResult<T, SPIE> = core::result::Result<T, AdinError<SPIE>>;
47+
pub type AEResult<T, SPIError> = core::result::Result<T, AdinError<SPIError>>;
4748
pub const MDIO_PHY_ADDR: u8 = 0x01;
4849

4950
/// Maximum Transmission Unit
@@ -99,16 +100,12 @@ pub(crate) fn size_align_u32(size: u32) -> u32 {
99100
(size + 3) & 0xFFFF_FFFC
100101
}
101102

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> {
107104
pub fn new(spi: SPI, crc: bool) -> Self {
108105
Self { spi, crc }
109106
}
110107

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> {
112109
let mut tx_buf = Vec::<u8, 16>::new();
113110

114111
let mut spi_hdr = SpiHeader(0);
@@ -147,7 +144,7 @@ where
147144
Ok(value)
148145
}
149146

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> {
151148
let mut tx_buf = Vec::<u8, 16>::new();
152149

153150
let mut spi_hdr = SpiHeader(0);
@@ -176,7 +173,7 @@ where
176173
}
177174

178175
/// 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> {
180177
self.write_reg(sr::MDIO_ACC, mdio_acc_val).await?;
181178

182179
// TODO: Add proper timeout!
@@ -191,7 +188,7 @@ where
191188
}
192189

193190
/// 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> {
195192
let mut tx_buf = Vec::<u8, 16>::new();
196193

197194
// Size of the frame, also includes the appednded header.
@@ -237,7 +234,7 @@ where
237234
}
238235

239236
/// 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> {
241238
let header_len = self.header_write_len();
242239

243240
let mut packet = Packet::new();
@@ -317,7 +314,7 @@ where
317314
/// Programs the mac address in the mac filters.
318315
/// Also set the boardcast address.
319316
/// 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> {
321318
let mac_high_part = u16::from_be_bytes(mac[0..2].try_into().unwrap());
322319
let mac_low_part = u32::from_be_bytes(mac[2..6].try_into().unwrap());
323320

@@ -340,12 +337,8 @@ where
340337
}
341338
}
342339

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>;
349342

350343
/// Read from the PHY Registers as Clause 22.
351344
async fn read_cl22(&mut self, phy_id: u8, reg: u8) -> Result<u16, Self::Error> {
@@ -379,7 +372,7 @@ where
379372
}
380373

381374
/// 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> {
383376
let phy_id = u32::from(phy_id & 0x1F) << 21;
384377
let dev_addr = u32::from(regc45.0 & 0x1F) << 16;
385378
let reg = u32::from(regc45.1);

0 commit comments

Comments
 (0)