diff --git a/examples/tcp_stm32f407.rs b/examples/tcp_stm32f407.rs index d734160..10e4e7a 100644 --- a/examples/tcp_stm32f407.rs +++ b/examples/tcp_stm32f407.rs @@ -180,7 +180,7 @@ const APP: () = { // Read MAC let mut eth_mac_addr: [u8; 6] = [0; 6]; - spi_eth.read_from_mac(&mut eth_mac_addr).unwrap(); + spi_eth.read_from_mac(&mut eth_mac_addr); for i in 0..6 { let byte = eth_mac_addr[i]; match i { @@ -192,8 +192,8 @@ const APP: () = { } // Init Rx/Tx buffers - spi_eth.init_rxbuf().unwrap(); - spi_eth.init_txbuf().unwrap(); + spi_eth.init_rxbuf(); + spi_eth.init_txbuf(); iprintln!(stim0, "Ethernet controller initialized"); // Init smoltcp interface diff --git a/examples/tx_stm32f407.rs b/examples/tx_stm32f407.rs index 6c36402..93d6ab9 100644 --- a/examples/tx_stm32f407.rs +++ b/examples/tx_stm32f407.rs @@ -102,7 +102,7 @@ const APP: () = { // Read MAC let mut eth_mac_addr: [u8; 6] = [0; 6]; - spi_eth.read_from_mac(&mut eth_mac_addr).unwrap(); + spi_eth.read_from_mac(&mut eth_mac_addr); for i in 0..6 { let byte = eth_mac_addr[i]; match i { @@ -114,8 +114,8 @@ const APP: () = { } // Init Rx/Tx buffers - spi_eth.init_rxbuf().unwrap(); - spi_eth.init_txbuf().unwrap(); + spi_eth.init_rxbuf(); + spi_eth.init_txbuf(); iprintln!(stim0, "Ethernet controller initialized"); init::LateResources { @@ -157,7 +157,7 @@ const APP: () = { _ => () }; } - c.resources.spi_eth.send_raw_packet(ð_tx_packet).unwrap(); + c.resources.spi_eth.send_raw_packet(ð_tx_packet); iprintln!(stim0, "Packet sent"); c.resources.delay.delay_ms(100_u32); } diff --git a/src/lib.rs b/src/lib.rs index e99cefa..71e6e7c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -54,9 +54,9 @@ pub struct SpiEth, impl , NSS: OutputPin, F: FnMut(u32) -> ()> SpiEth { - pub fn new(spi: SPI, nss: NSS, f: F) -> Self { + pub fn new(spi: SPI, nss: NSS, delay_ns: F) -> Self { SpiEth { - spi_port: spi::SpiPort::new(spi, nss, f), + spi_port: spi::SpiPort::new(spi, nss, delay_ns), rx_buf: rx::RxBuffer::new(), tx_buf: tx::TxBuffer::new() } diff --git a/src/spi.rs b/src/spi.rs index 6bb1d37..a5dd23c 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -1,5 +1,5 @@ use embedded_hal::{ - blocking::{spi::Transfer}, + blocking::spi::Transfer, digital::v2::OutputPin, }; @@ -68,13 +68,13 @@ impl , NSS: OutputPin, F: FnMut(u32) -> ()> SpiPort { // TODO: return as Result() - pub fn new(spi: SPI, mut nss: NSS, f: F) -> Self { + pub fn new(spi: SPI, mut nss: NSS, delay_ns: F) -> Self { nss.set_high(); SpiPort { spi, nss, - delay_ns: f, + delay_ns, } }