From 6bdacb4f69d523ef814e7e3b9c4a878106ca0e62 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 27 Nov 2023 00:35:41 +0100 Subject: [PATCH 01/98] stm32/sdmmc: use unwrap to ensure panics get printed to defmt. --- embassy-stm32/src/sdmmc/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/embassy-stm32/src/sdmmc/mod.rs b/embassy-stm32/src/sdmmc/mod.rs index a99a5707..27a12062 100644 --- a/embassy-stm32/src/sdmmc/mod.rs +++ b/embassy-stm32/src/sdmmc/mod.rs @@ -1457,8 +1457,8 @@ cfg_if::cfg_if! { macro_rules! kernel_clk { ($inst:ident) => { critical_section::with(|_| unsafe { - crate::rcc::get_freqs().pll1_q - }).expect("PLL48 is required for SDIO") + unwrap!(crate::rcc::get_freqs().pll1_q) + }) } } } else if #[cfg(stm32f7)] { @@ -1469,7 +1469,7 @@ cfg_if::cfg_if! { if sdmmcsel == crate::pac::rcc::vals::Sdmmcsel::SYS { crate::rcc::get_freqs().sys } else { - crate::rcc::get_freqs().pll1_q.expect("PLL48 is required for SDMMC") + unwrap!(crate::rcc::get_freqs().pll1_q) } }) }; @@ -1479,7 +1479,7 @@ cfg_if::cfg_if! { if sdmmcsel == crate::pac::rcc::vals::Sdmmcsel::SYS { crate::rcc::get_freqs().sys } else { - crate::rcc::get_freqs().pll1_q.expect("PLL48 is required for SDMMC") + unwrap!(crate::rcc::get_freqs().pll1_q) } }) }; From cf13f70ea929ee550e418fe3c954b0415207ca88 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 27 Nov 2023 00:36:04 +0100 Subject: [PATCH 02/98] stm32/test: add stm32f446 (board not in HIL rig yet) --- ci.sh | 3 +++ tests/stm32/Cargo.toml | 29 +++++++++++++++-------------- tests/stm32/src/bin/can.rs | 12 ++++++------ tests/stm32/src/bin/dac.rs | 21 +++++++++------------ tests/stm32/src/bin/sdmmc.rs | 11 ++++------- tests/stm32/src/common.rs | 35 +++++++++++++++++++++++++++++++++++ 6 files changed, 72 insertions(+), 39 deletions(-) diff --git a/ci.sh b/ci.sh index aff88353..5a4773da 100755 --- a/ci.sh +++ b/ci.sh @@ -190,6 +190,7 @@ cargo batch \ --- build --release --manifest-path examples/wasm/Cargo.toml --target wasm32-unknown-unknown --out-dir out/examples/wasm \ --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f103c8 --out-dir out/tests/stm32f103c8 \ --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi --out-dir out/tests/stm32f429zi \ + --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f446re --out-dir out/tests/stm32f446re \ --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g491re --out-dir out/tests/stm32g491re \ --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32g071rb --out-dir out/tests/stm32g071rb \ --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32c031c6 --out-dir out/tests/stm32c031c6 \ @@ -220,6 +221,8 @@ cargo batch \ rm out/tests/stm32wb55rg/wpan_mac rm out/tests/stm32wb55rg/wpan_ble +# not in CI yet. +rm -rf out/tests/stm32f446re # unstable, I think it's running out of RAM? rm out/tests/stm32f207zg/eth diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index ab701616..78508225 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -6,28 +6,29 @@ license = "MIT OR Apache-2.0" autobins = false [features] -stm32f103c8 = ["embassy-stm32/stm32f103c8", "not-gpdma"] -stm32f429zi = ["embassy-stm32/stm32f429zi", "chrono", "eth", "stop", "can", "not-gpdma", "dac-adc-pin", "rng"] -stm32g071rb = ["embassy-stm32/stm32g071rb", "cm0", "not-gpdma", "dac-adc-pin"] stm32c031c6 = ["embassy-stm32/stm32c031c6", "cm0", "not-gpdma"] +stm32f103c8 = ["embassy-stm32/stm32f103c8", "not-gpdma"] +stm32f207zg = ["embassy-stm32/stm32f207zg", "chrono", "not-gpdma", "eth", "rng"] +stm32f303ze = ["embassy-stm32/stm32f303ze", "chrono", "not-gpdma"] +stm32f429zi = ["embassy-stm32/stm32f429zi", "chrono", "eth", "stop", "can", "not-gpdma", "dac-adc-pin", "rng"] +stm32f446re = ["embassy-stm32/stm32f446re", "chrono", "stop", "can", "not-gpdma", "dac-adc-pin", "sdmmc"] +stm32f767zi = ["embassy-stm32/stm32f767zi", "chrono", "not-gpdma", "eth", "rng"] +stm32g071rb = ["embassy-stm32/stm32g071rb", "cm0", "not-gpdma", "dac-adc-pin"] stm32g491re = ["embassy-stm32/stm32g491re", "chrono", "stop", "not-gpdma", "rng"] -stm32h755zi = ["embassy-stm32/stm32h755zi-cm7", "chrono", "not-gpdma", "eth", "dac-adc-pin", "rng"] -stm32h753zi = ["embassy-stm32/stm32h753zi", "chrono", "not-gpdma", "eth", "rng"] -stm32h7a3zi = ["embassy-stm32/stm32h7a3zi", "not-gpdma", "rng"] -stm32wb55rg = ["embassy-stm32/stm32wb55rg", "chrono", "not-gpdma", "ble", "mac" , "rng"] stm32h563zi = ["embassy-stm32/stm32h563zi", "chrono", "eth", "rng"] -stm32u585ai = ["embassy-stm32/stm32u585ai", "chrono", "rng"] -stm32u5a5zj = ["embassy-stm32/stm32u5a5zj", "chrono", "rng"] -stm32wba52cg = ["embassy-stm32/stm32wba52cg", "chrono", "rng"] +stm32h753zi = ["embassy-stm32/stm32h753zi", "chrono", "not-gpdma", "eth", "rng"] +stm32h755zi = ["embassy-stm32/stm32h755zi-cm7", "chrono", "not-gpdma", "eth", "dac-adc-pin", "rng"] +stm32h7a3zi = ["embassy-stm32/stm32h7a3zi", "not-gpdma", "rng"] stm32l073rz = ["embassy-stm32/stm32l073rz", "cm0", "not-gpdma", "rng"] stm32l152re = ["embassy-stm32/stm32l152re", "chrono", "not-gpdma"] +stm32l496zg = ["embassy-stm32/stm32l496zg", "not-gpdma", "rng"] stm32l4a6zg = ["embassy-stm32/stm32l4a6zg", "chrono", "not-gpdma", "rng"] stm32l4r5zi = ["embassy-stm32/stm32l4r5zi", "chrono", "not-gpdma", "rng"] stm32l552ze = ["embassy-stm32/stm32l552ze", "not-gpdma", "rng"] -stm32f767zi = ["embassy-stm32/stm32f767zi", "chrono", "not-gpdma", "eth", "rng"] -stm32f207zg = ["embassy-stm32/stm32f207zg", "chrono", "not-gpdma", "eth", "rng"] -stm32f303ze = ["embassy-stm32/stm32f303ze", "chrono", "not-gpdma"] -stm32l496zg = ["embassy-stm32/stm32l496zg", "not-gpdma", "rng"] +stm32u585ai = ["embassy-stm32/stm32u585ai", "chrono", "rng"] +stm32u5a5zj = ["embassy-stm32/stm32u5a5zj", "chrono", "rng"] +stm32wb55rg = ["embassy-stm32/stm32wb55rg", "chrono", "not-gpdma", "ble", "mac" , "rng"] +stm32wba52cg = ["embassy-stm32/stm32wba52cg", "chrono", "rng"] stm32wl55jc = ["embassy-stm32/stm32wl55jc-cm4", "not-gpdma", "rng", "chrono"] eth = [] diff --git a/tests/stm32/src/bin/can.rs b/tests/stm32/src/bin/can.rs index acf54521..8d782d2e 100644 --- a/tests/stm32/src/bin/can.rs +++ b/tests/stm32/src/bin/can.rs @@ -27,21 +27,21 @@ bind_interrupts!(struct Irqs { #[embassy_executor::main] async fn main(_spawner: Spawner) { - let mut p = embassy_stm32::init(config()); + let p = embassy_stm32::init(config()); info!("Hello World!"); - // HW is connected as follows: - // PB13 -> PD0 - // PB12 -> PD1 + let can = peri!(p, CAN); + let tx = peri!(p, CAN_TX); + let mut rx = peri!(p, CAN_RX); // The next two lines are a workaround for testing without transceiver. // To synchronise to the bus the RX input needs to see a high level. // Use `mem::forget()` to release the borrow on the pin but keep the // pull-up resistor enabled. - let rx_pin = Input::new(&mut p.PD0, Pull::Up); + let rx_pin = Input::new(&mut rx, Pull::Up); core::mem::forget(rx_pin); - let mut can = Can::new(p.CAN1, p.PD0, p.PD1, Irqs); + let mut can = Can::new(can, rx, tx, Irqs); info!("Configuring can..."); diff --git a/tests/stm32/src/bin/dac.rs b/tests/stm32/src/bin/dac.rs index 824eb880..29d5f866 100644 --- a/tests/stm32/src/bin/dac.rs +++ b/tests/stm32/src/bin/dac.rs @@ -6,6 +6,8 @@ #[path = "../common.rs"] mod common; +use core::f32::consts::PI; + use common::*; use defmt::assert; use embassy_executor::Spawner; @@ -13,6 +15,7 @@ use embassy_stm32::adc::Adc; use embassy_stm32::dac::{DacCh1, Value}; use embassy_stm32::dma::NoDma; use embassy_time::{Delay, Timer}; +use micromath::F32Ext; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] @@ -20,24 +23,22 @@ async fn main(_spawner: Spawner) { // Initialize the board and obtain a Peripherals instance let p: embassy_stm32::Peripherals = embassy_stm32::init(config()); - #[cfg(feature = "stm32f429zi")] - let dac_peripheral = p.DAC; + let dac = peri!(p, DAC); + let dac_pin = peri!(p, DAC_PIN); + let mut adc_pin = unsafe { core::ptr::read(&dac_pin) }; - #[cfg(any(feature = "stm32h755zi", feature = "stm32g071rb"))] - let dac_peripheral = p.DAC1; - - let mut dac = DacCh1::new(dac_peripheral, NoDma, p.PA4); + let mut dac = DacCh1::new(dac, NoDma, dac_pin); let mut adc = Adc::new(p.ADC1, &mut Delay); #[cfg(feature = "stm32h755zi")] let normalization_factor = 256; - #[cfg(any(feature = "stm32f429zi", feature = "stm32g071rb"))] + #[cfg(any(feature = "stm32f429zi", feature = "stm32f446re", feature = "stm32g071rb"))] let normalization_factor: i32 = 16; dac.set(Value::Bit8(0)); // Now wait a little to obtain a stable value Timer::after_millis(30).await; - let offset = adc.read(&mut unsafe { embassy_stm32::Peripherals::steal() }.PA4); + let offset = adc.read(&mut adc_pin); for v in 0..=255 { // First set the DAC output value @@ -62,10 +63,6 @@ async fn main(_spawner: Spawner) { cortex_m::asm::bkpt(); } -use core::f32::consts::PI; - -use micromath::F32Ext; - fn to_sine_wave(v: u8) -> u8 { if v >= 128 { // top half diff --git a/tests/stm32/src/bin/sdmmc.rs b/tests/stm32/src/bin/sdmmc.rs index 51502538..341d34ba 100644 --- a/tests/stm32/src/bin/sdmmc.rs +++ b/tests/stm32/src/bin/sdmmc.rs @@ -5,11 +5,12 @@ #[path = "../common.rs"] mod common; -use defmt::{assert_eq, *}; +use common::*; +use defmt::assert_eq; use embassy_executor::Spawner; use embassy_stm32::sdmmc::{DataBlock, Sdmmc}; use embassy_stm32::time::mhz; -use embassy_stm32::{bind_interrupts, peripherals, sdmmc, Config}; +use embassy_stm32::{bind_interrupts, peripherals, sdmmc}; use {defmt_rtt as _, panic_probe as _}; bind_interrupts!(struct Irqs { @@ -20,12 +21,8 @@ bind_interrupts!(struct Irqs { async fn main(_spawner: Spawner) { info!("Hello World!"); - let mut config = Config::default(); - config.rcc.sys_ck = Some(mhz(48)); - config.rcc.pll48 = true; - let p = embassy_stm32::init(config); + let p = embassy_stm32::init(config()); - #[cfg(feature = "stm32f429zi")] 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); diff --git a/tests/stm32/src/common.rs b/tests/stm32/src/common.rs index a44e8230..155e1d9d 100644 --- a/tests/stm32/src/common.rs +++ b/tests/stm32/src/common.rs @@ -14,6 +14,8 @@ teleprobe_meta::target!(b"nucleo-stm32g491re"); teleprobe_meta::target!(b"nucleo-stm32g071rb"); #[cfg(feature = "stm32f429zi")] teleprobe_meta::target!(b"nucleo-stm32f429zi"); +#[cfg(feature = "stm32f446re")] +teleprobe_meta::target!(b"weact-stm32f446re"); #[cfg(feature = "stm32wb55rg")] teleprobe_meta::target!(b"nucleo-stm32wb55rg"); #[cfg(feature = "stm32h755zi")] @@ -99,14 +101,25 @@ define_peris!( define_peris!( UART = USART1, UART_TX = PC4, UART_RX = PC5, UART_TX_DMA = DMA1_CH1, UART_RX_DMA = DMA1_CH2, SPI = SPI1, SPI_SCK = PA5, SPI_MOSI = PA7, SPI_MISO = PA6, SPI_TX_DMA = DMA1_CH1, SPI_RX_DMA = DMA1_CH2, + DAC = DAC1, DAC_PIN = PA4, @irq UART = {USART1 => embassy_stm32::usart::InterruptHandler;}, ); #[cfg(feature = "stm32f429zi")] define_peris!( UART = USART6, UART_TX = PG14, UART_RX = PG9, UART_TX_DMA = DMA2_CH6, UART_RX_DMA = DMA2_CH1, SPI = SPI1, SPI_SCK = PA5, SPI_MOSI = PA7, SPI_MISO = PA6, SPI_TX_DMA = DMA2_CH3, SPI_RX_DMA = DMA2_CH2, + DAC = DAC, DAC_PIN = PA4, + CAN = CAN1, CAN_RX = PD0, CAN_TX = PD1, @irq UART = {USART6 => embassy_stm32::usart::InterruptHandler;}, ); +#[cfg(feature = "stm32f446re")] +define_peris!( + UART = USART1, UART_TX = PA9, UART_RX = PA10, UART_TX_DMA = DMA2_CH7, UART_RX_DMA = DMA2_CH5, + SPI = SPI1, SPI_SCK = PA5, SPI_MOSI = PA7, SPI_MISO = PA6, SPI_TX_DMA = DMA2_CH3, SPI_RX_DMA = DMA2_CH2, + DAC = DAC, DAC_PIN = PA4, + CAN = CAN1, CAN_RX = PA11, CAN_TX = PA12, + @irq UART = {USART1 => embassy_stm32::usart::InterruptHandler;}, +); #[cfg(feature = "stm32wb55rg")] define_peris!( UART = LPUART1, UART_TX = PA2, UART_RX = PA3, UART_TX_DMA = DMA1_CH1, UART_RX_DMA = DMA1_CH2, @@ -117,6 +130,7 @@ define_peris!( define_peris!( UART = USART1, UART_TX = PB6, UART_RX = PB7, UART_TX_DMA = DMA1_CH0, UART_RX_DMA = DMA1_CH1, SPI = SPI1, SPI_SCK = PA5, SPI_MOSI = PB5, SPI_MISO = PA6, SPI_TX_DMA = DMA1_CH0, SPI_RX_DMA = DMA1_CH1, + DAC = DAC1, DAC_PIN = PA4, @irq UART = {USART1 => embassy_stm32::usart::InterruptHandler;}, ); #[cfg(feature = "stm32h7a3zi")] @@ -282,6 +296,27 @@ pub fn config() -> Config { config.rcc.sys = Sysclk::PLL1_P; } + #[cfg(feature = "stm32f446re")] + { + use embassy_stm32::rcc::*; + config.rcc.hse = Some(Hse { + freq: Hertz(8_000_000), + mode: HseMode::Oscillator, + }); + config.rcc.pll_src = PllSource::HSE; + config.rcc.pll = Some(Pll { + prediv: PllPreDiv::DIV4, + mul: PllMul::MUL168, + divp: Some(PllPDiv::DIV2), // 8mhz / 4 * 168 / 2 = 168 Mhz. + divq: Some(PllQDiv::DIV7), // 8mhz / 4 * 168 / 7 = 48 Mhz. + divr: None, + }); + config.rcc.ahb_pre = AHBPrescaler::DIV1; + config.rcc.apb1_pre = APBPrescaler::DIV4; + config.rcc.apb2_pre = APBPrescaler::DIV2; + config.rcc.sys = Sysclk::PLL1_P; + } + #[cfg(feature = "stm32f767zi")] { use embassy_stm32::rcc::*; From 0bd47c779bcb909000db28d8e09600e6aeaf21ab Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 27 Nov 2023 01:21:44 +0100 Subject: [PATCH 03/98] tests: use executor task arena instead of TAIT. --- tests/nrf/Cargo.toml | 2 +- tests/nrf/src/bin/buffered_uart.rs | 1 - tests/nrf/src/bin/buffered_uart_full.rs | 1 - tests/nrf/src/bin/buffered_uart_spam.rs | 1 - tests/nrf/src/bin/timer.rs | 1 - tests/riscv32/Cargo.toml | 2 +- tests/riscv32/src/bin/empty.rs | 1 - tests/rp/Cargo.toml | 2 +- tests/rp/src/bin/adc.rs | 1 - tests/rp/src/bin/bootsel.rs | 1 - tests/rp/src/bin/dma_copy_async.rs | 1 - tests/rp/src/bin/flash.rs | 1 - tests/rp/src/bin/float.rs | 1 - tests/rp/src/bin/gpio.rs | 1 - tests/rp/src/bin/gpio_async.rs | 1 - tests/rp/src/bin/gpio_multicore.rs | 1 - tests/rp/src/bin/i2c.rs | 1 - tests/rp/src/bin/multicore.rs | 1 - tests/rp/src/bin/pio_irq.rs | 1 - tests/rp/src/bin/pio_multi_load.rs | 1 - tests/rp/src/bin/pwm.rs | 1 - tests/rp/src/bin/spi.rs | 1 - tests/rp/src/bin/spi_async.rs | 1 - tests/rp/src/bin/uart.rs | 1 - tests/rp/src/bin/uart_buffered.rs | 1 - tests/rp/src/bin/uart_dma.rs | 1 - tests/rp/src/bin/uart_upgrade.rs | 1 - tests/stm32/Cargo.toml | 4 ++-- tests/stm32/src/bin/can.rs | 1 - tests/stm32/src/bin/dac.rs | 1 - tests/stm32/src/bin/gpio.rs | 1 - tests/stm32/src/bin/rng.rs | 1 - tests/stm32/src/bin/rtc.rs | 1 - tests/stm32/src/bin/sdmmc.rs | 1 - tests/stm32/src/bin/spi.rs | 1 - tests/stm32/src/bin/spi_dma.rs | 1 - tests/stm32/src/bin/timer.rs | 1 - tests/stm32/src/bin/usart.rs | 1 - tests/stm32/src/bin/usart_dma.rs | 1 - tests/stm32/src/bin/usart_rx_ringbuffered.rs | 1 - tests/stm32/src/bin/wpan_ble.rs | 1 - tests/stm32/src/bin/wpan_mac.rs | 1 - 42 files changed, 5 insertions(+), 43 deletions(-) diff --git a/tests/nrf/Cargo.toml b/tests/nrf/Cargo.toml index 76f94238..fd756881 100644 --- a/tests/nrf/Cargo.toml +++ b/tests/nrf/Cargo.toml @@ -9,7 +9,7 @@ teleprobe-meta = "1" embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt", "nightly"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "nightly", "integrated-timers"] } +embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "task-arena-size-16384", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "nightly", "unstable-traits", "defmt-timestamp-uptime"] } embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nightly", "unstable-traits", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } embedded-io-async = { version = "0.6.0", features = ["defmt-03"] } diff --git a/tests/nrf/src/bin/buffered_uart.rs b/tests/nrf/src/bin/buffered_uart.rs index 932e5926..354d787b 100644 --- a/tests/nrf/src/bin/buffered_uart.rs +++ b/tests/nrf/src/bin/buffered_uart.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"nrf52840-dk"); use defmt::{assert_eq, *}; diff --git a/tests/nrf/src/bin/buffered_uart_full.rs b/tests/nrf/src/bin/buffered_uart_full.rs index 2db8f88d..e59c75ba 100644 --- a/tests/nrf/src/bin/buffered_uart_full.rs +++ b/tests/nrf/src/bin/buffered_uart_full.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"nrf52840-dk"); use defmt::{assert_eq, *}; diff --git a/tests/nrf/src/bin/buffered_uart_spam.rs b/tests/nrf/src/bin/buffered_uart_spam.rs index 65b9d76d..400c0df9 100644 --- a/tests/nrf/src/bin/buffered_uart_spam.rs +++ b/tests/nrf/src/bin/buffered_uart_spam.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"nrf52840-dk"); use core::mem; diff --git a/tests/nrf/src/bin/timer.rs b/tests/nrf/src/bin/timer.rs index 5723acb0..2a147e7b 100644 --- a/tests/nrf/src/bin/timer.rs +++ b/tests/nrf/src/bin/timer.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"nrf52840-dk"); use defmt::{assert, info}; diff --git a/tests/riscv32/Cargo.toml b/tests/riscv32/Cargo.toml index 24597a03..0f9b8221 100644 --- a/tests/riscv32/Cargo.toml +++ b/tests/riscv32/Cargo.toml @@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0" [dependencies] critical-section = { version = "1.1.1", features = ["restore-state-bool"] } embassy-sync = { version = "0.4.0", path = "../../embassy-sync" } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-riscv32", "nightly", "executor-thread"] } +embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-riscv32", "executor-thread"] } embassy-time = { version = "0.1.5", path = "../../embassy-time" } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } diff --git a/tests/riscv32/src/bin/empty.rs b/tests/riscv32/src/bin/empty.rs index 1874caec..55a10306 100644 --- a/tests/riscv32/src/bin/empty.rs +++ b/tests/riscv32/src/bin/empty.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] use embassy_executor::Spawner; diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index 1629cc8b..fc434a02 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" teleprobe-meta = "1.1" embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "nightly", "unstable-traits"] } embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "time-driver", "critical-section-impl", "intrinsics", "rom-v2-intrinsics", "run-from-ram"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } diff --git a/tests/rp/src/bin/adc.rs b/tests/rp/src/bin/adc.rs index 0c04a55f..29eda95b 100644 --- a/tests/rp/src/bin/adc.rs +++ b/tests/rp/src/bin/adc.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"rpi-pico"); use defmt::*; diff --git a/tests/rp/src/bin/bootsel.rs b/tests/rp/src/bin/bootsel.rs index 4678775e..e88d8bf6 100644 --- a/tests/rp/src/bin/bootsel.rs +++ b/tests/rp/src/bin/bootsel.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"rpi-pico"); use defmt::{assert_eq, *}; diff --git a/tests/rp/src/bin/dma_copy_async.rs b/tests/rp/src/bin/dma_copy_async.rs index b071ed9d..7c64bc39 100644 --- a/tests/rp/src/bin/dma_copy_async.rs +++ b/tests/rp/src/bin/dma_copy_async.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"rpi-pico"); use defmt::{assert_eq, *}; diff --git a/tests/rp/src/bin/flash.rs b/tests/rp/src/bin/flash.rs index 2d85135d..310f0d58 100644 --- a/tests/rp/src/bin/flash.rs +++ b/tests/rp/src/bin/flash.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"rpi-pico"); use defmt::*; diff --git a/tests/rp/src/bin/float.rs b/tests/rp/src/bin/float.rs index 1e89c10f..74e5805f 100644 --- a/tests/rp/src/bin/float.rs +++ b/tests/rp/src/bin/float.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"rpi-pico"); use defmt::*; diff --git a/tests/rp/src/bin/gpio.rs b/tests/rp/src/bin/gpio.rs index 1a43a928..e0c30988 100644 --- a/tests/rp/src/bin/gpio.rs +++ b/tests/rp/src/bin/gpio.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"rpi-pico"); use defmt::{assert, *}; diff --git a/tests/rp/src/bin/gpio_async.rs b/tests/rp/src/bin/gpio_async.rs index 26582f74..40a30446 100644 --- a/tests/rp/src/bin/gpio_async.rs +++ b/tests/rp/src/bin/gpio_async.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"rpi-pico"); use defmt::{assert, *}; diff --git a/tests/rp/src/bin/gpio_multicore.rs b/tests/rp/src/bin/gpio_multicore.rs index a4923b6b..8aed9b80 100644 --- a/tests/rp/src/bin/gpio_multicore.rs +++ b/tests/rp/src/bin/gpio_multicore.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"rpi-pico"); use defmt::{info, unwrap}; diff --git a/tests/rp/src/bin/i2c.rs b/tests/rp/src/bin/i2c.rs index 7ddb71c7..77d628cf 100644 --- a/tests/rp/src/bin/i2c.rs +++ b/tests/rp/src/bin/i2c.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"rpi-pico"); use defmt::{assert_eq, info, panic, unwrap}; diff --git a/tests/rp/src/bin/multicore.rs b/tests/rp/src/bin/multicore.rs index 6560b6c8..60d9f85e 100644 --- a/tests/rp/src/bin/multicore.rs +++ b/tests/rp/src/bin/multicore.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"rpi-pico"); use defmt::{info, unwrap}; diff --git a/tests/rp/src/bin/pio_irq.rs b/tests/rp/src/bin/pio_irq.rs index c71e55d9..33cdaaac 100644 --- a/tests/rp/src/bin/pio_irq.rs +++ b/tests/rp/src/bin/pio_irq.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"rpi-pico"); use defmt::info; diff --git a/tests/rp/src/bin/pio_multi_load.rs b/tests/rp/src/bin/pio_multi_load.rs index 6343ff3a..cd28f99b 100644 --- a/tests/rp/src/bin/pio_multi_load.rs +++ b/tests/rp/src/bin/pio_multi_load.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"rpi-pico"); use defmt::info; diff --git a/tests/rp/src/bin/pwm.rs b/tests/rp/src/bin/pwm.rs index 8c9db115..e71d9e61 100644 --- a/tests/rp/src/bin/pwm.rs +++ b/tests/rp/src/bin/pwm.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"rpi-pico"); use defmt::{assert, assert_eq, assert_ne, *}; diff --git a/tests/rp/src/bin/spi.rs b/tests/rp/src/bin/spi.rs index f347b80c..4b02942a 100644 --- a/tests/rp/src/bin/spi.rs +++ b/tests/rp/src/bin/spi.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"rpi-pico"); use defmt::{assert_eq, *}; diff --git a/tests/rp/src/bin/spi_async.rs b/tests/rp/src/bin/spi_async.rs index 80d5a714..efdc80b5 100644 --- a/tests/rp/src/bin/spi_async.rs +++ b/tests/rp/src/bin/spi_async.rs @@ -3,7 +3,6 @@ //! #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"rpi-pico"); use defmt::{assert_eq, *}; diff --git a/tests/rp/src/bin/uart.rs b/tests/rp/src/bin/uart.rs index 8d351a3a..f4d64117 100644 --- a/tests/rp/src/bin/uart.rs +++ b/tests/rp/src/bin/uart.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"rpi-pico"); use defmt::{assert_eq, *}; diff --git a/tests/rp/src/bin/uart_buffered.rs b/tests/rp/src/bin/uart_buffered.rs index 6a9c910f..14647e44 100644 --- a/tests/rp/src/bin/uart_buffered.rs +++ b/tests/rp/src/bin/uart_buffered.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"rpi-pico"); use defmt::{assert_eq, panic, *}; diff --git a/tests/rp/src/bin/uart_dma.rs b/tests/rp/src/bin/uart_dma.rs index e79fcde6..130d8599 100644 --- a/tests/rp/src/bin/uart_dma.rs +++ b/tests/rp/src/bin/uart_dma.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"rpi-pico"); use defmt::{assert_eq, *}; diff --git a/tests/rp/src/bin/uart_upgrade.rs b/tests/rp/src/bin/uart_upgrade.rs index c07fc08c..603e20f2 100644 --- a/tests/rp/src/bin/uart_upgrade.rs +++ b/tests/rp/src/bin/uart_upgrade.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] teleprobe_meta::target!(b"rpi-pico"); use defmt::{assert_eq, *}; diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index 78508225..8c2cfdf5 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -31,7 +31,7 @@ stm32wb55rg = ["embassy-stm32/stm32wb55rg", "chrono", "not-gpdma", "ble", "mac" stm32wba52cg = ["embassy-stm32/stm32wba52cg", "chrono", "rng"] stm32wl55jc = ["embassy-stm32/stm32wl55jc-cm4", "not-gpdma", "rng", "chrono"] -eth = [] +eth = ["embassy-executor/task-arena-size-16384"] rng = [] sdmmc = [] stop = ["embassy-stm32/low-power", "embassy-stm32/low-power-debug-with-sleep"] @@ -49,7 +49,7 @@ cm0 = ["portable-atomic/unsafe-assume-single-core"] teleprobe-meta = "1" embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "tick-hz-131_072", "defmt-timestamp-uptime"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "memory-x", "time-driver-any"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } diff --git a/tests/stm32/src/bin/can.rs b/tests/stm32/src/bin/can.rs index 8d782d2e..f4effa24 100644 --- a/tests/stm32/src/bin/can.rs +++ b/tests/stm32/src/bin/can.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] // required-features: can diff --git a/tests/stm32/src/bin/dac.rs b/tests/stm32/src/bin/dac.rs index 29d5f866..cf43106b 100644 --- a/tests/stm32/src/bin/dac.rs +++ b/tests/stm32/src/bin/dac.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] // required-features: dac-adc-pin diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs index 83c96ce9..c4e2fe16 100644 --- a/tests/stm32/src/bin/gpio.rs +++ b/tests/stm32/src/bin/gpio.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] #[path = "../common.rs"] mod common; diff --git a/tests/stm32/src/bin/rng.rs b/tests/stm32/src/bin/rng.rs index b7f36137..7f2023d4 100644 --- a/tests/stm32/src/bin/rng.rs +++ b/tests/stm32/src/bin/rng.rs @@ -1,7 +1,6 @@ // required-features: rng #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] #[path = "../common.rs"] mod common; diff --git a/tests/stm32/src/bin/rtc.rs b/tests/stm32/src/bin/rtc.rs index 64f1122a..c04d616a 100644 --- a/tests/stm32/src/bin/rtc.rs +++ b/tests/stm32/src/bin/rtc.rs @@ -2,7 +2,6 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] #[path = "../common.rs"] mod common; diff --git a/tests/stm32/src/bin/sdmmc.rs b/tests/stm32/src/bin/sdmmc.rs index 341d34ba..54f55d2d 100644 --- a/tests/stm32/src/bin/sdmmc.rs +++ b/tests/stm32/src/bin/sdmmc.rs @@ -1,7 +1,6 @@ // required-features: sdmmc #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] #[path = "../common.rs"] mod common; diff --git a/tests/stm32/src/bin/spi.rs b/tests/stm32/src/bin/spi.rs index b0fb75d6..b0bdd477 100644 --- a/tests/stm32/src/bin/spi.rs +++ b/tests/stm32/src/bin/spi.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] #[path = "../common.rs"] mod common; diff --git a/tests/stm32/src/bin/spi_dma.rs b/tests/stm32/src/bin/spi_dma.rs index 212cfae5..5d46726d 100644 --- a/tests/stm32/src/bin/spi_dma.rs +++ b/tests/stm32/src/bin/spi_dma.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] #[path = "../common.rs"] mod common; diff --git a/tests/stm32/src/bin/timer.rs b/tests/stm32/src/bin/timer.rs index 4efeb0a4..d86f54ad 100644 --- a/tests/stm32/src/bin/timer.rs +++ b/tests/stm32/src/bin/timer.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] #[path = "../common.rs"] mod common; diff --git a/tests/stm32/src/bin/usart.rs b/tests/stm32/src/bin/usart.rs index 74a81b4e..9b20eb78 100644 --- a/tests/stm32/src/bin/usart.rs +++ b/tests/stm32/src/bin/usart.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] #[path = "../common.rs"] mod common; diff --git a/tests/stm32/src/bin/usart_dma.rs b/tests/stm32/src/bin/usart_dma.rs index 1421f660..24e2b289 100644 --- a/tests/stm32/src/bin/usart_dma.rs +++ b/tests/stm32/src/bin/usart_dma.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] #[path = "../common.rs"] mod common; diff --git a/tests/stm32/src/bin/usart_rx_ringbuffered.rs b/tests/stm32/src/bin/usart_rx_ringbuffered.rs index 7e15f64b..f5d618db 100644 --- a/tests/stm32/src/bin/usart_rx_ringbuffered.rs +++ b/tests/stm32/src/bin/usart_rx_ringbuffered.rs @@ -2,7 +2,6 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] #[path = "../common.rs"] mod common; diff --git a/tests/stm32/src/bin/wpan_ble.rs b/tests/stm32/src/bin/wpan_ble.rs index 452da77a..ff838471 100644 --- a/tests/stm32/src/bin/wpan_ble.rs +++ b/tests/stm32/src/bin/wpan_ble.rs @@ -2,7 +2,6 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] #[path = "../common.rs"] mod common; diff --git a/tests/stm32/src/bin/wpan_mac.rs b/tests/stm32/src/bin/wpan_mac.rs index 7eab2fd3..fe53b878 100644 --- a/tests/stm32/src/bin/wpan_mac.rs +++ b/tests/stm32/src/bin/wpan_mac.rs @@ -2,7 +2,6 @@ #![no_std] #![no_main] -#![feature(type_alias_impl_trait)] #[path = "../common.rs"] mod common; From 5844f5ce2d704058312ea607eb976e438ad990cb Mon Sep 17 00:00:00 2001 From: Adin Ackerman Date: Mon, 27 Nov 2023 10:23:42 -0800 Subject: [PATCH 04/98] Update faq.adoc --- docs/modules/ROOT/pages/faq.adoc | 125 +++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/docs/modules/ROOT/pages/faq.adoc b/docs/modules/ROOT/pages/faq.adoc index 6032985f..2d49b68a 100644 --- a/docs/modules/ROOT/pages/faq.adoc +++ b/docs/modules/ROOT/pages/faq.adoc @@ -4,6 +4,87 @@ These are a list of unsorted, commonly asked questions and answers. Please feel free to add items to link:https://github.com/embassy-rs/embassy/edit/main/docs/modules/ROOT/pages/faq.adoc[this page], especially if someone in the chat answered a question for you! +== How do I even start? + +There are many ways to configure embassy and it's components for your exact application. The link:https://github.com/embassy-rs/embassy/tree/main/examples[examples] directory for each chipset demonstrate how your project structure should look. Let's break it down: + +The toplevel file structure of your project should look like this: +[source,plain] +---- +{} = Maybe + +my-project +|- .cargo +| |- config.toml +|- src +| |- main.rs +|- build.rs +|- Cargo.toml +|- {memory.x} +|- rust-toolchain.toml +---- + +=== .cargo/config.toml + +This directory/file describes what platform you're on, and configures link:https://github.com/probe-rs/probe-rs[probe-rs] to deploy to your device. + +Here is a minimal example: + +[source,toml] +---- +[target.thumbv6m-none-eabi] # <-change for your platform +runner = 'probe-rs run --chip STM32F031K6Tx' # <- change for your chip + +[build] +target = "thumbv6m-none-eabi" # <-change for your platform + +[env] +DEFMT_LOG = "trace" # <- can change to info, warn, or error +---- + +=== build.rs + +This is the build script for your project. It links defmt (what is defmt?) and the `memory.x` file if need be. This file is pretty specific for each chipset, just copy and paste from the corresponding link:https://github.com/embassy-rs/embassy/tree/main/examples[example]. + +=== Cargo.toml + +This is your manifest file, where you can configure all of the embassy components to use the features you need. + +TODO: someone should exhaustively describe every feature for every component! + +=== memory.x + +This file outlines the flash/ram usage of your program. It is especially useful when using link:https://github.com/embassy-rs/nrf-softdevice[nrf-softdevice] on an nRF5x. + +Here is an example for using S140 with an nRF52840: + +[source,x] +---- +MEMORY +{ + /* NOTE 1 K = 1 KiBi = 1024 bytes */ + /* These values correspond to the NRF52840 with Softdevices S140 7.0.1 */ + FLASH : ORIGIN = 0x00027000, LENGTH = 868K + RAM : ORIGIN = 0x20020000, LENGTH = 128K +} +---- + +=== rust-toolchain.toml + +This file configures the rust version and configuration to use. + +A minimal example: + +[source,toml] +---- +[toolchain] +channel = "nightly-2023-08-19" # <- as of writing, this is the exact rust version embassy uses +components = [ "rust-src", "rustfmt" ] # <- optionally add "llvm-tools-preview" for some extra features like "cargo size" +targets = [ + "thumbv6m-none-eabi" # <-change for your platform +] +---- + == How to deploy to RP2040 without a debugging probe. Install link:https://github.com/JoNil/elf2uf2-rs[elf2uf2-rs] for converting the generated elf binary into a uf2 file. @@ -36,3 +117,47 @@ For Cortex-M targets, consider making sure that ALL of the following features ar * `nightly` For Xtensa ESP32, consider using the executors and `#[main]` macro provided by your appropriate link:https://crates.io/crates/esp-hal-common[HAL crate]. + +== Why is my binary so big? + +The first step to managing your binary size is to set up your link:https://doc.rust-lang.org/cargo/reference/profiles.html[profiles]. + +[source,toml] +---- +[profile.release] +debug = false +lto = true +opt-level = "s" +incremental = true +---- + +All of these flags are elaborated on in the Rust Book page linked above. + +=== My binary is still big... filled with `std::fmt` stuff! + +This means your code is sufficiently complex that `panic!` invocation's formatting requirements could not be optimized out, despite your usage of `panic-halt` or `panic-reset`. + +You can remedy this by adding the following to your `.cargo/config.toml`: + +[source,toml] +---- +[unstable] +build-std = ["core"] +build-std-features = ["panic_immediate_abort"] +---- + +This replaces all panics with a `UDF` (undefined) instruction. + +Depending on your chipset, this will exhibit different behavior. + +Refer to the spec for your chipset, but for `thumbv6m`, it results in a hardfault. Which can be configured like so: + +[source,rust] +---- +#[exception] +unsafe fn HardFault(_frame: &ExceptionFrame) -> ! { + SCB::sys_reset() // <- you could do something other than reset +} +---- + +Refer to cortex-m's link:https://docs.rs/cortex-m-rt/latest/cortex_m_rt/attr.exception.html[exception handling] for more info. From 142f42fe90caf8edddb34ba1fe6119dbd80a67e6 Mon Sep 17 00:00:00 2001 From: Adin Ackerman Date: Mon, 27 Nov 2023 10:44:47 -0800 Subject: [PATCH 05/98] ... --- docs/modules/ROOT/nav.adoc | 1 + docs/modules/ROOT/pages/faq.adoc | 81 ------------------- .../modules/ROOT/pages/project_structure.adoc | 80 ++++++++++++++++++ 3 files changed, 81 insertions(+), 81 deletions(-) create mode 100644 docs/modules/ROOT/pages/project_structure.adoc diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index 7e178df6..13459099 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -1,5 +1,6 @@ * xref:getting_started.adoc[Getting started] ** xref:basic_application.adoc[Basic application] +** xref:project_structure.adoc[Project Structure] * xref:layer_by_layer.adoc[Bare metal to async] * xref:runtime.adoc[Executor] * xref:hal.adoc[HAL] diff --git a/docs/modules/ROOT/pages/faq.adoc b/docs/modules/ROOT/pages/faq.adoc index 2d49b68a..2994c627 100644 --- a/docs/modules/ROOT/pages/faq.adoc +++ b/docs/modules/ROOT/pages/faq.adoc @@ -4,87 +4,6 @@ These are a list of unsorted, commonly asked questions and answers. Please feel free to add items to link:https://github.com/embassy-rs/embassy/edit/main/docs/modules/ROOT/pages/faq.adoc[this page], especially if someone in the chat answered a question for you! -== How do I even start? - -There are many ways to configure embassy and it's components for your exact application. The link:https://github.com/embassy-rs/embassy/tree/main/examples[examples] directory for each chipset demonstrate how your project structure should look. Let's break it down: - -The toplevel file structure of your project should look like this: -[source,plain] ----- -{} = Maybe - -my-project -|- .cargo -| |- config.toml -|- src -| |- main.rs -|- build.rs -|- Cargo.toml -|- {memory.x} -|- rust-toolchain.toml ----- - -=== .cargo/config.toml - -This directory/file describes what platform you're on, and configures link:https://github.com/probe-rs/probe-rs[probe-rs] to deploy to your device. - -Here is a minimal example: - -[source,toml] ----- -[target.thumbv6m-none-eabi] # <-change for your platform -runner = 'probe-rs run --chip STM32F031K6Tx' # <- change for your chip - -[build] -target = "thumbv6m-none-eabi" # <-change for your platform - -[env] -DEFMT_LOG = "trace" # <- can change to info, warn, or error ----- - -=== build.rs - -This is the build script for your project. It links defmt (what is defmt?) and the `memory.x` file if need be. This file is pretty specific for each chipset, just copy and paste from the corresponding link:https://github.com/embassy-rs/embassy/tree/main/examples[example]. - -=== Cargo.toml - -This is your manifest file, where you can configure all of the embassy components to use the features you need. - -TODO: someone should exhaustively describe every feature for every component! - -=== memory.x - -This file outlines the flash/ram usage of your program. It is especially useful when using link:https://github.com/embassy-rs/nrf-softdevice[nrf-softdevice] on an nRF5x. - -Here is an example for using S140 with an nRF52840: - -[source,x] ----- -MEMORY -{ - /* NOTE 1 K = 1 KiBi = 1024 bytes */ - /* These values correspond to the NRF52840 with Softdevices S140 7.0.1 */ - FLASH : ORIGIN = 0x00027000, LENGTH = 868K - RAM : ORIGIN = 0x20020000, LENGTH = 128K -} ----- - -=== rust-toolchain.toml - -This file configures the rust version and configuration to use. - -A minimal example: - -[source,toml] ----- -[toolchain] -channel = "nightly-2023-08-19" # <- as of writing, this is the exact rust version embassy uses -components = [ "rust-src", "rustfmt" ] # <- optionally add "llvm-tools-preview" for some extra features like "cargo size" -targets = [ - "thumbv6m-none-eabi" # <-change for your platform -] ----- - == How to deploy to RP2040 without a debugging probe. Install link:https://github.com/JoNil/elf2uf2-rs[elf2uf2-rs] for converting the generated elf binary into a uf2 file. diff --git a/docs/modules/ROOT/pages/project_structure.adoc b/docs/modules/ROOT/pages/project_structure.adoc new file mode 100644 index 00000000..31417d09 --- /dev/null +++ b/docs/modules/ROOT/pages/project_structure.adoc @@ -0,0 +1,80 @@ += Project Structure + +There are many ways to configure embassy and it's components for your exact application. The link:https://github.com/embassy-rs/embassy/tree/main/examples[examples] directory for each chipset demonstrate how your project structure should look. Let's break it down: + +The toplevel file structure of your project should look like this: +[source,plain] +---- +{} = Maybe + +my-project +|- .cargo +| |- config.toml +|- src +| |- main.rs +|- build.rs +|- Cargo.toml +|- {memory.x} +|- rust-toolchain.toml +---- + +=== .cargo/config.toml + +This directory/file describes what platform you're on, and configures link:https://github.com/probe-rs/probe-rs[probe-rs] to deploy to your device. + +Here is a minimal example: + +[source,toml] +---- +[target.thumbv6m-none-eabi] # <-change for your platform +runner = 'probe-rs run --chip STM32F031K6Tx' # <- change for your chip + +[build] +target = "thumbv6m-none-eabi" # <-change for your platform + +[env] +DEFMT_LOG = "trace" # <- can change to info, warn, or error +---- + +=== build.rs + +This is the build script for your project. It links defmt (what is defmt?) and the `memory.x` file if need be. This file is pretty specific for each chipset, just copy and paste from the corresponding link:https://github.com/embassy-rs/embassy/tree/main/examples[example]. + +=== Cargo.toml + +This is your manifest file, where you can configure all of the embassy components to use the features you need. + +TODO: someone should exhaustively describe every feature for every component! + +=== memory.x + +This file outlines the flash/ram usage of your program. It is especially useful when using link:https://github.com/embassy-rs/nrf-softdevice[nrf-softdevice] on an nRF5x. + +Here is an example for using S140 with an nRF52840: + +[source,x] +---- +MEMORY +{ + /* NOTE 1 K = 1 KiBi = 1024 bytes */ + /* These values correspond to the NRF52840 with Softdevices S140 7.0.1 */ + FLASH : ORIGIN = 0x00027000, LENGTH = 868K + RAM : ORIGIN = 0x20020000, LENGTH = 128K +} +---- + +=== rust-toolchain.toml + +This file configures the rust version and configuration to use. + +A minimal example: + +[source,toml] +---- +[toolchain] +channel = "nightly-2023-08-19" # <- as of writing, this is the exact rust version embassy uses +components = [ "rust-src", "rustfmt" ] # <- optionally add "llvm-tools-preview" for some extra features like "cargo size" +targets = [ + "thumbv6m-none-eabi" # <-change for your platform +] +---- From a42aef7759a2f2b1da5bb9a62bb83006c4e856e0 Mon Sep 17 00:00:00 2001 From: AdinAck Date: Mon, 27 Nov 2023 10:51:05 -0800 Subject: [PATCH 06/98] it's -> its MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Dániel Buga --- docs/modules/ROOT/pages/project_structure.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/modules/ROOT/pages/project_structure.adoc b/docs/modules/ROOT/pages/project_structure.adoc index 31417d09..ac992f8b 100644 --- a/docs/modules/ROOT/pages/project_structure.adoc +++ b/docs/modules/ROOT/pages/project_structure.adoc @@ -1,6 +1,6 @@ = Project Structure -There are many ways to configure embassy and it's components for your exact application. The link:https://github.com/embassy-rs/embassy/tree/main/examples[examples] directory for each chipset demonstrate how your project structure should look. Let's break it down: +There are many ways to configure embassy and its components for your exact application. The link:https://github.com/embassy-rs/embassy/tree/main/examples[examples] directory for each chipset demonstrates how your project structure should look. Let's break it down: The toplevel file structure of your project should look like this: [source,plain] From 02305451b1893924effa8d036a0d379ed485a364 Mon Sep 17 00:00:00 2001 From: AdinAck Date: Mon, 27 Nov 2023 10:51:20 -0800 Subject: [PATCH 07/98] need be -> needed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Dániel Buga --- docs/modules/ROOT/pages/project_structure.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/modules/ROOT/pages/project_structure.adoc b/docs/modules/ROOT/pages/project_structure.adoc index ac992f8b..3e6008ec 100644 --- a/docs/modules/ROOT/pages/project_structure.adoc +++ b/docs/modules/ROOT/pages/project_structure.adoc @@ -38,7 +38,7 @@ DEFMT_LOG = "trace" # <- can change to info, warn, or error === build.rs -This is the build script for your project. It links defmt (what is defmt?) and the `memory.x` file if need be. This file is pretty specific for each chipset, just copy and paste from the corresponding link:https://github.com/embassy-rs/embassy/tree/main/examples[example]. +This is the build script for your project. It links defmt (what is defmt?) and the `memory.x` file if needed. This file is pretty specific for each chipset, just copy and paste from the corresponding link:https://github.com/embassy-rs/embassy/tree/main/examples[example]. === Cargo.toml From f88aa9ce4857d59a5bcb40e300728c9b1f6e8f06 Mon Sep 17 00:00:00 2001 From: James Munns Date: Mon, 27 Nov 2023 21:42:10 +0100 Subject: [PATCH 08/98] (FAQ): Add time driver note --- docs/modules/ROOT/pages/faq.adoc | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/docs/modules/ROOT/pages/faq.adoc b/docs/modules/ROOT/pages/faq.adoc index 2994c627..1b4357be 100644 --- a/docs/modules/ROOT/pages/faq.adoc +++ b/docs/modules/ROOT/pages/faq.adoc @@ -80,3 +80,39 @@ unsafe fn HardFault(_frame: &ExceptionFrame) -> ! { ---- Refer to cortex-m's link:https://docs.rs/cortex-m-rt/latest/cortex_m_rt/attr.exception.html[exception handling] for more info. + +== `embassy-time` throws linker errors + +If you see linker error like this: + +[source,text] +---- + = note: rust-lld: error: undefined symbol: _embassy_time_now + >>> referenced by driver.rs:127 (src/driver.rs:127) + >>> embassy_time-846f66f1620ad42c.embassy_time.4f6a638abb75dd4c-cgu.0.rcgu.o:(embassy_time::driver::now::hefb1f99d6e069842) in archive Devel/Embedded/pogodyna/target/thumbv7em-none-eabihf/debug/deps/libembassy_time-846f66f1620ad42c.rlib + + rust-lld: error: undefined symbol: _embassy_time_allocate_alarm + >>> referenced by driver.rs:134 (src/driver.rs:134) + >>> embassy_time-846f66f1620ad42c.embassy_time.4f6a638abb75dd4c-cgu.0.rcgu.o:(embassy_time::driver::allocate_alarm::hf5145b6bd46706b2) in archive Devel/Embedded/pogodyna/target/thumbv7em-none-eabihf/debug/deps/libembassy_time-846f66f1620ad42c.rlib + + rust-lld: error: undefined symbol: _embassy_time_set_alarm_callback + >>> referenced by driver.rs:139 (src/driver.rs:139) + >>> embassy_time-846f66f1620ad42c.embassy_time.4f6a638abb75dd4c-cgu.0.rcgu.o:(embassy_time::driver::set_alarm_callback::h24f92388d96eafd2) in archive Devel/Embedded/pogodyna/target/thumbv7em-none-eabihf/debug/deps/libembassy_time-846f66f1620ad42c.rlib + + rust-lld: error: undefined symbol: _embassy_time_set_alarm + >>> referenced by driver.rs:144 (src/driver.rs:144) + >>> embassy_time-846f66f1620ad42c.embassy_time.4f6a638abb75dd4c-cgu.0.rcgu.o:(embassy_time::driver::set_alarm::h530a5b1f444a6d5b) in archive Devel/Embedded/pogodyna/target/thumbv7em-none-eabihf/debug/deps/libembassy_time-846f66f1620ad42c.rlib +---- + +You probably need to enable a time driver for your HAL (not in `embassy-time`!). For example with `embassy-stm32`, you might need to enable `time-driver-any`: + +[source,toml] +---- +[dependencies.embassy-stm32] +version = "0.1.0", +features = [ + # ... + "time-driver-any", # Add this line! + # ... +] +---- From 74a6855f0104f5e9a4ad8603546444d9428c8917 Mon Sep 17 00:00:00 2001 From: James Munns Date: Mon, 27 Nov 2023 21:43:05 +0100 Subject: [PATCH 09/98] Update docs/modules/ROOT/pages/faq.adoc --- docs/modules/ROOT/pages/faq.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/modules/ROOT/pages/faq.adoc b/docs/modules/ROOT/pages/faq.adoc index 1b4357be..37a2605d 100644 --- a/docs/modules/ROOT/pages/faq.adoc +++ b/docs/modules/ROOT/pages/faq.adoc @@ -109,7 +109,7 @@ You probably need to enable a time driver for your HAL (not in `embassy-time`!). [source,toml] ---- [dependencies.embassy-stm32] -version = "0.1.0", +version = "0.1.0" features = [ # ... "time-driver-any", # Add this line! From 2c9f4bce019daa475cd8a0c5455abaff6f32c80a Mon Sep 17 00:00:00 2001 From: Torin Cooper-Bennun Date: Mon, 27 Nov 2023 19:52:31 +0000 Subject: [PATCH 10/98] shared_bus/blocking/spi: fix build and behaviour when "time" disabled new behaviour: check for DelayUs presence in operations instead of shortcircuiting --- embassy-embedded-hal/src/shared_bus/blocking/spi.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/embassy-embedded-hal/src/shared_bus/blocking/spi.rs b/embassy-embedded-hal/src/shared_bus/blocking/spi.rs index feb0f5b7..2b67862e 100644 --- a/embassy-embedded-hal/src/shared_bus/blocking/spi.rs +++ b/embassy-embedded-hal/src/shared_bus/blocking/spi.rs @@ -55,6 +55,10 @@ where CS: OutputPin, { fn transaction(&mut self, operations: &mut [Operation<'_, u8>]) -> Result<(), Self::Error> { + if cfg!(not(feature = "time")) && operations.iter().any(|op| matches!(op, Operation::DelayUs(_))) { + return Err(SpiDeviceError::DelayUsNotSupported); + } + self.bus.lock(|bus| { let mut bus = bus.borrow_mut(); self.cs.set_low().map_err(SpiDeviceError::Cs)?; @@ -65,7 +69,7 @@ where Operation::Transfer(read, write) => bus.transfer(read, write), Operation::TransferInPlace(buf) => bus.transfer_in_place(buf), #[cfg(not(feature = "time"))] - Operation::DelayUs(_) => Err(SpiDeviceError::DelayUsNotSupported), + Operation::DelayUs(_) => unreachable!(), #[cfg(feature = "time")] Operation::DelayUs(us) => { embassy_time::block_for(embassy_time::Duration::from_micros(*us as _)); @@ -161,6 +165,10 @@ where CS: OutputPin, { fn transaction(&mut self, operations: &mut [Operation<'_, u8>]) -> Result<(), Self::Error> { + if cfg!(not(feature = "time")) && operations.iter().any(|op| matches!(op, Operation::DelayUs(_))) { + return Err(SpiDeviceError::DelayUsNotSupported); + } + self.bus.lock(|bus| { let mut bus = bus.borrow_mut(); bus.set_config(&self.config).map_err(|_| SpiDeviceError::Config)?; @@ -172,7 +180,7 @@ where Operation::Transfer(read, write) => bus.transfer(read, write), Operation::TransferInPlace(buf) => bus.transfer_in_place(buf), #[cfg(not(feature = "time"))] - Operation::DelayUs(_) => Err(SpiDeviceError::DelayUsNotSupported), + Operation::DelayUs(_) => unreachable!(), #[cfg(feature = "time")] Operation::DelayUs(us) => { embassy_time::block_for(embassy_time::Duration::from_micros(*us as _)); From a3c99f032460a503ac8a55a613f060801842fb5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Mon, 27 Nov 2023 18:26:52 +0100 Subject: [PATCH 11/98] Add multiple dependency error faq --- docs/modules/ROOT/pages/faq.adoc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/modules/ROOT/pages/faq.adoc b/docs/modules/ROOT/pages/faq.adoc index 37a2605d..df3f6665 100644 --- a/docs/modules/ROOT/pages/faq.adoc +++ b/docs/modules/ROOT/pages/faq.adoc @@ -116,3 +116,22 @@ features = [ # ... ] ---- + +== Error: `Only one package in the dependency graph may specify the same links value.` + +You have multiple versions of the same crate in your dependency tree. This means that some of your +embassy crates are coming from crates.io, and some from git, each of them pulling in a different set +of dependencies. + +To resolve this issue, make sure to only use a single source for all your embassy crates! To do this, +you should patch your dependencies to use git sources using `[patch.crates.io]` and maybe `[patch.'https://github.com/embassy-rs/embassy.git']`. + +Example: + +[source,toml] +---- +[patch.crates-io] +embassy-time = { git = "https://github.com/embassy-rs/embassy.git", rev = "e5fdd35" } +---- + +Note that the git revision should match any other embassy patches or git dependencies that you are using! From 1b9925e3da0ec42b770f736cd22325203c97cb47 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 29 Nov 2023 16:26:31 +0100 Subject: [PATCH 12/98] Move embassy-lora, lora examples to lora-phy repo. --- embassy-lora/Cargo.toml | 31 -- embassy-lora/src/fmt.rs | 258 -------------- embassy-lora/src/iv.rs | 317 ------------------ embassy-lora/src/lib.rs | 40 --- examples/nrf52840/Cargo.toml | 8 - examples/nrf52840/src/bin/lora_cad.rs | 97 ------ examples/nrf52840/src/bin/lora_lorawan.rs | 82 ----- examples/nrf52840/src/bin/lora_p2p_receive.rs | 119 ------- .../src/bin/lora_p2p_receive_duty_cycle.rs | 127 ------- examples/nrf52840/src/bin/lora_p2p_send.rs | 102 ------ examples/rp/Cargo.toml | 4 - examples/rp/src/bin/lora_lorawan.rs | 74 ---- examples/rp/src/bin/lora_p2p_receive.rs | 108 ------ examples/rp/src/bin/lora_p2p_send.rs | 96 ------ .../rp/src/bin/lora_p2p_send_multicore.rs | 133 -------- examples/stm32l0/Cargo.toml | 7 +- examples/stm32l0/src/bin/lora_cad.rs | 97 ------ examples/stm32l0/src/bin/lora_lorawan.rs | 85 ----- examples/stm32l0/src/bin/lora_p2p_receive.rs | 119 ------- examples/stm32l0/src/bin/lora_p2p_send.rs | 102 ------ examples/stm32wl/Cargo.toml | 4 - examples/stm32wl/src/bin/lora_lorawan.rs | 95 ------ examples/stm32wl/src/bin/lora_p2p_receive.rs | 133 -------- examples/stm32wl/src/bin/lora_p2p_send.rs | 116 ------- 24 files changed, 1 insertion(+), 2353 deletions(-) delete mode 100644 embassy-lora/Cargo.toml delete mode 100644 embassy-lora/src/fmt.rs delete mode 100644 embassy-lora/src/iv.rs delete mode 100644 embassy-lora/src/lib.rs delete mode 100644 examples/nrf52840/src/bin/lora_cad.rs delete mode 100644 examples/nrf52840/src/bin/lora_lorawan.rs delete mode 100644 examples/nrf52840/src/bin/lora_p2p_receive.rs delete mode 100644 examples/nrf52840/src/bin/lora_p2p_receive_duty_cycle.rs delete mode 100644 examples/nrf52840/src/bin/lora_p2p_send.rs delete mode 100644 examples/rp/src/bin/lora_lorawan.rs delete mode 100644 examples/rp/src/bin/lora_p2p_receive.rs delete mode 100644 examples/rp/src/bin/lora_p2p_send.rs delete mode 100644 examples/rp/src/bin/lora_p2p_send_multicore.rs delete mode 100644 examples/stm32l0/src/bin/lora_cad.rs delete mode 100644 examples/stm32l0/src/bin/lora_lorawan.rs delete mode 100644 examples/stm32l0/src/bin/lora_p2p_receive.rs delete mode 100644 examples/stm32l0/src/bin/lora_p2p_send.rs delete mode 100644 examples/stm32wl/src/bin/lora_lorawan.rs delete mode 100644 examples/stm32wl/src/bin/lora_p2p_receive.rs delete mode 100644 examples/stm32wl/src/bin/lora_p2p_send.rs diff --git a/embassy-lora/Cargo.toml b/embassy-lora/Cargo.toml deleted file mode 100644 index f2ba379b..00000000 --- a/embassy-lora/Cargo.toml +++ /dev/null @@ -1,31 +0,0 @@ -[package] -name = "embassy-lora" -version = "0.1.0" -edition = "2021" -license = "MIT OR Apache-2.0" - -[package.metadata.embassy_docs] -src_base = "https://github.com/embassy-rs/embassy/blob/embassy-lora-v$VERSION/embassy-lora/src/" -src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-lora/src/" -features = ["stm32wl", "embassy-stm32?/stm32wl55jc-cm4", "embassy-stm32?/unstable-pac", "time", "defmt"] -target = "thumbv7em-none-eabi" - -[features] -stm32wl = ["dep:embassy-stm32"] -time = ["embassy-time", "lorawan-device"] -defmt = ["dep:defmt", "lorawan-device/defmt"] - -[dependencies] - -defmt = { version = "0.3", optional = true } -log = { version = "0.4.14", optional = true } - -embassy-time = { version = "0.1.5", path = "../embassy-time", optional = true } -embassy-sync = { version = "0.4.0", path = "../embassy-sync" } -embassy-stm32 = { version = "0.1.0", path = "../embassy-stm32", default-features = false, optional = true } -embedded-hal-async = { version = "=1.0.0-rc.1" } -embedded-hal = { version = "0.2", features = ["unproven"] } - -futures = { version = "0.3.17", default-features = false, features = [ "async-await" ] } -lora-phy = { version = "2" } -lorawan-device = { version = "0.11.0", default-features = false, features = ["async"], optional = true } diff --git a/embassy-lora/src/fmt.rs b/embassy-lora/src/fmt.rs deleted file mode 100644 index 78e583c1..00000000 --- a/embassy-lora/src/fmt.rs +++ /dev/null @@ -1,258 +0,0 @@ -#![macro_use] -#![allow(unused_macros)] - -use core::fmt::{Debug, Display, LowerHex}; - -#[cfg(all(feature = "defmt", feature = "log"))] -compile_error!("You may not enable both `defmt` and `log` features."); - -macro_rules! assert { - ($($x:tt)*) => { - { - #[cfg(not(feature = "defmt"))] - ::core::assert!($($x)*); - #[cfg(feature = "defmt")] - ::defmt::assert!($($x)*); - } - }; -} - -macro_rules! assert_eq { - ($($x:tt)*) => { - { - #[cfg(not(feature = "defmt"))] - ::core::assert_eq!($($x)*); - #[cfg(feature = "defmt")] - ::defmt::assert_eq!($($x)*); - } - }; -} - -macro_rules! assert_ne { - ($($x:tt)*) => { - { - #[cfg(not(feature = "defmt"))] - ::core::assert_ne!($($x)*); - #[cfg(feature = "defmt")] - ::defmt::assert_ne!($($x)*); - } - }; -} - -macro_rules! debug_assert { - ($($x:tt)*) => { - { - #[cfg(not(feature = "defmt"))] - ::core::debug_assert!($($x)*); - #[cfg(feature = "defmt")] - ::defmt::debug_assert!($($x)*); - } - }; -} - -macro_rules! debug_assert_eq { - ($($x:tt)*) => { - { - #[cfg(not(feature = "defmt"))] - ::core::debug_assert_eq!($($x)*); - #[cfg(feature = "defmt")] - ::defmt::debug_assert_eq!($($x)*); - } - }; -} - -macro_rules! debug_assert_ne { - ($($x:tt)*) => { - { - #[cfg(not(feature = "defmt"))] - ::core::debug_assert_ne!($($x)*); - #[cfg(feature = "defmt")] - ::defmt::debug_assert_ne!($($x)*); - } - }; -} - -macro_rules! todo { - ($($x:tt)*) => { - { - #[cfg(not(feature = "defmt"))] - ::core::todo!($($x)*); - #[cfg(feature = "defmt")] - ::defmt::todo!($($x)*); - } - }; -} - -#[cfg(not(feature = "defmt"))] -macro_rules! unreachable { - ($($x:tt)*) => { - ::core::unreachable!($($x)*) - }; -} - -#[cfg(feature = "defmt")] -macro_rules! unreachable { - ($($x:tt)*) => { - ::defmt::unreachable!($($x)*) - }; -} - -macro_rules! panic { - ($($x:tt)*) => { - { - #[cfg(not(feature = "defmt"))] - ::core::panic!($($x)*); - #[cfg(feature = "defmt")] - ::defmt::panic!($($x)*); - } - }; -} - -macro_rules! trace { - ($s:literal $(, $x:expr)* $(,)?) => { - { - #[cfg(feature = "log")] - ::log::trace!($s $(, $x)*); - #[cfg(feature = "defmt")] - ::defmt::trace!($s $(, $x)*); - #[cfg(not(any(feature = "log", feature="defmt")))] - let _ = ($( & $x ),*); - } - }; -} - -macro_rules! debug { - ($s:literal $(, $x:expr)* $(,)?) => { - { - #[cfg(feature = "log")] - ::log::debug!($s $(, $x)*); - #[cfg(feature = "defmt")] - ::defmt::debug!($s $(, $x)*); - #[cfg(not(any(feature = "log", feature="defmt")))] - let _ = ($( & $x ),*); - } - }; -} - -macro_rules! info { - ($s:literal $(, $x:expr)* $(,)?) => { - { - #[cfg(feature = "log")] - ::log::info!($s $(, $x)*); - #[cfg(feature = "defmt")] - ::defmt::info!($s $(, $x)*); - #[cfg(not(any(feature = "log", feature="defmt")))] - let _ = ($( & $x ),*); - } - }; -} - -macro_rules! warn { - ($s:literal $(, $x:expr)* $(,)?) => { - { - #[cfg(feature = "log")] - ::log::warn!($s $(, $x)*); - #[cfg(feature = "defmt")] - ::defmt::warn!($s $(, $x)*); - #[cfg(not(any(feature = "log", feature="defmt")))] - let _ = ($( & $x ),*); - } - }; -} - -macro_rules! error { - ($s:literal $(, $x:expr)* $(,)?) => { - { - #[cfg(feature = "log")] - ::log::error!($s $(, $x)*); - #[cfg(feature = "defmt")] - ::defmt::error!($s $(, $x)*); - #[cfg(not(any(feature = "log", feature="defmt")))] - let _ = ($( & $x ),*); - } - }; -} - -#[cfg(feature = "defmt")] -macro_rules! unwrap { - ($($x:tt)*) => { - ::defmt::unwrap!($($x)*) - }; -} - -#[cfg(not(feature = "defmt"))] -macro_rules! unwrap { - ($arg:expr) => { - match $crate::fmt::Try::into_result($arg) { - ::core::result::Result::Ok(t) => t, - ::core::result::Result::Err(e) => { - ::core::panic!("unwrap of `{}` failed: {:?}", ::core::stringify!($arg), e); - } - } - }; - ($arg:expr, $($msg:expr),+ $(,)? ) => { - match $crate::fmt::Try::into_result($arg) { - ::core::result::Result::Ok(t) => t, - ::core::result::Result::Err(e) => { - ::core::panic!("unwrap of `{}` failed: {}: {:?}", ::core::stringify!($arg), ::core::format_args!($($msg,)*), e); - } - } - } -} - -#[derive(Debug, Copy, Clone, Eq, PartialEq)] -pub struct NoneError; - -pub trait Try { - type Ok; - type Error; - fn into_result(self) -> Result; -} - -impl Try for Option { - type Ok = T; - type Error = NoneError; - - #[inline] - fn into_result(self) -> Result { - self.ok_or(NoneError) - } -} - -impl Try for Result { - type Ok = T; - type Error = E; - - #[inline] - fn into_result(self) -> Self { - self - } -} - -#[allow(unused)] -pub(crate) struct Bytes<'a>(pub &'a [u8]); - -impl<'a> Debug for Bytes<'a> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - write!(f, "{:#02x?}", self.0) - } -} - -impl<'a> Display for Bytes<'a> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - write!(f, "{:#02x?}", self.0) - } -} - -impl<'a> LowerHex for Bytes<'a> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - write!(f, "{:#02x?}", self.0) - } -} - -#[cfg(feature = "defmt")] -impl<'a> defmt::Format for Bytes<'a> { - fn format(&self, fmt: defmt::Formatter) { - defmt::write!(fmt, "{:02x}", self.0) - } -} diff --git a/embassy-lora/src/iv.rs b/embassy-lora/src/iv.rs deleted file mode 100644 index d22beb33..00000000 --- a/embassy-lora/src/iv.rs +++ /dev/null @@ -1,317 +0,0 @@ -#[cfg(feature = "stm32wl")] -use embassy_stm32::interrupt; -#[cfg(feature = "stm32wl")] -use embassy_stm32::interrupt::InterruptExt; -#[cfg(feature = "stm32wl")] -use embassy_stm32::pac; -#[cfg(feature = "stm32wl")] -use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; -#[cfg(feature = "stm32wl")] -use embassy_sync::signal::Signal; -use embedded_hal::digital::v2::OutputPin; -use embedded_hal_async::delay::DelayUs; -use embedded_hal_async::digital::Wait; -use lora_phy::mod_params::RadioError::*; -use lora_phy::mod_params::{BoardType, RadioError}; -use lora_phy::mod_traits::InterfaceVariant; - -/// Interrupt handler. -#[cfg(feature = "stm32wl")] -pub struct InterruptHandler {} - -#[cfg(feature = "stm32wl")] -impl interrupt::typelevel::Handler for InterruptHandler { - unsafe fn on_interrupt() { - interrupt::SUBGHZ_RADIO.disable(); - IRQ_SIGNAL.signal(()); - } -} - -#[cfg(feature = "stm32wl")] -static IRQ_SIGNAL: Signal = Signal::new(); - -#[cfg(feature = "stm32wl")] -/// Base for the InterfaceVariant implementation for an stm32wl/sx1262 combination -pub struct Stm32wlInterfaceVariant { - board_type: BoardType, - rf_switch_rx: Option, - rf_switch_tx: Option, -} - -#[cfg(feature = "stm32wl")] -impl<'a, CTRL> Stm32wlInterfaceVariant -where - CTRL: OutputPin, -{ - /// Create an InterfaceVariant instance for an stm32wl/sx1262 combination - pub fn new( - _irq: impl interrupt::typelevel::Binding, - rf_switch_rx: Option, - rf_switch_tx: Option, - ) -> Result { - interrupt::SUBGHZ_RADIO.disable(); - Ok(Self { - board_type: BoardType::Stm32wlSx1262, // updated when associated with a specific LoRa board - rf_switch_rx, - rf_switch_tx, - }) - } -} - -#[cfg(feature = "stm32wl")] -impl InterfaceVariant for Stm32wlInterfaceVariant -where - CTRL: OutputPin, -{ - fn set_board_type(&mut self, board_type: BoardType) { - self.board_type = board_type; - } - async fn set_nss_low(&mut self) -> Result<(), RadioError> { - pac::PWR.subghzspicr().modify(|w| w.set_nss(false)); - Ok(()) - } - async fn set_nss_high(&mut self) -> Result<(), RadioError> { - pac::PWR.subghzspicr().modify(|w| w.set_nss(true)); - Ok(()) - } - async fn reset(&mut self, _delay: &mut impl DelayUs) -> Result<(), RadioError> { - pac::RCC.csr().modify(|w| w.set_rfrst(true)); - pac::RCC.csr().modify(|w| w.set_rfrst(false)); - Ok(()) - } - async fn wait_on_busy(&mut self) -> Result<(), RadioError> { - while pac::PWR.sr2().read().rfbusys() {} - Ok(()) - } - - async fn await_irq(&mut self) -> Result<(), RadioError> { - unsafe { interrupt::SUBGHZ_RADIO.enable() }; - IRQ_SIGNAL.wait().await; - Ok(()) - } - - async fn enable_rf_switch_rx(&mut self) -> Result<(), RadioError> { - match &mut self.rf_switch_tx { - Some(pin) => pin.set_low().map_err(|_| RfSwitchTx)?, - None => (), - }; - match &mut self.rf_switch_rx { - Some(pin) => pin.set_high().map_err(|_| RfSwitchRx), - None => Ok(()), - } - } - async fn enable_rf_switch_tx(&mut self) -> Result<(), RadioError> { - match &mut self.rf_switch_rx { - Some(pin) => pin.set_low().map_err(|_| RfSwitchRx)?, - None => (), - }; - match &mut self.rf_switch_tx { - Some(pin) => pin.set_high().map_err(|_| RfSwitchTx), - None => Ok(()), - } - } - async fn disable_rf_switch(&mut self) -> Result<(), RadioError> { - match &mut self.rf_switch_rx { - Some(pin) => pin.set_low().map_err(|_| RfSwitchRx)?, - None => (), - }; - match &mut self.rf_switch_tx { - Some(pin) => pin.set_low().map_err(|_| RfSwitchTx), - None => Ok(()), - } - } -} - -/// Base for the InterfaceVariant implementation for an stm32l0/sx1276 combination -pub struct Stm32l0InterfaceVariant { - board_type: BoardType, - nss: CTRL, - reset: CTRL, - irq: WAIT, - rf_switch_rx: Option, - rf_switch_tx: Option, -} - -impl Stm32l0InterfaceVariant -where - CTRL: OutputPin, - WAIT: Wait, -{ - /// Create an InterfaceVariant instance for an stm32l0/sx1276 combination - pub fn new( - nss: CTRL, - reset: CTRL, - irq: WAIT, - rf_switch_rx: Option, - rf_switch_tx: Option, - ) -> Result { - Ok(Self { - board_type: BoardType::Stm32l0Sx1276, // updated when associated with a specific LoRa board - nss, - reset, - irq, - rf_switch_rx, - rf_switch_tx, - }) - } -} - -impl InterfaceVariant for Stm32l0InterfaceVariant -where - CTRL: OutputPin, - WAIT: Wait, -{ - fn set_board_type(&mut self, board_type: BoardType) { - self.board_type = board_type; - } - async fn set_nss_low(&mut self) -> Result<(), RadioError> { - self.nss.set_low().map_err(|_| NSS) - } - async fn set_nss_high(&mut self) -> Result<(), RadioError> { - self.nss.set_high().map_err(|_| NSS) - } - async fn reset(&mut self, delay: &mut impl DelayUs) -> Result<(), RadioError> { - delay.delay_ms(10).await; - self.reset.set_low().map_err(|_| Reset)?; - delay.delay_ms(10).await; - self.reset.set_high().map_err(|_| Reset)?; - delay.delay_ms(10).await; - Ok(()) - } - async fn wait_on_busy(&mut self) -> Result<(), RadioError> { - Ok(()) - } - async fn await_irq(&mut self) -> Result<(), RadioError> { - self.irq.wait_for_high().await.map_err(|_| Irq) - } - - async fn enable_rf_switch_rx(&mut self) -> Result<(), RadioError> { - match &mut self.rf_switch_tx { - Some(pin) => pin.set_low().map_err(|_| RfSwitchTx)?, - None => (), - }; - match &mut self.rf_switch_rx { - Some(pin) => pin.set_high().map_err(|_| RfSwitchRx), - None => Ok(()), - } - } - async fn enable_rf_switch_tx(&mut self) -> Result<(), RadioError> { - match &mut self.rf_switch_rx { - Some(pin) => pin.set_low().map_err(|_| RfSwitchRx)?, - None => (), - }; - match &mut self.rf_switch_tx { - Some(pin) => pin.set_high().map_err(|_| RfSwitchTx), - None => Ok(()), - } - } - async fn disable_rf_switch(&mut self) -> Result<(), RadioError> { - match &mut self.rf_switch_rx { - Some(pin) => pin.set_low().map_err(|_| RfSwitchRx)?, - None => (), - }; - match &mut self.rf_switch_tx { - Some(pin) => pin.set_low().map_err(|_| RfSwitchTx), - None => Ok(()), - } - } -} - -/// Base for the InterfaceVariant implementation for a generic Sx126x LoRa board -pub struct GenericSx126xInterfaceVariant { - board_type: BoardType, - nss: CTRL, - reset: CTRL, - dio1: WAIT, - busy: WAIT, - rf_switch_rx: Option, - rf_switch_tx: Option, -} - -impl GenericSx126xInterfaceVariant -where - CTRL: OutputPin, - WAIT: Wait, -{ - /// Create an InterfaceVariant instance for an nrf52840/sx1262 combination - pub fn new( - nss: CTRL, - reset: CTRL, - dio1: WAIT, - busy: WAIT, - rf_switch_rx: Option, - rf_switch_tx: Option, - ) -> Result { - Ok(Self { - board_type: BoardType::Rak4631Sx1262, // updated when associated with a specific LoRa board - nss, - reset, - dio1, - busy, - rf_switch_rx, - rf_switch_tx, - }) - } -} - -impl InterfaceVariant for GenericSx126xInterfaceVariant -where - CTRL: OutputPin, - WAIT: Wait, -{ - fn set_board_type(&mut self, board_type: BoardType) { - self.board_type = board_type; - } - async fn set_nss_low(&mut self) -> Result<(), RadioError> { - self.nss.set_low().map_err(|_| NSS) - } - async fn set_nss_high(&mut self) -> Result<(), RadioError> { - self.nss.set_high().map_err(|_| NSS) - } - async fn reset(&mut self, delay: &mut impl DelayUs) -> Result<(), RadioError> { - delay.delay_ms(10).await; - self.reset.set_low().map_err(|_| Reset)?; - delay.delay_ms(20).await; - self.reset.set_high().map_err(|_| Reset)?; - delay.delay_ms(10).await; - Ok(()) - } - async fn wait_on_busy(&mut self) -> Result<(), RadioError> { - self.busy.wait_for_low().await.map_err(|_| Busy) - } - async fn await_irq(&mut self) -> Result<(), RadioError> { - self.dio1.wait_for_high().await.map_err(|_| DIO1)?; - Ok(()) - } - - async fn enable_rf_switch_rx(&mut self) -> Result<(), RadioError> { - match &mut self.rf_switch_tx { - Some(pin) => pin.set_low().map_err(|_| RfSwitchTx)?, - None => (), - }; - match &mut self.rf_switch_rx { - Some(pin) => pin.set_high().map_err(|_| RfSwitchRx), - None => Ok(()), - } - } - async fn enable_rf_switch_tx(&mut self) -> Result<(), RadioError> { - match &mut self.rf_switch_rx { - Some(pin) => pin.set_low().map_err(|_| RfSwitchRx)?, - None => (), - }; - match &mut self.rf_switch_tx { - Some(pin) => pin.set_high().map_err(|_| RfSwitchTx), - None => Ok(()), - } - } - async fn disable_rf_switch(&mut self) -> Result<(), RadioError> { - match &mut self.rf_switch_rx { - Some(pin) => pin.set_low().map_err(|_| RfSwitchRx)?, - None => (), - }; - match &mut self.rf_switch_tx { - Some(pin) => pin.set_low().map_err(|_| RfSwitchTx), - None => Ok(()), - } - } -} diff --git a/embassy-lora/src/lib.rs b/embassy-lora/src/lib.rs deleted file mode 100644 index 653c9825..00000000 --- a/embassy-lora/src/lib.rs +++ /dev/null @@ -1,40 +0,0 @@ -#![no_std] -#![feature(async_fn_in_trait, impl_trait_projections)] -#![allow(stable_features, unknown_lints, async_fn_in_trait)] -//! embassy-lora holds LoRa-specific functionality. - -pub(crate) mod fmt; - -/// interface variants required by the external lora physical layer crate (lora-phy) -pub mod iv; - -#[cfg(feature = "time")] -use embassy_time::{Duration, Instant, Timer}; - -/// A convenience timer to use with the LoRaWAN crate -#[cfg(feature = "time")] -pub struct LoraTimer { - start: Instant, -} - -#[cfg(feature = "time")] -impl LoraTimer { - pub fn new() -> Self { - Self { start: Instant::now() } - } -} - -#[cfg(feature = "time")] -impl lorawan_device::async_device::radio::Timer for LoraTimer { - fn reset(&mut self) { - self.start = Instant::now(); - } - - async fn at(&mut self, millis: u64) { - Timer::at(self.start + Duration::from_millis(millis)).await - } - - async fn delay_ms(&mut self, millis: u64) { - Timer::after_millis(millis).await - } -} diff --git a/examples/nrf52840/Cargo.toml b/examples/nrf52840/Cargo.toml index df5b1f3b..88e8d58d 100644 --- a/examples/nrf52840/Cargo.toml +++ b/examples/nrf52840/Cargo.toml @@ -21,10 +21,6 @@ nightly = [ "embedded-io-async", "embedded-hal-bus/async", "embassy-net", - "embassy-lora", - "lora-phy", - "lorawan-device", - "lorawan", ] [dependencies] @@ -37,10 +33,6 @@ embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defm embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"], optional = true } embedded-io = { version = "0.6.0", features = ["defmt-03"] } embedded-io-async = { version = "0.6.0", optional = true, features = ["defmt-03"] } -embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["time", "defmt"], optional = true } -lora-phy = { version = "2", optional = true } -lorawan-device = { version = "0.11.0", default-features = false, features = ["async", "external-lora-phy"], optional = true } -lorawan = { version = "0.7.4", default-features = false, features = ["default-crypto"], optional = true } embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"], optional = true } embassy-net-enc28j60 = { version = "0.1.0", path = "../../embassy-net-enc28j60", features = ["defmt"], optional = true } diff --git a/examples/nrf52840/src/bin/lora_cad.rs b/examples/nrf52840/src/bin/lora_cad.rs deleted file mode 100644 index 38e6d619..00000000 --- a/examples/nrf52840/src/bin/lora_cad.rs +++ /dev/null @@ -1,97 +0,0 @@ -//! This example runs on the RAK4631 WisBlock, which has an nRF52840 MCU and Semtech Sx126x radio. -//! Other nrf/sx126x combinations may work with appropriate pin modifications. -//! It demonstrates LORA CAD functionality. -#![no_std] -#![no_main] -#![macro_use] -#![feature(type_alias_impl_trait)] - -use defmt::*; -use embassy_executor::Spawner; -use embassy_lora::iv::GenericSx126xInterfaceVariant; -use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull}; -use embassy_nrf::{bind_interrupts, peripherals, spim}; -use embassy_time::{Delay, Timer}; -use lora_phy::mod_params::*; -use lora_phy::sx1261_2::SX1261_2; -use lora_phy::LoRa; -use {defmt_rtt as _, panic_probe as _}; - -const LORA_FREQUENCY_IN_HZ: u32 = 903_900_000; // warning: set this appropriately for the region - -bind_interrupts!(struct Irqs { - SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1 => spim::InterruptHandler; -}); - -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let p = embassy_nrf::init(Default::default()); - let mut spi_config = spim::Config::default(); - spi_config.frequency = spim::Frequency::M16; - - let spim = spim::Spim::new(p.TWISPI1, Irqs, p.P1_11, p.P1_13, p.P1_12, spi_config); - - let nss = Output::new(p.P1_10.degrade(), Level::High, OutputDrive::Standard); - let reset = Output::new(p.P1_06.degrade(), Level::High, OutputDrive::Standard); - let dio1 = Input::new(p.P1_15.degrade(), Pull::Down); - let busy = Input::new(p.P1_14.degrade(), Pull::Down); - let rf_switch_rx = Output::new(p.P1_05.degrade(), Level::Low, OutputDrive::Standard); - let rf_switch_tx = Output::new(p.P1_07.degrade(), Level::Low, OutputDrive::Standard); - - let iv = - GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); - - let mut lora = { - match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, Delay).await { - Ok(l) => l, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let mut debug_indicator = Output::new(p.P1_03, Level::Low, OutputDrive::Standard); - let mut start_indicator = Output::new(p.P1_04, Level::Low, OutputDrive::Standard); - - start_indicator.set_high(); - Timer::after_secs(5).await; - start_indicator.set_low(); - - let mdltn_params = { - match lora.create_modulation_params( - SpreadingFactor::_10, - Bandwidth::_250KHz, - CodingRate::_4_8, - LORA_FREQUENCY_IN_HZ, - ) { - Ok(mp) => mp, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - match lora.prepare_for_cad(&mdltn_params, true).await { - Ok(()) => {} - Err(err) => { - info!("Radio error = {}", err); - return; - } - }; - - match lora.cad().await { - Ok(cad_activity_detected) => { - if cad_activity_detected { - info!("cad successful with activity detected") - } else { - info!("cad successful without activity detected") - } - debug_indicator.set_high(); - Timer::after_secs(5).await; - debug_indicator.set_low(); - } - Err(err) => info!("cad unsuccessful = {}", err), - } -} diff --git a/examples/nrf52840/src/bin/lora_lorawan.rs b/examples/nrf52840/src/bin/lora_lorawan.rs deleted file mode 100644 index 666330ba..00000000 --- a/examples/nrf52840/src/bin/lora_lorawan.rs +++ /dev/null @@ -1,82 +0,0 @@ -//! This example runs on the RAK4631 WisBlock, which has an nRF52840 MCU and Semtech Sx126x radio. -//! Other nrf/sx126x combinations may work with appropriate pin modifications. -//! It demonstrates LoRaWAN join functionality. -#![no_std] -#![no_main] -#![macro_use] -#![feature(type_alias_impl_trait)] - -use defmt::*; -use embassy_executor::Spawner; -use embassy_lora::iv::GenericSx126xInterfaceVariant; -use embassy_lora::LoraTimer; -use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull}; -use embassy_nrf::rng::Rng; -use embassy_nrf::{bind_interrupts, peripherals, rng, spim}; -use embassy_time::Delay; -use lora_phy::mod_params::*; -use lora_phy::sx1261_2::SX1261_2; -use lora_phy::LoRa; -use lorawan::default_crypto::DefaultFactory as Crypto; -use lorawan_device::async_device::lora_radio::LoRaRadio; -use lorawan_device::async_device::{region, Device, JoinMode}; -use lorawan_device::{AppEui, AppKey, DevEui}; -use {defmt_rtt as _, panic_probe as _}; - -const LORAWAN_REGION: region::Region = region::Region::EU868; // warning: set this appropriately for the region - -bind_interrupts!(struct Irqs { - SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1 => spim::InterruptHandler; - RNG => rng::InterruptHandler; -}); - -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let p = embassy_nrf::init(Default::default()); - let mut spi_config = spim::Config::default(); - spi_config.frequency = spim::Frequency::M16; - - let spim = spim::Spim::new(p.TWISPI1, Irqs, p.P1_11, p.P1_13, p.P1_12, spi_config); - - let nss = Output::new(p.P1_10.degrade(), Level::High, OutputDrive::Standard); - let reset = Output::new(p.P1_06.degrade(), Level::High, OutputDrive::Standard); - let dio1 = Input::new(p.P1_15.degrade(), Pull::Down); - let busy = Input::new(p.P1_14.degrade(), Pull::Down); - let rf_switch_rx = Output::new(p.P1_05.degrade(), Level::Low, OutputDrive::Standard); - let rf_switch_tx = Output::new(p.P1_07.degrade(), Level::Low, OutputDrive::Standard); - - let iv = - GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); - - let lora = { - match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), true, Delay).await { - Ok(l) => l, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let radio = LoRaRadio::new(lora); - let region: region::Configuration = region::Configuration::new(LORAWAN_REGION); - let mut device: Device<_, Crypto, _, _> = Device::new(region, radio, LoraTimer::new(), Rng::new(p.RNG, Irqs)); - - defmt::info!("Joining LoRaWAN network"); - - // TODO: Adjust the EUI and Keys according to your network credentials - match device - .join(&JoinMode::OTAA { - deveui: DevEui::from([0, 0, 0, 0, 0, 0, 0, 0]), - appeui: AppEui::from([0, 0, 0, 0, 0, 0, 0, 0]), - appkey: AppKey::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), - }) - .await - { - Ok(()) => defmt::info!("LoRaWAN network joined"), - Err(err) => { - info!("Radio error = {}", err); - return; - } - }; -} diff --git a/examples/nrf52840/src/bin/lora_p2p_receive.rs b/examples/nrf52840/src/bin/lora_p2p_receive.rs deleted file mode 100644 index 4f41e124..00000000 --- a/examples/nrf52840/src/bin/lora_p2p_receive.rs +++ /dev/null @@ -1,119 +0,0 @@ -//! This example runs on the RAK4631 WisBlock, which has an nRF52840 MCU and Semtech Sx126x radio. -//! Other nrf/sx126x combinations may work with appropriate pin modifications. -//! It demonstrates LORA P2P receive functionality in conjunction with the lora_p2p_send example. -#![no_std] -#![no_main] -#![macro_use] -#![feature(type_alias_impl_trait)] - -use defmt::*; -use embassy_executor::Spawner; -use embassy_lora::iv::GenericSx126xInterfaceVariant; -use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull}; -use embassy_nrf::{bind_interrupts, peripherals, spim}; -use embassy_time::{Delay, Timer}; -use lora_phy::mod_params::*; -use lora_phy::sx1261_2::SX1261_2; -use lora_phy::LoRa; -use {defmt_rtt as _, panic_probe as _}; - -const LORA_FREQUENCY_IN_HZ: u32 = 903_900_000; // warning: set this appropriately for the region - -bind_interrupts!(struct Irqs { - SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1 => spim::InterruptHandler; -}); - -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let p = embassy_nrf::init(Default::default()); - let mut spi_config = spim::Config::default(); - spi_config.frequency = spim::Frequency::M16; - - let spim = spim::Spim::new(p.TWISPI1, Irqs, p.P1_11, p.P1_13, p.P1_12, spi_config); - - let nss = Output::new(p.P1_10.degrade(), Level::High, OutputDrive::Standard); - let reset = Output::new(p.P1_06.degrade(), Level::High, OutputDrive::Standard); - let dio1 = Input::new(p.P1_15.degrade(), Pull::Down); - let busy = Input::new(p.P1_14.degrade(), Pull::Down); - let rf_switch_rx = Output::new(p.P1_05.degrade(), Level::Low, OutputDrive::Standard); - let rf_switch_tx = Output::new(p.P1_07.degrade(), Level::Low, OutputDrive::Standard); - - let iv = - GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); - - let mut lora = { - match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, Delay).await { - Ok(l) => l, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let mut debug_indicator = Output::new(p.P1_03, Level::Low, OutputDrive::Standard); - let mut start_indicator = Output::new(p.P1_04, Level::Low, OutputDrive::Standard); - - start_indicator.set_high(); - Timer::after_secs(5).await; - start_indicator.set_low(); - - let mut receiving_buffer = [00u8; 100]; - - let mdltn_params = { - match lora.create_modulation_params( - SpreadingFactor::_10, - Bandwidth::_250KHz, - CodingRate::_4_8, - LORA_FREQUENCY_IN_HZ, - ) { - Ok(mp) => mp, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let rx_pkt_params = { - match lora.create_rx_packet_params(4, false, receiving_buffer.len() as u8, true, false, &mdltn_params) { - Ok(pp) => pp, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - match lora - .prepare_for_rx(&mdltn_params, &rx_pkt_params, None, None, false) - .await - { - Ok(()) => {} - Err(err) => { - info!("Radio error = {}", err); - return; - } - }; - - loop { - receiving_buffer = [00u8; 100]; - match lora.rx(&rx_pkt_params, &mut receiving_buffer).await { - Ok((received_len, _rx_pkt_status)) => { - if (received_len == 3) - && (receiving_buffer[0] == 0x01u8) - && (receiving_buffer[1] == 0x02u8) - && (receiving_buffer[2] == 0x03u8) - { - info!("rx successful"); - debug_indicator.set_high(); - Timer::after_secs(5).await; - debug_indicator.set_low(); - } else { - info!("rx unknown packet"); - } - } - Err(err) => info!("rx unsuccessful = {}", err), - } - } -} diff --git a/examples/nrf52840/src/bin/lora_p2p_receive_duty_cycle.rs b/examples/nrf52840/src/bin/lora_p2p_receive_duty_cycle.rs deleted file mode 100644 index 3d34f6ae..00000000 --- a/examples/nrf52840/src/bin/lora_p2p_receive_duty_cycle.rs +++ /dev/null @@ -1,127 +0,0 @@ -//! This example runs on the RAK4631 WisBlock, which has an nRF52840 MCU and Semtech Sx126x radio. -//! Other nrf/sx126x combinations may work with appropriate pin modifications. -//! It demonstrates LoRa Rx duty cycle functionality in conjunction with the lora_p2p_send example. -#![no_std] -#![no_main] -#![macro_use] -#![feature(type_alias_impl_trait)] - -use defmt::*; -use embassy_executor::Spawner; -use embassy_lora::iv::GenericSx126xInterfaceVariant; -use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull}; -use embassy_nrf::{bind_interrupts, peripherals, spim}; -use embassy_time::{Delay, Timer}; -use lora_phy::mod_params::*; -use lora_phy::sx1261_2::SX1261_2; -use lora_phy::LoRa; -use {defmt_rtt as _, panic_probe as _}; - -const LORA_FREQUENCY_IN_HZ: u32 = 903_900_000; // warning: set this appropriately for the region - -bind_interrupts!(struct Irqs { - SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1 => spim::InterruptHandler; -}); - -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let p = embassy_nrf::init(Default::default()); - let mut spi_config = spim::Config::default(); - spi_config.frequency = spim::Frequency::M16; - - let spim = spim::Spim::new(p.TWISPI1, Irqs, p.P1_11, p.P1_13, p.P1_12, spi_config); - - let nss = Output::new(p.P1_10.degrade(), Level::High, OutputDrive::Standard); - let reset = Output::new(p.P1_06.degrade(), Level::High, OutputDrive::Standard); - let dio1 = Input::new(p.P1_15.degrade(), Pull::Down); - let busy = Input::new(p.P1_14.degrade(), Pull::Down); - let rf_switch_rx = Output::new(p.P1_05.degrade(), Level::Low, OutputDrive::Standard); - let rf_switch_tx = Output::new(p.P1_07.degrade(), Level::Low, OutputDrive::Standard); - - let iv = - GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); - - let mut lora = { - match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, Delay).await { - Ok(l) => l, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let mut debug_indicator = Output::new(p.P1_03, Level::Low, OutputDrive::Standard); - let mut start_indicator = Output::new(p.P1_04, Level::Low, OutputDrive::Standard); - - start_indicator.set_high(); - Timer::after_secs(5).await; - start_indicator.set_low(); - - let mut receiving_buffer = [00u8; 100]; - - let mdltn_params = { - match lora.create_modulation_params( - SpreadingFactor::_10, - Bandwidth::_250KHz, - CodingRate::_4_8, - LORA_FREQUENCY_IN_HZ, - ) { - Ok(mp) => mp, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let rx_pkt_params = { - match lora.create_rx_packet_params(4, false, receiving_buffer.len() as u8, true, false, &mdltn_params) { - Ok(pp) => pp, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - // See "RM0453 Reference manual STM32WL5x advanced Arm®-based 32-bit MCUs with sub-GHz radio solution" for the best explanation of Rx duty cycle processing. - match lora - .prepare_for_rx( - &mdltn_params, - &rx_pkt_params, - None, - Some(&DutyCycleParams { - rx_time: 300_000, // 300_000 units * 15.625 us/unit = 4.69 s - sleep_time: 200_000, // 200_000 units * 15.625 us/unit = 3.13 s - }), - false, - ) - .await - { - Ok(()) => {} - Err(err) => { - info!("Radio error = {}", err); - return; - } - }; - - receiving_buffer = [00u8; 100]; - match lora.rx(&rx_pkt_params, &mut receiving_buffer).await { - Ok((received_len, _rx_pkt_status)) => { - if (received_len == 3) - && (receiving_buffer[0] == 0x01u8) - && (receiving_buffer[1] == 0x02u8) - && (receiving_buffer[2] == 0x03u8) - { - info!("rx successful"); - debug_indicator.set_high(); - Timer::after_secs(5).await; - debug_indicator.set_low(); - } else { - info!("rx unknown packet") - } - } - Err(err) => info!("rx unsuccessful = {}", err), - } -} diff --git a/examples/nrf52840/src/bin/lora_p2p_send.rs b/examples/nrf52840/src/bin/lora_p2p_send.rs deleted file mode 100644 index 676221a2..00000000 --- a/examples/nrf52840/src/bin/lora_p2p_send.rs +++ /dev/null @@ -1,102 +0,0 @@ -//! This example runs on the RAK4631 WisBlock, which has an nRF52840 MCU and Semtech Sx126x radio. -//! Other nrf/sx126x combinations may work with appropriate pin modifications. -//! It demonstrates LORA P2P send functionality. -#![no_std] -#![no_main] -#![macro_use] -#![feature(type_alias_impl_trait)] - -use defmt::*; -use embassy_executor::Spawner; -use embassy_lora::iv::GenericSx126xInterfaceVariant; -use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull}; -use embassy_nrf::{bind_interrupts, peripherals, spim}; -use embassy_time::Delay; -use lora_phy::mod_params::*; -use lora_phy::sx1261_2::SX1261_2; -use lora_phy::LoRa; -use {defmt_rtt as _, panic_probe as _}; - -const LORA_FREQUENCY_IN_HZ: u32 = 903_900_000; // warning: set this appropriately for the region - -bind_interrupts!(struct Irqs { - SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1 => spim::InterruptHandler; -}); - -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let p = embassy_nrf::init(Default::default()); - let mut spi_config = spim::Config::default(); - spi_config.frequency = spim::Frequency::M16; - - let spim = spim::Spim::new(p.TWISPI1, Irqs, p.P1_11, p.P1_13, p.P1_12, spi_config); - - let nss = Output::new(p.P1_10.degrade(), Level::High, OutputDrive::Standard); - let reset = Output::new(p.P1_06.degrade(), Level::High, OutputDrive::Standard); - let dio1 = Input::new(p.P1_15.degrade(), Pull::Down); - let busy = Input::new(p.P1_14.degrade(), Pull::Down); - let rf_switch_rx = Output::new(p.P1_05.degrade(), Level::Low, OutputDrive::Standard); - let rf_switch_tx = Output::new(p.P1_07.degrade(), Level::Low, OutputDrive::Standard); - - let iv = - GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); - - let mut lora = { - match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, Delay).await { - Ok(l) => l, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let mdltn_params = { - match lora.create_modulation_params( - SpreadingFactor::_10, - Bandwidth::_250KHz, - CodingRate::_4_8, - LORA_FREQUENCY_IN_HZ, - ) { - Ok(mp) => mp, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let mut tx_pkt_params = { - match lora.create_tx_packet_params(4, false, true, false, &mdltn_params) { - Ok(pp) => pp, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - match lora.prepare_for_tx(&mdltn_params, 20, false).await { - Ok(()) => {} - Err(err) => { - info!("Radio error = {}", err); - return; - } - }; - - let buffer = [0x01u8, 0x02u8, 0x03u8]; - match lora.tx(&mdltn_params, &mut tx_pkt_params, &buffer, 0xffffff).await { - Ok(()) => { - info!("TX DONE"); - } - Err(err) => { - info!("Radio error = {}", err); - return; - } - }; - - match lora.sleep(false).await { - Ok(()) => info!("Sleep successful"), - Err(err) => info!("Sleep unsuccessful = {}", err), - } -} diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index 7e752bad..1012a8b5 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml @@ -16,10 +16,6 @@ embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defm embassy-net-wiznet = { version = "0.1.0", path = "../../embassy-net-wiznet", features = ["defmt"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-usb-logger = { version = "0.1.0", path = "../../embassy-usb-logger" } -embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["time", "defmt"] } -lora-phy = { version = "2" } -lorawan-device = { version = "0.11.0", default-features = false, features = ["async", "external-lora-phy"] } -lorawan = { version = "0.7.4", default-features = false, features = ["default-crypto"] } cyw43 = { path = "../../cyw43", features = ["defmt", "firmware-logs"] } cyw43-pio = { path = "../../cyw43-pio", features = ["defmt", "overclock"] } diff --git a/examples/rp/src/bin/lora_lorawan.rs b/examples/rp/src/bin/lora_lorawan.rs deleted file mode 100644 index e7e81863..00000000 --- a/examples/rp/src/bin/lora_lorawan.rs +++ /dev/null @@ -1,74 +0,0 @@ -//! This example runs on the Raspberry Pi Pico with a Waveshare board containing a Semtech Sx1262 radio. -//! It demonstrates LoRaWAN join functionality. - -#![no_std] -#![no_main] -#![macro_use] -#![feature(type_alias_impl_trait)] - -use defmt::*; -use embassy_executor::Spawner; -use embassy_lora::iv::GenericSx126xInterfaceVariant; -use embassy_lora::LoraTimer; -use embassy_rp::gpio::{Input, Level, Output, Pin, Pull}; -use embassy_rp::spi::{Config, Spi}; -use embassy_time::Delay; -use lora_phy::mod_params::*; -use lora_phy::sx1261_2::SX1261_2; -use lora_phy::LoRa; -use lorawan::default_crypto::DefaultFactory as Crypto; -use lorawan_device::async_device::lora_radio::LoRaRadio; -use lorawan_device::async_device::{region, Device, JoinMode}; -use lorawan_device::{AppEui, AppKey, DevEui}; -use {defmt_rtt as _, panic_probe as _}; - -const LORAWAN_REGION: region::Region = region::Region::EU868; // warning: set this appropriately for the region - -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let p = embassy_rp::init(Default::default()); - - let miso = p.PIN_12; - let mosi = p.PIN_11; - let clk = p.PIN_10; - let spi = Spi::new(p.SPI1, clk, mosi, miso, p.DMA_CH0, p.DMA_CH1, Config::default()); - - let nss = Output::new(p.PIN_3.degrade(), Level::High); - let reset = Output::new(p.PIN_15.degrade(), Level::High); - let dio1 = Input::new(p.PIN_20.degrade(), Pull::None); - let busy = Input::new(p.PIN_2.degrade(), Pull::None); - - let iv = GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, None, None).unwrap(); - - let lora = { - match LoRa::new(SX1261_2::new(BoardType::RpPicoWaveshareSx1262, spi, iv), true, Delay).await { - Ok(l) => l, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let radio = LoRaRadio::new(lora); - let region: region::Configuration = region::Configuration::new(LORAWAN_REGION); - let mut device: Device<_, Crypto, _, _> = Device::new(region, radio, LoraTimer::new(), embassy_rp::clocks::RoscRng); - - defmt::info!("Joining LoRaWAN network"); - - // TODO: Adjust the EUI and Keys according to your network credentials - match device - .join(&JoinMode::OTAA { - deveui: DevEui::from([0, 0, 0, 0, 0, 0, 0, 0]), - appeui: AppEui::from([0, 0, 0, 0, 0, 0, 0, 0]), - appkey: AppKey::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), - }) - .await - { - Ok(()) => defmt::info!("LoRaWAN network joined"), - Err(err) => { - info!("Radio error = {}", err); - return; - } - }; -} diff --git a/examples/rp/src/bin/lora_p2p_receive.rs b/examples/rp/src/bin/lora_p2p_receive.rs deleted file mode 100644 index d5843fdc..00000000 --- a/examples/rp/src/bin/lora_p2p_receive.rs +++ /dev/null @@ -1,108 +0,0 @@ -//! This example runs on the Raspberry Pi Pico with a Waveshare board containing a Semtech Sx1262 radio. -//! It demonstrates LORA P2P receive functionality in conjunction with the lora_p2p_send example. - -#![no_std] -#![no_main] -#![macro_use] -#![feature(type_alias_impl_trait)] - -use defmt::*; -use embassy_executor::Spawner; -use embassy_lora::iv::GenericSx126xInterfaceVariant; -use embassy_rp::gpio::{Input, Level, Output, Pin, Pull}; -use embassy_rp::spi::{Config, Spi}; -use embassy_time::{Delay, Timer}; -use lora_phy::mod_params::*; -use lora_phy::sx1261_2::SX1261_2; -use lora_phy::LoRa; -use {defmt_rtt as _, panic_probe as _}; - -const LORA_FREQUENCY_IN_HZ: u32 = 903_900_000; // warning: set this appropriately for the region - -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let p = embassy_rp::init(Default::default()); - - let miso = p.PIN_12; - let mosi = p.PIN_11; - let clk = p.PIN_10; - let spi = Spi::new(p.SPI1, clk, mosi, miso, p.DMA_CH0, p.DMA_CH1, Config::default()); - - let nss = Output::new(p.PIN_3.degrade(), Level::High); - let reset = Output::new(p.PIN_15.degrade(), Level::High); - let dio1 = Input::new(p.PIN_20.degrade(), Pull::None); - let busy = Input::new(p.PIN_2.degrade(), Pull::None); - - let iv = GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, None, None).unwrap(); - - let mut lora = { - match LoRa::new(SX1261_2::new(BoardType::RpPicoWaveshareSx1262, spi, iv), false, Delay).await { - Ok(l) => l, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let mut debug_indicator = Output::new(p.PIN_25, Level::Low); - - let mut receiving_buffer = [00u8; 100]; - - let mdltn_params = { - match lora.create_modulation_params( - SpreadingFactor::_10, - Bandwidth::_250KHz, - CodingRate::_4_8, - LORA_FREQUENCY_IN_HZ, - ) { - Ok(mp) => mp, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let rx_pkt_params = { - match lora.create_rx_packet_params(4, false, receiving_buffer.len() as u8, true, false, &mdltn_params) { - Ok(pp) => pp, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - match lora - .prepare_for_rx(&mdltn_params, &rx_pkt_params, None, None, false) - .await - { - Ok(()) => {} - Err(err) => { - info!("Radio error = {}", err); - return; - } - }; - - loop { - receiving_buffer = [00u8; 100]; - match lora.rx(&rx_pkt_params, &mut receiving_buffer).await { - Ok((received_len, _rx_pkt_status)) => { - if (received_len == 3) - && (receiving_buffer[0] == 0x01u8) - && (receiving_buffer[1] == 0x02u8) - && (receiving_buffer[2] == 0x03u8) - { - info!("rx successful"); - debug_indicator.set_high(); - Timer::after_secs(5).await; - debug_indicator.set_low(); - } else { - info!("rx unknown packet"); - } - } - Err(err) => info!("rx unsuccessful = {}", err), - } - } -} diff --git a/examples/rp/src/bin/lora_p2p_send.rs b/examples/rp/src/bin/lora_p2p_send.rs deleted file mode 100644 index 94bdb4e9..00000000 --- a/examples/rp/src/bin/lora_p2p_send.rs +++ /dev/null @@ -1,96 +0,0 @@ -//! This example runs on the Raspberry Pi Pico with a Waveshare board containing a Semtech Sx1262 radio. -//! It demonstrates LORA P2P send functionality. - -#![no_std] -#![no_main] -#![macro_use] -#![feature(type_alias_impl_trait)] - -use defmt::*; -use embassy_executor::Spawner; -use embassy_lora::iv::GenericSx126xInterfaceVariant; -use embassy_rp::gpio::{Input, Level, Output, Pin, Pull}; -use embassy_rp::spi::{Config, Spi}; -use embassy_time::Delay; -use lora_phy::mod_params::*; -use lora_phy::sx1261_2::SX1261_2; -use lora_phy::LoRa; -use {defmt_rtt as _, panic_probe as _}; - -const LORA_FREQUENCY_IN_HZ: u32 = 903_900_000; // warning: set this appropriately for the region - -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let p = embassy_rp::init(Default::default()); - - let miso = p.PIN_12; - let mosi = p.PIN_11; - let clk = p.PIN_10; - let spi = Spi::new(p.SPI1, clk, mosi, miso, p.DMA_CH0, p.DMA_CH1, Config::default()); - - let nss = Output::new(p.PIN_3.degrade(), Level::High); - let reset = Output::new(p.PIN_15.degrade(), Level::High); - let dio1 = Input::new(p.PIN_20.degrade(), Pull::None); - let busy = Input::new(p.PIN_2.degrade(), Pull::None); - - let iv = GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, None, None).unwrap(); - - let mut lora = { - match LoRa::new(SX1261_2::new(BoardType::RpPicoWaveshareSx1262, spi, iv), false, Delay).await { - Ok(l) => l, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let mdltn_params = { - match lora.create_modulation_params( - SpreadingFactor::_10, - Bandwidth::_250KHz, - CodingRate::_4_8, - LORA_FREQUENCY_IN_HZ, - ) { - Ok(mp) => mp, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let mut tx_pkt_params = { - match lora.create_tx_packet_params(4, false, true, false, &mdltn_params) { - Ok(pp) => pp, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - match lora.prepare_for_tx(&mdltn_params, 20, false).await { - Ok(()) => {} - Err(err) => { - info!("Radio error = {}", err); - return; - } - }; - - let buffer = [0x01u8, 0x02u8, 0x03u8]; - match lora.tx(&mdltn_params, &mut tx_pkt_params, &buffer, 0xffffff).await { - Ok(()) => { - info!("TX DONE"); - } - Err(err) => { - info!("Radio error = {}", err); - return; - } - }; - - match lora.sleep(false).await { - Ok(()) => info!("Sleep successful"), - Err(err) => info!("Sleep unsuccessful = {}", err), - } -} diff --git a/examples/rp/src/bin/lora_p2p_send_multicore.rs b/examples/rp/src/bin/lora_p2p_send_multicore.rs deleted file mode 100644 index ccf44987..00000000 --- a/examples/rp/src/bin/lora_p2p_send_multicore.rs +++ /dev/null @@ -1,133 +0,0 @@ -//! This example runs on the Raspberry Pi Pico with a Waveshare board containing a Semtech Sx1262 radio. -//! It demonstrates LORA P2P send functionality using the second core, with data provided by the first core. - -#![no_std] -#![no_main] -#![macro_use] -#![feature(type_alias_impl_trait)] - -use defmt::*; -use embassy_executor::Executor; -use embassy_lora::iv::GenericSx126xInterfaceVariant; -use embassy_rp::gpio::{AnyPin, Input, Level, Output, Pin, Pull}; -use embassy_rp::multicore::{spawn_core1, Stack}; -use embassy_rp::peripherals::SPI1; -use embassy_rp::spi::{Async, Config, Spi}; -use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; -use embassy_sync::channel::Channel; -use embassy_time::{Delay, Timer}; -use lora_phy::mod_params::*; -use lora_phy::sx1261_2::SX1261_2; -use lora_phy::LoRa; -use static_cell::StaticCell; -use {defmt_rtt as _, panic_probe as _}; - -static mut CORE1_STACK: Stack<4096> = Stack::new(); -static EXECUTOR0: StaticCell = StaticCell::new(); -static EXECUTOR1: StaticCell = StaticCell::new(); -static CHANNEL: Channel = Channel::new(); - -const LORA_FREQUENCY_IN_HZ: u32 = 903_900_000; // warning: set this appropriately for the region - -#[cortex_m_rt::entry] -fn main() -> ! { - let p = embassy_rp::init(Default::default()); - - let miso = p.PIN_12; - let mosi = p.PIN_11; - let clk = p.PIN_10; - let spi = Spi::new(p.SPI1, clk, mosi, miso, p.DMA_CH0, p.DMA_CH1, Config::default()); - - let nss = Output::new(p.PIN_3.degrade(), Level::High); - let reset = Output::new(p.PIN_15.degrade(), Level::High); - let dio1 = Input::new(p.PIN_20.degrade(), Pull::None); - let busy = Input::new(p.PIN_2.degrade(), Pull::None); - - let iv = GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, None, None).unwrap(); - - spawn_core1(p.CORE1, unsafe { &mut CORE1_STACK }, move || { - let executor1 = EXECUTOR1.init(Executor::new()); - executor1.run(|spawner| unwrap!(spawner.spawn(core1_task(spi, iv)))); - }); - - let executor0 = EXECUTOR0.init(Executor::new()); - executor0.run(|spawner| unwrap!(spawner.spawn(core0_task()))); -} - -#[embassy_executor::task] -async fn core0_task() { - info!("Hello from core 0"); - loop { - CHANNEL.send([0x01u8, 0x02u8, 0x03u8]).await; - Timer::after_millis(60 * 1000).await; - } -} - -#[embassy_executor::task] -async fn core1_task( - spi: Spi<'static, SPI1, Async>, - iv: GenericSx126xInterfaceVariant, Input<'static, AnyPin>>, -) { - info!("Hello from core 1"); - - let mut lora = { - match LoRa::new(SX1261_2::new(BoardType::RpPicoWaveshareSx1262, spi, iv), false, Delay).await { - Ok(l) => l, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let mdltn_params = { - match lora.create_modulation_params( - SpreadingFactor::_10, - Bandwidth::_250KHz, - CodingRate::_4_8, - LORA_FREQUENCY_IN_HZ, - ) { - Ok(mp) => mp, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let mut tx_pkt_params = { - match lora.create_tx_packet_params(4, false, true, false, &mdltn_params) { - Ok(pp) => pp, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - loop { - let buffer: [u8; 3] = CHANNEL.receive().await; - match lora.prepare_for_tx(&mdltn_params, 20, false).await { - Ok(()) => {} - Err(err) => { - info!("Radio error = {}", err); - return; - } - }; - - match lora.tx(&mdltn_params, &mut tx_pkt_params, &buffer, 0xffffff).await { - Ok(()) => { - info!("TX DONE"); - } - Err(err) => { - info!("Radio error = {}", err); - return; - } - }; - - match lora.sleep(false).await { - Ok(()) => info!("Sleep successful"), - Err(err) => info!("Sleep unsuccessful = {}", err), - } - } -} diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index 2b89ac27..2ba58c3d 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml @@ -6,8 +6,7 @@ license = "MIT OR Apache-2.0" [features] default = ["nightly"] -nightly = ["embassy-stm32/nightly", "embassy-time/nightly", "embassy-time/unstable-traits", "embassy-executor/nightly", - "embassy-lora", "lora-phy", "lorawan-device", "lorawan", "dep:embedded-io-async"] +nightly = ["embassy-stm32/nightly", "embassy-time/nightly", "embassy-time/unstable-traits", "embassy-executor/nightly", "dep:embedded-io-async"] [dependencies] # Change stm32l072cz to your chip name, if necessary. @@ -15,10 +14,6 @@ embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [" embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } -embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["time", "defmt"], optional = true } -lora-phy = { version = "2", optional = true } -lorawan-device = { version = "0.11.0", default-features = false, features = ["async", "external-lora-phy"], optional = true } -lorawan = { version = "0.7.4", default-features = false, features = ["default-crypto"], optional = true } defmt = "0.3" defmt-rtt = "0.4" diff --git a/examples/stm32l0/src/bin/lora_cad.rs b/examples/stm32l0/src/bin/lora_cad.rs deleted file mode 100644 index 8ca9e8b2..00000000 --- a/examples/stm32l0/src/bin/lora_cad.rs +++ /dev/null @@ -1,97 +0,0 @@ -//! This example runs on the STM32 LoRa Discovery board, which has a builtin Semtech Sx1276 radio. -//! It demonstrates LORA P2P CAD functionality. -#![no_std] -#![no_main] -#![macro_use] -#![feature(type_alias_impl_trait)] - -use defmt::*; -use embassy_executor::Spawner; -use embassy_lora::iv::Stm32l0InterfaceVariant; -use embassy_stm32::exti::{Channel, ExtiInput}; -use embassy_stm32::gpio::{Input, Level, Output, Pin, Pull, Speed}; -use embassy_stm32::spi; -use embassy_stm32::time::khz; -use embassy_time::{Delay, Timer}; -use lora_phy::mod_params::*; -use lora_phy::sx1276_7_8_9::SX1276_7_8_9; -use lora_phy::LoRa; -use {defmt_rtt as _, panic_probe as _}; - -const LORA_FREQUENCY_IN_HZ: u32 = 903_900_000; // warning: set this appropriately for the region - -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let mut config = embassy_stm32::Config::default(); - config.rcc.hsi = true; - config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI; - let p = embassy_stm32::init(config); - - let mut spi_config = spi::Config::default(); - spi_config.frequency = khz(200); - - // SPI for sx1276 - let spi = spi::Spi::new(p.SPI1, p.PB3, p.PA7, p.PA6, p.DMA1_CH3, p.DMA1_CH2, spi_config); - - let nss = Output::new(p.PA15.degrade(), Level::High, Speed::Low); - let reset = Output::new(p.PC0.degrade(), Level::High, Speed::Low); - - let irq_pin = Input::new(p.PB4.degrade(), Pull::Up); - let irq = ExtiInput::new(irq_pin, p.EXTI4.degrade()); - - let iv = Stm32l0InterfaceVariant::new(nss, reset, irq, None, None).unwrap(); - - let mut lora = { - match LoRa::new(SX1276_7_8_9::new(BoardType::Stm32l0Sx1276, spi, iv), false, Delay).await { - Ok(l) => l, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let mut debug_indicator = Output::new(p.PB5, Level::Low, Speed::Low); - let mut start_indicator = Output::new(p.PB6, Level::Low, Speed::Low); - - start_indicator.set_high(); - Timer::after_secs(5).await; - start_indicator.set_low(); - - let mdltn_params = { - match lora.create_modulation_params( - SpreadingFactor::_10, - Bandwidth::_250KHz, - CodingRate::_4_8, - LORA_FREQUENCY_IN_HZ, - ) { - Ok(mp) => mp, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - match lora.prepare_for_cad(&mdltn_params, true).await { - Ok(()) => {} - Err(err) => { - info!("Radio error = {}", err); - return; - } - }; - - match lora.cad().await { - Ok(cad_activity_detected) => { - if cad_activity_detected { - info!("cad successful with activity detected") - } else { - info!("cad successful without activity detected") - } - debug_indicator.set_high(); - Timer::after_secs(5).await; - debug_indicator.set_low(); - } - Err(err) => info!("cad unsuccessful = {}", err), - } -} diff --git a/examples/stm32l0/src/bin/lora_lorawan.rs b/examples/stm32l0/src/bin/lora_lorawan.rs deleted file mode 100644 index 4365c4cf..00000000 --- a/examples/stm32l0/src/bin/lora_lorawan.rs +++ /dev/null @@ -1,85 +0,0 @@ -//! This example runs on the STM32 LoRa Discovery board, which has a builtin Semtech Sx1276 radio. -//! It demonstrates LoRaWAN join functionality. -#![no_std] -#![no_main] -#![macro_use] -#![feature(type_alias_impl_trait)] - -use defmt::*; -use embassy_executor::Spawner; -use embassy_lora::iv::Stm32l0InterfaceVariant; -use embassy_lora::LoraTimer; -use embassy_stm32::exti::{Channel, ExtiInput}; -use embassy_stm32::gpio::{Input, Level, Output, Pin, Pull, Speed}; -use embassy_stm32::rng::Rng; -use embassy_stm32::time::khz; -use embassy_stm32::{bind_interrupts, peripherals, rng, spi}; -use embassy_time::Delay; -use lora_phy::mod_params::*; -use lora_phy::sx1276_7_8_9::SX1276_7_8_9; -use lora_phy::LoRa; -use lorawan::default_crypto::DefaultFactory as Crypto; -use lorawan_device::async_device::lora_radio::LoRaRadio; -use lorawan_device::async_device::{region, Device, JoinMode}; -use lorawan_device::{AppEui, AppKey, DevEui}; -use {defmt_rtt as _, panic_probe as _}; - -bind_interrupts!(struct Irqs { - RNG_LPUART1 => rng::InterruptHandler; -}); - -const LORAWAN_REGION: region::Region = region::Region::EU868; // warning: set this appropriately for the region - -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let mut config = embassy_stm32::Config::default(); - config.rcc.hsi = true; - config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI; - let p = embassy_stm32::init(config); - - let mut spi_config = spi::Config::default(); - spi_config.frequency = khz(200); - - // SPI for sx1276 - let spi = spi::Spi::new(p.SPI1, p.PB3, p.PA7, p.PA6, p.DMA1_CH3, p.DMA1_CH2, spi_config); - - let nss = Output::new(p.PA15.degrade(), Level::High, Speed::Low); - let reset = Output::new(p.PC0.degrade(), Level::High, Speed::Low); - - let irq_pin = Input::new(p.PB4.degrade(), Pull::Up); - let irq = ExtiInput::new(irq_pin, p.EXTI4.degrade()); - - let iv = Stm32l0InterfaceVariant::new(nss, reset, irq, None, None).unwrap(); - - let lora = { - match LoRa::new(SX1276_7_8_9::new(BoardType::Stm32l0Sx1276, spi, iv), true, Delay).await { - Ok(l) => l, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let radio = LoRaRadio::new(lora); - let region: region::Configuration = region::Configuration::new(LORAWAN_REGION); - let mut device: Device<_, Crypto, _, _> = Device::new(region, radio, LoraTimer::new(), Rng::new(p.RNG, Irqs)); - - defmt::info!("Joining LoRaWAN network"); - - // TODO: Adjust the EUI and Keys according to your network credentials - match device - .join(&JoinMode::OTAA { - deveui: DevEui::from([0, 0, 0, 0, 0, 0, 0, 0]), - appeui: AppEui::from([0, 0, 0, 0, 0, 0, 0, 0]), - appkey: AppKey::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), - }) - .await - { - Ok(()) => defmt::info!("LoRaWAN network joined"), - Err(err) => { - info!("Radio error = {}", err); - return; - } - }; -} diff --git a/examples/stm32l0/src/bin/lora_p2p_receive.rs b/examples/stm32l0/src/bin/lora_p2p_receive.rs deleted file mode 100644 index 0627ac08..00000000 --- a/examples/stm32l0/src/bin/lora_p2p_receive.rs +++ /dev/null @@ -1,119 +0,0 @@ -//! This example runs on the STM32 LoRa Discovery board, which has a builtin Semtech Sx1276 radio. -//! It demonstrates LORA P2P receive functionality in conjunction with the lora_p2p_send example. -#![no_std] -#![no_main] -#![macro_use] -#![feature(type_alias_impl_trait)] - -use defmt::*; -use embassy_executor::Spawner; -use embassy_lora::iv::Stm32l0InterfaceVariant; -use embassy_stm32::exti::{Channel, ExtiInput}; -use embassy_stm32::gpio::{Input, Level, Output, Pin, Pull, Speed}; -use embassy_stm32::spi; -use embassy_stm32::time::khz; -use embassy_time::{Delay, Timer}; -use lora_phy::mod_params::*; -use lora_phy::sx1276_7_8_9::SX1276_7_8_9; -use lora_phy::LoRa; -use {defmt_rtt as _, panic_probe as _}; - -const LORA_FREQUENCY_IN_HZ: u32 = 903_900_000; // warning: set this appropriately for the region - -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let mut config = embassy_stm32::Config::default(); - config.rcc.hsi = true; - config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI; - let p = embassy_stm32::init(config); - - let mut spi_config = spi::Config::default(); - spi_config.frequency = khz(200); - - // SPI for sx1276 - let spi = spi::Spi::new(p.SPI1, p.PB3, p.PA7, p.PA6, p.DMA1_CH3, p.DMA1_CH2, spi_config); - - let nss = Output::new(p.PA15.degrade(), Level::High, Speed::Low); - let reset = Output::new(p.PC0.degrade(), Level::High, Speed::Low); - - let irq_pin = Input::new(p.PB4.degrade(), Pull::Up); - let irq = ExtiInput::new(irq_pin, p.EXTI4.degrade()); - - let iv = Stm32l0InterfaceVariant::new(nss, reset, irq, None, None).unwrap(); - - let mut lora = { - match LoRa::new(SX1276_7_8_9::new(BoardType::Stm32l0Sx1276, spi, iv), false, Delay).await { - Ok(l) => l, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let mut debug_indicator = Output::new(p.PB5, Level::Low, Speed::Low); - let mut start_indicator = Output::new(p.PB6, Level::Low, Speed::Low); - - start_indicator.set_high(); - Timer::after_secs(5).await; - start_indicator.set_low(); - - let mut receiving_buffer = [00u8; 100]; - - let mdltn_params = { - match lora.create_modulation_params( - SpreadingFactor::_10, - Bandwidth::_250KHz, - CodingRate::_4_8, - LORA_FREQUENCY_IN_HZ, - ) { - Ok(mp) => mp, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let rx_pkt_params = { - match lora.create_rx_packet_params(4, false, receiving_buffer.len() as u8, true, false, &mdltn_params) { - Ok(pp) => pp, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - match lora - .prepare_for_rx(&mdltn_params, &rx_pkt_params, None, None, false) - .await - { - Ok(()) => {} - Err(err) => { - info!("Radio error = {}", err); - return; - } - }; - - loop { - receiving_buffer = [00u8; 100]; - match lora.rx(&rx_pkt_params, &mut receiving_buffer).await { - Ok((received_len, _rx_pkt_status)) => { - if (received_len == 3) - && (receiving_buffer[0] == 0x01u8) - && (receiving_buffer[1] == 0x02u8) - && (receiving_buffer[2] == 0x03u8) - { - info!("rx successful"); - debug_indicator.set_high(); - Timer::after_secs(5).await; - debug_indicator.set_low(); - } else { - info!("rx unknown packet"); - } - } - Err(err) => info!("rx unsuccessful = {}", err), - } - } -} diff --git a/examples/stm32l0/src/bin/lora_p2p_send.rs b/examples/stm32l0/src/bin/lora_p2p_send.rs deleted file mode 100644 index 4f12cadc..00000000 --- a/examples/stm32l0/src/bin/lora_p2p_send.rs +++ /dev/null @@ -1,102 +0,0 @@ -//! This example runs on the STM32 LoRa Discovery board, which has a builtin Semtech Sx1276 radio. -//! It demonstrates LORA P2P send functionality. -#![no_std] -#![no_main] -#![macro_use] -#![feature(type_alias_impl_trait)] - -use defmt::*; -use embassy_executor::Spawner; -use embassy_lora::iv::Stm32l0InterfaceVariant; -use embassy_stm32::exti::{Channel, ExtiInput}; -use embassy_stm32::gpio::{Input, Level, Output, Pin, Pull, Speed}; -use embassy_stm32::spi; -use embassy_stm32::time::khz; -use embassy_time::Delay; -use lora_phy::mod_params::*; -use lora_phy::sx1276_7_8_9::SX1276_7_8_9; -use lora_phy::LoRa; -use {defmt_rtt as _, panic_probe as _}; - -const LORA_FREQUENCY_IN_HZ: u32 = 903_900_000; // warning: set this appropriately for the region - -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let mut config = embassy_stm32::Config::default(); - config.rcc.hsi = true; - config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI; - let p = embassy_stm32::init(config); - - let mut spi_config = spi::Config::default(); - spi_config.frequency = khz(200); - - // SPI for sx1276 - let spi = spi::Spi::new(p.SPI1, p.PB3, p.PA7, p.PA6, p.DMA1_CH3, p.DMA1_CH2, spi_config); - - let nss = Output::new(p.PA15.degrade(), Level::High, Speed::Low); - let reset = Output::new(p.PC0.degrade(), Level::High, Speed::Low); - - let irq_pin = Input::new(p.PB4.degrade(), Pull::Up); - let irq = ExtiInput::new(irq_pin, p.EXTI4.degrade()); - - let iv = Stm32l0InterfaceVariant::new(nss, reset, irq, None, None).unwrap(); - - let mut lora = { - match LoRa::new(SX1276_7_8_9::new(BoardType::Stm32l0Sx1276, spi, iv), false, Delay).await { - Ok(l) => l, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let mdltn_params = { - match lora.create_modulation_params( - SpreadingFactor::_10, - Bandwidth::_250KHz, - CodingRate::_4_8, - LORA_FREQUENCY_IN_HZ, - ) { - Ok(mp) => mp, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let mut tx_pkt_params = { - match lora.create_tx_packet_params(4, false, true, false, &mdltn_params) { - Ok(pp) => pp, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - match lora.prepare_for_tx(&mdltn_params, 17, true).await { - Ok(()) => {} - Err(err) => { - info!("Radio error = {}", err); - return; - } - }; - - let buffer = [0x01u8, 0x02u8, 0x03u8]; - match lora.tx(&mdltn_params, &mut tx_pkt_params, &buffer, 0xffffff).await { - Ok(()) => { - info!("TX DONE"); - } - Err(err) => { - info!("Radio error = {}", err); - return; - } - }; - - match lora.sleep(false).await { - Ok(()) => info!("Sleep successful"), - Err(err) => info!("Sleep unsuccessful = {}", err), - } -} diff --git a/examples/stm32wl/Cargo.toml b/examples/stm32wl/Cargo.toml index 645ca84d..4f608fcf 100644 --- a/examples/stm32wl/Cargo.toml +++ b/examples/stm32wl/Cargo.toml @@ -11,10 +11,6 @@ embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["de embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } -embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["stm32wl", "time", "defmt"] } -lora-phy = { version = "2" } -lorawan-device = { version = "0.11.0", default-features = false, features = ["async", "external-lora-phy"] } -lorawan = { version = "0.7.4", default-features = false, features = ["default-crypto"] } defmt = "0.3" defmt-rtt = "0.4" diff --git a/examples/stm32wl/src/bin/lora_lorawan.rs b/examples/stm32wl/src/bin/lora_lorawan.rs deleted file mode 100644 index 348e3cdc..00000000 --- a/examples/stm32wl/src/bin/lora_lorawan.rs +++ /dev/null @@ -1,95 +0,0 @@ -//! This example runs on a STM32WL board, which has a builtin Semtech Sx1262 radio. -//! It demonstrates LoRaWAN join functionality. -#![no_std] -#![no_main] -#![macro_use] -#![feature(type_alias_impl_trait, async_fn_in_trait)] -#![allow(stable_features, unknown_lints, async_fn_in_trait)] - -use defmt::info; -use embassy_executor::Spawner; -use embassy_lora::iv::{InterruptHandler, Stm32wlInterfaceVariant}; -use embassy_lora::LoraTimer; -use embassy_stm32::gpio::{Level, Output, Pin, Speed}; -use embassy_stm32::rng::{self, Rng}; -use embassy_stm32::spi::Spi; -use embassy_stm32::time::Hertz; -use embassy_stm32::{bind_interrupts, peripherals}; -use embassy_time::Delay; -use lora_phy::mod_params::*; -use lora_phy::sx1261_2::SX1261_2; -use lora_phy::LoRa; -use lorawan::default_crypto::DefaultFactory as Crypto; -use lorawan_device::async_device::lora_radio::LoRaRadio; -use lorawan_device::async_device::{region, Device, JoinMode}; -use lorawan_device::{AppEui, AppKey, DevEui}; -use {defmt_rtt as _, panic_probe as _}; - -const LORAWAN_REGION: region::Region = region::Region::EU868; // warning: set this appropriately for the region - -bind_interrupts!(struct Irqs{ - SUBGHZ_RADIO => InterruptHandler; - RNG => rng::InterruptHandler; -}); - -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let mut config = embassy_stm32::Config::default(); - { - use embassy_stm32::rcc::*; - config.rcc.hse = Some(Hse { - freq: Hertz(32_000_000), - mode: HseMode::Bypass, - prescaler: HsePrescaler::DIV1, - }); - config.rcc.mux = ClockSrc::PLL1_R; - config.rcc.pll = Some(Pll { - source: PllSource::HSE, - prediv: PllPreDiv::DIV2, - mul: PllMul::MUL6, - divp: None, - divq: Some(PllQDiv::DIV2), // PLL1_Q clock (32 / 2 * 6 / 2), used for RNG - divr: Some(PllRDiv::DIV2), // sysclk 48Mhz clock (32 / 2 * 6 / 2) - }); - } - let p = embassy_stm32::init(config); - - let spi = Spi::new_subghz(p.SUBGHZSPI, p.DMA1_CH1, p.DMA1_CH2); - - // Set CTRL1 and CTRL3 for high-power transmission, while CTRL2 acts as an RF switch between tx and rx - let _ctrl1 = Output::new(p.PC4.degrade(), Level::Low, Speed::High); - let ctrl2 = Output::new(p.PC5.degrade(), Level::High, Speed::High); - let _ctrl3 = Output::new(p.PC3.degrade(), Level::High, Speed::High); - let iv = Stm32wlInterfaceVariant::new(Irqs, None, Some(ctrl2)).unwrap(); - - let lora = { - match LoRa::new(SX1261_2::new(BoardType::Stm32wlSx1262, spi, iv), true, Delay).await { - Ok(l) => l, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - let radio = LoRaRadio::new(lora); - let region: region::Configuration = region::Configuration::new(LORAWAN_REGION); - let mut device: Device<_, Crypto, _, _> = Device::new(region, radio, LoraTimer::new(), Rng::new(p.RNG, Irqs)); - - defmt::info!("Joining LoRaWAN network"); - - // TODO: Adjust the EUI and Keys according to your network credentials - match device - .join(&JoinMode::OTAA { - deveui: DevEui::from([0, 0, 0, 0, 0, 0, 0, 0]), - appeui: AppEui::from([0, 0, 0, 0, 0, 0, 0, 0]), - appkey: AppKey::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), - }) - .await - { - Ok(()) => defmt::info!("LoRaWAN network joined"), - Err(err) => { - info!("Radio error = {}", err); - return; - } - }; -} diff --git a/examples/stm32wl/src/bin/lora_p2p_receive.rs b/examples/stm32wl/src/bin/lora_p2p_receive.rs deleted file mode 100644 index c643ddb1..00000000 --- a/examples/stm32wl/src/bin/lora_p2p_receive.rs +++ /dev/null @@ -1,133 +0,0 @@ -//! This example runs on the STM32WL board, which has a builtin Semtech Sx1262 radio. -//! It demonstrates LORA P2P receive functionality in conjunction with the lora_p2p_send example. -#![no_std] -#![no_main] -#![macro_use] -#![feature(type_alias_impl_trait, async_fn_in_trait)] -#![allow(stable_features, unknown_lints, async_fn_in_trait)] - -use defmt::info; -use embassy_executor::Spawner; -use embassy_lora::iv::{InterruptHandler, Stm32wlInterfaceVariant}; -use embassy_stm32::bind_interrupts; -use embassy_stm32::gpio::{Level, Output, Pin, Speed}; -use embassy_stm32::spi::Spi; -use embassy_stm32::time::Hertz; -use embassy_time::{Delay, Timer}; -use lora_phy::mod_params::*; -use lora_phy::sx1261_2::SX1261_2; -use lora_phy::LoRa; -use {defmt_rtt as _, panic_probe as _}; - -const LORA_FREQUENCY_IN_HZ: u32 = 903_900_000; // warning: set this appropriately for the region - -bind_interrupts!(struct Irqs{ - SUBGHZ_RADIO => InterruptHandler; -}); - -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let mut config = embassy_stm32::Config::default(); - { - use embassy_stm32::rcc::*; - config.rcc.hse = Some(Hse { - freq: Hertz(32_000_000), - mode: HseMode::Bypass, - prescaler: HsePrescaler::DIV1, - }); - config.rcc.mux = ClockSrc::PLL1_R; - config.rcc.pll = Some(Pll { - source: PllSource::HSE, - prediv: PllPreDiv::DIV2, - mul: PllMul::MUL6, - divp: None, - divq: Some(PllQDiv::DIV2), // PLL1_Q clock (32 / 2 * 6 / 2), used for RNG - divr: Some(PllRDiv::DIV2), // sysclk 48Mhz clock (32 / 2 * 6 / 2) - }); - } - let p = embassy_stm32::init(config); - - let spi = Spi::new_subghz(p.SUBGHZSPI, p.DMA1_CH1, p.DMA1_CH2); - - // Set CTRL1 and CTRL3 for high-power transmission, while CTRL2 acts as an RF switch between tx and rx - let _ctrl1 = Output::new(p.PC4.degrade(), Level::Low, Speed::High); - let ctrl2 = Output::new(p.PC5.degrade(), Level::High, Speed::High); - let _ctrl3 = Output::new(p.PC3.degrade(), Level::High, Speed::High); - let iv = Stm32wlInterfaceVariant::new(Irqs, None, Some(ctrl2)).unwrap(); - - let mut lora = { - match LoRa::new(SX1261_2::new(BoardType::Stm32wlSx1262, spi, iv), false, Delay).await { - Ok(l) => l, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let mut debug_indicator = Output::new(p.PB9, Level::Low, Speed::Low); - let mut start_indicator = Output::new(p.PB15, Level::Low, Speed::Low); - - start_indicator.set_high(); - Timer::after_secs(5).await; - start_indicator.set_low(); - - let mut receiving_buffer = [00u8; 100]; - - let mdltn_params = { - match lora.create_modulation_params( - SpreadingFactor::_10, - Bandwidth::_250KHz, - CodingRate::_4_8, - LORA_FREQUENCY_IN_HZ, - ) { - Ok(mp) => mp, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let rx_pkt_params = { - match lora.create_rx_packet_params(4, false, receiving_buffer.len() as u8, true, false, &mdltn_params) { - Ok(pp) => pp, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - match lora - .prepare_for_rx(&mdltn_params, &rx_pkt_params, None, None, false) - .await - { - Ok(()) => {} - Err(err) => { - info!("Radio error = {}", err); - return; - } - }; - - loop { - receiving_buffer = [00u8; 100]; - match lora.rx(&rx_pkt_params, &mut receiving_buffer).await { - Ok((received_len, _rx_pkt_status)) => { - if (received_len == 3) - && (receiving_buffer[0] == 0x01u8) - && (receiving_buffer[1] == 0x02u8) - && (receiving_buffer[2] == 0x03u8) - { - info!("rx successful"); - debug_indicator.set_high(); - Timer::after_secs(5).await; - debug_indicator.set_low(); - } else { - info!("rx unknown packet"); - } - } - Err(err) => info!("rx unsuccessful = {}", err), - } - } -} diff --git a/examples/stm32wl/src/bin/lora_p2p_send.rs b/examples/stm32wl/src/bin/lora_p2p_send.rs deleted file mode 100644 index 7fe8cea3..00000000 --- a/examples/stm32wl/src/bin/lora_p2p_send.rs +++ /dev/null @@ -1,116 +0,0 @@ -//! This example runs on a STM32WL board, which has a builtin Semtech Sx1262 radio. -//! It demonstrates LORA P2P send functionality. -#![no_std] -#![no_main] -#![macro_use] -#![feature(type_alias_impl_trait, async_fn_in_trait)] -#![allow(stable_features, unknown_lints, async_fn_in_trait)] - -use defmt::info; -use embassy_executor::Spawner; -use embassy_lora::iv::{InterruptHandler, Stm32wlInterfaceVariant}; -use embassy_stm32::bind_interrupts; -use embassy_stm32::gpio::{Level, Output, Pin, Speed}; -use embassy_stm32::spi::Spi; -use embassy_stm32::time::Hertz; -use embassy_time::Delay; -use lora_phy::mod_params::*; -use lora_phy::sx1261_2::SX1261_2; -use lora_phy::LoRa; -use {defmt_rtt as _, panic_probe as _}; - -const LORA_FREQUENCY_IN_HZ: u32 = 903_900_000; // warning: set this appropriately for the region - -bind_interrupts!(struct Irqs{ - SUBGHZ_RADIO => InterruptHandler; -}); - -#[embassy_executor::main] -async fn main(_spawner: Spawner) { - let mut config = embassy_stm32::Config::default(); - { - use embassy_stm32::rcc::*; - config.rcc.hse = Some(Hse { - freq: Hertz(32_000_000), - mode: HseMode::Bypass, - prescaler: HsePrescaler::DIV1, - }); - config.rcc.mux = ClockSrc::PLL1_R; - config.rcc.pll = Some(Pll { - source: PllSource::HSE, - prediv: PllPreDiv::DIV2, - mul: PllMul::MUL6, - divp: None, - divq: Some(PllQDiv::DIV2), // PLL1_Q clock (32 / 2 * 6 / 2), used for RNG - divr: Some(PllRDiv::DIV2), // sysclk 48Mhz clock (32 / 2 * 6 / 2) - }); - } - let p = embassy_stm32::init(config); - - let spi = Spi::new_subghz(p.SUBGHZSPI, p.DMA1_CH1, p.DMA1_CH2); - - // Set CTRL1 and CTRL3 for high-power transmission, while CTRL2 acts as an RF switch between tx and rx - let _ctrl1 = Output::new(p.PC4.degrade(), Level::Low, Speed::High); - let ctrl2 = Output::new(p.PC5.degrade(), Level::High, Speed::High); - let _ctrl3 = Output::new(p.PC3.degrade(), Level::High, Speed::High); - let iv = Stm32wlInterfaceVariant::new(Irqs, None, Some(ctrl2)).unwrap(); - - let mut lora = { - match LoRa::new(SX1261_2::new(BoardType::Stm32wlSx1262, spi, iv), false, Delay).await { - Ok(l) => l, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let mdltn_params = { - match lora.create_modulation_params( - SpreadingFactor::_10, - Bandwidth::_250KHz, - CodingRate::_4_8, - LORA_FREQUENCY_IN_HZ, - ) { - Ok(mp) => mp, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - let mut tx_pkt_params = { - match lora.create_tx_packet_params(4, false, true, false, &mdltn_params) { - Ok(pp) => pp, - Err(err) => { - info!("Radio error = {}", err); - return; - } - } - }; - - match lora.prepare_for_tx(&mdltn_params, 20, false).await { - Ok(()) => {} - Err(err) => { - info!("Radio error = {}", err); - return; - } - }; - - let buffer = [0x01u8, 0x02u8, 0x03u8]; - match lora.tx(&mdltn_params, &mut tx_pkt_params, &buffer, 0xffffff).await { - Ok(()) => { - info!("TX DONE"); - } - Err(err) => { - info!("Radio error = {}", err); - return; - } - }; - - match lora.sleep(false).await { - Ok(()) => info!("Sleep successful"), - Err(err) => info!("Sleep unsuccessful = {}", err), - } -} From 4634316749c41dd5d8cc2f316033c9098369ed2f Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 29 Nov 2023 16:37:07 +0100 Subject: [PATCH 13/98] Update embedded-(hal,io,nal). --- cyw43/Cargo.toml | 2 +- embassy-embedded-hal/Cargo.toml | 4 ++-- .../src/shared_bus/asynch/spi.rs | 20 +++++++++++++------ .../src/shared_bus/blocking/spi.rs | 20 +++++++++---------- embassy-embedded-hal/src/shared_bus/mod.rs | 6 +++--- embassy-net-adin1110/Cargo.toml | 8 ++++---- embassy-net-adin1110/src/lib.rs | 8 ++++++-- embassy-net-enc28j60/Cargo.toml | 4 ++-- embassy-net-esp-hosted/Cargo.toml | 4 ++-- embassy-net-ppp/Cargo.toml | 2 +- embassy-net-wiznet/Cargo.toml | 4 ++-- embassy-net/Cargo.toml | 4 ++-- embassy-nrf/Cargo.toml | 6 +++--- embassy-rp/Cargo.toml | 8 ++++---- embassy-stm32/Cargo.toml | 8 ++++---- embassy-sync/Cargo.toml | 2 +- embassy-time/CHANGELOG.md | 4 ++-- embassy-time/Cargo.toml | 4 ++-- embassy-time/src/delay.rs | 20 +++++++++++++------ embassy-time/src/duration.rs | 9 +++++++++ embassy-time/src/lib.rs | 1 + embassy-time/src/timer.rs | 9 +++++++++ examples/nrf52840/Cargo.toml | 8 ++++---- examples/nrf5340/Cargo.toml | 2 +- examples/rp/Cargo.toml | 8 ++++---- examples/std/Cargo.toml | 4 ++-- examples/stm32f4/Cargo.toml | 2 +- examples/stm32f7/Cargo.toml | 2 +- examples/stm32h5/Cargo.toml | 8 ++++---- examples/stm32h7/Cargo.toml | 8 ++++---- examples/stm32l0/Cargo.toml | 2 +- examples/stm32l4/Cargo.toml | 8 ++++---- examples/stm32l5/Cargo.toml | 2 +- tests/nrf/Cargo.toml | 6 +++--- tests/rp/Cargo.toml | 8 ++++---- tests/stm32/Cargo.toml | 4 ++-- 36 files changed, 134 insertions(+), 95 deletions(-) diff --git a/cyw43/Cargo.toml b/cyw43/Cargo.toml index 789e3ab0..3e37a8cd 100644 --- a/cyw43/Cargo.toml +++ b/cyw43/Cargo.toml @@ -23,7 +23,7 @@ cortex-m = "0.7.6" cortex-m-rt = "0.7.0" futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] } -embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-rc.1" } +embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-rc.2" } num_enum = { version = "0.5.7", default-features = false } [package.metadata.embassy_docs] diff --git a/embassy-embedded-hal/Cargo.toml b/embassy-embedded-hal/Cargo.toml index 11e47acb..52ecd5c7 100644 --- a/embassy-embedded-hal/Cargo.toml +++ b/embassy-embedded-hal/Cargo.toml @@ -25,8 +25,8 @@ embassy-time = { version = "0.1.5", path = "../embassy-time", optional = true } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = [ "unproven", ] } -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1" } -embedded-hal-async = { version = "=1.0.0-rc.1", optional = true } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } +embedded-hal-async = { version = "=1.0.0-rc.2", optional = true } embedded-storage = "0.3.0" embedded-storage-async = { version = "0.4.0", optional = true } nb = "1.0.0" diff --git a/embassy-embedded-hal/src/shared_bus/asynch/spi.rs b/embassy-embedded-hal/src/shared_bus/asynch/spi.rs index 17d5f367..b4f53c62 100644 --- a/embassy-embedded-hal/src/shared_bus/asynch/spi.rs +++ b/embassy-embedded-hal/src/shared_bus/asynch/spi.rs @@ -63,6 +63,10 @@ where CS: OutputPin, { async fn transaction(&mut self, operations: &mut [spi::Operation<'_, u8>]) -> Result<(), Self::Error> { + if cfg!(not(feature = "time")) && operations.iter().any(|op| matches!(op, Operation::DelayNs(_))) { + return Err(SpiDeviceError::DelayNotSupported); + } + let mut bus = self.bus.lock().await; self.cs.set_low().map_err(SpiDeviceError::Cs)?; @@ -74,12 +78,12 @@ where Operation::Transfer(read, write) => bus.transfer(read, write).await, Operation::TransferInPlace(buf) => bus.transfer_in_place(buf).await, #[cfg(not(feature = "time"))] - Operation::DelayUs(us) => return Err(SpiDeviceError::DelayUsNotSupported), + Operation::DelayNs(_) => unreachable!(), #[cfg(feature = "time")] - Operation::DelayUs(us) => match bus.flush().await { + Operation::DelayNs(ns) => match bus.flush().await { Err(e) => Err(e), Ok(()) => { - embassy_time::Timer::after_micros(*us as _).await; + embassy_time::Timer::after_nanos(*ns as _).await; Ok(()) } }, @@ -137,6 +141,10 @@ where CS: OutputPin, { async fn transaction(&mut self, operations: &mut [spi::Operation<'_, u8>]) -> Result<(), Self::Error> { + if cfg!(not(feature = "time")) && operations.iter().any(|op| matches!(op, Operation::DelayNs(_))) { + return Err(SpiDeviceError::DelayNotSupported); + } + let mut bus = self.bus.lock().await; bus.set_config(&self.config).map_err(|_| SpiDeviceError::Config)?; self.cs.set_low().map_err(SpiDeviceError::Cs)?; @@ -149,12 +157,12 @@ where Operation::Transfer(read, write) => bus.transfer(read, write).await, Operation::TransferInPlace(buf) => bus.transfer_in_place(buf).await, #[cfg(not(feature = "time"))] - Operation::DelayUs(us) => return Err(SpiDeviceError::DelayUsNotSupported), + Operation::DelayNs(_) => unreachable!(), #[cfg(feature = "time")] - Operation::DelayUs(us) => match bus.flush().await { + Operation::DelayNs(ns) => match bus.flush().await { Err(e) => Err(e), Ok(()) => { - embassy_time::Timer::after_micros(*us as _).await; + embassy_time::Timer::after_nanos(*ns as _).await; Ok(()) } }, diff --git a/embassy-embedded-hal/src/shared_bus/blocking/spi.rs b/embassy-embedded-hal/src/shared_bus/blocking/spi.rs index 2b67862e..59b65bfb 100644 --- a/embassy-embedded-hal/src/shared_bus/blocking/spi.rs +++ b/embassy-embedded-hal/src/shared_bus/blocking/spi.rs @@ -55,8 +55,8 @@ where CS: OutputPin, { fn transaction(&mut self, operations: &mut [Operation<'_, u8>]) -> Result<(), Self::Error> { - if cfg!(not(feature = "time")) && operations.iter().any(|op| matches!(op, Operation::DelayUs(_))) { - return Err(SpiDeviceError::DelayUsNotSupported); + if cfg!(not(feature = "time")) && operations.iter().any(|op| matches!(op, Operation::DelayNs(_))) { + return Err(SpiDeviceError::DelayNotSupported); } self.bus.lock(|bus| { @@ -69,10 +69,10 @@ where Operation::Transfer(read, write) => bus.transfer(read, write), Operation::TransferInPlace(buf) => bus.transfer_in_place(buf), #[cfg(not(feature = "time"))] - Operation::DelayUs(_) => unreachable!(), + Operation::DelayNs(_) => unreachable!(), #[cfg(feature = "time")] - Operation::DelayUs(us) => { - embassy_time::block_for(embassy_time::Duration::from_micros(*us as _)); + Operation::DelayNs(ns) => { + embassy_time::block_for(embassy_time::Duration::from_nanos(*ns as _)); Ok(()) } }); @@ -165,8 +165,8 @@ where CS: OutputPin, { fn transaction(&mut self, operations: &mut [Operation<'_, u8>]) -> Result<(), Self::Error> { - if cfg!(not(feature = "time")) && operations.iter().any(|op| matches!(op, Operation::DelayUs(_))) { - return Err(SpiDeviceError::DelayUsNotSupported); + if cfg!(not(feature = "time")) && operations.iter().any(|op| matches!(op, Operation::DelayNs(_))) { + return Err(SpiDeviceError::DelayNotSupported); } self.bus.lock(|bus| { @@ -180,10 +180,10 @@ where Operation::Transfer(read, write) => bus.transfer(read, write), Operation::TransferInPlace(buf) => bus.transfer_in_place(buf), #[cfg(not(feature = "time"))] - Operation::DelayUs(_) => unreachable!(), + Operation::DelayNs(_) => unreachable!(), #[cfg(feature = "time")] - Operation::DelayUs(us) => { - embassy_time::block_for(embassy_time::Duration::from_micros(*us as _)); + Operation::DelayNs(ns) => { + embassy_time::block_for(embassy_time::Duration::from_nanos(*ns as _)); Ok(()) } }); diff --git a/embassy-embedded-hal/src/shared_bus/mod.rs b/embassy-embedded-hal/src/shared_bus/mod.rs index b0159ac0..ab96df13 100644 --- a/embassy-embedded-hal/src/shared_bus/mod.rs +++ b/embassy-embedded-hal/src/shared_bus/mod.rs @@ -39,8 +39,8 @@ pub enum SpiDeviceError { Spi(BUS), /// Setting the value of the Chip Select (CS) pin failed. Cs(CS), - /// DelayUs operations are not supported when the `time` Cargo feature is not enabled. - DelayUsNotSupported, + /// Delay operations are not supported when the `time` Cargo feature is not enabled. + DelayNotSupported, /// The SPI bus could not be configured. Config, } @@ -54,7 +54,7 @@ where match self { Self::Spi(e) => e.kind(), Self::Cs(_) => spi::ErrorKind::Other, - Self::DelayUsNotSupported => spi::ErrorKind::Other, + Self::DelayNotSupported => spi::ErrorKind::Other, Self::Config => spi::ErrorKind::Other, } } diff --git a/embassy-net-adin1110/Cargo.toml b/embassy-net-adin1110/Cargo.toml index 3f016160..3dbbee44 100644 --- a/embassy-net-adin1110/Cargo.toml +++ b/embassy-net-adin1110/Cargo.toml @@ -13,16 +13,16 @@ edition = "2021" heapless = "0.8" defmt = { version = "0.3", optional = true } log = { version = "0.4", default-features = false, optional = true } -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1" } -embedded-hal-async = { version = "=1.0.0-rc.1" } -embedded-hal-bus = { version = "=0.1.0-rc.1", features = ["async"] } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } +embedded-hal-async = { version = "=1.0.0-rc.2" } +embedded-hal-bus = { version = "=0.1.0-rc.2", features = ["async"] } embassy-net-driver-channel = { version = "0.2.0", path = "../embassy-net-driver-channel" } embassy-time = { version = "0.1.5", path = "../embassy-time" } embassy-futures = { version = "0.1.0", path = "../embassy-futures" } bitfield = "0.14.0" [dev-dependencies] -embedded-hal-mock = { version = "=0.10.0-rc.1", features = ["embedded-hal-async", "eh1"] } +embedded-hal-mock = { git = "https://github.com/Dirbaio/embedded-hal-mock", rev = "c5c4dca18e043e6386aee02173f61a65fea3981e", features = ["embedded-hal-async", "eh1"] } crc = "3.0.1" env_logger = "0.10" critical-section = { version = "1.1.2", features = ["std"] } diff --git a/embassy-net-adin1110/src/lib.rs b/embassy-net-adin1110/src/lib.rs index 331c596d..e4a3cb20 100644 --- a/embassy-net-adin1110/src/lib.rs +++ b/embassy-net-adin1110/src/lib.rs @@ -729,7 +729,7 @@ mod tests { use core::convert::Infallible; use embedded_hal_1::digital::{ErrorType, OutputPin}; - use embedded_hal_async::delay::DelayUs; + use embedded_hal_async::delay::DelayNs; use embedded_hal_bus::spi::ExclusiveDevice; use embedded_hal_mock::common::Generic; use embedded_hal_mock::eh1::spi::{Mock as SpiMock, Transaction as SpiTransaction}; @@ -760,7 +760,11 @@ mod tests { // see https://github.com/rust-embedded/embedded-hal/pull/462#issuecomment-1560014426 struct MockDelay {} - impl DelayUs for MockDelay { + impl DelayNs for MockDelay { + async fn delay_ns(&mut self, _ns: u32) { + todo!() + } + async fn delay_us(&mut self, _us: u32) { todo!() } diff --git a/embassy-net-enc28j60/Cargo.toml b/embassy-net-enc28j60/Cargo.toml index ea2ed1f7..eda699d9 100644 --- a/embassy-net-enc28j60/Cargo.toml +++ b/embassy-net-enc28j60/Cargo.toml @@ -8,8 +8,8 @@ license = "MIT OR Apache-2.0" edition = "2021" [dependencies] -embedded-hal = { version = "1.0.0-rc.1" } -embedded-hal-async = { version = "=1.0.0-rc.1" } +embedded-hal = { version = "1.0.0-rc.2" } +embedded-hal-async = { version = "=1.0.0-rc.2" } embassy-net-driver = { version = "0.2.0", path = "../embassy-net-driver" } embassy-time = { version = "0.1.5", path = "../embassy-time" } embassy-futures = { version = "0.1.0", path = "../embassy-futures" } diff --git a/embassy-net-esp-hosted/Cargo.toml b/embassy-net-esp-hosted/Cargo.toml index e86be445..6b325c80 100644 --- a/embassy-net-esp-hosted/Cargo.toml +++ b/embassy-net-esp-hosted/Cargo.toml @@ -12,8 +12,8 @@ embassy-sync = { version = "0.4.0", path = "../embassy-sync"} embassy-futures = { version = "0.1.0", path = "../embassy-futures"} embassy-net-driver-channel = { version = "0.2.0", path = "../embassy-net-driver-channel"} -embedded-hal = { version = "1.0.0-rc.1" } -embedded-hal-async = { version = "=1.0.0-rc.1" } +embedded-hal = { version = "1.0.0-rc.2" } +embedded-hal-async = { version = "=1.0.0-rc.2" } noproto = { git="https://github.com/embassy-rs/noproto", rev = "f5e6d1f325b6ad4e344f60452b09576e24671f62", default-features = false, features = ["derive"] } #noproto = { version = "0.1", path = "/home/dirbaio/noproto", default-features = false, features = ["derive"] } diff --git a/embassy-net-ppp/Cargo.toml b/embassy-net-ppp/Cargo.toml index 273dccbc..7119ebd5 100644 --- a/embassy-net-ppp/Cargo.toml +++ b/embassy-net-ppp/Cargo.toml @@ -15,7 +15,7 @@ log = ["dep:log", "ppproto/log"] defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } -embedded-io-async = { version = "0.6.0" } +embedded-io-async = { version = "0.6.1" } embassy-net-driver-channel = { version = "0.2.0", path = "../embassy-net-driver-channel" } embassy-futures = { version = "0.1.0", path = "../embassy-futures" } ppproto = { version = "0.1.2"} diff --git a/embassy-net-wiznet/Cargo.toml b/embassy-net-wiznet/Cargo.toml index 0cc086b7..187f3e29 100644 --- a/embassy-net-wiznet/Cargo.toml +++ b/embassy-net-wiznet/Cargo.toml @@ -8,8 +8,8 @@ license = "MIT OR Apache-2.0" edition = "2021" [dependencies] -embedded-hal = { version = "1.0.0-rc.1" } -embedded-hal-async = { version = "=1.0.0-rc.1" } +embedded-hal = { version = "1.0.0-rc.2" } +embedded-hal-async = { version = "=1.0.0-rc.2" } embassy-net-driver-channel = { version = "0.2.0", path = "../embassy-net-driver-channel" } embassy-time = { version = "0.1.5", path = "../embassy-time" } embassy-futures = { version = "0.1.0", path = "../embassy-futures" } diff --git a/embassy-net/Cargo.toml b/embassy-net/Cargo.toml index ef66078c..fe8344f5 100644 --- a/embassy-net/Cargo.toml +++ b/embassy-net/Cargo.toml @@ -54,7 +54,7 @@ smoltcp = { git = "https://github.com/smoltcp-rs/smoltcp.git", rev = "b57e2f9e70 embassy-net-driver = { version = "0.2.0", path = "../embassy-net-driver" } embassy-time = { version = "0.1.5", path = "../embassy-time" } embassy-sync = { version = "0.4.0", path = "../embassy-sync" } -embedded-io-async = { version = "0.6.0", optional = true } +embedded-io-async = { version = "0.6.1", optional = true } managed = { version = "0.8.0", default-features = false, features = [ "map" ] } heapless = { version = "0.8", default-features = false } @@ -63,4 +63,4 @@ generic-array = { version = "0.14.4", default-features = false } stable_deref_trait = { version = "1.2.0", default-features = false } futures = { version = "0.3.17", default-features = false, features = [ "async-await" ] } atomic-pool = "1.0" -embedded-nal-async = { version = "0.7", optional = true } +embedded-nal-async = { version = "0.7.1", optional = true } diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index 60e03d85..a75a94f0 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml @@ -101,10 +101,10 @@ embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver", optional=true } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1", optional = true} -embedded-hal-async = { version = "=1.0.0-rc.1", optional = true} +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2", optional = true} +embedded-hal-async = { version = "=1.0.0-rc.2", optional = true} embedded-io = { version = "0.6.0" } -embedded-io-async = { version = "0.6.0", optional = true } +embedded-io-async = { version = "0.6.1", optional = true } defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index eb79cfd3..35ea77f0 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml @@ -76,7 +76,7 @@ critical-section = "1.1" futures = { version = "0.3.17", default-features = false, features = ["async-await"] } chrono = { version = "0.4", default-features = false, optional = true } embedded-io = { version = "0.6.0" } -embedded-io-async = { version = "0.6.0", optional = true } +embedded-io-async = { version = "0.6.1", optional = true } embedded-storage = { version = "0.3" } embedded-storage-async = { version = "0.4.0", optional = true } rand_core = "0.6.4" @@ -85,9 +85,9 @@ fixed = "1.23.1" rp-pac = { version = "6" } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1", optional = true} -embedded-hal-async = { version = "=1.0.0-rc.1", optional = true} -embedded-hal-nb = { version = "=1.0.0-rc.1", optional = true} +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2", optional = true} +embedded-hal-async = { version = "=1.0.0-rc.2", optional = true} +embedded-hal-nb = { version = "=1.0.0-rc.2", optional = true} pio-proc = {version= "0.2" } pio = {version= "0.2.1" } diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 292902ac..535357fc 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -42,9 +42,9 @@ embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver", optiona embassy-executor = { version = "0.3.3", path = "../embassy-executor", optional = true } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1", optional = true} -embedded-hal-async = { version = "=1.0.0-rc.1", optional = true} -embedded-hal-nb = { version = "=1.0.0-rc.1", optional = true} +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2", optional = true} +embedded-hal-async = { version = "=1.0.0-rc.2", optional = true} +embedded-hal-nb = { version = "=1.0.0-rc.2", optional = true} embedded-storage = "0.3.0" embedded-storage-async = { version = "0.4.0", optional = true } @@ -65,7 +65,7 @@ nb = "1.0.0" stm32-fmc = "0.3.0" cfg-if = "1.0.0" embedded-io = { version = "0.6.0" } -embedded-io-async = { version = "0.6.0", optional = true } +embedded-io-async = { version = "0.6.1", optional = true } chrono = { version = "^0.4", default-features = false, optional = true} bit_field = "0.10.2" document-features = "0.2.7" diff --git a/embassy-sync/Cargo.toml b/embassy-sync/Cargo.toml index e395389a..ffcd13d9 100644 --- a/embassy-sync/Cargo.toml +++ b/embassy-sync/Cargo.toml @@ -35,7 +35,7 @@ futures-util = { version = "0.3.17", default-features = false } critical-section = "1.1" heapless = "0.8" cfg-if = "1.0.0" -embedded-io-async = { version = "0.6.0", optional = true } +embedded-io-async = { version = "0.6.1", optional = true } [dev-dependencies] futures-executor = { version = "0.3.17", features = [ "thread-pool" ] } diff --git a/embassy-time/CHANGELOG.md b/embassy-time/CHANGELOG.md index 1421d76a..9625b890 100644 --- a/embassy-time/CHANGELOG.md +++ b/embassy-time/CHANGELOG.md @@ -22,8 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## 0.1.3 - 2023-08-28 -- Update `embedded-hal-async` to `1.0.0-rc.1` -- Update `embedded-hal v1` to `1.0.0-rc.1` +- Update `embedded-hal-async` to `1.0.0-rc.2` +- Update `embedded-hal v1` to `1.0.0-rc.2` ## 0.1.2 - 2023-07-05 diff --git a/embassy-time/Cargo.toml b/embassy-time/Cargo.toml index 3cabb237..570e0efa 100644 --- a/embassy-time/Cargo.toml +++ b/embassy-time/Cargo.toml @@ -242,8 +242,8 @@ defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6" } -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1", optional = true} -embedded-hal-async = { version = "=1.0.0-rc.1", optional = true} +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2", optional = true} +embedded-hal-async = { version = "=1.0.0-rc.2", optional = true} futures-util = { version = "0.3.17", default-features = false } critical-section = "1.1" diff --git a/embassy-time/src/delay.rs b/embassy-time/src/delay.rs index be962747..aab56b1f 100644 --- a/embassy-time/src/delay.rs +++ b/embassy-time/src/delay.rs @@ -18,7 +18,11 @@ pub struct Delay; mod eh1 { use super::*; - impl embedded_hal_1::delay::DelayUs for Delay { + impl embedded_hal_1::delay::DelayNs for Delay { + fn delay_ns(&mut self, ns: u32) { + block_for(Duration::from_nanos(ns as u64)) + } + fn delay_us(&mut self, us: u32) { block_for(Duration::from_micros(us as u64)) } @@ -34,13 +38,17 @@ mod eha { use super::*; use crate::Timer; - impl embedded_hal_async::delay::DelayUs for Delay { - async fn delay_us(&mut self, micros: u32) { - Timer::after_micros(micros as _).await + impl embedded_hal_async::delay::DelayNs for Delay { + async fn delay_ns(&mut self, ns: u32) { + Timer::after_nanos(ns as _).await } - async fn delay_ms(&mut self, millis: u32) { - Timer::after_millis(millis as _).await + async fn delay_us(&mut self, us: u32) { + Timer::after_micros(us as _).await + } + + async fn delay_ms(&mut self, ms: u32) { + Timer::after_millis(ms as _).await } } } diff --git a/embassy-time/src/duration.rs b/embassy-time/src/duration.rs index 8366455b..647d208e 100644 --- a/embassy-time/src/duration.rs +++ b/embassy-time/src/duration.rs @@ -2,6 +2,7 @@ use core::fmt; use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}; use super::{GCD_1K, GCD_1M, TICK_HZ}; +use crate::GCD_1G; #[derive(Debug, Default, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] @@ -61,6 +62,14 @@ impl Duration { } } + /// Creates a duration from the specified number of nanoseconds, rounding up. + /// NOTE: Delays this small may be inaccurate. + pub const fn from_nanos(micros: u64) -> Duration { + Duration { + ticks: div_ceil(micros * (TICK_HZ / GCD_1G), 1_000_000_000 / GCD_1G), + } + } + /// Creates a duration from the specified number of seconds, rounding down. pub const fn from_secs_floor(secs: u64) -> Duration { Duration { ticks: secs * TICK_HZ } diff --git a/embassy-time/src/lib.rs b/embassy-time/src/lib.rs index a90368d5..a0f6e382 100644 --- a/embassy-time/src/lib.rs +++ b/embassy-time/src/lib.rs @@ -52,6 +52,7 @@ const fn gcd(a: u64, b: u64) -> u64 { pub(crate) const GCD_1K: u64 = gcd(TICK_HZ, 1_000); pub(crate) const GCD_1M: u64 = gcd(TICK_HZ, 1_000_000); +pub(crate) const GCD_1G: u64 = gcd(TICK_HZ, 1_000_000_000); #[cfg(feature = "defmt-timestamp-uptime")] defmt::timestamp! {"{=u64:us}", Instant::now().as_micros() } diff --git a/embassy-time/src/timer.rs b/embassy-time/src/timer.rs index ee2423da..574d715d 100644 --- a/embassy-time/src/timer.rs +++ b/embassy-time/src/timer.rs @@ -74,6 +74,15 @@ impl Timer { Self::after(Duration::from_ticks(ticks)) } + /// Expire after the specified number of nanoseconds. + /// + /// This method is a convenience wrapper for calling `Timer::after(Duration::from_nanos())`. + /// For more details, refer to [`Timer::after()`] and [`Duration::from_nanos()`]. + #[inline] + pub fn after_nanos(nanos: u64) -> Self { + Self::after(Duration::from_nanos(nanos)) + } + /// Expire after the specified number of microseconds. /// /// This method is a convenience wrapper for calling `Timer::after(Duration::from_micros())`. diff --git a/examples/nrf52840/Cargo.toml b/examples/nrf52840/Cargo.toml index 88e8d58d..d9b22a4d 100644 --- a/examples/nrf52840/Cargo.toml +++ b/examples/nrf52840/Cargo.toml @@ -32,7 +32,7 @@ embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defm embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"], optional = true } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"], optional = true } embedded-io = { version = "0.6.0", features = ["defmt-03"] } -embedded-io-async = { version = "0.6.0", optional = true, features = ["defmt-03"] } +embedded-io-async = { version = "0.6.1", optional = true, features = ["defmt-03"] } embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"], optional = true } embassy-net-enc28j60 = { version = "0.1.0", path = "../../embassy-net-enc28j60", features = ["defmt"], optional = true } @@ -49,9 +49,9 @@ rand = { version = "0.8.4", default-features = false } embedded-storage = "0.3.0" usbd-hid = "0.6.0" serde = { version = "1.0.136", default-features = false } -embedded-hal = { version = "1.0.0-rc.1" } -embedded-hal-async = { version = "1.0.0-rc.1", optional = true } -embedded-hal-bus = { version = "0.1.0-rc.1" } +embedded-hal = { version = "1.0.0-rc.2" } +embedded-hal-async = { version = "1.0.0-rc.2", optional = true } +embedded-hal-bus = { version = "0.1.0-rc.2" } num-integer = { version = "0.1.45", default-features = false } microfft = "0.5.0" diff --git a/examples/nrf5340/Cargo.toml b/examples/nrf5340/Cargo.toml index 032ec980..25ae9749 100644 --- a/examples/nrf5340/Cargo.toml +++ b/examples/nrf5340/Cargo.toml @@ -37,7 +37,7 @@ embassy-net = { version = "0.2.0", path = "../../embassy-net", features = [ embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = [ "defmt", ] } -embedded-io-async = { version = "0.6.0" } +embedded-io-async = { version = "0.6.1" } defmt = "0.3" defmt-rtt = "0.4" diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index 1012a8b5..e0e0d8a7 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml @@ -38,10 +38,10 @@ smart-leds = "0.3.0" heapless = "0.8" usbd-hid = "0.6.1" -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1" } -embedded-hal-async = "1.0.0-rc.1" -embedded-hal-bus = { version = "0.1.0-rc.1", features = ["async"] } -embedded-io-async = { version = "0.6.0", features = ["defmt-03"] } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } +embedded-hal-async = "1.0.0-rc.2" +embedded-hal-bus = { version = "0.1.0-rc.2", features = ["async"] } +embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } embedded-storage = { version = "0.3" } static_cell = { version = "2", features = ["nightly"]} portable-atomic = { version = "1.5", features = ["critical-section"] } diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index 75ed74b5..2a59fd69 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml @@ -11,8 +11,8 @@ embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["lo embassy-net = { version = "0.2.0", path = "../../embassy-net", features=[ "std", "nightly", "log", "medium-ethernet", "medium-ip", "tcp", "udp", "dns", "dhcpv4", "proto-ipv6"] } embassy-net-tuntap = { version = "0.1.0", path = "../../embassy-net-tuntap" } embassy-net-ppp = { version = "0.1.0", path = "../../embassy-net-ppp", features = ["log"]} -embedded-io-async = { version = "0.6.0" } -embedded-io-adapters = { version = "0.6.0", features = ["futures-03"] } +embedded-io-async = { version = "0.6.1" } +embedded-io-adapters = { version = "0.6.1", features = ["futures-03"] } critical-section = { version = "1.1", features = ["std"] } async-io = "1.6.0" diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml index 772d873c..8cee6d23 100644 --- a/examples/stm32f4/Cargo.toml +++ b/examples/stm32f4/Cargo.toml @@ -20,7 +20,7 @@ cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-sing cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" embedded-io = { version = "0.6.0" } -embedded-io-async = { version = "0.6.0" } +embedded-io-async = { version = "0.6.1" } panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } heapless = { version = "0.8", default-features = false } diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml index d418f813..8fe2f289 100644 --- a/examples/stm32f7/Cargo.toml +++ b/examples/stm32f7/Cargo.toml @@ -11,7 +11,7 @@ embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["de embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet"] } -embedded-io-async = { version = "0.6.0" } +embedded-io-async = { version = "0.6.1" } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } defmt = "0.3" diff --git a/examples/stm32h5/Cargo.toml b/examples/stm32h5/Cargo.toml index e8d17cee..db34005a 100644 --- a/examples/stm32h5/Cargo.toml +++ b/examples/stm32h5/Cargo.toml @@ -11,7 +11,7 @@ embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["de embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6"] } -embedded-io-async = { version = "0.6.0" } +embedded-io-async = { version = "0.6.1" } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } defmt = "0.3" @@ -20,9 +20,9 @@ defmt-rtt = "0.4" cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1" } -embedded-hal-async = { version = "=1.0.0-rc.1" } -embedded-nal-async = { version = "0.7" } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } +embedded-hal-async = { version = "=1.0.0-rc.2" } +embedded-nal-async = { version = "0.7.1" } panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } heapless = { version = "0.8", default-features = false } diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index 05523d00..2fe88dfa 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml @@ -11,7 +11,7 @@ embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["de embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns"] } -embedded-io-async = { version = "0.6.0" } +embedded-io-async = { version = "0.6.1" } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } defmt = "0.3" @@ -20,9 +20,9 @@ defmt-rtt = "0.4" cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1" } -embedded-hal-async = { version = "=1.0.0-rc.1" } -embedded-nal-async = { version = "0.7" } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } +embedded-hal-async = { version = "=1.0.0-rc.2" } +embedded-nal-async = { version = "0.7.1" } panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } heapless = { version = "0.8", default-features = false } diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index 2ba58c3d..15f7afe9 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml @@ -20,7 +20,7 @@ defmt-rtt = "0.4" embedded-storage = "0.3.0" embedded-io = { version = "0.6.0" } -embedded-io-async = { version = "0.6.0", optional = true } +embedded-io-async = { version = "0.6.1", optional = true } cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } cortex-m-rt = "0.7.0" diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml index f4eaf647..350e6e26 100644 --- a/examples/stm32l4/Cargo.toml +++ b/examples/stm32l4/Cargo.toml @@ -15,7 +15,7 @@ embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defm embassy-net-adin1110 = { version = "0.2.0", path = "../../embassy-net-adin1110" } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "nightly", "udp", "tcp", "dhcpv4", "medium-ethernet"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } -embedded-io-async = { version = "0.6.0", features = ["defmt-03"] } +embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } embedded-io = { version = "0.6.0", features = ["defmt-03"] } defmt = "0.3" @@ -24,9 +24,9 @@ defmt-rtt = "0.4" cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1" } -embedded-hal-async = { version = "=1.0.0-rc.1" } -embedded-hal-bus = { version = "=0.1.0-rc.1", features = ["async"] } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } +embedded-hal-async = { version = "=1.0.0-rc.2" } +embedded-hal-bus = { version = "=0.1.0-rc.2", features = ["async"] } panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } heapless = { version = "0.8", default-features = false } diff --git a/examples/stm32l5/Cargo.toml b/examples/stm32l5/Cargo.toml index 1b9b026f..7bca51ad 100644 --- a/examples/stm32l5/Cargo.toml +++ b/examples/stm32l5/Cargo.toml @@ -25,7 +25,7 @@ embedded-hal = "0.2.6" futures = { version = "0.3.17", default-features = false, features = ["async-await"] } heapless = { version = "0.8", default-features = false } rand_core = { version = "0.6.3", default-features = false } -embedded-io-async = { version = "0.6.0" } +embedded-io-async = { version = "0.6.1" } static_cell = { version = "2", features = ["nightly"]} [profile.release] diff --git a/tests/nrf/Cargo.toml b/tests/nrf/Cargo.toml index fd756881..70bb17c1 100644 --- a/tests/nrf/Cargo.toml +++ b/tests/nrf/Cargo.toml @@ -12,12 +12,12 @@ embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["de embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "task-arena-size-16384", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "nightly", "unstable-traits", "defmt-timestamp-uptime"] } embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nightly", "unstable-traits", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } -embedded-io-async = { version = "0.6.0", features = ["defmt-03"] } +embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "nightly"] } embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] } embassy-net-enc28j60 = { version = "0.1.0", path = "../../embassy-net-enc28j60", features = ["defmt"] } -embedded-hal-async = { version = "1.0.0-rc.1" } -embedded-hal-bus = { version = "0.1.0-rc.1", features = ["async"] } +embedded-hal-async = { version = "1.0.0-rc.2" } +embedded-hal-bus = { version = "0.1.0-rc.2", features = ["async"] } static_cell = { version = "2", features = [ "nightly" ] } perf-client = { path = "../perf-client" } diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index fc434a02..d69bd795 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -24,12 +24,12 @@ defmt-rtt = "0.4" cortex-m = { version = "0.7.6" } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1" } -embedded-hal-async = { version = "=1.0.0-rc.1" } -embedded-hal-bus = { version = "=0.1.0-rc.1", features = ["async"] } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } +embedded-hal-async = { version = "=1.0.0-rc.2" } +embedded-hal-bus = { version = "=0.1.0-rc.2", features = ["async"] } panic-probe = { version = "0.3.0", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } -embedded-io-async = { version = "0.6.0" } +embedded-io-async = { version = "0.6.1" } embedded-storage = { version = "0.3" } static_cell = { version = "2", features = ["nightly"]} portable-atomic = { version = "1.5", features = ["critical-section"] } diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index 8c2cfdf5..ba72c642 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -63,8 +63,8 @@ defmt-rtt = "0.4" cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1" } -embedded-hal-async = { version = "=1.0.0-rc.1" } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } +embedded-hal-async = { version = "=1.0.0-rc.2" } micromath = "2.0.0" panic-probe = { version = "0.3.0", features = ["print-defmt"] } rand_core = { version = "0.6", default-features = false } From c6989dfbca51787146f50270c671af9db434f577 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 29 Nov 2023 17:23:48 +0100 Subject: [PATCH 14/98] Remove nightly and unstable-traits features in preparation for 1.75. --- .cargo/config.toml | 3 + .github/ci/build-stable.sh | 2 +- .github/ci/test.sh | 26 +- ci.sh | 172 +++--- ci_stable.sh | 64 +-- cyw43-pio/src/lib.rs | 3 +- cyw43/src/lib.rs | 3 +- docs/modules/ROOT/examples/basic/Cargo.toml | 6 +- embassy-boot/boot/Cargo.toml | 6 +- embassy-boot/boot/src/firmware_updater/mod.rs | 2 - embassy-boot/boot/src/lib.rs | 21 +- embassy-boot/boot/src/mem_flash.rs | 3 - embassy-boot/boot/src/test_flash/blocking.rs | 1 - embassy-boot/boot/src/test_flash/mod.rs | 2 - embassy-boot/nrf/Cargo.toml | 7 +- embassy-boot/nrf/src/lib.rs | 5 +- embassy-boot/rp/Cargo.toml | 8 +- embassy-boot/rp/src/lib.rs | 5 +- embassy-boot/stm32/Cargo.toml | 19 +- embassy-boot/stm32/src/lib.rs | 5 +- embassy-embedded-hal/Cargo.toml | 10 +- embassy-embedded-hal/build.rs | 18 + .../src/flash/concat_flash.rs | 3 - embassy-embedded-hal/src/flash/mem_flash.rs | 3 - .../src/flash/partition/mod.rs | 2 - embassy-embedded-hal/src/lib.rs | 8 +- .../src/shared_bus/asynch/i2c.rs | 13 +- .../src/shared_bus/asynch/spi.rs | 11 +- embassy-embedded-hal/src/shared_bus/mod.rs | 2 - embassy-net-adin1110/src/lib.rs | 3 +- embassy-net-wiznet/src/lib.rs | 3 +- embassy-net/Cargo.toml | 10 +- embassy-net/build.rs | 18 + embassy-net/src/dns.rs | 1 - embassy-net/src/lib.rs | 5 +- embassy-net/src/tcp.rs | 2 - embassy-nrf/Cargo.toml | 21 +- embassy-nrf/src/buffered_uarte.rs | 1 - embassy-nrf/src/chips/nrf52820.rs | 1 - embassy-nrf/src/chips/nrf52833.rs | 1 - embassy-nrf/src/chips/nrf52840.rs | 1 - embassy-nrf/src/chips/nrf5340_app.rs | 1 - embassy-nrf/src/gpio.rs | 143 +++-- embassy-nrf/src/gpiote.rs | 98 ++-- embassy-nrf/src/lib.rs | 4 +- embassy-nrf/src/qspi.rs | 1 - embassy-nrf/src/spim.rs | 101 ++-- embassy-nrf/src/twim.rs | 127 +++-- embassy-rp/Cargo.toml | 23 +- embassy-rp/src/flash.rs | 2 - embassy-rp/src/gpio.rs | 409 +++++++-------- embassy-rp/src/i2c.rs | 240 ++++----- embassy-rp/src/lib.rs | 4 +- embassy-rp/src/spi.rs | 124 ++--- embassy-rp/src/uart/buffered.rs | 211 ++++---- embassy-rp/src/uart/mod.rs | 296 +++++------ embassy-stm32-wpan/src/lib.rs | 6 +- embassy-stm32/Cargo.toml | 26 +- embassy-stm32/src/exti.rs | 89 ++-- embassy-stm32/src/flash/asynch.rs | 8 +- embassy-stm32/src/flash/f4.rs | 2 - embassy-stm32/src/gpio.rs | 495 +++++++++--------- embassy-stm32/src/i2c/mod.rs | 162 +++--- embassy-stm32/src/lib.rs | 3 +- embassy-stm32/src/spi/mod.rs | 138 +++-- embassy-stm32/src/usart/buffered.rs | 256 ++++----- embassy-stm32/src/usart/mod.rs | 215 ++++---- embassy-stm32/src/usart/ringbuffered.rs | 38 +- embassy-stm32/src/usb/mod.rs | 2 - embassy-stm32/src/usb_otg/mod.rs | 10 +- embassy-sync/Cargo.toml | 7 +- embassy-sync/build.rs | 15 + embassy-sync/src/lib.rs | 5 +- embassy-sync/src/pipe.rs | 128 +++-- embassy-time/Cargo.toml | 17 +- embassy-time/build.rs | 19 +- embassy-time/src/delay.rs | 120 ++--- embassy-time/src/lib.rs | 5 +- embassy-usb-driver/src/lib.rs | 3 +- examples/boot/application/nrf/Cargo.toml | 8 +- examples/boot/application/rp/Cargo.toml | 6 +- examples/boot/application/stm32f3/Cargo.toml | 6 +- examples/boot/application/stm32f7/Cargo.toml | 6 +- examples/boot/application/stm32h7/Cargo.toml | 6 +- examples/boot/application/stm32l0/Cargo.toml | 6 +- examples/boot/application/stm32l1/Cargo.toml | 6 +- examples/boot/application/stm32l4/Cargo.toml | 6 +- examples/boot/application/stm32wl/Cargo.toml | 6 +- examples/boot/bootloader/nrf/Cargo.toml | 2 +- examples/boot/bootloader/rp/Cargo.toml | 4 +- examples/boot/bootloader/stm32/Cargo.toml | 2 +- examples/nrf-rtos-trace/Cargo.toml | 5 +- examples/nrf52840-rtic/Cargo.toml | 4 +- examples/nrf52840/Cargo.toml | 27 +- examples/nrf5340/Cargo.toml | 41 +- examples/rp/Cargo.toml | 6 +- examples/rp/src/bin/pio_uart.rs | 11 +- examples/rp/src/bin/wifi_ap_tcp_server.rs | 3 +- examples/rp/src/bin/wifi_scan.rs | 3 +- examples/rp/src/bin/wifi_tcp_server.rs | 3 +- examples/std/Cargo.toml | 4 +- examples/std/src/bin/net_ppp.rs | 3 +- examples/stm32c0/Cargo.toml | 2 +- examples/stm32f0/Cargo.toml | 2 +- examples/stm32f1/Cargo.toml | 2 +- examples/stm32f2/Cargo.toml | 2 +- examples/stm32f3/Cargo.toml | 2 +- examples/stm32f334/Cargo.toml | 2 +- examples/stm32f4/Cargo.toml | 6 +- examples/stm32f7/Cargo.toml | 4 +- examples/stm32g0/Cargo.toml | 2 +- examples/stm32g4/Cargo.toml | 2 +- examples/stm32h5/Cargo.toml | 8 +- examples/stm32h7/Cargo.toml | 8 +- examples/stm32l0/Cargo.toml | 6 +- examples/stm32l1/Cargo.toml | 2 +- examples/stm32l4/Cargo.toml | 6 +- examples/stm32l5/Cargo.toml | 4 +- examples/stm32u5/Cargo.toml | 2 +- examples/stm32wb/Cargo.toml | 4 +- examples/stm32wba/Cargo.toml | 4 +- examples/stm32wl/Cargo.toml | 4 +- examples/wasm/Cargo.toml | 2 +- tests/nrf/Cargo.toml | 8 +- tests/perf-client/Cargo.toml | 2 +- tests/rp/Cargo.toml | 6 +- tests/stm32/Cargo.toml | 4 +- 127 files changed, 1971 insertions(+), 2352 deletions(-) create mode 100644 .cargo/config.toml create mode 100644 embassy-embedded-hal/build.rs create mode 100644 embassy-net/build.rs diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000..c1ab9a9b --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,3 @@ +[patch.crates-io] +embedded-storage = { git = "https://github.com/rust-embedded-community/embedded-storage", rev = "634302740f8d676538c3890748e7d7dfe372a040" } +embedded-storage-async = { git = "https://github.com/rust-embedded-community/embedded-storage", rev = "634302740f8d676538c3890748e7d7dfe372a040" } \ No newline at end of file diff --git a/.github/ci/build-stable.sh b/.github/ci/build-stable.sh index ffaebeb3..9160a2be 100755 --- a/.github/ci/build-stable.sh +++ b/.github/ci/build-stable.sh @@ -21,7 +21,7 @@ fi hashtime restore /ci/cache/filetime.json || true hashtime save /ci/cache/filetime.json -sed -i 's/channel.*/channel = "stable"/g' rust-toolchain.toml +sed -i 's/channel.*/channel = "beta"/g' rust-toolchain.toml ./ci_stable.sh diff --git a/.github/ci/test.sh b/.github/ci/test.sh index dfc2b08c..1ee760d3 100755 --- a/.github/ci/test.sh +++ b/.github/ci/test.sh @@ -4,17 +4,6 @@ set -euo pipefail -export RUSTUP_HOME=/ci/cache/rustup -export CARGO_HOME=/ci/cache/cargo -export CARGO_TARGET_DIR=/ci/cache/target - -# needed for "dumb HTTP" transport support -# used when pointing stm32-metapac to a CI-built one. -export CARGO_NET_GIT_FETCH_WITH_CLI=true - -hashtime restore /ci/cache/filetime.json || true -hashtime save /ci/cache/filetime.json - MIRIFLAGS=-Zmiri-ignore-leaks cargo miri test --manifest-path ./embassy-executor/Cargo.toml MIRIFLAGS=-Zmiri-ignore-leaks cargo miri test --manifest-path ./embassy-executor/Cargo.toml --features nightly @@ -24,16 +13,15 @@ cargo test --manifest-path ./embassy-hal-internal/Cargo.toml cargo test --manifest-path ./embassy-time/Cargo.toml --features generic-queue cargo test --manifest-path ./embassy-boot/boot/Cargo.toml -cargo test --manifest-path ./embassy-boot/boot/Cargo.toml --features nightly -cargo test --manifest-path ./embassy-boot/boot/Cargo.toml --features nightly,ed25519-dalek -cargo test --manifest-path ./embassy-boot/boot/Cargo.toml --features nightly,ed25519-salty +cargo test --manifest-path ./embassy-boot/boot/Cargo.toml --features ed25519-dalek +cargo test --manifest-path ./embassy-boot/boot/Cargo.toml --features ed25519-salty -cargo test --manifest-path ./embassy-nrf/Cargo.toml --no-default-features --features nightly,nrf52840,time-driver-rtc1,gpiote +cargo test --manifest-path ./embassy-nrf/Cargo.toml --no-default-features --features nrf52840,time-driver-rtc1,gpiote -cargo test --manifest-path ./embassy-rp/Cargo.toml --no-default-features --features nightly,time-driver +cargo test --manifest-path ./embassy-rp/Cargo.toml --no-default-features --features time-driver -cargo test --manifest-path ./embassy-stm32/Cargo.toml --no-default-features --features nightly,stm32f429vg,exti,time-driver-any,exti -cargo test --manifest-path ./embassy-stm32/Cargo.toml --no-default-features --features nightly,stm32f732ze,exti,time-driver-any,exti -cargo test --manifest-path ./embassy-stm32/Cargo.toml --no-default-features --features nightly,stm32f769ni,exti,time-driver-any,exti +cargo test --manifest-path ./embassy-stm32/Cargo.toml --no-default-features --features stm32f429vg,exti,time-driver-any,exti +cargo test --manifest-path ./embassy-stm32/Cargo.toml --no-default-features --features stm32f732ze,exti,time-driver-any,exti +cargo test --manifest-path ./embassy-stm32/Cargo.toml --no-default-features --features stm32f769ni,exti,time-driver-any,exti cargo test --manifest-path ./embassy-net-adin1110/Cargo.toml diff --git a/ci.sh b/ci.sh index 5a4773da..8a5e206d 100755 --- a/ci.sh +++ b/ci.sh @@ -35,104 +35,94 @@ cargo batch \ --- build --release --manifest-path embassy-executor/Cargo.toml --target riscv32imac-unknown-none-elf --features nightly,arch-riscv32,integrated-timers \ --- build --release --manifest-path embassy-executor/Cargo.toml --target riscv32imac-unknown-none-elf --features nightly,arch-riscv32,executor-thread \ --- build --release --manifest-path embassy-executor/Cargo.toml --target riscv32imac-unknown-none-elf --features nightly,arch-riscv32,executor-thread,integrated-timers \ - --- build --release --manifest-path embassy-sync/Cargo.toml --target thumbv6m-none-eabi --features nightly,defmt \ - --- build --release --manifest-path embassy-time/Cargo.toml --target thumbv6m-none-eabi --features nightly,defmt,defmt-timestamp-uptime,tick-hz-32_768,generic-queue-8 \ + --- build --release --manifest-path embassy-sync/Cargo.toml --target thumbv6m-none-eabi --features defmt \ + --- build --release --manifest-path embassy-time/Cargo.toml --target thumbv6m-none-eabi --features defmt,defmt-timestamp-uptime,tick-hz-32_768,generic-queue-8 \ --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,medium-ethernet \ --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,igmp,medium-ethernet \ --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet \ - --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet,nightly,dhcpv4-hostname \ + --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,dhcpv4,medium-ethernet,dhcpv4-hostname \ --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv6,medium-ethernet \ --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv6,medium-ieee802154 \ --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv6,medium-ethernet,medium-ieee802154 \ - --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv6,medium-ethernet,nightly \ + --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv6,medium-ethernet \ --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ethernet \ - --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ethernet,nightly \ - --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ip,nightly \ - --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ip,medium-ethernet,nightly \ - --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ip,medium-ethernet,medium-ieee802154,nightly \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52805,gpiote,time-driver-rtc1 \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52810,gpiote,time-driver-rtc1 \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52811,gpiote,time-driver-rtc1 \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52820,gpiote,time-driver-rtc1 \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52832,gpiote,time-driver-rtc1,reset-pin-as-gpio \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52833,gpiote,time-driver-rtc1,unstable-traits,nfc-pins-as-gpio \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf9160-s,gpiote,time-driver-rtc1 \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf9160-ns,gpiote,time-driver-rtc1,unstable-traits \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf5340-app-s,gpiote,time-driver-rtc1,unstable-traits \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf5340-app-ns,gpiote,time-driver-rtc1 \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,nrf5340-net,gpiote,time-driver-rtc1,unstable-traits \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52840,gpiote,time-driver-rtc1 \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52840,log,gpiote,time-driver-rtc1 \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nightly,nrf52840,defmt,gpiote,time-driver-rtc1,unstable-traits \ - --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits,defmt \ - --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits,log \ - --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,unstable-traits \ - --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly \ - --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,intrinsics \ - --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features nightly,qspi-as-gpio \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti,time-driver-any,unstable-traits,time \ + --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ip \ + --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ip,medium-ethernet \ + --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ip,medium-ethernet,medium-ieee802154 \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52805,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52810,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52811,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52820,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52832,gpiote,time-driver-rtc1,reset-pin-as-gpio \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52833,gpiote,time-driver-rtc1,nfc-pins-as-gpio \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf9160-s,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf9160-ns,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340-app-s,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340-app-ns,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340-net,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840,log,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840,defmt,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features defmt \ + --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features log \ + --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features intrinsics \ + --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features qspi-as-gpio \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti,time-driver-any,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,time-driver-any,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,time-driver-any,unstable-traits,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti,unstable-traits,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,nightly,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,nightly,defmt,exti,time-driver-any,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,nightly,defmt,time-driver-any,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,nightly,defmt,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,nightly,defmt,exti,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,nightly,defmt,exti,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,nightly,defmt,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,nightly,defmt,exti \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,nightly,defmt,exti,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,nightly,defmt \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f401ve,defmt,exti,time-driver-any,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f405zg,defmt,exti,time-driver-any,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f407zg,defmt,exti,time-driver-any,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f401ve,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f405zg,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f407zg,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f410tb,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f411ce,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f412zg,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f413vh,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f415zg,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f417zg,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f423zh,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f427zi,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f429zi,log,exti,time-driver-any,unstable-traits,embedded-sdmmc,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f437zi,log,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f439zi,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f446ze,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f469zi,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f479zi,defmt,exti,time-driver-any,unstable-traits,embedded-sdmmc,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32f730i8,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32h753zi,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32h735zg,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32h755zi-cm7,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32h725re,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32h7b3ai,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32l476vg,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32l422cb,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wb15cc,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32l072cz,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32l041f6,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32l073cz,defmt,exti,time-driver-any,unstable-traits,low-power,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32l151cb-a,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f398ve,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f378cc,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32g0c1ve,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f217zg,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,stm32l552ze,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32wl54jc-cm0p,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wle5jb,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32g474pe,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f107vc,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f103re,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f100c4,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32h503rb,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32h562ag,defmt,exti,time-driver-any,unstable-traits,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f401ve,defmt,exti,time-driver-any \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f405zg,defmt,exti,time-driver-any \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f407zg,defmt,exti,time-driver-any \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f401ve,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f405zg,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f407zg,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f412zg,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f413vh,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f415zg,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f417zg,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f423zh,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f427zi,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any,embedded-sdmmc,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f437zi,log,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f439zi,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f446ze,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f469zi,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f479zi,defmt,exti,time-driver-any,embedded-sdmmc,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f730i8,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h753zi,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h735zg,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h725re,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h7b3ai,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l422cb,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb15cc,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l041f6,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l073cz,defmt,exti,time-driver-any,low-power,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f398ve,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f378cc,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32g0c1ve,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32wl54jc-cm0p,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wle5jb,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g474pe,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f107vc,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f103re,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f100c4,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32h503rb,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32h562ag,defmt,exti,time-driver-any,time \ --- build --release --manifest-path cyw43/Cargo.toml --target thumbv6m-none-eabi --features ''\ --- build --release --manifest-path cyw43/Cargo.toml --target thumbv6m-none-eabi --features 'log' \ --- build --release --manifest-path cyw43/Cargo.toml --target thumbv6m-none-eabi --features 'defmt' \ @@ -140,10 +130,10 @@ cargo batch \ --- build --release --manifest-path cyw43/Cargo.toml --target thumbv6m-none-eabi --features 'defmt,firmware-logs' \ --- build --release --manifest-path cyw43-pio/Cargo.toml --target thumbv6m-none-eabi --features '' \ --- build --release --manifest-path cyw43-pio/Cargo.toml --target thumbv6m-none-eabi --features 'overclock' \ - --- build --release --manifest-path embassy-boot/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840,nightly \ - --- build --release --manifest-path embassy-boot/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9160-ns,nightly \ - --- build --release --manifest-path embassy-boot/rp/Cargo.toml --target thumbv6m-none-eabi --features nightly \ - --- build --release --manifest-path embassy-boot/stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4,nightly \ + --- build --release --manifest-path embassy-boot/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840 \ + --- build --release --manifest-path embassy-boot/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9160-ns \ + --- build --release --manifest-path embassy-boot/rp/Cargo.toml --target thumbv6m-none-eabi \ + --- build --release --manifest-path embassy-boot/stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4 \ --- build --release --manifest-path docs/modules/ROOT/examples/basic/Cargo.toml --target thumbv7em-none-eabi \ --- build --release --manifest-path docs/modules/ROOT/examples/layer-by-layer/blinky-pac/Cargo.toml --target thumbv7em-none-eabi \ --- build --release --manifest-path docs/modules/ROOT/examples/layer-by-layer/blinky-hal/Cargo.toml --target thumbv7em-none-eabi \ diff --git a/ci_stable.sh b/ci_stable.sh index 1fe4e3a1..66ed8f79 100755 --- a/ci_stable.sh +++ b/ci_stable.sh @@ -22,56 +22,56 @@ cargo batch \ --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52811,gpiote,time-driver-rtc1 \ --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52820,gpiote,time-driver-rtc1 \ --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52832,gpiote,time-driver-rtc1 \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52833,gpiote,time-driver-rtc1,unstable-traits \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52833,gpiote,time-driver-rtc1 \ --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf9160-s,gpiote,time-driver-rtc1 \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf9160-ns,gpiote,time-driver-rtc1,unstable-traits \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340-app-s,gpiote,time-driver-rtc1,unstable-traits \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf9160-ns,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340-app-s,gpiote,time-driver-rtc1 \ --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340-app-ns,gpiote,time-driver-rtc1 \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340-net,gpiote,time-driver-rtc1,unstable-traits \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340-net,gpiote,time-driver-rtc1 \ --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840,gpiote,time-driver-rtc1 \ --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840,log,gpiote,time-driver-rtc1 \ - --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840,defmt,gpiote,time-driver-rtc1,unstable-traits \ - --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features unstable-traits,defmt \ - --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features unstable-traits,log \ + --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840,defmt,gpiote,time-driver-rtc1 \ + --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features defmt \ + --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features log \ --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi \ --- build --release --manifest-path embassy-rp/Cargo.toml --target thumbv6m-none-eabi --features qspi-as-gpio \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g473cc,defmt,exti,time-driver-any,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g491re,defmt,exti,time-driver-any,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32u585zi,defmt,exti,time-driver-any,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb55vy,defmt,exti,time-driver-any,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wl55cc-cm4,defmt,exti,time-driver-any,unstable-traits \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g473cc,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g491re,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32u585zi,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb55vy,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wl55cc-cm4,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l4r9zi,defmt,exti,time-driver-any,unstable-traits,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f303vc,defmt,exti,time-driver-any,unstable-traits,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g473cc,defmt,exti,time-driver-any \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g491re,defmt,exti,time-driver-any \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32u585zi,defmt,exti,time-driver-any \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb55vy,defmt,exti,time-driver-any \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wl55cc-cm4,defmt,exti,time-driver-any \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g473cc,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32g491re,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32u585zi,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb55vy,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wl55cc-cm4,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l4r9zi,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f303vc,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f411ce,defmt,time-driver-any,unstable-traits,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any,unstable-traits,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,time-driver-any,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,time-driver-any,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,time-driver-any,unstable-traits,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,time-driver-any,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,time-driver-any,unstable-traits,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,time-driver-any,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,time-driver-any,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,time-driver-any,unstable-traits,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,time-driver-any,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,time-driver-any,unstable-traits,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f410tb,defmt,exti,time-driver-any,unstable-traits,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any,unstable-traits,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi,log,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,unstable-traits,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,unstable-traits,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32l072cz,defmt,exti,time-driver-any,unstable-traits,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,exti,time-driver-any,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,exti,time-driver-any,unstable-traits,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32l151cb-a,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any,time \ - --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f217zg,defmt,exti,time-driver-any,unstable-traits,time \ --- build --release --manifest-path examples/nrf52840/Cargo.toml --target thumbv7em-none-eabi --no-default-features --out-dir out/examples/nrf52840 --bin raw_spawn \ --- build --release --manifest-path examples/stm32l0/Cargo.toml --target thumbv6m-none-eabi --no-default-features --out-dir out/examples/stm32l0 --bin raw_spawn \ diff --git a/cyw43-pio/src/lib.rs b/cyw43-pio/src/lib.rs index de89ed58..41b67032 100644 --- a/cyw43-pio/src/lib.rs +++ b/cyw43-pio/src/lib.rs @@ -1,6 +1,5 @@ #![no_std] -#![feature(async_fn_in_trait)] -#![allow(stable_features, unknown_lints, async_fn_in_trait)] +#![allow(async_fn_in_trait)] use core::slice; diff --git a/cyw43/src/lib.rs b/cyw43/src/lib.rs index 4a1d015a..300465e3 100644 --- a/cyw43/src/lib.rs +++ b/cyw43/src/lib.rs @@ -1,7 +1,6 @@ #![no_std] #![no_main] -#![feature(async_fn_in_trait, type_alias_impl_trait)] -#![allow(stable_features, unknown_lints, async_fn_in_trait)] +#![allow(async_fn_in_trait)] #![deny(unused_must_use)] // This mod MUST go first, so that the others see its macros. diff --git a/docs/modules/ROOT/examples/basic/Cargo.toml b/docs/modules/ROOT/examples/basic/Cargo.toml index 527ce2ed..516dc470 100644 --- a/docs/modules/ROOT/examples/basic/Cargo.toml +++ b/docs/modules/ROOT/examples/basic/Cargo.toml @@ -6,9 +6,9 @@ version = "0.1.0" license = "MIT OR Apache-2.0" [dependencies] -embassy-executor = { version = "0.3.0", path = "../../../../../embassy-executor", features = ["defmt", "nightly", "integrated-timers", "arch-cortex-m", "executor-thread"] } -embassy-time = { version = "0.1.4", path = "../../../../../embassy-time", features = ["defmt", "nightly"] } -embassy-nrf = { version = "0.1.0", path = "../../../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "nightly"] } +embassy-executor = { version = "0.3.0", path = "../../../../../embassy-executor", features = ["defmt", "integrated-timers", "arch-cortex-m", "executor-thread"] } +embassy-time = { version = "0.1.4", path = "../../../../../embassy-time", features = ["defmt"] } +embassy-nrf = { version = "0.1.0", path = "../../../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote"] } defmt = "0.3" defmt-rtt = "0.3" diff --git a/embassy-boot/boot/Cargo.toml b/embassy-boot/boot/Cargo.toml index 8e11db57..ee69bc26 100644 --- a/embassy-boot/boot/Cargo.toml +++ b/embassy-boot/boot/Cargo.toml @@ -25,12 +25,12 @@ features = ["defmt"] [dependencies] defmt = { version = "0.3", optional = true } digest = "0.10" -log = { version = "0.4", optional = true } +log = { version = "0.4", optional = true } ed25519-dalek = { version = "1.0.1", default_features = false, features = ["u32_backend"], optional = true } embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } embassy-sync = { version = "0.4.0", path = "../../embassy-sync" } embedded-storage = "0.3.0" -embedded-storage-async = { version = "0.4.0", optional = true } +embedded-storage-async = { version = "0.4.0" } salty = { git = "https://github.com/ycrypto/salty.git", rev = "a9f17911a5024698406b75c0fac56ab5ccf6a8c7", optional = true } signature = { version = "1.6.4", default-features = false } @@ -50,7 +50,5 @@ features = ["rand", "std", "u32_backend"] ed25519-dalek = ["dep:ed25519-dalek", "_verify"] ed25519-salty = ["dep:salty", "_verify"] -nightly = ["dep:embedded-storage-async", "embassy-embedded-hal/nightly"] - #Internal features _verify = [] diff --git a/embassy-boot/boot/src/firmware_updater/mod.rs b/embassy-boot/boot/src/firmware_updater/mod.rs index 937ddcc6..4814786b 100644 --- a/embassy-boot/boot/src/firmware_updater/mod.rs +++ b/embassy-boot/boot/src/firmware_updater/mod.rs @@ -1,8 +1,6 @@ -#[cfg(feature = "nightly")] mod asynch; mod blocking; -#[cfg(feature = "nightly")] pub use asynch::{FirmwareState, FirmwareUpdater}; pub use blocking::{BlockingFirmwareState, BlockingFirmwareUpdater}; use embedded_storage::nor_flash::{NorFlashError, NorFlashErrorKind}; diff --git a/embassy-boot/boot/src/lib.rs b/embassy-boot/boot/src/lib.rs index 9f035637..9e70a4dc 100644 --- a/embassy-boot/boot/src/lib.rs +++ b/embassy-boot/boot/src/lib.rs @@ -1,6 +1,5 @@ -#![cfg_attr(feature = "nightly", feature(async_fn_in_trait))] -#![cfg_attr(feature = "nightly", allow(stable_features, unknown_lints, async_fn_in_trait))] #![no_std] +#![allow(async_fn_in_trait)] #![warn(missing_docs)] #![doc = include_str!("../README.md")] mod fmt; @@ -18,10 +17,9 @@ mod test_flash; pub(crate) const STATE_ERASE_VALUE: u8 = 0xFF; pub use boot_loader::{BootError, BootLoader, BootLoaderConfig}; pub use firmware_updater::{ - BlockingFirmwareState, BlockingFirmwareUpdater, FirmwareUpdaterConfig, FirmwareUpdaterError, + BlockingFirmwareState, BlockingFirmwareUpdater, FirmwareState, FirmwareUpdater, FirmwareUpdaterConfig, + FirmwareUpdaterError, }; -#[cfg(feature = "nightly")] -pub use firmware_updater::{FirmwareState, FirmwareUpdater}; pub(crate) const BOOT_MAGIC: u8 = 0xD0; pub(crate) const SWAP_MAGIC: u8 = 0xF0; @@ -57,7 +55,6 @@ mod tests { #![allow(unused_imports)] use embedded_storage::nor_flash::{NorFlash, ReadNorFlash}; - #[cfg(feature = "nightly")] use embedded_storage_async::nor_flash::NorFlash as AsyncNorFlash; use futures::executor::block_on; @@ -65,9 +62,7 @@ mod tests { use crate::boot_loader::BootLoaderConfig; use crate::firmware_updater::FirmwareUpdaterConfig; use crate::mem_flash::MemFlash; - #[cfg(feature = "nightly")] - use crate::test_flash::AsyncTestFlash; - use crate::test_flash::BlockingTestFlash; + use crate::test_flash::{AsyncTestFlash, BlockingTestFlash}; /* #[test] @@ -105,7 +100,7 @@ mod tests { } #[test] - #[cfg(all(feature = "nightly", not(feature = "_verify")))] + #[cfg(not(feature = "_verify"))] fn test_swap_state() { const FIRMWARE_SIZE: usize = 57344; let flash = AsyncTestFlash::new(BootLoaderConfig { @@ -183,7 +178,7 @@ mod tests { } #[test] - #[cfg(all(feature = "nightly", not(feature = "_verify")))] + #[cfg(not(feature = "_verify"))] fn test_swap_state_active_page_biggest() { const FIRMWARE_SIZE: usize = 12288; let flash = AsyncTestFlash::new(BootLoaderConfig { @@ -228,7 +223,7 @@ mod tests { } #[test] - #[cfg(all(feature = "nightly", not(feature = "_verify")))] + #[cfg(not(feature = "_verify"))] fn test_swap_state_dfu_page_biggest() { const FIRMWARE_SIZE: usize = 12288; let flash = AsyncTestFlash::new(BootLoaderConfig { @@ -272,7 +267,7 @@ mod tests { } #[test] - #[cfg(all(feature = "nightly", feature = "_verify"))] + #[cfg(feature = "_verify")] fn test_verify() { // The following key setup is based on: // https://docs.rs/ed25519-dalek/latest/ed25519_dalek/#example diff --git a/embassy-boot/boot/src/mem_flash.rs b/embassy-boot/boot/src/mem_flash.rs index 2728e972..40f352c8 100644 --- a/embassy-boot/boot/src/mem_flash.rs +++ b/embassy-boot/boot/src/mem_flash.rs @@ -3,7 +3,6 @@ use core::ops::{Bound, Range, RangeBounds}; use embedded_storage::nor_flash::{ErrorType, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash}; -#[cfg(feature = "nightly")] use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash}; pub struct MemFlash { @@ -141,7 +140,6 @@ impl NorFla } } -#[cfg(feature = "nightly")] impl AsyncReadNorFlash for MemFlash { @@ -156,7 +154,6 @@ impl AsyncR } } -#[cfg(feature = "nightly")] impl AsyncNorFlash for MemFlash { diff --git a/embassy-boot/boot/src/test_flash/blocking.rs b/embassy-boot/boot/src/test_flash/blocking.rs index ba33c920..5ec476c6 100644 --- a/embassy-boot/boot/src/test_flash/blocking.rs +++ b/embassy-boot/boot/src/test_flash/blocking.rs @@ -51,7 +51,6 @@ where } } -#[cfg(feature = "nightly")] impl BlockingTestFlash where ACTIVE: NorFlash + embedded_storage_async::nor_flash::NorFlash, diff --git a/embassy-boot/boot/src/test_flash/mod.rs b/embassy-boot/boot/src/test_flash/mod.rs index a0672322..79b15a08 100644 --- a/embassy-boot/boot/src/test_flash/mod.rs +++ b/embassy-boot/boot/src/test_flash/mod.rs @@ -1,7 +1,5 @@ -#[cfg(feature = "nightly")] mod asynch; mod blocking; -#[cfg(feature = "nightly")] pub(crate) use asynch::AsyncTestFlash; pub(crate) use blocking::BlockingTestFlash; diff --git a/embassy-boot/nrf/Cargo.toml b/embassy-boot/nrf/Cargo.toml index 72c27efa..b1650631 100644 --- a/embassy-boot/nrf/Cargo.toml +++ b/embassy-boot/nrf/Cargo.toml @@ -22,7 +22,7 @@ embassy-boot = { path = "../boot", default-features = false } cortex-m = { version = "0.7.6" } cortex-m-rt = { version = "0.7" } embedded-storage = "0.3.0" -embedded-storage-async = { version = "0.4.0", optional = true } +embedded-storage-async = { version = "0.4.0" } cfg-if = "1.0.0" nrf-softdevice-mbr = { version = "0.1.0", git = "https://github.com/embassy-rs/nrf-softdevice.git", branch = "master", optional = true } @@ -36,8 +36,3 @@ defmt = [ softdevice = [ "nrf-softdevice-mbr", ] -nightly = [ - "dep:embedded-storage-async", - "embassy-boot/nightly", - "embassy-nrf/nightly" -] diff --git a/embassy-boot/nrf/src/lib.rs b/embassy-boot/nrf/src/lib.rs index b9d86eb1..5b20a93c 100644 --- a/embassy-boot/nrf/src/lib.rs +++ b/embassy-boot/nrf/src/lib.rs @@ -4,10 +4,9 @@ mod fmt; pub use embassy_boot::{ - AlignedBuffer, BlockingFirmwareState, BlockingFirmwareUpdater, BootLoaderConfig, FirmwareUpdaterConfig, + AlignedBuffer, BlockingFirmwareState, BlockingFirmwareUpdater, BootLoaderConfig, FirmwareState, FirmwareUpdater, + FirmwareUpdaterConfig, }; -#[cfg(feature = "nightly")] -pub use embassy_boot::{FirmwareState, FirmwareUpdater}; use embassy_nrf::nvmc::PAGE_SIZE; use embassy_nrf::peripherals::WDT; use embassy_nrf::wdt; diff --git a/embassy-boot/rp/Cargo.toml b/embassy-boot/rp/Cargo.toml index efa0ef8a..7329ea57 100644 --- a/embassy-boot/rp/Cargo.toml +++ b/embassy-boot/rp/Cargo.toml @@ -25,7 +25,7 @@ embassy-time = { path = "../../embassy-time" } cortex-m = { version = "0.7.6" } cortex-m-rt = { version = "0.7" } embedded-storage = "0.3.0" -embedded-storage-async = { version = "0.4.0", optional = true } +embedded-storage-async = { version = "0.4.0" } cfg-if = "1.0.0" [features] @@ -40,12 +40,6 @@ log = [ "embassy-rp/log", ] debug = ["defmt-rtt"] -nightly = [ - "dep:embedded-storage-async", - "embassy-boot/nightly", - "embassy-rp/nightly", - "embassy-time/nightly" -] [profile.dev] debug = 2 diff --git a/embassy-boot/rp/src/lib.rs b/embassy-boot/rp/src/lib.rs index 989e7521..07a5b3f4 100644 --- a/embassy-boot/rp/src/lib.rs +++ b/embassy-boot/rp/src/lib.rs @@ -4,10 +4,9 @@ mod fmt; pub use embassy_boot::{ - AlignedBuffer, BlockingFirmwareState, BlockingFirmwareUpdater, BootLoaderConfig, FirmwareUpdaterConfig, State, + AlignedBuffer, BlockingFirmwareState, BlockingFirmwareUpdater, BootLoaderConfig, FirmwareState, FirmwareUpdater, + FirmwareUpdaterConfig, State, }; -#[cfg(feature = "nightly")] -pub use embassy_boot::{FirmwareState, FirmwareUpdater}; use embassy_rp::flash::{Blocking, Flash, ERASE_SIZE}; use embassy_rp::peripherals::{FLASH, WATCHDOG}; use embassy_rp::watchdog::Watchdog; diff --git a/embassy-boot/stm32/Cargo.toml b/embassy-boot/stm32/Cargo.toml index da310277..a9f0e4f0 100644 --- a/embassy-boot/stm32/Cargo.toml +++ b/embassy-boot/stm32/Cargo.toml @@ -24,26 +24,13 @@ embassy-boot = { path = "../boot", default-features = false } cortex-m = { version = "0.7.6" } cortex-m-rt = { version = "0.7" } embedded-storage = "0.3.0" -embedded-storage-async = { version = "0.4.0", optional = true } +embedded-storage-async = { version = "0.4.0" } cfg-if = "1.0.0" [features] -defmt = [ - "dep:defmt", - "embassy-boot/defmt", - "embassy-stm32/defmt", -] -log = [ - "dep:log", - "embassy-boot/log", - "embassy-stm32/log", -] +defmt = ["dep:defmt", "embassy-boot/defmt", "embassy-stm32/defmt"] +log = ["dep:log", "embassy-boot/log", "embassy-stm32/log"] debug = ["defmt-rtt"] -nightly = [ - "dep:embedded-storage-async", - "embassy-boot/nightly", - "embassy-stm32/nightly" -] [profile.dev] debug = 2 diff --git a/embassy-boot/stm32/src/lib.rs b/embassy-boot/stm32/src/lib.rs index c6350c49..c418cb26 100644 --- a/embassy-boot/stm32/src/lib.rs +++ b/embassy-boot/stm32/src/lib.rs @@ -4,10 +4,9 @@ mod fmt; pub use embassy_boot::{ - AlignedBuffer, BlockingFirmwareState, BlockingFirmwareUpdater, BootLoaderConfig, FirmwareUpdaterConfig, State, + AlignedBuffer, BlockingFirmwareState, BlockingFirmwareUpdater, BootLoaderConfig, FirmwareState, FirmwareUpdater, + FirmwareUpdaterConfig, State, }; -#[cfg(feature = "nightly")] -pub use embassy_boot::{FirmwareState, FirmwareUpdater}; use embedded_storage::nor_flash::NorFlash; /// A bootloader for STM32 devices. diff --git a/embassy-embedded-hal/Cargo.toml b/embassy-embedded-hal/Cargo.toml index 52ecd5c7..db4dc958 100644 --- a/embassy-embedded-hal/Cargo.toml +++ b/embassy-embedded-hal/Cargo.toml @@ -8,27 +8,25 @@ license = "MIT OR Apache-2.0" [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-embedded-hal-v$VERSION/embassy-embedded-hal/src/" src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-embedded-hal/src/" -features = ["nightly", "std"] +features = ["std"] target = "x86_64-unknown-linux-gnu" [features] std = [] -# Enable nightly-only features -nightly = ["embassy-futures", "embedded-hal-async", "embedded-storage-async"] time = ["dep:embassy-time"] default = ["time"] [dependencies] -embassy-futures = { version = "0.1.0", path = "../embassy-futures", optional = true } +embassy-futures = { version = "0.1.0", path = "../embassy-futures" } embassy-sync = { version = "0.4.0", path = "../embassy-sync" } embassy-time = { version = "0.1.5", path = "../embassy-time", optional = true } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = [ "unproven", ] } embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } -embedded-hal-async = { version = "=1.0.0-rc.2", optional = true } +embedded-hal-async = { version = "=1.0.0-rc.2" } embedded-storage = "0.3.0" -embedded-storage-async = { version = "0.4.0", optional = true } +embedded-storage-async = { version = "0.4.0" } nb = "1.0.0" defmt = { version = "0.3", optional = true } diff --git a/embassy-embedded-hal/build.rs b/embassy-embedded-hal/build.rs new file mode 100644 index 00000000..78bd27ec --- /dev/null +++ b/embassy-embedded-hal/build.rs @@ -0,0 +1,18 @@ +use std::env; +use std::ffi::OsString; +use std::process::Command; + +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + + let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc")); + + let output = Command::new(rustc) + .arg("--version") + .output() + .expect("failed to run `rustc --version`"); + + if String::from_utf8_lossy(&output.stdout).contains("nightly") { + println!("cargo:rustc-cfg=nightly"); + } +} diff --git a/embassy-embedded-hal/src/flash/concat_flash.rs b/embassy-embedded-hal/src/flash/concat_flash.rs index 1ea84269..499941d1 100644 --- a/embassy-embedded-hal/src/flash/concat_flash.rs +++ b/embassy-embedded-hal/src/flash/concat_flash.rs @@ -1,5 +1,4 @@ use embedded_storage::nor_flash::{ErrorType, NorFlash, NorFlashError, ReadNorFlash}; -#[cfg(feature = "nightly")] use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash}; /// Convenience helper for concatenating two consecutive flashes into one. @@ -117,7 +116,6 @@ where } } -#[cfg(feature = "nightly")] impl AsyncReadNorFlash for ConcatFlash where First: AsyncReadNorFlash, @@ -146,7 +144,6 @@ where } } -#[cfg(feature = "nightly")] impl AsyncNorFlash for ConcatFlash where First: AsyncNorFlash, diff --git a/embassy-embedded-hal/src/flash/mem_flash.rs b/embassy-embedded-hal/src/flash/mem_flash.rs index afb0d1a1..d24c6182 100644 --- a/embassy-embedded-hal/src/flash/mem_flash.rs +++ b/embassy-embedded-hal/src/flash/mem_flash.rs @@ -1,7 +1,6 @@ use alloc::vec::Vec; use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash}; -#[cfg(feature = "nightly")] use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash}; extern crate alloc; @@ -93,7 +92,6 @@ impl NorFla } } -#[cfg(feature = "nightly")] impl AsyncReadNorFlash for MemFlash { @@ -109,7 +107,6 @@ impl AsyncR } } -#[cfg(feature = "nightly")] impl AsyncNorFlash for MemFlash { diff --git a/embassy-embedded-hal/src/flash/partition/mod.rs b/embassy-embedded-hal/src/flash/partition/mod.rs index 42c8a308..6177ed9a 100644 --- a/embassy-embedded-hal/src/flash/partition/mod.rs +++ b/embassy-embedded-hal/src/flash/partition/mod.rs @@ -2,11 +2,9 @@ use embedded_storage::nor_flash::{NorFlashError, NorFlashErrorKind}; -#[cfg(feature = "nightly")] mod asynch; mod blocking; -#[cfg(feature = "nightly")] pub use asynch::Partition; pub use blocking::BlockingPartition; diff --git a/embassy-embedded-hal/src/lib.rs b/embassy-embedded-hal/src/lib.rs index ce5fac3f..b40f892f 100644 --- a/embassy-embedded-hal/src/lib.rs +++ b/embassy-embedded-hal/src/lib.rs @@ -1,15 +1,13 @@ #![cfg_attr(not(feature = "std"), no_std)] -#![cfg_attr(feature = "nightly", feature(async_fn_in_trait, impl_trait_projections))] -#![cfg_attr(feature = "nightly", allow(stable_features, unknown_lints, async_fn_in_trait))] +#![cfg_attr(nightly, feature(async_fn_in_trait, impl_trait_projections))] +#![cfg_attr(nightly, allow(stable_features, unknown_lints))] +#![allow(async_fn_in_trait)] #![warn(missing_docs)] //! Utilities to use `embedded-hal` traits with Embassy. -#[cfg(feature = "nightly")] pub mod adapter; - pub mod flash; - pub mod shared_bus; /// Set the configuration of a peripheral driver. diff --git a/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs b/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs index 1053d384..779c0426 100644 --- a/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs +++ b/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs @@ -2,16 +2,15 @@ //! //! # Example (nrf52) //! -//! ```rust -//! use embassy_embedded_hal::shared_bus::i2c::I2cDevice; +//! ```rust,ignore +//! use embassy_embedded_hal::shared_bus::asynch::i2c::I2cDevice; //! use embassy_sync::mutex::Mutex; -//! use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; +//! use embassy_sync::blocking_mutex::raw::NoopRawMutex; //! -//! static I2C_BUS: StaticCell>> = StaticCell::new(); +//! static I2C_BUS: StaticCell>> = StaticCell::new(); //! let config = twim::Config::default(); -//! let irq = interrupt::take!(SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0); -//! let i2c = Twim::new(p.TWISPI0, irq, p.P0_03, p.P0_04, config); -//! let i2c_bus = Mutex::::new(i2c); +//! let i2c = Twim::new(p.TWISPI0, Irqs, p.P0_03, p.P0_04, config); +//! let i2c_bus = Mutex::new(i2c); //! let i2c_bus = I2C_BUS.init(i2c_bus); //! //! // Device 1, using embedded-hal-async compatible driver for QMC5883L compass diff --git a/embassy-embedded-hal/src/shared_bus/asynch/spi.rs b/embassy-embedded-hal/src/shared_bus/asynch/spi.rs index b4f53c62..62b2c92a 100644 --- a/embassy-embedded-hal/src/shared_bus/asynch/spi.rs +++ b/embassy-embedded-hal/src/shared_bus/asynch/spi.rs @@ -2,17 +2,16 @@ //! //! # Example (nrf52) //! -//! ```rust +//! ```rust,ignore //! use embassy_embedded_hal::shared_bus::spi::SpiDevice; //! use embassy_sync::mutex::Mutex; -//! use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; +//! use embassy_sync::blocking_mutex::raw::NoopRawMutex; //! -//! static SPI_BUS: StaticCell>> = StaticCell::new(); +//! static SPI_BUS: StaticCell>> = StaticCell::new(); //! let mut config = spim::Config::default(); //! config.frequency = spim::Frequency::M32; -//! let irq = interrupt::take!(SPIM3); -//! let spi = spim::Spim::new_txonly(p.SPI3, irq, p.P0_15, p.P0_18, config); -//! let spi_bus = Mutex::::new(spi); +//! let spi = spim::Spim::new_txonly(p.SPI3, Irqs, p.P0_15, p.P0_18, config); +//! let spi_bus = Mutex::new(spi); //! let spi_bus = SPI_BUS.init(spi_bus); //! //! // Device 1, using embedded-hal-async compatible driver for ST7735 LCD display diff --git a/embassy-embedded-hal/src/shared_bus/mod.rs b/embassy-embedded-hal/src/shared_bus/mod.rs index ab96df13..d835306b 100644 --- a/embassy-embedded-hal/src/shared_bus/mod.rs +++ b/embassy-embedded-hal/src/shared_bus/mod.rs @@ -3,9 +3,7 @@ use core::fmt::Debug; use embedded_hal_1::{i2c, spi}; -#[cfg(feature = "nightly")] pub mod asynch; - pub mod blocking; /// Error returned by I2C device implementations in this crate. diff --git a/embassy-net-adin1110/src/lib.rs b/embassy-net-adin1110/src/lib.rs index e4a3cb20..080b3f94 100644 --- a/embassy-net-adin1110/src/lib.rs +++ b/embassy-net-adin1110/src/lib.rs @@ -1,6 +1,5 @@ #![deny(clippy::pedantic)] -#![feature(async_fn_in_trait)] -#![allow(stable_features, unknown_lints, async_fn_in_trait)] +#![allow(async_fn_in_trait)] #![cfg_attr(not(any(test, feature = "std")), no_std)] #![allow(clippy::module_name_repetitions)] #![allow(clippy::missing_errors_doc)] diff --git a/embassy-net-wiznet/src/lib.rs b/embassy-net-wiznet/src/lib.rs index 21d5f46d..f26f2bbb 100644 --- a/embassy-net-wiznet/src/lib.rs +++ b/embassy-net-wiznet/src/lib.rs @@ -1,6 +1,5 @@ #![no_std] -#![feature(async_fn_in_trait)] -#![allow(stable_features, unknown_lints, async_fn_in_trait)] +#![allow(async_fn_in_trait)] #![doc = include_str!("../README.md")] pub mod chip; diff --git a/embassy-net/Cargo.toml b/embassy-net/Cargo.toml index fe8344f5..f106582e 100644 --- a/embassy-net/Cargo.toml +++ b/embassy-net/Cargo.toml @@ -15,11 +15,11 @@ categories = [ [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-net-v$VERSION/embassy-net/src/" src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-net/src/" -features = ["nightly", "defmt", "tcp", "udp", "dns", "dhcpv4", "proto-ipv6", "medium-ethernet", "medium-ip", "medium-ieee802154", "igmp"] +features = ["defmt", "tcp", "udp", "dns", "dhcpv4", "proto-ipv6", "medium-ethernet", "medium-ip", "medium-ieee802154", "igmp"] target = "thumbv7em-none-eabi" [package.metadata.docs.rs] -features = ["nightly", "defmt", "tcp", "udp", "dns", "dhcpv4", "proto-ipv6", "medium-ethernet", "medium-ip", "medium-ieee802154", "igmp"] +features = ["defmt", "tcp", "udp", "dns", "dhcpv4", "proto-ipv6", "medium-ethernet", "medium-ip", "medium-ieee802154", "igmp"] [features] default = [] @@ -27,8 +27,6 @@ std = [] defmt = ["dep:defmt", "smoltcp/defmt", "embassy-net-driver/defmt", "heapless/defmt-03"] -nightly = ["dep:embedded-io-async", "dep:embedded-nal-async"] - udp = ["smoltcp/socket-udp"] tcp = ["smoltcp/socket-tcp"] dns = ["smoltcp/socket-dns", "smoltcp/proto-dns"] @@ -54,7 +52,7 @@ smoltcp = { git = "https://github.com/smoltcp-rs/smoltcp.git", rev = "b57e2f9e70 embassy-net-driver = { version = "0.2.0", path = "../embassy-net-driver" } embassy-time = { version = "0.1.5", path = "../embassy-time" } embassy-sync = { version = "0.4.0", path = "../embassy-sync" } -embedded-io-async = { version = "0.6.1", optional = true } +embedded-io-async = { version = "0.6.1" } managed = { version = "0.8.0", default-features = false, features = [ "map" ] } heapless = { version = "0.8", default-features = false } @@ -63,4 +61,4 @@ generic-array = { version = "0.14.4", default-features = false } stable_deref_trait = { version = "1.2.0", default-features = false } futures = { version = "0.3.17", default-features = false, features = [ "async-await" ] } atomic-pool = "1.0" -embedded-nal-async = { version = "0.7.1", optional = true } +embedded-nal-async = { version = "0.7.1" } diff --git a/embassy-net/build.rs b/embassy-net/build.rs new file mode 100644 index 00000000..78bd27ec --- /dev/null +++ b/embassy-net/build.rs @@ -0,0 +1,18 @@ +use std::env; +use std::ffi::OsString; +use std::process::Command; + +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + + let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc")); + + let output = Command::new(rustc) + .arg("--version") + .output() + .expect("failed to run `rustc --version`"); + + if String::from_utf8_lossy(&output.stdout).contains("nightly") { + println!("cargo:rustc-cfg=nightly"); + } +} diff --git a/embassy-net/src/dns.rs b/embassy-net/src/dns.rs index 69fc5cdf..a1151d5e 100644 --- a/embassy-net/src/dns.rs +++ b/embassy-net/src/dns.rs @@ -72,7 +72,6 @@ where } } -#[cfg(feature = "nightly")] impl<'a, D> embedded_nal_async::Dns for DnsSocket<'a, D> where D: Driver + 'static, diff --git a/embassy-net/src/lib.rs b/embassy-net/src/lib.rs index 58310b20..bf146864 100644 --- a/embassy-net/src/lib.rs +++ b/embassy-net/src/lib.rs @@ -1,6 +1,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -#![cfg_attr(feature = "nightly", feature(async_fn_in_trait, impl_trait_projections))] -#![cfg_attr(feature = "nightly", allow(stable_features, unknown_lints, async_fn_in_trait))] +#![cfg_attr(nightly, feature(async_fn_in_trait, impl_trait_projections))] +#![cfg_attr(nightly, allow(stable_features, unknown_lints))] +#![allow(async_fn_in_trait)] #![warn(missing_docs)] #![doc = include_str!("../README.md")] diff --git a/embassy-net/src/tcp.rs b/embassy-net/src/tcp.rs index 90fd08e9..dcfb5c96 100644 --- a/embassy-net/src/tcp.rs +++ b/embassy-net/src/tcp.rs @@ -515,7 +515,6 @@ impl<'d> TcpIo<'d> { } } -#[cfg(feature = "nightly")] mod embedded_io_impls { use super::*; @@ -584,7 +583,6 @@ mod embedded_io_impls { } /// TCP client compatible with `embedded-nal-async` traits. -#[cfg(feature = "nightly")] pub mod client { use core::cell::{Cell, UnsafeCell}; use core::mem::MaybeUninit; diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index a75a94f0..bde15267 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" src_base = "https://github.com/embassy-rs/embassy/blob/embassy-nrf-v$VERSION/embassy-nrf/src/" src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-nrf/src/" -features = ["nightly", "time", "defmt", "unstable-pac", "unstable-traits", "gpiote", "time-driver-rtc1"] +features = ["time", "defmt", "unstable-pac", "gpiote", "time-driver-rtc1"] flavors = [ { regex_feature = "nrf52.*", target = "thumbv7em-none-eabihf" }, { regex_feature = "nrf53.*", target = "thumbv8m.main-none-eabihf" }, @@ -32,10 +32,7 @@ rt = [ time = ["dep:embassy-time"] -defmt = ["dep:defmt", "embassy-hal-internal/defmt", "embassy-sync/defmt", "embassy-usb-driver?/defmt", "embassy-embedded-hal/defmt"] - -# Enable nightly-only features -nightly = ["embedded-hal-1", "embedded-hal-async", "dep:embassy-usb-driver", "embedded-storage-async", "dep:embedded-io-async", "embassy-embedded-hal/nightly"] +defmt = ["dep:defmt", "embassy-hal-internal/defmt", "embassy-sync/defmt", "embassy-usb-driver/defmt", "embassy-embedded-hal/defmt"] # Reexport the PAC for the currently enabled chip at `embassy_nrf::pac`. # This is unstable because semver-minor (non-breaking) releases of embassy-nrf may major-bump (breaking) the PAC version. @@ -43,10 +40,6 @@ nightly = ["embedded-hal-1", "embedded-hal-async", "dep:embassy-usb-driver", "em # There are no plans to make this stable. unstable-pac = [] -# Implement embedded-hal 1.0 alpha traits. -# Implement embedded-hal-async traits if `nightly` is set as well. -unstable-traits = ["embedded-hal-1"] - nrf52805 = ["nrf52805-pac", "_nrf52"] nrf52810 = ["nrf52810-pac", "_nrf52"] nrf52811 = ["nrf52811-pac", "_nrf52"] @@ -98,13 +91,13 @@ embassy-time = { version = "0.1.5", path = "../embassy-time", optional = true } embassy-sync = { version = "0.4.0", path = "../embassy-sync" } embassy-hal-internal = {version = "0.1.0", path = "../embassy-hal-internal", features = ["cortex-m", "prio-bits-3"] } embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } -embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver", optional=true } +embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver" } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2", optional = true} -embedded-hal-async = { version = "=1.0.0-rc.2", optional = true} +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } +embedded-hal-async = { version = "=1.0.0-rc.2" } embedded-io = { version = "0.6.0" } -embedded-io-async = { version = "0.6.1", optional = true } +embedded-io-async = { version = "0.6.1" } defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } @@ -114,7 +107,7 @@ critical-section = "1.1" rand_core = "0.6.3" fixed = "1.10.0" embedded-storage = "0.3.0" -embedded-storage-async = { version = "0.4.0", optional = true } +embedded-storage-async = "0.4.0" cfg-if = "1.0.0" nrf52805-pac = { version = "0.12.0", optional = true } diff --git a/embassy-nrf/src/buffered_uarte.rs b/embassy-nrf/src/buffered_uarte.rs index e4b556f0..4ac622d3 100644 --- a/embassy-nrf/src/buffered_uarte.rs +++ b/embassy-nrf/src/buffered_uarte.rs @@ -607,7 +607,6 @@ impl<'u, 'd, U: UarteInstance, T: TimerInstance> BufferedUarteRx<'u, 'd, U, T> { } } -#[cfg(feature = "nightly")] mod _embedded_io { use super::*; diff --git a/embassy-nrf/src/chips/nrf52820.rs b/embassy-nrf/src/chips/nrf52820.rs index 0ecddaf3..85184d48 100644 --- a/embassy-nrf/src/chips/nrf52820.rs +++ b/embassy-nrf/src/chips/nrf52820.rs @@ -131,7 +131,6 @@ embassy_hal_internal::peripherals! { QDEC, } -#[cfg(feature = "nightly")] impl_usb!(USBD, USBD, USBD); impl_uarte!(UARTE0, UARTE0, UARTE0_UART0); diff --git a/embassy-nrf/src/chips/nrf52833.rs b/embassy-nrf/src/chips/nrf52833.rs index b8830b33..342ae8b1 100644 --- a/embassy-nrf/src/chips/nrf52833.rs +++ b/embassy-nrf/src/chips/nrf52833.rs @@ -171,7 +171,6 @@ embassy_hal_internal::peripherals! { I2S, } -#[cfg(feature = "nightly")] impl_usb!(USBD, USBD, USBD); impl_uarte!(UARTE0, UARTE0, UARTE0_UART0); diff --git a/embassy-nrf/src/chips/nrf52840.rs b/embassy-nrf/src/chips/nrf52840.rs index a490cb07..a5cbd798 100644 --- a/embassy-nrf/src/chips/nrf52840.rs +++ b/embassy-nrf/src/chips/nrf52840.rs @@ -174,7 +174,6 @@ embassy_hal_internal::peripherals! { I2S, } -#[cfg(feature = "nightly")] impl_usb!(USBD, USBD, USBD); impl_uarte!(UARTE0, UARTE0, UARTE0_UART0); diff --git a/embassy-nrf/src/chips/nrf5340_app.rs b/embassy-nrf/src/chips/nrf5340_app.rs index 5e9a8ed0..62c74bb6 100644 --- a/embassy-nrf/src/chips/nrf5340_app.rs +++ b/embassy-nrf/src/chips/nrf5340_app.rs @@ -382,7 +382,6 @@ embassy_hal_internal::peripherals! { P1_15, } -#[cfg(feature = "nightly")] impl_usb!(USBD, USBD, USBD); impl_uarte!(SERIAL0, UARTE0, SERIAL0); diff --git a/embassy-nrf/src/gpio.rs b/embassy-nrf/src/gpio.rs index ea2b7609..cf622528 100644 --- a/embassy-nrf/src/gpio.rs +++ b/embassy-nrf/src/gpio.rs @@ -566,82 +566,77 @@ mod eh02 { } } -#[cfg(feature = "unstable-traits")] -mod eh1 { - use super::*; +impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> { + type Error = Infallible; +} - impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> { - type Error = Infallible; +impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { + fn is_high(&self) -> Result { + Ok(self.is_high()) } - impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { - fn is_high(&self) -> Result { - Ok(self.is_high()) - } - - fn is_low(&self) -> Result { - Ok(self.is_low()) - } - } - - impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Output<'d, T> { - type Error = Infallible; - } - - impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(self.set_high()) - } - - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(self.set_low()) - } - } - - impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { - fn is_set_high(&self) -> Result { - Ok(self.is_set_high()) - } - - fn is_set_low(&self) -> Result { - Ok(self.is_set_low()) - } - } - - impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { - type Error = Infallible; - } - - /// Implement [`InputPin`] for [`Flex`]; - /// - /// If the pin is not in input mode the result is unspecified. - impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { - fn is_high(&self) -> Result { - Ok(self.is_high()) - } - - fn is_low(&self) -> Result { - Ok(self.is_low()) - } - } - - impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(self.set_high()) - } - - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(self.set_low()) - } - } - - impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { - fn is_set_high(&self) -> Result { - Ok(self.is_set_high()) - } - - fn is_set_low(&self) -> Result { - Ok(self.is_set_low()) - } + fn is_low(&self) -> Result { + Ok(self.is_low()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Output<'d, T> { + type Error = Infallible; +} + +impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { + fn set_high(&mut self) -> Result<(), Self::Error> { + Ok(self.set_high()) + } + + fn set_low(&mut self) -> Result<(), Self::Error> { + Ok(self.set_low()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { + fn is_set_high(&self) -> Result { + Ok(self.is_set_high()) + } + + fn is_set_low(&self) -> Result { + Ok(self.is_set_low()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { + type Error = Infallible; +} + +/// Implement [`InputPin`] for [`Flex`]; +/// +/// If the pin is not in input mode the result is unspecified. +impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { + fn is_high(&self) -> Result { + Ok(self.is_high()) + } + + fn is_low(&self) -> Result { + Ok(self.is_low()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { + fn set_high(&mut self) -> Result<(), Self::Error> { + Ok(self.set_high()) + } + + fn set_low(&mut self) -> Result<(), Self::Error> { + Ok(self.set_low()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { + fn is_set_high(&self) -> Result { + Ok(self.is_set_high()) + } + + fn is_set_low(&self) -> Result { + Ok(self.is_set_low()) } } diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index d16b4a43..fd629ea7 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs @@ -490,70 +490,60 @@ mod eh02 { } } -#[cfg(feature = "unstable-traits")] -mod eh1 { - use super::*; +impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::ErrorType for InputChannel<'d, C, T> { + type Error = Infallible; +} - impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::ErrorType for InputChannel<'d, C, T> { - type Error = Infallible; +impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::InputPin for InputChannel<'d, C, T> { + fn is_high(&self) -> Result { + Ok(self.pin.is_high()) } - impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::InputPin for InputChannel<'d, C, T> { - fn is_high(&self) -> Result { - Ok(self.pin.is_high()) - } - - fn is_low(&self) -> Result { - Ok(self.pin.is_low()) - } + fn is_low(&self) -> Result { + Ok(self.pin.is_low()) } } -#[cfg(all(feature = "unstable-traits", feature = "nightly"))] -mod eha { - use super::*; - - impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> { - async fn wait_for_high(&mut self) -> Result<(), Self::Error> { - Ok(self.wait_for_high().await) - } - - async fn wait_for_low(&mut self) -> Result<(), Self::Error> { - Ok(self.wait_for_low().await) - } - - async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> { - Ok(self.wait_for_rising_edge().await) - } - - async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> { - Ok(self.wait_for_falling_edge().await) - } - - async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> { - Ok(self.wait_for_any_edge().await) - } +impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> { + async fn wait_for_high(&mut self) -> Result<(), Self::Error> { + Ok(self.wait_for_high().await) } - impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Flex<'d, T> { - async fn wait_for_high(&mut self) -> Result<(), Self::Error> { - Ok(self.wait_for_high().await) - } + async fn wait_for_low(&mut self) -> Result<(), Self::Error> { + Ok(self.wait_for_low().await) + } - async fn wait_for_low(&mut self) -> Result<(), Self::Error> { - Ok(self.wait_for_low().await) - } + async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> { + Ok(self.wait_for_rising_edge().await) + } - async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> { - Ok(self.wait_for_rising_edge().await) - } + async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> { + Ok(self.wait_for_falling_edge().await) + } - async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> { - Ok(self.wait_for_falling_edge().await) - } - - async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> { - Ok(self.wait_for_any_edge().await) - } + async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> { + Ok(self.wait_for_any_edge().await) + } +} + +impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Flex<'d, T> { + async fn wait_for_high(&mut self) -> Result<(), Self::Error> { + Ok(self.wait_for_high().await) + } + + async fn wait_for_low(&mut self) -> Result<(), Self::Error> { + Ok(self.wait_for_low().await) + } + + async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> { + Ok(self.wait_for_rising_edge().await) + } + + async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> { + Ok(self.wait_for_falling_edge().await) + } + + async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> { + Ok(self.wait_for_any_edge().await) } } diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs index 71528111..ed8aad89 100644 --- a/embassy-nrf/src/lib.rs +++ b/embassy-nrf/src/lib.rs @@ -1,6 +1,5 @@ #![no_std] -#![cfg_attr(feature = "nightly", feature(async_fn_in_trait, impl_trait_projections))] -#![cfg_attr(feature = "nightly", allow(stable_features, unknown_lints, async_fn_in_trait))] +#![allow(async_fn_in_trait)] #![doc = include_str!("../README.md")] #![warn(missing_docs)] @@ -76,7 +75,6 @@ pub mod uarte; feature = "nrf52833", feature = "nrf52840" ))] -#[cfg(feature = "nightly")] pub mod usb; #[cfg(not(feature = "_nrf5340"))] pub mod wdt; diff --git a/embassy-nrf/src/qspi.rs b/embassy-nrf/src/qspi.rs index 36ee33f6..add093b6 100644 --- a/embassy-nrf/src/qspi.rs +++ b/embassy-nrf/src/qspi.rs @@ -585,7 +585,6 @@ impl<'d, T: Instance> NorFlash for Qspi<'d, T> { } } -#[cfg(feature = "nightly")] mod _eh1 { use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash}; diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs index caf681d9..5d3c3268 100644 --- a/embassy-nrf/src/spim.rs +++ b/embassy-nrf/src/spim.rs @@ -495,72 +495,61 @@ mod eh02 { } } -#[cfg(feature = "unstable-traits")] -mod eh1 { - use super::*; - - impl embedded_hal_1::spi::Error for Error { - fn kind(&self) -> embedded_hal_1::spi::ErrorKind { - match *self { - Self::TxBufferTooLong => embedded_hal_1::spi::ErrorKind::Other, - Self::RxBufferTooLong => embedded_hal_1::spi::ErrorKind::Other, - Self::BufferNotInRAM => embedded_hal_1::spi::ErrorKind::Other, - } - } - } - - impl<'d, T: Instance> embedded_hal_1::spi::ErrorType for Spim<'d, T> { - type Error = Error; - } - - impl<'d, T: Instance> embedded_hal_1::spi::SpiBus for Spim<'d, T> { - fn flush(&mut self) -> Result<(), Self::Error> { - Ok(()) - } - - fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { - self.blocking_transfer(words, &[]) - } - - fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> { - self.blocking_write(words) - } - - fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> { - self.blocking_transfer(read, write) - } - - fn transfer_in_place(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { - self.blocking_transfer_in_place(words) +impl embedded_hal_1::spi::Error for Error { + fn kind(&self) -> embedded_hal_1::spi::ErrorKind { + match *self { + Self::TxBufferTooLong => embedded_hal_1::spi::ErrorKind::Other, + Self::RxBufferTooLong => embedded_hal_1::spi::ErrorKind::Other, + Self::BufferNotInRAM => embedded_hal_1::spi::ErrorKind::Other, } } } -#[cfg(all(feature = "unstable-traits", feature = "nightly"))] -mod eha { +impl<'d, T: Instance> embedded_hal_1::spi::ErrorType for Spim<'d, T> { + type Error = Error; +} - use super::*; +impl<'d, T: Instance> embedded_hal_1::spi::SpiBus for Spim<'d, T> { + fn flush(&mut self) -> Result<(), Self::Error> { + Ok(()) + } - impl<'d, T: Instance> embedded_hal_async::spi::SpiBus for Spim<'d, T> { - async fn flush(&mut self) -> Result<(), Error> { - Ok(()) - } + fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { + self.blocking_transfer(words, &[]) + } - async fn read(&mut self, words: &mut [u8]) -> Result<(), Error> { - self.read(words).await - } + fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> { + self.blocking_write(words) + } - async fn write(&mut self, data: &[u8]) -> Result<(), Error> { - self.write(data).await - } + fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> { + self.blocking_transfer(read, write) + } - async fn transfer(&mut self, rx: &mut [u8], tx: &[u8]) -> Result<(), Error> { - self.transfer(rx, tx).await - } + fn transfer_in_place(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { + self.blocking_transfer_in_place(words) + } +} - async fn transfer_in_place(&mut self, words: &mut [u8]) -> Result<(), Error> { - self.transfer_in_place(words).await - } +impl<'d, T: Instance> embedded_hal_async::spi::SpiBus for Spim<'d, T> { + async fn flush(&mut self) -> Result<(), Error> { + Ok(()) + } + + async fn read(&mut self, words: &mut [u8]) -> Result<(), Error> { + self.read(words).await + } + + async fn write(&mut self, data: &[u8]) -> Result<(), Error> { + self.write(data).await + } + + async fn transfer(&mut self, rx: &mut [u8], tx: &[u8]) -> Result<(), Error> { + self.transfer(rx, tx).await + } + + async fn transfer_in_place(&mut self, words: &mut [u8]) -> Result<(), Error> { + self.transfer_in_place(words).await } } diff --git a/embassy-nrf/src/twim.rs b/embassy-nrf/src/twim.rs index 919bb4ab..da8e15d0 100644 --- a/embassy-nrf/src/twim.rs +++ b/embassy-nrf/src/twim.rs @@ -810,81 +810,72 @@ mod eh02 { } } -#[cfg(feature = "unstable-traits")] -mod eh1 { - use super::*; - - impl embedded_hal_1::i2c::Error for Error { - fn kind(&self) -> embedded_hal_1::i2c::ErrorKind { - match *self { - Self::TxBufferTooLong => embedded_hal_1::i2c::ErrorKind::Other, - Self::RxBufferTooLong => embedded_hal_1::i2c::ErrorKind::Other, - Self::Transmit => embedded_hal_1::i2c::ErrorKind::Other, - Self::Receive => embedded_hal_1::i2c::ErrorKind::Other, - Self::BufferNotInRAM => embedded_hal_1::i2c::ErrorKind::Other, - Self::AddressNack => { - embedded_hal_1::i2c::ErrorKind::NoAcknowledge(embedded_hal_1::i2c::NoAcknowledgeSource::Address) - } - Self::DataNack => { - embedded_hal_1::i2c::ErrorKind::NoAcknowledge(embedded_hal_1::i2c::NoAcknowledgeSource::Data) - } - Self::Overrun => embedded_hal_1::i2c::ErrorKind::Overrun, - Self::Timeout => embedded_hal_1::i2c::ErrorKind::Other, +impl embedded_hal_1::i2c::Error for Error { + fn kind(&self) -> embedded_hal_1::i2c::ErrorKind { + match *self { + Self::TxBufferTooLong => embedded_hal_1::i2c::ErrorKind::Other, + Self::RxBufferTooLong => embedded_hal_1::i2c::ErrorKind::Other, + Self::Transmit => embedded_hal_1::i2c::ErrorKind::Other, + Self::Receive => embedded_hal_1::i2c::ErrorKind::Other, + Self::BufferNotInRAM => embedded_hal_1::i2c::ErrorKind::Other, + Self::AddressNack => { + embedded_hal_1::i2c::ErrorKind::NoAcknowledge(embedded_hal_1::i2c::NoAcknowledgeSource::Address) } - } - } - - impl<'d, T: Instance> embedded_hal_1::i2c::ErrorType for Twim<'d, T> { - type Error = Error; - } - - impl<'d, T: Instance> embedded_hal_1::i2c::I2c for Twim<'d, T> { - fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> { - self.blocking_read(address, buffer) - } - - fn write(&mut self, address: u8, buffer: &[u8]) -> Result<(), Self::Error> { - self.blocking_write(address, buffer) - } - - fn write_read(&mut self, address: u8, wr_buffer: &[u8], rd_buffer: &mut [u8]) -> Result<(), Self::Error> { - self.blocking_write_read(address, wr_buffer, rd_buffer) - } - - fn transaction<'a>( - &mut self, - _address: u8, - _operations: &mut [embedded_hal_1::i2c::Operation<'a>], - ) -> Result<(), Self::Error> { - todo!(); + Self::DataNack => { + embedded_hal_1::i2c::ErrorKind::NoAcknowledge(embedded_hal_1::i2c::NoAcknowledgeSource::Data) + } + Self::Overrun => embedded_hal_1::i2c::ErrorKind::Overrun, + Self::Timeout => embedded_hal_1::i2c::ErrorKind::Other, } } } -#[cfg(all(feature = "unstable-traits", feature = "nightly"))] -mod eha { - use super::*; - impl<'d, T: Instance> embedded_hal_async::i2c::I2c for Twim<'d, T> { - async fn read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Self::Error> { - self.read(address, read).await - } +impl<'d, T: Instance> embedded_hal_1::i2c::ErrorType for Twim<'d, T> { + type Error = Error; +} - async fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Self::Error> { - self.write(address, write).await - } - async fn write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error> { - self.write_read(address, write, read).await - } +impl<'d, T: Instance> embedded_hal_1::i2c::I2c for Twim<'d, T> { + fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> { + self.blocking_read(address, buffer) + } - async fn transaction( - &mut self, - address: u8, - operations: &mut [embedded_hal_1::i2c::Operation<'_>], - ) -> Result<(), Self::Error> { - let _ = address; - let _ = operations; - todo!() - } + fn write(&mut self, address: u8, buffer: &[u8]) -> Result<(), Self::Error> { + self.blocking_write(address, buffer) + } + + fn write_read(&mut self, address: u8, wr_buffer: &[u8], rd_buffer: &mut [u8]) -> Result<(), Self::Error> { + self.blocking_write_read(address, wr_buffer, rd_buffer) + } + + fn transaction<'a>( + &mut self, + _address: u8, + _operations: &mut [embedded_hal_1::i2c::Operation<'a>], + ) -> Result<(), Self::Error> { + todo!(); + } +} + +impl<'d, T: Instance> embedded_hal_async::i2c::I2c for Twim<'d, T> { + async fn read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Self::Error> { + self.read(address, read).await + } + + async fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Self::Error> { + self.write(address, write).await + } + async fn write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error> { + self.write_read(address, write, read).await + } + + async fn transaction( + &mut self, + address: u8, + operations: &mut [embedded_hal_1::i2c::Operation<'_>], + ) -> Result<(), Self::Error> { + let _ = address; + let _ = operations; + todo!() } } diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index 35ea77f0..1a2945a7 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml @@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0" [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-rp-v$VERSION/embassy-rp/src/" src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-rp/src/" -features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "time-driver"] +features = ["defmt", "unstable-pac", "time-driver"] flavors = [ { name = "rp2040", target = "thumbv6m-none-eabi" }, ] @@ -16,7 +16,7 @@ flavors = [ default = [ "rt" ] rt = [ "rp-pac/rt" ] -defmt = ["dep:defmt", "embassy-usb-driver?/defmt", "embassy-hal-internal/defmt"] +defmt = ["dep:defmt", "embassy-usb-driver/defmt", "embassy-hal-internal/defmt"] # critical section that is safe for multicore use critical-section-impl = ["critical-section/restore-state-u8"] @@ -51,20 +51,13 @@ qspi-as-gpio = [] # This allows the flash driver to not force pausing execution on both cores when doing flash operations. run-from-ram = [] -# Enable nightly-only features -nightly = ["embedded-hal-1", "embedded-hal-async", "embedded-storage-async", "embassy-embedded-hal/nightly", "dep:embassy-usb-driver", "dep:embedded-io-async"] - -# Implement embedded-hal 1.0 alpha traits. -# Implement embedded-hal-async traits if `nightly` is set as well. -unstable-traits = ["embedded-hal-1", "embedded-hal-nb"] - [dependencies] embassy-sync = { version = "0.4.0", path = "../embassy-sync" } embassy-time = { version = "0.1.5", path = "../embassy-time", features = [ "tick-hz-1_000_000" ] } embassy-futures = { version = "0.1.0", path = "../embassy-futures" } embassy-hal-internal = {version = "0.1.0", path = "../embassy-hal-internal", features = ["cortex-m", "prio-bits-2"] } embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } -embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver", optional = true } +embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver" } atomic-polyfill = "1.0.1" defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } @@ -76,18 +69,18 @@ critical-section = "1.1" futures = { version = "0.3.17", default-features = false, features = ["async-await"] } chrono = { version = "0.4", default-features = false, optional = true } embedded-io = { version = "0.6.0" } -embedded-io-async = { version = "0.6.1", optional = true } +embedded-io-async = { version = "0.6.1" } embedded-storage = { version = "0.3" } -embedded-storage-async = { version = "0.4.0", optional = true } +embedded-storage-async = { version = "0.4.0" } rand_core = "0.6.4" fixed = "1.23.1" rp-pac = { version = "6" } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2", optional = true} -embedded-hal-async = { version = "=1.0.0-rc.2", optional = true} -embedded-hal-nb = { version = "=1.0.0-rc.2", optional = true} +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } +embedded-hal-async = { version = "=1.0.0-rc.2" } +embedded-hal-nb = { version = "=1.0.0-rc.2" } pio-proc = {version= "0.2" } pio = {version= "0.2.1" } diff --git a/embassy-rp/src/flash.rs b/embassy-rp/src/flash.rs index 8fb5542f..1b20561d 100644 --- a/embassy-rp/src/flash.rs +++ b/embassy-rp/src/flash.rs @@ -352,7 +352,6 @@ impl<'d, T: Instance, M: Mode, const FLASH_SIZE: usize> NorFlash for Flash<'d, T } } -#[cfg(feature = "nightly")] impl<'d, T: Instance, const FLASH_SIZE: usize> embedded_storage_async::nor_flash::ReadNorFlash for Flash<'d, T, Async, FLASH_SIZE> { @@ -367,7 +366,6 @@ impl<'d, T: Instance, const FLASH_SIZE: usize> embedded_storage_async::nor_flash } } -#[cfg(feature = "nightly")] impl<'d, T: Instance, const FLASH_SIZE: usize> embedded_storage_async::nor_flash::NorFlash for Flash<'d, T, Async, FLASH_SIZE> { diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs index ee7e03e9..9034f3f3 100644 --- a/embassy-rp/src/gpio.rs +++ b/embassy-rp/src/gpio.rs @@ -1,4 +1,5 @@ #![macro_use] +use core::convert::Infallible; use core::future::Future; use core::pin::Pin as FuturePin; use core::task::{Context, Poll}; @@ -1036,217 +1037,207 @@ mod eh02 { } } -#[cfg(feature = "unstable-traits")] -mod eh1 { - use core::convert::Infallible; +impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> { + type Error = Infallible; +} - use super::*; - - impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> { - type Error = Infallible; +impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { + fn is_high(&self) -> Result { + Ok(self.is_high()) } - impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { - fn is_high(&self) -> Result { - Ok(self.is_high()) - } - - fn is_low(&self) -> Result { - Ok(self.is_low()) - } - } - - impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Output<'d, T> { - type Error = Infallible; - } - - impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(self.set_high()) - } - - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(self.set_low()) - } - } - - impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { - fn is_set_high(&self) -> Result { - Ok(self.is_set_high()) - } - - fn is_set_low(&self) -> Result { - Ok(self.is_set_low()) - } - } - - impl<'d, T: Pin> embedded_hal_1::digital::ToggleableOutputPin for Output<'d, T> { - fn toggle(&mut self) -> Result<(), Self::Error> { - Ok(self.toggle()) - } - } - - impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for OutputOpenDrain<'d, T> { - type Error = Infallible; - } - - impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> { - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(self.set_high()) - } - - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(self.set_low()) - } - } - - impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> { - fn is_set_high(&self) -> Result { - Ok(self.is_set_high()) - } - - fn is_set_low(&self) -> Result { - Ok(self.is_set_low()) - } - } - - impl<'d, T: Pin> embedded_hal_1::digital::ToggleableOutputPin for OutputOpenDrain<'d, T> { - fn toggle(&mut self) -> Result<(), Self::Error> { - Ok(self.toggle()) - } - } - - impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> { - fn is_high(&self) -> Result { - Ok(self.is_high()) - } - - fn is_low(&self) -> Result { - Ok(self.is_low()) - } - } - - impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { - type Error = Infallible; - } - - impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { - fn is_high(&self) -> Result { - Ok(self.is_high()) - } - - fn is_low(&self) -> Result { - Ok(self.is_low()) - } - } - - impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(self.set_high()) - } - - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(self.set_low()) - } - } - - impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { - fn is_set_high(&self) -> Result { - Ok(self.is_set_high()) - } - - fn is_set_low(&self) -> Result { - Ok(self.is_set_low()) - } - } - - impl<'d, T: Pin> embedded_hal_1::digital::ToggleableOutputPin for Flex<'d, T> { - fn toggle(&mut self) -> Result<(), Self::Error> { - Ok(self.toggle()) - } - } - - #[cfg(feature = "nightly")] - impl<'d, T: Pin> embedded_hal_async::digital::Wait for Flex<'d, T> { - async fn wait_for_high(&mut self) -> Result<(), Self::Error> { - self.wait_for_high().await; - Ok(()) - } - - async fn wait_for_low(&mut self) -> Result<(), Self::Error> { - self.wait_for_low().await; - Ok(()) - } - - async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> { - self.wait_for_rising_edge().await; - Ok(()) - } - - async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> { - self.wait_for_falling_edge().await; - Ok(()) - } - - async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> { - self.wait_for_any_edge().await; - Ok(()) - } - } - - #[cfg(feature = "nightly")] - impl<'d, T: Pin> embedded_hal_async::digital::Wait for Input<'d, T> { - async fn wait_for_high(&mut self) -> Result<(), Self::Error> { - self.wait_for_high().await; - Ok(()) - } - - async fn wait_for_low(&mut self) -> Result<(), Self::Error> { - self.wait_for_low().await; - Ok(()) - } - - async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> { - self.wait_for_rising_edge().await; - Ok(()) - } - - async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> { - self.wait_for_falling_edge().await; - Ok(()) - } - - async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> { - self.wait_for_any_edge().await; - Ok(()) - } - } - - #[cfg(feature = "nightly")] - impl<'d, T: Pin> embedded_hal_async::digital::Wait for OutputOpenDrain<'d, T> { - async fn wait_for_high(&mut self) -> Result<(), Self::Error> { - self.wait_for_high().await; - Ok(()) - } - - async fn wait_for_low(&mut self) -> Result<(), Self::Error> { - self.wait_for_low().await; - Ok(()) - } - - async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> { - self.wait_for_rising_edge().await; - Ok(()) - } - - async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> { - self.wait_for_falling_edge().await; - Ok(()) - } - - async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> { - self.wait_for_any_edge().await; - Ok(()) - } + fn is_low(&self) -> Result { + Ok(self.is_low()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Output<'d, T> { + type Error = Infallible; +} + +impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { + fn set_high(&mut self) -> Result<(), Self::Error> { + Ok(self.set_high()) + } + + fn set_low(&mut self) -> Result<(), Self::Error> { + Ok(self.set_low()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { + fn is_set_high(&self) -> Result { + Ok(self.is_set_high()) + } + + fn is_set_low(&self) -> Result { + Ok(self.is_set_low()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::ToggleableOutputPin for Output<'d, T> { + fn toggle(&mut self) -> Result<(), Self::Error> { + Ok(self.toggle()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for OutputOpenDrain<'d, T> { + type Error = Infallible; +} + +impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> { + fn set_high(&mut self) -> Result<(), Self::Error> { + Ok(self.set_high()) + } + + fn set_low(&mut self) -> Result<(), Self::Error> { + Ok(self.set_low()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> { + fn is_set_high(&self) -> Result { + Ok(self.is_set_high()) + } + + fn is_set_low(&self) -> Result { + Ok(self.is_set_low()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::ToggleableOutputPin for OutputOpenDrain<'d, T> { + fn toggle(&mut self) -> Result<(), Self::Error> { + Ok(self.toggle()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> { + fn is_high(&self) -> Result { + Ok(self.is_high()) + } + + fn is_low(&self) -> Result { + Ok(self.is_low()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { + type Error = Infallible; +} + +impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { + fn is_high(&self) -> Result { + Ok(self.is_high()) + } + + fn is_low(&self) -> Result { + Ok(self.is_low()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { + fn set_high(&mut self) -> Result<(), Self::Error> { + Ok(self.set_high()) + } + + fn set_low(&mut self) -> Result<(), Self::Error> { + Ok(self.set_low()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { + fn is_set_high(&self) -> Result { + Ok(self.is_set_high()) + } + + fn is_set_low(&self) -> Result { + Ok(self.is_set_low()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::ToggleableOutputPin for Flex<'d, T> { + fn toggle(&mut self) -> Result<(), Self::Error> { + Ok(self.toggle()) + } +} + +impl<'d, T: Pin> embedded_hal_async::digital::Wait for Flex<'d, T> { + async fn wait_for_high(&mut self) -> Result<(), Self::Error> { + self.wait_for_high().await; + Ok(()) + } + + async fn wait_for_low(&mut self) -> Result<(), Self::Error> { + self.wait_for_low().await; + Ok(()) + } + + async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> { + self.wait_for_rising_edge().await; + Ok(()) + } + + async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> { + self.wait_for_falling_edge().await; + Ok(()) + } + + async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> { + self.wait_for_any_edge().await; + Ok(()) + } +} + +impl<'d, T: Pin> embedded_hal_async::digital::Wait for Input<'d, T> { + async fn wait_for_high(&mut self) -> Result<(), Self::Error> { + self.wait_for_high().await; + Ok(()) + } + + async fn wait_for_low(&mut self) -> Result<(), Self::Error> { + self.wait_for_low().await; + Ok(()) + } + + async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> { + self.wait_for_rising_edge().await; + Ok(()) + } + + async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> { + self.wait_for_falling_edge().await; + Ok(()) + } + + async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> { + self.wait_for_any_edge().await; + Ok(()) + } +} + +impl<'d, T: Pin> embedded_hal_async::digital::Wait for OutputOpenDrain<'d, T> { + async fn wait_for_high(&mut self) -> Result<(), Self::Error> { + self.wait_for_high().await; + Ok(()) + } + + async fn wait_for_low(&mut self) -> Result<(), Self::Error> { + self.wait_for_low().await; + Ok(()) + } + + async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> { + self.wait_for_rising_edge().await; + Ok(()) + } + + async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> { + self.wait_for_falling_edge().await; + Ok(()) + } + + async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> { + self.wait_for_any_edge().await; + Ok(()) } } diff --git a/embassy-rp/src/i2c.rs b/embassy-rp/src/i2c.rs index 4fe4b27e..15095236 100644 --- a/embassy-rp/src/i2c.rs +++ b/embassy-rp/src/i2c.rs @@ -588,167 +588,157 @@ impl<'d, T: Instance + 'd, M: Mode> I2c<'d, T, M> { } } -mod eh02 { - use super::*; +impl<'d, T: Instance, M: Mode> embedded_hal_02::blocking::i2c::Read for I2c<'d, T, M> { + type Error = Error; - impl<'d, T: Instance, M: Mode> embedded_hal_02::blocking::i2c::Read for I2c<'d, T, M> { - type Error = Error; - - fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> { - self.blocking_read(address, buffer) - } + fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> { + self.blocking_read(address, buffer) } +} - impl<'d, T: Instance, M: Mode> embedded_hal_02::blocking::i2c::Write for I2c<'d, T, M> { - type Error = Error; +impl<'d, T: Instance, M: Mode> embedded_hal_02::blocking::i2c::Write for I2c<'d, T, M> { + type Error = Error; - fn write(&mut self, address: u8, bytes: &[u8]) -> Result<(), Self::Error> { - self.blocking_write(address, bytes) - } + fn write(&mut self, address: u8, bytes: &[u8]) -> Result<(), Self::Error> { + self.blocking_write(address, bytes) } +} - impl<'d, T: Instance, M: Mode> embedded_hal_02::blocking::i2c::WriteRead for I2c<'d, T, M> { - type Error = Error; +impl<'d, T: Instance, M: Mode> embedded_hal_02::blocking::i2c::WriteRead for I2c<'d, T, M> { + type Error = Error; - fn write_read(&mut self, address: u8, bytes: &[u8], buffer: &mut [u8]) -> Result<(), Self::Error> { - self.blocking_write_read(address, bytes, buffer) - } + fn write_read(&mut self, address: u8, bytes: &[u8], buffer: &mut [u8]) -> Result<(), Self::Error> { + self.blocking_write_read(address, bytes, buffer) } +} - impl<'d, T: Instance, M: Mode> embedded_hal_02::blocking::i2c::Transactional for I2c<'d, T, M> { - type Error = Error; +impl<'d, T: Instance, M: Mode> embedded_hal_02::blocking::i2c::Transactional for I2c<'d, T, M> { + type Error = Error; - fn exec( - &mut self, - address: u8, - operations: &mut [embedded_hal_02::blocking::i2c::Operation<'_>], - ) -> Result<(), Self::Error> { - Self::setup(address.into())?; - for i in 0..operations.len() { - let last = i == operations.len() - 1; - match &mut operations[i] { - embedded_hal_02::blocking::i2c::Operation::Read(buf) => { - self.read_blocking_internal(buf, false, last)? - } - embedded_hal_02::blocking::i2c::Operation::Write(buf) => self.write_blocking_internal(buf, last)?, + fn exec( + &mut self, + address: u8, + operations: &mut [embedded_hal_02::blocking::i2c::Operation<'_>], + ) -> Result<(), Self::Error> { + Self::setup(address.into())?; + for i in 0..operations.len() { + let last = i == operations.len() - 1; + match &mut operations[i] { + embedded_hal_02::blocking::i2c::Operation::Read(buf) => { + self.read_blocking_internal(buf, false, last)? } + embedded_hal_02::blocking::i2c::Operation::Write(buf) => self.write_blocking_internal(buf, last)?, } - Ok(()) + } + Ok(()) + } +} + +impl embedded_hal_1::i2c::Error for Error { + fn kind(&self) -> embedded_hal_1::i2c::ErrorKind { + match *self { + Self::Abort(AbortReason::ArbitrationLoss) => embedded_hal_1::i2c::ErrorKind::ArbitrationLoss, + Self::Abort(AbortReason::NoAcknowledge) => { + embedded_hal_1::i2c::ErrorKind::NoAcknowledge(embedded_hal_1::i2c::NoAcknowledgeSource::Address) + } + Self::Abort(AbortReason::TxNotEmpty(_)) => embedded_hal_1::i2c::ErrorKind::Other, + Self::Abort(AbortReason::Other(_)) => embedded_hal_1::i2c::ErrorKind::Other, + Self::InvalidReadBufferLength => embedded_hal_1::i2c::ErrorKind::Other, + Self::InvalidWriteBufferLength => embedded_hal_1::i2c::ErrorKind::Other, + Self::AddressOutOfRange(_) => embedded_hal_1::i2c::ErrorKind::Other, + Self::AddressReserved(_) => embedded_hal_1::i2c::ErrorKind::Other, } } } -#[cfg(feature = "unstable-traits")] -mod eh1 { - use super::*; +impl<'d, T: Instance, M: Mode> embedded_hal_1::i2c::ErrorType for I2c<'d, T, M> { + type Error = Error; +} - impl embedded_hal_1::i2c::Error for Error { - fn kind(&self) -> embedded_hal_1::i2c::ErrorKind { - match *self { - Self::Abort(AbortReason::ArbitrationLoss) => embedded_hal_1::i2c::ErrorKind::ArbitrationLoss, - Self::Abort(AbortReason::NoAcknowledge) => { - embedded_hal_1::i2c::ErrorKind::NoAcknowledge(embedded_hal_1::i2c::NoAcknowledgeSource::Address) - } - Self::Abort(AbortReason::TxNotEmpty(_)) => embedded_hal_1::i2c::ErrorKind::Other, - Self::Abort(AbortReason::Other(_)) => embedded_hal_1::i2c::ErrorKind::Other, - Self::InvalidReadBufferLength => embedded_hal_1::i2c::ErrorKind::Other, - Self::InvalidWriteBufferLength => embedded_hal_1::i2c::ErrorKind::Other, - Self::AddressOutOfRange(_) => embedded_hal_1::i2c::ErrorKind::Other, - Self::AddressReserved(_) => embedded_hal_1::i2c::ErrorKind::Other, - } - } +impl<'d, T: Instance, M: Mode> embedded_hal_1::i2c::I2c for I2c<'d, T, M> { + fn read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Self::Error> { + self.blocking_read(address, read) } - impl<'d, T: Instance, M: Mode> embedded_hal_1::i2c::ErrorType for I2c<'d, T, M> { - type Error = Error; + fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Self::Error> { + self.blocking_write(address, write) } - impl<'d, T: Instance, M: Mode> embedded_hal_1::i2c::I2c for I2c<'d, T, M> { - fn read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Self::Error> { - self.blocking_read(address, read) - } + fn write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error> { + self.blocking_write_read(address, write, read) + } - fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Self::Error> { - self.blocking_write(address, write) - } - - fn write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error> { - self.blocking_write_read(address, write, read) - } - - fn transaction( - &mut self, - address: u8, - operations: &mut [embedded_hal_1::i2c::Operation<'_>], - ) -> Result<(), Self::Error> { - Self::setup(address.into())?; - for i in 0..operations.len() { - let last = i == operations.len() - 1; - match &mut operations[i] { - embedded_hal_1::i2c::Operation::Read(buf) => self.read_blocking_internal(buf, false, last)?, - embedded_hal_1::i2c::Operation::Write(buf) => self.write_blocking_internal(buf, last)?, - } + fn transaction( + &mut self, + address: u8, + operations: &mut [embedded_hal_1::i2c::Operation<'_>], + ) -> Result<(), Self::Error> { + Self::setup(address.into())?; + for i in 0..operations.len() { + let last = i == operations.len() - 1; + match &mut operations[i] { + embedded_hal_1::i2c::Operation::Read(buf) => self.read_blocking_internal(buf, false, last)?, + embedded_hal_1::i2c::Operation::Write(buf) => self.write_blocking_internal(buf, last)?, } - Ok(()) } + Ok(()) } } -#[cfg(all(feature = "unstable-traits", feature = "nightly"))] -mod nightly { - use embedded_hal_1::i2c::Operation; - use embedded_hal_async::i2c::AddressMode; - use super::*; +impl<'d, A, T> embedded_hal_async::i2c::I2c for I2c<'d, T, Async> +where + A: embedded_hal_async::i2c::AddressMode + Into + 'static, + T: Instance + 'd, +{ + async fn read(&mut self, address: A, read: &mut [u8]) -> Result<(), Self::Error> { + let addr: u16 = address.into(); - impl<'d, A, T> embedded_hal_async::i2c::I2c for I2c<'d, T, Async> - where - A: AddressMode + Into + 'static, - T: Instance + 'd, - { - async fn read(&mut self, address: A, read: &mut [u8]) -> Result<(), Self::Error> { - let addr: u16 = address.into(); + Self::setup(addr)?; + self.read_async_internal(read, false, true).await + } + async fn write(&mut self, address: A, write: &[u8]) -> Result<(), Self::Error> { + let addr: u16 = address.into(); + + Self::setup(addr)?; + self.write_async_internal(write.iter().copied(), true).await + } + + async fn write_read(&mut self, address: A, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error> { + let addr: u16 = address.into(); + + Self::setup(addr)?; + self.write_async_internal(write.iter().cloned(), false).await?; + self.read_async_internal(read, true, true).await + } + + async fn transaction( + &mut self, + address: A, + operations: &mut [embedded_hal_1::i2c::Operation<'_>], + ) -> Result<(), Self::Error> { + use embedded_hal_1::i2c::Operation; + + let addr: u16 = address.into(); + + if operations.len() > 0 { Self::setup(addr)?; - self.read_async_internal(read, false, true).await } + let mut iterator = operations.iter_mut(); - async fn write(&mut self, address: A, write: &[u8]) -> Result<(), Self::Error> { - let addr: u16 = address.into(); + while let Some(op) = iterator.next() { + let last = iterator.len() == 0; - Self::setup(addr)?; - self.write_async_internal(write.iter().copied(), true).await - } - - async fn write_read(&mut self, address: A, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error> { - let addr: u16 = address.into(); - - Self::setup(addr)?; - self.write_async_internal(write.iter().cloned(), false).await?; - self.read_async_internal(read, true, true).await - } - - async fn transaction(&mut self, address: A, operations: &mut [Operation<'_>]) -> Result<(), Self::Error> { - let addr: u16 = address.into(); - - if operations.len() > 0 { - Self::setup(addr)?; - } - let mut iterator = operations.iter_mut(); - - while let Some(op) = iterator.next() { - let last = iterator.len() == 0; - - match op { - Operation::Read(buffer) => { - self.read_async_internal(buffer, false, last).await?; - } - Operation::Write(buffer) => { - self.write_async_internal(buffer.into_iter().cloned(), last).await?; - } + match op { + Operation::Read(buffer) => { + self.read_async_internal(buffer, false, last).await?; + } + Operation::Write(buffer) => { + self.write_async_internal(buffer.into_iter().cloned(), last).await?; } } - Ok(()) } + Ok(()) } } diff --git a/embassy-rp/src/lib.rs b/embassy-rp/src/lib.rs index c9fe89b8..66e4cfdc 100644 --- a/embassy-rp/src/lib.rs +++ b/embassy-rp/src/lib.rs @@ -1,6 +1,5 @@ #![no_std] -#![cfg_attr(feature = "nightly", feature(async_fn_in_trait, impl_trait_projections))] -#![cfg_attr(feature = "nightly", allow(stable_features, unknown_lints, async_fn_in_trait))] +#![allow(async_fn_in_trait)] // This mod MUST go first, so that the others see its macros. pub(crate) mod fmt; @@ -28,7 +27,6 @@ pub mod spi; #[cfg(feature = "time-driver")] pub mod timer; pub mod uart; -#[cfg(feature = "nightly")] pub mod usb; pub mod watchdog; diff --git a/embassy-rp/src/spi.rs b/embassy-rp/src/spi.rs index a59ce841..6ba985a6 100644 --- a/embassy-rp/src/spi.rs +++ b/embassy-rp/src/spi.rs @@ -511,87 +511,73 @@ impl_mode!(Async); // ==================== -mod eh02 { - use super::*; - - impl<'d, T: Instance, M: Mode> embedded_hal_02::blocking::spi::Transfer for Spi<'d, T, M> { - type Error = Error; - fn transfer<'w>(&mut self, words: &'w mut [u8]) -> Result<&'w [u8], Self::Error> { - self.blocking_transfer_in_place(words)?; - Ok(words) - } - } - - impl<'d, T: Instance, M: Mode> embedded_hal_02::blocking::spi::Write for Spi<'d, T, M> { - type Error = Error; - - fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> { - self.blocking_write(words) - } +impl<'d, T: Instance, M: Mode> embedded_hal_02::blocking::spi::Transfer for Spi<'d, T, M> { + type Error = Error; + fn transfer<'w>(&mut self, words: &'w mut [u8]) -> Result<&'w [u8], Self::Error> { + self.blocking_transfer_in_place(words)?; + Ok(words) } } -#[cfg(feature = "unstable-traits")] -mod eh1 { - use super::*; +impl<'d, T: Instance, M: Mode> embedded_hal_02::blocking::spi::Write for Spi<'d, T, M> { + type Error = Error; - impl embedded_hal_1::spi::Error for Error { - fn kind(&self) -> embedded_hal_1::spi::ErrorKind { - match *self {} - } - } - - impl<'d, T: Instance, M: Mode> embedded_hal_1::spi::ErrorType for Spi<'d, T, M> { - type Error = Error; - } - - impl<'d, T: Instance, M: Mode> embedded_hal_1::spi::SpiBus for Spi<'d, T, M> { - fn flush(&mut self) -> Result<(), Self::Error> { - Ok(()) - } - - fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { - self.blocking_transfer(words, &[]) - } - - fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> { - self.blocking_write(words) - } - - fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> { - self.blocking_transfer(read, write) - } - - fn transfer_in_place(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { - self.blocking_transfer_in_place(words) - } + fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> { + self.blocking_write(words) } } -#[cfg(all(feature = "unstable-traits", feature = "nightly"))] -mod eha { - use super::*; +impl embedded_hal_1::spi::Error for Error { + fn kind(&self) -> embedded_hal_1::spi::ErrorKind { + match *self {} + } +} - impl<'d, T: Instance> embedded_hal_async::spi::SpiBus for Spi<'d, T, Async> { - async fn flush(&mut self) -> Result<(), Self::Error> { - Ok(()) - } +impl<'d, T: Instance, M: Mode> embedded_hal_1::spi::ErrorType for Spi<'d, T, M> { + type Error = Error; +} - async fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> { - self.write(words).await - } +impl<'d, T: Instance, M: Mode> embedded_hal_1::spi::SpiBus for Spi<'d, T, M> { + fn flush(&mut self) -> Result<(), Self::Error> { + Ok(()) + } - async fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { - self.read(words).await - } + fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { + self.blocking_transfer(words, &[]) + } - async fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> { - self.transfer(read, write).await - } + fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> { + self.blocking_write(words) + } - async fn transfer_in_place(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { - self.transfer_in_place(words).await - } + fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> { + self.blocking_transfer(read, write) + } + + fn transfer_in_place(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { + self.blocking_transfer_in_place(words) + } +} + +impl<'d, T: Instance> embedded_hal_async::spi::SpiBus for Spi<'d, T, Async> { + async fn flush(&mut self) -> Result<(), Self::Error> { + Ok(()) + } + + async fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> { + self.write(words).await + } + + async fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { + self.read(words).await + } + + async fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> { + self.transfer(read, write).await + } + + async fn transfer_in_place(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { + self.transfer_in_place(words).await } } diff --git a/embassy-rp/src/uart/buffered.rs b/embassy-rp/src/uart/buffered.rs index 9f638761..ca030f56 100644 --- a/embassy-rp/src/uart/buffered.rs +++ b/embassy-rp/src/uart/buffered.rs @@ -668,126 +668,117 @@ impl<'d, T: Instance + 'd> embedded_io::Write for BufferedUartTx<'d, T> { } } -mod eh02 { - use super::*; +impl<'d, T: Instance> embedded_hal_02::serial::Read for BufferedUartRx<'d, T> { + type Error = Error; - impl<'d, T: Instance> embedded_hal_02::serial::Read for BufferedUartRx<'d, T> { - type Error = Error; - - fn read(&mut self) -> Result> { - let r = T::regs(); - if r.uartfr().read().rxfe() { - return Err(nb::Error::WouldBlock); - } - - let dr = r.uartdr().read(); - - if dr.oe() { - Err(nb::Error::Other(Error::Overrun)) - } else if dr.be() { - Err(nb::Error::Other(Error::Break)) - } else if dr.pe() { - Err(nb::Error::Other(Error::Parity)) - } else if dr.fe() { - Err(nb::Error::Other(Error::Framing)) - } else { - Ok(dr.data()) - } - } - } - - impl<'d, T: Instance> embedded_hal_02::blocking::serial::Write for BufferedUartTx<'d, T> { - type Error = Error; - - fn bwrite_all(&mut self, mut buffer: &[u8]) -> Result<(), Self::Error> { - while !buffer.is_empty() { - match self.blocking_write(buffer) { - Ok(0) => panic!("zero-length write."), - Ok(n) => buffer = &buffer[n..], - Err(e) => return Err(e), - } - } - Ok(()) + fn read(&mut self) -> Result> { + let r = T::regs(); + if r.uartfr().read().rxfe() { + return Err(nb::Error::WouldBlock); } - fn bflush(&mut self) -> Result<(), Self::Error> { - self.blocking_flush() - } - } + let dr = r.uartdr().read(); - impl<'d, T: Instance> embedded_hal_02::serial::Read for BufferedUart<'d, T> { - type Error = Error; - - fn read(&mut self) -> Result> { - embedded_hal_02::serial::Read::read(&mut self.rx) - } - } - - impl<'d, T: Instance> embedded_hal_02::blocking::serial::Write for BufferedUart<'d, T> { - type Error = Error; - - fn bwrite_all(&mut self, mut buffer: &[u8]) -> Result<(), Self::Error> { - while !buffer.is_empty() { - match self.blocking_write(buffer) { - Ok(0) => panic!("zero-length write."), - Ok(n) => buffer = &buffer[n..], - Err(e) => return Err(e), - } - } - Ok(()) - } - - fn bflush(&mut self) -> Result<(), Self::Error> { - self.blocking_flush() + if dr.oe() { + Err(nb::Error::Other(Error::Overrun)) + } else if dr.be() { + Err(nb::Error::Other(Error::Break)) + } else if dr.pe() { + Err(nb::Error::Other(Error::Parity)) + } else if dr.fe() { + Err(nb::Error::Other(Error::Framing)) + } else { + Ok(dr.data()) } } } -#[cfg(feature = "unstable-traits")] -mod eh1 { - use super::*; +impl<'d, T: Instance> embedded_hal_02::blocking::serial::Write for BufferedUartTx<'d, T> { + type Error = Error; - impl<'d, T: Instance> embedded_hal_nb::serial::ErrorType for BufferedUartRx<'d, T> { - type Error = Error; + fn bwrite_all(&mut self, mut buffer: &[u8]) -> Result<(), Self::Error> { + while !buffer.is_empty() { + match self.blocking_write(buffer) { + Ok(0) => panic!("zero-length write."), + Ok(n) => buffer = &buffer[n..], + Err(e) => return Err(e), + } + } + Ok(()) } - impl<'d, T: Instance> embedded_hal_nb::serial::ErrorType for BufferedUartTx<'d, T> { - type Error = Error; - } - - impl<'d, T: Instance> embedded_hal_nb::serial::ErrorType for BufferedUart<'d, T> { - type Error = Error; - } - - impl<'d, T: Instance> embedded_hal_nb::serial::Read for BufferedUartRx<'d, T> { - fn read(&mut self) -> nb::Result { - embedded_hal_02::serial::Read::read(self) - } - } - - impl<'d, T: Instance> embedded_hal_nb::serial::Write for BufferedUartTx<'d, T> { - fn write(&mut self, char: u8) -> nb::Result<(), Self::Error> { - self.blocking_write(&[char]).map(drop).map_err(nb::Error::Other) - } - - fn flush(&mut self) -> nb::Result<(), Self::Error> { - self.blocking_flush().map_err(nb::Error::Other) - } - } - - impl<'d, T: Instance> embedded_hal_nb::serial::Read for BufferedUart<'d, T> { - fn read(&mut self) -> Result> { - embedded_hal_02::serial::Read::read(&mut self.rx) - } - } - - impl<'d, T: Instance> embedded_hal_nb::serial::Write for BufferedUart<'d, T> { - fn write(&mut self, char: u8) -> nb::Result<(), Self::Error> { - self.blocking_write(&[char]).map(drop).map_err(nb::Error::Other) - } - - fn flush(&mut self) -> nb::Result<(), Self::Error> { - self.blocking_flush().map_err(nb::Error::Other) - } + fn bflush(&mut self) -> Result<(), Self::Error> { + self.blocking_flush() + } +} + +impl<'d, T: Instance> embedded_hal_02::serial::Read for BufferedUart<'d, T> { + type Error = Error; + + fn read(&mut self) -> Result> { + embedded_hal_02::serial::Read::read(&mut self.rx) + } +} + +impl<'d, T: Instance> embedded_hal_02::blocking::serial::Write for BufferedUart<'d, T> { + type Error = Error; + + fn bwrite_all(&mut self, mut buffer: &[u8]) -> Result<(), Self::Error> { + while !buffer.is_empty() { + match self.blocking_write(buffer) { + Ok(0) => panic!("zero-length write."), + Ok(n) => buffer = &buffer[n..], + Err(e) => return Err(e), + } + } + Ok(()) + } + + fn bflush(&mut self) -> Result<(), Self::Error> { + self.blocking_flush() + } +} + +impl<'d, T: Instance> embedded_hal_nb::serial::ErrorType for BufferedUartRx<'d, T> { + type Error = Error; +} + +impl<'d, T: Instance> embedded_hal_nb::serial::ErrorType for BufferedUartTx<'d, T> { + type Error = Error; +} + +impl<'d, T: Instance> embedded_hal_nb::serial::ErrorType for BufferedUart<'d, T> { + type Error = Error; +} + +impl<'d, T: Instance> embedded_hal_nb::serial::Read for BufferedUartRx<'d, T> { + fn read(&mut self) -> nb::Result { + embedded_hal_02::serial::Read::read(self) + } +} + +impl<'d, T: Instance> embedded_hal_nb::serial::Write for BufferedUartTx<'d, T> { + fn write(&mut self, char: u8) -> nb::Result<(), Self::Error> { + self.blocking_write(&[char]).map(drop).map_err(nb::Error::Other) + } + + fn flush(&mut self) -> nb::Result<(), Self::Error> { + self.blocking_flush().map_err(nb::Error::Other) + } +} + +impl<'d, T: Instance> embedded_hal_nb::serial::Read for BufferedUart<'d, T> { + fn read(&mut self) -> Result> { + embedded_hal_02::serial::Read::read(&mut self.rx) + } +} + +impl<'d, T: Instance> embedded_hal_nb::serial::Write for BufferedUart<'d, T> { + fn write(&mut self, char: u8) -> nb::Result<(), Self::Error> { + self.blocking_write(&[char]).map(drop).map_err(nb::Error::Other) + } + + fn flush(&mut self) -> nb::Result<(), Self::Error> { + self.blocking_flush().map_err(nb::Error::Other) } } diff --git a/embassy-rp/src/uart/mod.rs b/embassy-rp/src/uart/mod.rs index 461986c8..18705b14 100644 --- a/embassy-rp/src/uart/mod.rs +++ b/embassy-rp/src/uart/mod.rs @@ -17,9 +17,7 @@ use crate::interrupt::typelevel::{Binding, Interrupt}; use crate::pac::io::vals::{Inover, Outover}; use crate::{interrupt, pac, peripherals, Peripheral, RegExt}; -#[cfg(feature = "nightly")] mod buffered; -#[cfg(feature = "nightly")] pub use buffered::{BufferedInterruptHandler, BufferedUart, BufferedUartRx, BufferedUartTx}; #[derive(Clone, Copy, PartialEq, Eq, Debug)] @@ -193,7 +191,6 @@ impl<'d, T: Instance, M: Mode> UartTx<'d, T, M> { } impl<'d, T: Instance> UartTx<'d, T, Blocking> { - #[cfg(feature = "nightly")] pub fn into_buffered( self, irq: impl Binding>, @@ -307,7 +304,6 @@ impl<'d, T: Instance> UartRx<'d, T, Blocking> { Self::new_inner(false, None) } - #[cfg(feature = "nightly")] pub fn into_buffered( self, irq: impl Binding>, @@ -462,7 +458,6 @@ impl<'d, T: Instance> Uart<'d, T, Blocking> { ) } - #[cfg(feature = "nightly")] pub fn into_buffered( self, irq: impl Binding>, @@ -709,175 +704,166 @@ impl<'d, T: Instance> Uart<'d, T, Async> { } } -mod eh02 { - use super::*; - - impl<'d, T: Instance, M: Mode> embedded_hal_02::serial::Read for UartRx<'d, T, M> { - type Error = Error; - fn read(&mut self) -> Result> { - let r = T::regs(); - if r.uartfr().read().rxfe() { - return Err(nb::Error::WouldBlock); - } - - let dr = r.uartdr().read(); - - if dr.oe() { - Err(nb::Error::Other(Error::Overrun)) - } else if dr.be() { - Err(nb::Error::Other(Error::Break)) - } else if dr.pe() { - Err(nb::Error::Other(Error::Parity)) - } else if dr.fe() { - Err(nb::Error::Other(Error::Framing)) - } else { - Ok(dr.data()) - } - } - } - - impl<'d, T: Instance, M: Mode> embedded_hal_02::serial::Write for UartTx<'d, T, M> { - type Error = Error; - - fn write(&mut self, word: u8) -> Result<(), nb::Error> { - let r = T::regs(); - if r.uartfr().read().txff() { - return Err(nb::Error::WouldBlock); - } - - r.uartdr().write(|w| w.set_data(word)); - Ok(()) +impl<'d, T: Instance, M: Mode> embedded_hal_02::serial::Read for UartRx<'d, T, M> { + type Error = Error; + fn read(&mut self) -> Result> { + let r = T::regs(); + if r.uartfr().read().rxfe() { + return Err(nb::Error::WouldBlock); } - fn flush(&mut self) -> Result<(), nb::Error> { - let r = T::regs(); - if !r.uartfr().read().txfe() { - return Err(nb::Error::WouldBlock); - } - Ok(()) - } - } + let dr = r.uartdr().read(); - impl<'d, T: Instance, M: Mode> embedded_hal_02::blocking::serial::Write for UartTx<'d, T, M> { - type Error = Error; - - fn bwrite_all(&mut self, buffer: &[u8]) -> Result<(), Self::Error> { - self.blocking_write(buffer) - } - - fn bflush(&mut self) -> Result<(), Self::Error> { - self.blocking_flush() - } - } - - impl<'d, T: Instance, M: Mode> embedded_hal_02::serial::Read for Uart<'d, T, M> { - type Error = Error; - - fn read(&mut self) -> Result> { - embedded_hal_02::serial::Read::read(&mut self.rx) - } - } - - impl<'d, T: Instance, M: Mode> embedded_hal_02::serial::Write for Uart<'d, T, M> { - type Error = Error; - - fn write(&mut self, word: u8) -> Result<(), nb::Error> { - embedded_hal_02::serial::Write::write(&mut self.tx, word) - } - - fn flush(&mut self) -> Result<(), nb::Error> { - embedded_hal_02::serial::Write::flush(&mut self.tx) - } - } - - impl<'d, T: Instance, M: Mode> embedded_hal_02::blocking::serial::Write for Uart<'d, T, M> { - type Error = Error; - - fn bwrite_all(&mut self, buffer: &[u8]) -> Result<(), Self::Error> { - self.blocking_write(buffer) - } - - fn bflush(&mut self) -> Result<(), Self::Error> { - self.blocking_flush() + if dr.oe() { + Err(nb::Error::Other(Error::Overrun)) + } else if dr.be() { + Err(nb::Error::Other(Error::Break)) + } else if dr.pe() { + Err(nb::Error::Other(Error::Parity)) + } else if dr.fe() { + Err(nb::Error::Other(Error::Framing)) + } else { + Ok(dr.data()) } } } -#[cfg(feature = "unstable-traits")] -mod eh1 { - use super::*; +impl<'d, T: Instance, M: Mode> embedded_hal_02::serial::Write for UartTx<'d, T, M> { + type Error = Error; - impl embedded_hal_nb::serial::Error for Error { - fn kind(&self) -> embedded_hal_nb::serial::ErrorKind { - match *self { - Self::Framing => embedded_hal_nb::serial::ErrorKind::FrameFormat, - Self::Break => embedded_hal_nb::serial::ErrorKind::Other, - Self::Overrun => embedded_hal_nb::serial::ErrorKind::Overrun, - Self::Parity => embedded_hal_nb::serial::ErrorKind::Parity, - } - } - } - - impl<'d, T: Instance, M: Mode> embedded_hal_nb::serial::ErrorType for UartRx<'d, T, M> { - type Error = Error; - } - - impl<'d, T: Instance, M: Mode> embedded_hal_nb::serial::ErrorType for UartTx<'d, T, M> { - type Error = Error; - } - - impl<'d, T: Instance, M: Mode> embedded_hal_nb::serial::ErrorType for Uart<'d, T, M> { - type Error = Error; - } - - impl<'d, T: Instance, M: Mode> embedded_hal_nb::serial::Read for UartRx<'d, T, M> { - fn read(&mut self) -> nb::Result { - let r = T::regs(); - let dr = r.uartdr().read(); - - if dr.oe() { - Err(nb::Error::Other(Error::Overrun)) - } else if dr.be() { - Err(nb::Error::Other(Error::Break)) - } else if dr.pe() { - Err(nb::Error::Other(Error::Parity)) - } else if dr.fe() { - Err(nb::Error::Other(Error::Framing)) - } else if dr.fe() { - Ok(dr.data()) - } else { - Err(nb::Error::WouldBlock) - } - } - } - - impl<'d, T: Instance, M: Mode> embedded_hal_nb::serial::Write for UartTx<'d, T, M> { - fn write(&mut self, char: u8) -> nb::Result<(), Self::Error> { - self.blocking_write(&[char]).map_err(nb::Error::Other) + fn write(&mut self, word: u8) -> Result<(), nb::Error> { + let r = T::regs(); + if r.uartfr().read().txff() { + return Err(nb::Error::WouldBlock); } - fn flush(&mut self) -> nb::Result<(), Self::Error> { - self.blocking_flush().map_err(nb::Error::Other) - } + r.uartdr().write(|w| w.set_data(word)); + Ok(()) } - impl<'d, T: Instance, M: Mode> embedded_hal_nb::serial::Read for Uart<'d, T, M> { - fn read(&mut self) -> Result> { - embedded_hal_02::serial::Read::read(&mut self.rx) + fn flush(&mut self) -> Result<(), nb::Error> { + let r = T::regs(); + if !r.uartfr().read().txfe() { + return Err(nb::Error::WouldBlock); } + Ok(()) + } +} + +impl<'d, T: Instance, M: Mode> embedded_hal_02::blocking::serial::Write for UartTx<'d, T, M> { + type Error = Error; + + fn bwrite_all(&mut self, buffer: &[u8]) -> Result<(), Self::Error> { + self.blocking_write(buffer) } - impl<'d, T: Instance, M: Mode> embedded_hal_nb::serial::Write for Uart<'d, T, M> { - fn write(&mut self, char: u8) -> nb::Result<(), Self::Error> { - self.blocking_write(&[char]).map_err(nb::Error::Other) - } + fn bflush(&mut self) -> Result<(), Self::Error> { + self.blocking_flush() + } +} - fn flush(&mut self) -> nb::Result<(), Self::Error> { - self.blocking_flush().map_err(nb::Error::Other) +impl<'d, T: Instance, M: Mode> embedded_hal_02::serial::Read for Uart<'d, T, M> { + type Error = Error; + + fn read(&mut self) -> Result> { + embedded_hal_02::serial::Read::read(&mut self.rx) + } +} + +impl<'d, T: Instance, M: Mode> embedded_hal_02::serial::Write for Uart<'d, T, M> { + type Error = Error; + + fn write(&mut self, word: u8) -> Result<(), nb::Error> { + embedded_hal_02::serial::Write::write(&mut self.tx, word) + } + + fn flush(&mut self) -> Result<(), nb::Error> { + embedded_hal_02::serial::Write::flush(&mut self.tx) + } +} + +impl<'d, T: Instance, M: Mode> embedded_hal_02::blocking::serial::Write for Uart<'d, T, M> { + type Error = Error; + + fn bwrite_all(&mut self, buffer: &[u8]) -> Result<(), Self::Error> { + self.blocking_write(buffer) + } + + fn bflush(&mut self) -> Result<(), Self::Error> { + self.blocking_flush() + } +} + +impl embedded_hal_nb::serial::Error for Error { + fn kind(&self) -> embedded_hal_nb::serial::ErrorKind { + match *self { + Self::Framing => embedded_hal_nb::serial::ErrorKind::FrameFormat, + Self::Break => embedded_hal_nb::serial::ErrorKind::Other, + Self::Overrun => embedded_hal_nb::serial::ErrorKind::Overrun, + Self::Parity => embedded_hal_nb::serial::ErrorKind::Parity, } } } +impl<'d, T: Instance, M: Mode> embedded_hal_nb::serial::ErrorType for UartRx<'d, T, M> { + type Error = Error; +} + +impl<'d, T: Instance, M: Mode> embedded_hal_nb::serial::ErrorType for UartTx<'d, T, M> { + type Error = Error; +} + +impl<'d, T: Instance, M: Mode> embedded_hal_nb::serial::ErrorType for Uart<'d, T, M> { + type Error = Error; +} + +impl<'d, T: Instance, M: Mode> embedded_hal_nb::serial::Read for UartRx<'d, T, M> { + fn read(&mut self) -> nb::Result { + let r = T::regs(); + let dr = r.uartdr().read(); + + if dr.oe() { + Err(nb::Error::Other(Error::Overrun)) + } else if dr.be() { + Err(nb::Error::Other(Error::Break)) + } else if dr.pe() { + Err(nb::Error::Other(Error::Parity)) + } else if dr.fe() { + Err(nb::Error::Other(Error::Framing)) + } else if dr.fe() { + Ok(dr.data()) + } else { + Err(nb::Error::WouldBlock) + } + } +} + +impl<'d, T: Instance, M: Mode> embedded_hal_nb::serial::Write for UartTx<'d, T, M> { + fn write(&mut self, char: u8) -> nb::Result<(), Self::Error> { + self.blocking_write(&[char]).map_err(nb::Error::Other) + } + + fn flush(&mut self) -> nb::Result<(), Self::Error> { + self.blocking_flush().map_err(nb::Error::Other) + } +} + +impl<'d, T: Instance, M: Mode> embedded_hal_nb::serial::Read for Uart<'d, T, M> { + fn read(&mut self) -> Result> { + embedded_hal_02::serial::Read::read(&mut self.rx) + } +} + +impl<'d, T: Instance, M: Mode> embedded_hal_nb::serial::Write for Uart<'d, T, M> { + fn write(&mut self, char: u8) -> nb::Result<(), Self::Error> { + self.blocking_write(&[char]).map_err(nb::Error::Other) + } + + fn flush(&mut self) -> nb::Result<(), Self::Error> { + self.blocking_flush().map_err(nb::Error::Other) + } +} + mod sealed { use super::*; @@ -891,7 +877,6 @@ mod sealed { fn regs() -> pac::uart::Uart; - #[cfg(feature = "nightly")] fn buffered_state() -> &'static buffered::State; fn dma_state() -> &'static DmaState; @@ -931,7 +916,6 @@ macro_rules! impl_instance { pac::$inst } - #[cfg(feature = "nightly")] fn buffered_state() -> &'static buffered::State { static STATE: buffered::State = buffered::State::new(); &STATE diff --git a/embassy-stm32-wpan/src/lib.rs b/embassy-stm32-wpan/src/lib.rs index 84cf0a02..a5dbb742 100644 --- a/embassy-stm32-wpan/src/lib.rs +++ b/embassy-stm32-wpan/src/lib.rs @@ -1,9 +1,5 @@ #![no_std] -#![cfg_attr(any(feature = "ble", feature = "mac"), feature(async_fn_in_trait))] -#![cfg_attr( - any(feature = "ble", feature = "mac"), - allow(stable_features, unknown_lints, async_fn_in_trait) -)] +#![allow(async_fn_in_trait)] // This must go FIRST so that all the other modules see its macros. mod fmt; diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 535357fc..0ef60305 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" src_base = "https://github.com/embassy-rs/embassy/blob/embassy-stm32-v$VERSION/embassy-stm32/src/" src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-stm32/src/" -features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "exti", "time-driver-any", "time"] +features = ["defmt", "unstable-pac", "exti", "time-driver-any", "time"] flavors = [ { regex_feature = "stm32f0.*", target = "thumbv6m-none-eabi" }, { regex_feature = "stm32f1.*", target = "thumbv7m-none-eabi" }, @@ -38,16 +38,16 @@ embassy-futures = { version = "0.1.0", path = "../embassy-futures" } embassy-hal-internal = {version = "0.1.0", path = "../embassy-hal-internal", features = ["cortex-m", "prio-bits-4"] } embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } embassy-net-driver = { version = "0.2.0", path = "../embassy-net-driver" } -embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver", optional = true } +embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver" } embassy-executor = { version = "0.3.3", path = "../embassy-executor", optional = true } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2", optional = true} -embedded-hal-async = { version = "=1.0.0-rc.2", optional = true} -embedded-hal-nb = { version = "=1.0.0-rc.2", optional = true} +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } +embedded-hal-async = { version = "=1.0.0-rc.2" } +embedded-hal-nb = { version = "=1.0.0-rc.2" } embedded-storage = "0.3.0" -embedded-storage-async = { version = "0.4.0", optional = true } +embedded-storage-async = { version = "0.4.0" } defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } @@ -65,7 +65,7 @@ nb = "1.0.0" stm32-fmc = "0.3.0" cfg-if = "1.0.0" embedded-io = { version = "0.6.0" } -embedded-io-async = { version = "0.6.1", optional = true } +embedded-io-async = { version = "0.6.1" } chrono = { version = "^0.4", default-features = false, optional = true} bit_field = "0.10.2" document-features = "0.2.7" @@ -86,29 +86,21 @@ default = ["rt"] rt = ["stm32-metapac/rt"] ## Use [`defmt`](https://docs.rs/defmt/latest/defmt/) for logging -defmt = ["dep:defmt", "bxcan/unstable-defmt", "embassy-sync/defmt", "embassy-embedded-hal/defmt", "embassy-hal-internal/defmt", "embedded-io-async?/defmt-03", "embassy-usb-driver?/defmt", "embassy-net-driver/defmt", "embassy-time?/defmt"] +defmt = ["dep:defmt", "bxcan/unstable-defmt", "embassy-sync/defmt", "embassy-embedded-hal/defmt", "embassy-hal-internal/defmt", "embedded-io-async/defmt-03", "embassy-usb-driver/defmt", "embassy-net-driver/defmt", "embassy-time?/defmt"] exti = [] -low-power = [ "dep:embassy-executor", "embassy-executor/arch-cortex-m" ] +low-power = [ "dep:embassy-executor", "embassy-executor?/arch-cortex-m" ] low-power-debug-with-sleep = [] -embassy-executor = [] ## Automatically generate `memory.x` file using [`stm32-metapac`](https://docs.rs/stm32-metapac/) memory-x = ["stm32-metapac/memory-x"] -## Enable nightly-only features -nightly = ["embedded-hal-1", "embedded-hal-async", "embedded-storage-async", "dep:embedded-io-async", "dep:embassy-usb-driver", "embassy-embedded-hal/nightly"] - ## Re-export stm32-metapac at `embassy_stm32::pac`. ## This is unstable because semver-minor (non-breaking) releases of embassy-stm32 may major-bump (breaking) the stm32-metapac version. ## If this is an issue for you, you're encouraged to directly depend on a fixed version of the PAC. ## There are no plans to make this stable. unstable-pac = [] -## Implement embedded-hal 1.0 alpha traits. -## Implement embedded-hal-async traits if `nightly` is set as well. -unstable-traits = ["embedded-hal-1", "dep:embedded-hal-nb"] - #! ## Time ## Enables additional driver features that depend on embassy-time diff --git a/embassy-stm32/src/exti.rs b/embassy-stm32/src/exti.rs index 07c63a2e..dbd24804 100644 --- a/embassy-stm32/src/exti.rs +++ b/embassy-stm32/src/exti.rs @@ -1,3 +1,4 @@ +use core::convert::Infallible; use core::future::Future; use core::marker::PhantomData; use core::pin::Pin; @@ -137,74 +138,56 @@ impl<'d, T: GpioPin> ExtiInput<'d, T> { } } -mod eh02 { - use core::convert::Infallible; +impl<'d, T: GpioPin> embedded_hal_02::digital::v2::InputPin for ExtiInput<'d, T> { + type Error = Infallible; - use super::*; + fn is_high(&self) -> Result { + Ok(self.is_high()) + } - impl<'d, T: GpioPin> embedded_hal_02::digital::v2::InputPin for ExtiInput<'d, T> { - type Error = Infallible; - - fn is_high(&self) -> Result { - Ok(self.is_high()) - } - - fn is_low(&self) -> Result { - Ok(self.is_low()) - } + fn is_low(&self) -> Result { + Ok(self.is_low()) } } -#[cfg(feature = "unstable-traits")] -mod eh1 { - use core::convert::Infallible; +impl<'d, T: GpioPin> embedded_hal_1::digital::ErrorType for ExtiInput<'d, T> { + type Error = Infallible; +} - use super::*; - - impl<'d, T: GpioPin> embedded_hal_1::digital::ErrorType for ExtiInput<'d, T> { - type Error = Infallible; +impl<'d, T: GpioPin> embedded_hal_1::digital::InputPin for ExtiInput<'d, T> { + fn is_high(&self) -> Result { + Ok(self.is_high()) } - impl<'d, T: GpioPin> embedded_hal_1::digital::InputPin for ExtiInput<'d, T> { - fn is_high(&self) -> Result { - Ok(self.is_high()) - } - - fn is_low(&self) -> Result { - Ok(self.is_low()) - } + fn is_low(&self) -> Result { + Ok(self.is_low()) } } -#[cfg(all(feature = "unstable-traits", feature = "nightly"))] -mod eha { - use super::*; +impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for ExtiInput<'d, T> { + async fn wait_for_high(&mut self) -> Result<(), Self::Error> { + self.wait_for_high().await; + Ok(()) + } - impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for ExtiInput<'d, T> { - async fn wait_for_high(&mut self) -> Result<(), Self::Error> { - self.wait_for_high().await; - Ok(()) - } + async fn wait_for_low(&mut self) -> Result<(), Self::Error> { + self.wait_for_low().await; + Ok(()) + } - async fn wait_for_low(&mut self) -> Result<(), Self::Error> { - self.wait_for_low().await; - Ok(()) - } + async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> { + self.wait_for_rising_edge().await; + Ok(()) + } - async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> { - self.wait_for_rising_edge().await; - Ok(()) - } + async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> { + self.wait_for_falling_edge().await; + Ok(()) + } - async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> { - self.wait_for_falling_edge().await; - Ok(()) - } - - async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> { - self.wait_for_any_edge().await; - Ok(()) - } + async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> { + self.wait_for_any_edge().await; + Ok(()) } } diff --git a/embassy-stm32/src/flash/asynch.rs b/embassy-stm32/src/flash/asynch.rs index e966e2a7..eae40c7e 100644 --- a/embassy-stm32/src/flash/asynch.rs +++ b/embassy-stm32/src/flash/asynch.rs @@ -55,7 +55,6 @@ impl interrupt::typelevel::Handler for Inter } } -#[cfg(feature = "nightly")] impl embedded_storage_async::nor_flash::ReadNorFlash for Flash<'_, Async> { const READ_SIZE: usize = super::READ_SIZE; @@ -68,7 +67,6 @@ impl embedded_storage_async::nor_flash::ReadNorFlash for Flash<'_, Async> { } } -#[cfg(feature = "nightly")] impl embedded_storage_async::nor_flash::NorFlash for Flash<'_, Async> { const WRITE_SIZE: usize = WRITE_SIZE; const ERASE_SIZE: usize = super::MAX_ERASE_SIZE; @@ -158,8 +156,7 @@ foreach_flash_region! { } } - #[cfg(feature = "nightly")] - impl embedded_storage_async::nor_flash::ReadNorFlash for crate::_generated::flash_regions::$type_name<'_, Async> { + impl embedded_storage_async::nor_flash::ReadNorFlash for crate::_generated::flash_regions::$type_name<'_, Async> { const READ_SIZE: usize = super::READ_SIZE; async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { @@ -171,8 +168,7 @@ foreach_flash_region! { } } - #[cfg(feature = "nightly")] - impl embedded_storage_async::nor_flash::NorFlash for crate::_generated::flash_regions::$type_name<'_, Async> { + impl embedded_storage_async::nor_flash::NorFlash for crate::_generated::flash_regions::$type_name<'_, Async> { const WRITE_SIZE: usize = $write_size; const ERASE_SIZE: usize = $erase_size; diff --git a/embassy-stm32/src/flash/f4.rs b/embassy-stm32/src/flash/f4.rs index 3e5959dd..5d07020c 100644 --- a/embassy-stm32/src/flash/f4.rs +++ b/embassy-stm32/src/flash/f4.rs @@ -142,7 +142,6 @@ mod alt_regions { } } - #[cfg(feature = "nightly")] impl embedded_storage_async::nor_flash::ReadNorFlash for $type_name<'_, Async> { const READ_SIZE: usize = crate::flash::READ_SIZE; @@ -155,7 +154,6 @@ mod alt_regions { } } - #[cfg(feature = "nightly")] impl embedded_storage_async::nor_flash::NorFlash for $type_name<'_, Async> { const WRITE_SIZE: usize = $region.write_size as usize; const ERASE_SIZE: usize = $region.erase_size as usize; diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 011f4c07..b863c4ff 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -772,306 +772,293 @@ pub(crate) unsafe fn init(_cs: CriticalSection) { }); } -mod eh02 { - use embedded_hal_02::digital::v2::{InputPin, OutputPin, StatefulOutputPin, ToggleableOutputPin}; +impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Input<'d, T> { + type Error = Infallible; - use super::*; - - impl<'d, T: Pin> InputPin for Input<'d, T> { - type Error = Infallible; - - #[inline] - fn is_high(&self) -> Result { - Ok(self.is_high()) - } - - #[inline] - fn is_low(&self) -> Result { - Ok(self.is_low()) - } + #[inline] + fn is_high(&self) -> Result { + Ok(self.is_high()) } - impl<'d, T: Pin> OutputPin for Output<'d, T> { - type Error = Infallible; - - #[inline] - fn set_high(&mut self) -> Result<(), Self::Error> { - self.set_high(); - Ok(()) - } - - #[inline] - fn set_low(&mut self) -> Result<(), Self::Error> { - self.set_low(); - Ok(()) - } - } - - impl<'d, T: Pin> StatefulOutputPin for Output<'d, T> { - #[inline] - fn is_set_high(&self) -> Result { - Ok(self.is_set_high()) - } - - /// Is the output pin set as low? - #[inline] - fn is_set_low(&self) -> Result { - Ok(self.is_set_low()) - } - } - - impl<'d, T: Pin> ToggleableOutputPin for Output<'d, T> { - type Error = Infallible; - #[inline] - fn toggle(&mut self) -> Result<(), Self::Error> { - self.toggle(); - Ok(()) - } - } - - impl<'d, T: Pin> OutputPin for OutputOpenDrain<'d, T> { - type Error = Infallible; - - #[inline] - fn set_high(&mut self) -> Result<(), Self::Error> { - self.set_high(); - Ok(()) - } - - #[inline] - fn set_low(&mut self) -> Result<(), Self::Error> { - self.set_low(); - Ok(()) - } - } - - impl<'d, T: Pin> StatefulOutputPin for OutputOpenDrain<'d, T> { - #[inline] - fn is_set_high(&self) -> Result { - Ok(self.is_set_high()) - } - - /// Is the output pin set as low? - #[inline] - fn is_set_low(&self) -> Result { - Ok(self.is_set_low()) - } - } - - impl<'d, T: Pin> ToggleableOutputPin for OutputOpenDrain<'d, T> { - type Error = Infallible; - #[inline] - fn toggle(&mut self) -> Result<(), Self::Error> { - self.toggle(); - Ok(()) - } - } - - impl<'d, T: Pin> InputPin for Flex<'d, T> { - type Error = Infallible; - - #[inline] - fn is_high(&self) -> Result { - Ok(self.is_high()) - } - - #[inline] - fn is_low(&self) -> Result { - Ok(self.is_low()) - } - } - - impl<'d, T: Pin> OutputPin for Flex<'d, T> { - type Error = Infallible; - - #[inline] - fn set_high(&mut self) -> Result<(), Self::Error> { - self.set_high(); - Ok(()) - } - - #[inline] - fn set_low(&mut self) -> Result<(), Self::Error> { - self.set_low(); - Ok(()) - } - } - - impl<'d, T: Pin> StatefulOutputPin for Flex<'d, T> { - #[inline] - fn is_set_high(&self) -> Result { - Ok(self.is_set_high()) - } - - /// Is the output pin set as low? - #[inline] - fn is_set_low(&self) -> Result { - Ok(self.is_set_low()) - } - } - - impl<'d, T: Pin> ToggleableOutputPin for Flex<'d, T> { - type Error = Infallible; - #[inline] - fn toggle(&mut self) -> Result<(), Self::Error> { - self.toggle(); - Ok(()) - } + #[inline] + fn is_low(&self) -> Result { + Ok(self.is_low()) } } -#[cfg(feature = "unstable-traits")] -mod eh1 { - use embedded_hal_1::digital::{ErrorType, InputPin, OutputPin, StatefulOutputPin, ToggleableOutputPin}; +impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Output<'d, T> { + type Error = Infallible; - use super::*; - - impl<'d, T: Pin> ErrorType for Input<'d, T> { - type Error = Infallible; + #[inline] + fn set_high(&mut self) -> Result<(), Self::Error> { + self.set_high(); + Ok(()) } - impl<'d, T: Pin> InputPin for Input<'d, T> { - #[inline] - fn is_high(&self) -> Result { - Ok(self.is_high()) - } + #[inline] + fn set_low(&mut self) -> Result<(), Self::Error> { + self.set_low(); + Ok(()) + } +} - #[inline] - fn is_low(&self) -> Result { - Ok(self.is_low()) - } +impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> { + #[inline] + fn is_set_high(&self) -> Result { + Ok(self.is_set_high()) } - impl<'d, T: Pin> ErrorType for Output<'d, T> { - type Error = Infallible; + /// Is the output pin set as low? + #[inline] + fn is_set_low(&self) -> Result { + Ok(self.is_set_low()) + } +} + +impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d, T> { + type Error = Infallible; + #[inline] + fn toggle(&mut self) -> Result<(), Self::Error> { + self.toggle(); + Ok(()) + } +} + +impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d, T> { + type Error = Infallible; + + #[inline] + fn set_high(&mut self) -> Result<(), Self::Error> { + self.set_high(); + Ok(()) } - impl<'d, T: Pin> OutputPin for Output<'d, T> { - #[inline] - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(self.set_high()) - } + #[inline] + fn set_low(&mut self) -> Result<(), Self::Error> { + self.set_low(); + Ok(()) + } +} - #[inline] - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(self.set_low()) - } +impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d, T> { + #[inline] + fn is_set_high(&self) -> Result { + Ok(self.is_set_high()) } - impl<'d, T: Pin> StatefulOutputPin for Output<'d, T> { - #[inline] - fn is_set_high(&self) -> Result { - Ok(self.is_set_high()) - } + /// Is the output pin set as low? + #[inline] + fn is_set_low(&self) -> Result { + Ok(self.is_set_low()) + } +} - /// Is the output pin set as low? - #[inline] - fn is_set_low(&self) -> Result { - Ok(self.is_set_low()) - } +impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for OutputOpenDrain<'d, T> { + type Error = Infallible; + #[inline] + fn toggle(&mut self) -> Result<(), Self::Error> { + self.toggle(); + Ok(()) + } +} + +impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Flex<'d, T> { + type Error = Infallible; + + #[inline] + fn is_high(&self) -> Result { + Ok(self.is_high()) } - impl<'d, T: Pin> ToggleableOutputPin for Output<'d, T> { - #[inline] - fn toggle(&mut self) -> Result<(), Self::Error> { - Ok(self.toggle()) - } + #[inline] + fn is_low(&self) -> Result { + Ok(self.is_low()) + } +} + +impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Flex<'d, T> { + type Error = Infallible; + + #[inline] + fn set_high(&mut self) -> Result<(), Self::Error> { + self.set_high(); + Ok(()) } - impl<'d, T: Pin> ErrorType for OutputOpenDrain<'d, T> { - type Error = Infallible; + #[inline] + fn set_low(&mut self) -> Result<(), Self::Error> { + self.set_low(); + Ok(()) + } +} + +impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> { + #[inline] + fn is_set_high(&self) -> Result { + Ok(self.is_set_high()) } - impl<'d, T: Pin> InputPin for OutputOpenDrain<'d, T> { - #[inline] - fn is_high(&self) -> Result { - Ok(self.is_high()) - } + /// Is the output pin set as low? + #[inline] + fn is_set_low(&self) -> Result { + Ok(self.is_set_low()) + } +} - #[inline] - fn is_low(&self) -> Result { - Ok(self.is_low()) - } +impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d, T> { + type Error = Infallible; + #[inline] + fn toggle(&mut self) -> Result<(), Self::Error> { + self.toggle(); + Ok(()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> { + type Error = Infallible; +} + +impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { + #[inline] + fn is_high(&self) -> Result { + Ok(self.is_high()) } - impl<'d, T: Pin> OutputPin for OutputOpenDrain<'d, T> { - #[inline] - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(self.set_high()) - } + #[inline] + fn is_low(&self) -> Result { + Ok(self.is_low()) + } +} - #[inline] - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(self.set_low()) - } +impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Output<'d, T> { + type Error = Infallible; +} + +impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { + #[inline] + fn set_high(&mut self) -> Result<(), Self::Error> { + Ok(self.set_high()) } - impl<'d, T: Pin> StatefulOutputPin for OutputOpenDrain<'d, T> { - #[inline] - fn is_set_high(&self) -> Result { - Ok(self.is_set_high()) - } + #[inline] + fn set_low(&mut self) -> Result<(), Self::Error> { + Ok(self.set_low()) + } +} - /// Is the output pin set as low? - #[inline] - fn is_set_low(&self) -> Result { - Ok(self.is_set_low()) - } +impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { + #[inline] + fn is_set_high(&self) -> Result { + Ok(self.is_set_high()) } - impl<'d, T: Pin> ToggleableOutputPin for OutputOpenDrain<'d, T> { - #[inline] - fn toggle(&mut self) -> Result<(), Self::Error> { - Ok(self.toggle()) - } + /// Is the output pin set as low? + #[inline] + fn is_set_low(&self) -> Result { + Ok(self.is_set_low()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::ToggleableOutputPin for Output<'d, T> { + #[inline] + fn toggle(&mut self) -> Result<(), Self::Error> { + Ok(self.toggle()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for OutputOpenDrain<'d, T> { + type Error = Infallible; +} + +impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> { + #[inline] + fn is_high(&self) -> Result { + Ok(self.is_high()) } - impl<'d, T: Pin> InputPin for Flex<'d, T> { - #[inline] - fn is_high(&self) -> Result { - Ok(self.is_high()) - } + #[inline] + fn is_low(&self) -> Result { + Ok(self.is_low()) + } +} - #[inline] - fn is_low(&self) -> Result { - Ok(self.is_low()) - } +impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> { + #[inline] + fn set_high(&mut self) -> Result<(), Self::Error> { + Ok(self.set_high()) } - impl<'d, T: Pin> OutputPin for Flex<'d, T> { - #[inline] - fn set_high(&mut self) -> Result<(), Self::Error> { - Ok(self.set_high()) - } + #[inline] + fn set_low(&mut self) -> Result<(), Self::Error> { + Ok(self.set_low()) + } +} - #[inline] - fn set_low(&mut self) -> Result<(), Self::Error> { - Ok(self.set_low()) - } +impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> { + #[inline] + fn is_set_high(&self) -> Result { + Ok(self.is_set_high()) } - impl<'d, T: Pin> ToggleableOutputPin for Flex<'d, T> { - #[inline] - fn toggle(&mut self) -> Result<(), Self::Error> { - Ok(self.toggle()) - } + /// Is the output pin set as low? + #[inline] + fn is_set_low(&self) -> Result { + Ok(self.is_set_low()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::ToggleableOutputPin for OutputOpenDrain<'d, T> { + #[inline] + fn toggle(&mut self) -> Result<(), Self::Error> { + Ok(self.toggle()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { + #[inline] + fn is_high(&self) -> Result { + Ok(self.is_high()) } - impl<'d, T: Pin> ErrorType for Flex<'d, T> { - type Error = Infallible; + #[inline] + fn is_low(&self) -> Result { + Ok(self.is_low()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { + #[inline] + fn set_high(&mut self) -> Result<(), Self::Error> { + Ok(self.set_high()) } - impl<'d, T: Pin> StatefulOutputPin for Flex<'d, T> { - #[inline] - fn is_set_high(&self) -> Result { - Ok(self.is_set_high()) - } + #[inline] + fn set_low(&mut self) -> Result<(), Self::Error> { + Ok(self.set_low()) + } +} - /// Is the output pin set as low? - #[inline] - fn is_set_low(&self) -> Result { - Ok(self.is_set_low()) - } +impl<'d, T: Pin> embedded_hal_1::digital::ToggleableOutputPin for Flex<'d, T> { + #[inline] + fn toggle(&mut self) -> Result<(), Self::Error> { + Ok(self.toggle()) + } +} + +impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { + type Error = Infallible; +} + +impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { + #[inline] + fn is_set_high(&self) -> Result { + Ok(self.is_set_high()) + } + + /// Is the output pin set as low? + #[inline] + fn is_set_low(&self) -> Result { + Ok(self.is_set_low()) } } diff --git a/embassy-stm32/src/i2c/mod.rs b/embassy-stm32/src/i2c/mod.rs index 19346d70..d2a50cf7 100644 --- a/embassy-stm32/src/i2c/mod.rs +++ b/embassy-stm32/src/i2c/mod.rs @@ -2,6 +2,7 @@ use core::marker::PhantomData; +use crate::dma::NoDma; use crate::interrupt; #[cfg_attr(i2c_v1, path = "v1.rs")] @@ -97,107 +98,92 @@ foreach_peripheral!( }; ); -mod eh02 { - use super::*; +impl<'d, T: Instance> embedded_hal_02::blocking::i2c::Read for I2c<'d, T> { + type Error = Error; - impl<'d, T: Instance> embedded_hal_02::blocking::i2c::Read for I2c<'d, T> { - type Error = Error; - - fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> { - self.blocking_read(address, buffer) - } - } - - impl<'d, T: Instance> embedded_hal_02::blocking::i2c::Write for I2c<'d, T> { - type Error = Error; - - fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Self::Error> { - self.blocking_write(address, write) - } - } - - impl<'d, T: Instance> embedded_hal_02::blocking::i2c::WriteRead for I2c<'d, T> { - type Error = Error; - - fn write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error> { - self.blocking_write_read(address, write, read) - } + fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> { + self.blocking_read(address, buffer) } } -#[cfg(feature = "unstable-traits")] -mod eh1 { - use super::*; - use crate::dma::NoDma; +impl<'d, T: Instance> embedded_hal_02::blocking::i2c::Write for I2c<'d, T> { + type Error = Error; - impl embedded_hal_1::i2c::Error for Error { - fn kind(&self) -> embedded_hal_1::i2c::ErrorKind { - match *self { - Self::Bus => embedded_hal_1::i2c::ErrorKind::Bus, - Self::Arbitration => embedded_hal_1::i2c::ErrorKind::ArbitrationLoss, - Self::Nack => { - embedded_hal_1::i2c::ErrorKind::NoAcknowledge(embedded_hal_1::i2c::NoAcknowledgeSource::Unknown) - } - Self::Timeout => embedded_hal_1::i2c::ErrorKind::Other, - Self::Crc => embedded_hal_1::i2c::ErrorKind::Other, - Self::Overrun => embedded_hal_1::i2c::ErrorKind::Overrun, - Self::ZeroLengthTransfer => embedded_hal_1::i2c::ErrorKind::Other, + fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Self::Error> { + self.blocking_write(address, write) + } +} + +impl<'d, T: Instance> embedded_hal_02::blocking::i2c::WriteRead for I2c<'d, T> { + type Error = Error; + + fn write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error> { + self.blocking_write_read(address, write, read) + } +} + +impl embedded_hal_1::i2c::Error for Error { + fn kind(&self) -> embedded_hal_1::i2c::ErrorKind { + match *self { + Self::Bus => embedded_hal_1::i2c::ErrorKind::Bus, + Self::Arbitration => embedded_hal_1::i2c::ErrorKind::ArbitrationLoss, + Self::Nack => { + embedded_hal_1::i2c::ErrorKind::NoAcknowledge(embedded_hal_1::i2c::NoAcknowledgeSource::Unknown) } - } - } - - impl<'d, T: Instance, TXDMA, RXDMA> embedded_hal_1::i2c::ErrorType for I2c<'d, T, TXDMA, RXDMA> { - type Error = Error; - } - - impl<'d, T: Instance> embedded_hal_1::i2c::I2c for I2c<'d, T, NoDma, NoDma> { - fn read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Self::Error> { - self.blocking_read(address, read) - } - - fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Self::Error> { - self.blocking_write(address, write) - } - - fn write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error> { - self.blocking_write_read(address, write, read) - } - - fn transaction( - &mut self, - _address: u8, - _operations: &mut [embedded_hal_1::i2c::Operation<'_>], - ) -> Result<(), Self::Error> { - todo!(); + Self::Timeout => embedded_hal_1::i2c::ErrorKind::Other, + Self::Crc => embedded_hal_1::i2c::ErrorKind::Other, + Self::Overrun => embedded_hal_1::i2c::ErrorKind::Overrun, + Self::ZeroLengthTransfer => embedded_hal_1::i2c::ErrorKind::Other, } } } -#[cfg(all(feature = "unstable-traits", feature = "nightly"))] -mod eha { - use super::*; +impl<'d, T: Instance, TXDMA, RXDMA> embedded_hal_1::i2c::ErrorType for I2c<'d, T, TXDMA, RXDMA> { + type Error = Error; +} - impl<'d, T: Instance, TXDMA: TxDma, RXDMA: RxDma> embedded_hal_async::i2c::I2c for I2c<'d, T, TXDMA, RXDMA> { - async fn read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Self::Error> { - self.read(address, read).await - } +impl<'d, T: Instance> embedded_hal_1::i2c::I2c for I2c<'d, T, NoDma, NoDma> { + fn read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Self::Error> { + self.blocking_read(address, read) + } - async fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Self::Error> { - self.write(address, write).await - } + fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Self::Error> { + self.blocking_write(address, write) + } - async fn write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error> { - self.write_read(address, write, read).await - } + fn write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error> { + self.blocking_write_read(address, write, read) + } - async fn transaction( - &mut self, - address: u8, - operations: &mut [embedded_hal_1::i2c::Operation<'_>], - ) -> Result<(), Self::Error> { - let _ = address; - let _ = operations; - todo!() - } + fn transaction( + &mut self, + _address: u8, + _operations: &mut [embedded_hal_1::i2c::Operation<'_>], + ) -> Result<(), Self::Error> { + todo!(); + } +} + +impl<'d, T: Instance, TXDMA: TxDma, RXDMA: RxDma> embedded_hal_async::i2c::I2c for I2c<'d, T, TXDMA, RXDMA> { + async fn read(&mut self, address: u8, read: &mut [u8]) -> Result<(), Self::Error> { + self.read(address, read).await + } + + async fn write(&mut self, address: u8, write: &[u8]) -> Result<(), Self::Error> { + self.write(address, write).await + } + + async fn write_read(&mut self, address: u8, write: &[u8], read: &mut [u8]) -> Result<(), Self::Error> { + self.write_read(address, write, read).await + } + + async fn transaction( + &mut self, + address: u8, + operations: &mut [embedded_hal_1::i2c::Operation<'_>], + ) -> Result<(), Self::Error> { + let _ = address; + let _ = operations; + todo!() } } diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 511da917..7ce801a0 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs @@ -1,6 +1,5 @@ #![cfg_attr(not(test), no_std)] -#![cfg_attr(feature = "nightly", feature(async_fn_in_trait, impl_trait_projections))] -#![cfg_attr(feature = "nightly", allow(stable_features, unknown_lints, async_fn_in_trait))] +#![allow(async_fn_in_trait)] //! ## Feature flags #![doc = document_features::document_features!(feature_label = r#"{feature}"#)] diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index c391e0a5..92599c75 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs @@ -848,102 +848,88 @@ fn transfer_word(regs: Regs, tx_word: W) -> Result { Ok(rx_word) } -mod eh02 { - use super::*; +// Note: It is not possible to impl these traits generically in embedded-hal 0.2 due to a conflict with +// some marker traits. For details, see https://github.com/rust-embedded/embedded-hal/pull/289 +macro_rules! impl_blocking { + ($w:ident) => { + impl<'d, T: Instance, Tx, Rx> embedded_hal_02::blocking::spi::Write<$w> for Spi<'d, T, Tx, Rx> { + type Error = Error; - // Note: It is not possible to impl these traits generically in embedded-hal 0.2 due to a conflict with - // some marker traits. For details, see https://github.com/rust-embedded/embedded-hal/pull/289 - macro_rules! impl_blocking { - ($w:ident) => { - impl<'d, T: Instance, Tx, Rx> embedded_hal_02::blocking::spi::Write<$w> for Spi<'d, T, Tx, Rx> { - type Error = Error; - - fn write(&mut self, words: &[$w]) -> Result<(), Self::Error> { - self.blocking_write(words) - } + fn write(&mut self, words: &[$w]) -> Result<(), Self::Error> { + self.blocking_write(words) } + } - impl<'d, T: Instance, Tx, Rx> embedded_hal_02::blocking::spi::Transfer<$w> for Spi<'d, T, Tx, Rx> { - type Error = Error; + impl<'d, T: Instance, Tx, Rx> embedded_hal_02::blocking::spi::Transfer<$w> for Spi<'d, T, Tx, Rx> { + type Error = Error; - fn transfer<'w>(&mut self, words: &'w mut [$w]) -> Result<&'w [$w], Self::Error> { - self.blocking_transfer_in_place(words)?; - Ok(words) - } + fn transfer<'w>(&mut self, words: &'w mut [$w]) -> Result<&'w [$w], Self::Error> { + self.blocking_transfer_in_place(words)?; + Ok(words) } - }; - } - - impl_blocking!(u8); - impl_blocking!(u16); + } + }; } -#[cfg(feature = "unstable-traits")] -mod eh1 { - use super::*; +impl_blocking!(u8); +impl_blocking!(u16); - impl<'d, T: Instance, Tx, Rx> embedded_hal_1::spi::ErrorType for Spi<'d, T, Tx, Rx> { - type Error = Error; +impl<'d, T: Instance, Tx, Rx> embedded_hal_1::spi::ErrorType for Spi<'d, T, Tx, Rx> { + type Error = Error; +} + +impl<'d, T: Instance, W: Word, Tx, Rx> embedded_hal_1::spi::SpiBus for Spi<'d, T, Tx, Rx> { + fn flush(&mut self) -> Result<(), Self::Error> { + Ok(()) } - impl<'d, T: Instance, W: Word, Tx, Rx> embedded_hal_1::spi::SpiBus for Spi<'d, T, Tx, Rx> { - fn flush(&mut self) -> Result<(), Self::Error> { - Ok(()) - } - - fn read(&mut self, words: &mut [W]) -> Result<(), Self::Error> { - self.blocking_read(words) - } - - fn write(&mut self, words: &[W]) -> Result<(), Self::Error> { - self.blocking_write(words) - } - - fn transfer(&mut self, read: &mut [W], write: &[W]) -> Result<(), Self::Error> { - self.blocking_transfer(read, write) - } - - fn transfer_in_place(&mut self, words: &mut [W]) -> Result<(), Self::Error> { - self.blocking_transfer_in_place(words) - } + fn read(&mut self, words: &mut [W]) -> Result<(), Self::Error> { + self.blocking_read(words) } - impl embedded_hal_1::spi::Error for Error { - fn kind(&self) -> embedded_hal_1::spi::ErrorKind { - match *self { - Self::Framing => embedded_hal_1::spi::ErrorKind::FrameFormat, - Self::Crc => embedded_hal_1::spi::ErrorKind::Other, - Self::ModeFault => embedded_hal_1::spi::ErrorKind::ModeFault, - Self::Overrun => embedded_hal_1::spi::ErrorKind::Overrun, - } + fn write(&mut self, words: &[W]) -> Result<(), Self::Error> { + self.blocking_write(words) + } + + fn transfer(&mut self, read: &mut [W], write: &[W]) -> Result<(), Self::Error> { + self.blocking_transfer(read, write) + } + + fn transfer_in_place(&mut self, words: &mut [W]) -> Result<(), Self::Error> { + self.blocking_transfer_in_place(words) + } +} + +impl embedded_hal_1::spi::Error for Error { + fn kind(&self) -> embedded_hal_1::spi::ErrorKind { + match *self { + Self::Framing => embedded_hal_1::spi::ErrorKind::FrameFormat, + Self::Crc => embedded_hal_1::spi::ErrorKind::Other, + Self::ModeFault => embedded_hal_1::spi::ErrorKind::ModeFault, + Self::Overrun => embedded_hal_1::spi::ErrorKind::Overrun, } } } -#[cfg(all(feature = "unstable-traits", feature = "nightly"))] -mod eha { - use super::*; +impl<'d, T: Instance, Tx: TxDma, Rx: RxDma, W: Word> embedded_hal_async::spi::SpiBus for Spi<'d, T, Tx, Rx> { + async fn flush(&mut self) -> Result<(), Self::Error> { + Ok(()) + } - impl<'d, T: Instance, Tx: TxDma, Rx: RxDma, W: Word> embedded_hal_async::spi::SpiBus for Spi<'d, T, Tx, Rx> { - async fn flush(&mut self) -> Result<(), Self::Error> { - Ok(()) - } + async fn write(&mut self, words: &[W]) -> Result<(), Self::Error> { + self.write(words).await + } - async fn write(&mut self, words: &[W]) -> Result<(), Self::Error> { - self.write(words).await - } + async fn read(&mut self, words: &mut [W]) -> Result<(), Self::Error> { + self.read(words).await + } - async fn read(&mut self, words: &mut [W]) -> Result<(), Self::Error> { - self.read(words).await - } + async fn transfer(&mut self, read: &mut [W], write: &[W]) -> Result<(), Self::Error> { + self.transfer(read, write).await + } - async fn transfer(&mut self, read: &mut [W], write: &[W]) -> Result<(), Self::Error> { - self.transfer(read, write).await - } - - async fn transfer_in_place(&mut self, words: &mut [W]) -> Result<(), Self::Error> { - self.transfer_in_place(words).await - } + async fn transfer_in_place(&mut self, words: &mut [W]) -> Result<(), Self::Error> { + self.transfer_in_place(words).await } } diff --git a/embassy-stm32/src/usart/buffered.rs b/embassy-stm32/src/usart/buffered.rs index 4daddfe9..a2e4ceaa 100644 --- a/embassy-stm32/src/usart/buffered.rs +++ b/embassy-stm32/src/usart/buffered.rs @@ -560,172 +560,120 @@ impl<'d, T: BasicInstance> embedded_io::Write for BufferedUartTx<'d, T> { } } -mod eh02 { - use super::*; +impl<'d, T: BasicInstance> embedded_hal_02::serial::Read for BufferedUartRx<'d, T> { + type Error = Error; - impl<'d, T: BasicInstance> embedded_hal_02::serial::Read for BufferedUartRx<'d, T> { - type Error = Error; - - fn read(&mut self) -> Result> { - let r = T::regs(); - unsafe { - let sr = sr(r).read(); - if sr.pe() { - rdr(r).read_volatile(); - Err(nb::Error::Other(Error::Parity)) - } else if sr.fe() { - rdr(r).read_volatile(); - Err(nb::Error::Other(Error::Framing)) - } else if sr.ne() { - rdr(r).read_volatile(); - Err(nb::Error::Other(Error::Noise)) - } else if sr.ore() { - rdr(r).read_volatile(); - Err(nb::Error::Other(Error::Overrun)) - } else if sr.rxne() { - Ok(rdr(r).read_volatile()) - } else { - Err(nb::Error::WouldBlock) - } + fn read(&mut self) -> Result> { + let r = T::regs(); + unsafe { + let sr = sr(r).read(); + if sr.pe() { + rdr(r).read_volatile(); + Err(nb::Error::Other(Error::Parity)) + } else if sr.fe() { + rdr(r).read_volatile(); + Err(nb::Error::Other(Error::Framing)) + } else if sr.ne() { + rdr(r).read_volatile(); + Err(nb::Error::Other(Error::Noise)) + } else if sr.ore() { + rdr(r).read_volatile(); + Err(nb::Error::Other(Error::Overrun)) + } else if sr.rxne() { + Ok(rdr(r).read_volatile()) + } else { + Err(nb::Error::WouldBlock) } } } - - impl<'d, T: BasicInstance> embedded_hal_02::blocking::serial::Write for BufferedUartTx<'d, T> { - type Error = Error; - - fn bwrite_all(&mut self, mut buffer: &[u8]) -> Result<(), Self::Error> { - while !buffer.is_empty() { - match self.blocking_write(buffer) { - Ok(0) => panic!("zero-length write."), - Ok(n) => buffer = &buffer[n..], - Err(e) => return Err(e), - } - } - Ok(()) - } - - fn bflush(&mut self) -> Result<(), Self::Error> { - self.blocking_flush() - } - } - - impl<'d, T: BasicInstance> embedded_hal_02::serial::Read for BufferedUart<'d, T> { - type Error = Error; - - fn read(&mut self) -> Result> { - embedded_hal_02::serial::Read::read(&mut self.rx) - } - } - - impl<'d, T: BasicInstance> embedded_hal_02::blocking::serial::Write for BufferedUart<'d, T> { - type Error = Error; - - fn bwrite_all(&mut self, mut buffer: &[u8]) -> Result<(), Self::Error> { - while !buffer.is_empty() { - match self.tx.blocking_write(buffer) { - Ok(0) => panic!("zero-length write."), - Ok(n) => buffer = &buffer[n..], - Err(e) => return Err(e), - } - } - Ok(()) - } - - fn bflush(&mut self) -> Result<(), Self::Error> { - self.tx.blocking_flush() - } - } } -#[cfg(feature = "unstable-traits")] -mod eh1 { - use super::*; +impl<'d, T: BasicInstance> embedded_hal_02::blocking::serial::Write for BufferedUartTx<'d, T> { + type Error = Error; - impl<'d, T: BasicInstance> embedded_hal_nb::serial::ErrorType for BufferedUart<'d, T> { - type Error = Error; + fn bwrite_all(&mut self, mut buffer: &[u8]) -> Result<(), Self::Error> { + while !buffer.is_empty() { + match self.blocking_write(buffer) { + Ok(0) => panic!("zero-length write."), + Ok(n) => buffer = &buffer[n..], + Err(e) => return Err(e), + } + } + Ok(()) } - impl<'d, T: BasicInstance> embedded_hal_nb::serial::ErrorType for BufferedUartTx<'d, T> { - type Error = Error; - } - - impl<'d, T: BasicInstance> embedded_hal_nb::serial::ErrorType for BufferedUartRx<'d, T> { - type Error = Error; - } - - impl<'d, T: BasicInstance> embedded_hal_nb::serial::Read for BufferedUartRx<'d, T> { - fn read(&mut self) -> nb::Result { - embedded_hal_02::serial::Read::read(self) - } - } - - impl<'d, T: BasicInstance> embedded_hal_nb::serial::Write for BufferedUartTx<'d, T> { - fn write(&mut self, char: u8) -> nb::Result<(), Self::Error> { - self.blocking_write(&[char]).map(drop).map_err(nb::Error::Other) - } - - fn flush(&mut self) -> nb::Result<(), Self::Error> { - self.blocking_flush().map_err(nb::Error::Other) - } - } - - impl<'d, T: BasicInstance> embedded_hal_nb::serial::Read for BufferedUart<'d, T> { - fn read(&mut self) -> Result> { - embedded_hal_02::serial::Read::read(&mut self.rx) - } - } - - impl<'d, T: BasicInstance> embedded_hal_nb::serial::Write for BufferedUart<'d, T> { - fn write(&mut self, char: u8) -> nb::Result<(), Self::Error> { - self.tx.blocking_write(&[char]).map(drop).map_err(nb::Error::Other) - } - - fn flush(&mut self) -> nb::Result<(), Self::Error> { - self.tx.blocking_flush().map_err(nb::Error::Other) - } + fn bflush(&mut self) -> Result<(), Self::Error> { + self.blocking_flush() } } -#[cfg(all( - feature = "unstable-traits", - feature = "nightly", - feature = "_todo_embedded_hal_serial" -))] -mod eha { - use core::future::Future; +impl<'d, T: BasicInstance> embedded_hal_02::serial::Read for BufferedUart<'d, T> { + type Error = Error; - use super::*; - - impl<'d, T: BasicInstance> embedded_hal_async::serial::Write for BufferedUartTx<'d, T> { - async fn write(&mut self, buf: &[u8]) -> Result<(), Self::Error> { - Self::write(buf) - } - - async fn flush(&mut self) -> Result<(), Self::Error> { - Self::flush() - } - } - - impl<'d, T: BasicInstance> embedded_hal_async::serial::Read for BufferedUartRx<'d, T> { - async fn read(&mut self, buf: &mut [u8]) -> Result<(), Self::Error> { - Self::read(buf) - } - } - - impl<'d, T: BasicInstance> embedded_hal_async::serial::Write for BufferedUart<'d, T> { - async fn write(&mut self, buf: &[u8]) -> Result<(), Self::Error> { - self.tx.write(buf) - } - - async fn flush(&mut self) -> Result<(), Self::Error> { - self.tx.flush() - } - } - - impl<'d, T: BasicInstance> embedded_hal_async::serial::Read for BufferedUart<'d, T> { - async fn read(&mut self, buf: &mut [u8]) -> Result<(), Self::Error> { - self.rx.read(buf) - } + fn read(&mut self) -> Result> { + embedded_hal_02::serial::Read::read(&mut self.rx) + } +} + +impl<'d, T: BasicInstance> embedded_hal_02::blocking::serial::Write for BufferedUart<'d, T> { + type Error = Error; + + fn bwrite_all(&mut self, mut buffer: &[u8]) -> Result<(), Self::Error> { + while !buffer.is_empty() { + match self.tx.blocking_write(buffer) { + Ok(0) => panic!("zero-length write."), + Ok(n) => buffer = &buffer[n..], + Err(e) => return Err(e), + } + } + Ok(()) + } + + fn bflush(&mut self) -> Result<(), Self::Error> { + self.tx.blocking_flush() + } +} + +impl<'d, T: BasicInstance> embedded_hal_nb::serial::ErrorType for BufferedUart<'d, T> { + type Error = Error; +} + +impl<'d, T: BasicInstance> embedded_hal_nb::serial::ErrorType for BufferedUartTx<'d, T> { + type Error = Error; +} + +impl<'d, T: BasicInstance> embedded_hal_nb::serial::ErrorType for BufferedUartRx<'d, T> { + type Error = Error; +} + +impl<'d, T: BasicInstance> embedded_hal_nb::serial::Read for BufferedUartRx<'d, T> { + fn read(&mut self) -> nb::Result { + embedded_hal_02::serial::Read::read(self) + } +} + +impl<'d, T: BasicInstance> embedded_hal_nb::serial::Write for BufferedUartTx<'d, T> { + fn write(&mut self, char: u8) -> nb::Result<(), Self::Error> { + self.blocking_write(&[char]).map(drop).map_err(nb::Error::Other) + } + + fn flush(&mut self) -> nb::Result<(), Self::Error> { + self.blocking_flush().map_err(nb::Error::Other) + } +} + +impl<'d, T: BasicInstance> embedded_hal_nb::serial::Read for BufferedUart<'d, T> { + fn read(&mut self) -> Result> { + embedded_hal_02::serial::Read::read(&mut self.rx) + } +} + +impl<'d, T: BasicInstance> embedded_hal_nb::serial::Write for BufferedUart<'d, T> { + fn write(&mut self, char: u8) -> nb::Result<(), Self::Error> { + self.tx.blocking_write(&[char]).map(drop).map_err(nb::Error::Other) + } + + fn flush(&mut self) -> nb::Result<(), Self::Error> { + self.tx.blocking_flush().map_err(nb::Error::Other) } } diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index ea127e7f..d5828a49 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs @@ -1010,102 +1010,93 @@ fn configure( Ok(()) } -mod eh02 { - use super::*; - - impl<'d, T: BasicInstance, RxDma> embedded_hal_02::serial::Read for UartRx<'d, T, RxDma> { - type Error = Error; - fn read(&mut self) -> Result> { - self.nb_read() - } +impl<'d, T: BasicInstance, RxDma> embedded_hal_02::serial::Read for UartRx<'d, T, RxDma> { + type Error = Error; + fn read(&mut self) -> Result> { + self.nb_read() } +} - impl<'d, T: BasicInstance, TxDma> embedded_hal_02::blocking::serial::Write for UartTx<'d, T, TxDma> { - type Error = Error; - fn bwrite_all(&mut self, buffer: &[u8]) -> Result<(), Self::Error> { - self.blocking_write(buffer) - } - fn bflush(&mut self) -> Result<(), Self::Error> { - self.blocking_flush() - } +impl<'d, T: BasicInstance, TxDma> embedded_hal_02::blocking::serial::Write for UartTx<'d, T, TxDma> { + type Error = Error; + fn bwrite_all(&mut self, buffer: &[u8]) -> Result<(), Self::Error> { + self.blocking_write(buffer) } - - impl<'d, T: BasicInstance, TxDma, RxDma> embedded_hal_02::serial::Read for Uart<'d, T, TxDma, RxDma> { - type Error = Error; - fn read(&mut self) -> Result> { - self.nb_read() - } + fn bflush(&mut self) -> Result<(), Self::Error> { + self.blocking_flush() } +} - impl<'d, T: BasicInstance, TxDma, RxDma> embedded_hal_02::blocking::serial::Write for Uart<'d, T, TxDma, RxDma> { - type Error = Error; - fn bwrite_all(&mut self, buffer: &[u8]) -> Result<(), Self::Error> { - self.blocking_write(buffer) - } - fn bflush(&mut self) -> Result<(), Self::Error> { - self.blocking_flush() +impl<'d, T: BasicInstance, TxDma, RxDma> embedded_hal_02::serial::Read for Uart<'d, T, TxDma, RxDma> { + type Error = Error; + fn read(&mut self) -> Result> { + self.nb_read() + } +} + +impl<'d, T: BasicInstance, TxDma, RxDma> embedded_hal_02::blocking::serial::Write for Uart<'d, T, TxDma, RxDma> { + type Error = Error; + fn bwrite_all(&mut self, buffer: &[u8]) -> Result<(), Self::Error> { + self.blocking_write(buffer) + } + fn bflush(&mut self) -> Result<(), Self::Error> { + self.blocking_flush() + } +} + +impl embedded_hal_nb::serial::Error for Error { + fn kind(&self) -> embedded_hal_nb::serial::ErrorKind { + match *self { + Self::Framing => embedded_hal_nb::serial::ErrorKind::FrameFormat, + Self::Noise => embedded_hal_nb::serial::ErrorKind::Noise, + Self::Overrun => embedded_hal_nb::serial::ErrorKind::Overrun, + Self::Parity => embedded_hal_nb::serial::ErrorKind::Parity, + Self::BufferTooLong => embedded_hal_nb::serial::ErrorKind::Other, } } } -#[cfg(feature = "unstable-traits")] -mod eh1 { - use super::*; +impl<'d, T: BasicInstance, TxDma, RxDma> embedded_hal_nb::serial::ErrorType for Uart<'d, T, TxDma, RxDma> { + type Error = Error; +} - impl embedded_hal_nb::serial::Error for Error { - fn kind(&self) -> embedded_hal_nb::serial::ErrorKind { - match *self { - Self::Framing => embedded_hal_nb::serial::ErrorKind::FrameFormat, - Self::Noise => embedded_hal_nb::serial::ErrorKind::Noise, - Self::Overrun => embedded_hal_nb::serial::ErrorKind::Overrun, - Self::Parity => embedded_hal_nb::serial::ErrorKind::Parity, - Self::BufferTooLong => embedded_hal_nb::serial::ErrorKind::Other, - } - } +impl<'d, T: BasicInstance, TxDma> embedded_hal_nb::serial::ErrorType for UartTx<'d, T, TxDma> { + type Error = Error; +} + +impl<'d, T: BasicInstance, RxDma> embedded_hal_nb::serial::ErrorType for UartRx<'d, T, RxDma> { + type Error = Error; +} + +impl<'d, T: BasicInstance, RxDma> embedded_hal_nb::serial::Read for UartRx<'d, T, RxDma> { + fn read(&mut self) -> nb::Result { + self.nb_read() + } +} + +impl<'d, T: BasicInstance, TxDma> embedded_hal_nb::serial::Write for UartTx<'d, T, TxDma> { + fn write(&mut self, char: u8) -> nb::Result<(), Self::Error> { + self.blocking_write(&[char]).map_err(nb::Error::Other) } - impl<'d, T: BasicInstance, TxDma, RxDma> embedded_hal_nb::serial::ErrorType for Uart<'d, T, TxDma, RxDma> { - type Error = Error; + fn flush(&mut self) -> nb::Result<(), Self::Error> { + self.blocking_flush().map_err(nb::Error::Other) + } +} + +impl<'d, T: BasicInstance, TxDma, RxDma> embedded_hal_nb::serial::Read for Uart<'d, T, TxDma, RxDma> { + fn read(&mut self) -> Result> { + self.nb_read() + } +} + +impl<'d, T: BasicInstance, TxDma, RxDma> embedded_hal_nb::serial::Write for Uart<'d, T, TxDma, RxDma> { + fn write(&mut self, char: u8) -> nb::Result<(), Self::Error> { + self.blocking_write(&[char]).map_err(nb::Error::Other) } - impl<'d, T: BasicInstance, TxDma> embedded_hal_nb::serial::ErrorType for UartTx<'d, T, TxDma> { - type Error = Error; - } - - impl<'d, T: BasicInstance, RxDma> embedded_hal_nb::serial::ErrorType for UartRx<'d, T, RxDma> { - type Error = Error; - } - - impl<'d, T: BasicInstance, RxDma> embedded_hal_nb::serial::Read for UartRx<'d, T, RxDma> { - fn read(&mut self) -> nb::Result { - self.nb_read() - } - } - - impl<'d, T: BasicInstance, TxDma> embedded_hal_nb::serial::Write for UartTx<'d, T, TxDma> { - fn write(&mut self, char: u8) -> nb::Result<(), Self::Error> { - self.blocking_write(&[char]).map_err(nb::Error::Other) - } - - fn flush(&mut self) -> nb::Result<(), Self::Error> { - self.blocking_flush().map_err(nb::Error::Other) - } - } - - impl<'d, T: BasicInstance, TxDma, RxDma> embedded_hal_nb::serial::Read for Uart<'d, T, TxDma, RxDma> { - fn read(&mut self) -> Result> { - self.nb_read() - } - } - - impl<'d, T: BasicInstance, TxDma, RxDma> embedded_hal_nb::serial::Write for Uart<'d, T, TxDma, RxDma> { - fn write(&mut self, char: u8) -> nb::Result<(), Self::Error> { - self.blocking_write(&[char]).map_err(nb::Error::Other) - } - - fn flush(&mut self) -> nb::Result<(), Self::Error> { - self.blocking_flush().map_err(nb::Error::Other) - } + fn flush(&mut self) -> nb::Result<(), Self::Error> { + self.blocking_flush().map_err(nb::Error::Other) } } @@ -1159,47 +1150,39 @@ where } } -#[cfg(all(feature = "unstable-traits", feature = "nightly"))] -mod eio { - use super::*; - - impl embedded_io_async::Write for Uart<'_, T, TxDma, RxDma> - where - T: BasicInstance, - TxDma: super::TxDma, - { - async fn write(&mut self, buf: &[u8]) -> Result { - self.write(buf).await?; - Ok(buf.len()) - } - - async fn flush(&mut self) -> Result<(), Self::Error> { - self.blocking_flush() - } +impl embedded_io_async::Write for Uart<'_, T, TxDma, RxDma> +where + T: BasicInstance, + TxDma: self::TxDma, +{ + async fn write(&mut self, buf: &[u8]) -> Result { + self.write(buf).await?; + Ok(buf.len()) } - impl embedded_io_async::Write for UartTx<'_, T, TxDma> - where - T: BasicInstance, - TxDma: super::TxDma, - { - async fn write(&mut self, buf: &[u8]) -> Result { - self.write(buf).await?; - Ok(buf.len()) - } - - async fn flush(&mut self) -> Result<(), Self::Error> { - self.blocking_flush() - } + async fn flush(&mut self) -> Result<(), Self::Error> { + self.blocking_flush() + } +} + +impl embedded_io_async::Write for UartTx<'_, T, TxDma> +where + T: BasicInstance, + TxDma: self::TxDma, +{ + async fn write(&mut self, buf: &[u8]) -> Result { + self.write(buf).await?; + Ok(buf.len()) + } + + async fn flush(&mut self) -> Result<(), Self::Error> { + self.blocking_flush() } } -#[cfg(feature = "nightly")] pub use buffered::*; -#[cfg(feature = "nightly")] pub use crate::usart::buffered::InterruptHandler as BufferedInterruptHandler; -#[cfg(feature = "nightly")] mod buffered; #[cfg(not(gpdma))] @@ -1284,7 +1267,6 @@ pub(crate) mod sealed { fn regs() -> Regs; fn state() -> &'static State; - #[cfg(feature = "nightly")] fn buffered_state() -> &'static buffered::State; } @@ -1322,7 +1304,6 @@ macro_rules! impl_usart { &STATE } - #[cfg(feature = "nightly")] fn buffered_state() -> &'static buffered::State { static STATE: buffered::State = buffered::State::new(); &STATE diff --git a/embassy-stm32/src/usart/ringbuffered.rs b/embassy-stm32/src/usart/ringbuffered.rs index eceabbe9..b8d17e4e 100644 --- a/embassy-stm32/src/usart/ringbuffered.rs +++ b/embassy-stm32/src/usart/ringbuffered.rs @@ -7,7 +7,7 @@ use embassy_embedded_hal::SetConfig; use embassy_hal_internal::PeripheralRef; use futures::future::{select, Either}; -use super::{clear_interrupt_flags, rdr, reconfigure, sr, BasicInstance, Config, ConfigError, Error, UartRx}; +use super::{clear_interrupt_flags, rdr, reconfigure, sr, BasicInstance, Config, ConfigError, Error, RxDma, UartRx}; use crate::dma::ReadableRingBuffer; use crate::usart::{Regs, Sr}; @@ -240,28 +240,20 @@ fn clear_idle_flag(r: Regs) -> Sr { sr } -#[cfg(all(feature = "unstable-traits", feature = "nightly"))] -mod eio { - use embedded_io_async::{ErrorType, Read}; +impl embedded_io_async::ErrorType for RingBufferedUartRx<'_, T, Rx> +where + T: BasicInstance, + Rx: RxDma, +{ + type Error = Error; +} - use super::RingBufferedUartRx; - use crate::usart::{BasicInstance, Error, RxDma}; - - impl ErrorType for RingBufferedUartRx<'_, T, Rx> - where - T: BasicInstance, - Rx: RxDma, - { - type Error = Error; - } - - impl Read for RingBufferedUartRx<'_, T, Rx> - where - T: BasicInstance, - Rx: RxDma, - { - async fn read(&mut self, buf: &mut [u8]) -> Result { - self.read(buf).await - } +impl embedded_io_async::Read for RingBufferedUartRx<'_, T, Rx> +where + T: BasicInstance, + Rx: RxDma, +{ + async fn read(&mut self, buf: &mut [u8]) -> Result { + self.read(buf).await } } diff --git a/embassy-stm32/src/usb/mod.rs b/embassy-stm32/src/usb/mod.rs index bee287fe..d0b28946 100644 --- a/embassy-stm32/src/usb/mod.rs +++ b/embassy-stm32/src/usb/mod.rs @@ -1,9 +1,7 @@ use crate::interrupt; use crate::rcc::RccPeripheral; -#[cfg(feature = "nightly")] mod usb; -#[cfg(feature = "nightly")] pub use usb::*; pub(crate) mod sealed { diff --git a/embassy-stm32/src/usb_otg/mod.rs b/embassy-stm32/src/usb_otg/mod.rs index 12e5f0e6..be54a3d1 100644 --- a/embassy-stm32/src/usb_otg/mod.rs +++ b/embassy-stm32/src/usb_otg/mod.rs @@ -1,13 +1,10 @@ use crate::rcc::RccPeripheral; use crate::{interrupt, peripherals}; -#[cfg(feature = "nightly")] mod usb; -#[cfg(feature = "nightly")] pub use usb::*; // Using Instance::ENDPOINT_COUNT requires feature(const_generic_expr) so just define maximum eps -#[cfg(feature = "nightly")] const MAX_EP_COUNT: usize = 9; pub(crate) mod sealed { @@ -17,7 +14,6 @@ pub(crate) mod sealed { const ENDPOINT_COUNT: usize; fn regs() -> crate::pac::otg::Otg; - #[cfg(feature = "nightly")] fn state() -> &'static super::State<{ super::MAX_EP_COUNT }>; } } @@ -99,8 +95,7 @@ foreach_interrupt!( crate::pac::USB_OTG_FS } - #[cfg(feature = "nightly")] - fn state() -> &'static State { + fn state() -> &'static State { static STATE: State = State::new(); &STATE } @@ -151,8 +146,7 @@ foreach_interrupt!( unsafe { crate::pac::otg::Otg::from_ptr(crate::pac::USB_OTG_HS.as_ptr()) } } - #[cfg(feature = "nightly")] - fn state() -> &'static State { + fn state() -> &'static State { static STATE: State = State::new(); &STATE } diff --git a/embassy-sync/Cargo.toml b/embassy-sync/Cargo.toml index ffcd13d9..6588406a 100644 --- a/embassy-sync/Cargo.toml +++ b/embassy-sync/Cargo.toml @@ -16,14 +16,9 @@ categories = [ [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-sync-v$VERSION/embassy-sync/src/" src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-sync/src/" -features = ["nightly"] target = "thumbv7em-none-eabi" -[package.metadata.docs.rs] -features = ["nightly"] - [features] -nightly = ["dep:embedded-io-async"] std = [] turbowakers = [] @@ -35,7 +30,7 @@ futures-util = { version = "0.3.17", default-features = false } critical-section = "1.1" heapless = "0.8" cfg-if = "1.0.0" -embedded-io-async = { version = "0.6.1", optional = true } +embedded-io-async = { version = "0.6.1" } [dev-dependencies] futures-executor = { version = "0.3.17", features = [ "thread-pool" ] } diff --git a/embassy-sync/build.rs b/embassy-sync/build.rs index 6fe82b44..0a796b88 100644 --- a/embassy-sync/build.rs +++ b/embassy-sync/build.rs @@ -1,6 +1,21 @@ use std::env; +use std::ffi::OsString; +use std::process::Command; fn main() { + println!("cargo:rerun-if-changed=build.rs"); + + let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc")); + + let output = Command::new(rustc) + .arg("--version") + .output() + .expect("failed to run `rustc --version`"); + + if String::from_utf8_lossy(&output.stdout).contains("nightly") { + println!("cargo:rustc-cfg=nightly"); + } + let target = env::var("TARGET").unwrap(); if target.starts_with("thumbv6m-") { diff --git a/embassy-sync/src/lib.rs b/embassy-sync/src/lib.rs index 3ffcb913..b0ccfde5 100644 --- a/embassy-sync/src/lib.rs +++ b/embassy-sync/src/lib.rs @@ -1,6 +1,7 @@ #![cfg_attr(not(any(feature = "std", feature = "wasm")), no_std)] -#![cfg_attr(feature = "nightly", feature(async_fn_in_trait, impl_trait_projections))] -#![cfg_attr(feature = "nightly", allow(stable_features, unknown_lints, async_fn_in_trait))] +#![cfg_attr(nightly, feature(async_fn_in_trait, impl_trait_projections))] +#![cfg_attr(nightly, allow(stable_features, unknown_lints))] +#![allow(async_fn_in_trait)] #![allow(clippy::new_without_default)] #![doc = include_str!("../README.md")] #![warn(missing_docs)] diff --git a/embassy-sync/src/pipe.rs b/embassy-sync/src/pipe.rs index ec0cbbf2..42fe8ebd 100644 --- a/embassy-sync/src/pipe.rs +++ b/embassy-sync/src/pipe.rs @@ -1,6 +1,7 @@ //! Async byte stream pipe. use core::cell::{RefCell, UnsafeCell}; +use core::convert::Infallible; use core::future::Future; use core::ops::Range; use core::pin::Pin; @@ -457,84 +458,77 @@ where } } -#[cfg(feature = "nightly")] -mod io_impls { - use core::convert::Infallible; +impl embedded_io_async::ErrorType for Pipe { + type Error = Infallible; +} - use super::*; +impl embedded_io_async::Read for Pipe { + async fn read(&mut self, buf: &mut [u8]) -> Result { + Ok(Pipe::read(self, buf).await) + } +} - impl embedded_io_async::ErrorType for Pipe { - type Error = Infallible; +impl embedded_io_async::Write for Pipe { + async fn write(&mut self, buf: &[u8]) -> Result { + Ok(Pipe::write(self, buf).await) } - impl embedded_io_async::Read for Pipe { - async fn read(&mut self, buf: &mut [u8]) -> Result { - Ok(Pipe::read(self, buf).await) - } + async fn flush(&mut self) -> Result<(), Self::Error> { + Ok(()) + } +} + +impl embedded_io_async::ErrorType for &Pipe { + type Error = Infallible; +} + +impl embedded_io_async::Read for &Pipe { + async fn read(&mut self, buf: &mut [u8]) -> Result { + Ok(Pipe::read(self, buf).await) + } +} + +impl embedded_io_async::Write for &Pipe { + async fn write(&mut self, buf: &[u8]) -> Result { + Ok(Pipe::write(self, buf).await) } - impl embedded_io_async::Write for Pipe { - async fn write(&mut self, buf: &[u8]) -> Result { - Ok(Pipe::write(self, buf).await) - } + async fn flush(&mut self) -> Result<(), Self::Error> { + Ok(()) + } +} - async fn flush(&mut self) -> Result<(), Self::Error> { - Ok(()) - } +impl embedded_io_async::ErrorType for Reader<'_, M, N> { + type Error = Infallible; +} + +impl embedded_io_async::Read for Reader<'_, M, N> { + async fn read(&mut self, buf: &mut [u8]) -> Result { + Ok(Reader::read(self, buf).await) + } +} + +impl embedded_io_async::BufRead for Reader<'_, M, N> { + async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { + Ok(Reader::fill_buf(self).await) } - impl embedded_io_async::ErrorType for &Pipe { - type Error = Infallible; + fn consume(&mut self, amt: usize) { + Reader::consume(self, amt) + } +} + +impl embedded_io_async::ErrorType for Writer<'_, M, N> { + type Error = Infallible; +} + +impl embedded_io_async::Write for Writer<'_, M, N> { + async fn write(&mut self, buf: &[u8]) -> Result { + Ok(Writer::write(self, buf).await) } - impl embedded_io_async::Read for &Pipe { - async fn read(&mut self, buf: &mut [u8]) -> Result { - Ok(Pipe::read(self, buf).await) - } - } - - impl embedded_io_async::Write for &Pipe { - async fn write(&mut self, buf: &[u8]) -> Result { - Ok(Pipe::write(self, buf).await) - } - - async fn flush(&mut self) -> Result<(), Self::Error> { - Ok(()) - } - } - - impl embedded_io_async::ErrorType for Reader<'_, M, N> { - type Error = Infallible; - } - - impl embedded_io_async::Read for Reader<'_, M, N> { - async fn read(&mut self, buf: &mut [u8]) -> Result { - Ok(Reader::read(self, buf).await) - } - } - - impl embedded_io_async::BufRead for Reader<'_, M, N> { - async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { - Ok(Reader::fill_buf(self).await) - } - - fn consume(&mut self, amt: usize) { - Reader::consume(self, amt) - } - } - - impl embedded_io_async::ErrorType for Writer<'_, M, N> { - type Error = Infallible; - } - - impl embedded_io_async::Write for Writer<'_, M, N> { - async fn write(&mut self, buf: &[u8]) -> Result { - Ok(Writer::write(self, buf).await) - } - - async fn flush(&mut self) -> Result<(), Self::Error> { - Ok(()) - } + async fn flush(&mut self) -> Result<(), Self::Error> { + Ok(()) } } diff --git a/embassy-time/Cargo.toml b/embassy-time/Cargo.toml index 570e0efa..5cbb44b3 100644 --- a/embassy-time/Cargo.toml +++ b/embassy-time/Cargo.toml @@ -22,23 +22,16 @@ links = "embassy-time" [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-time-v$VERSION/embassy-time/src/" src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-time/src/" -features = ["nightly", "defmt", "unstable-traits", "std"] +features = ["defmt", "std"] target = "x86_64-unknown-linux-gnu" [package.metadata.docs.rs] -features = ["nightly", "defmt", "unstable-traits", "std"] +features = ["defmt", "std"] [features] std = ["tick-hz-1_000_000", "critical-section/std"] wasm = ["dep:wasm-bindgen", "dep:js-sys", "dep:wasm-timer", "tick-hz-1_000_000"] -# Enable nightly-only features -nightly = ["embedded-hal-async"] - -# Implement embedded-hal 1.0 alpha and embedded-hal-async traits. -# Implement embedded-hal-async traits if `nightly` is set as well. -unstable-traits = ["embedded-hal-1"] - # Display a timestamp of the number of seconds since startup next to defmt log messages # To use this you must have a time driver provided. defmt-timestamp-uptime = ["defmt"] @@ -242,8 +235,8 @@ defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6" } -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2", optional = true} -embedded-hal-async = { version = "=1.0.0-rc.2", optional = true} +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } +embedded-hal-async = { version = "=1.0.0-rc.2" } futures-util = { version = "0.3.17", default-features = false } critical-section = "1.1" @@ -258,4 +251,4 @@ wasm-timer = { version = "0.2.5", optional = true } [dev-dependencies] serial_test = "0.9" critical-section = { version = "1.1", features = ["std"] } -embassy-executor = { version = "0.3.3", path = "../embassy-executor", features = ["nightly"] } +embassy-executor = { version = "0.3.3", path = "../embassy-executor" } diff --git a/embassy-time/build.rs b/embassy-time/build.rs index 5b009566..78bd27ec 100644 --- a/embassy-time/build.rs +++ b/embassy-time/build.rs @@ -1,3 +1,18 @@ -// empty, needed to be able to use `links` in Cargo.toml. +use std::env; +use std::ffi::OsString; +use std::process::Command; -fn main() {} +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + + let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc")); + + let output = Command::new(rustc) + .arg("--version") + .output() + .expect("failed to run `rustc --version`"); + + if String::from_utf8_lossy(&output.stdout).contains("nightly") { + println!("cargo:rustc-cfg=nightly"); + } +} diff --git a/embassy-time/src/delay.rs b/embassy-time/src/delay.rs index aab56b1f..7ef5961f 100644 --- a/embassy-time/src/delay.rs +++ b/embassy-time/src/delay.rs @@ -1,4 +1,5 @@ use super::{Duration, Instant}; +use crate::Timer; /// Blocks for at least `duration`. pub fn block_for(duration: Duration) { @@ -14,83 +15,66 @@ pub fn block_for(duration: Duration) { /// active driver. pub struct Delay; -#[cfg(feature = "unstable-traits")] -mod eh1 { - use super::*; +impl embedded_hal_1::delay::DelayNs for Delay { + fn delay_ns(&mut self, ns: u32) { + block_for(Duration::from_nanos(ns as u64)) + } - impl embedded_hal_1::delay::DelayNs for Delay { - fn delay_ns(&mut self, ns: u32) { - block_for(Duration::from_nanos(ns as u64)) - } + fn delay_us(&mut self, us: u32) { + block_for(Duration::from_micros(us as u64)) + } - fn delay_us(&mut self, us: u32) { - block_for(Duration::from_micros(us as u64)) - } - - fn delay_ms(&mut self, ms: u32) { - block_for(Duration::from_millis(ms as u64)) - } + fn delay_ms(&mut self, ms: u32) { + block_for(Duration::from_millis(ms as u64)) } } -#[cfg(all(feature = "unstable-traits", feature = "nightly"))] -mod eha { - use super::*; - use crate::Timer; +impl embedded_hal_async::delay::DelayNs for Delay { + async fn delay_ns(&mut self, ns: u32) { + Timer::after_nanos(ns as _).await + } - impl embedded_hal_async::delay::DelayNs for Delay { - async fn delay_ns(&mut self, ns: u32) { - Timer::after_nanos(ns as _).await - } + async fn delay_us(&mut self, us: u32) { + Timer::after_micros(us as _).await + } - async fn delay_us(&mut self, us: u32) { - Timer::after_micros(us as _).await - } - - async fn delay_ms(&mut self, ms: u32) { - Timer::after_millis(ms as _).await - } + async fn delay_ms(&mut self, ms: u32) { + Timer::after_millis(ms as _).await } } -mod eh02 { - use embedded_hal_02::blocking::delay::{DelayMs, DelayUs}; - - use super::*; - - impl DelayMs for Delay { - fn delay_ms(&mut self, ms: u8) { - block_for(Duration::from_millis(ms as u64)) - } - } - - impl DelayMs for Delay { - fn delay_ms(&mut self, ms: u16) { - block_for(Duration::from_millis(ms as u64)) - } - } - - impl DelayMs for Delay { - fn delay_ms(&mut self, ms: u32) { - block_for(Duration::from_millis(ms as u64)) - } - } - - impl DelayUs for Delay { - fn delay_us(&mut self, us: u8) { - block_for(Duration::from_micros(us as u64)) - } - } - - impl DelayUs for Delay { - fn delay_us(&mut self, us: u16) { - block_for(Duration::from_micros(us as u64)) - } - } - - impl DelayUs for Delay { - fn delay_us(&mut self, us: u32) { - block_for(Duration::from_micros(us as u64)) - } +impl embedded_hal_02::blocking::delay::DelayMs for Delay { + fn delay_ms(&mut self, ms: u8) { + block_for(Duration::from_millis(ms as u64)) + } +} + +impl embedded_hal_02::blocking::delay::DelayMs for Delay { + fn delay_ms(&mut self, ms: u16) { + block_for(Duration::from_millis(ms as u64)) + } +} + +impl embedded_hal_02::blocking::delay::DelayMs for Delay { + fn delay_ms(&mut self, ms: u32) { + block_for(Duration::from_millis(ms as u64)) + } +} + +impl embedded_hal_02::blocking::delay::DelayUs for Delay { + fn delay_us(&mut self, us: u8) { + block_for(Duration::from_micros(us as u64)) + } +} + +impl embedded_hal_02::blocking::delay::DelayUs for Delay { + fn delay_us(&mut self, us: u16) { + block_for(Duration::from_micros(us as u64)) + } +} + +impl embedded_hal_02::blocking::delay::DelayUs for Delay { + fn delay_us(&mut self, us: u32) { + block_for(Duration::from_micros(us as u64)) } } diff --git a/embassy-time/src/lib.rs b/embassy-time/src/lib.rs index a0f6e382..82a7ee0d 100644 --- a/embassy-time/src/lib.rs +++ b/embassy-time/src/lib.rs @@ -1,6 +1,7 @@ #![cfg_attr(not(any(feature = "std", feature = "wasm", test)), no_std)] -#![cfg_attr(feature = "nightly", feature(async_fn_in_trait))] -#![cfg_attr(feature = "nightly", allow(stable_features, unknown_lints, async_fn_in_trait))] +#![cfg_attr(nightly, feature(async_fn_in_trait, impl_trait_projections))] +#![cfg_attr(nightly, allow(stable_features, unknown_lints))] +#![allow(async_fn_in_trait)] #![doc = include_str!("../README.md")] #![allow(clippy::new_without_default)] #![warn(missing_docs)] diff --git a/embassy-usb-driver/src/lib.rs b/embassy-usb-driver/src/lib.rs index 9c2dddda..3b705c8c 100644 --- a/embassy-usb-driver/src/lib.rs +++ b/embassy-usb-driver/src/lib.rs @@ -1,6 +1,5 @@ #![no_std] -#![feature(async_fn_in_trait)] -#![allow(stable_features, unknown_lints, async_fn_in_trait)] +#![allow(async_fn_in_trait)] #![doc = include_str!("../README.md")] #![warn(missing_docs)] diff --git a/examples/boot/application/nrf/Cargo.toml b/examples/boot/application/nrf/Cargo.toml index 8489be5a..193ca5a2 100644 --- a/examples/boot/application/nrf/Cargo.toml +++ b/examples/boot/application/nrf/Cargo.toml @@ -7,10 +7,10 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers", "arch-cortex-m", "executor-thread"] } -embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = ["nightly"] } -embassy-nrf = { version = "0.1.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly"] } -embassy-boot = { version = "0.1.0", path = "../../../../embassy-boot/boot", features = ["nightly"] } -embassy-boot-nrf = { version = "0.1.0", path = "../../../../embassy-boot/nrf", features = ["nightly"] } +embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = [] } +embassy-nrf = { version = "0.1.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", ] } +embassy-boot = { version = "0.1.0", path = "../../../../embassy-boot/boot", features = [] } +embassy-boot-nrf = { version = "0.1.0", path = "../../../../embassy-boot/nrf", features = [] } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } defmt = { version = "0.3", optional = true } diff --git a/examples/boot/application/rp/Cargo.toml b/examples/boot/application/rp/Cargo.toml index e22d0c89..3008552e 100644 --- a/examples/boot/application/rp/Cargo.toml +++ b/examples/boot/application/rp/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers", "arch-cortex-m", "executor-thread"] } -embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = ["nightly"] } -embassy-rp = { version = "0.1.0", path = "../../../../embassy-rp", features = ["time-driver", "unstable-traits", "nightly"] } -embassy-boot-rp = { version = "0.1.0", path = "../../../../embassy-boot/rp", features = ["nightly"] } +embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = [] } +embassy-rp = { version = "0.1.0", path = "../../../../embassy-rp", features = ["time-driver", ] } +embassy-boot-rp = { version = "0.1.0", path = "../../../../embassy-boot/rp", features = [] } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } defmt = "0.3" diff --git a/examples/boot/application/stm32f3/Cargo.toml b/examples/boot/application/stm32f3/Cargo.toml index c9cecd65..26c46bc2 100644 --- a/examples/boot/application/stm32f3/Cargo.toml +++ b/examples/boot/application/stm32f3/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } -embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f303re", "time-driver-any", "exti"] } -embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } +embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } +embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["stm32f303re", "time-driver-any", "exti"] } +embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } defmt = { version = "0.3", optional = true } diff --git a/examples/boot/application/stm32f7/Cargo.toml b/examples/boot/application/stm32f7/Cargo.toml index 7464adcb..a3d345b6 100644 --- a/examples/boot/application/stm32f7/Cargo.toml +++ b/examples/boot/application/stm32f7/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } -embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f767zi", "time-driver-any", "exti"] } -embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } +embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } +embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["stm32f767zi", "time-driver-any", "exti"] } +embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = [] } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } defmt = { version = "0.3", optional = true } diff --git a/examples/boot/application/stm32h7/Cargo.toml b/examples/boot/application/stm32h7/Cargo.toml index 887c53b8..56b95993 100644 --- a/examples/boot/application/stm32h7/Cargo.toml +++ b/examples/boot/application/stm32h7/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } -embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32h743zi", "time-driver-any", "exti"] } -embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } +embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } +embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["stm32h743zi", "time-driver-any", "exti"] } +embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = [] } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } defmt = { version = "0.3", optional = true } diff --git a/examples/boot/application/stm32l0/Cargo.toml b/examples/boot/application/stm32l0/Cargo.toml index 5a2492f0..02993e4e 100644 --- a/examples/boot/application/stm32l0/Cargo.toml +++ b/examples/boot/application/stm32l0/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } -embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l072cz", "time-driver-any", "exti", "memory-x"] } -embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } +embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } +embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["stm32l072cz", "time-driver-any", "exti", "memory-x"] } +embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = [] } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } defmt = { version = "0.3", optional = true } diff --git a/examples/boot/application/stm32l1/Cargo.toml b/examples/boot/application/stm32l1/Cargo.toml index 148adc11..771266cc 100644 --- a/examples/boot/application/stm32l1/Cargo.toml +++ b/examples/boot/application/stm32l1/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } -embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l151cb-a", "time-driver-any", "exti"] } -embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } +embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } +embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["stm32l151cb-a", "time-driver-any", "exti"] } +embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = [] } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } defmt = { version = "0.3", optional = true } diff --git a/examples/boot/application/stm32l4/Cargo.toml b/examples/boot/application/stm32l4/Cargo.toml index 27e1ff9a..d375ff25 100644 --- a/examples/boot/application/stm32l4/Cargo.toml +++ b/examples/boot/application/stm32l4/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } -embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l475vg", "time-driver-any", "exti"] } -embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } +embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } +embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["stm32l475vg", "time-driver-any", "exti"] } +embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = [] } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } defmt = { version = "0.3", optional = true } diff --git a/examples/boot/application/stm32wl/Cargo.toml b/examples/boot/application/stm32wl/Cargo.toml index 7f57eb88..05f48c7d 100644 --- a/examples/boot/application/stm32wl/Cargo.toml +++ b/examples/boot/application/stm32wl/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } -embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32wl55jc-cm4", "time-driver-any", "exti"] } -embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } +embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } +embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["stm32wl55jc-cm4", "time-driver-any", "exti"] } +embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = [] } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } defmt = { version = "0.3", optional = true } diff --git a/examples/boot/bootloader/nrf/Cargo.toml b/examples/boot/bootloader/nrf/Cargo.toml index db0ffaec..a639d57f 100644 --- a/examples/boot/bootloader/nrf/Cargo.toml +++ b/examples/boot/bootloader/nrf/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0" defmt = { version = "0.3", optional = true } defmt-rtt = { version = "0.4", optional = true } -embassy-nrf = { path = "../../../../embassy-nrf", features = ["nightly"] } +embassy-nrf = { path = "../../../../embassy-nrf", features = [] } embassy-boot-nrf = { path = "../../../../embassy-boot/nrf" } cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } diff --git a/examples/boot/bootloader/rp/Cargo.toml b/examples/boot/bootloader/rp/Cargo.toml index b139a4b5..14297c7e 100644 --- a/examples/boot/bootloader/rp/Cargo.toml +++ b/examples/boot/bootloader/rp/Cargo.toml @@ -9,10 +9,10 @@ license = "MIT OR Apache-2.0" defmt = { version = "0.3", optional = true } defmt-rtt = { version = "0.4", optional = true } -embassy-rp = { path = "../../../../embassy-rp", features = ["nightly"] } +embassy-rp = { path = "../../../../embassy-rp", features = [] } embassy-boot-rp = { path = "../../../../embassy-boot/rp" } embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } -embassy-time = { path = "../../../../embassy-time", features = ["nightly"] } +embassy-time = { path = "../../../../embassy-time", features = [] } cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } cortex-m-rt = { version = "0.7" } diff --git a/examples/boot/bootloader/stm32/Cargo.toml b/examples/boot/bootloader/stm32/Cargo.toml index 4816e62e..fb38c3a6 100644 --- a/examples/boot/bootloader/stm32/Cargo.toml +++ b/examples/boot/bootloader/stm32/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0" defmt = { version = "0.3", optional = true } defmt-rtt = { version = "0.4", optional = true } -embassy-stm32 = { path = "../../../../embassy-stm32", features = ["nightly"] } +embassy-stm32 = { path = "../../../../embassy-stm32", features = [] } embassy-boot-stm32 = { path = "../../../../embassy-boot/stm32" } cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } diff --git a/examples/nrf-rtos-trace/Cargo.toml b/examples/nrf-rtos-trace/Cargo.toml index e3524deb..c99c31aa 100644 --- a/examples/nrf-rtos-trace/Cargo.toml +++ b/examples/nrf-rtos-trace/Cargo.toml @@ -5,8 +5,7 @@ version = "0.1.0" license = "MIT OR Apache-2.0" [features] -default = ["log", "nightly"] -nightly = ["embassy-executor/nightly", "embassy-nrf/nightly", "embassy-nrf/unstable-traits"] +default = ["log"] log = [ "dep:log", "embassy-sync/log", @@ -33,7 +32,7 @@ log = { version = "0.4.17", optional = true } [[bin]] name = "rtos_trace" -required-features = ["nightly"] + [profile.release] debug = 2 diff --git a/examples/nrf52840-rtic/Cargo.toml b/examples/nrf52840-rtic/Cargo.toml index 5bb8dc8a..3448c690 100644 --- a/examples/nrf52840-rtic/Cargo.toml +++ b/examples/nrf52840-rtic/Cargo.toml @@ -9,8 +9,8 @@ rtic = { version = "2", features = ["thumbv7-backend"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime", "generic-queue"] } -embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["nightly", "unstable-traits", "defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } +embassy-time = { version = "0.1.5", path = "../../embassy-time", features = [ "defmt", "defmt-timestamp-uptime", "generic-queue"] } +embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = [ "defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } defmt = "0.3" defmt-rtt = "0.4" diff --git a/examples/nrf52840/Cargo.toml b/examples/nrf52840/Cargo.toml index d9b22a4d..e2e79eae 100644 --- a/examples/nrf52840/Cargo.toml +++ b/examples/nrf52840/Cargo.toml @@ -7,20 +7,7 @@ license = "MIT OR Apache-2.0" [features] default = ["nightly"] nightly = [ - "embedded-hal-async", - "embassy-executor/nightly", - "embassy-nrf/nightly", - "embassy-net/nightly", - "embassy-net-esp-hosted", - "embassy-net-enc28j60", - "embassy-nrf/unstable-traits", - "embassy-time/nightly", - "embassy-time/unstable-traits", "static_cell/nightly", - "embassy-usb", - "embedded-io-async", - "embedded-hal-bus/async", - "embassy-net", ] [dependencies] @@ -29,12 +16,12 @@ embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["de embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } -embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"], optional = true } -embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"], optional = true } +embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"] } +embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } embedded-io = { version = "0.6.0", features = ["defmt-03"] } -embedded-io-async = { version = "0.6.1", optional = true, features = ["defmt-03"] } -embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"], optional = true } -embassy-net-enc28j60 = { version = "0.1.0", path = "../../embassy-net-enc28j60", features = ["defmt"], optional = true } +embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } +embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] } +embassy-net-enc28j60 = { version = "0.1.0", path = "../../embassy-net-enc28j60", features = ["defmt"] } defmt = "0.3" defmt-rtt = "0.4" @@ -50,8 +37,8 @@ embedded-storage = "0.3.0" usbd-hid = "0.6.0" serde = { version = "1.0.136", default-features = false } embedded-hal = { version = "1.0.0-rc.2" } -embedded-hal-async = { version = "1.0.0-rc.2", optional = true } -embedded-hal-bus = { version = "0.1.0-rc.2" } +embedded-hal-async = { version = "1.0.0-rc.2" } +embedded-hal-bus = { version = "0.1.0-rc.2", features = ["async"] } num-integer = { version = "0.1.45", default-features = false } microfft = "0.5.0" diff --git a/examples/nrf5340/Cargo.toml b/examples/nrf5340/Cargo.toml index 25ae9749..b4d71c75 100644 --- a/examples/nrf5340/Cargo.toml +++ b/examples/nrf5340/Cargo.toml @@ -6,37 +6,12 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = [ - "defmt", -] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", - "nightly", - "defmt", - "integrated-timers", -] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = [ - "defmt", - "defmt-timestamp-uptime", -] } -embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = [ - "nightly", - "unstable-traits", - "defmt", - "nrf5340-app-s", - "time-driver-rtc1", - "gpiote", - "unstable-pac", -] } -embassy-net = { version = "0.2.0", path = "../../embassy-net", features = [ - "nightly", - "defmt", - "tcp", - "dhcpv4", - "medium-ethernet", -] } -embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = [ - "defmt", -] } +embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "defmt", "integrated-timers"] } +embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } +embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf5340-app-s", "time-driver-rtc1", "gpiote", "unstable-pac"] } +embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"] } +embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } embedded-io-async = { version = "0.6.1" } defmt = "0.3" @@ -46,9 +21,7 @@ static_cell = { version = "2", features = ["nightly"]} cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } cortex-m-rt = "0.7.0" panic-probe = { version = "0.3", features = ["print-defmt"] } -futures = { version = "0.3.17", default-features = false, features = [ - "async-await", -] } +futures = { version = "0.3.17", default-features = false, features = ["async-await"] } rand = { version = "0.8.4", default-features = false } embedded-storage = "0.3.0" usbd-hid = "0.6.0" diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index e0e0d8a7..08898e96 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml @@ -9,10 +9,10 @@ license = "MIT OR Apache-2.0" embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal", features = ["defmt"] } embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime"] } -embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["defmt", "unstable-traits", "nightly", "unstable-pac", "time-driver", "critical-section-impl"] } +embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } +embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["defmt", "unstable-pac", "time-driver", "critical-section-impl"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } -embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "udp", "dhcpv4", "medium-ethernet"] } +embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] } embassy-net-wiznet = { version = "0.1.0", path = "../../embassy-net-wiznet", features = ["defmt"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-usb-logger = { version = "0.1.0", path = "../../embassy-usb-logger" } diff --git a/examples/rp/src/bin/pio_uart.rs b/examples/rp/src/bin/pio_uart.rs index fb9d423e..c0ea2360 100644 --- a/examples/rp/src/bin/pio_uart.rs +++ b/examples/rp/src/bin/pio_uart.rs @@ -9,8 +9,7 @@ #![no_std] #![no_main] #![feature(type_alias_impl_trait)] -#![feature(async_fn_in_trait)] -#![allow(stable_features, unknown_lints, async_fn_in_trait)] +#![allow(async_fn_in_trait)] use defmt::{info, panic, trace}; use embassy_executor::Spawner; @@ -148,7 +147,7 @@ async fn usb_read<'d, T: Instance + 'd>( let n = usb_rx.read_packet(&mut buf).await?; let data = &buf[..n]; trace!("USB IN: {:x}", data); - uart_pipe_writer.write(data).await; + (*uart_pipe_writer).write(data).await; } } @@ -159,7 +158,7 @@ async fn usb_write<'d, T: Instance + 'd>( ) -> Result<(), Disconnected> { let mut buf = [0; 64]; loop { - let n = usb_pipe_reader.read(&mut buf).await; + let n = (*usb_pipe_reader).read(&mut buf).await; let data = &buf[..n]; trace!("USB OUT: {:x}", data); usb_tx.write_packet(&data).await?; @@ -179,7 +178,7 @@ async fn uart_read( } let data = &buf[..n]; trace!("UART IN: {:x}", buf); - usb_pipe_writer.write(data).await; + (*usb_pipe_writer).write(data).await; } } @@ -190,7 +189,7 @@ async fn uart_write( ) -> ! { let mut buf = [0; 64]; loop { - let n = uart_pipe_reader.read(&mut buf).await; + let n = (*uart_pipe_reader).read(&mut buf).await; let data = &buf[..n]; trace!("UART OUT: {:x}", data); let _ = uart_tx.write(&data).await; diff --git a/examples/rp/src/bin/wifi_ap_tcp_server.rs b/examples/rp/src/bin/wifi_ap_tcp_server.rs index b5344c18..ad1fa646 100644 --- a/examples/rp/src/bin/wifi_ap_tcp_server.rs +++ b/examples/rp/src/bin/wifi_ap_tcp_server.rs @@ -4,8 +4,7 @@ #![no_std] #![no_main] #![feature(type_alias_impl_trait)] -#![feature(async_fn_in_trait)] -#![allow(stable_features, unknown_lints, async_fn_in_trait)] +#![allow(async_fn_in_trait)] use core::str::from_utf8; diff --git a/examples/rp/src/bin/wifi_scan.rs b/examples/rp/src/bin/wifi_scan.rs index f2acaf3e..7adf52b8 100644 --- a/examples/rp/src/bin/wifi_scan.rs +++ b/examples/rp/src/bin/wifi_scan.rs @@ -4,8 +4,7 @@ #![no_std] #![no_main] #![feature(type_alias_impl_trait)] -#![feature(async_fn_in_trait)] -#![allow(stable_features, unknown_lints, async_fn_in_trait)] +#![allow(async_fn_in_trait)] use core::str; diff --git a/examples/rp/src/bin/wifi_tcp_server.rs b/examples/rp/src/bin/wifi_tcp_server.rs index 4e74ad11..ec6b4ee7 100644 --- a/examples/rp/src/bin/wifi_tcp_server.rs +++ b/examples/rp/src/bin/wifi_tcp_server.rs @@ -4,8 +4,7 @@ #![no_std] #![no_main] #![feature(type_alias_impl_trait)] -#![feature(async_fn_in_trait)] -#![allow(stable_features, unknown_lints, async_fn_in_trait)] +#![allow(async_fn_in_trait)] use core::str::from_utf8; diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index 2a59fd69..228b6aa0 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml @@ -7,8 +7,8 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["log"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-std", "executor-thread", "log", "nightly", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["log", "std", "nightly"] } -embassy-net = { version = "0.2.0", path = "../../embassy-net", features=[ "std", "nightly", "log", "medium-ethernet", "medium-ip", "tcp", "udp", "dns", "dhcpv4", "proto-ipv6"] } +embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["log", "std", ] } +embassy-net = { version = "0.2.0", path = "../../embassy-net", features=[ "std", "log", "medium-ethernet", "medium-ip", "tcp", "udp", "dns", "dhcpv4", "proto-ipv6"] } embassy-net-tuntap = { version = "0.1.0", path = "../../embassy-net-tuntap" } embassy-net-ppp = { version = "0.1.0", path = "../../embassy-net-ppp", features = ["log"]} embedded-io-async = { version = "0.6.1" } diff --git a/examples/std/src/bin/net_ppp.rs b/examples/std/src/bin/net_ppp.rs index 6ac31f2f..cee04e55 100644 --- a/examples/std/src/bin/net_ppp.rs +++ b/examples/std/src/bin/net_ppp.rs @@ -8,8 +8,7 @@ //! nc 192.168.7.10 1234 #![feature(type_alias_impl_trait)] -#![feature(async_fn_in_trait, impl_trait_projections)] -#![allow(stable_features, unknown_lints, async_fn_in_trait)] +#![allow(async_fn_in_trait)] #[path = "../serial_port.rs"] mod serial_port; diff --git a/examples/stm32c0/Cargo.toml b/examples/stm32c0/Cargo.toml index ec5b78b0..595cb76a 100644 --- a/examples/stm32c0/Cargo.toml +++ b/examples/stm32c0/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32c031c6 to your chip name, if necessary. -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32c031c6", "memory-x", "unstable-pac", "exti"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "time-driver-any", "stm32c031c6", "memory-x", "unstable-pac", "exti"] } embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } diff --git a/examples/stm32f0/Cargo.toml b/examples/stm32f0/Cargo.toml index 71b3aaa7..9e85da9c 100644 --- a/examples/stm32f0/Cargo.toml +++ b/examples/stm32f0/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32f091rc to your chip name, if necessary. -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "memory-x", "stm32f091rc", "time-driver-any", "exti", "unstable-pac"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "memory-x", "stm32f091rc", "time-driver-any", "exti", "unstable-pac"] } cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } cortex-m-rt = "0.7.0" defmt = "0.3" diff --git a/examples/stm32f1/Cargo.toml b/examples/stm32f1/Cargo.toml index 29483ec5..4c9508c2 100644 --- a/examples/stm32f1/Cargo.toml +++ b/examples/stm32f1/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32f103c8 to your chip name, if necessary. -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f103c8", "unstable-pac", "memory-x", "time-driver-any", "unstable-traits" ] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32f103c8", "unstable-pac", "memory-x", "time-driver-any" ] } embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } diff --git a/examples/stm32f2/Cargo.toml b/examples/stm32f2/Cargo.toml index f4262e20..f088f1cb 100644 --- a/examples/stm32f2/Cargo.toml +++ b/examples/stm32f2/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32f207zg to your chip name, if necessary. -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f207zg", "unstable-pac", "memory-x", "time-driver-any", "exti"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32f207zg", "unstable-pac", "memory-x", "time-driver-any", "exti"] } embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } diff --git a/examples/stm32f3/Cargo.toml b/examples/stm32f3/Cargo.toml index e556b2a4..ad6b8ef4 100644 --- a/examples/stm32f3/Cargo.toml +++ b/examples/stm32f3/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32f303ze to your chip name, if necessary. -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f303ze", "unstable-pac", "memory-x", "time-driver-any", "exti"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32f303ze", "unstable-pac", "memory-x", "time-driver-any", "exti"] } embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } diff --git a/examples/stm32f334/Cargo.toml b/examples/stm32f334/Cargo.toml index e9670ab0..5cdcabfb 100644 --- a/examples/stm32f334/Cargo.toml +++ b/examples/stm32f334/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f334r8", "unstable-pac", "memory-x", "time-driver-any", "exti"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32f334r8", "unstable-pac", "memory-x", "time-driver-any", "exti"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml index 8cee6d23..1e85371e 100644 --- a/examples/stm32f4/Cargo.toml +++ b/examples/stm32f4/Cargo.toml @@ -6,12 +6,12 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32f429zi to your chip name, if necessary. -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti", "embedded-sdmmc", "chrono"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti", "embedded-sdmmc", "chrono"] } embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] } +embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt" ] } -embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "nightly"] } +embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] } defmt = "0.3" defmt-rtt = "0.4" diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml index 8fe2f289..e029da2c 100644 --- a/examples/stm32f7/Cargo.toml +++ b/examples/stm32f7/Cargo.toml @@ -6,11 +6,11 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32f767zi to your chip name, if necessary. -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f767zi", "memory-x", "unstable-pac", "time-driver-any", "exti"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32f767zi", "memory-x", "unstable-pac", "time-driver-any", "exti"] } embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } -embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet"] } +embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"] } embedded-io-async = { version = "0.6.1" } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } diff --git a/examples/stm32g0/Cargo.toml b/examples/stm32g0/Cargo.toml index 437f1e75..7218dbd2 100644 --- a/examples/stm32g0/Cargo.toml +++ b/examples/stm32g0/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32g071rb to your chip name, if necessary. -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g071rb", "memory-x", "unstable-pac", "exti"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "time-driver-any", "stm32g071rb", "memory-x", "unstable-pac", "exti"] } embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } diff --git a/examples/stm32g4/Cargo.toml b/examples/stm32g4/Cargo.toml index f5b2ab32..b03c5adb 100644 --- a/examples/stm32g4/Cargo.toml +++ b/examples/stm32g4/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32g491re to your chip name, if necessary. -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g491re", "memory-x", "unstable-pac", "exti"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "time-driver-any", "stm32g491re", "memory-x", "unstable-pac", "exti"] } embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } diff --git a/examples/stm32h5/Cargo.toml b/examples/stm32h5/Cargo.toml index db34005a..d389463f 100644 --- a/examples/stm32h5/Cargo.toml +++ b/examples/stm32h5/Cargo.toml @@ -6,12 +6,11 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32h563zi to your chip name, if necessary. -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h563zi", "memory-x", "time-driver-any", "exti", "unstable-pac", "unstable-traits"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32h563zi", "memory-x", "time-driver-any", "exti", "unstable-pac"] } embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] } -embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6"] } -embedded-io-async = { version = "0.6.1" } +embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } defmt = "0.3" @@ -22,6 +21,7 @@ cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } embedded-hal-async = { version = "=1.0.0-rc.2" } +embedded-io-async = { version = "0.6.1" } embedded-nal-async = { version = "0.7.1" } panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index 2fe88dfa..85396d8c 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml @@ -6,12 +6,11 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32h743bi to your chip name, if necessary. -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h743bi", "time-driver-any", "exti", "memory-x", "unstable-pac", "unstable-traits", "chrono"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32h743bi", "time-driver-any", "exti", "memory-x", "unstable-pac", "chrono"] } embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] } -embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns"] } -embedded-io-async = { version = "0.6.1" } +embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } defmt = "0.3" @@ -23,6 +22,7 @@ embedded-hal = "0.2.6" embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } embedded-hal-async = { version = "=1.0.0-rc.2" } embedded-nal-async = { version = "0.7.1" } +embedded-io-async = { version = "0.6.1" } panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } heapless = { version = "0.8", default-features = false } diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index 15f7afe9..8ce1e235 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml @@ -6,11 +6,11 @@ license = "MIT OR Apache-2.0" [features] default = ["nightly"] -nightly = ["embassy-stm32/nightly", "embassy-time/nightly", "embassy-time/unstable-traits", "embassy-executor/nightly", "dep:embedded-io-async"] +nightly = ["embassy-executor/nightly"] [dependencies] # Change stm32l072cz to your chip name, if necessary. -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "unstable-traits", "memory-x"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "memory-x"] } embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } @@ -20,7 +20,7 @@ defmt-rtt = "0.4" embedded-storage = "0.3.0" embedded-io = { version = "0.6.0" } -embedded-io-async = { version = "0.6.1", optional = true } +embedded-io-async = { version = "0.6.1" } cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } cortex-m-rt = "0.7.0" diff --git a/examples/stm32l1/Cargo.toml b/examples/stm32l1/Cargo.toml index f8f5c776..94fe339a 100644 --- a/examples/stm32l1/Cargo.toml +++ b/examples/stm32l1/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32l151cb-a", "time-driver-any", "memory-x"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32l151cb-a", "time-driver-any", "memory-x"] } defmt = "0.3" defmt-rtt = "0.4" diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml index 350e6e26..a0fe457b 100644 --- a/examples/stm32l4/Cargo.toml +++ b/examples/stm32l4/Cargo.toml @@ -6,14 +6,14 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32l4s5vi to your chip name, if necessary. -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l4s5qi", "memory-x", "time-driver-any", "exti", "unstable-traits", "chrono"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "unstable-pac", "stm32l4s5qi", "memory-x", "time-driver-any", "exti", "chrono"] } embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768", "unstable-traits", "nightly"] } +embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768", ] } embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } embassy-net-adin1110 = { version = "0.2.0", path = "../../embassy-net-adin1110" } -embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "nightly", "udp", "tcp", "dhcpv4", "medium-ethernet"] } +embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "udp", "tcp", "dhcpv4", "medium-ethernet"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } embedded-io = { version = "0.6.0", features = ["defmt-03"] } diff --git a/examples/stm32l5/Cargo.toml b/examples/stm32l5/Cargo.toml index 7bca51ad..6591e837 100644 --- a/examples/stm32l5/Cargo.toml +++ b/examples/stm32l5/Cargo.toml @@ -6,12 +6,12 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32l552ze to your chip name, if necessary. -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l552ze", "time-driver-any", "exti", "unstable-traits", "memory-x"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "unstable-pac", "stm32l552ze", "time-driver-any", "exti", "memory-x"] } embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } -embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet"] } +embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } usbd-hid = "0.6.0" diff --git a/examples/stm32u5/Cargo.toml b/examples/stm32u5/Cargo.toml index 3d316ab3..28009786 100644 --- a/examples/stm32u5/Cargo.toml +++ b/examples/stm32u5/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32u585ai to your chip name, if necessary. -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32u585ai", "time-driver-any", "memory-x" ] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "unstable-pac", "stm32u585ai", "time-driver-any", "memory-x" ] } embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } diff --git a/examples/stm32wb/Cargo.toml b/examples/stm32wb/Cargo.toml index 19fdeb6f..70917511 100644 --- a/examples/stm32wb/Cargo.toml +++ b/examples/stm32wb/Cargo.toml @@ -6,12 +6,12 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32wb55rg to your chip name in both dependencies, if necessary. -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wb55rg", "time-driver-any", "memory-x", "exti"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32wb55rg", "time-driver-any", "memory-x", "exti"] } embassy-stm32-wpan = { version = "0.1.0", path = "../../embassy-stm32-wpan", features = ["defmt", "stm32wb55rg"] } embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } -embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "udp", "proto-ipv6", "medium-ieee802154", "nightly"], optional=true } +embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "udp", "proto-ipv6", "medium-ieee802154", ], optional=true } defmt = "0.3" defmt-rtt = "0.4" diff --git a/examples/stm32wba/Cargo.toml b/examples/stm32wba/Cargo.toml index cac6753c..e30782c8 100644 --- a/examples/stm32wba/Cargo.toml +++ b/examples/stm32wba/Cargo.toml @@ -5,11 +5,11 @@ version = "0.1.0" license = "MIT OR Apache-2.0" [dependencies] -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wba52cg", "time-driver-any", "memory-x", "exti"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32wba52cg", "time-driver-any", "memory-x", "exti"] } embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } -embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "udp", "proto-ipv6", "medium-ieee802154", "nightly"], optional=true } +embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "udp", "proto-ipv6", "medium-ieee802154", ], optional=true } defmt = "0.3" defmt-rtt = "0.4" diff --git a/examples/stm32wl/Cargo.toml b/examples/stm32wl/Cargo.toml index 4f608fcf..58872135 100644 --- a/examples/stm32wl/Cargo.toml +++ b/examples/stm32wl/Cargo.toml @@ -6,10 +6,10 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32wl55jc-cm4 to your chip name, if necessary. -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32wl55jc-cm4", "time-driver-any", "memory-x", "unstable-pac", "exti", "chrono"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32wl55jc-cm4", "time-driver-any", "memory-x", "unstable-pac", "exti", "chrono"] } embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } defmt = "0.3" diff --git a/examples/wasm/Cargo.toml b/examples/wasm/Cargo.toml index c6e95e61..7e4fdff8 100644 --- a/examples/wasm/Cargo.toml +++ b/examples/wasm/Cargo.toml @@ -10,7 +10,7 @@ crate-type = ["cdylib"] [dependencies] embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["log"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-wasm", "executor-thread", "log", "nightly", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["log", "wasm", "nightly"] } +embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["log", "wasm", ] } wasm-logger = "0.2.0" wasm-bindgen = "0.2" diff --git a/tests/nrf/Cargo.toml b/tests/nrf/Cargo.toml index 70bb17c1..4f9b5a5f 100644 --- a/tests/nrf/Cargo.toml +++ b/tests/nrf/Cargo.toml @@ -8,12 +8,12 @@ license = "MIT OR Apache-2.0" teleprobe-meta = "1" embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt", "nightly"] } +embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt", ] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "task-arena-size-16384", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "nightly", "unstable-traits", "defmt-timestamp-uptime"] } -embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nightly", "unstable-traits", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } +embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } +embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } -embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "nightly"] } +embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] } embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] } embassy-net-enc28j60 = { version = "0.1.0", path = "../../embassy-net-enc28j60", features = ["defmt"] } embedded-hal-async = { version = "1.0.0-rc.2" } diff --git a/tests/perf-client/Cargo.toml b/tests/perf-client/Cargo.toml index bab5ac49..6c40d18a 100644 --- a/tests/perf-client/Cargo.toml +++ b/tests/perf-client/Cargo.toml @@ -7,6 +7,6 @@ edition = "2021" [dependencies] embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "nightly", "unstable-traits"] } +embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", ] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } defmt = "0.3.0" diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index d69bd795..3c4e6a68 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -9,10 +9,10 @@ teleprobe-meta = "1.1" embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "nightly", "unstable-traits"] } -embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "time-driver", "critical-section-impl", "intrinsics", "rom-v2-intrinsics", "run-from-ram"] } +embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", ] } +embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = [ "defmt", "unstable-pac", "time-driver", "critical-section-impl", "intrinsics", "rom-v2-intrinsics", "run-from-ram"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } -embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "udp", "dhcpv4", "medium-ethernet"] } +embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] } embassy-net-wiznet = { version = "0.1.0", path = "../../embassy-net-wiznet", features = ["defmt"] } cyw43 = { path = "../../cyw43", features = ["defmt", "firmware-logs"] } cyw43-pio = { path = "../../cyw43-pio", features = ["defmt", "overclock"] } diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index ba72c642..cf91a952 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -51,10 +51,10 @@ teleprobe-meta = "1" embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "tick-hz-131_072", "defmt-timestamp-uptime"] } -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "memory-x", "time-driver-any"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "unstable-pac", "memory-x", "time-driver-any"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-stm32-wpan = { version = "0.1.0", path = "../../embassy-stm32-wpan", optional = true, features = ["defmt", "stm32wb55rg", "ble"] } -embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "udp", "dhcpv4", "medium-ethernet"] } +embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] } perf-client = { path = "../perf-client" } defmt = "0.3.0" From 270504d87da42ff8bbad2afb1b905dd14df3dc4c Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Fri, 1 Dec 2023 08:45:20 +0200 Subject: [PATCH 15/98] runtime.adoc: typo --- docs/modules/ROOT/pages/runtime.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/modules/ROOT/pages/runtime.adoc b/docs/modules/ROOT/pages/runtime.adoc index 8f4921f6..f2812dd7 100644 --- a/docs/modules/ROOT/pages/runtime.adoc +++ b/docs/modules/ROOT/pages/runtime.adoc @@ -27,7 +27,7 @@ If you use the `#[embassy_executor::main]` macro in your application, it creates Interrupts are a common way for peripherals to signal completion of some operation and fits well with the async execution model. The following diagram describes a typical application flow where (1) a task is polled and is attempting to make progress. The task then (2) instructs the peripheral to perform some operation, and awaits. After some time has passed, (3) an interrupt is raised, marking the completion of the operation. -The peripheral HAL then (4) ensures that interrupt signals are routed to to the peripheral and updating the peripheral state with the results of the operation. The executor is then (5) notified that the task should be polled, which it will do. +The peripheral HAL then (4) ensures that interrupt signals are routed to the peripheral and updating the peripheral state with the results of the operation. The executor is then (5) notified that the task should be polled, which it will do. image::embassy_irq.png[Interrupt handling] From 33cfef871d848c95af448c311c4c82aa0c19cece Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Fri, 1 Dec 2023 11:56:35 +0200 Subject: [PATCH 16/98] no_std and no_main can be used on stable --- docs/modules/ROOT/pages/basic_application.adoc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/modules/ROOT/pages/basic_application.adoc b/docs/modules/ROOT/pages/basic_application.adoc index 73774c71..6d0d0438 100644 --- a/docs/modules/ROOT/pages/basic_application.adoc +++ b/docs/modules/ROOT/pages/basic_application.adoc @@ -6,13 +6,22 @@ So you've got one of the xref:examples.adoc[examples] running, but what now? Let The full example can be found link:https://github.com/embassy-rs/embassy/tree/master/docs/modules/ROOT/examples/basic[here]. -=== Rust Nightly +=== Bare metal -The first thing you'll notice is a few declarations stating that Embassy requires some nightly features: +The first thing you'll notice is a few declarations, two of which indicate that Embassy is suitable for bare metal development: [source,rust] ---- -include::example$basic/src/main.rs[lines="1..3"] +include::example$basic/src/main.rs[lines="1..2"] +---- + +=== Rust Nightly + +The next declaration is a Rust Unstable feature, which means that Embassy requires Rust Nightly: + +[source,rust] +---- +include::example$basic/src/main.rs[lines="3"] ---- === Dealing with errors From c97f65ac609221067f7af4deb69d5b7d66d57c7a Mon Sep 17 00:00:00 2001 From: Badr Bouslikhin Date: Fri, 1 Dec 2023 15:05:31 +0100 Subject: [PATCH 17/98] stm32/rcc: make h7 rm0399 power supply configurable --- embassy-stm32/src/rcc/h.rs | 148 ++++++++++++++++++++++++++++++++++++- 1 file changed, 147 insertions(+), 1 deletion(-) diff --git a/embassy-stm32/src/rcc/h.rs b/embassy-stm32/src/rcc/h.rs index 1a9603d0..2d3550da 100644 --- a/embassy-stm32/src/rcc/h.rs +++ b/embassy-stm32/src/rcc/h.rs @@ -117,6 +117,57 @@ impl From for Timpre { } } +/// Power supply configuration +/// See RM0433 Rev 4 7.4 +#[cfg(pwr_h7rm0399)] +pub enum SupplyConfig { + /// Default power supply configuration. + /// V CORE Power Domains are supplied from the LDO according to VOS. + /// SMPS step-down converter enabled at 1.2V, may be used to supply the LDO. + Default, + + /// Power supply configuration using the LDO. + /// V CORE Power Domains are supplied from the LDO according to VOS. + /// LDO power mode (Main, LP, Off) will follow system low-power modes. + /// SMPS step-down converter disabled. + LDO, + + /// Power supply configuration directly from the SMPS step-down converter. + /// V CORE Power Domains are supplied from SMPS step-down converter according to VOS. + /// LDO bypassed. + /// SMPS step-down converter power mode (MR, LP, Off) will follow system low-power modes. + DirectSMPS, + + /// Power supply configuration from the SMPS step-down converter, that supplies the LDO. + /// V CORE Power Domains are supplied from the LDO according to VOS + /// LDO power mode (Main, LP, Off) will follow system low-power modes. + /// SMPS step-down converter enabled according to SDLEVEL, and supplies the LDO. + /// SMPS step-down converter power mode (MR, LP, Off) will follow system low-power modes. + SMPSLDO, + + /// Power supply configuration from SMPS supplying external circuits and potentially the LDO. + /// V CORE Power Domains are supplied from voltage regulator according to VOS + /// LDO power mode (Main, LP, Off) will follow system low-power modes. + /// SMPS step-down converter enabled according to SDLEVEL used to supply external circuits and may supply the LDO. + /// SMPS step-down converter forced ON in MR mode. + SMPSExternalLDO, + + /// Power supply configuration from SMPS supplying external circuits and bypassing the LDO. + /// V CORE supplied from external source + /// SMPS step-down converter enabled according to SDLEVEL used to supply external circuits and may supply the external source for V CORE . + /// SMPS step-down converter forced ON in MR mode. + SMPSExternalLDOBypass, +} + +/// SMPS step-down converter voltage output level. +/// This is only used in certain power supply configurations: +/// SMPSLDO, SMPSExternalLDO, SMPSExternalLDOBypass. +#[cfg(pwr_h7rm0399)] +pub enum SMPSSupplyVoltage { + V1_8, + V2_5, +} + /// Configuration of the core clocks #[non_exhaustive] pub struct Config { @@ -144,6 +195,10 @@ pub struct Config { pub timer_prescaler: TimerPrescaler, pub voltage_scale: VoltageScale, pub ls: super::LsConfig, + + #[cfg(pwr_h7rm0399)] + pub supply_config: SupplyConfig, + pub smps_supply_voltage: Option, } impl Default for Config { @@ -177,6 +232,10 @@ impl Default for Config { timer_prescaler: TimerPrescaler::DefaultX2, voltage_scale: VoltageScale::Scale0, ls: Default::default(), + + #[cfg(pwr_h7rm0399)] + supply_config: SupplyConfig::Default, + smps_supply_voltage: None, } } } @@ -194,7 +253,7 @@ pub(crate) unsafe fn init(config: Config) { w.set_bypass(false); }); - #[cfg(any(pwr_h7rm0399, pwr_h7rm0455, pwr_h7rm0468))] + #[cfg(any(pwr_h7rm0455, pwr_h7rm0468))] PWR.cr3().modify(|w| { // hardcode "Direct SPMS" for now, this is what works on nucleos with the // default solderbridge configuration. @@ -202,6 +261,93 @@ pub(crate) unsafe fn init(config: Config) { w.set_ldoen(false); }); + #[cfg(pwr_h7rm0399)] + { + match config.supply_config { + SupplyConfig::Default => { + PWR.cr3().modify(|w| { + w.set_sdlevel(0b00); + w.set_sdexthp(false); + w.set_sden(true); + w.set_ldoen(true); + w.set_bypass(false); + }); + } + SupplyConfig::LDO => { + PWR.cr3().modify(|w| { + w.set_sden(false); + w.set_ldoen(true); + w.set_bypass(false); + }); + } + SupplyConfig::DirectSMPS => { + PWR.cr3().modify(|w| { + w.set_sdexthp(false); + w.set_sden(true); + w.set_ldoen(false); + w.set_bypass(false); + }); + } + SupplyConfig::SMPSLDO => { + PWR.cr3().modify(|w| { + match config.smps_supply_voltage { + Some(SMPSSupplyVoltage::V1_8) => { + PWR.cr3().modify(|w| w.set_sdlevel(0b01)); + } + Some(SMPSSupplyVoltage::V2_5) => { + PWR.cr3().modify(|w| w.set_sdlevel(0b10)); + } + None => { + panic!("Supply configuration SMPSLDO requires a supply voltage to be set."); + } + } + w.set_sdexthp(false); + w.set_sden(true); + w.set_ldoen(true); + w.set_bypass(false); + }); + } + SupplyConfig::SMPSExternalLDO => { + PWR.cr3().modify(|w| { + match config.smps_supply_voltage { + Some(SMPSSupplyVoltage::V1_8) => { + PWR.cr3().modify(|w| w.set_sdlevel(0b01)); + } + Some(SMPSSupplyVoltage::V2_5) => { + PWR.cr3().modify(|w| w.set_sdlevel(0b10)); + } + None => { + panic!("Supply configuration SMPSExternalLDO requires a supply voltage to be set."); + } + } + w.set_sdexthp(true); + w.set_sden(true); + w.set_ldoen(true); + w.set_bypass(false); + }); + } + SupplyConfig::SMPSExternalLDOBypass => { + PWR.cr3().modify(|w| { + match config.smps_supply_voltage { + Some(SMPSSupplyVoltage::V1_8) => { + PWR.cr3().modify(|w| w.set_sdlevel(0b01)); + } + Some(SMPSSupplyVoltage::V2_5) => { + PWR.cr3().modify(|w| w.set_sdlevel(0b10)); + } + None => { + panic!("Supply configuration SMPSExternalLDOBypass requires a supply voltage to be set."); + } + } + w.set_sdexthp(true); + w.set_sden(true); + w.set_ldoen(false); + w.set_bypass(true); + }); + } + } + } + // Validate the supply configuration. If you are stuck here, it is // because the voltages on your board do not match those specified // in the D3CR.VOS and CR3.SDLEVEL fields. By default after reset From 8c0e2748db61c0b1794a2921e7a813fd8fa92529 Mon Sep 17 00:00:00 2001 From: Grant Miller Date: Fri, 1 Dec 2023 22:06:48 -0600 Subject: [PATCH 18/98] stm32/timer: Fix frequency off-by-one --- embassy-stm32/src/timer/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/embassy-stm32/src/timer/mod.rs b/embassy-stm32/src/timer/mod.rs index 913bfed2..2313a5b9 100644 --- a/embassy-stm32/src/timer/mod.rs +++ b/embassy-stm32/src/timer/mod.rs @@ -46,7 +46,10 @@ pub(crate) mod sealed { assert!(f > 0); let pclk_ticks_per_timer_period = timer_f / f; let psc: u16 = unwrap!(((pclk_ticks_per_timer_period - 1) / (1 << 16)).try_into()); - let arr: u16 = unwrap!((pclk_ticks_per_timer_period / (u32::from(psc) + 1)).try_into()); + let divide_by = pclk_ticks_per_timer_period / (u32::from(psc) + 1); + + // the timer counts `0..=arr`, we want it to count `0..divide_by` + let arr = unwrap!(u16::try_from(divide_by - 1)); let regs = Self::regs(); regs.psc().write(|r| r.set_psc(psc)); From 87c0f1525dee9c2762872426076ffa82dc45900b Mon Sep 17 00:00:00 2001 From: Badr Bouslikhin Date: Sat, 2 Dec 2023 14:45:36 +0100 Subject: [PATCH 19/98] stm32/rcc: enable power supply configurability for rm0455 and rm0468 --- embassy-stm32/src/rcc/h.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/embassy-stm32/src/rcc/h.rs b/embassy-stm32/src/rcc/h.rs index 2d3550da..55543472 100644 --- a/embassy-stm32/src/rcc/h.rs +++ b/embassy-stm32/src/rcc/h.rs @@ -119,7 +119,7 @@ impl From for Timpre { /// Power supply configuration /// See RM0433 Rev 4 7.4 -#[cfg(pwr_h7rm0399)] +#[cfg(any(pwr_h7rm0399, pwr_h7rm0455, pwr_h7rm0468))] pub enum SupplyConfig { /// Default power supply configuration. /// V CORE Power Domains are supplied from the LDO according to VOS. @@ -162,7 +162,7 @@ pub enum SupplyConfig { /// SMPS step-down converter voltage output level. /// This is only used in certain power supply configurations: /// SMPSLDO, SMPSExternalLDO, SMPSExternalLDOBypass. -#[cfg(pwr_h7rm0399)] +#[cfg(any(pwr_h7rm0399, pwr_h7rm0455, pwr_h7rm0468))] pub enum SMPSSupplyVoltage { V1_8, V2_5, @@ -196,7 +196,7 @@ pub struct Config { pub voltage_scale: VoltageScale, pub ls: super::LsConfig, - #[cfg(pwr_h7rm0399)] + #[cfg(any(pwr_h7rm0399, pwr_h7rm0455, pwr_h7rm0468))] pub supply_config: SupplyConfig, pub smps_supply_voltage: Option, } @@ -233,7 +233,7 @@ impl Default for Config { voltage_scale: VoltageScale::Scale0, ls: Default::default(), - #[cfg(pwr_h7rm0399)] + #[cfg(any(pwr_h7rm0399, pwr_h7rm0455, pwr_h7rm0468))] supply_config: SupplyConfig::Default, smps_supply_voltage: None, } @@ -253,15 +253,7 @@ pub(crate) unsafe fn init(config: Config) { w.set_bypass(false); }); - #[cfg(any(pwr_h7rm0455, pwr_h7rm0468))] - PWR.cr3().modify(|w| { - // hardcode "Direct SPMS" for now, this is what works on nucleos with the - // default solderbridge configuration. - w.set_sden(true); - w.set_ldoen(false); - }); - - #[cfg(pwr_h7rm0399)] + #[cfg(any(pwr_h7rm0399, pwr_h7rm0455, pwr_h7rm0468))] { match config.supply_config { SupplyConfig::Default => { From 22c39fd6970ceb335949e6cef15331c993105a14 Mon Sep 17 00:00:00 2001 From: Badr Bouslikhin Date: Sat, 2 Dec 2023 14:47:36 +0100 Subject: [PATCH 20/98] stm32/rcc: refactor h7 rm0455,rm0468 and rm0468 power management --- embassy-stm32/src/rcc/h.rs | 87 +++++++++++++------------------------- 1 file changed, 29 insertions(+), 58 deletions(-) diff --git a/embassy-stm32/src/rcc/h.rs b/embassy-stm32/src/rcc/h.rs index 55543472..644647d9 100644 --- a/embassy-stm32/src/rcc/h.rs +++ b/embassy-stm32/src/rcc/h.rs @@ -120,6 +120,7 @@ impl From for Timpre { /// Power supply configuration /// See RM0433 Rev 4 7.4 #[cfg(any(pwr_h7rm0399, pwr_h7rm0455, pwr_h7rm0468))] +#[derive(PartialEq)] pub enum SupplyConfig { /// Default power supply configuration. /// V CORE Power Domains are supplied from the LDO according to VOS. @@ -143,31 +144,43 @@ pub enum SupplyConfig { /// LDO power mode (Main, LP, Off) will follow system low-power modes. /// SMPS step-down converter enabled according to SDLEVEL, and supplies the LDO. /// SMPS step-down converter power mode (MR, LP, Off) will follow system low-power modes. - SMPSLDO, + SMPSLDO(SMPSSupplyVoltage), /// Power supply configuration from SMPS supplying external circuits and potentially the LDO. /// V CORE Power Domains are supplied from voltage regulator according to VOS /// LDO power mode (Main, LP, Off) will follow system low-power modes. /// SMPS step-down converter enabled according to SDLEVEL used to supply external circuits and may supply the LDO. /// SMPS step-down converter forced ON in MR mode. - SMPSExternalLDO, + SMPSExternalLDO(SMPSSupplyVoltage), /// Power supply configuration from SMPS supplying external circuits and bypassing the LDO. /// V CORE supplied from external source /// SMPS step-down converter enabled according to SDLEVEL used to supply external circuits and may supply the external source for V CORE . /// SMPS step-down converter forced ON in MR mode. - SMPSExternalLDOBypass, + SMPSExternalLDOBypass(SMPSSupplyVoltage), } /// SMPS step-down converter voltage output level. /// This is only used in certain power supply configurations: /// SMPSLDO, SMPSExternalLDO, SMPSExternalLDOBypass. #[cfg(any(pwr_h7rm0399, pwr_h7rm0455, pwr_h7rm0468))] +#[derive(PartialEq)] pub enum SMPSSupplyVoltage { V1_8, V2_5, } +#[cfg(any(pwr_h7rm0399, pwr_h7rm0455, pwr_h7rm0468))] +impl SMPSSupplyVoltage { + /// Convert SMPSSupplyVoltage to u8 representation. + fn to_u8(&self) -> u8 { + match self { + SMPSSupplyVoltage::V1_8 => 0b01, + SMPSSupplyVoltage::V2_5 => 0b10, + } + } +} + /// Configuration of the core clocks #[non_exhaustive] pub struct Config { @@ -198,7 +211,6 @@ pub struct Config { #[cfg(any(pwr_h7rm0399, pwr_h7rm0455, pwr_h7rm0468))] pub supply_config: SupplyConfig, - pub smps_supply_voltage: Option, } impl Default for Config { @@ -235,7 +247,6 @@ impl Default for Config { #[cfg(any(pwr_h7rm0399, pwr_h7rm0455, pwr_h7rm0468))] supply_config: SupplyConfig::Default, - smps_supply_voltage: None, } } } @@ -280,61 +291,21 @@ pub(crate) unsafe fn init(config: Config) { w.set_bypass(false); }); } - SupplyConfig::SMPSLDO => { + SupplyConfig::SMPSLDO(ref smps_supply_voltage) + | SupplyConfig::SMPSExternalLDO(ref smps_supply_voltage) + | SupplyConfig::SMPSExternalLDOBypass(ref smps_supply_voltage) => { PWR.cr3().modify(|w| { - match config.smps_supply_voltage { - Some(SMPSSupplyVoltage::V1_8) => { - PWR.cr3().modify(|w| w.set_sdlevel(0b01)); - } - Some(SMPSSupplyVoltage::V2_5) => { - PWR.cr3().modify(|w| w.set_sdlevel(0b10)); - } - None => { - panic!("Supply configuration SMPSLDO requires a supply voltage to be set."); - } - } - w.set_sdexthp(false); + w.set_sdlevel(smps_supply_voltage.to_u8()); + w.set_sdexthp(matches!( + config.supply_config, + SupplyConfig::SMPSExternalLDO(_) | SupplyConfig::SMPSExternalLDOBypass(_) + )); w.set_sden(true); - w.set_ldoen(true); - w.set_bypass(false); - }); - } - SupplyConfig::SMPSExternalLDO => { - PWR.cr3().modify(|w| { - match config.smps_supply_voltage { - Some(SMPSSupplyVoltage::V1_8) => { - PWR.cr3().modify(|w| w.set_sdlevel(0b01)); - } - Some(SMPSSupplyVoltage::V2_5) => { - PWR.cr3().modify(|w| w.set_sdlevel(0b10)); - } - None => { - panic!("Supply configuration SMPSExternalLDO requires a supply voltage to be set."); - } - } - w.set_sdexthp(true); - w.set_sden(true); - w.set_ldoen(true); - w.set_bypass(false); - }); - } - SupplyConfig::SMPSExternalLDOBypass => { - PWR.cr3().modify(|w| { - match config.smps_supply_voltage { - Some(SMPSSupplyVoltage::V1_8) => { - PWR.cr3().modify(|w| w.set_sdlevel(0b01)); - } - Some(SMPSSupplyVoltage::V2_5) => { - PWR.cr3().modify(|w| w.set_sdlevel(0b10)); - } - None => { - panic!("Supply configuration SMPSExternalLDOBypass requires a supply voltage to be set."); - } - } - w.set_sdexthp(true); - w.set_sden(true); - w.set_ldoen(false); - w.set_bypass(true); + w.set_ldoen(matches!( + config.supply_config, + SupplyConfig::SMPSLDO(_) | SupplyConfig::SMPSExternalLDO(_) + )); + w.set_bypass(matches!(config.supply_config, SupplyConfig::SMPSExternalLDOBypass(_))); }); } } From ea43d74780fd801a6e68820d01fd7dd21287acf8 Mon Sep 17 00:00:00 2001 From: Badr Bouslikhin Date: Sat, 2 Dec 2023 14:55:00 +0100 Subject: [PATCH 21/98] stm32/rcc: add missing h7 power config --- embassy-stm32/src/rcc/h.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/embassy-stm32/src/rcc/h.rs b/embassy-stm32/src/rcc/h.rs index 644647d9..1889eb28 100644 --- a/embassy-stm32/src/rcc/h.rs +++ b/embassy-stm32/src/rcc/h.rs @@ -158,6 +158,11 @@ pub enum SupplyConfig { /// SMPS step-down converter enabled according to SDLEVEL used to supply external circuits and may supply the external source for V CORE . /// SMPS step-down converter forced ON in MR mode. SMPSExternalLDOBypass(SMPSSupplyVoltage), + + /// Power supply configuration from an external source, SMPS disabled and the LDO bypassed. + /// V CORE supplied from external source + /// SMPS step-down converter disabled and LDO bypassed, voltage monitoring still active. + SMPSDisabledLDOBypass, } /// SMPS step-down converter voltage output level. @@ -308,6 +313,13 @@ pub(crate) unsafe fn init(config: Config) { w.set_bypass(matches!(config.supply_config, SupplyConfig::SMPSExternalLDOBypass(_))); }); } + SupplyConfig::SMPSDisabledLDOBypass => { + PWR.cr3().modify(|w| { + w.set_sden(false); + w.set_ldoen(false); + w.set_bypass(true); + }); + } } } From dd62bb16e541dae3ed6471d170f6de68a2a03252 Mon Sep 17 00:00:00 2001 From: Peter Hansen Date: Sun, 3 Dec 2023 13:47:26 -0500 Subject: [PATCH 22/98] minimum build code for new APPROTECT is chip type-specific --- embassy-nrf/src/chips/nrf52805.rs | 1 + embassy-nrf/src/chips/nrf52810.rs | 1 + embassy-nrf/src/chips/nrf52811.rs | 1 + embassy-nrf/src/chips/nrf52820.rs | 1 + embassy-nrf/src/chips/nrf52832.rs | 1 + embassy-nrf/src/chips/nrf52833.rs | 1 + embassy-nrf/src/chips/nrf52840.rs | 1 + embassy-nrf/src/lib.rs | 5 +++-- 8 files changed, 10 insertions(+), 2 deletions(-) diff --git a/embassy-nrf/src/chips/nrf52805.rs b/embassy-nrf/src/chips/nrf52805.rs index 70e4b486..624d6613 100644 --- a/embassy-nrf/src/chips/nrf52805.rs +++ b/embassy-nrf/src/chips/nrf52805.rs @@ -7,6 +7,7 @@ pub const FORCE_COPY_BUFFER_SIZE: usize = 256; pub const FLASH_SIZE: usize = 192 * 1024; pub const RESET_PIN: u32 = 21; +pub const APPROTECT_MIN_BUILD_CODE: u8 = b'B'; embassy_hal_internal::peripherals! { // RTC diff --git a/embassy-nrf/src/chips/nrf52810.rs b/embassy-nrf/src/chips/nrf52810.rs index 7416d391..002feab3 100644 --- a/embassy-nrf/src/chips/nrf52810.rs +++ b/embassy-nrf/src/chips/nrf52810.rs @@ -7,6 +7,7 @@ pub const FORCE_COPY_BUFFER_SIZE: usize = 256; pub const FLASH_SIZE: usize = 192 * 1024; pub const RESET_PIN: u32 = 21; +pub const APPROTECT_MIN_BUILD_CODE: u8 = b'E'; embassy_hal_internal::peripherals! { // RTC diff --git a/embassy-nrf/src/chips/nrf52811.rs b/embassy-nrf/src/chips/nrf52811.rs index 58801068..5952907f 100644 --- a/embassy-nrf/src/chips/nrf52811.rs +++ b/embassy-nrf/src/chips/nrf52811.rs @@ -7,6 +7,7 @@ pub const FORCE_COPY_BUFFER_SIZE: usize = 256; pub const FLASH_SIZE: usize = 192 * 1024; pub const RESET_PIN: u32 = 21; +pub const APPROTECT_MIN_BUILD_CODE: u8 = b'B'; embassy_hal_internal::peripherals! { // RTC diff --git a/embassy-nrf/src/chips/nrf52820.rs b/embassy-nrf/src/chips/nrf52820.rs index 85184d48..c2f792cb 100644 --- a/embassy-nrf/src/chips/nrf52820.rs +++ b/embassy-nrf/src/chips/nrf52820.rs @@ -7,6 +7,7 @@ pub const FORCE_COPY_BUFFER_SIZE: usize = 512; pub const FLASH_SIZE: usize = 256 * 1024; pub const RESET_PIN: u32 = 18; +pub const APPROTECT_MIN_BUILD_CODE: u8 = b'D'; embassy_hal_internal::peripherals! { // USB diff --git a/embassy-nrf/src/chips/nrf52832.rs b/embassy-nrf/src/chips/nrf52832.rs index ae39628d..65d52364 100644 --- a/embassy-nrf/src/chips/nrf52832.rs +++ b/embassy-nrf/src/chips/nrf52832.rs @@ -11,6 +11,7 @@ pub const FORCE_COPY_BUFFER_SIZE: usize = 255; pub const FLASH_SIZE: usize = 512 * 1024; pub const RESET_PIN: u32 = 21; +pub const APPROTECT_MIN_BUILD_CODE: u8 = b'G'; embassy_hal_internal::peripherals! { // RTC diff --git a/embassy-nrf/src/chips/nrf52833.rs b/embassy-nrf/src/chips/nrf52833.rs index 342ae8b1..7c9b66d6 100644 --- a/embassy-nrf/src/chips/nrf52833.rs +++ b/embassy-nrf/src/chips/nrf52833.rs @@ -7,6 +7,7 @@ pub const FORCE_COPY_BUFFER_SIZE: usize = 512; pub const FLASH_SIZE: usize = 512 * 1024; pub const RESET_PIN: u32 = 18; +pub const APPROTECT_MIN_BUILD_CODE: u8 = b'B'; embassy_hal_internal::peripherals! { // USB diff --git a/embassy-nrf/src/chips/nrf52840.rs b/embassy-nrf/src/chips/nrf52840.rs index a5cbd798..51c55cd4 100644 --- a/embassy-nrf/src/chips/nrf52840.rs +++ b/embassy-nrf/src/chips/nrf52840.rs @@ -7,6 +7,7 @@ pub const FORCE_COPY_BUFFER_SIZE: usize = 512; pub const FLASH_SIZE: usize = 1024 * 1024; pub const RESET_PIN: u32 = 18; +pub const APPROTECT_MIN_BUILD_CODE: u8 = b'F'; embassy_hal_internal::peripherals! { // USB diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs index ed8aad89..3274dafb 100644 --- a/embassy-nrf/src/lib.rs +++ b/embassy-nrf/src/lib.rs @@ -349,10 +349,11 @@ pub fn init(config: config::Config) -> Peripherals { // Get the letter for the build code (b'A' .. b'F') let build_code = (variant >> 8) as u8; - if build_code >= b'F' { - // Chips with build code F and higher (revision 3 and higher) have an + if build_code >= chip::APPROTECT_MIN_BUILD_CODE { + // Chips with a certain chip type-specific build code or higher have an // improved APPROTECT ("hardware and software controlled access port protection") // which needs explicit action by the firmware to keep it unlocked + // See https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/working-with-the-nrf52-series-improved-approtect // UICR.APPROTECT = SwDisabled let res = uicr_write(consts::UICR_APPROTECT, consts::APPROTECT_DISABLED); From ca3891bb8cece2c24aa229248e71d41dd0b224f1 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Sun, 3 Dec 2023 22:25:51 +0100 Subject: [PATCH 23/98] executor: remove arch-xtensa. It's been broken for months and nobody has noticed. The `esp*-hal` crates have much better support. Fixes #2234 Closes #1912 --- embassy-executor/CHANGELOG.md | 4 ++ embassy-executor/Cargo.toml | 1 - embassy-executor/src/arch/xtensa.rs | 89 ----------------------------- embassy-executor/src/lib.rs | 4 +- 4 files changed, 5 insertions(+), 93 deletions(-) delete mode 100644 embassy-executor/src/arch/xtensa.rs diff --git a/embassy-executor/CHANGELOG.md b/embassy-executor/CHANGELOG.md index 559717da..c839981d 100644 --- a/embassy-executor/CHANGELOG.md +++ b/embassy-executor/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +- Removed `arch-xtensa`. Use the executor provided by the HAL crate (`esp-hal`, `esp32s3-hal`, etc...) instead. + ## 0.3.3 - 2023-11-15 - Add `main` macro reexport for Xtensa arch. diff --git a/embassy-executor/Cargo.toml b/embassy-executor/Cargo.toml index ae46b17c..bf58a2e1 100644 --- a/embassy-executor/Cargo.toml +++ b/embassy-executor/Cargo.toml @@ -57,7 +57,6 @@ critical-section = { version = "1.1", features = ["std"] } _arch = [] # some arch was picked arch-std = ["_arch", "critical-section/std"] arch-cortex-m = ["_arch", "dep:cortex-m"] -arch-xtensa = ["_arch"] arch-riscv32 = ["_arch", "dep:portable-atomic"] arch-wasm = ["_arch", "dep:wasm-bindgen", "dep:js-sys"] diff --git a/embassy-executor/src/arch/xtensa.rs b/embassy-executor/src/arch/xtensa.rs deleted file mode 100644 index 6ed9f9e7..00000000 --- a/embassy-executor/src/arch/xtensa.rs +++ /dev/null @@ -1,89 +0,0 @@ -#[cfg(feature = "executor-interrupt")] -compile_error!("`executor-interrupt` is not supported with `arch-xtensa`."); - -#[cfg(feature = "executor-thread")] -pub use thread::*; -#[cfg(feature = "executor-thread")] -mod thread { - use core::marker::PhantomData; - use core::sync::atomic::{AtomicBool, Ordering}; - - pub use embassy_macros::main_riscv as main; - - use crate::{raw, Spawner}; - - /// global atomic used to keep track of whether there is work to do since sev() is not available on Xtensa - static SIGNAL_WORK_THREAD_MODE: AtomicBool = AtomicBool::new(false); - - #[export_name = "__pender"] - fn __pender(_context: *mut ()) { - SIGNAL_WORK_THREAD_MODE.store(true, Ordering::SeqCst); - } - - /// Xtensa Executor - pub struct Executor { - inner: raw::Executor, - not_send: PhantomData<*mut ()>, - } - - impl Executor { - /// Create a new Executor. - pub fn new() -> Self { - Self { - inner: raw::Executor::new(core::ptr::null_mut()), - not_send: PhantomData, - } - } - - /// Run the executor. - /// - /// The `init` closure is called with a [`Spawner`] that spawns tasks on - /// this executor. Use it to spawn the initial task(s). After `init` returns, - /// the executor starts running the tasks. - /// - /// To spawn more tasks later, you may keep copies of the [`Spawner`] (it is `Copy`), - /// for example by passing it as an argument to the initial tasks. - /// - /// This function requires `&'static mut self`. This means you have to store the - /// Executor instance in a place where it'll live forever and grants you mutable - /// access. There's a few ways to do this: - /// - /// - a [StaticCell](https://docs.rs/static_cell/latest/static_cell/) (safe) - /// - a `static mut` (unsafe) - /// - a local variable in a function you know never returns (like `fn main() -> !`), upgrading its lifetime with `transmute`. (unsafe) - /// - /// This function never returns. - pub fn run(&'static mut self, init: impl FnOnce(Spawner)) -> ! { - init(self.inner.spawner()); - - loop { - unsafe { - self.inner.poll(); - - // Manual critical section implementation that only masks interrupts handlers. - // We must not acquire the cross-core on dual-core systems because that would - // prevent the other core from doing useful work while this core is sleeping. - let token: critical_section::RawRestoreState; - core::arch::asm!("rsil {0}, 5", out(reg) token); - - // we do not care about race conditions between the load and store operations, interrupts - // will only set this value to true. - // if there is work to do, loop back to polling - if SIGNAL_WORK_THREAD_MODE.load(Ordering::SeqCst) { - SIGNAL_WORK_THREAD_MODE.store(false, Ordering::SeqCst); - - core::arch::asm!( - "wsr.ps {0}", - "rsync", in(reg) token) - } else { - // waiti sets the PS.INTLEVEL when slipping into sleep - // because critical sections in Xtensa are implemented via increasing - // PS.INTLEVEL the critical section ends here - // take care not add code after `waiti` if it needs to be inside the CS - core::arch::asm!("waiti 0"); // critical section ends here - } - } - } - } - } -} diff --git a/embassy-executor/src/lib.rs b/embassy-executor/src/lib.rs index d8ac4893..89769615 100644 --- a/embassy-executor/src/lib.rs +++ b/embassy-executor/src/lib.rs @@ -1,5 +1,4 @@ #![cfg_attr(not(any(feature = "arch-std", feature = "arch-wasm")), no_std)] -#![cfg_attr(feature = "arch-xtensa", feature(asm_experimental_arch))] #![allow(clippy::new_without_default)] #![doc = include_str!("../README.md")] #![warn(missing_docs)] @@ -21,12 +20,11 @@ macro_rules! check_at_most_one { check_at_most_one!(@amo [$($f)*] [$($f)*] []); }; } -check_at_most_one!("arch-cortex-m", "arch-riscv32", "arch-xtensa", "arch-std", "arch-wasm",); +check_at_most_one!("arch-cortex-m", "arch-riscv32", "arch-std", "arch-wasm",); #[cfg(feature = "_arch")] #[cfg_attr(feature = "arch-cortex-m", path = "arch/cortex_m.rs")] #[cfg_attr(feature = "arch-riscv32", path = "arch/riscv32.rs")] -#[cfg_attr(feature = "arch-xtensa", path = "arch/xtensa.rs")] #[cfg_attr(feature = "arch-std", path = "arch/std.rs")] #[cfg_attr(feature = "arch-wasm", path = "arch/wasm.rs")] mod arch; From 9fb2eb7470d56d94bd8687b7566d60c3837df3a2 Mon Sep 17 00:00:00 2001 From: Peter Hansen Date: Sun, 3 Dec 2023 16:35:39 -0500 Subject: [PATCH 24/98] nrf52/qspi: avoid infinite busy-wait on QSPI read/write with zero-len buffer, fixes #2115 --- embassy-nrf/src/qspi.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) mode change 100644 => 100755 embassy-nrf/src/qspi.rs diff --git a/embassy-nrf/src/qspi.rs b/embassy-nrf/src/qspi.rs old mode 100644 new mode 100755 index add093b6..5e1a4e84 --- a/embassy-nrf/src/qspi.rs +++ b/embassy-nrf/src/qspi.rs @@ -391,8 +391,13 @@ impl<'d, T: Instance> Qspi<'d, T> { /// /// The difference with `read` is that this does not do bounds checks /// against the flash capacity. It is intended for use when QSPI is used as - /// a raw bus, not with flash memory. + /// a raw bus, not with flash memory. pub async fn read_raw(&mut self, address: u32, data: &mut [u8]) -> Result<(), Error> { + // Avoid blocking_wait_ready() blocking forever on zero-length buffers. + if data.len() == 0 { + return Ok(()); + } + let ondrop = OnDrop::new(Self::blocking_wait_ready); self.start_read(address, data)?; @@ -409,6 +414,11 @@ impl<'d, T: Instance> Qspi<'d, T> { /// against the flash capacity. It is intended for use when QSPI is used as /// a raw bus, not with flash memory. pub async fn write_raw(&mut self, address: u32, data: &[u8]) -> Result<(), Error> { + // Avoid blocking_wait_ready() blocking forever on zero-length buffers. + if data.len() == 0 { + return Ok(()); + } + let ondrop = OnDrop::new(Self::blocking_wait_ready); self.start_write(address, data)?; @@ -425,6 +435,11 @@ impl<'d, T: Instance> Qspi<'d, T> { /// against the flash capacity. It is intended for use when QSPI is used as /// a raw bus, not with flash memory. pub fn blocking_read_raw(&mut self, address: u32, data: &mut [u8]) -> Result<(), Error> { + // Avoid blocking_wait_ready() blocking forever on zero-length buffers. + if data.len() == 0 { + return Ok(()); + } + self.start_read(address, data)?; Self::blocking_wait_ready(); Ok(()) @@ -436,6 +451,11 @@ impl<'d, T: Instance> Qspi<'d, T> { /// against the flash capacity. It is intended for use when QSPI is used as /// a raw bus, not with flash memory. pub fn blocking_write_raw(&mut self, address: u32, data: &[u8]) -> Result<(), Error> { + // Avoid blocking_wait_ready() blocking forever on zero-length buffers. + if data.len() == 0 { + return Ok(()); + } + self.start_write(address, data)?; Self::blocking_wait_ready(); Ok(()) From 198ef8183e74543d013acd6b45d0efa861bb33fa Mon Sep 17 00:00:00 2001 From: Adam Greig Date: Sun, 3 Dec 2023 02:05:55 +0000 Subject: [PATCH 25/98] STM32: Add UID driver --- embassy-stm32/src/lib.rs | 2 ++ embassy-stm32/src/uid.rs | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 embassy-stm32/src/uid.rs diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 7ce801a0..13e189da 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs @@ -63,6 +63,8 @@ pub mod sai; pub mod sdmmc; #[cfg(spi)] pub mod spi; +#[cfg(uid)] +pub mod uid; #[cfg(usart)] pub mod usart; #[cfg(usb)] diff --git a/embassy-stm32/src/uid.rs b/embassy-stm32/src/uid.rs new file mode 100644 index 00000000..6dcfcb96 --- /dev/null +++ b/embassy-stm32/src/uid.rs @@ -0,0 +1,29 @@ +/// Get this device's unique 96-bit ID. +pub fn uid() -> &'static [u8; 12] { + unsafe { &*crate::pac::UID.uid(0).as_ptr().cast::<[u8; 12]>() } +} + +/// Get this device's unique 96-bit ID, encoded into a string of 24 hexadecimal ASCII digits. +pub fn uid_hex() -> &'static str { + unsafe { core::str::from_utf8_unchecked(uid_hex_bytes()) } +} + +/// Get this device's unique 96-bit ID, encoded into 24 hexadecimal ASCII bytes. +pub fn uid_hex_bytes() -> &'static [u8; 24] { + const HEX: &[u8; 16] = b"0123456789ABCDEF"; + static mut UID_HEX: [u8; 24] = [0; 24]; + static mut LOADED: bool = false; + critical_section::with(|_| unsafe { + if !LOADED { + let uid = uid(); + for (idx, v) in uid.iter().enumerate() { + let lo = v & 0x0f; + let hi = (v & 0xf0) >> 4; + UID_HEX[idx * 2] = HEX[hi as usize]; + UID_HEX[idx * 2 + 1] = HEX[lo as usize]; + } + LOADED = true; + } + }); + unsafe { &UID_HEX } +} From 35f16c6003b4be69ee18d24440560ce8a700169c Mon Sep 17 00:00:00 2001 From: Sam Mason Date: Mon, 4 Dec 2023 14:03:31 +1100 Subject: [PATCH 26/98] stm32: add ADC f3_v1_1 --- embassy-stm32/src/adc/f3_v1_1.rs | 408 +++++++++++++++++++++++++++ embassy-stm32/src/adc/mod.rs | 21 +- embassy-stm32/src/adc/resolution.rs | 26 +- embassy-stm32/src/adc/sample_time.rs | 25 ++ 4 files changed, 466 insertions(+), 14 deletions(-) create mode 100644 embassy-stm32/src/adc/f3_v1_1.rs diff --git a/embassy-stm32/src/adc/f3_v1_1.rs b/embassy-stm32/src/adc/f3_v1_1.rs new file mode 100644 index 00000000..0bbfd313 --- /dev/null +++ b/embassy-stm32/src/adc/f3_v1_1.rs @@ -0,0 +1,408 @@ +use core::future::poll_fn; +use core::marker::PhantomData; +use core::task::Poll; + +use embassy_futures::yield_now; +use embassy_hal_internal::into_ref; +use embassy_time::Instant; + +use super::Resolution; +use crate::adc::{Adc, AdcPin, Instance, SampleTime}; +use crate::interrupt::typelevel::Interrupt; +use crate::time::Hertz; +use crate::{interrupt, Peripheral}; + +const ADC_FREQ: Hertz = crate::rcc::HSI_FREQ; + +pub const VDDA_CALIB_MV: u32 = 3300; +pub const ADC_MAX: u32 = (1 << 12) - 1; +pub const VREF_INT: u32 = 1230; + +pub enum AdcPowerMode { + AlwaysOn, + DelayOff, + IdleOff, + DelayIdleOff, +} + +pub enum Prescaler { + Div1, + Div2, + Div3, + Div4, +} + +/// Interrupt handler. +pub struct InterruptHandler { + _phantom: PhantomData, +} + +impl interrupt::typelevel::Handler for InterruptHandler { + unsafe fn on_interrupt() { + if T::regs().sr().read().eoc() { + T::regs().cr1().modify(|w| w.set_eocie(false)); + } else { + return; + } + + T::state().waker.wake(); + } +} + +fn update_vref(op: i8) { + static VREF_STATUS: core::sync::atomic::AtomicU8 = core::sync::atomic::AtomicU8::new(0); + + if op > 0 { + if VREF_STATUS.fetch_add(1, core::sync::atomic::Ordering::SeqCst) == 0 { + T::regs().ccr().modify(|w| w.set_tsvrefe(true)); + } + } else { + if VREF_STATUS.fetch_sub(1, core::sync::atomic::Ordering::SeqCst) == 1 { + T::regs().ccr().modify(|w| w.set_tsvrefe(false)); + } + } +} + +pub struct Vref(core::marker::PhantomData); +impl AdcPin for Vref {} +impl super::sealed::AdcPin for Vref { + fn channel(&self) -> u8 { + 17 + } +} + +impl Vref { + /// The value that vref would be if vdda was at 3000mv + pub fn calibrated_value(&self) -> u16 { + crate::pac::VREFINTCAL.data().read().value() + } + + pub async fn calibrate(&mut self, adc: &mut Adc<'_, T>) -> Calibration { + let vref_val = adc.read(self).await; + Calibration { + vref_cal: self.calibrated_value(), + vref_val, + } + } +} + +pub struct Calibration { + vref_cal: u16, + vref_val: u16, +} + +impl Calibration { + /// The millivolts that the calibration value was measured at + pub const CALIBRATION_UV: u32 = 3_000_000; + + /// Returns the measured VddA in microvolts (uV) + pub fn vdda_uv(&self) -> u32 { + (Self::CALIBRATION_UV * self.vref_cal as u32) / self.vref_val as u32 + } + + /// Returns the measured VddA as an f32 + pub fn vdda_f32(&self) -> f32 { + (Self::CALIBRATION_UV as f32 / 1_000.0) * (self.vref_cal as f32 / self.vref_val as f32) + } + + /// Returns a calibrated voltage value as in microvolts (uV) + pub fn cal_uv(&self, raw: u16, resolution: super::Resolution) -> u32 { + (self.vdda_uv() / resolution.to_max_count()) * raw as u32 + } + + /// Returns a calibrated voltage value as an f32 + pub fn cal_f32(&self, raw: u16, resolution: super::Resolution) -> f32 { + raw as f32 * self.vdda_f32() / resolution.to_max_count() as f32 + } +} + +impl Drop for Vref { + fn drop(&mut self) { + update_vref::(-1) + } +} + +pub struct Temperature(core::marker::PhantomData); +impl AdcPin for Temperature {} +impl super::sealed::AdcPin for Temperature { + fn channel(&self) -> u8 { + 16 + } +} + +impl Drop for Temperature { + fn drop(&mut self) { + update_vref::(-1) + } +} + +impl<'d, T: Instance> Adc<'d, T> { + pub fn new( + adc: impl Peripheral

+ 'd, + _irq: impl interrupt::typelevel::Binding> + 'd, + ) -> Self { + into_ref!(adc); + + T::enable_and_reset(); + + //let r = T::regs(); + //r.cr2().write(|w| w.set_align(true)); + + T::Interrupt::unpend(); + unsafe { + T::Interrupt::enable(); + } + + Self { adc } + } + + fn freq() -> Hertz { + let div = T::regs().ccr().read().adcpre() + 1; + ADC_FREQ / div as u32 + } + + pub async fn set_resolution(&mut self, res: Resolution) { + let was_on = Self::is_on(); + if was_on { + self.stop_adc().await; + } + + T::regs().cr1().modify(|w| w.set_res(res.into())); + + if was_on { + self.start_adc().await; + } + } + + pub fn resolution(&self) -> Resolution { + T::regs().cr1().read().res().into() + } + + pub fn enable_vref(&self) -> Vref { + update_vref::(1); + + Vref(core::marker::PhantomData) + } + + pub fn enable_temperature(&self) -> Temperature { + T::regs().ccr().modify(|w| w.set_tsvrefe(true)); + + Temperature::(core::marker::PhantomData) + } + + /// Perform a single conversion. + async fn convert(&mut self) -> u16 { + let was_on = Self::is_on(); + + if !was_on { + self.start_adc().await; + } + + self.wait_sample_ready().await; + + T::regs().sr().write(|_| {}); + T::regs().cr1().modify(|w| { + w.set_eocie(true); + w.set_scan(false); + }); + T::regs().cr2().modify(|w| { + w.set_swstart(true); + w.set_cont(false); + }); // swstart cleared by HW + + let res = poll_fn(|cx| { + T::state().waker.register(cx.waker()); + + if T::regs().sr().read().eoc() { + let res = T::regs().dr().read().rdata(); + Poll::Ready(res) + } else { + Poll::Pending + } + }) + .await; + + if !was_on { + self.stop_adc().await; + } + + res + } + + #[inline(always)] + fn is_on() -> bool { + T::regs().sr().read().adons() || T::regs().cr2().read().adon() + } + + pub async fn start_adc(&self) { + //defmt::trace!("Turn ADC on"); + T::regs().cr2().modify(|w| w.set_adon(true)); + //defmt::trace!("Waiting for ADC to turn on"); + + let mut t = Instant::now(); + + while !T::regs().sr().read().adons() { + yield_now().await; + if t.elapsed() > embassy_time::Duration::from_millis(1000) { + t = Instant::now(); + //defmt::trace!("ADC still not on"); + } + } + + //defmt::trace!("ADC on"); + } + + pub async fn stop_adc(&self) { + if T::regs().cr2().read().adon() { + //defmt::trace!("ADC should be on, wait for it to start"); + while !T::regs().csr().read().adons1() { + yield_now().await; + } + } + + //defmt::trace!("Turn ADC off"); + + T::regs().cr2().modify(|w| w.set_adon(false)); + + //defmt::trace!("Waiting for ADC to turn off"); + + while T::regs().csr().read().adons1() { + yield_now().await; + } + } + + pub async fn read(&mut self, pin: &mut impl AdcPin) -> u16 { + self.set_sample_sequence(&[pin.channel()]).await; + self.convert().await + } + + async fn wait_sample_ready(&self) { + //trace!("Waiting for sample channel to be ready"); + while T::regs().sr().read().rcnr() { + yield_now().await; + } + } + + pub async fn set_sample_time(&mut self, pin: &mut impl AdcPin, sample_time: SampleTime) { + if Self::get_channel_sample_time(pin.channel()) != sample_time { + self.stop_adc().await; + unsafe { + Self::set_channel_sample_time(pin.channel(), sample_time); + } + self.start_adc().await; + } + } + + pub fn get_sample_time(&self, pin: &impl AdcPin) -> SampleTime { + Self::get_channel_sample_time(pin.channel()) + } + + /// Sets the channel sample time + /// + /// ## SAFETY: + /// - ADON == 0 i.e ADC must not be enabled when this is called. + unsafe fn set_channel_sample_time(ch: u8, sample_time: SampleTime) { + let sample_time = sample_time.into(); + + match ch { + 0..=9 => T::regs().smpr3().modify(|reg| reg.set_smp(ch as _, sample_time)), + 10..=19 => T::regs() + .smpr2() + .modify(|reg| reg.set_smp(ch as usize - 10, sample_time)), + 20..=29 => T::regs() + .smpr1() + .modify(|reg| reg.set_smp(ch as usize - 20, sample_time)), + 30..=31 => T::regs() + .smpr0() + .modify(|reg| reg.set_smp(ch as usize - 30, sample_time)), + _ => panic!("Invalid channel to sample"), + } + } + + fn get_channel_sample_time(ch: u8) -> SampleTime { + match ch { + 0..=9 => T::regs().smpr3().read().smp(ch as _), + 10..=19 => T::regs().smpr2().read().smp(ch as usize - 10), + 20..=29 => T::regs().smpr1().read().smp(ch as usize - 20), + 30..=31 => T::regs().smpr0().read().smp(ch as usize - 30), + _ => panic!("Invalid channel to sample"), + } + .into() + } + + /// Sets the sequence to sample the ADC. Must be less than 28 elements. + async fn set_sample_sequence(&self, sequence: &[u8]) { + assert!(sequence.len() <= 28); + let mut iter = sequence.iter(); + T::regs().sqr1().modify(|w| w.set_l((sequence.len() - 1) as _)); + for (idx, ch) in iter.by_ref().take(6).enumerate() { + T::regs().sqr5().modify(|w| w.set_sq(idx, *ch)); + } + for (idx, ch) in iter.by_ref().take(6).enumerate() { + T::regs().sqr4().modify(|w| w.set_sq(idx, *ch)); + } + for (idx, ch) in iter.by_ref().take(6).enumerate() { + T::regs().sqr3().modify(|w| w.set_sq(idx, *ch)); + } + for (idx, ch) in iter.by_ref().take(6).enumerate() { + T::regs().sqr2().modify(|w| w.set_sq(idx, *ch)); + } + for (idx, ch) in iter.by_ref().take(4).enumerate() { + T::regs().sqr1().modify(|w| w.set_sq(idx, *ch)); + } + } + + fn get_res_clks(res: Resolution) -> u32 { + match res { + Resolution::TwelveBit => 12, + Resolution::TenBit => 11, + Resolution::EightBit => 9, + Resolution::SixBit => 7, + } + } + + fn get_sample_time_clks(sample_time: SampleTime) -> u32 { + match sample_time { + SampleTime::Cycles4 => 4, + SampleTime::Cycles9 => 9, + SampleTime::Cycles16 => 16, + SampleTime::Cycles24 => 24, + SampleTime::Cycles48 => 48, + SampleTime::Cycles96 => 96, + SampleTime::Cycles192 => 192, + SampleTime::Cycles384 => 384, + } + } + + pub fn sample_time_for_us(&self, us: u32) -> SampleTime { + let res_clks = Self::get_res_clks(self.resolution()); + let us_clks = us * Self::freq().0 / 1_000_000; + let clks = us_clks.saturating_sub(res_clks); + match clks { + 0..=4 => SampleTime::Cycles4, + 5..=9 => SampleTime::Cycles9, + 10..=16 => SampleTime::Cycles16, + 17..=24 => SampleTime::Cycles24, + 25..=48 => SampleTime::Cycles48, + 49..=96 => SampleTime::Cycles96, + 97..=192 => SampleTime::Cycles192, + 193.. => SampleTime::Cycles384, + } + } + + pub fn us_for_cfg(&self, res: Resolution, sample_time: SampleTime) -> u32 { + let res_clks = Self::get_res_clks(res); + let sample_clks = Self::get_sample_time_clks(sample_time); + (res_clks + sample_clks) * 1_000_000 / Self::freq().0 + } +} + +impl<'d, T: Instance> Drop for Adc<'d, T> { + fn drop(&mut self) { + while !T::regs().sr().read().adons() {} + + T::regs().cr2().modify(|w| w.set_adon(false)); + + T::disable(); + } +} diff --git a/embassy-stm32/src/adc/mod.rs b/embassy-stm32/src/adc/mod.rs index 3e2980bf..dbe53c80 100644 --- a/embassy-stm32/src/adc/mod.rs +++ b/embassy-stm32/src/adc/mod.rs @@ -3,6 +3,7 @@ #[cfg(not(adc_f3_v2))] #[cfg_attr(adc_f1, path = "f1.rs")] #[cfg_attr(adc_f3, path = "f3.rs")] +#[cfg_attr(adc_f3_v1_1, path = "f3_v1_1.rs")] #[cfg_attr(adc_v1, path = "v1.rs")] #[cfg_attr(adc_v2, path = "v2.rs")] #[cfg_attr(any(adc_v3, adc_g0), path = "v3.rs")] @@ -26,20 +27,20 @@ use crate::peripherals; pub struct Adc<'d, T: Instance> { #[allow(unused)] adc: crate::PeripheralRef<'d, T>, - #[cfg(not(adc_f3_v2))] + #[cfg(not(any(adc_f3_v2, adc_f3_v1_1)))] sample_time: SampleTime, } pub(crate) mod sealed { - #[cfg(any(adc_f1, adc_f3, adc_v1))] + #[cfg(any(adc_f1, adc_f3, adc_v1, adc_f3_v1_1))] use embassy_sync::waitqueue::AtomicWaker; - #[cfg(any(adc_f1, adc_f3, adc_v1))] + #[cfg(any(adc_f1, adc_f3, adc_v1, adc_f3_v1_1))] pub struct State { pub waker: AtomicWaker, } - #[cfg(any(adc_f1, adc_f3, adc_v1))] + #[cfg(any(adc_f1, adc_f3, adc_v1, adc_f3_v1_1))] impl State { pub const fn new() -> Self { Self { @@ -54,11 +55,11 @@ pub(crate) mod sealed { pub trait Instance: InterruptableInstance { fn regs() -> crate::pac::adc::Adc; - #[cfg(not(any(adc_f1, adc_v1, adc_f3_v2, adc_g0)))] + #[cfg(not(any(adc_f1, adc_v1, adc_f3_v2, adc_f3_v1_1, adc_g0)))] fn common_regs() -> crate::pac::adccommon::AdcCommon; #[cfg(adc_f3)] fn frequency() -> crate::time::Hertz; - #[cfg(any(adc_f1, adc_f3, adc_v1))] + #[cfg(any(adc_f1, adc_f3, adc_v1, adc_f3_v1_1))] fn state() -> &'static State; } @@ -74,9 +75,9 @@ pub(crate) mod sealed { } } -#[cfg(not(any(adc_f1, adc_v1, adc_v2, adc_v3, adc_v4, adc_f3, adc_g0)))] +#[cfg(not(any(adc_f1, adc_v1, adc_v2, adc_v3, adc_v4, adc_f3, adc_f3_v1_1, adc_g0)))] pub trait Instance: sealed::Instance + crate::Peripheral

{} -#[cfg(any(adc_f1, adc_v1, adc_v2, adc_v3, adc_v4, adc_f3, adc_g0))] +#[cfg(any(adc_f1, adc_v1, adc_v2, adc_v3, adc_v4, adc_f3, adc_f3_v1_1, adc_g0))] pub trait Instance: sealed::Instance + crate::Peripheral

+ crate::rcc::RccPeripheral {} pub trait AdcPin: sealed::AdcPin {} @@ -89,7 +90,7 @@ foreach_adc!( crate::pac::$inst } - #[cfg(not(any(adc_f1, adc_v1, adc_f3_v2, adc_g0)))] + #[cfg(not(any(adc_f1, adc_v1, adc_f3_v2, adc_f3_v1_1, adc_g0)))] fn common_regs() -> crate::pac::adccommon::AdcCommon { return crate::pac::$common_inst } @@ -99,7 +100,7 @@ foreach_adc!( unsafe { crate::rcc::get_freqs() }.$clock.unwrap() } - #[cfg(any(adc_f1, adc_f3, adc_v1))] + #[cfg(any(adc_f1, adc_f3, adc_v1, adc_f3_v1_1))] fn state() -> &'static sealed::State { static STATE: sealed::State = sealed::State::new(); &STATE diff --git a/embassy-stm32/src/adc/resolution.rs b/embassy-stm32/src/adc/resolution.rs index 5668137b..b1597a82 100644 --- a/embassy-stm32/src/adc/resolution.rs +++ b/embassy-stm32/src/adc/resolution.rs @@ -1,5 +1,6 @@ -#[cfg(any(adc_v1, adc_v2, adc_v3, adc_g0, adc_f3))] +#[cfg(any(adc_v1, adc_v2, adc_v3, adc_g0, adc_f3, adc_f3_v1_1))] #[derive(Clone, Copy, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Resolution { TwelveBit, TenBit, @@ -9,6 +10,7 @@ pub enum Resolution { #[cfg(adc_v4)] #[derive(Clone, Copy, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Resolution { SixteenBit, FourteenBit, @@ -19,7 +21,7 @@ pub enum Resolution { impl Default for Resolution { fn default() -> Self { - #[cfg(any(adc_v1, adc_v2, adc_v3, adc_g0, adc_f3))] + #[cfg(any(adc_v1, adc_v2, adc_v3, adc_g0, adc_f3, adc_f3_v1_1))] { Self::TwelveBit } @@ -40,12 +42,28 @@ impl From for crate::pac::adc::vals::Res { Resolution::TwelveBit => crate::pac::adc::vals::Res::TWELVEBIT, Resolution::TenBit => crate::pac::adc::vals::Res::TENBIT, Resolution::EightBit => crate::pac::adc::vals::Res::EIGHTBIT, - #[cfg(any(adc_v1, adc_v2, adc_v3, adc_g0, adc_f3))] + #[cfg(any(adc_v1, adc_v2, adc_v3, adc_g0, adc_f3, adc_f3_v1_1))] Resolution::SixBit => crate::pac::adc::vals::Res::SIXBIT, } } } +impl From for Resolution { + fn from(res: crate::pac::adc::vals::Res) -> Resolution { + match res { + #[cfg(adc_v4)] + crate::pac::adc::vals::Res::SIXTEENBIT => Resolution::SixteenBit, + #[cfg(adc_v4)] + crate::pac::adc::vals::Res::FOURTEENBITV => Resolution::FourteenBit, + crate::pac::adc::vals::Res::TWELVEBIT => Resolution::TwelveBit, + crate::pac::adc::vals::Res::TENBIT => Resolution::TenBit, + crate::pac::adc::vals::Res::EIGHTBIT => Resolution::EightBit, + #[cfg(any(adc_v1, adc_v2, adc_v3, adc_g0, adc_f3, adc_f3_v1_1, adc_f3_v3))] + crate::pac::adc::vals::Res::SIXBIT => Resolution::SixBit, + } + } +} + impl Resolution { pub fn to_max_count(&self) -> u32 { match self { @@ -56,7 +74,7 @@ impl Resolution { Resolution::TwelveBit => (1 << 12) - 1, Resolution::TenBit => (1 << 10) - 1, Resolution::EightBit => (1 << 8) - 1, - #[cfg(any(adc_v1, adc_v2, adc_v3, adc_g0, adc_f3))] + #[cfg(any(adc_v1, adc_v2, adc_v3, adc_g0, adc_f3, adc_f3_v1_1))] Resolution::SixBit => (1 << 6) - 1, } } diff --git a/embassy-stm32/src/adc/sample_time.rs b/embassy-stm32/src/adc/sample_time.rs index 6a661929..5a06f1a5 100644 --- a/embassy-stm32/src/adc/sample_time.rs +++ b/embassy-stm32/src/adc/sample_time.rs @@ -3,6 +3,7 @@ macro_rules! impl_sample_time { ($default_doc:expr, $default:ident, ($(($doc:expr, $variant:ident, $pac_variant:ident)),*)) => { #[doc = concat!("ADC sample time\n\nThe default setting is ", $default_doc, " ADC clock cycles.")] #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)] + #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum SampleTime { $( #[doc = concat!($doc, " ADC clock cycles.")] @@ -18,6 +19,14 @@ macro_rules! impl_sample_time { } } + impl From for SampleTime { + fn from(sample_time: crate::pac::adc::vals::SampleTime) -> SampleTime { + match sample_time { + $(crate::pac::adc::vals::SampleTime::$pac_variant => SampleTime::$variant),* + } + } + } + impl Default for SampleTime { fn default() -> Self { Self::$default @@ -121,3 +130,19 @@ impl_sample_time!( ("601.5", Cycles601_5, CYCLES601_5) ) ); + +#[cfg(any(adc_f3_v1_1))] +impl_sample_time!( + "4", + Cycles4, + ( + ("4", Cycles4, CYCLES4), + ("9", Cycles9, CYCLES9), + ("16", Cycles16, CYCLES16), + ("24", Cycles24, CYCLES24), + ("48", Cycles48, CYCLES48), + ("96", Cycles96, CYCLES96), + ("192", Cycles192, CYCLES192), + ("384", Cycles384, CYCLES384) + ) +); From 09592ffa6aaf9730b649104d79353c7e30ba10d4 Mon Sep 17 00:00:00 2001 From: Carlos Barrales Ruiz Date: Mon, 27 Nov 2023 15:00:48 +0100 Subject: [PATCH 27/98] stm32/rcc: Add support for HSE Oscillator in stm32g0 --- embassy-stm32/src/rcc/g0.rs | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/embassy-stm32/src/rcc/g0.rs b/embassy-stm32/src/rcc/g0.rs index 75613dd2..d3367b04 100644 --- a/embassy-stm32/src/rcc/g0.rs +++ b/embassy-stm32/src/rcc/g0.rs @@ -10,10 +10,18 @@ use crate::time::Hertz; /// HSI speed pub const HSI_FREQ: Hertz = Hertz(16_000_000); +#[derive(Clone, Copy, Eq, PartialEq)] +pub enum HseMode { + /// crystal/ceramic oscillator (HSEBYP=0) + Oscillator, + /// external analog clock (low swing) (HSEBYP=1) + Bypass, +} + /// System clock mux source #[derive(Clone, Copy)] pub enum ClockSrc { - HSE(Hertz), + HSE(Hertz, HseMode), HSI(HSIPrescaler), PLL(PllConfig), LSI, @@ -61,7 +69,7 @@ impl Default for PllConfig { #[derive(Clone, Copy, Eq, PartialEq)] pub enum PllSource { HSI, - HSE(Hertz), + HSE(Hertz, HseMode), } /// Clocks configutation @@ -90,7 +98,7 @@ impl PllConfig { pub(crate) fn init(self) -> Hertz { let (src, input_freq) = match self.source { PllSource::HSI => (vals::Pllsrc::HSI, HSI_FREQ), - PllSource::HSE(freq) => (vals::Pllsrc::HSE, freq), + PllSource::HSE(freq, _) => (vals::Pllsrc::HSE, freq), }; let m_freq = input_freq / self.m; @@ -125,8 +133,11 @@ impl PllConfig { RCC.cr().write(|w| w.set_hsion(true)); while !RCC.cr().read().hsirdy() {} } - PllSource::HSE(_) => { - RCC.cr().write(|w| w.set_hseon(true)); + PllSource::HSE(_, mode) => { + RCC.cr().write(|w| { + w.set_hsebyp(mode != HseMode::Oscillator); + w.set_hseon(true); + }); while !RCC.cr().read().hserdy() {} } } @@ -177,9 +188,12 @@ pub(crate) unsafe fn init(config: Config) { (HSI_FREQ / div, Sw::HSI) } - ClockSrc::HSE(freq) => { + ClockSrc::HSE(freq, mode) => { // Enable HSE - RCC.cr().write(|w| w.set_hseon(true)); + RCC.cr().write(|w| { + w.set_hseon(true); + w.set_hsebyp(mode != HseMode::Oscillator); + }); while !RCC.cr().read().hserdy() {} (freq, Sw::HSE) From 03325ea81be84a0472fe66d743afb064eed6b904 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 4 Dec 2023 13:47:21 +0100 Subject: [PATCH 28/98] update embedded-storage{,-async}, remove patch. --- .cargo/config.toml | 3 --- embassy-boot/boot/Cargo.toml | 4 ++-- embassy-boot/nrf/Cargo.toml | 4 ++-- embassy-boot/rp/Cargo.toml | 4 ++-- embassy-boot/stm32/Cargo.toml | 4 ++-- embassy-embedded-hal/Cargo.toml | 4 ++-- embassy-nrf/Cargo.toml | 2 +- embassy-rp/Cargo.toml | 2 +- embassy-stm32/Cargo.toml | 4 ++-- examples/boot/application/rp/Cargo.toml | 2 +- examples/boot/application/stm32f7/Cargo.toml | 2 +- examples/boot/application/stm32h7/Cargo.toml | 2 +- examples/boot/bootloader/rp/Cargo.toml | 2 +- examples/boot/bootloader/stm32/Cargo.toml | 2 +- examples/nrf52840/Cargo.toml | 2 +- examples/nrf5340/Cargo.toml | 2 +- examples/stm32f3/Cargo.toml | 2 +- examples/stm32f334/Cargo.toml | 2 +- examples/stm32f4/Cargo.toml | 2 +- examples/stm32f7/Cargo.toml | 2 +- examples/stm32h5/Cargo.toml | 2 +- examples/stm32h7/Cargo.toml | 2 +- examples/stm32l0/Cargo.toml | 2 +- examples/stm32l1/Cargo.toml | 2 +- examples/stm32wl/Cargo.toml | 2 +- 25 files changed, 30 insertions(+), 33 deletions(-) delete mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml deleted file mode 100644 index c1ab9a9b..00000000 --- a/.cargo/config.toml +++ /dev/null @@ -1,3 +0,0 @@ -[patch.crates-io] -embedded-storage = { git = "https://github.com/rust-embedded-community/embedded-storage", rev = "634302740f8d676538c3890748e7d7dfe372a040" } -embedded-storage-async = { git = "https://github.com/rust-embedded-community/embedded-storage", rev = "634302740f8d676538c3890748e7d7dfe372a040" } \ No newline at end of file diff --git a/embassy-boot/boot/Cargo.toml b/embassy-boot/boot/Cargo.toml index ee69bc26..ee1dacc2 100644 --- a/embassy-boot/boot/Cargo.toml +++ b/embassy-boot/boot/Cargo.toml @@ -29,8 +29,8 @@ log = { version = "0.4", optional = true } ed25519-dalek = { version = "1.0.1", default_features = false, features = ["u32_backend"], optional = true } embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } embassy-sync = { version = "0.4.0", path = "../../embassy-sync" } -embedded-storage = "0.3.0" -embedded-storage-async = { version = "0.4.0" } +embedded-storage = "0.3.1" +embedded-storage-async = { version = "0.4.1" } salty = { git = "https://github.com/ycrypto/salty.git", rev = "a9f17911a5024698406b75c0fac56ab5ccf6a8c7", optional = true } signature = { version = "1.6.4", default-features = false } diff --git a/embassy-boot/nrf/Cargo.toml b/embassy-boot/nrf/Cargo.toml index b1650631..e4ec175a 100644 --- a/embassy-boot/nrf/Cargo.toml +++ b/embassy-boot/nrf/Cargo.toml @@ -21,8 +21,8 @@ embassy-nrf = { path = "../../embassy-nrf" } embassy-boot = { path = "../boot", default-features = false } cortex-m = { version = "0.7.6" } cortex-m-rt = { version = "0.7" } -embedded-storage = "0.3.0" -embedded-storage-async = { version = "0.4.0" } +embedded-storage = "0.3.1" +embedded-storage-async = { version = "0.4.1" } cfg-if = "1.0.0" nrf-softdevice-mbr = { version = "0.1.0", git = "https://github.com/embassy-rs/nrf-softdevice.git", branch = "master", optional = true } diff --git a/embassy-boot/rp/Cargo.toml b/embassy-boot/rp/Cargo.toml index 7329ea57..ad385473 100644 --- a/embassy-boot/rp/Cargo.toml +++ b/embassy-boot/rp/Cargo.toml @@ -24,8 +24,8 @@ embassy-time = { path = "../../embassy-time" } cortex-m = { version = "0.7.6" } cortex-m-rt = { version = "0.7" } -embedded-storage = "0.3.0" -embedded-storage-async = { version = "0.4.0" } +embedded-storage = "0.3.1" +embedded-storage-async = { version = "0.4.1" } cfg-if = "1.0.0" [features] diff --git a/embassy-boot/stm32/Cargo.toml b/embassy-boot/stm32/Cargo.toml index a9f0e4f0..7dedf8c4 100644 --- a/embassy-boot/stm32/Cargo.toml +++ b/embassy-boot/stm32/Cargo.toml @@ -23,8 +23,8 @@ embassy-stm32 = { path = "../../embassy-stm32", default-features = false } embassy-boot = { path = "../boot", default-features = false } cortex-m = { version = "0.7.6" } cortex-m-rt = { version = "0.7" } -embedded-storage = "0.3.0" -embedded-storage-async = { version = "0.4.0" } +embedded-storage = "0.3.1" +embedded-storage-async = { version = "0.4.1" } cfg-if = "1.0.0" [features] diff --git a/embassy-embedded-hal/Cargo.toml b/embassy-embedded-hal/Cargo.toml index db4dc958..7cd796e8 100644 --- a/embassy-embedded-hal/Cargo.toml +++ b/embassy-embedded-hal/Cargo.toml @@ -25,8 +25,8 @@ embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = [ ] } embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } embedded-hal-async = { version = "=1.0.0-rc.2" } -embedded-storage = "0.3.0" -embedded-storage-async = { version = "0.4.0" } +embedded-storage = "0.3.1" +embedded-storage-async = { version = "0.4.1" } nb = "1.0.0" defmt = { version = "0.3", optional = true } diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index bde15267..2da81a0f 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml @@ -106,7 +106,7 @@ cortex-m = "0.7.6" critical-section = "1.1" rand_core = "0.6.3" fixed = "1.10.0" -embedded-storage = "0.3.0" +embedded-storage = "0.3.1" embedded-storage-async = "0.4.0" cfg-if = "1.0.0" diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index 1a2945a7..3c654975 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml @@ -71,7 +71,7 @@ chrono = { version = "0.4", default-features = false, optional = true } embedded-io = { version = "0.6.0" } embedded-io-async = { version = "0.6.1" } embedded-storage = { version = "0.3" } -embedded-storage-async = { version = "0.4.0" } +embedded-storage-async = { version = "0.4.1" } rand_core = "0.6.4" fixed = "1.23.1" diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 0ef60305..dc9b331c 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -46,8 +46,8 @@ embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } embedded-hal-async = { version = "=1.0.0-rc.2" } embedded-hal-nb = { version = "=1.0.0-rc.2" } -embedded-storage = "0.3.0" -embedded-storage-async = { version = "0.4.0" } +embedded-storage = "0.3.1" +embedded-storage-async = { version = "0.4.1" } defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } diff --git a/examples/boot/application/rp/Cargo.toml b/examples/boot/application/rp/Cargo.toml index 3008552e..54ec53b3 100644 --- a/examples/boot/application/rp/Cargo.toml +++ b/examples/boot/application/rp/Cargo.toml @@ -20,7 +20,7 @@ embedded-hal = { version = "0.2.6" } cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } cortex-m-rt = "0.7.0" -embedded-storage = "0.3.0" +embedded-storage = "0.3.1" [features] default = ["panic-reset"] diff --git a/examples/boot/application/stm32f7/Cargo.toml b/examples/boot/application/stm32f7/Cargo.toml index a3d345b6..57be97af 100644 --- a/examples/boot/application/stm32f7/Cargo.toml +++ b/examples/boot/application/stm32f7/Cargo.toml @@ -16,7 +16,7 @@ defmt = { version = "0.3", optional = true } defmt-rtt = { version = "0.4", optional = true } panic-reset = { version = "0.1.1" } embedded-hal = { version = "0.2.6" } -embedded-storage = "0.3.0" +embedded-storage = "0.3.1" cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } cortex-m-rt = "0.7.0" diff --git a/examples/boot/application/stm32h7/Cargo.toml b/examples/boot/application/stm32h7/Cargo.toml index 56b95993..057060f8 100644 --- a/examples/boot/application/stm32h7/Cargo.toml +++ b/examples/boot/application/stm32h7/Cargo.toml @@ -16,7 +16,7 @@ defmt = { version = "0.3", optional = true } defmt-rtt = { version = "0.4", optional = true } panic-reset = { version = "0.1.1" } embedded-hal = { version = "0.2.6" } -embedded-storage = "0.3.0" +embedded-storage = "0.3.1" cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } cortex-m-rt = "0.7.0" diff --git a/examples/boot/bootloader/rp/Cargo.toml b/examples/boot/bootloader/rp/Cargo.toml index 14297c7e..18693f06 100644 --- a/examples/boot/bootloader/rp/Cargo.toml +++ b/examples/boot/bootloader/rp/Cargo.toml @@ -16,7 +16,7 @@ embassy-time = { path = "../../../../embassy-time", features = [] } cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } cortex-m-rt = { version = "0.7" } -embedded-storage = "0.3.0" +embedded-storage = "0.3.1" embedded-storage-async = "0.4.0" cfg-if = "1.0.0" diff --git a/examples/boot/bootloader/stm32/Cargo.toml b/examples/boot/bootloader/stm32/Cargo.toml index fb38c3a6..aa2b9fbe 100644 --- a/examples/boot/bootloader/stm32/Cargo.toml +++ b/examples/boot/bootloader/stm32/Cargo.toml @@ -14,7 +14,7 @@ embassy-boot-stm32 = { path = "../../../../embassy-boot/stm32" } cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } cortex-m-rt = { version = "0.7" } -embedded-storage = "0.3.0" +embedded-storage = "0.3.1" embedded-storage-async = "0.4.0" cfg-if = "1.0.0" diff --git a/examples/nrf52840/Cargo.toml b/examples/nrf52840/Cargo.toml index e2e79eae..be521922 100644 --- a/examples/nrf52840/Cargo.toml +++ b/examples/nrf52840/Cargo.toml @@ -33,7 +33,7 @@ cortex-m-rt = "0.7.0" panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } rand = { version = "0.8.4", default-features = false } -embedded-storage = "0.3.0" +embedded-storage = "0.3.1" usbd-hid = "0.6.0" serde = { version = "1.0.136", default-features = false } embedded-hal = { version = "1.0.0-rc.2" } diff --git a/examples/nrf5340/Cargo.toml b/examples/nrf5340/Cargo.toml index b4d71c75..d14678ab 100644 --- a/examples/nrf5340/Cargo.toml +++ b/examples/nrf5340/Cargo.toml @@ -23,7 +23,7 @@ cortex-m-rt = "0.7.0" panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } rand = { version = "0.8.4", default-features = false } -embedded-storage = "0.3.0" +embedded-storage = "0.3.1" usbd-hid = "0.6.0" serde = { version = "1.0.136", default-features = false } diff --git a/examples/stm32f3/Cargo.toml b/examples/stm32f3/Cargo.toml index ad6b8ef4..fe852387 100644 --- a/examples/stm32f3/Cargo.toml +++ b/examples/stm32f3/Cargo.toml @@ -23,7 +23,7 @@ panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } heapless = { version = "0.8", default-features = false } nb = "1.0.0" -embedded-storage = "0.3.0" +embedded-storage = "0.3.1" static_cell = { version = "2", features = ["nightly"]} [profile.release] diff --git a/examples/stm32f334/Cargo.toml b/examples/stm32f334/Cargo.toml index 5cdcabfb..ad9060a2 100644 --- a/examples/stm32f334/Cargo.toml +++ b/examples/stm32f334/Cargo.toml @@ -22,5 +22,5 @@ panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } heapless = { version = "0.8", default-features = false } nb = "1.0.0" -embedded-storage = "0.3.0" +embedded-storage = "0.3.1" static_cell = { version = "2", features = ["nightly"]} diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml index 1e85371e..947805c4 100644 --- a/examples/stm32f4/Cargo.toml +++ b/examples/stm32f4/Cargo.toml @@ -25,7 +25,7 @@ panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } heapless = { version = "0.8", default-features = false } nb = "1.0.0" -embedded-storage = "0.3.0" +embedded-storage = "0.3.1" micromath = "2.0.0" static_cell = { version = "2", features = ["nightly"]} chrono = { version = "^0.4", default-features = false} diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml index e029da2c..2e1f27df 100644 --- a/examples/stm32f7/Cargo.toml +++ b/examples/stm32f7/Cargo.toml @@ -26,7 +26,7 @@ heapless = { version = "0.8", default-features = false } nb = "1.0.0" rand_core = "0.6.3" critical-section = "1.1" -embedded-storage = "0.3.0" +embedded-storage = "0.3.1" static_cell = { version = "2", features = ["nightly"]} [profile.release] diff --git a/examples/stm32h5/Cargo.toml b/examples/stm32h5/Cargo.toml index d389463f..d15ecee1 100644 --- a/examples/stm32h5/Cargo.toml +++ b/examples/stm32h5/Cargo.toml @@ -30,7 +30,7 @@ rand_core = "0.6.3" critical-section = "1.1" micromath = "2.0.0" stm32-fmc = "0.3.0" -embedded-storage = "0.3.0" +embedded-storage = "0.3.1" static_cell = { version = "2", features = ["nightly"]} # cargo build/run diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index 85396d8c..ea59b5c0 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml @@ -30,7 +30,7 @@ rand_core = "0.6.3" critical-section = "1.1" micromath = "2.0.0" stm32-fmc = "0.3.0" -embedded-storage = "0.3.0" +embedded-storage = "0.3.1" static_cell = { version = "2", features = ["nightly"]} chrono = { version = "^0.4", default-features = false } diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index 8ce1e235..9fad48df 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml @@ -18,7 +18,7 @@ embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["de defmt = "0.3" defmt-rtt = "0.4" -embedded-storage = "0.3.0" +embedded-storage = "0.3.1" embedded-io = { version = "0.6.0" } embedded-io-async = { version = "0.6.1" } diff --git a/examples/stm32l1/Cargo.toml b/examples/stm32l1/Cargo.toml index 94fe339a..907b8ea6 100644 --- a/examples/stm32l1/Cargo.toml +++ b/examples/stm32l1/Cargo.toml @@ -19,7 +19,7 @@ embedded-hal = "0.2.6" panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } heapless = { version = "0.8", default-features = false } -embedded-storage = "0.3.0" +embedded-storage = "0.3.1" [profile.release] debug = 2 diff --git a/examples/stm32wl/Cargo.toml b/examples/stm32wl/Cargo.toml index 58872135..13a16307 100644 --- a/examples/stm32wl/Cargo.toml +++ b/examples/stm32wl/Cargo.toml @@ -18,7 +18,7 @@ defmt-rtt = "0.4" cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" -embedded-storage = "0.3.0" +embedded-storage = "0.3.1" panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } heapless = { version = "0.8", default-features = false } From d7eb067b4c63bf8a8e9d986f032cd8013f7cdca2 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 4 Dec 2023 14:01:53 +0100 Subject: [PATCH 29/98] Remove embassy-lora from doc build. --- .github/ci/doc.sh | 1 - README.md | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/ci/doc.sh b/.github/ci/doc.sh index 66caa915..ed3036f2 100755 --- a/.github/ci/doc.sh +++ b/.github/ci/doc.sh @@ -22,7 +22,6 @@ docserver-builder -i ./embassy-boot/stm32 -o webroot/crates/embassy-boot-stm32/g docserver-builder -i ./embassy-embedded-hal -o webroot/crates/embassy-embedded-hal/git.zup docserver-builder -i ./embassy-executor -o webroot/crates/embassy-executor/git.zup docserver-builder -i ./embassy-futures -o webroot/crates/embassy-futures/git.zup -docserver-builder -i ./embassy-lora -o webroot/crates/embassy-lora/git.zup docserver-builder -i ./embassy-net -o webroot/crates/embassy-net/git.zup docserver-builder -i ./embassy-net-driver -o webroot/crates/embassy-net-driver/git.zup docserver-builder -i ./embassy-net-driver-channel -o webroot/crates/embassy-net-driver-channel/git.zup diff --git a/README.md b/README.md index e5a97062..7ae40fe5 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ The nrf-softdevice cr The embassy-stm32-wpan crate provides Bluetooth Low Energy 5.x support for stm32wb microcontrollers. - **LoRa** - -embassy-lora supports LoRa networking. +The lora-rs project provides an async LoRa and LoRaWAN stack that works well on Embassy. - **USB** - embassy-usb implements a device-side USB stack. Implementations for common classes such as USB serial (CDC ACM) and USB HID are available, and a rich builder API allows building your own. From a6f4538219fdeebbb320bd860478010e333b5c45 Mon Sep 17 00:00:00 2001 From: Scott Mabin Date: Mon, 4 Dec 2023 12:53:04 +0000 Subject: [PATCH 30/98] embassy-sync 0.5 --- .vscode/settings.json | 3 +++ embassy-sync/CHANGELOG.md | 7 +++++++ embassy-sync/Cargo.toml | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index d48f7ba1..d46ce603 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,6 +3,9 @@ "[toml]": { "editor.formatOnSave": false }, + "[markdown]": { + "editor.formatOnSave": false + }, "rust-analyzer.check.allTargets": false, "rust-analyzer.check.noDefaultFeatures": true, "rust-analyzer.cargo.noDefaultFeatures": true, diff --git a/embassy-sync/CHANGELOG.md b/embassy-sync/CHANGELOG.md index 9340d734..e7db97ef 100644 --- a/embassy-sync/CHANGELOG.md +++ b/embassy-sync/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.5.0 - 2023-12-04 + +- Add a PriorityChannel. +- Remove nightly and unstable-traits features in preparation for 1.75. +- Upgrade heapless to 0.8. +- Upgrade static-cell to 2.0. + ## 0.4.0 - 2023-10-31 - Re-add impl_trait_projections diff --git a/embassy-sync/Cargo.toml b/embassy-sync/Cargo.toml index 6588406a..38b0e5d3 100644 --- a/embassy-sync/Cargo.toml +++ b/embassy-sync/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "embassy-sync" -version = "0.4.0" +version = "0.5.0" edition = "2021" description = "no-std, no-alloc synchronization primitives with async support" repository = "https://github.com/embassy-rs/embassy" From c7d6ea3c78eec11473c7d34d181ff1d71056184d Mon Sep 17 00:00:00 2001 From: Scott Mabin Date: Mon, 4 Dec 2023 12:56:57 +0000 Subject: [PATCH 31/98] embassy-time 0.2 --- embassy-time/CHANGELOG.md | 4 +++- embassy-time/Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/embassy-time/CHANGELOG.md b/embassy-time/CHANGELOG.md index 9625b890..d8c0c7d0 100644 --- a/embassy-time/CHANGELOG.md +++ b/embassy-time/CHANGELOG.md @@ -5,9 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## 0.1.6 - ??? +## 0.2.0 - 2023-12-04 - Added tick rates in multiples of 10 kHz +- Remove nightly and unstable-traits features in preparation for 1.75. +- Update heapless to 0.8. ## 0.1.5 - 2023-10-16 diff --git a/embassy-time/Cargo.toml b/embassy-time/Cargo.toml index 5cbb44b3..7358b064 100644 --- a/embassy-time/Cargo.toml +++ b/embassy-time/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "embassy-time" -version = "0.1.5" +version = "0.2.0" edition = "2021" description = "Instant and Duration for embedded no-std systems, with async timer support" repository = "https://github.com/embassy-rs/embassy" From 334900752ab0462a78ac4f327c7141418d24ca1d Mon Sep 17 00:00:00 2001 From: Scott Mabin Date: Mon, 4 Dec 2023 13:03:30 +0000 Subject: [PATCH 32/98] update release version in examples and other crates --- cyw43/Cargo.toml | 4 ++-- docs/modules/ROOT/examples/basic/Cargo.toml | 2 +- embassy-boot/boot/Cargo.toml | 2 +- embassy-boot/nrf/Cargo.toml | 2 +- embassy-boot/rp/Cargo.toml | 2 +- embassy-boot/stm32/Cargo.toml | 2 +- embassy-embedded-hal/Cargo.toml | 4 ++-- embassy-executor/Cargo.toml | 2 +- embassy-net-adin1110/Cargo.toml | 2 +- embassy-net-driver-channel/Cargo.toml | 2 +- embassy-net-enc28j60/Cargo.toml | 2 +- embassy-net-esp-hosted/Cargo.toml | 4 ++-- embassy-net-ppp/Cargo.toml | 2 +- embassy-net-wiznet/Cargo.toml | 2 +- embassy-net/Cargo.toml | 4 ++-- embassy-nrf/Cargo.toml | 4 ++-- embassy-rp/Cargo.toml | 4 ++-- embassy-stm32-wpan/Cargo.toml | 4 ++-- embassy-stm32/Cargo.toml | 4 ++-- embassy-usb-logger/Cargo.toml | 2 +- embassy-usb/Cargo.toml | 2 +- examples/boot/application/nrf/Cargo.toml | 4 ++-- examples/boot/application/rp/Cargo.toml | 4 ++-- examples/boot/application/stm32f3/Cargo.toml | 4 ++-- examples/boot/application/stm32f7/Cargo.toml | 4 ++-- examples/boot/application/stm32h7/Cargo.toml | 4 ++-- examples/boot/application/stm32l0/Cargo.toml | 4 ++-- examples/boot/application/stm32l1/Cargo.toml | 4 ++-- examples/boot/application/stm32l4/Cargo.toml | 4 ++-- examples/boot/application/stm32wl/Cargo.toml | 4 ++-- examples/boot/bootloader/nrf/Cargo.toml | 2 +- examples/boot/bootloader/rp/Cargo.toml | 2 +- examples/boot/bootloader/stm32/Cargo.toml | 2 +- examples/nrf-rtos-trace/Cargo.toml | 4 ++-- examples/nrf52840-rtic/Cargo.toml | 4 ++-- examples/nrf52840/Cargo.toml | 4 ++-- examples/nrf5340/Cargo.toml | 4 ++-- examples/rp/Cargo.toml | 4 ++-- examples/std/Cargo.toml | 4 ++-- examples/stm32c0/Cargo.toml | 4 ++-- examples/stm32f0/Cargo.toml | 4 ++-- examples/stm32f1/Cargo.toml | 4 ++-- examples/stm32f2/Cargo.toml | 4 ++-- examples/stm32f3/Cargo.toml | 4 ++-- examples/stm32f334/Cargo.toml | 4 ++-- examples/stm32f4/Cargo.toml | 4 ++-- examples/stm32f7/Cargo.toml | 4 ++-- examples/stm32g0/Cargo.toml | 4 ++-- examples/stm32g4/Cargo.toml | 4 ++-- examples/stm32h5/Cargo.toml | 4 ++-- examples/stm32h7/Cargo.toml | 4 ++-- examples/stm32l0/Cargo.toml | 4 ++-- examples/stm32l1/Cargo.toml | 4 ++-- examples/stm32l4/Cargo.toml | 4 ++-- examples/stm32l5/Cargo.toml | 4 ++-- examples/stm32u5/Cargo.toml | 4 ++-- examples/stm32wb/Cargo.toml | 4 ++-- examples/stm32wba/Cargo.toml | 4 ++-- examples/stm32wl/Cargo.toml | 4 ++-- examples/wasm/Cargo.toml | 4 ++-- tests/nrf/Cargo.toml | 4 ++-- tests/perf-client/Cargo.toml | 2 +- tests/riscv32/Cargo.toml | 4 ++-- tests/rp/Cargo.toml | 4 ++-- tests/stm32/Cargo.toml | 4 ++-- 65 files changed, 113 insertions(+), 113 deletions(-) diff --git a/cyw43/Cargo.toml b/cyw43/Cargo.toml index 3e37a8cd..293c0098 100644 --- a/cyw43/Cargo.toml +++ b/cyw43/Cargo.toml @@ -11,8 +11,8 @@ log = ["dep:log"] firmware-logs = [] [dependencies] -embassy-time = { version = "0.1.5", path = "../embassy-time"} -embassy-sync = { version = "0.4.0", path = "../embassy-sync"} +embassy-time = { version = "0.2", path = "../embassy-time"} +embassy-sync = { version = "0.5.0", path = "../embassy-sync"} embassy-futures = { version = "0.1.0", path = "../embassy-futures"} embassy-net-driver-channel = { version = "0.2.0", path = "../embassy-net-driver-channel"} diff --git a/docs/modules/ROOT/examples/basic/Cargo.toml b/docs/modules/ROOT/examples/basic/Cargo.toml index 516dc470..b2e173bf 100644 --- a/docs/modules/ROOT/examples/basic/Cargo.toml +++ b/docs/modules/ROOT/examples/basic/Cargo.toml @@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-executor = { version = "0.3.0", path = "../../../../../embassy-executor", features = ["defmt", "integrated-timers", "arch-cortex-m", "executor-thread"] } -embassy-time = { version = "0.1.4", path = "../../../../../embassy-time", features = ["defmt"] } +embassy-time = { version = "0.2.0", path = "../../../../../embassy-time", features = ["defmt"] } embassy-nrf = { version = "0.1.0", path = "../../../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote"] } defmt = "0.3" diff --git a/embassy-boot/boot/Cargo.toml b/embassy-boot/boot/Cargo.toml index ee1dacc2..dd2ff815 100644 --- a/embassy-boot/boot/Cargo.toml +++ b/embassy-boot/boot/Cargo.toml @@ -28,7 +28,7 @@ digest = "0.10" log = { version = "0.4", optional = true } ed25519-dalek = { version = "1.0.1", default_features = false, features = ["u32_backend"], optional = true } embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync" } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync" } embedded-storage = "0.3.1" embedded-storage-async = { version = "0.4.1" } salty = { git = "https://github.com/ycrypto/salty.git", rev = "a9f17911a5024698406b75c0fac56ab5ccf6a8c7", optional = true } diff --git a/embassy-boot/nrf/Cargo.toml b/embassy-boot/nrf/Cargo.toml index e4ec175a..eea29cf2 100644 --- a/embassy-boot/nrf/Cargo.toml +++ b/embassy-boot/nrf/Cargo.toml @@ -16,7 +16,7 @@ target = "thumbv7em-none-eabi" [dependencies] defmt = { version = "0.3", optional = true } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync" } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync" } embassy-nrf = { path = "../../embassy-nrf" } embassy-boot = { path = "../boot", default-features = false } cortex-m = { version = "0.7.6" } diff --git a/embassy-boot/rp/Cargo.toml b/embassy-boot/rp/Cargo.toml index ad385473..0f2dc462 100644 --- a/embassy-boot/rp/Cargo.toml +++ b/embassy-boot/rp/Cargo.toml @@ -17,7 +17,7 @@ defmt = { version = "0.3", optional = true } defmt-rtt = { version = "0.4", optional = true } log = { version = "0.4", optional = true } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync" } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync" } embassy-rp = { path = "../../embassy-rp", default-features = false } embassy-boot = { path = "../boot", default-features = false } embassy-time = { path = "../../embassy-time" } diff --git a/embassy-boot/stm32/Cargo.toml b/embassy-boot/stm32/Cargo.toml index 7dedf8c4..bc8da673 100644 --- a/embassy-boot/stm32/Cargo.toml +++ b/embassy-boot/stm32/Cargo.toml @@ -18,7 +18,7 @@ defmt = { version = "0.3", optional = true } defmt-rtt = { version = "0.4", optional = true } log = { version = "0.4", optional = true } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync" } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync" } embassy-stm32 = { path = "../../embassy-stm32", default-features = false } embassy-boot = { path = "../boot", default-features = false } cortex-m = { version = "0.7.6" } diff --git a/embassy-embedded-hal/Cargo.toml b/embassy-embedded-hal/Cargo.toml index 7cd796e8..2a0b2547 100644 --- a/embassy-embedded-hal/Cargo.toml +++ b/embassy-embedded-hal/Cargo.toml @@ -18,8 +18,8 @@ default = ["time"] [dependencies] embassy-futures = { version = "0.1.0", path = "../embassy-futures" } -embassy-sync = { version = "0.4.0", path = "../embassy-sync" } -embassy-time = { version = "0.1.5", path = "../embassy-time", optional = true } +embassy-sync = { version = "0.5.0", path = "../embassy-sync" } +embassy-time = { version = "0.2", path = "../embassy-time", optional = true } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = [ "unproven", ] } diff --git a/embassy-executor/Cargo.toml b/embassy-executor/Cargo.toml index bf58a2e1..74efe452 100644 --- a/embassy-executor/Cargo.toml +++ b/embassy-executor/Cargo.toml @@ -33,7 +33,7 @@ log = { version = "0.4.14", optional = true } rtos-trace = { version = "0.1.2", optional = true } embassy-macros = { version = "0.2.1", path = "../embassy-macros" } -embassy-time = { version = "0.1.5", path = "../embassy-time", optional = true} +embassy-time = { version = "0.2", path = "../embassy-time", optional = true} critical-section = "1.1" # needed for riscv diff --git a/embassy-net-adin1110/Cargo.toml b/embassy-net-adin1110/Cargo.toml index 3dbbee44..d95b2628 100644 --- a/embassy-net-adin1110/Cargo.toml +++ b/embassy-net-adin1110/Cargo.toml @@ -17,7 +17,7 @@ embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } embedded-hal-async = { version = "=1.0.0-rc.2" } embedded-hal-bus = { version = "=0.1.0-rc.2", features = ["async"] } embassy-net-driver-channel = { version = "0.2.0", path = "../embassy-net-driver-channel" } -embassy-time = { version = "0.1.5", path = "../embassy-time" } +embassy-time = { version = "0.2", path = "../embassy-time" } embassy-futures = { version = "0.1.0", path = "../embassy-futures" } bitfield = "0.14.0" diff --git a/embassy-net-driver-channel/Cargo.toml b/embassy-net-driver-channel/Cargo.toml index 100c3ebc..58d3d231 100644 --- a/embassy-net-driver-channel/Cargo.toml +++ b/embassy-net-driver-channel/Cargo.toml @@ -24,6 +24,6 @@ features = ["defmt"] defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } -embassy-sync = { version = "0.4.0", path = "../embassy-sync" } +embassy-sync = { version = "0.5.0", path = "../embassy-sync" } embassy-futures = { version = "0.1.0", path = "../embassy-futures" } embassy-net-driver = { version = "0.2.0", path = "../embassy-net-driver" } diff --git a/embassy-net-enc28j60/Cargo.toml b/embassy-net-enc28j60/Cargo.toml index eda699d9..72e1d4e5 100644 --- a/embassy-net-enc28j60/Cargo.toml +++ b/embassy-net-enc28j60/Cargo.toml @@ -11,7 +11,7 @@ edition = "2021" embedded-hal = { version = "1.0.0-rc.2" } embedded-hal-async = { version = "=1.0.0-rc.2" } embassy-net-driver = { version = "0.2.0", path = "../embassy-net-driver" } -embassy-time = { version = "0.1.5", path = "../embassy-time" } +embassy-time = { version = "0.2", path = "../embassy-time" } embassy-futures = { version = "0.1.0", path = "../embassy-futures" } defmt = { version = "0.3", optional = true } diff --git a/embassy-net-esp-hosted/Cargo.toml b/embassy-net-esp-hosted/Cargo.toml index 6b325c80..eb44a654 100644 --- a/embassy-net-esp-hosted/Cargo.toml +++ b/embassy-net-esp-hosted/Cargo.toml @@ -7,8 +7,8 @@ edition = "2021" defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } -embassy-time = { version = "0.1.5", path = "../embassy-time" } -embassy-sync = { version = "0.4.0", path = "../embassy-sync"} +embassy-time = { version = "0.2", path = "../embassy-time" } +embassy-sync = { version = "0.5.0", path = "../embassy-sync"} embassy-futures = { version = "0.1.0", path = "../embassy-futures"} embassy-net-driver-channel = { version = "0.2.0", path = "../embassy-net-driver-channel"} diff --git a/embassy-net-ppp/Cargo.toml b/embassy-net-ppp/Cargo.toml index 7119ebd5..33e05227 100644 --- a/embassy-net-ppp/Cargo.toml +++ b/embassy-net-ppp/Cargo.toml @@ -19,7 +19,7 @@ embedded-io-async = { version = "0.6.1" } embassy-net-driver-channel = { version = "0.2.0", path = "../embassy-net-driver-channel" } embassy-futures = { version = "0.1.0", path = "../embassy-futures" } ppproto = { version = "0.1.2"} -embassy-sync = { version = "0.4.0", path = "../embassy-sync" } +embassy-sync = { version = "0.5.0", path = "../embassy-sync" } [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-net-ppp-v$VERSION/embassy-net-ppp/src/" diff --git a/embassy-net-wiznet/Cargo.toml b/embassy-net-wiznet/Cargo.toml index 187f3e29..9c103ebb 100644 --- a/embassy-net-wiznet/Cargo.toml +++ b/embassy-net-wiznet/Cargo.toml @@ -11,7 +11,7 @@ edition = "2021" embedded-hal = { version = "1.0.0-rc.2" } embedded-hal-async = { version = "=1.0.0-rc.2" } embassy-net-driver-channel = { version = "0.2.0", path = "../embassy-net-driver-channel" } -embassy-time = { version = "0.1.5", path = "../embassy-time" } +embassy-time = { version = "0.2", path = "../embassy-time" } embassy-futures = { version = "0.1.0", path = "../embassy-futures" } defmt = { version = "0.3", optional = true } diff --git a/embassy-net/Cargo.toml b/embassy-net/Cargo.toml index f106582e..0c07e365 100644 --- a/embassy-net/Cargo.toml +++ b/embassy-net/Cargo.toml @@ -50,8 +50,8 @@ smoltcp = { git = "https://github.com/smoltcp-rs/smoltcp.git", rev = "b57e2f9e70 ] } embassy-net-driver = { version = "0.2.0", path = "../embassy-net-driver" } -embassy-time = { version = "0.1.5", path = "../embassy-time" } -embassy-sync = { version = "0.4.0", path = "../embassy-sync" } +embassy-time = { version = "0.2", path = "../embassy-time" } +embassy-sync = { version = "0.5.0", path = "../embassy-sync" } embedded-io-async = { version = "0.6.1" } managed = { version = "0.8.0", default-features = false, features = [ "map" ] } diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index 2da81a0f..a7f3cb35 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml @@ -87,8 +87,8 @@ _gpio-p1 = [] _nrf52832_anomaly_109 = [] [dependencies] -embassy-time = { version = "0.1.5", path = "../embassy-time", optional = true } -embassy-sync = { version = "0.4.0", path = "../embassy-sync" } +embassy-time = { version = "0.2", path = "../embassy-time", optional = true } +embassy-sync = { version = "0.5.0", path = "../embassy-sync" } embassy-hal-internal = {version = "0.1.0", path = "../embassy-hal-internal", features = ["cortex-m", "prio-bits-3"] } embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver" } diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index 3c654975..cfadd9f2 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml @@ -52,8 +52,8 @@ qspi-as-gpio = [] run-from-ram = [] [dependencies] -embassy-sync = { version = "0.4.0", path = "../embassy-sync" } -embassy-time = { version = "0.1.5", path = "../embassy-time", features = [ "tick-hz-1_000_000" ] } +embassy-sync = { version = "0.5.0", path = "../embassy-sync" } +embassy-time = { version = "0.2", path = "../embassy-time", features = [ "tick-hz-1_000_000" ] } embassy-futures = { version = "0.1.0", path = "../embassy-futures" } embassy-hal-internal = {version = "0.1.0", path = "../embassy-hal-internal", features = ["cortex-m", "prio-bits-2"] } embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } diff --git a/embassy-stm32-wpan/Cargo.toml b/embassy-stm32-wpan/Cargo.toml index 607cd44c..f887b817 100644 --- a/embassy-stm32-wpan/Cargo.toml +++ b/embassy-stm32-wpan/Cargo.toml @@ -12,8 +12,8 @@ features = ["stm32wb55rg"] [dependencies] embassy-stm32 = { version = "0.1.0", path = "../embassy-stm32" } -embassy-sync = { version = "0.4.0", path = "../embassy-sync" } -embassy-time = { version = "0.1.5", path = "../embassy-time", optional = true } +embassy-sync = { version = "0.5.0", path = "../embassy-sync" } +embassy-time = { version = "0.2", path = "../embassy-time", optional = true } embassy-futures = { version = "0.1.0", path = "../embassy-futures" } embassy-hal-internal = { version = "0.1.0", path = "../embassy-hal-internal" } embassy-embedded-hal = { version = "0.1.0", path = "../embassy-embedded-hal" } diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index dc9b331c..ea395c33 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -32,8 +32,8 @@ flavors = [ ] [dependencies] -embassy-sync = { version = "0.4.0", path = "../embassy-sync" } -embassy-time = { version = "0.1.5", path = "../embassy-time", optional = true } +embassy-sync = { version = "0.5.0", path = "../embassy-sync" } +embassy-time = { version = "0.2", path = "../embassy-time", optional = true } embassy-futures = { version = "0.1.0", path = "../embassy-futures" } embassy-hal-internal = {version = "0.1.0", path = "../embassy-hal-internal", features = ["cortex-m", "prio-bits-4"] } embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } diff --git a/embassy-usb-logger/Cargo.toml b/embassy-usb-logger/Cargo.toml index 48b8bbcc..c8b06fb0 100644 --- a/embassy-usb-logger/Cargo.toml +++ b/embassy-usb-logger/Cargo.toml @@ -10,7 +10,7 @@ target = "thumbv7em-none-eabi" [dependencies] embassy-usb = { version = "0.1.0", path = "../embassy-usb" } -embassy-sync = { version = "0.4.0", path = "../embassy-sync" } +embassy-sync = { version = "0.5.0", path = "../embassy-sync" } embassy-futures = { version = "0.1.0", path = "../embassy-futures" } futures = { version = "0.3", default-features = false } static_cell = { version = "2" } diff --git a/embassy-usb/Cargo.toml b/embassy-usb/Cargo.toml index ac2082dc..e6e6b195 100644 --- a/embassy-usb/Cargo.toml +++ b/embassy-usb/Cargo.toml @@ -40,7 +40,7 @@ max-handler-count-8 = [] [dependencies] embassy-futures = { version = "0.1.0", path = "../embassy-futures" } embassy-usb-driver = { version = "0.1.0", path = "../embassy-usb-driver" } -embassy-sync = { version = "0.4.0", path = "../embassy-sync" } +embassy-sync = { version = "0.5.0", path = "../embassy-sync" } embassy-net-driver-channel = { version = "0.2.0", path = "../embassy-net-driver-channel" } defmt = { version = "0.3", optional = true } diff --git a/examples/boot/application/nrf/Cargo.toml b/examples/boot/application/nrf/Cargo.toml index 193ca5a2..35ec426c 100644 --- a/examples/boot/application/nrf/Cargo.toml +++ b/examples/boot/application/nrf/Cargo.toml @@ -5,9 +5,9 @@ version = "0.1.0" license = "MIT OR Apache-2.0" [dependencies] -embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } +embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers", "arch-cortex-m", "executor-thread"] } -embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = [] } +embassy-time = { version = "0.2", path = "../../../../embassy-time", features = [] } embassy-nrf = { version = "0.1.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", ] } embassy-boot = { version = "0.1.0", path = "../../../../embassy-boot/boot", features = [] } embassy-boot-nrf = { version = "0.1.0", path = "../../../../embassy-boot/nrf", features = [] } diff --git a/examples/boot/application/rp/Cargo.toml b/examples/boot/application/rp/Cargo.toml index 54ec53b3..e4a992c2 100644 --- a/examples/boot/application/rp/Cargo.toml +++ b/examples/boot/application/rp/Cargo.toml @@ -5,9 +5,9 @@ version = "0.1.0" license = "MIT OR Apache-2.0" [dependencies] -embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } +embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers", "arch-cortex-m", "executor-thread"] } -embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = [] } +embassy-time = { version = "0.2", path = "../../../../embassy-time", features = [] } embassy-rp = { version = "0.1.0", path = "../../../../embassy-rp", features = ["time-driver", ] } embassy-boot-rp = { version = "0.1.0", path = "../../../../embassy-boot/rp", features = [] } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/stm32f3/Cargo.toml b/examples/boot/application/stm32f3/Cargo.toml index 26c46bc2..706331c8 100644 --- a/examples/boot/application/stm32f3/Cargo.toml +++ b/examples/boot/application/stm32f3/Cargo.toml @@ -5,9 +5,9 @@ version = "0.1.0" license = "MIT OR Apache-2.0" [dependencies] -embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } +embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["stm32f303re", "time-driver-any", "exti"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/stm32f7/Cargo.toml b/examples/boot/application/stm32f7/Cargo.toml index 57be97af..53c27a5a 100644 --- a/examples/boot/application/stm32f7/Cargo.toml +++ b/examples/boot/application/stm32f7/Cargo.toml @@ -5,9 +5,9 @@ version = "0.1.0" license = "MIT OR Apache-2.0" [dependencies] -embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } +embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["stm32f767zi", "time-driver-any", "exti"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = [] } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/stm32h7/Cargo.toml b/examples/boot/application/stm32h7/Cargo.toml index 057060f8..a755b438 100644 --- a/examples/boot/application/stm32h7/Cargo.toml +++ b/examples/boot/application/stm32h7/Cargo.toml @@ -5,9 +5,9 @@ version = "0.1.0" license = "MIT OR Apache-2.0" [dependencies] -embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } +embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["stm32h743zi", "time-driver-any", "exti"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = [] } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/stm32l0/Cargo.toml b/examples/boot/application/stm32l0/Cargo.toml index 02993e4e..0ab5f3e0 100644 --- a/examples/boot/application/stm32l0/Cargo.toml +++ b/examples/boot/application/stm32l0/Cargo.toml @@ -5,9 +5,9 @@ version = "0.1.0" license = "MIT OR Apache-2.0" [dependencies] -embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } +embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["stm32l072cz", "time-driver-any", "exti", "memory-x"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = [] } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/stm32l1/Cargo.toml b/examples/boot/application/stm32l1/Cargo.toml index 771266cc..59eadaf6 100644 --- a/examples/boot/application/stm32l1/Cargo.toml +++ b/examples/boot/application/stm32l1/Cargo.toml @@ -5,9 +5,9 @@ version = "0.1.0" license = "MIT OR Apache-2.0" [dependencies] -embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } +embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["stm32l151cb-a", "time-driver-any", "exti"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = [] } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/stm32l4/Cargo.toml b/examples/boot/application/stm32l4/Cargo.toml index d375ff25..a9ba4b42 100644 --- a/examples/boot/application/stm32l4/Cargo.toml +++ b/examples/boot/application/stm32l4/Cargo.toml @@ -5,9 +5,9 @@ version = "0.1.0" license = "MIT OR Apache-2.0" [dependencies] -embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } +embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["stm32l475vg", "time-driver-any", "exti"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = [] } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/application/stm32wl/Cargo.toml b/examples/boot/application/stm32wl/Cargo.toml index 05f48c7d..8d927333 100644 --- a/examples/boot/application/stm32wl/Cargo.toml +++ b/examples/boot/application/stm32wl/Cargo.toml @@ -5,9 +5,9 @@ version = "0.1.0" license = "MIT OR Apache-2.0" [dependencies] -embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } +embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["stm32wl55jc-cm4", "time-driver-any", "exti"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = [] } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } diff --git a/examples/boot/bootloader/nrf/Cargo.toml b/examples/boot/bootloader/nrf/Cargo.toml index a639d57f..a7273175 100644 --- a/examples/boot/bootloader/nrf/Cargo.toml +++ b/examples/boot/bootloader/nrf/Cargo.toml @@ -12,7 +12,7 @@ defmt-rtt = { version = "0.4", optional = true } embassy-nrf = { path = "../../../../embassy-nrf", features = [] } embassy-boot-nrf = { path = "../../../../embassy-boot/nrf" } cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } -embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } +embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } cortex-m-rt = { version = "0.7" } cfg-if = "1.0.0" diff --git a/examples/boot/bootloader/rp/Cargo.toml b/examples/boot/bootloader/rp/Cargo.toml index 18693f06..5bc61e9e 100644 --- a/examples/boot/bootloader/rp/Cargo.toml +++ b/examples/boot/bootloader/rp/Cargo.toml @@ -11,7 +11,7 @@ defmt-rtt = { version = "0.4", optional = true } embassy-rp = { path = "../../../../embassy-rp", features = [] } embassy-boot-rp = { path = "../../../../embassy-boot/rp" } -embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } +embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } embassy-time = { path = "../../../../embassy-time", features = [] } cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } diff --git a/examples/boot/bootloader/stm32/Cargo.toml b/examples/boot/bootloader/stm32/Cargo.toml index aa2b9fbe..2d88b0f7 100644 --- a/examples/boot/bootloader/stm32/Cargo.toml +++ b/examples/boot/bootloader/stm32/Cargo.toml @@ -12,7 +12,7 @@ defmt-rtt = { version = "0.4", optional = true } embassy-stm32 = { path = "../../../../embassy-stm32", features = [] } embassy-boot-stm32 = { path = "../../../../embassy-boot/stm32" } cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } -embassy-sync = { version = "0.4.0", path = "../../../../embassy-sync" } +embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } cortex-m-rt = { version = "0.7" } embedded-storage = "0.3.1" embedded-storage-async = "0.4.0" diff --git a/examples/nrf-rtos-trace/Cargo.toml b/examples/nrf-rtos-trace/Cargo.toml index c99c31aa..363c2259 100644 --- a/examples/nrf-rtos-trace/Cargo.toml +++ b/examples/nrf-rtos-trace/Cargo.toml @@ -15,9 +15,9 @@ log = [ ] [dependencies] -embassy-sync = { version = "0.4.0", path = "../../embassy-sync" } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync" } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "rtos-trace", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time" } +embassy-time = { version = "0.2", path = "../../embassy-time" } embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } diff --git a/examples/nrf52840-rtic/Cargo.toml b/examples/nrf52840-rtic/Cargo.toml index 3448c690..f5d49f0a 100644 --- a/examples/nrf52840-rtic/Cargo.toml +++ b/examples/nrf52840-rtic/Cargo.toml @@ -8,8 +8,8 @@ license = "MIT OR Apache-2.0" rtic = { version = "2", features = ["thumbv7-backend"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = [ "defmt", "defmt-timestamp-uptime", "generic-queue"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = [ "defmt", "defmt-timestamp-uptime", "generic-queue"] } embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = [ "defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } defmt = "0.3" diff --git a/examples/nrf52840/Cargo.toml b/examples/nrf52840/Cargo.toml index be521922..06cd15b0 100644 --- a/examples/nrf52840/Cargo.toml +++ b/examples/nrf52840/Cargo.toml @@ -12,9 +12,9 @@ nightly = [ [dependencies] embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } diff --git a/examples/nrf5340/Cargo.toml b/examples/nrf5340/Cargo.toml index d14678ab..ffff9373 100644 --- a/examples/nrf5340/Cargo.toml +++ b/examples/nrf5340/Cargo.toml @@ -6,9 +6,9 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf5340-app-s", "time-driver-rtc1", "gpiote", "unstable-pac"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index 08898e96..09b55269 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal", features = ["defmt"] } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["defmt", "unstable-pac", "time-driver", "critical-section-impl"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] } diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index 228b6aa0..e47ab4f3 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml @@ -5,9 +5,9 @@ version = "0.1.0" license = "MIT OR Apache-2.0" [dependencies] -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["log"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["log"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-std", "executor-thread", "log", "nightly", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["log", "std", ] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["log", "std", ] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features=[ "std", "log", "medium-ethernet", "medium-ip", "tcp", "udp", "dns", "dhcpv4", "proto-ipv6"] } embassy-net-tuntap = { version = "0.1.0", path = "../../embassy-net-tuntap" } embassy-net-ppp = { version = "0.1.0", path = "../../embassy-net-ppp", features = ["log"]} diff --git a/examples/stm32c0/Cargo.toml b/examples/stm32c0/Cargo.toml index 595cb76a..2f82f82f 100644 --- a/examples/stm32c0/Cargo.toml +++ b/examples/stm32c0/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32c031c6 to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "time-driver-any", "stm32c031c6", "memory-x", "unstable-pac", "exti"] } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } defmt = "0.3" defmt-rtt = "0.4" diff --git a/examples/stm32f0/Cargo.toml b/examples/stm32f0/Cargo.toml index 9e85da9c..f5a730a0 100644 --- a/examples/stm32f0/Cargo.toml +++ b/examples/stm32f0/Cargo.toml @@ -14,9 +14,9 @@ cortex-m-rt = "0.7.0" defmt = "0.3" defmt-rtt = "0.4" panic-probe = "0.3" -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } static_cell = { version = "2", features = ["nightly"]} portable-atomic = { version = "1.5", features = ["unsafe-assume-single-core"] } diff --git a/examples/stm32f1/Cargo.toml b/examples/stm32f1/Cargo.toml index 4c9508c2..f8642a5e 100644 --- a/examples/stm32f1/Cargo.toml +++ b/examples/stm32f1/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32f103c8 to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32f103c8", "unstable-pac", "memory-x", "time-driver-any" ] } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } diff --git a/examples/stm32f2/Cargo.toml b/examples/stm32f2/Cargo.toml index f088f1cb..61de3093 100644 --- a/examples/stm32f2/Cargo.toml +++ b/examples/stm32f2/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32f207zg to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32f207zg", "unstable-pac", "memory-x", "time-driver-any", "exti"] } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } defmt = "0.3" defmt-rtt = "0.4" diff --git a/examples/stm32f3/Cargo.toml b/examples/stm32f3/Cargo.toml index fe852387..f24cffbd 100644 --- a/examples/stm32f3/Cargo.toml +++ b/examples/stm32f3/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32f303ze to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32f303ze", "unstable-pac", "memory-x", "time-driver-any", "exti"] } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } diff --git a/examples/stm32f334/Cargo.toml b/examples/stm32f334/Cargo.toml index ad9060a2..930f0737 100644 --- a/examples/stm32f334/Cargo.toml +++ b/examples/stm32f334/Cargo.toml @@ -5,9 +5,9 @@ version = "0.1.0" license = "MIT OR Apache-2.0" [dependencies] -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-time = { version = "0.2.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32f334r8", "unstable-pac", "memory-x", "time-driver-any", "exti"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml index 947805c4..cd78ff09 100644 --- a/examples/stm32f4/Cargo.toml +++ b/examples/stm32f4/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32f429zi to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti", "embedded-sdmmc", "chrono"] } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt" ] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] } diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml index 2e1f27df..3e1a26e1 100644 --- a/examples/stm32f7/Cargo.toml +++ b/examples/stm32f7/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32f767zi to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32f767zi", "memory-x", "unstable-pac", "time-driver-any", "exti"] } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"] } embedded-io-async = { version = "0.6.1" } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } diff --git a/examples/stm32g0/Cargo.toml b/examples/stm32g0/Cargo.toml index 7218dbd2..2cb2c054 100644 --- a/examples/stm32g0/Cargo.toml +++ b/examples/stm32g0/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32g071rb to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "time-driver-any", "stm32g071rb", "memory-x", "unstable-pac", "exti"] } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } defmt = "0.3" defmt-rtt = "0.4" diff --git a/examples/stm32g4/Cargo.toml b/examples/stm32g4/Cargo.toml index b03c5adb..63cd027a 100644 --- a/examples/stm32g4/Cargo.toml +++ b/examples/stm32g4/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32g491re to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "time-driver-any", "stm32g491re", "memory-x", "unstable-pac", "exti"] } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } usbd-hid = "0.6.0" diff --git a/examples/stm32h5/Cargo.toml b/examples/stm32h5/Cargo.toml index d15ecee1..c9a137ee 100644 --- a/examples/stm32h5/Cargo.toml +++ b/examples/stm32h5/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32h563zi to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32h563zi", "memory-x", "time-driver-any", "exti", "unstable-pac"] } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index ea59b5c0..ca6b2d2f 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32h743bi to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32h743bi", "time-driver-any", "exti", "memory-x", "unstable-pac", "chrono"] } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index 9fad48df..193762fc 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml @@ -11,9 +11,9 @@ nightly = ["embassy-executor/nightly"] [dependencies] # Change stm32l072cz to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "memory-x"] } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } defmt = "0.3" defmt-rtt = "0.4" diff --git a/examples/stm32l1/Cargo.toml b/examples/stm32l1/Cargo.toml index 907b8ea6..18b99cb2 100644 --- a/examples/stm32l1/Cargo.toml +++ b/examples/stm32l1/Cargo.toml @@ -5,9 +5,9 @@ version = "0.1.0" license = "MIT OR Apache-2.0" [dependencies] -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32l151cb-a", "time-driver-any", "memory-x"] } defmt = "0.3" diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml index a0fe457b..d7f5eb90 100644 --- a/examples/stm32l4/Cargo.toml +++ b/examples/stm32l4/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32l4s5vi to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "unstable-pac", "stm32l4s5qi", "memory-x", "time-driver-any", "exti", "chrono"] } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768", ] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768", ] } embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } embassy-net-adin1110 = { version = "0.2.0", path = "../../embassy-net-adin1110" } diff --git a/examples/stm32l5/Cargo.toml b/examples/stm32l5/Cargo.toml index 6591e837..3eb862ac 100644 --- a/examples/stm32l5/Cargo.toml +++ b/examples/stm32l5/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32l552ze to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "unstable-pac", "stm32l552ze", "time-driver-any", "exti", "memory-x"] } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } diff --git a/examples/stm32u5/Cargo.toml b/examples/stm32u5/Cargo.toml index 28009786..18c920f5 100644 --- a/examples/stm32u5/Cargo.toml +++ b/examples/stm32u5/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32u585ai to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "unstable-pac", "stm32u585ai", "time-driver-any", "memory-x" ] } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } defmt = "0.3" diff --git a/examples/stm32wb/Cargo.toml b/examples/stm32wb/Cargo.toml index 70917511..63e94fe0 100644 --- a/examples/stm32wb/Cargo.toml +++ b/examples/stm32wb/Cargo.toml @@ -8,9 +8,9 @@ license = "MIT OR Apache-2.0" # Change stm32wb55rg to your chip name in both dependencies, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32wb55rg", "time-driver-any", "memory-x", "exti"] } embassy-stm32-wpan = { version = "0.1.0", path = "../../embassy-stm32-wpan", features = ["defmt", "stm32wb55rg"] } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "udp", "proto-ipv6", "medium-ieee802154", ], optional=true } defmt = "0.3" diff --git a/examples/stm32wba/Cargo.toml b/examples/stm32wba/Cargo.toml index e30782c8..c4f1f94f 100644 --- a/examples/stm32wba/Cargo.toml +++ b/examples/stm32wba/Cargo.toml @@ -6,9 +6,9 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32wba52cg", "time-driver-any", "memory-x", "exti"] } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "udp", "proto-ipv6", "medium-ieee802154", ], optional=true } defmt = "0.3" diff --git a/examples/stm32wl/Cargo.toml b/examples/stm32wl/Cargo.toml index 13a16307..28d6dbff 100644 --- a/examples/stm32wl/Cargo.toml +++ b/examples/stm32wl/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] # Change stm32wl55jc-cm4 to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32wl55jc-cm4", "time-driver-any", "memory-x", "unstable-pac", "exti", "chrono"] } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } defmt = "0.3" diff --git a/examples/wasm/Cargo.toml b/examples/wasm/Cargo.toml index 7e4fdff8..21c604eb 100644 --- a/examples/wasm/Cargo.toml +++ b/examples/wasm/Cargo.toml @@ -8,9 +8,9 @@ license = "MIT OR Apache-2.0" crate-type = ["cdylib"] [dependencies] -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["log"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["log"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-wasm", "executor-thread", "log", "nightly", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["log", "wasm", ] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["log", "wasm", ] } wasm-logger = "0.2.0" wasm-bindgen = "0.2" diff --git a/tests/nrf/Cargo.toml b/tests/nrf/Cargo.toml index 4f9b5a5f..df036685 100644 --- a/tests/nrf/Cargo.toml +++ b/tests/nrf/Cargo.toml @@ -8,9 +8,9 @@ license = "MIT OR Apache-2.0" teleprobe-meta = "1" embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt", ] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt", ] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "task-arena-size-16384", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] } diff --git a/tests/perf-client/Cargo.toml b/tests/perf-client/Cargo.toml index 6c40d18a..52aa74df 100644 --- a/tests/perf-client/Cargo.toml +++ b/tests/perf-client/Cargo.toml @@ -7,6 +7,6 @@ edition = "2021" [dependencies] embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", ] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", ] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } defmt = "0.3.0" diff --git a/tests/riscv32/Cargo.toml b/tests/riscv32/Cargo.toml index 0f9b8221..b3b50b84 100644 --- a/tests/riscv32/Cargo.toml +++ b/tests/riscv32/Cargo.toml @@ -6,9 +6,9 @@ license = "MIT OR Apache-2.0" [dependencies] critical-section = { version = "1.1.1", features = ["restore-state-bool"] } -embassy-sync = { version = "0.4.0", path = "../../embassy-sync" } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync" } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-riscv32", "executor-thread"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time" } +embassy-time = { version = "0.2", path = "../../embassy-time" } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } riscv-rt = "0.11" diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index 3c4e6a68..34ee61bb 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" [dependencies] teleprobe-meta = "1.1" -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", ] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", ] } embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = [ "defmt", "unstable-pac", "time-driver", "critical-section-impl", "intrinsics", "rom-v2-intrinsics", "run-from-ram"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "dhcpv4", "medium-ethernet"] } diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index cf91a952..d449cc82 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -48,9 +48,9 @@ cm0 = ["portable-atomic/unsafe-assume-single-core"] [dependencies] teleprobe-meta = "1" -embassy-sync = { version = "0.4.0", path = "../../embassy-sync", features = ["defmt"] } +embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } -embassy-time = { version = "0.1.5", path = "../../embassy-time", features = ["defmt", "tick-hz-131_072", "defmt-timestamp-uptime"] } +embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "tick-hz-131_072", "defmt-timestamp-uptime"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "unstable-pac", "memory-x", "time-driver-any"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-stm32-wpan = { version = "0.1.0", path = "../../embassy-stm32-wpan", optional = true, features = ["defmt", "stm32wb55rg", "ble"] } From e9fa79bd779a505b430ad6482d18af344f992e7e Mon Sep 17 00:00:00 2001 From: Mathias Date: Mon, 4 Dec 2023 14:19:30 +0100 Subject: [PATCH 33/98] Revert "fix day of the week conversion" This reverts commit 59a5e84df584faed5676de027601d09772be55f7. --- embassy-stm32/src/rtc/datetime.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embassy-stm32/src/rtc/datetime.rs b/embassy-stm32/src/rtc/datetime.rs index f3428108..f4e86dd8 100644 --- a/embassy-stm32/src/rtc/datetime.rs +++ b/embassy-stm32/src/rtc/datetime.rs @@ -211,7 +211,7 @@ pub enum DayOfWeek { #[cfg(feature = "chrono")] impl From for DayOfWeek { fn from(weekday: Weekday) -> Self { - day_of_week_from_u8(weekday.num_days_from_monday() as u8).unwrap() + day_of_week_from_u8(weekday.number_from_monday() as u8).unwrap() } } From 18e89d741062e23446f9b04db7bcf0ecc3a0775b Mon Sep 17 00:00:00 2001 From: James Munns Date: Mon, 4 Dec 2023 15:57:46 +0100 Subject: [PATCH 34/98] Add implementation note for embassy-stm32's time-driver This is a detail I didn't originally understand when hoping to use TIM16/17 as alternative embassy-time driver providers. Adding my note here to hopefully save the next person a little time. --- embassy-stm32/src/time_driver.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/embassy-stm32/src/time_driver.rs b/embassy-stm32/src/time_driver.rs index 564c9d08..e2a4cc4d 100644 --- a/embassy-stm32/src/time_driver.rs +++ b/embassy-stm32/src/time_driver.rs @@ -18,6 +18,17 @@ use crate::rtc::Rtc; use crate::timer::sealed::{Basic16bitInstance as BasicInstance, GeneralPurpose16bitInstance as Instance}; use crate::{interrupt, peripherals}; +// NOTE regarding ALARM_COUNT: +// +// As of 2023-12-04, this driver is implemented using CC1 as the halfway rollover interrupt, and any +// additional CC capabilities to provide timer alarms to embassy-time. embassy-time requires AT LEAST +// one alarm to be allocatable, which means timers that only have CC1, such as TIM16/TIM17, are not +// candidates for use as an embassy-time driver provider. +// +// The values of ALARM_COUNT below are not the TOTAL CC registers available, but rather the number +// available after reserving CC1 for regular time keeping. For example, TIM2 has four CC registers: +// CC1, CC2, CC3, and CC4, so it can provide ALARM_COUNT = 3. + #[cfg(not(any(time_driver_tim12, time_driver_tim15)))] const ALARM_COUNT: usize = 3; From 0b0ca62a95cd2dabbc7e160dc5d0fcfc1a7a76e8 Mon Sep 17 00:00:00 2001 From: JuliDi <20155974+JuliDi@users.noreply.github.com> Date: Mon, 4 Dec 2023 20:59:08 +0100 Subject: [PATCH 35/98] add speed optimization --- docs/modules/ROOT/pages/faq.adoc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/modules/ROOT/pages/faq.adoc b/docs/modules/ROOT/pages/faq.adoc index df3f6665..8ac1febc 100644 --- a/docs/modules/ROOT/pages/faq.adoc +++ b/docs/modules/ROOT/pages/faq.adoc @@ -135,3 +135,19 @@ embassy-time = { git = "https://github.com/embassy-rs/embassy.git", rev = "e5fdd ---- Note that the git revision should match any other embassy patches or git dependencies that you are using! + +== How can I optimize the speed of my embassy-stm32 program? + +* Make sure RCC is set up to go as fast as possible +* Make sure link:https://docs.rs/cortex-m/latest/cortex_m/peripheral/struct.SCB.html[flash cache] is enabled +* build with `--release` +* Set the following keys for the release profile in your `Cargo.toml``: + ** `opt-level=s` + ** `lto=fat` + ** `build-std=core` + ** `build-std-features=panic_immediate_abort` +* Enable feature `embassy-time/generic-queue`, disable feature `embassy-executor/integrated-timers` +* When using `InterruptExecutor`: + ** disable `executor-thread` + ** make `main`` spawn everything, then enable link:https://docs.rs/cortex-m/latest/cortex_m/peripheral/struct.SCB.html#method.set_sleeponexit[SCB.SLEEPONEXIT] and `loop { cortex_m::asm::wfi() }` + ** *Note:* If you need 2 priority levels, using 2 interrupt executors is better than 1 thread executor + 1 interrupt executor. \ No newline at end of file From bf7115cb4425959acd01d3e9a1d640a47948b2f9 Mon Sep 17 00:00:00 2001 From: JuliDi <20155974+JuliDi@users.noreply.github.com> Date: Mon, 4 Dec 2023 21:20:18 +0100 Subject: [PATCH 36/98] remove unnecessary backtick --- docs/modules/ROOT/pages/faq.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/modules/ROOT/pages/faq.adoc b/docs/modules/ROOT/pages/faq.adoc index 8ac1febc..0999b690 100644 --- a/docs/modules/ROOT/pages/faq.adoc +++ b/docs/modules/ROOT/pages/faq.adoc @@ -141,7 +141,7 @@ Note that the git revision should match any other embassy patches or git depende * Make sure RCC is set up to go as fast as possible * Make sure link:https://docs.rs/cortex-m/latest/cortex_m/peripheral/struct.SCB.html[flash cache] is enabled * build with `--release` -* Set the following keys for the release profile in your `Cargo.toml``: +* Set the following keys for the release profile in your `Cargo.toml`: ** `opt-level=s` ** `lto=fat` ** `build-std=core` From a76dd2d70ff85f83b7fe1b0771b12f313682e901 Mon Sep 17 00:00:00 2001 From: Barnaby Walters Date: Tue, 5 Dec 2023 01:01:50 +0100 Subject: [PATCH 37/98] Moved content from the wiki to the docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New: delaying_a_task.adoc, copied as-is from the wiki and placed in the navigation until we have a better place for it (or remove/replace it) index: Tweaked the structure, added some content from the wiki, and made some general copy edits to improve clarity. getting_started.adoc: Corrected various out-of-date information, added troubleshooting tips from the wiki, added some new information, various other small edits. basic_application.adoc: Corrected out-of-date information, various clarifications and edits. After these changes, IMO most of the content on the github wiki is no longer necessary and can be removed for clarity. The few sections I didn‘t integrate or copy over were either out of date or unfinished. --- docs/modules/ROOT/nav.adoc | 1 + .../modules/ROOT/pages/basic_application.adoc | 9 ++- docs/modules/ROOT/pages/delaying_a_task.adoc | 28 +++++++ docs/modules/ROOT/pages/getting_started.adoc | 73 ++++++++++++++++++- docs/modules/ROOT/pages/index.adoc | 50 +++++++++---- 5 files changed, 139 insertions(+), 22 deletions(-) create mode 100644 docs/modules/ROOT/pages/delaying_a_task.adoc diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index 13459099..8d7f6f41 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -3,6 +3,7 @@ ** xref:project_structure.adoc[Project Structure] * xref:layer_by_layer.adoc[Bare metal to async] * xref:runtime.adoc[Executor] +* xref:delaying_a_task.adoc[Delaying a Task] * xref:hal.adoc[HAL] ** xref:nrf.adoc[nRF] ** xref:stm32.adoc[STM32] diff --git a/docs/modules/ROOT/pages/basic_application.adoc b/docs/modules/ROOT/pages/basic_application.adoc index 6d0d0438..95792d5a 100644 --- a/docs/modules/ROOT/pages/basic_application.adoc +++ b/docs/modules/ROOT/pages/basic_application.adoc @@ -6,9 +6,11 @@ So you've got one of the xref:examples.adoc[examples] running, but what now? Let The full example can be found link:https://github.com/embassy-rs/embassy/tree/master/docs/modules/ROOT/examples/basic[here]. +NOTE: If you’re using VS Code and rust-analyzer to view and edit the examples, you may need to make some changes to `.vscode/settings.json` to tell it which project we’re working on. Follow the instructions commented in that file to get rust-analyzer working correctly. + === Bare metal -The first thing you'll notice is a few declarations, two of which indicate that Embassy is suitable for bare metal development: +The first thing you’ll notice are two attributes at the top of the file. These tells the compiler that program has no access to std, and that there is no main function (because it is not run by an OS). [source,rust] ---- @@ -48,9 +50,9 @@ NOTE: Notice that there is no busy waiting going on in this task. It is using th === Main -The main entry point of an Embassy application is defined using the `#[embassy_executor::main]` macro. The entry point is also required to take a `Spawner` and a `Peripherals` argument. +The main entry point of an Embassy application is defined using the `#[embassy_executor::main]` macro. The entry point is passed a `Spawner`, which it can use to spawn other tasks. -The `Spawner` is the way the main application spawns other tasks. The `Peripherals` type comes from the HAL and holds all peripherals that the application may use. In this case, we want to configure one of the pins as a GPIO output driving the LED: +We then initialize the HAL with a default config, which gives us a `Peripherals` struct we can use to access the MCU’s various peripherals. In this case, we want to configure one of the pins as a GPIO output driving the LED: [source,rust] ---- @@ -60,7 +62,6 @@ include::example$basic/src/main.rs[lines="22..-1"] What happens when the `blinker` task has been spawned and main returns? Well, the main entry point is actually just like any other task, except that you can only have one and it takes some specific type arguments. The magic lies within the `#[embassy_executor::main]` macro. The macro does the following: . Creates an Embassy Executor -. Initializes the microcontroller HAL to get the `Peripherals` . Defines a main task for the entry point . Runs the executor spawning the main task diff --git a/docs/modules/ROOT/pages/delaying_a_task.adoc b/docs/modules/ROOT/pages/delaying_a_task.adoc new file mode 100644 index 00000000..3171e351 --- /dev/null +++ b/docs/modules/ROOT/pages/delaying_a_task.adoc @@ -0,0 +1,28 @@ += Delaying a Task + +In an embedded program, delaying a task is one of the most common actions taken. In an event loop, delays will need to be inserted to ensure +that other tasks have a chance to run before the next iteration of the loop is called, if no other I/O is performed. Embassy provides an abstraction +to delay the current task for a specified interval of time. + +Timing is serviced by the `embassy::time::Timer` struct, which provides two timing methods. + +`Timer::at` creates a future that completes at the specified `Instant`, relative to the system boot time. +`Timer::after` creates a future that completes after the specified `Duration`, relative to when the future was created. + +An example of a delay is provided as follows: + +[,rust] +---- +use embassy::executor::{task, Executor}; +use embassy::time::{Duration, Timer}; + +#[task] +/// Task that ticks periodically +async fn tick_periodic() -> ! { + loop { + rprintln!("tick!"); + // async sleep primitive, suspends the task for 500ms. + Timer::after(Duration::from_millis(500)).await; + } +} +---- \ No newline at end of file diff --git a/docs/modules/ROOT/pages/getting_started.adoc b/docs/modules/ROOT/pages/getting_started.adoc index 2c6f4b1e..ab819ac2 100644 --- a/docs/modules/ROOT/pages/getting_started.adoc +++ b/docs/modules/ROOT/pages/getting_started.adoc @@ -9,7 +9,9 @@ If you don't have any supported board, don't worry: you can also run embassy on == Getting a board with examples -Embassy supports many microcontroller families, but the easiest ways to get started is if you have one of the more common development kits. +Embassy supports many microcontroller families, but the quickest way to get started is by using a board which Embassy has existing example code for. + +This list is non-exhaustive. If your board isn’t included here, check the link:https://github.com/embassy-rs/embassy/tree/main/examples[examples folder] to see if example code has been written for it. === nRF kits @@ -36,7 +38,7 @@ Embassy supports many microcontroller families, but the easiest ways to get star == Running an example -First you need to clone the [github repository]; +First you need to clone the link:https://github.com/embassy-rs/embassy[github repository]; [source, bash] ---- @@ -44,17 +46,80 @@ git clone https://github.com/embassy-rs/embassy.git cd embassy ---- -You can run an example by opening a terminal and entering the following commands: +Once you have a copy of the repository, find examples folder for your board and, and build an example program. `blinky` is a good choice as all it does is blink an LED – the embedded world’s equivalent of “Hello World”. [source, bash] ---- cd examples/nrf52840 +cargo build --bin blinky --release +---- + +Once you’ve confirmed you can build the example, connect your computer to your board with a debug probe and run it on hardware: + +[source, bash] +---- cargo run --bin blinky --release ---- +If everything worked correctly, you should see a blinking LED on your board, and debug output similar to this on your computer: + +[source] +---- + Finished dev [unoptimized + debuginfo] target(s) in 1m 56s + Running `probe-run --chip STM32F407VGTx target/thumbv7em-none-eabi/debug/blinky` +(HOST) INFO flashing program (71.36 KiB) +(HOST) INFO success! +──────────────────────────────────────────────────────────────────────────────── +0 INFO Hello World! +└─ blinky::__embassy_main::task::{generator#0} @ src/bin/blinky.rs:18 +1 INFO high +└─ blinky::__embassy_main::task::{generator#0} @ src/bin/blinky.rs:23 +2 INFO low +└─ blinky::__embassy_main::task::{generator#0} @ src/bin/blinky.rs:27 +3 INFO high +└─ blinky::__embassy_main::task::{generator#0} @ src/bin/blinky.rs:23 +4 INFO low +└─ blinky::__embassy_main::task::{generator#0} @ src/bin/blinky.rs:27 +---- + +NOTE: How does the `cargo run` command know how to connect to our board and program it? In each `examples` folder, there’s a `.cargo/config.toml` file which tells cargo to use link:https://probe.rs/[probe-rs] as the runner for ARM binaries in that folder. probe-rs handles communication with the debug probe and MCU. In order for this to work, probe-rs needs to know which chip it’s programming, so you’ll have to edit this file if you want to run examples on other chips. + +=== It didn’t work! + +If you hare having issues when running `cargo run --release`, please check the following: + +* You are specifying the correct `--chip on the command line``, OR +* You have set `.cargo/config.toml`'s run line to the correct chip, AND +* You have changed `examples/Cargo.toml`'s HAL (e.g. embassy-stm32) dependency's feature to use the correct chip (replace the existing stm32xxxx feature) + +At this point the project should run. If you do not see a blinky LED for blinky, for example, be sure to check the code is toggling your board's LED pin. + +If you are trying to run an example with `cargo run --release` and you see the following output: +[source] +---- +0.000000 INFO Hello World! +└─ +0.000000 DEBUG rcc: Clocks { sys: Hertz(80000000), apb1: Hertz(80000000), apb1_tim: Hertz(80000000), apb2: Hertz(80000000), apb2_tim: Hertz(80000000), ahb1: Hertz(80000000), ahb2: Hertz(80000000), ahb3: Hertz(80000000) } +└─ +0.000061 TRACE allocating type=Interrupt mps=8 interval_ms=255, dir=In +└─ +0.000091 TRACE index=1 +└─ +---- + +To get rid of the frame-index error add the following to your `Cargo.toml`: + +[source,toml] +---- +[profile.release] +debug = 2 +---- + +If you’re still having problems, check the link:https://embassy.dev/book/dev/faq.html[FAQ], or ask for help in the link:https://matrix.to/#/#embassy-rs:matrix.org[Embassy Chat Room]. + == What's next? -Congratulations, you have your first Embassy application running! Here are some alternatives on where to go from here: +Congratulations, you have your first Embassy application running! Here are some suggestions for where to go from here: * Read more about the xref:runtime.adoc[executor]. * Read more about the xref:hal.adoc[HAL]. diff --git a/docs/modules/ROOT/pages/index.adoc b/docs/modules/ROOT/pages/index.adoc index c6dead46..6fba80ed 100644 --- a/docs/modules/ROOT/pages/index.adoc +++ b/docs/modules/ROOT/pages/index.adoc @@ -4,34 +4,56 @@ Embassy is a project to make async/await a first-class option for embedded devel == What is async? -When handling I/O, software must call functions that block program execution until the I/O operation completes. When running inside of an OS such as Linux, such functions generally transfer control to the kernel so that another task, known as a thread, can be executed if available, or the CPU can be put to sleep until another such task is ready to perform more work. Because an OS cannot presume that threads will behave cooperatively, threads are relatively resource-intensive, and may be forcibly interrupted they do not transfer control back to the kernel within an allotted time. But if tasks could be presumed to behave cooperatively, or at least not maliciously, it would be possible to create tasks that appear to be almost free when compared to a traditional OS thread. In Rust, these lightweight tasks, known as 'coroutines' or 'goroutines' in other languages, are implemented with async. +When handling I/O, software must call functions that block program execution until the I/O operation completes. When running inside of an OS such as Linux, such functions generally transfer control to the kernel so that another task (known as a “thread”) can be executed if available, or the CPU can be put to sleep until another task is ready. -Async-await works by transforming each async function into an object called a future. When a future blocks on I/O the future yields, and the scheduler, called an executor, can select a different future to execute. Compared to alternatives such as an RTOS, async can yield better performance and lower power consumption because the executor doesn't have to guess when a future is ready to execute. However, program size may be higher than other alternatives, which may be a problem for certain space-constrained devices with very low memory. On the devices Embassy supports, such as stm32 and nrf, memory is generally large enough to accommodate the modestly-increased program size. +Because an OS cannot presume that threads will behave cooperatively, threads are relatively resource-intensive, and may be forcibly interrupted they do not transfer control back to the kernel within an allotted time. If tasks could be presumed to behave cooperatively, or at least not maliciously, it would be possible to create tasks that appear to be almost free when compared to a traditional OS thread. + +In other programming languages, these lightweight tasks are known as “coroutines” or ”goroutines”. In Rust, they are implemented with async. Async-await works by transforming each async function into an object called a future. When a future blocks on I/O the future yields, and the scheduler, called an executor, can select a different future to execute. + +Compared to alternatives such as an RTOS, async can yield better performance and lower power consumption because the executor doesn't have to guess when a future is ready to execute. However, program size may be higher than other alternatives, which may be a problem for certain space-constrained devices with very low memory. On the devices Embassy supports, such as stm32 and nrf, memory is generally large enough to accommodate the modestly-increased program size. == What is Embassy? The Embassy project consists of several crates that you can use together or independently: -* **Executor** - The link:https://docs.embassy.dev/embassy-executor/[embassy-executor] is an async/await executor that generally executes a fixed number of tasks, allocated at startup, though more can be added later. The HAL is an API that you can use to access peripherals, such as USART, UART, I2C, SPI, CAN, and USB. Embassy provides implementations of both async and blocking APIs where it makes sense. DMA (Direct Memory Access) is an example where async is a good fit, whereas GPIO states are a better fit for a blocking API. The executor may also provide a system timer that you can use for both async and blocking delays. For less than one microsecond, blocking delays should be used because the cost of context-switching is too high and the executor will be unable to provide accurate timing. +=== Executor +The link:https://docs.embassy.dev/embassy-executor/[embassy-executor] is an async/await executor that generally executes a fixed number of tasks, allocated at startup, though more can be added later. The executor may also provide a system timer that you can use for both async and blocking delays. For less than one microsecond, blocking delays should be used because the cost of context-switching is too high and the executor will be unable to provide accurate timing. + +=== Hardware Abstraction Layers +HALs implement safe Rust API which let you use peripherals such as USART, UART, I2C, SPI, CAN, and USB without having to directly manipulate registers. + +Embassy provides implementations of both async and blocking APIs where it makes sense. DMA (Direct Memory Access) is an example where async is a good fit, whereas GPIO states are a better fit for a blocking API. + +The Embassy project maintains HALs for select hardware, but you can still use HALs from other projects with Embassy. + +* link:https://docs.embassy.dev/embassy-stm32/[embassy-stm32], for all STM32 microcontroller families. +* link:https://docs.embassy.dev/embassy-nrf/[embassy-nrf], for the Nordic Semiconductor nRF52, nRF53, nRF91 series. +* link:https://docs.embassy.dev/embassy-rp/[embassy-rp], for the Raspberry Pi RP2040 microcontroller. +* link:https://github.com/esp-rs[esp-rs], for the Espressif Systems ESP32 series of chips. -* **Hardware Abstraction Layers** - HALs implement safe, idiomatic Rust APIs to use the hardware capabilities, so raw register manipulation is not needed. The Embassy project maintains HALs for select hardware, but you can still use HALs from other projects with Embassy. -** link:https://docs.embassy.dev/embassy-stm32/[embassy-stm32], for all STM32 microcontroller families. -** link:https://docs.embassy.dev/embassy-nrf/[embassy-nrf], for the Nordic Semiconductor nRF52, nRF53, nRF91 series. -** link:https://docs.embassy.dev/embassy-rp/[embassy-rp], for the Raspberry Pi RP2040 microcontroller. -** link:https://github.com/esp-rs[esp-rs], for the Espressif Systems ESP32 series of chips. -+ NOTE: A common question is if one can use the Embassy HALs standalone. Yes, it is possible! There are no dependency on the executor within the HALs. You can even use them without async, as they implement both the link:https://github.com/rust-embedded/embedded-hal[Embedded HAL] blocking and async traits. -* **Networking** - The link:https://docs.embassy.dev/embassy-net/[embassy-net] network stack implements extensive networking functionality, including Ethernet, IP, TCP, UDP, ICMP and DHCP. Async drastically simplifies managing timeouts and serving multiple connections concurrently. Several drivers for WiFi and Ethernet chips can be found. +=== Networking +The link:https://docs.embassy.dev/embassy-net/[embassy-net] network stack implements extensive networking functionality, including Ethernet, IP, TCP, UDP, ICMP and DHCP. Async drastically simplifies managing timeouts and serving multiple connections concurrently. Several drivers for WiFi and Ethernet chips can be found. -* **Bluetooth** - The link:https://github.com/embassy-rs/nrf-softdevice[nrf-softdevice] crate provides Bluetooth Low Energy 4.x and 5.x support for nRF52 microcontrollers. +=== Bluetooth +The link:https://github.com/embassy-rs/nrf-softdevice[nrf-softdevice] crate provides Bluetooth Low Energy 4.x and 5.x support for nRF52 microcontrollers. -* **LoRa** - link:https://github.com/embassy-rs/lora-phy[lora-phy] and link:https://docs.embassy.dev/embassy-lora/[embassy-lora] supports LoRa networking on a wide range of LoRa radios, fully integrated with a Rust link:https://github.com/ivajloip/rust-lorawan[LoRaWAN] implementation. +=== LoRa +link:https://github.com/embassy-rs/lora-phy[lora-phy] and link:https://docs.embassy.dev/embassy-lora/[embassy-lora] supports LoRa networking on a wide range of LoRa radios, fully integrated with a Rust link:https://github.com/ivajloip/rust-lorawan[LoRaWAN] implementation. -* **USB** - link:https://docs.embassy.dev/embassy-usb/[embassy-usb] implements a device-side USB stack. Implementations for common classes such as USB serial (CDC ACM) and USB HID are available, and a rich builder API allows building your own. +=== USB +link:https://docs.embassy.dev/embassy-usb/[embassy-usb] implements a device-side USB stack. Implementations for common classes such as USB serial (CDC ACM) and USB HID are available, and a rich builder API allows building your own. -* **Bootloader and DFU** - link:https://github.com/embassy-rs/embassy/tree/master/embassy-boot[embassy-boot] is a lightweight bootloader supporting firmware application upgrades in a power-fail-safe way, with trial boots and rollbacks. +=== Bootloader and DFU +link:https://github.com/embassy-rs/embassy/tree/master/embassy-boot[embassy-boot] is a lightweight bootloader supporting firmware application upgrades in a power-fail-safe way, with trial boots and rollbacks. + +== What is DMA? + +For most I/O in embedded devices, the peripheral doesn't directly support the transmission of multiple bits at once, with CAN being a notable exception. Instead, the MCU must write each byte, one at a time, and then wait until the peripheral is ready to send the next. For high I/O rates, this can pose a problem if the MCU must devote an increasing portion of its time handling each byte. The solution to this problem is to use the Direct Memory Access controller. + +The Direct Memory Access controller (DMA) is a controller that is present in MCUs that Embassy supports, including stm32 and nrf. The DMA allows the MCU to set up a transfer, either send or receive, and then wait for the transfer to complete. With DMA, once started, no MCU intervention is required until the transfer is complete, meaning that the MCU can perform other computation, or set up other I/O while the transfer is in progress. For high I/O rates, DMA can cut the time that the MCU spends handling I/O by over half. However, because DMA is more complex to set-up, it is less widely used in the embedded community. Embassy aims to change that by making DMA the first choice rather than the last. Using Embassy, there's no additional tuning required once I/O rates increase because your application is already set-up to handle them. == Resources From 1f6ffdcdd2e760d91ed10fa63f6819b71579b2b4 Mon Sep 17 00:00:00 2001 From: JuliDi <20155974+JuliDi@users.noreply.github.com> Date: Tue, 5 Dec 2023 10:10:47 +0100 Subject: [PATCH 38/98] fix Cargo.toml and config.toml keys --- docs/modules/ROOT/pages/faq.adoc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/modules/ROOT/pages/faq.adoc b/docs/modules/ROOT/pages/faq.adoc index 0999b690..cab9fb9d 100644 --- a/docs/modules/ROOT/pages/faq.adoc +++ b/docs/modules/ROOT/pages/faq.adoc @@ -142,10 +142,11 @@ Note that the git revision should match any other embassy patches or git depende * Make sure link:https://docs.rs/cortex-m/latest/cortex_m/peripheral/struct.SCB.html[flash cache] is enabled * build with `--release` * Set the following keys for the release profile in your `Cargo.toml`: - ** `opt-level=s` - ** `lto=fat` - ** `build-std=core` - ** `build-std-features=panic_immediate_abort` + ** `opt-level = "s"` + ** `lto = "fat"` +* Set the following keys in the `[unstable]` section of your `.cargo/config.toml` + ** `build-std = ["core"]` + ** `build-std-features = ["panic_immediate_abort"]` * Enable feature `embassy-time/generic-queue`, disable feature `embassy-executor/integrated-timers` * When using `InterruptExecutor`: ** disable `executor-thread` From d2a73229788c8776f822cfe9c6cac7c96d660cbd Mon Sep 17 00:00:00 2001 From: Badr Bouslikhin Date: Tue, 5 Dec 2023 19:48:03 +0100 Subject: [PATCH 39/98] stm32/eth: fix h7 examples The STM32H7 examples enable `dhcpv4` and `dns` features. Both use one socket, meaning that we need one extra socket for our firmware tcp socket. --- examples/stm32h7/src/bin/eth.rs | 2 +- examples/stm32h7/src/bin/eth_client.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index b7a07737..030c961e 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs @@ -92,7 +92,7 @@ async fn main(spawner: Spawner) -> ! { let stack = &*make_static!(Stack::new( device, config, - make_static!(StackResources::<2>::new()), + make_static!(StackResources::<3>::new()), seed )); diff --git a/examples/stm32h7/src/bin/eth_client.rs b/examples/stm32h7/src/bin/eth_client.rs index f0f28ec9..c6b8243e 100644 --- a/examples/stm32h7/src/bin/eth_client.rs +++ b/examples/stm32h7/src/bin/eth_client.rs @@ -93,7 +93,7 @@ async fn main(spawner: Spawner) -> ! { let stack = &*make_static!(Stack::new( device, config, - make_static!(StackResources::<2>::new()), + make_static!(StackResources::<3>::new()), seed )); From 0ffb35a2a14c5c033ca4376b329d347df1e3c6bf Mon Sep 17 00:00:00 2001 From: Badr Bouslikhin Date: Tue, 5 Dec 2023 19:50:11 +0100 Subject: [PATCH 40/98] stm32/eth: add host server command example --- examples/stm32h7/src/bin/eth.rs | 1 + examples/stm32h7/src/bin/eth_client.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index 030c961e..dbddfc22 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs @@ -113,6 +113,7 @@ async fn main(spawner: Spawner) -> ! { socket.set_timeout(Some(embassy_time::Duration::from_secs(10))); + // You need to start a server on the host machine, for example: `nc -l 8000` let remote_endpoint = (Ipv4Address::new(10, 42, 0, 1), 8000); info!("connecting..."); let r = socket.connect(remote_endpoint).await; diff --git a/examples/stm32h7/src/bin/eth_client.rs b/examples/stm32h7/src/bin/eth_client.rs index c6b8243e..17e1d9fb 100644 --- a/examples/stm32h7/src/bin/eth_client.rs +++ b/examples/stm32h7/src/bin/eth_client.rs @@ -109,6 +109,7 @@ async fn main(spawner: Spawner) -> ! { let client = TcpClient::new(&stack, &state); loop { + // You need to start a server on the host machine, for example: `nc -l 8000` let addr = SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(10, 42, 0, 1), 8000)); info!("connecting..."); From c5e8a2e8348a17aaeb2e026462f7b4ceaee6190d Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Tue, 5 Dec 2023 13:37:35 +0100 Subject: [PATCH 41/98] embassy-executor 0.4 --- embassy-executor/CHANGELOG.md | 5 ++++- embassy-executor/Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/embassy-executor/CHANGELOG.md b/embassy-executor/CHANGELOG.md index c839981d..5c674923 100644 --- a/embassy-executor/CHANGELOG.md +++ b/embassy-executor/CHANGELOG.md @@ -7,7 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased -- Removed `arch-xtensa`. Use the executor provided by the HAL crate (`esp-hal`, `esp32s3-hal`, etc...) instead. +## 0.4.0 - 2023-12-05 + +- Removed `arch-xtensa`. Use the executor provided by the HAL crate (`esp-hal`, `esp32s3-hal`, etc...) instead. +- Added an arena allocator for tasks, allowing using the `main` and `task` macros on Rust 1.75 stable. (it is only used if the `nightly` feature is not enabled. When `nightly` is enabled, `type_alias_impl_trait` is used to statically allocate tasks, as before). ## 0.3.3 - 2023-11-15 diff --git a/embassy-executor/Cargo.toml b/embassy-executor/Cargo.toml index 74efe452..a79bd89f 100644 --- a/embassy-executor/Cargo.toml +++ b/embassy-executor/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "embassy-executor" -version = "0.3.3" +version = "0.4.0" edition = "2021" license = "MIT OR Apache-2.0" description = "async/await executor designed for embedded usage" From 925f5cbc26d57f6a551593a5f973ad2b6edb9254 Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Wed, 6 Dec 2023 12:03:43 +0100 Subject: [PATCH 42/98] Update all references to `embasy-executor` to the latest version --- docs/modules/ROOT/examples/basic/Cargo.toml | 2 +- .../ROOT/examples/layer-by-layer/blinky-async/Cargo.toml | 2 +- embassy-rp/Cargo.toml | 2 +- embassy-stm32/Cargo.toml | 2 +- embassy-time/Cargo.toml | 2 +- examples/boot/application/nrf/Cargo.toml | 2 +- examples/boot/application/rp/Cargo.toml | 2 +- examples/boot/application/stm32f3/Cargo.toml | 2 +- examples/boot/application/stm32f7/Cargo.toml | 2 +- examples/boot/application/stm32h7/Cargo.toml | 2 +- examples/boot/application/stm32l0/Cargo.toml | 2 +- examples/boot/application/stm32l1/Cargo.toml | 2 +- examples/boot/application/stm32l4/Cargo.toml | 2 +- examples/boot/application/stm32wl/Cargo.toml | 2 +- examples/nrf-rtos-trace/Cargo.toml | 2 +- examples/nrf52840/Cargo.toml | 2 +- examples/nrf5340/Cargo.toml | 2 +- examples/rp/Cargo.toml | 2 +- examples/std/Cargo.toml | 2 +- examples/stm32c0/Cargo.toml | 2 +- examples/stm32f0/Cargo.toml | 2 +- examples/stm32f1/Cargo.toml | 2 +- examples/stm32f2/Cargo.toml | 2 +- examples/stm32f3/Cargo.toml | 2 +- examples/stm32f334/Cargo.toml | 2 +- examples/stm32f4/Cargo.toml | 2 +- examples/stm32f7/Cargo.toml | 2 +- examples/stm32g0/Cargo.toml | 2 +- examples/stm32g4/Cargo.toml | 2 +- examples/stm32h5/Cargo.toml | 2 +- examples/stm32h7/Cargo.toml | 2 +- examples/stm32l0/Cargo.toml | 2 +- examples/stm32l1/Cargo.toml | 2 +- examples/stm32l4/Cargo.toml | 2 +- examples/stm32l5/Cargo.toml | 2 +- examples/stm32u5/Cargo.toml | 2 +- examples/stm32wb/Cargo.toml | 2 +- examples/stm32wba/Cargo.toml | 2 +- examples/stm32wl/Cargo.toml | 2 +- examples/wasm/Cargo.toml | 2 +- tests/nrf/Cargo.toml | 2 +- tests/riscv32/Cargo.toml | 2 +- tests/rp/Cargo.toml | 2 +- tests/stm32/Cargo.toml | 2 +- 44 files changed, 44 insertions(+), 44 deletions(-) diff --git a/docs/modules/ROOT/examples/basic/Cargo.toml b/docs/modules/ROOT/examples/basic/Cargo.toml index b2e173bf..8f6e05fa 100644 --- a/docs/modules/ROOT/examples/basic/Cargo.toml +++ b/docs/modules/ROOT/examples/basic/Cargo.toml @@ -6,7 +6,7 @@ version = "0.1.0" license = "MIT OR Apache-2.0" [dependencies] -embassy-executor = { version = "0.3.0", path = "../../../../../embassy-executor", features = ["defmt", "integrated-timers", "arch-cortex-m", "executor-thread"] } +embassy-executor = { version = "0.4.0", path = "../../../../../embassy-executor", features = ["defmt", "integrated-timers", "arch-cortex-m", "executor-thread"] } embassy-time = { version = "0.2.0", path = "../../../../../embassy-time", features = ["defmt"] } embassy-nrf = { version = "0.1.0", path = "../../../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote"] } diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/Cargo.toml b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/Cargo.toml index b39f02ae..dcdb71e7 100644 --- a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/Cargo.toml +++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" cortex-m = "0.7" cortex-m-rt = "0.7" embassy-stm32 = { version = "0.1.0", features = ["stm32l475vg", "memory-x", "exti"] } -embassy-executor = { version = "0.3.0", features = ["nightly", "arch-cortex-m", "executor-thread"] } +embassy-executor = { version = "0.4.0", features = ["nightly", "arch-cortex-m", "executor-thread"] } defmt = "0.3.0" defmt-rtt = "0.3.0" diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index cfadd9f2..dfdd1fee 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml @@ -87,5 +87,5 @@ pio = {version= "0.2.1" } rp2040-boot2 = "0.3" [dev-dependencies] -embassy-executor = { version = "0.3.3", path = "../embassy-executor", features = ["nightly", "arch-std", "executor-thread"] } +embassy-executor = { version = "0.4.0", path = "../embassy-executor", features = ["nightly", "arch-std", "executor-thread"] } static_cell = { version = "2" } diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index ea395c33..a8790ce6 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -39,7 +39,7 @@ embassy-hal-internal = {version = "0.1.0", path = "../embassy-hal-internal", fea embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } embassy-net-driver = { version = "0.2.0", path = "../embassy-net-driver" } embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver" } -embassy-executor = { version = "0.3.3", path = "../embassy-executor", optional = true } +embassy-executor = { version = "0.4.0", path = "../embassy-executor", optional = true } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } diff --git a/embassy-time/Cargo.toml b/embassy-time/Cargo.toml index 7358b064..94e79382 100644 --- a/embassy-time/Cargo.toml +++ b/embassy-time/Cargo.toml @@ -251,4 +251,4 @@ wasm-timer = { version = "0.2.5", optional = true } [dev-dependencies] serial_test = "0.9" critical-section = { version = "1.1", features = ["std"] } -embassy-executor = { version = "0.3.3", path = "../embassy-executor" } +embassy-executor = { version = "0.4.0", path = "../embassy-executor" } diff --git a/examples/boot/application/nrf/Cargo.toml b/examples/boot/application/nrf/Cargo.toml index 35ec426c..5f11750b 100644 --- a/examples/boot/application/nrf/Cargo.toml +++ b/examples/boot/application/nrf/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } -embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers", "arch-cortex-m", "executor-thread"] } +embassy-executor = { version = "0.4.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers", "arch-cortex-m", "executor-thread"] } embassy-time = { version = "0.2", path = "../../../../embassy-time", features = [] } embassy-nrf = { version = "0.1.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", ] } embassy-boot = { version = "0.1.0", path = "../../../../embassy-boot/boot", features = [] } diff --git a/examples/boot/application/rp/Cargo.toml b/examples/boot/application/rp/Cargo.toml index e4a992c2..89ac5a8f 100644 --- a/examples/boot/application/rp/Cargo.toml +++ b/examples/boot/application/rp/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } -embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers", "arch-cortex-m", "executor-thread"] } +embassy-executor = { version = "0.4.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers", "arch-cortex-m", "executor-thread"] } embassy-time = { version = "0.2", path = "../../../../embassy-time", features = [] } embassy-rp = { version = "0.1.0", path = "../../../../embassy-rp", features = ["time-driver", ] } embassy-boot-rp = { version = "0.1.0", path = "../../../../embassy-boot/rp", features = [] } diff --git a/examples/boot/application/stm32f3/Cargo.toml b/examples/boot/application/stm32f3/Cargo.toml index 706331c8..1a0f8cee 100644 --- a/examples/boot/application/stm32f3/Cargo.toml +++ b/examples/boot/application/stm32f3/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } -embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["stm32f303re", "time-driver-any", "exti"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" } diff --git a/examples/boot/application/stm32f7/Cargo.toml b/examples/boot/application/stm32f7/Cargo.toml index 53c27a5a..e42d1d42 100644 --- a/examples/boot/application/stm32f7/Cargo.toml +++ b/examples/boot/application/stm32f7/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } -embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["stm32f767zi", "time-driver-any", "exti"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = [] } diff --git a/examples/boot/application/stm32h7/Cargo.toml b/examples/boot/application/stm32h7/Cargo.toml index a755b438..8450d863 100644 --- a/examples/boot/application/stm32h7/Cargo.toml +++ b/examples/boot/application/stm32h7/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } -embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["stm32h743zi", "time-driver-any", "exti"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = [] } diff --git a/examples/boot/application/stm32l0/Cargo.toml b/examples/boot/application/stm32l0/Cargo.toml index 0ab5f3e0..d6684bed 100644 --- a/examples/boot/application/stm32l0/Cargo.toml +++ b/examples/boot/application/stm32l0/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } -embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["stm32l072cz", "time-driver-any", "exti", "memory-x"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = [] } diff --git a/examples/boot/application/stm32l1/Cargo.toml b/examples/boot/application/stm32l1/Cargo.toml index 59eadaf6..cca8bf44 100644 --- a/examples/boot/application/stm32l1/Cargo.toml +++ b/examples/boot/application/stm32l1/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } -embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["stm32l151cb-a", "time-driver-any", "exti"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = [] } diff --git a/examples/boot/application/stm32l4/Cargo.toml b/examples/boot/application/stm32l4/Cargo.toml index a9ba4b42..30d61056 100644 --- a/examples/boot/application/stm32l4/Cargo.toml +++ b/examples/boot/application/stm32l4/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } -embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["stm32l475vg", "time-driver-any", "exti"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = [] } diff --git a/examples/boot/application/stm32wl/Cargo.toml b/examples/boot/application/stm32wl/Cargo.toml index 8d927333..7489a2fe 100644 --- a/examples/boot/application/stm32wl/Cargo.toml +++ b/examples/boot/application/stm32wl/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } -embassy-executor = { version = "0.3.3", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["stm32wl55jc-cm4", "time-driver-any", "exti"] } embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = [] } diff --git a/examples/nrf-rtos-trace/Cargo.toml b/examples/nrf-rtos-trace/Cargo.toml index 363c2259..bfbec028 100644 --- a/examples/nrf-rtos-trace/Cargo.toml +++ b/examples/nrf-rtos-trace/Cargo.toml @@ -16,7 +16,7 @@ log = [ [dependencies] embassy-sync = { version = "0.5.0", path = "../../embassy-sync" } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "rtos-trace", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "rtos-trace", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time" } embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } diff --git a/examples/nrf52840/Cargo.toml b/examples/nrf52840/Cargo.toml index 06cd15b0..65cd631f 100644 --- a/examples/nrf52840/Cargo.toml +++ b/examples/nrf52840/Cargo.toml @@ -13,7 +13,7 @@ nightly = [ [dependencies] embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"] } diff --git a/examples/nrf5340/Cargo.toml b/examples/nrf5340/Cargo.toml index ffff9373..17d3e30e 100644 --- a/examples/nrf5340/Cargo.toml +++ b/examples/nrf5340/Cargo.toml @@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf5340-app-s", "time-driver-rtc1", "gpiote", "unstable-pac"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"] } diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index 09b55269..7f637758 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal", features = ["defmt"] } embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["defmt", "unstable-pac", "time-driver", "critical-section-impl"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index e47ab4f3..ccc0a4af 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["log"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-std", "executor-thread", "log", "nightly", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["arch-std", "executor-thread", "log", "nightly", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["log", "std", ] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features=[ "std", "log", "medium-ethernet", "medium-ip", "tcp", "udp", "dns", "dhcpv4", "proto-ipv6"] } embassy-net-tuntap = { version = "0.1.0", path = "../../embassy-net-tuntap" } diff --git a/examples/stm32c0/Cargo.toml b/examples/stm32c0/Cargo.toml index 2f82f82f..2d831ba5 100644 --- a/examples/stm32c0/Cargo.toml +++ b/examples/stm32c0/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" # Change stm32c031c6 to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "time-driver-any", "stm32c031c6", "memory-x", "unstable-pac", "exti"] } embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } defmt = "0.3" diff --git a/examples/stm32f0/Cargo.toml b/examples/stm32f0/Cargo.toml index f5a730a0..2b066d73 100644 --- a/examples/stm32f0/Cargo.toml +++ b/examples/stm32f0/Cargo.toml @@ -15,7 +15,7 @@ defmt = "0.3" defmt-rtt = "0.4" panic-probe = "0.3" embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } static_cell = { version = "2", features = ["nightly"]} portable-atomic = { version = "1.5", features = ["unsafe-assume-single-core"] } diff --git a/examples/stm32f1/Cargo.toml b/examples/stm32f1/Cargo.toml index f8642a5e..f04d4131 100644 --- a/examples/stm32f1/Cargo.toml +++ b/examples/stm32f1/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" # Change stm32f103c8 to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32f103c8", "unstable-pac", "memory-x", "time-driver-any" ] } embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } diff --git a/examples/stm32f2/Cargo.toml b/examples/stm32f2/Cargo.toml index 61de3093..66cc1e15 100644 --- a/examples/stm32f2/Cargo.toml +++ b/examples/stm32f2/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" # Change stm32f207zg to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32f207zg", "unstable-pac", "memory-x", "time-driver-any", "exti"] } embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } defmt = "0.3" diff --git a/examples/stm32f3/Cargo.toml b/examples/stm32f3/Cargo.toml index f24cffbd..ed136785 100644 --- a/examples/stm32f3/Cargo.toml +++ b/examples/stm32f3/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" # Change stm32f303ze to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32f303ze", "unstable-pac", "memory-x", "time-driver-any", "exti"] } embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } diff --git a/examples/stm32f334/Cargo.toml b/examples/stm32f334/Cargo.toml index 930f0737..320cf7d7 100644 --- a/examples/stm32f334/Cargo.toml +++ b/examples/stm32f334/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } embassy-time = { version = "0.2.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32f334r8", "unstable-pac", "memory-x", "time-driver-any", "exti"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml index cd78ff09..6ea0018c 100644 --- a/examples/stm32f4/Cargo.toml +++ b/examples/stm32f4/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" # Change stm32f429zi to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti", "embedded-sdmmc", "chrono"] } embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt" ] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] } diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml index 3e1a26e1..4cca0d93 100644 --- a/examples/stm32f7/Cargo.toml +++ b/examples/stm32f7/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" # Change stm32f767zi to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32f767zi", "memory-x", "unstable-pac", "time-driver-any", "exti"] } embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"] } embedded-io-async = { version = "0.6.1" } diff --git a/examples/stm32g0/Cargo.toml b/examples/stm32g0/Cargo.toml index 2cb2c054..b1e74944 100644 --- a/examples/stm32g0/Cargo.toml +++ b/examples/stm32g0/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" # Change stm32g071rb to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "time-driver-any", "stm32g071rb", "memory-x", "unstable-pac", "exti"] } embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } defmt = "0.3" diff --git a/examples/stm32g4/Cargo.toml b/examples/stm32g4/Cargo.toml index 63cd027a..c56a6362 100644 --- a/examples/stm32g4/Cargo.toml +++ b/examples/stm32g4/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" # Change stm32g491re to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "time-driver-any", "stm32g491re", "memory-x", "unstable-pac", "exti"] } embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } diff --git a/examples/stm32h5/Cargo.toml b/examples/stm32h5/Cargo.toml index c9a137ee..0ed0ce3c 100644 --- a/examples/stm32h5/Cargo.toml +++ b/examples/stm32h5/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" # Change stm32h563zi to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32h563zi", "memory-x", "time-driver-any", "exti", "unstable-pac"] } embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index ca6b2d2f..baa530cf 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" # Change stm32h743bi to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32h743bi", "time-driver-any", "exti", "memory-x", "unstable-pac", "chrono"] } embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index 193762fc..7c826473 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml @@ -12,7 +12,7 @@ nightly = ["embassy-executor/nightly"] # Change stm32l072cz to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "memory-x"] } embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } defmt = "0.3" diff --git a/examples/stm32l1/Cargo.toml b/examples/stm32l1/Cargo.toml index 18b99cb2..23dd0ef8 100644 --- a/examples/stm32l1/Cargo.toml +++ b/examples/stm32l1/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32l151cb-a", "time-driver-any", "memory-x"] } diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml index d7f5eb90..a936d27c 100644 --- a/examples/stm32l4/Cargo.toml +++ b/examples/stm32l4/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" # Change stm32l4s5vi to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "unstable-pac", "stm32l4s5qi", "memory-x", "time-driver-any", "exti", "chrono"] } embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768", ] } embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } diff --git a/examples/stm32l5/Cargo.toml b/examples/stm32l5/Cargo.toml index 3eb862ac..2557ef42 100644 --- a/examples/stm32l5/Cargo.toml +++ b/examples/stm32l5/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" # Change stm32l552ze to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "unstable-pac", "stm32l552ze", "time-driver-any", "exti", "memory-x"] } embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"] } diff --git a/examples/stm32u5/Cargo.toml b/examples/stm32u5/Cargo.toml index 18c920f5..1afbd8db 100644 --- a/examples/stm32u5/Cargo.toml +++ b/examples/stm32u5/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" # Change stm32u585ai to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "unstable-pac", "stm32u585ai", "time-driver-any", "memory-x" ] } embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } diff --git a/examples/stm32wb/Cargo.toml b/examples/stm32wb/Cargo.toml index 63e94fe0..ada1f32e 100644 --- a/examples/stm32wb/Cargo.toml +++ b/examples/stm32wb/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0" embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32wb55rg", "time-driver-any", "memory-x", "exti"] } embassy-stm32-wpan = { version = "0.1.0", path = "../../embassy-stm32-wpan", features = ["defmt", "stm32wb55rg"] } embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "udp", "proto-ipv6", "medium-ieee802154", ], optional=true } diff --git a/examples/stm32wba/Cargo.toml b/examples/stm32wba/Cargo.toml index c4f1f94f..c9760593 100644 --- a/examples/stm32wba/Cargo.toml +++ b/examples/stm32wba/Cargo.toml @@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0" [dependencies] embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "stm32wba52cg", "time-driver-any", "memory-x", "exti"] } embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "udp", "proto-ipv6", "medium-ieee802154", ], optional=true } diff --git a/examples/stm32wl/Cargo.toml b/examples/stm32wl/Cargo.toml index 28d6dbff..070d27cb 100644 --- a/examples/stm32wl/Cargo.toml +++ b/examples/stm32wl/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" # Change stm32wl55jc-cm4 to your chip name, if necessary. embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32wl55jc-cm4", "time-driver-any", "memory-x", "unstable-pac", "exti", "chrono"] } embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } diff --git a/examples/wasm/Cargo.toml b/examples/wasm/Cargo.toml index 21c604eb..c96a428b 100644 --- a/examples/wasm/Cargo.toml +++ b/examples/wasm/Cargo.toml @@ -9,7 +9,7 @@ crate-type = ["cdylib"] [dependencies] embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["log"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-wasm", "executor-thread", "log", "nightly", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["arch-wasm", "executor-thread", "log", "nightly", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["log", "wasm", ] } wasm-logger = "0.2.0" diff --git a/tests/nrf/Cargo.toml b/tests/nrf/Cargo.toml index df036685..7b0d59ee 100644 --- a/tests/nrf/Cargo.toml +++ b/tests/nrf/Cargo.toml @@ -9,7 +9,7 @@ teleprobe-meta = "1" embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt", ] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "task-arena-size-16384", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "task-arena-size-16384", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } diff --git a/tests/riscv32/Cargo.toml b/tests/riscv32/Cargo.toml index b3b50b84..a7b38915 100644 --- a/tests/riscv32/Cargo.toml +++ b/tests/riscv32/Cargo.toml @@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0" [dependencies] critical-section = { version = "1.1.1", features = ["restore-state-bool"] } embassy-sync = { version = "0.5.0", path = "../../embassy-sync" } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-riscv32", "executor-thread"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["arch-riscv32", "executor-thread"] } embassy-time = { version = "0.2", path = "../../embassy-time" } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index 34ee61bb..44fb7bed 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" teleprobe-meta = "1.1" embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", ] } embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = [ "defmt", "unstable-pac", "time-driver", "critical-section-impl", "intrinsics", "rom-v2-intrinsics", "run-from-ram"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index d449cc82..c37d89a4 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -49,7 +49,7 @@ cm0 = ["portable-atomic/unsafe-assume-single-core"] teleprobe-meta = "1" embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt"] } -embassy-executor = { version = "0.3.3", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } +embassy-executor = { version = "0.4.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } embassy-time = { version = "0.2", path = "../../embassy-time", features = ["defmt", "tick-hz-131_072", "defmt-timestamp-uptime"] } embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "unstable-pac", "memory-x", "time-driver-any"] } embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } From cd62d2cd84176cd7a70ea164e34a3f2245c1fbd1 Mon Sep 17 00:00:00 2001 From: Barnaby Walters Date: Wed, 6 Dec 2023 21:10:16 +0100 Subject: [PATCH 43/98] Added embassy in the wild docs page with two projects --- docs/modules/ROOT/nav.adoc | 1 + docs/modules/ROOT/pages/embassy_in_the_wild.adoc | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 docs/modules/ROOT/pages/embassy_in_the_wild.adoc diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index 8d7f6f41..f79e1d54 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -12,4 +12,5 @@ * xref:examples.adoc[Examples] * xref:developer.adoc[Developer] ** xref:developer_stm32.adoc[Developer: STM32] +* xref:embassy_in_the_wild.adoc[Embassy in the wild] * xref:faq.adoc[Frequently Asked Questions] diff --git a/docs/modules/ROOT/pages/embassy_in_the_wild.adoc b/docs/modules/ROOT/pages/embassy_in_the_wild.adoc new file mode 100644 index 00000000..c1c09c38 --- /dev/null +++ b/docs/modules/ROOT/pages/embassy_in_the_wild.adoc @@ -0,0 +1,8 @@ += Embassy in the wild! + +Here are known examples of real-world projects which make use of Embassy. Feel free to link:https://github.com/embassy-rs/embassy/blob/main/docs/modules/ROOT/pages/embassy_in_the_wild.adoc[add more]! + +* link:https://github.com/cbruiz/printhor/[Printhor: The highly reliable but not necessarily functional 3D printer firmware] +** Targets some STM32 MCUs +* link:https://github.com/card-io-ecg/card-io-fw[Card/IO firmware] +** Targets the ESP32-S3 MCU \ No newline at end of file From 10c9e2e7238f07665333264afa132736cee09f8d Mon Sep 17 00:00:00 2001 From: Barnaby Walters Date: Wed, 6 Dec 2023 21:11:34 +0100 Subject: [PATCH 44/98] Added description for Card/IO --- docs/modules/ROOT/pages/embassy_in_the_wild.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/modules/ROOT/pages/embassy_in_the_wild.adoc b/docs/modules/ROOT/pages/embassy_in_the_wild.adoc index c1c09c38..a69aa701 100644 --- a/docs/modules/ROOT/pages/embassy_in_the_wild.adoc +++ b/docs/modules/ROOT/pages/embassy_in_the_wild.adoc @@ -4,5 +4,5 @@ Here are known examples of real-world projects which make use of Embassy. Feel f * link:https://github.com/cbruiz/printhor/[Printhor: The highly reliable but not necessarily functional 3D printer firmware] ** Targets some STM32 MCUs -* link:https://github.com/card-io-ecg/card-io-fw[Card/IO firmware] +* link:https://github.com/card-io-ecg/card-io-fw[Card/IO firmware] - firmware for an open source ECG device ** Targets the ESP32-S3 MCU \ No newline at end of file From 195b492158b7db8b81c4cf6bbc436884590d334b Mon Sep 17 00:00:00 2001 From: Barnaby Walters Date: Wed, 6 Dec 2023 21:13:56 +0100 Subject: [PATCH 45/98] Update docs/modules/ROOT/pages/embassy_in_the_wild.adoc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Dániel Buga --- docs/modules/ROOT/pages/embassy_in_the_wild.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/modules/ROOT/pages/embassy_in_the_wild.adoc b/docs/modules/ROOT/pages/embassy_in_the_wild.adoc index a69aa701..5c12227b 100644 --- a/docs/modules/ROOT/pages/embassy_in_the_wild.adoc +++ b/docs/modules/ROOT/pages/embassy_in_the_wild.adoc @@ -5,4 +5,4 @@ Here are known examples of real-world projects which make use of Embassy. Feel f * link:https://github.com/cbruiz/printhor/[Printhor: The highly reliable but not necessarily functional 3D printer firmware] ** Targets some STM32 MCUs * link:https://github.com/card-io-ecg/card-io-fw[Card/IO firmware] - firmware for an open source ECG device -** Targets the ESP32-S3 MCU \ No newline at end of file +** Targets the ESP32-S3 or ESP32-C6 MCU \ No newline at end of file From 7561696a57ce77146078e481dc75dd3ab9e1c76d Mon Sep 17 00:00:00 2001 From: Barnaby Walters Date: Wed, 6 Dec 2023 21:47:52 +0100 Subject: [PATCH 46/98] Added lora-rs links --- docs/modules/ROOT/pages/embassy_in_the_wild.adoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/modules/ROOT/pages/embassy_in_the_wild.adoc b/docs/modules/ROOT/pages/embassy_in_the_wild.adoc index a69aa701..625bd0b2 100644 --- a/docs/modules/ROOT/pages/embassy_in_the_wild.adoc +++ b/docs/modules/ROOT/pages/embassy_in_the_wild.adoc @@ -5,4 +5,5 @@ Here are known examples of real-world projects which make use of Embassy. Feel f * link:https://github.com/cbruiz/printhor/[Printhor: The highly reliable but not necessarily functional 3D printer firmware] ** Targets some STM32 MCUs * link:https://github.com/card-io-ecg/card-io-fw[Card/IO firmware] - firmware for an open source ECG device -** Targets the ESP32-S3 MCU \ No newline at end of file +** Targets the ESP32-S3 MCU +* The link:https://github.com/lora-rs/lora-rs[lora-rs] project includes link:https://github.com/lora-rs/lora-rs/tree/main/examples/stm32l0/src/bin[various standalone examples] for NRF52840, RP2040, STM32L0 and STM32WL \ No newline at end of file From 536e91d263ecfcf684f91598e5ca987ae0acc820 Mon Sep 17 00:00:00 2001 From: Barnaby Walters Date: Wed, 6 Dec 2023 23:51:13 +0100 Subject: [PATCH 47/98] Added a step-by-step guide to starting a new embassy project Based off an example, noting what to copy, what to change and why Briefly summarizing how to require embassy crates via github All steps tested and proven working at the time of writing --- docs/modules/ROOT/nav.adoc | 1 + docs/modules/ROOT/pages/new_project.adoc | 179 +++++++++++++++++++++++ 2 files changed, 180 insertions(+) create mode 100644 docs/modules/ROOT/pages/new_project.adoc diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index 8d7f6f41..70a4a415 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -1,6 +1,7 @@ * xref:getting_started.adoc[Getting started] ** xref:basic_application.adoc[Basic application] ** xref:project_structure.adoc[Project Structure] +** xref:new_project.adoc[Starting a new Embassy project] * xref:layer_by_layer.adoc[Bare metal to async] * xref:runtime.adoc[Executor] * xref:delaying_a_task.adoc[Delaying a Task] diff --git a/docs/modules/ROOT/pages/new_project.adoc b/docs/modules/ROOT/pages/new_project.adoc new file mode 100644 index 00000000..ae819aa8 --- /dev/null +++ b/docs/modules/ROOT/pages/new_project.adoc @@ -0,0 +1,179 @@ += Starting a new Embassy project + +Once you’ve successfully xref:getting_started.adoc[run some example projects], the next step is to make a standalone Embassy project. The easiest way to do this is to adapt an example for a similar chip to the one you’re targeting. + +As an example, let’s create a new embassy project from scratch for a STM32G474. The same instructions are applicable for any supported chip with some minor changes. + +Run: + +[source,bash] +---- +mkdir embassy-stm32g474 +cd embassy-stm32g474 +cargo init +---- + +to create an empty rust project: + +[source] +---- +embassy-stm32g474 +├── Cargo.toml +└── src + └── main.rs +---- + +Looking in link:https://github.com/embassy-rs/embassy/tree/main/examples[the Embassy examples], we can see there’s a `stm32g4` folder. Find `src/blinky.rs` and copy its contents into our `src/main.rs`. + +== .cargo/config.toml + +Currently, we’d need to provide cargo with a target triple every time we run `cargo build` or `cargo run`. Let’s spare ourselves that work by copying `.cargo/config.toml` from `examples/stm32g4` into our project. + +[source] +---- +embassy-stm32g474 +├── .cargo +│   └── config.toml +├── Cargo.toml +└── src + └── main.rs +---- + +In addition to a target triple, `.cargo/config.toml` contains a `runner` key which allows us to conveniently run our project on hardware with `cargo run` via probe-rs. In order for this to work, we need to provide the correct chip ID. We can do this by checking `probe-rs chip list`: + +[source,bash] +---- +$ probe-rs chip list | grep -i stm32g474re + STM32G474RETx +---- + +and copying `STM32G474RETx` into `.cargo/config.toml` as so: + +[source,toml] +---- +[target.'cfg(all(target_arch = "arm", target_os = "none"))'] +# replace STM32G071C8Rx with your chip as listed in `probe-rs chip list` +runner = "probe-rs run --chip STM32G474RETx" +---- + +== Cargo.toml + +Now that cargo knows what target to compile for (and probe-rs knows what chip to run it on), we’re ready to add some dependencies. + +Looking in `examples/stm32g4/Cargo.toml`, we can see that the examples require a number of embassy crates. For blinky, we’ll only need three of them: `embassy-stm32`, `embassy-executor` and `embassy-time`. + +At the time of writing, the latest version of embassy isn‘t available on crates.io, so we need to install it straight from the git repository. The recommended way of doing so is as follows: + +* Copy the required `embassy-*` lines from the example `Cargo.toml` +* Make any necessary changes to `features`, e.g. requiring the `stm32g474re` feature of `embassy-stm32` +* Remove the `path = ""` keys in the `embassy-*` entries +* Create a `[patch.crates-io]` section, with entries for each embassy crate we need. These should all contain identical values: a link to the git repository, and a reference to the commit we’re checking out. Assuming you want the latest commit, you can find it by running `git ls-remote https://github.com/embassy-rs/embassy.git HEAD` + +NOTE: When using this method, it’s necessary that the `version` keys in `[dependencies]` match up with the versions defined in each crate’s `Cargo.toml` in the specificed `rev` under `[patch.crates.io]`. This means that when updating, you have to a pick a new revision, change everything in `[patch.crates.io]` to match it, and then correct any versions under `[dependencies]` which have changed. Hopefully this will no longer be necessary once embassy is released on crates.io! + +At the time of writing, this method produces the following results: + +[source,toml] +---- +[dependencies] +embassy-stm32 = {version = "0.1.0", features = ["defmt", "time-driver-any", "stm32g474re", "memory-x", "unstable-pac", "exti"]} +embassy-executor = { version = "0.3.3", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } +embassy-time = { version = "0.2", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } + +[patch.crates-io] +embassy-time = { git = "https://github.com/embassy-rs/embassy", rev = "7703f47c1ecac029f603033b7977d9a2becef48c" } +embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "7703f47c1ecac029f603033b7977d9a2becef48c" } +embassy-stm32 = { git = "https://github.com/embassy-rs/embassy", rev = "7703f47c1ecac029f603033b7977d9a2becef48c" } +---- + +There are a few other dependencies we need to build the project, but fortunately they’re much simpler to install. Copy their lines from the example `Cargo.toml` to the the `[dependencies]` section in the new `Cargo.toml`: + +[source,toml] +---- +defmt = "0.3.5" +defmt-rtt = "0.4.0" +cortex-m = {version = "0.7.7", features = ["critical-section-single-core"]} +cortex-m-rt = "0.7.3" +panic-probe = "0.3.1" +---- + +These are the bare minimum dependencies required to run `blinky.rs`, but it’s worth taking a look at the other dependencies specified in the example `Cargo.toml`, and noting what features are required for use with embassy – for example `futures = { version = "0.3.17", default-features = false, features = ["async-await"] }`. + +Finally, copy the `[profile.release]` section from the example `Cargo.toml` into ours. + +[source,toml] +---- +[profile.release] +debug = 2 +---- + +== rust-toolchain.toml + +Before we can build our project, we need to add an additional file to tell cargo to use the nightly toolchain. Copy the `rust-toolchain.toml` from the embassy repo to ours, and trim the list of targets down to only the target triple relevent for our project — in this case, `thumbv7em-none-eabi`: + +[source] +---- +embassy-stm32g474 +├── .cargo +│   └── config.toml +├── Cargo.toml +├── rust-toolchain.toml +└── src + └── main.rs +---- + +[source,toml] +---- +# Before upgrading check that everything is available on all tier1 targets here: +# https://rust-lang.github.io/rustup-components-history +[toolchain] +channel = "nightly-2023-11-01" +components = [ "rust-src", "rustfmt", "llvm-tools", "miri" ] +targets = ["thumbv7em-none-eabi"] +---- + +== build.rs + +In order to produce a working binary for our target, cargo requires a custom build script. Copy `build.rs` from the example to our project: + +[source] +---- +embassy-stm32g474 +├── build.rs +├── .cargo +│ └── config.toml +├── Cargo.toml +├── rust-toolchain.toml +└── src + └── main.rs +---- + +== Building and running + +At this point, we‘re finally ready to build and run our project! Connect your board via a debug probe and run: + +[source,bash] +---- +cargo run --release +---- + +should result in a blinking LED (if there’s one attached to the pin in `src/main.rs` – change it if not!) and the following output: + +[source] +---- + Compiling embassy-stm32g474 v0.1.0 (/home/you/embassy-stm32g474) + Finished release [optimized + debuginfo] target(s) in 0.22s + Running `probe-rs run --chip STM32G474RETx target/thumbv7em-none-eabi/release/embassy-stm32g474` + Erasing sectors ✔ [00:00:00] [#########################################################] 18.00 KiB/18.00 KiB @ 54.09 KiB/s (eta 0s ) + Programming pages ✔ [00:00:00] [#########################################################] 17.00 KiB/17.00 KiB @ 35.91 KiB/s (eta 0s ) Finished in 0.817s +0.000000 TRACE BDCR configured: 00008200 +└─ embassy_stm32::rcc::bd::{impl#3}::init::{closure#4} @ /home/you/.cargo/git/checkouts/embassy-9312dcb0ed774b29/7703f47/embassy-stm32/src/fmt.rs:117 +0.000000 DEBUG rcc: Clocks { sys: Hertz(16000000), pclk1: Hertz(16000000), pclk1_tim: Hertz(16000000), pclk2: Hertz(16000000), pclk2_tim: Hertz(16000000), hclk1: Hertz(16000000), hclk2: Hertz(16000000), pll1_p: None, adc: None, adc34: None, rtc: Some(Hertz(32000)) } +└─ embassy_stm32::rcc::set_freqs @ /home/you/.cargo/git/checkouts/embassy-9312dcb0ed774b29/7703f47/embassy-stm32/src/fmt.rs:130 +0.000000 INFO Hello World! +└─ embassy_stm32g474::____embassy_main_task::{async_fn#0} @ src/main.rs:14 +0.000091 INFO high +└─ embassy_stm32g474::____embassy_main_task::{async_fn#0} @ src/main.rs:19 +0.300201 INFO low +└─ embassy_stm32g474::____embassy_main_task::{async_fn#0} @ src/main.rs:23 +---- \ No newline at end of file From ac2aec4e7a8e8a4c17c611810d382892398c9eb7 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Thu, 7 Dec 2023 00:43:18 +0100 Subject: [PATCH 48/98] executor: rename macro crate to embassy-executor-macros, bump it. --- .../Cargo.toml | 4 ++-- embassy-executor-macros/README.md | 15 +++++++++++++ .../src/lib.rs | 0 .../src/macros/main.rs | 0 .../src/macros/mod.rs | 0 .../src/macros/task.rs | 0 .../src/util/ctxt.rs | 0 .../src/util/mod.rs | 0 embassy-executor/Cargo.toml | 4 ++-- embassy-executor/src/arch/cortex_m.rs | 2 +- embassy-executor/src/arch/riscv32.rs | 2 +- embassy-executor/src/arch/std.rs | 2 +- embassy-executor/src/arch/wasm.rs | 2 +- embassy-executor/src/lib.rs | 2 +- embassy-executor/src/raw/mod.rs | 4 ++-- embassy-executor/src/spawner.rs | 4 ++-- embassy-macros/README.md | 21 ------------------- 17 files changed, 28 insertions(+), 34 deletions(-) rename {embassy-macros => embassy-executor-macros}/Cargo.toml (89%) create mode 100644 embassy-executor-macros/README.md rename {embassy-macros => embassy-executor-macros}/src/lib.rs (100%) rename {embassy-macros => embassy-executor-macros}/src/macros/main.rs (100%) rename {embassy-macros => embassy-executor-macros}/src/macros/mod.rs (100%) rename {embassy-macros => embassy-executor-macros}/src/macros/task.rs (100%) rename {embassy-macros => embassy-executor-macros}/src/util/ctxt.rs (100%) rename {embassy-macros => embassy-executor-macros}/src/util/mod.rs (100%) delete mode 100644 embassy-macros/README.md diff --git a/embassy-macros/Cargo.toml b/embassy-executor-macros/Cargo.toml similarity index 89% rename from embassy-macros/Cargo.toml rename to embassy-executor-macros/Cargo.toml index e13104cf..6ea7ddb7 100644 --- a/embassy-macros/Cargo.toml +++ b/embassy-executor-macros/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "embassy-macros" -version = "0.2.1" +name = "embassy-executor-macros" +version = "0.4.0" edition = "2021" license = "MIT OR Apache-2.0" description = "macros for creating the entry point and tasks for embassy-executor" diff --git a/embassy-executor-macros/README.md b/embassy-executor-macros/README.md new file mode 100644 index 00000000..a959c85d --- /dev/null +++ b/embassy-executor-macros/README.md @@ -0,0 +1,15 @@ +# embassy-executor-macros + +An [Embassy](https://embassy.dev) project. + +NOTE: Do not use this crate directly. The macros are re-exported by `embassy-executor`. + +## License + +This work is licensed under either of + +- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or + ) +- MIT license ([LICENSE-MIT](LICENSE-MIT) or ) + +at your option. diff --git a/embassy-macros/src/lib.rs b/embassy-executor-macros/src/lib.rs similarity index 100% rename from embassy-macros/src/lib.rs rename to embassy-executor-macros/src/lib.rs diff --git a/embassy-macros/src/macros/main.rs b/embassy-executor-macros/src/macros/main.rs similarity index 100% rename from embassy-macros/src/macros/main.rs rename to embassy-executor-macros/src/macros/main.rs diff --git a/embassy-macros/src/macros/mod.rs b/embassy-executor-macros/src/macros/mod.rs similarity index 100% rename from embassy-macros/src/macros/mod.rs rename to embassy-executor-macros/src/macros/mod.rs diff --git a/embassy-macros/src/macros/task.rs b/embassy-executor-macros/src/macros/task.rs similarity index 100% rename from embassy-macros/src/macros/task.rs rename to embassy-executor-macros/src/macros/task.rs diff --git a/embassy-macros/src/util/ctxt.rs b/embassy-executor-macros/src/util/ctxt.rs similarity index 100% rename from embassy-macros/src/util/ctxt.rs rename to embassy-executor-macros/src/util/ctxt.rs diff --git a/embassy-macros/src/util/mod.rs b/embassy-executor-macros/src/util/mod.rs similarity index 100% rename from embassy-macros/src/util/mod.rs rename to embassy-executor-macros/src/util/mod.rs diff --git a/embassy-executor/Cargo.toml b/embassy-executor/Cargo.toml index a79bd89f..ec5aca46 100644 --- a/embassy-executor/Cargo.toml +++ b/embassy-executor/Cargo.toml @@ -32,7 +32,7 @@ defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } rtos-trace = { version = "0.1.2", optional = true } -embassy-macros = { version = "0.2.1", path = "../embassy-macros" } +embassy-executor-macros = { version = "0.4.0", path = "../embassy-executor-macros" } embassy-time = { version = "0.2", path = "../embassy-time", optional = true} critical-section = "1.1" @@ -66,7 +66,7 @@ executor-thread = [] executor-interrupt = [] # Enable nightly-only features -nightly = ["embassy-macros/nightly"] +nightly = ["embassy-executor-macros/nightly"] turbowakers = [] diff --git a/embassy-executor/src/arch/cortex_m.rs b/embassy-executor/src/arch/cortex_m.rs index 4a6d5857..5c517e0a 100644 --- a/embassy-executor/src/arch/cortex_m.rs +++ b/embassy-executor/src/arch/cortex_m.rs @@ -51,7 +51,7 @@ mod thread { use core::arch::asm; use core::marker::PhantomData; - pub use embassy_macros::main_cortex_m as main; + pub use embassy_executor_macros::main_cortex_m as main; use crate::{raw, Spawner}; diff --git a/embassy-executor/src/arch/riscv32.rs b/embassy-executor/src/arch/riscv32.rs index ca12c340..c56f502d 100644 --- a/embassy-executor/src/arch/riscv32.rs +++ b/embassy-executor/src/arch/riscv32.rs @@ -7,7 +7,7 @@ pub use thread::*; mod thread { use core::marker::PhantomData; - pub use embassy_macros::main_riscv as main; + pub use embassy_executor_macros::main_riscv as main; use portable_atomic::{AtomicBool, Ordering}; use crate::{raw, Spawner}; diff --git a/embassy-executor/src/arch/std.rs b/embassy-executor/src/arch/std.rs index 598bb050..b02b1598 100644 --- a/embassy-executor/src/arch/std.rs +++ b/embassy-executor/src/arch/std.rs @@ -8,7 +8,7 @@ mod thread { use std::marker::PhantomData; use std::sync::{Condvar, Mutex}; - pub use embassy_macros::main_std as main; + pub use embassy_executor_macros::main_std as main; use crate::{raw, Spawner}; diff --git a/embassy-executor/src/arch/wasm.rs b/embassy-executor/src/arch/wasm.rs index 3faa9257..f9d0f935 100644 --- a/embassy-executor/src/arch/wasm.rs +++ b/embassy-executor/src/arch/wasm.rs @@ -8,7 +8,7 @@ mod thread { use core::marker::PhantomData; - pub use embassy_macros::main_wasm as main; + pub use embassy_executor_macros::main_wasm as main; use js_sys::Promise; use wasm_bindgen::prelude::*; diff --git a/embassy-executor/src/lib.rs b/embassy-executor/src/lib.rs index 89769615..4c6900a6 100644 --- a/embassy-executor/src/lib.rs +++ b/embassy-executor/src/lib.rs @@ -6,7 +6,7 @@ // This mod MUST go first, so that the others see its macros. pub(crate) mod fmt; -pub use embassy_macros::task; +pub use embassy_executor_macros::task; macro_rules! check_at_most_one { (@amo [$($feats:literal)*] [] [$($res:tt)*]) => { diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs index e9137f8f..b16a1c7c 100644 --- a/embassy-executor/src/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs @@ -5,7 +5,7 @@ //! ## WARNING: here be dragons! //! //! Using this module requires respecting subtle safety contracts. If you can, prefer using the safe -//! [executor wrappers](crate::Executor) and the [`embassy_executor::task`](embassy_macros::task) macro, which are fully safe. +//! [executor wrappers](crate::Executor) and the [`embassy_executor::task`](embassy_executor_macros::task) macro, which are fully safe. #[cfg_attr(target_has_atomic = "ptr", path = "run_queue_atomics.rs")] #[cfg_attr(not(target_has_atomic = "ptr"), path = "run_queue_critical_section.rs")] @@ -97,7 +97,7 @@ impl TaskRef { /// A `TaskStorage` must live forever, it may not be deallocated even after the task has finished /// running. Hence the relevant methods require `&'static self`. It may be reused, however. /// -/// Internally, the [embassy_executor::task](embassy_macros::task) macro allocates an array of `TaskStorage`s +/// Internally, the [embassy_executor::task](embassy_executor_macros::task) macro allocates an array of `TaskStorage`s /// in a `static`. The most common reason to use the raw `Task` is to have control of where /// the memory for the task is allocated: on the stack, or on the heap with e.g. `Box::leak`, etc. diff --git a/embassy-executor/src/spawner.rs b/embassy-executor/src/spawner.rs index 5a3a0dee..27160624 100644 --- a/embassy-executor/src/spawner.rs +++ b/embassy-executor/src/spawner.rs @@ -115,9 +115,9 @@ impl Spawner { } } - // Used by the `embassy_macros::main!` macro to throw an error when spawn + // Used by the `embassy_executor_macros::main!` macro to throw an error when spawn // fails. This is here to allow conditional use of `defmt::unwrap!` - // without introducing a `defmt` feature in the `embassy_macros` package, + // without introducing a `defmt` feature in the `embassy_executor_macros` package, // which would require use of `-Z namespaced-features`. /// Spawn a task into an executor, panicking on failure. /// diff --git a/embassy-macros/README.md b/embassy-macros/README.md deleted file mode 100644 index d1d6f4cc..00000000 --- a/embassy-macros/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# embassy-macros - -An [Embassy](https://embassy.dev) project. - -Macros for creating the main entry point and tasks that can be spawned by `embassy-executor`. - -NOTE: The macros are re-exported by the `embassy-executor` crate which should be used instead of adding a direct dependency on the `embassy-macros` crate. - -## Minimum supported Rust version (MSRV) - -The `task` and `main` macros require the type alias impl trait (TAIT) nightly feature in order to compile. - -## License - -This work is licensed under either of - -- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or - ) -- MIT license ([LICENSE-MIT](LICENSE-MIT) or ) - -at your option. From 16e31747cc860b194719d7d276f1a0c08e417632 Mon Sep 17 00:00:00 2001 From: Barnaby Walters Date: Thu, 7 Dec 2023 00:54:39 +0100 Subject: [PATCH 49/98] Changed example project name --- docs/modules/ROOT/pages/new_project.adoc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/docs/modules/ROOT/pages/new_project.adoc b/docs/modules/ROOT/pages/new_project.adoc index ae819aa8..ce139ed8 100644 --- a/docs/modules/ROOT/pages/new_project.adoc +++ b/docs/modules/ROOT/pages/new_project.adoc @@ -8,16 +8,15 @@ Run: [source,bash] ---- -mkdir embassy-stm32g474 -cd embassy-stm32g474 -cargo init +cargo new stm32g474-example +cd stm32g474-example ---- to create an empty rust project: [source] ---- -embassy-stm32g474 +stm32g474-example ├── Cargo.toml └── src └── main.rs @@ -31,7 +30,7 @@ Currently, we’d need to provide cargo with a target triple every time we run ` [source] ---- -embassy-stm32g474 +stm32g474-example ├── .cargo │   └── config.toml ├── Cargo.toml @@ -113,7 +112,7 @@ Before we can build our project, we need to add an additional file to tell cargo [source] ---- -embassy-stm32g474 +stm32g474-example ├── .cargo │   └── config.toml ├── Cargo.toml @@ -138,7 +137,7 @@ In order to produce a working binary for our target, cargo requires a custom bui [source] ---- -embassy-stm32g474 +stm32g474-example ├── build.rs ├── .cargo │ └── config.toml @@ -161,9 +160,9 @@ should result in a blinking LED (if there’s one attached to the pin in `src/ma [source] ---- - Compiling embassy-stm32g474 v0.1.0 (/home/you/embassy-stm32g474) + Compiling stm32g474-example v0.1.0 (/home/you/stm32g474-example) Finished release [optimized + debuginfo] target(s) in 0.22s - Running `probe-rs run --chip STM32G474RETx target/thumbv7em-none-eabi/release/embassy-stm32g474` + Running `probe-rs run --chip STM32G474RETx target/thumbv7em-none-eabi/release/stm32g474-example` Erasing sectors ✔ [00:00:00] [#########################################################] 18.00 KiB/18.00 KiB @ 54.09 KiB/s (eta 0s ) Programming pages ✔ [00:00:00] [#########################################################] 17.00 KiB/17.00 KiB @ 35.91 KiB/s (eta 0s ) Finished in 0.817s 0.000000 TRACE BDCR configured: 00008200 From 8fa5a6b282792d7f9238964acc2916452b494965 Mon Sep 17 00:00:00 2001 From: James Munns Date: Thu, 7 Dec 2023 14:27:09 +0100 Subject: [PATCH 50/98] Tweak FAQ size profile suggestions If we want the smallest binary, we probably want codegen-units = 1, and disable incremental builds. --- docs/modules/ROOT/pages/faq.adoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/modules/ROOT/pages/faq.adoc b/docs/modules/ROOT/pages/faq.adoc index df3f6665..2ec43891 100644 --- a/docs/modules/ROOT/pages/faq.adoc +++ b/docs/modules/ROOT/pages/faq.adoc @@ -47,7 +47,8 @@ The first step to managing your binary size is to set up your link:https://doc.r debug = false lto = true opt-level = "s" -incremental = true +incremental = false +codegen-units = 1 ---- All of these flags are elaborated on in the Rust Book page linked above. From c05149e5e4110bed416e8a8568cf446e9db8774d Mon Sep 17 00:00:00 2001 From: JuliDi <20155974+JuliDi@users.noreply.github.com> Date: Fri, 8 Dec 2023 13:00:21 +0100 Subject: [PATCH 51/98] add best practices first draft --- docs/modules/ROOT/nav.adoc | 5 +- docs/modules/ROOT/pages/best_practices.adoc | 53 +++++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 docs/modules/ROOT/pages/best_practices.adoc diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index 2154799f..fabb80e3 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -2,6 +2,7 @@ ** xref:basic_application.adoc[Basic application] ** xref:project_structure.adoc[Project Structure] ** xref:new_project.adoc[Starting a new Embassy project] +** xref:best_practices.adoc[Best Practices] * xref:layer_by_layer.adoc[Bare metal to async] * xref:runtime.adoc[Executor] * xref:delaying_a_task.adoc[Delaying a Task] @@ -11,7 +12,7 @@ * xref:bootloader.adoc[Bootloader] * xref:examples.adoc[Examples] -* xref:developer.adoc[Developer] -** xref:developer_stm32.adoc[Developer: STM32] +* xref:developer.adoc[Developer Docs] +** xref:developer_stm32.adoc[Developer Docs: STM32] * xref:embassy_in_the_wild.adoc[Embassy in the wild] * xref:faq.adoc[Frequently Asked Questions] diff --git a/docs/modules/ROOT/pages/best_practices.adoc b/docs/modules/ROOT/pages/best_practices.adoc new file mode 100644 index 00000000..1e02f9ba --- /dev/null +++ b/docs/modules/ROOT/pages/best_practices.adoc @@ -0,0 +1,53 @@ += Best Practices + +Over time, a couple of best practices have emerged. The following list should serve as a guideline for developers writing embedded software in _Rust_, especially in the context of the _Embassy_ framework. + +== Passing Buffers by Reference +It may be tempting to pass arrays or wrappers, like link:https://docs.rs/heapless/latest/heapless/[`heapless::Vec`], to a function or return one just like you would with a `std::Vec`. However, in most embedded applications you don't want to spend ressources on an allocator and end up placing buffers on the stack. +This, however, can easily blow up your stack if you are not careful. + +Consider the following example: +[,rust] +---- +fn process_buffer(mut buf: [u8; 1024]) -> [u8; 1024] { + // do stuff and return new buffer + for elem in buf.iter_mut() { + *elem = 0; + } + buf +} + +pub fn main() -> () { + let buf = [1u8; 1024]; + let buf_new = process_buffer(buf); + // do stuff with buf_new + () +} +---- +When calling `process_buffer` in your program, a copy of the buffer you pass to the function will be created, +consuming another 1024 bytes. +After the processing, another 1024 byte buffer will be placed on the stack to be returned to the caller. +(You can check the assembly, there will be two memcopy operations, e.g., `bl __aeabi_memcpy` when compiling for a Cortex-M processor.) + +*Possible Solution:* + +Pass the data by reference and not by value on both, the way in and the way out. +For example, you could return a slice of the input buffer as the output. +Requiring the lifetime of the input slice and the output slice to be the same, the memory safetly of this procedure will be enforced by the compiler. + +[,rust] +---- +fn process_buffer<'a>(buf: &'a mut [u8]) -> &'a mut[u8] { + for elem in buf.iter_mut() { + *elem = 0; + } + buf +} + +pub fn main() -> () { + let mut buf = [1u8; 1024]; + let buf_new = process_buffer(&mut buf); + // do stuff with buf_new + () +} +---- From 881cb16d2809cf84757b7ecabcad44be0d97fa14 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 8 Dec 2023 20:07:06 +0100 Subject: [PATCH 52/98] stm32/adc: move convert resolution from PAC to version-specific mod. --- embassy-stm32/src/adc/f3_v1_1.rs | 7 ++++++- embassy-stm32/src/adc/resolution.rs | 16 ---------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/embassy-stm32/src/adc/f3_v1_1.rs b/embassy-stm32/src/adc/f3_v1_1.rs index 0bbfd313..6915a8f1 100644 --- a/embassy-stm32/src/adc/f3_v1_1.rs +++ b/embassy-stm32/src/adc/f3_v1_1.rs @@ -175,7 +175,12 @@ impl<'d, T: Instance> Adc<'d, T> { } pub fn resolution(&self) -> Resolution { - T::regs().cr1().read().res().into() + match T::regs().cr1().read().res() { + crate::pac::adc::vals::Res::TWELVEBIT => Resolution::TwelveBit, + crate::pac::adc::vals::Res::TENBIT => Resolution::TenBit, + crate::pac::adc::vals::Res::EIGHTBIT => Resolution::EightBit, + crate::pac::adc::vals::Res::SIXBIT => Resolution::SixBit, + } } pub fn enable_vref(&self) -> Vref { diff --git a/embassy-stm32/src/adc/resolution.rs b/embassy-stm32/src/adc/resolution.rs index b1597a82..383980b5 100644 --- a/embassy-stm32/src/adc/resolution.rs +++ b/embassy-stm32/src/adc/resolution.rs @@ -48,22 +48,6 @@ impl From for crate::pac::adc::vals::Res { } } -impl From for Resolution { - fn from(res: crate::pac::adc::vals::Res) -> Resolution { - match res { - #[cfg(adc_v4)] - crate::pac::adc::vals::Res::SIXTEENBIT => Resolution::SixteenBit, - #[cfg(adc_v4)] - crate::pac::adc::vals::Res::FOURTEENBITV => Resolution::FourteenBit, - crate::pac::adc::vals::Res::TWELVEBIT => Resolution::TwelveBit, - crate::pac::adc::vals::Res::TENBIT => Resolution::TenBit, - crate::pac::adc::vals::Res::EIGHTBIT => Resolution::EightBit, - #[cfg(any(adc_v1, adc_v2, adc_v3, adc_g0, adc_f3, adc_f3_v1_1, adc_f3_v3))] - crate::pac::adc::vals::Res::SIXBIT => Resolution::SixBit, - } - } -} - impl Resolution { pub fn to_max_count(&self) -> u32 { match self { From c27459c05251aada50b4de620b78d13dc071a765 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 8 Dec 2023 20:07:59 +0100 Subject: [PATCH 53/98] Update stm32-metapac. --- embassy-stm32/Cargo.toml | 4 ++-- embassy-stm32/build.rs | 4 ++++ embassy-stm32/src/adc/f1.rs | 2 +- embassy-stm32/src/can/mod.rs | 2 +- embassy-stm32/src/rcc/g4.rs | 2 ++ embassy-stm32/src/rcc/mod.rs | 4 ++-- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 292902ac..c5877570 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -58,7 +58,7 @@ rand_core = "0.6.3" sdio-host = "0.5.0" embedded-sdmmc = { git = "https://github.com/embassy-rs/embedded-sdmmc-rs", rev = "a4f293d3a6f72158385f79c98634cb8a14d0d2fc", optional = true } critical-section = "1.1" -stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-7117ad49c06fa00c388130a34977e029910083bd" } +stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-019a5da1c47c092c199bc39a7f84fb444f2adcdf" } vcell = "0.1.3" bxcan = "0.7.0" nb = "1.0.0" @@ -76,7 +76,7 @@ critical-section = { version = "1.1", features = ["std"] } [build-dependencies] proc-macro2 = "1.0.36" quote = "1.0.15" -stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-7117ad49c06fa00c388130a34977e029910083bd", default-features = false, features = ["metadata"]} +stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-019a5da1c47c092c199bc39a7f84fb444f2adcdf", default-features = false, features = ["metadata"]} [features] diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 7bfd290d..0eef43ac 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs @@ -930,6 +930,10 @@ fn main() { } else if pin.signal.starts_with("INN") { // TODO handle in the future when embassy supports differential measurements None + } else if pin.signal.starts_with("IN") && pin.signal.ends_with("b") { + // we number STM32L1 ADC bank 1 as 0..=31, bank 2 as 32..=63 + let signal = pin.signal.strip_prefix("IN").unwrap().strip_suffix("b").unwrap(); + Some(32u8 + signal.parse::().unwrap()) } else if pin.signal.starts_with("IN") { Some(pin.signal.strip_prefix("IN").unwrap().parse().unwrap()) } else { diff --git a/embassy-stm32/src/adc/f1.rs b/embassy-stm32/src/adc/f1.rs index ad0f1382..fb27bb87 100644 --- a/embassy-stm32/src/adc/f1.rs +++ b/embassy-stm32/src/adc/f1.rs @@ -148,7 +148,7 @@ impl<'d, T: Instance> Adc<'d, T> { reg.set_cont(false); reg.set_exttrig(true); reg.set_swstart(false); - reg.set_extsel(crate::pac::adc::vals::Extsel::SWSTART); + reg.set_extsel(7); // SWSTART }); // Configure the channel to sample diff --git a/embassy-stm32/src/can/mod.rs b/embassy-stm32/src/can/mod.rs index 4ff5aa0d..425f9ac2 100644 --- a/embassy-stm32/src/can/mod.rs +++ b/embassy-stm32/src/can/mod.rs @@ -1,6 +1,6 @@ #![macro_use] #[cfg_attr(can_bxcan, path = "bxcan.rs")] -#[cfg_attr(can_fdcan, path = "fdcan.rs")] +#[cfg_attr(any(can_fdcan_v1, can_fdcan_h7), path = "fdcan.rs")] mod _version; pub use _version::*; diff --git a/embassy-stm32/src/rcc/g4.rs b/embassy-stm32/src/rcc/g4.rs index 48b27255..7af05b48 100644 --- a/embassy-stm32/src/rcc/g4.rs +++ b/embassy-stm32/src/rcc/g4.rs @@ -315,6 +315,8 @@ pub(crate) unsafe fn init(config: Config) { adc: adc12_ck, adc34: adc345_ck, pll1_p: None, + pll1_q: None, // TODO + hse: None, // TODO rtc, }); } diff --git a/embassy-stm32/src/rcc/mod.rs b/embassy-stm32/src/rcc/mod.rs index 2e144dc7..40a5a619 100644 --- a/embassy-stm32/src/rcc/mod.rs +++ b/embassy-stm32/src/rcc/mod.rs @@ -119,7 +119,7 @@ pub struct Clocks { #[cfg(any(stm32g4, rcc_l4))] pub pll1_p: Option, - #[cfg(any(stm32h5, stm32h7, rcc_f2, rcc_f4, rcc_f410, rcc_f7, rcc_l4))] + #[cfg(any(stm32h5, stm32h7, stm32f2, stm32f4, stm32f7, rcc_l4, stm32g4))] pub pll1_q: Option, #[cfg(any(stm32h5, stm32h7))] pub pll2_p: Option, @@ -167,7 +167,7 @@ pub struct Clocks { #[cfg(any(stm32h5, stm32h7, rcc_l4, rcc_c0))] pub lse: Option, - #[cfg(any(stm32h5, stm32h7))] + #[cfg(any(stm32h5, stm32h7, stm32g4))] pub hse: Option, #[cfg(stm32h5)] From fe218ed978a76014b45410e188f974e20adba1a0 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 8 Dec 2023 20:24:15 +0100 Subject: [PATCH 54/98] tests/stm32: add L1 DAC/ADC test. --- tests/stm32/Cargo.toml | 17 ++++--- tests/stm32/src/bin/dac.rs | 5 +- tests/stm32/src/bin/dac_l1.rs | 86 +++++++++++++++++++++++++++++++++++ tests/stm32/src/common.rs | 9 ++-- 4 files changed, 105 insertions(+), 12 deletions(-) create mode 100644 tests/stm32/src/bin/dac_l1.rs diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index 8c2cfdf5..460c103b 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -10,14 +10,14 @@ stm32c031c6 = ["embassy-stm32/stm32c031c6", "cm0", "not-gpdma"] stm32f103c8 = ["embassy-stm32/stm32f103c8", "not-gpdma"] stm32f207zg = ["embassy-stm32/stm32f207zg", "chrono", "not-gpdma", "eth", "rng"] stm32f303ze = ["embassy-stm32/stm32f303ze", "chrono", "not-gpdma"] -stm32f429zi = ["embassy-stm32/stm32f429zi", "chrono", "eth", "stop", "can", "not-gpdma", "dac-adc-pin", "rng"] -stm32f446re = ["embassy-stm32/stm32f446re", "chrono", "stop", "can", "not-gpdma", "dac-adc-pin", "sdmmc"] +stm32f429zi = ["embassy-stm32/stm32f429zi", "chrono", "eth", "stop", "can", "not-gpdma", "dac", "rng"] +stm32f446re = ["embassy-stm32/stm32f446re", "chrono", "stop", "can", "not-gpdma", "dac", "sdmmc"] stm32f767zi = ["embassy-stm32/stm32f767zi", "chrono", "not-gpdma", "eth", "rng"] -stm32g071rb = ["embassy-stm32/stm32g071rb", "cm0", "not-gpdma", "dac-adc-pin"] +stm32g071rb = ["embassy-stm32/stm32g071rb", "cm0", "not-gpdma", "dac"] stm32g491re = ["embassy-stm32/stm32g491re", "chrono", "stop", "not-gpdma", "rng"] stm32h563zi = ["embassy-stm32/stm32h563zi", "chrono", "eth", "rng"] stm32h753zi = ["embassy-stm32/stm32h753zi", "chrono", "not-gpdma", "eth", "rng"] -stm32h755zi = ["embassy-stm32/stm32h755zi-cm7", "chrono", "not-gpdma", "eth", "dac-adc-pin", "rng"] +stm32h755zi = ["embassy-stm32/stm32h755zi-cm7", "chrono", "not-gpdma", "eth", "dac", "rng"] stm32h7a3zi = ["embassy-stm32/stm32h7a3zi", "not-gpdma", "rng"] stm32l073rz = ["embassy-stm32/stm32l073rz", "cm0", "not-gpdma", "rng"] stm32l152re = ["embassy-stm32/stm32l152re", "chrono", "not-gpdma"] @@ -41,7 +41,7 @@ ble = ["dep:embassy-stm32-wpan", "embassy-stm32-wpan/ble"] mac = ["dep:embassy-stm32-wpan", "embassy-stm32-wpan/mac"] embassy-stm32-wpan = [] not-gpdma = [] -dac-adc-pin = [] +dac = [] cm0 = ["portable-atomic/unsafe-assume-single-core"] @@ -84,7 +84,12 @@ required-features = [ "can",] [[bin]] name = "dac" path = "src/bin/dac.rs" -required-features = [ "dac-adc-pin",] +required-features = [ "dac",] + +[[bin]] +name = "dac_l1" +path = "src/bin/dac_l1.rs" +required-features = [ "stm32l152re",] [[bin]] name = "eth" diff --git a/tests/stm32/src/bin/dac.rs b/tests/stm32/src/bin/dac.rs index cf43106b..9d64742d 100644 --- a/tests/stm32/src/bin/dac.rs +++ b/tests/stm32/src/bin/dac.rs @@ -1,7 +1,7 @@ #![no_std] #![no_main] -// required-features: dac-adc-pin +// required-features: dac #[path = "../common.rs"] mod common; @@ -22,12 +22,13 @@ async fn main(_spawner: Spawner) { // Initialize the board and obtain a Peripherals instance let p: embassy_stm32::Peripherals = embassy_stm32::init(config()); + let adc = peri!(p, ADC); let dac = peri!(p, DAC); let dac_pin = peri!(p, DAC_PIN); let mut adc_pin = unsafe { core::ptr::read(&dac_pin) }; let mut dac = DacCh1::new(dac, NoDma, dac_pin); - let mut adc = Adc::new(p.ADC1, &mut Delay); + let mut adc = Adc::new(adc, &mut Delay); #[cfg(feature = "stm32h755zi")] let normalization_factor = 256; diff --git a/tests/stm32/src/bin/dac_l1.rs b/tests/stm32/src/bin/dac_l1.rs new file mode 100644 index 00000000..f8b00aae --- /dev/null +++ b/tests/stm32/src/bin/dac_l1.rs @@ -0,0 +1,86 @@ +#![no_std] +#![no_main] + +// required-features: stm32l152re + +#[path = "../common.rs"] +mod common; +use core::f32::consts::PI; + +use common::*; +use defmt::assert; +use embassy_executor::Spawner; +use embassy_stm32::adc::Adc; +use embassy_stm32::dac::{DacCh1, Value}; +use embassy_stm32::dma::NoDma; +use embassy_stm32::{bind_interrupts, peripherals}; +use embassy_time::Timer; +use micromath::F32Ext; +use {defmt_rtt as _, panic_probe as _}; + +bind_interrupts!(struct Irqs { + ADC1 => embassy_stm32::adc::InterruptHandler; +}); + +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + // Initialize the board and obtain a Peripherals instance + let p: embassy_stm32::Peripherals = embassy_stm32::init(config()); + + let adc = peri!(p, ADC); + let dac = peri!(p, DAC); + let dac_pin = peri!(p, DAC_PIN); + let mut adc_pin = unsafe { core::ptr::read(&dac_pin) }; + + let mut dac = DacCh1::new(dac, NoDma, dac_pin); + let mut adc = Adc::new(adc, Irqs); + + #[cfg(feature = "stm32h755zi")] + let normalization_factor = 256; + #[cfg(any( + feature = "stm32f429zi", + feature = "stm32f446re", + feature = "stm32g071rb", + feature = "stm32l152re", + ))] + let normalization_factor: i32 = 16; + + dac.set(Value::Bit8(0)); + // Now wait a little to obtain a stable value + Timer::after_millis(30).await; + let offset = adc.read(&mut adc_pin).await; + + for v in 0..=255 { + // First set the DAC output value + let dac_output_val = to_sine_wave(v); + dac.set(Value::Bit8(dac_output_val)); + + // Now wait a little to obtain a stable value + Timer::after_millis(30).await; + + // Need to steal the peripherals here because PA4 is obviously in use already + let measured = adc.read(&mut unsafe { embassy_stm32::Peripherals::steal() }.PA4).await; + // Calibrate and normalize the measurement to get close to the dac_output_val + let measured_normalized = ((measured as i32 - offset as i32) / normalization_factor) as i16; + + info!("value / measured: {} / {}", dac_output_val, measured_normalized); + + // The deviations are quite enormous but that does not matter since this is only a quick test + assert!((dac_output_val as i16 - measured_normalized).abs() < 15); + } + + info!("Test OK"); + cortex_m::asm::bkpt(); +} + +fn to_sine_wave(v: u8) -> u8 { + if v >= 128 { + // top half + let r = PI * ((v - 128) as f32 / 128.0); + (r.sin() * 128.0 + 127.0) as u8 + } else { + // bottom half + let r = PI + PI * (v as f32 / 128.0); + (r.sin() * 128.0 + 127.0) as u8 + } +} diff --git a/tests/stm32/src/common.rs b/tests/stm32/src/common.rs index 155e1d9d..313380b3 100644 --- a/tests/stm32/src/common.rs +++ b/tests/stm32/src/common.rs @@ -101,14 +101,14 @@ define_peris!( define_peris!( UART = USART1, UART_TX = PC4, UART_RX = PC5, UART_TX_DMA = DMA1_CH1, UART_RX_DMA = DMA1_CH2, SPI = SPI1, SPI_SCK = PA5, SPI_MOSI = PA7, SPI_MISO = PA6, SPI_TX_DMA = DMA1_CH1, SPI_RX_DMA = DMA1_CH2, - DAC = DAC1, DAC_PIN = PA4, + ADC = ADC1, DAC = DAC1, DAC_PIN = PA4, @irq UART = {USART1 => embassy_stm32::usart::InterruptHandler;}, ); #[cfg(feature = "stm32f429zi")] define_peris!( UART = USART6, UART_TX = PG14, UART_RX = PG9, UART_TX_DMA = DMA2_CH6, UART_RX_DMA = DMA2_CH1, SPI = SPI1, SPI_SCK = PA5, SPI_MOSI = PA7, SPI_MISO = PA6, SPI_TX_DMA = DMA2_CH3, SPI_RX_DMA = DMA2_CH2, - DAC = DAC, DAC_PIN = PA4, + ADC = ADC1, DAC = DAC, DAC_PIN = PA4, CAN = CAN1, CAN_RX = PD0, CAN_TX = PD1, @irq UART = {USART6 => embassy_stm32::usart::InterruptHandler;}, ); @@ -116,7 +116,7 @@ define_peris!( define_peris!( UART = USART1, UART_TX = PA9, UART_RX = PA10, UART_TX_DMA = DMA2_CH7, UART_RX_DMA = DMA2_CH5, SPI = SPI1, SPI_SCK = PA5, SPI_MOSI = PA7, SPI_MISO = PA6, SPI_TX_DMA = DMA2_CH3, SPI_RX_DMA = DMA2_CH2, - DAC = DAC, DAC_PIN = PA4, + ADC = ADC1, DAC = DAC, DAC_PIN = PA4, CAN = CAN1, CAN_RX = PA11, CAN_TX = PA12, @irq UART = {USART1 => embassy_stm32::usart::InterruptHandler;}, ); @@ -130,7 +130,7 @@ define_peris!( define_peris!( UART = USART1, UART_TX = PB6, UART_RX = PB7, UART_TX_DMA = DMA1_CH0, UART_RX_DMA = DMA1_CH1, SPI = SPI1, SPI_SCK = PA5, SPI_MOSI = PB5, SPI_MISO = PA6, SPI_TX_DMA = DMA1_CH0, SPI_RX_DMA = DMA1_CH1, - DAC = DAC1, DAC_PIN = PA4, + ADC = ADC1, DAC = DAC1, DAC_PIN = PA4, @irq UART = {USART1 => embassy_stm32::usart::InterruptHandler;}, ); #[cfg(feature = "stm32h7a3zi")] @@ -191,6 +191,7 @@ define_peris!( define_peris!( UART = USART3, UART_TX = PB10, UART_RX = PB11, UART_TX_DMA = DMA1_CH2, UART_RX_DMA = DMA1_CH3, SPI = SPI1, SPI_SCK = PA5, SPI_MOSI = PA7, SPI_MISO = PA6, SPI_TX_DMA = DMA1_CH3, SPI_RX_DMA = DMA1_CH2, + ADC = ADC, DAC = DAC, DAC_PIN = PA4, @irq UART = {USART3 => embassy_stm32::usart::InterruptHandler;}, ); #[cfg(feature = "stm32l552ze")] From 6c746dcf3944fdd2901697c2bab107033458e22c Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 8 Dec 2023 21:26:28 +0100 Subject: [PATCH 55/98] Document how to bind multiple interrupts and handlers in `bind_interrupts!`. --- embassy-nrf/src/lib.rs | 22 ++++++++++++++++++++++ embassy-rp/src/lib.rs | 11 +++++++++++ embassy-stm32/src/lib.rs | 23 +++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs index 3274dafb..9093ad91 100644 --- a/embassy-nrf/src/lib.rs +++ b/embassy-nrf/src/lib.rs @@ -97,6 +97,28 @@ mod chip; /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) /// and implements the right [`Binding`]s for it. You can pass this struct to drivers to /// prove at compile-time that the right interrupts have been bound. +/// +/// Example of how to bind one interrupt: +/// +/// ```rust,ignore +/// use embassy_nrf::{bind_interrupts, spim, peripherals}; +/// +/// bind_interrupts!(struct Irqs { +/// SPIM3 => spim::InterruptHandler; +/// }); +/// ``` +/// +/// Example of how to bind multiple interrupts in a single macro invocation: +/// +/// ```rust,ignore +/// use embassy_nrf::{bind_interrupts, spim, twim, peripherals}; +/// +/// bind_interrupts!(struct Irqs { +/// SPIM3 => spim::InterruptHandler; +/// SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0 => twim::InterruptHandler; +/// }); +/// ``` + // developer note: this macro can't be in `embassy-hal-internal` due to the use of `$crate`. #[macro_export] macro_rules! bind_interrupts { diff --git a/embassy-rp/src/lib.rs b/embassy-rp/src/lib.rs index 66e4cfdc..5151323a 100644 --- a/embassy-rp/src/lib.rs +++ b/embassy-rp/src/lib.rs @@ -86,6 +86,17 @@ embassy_hal_internal::interrupt_mod!( /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) /// and implements the right [`Binding`]s for it. You can pass this struct to drivers to /// prove at compile-time that the right interrupts have been bound. +/// +/// Example of how to bind one interrupt: +/// +/// ```rust,ignore +/// use embassy_rp::{bind_interrupts, usb, peripherals}; +/// +/// bind_interrupts!(struct Irqs { +/// USBCTRL_IRQ => usb::InterruptHandler; +/// }); +/// ``` +/// // developer note: this macro can't be in `embassy-hal-internal` due to the use of `$crate`. #[macro_export] macro_rules! bind_interrupts { diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 13e189da..5d9b4e6a 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs @@ -90,6 +90,29 @@ pub use crate::_generated::interrupt; /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) /// and implements the right [`Binding`]s for it. You can pass this struct to drivers to /// prove at compile-time that the right interrupts have been bound. +/// +/// Example of how to bind one interrupt: +/// +/// ```rust,ignore +/// use embassy_stm32::{bind_interrupts, usb_otg, peripherals}; +/// +/// bind_interrupts!(struct Irqs { +/// OTG_FS => usb_otg::InterruptHandler; +/// }); +/// ``` +/// +/// Example of how to bind multiple interrupts, and multiple handlers to each interrupt, in a single macro invocation: +/// +/// ```rust,ignore +/// use embassy_stm32::{bind_interrupts, i2c, peripherals}; +/// +/// bind_interrupts!(struct Irqs { +/// I2C1 => i2c::EventInterruptHandler, i2c::ErrorInterruptHandler; +/// I2C2_3 => i2c::EventInterruptHandler, i2c::ErrorInterruptHandler, +/// i2c::EventInterruptHandler, i2c::ErrorInterruptHandler; +/// }); +/// ``` + // developer note: this macro can't be in `embassy-hal-internal` due to the use of `$crate`. #[macro_export] macro_rules! bind_interrupts { From 02b7a833d9855bd1db9665b8e9f311f0db93c156 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Fri, 8 Dec 2023 20:42:52 +0100 Subject: [PATCH 56/98] docs: document all public apis of embedded-hal-internal * Make some fields and functions non-public where possible. * Enable doc warnings for missing public API docs. --- embassy-hal-internal/src/atomic_ring_buffer.rs | 14 +++++++++++++- embassy-hal-internal/src/drop.rs | 7 ++++++- embassy-hal-internal/src/lib.rs | 1 + embassy-hal-internal/src/macros.rs | 5 +++++ embassy-hal-internal/src/peripheral.rs | 1 + embassy-hal-internal/src/ratio.rs | 1 + 6 files changed, 27 insertions(+), 2 deletions(-) diff --git a/embassy-hal-internal/src/atomic_ring_buffer.rs b/embassy-hal-internal/src/atomic_ring_buffer.rs index ea84925c..b4f2cec2 100644 --- a/embassy-hal-internal/src/atomic_ring_buffer.rs +++ b/embassy-hal-internal/src/atomic_ring_buffer.rs @@ -1,3 +1,4 @@ +//! Atomic reusable ringbuffer. use core::slice; use core::sync::atomic::{AtomicPtr, AtomicUsize, Ordering}; @@ -14,8 +15,9 @@ use core::sync::atomic::{AtomicPtr, AtomicUsize, Ordering}; /// One concurrent writer and one concurrent reader are supported, even at /// different execution priorities (like main and irq). pub struct RingBuffer { + #[doc(hidden)] pub buf: AtomicPtr, - pub len: AtomicUsize, + len: AtomicUsize, // start and end wrap at len*2, not at len. // This allows distinguishing "full" and "empty". @@ -24,11 +26,16 @@ pub struct RingBuffer { // // This avoids having to consider the ringbuffer "full" at len-1 instead of len. // The usual solution is adding a "full" flag, but that can't be made atomic + #[doc(hidden)] pub start: AtomicUsize, + #[doc(hidden)] pub end: AtomicUsize, } +/// A type which can only read from a ring buffer. pub struct Reader<'a>(&'a RingBuffer); + +/// A type which can only write to a ring buffer. pub struct Writer<'a>(&'a RingBuffer); impl RingBuffer { @@ -89,10 +96,12 @@ impl RingBuffer { Writer(self) } + /// Return length of buffer. pub fn len(&self) -> usize { self.len.load(Ordering::Relaxed) } + /// Check if buffer is full. pub fn is_full(&self) -> bool { let len = self.len.load(Ordering::Relaxed); let start = self.start.load(Ordering::Relaxed); @@ -101,6 +110,7 @@ impl RingBuffer { self.wrap(start + len) == end } + /// Check if buffer is empty. pub fn is_empty(&self) -> bool { let start = self.start.load(Ordering::Relaxed); let end = self.end.load(Ordering::Relaxed); @@ -238,6 +248,7 @@ impl<'a> Writer<'a> { [(unsafe { buf.add(end) }, n0), (buf, n1)] } + /// Mark n bytes as written and advance the write index. pub fn push_done(&mut self, n: usize) { trace!(" ringbuf: push {:?}", n); let end = self.0.end.load(Ordering::Relaxed); @@ -323,6 +334,7 @@ impl<'a> Reader<'a> { (unsafe { buf.add(start) }, n) } + /// Mark n bytes as read and allow advance the read index. pub fn pop_done(&mut self, n: usize) { trace!(" ringbuf: pop {:?}", n); diff --git a/embassy-hal-internal/src/drop.rs b/embassy-hal-internal/src/drop.rs index 7cd16aae..8383fcc1 100644 --- a/embassy-hal-internal/src/drop.rs +++ b/embassy-hal-internal/src/drop.rs @@ -1,16 +1,20 @@ +//! Types for controlling when drop is invoked. use core::mem; use core::mem::MaybeUninit; -#[must_use = "to delay the drop handler invokation to the end of the scope"] +/// A type to delay the drop handler invocation. +#[must_use = "to delay the drop handler invocation to the end of the scope"] pub struct OnDrop { f: MaybeUninit, } impl OnDrop { + /// Create a new instance. pub fn new(f: F) -> Self { Self { f: MaybeUninit::new(f) } } + /// Prevent drop handler from running. pub fn defuse(self) { mem::forget(self) } @@ -34,6 +38,7 @@ pub struct DropBomb { } impl DropBomb { + /// Create a new instance. pub fn new() -> Self { Self { _private: () } } diff --git a/embassy-hal-internal/src/lib.rs b/embassy-hal-internal/src/lib.rs index f3d59e58..89f20e99 100644 --- a/embassy-hal-internal/src/lib.rs +++ b/embassy-hal-internal/src/lib.rs @@ -1,6 +1,7 @@ #![no_std] #![allow(clippy::new_without_default)] #![doc = include_str!("../README.md")] +#![warn(missing_docs)] // This mod MUST go first, so that the others see its macros. pub(crate) mod fmt; diff --git a/embassy-hal-internal/src/macros.rs b/embassy-hal-internal/src/macros.rs index 97df3895..07cd8948 100644 --- a/embassy-hal-internal/src/macros.rs +++ b/embassy-hal-internal/src/macros.rs @@ -1,3 +1,4 @@ +/// Types for the peripheral singletons. #[macro_export] macro_rules! peripherals_definition { ($($(#[$cfg:meta])? $name:ident),*$(,)?) => { @@ -29,6 +30,7 @@ macro_rules! peripherals_definition { }; } +/// Define the peripherals struct. #[macro_export] macro_rules! peripherals_struct { ($($(#[$cfg:meta])? $name:ident),*$(,)?) => { @@ -87,6 +89,7 @@ macro_rules! peripherals_struct { }; } +/// Defining peripheral type. #[macro_export] macro_rules! peripherals { ($($(#[$cfg:meta])? $name:ident),*$(,)?) => { @@ -105,6 +108,7 @@ macro_rules! peripherals { }; } +/// Convenience converting into reference. #[macro_export] macro_rules! into_ref { ($($name:ident),*) => { @@ -114,6 +118,7 @@ macro_rules! into_ref { } } +/// Implement the peripheral trait. #[macro_export] macro_rules! impl_peripheral { ($type:ident) => { diff --git a/embassy-hal-internal/src/peripheral.rs b/embassy-hal-internal/src/peripheral.rs index 38b4c452..16d49edf 100644 --- a/embassy-hal-internal/src/peripheral.rs +++ b/embassy-hal-internal/src/peripheral.rs @@ -20,6 +20,7 @@ pub struct PeripheralRef<'a, T> { } impl<'a, T> PeripheralRef<'a, T> { + /// Create a new reference to a peripheral. #[inline] pub fn new(inner: T) -> Self { Self { diff --git a/embassy-hal-internal/src/ratio.rs b/embassy-hal-internal/src/ratio.rs index 9a8808a3..91dcfd47 100644 --- a/embassy-hal-internal/src/ratio.rs +++ b/embassy-hal-internal/src/ratio.rs @@ -1,3 +1,4 @@ +//! Types for dealing with rational numbers. use core::ops::{Add, Div, Mul}; use num_traits::{CheckedAdd, CheckedDiv, CheckedMul}; From 4d3fcd8d2d841dc4bce9f2f3308e9e9929a1330a Mon Sep 17 00:00:00 2001 From: Kaitlyn Kenwell Date: Fri, 8 Dec 2023 17:06:37 -0500 Subject: [PATCH 57/98] Assert CR2.USV on stm32wb55, wb35 series chips ref RM0434 p. 175 --- embassy-stm32/src/usb/usb.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embassy-stm32/src/usb/usb.rs b/embassy-stm32/src/usb/usb.rs index 9269ddd8..8b9a47f3 100644 --- a/embassy-stm32/src/usb/usb.rs +++ b/embassy-stm32/src/usb/usb.rs @@ -263,7 +263,7 @@ impl<'d, T: Instance> Driver<'d, T> { let regs = T::regs(); - #[cfg(stm32l5)] + #[cfg(any(stm32l5, stm32wb55, stm32wb35))] crate::pac::PWR.cr2().modify(|w| w.set_usv(true)); #[cfg(pwr_h5)] From 5973e69244e6b4a6f19af84bc004a139cf3f7688 Mon Sep 17 00:00:00 2001 From: Kaitlyn Kenwell Date: Fri, 8 Dec 2023 17:20:23 -0500 Subject: [PATCH 58/98] Conditionally compile line for all stm32wb chips --- embassy-stm32/src/usb/usb.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embassy-stm32/src/usb/usb.rs b/embassy-stm32/src/usb/usb.rs index 8b9a47f3..295dc919 100644 --- a/embassy-stm32/src/usb/usb.rs +++ b/embassy-stm32/src/usb/usb.rs @@ -263,7 +263,7 @@ impl<'d, T: Instance> Driver<'d, T> { let regs = T::regs(); - #[cfg(any(stm32l5, stm32wb55, stm32wb35))] + #[cfg(any(stm32l5, stm32wb))] crate::pac::PWR.cr2().modify(|w| w.set_usv(true)); #[cfg(pwr_h5)] From 4051aead0f50952d8b10242c00531e21f5b901f8 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 8 Dec 2023 23:29:48 +0100 Subject: [PATCH 59/98] stm32: update stm32-metapac. Fixes USB on STM32WB. --- embassy-stm32/Cargo.toml | 4 ++-- embassy-stm32/src/rcc/g4.rs | 1 + embassy-stm32/src/rcc/mod.rs | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 979d15c0..f8c4313e 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -58,7 +58,7 @@ rand_core = "0.6.3" sdio-host = "0.5.0" embedded-sdmmc = { git = "https://github.com/embassy-rs/embedded-sdmmc-rs", rev = "a4f293d3a6f72158385f79c98634cb8a14d0d2fc", optional = true } critical-section = "1.1" -stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-019a5da1c47c092c199bc39a7f84fb444f2adcdf" } +stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-8f5fcae8c289c1ad481cc3a2bb37db023a61599c" } vcell = "0.1.3" bxcan = "0.7.0" nb = "1.0.0" @@ -76,7 +76,7 @@ critical-section = { version = "1.1", features = ["std"] } [build-dependencies] proc-macro2 = "1.0.36" quote = "1.0.15" -stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-019a5da1c47c092c199bc39a7f84fb444f2adcdf", default-features = false, features = ["metadata"]} +stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-8f5fcae8c289c1ad481cc3a2bb37db023a61599c", default-features = false, features = ["metadata"]} [features] diff --git a/embassy-stm32/src/rcc/g4.rs b/embassy-stm32/src/rcc/g4.rs index 7af05b48..fca364c2 100644 --- a/embassy-stm32/src/rcc/g4.rs +++ b/embassy-stm32/src/rcc/g4.rs @@ -308,6 +308,7 @@ pub(crate) unsafe fn init(config: Config) { sys: sys_clk, hclk1: ahb_freq, hclk2: ahb_freq, + hclk3: ahb_freq, pclk1: apb1_freq, pclk1_tim: apb1_tim_freq, pclk2: apb2_freq, diff --git a/embassy-stm32/src/rcc/mod.rs b/embassy-stm32/src/rcc/mod.rs index 40a5a619..dc829a9a 100644 --- a/embassy-stm32/src/rcc/mod.rs +++ b/embassy-stm32/src/rcc/mod.rs @@ -95,6 +95,7 @@ pub struct Clocks { rcc_h7rm0433, rcc_h7ab, rcc_u5, + rcc_g4, rcc_wb, rcc_wl5, rcc_wle From 78f709a3621a50b434206a6200ae18ce7f5a0194 Mon Sep 17 00:00:00 2001 From: Carlos Barrales Ruiz Date: Sat, 9 Dec 2023 14:14:34 +0100 Subject: [PATCH 60/98] * Add GP TIM9 and TIM11 to be used as time_driver --- embassy-stm32/Cargo.toml | 4 ++++ embassy-stm32/build.rs | 8 +++++++- embassy-stm32/src/time_driver.rs | 21 ++++++++++++++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index f8c4313e..074538d3 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -120,6 +120,10 @@ time-driver-tim3 = ["_time-driver"] time-driver-tim4 = ["_time-driver"] ## Use TIM5 as time driver time-driver-tim5 = ["_time-driver"] +## Use TIM9 as time driver +time-driver-tim9 = ["_time-driver"] +## Use TIM11 as time driver +time-driver-tim11 = ["_time-driver"] ## Use TIM12 as time driver time-driver-tim12 = ["_time-driver"] ## Use TIM15 as time driver diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 0eef43ac..bb60d244 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs @@ -187,6 +187,8 @@ fn main() { Some("tim3") => "TIM3", Some("tim4") => "TIM4", Some("tim5") => "TIM5", + Some("tim9") => "TIM9", + Some("tim11") => "TIM11", Some("tim12") => "TIM12", Some("tim15") => "TIM15", Some("any") => { @@ -198,12 +200,16 @@ fn main() { "TIM4" } else if singletons.contains(&"TIM5".to_string()) { "TIM5" + } else if singletons.contains(&"TIM9".to_string()) { + "TIM9" + } else if singletons.contains(&"TIM11".to_string()) { + "TIM11" } else if singletons.contains(&"TIM12".to_string()) { "TIM12" } else if singletons.contains(&"TIM15".to_string()) { "TIM15" } else { - panic!("time-driver-any requested, but the chip doesn't have TIM2, TIM3, TIM4, TIM5, TIM12 or TIM15.") + panic!("time-driver-any requested, but the chip doesn't have TIM2, TIM3, TIM4, TIM5, TIM9, TIM11, TIM12 or TIM15.") } } _ => panic!("unknown time_driver {:?}", time_driver), diff --git a/embassy-stm32/src/time_driver.rs b/embassy-stm32/src/time_driver.rs index e2a4cc4d..ea9c22d8 100644 --- a/embassy-stm32/src/time_driver.rs +++ b/embassy-stm32/src/time_driver.rs @@ -43,7 +43,10 @@ type T = peripherals::TIM3; type T = peripherals::TIM4; #[cfg(time_driver_tim5)] type T = peripherals::TIM5; - +#[cfg(time_driver_tim9)] +type T = peripherals::TIM9; +#[cfg(time_driver_tim11)] +type T = peripherals::TIM11; #[cfg(time_driver_tim12)] type T = peripherals::TIM12; #[cfg(time_driver_tim15)] @@ -82,6 +85,22 @@ foreach_interrupt! { DRIVER.on_interrupt() } }; + (TIM9, timer, $block:ident, UP, $irq:ident) => { + #[cfg(time_driver_tim9)] + #[cfg(feature = "rt")] + #[interrupt] + fn $irq() { + DRIVER.on_interrupt() + } + }; + (TIM11, timer, $block:ident, UP, $irq:ident) => { + #[cfg(time_driver_tim11)] + #[cfg(feature = "rt")] + #[interrupt] + fn $irq() { + DRIVER.on_interrupt() + } + }; (TIM12, timer, $block:ident, UP, $irq:ident) => { #[cfg(time_driver_tim12)] #[cfg(feature = "rt")] From dfba51d3f2a4d6866f6d6de98fde9a620cda20b7 Mon Sep 17 00:00:00 2001 From: lights0123 Date: Sun, 10 Dec 2023 18:39:45 -0500 Subject: [PATCH 61/98] stm32: usart pin inversion --- embassy-stm32/src/usart/mod.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index d5828a49..dfa1f3a6 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs @@ -132,6 +132,14 @@ pub struct Config { /// Set this to true to swap the RX and TX pins. #[cfg(any(usart_v3, usart_v4))] pub swap_rx_tx: bool, + + /// Set this to true to invert TX pin signal values (VDD =0/mark, Gnd = 1/idle). + #[cfg(any(usart_v3, usart_v4))] + pub invert_tx: bool, + + /// Set this to true to invert RX pin signal values (VDD =0/mark, Gnd = 1/idle). + #[cfg(any(usart_v3, usart_v4))] + pub invert_rx: bool, } impl Default for Config { @@ -147,6 +155,10 @@ impl Default for Config { assume_noise_free: false, #[cfg(any(usart_v3, usart_v4))] swap_rx_tx: false, + #[cfg(any(usart_v3, usart_v4))] + invert_tx: false, + #[cfg(any(usart_v3, usart_v4))] + invert_rx: false, } } } @@ -972,7 +984,11 @@ fn configure( }); #[cfg(any(usart_v3, usart_v4))] - w.set_swap(config.swap_rx_tx); + { + w.set_txinv(config.invert_tx); + w.set_rxinv(config.invert_rx); + w.set_swap(config.swap_rx_tx); + } }); #[cfg(not(usart_v1))] From 13af76af88a82f6c0f453b66520f0ff83df09c2d Mon Sep 17 00:00:00 2001 From: Corey Schuhen Date: Mon, 11 Dec 2023 21:08:58 +1000 Subject: [PATCH 62/98] Add example for using CAN with STM32F103 (BluePill) with a real CAN --- examples/stm32f1/src/bin/can.rs | 79 +++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 examples/stm32f1/src/bin/can.rs diff --git a/examples/stm32f1/src/bin/can.rs b/examples/stm32f1/src/bin/can.rs new file mode 100644 index 00000000..abe60b35 --- /dev/null +++ b/examples/stm32f1/src/bin/can.rs @@ -0,0 +1,79 @@ +#![no_std] +#![no_main] +#![feature(type_alias_impl_trait)] + +use defmt::*; +use embassy_executor::Spawner; +use embassy_stm32::bind_interrupts; +use embassy_stm32::can::bxcan::filter::Mask32; +use embassy_stm32::can::bxcan::{Fifo, Frame, StandardId, Id}; +use embassy_stm32::can::{Can, Rx0InterruptHandler, Rx1InterruptHandler, SceInterruptHandler, TxInterruptHandler}; +use embassy_stm32::Config; + +use embassy_stm32::peripherals::CAN; +use {defmt_rtt as _, panic_probe as _}; + +bind_interrupts!(struct Irqs { + USB_LP_CAN1_RX0 => Rx0InterruptHandler; + CAN1_RX1 => Rx1InterruptHandler; + CAN1_SCE => SceInterruptHandler; + USB_HP_CAN1_TX => TxInterruptHandler; +}); + +// This example is configured to work with real CAN transceivers on B8/B9. +// See other examples for loopback. + + +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + + let p = embassy_stm32::init(Config::default()); + + // Set alternate pin mapping to B8/B9 + embassy_stm32::pac::AFIO.mapr().modify(|w| w.set_can1_remap(2)); + + let mut can = Can::new(p.CAN, p.PB8, p.PB9, Irqs); + + + can.as_mut() + .modify_filters() + .enable_bank(0, Fifo::Fifo0, Mask32::accept_all()); + + can.as_mut() + .modify_config() + .set_loopback(false) + .set_silent(false) + .leave_disabled(); + + + can.set_bitrate(250_000); + + can.enable().await; + + + let mut i: u8 = 0; + loop { + let tx_frame = Frame::new_data(unwrap!(StandardId::new(i as _)), [i]); + can.write(&tx_frame).await; + + match can.read().await { + Ok(env) => { + + match env.frame.id() { + Id::Extended(id) => { + defmt::println!("Extended Frame id={:x}", id.as_raw()); + }, + Id::Standard(id) => { + defmt::println!("Standard Frame id={:x}", id.as_raw()); + }, + } + + }, + Err(err) => { + defmt::println!("Error {}", err); + + } + } + i += 1; + } +} From b34c8e3eb1f3adab3e28c3b0b8ae3ab4c339c33b Mon Sep 17 00:00:00 2001 From: Corey Schuhen Date: Mon, 11 Dec 2023 21:25:05 +1000 Subject: [PATCH 63/98] Update formatting. --- examples/stm32f1/src/bin/can.rs | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/examples/stm32f1/src/bin/can.rs b/examples/stm32f1/src/bin/can.rs index abe60b35..625a3843 100644 --- a/examples/stm32f1/src/bin/can.rs +++ b/examples/stm32f1/src/bin/can.rs @@ -4,13 +4,12 @@ use defmt::*; use embassy_executor::Spawner; -use embassy_stm32::bind_interrupts; use embassy_stm32::can::bxcan::filter::Mask32; -use embassy_stm32::can::bxcan::{Fifo, Frame, StandardId, Id}; +use embassy_stm32::can::bxcan::{Fifo, Frame, Id, StandardId}; use embassy_stm32::can::{Can, Rx0InterruptHandler, Rx1InterruptHandler, SceInterruptHandler, TxInterruptHandler}; -use embassy_stm32::Config; use embassy_stm32::peripherals::CAN; +use embassy_stm32::{bind_interrupts, Config}; use {defmt_rtt as _, panic_probe as _}; bind_interrupts!(struct Irqs { @@ -23,10 +22,8 @@ bind_interrupts!(struct Irqs { // This example is configured to work with real CAN transceivers on B8/B9. // See other examples for loopback. - #[embassy_executor::main] async fn main(_spawner: Spawner) { - let p = embassy_stm32::init(Config::default()); // Set alternate pin mapping to B8/B9 @@ -34,7 +31,6 @@ async fn main(_spawner: Spawner) { let mut can = Can::new(p.CAN, p.PB8, p.PB9, Irqs); - can.as_mut() .modify_filters() .enable_bank(0, Fifo::Fifo0, Mask32::accept_all()); @@ -44,34 +40,27 @@ async fn main(_spawner: Spawner) { .set_loopback(false) .set_silent(false) .leave_disabled(); - can.set_bitrate(250_000); can.enable().await; - let mut i: u8 = 0; loop { let tx_frame = Frame::new_data(unwrap!(StandardId::new(i as _)), [i]); can.write(&tx_frame).await; match can.read().await { - Ok(env) => { - - match env.frame.id() { - Id::Extended(id) => { - defmt::println!("Extended Frame id={:x}", id.as_raw()); - }, - Id::Standard(id) => { - defmt::println!("Standard Frame id={:x}", id.as_raw()); - }, + Ok(env) => match env.frame.id() { + Id::Extended(id) => { + defmt::println!("Extended Frame id={:x}", id.as_raw()); + } + Id::Standard(id) => { + defmt::println!("Standard Frame id={:x}", id.as_raw()); } - }, Err(err) => { defmt::println!("Error {}", err); - } } i += 1; From 3626deecaab1ed5b2f2c97ef49f6dbf058ad068a Mon Sep 17 00:00:00 2001 From: Corey Schuhen Date: Mon, 11 Dec 2023 21:26:23 +1000 Subject: [PATCH 64/98] More formatting. --- examples/stm32f1/src/bin/can.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/stm32f1/src/bin/can.rs b/examples/stm32f1/src/bin/can.rs index 625a3843..a5ce819d 100644 --- a/examples/stm32f1/src/bin/can.rs +++ b/examples/stm32f1/src/bin/can.rs @@ -7,7 +7,6 @@ use embassy_executor::Spawner; use embassy_stm32::can::bxcan::filter::Mask32; use embassy_stm32::can::bxcan::{Fifo, Frame, Id, StandardId}; use embassy_stm32::can::{Can, Rx0InterruptHandler, Rx1InterruptHandler, SceInterruptHandler, TxInterruptHandler}; - use embassy_stm32::peripherals::CAN; use embassy_stm32::{bind_interrupts, Config}; use {defmt_rtt as _, panic_probe as _}; @@ -54,7 +53,7 @@ async fn main(_spawner: Spawner) { Ok(env) => match env.frame.id() { Id::Extended(id) => { defmt::println!("Extended Frame id={:x}", id.as_raw()); - } + } Id::Standard(id) => { defmt::println!("Standard Frame id={:x}", id.as_raw()); } From 6782fb1efa1bd4c5372220bb38539ea1e7ef6ffa Mon Sep 17 00:00:00 2001 From: Priit Laes Date: Wed, 13 Dec 2023 11:41:46 +0200 Subject: [PATCH 65/98] embassy-boot: Add explanation to dfu vs active size assertion --- embassy-boot/boot/src/boot_loader.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/embassy-boot/boot/src/boot_loader.rs b/embassy-boot/boot/src/boot_loader.rs index a8c19197..1663f4f2 100644 --- a/embassy-boot/boot/src/boot_loader.rs +++ b/embassy-boot/boot/src/boot_loader.rs @@ -224,6 +224,7 @@ impl BootLoader( ) { assert_eq!(active.capacity() as u32 % page_size, 0); assert_eq!(dfu.capacity() as u32 % page_size, 0); + // DFU partition has to be bigger than ACTIVE partition to handle swap algorithm assert!(dfu.capacity() as u32 - active.capacity() as u32 >= page_size); assert!(2 + 2 * (active.capacity() as u32 / page_size) <= state.capacity() as u32 / STATE::WRITE_SIZE as u32); } From d596a1091d25e89533d08a1f96678f1c1182dc40 Mon Sep 17 00:00:00 2001 From: djstrickland <96876452+dstric-aqueduct@users.noreply.github.com> Date: Wed, 13 Dec 2023 10:17:07 -0500 Subject: [PATCH 66/98] add `susependable` field to `embassy_usb::builder::Config` - allow for optional override of `Suspend` event for a UsbDevice --- embassy-usb/src/builder.rs | 10 ++++++++++ embassy-usb/src/lib.rs | 8 +++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/embassy-usb/src/builder.rs b/embassy-usb/src/builder.rs index c4705d04..ebc1283e 100644 --- a/embassy-usb/src/builder.rs +++ b/embassy-usb/src/builder.rs @@ -94,6 +94,15 @@ pub struct Config<'a> { /// Default: 100mA /// Max: 500mA pub max_power: u16, + + /// Allow the bus to be suspended. + /// + /// If set to `true`, the bus will put itself in the suspended state + /// when it receives a `driver::Event::Suspend` bus event. If you wish + /// to override this behavior, set this field to `false`. + /// + /// Default: `true` + pub suspendable: bool, } impl<'a> Config<'a> { @@ -114,6 +123,7 @@ impl<'a> Config<'a> { supports_remote_wakeup: false, composite_with_iads: false, max_power: 100, + suspendable: true, } } } diff --git a/embassy-usb/src/lib.rs b/embassy-usb/src/lib.rs index 241e33a7..ff329587 100644 --- a/embassy-usb/src/lib.rs +++ b/embassy-usb/src/lib.rs @@ -471,9 +471,11 @@ impl<'d, D: Driver<'d>> Inner<'d, D> { } Event::Suspend => { trace!("usb: suspend"); - self.suspended = true; - for h in &mut self.handlers { - h.suspended(true); + if self.config.suspendable { + self.suspended = true; + for h in &mut self.handlers { + h.suspended(true); + } } } Event::PowerDetected => { From 876faa5685de66ce422bc9196f2442195cdff63b Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Wed, 13 Dec 2023 19:00:26 +0100 Subject: [PATCH 67/98] docs: more docs in embassy-boot crate documentation --- docs/modules/ROOT/pages/bootloader.adoc | 4 +++- embassy-boot/boot/README.md | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/docs/modules/ROOT/pages/bootloader.adoc b/docs/modules/ROOT/pages/bootloader.adoc index b7215e52..3b0cdb18 100644 --- a/docs/modules/ROOT/pages/bootloader.adoc +++ b/docs/modules/ROOT/pages/bootloader.adoc @@ -45,6 +45,8 @@ The BOOTLOADER_STATE partition must be big enough to store one word per page in The bootloader has a platform-agnostic part, which implements the power fail safe swapping algorithm given the boundaries set by the partitions. The platform-specific part is a minimal shim that provides additional functionality such as watchdogs or supporting the nRF52 softdevice. +NOTE: The linker scripts for the application and bootloader look similar, but the FLASH region must point to the BOOTLOADER partition for the bootloader, and the ACTIVE partition for the application. + === FirmwareUpdater The `FirmwareUpdater` is an object for conveniently flashing firmware to the DFU partition and subsequently marking it as being ready for swapping with the active partition on the next reset. Its principle methods are `write_firmware`, which is called once per the size of the flash "write block" (typically 4KiB), and `mark_updated`, which is the final call. @@ -91,4 +93,4 @@ cp $FIRMWARE_DIR/myfirmware $FIRMWARE_DIR/myfirmware+signed tail -n1 $SECRETS_DIR/message.txt.sig | base64 -d -i - | dd ibs=10 skip=1 >> $FIRMWARE_DIR/myfirmware+signed ---- -Remember, guard the `$SECRETS_DIR/key.sec` key as compromising it means that another party can sign your firmware. \ No newline at end of file +Remember, guard the `$SECRETS_DIR/key.sec` key as compromising it means that another party can sign your firmware. diff --git a/embassy-boot/boot/README.md b/embassy-boot/boot/README.md index 07755bc6..3fc81f24 100644 --- a/embassy-boot/boot/README.md +++ b/embassy-boot/boot/README.md @@ -8,6 +8,24 @@ The bootloader can be used either as a library or be flashed directly with the d By design, the bootloader does not provide any network capabilities. Networking capabilities for fetching new firmware can be provided by the user application, using the bootloader as a library for updating the firmware, or by using the bootloader as a library and adding this capability yourself. +## Overview + +The bootloader divides the storage into 4 main partitions, configurable when creating the bootloader instance or via linker scripts: + +* BOOTLOADER - Where the bootloader is placed. The bootloader itself consumes about 8kB of flash, but if you need to debug it and have space available, increasing this to 24kB will allow you to run the bootloader with probe-rs. +* ACTIVE - Where the main application is placed. The bootloader will attempt to load the application at the start of this partition. The minimum size required for this partition is the size of your application. +* DFU - Where the application-to-be-swapped is placed. This partition is written to by the application. This partition must be at least 1 page bigger than the ACTIVE partition. +* BOOTLOADER STATE - Where the bootloader stores the current state describing if the active and dfu partitions need to be swapped. + +For any partition, the following preconditions are required: + +* Partitions must be aligned on the page size. +* Partitions must be a multiple of the page size. + +The linker scripts for the application and bootloader look similar, but the FLASH region must point to the BOOTLOADER partition for the bootloader, and the ACTIVE partition for the application. + +For more details on the bootloader, see [the documentation](https://embassy.dev/book/dev/bootloader.html). + ## Hardware support The bootloader supports different hardware in separate crates: @@ -16,6 +34,7 @@ The bootloader supports different hardware in separate crates: * `embassy-boot-rp` - for the RP2040 microcontrollers. * `embassy-boot-stm32` - for the STM32 microcontrollers. + ## Minimum supported Rust version (MSRV) `embassy-boot` is guaranteed to compile on the latest stable Rust version at the time of release. It might compile with older versions but that may change in any new patch release. From 976a7ae22aa222213861c12d515115aac87bd2e0 Mon Sep 17 00:00:00 2001 From: Kaitlyn Kenwell Date: Wed, 13 Dec 2023 14:40:49 -0500 Subject: [PATCH 68/98] Add embassy-usb-dfu --- embassy-boot/boot/src/boot_loader.rs | 4 +- .../boot/src/firmware_updater/asynch.rs | 13 +- .../boot/src/firmware_updater/blocking.rs | 17 +- embassy-boot/boot/src/lib.rs | 3 + embassy-boot/stm32/src/lib.rs | 9 +- embassy-usb-dfu/Cargo.toml | 31 +++ embassy-usb-dfu/src/application.rs | 114 ++++++++++ embassy-usb-dfu/src/bootloader.rs | 196 ++++++++++++++++++ embassy-usb-dfu/src/consts.rs | 96 +++++++++ embassy-usb-dfu/src/lib.rs | 16 ++ 10 files changed, 492 insertions(+), 7 deletions(-) create mode 100644 embassy-usb-dfu/Cargo.toml create mode 100644 embassy-usb-dfu/src/application.rs create mode 100644 embassy-usb-dfu/src/bootloader.rs create mode 100644 embassy-usb-dfu/src/consts.rs create mode 100644 embassy-usb-dfu/src/lib.rs diff --git a/embassy-boot/boot/src/boot_loader.rs b/embassy-boot/boot/src/boot_loader.rs index a8c19197..c0deca22 100644 --- a/embassy-boot/boot/src/boot_loader.rs +++ b/embassy-boot/boot/src/boot_loader.rs @@ -5,7 +5,7 @@ use embassy_sync::blocking_mutex::raw::NoopRawMutex; use embassy_sync::blocking_mutex::Mutex; use embedded_storage::nor_flash::{NorFlash, NorFlashError, NorFlashErrorKind}; -use crate::{State, BOOT_MAGIC, STATE_ERASE_VALUE, SWAP_MAGIC}; +use crate::{State, BOOT_MAGIC, STATE_ERASE_VALUE, SWAP_MAGIC, DFU_DETACH_MAGIC}; /// Errors returned by bootloader #[derive(PartialEq, Eq, Debug)] @@ -384,6 +384,8 @@ impl BootLoader FirmwareUpdater<'d, DFU, STATE> { self.state.mark_updated().await } + /// Mark to trigger USB DFU on next boot. + pub async fn mark_dfu(&mut self) -> Result<(), FirmwareUpdaterError> { + self.state.verify_booted().await?; + self.state.mark_dfu().await + } + /// Mark firmware boot successful and stop rollback on reset. pub async fn mark_booted(&mut self) -> Result<(), FirmwareUpdaterError> { self.state.mark_booted().await @@ -247,6 +253,11 @@ impl<'d, STATE: NorFlash> FirmwareState<'d, STATE> { self.set_magic(SWAP_MAGIC).await } + /// Mark to trigger USB DFU on next boot. + pub async fn mark_dfu(&mut self) -> Result<(), FirmwareUpdaterError> { + self.set_magic(DFU_DETACH_MAGIC).await + } + /// Mark firmware boot successful and stop rollback on reset. pub async fn mark_booted(&mut self) -> Result<(), FirmwareUpdaterError> { self.set_magic(BOOT_MAGIC).await diff --git a/embassy-boot/boot/src/firmware_updater/blocking.rs b/embassy-boot/boot/src/firmware_updater/blocking.rs index 76e4264a..b2a633d1 100644 --- a/embassy-boot/boot/src/firmware_updater/blocking.rs +++ b/embassy-boot/boot/src/firmware_updater/blocking.rs @@ -6,7 +6,7 @@ use embassy_sync::blocking_mutex::raw::NoopRawMutex; use embedded_storage::nor_flash::NorFlash; use super::FirmwareUpdaterConfig; -use crate::{FirmwareUpdaterError, State, BOOT_MAGIC, STATE_ERASE_VALUE, SWAP_MAGIC}; +use crate::{FirmwareUpdaterError, State, BOOT_MAGIC, STATE_ERASE_VALUE, SWAP_MAGIC, DFU_DETACH_MAGIC}; /// Blocking FirmwareUpdater is an application API for interacting with the BootLoader without the ability to /// 'mess up' the internal bootloader state @@ -168,6 +168,12 @@ impl<'d, DFU: NorFlash, STATE: NorFlash> BlockingFirmwareUpdater<'d, DFU, STATE> self.state.mark_updated() } + /// Mark to trigger USB DFU device on next boot. + pub fn mark_dfu(&mut self) -> Result<(), FirmwareUpdaterError> { + self.state.verify_booted()?; + self.state.mark_dfu() + } + /// Mark firmware boot successful and stop rollback on reset. pub fn mark_booted(&mut self) -> Result<(), FirmwareUpdaterError> { self.state.mark_booted() @@ -226,7 +232,7 @@ impl<'d, STATE: NorFlash> BlockingFirmwareState<'d, STATE> { // Make sure we are running a booted firmware to avoid reverting to a bad state. fn verify_booted(&mut self) -> Result<(), FirmwareUpdaterError> { - if self.get_state()? == State::Boot { + if self.get_state()? == State::Boot || self.get_state()? == State::DfuDetach { Ok(()) } else { Err(FirmwareUpdaterError::BadState) @@ -243,6 +249,8 @@ impl<'d, STATE: NorFlash> BlockingFirmwareState<'d, STATE> { if !self.aligned.iter().any(|&b| b != SWAP_MAGIC) { Ok(State::Swap) + } else if !self.aligned.iter().any(|&b| b != DFU_DETACH_MAGIC) { + Ok(State::DfuDetach) } else { Ok(State::Boot) } @@ -253,6 +261,11 @@ impl<'d, STATE: NorFlash> BlockingFirmwareState<'d, STATE> { self.set_magic(SWAP_MAGIC) } + /// Mark to trigger USB DFU on next boot. + pub fn mark_dfu(&mut self) -> Result<(), FirmwareUpdaterError> { + self.set_magic(DFU_DETACH_MAGIC) + } + /// Mark firmware boot successful and stop rollback on reset. pub fn mark_booted(&mut self) -> Result<(), FirmwareUpdaterError> { self.set_magic(BOOT_MAGIC) diff --git a/embassy-boot/boot/src/lib.rs b/embassy-boot/boot/src/lib.rs index 9e70a4dc..45199294 100644 --- a/embassy-boot/boot/src/lib.rs +++ b/embassy-boot/boot/src/lib.rs @@ -23,6 +23,7 @@ pub use firmware_updater::{ pub(crate) const BOOT_MAGIC: u8 = 0xD0; pub(crate) const SWAP_MAGIC: u8 = 0xF0; +pub(crate) const DFU_DETACH_MAGIC: u8 = 0xE0; /// The state of the bootloader after running prepare. #[derive(PartialEq, Eq, Debug)] @@ -32,6 +33,8 @@ pub enum State { Boot, /// Bootloader has swapped the active partition with the dfu partition and will attempt boot. Swap, + /// Application has received a DFU_DETACH request over USB, and is rebooting into the bootloader to apply a DFU. + DfuDetach, } /// Buffer aligned to 32 byte boundary, largest known alignment requirement for embassy-boot. diff --git a/embassy-boot/stm32/src/lib.rs b/embassy-boot/stm32/src/lib.rs index c418cb26..4b4091ac 100644 --- a/embassy-boot/stm32/src/lib.rs +++ b/embassy-boot/stm32/src/lib.rs @@ -10,7 +10,10 @@ pub use embassy_boot::{ use embedded_storage::nor_flash::NorFlash; /// A bootloader for STM32 devices. -pub struct BootLoader; +pub struct BootLoader { + /// The reported state of the bootloader after preparing for boot + pub state: State, +} impl BootLoader { /// Inspect the bootloader state and perform actions required before booting, such as swapping firmware @@ -19,8 +22,8 @@ impl BootLoader { ) -> Self { let mut aligned_buf = AlignedBuffer([0; BUFFER_SIZE]); let mut boot = embassy_boot::BootLoader::new(config); - boot.prepare_boot(aligned_buf.as_mut()).expect("Boot prepare error"); - Self + let state = boot.prepare_boot(aligned_buf.as_mut()).expect("Boot prepare error"); + Self { state } } /// Boots the application. diff --git a/embassy-usb-dfu/Cargo.toml b/embassy-usb-dfu/Cargo.toml new file mode 100644 index 00000000..62398afb --- /dev/null +++ b/embassy-usb-dfu/Cargo.toml @@ -0,0 +1,31 @@ +[package] +edition = "2021" +name = "embassy-usb-dfu" +version = "0.1.0" +description = "An implementation of the USB DFU 1.1 protocol, using embassy-boot" +license = "MIT OR Apache-2.0" +repository = "https://github.com/embassy-rs/embassy" +categories = [ + "embedded", + "no-std", + "asynchronous" +] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +bitflags = "2.4.1" +cortex-m = { version = "0.7.7", features = ["inline-asm"] } +defmt = { version = "0.3.5", optional = true } +embassy-boot = { version = "0.1.1", path = "../embassy-boot/boot" } +embassy-embedded-hal = { version = "0.1.0", path = "../embassy-embedded-hal" } +embassy-futures = { version = "0.1.1", path = "../embassy-futures" } +embassy-sync = { version = "0.5.0", path = "../embassy-sync" } +embassy-time = { version = "0.2.0", path = "../embassy-time" } +embassy-usb = { version = "0.1.0", path = "../embassy-usb", default-features = false } +embedded-storage = { version = "0.3.1" } + +[features] +bootloader = [] +application = [] +defmt = ["dep:defmt"] diff --git a/embassy-usb-dfu/src/application.rs b/embassy-usb-dfu/src/application.rs new file mode 100644 index 00000000..5a52a9fe --- /dev/null +++ b/embassy-usb-dfu/src/application.rs @@ -0,0 +1,114 @@ + +use embassy_boot::BlockingFirmwareUpdater; +use embassy_time::{Instant, Duration}; +use embassy_usb::{Handler, control::{RequestType, Recipient, OutResponse, InResponse}, Builder, driver::Driver}; +use embedded_storage::nor_flash::NorFlash; + +use crate::consts::{DfuAttributes, Request, Status, State, USB_CLASS_APPN_SPEC, APPN_SPEC_SUBCLASS_DFU, DESC_DFU_FUNCTIONAL, DFU_PROTOCOL_RT}; + +/// Internal state for the DFU class +pub struct Control<'d, DFU: NorFlash, STATE: NorFlash> { + updater: BlockingFirmwareUpdater<'d, DFU, STATE>, + attrs: DfuAttributes, + state: State, + timeout: Option, + detach_start: Option, +} + +impl<'d, DFU: NorFlash, STATE: NorFlash> Control<'d, DFU, STATE> { + pub fn new(updater: BlockingFirmwareUpdater<'d, DFU, STATE>, attrs: DfuAttributes) -> Self { + Control { updater, attrs, state: State::AppIdle, detach_start: None, timeout: None } + } +} + +impl<'d, DFU: NorFlash, STATE: NorFlash> Handler for Control<'d, DFU, STATE> { + fn reset(&mut self) { + if let Some(start) = self.detach_start { + let delta = Instant::now() - start; + let timeout = self.timeout.unwrap(); + #[cfg(feature = "defmt")] + defmt::info!("Received RESET with delta = {}, timeout = {}", delta.as_millis(), timeout.as_millis()); + if delta < timeout { + self.updater.mark_dfu().expect("Failed to mark DFU mode in bootloader"); + cortex_m::asm::dsb(); + cortex_m::peripheral::SCB::sys_reset(); + } + } + } + + fn control_out(&mut self, req: embassy_usb::control::Request, _: &[u8]) -> Option { + if (req.request_type, req.recipient) != (RequestType::Class, Recipient::Interface) { + return None; + } + + #[cfg(feature = "defmt")] + defmt::info!("Received request {}", req); + + match Request::try_from(req.request) { + Ok(Request::Detach) => { + #[cfg(feature = "defmt")] + defmt::info!("Received DETACH, awaiting USB reset"); + self.detach_start = Some(Instant::now()); + self.timeout = Some(Duration::from_millis(req.value as u64)); + self.state = State::AppDetach; + Some(OutResponse::Accepted) + } + _ => { + None + } + } + } + + fn control_in<'a>(&'a mut self, req: embassy_usb::control::Request, buf: &'a mut [u8]) -> Option> { + if (req.request_type, req.recipient) != (RequestType::Class, Recipient::Interface) { + return None; + } + + #[cfg(feature = "defmt")] + defmt::info!("Received request {}", req); + + match Request::try_from(req.request) { + Ok(Request::GetStatus) => { + buf[0..6].copy_from_slice(&[Status::Ok as u8, 0x32, 0x00, 0x00, self.state as u8, 0x00]); + Some(InResponse::Accepted(buf)) + } + _ => None + } + } +} + +/// An implementation of the USB DFU 1.1 runtime protocol +/// +/// This function will add a DFU interface descriptor to the provided Builder, and register the provided Control as a handler for the USB device. The USB builder can be used as normal once this is complete. +/// The handler is responsive to DFU GetStatus and Detach commands. +/// +/// Once a detach command, followed by a USB reset is received by the host, a magic number will be written into the bootloader state partition to indicate that +/// it should expose a DFU device, and a software reset will be issued. +/// +/// To apply USB DFU updates, the bootloader must be capable of recognizing the DFU magic and exposing a device to handle the full DFU transaction with the host. +pub fn usb_dfu<'d, D: Driver<'d>, DFU: NorFlash, STATE: NorFlash>(builder: &mut Builder<'d, D>, handler: &'d mut Control<'d, DFU, STATE>, timeout: Duration) { + #[cfg(feature = "defmt")] + defmt::info!("Application USB DFU initializing"); + let mut func = builder.function(0x00, 0x00, 0x00); + let mut iface = func.interface(); + let mut alt = iface.alt_setting( + USB_CLASS_APPN_SPEC, + APPN_SPEC_SUBCLASS_DFU, + DFU_PROTOCOL_RT, + None, + ); + let timeout = timeout.as_millis() as u16; + alt.descriptor( + DESC_DFU_FUNCTIONAL, + &[ + handler.attrs.bits(), + (timeout & 0xff) as u8, + ((timeout >> 8) & 0xff) as u8, + 0x40, 0x00, // 64B control buffer size for application side + 0x10, 0x01, // DFU 1.1 + ], + ); + + drop(func); + builder.handler(handler); +} \ No newline at end of file diff --git a/embassy-usb-dfu/src/bootloader.rs b/embassy-usb-dfu/src/bootloader.rs new file mode 100644 index 00000000..7bcb0b25 --- /dev/null +++ b/embassy-usb-dfu/src/bootloader.rs @@ -0,0 +1,196 @@ +use embassy_boot::BlockingFirmwareUpdater; +use embassy_usb::{ + control::{InResponse, OutResponse, Recipient, RequestType}, + driver::Driver, + Builder, Handler, +}; +use embedded_storage::nor_flash::{NorFlashErrorKind, NorFlash}; + +use crate::consts::{DfuAttributes, Request, State, Status, USB_CLASS_APPN_SPEC, APPN_SPEC_SUBCLASS_DFU, DFU_PROTOCOL_DFU, DESC_DFU_FUNCTIONAL}; + +/// Internal state for USB DFU +pub struct Control<'d, DFU: NorFlash, STATE: NorFlash, const BLOCK_SIZE: usize> { + updater: BlockingFirmwareUpdater<'d, DFU, STATE>, + attrs: DfuAttributes, + state: State, + status: Status, + offset: usize, +} + +impl<'d, DFU: NorFlash, STATE: NorFlash, const BLOCK_SIZE: usize> Control<'d, DFU, STATE, BLOCK_SIZE> { + pub fn new(updater: BlockingFirmwareUpdater<'d, DFU, STATE>, attrs: DfuAttributes) -> Self { + Self { + updater, + attrs, + state: State::DfuIdle, + status: Status::Ok, + offset: 0, + } + } + + fn reset_state(&mut self) { + self.offset = 0; + self.state = State::DfuIdle; + self.status = Status::Ok; + } +} + +impl<'d, DFU: NorFlash, STATE: NorFlash, const BLOCK_SIZE: usize> Handler for Control<'d, DFU, STATE, BLOCK_SIZE> { + fn control_out( + &mut self, + req: embassy_usb::control::Request, + data: &[u8], + ) -> Option { + if (req.request_type, req.recipient) != (RequestType::Class, Recipient::Interface) { + return None; + } + match Request::try_from(req.request) { + Ok(Request::Abort) => { + self.reset_state(); + Some(OutResponse::Accepted) + } + Ok(Request::Dnload) if self.attrs.contains(DfuAttributes::CAN_DOWNLOAD) => { + if req.value == 0 { + self.state = State::Download; + self.offset = 0; + } + + let mut buf = [0; BLOCK_SIZE]; + buf[..data.len()].copy_from_slice(data); + + if req.length == 0 { + match self.updater.mark_updated() { + Ok(_) => { + self.status = Status::Ok; + self.state = State::ManifestSync; + } + Err(e) => { + self.state = State::Error; + match e { + embassy_boot::FirmwareUpdaterError::Flash(e) => match e { + NorFlashErrorKind::NotAligned => self.status = Status::ErrWrite, + NorFlashErrorKind::OutOfBounds => { + self.status = Status::ErrAddress + } + _ => self.status = Status::ErrUnknown, + }, + embassy_boot::FirmwareUpdaterError::Signature(_) => { + self.status = Status::ErrVerify + } + embassy_boot::FirmwareUpdaterError::BadState => { + self.status = Status::ErrUnknown + } + } + } + } + } else { + if self.state != State::Download { + // Unexpected DNLOAD while chip is waiting for a GETSTATUS + self.status = Status::ErrUnknown; + self.state = State::Error; + return Some(OutResponse::Rejected); + } + match self.updater.write_firmware(self.offset, &buf[..]) { + Ok(_) => { + self.status = Status::Ok; + self.state = State::DlSync; + self.offset += data.len(); + } + Err(e) => { + self.state = State::Error; + match e { + embassy_boot::FirmwareUpdaterError::Flash(e) => match e { + NorFlashErrorKind::NotAligned => self.status = Status::ErrWrite, + NorFlashErrorKind::OutOfBounds => { + self.status = Status::ErrAddress + } + _ => self.status = Status::ErrUnknown, + }, + embassy_boot::FirmwareUpdaterError::Signature(_) => { + self.status = Status::ErrVerify + } + embassy_boot::FirmwareUpdaterError::BadState => { + self.status = Status::ErrUnknown + } + } + } + } + } + + Some(OutResponse::Accepted) + } + Ok(Request::Detach) => Some(OutResponse::Accepted), // Device is already in DFU mode + Ok(Request::ClrStatus) => { + self.reset_state(); + Some(OutResponse::Accepted) + } + _ => None, + } + } + + fn control_in<'a>( + &'a mut self, + req: embassy_usb::control::Request, + buf: &'a mut [u8], + ) -> Option> { + if (req.request_type, req.recipient) != (RequestType::Class, Recipient::Interface) { + return None; + } + match Request::try_from(req.request) { + Ok(Request::GetStatus) => { + //TODO: Configurable poll timeout, ability to add string for Vendor error + buf[0..6].copy_from_slice(&[self.status as u8, 0x32, 0x00, 0x00, self.state as u8, 0x00]); + match self.state { + State::DlSync => self.state = State::Download, + State::ManifestSync => cortex_m::peripheral::SCB::sys_reset(), + _ => {} + } + + Some(InResponse::Accepted(&buf[0..6])) + } + Ok(Request::GetState) => { + buf[0] = self.state as u8; + Some(InResponse::Accepted(&buf[0..1])) + } + Ok(Request::Upload) if self.attrs.contains(DfuAttributes::CAN_UPLOAD) => { + //TODO: FirmwareUpdater does not provide a way of reading the active partition, can't upload. + Some(InResponse::Rejected) + } + _ => None, + } + } +} + +/// An implementation of the USB DFU 1.1 protocol +/// +/// This function will add a DFU interface descriptor to the provided Builder, and register the provided Control as a handler for the USB device +/// The handler is responsive to DFU GetState, GetStatus, Abort, and ClrStatus commands, as well as Download if configured by the user. +/// +/// Once the host has initiated a DFU download operation, the chunks sent by the host will be written to the DFU partition. +/// Once the final sync in the manifestation phase has been received, the handler will trigger a system reset to swap the new firmware. +pub fn usb_dfu<'d, D: Driver<'d>, DFU: NorFlash, STATE: NorFlash, const BLOCK_SIZE: usize>( + builder: &mut Builder<'d, D>, + handler: &'d mut Control<'d, DFU, STATE, BLOCK_SIZE>, +) { + let mut func = builder.function(0x00, 0x00, 0x00); + let mut iface = func.interface(); + let mut alt = iface.alt_setting( + USB_CLASS_APPN_SPEC, + APPN_SPEC_SUBCLASS_DFU, + DFU_PROTOCOL_DFU, + None, + ); + alt.descriptor( + DESC_DFU_FUNCTIONAL, + &[ + handler.attrs.bits(), + 0xc4, 0x09, // 2500ms timeout, doesn't affect operation as DETACH not necessary in bootloader code + (BLOCK_SIZE & 0xff) as u8, + ((BLOCK_SIZE & 0xff00) >> 8) as u8, + 0x10, 0x01, // DFU 1.1 + ], + ); + + drop(func); + builder.handler(handler); +} diff --git a/embassy-usb-dfu/src/consts.rs b/embassy-usb-dfu/src/consts.rs new file mode 100644 index 00000000..b083af9d --- /dev/null +++ b/embassy-usb-dfu/src/consts.rs @@ -0,0 +1,96 @@ + +pub(crate) const USB_CLASS_APPN_SPEC: u8 = 0xFE; +pub(crate) const APPN_SPEC_SUBCLASS_DFU: u8 = 0x01; +#[allow(unused)] +pub(crate) const DFU_PROTOCOL_DFU: u8 = 0x02; +#[allow(unused)] +pub(crate) const DFU_PROTOCOL_RT: u8 = 0x01; +pub(crate) const DESC_DFU_FUNCTIONAL: u8 = 0x21; + +#[cfg(feature = "defmt")] +defmt::bitflags! { + pub struct DfuAttributes: u8 { + const WILL_DETACH = 0b0000_1000; + const MANIFESTATION_TOLERANT = 0b0000_0100; + const CAN_UPLOAD = 0b0000_0010; + const CAN_DOWNLOAD = 0b0000_0001; + } +} + +#[cfg(not(feature = "defmt"))] +bitflags::bitflags! { + pub struct DfuAttributes: u8 { + const WILL_DETACH = 0b0000_1000; + const MANIFESTATION_TOLERANT = 0b0000_0100; + const CAN_UPLOAD = 0b0000_0010; + const CAN_DOWNLOAD = 0b0000_0001; + } +} + +#[derive(Copy, Clone, PartialEq, Eq)] +#[repr(u8)] +#[allow(unused)] +pub enum State { + AppIdle = 0, + AppDetach = 1, + DfuIdle = 2, + DlSync = 3, + DlBusy = 4, + Download = 5, + ManifestSync = 6, + Manifest = 7, + ManifestWaitReset = 8, + UploadIdle = 9, + Error = 10, +} + +#[derive(Copy, Clone, PartialEq, Eq)] +#[repr(u8)] +#[allow(unused)] +pub enum Status { + Ok = 0x00, + ErrTarget = 0x01, + ErrFile = 0x02, + ErrWrite = 0x03, + ErrErase = 0x04, + ErrCheckErased = 0x05, + ErrProg = 0x06, + ErrVerify = 0x07, + ErrAddress = 0x08, + ErrNotDone = 0x09, + ErrFirmware = 0x0A, + ErrVendor = 0x0B, + ErrUsbr = 0x0C, + ErrPor = 0x0D, + ErrUnknown = 0x0E, + ErrStalledPkt = 0x0F, +} + +#[derive(Copy, Clone, PartialEq, Eq)] +#[repr(u8)] +pub enum Request { + Detach = 0, + Dnload = 1, + Upload = 2, + GetStatus = 3, + ClrStatus = 4, + GetState = 5, + Abort = 6, +} + +impl TryFrom for Request { + type Error = (); + + fn try_from(value: u8) -> Result { + match value { + 0 => Ok(Request::Detach), + 1 => Ok(Request::Dnload), + 2 => Ok(Request::Upload), + 3 => Ok(Request::GetStatus), + 4 => Ok(Request::ClrStatus), + 5 => Ok(Request::GetState), + 6 => Ok(Request::Abort), + _ => Err(()), + } + } +} diff --git a/embassy-usb-dfu/src/lib.rs b/embassy-usb-dfu/src/lib.rs new file mode 100644 index 00000000..dcdb11b2 --- /dev/null +++ b/embassy-usb-dfu/src/lib.rs @@ -0,0 +1,16 @@ +#![no_std] + +pub mod consts; + +#[cfg(feature = "bootloader")] +mod bootloader; +#[cfg(feature = "bootloader")] +pub use self::bootloader::*; + +#[cfg(feature = "application")] +mod application; +#[cfg(feature = "application")] +pub use self::application::*; + +#[cfg(any(all(feature = "bootloader", feature = "application"), not(any(feature = "bootloader", feature = "application"))))] +compile_error!("usb-dfu must be compiled with exactly one of `bootloader`, or `application` features"); From 6bf70e14fb14882ce6adf0d47179b7408bdcb184 Mon Sep 17 00:00:00 2001 From: djstrickland <96876452+dstric-aqueduct@users.noreply.github.com> Date: Wed, 13 Dec 2023 14:50:13 -0500 Subject: [PATCH 69/98] Update usb.rs - add check of `dev_resume_from_host` interrupt register to catch wake event --- embassy-rp/src/usb.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embassy-rp/src/usb.rs b/embassy-rp/src/usb.rs index 4ab881f6..4a74ee6f 100644 --- a/embassy-rp/src/usb.rs +++ b/embassy-rp/src/usb.rs @@ -363,7 +363,7 @@ impl<'d, T: Instance> driver::Bus for Bus<'d, T> { let siestatus = regs.sie_status().read(); let intrstatus = regs.intr().read(); - if siestatus.resume() { + if siestatus.resume() || intrstatus.dev_resume_from_host() { regs.sie_status().write(|w| w.set_resume(true)); return Poll::Ready(Event::Resume); } From c2942f2727739d8972ad211721b1bb1804fb7b4a Mon Sep 17 00:00:00 2001 From: Kaitlyn Kenwell Date: Wed, 13 Dec 2023 14:53:49 -0500 Subject: [PATCH 70/98] fmt --- embassy-usb-dfu/src/application.rs | 75 +++++++++++++++++++----------- embassy-usb-dfu/src/bootloader.rs | 56 +++++++++------------- embassy-usb-dfu/src/consts.rs | 1 - embassy-usb-dfu/src/lib.rs | 5 +- 4 files changed, 73 insertions(+), 64 deletions(-) diff --git a/embassy-usb-dfu/src/application.rs b/embassy-usb-dfu/src/application.rs index 5a52a9fe..2e7bda12 100644 --- a/embassy-usb-dfu/src/application.rs +++ b/embassy-usb-dfu/src/application.rs @@ -1,10 +1,14 @@ - use embassy_boot::BlockingFirmwareUpdater; -use embassy_time::{Instant, Duration}; -use embassy_usb::{Handler, control::{RequestType, Recipient, OutResponse, InResponse}, Builder, driver::Driver}; +use embassy_time::{Duration, Instant}; +use embassy_usb::control::{InResponse, OutResponse, Recipient, RequestType}; +use embassy_usb::driver::Driver; +use embassy_usb::{Builder, Handler}; use embedded_storage::nor_flash::NorFlash; -use crate::consts::{DfuAttributes, Request, Status, State, USB_CLASS_APPN_SPEC, APPN_SPEC_SUBCLASS_DFU, DESC_DFU_FUNCTIONAL, DFU_PROTOCOL_RT}; +use crate::consts::{ + DfuAttributes, Request, State, Status, APPN_SPEC_SUBCLASS_DFU, DESC_DFU_FUNCTIONAL, DFU_PROTOCOL_RT, + USB_CLASS_APPN_SPEC, +}; /// Internal state for the DFU class pub struct Control<'d, DFU: NorFlash, STATE: NorFlash> { @@ -17,7 +21,13 @@ pub struct Control<'d, DFU: NorFlash, STATE: NorFlash> { impl<'d, DFU: NorFlash, STATE: NorFlash> Control<'d, DFU, STATE> { pub fn new(updater: BlockingFirmwareUpdater<'d, DFU, STATE>, attrs: DfuAttributes) -> Self { - Control { updater, attrs, state: State::AppIdle, detach_start: None, timeout: None } + Control { + updater, + attrs, + state: State::AppIdle, + detach_start: None, + timeout: None, + } } } @@ -27,7 +37,11 @@ impl<'d, DFU: NorFlash, STATE: NorFlash> Handler for Control<'d, DFU, STATE> { let delta = Instant::now() - start; let timeout = self.timeout.unwrap(); #[cfg(feature = "defmt")] - defmt::info!("Received RESET with delta = {}, timeout = {}", delta.as_millis(), timeout.as_millis()); + defmt::info!( + "Received RESET with delta = {}, timeout = {}", + delta.as_millis(), + timeout.as_millis() + ); if delta < timeout { self.updater.mark_dfu().expect("Failed to mark DFU mode in bootloader"); cortex_m::asm::dsb(); @@ -36,7 +50,11 @@ impl<'d, DFU: NorFlash, STATE: NorFlash> Handler for Control<'d, DFU, STATE> { } } - fn control_out(&mut self, req: embassy_usb::control::Request, _: &[u8]) -> Option { + fn control_out( + &mut self, + req: embassy_usb::control::Request, + _: &[u8], + ) -> Option { if (req.request_type, req.recipient) != (RequestType::Class, Recipient::Interface) { return None; } @@ -53,13 +71,15 @@ impl<'d, DFU: NorFlash, STATE: NorFlash> Handler for Control<'d, DFU, STATE> { self.state = State::AppDetach; Some(OutResponse::Accepted) } - _ => { - None - } + _ => None, } } - fn control_in<'a>(&'a mut self, req: embassy_usb::control::Request, buf: &'a mut [u8]) -> Option> { + fn control_in<'a>( + &'a mut self, + req: embassy_usb::control::Request, + buf: &'a mut [u8], + ) -> Option> { if (req.request_type, req.recipient) != (RequestType::Class, Recipient::Interface) { return None; } @@ -72,31 +92,30 @@ impl<'d, DFU: NorFlash, STATE: NorFlash> Handler for Control<'d, DFU, STATE> { buf[0..6].copy_from_slice(&[Status::Ok as u8, 0x32, 0x00, 0x00, self.state as u8, 0x00]); Some(InResponse::Accepted(buf)) } - _ => None + _ => None, } } } /// An implementation of the USB DFU 1.1 runtime protocol -/// +/// /// This function will add a DFU interface descriptor to the provided Builder, and register the provided Control as a handler for the USB device. The USB builder can be used as normal once this is complete. -/// The handler is responsive to DFU GetStatus and Detach commands. -/// +/// The handler is responsive to DFU GetStatus and Detach commands. +/// /// Once a detach command, followed by a USB reset is received by the host, a magic number will be written into the bootloader state partition to indicate that /// it should expose a DFU device, and a software reset will be issued. -/// +/// /// To apply USB DFU updates, the bootloader must be capable of recognizing the DFU magic and exposing a device to handle the full DFU transaction with the host. -pub fn usb_dfu<'d, D: Driver<'d>, DFU: NorFlash, STATE: NorFlash>(builder: &mut Builder<'d, D>, handler: &'d mut Control<'d, DFU, STATE>, timeout: Duration) { +pub fn usb_dfu<'d, D: Driver<'d>, DFU: NorFlash, STATE: NorFlash>( + builder: &mut Builder<'d, D>, + handler: &'d mut Control<'d, DFU, STATE>, + timeout: Duration, +) { #[cfg(feature = "defmt")] defmt::info!("Application USB DFU initializing"); let mut func = builder.function(0x00, 0x00, 0x00); let mut iface = func.interface(); - let mut alt = iface.alt_setting( - USB_CLASS_APPN_SPEC, - APPN_SPEC_SUBCLASS_DFU, - DFU_PROTOCOL_RT, - None, - ); + let mut alt = iface.alt_setting(USB_CLASS_APPN_SPEC, APPN_SPEC_SUBCLASS_DFU, DFU_PROTOCOL_RT, None); let timeout = timeout.as_millis() as u16; alt.descriptor( DESC_DFU_FUNCTIONAL, @@ -104,11 +123,13 @@ pub fn usb_dfu<'d, D: Driver<'d>, DFU: NorFlash, STATE: NorFlash>(builder: &mut handler.attrs.bits(), (timeout & 0xff) as u8, ((timeout >> 8) & 0xff) as u8, - 0x40, 0x00, // 64B control buffer size for application side - 0x10, 0x01, // DFU 1.1 + 0x40, + 0x00, // 64B control buffer size for application side + 0x10, + 0x01, // DFU 1.1 ], ); drop(func); - builder.handler(handler); -} \ No newline at end of file + builder.handler(handler); +} diff --git a/embassy-usb-dfu/src/bootloader.rs b/embassy-usb-dfu/src/bootloader.rs index 7bcb0b25..21505893 100644 --- a/embassy-usb-dfu/src/bootloader.rs +++ b/embassy-usb-dfu/src/bootloader.rs @@ -1,12 +1,13 @@ use embassy_boot::BlockingFirmwareUpdater; -use embassy_usb::{ - control::{InResponse, OutResponse, Recipient, RequestType}, - driver::Driver, - Builder, Handler, -}; -use embedded_storage::nor_flash::{NorFlashErrorKind, NorFlash}; +use embassy_usb::control::{InResponse, OutResponse, Recipient, RequestType}; +use embassy_usb::driver::Driver; +use embassy_usb::{Builder, Handler}; +use embedded_storage::nor_flash::{NorFlash, NorFlashErrorKind}; -use crate::consts::{DfuAttributes, Request, State, Status, USB_CLASS_APPN_SPEC, APPN_SPEC_SUBCLASS_DFU, DFU_PROTOCOL_DFU, DESC_DFU_FUNCTIONAL}; +use crate::consts::{ + DfuAttributes, Request, State, Status, APPN_SPEC_SUBCLASS_DFU, DESC_DFU_FUNCTIONAL, DFU_PROTOCOL_DFU, + USB_CLASS_APPN_SPEC, +}; /// Internal state for USB DFU pub struct Control<'d, DFU: NorFlash, STATE: NorFlash, const BLOCK_SIZE: usize> { @@ -69,17 +70,11 @@ impl<'d, DFU: NorFlash, STATE: NorFlash, const BLOCK_SIZE: usize> Handler for Co match e { embassy_boot::FirmwareUpdaterError::Flash(e) => match e { NorFlashErrorKind::NotAligned => self.status = Status::ErrWrite, - NorFlashErrorKind::OutOfBounds => { - self.status = Status::ErrAddress - } + NorFlashErrorKind::OutOfBounds => self.status = Status::ErrAddress, _ => self.status = Status::ErrUnknown, }, - embassy_boot::FirmwareUpdaterError::Signature(_) => { - self.status = Status::ErrVerify - } - embassy_boot::FirmwareUpdaterError::BadState => { - self.status = Status::ErrUnknown - } + embassy_boot::FirmwareUpdaterError::Signature(_) => self.status = Status::ErrVerify, + embassy_boot::FirmwareUpdaterError::BadState => self.status = Status::ErrUnknown, } } } @@ -101,17 +96,11 @@ impl<'d, DFU: NorFlash, STATE: NorFlash, const BLOCK_SIZE: usize> Handler for Co match e { embassy_boot::FirmwareUpdaterError::Flash(e) => match e { NorFlashErrorKind::NotAligned => self.status = Status::ErrWrite, - NorFlashErrorKind::OutOfBounds => { - self.status = Status::ErrAddress - } + NorFlashErrorKind::OutOfBounds => self.status = Status::ErrAddress, _ => self.status = Status::ErrUnknown, }, - embassy_boot::FirmwareUpdaterError::Signature(_) => { - self.status = Status::ErrVerify - } - embassy_boot::FirmwareUpdaterError::BadState => { - self.status = Status::ErrUnknown - } + embassy_boot::FirmwareUpdaterError::Signature(_) => self.status = Status::ErrVerify, + embassy_boot::FirmwareUpdaterError::BadState => self.status = Status::ErrUnknown, } } } @@ -162,10 +151,10 @@ impl<'d, DFU: NorFlash, STATE: NorFlash, const BLOCK_SIZE: usize> Handler for Co } /// An implementation of the USB DFU 1.1 protocol -/// +/// /// This function will add a DFU interface descriptor to the provided Builder, and register the provided Control as a handler for the USB device /// The handler is responsive to DFU GetState, GetStatus, Abort, and ClrStatus commands, as well as Download if configured by the user. -/// +/// /// Once the host has initiated a DFU download operation, the chunks sent by the host will be written to the DFU partition. /// Once the final sync in the manifestation phase has been received, the handler will trigger a system reset to swap the new firmware. pub fn usb_dfu<'d, D: Driver<'d>, DFU: NorFlash, STATE: NorFlash, const BLOCK_SIZE: usize>( @@ -174,20 +163,17 @@ pub fn usb_dfu<'d, D: Driver<'d>, DFU: NorFlash, STATE: NorFlash, const BLOCK_SI ) { let mut func = builder.function(0x00, 0x00, 0x00); let mut iface = func.interface(); - let mut alt = iface.alt_setting( - USB_CLASS_APPN_SPEC, - APPN_SPEC_SUBCLASS_DFU, - DFU_PROTOCOL_DFU, - None, - ); + let mut alt = iface.alt_setting(USB_CLASS_APPN_SPEC, APPN_SPEC_SUBCLASS_DFU, DFU_PROTOCOL_DFU, None); alt.descriptor( DESC_DFU_FUNCTIONAL, &[ handler.attrs.bits(), - 0xc4, 0x09, // 2500ms timeout, doesn't affect operation as DETACH not necessary in bootloader code + 0xc4, + 0x09, // 2500ms timeout, doesn't affect operation as DETACH not necessary in bootloader code (BLOCK_SIZE & 0xff) as u8, ((BLOCK_SIZE & 0xff00) >> 8) as u8, - 0x10, 0x01, // DFU 1.1 + 0x10, + 0x01, // DFU 1.1 ], ); diff --git a/embassy-usb-dfu/src/consts.rs b/embassy-usb-dfu/src/consts.rs index b083af9d..b359a107 100644 --- a/embassy-usb-dfu/src/consts.rs +++ b/embassy-usb-dfu/src/consts.rs @@ -1,4 +1,3 @@ - pub(crate) const USB_CLASS_APPN_SPEC: u8 = 0xFE; pub(crate) const APPN_SPEC_SUBCLASS_DFU: u8 = 0x01; #[allow(unused)] diff --git a/embassy-usb-dfu/src/lib.rs b/embassy-usb-dfu/src/lib.rs index dcdb11b2..81ef041f 100644 --- a/embassy-usb-dfu/src/lib.rs +++ b/embassy-usb-dfu/src/lib.rs @@ -12,5 +12,8 @@ mod application; #[cfg(feature = "application")] pub use self::application::*; -#[cfg(any(all(feature = "bootloader", feature = "application"), not(any(feature = "bootloader", feature = "application"))))] +#[cfg(any( + all(feature = "bootloader", feature = "application"), + not(any(feature = "bootloader", feature = "application")) +))] compile_error!("usb-dfu must be compiled with exactly one of `bootloader`, or `application` features"); From 702d2a1a193985c9b8da6fc5e532ac55b5485464 Mon Sep 17 00:00:00 2001 From: Kaitlyn Kenwell Date: Wed, 13 Dec 2023 16:08:20 -0500 Subject: [PATCH 71/98] Formatting fixes, add example using stm32wb55 --- .../boot/src/firmware_updater/asynch.rs | 2 +- .../boot/src/firmware_updater/blocking.rs | 2 +- examples/boot-usb-dfu/.cargo/config.toml | 9 ++ .../application/stm32wb/.cargo/config.toml | 9 ++ .../application/stm32wb/Cargo.toml | 32 +++++++ .../application/stm32wb/README.md | 29 ++++++ .../boot-usb-dfu/application/stm32wb/build.rs | 37 ++++++++ .../boot-usb-dfu/application/stm32wb/memory.x | 15 +++ .../application/stm32wb/src/main.rs | 64 +++++++++++++ .../bootloader/stm32wb/Cargo.toml | 63 ++++++++++++ .../boot-usb-dfu/bootloader/stm32wb/README.md | 11 +++ .../boot-usb-dfu/bootloader/stm32wb/build.rs | 27 ++++++ .../boot-usb-dfu/bootloader/stm32wb/memory.x | 18 ++++ .../bootloader/stm32wb/src/main.rs | 95 +++++++++++++++++++ 14 files changed, 411 insertions(+), 2 deletions(-) create mode 100644 examples/boot-usb-dfu/.cargo/config.toml create mode 100644 examples/boot-usb-dfu/application/stm32wb/.cargo/config.toml create mode 100644 examples/boot-usb-dfu/application/stm32wb/Cargo.toml create mode 100644 examples/boot-usb-dfu/application/stm32wb/README.md create mode 100644 examples/boot-usb-dfu/application/stm32wb/build.rs create mode 100644 examples/boot-usb-dfu/application/stm32wb/memory.x create mode 100644 examples/boot-usb-dfu/application/stm32wb/src/main.rs create mode 100644 examples/boot-usb-dfu/bootloader/stm32wb/Cargo.toml create mode 100644 examples/boot-usb-dfu/bootloader/stm32wb/README.md create mode 100644 examples/boot-usb-dfu/bootloader/stm32wb/build.rs create mode 100644 examples/boot-usb-dfu/bootloader/stm32wb/memory.x create mode 100644 examples/boot-usb-dfu/bootloader/stm32wb/src/main.rs diff --git a/embassy-boot/boot/src/firmware_updater/asynch.rs b/embassy-boot/boot/src/firmware_updater/asynch.rs index 0a3cbc13..82e99965 100644 --- a/embassy-boot/boot/src/firmware_updater/asynch.rs +++ b/embassy-boot/boot/src/firmware_updater/asynch.rs @@ -6,7 +6,7 @@ use embassy_sync::blocking_mutex::raw::NoopRawMutex; use embedded_storage_async::nor_flash::NorFlash; use super::FirmwareUpdaterConfig; -use crate::{FirmwareUpdaterError, State, BOOT_MAGIC, STATE_ERASE_VALUE, SWAP_MAGIC, DFU_DETACH_MAGIC}; +use crate::{FirmwareUpdaterError, State, BOOT_MAGIC, DFU_DETACH_MAGIC, STATE_ERASE_VALUE, SWAP_MAGIC}; /// FirmwareUpdater is an application API for interacting with the BootLoader without the ability to /// 'mess up' the internal bootloader state diff --git a/embassy-boot/boot/src/firmware_updater/blocking.rs b/embassy-boot/boot/src/firmware_updater/blocking.rs index b2a633d1..ae4179ba 100644 --- a/embassy-boot/boot/src/firmware_updater/blocking.rs +++ b/embassy-boot/boot/src/firmware_updater/blocking.rs @@ -6,7 +6,7 @@ use embassy_sync::blocking_mutex::raw::NoopRawMutex; use embedded_storage::nor_flash::NorFlash; use super::FirmwareUpdaterConfig; -use crate::{FirmwareUpdaterError, State, BOOT_MAGIC, STATE_ERASE_VALUE, SWAP_MAGIC, DFU_DETACH_MAGIC}; +use crate::{FirmwareUpdaterError, State, BOOT_MAGIC, DFU_DETACH_MAGIC, STATE_ERASE_VALUE, SWAP_MAGIC}; /// Blocking FirmwareUpdater is an application API for interacting with the BootLoader without the ability to /// 'mess up' the internal bootloader state diff --git a/examples/boot-usb-dfu/.cargo/config.toml b/examples/boot-usb-dfu/.cargo/config.toml new file mode 100644 index 00000000..de3a814f --- /dev/null +++ b/examples/boot-usb-dfu/.cargo/config.toml @@ -0,0 +1,9 @@ +[unstable] +build-std = ["core"] +build-std-features = ["panic_immediate_abort"] + +[build] +target = "thumbv7em-none-eabi" + +[env] +DEFMT_LOG = "trace" diff --git a/examples/boot-usb-dfu/application/stm32wb/.cargo/config.toml b/examples/boot-usb-dfu/application/stm32wb/.cargo/config.toml new file mode 100644 index 00000000..4f8094ff --- /dev/null +++ b/examples/boot-usb-dfu/application/stm32wb/.cargo/config.toml @@ -0,0 +1,9 @@ +[target.'cfg(all(target_arch = "arm", target_os = "none"))'] +# replace your chip as listed in `probe-rs chip list` +runner = "probe-rs run --chip STM32WLE5JCIx" + +[build] +target = "thumbv7em-none-eabihf" + +[env] +DEFMT_LOG = "trace" diff --git a/examples/boot-usb-dfu/application/stm32wb/Cargo.toml b/examples/boot-usb-dfu/application/stm32wb/Cargo.toml new file mode 100644 index 00000000..0a41c064 --- /dev/null +++ b/examples/boot-usb-dfu/application/stm32wb/Cargo.toml @@ -0,0 +1,32 @@ +[package] +edition = "2021" +name = "embassy-boot-stm32wl-examples" +version = "0.1.0" +license = "MIT OR Apache-2.0" + +[dependencies] +embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } +embassy-executor = { version = "0.4.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } +embassy-time = { version = "0.2", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } +embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["stm32wb55rg", "time-driver-any", "exti"] } +embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = [] } +embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } +embassy-usb = { version = "0.1.0", path = "../../../../embassy-usb" } +embassy-usb-dfu = { version = "0.1.0", path = "../../../../embassy-usb-dfu", features = ["application"] } + +defmt = { version = "0.3", optional = true } +defmt-rtt = { version = "0.4", optional = true } +panic-reset = { version = "0.1.1" } +embedded-hal = { version = "0.2.6" } + +cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } +cortex-m-rt = "0.7.0" + +[features] +defmt = [ + "dep:defmt", + "embassy-stm32/defmt", + "embassy-boot-stm32/defmt", + "embassy-sync/defmt", +] +skip-include = [] diff --git a/examples/boot-usb-dfu/application/stm32wb/README.md b/examples/boot-usb-dfu/application/stm32wb/README.md new file mode 100644 index 00000000..c8dce038 --- /dev/null +++ b/examples/boot-usb-dfu/application/stm32wb/README.md @@ -0,0 +1,29 @@ +# Examples using bootloader + +Example for STM32WL demonstrating the bootloader. The example consists of application binaries, 'a' +which allows you to press a button to start the DFU process, and 'b' which is the updated +application. + + +## Prerequisites + +* `cargo-binutils` +* `cargo-flash` +* `embassy-boot-stm32` + +## Usage + +``` +# Flash bootloader +cargo flash --manifest-path ../../bootloader/stm32/Cargo.toml --release --features embassy-stm32/stm32wl55jc-cm4 --chip STM32WLE5JCIx +# Build 'b' +cargo build --release --bin b +# Generate binary for 'b' +cargo objcopy --release --bin b -- -O binary b.bin +``` + +# Flash `a` (which includes b.bin) + +``` +cargo flash --release --bin a --chip STM32WLE5JCIx +``` diff --git a/examples/boot-usb-dfu/application/stm32wb/build.rs b/examples/boot-usb-dfu/application/stm32wb/build.rs new file mode 100644 index 00000000..e1da6932 --- /dev/null +++ b/examples/boot-usb-dfu/application/stm32wb/build.rs @@ -0,0 +1,37 @@ +//! This build script copies the `memory.x` file from the crate root into +//! a directory where the linker can always find it at build time. +//! For many projects this is optional, as the linker always searches the +//! project root directory -- wherever `Cargo.toml` is. However, if you +//! are using a workspace or have a more complicated build setup, this +//! build script becomes required. Additionally, by requesting that +//! Cargo re-run the build script whenever `memory.x` is changed, +//! updating `memory.x` ensures a rebuild of the application with the +//! new memory settings. + +use std::env; +use std::fs::File; +use std::io::Write; +use std::path::PathBuf; + +fn main() { + // Put `memory.x` in our output directory and ensure it's + // on the linker search path. + let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); + File::create(out.join("memory.x")) + .unwrap() + .write_all(include_bytes!("memory.x")) + .unwrap(); + println!("cargo:rustc-link-search={}", out.display()); + + // By default, Cargo will re-run a build script whenever + // any file in the project changes. By specifying `memory.x` + // here, we ensure the build script is only re-run when + // `memory.x` is changed. + println!("cargo:rerun-if-changed=memory.x"); + + println!("cargo:rustc-link-arg-bins=--nmagic"); + println!("cargo:rustc-link-arg-bins=-Tlink.x"); + if env::var("CARGO_FEATURE_DEFMT").is_ok() { + println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); + } +} diff --git a/examples/boot-usb-dfu/application/stm32wb/memory.x b/examples/boot-usb-dfu/application/stm32wb/memory.x new file mode 100644 index 00000000..f5187576 --- /dev/null +++ b/examples/boot-usb-dfu/application/stm32wb/memory.x @@ -0,0 +1,15 @@ +MEMORY +{ + /* NOTE 1 K = 1 KiBi = 1024 bytes */ + BOOTLOADER : ORIGIN = 0x08000000, LENGTH = 24K + BOOTLOADER_STATE : ORIGIN = 0x08006000, LENGTH = 4K + FLASH : ORIGIN = 0x08008000, LENGTH = 32K + DFU : ORIGIN = 0x08010000, LENGTH = 36K + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K +} + +__bootloader_state_start = ORIGIN(BOOTLOADER_STATE) - ORIGIN(BOOTLOADER); +__bootloader_state_end = ORIGIN(BOOTLOADER_STATE) + LENGTH(BOOTLOADER_STATE) - ORIGIN(BOOTLOADER); + +__bootloader_dfu_start = ORIGIN(DFU) - ORIGIN(BOOTLOADER); +__bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU) - ORIGIN(BOOTLOADER); diff --git a/examples/boot-usb-dfu/application/stm32wb/src/main.rs b/examples/boot-usb-dfu/application/stm32wb/src/main.rs new file mode 100644 index 00000000..f03003ff --- /dev/null +++ b/examples/boot-usb-dfu/application/stm32wb/src/main.rs @@ -0,0 +1,64 @@ +#![no_std] +#![no_main] +#![feature(type_alias_impl_trait)] + +use core::cell::RefCell; + +#[cfg(feature = "defmt-rtt")] +use defmt_rtt::*; +use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdaterConfig}; +use embassy_executor::Spawner; +use embassy_stm32::flash::{Flash, WRITE_SIZE}; +use embassy_stm32::rcc::WPAN_DEFAULT; +use embassy_stm32::usb::{self, Driver}; +use embassy_stm32::{bind_interrupts, peripherals}; +use embassy_sync::blocking_mutex::Mutex; +use embassy_time::Duration; +use embassy_usb::Builder; +use embassy_usb_dfu::consts::DfuAttributes; +use embassy_usb_dfu::{usb_dfu, Control}; +use panic_reset as _; + +bind_interrupts!(struct Irqs { + USB_LP => usb::InterruptHandler; +}); + +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let mut config = embassy_stm32::Config::default(); + config.rcc = WPAN_DEFAULT; + let p = embassy_stm32::init(config); + let flash = Flash::new_blocking(p.FLASH); + let flash = Mutex::new(RefCell::new(flash)); + + let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash); + let mut magic = AlignedBuffer([0; WRITE_SIZE]); + let mut updater = BlockingFirmwareUpdater::new(config, &mut magic.0); + updater.mark_booted().expect("Failed to mark booted"); + + let driver = Driver::new(p.USB, Irqs, p.PA12, p.PA11); + let mut config = embassy_usb::Config::new(0xc0de, 0xcafe); + config.manufacturer = Some("Embassy"); + config.product = Some("USB-DFU Runtime example"); + config.serial_number = Some("1235678"); + + let mut device_descriptor = [0; 256]; + let mut config_descriptor = [0; 256]; + let mut bos_descriptor = [0; 256]; + let mut control_buf = [0; 64]; + let mut state = Control::new(updater, DfuAttributes::CAN_DOWNLOAD); + let mut builder = Builder::new( + driver, + config, + &mut device_descriptor, + &mut config_descriptor, + &mut bos_descriptor, + &mut [], + &mut control_buf, + ); + + usb_dfu::<_, _, _>(&mut builder, &mut state, Duration::from_millis(2500)); + + let mut dev = builder.build(); + dev.run().await +} diff --git a/examples/boot-usb-dfu/bootloader/stm32wb/Cargo.toml b/examples/boot-usb-dfu/bootloader/stm32wb/Cargo.toml new file mode 100644 index 00000000..774a8223 --- /dev/null +++ b/examples/boot-usb-dfu/bootloader/stm32wb/Cargo.toml @@ -0,0 +1,63 @@ +[package] +edition = "2021" +name = "stm32-bootloader-example" +version = "0.1.0" +description = "Example bootloader for STM32 chips" +license = "MIT OR Apache-2.0" + +[dependencies] +defmt = { version = "0.3", optional = true } +defmt-rtt = { version = "0.4", optional = true } + +embassy-stm32 = { path = "../../../../embassy-stm32", features = ["stm32wb55rg"] } +embassy-boot-stm32 = { path = "../../../../embassy-boot/stm32" } +cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } +embassy-sync = { version = "0.5.0", path = "../../../../embassy-sync" } +cortex-m-rt = { version = "0.7" } +embedded-storage = "0.3.1" +embedded-storage-async = "0.4.0" +cfg-if = "1.0.0" +embassy-usb-dfu = { version = "0.1.0", path = "../../../../embassy-usb-dfu", features = ["bootloader"] } +embassy-usb = { version = "0.1.0", path = "../../../../embassy-usb", default-features = false } +embassy-futures = { version = "0.1.1", path = "../../../../embassy-futures" } + +[features] +defmt = [ + "dep:defmt", + "embassy-boot-stm32/defmt", + "embassy-stm32/defmt", + "embassy-usb/defmt", + "embassy-usb-dfu/defmt" +] +debug = ["defmt-rtt", "defmt"] + +[profile.dev] +debug = 2 +debug-assertions = true +incremental = false +opt-level = 'z' +overflow-checks = true + +[profile.release] +codegen-units = 1 +debug = 2 +debug-assertions = false +incremental = false +lto = 'fat' +opt-level = 'z' +overflow-checks = false + +# do not optimize proc-macro crates = faster builds from scratch +[profile.dev.build-override] +codegen-units = 8 +debug = false +debug-assertions = false +opt-level = 0 +overflow-checks = false + +[profile.release.build-override] +codegen-units = 8 +debug = false +debug-assertions = false +opt-level = 0 +overflow-checks = false diff --git a/examples/boot-usb-dfu/bootloader/stm32wb/README.md b/examples/boot-usb-dfu/bootloader/stm32wb/README.md new file mode 100644 index 00000000..a82b730b --- /dev/null +++ b/examples/boot-usb-dfu/bootloader/stm32wb/README.md @@ -0,0 +1,11 @@ +# Bootloader for STM32 + +The bootloader uses `embassy-boot` to interact with the flash. + +# Usage + +Flash the bootloader + +``` +cargo flash --features embassy-stm32/stm32wl55jc-cm4 --release --chip STM32WLE5JCIx +``` diff --git a/examples/boot-usb-dfu/bootloader/stm32wb/build.rs b/examples/boot-usb-dfu/bootloader/stm32wb/build.rs new file mode 100644 index 00000000..fd605991 --- /dev/null +++ b/examples/boot-usb-dfu/bootloader/stm32wb/build.rs @@ -0,0 +1,27 @@ +use std::env; +use std::fs::File; +use std::io::Write; +use std::path::PathBuf; + +fn main() { + // Put `memory.x` in our output directory and ensure it's + // on the linker search path. + let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); + File::create(out.join("memory.x")) + .unwrap() + .write_all(include_bytes!("memory.x")) + .unwrap(); + println!("cargo:rustc-link-search={}", out.display()); + + // By default, Cargo will re-run a build script whenever + // any file in the project changes. By specifying `memory.x` + // here, we ensure the build script is only re-run when + // `memory.x` is changed. + println!("cargo:rerun-if-changed=memory.x"); + + println!("cargo:rustc-link-arg-bins=--nmagic"); + println!("cargo:rustc-link-arg-bins=-Tlink.x"); + if env::var("CARGO_FEATURE_DEFMT").is_ok() { + println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); + } +} diff --git a/examples/boot-usb-dfu/bootloader/stm32wb/memory.x b/examples/boot-usb-dfu/bootloader/stm32wb/memory.x new file mode 100644 index 00000000..b6f185ef --- /dev/null +++ b/examples/boot-usb-dfu/bootloader/stm32wb/memory.x @@ -0,0 +1,18 @@ +MEMORY +{ + /* NOTE 1 K = 1 KiBi = 1024 bytes */ + FLASH : ORIGIN = 0x08000000, LENGTH = 24K + BOOTLOADER_STATE : ORIGIN = 0x08006000, LENGTH = 4K + ACTIVE : ORIGIN = 0x08008000, LENGTH = 32K + DFU : ORIGIN = 0x08010000, LENGTH = 36K + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 16K +} + +__bootloader_state_start = ORIGIN(BOOTLOADER_STATE) - ORIGIN(FLASH); +__bootloader_state_end = ORIGIN(BOOTLOADER_STATE) + LENGTH(BOOTLOADER_STATE) - ORIGIN(FLASH); + +__bootloader_active_start = ORIGIN(ACTIVE) - ORIGIN(FLASH); +__bootloader_active_end = ORIGIN(ACTIVE) + LENGTH(ACTIVE) - ORIGIN(FLASH); + +__bootloader_dfu_start = ORIGIN(DFU) - ORIGIN(FLASH); +__bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU) - ORIGIN(FLASH); diff --git a/examples/boot-usb-dfu/bootloader/stm32wb/src/main.rs b/examples/boot-usb-dfu/bootloader/stm32wb/src/main.rs new file mode 100644 index 00000000..00a535d3 --- /dev/null +++ b/examples/boot-usb-dfu/bootloader/stm32wb/src/main.rs @@ -0,0 +1,95 @@ +#![no_std] +#![no_main] + +use core::cell::RefCell; + +use cortex_m_rt::{entry, exception}; +#[cfg(feature = "defmt")] +use defmt_rtt as _; +use embassy_boot_stm32::*; +use embassy_stm32::flash::{Flash, BANK1_REGION, WRITE_SIZE}; +use embassy_stm32::rcc::WPAN_DEFAULT; +use embassy_stm32::usb::Driver; +use embassy_stm32::{bind_interrupts, peripherals, usb}; +use embassy_sync::blocking_mutex::Mutex; +use embassy_usb::Builder; +use embassy_usb_dfu::consts::DfuAttributes; +use embassy_usb_dfu::{usb_dfu, Control}; + +bind_interrupts!(struct Irqs { + USB_LP => usb::InterruptHandler; +}); + +#[entry] +fn main() -> ! { + let mut config = embassy_stm32::Config::default(); + config.rcc = WPAN_DEFAULT; + let p = embassy_stm32::init(config); + + // Uncomment this if you are debugging the bootloader with debugger/RTT attached, + // as it prevents a hard fault when accessing flash 'too early' after boot. + /* + for i in 0..10000000 { + cortex_m::asm::nop(); + } + */ + + let layout = Flash::new_blocking(p.FLASH).into_blocking_regions(); + let flash = Mutex::new(RefCell::new(layout.bank1_region)); + + let config = BootLoaderConfig::from_linkerfile_blocking(&flash); + let active_offset = config.active.offset(); + let bl = BootLoader::prepare::<_, _, _, 2048>(config); + if bl.state == State::DfuDetach { + let driver = Driver::new(p.USB, Irqs, p.PA12, p.PA11); + let mut config = embassy_usb::Config::new(0xc0de, 0xcafe); + config.manufacturer = Some("Embassy"); + config.product = Some("USB-DFU Bootloader example"); + config.serial_number = Some("1235678"); + + let fw_config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash); + let mut buffer = AlignedBuffer([0; WRITE_SIZE]); + let updater = BlockingFirmwareUpdater::new(fw_config, &mut buffer.0[..]); + + let mut device_descriptor = [0; 256]; + let mut config_descriptor = [0; 256]; + let mut bos_descriptor = [0; 256]; + let mut control_buf = [0; 4096]; + let mut state = Control::new(updater, DfuAttributes::CAN_DOWNLOAD); + let mut builder = Builder::new( + driver, + config, + &mut device_descriptor, + &mut config_descriptor, + &mut bos_descriptor, + &mut [], + &mut control_buf, + ); + + usb_dfu::<_, _, _, 4096>(&mut builder, &mut state); + + let mut dev = builder.build(); + embassy_futures::block_on(dev.run()); + } + + unsafe { bl.load(BANK1_REGION.base + active_offset) } +} + +#[no_mangle] +#[cfg_attr(target_os = "none", link_section = ".HardFault.user")] +unsafe extern "C" fn HardFault() { + cortex_m::peripheral::SCB::sys_reset(); +} + +#[exception] +unsafe fn DefaultHandler(_: i16) -> ! { + const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32; + let irqn = core::ptr::read_volatile(SCB_ICSR) as u8 as i16 - 16; + + panic!("DefaultHandler #{:?}", irqn); +} + +#[panic_handler] +fn panic(_info: &core::panic::PanicInfo) -> ! { + cortex_m::asm::udf(); +} From b60b3f4eb8f22ecda1c30d63213010f1b6b47686 Mon Sep 17 00:00:00 2001 From: Kaitlyn Kenwell Date: Wed, 13 Dec 2023 16:19:59 -0500 Subject: [PATCH 72/98] Last fmt hopefully --- embassy-boot/boot/src/boot_loader.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embassy-boot/boot/src/boot_loader.rs b/embassy-boot/boot/src/boot_loader.rs index 340962a7..b3970d86 100644 --- a/embassy-boot/boot/src/boot_loader.rs +++ b/embassy-boot/boot/src/boot_loader.rs @@ -5,7 +5,7 @@ use embassy_sync::blocking_mutex::raw::NoopRawMutex; use embassy_sync::blocking_mutex::Mutex; use embedded_storage::nor_flash::{NorFlash, NorFlashError, NorFlashErrorKind}; -use crate::{State, BOOT_MAGIC, STATE_ERASE_VALUE, SWAP_MAGIC, DFU_DETACH_MAGIC}; +use crate::{State, BOOT_MAGIC, DFU_DETACH_MAGIC, STATE_ERASE_VALUE, SWAP_MAGIC}; /// Errors returned by bootloader #[derive(PartialEq, Eq, Debug)] From b17f16f0af635f4268543dcfe4cee1ec48b216a1 Mon Sep 17 00:00:00 2001 From: Priit Laes Date: Thu, 14 Dec 2023 09:11:30 +0200 Subject: [PATCH 73/98] embassy-boot: Fix formatting for tables Tables describing the a-b flashing were all garbled up in the cargo doc output, so fix up the syntax. --- embassy-boot/boot/src/boot_loader.rs | 36 +++++++++------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/embassy-boot/boot/src/boot_loader.rs b/embassy-boot/boot/src/boot_loader.rs index 1663f4f2..65b12dc5 100644 --- a/embassy-boot/boot/src/boot_loader.rs +++ b/embassy-boot/boot/src/boot_loader.rs @@ -135,51 +135,44 @@ impl BootLoader BootLoader Result { // Ensure we have enough progress pages to store copy progress From 879c0ad9890e80f2e7c19c715347b86b61eb432a Mon Sep 17 00:00:00 2001 From: eZio Pan Date: Thu, 14 Dec 2023 21:33:35 +0800 Subject: [PATCH 74/98] after stm32-metapac update, TIM CR1 ARPE enum to bool --- embassy-stm32/Cargo.toml | 4 ++-- embassy-stm32/src/timer/mod.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 074538d3..f54d5608 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -58,7 +58,7 @@ rand_core = "0.6.3" sdio-host = "0.5.0" embedded-sdmmc = { git = "https://github.com/embassy-rs/embedded-sdmmc-rs", rev = "a4f293d3a6f72158385f79c98634cb8a14d0d2fc", optional = true } critical-section = "1.1" -stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-8f5fcae8c289c1ad481cc3a2bb37db023a61599c" } +stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-91cee0d1fdcb4e447b65a09756b506f4af91b7e2" } vcell = "0.1.3" bxcan = "0.7.0" nb = "1.0.0" @@ -76,7 +76,7 @@ critical-section = { version = "1.1", features = ["std"] } [build-dependencies] proc-macro2 = "1.0.36" quote = "1.0.15" -stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-8f5fcae8c289c1ad481cc3a2bb37db023a61599c", default-features = false, features = ["metadata"]} +stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-91cee0d1fdcb4e447b65a09756b506f4af91b7e2", default-features = false, features = ["metadata"]} [features] diff --git a/embassy-stm32/src/timer/mod.rs b/embassy-stm32/src/timer/mod.rs index 2313a5b9..9f93c642 100644 --- a/embassy-stm32/src/timer/mod.rs +++ b/embassy-stm32/src/timer/mod.rs @@ -77,7 +77,7 @@ pub(crate) mod sealed { Self::regs().dier().write(|r| r.set_uie(enable)); } - fn set_autoreload_preload(&mut self, enable: vals::Arpe) { + fn set_autoreload_preload(&mut self, enable: bool) { Self::regs().cr1().modify(|r| r.set_arpe(enable)); } From e27e00f6280683293f427d0731aa69ca32dbbe60 Mon Sep 17 00:00:00 2001 From: Kaitlyn Kenwell Date: Thu, 14 Dec 2023 09:36:22 -0500 Subject: [PATCH 75/98] Address reviews --- .../boot/src/firmware_updater/asynch.rs | 10 + .../boot/src/firmware_updater/blocking.rs | 10 + embassy-boot/boot/src/lib.rs | 2 +- embassy-usb-dfu/src/application.rs | 36 ++- embassy-usb-dfu/src/bootloader.rs | 8 +- embassy-usb-dfu/src/fmt.rs | 258 ++++++++++++++++++ embassy-usb-dfu/src/lib.rs | 1 + examples/boot-usb-dfu/.cargo/config.toml | 9 - .../stm32wb-dfu}/.cargo/config.toml | 0 .../application/stm32wb-dfu}/Cargo.toml | 1 + .../application/stm32wb-dfu}/README.md | 0 .../application/stm32wb-dfu}/build.rs | 0 .../application/stm32wb-dfu}/memory.x | 0 .../application/stm32wb-dfu}/src/main.rs | 0 .../bootloader/stm32wb-dfu}/Cargo.toml | 0 .../bootloader/stm32wb-dfu}/README.md | 0 .../bootloader/stm32wb-dfu}/build.rs | 0 .../bootloader/stm32wb-dfu}/memory.x | 0 .../bootloader/stm32wb-dfu}/src/main.rs | 13 +- 19 files changed, 307 insertions(+), 41 deletions(-) create mode 100644 embassy-usb-dfu/src/fmt.rs delete mode 100644 examples/boot-usb-dfu/.cargo/config.toml rename examples/{boot-usb-dfu/application/stm32wb => boot/application/stm32wb-dfu}/.cargo/config.toml (100%) rename examples/{boot-usb-dfu/application/stm32wb => boot/application/stm32wb-dfu}/Cargo.toml (98%) rename examples/{boot-usb-dfu/application/stm32wb => boot/application/stm32wb-dfu}/README.md (100%) rename examples/{boot-usb-dfu/application/stm32wb => boot/application/stm32wb-dfu}/build.rs (100%) rename examples/{boot-usb-dfu/application/stm32wb => boot/application/stm32wb-dfu}/memory.x (100%) rename examples/{boot-usb-dfu/application/stm32wb => boot/application/stm32wb-dfu}/src/main.rs (100%) rename examples/{boot-usb-dfu/bootloader/stm32wb => boot/bootloader/stm32wb-dfu}/Cargo.toml (100%) rename examples/{boot-usb-dfu/bootloader/stm32wb => boot/bootloader/stm32wb-dfu}/README.md (100%) rename examples/{boot-usb-dfu/bootloader/stm32wb => boot/bootloader/stm32wb-dfu}/build.rs (100%) rename examples/{boot-usb-dfu/bootloader/stm32wb => boot/bootloader/stm32wb-dfu}/memory.x (100%) rename examples/{boot-usb-dfu/bootloader/stm32wb => boot/bootloader/stm32wb-dfu}/src/main.rs (91%) diff --git a/embassy-boot/boot/src/firmware_updater/asynch.rs b/embassy-boot/boot/src/firmware_updater/asynch.rs index 82e99965..d8d85c3d 100644 --- a/embassy-boot/boot/src/firmware_updater/asynch.rs +++ b/embassy-boot/boot/src/firmware_updater/asynch.rs @@ -213,6 +213,16 @@ pub struct FirmwareState<'d, STATE> { } impl<'d, STATE: NorFlash> FirmwareState<'d, STATE> { + /// Create a firmware state instance from a FirmwareUpdaterConfig with a buffer for magic content and state partition. + /// + /// # Safety + /// + /// The `aligned` buffer must have a size of STATE::WRITE_SIZE, and follow the alignment rules for the flash being read from + /// and written to. + pub fn from_config(config: FirmwareUpdaterConfig, aligned: &'d mut [u8]) -> Self { + Self::new(config.state, aligned) + } + /// Create a firmware state instance with a buffer for magic content and state partition. /// /// # Safety diff --git a/embassy-boot/boot/src/firmware_updater/blocking.rs b/embassy-boot/boot/src/firmware_updater/blocking.rs index ae4179ba..4f56f152 100644 --- a/embassy-boot/boot/src/firmware_updater/blocking.rs +++ b/embassy-boot/boot/src/firmware_updater/blocking.rs @@ -219,6 +219,16 @@ pub struct BlockingFirmwareState<'d, STATE> { } impl<'d, STATE: NorFlash> BlockingFirmwareState<'d, STATE> { + /// Creates a firmware state instance from a FirmwareUpdaterConfig, with a buffer for magic content and state partition. + /// + /// # Safety + /// + /// The `aligned` buffer must have a size of STATE::WRITE_SIZE, and follow the alignment rules for the flash being read from + /// and written to. + pub fn from_config(config: FirmwareUpdaterConfig, aligned: &'d mut [u8]) -> Self { + Self::new(config.state, aligned) + } + /// Create a firmware state instance with a buffer for magic content and state partition. /// /// # Safety diff --git a/embassy-boot/boot/src/lib.rs b/embassy-boot/boot/src/lib.rs index 45199294..15b69f69 100644 --- a/embassy-boot/boot/src/lib.rs +++ b/embassy-boot/boot/src/lib.rs @@ -33,7 +33,7 @@ pub enum State { Boot, /// Bootloader has swapped the active partition with the dfu partition and will attempt boot. Swap, - /// Application has received a DFU_DETACH request over USB, and is rebooting into the bootloader to apply a DFU. + /// Application has received a request to reboot into DFU mode to apply an update. DfuDetach, } diff --git a/embassy-usb-dfu/src/application.rs b/embassy-usb-dfu/src/application.rs index 2e7bda12..0b7b53af 100644 --- a/embassy-usb-dfu/src/application.rs +++ b/embassy-usb-dfu/src/application.rs @@ -1,4 +1,4 @@ -use embassy_boot::BlockingFirmwareUpdater; +use embassy_boot::BlockingFirmwareState; use embassy_time::{Duration, Instant}; use embassy_usb::control::{InResponse, OutResponse, Recipient, RequestType}; use embassy_usb::driver::Driver; @@ -11,18 +11,18 @@ use crate::consts::{ }; /// Internal state for the DFU class -pub struct Control<'d, DFU: NorFlash, STATE: NorFlash> { - updater: BlockingFirmwareUpdater<'d, DFU, STATE>, +pub struct Control<'d, STATE: NorFlash> { + firmware_state: BlockingFirmwareState<'d, STATE>, attrs: DfuAttributes, state: State, timeout: Option, detach_start: Option, } -impl<'d, DFU: NorFlash, STATE: NorFlash> Control<'d, DFU, STATE> { - pub fn new(updater: BlockingFirmwareUpdater<'d, DFU, STATE>, attrs: DfuAttributes) -> Self { +impl<'d, STATE: NorFlash> Control<'d, STATE> { + pub fn new(firmware_state: BlockingFirmwareState<'d, STATE>, attrs: DfuAttributes) -> Self { Control { - updater, + firmware_state, attrs, state: State::AppIdle, detach_start: None, @@ -31,19 +31,20 @@ impl<'d, DFU: NorFlash, STATE: NorFlash> Control<'d, DFU, STATE> { } } -impl<'d, DFU: NorFlash, STATE: NorFlash> Handler for Control<'d, DFU, STATE> { +impl<'d, STATE: NorFlash> Handler for Control<'d, STATE> { fn reset(&mut self) { if let Some(start) = self.detach_start { let delta = Instant::now() - start; let timeout = self.timeout.unwrap(); - #[cfg(feature = "defmt")] - defmt::info!( + trace!( "Received RESET with delta = {}, timeout = {}", delta.as_millis(), timeout.as_millis() ); if delta < timeout { - self.updater.mark_dfu().expect("Failed to mark DFU mode in bootloader"); + self.firmware_state + .mark_dfu() + .expect("Failed to mark DFU mode in bootloader"); cortex_m::asm::dsb(); cortex_m::peripheral::SCB::sys_reset(); } @@ -59,13 +60,11 @@ impl<'d, DFU: NorFlash, STATE: NorFlash> Handler for Control<'d, DFU, STATE> { return None; } - #[cfg(feature = "defmt")] - defmt::info!("Received request {}", req); + trace!("Received request {}", req); match Request::try_from(req.request) { Ok(Request::Detach) => { - #[cfg(feature = "defmt")] - defmt::info!("Received DETACH, awaiting USB reset"); + trace!("Received DETACH, awaiting USB reset"); self.detach_start = Some(Instant::now()); self.timeout = Some(Duration::from_millis(req.value as u64)); self.state = State::AppDetach; @@ -84,8 +83,7 @@ impl<'d, DFU: NorFlash, STATE: NorFlash> Handler for Control<'d, DFU, STATE> { return None; } - #[cfg(feature = "defmt")] - defmt::info!("Received request {}", req); + trace!("Received request {}", req); match Request::try_from(req.request) { Ok(Request::GetStatus) => { @@ -106,13 +104,11 @@ impl<'d, DFU: NorFlash, STATE: NorFlash> Handler for Control<'d, DFU, STATE> { /// it should expose a DFU device, and a software reset will be issued. /// /// To apply USB DFU updates, the bootloader must be capable of recognizing the DFU magic and exposing a device to handle the full DFU transaction with the host. -pub fn usb_dfu<'d, D: Driver<'d>, DFU: NorFlash, STATE: NorFlash>( +pub fn usb_dfu<'d, D: Driver<'d>, STATE: NorFlash>( builder: &mut Builder<'d, D>, - handler: &'d mut Control<'d, DFU, STATE>, + handler: &'d mut Control<'d, STATE>, timeout: Duration, ) { - #[cfg(feature = "defmt")] - defmt::info!("Application USB DFU initializing"); let mut func = builder.function(0x00, 0x00, 0x00); let mut iface = func.interface(); let mut alt = iface.alt_setting(USB_CLASS_APPN_SPEC, APPN_SPEC_SUBCLASS_DFU, DFU_PROTOCOL_RT, None); diff --git a/embassy-usb-dfu/src/bootloader.rs b/embassy-usb-dfu/src/bootloader.rs index 21505893..99384d96 100644 --- a/embassy-usb-dfu/src/bootloader.rs +++ b/embassy-usb-dfu/src/bootloader.rs @@ -1,4 +1,4 @@ -use embassy_boot::BlockingFirmwareUpdater; +use embassy_boot::{AlignedBuffer, BlockingFirmwareUpdater}; use embassy_usb::control::{InResponse, OutResponse, Recipient, RequestType}; use embassy_usb::driver::Driver; use embassy_usb::{Builder, Handler}; @@ -56,8 +56,8 @@ impl<'d, DFU: NorFlash, STATE: NorFlash, const BLOCK_SIZE: usize> Handler for Co self.offset = 0; } - let mut buf = [0; BLOCK_SIZE]; - buf[..data.len()].copy_from_slice(data); + let mut buf = AlignedBuffer([0; BLOCK_SIZE]); + buf.as_mut()[..data.len()].copy_from_slice(data); if req.length == 0 { match self.updater.mark_updated() { @@ -85,7 +85,7 @@ impl<'d, DFU: NorFlash, STATE: NorFlash, const BLOCK_SIZE: usize> Handler for Co self.state = State::Error; return Some(OutResponse::Rejected); } - match self.updater.write_firmware(self.offset, &buf[..]) { + match self.updater.write_firmware(self.offset, buf.as_ref()) { Ok(_) => { self.status = Status::Ok; self.state = State::DlSync; diff --git a/embassy-usb-dfu/src/fmt.rs b/embassy-usb-dfu/src/fmt.rs new file mode 100644 index 00000000..78e583c1 --- /dev/null +++ b/embassy-usb-dfu/src/fmt.rs @@ -0,0 +1,258 @@ +#![macro_use] +#![allow(unused_macros)] + +use core::fmt::{Debug, Display, LowerHex}; + +#[cfg(all(feature = "defmt", feature = "log"))] +compile_error!("You may not enable both `defmt` and `log` features."); + +macro_rules! assert { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::assert!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::assert!($($x)*); + } + }; +} + +macro_rules! assert_eq { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::assert_eq!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::assert_eq!($($x)*); + } + }; +} + +macro_rules! assert_ne { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::assert_ne!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::assert_ne!($($x)*); + } + }; +} + +macro_rules! debug_assert { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::debug_assert!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::debug_assert!($($x)*); + } + }; +} + +macro_rules! debug_assert_eq { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::debug_assert_eq!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::debug_assert_eq!($($x)*); + } + }; +} + +macro_rules! debug_assert_ne { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::debug_assert_ne!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::debug_assert_ne!($($x)*); + } + }; +} + +macro_rules! todo { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::todo!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::todo!($($x)*); + } + }; +} + +#[cfg(not(feature = "defmt"))] +macro_rules! unreachable { + ($($x:tt)*) => { + ::core::unreachable!($($x)*) + }; +} + +#[cfg(feature = "defmt")] +macro_rules! unreachable { + ($($x:tt)*) => { + ::defmt::unreachable!($($x)*) + }; +} + +macro_rules! panic { + ($($x:tt)*) => { + { + #[cfg(not(feature = "defmt"))] + ::core::panic!($($x)*); + #[cfg(feature = "defmt")] + ::defmt::panic!($($x)*); + } + }; +} + +macro_rules! trace { + ($s:literal $(, $x:expr)* $(,)?) => { + { + #[cfg(feature = "log")] + ::log::trace!($s $(, $x)*); + #[cfg(feature = "defmt")] + ::defmt::trace!($s $(, $x)*); + #[cfg(not(any(feature = "log", feature="defmt")))] + let _ = ($( & $x ),*); + } + }; +} + +macro_rules! debug { + ($s:literal $(, $x:expr)* $(,)?) => { + { + #[cfg(feature = "log")] + ::log::debug!($s $(, $x)*); + #[cfg(feature = "defmt")] + ::defmt::debug!($s $(, $x)*); + #[cfg(not(any(feature = "log", feature="defmt")))] + let _ = ($( & $x ),*); + } + }; +} + +macro_rules! info { + ($s:literal $(, $x:expr)* $(,)?) => { + { + #[cfg(feature = "log")] + ::log::info!($s $(, $x)*); + #[cfg(feature = "defmt")] + ::defmt::info!($s $(, $x)*); + #[cfg(not(any(feature = "log", feature="defmt")))] + let _ = ($( & $x ),*); + } + }; +} + +macro_rules! warn { + ($s:literal $(, $x:expr)* $(,)?) => { + { + #[cfg(feature = "log")] + ::log::warn!($s $(, $x)*); + #[cfg(feature = "defmt")] + ::defmt::warn!($s $(, $x)*); + #[cfg(not(any(feature = "log", feature="defmt")))] + let _ = ($( & $x ),*); + } + }; +} + +macro_rules! error { + ($s:literal $(, $x:expr)* $(,)?) => { + { + #[cfg(feature = "log")] + ::log::error!($s $(, $x)*); + #[cfg(feature = "defmt")] + ::defmt::error!($s $(, $x)*); + #[cfg(not(any(feature = "log", feature="defmt")))] + let _ = ($( & $x ),*); + } + }; +} + +#[cfg(feature = "defmt")] +macro_rules! unwrap { + ($($x:tt)*) => { + ::defmt::unwrap!($($x)*) + }; +} + +#[cfg(not(feature = "defmt"))] +macro_rules! unwrap { + ($arg:expr) => { + match $crate::fmt::Try::into_result($arg) { + ::core::result::Result::Ok(t) => t, + ::core::result::Result::Err(e) => { + ::core::panic!("unwrap of `{}` failed: {:?}", ::core::stringify!($arg), e); + } + } + }; + ($arg:expr, $($msg:expr),+ $(,)? ) => { + match $crate::fmt::Try::into_result($arg) { + ::core::result::Result::Ok(t) => t, + ::core::result::Result::Err(e) => { + ::core::panic!("unwrap of `{}` failed: {}: {:?}", ::core::stringify!($arg), ::core::format_args!($($msg,)*), e); + } + } + } +} + +#[derive(Debug, Copy, Clone, Eq, PartialEq)] +pub struct NoneError; + +pub trait Try { + type Ok; + type Error; + fn into_result(self) -> Result; +} + +impl Try for Option { + type Ok = T; + type Error = NoneError; + + #[inline] + fn into_result(self) -> Result { + self.ok_or(NoneError) + } +} + +impl Try for Result { + type Ok = T; + type Error = E; + + #[inline] + fn into_result(self) -> Self { + self + } +} + +#[allow(unused)] +pub(crate) struct Bytes<'a>(pub &'a [u8]); + +impl<'a> Debug for Bytes<'a> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{:#02x?}", self.0) + } +} + +impl<'a> Display for Bytes<'a> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{:#02x?}", self.0) + } +} + +impl<'a> LowerHex for Bytes<'a> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "{:#02x?}", self.0) + } +} + +#[cfg(feature = "defmt")] +impl<'a> defmt::Format for Bytes<'a> { + fn format(&self, fmt: defmt::Formatter) { + defmt::write!(fmt, "{:02x}", self.0) + } +} diff --git a/embassy-usb-dfu/src/lib.rs b/embassy-usb-dfu/src/lib.rs index 81ef041f..ae0fbbd4 100644 --- a/embassy-usb-dfu/src/lib.rs +++ b/embassy-usb-dfu/src/lib.rs @@ -1,4 +1,5 @@ #![no_std] +mod fmt; pub mod consts; diff --git a/examples/boot-usb-dfu/.cargo/config.toml b/examples/boot-usb-dfu/.cargo/config.toml deleted file mode 100644 index de3a814f..00000000 --- a/examples/boot-usb-dfu/.cargo/config.toml +++ /dev/null @@ -1,9 +0,0 @@ -[unstable] -build-std = ["core"] -build-std-features = ["panic_immediate_abort"] - -[build] -target = "thumbv7em-none-eabi" - -[env] -DEFMT_LOG = "trace" diff --git a/examples/boot-usb-dfu/application/stm32wb/.cargo/config.toml b/examples/boot/application/stm32wb-dfu/.cargo/config.toml similarity index 100% rename from examples/boot-usb-dfu/application/stm32wb/.cargo/config.toml rename to examples/boot/application/stm32wb-dfu/.cargo/config.toml diff --git a/examples/boot-usb-dfu/application/stm32wb/Cargo.toml b/examples/boot/application/stm32wb-dfu/Cargo.toml similarity index 98% rename from examples/boot-usb-dfu/application/stm32wb/Cargo.toml rename to examples/boot/application/stm32wb-dfu/Cargo.toml index 0a41c064..e67224ce 100644 --- a/examples/boot-usb-dfu/application/stm32wb/Cargo.toml +++ b/examples/boot/application/stm32wb-dfu/Cargo.toml @@ -25,6 +25,7 @@ cortex-m-rt = "0.7.0" [features] defmt = [ "dep:defmt", + "dep:defmt-rtt", "embassy-stm32/defmt", "embassy-boot-stm32/defmt", "embassy-sync/defmt", diff --git a/examples/boot-usb-dfu/application/stm32wb/README.md b/examples/boot/application/stm32wb-dfu/README.md similarity index 100% rename from examples/boot-usb-dfu/application/stm32wb/README.md rename to examples/boot/application/stm32wb-dfu/README.md diff --git a/examples/boot-usb-dfu/application/stm32wb/build.rs b/examples/boot/application/stm32wb-dfu/build.rs similarity index 100% rename from examples/boot-usb-dfu/application/stm32wb/build.rs rename to examples/boot/application/stm32wb-dfu/build.rs diff --git a/examples/boot-usb-dfu/application/stm32wb/memory.x b/examples/boot/application/stm32wb-dfu/memory.x similarity index 100% rename from examples/boot-usb-dfu/application/stm32wb/memory.x rename to examples/boot/application/stm32wb-dfu/memory.x diff --git a/examples/boot-usb-dfu/application/stm32wb/src/main.rs b/examples/boot/application/stm32wb-dfu/src/main.rs similarity index 100% rename from examples/boot-usb-dfu/application/stm32wb/src/main.rs rename to examples/boot/application/stm32wb-dfu/src/main.rs diff --git a/examples/boot-usb-dfu/bootloader/stm32wb/Cargo.toml b/examples/boot/bootloader/stm32wb-dfu/Cargo.toml similarity index 100% rename from examples/boot-usb-dfu/bootloader/stm32wb/Cargo.toml rename to examples/boot/bootloader/stm32wb-dfu/Cargo.toml diff --git a/examples/boot-usb-dfu/bootloader/stm32wb/README.md b/examples/boot/bootloader/stm32wb-dfu/README.md similarity index 100% rename from examples/boot-usb-dfu/bootloader/stm32wb/README.md rename to examples/boot/bootloader/stm32wb-dfu/README.md diff --git a/examples/boot-usb-dfu/bootloader/stm32wb/build.rs b/examples/boot/bootloader/stm32wb-dfu/build.rs similarity index 100% rename from examples/boot-usb-dfu/bootloader/stm32wb/build.rs rename to examples/boot/bootloader/stm32wb-dfu/build.rs diff --git a/examples/boot-usb-dfu/bootloader/stm32wb/memory.x b/examples/boot/bootloader/stm32wb-dfu/memory.x similarity index 100% rename from examples/boot-usb-dfu/bootloader/stm32wb/memory.x rename to examples/boot/bootloader/stm32wb-dfu/memory.x diff --git a/examples/boot-usb-dfu/bootloader/stm32wb/src/main.rs b/examples/boot/bootloader/stm32wb-dfu/src/main.rs similarity index 91% rename from examples/boot-usb-dfu/bootloader/stm32wb/src/main.rs rename to examples/boot/bootloader/stm32wb-dfu/src/main.rs index 00a535d3..a2b88477 100644 --- a/examples/boot-usb-dfu/bootloader/stm32wb/src/main.rs +++ b/examples/boot/bootloader/stm32wb-dfu/src/main.rs @@ -26,13 +26,12 @@ fn main() -> ! { config.rcc = WPAN_DEFAULT; let p = embassy_stm32::init(config); - // Uncomment this if you are debugging the bootloader with debugger/RTT attached, - // as it prevents a hard fault when accessing flash 'too early' after boot. - /* - for i in 0..10000000 { - cortex_m::asm::nop(); - } - */ + // Prevent a hard fault when accessing flash 'too early' after boot. + #[cfg(feature = "defmt")] + for _ in 0..10000000 { + cortex_m::asm::nop(); + } + let layout = Flash::new_blocking(p.FLASH).into_blocking_regions(); let flash = Mutex::new(RefCell::new(layout.bank1_region)); From c1438fe87bf363b018231bd36e188c72679eb202 Mon Sep 17 00:00:00 2001 From: Kaitlyn Kenwell Date: Thu, 14 Dec 2023 09:38:02 -0500 Subject: [PATCH 76/98] fmt --- embassy-boot/boot/src/firmware_updater/blocking.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/embassy-boot/boot/src/firmware_updater/blocking.rs b/embassy-boot/boot/src/firmware_updater/blocking.rs index 4f56f152..c4c14216 100644 --- a/embassy-boot/boot/src/firmware_updater/blocking.rs +++ b/embassy-boot/boot/src/firmware_updater/blocking.rs @@ -220,9 +220,9 @@ pub struct BlockingFirmwareState<'d, STATE> { impl<'d, STATE: NorFlash> BlockingFirmwareState<'d, STATE> { /// Creates a firmware state instance from a FirmwareUpdaterConfig, with a buffer for magic content and state partition. - /// + /// /// # Safety - /// + /// /// The `aligned` buffer must have a size of STATE::WRITE_SIZE, and follow the alignment rules for the flash being read from /// and written to. pub fn from_config(config: FirmwareUpdaterConfig, aligned: &'d mut [u8]) -> Self { From 9cc5d8ac892d4efbb629ab3bafdf341edd50ca7e Mon Sep 17 00:00:00 2001 From: Kaitlyn Kenwell Date: Thu, 14 Dec 2023 09:38:49 -0500 Subject: [PATCH 77/98] fmt --- examples/boot/bootloader/stm32wb-dfu/src/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/boot/bootloader/stm32wb-dfu/src/main.rs b/examples/boot/bootloader/stm32wb-dfu/src/main.rs index a2b88477..db7039e8 100644 --- a/examples/boot/bootloader/stm32wb-dfu/src/main.rs +++ b/examples/boot/bootloader/stm32wb-dfu/src/main.rs @@ -31,7 +31,6 @@ fn main() -> ! { for _ in 0..10000000 { cortex_m::asm::nop(); } - let layout = Flash::new_blocking(p.FLASH).into_blocking_regions(); let flash = Mutex::new(RefCell::new(layout.bank1_region)); From ef692c514101d6c91059c13af52cdd70dc5cd6e0 Mon Sep 17 00:00:00 2001 From: Kaitlyn Kenwell Date: Thu, 14 Dec 2023 10:06:36 -0500 Subject: [PATCH 78/98] SCB::sys_reset has a DSB internally, no need to replicate --- embassy-usb-dfu/src/application.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/embassy-usb-dfu/src/application.rs b/embassy-usb-dfu/src/application.rs index 0b7b53af..5ff8f90f 100644 --- a/embassy-usb-dfu/src/application.rs +++ b/embassy-usb-dfu/src/application.rs @@ -45,7 +45,6 @@ impl<'d, STATE: NorFlash> Handler for Control<'d, STATE> { self.firmware_state .mark_dfu() .expect("Failed to mark DFU mode in bootloader"); - cortex_m::asm::dsb(); cortex_m::peripheral::SCB::sys_reset(); } } From d81395fab3c4e336650b0481790ecdab7d7aa13f Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Thu, 14 Dec 2023 16:01:51 +0100 Subject: [PATCH 79/98] Update embedded-hal to 1.0.0-rc.3 --- cyw43/Cargo.toml | 2 +- .../layer-by-layer/blinky-hal/src/main.rs | 2 +- embassy-embedded-hal/Cargo.toml | 4 +- embassy-net-adin1110/Cargo.toml | 8 +- embassy-net-enc28j60/Cargo.toml | 4 +- embassy-net-esp-hosted/Cargo.toml | 4 +- embassy-net-wiznet/Cargo.toml | 4 +- embassy-nrf/Cargo.toml | 5 +- embassy-nrf/src/gpio.rs | 67 +++++++----- embassy-nrf/src/gpiote.rs | 10 +- embassy-rp/Cargo.toml | 6 +- embassy-rp/src/gpio.rs | 101 ++++++++++-------- embassy-stm32/Cargo.toml | 6 +- embassy-stm32/src/exti.rs | 14 +-- embassy-stm32/src/gpio.rs | 94 ++++++++-------- embassy-time/CHANGELOG.md | 4 +- embassy-time/Cargo.toml | 4 +- examples/nrf52840/Cargo.toml | 6 +- examples/rp/Cargo.toml | 6 +- examples/rp/src/bin/button.rs | 2 +- examples/stm32c0/src/bin/button.rs | 2 +- examples/stm32f3/src/bin/button.rs | 2 +- examples/stm32f4/src/bin/button.rs | 2 +- examples/stm32f7/src/bin/button.rs | 2 +- examples/stm32g0/src/bin/button.rs | 2 +- examples/stm32g4/src/bin/button.rs | 2 +- examples/stm32h5/Cargo.toml | 4 +- examples/stm32h7/Cargo.toml | 4 +- examples/stm32l0/src/bin/button.rs | 2 +- examples/stm32l4/Cargo.toml | 6 +- examples/stm32l4/src/bin/button.rs | 2 +- .../src/bin/spe_adin1110_http_server.rs | 8 +- .../stm32l4/src/bin/spi_blocking_async.rs | 2 +- examples/stm32l4/src/bin/spi_dma.rs | 2 +- examples/stm32wl/src/bin/button.rs | 2 +- tests/nrf/Cargo.toml | 4 +- tests/rp/Cargo.toml | 6 +- tests/rp/src/bin/gpio.rs | 10 +- tests/rp/src/bin/pwm.rs | 8 +- tests/stm32/Cargo.toml | 4 +- tests/stm32/src/bin/gpio.rs | 12 +-- 41 files changed, 238 insertions(+), 203 deletions(-) diff --git a/cyw43/Cargo.toml b/cyw43/Cargo.toml index 293c0098..72faad80 100644 --- a/cyw43/Cargo.toml +++ b/cyw43/Cargo.toml @@ -23,7 +23,7 @@ cortex-m = "0.7.6" cortex-m-rt = "0.7.0" futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] } -embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-rc.2" } +embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-rc.3" } num_enum = { version = "0.5.7", default-features = false } [package.metadata.embassy_docs] diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-hal/src/main.rs b/docs/modules/ROOT/examples/layer-by-layer/blinky-hal/src/main.rs index d0c9f490..54b87662 100644 --- a/docs/modules/ROOT/examples/layer-by-layer/blinky-hal/src/main.rs +++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-hal/src/main.rs @@ -9,7 +9,7 @@ use {defmt_rtt as _, panic_probe as _}; fn main() -> ! { let p = embassy_stm32::init(Default::default()); let mut led = Output::new(p.PB14, Level::High, Speed::VeryHigh); - let button = Input::new(p.PC13, Pull::Up); + let mut button = Input::new(p.PC13, Pull::Up); loop { if button.is_low() { diff --git a/embassy-embedded-hal/Cargo.toml b/embassy-embedded-hal/Cargo.toml index 2a0b2547..f292f952 100644 --- a/embassy-embedded-hal/Cargo.toml +++ b/embassy-embedded-hal/Cargo.toml @@ -23,8 +23,8 @@ embassy-time = { version = "0.2", path = "../embassy-time", optional = true } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = [ "unproven", ] } -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } -embedded-hal-async = { version = "=1.0.0-rc.2" } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.3" } +embedded-hal-async = { version = "=1.0.0-rc.3" } embedded-storage = "0.3.1" embedded-storage-async = { version = "0.4.1" } nb = "1.0.0" diff --git a/embassy-net-adin1110/Cargo.toml b/embassy-net-adin1110/Cargo.toml index d95b2628..adcdfe80 100644 --- a/embassy-net-adin1110/Cargo.toml +++ b/embassy-net-adin1110/Cargo.toml @@ -13,16 +13,16 @@ edition = "2021" heapless = "0.8" defmt = { version = "0.3", optional = true } log = { version = "0.4", default-features = false, optional = true } -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } -embedded-hal-async = { version = "=1.0.0-rc.2" } -embedded-hal-bus = { version = "=0.1.0-rc.2", features = ["async"] } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.3" } +embedded-hal-async = { version = "=1.0.0-rc.3" } +embedded-hal-bus = { version = "=0.1.0-rc.3", features = ["async"] } embassy-net-driver-channel = { version = "0.2.0", path = "../embassy-net-driver-channel" } embassy-time = { version = "0.2", path = "../embassy-time" } embassy-futures = { version = "0.1.0", path = "../embassy-futures" } bitfield = "0.14.0" [dev-dependencies] -embedded-hal-mock = { git = "https://github.com/Dirbaio/embedded-hal-mock", rev = "c5c4dca18e043e6386aee02173f61a65fea3981e", features = ["embedded-hal-async", "eh1"] } +embedded-hal-mock = { git = "https://github.com/Dirbaio/embedded-hal-mock", rev = "b5a2274759a8c484f4fae71a22f8a083fdd9d5da", features = ["embedded-hal-async", "eh1"] } crc = "3.0.1" env_logger = "0.10" critical-section = { version = "1.1.2", features = ["std"] } diff --git a/embassy-net-enc28j60/Cargo.toml b/embassy-net-enc28j60/Cargo.toml index 72e1d4e5..8cd723c4 100644 --- a/embassy-net-enc28j60/Cargo.toml +++ b/embassy-net-enc28j60/Cargo.toml @@ -8,8 +8,8 @@ license = "MIT OR Apache-2.0" edition = "2021" [dependencies] -embedded-hal = { version = "1.0.0-rc.2" } -embedded-hal-async = { version = "=1.0.0-rc.2" } +embedded-hal = { version = "1.0.0-rc.3" } +embedded-hal-async = { version = "=1.0.0-rc.3" } embassy-net-driver = { version = "0.2.0", path = "../embassy-net-driver" } embassy-time = { version = "0.2", path = "../embassy-time" } embassy-futures = { version = "0.1.0", path = "../embassy-futures" } diff --git a/embassy-net-esp-hosted/Cargo.toml b/embassy-net-esp-hosted/Cargo.toml index eb44a654..70b1bbe2 100644 --- a/embassy-net-esp-hosted/Cargo.toml +++ b/embassy-net-esp-hosted/Cargo.toml @@ -12,8 +12,8 @@ embassy-sync = { version = "0.5.0", path = "../embassy-sync"} embassy-futures = { version = "0.1.0", path = "../embassy-futures"} embassy-net-driver-channel = { version = "0.2.0", path = "../embassy-net-driver-channel"} -embedded-hal = { version = "1.0.0-rc.2" } -embedded-hal-async = { version = "=1.0.0-rc.2" } +embedded-hal = { version = "1.0.0-rc.3" } +embedded-hal-async = { version = "=1.0.0-rc.3" } noproto = { git="https://github.com/embassy-rs/noproto", rev = "f5e6d1f325b6ad4e344f60452b09576e24671f62", default-features = false, features = ["derive"] } #noproto = { version = "0.1", path = "/home/dirbaio/noproto", default-features = false, features = ["derive"] } diff --git a/embassy-net-wiznet/Cargo.toml b/embassy-net-wiznet/Cargo.toml index 9c103ebb..a1f0b0c5 100644 --- a/embassy-net-wiznet/Cargo.toml +++ b/embassy-net-wiznet/Cargo.toml @@ -8,8 +8,8 @@ license = "MIT OR Apache-2.0" edition = "2021" [dependencies] -embedded-hal = { version = "1.0.0-rc.2" } -embedded-hal-async = { version = "=1.0.0-rc.2" } +embedded-hal = { version = "1.0.0-rc.3" } +embedded-hal-async = { version = "=1.0.0-rc.3" } embassy-net-driver-channel = { version = "0.2.0", path = "../embassy-net-driver-channel" } embassy-time = { version = "0.2", path = "../embassy-time" } embassy-futures = { version = "0.1.0", path = "../embassy-futures" } diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index a7f3cb35..6d744051 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml @@ -94,8 +94,8 @@ embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" } embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver" } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } -embedded-hal-async = { version = "=1.0.0-rc.2" } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.3" } +embedded-hal-async = { version = "=1.0.0-rc.3" } embedded-io = { version = "0.6.0" } embedded-io-async = { version = "0.6.1" } @@ -120,4 +120,3 @@ nrf52840-pac = { version = "0.12.0", optional = true } nrf5340-app-pac = { version = "0.12.0", optional = true } nrf5340-net-pac = { version = "0.12.0", optional = true } nrf9160-pac = { version = "0.12.0", optional = true } - diff --git a/embassy-nrf/src/gpio.rs b/embassy-nrf/src/gpio.rs index cf622528..85977a80 100644 --- a/embassy-nrf/src/gpio.rs +++ b/embassy-nrf/src/gpio.rs @@ -52,19 +52,19 @@ impl<'d, T: Pin> Input<'d, T> { /// Test if current pin level is high. #[inline] - pub fn is_high(&self) -> bool { + pub fn is_high(&mut self) -> bool { self.pin.is_high() } /// Test if current pin level is low. #[inline] - pub fn is_low(&self) -> bool { + pub fn is_low(&mut self) -> bool { self.pin.is_low() } /// Returns current pin level #[inline] - pub fn get_level(&self) -> Level { + pub fn get_level(&mut self) -> Level { self.pin.get_level() } } @@ -160,19 +160,19 @@ impl<'d, T: Pin> Output<'d, T> { /// Is the output pin set as high? #[inline] - pub fn is_set_high(&self) -> bool { + pub fn is_set_high(&mut self) -> bool { self.pin.is_set_high() } /// Is the output pin set as low? #[inline] - pub fn is_set_low(&self) -> bool { + pub fn is_set_low(&mut self) -> bool { self.pin.is_set_low() } /// What level output is set to #[inline] - pub fn get_output_level(&self) -> Level { + pub fn get_output_level(&mut self) -> Level { self.pin.get_output_level() } } @@ -277,19 +277,24 @@ impl<'d, T: Pin> Flex<'d, T> { /// Test if current pin level is high. #[inline] - pub fn is_high(&self) -> bool { + pub fn is_high(&mut self) -> bool { !self.is_low() } /// Test if current pin level is low. #[inline] - pub fn is_low(&self) -> bool { + pub fn is_low(&mut self) -> bool { + self.ref_is_low() + } + + #[inline] + pub(crate) fn ref_is_low(&self) -> bool { self.pin.block().in_.read().bits() & (1 << self.pin.pin()) == 0 } /// Returns current pin level #[inline] - pub fn get_level(&self) -> Level { + pub fn get_level(&mut self) -> Level { self.is_high().into() } @@ -316,19 +321,25 @@ impl<'d, T: Pin> Flex<'d, T> { /// Is the output pin set as high? #[inline] - pub fn is_set_high(&self) -> bool { + pub fn is_set_high(&mut self) -> bool { !self.is_set_low() } /// Is the output pin set as low? #[inline] - pub fn is_set_low(&self) -> bool { + pub fn is_set_low(&mut self) -> bool { + self.ref_is_set_low() + } + + /// Is the output pin set as low? + #[inline] + pub(crate) fn ref_is_set_low(&self) -> bool { self.pin.block().out.read().bits() & (1 << self.pin.pin()) == 0 } /// What level output is set to #[inline] - pub fn get_output_level(&self) -> Level { + pub fn get_output_level(&mut self) -> Level { self.is_set_high().into() } } @@ -498,11 +509,11 @@ mod eh02 { type Error = Infallible; fn is_high(&self) -> Result { - Ok(self.is_high()) + Ok(!self.pin.ref_is_low()) } fn is_low(&self) -> Result { - Ok(self.is_low()) + Ok(self.pin.ref_is_low()) } } @@ -520,11 +531,11 @@ mod eh02 { impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> { fn is_set_high(&self) -> Result { - Ok(self.is_set_high()) + Ok(!self.pin.ref_is_set_low()) } fn is_set_low(&self) -> Result { - Ok(self.is_set_low()) + Ok(self.pin.ref_is_set_low()) } } @@ -535,11 +546,11 @@ mod eh02 { type Error = Infallible; fn is_high(&self) -> Result { - Ok(self.is_high()) + Ok(!self.ref_is_low()) } fn is_low(&self) -> Result { - Ok(self.is_low()) + Ok(self.ref_is_low()) } } @@ -557,11 +568,11 @@ mod eh02 { impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> { fn is_set_high(&self) -> Result { - Ok(self.is_set_high()) + Ok(!self.ref_is_set_low()) } fn is_set_low(&self) -> Result { - Ok(self.is_set_low()) + Ok(self.ref_is_set_low()) } } } @@ -571,11 +582,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> { } impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { - fn is_high(&self) -> Result { + fn is_high(&mut self) -> Result { Ok(self.is_high()) } - fn is_low(&self) -> Result { + fn is_low(&mut self) -> Result { Ok(self.is_low()) } } @@ -595,11 +606,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { } impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { - fn is_set_high(&self) -> Result { + fn is_set_high(&mut self) -> Result { Ok(self.is_set_high()) } - fn is_set_low(&self) -> Result { + fn is_set_low(&mut self) -> Result { Ok(self.is_set_low()) } } @@ -612,11 +623,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { /// /// If the pin is not in input mode the result is unspecified. impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { - fn is_high(&self) -> Result { + fn is_high(&mut self) -> Result { Ok(self.is_high()) } - fn is_low(&self) -> Result { + fn is_low(&mut self) -> Result { Ok(self.is_low()) } } @@ -632,11 +643,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { } impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { - fn is_set_high(&self) -> Result { + fn is_set_high(&mut self) -> Result { Ok(self.is_set_high()) } - fn is_set_low(&self) -> Result { + fn is_set_low(&mut self) -> Result { Ok(self.is_set_low()) } } diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index fd629ea7..07196abf 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs @@ -243,7 +243,7 @@ impl<'d, C: Channel, T: GpioPin> Drop for OutputChannel<'d, C, T> { impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> { /// Create a new GPIOTE output channel driver. - pub fn new(ch: impl Peripheral

+ 'd, pin: Output<'d, T>, polarity: OutputChannelPolarity) -> Self { + pub fn new(ch: impl Peripheral

+ 'd, mut pin: Output<'d, T>, polarity: OutputChannelPolarity) -> Self { into_ref!(ch); let g = regs(); let num = ch.number(); @@ -481,11 +481,11 @@ mod eh02 { type Error = Infallible; fn is_high(&self) -> Result { - Ok(self.pin.is_high()) + Ok(!self.pin.pin.ref_is_low()) } fn is_low(&self) -> Result { - Ok(self.pin.is_low()) + Ok(self.pin.pin.ref_is_low()) } } } @@ -495,11 +495,11 @@ impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::ErrorType for InputCha } impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::InputPin for InputChannel<'d, C, T> { - fn is_high(&self) -> Result { + fn is_high(&mut self) -> Result { Ok(self.pin.is_high()) } - fn is_low(&self) -> Result { + fn is_low(&mut self) -> Result { Ok(self.pin.is_low()) } } diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index dfdd1fee..c557940b 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml @@ -78,9 +78,9 @@ fixed = "1.23.1" rp-pac = { version = "6" } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } -embedded-hal-async = { version = "=1.0.0-rc.2" } -embedded-hal-nb = { version = "=1.0.0-rc.2" } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.3" } +embedded-hal-async = { version = "=1.0.0-rc.3" } +embedded-hal-nb = { version = "=1.0.0-rc.3" } pio-proc = {version= "0.2" } pio = {version= "0.2.1" } diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs index 9034f3f3..23273e62 100644 --- a/embassy-rp/src/gpio.rs +++ b/embassy-rp/src/gpio.rs @@ -105,18 +105,18 @@ impl<'d, T: Pin> Input<'d, T> { } #[inline] - pub fn is_high(&self) -> bool { + pub fn is_high(&mut self) -> bool { self.pin.is_high() } #[inline] - pub fn is_low(&self) -> bool { + pub fn is_low(&mut self) -> bool { self.pin.is_low() } /// Returns current pin level #[inline] - pub fn get_level(&self) -> Level { + pub fn get_level(&mut self) -> Level { self.pin.get_level() } @@ -357,19 +357,19 @@ impl<'d, T: Pin> Output<'d, T> { /// Is the output pin set as high? #[inline] - pub fn is_set_high(&self) -> bool { + pub fn is_set_high(&mut self) -> bool { self.pin.is_set_high() } /// Is the output pin set as low? #[inline] - pub fn is_set_low(&self) -> bool { + pub fn is_set_low(&mut self) -> bool { self.pin.is_set_low() } /// What level output is set to #[inline] - pub fn get_output_level(&self) -> Level { + pub fn get_output_level(&mut self) -> Level { self.pin.get_output_level() } @@ -434,19 +434,19 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { /// Is the output level high? #[inline] - pub fn is_set_high(&self) -> bool { + pub fn is_set_high(&mut self) -> bool { !self.is_set_low() } /// Is the output level low? #[inline] - pub fn is_set_low(&self) -> bool { + pub fn is_set_low(&mut self) -> bool { self.pin.is_set_as_output() } /// What level output is set to #[inline] - pub fn get_output_level(&self) -> Level { + pub fn get_output_level(&mut self) -> Level { self.is_set_high().into() } @@ -457,18 +457,18 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { } #[inline] - pub fn is_high(&self) -> bool { + pub fn is_high(&mut self) -> bool { self.pin.is_high() } #[inline] - pub fn is_low(&self) -> bool { + pub fn is_low(&mut self) -> bool { self.pin.is_low() } /// Returns current pin level #[inline] - pub fn get_level(&self) -> Level { + pub fn get_level(&mut self) -> Level { self.is_high().into() } @@ -590,7 +590,12 @@ impl<'d, T: Pin> Flex<'d, T> { } #[inline] - fn is_set_as_output(&self) -> bool { + pub fn is_set_as_output(&mut self) -> bool { + self.ref_is_set_as_output() + } + + #[inline] + pub(crate) fn ref_is_set_as_output(&self) -> bool { (self.pin.sio_oe().value().read() & self.bit()) != 0 } @@ -600,18 +605,23 @@ impl<'d, T: Pin> Flex<'d, T> { } #[inline] - pub fn is_high(&self) -> bool { + pub fn is_high(&mut self) -> bool { !self.is_low() } #[inline] - pub fn is_low(&self) -> bool { + pub fn is_low(&mut self) -> bool { + self.ref_is_low() + } + + #[inline] + pub(crate) fn ref_is_low(&self) -> bool { self.pin.sio_in().read() & self.bit() == 0 } /// Returns current pin level #[inline] - pub fn get_level(&self) -> Level { + pub fn get_level(&mut self) -> Level { self.is_high().into() } @@ -638,19 +648,24 @@ impl<'d, T: Pin> Flex<'d, T> { /// Is the output level high? #[inline] - pub fn is_set_high(&self) -> bool { + pub fn is_set_high(&mut self) -> bool { !self.is_set_low() } /// Is the output level low? #[inline] - pub fn is_set_low(&self) -> bool { + pub fn is_set_low(&mut self) -> bool { + self.ref_is_set_low() + } + + #[inline] + pub(crate) fn ref_is_set_low(&self) -> bool { (self.pin.sio_out().value().read() & self.bit()) == 0 } /// What level output is set to #[inline] - pub fn get_output_level(&self) -> Level { + pub fn get_output_level(&mut self) -> Level { self.is_set_high().into() } @@ -912,11 +927,11 @@ mod eh02 { type Error = Infallible; fn is_high(&self) -> Result { - Ok(self.is_high()) + Ok(!self.pin.ref_is_low()) } fn is_low(&self) -> Result { - Ok(self.is_low()) + Ok(self.pin.ref_is_low()) } } @@ -934,11 +949,11 @@ mod eh02 { impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> { fn is_set_high(&self) -> Result { - Ok(self.is_set_high()) + Ok(!self.pin.ref_is_set_low()) } fn is_set_low(&self) -> Result { - Ok(self.is_set_low()) + Ok(self.pin.ref_is_set_low()) } } @@ -954,11 +969,11 @@ mod eh02 { type Error = Infallible; fn is_high(&self) -> Result { - Ok(self.is_high()) + Ok(!self.pin.ref_is_low()) } fn is_low(&self) -> Result { - Ok(self.is_low()) + Ok(self.pin.ref_is_low()) } } @@ -978,11 +993,11 @@ mod eh02 { impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d, T> { fn is_set_high(&self) -> Result { - Ok(self.is_set_high()) + Ok(!self.pin.ref_is_set_as_output()) } fn is_set_low(&self) -> Result { - Ok(self.is_set_low()) + Ok(self.pin.ref_is_set_as_output()) } } @@ -998,11 +1013,11 @@ mod eh02 { type Error = Infallible; fn is_high(&self) -> Result { - Ok(self.is_high()) + Ok(!self.ref_is_low()) } fn is_low(&self) -> Result { - Ok(self.is_low()) + Ok(self.ref_is_low()) } } @@ -1020,11 +1035,11 @@ mod eh02 { impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> { fn is_set_high(&self) -> Result { - Ok(self.is_set_high()) + Ok(!self.ref_is_set_low()) } fn is_set_low(&self) -> Result { - Ok(self.is_set_low()) + Ok(self.ref_is_set_low()) } } @@ -1042,11 +1057,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> { } impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { - fn is_high(&self) -> Result { + fn is_high(&mut self) -> Result { Ok(self.is_high()) } - fn is_low(&self) -> Result { + fn is_low(&mut self) -> Result { Ok(self.is_low()) } } @@ -1066,11 +1081,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { } impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { - fn is_set_high(&self) -> Result { + fn is_set_high(&mut self) -> Result { Ok(self.is_set_high()) } - fn is_set_low(&self) -> Result { + fn is_set_low(&mut self) -> Result { Ok(self.is_set_low()) } } @@ -1096,11 +1111,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> { } impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> { - fn is_set_high(&self) -> Result { + fn is_set_high(&mut self) -> Result { Ok(self.is_set_high()) } - fn is_set_low(&self) -> Result { + fn is_set_low(&mut self) -> Result { Ok(self.is_set_low()) } } @@ -1112,11 +1127,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::ToggleableOutputPin for OutputOpenDrai } impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> { - fn is_high(&self) -> Result { + fn is_high(&mut self) -> Result { Ok(self.is_high()) } - fn is_low(&self) -> Result { + fn is_low(&mut self) -> Result { Ok(self.is_low()) } } @@ -1126,11 +1141,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { } impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { - fn is_high(&self) -> Result { + fn is_high(&mut self) -> Result { Ok(self.is_high()) } - fn is_low(&self) -> Result { + fn is_low(&mut self) -> Result { Ok(self.is_low()) } } @@ -1146,11 +1161,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { } impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { - fn is_set_high(&self) -> Result { + fn is_set_high(&mut self) -> Result { Ok(self.is_set_high()) } - fn is_set_low(&self) -> Result { + fn is_set_low(&mut self) -> Result { Ok(self.is_set_low()) } } diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 074538d3..3de15deb 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -42,9 +42,9 @@ embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver" } embassy-executor = { version = "0.4.0", path = "../embassy-executor", optional = true } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } -embedded-hal-async = { version = "=1.0.0-rc.2" } -embedded-hal-nb = { version = "=1.0.0-rc.2" } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.3" } +embedded-hal-async = { version = "=1.0.0-rc.3" } +embedded-hal-nb = { version = "=1.0.0-rc.3" } embedded-storage = "0.3.1" embedded-storage-async = { version = "0.4.1" } diff --git a/embassy-stm32/src/exti.rs b/embassy-stm32/src/exti.rs index dbd24804..e77ac30f 100644 --- a/embassy-stm32/src/exti.rs +++ b/embassy-stm32/src/exti.rs @@ -97,15 +97,15 @@ impl<'d, T: GpioPin> ExtiInput<'d, T> { Self { pin } } - pub fn is_high(&self) -> bool { + pub fn is_high(&mut self) -> bool { self.pin.is_high() } - pub fn is_low(&self) -> bool { + pub fn is_low(&mut self) -> bool { self.pin.is_low() } - pub fn get_level(&self) -> Level { + pub fn get_level(&mut self) -> Level { self.pin.get_level() } @@ -142,11 +142,11 @@ impl<'d, T: GpioPin> embedded_hal_02::digital::v2::InputPin for ExtiInput<'d, T> type Error = Infallible; fn is_high(&self) -> Result { - Ok(self.is_high()) + Ok(!self.pin.pin.ref_is_low()) } fn is_low(&self) -> Result { - Ok(self.is_low()) + Ok(self.pin.pin.ref_is_low()) } } @@ -155,11 +155,11 @@ impl<'d, T: GpioPin> embedded_hal_1::digital::ErrorType for ExtiInput<'d, T> { } impl<'d, T: GpioPin> embedded_hal_1::digital::InputPin for ExtiInput<'d, T> { - fn is_high(&self) -> Result { + fn is_high(&mut self) -> Result { Ok(self.is_high()) } - fn is_low(&self) -> Result { + fn is_low(&mut self) -> Result { Ok(self.is_low()) } } diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index b863c4ff..bb3cf2bc 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -142,36 +142,46 @@ impl<'d, T: Pin> Flex<'d, T> { } #[inline] - pub fn is_high(&self) -> bool { - !self.is_low() + pub fn is_high(&mut self) -> bool { + !self.ref_is_low() } #[inline] - pub fn is_low(&self) -> bool { + pub fn is_low(&mut self) -> bool { + self.ref_is_low() + } + + #[inline] + pub(crate) fn ref_is_low(&self) -> bool { let state = self.pin.block().idr().read().idr(self.pin.pin() as _); state == vals::Idr::LOW } #[inline] - pub fn get_level(&self) -> Level { + pub fn get_level(&mut self) -> Level { self.is_high().into() } #[inline] - pub fn is_set_high(&self) -> bool { - !self.is_set_low() + pub fn is_set_high(&mut self) -> bool { + !self.ref_is_set_low() } /// Is the output pin set as low? #[inline] - pub fn is_set_low(&self) -> bool { + pub fn is_set_low(&mut self) -> bool { + self.ref_is_set_low() + } + + #[inline] + pub(crate) fn ref_is_set_low(&self) -> bool { let state = self.pin.block().odr().read().odr(self.pin.pin() as _); state == vals::Odr::LOW } /// What level output is set to #[inline] - pub fn get_output_level(&self) -> Level { + pub fn get_output_level(&mut self) -> Level { self.is_set_high().into() } @@ -310,17 +320,17 @@ impl<'d, T: Pin> Input<'d, T> { } #[inline] - pub fn is_high(&self) -> bool { + pub fn is_high(&mut self) -> bool { self.pin.is_high() } #[inline] - pub fn is_low(&self) -> bool { + pub fn is_low(&mut self) -> bool { self.pin.is_low() } #[inline] - pub fn get_level(&self) -> Level { + pub fn get_level(&mut self) -> Level { self.pin.get_level() } } @@ -399,19 +409,19 @@ impl<'d, T: Pin> Output<'d, T> { /// Is the output pin set as high? #[inline] - pub fn is_set_high(&self) -> bool { + pub fn is_set_high(&mut self) -> bool { self.pin.is_set_high() } /// Is the output pin set as low? #[inline] - pub fn is_set_low(&self) -> bool { + pub fn is_set_low(&mut self) -> bool { self.pin.is_set_low() } /// What level output is set to #[inline] - pub fn get_output_level(&self) -> Level { + pub fn get_output_level(&mut self) -> Level { self.pin.get_output_level() } @@ -453,18 +463,18 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { } #[inline] - pub fn is_high(&self) -> bool { + pub fn is_high(&mut self) -> bool { !self.pin.is_low() } #[inline] - pub fn is_low(&self) -> bool { + pub fn is_low(&mut self) -> bool { self.pin.is_low() } /// Returns current pin level #[inline] - pub fn get_level(&self) -> Level { + pub fn get_level(&mut self) -> Level { self.pin.get_level() } @@ -488,19 +498,19 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { /// Is the output pin set as high? #[inline] - pub fn is_set_high(&self) -> bool { + pub fn is_set_high(&mut self) -> bool { self.pin.is_set_high() } /// Is the output pin set as low? #[inline] - pub fn is_set_low(&self) -> bool { + pub fn is_set_low(&mut self) -> bool { self.pin.is_set_low() } /// What level output is set to #[inline] - pub fn get_output_level(&self) -> Level { + pub fn get_output_level(&mut self) -> Level { self.pin.get_output_level() } @@ -777,12 +787,12 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Input<'d, T> { #[inline] fn is_high(&self) -> Result { - Ok(self.is_high()) + Ok(!self.pin.ref_is_low()) } #[inline] fn is_low(&self) -> Result { - Ok(self.is_low()) + Ok(self.pin.ref_is_low()) } } @@ -805,13 +815,13 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Output<'d, T> { impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> { #[inline] fn is_set_high(&self) -> Result { - Ok(self.is_set_high()) + Ok(!self.pin.ref_is_set_low()) } /// Is the output pin set as low? #[inline] fn is_set_low(&self) -> Result { - Ok(self.is_set_low()) + Ok(self.pin.ref_is_set_low()) } } @@ -843,13 +853,13 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d, impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d, T> { #[inline] fn is_set_high(&self) -> Result { - Ok(self.is_set_high()) + Ok(!self.pin.ref_is_set_low()) } /// Is the output pin set as low? #[inline] fn is_set_low(&self) -> Result { - Ok(self.is_set_low()) + Ok(self.pin.ref_is_set_low()) } } @@ -867,12 +877,12 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Flex<'d, T> { #[inline] fn is_high(&self) -> Result { - Ok(self.is_high()) + Ok(!self.ref_is_low()) } #[inline] fn is_low(&self) -> Result { - Ok(self.is_low()) + Ok(self.ref_is_low()) } } @@ -895,13 +905,13 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Flex<'d, T> { impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> { #[inline] fn is_set_high(&self) -> Result { - Ok(self.is_set_high()) + Ok(!self.ref_is_set_low()) } /// Is the output pin set as low? #[inline] fn is_set_low(&self) -> Result { - Ok(self.is_set_low()) + Ok(self.ref_is_set_low()) } } @@ -920,12 +930,12 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { #[inline] - fn is_high(&self) -> Result { + fn is_high(&mut self) -> Result { Ok(self.is_high()) } #[inline] - fn is_low(&self) -> Result { + fn is_low(&mut self) -> Result { Ok(self.is_low()) } } @@ -948,13 +958,13 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { #[inline] - fn is_set_high(&self) -> Result { + fn is_set_high(&mut self) -> Result { Ok(self.is_set_high()) } /// Is the output pin set as low? #[inline] - fn is_set_low(&self) -> Result { + fn is_set_low(&mut self) -> Result { Ok(self.is_set_low()) } } @@ -972,12 +982,12 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for OutputOpenDrain<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> { #[inline] - fn is_high(&self) -> Result { + fn is_high(&mut self) -> Result { Ok(self.is_high()) } #[inline] - fn is_low(&self) -> Result { + fn is_low(&mut self) -> Result { Ok(self.is_low()) } } @@ -996,13 +1006,13 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> { #[inline] - fn is_set_high(&self) -> Result { + fn is_set_high(&mut self) -> Result { Ok(self.is_set_high()) } /// Is the output pin set as low? #[inline] - fn is_set_low(&self) -> Result { + fn is_set_low(&mut self) -> Result { Ok(self.is_set_low()) } } @@ -1016,12 +1026,12 @@ impl<'d, T: Pin> embedded_hal_1::digital::ToggleableOutputPin for OutputOpenDrai impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { #[inline] - fn is_high(&self) -> Result { + fn is_high(&mut self) -> Result { Ok(self.is_high()) } #[inline] - fn is_low(&self) -> Result { + fn is_low(&mut self) -> Result { Ok(self.is_low()) } } @@ -1051,13 +1061,13 @@ impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { #[inline] - fn is_set_high(&self) -> Result { + fn is_set_high(&mut self) -> Result { Ok(self.is_set_high()) } /// Is the output pin set as low? #[inline] - fn is_set_low(&self) -> Result { + fn is_set_low(&mut self) -> Result { Ok(self.is_set_low()) } } diff --git a/embassy-time/CHANGELOG.md b/embassy-time/CHANGELOG.md index d8c0c7d0..99f6ef7a 100644 --- a/embassy-time/CHANGELOG.md +++ b/embassy-time/CHANGELOG.md @@ -24,8 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## 0.1.3 - 2023-08-28 -- Update `embedded-hal-async` to `1.0.0-rc.2` -- Update `embedded-hal v1` to `1.0.0-rc.2` +- Update `embedded-hal-async` to `1.0.0-rc.3` +- Update `embedded-hal v1` to `1.0.0-rc.3` ## 0.1.2 - 2023-07-05 diff --git a/embassy-time/Cargo.toml b/embassy-time/Cargo.toml index 94e79382..6d9b7aa6 100644 --- a/embassy-time/Cargo.toml +++ b/embassy-time/Cargo.toml @@ -235,8 +235,8 @@ defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6" } -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } -embedded-hal-async = { version = "=1.0.0-rc.2" } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.3" } +embedded-hal-async = { version = "=1.0.0-rc.3" } futures-util = { version = "0.3.17", default-features = false } critical-section = "1.1" diff --git a/examples/nrf52840/Cargo.toml b/examples/nrf52840/Cargo.toml index 65cd631f..1c49c32e 100644 --- a/examples/nrf52840/Cargo.toml +++ b/examples/nrf52840/Cargo.toml @@ -36,9 +36,9 @@ rand = { version = "0.8.4", default-features = false } embedded-storage = "0.3.1" usbd-hid = "0.6.0" serde = { version = "1.0.136", default-features = false } -embedded-hal = { version = "1.0.0-rc.2" } -embedded-hal-async = { version = "1.0.0-rc.2" } -embedded-hal-bus = { version = "0.1.0-rc.2", features = ["async"] } +embedded-hal = { version = "1.0.0-rc.3" } +embedded-hal-async = { version = "1.0.0-rc.3" } +embedded-hal-bus = { version = "0.1.0-rc.3", features = ["async"] } num-integer = { version = "0.1.45", default-features = false } microfft = "0.5.0" diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index 7f637758..521f17b8 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml @@ -38,9 +38,9 @@ smart-leds = "0.3.0" heapless = "0.8" usbd-hid = "0.6.1" -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } -embedded-hal-async = "1.0.0-rc.2" -embedded-hal-bus = { version = "0.1.0-rc.2", features = ["async"] } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.3" } +embedded-hal-async = "1.0.0-rc.3" +embedded-hal-bus = { version = "0.1.0-rc.3", features = ["async"] } embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } embedded-storage = { version = "0.3" } static_cell = { version = "2", features = ["nightly"]} diff --git a/examples/rp/src/bin/button.rs b/examples/rp/src/bin/button.rs index d7aa8941..a9f34ab5 100644 --- a/examples/rp/src/bin/button.rs +++ b/examples/rp/src/bin/button.rs @@ -17,7 +17,7 @@ async fn main(_spawner: Spawner) { // Use PIN_28, Pin34 on J0 for RP Pico, as a input. // You need to add your own button. - let button = Input::new(p.PIN_28, Pull::Up); + let mut button = Input::new(p.PIN_28, Pull::Up); loop { if button.is_high() { diff --git a/examples/stm32c0/src/bin/button.rs b/examples/stm32c0/src/bin/button.rs index 72a3f5cb..40c58013 100644 --- a/examples/stm32c0/src/bin/button.rs +++ b/examples/stm32c0/src/bin/button.rs @@ -13,7 +13,7 @@ fn main() -> ! { let p = embassy_stm32::init(Default::default()); - let button = Input::new(p.PC13, Pull::Up); + let mut button = Input::new(p.PC13, Pull::Up); loop { if button.is_high() { diff --git a/examples/stm32f3/src/bin/button.rs b/examples/stm32f3/src/bin/button.rs index b55bf390..2f47d8f8 100644 --- a/examples/stm32f3/src/bin/button.rs +++ b/examples/stm32f3/src/bin/button.rs @@ -13,7 +13,7 @@ fn main() -> ! { let p = embassy_stm32::init(Default::default()); - let button = Input::new(p.PA0, Pull::Down); + let mut button = Input::new(p.PA0, Pull::Down); let mut led1 = Output::new(p.PE9, Level::High, Speed::Low); let mut led2 = Output::new(p.PE15, Level::High, Speed::Low); diff --git a/examples/stm32f4/src/bin/button.rs b/examples/stm32f4/src/bin/button.rs index b13e6453..aa1eed46 100644 --- a/examples/stm32f4/src/bin/button.rs +++ b/examples/stm32f4/src/bin/button.rs @@ -13,7 +13,7 @@ fn main() -> ! { let p = embassy_stm32::init(Default::default()); - let button = Input::new(p.PC13, Pull::Down); + let mut button = Input::new(p.PC13, Pull::Down); let mut led1 = Output::new(p.PB0, Level::High, Speed::Low); let _led2 = Output::new(p.PB7, Level::High, Speed::Low); let mut led3 = Output::new(p.PB14, Level::High, Speed::Low); diff --git a/examples/stm32f7/src/bin/button.rs b/examples/stm32f7/src/bin/button.rs index b13e6453..aa1eed46 100644 --- a/examples/stm32f7/src/bin/button.rs +++ b/examples/stm32f7/src/bin/button.rs @@ -13,7 +13,7 @@ fn main() -> ! { let p = embassy_stm32::init(Default::default()); - let button = Input::new(p.PC13, Pull::Down); + let mut button = Input::new(p.PC13, Pull::Down); let mut led1 = Output::new(p.PB0, Level::High, Speed::Low); let _led2 = Output::new(p.PB7, Level::High, Speed::Low); let mut led3 = Output::new(p.PB14, Level::High, Speed::Low); diff --git a/examples/stm32g0/src/bin/button.rs b/examples/stm32g0/src/bin/button.rs index 72a3f5cb..40c58013 100644 --- a/examples/stm32g0/src/bin/button.rs +++ b/examples/stm32g0/src/bin/button.rs @@ -13,7 +13,7 @@ fn main() -> ! { let p = embassy_stm32::init(Default::default()); - let button = Input::new(p.PC13, Pull::Up); + let mut button = Input::new(p.PC13, Pull::Up); loop { if button.is_high() { diff --git a/examples/stm32g4/src/bin/button.rs b/examples/stm32g4/src/bin/button.rs index 15abd86d..127efb08 100644 --- a/examples/stm32g4/src/bin/button.rs +++ b/examples/stm32g4/src/bin/button.rs @@ -13,7 +13,7 @@ fn main() -> ! { let p = embassy_stm32::init(Default::default()); - let button = Input::new(p.PC13, Pull::Down); + let mut button = Input::new(p.PC13, Pull::Down); loop { if button.is_high() { diff --git a/examples/stm32h5/Cargo.toml b/examples/stm32h5/Cargo.toml index 0ed0ce3c..f714a398 100644 --- a/examples/stm32h5/Cargo.toml +++ b/examples/stm32h5/Cargo.toml @@ -19,8 +19,8 @@ defmt-rtt = "0.4" cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } -embedded-hal-async = { version = "=1.0.0-rc.2" } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.3" } +embedded-hal-async = { version = "=1.0.0-rc.3" } embedded-io-async = { version = "0.6.1" } embedded-nal-async = { version = "0.7.1" } panic-probe = { version = "0.3", features = ["print-defmt"] } diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index baa530cf..c6aea3e1 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml @@ -19,8 +19,8 @@ defmt-rtt = "0.4" cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } -embedded-hal-async = { version = "=1.0.0-rc.2" } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.3" } +embedded-hal-async = { version = "=1.0.0-rc.3" } embedded-nal-async = { version = "0.7.1" } embedded-io-async = { version = "0.6.1" } panic-probe = { version = "0.3", features = ["print-defmt"] } diff --git a/examples/stm32l0/src/bin/button.rs b/examples/stm32l0/src/bin/button.rs index 9d194471..3e56160e 100644 --- a/examples/stm32l0/src/bin/button.rs +++ b/examples/stm32l0/src/bin/button.rs @@ -12,7 +12,7 @@ async fn main(_spawner: Spawner) { let p = embassy_stm32::init(Default::default()); info!("Hello World!"); - let button = Input::new(p.PB2, Pull::Up); + let mut button = Input::new(p.PB2, Pull::Up); let mut led1 = Output::new(p.PA5, Level::High, Speed::Low); let mut led2 = Output::new(p.PB5, Level::High, Speed::Low); diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml index a936d27c..2861216d 100644 --- a/examples/stm32l4/Cargo.toml +++ b/examples/stm32l4/Cargo.toml @@ -24,9 +24,9 @@ defmt-rtt = "0.4" cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } -embedded-hal-async = { version = "=1.0.0-rc.2" } -embedded-hal-bus = { version = "=0.1.0-rc.2", features = ["async"] } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.3" } +embedded-hal-async = { version = "=1.0.0-rc.3" } +embedded-hal-bus = { version = "=0.1.0-rc.3", features = ["async"] } panic-probe = { version = "0.3", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } heapless = { version = "0.8", default-features = false } diff --git a/examples/stm32l4/src/bin/button.rs b/examples/stm32l4/src/bin/button.rs index 73b1962e..0a102c2d 100644 --- a/examples/stm32l4/src/bin/button.rs +++ b/examples/stm32l4/src/bin/button.rs @@ -12,7 +12,7 @@ fn main() -> ! { let p = embassy_stm32::init(Default::default()); - let button = Input::new(p.PC13, Pull::Up); + let mut button = Input::new(p.PC13, Pull::Up); loop { if button.is_high() { diff --git a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs index 4826e0be..8ec810c7 100644 --- a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs +++ b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs @@ -114,8 +114,8 @@ async fn main(spawner: Spawner) { let led_uc4_blue = Output::new(dp.PG15, Level::High, Speed::Low); // Read the uc_cfg switches - let uc_cfg0 = Input::new(dp.PB2, Pull::None); - let uc_cfg1 = Input::new(dp.PF11, Pull::None); + let mut uc_cfg0 = Input::new(dp.PB2, Pull::None); + let mut uc_cfg1 = Input::new(dp.PF11, Pull::None); let _uc_cfg2 = Input::new(dp.PG6, Pull::None); let _uc_cfg3 = Input::new(dp.PG11, Pull::None); @@ -133,8 +133,8 @@ async fn main(spawner: Spawner) { // Setup IO and SPI for the SPE chip let spe_reset_n = Output::new(dp.PC7, Level::Low, Speed::Low); - let spe_cfg0 = Input::new(dp.PC8, Pull::None); - let spe_cfg1 = Input::new(dp.PC9, Pull::None); + let mut spe_cfg0 = Input::new(dp.PC8, Pull::None); + let mut spe_cfg1 = Input::new(dp.PC9, Pull::None); let _spe_ts_capt = Output::new(dp.PC6, Level::Low, Speed::Low); let spe_int = Input::new(dp.PB11, Pull::None); diff --git a/examples/stm32l4/src/bin/spi_blocking_async.rs b/examples/stm32l4/src/bin/spi_blocking_async.rs index f1b80087..903ca58d 100644 --- a/examples/stm32l4/src/bin/spi_blocking_async.rs +++ b/examples/stm32l4/src/bin/spi_blocking_async.rs @@ -30,7 +30,7 @@ async fn main(_spawner: Spawner) { let _wake = Output::new(p.PB13, Level::Low, Speed::VeryHigh); let mut reset = Output::new(p.PE8, Level::Low, Speed::VeryHigh); let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh); - let ready = Input::new(p.PE1, Pull::Up); + let mut ready = Input::new(p.PE1, Pull::Up); cortex_m::asm::delay(100_000); reset.set_high(); diff --git a/examples/stm32l4/src/bin/spi_dma.rs b/examples/stm32l4/src/bin/spi_dma.rs index ff9b5b43..58cf2e51 100644 --- a/examples/stm32l4/src/bin/spi_dma.rs +++ b/examples/stm32l4/src/bin/spi_dma.rs @@ -25,7 +25,7 @@ async fn main(_spawner: Spawner) { let _wake = Output::new(p.PB13, Level::Low, Speed::VeryHigh); let mut reset = Output::new(p.PE8, Level::Low, Speed::VeryHigh); let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh); - let ready = Input::new(p.PE1, Pull::Up); + let mut ready = Input::new(p.PE1, Pull::Up); cortex_m::asm::delay(100_000); reset.set_high(); diff --git a/examples/stm32wl/src/bin/button.rs b/examples/stm32wl/src/bin/button.rs index 982a7a11..6c1f5a5e 100644 --- a/examples/stm32wl/src/bin/button.rs +++ b/examples/stm32wl/src/bin/button.rs @@ -13,7 +13,7 @@ fn main() -> ! { let p = embassy_stm32::init(Default::default()); - let button = Input::new(p.PA0, Pull::Up); + let mut 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); diff --git a/tests/nrf/Cargo.toml b/tests/nrf/Cargo.toml index 7b0d59ee..b6067abc 100644 --- a/tests/nrf/Cargo.toml +++ b/tests/nrf/Cargo.toml @@ -16,8 +16,8 @@ embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } embassy-net = { version = "0.2.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] } embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] } embassy-net-enc28j60 = { version = "0.1.0", path = "../../embassy-net-enc28j60", features = ["defmt"] } -embedded-hal-async = { version = "1.0.0-rc.2" } -embedded-hal-bus = { version = "0.1.0-rc.2", features = ["async"] } +embedded-hal-async = { version = "1.0.0-rc.3" } +embedded-hal-bus = { version = "0.1.0-rc.3", features = ["async"] } static_cell = { version = "2", features = [ "nightly" ] } perf-client = { path = "../perf-client" } diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index 44fb7bed..028ce43e 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml @@ -24,9 +24,9 @@ defmt-rtt = "0.4" cortex-m = { version = "0.7.6" } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } -embedded-hal-async = { version = "=1.0.0-rc.2" } -embedded-hal-bus = { version = "=0.1.0-rc.2", features = ["async"] } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.3" } +embedded-hal-async = { version = "=1.0.0-rc.3" } +embedded-hal-bus = { version = "=0.1.0-rc.3", features = ["async"] } panic-probe = { version = "0.3.0", features = ["print-defmt"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] } embedded-io-async = { version = "0.6.1" } diff --git a/tests/rp/src/bin/gpio.rs b/tests/rp/src/bin/gpio.rs index e0c30988..a57d5d9e 100644 --- a/tests/rp/src/bin/gpio.rs +++ b/tests/rp/src/bin/gpio.rs @@ -16,10 +16,10 @@ async fn main(_spawner: Spawner) { // Test initial output { - let b = Input::new(&mut b, Pull::None); + let mut b = Input::new(&mut b, Pull::None); { - let a = Output::new(&mut a, Level::Low); + let mut a = Output::new(&mut a, Level::Low); delay(); assert!(b.is_low()); assert!(!b.is_high()); @@ -64,7 +64,7 @@ async fn main(_spawner: Spawner) { // Test input no pull { - let b = Input::new(&mut b, Pull::None); + let mut b = Input::new(&mut b, Pull::None); // no pull, the status is undefined let mut a = Output::new(&mut a, Level::Low); @@ -77,7 +77,7 @@ async fn main(_spawner: Spawner) { // Test input pulldown { - let b = Input::new(&mut b, Pull::Down); + let mut b = Input::new(&mut b, Pull::Down); delay(); assert!(b.is_low()); @@ -91,7 +91,7 @@ async fn main(_spawner: Spawner) { // Test input pullup { - let b = Input::new(&mut b, Pull::Up); + let mut b = Input::new(&mut b, Pull::Up); delay(); assert!(b.is_high()); diff --git a/tests/rp/src/bin/pwm.rs b/tests/rp/src/bin/pwm.rs index e71d9e61..3fc0bb2a 100644 --- a/tests/rp/src/bin/pwm.rs +++ b/tests/rp/src/bin/pwm.rs @@ -45,7 +45,7 @@ async fn main(_spawner: Spawner) { // Test output from A { - let pin1 = Input::new(&mut p9, Pull::None); + let mut pin1 = Input::new(&mut p9, Pull::None); let _pwm = Pwm::new_output_a(&mut p.PWM_CH3, &mut p6, cfg.clone()); Timer::after_millis(1).await; assert_eq!(pin1.is_low(), invert_a); @@ -59,7 +59,7 @@ async fn main(_spawner: Spawner) { // Test output from B { - let pin2 = Input::new(&mut p11, Pull::None); + let mut pin2 = Input::new(&mut p11, Pull::None); let _pwm = Pwm::new_output_b(&mut p.PWM_CH3, &mut p7, cfg.clone()); Timer::after_millis(1).await; assert_ne!(pin2.is_low(), invert_a); @@ -73,8 +73,8 @@ async fn main(_spawner: Spawner) { // Test output from A+B { - let pin1 = Input::new(&mut p9, Pull::None); - let pin2 = Input::new(&mut p11, Pull::None); + let mut pin1 = Input::new(&mut p9, Pull::None); + let mut pin2 = Input::new(&mut p11, Pull::None); let _pwm = Pwm::new_output_ab(&mut p.PWM_CH3, &mut p6, &mut p7, cfg.clone()); Timer::after_millis(1).await; assert_eq!(pin1.is_low(), invert_a); diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index 4f53e84f..bdec4157 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml @@ -63,8 +63,8 @@ defmt-rtt = "0.4" cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m-rt = "0.7.0" embedded-hal = "0.2.6" -embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.2" } -embedded-hal-async = { version = "=1.0.0-rc.2" } +embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.3" } +embedded-hal-async = { version = "=1.0.0-rc.3" } micromath = "2.0.0" panic-probe = { version = "0.3.0", features = ["print-defmt"] } rand_core = { version = "0.6", default-features = false } diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs index c4e2fe16..9f199302 100644 --- a/tests/stm32/src/bin/gpio.rs +++ b/tests/stm32/src/bin/gpio.rs @@ -20,10 +20,10 @@ async fn main(_spawner: Spawner) { // Test initial output { - let b = Input::new(&mut b, Pull::None); + let mut b = Input::new(&mut b, Pull::None); { - let a = Output::new(&mut a, Level::Low, Speed::Low); + let mut a = Output::new(&mut a, Level::Low, Speed::Low); delay(); assert!(b.is_low()); assert!(!b.is_high()); @@ -68,7 +68,7 @@ async fn main(_spawner: Spawner) { // Test input no pull { - let b = Input::new(&mut b, Pull::None); + let mut b = Input::new(&mut b, Pull::None); // no pull, the status is undefined let mut a = Output::new(&mut a, Level::Low, Speed::Low); @@ -81,7 +81,7 @@ async fn main(_spawner: Spawner) { // Test input pulldown { - let b = Input::new(&mut b, Pull::Down); + let mut b = Input::new(&mut b, Pull::Down); delay(); assert!(b.is_low()); @@ -95,7 +95,7 @@ async fn main(_spawner: Spawner) { // Test input pullup { - let b = Input::new(&mut b, Pull::Up); + let mut b = Input::new(&mut b, Pull::Up); delay(); assert!(b.is_high()); @@ -109,7 +109,7 @@ async fn main(_spawner: Spawner) { // Test output open drain { - let b = Input::new(&mut b, Pull::Down); + let mut b = Input::new(&mut b, Pull::Down); // no pull, the status is undefined let mut a = OutputOpenDrain::new(&mut a, Level::Low, Speed::Low, Pull::None); From a34abd849f09187edea48713538403ebf44d6576 Mon Sep 17 00:00:00 2001 From: Kaitlyn Kenwell Date: Thu, 14 Dec 2023 10:30:10 -0500 Subject: [PATCH 80/98] Add examples to ci.sh --- ci.sh | 2 ++ examples/boot/application/stm32wb-dfu/Cargo.toml | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ci.sh b/ci.sh index 8a5e206d..83c05d1b 100755 --- a/ci.sh +++ b/ci.sh @@ -173,10 +173,12 @@ cargo batch \ --- build --release --manifest-path examples/boot/application/stm32l1/Cargo.toml --target thumbv7m-none-eabi --features skip-include --out-dir out/examples/boot/stm32l1 \ --- build --release --manifest-path examples/boot/application/stm32l4/Cargo.toml --target thumbv7em-none-eabi --features skip-include --out-dir out/examples/boot/stm32l4 \ --- build --release --manifest-path examples/boot/application/stm32wl/Cargo.toml --target thumbv7em-none-eabihf --features skip-include --out-dir out/examples/boot/stm32wl \ + --- build --release --manifest-path examples/boot/application/stm32wb-dfu/Cargo.toml --target thumbv7em-none-eabihf --out-dir out/examples/boot/stm32wb-dfu \ --- build --release --manifest-path examples/boot/bootloader/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840 \ --- build --release --manifest-path examples/boot/bootloader/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features embassy-nrf/nrf9160-ns \ --- build --release --manifest-path examples/boot/bootloader/rp/Cargo.toml --target thumbv6m-none-eabi \ --- build --release --manifest-path examples/boot/bootloader/stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4 \ + --- build --release --manifest-path examples/boot/bootloader/stm32wb-dfu/Cargo.toml --target thumbv7em-none-eabihf \ --- build --release --manifest-path examples/wasm/Cargo.toml --target wasm32-unknown-unknown --out-dir out/examples/wasm \ --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f103c8 --out-dir out/tests/stm32f103c8 \ --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi --out-dir out/tests/stm32f429zi \ diff --git a/examples/boot/application/stm32wb-dfu/Cargo.toml b/examples/boot/application/stm32wb-dfu/Cargo.toml index e67224ce..57d51de0 100644 --- a/examples/boot/application/stm32wb-dfu/Cargo.toml +++ b/examples/boot/application/stm32wb-dfu/Cargo.toml @@ -30,4 +30,3 @@ defmt = [ "embassy-boot-stm32/defmt", "embassy-sync/defmt", ] -skip-include = [] From e579095a9075c8a3efdb956877b533f47ef1ec42 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Thu, 14 Dec 2023 16:30:45 +0100 Subject: [PATCH 81/98] ci: fix test job not caching anything. --- .github/ci/build-stable.sh | 2 +- .github/ci/build.sh | 2 +- .github/ci/crlf.sh | 2 +- .github/ci/test.sh | 4 ++++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/ci/build-stable.sh b/.github/ci/build-stable.sh index 9160a2be..e0bd7786 100755 --- a/.github/ci/build-stable.sh +++ b/.github/ci/build-stable.sh @@ -27,4 +27,4 @@ sed -i 's/channel.*/channel = "beta"/g' rust-toolchain.toml # Save lockfiles echo Saving lockfiles... -find . -type f -name Cargo.lock -exec tar -cf /ci/cache/lockfiles.tar '{}' \+ \ No newline at end of file +find . -type f -name Cargo.lock -exec tar -cf /ci/cache/lockfiles.tar '{}' \+ diff --git a/.github/ci/build.sh b/.github/ci/build.sh index e7a6c0d8..77d2b3ca 100755 --- a/.github/ci/build.sh +++ b/.github/ci/build.sh @@ -31,4 +31,4 @@ hashtime save /ci/cache/filetime.json # Save lockfiles echo Saving lockfiles... -find . -type f -name Cargo.lock -exec tar -cf /ci/cache/lockfiles.tar '{}' \+ \ No newline at end of file +find . -type f -name Cargo.lock -exec tar -cf /ci/cache/lockfiles.tar '{}' \+ diff --git a/.github/ci/crlf.sh b/.github/ci/crlf.sh index 45751040..69838ce8 100755 --- a/.github/ci/crlf.sh +++ b/.github/ci/crlf.sh @@ -14,4 +14,4 @@ else echo -e "ERROR: Found ${NR_FILES} files with CRLF endings." echo "$FILES_WITH_CRLF" exit "$NR_FILES" -fi \ No newline at end of file +fi diff --git a/.github/ci/test.sh b/.github/ci/test.sh index 1ee760d3..0ec65d2a 100755 --- a/.github/ci/test.sh +++ b/.github/ci/test.sh @@ -4,6 +4,10 @@ set -euo pipefail +export RUSTUP_HOME=/ci/cache/rustup +export CARGO_HOME=/ci/cache/cargo +export CARGO_TARGET_DIR=/ci/cache/target + MIRIFLAGS=-Zmiri-ignore-leaks cargo miri test --manifest-path ./embassy-executor/Cargo.toml MIRIFLAGS=-Zmiri-ignore-leaks cargo miri test --manifest-path ./embassy-executor/Cargo.toml --features nightly From 27d054aa6875d977efc5f5c3554c57fd1245bdb9 Mon Sep 17 00:00:00 2001 From: Kaitlyn Kenwell Date: Thu, 14 Dec 2023 10:34:22 -0500 Subject: [PATCH 82/98] Adjust toml files, fix application example --- examples/boot/application/stm32wb-dfu/Cargo.toml | 2 +- examples/boot/application/stm32wb-dfu/src/main.rs | 10 +++++----- examples/boot/bootloader/stm32wb-dfu/Cargo.toml | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/boot/application/stm32wb-dfu/Cargo.toml b/examples/boot/application/stm32wb-dfu/Cargo.toml index 57d51de0..0ed0b75e 100644 --- a/examples/boot/application/stm32wb-dfu/Cargo.toml +++ b/examples/boot/application/stm32wb-dfu/Cargo.toml @@ -1,6 +1,6 @@ [package] edition = "2021" -name = "embassy-boot-stm32wl-examples" +name = "embassy-boot-stm32wb-dfu-examples" version = "0.1.0" license = "MIT OR Apache-2.0" diff --git a/examples/boot/application/stm32wb-dfu/src/main.rs b/examples/boot/application/stm32wb-dfu/src/main.rs index f03003ff..cdac903b 100644 --- a/examples/boot/application/stm32wb-dfu/src/main.rs +++ b/examples/boot/application/stm32wb-dfu/src/main.rs @@ -6,7 +6,7 @@ use core::cell::RefCell; #[cfg(feature = "defmt-rtt")] use defmt_rtt::*; -use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdaterConfig}; +use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareState, FirmwareUpdaterConfig}; use embassy_executor::Spawner; use embassy_stm32::flash::{Flash, WRITE_SIZE}; use embassy_stm32::rcc::WPAN_DEFAULT; @@ -33,8 +33,8 @@ async fn main(_spawner: Spawner) { let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash); let mut magic = AlignedBuffer([0; WRITE_SIZE]); - let mut updater = BlockingFirmwareUpdater::new(config, &mut magic.0); - updater.mark_booted().expect("Failed to mark booted"); + let mut firmware_state = BlockingFirmwareState::from_config(config, &mut magic.0); + firmware_state.mark_booted().expect("Failed to mark booted"); let driver = Driver::new(p.USB, Irqs, p.PA12, p.PA11); let mut config = embassy_usb::Config::new(0xc0de, 0xcafe); @@ -46,7 +46,7 @@ async fn main(_spawner: Spawner) { let mut config_descriptor = [0; 256]; let mut bos_descriptor = [0; 256]; let mut control_buf = [0; 64]; - let mut state = Control::new(updater, DfuAttributes::CAN_DOWNLOAD); + let mut state = Control::new(firmware_state, DfuAttributes::CAN_DOWNLOAD); let mut builder = Builder::new( driver, config, @@ -57,7 +57,7 @@ async fn main(_spawner: Spawner) { &mut control_buf, ); - usb_dfu::<_, _, _>(&mut builder, &mut state, Duration::from_millis(2500)); + usb_dfu::<_, _>(&mut builder, &mut state, Duration::from_millis(2500)); let mut dev = builder.build(); dev.run().await diff --git a/examples/boot/bootloader/stm32wb-dfu/Cargo.toml b/examples/boot/bootloader/stm32wb-dfu/Cargo.toml index 774a8223..fde9eb57 100644 --- a/examples/boot/bootloader/stm32wb-dfu/Cargo.toml +++ b/examples/boot/bootloader/stm32wb-dfu/Cargo.toml @@ -1,8 +1,8 @@ [package] edition = "2021" -name = "stm32-bootloader-example" +name = "stm32wb-dfu-bootloader-example" version = "0.1.0" -description = "Example bootloader for STM32 chips" +description = "Example USB DFUbootloader for the STM32WB series of chips" license = "MIT OR Apache-2.0" [dependencies] From cbc8ccc51e8e747fab51ac377225495cd24eb447 Mon Sep 17 00:00:00 2001 From: Kaitlyn Kenwell Date: Thu, 14 Dec 2023 10:56:16 -0500 Subject: [PATCH 83/98] Adjust stm32wb-dfu example memory maps to fix linker errors --- examples/boot/application/stm32wb-dfu/memory.x | 4 ++-- examples/boot/bootloader/stm32wb-dfu/memory.x | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/boot/application/stm32wb-dfu/memory.x b/examples/boot/application/stm32wb-dfu/memory.x index f5187576..ff1b800d 100644 --- a/examples/boot/application/stm32wb-dfu/memory.x +++ b/examples/boot/application/stm32wb-dfu/memory.x @@ -3,8 +3,8 @@ MEMORY /* NOTE 1 K = 1 KiBi = 1024 bytes */ BOOTLOADER : ORIGIN = 0x08000000, LENGTH = 24K BOOTLOADER_STATE : ORIGIN = 0x08006000, LENGTH = 4K - FLASH : ORIGIN = 0x08008000, LENGTH = 32K - DFU : ORIGIN = 0x08010000, LENGTH = 36K + FLASH : ORIGIN = 0x08008000, LENGTH = 128K + DFU : ORIGIN = 0x08028000, LENGTH = 132K RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K } diff --git a/examples/boot/bootloader/stm32wb-dfu/memory.x b/examples/boot/bootloader/stm32wb-dfu/memory.x index b6f185ef..85806263 100644 --- a/examples/boot/bootloader/stm32wb-dfu/memory.x +++ b/examples/boot/bootloader/stm32wb-dfu/memory.x @@ -3,8 +3,8 @@ MEMORY /* NOTE 1 K = 1 KiBi = 1024 bytes */ FLASH : ORIGIN = 0x08000000, LENGTH = 24K BOOTLOADER_STATE : ORIGIN = 0x08006000, LENGTH = 4K - ACTIVE : ORIGIN = 0x08008000, LENGTH = 32K - DFU : ORIGIN = 0x08010000, LENGTH = 36K + ACTIVE : ORIGIN = 0x08008000, LENGTH = 128K + DFU : ORIGIN = 0x08028000, LENGTH = 132K RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 16K } From 9f9f6e75bb3ef6d285ebed88a20ab57fb55f3d07 Mon Sep 17 00:00:00 2001 From: Kaitlyn Kenwell Date: Thu, 14 Dec 2023 13:29:26 -0500 Subject: [PATCH 84/98] Abstract chip reset logic, add Reset impls for cortex-m and esp32c3 --- embassy-usb-dfu/Cargo.toml | 5 +-- embassy-usb-dfu/src/application.rs | 17 ++++++---- embassy-usb-dfu/src/bootloader.rs | 19 ++++++++---- embassy-usb-dfu/src/lib.rs | 31 +++++++++++++++++++ .../boot/application/stm32wb-dfu/Cargo.toml | 2 +- .../boot/application/stm32wb-dfu/src/main.rs | 4 +-- .../boot/bootloader/stm32wb-dfu/Cargo.toml | 2 +- .../boot/bootloader/stm32wb-dfu/src/main.rs | 4 +-- 8 files changed, 64 insertions(+), 20 deletions(-) diff --git a/embassy-usb-dfu/Cargo.toml b/embassy-usb-dfu/Cargo.toml index 62398afb..02146c64 100644 --- a/embassy-usb-dfu/Cargo.toml +++ b/embassy-usb-dfu/Cargo.toml @@ -15,15 +15,16 @@ categories = [ [dependencies] bitflags = "2.4.1" -cortex-m = { version = "0.7.7", features = ["inline-asm"] } +cortex-m = { version = "0.7.7", features = ["inline-asm"], optional = true } defmt = { version = "0.3.5", optional = true } embassy-boot = { version = "0.1.1", path = "../embassy-boot/boot" } -embassy-embedded-hal = { version = "0.1.0", path = "../embassy-embedded-hal" } +# embassy-embedded-hal = { version = "0.1.0", path = "../embassy-embedded-hal" } embassy-futures = { version = "0.1.1", path = "../embassy-futures" } embassy-sync = { version = "0.5.0", path = "../embassy-sync" } embassy-time = { version = "0.2.0", path = "../embassy-time" } embassy-usb = { version = "0.1.0", path = "../embassy-usb", default-features = false } embedded-storage = { version = "0.3.1" } +esp32c3-hal = { version = "0.13.0", optional = true, default-features = false } [features] bootloader = [] diff --git a/embassy-usb-dfu/src/application.rs b/embassy-usb-dfu/src/application.rs index 5ff8f90f..75689db2 100644 --- a/embassy-usb-dfu/src/application.rs +++ b/embassy-usb-dfu/src/application.rs @@ -1,3 +1,5 @@ +use core::marker::PhantomData; + use embassy_boot::BlockingFirmwareState; use embassy_time::{Duration, Instant}; use embassy_usb::control::{InResponse, OutResponse, Recipient, RequestType}; @@ -9,17 +11,19 @@ use crate::consts::{ DfuAttributes, Request, State, Status, APPN_SPEC_SUBCLASS_DFU, DESC_DFU_FUNCTIONAL, DFU_PROTOCOL_RT, USB_CLASS_APPN_SPEC, }; +use crate::Reset; /// Internal state for the DFU class -pub struct Control<'d, STATE: NorFlash> { +pub struct Control<'d, STATE: NorFlash, RST: Reset> { firmware_state: BlockingFirmwareState<'d, STATE>, attrs: DfuAttributes, state: State, timeout: Option, detach_start: Option, + _rst: PhantomData, } -impl<'d, STATE: NorFlash> Control<'d, STATE> { +impl<'d, STATE: NorFlash, RST: Reset> Control<'d, STATE, RST> { pub fn new(firmware_state: BlockingFirmwareState<'d, STATE>, attrs: DfuAttributes) -> Self { Control { firmware_state, @@ -27,11 +31,12 @@ impl<'d, STATE: NorFlash> Control<'d, STATE> { state: State::AppIdle, detach_start: None, timeout: None, + _rst: PhantomData, } } } -impl<'d, STATE: NorFlash> Handler for Control<'d, STATE> { +impl<'d, STATE: NorFlash, RST: Reset> Handler for Control<'d, STATE, RST> { fn reset(&mut self) { if let Some(start) = self.detach_start { let delta = Instant::now() - start; @@ -45,7 +50,7 @@ impl<'d, STATE: NorFlash> Handler for Control<'d, STATE> { self.firmware_state .mark_dfu() .expect("Failed to mark DFU mode in bootloader"); - cortex_m::peripheral::SCB::sys_reset(); + RST::sys_reset() } } } @@ -103,9 +108,9 @@ impl<'d, STATE: NorFlash> Handler for Control<'d, STATE> { /// it should expose a DFU device, and a software reset will be issued. /// /// To apply USB DFU updates, the bootloader must be capable of recognizing the DFU magic and exposing a device to handle the full DFU transaction with the host. -pub fn usb_dfu<'d, D: Driver<'d>, STATE: NorFlash>( +pub fn usb_dfu<'d, D: Driver<'d>, STATE: NorFlash, RST: Reset>( builder: &mut Builder<'d, D>, - handler: &'d mut Control<'d, STATE>, + handler: &'d mut Control<'d, STATE, RST>, timeout: Duration, ) { let mut func = builder.function(0x00, 0x00, 0x00); diff --git a/embassy-usb-dfu/src/bootloader.rs b/embassy-usb-dfu/src/bootloader.rs index 99384d96..d41e6280 100644 --- a/embassy-usb-dfu/src/bootloader.rs +++ b/embassy-usb-dfu/src/bootloader.rs @@ -1,3 +1,5 @@ +use core::marker::PhantomData; + use embassy_boot::{AlignedBuffer, BlockingFirmwareUpdater}; use embassy_usb::control::{InResponse, OutResponse, Recipient, RequestType}; use embassy_usb::driver::Driver; @@ -8,17 +10,19 @@ use crate::consts::{ DfuAttributes, Request, State, Status, APPN_SPEC_SUBCLASS_DFU, DESC_DFU_FUNCTIONAL, DFU_PROTOCOL_DFU, USB_CLASS_APPN_SPEC, }; +use crate::Reset; /// Internal state for USB DFU -pub struct Control<'d, DFU: NorFlash, STATE: NorFlash, const BLOCK_SIZE: usize> { +pub struct Control<'d, DFU: NorFlash, STATE: NorFlash, RST: Reset, const BLOCK_SIZE: usize> { updater: BlockingFirmwareUpdater<'d, DFU, STATE>, attrs: DfuAttributes, state: State, status: Status, offset: usize, + _rst: PhantomData, } -impl<'d, DFU: NorFlash, STATE: NorFlash, const BLOCK_SIZE: usize> Control<'d, DFU, STATE, BLOCK_SIZE> { +impl<'d, DFU: NorFlash, STATE: NorFlash, RST: Reset, const BLOCK_SIZE: usize> Control<'d, DFU, STATE, RST, BLOCK_SIZE> { pub fn new(updater: BlockingFirmwareUpdater<'d, DFU, STATE>, attrs: DfuAttributes) -> Self { Self { updater, @@ -26,6 +30,7 @@ impl<'d, DFU: NorFlash, STATE: NorFlash, const BLOCK_SIZE: usize> Control<'d, DF state: State::DfuIdle, status: Status::Ok, offset: 0, + _rst: PhantomData, } } @@ -36,7 +41,9 @@ impl<'d, DFU: NorFlash, STATE: NorFlash, const BLOCK_SIZE: usize> Control<'d, DF } } -impl<'d, DFU: NorFlash, STATE: NorFlash, const BLOCK_SIZE: usize> Handler for Control<'d, DFU, STATE, BLOCK_SIZE> { +impl<'d, DFU: NorFlash, STATE: NorFlash, RST: Reset, const BLOCK_SIZE: usize> Handler + for Control<'d, DFU, STATE, RST, BLOCK_SIZE> +{ fn control_out( &mut self, req: embassy_usb::control::Request, @@ -131,7 +138,7 @@ impl<'d, DFU: NorFlash, STATE: NorFlash, const BLOCK_SIZE: usize> Handler for Co buf[0..6].copy_from_slice(&[self.status as u8, 0x32, 0x00, 0x00, self.state as u8, 0x00]); match self.state { State::DlSync => self.state = State::Download, - State::ManifestSync => cortex_m::peripheral::SCB::sys_reset(), + State::ManifestSync => RST::sys_reset(), _ => {} } @@ -157,9 +164,9 @@ impl<'d, DFU: NorFlash, STATE: NorFlash, const BLOCK_SIZE: usize> Handler for Co /// /// Once the host has initiated a DFU download operation, the chunks sent by the host will be written to the DFU partition. /// Once the final sync in the manifestation phase has been received, the handler will trigger a system reset to swap the new firmware. -pub fn usb_dfu<'d, D: Driver<'d>, DFU: NorFlash, STATE: NorFlash, const BLOCK_SIZE: usize>( +pub fn usb_dfu<'d, D: Driver<'d>, DFU: NorFlash, STATE: NorFlash, RST: Reset, const BLOCK_SIZE: usize>( builder: &mut Builder<'d, D>, - handler: &'d mut Control<'d, DFU, STATE, BLOCK_SIZE>, + handler: &'d mut Control<'d, DFU, STATE, RST, BLOCK_SIZE>, ) { let mut func = builder.function(0x00, 0x00, 0x00); let mut iface = func.interface(); diff --git a/embassy-usb-dfu/src/lib.rs b/embassy-usb-dfu/src/lib.rs index ae0fbbd4..283905de 100644 --- a/embassy-usb-dfu/src/lib.rs +++ b/embassy-usb-dfu/src/lib.rs @@ -18,3 +18,34 @@ pub use self::application::*; not(any(feature = "bootloader", feature = "application")) ))] compile_error!("usb-dfu must be compiled with exactly one of `bootloader`, or `application` features"); + +/// Provides a platform-agnostic interface for initiating a system reset. +/// +/// This crate exposes `ResetImmediate` when compiled with cortex-m or esp32c3 support, which immediately issues a +/// reset request without interfacing with any other peripherals. +/// +/// If alternate behaviour is desired, a custom implementation of Reset can be provided as a type argument to the usb_dfu function. +pub trait Reset { + fn sys_reset() -> !; +} + +#[cfg(feature = "esp32c3-hal")] +pub struct ResetImmediate; + +#[cfg(feature = "esp32c3-hal")] +impl Reset for ResetImmediate { + fn sys_reset() -> ! { + esp32c3_hal::reset::software_reset(); + loop {} + } +} + +#[cfg(feature = "cortex-m")] +pub struct ResetImmediate; + +#[cfg(feature = "cortex-m")] +impl Reset for ResetImmediate { + fn sys_reset() -> ! { + cortex_m::peripheral::SCB::sys_reset() + } +} diff --git a/examples/boot/application/stm32wb-dfu/Cargo.toml b/examples/boot/application/stm32wb-dfu/Cargo.toml index 0ed0b75e..f6beea49 100644 --- a/examples/boot/application/stm32wb-dfu/Cargo.toml +++ b/examples/boot/application/stm32wb-dfu/Cargo.toml @@ -12,7 +12,7 @@ embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", feature embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = [] } embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } embassy-usb = { version = "0.1.0", path = "../../../../embassy-usb" } -embassy-usb-dfu = { version = "0.1.0", path = "../../../../embassy-usb-dfu", features = ["application"] } +embassy-usb-dfu = { version = "0.1.0", path = "../../../../embassy-usb-dfu", features = ["application", "cortex-m"] } defmt = { version = "0.3", optional = true } defmt-rtt = { version = "0.4", optional = true } diff --git a/examples/boot/application/stm32wb-dfu/src/main.rs b/examples/boot/application/stm32wb-dfu/src/main.rs index cdac903b..fbecbf23 100644 --- a/examples/boot/application/stm32wb-dfu/src/main.rs +++ b/examples/boot/application/stm32wb-dfu/src/main.rs @@ -16,7 +16,7 @@ use embassy_sync::blocking_mutex::Mutex; use embassy_time::Duration; use embassy_usb::Builder; use embassy_usb_dfu::consts::DfuAttributes; -use embassy_usb_dfu::{usb_dfu, Control}; +use embassy_usb_dfu::{usb_dfu, Control, ResetImmediate}; use panic_reset as _; bind_interrupts!(struct Irqs { @@ -57,7 +57,7 @@ async fn main(_spawner: Spawner) { &mut control_buf, ); - usb_dfu::<_, _>(&mut builder, &mut state, Duration::from_millis(2500)); + usb_dfu::<_, _, ResetImmediate>(&mut builder, &mut state, Duration::from_millis(2500)); let mut dev = builder.build(); dev.run().await diff --git a/examples/boot/bootloader/stm32wb-dfu/Cargo.toml b/examples/boot/bootloader/stm32wb-dfu/Cargo.toml index fde9eb57..e849eb53 100644 --- a/examples/boot/bootloader/stm32wb-dfu/Cargo.toml +++ b/examples/boot/bootloader/stm32wb-dfu/Cargo.toml @@ -17,7 +17,7 @@ cortex-m-rt = { version = "0.7" } embedded-storage = "0.3.1" embedded-storage-async = "0.4.0" cfg-if = "1.0.0" -embassy-usb-dfu = { version = "0.1.0", path = "../../../../embassy-usb-dfu", features = ["bootloader"] } +embassy-usb-dfu = { version = "0.1.0", path = "../../../../embassy-usb-dfu", features = ["bootloader", "cortex-m"] } embassy-usb = { version = "0.1.0", path = "../../../../embassy-usb", default-features = false } embassy-futures = { version = "0.1.1", path = "../../../../embassy-futures" } diff --git a/examples/boot/bootloader/stm32wb-dfu/src/main.rs b/examples/boot/bootloader/stm32wb-dfu/src/main.rs index db7039e8..a7ab813b 100644 --- a/examples/boot/bootloader/stm32wb-dfu/src/main.rs +++ b/examples/boot/bootloader/stm32wb-dfu/src/main.rs @@ -14,7 +14,7 @@ use embassy_stm32::{bind_interrupts, peripherals, usb}; use embassy_sync::blocking_mutex::Mutex; use embassy_usb::Builder; use embassy_usb_dfu::consts::DfuAttributes; -use embassy_usb_dfu::{usb_dfu, Control}; +use embassy_usb_dfu::{usb_dfu, Control, ResetImmediate}; bind_interrupts!(struct Irqs { USB_LP => usb::InterruptHandler; @@ -64,7 +64,7 @@ fn main() -> ! { &mut control_buf, ); - usb_dfu::<_, _, _, 4096>(&mut builder, &mut state); + usb_dfu::<_, _, _, ResetImmediate, 4096>(&mut builder, &mut state); let mut dev = builder.build(); embassy_futures::block_on(dev.run()); From 33e8943e5b6e637b82f13c77bd88bb56d55ab515 Mon Sep 17 00:00:00 2001 From: Kaitlyn Kenwell Date: Thu, 14 Dec 2023 14:16:58 -0500 Subject: [PATCH 85/98] Rename bootloader feature to dfu --- embassy-usb-dfu/Cargo.toml | 2 +- embassy-usb-dfu/src/lib.rs | 8 ++++---- examples/boot/bootloader/stm32wb-dfu/Cargo.toml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/embassy-usb-dfu/Cargo.toml b/embassy-usb-dfu/Cargo.toml index 02146c64..ee110ee8 100644 --- a/embassy-usb-dfu/Cargo.toml +++ b/embassy-usb-dfu/Cargo.toml @@ -27,6 +27,6 @@ embedded-storage = { version = "0.3.1" } esp32c3-hal = { version = "0.13.0", optional = true, default-features = false } [features] -bootloader = [] +dfu = [] application = [] defmt = ["dep:defmt"] diff --git a/embassy-usb-dfu/src/lib.rs b/embassy-usb-dfu/src/lib.rs index 283905de..389bb33f 100644 --- a/embassy-usb-dfu/src/lib.rs +++ b/embassy-usb-dfu/src/lib.rs @@ -3,9 +3,9 @@ mod fmt; pub mod consts; -#[cfg(feature = "bootloader")] +#[cfg(feature = "dfu")] mod bootloader; -#[cfg(feature = "bootloader")] +#[cfg(feature = "dfu")] pub use self::bootloader::*; #[cfg(feature = "application")] @@ -14,8 +14,8 @@ mod application; pub use self::application::*; #[cfg(any( - all(feature = "bootloader", feature = "application"), - not(any(feature = "bootloader", feature = "application")) + all(feature = "dfu", feature = "application"), + not(any(feature = "dfu", feature = "application")) ))] compile_error!("usb-dfu must be compiled with exactly one of `bootloader`, or `application` features"); diff --git a/examples/boot/bootloader/stm32wb-dfu/Cargo.toml b/examples/boot/bootloader/stm32wb-dfu/Cargo.toml index e849eb53..ada07397 100644 --- a/examples/boot/bootloader/stm32wb-dfu/Cargo.toml +++ b/examples/boot/bootloader/stm32wb-dfu/Cargo.toml @@ -17,7 +17,7 @@ cortex-m-rt = { version = "0.7" } embedded-storage = "0.3.1" embedded-storage-async = "0.4.0" cfg-if = "1.0.0" -embassy-usb-dfu = { version = "0.1.0", path = "../../../../embassy-usb-dfu", features = ["bootloader", "cortex-m"] } +embassy-usb-dfu = { version = "0.1.0", path = "../../../../embassy-usb-dfu", features = ["dfu", "cortex-m"] } embassy-usb = { version = "0.1.0", path = "../../../../embassy-usb", default-features = false } embassy-futures = { version = "0.1.1", path = "../../../../embassy-futures" } From 98481c20fe44d5f0dea88675d08aa21c0fd8091c Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Thu, 14 Dec 2023 21:11:33 +0100 Subject: [PATCH 86/98] use released embedded-hal-mock. --- embassy-net-adin1110/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embassy-net-adin1110/Cargo.toml b/embassy-net-adin1110/Cargo.toml index adcdfe80..b1582ac9 100644 --- a/embassy-net-adin1110/Cargo.toml +++ b/embassy-net-adin1110/Cargo.toml @@ -22,7 +22,7 @@ embassy-futures = { version = "0.1.0", path = "../embassy-futures" } bitfield = "0.14.0" [dev-dependencies] -embedded-hal-mock = { git = "https://github.com/Dirbaio/embedded-hal-mock", rev = "b5a2274759a8c484f4fae71a22f8a083fdd9d5da", features = ["embedded-hal-async", "eh1"] } +embedded-hal-mock = { version = "0.10.0-rc.4", features = ["embedded-hal-async", "eh1"] } crc = "3.0.1" env_logger = "0.10" critical-section = { version = "1.1.2", features = ["std"] } From a165d73eedfd7e02fe5360e9d844882e0d0df113 Mon Sep 17 00:00:00 2001 From: eZio Pan Date: Fri, 15 Dec 2023 14:10:11 +0800 Subject: [PATCH 87/98] add ws2812 example for stm32f4 with PWM and DMA --- examples/stm32f4/src/bin/ws2812_pwm_dma.rs | 135 +++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 examples/stm32f4/src/bin/ws2812_pwm_dma.rs diff --git a/examples/stm32f4/src/bin/ws2812_pwm_dma.rs b/examples/stm32f4/src/bin/ws2812_pwm_dma.rs new file mode 100644 index 00000000..79493dce --- /dev/null +++ b/examples/stm32f4/src/bin/ws2812_pwm_dma.rs @@ -0,0 +1,135 @@ +// Configure TIM3 in PWM mode, and start DMA Transfer(s) to send color data into ws2812. +// We assume the DIN pin of ws2812 connect to GPIO PB4, and ws2812 is properly powered. +// +// This demo is a combination of HAL, PAC, and manually invoke `dma::Transfer` +// +// Warning: +// DO NOT stare at ws2812 directy (especially after each MCU Reset), its (max) brightness could easily make your eyes feel burn. + +#![no_std] +#![no_main] +#![feature(type_alias_impl_trait)] + +use embassy_executor::Spawner; + +use embassy_stm32::{ + gpio::OutputType, + pac, + time::khz, + timer::{ + simple_pwm::{PwmPin, SimplePwm}, + Channel, CountingMode, + }, +}; +use embassy_time::Timer; + +use {defmt_rtt as _, panic_probe as _}; + +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let mut device_config = embassy_stm32::Config::default(); + + // set SYSCLK/HCLK/PCLK2 to 20 MHz, thus each tick is 0.05 us, + // and ws2812 timings are integer multiples of 0.05 us + { + use embassy_stm32::rcc::*; + use embassy_stm32::time::*; + device_config.enable_debug_during_sleep = true; + device_config.rcc.hse = Some(Hse { + freq: mhz(12), + mode: HseMode::Oscillator, + }); + device_config.rcc.sys = Sysclk::PLL1_P; + device_config.rcc.pll_src = PllSource::HSE; + device_config.rcc.pll = Some(Pll { + prediv: PllPreDiv::DIV6, + mul: PllMul::MUL80, + divp: Some(PllPDiv::DIV8), + divq: None, + divr: None, + }); + } + + let mut dp = embassy_stm32::init(device_config); + + let mut ws2812_pwm = SimplePwm::new( + dp.TIM3, + Some(PwmPin::new_ch1(dp.PB4, OutputType::PushPull)), + None, + None, + None, + khz(800), // data rate of ws2812 + CountingMode::EdgeAlignedUp, + ); + + // PAC level hacking, + // enable auto-reload preload, and enable timer-update-event trigger DMA + { + pac::TIM3.cr1().modify(|v| v.set_arpe(true)); + pac::TIM3.dier().modify(|v| v.set_ude(true)); + } + + // construct ws2812 non-return-to-zero (NRZ) code bit by bit + + let max_duty = ws2812_pwm.get_max_duty(); + let n0 = 8 * max_duty / 25; // ws2812 Bit 0 high level timing + let n1 = 2 * n0; // ws2812 Bit 1 high level timing + + let turn_off = [ + n0, n0, n0, n0, n0, n0, n0, n0, // Green + n0, n0, n0, n0, n0, n0, n0, n0, // Red + n0, n0, n0, n0, n0, n0, n0, n0, // Blue + 0, // keep PWM output low after a transfer + ]; + + let dim_white = [ + n0, n0, n0, n0, n0, n0, n1, n0, // Green + n0, n0, n0, n0, n0, n0, n1, n0, // Red + n0, n0, n0, n0, n0, n0, n1, n0, // Blue + 0, // keep PWM output low after a transfer + ]; + + let color_list = [&turn_off, &dim_white]; + + // make sure PWM output keep low on first start + ws2812_pwm.set_duty(Channel::Ch1, 0); + + { + use embassy_stm32::dma::{Burst, FifoThreshold, Transfer, TransferOptions}; + + // configure FIFO and MBURST of DMA, to minimize DMA occupation on AHB/APB + let mut dma_transfer_option = TransferOptions::default(); + dma_transfer_option.fifo_threshold = Some(FifoThreshold::Full); + dma_transfer_option.mburst = Burst::Incr8; + + let mut color_list_index = 0; + + loop { + // start PWM output + ws2812_pwm.enable(Channel::Ch1); + + unsafe { + Transfer::new_write( + // with &mut, we can easily reuse same DMA channel multiple times + &mut dp.DMA1_CH2, + 5, + color_list[color_list_index], + pac::TIM3.ccr(0).as_ptr() as *mut _, + dma_transfer_option, + ) + .await; + // ws2812 need at least 50 us low level input to confirm the input data and change it's state + Timer::after_micros(50).await; + } + + // stop PWM output for saving some energy + ws2812_pwm.disable(Channel::Ch1); + + // wait another half second, so that we can see color change + Timer::after_millis(500).await; + + // flip the index bit so that next round DMA transfer the other color data + color_list_index ^= 1; + } + } +} From 77e372e842c64b95e94fff93a711112514588841 Mon Sep 17 00:00:00 2001 From: eZio Pan Date: Fri, 15 Dec 2023 14:15:45 +0800 Subject: [PATCH 88/98] cargo fmt --- examples/stm32f4/src/bin/ws2812_pwm_dma.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/examples/stm32f4/src/bin/ws2812_pwm_dma.rs b/examples/stm32f4/src/bin/ws2812_pwm_dma.rs index 79493dce..0c3444a4 100644 --- a/examples/stm32f4/src/bin/ws2812_pwm_dma.rs +++ b/examples/stm32f4/src/bin/ws2812_pwm_dma.rs @@ -11,18 +11,12 @@ #![feature(type_alias_impl_trait)] use embassy_executor::Spawner; - -use embassy_stm32::{ - gpio::OutputType, - pac, - time::khz, - timer::{ - simple_pwm::{PwmPin, SimplePwm}, - Channel, CountingMode, - }, -}; +use embassy_stm32::gpio::OutputType; +use embassy_stm32::pac; +use embassy_stm32::time::khz; +use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; +use embassy_stm32::timer::{Channel, CountingMode}; use embassy_time::Timer; - use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] From e5e85ba02bc91a47d80ba89dee27e6ccb20f0ccd Mon Sep 17 00:00:00 2001 From: Oliver Rockstedt Date: Fri, 15 Dec 2023 11:42:58 +0100 Subject: [PATCH 89/98] STM32H7: Allow PLL1 DIVP of 1 for certain series --- embassy-stm32/src/rcc/h.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/embassy-stm32/src/rcc/h.rs b/embassy-stm32/src/rcc/h.rs index 1889eb28..18dff9f2 100644 --- a/embassy-stm32/src/rcc/h.rs +++ b/embassy-stm32/src/rcc/h.rs @@ -70,7 +70,9 @@ pub struct Pll { pub mul: PllMul, /// PLL P division factor. If None, PLL P output is disabled. - /// On PLL1, it must be even (in particular, it cannot be 1.) + /// On PLL1, it must be even for most series (in particular, + /// it cannot be 1 in series other than STM32H723/733, + /// STM32H725/735 and STM32H730.) pub divp: Option, /// PLL Q division factor. If None, PLL Q output is disabled. pub divq: Option, @@ -729,9 +731,12 @@ fn init_pll(num: usize, config: Option, input: &PllInput) -> PllOutput { let p = config.divp.map(|div| { if num == 0 { - // on PLL1, DIVP must be even. + // on PLL1, DIVP must be even for most series. // The enum value is 1 less than the divider, so check it's odd. + #[cfg(not(pwr_h7rm0468))] assert!(div.to_bits() % 2 == 1); + #[cfg(pwr_h7rm0468)] + assert!(div.to_bits() % 2 == 1 || div.to_bits() == 0); } vco_clk / div From a8d0da91dc7b43bb05b200e7f530e58e25f20194 Mon Sep 17 00:00:00 2001 From: Oliver Rockstedt Date: Fri, 15 Dec 2023 12:22:17 +0100 Subject: [PATCH 90/98] STM32H7: adjust frequency limits for series in RM0468 --- embassy-stm32/src/rcc/h.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/embassy-stm32/src/rcc/h.rs b/embassy-stm32/src/rcc/h.rs index 18dff9f2..f28bd0b9 100644 --- a/embassy-stm32/src/rcc/h.rs +++ b/embassy-stm32/src/rcc/h.rs @@ -478,7 +478,14 @@ pub(crate) unsafe fn init(config: Config) { VoltageScale::Scale2 => (Hertz(160_000_000), Hertz(160_000_000), Hertz(80_000_000)), VoltageScale::Scale3 => (Hertz(88_000_000), Hertz(88_000_000), Hertz(44_000_000)), }; - #[cfg(all(stm32h7, not(pwr_h7rm0455)))] + #[cfg(pwr_h7rm0468)] + let (d1cpre_clk_max, hclk_max, pclk_max) = match config.voltage_scale { + VoltageScale::Scale0 => (Hertz(550_000_000), Hertz(275_000_000), Hertz(137_500_000)), + VoltageScale::Scale1 => (Hertz(400_000_000), Hertz(200_000_000), Hertz(100_000_000)), + VoltageScale::Scale2 => (Hertz(300_000_000), Hertz(150_000_000), Hertz(75_000_000)), + VoltageScale::Scale3 => (Hertz(170_000_000), Hertz(85_000_000), Hertz(42_500_000)), + }; + #[cfg(all(stm32h7, not(any(pwr_h7rm0455, pwr_h7rm0468))))] let (d1cpre_clk_max, hclk_max, pclk_max) = match config.voltage_scale { VoltageScale::Scale0 => (Hertz(480_000_000), Hertz(240_000_000), Hertz(120_000_000)), VoltageScale::Scale1 => (Hertz(400_000_000), Hertz(200_000_000), Hertz(100_000_000)), From c17fee27bb37233df7300bea3c2658f87df9dd6b Mon Sep 17 00:00:00 2001 From: Oliver Rockstedt Date: Fri, 15 Dec 2023 13:53:06 +0100 Subject: [PATCH 91/98] STM32H7: limit max frequency to 520MHz until cpu frequency boost option is implemented --- embassy-stm32/src/rcc/h.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embassy-stm32/src/rcc/h.rs b/embassy-stm32/src/rcc/h.rs index f28bd0b9..389b2a87 100644 --- a/embassy-stm32/src/rcc/h.rs +++ b/embassy-stm32/src/rcc/h.rs @@ -480,7 +480,7 @@ pub(crate) unsafe fn init(config: Config) { }; #[cfg(pwr_h7rm0468)] let (d1cpre_clk_max, hclk_max, pclk_max) = match config.voltage_scale { - VoltageScale::Scale0 => (Hertz(550_000_000), Hertz(275_000_000), Hertz(137_500_000)), + VoltageScale::Scale0 => (Hertz(520_000_000), Hertz(275_000_000), Hertz(137_500_000)), VoltageScale::Scale1 => (Hertz(400_000_000), Hertz(200_000_000), Hertz(100_000_000)), VoltageScale::Scale2 => (Hertz(300_000_000), Hertz(150_000_000), Hertz(75_000_000)), VoltageScale::Scale3 => (Hertz(170_000_000), Hertz(85_000_000), Hertz(42_500_000)), From 560e72813292e0ceb32b25daf887bb69b48af771 Mon Sep 17 00:00:00 2001 From: Oliver Rockstedt Date: Fri, 15 Dec 2023 14:14:30 +0100 Subject: [PATCH 92/98] STM32H7: adjust flash latency and programming delay for series in RM0468 --- embassy-stm32/src/rcc/h.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/embassy-stm32/src/rcc/h.rs b/embassy-stm32/src/rcc/h.rs index 389b2a87..15b51a39 100644 --- a/embassy-stm32/src/rcc/h.rs +++ b/embassy-stm32/src/rcc/h.rs @@ -832,7 +832,7 @@ fn flash_setup(clk: Hertz, vos: VoltageScale) { _ => unreachable!(), }; - #[cfg(flash_h7)] + #[cfg(all(flash_h7, not(pwr_h7rm0468)))] let (latency, wrhighfreq) = match (vos, clk.0) { // VOS 0 range VCORE 1.26V - 1.40V (VoltageScale::Scale0, ..=70_000_000) => (0, 0), @@ -861,6 +861,30 @@ fn flash_setup(clk: Hertz, vos: VoltageScale) { _ => unreachable!(), }; + // See RM0468 Rev 3 Table 16. FLASH recommended number of wait + // states and programming delay + #[cfg(all(flash_h7, pwr_h7rm0468))] + let (latency, wrhighfreq) = match (vos, clk.0) { + // VOS 0 range VCORE 1.26V - 1.40V + (VoltageScale::Scale0, ..=70_000_000) => (0, 0), + (VoltageScale::Scale0, ..=140_000_000) => (1, 1), + (VoltageScale::Scale0, ..=210_000_000) => (2, 2), + (VoltageScale::Scale0, ..=275_000_000) => (3, 3), + // VOS 1 range VCORE 1.15V - 1.26V + (VoltageScale::Scale1, ..=67_000_000) => (0, 0), + (VoltageScale::Scale1, ..=133_000_000) => (1, 1), + (VoltageScale::Scale1, ..=200_000_000) => (2, 2), + // VOS 2 range VCORE 1.05V - 1.15V + (VoltageScale::Scale2, ..=50_000_000) => (0, 0), + (VoltageScale::Scale2, ..=100_000_000) => (1, 1), + (VoltageScale::Scale2, ..=150_000_000) => (2, 2), + // VOS 3 range VCORE 0.95V - 1.05V + (VoltageScale::Scale3, ..=35_000_000) => (0, 0), + (VoltageScale::Scale3, ..=70_000_000) => (1, 1), + (VoltageScale::Scale3, ..=85_000_000) => (2, 2), + _ => unreachable!(), + }; + // See RM0455 Rev 10 Table 16. FLASH recommended number of wait // states and programming delay #[cfg(flash_h7ab)] From ea1e1973eb88a3a57e7f4e2ad97d32e5fcd8b8d1 Mon Sep 17 00:00:00 2001 From: eZio Pan Date: Sat, 16 Dec 2023 02:15:56 +0800 Subject: [PATCH 93/98] unify channel assign --- examples/stm32f4/src/bin/ws2812_pwm_dma.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/stm32f4/src/bin/ws2812_pwm_dma.rs b/examples/stm32f4/src/bin/ws2812_pwm_dma.rs index 0c3444a4..52cc665c 100644 --- a/examples/stm32f4/src/bin/ws2812_pwm_dma.rs +++ b/examples/stm32f4/src/bin/ws2812_pwm_dma.rs @@ -85,8 +85,10 @@ async fn main(_spawner: Spawner) { let color_list = [&turn_off, &dim_white]; + let pwm_channel = Channel::Ch1; + // make sure PWM output keep low on first start - ws2812_pwm.set_duty(Channel::Ch1, 0); + ws2812_pwm.set_duty(pwm_channel, 0); { use embassy_stm32::dma::{Burst, FifoThreshold, Transfer, TransferOptions}; @@ -100,7 +102,7 @@ async fn main(_spawner: Spawner) { loop { // start PWM output - ws2812_pwm.enable(Channel::Ch1); + ws2812_pwm.enable(pwm_channel); unsafe { Transfer::new_write( @@ -108,7 +110,7 @@ async fn main(_spawner: Spawner) { &mut dp.DMA1_CH2, 5, color_list[color_list_index], - pac::TIM3.ccr(0).as_ptr() as *mut _, + pac::TIM3.ccr(pwm_channel.raw()).as_ptr() as *mut _, dma_transfer_option, ) .await; @@ -117,7 +119,7 @@ async fn main(_spawner: Spawner) { } // stop PWM output for saving some energy - ws2812_pwm.disable(Channel::Ch1); + ws2812_pwm.disable(pwm_channel); // wait another half second, so that we can see color change Timer::after_millis(500).await; From 3568e4a5ffb1aebb97dd58975b02a00cd0a116fe Mon Sep 17 00:00:00 2001 From: Piotr Esden-Tempski Date: Fri, 15 Dec 2023 16:47:56 -0800 Subject: [PATCH 94/98] STM32 QSPI: Fix flash selection. --- embassy-stm32/src/qspi/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embassy-stm32/src/qspi/mod.rs b/embassy-stm32/src/qspi/mod.rs index 4b0e8ece..1153455c 100644 --- a/embassy-stm32/src/qspi/mod.rs +++ b/embassy-stm32/src/qspi/mod.rs @@ -119,7 +119,7 @@ impl<'d, T: Instance, Dma> Qspi<'d, T, Dma> { Some(nss.map_into()), dma, config, - FlashSelection::Flash2, + FlashSelection::Flash1, ) } From f6bc96dfbd1ec363a7bed877240a971ff1760200 Mon Sep 17 00:00:00 2001 From: Adam Greig Date: Sat, 16 Dec 2023 03:44:15 +0000 Subject: [PATCH 95/98] STM32: Enable flash support for STM32G4 --- embassy-stm32/src/flash/f0.rs | 2 +- embassy-stm32/src/flash/f3.rs | 2 +- embassy-stm32/src/flash/f4.rs | 2 +- embassy-stm32/src/flash/f7.rs | 2 +- embassy-stm32/src/flash/{g0.rs => g.rs} | 2 +- embassy-stm32/src/flash/h7.rs | 2 +- embassy-stm32/src/flash/l.rs | 2 +- embassy-stm32/src/flash/mod.rs | 6 +++--- 8 files changed, 10 insertions(+), 10 deletions(-) rename embassy-stm32/src/flash/{g0.rs => g.rs} (98%) diff --git a/embassy-stm32/src/flash/f0.rs b/embassy-stm32/src/flash/f0.rs index 1ab8435a..80d2a816 100644 --- a/embassy-stm32/src/flash/f0.rs +++ b/embassy-stm32/src/flash/f0.rs @@ -79,7 +79,7 @@ pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), E pub(crate) unsafe fn clear_all_err() { // read and write back the same value. - // This clears all "write 0 to clear" bits. + // This clears all "write 1 to clear" bits. pac::FLASH.sr().modify(|_| {}); } diff --git a/embassy-stm32/src/flash/f3.rs b/embassy-stm32/src/flash/f3.rs index 7e6d7ca2..27d5281a 100644 --- a/embassy-stm32/src/flash/f3.rs +++ b/embassy-stm32/src/flash/f3.rs @@ -79,7 +79,7 @@ pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), E pub(crate) unsafe fn clear_all_err() { // read and write back the same value. - // This clears all "write 0 to clear" bits. + // This clears all "write 1 to clear" bits. pac::FLASH.sr().modify(|_| {}); } diff --git a/embassy-stm32/src/flash/f4.rs b/embassy-stm32/src/flash/f4.rs index 5d07020c..f442c589 100644 --- a/embassy-stm32/src/flash/f4.rs +++ b/embassy-stm32/src/flash/f4.rs @@ -337,7 +337,7 @@ pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), E pub(crate) fn clear_all_err() { // read and write back the same value. - // This clears all "write 0 to clear" bits. + // This clears all "write 1 to clear" bits. pac::FLASH.sr().modify(|_| {}); } diff --git a/embassy-stm32/src/flash/f7.rs b/embassy-stm32/src/flash/f7.rs index b52231ca..017393e8 100644 --- a/embassy-stm32/src/flash/f7.rs +++ b/embassy-stm32/src/flash/f7.rs @@ -69,7 +69,7 @@ pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), E pub(crate) unsafe fn clear_all_err() { // read and write back the same value. - // This clears all "write 0 to clear" bits. + // This clears all "write 1 to clear" bits. pac::FLASH.sr().modify(|_| {}); } diff --git a/embassy-stm32/src/flash/g0.rs b/embassy-stm32/src/flash/g.rs similarity index 98% rename from embassy-stm32/src/flash/g0.rs rename to embassy-stm32/src/flash/g.rs index 19a38897..08145e9c 100644 --- a/embassy-stm32/src/flash/g0.rs +++ b/embassy-stm32/src/flash/g.rs @@ -92,6 +92,6 @@ pub(crate) unsafe fn wait_ready_blocking() -> Result<(), Error> { pub(crate) unsafe fn clear_all_err() { // read and write back the same value. - // This clears all "write 0 to clear" bits. + // This clears all "write 1 to clear" bits. pac::FLASH.sr().modify(|_| {}); } diff --git a/embassy-stm32/src/flash/h7.rs b/embassy-stm32/src/flash/h7.rs index b064fd6e..555f8d15 100644 --- a/embassy-stm32/src/flash/h7.rs +++ b/embassy-stm32/src/flash/h7.rs @@ -113,7 +113,7 @@ pub(crate) unsafe fn clear_all_err() { unsafe fn bank_clear_all_err(bank: pac::flash::Bank) { // read and write back the same value. - // This clears all "write 0 to clear" bits. + // This clears all "write 1 to clear" bits. bank.sr().modify(|_| {}); } diff --git a/embassy-stm32/src/flash/l.rs b/embassy-stm32/src/flash/l.rs index 1db0da92..e0159a3f 100644 --- a/embassy-stm32/src/flash/l.rs +++ b/embassy-stm32/src/flash/l.rs @@ -120,7 +120,7 @@ pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), E pub(crate) unsafe fn clear_all_err() { // read and write back the same value. - // This clears all "write 0 to clear" bits. + // This clears all "write 1 to clear" bits. pac::FLASH.sr().modify(|_| {}); } diff --git a/embassy-stm32/src/flash/mod.rs b/embassy-stm32/src/flash/mod.rs index fb20dcd3..3e8f2830 100644 --- a/embassy-stm32/src/flash/mod.rs +++ b/embassy-stm32/src/flash/mod.rs @@ -63,13 +63,13 @@ impl FlashRegion { #[cfg_attr(flash_f3, path = "f3.rs")] #[cfg_attr(flash_f4, path = "f4.rs")] #[cfg_attr(flash_f7, path = "f7.rs")] -#[cfg_attr(flash_g0, path = "g0.rs")] +#[cfg_attr(any(flash_g0, flash_g4), path = "g.rs")] #[cfg_attr(flash_h7, path = "h7.rs")] #[cfg_attr(flash_h7ab, path = "h7.rs")] #[cfg_attr( not(any( - flash_l0, flash_l1, flash_l4, flash_wl, flash_wb, flash_f0, flash_f3, flash_f4, flash_f7, flash_g0, flash_h7, - flash_h7ab + flash_l0, flash_l1, flash_l4, flash_wl, flash_wb, flash_f0, flash_f3, flash_f4, flash_f7, flash_g0, flash_g4, + flash_h7, flash_h7ab )), path = "other.rs" )] From a5379e708cab6e284a00f8b01e9db3d5c2eb400c Mon Sep 17 00:00:00 2001 From: djstrickland <96876452+dstric-aqueduct@users.noreply.github.com> Date: Sat, 16 Dec 2023 08:19:52 -0500 Subject: [PATCH 96/98] remove `suspendable` field from `embassy_usb::builder::Config` --- embassy-usb/src/builder.rs | 10 ---------- embassy-usb/src/lib.rs | 8 +++----- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/embassy-usb/src/builder.rs b/embassy-usb/src/builder.rs index ebc1283e..c4705d04 100644 --- a/embassy-usb/src/builder.rs +++ b/embassy-usb/src/builder.rs @@ -94,15 +94,6 @@ pub struct Config<'a> { /// Default: 100mA /// Max: 500mA pub max_power: u16, - - /// Allow the bus to be suspended. - /// - /// If set to `true`, the bus will put itself in the suspended state - /// when it receives a `driver::Event::Suspend` bus event. If you wish - /// to override this behavior, set this field to `false`. - /// - /// Default: `true` - pub suspendable: bool, } impl<'a> Config<'a> { @@ -123,7 +114,6 @@ impl<'a> Config<'a> { supports_remote_wakeup: false, composite_with_iads: false, max_power: 100, - suspendable: true, } } } diff --git a/embassy-usb/src/lib.rs b/embassy-usb/src/lib.rs index ff329587..241e33a7 100644 --- a/embassy-usb/src/lib.rs +++ b/embassy-usb/src/lib.rs @@ -471,11 +471,9 @@ impl<'d, D: Driver<'d>> Inner<'d, D> { } Event::Suspend => { trace!("usb: suspend"); - if self.config.suspendable { - self.suspended = true; - for h in &mut self.handlers { - h.suspended(true); - } + self.suspended = true; + for h in &mut self.handlers { + h.suspended(true); } } Event::PowerDetected => { From b857334f92fc188004567edb93e0d1dfce4c259e Mon Sep 17 00:00:00 2001 From: RobertTDowling Date: Sun, 17 Dec 2023 15:11:03 -0800 Subject: [PATCH 97/98] STM32: Fix race in alarm setting, which impacted scheduling. Detect potential race condition (should be rare) and return false back to caller, allowing them to handle the possibility that either the alarm was never set because it was in the past (old meaning of false), or that in fact the alarm was set and may have fired within the race window (new meaning of false). In either case, the caller needs to make sure the callback got called. --- embassy-stm32/src/time_driver.rs | 19 ++++++++++++++++--- embassy-time/src/driver.rs | 4 ++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/embassy-stm32/src/time_driver.rs b/embassy-stm32/src/time_driver.rs index ea9c22d8..9981800b 100644 --- a/embassy-stm32/src/time_driver.rs +++ b/embassy-stm32/src/time_driver.rs @@ -474,16 +474,29 @@ impl Driver for RtcDriver { return false; } - let safe_timestamp = timestamp.max(t + 3); - // Write the CCR value regardless of whether we're going to enable it now or not. // This way, when we enable it later, the right value is already set. - r.ccr(n + 1).write(|w| w.set_ccr(safe_timestamp as u16)); + r.ccr(n + 1).write(|w| w.set_ccr(timestamp as u16)); // Enable it if it'll happen soon. Otherwise, `next_period` will enable it. let diff = timestamp - t; r.dier().modify(|w| w.set_ccie(n + 1, diff < 0xc000)); + // Reevaluate if the alarm timestamp is still in the future + let t = self.now(); + if timestamp <= t { + // If alarm timestamp has passed since we set it, we have a race condition and + // the alarm may or may not have fired. + // Disarm the alarm and return `false` to indicate that. + // It is the caller's responsibility to handle this ambiguity. + r.dier().modify(|w| w.set_ccie(n + 1, false)); + + alarm.timestamp.set(u64::MAX); + + return false; + } + + // We're confident the alarm will ring in the future. true }) } diff --git a/embassy-time/src/driver.rs b/embassy-time/src/driver.rs index 5fe7beca..81ee1b0f 100644 --- a/embassy-time/src/driver.rs +++ b/embassy-time/src/driver.rs @@ -108,6 +108,10 @@ pub trait Driver: Send + Sync + 'static { /// The `Driver` implementation should guarantee that the alarm callback is never called synchronously from `set_alarm`. /// Rather - if `timestamp` is already in the past - `false` should be returned and alarm should not be set, /// or alternatively, the driver should return `true` and arrange to call the alarm callback as soon as possible, but not synchronously. + /// There is a rare third possibility that the alarm was barely in the future, and by the time it was enabled, it had slipped into the + /// past. This is can be detected by double-checking that the alarm is still in the future after enabling it; if it isn't, `false` + /// should also be returned to indicate that the callback may have been called already by the alarm, but it is not guaranteed, so the + /// caller should also call the callback, just like in the more common `false` case. (Note: This requires idempotency of the callback.) /// /// When callback is called, it is guaranteed that now() will return a value greater or equal than timestamp. /// From 80c9d04bbd83367340a4f3a1e991df825a0b6029 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Sun, 17 Dec 2023 22:09:14 +0100 Subject: [PATCH 98/98] stm32: add some docs. --- embassy-nrf/src/gpio.rs | 25 ++++---- embassy-stm32/src/adc/mod.rs | 6 ++ embassy-stm32/src/adc/resolution.rs | 7 +++ embassy-stm32/src/adc/v4.rs | 11 ++++ embassy-stm32/src/can/fdcan.rs | 15 +---- embassy-stm32/src/crc/v2v3.rs | 13 ++++ embassy-stm32/src/dac/mod.rs | 21 ++++--- embassy-stm32/src/dac/tsel.rs | 2 + embassy-stm32/src/dcmi.rs | 24 +++++++- embassy-stm32/src/dma/bdma.rs | 62 ++++++++++++++++--- embassy-stm32/src/dma/dma.rs | 79 ++++++++++++++++++++++-- embassy-stm32/src/dma/dmamux.rs | 4 ++ embassy-stm32/src/dma/mod.rs | 7 +++ embassy-stm32/src/dma/word.rs | 10 +++ embassy-stm32/src/eth/generic_smi.rs | 1 + embassy-stm32/src/eth/mod.rs | 25 +++++++- embassy-stm32/src/eth/v2/mod.rs | 3 + embassy-stm32/src/exti.rs | 50 ++++++++++++--- embassy-stm32/src/flash/asynch.rs | 2 +- embassy-stm32/src/flash/common.rs | 33 +++++++++- embassy-stm32/src/flash/f0.rs | 4 +- embassy-stm32/src/flash/f3.rs | 4 +- embassy-stm32/src/flash/f7.rs | 4 +- embassy-stm32/src/flash/g.rs | 4 +- embassy-stm32/src/flash/h7.rs | 4 +- embassy-stm32/src/flash/l.rs | 4 +- embassy-stm32/src/flash/mod.rs | 76 +++++++++++++++++------ embassy-stm32/src/flash/other.rs | 4 +- embassy-stm32/src/gpio.rs | 81 ++++++++++++++++++++++--- embassy-stm32/src/i2c/mod.rs | 14 ++++- embassy-stm32/src/qspi/enums.rs | 41 ++++++++++--- embassy-stm32/src/qspi/mod.rs | 4 +- embassy-stm32/src/sai/mod.rs | 4 +- embassy-stm32/src/traits.rs | 6 ++ embassy-stm32/src/usart/ringbuffered.rs | 2 +- examples/stm32f4/src/bin/flash.rs | 6 +- examples/stm32f4/src/bin/flash_async.rs | 6 +- 37 files changed, 544 insertions(+), 124 deletions(-) diff --git a/embassy-nrf/src/gpio.rs b/embassy-nrf/src/gpio.rs index 85977a80..a47fb835 100644 --- a/embassy-nrf/src/gpio.rs +++ b/embassy-nrf/src/gpio.rs @@ -50,19 +50,19 @@ impl<'d, T: Pin> Input<'d, T> { Self { pin } } - /// Test if current pin level is high. + /// Get whether the pin input level is high. #[inline] pub fn is_high(&mut self) -> bool { self.pin.is_high() } - /// Test if current pin level is low. + /// Get whether the pin input level is low. #[inline] pub fn is_low(&mut self) -> bool { self.pin.is_low() } - /// Returns current pin level + /// Get the pin input level. #[inline] pub fn get_level(&mut self) -> Level { self.pin.get_level() @@ -158,19 +158,19 @@ impl<'d, T: Pin> Output<'d, T> { self.pin.set_level(level) } - /// Is the output pin set as high? + /// Get whether the output level is set to high. #[inline] pub fn is_set_high(&mut self) -> bool { self.pin.is_set_high() } - /// Is the output pin set as low? + /// Get whether the output level is set to low. #[inline] pub fn is_set_low(&mut self) -> bool { self.pin.is_set_low() } - /// What level output is set to + /// Get the current output level. #[inline] pub fn get_output_level(&mut self) -> Level { self.pin.get_output_level() @@ -275,13 +275,13 @@ impl<'d, T: Pin> Flex<'d, T> { self.pin.conf().reset(); } - /// Test if current pin level is high. + /// Get whether the pin input level is high. #[inline] pub fn is_high(&mut self) -> bool { !self.is_low() } - /// Test if current pin level is low. + /// Get whether the pin input level is low. #[inline] pub fn is_low(&mut self) -> bool { self.ref_is_low() @@ -292,7 +292,7 @@ impl<'d, T: Pin> Flex<'d, T> { self.pin.block().in_.read().bits() & (1 << self.pin.pin()) == 0 } - /// Returns current pin level + /// Get the pin input level. #[inline] pub fn get_level(&mut self) -> Level { self.is_high().into() @@ -319,25 +319,24 @@ impl<'d, T: Pin> Flex<'d, T> { } } - /// Is the output pin set as high? + /// Get whether the output level is set to high. #[inline] pub fn is_set_high(&mut self) -> bool { !self.is_set_low() } - /// Is the output pin set as low? + /// Get whether the output level is set to low. #[inline] pub fn is_set_low(&mut self) -> bool { self.ref_is_set_low() } - /// Is the output pin set as low? #[inline] pub(crate) fn ref_is_set_low(&self) -> bool { self.pin.block().out.read().bits() & (1 << self.pin.pin()) == 0 } - /// What level output is set to + /// Get the current output level. #[inline] pub fn get_output_level(&mut self) -> Level { self.is_set_high().into() diff --git a/embassy-stm32/src/adc/mod.rs b/embassy-stm32/src/adc/mod.rs index dbe53c80..2e470662 100644 --- a/embassy-stm32/src/adc/mod.rs +++ b/embassy-stm32/src/adc/mod.rs @@ -1,3 +1,4 @@ +//! Analog to Digital (ADC) converter driver. #![macro_use] #[cfg(not(adc_f3_v2))] @@ -24,6 +25,7 @@ pub use sample_time::SampleTime; use crate::peripherals; +/// Analog to Digital driver. pub struct Adc<'d, T: Instance> { #[allow(unused)] adc: crate::PeripheralRef<'d, T>, @@ -75,12 +77,16 @@ pub(crate) mod sealed { } } +/// ADC instance. #[cfg(not(any(adc_f1, adc_v1, adc_v2, adc_v3, adc_v4, adc_f3, adc_f3_v1_1, adc_g0)))] pub trait Instance: sealed::Instance + crate::Peripheral

{} +/// ADC instance. #[cfg(any(adc_f1, adc_v1, adc_v2, adc_v3, adc_v4, adc_f3, adc_f3_v1_1, adc_g0))] pub trait Instance: sealed::Instance + crate::Peripheral

+ crate::rcc::RccPeripheral {} +/// ADC pin. pub trait AdcPin: sealed::AdcPin {} +/// ADC internal channel. pub trait InternalChannel: sealed::InternalChannel {} foreach_adc!( diff --git a/embassy-stm32/src/adc/resolution.rs b/embassy-stm32/src/adc/resolution.rs index 383980b5..64c25a77 100644 --- a/embassy-stm32/src/adc/resolution.rs +++ b/embassy-stm32/src/adc/resolution.rs @@ -1,3 +1,5 @@ +/// ADC resolution +#[allow(missing_docs)] #[cfg(any(adc_v1, adc_v2, adc_v3, adc_g0, adc_f3, adc_f3_v1_1))] #[derive(Clone, Copy, Debug, Eq, PartialEq)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] @@ -8,6 +10,8 @@ pub enum Resolution { SixBit, } +/// ADC resolution +#[allow(missing_docs)] #[cfg(adc_v4)] #[derive(Clone, Copy, Debug, Eq, PartialEq)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] @@ -49,6 +53,9 @@ impl From for crate::pac::adc::vals::Res { } impl Resolution { + /// Get the maximum reading value for this resolution. + /// + /// This is `2**n - 1`. pub fn to_max_count(&self) -> u32 { match self { #[cfg(adc_v4)] diff --git a/embassy-stm32/src/adc/v4.rs b/embassy-stm32/src/adc/v4.rs index d74617cb..048e7318 100644 --- a/embassy-stm32/src/adc/v4.rs +++ b/embassy-stm32/src/adc/v4.rs @@ -32,6 +32,7 @@ const TEMP_CHANNEL: u8 = 18; const VBAT_CHANNEL: u8 = 17; // NOTE: Vrefint/Temperature/Vbat are not available on all ADCs, this currently cannot be modeled with stm32-data, so these are available from the software on all ADCs +/// Internal voltage reference channel. pub struct VrefInt; impl InternalChannel for VrefInt {} impl super::sealed::InternalChannel for VrefInt { @@ -40,6 +41,7 @@ impl super::sealed::InternalChannel for VrefInt { } } +/// Internal temperature channel. pub struct Temperature; impl InternalChannel for Temperature {} impl super::sealed::InternalChannel for Temperature { @@ -48,6 +50,7 @@ impl super::sealed::InternalChannel for Temperature { } } +/// Internal battery voltage channel. pub struct Vbat; impl InternalChannel for Vbat {} impl super::sealed::InternalChannel for Vbat { @@ -125,6 +128,7 @@ impl Prescaler { } impl<'d, T: Instance> Adc<'d, T> { + /// Create a new ADC driver. pub fn new(adc: impl Peripheral

+ 'd, delay: &mut impl DelayUs) -> Self { embassy_hal_internal::into_ref!(adc); T::enable_and_reset(); @@ -212,6 +216,7 @@ impl<'d, T: Instance> Adc<'d, T> { }); } + /// Enable reading the voltage reference internal channel. pub fn enable_vrefint(&self) -> VrefInt { T::common_regs().ccr().modify(|reg| { reg.set_vrefen(true); @@ -220,6 +225,7 @@ impl<'d, T: Instance> Adc<'d, T> { VrefInt {} } + /// Enable reading the temperature internal channel. pub fn enable_temperature(&self) -> Temperature { T::common_regs().ccr().modify(|reg| { reg.set_vsenseen(true); @@ -228,6 +234,7 @@ impl<'d, T: Instance> Adc<'d, T> { Temperature {} } + /// Enable reading the vbat internal channel. pub fn enable_vbat(&self) -> Vbat { T::common_regs().ccr().modify(|reg| { reg.set_vbaten(true); @@ -236,10 +243,12 @@ impl<'d, T: Instance> Adc<'d, T> { Vbat {} } + /// Set the ADC sample time. pub fn set_sample_time(&mut self, sample_time: SampleTime) { self.sample_time = sample_time; } + /// Set the ADC resolution. pub fn set_resolution(&mut self, resolution: Resolution) { T::regs().cfgr().modify(|reg| reg.set_res(resolution.into())); } @@ -263,6 +272,7 @@ impl<'d, T: Instance> Adc<'d, T> { T::regs().dr().read().0 as u16 } + /// Read an ADC pin. pub fn read

(&mut self, pin: &mut P) -> u16 where P: AdcPin, @@ -273,6 +283,7 @@ impl<'d, T: Instance> Adc<'d, T> { self.read_channel(pin.channel()) } + /// Read an ADC internal channel. pub fn read_internal(&mut self, channel: &mut impl InternalChannel) -> u16 { self.read_channel(channel.channel()) } diff --git a/embassy-stm32/src/can/fdcan.rs b/embassy-stm32/src/can/fdcan.rs index f77788db..0cc2559c 100644 --- a/embassy-stm32/src/can/fdcan.rs +++ b/embassy-stm32/src/can/fdcan.rs @@ -1,6 +1,3 @@ -pub use bxcan; -use embassy_hal_internal::PeripheralRef; - use crate::peripherals; pub(crate) mod sealed { @@ -25,27 +22,19 @@ pub(crate) mod sealed { } pub trait Instance { - const REGISTERS: *mut bxcan::RegisterBlock; - fn regs() -> &'static crate::pac::can::Fdcan; fn state() -> &'static State; } } +/// Interruptable FDCAN instance. pub trait InterruptableInstance {} +/// FDCAN instance. pub trait Instance: sealed::Instance + InterruptableInstance + 'static {} -pub struct BxcanInstance<'a, T>(PeripheralRef<'a, T>); - -unsafe impl<'d, T: Instance> bxcan::Instance for BxcanInstance<'d, T> { - const REGISTERS: *mut bxcan::RegisterBlock = T::REGISTERS; -} - foreach_peripheral!( (can, $inst:ident) => { impl sealed::Instance for peripherals::$inst { - const REGISTERS: *mut bxcan::RegisterBlock = crate::pac::$inst.as_ptr() as *mut _; - fn regs() -> &'static crate::pac::can::Fdcan { &crate::pac::$inst } diff --git a/embassy-stm32/src/crc/v2v3.rs b/embassy-stm32/src/crc/v2v3.rs index b36f6018..0c4ae55c 100644 --- a/embassy-stm32/src/crc/v2v3.rs +++ b/embassy-stm32/src/crc/v2v3.rs @@ -6,15 +6,19 @@ use crate::peripherals::CRC; use crate::rcc::sealed::RccPeripheral; use crate::Peripheral; +/// CRC driver. pub struct Crc<'d> { _peripheral: PeripheralRef<'d, CRC>, _config: Config, } +/// CRC configuration errlr pub enum ConfigError { + /// The selected polynomial is invalid. InvalidPolynomial, } +/// CRC configuration pub struct Config { reverse_in: InputReverseConfig, reverse_out: bool, @@ -25,14 +29,20 @@ pub struct Config { crc_poly: u32, } +/// Input reverse configuration. pub enum InputReverseConfig { + /// Don't reverse anything None, + /// Reverse bytes Byte, + /// Reverse 16-bit halfwords. Halfword, + /// Reverse 32-bit words. Word, } impl Config { + /// Create a new CRC config. pub fn new( reverse_in: InputReverseConfig, reverse_out: bool, @@ -57,7 +67,9 @@ impl Config { } } +/// Polynomial size #[cfg(crc_v3)] +#[allow(missing_docs)] pub enum PolySize { Width7, Width8, @@ -81,6 +93,7 @@ impl<'d> Crc<'d> { instance } + /// Reset the CRC engine. pub fn reset(&mut self) { PAC_CRC.cr().modify(|w| w.set_reset(true)); } diff --git a/embassy-stm32/src/dac/mod.rs b/embassy-stm32/src/dac/mod.rs index 500eac4c..9c670195 100644 --- a/embassy-stm32/src/dac/mod.rs +++ b/embassy-stm32/src/dac/mod.rs @@ -62,11 +62,11 @@ impl Mode { /// /// 12-bit values outside the permitted range are silently truncated. pub enum Value { - // 8 bit value + /// 8 bit value Bit8(u8), - // 12 bit value stored in a u16, left-aligned + /// 12 bit value stored in a u16, left-aligned Bit12Left(u16), - // 12 bit value stored in a u16, right-aligned + /// 12 bit value stored in a u16, right-aligned Bit12Right(u16), } @@ -76,11 +76,11 @@ pub enum Value { /// /// 12-bit values outside the permitted range are silently truncated. pub enum DualValue { - // 8 bit value + /// 8 bit value Bit8(u8, u8), - // 12 bit value stored in a u16, left-aligned + /// 12 bit value stored in a u16, left-aligned Bit12Left(u16, u16), - // 12 bit value stored in a u16, right-aligned + /// 12 bit value stored in a u16, right-aligned Bit12Right(u16, u16), } @@ -88,11 +88,11 @@ pub enum DualValue { #[cfg_attr(feature = "defmt", derive(defmt::Format))] /// Array variant of [`Value`]. pub enum ValueArray<'a> { - // 8 bit values + /// 8 bit values Bit8(&'a [u8]), - // 12 bit value stored in a u16, left-aligned + /// 12 bit value stored in a u16, left-aligned Bit12Left(&'a [u16]), - // 12 bit values stored in a u16, right-aligned + /// 12 bit values stored in a u16, right-aligned Bit12Right(&'a [u16]), } @@ -106,7 +106,9 @@ pub struct DacChannel<'d, T: Instance, const N: u8, DMA = NoDma> { dma: PeripheralRef<'d, DMA>, } +/// DAC channel 1 type alias. pub type DacCh1<'d, T, DMA = NoDma> = DacChannel<'d, T, 1, DMA>; +/// DAC channel 2 type alias. pub type DacCh2<'d, T, DMA = NoDma> = DacChannel<'d, T, 2, DMA>; impl<'d, T: Instance, const N: u8, DMA> DacChannel<'d, T, N, DMA> { @@ -492,6 +494,7 @@ pub(crate) mod sealed { } } +/// DAC instance. pub trait Instance: sealed::Instance + RccPeripheral + 'static {} dma_trait!(DacDma1, Instance); dma_trait!(DacDma2, Instance); diff --git a/embassy-stm32/src/dac/tsel.rs b/embassy-stm32/src/dac/tsel.rs index f38dd8fd..22d8d3df 100644 --- a/embassy-stm32/src/dac/tsel.rs +++ b/embassy-stm32/src/dac/tsel.rs @@ -1,3 +1,5 @@ +#![allow(missing_docs)] + /// Trigger selection for STM32F0. #[cfg(stm32f0)] #[derive(Debug, Copy, Clone, Eq, PartialEq)] diff --git a/embassy-stm32/src/dcmi.rs b/embassy-stm32/src/dcmi.rs index b1223079..139d8fd1 100644 --- a/embassy-stm32/src/dcmi.rs +++ b/embassy-stm32/src/dcmi.rs @@ -36,6 +36,7 @@ impl interrupt::typelevel::Handler for InterruptHandl } /// The level on the VSync pin when the data is not valid on the parallel interface. +#[allow(missing_docs)] #[derive(Clone, Copy, PartialEq)] pub enum VSyncDataInvalidLevel { Low, @@ -43,6 +44,7 @@ pub enum VSyncDataInvalidLevel { } /// The level on the VSync pin when the data is not valid on the parallel interface. +#[allow(missing_docs)] #[derive(Clone, Copy, PartialEq)] pub enum HSyncDataInvalidLevel { Low, @@ -50,14 +52,16 @@ pub enum HSyncDataInvalidLevel { } #[derive(Clone, Copy, PartialEq)] +#[allow(missing_docs)] pub enum PixelClockPolarity { RisingEdge, FallingEdge, } -pub struct State { +struct State { waker: AtomicWaker, } + impl State { const fn new() -> State { State { @@ -68,18 +72,25 @@ impl State { static STATE: State = State::new(); +/// DCMI error. #[derive(Debug, Eq, PartialEq, Copy, Clone)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[non_exhaustive] pub enum Error { + /// Overrun error: the hardware generated data faster than we could read it. Overrun, + /// Internal peripheral error. PeripheralError, } +/// DCMI configuration. #[non_exhaustive] pub struct Config { + /// VSYNC level. pub vsync_level: VSyncDataInvalidLevel, + /// HSYNC level. pub hsync_level: HSyncDataInvalidLevel, + /// PIXCLK polarity. pub pixclk_polarity: PixelClockPolarity, } @@ -105,6 +116,7 @@ macro_rules! config_pins { }; } +/// DCMI driver. pub struct Dcmi<'d, T: Instance, Dma: FrameDma> { inner: PeripheralRef<'d, T>, dma: PeripheralRef<'d, Dma>, @@ -115,6 +127,7 @@ where T: Instance, Dma: FrameDma, { + /// Create a new DCMI driver with 8 data bits. pub fn new_8bit( peri: impl Peripheral

+ 'd, dma: impl Peripheral

+ 'd, @@ -139,6 +152,7 @@ where Self::new_inner(peri, dma, config, false, 0b00) } + /// Create a new DCMI driver with 10 data bits. pub fn new_10bit( peri: impl Peripheral

+ 'd, dma: impl Peripheral

+ 'd, @@ -165,6 +179,7 @@ where Self::new_inner(peri, dma, config, false, 0b01) } + /// Create a new DCMI driver with 12 data bits. pub fn new_12bit( peri: impl Peripheral

+ 'd, dma: impl Peripheral

+ 'd, @@ -193,6 +208,7 @@ where Self::new_inner(peri, dma, config, false, 0b10) } + /// Create a new DCMI driver with 14 data bits. pub fn new_14bit( peri: impl Peripheral

+ 'd, dma: impl Peripheral

+ 'd, @@ -223,6 +239,7 @@ where Self::new_inner(peri, dma, config, false, 0b11) } + /// Create a new DCMI driver with 8 data bits, with embedded synchronization. pub fn new_es_8bit( peri: impl Peripheral

+ 'd, dma: impl Peripheral

+ 'd, @@ -245,6 +262,7 @@ where Self::new_inner(peri, dma, config, true, 0b00) } + /// Create a new DCMI driver with 10 data bits, with embedded synchronization. pub fn new_es_10bit( peri: impl Peripheral

+ 'd, dma: impl Peripheral

+ 'd, @@ -269,6 +287,7 @@ where Self::new_inner(peri, dma, config, true, 0b01) } + /// Create a new DCMI driver with 12 data bits, with embedded synchronization. pub fn new_es_12bit( peri: impl Peripheral

+ 'd, dma: impl Peripheral

+ 'd, @@ -295,6 +314,7 @@ where Self::new_inner(peri, dma, config, true, 0b10) } + /// Create a new DCMI driver with 14 data bits, with embedded synchronization. pub fn new_es_14bit( peri: impl Peripheral

+ 'd, dma: impl Peripheral

+ 'd, @@ -538,7 +558,9 @@ mod sealed { } } +/// DCMI instance. pub trait Instance: sealed::Instance + 'static { + /// Interrupt for this instance. type Interrupt: interrupt::typelevel::Interrupt; } diff --git a/embassy-stm32/src/dma/bdma.rs b/embassy-stm32/src/dma/bdma.rs index a7422f66..5102330c 100644 --- a/embassy-stm32/src/dma/bdma.rs +++ b/embassy-stm32/src/dma/bdma.rs @@ -1,4 +1,4 @@ -#![macro_use] +//! Basic Direct Memory Acccess (BDMA) use core::future::Future; use core::pin::Pin; @@ -17,6 +17,7 @@ use crate::interrupt::Priority; use crate::pac; use crate::pac::bdma::{regs, vals}; +/// BDMA transfer options. #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[non_exhaustive] @@ -140,13 +141,17 @@ pub(crate) unsafe fn on_irq_inner(dma: pac::bdma::Dma, channel_num: usize, index STATE.ch_wakers[index].wake(); } +/// DMA request type alias. #[cfg(any(bdma_v2, dmamux))] pub type Request = u8; +/// DMA request type alias. #[cfg(not(any(bdma_v2, dmamux)))] pub type Request = (); +/// DMA channel. #[cfg(dmamux)] pub trait Channel: sealed::Channel + Peripheral

+ 'static + super::dmamux::MuxChannel {} +/// DMA channel. #[cfg(not(dmamux))] pub trait Channel: sealed::Channel + Peripheral

+ 'static {} @@ -161,12 +166,14 @@ pub(crate) mod sealed { } } +/// DMA transfer. #[must_use = "futures do nothing unless you `.await` or poll them"] pub struct Transfer<'a, C: Channel> { channel: PeripheralRef<'a, C>, } impl<'a, C: Channel> Transfer<'a, C> { + /// Create a new read DMA transfer (peripheral to memory). pub unsafe fn new_read( channel: impl Peripheral

+ 'a, request: Request, @@ -177,6 +184,7 @@ impl<'a, C: Channel> Transfer<'a, C> { Self::new_read_raw(channel, request, peri_addr, buf, options) } + /// Create a new read DMA transfer (peripheral to memory), using raw pointers. pub unsafe fn new_read_raw( channel: impl Peripheral

+ 'a, request: Request, @@ -202,6 +210,7 @@ impl<'a, C: Channel> Transfer<'a, C> { ) } + /// Create a new write DMA transfer (memory to peripheral). pub unsafe fn new_write( channel: impl Peripheral

+ 'a, request: Request, @@ -212,6 +221,7 @@ impl<'a, C: Channel> Transfer<'a, C> { Self::new_write_raw(channel, request, buf, peri_addr, options) } + /// Create a new write DMA transfer (memory to peripheral), using raw pointers. pub unsafe fn new_write_raw( channel: impl Peripheral

+ 'a, request: Request, @@ -237,6 +247,7 @@ impl<'a, C: Channel> Transfer<'a, C> { ) } + /// Create a new write DMA transfer (memory to peripheral), writing the same value repeatedly. pub unsafe fn new_write_repeated( channel: impl Peripheral

+ 'a, request: Request, @@ -321,6 +332,9 @@ impl<'a, C: Channel> Transfer<'a, C> { }); } + /// Request the transfer to stop. + /// + /// This doesn't immediately stop the transfer, you have to wait until [`is_running`](Self::is_running) returns false. pub fn request_stop(&mut self) { let ch = self.channel.regs().ch(self.channel.num()); @@ -331,6 +345,10 @@ impl<'a, C: Channel> Transfer<'a, C> { }); } + /// Return whether this transfer is still running. + /// + /// If this returns `false`, it can be because either the transfer finished, or + /// it was requested to stop early with [`request_stop`](Self::request_stop). pub fn is_running(&mut self) -> bool { let ch = self.channel.regs().ch(self.channel.num()); let en = ch.cr().read().en(); @@ -339,13 +357,15 @@ impl<'a, C: Channel> Transfer<'a, C> { en && (circular || !tcif) } - /// Gets the total remaining transfers for the channel - /// Note: this will be zero for transfers that completed without cancellation. + /// Get the total remaining transfers for the channel. + /// + /// This will be zero for transfers that completed instead of being canceled with [`request_stop`](Self::request_stop). pub fn get_remaining_transfers(&self) -> u16 { let ch = self.channel.regs().ch(self.channel.num()); ch.ndtr().read().ndt() } + /// Blocking wait until the transfer finishes. pub fn blocking_wait(mut self) { while self.is_running() {} self.request_stop(); @@ -411,6 +431,7 @@ impl<'a, C: Channel> DmaCtrl for DmaCtrlImpl<'a, C> { } } +/// Ringbuffer for reading data using DMA circular mode. pub struct ReadableRingBuffer<'a, C: Channel, W: Word> { cr: regs::Cr, channel: PeripheralRef<'a, C>, @@ -418,7 +439,8 @@ pub struct ReadableRingBuffer<'a, C: Channel, W: Word> { } impl<'a, C: Channel, W: Word> ReadableRingBuffer<'a, C, W> { - pub unsafe fn new_read( + /// Create a new ring buffer. + pub unsafe fn new( channel: impl Peripheral

+ 'a, _request: Request, peri_addr: *mut W, @@ -473,11 +495,15 @@ impl<'a, C: Channel, W: Word> ReadableRingBuffer<'a, C, W> { this } + /// Start the ring buffer operation. + /// + /// You must call this after creating it for it to work. pub fn start(&mut self) { let ch = self.channel.regs().ch(self.channel.num()); ch.cr().write_value(self.cr) } + /// Clear all data in the ring buffer. pub fn clear(&mut self) { self.ringbuf.clear(&mut DmaCtrlImpl(self.channel.reborrow())); } @@ -509,10 +535,11 @@ impl<'a, C: Channel, W: Word> ReadableRingBuffer<'a, C, W> { } /// The capacity of the ringbuffer. - pub const fn cap(&self) -> usize { + pub const fn capacity(&self) -> usize { self.ringbuf.cap() } + /// Set a waker to be woken when at least one byte is received. pub fn set_waker(&mut self, waker: &Waker) { DmaCtrlImpl(self.channel.reborrow()).set_waker(waker); } @@ -526,6 +553,9 @@ impl<'a, C: Channel, W: Word> ReadableRingBuffer<'a, C, W> { }); } + /// Request DMA to stop. + /// + /// This doesn't immediately stop the transfer, you have to wait until [`is_running`](Self::is_running) returns false. pub fn request_stop(&mut self) { let ch = self.channel.regs().ch(self.channel.num()); @@ -539,6 +569,10 @@ impl<'a, C: Channel, W: Word> ReadableRingBuffer<'a, C, W> { }); } + /// Return whether DMA is still running. + /// + /// If this returns `false`, it can be because either the transfer finished, or + /// it was requested to stop early with [`request_stop`](Self::request_stop). pub fn is_running(&mut self) -> bool { let ch = self.channel.regs().ch(self.channel.num()); ch.cr().read().en() @@ -555,6 +589,7 @@ impl<'a, C: Channel, W: Word> Drop for ReadableRingBuffer<'a, C, W> { } } +/// Ringbuffer for writing data using DMA circular mode. pub struct WritableRingBuffer<'a, C: Channel, W: Word> { cr: regs::Cr, channel: PeripheralRef<'a, C>, @@ -562,7 +597,8 @@ pub struct WritableRingBuffer<'a, C: Channel, W: Word> { } impl<'a, C: Channel, W: Word> WritableRingBuffer<'a, C, W> { - pub unsafe fn new_write( + /// Create a new ring buffer. + pub unsafe fn new( channel: impl Peripheral

+ 'a, _request: Request, peri_addr: *mut W, @@ -617,11 +653,15 @@ impl<'a, C: Channel, W: Word> WritableRingBuffer<'a, C, W> { this } + /// Start the ring buffer operation. + /// + /// You must call this after creating it for it to work. pub fn start(&mut self) { let ch = self.channel.regs().ch(self.channel.num()); ch.cr().write_value(self.cr) } + /// Clear all data in the ring buffer. pub fn clear(&mut self) { self.ringbuf.clear(&mut DmaCtrlImpl(self.channel.reborrow())); } @@ -640,10 +680,11 @@ impl<'a, C: Channel, W: Word> WritableRingBuffer<'a, C, W> { } /// The capacity of the ringbuffer. - pub const fn cap(&self) -> usize { + pub const fn capacity(&self) -> usize { self.ringbuf.cap() } + /// Set a waker to be woken when at least one byte is sent. pub fn set_waker(&mut self, waker: &Waker) { DmaCtrlImpl(self.channel.reborrow()).set_waker(waker); } @@ -657,6 +698,9 @@ impl<'a, C: Channel, W: Word> WritableRingBuffer<'a, C, W> { }); } + /// Request DMA to stop. + /// + /// This doesn't immediately stop the transfer, you have to wait until [`is_running`](Self::is_running) returns false. pub fn request_stop(&mut self) { let ch = self.channel.regs().ch(self.channel.num()); @@ -670,6 +714,10 @@ impl<'a, C: Channel, W: Word> WritableRingBuffer<'a, C, W> { }); } + /// Return whether DMA is still running. + /// + /// If this returns `false`, it can be because either the transfer finished, or + /// it was requested to stop early with [`request_stop`](Self::request_stop). pub fn is_running(&mut self) -> bool { let ch = self.channel.regs().ch(self.channel.num()); ch.cr().read().en() diff --git a/embassy-stm32/src/dma/dma.rs b/embassy-stm32/src/dma/dma.rs index cce0407c..64e492c1 100644 --- a/embassy-stm32/src/dma/dma.rs +++ b/embassy-stm32/src/dma/dma.rs @@ -16,6 +16,7 @@ use crate::interrupt::Priority; use crate::pac::dma::{regs, vals}; use crate::{interrupt, pac}; +/// DMA transfer options. #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[non_exhaustive] @@ -69,6 +70,7 @@ impl From

for vals::Dir { } } +/// DMA transfer burst setting. #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Burst { @@ -93,6 +95,7 @@ impl From for vals::Burst { } } +/// DMA flow control setting. #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum FlowControl { @@ -111,6 +114,7 @@ impl From for vals::Pfctrl { } } +/// DMA FIFO threshold. #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum FifoThreshold { @@ -208,13 +212,17 @@ pub(crate) unsafe fn on_irq_inner(dma: pac::dma::Dma, channel_num: usize, index: STATE.ch_wakers[index].wake(); } +/// DMA request type alias. (also known as DMA channel number in some chips) #[cfg(any(dma_v2, dmamux))] pub type Request = u8; +/// DMA request type alias. (also known as DMA channel number in some chips) #[cfg(not(any(dma_v2, dmamux)))] pub type Request = (); +/// DMA channel. #[cfg(dmamux)] pub trait Channel: sealed::Channel + Peripheral

+ 'static + super::dmamux::MuxChannel {} +/// DMA channel. #[cfg(not(dmamux))] pub trait Channel: sealed::Channel + Peripheral

+ 'static {} @@ -229,12 +237,14 @@ pub(crate) mod sealed { } } +/// DMA transfer. #[must_use = "futures do nothing unless you `.await` or poll them"] pub struct Transfer<'a, C: Channel> { channel: PeripheralRef<'a, C>, } impl<'a, C: Channel> Transfer<'a, C> { + /// Create a new read DMA transfer (peripheral to memory). pub unsafe fn new_read( channel: impl Peripheral

+ 'a, request: Request, @@ -245,6 +255,7 @@ impl<'a, C: Channel> Transfer<'a, C> { Self::new_read_raw(channel, request, peri_addr, buf, options) } + /// Create a new read DMA transfer (peripheral to memory), using raw pointers. pub unsafe fn new_read_raw( channel: impl Peripheral

+ 'a, request: Request, @@ -270,6 +281,7 @@ impl<'a, C: Channel> Transfer<'a, C> { ) } + /// Create a new write DMA transfer (memory to peripheral). pub unsafe fn new_write( channel: impl Peripheral

+ 'a, request: Request, @@ -280,6 +292,7 @@ impl<'a, C: Channel> Transfer<'a, C> { Self::new_write_raw(channel, request, buf, peri_addr, options) } + /// Create a new write DMA transfer (memory to peripheral), using raw pointers. pub unsafe fn new_write_raw( channel: impl Peripheral

+ 'a, request: Request, @@ -305,6 +318,7 @@ impl<'a, C: Channel> Transfer<'a, C> { ) } + /// Create a new write DMA transfer (memory to peripheral), writing the same value repeatedly. pub unsafe fn new_write_repeated( channel: impl Peripheral

+ 'a, request: Request, @@ -407,6 +421,9 @@ impl<'a, C: Channel> Transfer<'a, C> { }); } + /// Request the transfer to stop. + /// + /// This doesn't immediately stop the transfer, you have to wait until [`is_running`](Self::is_running) returns false. pub fn request_stop(&mut self) { let ch = self.channel.regs().st(self.channel.num()); @@ -417,6 +434,10 @@ impl<'a, C: Channel> Transfer<'a, C> { }); } + /// Return whether this transfer is still running. + /// + /// If this returns `false`, it can be because either the transfer finished, or + /// it was requested to stop early with [`request_stop`](Self::request_stop). pub fn is_running(&mut self) -> bool { let ch = self.channel.regs().st(self.channel.num()); ch.cr().read().en() @@ -429,6 +450,7 @@ impl<'a, C: Channel> Transfer<'a, C> { ch.ndtr().read().ndt() } + /// Blocking wait until the transfer finishes. pub fn blocking_wait(mut self) { while self.is_running() {} @@ -465,12 +487,14 @@ impl<'a, C: Channel> Future for Transfer<'a, C> { // ================================== +/// Double-buffered DMA transfer. pub struct DoubleBuffered<'a, C: Channel, W: Word> { channel: PeripheralRef<'a, C>, _phantom: PhantomData, } impl<'a, C: Channel, W: Word> DoubleBuffered<'a, C, W> { + /// Create a new read DMA transfer (peripheral to memory). pub unsafe fn new_read( channel: impl Peripheral

+ 'a, _request: Request, @@ -554,25 +578,36 @@ impl<'a, C: Channel, W: Word> DoubleBuffered<'a, C, W> { }); } + /// Set the first buffer address. + /// + /// You may call this while DMA is transferring the other buffer. pub unsafe fn set_buffer0(&mut self, buffer: *mut W) { let ch = self.channel.regs().st(self.channel.num()); ch.m0ar().write_value(buffer as _); } + /// Set the second buffer address. + /// + /// You may call this while DMA is transferring the other buffer. pub unsafe fn set_buffer1(&mut self, buffer: *mut W) { let ch = self.channel.regs().st(self.channel.num()); ch.m1ar().write_value(buffer as _); } + /// Returh whether buffer0 is accessible (i.e. whether DMA is transferring buffer1 now) pub fn is_buffer0_accessible(&mut self) -> bool { let ch = self.channel.regs().st(self.channel.num()); ch.cr().read().ct() == vals::Ct::MEMORY1 } + /// Set a waker to be woken when one of the buffers is being transferred. pub fn set_waker(&mut self, waker: &Waker) { STATE.ch_wakers[self.channel.index()].register(waker); } + /// Request the transfer to stop. + /// + /// This doesn't immediately stop the transfer, you have to wait until [`is_running`](Self::is_running) returns false. pub fn request_stop(&mut self) { let ch = self.channel.regs().st(self.channel.num()); @@ -583,6 +618,10 @@ impl<'a, C: Channel, W: Word> DoubleBuffered<'a, C, W> { }); } + /// Return whether this transfer is still running. + /// + /// If this returns `false`, it can be because either the transfer finished, or + /// it was requested to stop early with [`request_stop`](Self::request_stop). pub fn is_running(&mut self) -> bool { let ch = self.channel.regs().st(self.channel.num()); ch.cr().read().en() @@ -629,6 +668,7 @@ impl<'a, C: Channel> DmaCtrl for DmaCtrlImpl<'a, C> { } } +/// Ringbuffer for receiving data using DMA circular mode. pub struct ReadableRingBuffer<'a, C: Channel, W: Word> { cr: regs::Cr, channel: PeripheralRef<'a, C>, @@ -636,7 +676,8 @@ pub struct ReadableRingBuffer<'a, C: Channel, W: Word> { } impl<'a, C: Channel, W: Word> ReadableRingBuffer<'a, C, W> { - pub unsafe fn new_read( + /// Create a new ring buffer. + pub unsafe fn new( channel: impl Peripheral

+ 'a, _request: Request, peri_addr: *mut W, @@ -706,11 +747,15 @@ impl<'a, C: Channel, W: Word> ReadableRingBuffer<'a, C, W> { this } + /// Start the ring buffer operation. + /// + /// You must call this after creating it for it to work. pub fn start(&mut self) { let ch = self.channel.regs().st(self.channel.num()); ch.cr().write_value(self.cr); } + /// Clear all data in the ring buffer. pub fn clear(&mut self) { self.ringbuf.clear(&mut DmaCtrlImpl(self.channel.reborrow())); } @@ -741,11 +786,12 @@ impl<'a, C: Channel, W: Word> ReadableRingBuffer<'a, C, W> { .await } - // The capacity of the ringbuffer - pub const fn cap(&self) -> usize { + /// The capacity of the ringbuffer + pub const fn capacity(&self) -> usize { self.ringbuf.cap() } + /// Set a waker to be woken when at least one byte is received. pub fn set_waker(&mut self, waker: &Waker) { DmaCtrlImpl(self.channel.reborrow()).set_waker(waker); } @@ -763,6 +809,9 @@ impl<'a, C: Channel, W: Word> ReadableRingBuffer<'a, C, W> { }); } + /// Request DMA to stop. + /// + /// This doesn't immediately stop the transfer, you have to wait until [`is_running`](Self::is_running) returns false. pub fn request_stop(&mut self) { let ch = self.channel.regs().st(self.channel.num()); @@ -774,6 +823,10 @@ impl<'a, C: Channel, W: Word> ReadableRingBuffer<'a, C, W> { }); } + /// Return whether DMA is still running. + /// + /// If this returns `false`, it can be because either the transfer finished, or + /// it was requested to stop early with [`request_stop`](Self::request_stop). pub fn is_running(&mut self) -> bool { let ch = self.channel.regs().st(self.channel.num()); ch.cr().read().en() @@ -790,6 +843,7 @@ impl<'a, C: Channel, W: Word> Drop for ReadableRingBuffer<'a, C, W> { } } +/// Ringbuffer for writing data using DMA circular mode. pub struct WritableRingBuffer<'a, C: Channel, W: Word> { cr: regs::Cr, channel: PeripheralRef<'a, C>, @@ -797,7 +851,8 @@ pub struct WritableRingBuffer<'a, C: Channel, W: Word> { } impl<'a, C: Channel, W: Word> WritableRingBuffer<'a, C, W> { - pub unsafe fn new_write( + /// Create a new ring buffer. + pub unsafe fn new( channel: impl Peripheral

+ 'a, _request: Request, peri_addr: *mut W, @@ -867,11 +922,15 @@ impl<'a, C: Channel, W: Word> WritableRingBuffer<'a, C, W> { this } + /// Start the ring buffer operation. + /// + /// You must call this after creating it for it to work. pub fn start(&mut self) { let ch = self.channel.regs().st(self.channel.num()); ch.cr().write_value(self.cr); } + /// Clear all data in the ring buffer. pub fn clear(&mut self) { self.ringbuf.clear(&mut DmaCtrlImpl(self.channel.reborrow())); } @@ -889,11 +948,12 @@ impl<'a, C: Channel, W: Word> WritableRingBuffer<'a, C, W> { .await } - // The capacity of the ringbuffer - pub const fn cap(&self) -> usize { + /// The capacity of the ringbuffer + pub const fn capacity(&self) -> usize { self.ringbuf.cap() } + /// Set a waker to be woken when at least one byte is received. pub fn set_waker(&mut self, waker: &Waker) { DmaCtrlImpl(self.channel.reborrow()).set_waker(waker); } @@ -911,6 +971,9 @@ impl<'a, C: Channel, W: Word> WritableRingBuffer<'a, C, W> { }); } + /// Request DMA to stop. + /// + /// This doesn't immediately stop the transfer, you have to wait until [`is_running`](Self::is_running) returns false. pub fn request_stop(&mut self) { let ch = self.channel.regs().st(self.channel.num()); @@ -922,6 +985,10 @@ impl<'a, C: Channel, W: Word> WritableRingBuffer<'a, C, W> { }); } + /// Return whether DMA is still running. + /// + /// If this returns `false`, it can be because either the transfer finished, or + /// it was requested to stop early with [`request_stop`](Self::request_stop). pub fn is_running(&mut self) -> bool { let ch = self.channel.regs().st(self.channel.num()); ch.cr().read().en() diff --git a/embassy-stm32/src/dma/dmamux.rs b/embassy-stm32/src/dma/dmamux.rs index 20601dc8..9cd49472 100644 --- a/embassy-stm32/src/dma/dmamux.rs +++ b/embassy-stm32/src/dma/dmamux.rs @@ -22,11 +22,15 @@ pub(crate) mod dmamux_sealed { } } +/// DMAMUX1 instance. pub struct DMAMUX1; +/// DMAMUX2 instance. #[cfg(stm32h7)] pub struct DMAMUX2; +/// DMAMUX channel trait. pub trait MuxChannel: dmamux_sealed::MuxChannel { + /// DMAMUX instance this channel is on. type Mux; } diff --git a/embassy-stm32/src/dma/mod.rs b/embassy-stm32/src/dma/mod.rs index 29fced8f..fb40a4b5 100644 --- a/embassy-stm32/src/dma/mod.rs +++ b/embassy-stm32/src/dma/mod.rs @@ -39,6 +39,13 @@ enum Dir { PeripheralToMemory, } +/// "No DMA" placeholder. +/// +/// You may pass this in place of a real DMA channel when creating a driver +/// to indicate it should not use DMA. +/// +/// This often causes async functionality to not be available on the instance, +/// leaving only blocking functionality. pub struct NoDma; impl_peripheral!(NoDma); diff --git a/embassy-stm32/src/dma/word.rs b/embassy-stm32/src/dma/word.rs index aef6e970..a72c4b7d 100644 --- a/embassy-stm32/src/dma/word.rs +++ b/embassy-stm32/src/dma/word.rs @@ -1,3 +1,6 @@ +//! DMA word sizes. + +#[allow(missing_docs)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum WordSize { @@ -7,6 +10,7 @@ pub enum WordSize { } impl WordSize { + /// Amount of bytes of this word size. pub fn bytes(&self) -> usize { match self { Self::OneByte => 1, @@ -20,8 +24,13 @@ mod sealed { pub trait Word {} } +/// DMA word trait. +/// +/// This is implemented for u8, u16, u32, etc. pub trait Word: sealed::Word + Default + Copy + 'static { + /// Word size fn size() -> WordSize; + /// Amount of bits of this word size. fn bits() -> usize; } @@ -40,6 +49,7 @@ macro_rules! impl_word { ($T:ident, $uX:ident, $bits:literal, $size:ident) => { #[repr(transparent)] #[derive(Copy, Clone, Default)] + #[doc = concat!(stringify!($T), " word size")] pub struct $T(pub $uX); impl_word!(_, $T, $bits, $size); }; diff --git a/embassy-stm32/src/eth/generic_smi.rs b/embassy-stm32/src/eth/generic_smi.rs index 1e1094a1..9c26e90f 100644 --- a/embassy-stm32/src/eth/generic_smi.rs +++ b/embassy-stm32/src/eth/generic_smi.rs @@ -102,6 +102,7 @@ unsafe impl PHY for GenericSMI { /// Public functions for the PHY impl GenericSMI { + /// Set the SMI polling interval. #[cfg(feature = "time")] pub fn set_poll_interval(&mut self, poll_interval: Duration) { self.poll_interval = poll_interval diff --git a/embassy-stm32/src/eth/mod.rs b/embassy-stm32/src/eth/mod.rs index 556aadd7..dbf91eed 100644 --- a/embassy-stm32/src/eth/mod.rs +++ b/embassy-stm32/src/eth/mod.rs @@ -22,6 +22,14 @@ const RX_BUFFER_SIZE: usize = 1536; #[derive(Copy, Clone)] pub(crate) struct Packet([u8; N]); +/// Ethernet packet queue. +/// +/// This struct owns the memory used for reading and writing packets. +/// +/// `TX` is the number of packets in the transmit queue, `RX` in the receive +/// queue. A bigger queue allows the hardware to receive more packets while the +/// CPU is busy doing other things, which may increase performance (especially for RX) +/// at the cost of more RAM usage. pub struct PacketQueue { tx_desc: [TDes; TX], rx_desc: [RDes; RX], @@ -30,6 +38,7 @@ pub struct PacketQueue { } impl PacketQueue { + /// Create a new packet queue. pub const fn new() -> Self { const NEW_TDES: TDes = TDes::new(); const NEW_RDES: RDes = RDes::new(); @@ -41,7 +50,18 @@ impl PacketQueue { } } - // Allow to initialize a Self without requiring it to go on the stack + /// Initialize a packet queue in-place. + /// + /// This can be helpful to avoid accidentally stack-allocating the packet queue in the stack. The + /// Rust compiler can sometimes be a bit dumb when working with large owned values: if you call `new()` + /// and then store the returned PacketQueue in its final place (like a `static`), the compiler might + /// place it temporarily on the stack then move it. Since this struct is quite big, it may result + /// in a stack overflow. + /// + /// With this function, you can create an uninitialized `static` with type `MaybeUninit>` + /// and initialize it in-place, guaranteeing no stack usage. + /// + /// After calling this function, calling `assume_init` on the MaybeUninit is guaranteed safe. pub fn init(this: &mut MaybeUninit) { unsafe { this.as_mut_ptr().write_bytes(0u8, 1); @@ -93,6 +113,7 @@ impl<'d, T: Instance, P: PHY> embassy_net_driver::Driver for Ethernet<'d, T, P> } } +/// `embassy-net` RX token. pub struct RxToken<'a, 'd> { rx: &'a mut RDesRing<'d>, } @@ -110,6 +131,7 @@ impl<'a, 'd> embassy_net_driver::RxToken for RxToken<'a, 'd> { } } +/// `embassy-net` TX token. pub struct TxToken<'a, 'd> { tx: &'a mut TDesRing<'d>, } @@ -159,6 +181,7 @@ pub(crate) mod sealed { } } +/// Ethernet instance. pub trait Instance: sealed::Instance + Send + 'static {} impl sealed::Instance for crate::peripherals::ETH { diff --git a/embassy-stm32/src/eth/v2/mod.rs b/embassy-stm32/src/eth/v2/mod.rs index c77155fe..59745cba 100644 --- a/embassy-stm32/src/eth/v2/mod.rs +++ b/embassy-stm32/src/eth/v2/mod.rs @@ -34,6 +34,7 @@ impl interrupt::typelevel::Handler for InterruptHandl } } +/// Ethernet driver. pub struct Ethernet<'d, T: Instance, P: PHY> { _peri: PeripheralRef<'d, T>, pub(crate) tx: TDesRing<'d>, @@ -56,6 +57,7 @@ macro_rules! config_pins { } impl<'d, T: Instance, P: PHY> Ethernet<'d, T, P> { + /// Create a new Ethernet driver. pub fn new( queue: &'d mut PacketQueue, peri: impl Peripheral

+ 'd, @@ -237,6 +239,7 @@ impl<'d, T: Instance, P: PHY> Ethernet<'d, T, P> { } } +/// Ethernet SMI driver. pub struct EthernetStationManagement { peri: PhantomData, clock_range: u8, diff --git a/embassy-stm32/src/exti.rs b/embassy-stm32/src/exti.rs index e77ac30f..371be913 100644 --- a/embassy-stm32/src/exti.rs +++ b/embassy-stm32/src/exti.rs @@ -39,7 +39,7 @@ fn exticr_regs() -> pac::afio::Afio { pac::AFIO } -pub unsafe fn on_irq() { +unsafe fn on_irq() { #[cfg(feature = "low-power")] crate::low_power::on_wakeup_irq(); @@ -85,7 +85,13 @@ impl Iterator for BitIter { } } -/// EXTI input driver +/// EXTI input driver. +/// +/// This driver augments a GPIO `Input` with EXTI functionality. EXTI is not +/// built into `Input` itself because it needs to take ownership of the corresponding +/// EXTI channel, which is a limited resource. +/// +/// Pins PA5, PB5, PC5... all use EXTI channel 5, so you can't use EXTI on, say, PA5 and PC5 at the same time. pub struct ExtiInput<'d, T: GpioPin> { pin: Input<'d, T>, } @@ -93,23 +99,30 @@ pub struct ExtiInput<'d, T: GpioPin> { impl<'d, T: GpioPin> Unpin for ExtiInput<'d, T> {} impl<'d, T: GpioPin> ExtiInput<'d, T> { + /// Create an EXTI input. pub fn new(pin: Input<'d, T>, _ch: impl Peripheral

+ 'd) -> Self { Self { pin } } + /// Get whether the pin is high. pub fn is_high(&mut self) -> bool { self.pin.is_high() } + /// Get whether the pin is low. pub fn is_low(&mut self) -> bool { self.pin.is_low() } + /// Get the pin level. pub fn get_level(&mut self) -> Level { self.pin.get_level() } - pub async fn wait_for_high<'a>(&'a mut self) { + /// Asynchronously wait until the pin is high. + /// + /// This returns immediately if the pin is already high. + pub async fn wait_for_high(&mut self) { let fut = ExtiInputFuture::new(self.pin.pin.pin.pin(), self.pin.pin.pin.port(), true, false); if self.is_high() { return; @@ -117,7 +130,10 @@ impl<'d, T: GpioPin> ExtiInput<'d, T> { fut.await } - pub async fn wait_for_low<'a>(&'a mut self) { + /// Asynchronously wait until the pin is low. + /// + /// This returns immediately if the pin is already low. + pub async fn wait_for_low(&mut self) { let fut = ExtiInputFuture::new(self.pin.pin.pin.pin(), self.pin.pin.pin.port(), false, true); if self.is_low() { return; @@ -125,15 +141,22 @@ impl<'d, T: GpioPin> ExtiInput<'d, T> { fut.await } - pub async fn wait_for_rising_edge<'a>(&'a mut self) { + /// Asynchronously wait until the pin sees a rising edge. + /// + /// If the pin is already high, it will wait for it to go low then back high. + pub async fn wait_for_rising_edge(&mut self) { ExtiInputFuture::new(self.pin.pin.pin.pin(), self.pin.pin.pin.port(), true, false).await } - pub async fn wait_for_falling_edge<'a>(&'a mut self) { + /// Asynchronously wait until the pin sees a falling edge. + /// + /// If the pin is already low, it will wait for it to go high then back low. + pub async fn wait_for_falling_edge(&mut self) { ExtiInputFuture::new(self.pin.pin.pin.pin(), self.pin.pin.pin.port(), false, true).await } - pub async fn wait_for_any_edge<'a>(&'a mut self) { + /// Asynchronously wait until the pin sees any edge (either rising or falling). + pub async fn wait_for_any_edge(&mut self) { ExtiInputFuture::new(self.pin.pin.pin.pin(), self.pin.pin.pin.port(), true, true).await } } @@ -284,6 +307,7 @@ macro_rules! foreach_exti_irq { macro_rules! impl_irq { ($e:ident) => { + #[allow(non_snake_case)] #[cfg(feature = "rt")] #[interrupt] unsafe fn $e() { @@ -298,8 +322,16 @@ pub(crate) mod sealed { pub trait Channel {} } +/// EXTI channel trait. pub trait Channel: sealed::Channel + Sized { + /// Get the EXTI channel number. fn number(&self) -> usize; + + /// Type-erase (degrade) this channel into an `AnyChannel`. + /// + /// This converts EXTI channel singletons (`EXTI0`, `EXTI1`, ...), which + /// are all different types, into the same type. It is useful for + /// creating arrays of channels, or avoiding generics. fn degrade(self) -> AnyChannel { AnyChannel { number: self.number() as u8, @@ -307,9 +339,13 @@ pub trait Channel: sealed::Channel + Sized { } } +/// Type-erased (degraded) EXTI channel. +/// +/// This represents ownership over any EXTI channel, known at runtime. pub struct AnyChannel { number: u8, } + impl_peripheral!(AnyChannel); impl sealed::Channel for AnyChannel {} impl Channel for AnyChannel { diff --git a/embassy-stm32/src/flash/asynch.rs b/embassy-stm32/src/flash/asynch.rs index eae40c7e..e3c6d4d6 100644 --- a/embassy-stm32/src/flash/asynch.rs +++ b/embassy-stm32/src/flash/asynch.rs @@ -59,7 +59,7 @@ impl embedded_storage_async::nor_flash::ReadNorFlash for Flash<'_, Async> { const READ_SIZE: usize = super::READ_SIZE; async fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { - self.read(offset, bytes) + self.blocking_read(offset, bytes) } fn capacity(&self) -> usize { diff --git a/embassy-stm32/src/flash/common.rs b/embassy-stm32/src/flash/common.rs index 8acad1c7..f8561edb 100644 --- a/embassy-stm32/src/flash/common.rs +++ b/embassy-stm32/src/flash/common.rs @@ -12,12 +12,14 @@ use super::{ use crate::peripherals::FLASH; use crate::Peripheral; +/// Internal flash memory driver. pub struct Flash<'d, MODE = Async> { pub(crate) inner: PeripheralRef<'d, FLASH>, pub(crate) _mode: PhantomData, } impl<'d> Flash<'d, Blocking> { + /// Create a new flash driver, usable in blocking mode. pub fn new_blocking(p: impl Peripheral

+ 'd) -> Self { into_ref!(p); @@ -29,15 +31,26 @@ impl<'d> Flash<'d, Blocking> { } impl<'d, MODE> Flash<'d, MODE> { + /// Split this flash driver into one instance per flash memory region. + /// + /// See module-level documentation for details on how memory regions work. pub fn into_blocking_regions(self) -> FlashLayout<'d, Blocking> { assert!(family::is_default_layout()); FlashLayout::new(self.inner) } - pub fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { + /// Blocking read. + /// + /// NOTE: `offset` is an offset from the flash start, NOT an absolute address. + /// For example, to read address `0x0800_1234` you have to use offset `0x1234`. + pub fn blocking_read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { blocking_read(FLASH_BASE as u32, FLASH_SIZE as u32, offset, bytes) } + /// Blocking write. + /// + /// NOTE: `offset` is an offset from the flash start, NOT an absolute address. + /// For example, to write address `0x0800_1234` you have to use offset `0x1234`. pub fn blocking_write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { unsafe { blocking_write( @@ -50,6 +63,10 @@ impl<'d, MODE> Flash<'d, MODE> { } } + /// Blocking erase. + /// + /// NOTE: `from` and `to` are offsets from the flash start, NOT an absolute address. + /// For example, to erase address `0x0801_0000` you have to use offset `0x1_0000`. pub fn blocking_erase(&mut self, from: u32, to: u32) -> Result<(), Error> { unsafe { blocking_erase(FLASH_BASE as u32, from, to, erase_sector_unlocked) } } @@ -206,7 +223,7 @@ impl embedded_storage::nor_flash::ReadNorFlash for Flash<'_, MODE> { const READ_SIZE: usize = READ_SIZE; fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { - self.read(offset, bytes) + self.blocking_read(offset, bytes) } fn capacity(&self) -> usize { @@ -230,16 +247,28 @@ impl embedded_storage::nor_flash::NorFlash for Flash<'_, MODE> { foreach_flash_region! { ($type_name:ident, $write_size:literal, $erase_size:literal) => { impl crate::_generated::flash_regions::$type_name<'_, MODE> { + /// Blocking read. + /// + /// NOTE: `offset` is an offset from the flash start, NOT an absolute address. + /// For example, to read address `0x0800_1234` you have to use offset `0x1234`. pub fn blocking_read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Error> { blocking_read(self.0.base, self.0.size, offset, bytes) } } impl crate::_generated::flash_regions::$type_name<'_, Blocking> { + /// Blocking write. + /// + /// NOTE: `offset` is an offset from the flash start, NOT an absolute address. + /// For example, to write address `0x0800_1234` you have to use offset `0x1234`. pub fn blocking_write(&mut self, offset: u32, bytes: &[u8]) -> Result<(), Error> { unsafe { blocking_write(self.0.base, self.0.size, offset, bytes, write_chunk_with_critical_section) } } + /// Blocking erase. + /// + /// NOTE: `from` and `to` are offsets from the flash start, NOT an absolute address. + /// For example, to erase address `0x0801_0000` you have to use offset `0x1_0000`. pub fn blocking_erase(&mut self, from: u32, to: u32) -> Result<(), Error> { unsafe { blocking_erase(self.0.base, from, to, erase_sector_with_critical_section) } } diff --git a/embassy-stm32/src/flash/f0.rs b/embassy-stm32/src/flash/f0.rs index 80d2a816..c0a8d702 100644 --- a/embassy-stm32/src/flash/f0.rs +++ b/embassy-stm32/src/flash/f0.rs @@ -6,11 +6,11 @@ use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE}; use crate::flash::Error; use crate::pac; -pub const fn is_default_layout() -> bool { +pub(crate) const fn is_default_layout() -> bool { true } -pub const fn get_flash_regions() -> &'static [&'static FlashRegion] { +pub(crate) const fn get_flash_regions() -> &'static [&'static FlashRegion] { &FLASH_REGIONS } diff --git a/embassy-stm32/src/flash/f3.rs b/embassy-stm32/src/flash/f3.rs index 27d5281a..817ccef4 100644 --- a/embassy-stm32/src/flash/f3.rs +++ b/embassy-stm32/src/flash/f3.rs @@ -6,11 +6,11 @@ use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE}; use crate::flash::Error; use crate::pac; -pub const fn is_default_layout() -> bool { +pub(crate) const fn is_default_layout() -> bool { true } -pub const fn get_flash_regions() -> &'static [&'static FlashRegion] { +pub(crate) const fn get_flash_regions() -> &'static [&'static FlashRegion] { &FLASH_REGIONS } diff --git a/embassy-stm32/src/flash/f7.rs b/embassy-stm32/src/flash/f7.rs index 017393e8..6b3e66ac 100644 --- a/embassy-stm32/src/flash/f7.rs +++ b/embassy-stm32/src/flash/f7.rs @@ -6,11 +6,11 @@ use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE}; use crate::flash::Error; use crate::pac; -pub const fn is_default_layout() -> bool { +pub(crate) const fn is_default_layout() -> bool { true } -pub const fn get_flash_regions() -> &'static [&'static FlashRegion] { +pub(crate) const fn get_flash_regions() -> &'static [&'static FlashRegion] { &FLASH_REGIONS } diff --git a/embassy-stm32/src/flash/g.rs b/embassy-stm32/src/flash/g.rs index 08145e9c..d97b4a93 100644 --- a/embassy-stm32/src/flash/g.rs +++ b/embassy-stm32/src/flash/g.rs @@ -8,11 +8,11 @@ use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE}; use crate::flash::Error; use crate::pac; -pub const fn is_default_layout() -> bool { +pub(crate) const fn is_default_layout() -> bool { true } -pub const fn get_flash_regions() -> &'static [&'static FlashRegion] { +pub(crate) const fn get_flash_regions() -> &'static [&'static FlashRegion] { &FLASH_REGIONS } diff --git a/embassy-stm32/src/flash/h7.rs b/embassy-stm32/src/flash/h7.rs index 555f8d15..65d163d2 100644 --- a/embassy-stm32/src/flash/h7.rs +++ b/embassy-stm32/src/flash/h7.rs @@ -6,7 +6,7 @@ use super::{FlashRegion, FlashSector, BANK1_REGION, FLASH_REGIONS, WRITE_SIZE}; use crate::flash::Error; use crate::pac; -pub const fn is_default_layout() -> bool { +pub(crate) const fn is_default_layout() -> bool { true } @@ -14,7 +14,7 @@ const fn is_dual_bank() -> bool { FLASH_REGIONS.len() >= 2 } -pub fn get_flash_regions() -> &'static [&'static FlashRegion] { +pub(crate) fn get_flash_regions() -> &'static [&'static FlashRegion] { &FLASH_REGIONS } diff --git a/embassy-stm32/src/flash/l.rs b/embassy-stm32/src/flash/l.rs index e0159a3f..0b332dc6 100644 --- a/embassy-stm32/src/flash/l.rs +++ b/embassy-stm32/src/flash/l.rs @@ -5,11 +5,11 @@ use super::{FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE}; use crate::flash::Error; use crate::pac; -pub const fn is_default_layout() -> bool { +pub(crate) const fn is_default_layout() -> bool { true } -pub const fn get_flash_regions() -> &'static [&'static FlashRegion] { +pub(crate) const fn get_flash_regions() -> &'static [&'static FlashRegion] { &FLASH_REGIONS } diff --git a/embassy-stm32/src/flash/mod.rs b/embassy-stm32/src/flash/mod.rs index 3e8f2830..6b6b4d41 100644 --- a/embassy-stm32/src/flash/mod.rs +++ b/embassy-stm32/src/flash/mod.rs @@ -14,50 +14,84 @@ pub use crate::_generated::flash_regions::*; pub use crate::_generated::MAX_ERASE_SIZE; pub use crate::pac::{FLASH_BASE, FLASH_SIZE, WRITE_SIZE}; +/// Get whether the default flash layout is being used. +/// +/// In some chips, dual-bank is not default. This will then return `false` +/// when dual-bank is enabled. +pub fn is_default_layout() -> bool { + family::is_default_layout() +} + +/// Get all flash regions. +pub fn get_flash_regions() -> &'static [&'static FlashRegion] { + family::get_flash_regions() +} + +/// Read size (always 1) pub const READ_SIZE: usize = 1; -pub struct Blocking; -pub struct Async; +/// Blocking flash mode typestate. +pub enum Blocking {} +/// Async flash mode typestate. +pub enum Async {} +/// Flash memory region #[derive(Debug)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub struct FlashRegion { + /// Bank number. pub bank: FlashBank, + /// Absolute base address. pub base: u32, + /// Size in bytes. pub size: u32, + /// Erase size (sector size). pub erase_size: u32, + /// Minimum write size. pub write_size: u32, + /// Erase value (usually `0xFF`, but is `0x00` in some chips) pub erase_value: u8, pub(crate) _ensure_internal: (), } -#[derive(Debug, PartialEq)] -#[cfg_attr(feature = "defmt", derive(defmt::Format))] -pub struct FlashSector { - pub bank: FlashBank, - pub index_in_bank: u8, - pub start: u32, - pub size: u32, -} - -#[derive(Clone, Copy, Debug, PartialEq)] -#[cfg_attr(feature = "defmt", derive(defmt::Format))] -pub enum FlashBank { - Bank1 = 0, - Bank2 = 1, - Otp, -} - impl FlashRegion { + /// Absolute end address. pub const fn end(&self) -> u32 { self.base + self.size } + /// Number of sectors in the region. pub const fn sectors(&self) -> u8 { (self.size / self.erase_size) as u8 } } +/// Flash sector. +#[derive(Debug, PartialEq)] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] +pub struct FlashSector { + /// Bank number. + pub bank: FlashBank, + /// Sector number within the bank. + pub index_in_bank: u8, + /// Absolute start address. + pub start: u32, + /// Size in bytes. + pub size: u32, +} + +/// Flash bank. +#[derive(Clone, Copy, Debug, PartialEq)] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] +pub enum FlashBank { + /// Bank 1 + Bank1 = 0, + /// Bank 2 + Bank2 = 1, + /// OTP region + Otp, +} + #[cfg_attr(any(flash_l0, flash_l1, flash_l4, flash_wl, flash_wb), path = "l.rs")] #[cfg_attr(flash_f0, path = "f0.rs")] #[cfg_attr(flash_f3, path = "f3.rs")] @@ -78,6 +112,10 @@ mod family; #[allow(unused_imports)] pub use family::*; +/// Flash error +/// +/// See STM32 Reference Manual for your chip for details. +#[allow(missing_docs)] #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Error { diff --git a/embassy-stm32/src/flash/other.rs b/embassy-stm32/src/flash/other.rs index a7e8d1d5..20f84a72 100644 --- a/embassy-stm32/src/flash/other.rs +++ b/embassy-stm32/src/flash/other.rs @@ -2,11 +2,11 @@ use super::{Error, FlashRegion, FlashSector, FLASH_REGIONS, WRITE_SIZE}; -pub const fn is_default_layout() -> bool { +pub(crate) const fn is_default_layout() -> bool { true } -pub const fn get_flash_regions() -> &'static [&'static FlashRegion] { +pub(crate) const fn get_flash_regions() -> &'static [&'static FlashRegion] { &FLASH_REGIONS } diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index bb3cf2bc..083b3237 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -29,6 +29,11 @@ impl<'d, T: Pin> Flex<'d, T> { Self { pin } } + /// Type-erase (degrade) this pin into an `AnyPin`. + /// + /// This converts pin singletons (`PA5`, `PB6`, ...), which + /// are all different types, into the same type. It is useful for + /// creating arrays of pins, or avoiding generics. #[inline] pub fn degrade(self) -> Flex<'d, AnyPin> { // Safety: We are about to drop the other copy of this pin, so @@ -141,11 +146,13 @@ impl<'d, T: Pin> Flex<'d, T> { }); } + /// Get whether the pin input level is high. #[inline] pub fn is_high(&mut self) -> bool { !self.ref_is_low() } + /// Get whether the pin input level is low. #[inline] pub fn is_low(&mut self) -> bool { self.ref_is_low() @@ -157,17 +164,19 @@ impl<'d, T: Pin> Flex<'d, T> { state == vals::Idr::LOW } + /// Get the current pin input level. #[inline] pub fn get_level(&mut self) -> Level { self.is_high().into() } + /// Get whether the output level is set to high. #[inline] pub fn is_set_high(&mut self) -> bool { !self.ref_is_set_low() } - /// Is the output pin set as low? + /// Get whether the output level is set to low. #[inline] pub fn is_set_low(&mut self) -> bool { self.ref_is_set_low() @@ -179,12 +188,13 @@ impl<'d, T: Pin> Flex<'d, T> { state == vals::Odr::LOW } - /// What level output is set to + /// Get the current output level. #[inline] pub fn get_output_level(&mut self) -> Level { self.is_set_high().into() } + /// Set the output as high. #[inline] pub fn set_high(&mut self) { self.pin.set_high(); @@ -196,6 +206,7 @@ impl<'d, T: Pin> Flex<'d, T> { self.pin.set_low(); } + /// Set the output level. #[inline] pub fn set_level(&mut self, level: Level) { match level { @@ -204,7 +215,7 @@ impl<'d, T: Pin> Flex<'d, T> { } } - /// Toggle pin output + /// Toggle the output level. #[inline] pub fn toggle(&mut self) { if self.is_set_low() { @@ -242,8 +253,11 @@ impl<'d, T: Pin> Drop for Flex<'d, T> { #[derive(Debug, Eq, PartialEq, Copy, Clone)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Pull { + /// No pull None, + /// Pull up Up, + /// Pull down Down, } @@ -261,6 +275,9 @@ impl From for vals::Pupdr { } /// Speed settings +/// +/// These vary dpeending on the chip, ceck the reference manual or datasheet for details. +#[allow(missing_docs)] #[derive(Debug, Copy, Clone)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Speed { @@ -305,6 +322,7 @@ pub struct Input<'d, T: Pin> { } impl<'d, T: Pin> Input<'d, T> { + /// Create GPIO input driver for a [Pin] with the provided [Pull] configuration. #[inline] pub fn new(pin: impl Peripheral

+ 'd, pull: Pull) -> Self { let mut pin = Flex::new(pin); @@ -312,6 +330,11 @@ impl<'d, T: Pin> Input<'d, T> { Self { pin } } + /// Type-erase (degrade) this pin into an `AnyPin`. + /// + /// This converts pin singletons (`PA5`, `PB6`, ...), which + /// are all different types, into the same type. It is useful for + /// creating arrays of pins, or avoiding generics. #[inline] pub fn degrade(self) -> Input<'d, AnyPin> { Input { @@ -319,16 +342,19 @@ impl<'d, T: Pin> Input<'d, T> { } } + /// Get whether the pin input level is high. #[inline] pub fn is_high(&mut self) -> bool { self.pin.is_high() } + /// Get whether the pin input level is low. #[inline] pub fn is_low(&mut self) -> bool { self.pin.is_low() } + /// Get the current pin input level. #[inline] pub fn get_level(&mut self) -> Level { self.pin.get_level() @@ -339,7 +365,9 @@ impl<'d, T: Pin> Input<'d, T> { #[derive(Debug, Eq, PartialEq, Copy, Clone)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Level { + /// Low Low, + /// High High, } @@ -371,6 +399,7 @@ pub struct Output<'d, T: Pin> { } impl<'d, T: Pin> Output<'d, T> { + /// Create GPIO output driver for a [Pin] with the provided [Level] and [Speed] configuration. #[inline] pub fn new(pin: impl Peripheral

+ 'd, initial_output: Level, speed: Speed) -> Self { let mut pin = Flex::new(pin); @@ -382,6 +411,11 @@ impl<'d, T: Pin> Output<'d, T> { Self { pin } } + /// Type-erase (degrade) this pin into an `AnyPin`. + /// + /// This converts pin singletons (`PA5`, `PB6`, ...), which + /// are all different types, into the same type. It is useful for + /// creating arrays of pins, or avoiding generics. #[inline] pub fn degrade(self) -> Output<'d, AnyPin> { Output { @@ -442,6 +476,7 @@ pub struct OutputOpenDrain<'d, T: Pin> { } impl<'d, T: Pin> OutputOpenDrain<'d, T> { + /// Create a new GPIO open drain output driver for a [Pin] with the provided [Level] and [Speed], [Pull] configuration. #[inline] pub fn new(pin: impl Peripheral

+ 'd, initial_output: Level, speed: Speed, pull: Pull) -> Self { let mut pin = Flex::new(pin); @@ -455,6 +490,11 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { Self { pin } } + /// Type-erase (degrade) this pin into an `AnyPin`. + /// + /// This converts pin singletons (`PA5`, `PB6`, ...), which + /// are all different types, into the same type. It is useful for + /// creating arrays of pins, or avoiding generics. #[inline] pub fn degrade(self) -> Output<'d, AnyPin> { Output { @@ -462,17 +502,19 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { } } + /// Get whether the pin input level is high. #[inline] pub fn is_high(&mut self) -> bool { !self.pin.is_low() } + /// Get whether the pin input level is low. #[inline] pub fn is_low(&mut self) -> bool { self.pin.is_low() } - /// Returns current pin level + /// Get the current pin input level. #[inline] pub fn get_level(&mut self) -> Level { self.pin.get_level() @@ -496,19 +538,19 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { self.pin.set_level(level); } - /// Is the output pin set as high? + /// Get whether the output level is set to high. #[inline] pub fn is_set_high(&mut self) -> bool { self.pin.is_set_high() } - /// Is the output pin set as low? + /// Get whether the output level is set to low. #[inline] pub fn is_set_low(&mut self) -> bool { self.pin.is_set_low() } - /// What level output is set to + /// Get the current output level. #[inline] pub fn get_output_level(&mut self) -> Level { self.pin.get_output_level() @@ -521,8 +563,11 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { } } +/// GPIO output type pub enum OutputType { + /// Drive the pin both high or low. PushPull, + /// Drive the pin low, or don't drive it at all if the output level is high. OpenDrain, } @@ -535,6 +580,7 @@ impl From for sealed::AFType { } } +#[allow(missing_docs)] pub(crate) mod sealed { use super::*; @@ -542,8 +588,11 @@ pub(crate) mod sealed { #[derive(Debug, Copy, Clone)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum AFType { + /// Input Input, + /// Output, drive the pin both high or low. OutputPushPull, + /// Output, drive the pin low, or don't drive it at all if the output level is high. OutputOpenDrain, } @@ -686,7 +735,11 @@ pub(crate) mod sealed { } } +/// GPIO pin trait. pub trait Pin: Peripheral

+ Into + sealed::Pin + Sized + 'static { + /// EXTI channel assigned to this pin. + /// + /// For example, PC4 uses EXTI4. #[cfg(feature = "exti")] type ExtiChannel: crate::exti::Channel; @@ -702,7 +755,11 @@ pub trait Pin: Peripheral

+ Into + sealed::Pin + Sized + 'stat self._port() } - /// Convert from concrete pin type PX_XX to type erased `AnyPin`. + /// Type-erase (degrade) this pin into an `AnyPin`. + /// + /// This converts pin singletons (`PA5`, `PB6`, ...), which + /// are all different types, into the same type. It is useful for + /// creating arrays of pins, or avoiding generics. #[inline] fn degrade(self) -> AnyPin { AnyPin { @@ -711,12 +768,15 @@ pub trait Pin: Peripheral

+ Into + sealed::Pin + Sized + 'stat } } -// Type-erased GPIO pin +/// Type-erased GPIO pin pub struct AnyPin { pin_port: u8, } impl AnyPin { + /// Unsafely create an `AnyPin` from a pin+port number. + /// + /// `pin_port` is `port_num * 16 + pin_num`, where `port_num` is 0 for port `A`, 1 for port `B`, etc... #[inline] pub unsafe fn steal(pin_port: u8) -> Self { Self { pin_port } @@ -727,6 +787,8 @@ impl AnyPin { self.pin_port / 16 } + /// Get the GPIO register block for this pin. + #[cfg(feature = "unstable-pac")] #[inline] pub fn block(&self) -> gpio::Gpio { pac::GPIO(self._port() as _) @@ -1072,6 +1134,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { } } +/// Low-level GPIO manipulation. #[cfg(feature = "unstable-pac")] pub mod low_level { pub use super::sealed::*; diff --git a/embassy-stm32/src/i2c/mod.rs b/embassy-stm32/src/i2c/mod.rs index d2a50cf7..a8dc8e0e 100644 --- a/embassy-stm32/src/i2c/mod.rs +++ b/embassy-stm32/src/i2c/mod.rs @@ -13,15 +13,23 @@ use embassy_sync::waitqueue::AtomicWaker; use crate::peripherals; +/// I2C error. #[derive(Debug, PartialEq, Eq)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Error { + /// Bus error Bus, + /// Arbitration lost Arbitration, + /// ACK not received (either to the address or to a data byte) Nack, + /// Timeout Timeout, + /// CRC error Crc, + /// Overrun error Overrun, + /// Zero-length transfers are not allowed. ZeroLengthTransfer, } @@ -47,8 +55,11 @@ pub(crate) mod sealed { } } +/// I2C peripheral instance pub trait Instance: sealed::Instance + 'static { + /// Event interrupt for this instance type EventInterrupt: interrupt::typelevel::Interrupt; + /// Error interrupt for this instance type ErrorInterrupt: interrupt::typelevel::Interrupt; } @@ -57,7 +68,7 @@ pin_trait!(SdaPin, Instance); dma_trait!(RxDma, Instance); dma_trait!(TxDma, Instance); -/// Interrupt handler. +/// Event interrupt handler. pub struct EventInterruptHandler { _phantom: PhantomData, } @@ -68,6 +79,7 @@ impl interrupt::typelevel::Handler for EventInte } } +/// Error interrupt handler. pub struct ErrorInterruptHandler { _phantom: PhantomData, } diff --git a/embassy-stm32/src/qspi/enums.rs b/embassy-stm32/src/qspi/enums.rs index 0412d991..e9e7fd48 100644 --- a/embassy-stm32/src/qspi/enums.rs +++ b/embassy-stm32/src/qspi/enums.rs @@ -18,12 +18,17 @@ impl Into for QspiMode { } } +/// QSPI lane width #[allow(dead_code)] #[derive(Copy, Clone)] pub enum QspiWidth { + /// None NONE, + /// Single lane SING, + /// Dual lanes DUAL, + /// Quad lanes QUAD, } @@ -38,10 +43,13 @@ impl Into for QspiWidth { } } +/// Flash bank selection #[allow(dead_code)] #[derive(Copy, Clone)] pub enum FlashSelection { + /// Bank 1 Flash1, + /// Bank 2 Flash2, } @@ -54,6 +62,8 @@ impl Into for FlashSelection { } } +/// QSPI memory size. +#[allow(missing_docs)] #[derive(Copy, Clone)] pub enum MemorySize { _1KiB, @@ -113,11 +123,16 @@ impl Into for MemorySize { } } +/// QSPI Address size #[derive(Copy, Clone)] pub enum AddressSize { + /// 8-bit address _8Bit, + /// 16-bit address _16Bit, + /// 24-bit address _24bit, + /// 32-bit address _32bit, } @@ -132,8 +147,10 @@ impl Into for AddressSize { } } +/// Time the Chip Select line stays high. +#[allow(missing_docs)] #[derive(Copy, Clone)] -pub enum ChipSelectHightTime { +pub enum ChipSelectHighTime { _1Cycle, _2Cycle, _3Cycle, @@ -144,21 +161,23 @@ pub enum ChipSelectHightTime { _8Cycle, } -impl Into for ChipSelectHightTime { +impl Into for ChipSelectHighTime { fn into(self) -> u8 { match self { - ChipSelectHightTime::_1Cycle => 0, - ChipSelectHightTime::_2Cycle => 1, - ChipSelectHightTime::_3Cycle => 2, - ChipSelectHightTime::_4Cycle => 3, - ChipSelectHightTime::_5Cycle => 4, - ChipSelectHightTime::_6Cycle => 5, - ChipSelectHightTime::_7Cycle => 6, - ChipSelectHightTime::_8Cycle => 7, + ChipSelectHighTime::_1Cycle => 0, + ChipSelectHighTime::_2Cycle => 1, + ChipSelectHighTime::_3Cycle => 2, + ChipSelectHighTime::_4Cycle => 3, + ChipSelectHighTime::_5Cycle => 4, + ChipSelectHighTime::_6Cycle => 5, + ChipSelectHighTime::_7Cycle => 6, + ChipSelectHighTime::_8Cycle => 7, } } } +/// FIFO threshold. +#[allow(missing_docs)] #[derive(Copy, Clone)] pub enum FIFOThresholdLevel { _1Bytes, @@ -234,6 +253,8 @@ impl Into for FIFOThresholdLevel { } } +/// Dummy cycle count +#[allow(missing_docs)] #[derive(Copy, Clone)] pub enum DummyCycles { _0, diff --git a/embassy-stm32/src/qspi/mod.rs b/embassy-stm32/src/qspi/mod.rs index 1153455c..bac91f30 100644 --- a/embassy-stm32/src/qspi/mod.rs +++ b/embassy-stm32/src/qspi/mod.rs @@ -54,7 +54,7 @@ pub struct Config { /// Number of bytes to trigger FIFO threshold flag. pub fifo_threshold: FIFOThresholdLevel, /// Minimum number of cycles that chip select must be high between issued commands - pub cs_high_time: ChipSelectHightTime, + pub cs_high_time: ChipSelectHighTime, } impl Default for Config { @@ -64,7 +64,7 @@ impl Default for Config { address_size: AddressSize::_24bit, prescaler: 128, fifo_threshold: FIFOThresholdLevel::_17Bytes, - cs_high_time: ChipSelectHightTime::_5Cycle, + cs_high_time: ChipSelectHighTime::_5Cycle, } } } diff --git a/embassy-stm32/src/sai/mod.rs b/embassy-stm32/src/sai/mod.rs index a16d38af..3d7f6599 100644 --- a/embassy-stm32/src/sai/mod.rs +++ b/embassy-stm32/src/sai/mod.rs @@ -583,10 +583,10 @@ fn get_ring_buffer<'d, T: Instance, C: Channel, W: word::Word>( }; match tx_rx { TxRx::Transmitter => RingBuffer::Writable(unsafe { - WritableRingBuffer::new_write(dma, request, dr(T::REGS, sub_block), dma_buf, opts) + WritableRingBuffer::new(dma, request, dr(T::REGS, sub_block), dma_buf, opts) }), TxRx::Receiver => RingBuffer::Readable(unsafe { - ReadableRingBuffer::new_read(dma, request, dr(T::REGS, sub_block), dma_buf, opts) + ReadableRingBuffer::new(dma, request, dr(T::REGS, sub_block), dma_buf, opts) }), } } diff --git a/embassy-stm32/src/traits.rs b/embassy-stm32/src/traits.rs index ffce7bd4..b4166e71 100644 --- a/embassy-stm32/src/traits.rs +++ b/embassy-stm32/src/traits.rs @@ -2,7 +2,9 @@ macro_rules! pin_trait { ($signal:ident, $instance:path) => { + #[doc = concat!(stringify!($signal), " pin trait")] pub trait $signal: crate::gpio::Pin { + #[doc = concat!("Get the AF number needed to use this pin as", stringify!($signal))] fn af_num(&self) -> u8; } }; @@ -22,7 +24,11 @@ macro_rules! pin_trait_impl { macro_rules! dma_trait { ($signal:ident, $instance:path) => { + #[doc = concat!(stringify!($signal), " DMA request trait")] pub trait $signal: crate::dma::Channel { + #[doc = concat!("Get the DMA request number needed to use this channel as", stringify!($signal))] + /// Note: in some chips, ST calls this the "channel", and calls channels "streams". + /// `embassy-stm32` always uses the "channel" and "request number" names. fn request(&self) -> crate::dma::Request; } }; diff --git a/embassy-stm32/src/usart/ringbuffered.rs b/embassy-stm32/src/usart/ringbuffered.rs index b8d17e4e..f8ada392 100644 --- a/embassy-stm32/src/usart/ringbuffered.rs +++ b/embassy-stm32/src/usart/ringbuffered.rs @@ -39,7 +39,7 @@ impl<'d, T: BasicInstance, RxDma: super::RxDma> UartRx<'d, T, RxDma> { let rx_dma = unsafe { self.rx_dma.clone_unchecked() }; let _peri = unsafe { self._peri.clone_unchecked() }; - let ring_buf = unsafe { ReadableRingBuffer::new_read(rx_dma, request, rdr(T::regs()), dma_buf, opts) }; + let ring_buf = unsafe { ReadableRingBuffer::new(rx_dma, request, rdr(T::regs()), dma_buf, opts) }; // Don't disable the clock mem::forget(self); diff --git a/examples/stm32f4/src/bin/flash.rs b/examples/stm32f4/src/bin/flash.rs index 93c54e94..56a35dde 100644 --- a/examples/stm32f4/src/bin/flash.rs +++ b/examples/stm32f4/src/bin/flash.rs @@ -31,7 +31,7 @@ fn test_flash(f: &mut Flash<'_, Blocking>, offset: u32, size: u32) { info!("Reading..."); let mut buf = [0u8; 32]; - unwrap!(f.read(offset, &mut buf)); + unwrap!(f.blocking_read(offset, &mut buf)); info!("Read: {=[u8]:x}", buf); info!("Erasing..."); @@ -39,7 +39,7 @@ fn test_flash(f: &mut Flash<'_, Blocking>, offset: u32, size: u32) { info!("Reading..."); let mut buf = [0u8; 32]; - unwrap!(f.read(offset, &mut buf)); + unwrap!(f.blocking_read(offset, &mut buf)); info!("Read after erase: {=[u8]:x}", buf); info!("Writing..."); @@ -53,7 +53,7 @@ fn test_flash(f: &mut Flash<'_, Blocking>, offset: u32, size: u32) { info!("Reading..."); let mut buf = [0u8; 32]; - unwrap!(f.read(offset, &mut buf)); + unwrap!(f.blocking_read(offset, &mut buf)); info!("Read: {=[u8]:x}", buf); assert_eq!( &buf[..], diff --git a/examples/stm32f4/src/bin/flash_async.rs b/examples/stm32f4/src/bin/flash_async.rs index f0a65a72..1624d842 100644 --- a/examples/stm32f4/src/bin/flash_async.rs +++ b/examples/stm32f4/src/bin/flash_async.rs @@ -48,7 +48,7 @@ async fn test_flash<'a>(f: &mut Flash<'a>, offset: u32, size: u32) { info!("Reading..."); let mut buf = [0u8; 32]; - unwrap!(f.read(offset, &mut buf)); + unwrap!(f.blocking_read(offset, &mut buf)); info!("Read: {=[u8]:x}", buf); info!("Erasing..."); @@ -56,7 +56,7 @@ async fn test_flash<'a>(f: &mut Flash<'a>, offset: u32, size: u32) { info!("Reading..."); let mut buf = [0u8; 32]; - unwrap!(f.read(offset, &mut buf)); + unwrap!(f.blocking_read(offset, &mut buf)); info!("Read after erase: {=[u8]:x}", buf); info!("Writing..."); @@ -73,7 +73,7 @@ async fn test_flash<'a>(f: &mut Flash<'a>, offset: u32, size: u32) { info!("Reading..."); let mut buf = [0u8; 32]; - unwrap!(f.read(offset, &mut buf)); + unwrap!(f.blocking_read(offset, &mut buf)); info!("Read: {=[u8]:x}", buf); assert_eq!( &buf[..],