Updated WL examples to use new API

This commit is contained in:
Dion Dokter 2024-08-05 14:43:57 +02:00
parent 705a8fc38c
commit 5884576b88
9 changed files with 69 additions and 16 deletions

View File

@ -5,8 +5,8 @@ MEMORY
BOOTLOADER_STATE : ORIGIN = 0x08006000, LENGTH = 4K
FLASH : ORIGIN = 0x08008000, LENGTH = 64K
DFU : ORIGIN = 0x08018000, LENGTH = 68K
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K - 1K
SHARED_RAM (rwx) : ORIGIN = 0x20007C00, LENGTH = 1K
SHARED_RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 64
RAM (rwx) : ORIGIN = 0x20000040, LENGTH = 32K - 64
}
__bootloader_state_start = ORIGIN(BOOTLOADER_STATE) - ORIGIN(BOOTLOADER);

15
examples/stm32wl/memory.x Normal file
View File

@ -0,0 +1,15 @@
MEMORY
{
/* NOTE 1 K = 1 KiBi = 1024 bytes */
FLASH : ORIGIN = 0x08000000, LENGTH = 256K
SHARED_RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 64
RAM (rwx) : ORIGIN = 0x20000040, LENGTH = 64K - 64
}
SECTIONS
{
.shared_data :
{
*(.shared_data)
} > SHARED_RAM
}

View File

@ -1,15 +1,23 @@
#![no_std]
#![no_main]
use core::mem::MaybeUninit;
use defmt::*;
use embassy_executor::Spawner;
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::{
gpio::{Level, Output, Speed},
SharedData,
};
use embassy_time::Timer;
use {defmt_rtt as _, panic_probe as _};
#[link_section = ".shared_data"]
static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let p = embassy_stm32::init_primary(Default::default(), &SHARED_DATA);
info!("Hello World!");
let mut led = Output::new(p.PB15, Level::High, Speed::Low);

View File

@ -1,16 +1,21 @@
#![no_std]
#![no_main]
use core::mem::MaybeUninit;
use cortex_m_rt::entry;
use defmt::*;
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
use embassy_stm32::{gpio::{Input, Level, Output, Pull, Speed}, SharedData};
use {defmt_rtt as _, panic_probe as _};
#[link_section = ".shared_data"]
static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
#[entry]
fn main() -> ! {
info!("Hello World!");
let p = embassy_stm32::init(Default::default());
let p = embassy_stm32::init_primary(Default::default(), &SHARED_DATA);
let button = Input::new(p.PA0, Pull::Up);
let mut led1 = Output::new(p.PB15, Level::High, Speed::Low);

View File

@ -1,15 +1,20 @@
#![no_std]
#![no_main]
use core::mem::MaybeUninit;
use defmt::*;
use embassy_executor::Spawner;
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::gpio::Pull;
use embassy_stm32::{exti::ExtiInput, SharedData};
use {defmt_rtt as _, panic_probe as _};
#[link_section = ".shared_data"]
static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let p = embassy_stm32::init_primary(Default::default(), &SHARED_DATA);
info!("Hello World!");
let mut button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Up);

View File

@ -1,14 +1,19 @@
#![no_std]
#![no_main]
use core::mem::MaybeUninit;
use defmt::{info, unwrap};
use embassy_executor::Spawner;
use embassy_stm32::flash::Flash;
use embassy_stm32::{flash::Flash, SharedData};
use {defmt_rtt as _, panic_probe as _};
#[link_section = ".shared_data"]
static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let p = embassy_stm32::init_primary(Default::default(), &SHARED_DATA);
info!("Hello Flash!");
const ADDR: u32 = 0x36000;

View File

@ -1,17 +1,22 @@
#![no_std]
#![no_main]
use core::mem::MaybeUninit;
use defmt::*;
use embassy_executor::Spawner;
use embassy_stm32::rng::{self, Rng};
use embassy_stm32::time::Hertz;
use embassy_stm32::{bind_interrupts, peripherals};
use embassy_stm32::{bind_interrupts, peripherals, SharedData};
use {defmt_rtt as _, panic_probe as _};
bind_interrupts!(struct Irqs{
RNG => rng::InterruptHandler<peripherals::RNG>;
});
#[link_section = ".shared_data"]
static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let mut config = embassy_stm32::Config::default();
@ -32,7 +37,7 @@ async fn main(_spawner: Spawner) {
divr: Some(PllRDiv::DIV2), // sysclk 48Mhz clock (32 / 2 * 6 / 2)
});
}
let p = embassy_stm32::init(config);
let p = embassy_stm32::init_primary(config, &SHARED_DATA);
info!("Hello World!");

View File

@ -1,15 +1,20 @@
#![no_std]
#![no_main]
use core::mem::MaybeUninit;
use chrono::{NaiveDate, NaiveDateTime};
use defmt::*;
use embassy_executor::Spawner;
use embassy_stm32::rtc::{Rtc, RtcConfig};
use embassy_stm32::time::Hertz;
use embassy_stm32::Config;
use embassy_stm32::{Config, SharedData};
use embassy_time::Timer;
use {defmt_rtt as _, panic_probe as _};
#[link_section = ".shared_data"]
static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let mut config = Config::default();
@ -31,7 +36,7 @@ async fn main(_spawner: Spawner) {
divr: Some(PllRDiv::DIV2), // sysclk 48Mhz clock (32 / 2 * 6 / 2)
});
}
let p = embassy_stm32::init(config);
let p = embassy_stm32::init_primary(config, &SHARED_DATA);
info!("Hello World!");
let now = NaiveDate::from_ymd_opt(2020, 5, 15)

View File

@ -1,10 +1,12 @@
#![no_std]
#![no_main]
use core::mem::MaybeUninit;
use defmt::*;
use embassy_executor::Spawner;
use embassy_stm32::usart::{Config, InterruptHandler, Uart};
use embassy_stm32::{bind_interrupts, peripherals};
use embassy_stm32::{bind_interrupts, peripherals, SharedData};
use {defmt_rtt as _, panic_probe as _};
bind_interrupts!(struct Irqs{
@ -12,6 +14,9 @@ bind_interrupts!(struct Irqs{
LPUART1 => InterruptHandler<peripherals::LPUART1>;
});
#[link_section = ".shared_data"]
static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
/*
Pass Incoming data from LPUART1 to USART1
Example is written for the LoRa-E5 mini v1.0,
@ -21,7 +26,7 @@ but can be surely changed for your needs.
async fn main(_spawner: Spawner) {
let mut config = embassy_stm32::Config::default();
config.rcc.sys = embassy_stm32::rcc::Sysclk::HSE;
let p = embassy_stm32::init(config);
let p = embassy_stm32::init_primary(config, &SHARED_DATA);
defmt::info!("Starting system");