Cleanup stm32f4 examples

* Remove dependency on stm32f4 pac crate
* Remove unused `ZeroClock`
This commit is contained in:
Timo Kröger 2021-07-21 23:12:36 +02:00
parent 40ea8298ee
commit 5e998d1a6c
7 changed files with 101 additions and 170 deletions

View File

@ -19,9 +19,8 @@ defmt-error = []
[dependencies]
embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-trace"] }
embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] }
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "defmt-trace", "stm32f429zi"] }
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "defmt-trace", "stm32f429zi", "unstable-pac"] }
embassy-extras = {version = "0.1.0", path = "../../embassy-extras" }
stm32f4 = { version = "0.13", features = ["stm32f429"] }
defmt = "0.2.0"
defmt-rtt = "0.2.0"

View File

@ -9,34 +9,32 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::pac;
use embedded_hal::digital::v2::OutputPin;
use example_common::*;
use cortex_m_rt::entry;
use stm32f4::stm32f429 as pac;
#[entry]
fn main() -> ! {
info!("Hello World!");
let pp = pac::Peripherals::take().unwrap();
unsafe {
pac::DBGMCU.cr().modify(|w| {
w.set_dbg_sleep(true);
w.set_dbg_standby(true);
w.set_dbg_stop(true);
});
pp.DBGMCU.cr.modify(|_, w| {
w.dbg_sleep().set_bit();
w.dbg_standby().set_bit();
w.dbg_stop().set_bit()
});
pp.RCC.ahb1enr.modify(|_, w| w.dma1en().enabled());
pp.RCC.ahb1enr.modify(|_, w| {
w.gpioaen().enabled();
w.gpioben().enabled();
w.gpiocen().enabled();
w.gpioden().enabled();
w.gpioeen().enabled();
w.gpiofen().enabled();
w
});
pac::RCC.ahb1enr().modify(|w| {
w.set_gpioaen(true);
w.set_gpioben(true);
w.set_gpiocen(true);
w.set_gpioden(true);
w.set_gpioeen(true);
w.set_gpiofen(true);
});
}
let p = embassy_stm32::init(Default::default());

View File

@ -8,35 +8,32 @@
#[path = "../example_common.rs"]
mod example_common;
use cortex_m_rt::entry;
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
use embassy_stm32::pac;
use embedded_hal::digital::v2::{InputPin, OutputPin};
use example_common::*;
use cortex_m_rt::entry;
use stm32f4::stm32f429 as pac;
#[entry]
fn main() -> ! {
info!("Hello World!");
let pp = pac::Peripherals::take().unwrap();
unsafe {
pac::DBGMCU.cr().modify(|w| {
w.set_dbg_sleep(true);
w.set_dbg_standby(true);
w.set_dbg_stop(true);
});
pp.DBGMCU.cr.modify(|_, w| {
w.dbg_sleep().set_bit();
w.dbg_standby().set_bit();
w.dbg_stop().set_bit()
});
pp.RCC.ahb1enr.modify(|_, w| w.dma1en().enabled());
pp.RCC.ahb1enr.modify(|_, w| {
w.gpioaen().enabled();
w.gpioben().enabled();
w.gpiocen().enabled();
w.gpioden().enabled();
w.gpioeen().enabled();
w.gpiofen().enabled();
w
});
pac::RCC.ahb1enr().modify(|w| {
w.set_gpioaen(true);
w.set_gpioben(true);
w.set_gpiocen(true);
w.set_gpioden(true);
w.set_gpioeen(true);
w.set_gpiofen(true);
});
}
let p = embassy_stm32::init(Default::default());

View File

@ -9,7 +9,6 @@
#[path = "../example_common.rs"]
mod example_common;
use embassy::executor::Executor;
use embassy::time::Clock;
use embassy::util::Forever;
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::gpio::{Input, Pull};
@ -17,7 +16,7 @@ use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge};
use example_common::*;
use cortex_m_rt::entry;
use stm32f4::stm32f429 as pac;
use embassy_stm32::pac;
#[embassy::task]
async fn main_task() {
@ -36,44 +35,33 @@ async fn main_task() {
}
}
struct ZeroClock;
impl Clock for ZeroClock {
fn now(&self) -> u64 {
0
}
}
static EXECUTOR: Forever<Executor> = Forever::new();
#[entry]
fn main() -> ! {
info!("Hello World!");
let pp = pac::Peripherals::take().unwrap();
unsafe {
pac::DBGMCU.cr().modify(|w| {
w.set_dbg_sleep(true);
w.set_dbg_standby(true);
w.set_dbg_stop(true);
});
pp.DBGMCU.cr.modify(|_, w| {
w.dbg_sleep().set_bit();
w.dbg_standby().set_bit();
w.dbg_stop().set_bit()
});
pp.RCC.ahb1enr.modify(|_, w| w.dma1en().enabled());
pac::RCC.ahb1enr().modify(|w| {
w.set_gpioaen(true);
w.set_gpioben(true);
w.set_gpiocen(true);
w.set_gpioden(true);
w.set_gpioeen(true);
w.set_gpiofen(true);
});
pp.RCC.ahb1enr.modify(|_, w| {
w.gpioaen().enabled();
w.gpioben().enabled();
w.gpiocen().enabled();
w.gpioden().enabled();
w.gpioeen().enabled();
w.gpiofen().enabled();
w
});
pp.RCC.apb2enr.modify(|_, w| {
w.syscfgen().enabled();
w
});
unsafe { embassy::time::set_clock(&ZeroClock) };
// EXTI clock
pac::RCC.apb2enr().modify(|w| {
w.set_syscfgen(true);
});
}
let executor = EXECUTOR.put(Executor::new());

View File

@ -14,38 +14,31 @@ use embedded_hal::digital::v2::OutputPin;
use example_common::*;
use cortex_m_rt::entry;
use embassy_stm32::pac;
use embassy_stm32::spi::{Config, Spi};
use embassy_stm32::time::Hertz;
use embedded_hal::blocking::spi::Transfer;
use stm32f4::stm32f429 as pac;
#[entry]
fn main() -> ! {
info!("Hello World, dude!");
let pp = pac::Peripherals::take().unwrap();
unsafe {
pac::DBGMCU.cr().modify(|w| {
w.set_dbg_sleep(true);
w.set_dbg_standby(true);
w.set_dbg_stop(true);
});
pp.DBGMCU.cr.modify(|_, w| {
w.dbg_sleep().set_bit();
w.dbg_standby().set_bit();
w.dbg_stop().set_bit()
});
pp.RCC.ahb1enr.modify(|_, w| w.dma1en().set_bit());
pp.RCC.apb1enr.modify(|_, w| {
w.spi3en().enabled();
w
});
pp.RCC.ahb1enr.modify(|_, w| {
w.gpioaen().enabled();
w.gpioben().enabled();
w.gpiocen().enabled();
w.gpioden().enabled();
w.gpioeen().enabled();
w.gpiofen().enabled();
w
});
pac::RCC.ahb1enr().modify(|w| {
w.set_gpioaen(true);
w.set_gpioben(true);
w.set_gpiocen(true);
w.set_gpioden(true);
w.set_gpioeen(true);
w.set_gpiofen(true);
});
}
let p = embassy_stm32::init(Default::default());

View File

@ -10,14 +10,13 @@
mod example_common;
use cortex_m::prelude::_embedded_hal_blocking_serial_Write;
use embassy::executor::Executor;
use embassy::time::Clock;
use embassy::util::Forever;
use embassy_stm32::dma::NoDma;
use embassy_stm32::usart::{Config, Uart};
use example_common::*;
use cortex_m_rt::entry;
use stm32f4::stm32f429 as pac;
use embassy_stm32::pac;
#[embassy::task]
async fn main_task() {
@ -36,48 +35,28 @@ async fn main_task() {
}
}
struct ZeroClock;
impl Clock for ZeroClock {
fn now(&self) -> u64 {
0
}
}
static EXECUTOR: Forever<Executor> = Forever::new();
#[entry]
fn main() -> ! {
info!("Hello World!");
let pp = pac::Peripherals::take().unwrap();
unsafe {
pac::DBGMCU.cr().modify(|w| {
w.set_dbg_sleep(true);
w.set_dbg_standby(true);
w.set_dbg_stop(true);
});
pp.DBGMCU.cr.modify(|_, w| {
w.dbg_sleep().set_bit();
w.dbg_standby().set_bit();
w.dbg_stop().set_bit()
});
pp.RCC.ahb1enr.modify(|_, w| w.dma1en().enabled());
pp.RCC.ahb1enr.modify(|_, w| {
w.gpioaen().enabled();
w.gpioben().enabled();
w.gpiocen().enabled();
w.gpioden().enabled();
w.gpioeen().enabled();
w.gpiofen().enabled();
w
});
pp.RCC.apb2enr.modify(|_, w| {
w.syscfgen().enabled();
w
});
pp.RCC.apb1enr.modify(|_, w| {
w.usart3en().enabled();
w
});
unsafe { embassy::time::set_clock(&ZeroClock) };
pac::RCC.ahb1enr().modify(|w| {
w.set_gpioaen(true);
w.set_gpioben(true);
w.set_gpiocen(true);
w.set_gpioden(true);
w.set_gpioeen(true);
w.set_gpiofen(true);
});
}
let executor = EXECUTOR.put(Executor::new());

View File

@ -11,14 +11,13 @@ mod example_common;
use core::fmt::Write;
use cortex_m_rt::entry;
use embassy::executor::Executor;
use embassy::time::Clock;
use embassy::util::Forever;
use embassy_stm32::dma::NoDma;
use embassy_stm32::pac;
use embassy_stm32::usart::{Config, Uart};
use embassy_traits::uart::Write as _;
use example_common::*;
use heapless::String;
use stm32f4::stm32f429 as pac;
#[embassy::task]
async fn main_task() {
@ -36,50 +35,28 @@ async fn main_task() {
}
}
struct ZeroClock;
impl Clock for ZeroClock {
fn now(&self) -> u64 {
0
}
}
static EXECUTOR: Forever<Executor> = Forever::new();
#[entry]
fn main() -> ! {
info!("Hello World!");
let pp = pac::Peripherals::take().unwrap();
pp.DBGMCU.cr.modify(|_, w| {
w.dbg_sleep().set_bit();
w.dbg_standby().set_bit();
w.dbg_stop().set_bit()
});
pp.RCC.ahb1enr.modify(|_, w| w.dma1en().enabled());
pp.RCC.ahb1enr.modify(|_, w| {
w.gpioaen().enabled();
w.gpioben().enabled();
w.gpiocen().enabled();
w.gpioden().enabled();
w.gpioeen().enabled();
w.gpiofen().enabled();
w.dma1en().enabled();
w.dma2en().enabled();
w
});
pp.RCC.apb2enr.modify(|_, w| {
w.syscfgen().enabled();
w
});
pp.RCC.apb1enr.modify(|_, w| {
w.usart3en().enabled();
w
unsafe {
pac::DBGMCU.cr().modify(|w| {
w.set_dbg_sleep(true);
w.set_dbg_standby(true);
w.set_dbg_stop(true);
});
unsafe { embassy::time::set_clock(&ZeroClock) };
pac::RCC.ahb1enr().modify(|w| {
w.set_gpioaen(true);
w.set_gpioben(true);
w.set_gpiocen(true);
w.set_gpioden(true);
w.set_gpioeen(true);
w.set_gpiofen(true);
});
}
let executor = EXECUTOR.put(Executor::new());