Remove cortex-m dependencies for delay #2

Merged
sb10q merged 8 commits from occheung/ENC424J600:generalize_delay into master 2021-01-25 12:35:23 +08:00
4 changed files with 12 additions and 12 deletions
Showing only changes of commit d557e2542d - Show all commits

View File

@ -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);
Outdated
Review

unrelated change

unrelated change
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

View File

@ -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(&eth_tx_packet).unwrap();
c.resources.spi_eth.send_raw_packet(&eth_tx_packet);
iprintln!(stim0, "Packet sent");
c.resources.delay.delay_ms(100_u32);
}

View File

@ -54,9 +54,9 @@ pub struct SpiEth<SPI: Transfer<u8>,
impl <SPI: Transfer<u8>,
NSS: OutputPin,
F: FnMut(u32) -> ()> SpiEth<SPI, NSS, F> {
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()
}

View File

@ -1,5 +1,5 @@
use embedded_hal::{
blocking::{spi::Transfer},
blocking::spi::Transfer,
Outdated
Review

not needed

not needed
digital::v2::OutputPin,
};
@ -68,13 +68,13 @@ impl <SPI: Transfer<u8>,
NSS: OutputPin,
F: FnMut(u32) -> ()> SpiPort<SPI, NSS, F> {
// 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 {
Outdated
Review

why f and not delay_ns?

why ``f`` and not ``delay_ns``?
nss.set_high();
SpiPort {
spi,
nss,
delay_ns: f,
delay_ns,
}
}