examples: Replace delay_ns with cortex-m delay
This commit is contained in:
parent
999ca5f08a
commit
d8b1132b8a
|
@ -38,11 +38,11 @@ smoltcp-examples = [
|
||||||
"smoltcp-phy", "smoltcp/socket-tcp", "smoltcp/ethernet"
|
"smoltcp-phy", "smoltcp/socket-tcp", "smoltcp/ethernet"
|
||||||
]
|
]
|
||||||
tx_stm32f407 = [
|
tx_stm32f407 = [
|
||||||
"stm32f4xx-hal/stm32f407", "cortex-m", "cortex-m-rtic",
|
"stm32f4xx-hal/stm32f407", "cortex-m", "cortex-m-rtic", "cortex-m-cpu",
|
||||||
"panic-itm", "log"
|
"panic-itm", "log"
|
||||||
]
|
]
|
||||||
tcp_stm32f407 = [
|
tcp_stm32f407 = [
|
||||||
"stm32f4xx-hal/stm32f407", "cortex-m", "cortex-m-rt", "cortex-m-rtic",
|
"stm32f4xx-hal/stm32f407", "cortex-m", "cortex-m-rt", "cortex-m-rtic", "cortex-m-cpu",
|
||||||
"smoltcp-examples", "panic-itm", "log"]
|
"smoltcp-examples", "panic-itm", "log"]
|
||||||
default = []
|
default = []
|
||||||
|
|
||||||
|
|
|
@ -79,8 +79,7 @@ use stm32f4xx_hal::{
|
||||||
};
|
};
|
||||||
type SpiEth = enc424j600::Enc424j600<
|
type SpiEth = enc424j600::Enc424j600<
|
||||||
Spi<SPI1, (PA5<Alternate<AF5>>, PA6<Alternate<AF5>>, PA7<Alternate<AF5>>)>,
|
Spi<SPI1, (PA5<Alternate<AF5>>, PA6<Alternate<AF5>>, PA7<Alternate<AF5>>)>,
|
||||||
PA4<Output<PushPull>>,
|
PA4<Output<PushPull>>
|
||||||
fn(u32) -> ()
|
|
||||||
>;
|
>;
|
||||||
|
|
||||||
pub struct NetStorage {
|
pub struct NetStorage {
|
||||||
|
@ -153,14 +152,12 @@ const APP: () = {
|
||||||
Hertz(enc424j600::spi::interfaces::SPI_CLOCK_FREQ),
|
Hertz(enc424j600::spi::interfaces::SPI_CLOCK_FREQ),
|
||||||
clocks);
|
clocks);
|
||||||
|
|
||||||
let delay_ns_fp: fn(u32) -> () = |time_ns| {
|
SpiEth::new(spi_eth_port, spi1_nss)
|
||||||
cortex_m::asm::delay((time_ns*21)/125 + 1)
|
.cpu_freq_mhz(168)
|
||||||
};
|
|
||||||
SpiEth::new(spi_eth_port, spi1_nss, delay_ns_fp)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Init controller
|
// Init controller
|
||||||
match spi_eth.reset() {
|
match spi_eth.reset(&mut delay) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
iprintln!(stim0, "Initializing Ethernet...")
|
iprintln!(stim0, "Initializing Ethernet...")
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,7 @@ use stm32f4xx_hal::{
|
||||||
};
|
};
|
||||||
type SpiEth = enc424j600::Enc424j600<
|
type SpiEth = enc424j600::Enc424j600<
|
||||||
Spi<SPI1, (PA5<Alternate<AF5>>, PA6<Alternate<AF5>>, PA7<Alternate<AF5>>)>,
|
Spi<SPI1, (PA5<Alternate<AF5>>, PA6<Alternate<AF5>>, PA7<Alternate<AF5>>)>,
|
||||||
PA4<Output<PushPull>>,
|
PA4<Output<PushPull>>
|
||||||
fn(u32) -> ()
|
|
||||||
>;
|
>;
|
||||||
|
|
||||||
#[rtic::app(device = stm32f4xx_hal::stm32, peripherals = true, monotonic = rtic::cyccnt::CYCCNT)]
|
#[rtic::app(device = stm32f4xx_hal::stm32, peripherals = true, monotonic = rtic::cyccnt::CYCCNT)]
|
||||||
|
@ -84,14 +83,12 @@ const APP: () = {
|
||||||
Hertz(enc424j600::spi::interfaces::SPI_CLOCK_FREQ),
|
Hertz(enc424j600::spi::interfaces::SPI_CLOCK_FREQ),
|
||||||
clocks);
|
clocks);
|
||||||
|
|
||||||
let delay_ns: fn(u32) -> () = |time_ns| {
|
SpiEth::new(spi_eth_port, spi1_nss)
|
||||||
cortex_m::asm::delay((time_ns*21)/125 + 1)
|
.cpu_freq_mhz(168)
|
||||||
};
|
|
||||||
SpiEth::new(spi_eth_port, spi1_nss, delay_ns)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Init
|
// Init
|
||||||
match spi_eth.reset() {
|
match spi_eth.reset(&mut delay) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
iprintln!(stim0, "Initializing Ethernet...")
|
iprintln!(stim0, "Initializing Ethernet...")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue