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