diff --git a/examples/delay.rs b/examples/delay.rs index d3bbbb3..204fe0a 100644 --- a/examples/delay.rs +++ b/examples/delay.rs @@ -1,5 +1,6 @@ use embedded_hal::blocking::delay::{DelayMs, DelayUs}; +#[derive(Clone, Copy)] pub struct AsmDelay { frequency_us: u32, frequency_ms: u32, diff --git a/examples/tcp_stm32f407.rs b/examples/tcp_stm32f407.rs index a64b860..9727c4e 100644 --- a/examples/tcp_stm32f407.rs +++ b/examples/tcp_stm32f407.rs @@ -13,7 +13,6 @@ use stm32f4xx_hal::{ gpio::GpioExt, time::U32Ext, stm32::ITM, - delay::Delay, spi::Spi, time::Hertz }; @@ -127,8 +126,7 @@ const APP: () = { .pclk1(42.mhz()) .require_pll48clk() .freeze(); - let asm_delay = AsmDelay::new(clocks.sysclk().0); - let mut hal_delay = Delay::new(c.core.SYST, clocks); + let mut asm_delay = AsmDelay::new(clocks.sysclk().0); // Init ITM let mut itm = c.core.ITM; @@ -148,7 +146,7 @@ const APP: () = { // Map SPISEL: see Table 1, NIC100 Manual let mut spisel = gpioa.pa1.into_push_pull_output(); spisel.set_high().unwrap(); - hal_delay.delay_ms(1_u32); + asm_delay.delay_ms(1_u32); spisel.set_low().unwrap(); // Create SPI1 for HAL @@ -211,7 +209,7 @@ const APP: () = { // Setup SysTick after releasing SYST from Delay // Reference to stm32-eth:examples/ip.rs - timer_setup(hal_delay.free(), clocks); + timer_setup(c.core.SYST, clocks); iprintln!(stim0, "Timer initialized"); init::LateResources { diff --git a/examples/tx_stm32f407.rs b/examples/tx_stm32f407.rs index da8d7fc..fb76a6a 100644 --- a/examples/tx_stm32f407.rs +++ b/examples/tx_stm32f407.rs @@ -13,7 +13,6 @@ use stm32f4xx_hal::{ gpio::GpioExt, time::U32Ext, stm32::ITM, - delay::Delay, spi::Spi, time::Hertz }; @@ -40,7 +39,7 @@ type BoosterSpiEth = enc424j600::SpiEth< const APP: () = { struct Resources { spi_eth: BoosterSpiEth, - delay: Delay, + delay: AsmDelay, itm: ITM, } @@ -58,8 +57,7 @@ const APP: () = { //.pclk2(64.mhz()) .require_pll48clk() .freeze(); - let asm_delay = AsmDelay::new(clocks.sysclk().0); - let mut delay = Delay::new(c.core.SYST, clocks); + let mut asm_delay = AsmDelay::new(clocks.sysclk().0); // Init ITM let mut itm = c.core.ITM; @@ -78,7 +76,7 @@ const APP: () = { // Map SPISEL: see Table 1, NIC100 Manual let mut spisel = gpioa.pa1.into_push_pull_output(); spisel.set_high().unwrap(); - delay.delay_ms(1_u32); + asm_delay.delay_ms(1_u32); spisel.set_low().unwrap(); // Create SPI1 for HAL let mut spi_eth = { @@ -120,7 +118,7 @@ const APP: () = { init::LateResources { spi_eth, - delay, + delay: asm_delay, itm, } }