example/tcp: fix delay reference
This commit is contained in:
parent
d557e2542d
commit
5bdfd21e93
@ -13,6 +13,7 @@ use stm32f4xx_hal::{
|
||||
gpio::GpioExt,
|
||||
time::U32Ext,
|
||||
stm32::ITM,
|
||||
delay::Delay,
|
||||
spi::Spi,
|
||||
time::Hertz
|
||||
};
|
||||
@ -27,9 +28,6 @@ use smoltcp::socket::{SocketSet, TcpSocket, TcpSocketBuffer};
|
||||
use core::str;
|
||||
use core::fmt::Write;
|
||||
|
||||
mod delay;
|
||||
use delay::AsmDelay;
|
||||
|
||||
/// Timer
|
||||
use core::cell::RefCell;
|
||||
use cortex_m::interrupt::Mutex;
|
||||
@ -99,10 +97,6 @@ static mut NET_STORE: NetStorage = NetStorage {
|
||||
neighbor_cache: [None; 8],
|
||||
};
|
||||
|
||||
pub fn delay_ns(time_ns: u32) {
|
||||
cortex_m::asm::delay((time_ns*168_000_000)/1_000_000_000 + 1)
|
||||
}
|
||||
|
||||
#[rtic::app(device = stm32f4xx_hal::stm32, peripherals = true, monotonic = rtic::cyccnt::CYCCNT)]
|
||||
const APP: () = {
|
||||
struct Resources {
|
||||
@ -130,7 +124,7 @@ const APP: () = {
|
||||
.pclk1(42.mhz())
|
||||
.require_pll48clk()
|
||||
.freeze();
|
||||
let mut asm_delay = AsmDelay::new(clocks.sysclk().0);
|
||||
let mut delay = Delay::new(c.core.SYST, clocks);
|
||||
|
||||
// Init ITM
|
||||
let mut itm = c.core.ITM;
|
||||
@ -150,7 +144,7 @@ const APP: () = {
|
||||
// Map SPISEL: see Table 1, NIC100 Manual
|
||||
let mut spisel = gpioa.pa1.into_push_pull_output();
|
||||
spisel.set_high().unwrap();
|
||||
asm_delay.delay_ms(1_u32);
|
||||
delay.delay_ms(1_u32);
|
||||
spisel.set_low().unwrap();
|
||||
|
||||
// Create SPI1 for HAL
|
||||
@ -217,7 +211,7 @@ const APP: () = {
|
||||
|
||||
// Setup SysTick after releasing SYST from Delay
|
||||
// Reference to stm32-eth:examples/ip.rs
|
||||
timer_setup(c.core.SYST, clocks);
|
||||
timer_setup(delay.free(), clocks);
|
||||
iprintln!(stim0, "Timer initialized");
|
||||
|
||||
init::LateResources {
|
||||
|
@ -84,10 +84,10 @@ const APP: () = {
|
||||
Hertz(enc424j600::spi::interfaces::SPI_CLOCK_FREQ),
|
||||
clocks);
|
||||
|
||||
let delay_ns_fp: fn(u32) -> () = |time_ns| {
|
||||
let delay_ns: fn(u32) -> () = |time_ns| {
|
||||
cortex_m::asm::delay((time_ns*21)/125 + 1)
|
||||
};
|
||||
enc424j600::SpiEth::new(spi_eth_port, spi1_nss, delay_ns_fp)
|
||||
enc424j600::SpiEth::new(spi_eth_port, spi1_nss, delay_ns)
|
||||
};
|
||||
|
||||
// Init
|
||||
|
Loading…
Reference in New Issue
Block a user