Add example for STM32WL55

This commit is contained in:
Ulf Lilleengen 2021-08-17 13:14:21 +02:00
parent 4b74e8fc50
commit 61409e2fb6
8 changed files with 133 additions and 11 deletions

View File

@ -37,6 +37,7 @@ macro_rules! foreach_exti_irq {
#[cfg_attr(exti_v1, path = "v1.rs")]
#[cfg_attr(exti_h7, path = "v1.rs")]
#[cfg_attr(exti_wb55, path = "v2.rs")]
#[cfg_attr(exti_wl5x, path = "v2.rs")]
mod _version;
#[allow(unused)]
@ -110,6 +111,6 @@ pub(crate) unsafe fn init() {
foreach_exti_irq!(enable_irq);
#[cfg(not(rcc_wb55))]
#[cfg(not(any(rcc_wb55, rcc_wl5x)))]
<crate::peripherals::SYSCFG as crate::rcc::sealed::RccPeripheral>::enable();
}

View File

@ -116,15 +116,6 @@ impl<'d> Rcc<'d> {
pub fn clocks(&self) -> &'static Clocks {
unsafe { get_freqs() }
}
pub fn enable_debug_wfe(&mut self, _dbg: &mut peripherals::DBGMCU, enable_dma: bool) {
// NOTE(unsafe) We have exclusive access to the RCC and DBGMCU
unsafe {
pac::RCC.ahb1enr().modify(|w| w.set_dma1en(enable_dma));
Dbgmcu::enable_all();
}
}
}
/// Extension trait that freezes the `RCC` peripheral with provided clocks configuration

View File

@ -0,0 +1,34 @@
[package]
authors = ["Dario Nieuwenhuis <dirbaio@dirbaio.net>", "Ulf Lilleengen <ulf.lilleengen@gmail.com>"]
edition = "2018"
name = "embassy-stm32wl55-examples"
version = "0.1.0"
resolver = "2"
[features]
default = [
"defmt-default",
]
defmt-default = []
defmt-trace = []
defmt-debug = []
defmt-info = []
defmt-warn = []
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", "stm32wl55jc_cm4", "time-driver-tim2", "memory-x"] }
embassy-hal-common = {version = "0.1.0", path = "../../embassy-hal-common" }
defmt = "0.2.0"
defmt-rtt = "0.2.0"
cortex-m = "0.7.1"
cortex-m-rt = "0.6.14"
embedded-hal = { version = "0.2.4" }
panic-probe = { version = "0.2.0", features= ["print-defmt"] }
futures = { version = "0.3.8", default-features = false, features = ["async-await"] }
rtt-target = { version = "0.3", features = ["cortex-m"] }
heapless = { version = "0.7.1", default-features = false }

View File

@ -0,0 +1,5 @@
MEMORY
{
FLASH : ORIGIN = 0x08000000, LENGTH = 256K
RAM : ORIGIN = 0x20000000, LENGTH = 64K
}

View File

@ -0,0 +1,34 @@
#![no_std]
#![no_main]
#![feature(trait_alias)]
#![feature(type_alias_impl_trait)]
#![allow(incomplete_features)]
#[path = "../example_common.rs"]
mod example_common;
use embassy::executor::Spawner;
use embassy::time::{Duration, Timer};
use embassy_stm32::dbgmcu::Dbgmcu;
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::Peripherals;
use embedded_hal::digital::v2::OutputPin;
use example_common::*;
#[embassy::main]
async fn main(_spawner: Spawner, p: Peripherals) {
info!("Hello World!");
unsafe { Dbgmcu::enable_all() };
let mut led = Output::new(p.PB15, Level::High, Speed::Low);
loop {
info!("high");
unwrap!(led.set_high());
Timer::after(Duration::from_millis(500)).await;
info!("low");
unwrap!(led.set_low());
Timer::after(Duration::from_millis(500)).await;
}
}

View File

@ -0,0 +1,40 @@
#![no_std]
#![no_main]
#![feature(trait_alias)]
#![feature(type_alias_impl_trait)]
#![allow(incomplete_features)]
#[path = "../example_common.rs"]
mod example_common;
use embassy_stm32::{
dbgmcu::Dbgmcu,
gpio::{Input, Level, Output, Pull, Speed},
rcc::*,
};
use embedded_hal::digital::v2::{InputPin, OutputPin};
use example_common::*;
use cortex_m_rt::entry;
#[entry]
fn main() -> ! {
info!("Hello World!");
let mut p = embassy_stm32::init(Default::default());
unsafe { Dbgmcu::enable_all() };
let button = Input::new(p.PA0, Pull::Up);
let mut led1 = Output::new(p.PB15, Level::High, Speed::Low);
let mut led2 = Output::new(p.PB9, Level::High, Speed::Low);
loop {
if button.is_high().unwrap() {
led1.set_high().unwrap();
led2.set_low().unwrap();
} else {
led1.set_low().unwrap();
led2.set_high().unwrap();
}
}
}

View File

@ -0,0 +1,17 @@
#![macro_use]
use defmt_rtt as _; // global logger
use panic_probe as _;
pub use defmt::*;
use core::sync::atomic::{AtomicUsize, Ordering};
defmt::timestamp! {"{=u64}", {
static COUNT: AtomicUsize = AtomicUsize::new(0);
// NOTE(no-CAS) `timestamps` runs with interrupts disabled
let n = COUNT.load(Ordering::Relaxed);
COUNT.store(n + 1, Ordering::Relaxed);
n as u64
}
}

@ -1 +1 @@
Subproject commit 75a76596c37f07cbbdaa3a689c1776297063b651
Subproject commit bfd4797d1278c3e0b4611bc79e12346dedbde7c9