From 056f812e6035351d5c7a66ec2ed8fc1de315f70b Mon Sep 17 00:00:00 2001 From: occheung Date: Wed, 20 Jan 2021 17:27:02 +0800 Subject: [PATCH] init: use delay from internal spi --- src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d96cbaf..baf065f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,6 +67,7 @@ impl , impl , NSS: OutputPin, Delay: DelayUs> EthController for SpiEth { + fn init_dev(&mut self) -> Result<(), EthControllerError> { // Write 0x1234 to EUDAST self.spi_port.write_reg_16b(spi::addrs::EUDAST, 0x1234)?; // Verify that EUDAST is 0x1234 @@ -83,14 +84,14 @@ impl , let econ2 = self.spi_port.read_reg_8b(spi::addrs::ECON2)?; self.spi_port.write_reg_8b(spi::addrs::ECON2, 0x10 | (econ2 & 0b11101111))?; // Wait for 25us - delay.delay_us(25_u16); + self.spi_port.delay_us(25_u16); // Verify that EUDAST is 0x0000 eudast = self.spi_port.read_reg_16b(spi::addrs::EUDAST)?; if eudast != 0x0000 { return Err(EthControllerError::GeneralError) } // Wait for 256us - delay.delay_us(256_u16); + self.spi_port.delay_us(256_u16); Ok(()) }