Fix tests

This commit is contained in:
Dion Dokter 2024-08-05 15:07:51 +02:00
parent 5884576b88
commit 3cd2081450
24 changed files with 45 additions and 24 deletions

View File

@ -5,7 +5,10 @@ use core::mem::MaybeUninit;
use cortex_m_rt::entry; use cortex_m_rt::entry;
use defmt::*; use defmt::*;
use embassy_stm32::{gpio::{Input, Level, Output, Pull, Speed}, SharedData}; use embassy_stm32::{
gpio::{Input, Level, Output, Pull, Speed},
SharedData,
};
use {defmt_rtt as _, panic_probe as _}; use {defmt_rtt as _, panic_probe as _};
#[link_section = ".shared_data"] #[link_section = ".shared_data"]

View File

@ -27,7 +27,7 @@ bind_interrupts!(struct Irqs {
#[embassy_executor::main] #[embassy_executor::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(config()); let p = init();
info!("Hello World!"); info!("Hello World!");
let options = TestOptions { let options = TestOptions {

View File

@ -29,7 +29,7 @@ const OUTPUT_LENGTH: usize = (INPUT_U32_COUNT - 1) * 2;
#[embassy_executor::main] #[embassy_executor::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
let dp = embassy_stm32::init(config()); let dp = init();
// //
// use RNG generate random Q1.31 value // use RNG generate random Q1.31 value

View File

@ -20,7 +20,7 @@ bind_interrupts!(struct Irqs {
#[embassy_executor::main] #[embassy_executor::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
let p: embassy_stm32::Peripherals = embassy_stm32::init(config()); let p: embassy_stm32::Peripherals = init();
const PAYLOAD1: &[u8] = b"payload data 1 ;zdfhzdfhS;GKJASBDG;ASKDJBAL,zdfhzdfhzdfhzdfhvljhb,jhbjhb,sdhsdghsdhsfhsghzdfhzdfhzdfhzdfdhsdthsthsdhsgaadfhhgkdgfuoyguoft6783567"; const PAYLOAD1: &[u8] = b"payload data 1 ;zdfhzdfhS;GKJASBDG;ASKDJBAL,zdfhzdfhzdfhzdfhvljhb,jhbjhb,sdhsdghsdhsfhsghzdfhzdfhzdfhzdfdhsdthsthsdhsgaadfhhgkdgfuoyguoft6783567";
const PAYLOAD2: &[u8] = b"payload data 2 ;SKEzdfhzdfhzbhgvljhb,jhbjhb,sdhsdghsdhsfhsghshsfhshstsdthadfhsdfjhsfgjsfgjxfgjzdhgDFghSDGHjtfjtjszftjzsdtjhstdsdhsdhsdhsdhsdthsthsdhsgfh"; const PAYLOAD2: &[u8] = b"payload data 2 ;SKEzdfhzdfhzbhgvljhb,jhbjhb,sdhsdghsdhsfhsghshsfhshstsdthadfhsdfjhsfgjsfgjxfgjzdhgDFghSDGHjtfjtjszftjzsdtjhstdsdhsdhsdhsdhsdthsthsdhsgfh";

View File

@ -20,7 +20,7 @@ use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main] #[embassy_executor::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
// Initialize the board and obtain a Peripherals instance // Initialize the board and obtain a Peripherals instance
let p: embassy_stm32::Peripherals = embassy_stm32::init(config()); let p: embassy_stm32::Peripherals = init();
let adc = peri!(p, ADC); let adc = peri!(p, ADC);
let dac = peri!(p, DAC); let dac = peri!(p, DAC);

View File

@ -25,7 +25,7 @@ bind_interrupts!(struct Irqs {
#[embassy_executor::main] #[embassy_executor::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
// Initialize the board and obtain a Peripherals instance // Initialize the board and obtain a Peripherals instance
let p: embassy_stm32::Peripherals = embassy_stm32::init(config()); let p: embassy_stm32::Peripherals = init();
let adc = peri!(p, ADC); let adc = peri!(p, ADC);
let dac = peri!(p, DAC); let dac = peri!(p, DAC);

View File

@ -38,7 +38,7 @@ async fn net_task(stack: &'static Stack<Device>) -> ! {
#[embassy_executor::main] #[embassy_executor::main]
async fn main(spawner: Spawner) { async fn main(spawner: Spawner) {
let p = embassy_stm32::init(config()); let p = init();
info!("Hello World!"); info!("Hello World!");
// Generate random seed. // Generate random seed.

View File

@ -102,10 +102,10 @@ fn options() -> (Config, TestOptions) {
#[embassy_executor::main] #[embassy_executor::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
//let peripherals = embassy_stm32::init(config()); //let peripherals = init();
let (config, options) = options(); let (config, options) = options();
let peripherals = embassy_stm32::init(config); let peripherals = init_with_config(config);
let mut can = can::CanConfigurator::new(peripherals.FDCAN1, peripherals.PB8, peripherals.PB9, Irqs1); let mut can = can::CanConfigurator::new(peripherals.FDCAN1, peripherals.PB8, peripherals.PB9, Irqs1);
let mut can2 = can::CanConfigurator::new(peripherals.FDCAN2, peripherals.PB12, peripherals.PB13, Irqs2); let mut can2 = can::CanConfigurator::new(peripherals.FDCAN2, peripherals.PB12, peripherals.PB13, Irqs2);

View File

@ -10,7 +10,7 @@ use embassy_stm32::gpio::{Flex, Input, Level, Output, OutputOpenDrain, Pull, Spe
#[embassy_executor::main] #[embassy_executor::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(config()); let p = init();
info!("Hello World!"); info!("Hello World!");
// Arduino pins D0 and D1 // Arduino pins D0 and D1

View File

@ -35,7 +35,7 @@ bind_interrupts!(struct Irqs {
#[embassy_executor::main] #[embassy_executor::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
let p: embassy_stm32::Peripherals = embassy_stm32::init(config()); let p: embassy_stm32::Peripherals = init();
let mut hw_hasher = Hash::new(p.HASH, NoDma, Irqs); let mut hw_hasher = Hash::new(p.HASH, NoDma, Irqs);
let test_1: &[u8] = b"as;dfhaslfhas;oifvnasd;nifvnhasd;nifvhndlkfghsd;nvfnahssdfgsdafgsasdfasdfasdfasdfasdfghjklmnbvcalskdjghalskdjgfbaslkdjfgbalskdjgbalskdjbdfhsdfhsfghsfghfgh"; let test_1: &[u8] = b"as;dfhaslfhas;oifvnasd;nifvnhasd;nifvhndlkfghsd;nvfnahssdfgsdafgsasdfasdfasdfasdfasdfghjklmnbvcalskdjghalskdjgfbaslkdjfgbalskdjgbalskdjbdfhsdfhsfghsfghfgh";

View File

@ -41,7 +41,7 @@ bind_interrupts!(struct Irqs {
#[embassy_executor::main] #[embassy_executor::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
let p: embassy_stm32::Peripherals = embassy_stm32::init(config()); let p: embassy_stm32::Peripherals = init();
let mut rng = Rng::new(p.RNG, Irqs); let mut rng = Rng::new(p.RNG, Irqs);

View File

@ -18,7 +18,7 @@ async fn main(_spawner: Spawner) {
let mut config = config(); let mut config = config();
config.rcc.ls = LsConfig::default_lse(); config.rcc.ls = LsConfig::default_lse();
let p = embassy_stm32::init(config); let p = init_with_config(config);
info!("Hello World!"); info!("Hello World!");
let now = NaiveDate::from_ymd_opt(2020, 5, 15) let now = NaiveDate::from_ymd_opt(2020, 5, 15)

View File

@ -20,7 +20,7 @@ bind_interrupts!(struct Irqs {
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
info!("Hello World!"); info!("Hello World!");
let p = embassy_stm32::init(config()); let p = init();
let (mut sdmmc, mut dma, mut clk, mut cmd, mut d0, mut d1, mut d2, mut d3) = let (mut sdmmc, mut dma, mut clk, mut cmd, mut d0, mut d1, mut d2, mut d3) =
(p.SDIO, p.DMA2_CH3, p.PC12, p.PD2, p.PC8, p.PC9, p.PC10, p.PC11); (p.SDIO, p.DMA2_CH3, p.PC12, p.PD2, p.PC8, p.PC9, p.PC10, p.PC11);

View File

@ -12,7 +12,7 @@ use embassy_stm32::time::Hertz;
#[embassy_executor::main] #[embassy_executor::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(config()); let p = init();
info!("Hello World!"); info!("Hello World!");
let mut spi_peri = peri!(p, SPI); let mut spi_peri = peri!(p, SPI);

View File

@ -12,7 +12,7 @@ use embassy_stm32::time::Hertz;
#[embassy_executor::main] #[embassy_executor::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(config()); let p = init();
info!("Hello World!"); info!("Hello World!");
let mut spi_peri = peri!(p, SPI); let mut spi_peri = peri!(p, SPI);

View File

@ -58,7 +58,7 @@ async fn async_main(spawner: Spawner) {
config.rcc.hsi = Some(HSIPrescaler::DIV4); // 64 MHz HSI will need a /4 config.rcc.hsi = Some(HSIPrescaler::DIV4); // 64 MHz HSI will need a /4
} }
let p = embassy_stm32::init(config); let p = init_with_config(config);
info!("Hello World!"); info!("Hello World!");
let now = NaiveDate::from_ymd_opt(2020, 5, 15) let now = NaiveDate::from_ymd_opt(2020, 5, 15)

View File

@ -10,7 +10,7 @@ use embassy_time::{Instant, Timer};
#[embassy_executor::main] #[embassy_executor::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
let _p = embassy_stm32::init(config()); let _p = init();
info!("Hello World!"); info!("Hello World!");
let start = Instant::now(); let start = Instant::now();

View File

@ -102,7 +102,7 @@ async fn sink(
#[embassy_executor::main] #[embassy_executor::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(config()); let p = init();
info!("Hello World!"); info!("Hello World!");
// Wire between PD0 and PA8 // Wire between PD0 and PA8

View File

@ -11,7 +11,7 @@ use embassy_time::{block_for, Duration, Instant};
#[embassy_executor::main] #[embassy_executor::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(config()); let p = init();
info!("Hello World!"); info!("Hello World!");
// Arduino pins D0 and D1 // Arduino pins D0 and D1

View File

@ -11,7 +11,7 @@ use embassy_stm32::usart::{Config, Uart};
#[embassy_executor::main] #[embassy_executor::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(config()); let p = init();
info!("Hello World!"); info!("Hello World!");
// Arduino pins D0 and D1 // Arduino pins D0 and D1

View File

@ -18,7 +18,7 @@ const DMA_BUF_SIZE: usize = 256;
#[embassy_executor::main] #[embassy_executor::main]
async fn main(spawner: Spawner) { async fn main(spawner: Spawner) {
let p = embassy_stm32::init(config()); let p = init();
info!("Hello World!"); info!("Hello World!");
// Arduino pins D0 and D1 // Arduino pins D0 and D1

View File

@ -41,7 +41,7 @@ async fn main(spawner: Spawner) {
let mut config = config(); let mut config = config();
config.rcc = WPAN_DEFAULT; config.rcc = WPAN_DEFAULT;
let p = embassy_stm32::init(config); let p = init_with_config(config);
info!("Hello World!"); info!("Hello World!");
let config = Config::default(); let config = Config::default();

View File

@ -34,7 +34,7 @@ async fn main(spawner: Spawner) {
let mut config = config(); let mut config = config();
config.rcc = WPAN_DEFAULT; config.rcc = WPAN_DEFAULT;
let p = embassy_stm32::init(config); let p = init_with_config(config);
info!("Hello World!"); info!("Hello World!");
let config = Config::default(); let config = Config::default();

View File

@ -699,3 +699,21 @@ pub fn config() -> Config {
config config
} }
#[allow(unused)]
pub fn init() -> embassy_stm32::Peripherals {
init_with_config(config())
}
#[allow(unused)]
pub fn init_with_config(config: Config) -> embassy_stm32::Peripherals {
#[cfg(feature = "stm32wl55jc")]
{
// Not in shared memory, but we're not running the second core, so it's fine
static SHARED_DATA: core::mem::MaybeUninit<embassy_stm32::SharedData> = core::mem::MaybeUninit::uninit();
embassy_stm32::init_primary(config, &SHARED_DATA)
}
#[cfg(not(feature = "stm32wl55jc"))]
embassy_stm32::init(config)
}