diff options
| author | chasingRs <[email protected]> | 2025-10-10 10:26:46 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-10-10 10:26:46 +0800 |
| commit | 944fda48a94c2d6cb6bea56c8c8471858d75da7d (patch) | |
| tree | 1e3e2f463c2440afe81ca37b2e161f85d0bfc374 | |
| parent | 04171d903d3676d87aa0fd85719878d3087028f3 (diff) | |
| parent | 35b0ba4ce0fed7588febe504e16bbf1788384f5a (diff) | |
Merge branch 'embassy-rs:main' into fix/simple-pwm-32bit-timer-support
690 files changed, 2878 insertions, 2222 deletions
diff --git a/.github/ci/build-nightly.sh b/.github/ci/build-nightly.sh index 8cca1b445..82e9436f3 100755 --- a/.github/ci/build-nightly.sh +++ b/.github/ci/build-nightly.sh | |||
| @@ -23,7 +23,7 @@ fi | |||
| 23 | hashtime restore /ci/cache/filetime.json || true | 23 | hashtime restore /ci/cache/filetime.json || true |
| 24 | hashtime save /ci/cache/filetime.json | 24 | hashtime save /ci/cache/filetime.json |
| 25 | 25 | ||
| 26 | cargo install --git https://github.com/embassy-rs/cargo-embassy-devtool --locked --rev 676e6d602bf016dc71f1e98f2c7f191d7bd20707 | 26 | cargo install --git https://github.com/embassy-rs/cargo-embassy-devtool --locked --rev d015fd5e972a3e550ebef0da6748099b88a93ba6 |
| 27 | 27 | ||
| 28 | ./ci-nightly.sh | 28 | ./ci-nightly.sh |
| 29 | 29 | ||
diff --git a/.github/ci/build-xtensa.sh b/.github/ci/build-xtensa.sh index dbd2f7ffc..3f74b4a5a 100755 --- a/.github/ci/build-xtensa.sh +++ b/.github/ci/build-xtensa.sh | |||
| @@ -25,7 +25,7 @@ fi | |||
| 25 | hashtime restore /ci/cache/filetime.json || true | 25 | hashtime restore /ci/cache/filetime.json || true |
| 26 | hashtime save /ci/cache/filetime.json | 26 | hashtime save /ci/cache/filetime.json |
| 27 | 27 | ||
| 28 | cargo install --git https://github.com/embassy-rs/cargo-embassy-devtool --locked --rev 676e6d602bf016dc71f1e98f2c7f191d7bd20707 | 28 | cargo install --git https://github.com/embassy-rs/cargo-embassy-devtool --locked --rev d015fd5e972a3e550ebef0da6748099b88a93ba6 |
| 29 | 29 | ||
| 30 | ./ci-xtensa.sh | 30 | ./ci-xtensa.sh |
| 31 | 31 | ||
diff --git a/.github/ci/build.sh b/.github/ci/build.sh index d5e0e0bd2..3c196f72b 100755 --- a/.github/ci/build.sh +++ b/.github/ci/build.sh | |||
| @@ -28,7 +28,7 @@ fi | |||
| 28 | hashtime restore /ci/cache/filetime.json || true | 28 | hashtime restore /ci/cache/filetime.json || true |
| 29 | hashtime save /ci/cache/filetime.json | 29 | hashtime save /ci/cache/filetime.json |
| 30 | 30 | ||
| 31 | cargo install --git https://github.com/embassy-rs/cargo-embassy-devtool --locked --rev 676e6d602bf016dc71f1e98f2c7f191d7bd20707 | 31 | cargo install --git https://github.com/embassy-rs/cargo-embassy-devtool --locked --rev d015fd5e972a3e550ebef0da6748099b88a93ba6 |
| 32 | 32 | ||
| 33 | ./ci.sh | 33 | ./ci.sh |
| 34 | 34 | ||
diff --git a/.github/ci/doc.sh b/.github/ci/doc.sh index dab47e86d..535fc5262 100755 --- a/.github/ci/doc.sh +++ b/.github/ci/doc.sh | |||
| @@ -12,7 +12,7 @@ export CARGO_TARGET_DIR=/ci/cache/target | |||
| 12 | export PATH=$CARGO_HOME/bin:$PATH | 12 | export PATH=$CARGO_HOME/bin:$PATH |
| 13 | mv rust-toolchain-nightly.toml rust-toolchain.toml | 13 | mv rust-toolchain-nightly.toml rust-toolchain.toml |
| 14 | 14 | ||
| 15 | cargo install --git https://github.com/embassy-rs/cargo-embassy-devtool --locked --rev 676e6d602bf016dc71f1e98f2c7f191d7bd20707 | 15 | cargo install --git https://github.com/embassy-rs/cargo-embassy-devtool --locked --rev d015fd5e972a3e550ebef0da6748099b88a93ba6 |
| 16 | 16 | ||
| 17 | cargo embassy-devtool doc -o webroot | 17 | cargo embassy-devtool doc -o webroot |
| 18 | 18 | ||
diff --git a/.github/ci/janitor.sh b/.github/ci/janitor.sh index 305c6b227..bc43075bd 100755 --- a/.github/ci/janitor.sh +++ b/.github/ci/janitor.sh | |||
| @@ -9,7 +9,7 @@ export CARGO_HOME=/ci/cache/cargo | |||
| 9 | export CARGO_TARGET_DIR=/ci/cache/target | 9 | export CARGO_TARGET_DIR=/ci/cache/target |
| 10 | export PATH=$CARGO_HOME/bin:$PATH | 10 | export PATH=$CARGO_HOME/bin:$PATH |
| 11 | 11 | ||
| 12 | cargo install --git https://github.com/embassy-rs/cargo-embassy-devtool --locked --rev 676e6d602bf016dc71f1e98f2c7f191d7bd20707 | 12 | cargo install --git https://github.com/embassy-rs/cargo-embassy-devtool --locked --rev d015fd5e972a3e550ebef0da6748099b88a93ba6 |
| 13 | 13 | ||
| 14 | cargo embassy-devtool check-crlf | 14 | cargo embassy-devtool check-crlf |
| 15 | cargo embassy-devtool check-manifest | 15 | cargo embassy-devtool check-manifest |
diff --git a/.github/ci/rustfmt.sh b/.github/ci/rustfmt.sh index 369239cfe..7aaf93234 100755 --- a/.github/ci/rustfmt.sh +++ b/.github/ci/rustfmt.sh | |||
| @@ -9,4 +9,4 @@ export CARGO_HOME=/ci/cache/cargo | |||
| 9 | export CARGO_TARGET_DIR=/ci/cache/target | 9 | export CARGO_TARGET_DIR=/ci/cache/target |
| 10 | mv rust-toolchain-nightly.toml rust-toolchain.toml | 10 | mv rust-toolchain-nightly.toml rust-toolchain.toml |
| 11 | 11 | ||
| 12 | find . -name '*.rs' -not -path '*target*' | xargs rustfmt --check --skip-children --unstable-features --edition 2021 | 12 | find . -name '*.rs' -not -path '*target*' | xargs rustfmt --check --skip-children --unstable-features --edition 2024 |
diff --git a/cyw43-pio/Cargo.toml b/cyw43-pio/Cargo.toml index 6ab5c453e..a10a091e9 100644 --- a/cyw43-pio/Cargo.toml +++ b/cyw43-pio/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "cyw43-pio" | 2 | name = "cyw43-pio" |
| 3 | version = "0.8.0" | 3 | version = "0.8.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | description = "RP2040 PIO SPI implementation for cyw43" | 5 | description = "RP2040 PIO SPI implementation for cyw43" |
| 6 | keywords = ["embedded", "cyw43", "embassy-net", "embedded-hal-async", "wifi"] | 6 | keywords = ["embedded", "cyw43", "embassy-net", "embedded-hal-async", "wifi"] |
| 7 | categories = ["embedded", "hardware-support", "no-std", "network-programming", "asynchronous"] | 7 | categories = ["embedded", "hardware-support", "no-std", "network-programming", "asynchronous"] |
diff --git a/cyw43-pio/src/lib.rs b/cyw43-pio/src/lib.rs index b0be19358..41ac6816d 100644 --- a/cyw43-pio/src/lib.rs +++ b/cyw43-pio/src/lib.rs | |||
| @@ -6,13 +6,13 @@ | |||
| 6 | use core::slice; | 6 | use core::slice; |
| 7 | 7 | ||
| 8 | use cyw43::SpiBusCyw43; | 8 | use cyw43::SpiBusCyw43; |
| 9 | use embassy_rp::Peri; | ||
| 9 | use embassy_rp::dma::Channel; | 10 | use embassy_rp::dma::Channel; |
| 10 | use embassy_rp::gpio::{Drive, Level, Output, Pull, SlewRate}; | 11 | use embassy_rp::gpio::{Drive, Level, Output, Pull, SlewRate}; |
| 11 | use embassy_rp::pio::program::pio_asm; | 12 | use embassy_rp::pio::program::pio_asm; |
| 12 | use embassy_rp::pio::{Common, Config, Direction, Instance, Irq, PioPin, ShiftDirection, StateMachine}; | 13 | use embassy_rp::pio::{Common, Config, Direction, Instance, Irq, PioPin, ShiftDirection, StateMachine}; |
| 13 | use embassy_rp::Peri; | ||
| 14 | use fixed::types::extra::U8; | ||
| 15 | use fixed::FixedU32; | 14 | use fixed::FixedU32; |
| 15 | use fixed::types::extra::U8; | ||
| 16 | 16 | ||
| 17 | /// SPI comms driven by PIO. | 17 | /// SPI comms driven by PIO. |
| 18 | pub struct PioSpi<'d, PIO: Instance, const SM: usize, DMA: Channel> { | 18 | pub struct PioSpi<'d, PIO: Instance, const SM: usize, DMA: Channel> { |
diff --git a/cyw43/Cargo.toml b/cyw43/Cargo.toml index c59c15a71..314427611 100644 --- a/cyw43/Cargo.toml +++ b/cyw43/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "cyw43" | 2 | name = "cyw43" |
| 3 | version = "0.5.0" | 3 | version = "0.5.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | description = "Rust driver for the CYW43439 WiFi chip, used in the Raspberry Pi Pico W." | 5 | description = "Rust driver for the CYW43439 WiFi chip, used in the Raspberry Pi Pico W." |
| 6 | keywords = ["embedded", "cyw43", "embassy-net", "embedded-hal-async", "wifi"] | 6 | keywords = ["embedded", "cyw43", "embassy-net", "embedded-hal-async", "wifi"] |
| 7 | categories = ["embedded", "hardware-support", "no-std", "network-programming", "asynchronous"] | 7 | categories = ["embedded", "hardware-support", "no-std", "network-programming", "asynchronous"] |
diff --git a/cyw43/src/bluetooth.rs b/cyw43/src/bluetooth.rs index d176c4b09..332b7048d 100644 --- a/cyw43/src/bluetooth.rs +++ b/cyw43/src/bluetooth.rs | |||
| @@ -15,7 +15,7 @@ use crate::bus::Bus; | |||
| 15 | pub use crate::bus::SpiBusCyw43; | 15 | pub use crate::bus::SpiBusCyw43; |
| 16 | use crate::consts::*; | 16 | use crate::consts::*; |
| 17 | use crate::util::round_up; | 17 | use crate::util::round_up; |
| 18 | use crate::{util, CHIP}; | 18 | use crate::{CHIP, util}; |
| 19 | 19 | ||
| 20 | pub(crate) struct BtState { | 20 | pub(crate) struct BtState { |
| 21 | rx: [BtPacketBuf; 4], | 21 | rx: [BtPacketBuf; 4], |
diff --git a/cyw43/src/bus.rs b/cyw43/src/bus.rs index 8a53484d5..aa2b66a40 100644 --- a/cyw43/src/bus.rs +++ b/cyw43/src/bus.rs | |||
| @@ -340,11 +340,7 @@ where | |||
| 340 | self.status = self.spi.cmd_read(cmd, &mut buf[..len]).await; | 340 | self.status = self.spi.cmd_read(cmd, &mut buf[..len]).await; |
| 341 | 341 | ||
| 342 | // if we read from the backplane, the result is in the second word, after the response delay | 342 | // if we read from the backplane, the result is in the second word, after the response delay |
| 343 | if func == FUNC_BACKPLANE { | 343 | if func == FUNC_BACKPLANE { buf[1] } else { buf[0] } |
| 344 | buf[1] | ||
| 345 | } else { | ||
| 346 | buf[0] | ||
| 347 | } | ||
| 348 | } | 344 | } |
| 349 | 345 | ||
| 350 | async fn writen(&mut self, func: u32, addr: u32, val: u32, len: u32) { | 346 | async fn writen(&mut self, func: u32, addr: u32, val: u32, len: u32) { |
diff --git a/cyw43/src/control.rs b/cyw43/src/control.rs index fd0d4d532..49e3faee4 100644 --- a/cyw43/src/control.rs +++ b/cyw43/src/control.rs | |||
| @@ -10,7 +10,7 @@ use crate::events::{Event, EventSubscriber, Events}; | |||
| 10 | use crate::fmt::Bytes; | 10 | use crate::fmt::Bytes; |
| 11 | use crate::ioctl::{IoctlState, IoctlType}; | 11 | use crate::ioctl::{IoctlState, IoctlType}; |
| 12 | use crate::structs::*; | 12 | use crate::structs::*; |
| 13 | use crate::{countries, events, PowerManagementMode}; | 13 | use crate::{PowerManagementMode, countries, events}; |
| 14 | 14 | ||
| 15 | /// Control errors. | 15 | /// Control errors. |
| 16 | #[derive(Debug)] | 16 | #[derive(Debug)] |
diff --git a/cyw43/src/ioctl.rs b/cyw43/src/ioctl.rs index 35135e296..deccc945d 100644 --- a/cyw43/src/ioctl.rs +++ b/cyw43/src/ioctl.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | use core::cell::{Cell, RefCell}; | 1 | use core::cell::{Cell, RefCell}; |
| 2 | use core::future::{poll_fn, Future}; | 2 | use core::future::{Future, poll_fn}; |
| 3 | use core::task::{Poll, Waker}; | 3 | use core::task::{Poll, Waker}; |
| 4 | 4 | ||
| 5 | use embassy_sync::waitqueue::WakerRegistration; | 5 | use embassy_sync::waitqueue::WakerRegistration; |
diff --git a/cyw43/src/lib.rs b/cyw43/src/lib.rs index 16b436e66..82c636346 100644 --- a/cyw43/src/lib.rs +++ b/cyw43/src/lib.rs | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![allow(async_fn_in_trait)] | 3 | #![allow(async_fn_in_trait)] |
| 4 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 4 | #![deny(unused_must_use)] | 5 | #![deny(unused_must_use)] |
| 5 | #![doc = include_str!("../README.md")] | 6 | #![doc = include_str!("../README.md")] |
| 6 | #![warn(missing_docs)] | 7 | #![warn(missing_docs)] |
diff --git a/cyw43/src/runner.rs b/cyw43/src/runner.rs index 77910b281..7c38be24a 100644 --- a/cyw43/src/runner.rs +++ b/cyw43/src/runner.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | use embassy_futures::select::{select4, Either4}; | 1 | use embassy_futures::select::{Either4, select4}; |
| 2 | use embassy_net_driver_channel as ch; | 2 | use embassy_net_driver_channel as ch; |
| 3 | use embassy_time::{block_for, Duration, Timer}; | 3 | use embassy_time::{Duration, Timer, block_for}; |
| 4 | use embedded_hal_1::digital::OutputPin; | 4 | use embedded_hal_1::digital::OutputPin; |
| 5 | 5 | ||
| 6 | use crate::bus::Bus; | 6 | use crate::bus::Bus; |
| @@ -12,7 +12,7 @@ use crate::ioctl::{IoctlState, IoctlType, PendingIoctl}; | |||
| 12 | use crate::nvram::NVRAM; | 12 | use crate::nvram::NVRAM; |
| 13 | use crate::structs::*; | 13 | use crate::structs::*; |
| 14 | use crate::util::slice8_mut; | 14 | use crate::util::slice8_mut; |
| 15 | use crate::{events, Core, CHIP, MTU}; | 15 | use crate::{CHIP, Core, MTU, events}; |
| 16 | 16 | ||
| 17 | #[cfg(feature = "firmware-logs")] | 17 | #[cfg(feature = "firmware-logs")] |
| 18 | struct LogState { | 18 | struct LogState { |
diff --git a/docs/examples/basic/Cargo.toml b/docs/examples/basic/Cargo.toml index b6dbeda2a..b90180853 100644 --- a/docs/examples/basic/Cargo.toml +++ b/docs/examples/basic/Cargo.toml | |||
| @@ -9,7 +9,7 @@ publish = false | |||
| 9 | [dependencies] | 9 | [dependencies] |
| 10 | embassy-executor = { version = "0.9.0", path = "../../../embassy-executor", features = ["defmt", "arch-cortex-m", "executor-thread"] } | 10 | embassy-executor = { version = "0.9.0", path = "../../../embassy-executor", features = ["defmt", "arch-cortex-m", "executor-thread"] } |
| 11 | embassy-time = { version = "0.5.0", path = "../../../embassy-time", features = ["defmt"] } | 11 | embassy-time = { version = "0.5.0", path = "../../../embassy-time", features = ["defmt"] } |
| 12 | embassy-nrf = { version = "0.7.0", path = "../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote"] } | 12 | embassy-nrf = { version = "0.8.0", path = "../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote"] } |
| 13 | 13 | ||
| 14 | defmt = "1.0.1" | 14 | defmt = "1.0.1" |
| 15 | defmt-rtt = "1.0.0" | 15 | defmt-rtt = "1.0.0" |
diff --git a/docs/examples/layer-by-layer/blinky-async/Cargo.toml b/docs/examples/layer-by-layer/blinky-async/Cargo.toml index ec718022c..797ae3097 100644 --- a/docs/examples/layer-by-layer/blinky-async/Cargo.toml +++ b/docs/examples/layer-by-layer/blinky-async/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "blinky-async" | 2 | name = "blinky-async" |
| 3 | version = "0.1.0" | 3 | version = "0.1.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | publish = false | 7 | publish = false |
diff --git a/docs/examples/layer-by-layer/blinky-hal/Cargo.toml b/docs/examples/layer-by-layer/blinky-hal/Cargo.toml index 4a0b03a83..802b8b32e 100644 --- a/docs/examples/layer-by-layer/blinky-hal/Cargo.toml +++ b/docs/examples/layer-by-layer/blinky-hal/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "blinky-hal" | 2 | name = "blinky-hal" |
| 3 | version = "0.1.0" | 3 | version = "0.1.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | publish = false | 7 | publish = false |
diff --git a/docs/examples/layer-by-layer/blinky-irq/Cargo.toml b/docs/examples/layer-by-layer/blinky-irq/Cargo.toml index 3c4bf8446..d1b893a1e 100644 --- a/docs/examples/layer-by-layer/blinky-irq/Cargo.toml +++ b/docs/examples/layer-by-layer/blinky-irq/Cargo.toml | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | [package] | 3 | [package] |
| 4 | name = "blinky-irq" | 4 | name = "blinky-irq" |
| 5 | version = "0.1.0" | 5 | version = "0.1.0" |
| 6 | edition = "2021" | 6 | edition = "2024" |
| 7 | license = "MIT OR Apache-2.0" | 7 | license = "MIT OR Apache-2.0" |
| 8 | 8 | ||
| 9 | publish = false | 9 | publish = false |
diff --git a/docs/examples/layer-by-layer/blinky-pac/Cargo.toml b/docs/examples/layer-by-layer/blinky-pac/Cargo.toml index 0d4711da2..fa093a3af 100644 --- a/docs/examples/layer-by-layer/blinky-pac/Cargo.toml +++ b/docs/examples/layer-by-layer/blinky-pac/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "blinky-pac" | 2 | name = "blinky-pac" |
| 3 | version = "0.1.0" | 3 | version = "0.1.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | publish = false | 7 | publish = false |
diff --git a/docs/pages/embassy_in_the_wild.adoc b/docs/pages/embassy_in_the_wild.adoc index cedbedada..3b58bb9b4 100644 --- a/docs/pages/embassy_in_the_wild.adoc +++ b/docs/pages/embassy_in_the_wild.adoc | |||
| @@ -4,6 +4,8 @@ Here are known examples of real-world projects which make use of Embassy. Feel f | |||
| 4 | 4 | ||
| 5 | _newer entries at the top_ | 5 | _newer entries at the top_ |
| 6 | 6 | ||
| 7 | * link:https://github.com/1-rafael-1/air-quality-monitor[Air Quality Monitor] | ||
| 8 | ** Air Quality Monitor based on rp2350 board, ens160 and aht21 sensors and ssd1306 display. Code and 3D printable enclosure included. | ||
| 7 | * link:https://github.com/CarlKCarlK/clock[Embassy Clock: Layered, modular bare-metal clock with emulation] | 9 | * link:https://github.com/CarlKCarlK/clock[Embassy Clock: Layered, modular bare-metal clock with emulation] |
| 8 | ** A `no_std` Raspberry Pi Pico clock demonstrating layered Embassy tasks (Display->Blinker->Clock) for clean separation of multiplexing, blinking, and UI logic. Features single-button HH:MM/MM:SS time-set UI, heapless data structures, and a Renode emulator for hardware-free testing. See link:https://medium.com/@carlmkadie/how-rust-embassy-shine-on-embedded-devices-part-2-aad1adfccf72[this article] for details. | 10 | ** A `no_std` Raspberry Pi Pico clock demonstrating layered Embassy tasks (Display->Blinker->Clock) for clean separation of multiplexing, blinking, and UI logic. Features single-button HH:MM/MM:SS time-set UI, heapless data structures, and a Renode emulator for hardware-free testing. See link:https://medium.com/@carlmkadie/how-rust-embassy-shine-on-embedded-devices-part-2-aad1adfccf72[this article] for details. |
| 9 | * link:https://github.com/1-rafael-1/simple-robot[A simple tracked robot based on Raspberry Pi Pico 2] | 11 | * link:https://github.com/1-rafael-1/simple-robot[A simple tracked robot based on Raspberry Pi Pico 2] |
| @@ -11,7 +13,7 @@ _newer entries at the top_ | |||
| 11 | * link:https://github.com/1-rafael-1/pi-pico-alarmclock-rust[A Raspberry Pi Pico W Alarmclock] | 13 | * link:https://github.com/1-rafael-1/pi-pico-alarmclock-rust[A Raspberry Pi Pico W Alarmclock] |
| 12 | ** A hobbyist project building an alarm clock around a Pi Pico W complete with code, components list and enclosure design files. | 14 | ** A hobbyist project building an alarm clock around a Pi Pico W complete with code, components list and enclosure design files. |
| 13 | * link:https://github.com/haobogu/rmk/[RMK: A feature-rich Rust keyboard firmware] | 15 | * link:https://github.com/haobogu/rmk/[RMK: A feature-rich Rust keyboard firmware] |
| 14 | ** RMK has built-in layer support, wireless(BLE) support, real-time key editing support using vial, and more! | 16 | ** RMK has built-in layer support, wireless(BLE) support, real-time key editing support using vial, and more! |
| 15 | ** Targets STM32, RP2040, nRF52 and ESP32 MCUs | 17 | ** Targets STM32, RP2040, nRF52 and ESP32 MCUs |
| 16 | * link:https://github.com/cbruiz/printhor/[Printhor: The highly reliable but not necessarily functional 3D printer firmware] | 18 | * link:https://github.com/cbruiz/printhor/[Printhor: The highly reliable but not necessarily functional 3D printer firmware] |
| 17 | ** Targets some STM32 MCUs | 19 | ** Targets some STM32 MCUs |
| @@ -21,10 +23,9 @@ _newer entries at the top_ | |||
| 21 | * link:https://github.com/matoushybl/air-force-one[Air force one: A simple air quality monitoring system] | 23 | * link:https://github.com/matoushybl/air-force-one[Air force one: A simple air quality monitoring system] |
| 22 | ** Targets nRF52 and uses nrf-softdevice | 24 | ** Targets nRF52 and uses nrf-softdevice |
| 23 | 25 | ||
| 24 | * link:https://github.com/schmettow/ylab-edge-go[YLab Edge Go] and link:https://github.com/schmettow/ylab-edge-pro[YLab Edge Pro] projects develop | 26 | * link:https://github.com/schmettow/ylab-edge-go[YLab Edge Go] and link:https://github.com/schmettow/ylab-edge-pro[YLab Edge Pro] projects develop |
| 25 | firmware (RP2040, STM32) for capturing physiological data in behavioural science research. Included so far are: | 27 | firmware (RP2040, STM32) for capturing physiological data in behavioural science research. Included so far are: |
| 26 | ** biopotentials (analog ports) | 28 | ** biopotentials (analog ports) |
| 27 | ** motion capture (6-axis accelerometers) | 29 | ** motion capture (6-axis accelerometers) |
| 28 | ** air quality (CO2, Temp, Humidity) | 30 | ** air quality (CO2, Temp, Humidity) |
| 29 | ** comes with an app for capturing and visualizing data [link:https://github.com/schmettow/ystudio-zero[Ystudio]] | 31 | ** comes with an app for capturing and visualizing data [link:https://github.com/schmettow/ystudio-zero[Ystudio]] |
| 30 | |||
diff --git a/embassy-boot-nrf/CHANGELOG.md b/embassy-boot-nrf/CHANGELOG.md index 8cc1e73c0..54b7c8067 100644 --- a/embassy-boot-nrf/CHANGELOG.md +++ b/embassy-boot-nrf/CHANGELOG.md | |||
| @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
| 8 | <!-- next-header --> | 8 | <!-- next-header --> |
| 9 | ## Unreleased - ReleaseDate | 9 | ## Unreleased - ReleaseDate |
| 10 | 10 | ||
| 11 | ## 0.9.0 - 2025-09-30 | ||
| 12 | |||
| 13 | - Bumped embassy-nrf to 0.8.0 | ||
| 14 | |||
| 11 | ## 0.8.0 - 2025-08-26 | 15 | ## 0.8.0 - 2025-08-26 |
| 12 | 16 | ||
| 13 | ## 0.1.1 - 2025-08-15 | 17 | ## 0.1.1 - 2025-08-15 |
diff --git a/embassy-boot-nrf/Cargo.toml b/embassy-boot-nrf/Cargo.toml index 49dff061a..787a28d70 100644 --- a/embassy-boot-nrf/Cargo.toml +++ b/embassy-boot-nrf/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-boot-nrf" | 3 | name = "embassy-boot-nrf" |
| 4 | version = "0.8.0" | 4 | version = "0.9.0" |
| 5 | description = "Bootloader lib for nRF chips" | 5 | description = "Bootloader lib for nRF chips" |
| 6 | license = "MIT OR Apache-2.0" | 6 | license = "MIT OR Apache-2.0" |
| 7 | repository = "https://github.com/embassy-rs/embassy" | 7 | repository = "https://github.com/embassy-rs/embassy" |
| @@ -36,7 +36,7 @@ defmt = { version = "1.0.1", optional = true } | |||
| 36 | log = { version = "0.4.17", optional = true } | 36 | log = { version = "0.4.17", optional = true } |
| 37 | 37 | ||
| 38 | embassy-sync = { version = "0.7.2", path = "../embassy-sync" } | 38 | embassy-sync = { version = "0.7.2", path = "../embassy-sync" } |
| 39 | embassy-nrf = { version = "0.7.0", path = "../embassy-nrf", default-features = false } | 39 | embassy-nrf = { version = "0.8.0", path = "../embassy-nrf", default-features = false } |
| 40 | embassy-boot = { version = "0.6.1", path = "../embassy-boot" } | 40 | embassy-boot = { version = "0.6.1", path = "../embassy-boot" } |
| 41 | cortex-m = { version = "0.7.6" } | 41 | cortex-m = { version = "0.7.6" } |
| 42 | cortex-m-rt = { version = "0.7" } | 42 | cortex-m-rt = { version = "0.7" } |
diff --git a/embassy-boot-nrf/src/lib.rs b/embassy-boot-nrf/src/lib.rs index f1c9da080..b4c3c1151 100644 --- a/embassy-boot-nrf/src/lib.rs +++ b/embassy-boot-nrf/src/lib.rs | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 2 | #![warn(missing_docs)] | 3 | #![warn(missing_docs)] |
| 3 | #![doc = include_str!("../README.md")] | 4 | #![doc = include_str!("../README.md")] |
| 4 | mod fmt; | 5 | mod fmt; |
| @@ -8,7 +9,7 @@ pub use embassy_boot::{ | |||
| 8 | FirmwareUpdater, FirmwareUpdaterConfig, | 9 | FirmwareUpdater, FirmwareUpdaterConfig, |
| 9 | }; | 10 | }; |
| 10 | use embassy_nrf::nvmc::PAGE_SIZE; | 11 | use embassy_nrf::nvmc::PAGE_SIZE; |
| 11 | use embassy_nrf::{wdt, Peri}; | 12 | use embassy_nrf::{Peri, wdt}; |
| 12 | use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash}; | 13 | use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash}; |
| 13 | 14 | ||
| 14 | /// A bootloader for nRF devices. | 15 | /// A bootloader for nRF devices. |
diff --git a/embassy-boot-rp/Cargo.toml b/embassy-boot-rp/Cargo.toml index 894b77595..e80c79374 100644 --- a/embassy-boot-rp/Cargo.toml +++ b/embassy-boot-rp/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-boot-rp" | 3 | name = "embassy-boot-rp" |
| 4 | version = "0.8.0" | 4 | version = "0.8.0" |
| 5 | description = "Bootloader lib for RP2040 chips" | 5 | description = "Bootloader lib for RP2040 chips" |
diff --git a/embassy-boot-rp/src/lib.rs b/embassy-boot-rp/src/lib.rs index f704380ef..d090aee49 100644 --- a/embassy-boot-rp/src/lib.rs +++ b/embassy-boot-rp/src/lib.rs | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 2 | #![warn(missing_docs)] | 3 | #![warn(missing_docs)] |
| 3 | #![doc = include_str!("../README.md")] | 4 | #![doc = include_str!("../README.md")] |
| 4 | mod fmt; | 5 | mod fmt; |
| @@ -7,10 +8,10 @@ pub use embassy_boot::{ | |||
| 7 | AlignedBuffer, BlockingFirmwareState, BlockingFirmwareUpdater, BootError, BootLoaderConfig, FirmwareState, | 8 | AlignedBuffer, BlockingFirmwareState, BlockingFirmwareUpdater, BootError, BootLoaderConfig, FirmwareState, |
| 8 | FirmwareUpdater, FirmwareUpdaterConfig, State, | 9 | FirmwareUpdater, FirmwareUpdaterConfig, State, |
| 9 | }; | 10 | }; |
| 10 | use embassy_rp::flash::{Blocking, Flash, ERASE_SIZE}; | 11 | use embassy_rp::Peri; |
| 12 | use embassy_rp::flash::{Blocking, ERASE_SIZE, Flash}; | ||
| 11 | use embassy_rp::peripherals::{FLASH, WATCHDOG}; | 13 | use embassy_rp::peripherals::{FLASH, WATCHDOG}; |
| 12 | use embassy_rp::watchdog::Watchdog; | 14 | use embassy_rp::watchdog::Watchdog; |
| 13 | use embassy_rp::Peri; | ||
| 14 | use embassy_time::Duration; | 15 | use embassy_time::Duration; |
| 15 | use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash}; | 16 | use embedded_storage::nor_flash::{ErrorType, NorFlash, ReadNorFlash}; |
| 16 | 17 | ||
diff --git a/embassy-boot-stm32/Cargo.toml b/embassy-boot-stm32/Cargo.toml index 24eafcdbf..c8c7f4409 100644 --- a/embassy-boot-stm32/Cargo.toml +++ b/embassy-boot-stm32/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-boot-stm32" | 3 | name = "embassy-boot-stm32" |
| 4 | version = "0.6.0" | 4 | version = "0.6.0" |
| 5 | description = "Bootloader lib for STM32 chips" | 5 | description = "Bootloader lib for STM32 chips" |
diff --git a/embassy-boot-stm32/src/lib.rs b/embassy-boot-stm32/src/lib.rs index 387cc0ce5..ee6ae41b7 100644 --- a/embassy-boot-stm32/src/lib.rs +++ b/embassy-boot-stm32/src/lib.rs | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 2 | #![warn(missing_docs)] | 3 | #![warn(missing_docs)] |
| 3 | #![doc = include_str!("../README.md")] | 4 | #![doc = include_str!("../README.md")] |
| 4 | mod fmt; | 5 | mod fmt; |
diff --git a/embassy-boot/Cargo.toml b/embassy-boot/Cargo.toml index a18438c81..8c5c1f633 100644 --- a/embassy-boot/Cargo.toml +++ b/embassy-boot/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-boot" | 3 | name = "embassy-boot" |
| 4 | version = "0.6.1" | 4 | version = "0.6.1" |
| 5 | description = "A lightweight bootloader supporting firmware updates in a power-fail-safe way, with trial boots and rollbacks." | 5 | description = "A lightweight bootloader supporting firmware updates in a power-fail-safe way, with trial boots and rollbacks." |
diff --git a/embassy-boot/src/boot_loader.rs b/embassy-boot/src/boot_loader.rs index 5bffdc5ea..c38940d6e 100644 --- a/embassy-boot/src/boot_loader.rs +++ b/embassy-boot/src/boot_loader.rs | |||
| @@ -1,11 +1,11 @@ | |||
| 1 | use core::cell::RefCell; | 1 | use core::cell::RefCell; |
| 2 | 2 | ||
| 3 | use embassy_embedded_hal::flash::partition::BlockingPartition; | 3 | use embassy_embedded_hal::flash::partition::BlockingPartition; |
| 4 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | ||
| 5 | use embassy_sync::blocking_mutex::Mutex; | 4 | use embassy_sync::blocking_mutex::Mutex; |
| 5 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | ||
| 6 | use embedded_storage::nor_flash::{NorFlash, NorFlashError, NorFlashErrorKind}; | 6 | use embedded_storage::nor_flash::{NorFlash, NorFlashError, NorFlashErrorKind}; |
| 7 | 7 | ||
| 8 | use crate::{State, DFU_DETACH_MAGIC, REVERT_MAGIC, STATE_ERASE_VALUE, SWAP_MAGIC}; | 8 | use crate::{DFU_DETACH_MAGIC, REVERT_MAGIC, STATE_ERASE_VALUE, SWAP_MAGIC, State}; |
| 9 | 9 | ||
| 10 | /// Errors returned by bootloader | 10 | /// Errors returned by bootloader |
| 11 | #[derive(PartialEq, Eq, Debug)] | 11 | #[derive(PartialEq, Eq, Debug)] |
| @@ -94,7 +94,7 @@ impl<'a, ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash> | |||
| 94 | dfu_flash: &'a Mutex<NoopRawMutex, RefCell<DFU>>, | 94 | dfu_flash: &'a Mutex<NoopRawMutex, RefCell<DFU>>, |
| 95 | state_flash: &'a Mutex<NoopRawMutex, RefCell<STATE>>, | 95 | state_flash: &'a Mutex<NoopRawMutex, RefCell<STATE>>, |
| 96 | ) -> Self { | 96 | ) -> Self { |
| 97 | extern "C" { | 97 | unsafe extern "C" { |
| 98 | static __bootloader_state_start: u32; | 98 | static __bootloader_state_start: u32; |
| 99 | static __bootloader_state_end: u32; | 99 | static __bootloader_state_end: u32; |
| 100 | static __bootloader_active_start: u32; | 100 | static __bootloader_active_start: u32; |
diff --git a/embassy-boot/src/firmware_updater/asynch.rs b/embassy-boot/src/firmware_updater/asynch.rs index 66e311e38..26d4d39bd 100644 --- a/embassy-boot/src/firmware_updater/asynch.rs +++ b/embassy-boot/src/firmware_updater/asynch.rs | |||
| @@ -6,7 +6,7 @@ use embassy_sync::blocking_mutex::raw::NoopRawMutex; | |||
| 6 | use embedded_storage_async::nor_flash::NorFlash; | 6 | use embedded_storage_async::nor_flash::NorFlash; |
| 7 | 7 | ||
| 8 | use super::FirmwareUpdaterConfig; | 8 | use super::FirmwareUpdaterConfig; |
| 9 | use crate::{FirmwareUpdaterError, State, BOOT_MAGIC, DFU_DETACH_MAGIC, STATE_ERASE_VALUE, SWAP_MAGIC}; | 9 | use crate::{BOOT_MAGIC, DFU_DETACH_MAGIC, FirmwareUpdaterError, STATE_ERASE_VALUE, SWAP_MAGIC, State}; |
| 10 | 10 | ||
| 11 | /// FirmwareUpdater is an application API for interacting with the BootLoader without the ability to | 11 | /// FirmwareUpdater is an application API for interacting with the BootLoader without the ability to |
| 12 | /// 'mess up' the internal bootloader state | 12 | /// 'mess up' the internal bootloader state |
| @@ -25,7 +25,7 @@ impl<'a, DFU: NorFlash, STATE: NorFlash> | |||
| 25 | dfu_flash: &'a embassy_sync::mutex::Mutex<NoopRawMutex, DFU>, | 25 | dfu_flash: &'a embassy_sync::mutex::Mutex<NoopRawMutex, DFU>, |
| 26 | state_flash: &'a embassy_sync::mutex::Mutex<NoopRawMutex, STATE>, | 26 | state_flash: &'a embassy_sync::mutex::Mutex<NoopRawMutex, STATE>, |
| 27 | ) -> Self { | 27 | ) -> Self { |
| 28 | extern "C" { | 28 | unsafe extern "C" { |
| 29 | static __bootloader_state_start: u32; | 29 | static __bootloader_state_start: u32; |
| 30 | static __bootloader_state_end: u32; | 30 | static __bootloader_state_end: u32; |
| 31 | static __bootloader_dfu_start: u32; | 31 | static __bootloader_dfu_start: u32; |
diff --git a/embassy-boot/src/firmware_updater/blocking.rs b/embassy-boot/src/firmware_updater/blocking.rs index 0fedac1ea..5554025fc 100644 --- a/embassy-boot/src/firmware_updater/blocking.rs +++ b/embassy-boot/src/firmware_updater/blocking.rs | |||
| @@ -6,7 +6,7 @@ use embassy_sync::blocking_mutex::raw::NoopRawMutex; | |||
| 6 | use embedded_storage::nor_flash::NorFlash; | 6 | use embedded_storage::nor_flash::NorFlash; |
| 7 | 7 | ||
| 8 | use super::FirmwareUpdaterConfig; | 8 | use super::FirmwareUpdaterConfig; |
| 9 | use crate::{FirmwareUpdaterError, State, BOOT_MAGIC, DFU_DETACH_MAGIC, STATE_ERASE_VALUE, SWAP_MAGIC}; | 9 | use crate::{BOOT_MAGIC, DFU_DETACH_MAGIC, FirmwareUpdaterError, STATE_ERASE_VALUE, SWAP_MAGIC, State}; |
| 10 | 10 | ||
| 11 | /// Blocking FirmwareUpdater is an application API for interacting with the BootLoader without the ability to | 11 | /// Blocking FirmwareUpdater is an application API for interacting with the BootLoader without the ability to |
| 12 | /// 'mess up' the internal bootloader state | 12 | /// 'mess up' the internal bootloader state |
| @@ -55,7 +55,7 @@ impl<'a, DFU: NorFlash, STATE: NorFlash> | |||
| 55 | dfu_flash: &'a embassy_sync::blocking_mutex::Mutex<NoopRawMutex, core::cell::RefCell<DFU>>, | 55 | dfu_flash: &'a embassy_sync::blocking_mutex::Mutex<NoopRawMutex, core::cell::RefCell<DFU>>, |
| 56 | state_flash: &'a embassy_sync::blocking_mutex::Mutex<NoopRawMutex, core::cell::RefCell<STATE>>, | 56 | state_flash: &'a embassy_sync::blocking_mutex::Mutex<NoopRawMutex, core::cell::RefCell<STATE>>, |
| 57 | ) -> Self { | 57 | ) -> Self { |
| 58 | extern "C" { | 58 | unsafe extern "C" { |
| 59 | static __bootloader_state_start: u32; | 59 | static __bootloader_state_start: u32; |
| 60 | static __bootloader_state_end: u32; | 60 | static __bootloader_state_end: u32; |
| 61 | static __bootloader_dfu_start: u32; | 61 | static __bootloader_dfu_start: u32; |
| @@ -399,8 +399,8 @@ mod tests { | |||
| 399 | use core::cell::RefCell; | 399 | use core::cell::RefCell; |
| 400 | 400 | ||
| 401 | use embassy_embedded_hal::flash::partition::BlockingPartition; | 401 | use embassy_embedded_hal::flash::partition::BlockingPartition; |
| 402 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | ||
| 403 | use embassy_sync::blocking_mutex::Mutex; | 402 | use embassy_sync::blocking_mutex::Mutex; |
| 403 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | ||
| 404 | use sha1::{Digest, Sha1}; | 404 | use sha1::{Digest, Sha1}; |
| 405 | 405 | ||
| 406 | use super::*; | 406 | use super::*; |
diff --git a/embassy-boot/src/lib.rs b/embassy-boot/src/lib.rs index e2c4cf771..7dc811f66 100644 --- a/embassy-boot/src/lib.rs +++ b/embassy-boot/src/lib.rs | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![allow(async_fn_in_trait)] | 2 | #![allow(async_fn_in_trait)] |
| 3 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 3 | #![warn(missing_docs)] | 4 | #![warn(missing_docs)] |
| 4 | #![doc = include_str!("../README.md")] | 5 | #![doc = include_str!("../README.md")] |
| 5 | mod fmt; | 6 | mod fmt; |
| @@ -341,11 +342,13 @@ mod tests { | |||
| 341 | &mut aligned, | 342 | &mut aligned, |
| 342 | ); | 343 | ); |
| 343 | 344 | ||
| 344 | assert!(block_on(updater.verify_and_mark_updated( | 345 | assert!( |
| 345 | &public_key.to_bytes(), | 346 | block_on(updater.verify_and_mark_updated( |
| 346 | &signature.to_bytes(), | 347 | &public_key.to_bytes(), |
| 347 | firmware_len as u32, | 348 | &signature.to_bytes(), |
| 348 | )) | 349 | firmware_len as u32, |
| 349 | .is_ok()); | 350 | )) |
| 351 | .is_ok() | ||
| 352 | ); | ||
| 350 | } | 353 | } |
| 351 | } | 354 | } |
diff --git a/embassy-boot/src/test_flash/blocking.rs b/embassy-boot/src/test_flash/blocking.rs index 5ec476c65..7334346fd 100644 --- a/embassy-boot/src/test_flash/blocking.rs +++ b/embassy-boot/src/test_flash/blocking.rs | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | use core::cell::RefCell; | 1 | use core::cell::RefCell; |
| 2 | 2 | ||
| 3 | use embassy_embedded_hal::flash::partition::BlockingPartition; | 3 | use embassy_embedded_hal::flash::partition::BlockingPartition; |
| 4 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | ||
| 5 | use embassy_sync::blocking_mutex::Mutex; | 4 | use embassy_sync::blocking_mutex::Mutex; |
| 5 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | ||
| 6 | use embedded_storage::nor_flash::NorFlash; | 6 | use embedded_storage::nor_flash::NorFlash; |
| 7 | 7 | ||
| 8 | use crate::BootLoaderConfig; | 8 | use crate::BootLoaderConfig; |
diff --git a/embassy-embedded-hal/Cargo.toml b/embassy-embedded-hal/Cargo.toml index 8b8122567..c9551257a 100644 --- a/embassy-embedded-hal/Cargo.toml +++ b/embassy-embedded-hal/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-embedded-hal" | 2 | name = "embassy-embedded-hal" |
| 3 | version = "0.5.0" | 3 | version = "0.5.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | description = "Collection of utilities to use `embedded-hal` and `embedded-storage` traits with Embassy." | 6 | description = "Collection of utilities to use `embedded-hal` and `embedded-storage` traits with Embassy." |
| 7 | repository = "https://github.com/embassy-rs/embassy" | 7 | repository = "https://github.com/embassy-rs/embassy" |
diff --git a/embassy-embedded-hal/src/flash/partition/blocking.rs b/embassy-embedded-hal/src/flash/partition/blocking.rs index cb30290a8..bd9329e2d 100644 --- a/embassy-embedded-hal/src/flash/partition/blocking.rs +++ b/embassy-embedded-hal/src/flash/partition/blocking.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | use core::cell::RefCell; | 1 | use core::cell::RefCell; |
| 2 | 2 | ||
| 3 | use embassy_sync::blocking_mutex::raw::RawMutex; | ||
| 4 | use embassy_sync::blocking_mutex::Mutex; | 3 | use embassy_sync::blocking_mutex::Mutex; |
| 4 | use embassy_sync::blocking_mutex::raw::RawMutex; | ||
| 5 | use embedded_storage::nor_flash::{ErrorType, MultiwriteNorFlash, NorFlash, ReadNorFlash}; | 5 | use embedded_storage::nor_flash::{ErrorType, MultiwriteNorFlash, NorFlash, ReadNorFlash}; |
| 6 | 6 | ||
| 7 | use super::Error; | 7 | use super::Error; |
diff --git a/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs b/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs index 48246270e..9c7d3ee71 100644 --- a/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs +++ b/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs | |||
| @@ -26,8 +26,8 @@ use embassy_sync::blocking_mutex::raw::RawMutex; | |||
| 26 | use embassy_sync::mutex::Mutex; | 26 | use embassy_sync::mutex::Mutex; |
| 27 | use embedded_hal_async::i2c; | 27 | use embedded_hal_async::i2c; |
| 28 | 28 | ||
| 29 | use crate::shared_bus::I2cDeviceError; | ||
| 30 | use crate::SetConfig; | 29 | use crate::SetConfig; |
| 30 | use crate::shared_bus::I2cDeviceError; | ||
| 31 | 31 | ||
| 32 | /// I2C device on a shared bus. | 32 | /// I2C device on a shared bus. |
| 33 | pub struct I2cDevice<'a, M: RawMutex, BUS> { | 33 | pub struct I2cDevice<'a, M: RawMutex, BUS> { |
diff --git a/embassy-embedded-hal/src/shared_bus/asynch/spi.rs b/embassy-embedded-hal/src/shared_bus/asynch/spi.rs index 0faefbc1e..869a78164 100644 --- a/embassy-embedded-hal/src/shared_bus/asynch/spi.rs +++ b/embassy-embedded-hal/src/shared_bus/asynch/spi.rs | |||
| @@ -32,8 +32,8 @@ use embedded_hal_1::digital::OutputPin; | |||
| 32 | use embedded_hal_1::spi::Operation; | 32 | use embedded_hal_1::spi::Operation; |
| 33 | use embedded_hal_async::spi; | 33 | use embedded_hal_async::spi; |
| 34 | 34 | ||
| 35 | use crate::shared_bus::SpiDeviceError; | ||
| 36 | use crate::SetConfig; | 35 | use crate::SetConfig; |
| 36 | use crate::shared_bus::SpiDeviceError; | ||
| 37 | 37 | ||
| 38 | /// SPI device on a shared bus. | 38 | /// SPI device on a shared bus. |
| 39 | pub struct SpiDevice<'a, M: RawMutex, BUS, CS> { | 39 | pub struct SpiDevice<'a, M: RawMutex, BUS, CS> { |
diff --git a/embassy-embedded-hal/src/shared_bus/blocking/i2c.rs b/embassy-embedded-hal/src/shared_bus/blocking/i2c.rs index dc634a209..49b50f8c1 100644 --- a/embassy-embedded-hal/src/shared_bus/blocking/i2c.rs +++ b/embassy-embedded-hal/src/shared_bus/blocking/i2c.rs | |||
| @@ -17,12 +17,12 @@ | |||
| 17 | 17 | ||
| 18 | use core::cell::RefCell; | 18 | use core::cell::RefCell; |
| 19 | 19 | ||
| 20 | use embassy_sync::blocking_mutex::raw::RawMutex; | ||
| 21 | use embassy_sync::blocking_mutex::Mutex; | 20 | use embassy_sync::blocking_mutex::Mutex; |
| 21 | use embassy_sync::blocking_mutex::raw::RawMutex; | ||
| 22 | use embedded_hal_1::i2c::{ErrorType, I2c, Operation}; | 22 | use embedded_hal_1::i2c::{ErrorType, I2c, Operation}; |
| 23 | 23 | ||
| 24 | use crate::shared_bus::I2cDeviceError; | ||
| 25 | use crate::SetConfig; | 24 | use crate::SetConfig; |
| 25 | use crate::shared_bus::I2cDeviceError; | ||
| 26 | 26 | ||
| 27 | /// I2C device on a shared bus. | 27 | /// I2C device on a shared bus. |
| 28 | pub struct I2cDevice<'a, M: RawMutex, BUS> { | 28 | pub struct I2cDevice<'a, M: RawMutex, BUS> { |
diff --git a/embassy-embedded-hal/src/shared_bus/blocking/spi.rs b/embassy-embedded-hal/src/shared_bus/blocking/spi.rs index ffe2aa1c6..48fe2f4c4 100644 --- a/embassy-embedded-hal/src/shared_bus/blocking/spi.rs +++ b/embassy-embedded-hal/src/shared_bus/blocking/spi.rs | |||
| @@ -19,13 +19,13 @@ | |||
| 19 | 19 | ||
| 20 | use core::cell::RefCell; | 20 | use core::cell::RefCell; |
| 21 | 21 | ||
| 22 | use embassy_sync::blocking_mutex::raw::RawMutex; | ||
| 23 | use embassy_sync::blocking_mutex::Mutex; | 22 | use embassy_sync::blocking_mutex::Mutex; |
| 23 | use embassy_sync::blocking_mutex::raw::RawMutex; | ||
| 24 | use embedded_hal_1::digital::OutputPin; | 24 | use embedded_hal_1::digital::OutputPin; |
| 25 | use embedded_hal_1::spi::{self, Operation, SpiBus}; | 25 | use embedded_hal_1::spi::{self, Operation, SpiBus}; |
| 26 | 26 | ||
| 27 | use crate::shared_bus::SpiDeviceError; | ||
| 28 | use crate::SetConfig; | 27 | use crate::SetConfig; |
| 28 | use crate::shared_bus::SpiDeviceError; | ||
| 29 | 29 | ||
| 30 | /// SPI device on a shared bus. | 30 | /// SPI device on a shared bus. |
| 31 | pub struct SpiDevice<'a, M: RawMutex, BUS, CS> { | 31 | pub struct SpiDevice<'a, M: RawMutex, BUS, CS> { |
diff --git a/embassy-executor-macros/Cargo.toml b/embassy-executor-macros/Cargo.toml index 9c2b40d03..3eeed5e4d 100644 --- a/embassy-executor-macros/Cargo.toml +++ b/embassy-executor-macros/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-executor-macros" | 2 | name = "embassy-executor-macros" |
| 3 | version = "0.7.0" | 3 | version = "0.7.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | description = "macros for creating the entry point and tasks for embassy-executor" | 6 | description = "macros for creating the entry point and tasks for embassy-executor" |
| 7 | repository = "https://github.com/embassy-rs/embassy" | 7 | repository = "https://github.com/embassy-rs/embassy" |
diff --git a/embassy-executor-macros/src/macros/main.rs b/embassy-executor-macros/src/macros/main.rs index dc470e51c..c259c003f 100644 --- a/embassy-executor-macros/src/macros/main.rs +++ b/embassy-executor-macros/src/macros/main.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | use std::str::FromStr; | 1 | use std::str::FromStr; |
| 2 | 2 | ||
| 3 | use darling::export::NestedMeta; | ||
| 4 | use darling::FromMeta; | 3 | use darling::FromMeta; |
| 4 | use darling::export::NestedMeta; | ||
| 5 | use proc_macro2::TokenStream; | 5 | use proc_macro2::TokenStream; |
| 6 | use quote::quote; | 6 | use quote::quote; |
| 7 | use syn::{ReturnType, Type}; | 7 | use syn::{ReturnType, Type}; |
| @@ -183,7 +183,7 @@ For example: `#[embassy_executor::main(entry = ..., executor = \"some_crate::Exe | |||
| 183 | quote!(!), | 183 | quote!(!), |
| 184 | quote! { | 184 | quote! { |
| 185 | unsafe fn __make_static<T>(t: &mut T) -> &'static mut T { | 185 | unsafe fn __make_static<T>(t: &mut T) -> &'static mut T { |
| 186 | ::core::mem::transmute(t) | 186 | unsafe { ::core::mem::transmute(t) } |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | let mut executor = #executor::new(); | 189 | let mut executor = #executor::new(); |
diff --git a/embassy-executor-macros/src/macros/task.rs b/embassy-executor-macros/src/macros/task.rs index 755948882..8ce8d6726 100644 --- a/embassy-executor-macros/src/macros/task.rs +++ b/embassy-executor-macros/src/macros/task.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | use std::str::FromStr; | 1 | use std::str::FromStr; |
| 2 | 2 | ||
| 3 | use darling::export::NestedMeta; | ||
| 4 | use darling::FromMeta; | 3 | use darling::FromMeta; |
| 4 | use darling::export::NestedMeta; | ||
| 5 | use proc_macro2::{Span, TokenStream}; | 5 | use proc_macro2::{Span, TokenStream}; |
| 6 | use quote::{format_ident, quote}; | 6 | use quote::{format_ident, quote}; |
| 7 | use syn::visit::{self, Visit}; | 7 | use syn::visit::{self, Visit}; |
| @@ -287,7 +287,11 @@ fn check_arg_ty(errors: &mut TokenStream, ty: &Type) { | |||
| 287 | } | 287 | } |
| 288 | 288 | ||
| 289 | fn visit_type_impl_trait(&mut self, i: &'ast syn::TypeImplTrait) { | 289 | fn visit_type_impl_trait(&mut self, i: &'ast syn::TypeImplTrait) { |
| 290 | error(self.errors, i, "`impl Trait` is not allowed in task arguments. It is syntax sugar for generics, and tasks can't be generic."); | 290 | error( |
| 291 | self.errors, | ||
| 292 | i, | ||
| 293 | "`impl Trait` is not allowed in task arguments. It is syntax sugar for generics, and tasks can't be generic.", | ||
| 294 | ); | ||
| 291 | } | 295 | } |
| 292 | } | 296 | } |
| 293 | 297 | ||
diff --git a/embassy-executor-macros/src/util.rs b/embassy-executor-macros/src/util.rs index ebd032a62..5a13f2121 100644 --- a/embassy-executor-macros/src/util.rs +++ b/embassy-executor-macros/src/util.rs | |||
| @@ -3,7 +3,7 @@ use std::fmt::Display; | |||
| 3 | use proc_macro2::{TokenStream, TokenTree}; | 3 | use proc_macro2::{TokenStream, TokenTree}; |
| 4 | use quote::{ToTokens, TokenStreamExt}; | 4 | use quote::{ToTokens, TokenStreamExt}; |
| 5 | use syn::parse::{Parse, ParseStream}; | 5 | use syn::parse::{Parse, ParseStream}; |
| 6 | use syn::{braced, bracketed, token, AttrStyle, Attribute, Signature, Token, Visibility}; | 6 | use syn::{AttrStyle, Attribute, Signature, Token, Visibility, braced, bracketed, token}; |
| 7 | 7 | ||
| 8 | pub fn token_stream_with_error(mut tokens: TokenStream, error: syn::Error) -> TokenStream { | 8 | pub fn token_stream_with_error(mut tokens: TokenStream, error: syn::Error) -> TokenStream { |
| 9 | tokens.extend(error.into_compile_error()); | 9 | tokens.extend(error.into_compile_error()); |
diff --git a/embassy-executor-timer-queue/Cargo.toml b/embassy-executor-timer-queue/Cargo.toml index a0ac44420..6770ab26e 100644 --- a/embassy-executor-timer-queue/Cargo.toml +++ b/embassy-executor-timer-queue/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-executor-timer-queue" | 2 | name = "embassy-executor-timer-queue" |
| 3 | version = "0.1.0" | 3 | version = "0.1.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | description = "Timer queue item and interface between embassy-executor and timer queues" | 5 | description = "Timer queue item and interface between embassy-executor and timer queues" |
| 6 | repository = "https://github.com/embassy-rs/embassy" | 6 | repository = "https://github.com/embassy-rs/embassy" |
| 7 | documentation = "https://docs.embassy.dev/embassy-executor-timer-queue" | 7 | documentation = "https://docs.embassy.dev/embassy-executor-timer-queue" |
diff --git a/embassy-executor/CHANGELOG.md b/embassy-executor/CHANGELOG.md index 6f079a11a..47a8ae995 100644 --- a/embassy-executor/CHANGELOG.md +++ b/embassy-executor/CHANGELOG.md | |||
| @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
| 13 | - Upgraded rtos-trace | 13 | - Upgraded rtos-trace |
| 14 | - Added optional "highest priority" scheduling | 14 | - Added optional "highest priority" scheduling |
| 15 | - Added optional "earliest deadline first" EDF scheduling | 15 | - Added optional "earliest deadline first" EDF scheduling |
| 16 | - Bump `cortex-ar` to v0.3 | ||
| 16 | 17 | ||
| 17 | ## 0.9.1 - 2025-08-31 | 18 | ## 0.9.1 - 2025-08-31 |
| 18 | 19 | ||
diff --git a/embassy-executor/Cargo.toml b/embassy-executor/Cargo.toml index 61d060630..ecc4b6338 100644 --- a/embassy-executor/Cargo.toml +++ b/embassy-executor/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-executor" | 2 | name = "embassy-executor" |
| 3 | version = "0.9.1" | 3 | version = "0.9.1" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | description = "async/await executor designed for embedded usage" | 6 | description = "async/await executor designed for embedded usage" |
| 7 | repository = "https://github.com/embassy-rs/embassy" | 7 | repository = "https://github.com/embassy-rs/embassy" |
| @@ -30,6 +30,8 @@ build = [ | |||
| 30 | {target = "thumbv7em-none-eabi", features = ["arch-cortex-m", "executor-interrupt", "executor-thread", "embassy-time-driver", "scheduler-deadline"]}, | 30 | {target = "thumbv7em-none-eabi", features = ["arch-cortex-m", "executor-interrupt", "executor-thread", "embassy-time-driver", "scheduler-deadline"]}, |
| 31 | {target = "thumbv7em-none-eabi", features = ["arch-cortex-m", "executor-interrupt", "executor-thread", "scheduler-priority", "scheduler-deadline"]}, | 31 | {target = "thumbv7em-none-eabi", features = ["arch-cortex-m", "executor-interrupt", "executor-thread", "scheduler-priority", "scheduler-deadline"]}, |
| 32 | {target = "thumbv7em-none-eabi", features = ["arch-cortex-m", "executor-interrupt", "executor-thread", "scheduler-deadline"]}, | 32 | {target = "thumbv7em-none-eabi", features = ["arch-cortex-m", "executor-interrupt", "executor-thread", "scheduler-deadline"]}, |
| 33 | {target = "thumbv7em-none-eabi", features = ["arch-spin"]}, | ||
| 34 | {target = "thumbv7em-none-eabi", features = ["arch-spin", "scheduler-deadline"]}, | ||
| 33 | {target = "armv7a-none-eabi", features = ["arch-cortex-ar", "executor-thread"]}, | 35 | {target = "armv7a-none-eabi", features = ["arch-cortex-ar", "executor-thread"]}, |
| 34 | {target = "armv7r-none-eabi", features = ["arch-cortex-ar", "executor-thread"]}, | 36 | {target = "armv7r-none-eabi", features = ["arch-cortex-ar", "executor-thread"]}, |
| 35 | {target = "armv7r-none-eabihf", features = ["arch-cortex-ar", "executor-thread"]}, | 37 | {target = "armv7r-none-eabihf", features = ["arch-cortex-ar", "executor-thread"]}, |
| @@ -98,7 +100,7 @@ portable-atomic = { version = "1.5", optional = true } | |||
| 98 | cortex-m = { version = "0.7.6", optional = true } | 100 | cortex-m = { version = "0.7.6", optional = true } |
| 99 | 101 | ||
| 100 | # arch-cortex-ar dependencies | 102 | # arch-cortex-ar dependencies |
| 101 | cortex-ar = { version = "0.2", optional = true } | 103 | cortex-ar = { version = "0.3", optional = true } |
| 102 | 104 | ||
| 103 | # arch-wasm dependencies | 105 | # arch-wasm dependencies |
| 104 | wasm-bindgen = { version = "0.2.82", optional = true } | 106 | wasm-bindgen = { version = "0.2.82", optional = true } |
diff --git a/embassy-executor/src/arch/avr.rs b/embassy-executor/src/arch/avr.rs index 70085d04d..a841afe15 100644 --- a/embassy-executor/src/arch/avr.rs +++ b/embassy-executor/src/arch/avr.rs | |||
| @@ -10,11 +10,11 @@ mod thread { | |||
| 10 | pub use embassy_executor_macros::main_avr as main; | 10 | pub use embassy_executor_macros::main_avr as main; |
| 11 | use portable_atomic::{AtomicBool, Ordering}; | 11 | use portable_atomic::{AtomicBool, Ordering}; |
| 12 | 12 | ||
| 13 | use crate::{raw, Spawner}; | 13 | use crate::{Spawner, raw}; |
| 14 | 14 | ||
| 15 | static SIGNAL_WORK_THREAD_MODE: AtomicBool = AtomicBool::new(false); | 15 | static SIGNAL_WORK_THREAD_MODE: AtomicBool = AtomicBool::new(false); |
| 16 | 16 | ||
| 17 | #[export_name = "__pender"] | 17 | #[unsafe(export_name = "__pender")] |
| 18 | fn __pender(_context: *mut ()) { | 18 | fn __pender(_context: *mut ()) { |
| 19 | SIGNAL_WORK_THREAD_MODE.store(true, Ordering::SeqCst); | 19 | SIGNAL_WORK_THREAD_MODE.store(true, Ordering::SeqCst); |
| 20 | } | 20 | } |
diff --git a/embassy-executor/src/arch/cortex_ar.rs b/embassy-executor/src/arch/cortex_ar.rs index f9e2f3f7c..a9be3d323 100644 --- a/embassy-executor/src/arch/cortex_ar.rs +++ b/embassy-executor/src/arch/cortex_ar.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #[cfg(feature = "executor-interrupt")] | 1 | #[cfg(feature = "executor-interrupt")] |
| 2 | compile_error!("`executor-interrupt` is not supported with `arch-cortex-ar`."); | 2 | compile_error!("`executor-interrupt` is not supported with `arch-cortex-ar`."); |
| 3 | 3 | ||
| 4 | #[export_name = "__pender"] | 4 | #[unsafe(export_name = "__pender")] |
| 5 | #[cfg(any(feature = "executor-thread", feature = "executor-interrupt"))] | 5 | #[cfg(any(feature = "executor-thread", feature = "executor-interrupt"))] |
| 6 | fn __pender(context: *mut ()) { | 6 | fn __pender(context: *mut ()) { |
| 7 | // `context` is always `usize::MAX` created by `Executor::run`. | 7 | // `context` is always `usize::MAX` created by `Executor::run`. |
| @@ -26,7 +26,7 @@ mod thread { | |||
| 26 | use cortex_ar::asm::wfe; | 26 | use cortex_ar::asm::wfe; |
| 27 | pub use embassy_executor_macros::main_cortex_ar as main; | 27 | pub use embassy_executor_macros::main_cortex_ar as main; |
| 28 | 28 | ||
| 29 | use crate::{raw, Spawner}; | 29 | use crate::{Spawner, raw}; |
| 30 | 30 | ||
| 31 | /// Thread mode executor, using WFE/SEV. | 31 | /// Thread mode executor, using WFE/SEV. |
| 32 | /// | 32 | /// |
diff --git a/embassy-executor/src/arch/cortex_m.rs b/embassy-executor/src/arch/cortex_m.rs index 1c9ddd8a0..1ce96d1d5 100644 --- a/embassy-executor/src/arch/cortex_m.rs +++ b/embassy-executor/src/arch/cortex_m.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | #[export_name = "__pender"] | 1 | #[unsafe(export_name = "__pender")] |
| 2 | #[cfg(any(feature = "executor-thread", feature = "executor-interrupt"))] | 2 | #[cfg(any(feature = "executor-thread", feature = "executor-interrupt"))] |
| 3 | fn __pender(context: *mut ()) { | 3 | fn __pender(context: *mut ()) { |
| 4 | unsafe { | 4 | unsafe { |
| @@ -53,7 +53,7 @@ mod thread { | |||
| 53 | 53 | ||
| 54 | pub use embassy_executor_macros::main_cortex_m as main; | 54 | pub use embassy_executor_macros::main_cortex_m as main; |
| 55 | 55 | ||
| 56 | use crate::{raw, Spawner}; | 56 | use crate::{Spawner, raw}; |
| 57 | 57 | ||
| 58 | /// Thread mode executor, using WFE/SEV. | 58 | /// Thread mode executor, using WFE/SEV. |
| 59 | /// | 59 | /// |
diff --git a/embassy-executor/src/arch/riscv32.rs b/embassy-executor/src/arch/riscv32.rs index 01e63a9fd..c70c1344a 100644 --- a/embassy-executor/src/arch/riscv32.rs +++ b/embassy-executor/src/arch/riscv32.rs | |||
| @@ -10,12 +10,12 @@ mod thread { | |||
| 10 | 10 | ||
| 11 | pub use embassy_executor_macros::main_riscv as main; | 11 | pub use embassy_executor_macros::main_riscv as main; |
| 12 | 12 | ||
| 13 | use crate::{raw, Spawner}; | 13 | use crate::{Spawner, raw}; |
| 14 | 14 | ||
| 15 | /// global atomic used to keep track of whether there is work to do since sev() is not available on RISCV | 15 | /// global atomic used to keep track of whether there is work to do since sev() is not available on RISCV |
| 16 | static SIGNAL_WORK_THREAD_MODE: AtomicBool = AtomicBool::new(false); | 16 | static SIGNAL_WORK_THREAD_MODE: AtomicBool = AtomicBool::new(false); |
| 17 | 17 | ||
| 18 | #[export_name = "__pender"] | 18 | #[unsafe(export_name = "__pender")] |
| 19 | fn __pender(_context: *mut ()) { | 19 | fn __pender(_context: *mut ()) { |
| 20 | SIGNAL_WORK_THREAD_MODE.store(true, Ordering::SeqCst); | 20 | SIGNAL_WORK_THREAD_MODE.store(true, Ordering::SeqCst); |
| 21 | } | 21 | } |
diff --git a/embassy-executor/src/arch/spin.rs b/embassy-executor/src/arch/spin.rs index 340023620..49f3356a6 100644 --- a/embassy-executor/src/arch/spin.rs +++ b/embassy-executor/src/arch/spin.rs | |||
| @@ -9,9 +9,9 @@ mod thread { | |||
| 9 | 9 | ||
| 10 | pub use embassy_executor_macros::main_spin as main; | 10 | pub use embassy_executor_macros::main_spin as main; |
| 11 | 11 | ||
| 12 | use crate::{raw, Spawner}; | 12 | use crate::{Spawner, raw}; |
| 13 | 13 | ||
| 14 | #[export_name = "__pender"] | 14 | #[unsafe(export_name = "__pender")] |
| 15 | fn __pender(_context: *mut ()) {} | 15 | fn __pender(_context: *mut ()) {} |
| 16 | 16 | ||
| 17 | /// Spin Executor | 17 | /// Spin Executor |
diff --git a/embassy-executor/src/arch/std.rs b/embassy-executor/src/arch/std.rs index b02b15988..c62ab723b 100644 --- a/embassy-executor/src/arch/std.rs +++ b/embassy-executor/src/arch/std.rs | |||
| @@ -10,9 +10,9 @@ mod thread { | |||
| 10 | 10 | ||
| 11 | pub use embassy_executor_macros::main_std as main; | 11 | pub use embassy_executor_macros::main_std as main; |
| 12 | 12 | ||
| 13 | use crate::{raw, Spawner}; | 13 | use crate::{Spawner, raw}; |
| 14 | 14 | ||
| 15 | #[export_name = "__pender"] | 15 | #[unsafe(export_name = "__pender")] |
| 16 | fn __pender(context: *mut ()) { | 16 | fn __pender(context: *mut ()) { |
| 17 | let signaler: &'static Signaler = unsafe { std::mem::transmute(context) }; | 17 | let signaler: &'static Signaler = unsafe { std::mem::transmute(context) }; |
| 18 | signaler.signal() | 18 | signaler.signal() |
diff --git a/embassy-executor/src/arch/wasm.rs b/embassy-executor/src/arch/wasm.rs index f9d0f935c..d2ff2fe51 100644 --- a/embassy-executor/src/arch/wasm.rs +++ b/embassy-executor/src/arch/wasm.rs | |||
| @@ -13,9 +13,9 @@ mod thread { | |||
| 13 | use wasm_bindgen::prelude::*; | 13 | use wasm_bindgen::prelude::*; |
| 14 | 14 | ||
| 15 | use crate::raw::util::UninitCell; | 15 | use crate::raw::util::UninitCell; |
| 16 | use crate::{raw, Spawner}; | 16 | use crate::{Spawner, raw}; |
| 17 | 17 | ||
| 18 | #[export_name = "__pender"] | 18 | #[unsafe(export_name = "__pender")] |
| 19 | fn __pender(context: *mut ()) { | 19 | fn __pender(context: *mut ()) { |
| 20 | let signaler: &'static WasmContext = unsafe { std::mem::transmute(context) }; | 20 | let signaler: &'static WasmContext = unsafe { std::mem::transmute(context) }; |
| 21 | let _ = signaler.promise.then(unsafe { signaler.closure.as_mut() }); | 21 | let _ = signaler.promise.then(unsafe { signaler.closure.as_mut() }); |
diff --git a/embassy-executor/src/lib.rs b/embassy-executor/src/lib.rs index e47b8eb9f..cffc76699 100644 --- a/embassy-executor/src/lib.rs +++ b/embassy-executor/src/lib.rs | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #![cfg_attr(not(any(feature = "arch-std", feature = "arch-wasm")), no_std)] | 1 | #![cfg_attr(not(any(feature = "arch-std", feature = "arch-wasm")), no_std)] |
| 2 | #![allow(clippy::new_without_default)] | 2 | #![allow(clippy::new_without_default)] |
| 3 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 3 | #![doc = include_str!("../README.md")] | 4 | #![doc = include_str!("../README.md")] |
| 4 | #![warn(missing_docs)] | 5 | #![warn(missing_docs)] |
| 5 | 6 | ||
diff --git a/embassy-executor/src/metadata.rs b/embassy-executor/src/metadata.rs index bc0df0f83..76504ab0b 100644 --- a/embassy-executor/src/metadata.rs +++ b/embassy-executor/src/metadata.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #[cfg(feature = "metadata-name")] | 1 | #[cfg(feature = "metadata-name")] |
| 2 | use core::cell::Cell; | 2 | use core::cell::Cell; |
| 3 | use core::future::{poll_fn, Future}; | 3 | use core::future::{Future, poll_fn}; |
| 4 | #[cfg(feature = "scheduler-priority")] | 4 | #[cfg(feature = "scheduler-priority")] |
| 5 | use core::sync::atomic::{AtomicU8, Ordering}; | 5 | use core::sync::atomic::{AtomicU8, Ordering}; |
| 6 | use core::task::Poll; | 6 | use core::task::Poll; |
diff --git a/embassy-executor/src/raw/mod.rs b/embassy-executor/src/raw/mod.rs index dbd70cbf4..ab845ed3b 100644 --- a/embassy-executor/src/raw/mod.rs +++ b/embassy-executor/src/raw/mod.rs | |||
| @@ -52,7 +52,7 @@ pub use self::waker::task_from_waker; | |||
| 52 | use super::SpawnToken; | 52 | use super::SpawnToken; |
| 53 | use crate::{Metadata, SpawnError}; | 53 | use crate::{Metadata, SpawnError}; |
| 54 | 54 | ||
| 55 | #[no_mangle] | 55 | #[unsafe(no_mangle)] |
| 56 | extern "Rust" fn __embassy_time_queue_item_from_waker(waker: &Waker) -> &'static mut TimerQueueItem { | 56 | extern "Rust" fn __embassy_time_queue_item_from_waker(waker: &Waker) -> &'static mut TimerQueueItem { |
| 57 | unsafe { task_from_waker(waker).timer_queue_item() } | 57 | unsafe { task_from_waker(waker).timer_queue_item() } |
| 58 | } | 58 | } |
| @@ -407,7 +407,7 @@ unsafe impl Sync for Pender {} | |||
| 407 | 407 | ||
| 408 | impl Pender { | 408 | impl Pender { |
| 409 | pub(crate) fn pend(self) { | 409 | pub(crate) fn pend(self) { |
| 410 | extern "Rust" { | 410 | unsafe extern "Rust" { |
| 411 | fn __pender(context: *mut ()); | 411 | fn __pender(context: *mut ()); |
| 412 | } | 412 | } |
| 413 | unsafe { __pender(self.0) }; | 413 | unsafe { __pender(self.0) }; |
| @@ -507,7 +507,7 @@ impl SyncExecutor { | |||
| 507 | /// The pender function must be exported with the name `__pender` and have the following signature: | 507 | /// The pender function must be exported with the name `__pender` and have the following signature: |
| 508 | /// | 508 | /// |
| 509 | /// ```rust | 509 | /// ```rust |
| 510 | /// #[export_name = "__pender"] | 510 | /// #[unsafe(export_name = "__pender")] |
| 511 | /// fn pender(context: *mut ()) { | 511 | /// fn pender(context: *mut ()) { |
| 512 | /// // schedule `poll()` to be called | 512 | /// // schedule `poll()` to be called |
| 513 | /// } | 513 | /// } |
diff --git a/embassy-executor/src/raw/run_queue.rs b/embassy-executor/src/raw/run_queue.rs index b8b052310..6f2abdbd0 100644 --- a/embassy-executor/src/raw/run_queue.rs +++ b/embassy-executor/src/raw/run_queue.rs | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | use core::ptr::{addr_of_mut, NonNull}; | 1 | use core::ptr::{NonNull, addr_of_mut}; |
| 2 | 2 | ||
| 3 | use cordyceps::sorted_list::Links; | ||
| 4 | use cordyceps::Linked; | 3 | use cordyceps::Linked; |
| 5 | #[cfg(any(feature = "scheduler-priority", feature = "scheduler-deadline"))] | 4 | #[cfg(any(feature = "scheduler-priority", feature = "scheduler-deadline"))] |
| 6 | use cordyceps::SortedList; | 5 | use cordyceps::SortedList; |
| 6 | use cordyceps::sorted_list::Links; | ||
| 7 | 7 | ||
| 8 | #[cfg(target_has_atomic = "ptr")] | 8 | #[cfg(target_has_atomic = "ptr")] |
| 9 | type TransferStack<T> = cordyceps::TransferStack<T>; | 9 | type TransferStack<T> = cordyceps::TransferStack<T>; |
diff --git a/embassy-executor/src/raw/state_atomics_arm.rs b/embassy-executor/src/raw/state_atomics_arm.rs index b743dcc2c..f68de955f 100644 --- a/embassy-executor/src/raw/state_atomics_arm.rs +++ b/embassy-executor/src/raw/state_atomics_arm.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use core::sync::atomic::{compiler_fence, AtomicBool, AtomicU32, Ordering}; | 1 | use core::sync::atomic::{AtomicBool, AtomicU32, Ordering, compiler_fence}; |
| 2 | 2 | ||
| 3 | #[derive(Clone, Copy)] | 3 | #[derive(Clone, Copy)] |
| 4 | pub(crate) struct Token(()); | 4 | pub(crate) struct Token(()); |
diff --git a/embassy-executor/src/raw/state_critical_section.rs b/embassy-executor/src/raw/state_critical_section.rs index b69a6ac66..8d7ef2892 100644 --- a/embassy-executor/src/raw/state_critical_section.rs +++ b/embassy-executor/src/raw/state_critical_section.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | use core::cell::Cell; | 1 | use core::cell::Cell; |
| 2 | 2 | ||
| 3 | pub(crate) use critical_section::{with as locked, CriticalSection as Token}; | ||
| 4 | use critical_section::{CriticalSection, Mutex}; | 3 | use critical_section::{CriticalSection, Mutex}; |
| 4 | pub(crate) use critical_section::{CriticalSection as Token, with as locked}; | ||
| 5 | 5 | ||
| 6 | #[cfg(target_arch = "avr")] | 6 | #[cfg(target_arch = "avr")] |
| 7 | type StateBits = u8; | 7 | type StateBits = u8; |
diff --git a/embassy-executor/src/raw/trace.rs b/embassy-executor/src/raw/trace.rs index b3086948c..74519b927 100644 --- a/embassy-executor/src/raw/trace.rs +++ b/embassy-executor/src/raw/trace.rs | |||
| @@ -368,11 +368,7 @@ impl rtos_trace::RtosTraceOSCallbacks for crate::raw::SyncExecutor { | |||
| 368 | } | 368 | } |
| 369 | fn time() -> u64 { | 369 | fn time() -> u64 { |
| 370 | const fn gcd(a: u64, b: u64) -> u64 { | 370 | const fn gcd(a: u64, b: u64) -> u64 { |
| 371 | if b == 0 { | 371 | if b == 0 { a } else { gcd(b, a % b) } |
| 372 | a | ||
| 373 | } else { | ||
| 374 | gcd(b, a % b) | ||
| 375 | } | ||
| 376 | } | 372 | } |
| 377 | 373 | ||
| 378 | const GCD_1M: u64 = gcd(embassy_time_driver::TICK_HZ, 1_000_000); | 374 | const GCD_1M: u64 = gcd(embassy_time_driver::TICK_HZ, 1_000_000); |
diff --git a/embassy-executor/src/raw/waker.rs b/embassy-executor/src/raw/waker.rs index d0d7b003d..2706f0fdf 100644 --- a/embassy-executor/src/raw/waker.rs +++ b/embassy-executor/src/raw/waker.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | use core::task::{RawWaker, RawWakerVTable, Waker}; | 1 | use core::task::{RawWaker, RawWakerVTable, Waker}; |
| 2 | 2 | ||
| 3 | use super::{wake_task, TaskHeader, TaskRef}; | 3 | use super::{TaskHeader, TaskRef, wake_task}; |
| 4 | 4 | ||
| 5 | static VTABLE: RawWakerVTable = RawWakerVTable::new(clone, wake, wake, drop); | 5 | static VTABLE: RawWakerVTable = RawWakerVTable::new(clone, wake, wake, drop); |
| 6 | 6 | ||
| @@ -35,7 +35,9 @@ pub fn task_from_waker(waker: &Waker) -> TaskRef { | |||
| 35 | // make sure to compare vtable addresses. Doing `==` on the references | 35 | // make sure to compare vtable addresses. Doing `==` on the references |
| 36 | // will compare the contents, which is slower. | 36 | // will compare the contents, which is slower. |
| 37 | if waker.vtable() as *const _ != &VTABLE as *const _ { | 37 | if waker.vtable() as *const _ != &VTABLE as *const _ { |
| 38 | panic!("Found waker not created by the Embassy executor. `embassy_time::Timer` only works with the Embassy executor.") | 38 | panic!( |
| 39 | "Found waker not created by the Embassy executor. `embassy_time::Timer` only works with the Embassy executor." | ||
| 40 | ) | ||
| 39 | } | 41 | } |
| 40 | // safety: our wakers are always created with `TaskRef::as_ptr` | 42 | // safety: our wakers are always created with `TaskRef::as_ptr` |
| 41 | unsafe { TaskRef::from_ptr(waker.data() as *const TaskHeader) } | 43 | unsafe { TaskRef::from_ptr(waker.data() as *const TaskHeader) } |
diff --git a/embassy-executor/src/raw/waker_turbo.rs b/embassy-executor/src/raw/waker_turbo.rs index 435a0ff7e..919bcc61a 100644 --- a/embassy-executor/src/raw/waker_turbo.rs +++ b/embassy-executor/src/raw/waker_turbo.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | use core::ptr::NonNull; | 1 | use core::ptr::NonNull; |
| 2 | use core::task::Waker; | 2 | use core::task::Waker; |
| 3 | 3 | ||
| 4 | use super::{wake_task, TaskHeader, TaskRef}; | 4 | use super::{TaskHeader, TaskRef, wake_task}; |
| 5 | 5 | ||
| 6 | pub(crate) unsafe fn from_task(p: TaskRef) -> Waker { | 6 | pub(crate) unsafe fn from_task(p: TaskRef) -> Waker { |
| 7 | Waker::from_turbo_ptr(NonNull::new_unchecked(p.as_ptr() as _)) | 7 | Waker::from_turbo_ptr(NonNull::new_unchecked(p.as_ptr() as _)) |
| @@ -26,7 +26,7 @@ pub fn task_from_waker(waker: &Waker) -> TaskRef { | |||
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | #[inline(never)] | 28 | #[inline(never)] |
| 29 | #[no_mangle] | 29 | #[unsafe(no_mangle)] |
| 30 | fn _turbo_wake(ptr: NonNull<()>) { | 30 | fn _turbo_wake(ptr: NonNull<()>) { |
| 31 | // safety: our wakers are always created with `TaskRef::as_ptr` | 31 | // safety: our wakers are always created with `TaskRef::as_ptr` |
| 32 | let task = unsafe { TaskRef::from_ptr(ptr.as_ptr() as *const TaskHeader) }; | 32 | let task = unsafe { TaskRef::from_ptr(ptr.as_ptr() as *const TaskHeader) }; |
diff --git a/embassy-executor/src/spawner.rs b/embassy-executor/src/spawner.rs index 83d896b76..b73a1e7c6 100644 --- a/embassy-executor/src/spawner.rs +++ b/embassy-executor/src/spawner.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use core::future::{poll_fn, Future}; | 1 | use core::future::{Future, poll_fn}; |
| 2 | use core::marker::PhantomData; | 2 | use core::marker::PhantomData; |
| 3 | use core::mem; | 3 | use core::mem; |
| 4 | use core::sync::atomic::Ordering; | 4 | use core::sync::atomic::Ordering; |
| @@ -75,7 +75,10 @@ impl core::fmt::Debug for SpawnError { | |||
| 75 | impl core::fmt::Display for SpawnError { | 75 | impl core::fmt::Display for SpawnError { |
| 76 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { | 76 | fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { |
| 77 | match self { | 77 | match self { |
| 78 | SpawnError::Busy => write!(f, "Busy - Too many instances of this task are already running. Check the `pool_size` attribute of the task."), | 78 | SpawnError::Busy => write!( |
| 79 | f, | ||
| 80 | "Busy - Too many instances of this task are already running. Check the `pool_size` attribute of the task." | ||
| 81 | ), | ||
| 79 | } | 82 | } |
| 80 | } | 83 | } |
| 81 | } | 84 | } |
| @@ -84,7 +87,10 @@ impl core::fmt::Display for SpawnError { | |||
| 84 | impl defmt::Format for SpawnError { | 87 | impl defmt::Format for SpawnError { |
| 85 | fn format(&self, f: defmt::Formatter) { | 88 | fn format(&self, f: defmt::Formatter) { |
| 86 | match self { | 89 | match self { |
| 87 | SpawnError::Busy => defmt::write!(f, "Busy - Too many instances of this task are already running. Check the `pool_size` attribute of the task."), | 90 | SpawnError::Busy => defmt::write!( |
| 91 | f, | ||
| 92 | "Busy - Too many instances of this task are already running. Check the `pool_size` attribute of the task." | ||
| 93 | ), | ||
| 88 | } | 94 | } |
| 89 | } | 95 | } |
| 90 | } | 96 | } |
diff --git a/embassy-executor/tests/test.rs b/embassy-executor/tests/test.rs index 6baf3dc21..a99976168 100644 --- a/embassy-executor/tests/test.rs +++ b/embassy-executor/tests/test.rs | |||
| @@ -2,14 +2,14 @@ | |||
| 2 | #![cfg_attr(feature = "nightly", feature(never_type))] | 2 | #![cfg_attr(feature = "nightly", feature(never_type))] |
| 3 | 3 | ||
| 4 | use std::boxed::Box; | 4 | use std::boxed::Box; |
| 5 | use std::future::{poll_fn, Future}; | 5 | use std::future::{Future, poll_fn}; |
| 6 | use std::sync::{Arc, Mutex}; | 6 | use std::sync::{Arc, Mutex}; |
| 7 | use std::task::Poll; | 7 | use std::task::Poll; |
| 8 | 8 | ||
| 9 | use embassy_executor::raw::Executor; | 9 | use embassy_executor::raw::Executor; |
| 10 | use embassy_executor::{task, Spawner}; | 10 | use embassy_executor::{Spawner, task}; |
| 11 | 11 | ||
| 12 | #[export_name = "__pender"] | 12 | #[unsafe(export_name = "__pender")] |
| 13 | fn __pender(context: *mut ()) { | 13 | fn __pender(context: *mut ()) { |
| 14 | unsafe { | 14 | unsafe { |
| 15 | let trace = &*(context as *const Trace); | 15 | let trace = &*(context as *const Trace); |
diff --git a/embassy-executor/tests/ui/nonstatic_struct_elided.stderr b/embassy-executor/tests/ui/nonstatic_struct_elided.stderr index 0ee1bfe0c..e6829bf5d 100644 --- a/embassy-executor/tests/ui/nonstatic_struct_elided.stderr +++ b/embassy-executor/tests/ui/nonstatic_struct_elided.stderr | |||
| @@ -9,16 +9,16 @@ help: indicate the anonymous lifetime | |||
| 9 | 6 | async fn task(_x: Foo<'_>) {} | 9 | 6 | async fn task(_x: Foo<'_>) {} |
| 10 | | ++++ | 10 | | ++++ |
| 11 | 11 | ||
| 12 | error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds | 12 | error: lifetime may not live long enough |
| 13 | --> tests/ui/nonstatic_struct_elided.rs:5:1 | 13 | --> tests/ui/nonstatic_struct_elided.rs:5:1 |
| 14 | | | 14 | | |
| 15 | 5 | #[embassy_executor::task] | 15 | 5 | #[embassy_executor::task] |
| 16 | | ^^^^^^^^^^^^^^^^^^^^^^^^^ opaque type defined here | 16 | | ^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static` |
| 17 | 6 | async fn task(_x: Foo) {} | 17 | 6 | async fn task(_x: Foo) {} |
| 18 | | --- hidden type `impl Sized` captures the anonymous lifetime defined here | 18 | | -- has type `Foo<'1>` |
| 19 | | | 19 | | |
| 20 | = note: this error originates in the attribute macro `embassy_executor::task` (in Nightly builds, run with -Z macro-backtrace for more info) | 20 | = note: this error originates in the attribute macro `embassy_executor::task` (in Nightly builds, run with -Z macro-backtrace for more info) |
| 21 | help: add a `use<...>` bound to explicitly capture `'_` | 21 | help: to declare that `impl Sized` captures data from argument `_x`, you can add an explicit `'_` lifetime bound |
| 22 | | | 22 | | |
| 23 | 5 | #[embassy_executor::task] + use<'_> | 23 | 5 | #[embassy_executor::task] + '_ |
| 24 | | +++++++++ | 24 | | ++++ |
diff --git a/embassy-executor/tests/ui/task_safety_attribute.rs b/embassy-executor/tests/ui/task_safety_attribute.rs index ab5a2f99f..46a5c665f 100644 --- a/embassy-executor/tests/ui/task_safety_attribute.rs +++ b/embassy-executor/tests/ui/task_safety_attribute.rs | |||
| @@ -9,7 +9,7 @@ async fn safe() {} | |||
| 9 | #[embassy_executor::task] | 9 | #[embassy_executor::task] |
| 10 | async unsafe fn not_safe() {} | 10 | async unsafe fn not_safe() {} |
| 11 | 11 | ||
| 12 | #[export_name = "__pender"] | 12 | #[unsafe(export_name = "__pender")] |
| 13 | fn pender(_: *mut ()) { | 13 | fn pender(_: *mut ()) { |
| 14 | // The test doesn't link if we don't include this. | 14 | // The test doesn't link if we don't include this. |
| 15 | // We never call this anyway. | 15 | // We never call this anyway. |
diff --git a/embassy-futures/Cargo.toml b/embassy-futures/Cargo.toml index 07d5219cf..d344e5c4b 100644 --- a/embassy-futures/Cargo.toml +++ b/embassy-futures/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-futures" | 2 | name = "embassy-futures" |
| 3 | version = "0.1.2" | 3 | version = "0.1.2" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | description = "no-std, no-alloc utilities for working with futures" | 5 | description = "no-std, no-alloc utilities for working with futures" |
| 6 | repository = "https://github.com/embassy-rs/embassy" | 6 | repository = "https://github.com/embassy-rs/embassy" |
| 7 | documentation = "https://docs.embassy.dev/embassy-futures" | 7 | documentation = "https://docs.embassy.dev/embassy-futures" |
diff --git a/embassy-hal-internal/Cargo.toml b/embassy-hal-internal/Cargo.toml index 11dcc2466..c2e0bd30f 100644 --- a/embassy-hal-internal/Cargo.toml +++ b/embassy-hal-internal/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-hal-internal" | 2 | name = "embassy-hal-internal" |
| 3 | version = "0.3.0" | 3 | version = "0.3.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | description = "Internal implementation details for Embassy HALs. DO NOT USE DIRECTLY." | 6 | description = "Internal implementation details for Embassy HALs. DO NOT USE DIRECTLY." |
| 7 | repository = "https://github.com/embassy-rs/embassy" | 7 | repository = "https://github.com/embassy-rs/embassy" |
diff --git a/embassy-hal-internal/src/atomic_ring_buffer.rs b/embassy-hal-internal/src/atomic_ring_buffer.rs index 00b7a1249..8c3889b85 100644 --- a/embassy-hal-internal/src/atomic_ring_buffer.rs +++ b/embassy-hal-internal/src/atomic_ring_buffer.rs | |||
| @@ -133,6 +133,18 @@ impl RingBuffer { | |||
| 133 | self.len.load(Ordering::Relaxed) | 133 | self.len.load(Ordering::Relaxed) |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | /// Return number of items available to read. | ||
| 137 | pub fn available(&self) -> usize { | ||
| 138 | let end = self.end.load(Ordering::Relaxed); | ||
| 139 | let len = self.len.load(Ordering::Relaxed); | ||
| 140 | let start = self.start.load(Ordering::Relaxed); | ||
| 141 | if end >= start { | ||
| 142 | end - start | ||
| 143 | } else { | ||
| 144 | 2 * len - start + end | ||
| 145 | } | ||
| 146 | } | ||
| 147 | |||
| 136 | /// Check if buffer is full. | 148 | /// Check if buffer is full. |
| 137 | pub fn is_full(&self) -> bool { | 149 | pub fn is_full(&self) -> bool { |
| 138 | let len = self.len.load(Ordering::Relaxed); | 150 | let len = self.len.load(Ordering::Relaxed); |
| @@ -142,6 +154,11 @@ impl RingBuffer { | |||
| 142 | self.wrap(start + len) == end | 154 | self.wrap(start + len) == end |
| 143 | } | 155 | } |
| 144 | 156 | ||
| 157 | /// Check if buffer is at least half full. | ||
| 158 | pub fn is_half_full(&self) -> bool { | ||
| 159 | self.available() >= self.len.load(Ordering::Relaxed) / 2 | ||
| 160 | } | ||
| 161 | |||
| 145 | /// Check if buffer is empty. | 162 | /// Check if buffer is empty. |
| 146 | pub fn is_empty(&self) -> bool { | 163 | pub fn is_empty(&self) -> bool { |
| 147 | let start = self.start.load(Ordering::Relaxed); | 164 | let start = self.start.load(Ordering::Relaxed); |
| @@ -394,6 +411,7 @@ mod tests { | |||
| 394 | rb.init(b.as_mut_ptr(), 4); | 411 | rb.init(b.as_mut_ptr(), 4); |
| 395 | 412 | ||
| 396 | assert_eq!(rb.is_empty(), true); | 413 | assert_eq!(rb.is_empty(), true); |
| 414 | assert_eq!(rb.is_half_full(), false); | ||
| 397 | assert_eq!(rb.is_full(), false); | 415 | assert_eq!(rb.is_full(), false); |
| 398 | 416 | ||
| 399 | rb.writer().push(|buf| { | 417 | rb.writer().push(|buf| { |
| @@ -406,6 +424,7 @@ mod tests { | |||
| 406 | }); | 424 | }); |
| 407 | 425 | ||
| 408 | assert_eq!(rb.is_empty(), false); | 426 | assert_eq!(rb.is_empty(), false); |
| 427 | assert_eq!(rb.is_half_full(), true); | ||
| 409 | assert_eq!(rb.is_full(), true); | 428 | assert_eq!(rb.is_full(), true); |
| 410 | 429 | ||
| 411 | rb.writer().push(|buf| { | 430 | rb.writer().push(|buf| { |
| @@ -415,6 +434,7 @@ mod tests { | |||
| 415 | }); | 434 | }); |
| 416 | 435 | ||
| 417 | assert_eq!(rb.is_empty(), false); | 436 | assert_eq!(rb.is_empty(), false); |
| 437 | assert_eq!(rb.is_half_full(), true); | ||
| 418 | assert_eq!(rb.is_full(), true); | 438 | assert_eq!(rb.is_full(), true); |
| 419 | 439 | ||
| 420 | rb.reader().pop(|buf| { | 440 | rb.reader().pop(|buf| { |
| @@ -424,6 +444,7 @@ mod tests { | |||
| 424 | }); | 444 | }); |
| 425 | 445 | ||
| 426 | assert_eq!(rb.is_empty(), false); | 446 | assert_eq!(rb.is_empty(), false); |
| 447 | assert_eq!(rb.is_half_full(), true); | ||
| 427 | assert_eq!(rb.is_full(), false); | 448 | assert_eq!(rb.is_full(), false); |
| 428 | 449 | ||
| 429 | rb.reader().pop(|buf| { | 450 | rb.reader().pop(|buf| { |
| @@ -432,6 +453,7 @@ mod tests { | |||
| 432 | }); | 453 | }); |
| 433 | 454 | ||
| 434 | assert_eq!(rb.is_empty(), false); | 455 | assert_eq!(rb.is_empty(), false); |
| 456 | assert_eq!(rb.is_half_full(), true); | ||
| 435 | assert_eq!(rb.is_full(), false); | 457 | assert_eq!(rb.is_full(), false); |
| 436 | 458 | ||
| 437 | rb.reader().pop(|buf| { | 459 | rb.reader().pop(|buf| { |
| @@ -447,6 +469,7 @@ mod tests { | |||
| 447 | }); | 469 | }); |
| 448 | 470 | ||
| 449 | assert_eq!(rb.is_empty(), true); | 471 | assert_eq!(rb.is_empty(), true); |
| 472 | assert_eq!(rb.is_half_full(), false); | ||
| 450 | assert_eq!(rb.is_full(), false); | 473 | assert_eq!(rb.is_full(), false); |
| 451 | 474 | ||
| 452 | rb.reader().pop(|buf| { | 475 | rb.reader().pop(|buf| { |
| @@ -460,14 +483,28 @@ mod tests { | |||
| 460 | 1 | 483 | 1 |
| 461 | }); | 484 | }); |
| 462 | 485 | ||
| 486 | assert_eq!(rb.is_empty(), false); | ||
| 487 | assert_eq!(rb.is_half_full(), false); | ||
| 488 | assert_eq!(rb.is_full(), false); | ||
| 489 | |||
| 463 | rb.writer().push(|buf| { | 490 | rb.writer().push(|buf| { |
| 464 | assert_eq!(3, buf.len()); | 491 | assert_eq!(3, buf.len()); |
| 465 | buf[0] = 11; | 492 | buf[0] = 11; |
| 466 | buf[1] = 12; | 493 | 1 |
| 467 | 2 | 494 | }); |
| 495 | |||
| 496 | assert_eq!(rb.is_empty(), false); | ||
| 497 | assert_eq!(rb.is_half_full(), true); | ||
| 498 | assert_eq!(rb.is_full(), false); | ||
| 499 | |||
| 500 | rb.writer().push(|buf| { | ||
| 501 | assert_eq!(2, buf.len()); | ||
| 502 | buf[0] = 12; | ||
| 503 | 1 | ||
| 468 | }); | 504 | }); |
| 469 | 505 | ||
| 470 | assert_eq!(rb.is_empty(), false); | 506 | assert_eq!(rb.is_empty(), false); |
| 507 | assert_eq!(rb.is_half_full(), true); | ||
| 471 | assert_eq!(rb.is_full(), false); | 508 | assert_eq!(rb.is_full(), false); |
| 472 | 509 | ||
| 473 | rb.writer().push(|buf| { | 510 | rb.writer().push(|buf| { |
| @@ -477,6 +514,7 @@ mod tests { | |||
| 477 | }); | 514 | }); |
| 478 | 515 | ||
| 479 | assert_eq!(rb.is_empty(), false); | 516 | assert_eq!(rb.is_empty(), false); |
| 517 | assert_eq!(rb.is_half_full(), true); | ||
| 480 | assert_eq!(rb.is_full(), true); | 518 | assert_eq!(rb.is_full(), true); |
| 481 | } | 519 | } |
| 482 | } | 520 | } |
| @@ -490,6 +528,7 @@ mod tests { | |||
| 490 | rb.init(b.as_mut_ptr(), b.len()); | 528 | rb.init(b.as_mut_ptr(), b.len()); |
| 491 | 529 | ||
| 492 | assert_eq!(rb.is_empty(), true); | 530 | assert_eq!(rb.is_empty(), true); |
| 531 | assert_eq!(rb.is_half_full(), true); | ||
| 493 | assert_eq!(rb.is_full(), true); | 532 | assert_eq!(rb.is_full(), true); |
| 494 | 533 | ||
| 495 | rb.writer().push(|buf| { | 534 | rb.writer().push(|buf| { |
diff --git a/embassy-hal-internal/src/interrupt.rs b/embassy-hal-internal/src/interrupt.rs index 5e64dce9d..ce6057e2d 100644 --- a/embassy-hal-internal/src/interrupt.rs +++ b/embassy-hal-internal/src/interrupt.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | //! Interrupt handling for cortex-m devices. | 1 | //! Interrupt handling for cortex-m devices. |
| 2 | use core::mem; | 2 | use core::mem; |
| 3 | use core::sync::atomic::{compiler_fence, Ordering}; | 3 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 4 | 4 | ||
| 5 | use cortex_m::interrupt::InterruptNumber; | 5 | use cortex_m::interrupt::InterruptNumber; |
| 6 | use cortex_m::peripheral::NVIC; | 6 | use cortex_m::peripheral::NVIC; |
diff --git a/embassy-hal-internal/src/lib.rs b/embassy-hal-internal/src/lib.rs index 7addb71e2..729f97f0c 100644 --- a/embassy-hal-internal/src/lib.rs +++ b/embassy-hal-internal/src/lib.rs | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![allow(clippy::new_without_default)] | 2 | #![allow(clippy::new_without_default)] |
| 3 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 3 | #![doc = include_str!("../README.md")] | 4 | #![doc = include_str!("../README.md")] |
| 4 | #![warn(missing_docs)] | 5 | #![warn(missing_docs)] |
| 5 | 6 | ||
diff --git a/embassy-hal-internal/src/macros.rs b/embassy-hal-internal/src/macros.rs index ce72ded5c..0fcca2baf 100644 --- a/embassy-hal-internal/src/macros.rs +++ b/embassy-hal-internal/src/macros.rs | |||
| @@ -58,7 +58,7 @@ macro_rules! peripherals_struct { | |||
| 58 | ///Returns all the peripherals *once* | 58 | ///Returns all the peripherals *once* |
| 59 | #[inline] | 59 | #[inline] |
| 60 | pub(crate) fn take_with_cs(_cs: critical_section::CriticalSection) -> Self { | 60 | pub(crate) fn take_with_cs(_cs: critical_section::CriticalSection) -> Self { |
| 61 | #[no_mangle] | 61 | #[unsafe(no_mangle)] |
| 62 | static mut _EMBASSY_DEVICE_PERIPHERALS: bool = false; | 62 | static mut _EMBASSY_DEVICE_PERIPHERALS: bool = false; |
| 63 | 63 | ||
| 64 | // safety: OK because we're inside a CS. | 64 | // safety: OK because we're inside a CS. |
diff --git a/embassy-imxrt/Cargo.toml b/embassy-imxrt/Cargo.toml index 7561640dd..c47756f10 100644 --- a/embassy-imxrt/Cargo.toml +++ b/embassy-imxrt/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-imxrt" | 2 | name = "embassy-imxrt" |
| 3 | version = "0.1.0" | 3 | version = "0.1.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | description = "Embassy Hardware Abstraction Layer (HAL) for the IMXRT microcontroller" | 6 | description = "Embassy Hardware Abstraction Layer (HAL) for the IMXRT microcontroller" |
| 7 | keywords = ["embedded", "async", "imxrt", "rt600", "embedded-hal"] | 7 | keywords = ["embedded", "async", "imxrt", "rt600", "embedded-hal"] |
diff --git a/embassy-imxrt/src/clocks.rs b/embassy-imxrt/src/clocks.rs index 39c3e6238..22df2686f 100644 --- a/embassy-imxrt/src/clocks.rs +++ b/embassy-imxrt/src/clocks.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | //! Clock configuration for the `RT6xx` | 1 | //! Clock configuration for the `RT6xx` |
| 2 | use core::sync::atomic::{AtomicU32, AtomicU8, Ordering}; | 2 | use core::sync::atomic::{AtomicU8, AtomicU32, Ordering}; |
| 3 | 3 | ||
| 4 | use paste::paste; | 4 | use paste::paste; |
| 5 | 5 | ||
diff --git a/embassy-imxrt/src/crc.rs b/embassy-imxrt/src/crc.rs index 24d6ba5bd..d6f0419d0 100644 --- a/embassy-imxrt/src/crc.rs +++ b/embassy-imxrt/src/crc.rs | |||
| @@ -2,9 +2,9 @@ | |||
| 2 | 2 | ||
| 3 | use core::marker::PhantomData; | 3 | use core::marker::PhantomData; |
| 4 | 4 | ||
| 5 | use crate::clocks::{enable_and_reset, SysconPeripheral}; | 5 | use crate::clocks::{SysconPeripheral, enable_and_reset}; |
| 6 | pub use crate::pac::crc_engine::mode::CrcPolynomial as Polynomial; | 6 | pub use crate::pac::crc_engine::mode::CrcPolynomial as Polynomial; |
| 7 | use crate::{peripherals, Peri, PeripheralType}; | 7 | use crate::{Peri, PeripheralType, peripherals}; |
| 8 | 8 | ||
| 9 | /// CRC driver. | 9 | /// CRC driver. |
| 10 | pub struct Crc<'d> { | 10 | pub struct Crc<'d> { |
diff --git a/embassy-imxrt/src/dma.rs b/embassy-imxrt/src/dma.rs index e141447f3..e71a27e0e 100644 --- a/embassy-imxrt/src/dma.rs +++ b/embassy-imxrt/src/dma.rs | |||
| @@ -2,10 +2,10 @@ | |||
| 2 | 2 | ||
| 3 | use core::future::Future; | 3 | use core::future::Future; |
| 4 | use core::pin::Pin; | 4 | use core::pin::Pin; |
| 5 | use core::sync::atomic::{compiler_fence, Ordering}; | 5 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 6 | use core::task::{Context, Poll}; | 6 | use core::task::{Context, Poll}; |
| 7 | 7 | ||
| 8 | use embassy_hal_internal::{impl_peripheral, Peri, PeripheralType}; | 8 | use embassy_hal_internal::{Peri, PeripheralType, impl_peripheral}; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 10 | use pac::dma0::channel::cfg::Periphreqen; | 10 | use pac::dma0::channel::cfg::Periphreqen; |
| 11 | use pac::dma0::channel::xfercfg::{Dstinc, Srcinc, Width}; | 11 | use pac::dma0::channel::xfercfg::{Dstinc, Srcinc, Width}; |
| @@ -14,7 +14,7 @@ use crate::clocks::enable_and_reset; | |||
| 14 | use crate::interrupt::InterruptExt; | 14 | use crate::interrupt::InterruptExt; |
| 15 | use crate::peripherals::DMA0; | 15 | use crate::peripherals::DMA0; |
| 16 | use crate::sealed::Sealed; | 16 | use crate::sealed::Sealed; |
| 17 | use crate::{interrupt, pac, peripherals, BitIter}; | 17 | use crate::{BitIter, interrupt, pac, peripherals}; |
| 18 | 18 | ||
| 19 | #[cfg(feature = "rt")] | 19 | #[cfg(feature = "rt")] |
| 20 | #[interrupt] | 20 | #[interrupt] |
diff --git a/embassy-imxrt/src/flexcomm/mod.rs b/embassy-imxrt/src/flexcomm/mod.rs index 4473c9a77..27794042b 100644 --- a/embassy-imxrt/src/flexcomm/mod.rs +++ b/embassy-imxrt/src/flexcomm/mod.rs | |||
| @@ -4,11 +4,11 @@ pub mod uart; | |||
| 4 | 4 | ||
| 5 | use paste::paste; | 5 | use paste::paste; |
| 6 | 6 | ||
| 7 | use crate::clocks::{enable_and_reset, SysconPeripheral}; | 7 | use crate::clocks::{SysconPeripheral, enable_and_reset}; |
| 8 | use crate::peripherals::{ | 8 | use crate::peripherals::{ |
| 9 | FLEXCOMM0, FLEXCOMM1, FLEXCOMM14, FLEXCOMM15, FLEXCOMM2, FLEXCOMM3, FLEXCOMM4, FLEXCOMM5, FLEXCOMM6, FLEXCOMM7, | 9 | FLEXCOMM0, FLEXCOMM1, FLEXCOMM2, FLEXCOMM3, FLEXCOMM4, FLEXCOMM5, FLEXCOMM6, FLEXCOMM7, FLEXCOMM14, FLEXCOMM15, |
| 10 | }; | 10 | }; |
| 11 | use crate::{pac, PeripheralType}; | 11 | use crate::{PeripheralType, pac}; |
| 12 | 12 | ||
| 13 | /// clock selection option | 13 | /// clock selection option |
| 14 | #[derive(Copy, Clone, Debug)] | 14 | #[derive(Copy, Clone, Debug)] |
| @@ -223,9 +223,15 @@ macro_rules! into_mode { | |||
| 223 | } | 223 | } |
| 224 | } | 224 | } |
| 225 | 225 | ||
| 226 | into_mode!(usart, FLEXCOMM0, FLEXCOMM1, FLEXCOMM2, FLEXCOMM3, FLEXCOMM4, FLEXCOMM5, FLEXCOMM6, FLEXCOMM7); | 226 | into_mode!( |
| 227 | into_mode!(spi, FLEXCOMM0, FLEXCOMM1, FLEXCOMM2, FLEXCOMM3, FLEXCOMM4, FLEXCOMM5, FLEXCOMM6, FLEXCOMM7, FLEXCOMM14); | 227 | usart, FLEXCOMM0, FLEXCOMM1, FLEXCOMM2, FLEXCOMM3, FLEXCOMM4, FLEXCOMM5, FLEXCOMM6, FLEXCOMM7 |
| 228 | into_mode!(i2c, FLEXCOMM0, FLEXCOMM1, FLEXCOMM2, FLEXCOMM3, FLEXCOMM4, FLEXCOMM5, FLEXCOMM6, FLEXCOMM7, FLEXCOMM15); | 228 | ); |
| 229 | into_mode!( | ||
| 230 | spi, FLEXCOMM0, FLEXCOMM1, FLEXCOMM2, FLEXCOMM3, FLEXCOMM4, FLEXCOMM5, FLEXCOMM6, FLEXCOMM7, FLEXCOMM14 | ||
| 231 | ); | ||
| 232 | into_mode!( | ||
| 233 | i2c, FLEXCOMM0, FLEXCOMM1, FLEXCOMM2, FLEXCOMM3, FLEXCOMM4, FLEXCOMM5, FLEXCOMM6, FLEXCOMM7, FLEXCOMM15 | ||
| 234 | ); | ||
| 229 | 235 | ||
| 230 | into_mode!( | 236 | into_mode!( |
| 231 | i2s_transmit, | 237 | i2s_transmit, |
diff --git a/embassy-imxrt/src/flexcomm/uart.rs b/embassy-imxrt/src/flexcomm/uart.rs index 230b30d43..2b759ba84 100644 --- a/embassy-imxrt/src/flexcomm/uart.rs +++ b/embassy-imxrt/src/flexcomm/uart.rs | |||
| @@ -2,10 +2,10 @@ | |||
| 2 | 2 | ||
| 3 | use core::future::poll_fn; | 3 | use core::future::poll_fn; |
| 4 | use core::marker::PhantomData; | 4 | use core::marker::PhantomData; |
| 5 | use core::sync::atomic::{compiler_fence, AtomicU8, Ordering}; | 5 | use core::sync::atomic::{AtomicU8, Ordering, compiler_fence}; |
| 6 | use core::task::Poll; | 6 | use core::task::Poll; |
| 7 | 7 | ||
| 8 | use embassy_futures::select::{select, Either}; | 8 | use embassy_futures::select::{Either, select}; |
| 9 | use embassy_hal_internal::drop::OnDrop; | 9 | use embassy_hal_internal::drop::OnDrop; |
| 10 | use embassy_hal_internal::{Peri, PeripheralType}; | 10 | use embassy_hal_internal::{Peri, PeripheralType}; |
| 11 | use embassy_sync::waitqueue::AtomicWaker; | 11 | use embassy_sync::waitqueue::AtomicWaker; |
diff --git a/embassy-imxrt/src/gpio.rs b/embassy-imxrt/src/gpio.rs index e62fde8b1..4a0608e76 100644 --- a/embassy-imxrt/src/gpio.rs +++ b/embassy-imxrt/src/gpio.rs | |||
| @@ -13,7 +13,7 @@ use crate::clocks::enable_and_reset; | |||
| 13 | use crate::iopctl::IopctlPin; | 13 | use crate::iopctl::IopctlPin; |
| 14 | pub use crate::iopctl::{AnyPin, DriveMode, DriveStrength, Function, Inverter, Pull, SlewRate}; | 14 | pub use crate::iopctl::{AnyPin, DriveMode, DriveStrength, Function, Inverter, Pull, SlewRate}; |
| 15 | use crate::sealed::Sealed; | 15 | use crate::sealed::Sealed; |
| 16 | use crate::{interrupt, peripherals, BitIter, Peri, PeripheralType}; | 16 | use crate::{BitIter, Peri, PeripheralType, interrupt, peripherals}; |
| 17 | 17 | ||
| 18 | // This should be unique per IMXRT package | 18 | // This should be unique per IMXRT package |
| 19 | const PORT_COUNT: usize = 8; | 19 | const PORT_COUNT: usize = 8; |
diff --git a/embassy-imxrt/src/iopctl.rs b/embassy-imxrt/src/iopctl.rs index a3b8b14d6..805bf2f1b 100644 --- a/embassy-imxrt/src/iopctl.rs +++ b/embassy-imxrt/src/iopctl.rs | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | //! | 2 | //! |
| 3 | //! Also known as IO Pin Configuration (IOCON) | 3 | //! Also known as IO Pin Configuration (IOCON) |
| 4 | 4 | ||
| 5 | use crate::pac::{iopctl, Iopctl}; | 5 | use crate::pac::{Iopctl, iopctl}; |
| 6 | 6 | ||
| 7 | // A generic pin of any type. | 7 | // A generic pin of any type. |
| 8 | // | 8 | // |
diff --git a/embassy-imxrt/src/lib.rs b/embassy-imxrt/src/lib.rs index a3437c655..643dd0c8a 100644 --- a/embassy-imxrt/src/lib.rs +++ b/embassy-imxrt/src/lib.rs | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![allow(async_fn_in_trait)] | 2 | #![allow(async_fn_in_trait)] |
| 3 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 3 | #![doc = include_str!("../README.md")] | 4 | #![doc = include_str!("../README.md")] |
| 4 | #![warn(missing_docs)] | 5 | #![warn(missing_docs)] |
| 5 | 6 | ||
| @@ -39,7 +40,7 @@ pub use chip::interrupts::*; | |||
| 39 | pub use chip::pac; | 40 | pub use chip::pac; |
| 40 | #[cfg(not(feature = "unstable-pac"))] | 41 | #[cfg(not(feature = "unstable-pac"))] |
| 41 | pub(crate) use chip::pac; | 42 | pub(crate) use chip::pac; |
| 42 | pub use chip::{peripherals, Peripherals}; | 43 | pub use chip::{Peripherals, peripherals}; |
| 43 | pub use embassy_hal_internal::{Peri, PeripheralType}; | 44 | pub use embassy_hal_internal::{Peri, PeripheralType}; |
| 44 | 45 | ||
| 45 | #[cfg(feature = "rt")] | 46 | #[cfg(feature = "rt")] |
| @@ -74,7 +75,7 @@ macro_rules! bind_interrupts { | |||
| 74 | 75 | ||
| 75 | $( | 76 | $( |
| 76 | #[allow(non_snake_case)] | 77 | #[allow(non_snake_case)] |
| 77 | #[no_mangle] | 78 | #[unsafe(no_mangle)] |
| 78 | unsafe extern "C" fn $irq() { | 79 | unsafe extern "C" fn $irq() { |
| 79 | unsafe { | 80 | unsafe { |
| 80 | $( | 81 | $( |
diff --git a/embassy-imxrt/src/rng.rs b/embassy-imxrt/src/rng.rs index 75f243df9..094418e41 100644 --- a/embassy-imxrt/src/rng.rs +++ b/embassy-imxrt/src/rng.rs | |||
| @@ -7,9 +7,9 @@ use core::task::Poll; | |||
| 7 | use embassy_futures::block_on; | 7 | use embassy_futures::block_on; |
| 8 | use embassy_sync::waitqueue::AtomicWaker; | 8 | use embassy_sync::waitqueue::AtomicWaker; |
| 9 | 9 | ||
| 10 | use crate::clocks::{enable_and_reset, SysconPeripheral}; | 10 | use crate::clocks::{SysconPeripheral, enable_and_reset}; |
| 11 | use crate::interrupt::typelevel::Interrupt; | 11 | use crate::interrupt::typelevel::Interrupt; |
| 12 | use crate::{interrupt, peripherals, Peri, PeripheralType}; | 12 | use crate::{Peri, PeripheralType, interrupt, peripherals}; |
| 13 | 13 | ||
| 14 | static RNG_WAKER: AtomicWaker = AtomicWaker::new(); | 14 | static RNG_WAKER: AtomicWaker = AtomicWaker::new(); |
| 15 | 15 | ||
diff --git a/embassy-imxrt/src/time_driver.rs b/embassy-imxrt/src/time_driver.rs index f127609c8..fbd935b70 100644 --- a/embassy-imxrt/src/time_driver.rs +++ b/embassy-imxrt/src/time_driver.rs | |||
| @@ -1,11 +1,11 @@ | |||
| 1 | //! Time Driver. | 1 | //! Time Driver. |
| 2 | use core::cell::{Cell, RefCell}; | 2 | use core::cell::{Cell, RefCell}; |
| 3 | #[cfg(feature = "time-driver-rtc")] | 3 | #[cfg(feature = "time-driver-rtc")] |
| 4 | use core::sync::atomic::{compiler_fence, AtomicU32, Ordering}; | 4 | use core::sync::atomic::{AtomicU32, Ordering, compiler_fence}; |
| 5 | 5 | ||
| 6 | use critical_section::CriticalSection; | 6 | use critical_section::CriticalSection; |
| 7 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | ||
| 8 | use embassy_sync::blocking_mutex::Mutex; | 7 | use embassy_sync::blocking_mutex::Mutex; |
| 8 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | ||
| 9 | use embassy_time_driver::Driver; | 9 | use embassy_time_driver::Driver; |
| 10 | use embassy_time_queue_utils::Queue; | 10 | use embassy_time_queue_utils::Queue; |
| 11 | 11 | ||
diff --git a/embassy-mspm0/CHANGELOG.md b/embassy-mspm0/CHANGELOG.md index b846f21b1..948f0205d 100644 --- a/embassy-mspm0/CHANGELOG.md +++ b/embassy-mspm0/CHANGELOG.md | |||
| @@ -13,3 +13,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
| 13 | - feat: Add window watchdog implementation based on WWDT0, WWDT1 peripherals (#4574) | 13 | - feat: Add window watchdog implementation based on WWDT0, WWDT1 peripherals (#4574) |
| 14 | - feat: Add MSPM0C1105/C1106 support | 14 | - feat: Add MSPM0C1105/C1106 support |
| 15 | - feat: Add adc implementation (#4646) | 15 | - feat: Add adc implementation (#4646) |
| 16 | - fix: gpio OutputOpenDrain config (#4735) | ||
| 17 | - fix: add MSPM0C1106 to build test matrix | ||
| 18 | - feat: add MSPM0H3216 support | ||
diff --git a/embassy-mspm0/Cargo.toml b/embassy-mspm0/Cargo.toml index 1b32c4d43..df6176ff6 100644 --- a/embassy-mspm0/Cargo.toml +++ b/embassy-mspm0/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-mspm0" | 2 | name = "embassy-mspm0" |
| 3 | version = "0.1.0" | 3 | version = "0.1.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | description = "Embassy Hardware Abstraction Layer (HAL) for Texas Instruments MSPM0 series microcontrollers" | 6 | description = "Embassy Hardware Abstraction Layer (HAL) for Texas Instruments MSPM0 series microcontrollers" |
| 7 | keywords = ["embedded", "async", "mspm0", "hal", "embedded-hal"] | 7 | keywords = ["embedded", "async", "mspm0", "hal", "embedded-hal"] |
| @@ -15,17 +15,19 @@ publish = false | |||
| 15 | [package.metadata.embassy] | 15 | [package.metadata.embassy] |
| 16 | build = [ | 16 | build = [ |
| 17 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0c1104dgs20", "time-driver-any"]}, | 17 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0c1104dgs20", "time-driver-any"]}, |
| 18 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0c1106rgz", "time-driver-any"]}, | ||
| 19 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g1107ycj", "time-driver-any"]}, | ||
| 20 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g1505pt", "time-driver-any"]}, | ||
| 21 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g1519rhb", "time-driver-any"]}, | ||
| 22 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g3105rhb", "time-driver-any"]}, | ||
| 18 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g3507pm", "time-driver-any"]}, | 23 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g3507pm", "time-driver-any"]}, |
| 19 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g3519pz", "time-driver-any"]}, | 24 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g3519pz", "time-driver-any"]}, |
| 25 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0h3216pt", "time-driver-any"]}, | ||
| 20 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0l1306rhb", "time-driver-any"]}, | 26 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0l1306rhb", "time-driver-any"]}, |
| 21 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0l2228pn", "time-driver-any"]}, | 27 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0l2228pn", "time-driver-any"]}, |
| 22 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0l1345dgs28", "time-driver-any"]}, | 28 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0l1345dgs28", "time-driver-any"]}, |
| 23 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0l1106dgs28", "time-driver-any"]}, | 29 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0l1106dgs28", "time-driver-any"]}, |
| 24 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0l1228pm", "time-driver-any"]}, | 30 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0l1228pt", "time-driver-any"]}, |
| 25 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g1107ycj", "time-driver-any"]}, | ||
| 26 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g3105rhb", "time-driver-any"]}, | ||
| 27 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g1505pt", "time-driver-any"]}, | ||
| 28 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g1519rhb", "time-driver-any"]}, | ||
| 29 | ] | 31 | ] |
| 30 | 32 | ||
| 31 | [package.metadata.embassy_docs] | 33 | [package.metadata.embassy_docs] |
| @@ -37,6 +39,7 @@ flavors = [ | |||
| 37 | { regex_feature = "mspm0c.*", target = "thumbv6m-none-eabi" }, | 39 | { regex_feature = "mspm0c.*", target = "thumbv6m-none-eabi" }, |
| 38 | { regex_feature = "mspm0l.*", target = "thumbv6m-none-eabi" }, | 40 | { regex_feature = "mspm0l.*", target = "thumbv6m-none-eabi" }, |
| 39 | { regex_feature = "mspm0g.*", target = "thumbv6m-none-eabi" }, | 41 | { regex_feature = "mspm0g.*", target = "thumbv6m-none-eabi" }, |
| 42 | { regex_feature = "mspm0h.*", target = "thumbv6m-none-eabi" }, | ||
| 40 | ] | 43 | ] |
| 41 | 44 | ||
| 42 | [package.metadata.docs.rs] | 45 | [package.metadata.docs.rs] |
| @@ -69,7 +72,7 @@ cortex-m = "0.7.6" | |||
| 69 | critical-section = "1.2.0" | 72 | critical-section = "1.2.0" |
| 70 | 73 | ||
| 71 | # mspm0-metapac = { version = "" } | 74 | # mspm0-metapac = { version = "" } |
| 72 | mspm0-metapac = { git = "https://github.com/mspm0-rs/mspm0-data-generated/", tag = "mspm0-data-d7bf3d01ac0780e716a45b0474234d39443dc5cf" } | 75 | mspm0-metapac = { git = "https://github.com/mspm0-rs/mspm0-data-generated/", tag = "mspm0-data-e7de4103a0713772695ffcad52c3c2f07414dc29" } |
| 73 | 76 | ||
| 74 | [build-dependencies] | 77 | [build-dependencies] |
| 75 | proc-macro2 = "1.0.94" | 78 | proc-macro2 = "1.0.94" |
| @@ -77,7 +80,7 @@ quote = "1.0.40" | |||
| 77 | cfg_aliases = "0.2.1" | 80 | cfg_aliases = "0.2.1" |
| 78 | 81 | ||
| 79 | # mspm0-metapac = { version = "", default-features = false, features = ["metadata"] } | 82 | # mspm0-metapac = { version = "", default-features = false, features = ["metadata"] } |
| 80 | mspm0-metapac = { git = "https://github.com/mspm0-rs/mspm0-data-generated/", tag = "mspm0-data-d7bf3d01ac0780e716a45b0474234d39443dc5cf", default-features = false, features = ["metadata"] } | 83 | mspm0-metapac = { git = "https://github.com/mspm0-rs/mspm0-data-generated/", tag = "mspm0-data-e7de4103a0713772695ffcad52c3c2f07414dc29", default-features = false, features = ["metadata"] } |
| 81 | 84 | ||
| 82 | [features] | 85 | [features] |
| 83 | default = ["rt"] | 86 | default = ["rt"] |
| @@ -243,6 +246,7 @@ mspm0g3519pn = ["mspm0-metapac/mspm0g3519pn"] | |||
| 243 | mspm0g3519pz = ["mspm0-metapac/mspm0g3519pz"] | 246 | mspm0g3519pz = ["mspm0-metapac/mspm0g3519pz"] |
| 244 | mspm0g3519rgz = ["mspm0-metapac/mspm0g3519rgz"] | 247 | mspm0g3519rgz = ["mspm0-metapac/mspm0g3519rgz"] |
| 245 | mspm0g3519rhb = ["mspm0-metapac/mspm0g3519rhb"] | 248 | mspm0g3519rhb = ["mspm0-metapac/mspm0g3519rhb"] |
| 249 | mspm0h3216pt = ["mspm0-metapac/mspm0h3216pt"] | ||
| 246 | mspm0l1105dgs20 = ["mspm0-metapac/mspm0l1105dgs20"] | 250 | mspm0l1105dgs20 = ["mspm0-metapac/mspm0l1105dgs20"] |
| 247 | mspm0l1105dgs28 = ["mspm0-metapac/mspm0l1105dgs28"] | 251 | mspm0l1105dgs28 = ["mspm0-metapac/mspm0l1105dgs28"] |
| 248 | mspm0l1105dyy = ["mspm0-metapac/mspm0l1105dyy"] | 252 | mspm0l1105dyy = ["mspm0-metapac/mspm0l1105dyy"] |
diff --git a/embassy-mspm0/build.rs b/embassy-mspm0/build.rs index d294bc422..1d118ad66 100644 --- a/embassy-mspm0/build.rs +++ b/embassy-mspm0/build.rs | |||
| @@ -16,14 +16,15 @@ use quote::{format_ident, quote}; | |||
| 16 | mod common; | 16 | mod common; |
| 17 | 17 | ||
| 18 | fn main() { | 18 | fn main() { |
| 19 | generate_code(); | ||
| 20 | interrupt_group_linker_magic(); | ||
| 21 | } | ||
| 22 | |||
| 23 | fn generate_code() { | ||
| 24 | let mut cfgs = common::CfgSet::new(); | 19 | let mut cfgs = common::CfgSet::new(); |
| 25 | common::set_target_cfgs(&mut cfgs); | 20 | common::set_target_cfgs(&mut cfgs); |
| 26 | 21 | ||
| 22 | generate_code(&mut cfgs); | ||
| 23 | select_gpio_features(&mut cfgs); | ||
| 24 | interrupt_group_linker_magic(); | ||
| 25 | } | ||
| 26 | |||
| 27 | fn generate_code(cfgs: &mut CfgSet) { | ||
| 27 | #[cfg(any(feature = "rt"))] | 28 | #[cfg(any(feature = "rt"))] |
| 28 | println!( | 29 | println!( |
| 29 | "cargo:rustc-link-search={}", | 30 | "cargo:rustc-link-search={}", |
| @@ -53,9 +54,9 @@ fn generate_code() { | |||
| 53 | cfgs.declare_all(&get_chip_cfgs(&chip)); | 54 | cfgs.declare_all(&get_chip_cfgs(&chip)); |
| 54 | } | 55 | } |
| 55 | 56 | ||
| 56 | let mut singletons = get_singletons(&mut cfgs); | 57 | let mut singletons = get_singletons(cfgs); |
| 57 | 58 | ||
| 58 | time_driver(&mut singletons, &mut cfgs); | 59 | time_driver(&mut singletons, cfgs); |
| 59 | 60 | ||
| 60 | let mut g = TokenStream::new(); | 61 | let mut g = TokenStream::new(); |
| 61 | 62 | ||
| @@ -68,7 +69,7 @@ fn generate_code() { | |||
| 68 | g.extend(generate_pin_trait_impls()); | 69 | g.extend(generate_pin_trait_impls()); |
| 69 | g.extend(generate_groups()); | 70 | g.extend(generate_groups()); |
| 70 | g.extend(generate_dma_channel_count()); | 71 | g.extend(generate_dma_channel_count()); |
| 71 | g.extend(generate_adc_constants(&mut cfgs)); | 72 | g.extend(generate_adc_constants(cfgs)); |
| 72 | 73 | ||
| 73 | let out_dir = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); | 74 | let out_dir = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); |
| 74 | let out_file = out_dir.join("_generated.rs").to_string_lossy().to_string(); | 75 | let out_file = out_dir.join("_generated.rs").to_string_lossy().to_string(); |
| @@ -115,6 +116,10 @@ fn get_chip_cfgs(chip_name: &str) -> Vec<String> { | |||
| 115 | cfgs.push("mspm0g351x".to_string()); | 116 | cfgs.push("mspm0g351x".to_string()); |
| 116 | } | 117 | } |
| 117 | 118 | ||
| 119 | if chip_name.starts_with("mspm0h321") { | ||
| 120 | cfgs.push("mspm0h321x".to_string()); | ||
| 121 | } | ||
| 122 | |||
| 118 | if chip_name.starts_with("mspm0l110") { | 123 | if chip_name.starts_with("mspm0l110") { |
| 119 | cfgs.push("mspm0l110x".to_string()); | 124 | cfgs.push("mspm0l110x".to_string()); |
| 120 | } | 125 | } |
| @@ -208,7 +213,7 @@ fn generate_groups() -> TokenStream { | |||
| 208 | 213 | ||
| 209 | #[cfg(feature = "rt")] | 214 | #[cfg(feature = "rt")] |
| 210 | mod group_vectors { | 215 | mod group_vectors { |
| 211 | extern "Rust" { | 216 | unsafe extern "Rust" { |
| 212 | #(#group_vectors)* | 217 | #(#group_vectors)* |
| 213 | } | 218 | } |
| 214 | } | 219 | } |
| @@ -646,6 +651,35 @@ fn generate_pin_trait_impls() -> TokenStream { | |||
| 646 | } | 651 | } |
| 647 | } | 652 | } |
| 648 | 653 | ||
| 654 | fn select_gpio_features(cfgs: &mut CfgSet) { | ||
| 655 | cfgs.declare_all(&[ | ||
| 656 | "gpioa_interrupt", | ||
| 657 | "gpioa_group", | ||
| 658 | "gpiob_interrupt", | ||
| 659 | "gpiob_group", | ||
| 660 | "gpioc_group", | ||
| 661 | ]); | ||
| 662 | |||
| 663 | for interrupt in METADATA.interrupts.iter() { | ||
| 664 | match interrupt.name { | ||
| 665 | "GPIOA" => cfgs.enable("gpioa_interrupt"), | ||
| 666 | "GPIOB" => cfgs.enable("gpiob_interrupt"), | ||
| 667 | _ => (), | ||
| 668 | } | ||
| 669 | } | ||
| 670 | |||
| 671 | for group in METADATA.interrupt_groups.iter() { | ||
| 672 | for interrupt in group.interrupts { | ||
| 673 | match interrupt.name { | ||
| 674 | "GPIOA" => cfgs.enable("gpioa_group"), | ||
| 675 | "GPIOB" => cfgs.enable("gpiob_group"), | ||
| 676 | "GPIOC" => cfgs.enable("gpioc_group"), | ||
| 677 | _ => (), | ||
| 678 | } | ||
| 679 | } | ||
| 680 | } | ||
| 681 | } | ||
| 682 | |||
| 649 | /// rustfmt a given path. | 683 | /// rustfmt a given path. |
| 650 | /// Failures are logged to stderr and ignored. | 684 | /// Failures are logged to stderr and ignored. |
| 651 | fn rustfmt(path: impl AsRef<Path>) { | 685 | fn rustfmt(path: impl AsRef<Path>) { |
diff --git a/embassy-mspm0/src/adc.rs b/embassy-mspm0/src/adc.rs index 5b93e9a6e..948801679 100644 --- a/embassy-mspm0/src/adc.rs +++ b/embassy-mspm0/src/adc.rs | |||
| @@ -4,13 +4,13 @@ use core::future::poll_fn; | |||
| 4 | use core::marker::PhantomData; | 4 | use core::marker::PhantomData; |
| 5 | use core::task::Poll; | 5 | use core::task::Poll; |
| 6 | 6 | ||
| 7 | use embassy_hal_internal::{impl_peripheral, PeripheralType}; | 7 | use embassy_hal_internal::{PeripheralType, impl_peripheral}; |
| 8 | use embassy_sync::waitqueue::AtomicWaker; | 8 | use embassy_sync::waitqueue::AtomicWaker; |
| 9 | 9 | ||
| 10 | use crate::interrupt::{Interrupt, InterruptExt}; | 10 | use crate::interrupt::{Interrupt, InterruptExt}; |
| 11 | use crate::mode::{Async, Blocking, Mode}; | 11 | use crate::mode::{Async, Blocking, Mode}; |
| 12 | use crate::pac::adc::{vals, Adc as Regs}; | 12 | use crate::pac::adc::{Adc as Regs, vals}; |
| 13 | use crate::{interrupt, Peri}; | 13 | use crate::{Peri, interrupt}; |
| 14 | 14 | ||
| 15 | /// Interrupt handler. | 15 | /// Interrupt handler. |
| 16 | pub struct InterruptHandler<T: Instance> { | 16 | pub struct InterruptHandler<T: Instance> { |
diff --git a/embassy-mspm0/src/dma.rs b/embassy-mspm0/src/dma.rs index 66b79709c..58b087761 100644 --- a/embassy-mspm0/src/dma.rs +++ b/embassy-mspm0/src/dma.rs | |||
| @@ -5,18 +5,18 @@ | |||
| 5 | use core::future::Future; | 5 | use core::future::Future; |
| 6 | use core::mem; | 6 | use core::mem; |
| 7 | use core::pin::Pin; | 7 | use core::pin::Pin; |
| 8 | use core::sync::atomic::{compiler_fence, Ordering}; | 8 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 9 | use core::task::{Context, Poll}; | 9 | use core::task::{Context, Poll}; |
| 10 | 10 | ||
| 11 | use critical_section::CriticalSection; | 11 | use critical_section::CriticalSection; |
| 12 | use embassy_hal_internal::interrupt::InterruptExt; | 12 | use embassy_hal_internal::interrupt::InterruptExt; |
| 13 | use embassy_hal_internal::{impl_peripheral, PeripheralType}; | 13 | use embassy_hal_internal::{PeripheralType, impl_peripheral}; |
| 14 | use embassy_sync::waitqueue::AtomicWaker; | 14 | use embassy_sync::waitqueue::AtomicWaker; |
| 15 | use mspm0_metapac::common::{Reg, RW}; | 15 | use mspm0_metapac::common::{RW, Reg}; |
| 16 | use mspm0_metapac::dma::regs; | 16 | use mspm0_metapac::dma::regs; |
| 17 | use mspm0_metapac::dma::vals::{self, Autoen, Em, Incr, Preirq, Wdth}; | 17 | use mspm0_metapac::dma::vals::{self, Autoen, Em, Incr, Preirq, Wdth}; |
| 18 | 18 | ||
| 19 | use crate::{interrupt, pac, Peri}; | 19 | use crate::{Peri, interrupt, pac}; |
| 20 | 20 | ||
| 21 | /// The burst size of a DMA transfer. | 21 | /// The burst size of a DMA transfer. |
| 22 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | 22 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
diff --git a/embassy-mspm0/src/gpio.rs b/embassy-mspm0/src/gpio.rs index d5fd36dbf..d8eb42dc2 100644 --- a/embassy-mspm0/src/gpio.rs +++ b/embassy-mspm0/src/gpio.rs | |||
| @@ -5,12 +5,12 @@ use core::future::Future; | |||
| 5 | use core::pin::Pin as FuturePin; | 5 | use core::pin::Pin as FuturePin; |
| 6 | use core::task::{Context, Poll}; | 6 | use core::task::{Context, Poll}; |
| 7 | 7 | ||
| 8 | use embassy_hal_internal::{impl_peripheral, Peri, PeripheralType}; | 8 | use embassy_hal_internal::{Peri, PeripheralType, impl_peripheral}; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 10 | 10 | ||
| 11 | use crate::pac::gpio::vals::*; | 11 | use crate::pac::gpio::vals::*; |
| 12 | use crate::pac::gpio::{self}; | 12 | use crate::pac::gpio::{self}; |
| 13 | #[cfg(all(feature = "rt", any(mspm0c110x, mspm0c1105_c1106, mspm0l110x)))] | 13 | #[cfg(all(feature = "rt", any(gpioa_interrupt, gpiob_interrupt)))] |
| 14 | use crate::pac::interrupt; | 14 | use crate::pac::interrupt; |
| 15 | use crate::pac::{self}; | 15 | use crate::pac::{self}; |
| 16 | 16 | ||
| @@ -156,7 +156,12 @@ impl<'d> Flex<'d> { | |||
| 156 | w.set_pf(GPIO_PF); | 156 | w.set_pf(GPIO_PF); |
| 157 | w.set_hiz1(true); | 157 | w.set_hiz1(true); |
| 158 | w.set_pc(true); | 158 | w.set_pc(true); |
| 159 | w.set_inena(false); | 159 | w.set_inena(true); |
| 160 | }); | ||
| 161 | |||
| 162 | // Enable output driver (DOE) - required for open-drain to drive low | ||
| 163 | self.pin.block().doeset31_0().write(|w| { | ||
| 164 | w.set_dio(self.pin.bit_index(), true); | ||
| 160 | }); | 165 | }); |
| 161 | 166 | ||
| 162 | self.set_pull(Pull::None); | 167 | self.set_pull(Pull::None); |
| @@ -1105,16 +1110,21 @@ fn irq_handler(gpio: gpio::Gpio, wakers: &[AtomicWaker; 32]) { | |||
| 1105 | } | 1110 | } |
| 1106 | } | 1111 | } |
| 1107 | 1112 | ||
| 1113 | #[cfg(all(gpioa_interrupt, gpioa_group))] | ||
| 1114 | compile_error!("gpioa_interrupt and gpioa_group are mutually exclusive cfgs"); | ||
| 1115 | #[cfg(all(gpiob_interrupt, gpiob_group))] | ||
| 1116 | compile_error!("gpiob_interrupt and gpiob_group are mutually exclusive cfgs"); | ||
| 1117 | |||
| 1108 | // C110x and L110x have a dedicated interrupts just for GPIOA. | 1118 | // C110x and L110x have a dedicated interrupts just for GPIOA. |
| 1109 | // | 1119 | // |
| 1110 | // These chips do not have a GROUP1 interrupt. | 1120 | // These chips do not have a GROUP1 interrupt. |
| 1111 | #[cfg(all(feature = "rt", any(mspm0c110x, mspm0c1105_c1106, mspm0l110x)))] | 1121 | #[cfg(all(feature = "rt", gpioa_interrupt))] |
| 1112 | #[interrupt] | 1122 | #[interrupt] |
| 1113 | fn GPIOA() { | 1123 | fn GPIOA() { |
| 1114 | irq_handler(pac::GPIOA, &PORTA_WAKERS); | 1124 | irq_handler(pac::GPIOA, &PORTA_WAKERS); |
| 1115 | } | 1125 | } |
| 1116 | 1126 | ||
| 1117 | #[cfg(all(feature = "rt", mspm0c1105_c1106))] | 1127 | #[cfg(all(feature = "rt", gpiob_interrupt))] |
| 1118 | #[interrupt] | 1128 | #[interrupt] |
| 1119 | fn GPIOB() { | 1129 | fn GPIOB() { |
| 1120 | irq_handler(pac::GPIOB, &PORTB_WAKERS); | 1130 | irq_handler(pac::GPIOB, &PORTB_WAKERS); |
| @@ -1124,23 +1134,23 @@ fn GPIOB() { | |||
| 1124 | // | 1134 | // |
| 1125 | // Defining these as no_mangle is required so that the linker will pick these over the default handler. | 1135 | // Defining these as no_mangle is required so that the linker will pick these over the default handler. |
| 1126 | 1136 | ||
| 1127 | #[cfg(all(feature = "rt", not(any(mspm0c110x, mspm0c1105_c1106, mspm0l110x))))] | 1137 | #[cfg(all(feature = "rt", gpioa_group))] |
| 1128 | #[no_mangle] | 1138 | #[unsafe(no_mangle)] |
| 1129 | #[allow(non_snake_case)] | 1139 | #[allow(non_snake_case)] |
| 1130 | fn GPIOA() { | 1140 | fn GPIOA() { |
| 1131 | irq_handler(pac::GPIOA, &PORTA_WAKERS); | 1141 | irq_handler(pac::GPIOA, &PORTA_WAKERS); |
| 1132 | } | 1142 | } |
| 1133 | 1143 | ||
| 1134 | #[cfg(all(feature = "rt", gpio_pb, not(mspm0c1105_c1106)))] | 1144 | #[cfg(all(feature = "rt", gpiob_group))] |
| 1135 | #[no_mangle] | 1145 | #[unsafe(no_mangle)] |
| 1136 | #[allow(non_snake_case)] | 1146 | #[allow(non_snake_case)] |
| 1137 | fn GPIOB() { | 1147 | fn GPIOB() { |
| 1138 | irq_handler(pac::GPIOB, &PORTB_WAKERS); | 1148 | irq_handler(pac::GPIOB, &PORTB_WAKERS); |
| 1139 | } | 1149 | } |
| 1140 | 1150 | ||
| 1141 | #[cfg(all(feature = "rt", gpio_pc))] | 1151 | #[cfg(all(feature = "rt", gpioc_group))] |
| 1142 | #[allow(non_snake_case)] | 1152 | #[allow(non_snake_case)] |
| 1143 | #[no_mangle] | 1153 | #[unsafe(no_mangle)] |
| 1144 | fn GPIOC() { | 1154 | fn GPIOC() { |
| 1145 | irq_handler(pac::GPIOC, &PORTC_WAKERS); | 1155 | irq_handler(pac::GPIOC, &PORTC_WAKERS); |
| 1146 | } | 1156 | } |
diff --git a/embassy-mspm0/src/i2c.rs b/embassy-mspm0/src/i2c.rs index 1906e37ba..192527dd2 100644 --- a/embassy-mspm0/src/i2c.rs +++ b/embassy-mspm0/src/i2c.rs | |||
| @@ -10,13 +10,13 @@ use embassy_hal_internal::PeripheralType; | |||
| 10 | use embassy_sync::waitqueue::AtomicWaker; | 10 | use embassy_sync::waitqueue::AtomicWaker; |
| 11 | use mspm0_metapac::i2c; | 11 | use mspm0_metapac::i2c; |
| 12 | 12 | ||
| 13 | use crate::Peri; | ||
| 13 | use crate::gpio::{AnyPin, PfType, Pull, SealedPin}; | 14 | use crate::gpio::{AnyPin, PfType, Pull, SealedPin}; |
| 14 | use crate::interrupt::typelevel::Binding; | 15 | use crate::interrupt::typelevel::Binding; |
| 15 | use crate::interrupt::{Interrupt, InterruptExt}; | 16 | use crate::interrupt::{Interrupt, InterruptExt}; |
| 16 | use crate::mode::{Async, Blocking, Mode}; | 17 | use crate::mode::{Async, Blocking, Mode}; |
| 17 | use crate::pac::i2c::{vals, I2c as Regs}; | 18 | use crate::pac::i2c::{I2c as Regs, vals}; |
| 18 | use crate::pac::{self}; | 19 | use crate::pac::{self}; |
| 19 | use crate::Peri; | ||
| 20 | 20 | ||
| 21 | /// The clock source for the I2C. | 21 | /// The clock source for the I2C. |
| 22 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] | 22 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
| @@ -206,8 +206,8 @@ impl Config { | |||
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | #[cfg(any( | 208 | #[cfg(any( |
| 209 | mspm0g110x, mspm0g150x, mspm0g151x, mspm0g310x, mspm0g350x, mspm0g351x, mspm0l110x, mspm0l122x, mspm0l130x, | 209 | mspm0g110x, mspm0g150x, mspm0g151x, mspm0g310x, mspm0g350x, mspm0g351x, mspm0h321x, mspm0l110x, mspm0l122x, |
| 210 | mspm0l134x, mspm0l222x | 210 | mspm0l130x, mspm0l134x, mspm0l222x |
| 211 | ))] | 211 | ))] |
| 212 | fn calculate_clock_source(&self) -> u32 { | 212 | fn calculate_clock_source(&self) -> u32 { |
| 213 | // Assume that BusClk has default value. | 213 | // Assume that BusClk has default value. |
diff --git a/embassy-mspm0/src/lib.rs b/embassy-mspm0/src/lib.rs index 13f0ce662..55f3f9381 100644 --- a/embassy-mspm0/src/lib.rs +++ b/embassy-mspm0/src/lib.rs | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 2 | // Doc feature labels can be tested locally by running RUSTDOCFLAGS="--cfg=docsrs" cargo +nightly doc | 3 | // Doc feature labels can be tested locally by running RUSTDOCFLAGS="--cfg=docsrs" cargo +nightly doc |
| 3 | #![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg_hide), doc(cfg_hide(doc, docsrs)))] | 4 | #![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg_hide), doc(cfg_hide(doc, docsrs)))] |
| 4 | #![cfg_attr( | 5 | #![cfg_attr( |
| @@ -54,7 +55,7 @@ pub(crate) mod _generated { | |||
| 54 | 55 | ||
| 55 | // Reexports | 56 | // Reexports |
| 56 | pub(crate) use _generated::gpio_pincm; | 57 | pub(crate) use _generated::gpio_pincm; |
| 57 | pub use _generated::{peripherals, Peripherals}; | 58 | pub use _generated::{Peripherals, peripherals}; |
| 58 | pub use embassy_hal_internal::Peri; | 59 | pub use embassy_hal_internal::Peri; |
| 59 | #[cfg(feature = "unstable-pac")] | 60 | #[cfg(feature = "unstable-pac")] |
| 60 | pub use mspm0_metapac as pac; | 61 | pub use mspm0_metapac as pac; |
| @@ -111,7 +112,7 @@ macro_rules! bind_interrupts { | |||
| 111 | 112 | ||
| 112 | $( | 113 | $( |
| 113 | #[allow(non_snake_case)] | 114 | #[allow(non_snake_case)] |
| 114 | #[no_mangle] | 115 | #[unsafe(no_mangle)] |
| 115 | $(#[cfg($cond_irq)])? | 116 | $(#[cfg($cond_irq)])? |
| 116 | unsafe extern "C" fn $irq() { | 117 | unsafe extern "C" fn $irq() { |
| 117 | unsafe { | 118 | unsafe { |
diff --git a/embassy-mspm0/src/time_driver.rs b/embassy-mspm0/src/time_driver.rs index e80e89e55..0743c667b 100644 --- a/embassy-mspm0/src/time_driver.rs +++ b/embassy-mspm0/src/time_driver.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | use core::cell::{Cell, RefCell}; | 1 | use core::cell::{Cell, RefCell}; |
| 2 | use core::sync::atomic::{compiler_fence, AtomicU32, Ordering}; | 2 | use core::sync::atomic::{AtomicU32, Ordering, compiler_fence}; |
| 3 | use core::task::Waker; | 3 | use core::task::Waker; |
| 4 | 4 | ||
| 5 | use critical_section::{CriticalSection, Mutex}; | 5 | use critical_section::{CriticalSection, Mutex}; |
diff --git a/embassy-mspm0/src/uart/buffered.rs b/embassy-mspm0/src/uart/buffered.rs index cbc0b6c80..89e6bcc7b 100644 --- a/embassy-mspm0/src/uart/buffered.rs +++ b/embassy-mspm0/src/uart/buffered.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use core::future::{poll_fn, Future}; | 1 | use core::future::{Future, poll_fn}; |
| 2 | use core::marker::PhantomData; | 2 | use core::marker::PhantomData; |
| 3 | use core::slice; | 3 | use core::slice; |
| 4 | use core::sync::atomic::{AtomicU8, Ordering}; | 4 | use core::sync::atomic::{AtomicU8, Ordering}; |
| @@ -14,7 +14,7 @@ use crate::gpio::{AnyPin, SealedPin}; | |||
| 14 | use crate::interrupt::typelevel::Binding; | 14 | use crate::interrupt::typelevel::Binding; |
| 15 | use crate::pac::uart::Uart as Regs; | 15 | use crate::pac::uart::Uart as Regs; |
| 16 | use crate::uart::{Config, ConfigError, CtsPin, Error, Info, Instance, RtsPin, RxPin, State, TxPin}; | 16 | use crate::uart::{Config, ConfigError, CtsPin, Error, Info, Instance, RtsPin, RxPin, State, TxPin}; |
| 17 | use crate::{interrupt, Peri}; | 17 | use crate::{Peri, interrupt}; |
| 18 | 18 | ||
| 19 | /// Interrupt handler. | 19 | /// Interrupt handler. |
| 20 | pub struct BufferedInterruptHandler<T: Instance> { | 20 | pub struct BufferedInterruptHandler<T: Instance> { |
diff --git a/embassy-mspm0/src/uart/mod.rs b/embassy-mspm0/src/uart/mod.rs index 6599cea06..03e68d297 100644 --- a/embassy-mspm0/src/uart/mod.rs +++ b/embassy-mspm0/src/uart/mod.rs | |||
| @@ -3,17 +3,17 @@ | |||
| 3 | mod buffered; | 3 | mod buffered; |
| 4 | 4 | ||
| 5 | use core::marker::PhantomData; | 5 | use core::marker::PhantomData; |
| 6 | use core::sync::atomic::{compiler_fence, AtomicU32, Ordering}; | 6 | use core::sync::atomic::{AtomicU32, Ordering, compiler_fence}; |
| 7 | 7 | ||
| 8 | pub use buffered::*; | 8 | pub use buffered::*; |
| 9 | use embassy_embedded_hal::SetConfig; | 9 | use embassy_embedded_hal::SetConfig; |
| 10 | use embassy_hal_internal::PeripheralType; | 10 | use embassy_hal_internal::PeripheralType; |
| 11 | 11 | ||
| 12 | use crate::Peri; | ||
| 12 | use crate::gpio::{AnyPin, PfType, Pull, SealedPin}; | 13 | use crate::gpio::{AnyPin, PfType, Pull, SealedPin}; |
| 13 | use crate::interrupt::{Interrupt, InterruptExt}; | 14 | use crate::interrupt::{Interrupt, InterruptExt}; |
| 14 | use crate::mode::{Blocking, Mode}; | 15 | use crate::mode::{Blocking, Mode}; |
| 15 | use crate::pac::uart::{vals, Uart as Regs}; | 16 | use crate::pac::uart::{Uart as Regs, vals}; |
| 16 | use crate::Peri; | ||
| 17 | 17 | ||
| 18 | /// The clock source for the UART. | 18 | /// The clock source for the UART. |
| 19 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] | 19 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
| @@ -931,8 +931,7 @@ fn set_baudrate_inner(regs: Regs, clock: u32, baudrate: u32) -> Result<(), Confi | |||
| 931 | let Some(min_clock) = baudrate.checked_mul(oversampling as u32) else { | 931 | let Some(min_clock) = baudrate.checked_mul(oversampling as u32) else { |
| 932 | trace!( | 932 | trace!( |
| 933 | "{}x oversampling would cause overflow for clock: {} Hz", | 933 | "{}x oversampling would cause overflow for clock: {} Hz", |
| 934 | oversampling, | 934 | oversampling, clock |
| 935 | clock | ||
| 936 | ); | 935 | ); |
| 937 | continue; | 936 | continue; |
| 938 | }; | 937 | }; |
| @@ -945,9 +944,7 @@ fn set_baudrate_inner(regs: Regs, clock: u32, baudrate: u32) -> Result<(), Confi | |||
| 945 | for &(div, div_value) in &DIVS { | 944 | for &(div, div_value) in &DIVS { |
| 946 | trace!( | 945 | trace!( |
| 947 | "Trying div: {}, oversampling {} for {} baud", | 946 | "Trying div: {}, oversampling {} for {} baud", |
| 948 | div, | 947 | div, oversampling, baudrate |
| 949 | oversampling, | ||
| 950 | baudrate | ||
| 951 | ); | 948 | ); |
| 952 | 949 | ||
| 953 | let Some((ibrd, fbrd)) = calculate_brd(clock, div, baudrate, oversampling) else { | 950 | let Some((ibrd, fbrd)) = calculate_brd(clock, div, baudrate, oversampling) else { |
diff --git a/embassy-mspm0/src/wwdt.rs b/embassy-mspm0/src/wwdt.rs index e5c62c660..92aeb8b40 100644 --- a/embassy-mspm0/src/wwdt.rs +++ b/embassy-mspm0/src/wwdt.rs | |||
| @@ -6,9 +6,9 @@ | |||
| 6 | 6 | ||
| 7 | use embassy_hal_internal::PeripheralType; | 7 | use embassy_hal_internal::PeripheralType; |
| 8 | 8 | ||
| 9 | use crate::pac::wwdt::{vals, Wwdt as Regs}; | ||
| 10 | use crate::pac::{self}; | ||
| 11 | use crate::Peri; | 9 | use crate::Peri; |
| 10 | use crate::pac::wwdt::{Wwdt as Regs, vals}; | ||
| 11 | use crate::pac::{self}; | ||
| 12 | 12 | ||
| 13 | /// Possible watchdog timeout values. | 13 | /// Possible watchdog timeout values. |
| 14 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] | 14 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
diff --git a/embassy-net-adin1110/Cargo.toml b/embassy-net-adin1110/Cargo.toml index 587c69eb7..a5655870f 100644 --- a/embassy-net-adin1110/Cargo.toml +++ b/embassy-net-adin1110/Cargo.toml | |||
| @@ -5,7 +5,7 @@ description = "embassy-net driver for the ADIN1110 ethernet chip" | |||
| 5 | keywords = ["embedded", "ADIN1110", "embassy-net", "embedded-hal-async", "ethernet"] | 5 | keywords = ["embedded", "ADIN1110", "embassy-net", "embedded-hal-async", "ethernet"] |
| 6 | categories = ["embedded", "hardware-support", "no-std", "network-programming", "asynchronous"] | 6 | categories = ["embedded", "hardware-support", "no-std", "network-programming", "asynchronous"] |
| 7 | license = "MIT OR Apache-2.0" | 7 | license = "MIT OR Apache-2.0" |
| 8 | edition = "2021" | 8 | edition = "2024" |
| 9 | repository = "https://github.com/embassy-rs/embassy" | 9 | repository = "https://github.com/embassy-rs/embassy" |
| 10 | documentation = "https://docs.embassy.dev/embassy-net-adin1110" | 10 | documentation = "https://docs.embassy.dev/embassy-net-adin1110" |
| 11 | 11 | ||
diff --git a/embassy-net-adin1110/src/crc8.rs b/embassy-net-adin1110/src/crc8.rs index 321983e64..a51353aab 100644 --- a/embassy-net-adin1110/src/crc8.rs +++ b/embassy-net-adin1110/src/crc8.rs | |||
| @@ -23,7 +23,7 @@ pub fn crc8(data: &[u8]) -> u8 { | |||
| 23 | 23 | ||
| 24 | #[cfg(test)] | 24 | #[cfg(test)] |
| 25 | mod tests { | 25 | mod tests { |
| 26 | use ::crc::{Crc, CRC_8_SMBUS}; | 26 | use ::crc::{CRC_8_SMBUS, Crc}; |
| 27 | 27 | ||
| 28 | use super::crc8; | 28 | use super::crc8; |
| 29 | 29 | ||
diff --git a/embassy-net-adin1110/src/lib.rs b/embassy-net-adin1110/src/lib.rs index 7f1c772e2..90ac242bd 100644 --- a/embassy-net-adin1110/src/lib.rs +++ b/embassy-net-adin1110/src/lib.rs | |||
| @@ -17,9 +17,9 @@ mod phy; | |||
| 17 | mod regs; | 17 | mod regs; |
| 18 | 18 | ||
| 19 | use ch::driver::LinkState; | 19 | use ch::driver::LinkState; |
| 20 | pub use crc32::ETH_FCS; | ||
| 21 | use crc8::crc8; | 20 | use crc8::crc8; |
| 22 | use embassy_futures::select::{select, Either}; | 21 | pub use crc32::ETH_FCS; |
| 22 | use embassy_futures::select::{Either, select}; | ||
| 23 | use embassy_net_driver_channel as ch; | 23 | use embassy_net_driver_channel as ch; |
| 24 | use embassy_time::Timer; | 24 | use embassy_time::Timer; |
| 25 | use embedded_hal_1::digital::OutputPin; | 25 | use embedded_hal_1::digital::OutputPin; |
diff --git a/embassy-net-driver-channel/Cargo.toml b/embassy-net-driver-channel/Cargo.toml index 1e40c2d87..116057d6e 100644 --- a/embassy-net-driver-channel/Cargo.toml +++ b/embassy-net-driver-channel/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-net-driver-channel" | 2 | name = "embassy-net-driver-channel" |
| 3 | version = "0.3.2" | 3 | version = "0.3.2" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | description = "High-level channel-based driver for the `embassy-net` async TCP/IP network stack." | 6 | description = "High-level channel-based driver for the `embassy-net` async TCP/IP network stack." |
| 7 | repository = "https://github.com/embassy-rs/embassy" | 7 | repository = "https://github.com/embassy-rs/embassy" |
diff --git a/embassy-net-driver-channel/src/lib.rs b/embassy-net-driver-channel/src/lib.rs index 600efd9e5..d0a14aa52 100644 --- a/embassy-net-driver-channel/src/lib.rs +++ b/embassy-net-driver-channel/src/lib.rs | |||
| @@ -11,8 +11,8 @@ use core::task::{Context, Poll}; | |||
| 11 | 11 | ||
| 12 | pub use embassy_net_driver as driver; | 12 | pub use embassy_net_driver as driver; |
| 13 | use embassy_net_driver::{Capabilities, LinkState}; | 13 | use embassy_net_driver::{Capabilities, LinkState}; |
| 14 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | ||
| 15 | use embassy_sync::blocking_mutex::Mutex; | 14 | use embassy_sync::blocking_mutex::Mutex; |
| 15 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | ||
| 16 | use embassy_sync::waitqueue::WakerRegistration; | 16 | use embassy_sync::waitqueue::WakerRegistration; |
| 17 | use embassy_sync::zerocopy_channel; | 17 | use embassy_sync::zerocopy_channel; |
| 18 | 18 | ||
diff --git a/embassy-net-driver/Cargo.toml b/embassy-net-driver/Cargo.toml index a36e412ad..948fb2667 100644 --- a/embassy-net-driver/Cargo.toml +++ b/embassy-net-driver/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-net-driver" | 2 | name = "embassy-net-driver" |
| 3 | version = "0.2.0" | 3 | version = "0.2.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | description = "Driver trait for the `embassy-net` async TCP/IP network stack." | 6 | description = "Driver trait for the `embassy-net` async TCP/IP network stack." |
| 7 | repository = "https://github.com/embassy-rs/embassy" | 7 | repository = "https://github.com/embassy-rs/embassy" |
diff --git a/embassy-net-driver/src/lib.rs b/embassy-net-driver/src/lib.rs index 4c847718d..47babe34a 100644 --- a/embassy-net-driver/src/lib.rs +++ b/embassy-net-driver/src/lib.rs | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 2 | #![warn(missing_docs)] | 3 | #![warn(missing_docs)] |
| 3 | #![doc = include_str!("../README.md")] | 4 | #![doc = include_str!("../README.md")] |
| 4 | 5 | ||
diff --git a/embassy-net-enc28j60/Cargo.toml b/embassy-net-enc28j60/Cargo.toml index e7bad118b..7c3e05922 100644 --- a/embassy-net-enc28j60/Cargo.toml +++ b/embassy-net-enc28j60/Cargo.toml | |||
| @@ -5,7 +5,7 @@ description = "embassy-net driver for the ENC28J60 ethernet chip" | |||
| 5 | keywords = ["embedded", "enc28j60", "embassy-net", "embedded-hal-async", "ethernet"] | 5 | keywords = ["embedded", "enc28j60", "embassy-net", "embedded-hal-async", "ethernet"] |
| 6 | categories = ["embedded", "hardware-support", "no-std", "network-programming", "asynchronous"] | 6 | categories = ["embedded", "hardware-support", "no-std", "network-programming", "asynchronous"] |
| 7 | license = "MIT OR Apache-2.0" | 7 | license = "MIT OR Apache-2.0" |
| 8 | edition = "2021" | 8 | edition = "2024" |
| 9 | repository = "https://github.com/embassy-rs/embassy" | 9 | repository = "https://github.com/embassy-rs/embassy" |
| 10 | documentation = "https://docs.embassy.dev/embassy-net-enc28j60" | 10 | documentation = "https://docs.embassy.dev/embassy-net-enc28j60" |
| 11 | 11 | ||
diff --git a/embassy-net-esp-hosted/Cargo.toml b/embassy-net-esp-hosted/Cargo.toml index 149ff2bb2..f148f4762 100644 --- a/embassy-net-esp-hosted/Cargo.toml +++ b/embassy-net-esp-hosted/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-net-esp-hosted" | 2 | name = "embassy-net-esp-hosted" |
| 3 | version = "0.2.1" | 3 | version = "0.2.1" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | description = "embassy-net driver for ESP-Hosted" | 5 | description = "embassy-net driver for ESP-Hosted" |
| 6 | keywords = ["embedded", "esp-hosted", "embassy-net", "embedded-hal-async", "wifi"] | 6 | keywords = ["embedded", "esp-hosted", "embassy-net", "embedded-hal-async", "wifi"] |
| 7 | categories = ["embedded", "hardware-support", "no-std", "network-programming", "asynchronous"] | 7 | categories = ["embedded", "hardware-support", "no-std", "network-programming", "asynchronous"] |
diff --git a/embassy-net-esp-hosted/src/control.rs b/embassy-net-esp-hosted/src/control.rs index b1838a425..cbc194877 100644 --- a/embassy-net-esp-hosted/src/control.rs +++ b/embassy-net-esp-hosted/src/control.rs | |||
| @@ -65,8 +65,7 @@ macro_rules! ioctl { | |||
| 65 | }; | 65 | }; |
| 66 | $self.ioctl(&mut msg).await?; | 66 | $self.ioctl(&mut msg).await?; |
| 67 | #[allow(unused_mut)] | 67 | #[allow(unused_mut)] |
| 68 | let Some(proto::CtrlMsgPayload::$resp_variant(mut $resp)) = msg.payload | 68 | let Some(proto::CtrlMsgPayload::$resp_variant(mut $resp)) = msg.payload else { |
| 69 | else { | ||
| 70 | warn!("unexpected response variant"); | 69 | warn!("unexpected response variant"); |
| 71 | return Err(Error::Internal); | 70 | return Err(Error::Internal); |
| 72 | }; | 71 | }; |
diff --git a/embassy-net-esp-hosted/src/ioctl.rs b/embassy-net-esp-hosted/src/ioctl.rs index 512023206..a516f80c7 100644 --- a/embassy-net-esp-hosted/src/ioctl.rs +++ b/embassy-net-esp-hosted/src/ioctl.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | use core::cell::RefCell; | 1 | use core::cell::RefCell; |
| 2 | use core::future::{poll_fn, Future}; | 2 | use core::future::{Future, poll_fn}; |
| 3 | use core::task::Poll; | 3 | use core::task::Poll; |
| 4 | 4 | ||
| 5 | use embassy_sync::waitqueue::WakerRegistration; | 5 | use embassy_sync::waitqueue::WakerRegistration; |
diff --git a/embassy-net-esp-hosted/src/lib.rs b/embassy-net-esp-hosted/src/lib.rs index f05e2a70a..4405d9f77 100644 --- a/embassy-net-esp-hosted/src/lib.rs +++ b/embassy-net-esp-hosted/src/lib.rs | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | #![doc = include_str!("../README.md")] | 2 | #![doc = include_str!("../README.md")] |
| 3 | #![warn(missing_docs)] | 3 | #![warn(missing_docs)] |
| 4 | 4 | ||
| 5 | use embassy_futures::select::{select4, Either4}; | 5 | use embassy_futures::select::{Either4, select4}; |
| 6 | use embassy_net_driver_channel as ch; | 6 | use embassy_net_driver_channel as ch; |
| 7 | use embassy_net_driver_channel::driver::LinkState; | 7 | use embassy_net_driver_channel::driver::LinkState; |
| 8 | use embassy_time::{Duration, Instant, Timer}; | 8 | use embassy_time::{Duration, Instant, Timer}; |
diff --git a/embassy-net-nrf91/Cargo.toml b/embassy-net-nrf91/Cargo.toml index 35fbef3f6..ecb10246a 100644 --- a/embassy-net-nrf91/Cargo.toml +++ b/embassy-net-nrf91/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-net-nrf91" | 2 | name = "embassy-net-nrf91" |
| 3 | version = "0.1.1" | 3 | version = "0.1.1" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | description = "embassy-net driver for Nordic nRF91-series cellular modems" | 5 | description = "embassy-net driver for Nordic nRF91-series cellular modems" |
| 6 | keywords = ["embedded", "nrf91", "embassy-net", "cellular"] | 6 | keywords = ["embedded", "nrf91", "embassy-net", "cellular"] |
| 7 | categories = ["embedded", "hardware-support", "no-std", "network-programming", "asynchronous"] | 7 | categories = ["embedded", "hardware-support", "no-std", "network-programming", "asynchronous"] |
diff --git a/embassy-net-nrf91/src/lib.rs b/embassy-net-nrf91/src/lib.rs index 0bd9be0d9..dd4812aae 100644 --- a/embassy-net-nrf91/src/lib.rs +++ b/embassy-net-nrf91/src/lib.rs | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 2 | #![doc = include_str!("../README.md")] | 3 | #![doc = include_str!("../README.md")] |
| 3 | #![warn(missing_docs)] | 4 | #![warn(missing_docs)] |
| 4 | #![deny(unused_must_use)] | 5 | #![deny(unused_must_use)] |
| @@ -9,12 +10,12 @@ mod fmt; | |||
| 9 | pub mod context; | 10 | pub mod context; |
| 10 | 11 | ||
| 11 | use core::cell::RefCell; | 12 | use core::cell::RefCell; |
| 12 | use core::future::{poll_fn, Future}; | 13 | use core::future::{Future, poll_fn}; |
| 13 | use core::marker::PhantomData; | 14 | use core::marker::PhantomData; |
| 14 | use core::mem::{self, MaybeUninit}; | 15 | use core::mem::{self, MaybeUninit}; |
| 15 | use core::ptr::{self, addr_of, addr_of_mut, copy_nonoverlapping}; | 16 | use core::ptr::{self, addr_of, addr_of_mut, copy_nonoverlapping}; |
| 16 | use core::slice; | 17 | use core::slice; |
| 17 | use core::sync::atomic::{compiler_fence, fence, Ordering}; | 18 | use core::sync::atomic::{Ordering, compiler_fence, fence}; |
| 18 | use core::task::{Poll, Waker}; | 19 | use core::task::{Poll, Waker}; |
| 19 | 20 | ||
| 20 | use cortex_m::peripheral::NVIC; | 21 | use cortex_m::peripheral::NVIC; |
| @@ -139,9 +140,7 @@ async fn new_internal<'a>( | |||
| 139 | debug!("Setting IPC RAM as nonsecure..."); | 140 | debug!("Setting IPC RAM as nonsecure..."); |
| 140 | trace!( | 141 | trace!( |
| 141 | " SPU_REGION_SIZE={}, shmem_ptr=0x{:08X}, shmem_len={}", | 142 | " SPU_REGION_SIZE={}, shmem_ptr=0x{:08X}, shmem_len={}", |
| 142 | SPU_REGION_SIZE, | 143 | SPU_REGION_SIZE, shmem_ptr as usize, shmem_len |
| 143 | shmem_ptr as usize, | ||
| 144 | shmem_len | ||
| 145 | ); | 144 | ); |
| 146 | let region_start = (shmem_ptr as usize - 0x2000_0000) / SPU_REGION_SIZE; | 145 | let region_start = (shmem_ptr as usize - 0x2000_0000) / SPU_REGION_SIZE; |
| 147 | let region_end = region_start + shmem_len / SPU_REGION_SIZE; | 146 | let region_end = region_start + shmem_len / SPU_REGION_SIZE; |
| @@ -165,8 +164,7 @@ async fn new_internal<'a>( | |||
| 165 | }; | 164 | }; |
| 166 | trace!( | 165 | trace!( |
| 167 | " Allocator: start=0x{:08X}, end=0x{:08X}", | 166 | " Allocator: start=0x{:08X}, end=0x{:08X}", |
| 168 | alloc.start as usize, | 167 | alloc.start as usize, alloc.end as usize |
| 169 | alloc.end as usize | ||
| 170 | ); | 168 | ); |
| 171 | 169 | ||
| 172 | let cb: &mut ControlBlock = alloc.alloc().write(unsafe { mem::zeroed() }); | 170 | let cb: &mut ControlBlock = alloc.alloc().write(unsafe { mem::zeroed() }); |
diff --git a/embassy-net-ppp/Cargo.toml b/embassy-net-ppp/Cargo.toml index 644f5b827..45ee2f6b5 100644 --- a/embassy-net-ppp/Cargo.toml +++ b/embassy-net-ppp/Cargo.toml | |||
| @@ -5,7 +5,7 @@ description = "embassy-net driver for PPP over Serial" | |||
| 5 | keywords = ["embedded", "ppp", "embassy-net", "embedded-hal-async", "async"] | 5 | keywords = ["embedded", "ppp", "embassy-net", "embedded-hal-async", "async"] |
| 6 | categories = ["embedded", "hardware-support", "no-std", "network-programming", "asynchronous"] | 6 | categories = ["embedded", "hardware-support", "no-std", "network-programming", "asynchronous"] |
| 7 | license = "MIT OR Apache-2.0" | 7 | license = "MIT OR Apache-2.0" |
| 8 | edition = "2021" | 8 | edition = "2024" |
| 9 | repository = "https://github.com/embassy-rs/embassy" | 9 | repository = "https://github.com/embassy-rs/embassy" |
| 10 | documentation = "https://docs.embassy.dev/embassy-net-ppp" | 10 | documentation = "https://docs.embassy.dev/embassy-net-ppp" |
| 11 | 11 | ||
diff --git a/embassy-net-ppp/src/lib.rs b/embassy-net-ppp/src/lib.rs index 54a98c95f..ab42ecd26 100644 --- a/embassy-net-ppp/src/lib.rs +++ b/embassy-net-ppp/src/lib.rs | |||
| @@ -8,7 +8,7 @@ mod fmt; | |||
| 8 | use core::convert::Infallible; | 8 | use core::convert::Infallible; |
| 9 | use core::mem::MaybeUninit; | 9 | use core::mem::MaybeUninit; |
| 10 | 10 | ||
| 11 | use embassy_futures::select::{select, Either}; | 11 | use embassy_futures::select::{Either, select}; |
| 12 | use embassy_net_driver_channel as ch; | 12 | use embassy_net_driver_channel as ch; |
| 13 | use embassy_net_driver_channel::driver::LinkState; | 13 | use embassy_net_driver_channel::driver::LinkState; |
| 14 | use embedded_io_async::{BufRead, Write}; | 14 | use embedded_io_async::{BufRead, Write}; |
diff --git a/embassy-net-tuntap/Cargo.toml b/embassy-net-tuntap/Cargo.toml index 2cd0c0f7e..77668b445 100644 --- a/embassy-net-tuntap/Cargo.toml +++ b/embassy-net-tuntap/Cargo.toml | |||
| @@ -5,7 +5,7 @@ description = "embassy-net driver for Linux TUN/TAP interfaces." | |||
| 5 | keywords = ["embedded", "tuntap", "embassy-net", "ethernet", "async"] | 5 | keywords = ["embedded", "tuntap", "embassy-net", "ethernet", "async"] |
| 6 | categories = ["embedded", "hardware-support", "network-programming", "asynchronous"] | 6 | categories = ["embedded", "hardware-support", "network-programming", "asynchronous"] |
| 7 | license = "MIT OR Apache-2.0" | 7 | license = "MIT OR Apache-2.0" |
| 8 | edition = "2021" | 8 | edition = "2024" |
| 9 | repository = "https://github.com/embassy-rs/embassy" | 9 | repository = "https://github.com/embassy-rs/embassy" |
| 10 | documentation = "https://docs.embassy.dev/embassy-net-tuntap" | 10 | documentation = "https://docs.embassy.dev/embassy-net-tuntap" |
| 11 | 11 | ||
diff --git a/embassy-net-wiznet/Cargo.toml b/embassy-net-wiznet/Cargo.toml index 6e6dccebd..069f46fc3 100644 --- a/embassy-net-wiznet/Cargo.toml +++ b/embassy-net-wiznet/Cargo.toml | |||
| @@ -5,7 +5,7 @@ description = "embassy-net driver for WIZnet SPI Ethernet chips" | |||
| 5 | keywords = ["embedded", "embassy-net", "embedded-hal-async", "ethernet", "async"] | 5 | keywords = ["embedded", "embassy-net", "embedded-hal-async", "ethernet", "async"] |
| 6 | categories = ["embedded", "hardware-support", "no-std", "network-programming", "asynchronous"] | 6 | categories = ["embedded", "hardware-support", "no-std", "network-programming", "asynchronous"] |
| 7 | license = "MIT OR Apache-2.0" | 7 | license = "MIT OR Apache-2.0" |
| 8 | edition = "2021" | 8 | edition = "2024" |
| 9 | repository = "https://github.com/embassy-rs/embassy" | 9 | repository = "https://github.com/embassy-rs/embassy" |
| 10 | documentation = "https://docs.embassy.dev/embassy-net-wiznet" | 10 | documentation = "https://docs.embassy.dev/embassy-net-wiznet" |
| 11 | 11 | ||
diff --git a/embassy-net-wiznet/src/chip/mod.rs b/embassy-net-wiznet/src/chip/mod.rs index 47d7c5dc3..04346bb21 100644 --- a/embassy-net-wiznet/src/chip/mod.rs +++ b/embassy-net-wiznet/src/chip/mod.rs | |||
| @@ -43,7 +43,7 @@ pub(crate) trait SealedChip { | |||
| 43 | fn tx_addr(addr: u16) -> Self::Address; | 43 | fn tx_addr(addr: u16) -> Self::Address; |
| 44 | 44 | ||
| 45 | async fn bus_read<SPI: SpiDevice>(spi: &mut SPI, address: Self::Address, data: &mut [u8]) | 45 | async fn bus_read<SPI: SpiDevice>(spi: &mut SPI, address: Self::Address, data: &mut [u8]) |
| 46 | -> Result<(), SPI::Error>; | 46 | -> Result<(), SPI::Error>; |
| 47 | async fn bus_write<SPI: SpiDevice>(spi: &mut SPI, address: Self::Address, data: &[u8]) -> Result<(), SPI::Error>; | 47 | async fn bus_write<SPI: SpiDevice>(spi: &mut SPI, address: Self::Address, data: &[u8]) -> Result<(), SPI::Error>; |
| 48 | } | 48 | } |
| 49 | 49 | ||
diff --git a/embassy-net-wiznet/src/lib.rs b/embassy-net-wiznet/src/lib.rs index 3fbd4c741..30a5db9f6 100644 --- a/embassy-net-wiznet/src/lib.rs +++ b/embassy-net-wiznet/src/lib.rs | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | pub mod chip; | 6 | pub mod chip; |
| 7 | mod device; | 7 | mod device; |
| 8 | 8 | ||
| 9 | use embassy_futures::select::{select3, Either3}; | 9 | use embassy_futures::select::{Either3, select3}; |
| 10 | use embassy_net_driver_channel as ch; | 10 | use embassy_net_driver_channel as ch; |
| 11 | use embassy_net_driver_channel::driver::LinkState; | 11 | use embassy_net_driver_channel::driver::LinkState; |
| 12 | use embassy_time::{Duration, Ticker, Timer}; | 12 | use embassy_time::{Duration, Ticker, Timer}; |
diff --git a/embassy-net/Cargo.toml b/embassy-net/Cargo.toml index 31ce7e9a6..4c8075c43 100644 --- a/embassy-net/Cargo.toml +++ b/embassy-net/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-net" | 2 | name = "embassy-net" |
| 3 | version = "0.7.1" | 3 | version = "0.7.1" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | description = "Async TCP/IP network stack for embedded systems" | 6 | description = "Async TCP/IP network stack for embedded systems" |
| 7 | repository = "https://github.com/embassy-rs/embassy" | 7 | repository = "https://github.com/embassy-rs/embassy" |
diff --git a/embassy-net/src/icmp.rs b/embassy-net/src/icmp.rs index 22c31a589..09e91a1ae 100644 --- a/embassy-net/src/icmp.rs +++ b/embassy-net/src/icmp.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | //! ICMP sockets. | 1 | //! ICMP sockets. |
| 2 | 2 | ||
| 3 | use core::future::{poll_fn, Future}; | 3 | use core::future::{Future, poll_fn}; |
| 4 | use core::mem; | 4 | use core::mem; |
| 5 | use core::task::{Context, Poll}; | 5 | use core::task::{Context, Poll}; |
| 6 | 6 | ||
diff --git a/embassy-net/src/lib.rs b/embassy-net/src/lib.rs index 3f0634849..a49955c96 100644 --- a/embassy-net/src/lib.rs +++ b/embassy-net/src/lib.rs | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![allow(async_fn_in_trait)] | 2 | #![allow(async_fn_in_trait)] |
| 3 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 3 | #![warn(missing_docs)] | 4 | #![warn(missing_docs)] |
| 4 | #![doc = include_str!("../README.md")] | 5 | #![doc = include_str!("../README.md")] |
| 5 | 6 | ||
| @@ -26,7 +27,7 @@ mod time; | |||
| 26 | pub mod udp; | 27 | pub mod udp; |
| 27 | 28 | ||
| 28 | use core::cell::RefCell; | 29 | use core::cell::RefCell; |
| 29 | use core::future::{poll_fn, Future}; | 30 | use core::future::{Future, poll_fn}; |
| 30 | use core::mem::MaybeUninit; | 31 | use core::mem::MaybeUninit; |
| 31 | use core::pin::pin; | 32 | use core::pin::pin; |
| 32 | use core::task::{Context, Poll}; | 33 | use core::task::{Context, Poll}; |
diff --git a/embassy-net/src/raw.rs b/embassy-net/src/raw.rs index c9f753f13..89d2dd350 100644 --- a/embassy-net/src/raw.rs +++ b/embassy-net/src/raw.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | //! Raw sockets. | 1 | //! Raw sockets. |
| 2 | 2 | ||
| 3 | use core::future::{poll_fn, Future}; | 3 | use core::future::{Future, poll_fn}; |
| 4 | use core::mem; | 4 | use core::mem; |
| 5 | use core::task::{Context, Poll}; | 5 | use core::task::{Context, Poll}; |
| 6 | 6 | ||
diff --git a/embassy-net/src/tcp.rs b/embassy-net/src/tcp.rs index d0230b581..6792c5526 100644 --- a/embassy-net/src/tcp.rs +++ b/embassy-net/src/tcp.rs | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | //! Incoming connections when no socket is listening are rejected. To accept many incoming | 8 | //! Incoming connections when no socket is listening are rejected. To accept many incoming |
| 9 | //! connections, create many sockets and put them all into listening mode. | 9 | //! connections, create many sockets and put them all into listening mode. |
| 10 | 10 | ||
| 11 | use core::future::{poll_fn, Future}; | 11 | use core::future::{Future, poll_fn}; |
| 12 | use core::mem; | 12 | use core::mem; |
| 13 | use core::task::{Context, Poll}; | 13 | use core::task::{Context, Poll}; |
| 14 | 14 | ||
| @@ -18,8 +18,8 @@ use smoltcp::socket::tcp; | |||
| 18 | pub use smoltcp::socket::tcp::State; | 18 | pub use smoltcp::socket::tcp::State; |
| 19 | use smoltcp::wire::{IpEndpoint, IpListenEndpoint}; | 19 | use smoltcp::wire::{IpEndpoint, IpListenEndpoint}; |
| 20 | 20 | ||
| 21 | use crate::time::duration_to_smoltcp; | ||
| 22 | use crate::Stack; | 21 | use crate::Stack; |
| 22 | use crate::time::duration_to_smoltcp; | ||
| 23 | 23 | ||
| 24 | /// Error returned by TcpSocket read/write functions. | 24 | /// Error returned by TcpSocket read/write functions. |
| 25 | #[derive(PartialEq, Eq, Clone, Copy, Debug)] | 25 | #[derive(PartialEq, Eq, Clone, Copy, Debug)] |
diff --git a/embassy-net/src/udp.rs b/embassy-net/src/udp.rs index 482eb0e56..448c25ecc 100644 --- a/embassy-net/src/udp.rs +++ b/embassy-net/src/udp.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | //! UDP sockets. | 1 | //! UDP sockets. |
| 2 | 2 | ||
| 3 | use core::future::{poll_fn, Future}; | 3 | use core::future::{Future, poll_fn}; |
| 4 | use core::mem; | 4 | use core::mem; |
| 5 | use core::task::{Context, Poll}; | 5 | use core::task::{Context, Poll}; |
| 6 | 6 | ||
diff --git a/embassy-nrf/CHANGELOG.md b/embassy-nrf/CHANGELOG.md index b8d03a1f8..0244dedab 100644 --- a/embassy-nrf/CHANGELOG.md +++ b/embassy-nrf/CHANGELOG.md | |||
| @@ -7,8 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
| 7 | 7 | ||
| 8 | <!-- next-header --> | 8 | <!-- next-header --> |
| 9 | ## Unreleased - ReleaseDate | 9 | ## Unreleased - ReleaseDate |
| 10 | - changed: apply trimming values from FICR.TRIMCNF on nrf53/54l | ||
| 10 | 11 | ||
| 11 | - changed: erase Instance type from Spim | 12 | ## 0.8.0 - 2025-09-30 |
| 13 | |||
| 14 | - changed: Remove `T: Instance` generic params in all drivers. | ||
| 12 | - changed: nrf54l: Disable glitch detection and enable DC/DC in init. | 15 | - changed: nrf54l: Disable glitch detection and enable DC/DC in init. |
| 13 | - changed: Add embassy-net-driver-channel implementation for IEEE 802.15.4 | 16 | - changed: Add embassy-net-driver-channel implementation for IEEE 802.15.4 |
| 14 | - changed: add persist() method for gpio and ppi | 17 | - changed: add persist() method for gpio and ppi |
| @@ -17,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
| 17 | - changed: impl Drop for Timer | 20 | - changed: impl Drop for Timer |
| 18 | - added: expose `regs` for timer driver | 21 | - added: expose `regs` for timer driver |
| 19 | - added: timer driver CC `clear_events` method | 22 | - added: timer driver CC `clear_events` method |
| 23 | - changed: Saadc reset in Drop impl, anomaly 241 - high power usage | ||
| 20 | 24 | ||
| 21 | ## 0.7.0 - 2025-08-26 | 25 | ## 0.7.0 - 2025-08-26 |
| 22 | 26 | ||
diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index 1af633500..17ffaf439 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-nrf" | 2 | name = "embassy-nrf" |
| 3 | version = "0.7.0" | 3 | version = "0.8.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | description = "Embassy Hardware Abstraction Layer (HAL) for nRF series microcontrollers" | 6 | description = "Embassy Hardware Abstraction Layer (HAL) for nRF series microcontrollers" |
| 7 | keywords = ["embedded", "async", "nordic", "nrf", "embedded-hal"] | 7 | keywords = ["embedded", "async", "nordic", "nrf", "embedded-hal"] |
| @@ -34,6 +34,7 @@ build = [ | |||
| 34 | {target = "thumbv7em-none-eabi", features = ["defmt", "gpiote", "nrf52840", "time"]}, | 34 | {target = "thumbv7em-none-eabi", features = ["defmt", "gpiote", "nrf52840", "time"]}, |
| 35 | {target = "thumbv7em-none-eabi", features = ["defmt", "gpiote", "nrf52840", "time-driver-rtc1"]}, | 35 | {target = "thumbv7em-none-eabi", features = ["defmt", "gpiote", "nrf52840", "time-driver-rtc1"]}, |
| 36 | {target = "thumbv7em-none-eabi", features = ["defmt", "gpiote", "nrf52840", "time", "time-driver-rtc1"]}, | 36 | {target = "thumbv7em-none-eabi", features = ["defmt", "gpiote", "nrf52840", "time", "time-driver-rtc1"]}, |
| 37 | {target = "thumbv7em-none-eabi", features = ["defmt", "gpiote", "nrf52840", "time", "time-driver-rtc1","qspi-multiwrite-flash"]}, | ||
| 37 | {target = "thumbv6m-none-eabi", features = ["defmt", "nrf51", "time", "time-driver-rtc1"]}, | 38 | {target = "thumbv6m-none-eabi", features = ["defmt", "nrf51", "time", "time-driver-rtc1"]}, |
| 38 | {target = "thumbv6m-none-eabi", features = ["defmt", "nrf51", "time"]}, | 39 | {target = "thumbv6m-none-eabi", features = ["defmt", "nrf51", "time"]}, |
| 39 | {target = "thumbv6m-none-eabi", features = ["nrf51", "time"]}, | 40 | {target = "thumbv6m-none-eabi", features = ["nrf51", "time"]}, |
diff --git a/embassy-nrf/src/buffered_uarte.rs b/embassy-nrf/src/buffered_uarte.rs index 29e126903..4c946497d 100644 --- a/embassy-nrf/src/buffered_uarte.rs +++ b/embassy-nrf/src/buffered_uarte.rs | |||
| @@ -9,26 +9,27 @@ | |||
| 9 | //! Please also see [crate::uarte] to understand when [BufferedUarte] should be used. | 9 | //! Please also see [crate::uarte] to understand when [BufferedUarte] should be used. |
| 10 | 10 | ||
| 11 | use core::cmp::min; | 11 | use core::cmp::min; |
| 12 | use core::future::{poll_fn, Future}; | 12 | use core::future::{Future, poll_fn}; |
| 13 | use core::marker::PhantomData; | 13 | use core::marker::PhantomData; |
| 14 | use core::slice; | 14 | use core::slice; |
| 15 | use core::sync::atomic::{compiler_fence, AtomicBool, AtomicU8, AtomicUsize, Ordering}; | 15 | use core::sync::atomic::{AtomicBool, AtomicU8, AtomicUsize, Ordering, compiler_fence}; |
| 16 | use core::task::Poll; | 16 | use core::task::Poll; |
| 17 | 17 | ||
| 18 | use embassy_hal_internal::atomic_ring_buffer::RingBuffer; | ||
| 19 | use embassy_hal_internal::Peri; | 18 | use embassy_hal_internal::Peri; |
| 19 | use embassy_hal_internal::atomic_ring_buffer::RingBuffer; | ||
| 20 | use pac::uarte::vals; | 20 | use pac::uarte::vals; |
| 21 | // Re-export SVD variants to allow user to directly set values | 21 | // Re-export SVD variants to allow user to directly set values |
| 22 | pub use pac::uarte::vals::{Baudrate, ConfigParity as Parity}; | 22 | pub use pac::uarte::vals::{Baudrate, ConfigParity as Parity}; |
| 23 | 23 | ||
| 24 | use crate::gpio::{AnyPin, Pin as GpioPin}; | 24 | use crate::gpio::{AnyPin, Pin as GpioPin}; |
| 25 | use crate::interrupt::InterruptExt; | ||
| 25 | use crate::interrupt::typelevel::Interrupt; | 26 | use crate::interrupt::typelevel::Interrupt; |
| 26 | use crate::ppi::{ | 27 | use crate::ppi::{ |
| 27 | self, AnyConfigurableChannel, AnyGroup, Channel, ConfigurableChannel, Event, Group, Ppi, PpiGroup, Task, | 28 | self, AnyConfigurableChannel, AnyGroup, Channel, ConfigurableChannel, Event, Group, Ppi, PpiGroup, Task, |
| 28 | }; | 29 | }; |
| 29 | use crate::timer::{Instance as TimerInstance, Timer}; | 30 | use crate::timer::{Instance as TimerInstance, Timer}; |
| 30 | use crate::uarte::{configure, configure_rx_pins, configure_tx_pins, drop_tx_rx, Config, Instance as UarteInstance}; | 31 | use crate::uarte::{Config, Instance as UarteInstance, configure, configure_rx_pins, configure_tx_pins, drop_tx_rx}; |
| 31 | use crate::{interrupt, pac, EASY_DMA_SIZE}; | 32 | use crate::{EASY_DMA_SIZE, interrupt, pac}; |
| 32 | 33 | ||
| 33 | pub(crate) struct State { | 34 | pub(crate) struct State { |
| 34 | tx_buf: RingBuffer, | 35 | tx_buf: RingBuffer, |
| @@ -207,21 +208,21 @@ impl<U: UarteInstance> interrupt::typelevel::Handler<U::Interrupt> for Interrupt | |||
| 207 | } | 208 | } |
| 208 | 209 | ||
| 209 | /// Buffered UARTE driver. | 210 | /// Buffered UARTE driver. |
| 210 | pub struct BufferedUarte<'d, U: UarteInstance, T: TimerInstance> { | 211 | pub struct BufferedUarte<'d> { |
| 211 | tx: BufferedUarteTx<'d, U>, | 212 | tx: BufferedUarteTx<'d>, |
| 212 | rx: BufferedUarteRx<'d, U, T>, | 213 | rx: BufferedUarteRx<'d>, |
| 213 | } | 214 | } |
| 214 | 215 | ||
| 215 | impl<'d, U: UarteInstance, T: TimerInstance> Unpin for BufferedUarte<'d, U, T> {} | 216 | impl<'d> Unpin for BufferedUarte<'d> {} |
| 216 | 217 | ||
| 217 | impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> { | 218 | impl<'d> BufferedUarte<'d> { |
| 218 | /// Create a new BufferedUarte without hardware flow control. | 219 | /// Create a new BufferedUarte without hardware flow control. |
| 219 | /// | 220 | /// |
| 220 | /// # Panics | 221 | /// # Panics |
| 221 | /// | 222 | /// |
| 222 | /// Panics if `rx_buffer.len()` is odd. | 223 | /// Panics if `rx_buffer.len()` is odd. |
| 223 | #[allow(clippy::too_many_arguments)] | 224 | #[allow(clippy::too_many_arguments)] |
| 224 | pub fn new( | 225 | pub fn new<U: UarteInstance, T: TimerInstance>( |
| 225 | uarte: Peri<'d, U>, | 226 | uarte: Peri<'d, U>, |
| 226 | timer: Peri<'d, T>, | 227 | timer: Peri<'d, T>, |
| 227 | ppi_ch1: Peri<'d, impl ConfigurableChannel>, | 228 | ppi_ch1: Peri<'d, impl ConfigurableChannel>, |
| @@ -256,7 +257,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> { | |||
| 256 | /// | 257 | /// |
| 257 | /// Panics if `rx_buffer.len()` is odd. | 258 | /// Panics if `rx_buffer.len()` is odd. |
| 258 | #[allow(clippy::too_many_arguments)] | 259 | #[allow(clippy::too_many_arguments)] |
| 259 | pub fn new_with_rtscts( | 260 | pub fn new_with_rtscts<U: UarteInstance, T: TimerInstance>( |
| 260 | uarte: Peri<'d, U>, | 261 | uarte: Peri<'d, U>, |
| 261 | timer: Peri<'d, T>, | 262 | timer: Peri<'d, T>, |
| 262 | ppi_ch1: Peri<'d, impl ConfigurableChannel>, | 263 | ppi_ch1: Peri<'d, impl ConfigurableChannel>, |
| @@ -288,7 +289,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> { | |||
| 288 | } | 289 | } |
| 289 | 290 | ||
| 290 | #[allow(clippy::too_many_arguments)] | 291 | #[allow(clippy::too_many_arguments)] |
| 291 | fn new_inner( | 292 | fn new_inner<U: UarteInstance, T: TimerInstance>( |
| 292 | peri: Peri<'d, U>, | 293 | peri: Peri<'d, U>, |
| 293 | timer: Peri<'d, T>, | 294 | timer: Peri<'d, T>, |
| 294 | ppi_ch1: Peri<'d, AnyConfigurableChannel>, | 295 | ppi_ch1: Peri<'d, AnyConfigurableChannel>, |
| @@ -302,30 +303,33 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> { | |||
| 302 | rx_buffer: &'d mut [u8], | 303 | rx_buffer: &'d mut [u8], |
| 303 | tx_buffer: &'d mut [u8], | 304 | tx_buffer: &'d mut [u8], |
| 304 | ) -> Self { | 305 | ) -> Self { |
| 305 | configure(U::regs(), config, cts.is_some()); | 306 | let r = U::regs(); |
| 307 | let irq = U::Interrupt::IRQ; | ||
| 308 | let state = U::state(); | ||
| 309 | |||
| 310 | configure(r, config, cts.is_some()); | ||
| 306 | 311 | ||
| 307 | let tx = BufferedUarteTx::new_innerer(unsafe { peri.clone_unchecked() }, txd, cts, tx_buffer); | 312 | let tx = BufferedUarteTx::new_innerer(unsafe { peri.clone_unchecked() }, txd, cts, tx_buffer); |
| 308 | let rx = BufferedUarteRx::new_innerer(peri, timer, ppi_ch1, ppi_ch2, ppi_group, rxd, rts, rx_buffer); | 313 | let rx = BufferedUarteRx::new_innerer(peri, timer, ppi_ch1, ppi_ch2, ppi_group, rxd, rts, rx_buffer); |
| 309 | 314 | ||
| 310 | U::regs().enable().write(|w| w.set_enable(vals::Enable::ENABLED)); | 315 | r.enable().write(|w| w.set_enable(vals::Enable::ENABLED)); |
| 311 | U::Interrupt::pend(); | 316 | irq.pend(); |
| 312 | unsafe { U::Interrupt::enable() }; | 317 | unsafe { irq.enable() }; |
| 313 | 318 | ||
| 314 | U::state().tx_rx_refcount.store(2, Ordering::Relaxed); | 319 | state.tx_rx_refcount.store(2, Ordering::Relaxed); |
| 315 | 320 | ||
| 316 | Self { tx, rx } | 321 | Self { tx, rx } |
| 317 | } | 322 | } |
| 318 | 323 | ||
| 319 | /// Adjust the baud rate to the provided value. | 324 | /// Adjust the baud rate to the provided value. |
| 320 | pub fn set_baudrate(&mut self, baudrate: Baudrate) { | 325 | pub fn set_baudrate(&mut self, baudrate: Baudrate) { |
| 321 | let r = U::regs(); | 326 | self.tx.set_baudrate(baudrate); |
| 322 | r.baudrate().write(|w| w.set_baudrate(baudrate)); | ||
| 323 | } | 327 | } |
| 324 | 328 | ||
| 325 | /// Split the UART in reader and writer parts. | 329 | /// Split the UART in reader and writer parts. |
| 326 | /// | 330 | /// |
| 327 | /// This allows reading and writing concurrently from independent tasks. | 331 | /// This allows reading and writing concurrently from independent tasks. |
| 328 | pub fn split(self) -> (BufferedUarteRx<'d, U, T>, BufferedUarteTx<'d, U>) { | 332 | pub fn split(self) -> (BufferedUarteRx<'d>, BufferedUarteTx<'d>) { |
| 329 | (self.rx, self.tx) | 333 | (self.rx, self.tx) |
| 330 | } | 334 | } |
| 331 | 335 | ||
| @@ -333,7 +337,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> { | |||
| 333 | /// | 337 | /// |
| 334 | /// The returned halves borrow from `self`, so you can drop them and go back to using | 338 | /// The returned halves borrow from `self`, so you can drop them and go back to using |
| 335 | /// the "un-split" `self`. This allows temporarily splitting the UART. | 339 | /// the "un-split" `self`. This allows temporarily splitting the UART. |
| 336 | pub fn split_by_ref(&mut self) -> (&mut BufferedUarteRx<'d, U, T>, &mut BufferedUarteTx<'d, U>) { | 340 | pub fn split_by_ref(&mut self) -> (&mut BufferedUarteRx<'d>, &mut BufferedUarteTx<'d>) { |
| 337 | (&mut self.rx, &mut self.tx) | 341 | (&mut self.rx, &mut self.tx) |
| 338 | } | 342 | } |
| 339 | 343 | ||
| @@ -369,13 +373,17 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarte<'d, U, T> { | |||
| 369 | } | 373 | } |
| 370 | 374 | ||
| 371 | /// Reader part of the buffered UARTE driver. | 375 | /// Reader part of the buffered UARTE driver. |
| 372 | pub struct BufferedUarteTx<'d, U: UarteInstance> { | 376 | pub struct BufferedUarteTx<'d> { |
| 373 | _peri: Peri<'d, U>, | 377 | r: pac::uarte::Uarte, |
| 378 | _irq: interrupt::Interrupt, | ||
| 379 | state: &'static crate::uarte::State, | ||
| 380 | buffered_state: &'static State, | ||
| 381 | _p: PhantomData<&'d ()>, | ||
| 374 | } | 382 | } |
| 375 | 383 | ||
| 376 | impl<'d, U: UarteInstance> BufferedUarteTx<'d, U> { | 384 | impl<'d> BufferedUarteTx<'d> { |
| 377 | /// Create a new BufferedUarteTx without hardware flow control. | 385 | /// Create a new BufferedUarteTx without hardware flow control. |
| 378 | pub fn new( | 386 | pub fn new<U: UarteInstance>( |
| 379 | uarte: Peri<'d, U>, | 387 | uarte: Peri<'d, U>, |
| 380 | txd: Peri<'d, impl GpioPin>, | 388 | txd: Peri<'d, impl GpioPin>, |
| 381 | _irq: impl interrupt::typelevel::Binding<U::Interrupt, InterruptHandler<U>> + 'd, | 389 | _irq: impl interrupt::typelevel::Binding<U::Interrupt, InterruptHandler<U>> + 'd, |
| @@ -390,7 +398,7 @@ impl<'d, U: UarteInstance> BufferedUarteTx<'d, U> { | |||
| 390 | /// # Panics | 398 | /// # Panics |
| 391 | /// | 399 | /// |
| 392 | /// Panics if `rx_buffer.len()` is odd. | 400 | /// Panics if `rx_buffer.len()` is odd. |
| 393 | pub fn new_with_cts( | 401 | pub fn new_with_cts<U: UarteInstance>( |
| 394 | uarte: Peri<'d, U>, | 402 | uarte: Peri<'d, U>, |
| 395 | txd: Peri<'d, impl GpioPin>, | 403 | txd: Peri<'d, impl GpioPin>, |
| 396 | cts: Peri<'d, impl GpioPin>, | 404 | cts: Peri<'d, impl GpioPin>, |
| @@ -401,41 +409,48 @@ impl<'d, U: UarteInstance> BufferedUarteTx<'d, U> { | |||
| 401 | Self::new_inner(uarte, txd.into(), Some(cts.into()), config, tx_buffer) | 409 | Self::new_inner(uarte, txd.into(), Some(cts.into()), config, tx_buffer) |
| 402 | } | 410 | } |
| 403 | 411 | ||
| 404 | fn new_inner( | 412 | fn new_inner<U: UarteInstance>( |
| 405 | peri: Peri<'d, U>, | 413 | peri: Peri<'d, U>, |
| 406 | txd: Peri<'d, AnyPin>, | 414 | txd: Peri<'d, AnyPin>, |
| 407 | cts: Option<Peri<'d, AnyPin>>, | 415 | cts: Option<Peri<'d, AnyPin>>, |
| 408 | config: Config, | 416 | config: Config, |
| 409 | tx_buffer: &'d mut [u8], | 417 | tx_buffer: &'d mut [u8], |
| 410 | ) -> Self { | 418 | ) -> Self { |
| 411 | configure(U::regs(), config, cts.is_some()); | 419 | let r = U::regs(); |
| 420 | let irq = U::Interrupt::IRQ; | ||
| 421 | let state = U::state(); | ||
| 422 | let _buffered_state = U::buffered_state(); | ||
| 423 | |||
| 424 | configure(r, config, cts.is_some()); | ||
| 412 | 425 | ||
| 413 | let this = Self::new_innerer(peri, txd, cts, tx_buffer); | 426 | let this = Self::new_innerer(peri, txd, cts, tx_buffer); |
| 414 | 427 | ||
| 415 | U::regs().enable().write(|w| w.set_enable(vals::Enable::ENABLED)); | 428 | r.enable().write(|w| w.set_enable(vals::Enable::ENABLED)); |
| 416 | U::Interrupt::pend(); | 429 | irq.pend(); |
| 417 | unsafe { U::Interrupt::enable() }; | 430 | unsafe { irq.enable() }; |
| 418 | 431 | ||
| 419 | U::state().tx_rx_refcount.store(1, Ordering::Relaxed); | 432 | state.tx_rx_refcount.store(1, Ordering::Relaxed); |
| 420 | 433 | ||
| 421 | this | 434 | this |
| 422 | } | 435 | } |
| 423 | 436 | ||
| 424 | fn new_innerer( | 437 | fn new_innerer<U: UarteInstance>( |
| 425 | peri: Peri<'d, U>, | 438 | _peri: Peri<'d, U>, |
| 426 | txd: Peri<'d, AnyPin>, | 439 | txd: Peri<'d, AnyPin>, |
| 427 | cts: Option<Peri<'d, AnyPin>>, | 440 | cts: Option<Peri<'d, AnyPin>>, |
| 428 | tx_buffer: &'d mut [u8], | 441 | tx_buffer: &'d mut [u8], |
| 429 | ) -> Self { | 442 | ) -> Self { |
| 430 | let r = U::regs(); | 443 | let r = U::regs(); |
| 444 | let irq = U::Interrupt::IRQ; | ||
| 445 | let state = U::state(); | ||
| 446 | let buffered_state = U::buffered_state(); | ||
| 431 | 447 | ||
| 432 | configure_tx_pins(r, txd, cts); | 448 | configure_tx_pins(r, txd, cts); |
| 433 | 449 | ||
| 434 | // Initialize state | 450 | // Initialize state |
| 435 | let s = U::buffered_state(); | 451 | buffered_state.tx_count.store(0, Ordering::Relaxed); |
| 436 | s.tx_count.store(0, Ordering::Relaxed); | ||
| 437 | let len = tx_buffer.len(); | 452 | let len = tx_buffer.len(); |
| 438 | unsafe { s.tx_buf.init(tx_buffer.as_mut_ptr(), len) }; | 453 | unsafe { buffered_state.tx_buf.init(tx_buffer.as_mut_ptr(), len) }; |
| 439 | 454 | ||
| 440 | r.events_txstarted().write_value(0); | 455 | r.events_txstarted().write_value(0); |
| 441 | 456 | ||
| @@ -444,15 +459,21 @@ impl<'d, U: UarteInstance> BufferedUarteTx<'d, U> { | |||
| 444 | w.set_endtx(true); | 459 | w.set_endtx(true); |
| 445 | }); | 460 | }); |
| 446 | 461 | ||
| 447 | Self { _peri: peri } | 462 | Self { |
| 463 | r, | ||
| 464 | _irq: irq, | ||
| 465 | state, | ||
| 466 | buffered_state, | ||
| 467 | _p: PhantomData, | ||
| 468 | } | ||
| 448 | } | 469 | } |
| 449 | 470 | ||
| 450 | /// Write a buffer into this writer, returning how many bytes were written. | 471 | /// Write a buffer into this writer, returning how many bytes were written. |
| 451 | pub fn write<'a>(&'a mut self, buf: &'a [u8]) -> impl Future<Output = Result<usize, Error>> + 'a { | 472 | pub fn write<'a>(&'a mut self, buf: &'a [u8]) -> impl Future<Output = Result<usize, Error>> + 'a + use<'a, 'd> { |
| 452 | poll_fn(move |cx| { | 473 | poll_fn(move |cx| { |
| 453 | //trace!("poll_write: {:?}", buf.len()); | 474 | //trace!("poll_write: {:?}", buf.len()); |
| 454 | let ss = U::state(); | 475 | let ss = self.state; |
| 455 | let s = U::buffered_state(); | 476 | let s = self.buffered_state; |
| 456 | let mut tx = unsafe { s.tx_buf.writer() }; | 477 | let mut tx = unsafe { s.tx_buf.writer() }; |
| 457 | 478 | ||
| 458 | let tx_buf = tx.push_slice(); | 479 | let tx_buf = tx.push_slice(); |
| @@ -469,7 +490,7 @@ impl<'d, U: UarteInstance> BufferedUarteTx<'d, U> { | |||
| 469 | //trace!("poll_write: queued {:?}", n); | 490 | //trace!("poll_write: queued {:?}", n); |
| 470 | 491 | ||
| 471 | compiler_fence(Ordering::SeqCst); | 492 | compiler_fence(Ordering::SeqCst); |
| 472 | U::Interrupt::pend(); | 493 | self._irq.pend(); |
| 473 | 494 | ||
| 474 | Poll::Ready(Ok(n)) | 495 | Poll::Ready(Ok(n)) |
| 475 | }) | 496 | }) |
| @@ -478,7 +499,7 @@ impl<'d, U: UarteInstance> BufferedUarteTx<'d, U> { | |||
| 478 | /// Try writing a buffer without waiting, returning how many bytes were written. | 499 | /// Try writing a buffer without waiting, returning how many bytes were written. |
| 479 | pub fn try_write(&mut self, buf: &[u8]) -> Result<usize, Error> { | 500 | pub fn try_write(&mut self, buf: &[u8]) -> Result<usize, Error> { |
| 480 | //trace!("poll_write: {:?}", buf.len()); | 501 | //trace!("poll_write: {:?}", buf.len()); |
| 481 | let s = U::buffered_state(); | 502 | let s = self.buffered_state; |
| 482 | let mut tx = unsafe { s.tx_buf.writer() }; | 503 | let mut tx = unsafe { s.tx_buf.writer() }; |
| 483 | 504 | ||
| 484 | let tx_buf = tx.push_slice(); | 505 | let tx_buf = tx.push_slice(); |
| @@ -493,17 +514,17 @@ impl<'d, U: UarteInstance> BufferedUarteTx<'d, U> { | |||
| 493 | //trace!("poll_write: queued {:?}", n); | 514 | //trace!("poll_write: queued {:?}", n); |
| 494 | 515 | ||
| 495 | compiler_fence(Ordering::SeqCst); | 516 | compiler_fence(Ordering::SeqCst); |
| 496 | U::Interrupt::pend(); | 517 | self._irq.pend(); |
| 497 | 518 | ||
| 498 | Ok(n) | 519 | Ok(n) |
| 499 | } | 520 | } |
| 500 | 521 | ||
| 501 | /// Flush this output stream, ensuring that all intermediately buffered contents reach their destination. | 522 | /// Flush this output stream, ensuring that all intermediately buffered contents reach their destination. |
| 502 | pub fn flush(&mut self) -> impl Future<Output = Result<(), Error>> + '_ { | 523 | pub fn flush(&mut self) -> impl Future<Output = Result<(), Error>> + '_ { |
| 524 | let ss = self.state; | ||
| 525 | let s = self.buffered_state; | ||
| 503 | poll_fn(move |cx| { | 526 | poll_fn(move |cx| { |
| 504 | //trace!("poll_flush"); | 527 | //trace!("poll_flush"); |
| 505 | let ss = U::state(); | ||
| 506 | let s = U::buffered_state(); | ||
| 507 | if !s.tx_buf.is_empty() { | 528 | if !s.tx_buf.is_empty() { |
| 508 | //trace!("poll_flush: pending"); | 529 | //trace!("poll_flush: pending"); |
| 509 | ss.tx_waker.register(cx.waker()); | 530 | ss.tx_waker.register(cx.waker()); |
| @@ -513,11 +534,16 @@ impl<'d, U: UarteInstance> BufferedUarteTx<'d, U> { | |||
| 513 | Poll::Ready(Ok(())) | 534 | Poll::Ready(Ok(())) |
| 514 | }) | 535 | }) |
| 515 | } | 536 | } |
| 537 | |||
| 538 | /// Adjust the baud rate to the provided value. | ||
| 539 | pub fn set_baudrate(&mut self, baudrate: Baudrate) { | ||
| 540 | self.r.baudrate().write(|w| w.set_baudrate(baudrate)); | ||
| 541 | } | ||
| 516 | } | 542 | } |
| 517 | 543 | ||
| 518 | impl<'a, U: UarteInstance> Drop for BufferedUarteTx<'a, U> { | 544 | impl<'a> Drop for BufferedUarteTx<'a> { |
| 519 | fn drop(&mut self) { | 545 | fn drop(&mut self) { |
| 520 | let r = U::regs(); | 546 | let r = self.r; |
| 521 | 547 | ||
| 522 | r.intenclr().write(|w| { | 548 | r.intenclr().write(|w| { |
| 523 | w.set_txdrdy(true); | 549 | w.set_txdrdy(true); |
| @@ -528,31 +554,34 @@ impl<'a, U: UarteInstance> Drop for BufferedUarteTx<'a, U> { | |||
| 528 | r.tasks_stoptx().write_value(1); | 554 | r.tasks_stoptx().write_value(1); |
| 529 | while r.events_txstopped().read() == 0 {} | 555 | while r.events_txstopped().read() == 0 {} |
| 530 | 556 | ||
| 531 | let s = U::buffered_state(); | 557 | let s = self.buffered_state; |
| 532 | unsafe { s.tx_buf.deinit() } | 558 | unsafe { s.tx_buf.deinit() } |
| 533 | 559 | ||
| 534 | let s = U::state(); | 560 | let s = self.state; |
| 535 | drop_tx_rx(r, s); | 561 | drop_tx_rx(r, s); |
| 536 | } | 562 | } |
| 537 | } | 563 | } |
| 538 | 564 | ||
| 539 | /// Reader part of the buffered UARTE driver. | 565 | /// Reader part of the buffered UARTE driver. |
| 540 | pub struct BufferedUarteRx<'d, U: UarteInstance, T: TimerInstance> { | 566 | pub struct BufferedUarteRx<'d> { |
| 541 | _peri: Peri<'d, U>, | 567 | r: pac::uarte::Uarte, |
| 542 | timer: Timer<'d, T>, | 568 | state: &'static crate::uarte::State, |
| 569 | buffered_state: &'static State, | ||
| 570 | timer: Timer<'d>, | ||
| 543 | _ppi_ch1: Ppi<'d, AnyConfigurableChannel, 1, 1>, | 571 | _ppi_ch1: Ppi<'d, AnyConfigurableChannel, 1, 1>, |
| 544 | _ppi_ch2: Ppi<'d, AnyConfigurableChannel, 1, 2>, | 572 | _ppi_ch2: Ppi<'d, AnyConfigurableChannel, 1, 2>, |
| 545 | _ppi_group: PpiGroup<'d, AnyGroup>, | 573 | _ppi_group: PpiGroup<'d, AnyGroup>, |
| 574 | _p: PhantomData<&'d ()>, | ||
| 546 | } | 575 | } |
| 547 | 576 | ||
| 548 | impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarteRx<'d, U, T> { | 577 | impl<'d> BufferedUarteRx<'d> { |
| 549 | /// Create a new BufferedUarte without hardware flow control. | 578 | /// Create a new BufferedUarte without hardware flow control. |
| 550 | /// | 579 | /// |
| 551 | /// # Panics | 580 | /// # Panics |
| 552 | /// | 581 | /// |
| 553 | /// Panics if `rx_buffer.len()` is odd. | 582 | /// Panics if `rx_buffer.len()` is odd. |
| 554 | #[allow(clippy::too_many_arguments)] | 583 | #[allow(clippy::too_many_arguments)] |
| 555 | pub fn new( | 584 | pub fn new<U: UarteInstance, T: TimerInstance>( |
| 556 | uarte: Peri<'d, U>, | 585 | uarte: Peri<'d, U>, |
| 557 | timer: Peri<'d, T>, | 586 | timer: Peri<'d, T>, |
| 558 | ppi_ch1: Peri<'d, impl ConfigurableChannel>, | 587 | ppi_ch1: Peri<'d, impl ConfigurableChannel>, |
| @@ -582,7 +611,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarteRx<'d, U, T> { | |||
| 582 | /// | 611 | /// |
| 583 | /// Panics if `rx_buffer.len()` is odd. | 612 | /// Panics if `rx_buffer.len()` is odd. |
| 584 | #[allow(clippy::too_many_arguments)] | 613 | #[allow(clippy::too_many_arguments)] |
| 585 | pub fn new_with_rts( | 614 | pub fn new_with_rts<U: UarteInstance, T: TimerInstance>( |
| 586 | uarte: Peri<'d, U>, | 615 | uarte: Peri<'d, U>, |
| 587 | timer: Peri<'d, T>, | 616 | timer: Peri<'d, T>, |
| 588 | ppi_ch1: Peri<'d, impl ConfigurableChannel>, | 617 | ppi_ch1: Peri<'d, impl ConfigurableChannel>, |
| @@ -608,7 +637,7 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarteRx<'d, U, T> { | |||
| 608 | } | 637 | } |
| 609 | 638 | ||
| 610 | #[allow(clippy::too_many_arguments)] | 639 | #[allow(clippy::too_many_arguments)] |
| 611 | fn new_inner( | 640 | fn new_inner<U: UarteInstance, T: TimerInstance>( |
| 612 | peri: Peri<'d, U>, | 641 | peri: Peri<'d, U>, |
| 613 | timer: Peri<'d, T>, | 642 | timer: Peri<'d, T>, |
| 614 | ppi_ch1: Peri<'d, AnyConfigurableChannel>, | 643 | ppi_ch1: Peri<'d, AnyConfigurableChannel>, |
| @@ -619,22 +648,27 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarteRx<'d, U, T> { | |||
| 619 | config: Config, | 648 | config: Config, |
| 620 | rx_buffer: &'d mut [u8], | 649 | rx_buffer: &'d mut [u8], |
| 621 | ) -> Self { | 650 | ) -> Self { |
| 622 | configure(U::regs(), config, rts.is_some()); | 651 | let r = U::regs(); |
| 652 | let irq = U::Interrupt::IRQ; | ||
| 653 | let state = U::state(); | ||
| 654 | let _buffered_state = U::buffered_state(); | ||
| 655 | |||
| 656 | configure(r, config, rts.is_some()); | ||
| 623 | 657 | ||
| 624 | let this = Self::new_innerer(peri, timer, ppi_ch1, ppi_ch2, ppi_group, rxd, rts, rx_buffer); | 658 | let this = Self::new_innerer(peri, timer, ppi_ch1, ppi_ch2, ppi_group, rxd, rts, rx_buffer); |
| 625 | 659 | ||
| 626 | U::regs().enable().write(|w| w.set_enable(vals::Enable::ENABLED)); | 660 | r.enable().write(|w| w.set_enable(vals::Enable::ENABLED)); |
| 627 | U::Interrupt::pend(); | 661 | irq.pend(); |
| 628 | unsafe { U::Interrupt::enable() }; | 662 | unsafe { irq.enable() }; |
| 629 | 663 | ||
| 630 | U::state().tx_rx_refcount.store(1, Ordering::Relaxed); | 664 | state.tx_rx_refcount.store(1, Ordering::Relaxed); |
| 631 | 665 | ||
| 632 | this | 666 | this |
| 633 | } | 667 | } |
| 634 | 668 | ||
| 635 | #[allow(clippy::too_many_arguments)] | 669 | #[allow(clippy::too_many_arguments)] |
| 636 | fn new_innerer( | 670 | fn new_innerer<U: UarteInstance, T: TimerInstance>( |
| 637 | peri: Peri<'d, U>, | 671 | _peri: Peri<'d, U>, |
| 638 | timer: Peri<'d, T>, | 672 | timer: Peri<'d, T>, |
| 639 | ppi_ch1: Peri<'d, AnyConfigurableChannel>, | 673 | ppi_ch1: Peri<'d, AnyConfigurableChannel>, |
| 640 | ppi_ch2: Peri<'d, AnyConfigurableChannel>, | 674 | ppi_ch2: Peri<'d, AnyConfigurableChannel>, |
| @@ -646,16 +680,17 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarteRx<'d, U, T> { | |||
| 646 | assert!(rx_buffer.len() % 2 == 0); | 680 | assert!(rx_buffer.len() % 2 == 0); |
| 647 | 681 | ||
| 648 | let r = U::regs(); | 682 | let r = U::regs(); |
| 683 | let state = U::state(); | ||
| 684 | let buffered_state = U::buffered_state(); | ||
| 649 | 685 | ||
| 650 | configure_rx_pins(r, rxd, rts); | 686 | configure_rx_pins(r, rxd, rts); |
| 651 | 687 | ||
| 652 | // Initialize state | 688 | // Initialize state |
| 653 | let s = U::buffered_state(); | 689 | buffered_state.rx_started_count.store(0, Ordering::Relaxed); |
| 654 | s.rx_started_count.store(0, Ordering::Relaxed); | 690 | buffered_state.rx_ended_count.store(0, Ordering::Relaxed); |
| 655 | s.rx_ended_count.store(0, Ordering::Relaxed); | 691 | buffered_state.rx_started.store(false, Ordering::Relaxed); |
| 656 | s.rx_started.store(false, Ordering::Relaxed); | ||
| 657 | let rx_len = rx_buffer.len().min(EASY_DMA_SIZE * 2); | 692 | let rx_len = rx_buffer.len().min(EASY_DMA_SIZE * 2); |
| 658 | unsafe { s.rx_buf.init(rx_buffer.as_mut_ptr(), rx_len) }; | 693 | unsafe { buffered_state.rx_buf.init(rx_buffer.as_mut_ptr(), rx_len) }; |
| 659 | 694 | ||
| 660 | // clear errors | 695 | // clear errors |
| 661 | let errors = r.errorsrc().read(); | 696 | let errors = r.errorsrc().read(); |
| @@ -683,7 +718,9 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarteRx<'d, U, T> { | |||
| 683 | let mut ppi_ch1 = Ppi::new_one_to_one(ppi_ch1, Event::from_reg(r.events_rxdrdy()), timer.task_count()); | 718 | let mut ppi_ch1 = Ppi::new_one_to_one(ppi_ch1, Event::from_reg(r.events_rxdrdy()), timer.task_count()); |
| 684 | ppi_ch1.enable(); | 719 | ppi_ch1.enable(); |
| 685 | 720 | ||
| 686 | s.rx_ppi_ch.store(ppi_ch2.number() as u8, Ordering::Relaxed); | 721 | buffered_state |
| 722 | .rx_ppi_ch | ||
| 723 | .store(ppi_ch2.number() as u8, Ordering::Relaxed); | ||
| 687 | let mut ppi_group = PpiGroup::new(ppi_group); | 724 | let mut ppi_group = PpiGroup::new(ppi_group); |
| 688 | let mut ppi_ch2 = Ppi::new_one_to_two( | 725 | let mut ppi_ch2 = Ppi::new_one_to_two( |
| 689 | ppi_ch2, | 726 | ppi_ch2, |
| @@ -695,11 +732,14 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarteRx<'d, U, T> { | |||
| 695 | ppi_group.add_channel(&ppi_ch2); | 732 | ppi_group.add_channel(&ppi_ch2); |
| 696 | 733 | ||
| 697 | Self { | 734 | Self { |
| 698 | _peri: peri, | 735 | r, |
| 736 | state, | ||
| 737 | buffered_state, | ||
| 699 | timer, | 738 | timer, |
| 700 | _ppi_ch1: ppi_ch1, | 739 | _ppi_ch1: ppi_ch1, |
| 701 | _ppi_ch2: ppi_ch2, | 740 | _ppi_ch2: ppi_ch2, |
| 702 | _ppi_group: ppi_group, | 741 | _ppi_group: ppi_group, |
| 742 | _p: PhantomData, | ||
| 703 | } | 743 | } |
| 704 | } | 744 | } |
| 705 | 745 | ||
| @@ -714,17 +754,17 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarteRx<'d, U, T> { | |||
| 714 | 754 | ||
| 715 | /// Return the contents of the internal buffer, filling it with more data from the inner reader if it is empty. | 755 | /// Return the contents of the internal buffer, filling it with more data from the inner reader if it is empty. |
| 716 | pub fn fill_buf(&mut self) -> impl Future<Output = Result<&'_ [u8], Error>> { | 756 | pub fn fill_buf(&mut self) -> impl Future<Output = Result<&'_ [u8], Error>> { |
| 757 | let r = self.r; | ||
| 758 | let s = self.buffered_state; | ||
| 759 | let ss = self.state; | ||
| 760 | let timer = &self.timer; | ||
| 717 | poll_fn(move |cx| { | 761 | poll_fn(move |cx| { |
| 718 | compiler_fence(Ordering::SeqCst); | 762 | compiler_fence(Ordering::SeqCst); |
| 719 | //trace!("poll_read"); | 763 | //trace!("poll_read"); |
| 720 | 764 | ||
| 721 | let r = U::regs(); | ||
| 722 | let s = U::buffered_state(); | ||
| 723 | let ss = U::state(); | ||
| 724 | |||
| 725 | // Read the RXDRDY counter. | 765 | // Read the RXDRDY counter. |
| 726 | T::regs().tasks_capture(0).write_value(1); | 766 | timer.cc(0).capture(); |
| 727 | let mut end = T::regs().cc(0).read() as usize; | 767 | let mut end = timer.cc(0).read() as usize; |
| 728 | //trace!(" rxdrdy count = {:?}", end); | 768 | //trace!(" rxdrdy count = {:?}", end); |
| 729 | 769 | ||
| 730 | // We've set a compare channel that resets the counter to 0 when it reaches `len*2`. | 770 | // We've set a compare channel that resets the counter to 0 when it reaches `len*2`. |
| @@ -771,24 +811,24 @@ impl<'d, U: UarteInstance, T: TimerInstance> BufferedUarteRx<'d, U, T> { | |||
| 771 | return; | 811 | return; |
| 772 | } | 812 | } |
| 773 | 813 | ||
| 774 | let s = U::buffered_state(); | 814 | let s = self.buffered_state; |
| 775 | let mut rx = unsafe { s.rx_buf.reader() }; | 815 | let mut rx = unsafe { s.rx_buf.reader() }; |
| 776 | rx.pop_done(amt); | 816 | rx.pop_done(amt); |
| 777 | U::regs().intenset().write(|w| w.set_rxstarted(true)); | 817 | self.r.intenset().write(|w| w.set_rxstarted(true)); |
| 778 | } | 818 | } |
| 779 | 819 | ||
| 780 | /// we are ready to read if there is data in the buffer | 820 | /// we are ready to read if there is data in the buffer |
| 781 | fn read_ready() -> Result<bool, Error> { | 821 | fn read_ready(&self) -> Result<bool, Error> { |
| 782 | let state = U::buffered_state(); | 822 | let state = self.buffered_state; |
| 783 | Ok(!state.rx_buf.is_empty()) | 823 | Ok(!state.rx_buf.is_empty()) |
| 784 | } | 824 | } |
| 785 | } | 825 | } |
| 786 | 826 | ||
| 787 | impl<'a, U: UarteInstance, T: TimerInstance> Drop for BufferedUarteRx<'a, U, T> { | 827 | impl<'a> Drop for BufferedUarteRx<'a> { |
| 788 | fn drop(&mut self) { | 828 | fn drop(&mut self) { |
| 789 | self._ppi_group.disable_all(); | 829 | self._ppi_group.disable_all(); |
| 790 | 830 | ||
| 791 | let r = U::regs(); | 831 | let r = self.r; |
| 792 | 832 | ||
| 793 | self.timer.stop(); | 833 | self.timer.stop(); |
| 794 | 834 | ||
| @@ -801,10 +841,10 @@ impl<'a, U: UarteInstance, T: TimerInstance> Drop for BufferedUarteRx<'a, U, T> | |||
| 801 | r.tasks_stoprx().write_value(1); | 841 | r.tasks_stoprx().write_value(1); |
| 802 | while r.events_rxto().read() == 0 {} | 842 | while r.events_rxto().read() == 0 {} |
| 803 | 843 | ||
| 804 | let s = U::buffered_state(); | 844 | let s = self.buffered_state; |
| 805 | unsafe { s.rx_buf.deinit() } | 845 | unsafe { s.rx_buf.deinit() } |
| 806 | 846 | ||
| 807 | let s = U::state(); | 847 | let s = self.state; |
| 808 | drop_tx_rx(r, s); | 848 | drop_tx_rx(r, s); |
| 809 | } | 849 | } |
| 810 | } | 850 | } |
| @@ -818,43 +858,44 @@ mod _embedded_io { | |||
| 818 | } | 858 | } |
| 819 | } | 859 | } |
| 820 | 860 | ||
| 821 | impl<'d, U: UarteInstance, T: TimerInstance> embedded_io_async::ErrorType for BufferedUarte<'d, U, T> { | 861 | impl<'d> embedded_io_async::ErrorType for BufferedUarte<'d> { |
| 822 | type Error = Error; | 862 | type Error = Error; |
| 823 | } | 863 | } |
| 824 | 864 | ||
| 825 | impl<'d, U: UarteInstance, T: TimerInstance> embedded_io_async::ErrorType for BufferedUarteRx<'d, U, T> { | 865 | impl<'d> embedded_io_async::ErrorType for BufferedUarteRx<'d> { |
| 826 | type Error = Error; | 866 | type Error = Error; |
| 827 | } | 867 | } |
| 828 | 868 | ||
| 829 | impl<'d, U: UarteInstance> embedded_io_async::ErrorType for BufferedUarteTx<'d, U> { | 869 | impl<'d> embedded_io_async::ErrorType for BufferedUarteTx<'d> { |
| 830 | type Error = Error; | 870 | type Error = Error; |
| 831 | } | 871 | } |
| 832 | 872 | ||
| 833 | impl<'d, U: UarteInstance, T: TimerInstance> embedded_io_async::Read for BufferedUarte<'d, U, T> { | 873 | impl<'d> embedded_io_async::Read for BufferedUarte<'d> { |
| 834 | async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { | 874 | async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { |
| 835 | self.read(buf).await | 875 | self.read(buf).await |
| 836 | } | 876 | } |
| 837 | } | 877 | } |
| 838 | 878 | ||
| 839 | impl<'d: 'd, U: UarteInstance, T: TimerInstance> embedded_io_async::Read for BufferedUarteRx<'d, U, T> { | 879 | impl<'d> embedded_io_async::Read for BufferedUarteRx<'d> { |
| 840 | async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { | 880 | async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { |
| 841 | self.read(buf).await | 881 | self.read(buf).await |
| 842 | } | 882 | } |
| 843 | } | 883 | } |
| 844 | 884 | ||
| 845 | impl<'d, U: UarteInstance, T: TimerInstance + 'd> embedded_io_async::ReadReady for BufferedUarte<'d, U, T> { | 885 | impl<'d> embedded_io_async::ReadReady for BufferedUarte<'d> { |
| 846 | fn read_ready(&mut self) -> Result<bool, Self::Error> { | 886 | fn read_ready(&mut self) -> Result<bool, Self::Error> { |
| 847 | BufferedUarteRx::<'d, U, T>::read_ready() | 887 | self.rx.read_ready() |
| 848 | } | 888 | } |
| 849 | } | 889 | } |
| 850 | 890 | ||
| 851 | impl<'d, U: UarteInstance, T: TimerInstance + 'd> embedded_io_async::ReadReady for BufferedUarteRx<'d, U, T> { | 891 | impl<'d> embedded_io_async::ReadReady for BufferedUarteRx<'d> { |
| 852 | fn read_ready(&mut self) -> Result<bool, Self::Error> { | 892 | fn read_ready(&mut self) -> Result<bool, Self::Error> { |
| 853 | Self::read_ready() | 893 | let state = self.buffered_state; |
| 894 | Ok(!state.rx_buf.is_empty()) | ||
| 854 | } | 895 | } |
| 855 | } | 896 | } |
| 856 | 897 | ||
| 857 | impl<'d, U: UarteInstance, T: TimerInstance> embedded_io_async::BufRead for BufferedUarte<'d, U, T> { | 898 | impl<'d> embedded_io_async::BufRead for BufferedUarte<'d> { |
| 858 | async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { | 899 | async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { |
| 859 | self.fill_buf().await | 900 | self.fill_buf().await |
| 860 | } | 901 | } |
| @@ -864,7 +905,7 @@ mod _embedded_io { | |||
| 864 | } | 905 | } |
| 865 | } | 906 | } |
| 866 | 907 | ||
| 867 | impl<'d: 'd, U: UarteInstance, T: TimerInstance> embedded_io_async::BufRead for BufferedUarteRx<'d, U, T> { | 908 | impl<'d> embedded_io_async::BufRead for BufferedUarteRx<'d> { |
| 868 | async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { | 909 | async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { |
| 869 | self.fill_buf().await | 910 | self.fill_buf().await |
| 870 | } | 911 | } |
| @@ -874,7 +915,7 @@ mod _embedded_io { | |||
| 874 | } | 915 | } |
| 875 | } | 916 | } |
| 876 | 917 | ||
| 877 | impl<'d, U: UarteInstance, T: TimerInstance> embedded_io_async::Write for BufferedUarte<'d, U, T> { | 918 | impl<'d> embedded_io_async::Write for BufferedUarte<'d> { |
| 878 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { | 919 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { |
| 879 | self.write(buf).await | 920 | self.write(buf).await |
| 880 | } | 921 | } |
| @@ -884,7 +925,7 @@ mod _embedded_io { | |||
| 884 | } | 925 | } |
| 885 | } | 926 | } |
| 886 | 927 | ||
| 887 | impl<'d: 'd, U: UarteInstance> embedded_io_async::Write for BufferedUarteTx<'d, U> { | 928 | impl<'d> embedded_io_async::Write for BufferedUarteTx<'d> { |
| 888 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { | 929 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { |
| 889 | self.write(buf).await | 930 | self.write(buf).await |
| 890 | } | 931 | } |
diff --git a/embassy-nrf/src/chips/nrf54l15_app.rs b/embassy-nrf/src/chips/nrf54l15_app.rs index ff05bbec0..82d30104f 100644 --- a/embassy-nrf/src/chips/nrf54l15_app.rs +++ b/embassy-nrf/src/chips/nrf54l15_app.rs | |||
| @@ -94,6 +94,7 @@ pub mod pac { | |||
| 94 | #[cfg(feature = "_s")] | 94 | #[cfg(feature = "_s")] |
| 95 | #[doc(no_inline)] | 95 | #[doc(no_inline)] |
| 96 | pub use nrf_pac::{ | 96 | pub use nrf_pac::{ |
| 97 | FICR_NS as FICR, | ||
| 97 | SICR_S as SICR, | 98 | SICR_S as SICR, |
| 98 | ICACHEDATA_S as ICACHEDATA, | 99 | ICACHEDATA_S as ICACHEDATA, |
| 99 | ICACHEINFO_S as ICACHEINFO, | 100 | ICACHEINFO_S as ICACHEINFO, |
diff --git a/embassy-nrf/src/egu.rs b/embassy-nrf/src/egu.rs index 028396c7c..666986115 100644 --- a/embassy-nrf/src/egu.rs +++ b/embassy-nrf/src/egu.rs | |||
| @@ -10,24 +10,29 @@ use core::marker::PhantomData; | |||
| 10 | use embassy_hal_internal::PeripheralType; | 10 | use embassy_hal_internal::PeripheralType; |
| 11 | 11 | ||
| 12 | use crate::ppi::{Event, Task}; | 12 | use crate::ppi::{Event, Task}; |
| 13 | use crate::{interrupt, pac, Peri}; | 13 | use crate::{Peri, interrupt, pac}; |
| 14 | 14 | ||
| 15 | /// An instance of the EGU. | 15 | /// An instance of the EGU. |
| 16 | pub struct Egu<'d, T: Instance> { | 16 | pub struct Egu<'d> { |
| 17 | _p: Peri<'d, T>, | 17 | r: pac::egu::Egu, |
| 18 | _phantom: PhantomData<&'d ()>, | ||
| 18 | } | 19 | } |
| 19 | 20 | ||
| 20 | impl<'d, T: Instance> Egu<'d, T> { | 21 | impl<'d> Egu<'d> { |
| 21 | /// Create a new EGU instance. | 22 | /// Create a new EGU instance. |
| 22 | pub fn new(_p: Peri<'d, T>) -> Self { | 23 | pub fn new<T: Instance>(_p: Peri<'d, T>) -> Self { |
| 23 | Self { _p } | 24 | Self { |
| 25 | r: T::regs(), | ||
| 26 | _phantom: PhantomData, | ||
| 27 | } | ||
| 24 | } | 28 | } |
| 25 | 29 | ||
| 26 | /// Get a handle to a trigger for the EGU. | 30 | /// Get a handle to a trigger for the EGU. |
| 27 | pub fn trigger(&mut self, number: TriggerNumber) -> Trigger<'d, T> { | 31 | pub fn trigger(&mut self, number: TriggerNumber) -> Trigger<'d> { |
| 28 | Trigger { | 32 | Trigger { |
| 29 | number, | 33 | number, |
| 30 | _p: PhantomData, | 34 | r: self.r, |
| 35 | _phantom: PhantomData, | ||
| 31 | } | 36 | } |
| 32 | } | 37 | } |
| 33 | } | 38 | } |
| @@ -57,36 +62,37 @@ macro_rules! impl_egu { | |||
| 57 | } | 62 | } |
| 58 | 63 | ||
| 59 | /// Represents a trigger within the EGU. | 64 | /// Represents a trigger within the EGU. |
| 60 | pub struct Trigger<'d, T: Instance> { | 65 | pub struct Trigger<'d> { |
| 61 | number: TriggerNumber, | 66 | number: TriggerNumber, |
| 62 | _p: PhantomData<&'d T>, | 67 | r: pac::egu::Egu, |
| 68 | _phantom: PhantomData<&'d ()>, | ||
| 63 | } | 69 | } |
| 64 | 70 | ||
| 65 | impl<'d, T: Instance> Trigger<'d, T> { | 71 | impl<'d> Trigger<'d> { |
| 66 | /// Get task for this trigger to use with PPI. | 72 | /// Get task for this trigger to use with PPI. |
| 67 | pub fn task(&self) -> Task<'d> { | 73 | pub fn task(&self) -> Task<'d> { |
| 68 | let nr = self.number as usize; | 74 | let nr = self.number as usize; |
| 69 | let regs = T::regs(); | 75 | Task::from_reg(self.r.tasks_trigger(nr)) |
| 70 | Task::from_reg(regs.tasks_trigger(nr)) | ||
| 71 | } | 76 | } |
| 72 | 77 | ||
| 73 | /// Get event for this trigger to use with PPI. | 78 | /// Get event for this trigger to use with PPI. |
| 74 | pub fn event(&self) -> Event<'d> { | 79 | pub fn event(&self) -> Event<'d> { |
| 75 | let nr = self.number as usize; | 80 | let nr = self.number as usize; |
| 76 | let regs = T::regs(); | 81 | Event::from_reg(self.r.events_triggered(nr)) |
| 77 | Event::from_reg(regs.events_triggered(nr)) | ||
| 78 | } | 82 | } |
| 79 | 83 | ||
| 80 | /// Enable interrupts for this trigger | 84 | /// Enable interrupts for this trigger |
| 81 | pub fn enable_interrupt(&mut self) { | 85 | pub fn enable_interrupt(&mut self) { |
| 82 | let regs = T::regs(); | 86 | self.r |
| 83 | regs.intenset().modify(|w| w.set_triggered(self.number as usize, true)); | 87 | .intenset() |
| 88 | .modify(|w| w.set_triggered(self.number as usize, true)); | ||
| 84 | } | 89 | } |
| 85 | 90 | ||
| 86 | /// Enable interrupts for this trigger | 91 | /// Enable interrupts for this trigger |
| 87 | pub fn disable_interrupt(&mut self) { | 92 | pub fn disable_interrupt(&mut self) { |
| 88 | let regs = T::regs(); | 93 | self.r |
| 89 | regs.intenset().modify(|w| w.set_triggered(self.number as usize, false)); | 94 | .intenset() |
| 95 | .modify(|w| w.set_triggered(self.number as usize, false)); | ||
| 90 | } | 96 | } |
| 91 | } | 97 | } |
| 92 | 98 | ||
diff --git a/embassy-nrf/src/embassy_net_802154_driver.rs b/embassy-nrf/src/embassy_net_802154_driver.rs index 8662be787..4c47b7cbd 100644 --- a/embassy-nrf/src/embassy_net_802154_driver.rs +++ b/embassy-nrf/src/embassy_net_802154_driver.rs | |||
| @@ -1,12 +1,12 @@ | |||
| 1 | //! embassy-net IEEE 802.15.4 driver | 1 | //! embassy-net IEEE 802.15.4 driver |
| 2 | 2 | ||
| 3 | use embassy_futures::select::{select3, Either3}; | 3 | use embassy_futures::select::{Either3, select3}; |
| 4 | use embassy_net_driver_channel::driver::LinkState; | 4 | use embassy_net_driver_channel::driver::LinkState; |
| 5 | use embassy_net_driver_channel::{self as ch}; | 5 | use embassy_net_driver_channel::{self as ch}; |
| 6 | use embassy_time::{Duration, Ticker}; | 6 | use embassy_time::{Duration, Ticker}; |
| 7 | 7 | ||
| 8 | use crate::radio::ieee802154::{Packet, Radio}; | ||
| 9 | use crate::radio::InterruptHandler; | 8 | use crate::radio::InterruptHandler; |
| 9 | use crate::radio::ieee802154::{Packet, Radio}; | ||
| 10 | use crate::{self as nrf, interrupt}; | 10 | use crate::{self as nrf, interrupt}; |
| 11 | 11 | ||
| 12 | /// MTU for the nrf radio. | 12 | /// MTU for the nrf radio. |
| @@ -32,12 +32,12 @@ impl<const N_RX: usize, const N_TX: usize> State<N_RX, N_TX> { | |||
| 32 | /// Background runner for the driver. | 32 | /// Background runner for the driver. |
| 33 | /// | 33 | /// |
| 34 | /// You must call `.run()` in a background task for the driver to operate. | 34 | /// You must call `.run()` in a background task for the driver to operate. |
| 35 | pub struct Runner<'d, T: nrf::radio::Instance> { | 35 | pub struct Runner<'d> { |
| 36 | radio: nrf::radio::ieee802154::Radio<'d, T>, | 36 | radio: nrf::radio::ieee802154::Radio<'d>, |
| 37 | ch: ch::Runner<'d, MTU>, | 37 | ch: ch::Runner<'d, MTU>, |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | impl<'d, T: nrf::radio::Instance> Runner<'d, T> { | 40 | impl<'d> Runner<'d> { |
| 41 | /// Drives the radio. Needs to run to use the driver. | 41 | /// Drives the radio. Needs to run to use the driver. |
| 42 | pub async fn run(mut self) -> ! { | 42 | pub async fn run(mut self) -> ! { |
| 43 | let (state_chan, mut rx_chan, mut tx_chan) = self.ch.split(); | 43 | let (state_chan, mut rx_chan, mut tx_chan) = self.ch.split(); |
| @@ -84,7 +84,7 @@ pub async fn new<'a, const N_RX: usize, const N_TX: usize, T: nrf::radio::Instan | |||
| 84 | radio: nrf::Peri<'a, T>, | 84 | radio: nrf::Peri<'a, T>, |
| 85 | irq: Irq, | 85 | irq: Irq, |
| 86 | state: &'a mut State<N_RX, N_TX>, | 86 | state: &'a mut State<N_RX, N_TX>, |
| 87 | ) -> Result<(Device<'a>, Runner<'a, T>), ()> | 87 | ) -> Result<(Device<'a>, Runner<'a>), ()> |
| 88 | where | 88 | where |
| 89 | Irq: interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'a, | 89 | Irq: interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'a, |
| 90 | { | 90 | { |
diff --git a/embassy-nrf/src/gpio.rs b/embassy-nrf/src/gpio.rs index ab5e7ed4b..7ed3a7927 100644 --- a/embassy-nrf/src/gpio.rs +++ b/embassy-nrf/src/gpio.rs | |||
| @@ -5,10 +5,10 @@ use core::convert::Infallible; | |||
| 5 | use core::hint::unreachable_unchecked; | 5 | use core::hint::unreachable_unchecked; |
| 6 | 6 | ||
| 7 | use cfg_if::cfg_if; | 7 | use cfg_if::cfg_if; |
| 8 | use embassy_hal_internal::{impl_peripheral, Peri, PeripheralType}; | 8 | use embassy_hal_internal::{Peri, PeripheralType, impl_peripheral}; |
| 9 | 9 | ||
| 10 | use crate::pac; | 10 | use crate::pac; |
| 11 | use crate::pac::common::{Reg, RW}; | 11 | use crate::pac::common::{RW, Reg}; |
| 12 | use crate::pac::gpio; | 12 | use crate::pac::gpio; |
| 13 | use crate::pac::gpio::vals; | 13 | use crate::pac::gpio::vals; |
| 14 | #[cfg(not(feature = "_nrf51"))] | 14 | #[cfg(not(feature = "_nrf51"))] |
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index 43e43f0bf..a490d5b60 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | //! GPIO task/event (GPIOTE) driver. | 1 | //! GPIO task/event (GPIOTE) driver. |
| 2 | 2 | ||
| 3 | use core::convert::Infallible; | 3 | use core::convert::Infallible; |
| 4 | use core::future::{poll_fn, Future}; | 4 | use core::future::{Future, poll_fn}; |
| 5 | use core::task::{Context, Poll}; | 5 | use core::task::{Context, Poll}; |
| 6 | 6 | ||
| 7 | use embassy_hal_internal::{impl_peripheral, Peri, PeripheralType}; | 7 | use embassy_hal_internal::{Peri, PeripheralType, impl_peripheral}; |
| 8 | use embassy_sync::waitqueue::AtomicWaker; | 8 | use embassy_sync::waitqueue::AtomicWaker; |
| 9 | 9 | ||
| 10 | use crate::gpio::{AnyPin, Flex, Input, Output, Pin as GpioPin, SealedPin as _}; | 10 | use crate::gpio::{AnyPin, Flex, Input, Output, Pin as GpioPin, SealedPin as _}; |
diff --git a/embassy-nrf/src/i2s.rs b/embassy-nrf/src/i2s.rs index 53de8deee..9cce9f1e8 100644 --- a/embassy-nrf/src/i2s.rs +++ b/embassy-nrf/src/i2s.rs | |||
| @@ -6,7 +6,7 @@ use core::future::poll_fn; | |||
| 6 | use core::marker::PhantomData; | 6 | use core::marker::PhantomData; |
| 7 | use core::mem::size_of; | 7 | use core::mem::size_of; |
| 8 | use core::ops::{Deref, DerefMut}; | 8 | use core::ops::{Deref, DerefMut}; |
| 9 | use core::sync::atomic::{compiler_fence, AtomicBool, Ordering}; | 9 | use core::sync::atomic::{AtomicBool, Ordering, compiler_fence}; |
| 10 | use core::task::Poll; | 10 | use core::task::Poll; |
| 11 | 11 | ||
| 12 | use embassy_hal_internal::drop::OnDrop; | 12 | use embassy_hal_internal::drop::OnDrop; |
| @@ -17,7 +17,7 @@ use crate::gpio::{AnyPin, Pin as GpioPin, PselBits}; | |||
| 17 | use crate::interrupt::typelevel::Interrupt; | 17 | use crate::interrupt::typelevel::Interrupt; |
| 18 | use crate::pac::i2s::vals; | 18 | use crate::pac::i2s::vals; |
| 19 | use crate::util::slice_in_ram_or; | 19 | use crate::util::slice_in_ram_or; |
| 20 | use crate::{interrupt, pac, EASY_DMA_SIZE}; | 20 | use crate::{EASY_DMA_SIZE, interrupt, pac}; |
| 21 | 21 | ||
| 22 | /// Type alias for `MultiBuffering` with 2 buffers. | 22 | /// Type alias for `MultiBuffering` with 2 buffers. |
| 23 | pub type DoubleBuffering<S, const NS: usize> = MultiBuffering<S, 2, NS>; | 23 | pub type DoubleBuffering<S, const NS: usize> = MultiBuffering<S, 2, NS>; |
| @@ -381,7 +381,7 @@ pub struct InterruptHandler<T: Instance> { | |||
| 381 | 381 | ||
| 382 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { | 382 | impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> { |
| 383 | unsafe fn on_interrupt() { | 383 | unsafe fn on_interrupt() { |
| 384 | let device = Device::<T>::new(); | 384 | let device = Device::new(T::regs()); |
| 385 | let s = T::state(); | 385 | let s = T::state(); |
| 386 | 386 | ||
| 387 | if device.is_tx_ptr_updated() { | 387 | if device.is_tx_ptr_updated() { |
| @@ -405,8 +405,9 @@ impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandl | |||
| 405 | } | 405 | } |
| 406 | 406 | ||
| 407 | /// I2S driver. | 407 | /// I2S driver. |
| 408 | pub struct I2S<'d, T: Instance> { | 408 | pub struct I2S<'d> { |
| 409 | i2s: Peri<'d, T>, | 409 | r: pac::i2s::I2s, |
| 410 | state: &'static State, | ||
| 410 | mck: Option<Peri<'d, AnyPin>>, | 411 | mck: Option<Peri<'d, AnyPin>>, |
| 411 | sck: Peri<'d, AnyPin>, | 412 | sck: Peri<'d, AnyPin>, |
| 412 | lrck: Peri<'d, AnyPin>, | 413 | lrck: Peri<'d, AnyPin>, |
| @@ -416,10 +417,10 @@ pub struct I2S<'d, T: Instance> { | |||
| 416 | config: Config, | 417 | config: Config, |
| 417 | } | 418 | } |
| 418 | 419 | ||
| 419 | impl<'d, T: Instance> I2S<'d, T> { | 420 | impl<'d> I2S<'d> { |
| 420 | /// Create a new I2S in master mode | 421 | /// Create a new I2S in master mode |
| 421 | pub fn new_master( | 422 | pub fn new_master<T: Instance>( |
| 422 | i2s: Peri<'d, T>, | 423 | _i2s: Peri<'d, T>, |
| 423 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 424 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 424 | mck: Peri<'d, impl GpioPin>, | 425 | mck: Peri<'d, impl GpioPin>, |
| 425 | sck: Peri<'d, impl GpioPin>, | 426 | sck: Peri<'d, impl GpioPin>, |
| @@ -427,8 +428,12 @@ impl<'d, T: Instance> I2S<'d, T> { | |||
| 427 | master_clock: MasterClock, | 428 | master_clock: MasterClock, |
| 428 | config: Config, | 429 | config: Config, |
| 429 | ) -> Self { | 430 | ) -> Self { |
| 431 | T::Interrupt::unpend(); | ||
| 432 | unsafe { T::Interrupt::enable() }; | ||
| 433 | |||
| 430 | Self { | 434 | Self { |
| 431 | i2s, | 435 | r: T::regs(), |
| 436 | state: T::state(), | ||
| 432 | mck: Some(mck.into()), | 437 | mck: Some(mck.into()), |
| 433 | sck: sck.into(), | 438 | sck: sck.into(), |
| 434 | lrck: lrck.into(), | 439 | lrck: lrck.into(), |
| @@ -440,15 +445,19 @@ impl<'d, T: Instance> I2S<'d, T> { | |||
| 440 | } | 445 | } |
| 441 | 446 | ||
| 442 | /// Create a new I2S in slave mode | 447 | /// Create a new I2S in slave mode |
| 443 | pub fn new_slave( | 448 | pub fn new_slave<T: Instance>( |
| 444 | i2s: Peri<'d, T>, | 449 | _i2s: Peri<'d, T>, |
| 445 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 450 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 446 | sck: Peri<'d, impl GpioPin>, | 451 | sck: Peri<'d, impl GpioPin>, |
| 447 | lrck: Peri<'d, impl GpioPin>, | 452 | lrck: Peri<'d, impl GpioPin>, |
| 448 | config: Config, | 453 | config: Config, |
| 449 | ) -> Self { | 454 | ) -> Self { |
| 455 | T::Interrupt::unpend(); | ||
| 456 | unsafe { T::Interrupt::enable() }; | ||
| 457 | |||
| 450 | Self { | 458 | Self { |
| 451 | i2s, | 459 | r: T::regs(), |
| 460 | state: T::state(), | ||
| 452 | mck: None, | 461 | mck: None, |
| 453 | sck: sck.into(), | 462 | sck: sck.into(), |
| 454 | lrck: lrck.into(), | 463 | lrck: lrck.into(), |
| @@ -464,10 +473,13 @@ impl<'d, T: Instance> I2S<'d, T> { | |||
| 464 | mut self, | 473 | mut self, |
| 465 | sdout: Peri<'d, impl GpioPin>, | 474 | sdout: Peri<'d, impl GpioPin>, |
| 466 | buffers: MultiBuffering<S, NB, NS>, | 475 | buffers: MultiBuffering<S, NB, NS>, |
| 467 | ) -> OutputStream<'d, T, S, NB, NS> { | 476 | ) -> OutputStream<'d, S, NB, NS> { |
| 468 | self.sdout = Some(sdout.into()); | 477 | self.sdout = Some(sdout.into()); |
| 478 | let p = self.build(); | ||
| 469 | OutputStream { | 479 | OutputStream { |
| 470 | _p: self.build(), | 480 | r: p.0, |
| 481 | state: p.1, | ||
| 482 | _phantom: PhantomData, | ||
| 471 | buffers, | 483 | buffers, |
| 472 | } | 484 | } |
| 473 | } | 485 | } |
| @@ -477,11 +489,14 @@ impl<'d, T: Instance> I2S<'d, T> { | |||
| 477 | mut self, | 489 | mut self, |
| 478 | sdin: Peri<'d, impl GpioPin>, | 490 | sdin: Peri<'d, impl GpioPin>, |
| 479 | buffers: MultiBuffering<S, NB, NS>, | 491 | buffers: MultiBuffering<S, NB, NS>, |
| 480 | ) -> InputStream<'d, T, S, NB, NS> { | 492 | ) -> InputStream<'d, S, NB, NS> { |
| 481 | self.sdin = Some(sdin.into()); | 493 | self.sdin = Some(sdin.into()); |
| 494 | let p = self.build(); | ||
| 482 | InputStream { | 495 | InputStream { |
| 483 | _p: self.build(), | 496 | r: p.0, |
| 497 | state: p.1, | ||
| 484 | buffers, | 498 | buffers, |
| 499 | _phantom: PhantomData, | ||
| 485 | } | 500 | } |
| 486 | } | 501 | } |
| 487 | 502 | ||
| @@ -492,30 +507,33 @@ impl<'d, T: Instance> I2S<'d, T> { | |||
| 492 | sdout: Peri<'d, impl GpioPin>, | 507 | sdout: Peri<'d, impl GpioPin>, |
| 493 | buffers_out: MultiBuffering<S, NB, NS>, | 508 | buffers_out: MultiBuffering<S, NB, NS>, |
| 494 | buffers_in: MultiBuffering<S, NB, NS>, | 509 | buffers_in: MultiBuffering<S, NB, NS>, |
| 495 | ) -> FullDuplexStream<'d, T, S, NB, NS> { | 510 | ) -> FullDuplexStream<'d, S, NB, NS> { |
| 496 | self.sdout = Some(sdout.into()); | 511 | self.sdout = Some(sdout.into()); |
| 497 | self.sdin = Some(sdin.into()); | 512 | self.sdin = Some(sdin.into()); |
| 513 | let p = self.build(); | ||
| 498 | 514 | ||
| 499 | FullDuplexStream { | 515 | FullDuplexStream { |
| 500 | _p: self.build(), | 516 | r: p.0, |
| 517 | state: p.1, | ||
| 518 | _phantom: PhantomData, | ||
| 501 | buffers_out, | 519 | buffers_out, |
| 502 | buffers_in, | 520 | buffers_in, |
| 503 | } | 521 | } |
| 504 | } | 522 | } |
| 505 | 523 | ||
| 506 | fn build(self) -> Peri<'d, T> { | 524 | fn build(self) -> (pac::i2s::I2s, &'static State) { |
| 507 | self.apply_config(); | 525 | self.apply_config(); |
| 508 | self.select_pins(); | 526 | self.select_pins(); |
| 509 | self.setup_interrupt(); | 527 | self.setup_interrupt(); |
| 510 | 528 | ||
| 511 | let device = Device::<T>::new(); | 529 | let device = Device::new(self.r); |
| 512 | device.enable(); | 530 | device.enable(); |
| 513 | 531 | ||
| 514 | self.i2s | 532 | (self.r, self.state) |
| 515 | } | 533 | } |
| 516 | 534 | ||
| 517 | fn apply_config(&self) { | 535 | fn apply_config(&self) { |
| 518 | let c = T::regs().config(); | 536 | let c = self.r.config(); |
| 519 | match &self.master_clock { | 537 | match &self.master_clock { |
| 520 | Some(MasterClock { freq, ratio }) => { | 538 | Some(MasterClock { freq, ratio }) => { |
| 521 | c.mode().write(|w| w.set_mode(vals::Mode::MASTER)); | 539 | c.mode().write(|w| w.set_mode(vals::Mode::MASTER)); |
| @@ -535,7 +553,7 @@ impl<'d, T: Instance> I2S<'d, T> { | |||
| 535 | } | 553 | } |
| 536 | 554 | ||
| 537 | fn select_pins(&self) { | 555 | fn select_pins(&self) { |
| 538 | let psel = T::regs().psel(); | 556 | let psel = self.r.psel(); |
| 539 | psel.mck().write_value(self.mck.psel_bits()); | 557 | psel.mck().write_value(self.mck.psel_bits()); |
| 540 | psel.sck().write_value(self.sck.psel_bits()); | 558 | psel.sck().write_value(self.sck.psel_bits()); |
| 541 | psel.lrck().write_value(self.lrck.psel_bits()); | 559 | psel.lrck().write_value(self.lrck.psel_bits()); |
| @@ -544,10 +562,9 @@ impl<'d, T: Instance> I2S<'d, T> { | |||
| 544 | } | 562 | } |
| 545 | 563 | ||
| 546 | fn setup_interrupt(&self) { | 564 | fn setup_interrupt(&self) { |
| 547 | T::Interrupt::unpend(); | 565 | // Interrupt is already set up in constructor |
| 548 | unsafe { T::Interrupt::enable() }; | ||
| 549 | 566 | ||
| 550 | let device = Device::<T>::new(); | 567 | let device = Device::new(self.r); |
| 551 | device.disable_tx_ptr_interrupt(); | 568 | device.disable_tx_ptr_interrupt(); |
| 552 | device.disable_rx_ptr_interrupt(); | 569 | device.disable_rx_ptr_interrupt(); |
| 553 | device.disable_stopped_interrupt(); | 570 | device.disable_stopped_interrupt(); |
| @@ -561,16 +578,16 @@ impl<'d, T: Instance> I2S<'d, T> { | |||
| 561 | device.enable_stopped_interrupt(); | 578 | device.enable_stopped_interrupt(); |
| 562 | } | 579 | } |
| 563 | 580 | ||
| 564 | async fn stop() { | 581 | async fn stop(r: pac::i2s::I2s, state: &State) { |
| 565 | compiler_fence(Ordering::SeqCst); | 582 | compiler_fence(Ordering::SeqCst); |
| 566 | 583 | ||
| 567 | let device = Device::<T>::new(); | 584 | let device = Device::new(r); |
| 568 | device.stop(); | 585 | device.stop(); |
| 569 | 586 | ||
| 570 | T::state().started.store(false, Ordering::Relaxed); | 587 | state.started.store(false, Ordering::Relaxed); |
| 571 | 588 | ||
| 572 | poll_fn(|cx| { | 589 | poll_fn(|cx| { |
| 573 | T::state().stop_waker.register(cx.waker()); | 590 | state.stop_waker.register(cx.waker()); |
| 574 | 591 | ||
| 575 | if device.is_stopped() { | 592 | if device.is_stopped() { |
| 576 | trace!("STOP: Ready"); | 593 | trace!("STOP: Ready"); |
| @@ -586,7 +603,7 @@ impl<'d, T: Instance> I2S<'d, T> { | |||
| 586 | device.disable(); | 603 | device.disable(); |
| 587 | } | 604 | } |
| 588 | 605 | ||
| 589 | async fn send_from_ram<S>(buffer_ptr: *const [S]) -> Result<(), Error> | 606 | async fn send_from_ram<S>(r: pac::i2s::I2s, state: &State, buffer_ptr: *const [S]) -> Result<(), Error> |
| 590 | where | 607 | where |
| 591 | S: Sample, | 608 | S: Sample, |
| 592 | { | 609 | { |
| @@ -596,22 +613,22 @@ impl<'d, T: Instance> I2S<'d, T> { | |||
| 596 | 613 | ||
| 597 | compiler_fence(Ordering::SeqCst); | 614 | compiler_fence(Ordering::SeqCst); |
| 598 | 615 | ||
| 599 | let device = Device::<T>::new(); | 616 | let device = Device::new(r); |
| 600 | 617 | ||
| 601 | device.update_tx(buffer_ptr)?; | 618 | device.update_tx(buffer_ptr)?; |
| 602 | 619 | ||
| 603 | Self::wait_tx_ptr_update().await; | 620 | Self::wait_tx_ptr_update(r, state).await; |
| 604 | 621 | ||
| 605 | compiler_fence(Ordering::SeqCst); | 622 | compiler_fence(Ordering::SeqCst); |
| 606 | 623 | ||
| 607 | Ok(()) | 624 | Ok(()) |
| 608 | } | 625 | } |
| 609 | 626 | ||
| 610 | async fn wait_tx_ptr_update() { | 627 | async fn wait_tx_ptr_update(r: pac::i2s::I2s, state: &State) { |
| 611 | let drop = OnDrop::new(move || { | 628 | let drop = OnDrop::new(move || { |
| 612 | trace!("TX DROP: Stopping"); | 629 | trace!("TX DROP: Stopping"); |
| 613 | 630 | ||
| 614 | let device = Device::<T>::new(); | 631 | let device = Device::new(r); |
| 615 | device.disable_tx_ptr_interrupt(); | 632 | device.disable_tx_ptr_interrupt(); |
| 616 | device.reset_tx_ptr_event(); | 633 | device.reset_tx_ptr_event(); |
| 617 | device.disable_tx(); | 634 | device.disable_tx(); |
| @@ -623,9 +640,9 @@ impl<'d, T: Instance> I2S<'d, T> { | |||
| 623 | }); | 640 | }); |
| 624 | 641 | ||
| 625 | poll_fn(|cx| { | 642 | poll_fn(|cx| { |
| 626 | T::state().tx_waker.register(cx.waker()); | 643 | state.tx_waker.register(cx.waker()); |
| 627 | 644 | ||
| 628 | let device = Device::<T>::new(); | 645 | let device = Device::new(r); |
| 629 | if device.is_tx_ptr_updated() { | 646 | if device.is_tx_ptr_updated() { |
| 630 | trace!("TX POLL: Ready"); | 647 | trace!("TX POLL: Ready"); |
| 631 | device.reset_tx_ptr_event(); | 648 | device.reset_tx_ptr_event(); |
| @@ -641,7 +658,7 @@ impl<'d, T: Instance> I2S<'d, T> { | |||
| 641 | drop.defuse(); | 658 | drop.defuse(); |
| 642 | } | 659 | } |
| 643 | 660 | ||
| 644 | async fn receive_from_ram<S>(buffer_ptr: *mut [S]) -> Result<(), Error> | 661 | async fn receive_from_ram<S>(r: pac::i2s::I2s, state: &State, buffer_ptr: *mut [S]) -> Result<(), Error> |
| 645 | where | 662 | where |
| 646 | S: Sample, | 663 | S: Sample, |
| 647 | { | 664 | { |
| @@ -652,22 +669,22 @@ impl<'d, T: Instance> I2S<'d, T> { | |||
| 652 | 669 | ||
| 653 | compiler_fence(Ordering::SeqCst); | 670 | compiler_fence(Ordering::SeqCst); |
| 654 | 671 | ||
| 655 | let device = Device::<T>::new(); | 672 | let device = Device::new(r); |
| 656 | 673 | ||
| 657 | device.update_rx(buffer_ptr)?; | 674 | device.update_rx(buffer_ptr)?; |
| 658 | 675 | ||
| 659 | Self::wait_rx_ptr_update().await; | 676 | Self::wait_rx_ptr_update(r, state).await; |
| 660 | 677 | ||
| 661 | compiler_fence(Ordering::SeqCst); | 678 | compiler_fence(Ordering::SeqCst); |
| 662 | 679 | ||
| 663 | Ok(()) | 680 | Ok(()) |
| 664 | } | 681 | } |
| 665 | 682 | ||
| 666 | async fn wait_rx_ptr_update() { | 683 | async fn wait_rx_ptr_update(r: pac::i2s::I2s, state: &State) { |
| 667 | let drop = OnDrop::new(move || { | 684 | let drop = OnDrop::new(move || { |
| 668 | trace!("RX DROP: Stopping"); | 685 | trace!("RX DROP: Stopping"); |
| 669 | 686 | ||
| 670 | let device = Device::<T>::new(); | 687 | let device = Device::new(r); |
| 671 | device.disable_rx_ptr_interrupt(); | 688 | device.disable_rx_ptr_interrupt(); |
| 672 | device.reset_rx_ptr_event(); | 689 | device.reset_rx_ptr_event(); |
| 673 | device.disable_rx(); | 690 | device.disable_rx(); |
| @@ -679,9 +696,9 @@ impl<'d, T: Instance> I2S<'d, T> { | |||
| 679 | }); | 696 | }); |
| 680 | 697 | ||
| 681 | poll_fn(|cx| { | 698 | poll_fn(|cx| { |
| 682 | T::state().rx_waker.register(cx.waker()); | 699 | state.rx_waker.register(cx.waker()); |
| 683 | 700 | ||
| 684 | let device = Device::<T>::new(); | 701 | let device = Device::new(r); |
| 685 | if device.is_rx_ptr_updated() { | 702 | if device.is_rx_ptr_updated() { |
| 686 | trace!("RX POLL: Ready"); | 703 | trace!("RX POLL: Ready"); |
| 687 | device.reset_rx_ptr_event(); | 704 | device.reset_rx_ptr_event(); |
| @@ -699,12 +716,14 @@ impl<'d, T: Instance> I2S<'d, T> { | |||
| 699 | } | 716 | } |
| 700 | 717 | ||
| 701 | /// I2S output | 718 | /// I2S output |
| 702 | pub struct OutputStream<'d, T: Instance, S: Sample, const NB: usize, const NS: usize> { | 719 | pub struct OutputStream<'d, S: Sample, const NB: usize, const NS: usize> { |
| 703 | _p: Peri<'d, T>, | 720 | r: pac::i2s::I2s, |
| 721 | state: &'static State, | ||
| 704 | buffers: MultiBuffering<S, NB, NS>, | 722 | buffers: MultiBuffering<S, NB, NS>, |
| 723 | _phantom: PhantomData<&'d ()>, | ||
| 705 | } | 724 | } |
| 706 | 725 | ||
| 707 | impl<'d, T: Instance, S: Sample, const NB: usize, const NS: usize> OutputStream<'d, T, S, NB, NS> { | 726 | impl<'d, S: Sample, const NB: usize, const NS: usize> OutputStream<'d, S, NB, NS> { |
| 708 | /// Get a mutable reference to the current buffer. | 727 | /// Get a mutable reference to the current buffer. |
| 709 | pub fn buffer(&mut self) -> &mut [S] { | 728 | pub fn buffer(&mut self) -> &mut [S] { |
| 710 | self.buffers.get_mut() | 729 | self.buffers.get_mut() |
| @@ -715,10 +734,9 @@ impl<'d, T: Instance, S: Sample, const NB: usize, const NS: usize> OutputStream< | |||
| 715 | where | 734 | where |
| 716 | S: Sample, | 735 | S: Sample, |
| 717 | { | 736 | { |
| 718 | let device = Device::<T>::new(); | 737 | let device = Device::new(self.r); |
| 719 | 738 | ||
| 720 | let s = T::state(); | 739 | if self.state.started.load(Ordering::Relaxed) { |
| 721 | if s.started.load(Ordering::Relaxed) { | ||
| 722 | self.stop().await; | 740 | self.stop().await; |
| 723 | } | 741 | } |
| 724 | 742 | ||
| @@ -727,11 +745,11 @@ impl<'d, T: Instance, S: Sample, const NB: usize, const NS: usize> OutputStream< | |||
| 727 | 745 | ||
| 728 | device.update_tx(self.buffers.switch())?; | 746 | device.update_tx(self.buffers.switch())?; |
| 729 | 747 | ||
| 730 | s.started.store(true, Ordering::Relaxed); | 748 | self.state.started.store(true, Ordering::Relaxed); |
| 731 | 749 | ||
| 732 | device.start(); | 750 | device.start(); |
| 733 | 751 | ||
| 734 | I2S::<T>::wait_tx_ptr_update().await; | 752 | I2S::wait_tx_ptr_update(self.r, self.state).await; |
| 735 | 753 | ||
| 736 | Ok(()) | 754 | Ok(()) |
| 737 | } | 755 | } |
| @@ -739,7 +757,7 @@ impl<'d, T: Instance, S: Sample, const NB: usize, const NS: usize> OutputStream< | |||
| 739 | /// Stops the I2S transfer and waits until it has stopped. | 757 | /// Stops the I2S transfer and waits until it has stopped. |
| 740 | #[inline(always)] | 758 | #[inline(always)] |
| 741 | pub async fn stop(&self) { | 759 | pub async fn stop(&self) { |
| 742 | I2S::<T>::stop().await | 760 | I2S::stop(self.r, self.state).await |
| 743 | } | 761 | } |
| 744 | 762 | ||
| 745 | /// Sends the current buffer for transmission in the DMA. | 763 | /// Sends the current buffer for transmission in the DMA. |
| @@ -748,17 +766,19 @@ impl<'d, T: Instance, S: Sample, const NB: usize, const NS: usize> OutputStream< | |||
| 748 | where | 766 | where |
| 749 | S: Sample, | 767 | S: Sample, |
| 750 | { | 768 | { |
| 751 | I2S::<T>::send_from_ram(self.buffers.switch()).await | 769 | I2S::send_from_ram(self.r, self.state, self.buffers.switch()).await |
| 752 | } | 770 | } |
| 753 | } | 771 | } |
| 754 | 772 | ||
| 755 | /// I2S input | 773 | /// I2S input |
| 756 | pub struct InputStream<'d, T: Instance, S: Sample, const NB: usize, const NS: usize> { | 774 | pub struct InputStream<'d, S: Sample, const NB: usize, const NS: usize> { |
| 757 | _p: Peri<'d, T>, | 775 | r: pac::i2s::I2s, |
| 776 | state: &'static State, | ||
| 758 | buffers: MultiBuffering<S, NB, NS>, | 777 | buffers: MultiBuffering<S, NB, NS>, |
| 778 | _phantom: PhantomData<&'d ()>, | ||
| 759 | } | 779 | } |
| 760 | 780 | ||
| 761 | impl<'d, T: Instance, S: Sample, const NB: usize, const NS: usize> InputStream<'d, T, S, NB, NS> { | 781 | impl<'d, S: Sample, const NB: usize, const NS: usize> InputStream<'d, S, NB, NS> { |
| 762 | /// Get a mutable reference to the current buffer. | 782 | /// Get a mutable reference to the current buffer. |
| 763 | pub fn buffer(&mut self) -> &mut [S] { | 783 | pub fn buffer(&mut self) -> &mut [S] { |
| 764 | self.buffers.get_mut() | 784 | self.buffers.get_mut() |
| @@ -769,10 +789,9 @@ impl<'d, T: Instance, S: Sample, const NB: usize, const NS: usize> InputStream<' | |||
| 769 | where | 789 | where |
| 770 | S: Sample, | 790 | S: Sample, |
| 771 | { | 791 | { |
| 772 | let device = Device::<T>::new(); | 792 | let device = Device::new(self.r); |
| 773 | 793 | ||
| 774 | let s = T::state(); | 794 | if self.state.started.load(Ordering::Relaxed) { |
| 775 | if s.started.load(Ordering::Relaxed) { | ||
| 776 | self.stop().await; | 795 | self.stop().await; |
| 777 | } | 796 | } |
| 778 | 797 | ||
| @@ -781,11 +800,11 @@ impl<'d, T: Instance, S: Sample, const NB: usize, const NS: usize> InputStream<' | |||
| 781 | 800 | ||
| 782 | device.update_rx(self.buffers.switch())?; | 801 | device.update_rx(self.buffers.switch())?; |
| 783 | 802 | ||
| 784 | s.started.store(true, Ordering::Relaxed); | 803 | self.state.started.store(true, Ordering::Relaxed); |
| 785 | 804 | ||
| 786 | device.start(); | 805 | device.start(); |
| 787 | 806 | ||
| 788 | I2S::<T>::wait_rx_ptr_update().await; | 807 | I2S::wait_rx_ptr_update(self.r, self.state).await; |
| 789 | 808 | ||
| 790 | Ok(()) | 809 | Ok(()) |
| 791 | } | 810 | } |
| @@ -793,7 +812,7 @@ impl<'d, T: Instance, S: Sample, const NB: usize, const NS: usize> InputStream<' | |||
| 793 | /// Stops the I2S transfer and waits until it has stopped. | 812 | /// Stops the I2S transfer and waits until it has stopped. |
| 794 | #[inline(always)] | 813 | #[inline(always)] |
| 795 | pub async fn stop(&self) { | 814 | pub async fn stop(&self) { |
| 796 | I2S::<T>::stop().await | 815 | I2S::stop(self.r, self.state).await |
| 797 | } | 816 | } |
| 798 | 817 | ||
| 799 | /// Sets the current buffer for reception from the DMA. | 818 | /// Sets the current buffer for reception from the DMA. |
| @@ -803,18 +822,20 @@ impl<'d, T: Instance, S: Sample, const NB: usize, const NS: usize> InputStream<' | |||
| 803 | where | 822 | where |
| 804 | S: Sample, | 823 | S: Sample, |
| 805 | { | 824 | { |
| 806 | I2S::<T>::receive_from_ram(self.buffers.switch_mut()).await | 825 | I2S::receive_from_ram(self.r, self.state, self.buffers.switch_mut()).await |
| 807 | } | 826 | } |
| 808 | } | 827 | } |
| 809 | 828 | ||
| 810 | /// I2S full duplex stream (input & output) | 829 | /// I2S full duplex stream (input & output) |
| 811 | pub struct FullDuplexStream<'d, T: Instance, S: Sample, const NB: usize, const NS: usize> { | 830 | pub struct FullDuplexStream<'d, S: Sample, const NB: usize, const NS: usize> { |
| 812 | _p: Peri<'d, T>, | 831 | r: pac::i2s::I2s, |
| 832 | state: &'static State, | ||
| 813 | buffers_out: MultiBuffering<S, NB, NS>, | 833 | buffers_out: MultiBuffering<S, NB, NS>, |
| 814 | buffers_in: MultiBuffering<S, NB, NS>, | 834 | buffers_in: MultiBuffering<S, NB, NS>, |
| 835 | _phantom: PhantomData<&'d ()>, | ||
| 815 | } | 836 | } |
| 816 | 837 | ||
| 817 | impl<'d, T: Instance, S: Sample, const NB: usize, const NS: usize> FullDuplexStream<'d, T, S, NB, NS> { | 838 | impl<'d, S: Sample, const NB: usize, const NS: usize> FullDuplexStream<'d, S, NB, NS> { |
| 818 | /// Get the current output and input buffers. | 839 | /// Get the current output and input buffers. |
| 819 | pub fn buffers(&mut self) -> (&mut [S], &[S]) { | 840 | pub fn buffers(&mut self) -> (&mut [S], &[S]) { |
| 820 | (self.buffers_out.get_mut(), self.buffers_in.get()) | 841 | (self.buffers_out.get_mut(), self.buffers_in.get()) |
| @@ -825,10 +846,9 @@ impl<'d, T: Instance, S: Sample, const NB: usize, const NS: usize> FullDuplexStr | |||
| 825 | where | 846 | where |
| 826 | S: Sample, | 847 | S: Sample, |
| 827 | { | 848 | { |
| 828 | let device = Device::<T>::new(); | 849 | let device = Device::new(self.r); |
| 829 | 850 | ||
| 830 | let s = T::state(); | 851 | if self.state.started.load(Ordering::Relaxed) { |
| 831 | if s.started.load(Ordering::Relaxed) { | ||
| 832 | self.stop().await; | 852 | self.stop().await; |
| 833 | } | 853 | } |
| 834 | 854 | ||
| @@ -839,12 +859,12 @@ impl<'d, T: Instance, S: Sample, const NB: usize, const NS: usize> FullDuplexStr | |||
| 839 | device.update_tx(self.buffers_out.switch())?; | 859 | device.update_tx(self.buffers_out.switch())?; |
| 840 | device.update_rx(self.buffers_in.switch_mut())?; | 860 | device.update_rx(self.buffers_in.switch_mut())?; |
| 841 | 861 | ||
| 842 | s.started.store(true, Ordering::Relaxed); | 862 | self.state.started.store(true, Ordering::Relaxed); |
| 843 | 863 | ||
| 844 | device.start(); | 864 | device.start(); |
| 845 | 865 | ||
| 846 | I2S::<T>::wait_tx_ptr_update().await; | 866 | I2S::wait_tx_ptr_update(self.r, self.state).await; |
| 847 | I2S::<T>::wait_rx_ptr_update().await; | 867 | I2S::wait_rx_ptr_update(self.r, self.state).await; |
| 848 | 868 | ||
| 849 | Ok(()) | 869 | Ok(()) |
| 850 | } | 870 | } |
| @@ -852,7 +872,7 @@ impl<'d, T: Instance, S: Sample, const NB: usize, const NS: usize> FullDuplexStr | |||
| 852 | /// Stops the I2S transfer and waits until it has stopped. | 872 | /// Stops the I2S transfer and waits until it has stopped. |
| 853 | #[inline(always)] | 873 | #[inline(always)] |
| 854 | pub async fn stop(&self) { | 874 | pub async fn stop(&self) { |
| 855 | I2S::<T>::stop().await | 875 | I2S::stop(self.r, self.state).await |
| 856 | } | 876 | } |
| 857 | 877 | ||
| 858 | /// Sets the current buffers for output and input for transmission/reception from the DMA. | 878 | /// Sets the current buffers for output and input for transmission/reception from the DMA. |
| @@ -861,18 +881,18 @@ impl<'d, T: Instance, S: Sample, const NB: usize, const NS: usize> FullDuplexStr | |||
| 861 | where | 881 | where |
| 862 | S: Sample, | 882 | S: Sample, |
| 863 | { | 883 | { |
| 864 | I2S::<T>::send_from_ram(self.buffers_out.switch()).await?; | 884 | I2S::send_from_ram(self.r, self.state, self.buffers_out.switch()).await?; |
| 865 | I2S::<T>::receive_from_ram(self.buffers_in.switch_mut()).await?; | 885 | I2S::receive_from_ram(self.r, self.state, self.buffers_in.switch_mut()).await?; |
| 866 | Ok(()) | 886 | Ok(()) |
| 867 | } | 887 | } |
| 868 | } | 888 | } |
| 869 | 889 | ||
| 870 | /// Helper encapsulating common I2S device operations. | 890 | /// Helper encapsulating common I2S device operations. |
| 871 | struct Device<T>(pac::i2s::I2s, PhantomData<T>); | 891 | struct Device(pac::i2s::I2s); |
| 872 | 892 | ||
| 873 | impl<T: Instance> Device<T> { | 893 | impl Device { |
| 874 | fn new() -> Self { | 894 | fn new(r: pac::i2s::I2s) -> Self { |
| 875 | Self(T::regs(), PhantomData) | 895 | Self(r) |
| 876 | } | 896 | } |
| 877 | 897 | ||
| 878 | #[inline(always)] | 898 | #[inline(always)] |
diff --git a/embassy-nrf/src/ipc.rs b/embassy-nrf/src/ipc.rs index a8a08c911..a40c36c99 100644 --- a/embassy-nrf/src/ipc.rs +++ b/embassy-nrf/src/ipc.rs | |||
| @@ -134,97 +134,99 @@ impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandl | |||
| 134 | 134 | ||
| 135 | /// IPC driver | 135 | /// IPC driver |
| 136 | #[non_exhaustive] | 136 | #[non_exhaustive] |
| 137 | pub struct Ipc<'d, T: Instance> { | 137 | pub struct Ipc<'d> { |
| 138 | /// Event 0 | 138 | /// Event 0 |
| 139 | pub event0: Event<'d, T>, | 139 | pub event0: Event<'d>, |
| 140 | /// Event 1 | 140 | /// Event 1 |
| 141 | pub event1: Event<'d, T>, | 141 | pub event1: Event<'d>, |
| 142 | /// Event 2 | 142 | /// Event 2 |
| 143 | pub event2: Event<'d, T>, | 143 | pub event2: Event<'d>, |
| 144 | /// Event 3 | 144 | /// Event 3 |
| 145 | pub event3: Event<'d, T>, | 145 | pub event3: Event<'d>, |
| 146 | /// Event 4 | 146 | /// Event 4 |
| 147 | pub event4: Event<'d, T>, | 147 | pub event4: Event<'d>, |
| 148 | /// Event 5 | 148 | /// Event 5 |
| 149 | pub event5: Event<'d, T>, | 149 | pub event5: Event<'d>, |
| 150 | /// Event 6 | 150 | /// Event 6 |
| 151 | pub event6: Event<'d, T>, | 151 | pub event6: Event<'d>, |
| 152 | /// Event 7 | 152 | /// Event 7 |
| 153 | pub event7: Event<'d, T>, | 153 | pub event7: Event<'d>, |
| 154 | /// Event 8 | 154 | /// Event 8 |
| 155 | pub event8: Event<'d, T>, | 155 | pub event8: Event<'d>, |
| 156 | /// Event 9 | 156 | /// Event 9 |
| 157 | pub event9: Event<'d, T>, | 157 | pub event9: Event<'d>, |
| 158 | /// Event 10 | 158 | /// Event 10 |
| 159 | pub event10: Event<'d, T>, | 159 | pub event10: Event<'d>, |
| 160 | /// Event 11 | 160 | /// Event 11 |
| 161 | pub event11: Event<'d, T>, | 161 | pub event11: Event<'d>, |
| 162 | /// Event 12 | 162 | /// Event 12 |
| 163 | pub event12: Event<'d, T>, | 163 | pub event12: Event<'d>, |
| 164 | /// Event 13 | 164 | /// Event 13 |
| 165 | pub event13: Event<'d, T>, | 165 | pub event13: Event<'d>, |
| 166 | /// Event 14 | 166 | /// Event 14 |
| 167 | pub event14: Event<'d, T>, | 167 | pub event14: Event<'d>, |
| 168 | /// Event 15 | 168 | /// Event 15 |
| 169 | pub event15: Event<'d, T>, | 169 | pub event15: Event<'d>, |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | impl<'d, T: Instance> Ipc<'d, T> { | 172 | impl<'d> Ipc<'d> { |
| 173 | /// Create a new IPC driver. | 173 | /// Create a new IPC driver. |
| 174 | pub fn new( | 174 | pub fn new<T: Instance>( |
| 175 | _p: Peri<'d, T>, | 175 | _p: Peri<'d, T>, |
| 176 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 176 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 177 | ) -> Self { | 177 | ) -> Self { |
| 178 | T::Interrupt::unpend(); | 178 | T::Interrupt::unpend(); |
| 179 | unsafe { T::Interrupt::enable() }; | 179 | unsafe { T::Interrupt::enable() }; |
| 180 | 180 | ||
| 181 | let _phantom = PhantomData; | 181 | let r = T::regs(); |
| 182 | let state = T::state(); | ||
| 182 | #[rustfmt::skip] | 183 | #[rustfmt::skip] |
| 183 | let r = Self { // attributes on expressions are experimental | 184 | let result = Self { // attributes on expressions are experimental |
| 184 | event0: Event { number: EventNumber::Event0, _phantom }, | 185 | event0: Event { number: EventNumber::Event0, r, state, _phantom: PhantomData }, |
| 185 | event1: Event { number: EventNumber::Event1, _phantom }, | 186 | event1: Event { number: EventNumber::Event1, r, state, _phantom: PhantomData }, |
| 186 | event2: Event { number: EventNumber::Event2, _phantom }, | 187 | event2: Event { number: EventNumber::Event2, r, state, _phantom: PhantomData }, |
| 187 | event3: Event { number: EventNumber::Event3, _phantom }, | 188 | event3: Event { number: EventNumber::Event3, r, state, _phantom: PhantomData }, |
| 188 | event4: Event { number: EventNumber::Event4, _phantom }, | 189 | event4: Event { number: EventNumber::Event4, r, state, _phantom: PhantomData }, |
| 189 | event5: Event { number: EventNumber::Event5, _phantom }, | 190 | event5: Event { number: EventNumber::Event5, r, state, _phantom: PhantomData }, |
| 190 | event6: Event { number: EventNumber::Event6, _phantom }, | 191 | event6: Event { number: EventNumber::Event6, r, state, _phantom: PhantomData }, |
| 191 | event7: Event { number: EventNumber::Event7, _phantom }, | 192 | event7: Event { number: EventNumber::Event7, r, state, _phantom: PhantomData }, |
| 192 | event8: Event { number: EventNumber::Event8, _phantom }, | 193 | event8: Event { number: EventNumber::Event8, r, state, _phantom: PhantomData }, |
| 193 | event9: Event { number: EventNumber::Event9, _phantom }, | 194 | event9: Event { number: EventNumber::Event9, r, state, _phantom: PhantomData }, |
| 194 | event10: Event { number: EventNumber::Event10, _phantom }, | 195 | event10: Event { number: EventNumber::Event10, r, state, _phantom: PhantomData }, |
| 195 | event11: Event { number: EventNumber::Event11, _phantom }, | 196 | event11: Event { number: EventNumber::Event11, r, state, _phantom: PhantomData }, |
| 196 | event12: Event { number: EventNumber::Event12, _phantom }, | 197 | event12: Event { number: EventNumber::Event12, r, state, _phantom: PhantomData }, |
| 197 | event13: Event { number: EventNumber::Event13, _phantom }, | 198 | event13: Event { number: EventNumber::Event13, r, state, _phantom: PhantomData }, |
| 198 | event14: Event { number: EventNumber::Event14, _phantom }, | 199 | event14: Event { number: EventNumber::Event14, r, state, _phantom: PhantomData }, |
| 199 | event15: Event { number: EventNumber::Event15, _phantom }, | 200 | event15: Event { number: EventNumber::Event15, r, state, _phantom: PhantomData }, |
| 200 | }; | 201 | }; |
| 201 | r | 202 | result |
| 202 | } | 203 | } |
| 203 | } | 204 | } |
| 204 | 205 | ||
| 205 | /// IPC event | 206 | /// IPC event |
| 206 | pub struct Event<'d, T: Instance> { | 207 | pub struct Event<'d> { |
| 207 | number: EventNumber, | 208 | number: EventNumber, |
| 208 | _phantom: PhantomData<&'d T>, | 209 | r: pac::ipc::Ipc, |
| 210 | state: &'static State, | ||
| 211 | _phantom: PhantomData<&'d ()>, | ||
| 209 | } | 212 | } |
| 210 | 213 | ||
| 211 | impl<'d, T: Instance> Event<'d, T> { | 214 | impl<'d> Event<'d> { |
| 212 | /// Trigger the event. | 215 | /// Trigger the event. |
| 213 | pub fn trigger(&self) { | 216 | pub fn trigger(&self) { |
| 214 | let nr = self.number; | 217 | let nr = self.number; |
| 215 | T::regs().tasks_send(nr as usize).write_value(1); | 218 | self.r.tasks_send(nr as usize).write_value(1); |
| 216 | } | 219 | } |
| 217 | 220 | ||
| 218 | /// Wait for the event to be triggered. | 221 | /// Wait for the event to be triggered. |
| 219 | pub async fn wait(&mut self) { | 222 | pub async fn wait(&mut self) { |
| 220 | let regs = T::regs(); | ||
| 221 | let nr = self.number as usize; | 223 | let nr = self.number as usize; |
| 222 | regs.intenset().write(|w| w.0 = 1 << nr); | 224 | self.r.intenset().write(|w| w.0 = 1 << nr); |
| 223 | poll_fn(|cx| { | 225 | poll_fn(|cx| { |
| 224 | T::state().wakers[nr].register(cx.waker()); | 226 | self.state.wakers[nr].register(cx.waker()); |
| 225 | 227 | ||
| 226 | if regs.events_receive(nr).read() == 1 { | 228 | if self.r.events_receive(nr).read() == 1 { |
| 227 | regs.events_receive(nr).write_value(0x00); | 229 | self.r.events_receive(nr).write_value(0x00); |
| 228 | Poll::Ready(()) | 230 | Poll::Ready(()) |
| 229 | } else { | 231 | } else { |
| 230 | Poll::Pending | 232 | Poll::Pending |
| @@ -239,16 +241,17 @@ impl<'d, T: Instance> Event<'d, T> { | |||
| 239 | } | 241 | } |
| 240 | 242 | ||
| 241 | /// Create a handle that can trigger the event. | 243 | /// Create a handle that can trigger the event. |
| 242 | pub fn trigger_handle(&self) -> EventTrigger<'d, T> { | 244 | pub fn trigger_handle(&self) -> EventTrigger<'d> { |
| 243 | EventTrigger { | 245 | EventTrigger { |
| 244 | number: self.number, | 246 | number: self.number, |
| 247 | r: self.r, | ||
| 245 | _phantom: PhantomData, | 248 | _phantom: PhantomData, |
| 246 | } | 249 | } |
| 247 | } | 250 | } |
| 248 | 251 | ||
| 249 | /// Configure the channels the event will broadcast to | 252 | /// Configure the channels the event will broadcast to |
| 250 | pub fn configure_trigger<I: IntoIterator<Item = IpcChannel>>(&mut self, channels: I) { | 253 | pub fn configure_trigger<I: IntoIterator<Item = IpcChannel>>(&mut self, channels: I) { |
| 251 | T::regs().send_cnf(self.number as usize).write(|w| { | 254 | self.r.send_cnf(self.number as usize).write(|w| { |
| 252 | for channel in channels { | 255 | for channel in channels { |
| 253 | w.0 |= channel.mask(); | 256 | w.0 |= channel.mask(); |
| 254 | } | 257 | } |
| @@ -257,7 +260,7 @@ impl<'d, T: Instance> Event<'d, T> { | |||
| 257 | 260 | ||
| 258 | /// Configure the channels the event will listen on | 261 | /// Configure the channels the event will listen on |
| 259 | pub fn configure_wait<I: IntoIterator<Item = IpcChannel>>(&mut self, channels: I) { | 262 | pub fn configure_wait<I: IntoIterator<Item = IpcChannel>>(&mut self, channels: I) { |
| 260 | T::regs().receive_cnf(self.number as usize).write(|w| { | 263 | self.r.receive_cnf(self.number as usize).write(|w| { |
| 261 | for channel in channels { | 264 | for channel in channels { |
| 262 | w.0 |= channel.mask(); | 265 | w.0 |= channel.mask(); |
| 263 | } | 266 | } |
| @@ -267,22 +270,25 @@ impl<'d, T: Instance> Event<'d, T> { | |||
| 267 | /// Get the task for the IPC event to use with PPI. | 270 | /// Get the task for the IPC event to use with PPI. |
| 268 | pub fn task(&self) -> ppi::Task<'d> { | 271 | pub fn task(&self) -> ppi::Task<'d> { |
| 269 | let nr = self.number as usize; | 272 | let nr = self.number as usize; |
| 270 | let regs = T::regs(); | 273 | ppi::Task::from_reg(self.r.tasks_send(nr)) |
| 271 | ppi::Task::from_reg(regs.tasks_send(nr)) | ||
| 272 | } | 274 | } |
| 273 | 275 | ||
| 274 | /// Get the event for the IPC event to use with PPI. | 276 | /// Get the event for the IPC event to use with PPI. |
| 275 | pub fn event(&self) -> ppi::Event<'d> { | 277 | pub fn event(&self) -> ppi::Event<'d> { |
| 276 | let nr = self.number as usize; | 278 | let nr = self.number as usize; |
| 277 | let regs = T::regs(); | 279 | ppi::Event::from_reg(self.r.events_receive(nr)) |
| 278 | ppi::Event::from_reg(regs.events_receive(nr)) | ||
| 279 | } | 280 | } |
| 280 | 281 | ||
| 281 | /// Reborrow into a "child" Event. | 282 | /// Reborrow into a "child" Event. |
| 282 | /// | 283 | /// |
| 283 | /// `self` will stay borrowed until the child Event is dropped. | 284 | /// `self` will stay borrowed until the child Event is dropped. |
| 284 | pub fn reborrow(&mut self) -> Event<'_, T> { | 285 | pub fn reborrow(&mut self) -> Event<'_> { |
| 285 | Self { ..*self } | 286 | Event { |
| 287 | number: self.number, | ||
| 288 | r: self.r, | ||
| 289 | state: self.state, | ||
| 290 | _phantom: PhantomData, | ||
| 291 | } | ||
| 286 | } | 292 | } |
| 287 | 293 | ||
| 288 | /// Steal an IPC event by number. | 294 | /// Steal an IPC event by number. |
| @@ -290,9 +296,11 @@ impl<'d, T: Instance> Event<'d, T> { | |||
| 290 | /// # Safety | 296 | /// # Safety |
| 291 | /// | 297 | /// |
| 292 | /// The event number must not be in use by another [`Event`]. | 298 | /// The event number must not be in use by another [`Event`]. |
| 293 | pub unsafe fn steal(number: EventNumber) -> Self { | 299 | pub unsafe fn steal<T: Instance>(number: EventNumber) -> Self { |
| 294 | Self { | 300 | Self { |
| 295 | number, | 301 | number, |
| 302 | r: T::regs(), | ||
| 303 | state: T::state(), | ||
| 296 | _phantom: PhantomData, | 304 | _phantom: PhantomData, |
| 297 | } | 305 | } |
| 298 | } | 306 | } |
| @@ -301,17 +309,17 @@ impl<'d, T: Instance> Event<'d, T> { | |||
| 301 | /// A handle that can trigger an IPC event. | 309 | /// A handle that can trigger an IPC event. |
| 302 | /// | 310 | /// |
| 303 | /// This `struct` is returned by [`Event::trigger_handle`]. | 311 | /// This `struct` is returned by [`Event::trigger_handle`]. |
| 304 | #[derive(Debug, Copy, Clone)] | 312 | pub struct EventTrigger<'d> { |
| 305 | pub struct EventTrigger<'d, T: Instance> { | ||
| 306 | number: EventNumber, | 313 | number: EventNumber, |
| 307 | _phantom: PhantomData<&'d T>, | 314 | r: pac::ipc::Ipc, |
| 315 | _phantom: PhantomData<&'d ()>, | ||
| 308 | } | 316 | } |
| 309 | 317 | ||
| 310 | impl<T: Instance> EventTrigger<'_, T> { | 318 | impl EventTrigger<'_> { |
| 311 | /// Trigger the event. | 319 | /// Trigger the event. |
| 312 | pub fn trigger(&self) { | 320 | pub fn trigger(&self) { |
| 313 | let nr = self.number; | 321 | let nr = self.number; |
| 314 | T::regs().tasks_send(nr as usize).write_value(1); | 322 | self.r.tasks_send(nr as usize).write_value(1); |
| 315 | } | 323 | } |
| 316 | 324 | ||
| 317 | /// Returns the [`EventNumber`] of the event. | 325 | /// Returns the [`EventNumber`] of the event. |
diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs index 7c26a6184..1b7fb7e7f 100644 --- a/embassy-nrf/src/lib.rs +++ b/embassy-nrf/src/lib.rs | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![allow(async_fn_in_trait)] | 2 | #![allow(async_fn_in_trait)] |
| 3 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 3 | #![cfg_attr( | 4 | #![cfg_attr( |
| 4 | docsrs, | 5 | docsrs, |
| 5 | doc = "<div style='padding:30px;background:#810;color:#fff;text-align:center;'><p>You might want to <a href='https://docs.embassy.dev/embassy-nrf'>browse the `embassy-nrf` documentation on the Embassy website</a> instead.</p><p>The documentation here on `docs.rs` is built for a single chip only (nRF52840 in particular), while on the Embassy website you can pick your exact chip from the top menu. Available peripherals and their APIs change depending on the chip.</p></div>\n\n" | 6 | doc = "<div style='padding:30px;background:#810;color:#fff;text-align:center;'><p>You might want to <a href='https://docs.embassy.dev/embassy-nrf'>browse the `embassy-nrf` documentation on the Embassy website</a> instead.</p><p>The documentation here on `docs.rs` is built for a single chip only (nRF52840 in particular), while on the Embassy website you can pick your exact chip from the top menu. Available peripherals and their APIs change depending on the chip.</p></div>\n\n" |
| @@ -252,7 +253,7 @@ macro_rules! bind_interrupts { | |||
| 252 | 253 | ||
| 253 | $( | 254 | $( |
| 254 | #[allow(non_snake_case)] | 255 | #[allow(non_snake_case)] |
| 255 | #[no_mangle] | 256 | #[unsafe(no_mangle)] |
| 256 | $(#[cfg($cond_irq)])? | 257 | $(#[cfg($cond_irq)])? |
| 257 | unsafe extern "C" fn $irq() { | 258 | unsafe extern "C" fn $irq() { |
| 258 | unsafe { | 259 | unsafe { |
| @@ -284,7 +285,7 @@ macro_rules! bind_interrupts { | |||
| 284 | pub use chip::pac; | 285 | pub use chip::pac; |
| 285 | #[cfg(not(feature = "unstable-pac"))] | 286 | #[cfg(not(feature = "unstable-pac"))] |
| 286 | pub(crate) use chip::pac; | 287 | pub(crate) use chip::pac; |
| 287 | pub use chip::{peripherals, Peripherals, EASY_DMA_SIZE}; | 288 | pub use chip::{EASY_DMA_SIZE, Peripherals, peripherals}; |
| 288 | pub use embassy_hal_internal::{Peri, PeripheralType}; | 289 | pub use embassy_hal_internal::{Peri, PeripheralType}; |
| 289 | 290 | ||
| 290 | pub use crate::chip::interrupt; | 291 | pub use crate::chip::interrupt; |
| @@ -406,9 +407,10 @@ pub mod config { | |||
| 406 | /// Settings for the internal capacitors. | 407 | /// Settings for the internal capacitors. |
| 407 | #[cfg(feature = "nrf5340-app-s")] | 408 | #[cfg(feature = "nrf5340-app-s")] |
| 408 | pub struct InternalCapacitors { | 409 | pub struct InternalCapacitors { |
| 409 | /// Config for the internal capacitors on pins XC1 and XC2. | 410 | /// Config for the internal capacitors on pins XC1 and XC2. Pass `None` to not touch it. |
| 410 | pub hfxo: Option<HfxoCapacitance>, | 411 | pub hfxo: Option<HfxoCapacitance>, |
| 411 | /// Config for the internal capacitors between pins XL1 and XL2. | 412 | /// Config for the internal capacitors between pins XL1 and XL2. Pass `None` to not touch |
| 413 | /// it. | ||
| 412 | pub lfxo: Option<LfxoCapacitance>, | 414 | pub lfxo: Option<LfxoCapacitance>, |
| 413 | } | 415 | } |
| 414 | 416 | ||
| @@ -416,6 +418,8 @@ pub mod config { | |||
| 416 | #[cfg(feature = "nrf5340-app-s")] | 418 | #[cfg(feature = "nrf5340-app-s")] |
| 417 | #[derive(Copy, Clone)] | 419 | #[derive(Copy, Clone)] |
| 418 | pub enum HfxoCapacitance { | 420 | pub enum HfxoCapacitance { |
| 421 | /// Use external capacitors | ||
| 422 | External, | ||
| 419 | /// 7.0 pF | 423 | /// 7.0 pF |
| 420 | _7_0pF, | 424 | _7_0pF, |
| 421 | /// 7.5 pF | 425 | /// 7.5 pF |
| @@ -475,8 +479,9 @@ pub mod config { | |||
| 475 | #[cfg(feature = "nrf5340-app-s")] | 479 | #[cfg(feature = "nrf5340-app-s")] |
| 476 | impl HfxoCapacitance { | 480 | impl HfxoCapacitance { |
| 477 | /// The capacitance value times two. | 481 | /// The capacitance value times two. |
| 478 | pub(crate) const fn value2(self) -> i32 { | 482 | pub(crate) fn value2(self) -> i32 { |
| 479 | match self { | 483 | match self { |
| 484 | HfxoCapacitance::External => unreachable!(), | ||
| 480 | HfxoCapacitance::_7_0pF => 14, | 485 | HfxoCapacitance::_7_0pF => 14, |
| 481 | HfxoCapacitance::_7_5pF => 15, | 486 | HfxoCapacitance::_7_5pF => 15, |
| 482 | HfxoCapacitance::_8_0pF => 16, | 487 | HfxoCapacitance::_8_0pF => 16, |
| @@ -506,11 +511,17 @@ pub mod config { | |||
| 506 | HfxoCapacitance::_20_0pF => 40, | 511 | HfxoCapacitance::_20_0pF => 40, |
| 507 | } | 512 | } |
| 508 | } | 513 | } |
| 514 | |||
| 515 | pub(crate) fn external(self) -> bool { | ||
| 516 | matches!(self, Self::External) | ||
| 517 | } | ||
| 509 | } | 518 | } |
| 510 | 519 | ||
| 511 | /// Internal capacitance value for the LFXO. | 520 | /// Internal capacitance value for the LFXO. |
| 512 | #[cfg(feature = "nrf5340-app-s")] | 521 | #[cfg(feature = "nrf5340-app-s")] |
| 513 | pub enum LfxoCapacitance { | 522 | pub enum LfxoCapacitance { |
| 523 | /// Use external capacitors | ||
| 524 | External = 0, | ||
| 514 | /// 6 pF | 525 | /// 6 pF |
| 515 | _6pF = 1, | 526 | _6pF = 1, |
| 516 | /// 7 pF | 527 | /// 7 pF |
| @@ -523,6 +534,7 @@ pub mod config { | |||
| 523 | impl From<LfxoCapacitance> for super::pac::oscillators::vals::Intcap { | 534 | impl From<LfxoCapacitance> for super::pac::oscillators::vals::Intcap { |
| 524 | fn from(t: LfxoCapacitance) -> Self { | 535 | fn from(t: LfxoCapacitance) -> Self { |
| 525 | match t { | 536 | match t { |
| 537 | LfxoCapacitance::External => Self::EXTERNAL, | ||
| 526 | LfxoCapacitance::_6pF => Self::C6PF, | 538 | LfxoCapacitance::_6pF => Self::C6PF, |
| 527 | LfxoCapacitance::_7pF => Self::C7PF, | 539 | LfxoCapacitance::_7pF => Self::C7PF, |
| 528 | LfxoCapacitance::_9pF => Self::C9PF, | 540 | LfxoCapacitance::_9pF => Self::C9PF, |
| @@ -720,6 +732,29 @@ pub fn init(config: config::Config) -> Peripherals { | |||
| 720 | } | 732 | } |
| 721 | } | 733 | } |
| 722 | 734 | ||
| 735 | // Apply trimming values from the FICR. | ||
| 736 | #[cfg(any( | ||
| 737 | all(feature = "_nrf5340-app", feature = "_s"), | ||
| 738 | all(feature = "_nrf54l", feature = "_s"), | ||
| 739 | feature = "_nrf5340-net", | ||
| 740 | ))] | ||
| 741 | { | ||
| 742 | #[cfg(feature = "_nrf5340")] | ||
| 743 | let n = 32; | ||
| 744 | #[cfg(feature = "_nrf54l")] | ||
| 745 | let n = 64; | ||
| 746 | for i in 0..n { | ||
| 747 | let info = pac::FICR.trimcnf(i); | ||
| 748 | let addr = info.addr().read(); | ||
| 749 | if addr == 0 || addr == 0xFFFF_FFFF { | ||
| 750 | break; | ||
| 751 | } | ||
| 752 | unsafe { | ||
| 753 | (addr as *mut u32).write_volatile(info.data().read()); | ||
| 754 | } | ||
| 755 | } | ||
| 756 | } | ||
| 757 | |||
| 723 | // GLITCHDET is only accessible for secure code | 758 | // GLITCHDET is only accessible for secure code |
| 724 | #[cfg(all(feature = "_nrf54l", feature = "_s"))] | 759 | #[cfg(all(feature = "_nrf54l", feature = "_s"))] |
| 725 | { | 760 | { |
| @@ -953,17 +988,21 @@ pub fn init(config: config::Config) -> Peripherals { | |||
| 953 | #[cfg(feature = "nrf5340-app-s")] | 988 | #[cfg(feature = "nrf5340-app-s")] |
| 954 | { | 989 | { |
| 955 | if let Some(cap) = config.internal_capacitors.hfxo { | 990 | if let Some(cap) = config.internal_capacitors.hfxo { |
| 956 | let mut slope = pac::FICR.xosc32mtrim().read().slope() as i32; | 991 | if cap.external() { |
| 957 | let offset = pac::FICR.xosc32mtrim().read().offset() as i32; | 992 | pac::OSCILLATORS.xosc32mcaps().write(|w| w.set_enable(false)); |
| 958 | // slope is a signed 5-bit integer | 993 | } else { |
| 959 | if slope >= 16 { | 994 | let mut slope = pac::FICR.xosc32mtrim().read().slope() as i32; |
| 960 | slope -= 32; | 995 | let offset = pac::FICR.xosc32mtrim().read().offset() as i32; |
| 996 | // slope is a signed 5-bit integer | ||
| 997 | if slope >= 16 { | ||
| 998 | slope -= 32; | ||
| 999 | } | ||
| 1000 | let capvalue = (((slope + 56) * (cap.value2() - 14)) + ((offset - 8) << 4) + 32) >> 6; | ||
| 1001 | pac::OSCILLATORS.xosc32mcaps().write(|w| { | ||
| 1002 | w.set_capvalue(capvalue as u8); | ||
| 1003 | w.set_enable(true); | ||
| 1004 | }); | ||
| 961 | } | 1005 | } |
| 962 | let capvalue = (((slope + 56) * (cap.value2() - 14)) + ((offset - 8) << 4) + 32) >> 6; | ||
| 963 | pac::OSCILLATORS.xosc32mcaps().write(|w| { | ||
| 964 | w.set_capvalue(capvalue as u8); | ||
| 965 | w.set_enable(true); | ||
| 966 | }); | ||
| 967 | } | 1006 | } |
| 968 | if let Some(cap) = config.internal_capacitors.lfxo { | 1007 | if let Some(cap) = config.internal_capacitors.lfxo { |
| 969 | pac::OSCILLATORS.xosc32ki().intcap().write(|w| w.set_intcap(cap.into())); | 1008 | pac::OSCILLATORS.xosc32ki().intcap().write(|w| w.set_intcap(cap.into())); |
diff --git a/embassy-nrf/src/nfct.rs b/embassy-nrf/src/nfct.rs index 8d70ec954..bfbdc2906 100644 --- a/embassy-nrf/src/nfct.rs +++ b/embassy-nrf/src/nfct.rs | |||
| @@ -10,18 +10,18 @@ | |||
| 10 | #![macro_use] | 10 | #![macro_use] |
| 11 | 11 | ||
| 12 | use core::future::poll_fn; | 12 | use core::future::poll_fn; |
| 13 | use core::sync::atomic::{compiler_fence, Ordering}; | 13 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 14 | use core::task::Poll; | 14 | use core::task::Poll; |
| 15 | 15 | ||
| 16 | use embassy_sync::waitqueue::AtomicWaker; | 16 | use embassy_sync::waitqueue::AtomicWaker; |
| 17 | pub use vals::{Bitframesdd as SddPat, Discardmode as DiscardMode}; | 17 | pub use vals::{Bitframesdd as SddPat, Discardmode as DiscardMode}; |
| 18 | 18 | ||
| 19 | use crate::interrupt::InterruptExt; | 19 | use crate::interrupt::InterruptExt; |
| 20 | use crate::pac::nfct::vals; | ||
| 21 | use crate::pac::NFCT; | 20 | use crate::pac::NFCT; |
| 21 | use crate::pac::nfct::vals; | ||
| 22 | use crate::peripherals::NFCT; | 22 | use crate::peripherals::NFCT; |
| 23 | use crate::util::slice_in_ram; | 23 | use crate::util::slice_in_ram; |
| 24 | use crate::{interrupt, pac, Peri}; | 24 | use crate::{Peri, interrupt, pac}; |
| 25 | 25 | ||
| 26 | /// NFCID1 (aka UID) of different sizes. | 26 | /// NFCID1 (aka UID) of different sizes. |
| 27 | #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] | 27 | #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] |
diff --git a/embassy-nrf/src/nvmc.rs b/embassy-nrf/src/nvmc.rs index c46af0b34..3f38cd0f5 100644 --- a/embassy-nrf/src/nvmc.rs +++ b/embassy-nrf/src/nvmc.rs | |||
| @@ -8,7 +8,7 @@ use embedded_storage::nor_flash::{ | |||
| 8 | 8 | ||
| 9 | use crate::pac::nvmc::vals; | 9 | use crate::pac::nvmc::vals; |
| 10 | use crate::peripherals::NVMC; | 10 | use crate::peripherals::NVMC; |
| 11 | use crate::{pac, Peri}; | 11 | use crate::{Peri, pac}; |
| 12 | 12 | ||
| 13 | #[cfg(not(feature = "_nrf5340-net"))] | 13 | #[cfg(not(feature = "_nrf5340-net"))] |
| 14 | /// Erase size of NVMC flash in bytes. | 14 | /// Erase size of NVMC flash in bytes. |
diff --git a/embassy-nrf/src/pdm.rs b/embassy-nrf/src/pdm.rs index c2a4ba65f..bc28f5c8a 100644 --- a/embassy-nrf/src/pdm.rs +++ b/embassy-nrf/src/pdm.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | use core::future::poll_fn; | 5 | use core::future::poll_fn; |
| 6 | use core::marker::PhantomData; | 6 | use core::marker::PhantomData; |
| 7 | use core::sync::atomic::{compiler_fence, Ordering}; | 7 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 8 | use core::task::Poll; | 8 | use core::task::Poll; |
| 9 | 9 | ||
| 10 | use embassy_hal_internal::drop::OnDrop; | 10 | use embassy_hal_internal::drop::OnDrop; |
| @@ -13,7 +13,7 @@ use embassy_sync::waitqueue::AtomicWaker; | |||
| 13 | use fixed::types::I7F1; | 13 | use fixed::types::I7F1; |
| 14 | 14 | ||
| 15 | use crate::chip::EASY_DMA_SIZE; | 15 | use crate::chip::EASY_DMA_SIZE; |
| 16 | use crate::gpio::{AnyPin, Pin as GpioPin, SealedPin, DISCONNECTED}; | 16 | use crate::gpio::{AnyPin, DISCONNECTED, Pin as GpioPin, SealedPin}; |
| 17 | use crate::interrupt::typelevel::Interrupt; | 17 | use crate::interrupt::typelevel::Interrupt; |
| 18 | use crate::pac::gpio::vals as gpiovals; | 18 | use crate::pac::gpio::vals as gpiovals; |
| 19 | use crate::pac::pdm::vals; | 19 | use crate::pac::pdm::vals; |
| @@ -53,8 +53,10 @@ impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandl | |||
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | /// PDM microphone interface | 55 | /// PDM microphone interface |
| 56 | pub struct Pdm<'d, T: Instance> { | 56 | pub struct Pdm<'d> { |
| 57 | _peri: Peri<'d, T>, | 57 | r: pac::pdm::Pdm, |
| 58 | state: &'static State, | ||
| 59 | _phantom: PhantomData<&'d ()>, | ||
| 58 | } | 60 | } |
| 59 | 61 | ||
| 60 | /// PDM error | 62 | /// PDM error |
| @@ -86,9 +88,9 @@ pub enum SamplerState { | |||
| 86 | Stopped, | 88 | Stopped, |
| 87 | } | 89 | } |
| 88 | 90 | ||
| 89 | impl<'d, T: Instance> Pdm<'d, T> { | 91 | impl<'d> Pdm<'d> { |
| 90 | /// Create PDM driver | 92 | /// Create PDM driver |
| 91 | pub fn new( | 93 | pub fn new<T: Instance>( |
| 92 | pdm: Peri<'d, T>, | 94 | pdm: Peri<'d, T>, |
| 93 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 95 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 94 | clk: Peri<'d, impl GpioPin>, | 96 | clk: Peri<'d, impl GpioPin>, |
| @@ -98,7 +100,7 @@ impl<'d, T: Instance> Pdm<'d, T> { | |||
| 98 | Self::new_inner(pdm, clk.into(), din.into(), config) | 100 | Self::new_inner(pdm, clk.into(), din.into(), config) |
| 99 | } | 101 | } |
| 100 | 102 | ||
| 101 | fn new_inner(pdm: Peri<'d, T>, clk: Peri<'d, AnyPin>, din: Peri<'d, AnyPin>, config: Config) -> Self { | 103 | fn new_inner<T: Instance>(_pdm: Peri<'d, T>, clk: Peri<'d, AnyPin>, din: Peri<'d, AnyPin>, config: Config) -> Self { |
| 102 | let r = T::regs(); | 104 | let r = T::regs(); |
| 103 | 105 | ||
| 104 | // setup gpio pins | 106 | // setup gpio pins |
| @@ -133,7 +135,11 @@ impl<'d, T: Instance> Pdm<'d, T> { | |||
| 133 | 135 | ||
| 134 | r.enable().write(|w| w.set_enable(true)); | 136 | r.enable().write(|w| w.set_enable(true)); |
| 135 | 137 | ||
| 136 | Self { _peri: pdm } | 138 | Self { |
| 139 | r: T::regs(), | ||
| 140 | state: T::state(), | ||
| 141 | _phantom: PhantomData, | ||
| 142 | } | ||
| 137 | } | 143 | } |
| 138 | 144 | ||
| 139 | fn _set_gain(r: pac::pdm::Pdm, gain_left: I7F1, gain_right: I7F1) { | 145 | fn _set_gain(r: pac::pdm::Pdm, gain_left: I7F1, gain_right: I7F1) { |
| @@ -147,26 +153,26 @@ impl<'d, T: Instance> Pdm<'d, T> { | |||
| 147 | 153 | ||
| 148 | /// Adjust the gain of the PDM microphone on the fly | 154 | /// Adjust the gain of the PDM microphone on the fly |
| 149 | pub fn set_gain(&mut self, gain_left: I7F1, gain_right: I7F1) { | 155 | pub fn set_gain(&mut self, gain_left: I7F1, gain_right: I7F1) { |
| 150 | Self::_set_gain(T::regs(), gain_left, gain_right) | 156 | Self::_set_gain(self.r, gain_left, gain_right) |
| 151 | } | 157 | } |
| 152 | 158 | ||
| 153 | /// Start sampling microphone data into a dummy buffer. | 159 | /// Start sampling microphone data into a dummy buffer. |
| 154 | /// Useful to start the microphone and keep it active between recording samples. | 160 | /// Useful to start the microphone and keep it active between recording samples. |
| 155 | pub async fn start(&mut self) { | 161 | pub async fn start(&mut self) { |
| 156 | let r = T::regs(); | ||
| 157 | |||
| 158 | // start dummy sampling because microphone needs some setup time | 162 | // start dummy sampling because microphone needs some setup time |
| 159 | r.sample().ptr().write_value(DUMMY_BUFFER.as_ptr() as u32); | 163 | self.r.sample().ptr().write_value(DUMMY_BUFFER.as_ptr() as u32); |
| 160 | r.sample().maxcnt().write(|w| w.set_buffsize(DUMMY_BUFFER.len() as _)); | 164 | self.r |
| 165 | .sample() | ||
| 166 | .maxcnt() | ||
| 167 | .write(|w| w.set_buffsize(DUMMY_BUFFER.len() as _)); | ||
| 161 | 168 | ||
| 162 | r.tasks_start().write_value(1); | 169 | self.r.tasks_start().write_value(1); |
| 163 | } | 170 | } |
| 164 | 171 | ||
| 165 | /// Stop sampling microphone data inta a dummy buffer | 172 | /// Stop sampling microphone data inta a dummy buffer |
| 166 | pub async fn stop(&mut self) { | 173 | pub async fn stop(&mut self) { |
| 167 | let r = T::regs(); | 174 | self.r.tasks_stop().write_value(1); |
| 168 | r.tasks_stop().write_value(1); | 175 | self.r.events_started().write_value(0); |
| 169 | r.events_started().write_value(0); | ||
| 170 | } | 176 | } |
| 171 | 177 | ||
| 172 | /// Sample data into the given buffer | 178 | /// Sample data into the given buffer |
| @@ -178,12 +184,11 @@ impl<'d, T: Instance> Pdm<'d, T> { | |||
| 178 | return Err(Error::BufferTooLong); | 184 | return Err(Error::BufferTooLong); |
| 179 | } | 185 | } |
| 180 | 186 | ||
| 181 | let r = T::regs(); | 187 | if self.r.events_started().read() == 0 { |
| 182 | |||
| 183 | if r.events_started().read() == 0 { | ||
| 184 | return Err(Error::NotRunning); | 188 | return Err(Error::NotRunning); |
| 185 | } | 189 | } |
| 186 | 190 | ||
| 191 | let r = self.r; | ||
| 187 | let drop = OnDrop::new(move || { | 192 | let drop = OnDrop::new(move || { |
| 188 | r.intenclr().write(|w| w.set_end(true)); | 193 | r.intenclr().write(|w| w.set_end(true)); |
| 189 | r.events_stopped().write_value(0); | 194 | r.events_stopped().write_value(0); |
| @@ -198,34 +203,37 @@ impl<'d, T: Instance> Pdm<'d, T> { | |||
| 198 | // setup user buffer | 203 | // setup user buffer |
| 199 | let ptr = buffer.as_ptr(); | 204 | let ptr = buffer.as_ptr(); |
| 200 | let len = buffer.len(); | 205 | let len = buffer.len(); |
| 201 | r.sample().ptr().write_value(ptr as u32); | 206 | self.r.sample().ptr().write_value(ptr as u32); |
| 202 | r.sample().maxcnt().write(|w| w.set_buffsize(len as _)); | 207 | self.r.sample().maxcnt().write(|w| w.set_buffsize(len as _)); |
| 203 | 208 | ||
| 204 | // wait till the current sample is finished and the user buffer sample is started | 209 | // wait till the current sample is finished and the user buffer sample is started |
| 205 | Self::wait_for_sample().await; | 210 | self.wait_for_sample().await; |
| 206 | 211 | ||
| 207 | // reset the buffer back to the dummy buffer | 212 | // reset the buffer back to the dummy buffer |
| 208 | r.sample().ptr().write_value(DUMMY_BUFFER.as_ptr() as u32); | 213 | self.r.sample().ptr().write_value(DUMMY_BUFFER.as_ptr() as u32); |
| 209 | r.sample().maxcnt().write(|w| w.set_buffsize(DUMMY_BUFFER.len() as _)); | 214 | self.r |
| 215 | .sample() | ||
| 216 | .maxcnt() | ||
| 217 | .write(|w| w.set_buffsize(DUMMY_BUFFER.len() as _)); | ||
| 210 | 218 | ||
| 211 | // wait till the user buffer is sampled | 219 | // wait till the user buffer is sampled |
| 212 | Self::wait_for_sample().await; | 220 | self.wait_for_sample().await; |
| 213 | 221 | ||
| 214 | drop.defuse(); | 222 | drop.defuse(); |
| 215 | 223 | ||
| 216 | Ok(()) | 224 | Ok(()) |
| 217 | } | 225 | } |
| 218 | 226 | ||
| 219 | async fn wait_for_sample() { | 227 | async fn wait_for_sample(&mut self) { |
| 220 | let r = T::regs(); | 228 | self.r.events_end().write_value(0); |
| 221 | 229 | self.r.intenset().write(|w| w.set_end(true)); | |
| 222 | r.events_end().write_value(0); | ||
| 223 | r.intenset().write(|w| w.set_end(true)); | ||
| 224 | 230 | ||
| 225 | compiler_fence(Ordering::SeqCst); | 231 | compiler_fence(Ordering::SeqCst); |
| 226 | 232 | ||
| 233 | let state = self.state; | ||
| 234 | let r = self.r; | ||
| 227 | poll_fn(|cx| { | 235 | poll_fn(|cx| { |
| 228 | T::state().waker.register(cx.waker()); | 236 | state.waker.register(cx.waker()); |
| 229 | if r.events_end().read() != 0 { | 237 | if r.events_end().read() != 0 { |
| 230 | return Poll::Ready(()); | 238 | return Poll::Ready(()); |
| 231 | } | 239 | } |
| @@ -255,20 +263,18 @@ impl<'d, T: Instance> Pdm<'d, T> { | |||
| 255 | where | 263 | where |
| 256 | S: FnMut(&[i16; N]) -> SamplerState, | 264 | S: FnMut(&[i16; N]) -> SamplerState, |
| 257 | { | 265 | { |
| 258 | let r = T::regs(); | 266 | if self.r.events_started().read() != 0 { |
| 259 | |||
| 260 | if r.events_started().read() != 0 { | ||
| 261 | return Err(Error::AlreadyRunning); | 267 | return Err(Error::AlreadyRunning); |
| 262 | } | 268 | } |
| 263 | 269 | ||
| 264 | r.sample().ptr().write_value(bufs[0].as_mut_ptr() as u32); | 270 | self.r.sample().ptr().write_value(bufs[0].as_mut_ptr() as u32); |
| 265 | r.sample().maxcnt().write(|w| w.set_buffsize(N as _)); | 271 | self.r.sample().maxcnt().write(|w| w.set_buffsize(N as _)); |
| 266 | 272 | ||
| 267 | // Reset and enable the events | 273 | // Reset and enable the events |
| 268 | r.events_end().write_value(0); | 274 | self.r.events_end().write_value(0); |
| 269 | r.events_started().write_value(0); | 275 | self.r.events_started().write_value(0); |
| 270 | r.events_stopped().write_value(0); | 276 | self.r.events_stopped().write_value(0); |
| 271 | r.intenset().write(|w| { | 277 | self.r.intenset().write(|w| { |
| 272 | w.set_end(true); | 278 | w.set_end(true); |
| 273 | w.set_started(true); | 279 | w.set_started(true); |
| 274 | w.set_stopped(true); | 280 | w.set_stopped(true); |
| @@ -278,23 +284,24 @@ impl<'d, T: Instance> Pdm<'d, T> { | |||
| 278 | // wouldn't happen anyway | 284 | // wouldn't happen anyway |
| 279 | compiler_fence(Ordering::SeqCst); | 285 | compiler_fence(Ordering::SeqCst); |
| 280 | 286 | ||
| 281 | r.tasks_start().write_value(1); | 287 | self.r.tasks_start().write_value(1); |
| 282 | 288 | ||
| 283 | let mut current_buffer = 0; | 289 | let mut current_buffer = 0; |
| 284 | 290 | ||
| 285 | let mut done = false; | 291 | let mut done = false; |
| 286 | 292 | ||
| 287 | let drop = OnDrop::new(|| { | 293 | let r = self.r; |
| 294 | let drop = OnDrop::new(move || { | ||
| 288 | r.tasks_stop().write_value(1); | 295 | r.tasks_stop().write_value(1); |
| 289 | // N.B. It would be better if this were async, but Drop only support sync code | 296 | // N.B. It would be better if this were async, but Drop only support sync code |
| 290 | while r.events_stopped().read() != 0 {} | 297 | while r.events_stopped().read() != 0 {} |
| 291 | }); | 298 | }); |
| 292 | 299 | ||
| 300 | let state = self.state; | ||
| 301 | let r = self.r; | ||
| 293 | // Wait for events and complete when the sampler indicates it has had enough | 302 | // Wait for events and complete when the sampler indicates it has had enough |
| 294 | poll_fn(|cx| { | 303 | poll_fn(|cx| { |
| 295 | let r = T::regs(); | 304 | state.waker.register(cx.waker()); |
| 296 | |||
| 297 | T::state().waker.register(cx.waker()); | ||
| 298 | 305 | ||
| 299 | if r.events_end().read() != 0 { | 306 | if r.events_end().read() != 0 { |
| 300 | compiler_fence(Ordering::SeqCst); | 307 | compiler_fence(Ordering::SeqCst); |
| @@ -411,16 +418,14 @@ impl From<Edge> for vals::Edge { | |||
| 411 | } | 418 | } |
| 412 | } | 419 | } |
| 413 | 420 | ||
| 414 | impl<'d, T: Instance> Drop for Pdm<'d, T> { | 421 | impl<'d> Drop for Pdm<'d> { |
| 415 | fn drop(&mut self) { | 422 | fn drop(&mut self) { |
| 416 | let r = T::regs(); | 423 | self.r.tasks_stop().write_value(1); |
| 417 | |||
| 418 | r.tasks_stop().write_value(1); | ||
| 419 | 424 | ||
| 420 | r.enable().write(|w| w.set_enable(false)); | 425 | self.r.enable().write(|w| w.set_enable(false)); |
| 421 | 426 | ||
| 422 | r.psel().din().write_value(DISCONNECTED); | 427 | self.r.psel().din().write_value(DISCONNECTED); |
| 423 | r.psel().clk().write_value(DISCONNECTED); | 428 | self.r.psel().clk().write_value(DISCONNECTED); |
| 424 | } | 429 | } |
| 425 | } | 430 | } |
| 426 | 431 | ||
diff --git a/embassy-nrf/src/ppi/dppi.rs b/embassy-nrf/src/ppi/dppi.rs index 078d2fd1c..168647be3 100644 --- a/embassy-nrf/src/ppi/dppi.rs +++ b/embassy-nrf/src/ppi/dppi.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | use super::{Channel, ConfigurableChannel, Event, Ppi, Task}; | 1 | use super::{Channel, ConfigurableChannel, Event, Ppi, Task}; |
| 2 | use crate::{pac, Peri}; | 2 | use crate::{Peri, pac}; |
| 3 | 3 | ||
| 4 | const DPPI_ENABLE_BIT: u32 = 0x8000_0000; | 4 | const DPPI_ENABLE_BIT: u32 = 0x8000_0000; |
| 5 | const DPPI_CHANNEL_MASK: u32 = 0x0000_00FF; | 5 | const DPPI_CHANNEL_MASK: u32 = 0x0000_00FF; |
diff --git a/embassy-nrf/src/ppi/mod.rs b/embassy-nrf/src/ppi/mod.rs index 2bcf72e9c..f30c2218d 100644 --- a/embassy-nrf/src/ppi/mod.rs +++ b/embassy-nrf/src/ppi/mod.rs | |||
| @@ -18,9 +18,9 @@ | |||
| 18 | use core::marker::PhantomData; | 18 | use core::marker::PhantomData; |
| 19 | use core::ptr::NonNull; | 19 | use core::ptr::NonNull; |
| 20 | 20 | ||
| 21 | use embassy_hal_internal::{impl_peripheral, Peri, PeripheralType}; | 21 | use embassy_hal_internal::{Peri, PeripheralType, impl_peripheral}; |
| 22 | 22 | ||
| 23 | use crate::pac::common::{Reg, RW, W}; | 23 | use crate::pac::common::{RW, Reg, W}; |
| 24 | use crate::peripherals; | 24 | use crate::peripherals; |
| 25 | 25 | ||
| 26 | #[cfg_attr(feature = "_dppi", path = "dppi.rs")] | 26 | #[cfg_attr(feature = "_dppi", path = "dppi.rs")] |
diff --git a/embassy-nrf/src/ppi/ppi.rs b/embassy-nrf/src/ppi/ppi.rs index 531c25444..18bc8b8db 100644 --- a/embassy-nrf/src/ppi/ppi.rs +++ b/embassy-nrf/src/ppi/ppi.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | use super::{Channel, ConfigurableChannel, Event, Ppi, Task}; | 1 | use super::{Channel, ConfigurableChannel, Event, Ppi, Task}; |
| 2 | use crate::{pac, Peri}; | 2 | use crate::{Peri, pac}; |
| 3 | 3 | ||
| 4 | impl<'d> Task<'d> { | 4 | impl<'d> Task<'d> { |
| 5 | fn reg_val(&self) -> u32 { | 5 | fn reg_val(&self) -> u32 { |
diff --git a/embassy-nrf/src/pwm.rs b/embassy-nrf/src/pwm.rs index d6b40b5c0..e038f44b8 100644 --- a/embassy-nrf/src/pwm.rs +++ b/embassy-nrf/src/pwm.rs | |||
| @@ -2,11 +2,11 @@ | |||
| 2 | 2 | ||
| 3 | #![macro_use] | 3 | #![macro_use] |
| 4 | 4 | ||
| 5 | use core::sync::atomic::{compiler_fence, Ordering}; | 5 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 6 | 6 | ||
| 7 | use embassy_hal_internal::{Peri, PeripheralType}; | 7 | use embassy_hal_internal::{Peri, PeripheralType}; |
| 8 | 8 | ||
| 9 | use crate::gpio::{convert_drive, AnyPin, OutputDrive, Pin as GpioPin, PselBits, SealedPin as _, DISCONNECTED}; | 9 | use crate::gpio::{AnyPin, DISCONNECTED, OutputDrive, Pin as GpioPin, PselBits, SealedPin as _, convert_drive}; |
| 10 | use crate::pac::gpio::vals as gpiovals; | 10 | use crate::pac::gpio::vals as gpiovals; |
| 11 | use crate::pac::pwm::vals; | 11 | use crate::pac::pwm::vals; |
| 12 | use crate::ppi::{Event, Task}; | 12 | use crate::ppi::{Event, Task}; |
| @@ -15,8 +15,8 @@ use crate::{interrupt, pac}; | |||
| 15 | 15 | ||
| 16 | /// SimplePwm is the traditional pwm interface you're probably used to, allowing | 16 | /// SimplePwm is the traditional pwm interface you're probably used to, allowing |
| 17 | /// to simply set a duty cycle across up to four channels. | 17 | /// to simply set a duty cycle across up to four channels. |
| 18 | pub struct SimplePwm<'d, T: Instance> { | 18 | pub struct SimplePwm<'d> { |
| 19 | _peri: Peri<'d, T>, | 19 | r: pac::pwm::Pwm, |
| 20 | duty: [u16; 4], | 20 | duty: [u16; 4], |
| 21 | ch0: Option<Peri<'d, AnyPin>>, | 21 | ch0: Option<Peri<'d, AnyPin>>, |
| 22 | ch1: Option<Peri<'d, AnyPin>>, | 22 | ch1: Option<Peri<'d, AnyPin>>, |
| @@ -26,8 +26,8 @@ pub struct SimplePwm<'d, T: Instance> { | |||
| 26 | 26 | ||
| 27 | /// SequencePwm allows you to offload the updating of a sequence of duty cycles | 27 | /// SequencePwm allows you to offload the updating of a sequence of duty cycles |
| 28 | /// to up to four channels, as well as repeat that sequence n times. | 28 | /// to up to four channels, as well as repeat that sequence n times. |
| 29 | pub struct SequencePwm<'d, T: Instance> { | 29 | pub struct SequencePwm<'d> { |
| 30 | _peri: Peri<'d, T>, | 30 | r: pac::pwm::Pwm, |
| 31 | ch0: Option<Peri<'d, AnyPin>>, | 31 | ch0: Option<Peri<'d, AnyPin>>, |
| 32 | ch1: Option<Peri<'d, AnyPin>>, | 32 | ch1: Option<Peri<'d, AnyPin>>, |
| 33 | ch2: Option<Peri<'d, AnyPin>>, | 33 | ch2: Option<Peri<'d, AnyPin>>, |
| @@ -51,16 +51,16 @@ const MAX_SEQUENCE_LEN: usize = 32767; | |||
| 51 | /// The used pwm clock frequency | 51 | /// The used pwm clock frequency |
| 52 | pub const PWM_CLK_HZ: u32 = 16_000_000; | 52 | pub const PWM_CLK_HZ: u32 = 16_000_000; |
| 53 | 53 | ||
| 54 | impl<'d, T: Instance> SequencePwm<'d, T> { | 54 | impl<'d> SequencePwm<'d> { |
| 55 | /// Create a new 1-channel PWM | 55 | /// Create a new 1-channel PWM |
| 56 | #[allow(unused_unsafe)] | 56 | #[allow(unused_unsafe)] |
| 57 | pub fn new_1ch(pwm: Peri<'d, T>, ch0: Peri<'d, impl GpioPin>, config: Config) -> Result<Self, Error> { | 57 | pub fn new_1ch<T: Instance>(pwm: Peri<'d, T>, ch0: Peri<'d, impl GpioPin>, config: Config) -> Result<Self, Error> { |
| 58 | Self::new_inner(pwm, Some(ch0.into()), None, None, None, config) | 58 | Self::new_inner(pwm, Some(ch0.into()), None, None, None, config) |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | /// Create a new 2-channel PWM | 61 | /// Create a new 2-channel PWM |
| 62 | #[allow(unused_unsafe)] | 62 | #[allow(unused_unsafe)] |
| 63 | pub fn new_2ch( | 63 | pub fn new_2ch<T: Instance>( |
| 64 | pwm: Peri<'d, T>, | 64 | pwm: Peri<'d, T>, |
| 65 | ch0: Peri<'d, impl GpioPin>, | 65 | ch0: Peri<'d, impl GpioPin>, |
| 66 | ch1: Peri<'d, impl GpioPin>, | 66 | ch1: Peri<'d, impl GpioPin>, |
| @@ -71,7 +71,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { | |||
| 71 | 71 | ||
| 72 | /// Create a new 3-channel PWM | 72 | /// Create a new 3-channel PWM |
| 73 | #[allow(unused_unsafe)] | 73 | #[allow(unused_unsafe)] |
| 74 | pub fn new_3ch( | 74 | pub fn new_3ch<T: Instance>( |
| 75 | pwm: Peri<'d, T>, | 75 | pwm: Peri<'d, T>, |
| 76 | ch0: Peri<'d, impl GpioPin>, | 76 | ch0: Peri<'d, impl GpioPin>, |
| 77 | ch1: Peri<'d, impl GpioPin>, | 77 | ch1: Peri<'d, impl GpioPin>, |
| @@ -83,7 +83,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { | |||
| 83 | 83 | ||
| 84 | /// Create a new 4-channel PWM | 84 | /// Create a new 4-channel PWM |
| 85 | #[allow(unused_unsafe)] | 85 | #[allow(unused_unsafe)] |
| 86 | pub fn new_4ch( | 86 | pub fn new_4ch<T: Instance>( |
| 87 | pwm: Peri<'d, T>, | 87 | pwm: Peri<'d, T>, |
| 88 | ch0: Peri<'d, impl GpioPin>, | 88 | ch0: Peri<'d, impl GpioPin>, |
| 89 | ch1: Peri<'d, impl GpioPin>, | 89 | ch1: Peri<'d, impl GpioPin>, |
| @@ -101,7 +101,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { | |||
| 101 | ) | 101 | ) |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | fn new_inner( | 104 | fn new_inner<T: Instance>( |
| 105 | _pwm: Peri<'d, T>, | 105 | _pwm: Peri<'d, T>, |
| 106 | ch0: Option<Peri<'d, AnyPin>>, | 106 | ch0: Option<Peri<'d, AnyPin>>, |
| 107 | ch1: Option<Peri<'d, AnyPin>>, | 107 | ch1: Option<Peri<'d, AnyPin>>, |
| @@ -174,7 +174,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { | |||
| 174 | r.countertop().write(|w| w.set_countertop(config.max_duty)); | 174 | r.countertop().write(|w| w.set_countertop(config.max_duty)); |
| 175 | 175 | ||
| 176 | Ok(Self { | 176 | Ok(Self { |
| 177 | _peri: _pwm, | 177 | r: T::regs(), |
| 178 | ch0, | 178 | ch0, |
| 179 | ch1, | 179 | ch1, |
| 180 | ch2, | 180 | ch2, |
| @@ -185,57 +185,43 @@ impl<'d, T: Instance> SequencePwm<'d, T> { | |||
| 185 | /// Returns reference to `Stopped` event endpoint for PPI. | 185 | /// Returns reference to `Stopped` event endpoint for PPI. |
| 186 | #[inline(always)] | 186 | #[inline(always)] |
| 187 | pub fn event_stopped(&self) -> Event<'d> { | 187 | pub fn event_stopped(&self) -> Event<'d> { |
| 188 | let r = T::regs(); | 188 | Event::from_reg(self.r.events_stopped()) |
| 189 | |||
| 190 | Event::from_reg(r.events_stopped()) | ||
| 191 | } | 189 | } |
| 192 | 190 | ||
| 193 | /// Returns reference to `LoopsDone` event endpoint for PPI. | 191 | /// Returns reference to `LoopsDone` event endpoint for PPI. |
| 194 | #[inline(always)] | 192 | #[inline(always)] |
| 195 | pub fn event_loops_done(&self) -> Event<'d> { | 193 | pub fn event_loops_done(&self) -> Event<'d> { |
| 196 | let r = T::regs(); | 194 | Event::from_reg(self.r.events_loopsdone()) |
| 197 | |||
| 198 | Event::from_reg(r.events_loopsdone()) | ||
| 199 | } | 195 | } |
| 200 | 196 | ||
| 201 | /// Returns reference to `PwmPeriodEnd` event endpoint for PPI. | 197 | /// Returns reference to `PwmPeriodEnd` event endpoint for PPI. |
| 202 | #[inline(always)] | 198 | #[inline(always)] |
| 203 | pub fn event_pwm_period_end(&self) -> Event<'d> { | 199 | pub fn event_pwm_period_end(&self) -> Event<'d> { |
| 204 | let r = T::regs(); | 200 | Event::from_reg(self.r.events_pwmperiodend()) |
| 205 | |||
| 206 | Event::from_reg(r.events_pwmperiodend()) | ||
| 207 | } | 201 | } |
| 208 | 202 | ||
| 209 | /// Returns reference to `Seq0 End` event endpoint for PPI. | 203 | /// Returns reference to `Seq0 End` event endpoint for PPI. |
| 210 | #[inline(always)] | 204 | #[inline(always)] |
| 211 | pub fn event_seq_end(&self) -> Event<'d> { | 205 | pub fn event_seq_end(&self) -> Event<'d> { |
| 212 | let r = T::regs(); | 206 | Event::from_reg(self.r.events_seqend(0)) |
| 213 | |||
| 214 | Event::from_reg(r.events_seqend(0)) | ||
| 215 | } | 207 | } |
| 216 | 208 | ||
| 217 | /// Returns reference to `Seq1 End` event endpoint for PPI. | 209 | /// Returns reference to `Seq1 End` event endpoint for PPI. |
| 218 | #[inline(always)] | 210 | #[inline(always)] |
| 219 | pub fn event_seq1_end(&self) -> Event<'d> { | 211 | pub fn event_seq1_end(&self) -> Event<'d> { |
| 220 | let r = T::regs(); | 212 | Event::from_reg(self.r.events_seqend(1)) |
| 221 | |||
| 222 | Event::from_reg(r.events_seqend(1)) | ||
| 223 | } | 213 | } |
| 224 | 214 | ||
| 225 | /// Returns reference to `Seq0 Started` event endpoint for PPI. | 215 | /// Returns reference to `Seq0 Started` event endpoint for PPI. |
| 226 | #[inline(always)] | 216 | #[inline(always)] |
| 227 | pub fn event_seq0_started(&self) -> Event<'d> { | 217 | pub fn event_seq0_started(&self) -> Event<'d> { |
| 228 | let r = T::regs(); | 218 | Event::from_reg(self.r.events_seqstarted(0)) |
| 229 | |||
| 230 | Event::from_reg(r.events_seqstarted(0)) | ||
| 231 | } | 219 | } |
| 232 | 220 | ||
| 233 | /// Returns reference to `Seq1 Started` event endpoint for PPI. | 221 | /// Returns reference to `Seq1 Started` event endpoint for PPI. |
| 234 | #[inline(always)] | 222 | #[inline(always)] |
| 235 | pub fn event_seq1_started(&self) -> Event<'d> { | 223 | pub fn event_seq1_started(&self) -> Event<'d> { |
| 236 | let r = T::regs(); | 224 | Event::from_reg(self.r.events_seqstarted(1)) |
| 237 | |||
| 238 | Event::from_reg(r.events_seqstarted(1)) | ||
| 239 | } | 225 | } |
| 240 | 226 | ||
| 241 | /// Returns reference to `Seq0 Start` task endpoint for PPI. | 227 | /// Returns reference to `Seq0 Start` task endpoint for PPI. |
| @@ -244,9 +230,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { | |||
| 244 | /// Interacting with the sequence while it runs puts it in an unknown state | 230 | /// Interacting with the sequence while it runs puts it in an unknown state |
| 245 | #[inline(always)] | 231 | #[inline(always)] |
| 246 | pub unsafe fn task_start_seq0(&self) -> Task<'d> { | 232 | pub unsafe fn task_start_seq0(&self) -> Task<'d> { |
| 247 | let r = T::regs(); | 233 | Task::from_reg(self.r.tasks_seqstart(0)) |
| 248 | |||
| 249 | Task::from_reg(r.tasks_seqstart(0)) | ||
| 250 | } | 234 | } |
| 251 | 235 | ||
| 252 | /// Returns reference to `Seq1 Started` task endpoint for PPI. | 236 | /// Returns reference to `Seq1 Started` task endpoint for PPI. |
| @@ -255,9 +239,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { | |||
| 255 | /// Interacting with the sequence while it runs puts it in an unknown state | 239 | /// Interacting with the sequence while it runs puts it in an unknown state |
| 256 | #[inline(always)] | 240 | #[inline(always)] |
| 257 | pub unsafe fn task_start_seq1(&self) -> Task<'d> { | 241 | pub unsafe fn task_start_seq1(&self) -> Task<'d> { |
| 258 | let r = T::regs(); | 242 | Task::from_reg(self.r.tasks_seqstart(1)) |
| 259 | |||
| 260 | Task::from_reg(r.tasks_seqstart(1)) | ||
| 261 | } | 243 | } |
| 262 | 244 | ||
| 263 | /// Returns reference to `NextStep` task endpoint for PPI. | 245 | /// Returns reference to `NextStep` task endpoint for PPI. |
| @@ -266,9 +248,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { | |||
| 266 | /// Interacting with the sequence while it runs puts it in an unknown state | 248 | /// Interacting with the sequence while it runs puts it in an unknown state |
| 267 | #[inline(always)] | 249 | #[inline(always)] |
| 268 | pub unsafe fn task_next_step(&self) -> Task<'d> { | 250 | pub unsafe fn task_next_step(&self) -> Task<'d> { |
| 269 | let r = T::regs(); | 251 | Task::from_reg(self.r.tasks_nextstep()) |
| 270 | |||
| 271 | Task::from_reg(r.tasks_nextstep()) | ||
| 272 | } | 252 | } |
| 273 | 253 | ||
| 274 | /// Returns reference to `Stop` task endpoint for PPI. | 254 | /// Returns reference to `Stop` task endpoint for PPI. |
| @@ -277,36 +257,34 @@ impl<'d, T: Instance> SequencePwm<'d, T> { | |||
| 277 | /// Interacting with the sequence while it runs puts it in an unknown state | 257 | /// Interacting with the sequence while it runs puts it in an unknown state |
| 278 | #[inline(always)] | 258 | #[inline(always)] |
| 279 | pub unsafe fn task_stop(&self) -> Task<'d> { | 259 | pub unsafe fn task_stop(&self) -> Task<'d> { |
| 280 | let r = T::regs(); | 260 | Task::from_reg(self.r.tasks_stop()) |
| 281 | |||
| 282 | Task::from_reg(r.tasks_stop()) | ||
| 283 | } | 261 | } |
| 284 | } | 262 | } |
| 285 | 263 | ||
| 286 | impl<'a, T: Instance> Drop for SequencePwm<'a, T> { | 264 | impl<'a> Drop for SequencePwm<'a> { |
| 287 | fn drop(&mut self) { | 265 | fn drop(&mut self) { |
| 288 | let r = T::regs(); | ||
| 289 | |||
| 290 | if let Some(pin) = &self.ch0 { | 266 | if let Some(pin) = &self.ch0 { |
| 291 | pin.set_low(); | 267 | pin.set_low(); |
| 292 | pin.conf().write(|_| ()); | 268 | pin.conf().write(|_| ()); |
| 293 | r.psel().out(0).write_value(DISCONNECTED); | 269 | self.r.psel().out(0).write_value(DISCONNECTED); |
| 294 | } | 270 | } |
| 295 | if let Some(pin) = &self.ch1 { | 271 | if let Some(pin) = &self.ch1 { |
| 296 | pin.set_low(); | 272 | pin.set_low(); |
| 297 | pin.conf().write(|_| ()); | 273 | pin.conf().write(|_| ()); |
| 298 | r.psel().out(1).write_value(DISCONNECTED); | 274 | self.r.psel().out(1).write_value(DISCONNECTED); |
| 299 | } | 275 | } |
| 300 | if let Some(pin) = &self.ch2 { | 276 | if let Some(pin) = &self.ch2 { |
| 301 | pin.set_low(); | 277 | pin.set_low(); |
| 302 | pin.conf().write(|_| ()); | 278 | pin.conf().write(|_| ()); |
| 303 | r.psel().out(2).write_value(DISCONNECTED); | 279 | self.r.psel().out(2).write_value(DISCONNECTED); |
| 304 | } | 280 | } |
| 305 | if let Some(pin) = &self.ch3 { | 281 | if let Some(pin) = &self.ch3 { |
| 306 | pin.set_low(); | 282 | pin.set_low(); |
| 307 | pin.conf().write(|_| ()); | 283 | pin.conf().write(|_| ()); |
| 308 | r.psel().out(3).write_value(DISCONNECTED); | 284 | self.r.psel().out(3).write_value(DISCONNECTED); |
| 309 | } | 285 | } |
| 286 | |||
| 287 | self.r.enable().write(|w| w.set_enable(false)); | ||
| 310 | } | 288 | } |
| 311 | } | 289 | } |
| 312 | 290 | ||
| @@ -384,13 +362,13 @@ impl<'s> Sequence<'s> { | |||
| 384 | /// A single sequence that can be started and stopped. | 362 | /// A single sequence that can be started and stopped. |
| 385 | /// Takes one sequence along with its configuration. | 363 | /// Takes one sequence along with its configuration. |
| 386 | #[non_exhaustive] | 364 | #[non_exhaustive] |
| 387 | pub struct SingleSequencer<'d, 's, T: Instance> { | 365 | pub struct SingleSequencer<'d, 's> { |
| 388 | sequencer: Sequencer<'d, 's, T>, | 366 | sequencer: Sequencer<'d, 's>, |
| 389 | } | 367 | } |
| 390 | 368 | ||
| 391 | impl<'d, 's, T: Instance> SingleSequencer<'d, 's, T> { | 369 | impl<'d, 's> SingleSequencer<'d, 's> { |
| 392 | /// Create a new sequencer | 370 | /// Create a new sequencer |
| 393 | pub fn new(pwm: &'s mut SequencePwm<'d, T>, words: &'s [u16], config: SequenceConfig) -> Self { | 371 | pub fn new(pwm: &'s mut SequencePwm<'d>, words: &'s [u16], config: SequenceConfig) -> Self { |
| 394 | Self { | 372 | Self { |
| 395 | sequencer: Sequencer::new(pwm, Sequence::new(words, config), None), | 373 | sequencer: Sequencer::new(pwm, Sequence::new(words, config), None), |
| 396 | } | 374 | } |
| @@ -423,16 +401,16 @@ impl<'d, 's, T: Instance> SingleSequencer<'d, 's, T> { | |||
| 423 | /// In the case where no second sequence is provided then the first sequence | 401 | /// In the case where no second sequence is provided then the first sequence |
| 424 | /// is used. | 402 | /// is used. |
| 425 | #[non_exhaustive] | 403 | #[non_exhaustive] |
| 426 | pub struct Sequencer<'d, 's, T: Instance> { | 404 | pub struct Sequencer<'d, 's> { |
| 427 | _pwm: &'s mut SequencePwm<'d, T>, | 405 | _pwm: &'s mut SequencePwm<'d>, |
| 428 | sequence0: Sequence<'s>, | 406 | sequence0: Sequence<'s>, |
| 429 | sequence1: Option<Sequence<'s>>, | 407 | sequence1: Option<Sequence<'s>>, |
| 430 | } | 408 | } |
| 431 | 409 | ||
| 432 | impl<'d, 's, T: Instance> Sequencer<'d, 's, T> { | 410 | impl<'d, 's> Sequencer<'d, 's> { |
| 433 | /// Create a new double sequence. In the absence of sequence 1, sequence 0 | 411 | /// Create a new double sequence. In the absence of sequence 1, sequence 0 |
| 434 | /// will be used twice in the one loop. | 412 | /// will be used twice in the one loop. |
| 435 | pub fn new(pwm: &'s mut SequencePwm<'d, T>, sequence0: Sequence<'s>, sequence1: Option<Sequence<'s>>) -> Self { | 413 | pub fn new(pwm: &'s mut SequencePwm<'d>, sequence0: Sequence<'s>, sequence1: Option<Sequence<'s>>) -> Self { |
| 436 | Sequencer { | 414 | Sequencer { |
| 437 | _pwm: pwm, | 415 | _pwm: pwm, |
| 438 | sequence0, | 416 | sequence0, |
| @@ -459,7 +437,7 @@ impl<'d, 's, T: Instance> Sequencer<'d, 's, T> { | |||
| 459 | 437 | ||
| 460 | self.stop(); | 438 | self.stop(); |
| 461 | 439 | ||
| 462 | let r = T::regs(); | 440 | let r = self._pwm.r; |
| 463 | 441 | ||
| 464 | r.seq(0).refresh().write(|w| w.0 = sequence0.config.refresh); | 442 | r.seq(0).refresh().write(|w| w.0 = sequence0.config.refresh); |
| 465 | r.seq(0).enddelay().write(|w| w.0 = sequence0.config.end_delay); | 443 | r.seq(0).enddelay().write(|w| w.0 = sequence0.config.end_delay); |
| @@ -499,7 +477,7 @@ impl<'d, 's, T: Instance> Sequencer<'d, 's, T> { | |||
| 499 | /// `start` so that they may be further mutated. | 477 | /// `start` so that they may be further mutated. |
| 500 | #[inline(always)] | 478 | #[inline(always)] |
| 501 | pub fn stop(&self) { | 479 | pub fn stop(&self) { |
| 502 | let r = T::regs(); | 480 | let r = self._pwm.r; |
| 503 | 481 | ||
| 504 | r.shorts().write(|_| ()); | 482 | r.shorts().write(|_| ()); |
| 505 | 483 | ||
| @@ -510,7 +488,7 @@ impl<'d, 's, T: Instance> Sequencer<'d, 's, T> { | |||
| 510 | } | 488 | } |
| 511 | } | 489 | } |
| 512 | 490 | ||
| 513 | impl<'d, 's, T: Instance> Drop for Sequencer<'d, 's, T> { | 491 | impl<'d, 's> Drop for Sequencer<'d, 's> { |
| 514 | fn drop(&mut self) { | 492 | fn drop(&mut self) { |
| 515 | self.stop(); | 493 | self.stop(); |
| 516 | } | 494 | } |
| @@ -589,22 +567,22 @@ pub enum CounterMode { | |||
| 589 | UpAndDown, | 567 | UpAndDown, |
| 590 | } | 568 | } |
| 591 | 569 | ||
| 592 | impl<'d, T: Instance> SimplePwm<'d, T> { | 570 | impl<'d> SimplePwm<'d> { |
| 593 | /// Create a new 1-channel PWM | 571 | /// Create a new 1-channel PWM |
| 594 | #[allow(unused_unsafe)] | 572 | #[allow(unused_unsafe)] |
| 595 | pub fn new_1ch(pwm: Peri<'d, T>, ch0: Peri<'d, impl GpioPin>) -> Self { | 573 | pub fn new_1ch<T: Instance>(pwm: Peri<'d, T>, ch0: Peri<'d, impl GpioPin>) -> Self { |
| 596 | unsafe { Self::new_inner(pwm, Some(ch0.into()), None, None, None) } | 574 | unsafe { Self::new_inner(pwm, Some(ch0.into()), None, None, None) } |
| 597 | } | 575 | } |
| 598 | 576 | ||
| 599 | /// Create a new 2-channel PWM | 577 | /// Create a new 2-channel PWM |
| 600 | #[allow(unused_unsafe)] | 578 | #[allow(unused_unsafe)] |
| 601 | pub fn new_2ch(pwm: Peri<'d, T>, ch0: Peri<'d, impl GpioPin>, ch1: Peri<'d, impl GpioPin>) -> Self { | 579 | pub fn new_2ch<T: Instance>(pwm: Peri<'d, T>, ch0: Peri<'d, impl GpioPin>, ch1: Peri<'d, impl GpioPin>) -> Self { |
| 602 | Self::new_inner(pwm, Some(ch0.into()), Some(ch1.into()), None, None) | 580 | Self::new_inner(pwm, Some(ch0.into()), Some(ch1.into()), None, None) |
| 603 | } | 581 | } |
| 604 | 582 | ||
| 605 | /// Create a new 3-channel PWM | 583 | /// Create a new 3-channel PWM |
| 606 | #[allow(unused_unsafe)] | 584 | #[allow(unused_unsafe)] |
| 607 | pub fn new_3ch( | 585 | pub fn new_3ch<T: Instance>( |
| 608 | pwm: Peri<'d, T>, | 586 | pwm: Peri<'d, T>, |
| 609 | ch0: Peri<'d, impl GpioPin>, | 587 | ch0: Peri<'d, impl GpioPin>, |
| 610 | ch1: Peri<'d, impl GpioPin>, | 588 | ch1: Peri<'d, impl GpioPin>, |
| @@ -615,7 +593,7 @@ impl<'d, T: Instance> SimplePwm<'d, T> { | |||
| 615 | 593 | ||
| 616 | /// Create a new 4-channel PWM | 594 | /// Create a new 4-channel PWM |
| 617 | #[allow(unused_unsafe)] | 595 | #[allow(unused_unsafe)] |
| 618 | pub fn new_4ch( | 596 | pub fn new_4ch<T: Instance>( |
| 619 | pwm: Peri<'d, T>, | 597 | pwm: Peri<'d, T>, |
| 620 | ch0: Peri<'d, impl GpioPin>, | 598 | ch0: Peri<'d, impl GpioPin>, |
| 621 | ch1: Peri<'d, impl GpioPin>, | 599 | ch1: Peri<'d, impl GpioPin>, |
| @@ -633,7 +611,7 @@ impl<'d, T: Instance> SimplePwm<'d, T> { | |||
| 633 | } | 611 | } |
| 634 | } | 612 | } |
| 635 | 613 | ||
| 636 | fn new_inner( | 614 | fn new_inner<T: Instance>( |
| 637 | _pwm: Peri<'d, T>, | 615 | _pwm: Peri<'d, T>, |
| 638 | ch0: Option<Peri<'d, AnyPin>>, | 616 | ch0: Option<Peri<'d, AnyPin>>, |
| 639 | ch1: Option<Peri<'d, AnyPin>>, | 617 | ch1: Option<Peri<'d, AnyPin>>, |
| @@ -656,7 +634,7 @@ impl<'d, T: Instance> SimplePwm<'d, T> { | |||
| 656 | } | 634 | } |
| 657 | 635 | ||
| 658 | let pwm = Self { | 636 | let pwm = Self { |
| 659 | _peri: _pwm, | 637 | r: T::regs(), |
| 660 | ch0, | 638 | ch0, |
| 661 | ch1, | 639 | ch1, |
| 662 | ch2, | 640 | ch2, |
| @@ -691,22 +669,19 @@ impl<'d, T: Instance> SimplePwm<'d, T> { | |||
| 691 | /// Returns the enable state of the pwm counter | 669 | /// Returns the enable state of the pwm counter |
| 692 | #[inline(always)] | 670 | #[inline(always)] |
| 693 | pub fn is_enabled(&self) -> bool { | 671 | pub fn is_enabled(&self) -> bool { |
| 694 | let r = T::regs(); | 672 | self.r.enable().read().enable() |
| 695 | r.enable().read().enable() | ||
| 696 | } | 673 | } |
| 697 | 674 | ||
| 698 | /// Enables the PWM generator. | 675 | /// Enables the PWM generator. |
| 699 | #[inline(always)] | 676 | #[inline(always)] |
| 700 | pub fn enable(&self) { | 677 | pub fn enable(&self) { |
| 701 | let r = T::regs(); | 678 | self.r.enable().write(|w| w.set_enable(true)); |
| 702 | r.enable().write(|w| w.set_enable(true)); | ||
| 703 | } | 679 | } |
| 704 | 680 | ||
| 705 | /// Disables the PWM generator. Does NOT clear the last duty cycle from the pin. | 681 | /// Disables the PWM generator. Does NOT clear the last duty cycle from the pin. |
| 706 | #[inline(always)] | 682 | #[inline(always)] |
| 707 | pub fn disable(&self) { | 683 | pub fn disable(&self) { |
| 708 | let r = T::regs(); | 684 | self.r.enable().write(|w| w.set_enable(false)); |
| 709 | r.enable().write(|w| w.set_enable(false)); | ||
| 710 | } | 685 | } |
| 711 | 686 | ||
| 712 | /// Returns the current duty of the channel | 687 | /// Returns the current duty of the channel |
| @@ -716,32 +691,30 @@ impl<'d, T: Instance> SimplePwm<'d, T> { | |||
| 716 | 691 | ||
| 717 | /// Sets duty cycle (15 bit) for a PWM channel. | 692 | /// Sets duty cycle (15 bit) for a PWM channel. |
| 718 | pub fn set_duty(&mut self, channel: usize, duty: u16) { | 693 | pub fn set_duty(&mut self, channel: usize, duty: u16) { |
| 719 | let r = T::regs(); | ||
| 720 | |||
| 721 | self.duty[channel] = duty & 0x7FFF; | 694 | self.duty[channel] = duty & 0x7FFF; |
| 722 | 695 | ||
| 723 | // reload ptr in case self was moved | 696 | // reload ptr in case self was moved |
| 724 | r.seq(0).ptr().write_value((self.duty).as_ptr() as u32); | 697 | self.r.seq(0).ptr().write_value((self.duty).as_ptr() as u32); |
| 725 | 698 | ||
| 726 | // defensive before seqstart | 699 | // defensive before seqstart |
| 727 | compiler_fence(Ordering::SeqCst); | 700 | compiler_fence(Ordering::SeqCst); |
| 728 | 701 | ||
| 729 | r.events_seqend(0).write_value(0); | 702 | self.r.events_seqend(0).write_value(0); |
| 730 | 703 | ||
| 731 | // tasks_seqstart() doesn't exist in all svds so write its bit instead | 704 | // tasks_seqstart() doesn't exist in all svds so write its bit instead |
| 732 | r.tasks_seqstart(0).write_value(1); | 705 | self.r.tasks_seqstart(0).write_value(1); |
| 733 | 706 | ||
| 734 | // defensive wait until waveform is loaded after seqstart so set_duty | 707 | // defensive wait until waveform is loaded after seqstart so set_duty |
| 735 | // can't be called again while dma is still reading | 708 | // can't be called again while dma is still reading |
| 736 | if self.is_enabled() { | 709 | if self.is_enabled() { |
| 737 | while r.events_seqend(0).read() == 0 {} | 710 | while self.r.events_seqend(0).read() == 0 {} |
| 738 | } | 711 | } |
| 739 | } | 712 | } |
| 740 | 713 | ||
| 741 | /// Sets the PWM clock prescaler. | 714 | /// Sets the PWM clock prescaler. |
| 742 | #[inline(always)] | 715 | #[inline(always)] |
| 743 | pub fn set_prescaler(&self, div: Prescaler) { | 716 | pub fn set_prescaler(&self, div: Prescaler) { |
| 744 | T::regs() | 717 | self.r |
| 745 | .prescaler() | 718 | .prescaler() |
| 746 | .write(|w| w.set_prescaler(vals::Prescaler::from_bits(div as u8))); | 719 | .write(|w| w.set_prescaler(vals::Prescaler::from_bits(div as u8))); |
| 747 | } | 720 | } |
| @@ -749,7 +722,7 @@ impl<'d, T: Instance> SimplePwm<'d, T> { | |||
| 749 | /// Gets the PWM clock prescaler. | 722 | /// Gets the PWM clock prescaler. |
| 750 | #[inline(always)] | 723 | #[inline(always)] |
| 751 | pub fn prescaler(&self) -> Prescaler { | 724 | pub fn prescaler(&self) -> Prescaler { |
| 752 | match T::regs().prescaler().read().prescaler().to_bits() { | 725 | match self.r.prescaler().read().prescaler().to_bits() { |
| 753 | 0 => Prescaler::Div1, | 726 | 0 => Prescaler::Div1, |
| 754 | 1 => Prescaler::Div2, | 727 | 1 => Prescaler::Div2, |
| 755 | 2 => Prescaler::Div4, | 728 | 2 => Prescaler::Div4, |
| @@ -765,13 +738,13 @@ impl<'d, T: Instance> SimplePwm<'d, T> { | |||
| 765 | /// Sets the maximum duty cycle value. | 738 | /// Sets the maximum duty cycle value. |
| 766 | #[inline(always)] | 739 | #[inline(always)] |
| 767 | pub fn set_max_duty(&self, duty: u16) { | 740 | pub fn set_max_duty(&self, duty: u16) { |
| 768 | T::regs().countertop().write(|w| w.set_countertop(duty.min(32767u16))); | 741 | self.r.countertop().write(|w| w.set_countertop(duty.min(32767u16))); |
| 769 | } | 742 | } |
| 770 | 743 | ||
| 771 | /// Returns the maximum duty cycle value. | 744 | /// Returns the maximum duty cycle value. |
| 772 | #[inline(always)] | 745 | #[inline(always)] |
| 773 | pub fn max_duty(&self) -> u16 { | 746 | pub fn max_duty(&self) -> u16 { |
| 774 | T::regs().countertop().read().countertop() | 747 | self.r.countertop().read().countertop() |
| 775 | } | 748 | } |
| 776 | 749 | ||
| 777 | /// Sets the PWM output frequency. | 750 | /// Sets the PWM output frequency. |
| @@ -823,9 +796,9 @@ impl<'d, T: Instance> SimplePwm<'d, T> { | |||
| 823 | } | 796 | } |
| 824 | } | 797 | } |
| 825 | 798 | ||
| 826 | impl<'a, T: Instance> Drop for SimplePwm<'a, T> { | 799 | impl<'a> Drop for SimplePwm<'a> { |
| 827 | fn drop(&mut self) { | 800 | fn drop(&mut self) { |
| 828 | let r = T::regs(); | 801 | let r = &self.r; |
| 829 | 802 | ||
| 830 | self.disable(); | 803 | self.disable(); |
| 831 | 804 | ||
diff --git a/embassy-nrf/src/qdec.rs b/embassy-nrf/src/qdec.rs index 69bfab0bb..0ebd7afb8 100644 --- a/embassy-nrf/src/qdec.rs +++ b/embassy-nrf/src/qdec.rs | |||
| @@ -16,8 +16,10 @@ use crate::pac::qdec::vals; | |||
| 16 | use crate::{interrupt, pac}; | 16 | use crate::{interrupt, pac}; |
| 17 | 17 | ||
| 18 | /// Quadrature decoder driver. | 18 | /// Quadrature decoder driver. |
| 19 | pub struct Qdec<'d, T: Instance> { | 19 | pub struct Qdec<'d> { |
| 20 | _p: Peri<'d, T>, | 20 | r: pac::qdec::Qdec, |
| 21 | state: &'static State, | ||
| 22 | _phantom: PhantomData<&'d ()>, | ||
| 21 | } | 23 | } |
| 22 | 24 | ||
| 23 | /// QDEC config | 25 | /// QDEC config |
| @@ -59,9 +61,9 @@ impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandl | |||
| 59 | } | 61 | } |
| 60 | } | 62 | } |
| 61 | 63 | ||
| 62 | impl<'d, T: Instance> Qdec<'d, T> { | 64 | impl<'d> Qdec<'d> { |
| 63 | /// Create a new QDEC. | 65 | /// Create a new QDEC. |
| 64 | pub fn new( | 66 | pub fn new<T: Instance>( |
| 65 | qdec: Peri<'d, T>, | 67 | qdec: Peri<'d, T>, |
| 66 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 68 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 67 | a: Peri<'d, impl GpioPin>, | 69 | a: Peri<'d, impl GpioPin>, |
| @@ -72,7 +74,7 @@ impl<'d, T: Instance> Qdec<'d, T> { | |||
| 72 | } | 74 | } |
| 73 | 75 | ||
| 74 | /// Create a new QDEC, with a pin for LED output. | 76 | /// Create a new QDEC, with a pin for LED output. |
| 75 | pub fn new_with_led( | 77 | pub fn new_with_led<T: Instance>( |
| 76 | qdec: Peri<'d, T>, | 78 | qdec: Peri<'d, T>, |
| 77 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 79 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 78 | a: Peri<'d, impl GpioPin>, | 80 | a: Peri<'d, impl GpioPin>, |
| @@ -83,8 +85,8 @@ impl<'d, T: Instance> Qdec<'d, T> { | |||
| 83 | Self::new_inner(qdec, a.into(), b.into(), Some(led.into()), config) | 85 | Self::new_inner(qdec, a.into(), b.into(), Some(led.into()), config) |
| 84 | } | 86 | } |
| 85 | 87 | ||
| 86 | fn new_inner( | 88 | fn new_inner<T: Instance>( |
| 87 | p: Peri<'d, T>, | 89 | _p: Peri<'d, T>, |
| 88 | a: Peri<'d, AnyPin>, | 90 | a: Peri<'d, AnyPin>, |
| 89 | b: Peri<'d, AnyPin>, | 91 | b: Peri<'d, AnyPin>, |
| 90 | led: Option<Peri<'d, AnyPin>>, | 92 | led: Option<Peri<'d, AnyPin>>, |
| @@ -147,7 +149,11 @@ impl<'d, T: Instance> Qdec<'d, T> { | |||
| 147 | // Start sampling | 149 | // Start sampling |
| 148 | r.tasks_start().write_value(1); | 150 | r.tasks_start().write_value(1); |
| 149 | 151 | ||
| 150 | Self { _p: p } | 152 | Self { |
| 153 | r: T::regs(), | ||
| 154 | state: T::state(), | ||
| 155 | _phantom: PhantomData, | ||
| 156 | } | ||
| 151 | } | 157 | } |
| 152 | 158 | ||
| 153 | /// Perform an asynchronous read of the decoder. | 159 | /// Perform an asynchronous read of the decoder. |
| @@ -173,17 +179,18 @@ impl<'d, T: Instance> Qdec<'d, T> { | |||
| 173 | /// # }; | 179 | /// # }; |
| 174 | /// ``` | 180 | /// ``` |
| 175 | pub async fn read(&mut self) -> i16 { | 181 | pub async fn read(&mut self) -> i16 { |
| 176 | let t = T::regs(); | 182 | self.r.intenset().write(|w| w.set_reportrdy(true)); |
| 177 | t.intenset().write(|w| w.set_reportrdy(true)); | 183 | self.r.tasks_readclracc().write_value(1); |
| 178 | t.tasks_readclracc().write_value(1); | ||
| 179 | 184 | ||
| 180 | poll_fn(|cx| { | 185 | let state = self.state; |
| 181 | T::state().waker.register(cx.waker()); | 186 | let r = self.r; |
| 182 | if t.events_reportrdy().read() == 0 { | 187 | poll_fn(move |cx| { |
| 188 | state.waker.register(cx.waker()); | ||
| 189 | if r.events_reportrdy().read() == 0 { | ||
| 183 | Poll::Pending | 190 | Poll::Pending |
| 184 | } else { | 191 | } else { |
| 185 | t.events_reportrdy().write_value(0); | 192 | r.events_reportrdy().write_value(0); |
| 186 | let acc = t.accread().read(); | 193 | let acc = r.accread().read(); |
| 187 | Poll::Ready(acc as i16) | 194 | Poll::Ready(acc as i16) |
| 188 | } | 195 | } |
| 189 | }) | 196 | }) |
diff --git a/embassy-nrf/src/qspi.rs b/embassy-nrf/src/qspi.rs index e6e829f6e..6bb7c033e 100755 --- a/embassy-nrf/src/qspi.rs +++ b/embassy-nrf/src/qspi.rs | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | #![macro_use] | 3 | #![macro_use] |
| 4 | 4 | ||
| 5 | use core::future::{poll_fn, Future}; | 5 | use core::future::{Future, poll_fn}; |
| 6 | use core::marker::PhantomData; | 6 | use core::marker::PhantomData; |
| 7 | use core::ptr; | 7 | use core::ptr; |
| 8 | use core::task::Poll; | 8 | use core::task::Poll; |
| @@ -138,16 +138,18 @@ impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandl | |||
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | /// QSPI flash driver. | 140 | /// QSPI flash driver. |
| 141 | pub struct Qspi<'d, T: Instance> { | 141 | pub struct Qspi<'d> { |
| 142 | _peri: Peri<'d, T>, | 142 | r: pac::qspi::Qspi, |
| 143 | state: &'static State, | ||
| 143 | dpm_enabled: bool, | 144 | dpm_enabled: bool, |
| 144 | capacity: u32, | 145 | capacity: u32, |
| 146 | _phantom: PhantomData<&'d ()>, | ||
| 145 | } | 147 | } |
| 146 | 148 | ||
| 147 | impl<'d, T: Instance> Qspi<'d, T> { | 149 | impl<'d> Qspi<'d> { |
| 148 | /// Create a new QSPI driver. | 150 | /// Create a new QSPI driver. |
| 149 | pub fn new( | 151 | pub fn new<T: Instance>( |
| 150 | qspi: Peri<'d, T>, | 152 | _qspi: Peri<'d, T>, |
| 151 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 153 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 152 | sck: Peri<'d, impl GpioPin>, | 154 | sck: Peri<'d, impl GpioPin>, |
| 153 | csn: Peri<'d, impl GpioPin>, | 155 | csn: Peri<'d, impl GpioPin>, |
| @@ -214,9 +216,11 @@ impl<'d, T: Instance> Qspi<'d, T> { | |||
| 214 | r.enable().write(|w| w.set_enable(true)); | 216 | r.enable().write(|w| w.set_enable(true)); |
| 215 | 217 | ||
| 216 | let res = Self { | 218 | let res = Self { |
| 217 | _peri: qspi, | 219 | r: T::regs(), |
| 220 | state: T::state(), | ||
| 218 | dpm_enabled: config.deep_power_down.is_some(), | 221 | dpm_enabled: config.deep_power_down.is_some(), |
| 219 | capacity: config.capacity, | 222 | capacity: config.capacity, |
| 223 | _phantom: PhantomData, | ||
| 220 | }; | 224 | }; |
| 221 | 225 | ||
| 222 | r.events_ready().write_value(0); | 226 | r.events_ready().write_value(0); |
| @@ -274,14 +278,13 @@ impl<'d, T: Instance> Qspi<'d, T> { | |||
| 274 | } | 278 | } |
| 275 | } | 279 | } |
| 276 | 280 | ||
| 277 | let r = T::regs(); | 281 | self.r.cinstrdat0().write(|w| w.0 = dat0); |
| 278 | r.cinstrdat0().write(|w| w.0 = dat0); | 282 | self.r.cinstrdat1().write(|w| w.0 = dat1); |
| 279 | r.cinstrdat1().write(|w| w.0 = dat1); | ||
| 280 | 283 | ||
| 281 | r.events_ready().write_value(0); | 284 | self.r.events_ready().write_value(0); |
| 282 | r.intenset().write(|w| w.set_ready(true)); | 285 | self.r.intenset().write(|w| w.set_ready(true)); |
| 283 | 286 | ||
| 284 | r.cinstrconf().write(|w| { | 287 | self.r.cinstrconf().write(|w| { |
| 285 | w.set_opcode(opcode); | 288 | w.set_opcode(opcode); |
| 286 | w.set_length(vals::Length::from_bits(len + 1)); | 289 | w.set_length(vals::Length::from_bits(len + 1)); |
| 287 | w.set_lio2(true); | 290 | w.set_lio2(true); |
| @@ -295,10 +298,8 @@ impl<'d, T: Instance> Qspi<'d, T> { | |||
| 295 | } | 298 | } |
| 296 | 299 | ||
| 297 | fn custom_instruction_finish(&mut self, resp: &mut [u8]) -> Result<(), Error> { | 300 | fn custom_instruction_finish(&mut self, resp: &mut [u8]) -> Result<(), Error> { |
| 298 | let r = T::regs(); | 301 | let dat0 = self.r.cinstrdat0().read().0; |
| 299 | 302 | let dat1 = self.r.cinstrdat1().read().0; | |
| 300 | let dat0 = r.cinstrdat0().read().0; | ||
| 301 | let dat1 = r.cinstrdat1().read().0; | ||
| 302 | for i in 0..4 { | 303 | for i in 0..4 { |
| 303 | if i < resp.len() { | 304 | if i < resp.len() { |
| 304 | resp[i] = (dat0 >> (i * 8)) as u8; | 305 | resp[i] = (dat0 >> (i * 8)) as u8; |
| @@ -313,9 +314,9 @@ impl<'d, T: Instance> Qspi<'d, T> { | |||
| 313 | } | 314 | } |
| 314 | 315 | ||
| 315 | fn wait_ready(&mut self) -> impl Future<Output = ()> { | 316 | fn wait_ready(&mut self) -> impl Future<Output = ()> { |
| 317 | let r = self.r; | ||
| 318 | let s = self.state; | ||
| 316 | poll_fn(move |cx| { | 319 | poll_fn(move |cx| { |
| 317 | let r = T::regs(); | ||
| 318 | let s = T::state(); | ||
| 319 | s.waker.register(cx.waker()); | 320 | s.waker.register(cx.waker()); |
| 320 | if r.events_ready().read() != 0 { | 321 | if r.events_ready().read() != 0 { |
| 321 | return Poll::Ready(()); | 322 | return Poll::Ready(()); |
| @@ -326,7 +327,7 @@ impl<'d, T: Instance> Qspi<'d, T> { | |||
| 326 | 327 | ||
| 327 | fn blocking_wait_ready() { | 328 | fn blocking_wait_ready() { |
| 328 | loop { | 329 | loop { |
| 329 | let r = T::regs(); | 330 | let r = pac::QSPI; |
| 330 | if r.events_ready().read() != 0 { | 331 | if r.events_ready().read() != 0 { |
| 331 | break; | 332 | break; |
| 332 | } | 333 | } |
| @@ -339,15 +340,13 @@ impl<'d, T: Instance> Qspi<'d, T> { | |||
| 339 | assert_eq!(data.len() as u32 % 4, 0); | 340 | assert_eq!(data.len() as u32 % 4, 0); |
| 340 | assert_eq!(address % 4, 0); | 341 | assert_eq!(address % 4, 0); |
| 341 | 342 | ||
| 342 | let r = T::regs(); | 343 | self.r.read().src().write_value(address); |
| 343 | 344 | self.r.read().dst().write_value(data.as_ptr() as u32); | |
| 344 | r.read().src().write_value(address); | 345 | self.r.read().cnt().write(|w| w.set_cnt(data.len() as u32)); |
| 345 | r.read().dst().write_value(data.as_ptr() as u32); | ||
| 346 | r.read().cnt().write(|w| w.set_cnt(data.len() as u32)); | ||
| 347 | 346 | ||
| 348 | r.events_ready().write_value(0); | 347 | self.r.events_ready().write_value(0); |
| 349 | r.intenset().write(|w| w.set_ready(true)); | 348 | self.r.intenset().write(|w| w.set_ready(true)); |
| 350 | r.tasks_readstart().write_value(1); | 349 | self.r.tasks_readstart().write_value(1); |
| 351 | 350 | ||
| 352 | Ok(()) | 351 | Ok(()) |
| 353 | } | 352 | } |
| @@ -358,14 +357,13 @@ impl<'d, T: Instance> Qspi<'d, T> { | |||
| 358 | assert_eq!(data.len() as u32 % 4, 0); | 357 | assert_eq!(data.len() as u32 % 4, 0); |
| 359 | assert_eq!(address % 4, 0); | 358 | assert_eq!(address % 4, 0); |
| 360 | 359 | ||
| 361 | let r = T::regs(); | 360 | self.r.write().src().write_value(data.as_ptr() as u32); |
| 362 | r.write().src().write_value(data.as_ptr() as u32); | 361 | self.r.write().dst().write_value(address); |
| 363 | r.write().dst().write_value(address); | 362 | self.r.write().cnt().write(|w| w.set_cnt(data.len() as u32)); |
| 364 | r.write().cnt().write(|w| w.set_cnt(data.len() as u32)); | ||
| 365 | 363 | ||
| 366 | r.events_ready().write_value(0); | 364 | self.r.events_ready().write_value(0); |
| 367 | r.intenset().write(|w| w.set_ready(true)); | 365 | self.r.intenset().write(|w| w.set_ready(true)); |
| 368 | r.tasks_writestart().write_value(1); | 366 | self.r.tasks_writestart().write_value(1); |
| 369 | 367 | ||
| 370 | Ok(()) | 368 | Ok(()) |
| 371 | } | 369 | } |
| @@ -374,13 +372,12 @@ impl<'d, T: Instance> Qspi<'d, T> { | |||
| 374 | // TODO: Return these as errors instead. | 372 | // TODO: Return these as errors instead. |
| 375 | assert_eq!(address % 4096, 0); | 373 | assert_eq!(address % 4096, 0); |
| 376 | 374 | ||
| 377 | let r = T::regs(); | 375 | self.r.erase().ptr().write_value(address); |
| 378 | r.erase().ptr().write_value(address); | 376 | self.r.erase().len().write(|w| w.set_len(vals::Len::_4KB)); |
| 379 | r.erase().len().write(|w| w.set_len(vals::Len::_4KB)); | ||
| 380 | 377 | ||
| 381 | r.events_ready().write_value(0); | 378 | self.r.events_ready().write_value(0); |
| 382 | r.intenset().write(|w| w.set_ready(true)); | 379 | self.r.intenset().write(|w| w.set_ready(true)); |
| 383 | r.tasks_erasestart().write_value(1); | 380 | self.r.tasks_erasestart().write_value(1); |
| 384 | 381 | ||
| 385 | Ok(()) | 382 | Ok(()) |
| 386 | } | 383 | } |
| @@ -520,19 +517,17 @@ impl<'d, T: Instance> Qspi<'d, T> { | |||
| 520 | } | 517 | } |
| 521 | } | 518 | } |
| 522 | 519 | ||
| 523 | impl<'d, T: Instance> Drop for Qspi<'d, T> { | 520 | impl<'d> Drop for Qspi<'d> { |
| 524 | fn drop(&mut self) { | 521 | fn drop(&mut self) { |
| 525 | let r = T::regs(); | ||
| 526 | |||
| 527 | if self.dpm_enabled { | 522 | if self.dpm_enabled { |
| 528 | trace!("qspi: doing deep powerdown..."); | 523 | trace!("qspi: doing deep powerdown..."); |
| 529 | 524 | ||
| 530 | r.ifconfig1().modify(|w| w.set_dpmen(true)); | 525 | self.r.ifconfig1().modify(|w| w.set_dpmen(true)); |
| 531 | 526 | ||
| 532 | // Wait for DPM enter. | 527 | // Wait for DPM enter. |
| 533 | // Unfortunately we must spin. There's no way to do this interrupt-driven. | 528 | // Unfortunately we must spin. There's no way to do this interrupt-driven. |
| 534 | // The READY event does NOT fire on DPM enter (but it does fire on DPM exit :shrug:) | 529 | // The READY event does NOT fire on DPM enter (but it does fire on DPM exit :shrug:) |
| 535 | while !r.status().read().dpm() {} | 530 | while !self.r.status().read().dpm() {} |
| 536 | 531 | ||
| 537 | // Wait MORE for DPM enter. | 532 | // Wait MORE for DPM enter. |
| 538 | // I have absolutely no idea why, but the wait above is not enough :'( | 533 | // I have absolutely no idea why, but the wait above is not enough :'( |
| @@ -541,29 +536,29 @@ impl<'d, T: Instance> Drop for Qspi<'d, T> { | |||
| 541 | } | 536 | } |
| 542 | 537 | ||
| 543 | // it seems events_ready is not generated in response to deactivate. nrfx doesn't wait for it. | 538 | // it seems events_ready is not generated in response to deactivate. nrfx doesn't wait for it. |
| 544 | r.tasks_deactivate().write_value(1); | 539 | self.r.tasks_deactivate().write_value(1); |
| 545 | 540 | ||
| 546 | // Workaround https://docs.nordicsemi.com/bundle/errata_nRF52840_Rev3/page/ERR/nRF52840/Rev3/latest/anomaly_840_122.html | 541 | // Workaround https://docs.nordicsemi.com/bundle/errata_nRF52840_Rev3/page/ERR/nRF52840/Rev3/latest/anomaly_840_122.html |
| 547 | // Note that the doc has 2 register writes, but the first one is really the write to tasks_deactivate, | 542 | // Note that the doc has 2 register writes, but the first one is really the write to tasks_deactivate, |
| 548 | // so we only do the second one here. | 543 | // so we only do the second one here. |
| 549 | unsafe { ptr::write_volatile(0x40029054 as *mut u32, 1) } | 544 | unsafe { ptr::write_volatile(0x40029054 as *mut u32, 1) } |
| 550 | 545 | ||
| 551 | r.enable().write(|w| w.set_enable(false)); | 546 | self.r.enable().write(|w| w.set_enable(false)); |
| 552 | 547 | ||
| 553 | // Note: we do NOT deconfigure CSN here. If DPM is in use and we disconnect CSN, | 548 | // Note: we do NOT deconfigure CSN here. If DPM is in use and we disconnect CSN, |
| 554 | // leaving it floating, the flash chip might read it as zero which would cause it to | 549 | // leaving it floating, the flash chip might read it as zero which would cause it to |
| 555 | // spuriously exit DPM. | 550 | // spuriously exit DPM. |
| 556 | gpio::deconfigure_pin(r.psel().sck().read()); | 551 | gpio::deconfigure_pin(self.r.psel().sck().read()); |
| 557 | gpio::deconfigure_pin(r.psel().io0().read()); | 552 | gpio::deconfigure_pin(self.r.psel().io0().read()); |
| 558 | gpio::deconfigure_pin(r.psel().io1().read()); | 553 | gpio::deconfigure_pin(self.r.psel().io1().read()); |
| 559 | gpio::deconfigure_pin(r.psel().io2().read()); | 554 | gpio::deconfigure_pin(self.r.psel().io2().read()); |
| 560 | gpio::deconfigure_pin(r.psel().io3().read()); | 555 | gpio::deconfigure_pin(self.r.psel().io3().read()); |
| 561 | 556 | ||
| 562 | trace!("qspi: dropped"); | 557 | trace!("qspi: dropped"); |
| 563 | } | 558 | } |
| 564 | } | 559 | } |
| 565 | 560 | ||
| 566 | impl<'d, T: Instance> ErrorType for Qspi<'d, T> { | 561 | impl<'d> ErrorType for Qspi<'d> { |
| 567 | type Error = Error; | 562 | type Error = Error; |
| 568 | } | 563 | } |
| 569 | 564 | ||
| @@ -573,7 +568,7 @@ impl NorFlashError for Error { | |||
| 573 | } | 568 | } |
| 574 | } | 569 | } |
| 575 | 570 | ||
| 576 | impl<'d, T: Instance> ReadNorFlash for Qspi<'d, T> { | 571 | impl<'d> ReadNorFlash for Qspi<'d> { |
| 577 | const READ_SIZE: usize = 4; | 572 | const READ_SIZE: usize = 4; |
| 578 | 573 | ||
| 579 | fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { | 574 | fn read(&mut self, offset: u32, bytes: &mut [u8]) -> Result<(), Self::Error> { |
| @@ -586,7 +581,7 @@ impl<'d, T: Instance> ReadNorFlash for Qspi<'d, T> { | |||
| 586 | } | 581 | } |
| 587 | } | 582 | } |
| 588 | 583 | ||
| 589 | impl<'d, T: Instance> NorFlash for Qspi<'d, T> { | 584 | impl<'d> NorFlash for Qspi<'d> { |
| 590 | const WRITE_SIZE: usize = 4; | 585 | const WRITE_SIZE: usize = 4; |
| 591 | const ERASE_SIZE: usize = 4096; | 586 | const ERASE_SIZE: usize = 4096; |
| 592 | 587 | ||
| @@ -604,14 +599,14 @@ impl<'d, T: Instance> NorFlash for Qspi<'d, T> { | |||
| 604 | } | 599 | } |
| 605 | 600 | ||
| 606 | #[cfg(feature = "qspi-multiwrite-flash")] | 601 | #[cfg(feature = "qspi-multiwrite-flash")] |
| 607 | impl<'d, T: Instance> embedded_storage::nor_flash::MultiwriteNorFlash for Qspi<'d, T> {} | 602 | impl<'d> embedded_storage::nor_flash::MultiwriteNorFlash for Qspi<'d> {} |
| 608 | 603 | ||
| 609 | mod _eh1 { | 604 | mod _eh1 { |
| 610 | use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash}; | 605 | use embedded_storage_async::nor_flash::{NorFlash as AsyncNorFlash, ReadNorFlash as AsyncReadNorFlash}; |
| 611 | 606 | ||
| 612 | use super::*; | 607 | use super::*; |
| 613 | 608 | ||
| 614 | impl<'d, T: Instance> AsyncNorFlash for Qspi<'d, T> { | 609 | impl<'d> AsyncNorFlash for Qspi<'d> { |
| 615 | const WRITE_SIZE: usize = <Self as NorFlash>::WRITE_SIZE; | 610 | const WRITE_SIZE: usize = <Self as NorFlash>::WRITE_SIZE; |
| 616 | const ERASE_SIZE: usize = <Self as NorFlash>::ERASE_SIZE; | 611 | const ERASE_SIZE: usize = <Self as NorFlash>::ERASE_SIZE; |
| 617 | 612 | ||
| @@ -627,7 +622,7 @@ mod _eh1 { | |||
| 627 | } | 622 | } |
| 628 | } | 623 | } |
| 629 | 624 | ||
| 630 | impl<'d, T: Instance> AsyncReadNorFlash for Qspi<'d, T> { | 625 | impl<'d> AsyncReadNorFlash for Qspi<'d> { |
| 631 | const READ_SIZE: usize = 4; | 626 | const READ_SIZE: usize = 4; |
| 632 | async fn read(&mut self, address: u32, data: &mut [u8]) -> Result<(), Self::Error> { | 627 | async fn read(&mut self, address: u32, data: &mut [u8]) -> Result<(), Self::Error> { |
| 633 | self.read(address, data).await | 628 | self.read(address, data).await |
| @@ -639,7 +634,7 @@ mod _eh1 { | |||
| 639 | } | 634 | } |
| 640 | 635 | ||
| 641 | #[cfg(feature = "qspi-multiwrite-flash")] | 636 | #[cfg(feature = "qspi-multiwrite-flash")] |
| 642 | impl<'d, T: Instance> embedded_storage_async::nor_flash::MultiwriteNorFlash for Qspi<'d, T> {} | 637 | impl<'d> embedded_storage_async::nor_flash::MultiwriteNorFlash for Qspi<'d> {} |
| 643 | } | 638 | } |
| 644 | 639 | ||
| 645 | /// Peripheral static state | 640 | /// Peripheral static state |
diff --git a/embassy-nrf/src/radio/ieee802154.rs b/embassy-nrf/src/radio/ieee802154.rs index 7f4f8f462..54b463343 100644 --- a/embassy-nrf/src/radio/ieee802154.rs +++ b/embassy-nrf/src/radio/ieee802154.rs | |||
| @@ -1,16 +1,18 @@ | |||
| 1 | //! IEEE 802.15.4 radio driver | 1 | //! IEEE 802.15.4 radio driver |
| 2 | 2 | ||
| 3 | use core::sync::atomic::{compiler_fence, Ordering}; | 3 | use core::marker::PhantomData; |
| 4 | use core::sync::atomic::{Ordering, compiler_fence}; | ||
| 4 | use core::task::Poll; | 5 | use core::task::Poll; |
| 5 | 6 | ||
| 6 | use embassy_hal_internal::drop::OnDrop; | 7 | use embassy_hal_internal::drop::OnDrop; |
| 7 | 8 | ||
| 8 | use super::{Error, Instance, InterruptHandler, TxPower}; | 9 | use super::{Error, InterruptHandler, TxPower}; |
| 10 | use crate::Peri; | ||
| 9 | use crate::interrupt::typelevel::Interrupt; | 11 | use crate::interrupt::typelevel::Interrupt; |
| 10 | use crate::interrupt::{self}; | 12 | use crate::interrupt::{self}; |
| 11 | use crate::pac::radio::vals; | 13 | use crate::pac::radio::vals; |
| 12 | pub use crate::pac::radio::vals::State as RadioState; | 14 | pub use crate::pac::radio::vals::State as RadioState; |
| 13 | use crate::Peri; | 15 | use crate::radio::Instance; |
| 14 | 16 | ||
| 15 | /// Default (IEEE compliant) Start of Frame Delimiter | 17 | /// Default (IEEE compliant) Start of Frame Delimiter |
| 16 | pub const DEFAULT_SFD: u8 = 0xA7; | 18 | pub const DEFAULT_SFD: u8 = 0xA7; |
| @@ -32,22 +34,25 @@ pub enum Cca { | |||
| 32 | } | 34 | } |
| 33 | 35 | ||
| 34 | /// IEEE 802.15.4 radio driver. | 36 | /// IEEE 802.15.4 radio driver. |
| 35 | pub struct Radio<'d, T: Instance> { | 37 | pub struct Radio<'d> { |
| 36 | _p: Peri<'d, T>, | 38 | r: crate::pac::radio::Radio, |
| 39 | state: &'static crate::radio::State, | ||
| 37 | needs_enable: bool, | 40 | needs_enable: bool, |
| 41 | phantom: PhantomData<&'d ()>, | ||
| 38 | } | 42 | } |
| 39 | 43 | ||
| 40 | impl<'d, T: Instance> Radio<'d, T> { | 44 | impl<'d> Radio<'d> { |
| 41 | /// Create a new IEEE 802.15.4 radio driver. | 45 | /// Create a new IEEE 802.15.4 radio driver. |
| 42 | pub fn new( | 46 | pub fn new<T: Instance>( |
| 43 | radio: Peri<'d, T>, | 47 | _radio: Peri<'d, T>, |
| 44 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 48 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 45 | ) -> Self { | 49 | ) -> Self { |
| 46 | let r = T::regs(); | 50 | let r = crate::pac::RADIO; |
| 47 | 51 | ||
| 48 | // Disable and enable to reset peripheral | 52 | // Disable and enable to reset peripheral |
| 49 | r.power().write(|w| w.set_power(false)); | 53 | r.power().write(|w| w.set_power(false)); |
| 50 | r.power().write(|w| w.set_power(true)); | 54 | r.power().write(|w| w.set_power(true)); |
| 55 | errata::post_power(); | ||
| 51 | 56 | ||
| 52 | // Enable 802.15.4 mode | 57 | // Enable 802.15.4 mode |
| 53 | r.mode().write(|w| w.set_mode(vals::Mode::IEEE802154_250KBIT)); | 58 | r.mode().write(|w| w.set_mode(vals::Mode::IEEE802154_250KBIT)); |
| @@ -89,12 +94,14 @@ impl<'d, T: Instance> Radio<'d, T> { | |||
| 89 | }); | 94 | }); |
| 90 | 95 | ||
| 91 | // Enable NVIC interrupt | 96 | // Enable NVIC interrupt |
| 92 | T::Interrupt::unpend(); | 97 | crate::interrupt::typelevel::RADIO::unpend(); |
| 93 | unsafe { T::Interrupt::enable() }; | 98 | unsafe { crate::interrupt::typelevel::RADIO::enable() }; |
| 94 | 99 | ||
| 95 | let mut radio = Self { | 100 | let mut radio = Self { |
| 96 | _p: radio, | 101 | r: crate::pac::RADIO, |
| 102 | state: T::state(), | ||
| 97 | needs_enable: false, | 103 | needs_enable: false, |
| 104 | phantom: PhantomData, | ||
| 98 | }; | 105 | }; |
| 99 | 106 | ||
| 100 | radio.set_sfd(DEFAULT_SFD); | 107 | radio.set_sfd(DEFAULT_SFD); |
| @@ -107,7 +114,7 @@ impl<'d, T: Instance> Radio<'d, T> { | |||
| 107 | 114 | ||
| 108 | /// Changes the radio channel | 115 | /// Changes the radio channel |
| 109 | pub fn set_channel(&mut self, channel: u8) { | 116 | pub fn set_channel(&mut self, channel: u8) { |
| 110 | let r = T::regs(); | 117 | let r = self.r; |
| 111 | if channel < 11 || channel > 26 { | 118 | if channel < 11 || channel > 26 { |
| 112 | panic!("Bad 802.15.4 channel"); | 119 | panic!("Bad 802.15.4 channel"); |
| 113 | } | 120 | } |
| @@ -121,7 +128,7 @@ impl<'d, T: Instance> Radio<'d, T> { | |||
| 121 | 128 | ||
| 122 | /// Changes the Clear Channel Assessment method | 129 | /// Changes the Clear Channel Assessment method |
| 123 | pub fn set_cca(&mut self, cca: Cca) { | 130 | pub fn set_cca(&mut self, cca: Cca) { |
| 124 | let r = T::regs(); | 131 | let r = self.r; |
| 125 | self.needs_enable = true; | 132 | self.needs_enable = true; |
| 126 | match cca { | 133 | match cca { |
| 127 | Cca::CarrierSense => r.ccactrl().write(|w| w.set_ccamode(vals::Ccamode::CARRIER_MODE)), | 134 | Cca::CarrierSense => r.ccactrl().write(|w| w.set_ccamode(vals::Ccamode::CARRIER_MODE)), |
| @@ -138,19 +145,19 @@ impl<'d, T: Instance> Radio<'d, T> { | |||
| 138 | 145 | ||
| 139 | /// Changes the Start of Frame Delimiter (SFD) | 146 | /// Changes the Start of Frame Delimiter (SFD) |
| 140 | pub fn set_sfd(&mut self, sfd: u8) { | 147 | pub fn set_sfd(&mut self, sfd: u8) { |
| 141 | let r = T::regs(); | 148 | let r = self.r; |
| 142 | r.sfd().write(|w| w.set_sfd(sfd)); | 149 | r.sfd().write(|w| w.set_sfd(sfd)); |
| 143 | } | 150 | } |
| 144 | 151 | ||
| 145 | /// Clear interrupts | 152 | /// Clear interrupts |
| 146 | pub fn clear_all_interrupts(&mut self) { | 153 | pub fn clear_all_interrupts(&mut self) { |
| 147 | let r = T::regs(); | 154 | let r = self.r; |
| 148 | r.intenclr().write(|w| w.0 = 0xffff_ffff); | 155 | r.intenclr().write(|w| w.0 = 0xffff_ffff); |
| 149 | } | 156 | } |
| 150 | 157 | ||
| 151 | /// Changes the radio transmission power | 158 | /// Changes the radio transmission power |
| 152 | pub fn set_transmission_power(&mut self, power: i8) { | 159 | pub fn set_transmission_power(&mut self, power: i8) { |
| 153 | let r = T::regs(); | 160 | let r = self.r; |
| 154 | self.needs_enable = true; | 161 | self.needs_enable = true; |
| 155 | 162 | ||
| 156 | let tx_power: TxPower = match power { | 163 | let tx_power: TxPower = match power { |
| @@ -201,12 +208,12 @@ impl<'d, T: Instance> Radio<'d, T> { | |||
| 201 | 208 | ||
| 202 | /// Get the current radio state | 209 | /// Get the current radio state |
| 203 | fn state(&self) -> RadioState { | 210 | fn state(&self) -> RadioState { |
| 204 | T::regs().state().read().state() | 211 | self.r.state().read().state() |
| 205 | } | 212 | } |
| 206 | 213 | ||
| 207 | /// Moves the radio from any state to the DISABLED state | 214 | /// Moves the radio from any state to the DISABLED state |
| 208 | fn disable(&mut self) { | 215 | fn disable(&mut self) { |
| 209 | let r = T::regs(); | 216 | let r = self.r; |
| 210 | // See figure 110 in nRF52840-PS | 217 | // See figure 110 in nRF52840-PS |
| 211 | loop { | 218 | loop { |
| 212 | match self.state() { | 219 | match self.state() { |
| @@ -238,15 +245,15 @@ impl<'d, T: Instance> Radio<'d, T> { | |||
| 238 | } | 245 | } |
| 239 | 246 | ||
| 240 | fn set_buffer(&mut self, buffer: &[u8]) { | 247 | fn set_buffer(&mut self, buffer: &[u8]) { |
| 241 | let r = T::regs(); | 248 | let r = self.r; |
| 242 | r.packetptr().write_value(buffer.as_ptr() as u32); | 249 | r.packetptr().write_value(buffer.as_ptr() as u32); |
| 243 | } | 250 | } |
| 244 | 251 | ||
| 245 | /// Moves the radio to the RXIDLE state | 252 | /// Moves the radio to the RXIDLE state |
| 246 | fn receive_prepare(&mut self) { | 253 | fn receive_prepare(&mut self) { |
| 247 | // clear related events | 254 | // clear related events |
| 248 | T::regs().events_ccabusy().write_value(0); | 255 | self.r.events_ccabusy().write_value(0); |
| 249 | T::regs().events_phyend().write_value(0); | 256 | self.r.events_phyend().write_value(0); |
| 250 | // NOTE to avoid errata 204 (see rev1 v1.4) we do TX_IDLE -> DISABLED -> RXIDLE | 257 | // NOTE to avoid errata 204 (see rev1 v1.4) we do TX_IDLE -> DISABLED -> RXIDLE |
| 251 | let disable = match self.state() { | 258 | let disable = match self.state() { |
| 252 | RadioState::DISABLED => false, | 259 | RadioState::DISABLED => false, |
| @@ -263,7 +270,7 @@ impl<'d, T: Instance> Radio<'d, T> { | |||
| 263 | fn receive_start(&mut self, packet: &mut Packet) { | 270 | fn receive_start(&mut self, packet: &mut Packet) { |
| 264 | // NOTE we do NOT check the address of `packet` because the mutable reference ensures it's | 271 | // NOTE we do NOT check the address of `packet` because the mutable reference ensures it's |
| 265 | // allocated in RAM | 272 | // allocated in RAM |
| 266 | let r = T::regs(); | 273 | let r = self.r; |
| 267 | 274 | ||
| 268 | self.receive_prepare(); | 275 | self.receive_prepare(); |
| 269 | 276 | ||
| @@ -290,7 +297,7 @@ impl<'d, T: Instance> Radio<'d, T> { | |||
| 290 | 297 | ||
| 291 | /// Cancel receiving packet | 298 | /// Cancel receiving packet |
| 292 | fn receive_cancel() { | 299 | fn receive_cancel() { |
| 293 | let r = T::regs(); | 300 | let r = crate::pac::RADIO; |
| 294 | r.shorts().write(|_| {}); | 301 | r.shorts().write(|_| {}); |
| 295 | r.tasks_stop().write_value(1); | 302 | r.tasks_stop().write_value(1); |
| 296 | loop { | 303 | loop { |
| @@ -309,8 +316,8 @@ impl<'d, T: Instance> Radio<'d, T> { | |||
| 309 | /// validated by the hardware; otherwise it returns the `Err` variant. In either case, `packet` | 316 | /// validated by the hardware; otherwise it returns the `Err` variant. In either case, `packet` |
| 310 | /// will be updated with the received packet's data | 317 | /// will be updated with the received packet's data |
| 311 | pub async fn receive(&mut self, packet: &mut Packet) -> Result<(), Error> { | 318 | pub async fn receive(&mut self, packet: &mut Packet) -> Result<(), Error> { |
| 312 | let s = T::state(); | 319 | let s = self.state; |
| 313 | let r = T::regs(); | 320 | let r = self.r; |
| 314 | 321 | ||
| 315 | // Start the read | 322 | // Start the read |
| 316 | self.receive_start(packet); | 323 | self.receive_start(packet); |
| @@ -356,8 +363,8 @@ impl<'d, T: Instance> Radio<'d, T> { | |||
| 356 | // NOTE we do NOT check the address of `packet` because the mutable reference ensures it's | 363 | // NOTE we do NOT check the address of `packet` because the mutable reference ensures it's |
| 357 | // allocated in RAM | 364 | // allocated in RAM |
| 358 | pub async fn try_send(&mut self, packet: &mut Packet) -> Result<(), Error> { | 365 | pub async fn try_send(&mut self, packet: &mut Packet) -> Result<(), Error> { |
| 359 | let s = T::state(); | 366 | let s = self.state; |
| 360 | let r = T::regs(); | 367 | let r = self.r; |
| 361 | 368 | ||
| 362 | // enable radio to perform cca | 369 | // enable radio to perform cca |
| 363 | self.receive_prepare(); | 370 | self.receive_prepare(); |
| @@ -535,3 +542,19 @@ fn dma_start_fence() { | |||
| 535 | fn dma_end_fence() { | 542 | fn dma_end_fence() { |
| 536 | compiler_fence(Ordering::Acquire); | 543 | compiler_fence(Ordering::Acquire); |
| 537 | } | 544 | } |
| 545 | |||
| 546 | mod errata { | ||
| 547 | pub fn post_power() { | ||
| 548 | // Workaround for anomaly 158 | ||
| 549 | #[cfg(feature = "_nrf5340-net")] | ||
| 550 | for i in 0..32 { | ||
| 551 | let info = crate::pac::FICR.trimcnf(i); | ||
| 552 | let addr = info.addr().read(); | ||
| 553 | if addr & 0xFFFF_F000 == crate::pac::RADIO.as_ptr() as u32 { | ||
| 554 | unsafe { | ||
| 555 | (addr as *mut u32).write_volatile(info.data().read()); | ||
| 556 | } | ||
| 557 | } | ||
| 558 | } | ||
| 559 | } | ||
| 560 | } | ||
diff --git a/embassy-nrf/src/rng.rs b/embassy-nrf/src/rng.rs index 9d3130e6e..8070c1afe 100644 --- a/embassy-nrf/src/rng.rs +++ b/embassy-nrf/src/rng.rs | |||
| @@ -56,21 +56,23 @@ impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandl | |||
| 56 | /// A wrapper around an nRF RNG peripheral. | 56 | /// A wrapper around an nRF RNG peripheral. |
| 57 | /// | 57 | /// |
| 58 | /// It has a non-blocking API, and a blocking api through `rand`. | 58 | /// It has a non-blocking API, and a blocking api through `rand`. |
| 59 | pub struct Rng<'d, T: Instance, M: Mode> { | 59 | pub struct Rng<'d, M: Mode> { |
| 60 | _peri: Peri<'d, T>, | 60 | r: pac::rng::Rng, |
| 61 | _phantom: PhantomData<M>, | 61 | state: &'static State, |
| 62 | _phantom: PhantomData<(&'d (), M)>, | ||
| 62 | } | 63 | } |
| 63 | 64 | ||
| 64 | impl<'d, T: Instance> Rng<'d, T, Blocking> { | 65 | impl<'d> Rng<'d, Blocking> { |
| 65 | /// Creates a new RNG driver from the `RNG` peripheral and interrupt. | 66 | /// Creates a new RNG driver from the `RNG` peripheral and interrupt. |
| 66 | /// | 67 | /// |
| 67 | /// SAFETY: The future returned from `fill_bytes` must not have its lifetime end without running its destructor, | 68 | /// SAFETY: The future returned from `fill_bytes` must not have its lifetime end without running its destructor, |
| 68 | /// e.g. using `mem::forget`. | 69 | /// e.g. using `mem::forget`. |
| 69 | /// | 70 | /// |
| 70 | /// The synchronous API is safe. | 71 | /// The synchronous API is safe. |
| 71 | pub fn new_blocking(rng: Peri<'d, T>) -> Self { | 72 | pub fn new_blocking<T: Instance>(_rng: Peri<'d, T>) -> Self { |
| 72 | let this = Self { | 73 | let this = Self { |
| 73 | _peri: rng, | 74 | r: T::regs(), |
| 75 | state: T::state(), | ||
| 74 | _phantom: PhantomData, | 76 | _phantom: PhantomData, |
| 75 | }; | 77 | }; |
| 76 | 78 | ||
| @@ -80,19 +82,20 @@ impl<'d, T: Instance> Rng<'d, T, Blocking> { | |||
| 80 | } | 82 | } |
| 81 | } | 83 | } |
| 82 | 84 | ||
| 83 | impl<'d, T: Instance> Rng<'d, T, Async> { | 85 | impl<'d> Rng<'d, Async> { |
| 84 | /// Creates a new RNG driver from the `RNG` peripheral and interrupt. | 86 | /// Creates a new RNG driver from the `RNG` peripheral and interrupt. |
| 85 | /// | 87 | /// |
| 86 | /// SAFETY: The future returned from `fill_bytes` must not have its lifetime end without running its destructor, | 88 | /// SAFETY: The future returned from `fill_bytes` must not have its lifetime end without running its destructor, |
| 87 | /// e.g. using `mem::forget`. | 89 | /// e.g. using `mem::forget`. |
| 88 | /// | 90 | /// |
| 89 | /// The synchronous API is safe. | 91 | /// The synchronous API is safe. |
| 90 | pub fn new( | 92 | pub fn new<T: Instance>( |
| 91 | rng: Peri<'d, T>, | 93 | _rng: Peri<'d, T>, |
| 92 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 94 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 93 | ) -> Self { | 95 | ) -> Self { |
| 94 | let this = Self { | 96 | let this = Self { |
| 95 | _peri: rng, | 97 | r: T::regs(), |
| 98 | state: T::state(), | ||
| 96 | _phantom: PhantomData, | 99 | _phantom: PhantomData, |
| 97 | }; | 100 | }; |
| 98 | 101 | ||
| @@ -106,11 +109,11 @@ impl<'d, T: Instance> Rng<'d, T, Async> { | |||
| 106 | } | 109 | } |
| 107 | 110 | ||
| 108 | fn enable_irq(&self) { | 111 | fn enable_irq(&self) { |
| 109 | T::regs().intenset().write(|w| w.set_valrdy(true)); | 112 | self.r.intenset().write(|w| w.set_valrdy(true)); |
| 110 | } | 113 | } |
| 111 | 114 | ||
| 112 | fn disable_irq(&self) { | 115 | fn disable_irq(&self) { |
| 113 | T::regs().intenclr().write(|w| w.set_valrdy(true)); | 116 | self.r.intenclr().write(|w| w.set_valrdy(true)); |
| 114 | } | 117 | } |
| 115 | 118 | ||
| 116 | /// Fill the buffer with random bytes. | 119 | /// Fill the buffer with random bytes. |
| @@ -120,10 +123,11 @@ impl<'d, T: Instance> Rng<'d, T, Async> { | |||
| 120 | } | 123 | } |
| 121 | 124 | ||
| 122 | let range = dest.as_mut_ptr_range(); | 125 | let range = dest.as_mut_ptr_range(); |
| 126 | let state = self.state; | ||
| 123 | // Even if we've preempted the interrupt, it can't preempt us again, | 127 | // Even if we've preempted the interrupt, it can't preempt us again, |
| 124 | // so we don't need to worry about the order we write these in. | 128 | // so we don't need to worry about the order we write these in. |
| 125 | critical_section::with(|cs| { | 129 | critical_section::with(|cs| { |
| 126 | let mut state = T::state().borrow_mut(cs); | 130 | let mut state = state.borrow_mut(cs); |
| 127 | state.ptr = range.start; | 131 | state.ptr = range.start; |
| 128 | state.end = range.end; | 132 | state.end = range.end; |
| 129 | }); | 133 | }); |
| @@ -136,7 +140,7 @@ impl<'d, T: Instance> Rng<'d, T, Async> { | |||
| 136 | self.disable_irq(); | 140 | self.disable_irq(); |
| 137 | 141 | ||
| 138 | critical_section::with(|cs| { | 142 | critical_section::with(|cs| { |
| 139 | let mut state = T::state().borrow_mut(cs); | 143 | let mut state = state.borrow_mut(cs); |
| 140 | state.ptr = ptr::null_mut(); | 144 | state.ptr = ptr::null_mut(); |
| 141 | state.end = ptr::null_mut(); | 145 | state.end = ptr::null_mut(); |
| 142 | }); | 146 | }); |
| @@ -144,7 +148,7 @@ impl<'d, T: Instance> Rng<'d, T, Async> { | |||
| 144 | 148 | ||
| 145 | poll_fn(|cx| { | 149 | poll_fn(|cx| { |
| 146 | critical_section::with(|cs| { | 150 | critical_section::with(|cs| { |
| 147 | let mut s = T::state().borrow_mut(cs); | 151 | let mut s = state.borrow_mut(cs); |
| 148 | s.waker.register(cx.waker()); | 152 | s.waker.register(cx.waker()); |
| 149 | if s.ptr == s.end { | 153 | if s.ptr == s.end { |
| 150 | // We're done. | 154 | // We're done. |
| @@ -161,13 +165,13 @@ impl<'d, T: Instance> Rng<'d, T, Async> { | |||
| 161 | } | 165 | } |
| 162 | } | 166 | } |
| 163 | 167 | ||
| 164 | impl<'d, T: Instance, M: Mode> Rng<'d, T, M> { | 168 | impl<'d, M: Mode> Rng<'d, M> { |
| 165 | fn stop(&self) { | 169 | fn stop(&self) { |
| 166 | T::regs().tasks_stop().write_value(1) | 170 | self.r.tasks_stop().write_value(1) |
| 167 | } | 171 | } |
| 168 | 172 | ||
| 169 | fn start(&self) { | 173 | fn start(&self) { |
| 170 | T::regs().tasks_start().write_value(1) | 174 | self.r.tasks_start().write_value(1) |
| 171 | } | 175 | } |
| 172 | 176 | ||
| 173 | /// Enable or disable the RNG's bias correction. | 177 | /// Enable or disable the RNG's bias correction. |
| @@ -177,7 +181,7 @@ impl<'d, T: Instance, M: Mode> Rng<'d, T, M> { | |||
| 177 | /// | 181 | /// |
| 178 | /// Defaults to disabled. | 182 | /// Defaults to disabled. |
| 179 | pub fn set_bias_correction(&self, enable: bool) { | 183 | pub fn set_bias_correction(&self, enable: bool) { |
| 180 | T::regs().config().write(|w| w.set_dercen(enable)) | 184 | self.r.config().write(|w| w.set_dercen(enable)) |
| 181 | } | 185 | } |
| 182 | 186 | ||
| 183 | /// Fill the buffer with random bytes, blocking version. | 187 | /// Fill the buffer with random bytes, blocking version. |
| @@ -185,7 +189,7 @@ impl<'d, T: Instance, M: Mode> Rng<'d, T, M> { | |||
| 185 | self.start(); | 189 | self.start(); |
| 186 | 190 | ||
| 187 | for byte in dest.iter_mut() { | 191 | for byte in dest.iter_mut() { |
| 188 | let regs = T::regs(); | 192 | let regs = self.r; |
| 189 | while regs.events_valrdy().read() == 0 {} | 193 | while regs.events_valrdy().read() == 0 {} |
| 190 | regs.events_valrdy().write_value(0); | 194 | regs.events_valrdy().write_value(0); |
| 191 | *byte = regs.value().read().value(); | 195 | *byte = regs.value().read().value(); |
| @@ -210,18 +214,18 @@ impl<'d, T: Instance, M: Mode> Rng<'d, T, M> { | |||
| 210 | } | 214 | } |
| 211 | } | 215 | } |
| 212 | 216 | ||
| 213 | impl<'d, T: Instance, M: Mode> Drop for Rng<'d, T, M> { | 217 | impl<'d, M: Mode> Drop for Rng<'d, M> { |
| 214 | fn drop(&mut self) { | 218 | fn drop(&mut self) { |
| 215 | self.stop(); | 219 | self.stop(); |
| 216 | critical_section::with(|cs| { | 220 | critical_section::with(|cs| { |
| 217 | let mut state = T::state().borrow_mut(cs); | 221 | let mut state = self.state.borrow_mut(cs); |
| 218 | state.ptr = ptr::null_mut(); | 222 | state.ptr = ptr::null_mut(); |
| 219 | state.end = ptr::null_mut(); | 223 | state.end = ptr::null_mut(); |
| 220 | }); | 224 | }); |
| 221 | } | 225 | } |
| 222 | } | 226 | } |
| 223 | 227 | ||
| 224 | impl<'d, T: Instance, M: Mode> rand_core_06::RngCore for Rng<'d, T, M> { | 228 | impl<'d, M: Mode> rand_core_06::RngCore for Rng<'d, M> { |
| 225 | fn fill_bytes(&mut self, dest: &mut [u8]) { | 229 | fn fill_bytes(&mut self, dest: &mut [u8]) { |
| 226 | self.blocking_fill_bytes(dest); | 230 | self.blocking_fill_bytes(dest); |
| 227 | } | 231 | } |
| @@ -237,9 +241,9 @@ impl<'d, T: Instance, M: Mode> rand_core_06::RngCore for Rng<'d, T, M> { | |||
| 237 | } | 241 | } |
| 238 | } | 242 | } |
| 239 | 243 | ||
| 240 | impl<'d, T: Instance, M: Mode> rand_core_06::CryptoRng for Rng<'d, T, M> {} | 244 | impl<'d, M: Mode> rand_core_06::CryptoRng for Rng<'d, M> {} |
| 241 | 245 | ||
| 242 | impl<'d, T: Instance, M: Mode> rand_core_09::RngCore for Rng<'d, T, M> { | 246 | impl<'d, M: Mode> rand_core_09::RngCore for Rng<'d, M> { |
| 243 | fn fill_bytes(&mut self, dest: &mut [u8]) { | 247 | fn fill_bytes(&mut self, dest: &mut [u8]) { |
| 244 | self.blocking_fill_bytes(dest); | 248 | self.blocking_fill_bytes(dest); |
| 245 | } | 249 | } |
| @@ -251,7 +255,7 @@ impl<'d, T: Instance, M: Mode> rand_core_09::RngCore for Rng<'d, T, M> { | |||
| 251 | } | 255 | } |
| 252 | } | 256 | } |
| 253 | 257 | ||
| 254 | impl<'d, T: Instance, M: Mode> rand_core_09::CryptoRng for Rng<'d, T, M> {} | 258 | impl<'d, M: Mode> rand_core_09::CryptoRng for Rng<'d, M> {} |
| 255 | 259 | ||
| 256 | /// Peripheral static state | 260 | /// Peripheral static state |
| 257 | pub(crate) struct State { | 261 | pub(crate) struct State { |
diff --git a/embassy-nrf/src/rramc.rs b/embassy-nrf/src/rramc.rs index 7cb5660cb..521ac4ee7 100644 --- a/embassy-nrf/src/rramc.rs +++ b/embassy-nrf/src/rramc.rs | |||
| @@ -7,7 +7,7 @@ use embedded_storage::nor_flash::{ | |||
| 7 | }; | 7 | }; |
| 8 | 8 | ||
| 9 | use crate::peripherals::RRAMC; | 9 | use crate::peripherals::RRAMC; |
| 10 | use crate::{pac, Peri}; | 10 | use crate::{Peri, pac}; |
| 11 | 11 | ||
| 12 | // | 12 | // |
| 13 | // Export Nvmc alias and page size for downstream compatibility | 13 | // Export Nvmc alias and page size for downstream compatibility |
diff --git a/embassy-nrf/src/rtc.rs b/embassy-nrf/src/rtc.rs index 1a90d1e24..652de511b 100644 --- a/embassy-nrf/src/rtc.rs +++ b/embassy-nrf/src/rtc.rs | |||
| @@ -2,10 +2,13 @@ | |||
| 2 | 2 | ||
| 3 | #![macro_use] | 3 | #![macro_use] |
| 4 | 4 | ||
| 5 | use core::marker::PhantomData; | ||
| 6 | |||
| 7 | use embassy_hal_internal::interrupt::InterruptExt; | ||
| 5 | use embassy_hal_internal::{Peri, PeripheralType}; | 8 | use embassy_hal_internal::{Peri, PeripheralType}; |
| 6 | 9 | ||
| 7 | use crate::chip::interrupt::typelevel::Interrupt as _; | 10 | use crate::interrupt::typelevel::Interrupt as _; |
| 8 | use crate::pac; | 11 | use crate::{interrupt, pac}; |
| 9 | 12 | ||
| 10 | /// Prescaler has an invalid value which exceeds 12 bits. | 13 | /// Prescaler has an invalid value which exceeds 12 bits. |
| 11 | #[derive(Debug, PartialEq, Eq)] | 14 | #[derive(Debug, PartialEq, Eq)] |
| @@ -88,23 +91,31 @@ macro_rules! impl_rtc { | |||
| 88 | } | 91 | } |
| 89 | 92 | ||
| 90 | /// nRF RTC driver. | 93 | /// nRF RTC driver. |
| 91 | pub struct Rtc<'d, T: Instance>(Peri<'d, T>); | 94 | pub struct Rtc<'d> { |
| 95 | r: pac::rtc::Rtc, | ||
| 96 | irq: interrupt::Interrupt, | ||
| 97 | _phantom: PhantomData<&'d ()>, | ||
| 98 | } | ||
| 92 | 99 | ||
| 93 | impl<'d, T: Instance> Rtc<'d, T> { | 100 | impl<'d> Rtc<'d> { |
| 94 | /// Create a new `Rtc` driver. | 101 | /// Create a new `Rtc` driver. |
| 95 | /// | 102 | /// |
| 96 | /// fRTC \[Hz\] = 32_768 / (`prescaler` + 1 ) | 103 | /// fRTC \[Hz\] = 32_768 / (`prescaler` + 1 ) |
| 97 | pub fn new(rtc: Peri<'d, T>, prescaler: u32) -> Result<Self, PrescalerOutOfRangeError> { | 104 | pub fn new<T: Instance>(_rtc: Peri<'d, T>, prescaler: u32) -> Result<Self, PrescalerOutOfRangeError> { |
| 98 | if prescaler >= (1 << 12) { | 105 | if prescaler >= (1 << 12) { |
| 99 | return Err(PrescalerOutOfRangeError(prescaler)); | 106 | return Err(PrescalerOutOfRangeError(prescaler)); |
| 100 | } | 107 | } |
| 101 | 108 | ||
| 102 | T::regs().prescaler().write(|w| w.set_prescaler(prescaler as u16)); | 109 | T::regs().prescaler().write(|w| w.set_prescaler(prescaler as u16)); |
| 103 | Ok(Self(rtc)) | 110 | Ok(Self { |
| 111 | r: T::regs(), | ||
| 112 | irq: T::Interrupt::IRQ, | ||
| 113 | _phantom: PhantomData, | ||
| 114 | }) | ||
| 104 | } | 115 | } |
| 105 | 116 | ||
| 106 | /// Create a new `Rtc` driver, configuring it to run at the given frequency. | 117 | /// Create a new `Rtc` driver, configuring it to run at the given frequency. |
| 107 | pub fn new_for_freq(rtc: Peri<'d, T>, freq_hz: u32) -> Result<Self, PrescalerOutOfRangeError> { | 118 | pub fn new_for_freq<T: Instance>(rtc: Peri<'d, T>, freq_hz: u32) -> Result<Self, PrescalerOutOfRangeError> { |
| 108 | let prescaler = (32_768 / freq_hz).saturating_sub(1); | 119 | let prescaler = (32_768 / freq_hz).saturating_sub(1); |
| 109 | Self::new(rtc, prescaler) | 120 | Self::new(rtc, prescaler) |
| 110 | } | 121 | } |
| @@ -115,34 +126,38 @@ impl<'d, T: Instance> Rtc<'d, T> { | |||
| 115 | /// | 126 | /// |
| 116 | /// Potentially allows to create multiple instances of the driver for the same peripheral | 127 | /// Potentially allows to create multiple instances of the driver for the same peripheral |
| 117 | /// which can lead to undefined behavior. | 128 | /// which can lead to undefined behavior. |
| 118 | pub unsafe fn steal() -> Self { | 129 | pub unsafe fn steal<T: Instance>() -> Self { |
| 119 | Self(unsafe { T::steal() }) | 130 | Self { |
| 131 | r: T::regs(), | ||
| 132 | irq: T::Interrupt::IRQ, | ||
| 133 | _phantom: PhantomData, | ||
| 134 | } | ||
| 120 | } | 135 | } |
| 121 | 136 | ||
| 122 | /// Direct access to the RTC registers. | 137 | /// Direct access to the RTC registers. |
| 123 | #[cfg(feature = "unstable-pac")] | 138 | #[cfg(feature = "unstable-pac")] |
| 124 | #[inline] | 139 | #[inline] |
| 125 | pub fn regs(&mut self) -> pac::rtc::Rtc { | 140 | pub fn regs(&mut self) -> pac::rtc::Rtc { |
| 126 | T::regs() | 141 | self.r |
| 127 | } | 142 | } |
| 128 | 143 | ||
| 129 | /// Enable the RTC. | 144 | /// Enable the RTC. |
| 130 | #[inline] | 145 | #[inline] |
| 131 | pub fn enable(&mut self) { | 146 | pub fn enable(&mut self) { |
| 132 | T::regs().tasks_start().write_value(1); | 147 | self.r.tasks_start().write_value(1); |
| 133 | } | 148 | } |
| 134 | 149 | ||
| 135 | /// Disable the RTC. | 150 | /// Disable the RTC. |
| 136 | #[inline] | 151 | #[inline] |
| 137 | pub fn disable(&mut self) { | 152 | pub fn disable(&mut self) { |
| 138 | T::regs().tasks_stop().write_value(1); | 153 | self.r.tasks_stop().write_value(1); |
| 139 | } | 154 | } |
| 140 | 155 | ||
| 141 | /// Enables interrupts for the given [Interrupt] source. | 156 | /// Enables interrupts for the given [Interrupt] source. |
| 142 | /// | 157 | /// |
| 143 | /// Optionally also enables the interrupt in the NVIC. | 158 | /// Optionally also enables the interrupt in the NVIC. |
| 144 | pub fn enable_interrupt(&mut self, int: Interrupt, enable_in_nvic: bool) { | 159 | pub fn enable_interrupt(&mut self, int: Interrupt, enable_in_nvic: bool) { |
| 145 | let regs = T::regs(); | 160 | let regs = self.r; |
| 146 | match int { | 161 | match int { |
| 147 | Interrupt::Tick => regs.intenset().write(|w| w.set_tick(true)), | 162 | Interrupt::Tick => regs.intenset().write(|w| w.set_tick(true)), |
| 148 | Interrupt::Overflow => regs.intenset().write(|w| w.set_ovrflw(true)), | 163 | Interrupt::Overflow => regs.intenset().write(|w| w.set_ovrflw(true)), |
| @@ -152,7 +167,7 @@ impl<'d, T: Instance> Rtc<'d, T> { | |||
| 152 | Interrupt::Compare3 => regs.intenset().write(|w| w.set_compare(3, true)), | 167 | Interrupt::Compare3 => regs.intenset().write(|w| w.set_compare(3, true)), |
| 153 | } | 168 | } |
| 154 | if enable_in_nvic { | 169 | if enable_in_nvic { |
| 155 | unsafe { T::Interrupt::enable() }; | 170 | unsafe { self.irq.enable() }; |
| 156 | } | 171 | } |
| 157 | } | 172 | } |
| 158 | 173 | ||
| @@ -160,7 +175,7 @@ impl<'d, T: Instance> Rtc<'d, T> { | |||
| 160 | /// | 175 | /// |
| 161 | /// Optionally also disables the interrupt in the NVIC. | 176 | /// Optionally also disables the interrupt in the NVIC. |
| 162 | pub fn disable_interrupt(&mut self, int: Interrupt, disable_in_nvic: bool) { | 177 | pub fn disable_interrupt(&mut self, int: Interrupt, disable_in_nvic: bool) { |
| 163 | let regs = T::regs(); | 178 | let regs = self.r; |
| 164 | match int { | 179 | match int { |
| 165 | Interrupt::Tick => regs.intenclr().write(|w| w.set_tick(true)), | 180 | Interrupt::Tick => regs.intenclr().write(|w| w.set_tick(true)), |
| 166 | Interrupt::Overflow => regs.intenclr().write(|w| w.set_ovrflw(true)), | 181 | Interrupt::Overflow => regs.intenclr().write(|w| w.set_ovrflw(true)), |
| @@ -170,13 +185,13 @@ impl<'d, T: Instance> Rtc<'d, T> { | |||
| 170 | Interrupt::Compare3 => regs.intenclr().write(|w| w.set_compare(3, true)), | 185 | Interrupt::Compare3 => regs.intenclr().write(|w| w.set_compare(3, true)), |
| 171 | } | 186 | } |
| 172 | if disable_in_nvic { | 187 | if disable_in_nvic { |
| 173 | T::Interrupt::disable(); | 188 | self.irq.disable(); |
| 174 | } | 189 | } |
| 175 | } | 190 | } |
| 176 | 191 | ||
| 177 | /// Enable the generation of a hardware event from a given stimulus. | 192 | /// Enable the generation of a hardware event from a given stimulus. |
| 178 | pub fn enable_event(&mut self, evt: Interrupt) { | 193 | pub fn enable_event(&mut self, evt: Interrupt) { |
| 179 | let regs = T::regs(); | 194 | let regs = self.r; |
| 180 | match evt { | 195 | match evt { |
| 181 | Interrupt::Tick => regs.evtenset().write(|w| w.set_tick(true)), | 196 | Interrupt::Tick => regs.evtenset().write(|w| w.set_tick(true)), |
| 182 | Interrupt::Overflow => regs.evtenset().write(|w| w.set_ovrflw(true)), | 197 | Interrupt::Overflow => regs.evtenset().write(|w| w.set_ovrflw(true)), |
| @@ -189,7 +204,7 @@ impl<'d, T: Instance> Rtc<'d, T> { | |||
| 189 | 204 | ||
| 190 | /// Disable the generation of a hardware event from a given stimulus. | 205 | /// Disable the generation of a hardware event from a given stimulus. |
| 191 | pub fn disable_event(&mut self, evt: Interrupt) { | 206 | pub fn disable_event(&mut self, evt: Interrupt) { |
| 192 | let regs = T::regs(); | 207 | let regs = self.r; |
| 193 | match evt { | 208 | match evt { |
| 194 | Interrupt::Tick => regs.evtenclr().write(|w| w.set_tick(true)), | 209 | Interrupt::Tick => regs.evtenclr().write(|w| w.set_tick(true)), |
| 195 | Interrupt::Overflow => regs.evtenclr().write(|w| w.set_ovrflw(true)), | 210 | Interrupt::Overflow => regs.evtenclr().write(|w| w.set_ovrflw(true)), |
| @@ -202,7 +217,7 @@ impl<'d, T: Instance> Rtc<'d, T> { | |||
| 202 | 217 | ||
| 203 | /// Resets the given event. | 218 | /// Resets the given event. |
| 204 | pub fn reset_event(&mut self, evt: Interrupt) { | 219 | pub fn reset_event(&mut self, evt: Interrupt) { |
| 205 | let regs = T::regs(); | 220 | let regs = self.r; |
| 206 | match evt { | 221 | match evt { |
| 207 | Interrupt::Tick => regs.events_tick().write_value(0), | 222 | Interrupt::Tick => regs.events_tick().write_value(0), |
| 208 | Interrupt::Overflow => regs.events_ovrflw().write_value(0), | 223 | Interrupt::Overflow => regs.events_ovrflw().write_value(0), |
| @@ -215,7 +230,7 @@ impl<'d, T: Instance> Rtc<'d, T> { | |||
| 215 | 230 | ||
| 216 | /// Checks if the given event has been triggered. | 231 | /// Checks if the given event has been triggered. |
| 217 | pub fn is_event_triggered(&self, evt: Interrupt) -> bool { | 232 | pub fn is_event_triggered(&self, evt: Interrupt) -> bool { |
| 218 | let regs = T::regs(); | 233 | let regs = self.r; |
| 219 | let val = match evt { | 234 | let val = match evt { |
| 220 | Interrupt::Tick => regs.events_tick().read(), | 235 | Interrupt::Tick => regs.events_tick().read(), |
| 221 | Interrupt::Overflow => regs.events_ovrflw().read(), | 236 | Interrupt::Overflow => regs.events_ovrflw().read(), |
| @@ -241,25 +256,19 @@ impl<'d, T: Instance> Rtc<'d, T> { | |||
| 241 | CompareChannel::_3 => 3, | 256 | CompareChannel::_3 => 3, |
| 242 | }; | 257 | }; |
| 243 | 258 | ||
| 244 | T::regs().cc(reg).write(|w| w.set_compare(val)); | 259 | self.r.cc(reg).write(|w| w.set_compare(val)); |
| 245 | Ok(()) | 260 | Ok(()) |
| 246 | } | 261 | } |
| 247 | 262 | ||
| 248 | /// Clear the Real Time Counter. | 263 | /// Clear the Real Time Counter. |
| 249 | #[inline] | 264 | #[inline] |
| 250 | pub fn clear(&self) { | 265 | pub fn clear(&self) { |
| 251 | T::regs().tasks_clear().write_value(1); | 266 | self.r.tasks_clear().write_value(1); |
| 252 | } | 267 | } |
| 253 | 268 | ||
| 254 | /// Obtain the current value of the Real Time Counter, 24 bits of range. | 269 | /// Obtain the current value of the Real Time Counter, 24 bits of range. |
| 255 | #[inline] | 270 | #[inline] |
| 256 | pub fn read(&self) -> u32 { | 271 | pub fn read(&self) -> u32 { |
| 257 | T::regs().counter().read().counter() | 272 | self.r.counter().read().counter() |
| 258 | } | ||
| 259 | |||
| 260 | /// Relase the RTC, returning the underlying peripheral instance. | ||
| 261 | #[inline] | ||
| 262 | pub fn release(self) -> Peri<'d, T> { | ||
| 263 | self.0 | ||
| 264 | } | 273 | } |
| 265 | } | 274 | } |
diff --git a/embassy-nrf/src/saadc.rs b/embassy-nrf/src/saadc.rs index 92b6fb01f..a199c1c4d 100644 --- a/embassy-nrf/src/saadc.rs +++ b/embassy-nrf/src/saadc.rs | |||
| @@ -4,11 +4,11 @@ | |||
| 4 | 4 | ||
| 5 | use core::future::poll_fn; | 5 | use core::future::poll_fn; |
| 6 | use core::marker::PhantomData; | 6 | use core::marker::PhantomData; |
| 7 | use core::sync::atomic::{compiler_fence, Ordering}; | 7 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 8 | use core::task::Poll; | 8 | use core::task::Poll; |
| 9 | 9 | ||
| 10 | use embassy_hal_internal::drop::OnDrop; | 10 | use embassy_hal_internal::drop::OnDrop; |
| 11 | use embassy_hal_internal::{impl_peripheral, Peri}; | 11 | use embassy_hal_internal::{Peri, impl_peripheral}; |
| 12 | use embassy_sync::waitqueue::AtomicWaker; | 12 | use embassy_sync::waitqueue::AtomicWaker; |
| 13 | pub(crate) use vals::Psel as InputChannel; | 13 | pub(crate) use vals::Psel as InputChannel; |
| 14 | 14 | ||
| @@ -457,6 +457,19 @@ impl<'d> Saadc<'d, 1> { | |||
| 457 | 457 | ||
| 458 | impl<'d, const N: usize> Drop for Saadc<'d, N> { | 458 | impl<'d, const N: usize> Drop for Saadc<'d, N> { |
| 459 | fn drop(&mut self) { | 459 | fn drop(&mut self) { |
| 460 | // Reset of SAADC. | ||
| 461 | // | ||
| 462 | // This is needed when more than one pin is sampled to avoid needless power consumption. | ||
| 463 | // More information can be found in [nrf52 Anomaly 241](https://docs.nordicsemi.com/bundle/errata_nRF52810_Rev1/page/ERR/nRF52810/Rev1/latest/anomaly_810_241.html). | ||
| 464 | // The workaround seems like it copies the configuration before reset and reapplies it after. | ||
| 465 | // The instance is dropped, forcing a reconfiguration at compile time, hence we only | ||
| 466 | // call what is the reset portion of the workaround. | ||
| 467 | #[cfg(feature = "_nrf52")] | ||
| 468 | { | ||
| 469 | unsafe { core::ptr::write_volatile(0x40007FFC as *mut u32, 0) } | ||
| 470 | unsafe { core::ptr::read_volatile(0x40007FFC as *const ()) } | ||
| 471 | unsafe { core::ptr::write_volatile(0x40007FFC as *mut u32, 1) } | ||
| 472 | } | ||
| 460 | let r = Self::regs(); | 473 | let r = Self::regs(); |
| 461 | r.enable().write(|w| w.set_enable(false)); | 474 | r.enable().write(|w| w.set_enable(false)); |
| 462 | for i in 0..N { | 475 | for i in 0..N { |
diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs index c410e49fd..ce994dbc9 100644 --- a/embassy-nrf/src/spim.rs +++ b/embassy-nrf/src/spim.rs | |||
| @@ -6,17 +6,17 @@ use core::future::poll_fn; | |||
| 6 | use core::marker::PhantomData; | 6 | use core::marker::PhantomData; |
| 7 | #[cfg(feature = "_nrf52832_anomaly_109")] | 7 | #[cfg(feature = "_nrf52832_anomaly_109")] |
| 8 | use core::sync::atomic::AtomicU8; | 8 | use core::sync::atomic::AtomicU8; |
| 9 | use core::sync::atomic::{compiler_fence, Ordering}; | 9 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 10 | use core::task::Poll; | 10 | use core::task::Poll; |
| 11 | 11 | ||
| 12 | use embassy_embedded_hal::SetConfig; | 12 | use embassy_embedded_hal::SetConfig; |
| 13 | use embassy_hal_internal::{Peri, PeripheralType}; | 13 | use embassy_hal_internal::{Peri, PeripheralType}; |
| 14 | use embassy_sync::waitqueue::AtomicWaker; | 14 | use embassy_sync::waitqueue::AtomicWaker; |
| 15 | pub use embedded_hal_02::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_3}; | 15 | pub use embedded_hal_02::spi::{MODE_0, MODE_1, MODE_2, MODE_3, Mode, Phase, Polarity}; |
| 16 | pub use pac::spim::vals::{Frequency, Order as BitOrder}; | 16 | pub use pac::spim::vals::{Frequency, Order as BitOrder}; |
| 17 | 17 | ||
| 18 | use crate::chip::{EASY_DMA_SIZE, FORCE_COPY_BUFFER_SIZE}; | 18 | use crate::chip::{EASY_DMA_SIZE, FORCE_COPY_BUFFER_SIZE}; |
| 19 | use crate::gpio::{self, convert_drive, AnyPin, OutputDrive, Pin as GpioPin, PselBits, SealedPin as _}; | 19 | use crate::gpio::{self, AnyPin, OutputDrive, Pin as GpioPin, PselBits, SealedPin as _, convert_drive}; |
| 20 | use crate::interrupt::typelevel::Interrupt; | 20 | use crate::interrupt::typelevel::Interrupt; |
| 21 | use crate::pac::gpio::vals as gpiovals; | 21 | use crate::pac::gpio::vals as gpiovals; |
| 22 | use crate::pac::spim::vals; | 22 | use crate::pac::spim::vals; |
diff --git a/embassy-nrf/src/spis.rs b/embassy-nrf/src/spis.rs index 2a3928d25..885821146 100644 --- a/embassy-nrf/src/spis.rs +++ b/embassy-nrf/src/spis.rs | |||
| @@ -3,17 +3,17 @@ | |||
| 3 | #![macro_use] | 3 | #![macro_use] |
| 4 | use core::future::poll_fn; | 4 | use core::future::poll_fn; |
| 5 | use core::marker::PhantomData; | 5 | use core::marker::PhantomData; |
| 6 | use core::sync::atomic::{compiler_fence, Ordering}; | 6 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 7 | use core::task::Poll; | 7 | use core::task::Poll; |
| 8 | 8 | ||
| 9 | use embassy_embedded_hal::SetConfig; | 9 | use embassy_embedded_hal::SetConfig; |
| 10 | use embassy_hal_internal::{Peri, PeripheralType}; | 10 | use embassy_hal_internal::{Peri, PeripheralType}; |
| 11 | use embassy_sync::waitqueue::AtomicWaker; | 11 | use embassy_sync::waitqueue::AtomicWaker; |
| 12 | pub use embedded_hal_02::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_3}; | 12 | pub use embedded_hal_02::spi::{MODE_0, MODE_1, MODE_2, MODE_3, Mode, Phase, Polarity}; |
| 13 | pub use pac::spis::vals::Order as BitOrder; | 13 | pub use pac::spis::vals::Order as BitOrder; |
| 14 | 14 | ||
| 15 | use crate::chip::{EASY_DMA_SIZE, FORCE_COPY_BUFFER_SIZE}; | 15 | use crate::chip::{EASY_DMA_SIZE, FORCE_COPY_BUFFER_SIZE}; |
| 16 | use crate::gpio::{self, convert_drive, AnyPin, OutputDrive, Pin as GpioPin, SealedPin as _}; | 16 | use crate::gpio::{self, AnyPin, OutputDrive, Pin as GpioPin, SealedPin as _, convert_drive}; |
| 17 | use crate::interrupt::typelevel::Interrupt; | 17 | use crate::interrupt::typelevel::Interrupt; |
| 18 | use crate::pac::gpio::vals as gpiovals; | 18 | use crate::pac::gpio::vals as gpiovals; |
| 19 | use crate::pac::spis::vals; | 19 | use crate::pac::spis::vals; |
| @@ -96,14 +96,16 @@ impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandl | |||
| 96 | } | 96 | } |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | /// SPIS driver. | 99 | /// Serial Peripheral Interface in slave mode. |
| 100 | pub struct Spis<'d, T: Instance> { | 100 | pub struct Spis<'d> { |
| 101 | _p: Peri<'d, T>, | 101 | r: pac::spis::Spis, |
| 102 | state: &'static State, | ||
| 103 | _p: PhantomData<&'d ()>, | ||
| 102 | } | 104 | } |
| 103 | 105 | ||
| 104 | impl<'d, T: Instance> Spis<'d, T> { | 106 | impl<'d> Spis<'d> { |
| 105 | /// Create a new SPIS driver. | 107 | /// Create a new SPIS driver. |
| 106 | pub fn new( | 108 | pub fn new<T: Instance>( |
| 107 | spis: Peri<'d, T>, | 109 | spis: Peri<'d, T>, |
| 108 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 110 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 109 | cs: Peri<'d, impl GpioPin>, | 111 | cs: Peri<'d, impl GpioPin>, |
| @@ -123,7 +125,7 @@ impl<'d, T: Instance> Spis<'d, T> { | |||
| 123 | } | 125 | } |
| 124 | 126 | ||
| 125 | /// Create a new SPIS driver, capable of TX only (MISO only). | 127 | /// Create a new SPIS driver, capable of TX only (MISO only). |
| 126 | pub fn new_txonly( | 128 | pub fn new_txonly<T: Instance>( |
| 127 | spis: Peri<'d, T>, | 129 | spis: Peri<'d, T>, |
| 128 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 130 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 129 | cs: Peri<'d, impl GpioPin>, | 131 | cs: Peri<'d, impl GpioPin>, |
| @@ -135,7 +137,7 @@ impl<'d, T: Instance> Spis<'d, T> { | |||
| 135 | } | 137 | } |
| 136 | 138 | ||
| 137 | /// Create a new SPIS driver, capable of RX only (MOSI only). | 139 | /// Create a new SPIS driver, capable of RX only (MOSI only). |
| 138 | pub fn new_rxonly( | 140 | pub fn new_rxonly<T: Instance>( |
| 139 | spis: Peri<'d, T>, | 141 | spis: Peri<'d, T>, |
| 140 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 142 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 141 | cs: Peri<'d, impl GpioPin>, | 143 | cs: Peri<'d, impl GpioPin>, |
| @@ -147,7 +149,7 @@ impl<'d, T: Instance> Spis<'d, T> { | |||
| 147 | } | 149 | } |
| 148 | 150 | ||
| 149 | /// Create a new SPIS driver, capable of TX only (MISO only) without SCK pin. | 151 | /// Create a new SPIS driver, capable of TX only (MISO only) without SCK pin. |
| 150 | pub fn new_txonly_nosck( | 152 | pub fn new_txonly_nosck<T: Instance>( |
| 151 | spis: Peri<'d, T>, | 153 | spis: Peri<'d, T>, |
| 152 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 154 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 153 | cs: Peri<'d, impl GpioPin>, | 155 | cs: Peri<'d, impl GpioPin>, |
| @@ -157,8 +159,8 @@ impl<'d, T: Instance> Spis<'d, T> { | |||
| 157 | Self::new_inner(spis, cs.into(), None, Some(miso.into()), None, config) | 159 | Self::new_inner(spis, cs.into(), None, Some(miso.into()), None, config) |
| 158 | } | 160 | } |
| 159 | 161 | ||
| 160 | fn new_inner( | 162 | fn new_inner<T: Instance>( |
| 161 | spis: Peri<'d, T>, | 163 | _spis: Peri<'d, T>, |
| 162 | cs: Peri<'d, AnyPin>, | 164 | cs: Peri<'d, AnyPin>, |
| 163 | sck: Option<Peri<'d, AnyPin>>, | 165 | sck: Option<Peri<'d, AnyPin>>, |
| 164 | miso: Option<Peri<'d, AnyPin>>, | 166 | miso: Option<Peri<'d, AnyPin>>, |
| @@ -191,10 +193,14 @@ impl<'d, T: Instance> Spis<'d, T> { | |||
| 191 | // Enable SPIS instance. | 193 | // Enable SPIS instance. |
| 192 | r.enable().write(|w| w.set_enable(vals::Enable::ENABLED)); | 194 | r.enable().write(|w| w.set_enable(vals::Enable::ENABLED)); |
| 193 | 195 | ||
| 194 | let mut spis = Self { _p: spis }; | 196 | let mut spis = Self { |
| 197 | r: T::regs(), | ||
| 198 | state: T::state(), | ||
| 199 | _p: PhantomData, | ||
| 200 | }; | ||
| 195 | 201 | ||
| 196 | // Apply runtime peripheral configuration | 202 | // Apply runtime peripheral configuration |
| 197 | Self::set_config(&mut spis, &config).unwrap(); | 203 | spis.set_config(&config).unwrap(); |
| 198 | 204 | ||
| 199 | // Disable all events interrupts. | 205 | // Disable all events interrupts. |
| 200 | r.intenclr().write(|w| w.0 = 0xFFFF_FFFF); | 206 | r.intenclr().write(|w| w.0 = 0xFFFF_FFFF); |
| @@ -212,7 +218,7 @@ impl<'d, T: Instance> Spis<'d, T> { | |||
| 212 | 218 | ||
| 213 | compiler_fence(Ordering::SeqCst); | 219 | compiler_fence(Ordering::SeqCst); |
| 214 | 220 | ||
| 215 | let r = T::regs(); | 221 | let r = self.r; |
| 216 | 222 | ||
| 217 | // Set up the DMA write. | 223 | // Set up the DMA write. |
| 218 | if tx.len() > EASY_DMA_SIZE { | 224 | if tx.len() > EASY_DMA_SIZE { |
| @@ -239,7 +245,7 @@ impl<'d, T: Instance> Spis<'d, T> { | |||
| 239 | 245 | ||
| 240 | fn blocking_inner_from_ram(&mut self, rx: *mut [u8], tx: *const [u8]) -> Result<(usize, usize), Error> { | 246 | fn blocking_inner_from_ram(&mut self, rx: *mut [u8], tx: *const [u8]) -> Result<(usize, usize), Error> { |
| 241 | compiler_fence(Ordering::SeqCst); | 247 | compiler_fence(Ordering::SeqCst); |
| 242 | let r = T::regs(); | 248 | let r = self.r; |
| 243 | 249 | ||
| 244 | // Acquire semaphore. | 250 | // Acquire semaphore. |
| 245 | if r.semstat().read().0 != 1 { | 251 | if r.semstat().read().0 != 1 { |
| @@ -276,8 +282,8 @@ impl<'d, T: Instance> Spis<'d, T> { | |||
| 276 | } | 282 | } |
| 277 | 283 | ||
| 278 | async fn async_inner_from_ram(&mut self, rx: *mut [u8], tx: *const [u8]) -> Result<(usize, usize), Error> { | 284 | async fn async_inner_from_ram(&mut self, rx: *mut [u8], tx: *const [u8]) -> Result<(usize, usize), Error> { |
| 279 | let r = T::regs(); | 285 | let r = self.r; |
| 280 | let s = T::state(); | 286 | let s = self.state; |
| 281 | 287 | ||
| 282 | // Clear status register. | 288 | // Clear status register. |
| 283 | r.status().write(|w| { | 289 | r.status().write(|w| { |
| @@ -420,21 +426,21 @@ impl<'d, T: Instance> Spis<'d, T> { | |||
| 420 | 426 | ||
| 421 | /// Checks if last transaction overread. | 427 | /// Checks if last transaction overread. |
| 422 | pub fn is_overread(&mut self) -> bool { | 428 | pub fn is_overread(&mut self) -> bool { |
| 423 | T::regs().status().read().overread() | 429 | self.r.status().read().overread() |
| 424 | } | 430 | } |
| 425 | 431 | ||
| 426 | /// Checks if last transaction overflowed. | 432 | /// Checks if last transaction overflowed. |
| 427 | pub fn is_overflow(&mut self) -> bool { | 433 | pub fn is_overflow(&mut self) -> bool { |
| 428 | T::regs().status().read().overflow() | 434 | self.r.status().read().overflow() |
| 429 | } | 435 | } |
| 430 | } | 436 | } |
| 431 | 437 | ||
| 432 | impl<'d, T: Instance> Drop for Spis<'d, T> { | 438 | impl<'d> Drop for Spis<'d> { |
| 433 | fn drop(&mut self) { | 439 | fn drop(&mut self) { |
| 434 | trace!("spis drop"); | 440 | trace!("spis drop"); |
| 435 | 441 | ||
| 436 | // Disable | 442 | // Disable |
| 437 | let r = T::regs(); | 443 | let r = self.r; |
| 438 | r.enable().write(|w| w.set_enable(vals::Enable::DISABLED)); | 444 | r.enable().write(|w| w.set_enable(vals::Enable::DISABLED)); |
| 439 | 445 | ||
| 440 | gpio::deconfigure_pin(r.psel().sck().read()); | 446 | gpio::deconfigure_pin(r.psel().sck().read()); |
| @@ -489,11 +495,11 @@ macro_rules! impl_spis { | |||
| 489 | 495 | ||
| 490 | // ==================== | 496 | // ==================== |
| 491 | 497 | ||
| 492 | impl<'d, T: Instance> SetConfig for Spis<'d, T> { | 498 | impl<'d> SetConfig for Spis<'d> { |
| 493 | type Config = Config; | 499 | type Config = Config; |
| 494 | type ConfigError = (); | 500 | type ConfigError = (); |
| 495 | fn set_config(&mut self, config: &Self::Config) -> Result<(), Self::ConfigError> { | 501 | fn set_config(&mut self, config: &Self::Config) -> Result<(), Self::ConfigError> { |
| 496 | let r = T::regs(); | 502 | let r = self.r; |
| 497 | // Configure mode. | 503 | // Configure mode. |
| 498 | let mode = config.mode; | 504 | let mode = config.mode; |
| 499 | r.config().write(|w| { | 505 | r.config().write(|w| { |
diff --git a/embassy-nrf/src/temp.rs b/embassy-nrf/src/temp.rs index 44be0f6d1..a20e300b7 100644 --- a/embassy-nrf/src/temp.rs +++ b/embassy-nrf/src/temp.rs | |||
| @@ -9,7 +9,7 @@ use fixed::types::I30F2; | |||
| 9 | 9 | ||
| 10 | use crate::interrupt::InterruptExt; | 10 | use crate::interrupt::InterruptExt; |
| 11 | use crate::peripherals::TEMP; | 11 | use crate::peripherals::TEMP; |
| 12 | use crate::{interrupt, pac, Peri}; | 12 | use crate::{Peri, interrupt, pac}; |
| 13 | 13 | ||
| 14 | /// Interrupt handler. | 14 | /// Interrupt handler. |
| 15 | pub struct InterruptHandler { | 15 | pub struct InterruptHandler { |
diff --git a/embassy-nrf/src/time_driver.rs b/embassy-nrf/src/time_driver.rs index 03f4c2e2b..b723e2334 100644 --- a/embassy-nrf/src/time_driver.rs +++ b/embassy-nrf/src/time_driver.rs | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | use core::cell::{Cell, RefCell}; | 1 | use core::cell::{Cell, RefCell}; |
| 2 | use core::sync::atomic::{compiler_fence, AtomicU32, Ordering}; | 2 | use core::sync::atomic::{AtomicU32, Ordering, compiler_fence}; |
| 3 | 3 | ||
| 4 | use critical_section::CriticalSection; | 4 | use critical_section::CriticalSection; |
| 5 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | ||
| 6 | use embassy_sync::blocking_mutex::CriticalSectionMutex as Mutex; | 5 | use embassy_sync::blocking_mutex::CriticalSectionMutex as Mutex; |
| 6 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | ||
| 7 | use embassy_time_driver::Driver; | 7 | use embassy_time_driver::Driver; |
| 8 | use embassy_time_queue_utils::Queue; | 8 | use embassy_time_queue_utils::Queue; |
| 9 | 9 | ||
diff --git a/embassy-nrf/src/timer.rs b/embassy-nrf/src/timer.rs index 1d1f77ea8..0b0bb9780 100644 --- a/embassy-nrf/src/timer.rs +++ b/embassy-nrf/src/timer.rs | |||
| @@ -6,6 +6,8 @@ | |||
| 6 | 6 | ||
| 7 | #![macro_use] | 7 | #![macro_use] |
| 8 | 8 | ||
| 9 | use core::marker::PhantomData; | ||
| 10 | |||
| 9 | use embassy_hal_internal::{Peri, PeripheralType}; | 11 | use embassy_hal_internal::{Peri, PeripheralType}; |
| 10 | 12 | ||
| 11 | use crate::pac; | 13 | use crate::pac; |
| @@ -81,16 +83,18 @@ pub enum Frequency { | |||
| 81 | /// | 83 | /// |
| 82 | /// It has either 4 or 6 Capture/Compare registers, which can be used to capture the current state of the counter | 84 | /// It has either 4 or 6 Capture/Compare registers, which can be used to capture the current state of the counter |
| 83 | /// or trigger an event when the counter reaches a certain value. | 85 | /// or trigger an event when the counter reaches a certain value. |
| 84 | pub struct Timer<'d, T: Instance> { | 86 | pub struct Timer<'d> { |
| 85 | _p: Peri<'d, T>, | 87 | r: pac::timer::Timer, |
| 88 | ccs: usize, | ||
| 89 | _p: PhantomData<&'d ()>, | ||
| 86 | } | 90 | } |
| 87 | 91 | ||
| 88 | impl<'d, T: Instance> Timer<'d, T> { | 92 | impl<'d> Timer<'d> { |
| 89 | /// Create a new `Timer` driver. | 93 | /// Create a new `Timer` driver. |
| 90 | /// | 94 | /// |
| 91 | /// This can be useful for triggering tasks via PPI. | 95 | /// This can be useful for triggering tasks via PPI. |
| 92 | /// `Uarte` uses this internally. | 96 | /// `Uarte` uses this internally. |
| 93 | pub fn new(timer: Peri<'d, T>) -> Self { | 97 | pub fn new<T: Instance>(timer: Peri<'d, T>) -> Self { |
| 94 | Self::new_inner(timer, false) | 98 | Self::new_inner(timer, false) |
| 95 | } | 99 | } |
| 96 | 100 | ||
| @@ -98,14 +102,18 @@ impl<'d, T: Instance> Timer<'d, T> { | |||
| 98 | /// | 102 | /// |
| 99 | /// This can be useful for triggering tasks via PPI. | 103 | /// This can be useful for triggering tasks via PPI. |
| 100 | /// `Uarte` uses this internally. | 104 | /// `Uarte` uses this internally. |
| 101 | pub fn new_counter(timer: Peri<'d, T>) -> Self { | 105 | pub fn new_counter<T: Instance>(timer: Peri<'d, T>) -> Self { |
| 102 | Self::new_inner(timer, true) | 106 | Self::new_inner(timer, true) |
| 103 | } | 107 | } |
| 104 | 108 | ||
| 105 | fn new_inner(timer: Peri<'d, T>, is_counter: bool) -> Self { | 109 | fn new_inner<T: Instance>(_timer: Peri<'d, T>, is_counter: bool) -> Self { |
| 106 | let regs = T::regs(); | 110 | let regs = T::regs(); |
| 107 | 111 | ||
| 108 | let this = Self { _p: timer }; | 112 | let this = Self { |
| 113 | r: regs, | ||
| 114 | ccs: T::CCS, | ||
| 115 | _p: PhantomData, | ||
| 116 | }; | ||
| 109 | 117 | ||
| 110 | // Stop the timer before doing anything else, | 118 | // Stop the timer before doing anything else, |
| 111 | // since changing BITMODE while running can cause 'unpredictable behaviour' according to the specification. | 119 | // since changing BITMODE while running can cause 'unpredictable behaviour' according to the specification. |
| @@ -131,7 +139,7 @@ impl<'d, T: Instance> Timer<'d, T> { | |||
| 131 | // Default to the max frequency of the lower power clock | 139 | // Default to the max frequency of the lower power clock |
| 132 | this.set_frequency(Frequency::F1MHz); | 140 | this.set_frequency(Frequency::F1MHz); |
| 133 | 141 | ||
| 134 | for n in 0..T::CCS { | 142 | for n in 0..this.ccs { |
| 135 | let cc = this.cc(n); | 143 | let cc = this.cc(n); |
| 136 | // Initialize all the shorts as disabled. | 144 | // Initialize all the shorts as disabled. |
| 137 | cc.unshort_compare_clear(); | 145 | cc.unshort_compare_clear(); |
| @@ -147,43 +155,43 @@ impl<'d, T: Instance> Timer<'d, T> { | |||
| 147 | #[cfg(feature = "unstable-pac")] | 155 | #[cfg(feature = "unstable-pac")] |
| 148 | #[inline] | 156 | #[inline] |
| 149 | pub fn regs(&mut self) -> pac::timer::Timer { | 157 | pub fn regs(&mut self) -> pac::timer::Timer { |
| 150 | T::regs() | 158 | self.r |
| 151 | } | 159 | } |
| 152 | 160 | ||
| 153 | /// Starts the timer. | 161 | /// Starts the timer. |
| 154 | pub fn start(&self) { | 162 | pub fn start(&self) { |
| 155 | T::regs().tasks_start().write_value(1) | 163 | self.r.tasks_start().write_value(1) |
| 156 | } | 164 | } |
| 157 | 165 | ||
| 158 | /// Stops the timer. | 166 | /// Stops the timer. |
| 159 | pub fn stop(&self) { | 167 | pub fn stop(&self) { |
| 160 | T::regs().tasks_stop().write_value(1) | 168 | self.r.tasks_stop().write_value(1) |
| 161 | } | 169 | } |
| 162 | 170 | ||
| 163 | /// Reset the timer's counter to 0. | 171 | /// Reset the timer's counter to 0. |
| 164 | pub fn clear(&self) { | 172 | pub fn clear(&self) { |
| 165 | T::regs().tasks_clear().write_value(1) | 173 | self.r.tasks_clear().write_value(1) |
| 166 | } | 174 | } |
| 167 | 175 | ||
| 168 | /// Returns the START task, for use with PPI. | 176 | /// Returns the START task, for use with PPI. |
| 169 | /// | 177 | /// |
| 170 | /// When triggered, this task starts the timer. | 178 | /// When triggered, this task starts the timer. |
| 171 | pub fn task_start(&self) -> Task<'d> { | 179 | pub fn task_start(&self) -> Task<'d> { |
| 172 | Task::from_reg(T::regs().tasks_start()) | 180 | Task::from_reg(self.r.tasks_start()) |
| 173 | } | 181 | } |
| 174 | 182 | ||
| 175 | /// Returns the STOP task, for use with PPI. | 183 | /// Returns the STOP task, for use with PPI. |
| 176 | /// | 184 | /// |
| 177 | /// When triggered, this task stops the timer. | 185 | /// When triggered, this task stops the timer. |
| 178 | pub fn task_stop(&self) -> Task<'d> { | 186 | pub fn task_stop(&self) -> Task<'d> { |
| 179 | Task::from_reg(T::regs().tasks_stop()) | 187 | Task::from_reg(self.r.tasks_stop()) |
| 180 | } | 188 | } |
| 181 | 189 | ||
| 182 | /// Returns the CLEAR task, for use with PPI. | 190 | /// Returns the CLEAR task, for use with PPI. |
| 183 | /// | 191 | /// |
| 184 | /// When triggered, this task resets the timer's counter to 0. | 192 | /// When triggered, this task resets the timer's counter to 0. |
| 185 | pub fn task_clear(&self) -> Task<'d> { | 193 | pub fn task_clear(&self) -> Task<'d> { |
| 186 | Task::from_reg(T::regs().tasks_clear()) | 194 | Task::from_reg(self.r.tasks_clear()) |
| 187 | } | 195 | } |
| 188 | 196 | ||
| 189 | /// Returns the COUNT task, for use with PPI. | 197 | /// Returns the COUNT task, for use with PPI. |
| @@ -191,7 +199,7 @@ impl<'d, T: Instance> Timer<'d, T> { | |||
| 191 | /// When triggered, this task increments the timer's counter by 1. | 199 | /// When triggered, this task increments the timer's counter by 1. |
| 192 | /// Only works in counter mode. | 200 | /// Only works in counter mode. |
| 193 | pub fn task_count(&self) -> Task<'d> { | 201 | pub fn task_count(&self) -> Task<'d> { |
| 194 | Task::from_reg(T::regs().tasks_count()) | 202 | Task::from_reg(self.r.tasks_count()) |
| 195 | } | 203 | } |
| 196 | 204 | ||
| 197 | /// Change the timer's frequency. | 205 | /// Change the timer's frequency. |
| @@ -201,7 +209,7 @@ impl<'d, T: Instance> Timer<'d, T> { | |||
| 201 | pub fn set_frequency(&self, frequency: Frequency) { | 209 | pub fn set_frequency(&self, frequency: Frequency) { |
| 202 | self.stop(); | 210 | self.stop(); |
| 203 | 211 | ||
| 204 | T::regs() | 212 | self.r |
| 205 | .prescaler() | 213 | .prescaler() |
| 206 | // SAFETY: `frequency` is a variant of `Frequency`, | 214 | // SAFETY: `frequency` is a variant of `Frequency`, |
| 207 | // whose values are all in the range of 0-9 (the valid range of `prescaler`). | 215 | // whose values are all in the range of 0-9 (the valid range of `prescaler`). |
| @@ -212,18 +220,19 @@ impl<'d, T: Instance> Timer<'d, T> { | |||
| 212 | /// | 220 | /// |
| 213 | /// # Panics | 221 | /// # Panics |
| 214 | /// Panics if `n` >= the number of CC registers this timer has (4 for a normal timer, 6 for an extended timer). | 222 | /// Panics if `n` >= the number of CC registers this timer has (4 for a normal timer, 6 for an extended timer). |
| 215 | pub fn cc(&self, n: usize) -> Cc<'d, T> { | 223 | pub fn cc(&self, n: usize) -> Cc<'d> { |
| 216 | if n >= T::CCS { | 224 | if n >= self.ccs { |
| 217 | panic!("Cannot get CC register {} of timer with {} CC registers.", n, T::CCS); | 225 | panic!("Cannot get CC register {} of timer with {} CC registers.", n, self.ccs); |
| 218 | } | 226 | } |
| 219 | Cc { | 227 | Cc { |
| 220 | n, | 228 | n, |
| 221 | _p: unsafe { self._p.clone_unchecked() }, | 229 | r: self.r, |
| 230 | _p: PhantomData, | ||
| 222 | } | 231 | } |
| 223 | } | 232 | } |
| 224 | } | 233 | } |
| 225 | 234 | ||
| 226 | impl<T: Instance> Timer<'static, T> { | 235 | impl Timer<'static> { |
| 227 | /// Persist the timer's configuration for the rest of the program's lifetime. This method | 236 | /// Persist the timer's configuration for the rest of the program's lifetime. This method |
| 228 | /// should be preferred over [`core::mem::forget()`] because the `'static` bound prevents | 237 | /// should be preferred over [`core::mem::forget()`] because the `'static` bound prevents |
| 229 | /// accidental reuse of the underlying peripheral. | 238 | /// accidental reuse of the underlying peripheral. |
| @@ -232,7 +241,7 @@ impl<T: Instance> Timer<'static, T> { | |||
| 232 | } | 241 | } |
| 233 | } | 242 | } |
| 234 | 243 | ||
| 235 | impl<'d, T: Instance> Drop for Timer<'d, T> { | 244 | impl<'d> Drop for Timer<'d> { |
| 236 | fn drop(&mut self) { | 245 | fn drop(&mut self) { |
| 237 | self.stop(); | 246 | self.stop(); |
| 238 | } | 247 | } |
| @@ -245,27 +254,28 @@ impl<'d, T: Instance> Drop for Timer<'d, T> { | |||
| 245 | /// | 254 | /// |
| 246 | /// The timer will fire the register's COMPARE event when its counter reaches the value stored in the register. | 255 | /// The timer will fire the register's COMPARE event when its counter reaches the value stored in the register. |
| 247 | /// When the register's CAPTURE task is triggered, the timer will store the current value of its counter in the register | 256 | /// When the register's CAPTURE task is triggered, the timer will store the current value of its counter in the register |
| 248 | pub struct Cc<'d, T: Instance> { | 257 | pub struct Cc<'d> { |
| 249 | n: usize, | 258 | n: usize, |
| 250 | _p: Peri<'d, T>, | 259 | r: pac::timer::Timer, |
| 260 | _p: PhantomData<&'d ()>, | ||
| 251 | } | 261 | } |
| 252 | 262 | ||
| 253 | impl<'d, T: Instance> Cc<'d, T> { | 263 | impl<'d> Cc<'d> { |
| 254 | /// Get the current value stored in the register. | 264 | /// Get the current value stored in the register. |
| 255 | pub fn read(&self) -> u32 { | 265 | pub fn read(&self) -> u32 { |
| 256 | T::regs().cc(self.n).read() | 266 | self.r.cc(self.n).read() |
| 257 | } | 267 | } |
| 258 | 268 | ||
| 259 | /// Set the value stored in the register. | 269 | /// Set the value stored in the register. |
| 260 | /// | 270 | /// |
| 261 | /// `event_compare` will fire when the timer's counter reaches this value. | 271 | /// `event_compare` will fire when the timer's counter reaches this value. |
| 262 | pub fn write(&self, value: u32) { | 272 | pub fn write(&self, value: u32) { |
| 263 | T::regs().cc(self.n).write_value(value); | 273 | self.r.cc(self.n).write_value(value); |
| 264 | } | 274 | } |
| 265 | 275 | ||
| 266 | /// Capture the current value of the timer's counter in this register, and return it. | 276 | /// Capture the current value of the timer's counter in this register, and return it. |
| 267 | pub fn capture(&self) -> u32 { | 277 | pub fn capture(&self) -> u32 { |
| 268 | T::regs().tasks_capture(self.n).write_value(1); | 278 | self.r.tasks_capture(self.n).write_value(1); |
| 269 | self.read() | 279 | self.read() |
| 270 | } | 280 | } |
| 271 | 281 | ||
| @@ -273,20 +283,20 @@ impl<'d, T: Instance> Cc<'d, T> { | |||
| 273 | /// | 283 | /// |
| 274 | /// When triggered, this task will capture the current value of the timer's counter in this register. | 284 | /// When triggered, this task will capture the current value of the timer's counter in this register. |
| 275 | pub fn task_capture(&self) -> Task<'d> { | 285 | pub fn task_capture(&self) -> Task<'d> { |
| 276 | Task::from_reg(T::regs().tasks_capture(self.n)) | 286 | Task::from_reg(self.r.tasks_capture(self.n)) |
| 277 | } | 287 | } |
| 278 | 288 | ||
| 279 | /// Returns this CC register's COMPARE event, for use with PPI. | 289 | /// Returns this CC register's COMPARE event, for use with PPI. |
| 280 | /// | 290 | /// |
| 281 | /// This event will fire when the timer's counter reaches the value in this CC register. | 291 | /// This event will fire when the timer's counter reaches the value in this CC register. |
| 282 | pub fn event_compare(&self) -> Event<'d> { | 292 | pub fn event_compare(&self) -> Event<'d> { |
| 283 | Event::from_reg(T::regs().events_compare(self.n)) | 293 | Event::from_reg(self.r.events_compare(self.n)) |
| 284 | } | 294 | } |
| 285 | 295 | ||
| 286 | /// Clear the COMPARE event for this CC register. | 296 | /// Clear the COMPARE event for this CC register. |
| 287 | #[inline] | 297 | #[inline] |
| 288 | pub fn clear_events(&self) { | 298 | pub fn clear_events(&self) { |
| 289 | T::regs().events_compare(self.n).write_value(0); | 299 | self.r.events_compare(self.n).write_value(0); |
| 290 | } | 300 | } |
| 291 | 301 | ||
| 292 | /// Enable the shortcut between this CC register's COMPARE event and the timer's CLEAR task. | 302 | /// Enable the shortcut between this CC register's COMPARE event and the timer's CLEAR task. |
| @@ -295,12 +305,12 @@ impl<'d, T: Instance> Cc<'d, T> { | |||
| 295 | /// | 305 | /// |
| 296 | /// So, when the timer's counter reaches the value stored in this register, the timer's counter will be reset to 0. | 306 | /// So, when the timer's counter reaches the value stored in this register, the timer's counter will be reset to 0. |
| 297 | pub fn short_compare_clear(&self) { | 307 | pub fn short_compare_clear(&self) { |
| 298 | T::regs().shorts().modify(|w| w.set_compare_clear(self.n, true)) | 308 | self.r.shorts().modify(|w| w.set_compare_clear(self.n, true)) |
| 299 | } | 309 | } |
| 300 | 310 | ||
| 301 | /// Disable the shortcut between this CC register's COMPARE event and the timer's CLEAR task. | 311 | /// Disable the shortcut between this CC register's COMPARE event and the timer's CLEAR task. |
| 302 | pub fn unshort_compare_clear(&self) { | 312 | pub fn unshort_compare_clear(&self) { |
| 303 | T::regs().shorts().modify(|w| w.set_compare_clear(self.n, false)) | 313 | self.r.shorts().modify(|w| w.set_compare_clear(self.n, false)) |
| 304 | } | 314 | } |
| 305 | 315 | ||
| 306 | /// Enable the shortcut between this CC register's COMPARE event and the timer's STOP task. | 316 | /// Enable the shortcut between this CC register's COMPARE event and the timer's STOP task. |
| @@ -309,11 +319,11 @@ impl<'d, T: Instance> Cc<'d, T> { | |||
| 309 | /// | 319 | /// |
| 310 | /// So, when the timer's counter reaches the value stored in this register, the timer will stop counting up. | 320 | /// So, when the timer's counter reaches the value stored in this register, the timer will stop counting up. |
| 311 | pub fn short_compare_stop(&self) { | 321 | pub fn short_compare_stop(&self) { |
| 312 | T::regs().shorts().modify(|w| w.set_compare_stop(self.n, true)) | 322 | self.r.shorts().modify(|w| w.set_compare_stop(self.n, true)) |
| 313 | } | 323 | } |
| 314 | 324 | ||
| 315 | /// Disable the shortcut between this CC register's COMPARE event and the timer's STOP task. | 325 | /// Disable the shortcut between this CC register's COMPARE event and the timer's STOP task. |
| 316 | pub fn unshort_compare_stop(&self) { | 326 | pub fn unshort_compare_stop(&self) { |
| 317 | T::regs().shorts().modify(|w| w.set_compare_stop(self.n, false)) | 327 | self.r.shorts().modify(|w| w.set_compare_stop(self.n, false)) |
| 318 | } | 328 | } |
| 319 | } | 329 | } |
diff --git a/embassy-nrf/src/twim.rs b/embassy-nrf/src/twim.rs index 3fc59a39a..93255c832 100644 --- a/embassy-nrf/src/twim.rs +++ b/embassy-nrf/src/twim.rs | |||
| @@ -2,10 +2,10 @@ | |||
| 2 | 2 | ||
| 3 | #![macro_use] | 3 | #![macro_use] |
| 4 | 4 | ||
| 5 | use core::future::{poll_fn, Future}; | 5 | use core::future::poll_fn; |
| 6 | use core::marker::PhantomData; | 6 | use core::marker::PhantomData; |
| 7 | use core::sync::atomic::compiler_fence; | ||
| 8 | use core::sync::atomic::Ordering::SeqCst; | 7 | use core::sync::atomic::Ordering::SeqCst; |
| 8 | use core::sync::atomic::compiler_fence; | ||
| 9 | use core::task::Poll; | 9 | use core::task::Poll; |
| 10 | 10 | ||
| 11 | use embassy_embedded_hal::SetConfig; | 11 | use embassy_embedded_hal::SetConfig; |
| @@ -112,12 +112,14 @@ impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandl | |||
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | /// TWI driver. | 114 | /// TWI driver. |
| 115 | pub struct Twim<'d, T: Instance> { | 115 | pub struct Twim<'d> { |
| 116 | _p: Peri<'d, T>, | 116 | r: pac::twim::Twim, |
| 117 | state: &'static State, | ||
| 117 | tx_ram_buffer: &'d mut [u8], | 118 | tx_ram_buffer: &'d mut [u8], |
| 119 | _p: PhantomData<&'d ()>, | ||
| 118 | } | 120 | } |
| 119 | 121 | ||
| 120 | impl<'d, T: Instance> Twim<'d, T> { | 122 | impl<'d> Twim<'d> { |
| 121 | /// Create a new TWI driver. | 123 | /// Create a new TWI driver. |
| 122 | /// | 124 | /// |
| 123 | /// `tx_ram_buffer` is required if any write operations will be performed with data that is not in RAM. | 125 | /// `tx_ram_buffer` is required if any write operations will be performed with data that is not in RAM. |
| @@ -125,8 +127,8 @@ impl<'d, T: Instance> Twim<'d, T> { | |||
| 125 | /// needs to be at least as large as the largest write operation that will be executed with a buffer | 127 | /// needs to be at least as large as the largest write operation that will be executed with a buffer |
| 126 | /// that is not in RAM. If all write operations will be performed from RAM, an empty buffer (`&[]`) may | 128 | /// that is not in RAM. If all write operations will be performed from RAM, an empty buffer (`&[]`) may |
| 127 | /// be used. | 129 | /// be used. |
| 128 | pub fn new( | 130 | pub fn new<T: Instance>( |
| 129 | twim: Peri<'d, T>, | 131 | _twim: Peri<'d, T>, |
| 130 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 132 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 131 | sda: Peri<'d, impl GpioPin>, | 133 | sda: Peri<'d, impl GpioPin>, |
| 132 | scl: Peri<'d, impl GpioPin>, | 134 | scl: Peri<'d, impl GpioPin>, |
| @@ -167,8 +169,10 @@ impl<'d, T: Instance> Twim<'d, T> { | |||
| 167 | r.enable().write(|w| w.set_enable(vals::Enable::ENABLED)); | 169 | r.enable().write(|w| w.set_enable(vals::Enable::ENABLED)); |
| 168 | 170 | ||
| 169 | let mut twim = Self { | 171 | let mut twim = Self { |
| 170 | _p: twim, | 172 | r: T::regs(), |
| 173 | state: T::state(), | ||
| 171 | tx_ram_buffer, | 174 | tx_ram_buffer, |
| 175 | _p: PhantomData {}, | ||
| 172 | }; | 176 | }; |
| 173 | 177 | ||
| 174 | // Apply runtime peripheral configuration | 178 | // Apply runtime peripheral configuration |
| @@ -201,7 +205,7 @@ impl<'d, T: Instance> Twim<'d, T> { | |||
| 201 | return Err(Error::TxBufferTooLong); | 205 | return Err(Error::TxBufferTooLong); |
| 202 | } | 206 | } |
| 203 | 207 | ||
| 204 | let r = T::regs(); | 208 | let r = self.r; |
| 205 | 209 | ||
| 206 | // We're giving the register a pointer to the stack. Since we're | 210 | // We're giving the register a pointer to the stack. Since we're |
| 207 | // waiting for the I2C transaction to end before this stack pointer | 211 | // waiting for the I2C transaction to end before this stack pointer |
| @@ -228,7 +232,7 @@ impl<'d, T: Instance> Twim<'d, T> { | |||
| 228 | return Err(Error::RxBufferTooLong); | 232 | return Err(Error::RxBufferTooLong); |
| 229 | } | 233 | } |
| 230 | 234 | ||
| 231 | let r = T::regs(); | 235 | let r = self.r; |
| 232 | 236 | ||
| 233 | // We're giving the register a pointer to the stack. Since we're | 237 | // We're giving the register a pointer to the stack. Since we're |
| 234 | // waiting for the I2C transaction to end before this stack pointer | 238 | // waiting for the I2C transaction to end before this stack pointer |
| @@ -250,7 +254,7 @@ impl<'d, T: Instance> Twim<'d, T> { | |||
| 250 | } | 254 | } |
| 251 | 255 | ||
| 252 | fn clear_errorsrc(&mut self) { | 256 | fn clear_errorsrc(&mut self) { |
| 253 | let r = T::regs(); | 257 | let r = self.r; |
| 254 | r.errorsrc().write(|w| { | 258 | r.errorsrc().write(|w| { |
| 255 | w.set_anack(true); | 259 | w.set_anack(true); |
| 256 | w.set_dnack(true); | 260 | w.set_dnack(true); |
| @@ -259,8 +263,8 @@ impl<'d, T: Instance> Twim<'d, T> { | |||
| 259 | } | 263 | } |
| 260 | 264 | ||
| 261 | /// Get Error instance, if any occurred. | 265 | /// Get Error instance, if any occurred. |
| 262 | fn check_errorsrc() -> Result<(), Error> { | 266 | fn check_errorsrc(&mut self) -> Result<(), Error> { |
| 263 | let r = T::regs(); | 267 | let r = self.r; |
| 264 | 268 | ||
| 265 | let err = r.errorsrc().read(); | 269 | let err = r.errorsrc().read(); |
| 266 | if err.anack() { | 270 | if err.anack() { |
| @@ -276,7 +280,7 @@ impl<'d, T: Instance> Twim<'d, T> { | |||
| 276 | } | 280 | } |
| 277 | 281 | ||
| 278 | fn check_rx(&self, len: usize) -> Result<(), Error> { | 282 | fn check_rx(&self, len: usize) -> Result<(), Error> { |
| 279 | let r = T::regs(); | 283 | let r = self.r; |
| 280 | if r.rxd().amount().read().0 != len as u32 { | 284 | if r.rxd().amount().read().0 != len as u32 { |
| 281 | Err(Error::Receive) | 285 | Err(Error::Receive) |
| 282 | } else { | 286 | } else { |
| @@ -285,7 +289,7 @@ impl<'d, T: Instance> Twim<'d, T> { | |||
| 285 | } | 289 | } |
| 286 | 290 | ||
| 287 | fn check_tx(&self, len: usize) -> Result<(), Error> { | 291 | fn check_tx(&self, len: usize) -> Result<(), Error> { |
| 288 | let r = T::regs(); | 292 | let r = self.r; |
| 289 | if r.txd().amount().read().0 != len as u32 { | 293 | if r.txd().amount().read().0 != len as u32 { |
| 290 | Err(Error::Transmit) | 294 | Err(Error::Transmit) |
| 291 | } else { | 295 | } else { |
| @@ -295,7 +299,7 @@ impl<'d, T: Instance> Twim<'d, T> { | |||
| 295 | 299 | ||
| 296 | /// Wait for stop or error | 300 | /// Wait for stop or error |
| 297 | fn blocking_wait(&mut self) { | 301 | fn blocking_wait(&mut self) { |
| 298 | let r = T::regs(); | 302 | let r = self.r; |
| 299 | loop { | 303 | loop { |
| 300 | if r.events_suspended().read() != 0 || r.events_stopped().read() != 0 { | 304 | if r.events_suspended().read() != 0 || r.events_stopped().read() != 0 { |
| 301 | r.events_suspended().write_value(0); | 305 | r.events_suspended().write_value(0); |
| @@ -312,7 +316,7 @@ impl<'d, T: Instance> Twim<'d, T> { | |||
| 312 | /// Wait for stop or error | 316 | /// Wait for stop or error |
| 313 | #[cfg(feature = "time")] | 317 | #[cfg(feature = "time")] |
| 314 | fn blocking_wait_timeout(&mut self, timeout: Duration) -> Result<(), Error> { | 318 | fn blocking_wait_timeout(&mut self, timeout: Duration) -> Result<(), Error> { |
| 315 | let r = T::regs(); | 319 | let r = self.r; |
| 316 | let deadline = Instant::now() + timeout; | 320 | let deadline = Instant::now() + timeout; |
| 317 | loop { | 321 | loop { |
| 318 | if r.events_suspended().read() != 0 || r.events_stopped().read() != 0 { | 322 | if r.events_suspended().read() != 0 || r.events_stopped().read() != 0 { |
| @@ -333,10 +337,10 @@ impl<'d, T: Instance> Twim<'d, T> { | |||
| 333 | } | 337 | } |
| 334 | 338 | ||
| 335 | /// Wait for stop or error | 339 | /// Wait for stop or error |
| 336 | fn async_wait(&mut self) -> impl Future<Output = Result<(), Error>> { | 340 | async fn async_wait(&mut self) -> Result<(), Error> { |
| 337 | poll_fn(move |cx| { | 341 | poll_fn(|cx| { |
| 338 | let r = T::regs(); | 342 | let r = self.r; |
| 339 | let s = T::state(); | 343 | let s = self.state; |
| 340 | 344 | ||
| 341 | s.end_waker.register(cx.waker()); | 345 | s.end_waker.register(cx.waker()); |
| 342 | if r.events_suspended().read() != 0 || r.events_stopped().read() != 0 { | 346 | if r.events_suspended().read() != 0 || r.events_stopped().read() != 0 { |
| @@ -349,15 +353,16 @@ impl<'d, T: Instance> Twim<'d, T> { | |||
| 349 | if r.events_error().read() != 0 { | 353 | if r.events_error().read() != 0 { |
| 350 | r.events_error().write_value(0); | 354 | r.events_error().write_value(0); |
| 351 | r.tasks_stop().write_value(1); | 355 | r.tasks_stop().write_value(1); |
| 352 | if let Err(e) = Self::check_errorsrc() { | 356 | if let Err(e) = self.check_errorsrc() { |
| 353 | return Poll::Ready(Err(e)); | 357 | return Poll::Ready(Err(e)); |
| 354 | } else { | 358 | } else { |
| 355 | panic!("Found events_error bit without an error in errorsrc reg"); | 359 | return Poll::Ready(Err(Error::Timeout)); |
| 356 | } | 360 | } |
| 357 | } | 361 | } |
| 358 | 362 | ||
| 359 | Poll::Pending | 363 | Poll::Pending |
| 360 | }) | 364 | }) |
| 365 | .await | ||
| 361 | } | 366 | } |
| 362 | 367 | ||
| 363 | fn setup_operations( | 368 | fn setup_operations( |
| @@ -367,7 +372,7 @@ impl<'d, T: Instance> Twim<'d, T> { | |||
| 367 | last_op: Option<&Operation<'_>>, | 372 | last_op: Option<&Operation<'_>>, |
| 368 | inten: bool, | 373 | inten: bool, |
| 369 | ) -> Result<usize, Error> { | 374 | ) -> Result<usize, Error> { |
| 370 | let r = T::regs(); | 375 | let r = self.r; |
| 371 | 376 | ||
| 372 | compiler_fence(SeqCst); | 377 | compiler_fence(SeqCst); |
| 373 | 378 | ||
| @@ -511,7 +516,7 @@ impl<'d, T: Instance> Twim<'d, T> { | |||
| 511 | 516 | ||
| 512 | fn check_operations(&mut self, operations: &[Operation<'_>]) -> Result<(), Error> { | 517 | fn check_operations(&mut self, operations: &[Operation<'_>]) -> Result<(), Error> { |
| 513 | compiler_fence(SeqCst); | 518 | compiler_fence(SeqCst); |
| 514 | Self::check_errorsrc()?; | 519 | self.check_errorsrc()?; |
| 515 | 520 | ||
| 516 | assert!(operations.len() == 1 || operations.len() == 2); | 521 | assert!(operations.len() == 1 || operations.len() == 2); |
| 517 | match operations { | 522 | match operations { |
| @@ -696,14 +701,14 @@ impl<'d, T: Instance> Twim<'d, T> { | |||
| 696 | } | 701 | } |
| 697 | } | 702 | } |
| 698 | 703 | ||
| 699 | impl<'a, T: Instance> Drop for Twim<'a, T> { | 704 | impl<'a> Drop for Twim<'a> { |
| 700 | fn drop(&mut self) { | 705 | fn drop(&mut self) { |
| 701 | trace!("twim drop"); | 706 | trace!("twim drop"); |
| 702 | 707 | ||
| 703 | // TODO: check for abort | 708 | // TODO: check for abort |
| 704 | 709 | ||
| 705 | // disable! | 710 | // disable! |
| 706 | let r = T::regs(); | 711 | let r = self.r; |
| 707 | r.enable().write(|w| w.set_enable(vals::Enable::DISABLED)); | 712 | r.enable().write(|w| w.set_enable(vals::Enable::DISABLED)); |
| 708 | 713 | ||
| 709 | gpio::deconfigure_pin(r.psel().sda().read()); | 714 | gpio::deconfigure_pin(r.psel().sda().read()); |
| @@ -759,7 +764,7 @@ macro_rules! impl_twim { | |||
| 759 | mod eh02 { | 764 | mod eh02 { |
| 760 | use super::*; | 765 | use super::*; |
| 761 | 766 | ||
| 762 | impl<'a, T: Instance> embedded_hal_02::blocking::i2c::Write for Twim<'a, T> { | 767 | impl<'a> embedded_hal_02::blocking::i2c::Write for Twim<'a> { |
| 763 | type Error = Error; | 768 | type Error = Error; |
| 764 | 769 | ||
| 765 | fn write(&mut self, addr: u8, bytes: &[u8]) -> Result<(), Error> { | 770 | fn write(&mut self, addr: u8, bytes: &[u8]) -> Result<(), Error> { |
| @@ -767,7 +772,7 @@ mod eh02 { | |||
| 767 | } | 772 | } |
| 768 | } | 773 | } |
| 769 | 774 | ||
| 770 | impl<'a, T: Instance> embedded_hal_02::blocking::i2c::Read for Twim<'a, T> { | 775 | impl<'a> embedded_hal_02::blocking::i2c::Read for Twim<'a> { |
| 771 | type Error = Error; | 776 | type Error = Error; |
| 772 | 777 | ||
| 773 | fn read(&mut self, addr: u8, bytes: &mut [u8]) -> Result<(), Error> { | 778 | fn read(&mut self, addr: u8, bytes: &mut [u8]) -> Result<(), Error> { |
| @@ -775,7 +780,7 @@ mod eh02 { | |||
| 775 | } | 780 | } |
| 776 | } | 781 | } |
| 777 | 782 | ||
| 778 | impl<'a, T: Instance> embedded_hal_02::blocking::i2c::WriteRead for Twim<'a, T> { | 783 | impl<'a> embedded_hal_02::blocking::i2c::WriteRead for Twim<'a> { |
| 779 | type Error = Error; | 784 | type Error = Error; |
| 780 | 785 | ||
| 781 | fn write_read<'w>(&mut self, addr: u8, bytes: &'w [u8], buffer: &'w mut [u8]) -> Result<(), Error> { | 786 | fn write_read<'w>(&mut self, addr: u8, bytes: &'w [u8], buffer: &'w mut [u8]) -> Result<(), Error> { |
| @@ -804,27 +809,27 @@ impl embedded_hal_1::i2c::Error for Error { | |||
| 804 | } | 809 | } |
| 805 | } | 810 | } |
| 806 | 811 | ||
| 807 | impl<'d, T: Instance> embedded_hal_1::i2c::ErrorType for Twim<'d, T> { | 812 | impl<'d> embedded_hal_1::i2c::ErrorType for Twim<'d> { |
| 808 | type Error = Error; | 813 | type Error = Error; |
| 809 | } | 814 | } |
| 810 | 815 | ||
| 811 | impl<'d, T: Instance> embedded_hal_1::i2c::I2c for Twim<'d, T> { | 816 | impl<'d> embedded_hal_1::i2c::I2c for Twim<'d> { |
| 812 | fn transaction(&mut self, address: u8, operations: &mut [Operation<'_>]) -> Result<(), Self::Error> { | 817 | fn transaction(&mut self, address: u8, operations: &mut [Operation<'_>]) -> Result<(), Self::Error> { |
| 813 | self.blocking_transaction(address, operations) | 818 | self.blocking_transaction(address, operations) |
| 814 | } | 819 | } |
| 815 | } | 820 | } |
| 816 | 821 | ||
| 817 | impl<'d, T: Instance> embedded_hal_async::i2c::I2c for Twim<'d, T> { | 822 | impl<'d> embedded_hal_async::i2c::I2c for Twim<'d> { |
| 818 | async fn transaction(&mut self, address: u8, operations: &mut [Operation<'_>]) -> Result<(), Self::Error> { | 823 | async fn transaction(&mut self, address: u8, operations: &mut [Operation<'_>]) -> Result<(), Self::Error> { |
| 819 | self.transaction(address, operations).await | 824 | self.transaction(address, operations).await |
| 820 | } | 825 | } |
| 821 | } | 826 | } |
| 822 | 827 | ||
| 823 | impl<'d, T: Instance> SetConfig for Twim<'d, T> { | 828 | impl<'d> SetConfig for Twim<'d> { |
| 824 | type Config = Config; | 829 | type Config = Config; |
| 825 | type ConfigError = (); | 830 | type ConfigError = (); |
| 826 | fn set_config(&mut self, config: &Self::Config) -> Result<(), Self::ConfigError> { | 831 | fn set_config(&mut self, config: &Self::Config) -> Result<(), Self::ConfigError> { |
| 827 | let r = T::regs(); | 832 | let r = self.r; |
| 828 | r.frequency().write(|w| w.set_frequency(config.frequency)); | 833 | r.frequency().write(|w| w.set_frequency(config.frequency)); |
| 829 | 834 | ||
| 830 | Ok(()) | 835 | Ok(()) |
diff --git a/embassy-nrf/src/twis.rs b/embassy-nrf/src/twis.rs index c77d0f048..2bc0a5c13 100644 --- a/embassy-nrf/src/twis.rs +++ b/embassy-nrf/src/twis.rs | |||
| @@ -2,10 +2,10 @@ | |||
| 2 | 2 | ||
| 3 | #![macro_use] | 3 | #![macro_use] |
| 4 | 4 | ||
| 5 | use core::future::{poll_fn, Future}; | 5 | use core::future::{Future, poll_fn}; |
| 6 | use core::marker::PhantomData; | 6 | use core::marker::PhantomData; |
| 7 | use core::sync::atomic::compiler_fence; | ||
| 8 | use core::sync::atomic::Ordering::SeqCst; | 7 | use core::sync::atomic::Ordering::SeqCst; |
| 8 | use core::sync::atomic::compiler_fence; | ||
| 9 | use core::task::Poll; | 9 | use core::task::Poll; |
| 10 | 10 | ||
| 11 | use embassy_hal_internal::{Peri, PeripheralType}; | 11 | use embassy_hal_internal::{Peri, PeripheralType}; |
| @@ -140,14 +140,16 @@ impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandl | |||
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | /// TWIS driver. | 142 | /// TWIS driver. |
| 143 | pub struct Twis<'d, T: Instance> { | 143 | pub struct Twis<'d> { |
| 144 | _p: Peri<'d, T>, | 144 | r: pac::twis::Twis, |
| 145 | state: &'static State, | ||
| 146 | _p: PhantomData<&'d ()>, | ||
| 145 | } | 147 | } |
| 146 | 148 | ||
| 147 | impl<'d, T: Instance> Twis<'d, T> { | 149 | impl<'d> Twis<'d> { |
| 148 | /// Create a new TWIS driver. | 150 | /// Create a new TWIS driver. |
| 149 | pub fn new( | 151 | pub fn new<T: Instance>( |
| 150 | twis: Peri<'d, T>, | 152 | _twis: Peri<'d, T>, |
| 151 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 153 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 152 | sda: Peri<'d, impl GpioPin>, | 154 | sda: Peri<'d, impl GpioPin>, |
| 153 | scl: Peri<'d, impl GpioPin>, | 155 | scl: Peri<'d, impl GpioPin>, |
| @@ -206,7 +208,11 @@ impl<'d, T: Instance> Twis<'d, T> { | |||
| 206 | T::Interrupt::unpend(); | 208 | T::Interrupt::unpend(); |
| 207 | unsafe { T::Interrupt::enable() }; | 209 | unsafe { T::Interrupt::enable() }; |
| 208 | 210 | ||
| 209 | Self { _p: twis } | 211 | Self { |
| 212 | r: T::regs(), | ||
| 213 | state: T::state(), | ||
| 214 | _p: PhantomData, | ||
| 215 | } | ||
| 210 | } | 216 | } |
| 211 | 217 | ||
| 212 | /// Set TX buffer, checking that it is in RAM and has suitable length. | 218 | /// Set TX buffer, checking that it is in RAM and has suitable length. |
| @@ -217,7 +223,7 @@ impl<'d, T: Instance> Twis<'d, T> { | |||
| 217 | return Err(Error::TxBufferTooLong); | 223 | return Err(Error::TxBufferTooLong); |
| 218 | } | 224 | } |
| 219 | 225 | ||
| 220 | let r = T::regs(); | 226 | let r = self.r; |
| 221 | 227 | ||
| 222 | // We're giving the register a pointer to the stack. Since we're | 228 | // We're giving the register a pointer to the stack. Since we're |
| 223 | // waiting for the I2C transaction to end before this stack pointer | 229 | // waiting for the I2C transaction to end before this stack pointer |
| @@ -244,7 +250,7 @@ impl<'d, T: Instance> Twis<'d, T> { | |||
| 244 | return Err(Error::RxBufferTooLong); | 250 | return Err(Error::RxBufferTooLong); |
| 245 | } | 251 | } |
| 246 | 252 | ||
| 247 | let r = T::regs(); | 253 | let r = self.r; |
| 248 | 254 | ||
| 249 | // We're giving the register a pointer to the stack. Since we're | 255 | // We're giving the register a pointer to the stack. Since we're |
| 250 | // waiting for the I2C transaction to end before this stack pointer | 256 | // waiting for the I2C transaction to end before this stack pointer |
| @@ -266,7 +272,7 @@ impl<'d, T: Instance> Twis<'d, T> { | |||
| 266 | } | 272 | } |
| 267 | 273 | ||
| 268 | fn clear_errorsrc(&mut self) { | 274 | fn clear_errorsrc(&mut self) { |
| 269 | let r = T::regs(); | 275 | let r = self.r; |
| 270 | r.errorsrc().write(|w| { | 276 | r.errorsrc().write(|w| { |
| 271 | w.set_overflow(true); | 277 | w.set_overflow(true); |
| 272 | w.set_overread(true); | 278 | w.set_overread(true); |
| @@ -276,18 +282,18 @@ impl<'d, T: Instance> Twis<'d, T> { | |||
| 276 | 282 | ||
| 277 | /// Returns matched address for latest command. | 283 | /// Returns matched address for latest command. |
| 278 | pub fn address_match(&self) -> u8 { | 284 | pub fn address_match(&self) -> u8 { |
| 279 | let r = T::regs(); | 285 | let r = self.r; |
| 280 | r.address(r.match_().read().0 as usize).read().address() | 286 | r.address(r.match_().read().0 as usize).read().address() |
| 281 | } | 287 | } |
| 282 | 288 | ||
| 283 | /// Returns the index of the address matched in the latest command. | 289 | /// Returns the index of the address matched in the latest command. |
| 284 | pub fn address_match_index(&self) -> usize { | 290 | pub fn address_match_index(&self) -> usize { |
| 285 | T::regs().match_().read().0 as _ | 291 | self.r.match_().read().0 as _ |
| 286 | } | 292 | } |
| 287 | 293 | ||
| 288 | /// Wait for read, write, stop or error | 294 | /// Wait for read, write, stop or error |
| 289 | fn blocking_listen_wait(&mut self) -> Result<Status, Error> { | 295 | fn blocking_listen_wait(&mut self) -> Result<Status, Error> { |
| 290 | let r = T::regs(); | 296 | let r = self.r; |
| 291 | loop { | 297 | loop { |
| 292 | if r.events_error().read() != 0 { | 298 | if r.events_error().read() != 0 { |
| 293 | r.events_error().write_value(0); | 299 | r.events_error().write_value(0); |
| @@ -312,7 +318,7 @@ impl<'d, T: Instance> Twis<'d, T> { | |||
| 312 | 318 | ||
| 313 | /// Wait for stop, repeated start or error | 319 | /// Wait for stop, repeated start or error |
| 314 | fn blocking_listen_wait_end(&mut self, status: Status) -> Result<Command, Error> { | 320 | fn blocking_listen_wait_end(&mut self, status: Status) -> Result<Command, Error> { |
| 315 | let r = T::regs(); | 321 | let r = self.r; |
| 316 | loop { | 322 | loop { |
| 317 | // stop if an error occurred | 323 | // stop if an error occurred |
| 318 | if r.events_error().read() != 0 { | 324 | if r.events_error().read() != 0 { |
| @@ -338,7 +344,7 @@ impl<'d, T: Instance> Twis<'d, T> { | |||
| 338 | 344 | ||
| 339 | /// Wait for stop or error | 345 | /// Wait for stop or error |
| 340 | fn blocking_wait(&mut self) -> Result<usize, Error> { | 346 | fn blocking_wait(&mut self) -> Result<usize, Error> { |
| 341 | let r = T::regs(); | 347 | let r = self.r; |
| 342 | loop { | 348 | loop { |
| 343 | // stop if an error occurred | 349 | // stop if an error occurred |
| 344 | if r.events_error().read() != 0 { | 350 | if r.events_error().read() != 0 { |
| @@ -363,7 +369,7 @@ impl<'d, T: Instance> Twis<'d, T> { | |||
| 363 | /// Wait for stop or error with timeout | 369 | /// Wait for stop or error with timeout |
| 364 | #[cfg(feature = "time")] | 370 | #[cfg(feature = "time")] |
| 365 | fn blocking_wait_timeout(&mut self, timeout: Duration) -> Result<usize, Error> { | 371 | fn blocking_wait_timeout(&mut self, timeout: Duration) -> Result<usize, Error> { |
| 366 | let r = T::regs(); | 372 | let r = self.r; |
| 367 | let deadline = Instant::now() + timeout; | 373 | let deadline = Instant::now() + timeout; |
| 368 | loop { | 374 | loop { |
| 369 | // stop if an error occurred | 375 | // stop if an error occurred |
| @@ -392,7 +398,7 @@ impl<'d, T: Instance> Twis<'d, T> { | |||
| 392 | /// Wait for read, write, stop or error with timeout | 398 | /// Wait for read, write, stop or error with timeout |
| 393 | #[cfg(feature = "time")] | 399 | #[cfg(feature = "time")] |
| 394 | fn blocking_listen_wait_timeout(&mut self, timeout: Duration) -> Result<Status, Error> { | 400 | fn blocking_listen_wait_timeout(&mut self, timeout: Duration) -> Result<Status, Error> { |
| 395 | let r = T::regs(); | 401 | let r = self.r; |
| 396 | let deadline = Instant::now() + timeout; | 402 | let deadline = Instant::now() + timeout; |
| 397 | loop { | 403 | loop { |
| 398 | if r.events_error().read() != 0 { | 404 | if r.events_error().read() != 0 { |
| @@ -423,7 +429,7 @@ impl<'d, T: Instance> Twis<'d, T> { | |||
| 423 | /// Wait for stop, repeated start or error with timeout | 429 | /// Wait for stop, repeated start or error with timeout |
| 424 | #[cfg(feature = "time")] | 430 | #[cfg(feature = "time")] |
| 425 | fn blocking_listen_wait_end_timeout(&mut self, status: Status, timeout: Duration) -> Result<Command, Error> { | 431 | fn blocking_listen_wait_end_timeout(&mut self, status: Status, timeout: Duration) -> Result<Command, Error> { |
| 426 | let r = T::regs(); | 432 | let r = self.r; |
| 427 | let deadline = Instant::now() + timeout; | 433 | let deadline = Instant::now() + timeout; |
| 428 | loop { | 434 | loop { |
| 429 | // stop if an error occurred | 435 | // stop if an error occurred |
| @@ -453,10 +459,9 @@ impl<'d, T: Instance> Twis<'d, T> { | |||
| 453 | 459 | ||
| 454 | /// Wait for stop or error | 460 | /// Wait for stop or error |
| 455 | fn async_wait(&mut self) -> impl Future<Output = Result<usize, Error>> { | 461 | fn async_wait(&mut self) -> impl Future<Output = Result<usize, Error>> { |
| 462 | let r = self.r; | ||
| 463 | let s = self.state; | ||
| 456 | poll_fn(move |cx| { | 464 | poll_fn(move |cx| { |
| 457 | let r = T::regs(); | ||
| 458 | let s = T::state(); | ||
| 459 | |||
| 460 | s.waker.register(cx.waker()); | 465 | s.waker.register(cx.waker()); |
| 461 | 466 | ||
| 462 | // stop if an error occurred | 467 | // stop if an error occurred |
| @@ -483,10 +488,9 @@ impl<'d, T: Instance> Twis<'d, T> { | |||
| 483 | 488 | ||
| 484 | /// Wait for read or write | 489 | /// Wait for read or write |
| 485 | fn async_listen_wait(&mut self) -> impl Future<Output = Result<Status, Error>> { | 490 | fn async_listen_wait(&mut self) -> impl Future<Output = Result<Status, Error>> { |
| 491 | let r = self.r; | ||
| 492 | let s = self.state; | ||
| 486 | poll_fn(move |cx| { | 493 | poll_fn(move |cx| { |
| 487 | let r = T::regs(); | ||
| 488 | let s = T::state(); | ||
| 489 | |||
| 490 | s.waker.register(cx.waker()); | 494 | s.waker.register(cx.waker()); |
| 491 | 495 | ||
| 492 | // stop if an error occurred | 496 | // stop if an error occurred |
| @@ -510,10 +514,9 @@ impl<'d, T: Instance> Twis<'d, T> { | |||
| 510 | 514 | ||
| 511 | /// Wait for stop, repeated start or error | 515 | /// Wait for stop, repeated start or error |
| 512 | fn async_listen_wait_end(&mut self, status: Status) -> impl Future<Output = Result<Command, Error>> { | 516 | fn async_listen_wait_end(&mut self, status: Status) -> impl Future<Output = Result<Command, Error>> { |
| 517 | let r = self.r; | ||
| 518 | let s = self.state; | ||
| 513 | poll_fn(move |cx| { | 519 | poll_fn(move |cx| { |
| 514 | let r = T::regs(); | ||
| 515 | let s = T::state(); | ||
| 516 | |||
| 517 | s.waker.register(cx.waker()); | 520 | s.waker.register(cx.waker()); |
| 518 | 521 | ||
| 519 | // stop if an error occurred | 522 | // stop if an error occurred |
| @@ -540,7 +543,7 @@ impl<'d, T: Instance> Twis<'d, T> { | |||
| 540 | } | 543 | } |
| 541 | 544 | ||
| 542 | fn setup_respond_from_ram(&mut self, buffer: &[u8], inten: bool) -> Result<(), Error> { | 545 | fn setup_respond_from_ram(&mut self, buffer: &[u8], inten: bool) -> Result<(), Error> { |
| 543 | let r = T::regs(); | 546 | let r = self.r; |
| 544 | 547 | ||
| 545 | compiler_fence(SeqCst); | 548 | compiler_fence(SeqCst); |
| 546 | 549 | ||
| @@ -584,7 +587,7 @@ impl<'d, T: Instance> Twis<'d, T> { | |||
| 584 | } | 587 | } |
| 585 | 588 | ||
| 586 | fn setup_listen(&mut self, buffer: &mut [u8], inten: bool) -> Result<(), Error> { | 589 | fn setup_listen(&mut self, buffer: &mut [u8], inten: bool) -> Result<(), Error> { |
| 587 | let r = T::regs(); | 590 | let r = self.r; |
| 588 | compiler_fence(SeqCst); | 591 | compiler_fence(SeqCst); |
| 589 | 592 | ||
| 590 | // Set up the DMA read. | 593 | // Set up the DMA read. |
| @@ -620,7 +623,7 @@ impl<'d, T: Instance> Twis<'d, T> { | |||
| 620 | } | 623 | } |
| 621 | 624 | ||
| 622 | fn setup_listen_end(&mut self, inten: bool) -> Result<(), Error> { | 625 | fn setup_listen_end(&mut self, inten: bool) -> Result<(), Error> { |
| 623 | let r = T::regs(); | 626 | let r = self.r; |
| 624 | compiler_fence(SeqCst); | 627 | compiler_fence(SeqCst); |
| 625 | 628 | ||
| 626 | // Clear events | 629 | // Clear events |
| @@ -753,14 +756,14 @@ impl<'d, T: Instance> Twis<'d, T> { | |||
| 753 | } | 756 | } |
| 754 | } | 757 | } |
| 755 | 758 | ||
| 756 | impl<'a, T: Instance> Drop for Twis<'a, T> { | 759 | impl<'a> Drop for Twis<'a> { |
| 757 | fn drop(&mut self) { | 760 | fn drop(&mut self) { |
| 758 | trace!("twis drop"); | 761 | trace!("twis drop"); |
| 759 | 762 | ||
| 760 | // TODO: check for abort | 763 | // TODO: check for abort |
| 761 | 764 | ||
| 762 | // disable! | 765 | // disable! |
| 763 | let r = T::regs(); | 766 | let r = self.r; |
| 764 | r.enable().write(|w| w.set_enable(vals::Enable::DISABLED)); | 767 | r.enable().write(|w| w.set_enable(vals::Enable::DISABLED)); |
| 765 | 768 | ||
| 766 | gpio::deconfigure_pin(r.psel().sda().read()); | 769 | gpio::deconfigure_pin(r.psel().sda().read()); |
diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs index 927a0ac08..1ee452173 100644 --- a/embassy-nrf/src/uarte.rs +++ b/embassy-nrf/src/uarte.rs | |||
| @@ -15,7 +15,7 @@ | |||
| 15 | 15 | ||
| 16 | use core::future::poll_fn; | 16 | use core::future::poll_fn; |
| 17 | use core::marker::PhantomData; | 17 | use core::marker::PhantomData; |
| 18 | use core::sync::atomic::{compiler_fence, AtomicU8, Ordering}; | 18 | use core::sync::atomic::{AtomicU8, Ordering, compiler_fence}; |
| 19 | use core::task::Poll; | 19 | use core::task::Poll; |
| 20 | 20 | ||
| 21 | use embassy_hal_internal::drop::OnDrop; | 21 | use embassy_hal_internal::drop::OnDrop; |
| @@ -25,7 +25,7 @@ use embassy_sync::waitqueue::AtomicWaker; | |||
| 25 | pub use pac::uarte::vals::{Baudrate, ConfigParity as Parity}; | 25 | pub use pac::uarte::vals::{Baudrate, ConfigParity as Parity}; |
| 26 | 26 | ||
| 27 | use crate::chip::{EASY_DMA_SIZE, FORCE_COPY_BUFFER_SIZE}; | 27 | use crate::chip::{EASY_DMA_SIZE, FORCE_COPY_BUFFER_SIZE}; |
| 28 | use crate::gpio::{self, AnyPin, Pin as GpioPin, PselBits, SealedPin as _, DISCONNECTED}; | 28 | use crate::gpio::{self, AnyPin, DISCONNECTED, Pin as GpioPin, PselBits, SealedPin as _}; |
| 29 | use crate::interrupt::typelevel::Interrupt; | 29 | use crate::interrupt::typelevel::Interrupt; |
| 30 | use crate::pac::gpio::vals as gpiovals; | 30 | use crate::pac::gpio::vals as gpiovals; |
| 31 | use crate::pac::uarte::vals; | 31 | use crate::pac::uarte::vals; |
| @@ -132,28 +132,32 @@ impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandl | |||
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | /// UARTE driver. | 134 | /// UARTE driver. |
| 135 | pub struct Uarte<'d, T: Instance> { | 135 | pub struct Uarte<'d> { |
| 136 | tx: UarteTx<'d, T>, | 136 | tx: UarteTx<'d>, |
| 137 | rx: UarteRx<'d, T>, | 137 | rx: UarteRx<'d>, |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | /// Transmitter part of the UARTE driver. | 140 | /// Transmitter part of the UARTE driver. |
| 141 | /// | 141 | /// |
| 142 | /// This can be obtained via [`Uarte::split`], or created directly. | 142 | /// This can be obtained via [`Uarte::split`], or created directly. |
| 143 | pub struct UarteTx<'d, T: Instance> { | 143 | pub struct UarteTx<'d> { |
| 144 | _p: Peri<'d, T>, | 144 | r: pac::uarte::Uarte, |
| 145 | state: &'static State, | ||
| 146 | _p: PhantomData<&'d ()>, | ||
| 145 | } | 147 | } |
| 146 | 148 | ||
| 147 | /// Receiver part of the UARTE driver. | 149 | /// Receiver part of the UARTE driver. |
| 148 | /// | 150 | /// |
| 149 | /// This can be obtained via [`Uarte::split`], or created directly. | 151 | /// This can be obtained via [`Uarte::split`], or created directly. |
| 150 | pub struct UarteRx<'d, T: Instance> { | 152 | pub struct UarteRx<'d> { |
| 151 | _p: Peri<'d, T>, | 153 | r: pac::uarte::Uarte, |
| 154 | state: &'static State, | ||
| 155 | _p: PhantomData<&'d ()>, | ||
| 152 | } | 156 | } |
| 153 | 157 | ||
| 154 | impl<'d, T: Instance> Uarte<'d, T> { | 158 | impl<'d> Uarte<'d> { |
| 155 | /// Create a new UARTE without hardware flow control | 159 | /// Create a new UARTE without hardware flow control |
| 156 | pub fn new( | 160 | pub fn new<T: Instance>( |
| 157 | uarte: Peri<'d, T>, | 161 | uarte: Peri<'d, T>, |
| 158 | rxd: Peri<'d, impl GpioPin>, | 162 | rxd: Peri<'d, impl GpioPin>, |
| 159 | txd: Peri<'d, impl GpioPin>, | 163 | txd: Peri<'d, impl GpioPin>, |
| @@ -164,7 +168,7 @@ impl<'d, T: Instance> Uarte<'d, T> { | |||
| 164 | } | 168 | } |
| 165 | 169 | ||
| 166 | /// Create a new UARTE with hardware flow control (RTS/CTS) | 170 | /// Create a new UARTE with hardware flow control (RTS/CTS) |
| 167 | pub fn new_with_rtscts( | 171 | pub fn new_with_rtscts<T: Instance>( |
| 168 | uarte: Peri<'d, T>, | 172 | uarte: Peri<'d, T>, |
| 169 | rxd: Peri<'d, impl GpioPin>, | 173 | rxd: Peri<'d, impl GpioPin>, |
| 170 | txd: Peri<'d, impl GpioPin>, | 174 | txd: Peri<'d, impl GpioPin>, |
| @@ -183,8 +187,8 @@ impl<'d, T: Instance> Uarte<'d, T> { | |||
| 183 | ) | 187 | ) |
| 184 | } | 188 | } |
| 185 | 189 | ||
| 186 | fn new_inner( | 190 | fn new_inner<T: Instance>( |
| 187 | uarte: Peri<'d, T>, | 191 | _uarte: Peri<'d, T>, |
| 188 | rxd: Peri<'d, AnyPin>, | 192 | rxd: Peri<'d, AnyPin>, |
| 189 | txd: Peri<'d, AnyPin>, | 193 | txd: Peri<'d, AnyPin>, |
| 190 | cts: Option<Peri<'d, AnyPin>>, | 194 | cts: Option<Peri<'d, AnyPin>>, |
| @@ -211,16 +215,22 @@ impl<'d, T: Instance> Uarte<'d, T> { | |||
| 211 | 215 | ||
| 212 | Self { | 216 | Self { |
| 213 | tx: UarteTx { | 217 | tx: UarteTx { |
| 214 | _p: unsafe { uarte.clone_unchecked() }, | 218 | r: T::regs(), |
| 219 | state: T::state(), | ||
| 220 | _p: PhantomData {}, | ||
| 221 | }, | ||
| 222 | rx: UarteRx { | ||
| 223 | r: T::regs(), | ||
| 224 | state: T::state(), | ||
| 225 | _p: PhantomData {}, | ||
| 215 | }, | 226 | }, |
| 216 | rx: UarteRx { _p: uarte }, | ||
| 217 | } | 227 | } |
| 218 | } | 228 | } |
| 219 | 229 | ||
| 220 | /// Split the Uarte into the transmitter and receiver parts. | 230 | /// Split the Uarte into the transmitter and receiver parts. |
| 221 | /// | 231 | /// |
| 222 | /// This is useful to concurrently transmit and receive from independent tasks. | 232 | /// This is useful to concurrently transmit and receive from independent tasks. |
| 223 | pub fn split(self) -> (UarteTx<'d, T>, UarteRx<'d, T>) { | 233 | pub fn split(self) -> (UarteTx<'d>, UarteRx<'d>) { |
| 224 | (self.tx, self.rx) | 234 | (self.tx, self.rx) |
| 225 | } | 235 | } |
| 226 | 236 | ||
| @@ -228,7 +238,7 @@ impl<'d, T: Instance> Uarte<'d, T> { | |||
| 228 | /// | 238 | /// |
| 229 | /// The returned halves borrow from `self`, so you can drop them and go back to using | 239 | /// The returned halves borrow from `self`, so you can drop them and go back to using |
| 230 | /// the "un-split" `self`. This allows temporarily splitting the UART. | 240 | /// the "un-split" `self`. This allows temporarily splitting the UART. |
| 231 | pub fn split_by_ref(&mut self) -> (&mut UarteTx<'d, T>, &mut UarteRx<'d, T>) { | 241 | pub fn split_by_ref(&mut self) -> (&mut UarteTx<'d>, &mut UarteRx<'d>) { |
| 232 | (&mut self.tx, &mut self.rx) | 242 | (&mut self.tx, &mut self.rx) |
| 233 | } | 243 | } |
| 234 | 244 | ||
| @@ -240,13 +250,13 @@ impl<'d, T: Instance> Uarte<'d, T> { | |||
| 240 | timer: Peri<'d, U>, | 250 | timer: Peri<'d, U>, |
| 241 | ppi_ch1: Peri<'d, impl ConfigurableChannel + 'd>, | 251 | ppi_ch1: Peri<'d, impl ConfigurableChannel + 'd>, |
| 242 | ppi_ch2: Peri<'d, impl ConfigurableChannel + 'd>, | 252 | ppi_ch2: Peri<'d, impl ConfigurableChannel + 'd>, |
| 243 | ) -> (UarteTx<'d, T>, UarteRxWithIdle<'d, T, U>) { | 253 | ) -> (UarteTx<'d>, UarteRxWithIdle<'d>) { |
| 244 | (self.tx, self.rx.with_idle(timer, ppi_ch1, ppi_ch2)) | 254 | (self.tx, self.rx.with_idle(timer, ppi_ch1, ppi_ch2)) |
| 245 | } | 255 | } |
| 246 | 256 | ||
| 247 | /// Return the endtx event for use with PPI | 257 | /// Return the endtx event for use with PPI |
| 248 | pub fn event_endtx(&self) -> Event<'_> { | 258 | pub fn event_endtx(&self) -> Event<'_> { |
| 249 | let r = T::regs(); | 259 | let r = self.tx.r; |
| 250 | Event::from_reg(r.events_endtx()) | 260 | Event::from_reg(r.events_endtx()) |
| 251 | } | 261 | } |
| 252 | 262 | ||
| @@ -343,9 +353,9 @@ pub(crate) fn configure(r: pac::uarte::Uarte, config: Config, hardware_flow_cont | |||
| 343 | apply_workaround_for_enable_anomaly(r); | 353 | apply_workaround_for_enable_anomaly(r); |
| 344 | } | 354 | } |
| 345 | 355 | ||
| 346 | impl<'d, T: Instance> UarteTx<'d, T> { | 356 | impl<'d> UarteTx<'d> { |
| 347 | /// Create a new tx-only UARTE without hardware flow control | 357 | /// Create a new tx-only UARTE without hardware flow control |
| 348 | pub fn new( | 358 | pub fn new<T: Instance>( |
| 349 | uarte: Peri<'d, T>, | 359 | uarte: Peri<'d, T>, |
| 350 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 360 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 351 | txd: Peri<'d, impl GpioPin>, | 361 | txd: Peri<'d, impl GpioPin>, |
| @@ -355,7 +365,7 @@ impl<'d, T: Instance> UarteTx<'d, T> { | |||
| 355 | } | 365 | } |
| 356 | 366 | ||
| 357 | /// Create a new tx-only UARTE with hardware flow control (RTS/CTS) | 367 | /// Create a new tx-only UARTE with hardware flow control (RTS/CTS) |
| 358 | pub fn new_with_rtscts( | 368 | pub fn new_with_rtscts<T: Instance>( |
| 359 | uarte: Peri<'d, T>, | 369 | uarte: Peri<'d, T>, |
| 360 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 370 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 361 | txd: Peri<'d, impl GpioPin>, | 371 | txd: Peri<'d, impl GpioPin>, |
| @@ -365,7 +375,12 @@ impl<'d, T: Instance> UarteTx<'d, T> { | |||
| 365 | Self::new_inner(uarte, txd.into(), Some(cts.into()), config) | 375 | Self::new_inner(uarte, txd.into(), Some(cts.into()), config) |
| 366 | } | 376 | } |
| 367 | 377 | ||
| 368 | fn new_inner(uarte: Peri<'d, T>, txd: Peri<'d, AnyPin>, cts: Option<Peri<'d, AnyPin>>, config: Config) -> Self { | 378 | fn new_inner<T: Instance>( |
| 379 | _uarte: Peri<'d, T>, | ||
| 380 | txd: Peri<'d, AnyPin>, | ||
| 381 | cts: Option<Peri<'d, AnyPin>>, | ||
| 382 | config: Config, | ||
| 383 | ) -> Self { | ||
| 369 | let r = T::regs(); | 384 | let r = T::regs(); |
| 370 | 385 | ||
| 371 | configure(r, config, cts.is_some()); | 386 | configure(r, config, cts.is_some()); |
| @@ -378,7 +393,11 @@ impl<'d, T: Instance> UarteTx<'d, T> { | |||
| 378 | let s = T::state(); | 393 | let s = T::state(); |
| 379 | s.tx_rx_refcount.store(1, Ordering::Relaxed); | 394 | s.tx_rx_refcount.store(1, Ordering::Relaxed); |
| 380 | 395 | ||
| 381 | Self { _p: uarte } | 396 | Self { |
| 397 | r: T::regs(), | ||
| 398 | state: T::state(), | ||
| 399 | _p: PhantomData {}, | ||
| 400 | } | ||
| 382 | } | 401 | } |
| 383 | 402 | ||
| 384 | /// Write all bytes in the buffer. | 403 | /// Write all bytes in the buffer. |
| @@ -409,8 +428,8 @@ impl<'d, T: Instance> UarteTx<'d, T> { | |||
| 409 | let ptr = buffer.as_ptr(); | 428 | let ptr = buffer.as_ptr(); |
| 410 | let len = buffer.len(); | 429 | let len = buffer.len(); |
| 411 | 430 | ||
| 412 | let r = T::regs(); | 431 | let r = self.r; |
| 413 | let s = T::state(); | 432 | let s = self.state; |
| 414 | 433 | ||
| 415 | let drop = OnDrop::new(move || { | 434 | let drop = OnDrop::new(move || { |
| 416 | trace!("write drop: stopping"); | 435 | trace!("write drop: stopping"); |
| @@ -479,7 +498,7 @@ impl<'d, T: Instance> UarteTx<'d, T> { | |||
| 479 | let ptr = buffer.as_ptr(); | 498 | let ptr = buffer.as_ptr(); |
| 480 | let len = buffer.len(); | 499 | let len = buffer.len(); |
| 481 | 500 | ||
| 482 | let r = T::regs(); | 501 | let r = self.r; |
| 483 | 502 | ||
| 484 | r.txd().ptr().write_value(ptr as u32); | 503 | r.txd().ptr().write_value(ptr as u32); |
| 485 | r.txd().maxcnt().write(|w| w.set_maxcnt(len as _)); | 504 | r.txd().maxcnt().write(|w| w.set_maxcnt(len as _)); |
| @@ -501,11 +520,11 @@ impl<'d, T: Instance> UarteTx<'d, T> { | |||
| 501 | } | 520 | } |
| 502 | } | 521 | } |
| 503 | 522 | ||
| 504 | impl<'a, T: Instance> Drop for UarteTx<'a, T> { | 523 | impl<'a> Drop for UarteTx<'a> { |
| 505 | fn drop(&mut self) { | 524 | fn drop(&mut self) { |
| 506 | trace!("uarte tx drop"); | 525 | trace!("uarte tx drop"); |
| 507 | 526 | ||
| 508 | let r = T::regs(); | 527 | let r = self.r; |
| 509 | 528 | ||
| 510 | let did_stoptx = r.events_txstarted().read() != 0; | 529 | let did_stoptx = r.events_txstarted().read() != 0; |
| 511 | trace!("did_stoptx {}", did_stoptx); | 530 | trace!("did_stoptx {}", did_stoptx); |
| @@ -513,15 +532,15 @@ impl<'a, T: Instance> Drop for UarteTx<'a, T> { | |||
| 513 | // Wait for txstopped, if needed. | 532 | // Wait for txstopped, if needed. |
| 514 | while did_stoptx && r.events_txstopped().read() == 0 {} | 533 | while did_stoptx && r.events_txstopped().read() == 0 {} |
| 515 | 534 | ||
| 516 | let s = T::state(); | 535 | let s = self.state; |
| 517 | 536 | ||
| 518 | drop_tx_rx(r, s); | 537 | drop_tx_rx(r, s); |
| 519 | } | 538 | } |
| 520 | } | 539 | } |
| 521 | 540 | ||
| 522 | impl<'d, T: Instance> UarteRx<'d, T> { | 541 | impl<'d> UarteRx<'d> { |
| 523 | /// Create a new rx-only UARTE without hardware flow control | 542 | /// Create a new rx-only UARTE without hardware flow control |
| 524 | pub fn new( | 543 | pub fn new<T: Instance>( |
| 525 | uarte: Peri<'d, T>, | 544 | uarte: Peri<'d, T>, |
| 526 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 545 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 527 | rxd: Peri<'d, impl GpioPin>, | 546 | rxd: Peri<'d, impl GpioPin>, |
| @@ -531,7 +550,7 @@ impl<'d, T: Instance> UarteRx<'d, T> { | |||
| 531 | } | 550 | } |
| 532 | 551 | ||
| 533 | /// Create a new rx-only UARTE with hardware flow control (RTS/CTS) | 552 | /// Create a new rx-only UARTE with hardware flow control (RTS/CTS) |
| 534 | pub fn new_with_rtscts( | 553 | pub fn new_with_rtscts<T: Instance>( |
| 535 | uarte: Peri<'d, T>, | 554 | uarte: Peri<'d, T>, |
| 536 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 555 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 537 | rxd: Peri<'d, impl GpioPin>, | 556 | rxd: Peri<'d, impl GpioPin>, |
| @@ -543,13 +562,18 @@ impl<'d, T: Instance> UarteRx<'d, T> { | |||
| 543 | 562 | ||
| 544 | /// Check for errors and clear the error register if an error occured. | 563 | /// Check for errors and clear the error register if an error occured. |
| 545 | fn check_and_clear_errors(&mut self) -> Result<(), Error> { | 564 | fn check_and_clear_errors(&mut self) -> Result<(), Error> { |
| 546 | let r = T::regs(); | 565 | let r = self.r; |
| 547 | let err_bits = r.errorsrc().read(); | 566 | let err_bits = r.errorsrc().read(); |
| 548 | r.errorsrc().write_value(err_bits); | 567 | r.errorsrc().write_value(err_bits); |
| 549 | ErrorSource::from_bits_truncate(err_bits.0).check() | 568 | ErrorSource::from_bits_truncate(err_bits.0).check() |
| 550 | } | 569 | } |
| 551 | 570 | ||
| 552 | fn new_inner(uarte: Peri<'d, T>, rxd: Peri<'d, AnyPin>, rts: Option<Peri<'d, AnyPin>>, config: Config) -> Self { | 571 | fn new_inner<T: Instance>( |
| 572 | _uarte: Peri<'d, T>, | ||
| 573 | rxd: Peri<'d, AnyPin>, | ||
| 574 | rts: Option<Peri<'d, AnyPin>>, | ||
| 575 | config: Config, | ||
| 576 | ) -> Self { | ||
| 553 | let r = T::regs(); | 577 | let r = T::regs(); |
| 554 | 578 | ||
| 555 | configure(r, config, rts.is_some()); | 579 | configure(r, config, rts.is_some()); |
| @@ -562,7 +586,11 @@ impl<'d, T: Instance> UarteRx<'d, T> { | |||
| 562 | let s = T::state(); | 586 | let s = T::state(); |
| 563 | s.tx_rx_refcount.store(1, Ordering::Relaxed); | 587 | s.tx_rx_refcount.store(1, Ordering::Relaxed); |
| 564 | 588 | ||
| 565 | Self { _p: uarte } | 589 | Self { |
| 590 | r: T::regs(), | ||
| 591 | state: T::state(), | ||
| 592 | _p: PhantomData {}, | ||
| 593 | } | ||
| 566 | } | 594 | } |
| 567 | 595 | ||
| 568 | /// Upgrade to an instance that supports idle line detection. | 596 | /// Upgrade to an instance that supports idle line detection. |
| @@ -571,10 +599,10 @@ impl<'d, T: Instance> UarteRx<'d, T> { | |||
| 571 | timer: Peri<'d, U>, | 599 | timer: Peri<'d, U>, |
| 572 | ppi_ch1: Peri<'d, impl ConfigurableChannel + 'd>, | 600 | ppi_ch1: Peri<'d, impl ConfigurableChannel + 'd>, |
| 573 | ppi_ch2: Peri<'d, impl ConfigurableChannel + 'd>, | 601 | ppi_ch2: Peri<'d, impl ConfigurableChannel + 'd>, |
| 574 | ) -> UarteRxWithIdle<'d, T, U> { | 602 | ) -> UarteRxWithIdle<'d> { |
| 575 | let timer = Timer::new(timer); | 603 | let timer = Timer::new(timer); |
| 576 | 604 | ||
| 577 | let r = T::regs(); | 605 | let r = self.r; |
| 578 | 606 | ||
| 579 | // BAUDRATE register values are `baudrate * 2^32 / 16000000` | 607 | // BAUDRATE register values are `baudrate * 2^32 / 16000000` |
| 580 | // source: https://devzone.nordicsemi.com/f/nordic-q-a/391/uart-baudrate-register-values | 608 | // source: https://devzone.nordicsemi.com/f/nordic-q-a/391/uart-baudrate-register-values |
| @@ -605,11 +633,15 @@ impl<'d, T: Instance> UarteRx<'d, T> { | |||
| 605 | ); | 633 | ); |
| 606 | ppi_ch2.enable(); | 634 | ppi_ch2.enable(); |
| 607 | 635 | ||
| 636 | let state = self.state; | ||
| 637 | |||
| 608 | UarteRxWithIdle { | 638 | UarteRxWithIdle { |
| 609 | rx: self, | 639 | rx: self, |
| 610 | timer, | 640 | timer, |
| 611 | ppi_ch1, | 641 | ppi_ch1: ppi_ch1, |
| 612 | _ppi_ch2: ppi_ch2, | 642 | _ppi_ch2: ppi_ch2, |
| 643 | r: r, | ||
| 644 | state: state, | ||
| 613 | } | 645 | } |
| 614 | } | 646 | } |
| 615 | 647 | ||
| @@ -625,8 +657,8 @@ impl<'d, T: Instance> UarteRx<'d, T> { | |||
| 625 | let ptr = buffer.as_ptr(); | 657 | let ptr = buffer.as_ptr(); |
| 626 | let len = buffer.len(); | 658 | let len = buffer.len(); |
| 627 | 659 | ||
| 628 | let r = T::regs(); | 660 | let r = self.r; |
| 629 | let s = T::state(); | 661 | let s = self.state; |
| 630 | 662 | ||
| 631 | let drop = OnDrop::new(move || { | 663 | let drop = OnDrop::new(move || { |
| 632 | trace!("read drop: stopping"); | 664 | trace!("read drop: stopping"); |
| @@ -692,7 +724,7 @@ impl<'d, T: Instance> UarteRx<'d, T> { | |||
| 692 | let ptr = buffer.as_ptr(); | 724 | let ptr = buffer.as_ptr(); |
| 693 | let len = buffer.len(); | 725 | let len = buffer.len(); |
| 694 | 726 | ||
| 695 | let r = T::regs(); | 727 | let r = self.r; |
| 696 | 728 | ||
| 697 | r.rxd().ptr().write_value(ptr as u32); | 729 | r.rxd().ptr().write_value(ptr as u32); |
| 698 | r.rxd().maxcnt().write(|w| w.set_maxcnt(len as _)); | 730 | r.rxd().maxcnt().write(|w| w.set_maxcnt(len as _)); |
| @@ -718,11 +750,11 @@ impl<'d, T: Instance> UarteRx<'d, T> { | |||
| 718 | } | 750 | } |
| 719 | } | 751 | } |
| 720 | 752 | ||
| 721 | impl<'a, T: Instance> Drop for UarteRx<'a, T> { | 753 | impl<'a> Drop for UarteRx<'a> { |
| 722 | fn drop(&mut self) { | 754 | fn drop(&mut self) { |
| 723 | trace!("uarte rx drop"); | 755 | trace!("uarte rx drop"); |
| 724 | 756 | ||
| 725 | let r = T::regs(); | 757 | let r = self.r; |
| 726 | 758 | ||
| 727 | let did_stoprx = r.events_rxstarted().read() != 0; | 759 | let did_stoprx = r.events_rxstarted().read() != 0; |
| 728 | trace!("did_stoprx {}", did_stoprx); | 760 | trace!("did_stoprx {}", did_stoprx); |
| @@ -730,7 +762,7 @@ impl<'a, T: Instance> Drop for UarteRx<'a, T> { | |||
| 730 | // Wait for rxto, if needed. | 762 | // Wait for rxto, if needed. |
| 731 | while did_stoprx && r.events_rxto().read() == 0 {} | 763 | while did_stoprx && r.events_rxto().read() == 0 {} |
| 732 | 764 | ||
| 733 | let s = T::state(); | 765 | let s = self.state; |
| 734 | 766 | ||
| 735 | drop_tx_rx(r, s); | 767 | drop_tx_rx(r, s); |
| 736 | } | 768 | } |
| @@ -739,14 +771,16 @@ impl<'a, T: Instance> Drop for UarteRx<'a, T> { | |||
| 739 | /// Receiver part of the UARTE driver, with `read_until_idle` support. | 771 | /// Receiver part of the UARTE driver, with `read_until_idle` support. |
| 740 | /// | 772 | /// |
| 741 | /// This can be obtained via [`Uarte::split_with_idle`]. | 773 | /// This can be obtained via [`Uarte::split_with_idle`]. |
| 742 | pub struct UarteRxWithIdle<'d, T: Instance, U: TimerInstance> { | 774 | pub struct UarteRxWithIdle<'d> { |
| 743 | rx: UarteRx<'d, T>, | 775 | rx: UarteRx<'d>, |
| 744 | timer: Timer<'d, U>, | 776 | timer: Timer<'d>, |
| 745 | ppi_ch1: Ppi<'d, AnyConfigurableChannel, 1, 2>, | 777 | ppi_ch1: Ppi<'d, AnyConfigurableChannel, 1, 2>, |
| 746 | _ppi_ch2: Ppi<'d, AnyConfigurableChannel, 1, 1>, | 778 | _ppi_ch2: Ppi<'d, AnyConfigurableChannel, 1, 1>, |
| 779 | r: pac::uarte::Uarte, | ||
| 780 | state: &'static State, | ||
| 747 | } | 781 | } |
| 748 | 782 | ||
| 749 | impl<'d, T: Instance, U: TimerInstance> UarteRxWithIdle<'d, T, U> { | 783 | impl<'d> UarteRxWithIdle<'d> { |
| 750 | /// Read bytes until the buffer is filled. | 784 | /// Read bytes until the buffer is filled. |
| 751 | pub async fn read(&mut self, buffer: &mut [u8]) -> Result<(), Error> { | 785 | pub async fn read(&mut self, buffer: &mut [u8]) -> Result<(), Error> { |
| 752 | self.ppi_ch1.disable(); | 786 | self.ppi_ch1.disable(); |
| @@ -773,8 +807,8 @@ impl<'d, T: Instance, U: TimerInstance> UarteRxWithIdle<'d, T, U> { | |||
| 773 | let ptr = buffer.as_ptr(); | 807 | let ptr = buffer.as_ptr(); |
| 774 | let len = buffer.len(); | 808 | let len = buffer.len(); |
| 775 | 809 | ||
| 776 | let r = T::regs(); | 810 | let r = self.r; |
| 777 | let s = T::state(); | 811 | let s = self.state; |
| 778 | 812 | ||
| 779 | self.ppi_ch1.enable(); | 813 | self.ppi_ch1.enable(); |
| 780 | 814 | ||
| @@ -846,7 +880,7 @@ impl<'d, T: Instance, U: TimerInstance> UarteRxWithIdle<'d, T, U> { | |||
| 846 | let ptr = buffer.as_ptr(); | 880 | let ptr = buffer.as_ptr(); |
| 847 | let len = buffer.len(); | 881 | let len = buffer.len(); |
| 848 | 882 | ||
| 849 | let r = T::regs(); | 883 | let r = self.r; |
| 850 | 884 | ||
| 851 | self.ppi_ch1.enable(); | 885 | self.ppi_ch1.enable(); |
| 852 | 886 | ||
| @@ -997,7 +1031,7 @@ macro_rules! impl_uarte { | |||
| 997 | mod eh02 { | 1031 | mod eh02 { |
| 998 | use super::*; | 1032 | use super::*; |
| 999 | 1033 | ||
| 1000 | impl<'d, T: Instance> embedded_hal_02::blocking::serial::Write<u8> for Uarte<'d, T> { | 1034 | impl<'d> embedded_hal_02::blocking::serial::Write<u8> for Uarte<'d> { |
| 1001 | type Error = Error; | 1035 | type Error = Error; |
| 1002 | 1036 | ||
| 1003 | fn bwrite_all(&mut self, buffer: &[u8]) -> Result<(), Self::Error> { | 1037 | fn bwrite_all(&mut self, buffer: &[u8]) -> Result<(), Self::Error> { |
| @@ -1009,7 +1043,7 @@ mod eh02 { | |||
| 1009 | } | 1043 | } |
| 1010 | } | 1044 | } |
| 1011 | 1045 | ||
| 1012 | impl<'d, T: Instance> embedded_hal_02::blocking::serial::Write<u8> for UarteTx<'d, T> { | 1046 | impl<'d> embedded_hal_02::blocking::serial::Write<u8> for UarteTx<'d> { |
| 1013 | type Error = Error; | 1047 | type Error = Error; |
| 1014 | 1048 | ||
| 1015 | fn bwrite_all(&mut self, buffer: &[u8]) -> Result<(), Self::Error> { | 1049 | fn bwrite_all(&mut self, buffer: &[u8]) -> Result<(), Self::Error> { |
| @@ -1038,22 +1072,22 @@ mod _embedded_io { | |||
| 1038 | } | 1072 | } |
| 1039 | } | 1073 | } |
| 1040 | 1074 | ||
| 1041 | impl<'d, U: Instance> embedded_io_async::ErrorType for Uarte<'d, U> { | 1075 | impl<'d> embedded_io_async::ErrorType for Uarte<'d> { |
| 1042 | type Error = Error; | 1076 | type Error = Error; |
| 1043 | } | 1077 | } |
| 1044 | 1078 | ||
| 1045 | impl<'d, U: Instance> embedded_io_async::ErrorType for UarteTx<'d, U> { | 1079 | impl<'d> embedded_io_async::ErrorType for UarteTx<'d> { |
| 1046 | type Error = Error; | 1080 | type Error = Error; |
| 1047 | } | 1081 | } |
| 1048 | 1082 | ||
| 1049 | impl<'d, U: Instance> embedded_io_async::Write for Uarte<'d, U> { | 1083 | impl<'d> embedded_io_async::Write for Uarte<'d> { |
| 1050 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { | 1084 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { |
| 1051 | self.write(buf).await?; | 1085 | self.write(buf).await?; |
| 1052 | Ok(buf.len()) | 1086 | Ok(buf.len()) |
| 1053 | } | 1087 | } |
| 1054 | } | 1088 | } |
| 1055 | 1089 | ||
| 1056 | impl<'d: 'd, U: Instance> embedded_io_async::Write for UarteTx<'d, U> { | 1090 | impl<'d> embedded_io_async::Write for UarteTx<'d> { |
| 1057 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { | 1091 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { |
| 1058 | self.write(buf).await?; | 1092 | self.write(buf).await?; |
| 1059 | Ok(buf.len()) | 1093 | Ok(buf.len()) |
diff --git a/embassy-nrf/src/usb/mod.rs b/embassy-nrf/src/usb/mod.rs index c6970fc0f..07cf2578a 100644 --- a/embassy-nrf/src/usb/mod.rs +++ b/embassy-nrf/src/usb/mod.rs | |||
| @@ -4,10 +4,10 @@ | |||
| 4 | 4 | ||
| 5 | pub mod vbus_detect; | 5 | pub mod vbus_detect; |
| 6 | 6 | ||
| 7 | use core::future::{poll_fn, Future}; | 7 | use core::future::{Future, poll_fn}; |
| 8 | use core::marker::PhantomData; | 8 | use core::marker::PhantomData; |
| 9 | use core::mem::MaybeUninit; | 9 | use core::mem::MaybeUninit; |
| 10 | use core::sync::atomic::{compiler_fence, AtomicU32, Ordering}; | 10 | use core::sync::atomic::{AtomicU32, Ordering, compiler_fence}; |
| 11 | use core::task::Poll; | 11 | use core::task::Poll; |
| 12 | 12 | ||
| 13 | use cortex_m::peripheral::NVIC; | 13 | use cortex_m::peripheral::NVIC; |
| @@ -86,17 +86,18 @@ impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandl | |||
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | /// USB driver. | 88 | /// USB driver. |
| 89 | pub struct Driver<'d, T: Instance, V: VbusDetect> { | 89 | pub struct Driver<'d, V: VbusDetect> { |
| 90 | _p: Peri<'d, T>, | 90 | regs: pac::usbd::Usbd, |
| 91 | alloc_in: Allocator, | 91 | alloc_in: Allocator, |
| 92 | alloc_out: Allocator, | 92 | alloc_out: Allocator, |
| 93 | vbus_detect: V, | 93 | vbus_detect: V, |
| 94 | _phantom: PhantomData<&'d ()>, | ||
| 94 | } | 95 | } |
| 95 | 96 | ||
| 96 | impl<'d, T: Instance, V: VbusDetect> Driver<'d, T, V> { | 97 | impl<'d, V: VbusDetect> Driver<'d, V> { |
| 97 | /// Create a new USB driver. | 98 | /// Create a new USB driver. |
| 98 | pub fn new( | 99 | pub fn new<T: Instance>( |
| 99 | usb: Peri<'d, T>, | 100 | _usb: Peri<'d, T>, |
| 100 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, | 101 | _irq: impl interrupt::typelevel::Binding<T::Interrupt, InterruptHandler<T>> + 'd, |
| 101 | vbus_detect: V, | 102 | vbus_detect: V, |
| 102 | ) -> Self { | 103 | ) -> Self { |
| @@ -104,19 +105,20 @@ impl<'d, T: Instance, V: VbusDetect> Driver<'d, T, V> { | |||
| 104 | unsafe { T::Interrupt::enable() }; | 105 | unsafe { T::Interrupt::enable() }; |
| 105 | 106 | ||
| 106 | Self { | 107 | Self { |
| 107 | _p: usb, | 108 | regs: crate::pac::USBD, |
| 108 | alloc_in: Allocator::new(), | 109 | alloc_in: Allocator::new(), |
| 109 | alloc_out: Allocator::new(), | 110 | alloc_out: Allocator::new(), |
| 110 | vbus_detect, | 111 | vbus_detect, |
| 112 | _phantom: PhantomData, | ||
| 111 | } | 113 | } |
| 112 | } | 114 | } |
| 113 | } | 115 | } |
| 114 | 116 | ||
| 115 | impl<'d, T: Instance, V: VbusDetect + 'd> driver::Driver<'d> for Driver<'d, T, V> { | 117 | impl<'d, V: VbusDetect + 'd> driver::Driver<'d> for Driver<'d, V> { |
| 116 | type EndpointOut = Endpoint<'d, T, Out>; | 118 | type EndpointOut = Endpoint<'d, Out>; |
| 117 | type EndpointIn = Endpoint<'d, T, In>; | 119 | type EndpointIn = Endpoint<'d, In>; |
| 118 | type ControlPipe = ControlPipe<'d, T>; | 120 | type ControlPipe = ControlPipe<'d>; |
| 119 | type Bus = Bus<'d, T, V>; | 121 | type Bus = Bus<'d, V>; |
| 120 | 122 | ||
| 121 | fn alloc_endpoint_in( | 123 | fn alloc_endpoint_in( |
| 122 | &mut self, | 124 | &mut self, |
| @@ -127,12 +129,15 @@ impl<'d, T: Instance, V: VbusDetect + 'd> driver::Driver<'d> for Driver<'d, T, V | |||
| 127 | ) -> Result<Self::EndpointIn, driver::EndpointAllocError> { | 129 | ) -> Result<Self::EndpointIn, driver::EndpointAllocError> { |
| 128 | let index = self.alloc_in.allocate(ep_type, ep_addr)?; | 130 | let index = self.alloc_in.allocate(ep_type, ep_addr)?; |
| 129 | let ep_addr = EndpointAddress::from_parts(index, Direction::In); | 131 | let ep_addr = EndpointAddress::from_parts(index, Direction::In); |
| 130 | Ok(Endpoint::new(EndpointInfo { | 132 | Ok(Endpoint::new( |
| 131 | addr: ep_addr, | 133 | self.regs, |
| 132 | ep_type, | 134 | EndpointInfo { |
| 133 | max_packet_size: packet_size, | 135 | addr: ep_addr, |
| 134 | interval_ms, | 136 | ep_type, |
| 135 | })) | 137 | max_packet_size: packet_size, |
| 138 | interval_ms, | ||
| 139 | }, | ||
| 140 | )) | ||
| 136 | } | 141 | } |
| 137 | 142 | ||
| 138 | fn alloc_endpoint_out( | 143 | fn alloc_endpoint_out( |
| @@ -144,39 +149,45 @@ impl<'d, T: Instance, V: VbusDetect + 'd> driver::Driver<'d> for Driver<'d, T, V | |||
| 144 | ) -> Result<Self::EndpointOut, driver::EndpointAllocError> { | 149 | ) -> Result<Self::EndpointOut, driver::EndpointAllocError> { |
| 145 | let index = self.alloc_out.allocate(ep_type, ep_addr)?; | 150 | let index = self.alloc_out.allocate(ep_type, ep_addr)?; |
| 146 | let ep_addr = EndpointAddress::from_parts(index, Direction::Out); | 151 | let ep_addr = EndpointAddress::from_parts(index, Direction::Out); |
| 147 | Ok(Endpoint::new(EndpointInfo { | 152 | Ok(Endpoint::new( |
| 148 | addr: ep_addr, | 153 | self.regs, |
| 149 | ep_type, | 154 | EndpointInfo { |
| 150 | max_packet_size: packet_size, | 155 | addr: ep_addr, |
| 151 | interval_ms, | 156 | ep_type, |
| 152 | })) | 157 | max_packet_size: packet_size, |
| 158 | interval_ms, | ||
| 159 | }, | ||
| 160 | )) | ||
| 153 | } | 161 | } |
| 154 | 162 | ||
| 155 | fn start(self, control_max_packet_size: u16) -> (Self::Bus, Self::ControlPipe) { | 163 | fn start(self, control_max_packet_size: u16) -> (Self::Bus, Self::ControlPipe) { |
| 156 | ( | 164 | ( |
| 157 | Bus { | 165 | Bus { |
| 158 | _p: unsafe { self._p.clone_unchecked() }, | 166 | regs: self.regs, |
| 159 | power_available: false, | 167 | power_available: false, |
| 160 | vbus_detect: self.vbus_detect, | 168 | vbus_detect: self.vbus_detect, |
| 169 | _phantom: PhantomData, | ||
| 161 | }, | 170 | }, |
| 162 | ControlPipe { | 171 | ControlPipe { |
| 163 | _p: self._p, | 172 | regs: self.regs, |
| 164 | max_packet_size: control_max_packet_size, | 173 | max_packet_size: control_max_packet_size, |
| 174 | _phantom: PhantomData, | ||
| 165 | }, | 175 | }, |
| 166 | ) | 176 | ) |
| 167 | } | 177 | } |
| 168 | } | 178 | } |
| 169 | 179 | ||
| 170 | /// USB bus. | 180 | /// USB bus. |
| 171 | pub struct Bus<'d, T: Instance, V: VbusDetect> { | 181 | pub struct Bus<'d, V: VbusDetect> { |
| 172 | _p: Peri<'d, T>, | 182 | regs: pac::usbd::Usbd, |
| 173 | power_available: bool, | 183 | power_available: bool, |
| 174 | vbus_detect: V, | 184 | vbus_detect: V, |
| 185 | _phantom: PhantomData<&'d ()>, | ||
| 175 | } | 186 | } |
| 176 | 187 | ||
| 177 | impl<'d, T: Instance, V: VbusDetect> driver::Bus for Bus<'d, T, V> { | 188 | impl<'d, V: VbusDetect> driver::Bus for Bus<'d, V> { |
| 178 | async fn enable(&mut self) { | 189 | async fn enable(&mut self) { |
| 179 | let regs = T::regs(); | 190 | let regs = self.regs; |
| 180 | 191 | ||
| 181 | errata::pre_enable(); | 192 | errata::pre_enable(); |
| 182 | 193 | ||
| @@ -215,14 +226,14 @@ impl<'d, T: Instance, V: VbusDetect> driver::Bus for Bus<'d, T, V> { | |||
| 215 | } | 226 | } |
| 216 | 227 | ||
| 217 | async fn disable(&mut self) { | 228 | async fn disable(&mut self) { |
| 218 | let regs = T::regs(); | 229 | let regs = self.regs; |
| 219 | regs.enable().write(|x| x.set_enable(false)); | 230 | regs.enable().write(|x| x.set_enable(false)); |
| 220 | } | 231 | } |
| 221 | 232 | ||
| 222 | fn poll(&mut self) -> impl Future<Output = Event> { | 233 | fn poll(&mut self) -> impl Future<Output = Event> { |
| 223 | poll_fn(|cx| { | 234 | poll_fn(|cx| { |
| 224 | BUS_WAKER.register(cx.waker()); | 235 | BUS_WAKER.register(cx.waker()); |
| 225 | let regs = T::regs(); | 236 | let regs = self.regs; |
| 226 | 237 | ||
| 227 | if regs.events_usbreset().read() != 0 { | 238 | if regs.events_usbreset().read() != 0 { |
| 228 | regs.events_usbreset().write_value(0); | 239 | regs.events_usbreset().write_value(0); |
| @@ -280,7 +291,7 @@ impl<'d, T: Instance, V: VbusDetect> driver::Bus for Bus<'d, T, V> { | |||
| 280 | } | 291 | } |
| 281 | 292 | ||
| 282 | fn endpoint_set_stalled(&mut self, ep_addr: EndpointAddress, stalled: bool) { | 293 | fn endpoint_set_stalled(&mut self, ep_addr: EndpointAddress, stalled: bool) { |
| 283 | let regs = T::regs(); | 294 | let regs = self.regs; |
| 284 | if ep_addr.index() == 0 { | 295 | if ep_addr.index() == 0 { |
| 285 | if stalled { | 296 | if stalled { |
| 286 | regs.tasks_ep0stall().write_value(1); | 297 | regs.tasks_ep0stall().write_value(1); |
| @@ -298,7 +309,7 @@ impl<'d, T: Instance, V: VbusDetect> driver::Bus for Bus<'d, T, V> { | |||
| 298 | } | 309 | } |
| 299 | 310 | ||
| 300 | fn endpoint_is_stalled(&mut self, ep_addr: EndpointAddress) -> bool { | 311 | fn endpoint_is_stalled(&mut self, ep_addr: EndpointAddress) -> bool { |
| 301 | let regs = T::regs(); | 312 | let regs = self.regs; |
| 302 | let i = ep_addr.index(); | 313 | let i = ep_addr.index(); |
| 303 | match ep_addr.direction() { | 314 | match ep_addr.direction() { |
| 304 | Direction::Out => regs.halted().epout(i).read().getstatus() == vals::Getstatus::HALTED, | 315 | Direction::Out => regs.halted().epout(i).read().getstatus() == vals::Getstatus::HALTED, |
| @@ -307,7 +318,7 @@ impl<'d, T: Instance, V: VbusDetect> driver::Bus for Bus<'d, T, V> { | |||
| 307 | } | 318 | } |
| 308 | 319 | ||
| 309 | fn endpoint_set_enabled(&mut self, ep_addr: EndpointAddress, enabled: bool) { | 320 | fn endpoint_set_enabled(&mut self, ep_addr: EndpointAddress, enabled: bool) { |
| 310 | let regs = T::regs(); | 321 | let regs = self.regs; |
| 311 | 322 | ||
| 312 | let i = ep_addr.index(); | 323 | let i = ep_addr.index(); |
| 313 | let mask = 1 << i; | 324 | let mask = 1 << i; |
| @@ -319,11 +330,7 @@ impl<'d, T: Instance, V: VbusDetect> driver::Bus for Bus<'d, T, V> { | |||
| 319 | let mut was_enabled = false; | 330 | let mut was_enabled = false; |
| 320 | regs.epinen().modify(|w| { | 331 | regs.epinen().modify(|w| { |
| 321 | was_enabled = (w.0 & mask) != 0; | 332 | was_enabled = (w.0 & mask) != 0; |
| 322 | if enabled { | 333 | if enabled { w.0 |= mask } else { w.0 &= !mask } |
| 323 | w.0 |= mask | ||
| 324 | } else { | ||
| 325 | w.0 &= !mask | ||
| 326 | } | ||
| 327 | }); | 334 | }); |
| 328 | 335 | ||
| 329 | let ready_mask = In::mask(i); | 336 | let ready_mask = In::mask(i); |
| @@ -359,7 +366,7 @@ impl<'d, T: Instance, V: VbusDetect> driver::Bus for Bus<'d, T, V> { | |||
| 359 | 366 | ||
| 360 | #[inline] | 367 | #[inline] |
| 361 | async fn remote_wakeup(&mut self) -> Result<(), Unsupported> { | 368 | async fn remote_wakeup(&mut self) -> Result<(), Unsupported> { |
| 362 | let regs = T::regs(); | 369 | let regs = self.regs; |
| 363 | 370 | ||
| 364 | if regs.lowpower().read().lowpower() == vals::Lowpower::LOW_POWER { | 371 | if regs.lowpower().read().lowpower() == vals::Lowpower::LOW_POWER { |
| 365 | errata::pre_wakeup(); | 372 | errata::pre_wakeup(); |
| @@ -368,7 +375,7 @@ impl<'d, T: Instance, V: VbusDetect> driver::Bus for Bus<'d, T, V> { | |||
| 368 | 375 | ||
| 369 | poll_fn(|cx| { | 376 | poll_fn(|cx| { |
| 370 | BUS_WAKER.register(cx.waker()); | 377 | BUS_WAKER.register(cx.waker()); |
| 371 | let regs = T::regs(); | 378 | let regs = self.regs; |
| 372 | let r = regs.eventcause().read(); | 379 | let r = regs.eventcause().read(); |
| 373 | 380 | ||
| 374 | if regs.events_usbreset().read() != 0 { | 381 | if regs.events_usbreset().read() != 0 { |
| @@ -441,21 +448,23 @@ impl EndpointDir for Out { | |||
| 441 | } | 448 | } |
| 442 | 449 | ||
| 443 | /// USB endpoint. | 450 | /// USB endpoint. |
| 444 | pub struct Endpoint<'d, T: Instance, Dir> { | 451 | pub struct Endpoint<'d, Dir> { |
| 445 | _phantom: PhantomData<(&'d mut T, Dir)>, | 452 | regs: pac::usbd::Usbd, |
| 446 | info: EndpointInfo, | 453 | info: EndpointInfo, |
| 454 | _phantom: PhantomData<(&'d (), Dir)>, | ||
| 447 | } | 455 | } |
| 448 | 456 | ||
| 449 | impl<'d, T: Instance, Dir> Endpoint<'d, T, Dir> { | 457 | impl<'d, Dir> Endpoint<'d, Dir> { |
| 450 | fn new(info: EndpointInfo) -> Self { | 458 | fn new(regs: pac::usbd::Usbd, info: EndpointInfo) -> Self { |
| 451 | Self { | 459 | Self { |
| 460 | regs, | ||
| 452 | info, | 461 | info, |
| 453 | _phantom: PhantomData, | 462 | _phantom: PhantomData, |
| 454 | } | 463 | } |
| 455 | } | 464 | } |
| 456 | } | 465 | } |
| 457 | 466 | ||
| 458 | impl<'d, T: Instance, Dir: EndpointDir> driver::Endpoint for Endpoint<'d, T, Dir> { | 467 | impl<'d, Dir: EndpointDir> driver::Endpoint for Endpoint<'d, Dir> { |
| 459 | fn info(&self) -> &EndpointInfo { | 468 | fn info(&self) -> &EndpointInfo { |
| 460 | &self.info | 469 | &self.info |
| 461 | } | 470 | } |
| @@ -466,14 +475,14 @@ impl<'d, T: Instance, Dir: EndpointDir> driver::Endpoint for Endpoint<'d, T, Dir | |||
| 466 | } | 475 | } |
| 467 | 476 | ||
| 468 | #[allow(private_bounds)] | 477 | #[allow(private_bounds)] |
| 469 | impl<'d, T: Instance, Dir: EndpointDir> Endpoint<'d, T, Dir> { | 478 | impl<'d, Dir: EndpointDir> Endpoint<'d, Dir> { |
| 470 | fn wait_enabled_state(&mut self, state: bool) -> impl Future<Output = ()> { | 479 | fn wait_enabled_state(&mut self, state: bool) -> impl Future<Output = ()> + use<'_, 'd, Dir> { |
| 471 | let i = self.info.addr.index(); | 480 | let i = self.info.addr.index(); |
| 472 | assert!(i != 0); | 481 | assert!(i != 0); |
| 473 | 482 | ||
| 474 | poll_fn(move |cx| { | 483 | poll_fn(move |cx| { |
| 475 | Dir::waker(i).register(cx.waker()); | 484 | Dir::waker(i).register(cx.waker()); |
| 476 | if Dir::is_enabled(T::regs(), i) == state { | 485 | if Dir::is_enabled(self.regs, i) == state { |
| 477 | Poll::Ready(()) | 486 | Poll::Ready(()) |
| 478 | } else { | 487 | } else { |
| 479 | Poll::Pending | 488 | Poll::Pending |
| @@ -482,12 +491,12 @@ impl<'d, T: Instance, Dir: EndpointDir> Endpoint<'d, T, Dir> { | |||
| 482 | } | 491 | } |
| 483 | 492 | ||
| 484 | /// Wait for the endpoint to be disabled | 493 | /// Wait for the endpoint to be disabled |
| 485 | pub fn wait_disabled(&mut self) -> impl Future<Output = ()> { | 494 | pub fn wait_disabled(&mut self) -> impl Future<Output = ()> + use<'_, 'd, Dir> { |
| 486 | self.wait_enabled_state(false) | 495 | self.wait_enabled_state(false) |
| 487 | } | 496 | } |
| 488 | } | 497 | } |
| 489 | 498 | ||
| 490 | impl<'d, T: Instance, Dir> Endpoint<'d, T, Dir> { | 499 | impl<'d, Dir> Endpoint<'d, Dir> { |
| 491 | async fn wait_data_ready(&mut self) -> Result<(), ()> | 500 | async fn wait_data_ready(&mut self) -> Result<(), ()> |
| 492 | where | 501 | where |
| 493 | Dir: EndpointDir, | 502 | Dir: EndpointDir, |
| @@ -497,7 +506,7 @@ impl<'d, T: Instance, Dir> Endpoint<'d, T, Dir> { | |||
| 497 | poll_fn(|cx| { | 506 | poll_fn(|cx| { |
| 498 | Dir::waker(i).register(cx.waker()); | 507 | Dir::waker(i).register(cx.waker()); |
| 499 | let r = READY_ENDPOINTS.load(Ordering::Acquire); | 508 | let r = READY_ENDPOINTS.load(Ordering::Acquire); |
| 500 | if !Dir::is_enabled(T::regs(), i) { | 509 | if !Dir::is_enabled(self.regs, i) { |
| 501 | Poll::Ready(Err(())) | 510 | Poll::Ready(Err(())) |
| 502 | } else if r & Dir::mask(i) != 0 { | 511 | } else if r & Dir::mask(i) != 0 { |
| 503 | Poll::Ready(Ok(())) | 512 | Poll::Ready(Ok(())) |
| @@ -514,9 +523,7 @@ impl<'d, T: Instance, Dir> Endpoint<'d, T, Dir> { | |||
| 514 | } | 523 | } |
| 515 | } | 524 | } |
| 516 | 525 | ||
| 517 | unsafe fn read_dma<T: Instance>(i: usize, buf: &mut [u8]) -> Result<usize, EndpointError> { | 526 | unsafe fn read_dma(regs: pac::usbd::Usbd, i: usize, buf: &mut [u8]) -> Result<usize, EndpointError> { |
| 518 | let regs = T::regs(); | ||
| 519 | |||
| 520 | // Check that the packet fits into the buffer | 527 | // Check that the packet fits into the buffer |
| 521 | let size = regs.size().epout(i).read().0 as usize; | 528 | let size = regs.size().epout(i).read().0 as usize; |
| 522 | if size > buf.len() { | 529 | if size > buf.len() { |
| @@ -539,8 +546,7 @@ unsafe fn read_dma<T: Instance>(i: usize, buf: &mut [u8]) -> Result<usize, Endpo | |||
| 539 | Ok(size) | 546 | Ok(size) |
| 540 | } | 547 | } |
| 541 | 548 | ||
| 542 | unsafe fn write_dma<T: Instance>(i: usize, buf: &[u8]) { | 549 | unsafe fn write_dma(regs: pac::usbd::Usbd, i: usize, buf: &[u8]) { |
| 543 | let regs = T::regs(); | ||
| 544 | assert!(buf.len() <= 64); | 550 | assert!(buf.len() <= 64); |
| 545 | 551 | ||
| 546 | let mut ram_buf: MaybeUninit<[u8; 64]> = MaybeUninit::uninit(); | 552 | let mut ram_buf: MaybeUninit<[u8; 64]> = MaybeUninit::uninit(); |
| @@ -566,43 +572,44 @@ unsafe fn write_dma<T: Instance>(i: usize, buf: &[u8]) { | |||
| 566 | dma_end(); | 572 | dma_end(); |
| 567 | } | 573 | } |
| 568 | 574 | ||
| 569 | impl<'d, T: Instance> driver::EndpointOut for Endpoint<'d, T, Out> { | 575 | impl<'d> driver::EndpointOut for Endpoint<'d, Out> { |
| 570 | async fn read(&mut self, buf: &mut [u8]) -> Result<usize, EndpointError> { | 576 | async fn read(&mut self, buf: &mut [u8]) -> Result<usize, EndpointError> { |
| 571 | let i = self.info.addr.index(); | 577 | let i = self.info.addr.index(); |
| 572 | assert!(i != 0); | 578 | assert!(i != 0); |
| 573 | 579 | ||
| 574 | self.wait_data_ready().await.map_err(|_| EndpointError::Disabled)?; | 580 | self.wait_data_ready().await.map_err(|_| EndpointError::Disabled)?; |
| 575 | 581 | ||
| 576 | unsafe { read_dma::<T>(i, buf) } | 582 | unsafe { read_dma(self.regs, i, buf) } |
| 577 | } | 583 | } |
| 578 | } | 584 | } |
| 579 | 585 | ||
| 580 | impl<'d, T: Instance> driver::EndpointIn for Endpoint<'d, T, In> { | 586 | impl<'d> driver::EndpointIn for Endpoint<'d, In> { |
| 581 | async fn write(&mut self, buf: &[u8]) -> Result<(), EndpointError> { | 587 | async fn write(&mut self, buf: &[u8]) -> Result<(), EndpointError> { |
| 582 | let i = self.info.addr.index(); | 588 | let i = self.info.addr.index(); |
| 583 | assert!(i != 0); | 589 | assert!(i != 0); |
| 584 | 590 | ||
| 585 | self.wait_data_ready().await.map_err(|_| EndpointError::Disabled)?; | 591 | self.wait_data_ready().await.map_err(|_| EndpointError::Disabled)?; |
| 586 | 592 | ||
| 587 | unsafe { write_dma::<T>(i, buf) } | 593 | unsafe { write_dma(self.regs, i, buf) } |
| 588 | 594 | ||
| 589 | Ok(()) | 595 | Ok(()) |
| 590 | } | 596 | } |
| 591 | } | 597 | } |
| 592 | 598 | ||
| 593 | /// USB control pipe. | 599 | /// USB control pipe. |
| 594 | pub struct ControlPipe<'d, T: Instance> { | 600 | pub struct ControlPipe<'d> { |
| 595 | _p: Peri<'d, T>, | 601 | regs: pac::usbd::Usbd, |
| 596 | max_packet_size: u16, | 602 | max_packet_size: u16, |
| 603 | _phantom: PhantomData<&'d ()>, | ||
| 597 | } | 604 | } |
| 598 | 605 | ||
| 599 | impl<'d, T: Instance> driver::ControlPipe for ControlPipe<'d, T> { | 606 | impl<'d> driver::ControlPipe for ControlPipe<'d> { |
| 600 | fn max_packet_size(&self) -> usize { | 607 | fn max_packet_size(&self) -> usize { |
| 601 | usize::from(self.max_packet_size) | 608 | usize::from(self.max_packet_size) |
| 602 | } | 609 | } |
| 603 | 610 | ||
| 604 | async fn setup(&mut self) -> [u8; 8] { | 611 | async fn setup(&mut self) -> [u8; 8] { |
| 605 | let regs = T::regs(); | 612 | let regs = self.regs; |
| 606 | 613 | ||
| 607 | // Reset shorts | 614 | // Reset shorts |
| 608 | regs.shorts().write(|_| ()); | 615 | regs.shorts().write(|_| ()); |
| @@ -611,7 +618,7 @@ impl<'d, T: Instance> driver::ControlPipe for ControlPipe<'d, T> { | |||
| 611 | regs.intenset().write(|w| w.set_ep0setup(true)); | 618 | regs.intenset().write(|w| w.set_ep0setup(true)); |
| 612 | poll_fn(|cx| { | 619 | poll_fn(|cx| { |
| 613 | EP0_WAKER.register(cx.waker()); | 620 | EP0_WAKER.register(cx.waker()); |
| 614 | let regs = T::regs(); | 621 | let regs = self.regs; |
| 615 | if regs.events_ep0setup().read() != 0 { | 622 | if regs.events_ep0setup().read() != 0 { |
| 616 | Poll::Ready(()) | 623 | Poll::Ready(()) |
| 617 | } else { | 624 | } else { |
| @@ -636,7 +643,7 @@ impl<'d, T: Instance> driver::ControlPipe for ControlPipe<'d, T> { | |||
| 636 | } | 643 | } |
| 637 | 644 | ||
| 638 | async fn data_out(&mut self, buf: &mut [u8], _first: bool, _last: bool) -> Result<usize, EndpointError> { | 645 | async fn data_out(&mut self, buf: &mut [u8], _first: bool, _last: bool) -> Result<usize, EndpointError> { |
| 639 | let regs = T::regs(); | 646 | let regs = self.regs; |
| 640 | 647 | ||
| 641 | regs.events_ep0datadone().write_value(0); | 648 | regs.events_ep0datadone().write_value(0); |
| 642 | 649 | ||
| @@ -651,7 +658,7 @@ impl<'d, T: Instance> driver::ControlPipe for ControlPipe<'d, T> { | |||
| 651 | }); | 658 | }); |
| 652 | poll_fn(|cx| { | 659 | poll_fn(|cx| { |
| 653 | EP0_WAKER.register(cx.waker()); | 660 | EP0_WAKER.register(cx.waker()); |
| 654 | let regs = T::regs(); | 661 | let regs = self.regs; |
| 655 | if regs.events_ep0datadone().read() != 0 { | 662 | if regs.events_ep0datadone().read() != 0 { |
| 656 | Poll::Ready(Ok(())) | 663 | Poll::Ready(Ok(())) |
| 657 | } else if regs.events_usbreset().read() != 0 { | 664 | } else if regs.events_usbreset().read() != 0 { |
| @@ -666,17 +673,17 @@ impl<'d, T: Instance> driver::ControlPipe for ControlPipe<'d, T> { | |||
| 666 | }) | 673 | }) |
| 667 | .await?; | 674 | .await?; |
| 668 | 675 | ||
| 669 | unsafe { read_dma::<T>(0, buf) } | 676 | unsafe { read_dma(self.regs, 0, buf) } |
| 670 | } | 677 | } |
| 671 | 678 | ||
| 672 | async fn data_in(&mut self, buf: &[u8], _first: bool, last: bool) -> Result<(), EndpointError> { | 679 | async fn data_in(&mut self, buf: &[u8], _first: bool, last: bool) -> Result<(), EndpointError> { |
| 673 | let regs = T::regs(); | 680 | let regs = self.regs; |
| 674 | regs.events_ep0datadone().write_value(0); | 681 | regs.events_ep0datadone().write_value(0); |
| 675 | 682 | ||
| 676 | regs.shorts().write(|w| w.set_ep0datadone_ep0status(last)); | 683 | regs.shorts().write(|w| w.set_ep0datadone_ep0status(last)); |
| 677 | 684 | ||
| 678 | // This starts a TX on EP0. events_ep0datadone notifies when done. | 685 | // This starts a TX on EP0. events_ep0datadone notifies when done. |
| 679 | unsafe { write_dma::<T>(0, buf) } | 686 | unsafe { write_dma(self.regs, 0, buf) } |
| 680 | 687 | ||
| 681 | regs.intenset().write(|w| { | 688 | regs.intenset().write(|w| { |
| 682 | w.set_usbreset(true); | 689 | w.set_usbreset(true); |
| @@ -687,7 +694,7 @@ impl<'d, T: Instance> driver::ControlPipe for ControlPipe<'d, T> { | |||
| 687 | poll_fn(|cx| { | 694 | poll_fn(|cx| { |
| 688 | cx.waker().wake_by_ref(); | 695 | cx.waker().wake_by_ref(); |
| 689 | EP0_WAKER.register(cx.waker()); | 696 | EP0_WAKER.register(cx.waker()); |
| 690 | let regs = T::regs(); | 697 | let regs = self.regs; |
| 691 | if regs.events_ep0datadone().read() != 0 { | 698 | if regs.events_ep0datadone().read() != 0 { |
| 692 | Poll::Ready(Ok(())) | 699 | Poll::Ready(Ok(())) |
| 693 | } else if regs.events_usbreset().read() != 0 { | 700 | } else if regs.events_usbreset().read() != 0 { |
| @@ -704,12 +711,12 @@ impl<'d, T: Instance> driver::ControlPipe for ControlPipe<'d, T> { | |||
| 704 | } | 711 | } |
| 705 | 712 | ||
| 706 | async fn accept(&mut self) { | 713 | async fn accept(&mut self) { |
| 707 | let regs = T::regs(); | 714 | let regs = self.regs; |
| 708 | regs.tasks_ep0status().write_value(1); | 715 | regs.tasks_ep0status().write_value(1); |
| 709 | } | 716 | } |
| 710 | 717 | ||
| 711 | async fn reject(&mut self) { | 718 | async fn reject(&mut self) { |
| 712 | let regs = T::regs(); | 719 | let regs = self.regs; |
| 713 | regs.tasks_ep0stall().write_value(1); | 720 | regs.tasks_ep0stall().write_value(1); |
| 714 | } | 721 | } |
| 715 | 722 | ||
diff --git a/embassy-nrf/src/usb/vbus_detect.rs b/embassy-nrf/src/usb/vbus_detect.rs index 33cf91ee2..f24a7bff5 100644 --- a/embassy-nrf/src/usb/vbus_detect.rs +++ b/embassy-nrf/src/usb/vbus_detect.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | //! Trait and implementations for performing VBUS detection. | 1 | //! Trait and implementations for performing VBUS detection. |
| 2 | 2 | ||
| 3 | use core::future::{poll_fn, Future}; | 3 | use core::future::{Future, poll_fn}; |
| 4 | use core::sync::atomic::{AtomicBool, Ordering}; | 4 | use core::sync::atomic::{AtomicBool, Ordering}; |
| 5 | use core::task::Poll; | 5 | use core::task::Poll; |
| 6 | 6 | ||
diff --git a/embassy-nrf/src/util.rs b/embassy-nrf/src/util.rs index 78f71719f..87118d347 100644 --- a/embassy-nrf/src/util.rs +++ b/embassy-nrf/src/util.rs | |||
| @@ -15,9 +15,5 @@ pub(crate) fn slice_in_ram<T>(slice: *const [T]) -> bool { | |||
| 15 | 15 | ||
| 16 | /// Return an error if slice is not in RAM. Skips check if slice is zero-length. | 16 | /// Return an error if slice is not in RAM. Skips check if slice is zero-length. |
| 17 | pub(crate) fn slice_in_ram_or<T, E>(slice: *const [T], err: E) -> Result<(), E> { | 17 | pub(crate) fn slice_in_ram_or<T, E>(slice: *const [T], err: E) -> Result<(), E> { |
| 18 | if slice_in_ram(slice) { | 18 | if slice_in_ram(slice) { Ok(()) } else { Err(err) } |
| 19 | Ok(()) | ||
| 20 | } else { | ||
| 21 | Err(err) | ||
| 22 | } | ||
| 23 | } | 19 | } |
diff --git a/embassy-nrf/src/wdt.rs b/embassy-nrf/src/wdt.rs index 7ab9adc29..6afd73431 100644 --- a/embassy-nrf/src/wdt.rs +++ b/embassy-nrf/src/wdt.rs | |||
| @@ -11,7 +11,7 @@ use embassy_hal_internal::PeripheralType; | |||
| 11 | 11 | ||
| 12 | use crate::pac::wdt::vals; | 12 | use crate::pac::wdt::vals; |
| 13 | pub use crate::pac::wdt::vals::{Halt as HaltConfig, Sleep as SleepConfig}; | 13 | pub use crate::pac::wdt::vals::{Halt as HaltConfig, Sleep as SleepConfig}; |
| 14 | use crate::{interrupt, pac, peripherals, Peri}; | 14 | use crate::{Peri, interrupt, pac, peripherals}; |
| 15 | 15 | ||
| 16 | const MIN_TICKS: u32 = 15; | 16 | const MIN_TICKS: u32 = 15; |
| 17 | 17 | ||
| @@ -66,11 +66,11 @@ impl Default for Config { | |||
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | /// Watchdog driver. | 68 | /// Watchdog driver. |
| 69 | pub struct Watchdog<T: Instance> { | 69 | pub struct Watchdog { |
| 70 | _wdt: Peri<'static, T>, | 70 | r: pac::wdt::Wdt, |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | impl<T: Instance> Watchdog<T> { | 73 | impl Watchdog { |
| 74 | /// Try to create a new watchdog driver. | 74 | /// Try to create a new watchdog driver. |
| 75 | /// | 75 | /// |
| 76 | /// This function will return an error if the watchdog is already active | 76 | /// This function will return an error if the watchdog is already active |
| @@ -79,7 +79,7 @@ impl<T: Instance> Watchdog<T> { | |||
| 79 | /// | 79 | /// |
| 80 | /// `N` must be between 1 and 8, inclusive. | 80 | /// `N` must be between 1 and 8, inclusive. |
| 81 | #[inline] | 81 | #[inline] |
| 82 | pub fn try_new<const N: usize>( | 82 | pub fn try_new<T: Instance, const N: usize>( |
| 83 | wdt: Peri<'static, T>, | 83 | wdt: Peri<'static, T>, |
| 84 | config: Config, | 84 | config: Config, |
| 85 | ) -> Result<(Self, [WatchdogHandle; N]), Peri<'static, T>> { | 85 | ) -> Result<(Self, [WatchdogHandle; N]), Peri<'static, T>> { |
| @@ -116,7 +116,7 @@ impl<T: Instance> Watchdog<T> { | |||
| 116 | r.tasks_start().write_value(1); | 116 | r.tasks_start().write_value(1); |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | let this = Self { _wdt: wdt }; | 119 | let this = Self { r: T::REGS }; |
| 120 | 120 | ||
| 121 | let mut handles = [const { WatchdogHandle { index: 0 } }; N]; | 121 | let mut handles = [const { WatchdogHandle { index: 0 } }; N]; |
| 122 | for i in 0..N { | 122 | for i in 0..N { |
| @@ -135,7 +135,7 @@ impl<T: Instance> Watchdog<T> { | |||
| 135 | /// interrupt has been enabled. | 135 | /// interrupt has been enabled. |
| 136 | #[inline(always)] | 136 | #[inline(always)] |
| 137 | pub fn enable_interrupt(&mut self) { | 137 | pub fn enable_interrupt(&mut self) { |
| 138 | T::REGS.intenset().write(|w| w.set_timeout(true)); | 138 | self.r.intenset().write(|w| w.set_timeout(true)); |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | /// Disable the watchdog interrupt. | 141 | /// Disable the watchdog interrupt. |
| @@ -143,7 +143,7 @@ impl<T: Instance> Watchdog<T> { | |||
| 143 | /// NOTE: This has no effect on the reset caused by the Watchdog. | 143 | /// NOTE: This has no effect on the reset caused by the Watchdog. |
| 144 | #[inline(always)] | 144 | #[inline(always)] |
| 145 | pub fn disable_interrupt(&mut self) { | 145 | pub fn disable_interrupt(&mut self) { |
| 146 | T::REGS.intenclr().write(|w| w.set_timeout(true)); | 146 | self.r.intenclr().write(|w| w.set_timeout(true)); |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | /// Is the watchdog still awaiting pets from any handle? | 149 | /// Is the watchdog still awaiting pets from any handle? |
| @@ -152,9 +152,8 @@ impl<T: Instance> Watchdog<T> { | |||
| 152 | /// handles to prevent a reset this time period. | 152 | /// handles to prevent a reset this time period. |
| 153 | #[inline(always)] | 153 | #[inline(always)] |
| 154 | pub fn awaiting_pets(&self) -> bool { | 154 | pub fn awaiting_pets(&self) -> bool { |
| 155 | let r = T::REGS; | 155 | let enabled = self.r.rren().read().0; |
| 156 | let enabled = r.rren().read().0; | 156 | let status = self.r.reqstatus().read().0; |
| 157 | let status = r.reqstatus().read().0; | ||
| 158 | (status & enabled) == 0 | 157 | (status & enabled) == 0 |
| 159 | } | 158 | } |
| 160 | } | 159 | } |
diff --git a/embassy-nxp/Cargo.toml b/embassy-nxp/Cargo.toml index f3c828313..33f0f2dff 100644 --- a/embassy-nxp/Cargo.toml +++ b/embassy-nxp/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-nxp" | 2 | name = "embassy-nxp" |
| 3 | version = "0.1.0" | 3 | version = "0.1.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | publish = false | 7 | publish = false |
diff --git a/embassy-nxp/src/dma/lpc55.rs b/embassy-nxp/src/dma/lpc55.rs index 578d1fd88..5bd763f03 100644 --- a/embassy-nxp/src/dma/lpc55.rs +++ b/embassy-nxp/src/dma/lpc55.rs | |||
| @@ -1,16 +1,16 @@ | |||
| 1 | use core::cell::RefCell; | 1 | use core::cell::RefCell; |
| 2 | use core::future::Future; | 2 | use core::future::Future; |
| 3 | use core::pin::Pin; | 3 | use core::pin::Pin; |
| 4 | use core::sync::atomic::{compiler_fence, Ordering}; | 4 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 5 | use core::task::{Context, Poll}; | 5 | use core::task::{Context, Poll}; |
| 6 | 6 | ||
| 7 | use critical_section::Mutex; | 7 | use critical_section::Mutex; |
| 8 | use embassy_hal_internal::interrupt::InterruptExt; | 8 | use embassy_hal_internal::interrupt::InterruptExt; |
| 9 | use embassy_hal_internal::{impl_peripheral, PeripheralType}; | 9 | use embassy_hal_internal::{PeripheralType, impl_peripheral}; |
| 10 | use embassy_sync::waitqueue::AtomicWaker; | 10 | use embassy_sync::waitqueue::AtomicWaker; |
| 11 | 11 | ||
| 12 | use crate::pac::{DMA0, SYSCON, *}; | 12 | use crate::pac::{DMA0, SYSCON, *}; |
| 13 | use crate::{peripherals, Peri}; | 13 | use crate::{Peri, peripherals}; |
| 14 | 14 | ||
| 15 | #[interrupt] | 15 | #[interrupt] |
| 16 | fn DMA0() { | 16 | fn DMA0() { |
diff --git a/embassy-nxp/src/gpio/lpc55.rs b/embassy-nxp/src/gpio/lpc55.rs index 36ea99d21..ac8a27d4f 100644 --- a/embassy-nxp/src/gpio/lpc55.rs +++ b/embassy-nxp/src/gpio/lpc55.rs | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | use embassy_hal_internal::{impl_peripheral, PeripheralType}; | 1 | use embassy_hal_internal::{PeripheralType, impl_peripheral}; |
| 2 | 2 | ||
| 3 | use crate::pac::iocon::vals::{PioDigimode, PioMode}; | 3 | use crate::pac::iocon::vals::{PioDigimode, PioMode}; |
| 4 | use crate::pac::{GPIO, IOCON, SYSCON}; | 4 | use crate::pac::{GPIO, IOCON, SYSCON}; |
| 5 | use crate::{peripherals, Peri}; | 5 | use crate::{Peri, peripherals}; |
| 6 | 6 | ||
| 7 | pub(crate) fn init() { | 7 | pub(crate) fn init() { |
| 8 | // Enable clocks for GPIO, PINT, and IOCON | 8 | // Enable clocks for GPIO, PINT, and IOCON |
diff --git a/embassy-nxp/src/gpio/rt1xxx.rs b/embassy-nxp/src/gpio/rt1xxx.rs index 1d60a0d51..c4dc110ff 100644 --- a/embassy-nxp/src/gpio/rt1xxx.rs +++ b/embassy-nxp/src/gpio/rt1xxx.rs | |||
| @@ -5,13 +5,13 @@ use core::ops::Not; | |||
| 5 | use core::pin::Pin as FuturePin; | 5 | use core::pin::Pin as FuturePin; |
| 6 | use core::task::{Context, Poll}; | 6 | use core::task::{Context, Poll}; |
| 7 | 7 | ||
| 8 | use embassy_hal_internal::{impl_peripheral, Peri, PeripheralType}; | 8 | use embassy_hal_internal::{Peri, PeripheralType, impl_peripheral}; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 10 | use nxp_pac::gpio::vals::Icr; | 10 | use nxp_pac::gpio::vals::Icr; |
| 11 | use nxp_pac::iomuxc::vals::Pus; | 11 | use nxp_pac::iomuxc::vals::Pus; |
| 12 | 12 | ||
| 13 | use crate::chip::{mux_address, pad_address}; | 13 | use crate::chip::{mux_address, pad_address}; |
| 14 | use crate::pac::common::{Reg, RW}; | 14 | use crate::pac::common::{RW, Reg}; |
| 15 | use crate::pac::gpio::Gpio; | 15 | use crate::pac::gpio::Gpio; |
| 16 | #[cfg(feature = "rt")] | 16 | #[cfg(feature = "rt")] |
| 17 | use crate::pac::interrupt; | 17 | use crate::pac::interrupt; |
diff --git a/embassy-nxp/src/lib.rs b/embassy-nxp/src/lib.rs index f0f0afb6c..9576f02b1 100644 --- a/embassy-nxp/src/lib.rs +++ b/embassy-nxp/src/lib.rs | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 2 | 3 | ||
| 3 | // This mod MUST go first, so that the others see its macros. | 4 | // This mod MUST go first, so that the others see its macros. |
| 4 | pub(crate) mod fmt; | 5 | pub(crate) mod fmt; |
| @@ -29,7 +30,7 @@ pub use chip::interrupt; | |||
| 29 | pub use chip::pac; | 30 | pub use chip::pac; |
| 30 | #[cfg(not(feature = "unstable-pac"))] | 31 | #[cfg(not(feature = "unstable-pac"))] |
| 31 | pub(crate) use chip::pac; | 32 | pub(crate) use chip::pac; |
| 32 | pub use chip::{peripherals, Peripherals}; | 33 | pub use chip::{Peripherals, peripherals}; |
| 33 | pub use embassy_hal_internal::{Peri, PeripheralType}; | 34 | pub use embassy_hal_internal::{Peri, PeripheralType}; |
| 34 | 35 | ||
| 35 | /// Macro to bind interrupts to handlers. | 36 | /// Macro to bind interrupts to handlers. |
| @@ -67,7 +68,7 @@ macro_rules! bind_interrupts { | |||
| 67 | 68 | ||
| 68 | $( | 69 | $( |
| 69 | #[allow(non_snake_case)] | 70 | #[allow(non_snake_case)] |
| 70 | #[no_mangle] | 71 | #[unsafe(no_mangle)] |
| 71 | $(#[cfg($cond_irq)])? | 72 | $(#[cfg($cond_irq)])? |
| 72 | unsafe extern "C" fn $irq() { | 73 | unsafe extern "C" fn $irq() { |
| 73 | unsafe { | 74 | unsafe { |
diff --git a/embassy-nxp/src/pint.rs b/embassy-nxp/src/pint.rs index e594aaa6a..5b10b4540 100644 --- a/embassy-nxp/src/pint.rs +++ b/embassy-nxp/src/pint.rs | |||
| @@ -8,9 +8,9 @@ use critical_section::Mutex; | |||
| 8 | use embassy_hal_internal::interrupt::InterruptExt; | 8 | use embassy_hal_internal::interrupt::InterruptExt; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 10 | 10 | ||
| 11 | use crate::gpio::{self, AnyPin, Level, SealedPin}; | ||
| 12 | use crate::pac::{interrupt, INPUTMUX, PINT, SYSCON}; | ||
| 13 | use crate::Peri; | 11 | use crate::Peri; |
| 12 | use crate::gpio::{self, AnyPin, Level, SealedPin}; | ||
| 13 | use crate::pac::{INPUTMUX, PINT, SYSCON, interrupt}; | ||
| 14 | 14 | ||
| 15 | struct PinInterrupt { | 15 | struct PinInterrupt { |
| 16 | assigned: bool, | 16 | assigned: bool, |
diff --git a/embassy-nxp/src/time_driver/rtc.rs b/embassy-nxp/src/time_driver/rtc.rs index fb6de6a5e..0883fa2e8 100644 --- a/embassy-nxp/src/time_driver/rtc.rs +++ b/embassy-nxp/src/time_driver/rtc.rs | |||
| @@ -4,10 +4,10 @@ use core::task::Waker; | |||
| 4 | use critical_section::CriticalSection; | 4 | use critical_section::CriticalSection; |
| 5 | use embassy_hal_internal::interrupt::{InterruptExt, Priority}; | 5 | use embassy_hal_internal::interrupt::{InterruptExt, Priority}; |
| 6 | use embassy_sync::blocking_mutex::CriticalSectionMutex as Mutex; | 6 | use embassy_sync::blocking_mutex::CriticalSectionMutex as Mutex; |
| 7 | use embassy_time_driver::{time_driver_impl, Driver}; | 7 | use embassy_time_driver::{Driver, time_driver_impl}; |
| 8 | use embassy_time_queue_utils::Queue; | 8 | use embassy_time_queue_utils::Queue; |
| 9 | 9 | ||
| 10 | use crate::pac::{interrupt, pmc, rtc, PMC, RTC, SYSCON}; | 10 | use crate::pac::{PMC, RTC, SYSCON, interrupt, pmc, rtc}; |
| 11 | 11 | ||
| 12 | struct AlarmState { | 12 | struct AlarmState { |
| 13 | timestamp: Cell<u64>, | 13 | timestamp: Cell<u64>, |
diff --git a/embassy-nxp/src/usart/lpc55.rs b/embassy-nxp/src/usart/lpc55.rs index 9034ed429..0be5a8ce7 100644 --- a/embassy-nxp/src/usart/lpc55.rs +++ b/embassy-nxp/src/usart/lpc55.rs | |||
| @@ -4,16 +4,16 @@ use core::marker::PhantomData; | |||
| 4 | use core::sync::atomic::{AtomicBool, Ordering}; | 4 | use core::sync::atomic::{AtomicBool, Ordering}; |
| 5 | use core::task::Poll; | 5 | use core::task::Poll; |
| 6 | 6 | ||
| 7 | use embassy_futures::select::{select, Either}; | 7 | use embassy_futures::select::{Either, select}; |
| 8 | use embassy_hal_internal::interrupt::InterruptExt; | 8 | use embassy_hal_internal::interrupt::InterruptExt; |
| 9 | use embassy_hal_internal::{Peri, PeripheralType}; | 9 | use embassy_hal_internal::{Peri, PeripheralType}; |
| 10 | use embassy_sync::waitqueue::AtomicWaker; | 10 | use embassy_sync::waitqueue::AtomicWaker; |
| 11 | use embedded_io::{self, ErrorKind}; | 11 | use embedded_io::{self, ErrorKind}; |
| 12 | 12 | ||
| 13 | use crate::dma::{AnyChannel, Channel}; | 13 | use crate::dma::{AnyChannel, Channel}; |
| 14 | use crate::gpio::{match_iocon, AnyPin, Bank, SealedPin}; | 14 | use crate::gpio::{AnyPin, Bank, SealedPin, match_iocon}; |
| 15 | use crate::interrupt::typelevel::{Binding, Interrupt as _}; | ||
| 16 | use crate::interrupt::Interrupt; | 15 | use crate::interrupt::Interrupt; |
| 16 | use crate::interrupt::typelevel::{Binding, Interrupt as _}; | ||
| 17 | use crate::pac::flexcomm::Flexcomm as FlexcommReg; | 17 | use crate::pac::flexcomm::Flexcomm as FlexcommReg; |
| 18 | use crate::pac::iocon::vals::PioFunc; | 18 | use crate::pac::iocon::vals::PioFunc; |
| 19 | use crate::pac::usart::Usart as UsartReg; | 19 | use crate::pac::usart::Usart as UsartReg; |
diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index f6b0900f2..9ad4b47a3 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-rp" | 2 | name = "embassy-rp" |
| 3 | version = "0.8.0" | 3 | version = "0.8.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | description = "Embassy Hardware Abstraction Layer (HAL) for the Raspberry Pi RP2040 or RP235x microcontroller" | 6 | description = "Embassy Hardware Abstraction Layer (HAL) for the Raspberry Pi RP2040 or RP235x microcontroller" |
| 7 | keywords = ["embedded", "async", "rp235x", "rp2040", "embedded-hal"] | 7 | keywords = ["embedded", "async", "rp235x", "rp2040", "embedded-hal"] |
| @@ -104,7 +104,7 @@ boot2-w25x10cl = [] | |||
| 104 | ## Have embassy-rp not provide the boot2 so you can use your own. | 104 | ## Have embassy-rp not provide the boot2 so you can use your own. |
| 105 | ## Place your own in the ".boot2" section like: | 105 | ## Place your own in the ".boot2" section like: |
| 106 | ## ``` | 106 | ## ``` |
| 107 | ## #[link_section = ".boot2"] | 107 | ## #[unsafe(link_section = ".boot2")] |
| 108 | ## #[used] | 108 | ## #[used] |
| 109 | ## static BOOT2: [u8; 256] = [0; 256]; // Provide your own with e.g. include_bytes! | 109 | ## static BOOT2: [u8; 256] = [0; 256]; // Provide your own with e.g. include_bytes! |
| 110 | ## ``` | 110 | ## ``` |
| @@ -127,7 +127,7 @@ imagedef-nonsecure-exe = [] | |||
| 127 | ## ```ignore | 127 | ## ```ignore |
| 128 | ## use embassy_rp::block::ImageDef; | 128 | ## use embassy_rp::block::ImageDef; |
| 129 | ## | 129 | ## |
| 130 | ## #[link_section = ".start_block"] | 130 | ## #[unsafe(link_section = ".start_block")] |
| 131 | ## #[used] | 131 | ## #[used] |
| 132 | ## static IMAGE_DEF: ImageDef = ImageDef::secure_exe(); // Update this with your own implementation. | 132 | ## static IMAGE_DEF: ImageDef = ImageDef::secure_exe(); // Update this with your own implementation. |
| 133 | ## ``` | 133 | ## ``` |
diff --git a/embassy-rp/src/adc.rs b/embassy-rp/src/adc.rs index 2db8e63d7..d16779e01 100644 --- a/embassy-rp/src/adc.rs +++ b/embassy-rp/src/adc.rs | |||
| @@ -1,18 +1,18 @@ | |||
| 1 | //! ADC driver. | 1 | //! ADC driver. |
| 2 | use core::future::{poll_fn, Future}; | 2 | use core::future::{Future, poll_fn}; |
| 3 | use core::marker::PhantomData; | 3 | use core::marker::PhantomData; |
| 4 | use core::mem; | 4 | use core::mem; |
| 5 | use core::sync::atomic::{compiler_fence, Ordering}; | 5 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 6 | use core::task::Poll; | 6 | use core::task::Poll; |
| 7 | 7 | ||
| 8 | use embassy_sync::waitqueue::AtomicWaker; | 8 | use embassy_sync::waitqueue::AtomicWaker; |
| 9 | 9 | ||
| 10 | use crate::gpio::{self, AnyPin, Pull, SealedPin as GpioPin}; | 10 | use crate::gpio::{self, AnyPin, Pull, SealedPin as GpioPin}; |
| 11 | use crate::interrupt::typelevel::Binding; | ||
| 12 | use crate::interrupt::InterruptExt; | 11 | use crate::interrupt::InterruptExt; |
| 12 | use crate::interrupt::typelevel::Binding; | ||
| 13 | use crate::pac::dma::vals::TreqSel; | 13 | use crate::pac::dma::vals::TreqSel; |
| 14 | use crate::peripherals::{ADC, ADC_TEMP_SENSOR}; | 14 | use crate::peripherals::{ADC, ADC_TEMP_SENSOR}; |
| 15 | use crate::{dma, interrupt, pac, peripherals, Peri, RegExt}; | 15 | use crate::{Peri, RegExt, dma, interrupt, pac, peripherals}; |
| 16 | 16 | ||
| 17 | static WAKER: AtomicWaker = AtomicWaker::new(); | 17 | static WAKER: AtomicWaker = AtomicWaker::new(); |
| 18 | 18 | ||
diff --git a/embassy-rp/src/bootsel.rs b/embassy-rp/src/bootsel.rs index 14f9e46aa..b24b98cd5 100644 --- a/embassy-rp/src/bootsel.rs +++ b/embassy-rp/src/bootsel.rs | |||
| @@ -7,8 +7,8 @@ | |||
| 7 | //! | 7 | //! |
| 8 | //! This module provides functionality to poll BOOTSEL from an embassy application. | 8 | //! This module provides functionality to poll BOOTSEL from an embassy application. |
| 9 | 9 | ||
| 10 | use crate::flash::in_ram; | ||
| 11 | use crate::Peri; | 10 | use crate::Peri; |
| 11 | use crate::flash::in_ram; | ||
| 12 | 12 | ||
| 13 | /// Reads the BOOTSEL button. Returns true if the button is pressed. | 13 | /// Reads the BOOTSEL button. Returns true if the button is pressed. |
| 14 | /// | 14 | /// |
| @@ -36,7 +36,7 @@ mod ram_helpers { | |||
| 36 | /// This function must live in ram. It uses inline asm to avoid any | 36 | /// This function must live in ram. It uses inline asm to avoid any |
| 37 | /// potential calls to ABI functions that might be in flash. | 37 | /// potential calls to ABI functions that might be in flash. |
| 38 | #[inline(never)] | 38 | #[inline(never)] |
| 39 | #[link_section = ".data.ram_func"] | 39 | #[unsafe(link_section = ".data.ram_func")] |
| 40 | #[cfg(target_arch = "arm")] | 40 | #[cfg(target_arch = "arm")] |
| 41 | pub unsafe fn read_cs_status() -> GpioStatus { | 41 | pub unsafe fn read_cs_status() -> GpioStatus { |
| 42 | let result: u32; | 42 | let result: u32; |
diff --git a/embassy-rp/src/clocks.rs b/embassy-rp/src/clocks.rs index 2eddc0bcc..56892d7a2 100644 --- a/embassy-rp/src/clocks.rs +++ b/embassy-rp/src/clocks.rs | |||
| @@ -72,8 +72,8 @@ use core::sync::atomic::{AtomicU32, Ordering}; | |||
| 72 | use pac::clocks::vals::*; | 72 | use pac::clocks::vals::*; |
| 73 | 73 | ||
| 74 | use crate::gpio::{AnyPin, SealedPin}; | 74 | use crate::gpio::{AnyPin, SealedPin}; |
| 75 | use crate::pac::common::{Reg, RW}; | 75 | use crate::pac::common::{RW, Reg}; |
| 76 | use crate::{pac, reset, Peri}; | 76 | use crate::{Peri, pac, reset}; |
| 77 | 77 | ||
| 78 | // NOTE: all gpin handling is commented out for future reference. | 78 | // NOTE: all gpin handling is commented out for future reference. |
| 79 | // gpin is not usually safe to use during the boot init() call, so it won't | 79 | // gpin is not usually safe to use during the boot init() call, so it won't |
diff --git a/embassy-rp/src/dma.rs b/embassy-rp/src/dma.rs index d31d1e159..18aec60a5 100644 --- a/embassy-rp/src/dma.rs +++ b/embassy-rp/src/dma.rs | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | //! Direct Memory Access (DMA) | 1 | //! Direct Memory Access (DMA) |
| 2 | use core::future::Future; | 2 | use core::future::Future; |
| 3 | use core::pin::Pin; | 3 | use core::pin::Pin; |
| 4 | use core::sync::atomic::{compiler_fence, Ordering}; | 4 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 5 | use core::task::{Context, Poll}; | 5 | use core::task::{Context, Poll}; |
| 6 | 6 | ||
| 7 | use embassy_hal_internal::{impl_peripheral, Peri, PeripheralType}; | 7 | use embassy_hal_internal::{Peri, PeripheralType, impl_peripheral}; |
| 8 | use embassy_sync::waitqueue::AtomicWaker; | 8 | use embassy_sync::waitqueue::AtomicWaker; |
| 9 | use pac::dma::vals::DataSize; | 9 | use pac::dma::vals::DataSize; |
| 10 | 10 | ||
diff --git a/embassy-rp/src/flash.rs b/embassy-rp/src/flash.rs index 8c809090e..7cc8f0c1d 100644 --- a/embassy-rp/src/flash.rs +++ b/embassy-rp/src/flash.rs | |||
| @@ -6,8 +6,8 @@ use core::task::{Context, Poll}; | |||
| 6 | 6 | ||
| 7 | use embassy_hal_internal::{Peri, PeripheralType}; | 7 | use embassy_hal_internal::{Peri, PeripheralType}; |
| 8 | use embedded_storage::nor_flash::{ | 8 | use embedded_storage::nor_flash::{ |
| 9 | check_erase, check_read, check_write, ErrorType, MultiwriteNorFlash, NorFlash, NorFlashError, NorFlashErrorKind, | 9 | ErrorType, MultiwriteNorFlash, NorFlash, NorFlashError, NorFlashErrorKind, ReadNorFlash, check_erase, check_read, |
| 10 | ReadNorFlash, | 10 | check_write, |
| 11 | }; | 11 | }; |
| 12 | 12 | ||
| 13 | use crate::dma::{AnyChannel, Channel, Transfer}; | 13 | use crate::dma::{AnyChannel, Channel, Transfer}; |
| @@ -627,7 +627,7 @@ mod ram_helpers { | |||
| 627 | /// Length of data must be a multiple of 4096 | 627 | /// Length of data must be a multiple of 4096 |
| 628 | /// addr must be aligned to 4096 | 628 | /// addr must be aligned to 4096 |
| 629 | #[inline(never)] | 629 | #[inline(never)] |
| 630 | #[link_section = ".data.ram_func"] | 630 | #[unsafe(link_section = ".data.ram_func")] |
| 631 | #[cfg(feature = "rp2040")] | 631 | #[cfg(feature = "rp2040")] |
| 632 | unsafe fn write_flash_inner(addr: u32, len: u32, data: Option<&[u8]>, ptrs: *const FlashFunctionPointers) { | 632 | unsafe fn write_flash_inner(addr: u32, len: u32, data: Option<&[u8]>, ptrs: *const FlashFunctionPointers) { |
| 633 | #[cfg(target_arch = "arm")] | 633 | #[cfg(target_arch = "arm")] |
| @@ -692,7 +692,7 @@ mod ram_helpers { | |||
| 692 | /// Length of data must be a multiple of 4096 | 692 | /// Length of data must be a multiple of 4096 |
| 693 | /// addr must be aligned to 4096 | 693 | /// addr must be aligned to 4096 |
| 694 | #[inline(never)] | 694 | #[inline(never)] |
| 695 | #[link_section = ".data.ram_func"] | 695 | #[unsafe(link_section = ".data.ram_func")] |
| 696 | #[cfg(feature = "_rp235x")] | 696 | #[cfg(feature = "_rp235x")] |
| 697 | unsafe fn write_flash_inner(addr: u32, len: u32, data: Option<&[u8]>, ptrs: *const FlashFunctionPointers) { | 697 | unsafe fn write_flash_inner(addr: u32, len: u32, data: Option<&[u8]>, ptrs: *const FlashFunctionPointers) { |
| 698 | let data = data.map(|d| d.as_ptr()).unwrap_or(core::ptr::null()); | 698 | let data = data.map(|d| d.as_ptr()).unwrap_or(core::ptr::null()); |
| @@ -811,7 +811,7 @@ mod ram_helpers { | |||
| 811 | /// | 811 | /// |
| 812 | /// Credit: taken from `rp2040-flash` (also licensed Apache+MIT) | 812 | /// Credit: taken from `rp2040-flash` (also licensed Apache+MIT) |
| 813 | #[inline(never)] | 813 | #[inline(never)] |
| 814 | #[link_section = ".data.ram_func"] | 814 | #[unsafe(link_section = ".data.ram_func")] |
| 815 | #[cfg(feature = "rp2040")] | 815 | #[cfg(feature = "rp2040")] |
| 816 | unsafe fn read_flash_inner(cmd: FlashCommand, ptrs: *const FlashFunctionPointers) { | 816 | unsafe fn read_flash_inner(cmd: FlashCommand, ptrs: *const FlashFunctionPointers) { |
| 817 | #[cfg(target_arch = "arm")] | 817 | #[cfg(target_arch = "arm")] |
diff --git a/embassy-rp/src/float/cmp.rs b/embassy-rp/src/float/cmp.rs index e540e3918..f917eb9b3 100644 --- a/embassy-rp/src/float/cmp.rs +++ b/embassy-rp/src/float/cmp.rs | |||
| @@ -21,19 +21,11 @@ impl ROMCmp for f64 { | |||
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | fn le_abi<F: Float + ROMCmp>(a: F, b: F) -> i32 { | 23 | fn le_abi<F: Float + ROMCmp>(a: F, b: F) -> i32 { |
| 24 | if a.is_nan() || b.is_nan() { | 24 | if a.is_nan() || b.is_nan() { 1 } else { a.rom_cmp(b) } |
| 25 | 1 | ||
| 26 | } else { | ||
| 27 | a.rom_cmp(b) | ||
| 28 | } | ||
| 29 | } | 25 | } |
| 30 | 26 | ||
| 31 | fn ge_abi<F: Float + ROMCmp>(a: F, b: F) -> i32 { | 27 | fn ge_abi<F: Float + ROMCmp>(a: F, b: F) -> i32 { |
| 32 | if a.is_nan() || b.is_nan() { | 28 | if a.is_nan() || b.is_nan() { -1 } else { a.rom_cmp(b) } |
| 33 | -1 | ||
| 34 | } else { | ||
| 35 | a.rom_cmp(b) | ||
| 36 | } | ||
| 37 | } | 29 | } |
| 38 | 30 | ||
| 39 | intrinsics! { | 31 | intrinsics! { |
diff --git a/embassy-rp/src/float/functions.rs b/embassy-rp/src/float/functions.rs index de29ce336..170168237 100644 --- a/embassy-rp/src/float/functions.rs +++ b/embassy-rp/src/float/functions.rs | |||
| @@ -114,19 +114,11 @@ fn sqrt<F: Float + ROMFunctions>(f: F) -> F { | |||
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | fn ln<F: Float + ROMFunctions>(f: F) -> F { | 116 | fn ln<F: Float + ROMFunctions>(f: F) -> F { |
| 117 | if is_negative_nonzero_or_nan(f) { | 117 | if is_negative_nonzero_or_nan(f) { F::NAN } else { f.ln() } |
| 118 | F::NAN | ||
| 119 | } else { | ||
| 120 | f.ln() | ||
| 121 | } | ||
| 122 | } | 118 | } |
| 123 | 119 | ||
| 124 | fn exp<F: Float + ROMFunctions>(f: F) -> F { | 120 | fn exp<F: Float + ROMFunctions>(f: F) -> F { |
| 125 | if f.is_nan() { | 121 | if f.is_nan() { F::NAN } else { f.exp() } |
| 126 | F::NAN | ||
| 127 | } else { | ||
| 128 | f.exp() | ||
| 129 | } | ||
| 130 | } | 122 | } |
| 131 | 123 | ||
| 132 | fn sin<F: Float + ROMFunctions>(f: F) -> F { | 124 | fn sin<F: Float + ROMFunctions>(f: F) -> F { |
diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs index f79bf8948..c15e0e41b 100644 --- a/embassy-rp/src/gpio.rs +++ b/embassy-rp/src/gpio.rs | |||
| @@ -5,13 +5,13 @@ use core::future::Future; | |||
| 5 | use core::pin::Pin as FuturePin; | 5 | use core::pin::Pin as FuturePin; |
| 6 | use core::task::{Context, Poll}; | 6 | use core::task::{Context, Poll}; |
| 7 | 7 | ||
| 8 | use embassy_hal_internal::{impl_peripheral, Peri, PeripheralType}; | 8 | use embassy_hal_internal::{Peri, PeripheralType, impl_peripheral}; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 10 | 10 | ||
| 11 | use crate::interrupt::InterruptExt; | 11 | use crate::interrupt::InterruptExt; |
| 12 | use crate::pac::common::{Reg, RW}; | ||
| 13 | use crate::pac::SIO; | 12 | use crate::pac::SIO; |
| 14 | use crate::{interrupt, pac, peripherals, RegExt}; | 13 | use crate::pac::common::{RW, Reg}; |
| 14 | use crate::{RegExt, interrupt, pac, peripherals}; | ||
| 15 | 15 | ||
| 16 | #[cfg(any(feature = "rp2040", feature = "rp235xa"))] | 16 | #[cfg(any(feature = "rp2040", feature = "rp235xa"))] |
| 17 | pub(crate) const BANK0_PIN_COUNT: usize = 30; | 17 | pub(crate) const BANK0_PIN_COUNT: usize = 30; |
diff --git a/embassy-rp/src/i2c_slave.rs b/embassy-rp/src/i2c_slave.rs index c263047ad..770087bc8 100644 --- a/embassy-rp/src/i2c_slave.rs +++ b/embassy-rp/src/i2c_slave.rs | |||
| @@ -5,9 +5,9 @@ use core::task::Poll; | |||
| 5 | 5 | ||
| 6 | use pac::i2c; | 6 | use pac::i2c; |
| 7 | 7 | ||
| 8 | use crate::i2c::{set_up_i2c_pin, AbortReason, Instance, InterruptHandler, SclPin, SdaPin, FIFO_SIZE}; | 8 | use crate::i2c::{AbortReason, FIFO_SIZE, Instance, InterruptHandler, SclPin, SdaPin, set_up_i2c_pin}; |
| 9 | use crate::interrupt::typelevel::{Binding, Interrupt}; | 9 | use crate::interrupt::typelevel::{Binding, Interrupt}; |
| 10 | use crate::{pac, Peri}; | 10 | use crate::{Peri, pac}; |
| 11 | 11 | ||
| 12 | /// I2C error | 12 | /// I2C error |
| 13 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 13 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
diff --git a/embassy-rp/src/intrinsics.rs b/embassy-rp/src/intrinsics.rs index 69d5d92de..aed8a3227 100644 --- a/embassy-rp/src/intrinsics.rs +++ b/embassy-rp/src/intrinsics.rs | |||
| @@ -223,7 +223,7 @@ macro_rules! intrinsics { | |||
| 223 | 223 | ||
| 224 | #[cfg(all(target_arch = "arm", feature = "intrinsics"))] | 224 | #[cfg(all(target_arch = "arm", feature = "intrinsics"))] |
| 225 | mod $name { | 225 | mod $name { |
| 226 | #[no_mangle] | 226 | #[unsafe(no_mangle)] |
| 227 | $(#[$($attr)*])* | 227 | $(#[$($attr)*])* |
| 228 | pub extern $abi fn $name( $($argname: $ty),* ) -> $ret { | 228 | pub extern $abi fn $name( $($argname: $ty),* ) -> $ret { |
| 229 | super::$name($($argname),*) | 229 | super::$name($($argname),*) |
| @@ -257,7 +257,7 @@ macro_rules! intrinsics { | |||
| 257 | 257 | ||
| 258 | #[cfg(all(target_arch = "arm", feature = "intrinsics"))] | 258 | #[cfg(all(target_arch = "arm", feature = "intrinsics"))] |
| 259 | mod $name { | 259 | mod $name { |
| 260 | #[no_mangle] | 260 | #[unsafe(no_mangle)] |
| 261 | $(#[$($attr)*])* | 261 | $(#[$($attr)*])* |
| 262 | pub unsafe extern $abi fn $name( $($argname: $ty),* ) -> $ret { | 262 | pub unsafe extern $abi fn $name( $($argname: $ty),* ) -> $ret { |
| 263 | super::$name($($argname),*) | 263 | super::$name($($argname),*) |
| @@ -392,7 +392,7 @@ macro_rules! division_function { | |||
| 392 | ); | 392 | ); |
| 393 | 393 | ||
| 394 | #[cfg(target_arch = "arm")] | 394 | #[cfg(target_arch = "arm")] |
| 395 | extern "aapcs" { | 395 | unsafe extern "aapcs" { |
| 396 | // Connect a local name to global symbol above through FFI. | 396 | // Connect a local name to global symbol above through FFI. |
| 397 | #[link_name = concat!("_erphal_", stringify!($name)) ] | 397 | #[link_name = concat!("_erphal_", stringify!($name)) ] |
| 398 | fn $name(n: $argty, d: $argty) -> u64; | 398 | fn $name(n: $argty, d: $argty) -> u64; |
diff --git a/embassy-rp/src/lib.rs b/embassy-rp/src/lib.rs index d03ba1fef..4cb1a0912 100644 --- a/embassy-rp/src/lib.rs +++ b/embassy-rp/src/lib.rs | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![allow(async_fn_in_trait)] | 2 | #![allow(async_fn_in_trait)] |
| 3 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 4 | #![allow(unused_unsafe)] | ||
| 3 | #![doc = include_str!("../README.md")] | 5 | #![doc = include_str!("../README.md")] |
| 4 | #![warn(missing_docs)] | 6 | #![warn(missing_docs)] |
| 5 | 7 | ||
| @@ -190,7 +192,7 @@ macro_rules! bind_interrupts { | |||
| 190 | 192 | ||
| 191 | $( | 193 | $( |
| 192 | #[allow(non_snake_case)] | 194 | #[allow(non_snake_case)] |
| 193 | #[no_mangle] | 195 | #[unsafe(no_mangle)] |
| 194 | $(#[cfg($cond_irq)])? | 196 | $(#[cfg($cond_irq)])? |
| 195 | unsafe extern "C" fn $irq() { | 197 | unsafe extern "C" fn $irq() { |
| 196 | unsafe { | 198 | unsafe { |
| @@ -446,13 +448,13 @@ macro_rules! select_bootloader { | |||
| 446 | ( $( $feature:literal => $loader:ident, )+ default => $default:ident ) => { | 448 | ( $( $feature:literal => $loader:ident, )+ default => $default:ident ) => { |
| 447 | $( | 449 | $( |
| 448 | #[cfg(feature = $feature)] | 450 | #[cfg(feature = $feature)] |
| 449 | #[link_section = ".boot2"] | 451 | #[unsafe(link_section = ".boot2")] |
| 450 | #[used] | 452 | #[used] |
| 451 | static BOOT2: [u8; 256] = rp2040_boot2::$loader; | 453 | static BOOT2: [u8; 256] = rp2040_boot2::$loader; |
| 452 | )* | 454 | )* |
| 453 | 455 | ||
| 454 | #[cfg(not(any( $( feature = $feature),* )))] | 456 | #[cfg(not(any( $( feature = $feature),* )))] |
| 455 | #[link_section = ".boot2"] | 457 | #[unsafe(link_section = ".boot2")] |
| 456 | #[used] | 458 | #[used] |
| 457 | static BOOT2: [u8; 256] = rp2040_boot2::$default; | 459 | static BOOT2: [u8; 256] = rp2040_boot2::$default; |
| 458 | } | 460 | } |
| @@ -475,13 +477,13 @@ macro_rules! select_imagedef { | |||
| 475 | ( $( $feature:literal => $imagedef:ident, )+ default => $default:ident ) => { | 477 | ( $( $feature:literal => $imagedef:ident, )+ default => $default:ident ) => { |
| 476 | $( | 478 | $( |
| 477 | #[cfg(feature = $feature)] | 479 | #[cfg(feature = $feature)] |
| 478 | #[link_section = ".start_block"] | 480 | #[unsafe(link_section = ".start_block")] |
| 479 | #[used] | 481 | #[used] |
| 480 | static IMAGE_DEF: crate::block::ImageDef = crate::block::ImageDef::$imagedef(); | 482 | static IMAGE_DEF: crate::block::ImageDef = crate::block::ImageDef::$imagedef(); |
| 481 | )* | 483 | )* |
| 482 | 484 | ||
| 483 | #[cfg(not(any( $( feature = $feature),* )))] | 485 | #[cfg(not(any( $( feature = $feature),* )))] |
| 484 | #[link_section = ".start_block"] | 486 | #[unsafe(link_section = ".start_block")] |
| 485 | #[used] | 487 | #[used] |
| 486 | static IMAGE_DEF: crate::block::ImageDef = crate::block::ImageDef::$default(); | 488 | static IMAGE_DEF: crate::block::ImageDef = crate::block::ImageDef::$default(); |
| 487 | } | 489 | } |
| @@ -528,7 +530,7 @@ select_imagedef! { | |||
| 528 | /// } | 530 | /// } |
| 529 | /// ``` | 531 | /// ``` |
| 530 | pub fn install_core0_stack_guard() -> Result<(), ()> { | 532 | pub fn install_core0_stack_guard() -> Result<(), ()> { |
| 531 | extern "C" { | 533 | unsafe extern "C" { |
| 532 | static mut _stack_end: usize; | 534 | static mut _stack_end: usize; |
| 533 | } | 535 | } |
| 534 | unsafe { install_stack_guard(core::ptr::addr_of_mut!(_stack_end)) } | 536 | unsafe { install_stack_guard(core::ptr::addr_of_mut!(_stack_end)) } |
diff --git a/embassy-rp/src/multicore.rs b/embassy-rp/src/multicore.rs index adedc98ad..3b120e349 100644 --- a/embassy-rp/src/multicore.rs +++ b/embassy-rp/src/multicore.rs | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | //! use embassy_rp::multicore::Stack; | 14 | //! use embassy_rp::multicore::Stack; |
| 15 | //! use static_cell::StaticCell; | 15 | //! use static_cell::StaticCell; |
| 16 | //! use embassy_executor::Executor; | 16 | //! use embassy_executor::Executor; |
| 17 | //! use core::ptr::addr_of_mut; | ||
| 17 | //! | 18 | //! |
| 18 | //! static mut CORE1_STACK: Stack<4096> = Stack::new(); | 19 | //! static mut CORE1_STACK: Stack<4096> = Stack::new(); |
| 19 | //! static EXECUTOR0: StaticCell<Executor> = StaticCell::new(); | 20 | //! static EXECUTOR0: StaticCell<Executor> = StaticCell::new(); |
| @@ -36,7 +37,7 @@ | |||
| 36 | //! fn main() -> ! { | 37 | //! fn main() -> ! { |
| 37 | //! let p = embassy_rp::init(Default::default()); | 38 | //! let p = embassy_rp::init(Default::default()); |
| 38 | //! | 39 | //! |
| 39 | //! embassy_rp::multicore::spawn_core1(p.CORE1, unsafe { &mut CORE1_STACK }, move || { | 40 | //! embassy_rp::multicore::spawn_core1(p.CORE1, unsafe { &mut *addr_of_mut!(CORE1_STACK) }, move || { |
| 40 | //! let executor1 = EXECUTOR1.init(Executor::new()); | 41 | //! let executor1 = EXECUTOR1.init(Executor::new()); |
| 41 | //! executor1.run(|spawner| spawner.spawn(core1_task().unwrap())); | 42 | //! executor1.run(|spawner| spawner.spawn(core1_task().unwrap())); |
| 42 | //! }); | 43 | //! }); |
| @@ -47,11 +48,11 @@ | |||
| 47 | //! ``` | 48 | //! ``` |
| 48 | 49 | ||
| 49 | use core::mem::ManuallyDrop; | 50 | use core::mem::ManuallyDrop; |
| 50 | use core::sync::atomic::{compiler_fence, AtomicBool, Ordering}; | 51 | use core::sync::atomic::{AtomicBool, Ordering, compiler_fence}; |
| 51 | 52 | ||
| 52 | use crate::interrupt::InterruptExt; | 53 | use crate::interrupt::InterruptExt; |
| 53 | use crate::peripherals::CORE1; | 54 | use crate::peripherals::CORE1; |
| 54 | use crate::{gpio, install_stack_guard, interrupt, pac, Peri}; | 55 | use crate::{Peri, gpio, install_stack_guard, interrupt, pac}; |
| 55 | 56 | ||
| 56 | const PAUSE_TOKEN: u32 = 0xDEADBEEF; | 57 | const PAUSE_TOKEN: u32 = 0xDEADBEEF; |
| 57 | const RESUME_TOKEN: u32 = !0xDEADBEEF; | 58 | const RESUME_TOKEN: u32 = !0xDEADBEEF; |
| @@ -110,7 +111,6 @@ impl<const SIZE: usize> Stack<SIZE> { | |||
| 110 | 111 | ||
| 111 | #[cfg(all(feature = "rt", feature = "rp2040"))] | 112 | #[cfg(all(feature = "rt", feature = "rp2040"))] |
| 112 | #[interrupt] | 113 | #[interrupt] |
| 113 | #[link_section = ".data.ram_func"] | ||
| 114 | unsafe fn SIO_IRQ_PROC1() { | 114 | unsafe fn SIO_IRQ_PROC1() { |
| 115 | let sio = pac::SIO; | 115 | let sio = pac::SIO; |
| 116 | // Clear IRQ | 116 | // Clear IRQ |
| @@ -135,7 +135,6 @@ unsafe fn SIO_IRQ_PROC1() { | |||
| 135 | 135 | ||
| 136 | #[cfg(all(feature = "rt", feature = "_rp235x"))] | 136 | #[cfg(all(feature = "rt", feature = "_rp235x"))] |
| 137 | #[interrupt] | 137 | #[interrupt] |
| 138 | #[link_section = ".data.ram_func"] | ||
| 139 | unsafe fn SIO_IRQ_FIFO() { | 138 | unsafe fn SIO_IRQ_FIFO() { |
| 140 | let sio = pac::SIO; | 139 | let sio = pac::SIO; |
| 141 | // Clear IRQ | 140 | // Clear IRQ |
diff --git a/embassy-rp/src/pio/mod.rs b/embassy-rp/src/pio/mod.rs index 5f554dfe3..38ee1f97c 100644 --- a/embassy-rp/src/pio/mod.rs +++ b/embassy-rp/src/pio/mod.rs | |||
| @@ -2,21 +2,21 @@ | |||
| 2 | use core::future::Future; | 2 | use core::future::Future; |
| 3 | use core::marker::PhantomData; | 3 | use core::marker::PhantomData; |
| 4 | use core::pin::Pin as FuturePin; | 4 | use core::pin::Pin as FuturePin; |
| 5 | use core::sync::atomic::{compiler_fence, Ordering}; | 5 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 6 | use core::task::{Context, Poll}; | 6 | use core::task::{Context, Poll}; |
| 7 | 7 | ||
| 8 | use atomic_polyfill::{AtomicU64, AtomicU8}; | 8 | use atomic_polyfill::{AtomicU8, AtomicU64}; |
| 9 | use embassy_hal_internal::{Peri, PeripheralType}; | 9 | use embassy_hal_internal::{Peri, PeripheralType}; |
| 10 | use embassy_sync::waitqueue::AtomicWaker; | 10 | use embassy_sync::waitqueue::AtomicWaker; |
| 11 | use fixed::types::extra::U8; | ||
| 12 | use fixed::FixedU32; | 11 | use fixed::FixedU32; |
| 12 | use fixed::types::extra::U8; | ||
| 13 | use pio::{Program, SideSet, Wrap}; | 13 | use pio::{Program, SideSet, Wrap}; |
| 14 | 14 | ||
| 15 | use crate::dma::{self, Channel, Transfer, Word}; | 15 | use crate::dma::{self, Channel, Transfer, Word}; |
| 16 | use crate::gpio::{self, AnyPin, Drive, Level, Pull, SealedPin, SlewRate}; | 16 | use crate::gpio::{self, AnyPin, Drive, Level, Pull, SealedPin, SlewRate}; |
| 17 | use crate::interrupt::typelevel::{Binding, Handler, Interrupt}; | 17 | use crate::interrupt::typelevel::{Binding, Handler, Interrupt}; |
| 18 | use crate::relocate::RelocatedProgram; | 18 | use crate::relocate::RelocatedProgram; |
| 19 | use crate::{pac, peripherals, RegExt}; | 19 | use crate::{RegExt, pac, peripherals}; |
| 20 | 20 | ||
| 21 | mod instr; | 21 | mod instr; |
| 22 | 22 | ||
| @@ -984,11 +984,7 @@ impl<'d, PIO: Instance + 'd, const SM: usize> StateMachine<'d, PIO, SM> { | |||
| 984 | 984 | ||
| 985 | #[cfg(feature = "_rp235x")] | 985 | #[cfg(feature = "_rp235x")] |
| 986 | fn pin_base() -> u8 { | 986 | fn pin_base() -> u8 { |
| 987 | if PIO::PIO.gpiobase().read().gpiobase() { | 987 | if PIO::PIO.gpiobase().read().gpiobase() { 16 } else { 0 } |
| 988 | 16 | ||
| 989 | } else { | ||
| 990 | 0 | ||
| 991 | } | ||
| 992 | } | 988 | } |
| 993 | 989 | ||
| 994 | /// Sets pin directions. This pauses the current state machine to run `SET` commands | 990 | /// Sets pin directions. This pauses the current state machine to run `SET` commands |
diff --git a/embassy-rp/src/pio_programs/hd44780.rs b/embassy-rp/src/pio_programs/hd44780.rs index 546c85a89..78281ddd4 100644 --- a/embassy-rp/src/pio_programs/hd44780.rs +++ b/embassy-rp/src/pio_programs/hd44780.rs | |||
| @@ -1,12 +1,12 @@ | |||
| 1 | //! [HD44780 display driver](https://www.sparkfun.com/datasheets/LCD/HD44780.pdf) | 1 | //! [HD44780 display driver](https://www.sparkfun.com/datasheets/LCD/HD44780.pdf) |
| 2 | 2 | ||
| 3 | use crate::Peri; | ||
| 3 | use crate::dma::{AnyChannel, Channel}; | 4 | use crate::dma::{AnyChannel, Channel}; |
| 4 | use crate::pio::{ | 5 | use crate::pio::{ |
| 5 | Common, Config, Direction, FifoJoin, Instance, Irq, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, | 6 | Common, Config, Direction, FifoJoin, Instance, Irq, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, |
| 6 | StateMachine, | 7 | StateMachine, |
| 7 | }; | 8 | }; |
| 8 | use crate::pio_programs::clock_divider::calculate_pio_clock_divider; | 9 | use crate::pio_programs::clock_divider::calculate_pio_clock_divider; |
| 9 | use crate::Peri; | ||
| 10 | 10 | ||
| 11 | /// This struct represents a HD44780 program that takes command words (<wait:24> <command:4> <0:4>) | 11 | /// This struct represents a HD44780 program that takes command words (<wait:24> <command:4> <0:4>) |
| 12 | pub struct PioHD44780CommandWordProgram<'a, PIO: Instance> { | 12 | pub struct PioHD44780CommandWordProgram<'a, PIO: Instance> { |
diff --git a/embassy-rp/src/pio_programs/i2s.rs b/embassy-rp/src/pio_programs/i2s.rs index 2382a3f9f..7e5f68ad6 100644 --- a/embassy-rp/src/pio_programs/i2s.rs +++ b/embassy-rp/src/pio_programs/i2s.rs | |||
| @@ -2,12 +2,12 @@ | |||
| 2 | 2 | ||
| 3 | use fixed::traits::ToFixed; | 3 | use fixed::traits::ToFixed; |
| 4 | 4 | ||
| 5 | use crate::Peri; | ||
| 5 | use crate::dma::{AnyChannel, Channel, Transfer}; | 6 | use crate::dma::{AnyChannel, Channel, Transfer}; |
| 6 | use crate::gpio::Pull; | 7 | use crate::gpio::Pull; |
| 7 | use crate::pio::{ | 8 | use crate::pio::{ |
| 8 | Common, Config, Direction, FifoJoin, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine, | 9 | Common, Config, Direction, FifoJoin, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine, |
| 9 | }; | 10 | }; |
| 10 | use crate::Peri; | ||
| 11 | 11 | ||
| 12 | /// This struct represents an i2s receiver & controller driver program | 12 | /// This struct represents an i2s receiver & controller driver program |
| 13 | pub struct PioI2sInProgram<'d, PIO: Instance> { | 13 | pub struct PioI2sInProgram<'d, PIO: Instance> { |
diff --git a/embassy-rp/src/pio_programs/onewire.rs b/embassy-rp/src/pio_programs/onewire.rs index 980d0fe5f..09babc229 100644 --- a/embassy-rp/src/pio_programs/onewire.rs +++ b/embassy-rp/src/pio_programs/onewire.rs | |||
| @@ -1,11 +1,11 @@ | |||
| 1 | //! OneWire pio driver | 1 | //! OneWire pio driver |
| 2 | 2 | ||
| 3 | use crate::Peri; | ||
| 3 | use crate::clocks::clk_sys_freq; | 4 | use crate::clocks::clk_sys_freq; |
| 4 | use crate::gpio::Level; | 5 | use crate::gpio::Level; |
| 5 | use crate::pio::{ | 6 | use crate::pio::{ |
| 6 | Common, Config, Direction, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine, | 7 | Common, Config, Direction, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine, |
| 7 | }; | 8 | }; |
| 8 | use crate::Peri; | ||
| 9 | 9 | ||
| 10 | /// This struct represents a onewire driver program | 10 | /// This struct represents a onewire driver program |
| 11 | pub struct PioOneWireProgram<'a, PIO: Instance> { | 11 | pub struct PioOneWireProgram<'a, PIO: Instance> { |
| @@ -321,11 +321,7 @@ impl PioOneWireSearch { | |||
| 321 | 321 | ||
| 322 | /// Search for the next address on the bus | 322 | /// Search for the next address on the bus |
| 323 | pub async fn next<PIO: Instance, const SM: usize>(&mut self, pio: &mut PioOneWire<'_, PIO, SM>) -> Option<u64> { | 323 | pub async fn next<PIO: Instance, const SM: usize>(&mut self, pio: &mut PioOneWire<'_, PIO, SM>) -> Option<u64> { |
| 324 | if self.finished { | 324 | if self.finished { None } else { pio.search(self).await } |
| 325 | None | ||
| 326 | } else { | ||
| 327 | pio.search(self).await | ||
| 328 | } | ||
| 329 | } | 325 | } |
| 330 | 326 | ||
| 331 | /// Is finished when all devices have been found | 327 | /// Is finished when all devices have been found |
diff --git a/embassy-rp/src/pio_programs/pwm.rs b/embassy-rp/src/pio_programs/pwm.rs index f0f837bc5..ba06bb3c1 100644 --- a/embassy-rp/src/pio_programs/pwm.rs +++ b/embassy-rp/src/pio_programs/pwm.rs | |||
| @@ -6,7 +6,7 @@ use pio::InstructionOperands; | |||
| 6 | 6 | ||
| 7 | use crate::gpio::Level; | 7 | use crate::gpio::Level; |
| 8 | use crate::pio::{Common, Config, Direction, Instance, LoadedProgram, Pin, PioPin, StateMachine}; | 8 | use crate::pio::{Common, Config, Direction, Instance, LoadedProgram, Pin, PioPin, StateMachine}; |
| 9 | use crate::{clocks, Peri}; | 9 | use crate::{Peri, clocks}; |
| 10 | 10 | ||
| 11 | /// This converts the duration provided into the number of cycles the PIO needs to run to make it take the same time | 11 | /// This converts the duration provided into the number of cycles the PIO needs to run to make it take the same time |
| 12 | fn to_pio_cycles(duration: Duration) -> u32 { | 12 | fn to_pio_cycles(duration: Duration) -> u32 { |
diff --git a/embassy-rp/src/pio_programs/rotary_encoder.rs b/embassy-rp/src/pio_programs/rotary_encoder.rs index 70b3795e9..6347527e6 100644 --- a/embassy-rp/src/pio_programs/rotary_encoder.rs +++ b/embassy-rp/src/pio_programs/rotary_encoder.rs | |||
| @@ -1,11 +1,11 @@ | |||
| 1 | //! PIO backed quadrature encoder | 1 | //! PIO backed quadrature encoder |
| 2 | 2 | ||
| 3 | use crate::Peri; | ||
| 3 | use crate::gpio::Pull; | 4 | use crate::gpio::Pull; |
| 4 | use crate::pio::{ | 5 | use crate::pio::{ |
| 5 | Common, Config, Direction as PioDirection, FifoJoin, Instance, LoadedProgram, PioPin, ShiftDirection, StateMachine, | 6 | Common, Config, Direction as PioDirection, FifoJoin, Instance, LoadedProgram, PioPin, ShiftDirection, StateMachine, |
| 6 | }; | 7 | }; |
| 7 | use crate::pio_programs::clock_divider::calculate_pio_clock_divider; | 8 | use crate::pio_programs::clock_divider::calculate_pio_clock_divider; |
| 8 | use crate::Peri; | ||
| 9 | 9 | ||
| 10 | /// This struct represents an Encoder program loaded into pio instruction memory. | 10 | /// This struct represents an Encoder program loaded into pio instruction memory. |
| 11 | pub struct PioEncoderProgram<'a, PIO: Instance> { | 11 | pub struct PioEncoderProgram<'a, PIO: Instance> { |
diff --git a/embassy-rp/src/pio_programs/stepper.rs b/embassy-rp/src/pio_programs/stepper.rs index 0e9a8daf9..5762ee189 100644 --- a/embassy-rp/src/pio_programs/stepper.rs +++ b/embassy-rp/src/pio_programs/stepper.rs | |||
| @@ -2,9 +2,9 @@ | |||
| 2 | 2 | ||
| 3 | use core::mem::{self, MaybeUninit}; | 3 | use core::mem::{self, MaybeUninit}; |
| 4 | 4 | ||
| 5 | use crate::Peri; | ||
| 5 | use crate::pio::{Common, Config, Direction, Instance, Irq, LoadedProgram, PioPin, StateMachine}; | 6 | use crate::pio::{Common, Config, Direction, Instance, Irq, LoadedProgram, PioPin, StateMachine}; |
| 6 | use crate::pio_programs::clock_divider::calculate_pio_clock_divider; | 7 | use crate::pio_programs::clock_divider::calculate_pio_clock_divider; |
| 7 | use crate::Peri; | ||
| 8 | 8 | ||
| 9 | /// This struct represents a Stepper driver program loaded into pio instruction memory. | 9 | /// This struct represents a Stepper driver program loaded into pio instruction memory. |
| 10 | pub struct PioStepperProgram<'a, PIO: Instance> { | 10 | pub struct PioStepperProgram<'a, PIO: Instance> { |
diff --git a/embassy-rp/src/pio_programs/uart.rs b/embassy-rp/src/pio_programs/uart.rs index 04e39a571..444efb5db 100644 --- a/embassy-rp/src/pio_programs/uart.rs +++ b/embassy-rp/src/pio_programs/uart.rs | |||
| @@ -5,12 +5,12 @@ use core::convert::Infallible; | |||
| 5 | use embedded_io_async::{ErrorType, Read, Write}; | 5 | use embedded_io_async::{ErrorType, Read, Write}; |
| 6 | use fixed::traits::ToFixed; | 6 | use fixed::traits::ToFixed; |
| 7 | 7 | ||
| 8 | use crate::Peri; | ||
| 8 | use crate::clocks::clk_sys_freq; | 9 | use crate::clocks::clk_sys_freq; |
| 9 | use crate::gpio::Level; | 10 | use crate::gpio::Level; |
| 10 | use crate::pio::{ | 11 | use crate::pio::{ |
| 11 | Common, Config, Direction as PioDirection, FifoJoin, Instance, LoadedProgram, PioPin, ShiftDirection, StateMachine, | 12 | Common, Config, Direction as PioDirection, FifoJoin, Instance, LoadedProgram, PioPin, ShiftDirection, StateMachine, |
| 12 | }; | 13 | }; |
| 13 | use crate::Peri; | ||
| 14 | 14 | ||
| 15 | /// This struct represents a uart tx program loaded into pio instruction memory. | 15 | /// This struct represents a uart tx program loaded into pio instruction memory. |
| 16 | pub struct PioUartTxProgram<'d, PIO: Instance> { | 16 | pub struct PioUartTxProgram<'d, PIO: Instance> { |
diff --git a/embassy-rp/src/pio_programs/ws2812.rs b/embassy-rp/src/pio_programs/ws2812.rs index 37dd1c4e0..e6851b1a6 100644 --- a/embassy-rp/src/pio_programs/ws2812.rs +++ b/embassy-rp/src/pio_programs/ws2812.rs | |||
| @@ -4,12 +4,12 @@ use embassy_time::Timer; | |||
| 4 | use fixed::types::U24F8; | 4 | use fixed::types::U24F8; |
| 5 | use smart_leds::{RGB8, RGBW}; | 5 | use smart_leds::{RGB8, RGBW}; |
| 6 | 6 | ||
| 7 | use crate::Peri; | ||
| 7 | use crate::clocks::clk_sys_freq; | 8 | use crate::clocks::clk_sys_freq; |
| 8 | use crate::dma::{AnyChannel, Channel}; | 9 | use crate::dma::{AnyChannel, Channel}; |
| 9 | use crate::pio::{ | 10 | use crate::pio::{ |
| 10 | Common, Config, FifoJoin, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine, | 11 | Common, Config, FifoJoin, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine, |
| 11 | }; | 12 | }; |
| 12 | use crate::Peri; | ||
| 13 | 13 | ||
| 14 | const T1: u8 = 2; // start bit | 14 | const T1: u8 = 2; // start bit |
| 15 | const T2: u8 = 5; // data bit | 15 | const T2: u8 = 5; // data bit |
diff --git a/embassy-rp/src/psram.rs b/embassy-rp/src/psram.rs index ae43dd5aa..25185ead2 100644 --- a/embassy-rp/src/psram.rs +++ b/embassy-rp/src/psram.rs | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | #![cfg(feature = "_rp235x")] | 11 | #![cfg(feature = "_rp235x")] |
| 12 | 12 | ||
| 13 | use critical_section::{acquire, release, CriticalSection, RestoreState}; | 13 | use critical_section::{CriticalSection, RestoreState, acquire, release}; |
| 14 | 14 | ||
| 15 | use crate::pac; | 15 | use crate::pac; |
| 16 | use crate::qmi_cs1::QmiCs1; | 16 | use crate::qmi_cs1::QmiCs1; |
| @@ -251,7 +251,7 @@ impl<'d> Psram<'d> { | |||
| 251 | } | 251 | } |
| 252 | 252 | ||
| 253 | /// Verify APS6404L PSRAM device matches expected configuration. | 253 | /// Verify APS6404L PSRAM device matches expected configuration. |
| 254 | #[link_section = ".data.ram_func"] | 254 | #[unsafe(link_section = ".data.ram_func")] |
| 255 | #[inline(never)] | 255 | #[inline(never)] |
| 256 | fn verify_aps6404l(qmi: &pac::qmi::Qmi, expected_size: usize) -> Result<(), Error> { | 256 | fn verify_aps6404l(qmi: &pac::qmi::Qmi, expected_size: usize) -> Result<(), Error> { |
| 257 | // APS6404L-specific constants | 257 | // APS6404L-specific constants |
| @@ -306,7 +306,7 @@ impl<'d> Psram<'d> { | |||
| 306 | Ok(()) | 306 | Ok(()) |
| 307 | } | 307 | } |
| 308 | 308 | ||
| 309 | #[link_section = ".data.ram_func"] | 309 | #[unsafe(link_section = ".data.ram_func")] |
| 310 | #[inline(never)] | 310 | #[inline(never)] |
| 311 | unsafe fn read_aps6404l_kgd_eid(qmi: &pac::qmi::Qmi) -> (u32, u32) { | 311 | unsafe fn read_aps6404l_kgd_eid(qmi: &pac::qmi::Qmi) -> (u32, u32) { |
| 312 | const RESET_ENABLE_CMD: u8 = 0xf5; | 312 | const RESET_ENABLE_CMD: u8 = 0xf5; |
| @@ -435,7 +435,7 @@ impl<'d> Psram<'d> { | |||
| 435 | } | 435 | } |
| 436 | 436 | ||
| 437 | /// Initialize PSRAM with proper timing. | 437 | /// Initialize PSRAM with proper timing. |
| 438 | #[link_section = ".data.ram_func"] | 438 | #[unsafe(link_section = ".data.ram_func")] |
| 439 | #[inline(never)] | 439 | #[inline(never)] |
| 440 | fn init_psram(qmi: &pac::qmi::Qmi, xip_ctrl: &pac::xip_ctrl::XipCtrl, config: &Config) -> Result<(), Error> { | 440 | fn init_psram(qmi: &pac::qmi::Qmi, xip_ctrl: &pac::xip_ctrl::XipCtrl, config: &Config) -> Result<(), Error> { |
| 441 | // Set PSRAM timing for APS6404 | 441 | // Set PSRAM timing for APS6404 |
| @@ -610,7 +610,7 @@ impl<'d> Psram<'d> { | |||
| 610 | Ok(()) | 610 | Ok(()) |
| 611 | } | 611 | } |
| 612 | 612 | ||
| 613 | #[link_section = ".data.ram_func"] | 613 | #[unsafe(link_section = ".data.ram_func")] |
| 614 | #[inline(never)] | 614 | #[inline(never)] |
| 615 | unsafe fn direct_csr_send_init_command(config: &Config, init_cmd: u8) { | 615 | unsafe fn direct_csr_send_init_command(config: &Config, init_cmd: u8) { |
| 616 | #[cfg(target_arch = "arm")] | 616 | #[cfg(target_arch = "arm")] |
diff --git a/embassy-rp/src/pwm.rs b/embassy-rp/src/pwm.rs index 1e1ccc4c6..59a3fc9a2 100644 --- a/embassy-rp/src/pwm.rs +++ b/embassy-rp/src/pwm.rs | |||
| @@ -3,13 +3,13 @@ | |||
| 3 | use embassy_hal_internal::{Peri, PeripheralType}; | 3 | use embassy_hal_internal::{Peri, PeripheralType}; |
| 4 | pub use embedded_hal_1::pwm::SetDutyCycle; | 4 | pub use embedded_hal_1::pwm::SetDutyCycle; |
| 5 | use embedded_hal_1::pwm::{Error, ErrorKind, ErrorType}; | 5 | use embedded_hal_1::pwm::{Error, ErrorKind, ErrorType}; |
| 6 | use fixed::traits::ToFixed; | ||
| 7 | use fixed::FixedU16; | 6 | use fixed::FixedU16; |
| 7 | use fixed::traits::ToFixed; | ||
| 8 | use pac::pwm::regs::{ChDiv, Intr}; | 8 | use pac::pwm::regs::{ChDiv, Intr}; |
| 9 | use pac::pwm::vals::Divmode; | 9 | use pac::pwm::vals::Divmode; |
| 10 | 10 | ||
| 11 | use crate::gpio::{AnyPin, Pin as GpioPin, Pull, SealedPin as _}; | 11 | use crate::gpio::{AnyPin, Pin as GpioPin, Pull, SealedPin as _}; |
| 12 | use crate::{pac, peripherals, RegExt}; | 12 | use crate::{RegExt, pac, peripherals}; |
| 13 | 13 | ||
| 14 | /// The configuration of a PWM slice. | 14 | /// The configuration of a PWM slice. |
| 15 | /// Note the period in clock cycles of a slice can be computed as: | 15 | /// Note the period in clock cycles of a slice can be computed as: |
diff --git a/embassy-rp/src/rtc/mod.rs b/embassy-rp/src/rtc/mod.rs index 8b0deed21..68fb3b765 100644 --- a/embassy-rp/src/rtc/mod.rs +++ b/embassy-rp/src/rtc/mod.rs | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | mod filter; | 2 | mod filter; |
| 3 | 3 | ||
| 4 | use core::future::poll_fn; | 4 | use core::future::poll_fn; |
| 5 | use core::sync::atomic::{compiler_fence, AtomicBool, Ordering}; | 5 | use core::sync::atomic::{AtomicBool, Ordering, compiler_fence}; |
| 6 | use core::task::Poll; | 6 | use core::task::Poll; |
| 7 | 7 | ||
| 8 | use embassy_hal_internal::{Peri, PeripheralType}; | 8 | use embassy_hal_internal::{Peri, PeripheralType}; |
diff --git a/embassy-rp/src/time_driver.rs b/embassy-rp/src/time_driver.rs index d598287a9..ec1c17ed5 100644 --- a/embassy-rp/src/time_driver.rs +++ b/embassy-rp/src/time_driver.rs | |||
| @@ -2,8 +2,8 @@ | |||
| 2 | use core::cell::{Cell, RefCell}; | 2 | use core::cell::{Cell, RefCell}; |
| 3 | 3 | ||
| 4 | use critical_section::CriticalSection; | 4 | use critical_section::CriticalSection; |
| 5 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | ||
| 6 | use embassy_sync::blocking_mutex::Mutex; | 5 | use embassy_sync::blocking_mutex::Mutex; |
| 6 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | ||
| 7 | use embassy_time_driver::Driver; | 7 | use embassy_time_driver::Driver; |
| 8 | use embassy_time_queue_utils::Queue; | 8 | use embassy_time_queue_utils::Queue; |
| 9 | #[cfg(feature = "rp2040")] | 9 | #[cfg(feature = "rp2040")] |
diff --git a/embassy-rp/src/uart/mod.rs b/embassy-rp/src/uart/mod.rs index 6f4e2ee07..43187df2d 100644 --- a/embassy-rp/src/uart/mod.rs +++ b/embassy-rp/src/uart/mod.rs | |||
| @@ -4,7 +4,7 @@ use core::marker::PhantomData; | |||
| 4 | use core::task::Poll; | 4 | use core::task::Poll; |
| 5 | 5 | ||
| 6 | use atomic_polyfill::{AtomicU16, Ordering}; | 6 | use atomic_polyfill::{AtomicU16, Ordering}; |
| 7 | use embassy_futures::select::{select, Either}; | 7 | use embassy_futures::select::{Either, select}; |
| 8 | use embassy_hal_internal::{Peri, PeripheralType}; | 8 | use embassy_hal_internal::{Peri, PeripheralType}; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 10 | use embassy_time::{Delay, Timer}; | 10 | use embassy_time::{Delay, Timer}; |
| @@ -16,7 +16,7 @@ use crate::gpio::{AnyPin, SealedPin}; | |||
| 16 | use crate::interrupt::typelevel::{Binding, Interrupt as _}; | 16 | use crate::interrupt::typelevel::{Binding, Interrupt as _}; |
| 17 | use crate::interrupt::{Interrupt, InterruptExt}; | 17 | use crate::interrupt::{Interrupt, InterruptExt}; |
| 18 | use crate::pac::io::vals::{Inover, Outover}; | 18 | use crate::pac::io::vals::{Inover, Outover}; |
| 19 | use crate::{interrupt, pac, peripherals, RegExt}; | 19 | use crate::{RegExt, interrupt, pac, peripherals}; |
| 20 | 20 | ||
| 21 | mod buffered; | 21 | mod buffered; |
| 22 | pub use buffered::{BufferedInterruptHandler, BufferedUart, BufferedUartRx, BufferedUartTx}; | 22 | pub use buffered::{BufferedInterruptHandler, BufferedUart, BufferedUartRx, BufferedUartTx}; |
| @@ -863,11 +863,7 @@ impl<'d, M: Mode> Uart<'d, M> { | |||
| 863 | if let Some(pin) = &tx { | 863 | if let Some(pin) = &tx { |
| 864 | let funcsel = { | 864 | let funcsel = { |
| 865 | let pin_number = ((pin.gpio().as_ptr() as u32) & 0x1FF) / 8; | 865 | let pin_number = ((pin.gpio().as_ptr() as u32) & 0x1FF) / 8; |
| 866 | if (pin_number % 4) == 0 { | 866 | if (pin_number % 4) == 0 { 2 } else { 11 } |
| 867 | 2 | ||
| 868 | } else { | ||
| 869 | 11 | ||
| 870 | } | ||
| 871 | }; | 867 | }; |
| 872 | pin.gpio().ctrl().write(|w| { | 868 | pin.gpio().ctrl().write(|w| { |
| 873 | w.set_funcsel(funcsel); | 869 | w.set_funcsel(funcsel); |
| @@ -886,11 +882,7 @@ impl<'d, M: Mode> Uart<'d, M> { | |||
| 886 | if let Some(pin) = &rx { | 882 | if let Some(pin) = &rx { |
| 887 | let funcsel = { | 883 | let funcsel = { |
| 888 | let pin_number = ((pin.gpio().as_ptr() as u32) & 0x1FF) / 8; | 884 | let pin_number = ((pin.gpio().as_ptr() as u32) & 0x1FF) / 8; |
| 889 | if ((pin_number - 1) % 4) == 0 { | 885 | if ((pin_number - 1) % 4) == 0 { 2 } else { 11 } |
| 890 | 2 | ||
| 891 | } else { | ||
| 892 | 11 | ||
| 893 | } | ||
| 894 | }; | 886 | }; |
| 895 | pin.gpio().ctrl().write(|w| { | 887 | pin.gpio().ctrl().write(|w| { |
| 896 | w.set_funcsel(funcsel); | 888 | w.set_funcsel(funcsel); |
diff --git a/embassy-rp/src/usb.rs b/embassy-rp/src/usb.rs index 671ecbd32..e8273c3f2 100644 --- a/embassy-rp/src/usb.rs +++ b/embassy-rp/src/usb.rs | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | use core::future::poll_fn; | 2 | use core::future::poll_fn; |
| 3 | use core::marker::PhantomData; | 3 | use core::marker::PhantomData; |
| 4 | use core::slice; | 4 | use core::slice; |
| 5 | use core::sync::atomic::{compiler_fence, Ordering}; | 5 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 6 | use core::task::Poll; | 6 | use core::task::Poll; |
| 7 | 7 | ||
| 8 | use embassy_hal_internal::PeripheralType; | 8 | use embassy_hal_internal::PeripheralType; |
| @@ -13,7 +13,7 @@ use embassy_usb_driver::{ | |||
| 13 | }; | 13 | }; |
| 14 | 14 | ||
| 15 | use crate::interrupt::typelevel::{Binding, Interrupt}; | 15 | use crate::interrupt::typelevel::{Binding, Interrupt}; |
| 16 | use crate::{interrupt, pac, peripherals, Peri, RegExt}; | 16 | use crate::{Peri, RegExt, interrupt, pac, peripherals}; |
| 17 | 17 | ||
| 18 | trait SealedInstance { | 18 | trait SealedInstance { |
| 19 | fn regs() -> crate::pac::usb::Usb; | 19 | fn regs() -> crate::pac::usb::Usb; |
| @@ -545,11 +545,7 @@ impl<'d, T: Instance> driver::Endpoint for Endpoint<'d, T, In> { | |||
| 545 | poll_fn(|cx| { | 545 | poll_fn(|cx| { |
| 546 | EP_IN_WAKERS[index].register(cx.waker()); | 546 | EP_IN_WAKERS[index].register(cx.waker()); |
| 547 | let val = T::dpram().ep_in_control(self.info.addr.index() - 1).read(); | 547 | let val = T::dpram().ep_in_control(self.info.addr.index() - 1).read(); |
| 548 | if val.enable() { | 548 | if val.enable() { Poll::Ready(()) } else { Poll::Pending } |
| 549 | Poll::Ready(()) | ||
| 550 | } else { | ||
| 551 | Poll::Pending | ||
| 552 | } | ||
| 553 | }) | 549 | }) |
| 554 | .await; | 550 | .await; |
| 555 | trace!("wait_enabled IN OK"); | 551 | trace!("wait_enabled IN OK"); |
| @@ -567,11 +563,7 @@ impl<'d, T: Instance> driver::Endpoint for Endpoint<'d, T, Out> { | |||
| 567 | poll_fn(|cx| { | 563 | poll_fn(|cx| { |
| 568 | EP_OUT_WAKERS[index].register(cx.waker()); | 564 | EP_OUT_WAKERS[index].register(cx.waker()); |
| 569 | let val = T::dpram().ep_out_control(self.info.addr.index() - 1).read(); | 565 | let val = T::dpram().ep_out_control(self.info.addr.index() - 1).read(); |
| 570 | if val.enable() { | 566 | if val.enable() { Poll::Ready(()) } else { Poll::Pending } |
| 571 | Poll::Ready(()) | ||
| 572 | } else { | ||
| 573 | Poll::Pending | ||
| 574 | } | ||
| 575 | }) | 567 | }) |
| 576 | .await; | 568 | .await; |
| 577 | trace!("wait_enabled OUT OK"); | 569 | trace!("wait_enabled OUT OK"); |
diff --git a/embassy-rp/src/watchdog.rs b/embassy-rp/src/watchdog.rs index 49cf03850..d42601745 100644 --- a/embassy-rp/src/watchdog.rs +++ b/embassy-rp/src/watchdog.rs | |||
| @@ -11,7 +11,7 @@ use core::marker::PhantomData; | |||
| 11 | use embassy_time::Duration; | 11 | use embassy_time::Duration; |
| 12 | 12 | ||
| 13 | use crate::peripherals::WATCHDOG; | 13 | use crate::peripherals::WATCHDOG; |
| 14 | use crate::{pac, Peri}; | 14 | use crate::{Peri, pac}; |
| 15 | 15 | ||
| 16 | /// The reason for a system reset from the watchdog. | 16 | /// The reason for a system reset from the watchdog. |
| 17 | #[derive(Debug, Copy, Clone, PartialEq, Eq)] | 17 | #[derive(Debug, Copy, Clone, PartialEq, Eq)] |
diff --git a/embassy-stm32-wpan/Cargo.toml b/embassy-stm32-wpan/Cargo.toml index d7c7a284c..0802b7328 100644 --- a/embassy-stm32-wpan/Cargo.toml +++ b/embassy-stm32-wpan/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-stm32-wpan" | 2 | name = "embassy-stm32-wpan" |
| 3 | version = "0.1.0" | 3 | version = "0.1.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | description = "Async STM32 WPAN stack for embedded devices in Rust." | 6 | description = "Async STM32 WPAN stack for embedded devices in Rust." |
| 7 | keywords = ["embedded", "async", "stm32", "ble", "wpan"] | 7 | keywords = ["embedded", "async", "stm32", "ble", "wpan"] |
diff --git a/embassy-stm32-wpan/src/cmd.rs b/embassy-stm32-wpan/src/cmd.rs index 928357384..5c81a4aa7 100644 --- a/embassy-stm32-wpan/src/cmd.rs +++ b/embassy-stm32-wpan/src/cmd.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | use core::ptr; | 1 | use core::ptr; |
| 2 | 2 | ||
| 3 | use crate::consts::TlPacketType; | ||
| 4 | use crate::PacketHeader; | 3 | use crate::PacketHeader; |
| 4 | use crate::consts::TlPacketType; | ||
| 5 | 5 | ||
| 6 | #[derive(Copy, Clone)] | 6 | #[derive(Copy, Clone)] |
| 7 | #[repr(C, packed)] | 7 | #[repr(C, packed)] |
diff --git a/embassy-stm32-wpan/src/consts.rs b/embassy-stm32-wpan/src/consts.rs index e2ae6ca86..7ecb22974 100644 --- a/embassy-stm32-wpan/src/consts.rs +++ b/embassy-stm32-wpan/src/consts.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | use crate::evt::CsEvt; | ||
| 2 | use crate::PacketHeader; | 1 | use crate::PacketHeader; |
| 2 | use crate::evt::CsEvt; | ||
| 3 | 3 | ||
| 4 | #[derive(Debug)] | 4 | #[derive(Debug)] |
| 5 | #[repr(C)] | 5 | #[repr(C)] |
diff --git a/embassy-stm32-wpan/src/lhci.rs b/embassy-stm32-wpan/src/lhci.rs index 89f204f99..59c8bfb5d 100644 --- a/embassy-stm32-wpan/src/lhci.rs +++ b/embassy-stm32-wpan/src/lhci.rs | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | use core::ptr; | 1 | use core::ptr; |
| 2 | 2 | ||
| 3 | use crate::cmd::CmdPacket; | 3 | use crate::cmd::CmdPacket; |
| 4 | use crate::consts::{TlPacketType, TL_EVT_HEADER_SIZE}; | 4 | use crate::consts::{TL_EVT_HEADER_SIZE, TlPacketType}; |
| 5 | use crate::evt::{CcEvt, EvtPacket, EvtSerial}; | 5 | use crate::evt::{CcEvt, EvtPacket, EvtSerial}; |
| 6 | use crate::tables::{DeviceInfoTable, RssInfoTable, SafeBootInfoTable, WirelessFwInfoTable, TL_DEVICE_INFO_TABLE}; | 6 | use crate::tables::{DeviceInfoTable, RssInfoTable, SafeBootInfoTable, TL_DEVICE_INFO_TABLE, WirelessFwInfoTable}; |
| 7 | 7 | ||
| 8 | const TL_BLEEVT_CC_OPCODE: u8 = 0x0e; | 8 | const TL_BLEEVT_CC_OPCODE: u8 = 0x0e; |
| 9 | const LHCI_OPCODE_C1_DEVICE_INF: u16 = 0xfd62; | 9 | const LHCI_OPCODE_C1_DEVICE_INF: u16 = 0xfd62; |
diff --git a/embassy-stm32-wpan/src/lib.rs b/embassy-stm32-wpan/src/lib.rs index 40ff14795..f6b1f6021 100644 --- a/embassy-stm32-wpan/src/lib.rs +++ b/embassy-stm32-wpan/src/lib.rs | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | 13 | ||
| 14 | #![no_std] | 14 | #![no_std] |
| 15 | #![allow(async_fn_in_trait)] | 15 | #![allow(async_fn_in_trait)] |
| 16 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 16 | #![doc = include_str!("../README.md")] | 17 | #![doc = include_str!("../README.md")] |
| 17 | // #![warn(missing_docs)] | 18 | // #![warn(missing_docs)] |
| 18 | #![allow(static_mut_refs)] // TODO: Fix | 19 | #![allow(static_mut_refs)] // TODO: Fix |
| @@ -21,7 +22,7 @@ | |||
| 21 | mod fmt; | 22 | mod fmt; |
| 22 | 23 | ||
| 23 | use core::mem::MaybeUninit; | 24 | use core::mem::MaybeUninit; |
| 24 | use core::sync::atomic::{compiler_fence, Ordering}; | 25 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 25 | 26 | ||
| 26 | use embassy_hal_internal::Peri; | 27 | use embassy_hal_internal::Peri; |
| 27 | use embassy_stm32::interrupt; | 28 | use embassy_stm32::interrupt; |
| @@ -94,7 +95,7 @@ impl<'d> TlMbox<'d> { | |||
| 94 | pub fn init( | 95 | pub fn init( |
| 95 | ipcc: Peri<'d, IPCC>, | 96 | ipcc: Peri<'d, IPCC>, |
| 96 | _irqs: impl interrupt::typelevel::Binding<interrupt::typelevel::IPCC_C1_RX, ReceiveInterruptHandler> | 97 | _irqs: impl interrupt::typelevel::Binding<interrupt::typelevel::IPCC_C1_RX, ReceiveInterruptHandler> |
| 97 | + interrupt::typelevel::Binding<interrupt::typelevel::IPCC_C1_TX, TransmitInterruptHandler>, | 98 | + interrupt::typelevel::Binding<interrupt::typelevel::IPCC_C1_TX, TransmitInterruptHandler>, |
| 98 | config: Config, | 99 | config: Config, |
| 99 | ) -> Self { | 100 | ) -> Self { |
| 100 | // this is an inlined version of TL_Init from the STM32WB firmware as requested by AN5289. | 101 | // this is an inlined version of TL_Init from the STM32WB firmware as requested by AN5289. |
diff --git a/embassy-stm32-wpan/src/mac/driver.rs b/embassy-stm32-wpan/src/mac/driver.rs index 41cca09e3..480ac3790 100644 --- a/embassy-stm32-wpan/src/mac/driver.rs +++ b/embassy-stm32-wpan/src/mac/driver.rs | |||
| @@ -6,9 +6,9 @@ use embassy_net_driver::{Capabilities, HardwareAddress, LinkState}; | |||
| 6 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 6 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| 7 | use embassy_sync::channel::Channel; | 7 | use embassy_sync::channel::Channel; |
| 8 | 8 | ||
| 9 | use crate::mac::MTU; | ||
| 9 | use crate::mac::event::MacEvent; | 10 | use crate::mac::event::MacEvent; |
| 10 | use crate::mac::runner::Runner; | 11 | use crate::mac::runner::Runner; |
| 11 | use crate::mac::MTU; | ||
| 12 | 12 | ||
| 13 | pub struct Driver<'d> { | 13 | pub struct Driver<'d> { |
| 14 | runner: &'d Runner<'d>, | 14 | runner: &'d Runner<'d>, |
diff --git a/embassy-stm32-wpan/src/mac/runner.rs b/embassy-stm32-wpan/src/mac/runner.rs index d3099b6b7..2409f994d 100644 --- a/embassy-stm32-wpan/src/mac/runner.rs +++ b/embassy-stm32-wpan/src/mac/runner.rs | |||
| @@ -7,10 +7,10 @@ use embassy_sync::channel::Channel; | |||
| 7 | use embassy_sync::mutex::Mutex; | 7 | use embassy_sync::mutex::Mutex; |
| 8 | use embassy_sync::signal::Signal; | 8 | use embassy_sync::signal::Signal; |
| 9 | 9 | ||
| 10 | use crate::mac::MTU; | ||
| 10 | use crate::mac::commands::DataRequest; | 11 | use crate::mac::commands::DataRequest; |
| 11 | use crate::mac::event::MacEvent; | 12 | use crate::mac::event::MacEvent; |
| 12 | use crate::mac::typedefs::{AddressMode, MacAddress, PanId, SecurityLevel}; | 13 | use crate::mac::typedefs::{AddressMode, MacAddress, PanId, SecurityLevel}; |
| 13 | use crate::mac::MTU; | ||
| 14 | use crate::sub::mac::Mac; | 14 | use crate::sub::mac::Mac; |
| 15 | 15 | ||
| 16 | type ZeroCopyPubSub<M, T> = blocking_mutex::Mutex<M, RefCell<Option<Signal<NoopRawMutex, T>>>>; | 16 | type ZeroCopyPubSub<M, T> = blocking_mutex::Mutex<M, RefCell<Option<Signal<NoopRawMutex, T>>>>; |
diff --git a/embassy-stm32-wpan/src/sub/ble.rs b/embassy-stm32-wpan/src/sub/ble.rs index 0f770d92c..cd69a0479 100644 --- a/embassy-stm32-wpan/src/sub/ble.rs +++ b/embassy-stm32-wpan/src/sub/ble.rs | |||
| @@ -4,10 +4,10 @@ use embassy_stm32::ipcc::Ipcc; | |||
| 4 | use hci::Opcode; | 4 | use hci::Opcode; |
| 5 | 5 | ||
| 6 | use crate::cmd::CmdPacket; | 6 | use crate::cmd::CmdPacket; |
| 7 | use crate::consts::{TlPacketType, TL_BLEEVT_CC_OPCODE, TL_BLEEVT_CS_OPCODE}; | 7 | use crate::consts::{TL_BLEEVT_CC_OPCODE, TL_BLEEVT_CS_OPCODE, TlPacketType}; |
| 8 | use crate::evt::{EvtBox, EvtPacket, EvtStub}; | 8 | use crate::evt::{EvtBox, EvtPacket, EvtStub}; |
| 9 | use crate::sub::mm; | 9 | use crate::sub::mm; |
| 10 | use crate::tables::{BleTable, BLE_CMD_BUFFER, CS_BUFFER, EVT_QUEUE, HCI_ACL_DATA_BUFFER, TL_BLE_TABLE}; | 10 | use crate::tables::{BLE_CMD_BUFFER, BleTable, CS_BUFFER, EVT_QUEUE, HCI_ACL_DATA_BUFFER, TL_BLE_TABLE}; |
| 11 | use crate::unsafe_linked_list::LinkedListNode; | 11 | use crate::unsafe_linked_list::LinkedListNode; |
| 12 | use crate::{channels, evt}; | 12 | use crate::{channels, evt}; |
| 13 | 13 | ||
diff --git a/embassy-stm32-wpan/src/sub/mm.rs b/embassy-stm32-wpan/src/sub/mm.rs index 4e4d2f854..62d0de8bd 100644 --- a/embassy-stm32-wpan/src/sub/mm.rs +++ b/embassy-stm32-wpan/src/sub/mm.rs | |||
| @@ -3,7 +3,7 @@ use core::future::poll_fn; | |||
| 3 | use core::mem::MaybeUninit; | 3 | use core::mem::MaybeUninit; |
| 4 | use core::task::Poll; | 4 | use core::task::Poll; |
| 5 | 5 | ||
| 6 | use aligned::{Aligned, A4}; | 6 | use aligned::{A4, Aligned}; |
| 7 | use cortex_m::interrupt; | 7 | use cortex_m::interrupt; |
| 8 | use embassy_stm32::ipcc::Ipcc; | 8 | use embassy_stm32::ipcc::Ipcc; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| @@ -12,7 +12,7 @@ use crate::consts::POOL_SIZE; | |||
| 12 | use crate::evt::EvtPacket; | 12 | use crate::evt::EvtPacket; |
| 13 | #[cfg(feature = "ble")] | 13 | #[cfg(feature = "ble")] |
| 14 | use crate::tables::BLE_SPARE_EVT_BUF; | 14 | use crate::tables::BLE_SPARE_EVT_BUF; |
| 15 | use crate::tables::{MemManagerTable, EVT_POOL, FREE_BUF_QUEUE, SYS_SPARE_EVT_BUF, TL_MEM_MANAGER_TABLE}; | 15 | use crate::tables::{EVT_POOL, FREE_BUF_QUEUE, MemManagerTable, SYS_SPARE_EVT_BUF, TL_MEM_MANAGER_TABLE}; |
| 16 | use crate::unsafe_linked_list::LinkedListNode; | 16 | use crate::unsafe_linked_list::LinkedListNode; |
| 17 | use crate::{channels, evt}; | 17 | use crate::{channels, evt}; |
| 18 | 18 | ||
diff --git a/embassy-stm32-wpan/src/sub/sys.rs b/embassy-stm32-wpan/src/sub/sys.rs index cf6df58bf..8a3382f86 100644 --- a/embassy-stm32-wpan/src/sub/sys.rs +++ b/embassy-stm32-wpan/src/sub/sys.rs | |||
| @@ -8,7 +8,7 @@ use crate::shci::{SchiCommandStatus, ShciBleInitCmdParam, ShciOpcode}; | |||
| 8 | use crate::sub::mm; | 8 | use crate::sub::mm; |
| 9 | use crate::tables::{SysTable, WirelessFwInfoTable}; | 9 | use crate::tables::{SysTable, WirelessFwInfoTable}; |
| 10 | use crate::unsafe_linked_list::LinkedListNode; | 10 | use crate::unsafe_linked_list::LinkedListNode; |
| 11 | use crate::{channels, Ipcc, SYSTEM_EVT_QUEUE, SYS_CMD_BUF, TL_DEVICE_INFO_TABLE, TL_SYS_TABLE}; | 11 | use crate::{Ipcc, SYS_CMD_BUF, SYSTEM_EVT_QUEUE, TL_DEVICE_INFO_TABLE, TL_SYS_TABLE, channels}; |
| 12 | 12 | ||
| 13 | /// A guard that, once constructed, allows for sys commands to be sent to CPU2. | 13 | /// A guard that, once constructed, allows for sys commands to be sent to CPU2. |
| 14 | pub struct Sys { | 14 | pub struct Sys { |
| @@ -35,11 +35,7 @@ impl Sys { | |||
| 35 | let info = unsafe { TL_DEVICE_INFO_TABLE.as_mut_ptr().read_volatile().wireless_fw_info_table }; | 35 | let info = unsafe { TL_DEVICE_INFO_TABLE.as_mut_ptr().read_volatile().wireless_fw_info_table }; |
| 36 | 36 | ||
| 37 | // Zero version indicates that CPU2 wasn't active and didn't fill the information table | 37 | // Zero version indicates that CPU2 wasn't active and didn't fill the information table |
| 38 | if info.version != 0 { | 38 | if info.version != 0 { Some(info) } else { None } |
| 39 | Some(info) | ||
| 40 | } else { | ||
| 41 | None | ||
| 42 | } | ||
| 43 | } | 39 | } |
| 44 | 40 | ||
| 45 | pub async fn write(&self, opcode: ShciOpcode, payload: &[u8]) { | 41 | pub async fn write(&self, opcode: ShciOpcode, payload: &[u8]) { |
| @@ -66,8 +62,8 @@ impl Sys { | |||
| 66 | #[cfg(feature = "mac")] | 62 | #[cfg(feature = "mac")] |
| 67 | pub async fn shci_c2_mac_802_15_4_init(&self) -> Result<SchiCommandStatus, ()> { | 63 | pub async fn shci_c2_mac_802_15_4_init(&self) -> Result<SchiCommandStatus, ()> { |
| 68 | use crate::tables::{ | 64 | use crate::tables::{ |
| 69 | Mac802_15_4Table, TracesTable, MAC_802_15_4_CMD_BUFFER, MAC_802_15_4_NOTIF_RSP_EVT_BUFFER, | 65 | MAC_802_15_4_CMD_BUFFER, MAC_802_15_4_NOTIF_RSP_EVT_BUFFER, Mac802_15_4Table, TL_MAC_802_15_4_TABLE, |
| 70 | TL_MAC_802_15_4_TABLE, TL_TRACES_TABLE, TRACES_EVT_QUEUE, | 66 | TL_TRACES_TABLE, TRACES_EVT_QUEUE, TracesTable, |
| 71 | }; | 67 | }; |
| 72 | 68 | ||
| 73 | unsafe { | 69 | unsafe { |
diff --git a/embassy-stm32-wpan/src/tables.rs b/embassy-stm32-wpan/src/tables.rs index fe6fc47a3..1dafed159 100644 --- a/embassy-stm32-wpan/src/tables.rs +++ b/embassy-stm32-wpan/src/tables.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | use core::mem::MaybeUninit; | 1 | use core::mem::MaybeUninit; |
| 2 | 2 | ||
| 3 | use aligned::{Aligned, A4}; | 3 | use aligned::{A4, Aligned}; |
| 4 | use bit_field::BitField; | 4 | use bit_field::BitField; |
| 5 | 5 | ||
| 6 | use crate::cmd::{AclDataPacket, CmdPacket}; | 6 | use crate::cmd::{AclDataPacket, CmdPacket}; |
| @@ -190,94 +190,94 @@ pub struct RefTable { | |||
| 190 | } | 190 | } |
| 191 | 191 | ||
| 192 | // --------------------- ref table --------------------- | 192 | // --------------------- ref table --------------------- |
| 193 | #[link_section = "TL_REF_TABLE"] | 193 | #[unsafe(link_section = "TL_REF_TABLE")] |
| 194 | pub static mut TL_REF_TABLE: MaybeUninit<RefTable> = MaybeUninit::uninit(); | 194 | pub static mut TL_REF_TABLE: MaybeUninit<RefTable> = MaybeUninit::uninit(); |
| 195 | 195 | ||
| 196 | #[link_section = "MB_MEM1"] | 196 | #[unsafe(link_section = "MB_MEM1")] |
| 197 | pub static mut TL_DEVICE_INFO_TABLE: Aligned<A4, MaybeUninit<DeviceInfoTable>> = Aligned(MaybeUninit::uninit()); | 197 | pub static mut TL_DEVICE_INFO_TABLE: Aligned<A4, MaybeUninit<DeviceInfoTable>> = Aligned(MaybeUninit::uninit()); |
| 198 | 198 | ||
| 199 | #[link_section = "MB_MEM1"] | 199 | #[unsafe(link_section = "MB_MEM1")] |
| 200 | pub static mut TL_BLE_TABLE: Aligned<A4, MaybeUninit<BleTable>> = Aligned(MaybeUninit::uninit()); | 200 | pub static mut TL_BLE_TABLE: Aligned<A4, MaybeUninit<BleTable>> = Aligned(MaybeUninit::uninit()); |
| 201 | 201 | ||
| 202 | #[link_section = "MB_MEM1"] | 202 | #[unsafe(link_section = "MB_MEM1")] |
| 203 | pub static mut TL_THREAD_TABLE: Aligned<A4, MaybeUninit<ThreadTable>> = Aligned(MaybeUninit::uninit()); | 203 | pub static mut TL_THREAD_TABLE: Aligned<A4, MaybeUninit<ThreadTable>> = Aligned(MaybeUninit::uninit()); |
| 204 | 204 | ||
| 205 | #[link_section = "MB_MEM1"] | 205 | #[unsafe(link_section = "MB_MEM1")] |
| 206 | pub static mut TL_LLD_TESTS_TABLE: Aligned<A4, MaybeUninit<LldTestsTable>> = Aligned(MaybeUninit::uninit()); | 206 | pub static mut TL_LLD_TESTS_TABLE: Aligned<A4, MaybeUninit<LldTestsTable>> = Aligned(MaybeUninit::uninit()); |
| 207 | 207 | ||
| 208 | #[link_section = "MB_MEM1"] | 208 | #[unsafe(link_section = "MB_MEM1")] |
| 209 | pub static mut TL_BLE_LLD_TABLE: Aligned<A4, MaybeUninit<BleLldTable>> = Aligned(MaybeUninit::uninit()); | 209 | pub static mut TL_BLE_LLD_TABLE: Aligned<A4, MaybeUninit<BleLldTable>> = Aligned(MaybeUninit::uninit()); |
| 210 | 210 | ||
| 211 | #[link_section = "MB_MEM1"] | 211 | #[unsafe(link_section = "MB_MEM1")] |
| 212 | pub static mut TL_SYS_TABLE: Aligned<A4, MaybeUninit<SysTable>> = Aligned(MaybeUninit::uninit()); | 212 | pub static mut TL_SYS_TABLE: Aligned<A4, MaybeUninit<SysTable>> = Aligned(MaybeUninit::uninit()); |
| 213 | 213 | ||
| 214 | #[link_section = "MB_MEM1"] | 214 | #[unsafe(link_section = "MB_MEM1")] |
| 215 | pub static mut TL_MEM_MANAGER_TABLE: Aligned<A4, MaybeUninit<MemManagerTable>> = Aligned(MaybeUninit::uninit()); | 215 | pub static mut TL_MEM_MANAGER_TABLE: Aligned<A4, MaybeUninit<MemManagerTable>> = Aligned(MaybeUninit::uninit()); |
| 216 | 216 | ||
| 217 | #[link_section = "MB_MEM1"] | 217 | #[unsafe(link_section = "MB_MEM1")] |
| 218 | pub static mut TL_TRACES_TABLE: Aligned<A4, MaybeUninit<TracesTable>> = Aligned(MaybeUninit::uninit()); | 218 | pub static mut TL_TRACES_TABLE: Aligned<A4, MaybeUninit<TracesTable>> = Aligned(MaybeUninit::uninit()); |
| 219 | 219 | ||
| 220 | #[link_section = "MB_MEM1"] | 220 | #[unsafe(link_section = "MB_MEM1")] |
| 221 | pub static mut TL_MAC_802_15_4_TABLE: Aligned<A4, MaybeUninit<Mac802_15_4Table>> = Aligned(MaybeUninit::uninit()); | 221 | pub static mut TL_MAC_802_15_4_TABLE: Aligned<A4, MaybeUninit<Mac802_15_4Table>> = Aligned(MaybeUninit::uninit()); |
| 222 | 222 | ||
| 223 | #[link_section = "MB_MEM1"] | 223 | #[unsafe(link_section = "MB_MEM1")] |
| 224 | pub static mut TL_ZIGBEE_TABLE: Aligned<A4, MaybeUninit<ZigbeeTable>> = Aligned(MaybeUninit::uninit()); | 224 | pub static mut TL_ZIGBEE_TABLE: Aligned<A4, MaybeUninit<ZigbeeTable>> = Aligned(MaybeUninit::uninit()); |
| 225 | 225 | ||
| 226 | // --------------------- tables --------------------- | 226 | // --------------------- tables --------------------- |
| 227 | #[link_section = "MB_MEM1"] | 227 | #[unsafe(link_section = "MB_MEM1")] |
| 228 | pub static mut FREE_BUF_QUEUE: Aligned<A4, MaybeUninit<LinkedListNode>> = Aligned(MaybeUninit::uninit()); | 228 | pub static mut FREE_BUF_QUEUE: Aligned<A4, MaybeUninit<LinkedListNode>> = Aligned(MaybeUninit::uninit()); |
| 229 | 229 | ||
| 230 | #[allow(dead_code)] | 230 | #[allow(dead_code)] |
| 231 | #[link_section = "MB_MEM1"] | 231 | #[unsafe(link_section = "MB_MEM1")] |
| 232 | pub static mut TRACES_EVT_QUEUE: Aligned<A4, MaybeUninit<LinkedListNode>> = Aligned(MaybeUninit::uninit()); | 232 | pub static mut TRACES_EVT_QUEUE: Aligned<A4, MaybeUninit<LinkedListNode>> = Aligned(MaybeUninit::uninit()); |
| 233 | 233 | ||
| 234 | #[link_section = "MB_MEM2"] | 234 | #[unsafe(link_section = "MB_MEM2")] |
| 235 | pub static mut CS_BUFFER: Aligned<A4, MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + TL_CS_EVT_SIZE]>> = | 235 | pub static mut CS_BUFFER: Aligned<A4, MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + TL_CS_EVT_SIZE]>> = |
| 236 | Aligned(MaybeUninit::uninit()); | 236 | Aligned(MaybeUninit::uninit()); |
| 237 | 237 | ||
| 238 | #[link_section = "MB_MEM2"] | 238 | #[unsafe(link_section = "MB_MEM2")] |
| 239 | pub static mut EVT_QUEUE: Aligned<A4, MaybeUninit<LinkedListNode>> = Aligned(MaybeUninit::uninit()); | 239 | pub static mut EVT_QUEUE: Aligned<A4, MaybeUninit<LinkedListNode>> = Aligned(MaybeUninit::uninit()); |
| 240 | 240 | ||
| 241 | #[link_section = "MB_MEM2"] | 241 | #[unsafe(link_section = "MB_MEM2")] |
| 242 | pub static mut SYSTEM_EVT_QUEUE: Aligned<A4, MaybeUninit<LinkedListNode>> = Aligned(MaybeUninit::uninit()); | 242 | pub static mut SYSTEM_EVT_QUEUE: Aligned<A4, MaybeUninit<LinkedListNode>> = Aligned(MaybeUninit::uninit()); |
| 243 | 243 | ||
| 244 | // --------------------- app tables --------------------- | 244 | // --------------------- app tables --------------------- |
| 245 | #[cfg(feature = "mac")] | 245 | #[cfg(feature = "mac")] |
| 246 | #[link_section = "MB_MEM2"] | 246 | #[unsafe(link_section = "MB_MEM2")] |
| 247 | pub static mut MAC_802_15_4_CMD_BUFFER: Aligned<A4, MaybeUninit<CmdPacket>> = Aligned(MaybeUninit::uninit()); | 247 | pub static mut MAC_802_15_4_CMD_BUFFER: Aligned<A4, MaybeUninit<CmdPacket>> = Aligned(MaybeUninit::uninit()); |
| 248 | 248 | ||
| 249 | #[cfg(feature = "mac")] | 249 | #[cfg(feature = "mac")] |
| 250 | #[link_section = "MB_MEM2"] | 250 | #[unsafe(link_section = "MB_MEM2")] |
| 251 | pub static mut MAC_802_15_4_NOTIF_RSP_EVT_BUFFER: MaybeUninit< | 251 | pub static mut MAC_802_15_4_NOTIF_RSP_EVT_BUFFER: MaybeUninit< |
| 252 | Aligned<A4, [u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>, | 252 | Aligned<A4, [u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>, |
| 253 | > = MaybeUninit::uninit(); | 253 | > = MaybeUninit::uninit(); |
| 254 | 254 | ||
| 255 | #[link_section = "MB_MEM2"] | 255 | #[unsafe(link_section = "MB_MEM2")] |
| 256 | pub static mut EVT_POOL: Aligned<A4, MaybeUninit<[u8; POOL_SIZE]>> = Aligned(MaybeUninit::uninit()); | 256 | pub static mut EVT_POOL: Aligned<A4, MaybeUninit<[u8; POOL_SIZE]>> = Aligned(MaybeUninit::uninit()); |
| 257 | 257 | ||
| 258 | #[link_section = "MB_MEM2"] | 258 | #[unsafe(link_section = "MB_MEM2")] |
| 259 | pub static mut SYS_CMD_BUF: Aligned<A4, MaybeUninit<CmdPacket>> = Aligned(MaybeUninit::uninit()); | 259 | pub static mut SYS_CMD_BUF: Aligned<A4, MaybeUninit<CmdPacket>> = Aligned(MaybeUninit::uninit()); |
| 260 | 260 | ||
| 261 | #[link_section = "MB_MEM2"] | 261 | #[unsafe(link_section = "MB_MEM2")] |
| 262 | pub static mut SYS_SPARE_EVT_BUF: Aligned<A4, MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>> = | 262 | pub static mut SYS_SPARE_EVT_BUF: Aligned<A4, MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>> = |
| 263 | Aligned(MaybeUninit::uninit()); | 263 | Aligned(MaybeUninit::uninit()); |
| 264 | 264 | ||
| 265 | #[cfg(feature = "mac")] | 265 | #[cfg(feature = "mac")] |
| 266 | #[link_section = "MB_MEM2"] | 266 | #[unsafe(link_section = "MB_MEM2")] |
| 267 | pub static mut MAC_802_15_4_CNFINDNOT: Aligned<A4, MaybeUninit<[u8; C_SIZE_CMD_STRING]>> = | 267 | pub static mut MAC_802_15_4_CNFINDNOT: Aligned<A4, MaybeUninit<[u8; C_SIZE_CMD_STRING]>> = |
| 268 | Aligned(MaybeUninit::uninit()); | 268 | Aligned(MaybeUninit::uninit()); |
| 269 | 269 | ||
| 270 | #[cfg(feature = "ble")] | 270 | #[cfg(feature = "ble")] |
| 271 | #[link_section = "MB_MEM1"] | 271 | #[unsafe(link_section = "MB_MEM1")] |
| 272 | pub static mut BLE_CMD_BUFFER: Aligned<A4, MaybeUninit<CmdPacket>> = Aligned(MaybeUninit::uninit()); | 272 | pub static mut BLE_CMD_BUFFER: Aligned<A4, MaybeUninit<CmdPacket>> = Aligned(MaybeUninit::uninit()); |
| 273 | 273 | ||
| 274 | #[cfg(feature = "ble")] | 274 | #[cfg(feature = "ble")] |
| 275 | #[link_section = "MB_MEM2"] | 275 | #[unsafe(link_section = "MB_MEM2")] |
| 276 | pub static mut BLE_SPARE_EVT_BUF: Aligned<A4, MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>> = | 276 | pub static mut BLE_SPARE_EVT_BUF: Aligned<A4, MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>> = |
| 277 | Aligned(MaybeUninit::uninit()); | 277 | Aligned(MaybeUninit::uninit()); |
| 278 | 278 | ||
| 279 | #[cfg(feature = "ble")] | 279 | #[cfg(feature = "ble")] |
| 280 | #[link_section = "MB_MEM2"] | 280 | #[unsafe(link_section = "MB_MEM2")] |
| 281 | // fuck these "magic" numbers from ST ---v---v | 281 | // fuck these "magic" numbers from ST ---v---v |
| 282 | pub static mut HCI_ACL_DATA_BUFFER: Aligned<A4, MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + 5 + 251]>> = | 282 | pub static mut HCI_ACL_DATA_BUFFER: Aligned<A4, MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + 5 + 251]>> = |
| 283 | Aligned(MaybeUninit::uninit()); | 283 | Aligned(MaybeUninit::uninit()); |
diff --git a/embassy-stm32/CHANGELOG.md b/embassy-stm32/CHANGELOG.md index 835d9c704..a6ee5c4b8 100644 --- a/embassy-stm32/CHANGELOG.md +++ b/embassy-stm32/CHANGELOG.md | |||
| @@ -25,6 +25,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
| 25 | - feat: Add USB CRS sync support for STM32C071 | 25 | - feat: Add USB CRS sync support for STM32C071 |
| 26 | - fix: RTC register definition for STM32L4P5 and L4Q5 as they use v3 register map. | 26 | - fix: RTC register definition for STM32L4P5 and L4Q5 as they use v3 register map. |
| 27 | - fix: Cut down the capabilities of the STM32L412 and L422 RTC as those are missing binary timer mode and underflow interrupt. | 27 | - fix: Cut down the capabilities of the STM32L412 and L422 RTC as those are missing binary timer mode and underflow interrupt. |
| 28 | - fix: Allow configuration of the internal pull up/down resistors on the pins for the Qei peripheral, as well as the Qei decoder mode. | ||
| 29 | - feat: stm32/rcc/mco: Added support for IO driver strength when using Master Clock Out IO. This changes signature on Mco::new taking a McoConfig struct ([#4679](https://github.com/embassy-rs/embassy/pull/4679)) | ||
| 30 | - feat: derive Clone, Copy and defmt::Format for all SPI-related configs | ||
| 31 | - feat: stm32/usart: add `eager_reads` option to control if buffered readers return as soon as possible or after more data is available ([#4668](https://github.com/embassy-rs/embassy/pull/4668)) | ||
| 32 | - feat: stm32/usart: add `de_assertion_time` and `de_deassertion_time` config options | ||
| 33 | - change: stm32/uart: BufferedUartRx now returns all available bytes from the internal buffer | ||
| 28 | 34 | ||
| 29 | ## 0.4.0 - 2025-08-26 | 35 | ## 0.4.0 - 2025-08-26 |
| 30 | 36 | ||
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 82bc73708..7c243b350 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-stm32" | 2 | name = "embassy-stm32" |
| 3 | version = "0.4.0" | 3 | version = "0.4.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | description = "Embassy Hardware Abstraction Layer (HAL) for ST STM32 series microcontrollers" | 6 | description = "Embassy Hardware Abstraction Layer (HAL) for ST STM32 series microcontrollers" |
| 7 | keywords = ["embedded", "async", "stm32", "hal", "embedded-hal"] | 7 | keywords = ["embedded", "async", "stm32", "hal", "embedded-hal"] |
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index b5f1261fe..eea1acf68 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs | |||
| @@ -9,8 +9,8 @@ use proc_macro2::{Ident, TokenStream}; | |||
| 9 | use quote::{format_ident, quote}; | 9 | use quote::{format_ident, quote}; |
| 10 | use stm32_metapac::metadata::ir::BitOffset; | 10 | use stm32_metapac::metadata::ir::BitOffset; |
| 11 | use stm32_metapac::metadata::{ | 11 | use stm32_metapac::metadata::{ |
| 12 | MemoryRegion, MemoryRegionKind, PeripheralRccKernelClock, PeripheralRccRegister, PeripheralRegisters, StopMode, | 12 | ALL_CHIPS, ALL_PERIPHERAL_VERSIONS, METADATA, MemoryRegion, MemoryRegionKind, PeripheralRccKernelClock, |
| 13 | ALL_CHIPS, ALL_PERIPHERAL_VERSIONS, METADATA, | 13 | PeripheralRccRegister, PeripheralRegisters, StopMode, |
| 14 | }; | 14 | }; |
| 15 | 15 | ||
| 16 | #[path = "./build_common.rs"] | 16 | #[path = "./build_common.rs"] |
| @@ -105,7 +105,9 @@ fn main() { | |||
| 105 | } | 105 | } |
| 106 | (false, false) => { | 106 | (false, false) => { |
| 107 | if METADATA.memory.len() != 1 { | 107 | if METADATA.memory.len() != 1 { |
| 108 | panic!("Chip supports single and dual bank configuration. No Cargo feature to select one is enabled. Use the 'single-bank' or 'dual-bank' feature to make your selection") | 108 | panic!( |
| 109 | "Chip supports single and dual bank configuration. No Cargo feature to select one is enabled. Use the 'single-bank' or 'dual-bank' feature to make your selection" | ||
| 110 | ) | ||
| 109 | } | 111 | } |
| 110 | METADATA.memory[0] | 112 | METADATA.memory[0] |
| 111 | } | 113 | } |
diff --git a/embassy-stm32/src/adc/adc4.rs b/embassy-stm32/src/adc/adc4.rs index 255dc7956..2608160a3 100644 --- a/embassy-stm32/src/adc/adc4.rs +++ b/embassy-stm32/src/adc/adc4.rs | |||
| @@ -4,7 +4,7 @@ use pac::adc::vals::{Adc4Dmacfg as Dmacfg, Adc4Exten as Exten, Adc4OversamplingR | |||
| 4 | #[cfg(stm32wba)] | 4 | #[cfg(stm32wba)] |
| 5 | use pac::adc::vals::{Chselrmod, Cont, Dmacfg, Exten, OversamplingRatio, Ovss, Smpsel}; | 5 | use pac::adc::vals::{Chselrmod, Cont, Dmacfg, Exten, OversamplingRatio, Ovss, Smpsel}; |
| 6 | 6 | ||
| 7 | use super::{blocking_delay_us, AdcChannel, AnyAdcChannel, RxDma4, SealedAdcChannel}; | 7 | use super::{AdcChannel, AnyAdcChannel, RxDma4, SealedAdcChannel, blocking_delay_us}; |
| 8 | use crate::dma::Transfer; | 8 | use crate::dma::Transfer; |
| 9 | #[cfg(stm32u5)] | 9 | #[cfg(stm32u5)] |
| 10 | pub use crate::pac::adc::regs::Adc4Chselrmod0 as Chselr; | 10 | pub use crate::pac::adc::regs::Adc4Chselrmod0 as Chselr; |
| @@ -15,7 +15,7 @@ pub use crate::pac::adc::vals::{Adc4Presc as Presc, Adc4Res as Resolution, Adc4S | |||
| 15 | #[cfg(stm32wba)] | 15 | #[cfg(stm32wba)] |
| 16 | pub use crate::pac::adc::vals::{Presc, Res as Resolution, SampleTime}; | 16 | pub use crate::pac::adc::vals::{Presc, Res as Resolution, SampleTime}; |
| 17 | use crate::time::Hertz; | 17 | use crate::time::Hertz; |
| 18 | use crate::{pac, rcc, Peri}; | 18 | use crate::{Peri, pac, rcc}; |
| 19 | 19 | ||
| 20 | const MAX_ADC_CLK_FREQ: Hertz = Hertz::mhz(55); | 20 | const MAX_ADC_CLK_FREQ: Hertz = Hertz::mhz(55); |
| 21 | 21 | ||
| @@ -208,7 +208,10 @@ impl<'d, T: Instance> Adc4<'d, T> { | |||
| 208 | info!("ADC4 frequency set to {}", frequency); | 208 | info!("ADC4 frequency set to {}", frequency); |
| 209 | 209 | ||
| 210 | if frequency > MAX_ADC_CLK_FREQ { | 210 | if frequency > MAX_ADC_CLK_FREQ { |
| 211 | panic!("Maximal allowed frequency for ADC4 is {} MHz and it varies with different packages, refer to ST docs for more information.", MAX_ADC_CLK_FREQ.0 / 1_000_000 ); | 211 | panic!( |
| 212 | "Maximal allowed frequency for ADC4 is {} MHz and it varies with different packages, refer to ST docs for more information.", | ||
| 213 | MAX_ADC_CLK_FREQ.0 / 1_000_000 | ||
| 214 | ); | ||
| 212 | } | 215 | } |
| 213 | 216 | ||
| 214 | let mut s = Self { adc }; | 217 | let mut s = Self { adc }; |
diff --git a/embassy-stm32/src/adc/c0.rs b/embassy-stm32/src/adc/c0.rs index f2837a8f1..fc28df346 100644 --- a/embassy-stm32/src/adc/c0.rs +++ b/embassy-stm32/src/adc/c0.rs | |||
| @@ -4,11 +4,11 @@ use pac::adc::vals::{Adstp, Align, Ckmode, Dmacfg, Exten, Ovrmod, Ovsr}; | |||
| 4 | use pac::adccommon::vals::Presc; | 4 | use pac::adccommon::vals::Presc; |
| 5 | 5 | ||
| 6 | use super::{ | 6 | use super::{ |
| 7 | blocking_delay_us, Adc, AdcChannel, AnyAdcChannel, Instance, Resolution, RxDma, SampleTime, SealedAdcChannel, | 7 | Adc, AdcChannel, AnyAdcChannel, Instance, Resolution, RxDma, SampleTime, SealedAdcChannel, blocking_delay_us, |
| 8 | }; | 8 | }; |
| 9 | use crate::dma::Transfer; | 9 | use crate::dma::Transfer; |
| 10 | use crate::time::Hertz; | 10 | use crate::time::Hertz; |
| 11 | use crate::{pac, rcc, Peri}; | 11 | use crate::{Peri, pac, rcc}; |
| 12 | 12 | ||
| 13 | /// Default VREF voltage used for sample conversion to millivolts. | 13 | /// Default VREF voltage used for sample conversion to millivolts. |
| 14 | pub const VREF_DEFAULT_MV: u32 = 3300; | 14 | pub const VREF_DEFAULT_MV: u32 = 3300; |
| @@ -168,7 +168,10 @@ impl<'d, T: Instance> Adc<'d, T> { | |||
| 168 | debug!("ADC frequency set to {}", frequency); | 168 | debug!("ADC frequency set to {}", frequency); |
| 169 | 169 | ||
| 170 | if frequency > MAX_ADC_CLK_FREQ { | 170 | if frequency > MAX_ADC_CLK_FREQ { |
| 171 | panic!("Maximal allowed frequency for the ADC is {} MHz and it varies with different packages, refer to ST docs for more information.", MAX_ADC_CLK_FREQ.0 / 1_000_000 ); | 171 | panic!( |
| 172 | "Maximal allowed frequency for the ADC is {} MHz and it varies with different packages, refer to ST docs for more information.", | ||
| 173 | MAX_ADC_CLK_FREQ.0 / 1_000_000 | ||
| 174 | ); | ||
| 172 | } | 175 | } |
| 173 | 176 | ||
| 174 | let mut s = Self { | 177 | let mut s = Self { |
diff --git a/embassy-stm32/src/adc/f1.rs b/embassy-stm32/src/adc/f1.rs index 3cdc9d8fb..f9c23d72b 100644 --- a/embassy-stm32/src/adc/f1.rs +++ b/embassy-stm32/src/adc/f1.rs | |||
| @@ -7,7 +7,7 @@ use crate::adc::{Adc, AdcChannel, Instance, SampleTime}; | |||
| 7 | use crate::interrupt::typelevel::Interrupt; | 7 | use crate::interrupt::typelevel::Interrupt; |
| 8 | use crate::interrupt::{self}; | 8 | use crate::interrupt::{self}; |
| 9 | use crate::time::Hertz; | 9 | use crate::time::Hertz; |
| 10 | use crate::{rcc, Peri}; | 10 | use crate::{Peri, rcc}; |
| 11 | 11 | ||
| 12 | pub const VDDA_CALIB_MV: u32 = 3300; | 12 | pub const VDDA_CALIB_MV: u32 = 3300; |
| 13 | pub const ADC_MAX: u32 = (1 << 12) - 1; | 13 | pub const ADC_MAX: u32 = (1 << 12) - 1; |
diff --git a/embassy-stm32/src/adc/f3.rs b/embassy-stm32/src/adc/f3.rs index 3aeb6f2c7..73ceb087a 100644 --- a/embassy-stm32/src/adc/f3.rs +++ b/embassy-stm32/src/adc/f3.rs | |||
| @@ -6,7 +6,7 @@ use super::blocking_delay_us; | |||
| 6 | use crate::adc::{Adc, AdcChannel, Instance, SampleTime}; | 6 | use crate::adc::{Adc, AdcChannel, Instance, SampleTime}; |
| 7 | use crate::interrupt::typelevel::Interrupt; | 7 | use crate::interrupt::typelevel::Interrupt; |
| 8 | use crate::time::Hertz; | 8 | use crate::time::Hertz; |
| 9 | use crate::{interrupt, rcc, Peri}; | 9 | use crate::{Peri, interrupt, rcc}; |
| 10 | 10 | ||
| 11 | pub const VDDA_CALIB_MV: u32 = 3300; | 11 | pub const VDDA_CALIB_MV: u32 = 3300; |
| 12 | pub const ADC_MAX: u32 = (1 << 12) - 1; | 12 | pub const ADC_MAX: u32 = (1 << 12) - 1; |
diff --git a/embassy-stm32/src/adc/f3_v1_1.rs b/embassy-stm32/src/adc/f3_v1_1.rs index 84613078c..cd5de54f5 100644 --- a/embassy-stm32/src/adc/f3_v1_1.rs +++ b/embassy-stm32/src/adc/f3_v1_1.rs | |||
| @@ -9,7 +9,7 @@ use super::Resolution; | |||
| 9 | use crate::adc::{Adc, AdcChannel, Instance, SampleTime}; | 9 | use crate::adc::{Adc, AdcChannel, Instance, SampleTime}; |
| 10 | use crate::interrupt::typelevel::Interrupt; | 10 | use crate::interrupt::typelevel::Interrupt; |
| 11 | use crate::time::Hertz; | 11 | use crate::time::Hertz; |
| 12 | use crate::{interrupt, rcc, Peri}; | 12 | use crate::{Peri, interrupt, rcc}; |
| 13 | 13 | ||
| 14 | const ADC_FREQ: Hertz = crate::rcc::HSI_FREQ; | 14 | const ADC_FREQ: Hertz = crate::rcc::HSI_FREQ; |
| 15 | 15 | ||
diff --git a/embassy-stm32/src/adc/g4.rs b/embassy-stm32/src/adc/g4.rs index 43498966f..5098aadd8 100644 --- a/embassy-stm32/src/adc/g4.rs +++ b/embassy-stm32/src/adc/g4.rs | |||
| @@ -7,11 +7,11 @@ use pac::adc::vals::{Adcaldif, Difsel, Exten, Rovsm, Trovs}; | |||
| 7 | use pac::adccommon::vals::Presc; | 7 | use pac::adccommon::vals::Presc; |
| 8 | use stm32_metapac::adc::vals::{Adstp, Dmacfg, Dmaen}; | 8 | use stm32_metapac::adc::vals::{Adstp, Dmacfg, Dmaen}; |
| 9 | 9 | ||
| 10 | use super::{blocking_delay_us, Adc, AdcChannel, AnyAdcChannel, Instance, Resolution, RxDma, SampleTime}; | 10 | use super::{Adc, AdcChannel, AnyAdcChannel, Instance, Resolution, RxDma, SampleTime, blocking_delay_us}; |
| 11 | use crate::adc::SealedAdcChannel; | 11 | use crate::adc::SealedAdcChannel; |
| 12 | use crate::dma::Transfer; | 12 | use crate::dma::Transfer; |
| 13 | use crate::time::Hertz; | 13 | use crate::time::Hertz; |
| 14 | use crate::{pac, rcc, Peri}; | 14 | use crate::{Peri, pac, rcc}; |
| 15 | 15 | ||
| 16 | /// Default VREF voltage used for sample conversion to millivolts. | 16 | /// Default VREF voltage used for sample conversion to millivolts. |
| 17 | pub const VREF_DEFAULT_MV: u32 = 3300; | 17 | pub const VREF_DEFAULT_MV: u32 = 3300; |
| @@ -133,7 +133,10 @@ impl<'d, T: Instance> Adc<'d, T> { | |||
| 133 | trace!("ADC frequency set to {}", frequency); | 133 | trace!("ADC frequency set to {}", frequency); |
| 134 | 134 | ||
| 135 | if frequency > MAX_ADC_CLK_FREQ { | 135 | if frequency > MAX_ADC_CLK_FREQ { |
| 136 | panic!("Maximal allowed frequency for the ADC is {} MHz and it varies with different packages, refer to ST docs for more information.", MAX_ADC_CLK_FREQ.0 / 1_000_000 ); | 136 | panic!( |
| 137 | "Maximal allowed frequency for the ADC is {} MHz and it varies with different packages, refer to ST docs for more information.", | ||
| 138 | MAX_ADC_CLK_FREQ.0 / 1_000_000 | ||
| 139 | ); | ||
| 137 | } | 140 | } |
| 138 | 141 | ||
| 139 | let mut s = Self { | 142 | let mut s = Self { |
diff --git a/embassy-stm32/src/adc/mod.rs b/embassy-stm32/src/adc/mod.rs index ea986f4cf..22ed8295f 100644 --- a/embassy-stm32/src/adc/mod.rs +++ b/embassy-stm32/src/adc/mod.rs | |||
| @@ -22,7 +22,7 @@ use core::marker::PhantomData; | |||
| 22 | #[allow(unused)] | 22 | #[allow(unused)] |
| 23 | #[cfg(not(any(adc_f3v3, adc_wba)))] | 23 | #[cfg(not(any(adc_f3v3, adc_wba)))] |
| 24 | pub use _version::*; | 24 | pub use _version::*; |
| 25 | use embassy_hal_internal::{impl_peripheral, PeripheralType}; | 25 | use embassy_hal_internal::{PeripheralType, impl_peripheral}; |
| 26 | #[cfg(any(adc_f1, adc_f3v1, adc_v1, adc_l0, adc_f3v2))] | 26 | #[cfg(any(adc_f1, adc_f3v1, adc_v1, adc_l0, adc_f3v2))] |
| 27 | use embassy_sync::waitqueue::AtomicWaker; | 27 | use embassy_sync::waitqueue::AtomicWaker; |
| 28 | 28 | ||
diff --git a/embassy-stm32/src/adc/ringbuffered_v2.rs b/embassy-stm32/src/adc/ringbuffered_v2.rs index 6f69e8486..9b2e5b8fe 100644 --- a/embassy-stm32/src/adc/ringbuffered_v2.rs +++ b/embassy-stm32/src/adc/ringbuffered_v2.rs | |||
| @@ -1,13 +1,13 @@ | |||
| 1 | use core::marker::PhantomData; | 1 | use core::marker::PhantomData; |
| 2 | use core::mem; | 2 | use core::mem; |
| 3 | use core::sync::atomic::{compiler_fence, Ordering}; | 3 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 4 | 4 | ||
| 5 | use stm32_metapac::adc::vals::SampleTime; | 5 | use stm32_metapac::adc::vals::SampleTime; |
| 6 | 6 | ||
| 7 | use crate::adc::{Adc, AdcChannel, Instance, RxDma}; | 7 | use crate::adc::{Adc, AdcChannel, Instance, RxDma}; |
| 8 | use crate::dma::{Priority, ReadableRingBuffer, TransferOptions}; | 8 | use crate::dma::{Priority, ReadableRingBuffer, TransferOptions}; |
| 9 | use crate::pac::adc::vals; | 9 | use crate::pac::adc::vals; |
| 10 | use crate::{rcc, Peri}; | 10 | use crate::{Peri, rcc}; |
| 11 | 11 | ||
| 12 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 12 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 13 | pub struct OverrunError; | 13 | pub struct OverrunError; |
diff --git a/embassy-stm32/src/adc/v1.rs b/embassy-stm32/src/adc/v1.rs index d09374876..a5869d110 100644 --- a/embassy-stm32/src/adc/v1.rs +++ b/embassy-stm32/src/adc/v1.rs | |||
| @@ -9,7 +9,7 @@ use super::blocking_delay_us; | |||
| 9 | use crate::adc::{Adc, AdcChannel, Instance, Resolution, SampleTime}; | 9 | use crate::adc::{Adc, AdcChannel, Instance, Resolution, SampleTime}; |
| 10 | use crate::interrupt::typelevel::Interrupt; | 10 | use crate::interrupt::typelevel::Interrupt; |
| 11 | use crate::peripherals::ADC1; | 11 | use crate::peripherals::ADC1; |
| 12 | use crate::{interrupt, rcc, Peri}; | 12 | use crate::{Peri, interrupt, rcc}; |
| 13 | 13 | ||
| 14 | mod watchdog_v1; | 14 | mod watchdog_v1; |
| 15 | pub use watchdog_v1::WatchdogChannels; | 15 | pub use watchdog_v1::WatchdogChannels; |
| @@ -66,11 +66,7 @@ pub struct Temperature; | |||
| 66 | impl AdcChannel<ADC1> for Temperature {} | 66 | impl AdcChannel<ADC1> for Temperature {} |
| 67 | impl super::SealedAdcChannel<ADC1> for Temperature { | 67 | impl super::SealedAdcChannel<ADC1> for Temperature { |
| 68 | fn channel(&self) -> u8 { | 68 | fn channel(&self) -> u8 { |
| 69 | if cfg!(adc_l0) { | 69 | if cfg!(adc_l0) { 18 } else { 16 } |
| 70 | 18 | ||
| 71 | } else { | ||
| 72 | 16 | ||
| 73 | } | ||
| 74 | } | 70 | } |
| 75 | } | 71 | } |
| 76 | 72 | ||
diff --git a/embassy-stm32/src/adc/v2.rs b/embassy-stm32/src/adc/v2.rs index e94a25b24..93ec78548 100644 --- a/embassy-stm32/src/adc/v2.rs +++ b/embassy-stm32/src/adc/v2.rs | |||
| @@ -2,7 +2,7 @@ use super::blocking_delay_us; | |||
| 2 | use crate::adc::{Adc, AdcChannel, Instance, Resolution, SampleTime}; | 2 | use crate::adc::{Adc, AdcChannel, Instance, Resolution, SampleTime}; |
| 3 | use crate::peripherals::ADC1; | 3 | use crate::peripherals::ADC1; |
| 4 | use crate::time::Hertz; | 4 | use crate::time::Hertz; |
| 5 | use crate::{rcc, Peri}; | 5 | use crate::{Peri, rcc}; |
| 6 | 6 | ||
| 7 | mod ringbuffered_v2; | 7 | mod ringbuffered_v2; |
| 8 | pub use ringbuffered_v2::{RingBufferedAdc, Sequence}; | 8 | pub use ringbuffered_v2::{RingBufferedAdc, Sequence}; |
diff --git a/embassy-stm32/src/adc/v3.rs b/embassy-stm32/src/adc/v3.rs index 16063ce4d..47632263b 100644 --- a/embassy-stm32/src/adc/v3.rs +++ b/embassy-stm32/src/adc/v3.rs | |||
| @@ -10,10 +10,10 @@ use pac::adc::vals::{OversamplingRatio, OversamplingShift, Rovsm, Trovs}; | |||
| 10 | pub use pac::adc::vals::{Ovsr, Ovss, Presc}; | 10 | pub use pac::adc::vals::{Ovsr, Ovss, Presc}; |
| 11 | 11 | ||
| 12 | use super::{ | 12 | use super::{ |
| 13 | blocking_delay_us, Adc, AdcChannel, AnyAdcChannel, Instance, Resolution, RxDma, SampleTime, SealedAdcChannel, | 13 | Adc, AdcChannel, AnyAdcChannel, Instance, Resolution, RxDma, SampleTime, SealedAdcChannel, blocking_delay_us, |
| 14 | }; | 14 | }; |
| 15 | use crate::dma::Transfer; | 15 | use crate::dma::Transfer; |
| 16 | use crate::{pac, rcc, Peri}; | 16 | use crate::{Peri, pac, rcc}; |
| 17 | 17 | ||
| 18 | /// Default VREF voltage used for sample conversion to millivolts. | 18 | /// Default VREF voltage used for sample conversion to millivolts. |
| 19 | pub const VREF_DEFAULT_MV: u32 = 3300; | 19 | pub const VREF_DEFAULT_MV: u32 = 3300; |
diff --git a/embassy-stm32/src/adc/v4.rs b/embassy-stm32/src/adc/v4.rs index b66437e6e..c7d0103a6 100644 --- a/embassy-stm32/src/adc/v4.rs +++ b/embassy-stm32/src/adc/v4.rs | |||
| @@ -5,11 +5,11 @@ use pac::adc::vals::{Adstp, Difsel, Dmngt, Exten, Pcsel}; | |||
| 5 | use pac::adccommon::vals::Presc; | 5 | use pac::adccommon::vals::Presc; |
| 6 | 6 | ||
| 7 | use super::{ | 7 | use super::{ |
| 8 | blocking_delay_us, Adc, AdcChannel, AnyAdcChannel, Instance, Resolution, RxDma, SampleTime, SealedAdcChannel, | 8 | Adc, AdcChannel, AnyAdcChannel, Instance, Resolution, RxDma, SampleTime, SealedAdcChannel, blocking_delay_us, |
| 9 | }; | 9 | }; |
| 10 | use crate::dma::Transfer; | 10 | use crate::dma::Transfer; |
| 11 | use crate::time::Hertz; | 11 | use crate::time::Hertz; |
| 12 | use crate::{pac, rcc, Peri}; | 12 | use crate::{Peri, pac, rcc}; |
| 13 | 13 | ||
| 14 | /// Default VREF voltage used for sample conversion to millivolts. | 14 | /// Default VREF voltage used for sample conversion to millivolts. |
| 15 | pub const VREF_DEFAULT_MV: u32 = 3300; | 15 | pub const VREF_DEFAULT_MV: u32 = 3300; |
| @@ -171,7 +171,10 @@ impl<'d, T: Instance> Adc<'d, T> { | |||
| 171 | info!("ADC frequency set to {}", frequency); | 171 | info!("ADC frequency set to {}", frequency); |
| 172 | 172 | ||
| 173 | if frequency > MAX_ADC_CLK_FREQ { | 173 | if frequency > MAX_ADC_CLK_FREQ { |
| 174 | panic!("Maximal allowed frequency for the ADC is {} MHz and it varies with different packages, refer to ST docs for more information.", MAX_ADC_CLK_FREQ.0 / 1_000_000 ); | 174 | panic!( |
| 175 | "Maximal allowed frequency for the ADC is {} MHz and it varies with different packages, refer to ST docs for more information.", | ||
| 176 | MAX_ADC_CLK_FREQ.0 / 1_000_000 | ||
| 177 | ); | ||
| 175 | } | 178 | } |
| 176 | 179 | ||
| 177 | #[cfg(stm32h7)] | 180 | #[cfg(stm32h7)] |
diff --git a/embassy-stm32/src/can/bxcan/mod.rs b/embassy-stm32/src/can/bxcan/mod.rs index 8eb188560..507350c42 100644 --- a/embassy-stm32/src/can/bxcan/mod.rs +++ b/embassy-stm32/src/can/bxcan/mod.rs | |||
| @@ -5,8 +5,8 @@ use core::future::poll_fn; | |||
| 5 | use core::marker::PhantomData; | 5 | use core::marker::PhantomData; |
| 6 | use core::task::Poll; | 6 | use core::task::Poll; |
| 7 | 7 | ||
| 8 | use embassy_hal_internal::interrupt::InterruptExt; | ||
| 9 | use embassy_hal_internal::PeripheralType; | 8 | use embassy_hal_internal::PeripheralType; |
| 9 | use embassy_hal_internal::interrupt::InterruptExt; | ||
| 10 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 10 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| 11 | use embassy_sync::channel::Channel; | 11 | use embassy_sync::channel::Channel; |
| 12 | use embassy_sync::waitqueue::AtomicWaker; | 12 | use embassy_sync::waitqueue::AtomicWaker; |
| @@ -22,7 +22,7 @@ use crate::can::enums::{BusError, RefCountOp, TryReadError}; | |||
| 22 | use crate::gpio::{AfType, OutputType, Pull, Speed}; | 22 | use crate::gpio::{AfType, OutputType, Pull, Speed}; |
| 23 | use crate::interrupt::typelevel::Interrupt; | 23 | use crate::interrupt::typelevel::Interrupt; |
| 24 | use crate::rcc::{self, RccPeripheral}; | 24 | use crate::rcc::{self, RccPeripheral}; |
| 25 | use crate::{interrupt, peripherals, Peri}; | 25 | use crate::{Peri, interrupt, peripherals}; |
| 26 | 26 | ||
| 27 | /// Interrupt handler. | 27 | /// Interrupt handler. |
| 28 | pub struct TxInterruptHandler<T: Instance> { | 28 | pub struct TxInterruptHandler<T: Instance> { |
| @@ -186,10 +186,10 @@ impl<'d> Can<'d> { | |||
| 186 | rx: Peri<'d, if_afio!(impl RxPin<T, A>)>, | 186 | rx: Peri<'d, if_afio!(impl RxPin<T, A>)>, |
| 187 | tx: Peri<'d, if_afio!(impl TxPin<T, A>)>, | 187 | tx: Peri<'d, if_afio!(impl TxPin<T, A>)>, |
| 188 | _irqs: impl interrupt::typelevel::Binding<T::TXInterrupt, TxInterruptHandler<T>> | 188 | _irqs: impl interrupt::typelevel::Binding<T::TXInterrupt, TxInterruptHandler<T>> |
| 189 | + interrupt::typelevel::Binding<T::RX0Interrupt, Rx0InterruptHandler<T>> | 189 | + interrupt::typelevel::Binding<T::RX0Interrupt, Rx0InterruptHandler<T>> |
| 190 | + interrupt::typelevel::Binding<T::RX1Interrupt, Rx1InterruptHandler<T>> | 190 | + interrupt::typelevel::Binding<T::RX1Interrupt, Rx1InterruptHandler<T>> |
| 191 | + interrupt::typelevel::Binding<T::SCEInterrupt, SceInterruptHandler<T>> | 191 | + interrupt::typelevel::Binding<T::SCEInterrupt, SceInterruptHandler<T>> |
| 192 | + 'd, | 192 | + 'd, |
| 193 | ) -> Self { | 193 | ) -> Self { |
| 194 | let info = T::info(); | 194 | let info = T::info(); |
| 195 | let regs = &T::info().regs; | 195 | let regs = &T::info().regs; |
diff --git a/embassy-stm32/src/can/fd/config.rs b/embassy-stm32/src/can/fd/config.rs index c6a66b469..e08349f02 100644 --- a/embassy-stm32/src/can/fd/config.rs +++ b/embassy-stm32/src/can/fd/config.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | //! Configuration for FDCAN Module | 1 | //! Configuration for FDCAN Module |
| 2 | // Note: This file is copied and modified from fdcan crate by Richard Meadows | 2 | // Note: This file is copied and modified from fdcan crate by Richard Meadows |
| 3 | 3 | ||
| 4 | use core::num::{NonZeroU16, NonZeroU8}; | 4 | use core::num::{NonZeroU8, NonZeroU16}; |
| 5 | 5 | ||
| 6 | /// Configures the bit timings. | 6 | /// Configures the bit timings. |
| 7 | /// | 7 | /// |
diff --git a/embassy-stm32/src/can/fdcan.rs b/embassy-stm32/src/can/fdcan.rs index d8f71e03e..a142a6d63 100644 --- a/embassy-stm32/src/can/fdcan.rs +++ b/embassy-stm32/src/can/fdcan.rs | |||
| @@ -3,8 +3,8 @@ use core::future::poll_fn; | |||
| 3 | use core::marker::PhantomData; | 3 | use core::marker::PhantomData; |
| 4 | use core::task::Poll; | 4 | use core::task::Poll; |
| 5 | 5 | ||
| 6 | use embassy_hal_internal::interrupt::InterruptExt; | ||
| 7 | use embassy_hal_internal::PeripheralType; | 6 | use embassy_hal_internal::PeripheralType; |
| 7 | use embassy_hal_internal::interrupt::InterruptExt; | ||
| 8 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 8 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| 9 | use embassy_sync::channel::Channel; | 9 | use embassy_sync::channel::Channel; |
| 10 | use embassy_sync::waitqueue::AtomicWaker; | 10 | use embassy_sync::waitqueue::AtomicWaker; |
| @@ -13,7 +13,7 @@ use crate::can::fd::peripheral::Registers; | |||
| 13 | use crate::gpio::{AfType, OutputType, Pull, SealedPin as _, Speed}; | 13 | use crate::gpio::{AfType, OutputType, Pull, SealedPin as _, Speed}; |
| 14 | use crate::interrupt::typelevel::Interrupt; | 14 | use crate::interrupt::typelevel::Interrupt; |
| 15 | use crate::rcc::{self, RccPeripheral}; | 15 | use crate::rcc::{self, RccPeripheral}; |
| 16 | use crate::{interrupt, peripherals, Peri}; | 16 | use crate::{Peri, interrupt, peripherals}; |
| 17 | 17 | ||
| 18 | pub(crate) mod fd; | 18 | pub(crate) mod fd; |
| 19 | 19 | ||
| @@ -182,8 +182,8 @@ impl<'d> CanConfigurator<'d> { | |||
| 182 | rx: Peri<'d, impl RxPin<T>>, | 182 | rx: Peri<'d, impl RxPin<T>>, |
| 183 | tx: Peri<'d, impl TxPin<T>>, | 183 | tx: Peri<'d, impl TxPin<T>>, |
| 184 | _irqs: impl interrupt::typelevel::Binding<T::IT0Interrupt, IT0InterruptHandler<T>> | 184 | _irqs: impl interrupt::typelevel::Binding<T::IT0Interrupt, IT0InterruptHandler<T>> |
| 185 | + interrupt::typelevel::Binding<T::IT1Interrupt, IT1InterruptHandler<T>> | 185 | + interrupt::typelevel::Binding<T::IT1Interrupt, IT1InterruptHandler<T>> |
| 186 | + 'd, | 186 | + 'd, |
| 187 | ) -> CanConfigurator<'d> { | 187 | ) -> CanConfigurator<'d> { |
| 188 | set_as_af!(rx, AfType::input(Pull::None)); | 188 | set_as_af!(rx, AfType::input(Pull::None)); |
| 189 | set_as_af!(tx, AfType::output(OutputType::PushPull, Speed::VeryHigh)); | 189 | set_as_af!(tx, AfType::output(OutputType::PushPull, Speed::VeryHigh)); |
| @@ -459,7 +459,7 @@ impl<'c, 'd, const TX_BUF_SIZE: usize, const RX_BUF_SIZE: usize> BufferedCan<'d, | |||
| 459 | pub async fn write(&mut self, frame: Frame) { | 459 | pub async fn write(&mut self, frame: Frame) { |
| 460 | self.tx_buf.send(frame).await; | 460 | self.tx_buf.send(frame).await; |
| 461 | self.info.interrupt0.pend(); // Wake for Tx | 461 | self.info.interrupt0.pend(); // Wake for Tx |
| 462 | //T::IT0Interrupt::pend(); // Wake for Tx | 462 | //T::IT0Interrupt::pend(); // Wake for Tx |
| 463 | } | 463 | } |
| 464 | 464 | ||
| 465 | /// Async read frame from RX buffer. | 465 | /// Async read frame from RX buffer. |
| @@ -548,7 +548,7 @@ impl<'c, 'd, const TX_BUF_SIZE: usize, const RX_BUF_SIZE: usize> BufferedCanFd<' | |||
| 548 | pub async fn write(&mut self, frame: FdFrame) { | 548 | pub async fn write(&mut self, frame: FdFrame) { |
| 549 | self.tx_buf.send(frame).await; | 549 | self.tx_buf.send(frame).await; |
| 550 | self.info.interrupt0.pend(); // Wake for Tx | 550 | self.info.interrupt0.pend(); // Wake for Tx |
| 551 | //T::IT0Interrupt::pend(); // Wake for Tx | 551 | //T::IT0Interrupt::pend(); // Wake for Tx |
| 552 | } | 552 | } |
| 553 | 553 | ||
| 554 | /// Async read frame from RX buffer. | 554 | /// Async read frame from RX buffer. |
diff --git a/embassy-stm32/src/can/util.rs b/embassy-stm32/src/can/util.rs index fcdbbad62..6d7f0c16a 100644 --- a/embassy-stm32/src/can/util.rs +++ b/embassy-stm32/src/can/util.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | //! Utility functions shared between CAN controller types. | 1 | //! Utility functions shared between CAN controller types. |
| 2 | 2 | ||
| 3 | use core::num::{NonZeroU16, NonZeroU8}; | 3 | use core::num::{NonZeroU8, NonZeroU16}; |
| 4 | 4 | ||
| 5 | /// Shared struct to represent bit timings used by calc_can_timings. | 5 | /// Shared struct to represent bit timings used by calc_can_timings. |
| 6 | #[derive(Clone, Copy, Debug)] | 6 | #[derive(Clone, Copy, Debug)] |
diff --git a/embassy-stm32/src/crc/v1.rs b/embassy-stm32/src/crc/v1.rs index 13e5263de..836228599 100644 --- a/embassy-stm32/src/crc/v1.rs +++ b/embassy-stm32/src/crc/v1.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | use crate::pac::CRC as PAC_CRC; | 1 | use crate::pac::CRC as PAC_CRC; |
| 2 | use crate::peripherals::CRC; | 2 | use crate::peripherals::CRC; |
| 3 | use crate::{rcc, Peri}; | 3 | use crate::{Peri, rcc}; |
| 4 | 4 | ||
| 5 | /// CRC driver. | 5 | /// CRC driver. |
| 6 | pub struct Crc<'d> { | 6 | pub struct Crc<'d> { |
diff --git a/embassy-stm32/src/crc/v2v3.rs b/embassy-stm32/src/crc/v2v3.rs index d834d0971..a566a2e04 100644 --- a/embassy-stm32/src/crc/v2v3.rs +++ b/embassy-stm32/src/crc/v2v3.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | use crate::pac::crc::vals; | ||
| 2 | use crate::pac::CRC as PAC_CRC; | 1 | use crate::pac::CRC as PAC_CRC; |
| 2 | use crate::pac::crc::vals; | ||
| 3 | use crate::peripherals::CRC; | 3 | use crate::peripherals::CRC; |
| 4 | use crate::{rcc, Peri}; | 4 | use crate::{Peri, rcc}; |
| 5 | 5 | ||
| 6 | /// CRC driver. | 6 | /// CRC driver. |
| 7 | pub struct Crc<'d> { | 7 | pub struct Crc<'d> { |
diff --git a/embassy-stm32/src/cryp/mod.rs b/embassy-stm32/src/cryp/mod.rs index 0173b2b5d..4f1115fb7 100644 --- a/embassy-stm32/src/cryp/mod.rs +++ b/embassy-stm32/src/cryp/mod.rs | |||
| @@ -1236,7 +1236,10 @@ impl<'d, T: Instance, M: Mode> Cryp<'d, T, M> { | |||
| 1236 | } | 1236 | } |
| 1237 | if C::REQUIRES_PADDING { | 1237 | if C::REQUIRES_PADDING { |
| 1238 | if last_block_remainder != 0 { | 1238 | if last_block_remainder != 0 { |
| 1239 | panic!("Input must be a multiple of {} bytes in ECB and CBC modes. Consider padding or ciphertext stealing.", C::BLOCK_SIZE); | 1239 | panic!( |
| 1240 | "Input must be a multiple of {} bytes in ECB and CBC modes. Consider padding or ciphertext stealing.", | ||
| 1241 | C::BLOCK_SIZE | ||
| 1242 | ); | ||
| 1240 | } | 1243 | } |
| 1241 | } | 1244 | } |
| 1242 | if last_block { | 1245 | if last_block { |
| @@ -1703,7 +1706,10 @@ impl<'d, T: Instance> Cryp<'d, T, Async> { | |||
| 1703 | } | 1706 | } |
| 1704 | if C::REQUIRES_PADDING { | 1707 | if C::REQUIRES_PADDING { |
| 1705 | if last_block_remainder != 0 { | 1708 | if last_block_remainder != 0 { |
| 1706 | panic!("Input must be a multiple of {} bytes in ECB and CBC modes. Consider padding or ciphertext stealing.", C::BLOCK_SIZE); | 1709 | panic!( |
| 1710 | "Input must be a multiple of {} bytes in ECB and CBC modes. Consider padding or ciphertext stealing.", | ||
| 1711 | C::BLOCK_SIZE | ||
| 1712 | ); | ||
| 1707 | } | 1713 | } |
| 1708 | } | 1714 | } |
| 1709 | if last_block { | 1715 | if last_block { |
diff --git a/embassy-stm32/src/dac/mod.rs b/embassy-stm32/src/dac/mod.rs index 08e001337..d74d4a4be 100644 --- a/embassy-stm32/src/dac/mod.rs +++ b/embassy-stm32/src/dac/mod.rs | |||
| @@ -8,7 +8,7 @@ use crate::mode::{Async, Blocking, Mode as PeriMode}; | |||
| 8 | #[cfg(any(dac_v3, dac_v4, dac_v5, dac_v6, dac_v7))] | 8 | #[cfg(any(dac_v3, dac_v4, dac_v5, dac_v6, dac_v7))] |
| 9 | use crate::pac::dac; | 9 | use crate::pac::dac; |
| 10 | use crate::rcc::{self, RccPeripheral}; | 10 | use crate::rcc::{self, RccPeripheral}; |
| 11 | use crate::{peripherals, Peri}; | 11 | use crate::{Peri, peripherals}; |
| 12 | 12 | ||
| 13 | mod tsel; | 13 | mod tsel; |
| 14 | use embassy_hal_internal::PeripheralType; | 14 | use embassy_hal_internal::PeripheralType; |
diff --git a/embassy-stm32/src/dcmi.rs b/embassy-stm32/src/dcmi.rs index bd03f1e00..dcae9f298 100644 --- a/embassy-stm32/src/dcmi.rs +++ b/embassy-stm32/src/dcmi.rs | |||
| @@ -9,7 +9,7 @@ use embassy_sync::waitqueue::AtomicWaker; | |||
| 9 | use crate::dma::Transfer; | 9 | use crate::dma::Transfer; |
| 10 | use crate::gpio::{AfType, Pull}; | 10 | use crate::gpio::{AfType, Pull}; |
| 11 | use crate::interrupt::typelevel::Interrupt; | 11 | use crate::interrupt::typelevel::Interrupt; |
| 12 | use crate::{interrupt, rcc, Peri}; | 12 | use crate::{Peri, interrupt, rcc}; |
| 13 | 13 | ||
| 14 | /// Interrupt handler. | 14 | /// Interrupt handler. |
| 15 | pub struct InterruptHandler<T: Instance> { | 15 | pub struct InterruptHandler<T: Instance> { |
diff --git a/embassy-stm32/src/dma/dma_bdma.rs b/embassy-stm32/src/dma/dma_bdma.rs index 73ecab070..90dbf4f09 100644 --- a/embassy-stm32/src/dma/dma_bdma.rs +++ b/embassy-stm32/src/dma/dma_bdma.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | use core::future::{poll_fn, Future}; | 1 | use core::future::{Future, poll_fn}; |
| 2 | use core::pin::Pin; | 2 | use core::pin::Pin; |
| 3 | use core::sync::atomic::{fence, AtomicUsize, Ordering}; | 3 | use core::sync::atomic::{AtomicUsize, Ordering, fence}; |
| 4 | use core::task::{Context, Poll, Waker}; | 4 | use core::task::{Context, Poll, Waker}; |
| 5 | 5 | ||
| 6 | use embassy_hal_internal::Peri; | 6 | use embassy_hal_internal::Peri; |
diff --git a/embassy-stm32/src/dma/gpdma/mod.rs b/embassy-stm32/src/dma/gpdma/mod.rs index 4a14c2a8e..3e117c331 100644 --- a/embassy-stm32/src/dma/gpdma/mod.rs +++ b/embassy-stm32/src/dma/gpdma/mod.rs | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | use core::future::Future; | 3 | use core::future::Future; |
| 4 | use core::pin::Pin; | 4 | use core::pin::Pin; |
| 5 | use core::sync::atomic::{fence, AtomicUsize, Ordering}; | 5 | use core::sync::atomic::{AtomicUsize, Ordering, fence}; |
| 6 | use core::task::{Context, Poll}; | 6 | use core::task::{Context, Poll}; |
| 7 | 7 | ||
| 8 | use embassy_hal_internal::Peri; | 8 | use embassy_hal_internal::Peri; |
diff --git a/embassy-stm32/src/dma/gpdma/ringbuffered.rs b/embassy-stm32/src/dma/gpdma/ringbuffered.rs index 9ee52193b..94c597e0d 100644 --- a/embassy-stm32/src/dma/gpdma/ringbuffered.rs +++ b/embassy-stm32/src/dma/gpdma/ringbuffered.rs | |||
| @@ -3,12 +3,12 @@ | |||
| 3 | //! FIXME: Add request_pause functionality? | 3 | //! FIXME: Add request_pause functionality? |
| 4 | //! FIXME: Stop the DMA, if a user does not queue new transfers (chain of linked-list items ends automatically). | 4 | //! FIXME: Stop the DMA, if a user does not queue new transfers (chain of linked-list items ends automatically). |
| 5 | use core::future::poll_fn; | 5 | use core::future::poll_fn; |
| 6 | use core::sync::atomic::{fence, Ordering}; | 6 | use core::sync::atomic::{Ordering, fence}; |
| 7 | use core::task::Waker; | 7 | use core::task::Waker; |
| 8 | 8 | ||
| 9 | use embassy_hal_internal::Peri; | 9 | use embassy_hal_internal::Peri; |
| 10 | 10 | ||
| 11 | use super::{AnyChannel, TransferOptions, STATE}; | 11 | use super::{AnyChannel, STATE, TransferOptions}; |
| 12 | use crate::dma::gpdma::linked_list::{RunMode, Table}; | 12 | use crate::dma::gpdma::linked_list::{RunMode, Table}; |
| 13 | use crate::dma::ringbuffer::{DmaCtrl, Error, ReadableDmaRingBuffer, WritableDmaRingBuffer}; | 13 | use crate::dma::ringbuffer::{DmaCtrl, Error, ReadableDmaRingBuffer, WritableDmaRingBuffer}; |
| 14 | use crate::dma::word::Word; | 14 | use crate::dma::word::Word; |
diff --git a/embassy-stm32/src/dma/mod.rs b/embassy-stm32/src/dma/mod.rs index 5989bfd7c..297fa3674 100644 --- a/embassy-stm32/src/dma/mod.rs +++ b/embassy-stm32/src/dma/mod.rs | |||
| @@ -24,7 +24,7 @@ pub(crate) use util::*; | |||
| 24 | pub(crate) mod ringbuffer; | 24 | pub(crate) mod ringbuffer; |
| 25 | pub mod word; | 25 | pub mod word; |
| 26 | 26 | ||
| 27 | use embassy_hal_internal::{impl_peripheral, PeripheralType}; | 27 | use embassy_hal_internal::{PeripheralType, impl_peripheral}; |
| 28 | 28 | ||
| 29 | use crate::interrupt; | 29 | use crate::interrupt; |
| 30 | 30 | ||
diff --git a/embassy-stm32/src/dma/ringbuffer/tests/prop_test/mod.rs b/embassy-stm32/src/dma/ringbuffer/tests/prop_test/mod.rs index 661fb1728..eff5b4058 100644 --- a/embassy-stm32/src/dma/ringbuffer/tests/prop_test/mod.rs +++ b/embassy-stm32/src/dma/ringbuffer/tests/prop_test/mod.rs | |||
| @@ -2,7 +2,7 @@ use std::task::Waker; | |||
| 2 | 2 | ||
| 3 | use proptest::prop_oneof; | 3 | use proptest::prop_oneof; |
| 4 | use proptest::strategy::{self, BoxedStrategy, Strategy as _}; | 4 | use proptest::strategy::{self, BoxedStrategy, Strategy as _}; |
| 5 | use proptest_state_machine::{prop_state_machine, ReferenceStateMachine, StateMachineTest}; | 5 | use proptest_state_machine::{ReferenceStateMachine, StateMachineTest, prop_state_machine}; |
| 6 | 6 | ||
| 7 | use super::*; | 7 | use super::*; |
| 8 | 8 | ||
diff --git a/embassy-stm32/src/dsihost.rs b/embassy-stm32/src/dsihost.rs index deda956af..fd1682d2b 100644 --- a/embassy-stm32/src/dsihost.rs +++ b/embassy-stm32/src/dsihost.rs | |||
| @@ -7,7 +7,7 @@ use embassy_hal_internal::PeripheralType; | |||
| 7 | //use crate::gpio::{AnyPin, SealedPin}; | 7 | //use crate::gpio::{AnyPin, SealedPin}; |
| 8 | use crate::gpio::{AfType, AnyPin, OutputType, Speed}; | 8 | use crate::gpio::{AfType, AnyPin, OutputType, Speed}; |
| 9 | use crate::rcc::{self, RccPeripheral}; | 9 | use crate::rcc::{self, RccPeripheral}; |
| 10 | use crate::{peripherals, Peri}; | 10 | use crate::{Peri, peripherals}; |
| 11 | 11 | ||
| 12 | /// Performs a busy-wait delay for a specified number of microseconds. | 12 | /// Performs a busy-wait delay for a specified number of microseconds. |
| 13 | pub fn blocking_delay_ms(ms: u32) { | 13 | pub fn blocking_delay_ms(ms: u32) { |
diff --git a/embassy-stm32/src/dts/mod.rs b/embassy-stm32/src/dts/mod.rs index 1f39c8db5..a75ae0560 100644 --- a/embassy-stm32/src/dts/mod.rs +++ b/embassy-stm32/src/dts/mod.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | //! Digital Temperature Sensor (DTS) | 1 | //! Digital Temperature Sensor (DTS) |
| 2 | 2 | ||
| 3 | use core::future::poll_fn; | 3 | use core::future::poll_fn; |
| 4 | use core::sync::atomic::{compiler_fence, Ordering}; | 4 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 5 | use core::task::Poll; | 5 | use core::task::Poll; |
| 6 | 6 | ||
| 7 | use embassy_hal_internal::Peri; | 7 | use embassy_hal_internal::Peri; |
diff --git a/embassy-stm32/src/eth/v1/mod.rs b/embassy-stm32/src/eth/v1/mod.rs index 5be1c9739..a77eb8719 100644 --- a/embassy-stm32/src/eth/v1/mod.rs +++ b/embassy-stm32/src/eth/v1/mod.rs | |||
| @@ -4,7 +4,7 @@ mod rx_desc; | |||
| 4 | mod tx_desc; | 4 | mod tx_desc; |
| 5 | 5 | ||
| 6 | use core::marker::PhantomData; | 6 | use core::marker::PhantomData; |
| 7 | use core::sync::atomic::{fence, Ordering}; | 7 | use core::sync::atomic::{Ordering, fence}; |
| 8 | 8 | ||
| 9 | use embassy_hal_internal::Peri; | 9 | use embassy_hal_internal::Peri; |
| 10 | use stm32_metapac::eth::vals::{Apcs, Cr, Dm, DmaomrSr, Fes, Ftf, Ifg, MbProgress, Mw, Pbl, Rsf, St, Tsf}; | 10 | use stm32_metapac::eth::vals::{Apcs, Cr, Dm, DmaomrSr, Fes, Ftf, Ifg, MbProgress, Mw, Pbl, Rsf, St, Tsf}; |
| @@ -190,7 +190,7 @@ impl<'d, T: Instance, P: Phy> Ethernet<'d, T, P> { | |||
| 190 | w.set_apcs(Apcs::STRIP); // automatic padding and crc stripping | 190 | w.set_apcs(Apcs::STRIP); // automatic padding and crc stripping |
| 191 | w.set_fes(Fes::FES100); // fast ethernet speed | 191 | w.set_fes(Fes::FES100); // fast ethernet speed |
| 192 | w.set_dm(Dm::FULL_DUPLEX); // full duplex | 192 | w.set_dm(Dm::FULL_DUPLEX); // full duplex |
| 193 | // TODO: Carrier sense ? ECRSFD | 193 | // TODO: Carrier sense ? ECRSFD |
| 194 | }); | 194 | }); |
| 195 | 195 | ||
| 196 | // Set the mac to pass all multicast packets | 196 | // Set the mac to pass all multicast packets |
| @@ -350,7 +350,9 @@ impl<'d, T: Instance, P: Phy> Ethernet<'d, T, P> { | |||
| 350 | } | 350 | } |
| 351 | 351 | ||
| 352 | #[cfg(any(eth_v1b, eth_v1c))] | 352 | #[cfg(any(eth_v1b, eth_v1c))] |
| 353 | config_pins!(rx_clk, tx_clk, mdio, mdc, rxdv, rx_d0, rx_d1, rx_d2, rx_d3, tx_d0, tx_d1, tx_d2, tx_d3, tx_en); | 353 | config_pins!( |
| 354 | rx_clk, tx_clk, mdio, mdc, rxdv, rx_d0, rx_d1, rx_d2, rx_d3, tx_d0, tx_d1, tx_d2, tx_d3, tx_en | ||
| 355 | ); | ||
| 354 | 356 | ||
| 355 | let pins = Pins::Mii([ | 357 | let pins = Pins::Mii([ |
| 356 | rx_clk.into(), | 358 | rx_clk.into(), |
diff --git a/embassy-stm32/src/eth/v1/rx_desc.rs b/embassy-stm32/src/eth/v1/rx_desc.rs index 2a46c1895..6ade1f29c 100644 --- a/embassy-stm32/src/eth/v1/rx_desc.rs +++ b/embassy-stm32/src/eth/v1/rx_desc.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use core::sync::atomic::{compiler_fence, fence, Ordering}; | 1 | use core::sync::atomic::{Ordering, compiler_fence, fence}; |
| 2 | 2 | ||
| 3 | use stm32_metapac::eth::vals::{Rpd, Rps}; | 3 | use stm32_metapac::eth::vals::{Rpd, Rps}; |
| 4 | use vcell::VolatileCell; | 4 | use vcell::VolatileCell; |
diff --git a/embassy-stm32/src/eth/v1/tx_desc.rs b/embassy-stm32/src/eth/v1/tx_desc.rs index 1317d20f4..ba99b66cb 100644 --- a/embassy-stm32/src/eth/v1/tx_desc.rs +++ b/embassy-stm32/src/eth/v1/tx_desc.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use core::sync::atomic::{compiler_fence, fence, Ordering}; | 1 | use core::sync::atomic::{Ordering, compiler_fence, fence}; |
| 2 | 2 | ||
| 3 | use vcell::VolatileCell; | 3 | use vcell::VolatileCell; |
| 4 | 4 | ||
diff --git a/embassy-stm32/src/eth/v2/descriptors.rs b/embassy-stm32/src/eth/v2/descriptors.rs index 645bfdb14..e335ed8f3 100644 --- a/embassy-stm32/src/eth/v2/descriptors.rs +++ b/embassy-stm32/src/eth/v2/descriptors.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use core::sync::atomic::{fence, Ordering}; | 1 | use core::sync::atomic::{Ordering, fence}; |
| 2 | 2 | ||
| 3 | use vcell::VolatileCell; | 3 | use vcell::VolatileCell; |
| 4 | 4 | ||
diff --git a/embassy-stm32/src/eth/v2/mod.rs b/embassy-stm32/src/eth/v2/mod.rs index cf7a9901b..39a6e8b0f 100644 --- a/embassy-stm32/src/eth/v2/mod.rs +++ b/embassy-stm32/src/eth/v2/mod.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | mod descriptors; | 1 | mod descriptors; |
| 2 | 2 | ||
| 3 | use core::marker::PhantomData; | 3 | use core::marker::PhantomData; |
| 4 | use core::sync::atomic::{fence, Ordering}; | 4 | use core::sync::atomic::{Ordering, fence}; |
| 5 | 5 | ||
| 6 | use embassy_hal_internal::Peri; | 6 | use embassy_hal_internal::Peri; |
| 7 | use stm32_metapac::syscfg::vals::EthSelPhy; | 7 | use stm32_metapac::syscfg::vals::EthSelPhy; |
| @@ -144,7 +144,9 @@ impl<'d, T: Instance, P: Phy> Ethernet<'d, T, P> { | |||
| 144 | .modify(|w| w.set_eth_sel_phy(EthSelPhy::MII_GMII)); | 144 | .modify(|w| w.set_eth_sel_phy(EthSelPhy::MII_GMII)); |
| 145 | }); | 145 | }); |
| 146 | 146 | ||
| 147 | config_pins!(rx_clk, tx_clk, mdio, mdc, rxdv, rx_d0, rx_d1, rx_d2, rx_d3, tx_d0, tx_d1, tx_d2, tx_d3, tx_en); | 147 | config_pins!( |
| 148 | rx_clk, tx_clk, mdio, mdc, rxdv, rx_d0, rx_d1, rx_d2, rx_d3, tx_d0, tx_d1, tx_d2, tx_d3, tx_en | ||
| 149 | ); | ||
| 148 | 150 | ||
| 149 | let pins = Pins::Mii([ | 151 | let pins = Pins::Mii([ |
| 150 | rx_clk.into(), | 152 | rx_clk.into(), |
diff --git a/embassy-stm32/src/exti.rs b/embassy-stm32/src/exti.rs index 9fce78f95..12600d4eb 100644 --- a/embassy-stm32/src/exti.rs +++ b/embassy-stm32/src/exti.rs | |||
| @@ -5,13 +5,13 @@ use core::marker::PhantomData; | |||
| 5 | use core::pin::Pin; | 5 | use core::pin::Pin; |
| 6 | use core::task::{Context, Poll}; | 6 | use core::task::{Context, Poll}; |
| 7 | 7 | ||
| 8 | use embassy_hal_internal::{impl_peripheral, PeripheralType}; | 8 | use embassy_hal_internal::{PeripheralType, impl_peripheral}; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 10 | 10 | ||
| 11 | use crate::gpio::{AnyPin, Input, Level, Pin as GpioPin, Pull}; | 11 | use crate::gpio::{AnyPin, Input, Level, Pin as GpioPin, Pull}; |
| 12 | use crate::pac::exti::regs::Lines; | ||
| 13 | use crate::pac::EXTI; | 12 | use crate::pac::EXTI; |
| 14 | use crate::{interrupt, pac, peripherals, Peri}; | 13 | use crate::pac::exti::regs::Lines; |
| 14 | use crate::{Peri, interrupt, pac, peripherals}; | ||
| 15 | 15 | ||
| 16 | const EXTI_COUNT: usize = 16; | 16 | const EXTI_COUNT: usize = 16; |
| 17 | static EXTI_WAKERS: [AtomicWaker; EXTI_COUNT] = [const { AtomicWaker::new() }; EXTI_COUNT]; | 17 | static EXTI_WAKERS: [AtomicWaker; EXTI_COUNT] = [const { AtomicWaker::new() }; EXTI_COUNT]; |
diff --git a/embassy-stm32/src/flash/asynch.rs b/embassy-stm32/src/flash/asynch.rs index 006dcddeb..a131217b7 100644 --- a/embassy-stm32/src/flash/asynch.rs +++ b/embassy-stm32/src/flash/asynch.rs | |||
| @@ -1,17 +1,17 @@ | |||
| 1 | use core::marker::PhantomData; | 1 | use core::marker::PhantomData; |
| 2 | use core::sync::atomic::{fence, Ordering}; | 2 | use core::sync::atomic::{Ordering, fence}; |
| 3 | 3 | ||
| 4 | use embassy_hal_internal::drop::OnDrop; | 4 | use embassy_hal_internal::drop::OnDrop; |
| 5 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 5 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| 6 | use embassy_sync::mutex::Mutex; | 6 | use embassy_sync::mutex::Mutex; |
| 7 | 7 | ||
| 8 | use super::{ | 8 | use super::{ |
| 9 | blocking_read, ensure_sector_aligned, family, get_flash_regions, get_sector, Async, Error, Flash, FlashLayout, | 9 | Async, Error, FLASH_BASE, FLASH_SIZE, Flash, FlashLayout, WRITE_SIZE, blocking_read, ensure_sector_aligned, family, |
| 10 | FLASH_BASE, FLASH_SIZE, WRITE_SIZE, | 10 | get_flash_regions, get_sector, |
| 11 | }; | 11 | }; |
| 12 | use crate::interrupt::InterruptExt; | 12 | use crate::interrupt::InterruptExt; |
| 13 | use crate::peripherals::FLASH; | 13 | use crate::peripherals::FLASH; |
| 14 | use crate::{interrupt, Peri}; | 14 | use crate::{Peri, interrupt}; |
| 15 | 15 | ||
| 16 | pub(super) static REGION_ACCESS: Mutex<CriticalSectionRawMutex, ()> = Mutex::new(()); | 16 | pub(super) static REGION_ACCESS: Mutex<CriticalSectionRawMutex, ()> = Mutex::new(()); |
| 17 | 17 | ||
diff --git a/embassy-stm32/src/flash/common.rs b/embassy-stm32/src/flash/common.rs index 10023e637..b595938a6 100644 --- a/embassy-stm32/src/flash/common.rs +++ b/embassy-stm32/src/flash/common.rs | |||
| @@ -1,14 +1,14 @@ | |||
| 1 | use core::marker::PhantomData; | 1 | use core::marker::PhantomData; |
| 2 | use core::sync::atomic::{fence, Ordering}; | 2 | use core::sync::atomic::{Ordering, fence}; |
| 3 | 3 | ||
| 4 | use embassy_hal_internal::drop::OnDrop; | 4 | use embassy_hal_internal::drop::OnDrop; |
| 5 | 5 | ||
| 6 | use super::{ | 6 | use super::{ |
| 7 | family, get_flash_regions, Async, Blocking, Error, FlashBank, FlashLayout, FlashRegion, FlashSector, FLASH_SIZE, | 7 | Async, Blocking, Error, FLASH_SIZE, FlashBank, FlashLayout, FlashRegion, FlashSector, MAX_ERASE_SIZE, READ_SIZE, |
| 8 | MAX_ERASE_SIZE, READ_SIZE, WRITE_SIZE, | 8 | WRITE_SIZE, family, get_flash_regions, |
| 9 | }; | 9 | }; |
| 10 | use crate::Peri; | ||
| 11 | use crate::_generated::FLASH_BASE; | 10 | use crate::_generated::FLASH_BASE; |
| 11 | use crate::Peri; | ||
| 12 | use crate::peripherals::FLASH; | 12 | use crate::peripherals::FLASH; |
| 13 | 13 | ||
| 14 | /// Internal flash memory driver. | 14 | /// Internal flash memory driver. |
diff --git a/embassy-stm32/src/flash/eeprom.rs b/embassy-stm32/src/flash/eeprom.rs index cc3529eb9..39c497e3f 100644 --- a/embassy-stm32/src/flash/eeprom.rs +++ b/embassy-stm32/src/flash/eeprom.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | use embassy_hal_internal::drop::OnDrop; | 1 | use embassy_hal_internal::drop::OnDrop; |
| 2 | 2 | ||
| 3 | use super::{family, Blocking, Error, Flash, EEPROM_BASE, EEPROM_SIZE}; | 3 | use super::{Blocking, EEPROM_BASE, EEPROM_SIZE, Error, Flash, family}; |
| 4 | 4 | ||
| 5 | #[cfg(eeprom)] | 5 | #[cfg(eeprom)] |
| 6 | impl<'d> Flash<'d, Blocking> { | 6 | impl<'d> Flash<'d, Blocking> { |
diff --git a/embassy-stm32/src/flash/f0.rs b/embassy-stm32/src/flash/f0.rs index 3f9dbe945..5c01fce9c 100644 --- a/embassy-stm32/src/flash/f0.rs +++ b/embassy-stm32/src/flash/f0.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | use core::ptr::write_volatile; | 1 | use core::ptr::write_volatile; |
| 2 | use core::sync::atomic::{fence, Ordering}; | 2 | use core::sync::atomic::{Ordering, fence}; |
| 3 | 3 | ||
| 4 | use super::{FlashSector, WRITE_SIZE}; | 4 | use super::{FlashSector, WRITE_SIZE}; |
| 5 | use crate::flash::Error; | 5 | use crate::flash::Error; |
diff --git a/embassy-stm32/src/flash/f1f3.rs b/embassy-stm32/src/flash/f1f3.rs index bf9ad2893..9e469ffbc 100644 --- a/embassy-stm32/src/flash/f1f3.rs +++ b/embassy-stm32/src/flash/f1f3.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | use core::ptr::write_volatile; | 1 | use core::ptr::write_volatile; |
| 2 | use core::sync::atomic::{fence, Ordering}; | 2 | use core::sync::atomic::{Ordering, fence}; |
| 3 | 3 | ||
| 4 | use super::{FlashSector, WRITE_SIZE}; | 4 | use super::{FlashSector, WRITE_SIZE}; |
| 5 | use crate::flash::Error; | 5 | use crate::flash::Error; |
diff --git a/embassy-stm32/src/flash/f2.rs b/embassy-stm32/src/flash/f2.rs index 67e380619..b48ab3b76 100644 --- a/embassy-stm32/src/flash/f2.rs +++ b/embassy-stm32/src/flash/f2.rs | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | use core::ptr::write_volatile; | 1 | use core::ptr::write_volatile; |
| 2 | use core::sync::atomic::{fence, AtomicBool, Ordering}; | 2 | use core::sync::atomic::{AtomicBool, Ordering, fence}; |
| 3 | 3 | ||
| 4 | use pac::flash::regs::Sr; | 4 | use pac::flash::regs::Sr; |
| 5 | 5 | ||
| 6 | use super::{get_flash_regions, FlashBank, FlashSector, WRITE_SIZE}; | 6 | use super::{FlashBank, FlashSector, WRITE_SIZE, get_flash_regions}; |
| 7 | use crate::flash::Error; | 7 | use crate::flash::Error; |
| 8 | use crate::pac; | 8 | use crate::pac; |
| 9 | 9 | ||
diff --git a/embassy-stm32/src/flash/f4.rs b/embassy-stm32/src/flash/f4.rs index 62e0492b5..9c5051492 100644 --- a/embassy-stm32/src/flash/f4.rs +++ b/embassy-stm32/src/flash/f4.rs | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | use core::ptr::write_volatile; | 1 | use core::ptr::write_volatile; |
| 2 | use core::sync::atomic::{fence, AtomicBool, Ordering}; | 2 | use core::sync::atomic::{AtomicBool, Ordering, fence}; |
| 3 | 3 | ||
| 4 | use embassy_sync::waitqueue::AtomicWaker; | 4 | use embassy_sync::waitqueue::AtomicWaker; |
| 5 | use pac::flash::regs::Sr; | 5 | use pac::flash::regs::Sr; |
| 6 | 6 | ||
| 7 | use super::{get_flash_regions, FlashBank, FlashSector, WRITE_SIZE}; | 7 | use super::{FlashBank, FlashSector, WRITE_SIZE, get_flash_regions}; |
| 8 | use crate::_generated::FLASH_SIZE; | 8 | use crate::_generated::FLASH_SIZE; |
| 9 | use crate::flash::Error; | 9 | use crate::flash::Error; |
| 10 | use crate::pac; | 10 | use crate::pac; |
| @@ -246,7 +246,9 @@ pub(crate) fn assert_not_corrupted_read(end_address: u32) { | |||
| 246 | feature = "stm32f439zi", | 246 | feature = "stm32f439zi", |
| 247 | ))] | 247 | ))] |
| 248 | if second_bank_read && pac::DBGMCU.idcode().read().rev_id() < REVISION_3 && !pa12_is_output_pull_low() { | 248 | if second_bank_read && pac::DBGMCU.idcode().read().rev_id() < REVISION_3 && !pa12_is_output_pull_low() { |
| 249 | panic!("Read corruption for stm32f42xxI and stm32f43xxI when PA12 is in use for chips below revision 3, see errata 2.2.11"); | 249 | panic!( |
| 250 | "Read corruption for stm32f42xxI and stm32f43xxI when PA12 is in use for chips below revision 3, see errata 2.2.11" | ||
| 251 | ); | ||
| 250 | } | 252 | } |
| 251 | 253 | ||
| 252 | #[cfg(any( | 254 | #[cfg(any( |
| @@ -270,14 +272,16 @@ pub(crate) fn assert_not_corrupted_read(end_address: u32) { | |||
| 270 | feature = "stm32f439zg", | 272 | feature = "stm32f439zg", |
| 271 | ))] | 273 | ))] |
| 272 | if second_bank_read && pac::DBGMCU.idcode().read().rev_id() < REVISION_3 && !pa12_is_output_pull_low() { | 274 | if second_bank_read && pac::DBGMCU.idcode().read().rev_id() < REVISION_3 && !pa12_is_output_pull_low() { |
| 273 | panic!("Read corruption for stm32f42xxG and stm32f43xxG in dual bank mode when PA12 is in use for chips below revision 3, see errata 2.2.11"); | 275 | panic!( |
| 276 | "Read corruption for stm32f42xxG and stm32f43xxG in dual bank mode when PA12 is in use for chips below revision 3, see errata 2.2.11" | ||
| 277 | ); | ||
| 274 | } | 278 | } |
| 275 | } | 279 | } |
| 276 | 280 | ||
| 277 | #[allow(unused)] | 281 | #[allow(unused)] |
| 278 | fn pa12_is_output_pull_low() -> bool { | 282 | fn pa12_is_output_pull_low() -> bool { |
| 279 | use pac::gpio::vals; | ||
| 280 | use pac::GPIOA; | 283 | use pac::GPIOA; |
| 284 | use pac::gpio::vals; | ||
| 281 | const PIN: usize = 12; | 285 | const PIN: usize = 12; |
| 282 | GPIOA.moder().read().moder(PIN) == vals::Moder::OUTPUT | 286 | GPIOA.moder().read().moder(PIN) == vals::Moder::OUTPUT |
| 283 | && GPIOA.pupdr().read().pupdr(PIN) == vals::Pupdr::PULL_DOWN | 287 | && GPIOA.pupdr().read().pupdr(PIN) == vals::Pupdr::PULL_DOWN |
| @@ -287,7 +291,7 @@ fn pa12_is_output_pull_low() -> bool { | |||
| 287 | #[cfg(test)] | 291 | #[cfg(test)] |
| 288 | mod tests { | 292 | mod tests { |
| 289 | use super::*; | 293 | use super::*; |
| 290 | use crate::flash::{get_sector, FlashBank}; | 294 | use crate::flash::{FlashBank, get_sector}; |
| 291 | 295 | ||
| 292 | #[test] | 296 | #[test] |
| 293 | #[cfg(stm32f429)] | 297 | #[cfg(stm32f429)] |
| @@ -370,9 +374,13 @@ mod tests { | |||
| 370 | #[cfg(all(bank_setup_configurable))] | 374 | #[cfg(all(bank_setup_configurable))] |
| 371 | pub(crate) fn check_bank_setup() { | 375 | pub(crate) fn check_bank_setup() { |
| 372 | if cfg!(feature = "single-bank") && pac::FLASH.optcr().read().db1m() { | 376 | if cfg!(feature = "single-bank") && pac::FLASH.optcr().read().db1m() { |
| 373 | panic!("Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the db1m value in the user option bytes or configure embassy to use dual-bank config"); | 377 | panic!( |
| 378 | "Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the db1m value in the user option bytes or configure embassy to use dual-bank config" | ||
| 379 | ); | ||
| 374 | } | 380 | } |
| 375 | if cfg!(feature = "dual-bank") && !pac::FLASH.optcr().read().db1m() { | 381 | if cfg!(feature = "dual-bank") && !pac::FLASH.optcr().read().db1m() { |
| 376 | panic!("Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the db1m value in the user option bytes or configure embassy to use single-bank config"); | 382 | panic!( |
| 383 | "Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the db1m value in the user option bytes or configure embassy to use single-bank config" | ||
| 384 | ); | ||
| 377 | } | 385 | } |
| 378 | } | 386 | } |
diff --git a/embassy-stm32/src/flash/f7.rs b/embassy-stm32/src/flash/f7.rs index 0547c747a..09389c417 100644 --- a/embassy-stm32/src/flash/f7.rs +++ b/embassy-stm32/src/flash/f7.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | use core::ptr::write_volatile; | 1 | use core::ptr::write_volatile; |
| 2 | use core::sync::atomic::{fence, Ordering}; | 2 | use core::sync::atomic::{Ordering, fence}; |
| 3 | 3 | ||
| 4 | use super::{FlashSector, WRITE_SIZE}; | 4 | use super::{FlashSector, WRITE_SIZE}; |
| 5 | use crate::flash::Error; | 5 | use crate::flash::Error; |
| @@ -99,7 +99,7 @@ unsafe fn blocking_wait_ready() -> Result<(), Error> { | |||
| 99 | #[cfg(test)] | 99 | #[cfg(test)] |
| 100 | mod tests { | 100 | mod tests { |
| 101 | use super::*; | 101 | use super::*; |
| 102 | use crate::flash::{get_sector, FlashBank}; | 102 | use crate::flash::{FlashBank, get_sector}; |
| 103 | 103 | ||
| 104 | #[test] | 104 | #[test] |
| 105 | #[cfg(stm32f732)] | 105 | #[cfg(stm32f732)] |
| @@ -218,9 +218,13 @@ mod tests { | |||
| 218 | #[cfg(all(bank_setup_configurable))] | 218 | #[cfg(all(bank_setup_configurable))] |
| 219 | pub(crate) fn check_bank_setup() { | 219 | pub(crate) fn check_bank_setup() { |
| 220 | if cfg!(feature = "single-bank") && !pac::FLASH.optcr().read().n_dbank() { | 220 | if cfg!(feature = "single-bank") && !pac::FLASH.optcr().read().n_dbank() { |
| 221 | panic!("Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the ndbank value in the user option bytes or configure embassy to use dual-bank config"); | 221 | panic!( |
| 222 | "Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the ndbank value in the user option bytes or configure embassy to use dual-bank config" | ||
| 223 | ); | ||
| 222 | } | 224 | } |
| 223 | if cfg!(feature = "dual-bank") && pac::FLASH.optcr().read().n_dbank() { | 225 | if cfg!(feature = "dual-bank") && pac::FLASH.optcr().read().n_dbank() { |
| 224 | panic!("Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the ndbank value in the user option bytes or configure embassy to use single-bank config"); | 226 | panic!( |
| 227 | "Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the ndbank value in the user option bytes or configure embassy to use single-bank config" | ||
| 228 | ); | ||
| 225 | } | 229 | } |
| 226 | } | 230 | } |
diff --git a/embassy-stm32/src/flash/g.rs b/embassy-stm32/src/flash/g.rs index bc1fd360c..d026541a4 100644 --- a/embassy-stm32/src/flash/g.rs +++ b/embassy-stm32/src/flash/g.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | use core::ptr::write_volatile; | 1 | use core::ptr::write_volatile; |
| 2 | use core::sync::atomic::{fence, Ordering}; | 2 | use core::sync::atomic::{Ordering, fence}; |
| 3 | 3 | ||
| 4 | use cortex_m::interrupt; | 4 | use cortex_m::interrupt; |
| 5 | 5 | ||
| @@ -105,19 +105,27 @@ fn wait_busy() { | |||
| 105 | #[cfg(all(bank_setup_configurable, any(flash_g4c2, flash_g4c3, flash_g4c4)))] | 105 | #[cfg(all(bank_setup_configurable, any(flash_g4c2, flash_g4c3, flash_g4c4)))] |
| 106 | pub(crate) fn check_bank_setup() { | 106 | pub(crate) fn check_bank_setup() { |
| 107 | if cfg!(feature = "single-bank") && pac::FLASH.optr().read().dbank() { | 107 | if cfg!(feature = "single-bank") && pac::FLASH.optr().read().dbank() { |
| 108 | panic!("Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the dbank value in the user option bytes or configure embassy to use dual-bank config"); | 108 | panic!( |
| 109 | "Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the dbank value in the user option bytes or configure embassy to use dual-bank config" | ||
| 110 | ); | ||
| 109 | } | 111 | } |
| 110 | if cfg!(feature = "dual-bank") && !pac::FLASH.optr().read().dbank() { | 112 | if cfg!(feature = "dual-bank") && !pac::FLASH.optr().read().dbank() { |
| 111 | panic!("Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the dbank value in the user option bytes or configure embassy to use single-bank config"); | 113 | panic!( |
| 114 | "Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the dbank value in the user option bytes or configure embassy to use single-bank config" | ||
| 115 | ); | ||
| 112 | } | 116 | } |
| 113 | } | 117 | } |
| 114 | 118 | ||
| 115 | #[cfg(all(bank_setup_configurable, flash_g0x1))] | 119 | #[cfg(all(bank_setup_configurable, flash_g0x1))] |
| 116 | pub(crate) fn check_bank_setup() { | 120 | pub(crate) fn check_bank_setup() { |
| 117 | if cfg!(feature = "single-bank") && pac::FLASH.optr().read().dual_bank() { | 121 | if cfg!(feature = "single-bank") && pac::FLASH.optr().read().dual_bank() { |
| 118 | panic!("Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the dual_bank value in the user option bytes or configure embassy to use dual-bank config"); | 122 | panic!( |
| 123 | "Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the dual_bank value in the user option bytes or configure embassy to use dual-bank config" | ||
| 124 | ); | ||
| 119 | } | 125 | } |
| 120 | if cfg!(feature = "dual-bank") && !pac::FLASH.optr().read().dual_bank() { | 126 | if cfg!(feature = "dual-bank") && !pac::FLASH.optr().read().dual_bank() { |
| 121 | panic!("Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the dual_bank value in the user option bytes or configure embassy to use single-bank config"); | 127 | panic!( |
| 128 | "Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the dual_bank value in the user option bytes or configure embassy to use single-bank config" | ||
| 129 | ); | ||
| 122 | } | 130 | } |
| 123 | } | 131 | } |
diff --git a/embassy-stm32/src/flash/h5.rs b/embassy-stm32/src/flash/h5.rs index fd9bfcc75..88f247879 100644 --- a/embassy-stm32/src/flash/h5.rs +++ b/embassy-stm32/src/flash/h5.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | use core::ptr::write_volatile; | 1 | use core::ptr::write_volatile; |
| 2 | use core::sync::atomic::{fence, Ordering}; | 2 | use core::sync::atomic::{Ordering, fence}; |
| 3 | 3 | ||
| 4 | use super::{FlashSector, WRITE_SIZE}; | 4 | use super::{FlashSector, WRITE_SIZE}; |
| 5 | use crate::flash::Error; | 5 | use crate::flash::Error; |
diff --git a/embassy-stm32/src/flash/h50.rs b/embassy-stm32/src/flash/h50.rs index f8e210556..91d5da4d6 100644 --- a/embassy-stm32/src/flash/h50.rs +++ b/embassy-stm32/src/flash/h50.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /// STM32H50 series flash impl. See RM0492 | 1 | /// STM32H50 series flash impl. See RM0492 |
| 2 | use core::{ | 2 | use core::{ |
| 3 | ptr::write_volatile, | 3 | ptr::write_volatile, |
| 4 | sync::atomic::{fence, Ordering}, | 4 | sync::atomic::{Ordering, fence}, |
| 5 | }; | 5 | }; |
| 6 | 6 | ||
| 7 | use cortex_m::interrupt; | 7 | use cortex_m::interrupt; |
diff --git a/embassy-stm32/src/flash/h7.rs b/embassy-stm32/src/flash/h7.rs index f1d84101c..8a43cce3f 100644 --- a/embassy-stm32/src/flash/h7.rs +++ b/embassy-stm32/src/flash/h7.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | use core::ptr::write_volatile; | 1 | use core::ptr::write_volatile; |
| 2 | use core::sync::atomic::{fence, Ordering}; | 2 | use core::sync::atomic::{Ordering, fence}; |
| 3 | 3 | ||
| 4 | use super::{FlashSector, BANK1_REGION, FLASH_REGIONS, WRITE_SIZE}; | 4 | use super::{BANK1_REGION, FLASH_REGIONS, FlashSector, WRITE_SIZE}; |
| 5 | use crate::flash::Error; | 5 | use crate::flash::Error; |
| 6 | use crate::pac; | 6 | use crate::pac; |
| 7 | 7 | ||
diff --git a/embassy-stm32/src/flash/l.rs b/embassy-stm32/src/flash/l.rs index 1b82704ec..cd23cda5c 100644 --- a/embassy-stm32/src/flash/l.rs +++ b/embassy-stm32/src/flash/l.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | use core::ptr::write_volatile; | 1 | use core::ptr::write_volatile; |
| 2 | use core::sync::atomic::{fence, Ordering}; | 2 | use core::sync::atomic::{Ordering, fence}; |
| 3 | 3 | ||
| 4 | use super::{FlashSector, WRITE_SIZE}; | 4 | use super::{FlashSector, WRITE_SIZE}; |
| 5 | use crate::flash::Error; | 5 | use crate::flash::Error; |
| @@ -234,19 +234,27 @@ pub(crate) unsafe fn wait_ready_blocking() -> Result<(), Error> { | |||
| 234 | #[cfg(all(bank_setup_configurable, flash_l5))] | 234 | #[cfg(all(bank_setup_configurable, flash_l5))] |
| 235 | pub(crate) fn check_bank_setup() { | 235 | pub(crate) fn check_bank_setup() { |
| 236 | if cfg!(feature = "single-bank") && pac::FLASH.optr().read().dbank() { | 236 | if cfg!(feature = "single-bank") && pac::FLASH.optr().read().dbank() { |
| 237 | panic!("Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the dbank value in the user option bytes or configure embassy to use dual-bank config"); | 237 | panic!( |
| 238 | "Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the dbank value in the user option bytes or configure embassy to use dual-bank config" | ||
| 239 | ); | ||
| 238 | } | 240 | } |
| 239 | if cfg!(feature = "dual-bank") && !pac::FLASH.optr().read().dbank() { | 241 | if cfg!(feature = "dual-bank") && !pac::FLASH.optr().read().dbank() { |
| 240 | panic!("Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the dbank value in the user option bytes or configure embassy to use single-bank config"); | 242 | panic!( |
| 243 | "Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the dbank value in the user option bytes or configure embassy to use single-bank config" | ||
| 244 | ); | ||
| 241 | } | 245 | } |
| 242 | } | 246 | } |
| 243 | 247 | ||
| 244 | #[cfg(all(bank_setup_configurable, flash_l4))] | 248 | #[cfg(all(bank_setup_configurable, flash_l4))] |
| 245 | pub(crate) fn check_bank_setup() { | 249 | pub(crate) fn check_bank_setup() { |
| 246 | if cfg!(feature = "single-bank") && pac::FLASH.optr().read().dualbank() { | 250 | if cfg!(feature = "single-bank") && pac::FLASH.optr().read().dualbank() { |
| 247 | panic!("Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the dualbank value in the user option bytes or configure embassy to use dual-bank config"); | 251 | panic!( |
| 252 | "Embassy is configured as single-bank, but the hardware is running in dual-bank mode. Change the hardware by changing the dualbank value in the user option bytes or configure embassy to use dual-bank config" | ||
| 253 | ); | ||
| 248 | } | 254 | } |
| 249 | if cfg!(feature = "dual-bank") && !pac::FLASH.optr().read().dualbank() { | 255 | if cfg!(feature = "dual-bank") && !pac::FLASH.optr().read().dualbank() { |
| 250 | panic!("Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the dualbank value in the user option bytes or configure embassy to use single-bank config"); | 256 | panic!( |
| 257 | "Embassy is configured as dual-bank, but the hardware is running in single-bank mode. Change the hardware by changing the dualbank value in the user option bytes or configure embassy to use single-bank config" | ||
| 258 | ); | ||
| 251 | } | 259 | } |
| 252 | } | 260 | } |
diff --git a/embassy-stm32/src/flash/u0.rs b/embassy-stm32/src/flash/u0.rs index 68d847eca..a64f6c492 100644 --- a/embassy-stm32/src/flash/u0.rs +++ b/embassy-stm32/src/flash/u0.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | use core::ptr::write_volatile; | 1 | use core::ptr::write_volatile; |
| 2 | use core::sync::atomic::{fence, Ordering}; | 2 | use core::sync::atomic::{Ordering, fence}; |
| 3 | 3 | ||
| 4 | use cortex_m::interrupt; | 4 | use cortex_m::interrupt; |
| 5 | 5 | ||
diff --git a/embassy-stm32/src/flash/u5.rs b/embassy-stm32/src/flash/u5.rs index 6c3d4b422..5f1f562c0 100644 --- a/embassy-stm32/src/flash/u5.rs +++ b/embassy-stm32/src/flash/u5.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | use core::ptr::write_volatile; | 1 | use core::ptr::write_volatile; |
| 2 | use core::sync::atomic::{fence, Ordering}; | 2 | use core::sync::atomic::{Ordering, fence}; |
| 3 | 3 | ||
| 4 | use super::{FlashBank, FlashSector, WRITE_SIZE}; | 4 | use super::{FlashBank, FlashSector, WRITE_SIZE}; |
| 5 | use crate::flash::Error; | 5 | use crate::flash::Error; |
diff --git a/embassy-stm32/src/fmc.rs b/embassy-stm32/src/fmc.rs index ff18a8bee..8ecfbc522 100644 --- a/embassy-stm32/src/fmc.rs +++ b/embassy-stm32/src/fmc.rs | |||
| @@ -4,7 +4,7 @@ use core::marker::PhantomData; | |||
| 4 | use embassy_hal_internal::PeripheralType; | 4 | use embassy_hal_internal::PeripheralType; |
| 5 | 5 | ||
| 6 | use crate::gpio::{AfType, OutputType, Pull, Speed}; | 6 | use crate::gpio::{AfType, OutputType, Pull, Speed}; |
| 7 | use crate::{rcc, Peri}; | 7 | use crate::{Peri, rcc}; |
| 8 | 8 | ||
| 9 | /// FMC driver | 9 | /// FMC driver |
| 10 | pub struct Fmc<'d, T: Instance> { | 10 | pub struct Fmc<'d, T: Instance> { |
diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 5a8d23183..b55baffdc 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | use core::convert::Infallible; | 4 | use core::convert::Infallible; |
| 5 | 5 | ||
| 6 | use critical_section::CriticalSection; | 6 | use critical_section::CriticalSection; |
| 7 | use embassy_hal_internal::{impl_peripheral, Peri, PeripheralType}; | 7 | use embassy_hal_internal::{Peri, PeripheralType, impl_peripheral}; |
| 8 | 8 | ||
| 9 | use crate::pac::gpio::{self, vals}; | 9 | use crate::pac::gpio::{self, vals}; |
| 10 | use crate::peripherals; | 10 | use crate::peripherals; |
diff --git a/embassy-stm32/src/hash/mod.rs b/embassy-stm32/src/hash/mod.rs index 90c06c0d8..ba573267c 100644 --- a/embassy-stm32/src/hash/mod.rs +++ b/embassy-stm32/src/hash/mod.rs | |||
| @@ -19,7 +19,7 @@ use crate::interrupt::typelevel::Interrupt; | |||
| 19 | use crate::mode::Async; | 19 | use crate::mode::Async; |
| 20 | use crate::mode::{Blocking, Mode}; | 20 | use crate::mode::{Blocking, Mode}; |
| 21 | use crate::peripherals::HASH; | 21 | use crate::peripherals::HASH; |
| 22 | use crate::{interrupt, pac, peripherals, rcc, Peri}; | 22 | use crate::{Peri, interrupt, pac, peripherals, rcc}; |
| 23 | 23 | ||
| 24 | #[cfg(hash_v1)] | 24 | #[cfg(hash_v1)] |
| 25 | const NUM_CONTEXT_REGS: usize = 51; | 25 | const NUM_CONTEXT_REGS: usize = 51; |
| @@ -514,11 +514,7 @@ impl<'d, T: Instance> Hash<'d, T, Async> { | |||
| 514 | T::regs().imr().modify(|reg| reg.set_dcie(true)); | 514 | T::regs().imr().modify(|reg| reg.set_dcie(true)); |
| 515 | // Check for completion. | 515 | // Check for completion. |
| 516 | let bits = T::regs().sr().read(); | 516 | let bits = T::regs().sr().read(); |
| 517 | if bits.dcis() { | 517 | if bits.dcis() { Poll::Ready(()) } else { Poll::Pending } |
| 518 | Poll::Ready(()) | ||
| 519 | } else { | ||
| 520 | Poll::Pending | ||
| 521 | } | ||
| 522 | }) | 518 | }) |
| 523 | .await; | 519 | .await; |
| 524 | 520 | ||
diff --git a/embassy-stm32/src/hsem/mod.rs b/embassy-stm32/src/hsem/mod.rs index 573a1851d..4d3a5d68d 100644 --- a/embassy-stm32/src/hsem/mod.rs +++ b/embassy-stm32/src/hsem/mod.rs | |||
| @@ -2,13 +2,13 @@ | |||
| 2 | 2 | ||
| 3 | use embassy_hal_internal::PeripheralType; | 3 | use embassy_hal_internal::PeripheralType; |
| 4 | 4 | ||
| 5 | use crate::pac; | ||
| 6 | use crate::rcc::{self, RccPeripheral}; | ||
| 7 | // TODO: This code works for all HSEM implemenations except for the STM32WBA52/4/5xx MCUs. | 5 | // TODO: This code works for all HSEM implemenations except for the STM32WBA52/4/5xx MCUs. |
| 8 | // Those MCUs have a different HSEM implementation (Secure semaphore lock support, | 6 | // Those MCUs have a different HSEM implementation (Secure semaphore lock support, |
| 9 | // Privileged / unprivileged semaphore lock support, Semaphore lock protection via semaphore attribute), | 7 | // Privileged / unprivileged semaphore lock support, Semaphore lock protection via semaphore attribute), |
| 10 | // which is not yet supported by this code. | 8 | // which is not yet supported by this code. |
| 11 | use crate::Peri; | 9 | use crate::Peri; |
| 10 | use crate::pac; | ||
| 11 | use crate::rcc::{self, RccPeripheral}; | ||
| 12 | 12 | ||
| 13 | /// HSEM error. | 13 | /// HSEM error. |
| 14 | #[derive(Debug)] | 14 | #[derive(Debug)] |
diff --git a/embassy-stm32/src/hspi/mod.rs b/embassy-stm32/src/hspi/mod.rs index 95d9e5099..69baa708e 100644 --- a/embassy-stm32/src/hspi/mod.rs +++ b/embassy-stm32/src/hspi/mod.rs | |||
| @@ -16,7 +16,7 @@ use embassy_embedded_hal::{GetConfig, SetConfig}; | |||
| 16 | use embassy_hal_internal::{Peri, PeripheralType}; | 16 | use embassy_hal_internal::{Peri, PeripheralType}; |
| 17 | pub use enums::*; | 17 | pub use enums::*; |
| 18 | 18 | ||
| 19 | use crate::dma::{word, ChannelAndRequest}; | 19 | use crate::dma::{ChannelAndRequest, word}; |
| 20 | use crate::gpio::{AfType, AnyPin, OutputType, Pull, SealedPin as _, Speed}; | 20 | use crate::gpio::{AfType, AnyPin, OutputType, Pull, SealedPin as _, Speed}; |
| 21 | use crate::mode::{Async, Blocking, Mode as PeriMode}; | 21 | use crate::mode::{Async, Blocking, Mode as PeriMode}; |
| 22 | use crate::pac::hspi::Hspi as Regs; | 22 | use crate::pac::hspi::Hspi as Regs; |
diff --git a/embassy-stm32/src/i2c/mod.rs b/embassy-stm32/src/i2c/mod.rs index 249bac41c..f4bf55d34 100644 --- a/embassy-stm32/src/i2c/mod.rs +++ b/embassy-stm32/src/i2c/mod.rs | |||
| @@ -154,8 +154,8 @@ impl<'d> I2c<'d, Async, Master> { | |||
| 154 | scl: Peri<'d, if_afio!(impl SclPin<T, A>)>, | 154 | scl: Peri<'d, if_afio!(impl SclPin<T, A>)>, |
| 155 | sda: Peri<'d, if_afio!(impl SdaPin<T, A>)>, | 155 | sda: Peri<'d, if_afio!(impl SdaPin<T, A>)>, |
| 156 | _irq: impl interrupt::typelevel::Binding<T::EventInterrupt, EventInterruptHandler<T>> | 156 | _irq: impl interrupt::typelevel::Binding<T::EventInterrupt, EventInterruptHandler<T>> |
| 157 | + interrupt::typelevel::Binding<T::ErrorInterrupt, ErrorInterruptHandler<T>> | 157 | + interrupt::typelevel::Binding<T::ErrorInterrupt, ErrorInterruptHandler<T>> |
| 158 | + 'd, | 158 | + 'd, |
| 159 | tx_dma: Peri<'d, impl TxDma<T>>, | 159 | tx_dma: Peri<'d, impl TxDma<T>>, |
| 160 | rx_dma: Peri<'d, impl RxDma<T>>, | 160 | rx_dma: Peri<'d, impl RxDma<T>>, |
| 161 | config: Config, | 161 | config: Config, |
diff --git a/embassy-stm32/src/i2c/v1.rs b/embassy-stm32/src/i2c/v1.rs index 081eb1191..e6b6c7c42 100644 --- a/embassy-stm32/src/i2c/v1.rs +++ b/embassy-stm32/src/i2c/v1.rs | |||
| @@ -8,7 +8,7 @@ use core::future::poll_fn; | |||
| 8 | use core::task::Poll; | 8 | use core::task::Poll; |
| 9 | 9 | ||
| 10 | use embassy_embedded_hal::SetConfig; | 10 | use embassy_embedded_hal::SetConfig; |
| 11 | use embassy_futures::select::{select, Either}; | 11 | use embassy_futures::select::{Either, select}; |
| 12 | use embassy_hal_internal::drop::OnDrop; | 12 | use embassy_hal_internal::drop::OnDrop; |
| 13 | use embedded_hal_1::i2c::Operation; | 13 | use embedded_hal_1::i2c::Operation; |
| 14 | use mode::Master; | 14 | use mode::Master; |
| @@ -762,11 +762,7 @@ impl Timings { | |||
| 762 | mode = Mode::Standard; | 762 | mode = Mode::Standard; |
| 763 | ccr = { | 763 | ccr = { |
| 764 | let ccr = clock / (frequency * 2); | 764 | let ccr = clock / (frequency * 2); |
| 765 | if ccr < 4 { | 765 | if ccr < 4 { 4 } else { ccr } |
| 766 | 4 | ||
| 767 | } else { | ||
| 768 | ccr | ||
| 769 | } | ||
| 770 | }; | 766 | }; |
| 771 | } else { | 767 | } else { |
| 772 | const DUTYCYCLE: u8 = 0; | 768 | const DUTYCYCLE: u8 = 0; |
diff --git a/embassy-stm32/src/i2c/v2.rs b/embassy-stm32/src/i2c/v2.rs index 0bfc795ac..01b6b8800 100644 --- a/embassy-stm32/src/i2c/v2.rs +++ b/embassy-stm32/src/i2c/v2.rs | |||
| @@ -2,7 +2,7 @@ use core::cmp; | |||
| 2 | use core::future::poll_fn; | 2 | use core::future::poll_fn; |
| 3 | use core::task::Poll; | 3 | use core::task::Poll; |
| 4 | 4 | ||
| 5 | use config::{Address, OwnAddresses, OA2}; | 5 | use config::{Address, OA2, OwnAddresses}; |
| 6 | use embassy_embedded_hal::SetConfig; | 6 | use embassy_embedded_hal::SetConfig; |
| 7 | use embassy_hal_internal::drop::OnDrop; | 7 | use embassy_hal_internal::drop::OnDrop; |
| 8 | use embedded_hal_1::i2c::Operation; | 8 | use embedded_hal_1::i2c::Operation; |
diff --git a/embassy-stm32/src/i2s.rs b/embassy-stm32/src/i2s.rs index b6d3daf54..db22cfa11 100644 --- a/embassy-stm32/src/i2s.rs +++ b/embassy-stm32/src/i2s.rs | |||
| @@ -3,12 +3,12 @@ | |||
| 3 | use embassy_futures::join::join; | 3 | use embassy_futures::join::join; |
| 4 | use stm32_metapac::spi::vals; | 4 | use stm32_metapac::spi::vals; |
| 5 | 5 | ||
| 6 | use crate::dma::{ringbuffer, ChannelAndRequest, ReadableRingBuffer, TransferOptions, WritableRingBuffer}; | 6 | use crate::Peri; |
| 7 | use crate::dma::{ChannelAndRequest, ReadableRingBuffer, TransferOptions, WritableRingBuffer, ringbuffer}; | ||
| 7 | use crate::gpio::{AfType, AnyPin, OutputType, SealedPin, Speed}; | 8 | use crate::gpio::{AfType, AnyPin, OutputType, SealedPin, Speed}; |
| 8 | use crate::mode::Async; | 9 | use crate::mode::Async; |
| 9 | use crate::spi::{Config as SpiConfig, RegsExt as _, *}; | 10 | use crate::spi::{Config as SpiConfig, RegsExt as _, *}; |
| 10 | use crate::time::Hertz; | 11 | use crate::time::Hertz; |
| 11 | use crate::Peri; | ||
| 12 | 12 | ||
| 13 | /// I2S mode | 13 | /// I2S mode |
| 14 | #[derive(Copy, Clone)] | 14 | #[derive(Copy, Clone)] |
diff --git a/embassy-stm32/src/ipcc.rs b/embassy-stm32/src/ipcc.rs index 670d8332c..e1d8b1c2a 100644 --- a/embassy-stm32/src/ipcc.rs +++ b/embassy-stm32/src/ipcc.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | //! Inter-Process Communication Controller (IPCC) | 1 | //! Inter-Process Communication Controller (IPCC) |
| 2 | 2 | ||
| 3 | use core::future::poll_fn; | 3 | use core::future::poll_fn; |
| 4 | use core::sync::atomic::{compiler_fence, Ordering}; | 4 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 5 | use core::task::Poll; | 5 | use core::task::Poll; |
| 6 | 6 | ||
| 7 | use embassy_sync::waitqueue::AtomicWaker; | 7 | use embassy_sync::waitqueue::AtomicWaker; |
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 7e0f7884e..dbf0fe620 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #![cfg_attr(not(test), no_std)] | 1 | #![cfg_attr(not(test), no_std)] |
| 2 | #![allow(async_fn_in_trait)] | 2 | #![allow(async_fn_in_trait)] |
| 3 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 3 | #![cfg_attr( | 4 | #![cfg_attr( |
| 4 | docsrs, | 5 | docsrs, |
| 5 | doc = "<div style='padding:30px;background:#810;color:#fff;text-align:center;'><p>You might want to <a href='https://docs.embassy.dev/embassy-stm32'>browse the `embassy-stm32` documentation on the Embassy website</a> instead.</p><p>The documentation here on `docs.rs` is built for a single chip only (stm32h7, stm32h7rs55 in particular), while on the Embassy website you can pick your exact chip from the top menu. Available peripherals and their APIs change depending on the chip.</p></div>\n\n" | 6 | doc = "<div style='padding:30px;background:#810;color:#fff;text-align:center;'><p>You might want to <a href='https://docs.embassy.dev/embassy-stm32'>browse the `embassy-stm32` documentation on the Embassy website</a> instead.</p><p>The documentation here on `docs.rs` is built for a single chip only (stm32h7, stm32h7rs55 in particular), while on the Embassy website you can pick your exact chip from the top menu. Available peripherals and their APIs change depending on the chip.</p></div>\n\n" |
| @@ -194,7 +195,7 @@ macro_rules! bind_interrupts { | |||
| 194 | 195 | ||
| 195 | $( | 196 | $( |
| 196 | #[allow(non_snake_case)] | 197 | #[allow(non_snake_case)] |
| 197 | #[no_mangle] | 198 | #[unsafe(no_mangle)] |
| 198 | $(#[cfg($cond_irq)])? | 199 | $(#[cfg($cond_irq)])? |
| 199 | $(#[doc = $doc])* | 200 | $(#[doc = $doc])* |
| 200 | unsafe extern "C" fn $irq() { | 201 | unsafe extern "C" fn $irq() { |
| @@ -222,7 +223,7 @@ macro_rules! bind_interrupts { | |||
| 222 | } | 223 | } |
| 223 | 224 | ||
| 224 | // Reexports | 225 | // Reexports |
| 225 | pub use _generated::{peripherals, Peripherals}; | 226 | pub use _generated::{Peripherals, peripherals}; |
| 226 | pub use embassy_hal_internal::{Peri, PeripheralType}; | 227 | pub use embassy_hal_internal::{Peri, PeripheralType}; |
| 227 | #[cfg(feature = "unstable-pac")] | 228 | #[cfg(feature = "unstable-pac")] |
| 228 | pub use stm32_metapac as pac; | 229 | pub use stm32_metapac as pac; |
diff --git a/embassy-stm32/src/low_power.rs b/embassy-stm32/src/low_power.rs index 342f73bc8..1b66ca680 100644 --- a/embassy-stm32/src/low_power.rs +++ b/embassy-stm32/src/low_power.rs | |||
| @@ -56,13 +56,13 @@ | |||
| 56 | 56 | ||
| 57 | use core::arch::asm; | 57 | use core::arch::asm; |
| 58 | use core::marker::PhantomData; | 58 | use core::marker::PhantomData; |
| 59 | use core::sync::atomic::{compiler_fence, Ordering}; | 59 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 60 | 60 | ||
| 61 | use cortex_m::peripheral::SCB; | 61 | use cortex_m::peripheral::SCB; |
| 62 | use embassy_executor::*; | 62 | use embassy_executor::*; |
| 63 | 63 | ||
| 64 | use crate::interrupt; | 64 | use crate::interrupt; |
| 65 | use crate::time_driver::{get_driver, RtcDriver}; | 65 | use crate::time_driver::{RtcDriver, get_driver}; |
| 66 | 66 | ||
| 67 | const THREAD_PENDER: usize = usize::MAX; | 67 | const THREAD_PENDER: usize = usize::MAX; |
| 68 | 68 | ||
diff --git a/embassy-stm32/src/lptim/pwm.rs b/embassy-stm32/src/lptim/pwm.rs index 96af9f4d9..a69db3caf 100644 --- a/embassy-stm32/src/lptim/pwm.rs +++ b/embassy-stm32/src/lptim/pwm.rs | |||
| @@ -4,12 +4,12 @@ use core::marker::PhantomData; | |||
| 4 | 4 | ||
| 5 | use embassy_hal_internal::Peri; | 5 | use embassy_hal_internal::Peri; |
| 6 | 6 | ||
| 7 | use super::timer::Timer; | ||
| 8 | #[cfg(not(any(lptim_v2a, lptim_v2b)))] | 7 | #[cfg(not(any(lptim_v2a, lptim_v2b)))] |
| 9 | use super::OutputPin; | 8 | use super::OutputPin; |
| 10 | #[cfg(any(lptim_v2a, lptim_v2b))] | 9 | use super::timer::Timer; |
| 11 | use super::{channel::Channel, timer::ChannelDirection, Channel1Pin, Channel2Pin}; | ||
| 12 | use super::{BasicInstance, Instance}; | 10 | use super::{BasicInstance, Instance}; |
| 11 | #[cfg(any(lptim_v2a, lptim_v2b))] | ||
| 12 | use super::{Channel1Pin, Channel2Pin, channel::Channel, timer::ChannelDirection}; | ||
| 13 | #[cfg(gpio_v2)] | 13 | #[cfg(gpio_v2)] |
| 14 | use crate::gpio::Pull; | 14 | use crate::gpio::Pull; |
| 15 | use crate::gpio::{AfType, AnyPin, OutputType, Speed}; | 15 | use crate::gpio::{AfType, AnyPin, OutputType, Speed}; |
diff --git a/embassy-stm32/src/ltdc.rs b/embassy-stm32/src/ltdc.rs index 0f6ef569c..de2db9872 100644 --- a/embassy-stm32/src/ltdc.rs +++ b/embassy-stm32/src/ltdc.rs | |||
| @@ -14,7 +14,7 @@ use stm32_metapac::ltdc::vals::{Bf1, Bf2, Cfuif, Clif, Crrif, Cterrif, Pf, Vbr}; | |||
| 14 | use crate::gpio::{AfType, OutputType, Speed}; | 14 | use crate::gpio::{AfType, OutputType, Speed}; |
| 15 | use crate::interrupt::typelevel::Interrupt; | 15 | use crate::interrupt::typelevel::Interrupt; |
| 16 | use crate::interrupt::{self}; | 16 | use crate::interrupt::{self}; |
| 17 | use crate::{peripherals, rcc, Peri}; | 17 | use crate::{Peri, peripherals, rcc}; |
| 18 | 18 | ||
| 19 | static LTDC_WAKER: AtomicWaker = AtomicWaker::new(); | 19 | static LTDC_WAKER: AtomicWaker = AtomicWaker::new(); |
| 20 | 20 | ||
diff --git a/embassy-stm32/src/opamp.rs b/embassy-stm32/src/opamp.rs index e36719ef3..ac8d5de21 100644 --- a/embassy-stm32/src/opamp.rs +++ b/embassy-stm32/src/opamp.rs | |||
| @@ -3,10 +3,10 @@ | |||
| 3 | 3 | ||
| 4 | use embassy_hal_internal::PeripheralType; | 4 | use embassy_hal_internal::PeripheralType; |
| 5 | 5 | ||
| 6 | use crate::Peri; | ||
| 6 | use crate::pac::opamp::vals::*; | 7 | use crate::pac::opamp::vals::*; |
| 7 | #[cfg(not(any(stm32g4, stm32f3)))] | 8 | #[cfg(not(any(stm32g4, stm32f3)))] |
| 8 | use crate::rcc::RccInfo; | 9 | use crate::rcc::RccInfo; |
| 9 | use crate::Peri; | ||
| 10 | 10 | ||
| 11 | /// Performs a busy-wait delay for a specified number of microseconds. | 11 | /// Performs a busy-wait delay for a specified number of microseconds. |
| 12 | #[cfg(opamp_v5)] | 12 | #[cfg(opamp_v5)] |
diff --git a/embassy-stm32/src/ospi/mod.rs b/embassy-stm32/src/ospi/mod.rs index d93cecb69..592a8594a 100644 --- a/embassy-stm32/src/ospi/mod.rs +++ b/embassy-stm32/src/ospi/mod.rs | |||
| @@ -12,14 +12,14 @@ use embassy_hal_internal::PeripheralType; | |||
| 12 | pub use enums::*; | 12 | pub use enums::*; |
| 13 | use stm32_metapac::octospi::vals::{PhaseMode, SizeInBits}; | 13 | use stm32_metapac::octospi::vals::{PhaseMode, SizeInBits}; |
| 14 | 14 | ||
| 15 | use crate::dma::{word, ChannelAndRequest}; | 15 | use crate::dma::{ChannelAndRequest, word}; |
| 16 | use crate::gpio::{AfType, AnyPin, OutputType, Pull, SealedPin as _, Speed}; | 16 | use crate::gpio::{AfType, AnyPin, OutputType, Pull, SealedPin as _, Speed}; |
| 17 | use crate::mode::{Async, Blocking, Mode as PeriMode}; | 17 | use crate::mode::{Async, Blocking, Mode as PeriMode}; |
| 18 | use crate::pac::octospi::{vals, Octospi as Regs}; | 18 | use crate::pac::octospi::{Octospi as Regs, vals}; |
| 19 | #[cfg(octospim_v1)] | 19 | #[cfg(octospim_v1)] |
| 20 | use crate::pac::octospim::Octospim; | 20 | use crate::pac::octospim::Octospim; |
| 21 | use crate::rcc::{self, RccPeripheral}; | 21 | use crate::rcc::{self, RccPeripheral}; |
| 22 | use crate::{peripherals, Peri}; | 22 | use crate::{Peri, peripherals}; |
| 23 | 23 | ||
| 24 | /// OPSI driver config. | 24 | /// OPSI driver config. |
| 25 | #[derive(Clone, Copy)] | 25 | #[derive(Clone, Copy)] |
diff --git a/embassy-stm32/src/qspi/mod.rs b/embassy-stm32/src/qspi/mod.rs index b03cd9009..bb4f4f1d0 100644 --- a/embassy-stm32/src/qspi/mod.rs +++ b/embassy-stm32/src/qspi/mod.rs | |||
| @@ -14,7 +14,7 @@ use crate::gpio::{AfType, AnyPin, OutputType, Pull, Speed}; | |||
| 14 | use crate::mode::{Async, Blocking, Mode as PeriMode}; | 14 | use crate::mode::{Async, Blocking, Mode as PeriMode}; |
| 15 | use crate::pac::quadspi::Quadspi as Regs; | 15 | use crate::pac::quadspi::Quadspi as Regs; |
| 16 | use crate::rcc::{self, RccPeripheral}; | 16 | use crate::rcc::{self, RccPeripheral}; |
| 17 | use crate::{peripherals, Peri}; | 17 | use crate::{Peri, peripherals}; |
| 18 | 18 | ||
| 19 | /// QSPI transfer configuration. | 19 | /// QSPI transfer configuration. |
| 20 | #[derive(Clone, Copy)] | 20 | #[derive(Clone, Copy)] |
diff --git a/embassy-stm32/src/rcc/bd.rs b/embassy-stm32/src/rcc/bd.rs index 63fc195dd..3b2a10581 100644 --- a/embassy-stm32/src/rcc/bd.rs +++ b/embassy-stm32/src/rcc/bd.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | use core::sync::atomic::{compiler_fence, Ordering}; | 1 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 2 | 2 | ||
| 3 | use crate::pac::common::{Reg, RW}; | 3 | use crate::pac::common::{RW, Reg}; |
| 4 | pub use crate::pac::rcc::vals::Rtcsel as RtcClockSource; | 4 | pub use crate::pac::rcc::vals::Rtcsel as RtcClockSource; |
| 5 | use crate::time::Hertz; | 5 | use crate::time::Hertz; |
| 6 | 6 | ||
diff --git a/embassy-stm32/src/rcc/f247.rs b/embassy-stm32/src/rcc/f247.rs index 8f2e8db5f..d941054cd 100644 --- a/embassy-stm32/src/rcc/f247.rs +++ b/embassy-stm32/src/rcc/f247.rs | |||
| @@ -1,13 +1,13 @@ | |||
| 1 | use stm32_metapac::flash::vals::Latency; | 1 | use stm32_metapac::flash::vals::Latency; |
| 2 | 2 | ||
| 3 | #[cfg(any(stm32f4, stm32f7))] | ||
| 4 | use crate::pac::PWR; | ||
| 3 | #[cfg(any(stm32f413, stm32f423, stm32f412))] | 5 | #[cfg(any(stm32f413, stm32f423, stm32f412))] |
| 4 | pub use crate::pac::rcc::vals::Plli2ssrc as Plli2sSource; | 6 | pub use crate::pac::rcc::vals::Plli2ssrc as Plli2sSource; |
| 5 | pub use crate::pac::rcc::vals::{ | 7 | pub use crate::pac::rcc::vals::{ |
| 6 | Hpre as AHBPrescaler, Pllm as PllPreDiv, Plln as PllMul, Pllp as PllPDiv, Pllq as PllQDiv, Pllr as PllRDiv, | 8 | Hpre as AHBPrescaler, Pllm as PllPreDiv, Plln as PllMul, Pllp as PllPDiv, Pllq as PllQDiv, Pllr as PllRDiv, |
| 7 | Pllsrc as PllSource, Ppre as APBPrescaler, Sw as Sysclk, | 9 | Pllsrc as PllSource, Ppre as APBPrescaler, Sw as Sysclk, |
| 8 | }; | 10 | }; |
| 9 | #[cfg(any(stm32f4, stm32f7))] | ||
| 10 | use crate::pac::PWR; | ||
| 11 | use crate::pac::{FLASH, RCC}; | 11 | use crate::pac::{FLASH, RCC}; |
| 12 | use crate::time::Hertz; | 12 | use crate::time::Hertz; |
| 13 | 13 | ||
diff --git a/embassy-stm32/src/rcc/h.rs b/embassy-stm32/src/rcc/h.rs index 331bab7a0..485edd390 100644 --- a/embassy-stm32/src/rcc/h.rs +++ b/embassy-stm32/src/rcc/h.rs | |||
| @@ -597,7 +597,10 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 597 | Hertz(24_000_000) => Usbrefcksel::MHZ24, | 597 | Hertz(24_000_000) => Usbrefcksel::MHZ24, |
| 598 | Hertz(26_000_000) => Usbrefcksel::MHZ26, | 598 | Hertz(26_000_000) => Usbrefcksel::MHZ26, |
| 599 | Hertz(32_000_000) => Usbrefcksel::MHZ32, | 599 | Hertz(32_000_000) => Usbrefcksel::MHZ32, |
| 600 | _ => panic!("cannot select USBPHYC reference clock with source frequency of {}, must be one of 16, 19.2, 20, 24, 26, 32 MHz", clk_val), | 600 | _ => panic!( |
| 601 | "cannot select USBPHYC reference clock with source frequency of {}, must be one of 16, 19.2, 20, 24, 26, 32 MHz", | ||
| 602 | clk_val | ||
| 603 | ), | ||
| 601 | }, | 604 | }, |
| 602 | None => Usbrefcksel::MHZ24, | 605 | None => Usbrefcksel::MHZ24, |
| 603 | }; | 606 | }; |
diff --git a/embassy-stm32/src/rcc/l.rs b/embassy-stm32/src/rcc/l.rs index 81b89046e..2e1cbd702 100644 --- a/embassy-stm32/src/rcc/l.rs +++ b/embassy-stm32/src/rcc/l.rs | |||
| @@ -499,9 +499,9 @@ pub use pll::*; | |||
| 499 | 499 | ||
| 500 | #[cfg(any(stm32l0, stm32l1))] | 500 | #[cfg(any(stm32l0, stm32l1))] |
| 501 | mod pll { | 501 | mod pll { |
| 502 | use super::{pll_enable, PllInstance}; | 502 | use super::{PllInstance, pll_enable}; |
| 503 | pub use crate::pac::rcc::vals::{Plldiv as PllDiv, Pllmul as PllMul, Pllsrc as PllSource}; | ||
| 504 | use crate::pac::RCC; | 503 | use crate::pac::RCC; |
| 504 | pub use crate::pac::rcc::vals::{Plldiv as PllDiv, Pllmul as PllMul, Pllsrc as PllSource}; | ||
| 505 | use crate::time::Hertz; | 505 | use crate::time::Hertz; |
| 506 | 506 | ||
| 507 | #[derive(Clone, Copy)] | 507 | #[derive(Clone, Copy)] |
| @@ -563,11 +563,11 @@ mod pll { | |||
| 563 | 563 | ||
| 564 | #[cfg(any(stm32l4, stm32l5, stm32wb, stm32wl, stm32u0))] | 564 | #[cfg(any(stm32l4, stm32l5, stm32wb, stm32wl, stm32u0))] |
| 565 | mod pll { | 565 | mod pll { |
| 566 | use super::{pll_enable, PllInstance}; | 566 | use super::{PllInstance, pll_enable}; |
| 567 | use crate::pac::RCC; | ||
| 567 | pub use crate::pac::rcc::vals::{ | 568 | pub use crate::pac::rcc::vals::{ |
| 568 | Pllm as PllPreDiv, Plln as PllMul, Pllp as PllPDiv, Pllq as PllQDiv, Pllr as PllRDiv, Pllsrc as PllSource, | 569 | Pllm as PllPreDiv, Plln as PllMul, Pllp as PllPDiv, Pllq as PllQDiv, Pllr as PllRDiv, Pllsrc as PllSource, |
| 569 | }; | 570 | }; |
| 570 | use crate::pac::RCC; | ||
| 571 | use crate::time::Hertz; | 571 | use crate::time::Hertz; |
| 572 | 572 | ||
| 573 | #[derive(Clone, Copy)] | 573 | #[derive(Clone, Copy)] |
diff --git a/embassy-stm32/src/rcc/mco.rs b/embassy-stm32/src/rcc/mco.rs index 59ccc8cb5..3d961df03 100644 --- a/embassy-stm32/src/rcc/mco.rs +++ b/embassy-stm32/src/rcc/mco.rs | |||
| @@ -3,6 +3,7 @@ use core::marker::PhantomData; | |||
| 3 | use embassy_hal_internal::PeripheralType; | 3 | use embassy_hal_internal::PeripheralType; |
| 4 | 4 | ||
| 5 | use crate::gpio::{AfType, OutputType, Speed}; | 5 | use crate::gpio::{AfType, OutputType, Speed}; |
| 6 | use crate::pac::RCC; | ||
| 6 | #[cfg(not(any(stm32f1, rcc_f0v1, rcc_f3v1, rcc_f37)))] | 7 | #[cfg(not(any(stm32f1, rcc_f0v1, rcc_f3v1, rcc_f37)))] |
| 7 | pub use crate::pac::rcc::vals::Mcopre as McoPrescaler; | 8 | pub use crate::pac::rcc::vals::Mcopre as McoPrescaler; |
| 8 | #[cfg(not(any( | 9 | #[cfg(not(any( |
| @@ -31,8 +32,7 @@ pub use crate::pac::rcc::vals::Mcosel as McoSource; | |||
| 31 | rcc_h7rs | 32 | rcc_h7rs |
| 32 | ))] | 33 | ))] |
| 33 | pub use crate::pac::rcc::vals::{Mco1sel as Mco1Source, Mco2sel as Mco2Source}; | 34 | pub use crate::pac::rcc::vals::{Mco1sel as Mco1Source, Mco2sel as Mco2Source}; |
| 34 | use crate::pac::RCC; | 35 | use crate::{Peri, peripherals}; |
| 35 | use crate::{peripherals, Peri}; | ||
| 36 | 36 | ||
| 37 | #[cfg(any(stm32f1, rcc_f0v1, rcc_f3v1, rcc_f37))] | 37 | #[cfg(any(stm32f1, rcc_f0v1, rcc_f3v1, rcc_f37))] |
| 38 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | 38 | #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] |
| @@ -91,12 +91,29 @@ pub struct Mco<'d, T: McoInstance> { | |||
| 91 | 91 | ||
| 92 | impl<'d, T: McoInstance> Mco<'d, T> { | 92 | impl<'d, T: McoInstance> Mco<'d, T> { |
| 93 | /// Create a new MCO instance. | 93 | /// Create a new MCO instance. |
| 94 | pub fn new(_peri: Peri<'d, T>, pin: Peri<'d, impl McoPin<T>>, source: T::Source, prescaler: McoPrescaler) -> Self { | 94 | pub fn new(_peri: Peri<'d, T>, pin: Peri<'d, impl McoPin<T>>, source: T::Source, config: McoConfig) -> Self { |
| 95 | critical_section::with(|_| unsafe { | 95 | critical_section::with(|_| unsafe { |
| 96 | T::_apply_clock_settings(source, prescaler); | 96 | T::_apply_clock_settings(source, config.prescaler); |
| 97 | set_as_af!(pin, AfType::output(OutputType::PushPull, Speed::VeryHigh)); | 97 | set_as_af!(pin, AfType::output(OutputType::PushPull, config.speed)); |
| 98 | }); | 98 | }); |
| 99 | 99 | ||
| 100 | Self { phantom: PhantomData } | 100 | Self { phantom: PhantomData } |
| 101 | } | 101 | } |
| 102 | } | 102 | } |
| 103 | |||
| 104 | #[non_exhaustive] | ||
| 105 | pub struct McoConfig { | ||
| 106 | /// Master Clock Out prescaler | ||
| 107 | pub prescaler: McoPrescaler, | ||
| 108 | /// IO Drive Strength | ||
| 109 | pub speed: Speed, | ||
| 110 | } | ||
| 111 | |||
| 112 | impl Default for McoConfig { | ||
| 113 | fn default() -> Self { | ||
| 114 | Self { | ||
| 115 | prescaler: McoPrescaler::DIV1, | ||
| 116 | speed: Speed::VeryHigh, | ||
| 117 | } | ||
| 118 | } | ||
| 119 | } | ||
diff --git a/embassy-stm32/src/rcc/mod.rs b/embassy-stm32/src/rcc/mod.rs index c41f81816..addfca3c3 100644 --- a/embassy-stm32/src/rcc/mod.rs +++ b/embassy-stm32/src/rcc/mod.rs | |||
| @@ -33,7 +33,7 @@ mod _version; | |||
| 33 | pub use _version::*; | 33 | pub use _version::*; |
| 34 | use stm32_metapac::RCC; | 34 | use stm32_metapac::RCC; |
| 35 | 35 | ||
| 36 | pub use crate::_generated::{mux, Clocks}; | 36 | pub use crate::_generated::{Clocks, mux}; |
| 37 | use crate::time::Hertz; | 37 | use crate::time::Hertz; |
| 38 | 38 | ||
| 39 | #[cfg(feature = "low-power")] | 39 | #[cfg(feature = "low-power")] |
diff --git a/embassy-stm32/src/rcc/u5.rs b/embassy-stm32/src/rcc/u5.rs index 06895a99a..7b0dcb63f 100644 --- a/embassy-stm32/src/rcc/u5.rs +++ b/embassy-stm32/src/rcc/u5.rs | |||
| @@ -6,9 +6,9 @@ pub use crate::pac::rcc::vals::{ | |||
| 6 | Pllsrc as PllSource, Ppre as APBPrescaler, Sw as Sysclk, | 6 | Pllsrc as PllSource, Ppre as APBPrescaler, Sw as Sysclk, |
| 7 | }; | 7 | }; |
| 8 | use crate::pac::rcc::vals::{Hseext, Msipllfast, Msipllsel, Msirgsel, Pllmboost, Pllrge}; | 8 | use crate::pac::rcc::vals::{Hseext, Msipllfast, Msipllsel, Msirgsel, Pllmboost, Pllrge}; |
| 9 | #[cfg(all(peri_usb_otg_hs))] | ||
| 10 | pub use crate::pac::{syscfg::vals::Usbrefcksel, SYSCFG}; | ||
| 11 | use crate::pac::{FLASH, PWR, RCC}; | 9 | use crate::pac::{FLASH, PWR, RCC}; |
| 10 | #[cfg(all(peri_usb_otg_hs))] | ||
| 11 | pub use crate::pac::{SYSCFG, syscfg::vals::Usbrefcksel}; | ||
| 12 | use crate::rcc::LSI_FREQ; | 12 | use crate::rcc::LSI_FREQ; |
| 13 | use crate::time::Hertz; | 13 | use crate::time::Hertz; |
| 14 | 14 | ||
| @@ -442,7 +442,10 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 442 | Hertz(24_000_000) => Usbrefcksel::MHZ24, | 442 | Hertz(24_000_000) => Usbrefcksel::MHZ24, |
| 443 | Hertz(26_000_000) => Usbrefcksel::MHZ26, | 443 | Hertz(26_000_000) => Usbrefcksel::MHZ26, |
| 444 | Hertz(32_000_000) => Usbrefcksel::MHZ32, | 444 | Hertz(32_000_000) => Usbrefcksel::MHZ32, |
| 445 | _ => panic!("cannot select OTG_HS reference clock with source frequency of {}, must be one of 16, 19.2, 20, 24, 26, 32 MHz", clk_val), | 445 | _ => panic!( |
| 446 | "cannot select OTG_HS reference clock with source frequency of {}, must be one of 16, 19.2, 20, 24, 26, 32 MHz", | ||
| 447 | clk_val | ||
| 448 | ), | ||
| 446 | }, | 449 | }, |
| 447 | None => Usbrefcksel::MHZ24, | 450 | None => Usbrefcksel::MHZ24, |
| 448 | }; | 451 | }; |
diff --git a/embassy-stm32/src/rcc/wba.rs b/embassy-stm32/src/rcc/wba.rs index 481437939..2528996d5 100644 --- a/embassy-stm32/src/rcc/wba.rs +++ b/embassy-stm32/src/rcc/wba.rs | |||
| @@ -7,9 +7,9 @@ pub use crate::pac::rcc::vals::{ | |||
| 7 | Hdiv5, Hpre as AHBPrescaler, Hpre5 as AHB5Prescaler, Hsepre as HsePrescaler, Plldiv as PllDiv, Pllm as PllPreDiv, | 7 | Hdiv5, Hpre as AHBPrescaler, Hpre5 as AHB5Prescaler, Hsepre as HsePrescaler, Plldiv as PllDiv, Pllm as PllPreDiv, |
| 8 | Plln as PllMul, Pllsrc as PllSource, Ppre as APBPrescaler, Sai1sel, Sw as Sysclk, | 8 | Plln as PllMul, Pllsrc as PllSource, Ppre as APBPrescaler, Sai1sel, Sw as Sysclk, |
| 9 | }; | 9 | }; |
| 10 | #[cfg(all(peri_usb_otg_hs))] | ||
| 11 | pub use crate::pac::{syscfg::vals::Usbrefcksel, SYSCFG}; | ||
| 12 | use crate::pac::{FLASH, RCC}; | 10 | use crate::pac::{FLASH, RCC}; |
| 11 | #[cfg(all(peri_usb_otg_hs))] | ||
| 12 | pub use crate::pac::{SYSCFG, syscfg::vals::Usbrefcksel}; | ||
| 13 | use crate::rcc::LSI_FREQ; | 13 | use crate::rcc::LSI_FREQ; |
| 14 | use crate::time::Hertz; | 14 | use crate::time::Hertz; |
| 15 | 15 | ||
| @@ -245,7 +245,10 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 245 | Hertz(24_000_000) => Usbrefcksel::MHZ24, | 245 | Hertz(24_000_000) => Usbrefcksel::MHZ24, |
| 246 | Hertz(26_000_000) => Usbrefcksel::MHZ26, | 246 | Hertz(26_000_000) => Usbrefcksel::MHZ26, |
| 247 | Hertz(32_000_000) => Usbrefcksel::MHZ32, | 247 | Hertz(32_000_000) => Usbrefcksel::MHZ32, |
| 248 | _ => panic!("cannot select OTG_HS reference clock with source frequency of {}, must be one of 16, 19.2, 20, 24, 26, 32 MHz", clk_val), | 248 | _ => panic!( |
| 249 | "cannot select OTG_HS reference clock with source frequency of {}, must be one of 16, 19.2, 20, 24, 26, 32 MHz", | ||
| 250 | clk_val | ||
| 251 | ), | ||
| 249 | }, | 252 | }, |
| 250 | None => Usbrefcksel::MHZ24, | 253 | None => Usbrefcksel::MHZ24, |
| 251 | }; | 254 | }; |
diff --git a/embassy-stm32/src/rng.rs b/embassy-stm32/src/rng.rs index 63654639e..dada9bda1 100644 --- a/embassy-stm32/src/rng.rs +++ b/embassy-stm32/src/rng.rs | |||
| @@ -9,7 +9,7 @@ use embassy_hal_internal::PeripheralType; | |||
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 10 | 10 | ||
| 11 | use crate::interrupt::typelevel::Interrupt; | 11 | use crate::interrupt::typelevel::Interrupt; |
| 12 | use crate::{interrupt, pac, peripherals, rcc, Peri}; | 12 | use crate::{Peri, interrupt, pac, peripherals, rcc}; |
| 13 | 13 | ||
| 14 | static RNG_WAKER: AtomicWaker = AtomicWaker::new(); | 14 | static RNG_WAKER: AtomicWaker = AtomicWaker::new(); |
| 15 | 15 | ||
diff --git a/embassy-stm32/src/rtc/low_power.rs b/embassy-stm32/src/rtc/low_power.rs index a81ac6746..999f24714 100644 --- a/embassy-stm32/src/rtc/low_power.rs +++ b/embassy-stm32/src/rtc/low_power.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #[cfg(feature = "time")] | 1 | #[cfg(feature = "time")] |
| 2 | use embassy_time::{Duration, TICK_HZ}; | 2 | use embassy_time::{Duration, TICK_HZ}; |
| 3 | 3 | ||
| 4 | use super::{bcd2_to_byte, DateTimeError, Rtc, RtcError}; | 4 | use super::{DateTimeError, Rtc, RtcError, bcd2_to_byte}; |
| 5 | use crate::interrupt::typelevel::Interrupt; | 5 | use crate::interrupt::typelevel::Interrupt; |
| 6 | use crate::peripherals::RTC; | 6 | use crate::peripherals::RTC; |
| 7 | use crate::rtc::SealedInstance; | 7 | use crate::rtc::SealedInstance; |
diff --git a/embassy-stm32/src/rtc/mod.rs b/embassy-stm32/src/rtc/mod.rs index 92dec0960..bc6df528b 100644 --- a/embassy-stm32/src/rtc/mod.rs +++ b/embassy-stm32/src/rtc/mod.rs | |||
| @@ -8,12 +8,12 @@ mod low_power; | |||
| 8 | use core::cell::Cell; | 8 | use core::cell::Cell; |
| 9 | 9 | ||
| 10 | #[cfg(feature = "low-power")] | 10 | #[cfg(feature = "low-power")] |
| 11 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | ||
| 12 | #[cfg(feature = "low-power")] | ||
| 13 | use embassy_sync::blocking_mutex::Mutex; | 11 | use embassy_sync::blocking_mutex::Mutex; |
| 12 | #[cfg(feature = "low-power")] | ||
| 13 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | ||
| 14 | 14 | ||
| 15 | use self::datetime::{day_of_week_from_u8, day_of_week_to_u8}; | ||
| 16 | pub use self::datetime::{DateTime, DayOfWeek, Error as DateTimeError}; | 15 | pub use self::datetime::{DateTime, DayOfWeek, Error as DateTimeError}; |
| 16 | use self::datetime::{day_of_week_from_u8, day_of_week_to_u8}; | ||
| 17 | use crate::pac::rtc::regs::{Dr, Tr}; | 17 | use crate::pac::rtc::regs::{Dr, Tr}; |
| 18 | use crate::time::Hertz; | 18 | use crate::time::Hertz; |
| 19 | 19 | ||
| @@ -25,8 +25,8 @@ mod _version; | |||
| 25 | #[allow(unused_imports)] | 25 | #[allow(unused_imports)] |
| 26 | pub use _version::*; | 26 | pub use _version::*; |
| 27 | 27 | ||
| 28 | use crate::peripherals::RTC; | ||
| 29 | use crate::Peri; | 28 | use crate::Peri; |
| 29 | use crate::peripherals::RTC; | ||
| 30 | 30 | ||
| 31 | /// Errors that can occur on methods on [RtcClock] | 31 | /// Errors that can occur on methods on [RtcClock] |
| 32 | #[non_exhaustive] | 32 | #[non_exhaustive] |
diff --git a/embassy-stm32/src/rtc/v3.rs b/embassy-stm32/src/rtc/v3.rs index d0b52049e..01da5d70a 100644 --- a/embassy-stm32/src/rtc/v3.rs +++ b/embassy-stm32/src/rtc/v3.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use stm32_metapac::rtc::vals::{Calp, Calw16, Calw8, Fmt, Key, Osel, Pol, TampalrmType}; | 1 | use stm32_metapac::rtc::vals::{Calp, Calw8, Calw16, Fmt, Key, Osel, Pol, TampalrmType}; |
| 2 | 2 | ||
| 3 | use super::RtcCalibrationCyclePeriod; | 3 | use super::RtcCalibrationCyclePeriod; |
| 4 | use crate::pac::rtc::Rtc; | 4 | use crate::pac::rtc::Rtc; |
diff --git a/embassy-stm32/src/sai/mod.rs b/embassy-stm32/src/sai/mod.rs index fb8b23b79..726d1729a 100644 --- a/embassy-stm32/src/sai/mod.rs +++ b/embassy-stm32/src/sai/mod.rs | |||
| @@ -6,12 +6,12 @@ use core::marker::PhantomData; | |||
| 6 | use embassy_hal_internal::PeripheralType; | 6 | use embassy_hal_internal::PeripheralType; |
| 7 | 7 | ||
| 8 | pub use crate::dma::word; | 8 | pub use crate::dma::word; |
| 9 | use crate::dma::{ringbuffer, Channel, ReadableRingBuffer, Request, TransferOptions, WritableRingBuffer}; | 9 | use crate::dma::{Channel, ReadableRingBuffer, Request, TransferOptions, WritableRingBuffer, ringbuffer}; |
| 10 | use crate::gpio::{AfType, AnyPin, OutputType, Pull, SealedPin as _, Speed}; | 10 | use crate::gpio::{AfType, AnyPin, OutputType, Pull, SealedPin as _, Speed}; |
| 11 | pub use crate::pac::sai::vals::Mckdiv as MasterClockDivider; | 11 | pub use crate::pac::sai::vals::Mckdiv as MasterClockDivider; |
| 12 | use crate::pac::sai::{vals, Sai as Regs}; | 12 | use crate::pac::sai::{Sai as Regs, vals}; |
| 13 | use crate::rcc::{self, RccPeripheral}; | 13 | use crate::rcc::{self, RccPeripheral}; |
| 14 | use crate::{peripherals, Peri}; | 14 | use crate::{Peri, peripherals}; |
| 15 | 15 | ||
| 16 | /// SAI error | 16 | /// SAI error |
| 17 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 17 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
diff --git a/embassy-stm32/src/sdmmc/mod.rs b/embassy-stm32/src/sdmmc/mod.rs index ccbd16cbf..408d1b764 100644 --- a/embassy-stm32/src/sdmmc/mod.rs +++ b/embassy-stm32/src/sdmmc/mod.rs | |||
| @@ -11,9 +11,9 @@ use embassy_hal_internal::drop::OnDrop; | |||
| 11 | use embassy_hal_internal::{Peri, PeripheralType}; | 11 | use embassy_hal_internal::{Peri, PeripheralType}; |
| 12 | use embassy_sync::waitqueue::AtomicWaker; | 12 | use embassy_sync::waitqueue::AtomicWaker; |
| 13 | use sdio_host::common_cmd::{self, Resp, ResponseLen}; | 13 | use sdio_host::common_cmd::{self, Resp, ResponseLen}; |
| 14 | use sdio_host::emmc::{ExtCSD, EMMC}; | 14 | use sdio_host::emmc::{EMMC, ExtCSD}; |
| 15 | use sdio_host::sd::{BusWidth, CardCapacity, CardStatus, CurrentState, SDStatus, CIC, CID, CSD, OCR, RCA, SCR, SD}; | 15 | use sdio_host::sd::{BusWidth, CIC, CID, CSD, CardCapacity, CardStatus, CurrentState, OCR, RCA, SCR, SD, SDStatus}; |
| 16 | use sdio_host::{emmc_cmd, sd_cmd, Cmd}; | 16 | use sdio_host::{Cmd, emmc_cmd, sd_cmd}; |
| 17 | 17 | ||
| 18 | #[cfg(sdmmc_v1)] | 18 | #[cfg(sdmmc_v1)] |
| 19 | use crate::dma::ChannelAndRequest; | 19 | use crate::dma::ChannelAndRequest; |
diff --git a/embassy-stm32/src/spdifrx/mod.rs b/embassy-stm32/src/spdifrx/mod.rs index b0a32d5d1..6f2d24560 100644 --- a/embassy-stm32/src/spdifrx/mod.rs +++ b/embassy-stm32/src/spdifrx/mod.rs | |||
| @@ -13,7 +13,7 @@ use crate::gpio::{AfType, AnyPin, Pull, SealedPin as _}; | |||
| 13 | use crate::interrupt::typelevel::Interrupt; | 13 | use crate::interrupt::typelevel::Interrupt; |
| 14 | use crate::pac::spdifrx::Spdifrx as Regs; | 14 | use crate::pac::spdifrx::Spdifrx as Regs; |
| 15 | use crate::rcc::{RccInfo, SealedRccPeripheral}; | 15 | use crate::rcc::{RccInfo, SealedRccPeripheral}; |
| 16 | use crate::{interrupt, peripherals, Peri}; | 16 | use crate::{Peri, interrupt, peripherals}; |
| 17 | 17 | ||
| 18 | /// Possible S/PDIF preamble types. | 18 | /// Possible S/PDIF preamble types. |
| 19 | #[allow(dead_code)] | 19 | #[allow(dead_code)] |
diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index c5373a54d..c27d09ea7 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs | |||
| @@ -6,15 +6,15 @@ use core::ptr; | |||
| 6 | 6 | ||
| 7 | use embassy_embedded_hal::SetConfig; | 7 | use embassy_embedded_hal::SetConfig; |
| 8 | use embassy_futures::join::join; | 8 | use embassy_futures::join::join; |
| 9 | pub use embedded_hal_02::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_3}; | 9 | pub use embedded_hal_02::spi::{MODE_0, MODE_1, MODE_2, MODE_3, Mode, Phase, Polarity}; |
| 10 | 10 | ||
| 11 | use crate::dma::{word, ChannelAndRequest}; | 11 | use crate::Peri; |
| 12 | use crate::dma::{ChannelAndRequest, word}; | ||
| 12 | use crate::gpio::{AfType, AnyPin, OutputType, Pull, SealedPin as _, Speed}; | 13 | use crate::gpio::{AfType, AnyPin, OutputType, Pull, SealedPin as _, Speed}; |
| 13 | use crate::mode::{Async, Blocking, Mode as PeriMode}; | 14 | use crate::mode::{Async, Blocking, Mode as PeriMode}; |
| 14 | use crate::pac::spi::{regs, vals, Spi as Regs}; | 15 | use crate::pac::spi::{Spi as Regs, regs, vals}; |
| 15 | use crate::rcc::{RccInfo, SealedRccPeripheral}; | 16 | use crate::rcc::{RccInfo, SealedRccPeripheral}; |
| 16 | use crate::time::Hertz; | 17 | use crate::time::Hertz; |
| 17 | use crate::Peri; | ||
| 18 | 18 | ||
| 19 | /// SPI error. | 19 | /// SPI error. |
| 20 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 20 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] |
diff --git a/embassy-stm32/src/time_driver.rs b/embassy-stm32/src/time_driver.rs index 7db74bdf6..74b10a183 100644 --- a/embassy-stm32/src/time_driver.rs +++ b/embassy-stm32/src/time_driver.rs | |||
| @@ -1,14 +1,14 @@ | |||
| 1 | #![allow(non_snake_case)] | 1 | #![allow(non_snake_case)] |
| 2 | 2 | ||
| 3 | use core::cell::{Cell, RefCell}; | 3 | use core::cell::{Cell, RefCell}; |
| 4 | use core::sync::atomic::{compiler_fence, AtomicU32, Ordering}; | 4 | use core::sync::atomic::{AtomicU32, Ordering, compiler_fence}; |
| 5 | 5 | ||
| 6 | use critical_section::CriticalSection; | 6 | use critical_section::CriticalSection; |
| 7 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | ||
| 8 | use embassy_sync::blocking_mutex::Mutex; | 7 | use embassy_sync::blocking_mutex::Mutex; |
| 8 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | ||
| 9 | use embassy_time_driver::{Driver, TICK_HZ}; | 9 | use embassy_time_driver::{Driver, TICK_HZ}; |
| 10 | use embassy_time_queue_utils::Queue; | 10 | use embassy_time_queue_utils::Queue; |
| 11 | use stm32_metapac::timer::{regs, TimGp16}; | 11 | use stm32_metapac::timer::{TimGp16, regs}; |
| 12 | 12 | ||
| 13 | use crate::interrupt::typelevel::Interrupt; | 13 | use crate::interrupt::typelevel::Interrupt; |
| 14 | use crate::pac::timer::vals; | 14 | use crate::pac::timer::vals; |
diff --git a/embassy-stm32/src/timer/complementary_pwm.rs b/embassy-stm32/src/timer/complementary_pwm.rs index 484aae1d0..75a83629c 100644 --- a/embassy-stm32/src/timer/complementary_pwm.rs +++ b/embassy-stm32/src/timer/complementary_pwm.rs | |||
| @@ -7,11 +7,11 @@ pub use stm32_metapac::timer::vals::{Ckd, Ossi, Ossr}; | |||
| 7 | use super::low_level::{CountingMode, OutputPolarity, Timer}; | 7 | use super::low_level::{CountingMode, OutputPolarity, Timer}; |
| 8 | use super::simple_pwm::PwmPin; | 8 | use super::simple_pwm::PwmPin; |
| 9 | use super::{AdvancedInstance4Channel, Ch1, Ch2, Ch3, Ch4, Channel, TimerComplementaryPin}; | 9 | use super::{AdvancedInstance4Channel, Ch1, Ch2, Ch3, Ch4, Channel, TimerComplementaryPin}; |
| 10 | use crate::Peri; | ||
| 10 | use crate::gpio::{AnyPin, OutputType}; | 11 | use crate::gpio::{AnyPin, OutputType}; |
| 11 | use crate::time::Hertz; | 12 | use crate::time::Hertz; |
| 12 | use crate::timer::low_level::OutputCompareMode; | ||
| 13 | use crate::timer::TimerChannel; | 13 | use crate::timer::TimerChannel; |
| 14 | use crate::Peri; | 14 | use crate::timer::low_level::OutputCompareMode; |
| 15 | 15 | ||
| 16 | /// Complementary PWM pin wrapper. | 16 | /// Complementary PWM pin wrapper. |
| 17 | /// | 17 | /// |
| @@ -388,7 +388,7 @@ fn compute_dead_time_value(value: u16) -> (Ckd, u8) { | |||
| 388 | 388 | ||
| 389 | #[cfg(test)] | 389 | #[cfg(test)] |
| 390 | mod tests { | 390 | mod tests { |
| 391 | use super::{compute_dead_time_value, Ckd}; | 391 | use super::{Ckd, compute_dead_time_value}; |
| 392 | 392 | ||
| 393 | #[test] | 393 | #[test] |
| 394 | fn test_compute_dead_time_value() { | 394 | fn test_compute_dead_time_value() { |
diff --git a/embassy-stm32/src/timer/input_capture.rs b/embassy-stm32/src/timer/input_capture.rs index 7a25e6c21..2a4ec2db0 100644 --- a/embassy-stm32/src/timer/input_capture.rs +++ b/embassy-stm32/src/timer/input_capture.rs | |||
| @@ -8,11 +8,11 @@ use core::task::{Context, Poll}; | |||
| 8 | use super::low_level::{CountingMode, FilterValue, InputCaptureMode, InputTISelection, Timer}; | 8 | use super::low_level::{CountingMode, FilterValue, InputCaptureMode, InputTISelection, Timer}; |
| 9 | use super::{CaptureCompareInterruptHandler, Channel, GeneralInstance4Channel, TimerPin}; | 9 | use super::{CaptureCompareInterruptHandler, Channel, GeneralInstance4Channel, TimerPin}; |
| 10 | pub use super::{Ch1, Ch2, Ch3, Ch4}; | 10 | pub use super::{Ch1, Ch2, Ch3, Ch4}; |
| 11 | use crate::Peri; | ||
| 11 | use crate::gpio::{AfType, AnyPin, Pull}; | 12 | use crate::gpio::{AfType, AnyPin, Pull}; |
| 12 | use crate::interrupt::typelevel::{Binding, Interrupt}; | 13 | use crate::interrupt::typelevel::{Binding, Interrupt}; |
| 13 | use crate::time::Hertz; | 14 | use crate::time::Hertz; |
| 14 | use crate::timer::TimerChannel; | 15 | use crate::timer::TimerChannel; |
| 15 | use crate::Peri; | ||
| 16 | 16 | ||
| 17 | /// Capture pin wrapper. | 17 | /// Capture pin wrapper. |
| 18 | /// | 18 | /// |
diff --git a/embassy-stm32/src/timer/one_pulse.rs b/embassy-stm32/src/timer/one_pulse.rs index a75b41bd7..fe8681356 100644 --- a/embassy-stm32/src/timer/one_pulse.rs +++ b/embassy-stm32/src/timer/one_pulse.rs | |||
| @@ -11,12 +11,12 @@ use super::low_level::{ | |||
| 11 | }; | 11 | }; |
| 12 | use super::{CaptureCompareInterruptHandler, Channel, ExternalTriggerPin, GeneralInstance4Channel, TimerPin}; | 12 | use super::{CaptureCompareInterruptHandler, Channel, ExternalTriggerPin, GeneralInstance4Channel, TimerPin}; |
| 13 | pub use super::{Ch1, Ch2}; | 13 | pub use super::{Ch1, Ch2}; |
| 14 | use crate::Peri; | ||
| 14 | use crate::gpio::{AfType, AnyPin, Pull}; | 15 | use crate::gpio::{AfType, AnyPin, Pull}; |
| 15 | use crate::interrupt::typelevel::{Binding, Interrupt}; | 16 | use crate::interrupt::typelevel::{Binding, Interrupt}; |
| 16 | use crate::pac::timer::vals::Etp; | 17 | use crate::pac::timer::vals::Etp; |
| 17 | use crate::time::Hertz; | 18 | use crate::time::Hertz; |
| 18 | use crate::timer::TimerChannel; | 19 | use crate::timer::TimerChannel; |
| 19 | use crate::Peri; | ||
| 20 | 20 | ||
| 21 | /// External input marker type. | 21 | /// External input marker type. |
| 22 | pub enum Ext {} | 22 | pub enum Ext {} |
diff --git a/embassy-stm32/src/timer/pwm_input.rs b/embassy-stm32/src/timer/pwm_input.rs index 159b5a177..da8a79b09 100644 --- a/embassy-stm32/src/timer/pwm_input.rs +++ b/embassy-stm32/src/timer/pwm_input.rs | |||
| @@ -2,9 +2,9 @@ | |||
| 2 | 2 | ||
| 3 | use super::low_level::{CountingMode, InputCaptureMode, InputTISelection, SlaveMode, Timer, TriggerSource}; | 3 | use super::low_level::{CountingMode, InputCaptureMode, InputTISelection, SlaveMode, Timer, TriggerSource}; |
| 4 | use super::{Ch1, Ch2, Channel, GeneralInstance4Channel, TimerPin}; | 4 | use super::{Ch1, Ch2, Channel, GeneralInstance4Channel, TimerPin}; |
| 5 | use crate::Peri; | ||
| 5 | use crate::gpio::{AfType, Pull}; | 6 | use crate::gpio::{AfType, Pull}; |
| 6 | use crate::time::Hertz; | 7 | use crate::time::Hertz; |
| 7 | use crate::Peri; | ||
| 8 | 8 | ||
| 9 | /// PWM Input driver. | 9 | /// PWM Input driver. |
| 10 | /// | 10 | /// |
diff --git a/embassy-stm32/src/timer/qei.rs b/embassy-stm32/src/timer/qei.rs index 82b5968b0..a547a2a19 100644 --- a/embassy-stm32/src/timer/qei.rs +++ b/embassy-stm32/src/timer/qei.rs | |||
| @@ -1,45 +1,67 @@ | |||
| 1 | //! Quadrature decoder using a timer. | 1 | //! Quadrature decoder using a timer. |
| 2 | 2 | ||
| 3 | use core::marker::PhantomData; | 3 | use stm32_metapac::timer::vals::{self, Sms}; |
| 4 | |||
| 5 | use stm32_metapac::timer::vals; | ||
| 6 | 4 | ||
| 7 | use super::low_level::Timer; | 5 | use super::low_level::Timer; |
| 8 | pub use super::{Ch1, Ch2}; | 6 | pub use super::{Ch1, Ch2}; |
| 9 | use super::{GeneralInstance4Channel, TimerPin}; | 7 | use super::{GeneralInstance4Channel, TimerPin}; |
| 8 | use crate::Peri; | ||
| 10 | use crate::gpio::{AfType, AnyPin, Pull}; | 9 | use crate::gpio::{AfType, AnyPin, Pull}; |
| 11 | use crate::timer::TimerChannel; | 10 | use crate::timer::TimerChannel; |
| 12 | use crate::Peri; | ||
| 13 | 11 | ||
| 14 | /// Counting direction | 12 | /// Qei driver config. |
| 15 | pub enum Direction { | 13 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 16 | /// Counting up. | 14 | #[derive(Clone, Copy)] |
| 17 | Upcounting, | 15 | pub struct Config { |
| 18 | /// Counting down. | 16 | /// Configures the internal pull up/down resistor for Qei's channel 1 pin. |
| 19 | Downcounting, | 17 | pub ch1_pull: Pull, |
| 18 | /// Configures the internal pull up/down resistor for Qei's channel 2 pin. | ||
| 19 | pub ch2_pull: Pull, | ||
| 20 | /// Specifies the encoder mode to use for the Qei peripheral. | ||
| 21 | pub mode: QeiMode, | ||
| 20 | } | 22 | } |
| 21 | 23 | ||
| 22 | /// Wrapper for using a pin with QEI. | 24 | impl Default for Config { |
| 23 | pub struct QeiPin<'d, T, Channel, #[cfg(afio)] A> { | 25 | /// Arbitrary defaults to preserve backwards compatibility |
| 24 | #[allow(unused)] | 26 | fn default() -> Self { |
| 25 | pin: Peri<'d, AnyPin>, | 27 | Self { |
| 26 | phantom: PhantomData<if_afio!((T, Channel, A))>, | 28 | ch1_pull: Pull::None, |
| 29 | ch2_pull: Pull::None, | ||
| 30 | mode: QeiMode::Mode3, | ||
| 31 | } | ||
| 32 | } | ||
| 27 | } | 33 | } |
| 28 | 34 | ||
| 29 | impl<'d, T: GeneralInstance4Channel, C: QeiChannel, #[cfg(afio)] A> if_afio!(QeiPin<'d, T, C, A>) { | 35 | /// See STMicro AN4013 for §2.3 for more information |
| 30 | /// Create a new QEI pin instance. | 36 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 31 | pub fn new(pin: Peri<'d, if_afio!(impl TimerPin<T, C, A>)>) -> Self { | 37 | #[derive(Clone, Copy)] |
| 32 | critical_section::with(|_| { | 38 | pub enum QeiMode { |
| 33 | pin.set_low(); | 39 | /// Direct alias for [`Sms::ENCODER_MODE_1`] |
| 34 | set_as_af!(pin, AfType::input(Pull::None)); | 40 | Mode1, |
| 35 | }); | 41 | /// Direct alias for [`Sms::ENCODER_MODE_2`] |
| 36 | QeiPin { | 42 | Mode2, |
| 37 | pin: pin.into(), | 43 | /// Direct alias for [`Sms::ENCODER_MODE_3`] |
| 38 | phantom: PhantomData, | 44 | Mode3, |
| 45 | } | ||
| 46 | |||
| 47 | impl From<QeiMode> for Sms { | ||
| 48 | fn from(mode: QeiMode) -> Self { | ||
| 49 | match mode { | ||
| 50 | QeiMode::Mode1 => Sms::ENCODER_MODE_1, | ||
| 51 | QeiMode::Mode2 => Sms::ENCODER_MODE_2, | ||
| 52 | QeiMode::Mode3 => Sms::ENCODER_MODE_3, | ||
| 39 | } | 53 | } |
| 40 | } | 54 | } |
| 41 | } | 55 | } |
| 42 | 56 | ||
| 57 | /// Counting direction | ||
| 58 | pub enum Direction { | ||
| 59 | /// Counting up. | ||
| 60 | Upcounting, | ||
| 61 | /// Counting down. | ||
| 62 | Downcounting, | ||
| 63 | } | ||
| 64 | |||
| 43 | trait SealedQeiChannel: TimerChannel {} | 65 | trait SealedQeiChannel: TimerChannel {} |
| 44 | 66 | ||
| 45 | /// Marker trait for a timer channel eligible for use with QEI. | 67 | /// Marker trait for a timer channel eligible for use with QEI. |
| @@ -55,20 +77,28 @@ impl SealedQeiChannel for Ch2 {} | |||
| 55 | /// Quadrature decoder driver. | 77 | /// Quadrature decoder driver. |
| 56 | pub struct Qei<'d, T: GeneralInstance4Channel> { | 78 | pub struct Qei<'d, T: GeneralInstance4Channel> { |
| 57 | inner: Timer<'d, T>, | 79 | inner: Timer<'d, T>, |
| 80 | _ch1: Peri<'d, AnyPin>, | ||
| 81 | _ch2: Peri<'d, AnyPin>, | ||
| 58 | } | 82 | } |
| 59 | 83 | ||
| 60 | impl<'d, T: GeneralInstance4Channel> Qei<'d, T> { | 84 | impl<'d, T: GeneralInstance4Channel> Qei<'d, T> { |
| 61 | /// Create a new quadrature decoder driver. | 85 | /// Create a new quadrature decoder driver, with a given [`Config`]. |
| 62 | #[allow(unused)] | 86 | #[allow(unused)] |
| 63 | pub fn new<#[cfg(afio)] A>( | 87 | pub fn new<CH1: QeiChannel, CH2: QeiChannel, #[cfg(afio)] A>( |
| 64 | tim: Peri<'d, T>, | 88 | tim: Peri<'d, T>, |
| 65 | ch1: if_afio!(QeiPin<'d, T, Ch1, A>), | 89 | ch1: Peri<'d, if_afio!(impl TimerPin<T, CH1, A>)>, |
| 66 | ch2: if_afio!(QeiPin<'d, T, Ch2, A>), | 90 | ch2: Peri<'d, if_afio!(impl TimerPin<T, CH2, A>)>, |
| 91 | config: Config, | ||
| 67 | ) -> Self { | 92 | ) -> Self { |
| 68 | Self::new_inner(tim) | 93 | // Configure the pins to be used for the QEI peripheral. |
| 69 | } | 94 | critical_section::with(|_| { |
| 95 | ch1.set_low(); | ||
| 96 | set_as_af!(ch1, AfType::input(config.ch1_pull)); | ||
| 97 | |||
| 98 | ch2.set_low(); | ||
| 99 | set_as_af!(ch2, AfType::input(config.ch2_pull)); | ||
| 100 | }); | ||
| 70 | 101 | ||
| 71 | fn new_inner(tim: Peri<'d, T>) -> Self { | ||
| 72 | let inner = Timer::new(tim); | 102 | let inner = Timer::new(tim); |
| 73 | let r = inner.regs_gp16(); | 103 | let r = inner.regs_gp16(); |
| 74 | 104 | ||
| @@ -88,13 +118,17 @@ impl<'d, T: GeneralInstance4Channel> Qei<'d, T> { | |||
| 88 | }); | 118 | }); |
| 89 | 119 | ||
| 90 | r.smcr().modify(|w| { | 120 | r.smcr().modify(|w| { |
| 91 | w.set_sms(vals::Sms::ENCODER_MODE_3); | 121 | w.set_sms(config.mode.into()); |
| 92 | }); | 122 | }); |
| 93 | 123 | ||
| 94 | r.arr().modify(|w| w.set_arr(u16::MAX)); | 124 | r.arr().modify(|w| w.set_arr(u16::MAX)); |
| 95 | r.cr1().modify(|w| w.set_cen(true)); | 125 | r.cr1().modify(|w| w.set_cen(true)); |
| 96 | 126 | ||
| 97 | Self { inner } | 127 | Self { |
| 128 | inner, | ||
| 129 | _ch1: ch1.into(), | ||
| 130 | _ch2: ch2.into(), | ||
| 131 | } | ||
| 98 | } | 132 | } |
| 99 | 133 | ||
| 100 | /// Get direction. | 134 | /// Get direction. |
diff --git a/embassy-stm32/src/timer/simple_pwm.rs b/embassy-stm32/src/timer/simple_pwm.rs index e60bb5b06..36303aeb4 100644 --- a/embassy-stm32/src/timer/simple_pwm.rs +++ b/embassy-stm32/src/timer/simple_pwm.rs | |||
| @@ -5,11 +5,11 @@ use core::mem::ManuallyDrop; | |||
| 5 | 5 | ||
| 6 | use super::low_level::{CountingMode, OutputCompareMode, OutputPolarity, Timer}; | 6 | use super::low_level::{CountingMode, OutputCompareMode, OutputPolarity, Timer}; |
| 7 | use super::{Ch1, Ch2, Ch3, Ch4, Channel, GeneralInstance4Channel, TimerBits, TimerChannel, TimerPin}; | 7 | use super::{Ch1, Ch2, Ch3, Ch4, Channel, GeneralInstance4Channel, TimerBits, TimerChannel, TimerPin}; |
| 8 | use crate::Peri; | ||
| 8 | #[cfg(gpio_v2)] | 9 | #[cfg(gpio_v2)] |
| 9 | use crate::gpio::Pull; | 10 | use crate::gpio::Pull; |
| 10 | use crate::gpio::{AfType, AnyPin, OutputType, Speed}; | 11 | use crate::gpio::{AfType, AnyPin, OutputType, Speed}; |
| 11 | use crate::time::Hertz; | 12 | use crate::time::Hertz; |
| 12 | use crate::Peri; | ||
| 13 | 13 | ||
| 14 | /// PWM pin wrapper. | 14 | /// PWM pin wrapper. |
| 15 | /// | 15 | /// |
diff --git a/embassy-stm32/src/tsc/acquisition_banks.rs b/embassy-stm32/src/tsc/acquisition_banks.rs index 7d6442b48..097cf7942 100644 --- a/embassy-stm32/src/tsc/acquisition_banks.rs +++ b/embassy-stm32/src/tsc/acquisition_banks.rs | |||
| @@ -1,11 +1,11 @@ | |||
| 1 | use super::TSC_NUM_GROUPS; | ||
| 1 | use super::io_pin::*; | 2 | use super::io_pin::*; |
| 2 | #[cfg(any(tsc_v2, tsc_v3))] | 3 | #[cfg(any(tsc_v2, tsc_v3))] |
| 3 | use super::pin_groups::G7; | 4 | use super::pin_groups::G7; |
| 4 | #[cfg(tsc_v3)] | 5 | #[cfg(tsc_v3)] |
| 5 | use super::pin_groups::G8; | 6 | use super::pin_groups::G8; |
| 6 | use super::pin_groups::{pin_roles, G1, G2, G3, G4, G5, G6}; | 7 | use super::pin_groups::{G1, G2, G3, G4, G5, G6, pin_roles}; |
| 7 | use super::types::{Group, GroupStatus}; | 8 | use super::types::{Group, GroupStatus}; |
| 8 | use super::TSC_NUM_GROUPS; | ||
| 9 | 9 | ||
| 10 | /// Represents a collection of TSC (Touch Sensing Controller) pins for an acquisition bank. | 10 | /// Represents a collection of TSC (Touch Sensing Controller) pins for an acquisition bank. |
| 11 | /// | 11 | /// |
diff --git a/embassy-stm32/src/tsc/pin_groups.rs b/embassy-stm32/src/tsc/pin_groups.rs index 84421f7ff..9347e6bc0 100644 --- a/embassy-stm32/src/tsc/pin_groups.rs +++ b/embassy-stm32/src/tsc/pin_groups.rs | |||
| @@ -1,11 +1,11 @@ | |||
| 1 | use core::marker::PhantomData; | 1 | use core::marker::PhantomData; |
| 2 | use core::ops::BitOr; | 2 | use core::ops::BitOr; |
| 3 | 3 | ||
| 4 | use super::Instance; | ||
| 4 | use super::errors::GroupError; | 5 | use super::errors::GroupError; |
| 5 | use super::io_pin::*; | 6 | use super::io_pin::*; |
| 6 | use super::Instance; | ||
| 7 | use crate::gpio::{AfType, AnyPin, OutputType, Speed}; | ||
| 8 | use crate::Peri; | 7 | use crate::Peri; |
| 8 | use crate::gpio::{AfType, AnyPin, OutputType, Speed}; | ||
| 9 | 9 | ||
| 10 | /// Pin type definition to control IO parameters | 10 | /// Pin type definition to control IO parameters |
| 11 | #[derive(PartialEq, Clone, Copy)] | 11 | #[derive(PartialEq, Clone, Copy)] |
diff --git a/embassy-stm32/src/ucpd.rs b/embassy-stm32/src/ucpd.rs index 18aff4fbd..8f259a917 100644 --- a/embassy-stm32/src/ucpd.rs +++ b/embassy-stm32/src/ucpd.rs | |||
| @@ -19,8 +19,8 @@ use core::marker::PhantomData; | |||
| 19 | use core::sync::atomic::{AtomicBool, Ordering}; | 19 | use core::sync::atomic::{AtomicBool, Ordering}; |
| 20 | use core::task::Poll; | 20 | use core::task::Poll; |
| 21 | 21 | ||
| 22 | use embassy_hal_internal::drop::OnDrop; | ||
| 23 | use embassy_hal_internal::PeripheralType; | 22 | use embassy_hal_internal::PeripheralType; |
| 23 | use embassy_hal_internal::drop::OnDrop; | ||
| 24 | use embassy_sync::waitqueue::AtomicWaker; | 24 | use embassy_sync::waitqueue::AtomicWaker; |
| 25 | 25 | ||
| 26 | use crate::dma::{ChannelAndRequest, TransferOptions}; | 26 | use crate::dma::{ChannelAndRequest, TransferOptions}; |
| @@ -28,7 +28,7 @@ use crate::interrupt::typelevel::Interrupt; | |||
| 28 | use crate::pac::ucpd::vals::{Anamode, Ccenable, PscUsbpdclk, Txmode}; | 28 | use crate::pac::ucpd::vals::{Anamode, Ccenable, PscUsbpdclk, Txmode}; |
| 29 | pub use crate::pac::ucpd::vals::{Phyccsel as CcSel, Rxordset, TypecVstateCc as CcVState}; | 29 | pub use crate::pac::ucpd::vals::{Phyccsel as CcSel, Rxordset, TypecVstateCc as CcVState}; |
| 30 | use crate::rcc::{self, RccPeripheral}; | 30 | use crate::rcc::{self, RccPeripheral}; |
| 31 | use crate::{interrupt, Peri}; | 31 | use crate::{Peri, interrupt}; |
| 32 | 32 | ||
| 33 | pub(crate) fn init( | 33 | pub(crate) fn init( |
| 34 | _cs: critical_section::CriticalSection, | 34 | _cs: critical_section::CriticalSection, |
diff --git a/embassy-stm32/src/usart/buffered.rs b/embassy-stm32/src/usart/buffered.rs index c734eed49..69c3a740f 100644 --- a/embassy-stm32/src/usart/buffered.rs +++ b/embassy-stm32/src/usart/buffered.rs | |||
| @@ -1,20 +1,20 @@ | |||
| 1 | use core::future::poll_fn; | 1 | use core::future::poll_fn; |
| 2 | use core::marker::PhantomData; | 2 | use core::marker::PhantomData; |
| 3 | use core::slice; | 3 | use core::slice; |
| 4 | use core::sync::atomic::{AtomicBool, AtomicU8, Ordering}; | 4 | use core::sync::atomic::{AtomicBool, AtomicU8, AtomicUsize, Ordering}; |
| 5 | use core::task::Poll; | 5 | use core::task::Poll; |
| 6 | 6 | ||
| 7 | use embassy_embedded_hal::SetConfig; | 7 | use embassy_embedded_hal::SetConfig; |
| 8 | use embassy_hal_internal::atomic_ring_buffer::RingBuffer; | ||
| 9 | use embassy_hal_internal::Peri; | 8 | use embassy_hal_internal::Peri; |
| 9 | use embassy_hal_internal::atomic_ring_buffer::RingBuffer; | ||
| 10 | use embassy_sync::waitqueue::AtomicWaker; | 10 | use embassy_sync::waitqueue::AtomicWaker; |
| 11 | 11 | ||
| 12 | #[cfg(not(any(usart_v1, usart_v2)))] | 12 | #[cfg(not(any(usart_v1, usart_v2)))] |
| 13 | use super::DePin; | 13 | use super::DePin; |
| 14 | use super::{ | 14 | use super::{ |
| 15 | Config, ConfigError, CtsPin, Duplex, Error, HalfDuplexReadback, Info, Instance, Regs, RtsPin, RxPin, TxPin, | ||
| 15 | clear_interrupt_flags, configure, half_duplex_set_rx_tx_before_write, rdr, reconfigure, send_break, set_baudrate, | 16 | clear_interrupt_flags, configure, half_duplex_set_rx_tx_before_write, rdr, reconfigure, send_break, set_baudrate, |
| 16 | sr, tdr, Config, ConfigError, CtsPin, Duplex, Error, HalfDuplexReadback, Info, Instance, Regs, RtsPin, RxPin, | 17 | sr, tdr, |
| 17 | TxPin, | ||
| 18 | }; | 18 | }; |
| 19 | use crate::gpio::{AfType, AnyPin, Pull, SealedPin as _}; | 19 | use crate::gpio::{AfType, AnyPin, Pull, SealedPin as _}; |
| 20 | use crate::interrupt::{self, InterruptExt}; | 20 | use crate::interrupt::{self, InterruptExt}; |
| @@ -68,8 +68,15 @@ unsafe fn on_interrupt(r: Regs, state: &'static State) { | |||
| 68 | // FIXME: Should we disable any further RX interrupts when the buffer becomes full. | 68 | // FIXME: Should we disable any further RX interrupts when the buffer becomes full. |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | if !state.rx_buf.is_empty() { | 71 | let eager = state.eager_reads.load(Ordering::Relaxed); |
| 72 | state.rx_waker.wake(); | 72 | if eager > 0 { |
| 73 | if state.rx_buf.available() >= eager { | ||
| 74 | state.rx_waker.wake(); | ||
| 75 | } | ||
| 76 | } else { | ||
| 77 | if state.rx_buf.is_half_full() { | ||
| 78 | state.rx_waker.wake(); | ||
| 79 | } | ||
| 73 | } | 80 | } |
| 74 | } | 81 | } |
| 75 | 82 | ||
| @@ -132,6 +139,7 @@ pub(super) struct State { | |||
| 132 | tx_done: AtomicBool, | 139 | tx_done: AtomicBool, |
| 133 | tx_rx_refcount: AtomicU8, | 140 | tx_rx_refcount: AtomicU8, |
| 134 | half_duplex_readback: AtomicBool, | 141 | half_duplex_readback: AtomicBool, |
| 142 | eager_reads: AtomicUsize, | ||
| 135 | } | 143 | } |
| 136 | 144 | ||
| 137 | impl State { | 145 | impl State { |
| @@ -144,6 +152,7 @@ impl State { | |||
| 144 | tx_done: AtomicBool::new(true), | 152 | tx_done: AtomicBool::new(true), |
| 145 | tx_rx_refcount: AtomicU8::new(0), | 153 | tx_rx_refcount: AtomicU8::new(0), |
| 146 | half_duplex_readback: AtomicBool::new(false), | 154 | half_duplex_readback: AtomicBool::new(false), |
| 155 | eager_reads: AtomicUsize::new(0), | ||
| 147 | } | 156 | } |
| 148 | } | 157 | } |
| 149 | } | 158 | } |
| @@ -419,6 +428,9 @@ impl<'d> BufferedUart<'d> { | |||
| 419 | let state = T::buffered_state(); | 428 | let state = T::buffered_state(); |
| 420 | let kernel_clock = T::frequency(); | 429 | let kernel_clock = T::frequency(); |
| 421 | 430 | ||
| 431 | state | ||
| 432 | .eager_reads | ||
| 433 | .store(config.eager_reads.unwrap_or(0), Ordering::Relaxed); | ||
| 422 | state.half_duplex_readback.store( | 434 | state.half_duplex_readback.store( |
| 423 | config.duplex == Duplex::Half(HalfDuplexReadback::Readback), | 435 | config.duplex == Duplex::Half(HalfDuplexReadback::Readback), |
| 424 | Ordering::Relaxed, | 436 | Ordering::Relaxed, |
| @@ -456,6 +468,9 @@ impl<'d> BufferedUart<'d> { | |||
| 456 | let info = self.rx.info; | 468 | let info = self.rx.info; |
| 457 | let state = self.rx.state; | 469 | let state = self.rx.state; |
| 458 | state.tx_rx_refcount.store(2, Ordering::Relaxed); | 470 | state.tx_rx_refcount.store(2, Ordering::Relaxed); |
| 471 | state | ||
| 472 | .eager_reads | ||
| 473 | .store(config.eager_reads.unwrap_or(0), Ordering::Relaxed); | ||
| 459 | 474 | ||
| 460 | info.rcc.enable_and_reset(); | 475 | info.rcc.enable_and_reset(); |
| 461 | 476 | ||
| @@ -527,6 +542,11 @@ impl<'d> BufferedUart<'d> { | |||
| 527 | pub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError> { | 542 | pub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError> { |
| 528 | reconfigure(self.rx.info, self.rx.kernel_clock, config)?; | 543 | reconfigure(self.rx.info, self.rx.kernel_clock, config)?; |
| 529 | 544 | ||
| 545 | self.rx | ||
| 546 | .state | ||
| 547 | .eager_reads | ||
| 548 | .store(config.eager_reads.unwrap_or(0), Ordering::Relaxed); | ||
| 549 | |||
| 530 | self.rx.info.regs.cr1().modify(|w| { | 550 | self.rx.info.regs.cr1().modify(|w| { |
| 531 | w.set_rxneie(true); | 551 | w.set_rxneie(true); |
| 532 | w.set_idleie(true); | 552 | w.set_idleie(true); |
| @@ -553,24 +573,30 @@ impl<'d> BufferedUartRx<'d> { | |||
| 553 | poll_fn(move |cx| { | 573 | poll_fn(move |cx| { |
| 554 | let state = self.state; | 574 | let state = self.state; |
| 555 | let mut rx_reader = unsafe { state.rx_buf.reader() }; | 575 | let mut rx_reader = unsafe { state.rx_buf.reader() }; |
| 556 | let data = rx_reader.pop_slice(); | 576 | let mut buf_len = 0; |
| 577 | let mut data = rx_reader.pop_slice(); | ||
| 557 | 578 | ||
| 558 | if !data.is_empty() { | 579 | while !data.is_empty() && buf_len < buf.len() { |
| 559 | let len = data.len().min(buf.len()); | 580 | let data_len = data.len().min(buf.len() - buf_len); |
| 560 | buf[..len].copy_from_slice(&data[..len]); | 581 | buf[buf_len..buf_len + data_len].copy_from_slice(&data[..data_len]); |
| 582 | buf_len += data_len; | ||
| 561 | 583 | ||
| 562 | let do_pend = state.rx_buf.is_full(); | 584 | let do_pend = state.rx_buf.is_full(); |
| 563 | rx_reader.pop_done(len); | 585 | rx_reader.pop_done(data_len); |
| 564 | 586 | ||
| 565 | if do_pend { | 587 | if do_pend { |
| 566 | self.info.interrupt.pend(); | 588 | self.info.interrupt.pend(); |
| 567 | } | 589 | } |
| 568 | 590 | ||
| 569 | return Poll::Ready(Ok(len)); | 591 | data = rx_reader.pop_slice(); |
| 570 | } | 592 | } |
| 571 | 593 | ||
| 572 | state.rx_waker.register(cx.waker()); | 594 | if buf_len != 0 { |
| 573 | Poll::Pending | 595 | Poll::Ready(Ok(buf_len)) |
| 596 | } else { | ||
| 597 | state.rx_waker.register(cx.waker()); | ||
| 598 | Poll::Pending | ||
| 599 | } | ||
| 574 | }) | 600 | }) |
| 575 | .await | 601 | .await |
| 576 | } | 602 | } |
| @@ -579,21 +605,24 @@ impl<'d> BufferedUartRx<'d> { | |||
| 579 | loop { | 605 | loop { |
| 580 | let state = self.state; | 606 | let state = self.state; |
| 581 | let mut rx_reader = unsafe { state.rx_buf.reader() }; | 607 | let mut rx_reader = unsafe { state.rx_buf.reader() }; |
| 582 | let data = rx_reader.pop_slice(); | 608 | let mut buf_len = 0; |
| 609 | let mut data = rx_reader.pop_slice(); | ||
| 583 | 610 | ||
| 584 | if !data.is_empty() { | 611 | while !data.is_empty() && buf_len < buf.len() { |
| 585 | let len = data.len().min(buf.len()); | 612 | let data_len = data.len().min(buf.len() - buf_len); |
| 586 | buf[..len].copy_from_slice(&data[..len]); | 613 | buf[buf_len..buf_len + data_len].copy_from_slice(&data[..data_len]); |
| 614 | buf_len += data_len; | ||
| 587 | 615 | ||
| 588 | let do_pend = state.rx_buf.is_full(); | 616 | let do_pend = state.rx_buf.is_full(); |
| 589 | rx_reader.pop_done(len); | 617 | rx_reader.pop_done(data_len); |
| 590 | 618 | ||
| 591 | if do_pend { | 619 | if do_pend { |
| 592 | self.info.interrupt.pend(); | 620 | self.info.interrupt.pend(); |
| 593 | } | 621 | } |
| 594 | 622 | ||
| 595 | return Ok(len); | 623 | data = rx_reader.pop_slice(); |
| 596 | } | 624 | } |
| 625 | return Ok(buf_len); | ||
| 597 | } | 626 | } |
| 598 | } | 627 | } |
| 599 | 628 | ||
| @@ -633,6 +662,10 @@ impl<'d> BufferedUartRx<'d> { | |||
| 633 | pub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError> { | 662 | pub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError> { |
| 634 | reconfigure(self.info, self.kernel_clock, config)?; | 663 | reconfigure(self.info, self.kernel_clock, config)?; |
| 635 | 664 | ||
| 665 | self.state | ||
| 666 | .eager_reads | ||
| 667 | .store(config.eager_reads.unwrap_or(0), Ordering::Relaxed); | ||
| 668 | |||
| 636 | self.info.regs.cr1().modify(|w| { | 669 | self.info.regs.cr1().modify(|w| { |
| 637 | w.set_rxneie(true); | 670 | w.set_rxneie(true); |
| 638 | w.set_idleie(true); | 671 | w.set_idleie(true); |
diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index ff211e0c9..0e7da634d 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs | |||
| @@ -4,15 +4,16 @@ | |||
| 4 | 4 | ||
| 5 | use core::future::poll_fn; | 5 | use core::future::poll_fn; |
| 6 | use core::marker::PhantomData; | 6 | use core::marker::PhantomData; |
| 7 | use core::sync::atomic::{compiler_fence, AtomicU8, Ordering}; | 7 | use core::sync::atomic::{AtomicU8, AtomicUsize, Ordering, compiler_fence}; |
| 8 | use core::task::Poll; | 8 | use core::task::Poll; |
| 9 | 9 | ||
| 10 | use embassy_embedded_hal::SetConfig; | 10 | use embassy_embedded_hal::SetConfig; |
| 11 | use embassy_hal_internal::drop::OnDrop; | ||
| 12 | use embassy_hal_internal::PeripheralType; | 11 | use embassy_hal_internal::PeripheralType; |
| 12 | use embassy_hal_internal::drop::OnDrop; | ||
| 13 | use embassy_sync::waitqueue::AtomicWaker; | 13 | use embassy_sync::waitqueue::AtomicWaker; |
| 14 | use futures_util::future::{select, Either}; | 14 | use futures_util::future::{Either, select}; |
| 15 | 15 | ||
| 16 | use crate::Peri; | ||
| 16 | use crate::dma::ChannelAndRequest; | 17 | use crate::dma::ChannelAndRequest; |
| 17 | use crate::gpio::{AfType, AnyPin, OutputType, Pull, SealedPin as _, Speed}; | 18 | use crate::gpio::{AfType, AnyPin, OutputType, Pull, SealedPin as _, Speed}; |
| 18 | use crate::interrupt::typelevel::Interrupt as _; | 19 | use crate::interrupt::typelevel::Interrupt as _; |
| @@ -25,7 +26,6 @@ use crate::pac::usart::Usart as Regs; | |||
| 25 | use crate::pac::usart::{regs, vals}; | 26 | use crate::pac::usart::{regs, vals}; |
| 26 | use crate::rcc::{RccInfo, SealedRccPeripheral}; | 27 | use crate::rcc::{RccInfo, SealedRccPeripheral}; |
| 27 | use crate::time::Hertz; | 28 | use crate::time::Hertz; |
| 28 | use crate::Peri; | ||
| 29 | 29 | ||
| 30 | /// Interrupt handler. | 30 | /// Interrupt handler. |
| 31 | pub struct InterruptHandler<T: Instance> { | 31 | pub struct InterruptHandler<T: Instance> { |
| @@ -185,6 +185,12 @@ pub enum ConfigError { | |||
| 185 | RxOrTxNotEnabled, | 185 | RxOrTxNotEnabled, |
| 186 | /// Data bits and parity combination not supported | 186 | /// Data bits and parity combination not supported |
| 187 | DataParityNotSupported, | 187 | DataParityNotSupported, |
| 188 | /// DE assertion time too high | ||
| 189 | #[cfg(not(any(usart_v1, usart_v2)))] | ||
| 190 | DeAssertionTimeTooHigh, | ||
| 191 | /// DE deassertion time too high | ||
| 192 | #[cfg(not(any(usart_v1, usart_v2)))] | ||
| 193 | DeDeassertionTimeTooHigh, | ||
| 188 | } | 194 | } |
| 189 | 195 | ||
| 190 | #[non_exhaustive] | 196 | #[non_exhaustive] |
| @@ -206,6 +212,21 @@ pub struct Config { | |||
| 206 | /// If false: the error is ignored and cleared | 212 | /// If false: the error is ignored and cleared |
| 207 | pub detect_previous_overrun: bool, | 213 | pub detect_previous_overrun: bool, |
| 208 | 214 | ||
| 215 | /// If `None` (the default) then read-like calls on `BufferedUartRx` and `RingBufferedUartRx` | ||
| 216 | /// typically only wake/return after line idle or after the buffer is at least half full | ||
| 217 | /// (for `BufferedUartRx`) or the DMA buffer is written at the half or full positions | ||
| 218 | /// (for `RingBufferedUartRx`), though it may also wake/return earlier in some circumstances. | ||
| 219 | /// | ||
| 220 | /// If `Some(n)` then such reads are also woken/return as soon as at least `n` words are | ||
| 221 | /// available in the buffer, in addition to waking/returning when the conditions described | ||
| 222 | /// above are met. `Some(0)` is treated as `None`. Setting this for `RingBufferedUartRx` | ||
| 223 | /// will trigger an interrupt for every received word to check the buffer level, which may | ||
| 224 | /// impact performance at high data rates. | ||
| 225 | /// | ||
| 226 | /// Has no effect on plain `Uart` or `UartRx` reads, which are specified to either | ||
| 227 | /// return a single word, a full buffer, or after line idle. | ||
| 228 | pub eager_reads: Option<usize>, | ||
| 229 | |||
| 209 | /// Set this to true if the line is considered noise free. | 230 | /// Set this to true if the line is considered noise free. |
| 210 | /// This will increase the receiver’s tolerance to clock deviations, | 231 | /// This will increase the receiver’s tolerance to clock deviations, |
| 211 | /// but will effectively disable noise detection. | 232 | /// but will effectively disable noise detection. |
| @@ -239,6 +260,14 @@ pub struct Config { | |||
| 239 | /// Set the pin configuration for the DE pin. | 260 | /// Set the pin configuration for the DE pin. |
| 240 | pub de_config: OutputConfig, | 261 | pub de_config: OutputConfig, |
| 241 | 262 | ||
| 263 | /// Set DE assertion time before the first start bit, 0-31 16ths of a bit period. | ||
| 264 | #[cfg(not(any(usart_v1, usart_v2)))] | ||
| 265 | pub de_assertion_time: u8, | ||
| 266 | |||
| 267 | /// Set DE deassertion time after the last stop bit, 0-31 16ths of a bit period. | ||
| 268 | #[cfg(not(any(usart_v1, usart_v2)))] | ||
| 269 | pub de_deassertion_time: u8, | ||
| 270 | |||
| 242 | // private: set by new_half_duplex, not by the user. | 271 | // private: set by new_half_duplex, not by the user. |
| 243 | duplex: Duplex, | 272 | duplex: Duplex, |
| 244 | } | 273 | } |
| @@ -270,6 +299,7 @@ impl Default for Config { | |||
| 270 | parity: Parity::ParityNone, | 299 | parity: Parity::ParityNone, |
| 271 | // historical behavior | 300 | // historical behavior |
| 272 | detect_previous_overrun: false, | 301 | detect_previous_overrun: false, |
| 302 | eager_reads: None, | ||
| 273 | #[cfg(not(usart_v1))] | 303 | #[cfg(not(usart_v1))] |
| 274 | assume_noise_free: false, | 304 | assume_noise_free: false, |
| 275 | #[cfg(any(usart_v3, usart_v4))] | 305 | #[cfg(any(usart_v3, usart_v4))] |
| @@ -283,6 +313,10 @@ impl Default for Config { | |||
| 283 | tx_config: OutputConfig::PushPull, | 313 | tx_config: OutputConfig::PushPull, |
| 284 | rts_config: OutputConfig::PushPull, | 314 | rts_config: OutputConfig::PushPull, |
| 285 | de_config: OutputConfig::PushPull, | 315 | de_config: OutputConfig::PushPull, |
| 316 | #[cfg(not(any(usart_v1, usart_v2)))] | ||
| 317 | de_assertion_time: 0, | ||
| 318 | #[cfg(not(any(usart_v1, usart_v2)))] | ||
| 319 | de_deassertion_time: 0, | ||
| 286 | duplex: Duplex::Full, | 320 | duplex: Duplex::Full, |
| 287 | } | 321 | } |
| 288 | } | 322 | } |
| @@ -966,6 +1000,9 @@ impl<'d, M: Mode> UartRx<'d, M> { | |||
| 966 | let info = self.info; | 1000 | let info = self.info; |
| 967 | let state = self.state; | 1001 | let state = self.state; |
| 968 | state.tx_rx_refcount.store(1, Ordering::Relaxed); | 1002 | state.tx_rx_refcount.store(1, Ordering::Relaxed); |
| 1003 | state | ||
| 1004 | .eager_reads | ||
| 1005 | .store(config.eager_reads.unwrap_or(0), Ordering::Relaxed); | ||
| 969 | 1006 | ||
| 970 | info.rcc.enable_and_reset(); | 1007 | info.rcc.enable_and_reset(); |
| 971 | 1008 | ||
| @@ -982,6 +1019,9 @@ impl<'d, M: Mode> UartRx<'d, M> { | |||
| 982 | 1019 | ||
| 983 | /// Reconfigure the driver | 1020 | /// Reconfigure the driver |
| 984 | pub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError> { | 1021 | pub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError> { |
| 1022 | self.state | ||
| 1023 | .eager_reads | ||
| 1024 | .store(config.eager_reads.unwrap_or(0), Ordering::Relaxed); | ||
| 985 | reconfigure(self.info, self.kernel_clock, config) | 1025 | reconfigure(self.info, self.kernel_clock, config) |
| 986 | } | 1026 | } |
| 987 | 1027 | ||
| @@ -1462,6 +1502,9 @@ impl<'d, M: Mode> Uart<'d, M> { | |||
| 1462 | let info = self.rx.info; | 1502 | let info = self.rx.info; |
| 1463 | let state = self.rx.state; | 1503 | let state = self.rx.state; |
| 1464 | state.tx_rx_refcount.store(2, Ordering::Relaxed); | 1504 | state.tx_rx_refcount.store(2, Ordering::Relaxed); |
| 1505 | state | ||
| 1506 | .eager_reads | ||
| 1507 | .store(config.eager_reads.unwrap_or(0), Ordering::Relaxed); | ||
| 1465 | 1508 | ||
| 1466 | info.rcc.enable_and_reset(); | 1509 | info.rcc.enable_and_reset(); |
| 1467 | 1510 | ||
| @@ -1690,6 +1733,16 @@ fn configure( | |||
| 1690 | return Err(ConfigError::RxOrTxNotEnabled); | 1733 | return Err(ConfigError::RxOrTxNotEnabled); |
| 1691 | } | 1734 | } |
| 1692 | 1735 | ||
| 1736 | #[cfg(not(any(usart_v1, usart_v2)))] | ||
| 1737 | let dem = r.cr3().read().dem(); | ||
| 1738 | |||
| 1739 | #[cfg(not(any(usart_v1, usart_v2)))] | ||
| 1740 | if config.de_assertion_time > 31 { | ||
| 1741 | return Err(ConfigError::DeAssertionTimeTooHigh); | ||
| 1742 | } else if config.de_deassertion_time > 31 { | ||
| 1743 | return Err(ConfigError::DeDeassertionTimeTooHigh); | ||
| 1744 | } | ||
| 1745 | |||
| 1693 | // UART must be disabled during configuration. | 1746 | // UART must be disabled during configuration. |
| 1694 | r.cr1().modify(|w| { | 1747 | r.cr1().modify(|w| { |
| 1695 | w.set_ue(false); | 1748 | w.set_ue(false); |
| @@ -1738,6 +1791,20 @@ fn configure( | |||
| 1738 | w.set_re(enable_rx); | 1791 | w.set_re(enable_rx); |
| 1739 | } | 1792 | } |
| 1740 | 1793 | ||
| 1794 | #[cfg(not(any(usart_v1, usart_v2)))] | ||
| 1795 | if dem { | ||
| 1796 | w.set_deat(if over8 { | ||
| 1797 | config.de_assertion_time / 2 | ||
| 1798 | } else { | ||
| 1799 | config.de_assertion_time | ||
| 1800 | }); | ||
| 1801 | w.set_dedt(if over8 { | ||
| 1802 | config.de_assertion_time / 2 | ||
| 1803 | } else { | ||
| 1804 | config.de_assertion_time | ||
| 1805 | }); | ||
| 1806 | } | ||
| 1807 | |||
| 1741 | // configure word size and parity, since the parity bit is inserted into the MSB position, | 1808 | // configure word size and parity, since the parity bit is inserted into the MSB position, |
| 1742 | // it increases the effective word size | 1809 | // it increases the effective word size |
| 1743 | match (config.parity, config.data_bits) { | 1810 | match (config.parity, config.data_bits) { |
| @@ -2022,6 +2089,7 @@ struct State { | |||
| 2022 | rx_waker: AtomicWaker, | 2089 | rx_waker: AtomicWaker, |
| 2023 | tx_waker: AtomicWaker, | 2090 | tx_waker: AtomicWaker, |
| 2024 | tx_rx_refcount: AtomicU8, | 2091 | tx_rx_refcount: AtomicU8, |
| 2092 | eager_reads: AtomicUsize, | ||
| 2025 | } | 2093 | } |
| 2026 | 2094 | ||
| 2027 | impl State { | 2095 | impl State { |
| @@ -2030,6 +2098,7 @@ impl State { | |||
| 2030 | rx_waker: AtomicWaker::new(), | 2098 | rx_waker: AtomicWaker::new(), |
| 2031 | tx_waker: AtomicWaker::new(), | 2099 | tx_waker: AtomicWaker::new(), |
| 2032 | tx_rx_refcount: AtomicU8::new(0), | 2100 | tx_rx_refcount: AtomicU8::new(0), |
| 2101 | eager_reads: AtomicUsize::new(0), | ||
| 2033 | } | 2102 | } |
| 2034 | } | 2103 | } |
| 2035 | } | 2104 | } |
diff --git a/embassy-stm32/src/usart/ringbuffered.rs b/embassy-stm32/src/usart/ringbuffered.rs index 5f4e87834..20bfefd9e 100644 --- a/embassy-stm32/src/usart/ringbuffered.rs +++ b/embassy-stm32/src/usart/ringbuffered.rs | |||
| @@ -1,19 +1,19 @@ | |||
| 1 | use core::future::poll_fn; | 1 | use core::future::poll_fn; |
| 2 | use core::mem; | 2 | use core::mem; |
| 3 | use core::sync::atomic::{compiler_fence, Ordering}; | 3 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 4 | use core::task::Poll; | 4 | use core::task::Poll; |
| 5 | 5 | ||
| 6 | use embassy_embedded_hal::SetConfig; | 6 | use embassy_embedded_hal::SetConfig; |
| 7 | use embedded_io_async::ReadReady; | 7 | use embedded_io_async::ReadReady; |
| 8 | use futures_util::future::{select, Either}; | 8 | use futures_util::future::{Either, select}; |
| 9 | 9 | ||
| 10 | use super::{rdr, reconfigure, set_baudrate, sr, Config, ConfigError, Error, Info, State, UartRx}; | 10 | use super::{Config, ConfigError, Error, Info, State, UartRx, rdr, reconfigure, set_baudrate, sr}; |
| 11 | use crate::Peri; | ||
| 11 | use crate::dma::ReadableRingBuffer; | 12 | use crate::dma::ReadableRingBuffer; |
| 12 | use crate::gpio::{AnyPin, SealedPin as _}; | 13 | use crate::gpio::{AnyPin, SealedPin as _}; |
| 13 | use crate::mode::Async; | 14 | use crate::mode::Async; |
| 14 | use crate::time::Hertz; | 15 | use crate::time::Hertz; |
| 15 | use crate::usart::Regs; | 16 | use crate::usart::Regs; |
| 16 | use crate::Peri; | ||
| 17 | 17 | ||
| 18 | /// Rx-only Ring-buffered UART Driver | 18 | /// Rx-only Ring-buffered UART Driver |
| 19 | /// | 19 | /// |
| @@ -26,9 +26,9 @@ use crate::Peri; | |||
| 26 | /// contain enough bytes to fill the buffer passed by the caller of | 26 | /// contain enough bytes to fill the buffer passed by the caller of |
| 27 | /// the function, or is empty. | 27 | /// the function, or is empty. |
| 28 | /// | 28 | /// |
| 29 | /// Waiting for bytes operates in one of two modes, depending on | 29 | /// Waiting for bytes operates in one of three modes, depending on |
| 30 | /// the behavior of the sender and the size of the buffer passed | 30 | /// the behavior of the sender, the size of the buffer passed |
| 31 | /// to the function: | 31 | /// to the function, and the configuration: |
| 32 | /// | 32 | /// |
| 33 | /// - If the sender sends intermittently, the 'idle line' | 33 | /// - If the sender sends intermittently, the 'idle line' |
| 34 | /// condition will be detected when the sender stops, and any | 34 | /// condition will be detected when the sender stops, and any |
| @@ -47,7 +47,11 @@ use crate::Peri; | |||
| 47 | /// interrupt when those specific buffer addresses have been | 47 | /// interrupt when those specific buffer addresses have been |
| 48 | /// written. | 48 | /// written. |
| 49 | /// | 49 | /// |
| 50 | /// In both cases this will result in variable latency due to the | 50 | /// - If `eager_reads` is enabled in `config`, the UART interrupt |
| 51 | /// is enabled on all data reception and the call will only wait | ||
| 52 | /// for at least one byte to be available before returning. | ||
| 53 | /// | ||
| 54 | /// In the first two cases this will result in variable latency due to the | ||
| 51 | /// buffering effect. For example, if the baudrate is 2400 bps, and | 55 | /// buffering effect. For example, if the baudrate is 2400 bps, and |
| 52 | /// the configuration is 8 data bits, no parity bit, and one stop bit, | 56 | /// the configuration is 8 data bits, no parity bit, and one stop bit, |
| 53 | /// then a byte will be received every ~4.16ms. If the ring buffer is | 57 | /// then a byte will be received every ~4.16ms. If the ring buffer is |
| @@ -68,15 +72,10 @@ use crate::Peri; | |||
| 68 | /// sending, but would be falsely triggered in the worst-case | 72 | /// sending, but would be falsely triggered in the worst-case |
| 69 | /// buffer delay scenario. | 73 | /// buffer delay scenario. |
| 70 | /// | 74 | /// |
| 71 | /// Note: This latency is caused by the limited capabilities of the | 75 | /// Note: Enabling `eager_reads` with `RingBufferedUartRx` will enable |
| 72 | /// STM32 DMA controller; since it cannot generate an interrupt when | 76 | /// an UART RXNE interrupt, which will cause an interrupt to occur on |
| 73 | /// it stores a byte into an empty ring buffer, or in any other | 77 | /// every received data byte. The data is still copied using DMA, but |
| 74 | /// configurable conditions, it is not possible to take notice of the | 78 | /// there is nevertheless additional processing overhead for each byte. |
| 75 | /// contents of the ring buffer more quickly without introducing | ||
| 76 | /// polling. As a result the latency can be reduced by calling the | ||
| 77 | /// read functions repeatedly with smaller buffers to receive the | ||
| 78 | /// available bytes, as each call to a read function will explicitly | ||
| 79 | /// check the ring buffer for available bytes. | ||
| 80 | pub struct RingBufferedUartRx<'d> { | 79 | pub struct RingBufferedUartRx<'d> { |
| 81 | info: &'static Info, | 80 | info: &'static Info, |
| 82 | state: &'static State, | 81 | state: &'static State, |
| @@ -133,6 +132,9 @@ impl<'d> UartRx<'d, Async> { | |||
| 133 | impl<'d> RingBufferedUartRx<'d> { | 132 | impl<'d> RingBufferedUartRx<'d> { |
| 134 | /// Reconfigure the driver | 133 | /// Reconfigure the driver |
| 135 | pub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError> { | 134 | pub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError> { |
| 135 | self.state | ||
| 136 | .eager_reads | ||
| 137 | .store(config.eager_reads.unwrap_or(0), Ordering::Relaxed); | ||
| 136 | reconfigure(self.info, self.kernel_clock, config) | 138 | reconfigure(self.info, self.kernel_clock, config) |
| 137 | } | 139 | } |
| 138 | 140 | ||
| @@ -148,8 +150,8 @@ impl<'d> RingBufferedUartRx<'d> { | |||
| 148 | let r = self.info.regs; | 150 | let r = self.info.regs; |
| 149 | // clear all interrupts and DMA Rx Request | 151 | // clear all interrupts and DMA Rx Request |
| 150 | r.cr1().modify(|w| { | 152 | r.cr1().modify(|w| { |
| 151 | // disable RXNE interrupt | 153 | // use RXNE only when returning reads early |
| 152 | w.set_rxneie(false); | 154 | w.set_rxneie(self.state.eager_reads.load(Ordering::Relaxed) > 0); |
| 153 | // enable parity interrupt if not ParityNone | 155 | // enable parity interrupt if not ParityNone |
| 154 | w.set_peie(w.pce()); | 156 | w.set_peie(w.pce()); |
| 155 | // enable idle line interrupt | 157 | // enable idle line interrupt |
| @@ -248,39 +250,67 @@ impl<'d> RingBufferedUartRx<'d> { | |||
| 248 | async fn wait_for_data_or_idle(&mut self) -> Result<(), Error> { | 250 | async fn wait_for_data_or_idle(&mut self) -> Result<(), Error> { |
| 249 | compiler_fence(Ordering::SeqCst); | 251 | compiler_fence(Ordering::SeqCst); |
| 250 | 252 | ||
| 251 | // Future which completes when idle line is detected | 253 | loop { |
| 252 | let s = self.state; | 254 | // Future which completes when idle line is detected |
| 253 | let uart = poll_fn(|cx| { | 255 | let s = self.state; |
| 254 | s.rx_waker.register(cx.waker()); | 256 | let mut uart_init = false; |
| 255 | 257 | let uart = poll_fn(|cx| { | |
| 256 | compiler_fence(Ordering::SeqCst); | 258 | s.rx_waker.register(cx.waker()); |
| 257 | 259 | ||
| 258 | if check_idle_and_errors(self.info.regs)? { | 260 | compiler_fence(Ordering::SeqCst); |
| 259 | // Idle line is detected | 261 | |
| 260 | Poll::Ready(Ok(())) | 262 | // We may have been woken by IDLE or, if eager_reads is set, by RXNE. |
| 261 | } else { | 263 | // However, DMA will clear RXNE, so we can't check directly, and because |
| 262 | Poll::Pending | 264 | // the other future borrows `ring_buf`, we can't check `len()` here either. |
| 263 | } | 265 | // Instead, return from this future and we'll check the length afterwards. |
| 264 | }); | 266 | let eager = s.eager_reads.load(Ordering::Relaxed) > 0; |
| 267 | |||
| 268 | let idle = check_idle_and_errors(self.info.regs)?; | ||
| 269 | if idle || (eager && uart_init) { | ||
| 270 | // Idle line is detected, or eager reads is set and some data is available. | ||
| 271 | Poll::Ready(Ok(idle)) | ||
| 272 | } else { | ||
| 273 | uart_init = true; | ||
| 274 | Poll::Pending | ||
| 275 | } | ||
| 276 | }); | ||
| 265 | 277 | ||
| 266 | let mut dma_init = false; | 278 | let mut dma_init = false; |
| 267 | // Future which completes when the DMA controller indicates it | 279 | // Future which completes when the DMA controller indicates it |
| 268 | // has written to the ring buffer's middle byte, or last byte | 280 | // has written to the ring buffer's middle byte, or last byte |
| 269 | let dma = poll_fn(|cx| { | 281 | let dma = poll_fn(|cx| { |
| 270 | self.ring_buf.set_waker(cx.waker()); | 282 | self.ring_buf.set_waker(cx.waker()); |
| 271 | 283 | ||
| 272 | let status = match dma_init { | 284 | let status = match dma_init { |
| 273 | false => Poll::Pending, | 285 | false => Poll::Pending, |
| 274 | true => Poll::Ready(()), | 286 | true => Poll::Ready(()), |
| 275 | }; | 287 | }; |
| 276 | 288 | ||
| 277 | dma_init = true; | 289 | dma_init = true; |
| 278 | status | 290 | status |
| 279 | }); | 291 | }); |
| 280 | 292 | ||
| 281 | match select(uart, dma).await { | 293 | match select(uart, dma).await { |
| 282 | Either::Left((result, _)) => result, | 294 | // UART woke with line idle |
| 283 | Either::Right(((), _)) => Ok(()), | 295 | Either::Left((Ok(true), _)) => { |
| 296 | return Ok(()); | ||
| 297 | } | ||
| 298 | // UART woke without idle or error: word received | ||
| 299 | Either::Left((Ok(false), _)) => { | ||
| 300 | let eager = self.state.eager_reads.load(Ordering::Relaxed); | ||
| 301 | if eager > 0 && self.ring_buf.len().unwrap_or(0) >= eager { | ||
| 302 | return Ok(()); | ||
| 303 | } else { | ||
| 304 | continue; | ||
| 305 | } | ||
| 306 | } | ||
| 307 | // UART woke with error | ||
| 308 | Either::Left((Err(e), _)) => { | ||
| 309 | return Err(e); | ||
| 310 | } | ||
| 311 | // DMA woke | ||
| 312 | Either::Right(((), _)) => return Ok(()), | ||
| 313 | } | ||
| 284 | } | 314 | } |
| 285 | } | 315 | } |
| 286 | 316 | ||
diff --git a/embassy-stm32/src/usb/otg.rs b/embassy-stm32/src/usb/otg.rs index 5ce81b131..f6b1a81db 100644 --- a/embassy-stm32/src/usb/otg.rs +++ b/embassy-stm32/src/usb/otg.rs | |||
| @@ -2,18 +2,18 @@ use core::marker::PhantomData; | |||
| 2 | 2 | ||
| 3 | use embassy_hal_internal::PeripheralType; | 3 | use embassy_hal_internal::PeripheralType; |
| 4 | use embassy_usb_driver::{EndpointAddress, EndpointAllocError, EndpointType, Event, Unsupported}; | 4 | use embassy_usb_driver::{EndpointAddress, EndpointAllocError, EndpointType, Event, Unsupported}; |
| 5 | use embassy_usb_synopsys_otg::otg_v1::vals::Dspd; | ||
| 6 | use embassy_usb_synopsys_otg::otg_v1::Otg; | ||
| 7 | pub use embassy_usb_synopsys_otg::Config; | 5 | pub use embassy_usb_synopsys_otg::Config; |
| 6 | use embassy_usb_synopsys_otg::otg_v1::Otg; | ||
| 7 | use embassy_usb_synopsys_otg::otg_v1::vals::Dspd; | ||
| 8 | use embassy_usb_synopsys_otg::{ | 8 | use embassy_usb_synopsys_otg::{ |
| 9 | on_interrupt as on_interrupt_impl, Bus as OtgBus, ControlPipe, Driver as OtgDriver, Endpoint, In, OtgInstance, Out, | 9 | Bus as OtgBus, ControlPipe, Driver as OtgDriver, Endpoint, In, OtgInstance, Out, PhyType, State, |
| 10 | PhyType, State, | 10 | on_interrupt as on_interrupt_impl, |
| 11 | }; | 11 | }; |
| 12 | 12 | ||
| 13 | use crate::gpio::{AfType, OutputType, Speed}; | 13 | use crate::gpio::{AfType, OutputType, Speed}; |
| 14 | use crate::interrupt::typelevel::Interrupt; | 14 | use crate::interrupt::typelevel::Interrupt; |
| 15 | use crate::rcc::{self, RccPeripheral}; | 15 | use crate::rcc::{self, RccPeripheral}; |
| 16 | use crate::{interrupt, Peri}; | 16 | use crate::{Peri, interrupt}; |
| 17 | 17 | ||
| 18 | const MAX_EP_COUNT: usize = 9; | 18 | const MAX_EP_COUNT: usize = 9; |
| 19 | 19 | ||
diff --git a/embassy-stm32/src/usb/usb.rs b/embassy-stm32/src/usb/usb.rs index 9e08d99b3..d405e4802 100644 --- a/embassy-stm32/src/usb/usb.rs +++ b/embassy-stm32/src/usb/usb.rs | |||
| @@ -12,11 +12,11 @@ use embassy_usb_driver::{ | |||
| 12 | Direction, EndpointAddress, EndpointAllocError, EndpointError, EndpointInfo, EndpointType, Event, Unsupported, | 12 | Direction, EndpointAddress, EndpointAllocError, EndpointError, EndpointInfo, EndpointType, Event, Unsupported, |
| 13 | }; | 13 | }; |
| 14 | 14 | ||
| 15 | use crate::pac::USBRAM; | ||
| 15 | use crate::pac::usb::regs; | 16 | use crate::pac::usb::regs; |
| 16 | use crate::pac::usb::vals::{EpType, Stat}; | 17 | use crate::pac::usb::vals::{EpType, Stat}; |
| 17 | use crate::pac::USBRAM; | ||
| 18 | use crate::rcc::RccPeripheral; | 18 | use crate::rcc::RccPeripheral; |
| 19 | use crate::{interrupt, Peri}; | 19 | use crate::{Peri, interrupt}; |
| 20 | 20 | ||
| 21 | /// Interrupt handler. | 21 | /// Interrupt handler. |
| 22 | pub struct InterruptHandler<T: Instance> { | 22 | pub struct InterruptHandler<T: Instance> { |
diff --git a/embassy-stm32/src/vrefbuf/mod.rs b/embassy-stm32/src/vrefbuf/mod.rs index ccbd748d5..b061306a0 100644 --- a/embassy-stm32/src/vrefbuf/mod.rs +++ b/embassy-stm32/src/vrefbuf/mod.rs | |||
| @@ -62,8 +62,7 @@ impl<'d, T: Instance> VoltageReferenceBuffer<'d, T> { | |||
| 62 | } | 62 | } |
| 63 | trace!( | 63 | trace!( |
| 64 | "Vrefbuf configured with voltage scale {} and impedance mode {}", | 64 | "Vrefbuf configured with voltage scale {} and impedance mode {}", |
| 65 | voltage_scale as u8, | 65 | voltage_scale as u8, impedance_mode as u8, |
| 66 | impedance_mode as u8, | ||
| 67 | ); | 66 | ); |
| 68 | VoltageReferenceBuffer { vrefbuf: PhantomData } | 67 | VoltageReferenceBuffer { vrefbuf: PhantomData } |
| 69 | } | 68 | } |
diff --git a/embassy-stm32/src/wdg/mod.rs b/embassy-stm32/src/wdg/mod.rs index fb5c3d930..1164739ff 100644 --- a/embassy-stm32/src/wdg/mod.rs +++ b/embassy-stm32/src/wdg/mod.rs | |||
| @@ -4,8 +4,8 @@ use core::marker::PhantomData; | |||
| 4 | use embassy_hal_internal::PeripheralType; | 4 | use embassy_hal_internal::PeripheralType; |
| 5 | use stm32_metapac::iwdg::vals::{Key, Pr}; | 5 | use stm32_metapac::iwdg::vals::{Key, Pr}; |
| 6 | 6 | ||
| 7 | use crate::rcc::LSI_FREQ; | ||
| 8 | use crate::Peri; | 7 | use crate::Peri; |
| 8 | use crate::rcc::LSI_FREQ; | ||
| 9 | 9 | ||
| 10 | /// Independent watchdog (IWDG) driver. | 10 | /// Independent watchdog (IWDG) driver. |
| 11 | pub struct IndependentWatchdog<'d, T: Instance> { | 11 | pub struct IndependentWatchdog<'d, T: Instance> { |
diff --git a/embassy-stm32/src/xspi/mod.rs b/embassy-stm32/src/xspi/mod.rs index 901569f64..a80a2692b 100644 --- a/embassy-stm32/src/xspi/mod.rs +++ b/embassy-stm32/src/xspi/mod.rs | |||
| @@ -11,15 +11,15 @@ use embassy_embedded_hal::{GetConfig, SetConfig}; | |||
| 11 | use embassy_hal_internal::PeripheralType; | 11 | use embassy_hal_internal::PeripheralType; |
| 12 | pub use enums::*; | 12 | pub use enums::*; |
| 13 | 13 | ||
| 14 | use crate::dma::{word, ChannelAndRequest}; | 14 | use crate::dma::{ChannelAndRequest, word}; |
| 15 | use crate::gpio::{AfType, AnyPin, OutputType, Pull, SealedPin as _, Speed}; | 15 | use crate::gpio::{AfType, AnyPin, OutputType, Pull, SealedPin as _, Speed}; |
| 16 | use crate::mode::{Async, Blocking, Mode as PeriMode}; | 16 | use crate::mode::{Async, Blocking, Mode as PeriMode}; |
| 17 | use crate::pac::xspi::vals::*; | ||
| 18 | use crate::pac::xspi::Xspi as Regs; | 17 | use crate::pac::xspi::Xspi as Regs; |
| 18 | use crate::pac::xspi::vals::*; | ||
| 19 | #[cfg(xspim_v1)] | 19 | #[cfg(xspim_v1)] |
| 20 | use crate::pac::xspim::Xspim; | 20 | use crate::pac::xspim::Xspim; |
| 21 | use crate::rcc::{self, RccPeripheral}; | 21 | use crate::rcc::{self, RccPeripheral}; |
| 22 | use crate::{peripherals, Peri}; | 22 | use crate::{Peri, peripherals}; |
| 23 | 23 | ||
| 24 | /// XPSI driver config. | 24 | /// XPSI driver config. |
| 25 | #[derive(Clone, Copy)] | 25 | #[derive(Clone, Copy)] |
diff --git a/embassy-sync/Cargo.toml b/embassy-sync/Cargo.toml index 64d76baba..0c28cec7d 100644 --- a/embassy-sync/Cargo.toml +++ b/embassy-sync/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-sync" | 2 | name = "embassy-sync" |
| 3 | version = "0.7.2" | 3 | version = "0.7.2" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | description = "no-std, no-alloc synchronization primitives with async support" | 5 | description = "no-std, no-alloc synchronization primitives with async support" |
| 6 | repository = "https://github.com/embassy-rs/embassy" | 6 | repository = "https://github.com/embassy-rs/embassy" |
| 7 | documentation = "https://docs.embassy.dev/embassy-sync" | 7 | documentation = "https://docs.embassy.dev/embassy-sync" |
diff --git a/embassy-sync/src/channel.rs b/embassy-sync/src/channel.rs index de437cc52..dbd24a6c7 100644 --- a/embassy-sync/src/channel.rs +++ b/embassy-sync/src/channel.rs | |||
| @@ -50,8 +50,8 @@ use core::task::{Context, Poll}; | |||
| 50 | 50 | ||
| 51 | use heapless::Deque; | 51 | use heapless::Deque; |
| 52 | 52 | ||
| 53 | use crate::blocking_mutex::raw::RawMutex; | ||
| 54 | use crate::blocking_mutex::Mutex; | 53 | use crate::blocking_mutex::Mutex; |
| 54 | use crate::blocking_mutex::raw::RawMutex; | ||
| 55 | use crate::waitqueue::WakerRegistration; | 55 | use crate::waitqueue::WakerRegistration; |
| 56 | 56 | ||
| 57 | /// Send-only access to a [`Channel`]. | 57 | /// Send-only access to a [`Channel`]. |
| @@ -1112,11 +1112,13 @@ mod tests { | |||
| 1112 | static CHANNEL: StaticCell<Channel<CriticalSectionRawMutex, u32, 3>> = StaticCell::new(); | 1112 | static CHANNEL: StaticCell<Channel<CriticalSectionRawMutex, u32, 3>> = StaticCell::new(); |
| 1113 | let c = &*CHANNEL.init(Channel::new()); | 1113 | let c = &*CHANNEL.init(Channel::new()); |
| 1114 | let c2 = c; | 1114 | let c2 = c; |
| 1115 | assert!(executor | 1115 | assert!( |
| 1116 | .spawn(async move { | 1116 | executor |
| 1117 | assert!(c2.try_send(1).is_ok()); | 1117 | .spawn(async move { |
| 1118 | }) | 1118 | assert!(c2.try_send(1).is_ok()); |
| 1119 | .is_ok()); | 1119 | }) |
| 1120 | .is_ok() | ||
| 1121 | ); | ||
| 1120 | assert_eq!(c.receive().await, 1); | 1122 | assert_eq!(c.receive().await, 1); |
| 1121 | } | 1123 | } |
| 1122 | 1124 | ||
| @@ -1143,13 +1145,15 @@ mod tests { | |||
| 1143 | // However, I've used the debugger to observe that the send does indeed wait. | 1145 | // However, I've used the debugger to observe that the send does indeed wait. |
| 1144 | Delay::new(Duration::from_millis(500)).await; | 1146 | Delay::new(Duration::from_millis(500)).await; |
| 1145 | assert_eq!(c.receive().await, 1); | 1147 | assert_eq!(c.receive().await, 1); |
| 1146 | assert!(executor | 1148 | assert!( |
| 1147 | .spawn(async move { | 1149 | executor |
| 1148 | loop { | 1150 | .spawn(async move { |
| 1149 | c.receive().await; | 1151 | loop { |
| 1150 | } | 1152 | c.receive().await; |
| 1151 | }) | 1153 | } |
| 1152 | .is_ok()); | 1154 | }) |
| 1155 | .is_ok() | ||
| 1156 | ); | ||
| 1153 | send_task_1.unwrap().await; | 1157 | send_task_1.unwrap().await; |
| 1154 | send_task_2.unwrap().await; | 1158 | send_task_2.unwrap().await; |
| 1155 | } | 1159 | } |
diff --git a/embassy-sync/src/lib.rs b/embassy-sync/src/lib.rs index 5d91b4d9c..1cfde8b10 100644 --- a/embassy-sync/src/lib.rs +++ b/embassy-sync/src/lib.rs | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #![cfg_attr(not(feature = "std"), no_std)] | 1 | #![cfg_attr(not(feature = "std"), no_std)] |
| 2 | #![allow(async_fn_in_trait)] | 2 | #![allow(async_fn_in_trait)] |
| 3 | #![allow(clippy::new_without_default)] | 3 | #![allow(clippy::new_without_default)] |
| 4 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 4 | #![doc = include_str!("../README.md")] | 5 | #![doc = include_str!("../README.md")] |
| 5 | #![warn(missing_docs)] | 6 | #![warn(missing_docs)] |
| 6 | 7 | ||
diff --git a/embassy-sync/src/mutex.rs b/embassy-sync/src/mutex.rs index aea682899..96b834f02 100644 --- a/embassy-sync/src/mutex.rs +++ b/embassy-sync/src/mutex.rs | |||
| @@ -2,13 +2,13 @@ | |||
| 2 | //! | 2 | //! |
| 3 | //! This module provides a mutex that can be used to synchronize data between asynchronous tasks. | 3 | //! This module provides a mutex that can be used to synchronize data between asynchronous tasks. |
| 4 | use core::cell::{RefCell, UnsafeCell}; | 4 | use core::cell::{RefCell, UnsafeCell}; |
| 5 | use core::future::{poll_fn, Future}; | 5 | use core::future::{Future, poll_fn}; |
| 6 | use core::ops::{Deref, DerefMut}; | 6 | use core::ops::{Deref, DerefMut}; |
| 7 | use core::task::Poll; | 7 | use core::task::Poll; |
| 8 | use core::{fmt, mem}; | 8 | use core::{fmt, mem}; |
| 9 | 9 | ||
| 10 | use crate::blocking_mutex::raw::RawMutex; | ||
| 11 | use crate::blocking_mutex::Mutex as BlockingMutex; | 10 | use crate::blocking_mutex::Mutex as BlockingMutex; |
| 11 | use crate::blocking_mutex::raw::RawMutex; | ||
| 12 | use crate::waitqueue::WakerRegistration; | 12 | use crate::waitqueue::WakerRegistration; |
| 13 | 13 | ||
| 14 | /// Error returned by [`Mutex::try_lock`] | 14 | /// Error returned by [`Mutex::try_lock`] |
diff --git a/embassy-sync/src/once_lock.rs b/embassy-sync/src/once_lock.rs index 73edfea9a..2af19ca20 100644 --- a/embassy-sync/src/once_lock.rs +++ b/embassy-sync/src/once_lock.rs | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | use core::cell::Cell; | 3 | use core::cell::Cell; |
| 4 | use core::fmt::{Debug, Formatter}; | 4 | use core::fmt::{Debug, Formatter}; |
| 5 | use core::future::{poll_fn, Future}; | 5 | use core::future::{Future, poll_fn}; |
| 6 | use core::mem::MaybeUninit; | 6 | use core::mem::MaybeUninit; |
| 7 | use core::sync::atomic::{AtomicBool, Ordering}; | 7 | use core::sync::atomic::{AtomicBool, Ordering}; |
| 8 | use core::task::Poll; | 8 | use core::task::Poll; |
diff --git a/embassy-sync/src/pipe.rs b/embassy-sync/src/pipe.rs index 6d624979a..215a556d9 100644 --- a/embassy-sync/src/pipe.rs +++ b/embassy-sync/src/pipe.rs | |||
| @@ -7,8 +7,8 @@ use core::ops::Range; | |||
| 7 | use core::pin::Pin; | 7 | use core::pin::Pin; |
| 8 | use core::task::{Context, Poll}; | 8 | use core::task::{Context, Poll}; |
| 9 | 9 | ||
| 10 | use crate::blocking_mutex::raw::RawMutex; | ||
| 11 | use crate::blocking_mutex::Mutex; | 10 | use crate::blocking_mutex::Mutex; |
| 11 | use crate::blocking_mutex::raw::RawMutex; | ||
| 12 | use crate::ring_buffer::RingBuffer; | 12 | use crate::ring_buffer::RingBuffer; |
| 13 | use crate::waitqueue::WakerRegistration; | 13 | use crate::waitqueue::WakerRegistration; |
| 14 | 14 | ||
diff --git a/embassy-sync/src/priority_channel.rs b/embassy-sync/src/priority_channel.rs index 715a20e86..1af7d9221 100644 --- a/embassy-sync/src/priority_channel.rs +++ b/embassy-sync/src/priority_channel.rs | |||
| @@ -8,11 +8,11 @@ use core::future::Future; | |||
| 8 | use core::pin::Pin; | 8 | use core::pin::Pin; |
| 9 | use core::task::{Context, Poll}; | 9 | use core::task::{Context, Poll}; |
| 10 | 10 | ||
| 11 | pub use heapless::binary_heap::{Kind, Max, Min}; | ||
| 12 | use heapless::BinaryHeap; | 11 | use heapless::BinaryHeap; |
| 12 | pub use heapless::binary_heap::{Kind, Max, Min}; | ||
| 13 | 13 | ||
| 14 | use crate::blocking_mutex::raw::RawMutex; | ||
| 15 | use crate::blocking_mutex::Mutex; | 14 | use crate::blocking_mutex::Mutex; |
| 15 | use crate::blocking_mutex::raw::RawMutex; | ||
| 16 | use crate::channel::{DynamicChannel, DynamicReceiver, DynamicSender, TryReceiveError, TrySendError}; | 16 | use crate::channel::{DynamicChannel, DynamicReceiver, DynamicSender, TryReceiveError, TrySendError}; |
| 17 | use crate::waitqueue::WakerRegistration; | 17 | use crate::waitqueue::WakerRegistration; |
| 18 | 18 | ||
| @@ -799,11 +799,13 @@ mod tests { | |||
| 799 | static CHANNEL: StaticCell<PriorityChannel<CriticalSectionRawMutex, u32, Max, 3>> = StaticCell::new(); | 799 | static CHANNEL: StaticCell<PriorityChannel<CriticalSectionRawMutex, u32, Max, 3>> = StaticCell::new(); |
| 800 | let c = &*CHANNEL.init(PriorityChannel::new()); | 800 | let c = &*CHANNEL.init(PriorityChannel::new()); |
| 801 | let c2 = c; | 801 | let c2 = c; |
| 802 | assert!(executor | 802 | assert!( |
| 803 | .spawn(async move { | 803 | executor |
| 804 | assert!(c2.try_send(1).is_ok()); | 804 | .spawn(async move { |
| 805 | }) | 805 | assert!(c2.try_send(1).is_ok()); |
| 806 | .is_ok()); | 806 | }) |
| 807 | .is_ok() | ||
| 808 | ); | ||
| 807 | assert_eq!(c.receive().await, 1); | 809 | assert_eq!(c.receive().await, 1); |
| 808 | } | 810 | } |
| 809 | 811 | ||
| @@ -830,13 +832,15 @@ mod tests { | |||
| 830 | // However, I've used the debugger to observe that the send does indeed wait. | 832 | // However, I've used the debugger to observe that the send does indeed wait. |
| 831 | Delay::new(Duration::from_millis(500)).await; | 833 | Delay::new(Duration::from_millis(500)).await; |
| 832 | assert_eq!(c.receive().await, 1); | 834 | assert_eq!(c.receive().await, 1); |
| 833 | assert!(executor | 835 | assert!( |
| 834 | .spawn(async move { | 836 | executor |
| 835 | loop { | 837 | .spawn(async move { |
| 836 | c.receive().await; | 838 | loop { |
| 837 | } | 839 | c.receive().await; |
| 838 | }) | 840 | } |
| 839 | .is_ok()); | 841 | }) |
| 842 | .is_ok() | ||
| 843 | ); | ||
| 840 | send_task_1.unwrap().await; | 844 | send_task_1.unwrap().await; |
| 841 | send_task_2.unwrap().await; | 845 | send_task_2.unwrap().await; |
| 842 | } | 846 | } |
diff --git a/embassy-sync/src/pubsub/mod.rs b/embassy-sync/src/pubsub/mod.rs index ad9402f5a..127a208f1 100644 --- a/embassy-sync/src/pubsub/mod.rs +++ b/embassy-sync/src/pubsub/mod.rs | |||
| @@ -10,8 +10,8 @@ use heapless::Deque; | |||
| 10 | 10 | ||
| 11 | use self::publisher::{ImmediatePub, Pub}; | 11 | use self::publisher::{ImmediatePub, Pub}; |
| 12 | use self::subscriber::Sub; | 12 | use self::subscriber::Sub; |
| 13 | use crate::blocking_mutex::raw::RawMutex; | ||
| 14 | use crate::blocking_mutex::Mutex; | 13 | use crate::blocking_mutex::Mutex; |
| 14 | use crate::blocking_mutex::raw::RawMutex; | ||
| 15 | use crate::waitqueue::MultiWakerRegistration; | 15 | use crate::waitqueue::MultiWakerRegistration; |
| 16 | 16 | ||
| 17 | pub mod publisher; | 17 | pub mod publisher; |
diff --git a/embassy-sync/src/ring_buffer.rs b/embassy-sync/src/ring_buffer.rs index f03b7dd8f..608447cd6 100644 --- a/embassy-sync/src/ring_buffer.rs +++ b/embassy-sync/src/ring_buffer.rs | |||
| @@ -95,11 +95,7 @@ impl<const N: usize> RingBuffer<N> { | |||
| 95 | 95 | ||
| 96 | fn wrap(&self, n: usize) -> usize { | 96 | fn wrap(&self, n: usize) -> usize { |
| 97 | assert!(n <= N); | 97 | assert!(n <= N); |
| 98 | if n == N { | 98 | if n == N { 0 } else { n } |
| 99 | 0 | ||
| 100 | } else { | ||
| 101 | n | ||
| 102 | } | ||
| 103 | } | 99 | } |
| 104 | } | 100 | } |
| 105 | 101 | ||
diff --git a/embassy-sync/src/rwlock.rs b/embassy-sync/src/rwlock.rs index e43388c4d..918a6aa41 100644 --- a/embassy-sync/src/rwlock.rs +++ b/embassy-sync/src/rwlock.rs | |||
| @@ -3,12 +3,12 @@ | |||
| 3 | //! This module provides a read-write lock that can be used to synchronize data between asynchronous tasks. | 3 | //! This module provides a read-write lock that can be used to synchronize data between asynchronous tasks. |
| 4 | use core::cell::{RefCell, UnsafeCell}; | 4 | use core::cell::{RefCell, UnsafeCell}; |
| 5 | use core::fmt; | 5 | use core::fmt; |
| 6 | use core::future::{poll_fn, Future}; | 6 | use core::future::{Future, poll_fn}; |
| 7 | use core::ops::{Deref, DerefMut}; | 7 | use core::ops::{Deref, DerefMut}; |
| 8 | use core::task::Poll; | 8 | use core::task::Poll; |
| 9 | 9 | ||
| 10 | use crate::blocking_mutex::raw::RawMutex; | ||
| 11 | use crate::blocking_mutex::Mutex as BlockingMutex; | 10 | use crate::blocking_mutex::Mutex as BlockingMutex; |
| 11 | use crate::blocking_mutex::raw::RawMutex; | ||
| 12 | use crate::waitqueue::WakerRegistration; | 12 | use crate::waitqueue::WakerRegistration; |
| 13 | 13 | ||
| 14 | /// Error returned by [`RwLock::try_read`] and [`RwLock::try_write`] when the lock is already held. | 14 | /// Error returned by [`RwLock::try_read`] and [`RwLock::try_write`] when the lock is already held. |
diff --git a/embassy-sync/src/semaphore.rs b/embassy-sync/src/semaphore.rs index 4e82b0fcd..8d2413931 100644 --- a/embassy-sync/src/semaphore.rs +++ b/embassy-sync/src/semaphore.rs | |||
| @@ -1,13 +1,13 @@ | |||
| 1 | //! A synchronization primitive for controlling access to a pool of resources. | 1 | //! A synchronization primitive for controlling access to a pool of resources. |
| 2 | use core::cell::{Cell, RefCell}; | 2 | use core::cell::{Cell, RefCell}; |
| 3 | use core::convert::Infallible; | 3 | use core::convert::Infallible; |
| 4 | use core::future::{poll_fn, Future}; | 4 | use core::future::{Future, poll_fn}; |
| 5 | use core::task::{Poll, Waker}; | 5 | use core::task::{Poll, Waker}; |
| 6 | 6 | ||
| 7 | use heapless::Deque; | 7 | use heapless::Deque; |
| 8 | 8 | ||
| 9 | use crate::blocking_mutex::raw::RawMutex; | ||
| 10 | use crate::blocking_mutex::Mutex; | 9 | use crate::blocking_mutex::Mutex; |
| 10 | use crate::blocking_mutex::raw::RawMutex; | ||
| 11 | use crate::waitqueue::WakerRegistration; | 11 | use crate::waitqueue::WakerRegistration; |
| 12 | 12 | ||
| 13 | /// An asynchronous semaphore. | 13 | /// An asynchronous semaphore. |
diff --git a/embassy-sync/src/signal.rs b/embassy-sync/src/signal.rs index 229b1fa99..cc02228cf 100644 --- a/embassy-sync/src/signal.rs +++ b/embassy-sync/src/signal.rs | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | //! A synchronization primitive for passing the latest value to a task. | 1 | //! A synchronization primitive for passing the latest value to a task. |
| 2 | use core::cell::Cell; | 2 | use core::cell::Cell; |
| 3 | use core::future::{poll_fn, Future}; | 3 | use core::future::{Future, poll_fn}; |
| 4 | use core::task::{Context, Poll, Waker}; | 4 | use core::task::{Context, Poll, Waker}; |
| 5 | 5 | ||
| 6 | use crate::blocking_mutex::raw::RawMutex; | ||
| 7 | use crate::blocking_mutex::Mutex; | 6 | use crate::blocking_mutex::Mutex; |
| 7 | use crate::blocking_mutex::raw::RawMutex; | ||
| 8 | 8 | ||
| 9 | /// Single-slot signaling primitive for a _single_ consumer. | 9 | /// Single-slot signaling primitive for a _single_ consumer. |
| 10 | /// | 10 | /// |
diff --git a/embassy-sync/src/waitqueue/atomic_waker.rs b/embassy-sync/src/waitqueue/atomic_waker.rs index 5a9910e7f..d2bf890e5 100644 --- a/embassy-sync/src/waitqueue/atomic_waker.rs +++ b/embassy-sync/src/waitqueue/atomic_waker.rs | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | use core::cell::Cell; | 1 | use core::cell::Cell; |
| 2 | use core::task::Waker; | 2 | use core::task::Waker; |
| 3 | 3 | ||
| 4 | use crate::blocking_mutex::raw::{CriticalSectionRawMutex, RawMutex}; | ||
| 5 | use crate::blocking_mutex::Mutex; | 4 | use crate::blocking_mutex::Mutex; |
| 5 | use crate::blocking_mutex::raw::{CriticalSectionRawMutex, RawMutex}; | ||
| 6 | 6 | ||
| 7 | /// Utility struct to register and wake a waker. | 7 | /// Utility struct to register and wake a waker. |
| 8 | /// If a waker is registered, registering another waker will replace the previous one without waking it. | 8 | /// If a waker is registered, registering another waker will replace the previous one without waking it. |
diff --git a/embassy-sync/src/watch.rs b/embassy-sync/src/watch.rs index 332ab5405..0f8a8d679 100644 --- a/embassy-sync/src/watch.rs +++ b/embassy-sync/src/watch.rs | |||
| @@ -1,13 +1,13 @@ | |||
| 1 | //! A synchronization primitive for passing the latest value to **multiple** receivers. | 1 | //! A synchronization primitive for passing the latest value to **multiple** receivers. |
| 2 | 2 | ||
| 3 | use core::cell::RefCell; | 3 | use core::cell::RefCell; |
| 4 | use core::future::{poll_fn, Future}; | 4 | use core::future::{Future, poll_fn}; |
| 5 | use core::marker::PhantomData; | 5 | use core::marker::PhantomData; |
| 6 | use core::ops::{Deref, DerefMut}; | 6 | use core::ops::{Deref, DerefMut}; |
| 7 | use core::task::{Context, Poll}; | 7 | use core::task::{Context, Poll}; |
| 8 | 8 | ||
| 9 | use crate::blocking_mutex::raw::RawMutex; | ||
| 10 | use crate::blocking_mutex::Mutex; | 9 | use crate::blocking_mutex::Mutex; |
| 10 | use crate::blocking_mutex::raw::RawMutex; | ||
| 11 | use crate::waitqueue::MultiWakerRegistration; | 11 | use crate::waitqueue::MultiWakerRegistration; |
| 12 | 12 | ||
| 13 | /// The `Watch` is a single-slot signaling primitive that allows _multiple_ (`N`) receivers to concurrently await | 13 | /// The `Watch` is a single-slot signaling primitive that allows _multiple_ (`N`) receivers to concurrently await |
diff --git a/embassy-sync/src/zerocopy_channel.rs b/embassy-sync/src/zerocopy_channel.rs index b3f7dbe8c..c572592b8 100644 --- a/embassy-sync/src/zerocopy_channel.rs +++ b/embassy-sync/src/zerocopy_channel.rs | |||
| @@ -15,12 +15,12 @@ | |||
| 15 | //! another message will result in an error being returned. | 15 | //! another message will result in an error being returned. |
| 16 | 16 | ||
| 17 | use core::cell::RefCell; | 17 | use core::cell::RefCell; |
| 18 | use core::future::{poll_fn, Future}; | 18 | use core::future::{Future, poll_fn}; |
| 19 | use core::marker::PhantomData; | 19 | use core::marker::PhantomData; |
| 20 | use core::task::{Context, Poll}; | 20 | use core::task::{Context, Poll}; |
| 21 | 21 | ||
| 22 | use crate::blocking_mutex::raw::RawMutex; | ||
| 23 | use crate::blocking_mutex::Mutex; | 22 | use crate::blocking_mutex::Mutex; |
| 23 | use crate::blocking_mutex::raw::RawMutex; | ||
| 24 | use crate::waitqueue::WakerRegistration; | 24 | use crate::waitqueue::WakerRegistration; |
| 25 | 25 | ||
| 26 | /// A bounded zero-copy channel for communicating between asynchronous tasks | 26 | /// A bounded zero-copy channel for communicating between asynchronous tasks |
| @@ -296,11 +296,7 @@ struct State { | |||
| 296 | 296 | ||
| 297 | impl State { | 297 | impl State { |
| 298 | fn increment(&self, i: usize) -> usize { | 298 | fn increment(&self, i: usize) -> usize { |
| 299 | if i + 1 == self.capacity { | 299 | if i + 1 == self.capacity { 0 } else { i + 1 } |
| 300 | 0 | ||
| 301 | } else { | ||
| 302 | i + 1 | ||
| 303 | } | ||
| 304 | } | 300 | } |
| 305 | 301 | ||
| 306 | fn clear(&mut self) { | 302 | fn clear(&mut self) { |
diff --git a/embassy-time-driver/Cargo.toml b/embassy-time-driver/Cargo.toml index 56ef3d15f..a52e82433 100644 --- a/embassy-time-driver/Cargo.toml +++ b/embassy-time-driver/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-time-driver" | 2 | name = "embassy-time-driver" |
| 3 | version = "0.2.1" | 3 | version = "0.2.1" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | description = "Driver trait for embassy-time" | 5 | description = "Driver trait for embassy-time" |
| 6 | repository = "https://github.com/embassy-rs/embassy" | 6 | repository = "https://github.com/embassy-rs/embassy" |
| 7 | documentation = "https://docs.embassy.dev/embassy-time-driver" | 7 | documentation = "https://docs.embassy.dev/embassy-time-driver" |
diff --git a/embassy-time-driver/src/lib.rs b/embassy-time-driver/src/lib.rs index 44d9a156a..f3e8e0153 100644 --- a/embassy-time-driver/src/lib.rs +++ b/embassy-time-driver/src/lib.rs | |||
| @@ -89,7 +89,7 @@ | |||
| 89 | //! Instead of the usual "trait + generic params" approach, calls from embassy to the driver are done via `extern` functions. | 89 | //! Instead of the usual "trait + generic params" approach, calls from embassy to the driver are done via `extern` functions. |
| 90 | //! | 90 | //! |
| 91 | //! `embassy` internally defines the driver function as `extern "Rust" { fn _embassy_time_now() -> u64; }` and calls it. | 91 | //! `embassy` internally defines the driver function as `extern "Rust" { fn _embassy_time_now() -> u64; }` and calls it. |
| 92 | //! The driver crate defines the function as `#[no_mangle] fn _embassy_time_now() -> u64`. The linker will resolve the | 92 | //! The driver crate defines the function as `#[unsafe(no_mangle)] fn _embassy_time_now() -> u64`. The linker will resolve the |
| 93 | //! calls from the `embassy` crate to call into the driver crate. | 93 | //! calls from the `embassy` crate to call into the driver crate. |
| 94 | //! | 94 | //! |
| 95 | //! If there is none or multiple drivers in the crate tree, linking will fail. | 95 | //! If there is none or multiple drivers in the crate tree, linking will fail. |
| @@ -133,7 +133,7 @@ pub trait Driver: Send + Sync + 'static { | |||
| 133 | fn schedule_wake(&self, at: u64, waker: &Waker); | 133 | fn schedule_wake(&self, at: u64, waker: &Waker); |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | extern "Rust" { | 136 | unsafe extern "Rust" { |
| 137 | fn _embassy_time_now() -> u64; | 137 | fn _embassy_time_now() -> u64; |
| 138 | fn _embassy_time_schedule_wake(at: u64, waker: &Waker); | 138 | fn _embassy_time_schedule_wake(at: u64, waker: &Waker); |
| 139 | } | 139 | } |
| @@ -158,13 +158,13 @@ macro_rules! time_driver_impl { | |||
| 158 | (static $name:ident: $t: ty = $val:expr) => { | 158 | (static $name:ident: $t: ty = $val:expr) => { |
| 159 | static $name: $t = $val; | 159 | static $name: $t = $val; |
| 160 | 160 | ||
| 161 | #[no_mangle] | 161 | #[unsafe(no_mangle)] |
| 162 | #[inline] | 162 | #[inline] |
| 163 | fn _embassy_time_now() -> u64 { | 163 | fn _embassy_time_now() -> u64 { |
| 164 | <$t as $crate::Driver>::now(&$name) | 164 | <$t as $crate::Driver>::now(&$name) |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | #[no_mangle] | 167 | #[unsafe(no_mangle)] |
| 168 | #[inline] | 168 | #[inline] |
| 169 | fn _embassy_time_schedule_wake(at: u64, waker: &core::task::Waker) { | 169 | fn _embassy_time_schedule_wake(at: u64, waker: &core::task::Waker) { |
| 170 | <$t as $crate::Driver>::schedule_wake(&$name, at, waker); | 170 | <$t as $crate::Driver>::schedule_wake(&$name, at, waker); |
diff --git a/embassy-time-queue-utils/Cargo.toml b/embassy-time-queue-utils/Cargo.toml index 13da62874..8da30c544 100644 --- a/embassy-time-queue-utils/Cargo.toml +++ b/embassy-time-queue-utils/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-time-queue-utils" | 2 | name = "embassy-time-queue-utils" |
| 3 | version = "0.3.0" | 3 | version = "0.3.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | description = "Timer queue driver trait for embassy-time" | 5 | description = "Timer queue driver trait for embassy-time" |
| 6 | repository = "https://github.com/embassy-rs/embassy" | 6 | repository = "https://github.com/embassy-rs/embassy" |
| 7 | documentation = "https://docs.embassy.dev/embassy-time-queue-utils" | 7 | documentation = "https://docs.embassy.dev/embassy-time-queue-utils" |
diff --git a/embassy-time-queue-utils/src/queue_generic.rs b/embassy-time-queue-utils/src/queue_generic.rs index bff7a4735..88986953d 100644 --- a/embassy-time-queue-utils/src/queue_generic.rs +++ b/embassy-time-queue-utils/src/queue_generic.rs | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | //! | 2 | //! |
| 3 | //! Time queue drivers may use this to simplify their implementation. | 3 | //! Time queue drivers may use this to simplify their implementation. |
| 4 | 4 | ||
| 5 | use core::cmp::{min, Ordering}; | 5 | use core::cmp::{Ordering, min}; |
| 6 | use core::task::Waker; | 6 | use core::task::Waker; |
| 7 | 7 | ||
| 8 | use heapless::Vec; | 8 | use heapless::Vec; |
diff --git a/embassy-time/Cargo.toml b/embassy-time/Cargo.toml index bad6ecf97..05614dbf5 100644 --- a/embassy-time/Cargo.toml +++ b/embassy-time/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-time" | 2 | name = "embassy-time" |
| 3 | version = "0.5.0" | 3 | version = "0.5.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | description = "Instant and Duration for embedded no-std systems, with async timer support" | 5 | description = "Instant and Duration for embedded no-std systems, with async timer support" |
| 6 | repository = "https://github.com/embassy-rs/embassy" | 6 | repository = "https://github.com/embassy-rs/embassy" |
| 7 | documentation = "https://docs.embassy.dev/embassy-time" | 7 | documentation = "https://docs.embassy.dev/embassy-time" |
diff --git a/embassy-time/src/duration.rs b/embassy-time/src/duration.rs index b3ea0468d..b2bfd6de9 100644 --- a/embassy-time/src/duration.rs +++ b/embassy-time/src/duration.rs | |||
| @@ -175,13 +175,7 @@ impl Duration { | |||
| 175 | /// NOTE: Giving this function a hz >= the TICK_HZ of your platform will clamp the Duration to 1 | 175 | /// NOTE: Giving this function a hz >= the TICK_HZ of your platform will clamp the Duration to 1 |
| 176 | /// tick. Doing so will not deadlock, but will certainly not produce the desired output. | 176 | /// tick. Doing so will not deadlock, but will certainly not produce the desired output. |
| 177 | pub const fn from_hz(hz: u64) -> Duration { | 177 | pub const fn from_hz(hz: u64) -> Duration { |
| 178 | let ticks = { | 178 | let ticks = { if hz >= TICK_HZ { 1 } else { (TICK_HZ + hz / 2) / hz } }; |
| 179 | if hz >= TICK_HZ { | ||
| 180 | 1 | ||
| 181 | } else { | ||
| 182 | (TICK_HZ + hz / 2) / hz | ||
| 183 | } | ||
| 184 | }; | ||
| 185 | Duration { ticks } | 179 | Duration { ticks } |
| 186 | } | 180 | } |
| 187 | 181 | ||
diff --git a/embassy-time/src/lib.rs b/embassy-time/src/lib.rs index 77f4b344d..e375fe93e 100644 --- a/embassy-time/src/lib.rs +++ b/embassy-time/src/lib.rs | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #![cfg_attr(not(any(feature = "std", feature = "wasm", test)), no_std)] | 1 | #![cfg_attr(not(any(feature = "std", feature = "wasm", test)), no_std)] |
| 2 | #![allow(async_fn_in_trait)] | 2 | #![allow(async_fn_in_trait)] |
| 3 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 3 | #![doc = include_str!("../README.md")] | 4 | #![doc = include_str!("../README.md")] |
| 4 | #![allow(clippy::new_without_default)] | 5 | #![allow(clippy::new_without_default)] |
| 5 | #![warn(missing_docs)] | 6 | #![warn(missing_docs)] |
| @@ -27,18 +28,14 @@ mod driver_std; | |||
| 27 | #[cfg(feature = "wasm")] | 28 | #[cfg(feature = "wasm")] |
| 28 | mod driver_wasm; | 29 | mod driver_wasm; |
| 29 | 30 | ||
| 30 | pub use delay::{block_for, Delay}; | 31 | pub use delay::{Delay, block_for}; |
| 31 | pub use duration::Duration; | 32 | pub use duration::Duration; |
| 32 | pub use embassy_time_driver::TICK_HZ; | 33 | pub use embassy_time_driver::TICK_HZ; |
| 33 | pub use instant::Instant; | 34 | pub use instant::Instant; |
| 34 | pub use timer::{with_deadline, with_timeout, Ticker, TimeoutError, Timer, WithTimeout}; | 35 | pub use timer::{Ticker, TimeoutError, Timer, WithTimeout, with_deadline, with_timeout}; |
| 35 | 36 | ||
| 36 | const fn gcd(a: u64, b: u64) -> u64 { | 37 | const fn gcd(a: u64, b: u64) -> u64 { |
| 37 | if b == 0 { | 38 | if b == 0 { a } else { gcd(b, a % b) } |
| 38 | a | ||
| 39 | } else { | ||
| 40 | gcd(b, a % b) | ||
| 41 | } | ||
| 42 | } | 39 | } |
| 43 | 40 | ||
| 44 | pub(crate) const GCD_1K: u64 = gcd(TICK_HZ, 1_000); | 41 | pub(crate) const GCD_1K: u64 = gcd(TICK_HZ, 1_000); |
diff --git a/embassy-time/src/timer.rs b/embassy-time/src/timer.rs index fcf79f58e..2f5967c63 100644 --- a/embassy-time/src/timer.rs +++ b/embassy-time/src/timer.rs | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | use core::future::{poll_fn, Future}; | 1 | use core::future::{Future, poll_fn}; |
| 2 | use core::pin::Pin; | 2 | use core::pin::Pin; |
| 3 | use core::task::{Context, Poll}; | 3 | use core::task::{Context, Poll}; |
| 4 | 4 | ||
| 5 | use futures_core::stream::FusedStream; | ||
| 6 | use futures_core::Stream; | 5 | use futures_core::Stream; |
| 6 | use futures_core::stream::FusedStream; | ||
| 7 | 7 | ||
| 8 | use crate::{Duration, Instant}; | 8 | use crate::{Duration, Instant}; |
| 9 | 9 | ||
diff --git a/embassy-usb-dfu/Cargo.toml b/embassy-usb-dfu/Cargo.toml index e70ab970e..8b32582c0 100644 --- a/embassy-usb-dfu/Cargo.toml +++ b/embassy-usb-dfu/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-usb-dfu" | 3 | name = "embassy-usb-dfu" |
| 4 | version = "0.2.0" | 4 | version = "0.2.0" |
| 5 | description = "An implementation of the USB DFU 1.1 protocol, using embassy-boot" | 5 | description = "An implementation of the USB DFU 1.1 protocol, using embassy-boot" |
diff --git a/embassy-usb-dfu/src/application.rs b/embassy-usb-dfu/src/application.rs index 78eb2c083..1ea1a74fe 100644 --- a/embassy-usb-dfu/src/application.rs +++ b/embassy-usb-dfu/src/application.rs | |||
| @@ -6,11 +6,11 @@ use embassy_usb::driver::Driver; | |||
| 6 | use embassy_usb::{Builder, FunctionBuilder, Handler}; | 6 | use embassy_usb::{Builder, FunctionBuilder, Handler}; |
| 7 | use embedded_storage::nor_flash::NorFlash; | 7 | use embedded_storage::nor_flash::NorFlash; |
| 8 | 8 | ||
| 9 | use crate::Reset; | ||
| 9 | use crate::consts::{ | 10 | use crate::consts::{ |
| 10 | DfuAttributes, Request, State, Status, APPN_SPEC_SUBCLASS_DFU, DESC_DFU_FUNCTIONAL, DFU_PROTOCOL_RT, | 11 | APPN_SPEC_SUBCLASS_DFU, DESC_DFU_FUNCTIONAL, DFU_PROTOCOL_RT, DfuAttributes, Request, State, Status, |
| 11 | USB_CLASS_APPN_SPEC, | 12 | USB_CLASS_APPN_SPEC, |
| 12 | }; | 13 | }; |
| 13 | use crate::Reset; | ||
| 14 | 14 | ||
| 15 | /// Generic interface for a system that can signal to the bootloader that USB DFU mode is needed on the next boot. | 15 | /// Generic interface for a system that can signal to the bootloader that USB DFU mode is needed on the next boot. |
| 16 | /// | 16 | /// |
diff --git a/embassy-usb-dfu/src/dfu.rs b/embassy-usb-dfu/src/dfu.rs index 7c28d04cf..2ed4511ce 100644 --- a/embassy-usb-dfu/src/dfu.rs +++ b/embassy-usb-dfu/src/dfu.rs | |||
| @@ -5,11 +5,11 @@ use embassy_usb::driver::Driver; | |||
| 5 | use embassy_usb::{Builder, FunctionBuilder, Handler}; | 5 | use embassy_usb::{Builder, FunctionBuilder, Handler}; |
| 6 | use embedded_storage::nor_flash::{NorFlash, NorFlashErrorKind}; | 6 | use embedded_storage::nor_flash::{NorFlash, NorFlashErrorKind}; |
| 7 | 7 | ||
| 8 | use crate::Reset; | ||
| 8 | use crate::consts::{ | 9 | use crate::consts::{ |
| 9 | DfuAttributes, Request, State, Status, APPN_SPEC_SUBCLASS_DFU, DESC_DFU_FUNCTIONAL, DFU_PROTOCOL_DFU, | 10 | APPN_SPEC_SUBCLASS_DFU, DESC_DFU_FUNCTIONAL, DFU_PROTOCOL_DFU, DfuAttributes, Request, State, Status, |
| 10 | USB_CLASS_APPN_SPEC, | 11 | USB_CLASS_APPN_SPEC, |
| 11 | }; | 12 | }; |
| 12 | use crate::Reset; | ||
| 13 | 13 | ||
| 14 | /// Internal state for USB DFU | 14 | /// Internal state for USB DFU |
| 15 | pub struct Control<'d, DFU: NorFlash, STATE: NorFlash, RST: Reset, const BLOCK_SIZE: usize> { | 15 | pub struct Control<'d, DFU: NorFlash, STATE: NorFlash, RST: Reset, const BLOCK_SIZE: usize> { |
diff --git a/embassy-usb-driver/Cargo.toml b/embassy-usb-driver/Cargo.toml index 6e4c31273..3f43f60a3 100644 --- a/embassy-usb-driver/Cargo.toml +++ b/embassy-usb-driver/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-usb-driver" | 2 | name = "embassy-usb-driver" |
| 3 | version = "0.2.0" | 3 | version = "0.2.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | description = "Driver trait for `embassy-usb`, an async USB device stack for embedded devices." | 6 | description = "Driver trait for `embassy-usb`, an async USB device stack for embedded devices." |
| 7 | keywords = ["embedded", "async", "usb", "hal", "embedded-hal"] | 7 | keywords = ["embedded", "async", "usb", "hal", "embedded-hal"] |
diff --git a/embassy-usb-driver/src/lib.rs b/embassy-usb-driver/src/lib.rs index 59845a268..f19e0a401 100644 --- a/embassy-usb-driver/src/lib.rs +++ b/embassy-usb-driver/src/lib.rs | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![allow(async_fn_in_trait)] | 2 | #![allow(async_fn_in_trait)] |
| 3 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 3 | #![doc = include_str!("../README.md")] | 4 | #![doc = include_str!("../README.md")] |
| 4 | #![warn(missing_docs)] | 5 | #![warn(missing_docs)] |
| 5 | 6 | ||
diff --git a/embassy-usb-logger/Cargo.toml b/embassy-usb-logger/Cargo.toml index 6d13653bf..683821759 100644 --- a/embassy-usb-logger/Cargo.toml +++ b/embassy-usb-logger/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-usb-logger" | 2 | name = "embassy-usb-logger" |
| 3 | version = "0.5.1" | 3 | version = "0.5.1" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | description = "`log` implementation for USB serial using `embassy-usb`." | 6 | description = "`log` implementation for USB serial using `embassy-usb`." |
| 7 | keywords = ["embedded", "log", "usb", "hal", "serial"] | 7 | keywords = ["embedded", "log", "usb", "hal", "serial"] |
diff --git a/embassy-usb-synopsys-otg/Cargo.toml b/embassy-usb-synopsys-otg/Cargo.toml index 61b14a215..eca68095d 100644 --- a/embassy-usb-synopsys-otg/Cargo.toml +++ b/embassy-usb-synopsys-otg/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-usb-synopsys-otg" | 2 | name = "embassy-usb-synopsys-otg" |
| 3 | version = "0.3.1" | 3 | version = "0.3.1" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | description = "`embassy-usb-driver` implementation for Synopsys OTG USB controllers" | 6 | description = "`embassy-usb-driver` implementation for Synopsys OTG USB controllers" |
| 7 | keywords = ["embedded", "async", "usb", "hal", "embedded-hal"] | 7 | keywords = ["embedded", "async", "usb", "hal", "embedded-hal"] |
diff --git a/embassy-usb-synopsys-otg/src/lib.rs b/embassy-usb-synopsys-otg/src/lib.rs index 6b4a87bdf..d94209f45 100644 --- a/embassy-usb-synopsys-otg/src/lib.rs +++ b/embassy-usb-synopsys-otg/src/lib.rs | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #![cfg_attr(not(test), no_std)] | 1 | #![cfg_attr(not(test), no_std)] |
| 2 | #![allow(async_fn_in_trait)] | 2 | #![allow(async_fn_in_trait)] |
| 3 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 3 | #![doc = include_str!("../README.md")] | 4 | #![doc = include_str!("../README.md")] |
| 4 | #![warn(missing_docs)] | 5 | #![warn(missing_docs)] |
| 5 | 6 | ||
| @@ -22,7 +23,7 @@ use crate::fmt::Bytes; | |||
| 22 | 23 | ||
| 23 | pub mod otg_v1; | 24 | pub mod otg_v1; |
| 24 | 25 | ||
| 25 | use otg_v1::{regs, vals, Otg}; | 26 | use otg_v1::{Otg, regs, vals}; |
| 26 | 27 | ||
| 27 | /// Handle interrupts. | 28 | /// Handle interrupts. |
| 28 | pub unsafe fn on_interrupt<const MAX_EP_COUNT: usize>(r: Otg, state: &State<MAX_EP_COUNT>, ep_count: usize) { | 29 | pub unsafe fn on_interrupt<const MAX_EP_COUNT: usize>(r: Otg, state: &State<MAX_EP_COUNT>, ep_count: usize) { |
| @@ -679,9 +680,7 @@ impl<'d, const MAX_EP_COUNT: usize> Bus<'d, MAX_EP_COUNT> { | |||
| 679 | if let Some(ep) = self.ep_in[i] { | 680 | if let Some(ep) = self.ep_in[i] { |
| 680 | trace!( | 681 | trace!( |
| 681 | "configuring tx fifo ep={}, offset={}, size={}", | 682 | "configuring tx fifo ep={}, offset={}, size={}", |
| 682 | i, | 683 | i, fifo_top, ep.fifo_size_words |
| 683 | fifo_top, | ||
| 684 | ep.fifo_size_words | ||
| 685 | ); | 684 | ); |
| 686 | 685 | ||
| 687 | let dieptxf = if i == 0 { regs.dieptxf0() } else { regs.dieptxf(i - 1) }; | 686 | let dieptxf = if i == 0 { regs.dieptxf0() } else { regs.dieptxf(i - 1) }; |
| @@ -1158,9 +1157,7 @@ impl<'d> embassy_usb_driver::EndpointIn for Endpoint<'d, In> { | |||
| 1158 | let dtxfsts = self.regs.dtxfsts(index).read(); | 1157 | let dtxfsts = self.regs.dtxfsts(index).read(); |
| 1159 | trace!( | 1158 | trace!( |
| 1160 | "write ep={:?}: diepctl {:08x} ftxfsts {:08x}", | 1159 | "write ep={:?}: diepctl {:08x} ftxfsts {:08x}", |
| 1161 | self.info.addr, | 1160 | self.info.addr, diepctl.0, dtxfsts.0 |
| 1162 | diepctl.0, | ||
| 1163 | dtxfsts.0 | ||
| 1164 | ); | 1161 | ); |
| 1165 | if !diepctl.usbaep() { | 1162 | if !diepctl.usbaep() { |
| 1166 | trace!("write ep={:?} wait for prev: error disabled", self.info.addr); | 1163 | trace!("write ep={:?} wait for prev: error disabled", self.info.addr); |
| @@ -1375,11 +1372,7 @@ fn ep_irq_mask(eps: &[Option<EndpointData>]) -> u16 { | |||
| 1375 | eps.iter().enumerate().fold( | 1372 | eps.iter().enumerate().fold( |
| 1376 | 0, | 1373 | 0, |
| 1377 | |mask, (index, ep)| { | 1374 | |mask, (index, ep)| { |
| 1378 | if ep.is_some() { | 1375 | if ep.is_some() { mask | (1 << index) } else { mask } |
| 1379 | mask | (1 << index) | ||
| 1380 | } else { | ||
| 1381 | mask | ||
| 1382 | } | ||
| 1383 | }, | 1376 | }, |
| 1384 | ) | 1377 | ) |
| 1385 | } | 1378 | } |
diff --git a/embassy-usb/Cargo.toml b/embassy-usb/Cargo.toml index bff48c4a6..aeb7392f1 100644 --- a/embassy-usb/Cargo.toml +++ b/embassy-usb/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-usb" | 2 | name = "embassy-usb" |
| 3 | version = "0.5.1" | 3 | version = "0.5.1" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | description = "Async USB device stack for embedded devices in Rust." | 6 | description = "Async USB device stack for embedded devices in Rust." |
| 7 | keywords = ["embedded", "async", "usb", "hal", "embedded-hal"] | 7 | keywords = ["embedded", "async", "usb", "hal", "embedded-hal"] |
diff --git a/embassy-usb/src/builder.rs b/embassy-usb/src/builder.rs index 8d7abe46c..6fc2a5a22 100644 --- a/embassy-usb/src/builder.rs +++ b/embassy-usb/src/builder.rs | |||
| @@ -5,7 +5,7 @@ use crate::descriptor::{BosWriter, DescriptorWriter, SynchronizationType, UsageT | |||
| 5 | use crate::driver::{Driver, Endpoint, EndpointAddress, EndpointInfo, EndpointType}; | 5 | use crate::driver::{Driver, Endpoint, EndpointAddress, EndpointInfo, EndpointType}; |
| 6 | use crate::msos::{DeviceLevelDescriptor, FunctionLevelDescriptor, MsOsDescriptorWriter}; | 6 | use crate::msos::{DeviceLevelDescriptor, FunctionLevelDescriptor, MsOsDescriptorWriter}; |
| 7 | use crate::types::{InterfaceNumber, StringIndex}; | 7 | use crate::types::{InterfaceNumber, StringIndex}; |
| 8 | use crate::{Handler, Interface, UsbDevice, MAX_INTERFACE_COUNT, STRING_INDEX_CUSTOM_START}; | 8 | use crate::{Handler, Interface, MAX_INTERFACE_COUNT, STRING_INDEX_CUSTOM_START, UsbDevice}; |
| 9 | 9 | ||
| 10 | #[derive(Debug, Copy, Clone)] | 10 | #[derive(Debug, Copy, Clone)] |
| 11 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 11 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| @@ -176,7 +176,9 @@ impl<'d, D: Driver<'d>> Builder<'d, D> { | |||
| 176 | if config.composite_with_iads | 176 | if config.composite_with_iads |
| 177 | && (config.device_class != 0xEF || config.device_sub_class != 0x02 || config.device_protocol != 0x01) | 177 | && (config.device_class != 0xEF || config.device_sub_class != 0x02 || config.device_protocol != 0x01) |
| 178 | { | 178 | { |
| 179 | panic!("if composite_with_iads is set, you must set device_class = 0xEF, device_sub_class = 0x02, device_protocol = 0x01"); | 179 | panic!( |
| 180 | "if composite_with_iads is set, you must set device_class = 0xEF, device_sub_class = 0x02, device_protocol = 0x01" | ||
| 181 | ); | ||
| 180 | } | 182 | } |
| 181 | 183 | ||
| 182 | assert!( | 184 | assert!( |
| @@ -337,7 +339,8 @@ impl<'a, 'd, D: Driver<'d>> FunctionBuilder<'a, 'd, D> { | |||
| 337 | num_alt_settings: 0, | 339 | num_alt_settings: 0, |
| 338 | }; | 340 | }; |
| 339 | 341 | ||
| 340 | assert!(self.builder.interfaces.push(iface).is_ok(), | 342 | assert!( |
| 343 | self.builder.interfaces.push(iface).is_ok(), | ||
| 341 | "embassy-usb: interface list full. Increase the `max_interface_count` compile-time setting. Current value: {}", | 344 | "embassy-usb: interface list full. Increase the `max_interface_count` compile-time setting. Current value: {}", |
| 342 | MAX_INTERFACE_COUNT | 345 | MAX_INTERFACE_COUNT |
| 343 | ); | 346 | ); |
diff --git a/embassy-usb/src/class/cdc_acm.rs b/embassy-usb/src/class/cdc_acm.rs index 0a1a5e64f..388e21fbd 100644 --- a/embassy-usb/src/class/cdc_acm.rs +++ b/embassy-usb/src/class/cdc_acm.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | //! CDC-ACM class implementation, aka Serial over USB. | 1 | //! CDC-ACM class implementation, aka Serial over USB. |
| 2 | 2 | ||
| 3 | use core::cell::{Cell, RefCell}; | 3 | use core::cell::{Cell, RefCell}; |
| 4 | use core::future::{poll_fn, Future}; | 4 | use core::future::{Future, poll_fn}; |
| 5 | use core::mem::{self, MaybeUninit}; | 5 | use core::mem::{self, MaybeUninit}; |
| 6 | use core::sync::atomic::{AtomicBool, Ordering}; | 6 | use core::sync::atomic::{AtomicBool, Ordering}; |
| 7 | use core::task::Poll; | 7 | use core::task::Poll; |
diff --git a/embassy-usb/src/class/cdc_ncm/embassy_net.rs b/embassy-usb/src/class/cdc_ncm/embassy_net.rs index 57d322946..c83ff468a 100644 --- a/embassy-usb/src/class/cdc_ncm/embassy_net.rs +++ b/embassy-usb/src/class/cdc_ncm/embassy_net.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | //! [`embassy-net`](https://crates.io/crates/embassy-net) driver for the CDC-NCM class. | 1 | //! [`embassy-net`](https://crates.io/crates/embassy-net) driver for the CDC-NCM class. |
| 2 | 2 | ||
| 3 | use embassy_futures::select::{select, Either}; | 3 | use embassy_futures::select::{Either, select}; |
| 4 | use embassy_net_driver_channel as ch; | 4 | use embassy_net_driver_channel as ch; |
| 5 | use embassy_net_driver_channel::driver::LinkState; | 5 | use embassy_net_driver_channel::driver::LinkState; |
| 6 | use embassy_usb_driver::Driver; | 6 | use embassy_usb_driver::Driver; |
diff --git a/embassy-usb/src/class/cdc_ncm/mod.rs b/embassy-usb/src/class/cdc_ncm/mod.rs index 3af853091..9b6dd9f21 100644 --- a/embassy-usb/src/class/cdc_ncm/mod.rs +++ b/embassy-usb/src/class/cdc_ncm/mod.rs | |||
| @@ -14,7 +14,7 @@ | |||
| 14 | //! This is due to regex spaghetti: <https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-mainline-12.0.0_r84/core/res/res/values/config.xml#417> | 14 | //! This is due to regex spaghetti: <https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-mainline-12.0.0_r84/core/res/res/values/config.xml#417> |
| 15 | //! and this nonsense in the linux kernel: <https://github.com/torvalds/linux/blob/c00c5e1d157bec0ef0b0b59aa5482eb8dc7e8e49/drivers/net/usb/usbnet.c#L1751-L1757> | 15 | //! and this nonsense in the linux kernel: <https://github.com/torvalds/linux/blob/c00c5e1d157bec0ef0b0b59aa5482eb8dc7e8e49/drivers/net/usb/usbnet.c#L1751-L1757> |
| 16 | 16 | ||
| 17 | use core::mem::{size_of, MaybeUninit}; | 17 | use core::mem::{MaybeUninit, size_of}; |
| 18 | use core::ptr::{addr_of, copy_nonoverlapping}; | 18 | use core::ptr::{addr_of, copy_nonoverlapping}; |
| 19 | 19 | ||
| 20 | use crate::control::{self, InResponse, OutResponse, Recipient, Request, RequestType}; | 20 | use crate::control::{self, InResponse, OutResponse, Recipient, Request, RequestType}; |
diff --git a/embassy-usb/src/class/cmsis_dap_v2.rs b/embassy-usb/src/class/cmsis_dap_v2.rs index a9fd9cdf0..0e2356f17 100644 --- a/embassy-usb/src/class/cmsis_dap_v2.rs +++ b/embassy-usb/src/class/cmsis_dap_v2.rs | |||
| @@ -4,7 +4,7 @@ use core::mem::MaybeUninit; | |||
| 4 | 4 | ||
| 5 | use crate::driver::{Driver, Endpoint, EndpointError, EndpointIn, EndpointOut}; | 5 | use crate::driver::{Driver, Endpoint, EndpointError, EndpointIn, EndpointOut}; |
| 6 | use crate::types::StringIndex; | 6 | use crate::types::StringIndex; |
| 7 | use crate::{msos, Builder, Handler}; | 7 | use crate::{Builder, Handler, msos}; |
| 8 | 8 | ||
| 9 | /// State for the CMSIS-DAP v2 USB class. | 9 | /// State for the CMSIS-DAP v2 USB class. |
| 10 | pub struct State { | 10 | pub struct State { |
diff --git a/embassy-usb/src/class/midi.rs b/embassy-usb/src/class/midi.rs index 1d152ca44..d29172be1 100644 --- a/embassy-usb/src/class/midi.rs +++ b/embassy-usb/src/class/midi.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | //! MIDI class implementation. | 1 | //! MIDI class implementation. |
| 2 | 2 | ||
| 3 | use crate::driver::{Driver, Endpoint, EndpointError, EndpointIn, EndpointOut}; | ||
| 4 | use crate::Builder; | 3 | use crate::Builder; |
| 4 | use crate::driver::{Driver, Endpoint, EndpointError, EndpointIn, EndpointOut}; | ||
| 5 | 5 | ||
| 6 | /// This should be used as `device_class` when building the `UsbDevice`. | 6 | /// This should be used as `device_class` when building the `UsbDevice`. |
| 7 | pub const USB_AUDIO_CLASS: u8 = 0x01; | 7 | pub const USB_AUDIO_CLASS: u8 = 0x01; |
diff --git a/embassy-usb/src/class/uac1/speaker.rs b/embassy-usb/src/class/uac1/speaker.rs index 9565e2a25..46e0420d5 100644 --- a/embassy-usb/src/class/uac1/speaker.rs +++ b/embassy-usb/src/class/uac1/speaker.rs | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | //! The class provides volume and mute controls for each channel. | 11 | //! The class provides volume and mute controls for each channel. |
| 12 | 12 | ||
| 13 | use core::cell::{Cell, RefCell}; | 13 | use core::cell::{Cell, RefCell}; |
| 14 | use core::future::{poll_fn, Future}; | 14 | use core::future::{Future, poll_fn}; |
| 15 | use core::marker::PhantomData; | 15 | use core::marker::PhantomData; |
| 16 | use core::sync::atomic::{AtomicBool, AtomicU32, Ordering}; | 16 | use core::sync::atomic::{AtomicBool, AtomicU32, Ordering}; |
| 17 | use core::task::Poll; | 17 | use core::task::Poll; |
| @@ -22,7 +22,7 @@ use heapless::Vec; | |||
| 22 | 22 | ||
| 23 | use super::class_codes::*; | 23 | use super::class_codes::*; |
| 24 | use super::terminal_type::TerminalType; | 24 | use super::terminal_type::TerminalType; |
| 25 | use super::{Channel, ChannelConfig, FeedbackRefresh, SampleWidth, MAX_AUDIO_CHANNEL_COUNT, MAX_AUDIO_CHANNEL_INDEX}; | 25 | use super::{Channel, ChannelConfig, FeedbackRefresh, MAX_AUDIO_CHANNEL_COUNT, MAX_AUDIO_CHANNEL_INDEX, SampleWidth}; |
| 26 | use crate::control::{self, InResponse, OutResponse, Recipient, Request, RequestType}; | 26 | use crate::control::{self, InResponse, OutResponse, Recipient, Request, RequestType}; |
| 27 | use crate::descriptor::{SynchronizationType, UsageType}; | 27 | use crate::descriptor::{SynchronizationType, UsageType}; |
| 28 | use crate::driver::{Driver, Endpoint, EndpointError, EndpointIn, EndpointOut, EndpointType}; | 28 | use crate::driver::{Driver, Endpoint, EndpointError, EndpointIn, EndpointOut, EndpointType}; |
diff --git a/embassy-usb/src/descriptor.rs b/embassy-usb/src/descriptor.rs index e9a6fd79a..c79dd02eb 100644 --- a/embassy-usb/src/descriptor.rs +++ b/embassy-usb/src/descriptor.rs | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | //! Utilities for writing USB descriptors. | 1 | //! Utilities for writing USB descriptors. |
| 2 | use embassy_usb_driver::EndpointType; | 2 | use embassy_usb_driver::EndpointType; |
| 3 | 3 | ||
| 4 | use crate::CONFIGURATION_VALUE; | ||
| 4 | use crate::builder::Config; | 5 | use crate::builder::Config; |
| 5 | use crate::driver::EndpointInfo; | 6 | use crate::driver::EndpointInfo; |
| 6 | use crate::types::{InterfaceNumber, StringIndex}; | 7 | use crate::types::{InterfaceNumber, StringIndex}; |
| 7 | use crate::CONFIGURATION_VALUE; | ||
| 8 | 8 | ||
| 9 | /// Standard descriptor types | 9 | /// Standard descriptor types |
| 10 | #[allow(missing_docs)] | 10 | #[allow(missing_docs)] |
diff --git a/embassy-usb/src/lib.rs b/embassy-usb/src/lib.rs index 0638fd0a2..0c10c08df 100644 --- a/embassy-usb/src/lib.rs +++ b/embassy-usb/src/lib.rs | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![allow(unsafe_op_in_unsafe_fn)] | ||
| 2 | #![doc = include_str!("../README.md")] | 3 | #![doc = include_str!("../README.md")] |
| 3 | #![warn(missing_docs)] | 4 | #![warn(missing_docs)] |
| 4 | 5 | ||
| @@ -20,7 +21,7 @@ mod config { | |||
| 20 | include!(concat!(env!("OUT_DIR"), "/config.rs")); | 21 | include!(concat!(env!("OUT_DIR"), "/config.rs")); |
| 21 | } | 22 | } |
| 22 | 23 | ||
| 23 | use embassy_futures::select::{select, Either}; | 24 | use embassy_futures::select::{Either, select}; |
| 24 | use heapless::Vec; | 25 | use heapless::Vec; |
| 25 | 26 | ||
| 26 | pub use crate::builder::{Builder, Config, FunctionBuilder, InterfaceAltBuilder, InterfaceBuilder, UsbVersion}; | 27 | pub use crate::builder::{Builder, Config, FunctionBuilder, InterfaceAltBuilder, InterfaceBuilder, UsbVersion}; |
diff --git a/embassy-usb/src/msos.rs b/embassy-usb/src/msos.rs index 9f4e1a57b..66689871e 100644 --- a/embassy-usb/src/msos.rs +++ b/embassy-usb/src/msos.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | use core::mem::size_of; | 5 | use core::mem::size_of; |
| 6 | 6 | ||
| 7 | use crate::descriptor::{capability_type, BosWriter}; | 7 | use crate::descriptor::{BosWriter, capability_type}; |
| 8 | use crate::types::InterfaceNumber; | 8 | use crate::types::InterfaceNumber; |
| 9 | 9 | ||
| 10 | /// A serialized Microsoft OS 2.0 Descriptor set. | 10 | /// A serialized Microsoft OS 2.0 Descriptor set. |
diff --git a/examples/boot/application/nrf/Cargo.toml b/examples/boot/application/nrf/Cargo.toml index b0cc63a6c..55053bc33 100644 --- a/examples/boot/application/nrf/Cargo.toml +++ b/examples/boot/application/nrf/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-boot-nrf-examples" | 3 | name = "embassy-boot-nrf-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| @@ -9,9 +9,9 @@ publish = false | |||
| 9 | embassy-sync = { version = "0.7.2", path = "../../../../embassy-sync" } | 9 | embassy-sync = { version = "0.7.2", path = "../../../../embassy-sync" } |
| 10 | embassy-executor = { version = "0.9.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "arch-cortex-m", "executor-thread"] } | 10 | embassy-executor = { version = "0.9.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "arch-cortex-m", "executor-thread"] } |
| 11 | embassy-time = { version = "0.5.0", path = "../../../../embassy-time", features = [] } | 11 | embassy-time = { version = "0.5.0", path = "../../../../embassy-time", features = [] } |
| 12 | embassy-nrf = { version = "0.7.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", ] } | 12 | embassy-nrf = { version = "0.8.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", ] } |
| 13 | embassy-boot = { version = "0.6.1", path = "../../../../embassy-boot", features = [] } | 13 | embassy-boot = { version = "0.6.1", path = "../../../../embassy-boot", features = [] } |
| 14 | embassy-boot-nrf = { version = "0.8.0", path = "../../../../embassy-boot-nrf", features = [] } | 14 | embassy-boot-nrf = { version = "0.9.0", path = "../../../../embassy-boot-nrf", features = [] } |
| 15 | embassy-embedded-hal = { version = "0.5.0", path = "../../../../embassy-embedded-hal" } | 15 | embassy-embedded-hal = { version = "0.5.0", path = "../../../../embassy-embedded-hal" } |
| 16 | 16 | ||
| 17 | defmt = { version = "1.0.1", optional = true } | 17 | defmt = { version = "1.0.1", optional = true } |
diff --git a/examples/boot/application/rp/Cargo.toml b/examples/boot/application/rp/Cargo.toml index d86386b00..70a2c28c3 100644 --- a/examples/boot/application/rp/Cargo.toml +++ b/examples/boot/application/rp/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-boot-rp-examples" | 3 | name = "embassy-boot-rp-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/boot/application/stm32f3/Cargo.toml b/examples/boot/application/stm32f3/Cargo.toml index cd5f422fc..2dc75d939 100644 --- a/examples/boot/application/stm32f3/Cargo.toml +++ b/examples/boot/application/stm32f3/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-boot-stm32f3-examples" | 3 | name = "embassy-boot-stm32f3-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/boot/application/stm32f7/Cargo.toml b/examples/boot/application/stm32f7/Cargo.toml index c3921a166..5c372fb19 100644 --- a/examples/boot/application/stm32f7/Cargo.toml +++ b/examples/boot/application/stm32f7/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-boot-stm32f7-examples" | 3 | name = "embassy-boot-stm32f7-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/boot/application/stm32h7/Cargo.toml b/examples/boot/application/stm32h7/Cargo.toml index ca186d4d9..641a2ba96 100644 --- a/examples/boot/application/stm32h7/Cargo.toml +++ b/examples/boot/application/stm32h7/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-boot-stm32h7-examples" | 3 | name = "embassy-boot-stm32h7-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/boot/application/stm32l0/Cargo.toml b/examples/boot/application/stm32l0/Cargo.toml index be08956f1..4a168be15 100644 --- a/examples/boot/application/stm32l0/Cargo.toml +++ b/examples/boot/application/stm32l0/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-boot-stm32l0-examples" | 3 | name = "embassy-boot-stm32l0-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/boot/application/stm32l1/Cargo.toml b/examples/boot/application/stm32l1/Cargo.toml index 207eed733..af2cb3881 100644 --- a/examples/boot/application/stm32l1/Cargo.toml +++ b/examples/boot/application/stm32l1/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-boot-stm32l1-examples" | 3 | name = "embassy-boot-stm32l1-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/boot/application/stm32l4/Cargo.toml b/examples/boot/application/stm32l4/Cargo.toml index 22b9642d8..032e934aa 100644 --- a/examples/boot/application/stm32l4/Cargo.toml +++ b/examples/boot/application/stm32l4/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-boot-stm32l4-examples" | 3 | name = "embassy-boot-stm32l4-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/boot/application/stm32wb-dfu/Cargo.toml b/examples/boot/application/stm32wb-dfu/Cargo.toml index e2be4f470..ea4c26681 100644 --- a/examples/boot/application/stm32wb-dfu/Cargo.toml +++ b/examples/boot/application/stm32wb-dfu/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-boot-stm32wb-dfu-examples" | 3 | name = "embassy-boot-stm32wb-dfu-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | 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 5e7b71f5a..1ae28bf3a 100644 --- a/examples/boot/application/stm32wb-dfu/src/main.rs +++ b/examples/boot/application/stm32wb-dfu/src/main.rs | |||
| @@ -13,9 +13,9 @@ use embassy_stm32::usb::{self, Driver}; | |||
| 13 | use embassy_stm32::{bind_interrupts, peripherals}; | 13 | use embassy_stm32::{bind_interrupts, peripherals}; |
| 14 | use embassy_sync::blocking_mutex::Mutex; | 14 | use embassy_sync::blocking_mutex::Mutex; |
| 15 | use embassy_time::Duration; | 15 | use embassy_time::Duration; |
| 16 | use embassy_usb::{msos, Builder}; | 16 | use embassy_usb::{Builder, msos}; |
| 17 | use embassy_usb_dfu::consts::DfuAttributes; | 17 | use embassy_usb_dfu::consts::DfuAttributes; |
| 18 | use embassy_usb_dfu::{usb_dfu, Control, ResetImmediate}; | 18 | use embassy_usb_dfu::{Control, ResetImmediate, usb_dfu}; |
| 19 | use panic_reset as _; | 19 | use panic_reset as _; |
| 20 | 20 | ||
| 21 | bind_interrupts!(struct Irqs { | 21 | bind_interrupts!(struct Irqs { |
diff --git a/examples/boot/application/stm32wba-dfu/Cargo.toml b/examples/boot/application/stm32wba-dfu/Cargo.toml index 6f4213b2c..d6f7dc3b6 100644 --- a/examples/boot/application/stm32wba-dfu/Cargo.toml +++ b/examples/boot/application/stm32wba-dfu/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-boot-stm32wba-dfu-examples" | 3 | name = "embassy-boot-stm32wba-dfu-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/boot/application/stm32wba-dfu/src/main.rs b/examples/boot/application/stm32wba-dfu/src/main.rs index bf17a7150..8adb2e7c0 100644 --- a/examples/boot/application/stm32wba-dfu/src/main.rs +++ b/examples/boot/application/stm32wba-dfu/src/main.rs | |||
| @@ -12,9 +12,9 @@ use embassy_stm32::usb::{self, Driver}; | |||
| 12 | use embassy_stm32::{bind_interrupts, peripherals}; | 12 | use embassy_stm32::{bind_interrupts, peripherals}; |
| 13 | use embassy_sync::blocking_mutex::Mutex; | 13 | use embassy_sync::blocking_mutex::Mutex; |
| 14 | use embassy_time::Duration; | 14 | use embassy_time::Duration; |
| 15 | use embassy_usb::{msos, Builder}; | 15 | use embassy_usb::{Builder, msos}; |
| 16 | use embassy_usb_dfu::consts::DfuAttributes; | 16 | use embassy_usb_dfu::consts::DfuAttributes; |
| 17 | use embassy_usb_dfu::{usb_dfu, Control, ResetImmediate}; | 17 | use embassy_usb_dfu::{Control, ResetImmediate, usb_dfu}; |
| 18 | use panic_reset as _; | 18 | use panic_reset as _; |
| 19 | 19 | ||
| 20 | bind_interrupts!(struct Irqs { | 20 | bind_interrupts!(struct Irqs { |
diff --git a/examples/boot/application/stm32wl/Cargo.toml b/examples/boot/application/stm32wl/Cargo.toml index 8d1446ba9..c7fa811c9 100644 --- a/examples/boot/application/stm32wl/Cargo.toml +++ b/examples/boot/application/stm32wl/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-boot-stm32wl-examples" | 3 | name = "embassy-boot-stm32wl-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/boot/application/stm32wl/src/bin/a.rs b/examples/boot/application/stm32wl/src/bin/a.rs index e4526927f..3f381fd80 100644 --- a/examples/boot/application/stm32wl/src/bin/a.rs +++ b/examples/boot/application/stm32wl/src/bin/a.rs | |||
| @@ -8,10 +8,10 @@ use defmt_rtt::*; | |||
| 8 | use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig}; | 8 | use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig}; |
| 9 | use embassy_embedded_hal::adapter::BlockingAsync; | 9 | use embassy_embedded_hal::adapter::BlockingAsync; |
| 10 | use embassy_executor::Spawner; | 10 | use embassy_executor::Spawner; |
| 11 | use embassy_stm32::SharedData; | ||
| 11 | use embassy_stm32::exti::ExtiInput; | 12 | use embassy_stm32::exti::ExtiInput; |
| 12 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; | 13 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; |
| 13 | use embassy_stm32::gpio::{Level, Output, Pull, Speed}; | 14 | use embassy_stm32::gpio::{Level, Output, Pull, Speed}; |
| 14 | use embassy_stm32::SharedData; | ||
| 15 | use embassy_sync::mutex::Mutex; | 15 | use embassy_sync::mutex::Mutex; |
| 16 | use panic_reset as _; | 16 | use panic_reset as _; |
| 17 | 17 | ||
diff --git a/examples/boot/application/stm32wl/src/bin/b.rs b/examples/boot/application/stm32wl/src/bin/b.rs index 6016a9555..952e94a58 100644 --- a/examples/boot/application/stm32wl/src/bin/b.rs +++ b/examples/boot/application/stm32wl/src/bin/b.rs | |||
| @@ -6,8 +6,8 @@ use core::mem::MaybeUninit; | |||
| 6 | #[cfg(feature = "defmt")] | 6 | #[cfg(feature = "defmt")] |
| 7 | use defmt_rtt::*; | 7 | use defmt_rtt::*; |
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | ||
| 10 | use embassy_stm32::SharedData; | 9 | use embassy_stm32::SharedData; |
| 10 | use embassy_stm32::gpio::{Level, Output, Speed}; | ||
| 11 | use embassy_time::Timer; | 11 | use embassy_time::Timer; |
| 12 | use panic_reset as _; | 12 | use panic_reset as _; |
| 13 | 13 | ||
diff --git a/examples/boot/bootloader/nrf/Cargo.toml b/examples/boot/bootloader/nrf/Cargo.toml index 72b7114d4..1fea2b7d7 100644 --- a/examples/boot/bootloader/nrf/Cargo.toml +++ b/examples/boot/bootloader/nrf/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "nrf-bootloader-example" | 3 | name = "nrf-bootloader-example" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | description = "Bootloader for nRF chips" | 5 | description = "Bootloader for nRF chips" |
diff --git a/examples/boot/bootloader/nrf/src/main.rs b/examples/boot/bootloader/nrf/src/main.rs index b849a0df3..76c4c1048 100644 --- a/examples/boot/bootloader/nrf/src/main.rs +++ b/examples/boot/bootloader/nrf/src/main.rs | |||
| @@ -38,8 +38,8 @@ fn main() -> ! { | |||
| 38 | unsafe { bl.load(active_offset) } | 38 | unsafe { bl.load(active_offset) } |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | #[no_mangle] | 41 | #[unsafe(no_mangle)] |
| 42 | #[cfg_attr(target_os = "none", link_section = ".HardFault.user")] | 42 | #[cfg_attr(target_os = "none", unsafe(link_section = ".HardFault.user"))] |
| 43 | unsafe extern "C" fn HardFault() { | 43 | unsafe extern "C" fn HardFault() { |
| 44 | cortex_m::peripheral::SCB::sys_reset(); | 44 | cortex_m::peripheral::SCB::sys_reset(); |
| 45 | } | 45 | } |
| @@ -47,7 +47,7 @@ unsafe extern "C" fn HardFault() { | |||
| 47 | #[exception] | 47 | #[exception] |
| 48 | unsafe fn DefaultHandler(_: i16) -> ! { | 48 | unsafe fn DefaultHandler(_: i16) -> ! { |
| 49 | const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32; | 49 | const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32; |
| 50 | let irqn = core::ptr::read_volatile(SCB_ICSR) as u8 as i16 - 16; | 50 | let irqn = unsafe { core::ptr::read_volatile(SCB_ICSR) } as u8 as i16 - 16; |
| 51 | 51 | ||
| 52 | panic!("DefaultHandler #{:?}", irqn); | 52 | panic!("DefaultHandler #{:?}", irqn); |
| 53 | } | 53 | } |
diff --git a/examples/boot/bootloader/rp/Cargo.toml b/examples/boot/bootloader/rp/Cargo.toml index 93a1c4edf..188bcab36 100644 --- a/examples/boot/bootloader/rp/Cargo.toml +++ b/examples/boot/bootloader/rp/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "rp-bootloader-example" | 3 | name = "rp-bootloader-example" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | description = "Example bootloader for RP2040 chips" | 5 | description = "Example bootloader for RP2040 chips" |
diff --git a/examples/boot/bootloader/rp/src/main.rs b/examples/boot/bootloader/rp/src/main.rs index 25b1657b8..7ebefd374 100644 --- a/examples/boot/bootloader/rp/src/main.rs +++ b/examples/boot/bootloader/rp/src/main.rs | |||
| @@ -34,8 +34,8 @@ fn main() -> ! { | |||
| 34 | unsafe { bl.load(embassy_rp::flash::FLASH_BASE as u32 + active_offset) } | 34 | unsafe { bl.load(embassy_rp::flash::FLASH_BASE as u32 + active_offset) } |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | #[no_mangle] | 37 | #[unsafe(no_mangle)] |
| 38 | #[cfg_attr(target_os = "none", link_section = ".HardFault.user")] | 38 | #[cfg_attr(target_os = "none", unsafe(link_section = ".HardFault.user"))] |
| 39 | unsafe extern "C" fn HardFault() { | 39 | unsafe extern "C" fn HardFault() { |
| 40 | cortex_m::peripheral::SCB::sys_reset(); | 40 | cortex_m::peripheral::SCB::sys_reset(); |
| 41 | } | 41 | } |
| @@ -43,7 +43,7 @@ unsafe extern "C" fn HardFault() { | |||
| 43 | #[exception] | 43 | #[exception] |
| 44 | unsafe fn DefaultHandler(_: i16) -> ! { | 44 | unsafe fn DefaultHandler(_: i16) -> ! { |
| 45 | const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32; | 45 | const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32; |
| 46 | let irqn = core::ptr::read_volatile(SCB_ICSR) as u8 as i16 - 16; | 46 | let irqn = unsafe { core::ptr::read_volatile(SCB_ICSR) } as u8 as i16 - 16; |
| 47 | 47 | ||
| 48 | panic!("DefaultHandler #{:?}", irqn); | 48 | panic!("DefaultHandler #{:?}", irqn); |
| 49 | } | 49 | } |
diff --git a/examples/boot/bootloader/stm32-dual-bank/Cargo.toml b/examples/boot/bootloader/stm32-dual-bank/Cargo.toml index 95ca20a59..cf68921dc 100644 --- a/examples/boot/bootloader/stm32-dual-bank/Cargo.toml +++ b/examples/boot/bootloader/stm32-dual-bank/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "stm32-bootloader-dual-bank-flash-example" | 3 | name = "stm32-bootloader-dual-bank-flash-example" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | description = "Example bootloader for dual-bank flash STM32 chips" | 5 | description = "Example bootloader for dual-bank flash STM32 chips" |
diff --git a/examples/boot/bootloader/stm32-dual-bank/src/main.rs b/examples/boot/bootloader/stm32-dual-bank/src/main.rs index 4d2e82d26..f0063fb5c 100644 --- a/examples/boot/bootloader/stm32-dual-bank/src/main.rs +++ b/examples/boot/bootloader/stm32-dual-bank/src/main.rs | |||
| @@ -7,7 +7,7 @@ use cortex_m_rt::{entry, exception}; | |||
| 7 | #[cfg(feature = "defmt")] | 7 | #[cfg(feature = "defmt")] |
| 8 | use defmt_rtt as _; | 8 | use defmt_rtt as _; |
| 9 | use embassy_boot_stm32::*; | 9 | use embassy_boot_stm32::*; |
| 10 | use embassy_stm32::flash::{Flash, BANK1_REGION}; | 10 | use embassy_stm32::flash::{BANK1_REGION, Flash}; |
| 11 | use embassy_sync::blocking_mutex::Mutex; | 11 | use embassy_sync::blocking_mutex::Mutex; |
| 12 | 12 | ||
| 13 | #[entry] | 13 | #[entry] |
| @@ -33,8 +33,8 @@ fn main() -> ! { | |||
| 33 | unsafe { bl.load(BANK1_REGION.base + active_offset) } | 33 | unsafe { bl.load(BANK1_REGION.base + active_offset) } |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | #[no_mangle] | 36 | #[unsafe(no_mangle)] |
| 37 | #[cfg_attr(target_os = "none", link_section = ".HardFault.user")] | 37 | #[cfg_attr(target_os = "none", unsafe(link_section = ".HardFault.user"))] |
| 38 | unsafe extern "C" fn HardFault() { | 38 | unsafe extern "C" fn HardFault() { |
| 39 | cortex_m::peripheral::SCB::sys_reset(); | 39 | cortex_m::peripheral::SCB::sys_reset(); |
| 40 | } | 40 | } |
| @@ -42,7 +42,7 @@ unsafe extern "C" fn HardFault() { | |||
| 42 | #[exception] | 42 | #[exception] |
| 43 | unsafe fn DefaultHandler(_: i16) -> ! { | 43 | unsafe fn DefaultHandler(_: i16) -> ! { |
| 44 | const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32; | 44 | const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32; |
| 45 | let irqn = core::ptr::read_volatile(SCB_ICSR) as u8 as i16 - 16; | 45 | let irqn = unsafe { core::ptr::read_volatile(SCB_ICSR) } as u8 as i16 - 16; |
| 46 | 46 | ||
| 47 | panic!("DefaultHandler #{:?}", irqn); | 47 | panic!("DefaultHandler #{:?}", irqn); |
| 48 | } | 48 | } |
diff --git a/examples/boot/bootloader/stm32/Cargo.toml b/examples/boot/bootloader/stm32/Cargo.toml index 526637f37..e457310b9 100644 --- a/examples/boot/bootloader/stm32/Cargo.toml +++ b/examples/boot/bootloader/stm32/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "stm32-bootloader-example" | 3 | name = "stm32-bootloader-example" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | description = "Example bootloader for STM32 chips" | 5 | description = "Example bootloader for STM32 chips" |
diff --git a/examples/boot/bootloader/stm32/src/main.rs b/examples/boot/bootloader/stm32/src/main.rs index 99a7a6a6b..383ad912d 100644 --- a/examples/boot/bootloader/stm32/src/main.rs +++ b/examples/boot/bootloader/stm32/src/main.rs | |||
| @@ -7,7 +7,7 @@ use cortex_m_rt::{entry, exception}; | |||
| 7 | #[cfg(feature = "defmt")] | 7 | #[cfg(feature = "defmt")] |
| 8 | use defmt_rtt as _; | 8 | use defmt_rtt as _; |
| 9 | use embassy_boot_stm32::*; | 9 | use embassy_boot_stm32::*; |
| 10 | use embassy_stm32::flash::{Flash, BANK1_REGION}; | 10 | use embassy_stm32::flash::{BANK1_REGION, Flash}; |
| 11 | use embassy_sync::blocking_mutex::Mutex; | 11 | use embassy_sync::blocking_mutex::Mutex; |
| 12 | 12 | ||
| 13 | #[entry] | 13 | #[entry] |
| @@ -32,8 +32,8 @@ fn main() -> ! { | |||
| 32 | unsafe { bl.load(BANK1_REGION.base + active_offset) } | 32 | unsafe { bl.load(BANK1_REGION.base + active_offset) } |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | #[no_mangle] | 35 | #[unsafe(no_mangle)] |
| 36 | #[cfg_attr(target_os = "none", link_section = ".HardFault.user")] | 36 | #[cfg_attr(target_os = "none", unsafe(link_section = ".HardFault.user"))] |
| 37 | unsafe extern "C" fn HardFault() { | 37 | unsafe extern "C" fn HardFault() { |
| 38 | cortex_m::peripheral::SCB::sys_reset(); | 38 | cortex_m::peripheral::SCB::sys_reset(); |
| 39 | } | 39 | } |
| @@ -41,7 +41,7 @@ unsafe extern "C" fn HardFault() { | |||
| 41 | #[exception] | 41 | #[exception] |
| 42 | unsafe fn DefaultHandler(_: i16) -> ! { | 42 | unsafe fn DefaultHandler(_: i16) -> ! { |
| 43 | const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32; | 43 | const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32; |
| 44 | let irqn = core::ptr::read_volatile(SCB_ICSR) as u8 as i16 - 16; | 44 | let irqn = unsafe { core::ptr::read_volatile(SCB_ICSR) } as u8 as i16 - 16; |
| 45 | 45 | ||
| 46 | panic!("DefaultHandler #{:?}", irqn); | 46 | panic!("DefaultHandler #{:?}", irqn); |
| 47 | } | 47 | } |
diff --git a/examples/boot/bootloader/stm32wb-dfu/Cargo.toml b/examples/boot/bootloader/stm32wb-dfu/Cargo.toml index ef10aeabf..75b7081df 100644 --- a/examples/boot/bootloader/stm32wb-dfu/Cargo.toml +++ b/examples/boot/bootloader/stm32wb-dfu/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "stm32wb-dfu-bootloader-example" | 3 | name = "stm32wb-dfu-bootloader-example" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | description = "Example USB DFUbootloader for the STM32WB series of chips" | 5 | description = "Example USB DFUbootloader for the STM32WB series of chips" |
diff --git a/examples/boot/bootloader/stm32wb-dfu/src/main.rs b/examples/boot/bootloader/stm32wb-dfu/src/main.rs index 107f243fd..9ee82846d 100644 --- a/examples/boot/bootloader/stm32wb-dfu/src/main.rs +++ b/examples/boot/bootloader/stm32wb-dfu/src/main.rs | |||
| @@ -7,14 +7,14 @@ use cortex_m_rt::{entry, exception}; | |||
| 7 | #[cfg(feature = "defmt")] | 7 | #[cfg(feature = "defmt")] |
| 8 | use defmt_rtt as _; | 8 | use defmt_rtt as _; |
| 9 | use embassy_boot_stm32::*; | 9 | use embassy_boot_stm32::*; |
| 10 | use embassy_stm32::flash::{Flash, BANK1_REGION, WRITE_SIZE}; | 10 | use embassy_stm32::flash::{BANK1_REGION, Flash, WRITE_SIZE}; |
| 11 | use embassy_stm32::rcc::WPAN_DEFAULT; | 11 | use embassy_stm32::rcc::WPAN_DEFAULT; |
| 12 | use embassy_stm32::usb::Driver; | 12 | use embassy_stm32::usb::Driver; |
| 13 | use embassy_stm32::{bind_interrupts, peripherals, usb}; | 13 | use embassy_stm32::{bind_interrupts, peripherals, usb}; |
| 14 | use embassy_sync::blocking_mutex::Mutex; | 14 | use embassy_sync::blocking_mutex::Mutex; |
| 15 | use embassy_usb::{msos, Builder}; | 15 | use embassy_usb::{Builder, msos}; |
| 16 | use embassy_usb_dfu::consts::DfuAttributes; | 16 | use embassy_usb_dfu::consts::DfuAttributes; |
| 17 | use embassy_usb_dfu::{usb_dfu, Control, ResetImmediate}; | 17 | use embassy_usb_dfu::{Control, ResetImmediate, usb_dfu}; |
| 18 | 18 | ||
| 19 | bind_interrupts!(struct Irqs { | 19 | bind_interrupts!(struct Irqs { |
| 20 | USB_LP => usb::InterruptHandler<peripherals::USB>; | 20 | USB_LP => usb::InterruptHandler<peripherals::USB>; |
| @@ -109,8 +109,8 @@ fn main() -> ! { | |||
| 109 | unsafe { bl.load(BANK1_REGION.base + active_offset) } | 109 | unsafe { bl.load(BANK1_REGION.base + active_offset) } |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | #[no_mangle] | 112 | #[unsafe(no_mangle)] |
| 113 | #[cfg_attr(target_os = "none", link_section = ".HardFault.user")] | 113 | #[cfg_attr(target_os = "none", unsafe(link_section = ".HardFault.user"))] |
| 114 | unsafe extern "C" fn HardFault() { | 114 | unsafe extern "C" fn HardFault() { |
| 115 | cortex_m::peripheral::SCB::sys_reset(); | 115 | cortex_m::peripheral::SCB::sys_reset(); |
| 116 | } | 116 | } |
| @@ -118,7 +118,7 @@ unsafe extern "C" fn HardFault() { | |||
| 118 | #[exception] | 118 | #[exception] |
| 119 | unsafe fn DefaultHandler(_: i16) -> ! { | 119 | unsafe fn DefaultHandler(_: i16) -> ! { |
| 120 | const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32; | 120 | const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32; |
| 121 | let irqn = core::ptr::read_volatile(SCB_ICSR) as u8 as i16 - 16; | 121 | let irqn = unsafe { core::ptr::read_volatile(SCB_ICSR) } as u8 as i16 - 16; |
| 122 | 122 | ||
| 123 | panic!("DefaultHandler #{:?}", irqn); | 123 | panic!("DefaultHandler #{:?}", irqn); |
| 124 | } | 124 | } |
diff --git a/examples/boot/bootloader/stm32wba-dfu/Cargo.toml b/examples/boot/bootloader/stm32wba-dfu/Cargo.toml index 16de7684e..eee2b2f71 100644 --- a/examples/boot/bootloader/stm32wba-dfu/Cargo.toml +++ b/examples/boot/bootloader/stm32wba-dfu/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "stm32wba6-dfu-bootloader-example" | 3 | name = "stm32wba6-dfu-bootloader-example" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | description = "Example USB DFUbootloader for the STM32WBA series of chips" | 5 | description = "Example USB DFUbootloader for the STM32WBA series of chips" |
diff --git a/examples/boot/bootloader/stm32wba-dfu/src/main.rs b/examples/boot/bootloader/stm32wba-dfu/src/main.rs index 75d8d4199..b33a75d95 100644 --- a/examples/boot/bootloader/stm32wba-dfu/src/main.rs +++ b/examples/boot/bootloader/stm32wba-dfu/src/main.rs | |||
| @@ -7,13 +7,13 @@ use cortex_m_rt::{entry, exception}; | |||
| 7 | #[cfg(feature = "defmt")] | 7 | #[cfg(feature = "defmt")] |
| 8 | use defmt_rtt as _; | 8 | use defmt_rtt as _; |
| 9 | use embassy_boot_stm32::*; | 9 | use embassy_boot_stm32::*; |
| 10 | use embassy_stm32::flash::{Flash, BANK1_REGION, WRITE_SIZE}; | 10 | use embassy_stm32::flash::{BANK1_REGION, Flash, WRITE_SIZE}; |
| 11 | use embassy_stm32::usb::Driver; | 11 | use embassy_stm32::usb::Driver; |
| 12 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 12 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 13 | use embassy_sync::blocking_mutex::Mutex; | 13 | use embassy_sync::blocking_mutex::Mutex; |
| 14 | use embassy_usb::{msos, Builder}; | 14 | use embassy_usb::{Builder, msos}; |
| 15 | use embassy_usb_dfu::consts::DfuAttributes; | 15 | use embassy_usb_dfu::consts::DfuAttributes; |
| 16 | use embassy_usb_dfu::{usb_dfu, Control, ResetImmediate}; | 16 | use embassy_usb_dfu::{Control, ResetImmediate, usb_dfu}; |
| 17 | 17 | ||
| 18 | bind_interrupts!(struct Irqs { | 18 | bind_interrupts!(struct Irqs { |
| 19 | USB_OTG_HS => usb::InterruptHandler<peripherals::USB_OTG_HS>; | 19 | USB_OTG_HS => usb::InterruptHandler<peripherals::USB_OTG_HS>; |
| @@ -138,8 +138,8 @@ fn main() -> ! { | |||
| 138 | unsafe { bl.load(BANK1_REGION.base + active_offset) } | 138 | unsafe { bl.load(BANK1_REGION.base + active_offset) } |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | #[no_mangle] | 141 | #[unsafe(no_mangle)] |
| 142 | #[cfg_attr(target_os = "none", link_section = ".HardFault.user")] | 142 | #[cfg_attr(target_os = "none", unsafe(link_section = ".HardFault.user"))] |
| 143 | unsafe extern "C" fn HardFault() { | 143 | unsafe extern "C" fn HardFault() { |
| 144 | cortex_m::peripheral::SCB::sys_reset(); | 144 | cortex_m::peripheral::SCB::sys_reset(); |
| 145 | } | 145 | } |
| @@ -147,7 +147,7 @@ unsafe extern "C" fn HardFault() { | |||
| 147 | #[exception] | 147 | #[exception] |
| 148 | unsafe fn DefaultHandler(_: i16) -> ! { | 148 | unsafe fn DefaultHandler(_: i16) -> ! { |
| 149 | const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32; | 149 | const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32; |
| 150 | let irqn = core::ptr::read_volatile(SCB_ICSR) as u8 as i16 - 16; | 150 | let irqn = unsafe { core::ptr::read_volatile(SCB_ICSR) } as u8 as i16 - 16; |
| 151 | 151 | ||
| 152 | panic!("DefaultHandler #{:?}", irqn); | 152 | panic!("DefaultHandler #{:?}", irqn); |
| 153 | } | 153 | } |
diff --git a/examples/lpc55s69/Cargo.toml b/examples/lpc55s69/Cargo.toml index 579748595..94903b3f8 100644 --- a/examples/lpc55s69/Cargo.toml +++ b/examples/lpc55s69/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-nxp-lpc55s69-examples" | 3 | name = "embassy-nxp-lpc55s69-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/mimxrt1011/Cargo.toml b/examples/mimxrt1011/Cargo.toml index 3038f5d4d..d784ce729 100644 --- a/examples/mimxrt1011/Cargo.toml +++ b/examples/mimxrt1011/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-imxrt1011-examples" | 2 | name = "embassy-imxrt1011-examples" |
| 3 | version = "0.1.0" | 3 | version = "0.1.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | publish = false | 6 | publish = false |
| 7 | 7 | ||
diff --git a/examples/mimxrt1011/src/lib.rs b/examples/mimxrt1011/src/lib.rs index f0391ef57..36d3e2fb3 100644 --- a/examples/mimxrt1011/src/lib.rs +++ b/examples/mimxrt1011/src/lib.rs | |||
| @@ -71,5 +71,5 @@ pub const SERIAL_NOR_CONFIGURATION_BLOCK: nor::ConfigurationBlock = | |||
| 71 | .ip_cmd_serial_clk_freq(nor::SerialClockFrequency::MHz30); | 71 | .ip_cmd_serial_clk_freq(nor::SerialClockFrequency::MHz30); |
| 72 | 72 | ||
| 73 | #[unsafe(no_mangle)] | 73 | #[unsafe(no_mangle)] |
| 74 | #[cfg_attr(all(target_arch = "arm", target_os = "none"), link_section = ".fcb")] | 74 | #[cfg_attr(all(target_arch = "arm", target_os = "none"), unsafe(link_section = ".fcb"))] |
| 75 | pub static FLEXSPI_CONFIGURATION_BLOCK: nor::ConfigurationBlock = SERIAL_NOR_CONFIGURATION_BLOCK; | 75 | pub static FLEXSPI_CONFIGURATION_BLOCK: nor::ConfigurationBlock = SERIAL_NOR_CONFIGURATION_BLOCK; |
diff --git a/examples/mimxrt1062-evk/Cargo.toml b/examples/mimxrt1062-evk/Cargo.toml index 82a24490d..29a80db12 100644 --- a/examples/mimxrt1062-evk/Cargo.toml +++ b/examples/mimxrt1062-evk/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-imxrt1062-evk-examples" | 2 | name = "embassy-imxrt1062-evk-examples" |
| 3 | version = "0.1.0" | 3 | version = "0.1.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | publish = false | 6 | publish = false |
| 7 | 7 | ||
diff --git a/examples/mimxrt1062-evk/src/lib.rs b/examples/mimxrt1062-evk/src/lib.rs index 3f99f9db3..e952b91ec 100644 --- a/examples/mimxrt1062-evk/src/lib.rs +++ b/examples/mimxrt1062-evk/src/lib.rs | |||
| @@ -55,6 +55,6 @@ pub const SERIAL_NOR_CONFIGURATION_BLOCK: nor::ConfigurationBlock = | |||
| 55 | .sector_size(4096) | 55 | .sector_size(4096) |
| 56 | .ip_cmd_serial_clk_freq(nor::SerialClockFrequency::MHz30); | 56 | .ip_cmd_serial_clk_freq(nor::SerialClockFrequency::MHz30); |
| 57 | 57 | ||
| 58 | #[no_mangle] | 58 | #[unsafe(no_mangle)] |
| 59 | #[cfg_attr(all(target_arch = "arm", target_os = "none"), link_section = ".fcb")] | 59 | #[cfg_attr(all(target_arch = "arm", target_os = "none"), unsafe(link_section = ".fcb"))] |
| 60 | pub static FLEXSPI_CONFIGURATION_BLOCK: nor::ConfigurationBlock = SERIAL_NOR_CONFIGURATION_BLOCK; | 60 | pub static FLEXSPI_CONFIGURATION_BLOCK: nor::ConfigurationBlock = SERIAL_NOR_CONFIGURATION_BLOCK; |
diff --git a/examples/mimxrt6/Cargo.toml b/examples/mimxrt6/Cargo.toml index 3f7ad8485..dc09e97e7 100644 --- a/examples/mimxrt6/Cargo.toml +++ b/examples/mimxrt6/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-imxrt-examples" | 2 | name = "embassy-imxrt-examples" |
| 3 | version = "0.1.0" | 3 | version = "0.1.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | publish = false | 6 | publish = false |
| 7 | 7 | ||
diff --git a/examples/mimxrt6/src/bin/button.rs b/examples/mimxrt6/src/bin/button.rs index efb7f14af..a9bdde98e 100644 --- a/examples/mimxrt6/src/bin/button.rs +++ b/examples/mimxrt6/src/bin/button.rs | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::info; | 4 | use defmt::info; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_futures::select::{select, Either}; | 6 | use embassy_futures::select::{Either, select}; |
| 7 | use embassy_imxrt::gpio; | 7 | use embassy_imxrt::gpio; |
| 8 | use {defmt_rtt as _, embassy_imxrt_examples as _, panic_probe as _}; | 8 | use {defmt_rtt as _, embassy_imxrt_examples as _, panic_probe as _}; |
| 9 | 9 | ||
diff --git a/examples/mspm0c1104/Cargo.toml b/examples/mspm0c1104/Cargo.toml index 21434106a..74301bc9c 100644 --- a/examples/mspm0c1104/Cargo.toml +++ b/examples/mspm0c1104/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-mspm0-c1104-examples" | 3 | name = "embassy-mspm0-c1104-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/mspm0c1104/src/bin/blinky.rs b/examples/mspm0c1104/src/bin/blinky.rs index 0d974cc5e..345077b37 100644 --- a/examples/mspm0c1104/src/bin/blinky.rs +++ b/examples/mspm0c1104/src/bin/blinky.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_mspm0::gpio::{Level, Output}; | ||
| 7 | use embassy_mspm0::Config; | 6 | use embassy_mspm0::Config; |
| 7 | use embassy_mspm0::gpio::{Level, Output}; | ||
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_halt as _}; | 9 | use {defmt_rtt as _, panic_halt as _}; |
| 10 | 10 | ||
diff --git a/examples/mspm0c1104/src/bin/button.rs b/examples/mspm0c1104/src/bin/button.rs index 7face1618..557d997cd 100644 --- a/examples/mspm0c1104/src/bin/button.rs +++ b/examples/mspm0c1104/src/bin/button.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_mspm0::gpio::{Input, Level, Output, Pull}; | ||
| 7 | use embassy_mspm0::Config; | 6 | use embassy_mspm0::Config; |
| 7 | use embassy_mspm0::gpio::{Input, Level, Output, Pull}; | ||
| 8 | use {defmt_rtt as _, panic_halt as _}; | 8 | use {defmt_rtt as _, panic_halt as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
diff --git a/examples/mspm0g3507/Cargo.toml b/examples/mspm0g3507/Cargo.toml index 616b82adb..8c230f038 100644 --- a/examples/mspm0g3507/Cargo.toml +++ b/examples/mspm0g3507/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-mspm0-g3507-examples" | 3 | name = "embassy-mspm0-g3507-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/mspm0g3507/src/bin/adc.rs b/examples/mspm0g3507/src/bin/adc.rs index ceccc7c02..cf1abb471 100644 --- a/examples/mspm0g3507/src/bin/adc.rs +++ b/examples/mspm0g3507/src/bin/adc.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_mspm0::adc::{self, Adc, Vrsel}; | 6 | use embassy_mspm0::adc::{self, Adc, Vrsel}; |
| 7 | use embassy_mspm0::{bind_interrupts, peripherals, Config}; | 7 | use embassy_mspm0::{Config, bind_interrupts, peripherals}; |
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_halt as _}; | 9 | use {defmt_rtt as _, panic_halt as _}; |
| 10 | 10 | ||
diff --git a/examples/mspm0g3507/src/bin/blinky.rs b/examples/mspm0g3507/src/bin/blinky.rs index 055a5cd81..47eaf1535 100644 --- a/examples/mspm0g3507/src/bin/blinky.rs +++ b/examples/mspm0g3507/src/bin/blinky.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_mspm0::gpio::{Level, Output}; | ||
| 7 | use embassy_mspm0::Config; | 6 | use embassy_mspm0::Config; |
| 7 | use embassy_mspm0::gpio::{Level, Output}; | ||
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_halt as _}; | 9 | use {defmt_rtt as _, panic_halt as _}; |
| 10 | 10 | ||
diff --git a/examples/mspm0g3507/src/bin/button.rs b/examples/mspm0g3507/src/bin/button.rs index cde1f2892..76f3a1aba 100644 --- a/examples/mspm0g3507/src/bin/button.rs +++ b/examples/mspm0g3507/src/bin/button.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_mspm0::gpio::{Input, Level, Output, Pull}; | ||
| 7 | use embassy_mspm0::Config; | 6 | use embassy_mspm0::Config; |
| 7 | use embassy_mspm0::gpio::{Input, Level, Output, Pull}; | ||
| 8 | use {defmt_rtt as _, panic_halt as _}; | 8 | use {defmt_rtt as _, panic_halt as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
diff --git a/examples/mspm0g3519/Cargo.toml b/examples/mspm0g3519/Cargo.toml index ae699d6f4..0f5e58343 100644 --- a/examples/mspm0g3519/Cargo.toml +++ b/examples/mspm0g3519/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-mspm0-g3519-examples" | 3 | name = "embassy-mspm0-g3519-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/mspm0g3519/src/bin/blinky.rs b/examples/mspm0g3519/src/bin/blinky.rs index 055a5cd81..47eaf1535 100644 --- a/examples/mspm0g3519/src/bin/blinky.rs +++ b/examples/mspm0g3519/src/bin/blinky.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_mspm0::gpio::{Level, Output}; | ||
| 7 | use embassy_mspm0::Config; | 6 | use embassy_mspm0::Config; |
| 7 | use embassy_mspm0::gpio::{Level, Output}; | ||
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_halt as _}; | 9 | use {defmt_rtt as _, panic_halt as _}; |
| 10 | 10 | ||
diff --git a/examples/mspm0g3519/src/bin/button.rs b/examples/mspm0g3519/src/bin/button.rs index c81cc2918..21e7873d8 100644 --- a/examples/mspm0g3519/src/bin/button.rs +++ b/examples/mspm0g3519/src/bin/button.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_mspm0::gpio::{Input, Level, Output, Pull}; | ||
| 7 | use embassy_mspm0::Config; | 6 | use embassy_mspm0::Config; |
| 7 | use embassy_mspm0::gpio::{Input, Level, Output, Pull}; | ||
| 8 | use {defmt_rtt as _, panic_halt as _}; | 8 | use {defmt_rtt as _, panic_halt as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
diff --git a/examples/mspm0l1306/Cargo.toml b/examples/mspm0l1306/Cargo.toml index 8100e11da..d5b5e9d3e 100644 --- a/examples/mspm0l1306/Cargo.toml +++ b/examples/mspm0l1306/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-mspm0-l1306-examples" | 3 | name = "embassy-mspm0-l1306-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/mspm0l1306/src/bin/adc.rs b/examples/mspm0l1306/src/bin/adc.rs index 2806b98cc..235396b8a 100644 --- a/examples/mspm0l1306/src/bin/adc.rs +++ b/examples/mspm0l1306/src/bin/adc.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_mspm0::adc::{self, Adc, Vrsel}; | 6 | use embassy_mspm0::adc::{self, Adc, Vrsel}; |
| 7 | use embassy_mspm0::{bind_interrupts, peripherals, Config}; | 7 | use embassy_mspm0::{Config, bind_interrupts, peripherals}; |
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_halt as _}; | 9 | use {defmt_rtt as _, panic_halt as _}; |
| 10 | 10 | ||
diff --git a/examples/mspm0l1306/src/bin/blinky.rs b/examples/mspm0l1306/src/bin/blinky.rs index 055a5cd81..47eaf1535 100644 --- a/examples/mspm0l1306/src/bin/blinky.rs +++ b/examples/mspm0l1306/src/bin/blinky.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_mspm0::gpio::{Level, Output}; | ||
| 7 | use embassy_mspm0::Config; | 6 | use embassy_mspm0::Config; |
| 7 | use embassy_mspm0::gpio::{Level, Output}; | ||
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_halt as _}; | 9 | use {defmt_rtt as _, panic_halt as _}; |
| 10 | 10 | ||
diff --git a/examples/mspm0l1306/src/bin/button.rs b/examples/mspm0l1306/src/bin/button.rs index d8c85947f..33e682272 100644 --- a/examples/mspm0l1306/src/bin/button.rs +++ b/examples/mspm0l1306/src/bin/button.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_mspm0::gpio::{Input, Level, Output, Pull}; | ||
| 7 | use embassy_mspm0::Config; | 6 | use embassy_mspm0::Config; |
| 7 | use embassy_mspm0::gpio::{Input, Level, Output, Pull}; | ||
| 8 | use {defmt_rtt as _, panic_halt as _}; | 8 | use {defmt_rtt as _, panic_halt as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
diff --git a/examples/mspm0l2228/Cargo.toml b/examples/mspm0l2228/Cargo.toml index 3add7b8e8..1d27ae64a 100644 --- a/examples/mspm0l2228/Cargo.toml +++ b/examples/mspm0l2228/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-mspm0-l2228-examples" | 3 | name = "embassy-mspm0-l2228-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/mspm0l2228/src/bin/blinky.rs b/examples/mspm0l2228/src/bin/blinky.rs index 055a5cd81..47eaf1535 100644 --- a/examples/mspm0l2228/src/bin/blinky.rs +++ b/examples/mspm0l2228/src/bin/blinky.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_mspm0::gpio::{Level, Output}; | ||
| 7 | use embassy_mspm0::Config; | 6 | use embassy_mspm0::Config; |
| 7 | use embassy_mspm0::gpio::{Level, Output}; | ||
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_halt as _}; | 9 | use {defmt_rtt as _, panic_halt as _}; |
| 10 | 10 | ||
diff --git a/examples/mspm0l2228/src/bin/button.rs b/examples/mspm0l2228/src/bin/button.rs index 47bfd274b..bad1cb138 100644 --- a/examples/mspm0l2228/src/bin/button.rs +++ b/examples/mspm0l2228/src/bin/button.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_mspm0::gpio::{Input, Level, Output, Pull}; | ||
| 7 | use embassy_mspm0::Config; | 6 | use embassy_mspm0::Config; |
| 7 | use embassy_mspm0::gpio::{Input, Level, Output, Pull}; | ||
| 8 | use {defmt_rtt as _, panic_halt as _}; | 8 | use {defmt_rtt as _, panic_halt as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
diff --git a/examples/nrf-rtos-trace/Cargo.toml b/examples/nrf-rtos-trace/Cargo.toml index c9eeaaac7..5caabf228 100644 --- a/examples/nrf-rtos-trace/Cargo.toml +++ b/examples/nrf-rtos-trace/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-nrf-rtos-trace-examples" | 3 | name = "embassy-nrf-rtos-trace-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| @@ -19,7 +19,7 @@ log = [ | |||
| 19 | embassy-sync = { version = "0.7.2", path = "../../embassy-sync" } | 19 | embassy-sync = { version = "0.7.2", path = "../../embassy-sync" } |
| 20 | embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "rtos-trace"] } | 20 | embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "rtos-trace"] } |
| 21 | embassy-time = { version = "0.5.0", path = "../../embassy-time" } | 21 | embassy-time = { version = "0.5.0", path = "../../embassy-time" } |
| 22 | embassy-nrf = { version = "0.7.0", path = "../../embassy-nrf", features = ["nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } | 22 | embassy-nrf = { version = "0.8.0", path = "../../embassy-nrf", features = ["nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } |
| 23 | 23 | ||
| 24 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } | 24 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } |
| 25 | cortex-m-rt = "0.7.0" | 25 | cortex-m-rt = "0.7.0" |
diff --git a/examples/nrf51/Cargo.toml b/examples/nrf51/Cargo.toml index dded6de59..c7492f562 100644 --- a/examples/nrf51/Cargo.toml +++ b/examples/nrf51/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-nrf51-examples" | 3 | name = "embassy-nrf51-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| @@ -8,7 +8,7 @@ publish = false | |||
| 8 | [dependencies] | 8 | [dependencies] |
| 9 | embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } | 9 | embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } |
| 10 | embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } | 10 | embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } |
| 11 | embassy-nrf = { version = "0.7.0", path = "../../embassy-nrf", features = ["defmt", "nrf51", "gpiote", "time-driver-rtc1", "unstable-pac", "time", "rt"] } | 11 | embassy-nrf = { version = "0.8.0", path = "../../embassy-nrf", features = ["defmt", "nrf51", "gpiote", "time-driver-rtc1", "unstable-pac", "time", "rt"] } |
| 12 | 12 | ||
| 13 | defmt = "1.0.1" | 13 | defmt = "1.0.1" |
| 14 | defmt-rtt = "1.0.0" | 14 | defmt-rtt = "1.0.0" |
diff --git a/examples/nrf52810/Cargo.toml b/examples/nrf52810/Cargo.toml index aa1a4bf73..1711a3d8d 100644 --- a/examples/nrf52810/Cargo.toml +++ b/examples/nrf52810/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-nrf52810-examples" | 3 | name = "embassy-nrf52810-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| @@ -10,7 +10,7 @@ embassy-futures = { version = "0.1.2", path = "../../embassy-futures" } | |||
| 10 | embassy-sync = { version = "0.7.2", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.7.2", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } | 11 | embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } |
| 12 | embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } | 12 | embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } |
| 13 | embassy-nrf = { version = "0.7.0", path = "../../embassy-nrf", features = ["defmt", "nrf52810", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } | 13 | embassy-nrf = { version = "0.8.0", path = "../../embassy-nrf", features = ["defmt", "nrf52810", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } |
| 14 | 14 | ||
| 15 | defmt = "1.0.1" | 15 | defmt = "1.0.1" |
| 16 | defmt-rtt = "1.0.0" | 16 | defmt-rtt = "1.0.0" |
diff --git a/examples/nrf52810/src/bin/saadc_lowpower.rs b/examples/nrf52810/src/bin/saadc_lowpower.rs new file mode 100644 index 000000000..d7e7f09a4 --- /dev/null +++ b/examples/nrf52810/src/bin/saadc_lowpower.rs | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | //! Run SAADC on multiple pins only every 3rd time, to show anomaly 241 workaround. | ||
| 2 | //! | ||
| 3 | //! To correctly measure the MCU current on the NRF52DK follow the instructions | ||
| 4 | //! <https://docs.nordicsemi.com/bundle/ug_nrf52832_dk/page/UG/dk/prepare_board.html> | ||
| 5 | //! otherwise you will measure the whole board, including the segger j-link chip for example | ||
| 6 | |||
| 7 | #![no_std] | ||
| 8 | #![no_main] | ||
| 9 | |||
| 10 | use defmt::info; | ||
| 11 | use embassy_executor::Spawner; | ||
| 12 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | ||
| 13 | use embassy_nrf::saadc::{Oversample, Saadc}; | ||
| 14 | use embassy_nrf::{bind_interrupts, saadc}; | ||
| 15 | use embassy_time::Timer; | ||
| 16 | use {defmt_rtt as _, panic_probe as _}; | ||
| 17 | |||
| 18 | bind_interrupts!(struct Irqs { | ||
| 19 | SAADC => saadc::InterruptHandler; | ||
| 20 | }); | ||
| 21 | |||
| 22 | #[embassy_executor::main] | ||
| 23 | async fn main(_p: Spawner) { | ||
| 24 | let mut p = embassy_nrf::init(Default::default()); | ||
| 25 | |||
| 26 | // For PPK2 digital channel plot to track when SAADC is on/off. | ||
| 27 | let mut ppk2_d0 = Output::new(p.P0_27, Level::Low, OutputDrive::Standard); | ||
| 28 | let mut num_loops: usize = 0; | ||
| 29 | loop { | ||
| 30 | num_loops += 1; | ||
| 31 | if num_loops.is_multiple_of(3) { | ||
| 32 | ppk2_d0.set_high(); | ||
| 33 | let battery_pin = p.P0_02.reborrow(); | ||
| 34 | let sensor1_pin = p.P0_03.reborrow(); | ||
| 35 | let mut adc_config = saadc::Config::default(); | ||
| 36 | adc_config.oversample = Oversample::OVER4X; | ||
| 37 | let battery = saadc::ChannelConfig::single_ended(battery_pin); | ||
| 38 | let sensor1 = saadc::ChannelConfig::single_ended(sensor1_pin); | ||
| 39 | let mut saadc = Saadc::new(p.SAADC.reborrow(), Irqs, adc_config, [battery, sensor1]); | ||
| 40 | // Indicated: wait for ADC calibration. | ||
| 41 | saadc.calibrate().await; | ||
| 42 | let mut buf = [0; 2]; | ||
| 43 | info!("sampling..."); | ||
| 44 | saadc.sample(&mut buf).await; | ||
| 45 | info!("data: {:x}", buf); | ||
| 46 | |||
| 47 | // Sleep to show the high power usage on the plot, even though sampling is done. | ||
| 48 | Timer::after_millis(100).await; | ||
| 49 | ppk2_d0.set_low(); | ||
| 50 | // disable the following line to show the anomaly on the power profiler plot. | ||
| 51 | core::mem::drop(saadc); | ||
| 52 | // Sleep to show the power usage when drop did not happen. | ||
| 53 | Timer::after_millis(100).await; | ||
| 54 | // worst case drop happens here | ||
| 55 | } else { | ||
| 56 | info!("waiting"); | ||
| 57 | } | ||
| 58 | // Sleep for 1 second. The executor ensures the core sleeps with a WFE when it has nothing to do. | ||
| 59 | // During this sleep, the nRF chip should only use ~3uA | ||
| 60 | Timer::after_secs(1).await; | ||
| 61 | } | ||
| 62 | } | ||
diff --git a/examples/nrf52840-edf/Cargo.toml b/examples/nrf52840-edf/Cargo.toml index 1e8803233..8b1db4652 100644 --- a/examples/nrf52840-edf/Cargo.toml +++ b/examples/nrf52840-edf/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-nrf52840-edf-examples" | 3 | name = "embassy-nrf52840-edf-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| @@ -9,7 +9,7 @@ publish = false | |||
| 9 | # NOTE: "scheduler-deadline" and "embassy-time-driver" features are enabled | 9 | # NOTE: "scheduler-deadline" and "embassy-time-driver" features are enabled |
| 10 | embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "scheduler-deadline", "embassy-time-driver"] } | 10 | embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "scheduler-deadline", "embassy-time-driver"] } |
| 11 | embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } | 11 | embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } |
| 12 | embassy-nrf = { version = "0.7.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } | 12 | embassy-nrf = { version = "0.8.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } |
| 13 | 13 | ||
| 14 | defmt = "1.0.1" | 14 | defmt = "1.0.1" |
| 15 | defmt-rtt = "1.0.0" | 15 | defmt-rtt = "1.0.0" |
diff --git a/examples/nrf52840-edf/src/bin/basic.rs b/examples/nrf52840-edf/src/bin/basic.rs index d888e17d1..f7214790d 100644 --- a/examples/nrf52840-edf/src/bin/basic.rs +++ b/examples/nrf52840-edf/src/bin/basic.rs | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | #![no_std] | 12 | #![no_std] |
| 13 | #![no_main] | 13 | #![no_main] |
| 14 | 14 | ||
| 15 | use core::sync::atomic::{compiler_fence, Ordering}; | 15 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 16 | 16 | ||
| 17 | use defmt::unwrap; | 17 | use defmt::unwrap; |
| 18 | use embassy_executor::Spawner; | 18 | use embassy_executor::Spawner; |
diff --git a/examples/nrf52840-rtic/Cargo.toml b/examples/nrf52840-rtic/Cargo.toml index f6937c263..26b21598f 100644 --- a/examples/nrf52840-rtic/Cargo.toml +++ b/examples/nrf52840-rtic/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-nrf52840-rtic-examples" | 3 | name = "embassy-nrf52840-rtic-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| @@ -12,7 +12,7 @@ embassy-futures = { version = "0.1.2", path = "../../embassy-futures" } | |||
| 12 | embassy-sync = { version = "0.7.2", path = "../../embassy-sync", features = ["defmt"] } | 12 | embassy-sync = { version = "0.7.2", path = "../../embassy-sync", features = ["defmt"] } |
| 13 | embassy-time = { version = "0.5.0", path = "../../embassy-time", features = [ "defmt", "defmt-timestamp-uptime"] } | 13 | embassy-time = { version = "0.5.0", path = "../../embassy-time", features = [ "defmt", "defmt-timestamp-uptime"] } |
| 14 | embassy-time-queue-utils = { version = "0.3.0", path = "../../embassy-time-queue-utils", features = ["generic-queue-8"] } | 14 | embassy-time-queue-utils = { version = "0.3.0", path = "../../embassy-time-queue-utils", features = ["generic-queue-8"] } |
| 15 | embassy-nrf = { version = "0.7.0", path = "../../embassy-nrf", features = [ "defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } | 15 | embassy-nrf = { version = "0.8.0", path = "../../embassy-nrf", features = [ "defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } |
| 16 | 16 | ||
| 17 | defmt = "1.0.1" | 17 | defmt = "1.0.1" |
| 18 | defmt-rtt = "1.0.0" | 18 | defmt-rtt = "1.0.0" |
diff --git a/examples/nrf52840-rtic/src/bin/blinky.rs b/examples/nrf52840-rtic/src/bin/blinky.rs index 2adac7e0a..671082117 100644 --- a/examples/nrf52840-rtic/src/bin/blinky.rs +++ b/examples/nrf52840-rtic/src/bin/blinky.rs | |||
| @@ -7,7 +7,7 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 7 | mod app { | 7 | mod app { |
| 8 | use defmt::info; | 8 | use defmt::info; |
| 9 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | 9 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; |
| 10 | use embassy_nrf::{peripherals, Peri}; | 10 | use embassy_nrf::{Peri, peripherals}; |
| 11 | use embassy_time::Timer; | 11 | use embassy_time::Timer; |
| 12 | 12 | ||
| 13 | #[shared] | 13 | #[shared] |
diff --git a/examples/nrf52840/Cargo.toml b/examples/nrf52840/Cargo.toml index ca3c6f863..a026d6352 100644 --- a/examples/nrf52840/Cargo.toml +++ b/examples/nrf52840/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-nrf52840-examples" | 3 | name = "embassy-nrf52840-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| @@ -10,7 +10,7 @@ embassy-futures = { version = "0.1.2", path = "../../embassy-futures" } | |||
| 10 | embassy-sync = { version = "0.7.2", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.7.2", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } | 11 | embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } |
| 12 | embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } | 12 | embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } |
| 13 | embassy-nrf = { version = "0.7.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time", "net-driver"] } | 13 | embassy-nrf = { version = "0.8.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time", "net-driver"] } |
| 14 | embassy-net = { version = "0.7.1", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet","udp", "medium-ieee802154", "proto-ipv6"] } | 14 | embassy-net = { version = "0.7.1", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet","udp", "medium-ieee802154", "proto-ipv6"] } |
| 15 | embassy-usb = { version = "0.5.1", path = "../../embassy-usb", features = ["defmt"] } | 15 | embassy-usb = { version = "0.5.1", path = "../../embassy-usb", features = ["defmt"] } |
| 16 | embedded-io = { version = "0.6.0", features = ["defmt-03"] } | 16 | embedded-io = { version = "0.6.0", features = ["defmt-03"] } |
diff --git a/examples/nrf52840/src/bin/channel_sender_receiver.rs b/examples/nrf52840/src/bin/channel_sender_receiver.rs index 09050db68..de694eaa0 100644 --- a/examples/nrf52840/src/bin/channel_sender_receiver.rs +++ b/examples/nrf52840/src/bin/channel_sender_receiver.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::unwrap; | 4 | use defmt::unwrap; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive}; | ||
| 7 | use embassy_nrf::Peri; | 6 | use embassy_nrf::Peri; |
| 7 | use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive}; | ||
| 8 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | 8 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; |
| 9 | use embassy_sync::channel::{Channel, Receiver, Sender}; | 9 | use embassy_sync::channel::{Channel, Receiver, Sender}; |
| 10 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
diff --git a/examples/nrf52840/src/bin/ethernet_enc28j60.rs b/examples/nrf52840/src/bin/ethernet_enc28j60.rs index e59afd37f..5a988d89b 100644 --- a/examples/nrf52840/src/bin/ethernet_enc28j60.rs +++ b/examples/nrf52840/src/bin/ethernet_enc28j60.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_net::tcp::TcpSocket; | ||
| 7 | use embassy_net::StackResources; | 6 | use embassy_net::StackResources; |
| 7 | use embassy_net::tcp::TcpSocket; | ||
| 8 | use embassy_net_enc28j60::Enc28j60; | 8 | use embassy_net_enc28j60::Enc28j60; |
| 9 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | 9 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; |
| 10 | use embassy_nrf::rng::Rng; | 10 | use embassy_nrf::rng::Rng; |
diff --git a/examples/nrf52840/src/bin/i2s_effect.rs b/examples/nrf52840/src/bin/i2s_effect.rs index 9eadeb4e4..c31b78614 100644 --- a/examples/nrf52840/src/bin/i2s_effect.rs +++ b/examples/nrf52840/src/bin/i2s_effect.rs | |||
| @@ -5,7 +5,7 @@ use core::f32::consts::PI; | |||
| 5 | 5 | ||
| 6 | use defmt::{error, info}; | 6 | use defmt::{error, info}; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_nrf::i2s::{self, Channels, Config, MasterClock, MultiBuffering, Sample as _, SampleWidth, I2S}; | 8 | use embassy_nrf::i2s::{self, Channels, Config, I2S, MasterClock, MultiBuffering, Sample as _, SampleWidth}; |
| 9 | use embassy_nrf::{bind_interrupts, peripherals}; | 9 | use embassy_nrf::{bind_interrupts, peripherals}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| @@ -102,11 +102,7 @@ impl SineOsc { | |||
| 102 | 102 | ||
| 103 | #[inline] | 103 | #[inline] |
| 104 | fn abs(value: f32) -> f32 { | 104 | fn abs(value: f32) -> f32 { |
| 105 | if value < 0.0 { | 105 | if value < 0.0 { -value } else { value } |
| 106 | -value | ||
| 107 | } else { | ||
| 108 | value | ||
| 109 | } | ||
| 110 | } | 106 | } |
| 111 | 107 | ||
| 112 | #[inline] | 108 | #[inline] |
diff --git a/examples/nrf52840/src/bin/i2s_monitor.rs b/examples/nrf52840/src/bin/i2s_monitor.rs index 799be351f..66b429b09 100644 --- a/examples/nrf52840/src/bin/i2s_monitor.rs +++ b/examples/nrf52840/src/bin/i2s_monitor.rs | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::{debug, error, info}; | 4 | use defmt::{debug, error, info}; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_nrf::i2s::{self, Channels, Config, DoubleBuffering, MasterClock, Sample as _, SampleWidth, I2S}; | 6 | use embassy_nrf::i2s::{self, Channels, Config, DoubleBuffering, I2S, MasterClock, Sample as _, SampleWidth}; |
| 7 | use embassy_nrf::pwm::{Prescaler, SimplePwm}; | 7 | use embassy_nrf::pwm::{Prescaler, SimplePwm}; |
| 8 | use embassy_nrf::{bind_interrupts, peripherals}; | 8 | use embassy_nrf::{bind_interrupts, peripherals}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
diff --git a/examples/nrf52840/src/bin/i2s_waveform.rs b/examples/nrf52840/src/bin/i2s_waveform.rs index 137d82840..ce7a68d3a 100644 --- a/examples/nrf52840/src/bin/i2s_waveform.rs +++ b/examples/nrf52840/src/bin/i2s_waveform.rs | |||
| @@ -5,7 +5,7 @@ use core::f32::consts::PI; | |||
| 5 | 5 | ||
| 6 | use defmt::{error, info}; | 6 | use defmt::{error, info}; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_nrf::i2s::{self, Channels, Config, DoubleBuffering, MasterClock, Sample as _, SampleWidth, I2S}; | 8 | use embassy_nrf::i2s::{self, Channels, Config, DoubleBuffering, I2S, MasterClock, Sample as _, SampleWidth}; |
| 9 | use embassy_nrf::{bind_interrupts, peripherals}; | 9 | use embassy_nrf::{bind_interrupts, peripherals}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| @@ -140,11 +140,7 @@ impl SineOsc { | |||
| 140 | 140 | ||
| 141 | #[inline] | 141 | #[inline] |
| 142 | fn abs(value: f32) -> f32 { | 142 | fn abs(value: f32) -> f32 { |
| 143 | if value < 0.0 { | 143 | if value < 0.0 { -value } else { value } |
| 144 | -value | ||
| 145 | } else { | ||
| 146 | value | ||
| 147 | } | ||
| 148 | } | 144 | } |
| 149 | 145 | ||
| 150 | #[inline] | 146 | #[inline] |
diff --git a/examples/nrf52840/src/bin/multiprio.rs b/examples/nrf52840/src/bin/multiprio.rs index 4d9b986d4..dc566adee 100644 --- a/examples/nrf52840/src/bin/multiprio.rs +++ b/examples/nrf52840/src/bin/multiprio.rs | |||
| @@ -113,12 +113,12 @@ static EXECUTOR_LOW: StaticCell<Executor> = StaticCell::new(); | |||
| 113 | 113 | ||
| 114 | #[interrupt] | 114 | #[interrupt] |
| 115 | unsafe fn EGU1_SWI1() { | 115 | unsafe fn EGU1_SWI1() { |
| 116 | EXECUTOR_HIGH.on_interrupt() | 116 | unsafe { EXECUTOR_HIGH.on_interrupt() } |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | #[interrupt] | 119 | #[interrupt] |
| 120 | unsafe fn EGU0_SWI0() { | 120 | unsafe fn EGU0_SWI0() { |
| 121 | EXECUTOR_MED.on_interrupt() | 121 | unsafe { EXECUTOR_MED.on_interrupt() } |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | #[entry] | 124 | #[entry] |
diff --git a/examples/nrf52840/src/bin/raw_spawn.rs b/examples/nrf52840/src/bin/raw_spawn.rs index b80954408..783be763d 100644 --- a/examples/nrf52840/src/bin/raw_spawn.rs +++ b/examples/nrf52840/src/bin/raw_spawn.rs | |||
| @@ -5,8 +5,8 @@ use core::mem; | |||
| 5 | 5 | ||
| 6 | use cortex_m_rt::entry; | 6 | use cortex_m_rt::entry; |
| 7 | use defmt::{info, unwrap}; | 7 | use defmt::{info, unwrap}; |
| 8 | use embassy_executor::raw::TaskStorage; | ||
| 9 | use embassy_executor::Executor; | 8 | use embassy_executor::Executor; |
| 9 | use embassy_executor::raw::TaskStorage; | ||
| 10 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 11 | use static_cell::StaticCell; | 11 | use static_cell::StaticCell; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -48,5 +48,5 @@ fn main() -> ! { | |||
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | unsafe fn make_static<T>(t: &T) -> &'static T { | 50 | unsafe fn make_static<T>(t: &T) -> &'static T { |
| 51 | mem::transmute(t) | 51 | unsafe { mem::transmute(t) } |
| 52 | } | 52 | } |
diff --git a/examples/nrf52840/src/bin/rtc.rs b/examples/nrf52840/src/bin/rtc.rs index a3df7da14..56a0c25f4 100644 --- a/examples/nrf52840/src/bin/rtc.rs +++ b/examples/nrf52840/src/bin/rtc.rs | |||
| @@ -7,15 +7,14 @@ use embassy_executor::Spawner; | |||
| 7 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | 7 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; |
| 8 | use embassy_nrf::interrupt; | 8 | use embassy_nrf::interrupt; |
| 9 | use embassy_nrf::rtc::Rtc; | 9 | use embassy_nrf::rtc::Rtc; |
| 10 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | ||
| 11 | use embassy_sync::blocking_mutex::Mutex; | 10 | use embassy_sync::blocking_mutex::Mutex; |
| 11 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | ||
| 12 | use portable_atomic::AtomicU64; | 12 | use portable_atomic::AtomicU64; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| 15 | // 64 bit counter which will never overflow. | 15 | // 64 bit counter which will never overflow. |
| 16 | static TICK_COUNTER: AtomicU64 = AtomicU64::new(0); | 16 | static TICK_COUNTER: AtomicU64 = AtomicU64::new(0); |
| 17 | static RTC: Mutex<CriticalSectionRawMutex, RefCell<Option<Rtc<'static, embassy_nrf::peripherals::RTC0>>>> = | 17 | static RTC: Mutex<CriticalSectionRawMutex, RefCell<Option<Rtc<'static>>>> = Mutex::new(RefCell::new(None)); |
| 18 | Mutex::new(RefCell::new(None)); | ||
| 19 | 18 | ||
| 20 | #[embassy_executor::main] | 19 | #[embassy_executor::main] |
| 21 | async fn main(_spawner: Spawner) { | 20 | async fn main(_spawner: Spawner) { |
diff --git a/examples/nrf52840/src/bin/sixlowpan.rs b/examples/nrf52840/src/bin/sixlowpan.rs index 00a597366..12e385e01 100644 --- a/examples/nrf52840/src/bin/sixlowpan.rs +++ b/examples/nrf52840/src/bin/sixlowpan.rs | |||
| @@ -21,7 +21,7 @@ bind_interrupts!(struct Irqs { | |||
| 21 | }); | 21 | }); |
| 22 | 22 | ||
| 23 | #[embassy_executor::task] | 23 | #[embassy_executor::task] |
| 24 | async fn ieee802154_task(runner: net::Runner<'static, peripherals::RADIO>) -> ! { | 24 | async fn ieee802154_task(runner: net::Runner<'static>) -> ! { |
| 25 | runner.run().await | 25 | runner.run().await |
| 26 | } | 26 | } |
| 27 | 27 | ||
diff --git a/examples/nrf52840/src/bin/uart_split.rs b/examples/nrf52840/src/bin/uart_split.rs index 51af90727..d75143126 100644 --- a/examples/nrf52840/src/bin/uart_split.rs +++ b/examples/nrf52840/src/bin/uart_split.rs | |||
| @@ -52,7 +52,7 @@ async fn main(spawner: Spawner) { | |||
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | #[embassy_executor::task] | 54 | #[embassy_executor::task] |
| 55 | async fn reader(mut rx: UarteRx<'static, UARTE0>) { | 55 | async fn reader(mut rx: UarteRx<'static>) { |
| 56 | let mut buf = [0; 8]; | 56 | let mut buf = [0; 8]; |
| 57 | loop { | 57 | loop { |
| 58 | info!("reading..."); | 58 | info!("reading..."); |
diff --git a/examples/nrf52840/src/bin/usb_ethernet.rs b/examples/nrf52840/src/bin/usb_ethernet.rs index 87aa4c6c5..14a1004d7 100644 --- a/examples/nrf52840/src/bin/usb_ethernet.rs +++ b/examples/nrf52840/src/bin/usb_ethernet.rs | |||
| @@ -3,11 +3,11 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_net::tcp::TcpSocket; | ||
| 7 | use embassy_net::StackResources; | 6 | use embassy_net::StackResources; |
| 7 | use embassy_net::tcp::TcpSocket; | ||
| 8 | use embassy_nrf::rng::Rng; | 8 | use embassy_nrf::rng::Rng; |
| 9 | use embassy_nrf::usb::vbus_detect::HardwareVbusDetect; | ||
| 10 | use embassy_nrf::usb::Driver; | 9 | use embassy_nrf::usb::Driver; |
| 10 | use embassy_nrf::usb::vbus_detect::HardwareVbusDetect; | ||
| 11 | use embassy_nrf::{bind_interrupts, pac, peripherals, rng, usb}; | 11 | use embassy_nrf::{bind_interrupts, pac, peripherals, rng, usb}; |
| 12 | use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState}; | 12 | use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState}; |
| 13 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; | 13 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; |
| @@ -22,7 +22,7 @@ bind_interrupts!(struct Irqs { | |||
| 22 | RNG => rng::InterruptHandler<peripherals::RNG>; | 22 | RNG => rng::InterruptHandler<peripherals::RNG>; |
| 23 | }); | 23 | }); |
| 24 | 24 | ||
| 25 | type MyDriver = Driver<'static, peripherals::USBD, HardwareVbusDetect>; | 25 | type MyDriver = Driver<'static, HardwareVbusDetect>; |
| 26 | 26 | ||
| 27 | const MTU: usize = 1514; | 27 | const MTU: usize = 1514; |
| 28 | 28 | ||
diff --git a/examples/nrf52840/src/bin/usb_hid_keyboard.rs b/examples/nrf52840/src/bin/usb_hid_keyboard.rs index 5a9dc90a2..1cd730503 100644 --- a/examples/nrf52840/src/bin/usb_hid_keyboard.rs +++ b/examples/nrf52840/src/bin/usb_hid_keyboard.rs | |||
| @@ -6,10 +6,10 @@ use core::sync::atomic::{AtomicBool, Ordering}; | |||
| 6 | use defmt::*; | 6 | use defmt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_futures::join::join; | 8 | use embassy_futures::join::join; |
| 9 | use embassy_futures::select::{select, Either}; | 9 | use embassy_futures::select::{Either, select}; |
| 10 | use embassy_nrf::gpio::{Input, Pull}; | 10 | use embassy_nrf::gpio::{Input, Pull}; |
| 11 | use embassy_nrf::usb::vbus_detect::HardwareVbusDetect; | ||
| 12 | use embassy_nrf::usb::Driver; | 11 | use embassy_nrf::usb::Driver; |
| 12 | use embassy_nrf::usb::vbus_detect::HardwareVbusDetect; | ||
| 13 | use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; | 13 | use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; |
| 14 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 14 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| 15 | use embassy_sync::signal::Signal; | 15 | use embassy_sync::signal::Signal; |
| @@ -210,7 +210,9 @@ impl Handler for MyDeviceHandler { | |||
| 210 | 210 | ||
| 211 | fn suspended(&mut self, suspended: bool) { | 211 | fn suspended(&mut self, suspended: bool) { |
| 212 | if suspended { | 212 | if suspended { |
| 213 | info!("Device suspended, the Vbus current limit is 500µA (or 2.5mA for high-power devices with remote wakeup enabled)."); | 213 | info!( |
| 214 | "Device suspended, the Vbus current limit is 500µA (or 2.5mA for high-power devices with remote wakeup enabled)." | ||
| 215 | ); | ||
| 214 | SUSPENDED.store(true, Ordering::Release); | 216 | SUSPENDED.store(true, Ordering::Release); |
| 215 | } else { | 217 | } else { |
| 216 | SUSPENDED.store(false, Ordering::Release); | 218 | SUSPENDED.store(false, Ordering::Release); |
diff --git a/examples/nrf52840/src/bin/usb_hid_mouse.rs b/examples/nrf52840/src/bin/usb_hid_mouse.rs index 80cda70e3..3c0fc04e8 100644 --- a/examples/nrf52840/src/bin/usb_hid_mouse.rs +++ b/examples/nrf52840/src/bin/usb_hid_mouse.rs | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_futures::join::join; | 6 | use embassy_futures::join::join; |
| 7 | use embassy_nrf::usb::vbus_detect::HardwareVbusDetect; | ||
| 8 | use embassy_nrf::usb::Driver; | 7 | use embassy_nrf::usb::Driver; |
| 8 | use embassy_nrf::usb::vbus_detect::HardwareVbusDetect; | ||
| 9 | use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; | 9 | use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; |
| 10 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 11 | use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State}; | 11 | use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State}; |
diff --git a/examples/nrf52840/src/bin/usb_serial.rs b/examples/nrf52840/src/bin/usb_serial.rs index 8d05df791..469002bc7 100644 --- a/examples/nrf52840/src/bin/usb_serial.rs +++ b/examples/nrf52840/src/bin/usb_serial.rs | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | use defmt::{info, panic}; | 4 | use defmt::{info, panic}; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_futures::join::join; | 6 | use embassy_futures::join::join; |
| 7 | use embassy_nrf::usb::Driver; | ||
| 7 | use embassy_nrf::usb::vbus_detect::{HardwareVbusDetect, VbusDetect}; | 8 | use embassy_nrf::usb::vbus_detect::{HardwareVbusDetect, VbusDetect}; |
| 8 | use embassy_nrf::usb::{Driver, Instance}; | ||
| 9 | use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; | 9 | use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; |
| 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 11 | use embassy_usb::driver::EndpointError; | 11 | use embassy_usb::driver::EndpointError; |
| @@ -89,9 +89,7 @@ impl From<EndpointError> for Disconnected { | |||
| 89 | } | 89 | } |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | async fn echo<'d, T: Instance + 'd, P: VbusDetect + 'd>( | 92 | async fn echo<'d, V: VbusDetect + 'd>(class: &mut CdcAcmClass<'d, Driver<'d, V>>) -> Result<(), Disconnected> { |
| 93 | class: &mut CdcAcmClass<'d, Driver<'d, T, P>>, | ||
| 94 | ) -> Result<(), Disconnected> { | ||
| 95 | let mut buf = [0; 64]; | 93 | let mut buf = [0; 64]; |
| 96 | loop { | 94 | loop { |
| 97 | let n = class.read_packet(&mut buf).await?; | 95 | let n = class.read_packet(&mut buf).await?; |
diff --git a/examples/nrf52840/src/bin/usb_serial_multitask.rs b/examples/nrf52840/src/bin/usb_serial_multitask.rs index 00a91a233..67b2bccbb 100644 --- a/examples/nrf52840/src/bin/usb_serial_multitask.rs +++ b/examples/nrf52840/src/bin/usb_serial_multitask.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::{info, panic, unwrap}; | 4 | use defmt::{info, panic, unwrap}; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_nrf::usb::vbus_detect::HardwareVbusDetect; | ||
| 7 | use embassy_nrf::usb::Driver; | 6 | use embassy_nrf::usb::Driver; |
| 7 | use embassy_nrf::usb::vbus_detect::HardwareVbusDetect; | ||
| 8 | use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; | 8 | use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; |
| 9 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 9 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 10 | use embassy_usb::driver::EndpointError; | 10 | use embassy_usb::driver::EndpointError; |
| @@ -17,7 +17,7 @@ bind_interrupts!(struct Irqs { | |||
| 17 | CLOCK_POWER => usb::vbus_detect::InterruptHandler; | 17 | CLOCK_POWER => usb::vbus_detect::InterruptHandler; |
| 18 | }); | 18 | }); |
| 19 | 19 | ||
| 20 | type MyDriver = Driver<'static, peripherals::USBD, HardwareVbusDetect>; | 20 | type MyDriver = Driver<'static, HardwareVbusDetect>; |
| 21 | 21 | ||
| 22 | #[embassy_executor::task] | 22 | #[embassy_executor::task] |
| 23 | async fn usb_task(mut device: UsbDevice<'static, MyDriver>) { | 23 | async fn usb_task(mut device: UsbDevice<'static, MyDriver>) { |
diff --git a/examples/nrf52840/src/bin/usb_serial_winusb.rs b/examples/nrf52840/src/bin/usb_serial_winusb.rs index 8a20ce673..cd4d5bca1 100644 --- a/examples/nrf52840/src/bin/usb_serial_winusb.rs +++ b/examples/nrf52840/src/bin/usb_serial_winusb.rs | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | use defmt::{info, panic}; | 4 | use defmt::{info, panic}; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_futures::join::join; | 6 | use embassy_futures::join::join; |
| 7 | use embassy_nrf::usb::Driver; | ||
| 7 | use embassy_nrf::usb::vbus_detect::{HardwareVbusDetect, VbusDetect}; | 8 | use embassy_nrf::usb::vbus_detect::{HardwareVbusDetect, VbusDetect}; |
| 8 | use embassy_nrf::usb::{Driver, Instance}; | ||
| 9 | use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; | 9 | use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; |
| 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 11 | use embassy_usb::driver::EndpointError; | 11 | use embassy_usb::driver::EndpointError; |
| @@ -108,9 +108,7 @@ impl From<EndpointError> for Disconnected { | |||
| 108 | } | 108 | } |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | async fn echo<'d, T: Instance + 'd, P: VbusDetect + 'd>( | 111 | async fn echo<'d, V: VbusDetect + 'd>(class: &mut CdcAcmClass<'d, Driver<'d, V>>) -> Result<(), Disconnected> { |
| 112 | class: &mut CdcAcmClass<'d, Driver<'d, T, P>>, | ||
| 113 | ) -> Result<(), Disconnected> { | ||
| 114 | let mut buf = [0; 64]; | 112 | let mut buf = [0; 64]; |
| 115 | loop { | 113 | loop { |
| 116 | let n = class.read_packet(&mut buf).await?; | 114 | let n = class.read_packet(&mut buf).await?; |
diff --git a/examples/nrf52840/src/bin/wifi_esp_hosted.rs b/examples/nrf52840/src/bin/wifi_esp_hosted.rs index 1bc35746a..07752ffc4 100644 --- a/examples/nrf52840/src/bin/wifi_esp_hosted.rs +++ b/examples/nrf52840/src/bin/wifi_esp_hosted.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::{info, unwrap, warn}; | 4 | use defmt::{info, unwrap, warn}; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_net::tcp::TcpSocket; | ||
| 7 | use embassy_net::StackResources; | 6 | use embassy_net::StackResources; |
| 7 | use embassy_net::tcp::TcpSocket; | ||
| 8 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; | 8 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; |
| 9 | use embassy_nrf::rng::Rng; | 9 | use embassy_nrf::rng::Rng; |
| 10 | use embassy_nrf::spim::{self, Spim}; | 10 | use embassy_nrf::spim::{self, Spim}; |
diff --git a/examples/nrf5340/Cargo.toml b/examples/nrf5340/Cargo.toml index 425015667..4dcbdd715 100644 --- a/examples/nrf5340/Cargo.toml +++ b/examples/nrf5340/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-nrf5340-examples" | 3 | name = "embassy-nrf5340-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| @@ -10,7 +10,7 @@ embassy-futures = { version = "0.1.2", path = "../../embassy-futures" } | |||
| 10 | embassy-sync = { version = "0.7.2", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.7.2", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } | 11 | embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } |
| 12 | embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } | 12 | embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } |
| 13 | embassy-nrf = { version = "0.7.0", path = "../../embassy-nrf", features = ["defmt", "nrf5340-app-s", "time-driver-rtc1", "gpiote", "unstable-pac"] } | 13 | embassy-nrf = { version = "0.8.0", path = "../../embassy-nrf", features = ["defmt", "nrf5340-app-s", "time-driver-rtc1", "gpiote", "unstable-pac"] } |
| 14 | embassy-net = { version = "0.7.1", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"] } | 14 | embassy-net = { version = "0.7.1", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"] } |
| 15 | embassy-usb = { version = "0.5.1", path = "../../embassy-usb", features = ["defmt"] } | 15 | embassy-usb = { version = "0.5.1", path = "../../embassy-usb", features = ["defmt"] } |
| 16 | embedded-io-async = { version = "0.6.1" } | 16 | embedded-io-async = { version = "0.6.1" } |
diff --git a/examples/nrf5340/src/bin/nrf5340dk_internal_caps.rs b/examples/nrf5340/src/bin/nrf5340dk_internal_caps.rs new file mode 100644 index 000000000..0b1fb852e --- /dev/null +++ b/examples/nrf5340/src/bin/nrf5340dk_internal_caps.rs | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | |||
| 4 | use defmt::info; | ||
| 5 | use embassy_executor::Spawner; | ||
| 6 | use embassy_nrf::config::{Config, HfclkSource, LfclkSource, LfxoCapacitance}; | ||
| 7 | use embassy_nrf::pac; | ||
| 8 | use {defmt_rtt as _, panic_probe as _}; | ||
| 9 | |||
| 10 | fn print_xosc32mcaps() { | ||
| 11 | let value = pac::OSCILLATORS.xosc32mcaps().read(); | ||
| 12 | info!("XOSC32MCAPS.ENABLE = {}", value.enable()); | ||
| 13 | info!("XOSC32MCAPS.CAPVALUE = {}", value.capvalue()); | ||
| 14 | } | ||
| 15 | |||
| 16 | #[embassy_executor::main] | ||
| 17 | async fn main(_spawner: Spawner) { | ||
| 18 | info!("Before init:"); | ||
| 19 | print_xosc32mcaps(); | ||
| 20 | |||
| 21 | let mut config = Config::default(); | ||
| 22 | config.hfclk_source = HfclkSource::Internal; | ||
| 23 | config.lfclk_source = LfclkSource::ExternalXtal; | ||
| 24 | config.internal_capacitors.hfxo = None; // keep the value from the FICR | ||
| 25 | config.internal_capacitors.lfxo = Some(LfxoCapacitance::_7pF); | ||
| 26 | let _p = embassy_nrf::init(config); | ||
| 27 | |||
| 28 | info!("After init:"); | ||
| 29 | print_xosc32mcaps(); | ||
| 30 | } | ||
diff --git a/examples/nrf54l15/Cargo.toml b/examples/nrf54l15/Cargo.toml index 7f67b41f6..a053dd0ec 100644 --- a/examples/nrf54l15/Cargo.toml +++ b/examples/nrf54l15/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-nrf54l15-examples" | 3 | name = "embassy-nrf54l15-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| @@ -8,7 +8,7 @@ publish = false | |||
| 8 | [dependencies] | 8 | [dependencies] |
| 9 | embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } | 9 | embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } |
| 10 | embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } | 10 | embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } |
| 11 | embassy-nrf = { version = "0.7.0", path = "../../embassy-nrf", features = ["defmt", "nrf54l15-app-s", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } | 11 | embassy-nrf = { version = "0.8.0", path = "../../embassy-nrf", features = ["defmt", "nrf54l15-app-s", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } |
| 12 | 12 | ||
| 13 | defmt = "1.0.1" | 13 | defmt = "1.0.1" |
| 14 | defmt-rtt = "1.0.0" | 14 | defmt-rtt = "1.0.0" |
diff --git a/examples/nrf9151/ns/Cargo.toml b/examples/nrf9151/ns/Cargo.toml index 8e420477f..7f1f5239a 100644 --- a/examples/nrf9151/ns/Cargo.toml +++ b/examples/nrf9151/ns/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-nrf9151-non-secure-examples" | 3 | name = "embassy-nrf9151-non-secure-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| @@ -8,7 +8,7 @@ publish = false | |||
| 8 | [dependencies] | 8 | [dependencies] |
| 9 | embassy-executor = { version = "0.9.0", path = "../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } | 9 | embassy-executor = { version = "0.9.0", path = "../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } |
| 10 | embassy-time = { version = "0.5.0", path = "../../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } | 10 | embassy-time = { version = "0.5.0", path = "../../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } |
| 11 | embassy-nrf = { version = "0.7.0", path = "../../../embassy-nrf", features = ["defmt", "nrf9120-ns", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } | 11 | embassy-nrf = { version = "0.8.0", path = "../../../embassy-nrf", features = ["defmt", "nrf9120-ns", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } |
| 12 | 12 | ||
| 13 | defmt = "1.0.1" | 13 | defmt = "1.0.1" |
| 14 | defmt-rtt = "1.0.0" | 14 | defmt-rtt = "1.0.0" |
diff --git a/examples/nrf9151/s/Cargo.toml b/examples/nrf9151/s/Cargo.toml index e4ca85553..ce71cc456 100644 --- a/examples/nrf9151/s/Cargo.toml +++ b/examples/nrf9151/s/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-nrf9151-secure-examples" | 3 | name = "embassy-nrf9151-secure-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| @@ -8,7 +8,7 @@ publish = false | |||
| 8 | [dependencies] | 8 | [dependencies] |
| 9 | embassy-executor = { version = "0.9.0", path = "../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } | 9 | embassy-executor = { version = "0.9.0", path = "../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } |
| 10 | embassy-time = { version = "0.5.0", path = "../../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } | 10 | embassy-time = { version = "0.5.0", path = "../../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } |
| 11 | embassy-nrf = { version = "0.7.0", path = "../../../embassy-nrf", features = ["defmt", "nrf9120-s", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } | 11 | embassy-nrf = { version = "0.8.0", path = "../../../embassy-nrf", features = ["defmt", "nrf9120-s", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } |
| 12 | 12 | ||
| 13 | defmt = "1.0.1" | 13 | defmt = "1.0.1" |
| 14 | defmt-rtt = "1.0.0" | 14 | defmt-rtt = "1.0.0" |
diff --git a/examples/nrf9160/Cargo.toml b/examples/nrf9160/Cargo.toml index d7b63a7ac..ae3b2eeb1 100644 --- a/examples/nrf9160/Cargo.toml +++ b/examples/nrf9160/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-nrf9160-examples" | 3 | name = "embassy-nrf9160-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| @@ -8,7 +8,7 @@ publish = false | |||
| 8 | [dependencies] | 8 | [dependencies] |
| 9 | embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } | 9 | embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } |
| 10 | embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } | 10 | embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } |
| 11 | embassy-nrf = { version = "0.7.0", path = "../../embassy-nrf", features = ["defmt", "nrf9160-s", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } | 11 | embassy-nrf = { version = "0.8.0", path = "../../embassy-nrf", features = ["defmt", "nrf9160-s", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } |
| 12 | embassy-net-nrf91 = { version = "0.1.0", path = "../../embassy-net-nrf91", features = ["defmt"] } | 12 | embassy-net-nrf91 = { version = "0.1.0", path = "../../embassy-net-nrf91", features = ["defmt"] } |
| 13 | embassy-net = { version = "0.7.1", path = "../../embassy-net", features = ["defmt", "tcp", "proto-ipv4", "medium-ip"] } | 13 | embassy-net = { version = "0.7.1", path = "../../embassy-net", features = ["defmt", "tcp", "proto-ipv4", "medium-ip"] } |
| 14 | 14 | ||
diff --git a/examples/nrf9160/src/bin/modem_tcp_client.rs b/examples/nrf9160/src/bin/modem_tcp_client.rs index 7d4815699..07fa57e63 100644 --- a/examples/nrf9160/src/bin/modem_tcp_client.rs +++ b/examples/nrf9160/src/bin/modem_tcp_client.rs | |||
| @@ -11,11 +11,11 @@ use defmt::{info, unwrap, warn}; | |||
| 11 | use embassy_executor::Spawner; | 11 | use embassy_executor::Spawner; |
| 12 | use embassy_net::{Ipv4Cidr, Stack, StackResources}; | 12 | use embassy_net::{Ipv4Cidr, Stack, StackResources}; |
| 13 | use embassy_net_nrf91::context::Status; | 13 | use embassy_net_nrf91::context::Status; |
| 14 | use embassy_net_nrf91::{context, Runner, State, TraceBuffer, TraceReader}; | 14 | use embassy_net_nrf91::{Runner, State, TraceBuffer, TraceReader, context}; |
| 15 | use embassy_nrf::buffered_uarte::{self, BufferedUarteTx}; | 15 | use embassy_nrf::buffered_uarte::{self, BufferedUarteTx}; |
| 16 | use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive}; | 16 | use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive}; |
| 17 | use embassy_nrf::uarte::Baudrate; | 17 | use embassy_nrf::uarte::Baudrate; |
| 18 | use embassy_nrf::{bind_interrupts, interrupt, peripherals, uarte, Peri}; | 18 | use embassy_nrf::{Peri, bind_interrupts, interrupt, peripherals, uarte}; |
| 19 | use embassy_time::{Duration, Timer}; | 19 | use embassy_time::{Duration, Timer}; |
| 20 | use embedded_io_async::Write; | 20 | use embedded_io_async::Write; |
| 21 | use heapless::Vec; | 21 | use heapless::Vec; |
| @@ -32,7 +32,7 @@ bind_interrupts!(struct Irqs { | |||
| 32 | }); | 32 | }); |
| 33 | 33 | ||
| 34 | #[embassy_executor::task] | 34 | #[embassy_executor::task] |
| 35 | async fn trace_task(mut uart: BufferedUarteTx<'static, peripherals::SERIAL0>, reader: TraceReader<'static>) -> ! { | 35 | async fn trace_task(mut uart: BufferedUarteTx<'static>, reader: TraceReader<'static>) -> ! { |
| 36 | let mut rx = [0u8; 1024]; | 36 | let mut rx = [0u8; 1024]; |
| 37 | loop { | 37 | loop { |
| 38 | let n = reader.read(&mut rx[..]).await; | 38 | let n = reader.read(&mut rx[..]).await; |
| @@ -101,7 +101,7 @@ async fn blink_task(pin: Peri<'static, AnyPin>) { | |||
| 101 | } | 101 | } |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | extern "C" { | 104 | unsafe extern "C" { |
| 105 | static __start_ipc: u8; | 105 | static __start_ipc: u8; |
| 106 | static __end_ipc: u8; | 106 | static __end_ipc: u8; |
| 107 | } | 107 | } |
diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index 97e019cdf..640addb28 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-rp-examples" | 3 | name = "embassy-rp-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/rp/src/bin/assign_resources.rs b/examples/rp/src/bin/assign_resources.rs index 4ee4278b5..aaa134768 100644 --- a/examples/rp/src/bin/assign_resources.rs +++ b/examples/rp/src/bin/assign_resources.rs | |||
| @@ -14,9 +14,9 @@ | |||
| 14 | use assign_resources::assign_resources; | 14 | use assign_resources::assign_resources; |
| 15 | use defmt::*; | 15 | use defmt::*; |
| 16 | use embassy_executor::Spawner; | 16 | use embassy_executor::Spawner; |
| 17 | use embassy_rp::Peri; | ||
| 17 | use embassy_rp::gpio::{Level, Output}; | 18 | use embassy_rp::gpio::{Level, Output}; |
| 18 | use embassy_rp::peripherals::{self, PIN_20, PIN_21}; | 19 | use embassy_rp::peripherals::{self, PIN_20, PIN_21}; |
| 19 | use embassy_rp::Peri; | ||
| 20 | use embassy_time::Timer; | 20 | use embassy_time::Timer; |
| 21 | use {defmt_rtt as _, panic_probe as _}; | 21 | use {defmt_rtt as _, panic_probe as _}; |
| 22 | 22 | ||
diff --git a/examples/rp/src/bin/debounce.rs b/examples/rp/src/bin/debounce.rs index 0077f19fc..6eeb01d0a 100644 --- a/examples/rp/src/bin/debounce.rs +++ b/examples/rp/src/bin/debounce.rs | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | use defmt::info; | 7 | use defmt::info; |
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_rp::gpio::{Input, Level, Pull}; | 9 | use embassy_rp::gpio::{Input, Level, Pull}; |
| 10 | use embassy_time::{with_deadline, Duration, Instant, Timer}; | 10 | use embassy_time::{Duration, Instant, Timer, with_deadline}; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | pub struct Debouncer<'a> { | 13 | pub struct Debouncer<'a> { |
diff --git a/examples/rp/src/bin/ethernet_w5500_icmp_ping.rs b/examples/rp/src/bin/ethernet_w5500_icmp_ping.rs index 49d28071a..cb667f24f 100644 --- a/examples/rp/src/bin/ethernet_w5500_icmp_ping.rs +++ b/examples/rp/src/bin/ethernet_w5500_icmp_ping.rs | |||
| @@ -12,8 +12,8 @@ use core::str::FromStr; | |||
| 12 | use defmt::*; | 12 | use defmt::*; |
| 13 | use embassy_executor::Spawner; | 13 | use embassy_executor::Spawner; |
| 14 | use embassy_futures::yield_now; | 14 | use embassy_futures::yield_now; |
| 15 | use embassy_net::icmp::ping::{PingManager, PingParams}; | ||
| 16 | use embassy_net::icmp::PacketMetadata; | 15 | use embassy_net::icmp::PacketMetadata; |
| 16 | use embassy_net::icmp::ping::{PingManager, PingParams}; | ||
| 17 | use embassy_net::{Ipv4Cidr, Stack, StackResources}; | 17 | use embassy_net::{Ipv4Cidr, Stack, StackResources}; |
| 18 | use embassy_net_wiznet::chip::W5500; | 18 | use embassy_net_wiznet::chip::W5500; |
| 19 | use embassy_net_wiznet::*; | 19 | use embassy_net_wiznet::*; |
| @@ -99,7 +99,7 @@ async fn main(spawner: Spawner) { | |||
| 99 | // Create the ping manager instance | 99 | // Create the ping manager instance |
| 100 | let mut ping_manager = PingManager::new(stack, &mut rx_meta, &mut rx_buffer, &mut tx_meta, &mut tx_buffer); | 100 | let mut ping_manager = PingManager::new(stack, &mut rx_meta, &mut rx_buffer, &mut tx_meta, &mut tx_buffer); |
| 101 | let addr = "192.168.8.1"; // Address to ping to | 101 | let addr = "192.168.8.1"; // Address to ping to |
| 102 | // Create the PingParams with the target address | 102 | // Create the PingParams with the target address |
| 103 | let mut ping_params = PingParams::new(Ipv4Addr::from_str(addr).unwrap()); | 103 | let mut ping_params = PingParams::new(Ipv4Addr::from_str(addr).unwrap()); |
| 104 | // (optional) Set custom properties of the ping | 104 | // (optional) Set custom properties of the ping |
| 105 | ping_params.set_payload(b"Hello, Ping!"); // custom payload | 105 | ping_params.set_payload(b"Hello, Ping!"); // custom payload |
diff --git a/examples/rp/src/bin/ethernet_w55rp20_tcp_server.rs b/examples/rp/src/bin/ethernet_w55rp20_tcp_server.rs index f51df2df9..b402029b5 100644 --- a/examples/rp/src/bin/ethernet_w55rp20_tcp_server.rs +++ b/examples/rp/src/bin/ethernet_w55rp20_tcp_server.rs | |||
| @@ -65,7 +65,7 @@ async fn main(spawner: Spawner) { | |||
| 65 | // Construct an SPI driver backed by a PIO state machine | 65 | // Construct an SPI driver backed by a PIO state machine |
| 66 | let mut spi_cfg = SpiConfig::default(); | 66 | let mut spi_cfg = SpiConfig::default(); |
| 67 | spi_cfg.frequency = 12_500_000; // The PIO SPI program is much less stable than the actual SPI | 67 | spi_cfg.frequency = 12_500_000; // The PIO SPI program is much less stable than the actual SPI |
| 68 | // peripheral, use higher speeds at your peril | 68 | // peripheral, use higher speeds at your peril |
| 69 | let spi = Spi::new(&mut common, sm0, clk, mosi, miso, p.DMA_CH0, p.DMA_CH1, spi_cfg); | 69 | let spi = Spi::new(&mut common, sm0, clk, mosi, miso, p.DMA_CH0, p.DMA_CH1, spi_cfg); |
| 70 | 70 | ||
| 71 | // Further control pins | 71 | // Further control pins |
diff --git a/examples/rp/src/bin/interrupt.rs b/examples/rp/src/bin/interrupt.rs index 2748f778a..2605622ab 100644 --- a/examples/rp/src/bin/interrupt.rs +++ b/examples/rp/src/bin/interrupt.rs | |||
| @@ -16,8 +16,8 @@ use embassy_rp::adc::{self, Adc, Blocking}; | |||
| 16 | use embassy_rp::gpio::Pull; | 16 | use embassy_rp::gpio::Pull; |
| 17 | use embassy_rp::interrupt; | 17 | use embassy_rp::interrupt; |
| 18 | use embassy_rp::pwm::{Config, Pwm}; | 18 | use embassy_rp::pwm::{Config, Pwm}; |
| 19 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | ||
| 20 | use embassy_sync::blocking_mutex::Mutex; | 19 | use embassy_sync::blocking_mutex::Mutex; |
| 20 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | ||
| 21 | use embassy_sync::channel::Channel; | 21 | use embassy_sync::channel::Channel; |
| 22 | use embassy_time::{Duration, Ticker}; | 22 | use embassy_time::{Duration, Ticker}; |
| 23 | use portable_atomic::{AtomicU32, Ordering}; | 23 | use portable_atomic::{AtomicU32, Ordering}; |
diff --git a/examples/rp/src/bin/multicore.rs b/examples/rp/src/bin/multicore.rs index 3a6367420..d289f8020 100644 --- a/examples/rp/src/bin/multicore.rs +++ b/examples/rp/src/bin/multicore.rs | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | use defmt::*; | 8 | use defmt::*; |
| 9 | use embassy_executor::Executor; | 9 | use embassy_executor::Executor; |
| 10 | use embassy_rp::gpio::{Level, Output}; | 10 | use embassy_rp::gpio::{Level, Output}; |
| 11 | use embassy_rp::multicore::{spawn_core1, Stack}; | 11 | use embassy_rp::multicore::{Stack, spawn_core1}; |
| 12 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 12 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| 13 | use embassy_sync::channel::Channel; | 13 | use embassy_sync::channel::Channel; |
| 14 | use embassy_time::Timer; | 14 | use embassy_time::Timer; |
diff --git a/examples/rp/src/bin/multiprio.rs b/examples/rp/src/bin/multiprio.rs index 96cdf8fb1..310047505 100644 --- a/examples/rp/src/bin/multiprio.rs +++ b/examples/rp/src/bin/multiprio.rs | |||
| @@ -61,7 +61,7 @@ use defmt::{info, unwrap}; | |||
| 61 | use embassy_executor::{Executor, InterruptExecutor}; | 61 | use embassy_executor::{Executor, InterruptExecutor}; |
| 62 | use embassy_rp::interrupt; | 62 | use embassy_rp::interrupt; |
| 63 | use embassy_rp::interrupt::{InterruptExt, Priority}; | 63 | use embassy_rp::interrupt::{InterruptExt, Priority}; |
| 64 | use embassy_time::{Instant, Timer, TICK_HZ}; | 64 | use embassy_time::{Instant, TICK_HZ, Timer}; |
| 65 | use static_cell::StaticCell; | 65 | use static_cell::StaticCell; |
| 66 | use {defmt_rtt as _, panic_probe as _}; | 66 | use {defmt_rtt as _, panic_probe as _}; |
| 67 | 67 | ||
| @@ -113,12 +113,12 @@ static EXECUTOR_LOW: StaticCell<Executor> = StaticCell::new(); | |||
| 113 | 113 | ||
| 114 | #[interrupt] | 114 | #[interrupt] |
| 115 | unsafe fn SWI_IRQ_1() { | 115 | unsafe fn SWI_IRQ_1() { |
| 116 | EXECUTOR_HIGH.on_interrupt() | 116 | unsafe { EXECUTOR_HIGH.on_interrupt() } |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | #[interrupt] | 119 | #[interrupt] |
| 120 | unsafe fn SWI_IRQ_0() { | 120 | unsafe fn SWI_IRQ_0() { |
| 121 | EXECUTOR_MED.on_interrupt() | 121 | unsafe { EXECUTOR_MED.on_interrupt() } |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | #[entry] | 124 | #[entry] |
diff --git a/examples/rp/src/bin/orchestrate_tasks.rs b/examples/rp/src/bin/orchestrate_tasks.rs index 9f25e1087..cd26a5371 100644 --- a/examples/rp/src/bin/orchestrate_tasks.rs +++ b/examples/rp/src/bin/orchestrate_tasks.rs | |||
| @@ -20,11 +20,11 @@ | |||
| 20 | use assign_resources::assign_resources; | 20 | use assign_resources::assign_resources; |
| 21 | use defmt::*; | 21 | use defmt::*; |
| 22 | use embassy_executor::Spawner; | 22 | use embassy_executor::Spawner; |
| 23 | use embassy_futures::select::{select, Either}; | 23 | use embassy_futures::select::{Either, select}; |
| 24 | use embassy_rp::adc::{Adc, Channel, Config, InterruptHandler}; | 24 | use embassy_rp::adc::{Adc, Channel, Config, InterruptHandler}; |
| 25 | use embassy_rp::clocks::RoscRng; | 25 | use embassy_rp::clocks::RoscRng; |
| 26 | use embassy_rp::gpio::{Input, Pull}; | 26 | use embassy_rp::gpio::{Input, Pull}; |
| 27 | use embassy_rp::{bind_interrupts, peripherals, Peri}; | 27 | use embassy_rp::{Peri, bind_interrupts, peripherals}; |
| 28 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 28 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| 29 | use embassy_sync::mutex::Mutex; | 29 | use embassy_sync::mutex::Mutex; |
| 30 | use embassy_sync::{channel, signal}; | 30 | use embassy_sync::{channel, signal}; |
diff --git a/examples/rp/src/bin/overclock.rs b/examples/rp/src/bin/overclock.rs index 83b17308b..a98185a8e 100644 --- a/examples/rp/src/bin/overclock.rs +++ b/examples/rp/src/bin/overclock.rs | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | 7 | ||
| 8 | use defmt::*; | 8 | use defmt::*; |
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_rp::clocks::{clk_sys_freq, core_voltage, ClockConfig}; | 10 | use embassy_rp::clocks::{ClockConfig, clk_sys_freq, core_voltage}; |
| 11 | use embassy_rp::config::Config; | 11 | use embassy_rp::config::Config; |
| 12 | use embassy_rp::gpio::{Level, Output}; | 12 | use embassy_rp::gpio::{Level, Output}; |
| 13 | use embassy_time::{Duration, Instant, Timer}; | 13 | use embassy_time::{Duration, Instant, Timer}; |
diff --git a/examples/rp/src/bin/overclock_manual.rs b/examples/rp/src/bin/overclock_manual.rs index dea5cfb3c..18397f9a8 100644 --- a/examples/rp/src/bin/overclock_manual.rs +++ b/examples/rp/src/bin/overclock_manual.rs | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | 7 | ||
| 8 | use defmt::*; | 8 | use defmt::*; |
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_rp::clocks::{clk_sys_freq, core_voltage, ClockConfig, CoreVoltage, PllConfig}; | 10 | use embassy_rp::clocks::{ClockConfig, CoreVoltage, PllConfig, clk_sys_freq, core_voltage}; |
| 11 | use embassy_rp::config::Config; | 11 | use embassy_rp::config::Config; |
| 12 | use embassy_rp::gpio::{Level, Output}; | 12 | use embassy_rp::gpio::{Level, Output}; |
| 13 | use embassy_time::{Duration, Instant, Timer}; | 13 | use embassy_time::{Duration, Instant, Timer}; |
diff --git a/examples/rp/src/bin/pio_async.rs b/examples/rp/src/bin/pio_async.rs index 1743a417e..55e983c36 100644 --- a/examples/rp/src/bin/pio_async.rs +++ b/examples/rp/src/bin/pio_async.rs | |||
| @@ -7,7 +7,7 @@ use embassy_executor::Spawner; | |||
| 7 | use embassy_rp::peripherals::PIO0; | 7 | use embassy_rp::peripherals::PIO0; |
| 8 | use embassy_rp::pio::program::pio_asm; | 8 | use embassy_rp::pio::program::pio_asm; |
| 9 | use embassy_rp::pio::{Common, Config, InterruptHandler, Irq, Pio, PioPin, ShiftDirection, StateMachine}; | 9 | use embassy_rp::pio::{Common, Config, InterruptHandler, Irq, Pio, PioPin, ShiftDirection, StateMachine}; |
| 10 | use embassy_rp::{bind_interrupts, Peri}; | 10 | use embassy_rp::{Peri, bind_interrupts}; |
| 11 | use fixed::traits::ToFixed; | 11 | use fixed::traits::ToFixed; |
| 12 | use fixed_macro::types::U56F8; | 12 | use fixed_macro::types::U56F8; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
diff --git a/examples/rp/src/bin/pio_stepper.rs b/examples/rp/src/bin/pio_stepper.rs index 3862c248b..e8f203990 100644 --- a/examples/rp/src/bin/pio_stepper.rs +++ b/examples/rp/src/bin/pio_stepper.rs | |||
| @@ -10,7 +10,7 @@ use embassy_rp::bind_interrupts; | |||
| 10 | use embassy_rp::peripherals::PIO0; | 10 | use embassy_rp::peripherals::PIO0; |
| 11 | use embassy_rp::pio::{InterruptHandler, Pio}; | 11 | use embassy_rp::pio::{InterruptHandler, Pio}; |
| 12 | use embassy_rp::pio_programs::stepper::{PioStepper, PioStepperProgram}; | 12 | use embassy_rp::pio_programs::stepper::{PioStepper, PioStepperProgram}; |
| 13 | use embassy_time::{with_timeout, Duration, Timer}; | 13 | use embassy_time::{Duration, Timer, with_timeout}; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 15 | ||
| 16 | bind_interrupts!(struct Irqs { | 16 | bind_interrupts!(struct Irqs { |
diff --git a/examples/rp/src/bin/pwm.rs b/examples/rp/src/bin/pwm.rs index 9dd07ab6e..f985bf7cf 100644 --- a/examples/rp/src/bin/pwm.rs +++ b/examples/rp/src/bin/pwm.rs | |||
| @@ -9,9 +9,9 @@ | |||
| 9 | 9 | ||
| 10 | use defmt::*; | 10 | use defmt::*; |
| 11 | use embassy_executor::Spawner; | 11 | use embassy_executor::Spawner; |
| 12 | use embassy_rp::peripherals::{PIN_25, PIN_4, PWM_SLICE2, PWM_SLICE4}; | ||
| 13 | use embassy_rp::pwm::{Config, Pwm, SetDutyCycle}; | ||
| 14 | use embassy_rp::Peri; | 12 | use embassy_rp::Peri; |
| 13 | use embassy_rp::peripherals::{PIN_4, PIN_25, PWM_SLICE2, PWM_SLICE4}; | ||
| 14 | use embassy_rp::pwm::{Config, Pwm, SetDutyCycle}; | ||
| 15 | use embassy_time::Timer; | 15 | use embassy_time::Timer; |
| 16 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
| 17 | 17 | ||
diff --git a/examples/rp/src/bin/rtc_alarm.rs b/examples/rp/src/bin/rtc_alarm.rs index 94b5fbd27..bde49ccd5 100644 --- a/examples/rp/src/bin/rtc_alarm.rs +++ b/examples/rp/src/bin/rtc_alarm.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | use defmt::*; | 6 | use defmt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_futures::select::{select, Either}; | 8 | use embassy_futures::select::{Either, select}; |
| 9 | use embassy_rp::bind_interrupts; | 9 | use embassy_rp::bind_interrupts; |
| 10 | use embassy_rp::rtc::{DateTime, DateTimeFilter, DayOfWeek, Rtc}; | 10 | use embassy_rp::rtc::{DateTime, DateTimeFilter, DayOfWeek, Rtc}; |
| 11 | use embassy_time::Timer; | 11 | use embassy_time::Timer; |
diff --git a/examples/rp/src/bin/sharing.rs b/examples/rp/src/bin/sharing.rs index d4c89946b..618ab9117 100644 --- a/examples/rp/src/bin/sharing.rs +++ b/examples/rp/src/bin/sharing.rs | |||
| @@ -52,7 +52,7 @@ bind_interrupts!(struct Irqs { | |||
| 52 | 52 | ||
| 53 | #[interrupt] | 53 | #[interrupt] |
| 54 | unsafe fn SWI_IRQ_0() { | 54 | unsafe fn SWI_IRQ_0() { |
| 55 | EXECUTOR_HI.on_interrupt() | 55 | unsafe { EXECUTOR_HI.on_interrupt() } |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | #[entry] | 58 | #[entry] |
diff --git a/examples/rp/src/bin/spi_display.rs b/examples/rp/src/bin/spi_display.rs index dd114a4ae..4bf924e56 100644 --- a/examples/rp/src/bin/spi_display.rs +++ b/examples/rp/src/bin/spi_display.rs | |||
| @@ -15,19 +15,19 @@ use embassy_executor::Spawner; | |||
| 15 | use embassy_rp::gpio::{Level, Output}; | 15 | use embassy_rp::gpio::{Level, Output}; |
| 16 | use embassy_rp::spi; | 16 | use embassy_rp::spi; |
| 17 | use embassy_rp::spi::Spi; | 17 | use embassy_rp::spi::Spi; |
| 18 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | ||
| 19 | use embassy_sync::blocking_mutex::Mutex; | 18 | use embassy_sync::blocking_mutex::Mutex; |
| 19 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | ||
| 20 | use embassy_time::Delay; | 20 | use embassy_time::Delay; |
| 21 | use embedded_graphics::image::{Image, ImageRawLE}; | 21 | use embedded_graphics::image::{Image, ImageRawLE}; |
| 22 | use embedded_graphics::mono_font::ascii::FONT_10X20; | ||
| 23 | use embedded_graphics::mono_font::MonoTextStyle; | 22 | use embedded_graphics::mono_font::MonoTextStyle; |
| 23 | use embedded_graphics::mono_font::ascii::FONT_10X20; | ||
| 24 | use embedded_graphics::pixelcolor::Rgb565; | 24 | use embedded_graphics::pixelcolor::Rgb565; |
| 25 | use embedded_graphics::prelude::*; | 25 | use embedded_graphics::prelude::*; |
| 26 | use embedded_graphics::primitives::{PrimitiveStyleBuilder, Rectangle}; | 26 | use embedded_graphics::primitives::{PrimitiveStyleBuilder, Rectangle}; |
| 27 | use embedded_graphics::text::Text; | 27 | use embedded_graphics::text::Text; |
| 28 | use mipidsi::Builder; | ||
| 28 | use mipidsi::models::ST7789; | 29 | use mipidsi::models::ST7789; |
| 29 | use mipidsi::options::{Orientation, Rotation}; | 30 | use mipidsi::options::{Orientation, Rotation}; |
| 30 | use mipidsi::Builder; | ||
| 31 | use {defmt_rtt as _, panic_probe as _}; | 31 | use {defmt_rtt as _, panic_probe as _}; |
| 32 | 32 | ||
| 33 | use crate::touch::Touch; | 33 | use crate::touch::Touch; |
| @@ -167,11 +167,7 @@ mod touch { | |||
| 167 | 167 | ||
| 168 | let x = ((x - cal.x1) * cal.sx / (cal.x2 - cal.x1)).clamp(0, cal.sx); | 168 | let x = ((x - cal.x1) * cal.sx / (cal.x2 - cal.x1)).clamp(0, cal.sx); |
| 169 | let y = ((y - cal.y1) * cal.sy / (cal.y2 - cal.y1)).clamp(0, cal.sy); | 169 | let y = ((y - cal.y1) * cal.sy / (cal.y2 - cal.y1)).clamp(0, cal.sy); |
| 170 | if x == 0 && y == 0 { | 170 | if x == 0 && y == 0 { None } else { Some((x, y)) } |
| 171 | None | ||
| 172 | } else { | ||
| 173 | Some((x, y)) | ||
| 174 | } | ||
| 175 | } | 171 | } |
| 176 | } | 172 | } |
| 177 | } | 173 | } |
diff --git a/examples/rp/src/bin/spi_gc9a01.rs b/examples/rp/src/bin/spi_gc9a01.rs index fdef09d4b..fd007b9bd 100644 --- a/examples/rp/src/bin/spi_gc9a01.rs +++ b/examples/rp/src/bin/spi_gc9a01.rs | |||
| @@ -16,16 +16,16 @@ use embassy_rp::clocks::RoscRng; | |||
| 16 | use embassy_rp::gpio::{Level, Output}; | 16 | use embassy_rp::gpio::{Level, Output}; |
| 17 | use embassy_rp::spi; | 17 | use embassy_rp::spi; |
| 18 | use embassy_rp::spi::{Blocking, Spi}; | 18 | use embassy_rp::spi::{Blocking, Spi}; |
| 19 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | ||
| 20 | use embassy_sync::blocking_mutex::Mutex; | 19 | use embassy_sync::blocking_mutex::Mutex; |
| 20 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | ||
| 21 | use embassy_time::{Delay, Duration, Timer}; | 21 | use embassy_time::{Delay, Duration, Timer}; |
| 22 | use embedded_graphics::image::{Image, ImageRawLE}; | 22 | use embedded_graphics::image::{Image, ImageRawLE}; |
| 23 | use embedded_graphics::pixelcolor::Rgb565; | 23 | use embedded_graphics::pixelcolor::Rgb565; |
| 24 | use embedded_graphics::prelude::*; | 24 | use embedded_graphics::prelude::*; |
| 25 | use embedded_graphics::primitives::{PrimitiveStyleBuilder, Rectangle}; | 25 | use embedded_graphics::primitives::{PrimitiveStyleBuilder, Rectangle}; |
| 26 | use mipidsi::Builder; | ||
| 26 | use mipidsi::models::GC9A01; | 27 | use mipidsi::models::GC9A01; |
| 27 | use mipidsi::options::{ColorInversion, ColorOrder}; | 28 | use mipidsi::options::{ColorInversion, ColorOrder}; |
| 28 | use mipidsi::Builder; | ||
| 29 | use {defmt_rtt as _, panic_probe as _}; | 29 | use {defmt_rtt as _, panic_probe as _}; |
| 30 | 30 | ||
| 31 | const DISPLAY_FREQ: u32 = 64_000_000; | 31 | const DISPLAY_FREQ: u32 = 64_000_000; |
diff --git a/examples/rp/src/bin/uart_r503.rs b/examples/rp/src/bin/uart_r503.rs index 085be280b..a25d45b18 100644 --- a/examples/rp/src/bin/uart_r503.rs +++ b/examples/rp/src/bin/uart_r503.rs | |||
| @@ -6,7 +6,7 @@ use embassy_executor::Spawner; | |||
| 6 | use embassy_rp::bind_interrupts; | 6 | use embassy_rp::bind_interrupts; |
| 7 | use embassy_rp::peripherals::UART0; | 7 | use embassy_rp::peripherals::UART0; |
| 8 | use embassy_rp::uart::{Config, DataBits, InterruptHandler as UARTInterruptHandler, Parity, StopBits, Uart}; | 8 | use embassy_rp::uart::{Config, DataBits, InterruptHandler as UARTInterruptHandler, Parity, StopBits, Uart}; |
| 9 | use embassy_time::{with_timeout, Duration, Timer}; | 9 | use embassy_time::{Duration, Timer, with_timeout}; |
| 10 | use heapless::Vec; | 10 | use heapless::Vec; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
diff --git a/examples/rp/src/bin/usb_ethernet.rs b/examples/rp/src/bin/usb_ethernet.rs index 912e52e96..b62a602b1 100644 --- a/examples/rp/src/bin/usb_ethernet.rs +++ b/examples/rp/src/bin/usb_ethernet.rs | |||
| @@ -7,8 +7,8 @@ | |||
| 7 | 7 | ||
| 8 | use defmt::*; | 8 | use defmt::*; |
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_net::tcp::TcpSocket; | ||
| 11 | use embassy_net::StackResources; | 10 | use embassy_net::StackResources; |
| 11 | use embassy_net::tcp::TcpSocket; | ||
| 12 | use embassy_rp::clocks::RoscRng; | 12 | use embassy_rp::clocks::RoscRng; |
| 13 | use embassy_rp::peripherals::USB; | 13 | use embassy_rp::peripherals::USB; |
| 14 | use embassy_rp::usb::{Driver, InterruptHandler}; | 14 | use embassy_rp::usb::{Driver, InterruptHandler}; |
diff --git a/examples/rp/src/bin/usb_serial.rs b/examples/rp/src/bin/usb_serial.rs index b79012acb..23d0c9e8b 100644 --- a/examples/rp/src/bin/usb_serial.rs +++ b/examples/rp/src/bin/usb_serial.rs | |||
| @@ -10,9 +10,9 @@ use embassy_executor::Spawner; | |||
| 10 | use embassy_rp::bind_interrupts; | 10 | use embassy_rp::bind_interrupts; |
| 11 | use embassy_rp::peripherals::USB; | 11 | use embassy_rp::peripherals::USB; |
| 12 | use embassy_rp::usb::{Driver, Instance, InterruptHandler}; | 12 | use embassy_rp::usb::{Driver, Instance, InterruptHandler}; |
| 13 | use embassy_usb::UsbDevice; | ||
| 13 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 14 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 14 | use embassy_usb::driver::EndpointError; | 15 | use embassy_usb::driver::EndpointError; |
| 15 | use embassy_usb::UsbDevice; | ||
| 16 | use static_cell::StaticCell; | 16 | use static_cell::StaticCell; |
| 17 | use {defmt_rtt as _, panic_probe as _}; | 17 | use {defmt_rtt as _, panic_probe as _}; |
| 18 | 18 | ||
diff --git a/examples/rp/src/bin/wifi_ap_tcp_server.rs b/examples/rp/src/bin/wifi_ap_tcp_server.rs index 128599e0d..0828dbbb9 100644 --- a/examples/rp/src/bin/wifi_ap_tcp_server.rs +++ b/examples/rp/src/bin/wifi_ap_tcp_server.rs | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | 7 | ||
| 8 | use core::str::from_utf8; | 8 | use core::str::from_utf8; |
| 9 | 9 | ||
| 10 | use cyw43_pio::{PioSpi, DEFAULT_CLOCK_DIVIDER}; | 10 | use cyw43_pio::{DEFAULT_CLOCK_DIVIDER, PioSpi}; |
| 11 | use defmt::*; | 11 | use defmt::*; |
| 12 | use embassy_executor::Spawner; | 12 | use embassy_executor::Spawner; |
| 13 | use embassy_net::tcp::TcpSocket; | 13 | use embassy_net::tcp::TcpSocket; |
diff --git a/examples/rp/src/bin/wifi_blinky.rs b/examples/rp/src/bin/wifi_blinky.rs index b2e08c517..aa6ee4df0 100644 --- a/examples/rp/src/bin/wifi_blinky.rs +++ b/examples/rp/src/bin/wifi_blinky.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | #![no_std] | 5 | #![no_std] |
| 6 | #![no_main] | 6 | #![no_main] |
| 7 | 7 | ||
| 8 | use cyw43_pio::{PioSpi, DEFAULT_CLOCK_DIVIDER}; | 8 | use cyw43_pio::{DEFAULT_CLOCK_DIVIDER, PioSpi}; |
| 9 | use defmt::*; | 9 | use defmt::*; |
| 10 | use embassy_executor::Spawner; | 10 | use embassy_executor::Spawner; |
| 11 | use embassy_rp::bind_interrupts; | 11 | use embassy_rp::bind_interrupts; |
diff --git a/examples/rp/src/bin/wifi_scan.rs b/examples/rp/src/bin/wifi_scan.rs index c884aa2ba..7e3de1db9 100644 --- a/examples/rp/src/bin/wifi_scan.rs +++ b/examples/rp/src/bin/wifi_scan.rs | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | 7 | ||
| 8 | use core::str; | 8 | use core::str; |
| 9 | 9 | ||
| 10 | use cyw43_pio::{PioSpi, DEFAULT_CLOCK_DIVIDER}; | 10 | use cyw43_pio::{DEFAULT_CLOCK_DIVIDER, PioSpi}; |
| 11 | use defmt::*; | 11 | use defmt::*; |
| 12 | use embassy_executor::Spawner; | 12 | use embassy_executor::Spawner; |
| 13 | use embassy_rp::bind_interrupts; | 13 | use embassy_rp::bind_interrupts; |
diff --git a/examples/rp/src/bin/wifi_tcp_server.rs b/examples/rp/src/bin/wifi_tcp_server.rs index 126475779..e39de4902 100644 --- a/examples/rp/src/bin/wifi_tcp_server.rs +++ b/examples/rp/src/bin/wifi_tcp_server.rs | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | use core::str::from_utf8; | 8 | use core::str::from_utf8; |
| 9 | 9 | ||
| 10 | use cyw43::JoinOptions; | 10 | use cyw43::JoinOptions; |
| 11 | use cyw43_pio::{PioSpi, DEFAULT_CLOCK_DIVIDER}; | 11 | use cyw43_pio::{DEFAULT_CLOCK_DIVIDER, PioSpi}; |
| 12 | use defmt::*; | 12 | use defmt::*; |
| 13 | use embassy_executor::Spawner; | 13 | use embassy_executor::Spawner; |
| 14 | use embassy_net::tcp::TcpSocket; | 14 | use embassy_net::tcp::TcpSocket; |
diff --git a/examples/rp/src/bin/wifi_webrequest.rs b/examples/rp/src/bin/wifi_webrequest.rs index 079def370..b618d2b38 100644 --- a/examples/rp/src/bin/wifi_webrequest.rs +++ b/examples/rp/src/bin/wifi_webrequest.rs | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | use core::str::from_utf8; | 8 | use core::str::from_utf8; |
| 9 | 9 | ||
| 10 | use cyw43::JoinOptions; | 10 | use cyw43::JoinOptions; |
| 11 | use cyw43_pio::{PioSpi, DEFAULT_CLOCK_DIVIDER}; | 11 | use cyw43_pio::{DEFAULT_CLOCK_DIVIDER, PioSpi}; |
| 12 | use defmt::*; | 12 | use defmt::*; |
| 13 | use embassy_executor::Spawner; | 13 | use embassy_executor::Spawner; |
| 14 | use embassy_net::dns::DnsSocket; | 14 | use embassy_net::dns::DnsSocket; |
diff --git a/examples/rp/src/bin/zerocopy.rs b/examples/rp/src/bin/zerocopy.rs index d603e1ed3..fc5f95e6e 100644 --- a/examples/rp/src/bin/zerocopy.rs +++ b/examples/rp/src/bin/zerocopy.rs | |||
| @@ -11,7 +11,7 @@ use embassy_executor::Spawner; | |||
| 11 | use embassy_rp::adc::{self, Adc, Async, Config, InterruptHandler}; | 11 | use embassy_rp::adc::{self, Adc, Async, Config, InterruptHandler}; |
| 12 | use embassy_rp::gpio::Pull; | 12 | use embassy_rp::gpio::Pull; |
| 13 | use embassy_rp::peripherals::DMA_CH0; | 13 | use embassy_rp::peripherals::DMA_CH0; |
| 14 | use embassy_rp::{bind_interrupts, Peri}; | 14 | use embassy_rp::{Peri, bind_interrupts}; |
| 15 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | 15 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; |
| 16 | use embassy_sync::zerocopy_channel::{Channel, Receiver, Sender}; | 16 | use embassy_sync::zerocopy_channel::{Channel, Receiver, Sender}; |
| 17 | use embassy_time::{Duration, Ticker, Timer}; | 17 | use embassy_time::{Duration, Ticker, Timer}; |
diff --git a/examples/rp235x/Cargo.toml b/examples/rp235x/Cargo.toml index 40fbb5798..39a4f421a 100644 --- a/examples/rp235x/Cargo.toml +++ b/examples/rp235x/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-rp2350-examples" | 3 | name = "embassy-rp2350-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/rp235x/src/bin/assign_resources.rs b/examples/rp235x/src/bin/assign_resources.rs index 4ee4278b5..aaa134768 100644 --- a/examples/rp235x/src/bin/assign_resources.rs +++ b/examples/rp235x/src/bin/assign_resources.rs | |||
| @@ -14,9 +14,9 @@ | |||
| 14 | use assign_resources::assign_resources; | 14 | use assign_resources::assign_resources; |
| 15 | use defmt::*; | 15 | use defmt::*; |
| 16 | use embassy_executor::Spawner; | 16 | use embassy_executor::Spawner; |
| 17 | use embassy_rp::Peri; | ||
| 17 | use embassy_rp::gpio::{Level, Output}; | 18 | use embassy_rp::gpio::{Level, Output}; |
| 18 | use embassy_rp::peripherals::{self, PIN_20, PIN_21}; | 19 | use embassy_rp::peripherals::{self, PIN_20, PIN_21}; |
| 19 | use embassy_rp::Peri; | ||
| 20 | use embassy_time::Timer; | 20 | use embassy_time::Timer; |
| 21 | use {defmt_rtt as _, panic_probe as _}; | 21 | use {defmt_rtt as _, panic_probe as _}; |
| 22 | 22 | ||
diff --git a/examples/rp235x/src/bin/debounce.rs b/examples/rp235x/src/bin/debounce.rs index 0077f19fc..6eeb01d0a 100644 --- a/examples/rp235x/src/bin/debounce.rs +++ b/examples/rp235x/src/bin/debounce.rs | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | use defmt::info; | 7 | use defmt::info; |
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_rp::gpio::{Input, Level, Pull}; | 9 | use embassy_rp::gpio::{Input, Level, Pull}; |
| 10 | use embassy_time::{with_deadline, Duration, Instant, Timer}; | 10 | use embassy_time::{Duration, Instant, Timer, with_deadline}; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | pub struct Debouncer<'a> { | 13 | pub struct Debouncer<'a> { |
diff --git a/examples/rp235x/src/bin/ethernet_w5500_icmp_ping.rs b/examples/rp235x/src/bin/ethernet_w5500_icmp_ping.rs index 309d3e4f7..227e68029 100644 --- a/examples/rp235x/src/bin/ethernet_w5500_icmp_ping.rs +++ b/examples/rp235x/src/bin/ethernet_w5500_icmp_ping.rs | |||
| @@ -12,8 +12,8 @@ use core::str::FromStr; | |||
| 12 | use defmt::*; | 12 | use defmt::*; |
| 13 | use embassy_executor::Spawner; | 13 | use embassy_executor::Spawner; |
| 14 | use embassy_futures::yield_now; | 14 | use embassy_futures::yield_now; |
| 15 | use embassy_net::icmp::ping::{PingManager, PingParams}; | ||
| 16 | use embassy_net::icmp::PacketMetadata; | 15 | use embassy_net::icmp::PacketMetadata; |
| 16 | use embassy_net::icmp::ping::{PingManager, PingParams}; | ||
| 17 | use embassy_net::{Ipv4Cidr, Stack, StackResources}; | 17 | use embassy_net::{Ipv4Cidr, Stack, StackResources}; |
| 18 | use embassy_net_wiznet::chip::W5500; | 18 | use embassy_net_wiznet::chip::W5500; |
| 19 | use embassy_net_wiznet::*; | 19 | use embassy_net_wiznet::*; |
| @@ -99,7 +99,7 @@ async fn main(spawner: Spawner) { | |||
| 99 | // Create the ping manager instance | 99 | // Create the ping manager instance |
| 100 | let mut ping_manager = PingManager::new(stack, &mut rx_meta, &mut rx_buffer, &mut tx_meta, &mut tx_buffer); | 100 | let mut ping_manager = PingManager::new(stack, &mut rx_meta, &mut rx_buffer, &mut tx_meta, &mut tx_buffer); |
| 101 | let addr = "192.168.8.1"; // Address to ping to | 101 | let addr = "192.168.8.1"; // Address to ping to |
| 102 | // Create the PingParams with the target address | 102 | // Create the PingParams with the target address |
| 103 | let mut ping_params = PingParams::new(Ipv4Addr::from_str(addr).unwrap()); | 103 | let mut ping_params = PingParams::new(Ipv4Addr::from_str(addr).unwrap()); |
| 104 | // (optional) Set custom properties of the ping | 104 | // (optional) Set custom properties of the ping |
| 105 | ping_params.set_payload(b"Hello, Ping!"); // custom payload | 105 | ping_params.set_payload(b"Hello, Ping!"); // custom payload |
diff --git a/examples/rp235x/src/bin/interrupt.rs b/examples/rp235x/src/bin/interrupt.rs index 88513180c..1b18f6931 100644 --- a/examples/rp235x/src/bin/interrupt.rs +++ b/examples/rp235x/src/bin/interrupt.rs | |||
| @@ -16,8 +16,8 @@ use embassy_rp::adc::{self, Adc, Blocking}; | |||
| 16 | use embassy_rp::gpio::Pull; | 16 | use embassy_rp::gpio::Pull; |
| 17 | use embassy_rp::interrupt; | 17 | use embassy_rp::interrupt; |
| 18 | use embassy_rp::pwm::{Config, Pwm}; | 18 | use embassy_rp::pwm::{Config, Pwm}; |
| 19 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | ||
| 20 | use embassy_sync::blocking_mutex::Mutex; | 19 | use embassy_sync::blocking_mutex::Mutex; |
| 20 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | ||
| 21 | use embassy_sync::channel::Channel; | 21 | use embassy_sync::channel::Channel; |
| 22 | use embassy_time::{Duration, Ticker}; | 22 | use embassy_time::{Duration, Ticker}; |
| 23 | use portable_atomic::{AtomicU32, Ordering}; | 23 | use portable_atomic::{AtomicU32, Ordering}; |
diff --git a/examples/rp235x/src/bin/multicore.rs b/examples/rp235x/src/bin/multicore.rs index 4f82801d6..9b61fdbca 100644 --- a/examples/rp235x/src/bin/multicore.rs +++ b/examples/rp235x/src/bin/multicore.rs | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | use defmt::*; | 8 | use defmt::*; |
| 9 | use embassy_executor::Executor; | 9 | use embassy_executor::Executor; |
| 10 | use embassy_rp::gpio::{Level, Output}; | 10 | use embassy_rp::gpio::{Level, Output}; |
| 11 | use embassy_rp::multicore::{spawn_core1, Stack}; | 11 | use embassy_rp::multicore::{Stack, spawn_core1}; |
| 12 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 12 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| 13 | use embassy_sync::channel::Channel; | 13 | use embassy_sync::channel::Channel; |
| 14 | use embassy_time::Timer; | 14 | use embassy_time::Timer; |
diff --git a/examples/rp235x/src/bin/multicore_stack_overflow.rs b/examples/rp235x/src/bin/multicore_stack_overflow.rs index dba44aa23..9efe89318 100644 --- a/examples/rp235x/src/bin/multicore_stack_overflow.rs +++ b/examples/rp235x/src/bin/multicore_stack_overflow.rs | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | use defmt::*; | 6 | use defmt::*; |
| 7 | use embassy_executor::Executor; | 7 | use embassy_executor::Executor; |
| 8 | use embassy_rp::gpio::{Level, Output}; | 8 | use embassy_rp::gpio::{Level, Output}; |
| 9 | use embassy_rp::multicore::{spawn_core1, Stack}; | 9 | use embassy_rp::multicore::{Stack, spawn_core1}; |
| 10 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 11 | use static_cell::StaticCell; | 11 | use static_cell::StaticCell; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
diff --git a/examples/rp235x/src/bin/multiprio.rs b/examples/rp235x/src/bin/multiprio.rs index 96cdf8fb1..310047505 100644 --- a/examples/rp235x/src/bin/multiprio.rs +++ b/examples/rp235x/src/bin/multiprio.rs | |||
| @@ -61,7 +61,7 @@ use defmt::{info, unwrap}; | |||
| 61 | use embassy_executor::{Executor, InterruptExecutor}; | 61 | use embassy_executor::{Executor, InterruptExecutor}; |
| 62 | use embassy_rp::interrupt; | 62 | use embassy_rp::interrupt; |
| 63 | use embassy_rp::interrupt::{InterruptExt, Priority}; | 63 | use embassy_rp::interrupt::{InterruptExt, Priority}; |
| 64 | use embassy_time::{Instant, Timer, TICK_HZ}; | 64 | use embassy_time::{Instant, TICK_HZ, Timer}; |
| 65 | use static_cell::StaticCell; | 65 | use static_cell::StaticCell; |
| 66 | use {defmt_rtt as _, panic_probe as _}; | 66 | use {defmt_rtt as _, panic_probe as _}; |
| 67 | 67 | ||
| @@ -113,12 +113,12 @@ static EXECUTOR_LOW: StaticCell<Executor> = StaticCell::new(); | |||
| 113 | 113 | ||
| 114 | #[interrupt] | 114 | #[interrupt] |
| 115 | unsafe fn SWI_IRQ_1() { | 115 | unsafe fn SWI_IRQ_1() { |
| 116 | EXECUTOR_HIGH.on_interrupt() | 116 | unsafe { EXECUTOR_HIGH.on_interrupt() } |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | #[interrupt] | 119 | #[interrupt] |
| 120 | unsafe fn SWI_IRQ_0() { | 120 | unsafe fn SWI_IRQ_0() { |
| 121 | EXECUTOR_MED.on_interrupt() | 121 | unsafe { EXECUTOR_MED.on_interrupt() } |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | #[entry] | 124 | #[entry] |
diff --git a/examples/rp235x/src/bin/overclock.rs b/examples/rp235x/src/bin/overclock.rs index 5fd97ef97..cba137f3a 100644 --- a/examples/rp235x/src/bin/overclock.rs +++ b/examples/rp235x/src/bin/overclock.rs | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | use defmt::*; | 13 | use defmt::*; |
| 14 | use embassy_executor::Spawner; | 14 | use embassy_executor::Spawner; |
| 15 | use embassy_rp::clocks::{clk_sys_freq, core_voltage, ClockConfig, CoreVoltage}; | 15 | use embassy_rp::clocks::{ClockConfig, CoreVoltage, clk_sys_freq, core_voltage}; |
| 16 | use embassy_rp::config::Config; | 16 | use embassy_rp::config::Config; |
| 17 | use embassy_rp::gpio::{Level, Output}; | 17 | use embassy_rp::gpio::{Level, Output}; |
| 18 | use embassy_time::{Duration, Instant, Timer}; | 18 | use embassy_time::{Duration, Instant, Timer}; |
diff --git a/examples/rp235x/src/bin/pio_async.rs b/examples/rp235x/src/bin/pio_async.rs index d76930f5c..a392fe37e 100644 --- a/examples/rp235x/src/bin/pio_async.rs +++ b/examples/rp235x/src/bin/pio_async.rs | |||
| @@ -7,7 +7,7 @@ use embassy_executor::Spawner; | |||
| 7 | use embassy_rp::peripherals::PIO0; | 7 | use embassy_rp::peripherals::PIO0; |
| 8 | use embassy_rp::pio::program::pio_asm; | 8 | use embassy_rp::pio::program::pio_asm; |
| 9 | use embassy_rp::pio::{Common, Config, InterruptHandler, Irq, Pio, PioPin, ShiftDirection, StateMachine}; | 9 | use embassy_rp::pio::{Common, Config, InterruptHandler, Irq, Pio, PioPin, ShiftDirection, StateMachine}; |
| 10 | use embassy_rp::{bind_interrupts, Peri}; | 10 | use embassy_rp::{Peri, bind_interrupts}; |
| 11 | use fixed::traits::ToFixed; | 11 | use fixed::traits::ToFixed; |
| 12 | use fixed_macro::types::U56F8; | 12 | use fixed_macro::types::U56F8; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
diff --git a/examples/rp235x/src/bin/pio_i2s_rx.rs b/examples/rp235x/src/bin/pio_i2s_rx.rs index c3f505b13..6735c402f 100644 --- a/examples/rp235x/src/bin/pio_i2s_rx.rs +++ b/examples/rp235x/src/bin/pio_i2s_rx.rs | |||
| @@ -34,7 +34,7 @@ const SAMPLE_RATE: u32 = 48_000; | |||
| 34 | const BIT_DEPTH: u32 = 16; | 34 | const BIT_DEPTH: u32 = 16; |
| 35 | const CHANNELS: u32 = 2; | 35 | const CHANNELS: u32 = 2; |
| 36 | const USE_ONBOARD_PULLDOWN: bool = false; // whether or not to use the onboard pull-down resistor, | 36 | const USE_ONBOARD_PULLDOWN: bool = false; // whether or not to use the onboard pull-down resistor, |
| 37 | // which has documented issues on many RP235x boards | 37 | // which has documented issues on many RP235x boards |
| 38 | #[embassy_executor::main] | 38 | #[embassy_executor::main] |
| 39 | async fn main(_spawner: Spawner) { | 39 | async fn main(_spawner: Spawner) { |
| 40 | let p = embassy_rp::init(Default::default()); | 40 | let p = embassy_rp::init(Default::default()); |
diff --git a/examples/rp235x/src/bin/pio_rotary_encoder_rxf.rs b/examples/rp235x/src/bin/pio_rotary_encoder_rxf.rs index 61af94560..948699e40 100644 --- a/examples/rp235x/src/bin/pio_rotary_encoder_rxf.rs +++ b/examples/rp235x/src/bin/pio_rotary_encoder_rxf.rs | |||
| @@ -9,7 +9,7 @@ use embassy_executor::Spawner; | |||
| 9 | use embassy_rp::gpio::Pull; | 9 | use embassy_rp::gpio::Pull; |
| 10 | use embassy_rp::peripherals::PIO0; | 10 | use embassy_rp::peripherals::PIO0; |
| 11 | use embassy_rp::pio::program::pio_asm; | 11 | use embassy_rp::pio::program::pio_asm; |
| 12 | use embassy_rp::{bind_interrupts, pio, Peri}; | 12 | use embassy_rp::{Peri, bind_interrupts, pio}; |
| 13 | use embassy_time::Timer; | 13 | use embassy_time::Timer; |
| 14 | use fixed::traits::ToFixed; | 14 | use fixed::traits::ToFixed; |
| 15 | use pio::{Common, Config, FifoJoin, Instance, InterruptHandler, Pio, PioPin, ShiftDirection, StateMachine}; | 15 | use pio::{Common, Config, FifoJoin, Instance, InterruptHandler, Pio, PioPin, ShiftDirection, StateMachine}; |
diff --git a/examples/rp235x/src/bin/pio_stepper.rs b/examples/rp235x/src/bin/pio_stepper.rs index 931adbeda..9b33710ad 100644 --- a/examples/rp235x/src/bin/pio_stepper.rs +++ b/examples/rp235x/src/bin/pio_stepper.rs | |||
| @@ -10,7 +10,7 @@ use embassy_rp::bind_interrupts; | |||
| 10 | use embassy_rp::peripherals::PIO0; | 10 | use embassy_rp::peripherals::PIO0; |
| 11 | use embassy_rp::pio::{InterruptHandler, Pio}; | 11 | use embassy_rp::pio::{InterruptHandler, Pio}; |
| 12 | use embassy_rp::pio_programs::stepper::{PioStepper, PioStepperProgram}; | 12 | use embassy_rp::pio_programs::stepper::{PioStepper, PioStepperProgram}; |
| 13 | use embassy_time::{with_timeout, Duration, Timer}; | 13 | use embassy_time::{Duration, Timer, with_timeout}; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 15 | ||
| 16 | bind_interrupts!(struct Irqs { | 16 | bind_interrupts!(struct Irqs { |
diff --git a/examples/rp235x/src/bin/pwm.rs b/examples/rp235x/src/bin/pwm.rs index 289480c85..971e86aa7 100644 --- a/examples/rp235x/src/bin/pwm.rs +++ b/examples/rp235x/src/bin/pwm.rs | |||
| @@ -9,9 +9,9 @@ | |||
| 9 | 9 | ||
| 10 | use defmt::*; | 10 | use defmt::*; |
| 11 | use embassy_executor::Spawner; | 11 | use embassy_executor::Spawner; |
| 12 | use embassy_rp::peripherals::{PIN_25, PIN_4, PWM_SLICE2, PWM_SLICE4}; | ||
| 13 | use embassy_rp::pwm::{Config, Pwm, SetDutyCycle}; | ||
| 14 | use embassy_rp::Peri; | 12 | use embassy_rp::Peri; |
| 13 | use embassy_rp::peripherals::{PIN_4, PIN_25, PWM_SLICE2, PWM_SLICE4}; | ||
| 14 | use embassy_rp::pwm::{Config, Pwm, SetDutyCycle}; | ||
| 15 | use embassy_time::Timer; | 15 | use embassy_time::Timer; |
| 16 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
| 17 | 17 | ||
diff --git a/examples/rp235x/src/bin/pwm_tb6612fng_motor_driver.rs b/examples/rp235x/src/bin/pwm_tb6612fng_motor_driver.rs index 2cfb2038d..670f302a4 100644 --- a/examples/rp235x/src/bin/pwm_tb6612fng_motor_driver.rs +++ b/examples/rp235x/src/bin/pwm_tb6612fng_motor_driver.rs | |||
| @@ -10,7 +10,7 @@ use defmt::*; | |||
| 10 | use embassy_executor::Spawner; | 10 | use embassy_executor::Spawner; |
| 11 | use embassy_rp::config::Config; | 11 | use embassy_rp::config::Config; |
| 12 | use embassy_rp::gpio::Output; | 12 | use embassy_rp::gpio::Output; |
| 13 | use embassy_rp::{gpio, peripherals, pwm, Peri}; | 13 | use embassy_rp::{Peri, gpio, peripherals, pwm}; |
| 14 | use embassy_time::{Duration, Timer}; | 14 | use embassy_time::{Duration, Timer}; |
| 15 | use tb6612fng::{DriveCommand, Motor, Tb6612fng}; | 15 | use tb6612fng::{DriveCommand, Motor, Tb6612fng}; |
| 16 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
diff --git a/examples/rp235x/src/bin/sharing.rs b/examples/rp235x/src/bin/sharing.rs index d4c89946b..618ab9117 100644 --- a/examples/rp235x/src/bin/sharing.rs +++ b/examples/rp235x/src/bin/sharing.rs | |||
| @@ -52,7 +52,7 @@ bind_interrupts!(struct Irqs { | |||
| 52 | 52 | ||
| 53 | #[interrupt] | 53 | #[interrupt] |
| 54 | unsafe fn SWI_IRQ_0() { | 54 | unsafe fn SWI_IRQ_0() { |
| 55 | EXECUTOR_HI.on_interrupt() | 55 | unsafe { EXECUTOR_HI.on_interrupt() } |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | #[entry] | 58 | #[entry] |
diff --git a/examples/rp235x/src/bin/spi_display.rs b/examples/rp235x/src/bin/spi_display.rs index 9967abefd..3cef93f62 100644 --- a/examples/rp235x/src/bin/spi_display.rs +++ b/examples/rp235x/src/bin/spi_display.rs | |||
| @@ -15,19 +15,19 @@ use embassy_executor::Spawner; | |||
| 15 | use embassy_rp::gpio::{Level, Output}; | 15 | use embassy_rp::gpio::{Level, Output}; |
| 16 | use embassy_rp::spi; | 16 | use embassy_rp::spi; |
| 17 | use embassy_rp::spi::{Blocking, Spi}; | 17 | use embassy_rp::spi::{Blocking, Spi}; |
| 18 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | ||
| 19 | use embassy_sync::blocking_mutex::Mutex; | 18 | use embassy_sync::blocking_mutex::Mutex; |
| 19 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | ||
| 20 | use embassy_time::Delay; | 20 | use embassy_time::Delay; |
| 21 | use embedded_graphics::image::{Image, ImageRawLE}; | 21 | use embedded_graphics::image::{Image, ImageRawLE}; |
| 22 | use embedded_graphics::mono_font::ascii::FONT_10X20; | ||
| 23 | use embedded_graphics::mono_font::MonoTextStyle; | 22 | use embedded_graphics::mono_font::MonoTextStyle; |
| 23 | use embedded_graphics::mono_font::ascii::FONT_10X20; | ||
| 24 | use embedded_graphics::pixelcolor::Rgb565; | 24 | use embedded_graphics::pixelcolor::Rgb565; |
| 25 | use embedded_graphics::prelude::*; | 25 | use embedded_graphics::prelude::*; |
| 26 | use embedded_graphics::primitives::{PrimitiveStyleBuilder, Rectangle}; | 26 | use embedded_graphics::primitives::{PrimitiveStyleBuilder, Rectangle}; |
| 27 | use embedded_graphics::text::Text; | 27 | use embedded_graphics::text::Text; |
| 28 | use mipidsi::Builder; | ||
| 28 | use mipidsi::models::ST7789; | 29 | use mipidsi::models::ST7789; |
| 29 | use mipidsi::options::{Orientation, Rotation}; | 30 | use mipidsi::options::{Orientation, Rotation}; |
| 30 | use mipidsi::Builder; | ||
| 31 | use {defmt_rtt as _, panic_probe as _}; | 31 | use {defmt_rtt as _, panic_probe as _}; |
| 32 | 32 | ||
| 33 | use crate::touch::Touch; | 33 | use crate::touch::Touch; |
| @@ -167,11 +167,7 @@ mod touch { | |||
| 167 | 167 | ||
| 168 | let x = ((x - cal.x1) * cal.sx / (cal.x2 - cal.x1)).clamp(0, cal.sx); | 168 | let x = ((x - cal.x1) * cal.sx / (cal.x2 - cal.x1)).clamp(0, cal.sx); |
| 169 | let y = ((y - cal.y1) * cal.sy / (cal.y2 - cal.y1)).clamp(0, cal.sy); | 169 | let y = ((y - cal.y1) * cal.sy / (cal.y2 - cal.y1)).clamp(0, cal.sy); |
| 170 | if x == 0 && y == 0 { | 170 | if x == 0 && y == 0 { None } else { Some((x, y)) } |
| 171 | None | ||
| 172 | } else { | ||
| 173 | Some((x, y)) | ||
| 174 | } | ||
| 175 | } | 171 | } |
| 176 | } | 172 | } |
| 177 | } | 173 | } |
diff --git a/examples/rp235x/src/bin/uart_r503.rs b/examples/rp235x/src/bin/uart_r503.rs index 085be280b..a25d45b18 100644 --- a/examples/rp235x/src/bin/uart_r503.rs +++ b/examples/rp235x/src/bin/uart_r503.rs | |||
| @@ -6,7 +6,7 @@ use embassy_executor::Spawner; | |||
| 6 | use embassy_rp::bind_interrupts; | 6 | use embassy_rp::bind_interrupts; |
| 7 | use embassy_rp::peripherals::UART0; | 7 | use embassy_rp::peripherals::UART0; |
| 8 | use embassy_rp::uart::{Config, DataBits, InterruptHandler as UARTInterruptHandler, Parity, StopBits, Uart}; | 8 | use embassy_rp::uart::{Config, DataBits, InterruptHandler as UARTInterruptHandler, Parity, StopBits, Uart}; |
| 9 | use embassy_time::{with_timeout, Duration, Timer}; | 9 | use embassy_time::{Duration, Timer, with_timeout}; |
| 10 | use heapless::Vec; | 10 | use heapless::Vec; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
diff --git a/examples/rp235x/src/bin/zerocopy.rs b/examples/rp235x/src/bin/zerocopy.rs index 62ba4cfb8..55deffd5f 100644 --- a/examples/rp235x/src/bin/zerocopy.rs +++ b/examples/rp235x/src/bin/zerocopy.rs | |||
| @@ -11,7 +11,7 @@ use embassy_executor::Spawner; | |||
| 11 | use embassy_rp::adc::{self, Adc, Async, Config, InterruptHandler}; | 11 | use embassy_rp::adc::{self, Adc, Async, Config, InterruptHandler}; |
| 12 | use embassy_rp::gpio::Pull; | 12 | use embassy_rp::gpio::Pull; |
| 13 | use embassy_rp::peripherals::DMA_CH0; | 13 | use embassy_rp::peripherals::DMA_CH0; |
| 14 | use embassy_rp::{bind_interrupts, Peri}; | 14 | use embassy_rp::{Peri, bind_interrupts}; |
| 15 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | 15 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; |
| 16 | use embassy_sync::zerocopy_channel::{Channel, Receiver, Sender}; | 16 | use embassy_sync::zerocopy_channel::{Channel, Receiver, Sender}; |
| 17 | use embassy_time::{Duration, Ticker, Timer}; | 17 | use embassy_time::{Duration, Ticker, Timer}; |
diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index 449c5ddca..6dc6a353d 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-std-examples" | 3 | name = "embassy-std-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32c0/Cargo.toml b/examples/stm32c0/Cargo.toml index bb7b57496..696a95854 100644 --- a/examples/stm32c0/Cargo.toml +++ b/examples/stm32c0/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32c0-examples" | 3 | name = "embassy-stm32c0-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32c0/src/bin/rtc.rs b/examples/stm32c0/src/bin/rtc.rs index 82d8a37ba..feb27f6d9 100644 --- a/examples/stm32c0/src/bin/rtc.rs +++ b/examples/stm32c0/src/bin/rtc.rs | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | use chrono::{NaiveDate, NaiveDateTime}; | 4 | use chrono::{NaiveDate, NaiveDateTime}; |
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::rtc::{Rtc, RtcConfig}; | ||
| 8 | use embassy_stm32::Config; | 7 | use embassy_stm32::Config; |
| 8 | use embassy_stm32::rtc::{Rtc, RtcConfig}; | ||
| 9 | use embassy_time::Timer; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
diff --git a/examples/stm32f0/Cargo.toml b/examples/stm32f0/Cargo.toml index 11ecbe3c2..a78873d21 100644 --- a/examples/stm32f0/Cargo.toml +++ b/examples/stm32f0/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "embassy-stm32f0-examples" | 2 | name = "embassy-stm32f0-examples" |
| 3 | version = "0.1.0" | 3 | version = "0.1.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | publish = false | 6 | publish = false |
| 7 | 7 | ||
diff --git a/examples/stm32f0/src/bin/button_controlled_blink.rs b/examples/stm32f0/src/bin/button_controlled_blink.rs index f232e3290..0b678af01 100644 --- a/examples/stm32f0/src/bin/button_controlled_blink.rs +++ b/examples/stm32f0/src/bin/button_controlled_blink.rs | |||
| @@ -7,9 +7,9 @@ use core::sync::atomic::{AtomicU32, Ordering}; | |||
| 7 | 7 | ||
| 8 | use defmt::info; | 8 | use defmt::info; |
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_stm32::Peri; | ||
| 10 | use embassy_stm32::exti::ExtiInput; | 11 | use embassy_stm32::exti::ExtiInput; |
| 11 | use embassy_stm32::gpio::{AnyPin, Level, Output, Pull, Speed}; | 12 | use embassy_stm32::gpio::{AnyPin, Level, Output, Pull, Speed}; |
| 12 | use embassy_stm32::Peri; | ||
| 13 | use embassy_time::Timer; | 13 | use embassy_time::Timer; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 15 | ||
diff --git a/examples/stm32f0/src/bin/multiprio.rs b/examples/stm32f0/src/bin/multiprio.rs index b5244afc8..9a8dc5685 100644 --- a/examples/stm32f0/src/bin/multiprio.rs +++ b/examples/stm32f0/src/bin/multiprio.rs | |||
| @@ -113,12 +113,12 @@ static EXECUTOR_LOW: StaticCell<Executor> = StaticCell::new(); | |||
| 113 | 113 | ||
| 114 | #[interrupt] | 114 | #[interrupt] |
| 115 | unsafe fn USART1() { | 115 | unsafe fn USART1() { |
| 116 | EXECUTOR_HIGH.on_interrupt() | 116 | unsafe { EXECUTOR_HIGH.on_interrupt() } |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | #[interrupt] | 119 | #[interrupt] |
| 120 | unsafe fn USART2() { | 120 | unsafe fn USART2() { |
| 121 | EXECUTOR_MED.on_interrupt() | 121 | unsafe { EXECUTOR_MED.on_interrupt() } |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | #[entry] | 124 | #[entry] |
diff --git a/examples/stm32f1/Cargo.toml b/examples/stm32f1/Cargo.toml index dcb58796b..5714b149a 100644 --- a/examples/stm32f1/Cargo.toml +++ b/examples/stm32f1/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32f1-examples" | 3 | name = "embassy-stm32f1-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32f1/src/bin/can.rs b/examples/stm32f1/src/bin/can.rs index ad0c8a5a5..cbe13b206 100644 --- a/examples/stm32f1/src/bin/can.rs +++ b/examples/stm32f1/src/bin/can.rs | |||
| @@ -5,11 +5,11 @@ use defmt::*; | |||
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::can::frame::Envelope; | 6 | use embassy_stm32::can::frame::Envelope; |
| 7 | use embassy_stm32::can::{ | 7 | use embassy_stm32::can::{ |
| 8 | filter, Can, Fifo, Frame, Id, Rx0InterruptHandler, Rx1InterruptHandler, SceInterruptHandler, StandardId, | 8 | Can, Fifo, Frame, Id, Rx0InterruptHandler, Rx1InterruptHandler, SceInterruptHandler, StandardId, |
| 9 | TxInterruptHandler, | 9 | TxInterruptHandler, filter, |
| 10 | }; | 10 | }; |
| 11 | use embassy_stm32::peripherals::CAN; | 11 | use embassy_stm32::peripherals::CAN; |
| 12 | use embassy_stm32::{bind_interrupts, Config}; | 12 | use embassy_stm32::{Config, bind_interrupts}; |
| 13 | use static_cell::StaticCell; | 13 | use static_cell::StaticCell; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 15 | ||
diff --git a/examples/stm32f1/src/bin/input_capture.rs b/examples/stm32f1/src/bin/input_capture.rs index b5b26938d..6232d8c17 100644 --- a/examples/stm32f1/src/bin/input_capture.rs +++ b/examples/stm32f1/src/bin/input_capture.rs | |||
| @@ -7,7 +7,7 @@ use embassy_stm32::gpio::{AfioRemap, Level, Output, Pull, Speed}; | |||
| 7 | use embassy_stm32::time::khz; | 7 | use embassy_stm32::time::khz; |
| 8 | use embassy_stm32::timer::input_capture::{CapturePin, InputCapture}; | 8 | use embassy_stm32::timer::input_capture::{CapturePin, InputCapture}; |
| 9 | use embassy_stm32::timer::{self, Channel}; | 9 | use embassy_stm32::timer::{self, Channel}; |
| 10 | use embassy_stm32::{bind_interrupts, peripherals, Peri}; | 10 | use embassy_stm32::{Peri, bind_interrupts, peripherals}; |
| 11 | use embassy_time::Timer; | 11 | use embassy_time::Timer; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
diff --git a/examples/stm32f1/src/bin/pwm_input.rs b/examples/stm32f1/src/bin/pwm_input.rs index 9ae747018..136c5c555 100644 --- a/examples/stm32f1/src/bin/pwm_input.rs +++ b/examples/stm32f1/src/bin/pwm_input.rs | |||
| @@ -6,7 +6,7 @@ use embassy_executor::Spawner; | |||
| 6 | use embassy_stm32::gpio::{AfioRemap, Level, Output, Pull, Speed}; | 6 | use embassy_stm32::gpio::{AfioRemap, Level, Output, Pull, Speed}; |
| 7 | use embassy_stm32::time::khz; | 7 | use embassy_stm32::time::khz; |
| 8 | use embassy_stm32::timer::pwm_input::PwmInput; | 8 | use embassy_stm32::timer::pwm_input::PwmInput; |
| 9 | use embassy_stm32::{bind_interrupts, peripherals, timer, Peri}; | 9 | use embassy_stm32::{Peri, bind_interrupts, peripherals, timer}; |
| 10 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
diff --git a/examples/stm32f1/src/bin/usb_serial.rs b/examples/stm32f1/src/bin/usb_serial.rs index 77ec307b9..5ff54a521 100644 --- a/examples/stm32f1/src/bin/usb_serial.rs +++ b/examples/stm32f1/src/bin/usb_serial.rs | |||
| @@ -7,11 +7,11 @@ use embassy_futures::join::join; | |||
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_stm32::time::Hertz; | 8 | use embassy_stm32::time::Hertz; |
| 9 | use embassy_stm32::usb::{Driver, Instance}; | 9 | use embassy_stm32::usb::{Driver, Instance}; |
| 10 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 10 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 11 | use embassy_time::Timer; | 11 | use embassy_time::Timer; |
| 12 | use embassy_usb::Builder; | ||
| 12 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 13 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 13 | use embassy_usb::driver::EndpointError; | 14 | use embassy_usb::driver::EndpointError; |
| 14 | use embassy_usb::Builder; | ||
| 15 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 16 | ||
| 17 | bind_interrupts!(struct Irqs { | 17 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32f2/Cargo.toml b/examples/stm32f2/Cargo.toml index 498c20d84..f726018c3 100644 --- a/examples/stm32f2/Cargo.toml +++ b/examples/stm32f2/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32f2-examples" | 3 | name = "embassy-stm32f2-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32f2/src/bin/pll.rs b/examples/stm32f2/src/bin/pll.rs index e39e2daec..4418bf502 100644 --- a/examples/stm32f2/src/bin/pll.rs +++ b/examples/stm32f2/src/bin/pll.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::time::Hertz; | ||
| 7 | use embassy_stm32::Config; | 6 | use embassy_stm32::Config; |
| 7 | use embassy_stm32::time::Hertz; | ||
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
diff --git a/examples/stm32f3/Cargo.toml b/examples/stm32f3/Cargo.toml index 23025ef0b..4349e8055 100644 --- a/examples/stm32f3/Cargo.toml +++ b/examples/stm32f3/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32f3-examples" | 3 | name = "embassy-stm32f3-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32f3/src/bin/button_events.rs b/examples/stm32f3/src/bin/button_events.rs index a54d03212..99957a641 100644 --- a/examples/stm32f3/src/bin/button_events.rs +++ b/examples/stm32f3/src/bin/button_events.rs | |||
| @@ -15,7 +15,7 @@ use embassy_stm32::exti::ExtiInput; | |||
| 15 | use embassy_stm32::gpio::{Level, Output, Pull, Speed}; | 15 | use embassy_stm32::gpio::{Level, Output, Pull, Speed}; |
| 16 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; | 16 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; |
| 17 | use embassy_sync::channel::Channel; | 17 | use embassy_sync::channel::Channel; |
| 18 | use embassy_time::{with_timeout, Duration, Timer}; | 18 | use embassy_time::{Duration, Timer, with_timeout}; |
| 19 | use {defmt_rtt as _, panic_probe as _}; | 19 | use {defmt_rtt as _, panic_probe as _}; |
| 20 | 20 | ||
| 21 | struct Leds<'a> { | 21 | struct Leds<'a> { |
diff --git a/examples/stm32f3/src/bin/multiprio.rs b/examples/stm32f3/src/bin/multiprio.rs index 2f2ffdea2..8375e0e8e 100644 --- a/examples/stm32f3/src/bin/multiprio.rs +++ b/examples/stm32f3/src/bin/multiprio.rs | |||
| @@ -113,12 +113,12 @@ static EXECUTOR_LOW: StaticCell<Executor> = StaticCell::new(); | |||
| 113 | 113 | ||
| 114 | #[interrupt] | 114 | #[interrupt] |
| 115 | unsafe fn UART4() { | 115 | unsafe fn UART4() { |
| 116 | EXECUTOR_HIGH.on_interrupt() | 116 | unsafe { EXECUTOR_HIGH.on_interrupt() } |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | #[interrupt] | 119 | #[interrupt] |
| 120 | unsafe fn UART5() { | 120 | unsafe fn UART5() { |
| 121 | EXECUTOR_MED.on_interrupt() | 121 | unsafe { EXECUTOR_MED.on_interrupt() } |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | #[entry] | 124 | #[entry] |
diff --git a/examples/stm32f3/src/bin/usb_serial.rs b/examples/stm32f3/src/bin/usb_serial.rs index 5760f2c1c..58b801c36 100644 --- a/examples/stm32f3/src/bin/usb_serial.rs +++ b/examples/stm32f3/src/bin/usb_serial.rs | |||
| @@ -7,11 +7,11 @@ use embassy_futures::join::join; | |||
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_stm32::time::mhz; | 8 | use embassy_stm32::time::mhz; |
| 9 | use embassy_stm32::usb::{Driver, Instance}; | 9 | use embassy_stm32::usb::{Driver, Instance}; |
| 10 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 10 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 11 | use embassy_time::Timer; | 11 | use embassy_time::Timer; |
| 12 | use embassy_usb::Builder; | ||
| 12 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 13 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 13 | use embassy_usb::driver::EndpointError; | 14 | use embassy_usb::driver::EndpointError; |
| 14 | use embassy_usb::Builder; | ||
| 15 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 16 | ||
| 17 | bind_interrupts!(struct Irqs { | 17 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32f334/Cargo.toml b/examples/stm32f334/Cargo.toml index 3495b118c..cf22633dd 100644 --- a/examples/stm32f334/Cargo.toml +++ b/examples/stm32f334/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32f334-examples" | 3 | name = "embassy-stm32f334-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32f334/src/bin/adc.rs b/examples/stm32f334/src/bin/adc.rs index 0528a9637..a993b00ca 100644 --- a/examples/stm32f334/src/bin/adc.rs +++ b/examples/stm32f334/src/bin/adc.rs | |||
| @@ -6,7 +6,7 @@ use embassy_executor::Spawner; | |||
| 6 | use embassy_stm32::adc::{Adc, SampleTime}; | 6 | use embassy_stm32::adc::{Adc, SampleTime}; |
| 7 | use embassy_stm32::peripherals::ADC1; | 7 | use embassy_stm32::peripherals::ADC1; |
| 8 | use embassy_stm32::time::mhz; | 8 | use embassy_stm32::time::mhz; |
| 9 | use embassy_stm32::{adc, bind_interrupts, Config}; | 9 | use embassy_stm32::{Config, adc, bind_interrupts}; |
| 10 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
diff --git a/examples/stm32f334/src/bin/opamp.rs b/examples/stm32f334/src/bin/opamp.rs index c344935d7..3e621f2a1 100644 --- a/examples/stm32f334/src/bin/opamp.rs +++ b/examples/stm32f334/src/bin/opamp.rs | |||
| @@ -7,7 +7,7 @@ use embassy_stm32::adc::{Adc, SampleTime}; | |||
| 7 | use embassy_stm32::opamp::OpAmp; | 7 | use embassy_stm32::opamp::OpAmp; |
| 8 | use embassy_stm32::peripherals::ADC2; | 8 | use embassy_stm32::peripherals::ADC2; |
| 9 | use embassy_stm32::time::mhz; | 9 | use embassy_stm32::time::mhz; |
| 10 | use embassy_stm32::{adc, bind_interrupts, Config}; | 10 | use embassy_stm32::{Config, adc, bind_interrupts}; |
| 11 | use embassy_time::Timer; | 11 | use embassy_time::Timer; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
diff --git a/examples/stm32f334/src/bin/pwm.rs b/examples/stm32f334/src/bin/pwm.rs index 2b0686121..68a61ae22 100644 --- a/examples/stm32f334/src/bin/pwm.rs +++ b/examples/stm32f334/src/bin/pwm.rs | |||
| @@ -3,9 +3,9 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::Config; | ||
| 6 | use embassy_stm32::hrtim::*; | 7 | use embassy_stm32::hrtim::*; |
| 7 | use embassy_stm32::time::{khz, mhz}; | 8 | use embassy_stm32::time::{khz, mhz}; |
| 8 | use embassy_stm32::Config; | ||
| 9 | use embassy_time::Timer; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml index fb5f86aac..d06b7505c 100644 --- a/examples/stm32f4/Cargo.toml +++ b/examples/stm32f4/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32f4-examples" | 3 | name = "embassy-stm32f4-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32f4/src/bin/adc_dma.rs b/examples/stm32f4/src/bin/adc_dma.rs index 2ec48640e..c24f01753 100644 --- a/examples/stm32f4/src/bin/adc_dma.rs +++ b/examples/stm32f4/src/bin/adc_dma.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | use cortex_m::singleton; | 3 | use cortex_m::singleton; |
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::adc::{Adc, RingBufferedAdc, SampleTime, Sequence}; | ||
| 7 | use embassy_stm32::Peripherals; | 6 | use embassy_stm32::Peripherals; |
| 7 | use embassy_stm32::adc::{Adc, RingBufferedAdc, SampleTime, Sequence}; | ||
| 8 | use embassy_time::Instant; | 8 | use embassy_time::Instant; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
diff --git a/examples/stm32f4/src/bin/eth.rs b/examples/stm32f4/src/bin/eth.rs index f41a60529..2d72b6b0b 100644 --- a/examples/stm32f4/src/bin/eth.rs +++ b/examples/stm32f4/src/bin/eth.rs | |||
| @@ -9,7 +9,7 @@ use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue}; | |||
| 9 | use embassy_stm32::peripherals::ETH; | 9 | use embassy_stm32::peripherals::ETH; |
| 10 | use embassy_stm32::rng::Rng; | 10 | use embassy_stm32::rng::Rng; |
| 11 | use embassy_stm32::time::Hertz; | 11 | use embassy_stm32::time::Hertz; |
| 12 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 12 | use embassy_stm32::{Config, bind_interrupts, eth, peripherals, rng}; |
| 13 | use embassy_time::Timer; | 13 | use embassy_time::Timer; |
| 14 | use embedded_io_async::Write; | 14 | use embedded_io_async::Write; |
| 15 | use static_cell::StaticCell; | 15 | use static_cell::StaticCell; |
diff --git a/examples/stm32f4/src/bin/eth_compliance_test.rs b/examples/stm32f4/src/bin/eth_compliance_test.rs index 52f9d57f6..734a14c2c 100644 --- a/examples/stm32f4/src/bin/eth_compliance_test.rs +++ b/examples/stm32f4/src/bin/eth_compliance_test.rs | |||
| @@ -5,7 +5,7 @@ use defmt::*; | |||
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue, StationManagement}; | 6 | use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue, StationManagement}; |
| 7 | use embassy_stm32::time::Hertz; | 7 | use embassy_stm32::time::Hertz; |
| 8 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 8 | use embassy_stm32::{Config, bind_interrupts, eth, peripherals, rng}; |
| 9 | use embassy_time::Timer; | 9 | use embassy_time::Timer; |
| 10 | use static_cell::StaticCell; | 10 | use static_cell::StaticCell; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
diff --git a/examples/stm32f4/src/bin/eth_w5500.rs b/examples/stm32f4/src/bin/eth_w5500.rs index 7ce3bfe75..cccf20949 100644 --- a/examples/stm32f4/src/bin/eth_w5500.rs +++ b/examples/stm32f4/src/bin/eth_w5500.rs | |||
| @@ -13,7 +13,7 @@ use embassy_stm32::mode::Async; | |||
| 13 | use embassy_stm32::rng::Rng; | 13 | use embassy_stm32::rng::Rng; |
| 14 | use embassy_stm32::spi::Spi; | 14 | use embassy_stm32::spi::Spi; |
| 15 | use embassy_stm32::time::Hertz; | 15 | use embassy_stm32::time::Hertz; |
| 16 | use embassy_stm32::{bind_interrupts, peripherals, rng, spi, Config}; | 16 | use embassy_stm32::{Config, bind_interrupts, peripherals, rng, spi}; |
| 17 | use embassy_time::{Delay, Timer}; | 17 | use embassy_time::{Delay, Timer}; |
| 18 | use embedded_hal_bus::spi::ExclusiveDevice; | 18 | use embedded_hal_bus::spi::ExclusiveDevice; |
| 19 | use embedded_io_async::Write; | 19 | use embedded_io_async::Write; |
diff --git a/examples/stm32f4/src/bin/flash_async.rs b/examples/stm32f4/src/bin/flash_async.rs index 2feb9de09..14f029747 100644 --- a/examples/stm32f4/src/bin/flash_async.rs +++ b/examples/stm32f4/src/bin/flash_async.rs | |||
| @@ -5,7 +5,7 @@ use defmt::{info, unwrap}; | |||
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::flash::{Flash, InterruptHandler}; | 6 | use embassy_stm32::flash::{Flash, InterruptHandler}; |
| 7 | use embassy_stm32::gpio::{AnyPin, Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{AnyPin, Level, Output, Speed}; |
| 8 | use embassy_stm32::{bind_interrupts, Peri}; | 8 | use embassy_stm32::{Peri, bind_interrupts}; |
| 9 | use embassy_time::Timer; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
diff --git a/examples/stm32f4/src/bin/input_capture.rs b/examples/stm32f4/src/bin/input_capture.rs index 9998c4733..3ff96584d 100644 --- a/examples/stm32f4/src/bin/input_capture.rs +++ b/examples/stm32f4/src/bin/input_capture.rs | |||
| @@ -7,7 +7,7 @@ use embassy_stm32::gpio::{Level, Output, Pull, Speed}; | |||
| 7 | use embassy_stm32::time::khz; | 7 | use embassy_stm32::time::khz; |
| 8 | use embassy_stm32::timer::input_capture::{CapturePin, InputCapture}; | 8 | use embassy_stm32::timer::input_capture::{CapturePin, InputCapture}; |
| 9 | use embassy_stm32::timer::{self, Channel}; | 9 | use embassy_stm32::timer::{self, Channel}; |
| 10 | use embassy_stm32::{bind_interrupts, peripherals, Peri}; | 10 | use embassy_stm32::{Peri, bind_interrupts, peripherals}; |
| 11 | use embassy_time::Timer; | 11 | use embassy_time::Timer; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
diff --git a/examples/stm32f4/src/bin/mco.rs b/examples/stm32f4/src/bin/mco.rs index eb7bb6261..a2e229770 100644 --- a/examples/stm32f4/src/bin/mco.rs +++ b/examples/stm32f4/src/bin/mco.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::gpio::{Level, Output, Speed}; | 6 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 7 | use embassy_stm32::rcc::{Mco, Mco1Source, Mco2Source, McoPrescaler}; | 7 | use embassy_stm32::rcc::{Mco, Mco1Source, Mco2Source, McoConfig, McoPrescaler}; |
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| @@ -13,8 +13,20 @@ async fn main(_spawner: Spawner) { | |||
| 13 | let p = embassy_stm32::init(Default::default()); | 13 | let p = embassy_stm32::init(Default::default()); |
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let _mco1 = Mco::new(p.MCO1, p.PA8, Mco1Source::HSI, McoPrescaler::DIV1); | 16 | let config_mco1 = { |
| 17 | let _mco2 = Mco::new(p.MCO2, p.PC9, Mco2Source::PLL, McoPrescaler::DIV4); | 17 | let mut config = McoConfig::default(); |
| 18 | config.prescaler = McoPrescaler::DIV1; | ||
| 19 | config | ||
| 20 | }; | ||
| 21 | |||
| 22 | let config_mco2 = { | ||
| 23 | let mut config = McoConfig::default(); | ||
| 24 | config.prescaler = McoPrescaler::DIV4; | ||
| 25 | config | ||
| 26 | }; | ||
| 27 | |||
| 28 | let _mco1 = Mco::new(p.MCO1, p.PA8, Mco1Source::HSI, config_mco1); | ||
| 29 | let _mco2 = Mco::new(p.MCO2, p.PC9, Mco2Source::PLL, config_mco2); | ||
| 18 | let mut led = Output::new(p.PB7, Level::High, Speed::Low); | 30 | let mut led = Output::new(p.PB7, Level::High, Speed::Low); |
| 19 | 31 | ||
| 20 | loop { | 32 | loop { |
diff --git a/examples/stm32f4/src/bin/multiprio.rs b/examples/stm32f4/src/bin/multiprio.rs index 2f2ffdea2..8375e0e8e 100644 --- a/examples/stm32f4/src/bin/multiprio.rs +++ b/examples/stm32f4/src/bin/multiprio.rs | |||
| @@ -113,12 +113,12 @@ static EXECUTOR_LOW: StaticCell<Executor> = StaticCell::new(); | |||
| 113 | 113 | ||
| 114 | #[interrupt] | 114 | #[interrupt] |
| 115 | unsafe fn UART4() { | 115 | unsafe fn UART4() { |
| 116 | EXECUTOR_HIGH.on_interrupt() | 116 | unsafe { EXECUTOR_HIGH.on_interrupt() } |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | #[interrupt] | 119 | #[interrupt] |
| 120 | unsafe fn UART5() { | 120 | unsafe fn UART5() { |
| 121 | EXECUTOR_MED.on_interrupt() | 121 | unsafe { EXECUTOR_MED.on_interrupt() } |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | #[entry] | 124 | #[entry] |
diff --git a/examples/stm32f4/src/bin/pwm_complementary.rs b/examples/stm32f4/src/bin/pwm_complementary.rs index c981f1a76..50008a37b 100644 --- a/examples/stm32f4/src/bin/pwm_complementary.rs +++ b/examples/stm32f4/src/bin/pwm_complementary.rs | |||
| @@ -5,9 +5,9 @@ use defmt::*; | |||
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::gpio::OutputType; | 6 | use embassy_stm32::gpio::OutputType; |
| 7 | use embassy_stm32::time::khz; | 7 | use embassy_stm32::time::khz; |
| 8 | use embassy_stm32::timer::Channel; | ||
| 8 | use embassy_stm32::timer::complementary_pwm::{ComplementaryPwm, ComplementaryPwmPin}; | 9 | use embassy_stm32::timer::complementary_pwm::{ComplementaryPwm, ComplementaryPwmPin}; |
| 9 | use embassy_stm32::timer::simple_pwm::PwmPin; | 10 | use embassy_stm32::timer::simple_pwm::PwmPin; |
| 10 | use embassy_stm32::timer::Channel; | ||
| 11 | use embassy_time::Timer; | 11 | use embassy_time::Timer; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
diff --git a/examples/stm32f4/src/bin/pwm_input.rs b/examples/stm32f4/src/bin/pwm_input.rs index e8bfa524f..d8ea56a34 100644 --- a/examples/stm32f4/src/bin/pwm_input.rs +++ b/examples/stm32f4/src/bin/pwm_input.rs | |||
| @@ -6,7 +6,7 @@ use embassy_executor::Spawner; | |||
| 6 | use embassy_stm32::gpio::{Level, Output, Pull, Speed}; | 6 | use embassy_stm32::gpio::{Level, Output, Pull, Speed}; |
| 7 | use embassy_stm32::time::khz; | 7 | use embassy_stm32::time::khz; |
| 8 | use embassy_stm32::timer::pwm_input::PwmInput; | 8 | use embassy_stm32::timer::pwm_input::PwmInput; |
| 9 | use embassy_stm32::{bind_interrupts, peripherals, timer, Peri}; | 9 | use embassy_stm32::{Peri, bind_interrupts, peripherals, timer}; |
| 10 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
diff --git a/examples/stm32f4/src/bin/rtc.rs b/examples/stm32f4/src/bin/rtc.rs index 82d8a37ba..feb27f6d9 100644 --- a/examples/stm32f4/src/bin/rtc.rs +++ b/examples/stm32f4/src/bin/rtc.rs | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | use chrono::{NaiveDate, NaiveDateTime}; | 4 | use chrono::{NaiveDate, NaiveDateTime}; |
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::rtc::{Rtc, RtcConfig}; | ||
| 8 | use embassy_stm32::Config; | 7 | use embassy_stm32::Config; |
| 8 | use embassy_stm32::rtc::{Rtc, RtcConfig}; | ||
| 9 | use embassy_time::Timer; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
diff --git a/examples/stm32f4/src/bin/sdmmc.rs b/examples/stm32f4/src/bin/sdmmc.rs index e97b63925..fe0f887bf 100644 --- a/examples/stm32f4/src/bin/sdmmc.rs +++ b/examples/stm32f4/src/bin/sdmmc.rs | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::sdmmc::{DataBlock, Sdmmc}; | 6 | use embassy_stm32::sdmmc::{DataBlock, Sdmmc}; |
| 7 | use embassy_stm32::time::{mhz, Hertz}; | 7 | use embassy_stm32::time::{Hertz, mhz}; |
| 8 | use embassy_stm32::{bind_interrupts, peripherals, sdmmc, Config}; | 8 | use embassy_stm32::{Config, bind_interrupts, peripherals, sdmmc}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | /// This is a safeguard to not overwrite any data on the SD card. | 11 | /// This is a safeguard to not overwrite any data on the SD card. |
diff --git a/examples/stm32f4/src/bin/usb_ethernet.rs b/examples/stm32f4/src/bin/usb_ethernet.rs index 7abbe8719..a5e625edd 100644 --- a/examples/stm32f4/src/bin/usb_ethernet.rs +++ b/examples/stm32f4/src/bin/usb_ethernet.rs | |||
| @@ -3,12 +3,12 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_net::tcp::TcpSocket; | ||
| 7 | use embassy_net::StackResources; | 6 | use embassy_net::StackResources; |
| 7 | use embassy_net::tcp::TcpSocket; | ||
| 8 | use embassy_stm32::rng::{self, Rng}; | 8 | use embassy_stm32::rng::{self, Rng}; |
| 9 | use embassy_stm32::time::Hertz; | 9 | use embassy_stm32::time::Hertz; |
| 10 | use embassy_stm32::usb::Driver; | 10 | use embassy_stm32::usb::Driver; |
| 11 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 11 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 12 | use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState}; | 12 | use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState}; |
| 13 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; | 13 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; |
| 14 | use embassy_usb::{Builder, UsbDevice}; | 14 | use embassy_usb::{Builder, UsbDevice}; |
diff --git a/examples/stm32f4/src/bin/usb_hid_keyboard.rs b/examples/stm32f4/src/bin/usb_hid_keyboard.rs index d6b4a9bc9..a3afb887c 100644 --- a/examples/stm32f4/src/bin/usb_hid_keyboard.rs +++ b/examples/stm32f4/src/bin/usb_hid_keyboard.rs | |||
| @@ -10,7 +10,7 @@ use embassy_stm32::exti::ExtiInput; | |||
| 10 | use embassy_stm32::gpio::Pull; | 10 | use embassy_stm32::gpio::Pull; |
| 11 | use embassy_stm32::time::Hertz; | 11 | use embassy_stm32::time::Hertz; |
| 12 | use embassy_stm32::usb::Driver; | 12 | use embassy_stm32::usb::Driver; |
| 13 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 13 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 14 | use embassy_usb::class::hid::{HidReaderWriter, ReportId, RequestHandler, State}; | 14 | use embassy_usb::class::hid::{HidReaderWriter, ReportId, RequestHandler, State}; |
| 15 | use embassy_usb::control::OutResponse; | 15 | use embassy_usb::control::OutResponse; |
| 16 | use embassy_usb::{Builder, Handler}; | 16 | use embassy_usb::{Builder, Handler}; |
diff --git a/examples/stm32f4/src/bin/usb_hid_mouse.rs b/examples/stm32f4/src/bin/usb_hid_mouse.rs index badb65e98..162a035f2 100644 --- a/examples/stm32f4/src/bin/usb_hid_mouse.rs +++ b/examples/stm32f4/src/bin/usb_hid_mouse.rs | |||
| @@ -6,11 +6,11 @@ use embassy_executor::Spawner; | |||
| 6 | use embassy_futures::join::join; | 6 | use embassy_futures::join::join; |
| 7 | use embassy_stm32::time::Hertz; | 7 | use embassy_stm32::time::Hertz; |
| 8 | use embassy_stm32::usb::Driver; | 8 | use embassy_stm32::usb::Driver; |
| 9 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 9 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 10 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 11 | use embassy_usb::Builder; | ||
| 11 | use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State}; | 12 | use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State}; |
| 12 | use embassy_usb::control::OutResponse; | 13 | use embassy_usb::control::OutResponse; |
| 13 | use embassy_usb::Builder; | ||
| 14 | use usbd_hid::descriptor::{MouseReport, SerializedDescriptor}; | 14 | use usbd_hid::descriptor::{MouseReport, SerializedDescriptor}; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 16 | ||
diff --git a/examples/stm32f4/src/bin/usb_raw.rs b/examples/stm32f4/src/bin/usb_raw.rs index bbbcc082b..511f0b281 100644 --- a/examples/stm32f4/src/bin/usb_raw.rs +++ b/examples/stm32f4/src/bin/usb_raw.rs | |||
| @@ -53,7 +53,7 @@ use defmt::*; | |||
| 53 | use embassy_executor::Spawner; | 53 | use embassy_executor::Spawner; |
| 54 | use embassy_stm32::time::Hertz; | 54 | use embassy_stm32::time::Hertz; |
| 55 | use embassy_stm32::usb::Driver; | 55 | use embassy_stm32::usb::Driver; |
| 56 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 56 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 57 | use embassy_usb::control::{InResponse, OutResponse, Recipient, Request, RequestType}; | 57 | use embassy_usb::control::{InResponse, OutResponse, Recipient, Request, RequestType}; |
| 58 | use embassy_usb::msos::{self, windows_version}; | 58 | use embassy_usb::msos::{self, windows_version}; |
| 59 | use embassy_usb::types::InterfaceNumber; | 59 | use embassy_usb::types::InterfaceNumber; |
diff --git a/examples/stm32f4/src/bin/usb_serial.rs b/examples/stm32f4/src/bin/usb_serial.rs index e62b2d8d6..2e81e0a59 100644 --- a/examples/stm32f4/src/bin/usb_serial.rs +++ b/examples/stm32f4/src/bin/usb_serial.rs | |||
| @@ -6,10 +6,10 @@ use embassy_executor::Spawner; | |||
| 6 | use embassy_futures::join::join; | 6 | use embassy_futures::join::join; |
| 7 | use embassy_stm32::time::Hertz; | 7 | use embassy_stm32::time::Hertz; |
| 8 | use embassy_stm32::usb::{Driver, Instance}; | 8 | use embassy_stm32::usb::{Driver, Instance}; |
| 9 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 9 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 10 | use embassy_usb::Builder; | ||
| 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 11 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 11 | use embassy_usb::driver::EndpointError; | 12 | use embassy_usb::driver::EndpointError; |
| 12 | use embassy_usb::Builder; | ||
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| 15 | bind_interrupts!(struct Irqs { | 15 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32f4/src/bin/usb_uac_speaker.rs b/examples/stm32f4/src/bin/usb_uac_speaker.rs index 79bd2d914..b92f4531e 100644 --- a/examples/stm32f4/src/bin/usb_uac_speaker.rs +++ b/examples/stm32f4/src/bin/usb_uac_speaker.rs | |||
| @@ -6,9 +6,9 @@ use core::cell::{Cell, RefCell}; | |||
| 6 | use defmt::{panic, *}; | 6 | use defmt::{panic, *}; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::time::Hertz; | 8 | use embassy_stm32::time::Hertz; |
| 9 | use embassy_stm32::{bind_interrupts, interrupt, peripherals, timer, usb, Config}; | 9 | use embassy_stm32::{Config, bind_interrupts, interrupt, peripherals, timer, usb}; |
| 10 | use embassy_sync::blocking_mutex::raw::{CriticalSectionRawMutex, NoopRawMutex}; | ||
| 11 | use embassy_sync::blocking_mutex::Mutex; | 10 | use embassy_sync::blocking_mutex::Mutex; |
| 11 | use embassy_sync::blocking_mutex::raw::{CriticalSectionRawMutex, NoopRawMutex}; | ||
| 12 | use embassy_sync::signal::Signal; | 12 | use embassy_sync::signal::Signal; |
| 13 | use embassy_sync::zerocopy_channel; | 13 | use embassy_sync::zerocopy_channel; |
| 14 | use embassy_usb::class::uac1; | 14 | use embassy_usb::class::uac1; |
diff --git a/examples/stm32f4/src/bin/ws2812_pwm.rs b/examples/stm32f4/src/bin/ws2812_pwm.rs index 5153e1cfd..ccfd0661e 100644 --- a/examples/stm32f4/src/bin/ws2812_pwm.rs +++ b/examples/stm32f4/src/bin/ws2812_pwm.rs | |||
| @@ -15,9 +15,9 @@ | |||
| 15 | use embassy_executor::Spawner; | 15 | use embassy_executor::Spawner; |
| 16 | use embassy_stm32::gpio::OutputType; | 16 | use embassy_stm32::gpio::OutputType; |
| 17 | use embassy_stm32::time::khz; | 17 | use embassy_stm32::time::khz; |
| 18 | use embassy_stm32::timer::Channel; | ||
| 18 | use embassy_stm32::timer::low_level::CountingMode; | 19 | use embassy_stm32::timer::low_level::CountingMode; |
| 19 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; | 20 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; |
| 20 | use embassy_stm32::timer::Channel; | ||
| 21 | use embassy_time::{Duration, Ticker, Timer}; | 21 | use embassy_time::{Duration, Ticker, Timer}; |
| 22 | use {defmt_rtt as _, panic_probe as _}; | 22 | use {defmt_rtt as _, panic_probe as _}; |
| 23 | 23 | ||
diff --git a/examples/stm32f469/Cargo.toml b/examples/stm32f469/Cargo.toml index f1d0e411a..5216e19b4 100644 --- a/examples/stm32f469/Cargo.toml +++ b/examples/stm32f469/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32f469-examples" | 3 | name = "embassy-stm32f469-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32f469/src/bin/dsi_bsp.rs b/examples/stm32f469/src/bin/dsi_bsp.rs index 3a24d5dcf..d659291ff 100644 --- a/examples/stm32f469/src/bin/dsi_bsp.rs +++ b/examples/stm32f469/src/bin/dsi_bsp.rs | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::dsihost::{blocking_delay_ms, DsiHost, PacketType}; | 6 | use embassy_stm32::dsihost::{DsiHost, PacketType, blocking_delay_ms}; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_stm32::ltdc::Ltdc; | 8 | use embassy_stm32::ltdc::Ltdc; |
| 9 | use embassy_stm32::pac::dsihost::regs::{Ier0, Ier1}; | 9 | use embassy_stm32::pac::dsihost::regs::{Ier0, Ier1}; |
| @@ -211,7 +211,7 @@ async fn main(_spawner: Spawner) { | |||
| 211 | const HORIZONTAL_SYNC_ACTIVE: u16 = 4; // ((HSA as u32 * LANE_BYTE_CLK_K_HZ as u32 ) / LCD_CLOCK as u32 ) as u16; | 211 | const HORIZONTAL_SYNC_ACTIVE: u16 = 4; // ((HSA as u32 * LANE_BYTE_CLK_K_HZ as u32 ) / LCD_CLOCK as u32 ) as u16; |
| 212 | const HORIZONTAL_BACK_PORCH: u16 = 77; //((HBP as u32 * LANE_BYTE_CLK_K_HZ as u32 ) / LCD_CLOCK as u32) as u16; | 212 | const HORIZONTAL_BACK_PORCH: u16 = 77; //((HBP as u32 * LANE_BYTE_CLK_K_HZ as u32 ) / LCD_CLOCK as u32) as u16; |
| 213 | const HORIZONTAL_LINE: u16 = 1982; //(((HACT + HSA + HBP + HFP) as u32 * LANE_BYTE_CLK_K_HZ as u32 ) / LCD_CLOCK as u32 ) as u16; /* Value depending on display orientation choice portrait/landscape */ | 213 | const HORIZONTAL_LINE: u16 = 1982; //(((HACT + HSA + HBP + HFP) as u32 * LANE_BYTE_CLK_K_HZ as u32 ) / LCD_CLOCK as u32 ) as u16; /* Value depending on display orientation choice portrait/landscape */ |
| 214 | // FIXME: Make depend on orientation | 214 | // FIXME: Make depend on orientation |
| 215 | const VERTICAL_SYNC_ACTIVE: u16 = VSA; | 215 | const VERTICAL_SYNC_ACTIVE: u16 = VSA; |
| 216 | const VERTICAL_BACK_PORCH: u16 = VBP; | 216 | const VERTICAL_BACK_PORCH: u16 = VBP; |
| 217 | const VERTICAL_FRONT_PORCH: u16 = VFP; | 217 | const VERTICAL_FRONT_PORCH: u16 = VFP; |
| @@ -658,7 +658,7 @@ const NT35510_RASET_LANDSCAPE: &[u8] = &[NT35510_CMD_RASET, 0x00, 0x00, 0x01, 0x | |||
| 658 | 658 | ||
| 659 | const NT35510_WRITES_26: &[u8] = &[NT35510_CMD_TEEON, 0x00]; // Tear on | 659 | const NT35510_WRITES_26: &[u8] = &[NT35510_CMD_TEEON, 0x00]; // Tear on |
| 660 | const NT35510_WRITES_27: &[u8] = &[NT35510_CMD_SLPOUT, 0x00]; // Sleep out | 660 | const NT35510_WRITES_27: &[u8] = &[NT35510_CMD_SLPOUT, 0x00]; // Sleep out |
| 661 | // 28,29 missing | 661 | // 28,29 missing |
| 662 | const NT35510_WRITES_30: &[u8] = &[NT35510_CMD_DISPON, 0x00]; // Display on | 662 | const NT35510_WRITES_30: &[u8] = &[NT35510_CMD_DISPON, 0x00]; // Display on |
| 663 | 663 | ||
| 664 | const NT35510_WRITES_31: &[u8] = &[NT35510_CMD_WRDISBV, 0x7F]; | 664 | const NT35510_WRITES_31: &[u8] = &[NT35510_CMD_WRDISBV, 0x7F]; |
diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml index 5d7763334..565277394 100644 --- a/examples/stm32f7/Cargo.toml +++ b/examples/stm32f7/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32f7-examples" | 3 | name = "embassy-stm32f7-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32f7/src/bin/can.rs b/examples/stm32f7/src/bin/can.rs index 9a91ac814..2f3f6db84 100644 --- a/examples/stm32f7/src/bin/can.rs +++ b/examples/stm32f7/src/bin/can.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use core::num::{NonZeroU16, NonZeroU8}; | 4 | use core::num::{NonZeroU8, NonZeroU16}; |
| 5 | 5 | ||
| 6 | use defmt::*; | 6 | use defmt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
diff --git a/examples/stm32f7/src/bin/cryp.rs b/examples/stm32f7/src/bin/cryp.rs index a31e9b4f2..9ccef0b82 100644 --- a/examples/stm32f7/src/bin/cryp.rs +++ b/examples/stm32f7/src/bin/cryp.rs | |||
| @@ -1,13 +1,13 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use aes_gcm::Aes128Gcm; | ||
| 4 | use aes_gcm::aead::heapless::Vec; | 5 | use aes_gcm::aead::heapless::Vec; |
| 5 | use aes_gcm::aead::{AeadInPlace, KeyInit}; | 6 | use aes_gcm::aead::{AeadInPlace, KeyInit}; |
| 6 | use aes_gcm::Aes128Gcm; | ||
| 7 | use defmt::info; | 7 | use defmt::info; |
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::cryp::{self, *}; | 9 | use embassy_stm32::cryp::{self, *}; |
| 10 | use embassy_stm32::{bind_interrupts, peripherals, Config}; | 10 | use embassy_stm32::{Config, bind_interrupts, peripherals}; |
| 11 | use embassy_time::Instant; | 11 | use embassy_time::Instant; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs index b13b7bdda..f8a129239 100644 --- a/examples/stm32f7/src/bin/eth.rs +++ b/examples/stm32f7/src/bin/eth.rs | |||
| @@ -9,7 +9,7 @@ use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue}; | |||
| 9 | use embassy_stm32::peripherals::ETH; | 9 | use embassy_stm32::peripherals::ETH; |
| 10 | use embassy_stm32::rng::Rng; | 10 | use embassy_stm32::rng::Rng; |
| 11 | use embassy_stm32::time::Hertz; | 11 | use embassy_stm32::time::Hertz; |
| 12 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 12 | use embassy_stm32::{Config, bind_interrupts, eth, peripherals, rng}; |
| 13 | use embassy_time::Timer; | 13 | use embassy_time::Timer; |
| 14 | use embedded_io_async::Write; | 14 | use embedded_io_async::Write; |
| 15 | use static_cell::StaticCell; | 15 | use static_cell::StaticCell; |
diff --git a/examples/stm32f7/src/bin/hash.rs b/examples/stm32f7/src/bin/hash.rs index c2d1a7158..4fd465df6 100644 --- a/examples/stm32f7/src/bin/hash.rs +++ b/examples/stm32f7/src/bin/hash.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | use defmt::info; | 4 | use defmt::info; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::hash::*; | 6 | use embassy_stm32::hash::*; |
| 7 | use embassy_stm32::{bind_interrupts, hash, peripherals, Config}; | 7 | use embassy_stm32::{Config, bind_interrupts, hash, peripherals}; |
| 8 | use embassy_time::Instant; | 8 | use embassy_time::Instant; |
| 9 | use hmac::{Hmac, Mac}; | 9 | use hmac::{Hmac, Mac}; |
| 10 | use sha2::{Digest, Sha256}; | 10 | use sha2::{Digest, Sha256}; |
diff --git a/examples/stm32f7/src/bin/qspi.rs b/examples/stm32f7/src/bin/qspi.rs index 80652b865..e8ef3ad81 100644 --- a/examples/stm32f7/src/bin/qspi.rs +++ b/examples/stm32f7/src/bin/qspi.rs | |||
| @@ -4,11 +4,11 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::info; | 5 | use defmt::info; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::Config as StmCfg; | ||
| 7 | use embassy_stm32::mode::Async; | 8 | use embassy_stm32::mode::Async; |
| 8 | use embassy_stm32::qspi::enums::{AddressSize, ChipSelectHighTime, FIFOThresholdLevel, MemorySize, *}; | 9 | use embassy_stm32::qspi::enums::{AddressSize, ChipSelectHighTime, FIFOThresholdLevel, MemorySize, *}; |
| 9 | use embassy_stm32::qspi::{Config as QspiCfg, Instance, Qspi, TransferConfig}; | 10 | use embassy_stm32::qspi::{Config as QspiCfg, Instance, Qspi, TransferConfig}; |
| 10 | use embassy_stm32::time::mhz; | 11 | use embassy_stm32::time::mhz; |
| 11 | use embassy_stm32::Config as StmCfg; | ||
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | const MEMORY_PAGE_SIZE: usize = 256; | 14 | const MEMORY_PAGE_SIZE: usize = 256; |
diff --git a/examples/stm32f7/src/bin/sdmmc.rs b/examples/stm32f7/src/bin/sdmmc.rs index 787bef25e..8809b5d0c 100644 --- a/examples/stm32f7/src/bin/sdmmc.rs +++ b/examples/stm32f7/src/bin/sdmmc.rs | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::sdmmc::Sdmmc; | 6 | use embassy_stm32::sdmmc::Sdmmc; |
| 7 | use embassy_stm32::time::{mhz, Hertz}; | 7 | use embassy_stm32::time::{Hertz, mhz}; |
| 8 | use embassy_stm32::{bind_interrupts, peripherals, sdmmc, Config}; | 8 | use embassy_stm32::{Config, bind_interrupts, peripherals, sdmmc}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | bind_interrupts!(struct Irqs { | 11 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32f7/src/bin/usb_serial.rs b/examples/stm32f7/src/bin/usb_serial.rs index 349012888..9a30b2c20 100644 --- a/examples/stm32f7/src/bin/usb_serial.rs +++ b/examples/stm32f7/src/bin/usb_serial.rs | |||
| @@ -6,10 +6,10 @@ use embassy_executor::Spawner; | |||
| 6 | use embassy_futures::join::join; | 6 | use embassy_futures::join::join; |
| 7 | use embassy_stm32::time::Hertz; | 7 | use embassy_stm32::time::Hertz; |
| 8 | use embassy_stm32::usb::{Driver, Instance}; | 8 | use embassy_stm32::usb::{Driver, Instance}; |
| 9 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 9 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 10 | use embassy_usb::Builder; | ||
| 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 11 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 11 | use embassy_usb::driver::EndpointError; | 12 | use embassy_usb::driver::EndpointError; |
| 12 | use embassy_usb::Builder; | ||
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| 15 | bind_interrupts!(struct Irqs { | 15 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32g0/Cargo.toml b/examples/stm32g0/Cargo.toml index 1c9451469..16f28500d 100644 --- a/examples/stm32g0/Cargo.toml +++ b/examples/stm32g0/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32g0-examples" | 3 | name = "embassy-stm32g0-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32g0/src/bin/hf_timer.rs b/examples/stm32g0/src/bin/hf_timer.rs index 705905f01..88ee7ea86 100644 --- a/examples/stm32g0/src/bin/hf_timer.rs +++ b/examples/stm32g0/src/bin/hf_timer.rs | |||
| @@ -3,12 +3,12 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::info; | 4 | use defmt::info; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::Config as PeripheralConfig; | ||
| 6 | use embassy_stm32::gpio::OutputType; | 7 | use embassy_stm32::gpio::OutputType; |
| 7 | use embassy_stm32::time::khz; | 8 | use embassy_stm32::time::khz; |
| 9 | use embassy_stm32::timer::Channel; | ||
| 8 | use embassy_stm32::timer::complementary_pwm::{ComplementaryPwm, ComplementaryPwmPin}; | 10 | use embassy_stm32::timer::complementary_pwm::{ComplementaryPwm, ComplementaryPwmPin}; |
| 9 | use embassy_stm32::timer::simple_pwm::PwmPin; | 11 | use embassy_stm32::timer::simple_pwm::PwmPin; |
| 10 | use embassy_stm32::timer::Channel; | ||
| 11 | use embassy_stm32::Config as PeripheralConfig; | ||
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | #[embassy_executor::main] | 14 | #[embassy_executor::main] |
diff --git a/examples/stm32g0/src/bin/input_capture.rs b/examples/stm32g0/src/bin/input_capture.rs index 5501a6941..ca3e8eb41 100644 --- a/examples/stm32g0/src/bin/input_capture.rs +++ b/examples/stm32g0/src/bin/input_capture.rs | |||
| @@ -13,10 +13,10 @@ use defmt::*; | |||
| 13 | use embassy_executor::Spawner; | 13 | use embassy_executor::Spawner; |
| 14 | use embassy_stm32::gpio::{Level, Output, OutputType, Pull, Speed}; | 14 | use embassy_stm32::gpio::{Level, Output, OutputType, Pull, Speed}; |
| 15 | use embassy_stm32::time::khz; | 15 | use embassy_stm32::time::khz; |
| 16 | use embassy_stm32::timer::Channel; | ||
| 16 | use embassy_stm32::timer::input_capture::{CapturePin, InputCapture}; | 17 | use embassy_stm32::timer::input_capture::{CapturePin, InputCapture}; |
| 17 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; | 18 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; |
| 18 | use embassy_stm32::timer::Channel; | 19 | use embassy_stm32::{Peri, bind_interrupts, peripherals, timer}; |
| 19 | use embassy_stm32::{bind_interrupts, peripherals, timer, Peri}; | ||
| 20 | use embassy_time::Timer; | 20 | use embassy_time::Timer; |
| 21 | use {defmt_rtt as _, panic_probe as _}; | 21 | use {defmt_rtt as _, panic_probe as _}; |
| 22 | 22 | ||
diff --git a/examples/stm32g0/src/bin/pwm_complementary.rs b/examples/stm32g0/src/bin/pwm_complementary.rs index dbd9194c9..9856dd953 100644 --- a/examples/stm32g0/src/bin/pwm_complementary.rs +++ b/examples/stm32g0/src/bin/pwm_complementary.rs | |||
| @@ -17,9 +17,9 @@ use defmt::info; | |||
| 17 | use embassy_executor::Spawner; | 17 | use embassy_executor::Spawner; |
| 18 | use embassy_stm32::gpio::OutputType; | 18 | use embassy_stm32::gpio::OutputType; |
| 19 | use embassy_stm32::time::khz; | 19 | use embassy_stm32::time::khz; |
| 20 | use embassy_stm32::timer::Channel; | ||
| 20 | use embassy_stm32::timer::complementary_pwm::{ComplementaryPwm, ComplementaryPwmPin}; | 21 | use embassy_stm32::timer::complementary_pwm::{ComplementaryPwm, ComplementaryPwmPin}; |
| 21 | use embassy_stm32::timer::simple_pwm::PwmPin; | 22 | use embassy_stm32::timer::simple_pwm::PwmPin; |
| 22 | use embassy_stm32::timer::Channel; | ||
| 23 | use {defmt_rtt as _, panic_probe as _}; | 23 | use {defmt_rtt as _, panic_probe as _}; |
| 24 | 24 | ||
| 25 | #[embassy_executor::main] | 25 | #[embassy_executor::main] |
diff --git a/examples/stm32g0/src/bin/pwm_input.rs b/examples/stm32g0/src/bin/pwm_input.rs index 72aa07c03..5da19e077 100644 --- a/examples/stm32g0/src/bin/pwm_input.rs +++ b/examples/stm32g0/src/bin/pwm_input.rs | |||
| @@ -14,7 +14,7 @@ use embassy_stm32::gpio::{Level, Output, OutputType, Pull, Speed}; | |||
| 14 | use embassy_stm32::time::khz; | 14 | use embassy_stm32::time::khz; |
| 15 | use embassy_stm32::timer::pwm_input::PwmInput; | 15 | use embassy_stm32::timer::pwm_input::PwmInput; |
| 16 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; | 16 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; |
| 17 | use embassy_stm32::{bind_interrupts, peripherals, timer, Peri}; | 17 | use embassy_stm32::{Peri, bind_interrupts, peripherals, timer}; |
| 18 | use embassy_time::Timer; | 18 | use embassy_time::Timer; |
| 19 | use {defmt_rtt as _, panic_probe as _}; | 19 | use {defmt_rtt as _, panic_probe as _}; |
| 20 | 20 | ||
diff --git a/examples/stm32g0/src/bin/rtc.rs b/examples/stm32g0/src/bin/rtc.rs index 50fb6398e..21da204cc 100644 --- a/examples/stm32g0/src/bin/rtc.rs +++ b/examples/stm32g0/src/bin/rtc.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::rtc::{DateTime, DayOfWeek, Rtc, RtcConfig}; | ||
| 7 | use embassy_stm32::Config; | 6 | use embassy_stm32::Config; |
| 7 | use embassy_stm32::rtc::{DateTime, DayOfWeek, Rtc, RtcConfig}; | ||
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
diff --git a/examples/stm32g0/src/bin/usb_serial.rs b/examples/stm32g0/src/bin/usb_serial.rs index 162dfd86b..7dab393ac 100644 --- a/examples/stm32g0/src/bin/usb_serial.rs +++ b/examples/stm32g0/src/bin/usb_serial.rs | |||
| @@ -5,10 +5,10 @@ use defmt::{panic, *}; | |||
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_futures::join::join; | 6 | use embassy_futures::join::join; |
| 7 | use embassy_stm32::usb::{Driver, Instance}; | 7 | use embassy_stm32::usb::{Driver, Instance}; |
| 8 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 8 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 9 | use embassy_usb::Builder; | ||
| 9 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 10 | use embassy_usb::driver::EndpointError; | 11 | use embassy_usb::driver::EndpointError; |
| 11 | use embassy_usb::Builder; | ||
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | bind_interrupts!(struct Irqs { | 14 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32g4/Cargo.toml b/examples/stm32g4/Cargo.toml index 102960980..6fd282d6d 100644 --- a/examples/stm32g4/Cargo.toml +++ b/examples/stm32g4/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32g4-examples" | 3 | name = "embassy-stm32g4-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32g4/src/bin/adc.rs b/examples/stm32g4/src/bin/adc.rs index adca846d8..920142a18 100644 --- a/examples/stm32g4/src/bin/adc.rs +++ b/examples/stm32g4/src/bin/adc.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::adc::{Adc, SampleTime}; | ||
| 7 | use embassy_stm32::Config; | 6 | use embassy_stm32::Config; |
| 7 | use embassy_stm32::adc::{Adc, SampleTime}; | ||
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
diff --git a/examples/stm32g4/src/bin/adc_differential.rs b/examples/stm32g4/src/bin/adc_differential.rs index 78d071d45..301f0da84 100644 --- a/examples/stm32g4/src/bin/adc_differential.rs +++ b/examples/stm32g4/src/bin/adc_differential.rs | |||
| @@ -8,8 +8,8 @@ | |||
| 8 | 8 | ||
| 9 | use defmt::*; | 9 | use defmt::*; |
| 10 | use embassy_executor::Spawner; | 10 | use embassy_executor::Spawner; |
| 11 | use embassy_stm32::adc::{Adc, SampleTime}; | ||
| 12 | use embassy_stm32::Config; | 11 | use embassy_stm32::Config; |
| 12 | use embassy_stm32::adc::{Adc, SampleTime}; | ||
| 13 | use embassy_time::Timer; | 13 | use embassy_time::Timer; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 15 | ||
diff --git a/examples/stm32g4/src/bin/adc_dma.rs b/examples/stm32g4/src/bin/adc_dma.rs index 202704085..a82067049 100644 --- a/examples/stm32g4/src/bin/adc_dma.rs +++ b/examples/stm32g4/src/bin/adc_dma.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::adc::{Adc, AdcChannel as _, SampleTime}; | ||
| 7 | use embassy_stm32::Config; | 6 | use embassy_stm32::Config; |
| 7 | use embassy_stm32::adc::{Adc, AdcChannel as _, SampleTime}; | ||
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
diff --git a/examples/stm32g4/src/bin/adc_oversampling.rs b/examples/stm32g4/src/bin/adc_oversampling.rs index d31eb20f8..1e464183a 100644 --- a/examples/stm32g4/src/bin/adc_oversampling.rs +++ b/examples/stm32g4/src/bin/adc_oversampling.rs | |||
| @@ -7,9 +7,9 @@ | |||
| 7 | 7 | ||
| 8 | use defmt::*; | 8 | use defmt::*; |
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_stm32::Config; | ||
| 10 | use embassy_stm32::adc::vals::{Rovsm, Trovs}; | 11 | use embassy_stm32::adc::vals::{Rovsm, Trovs}; |
| 11 | use embassy_stm32::adc::{Adc, SampleTime}; | 12 | use embassy_stm32::adc::{Adc, SampleTime}; |
| 12 | use embassy_stm32::Config; | ||
| 13 | use embassy_time::Timer; | 13 | use embassy_time::Timer; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 15 | ||
diff --git a/examples/stm32g4/src/bin/can.rs b/examples/stm32g4/src/bin/can.rs index 90004f874..7ff7bd7b4 100644 --- a/examples/stm32g4/src/bin/can.rs +++ b/examples/stm32g4/src/bin/can.rs | |||
| @@ -4,7 +4,7 @@ use defmt::*; | |||
| 4 | use embassy_executor::Spawner; | 4 | use embassy_executor::Spawner; |
| 5 | use embassy_stm32::peripherals::*; | 5 | use embassy_stm32::peripherals::*; |
| 6 | use embassy_stm32::time::Hertz; | 6 | use embassy_stm32::time::Hertz; |
| 7 | use embassy_stm32::{bind_interrupts, can, Config}; | 7 | use embassy_stm32::{Config, bind_interrupts, can}; |
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use static_cell::StaticCell; | 9 | use static_cell::StaticCell; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
diff --git a/examples/stm32g4/src/bin/usb_c_pd.rs b/examples/stm32g4/src/bin/usb_c_pd.rs index 2e87d3931..b23984b3a 100644 --- a/examples/stm32g4/src/bin/usb_c_pd.rs +++ b/examples/stm32g4/src/bin/usb_c_pd.rs | |||
| @@ -1,11 +1,11 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use defmt::{error, info, Format}; | 4 | use defmt::{Format, error, info}; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::ucpd::{self, CcPhy, CcPull, CcSel, CcVState, Ucpd}; | 6 | use embassy_stm32::ucpd::{self, CcPhy, CcPull, CcSel, CcVState, Ucpd}; |
| 7 | use embassy_stm32::{bind_interrupts, peripherals, Config}; | 7 | use embassy_stm32::{Config, bind_interrupts, peripherals}; |
| 8 | use embassy_time::{with_timeout, Duration}; | 8 | use embassy_time::{Duration, with_timeout}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | bind_interrupts!(struct Irqs { | 11 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32g4/src/bin/usb_serial.rs b/examples/stm32g4/src/bin/usb_serial.rs index 9f66f0c53..a62da6d97 100644 --- a/examples/stm32g4/src/bin/usb_serial.rs +++ b/examples/stm32g4/src/bin/usb_serial.rs | |||
| @@ -6,10 +6,10 @@ use embassy_executor::Spawner; | |||
| 6 | use embassy_futures::join::join; | 6 | use embassy_futures::join::join; |
| 7 | use embassy_stm32::time::Hertz; | 7 | use embassy_stm32::time::Hertz; |
| 8 | use embassy_stm32::usb::{self, Driver, Instance}; | 8 | use embassy_stm32::usb::{self, Driver, Instance}; |
| 9 | use embassy_stm32::{bind_interrupts, peripherals, Config}; | 9 | use embassy_stm32::{Config, bind_interrupts, peripherals}; |
| 10 | use embassy_usb::Builder; | ||
| 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 11 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 11 | use embassy_usb::driver::EndpointError; | 12 | use embassy_usb::driver::EndpointError; |
| 12 | use embassy_usb::Builder; | ||
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| 15 | bind_interrupts!(struct Irqs { | 15 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32h5/Cargo.toml b/examples/stm32h5/Cargo.toml index 66680c027..475ba7e8a 100644 --- a/examples/stm32h5/Cargo.toml +++ b/examples/stm32h5/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32h5-examples" | 3 | name = "embassy-stm32h5-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32h5/src/bin/adc.rs b/examples/stm32h5/src/bin/adc.rs index c5d508ece..0566320d4 100644 --- a/examples/stm32h5/src/bin/adc.rs +++ b/examples/stm32h5/src/bin/adc.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::adc::{Adc, SampleTime}; | ||
| 7 | use embassy_stm32::Config; | 6 | use embassy_stm32::Config; |
| 7 | use embassy_stm32::adc::{Adc, SampleTime}; | ||
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
diff --git a/examples/stm32h5/src/bin/can.rs b/examples/stm32h5/src/bin/can.rs index 194239d47..b1923547e 100644 --- a/examples/stm32h5/src/bin/can.rs +++ b/examples/stm32h5/src/bin/can.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::peripherals::*; | 6 | use embassy_stm32::peripherals::*; |
| 7 | use embassy_stm32::{bind_interrupts, can, rcc, Config}; | 7 | use embassy_stm32::{Config, bind_interrupts, can, rcc}; |
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
diff --git a/examples/stm32h5/src/bin/dts.rs b/examples/stm32h5/src/bin/dts.rs index 8c18fafea..7c856b5b3 100644 --- a/examples/stm32h5/src/bin/dts.rs +++ b/examples/stm32h5/src/bin/dts.rs | |||
| @@ -6,7 +6,7 @@ use embassy_executor::Spawner; | |||
| 6 | use embassy_stm32::dts::{Dts, InterruptHandler, SampleTime}; | 6 | use embassy_stm32::dts::{Dts, InterruptHandler, SampleTime}; |
| 7 | use embassy_stm32::peripherals::DTS; | 7 | use embassy_stm32::peripherals::DTS; |
| 8 | use embassy_stm32::rcc::frequency; | 8 | use embassy_stm32::rcc::frequency; |
| 9 | use embassy_stm32::{bind_interrupts, dts, Config}; | 9 | use embassy_stm32::{Config, bind_interrupts, dts}; |
| 10 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
diff --git a/examples/stm32h5/src/bin/eth.rs b/examples/stm32h5/src/bin/eth.rs index a84fe358b..a5c6cee26 100644 --- a/examples/stm32h5/src/bin/eth.rs +++ b/examples/stm32h5/src/bin/eth.rs | |||
| @@ -12,7 +12,7 @@ use embassy_stm32::rcc::{ | |||
| 12 | }; | 12 | }; |
| 13 | use embassy_stm32::rng::Rng; | 13 | use embassy_stm32::rng::Rng; |
| 14 | use embassy_stm32::time::Hertz; | 14 | use embassy_stm32::time::Hertz; |
| 15 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 15 | use embassy_stm32::{Config, bind_interrupts, eth, peripherals, rng}; |
| 16 | use embassy_time::Timer; | 16 | use embassy_time::Timer; |
| 17 | use embedded_io_async::Write; | 17 | use embedded_io_async::Write; |
| 18 | use static_cell::StaticCell; | 18 | use static_cell::StaticCell; |
diff --git a/examples/stm32h5/src/bin/mco.rs b/examples/stm32h5/src/bin/mco.rs new file mode 100644 index 000000000..1137ba25c --- /dev/null +++ b/examples/stm32h5/src/bin/mco.rs | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | |||
| 4 | use defmt::*; | ||
| 5 | use embassy_executor::Spawner; | ||
| 6 | use embassy_stm32::gpio::Speed; | ||
| 7 | use embassy_stm32::rcc::{Mco, Mco2Source, McoConfig}; | ||
| 8 | use {defmt_rtt as _, panic_probe as _}; | ||
| 9 | |||
| 10 | #[embassy_executor::main] | ||
| 11 | async fn main(_spawner: Spawner) { | ||
| 12 | let p = embassy_stm32::init(Default::default()); | ||
| 13 | |||
| 14 | /* Default "VeryHigh" drive strength and prescaler DIV1 */ | ||
| 15 | // let _mco = Mco::new(p.MCO2, p.PC9, Mco2Source::SYS, McoConfig::default()); | ||
| 16 | |||
| 17 | /* Choose Speed::Low drive strength */ | ||
| 18 | let config = { | ||
| 19 | let mut config = McoConfig::default(); | ||
| 20 | config.speed = Speed::Low; | ||
| 21 | config | ||
| 22 | }; | ||
| 23 | |||
| 24 | let _mco = Mco::new(p.MCO2, p.PC9, Mco2Source::SYS, config); | ||
| 25 | |||
| 26 | info!("Clock out with low drive strength set on Master Clock Out 2 pin as AF on PC9"); | ||
| 27 | |||
| 28 | loop {} | ||
| 29 | } | ||
diff --git a/examples/stm32h5/src/bin/sai.rs b/examples/stm32h5/src/bin/sai.rs index 0e182f9cf..6632a7f98 100644 --- a/examples/stm32h5/src/bin/sai.rs +++ b/examples/stm32h5/src/bin/sai.rs | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::info; | 4 | use defmt::info; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::{sai, Config}; | 6 | use embassy_stm32::{Config, sai}; |
| 7 | use {defmt_rtt as _, panic_probe as _}; | 7 | use {defmt_rtt as _, panic_probe as _}; |
| 8 | 8 | ||
| 9 | #[embassy_executor::main] | 9 | #[embassy_executor::main] |
diff --git a/examples/stm32h5/src/bin/usb_c_pd.rs b/examples/stm32h5/src/bin/usb_c_pd.rs index acb03e498..ab6efff32 100644 --- a/examples/stm32h5/src/bin/usb_c_pd.rs +++ b/examples/stm32h5/src/bin/usb_c_pd.rs | |||
| @@ -3,12 +3,12 @@ | |||
| 3 | #![no_std] | 3 | #![no_std] |
| 4 | #![no_main] | 4 | #![no_main] |
| 5 | 5 | ||
| 6 | use defmt::{error, info, Format}; | 6 | use defmt::{Format, error, info}; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::gpio::Output; | 8 | use embassy_stm32::gpio::Output; |
| 9 | use embassy_stm32::ucpd::{self, CcPhy, CcPull, CcSel, CcVState, Ucpd}; | 9 | use embassy_stm32::ucpd::{self, CcPhy, CcPull, CcSel, CcVState, Ucpd}; |
| 10 | use embassy_stm32::{bind_interrupts, peripherals, Config}; | 10 | use embassy_stm32::{Config, bind_interrupts, peripherals}; |
| 11 | use embassy_time::{with_timeout, Duration}; | 11 | use embassy_time::{Duration, with_timeout}; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | bind_interrupts!(struct Irqs { | 14 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32h5/src/bin/usb_serial.rs b/examples/stm32h5/src/bin/usb_serial.rs index e8f536133..f72851ed7 100644 --- a/examples/stm32h5/src/bin/usb_serial.rs +++ b/examples/stm32h5/src/bin/usb_serial.rs | |||
| @@ -6,10 +6,10 @@ use embassy_executor::Spawner; | |||
| 6 | use embassy_futures::join::join; | 6 | use embassy_futures::join::join; |
| 7 | use embassy_stm32::time::Hertz; | 7 | use embassy_stm32::time::Hertz; |
| 8 | use embassy_stm32::usb::{Driver, Instance}; | 8 | use embassy_stm32::usb::{Driver, Instance}; |
| 9 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 9 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 10 | use embassy_usb::Builder; | ||
| 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 11 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 11 | use embassy_usb::driver::EndpointError; | 12 | use embassy_usb::driver::EndpointError; |
| 12 | use embassy_usb::Builder; | ||
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| 15 | bind_interrupts!(struct Irqs { | 15 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32h5/src/bin/usb_uac_speaker.rs b/examples/stm32h5/src/bin/usb_uac_speaker.rs index 86873cabd..f75b1fd8a 100644 --- a/examples/stm32h5/src/bin/usb_uac_speaker.rs +++ b/examples/stm32h5/src/bin/usb_uac_speaker.rs | |||
| @@ -6,9 +6,9 @@ use core::cell::{Cell, RefCell}; | |||
| 6 | use defmt::{panic, *}; | 6 | use defmt::{panic, *}; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::time::Hertz; | 8 | use embassy_stm32::time::Hertz; |
| 9 | use embassy_stm32::{bind_interrupts, interrupt, peripherals, timer, usb, Config}; | 9 | use embassy_stm32::{Config, bind_interrupts, interrupt, peripherals, timer, usb}; |
| 10 | use embassy_sync::blocking_mutex::raw::{CriticalSectionRawMutex, NoopRawMutex}; | ||
| 11 | use embassy_sync::blocking_mutex::Mutex; | 10 | use embassy_sync::blocking_mutex::Mutex; |
| 11 | use embassy_sync::blocking_mutex::raw::{CriticalSectionRawMutex, NoopRawMutex}; | ||
| 12 | use embassy_sync::signal::Signal; | 12 | use embassy_sync::signal::Signal; |
| 13 | use embassy_sync::zerocopy_channel; | 13 | use embassy_sync::zerocopy_channel; |
| 14 | use embassy_usb::class::uac1; | 14 | use embassy_usb::class::uac1; |
diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index 9a2080013..5993110de 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32h7-examples" | 3 | name = "embassy-stm32h7-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32h7/src/bin/adc.rs b/examples/stm32h7/src/bin/adc.rs index 98504ddf6..a53c9d8d5 100644 --- a/examples/stm32h7/src/bin/adc.rs +++ b/examples/stm32h7/src/bin/adc.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::adc::{Adc, SampleTime}; | ||
| 7 | use embassy_stm32::Config; | 6 | use embassy_stm32::Config; |
| 7 | use embassy_stm32::adc::{Adc, SampleTime}; | ||
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
diff --git a/examples/stm32h7/src/bin/adc_dma.rs b/examples/stm32h7/src/bin/adc_dma.rs index f06b5d06e..cedb32e47 100644 --- a/examples/stm32h7/src/bin/adc_dma.rs +++ b/examples/stm32h7/src/bin/adc_dma.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::adc::{Adc, AdcChannel as _, SampleTime}; | ||
| 7 | use embassy_stm32::Config; | 6 | use embassy_stm32::Config; |
| 7 | use embassy_stm32::adc::{Adc, AdcChannel as _, SampleTime}; | ||
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
diff --git a/examples/stm32h7/src/bin/camera.rs b/examples/stm32h7/src/bin/camera.rs index 8f2e265d6..c593d5e0b 100644 --- a/examples/stm32h7/src/bin/camera.rs +++ b/examples/stm32h7/src/bin/camera.rs | |||
| @@ -5,8 +5,8 @@ use embassy_executor::Spawner; | |||
| 5 | use embassy_stm32::dcmi::{self, *}; | 5 | use embassy_stm32::dcmi::{self, *}; |
| 6 | use embassy_stm32::gpio::{Level, Output, Speed}; | 6 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 7 | use embassy_stm32::i2c::I2c; | 7 | use embassy_stm32::i2c::I2c; |
| 8 | use embassy_stm32::rcc::{Mco, Mco1Source, McoPrescaler}; | 8 | use embassy_stm32::rcc::{Mco, Mco1Source, McoConfig, McoPrescaler}; |
| 9 | use embassy_stm32::{bind_interrupts, i2c, peripherals, Config}; | 9 | use embassy_stm32::{Config, bind_interrupts, i2c, peripherals}; |
| 10 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 11 | use ov7725::*; | 11 | use ov7725::*; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -48,7 +48,14 @@ async fn main(_spawner: Spawner) { | |||
| 48 | let p = embassy_stm32::init(config); | 48 | let p = embassy_stm32::init(config); |
| 49 | 49 | ||
| 50 | defmt::info!("Hello World!"); | 50 | defmt::info!("Hello World!"); |
| 51 | let mco = Mco::new(p.MCO1, p.PA8, Mco1Source::HSI, McoPrescaler::DIV3); | 51 | |
| 52 | let mco_config = { | ||
| 53 | let mut config = McoConfig::default(); | ||
| 54 | config.prescaler = McoPrescaler::DIV3; | ||
| 55 | config | ||
| 56 | }; | ||
| 57 | |||
| 58 | let mco = Mco::new(p.MCO1, p.PA8, Mco1Source::HSI, mco_config); | ||
| 52 | 59 | ||
| 53 | let mut led = Output::new(p.PE3, Level::High, Speed::Low); | 60 | let mut led = Output::new(p.PE3, Level::High, Speed::Low); |
| 54 | let cam_i2c = I2c::new(p.I2C1, p.PB8, p.PB9, Irqs, p.DMA1_CH1, p.DMA1_CH2, Default::default()); | 61 | let cam_i2c = I2c::new(p.I2C1, p.PB8, p.PB9, Irqs, p.DMA1_CH1, p.DMA1_CH2, Default::default()); |
diff --git a/examples/stm32h7/src/bin/can.rs b/examples/stm32h7/src/bin/can.rs index 0af11ef3e..49830f9b7 100644 --- a/examples/stm32h7/src/bin/can.rs +++ b/examples/stm32h7/src/bin/can.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::peripherals::*; | 6 | use embassy_stm32::peripherals::*; |
| 7 | use embassy_stm32::{bind_interrupts, can, rcc, Config}; | 7 | use embassy_stm32::{Config, bind_interrupts, can, rcc}; |
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
diff --git a/examples/stm32h7/src/bin/dac.rs b/examples/stm32h7/src/bin/dac.rs index 27df80336..fa22837c5 100644 --- a/examples/stm32h7/src/bin/dac.rs +++ b/examples/stm32h7/src/bin/dac.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use cortex_m_rt::entry; | 4 | use cortex_m_rt::entry; |
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_stm32::dac::{DacCh1, Value}; | ||
| 7 | use embassy_stm32::Config; | 6 | use embassy_stm32::Config; |
| 7 | use embassy_stm32::dac::{DacCh1, Value}; | ||
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[entry] | 10 | #[entry] |
diff --git a/examples/stm32h7/src/bin/dac_dma.rs b/examples/stm32h7/src/bin/dac_dma.rs index df37e9d78..9ccefa761 100644 --- a/examples/stm32h7/src/bin/dac_dma.rs +++ b/examples/stm32h7/src/bin/dac_dma.rs | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::Peri; | ||
| 6 | use embassy_stm32::dac::{DacCh1, DacCh2, ValueArray}; | 7 | use embassy_stm32::dac::{DacCh1, DacCh2, ValueArray}; |
| 7 | use embassy_stm32::mode::Async; | 8 | use embassy_stm32::mode::Async; |
| 8 | use embassy_stm32::pac::timer::vals::Mms; | 9 | use embassy_stm32::pac::timer::vals::Mms; |
| @@ -10,7 +11,6 @@ use embassy_stm32::peripherals::{DAC1, TIM6, TIM7}; | |||
| 10 | use embassy_stm32::rcc::frequency; | 11 | use embassy_stm32::rcc::frequency; |
| 11 | use embassy_stm32::time::Hertz; | 12 | use embassy_stm32::time::Hertz; |
| 12 | use embassy_stm32::timer::low_level::Timer; | 13 | use embassy_stm32::timer::low_level::Timer; |
| 13 | use embassy_stm32::Peri; | ||
| 14 | use micromath::F32Ext; | 14 | use micromath::F32Ext; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 16 | ||
diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index 6c215362d..589f4426e 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs | |||
| @@ -8,7 +8,7 @@ use embassy_net::{Ipv4Address, StackResources}; | |||
| 8 | use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue}; | 8 | use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue}; |
| 9 | use embassy_stm32::peripherals::ETH; | 9 | use embassy_stm32::peripherals::ETH; |
| 10 | use embassy_stm32::rng::Rng; | 10 | use embassy_stm32::rng::Rng; |
| 11 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 11 | use embassy_stm32::{Config, bind_interrupts, eth, peripherals, rng}; |
| 12 | use embassy_time::Timer; | 12 | use embassy_time::Timer; |
| 13 | use embedded_io_async::Write; | 13 | use embedded_io_async::Write; |
| 14 | use static_cell::StaticCell; | 14 | use static_cell::StaticCell; |
diff --git a/examples/stm32h7/src/bin/eth_client.rs b/examples/stm32h7/src/bin/eth_client.rs index 10ac57fc9..fed8f1a9c 100644 --- a/examples/stm32h7/src/bin/eth_client.rs +++ b/examples/stm32h7/src/bin/eth_client.rs | |||
| @@ -5,12 +5,12 @@ use core::net::{Ipv4Addr, SocketAddr, SocketAddrV4}; | |||
| 5 | 5 | ||
| 6 | use defmt::*; | 6 | use defmt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_net::tcp::client::{TcpClient, TcpClientState}; | ||
| 9 | use embassy_net::StackResources; | 8 | use embassy_net::StackResources; |
| 9 | use embassy_net::tcp::client::{TcpClient, TcpClientState}; | ||
| 10 | use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue}; | 10 | use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue}; |
| 11 | use embassy_stm32::peripherals::ETH; | 11 | use embassy_stm32::peripherals::ETH; |
| 12 | use embassy_stm32::rng::Rng; | 12 | use embassy_stm32::rng::Rng; |
| 13 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 13 | use embassy_stm32::{Config, bind_interrupts, eth, peripherals, rng}; |
| 14 | use embassy_time::Timer; | 14 | use embassy_time::Timer; |
| 15 | use embedded_io_async::Write; | 15 | use embedded_io_async::Write; |
| 16 | use embedded_nal_async::TcpConnect; | 16 | use embedded_nal_async::TcpConnect; |
diff --git a/examples/stm32h7/src/bin/eth_client_mii.rs b/examples/stm32h7/src/bin/eth_client_mii.rs index c6a108471..c3c631f0f 100644 --- a/examples/stm32h7/src/bin/eth_client_mii.rs +++ b/examples/stm32h7/src/bin/eth_client_mii.rs | |||
| @@ -5,12 +5,12 @@ use core::net::{Ipv4Addr, SocketAddr, SocketAddrV4}; | |||
| 5 | 5 | ||
| 6 | use defmt::*; | 6 | use defmt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_net::tcp::client::{TcpClient, TcpClientState}; | ||
| 9 | use embassy_net::StackResources; | 8 | use embassy_net::StackResources; |
| 9 | use embassy_net::tcp::client::{TcpClient, TcpClientState}; | ||
| 10 | use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue}; | 10 | use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue}; |
| 11 | use embassy_stm32::peripherals::ETH; | 11 | use embassy_stm32::peripherals::ETH; |
| 12 | use embassy_stm32::rng::Rng; | 12 | use embassy_stm32::rng::Rng; |
| 13 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 13 | use embassy_stm32::{Config, bind_interrupts, eth, peripherals, rng}; |
| 14 | use embassy_time::Timer; | 14 | use embassy_time::Timer; |
| 15 | use embedded_io_async::Write; | 15 | use embedded_io_async::Write; |
| 16 | use embedded_nal_async::TcpConnect; | 16 | use embedded_nal_async::TcpConnect; |
diff --git a/examples/stm32h7/src/bin/fmc.rs b/examples/stm32h7/src/bin/fmc.rs index 5e5e6ccc8..b65d50443 100644 --- a/examples/stm32h7/src/bin/fmc.rs +++ b/examples/stm32h7/src/bin/fmc.rs | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::fmc::Fmc; | ||
| 7 | use embassy_stm32::Config; | 6 | use embassy_stm32::Config; |
| 7 | use embassy_stm32::fmc::Fmc; | ||
| 8 | use embassy_time::{Delay, Timer}; | 8 | use embassy_time::{Delay, Timer}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
diff --git a/examples/stm32h7/src/bin/i2c_shared.rs b/examples/stm32h7/src/bin/i2c_shared.rs index 9e45d845f..08ff812f2 100644 --- a/examples/stm32h7/src/bin/i2c_shared.rs +++ b/examples/stm32h7/src/bin/i2c_shared.rs | |||
| @@ -9,8 +9,8 @@ use embassy_executor::Spawner; | |||
| 9 | use embassy_stm32::i2c::{self, I2c}; | 9 | use embassy_stm32::i2c::{self, I2c}; |
| 10 | use embassy_stm32::mode::Async; | 10 | use embassy_stm32::mode::Async; |
| 11 | use embassy_stm32::{bind_interrupts, peripherals}; | 11 | use embassy_stm32::{bind_interrupts, peripherals}; |
| 12 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | ||
| 13 | use embassy_sync::blocking_mutex::NoopMutex; | 12 | use embassy_sync::blocking_mutex::NoopMutex; |
| 13 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | ||
| 14 | use embassy_time::{Duration, Timer}; | 14 | use embassy_time::{Duration, Timer}; |
| 15 | use embedded_hal_1::i2c::I2c as _; | 15 | use embedded_hal_1::i2c::I2c as _; |
| 16 | use static_cell::StaticCell; | 16 | use static_cell::StaticCell; |
diff --git a/examples/stm32h7/src/bin/low_level_timer_api.rs b/examples/stm32h7/src/bin/low_level_timer_api.rs index 12abb8693..f17fb2aaa 100644 --- a/examples/stm32h7/src/bin/low_level_timer_api.rs +++ b/examples/stm32h7/src/bin/low_level_timer_api.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::gpio::{AfType, Flex, OutputType, Speed}; | 6 | use embassy_stm32::gpio::{AfType, Flex, OutputType, Speed}; |
| 7 | use embassy_stm32::time::{khz, Hertz}; | 7 | use embassy_stm32::time::{Hertz, khz}; |
| 8 | use embassy_stm32::timer::low_level::{OutputCompareMode, Timer as LLTimer}; | 8 | use embassy_stm32::timer::low_level::{OutputCompareMode, Timer as LLTimer}; |
| 9 | use embassy_stm32::timer::{Ch1, Ch2, Ch3, Ch4, Channel, GeneralInstance32bit4Channel, TimerPin}; | 9 | use embassy_stm32::timer::{Ch1, Ch2, Ch3, Ch4, Channel, GeneralInstance32bit4Channel, TimerPin}; |
| 10 | use embassy_stm32::{Config, Peri}; | 10 | use embassy_stm32::{Config, Peri}; |
diff --git a/examples/stm32h7/src/bin/mco.rs b/examples/stm32h7/src/bin/mco.rs index a6ee27625..cafcb90f6 100644 --- a/examples/stm32h7/src/bin/mco.rs +++ b/examples/stm32h7/src/bin/mco.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::gpio::{Level, Output, Speed}; | 6 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 7 | use embassy_stm32::rcc::{Mco, Mco1Source, McoPrescaler}; | 7 | use embassy_stm32::rcc::{Mco, Mco1Source, McoConfig, McoPrescaler}; |
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| @@ -15,7 +15,13 @@ async fn main(_spawner: Spawner) { | |||
| 15 | 15 | ||
| 16 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); | 16 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); |
| 17 | 17 | ||
| 18 | let _mco = Mco::new(p.MCO1, p.PA8, Mco1Source::HSI, McoPrescaler::DIV8); | 18 | let config = { |
| 19 | let mut config = McoConfig::default(); | ||
| 20 | config.prescaler = McoPrescaler::DIV8; | ||
| 21 | config | ||
| 22 | }; | ||
| 23 | |||
| 24 | let _mco = Mco::new(p.MCO1, p.PA8, Mco1Source::HSI, config); | ||
| 19 | 25 | ||
| 20 | loop { | 26 | loop { |
| 21 | info!("high"); | 27 | info!("high"); |
diff --git a/examples/stm32h7/src/bin/multiprio.rs b/examples/stm32h7/src/bin/multiprio.rs index 2f2ffdea2..8375e0e8e 100644 --- a/examples/stm32h7/src/bin/multiprio.rs +++ b/examples/stm32h7/src/bin/multiprio.rs | |||
| @@ -113,12 +113,12 @@ static EXECUTOR_LOW: StaticCell<Executor> = StaticCell::new(); | |||
| 113 | 113 | ||
| 114 | #[interrupt] | 114 | #[interrupt] |
| 115 | unsafe fn UART4() { | 115 | unsafe fn UART4() { |
| 116 | EXECUTOR_HIGH.on_interrupt() | 116 | unsafe { EXECUTOR_HIGH.on_interrupt() } |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | #[interrupt] | 119 | #[interrupt] |
| 120 | unsafe fn UART5() { | 120 | unsafe fn UART5() { |
| 121 | EXECUTOR_MED.on_interrupt() | 121 | unsafe { EXECUTOR_MED.on_interrupt() } |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | #[entry] | 124 | #[entry] |
diff --git a/examples/stm32h7/src/bin/pwm.rs b/examples/stm32h7/src/bin/pwm.rs index 73b43be69..ffd117580 100644 --- a/examples/stm32h7/src/bin/pwm.rs +++ b/examples/stm32h7/src/bin/pwm.rs | |||
| @@ -3,10 +3,10 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::Config; | ||
| 6 | use embassy_stm32::gpio::OutputType; | 7 | use embassy_stm32::gpio::OutputType; |
| 7 | use embassy_stm32::time::khz; | 8 | use embassy_stm32::time::khz; |
| 8 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; | 9 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; |
| 9 | use embassy_stm32::Config; | ||
| 10 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
diff --git a/examples/stm32h7/src/bin/rng.rs b/examples/stm32h7/src/bin/rng.rs index a9ef7200d..489747678 100644 --- a/examples/stm32h7/src/bin/rng.rs +++ b/examples/stm32h7/src/bin/rng.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::rng::Rng; | 6 | use embassy_stm32::rng::Rng; |
| 7 | use embassy_stm32::{bind_interrupts, peripherals, rng, Config}; | 7 | use embassy_stm32::{Config, bind_interrupts, peripherals, rng}; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | bind_interrupts!(struct Irqs { | 10 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32h7/src/bin/rtc.rs b/examples/stm32h7/src/bin/rtc.rs index 0adb48877..1bd71637b 100644 --- a/examples/stm32h7/src/bin/rtc.rs +++ b/examples/stm32h7/src/bin/rtc.rs | |||
| @@ -4,9 +4,9 @@ | |||
| 4 | use chrono::{NaiveDate, NaiveDateTime}; | 4 | use chrono::{NaiveDate, NaiveDateTime}; |
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::Config; | ||
| 7 | use embassy_stm32::rcc::LsConfig; | 8 | use embassy_stm32::rcc::LsConfig; |
| 8 | use embassy_stm32::rtc::{Rtc, RtcConfig}; | 9 | use embassy_stm32::rtc::{Rtc, RtcConfig}; |
| 9 | use embassy_stm32::Config; | ||
| 10 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
diff --git a/examples/stm32h7/src/bin/sdmmc.rs b/examples/stm32h7/src/bin/sdmmc.rs index 96840d8ff..4977fec79 100644 --- a/examples/stm32h7/src/bin/sdmmc.rs +++ b/examples/stm32h7/src/bin/sdmmc.rs | |||
| @@ -5,7 +5,7 @@ use defmt::*; | |||
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::sdmmc::Sdmmc; | 6 | use embassy_stm32::sdmmc::Sdmmc; |
| 7 | use embassy_stm32::time::mhz; | 7 | use embassy_stm32::time::mhz; |
| 8 | use embassy_stm32::{bind_interrupts, peripherals, sdmmc, Config}; | 8 | use embassy_stm32::{Config, bind_interrupts, peripherals, sdmmc}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | bind_interrupts!(struct Irqs { | 11 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32h7/src/bin/spi.rs b/examples/stm32h7/src/bin/spi.rs index dce30a4a7..61f31be24 100644 --- a/examples/stm32h7/src/bin/spi.rs +++ b/examples/stm32h7/src/bin/spi.rs | |||
| @@ -9,7 +9,7 @@ use defmt::*; | |||
| 9 | use embassy_executor::Executor; | 9 | use embassy_executor::Executor; |
| 10 | use embassy_stm32::mode::Blocking; | 10 | use embassy_stm32::mode::Blocking; |
| 11 | use embassy_stm32::time::mhz; | 11 | use embassy_stm32::time::mhz; |
| 12 | use embassy_stm32::{spi, Config}; | 12 | use embassy_stm32::{Config, spi}; |
| 13 | use heapless::String; | 13 | use heapless::String; |
| 14 | use static_cell::StaticCell; | 14 | use static_cell::StaticCell; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
diff --git a/examples/stm32h7/src/bin/spi_bdma.rs b/examples/stm32h7/src/bin/spi_bdma.rs index 828f687b8..be6a26d82 100644 --- a/examples/stm32h7/src/bin/spi_bdma.rs +++ b/examples/stm32h7/src/bin/spi_bdma.rs | |||
| @@ -9,7 +9,7 @@ use defmt::*; | |||
| 9 | use embassy_executor::Executor; | 9 | use embassy_executor::Executor; |
| 10 | use embassy_stm32::mode::Async; | 10 | use embassy_stm32::mode::Async; |
| 11 | use embassy_stm32::time::mhz; | 11 | use embassy_stm32::time::mhz; |
| 12 | use embassy_stm32::{spi, Config}; | 12 | use embassy_stm32::{Config, spi}; |
| 13 | use grounded::uninit::GroundedArrayCell; | 13 | use grounded::uninit::GroundedArrayCell; |
| 14 | use heapless::String; | 14 | use heapless::String; |
| 15 | use static_cell::StaticCell; | 15 | use static_cell::StaticCell; |
diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs index 2197fabce..20cb67ba0 100644 --- a/examples/stm32h7/src/bin/spi_dma.rs +++ b/examples/stm32h7/src/bin/spi_dma.rs | |||
| @@ -9,7 +9,7 @@ use defmt::*; | |||
| 9 | use embassy_executor::Executor; | 9 | use embassy_executor::Executor; |
| 10 | use embassy_stm32::mode::Async; | 10 | use embassy_stm32::mode::Async; |
| 11 | use embassy_stm32::time::mhz; | 11 | use embassy_stm32::time::mhz; |
| 12 | use embassy_stm32::{spi, Config}; | 12 | use embassy_stm32::{Config, spi}; |
| 13 | use heapless::String; | 13 | use heapless::String; |
| 14 | use static_cell::StaticCell; | 14 | use static_cell::StaticCell; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
diff --git a/examples/stm32h7/src/bin/usb_serial.rs b/examples/stm32h7/src/bin/usb_serial.rs index 50bb964da..d0470101b 100644 --- a/examples/stm32h7/src/bin/usb_serial.rs +++ b/examples/stm32h7/src/bin/usb_serial.rs | |||
| @@ -5,10 +5,10 @@ use defmt::{panic, *}; | |||
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_futures::join::join; | 6 | use embassy_futures::join::join; |
| 7 | use embassy_stm32::usb::{Driver, Instance}; | 7 | use embassy_stm32::usb::{Driver, Instance}; |
| 8 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 8 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 9 | use embassy_usb::Builder; | ||
| 9 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 10 | use embassy_usb::driver::EndpointError; | 11 | use embassy_usb::driver::EndpointError; |
| 11 | use embassy_usb::Builder; | ||
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | bind_interrupts!(struct Irqs { | 14 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32h723/Cargo.toml b/examples/stm32h723/Cargo.toml index 7e4ccc528..93a5109e2 100644 --- a/examples/stm32h723/Cargo.toml +++ b/examples/stm32h723/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32h723-examples" | 3 | name = "embassy-stm32h723-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32h723/src/bin/spdifrx.rs b/examples/stm32h723/src/bin/spdifrx.rs index b75a03ae8..cdbd69b89 100644 --- a/examples/stm32h723/src/bin/spdifrx.rs +++ b/examples/stm32h723/src/bin/spdifrx.rs | |||
| @@ -7,9 +7,9 @@ | |||
| 7 | 7 | ||
| 8 | use defmt::{info, trace}; | 8 | use defmt::{info, trace}; |
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_futures::select::{select, Either}; | 10 | use embassy_futures::select::{Either, select}; |
| 11 | use embassy_stm32::spdifrx::{self, Spdifrx}; | 11 | use embassy_stm32::spdifrx::{self, Spdifrx}; |
| 12 | use embassy_stm32::{bind_interrupts, peripherals, sai, Peri}; | 12 | use embassy_stm32::{Peri, bind_interrupts, peripherals, sai}; |
| 13 | use grounded::uninit::GroundedArrayCell; | 13 | use grounded::uninit::GroundedArrayCell; |
| 14 | use hal::sai::*; | 14 | use hal::sai::*; |
| 15 | use {defmt_rtt as _, embassy_stm32 as hal, panic_probe as _}; | 15 | use {defmt_rtt as _, embassy_stm32 as hal, panic_probe as _}; |
diff --git a/examples/stm32h735/Cargo.toml b/examples/stm32h735/Cargo.toml index 22b7ad96a..1ad2eeb2e 100644 --- a/examples/stm32h735/Cargo.toml +++ b/examples/stm32h735/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32h735-examples" | 3 | name = "embassy-stm32h735-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32h735/src/bin/ltdc.rs b/examples/stm32h735/src/bin/ltdc.rs index 8a99f745d..f042e04c2 100644 --- a/examples/stm32h735/src/bin/ltdc.rs +++ b/examples/stm32h735/src/bin/ltdc.rs | |||
| @@ -15,14 +15,14 @@ use embassy_stm32::gpio::{Level, Output, Speed}; | |||
| 15 | use embassy_stm32::ltdc::{self, Ltdc, LtdcConfiguration, LtdcLayer, LtdcLayerConfig, PolarityActive, PolarityEdge}; | 15 | use embassy_stm32::ltdc::{self, Ltdc, LtdcConfiguration, LtdcLayer, LtdcLayerConfig, PolarityActive, PolarityEdge}; |
| 16 | use embassy_stm32::{bind_interrupts, peripherals}; | 16 | use embassy_stm32::{bind_interrupts, peripherals}; |
| 17 | use embassy_time::{Duration, Timer}; | 17 | use embassy_time::{Duration, Timer}; |
| 18 | use embedded_graphics::Pixel; | ||
| 18 | use embedded_graphics::draw_target::DrawTarget; | 19 | use embedded_graphics::draw_target::DrawTarget; |
| 19 | use embedded_graphics::geometry::{OriginDimensions, Point, Size}; | 20 | use embedded_graphics::geometry::{OriginDimensions, Point, Size}; |
| 20 | use embedded_graphics::image::Image; | 21 | use embedded_graphics::image::Image; |
| 21 | use embedded_graphics::pixelcolor::raw::RawU24; | ||
| 22 | use embedded_graphics::pixelcolor::Rgb888; | 22 | use embedded_graphics::pixelcolor::Rgb888; |
| 23 | use embedded_graphics::pixelcolor::raw::RawU24; | ||
| 23 | use embedded_graphics::prelude::*; | 24 | use embedded_graphics::prelude::*; |
| 24 | use embedded_graphics::primitives::Rectangle; | 25 | use embedded_graphics::primitives::Rectangle; |
| 25 | use embedded_graphics::Pixel; | ||
| 26 | use heapless::{Entry, FnvIndexMap}; | 26 | use heapless::{Entry, FnvIndexMap}; |
| 27 | use tinybmp::Bmp; | 27 | use tinybmp::Bmp; |
| 28 | use {defmt_rtt as _, panic_probe as _}; | 28 | use {defmt_rtt as _, panic_probe as _}; |
diff --git a/examples/stm32h742/Cargo.toml b/examples/stm32h742/Cargo.toml index c76340b5f..9b5e5d93d 100644 --- a/examples/stm32h742/Cargo.toml +++ b/examples/stm32h742/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32h742-examples" | 3 | name = "embassy-stm32h742-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32h742/src/bin/qspi.rs b/examples/stm32h742/src/bin/qspi.rs index 9e79d7089..a88c8f249 100644 --- a/examples/stm32h742/src/bin/qspi.rs +++ b/examples/stm32h742/src/bin/qspi.rs | |||
| @@ -4,10 +4,10 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::info; | 5 | use defmt::info; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::Config as StmCfg; | ||
| 7 | use embassy_stm32::mode::Blocking; | 8 | use embassy_stm32::mode::Blocking; |
| 8 | use embassy_stm32::qspi::enums::{AddressSize, ChipSelectHighTime, FIFOThresholdLevel, MemorySize, *}; | 9 | use embassy_stm32::qspi::enums::{AddressSize, ChipSelectHighTime, FIFOThresholdLevel, MemorySize, *}; |
| 9 | use embassy_stm32::qspi::{Config as QspiCfg, Instance, Qspi, TransferConfig}; | 10 | use embassy_stm32::qspi::{Config as QspiCfg, Instance, Qspi, TransferConfig}; |
| 10 | use embassy_stm32::Config as StmCfg; | ||
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | const MEMORY_PAGE_SIZE: usize = 256; | 13 | const MEMORY_PAGE_SIZE: usize = 256; |
diff --git a/examples/stm32h755cm4/Cargo.toml b/examples/stm32h755cm4/Cargo.toml index c73f9df79..b5c313523 100644 --- a/examples/stm32h755cm4/Cargo.toml +++ b/examples/stm32h755cm4/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32h755cm4-examples" | 3 | name = "embassy-stm32h755cm4-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32h755cm4/src/bin/blinky.rs b/examples/stm32h755cm4/src/bin/blinky.rs index 39112c1f5..0ee3c68dc 100644 --- a/examples/stm32h755cm4/src/bin/blinky.rs +++ b/examples/stm32h755cm4/src/bin/blinky.rs | |||
| @@ -5,8 +5,8 @@ use core::mem::MaybeUninit; | |||
| 5 | 5 | ||
| 6 | use defmt::*; | 6 | use defmt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | ||
| 9 | use embassy_stm32::SharedData; | 8 | use embassy_stm32::SharedData; |
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | ||
| 10 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
diff --git a/examples/stm32h755cm4/src/bin/intercore.rs b/examples/stm32h755cm4/src/bin/intercore.rs index f584e31e9..c0db8cdd3 100644 --- a/examples/stm32h755cm4/src/bin/intercore.rs +++ b/examples/stm32h755cm4/src/bin/intercore.rs | |||
| @@ -85,7 +85,7 @@ mod shared { | |||
| 85 | } | 85 | } |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | #[link_section = ".ram_d3"] | 88 | #[unsafe(link_section = ".ram_d3")] |
| 89 | pub static SHARED_LED_STATE: SharedLedState = SharedLedState::new(); | 89 | pub static SHARED_LED_STATE: SharedLedState = SharedLedState::new(); |
| 90 | } | 90 | } |
| 91 | 91 | ||
| @@ -93,13 +93,13 @@ use core::mem::MaybeUninit; | |||
| 93 | 93 | ||
| 94 | use defmt::*; | 94 | use defmt::*; |
| 95 | use embassy_executor::Spawner; | 95 | use embassy_executor::Spawner; |
| 96 | use embassy_stm32::gpio::{Level, Output, Speed}; | ||
| 97 | use embassy_stm32::SharedData; | 96 | use embassy_stm32::SharedData; |
| 97 | use embassy_stm32::gpio::{Level, Output, Speed}; | ||
| 98 | use embassy_time::Timer; | 98 | use embassy_time::Timer; |
| 99 | use shared::SHARED_LED_STATE; | 99 | use shared::SHARED_LED_STATE; |
| 100 | use {defmt_rtt as _, panic_probe as _}; | 100 | use {defmt_rtt as _, panic_probe as _}; |
| 101 | 101 | ||
| 102 | #[link_section = ".ram_d3"] | 102 | #[unsafe(link_section = ".ram_d3")] |
| 103 | static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit(); | 103 | static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit(); |
| 104 | 104 | ||
| 105 | /// Task that continuously blinks the red LED as a heartbeat indicator | 105 | /// Task that continuously blinks the red LED as a heartbeat indicator |
diff --git a/examples/stm32h755cm7/Cargo.toml b/examples/stm32h755cm7/Cargo.toml index c34d4e45c..7a1519aae 100644 --- a/examples/stm32h755cm7/Cargo.toml +++ b/examples/stm32h755cm7/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32h755cm7-examples" | 3 | name = "embassy-stm32h755cm7-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32h755cm7/src/bin/blinky.rs b/examples/stm32h755cm7/src/bin/blinky.rs index b30bf4de8..e8f5a1c43 100644 --- a/examples/stm32h755cm7/src/bin/blinky.rs +++ b/examples/stm32h755cm7/src/bin/blinky.rs | |||
| @@ -5,8 +5,8 @@ use core::mem::MaybeUninit; | |||
| 5 | 5 | ||
| 6 | use defmt::*; | 6 | use defmt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | ||
| 9 | use embassy_stm32::SharedData; | 8 | use embassy_stm32::SharedData; |
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | ||
| 10 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
diff --git a/examples/stm32h755cm7/src/bin/intercore.rs b/examples/stm32h755cm7/src/bin/intercore.rs index a4e1b5ff4..3df0b26d7 100644 --- a/examples/stm32h755cm7/src/bin/intercore.rs +++ b/examples/stm32h755cm7/src/bin/intercore.rs | |||
| @@ -97,7 +97,7 @@ mod shared { | |||
| 97 | } | 97 | } |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | #[link_section = ".ram_d3"] | 100 | #[unsafe(link_section = ".ram_d3")] |
| 101 | pub static SHARED_LED_STATE: SharedLedState = SharedLedState::new(); | 101 | pub static SHARED_LED_STATE: SharedLedState = SharedLedState::new(); |
| 102 | 102 | ||
| 103 | // Memory region constants for MPU configuration | 103 | // Memory region constants for MPU configuration |
| @@ -106,7 +106,7 @@ mod shared { | |||
| 106 | pub const SRAM4_REGION_NUMBER: u8 = 0; | 106 | pub const SRAM4_REGION_NUMBER: u8 = 0; |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | #[link_section = ".ram_d3"] | 109 | #[unsafe(link_section = ".ram_d3")] |
| 110 | static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit(); | 110 | static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit(); |
| 111 | 111 | ||
| 112 | /// Configure MPU to make SRAM4 region non-cacheable | 112 | /// Configure MPU to make SRAM4 region non-cacheable |
diff --git a/examples/stm32h7b0/Cargo.toml b/examples/stm32h7b0/Cargo.toml index 1917749c5..4cd7b84e5 100644 --- a/examples/stm32h7b0/Cargo.toml +++ b/examples/stm32h7b0/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32h7b0-examples" | 3 | name = "embassy-stm32h7b0-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32h7b0/src/bin/ospi_memory_mapped.rs b/examples/stm32h7b0/src/bin/ospi_memory_mapped.rs index dffb740a9..865062f4b 100644 --- a/examples/stm32h7b0/src/bin/ospi_memory_mapped.rs +++ b/examples/stm32h7b0/src/bin/ospi_memory_mapped.rs | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | use defmt::info; | 6 | use defmt::info; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::Config; | ||
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 9 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::mode::Blocking; | 10 | use embassy_stm32::mode::Blocking; |
| 10 | use embassy_stm32::ospi::{ | 11 | use embassy_stm32::ospi::{ |
| @@ -12,7 +13,6 @@ use embassy_stm32::ospi::{ | |||
| 12 | OspiWidth, TransferConfig, WrapSize, | 13 | OspiWidth, TransferConfig, WrapSize, |
| 13 | }; | 14 | }; |
| 14 | use embassy_stm32::time::Hertz; | 15 | use embassy_stm32::time::Hertz; |
| 15 | use embassy_stm32::Config; | ||
| 16 | use embassy_time::Timer; | 16 | use embassy_time::Timer; |
| 17 | use {defmt_rtt as _, panic_probe as _}; | 17 | use {defmt_rtt as _, panic_probe as _}; |
| 18 | 18 | ||
diff --git a/examples/stm32h7rs/Cargo.toml b/examples/stm32h7rs/Cargo.toml index bfe59b68d..445916972 100644 --- a/examples/stm32h7rs/Cargo.toml +++ b/examples/stm32h7rs/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32h7rs-examples" | 3 | name = "embassy-stm32h7rs-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32h7rs/src/bin/blinky.rs b/examples/stm32h7rs/src/bin/blinky.rs index 5fd50fb15..4c0864ff6 100644 --- a/examples/stm32h7rs/src/bin/blinky.rs +++ b/examples/stm32h7rs/src/bin/blinky.rs | |||
| @@ -3,9 +3,9 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::Config; | ||
| 6 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 7 | use embassy_stm32::time::Hertz; | 8 | use embassy_stm32::time::Hertz; |
| 8 | use embassy_stm32::Config; | ||
| 9 | use embassy_time::Timer; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
diff --git a/examples/stm32h7rs/src/bin/can.rs b/examples/stm32h7rs/src/bin/can.rs index 0af11ef3e..49830f9b7 100644 --- a/examples/stm32h7rs/src/bin/can.rs +++ b/examples/stm32h7rs/src/bin/can.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::peripherals::*; | 6 | use embassy_stm32::peripherals::*; |
| 7 | use embassy_stm32::{bind_interrupts, can, rcc, Config}; | 7 | use embassy_stm32::{Config, bind_interrupts, can, rcc}; |
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
diff --git a/examples/stm32h7rs/src/bin/eth.rs b/examples/stm32h7rs/src/bin/eth.rs index 67f541564..5ce1d4765 100644 --- a/examples/stm32h7rs/src/bin/eth.rs +++ b/examples/stm32h7rs/src/bin/eth.rs | |||
| @@ -8,7 +8,7 @@ use embassy_net::{Ipv4Address, Ipv4Cidr, StackResources}; | |||
| 8 | use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue}; | 8 | use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue}; |
| 9 | use embassy_stm32::peripherals::ETH; | 9 | use embassy_stm32::peripherals::ETH; |
| 10 | use embassy_stm32::rng::Rng; | 10 | use embassy_stm32::rng::Rng; |
| 11 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 11 | use embassy_stm32::{Config, bind_interrupts, eth, peripherals, rng}; |
| 12 | use embassy_time::Timer; | 12 | use embassy_time::Timer; |
| 13 | use heapless::Vec; | 13 | use heapless::Vec; |
| 14 | use static_cell::StaticCell; | 14 | use static_cell::StaticCell; |
diff --git a/examples/stm32h7rs/src/bin/mco.rs b/examples/stm32h7rs/src/bin/mco.rs index a6ee27625..cafcb90f6 100644 --- a/examples/stm32h7rs/src/bin/mco.rs +++ b/examples/stm32h7rs/src/bin/mco.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::gpio::{Level, Output, Speed}; | 6 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 7 | use embassy_stm32::rcc::{Mco, Mco1Source, McoPrescaler}; | 7 | use embassy_stm32::rcc::{Mco, Mco1Source, McoConfig, McoPrescaler}; |
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| @@ -15,7 +15,13 @@ async fn main(_spawner: Spawner) { | |||
| 15 | 15 | ||
| 16 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); | 16 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); |
| 17 | 17 | ||
| 18 | let _mco = Mco::new(p.MCO1, p.PA8, Mco1Source::HSI, McoPrescaler::DIV8); | 18 | let config = { |
| 19 | let mut config = McoConfig::default(); | ||
| 20 | config.prescaler = McoPrescaler::DIV8; | ||
| 21 | config | ||
| 22 | }; | ||
| 23 | |||
| 24 | let _mco = Mco::new(p.MCO1, p.PA8, Mco1Source::HSI, config); | ||
| 19 | 25 | ||
| 20 | loop { | 26 | loop { |
| 21 | info!("high"); | 27 | info!("high"); |
diff --git a/examples/stm32h7rs/src/bin/multiprio.rs b/examples/stm32h7rs/src/bin/multiprio.rs index 2f2ffdea2..8375e0e8e 100644 --- a/examples/stm32h7rs/src/bin/multiprio.rs +++ b/examples/stm32h7rs/src/bin/multiprio.rs | |||
| @@ -113,12 +113,12 @@ static EXECUTOR_LOW: StaticCell<Executor> = StaticCell::new(); | |||
| 113 | 113 | ||
| 114 | #[interrupt] | 114 | #[interrupt] |
| 115 | unsafe fn UART4() { | 115 | unsafe fn UART4() { |
| 116 | EXECUTOR_HIGH.on_interrupt() | 116 | unsafe { EXECUTOR_HIGH.on_interrupt() } |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | #[interrupt] | 119 | #[interrupt] |
| 120 | unsafe fn UART5() { | 120 | unsafe fn UART5() { |
| 121 | EXECUTOR_MED.on_interrupt() | 121 | unsafe { EXECUTOR_MED.on_interrupt() } |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | #[entry] | 124 | #[entry] |
diff --git a/examples/stm32h7rs/src/bin/rng.rs b/examples/stm32h7rs/src/bin/rng.rs index a9ef7200d..489747678 100644 --- a/examples/stm32h7rs/src/bin/rng.rs +++ b/examples/stm32h7rs/src/bin/rng.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::rng::Rng; | 6 | use embassy_stm32::rng::Rng; |
| 7 | use embassy_stm32::{bind_interrupts, peripherals, rng, Config}; | 7 | use embassy_stm32::{Config, bind_interrupts, peripherals, rng}; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | bind_interrupts!(struct Irqs { | 10 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32h7rs/src/bin/rtc.rs b/examples/stm32h7rs/src/bin/rtc.rs index 0adb48877..1bd71637b 100644 --- a/examples/stm32h7rs/src/bin/rtc.rs +++ b/examples/stm32h7rs/src/bin/rtc.rs | |||
| @@ -4,9 +4,9 @@ | |||
| 4 | use chrono::{NaiveDate, NaiveDateTime}; | 4 | use chrono::{NaiveDate, NaiveDateTime}; |
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::Config; | ||
| 7 | use embassy_stm32::rcc::LsConfig; | 8 | use embassy_stm32::rcc::LsConfig; |
| 8 | use embassy_stm32::rtc::{Rtc, RtcConfig}; | 9 | use embassy_stm32::rtc::{Rtc, RtcConfig}; |
| 9 | use embassy_stm32::Config; | ||
| 10 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
diff --git a/examples/stm32h7rs/src/bin/usb_serial.rs b/examples/stm32h7rs/src/bin/usb_serial.rs index 23abc3e2f..3e295dd51 100644 --- a/examples/stm32h7rs/src/bin/usb_serial.rs +++ b/examples/stm32h7rs/src/bin/usb_serial.rs | |||
| @@ -6,10 +6,10 @@ use embassy_executor::Spawner; | |||
| 6 | use embassy_futures::join::join; | 6 | use embassy_futures::join::join; |
| 7 | use embassy_stm32::time::Hertz; | 7 | use embassy_stm32::time::Hertz; |
| 8 | use embassy_stm32::usb::{Driver, Instance}; | 8 | use embassy_stm32::usb::{Driver, Instance}; |
| 9 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 9 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 10 | use embassy_usb::Builder; | ||
| 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 11 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 11 | use embassy_usb::driver::EndpointError; | 12 | use embassy_usb::driver::EndpointError; |
| 12 | use embassy_usb::Builder; | ||
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| 15 | bind_interrupts!(struct Irqs { | 15 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32h7rs/src/bin/xspi_memory_mapped.rs b/examples/stm32h7rs/src/bin/xspi_memory_mapped.rs index 4c1b450b4..d91ae9de0 100644 --- a/examples/stm32h7rs/src/bin/xspi_memory_mapped.rs +++ b/examples/stm32h7rs/src/bin/xspi_memory_mapped.rs | |||
| @@ -8,6 +8,7 @@ use core::cmp::min; | |||
| 8 | 8 | ||
| 9 | use defmt::info; | 9 | use defmt::info; |
| 10 | use embassy_executor::Spawner; | 10 | use embassy_executor::Spawner; |
| 11 | use embassy_stm32::Config; | ||
| 11 | use embassy_stm32::gpio::{Level, Output, Speed}; | 12 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 12 | use embassy_stm32::mode::Blocking; | 13 | use embassy_stm32::mode::Blocking; |
| 13 | use embassy_stm32::time::Hertz; | 14 | use embassy_stm32::time::Hertz; |
| @@ -15,7 +16,6 @@ use embassy_stm32::xspi::{ | |||
| 15 | AddressSize, ChipSelectHighTime, DummyCycles, FIFOThresholdLevel, Instance, MemorySize, MemoryType, TransferConfig, | 16 | AddressSize, ChipSelectHighTime, DummyCycles, FIFOThresholdLevel, Instance, MemorySize, MemoryType, TransferConfig, |
| 16 | WrapSize, Xspi, XspiWidth, | 17 | WrapSize, Xspi, XspiWidth, |
| 17 | }; | 18 | }; |
| 18 | use embassy_stm32::Config; | ||
| 19 | use embassy_time::Timer; | 19 | use embassy_time::Timer; |
| 20 | use {defmt_rtt as _, panic_probe as _}; | 20 | use {defmt_rtt as _, panic_probe as _}; |
| 21 | 21 | ||
diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index d42cdac15..a9c71d655 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32l0-examples" | 3 | name = "embassy-stm32l0-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32l0/src/bin/button_exti.rs b/examples/stm32l0/src/bin/button_exti.rs index 4945da7ce..7ff4a7d52 100644 --- a/examples/stm32l0/src/bin/button_exti.rs +++ b/examples/stm32l0/src/bin/button_exti.rs | |||
| @@ -3,9 +3,9 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::Config; | ||
| 6 | use embassy_stm32::exti::ExtiInput; | 7 | use embassy_stm32::exti::ExtiInput; |
| 7 | use embassy_stm32::gpio::Pull; | 8 | use embassy_stm32::gpio::Pull; |
| 8 | use embassy_stm32::Config; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
diff --git a/examples/stm32l0/src/bin/dds.rs b/examples/stm32l0/src/bin/dds.rs index eaa7a61a8..d8f9020d4 100644 --- a/examples/stm32l0/src/bin/dds.rs +++ b/examples/stm32l0/src/bin/dds.rs | |||
| @@ -12,7 +12,7 @@ use embassy_stm32::time::hz; | |||
| 12 | use embassy_stm32::timer::low_level::{Timer as LLTimer, *}; | 12 | use embassy_stm32::timer::low_level::{Timer as LLTimer, *}; |
| 13 | use embassy_stm32::timer::simple_pwm::PwmPin; | 13 | use embassy_stm32::timer::simple_pwm::PwmPin; |
| 14 | use embassy_stm32::timer::{Ch3, Channel}; | 14 | use embassy_stm32::timer::{Ch3, Channel}; |
| 15 | use embassy_stm32::{interrupt, pac, Config}; | 15 | use embassy_stm32::{Config, interrupt, pac}; |
| 16 | use panic_probe as _; | 16 | use panic_probe as _; |
| 17 | 17 | ||
| 18 | const DDS_SINE_DATA: [u8; 256] = [ | 18 | const DDS_SINE_DATA: [u8; 256] = [ |
diff --git a/examples/stm32l0/src/bin/eeprom.rs b/examples/stm32l0/src/bin/eeprom.rs index 370246644..a33088f36 100644 --- a/examples/stm32l0/src/bin/eeprom.rs +++ b/examples/stm32l0/src/bin/eeprom.rs | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::{info, unwrap}; | 4 | use defmt::{info, unwrap}; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::flash::{Flash, EEPROM_BASE, EEPROM_SIZE}; | 6 | use embassy_stm32::flash::{EEPROM_BASE, EEPROM_SIZE, Flash}; |
| 7 | use {defmt_rtt as _, panic_probe as _}; | 7 | use {defmt_rtt as _, panic_probe as _}; |
| 8 | 8 | ||
| 9 | #[embassy_executor::main] | 9 | #[embassy_executor::main] |
diff --git a/examples/stm32l0/src/bin/raw_spawn.rs b/examples/stm32l0/src/bin/raw_spawn.rs index 6385e3c8f..8e8fe0240 100644 --- a/examples/stm32l0/src/bin/raw_spawn.rs +++ b/examples/stm32l0/src/bin/raw_spawn.rs | |||
| @@ -5,8 +5,8 @@ use core::mem; | |||
| 5 | 5 | ||
| 6 | use cortex_m_rt::entry; | 6 | use cortex_m_rt::entry; |
| 7 | use defmt::*; | 7 | use defmt::*; |
| 8 | use embassy_executor::raw::TaskStorage; | ||
| 9 | use embassy_executor::Executor; | 8 | use embassy_executor::Executor; |
| 9 | use embassy_executor::raw::TaskStorage; | ||
| 10 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 11 | use static_cell::StaticCell; | 11 | use static_cell::StaticCell; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -48,5 +48,5 @@ fn main() -> ! { | |||
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | unsafe fn make_static<T>(t: &T) -> &'static T { | 50 | unsafe fn make_static<T>(t: &T) -> &'static T { |
| 51 | mem::transmute(t) | 51 | unsafe { mem::transmute(t) } |
| 52 | } | 52 | } |
diff --git a/examples/stm32l0/src/bin/usb_serial.rs b/examples/stm32l0/src/bin/usb_serial.rs index fdb1aeb59..612082f29 100644 --- a/examples/stm32l0/src/bin/usb_serial.rs +++ b/examples/stm32l0/src/bin/usb_serial.rs | |||
| @@ -6,9 +6,9 @@ use embassy_executor::Spawner; | |||
| 6 | use embassy_futures::join::join; | 6 | use embassy_futures::join::join; |
| 7 | use embassy_stm32::usb::{self, Driver, Instance}; | 7 | use embassy_stm32::usb::{self, Driver, Instance}; |
| 8 | use embassy_stm32::{bind_interrupts, peripherals}; | 8 | use embassy_stm32::{bind_interrupts, peripherals}; |
| 9 | use embassy_usb::Builder; | ||
| 9 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 10 | use embassy_usb::driver::EndpointError; | 11 | use embassy_usb::driver::EndpointError; |
| 11 | use embassy_usb::Builder; | ||
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | bind_interrupts!(struct Irqs { | 14 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32l1/Cargo.toml b/examples/stm32l1/Cargo.toml index 76ceade9c..7f6b31ed5 100644 --- a/examples/stm32l1/Cargo.toml +++ b/examples/stm32l1/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32l1-examples" | 3 | name = "embassy-stm32l1-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32l1/src/bin/eeprom.rs b/examples/stm32l1/src/bin/eeprom.rs index 370246644..a33088f36 100644 --- a/examples/stm32l1/src/bin/eeprom.rs +++ b/examples/stm32l1/src/bin/eeprom.rs | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::{info, unwrap}; | 4 | use defmt::{info, unwrap}; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::flash::{Flash, EEPROM_BASE, EEPROM_SIZE}; | 6 | use embassy_stm32::flash::{EEPROM_BASE, EEPROM_SIZE, Flash}; |
| 7 | use {defmt_rtt as _, panic_probe as _}; | 7 | use {defmt_rtt as _, panic_probe as _}; |
| 8 | 8 | ||
| 9 | #[embassy_executor::main] | 9 | #[embassy_executor::main] |
diff --git a/examples/stm32l1/src/bin/usb_serial.rs b/examples/stm32l1/src/bin/usb_serial.rs index a35f1d7a7..c54d37f9d 100644 --- a/examples/stm32l1/src/bin/usb_serial.rs +++ b/examples/stm32l1/src/bin/usb_serial.rs | |||
| @@ -6,9 +6,9 @@ use embassy_executor::Spawner; | |||
| 6 | use embassy_futures::join::join; | 6 | use embassy_futures::join::join; |
| 7 | use embassy_stm32::usb::{self, Driver, Instance}; | 7 | use embassy_stm32::usb::{self, Driver, Instance}; |
| 8 | use embassy_stm32::{bind_interrupts, peripherals}; | 8 | use embassy_stm32::{bind_interrupts, peripherals}; |
| 9 | use embassy_usb::Builder; | ||
| 9 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 10 | use embassy_usb::driver::EndpointError; | 11 | use embassy_usb::driver::EndpointError; |
| 11 | use embassy_usb::Builder; | ||
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | bind_interrupts!(struct Irqs { | 14 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml index 1b7f15b1d..936472199 100644 --- a/examples/stm32l4/Cargo.toml +++ b/examples/stm32l4/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32l4-examples" | 3 | name = "embassy-stm32l4-examples" |
| 4 | version = "0.1.1" | 4 | version = "0.1.1" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32l4/src/bin/adc.rs b/examples/stm32l4/src/bin/adc.rs index c557ac6d7..40e907940 100644 --- a/examples/stm32l4/src/bin/adc.rs +++ b/examples/stm32l4/src/bin/adc.rs | |||
| @@ -2,8 +2,8 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_stm32::adc::{Adc, Resolution}; | ||
| 6 | use embassy_stm32::Config; | 5 | use embassy_stm32::Config; |
| 6 | use embassy_stm32::adc::{Adc, Resolution}; | ||
| 7 | use {defmt_rtt as _, panic_probe as _}; | 7 | use {defmt_rtt as _, panic_probe as _}; |
| 8 | 8 | ||
| 9 | #[cortex_m_rt::entry] | 9 | #[cortex_m_rt::entry] |
diff --git a/examples/stm32l4/src/bin/can.rs b/examples/stm32l4/src/bin/can.rs index 3c4cdac24..bd361417e 100644 --- a/examples/stm32l4/src/bin/can.rs +++ b/examples/stm32l4/src/bin/can.rs | |||
| @@ -8,7 +8,7 @@ use embassy_stm32::can::{ | |||
| 8 | Can, Fifo, Frame, Rx0InterruptHandler, Rx1InterruptHandler, SceInterruptHandler, TxInterruptHandler, | 8 | Can, Fifo, Frame, Rx0InterruptHandler, Rx1InterruptHandler, SceInterruptHandler, TxInterruptHandler, |
| 9 | }; | 9 | }; |
| 10 | use embassy_stm32::peripherals::CAN1; | 10 | use embassy_stm32::peripherals::CAN1; |
| 11 | use embassy_stm32::{bind_interrupts, Config}; | 11 | use embassy_stm32::{Config, bind_interrupts}; |
| 12 | use embassy_time::Timer; | 12 | use embassy_time::Timer; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
diff --git a/examples/stm32l4/src/bin/dac_dma.rs b/examples/stm32l4/src/bin/dac_dma.rs index 44edec728..bfdf858c5 100644 --- a/examples/stm32l4/src/bin/dac_dma.rs +++ b/examples/stm32l4/src/bin/dac_dma.rs | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::Peri; | ||
| 6 | use embassy_stm32::dac::{DacCh1, DacCh2, ValueArray}; | 7 | use embassy_stm32::dac::{DacCh1, DacCh2, ValueArray}; |
| 7 | use embassy_stm32::mode::Async; | 8 | use embassy_stm32::mode::Async; |
| 8 | use embassy_stm32::pac::timer::vals::Mms; | 9 | use embassy_stm32::pac::timer::vals::Mms; |
| @@ -10,7 +11,6 @@ use embassy_stm32::peripherals::{DAC1, TIM6, TIM7}; | |||
| 10 | use embassy_stm32::rcc::frequency; | 11 | use embassy_stm32::rcc::frequency; |
| 11 | use embassy_stm32::time::Hertz; | 12 | use embassy_stm32::time::Hertz; |
| 12 | use embassy_stm32::timer::low_level::Timer; | 13 | use embassy_stm32::timer::low_level::Timer; |
| 13 | use embassy_stm32::Peri; | ||
| 14 | use micromath::F32Ext; | 14 | use micromath::F32Ext; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 16 | ||
diff --git a/examples/stm32l4/src/bin/mco.rs b/examples/stm32l4/src/bin/mco.rs index 36c002952..4cdeaa440 100644 --- a/examples/stm32l4/src/bin/mco.rs +++ b/examples/stm32l4/src/bin/mco.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::gpio::{Level, Output, Speed}; | 6 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 7 | use embassy_stm32::rcc::{Mco, McoPrescaler, McoSource}; | 7 | use embassy_stm32::rcc::{Mco, McoConfig, McoPrescaler, McoSource}; |
| 8 | use embassy_time::Timer; | 8 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| @@ -13,7 +13,13 @@ async fn main(_spawner: Spawner) { | |||
| 13 | let p = embassy_stm32::init(Default::default()); | 13 | let p = embassy_stm32::init(Default::default()); |
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let _mco = Mco::new(p.MCO, p.PA8, McoSource::HSI, McoPrescaler::DIV1); | 16 | let config = { |
| 17 | let mut config = McoConfig::default(); | ||
| 18 | config.prescaler = McoPrescaler::DIV1; | ||
| 19 | config | ||
| 20 | }; | ||
| 21 | |||
| 22 | let _mco = Mco::new(p.MCO, p.PA8, McoSource::HSI, config); | ||
| 17 | 23 | ||
| 18 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); | 24 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); |
| 19 | 25 | ||
diff --git a/examples/stm32l4/src/bin/rng.rs b/examples/stm32l4/src/bin/rng.rs index 14d0e3c1e..4d9f83ad8 100644 --- a/examples/stm32l4/src/bin/rng.rs +++ b/examples/stm32l4/src/bin/rng.rs | |||
| @@ -5,7 +5,7 @@ use defmt::*; | |||
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::rcc::{Pll, PllMul, PllPreDiv, PllQDiv, PllRDiv, PllSource, Sysclk}; | 6 | use embassy_stm32::rcc::{Pll, PllMul, PllPreDiv, PllQDiv, PllRDiv, PllSource, Sysclk}; |
| 7 | use embassy_stm32::rng::Rng; | 7 | use embassy_stm32::rng::Rng; |
| 8 | use embassy_stm32::{bind_interrupts, peripherals, rng, Config}; | 8 | use embassy_stm32::{Config, bind_interrupts, peripherals, rng}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | bind_interrupts!(struct Irqs { | 11 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32l4/src/bin/rtc.rs b/examples/stm32l4/src/bin/rtc.rs index f554f0f78..1d26cd008 100644 --- a/examples/stm32l4/src/bin/rtc.rs +++ b/examples/stm32l4/src/bin/rtc.rs | |||
| @@ -4,9 +4,9 @@ | |||
| 4 | use chrono::{NaiveDate, NaiveDateTime}; | 4 | use chrono::{NaiveDate, NaiveDateTime}; |
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::Config; | ||
| 7 | use embassy_stm32::rtc::{Rtc, RtcConfig}; | 8 | use embassy_stm32::rtc::{Rtc, RtcConfig}; |
| 8 | use embassy_stm32::time::Hertz; | 9 | use embassy_stm32::time::Hertz; |
| 9 | use embassy_stm32::Config; | ||
| 10 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
diff --git a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs index 24efe526f..8e54938d1 100644 --- a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs +++ b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs | |||
| @@ -16,14 +16,14 @@ | |||
| 16 | use core::marker::PhantomData; | 16 | use core::marker::PhantomData; |
| 17 | use core::sync::atomic::{AtomicI32, Ordering}; | 17 | use core::sync::atomic::{AtomicI32, Ordering}; |
| 18 | 18 | ||
| 19 | use defmt::{error, info, println, unwrap, Format}; | 19 | use defmt::{Format, error, info, println, unwrap}; |
| 20 | use defmt_rtt as _; // global logger | 20 | use defmt_rtt as _; // global logger |
| 21 | use embassy_executor::Spawner; | 21 | use embassy_executor::Spawner; |
| 22 | use embassy_futures::select::{select, Either}; | 22 | use embassy_futures::select::{Either, select}; |
| 23 | use embassy_futures::yield_now; | 23 | use embassy_futures::yield_now; |
| 24 | use embassy_net::tcp::TcpSocket; | 24 | use embassy_net::tcp::TcpSocket; |
| 25 | use embassy_net::{Ipv4Address, Ipv4Cidr, Stack, StackResources, StaticConfigV4}; | 25 | use embassy_net::{Ipv4Address, Ipv4Cidr, Stack, StackResources, StaticConfigV4}; |
| 26 | use embassy_net_adin1110::{Device, Runner, ADIN1110}; | 26 | use embassy_net_adin1110::{ADIN1110, Device, Runner}; |
| 27 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 27 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 28 | use embassy_stm32::i2c::{self, Config as I2C_Config, I2c}; | 28 | use embassy_stm32::i2c::{self, Config as I2C_Config, I2c}; |
| 29 | use embassy_stm32::mode::Async; | 29 | use embassy_stm32::mode::Async; |
| @@ -159,7 +159,9 @@ async fn main(spawner: Spawner) { | |||
| 159 | 159 | ||
| 160 | // Check the SPI mode selected with the "HW CFG" dip-switch | 160 | // Check the SPI mode selected with the "HW CFG" dip-switch |
| 161 | if !cfg1_spi_mode { | 161 | if !cfg1_spi_mode { |
| 162 | error!("Driver doesn´t support SPI Protolcol \"OPEN Alliance\".\nplease use the \"Generic SPI\"! Turn On \"HW CFG\": \"SPI_CFG1\""); | 162 | error!( |
| 163 | "Driver doesn´t support SPI Protolcol \"OPEN Alliance\".\nplease use the \"Generic SPI\"! Turn On \"HW CFG\": \"SPI_CFG1\"" | ||
| 164 | ); | ||
| 163 | loop { | 165 | loop { |
| 164 | led_uc2_red.toggle(); | 166 | led_uc2_red.toggle(); |
| 165 | Timer::after(Duration::from_hz(10)).await; | 167 | Timer::after(Duration::from_hz(10)).await; |
diff --git a/examples/stm32l4/src/bin/usb_serial.rs b/examples/stm32l4/src/bin/usb_serial.rs index af90e297e..17cd107f6 100644 --- a/examples/stm32l4/src/bin/usb_serial.rs +++ b/examples/stm32l4/src/bin/usb_serial.rs | |||
| @@ -6,10 +6,10 @@ use defmt_rtt as _; // global logger | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_futures::join::join; | 7 | use embassy_futures::join::join; |
| 8 | use embassy_stm32::usb::{Driver, Instance}; | 8 | use embassy_stm32::usb::{Driver, Instance}; |
| 9 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 9 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 10 | use embassy_usb::Builder; | ||
| 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 11 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 11 | use embassy_usb::driver::EndpointError; | 12 | use embassy_usb::driver::EndpointError; |
| 12 | use embassy_usb::Builder; | ||
| 13 | use panic_probe as _; | 13 | use panic_probe as _; |
| 14 | 14 | ||
| 15 | bind_interrupts!(struct Irqs { | 15 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32l432/Cargo.toml b/examples/stm32l432/Cargo.toml index f173c651e..14f41992d 100644 --- a/examples/stm32l432/Cargo.toml +++ b/examples/stm32l432/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32l432-examples" | 3 | name = "embassy-stm32l432-examples" |
| 4 | version = "0.1.1" | 4 | version = "0.1.1" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32l5/Cargo.toml b/examples/stm32l5/Cargo.toml index 9999300b8..b6158c854 100644 --- a/examples/stm32l5/Cargo.toml +++ b/examples/stm32l5/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32l5-examples" | 3 | name = "embassy-stm32l5-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32l5/src/bin/rng.rs b/examples/stm32l5/src/bin/rng.rs index 0a644e73d..d6302e106 100644 --- a/examples/stm32l5/src/bin/rng.rs +++ b/examples/stm32l5/src/bin/rng.rs | |||
| @@ -5,7 +5,7 @@ use defmt::*; | |||
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::rcc::{Pll, PllMul, PllPreDiv, PllRDiv, PllSource, Sysclk}; | 6 | use embassy_stm32::rcc::{Pll, PllMul, PllPreDiv, PllRDiv, PllSource, Sysclk}; |
| 7 | use embassy_stm32::rng::Rng; | 7 | use embassy_stm32::rng::Rng; |
| 8 | use embassy_stm32::{bind_interrupts, peripherals, rng, Config}; | 8 | use embassy_stm32::{Config, bind_interrupts, peripherals, rng}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | bind_interrupts!(struct Irqs { | 11 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs index 25aa9ef69..d2cbeb550 100644 --- a/examples/stm32l5/src/bin/usb_ethernet.rs +++ b/examples/stm32l5/src/bin/usb_ethernet.rs | |||
| @@ -3,11 +3,11 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_net::tcp::TcpSocket; | ||
| 7 | use embassy_net::StackResources; | 6 | use embassy_net::StackResources; |
| 7 | use embassy_net::tcp::TcpSocket; | ||
| 8 | use embassy_stm32::rng::Rng; | 8 | use embassy_stm32::rng::Rng; |
| 9 | use embassy_stm32::usb::Driver; | 9 | use embassy_stm32::usb::Driver; |
| 10 | use embassy_stm32::{bind_interrupts, peripherals, rng, usb, Config}; | 10 | use embassy_stm32::{Config, bind_interrupts, peripherals, rng, usb}; |
| 11 | use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState}; | 11 | use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState}; |
| 12 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; | 12 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; |
| 13 | use embassy_usb::{Builder, UsbDevice}; | 13 | use embassy_usb::{Builder, UsbDevice}; |
diff --git a/examples/stm32l5/src/bin/usb_hid_mouse.rs b/examples/stm32l5/src/bin/usb_hid_mouse.rs index 3f8c52b82..b721f5b2e 100644 --- a/examples/stm32l5/src/bin/usb_hid_mouse.rs +++ b/examples/stm32l5/src/bin/usb_hid_mouse.rs | |||
| @@ -5,11 +5,11 @@ use defmt::*; | |||
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_futures::join::join; | 6 | use embassy_futures::join::join; |
| 7 | use embassy_stm32::usb::Driver; | 7 | use embassy_stm32::usb::Driver; |
| 8 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 8 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 9 | use embassy_time::Timer; | 9 | use embassy_time::Timer; |
| 10 | use embassy_usb::Builder; | ||
| 10 | use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State}; | 11 | use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State}; |
| 11 | use embassy_usb::control::OutResponse; | 12 | use embassy_usb::control::OutResponse; |
| 12 | use embassy_usb::Builder; | ||
| 13 | use usbd_hid::descriptor::{MouseReport, SerializedDescriptor}; | 13 | use usbd_hid::descriptor::{MouseReport, SerializedDescriptor}; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 15 | ||
diff --git a/examples/stm32l5/src/bin/usb_serial.rs b/examples/stm32l5/src/bin/usb_serial.rs index a64bda31b..4f77fc1d7 100644 --- a/examples/stm32l5/src/bin/usb_serial.rs +++ b/examples/stm32l5/src/bin/usb_serial.rs | |||
| @@ -5,10 +5,10 @@ use defmt::{panic, *}; | |||
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_futures::join::join; | 6 | use embassy_futures::join::join; |
| 7 | use embassy_stm32::usb::{Driver, Instance}; | 7 | use embassy_stm32::usb::{Driver, Instance}; |
| 8 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 8 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 9 | use embassy_usb::Builder; | ||
| 9 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 10 | use embassy_usb::driver::EndpointError; | 11 | use embassy_usb::driver::EndpointError; |
| 11 | use embassy_usb::Builder; | ||
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | bind_interrupts!(struct Irqs { | 14 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32u0/Cargo.toml b/examples/stm32u0/Cargo.toml index 9318414a5..9f5227e3f 100644 --- a/examples/stm32u0/Cargo.toml +++ b/examples/stm32u0/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32u0-examples" | 3 | name = "embassy-stm32u0-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32u0/src/bin/adc.rs b/examples/stm32u0/src/bin/adc.rs index c8252e4e1..32a54299d 100644 --- a/examples/stm32u0/src/bin/adc.rs +++ b/examples/stm32u0/src/bin/adc.rs | |||
| @@ -2,8 +2,8 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_stm32::adc::{Adc, Resolution}; | ||
| 6 | use embassy_stm32::Config; | 5 | use embassy_stm32::Config; |
| 6 | use embassy_stm32::adc::{Adc, Resolution}; | ||
| 7 | use embassy_time::Duration; | 7 | use embassy_time::Duration; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
diff --git a/examples/stm32u0/src/bin/rng.rs b/examples/stm32u0/src/bin/rng.rs index 89445b042..07deda94c 100644 --- a/examples/stm32u0/src/bin/rng.rs +++ b/examples/stm32u0/src/bin/rng.rs | |||
| @@ -5,7 +5,7 @@ use defmt::*; | |||
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::rcc::mux::Clk48sel; | 6 | use embassy_stm32::rcc::mux::Clk48sel; |
| 7 | use embassy_stm32::rng::Rng; | 7 | use embassy_stm32::rng::Rng; |
| 8 | use embassy_stm32::{bind_interrupts, peripherals, rng, Config}; | 8 | use embassy_stm32::{Config, bind_interrupts, peripherals, rng}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | bind_interrupts!(struct Irqs { | 11 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32u0/src/bin/rtc.rs b/examples/stm32u0/src/bin/rtc.rs index 72fa0fde4..d071cfbc7 100644 --- a/examples/stm32u0/src/bin/rtc.rs +++ b/examples/stm32u0/src/bin/rtc.rs | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | use chrono::{NaiveDate, NaiveDateTime}; | 4 | use chrono::{NaiveDate, NaiveDateTime}; |
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::rtc::{Rtc, RtcConfig}; | ||
| 8 | use embassy_stm32::Config; | 7 | use embassy_stm32::Config; |
| 8 | use embassy_stm32::rtc::{Rtc, RtcConfig}; | ||
| 9 | use embassy_time::Timer; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
diff --git a/examples/stm32u0/src/bin/usb_serial.rs b/examples/stm32u0/src/bin/usb_serial.rs index 273f40643..77d0640f6 100644 --- a/examples/stm32u0/src/bin/usb_serial.rs +++ b/examples/stm32u0/src/bin/usb_serial.rs | |||
| @@ -6,10 +6,10 @@ use defmt_rtt as _; // global logger | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_futures::join::join; | 7 | use embassy_futures::join::join; |
| 8 | use embassy_stm32::usb::{Driver, Instance}; | 8 | use embassy_stm32::usb::{Driver, Instance}; |
| 9 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 9 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 10 | use embassy_usb::Builder; | ||
| 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 11 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 11 | use embassy_usb::driver::EndpointError; | 12 | use embassy_usb::driver::EndpointError; |
| 12 | use embassy_usb::Builder; | ||
| 13 | use panic_probe as _; | 13 | use panic_probe as _; |
| 14 | 14 | ||
| 15 | bind_interrupts!(struct Irqs { | 15 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32u5/Cargo.toml b/examples/stm32u5/Cargo.toml index f2ffe52c5..7a1e62406 100644 --- a/examples/stm32u5/Cargo.toml +++ b/examples/stm32u5/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32u5-examples" | 3 | name = "embassy-stm32u5-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32u5/src/bin/adc.rs b/examples/stm32u5/src/bin/adc.rs index d2aa28087..91e33053e 100644 --- a/examples/stm32u5/src/bin/adc.rs +++ b/examples/stm32u5/src/bin/adc.rs | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_stm32::adc; | 5 | use embassy_stm32::adc; |
| 6 | use embassy_stm32::adc::{adc4, AdcChannel}; | 6 | use embassy_stm32::adc::{AdcChannel, adc4}; |
| 7 | use {defmt_rtt as _, panic_probe as _}; | 7 | use {defmt_rtt as _, panic_probe as _}; |
| 8 | 8 | ||
| 9 | #[embassy_executor::main] | 9 | #[embassy_executor::main] |
diff --git a/examples/stm32u5/src/bin/ltdc.rs b/examples/stm32u5/src/bin/ltdc.rs index 46d1c120f..d1fddb679 100644 --- a/examples/stm32u5/src/bin/ltdc.rs +++ b/examples/stm32u5/src/bin/ltdc.rs | |||
| @@ -13,14 +13,14 @@ use embassy_stm32::gpio::{Level, Output, Speed}; | |||
| 13 | use embassy_stm32::ltdc::{self, Ltdc, LtdcConfiguration, LtdcLayer, LtdcLayerConfig, PolarityActive, PolarityEdge}; | 13 | use embassy_stm32::ltdc::{self, Ltdc, LtdcConfiguration, LtdcLayer, LtdcLayerConfig, PolarityActive, PolarityEdge}; |
| 14 | use embassy_stm32::{bind_interrupts, peripherals}; | 14 | use embassy_stm32::{bind_interrupts, peripherals}; |
| 15 | use embassy_time::{Duration, Timer}; | 15 | use embassy_time::{Duration, Timer}; |
| 16 | use embedded_graphics::Pixel; | ||
| 16 | use embedded_graphics::draw_target::DrawTarget; | 17 | use embedded_graphics::draw_target::DrawTarget; |
| 17 | use embedded_graphics::geometry::{OriginDimensions, Point, Size}; | 18 | use embedded_graphics::geometry::{OriginDimensions, Point, Size}; |
| 18 | use embedded_graphics::image::Image; | 19 | use embedded_graphics::image::Image; |
| 19 | use embedded_graphics::pixelcolor::raw::RawU24; | ||
| 20 | use embedded_graphics::pixelcolor::Rgb888; | 20 | use embedded_graphics::pixelcolor::Rgb888; |
| 21 | use embedded_graphics::pixelcolor::raw::RawU24; | ||
| 21 | use embedded_graphics::prelude::*; | 22 | use embedded_graphics::prelude::*; |
| 22 | use embedded_graphics::primitives::Rectangle; | 23 | use embedded_graphics::primitives::Rectangle; |
| 23 | use embedded_graphics::Pixel; | ||
| 24 | use heapless::{Entry, FnvIndexMap}; | 24 | use heapless::{Entry, FnvIndexMap}; |
| 25 | use tinybmp::Bmp; | 25 | use tinybmp::Bmp; |
| 26 | use {defmt_rtt as _, panic_probe as _}; | 26 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -317,7 +317,7 @@ impl OriginDimensions for DoubleBuffer { | |||
| 317 | mod rcc_setup { | 317 | mod rcc_setup { |
| 318 | 318 | ||
| 319 | use embassy_stm32::time::Hertz; | 319 | use embassy_stm32::time::Hertz; |
| 320 | use embassy_stm32::{rcc, Config, Peripherals}; | 320 | use embassy_stm32::{Config, Peripherals, rcc}; |
| 321 | 321 | ||
| 322 | /// Sets up clocks for the stm32u5g9zj mcu | 322 | /// Sets up clocks for the stm32u5g9zj mcu |
| 323 | /// change this if you plan to use a different microcontroller | 323 | /// change this if you plan to use a different microcontroller |
diff --git a/examples/stm32u5/src/bin/usb_hs_serial.rs b/examples/stm32u5/src/bin/usb_hs_serial.rs index d37e7777b..c444d3479 100644 --- a/examples/stm32u5/src/bin/usb_hs_serial.rs +++ b/examples/stm32u5/src/bin/usb_hs_serial.rs | |||
| @@ -6,10 +6,10 @@ use defmt_rtt as _; // global logger | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_futures::join::join; | 7 | use embassy_futures::join::join; |
| 8 | use embassy_stm32::usb::{Driver, Instance}; | 8 | use embassy_stm32::usb::{Driver, Instance}; |
| 9 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 9 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 10 | use embassy_usb::Builder; | ||
| 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 11 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 11 | use embassy_usb::driver::EndpointError; | 12 | use embassy_usb::driver::EndpointError; |
| 12 | use embassy_usb::Builder; | ||
| 13 | use panic_probe as _; | 13 | use panic_probe as _; |
| 14 | 14 | ||
| 15 | bind_interrupts!(struct Irqs { | 15 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32u5/src/bin/usb_serial.rs b/examples/stm32u5/src/bin/usb_serial.rs index ff7f4e5be..c0a768cbb 100644 --- a/examples/stm32u5/src/bin/usb_serial.rs +++ b/examples/stm32u5/src/bin/usb_serial.rs | |||
| @@ -6,10 +6,10 @@ use defmt_rtt as _; // global logger | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_futures::join::join; | 7 | use embassy_futures::join::join; |
| 8 | use embassy_stm32::usb::{Driver, Instance}; | 8 | use embassy_stm32::usb::{Driver, Instance}; |
| 9 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 9 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 10 | use embassy_usb::Builder; | ||
| 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 11 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 11 | use embassy_usb::driver::EndpointError; | 12 | use embassy_usb::driver::EndpointError; |
| 12 | use embassy_usb::Builder; | ||
| 13 | use panic_probe as _; | 13 | use panic_probe as _; |
| 14 | 14 | ||
| 15 | bind_interrupts!(struct Irqs { | 15 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32wb/Cargo.toml b/examples/stm32wb/Cargo.toml index 7ab13c290..783690c11 100644 --- a/examples/stm32wb/Cargo.toml +++ b/examples/stm32wb/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32wb-examples" | 3 | name = "embassy-stm32wb-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32wb/src/bin/eddystone_beacon.rs b/examples/stm32wb/src/bin/eddystone_beacon.rs index 3bd8b4a63..f309ca3a2 100644 --- a/examples/stm32wb/src/bin/eddystone_beacon.rs +++ b/examples/stm32wb/src/bin/eddystone_beacon.rs | |||
| @@ -8,15 +8,15 @@ use embassy_executor::Spawner; | |||
| 8 | use embassy_stm32::bind_interrupts; | 8 | use embassy_stm32::bind_interrupts; |
| 9 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; | 9 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; |
| 10 | use embassy_stm32::rcc::WPAN_DEFAULT; | 10 | use embassy_stm32::rcc::WPAN_DEFAULT; |
| 11 | use embassy_stm32_wpan::TlMbox; | ||
| 12 | use embassy_stm32_wpan::hci::BdAddr; | ||
| 11 | use embassy_stm32_wpan::hci::host::uart::UartHci; | 13 | use embassy_stm32_wpan::hci::host::uart::UartHci; |
| 12 | use embassy_stm32_wpan::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; | 14 | use embassy_stm32_wpan::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; |
| 13 | use embassy_stm32_wpan::hci::types::AdvertisingType; | 15 | use embassy_stm32_wpan::hci::types::AdvertisingType; |
| 14 | use embassy_stm32_wpan::hci::vendor::command::gap::{AdvertisingDataType, DiscoverableParameters, GapCommands, Role}; | 16 | use embassy_stm32_wpan::hci::vendor::command::gap::{AdvertisingDataType, DiscoverableParameters, GapCommands, Role}; |
| 15 | use embassy_stm32_wpan::hci::vendor::command::gatt::GattCommands; | 17 | use embassy_stm32_wpan::hci::vendor::command::gatt::GattCommands; |
| 16 | use embassy_stm32_wpan::hci::vendor::command::hal::{ConfigData, HalCommands, PowerLevel}; | 18 | use embassy_stm32_wpan::hci::vendor::command::hal::{ConfigData, HalCommands, PowerLevel}; |
| 17 | use embassy_stm32_wpan::hci::BdAddr; | ||
| 18 | use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; | 19 | use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; |
| 19 | use embassy_stm32_wpan::TlMbox; | ||
| 20 | use {defmt_rtt as _, panic_probe as _}; | 20 | use {defmt_rtt as _, panic_probe as _}; |
| 21 | 21 | ||
| 22 | bind_interrupts!(struct Irqs{ | 22 | bind_interrupts!(struct Irqs{ |
diff --git a/examples/stm32wb/src/bin/gatt_server.rs b/examples/stm32wb/src/bin/gatt_server.rs index 5d927bc00..2ed257566 100644 --- a/examples/stm32wb/src/bin/gatt_server.rs +++ b/examples/stm32wb/src/bin/gatt_server.rs | |||
| @@ -8,6 +8,7 @@ use embassy_executor::Spawner; | |||
| 8 | use embassy_stm32::bind_interrupts; | 8 | use embassy_stm32::bind_interrupts; |
| 9 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; | 9 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; |
| 10 | use embassy_stm32::rcc::WPAN_DEFAULT; | 10 | use embassy_stm32::rcc::WPAN_DEFAULT; |
| 11 | use embassy_stm32_wpan::TlMbox; | ||
| 11 | use embassy_stm32_wpan::hci::event::command::{CommandComplete, ReturnParameters}; | 12 | use embassy_stm32_wpan::hci::event::command::{CommandComplete, ReturnParameters}; |
| 12 | use embassy_stm32_wpan::hci::host::uart::{Packet, UartHci}; | 13 | use embassy_stm32_wpan::hci::host::uart::{Packet, UartHci}; |
| 13 | use embassy_stm32_wpan::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; | 14 | use embassy_stm32_wpan::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; |
| @@ -28,7 +29,6 @@ use embassy_stm32_wpan::hci::{BdAddr, Event}; | |||
| 28 | use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; | 29 | use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; |
| 29 | use embassy_stm32_wpan::sub::ble::Ble; | 30 | use embassy_stm32_wpan::sub::ble::Ble; |
| 30 | use embassy_stm32_wpan::sub::mm; | 31 | use embassy_stm32_wpan::sub::mm; |
| 31 | use embassy_stm32_wpan::TlMbox; | ||
| 32 | use {defmt_rtt as _, panic_probe as _}; | 32 | use {defmt_rtt as _, panic_probe as _}; |
| 33 | 33 | ||
| 34 | bind_interrupts!(struct Irqs{ | 34 | bind_interrupts!(struct Irqs{ |
diff --git a/examples/stm32wb/src/bin/mac_ffd.rs b/examples/stm32wb/src/bin/mac_ffd.rs index ede6cf4b9..18a52e162 100644 --- a/examples/stm32wb/src/bin/mac_ffd.rs +++ b/examples/stm32wb/src/bin/mac_ffd.rs | |||
| @@ -6,11 +6,11 @@ use embassy_executor::Spawner; | |||
| 6 | use embassy_stm32::bind_interrupts; | 6 | use embassy_stm32::bind_interrupts; |
| 7 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; | 7 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; |
| 8 | use embassy_stm32::rcc::WPAN_DEFAULT; | 8 | use embassy_stm32::rcc::WPAN_DEFAULT; |
| 9 | use embassy_stm32_wpan::TlMbox; | ||
| 9 | use embassy_stm32_wpan::mac::commands::{AssociateResponse, ResetRequest, SetRequest, StartRequest}; | 10 | use embassy_stm32_wpan::mac::commands::{AssociateResponse, ResetRequest, SetRequest, StartRequest}; |
| 10 | use embassy_stm32_wpan::mac::event::MacEvent; | 11 | use embassy_stm32_wpan::mac::event::MacEvent; |
| 11 | use embassy_stm32_wpan::mac::typedefs::{MacChannel, MacStatus, PanId, PibId, SecurityLevel}; | 12 | use embassy_stm32_wpan::mac::typedefs::{MacChannel, MacStatus, PanId, PibId, SecurityLevel}; |
| 12 | use embassy_stm32_wpan::sub::mm; | 13 | use embassy_stm32_wpan::sub::mm; |
| 13 | use embassy_stm32_wpan::TlMbox; | ||
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 15 | 15 | ||
| 16 | bind_interrupts!(struct Irqs{ | 16 | bind_interrupts!(struct Irqs{ |
diff --git a/examples/stm32wb/src/bin/mac_ffd_net.rs b/examples/stm32wb/src/bin/mac_ffd_net.rs index cc3b21e2e..5296943a1 100644 --- a/examples/stm32wb/src/bin/mac_ffd_net.rs +++ b/examples/stm32wb/src/bin/mac_ffd_net.rs | |||
| @@ -6,11 +6,11 @@ use embassy_executor::Spawner; | |||
| 6 | use embassy_stm32::bind_interrupts; | 6 | use embassy_stm32::bind_interrupts; |
| 7 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; | 7 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; |
| 8 | use embassy_stm32::rcc::WPAN_DEFAULT; | 8 | use embassy_stm32::rcc::WPAN_DEFAULT; |
| 9 | use embassy_stm32_wpan::TlMbox; | ||
| 9 | use embassy_stm32_wpan::mac::commands::{ResetRequest, SetRequest, StartRequest}; | 10 | use embassy_stm32_wpan::mac::commands::{ResetRequest, SetRequest, StartRequest}; |
| 10 | use embassy_stm32_wpan::mac::typedefs::{MacChannel, PanId, PibId}; | 11 | use embassy_stm32_wpan::mac::typedefs::{MacChannel, PanId, PibId}; |
| 11 | use embassy_stm32_wpan::mac::{self, Runner}; | 12 | use embassy_stm32_wpan::mac::{self, Runner}; |
| 12 | use embassy_stm32_wpan::sub::mm; | 13 | use embassy_stm32_wpan::sub::mm; |
| 13 | use embassy_stm32_wpan::TlMbox; | ||
| 14 | use static_cell::StaticCell; | 14 | use static_cell::StaticCell; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 16 | ||
diff --git a/examples/stm32wb/src/bin/mac_rfd.rs b/examples/stm32wb/src/bin/mac_rfd.rs index d872104a8..883179023 100644 --- a/examples/stm32wb/src/bin/mac_rfd.rs +++ b/examples/stm32wb/src/bin/mac_rfd.rs | |||
| @@ -6,13 +6,13 @@ use embassy_executor::Spawner; | |||
| 6 | use embassy_stm32::bind_interrupts; | 6 | use embassy_stm32::bind_interrupts; |
| 7 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; | 7 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; |
| 8 | use embassy_stm32::rcc::WPAN_DEFAULT; | 8 | use embassy_stm32::rcc::WPAN_DEFAULT; |
| 9 | use embassy_stm32_wpan::TlMbox; | ||
| 9 | use embassy_stm32_wpan::mac::commands::{AssociateRequest, DataRequest, GetRequest, ResetRequest, SetRequest}; | 10 | use embassy_stm32_wpan::mac::commands::{AssociateRequest, DataRequest, GetRequest, ResetRequest, SetRequest}; |
| 10 | use embassy_stm32_wpan::mac::event::MacEvent; | 11 | use embassy_stm32_wpan::mac::event::MacEvent; |
| 11 | use embassy_stm32_wpan::mac::typedefs::{ | 12 | use embassy_stm32_wpan::mac::typedefs::{ |
| 12 | AddressMode, Capabilities, KeyIdMode, MacAddress, MacChannel, PanId, PibId, SecurityLevel, | 13 | AddressMode, Capabilities, KeyIdMode, MacAddress, MacChannel, PanId, PibId, SecurityLevel, |
| 13 | }; | 14 | }; |
| 14 | use embassy_stm32_wpan::sub::mm; | 15 | use embassy_stm32_wpan::sub::mm; |
| 15 | use embassy_stm32_wpan::TlMbox; | ||
| 16 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
| 17 | 17 | ||
| 18 | bind_interrupts!(struct Irqs{ | 18 | bind_interrupts!(struct Irqs{ |
diff --git a/examples/stm32wb/src/bin/tl_mbox_mac.rs b/examples/stm32wb/src/bin/tl_mbox_mac.rs index 95c73872b..16d0a1527 100644 --- a/examples/stm32wb/src/bin/tl_mbox_mac.rs +++ b/examples/stm32wb/src/bin/tl_mbox_mac.rs | |||
| @@ -6,8 +6,8 @@ use embassy_executor::Spawner; | |||
| 6 | use embassy_stm32::bind_interrupts; | 6 | use embassy_stm32::bind_interrupts; |
| 7 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; | 7 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; |
| 8 | use embassy_stm32::rcc::WPAN_DEFAULT; | 8 | use embassy_stm32::rcc::WPAN_DEFAULT; |
| 9 | use embassy_stm32_wpan::sub::mm; | ||
| 10 | use embassy_stm32_wpan::TlMbox; | 9 | use embassy_stm32_wpan::TlMbox; |
| 10 | use embassy_stm32_wpan::sub::mm; | ||
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | bind_interrupts!(struct Irqs{ | 13 | bind_interrupts!(struct Irqs{ |
diff --git a/examples/stm32wba/Cargo.toml b/examples/stm32wba/Cargo.toml index e1196614a..3496b41b0 100644 --- a/examples/stm32wba/Cargo.toml +++ b/examples/stm32wba/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32wba-examples" | 3 | name = "embassy-stm32wba-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32wba/src/bin/adc.rs b/examples/stm32wba/src/bin/adc.rs index a9651d57e..8c80470b8 100644 --- a/examples/stm32wba/src/bin/adc.rs +++ b/examples/stm32wba/src/bin/adc.rs | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_stm32::adc::{adc4, AdcChannel}; | 5 | use embassy_stm32::adc::{AdcChannel, adc4}; |
| 6 | use {defmt_rtt as _, panic_probe as _}; | 6 | use {defmt_rtt as _, panic_probe as _}; |
| 7 | 7 | ||
| 8 | #[embassy_executor::main] | 8 | #[embassy_executor::main] |
diff --git a/examples/stm32wba/src/bin/pwm.rs b/examples/stm32wba/src/bin/pwm.rs index de690fda0..f20c77a7c 100644 --- a/examples/stm32wba/src/bin/pwm.rs +++ b/examples/stm32wba/src/bin/pwm.rs | |||
| @@ -4,13 +4,13 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use defmt_rtt as _; // global logger | 5 | use defmt_rtt as _; // global logger |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::Config; | ||
| 7 | use embassy_stm32::gpio::OutputType; | 8 | use embassy_stm32::gpio::OutputType; |
| 8 | use embassy_stm32::rcc::{ | 9 | use embassy_stm32::rcc::{ |
| 9 | AHB5Prescaler, AHBPrescaler, APBPrescaler, PllDiv, PllMul, PllPreDiv, PllSource, Sysclk, VoltageScale, | 10 | AHB5Prescaler, AHBPrescaler, APBPrescaler, PllDiv, PllMul, PllPreDiv, PllSource, Sysclk, VoltageScale, |
| 10 | }; | 11 | }; |
| 11 | use embassy_stm32::time::khz; | 12 | use embassy_stm32::time::khz; |
| 12 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; | 13 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; |
| 13 | use embassy_stm32::Config; | ||
| 14 | use embassy_time::Timer; | 14 | use embassy_time::Timer; |
| 15 | use panic_probe as _; | 15 | use panic_probe as _; |
| 16 | 16 | ||
diff --git a/examples/stm32wba6/Cargo.toml b/examples/stm32wba6/Cargo.toml index f98317846..04bb27cb0 100644 --- a/examples/stm32wba6/Cargo.toml +++ b/examples/stm32wba6/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32wba6-examples" | 3 | name = "embassy-stm32wba6-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32wba6/src/bin/adc.rs b/examples/stm32wba6/src/bin/adc.rs index a9651d57e..8c80470b8 100644 --- a/examples/stm32wba6/src/bin/adc.rs +++ b/examples/stm32wba6/src/bin/adc.rs | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_stm32::adc::{adc4, AdcChannel}; | 5 | use embassy_stm32::adc::{AdcChannel, adc4}; |
| 6 | use {defmt_rtt as _, panic_probe as _}; | 6 | use {defmt_rtt as _, panic_probe as _}; |
| 7 | 7 | ||
| 8 | #[embassy_executor::main] | 8 | #[embassy_executor::main] |
diff --git a/examples/stm32wba6/src/bin/pwm.rs b/examples/stm32wba6/src/bin/pwm.rs index 2c696834a..64ae01945 100644 --- a/examples/stm32wba6/src/bin/pwm.rs +++ b/examples/stm32wba6/src/bin/pwm.rs | |||
| @@ -4,13 +4,13 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use defmt_rtt as _; // global logger | 5 | use defmt_rtt as _; // global logger |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::Config; | ||
| 7 | use embassy_stm32::gpio::OutputType; | 8 | use embassy_stm32::gpio::OutputType; |
| 8 | use embassy_stm32::rcc::{ | 9 | use embassy_stm32::rcc::{ |
| 9 | AHB5Prescaler, AHBPrescaler, APBPrescaler, PllDiv, PllMul, PllPreDiv, PllSource, Sysclk, VoltageScale, | 10 | AHB5Prescaler, AHBPrescaler, APBPrescaler, PllDiv, PllMul, PllPreDiv, PllSource, Sysclk, VoltageScale, |
| 10 | }; | 11 | }; |
| 11 | use embassy_stm32::time::khz; | 12 | use embassy_stm32::time::khz; |
| 12 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; | 13 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; |
| 13 | use embassy_stm32::Config; | ||
| 14 | use embassy_time::Timer; | 14 | use embassy_time::Timer; |
| 15 | use panic_probe as _; | 15 | use panic_probe as _; |
| 16 | 16 | ||
diff --git a/examples/stm32wba6/src/bin/usb_hs_serial.rs b/examples/stm32wba6/src/bin/usb_hs_serial.rs index 20bdeaac3..a60eeb480 100644 --- a/examples/stm32wba6/src/bin/usb_hs_serial.rs +++ b/examples/stm32wba6/src/bin/usb_hs_serial.rs | |||
| @@ -5,10 +5,10 @@ use defmt::{panic, *}; | |||
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_futures::join::join; | 6 | use embassy_futures::join::join; |
| 7 | use embassy_stm32::usb::{Driver, Instance}; | 7 | use embassy_stm32::usb::{Driver, Instance}; |
| 8 | use embassy_stm32::{bind_interrupts, peripherals, usb, Config}; | 8 | use embassy_stm32::{Config, bind_interrupts, peripherals, usb}; |
| 9 | use embassy_usb::Builder; | ||
| 9 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 10 | use embassy_usb::driver::EndpointError; | 11 | use embassy_usb::driver::EndpointError; |
| 11 | use embassy_usb::Builder; | ||
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
| 14 | bind_interrupts!(struct Irqs { | 14 | bind_interrupts!(struct Irqs { |
diff --git a/examples/stm32wl/Cargo.toml b/examples/stm32wl/Cargo.toml index 825d25c0d..1754aa0b8 100644 --- a/examples/stm32wl/Cargo.toml +++ b/examples/stm32wl/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32wl-examples" | 3 | name = "embassy-stm32wl-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/examples/stm32wl/src/bin/adc.rs b/examples/stm32wl/src/bin/adc.rs index 118f02ae1..6b21b086b 100644 --- a/examples/stm32wl/src/bin/adc.rs +++ b/examples/stm32wl/src/bin/adc.rs | |||
| @@ -5,8 +5,8 @@ use core::mem::MaybeUninit; | |||
| 5 | 5 | ||
| 6 | use defmt::*; | 6 | use defmt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::adc::{Adc, CkModePclk, Clock, SampleTime}; | ||
| 9 | use embassy_stm32::SharedData; | 8 | use embassy_stm32::SharedData; |
| 9 | use embassy_stm32::adc::{Adc, CkModePclk, Clock, SampleTime}; | ||
| 10 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
diff --git a/examples/stm32wl/src/bin/blinky.rs b/examples/stm32wl/src/bin/blinky.rs index a2a90871d..f7f57e35c 100644 --- a/examples/stm32wl/src/bin/blinky.rs +++ b/examples/stm32wl/src/bin/blinky.rs | |||
| @@ -5,8 +5,8 @@ use core::mem::MaybeUninit; | |||
| 5 | 5 | ||
| 6 | use defmt::*; | 6 | use defmt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | ||
| 9 | use embassy_stm32::SharedData; | 8 | use embassy_stm32::SharedData; |
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | ||
| 10 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
diff --git a/examples/stm32wl/src/bin/button.rs b/examples/stm32wl/src/bin/button.rs index 21bcd2ac6..07bc95ad7 100644 --- a/examples/stm32wl/src/bin/button.rs +++ b/examples/stm32wl/src/bin/button.rs | |||
| @@ -5,8 +5,8 @@ use core::mem::MaybeUninit; | |||
| 5 | 5 | ||
| 6 | use cortex_m_rt::entry; | 6 | use cortex_m_rt::entry; |
| 7 | use defmt::*; | 7 | use defmt::*; |
| 8 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | ||
| 9 | use embassy_stm32::SharedData; | 8 | use embassy_stm32::SharedData; |
| 9 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | #[unsafe(link_section = ".shared_data")] | 12 | #[unsafe(link_section = ".shared_data")] |
diff --git a/examples/stm32wl/src/bin/button_exti.rs b/examples/stm32wl/src/bin/button_exti.rs index 0a8aece34..953b13bac 100644 --- a/examples/stm32wl/src/bin/button_exti.rs +++ b/examples/stm32wl/src/bin/button_exti.rs | |||
| @@ -5,9 +5,9 @@ use core::mem::MaybeUninit; | |||
| 5 | 5 | ||
| 6 | use defmt::*; | 6 | use defmt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::SharedData; | ||
| 8 | use embassy_stm32::exti::ExtiInput; | 9 | use embassy_stm32::exti::ExtiInput; |
| 9 | use embassy_stm32::gpio::Pull; | 10 | use embassy_stm32::gpio::Pull; |
| 10 | use embassy_stm32::SharedData; | ||
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | #[unsafe(link_section = ".shared_data")] | 13 | #[unsafe(link_section = ".shared_data")] |
diff --git a/examples/stm32wl/src/bin/flash.rs b/examples/stm32wl/src/bin/flash.rs index 320a9723a..bc707820d 100644 --- a/examples/stm32wl/src/bin/flash.rs +++ b/examples/stm32wl/src/bin/flash.rs | |||
| @@ -5,8 +5,8 @@ use core::mem::MaybeUninit; | |||
| 5 | 5 | ||
| 6 | use defmt::{info, unwrap}; | 6 | use defmt::{info, unwrap}; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::flash::Flash; | ||
| 9 | use embassy_stm32::SharedData; | 8 | use embassy_stm32::SharedData; |
| 9 | use embassy_stm32::flash::Flash; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | #[unsafe(link_section = ".shared_data")] | 12 | #[unsafe(link_section = ".shared_data")] |
diff --git a/examples/stm32wl/src/bin/random.rs b/examples/stm32wl/src/bin/random.rs index 68b9d7d00..931f9819a 100644 --- a/examples/stm32wl/src/bin/random.rs +++ b/examples/stm32wl/src/bin/random.rs | |||
| @@ -7,7 +7,7 @@ use defmt::*; | |||
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::rng::{self, Rng}; | 8 | use embassy_stm32::rng::{self, Rng}; |
| 9 | use embassy_stm32::time::Hertz; | 9 | use embassy_stm32::time::Hertz; |
| 10 | use embassy_stm32::{bind_interrupts, peripherals, SharedData}; | 10 | use embassy_stm32::{SharedData, bind_interrupts, peripherals}; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
| 13 | bind_interrupts!(struct Irqs{ | 13 | bind_interrupts!(struct Irqs{ |
diff --git a/examples/stm32wl/src/bin/uart_async.rs b/examples/stm32wl/src/bin/uart_async.rs index 505a85f47..829ea2de7 100644 --- a/examples/stm32wl/src/bin/uart_async.rs +++ b/examples/stm32wl/src/bin/uart_async.rs | |||
| @@ -6,7 +6,7 @@ use core::mem::MaybeUninit; | |||
| 6 | use defmt::*; | 6 | use defmt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::usart::{Config, InterruptHandler, Uart}; | 8 | use embassy_stm32::usart::{Config, InterruptHandler, Uart}; |
| 9 | use embassy_stm32::{bind_interrupts, peripherals, SharedData}; | 9 | use embassy_stm32::{SharedData, bind_interrupts, peripherals}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| 12 | bind_interrupts!(struct Irqs{ | 12 | bind_interrupts!(struct Irqs{ |
diff --git a/examples/wasm/Cargo.toml b/examples/wasm/Cargo.toml index e8897506c..79d50b584 100644 --- a/examples/wasm/Cargo.toml +++ b/examples/wasm/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-wasm-example" | 3 | name = "embassy-wasm-example" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/rustfmt.toml b/rustfmt.toml index 2561562fd..3d5eeed93 100644 --- a/rustfmt.toml +++ b/rustfmt.toml | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | group_imports = "StdExternalCrate" | 1 | group_imports = "StdExternalCrate" |
| 2 | imports_granularity = "Module" | 2 | imports_granularity = "Module" |
| 3 | edition = "2021" | 3 | edition = "2024" |
| 4 | max_width = 120 | 4 | max_width = 120 |
diff --git a/tests/mspm0/Cargo.toml b/tests/mspm0/Cargo.toml index 227d898d5..df52b538d 100644 --- a/tests/mspm0/Cargo.toml +++ b/tests/mspm0/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-mspm0-tests" | 3 | name = "embassy-mspm0-tests" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/tests/mspm0/src/bin/dma.rs b/tests/mspm0/src/bin/dma.rs index 6fd973a18..9c56acadc 100644 --- a/tests/mspm0/src/bin/dma.rs +++ b/tests/mspm0/src/bin/dma.rs | |||
| @@ -11,8 +11,8 @@ use core::slice; | |||
| 11 | 11 | ||
| 12 | use defmt::{assert, assert_eq, *}; | 12 | use defmt::{assert, assert_eq, *}; |
| 13 | use embassy_executor::Spawner; | 13 | use embassy_executor::Spawner; |
| 14 | use embassy_mspm0::dma::{Channel, Transfer, TransferMode, TransferOptions, Word}; | ||
| 15 | use embassy_mspm0::Peri; | 14 | use embassy_mspm0::Peri; |
| 15 | use embassy_mspm0::dma::{Channel, Transfer, TransferMode, TransferOptions, Word}; | ||
| 16 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
| 17 | 17 | ||
| 18 | #[embassy_executor::main] | 18 | #[embassy_executor::main] |
diff --git a/tests/nrf/Cargo.toml b/tests/nrf/Cargo.toml index efc297ccf..3a9b86cef 100644 --- a/tests/nrf/Cargo.toml +++ b/tests/nrf/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-nrf-examples" | 3 | name = "embassy-nrf-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| @@ -12,7 +12,7 @@ embassy-futures = { version = "0.1.2", path = "../../embassy-futures" } | |||
| 12 | embassy-sync = { version = "0.7.2", path = "../../embassy-sync", features = ["defmt", ] } | 12 | embassy-sync = { version = "0.7.2", path = "../../embassy-sync", features = ["defmt", ] } |
| 13 | embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } | 13 | embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } |
| 14 | embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } | 14 | embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } |
| 15 | embassy-nrf = { version = "0.7.0", path = "../../embassy-nrf", features = ["defmt", "time-driver-rtc1", "gpiote", "unstable-pac"] } | 15 | embassy-nrf = { version = "0.8.0", path = "../../embassy-nrf", features = ["defmt", "time-driver-rtc1", "gpiote", "unstable-pac"] } |
| 16 | embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } | 16 | embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } |
| 17 | embassy-net = { version = "0.7.1", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] } | 17 | embassy-net = { version = "0.7.1", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] } |
| 18 | embassy-net-esp-hosted = { version = "0.2.1", path = "../../embassy-net-esp-hosted", features = ["defmt"] } | 18 | embassy-net-esp-hosted = { version = "0.2.1", path = "../../embassy-net-esp-hosted", features = ["defmt"] } |
diff --git a/tests/perf-client/Cargo.toml b/tests/perf-client/Cargo.toml index c426fdd74..3756046fa 100644 --- a/tests/perf-client/Cargo.toml +++ b/tests/perf-client/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "perf-client" | 2 | name = "perf-client" |
| 3 | version = "0.1.0" | 3 | version = "0.1.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | publish = false | 6 | publish = false |
| 7 | 7 | ||
diff --git a/tests/perf-client/src/lib.rs b/tests/perf-client/src/lib.rs index 4bd9e5674..1ba071e8d 100644 --- a/tests/perf-client/src/lib.rs +++ b/tests/perf-client/src/lib.rs | |||
| @@ -4,7 +4,7 @@ use defmt::{assert, *}; | |||
| 4 | use embassy_futures::join::join; | 4 | use embassy_futures::join::join; |
| 5 | use embassy_net::tcp::TcpSocket; | 5 | use embassy_net::tcp::TcpSocket; |
| 6 | use embassy_net::{Ipv4Address, Stack}; | 6 | use embassy_net::{Ipv4Address, Stack}; |
| 7 | use embassy_time::{with_timeout, Duration, Timer}; | 7 | use embassy_time::{Duration, Timer, with_timeout}; |
| 8 | 8 | ||
| 9 | pub struct Expected { | 9 | pub struct Expected { |
| 10 | pub down_kbps: usize, | 10 | pub down_kbps: usize, |
diff --git a/tests/perf-server/Cargo.toml b/tests/perf-server/Cargo.toml index f048eade2..72f92ed8d 100644 --- a/tests/perf-server/Cargo.toml +++ b/tests/perf-server/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "perf-server" | 2 | name = "perf-server" |
| 3 | version = "0.1.0" | 3 | version = "0.1.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | publish = false | 6 | publish = false |
| 7 | 7 | ||
diff --git a/tests/riscv32/Cargo.toml b/tests/riscv32/Cargo.toml index c441e8ed3..935c6a2ee 100644 --- a/tests/riscv32/Cargo.toml +++ b/tests/riscv32/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-riscv-tests" | 3 | name = "embassy-riscv-tests" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index 19461520a..640e58f11 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-rp-tests" | 3 | name = "embassy-rp-tests" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/tests/rp/src/bin/cyw43-perf.rs b/tests/rp/src/bin/cyw43-perf.rs index 555134ffd..9487f5e1a 100644 --- a/tests/rp/src/bin/cyw43-perf.rs +++ b/tests/rp/src/bin/cyw43-perf.rs | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | teleprobe_meta::target!(b"rpi-pico"); | 3 | teleprobe_meta::target!(b"rpi-pico"); |
| 4 | 4 | ||
| 5 | use cyw43::JoinOptions; | 5 | use cyw43::JoinOptions; |
| 6 | use cyw43_pio::{PioSpi, DEFAULT_CLOCK_DIVIDER}; | 6 | use cyw43_pio::{DEFAULT_CLOCK_DIVIDER, PioSpi}; |
| 7 | use defmt::{panic, *}; | 7 | use defmt::{panic, *}; |
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_net::{Config, StackResources}; | 9 | use embassy_net::{Config, StackResources}; |
diff --git a/tests/rp/src/bin/gpio_multicore.rs b/tests/rp/src/bin/gpio_multicore.rs index f48dd207b..6abcba590 100644 --- a/tests/rp/src/bin/gpio_multicore.rs +++ b/tests/rp/src/bin/gpio_multicore.rs | |||
| @@ -7,10 +7,10 @@ teleprobe_meta::target!(b"pimoroni-pico-plus-2"); | |||
| 7 | 7 | ||
| 8 | use defmt::{info, unwrap}; | 8 | use defmt::{info, unwrap}; |
| 9 | use embassy_executor::Executor; | 9 | use embassy_executor::Executor; |
| 10 | use embassy_rp::Peri; | ||
| 10 | use embassy_rp::gpio::{Input, Level, Output, Pull}; | 11 | use embassy_rp::gpio::{Input, Level, Output, Pull}; |
| 11 | use embassy_rp::multicore::{spawn_core1, Stack}; | 12 | use embassy_rp::multicore::{Stack, spawn_core1}; |
| 12 | use embassy_rp::peripherals::{PIN_0, PIN_1}; | 13 | use embassy_rp::peripherals::{PIN_0, PIN_1}; |
| 13 | use embassy_rp::Peri; | ||
| 14 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 14 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| 15 | use embassy_sync::channel::Channel; | 15 | use embassy_sync::channel::Channel; |
| 16 | use static_cell::StaticCell; | 16 | use static_cell::StaticCell; |
diff --git a/tests/rp/src/bin/multicore.rs b/tests/rp/src/bin/multicore.rs index 11b03cfea..7e34bc778 100644 --- a/tests/rp/src/bin/multicore.rs +++ b/tests/rp/src/bin/multicore.rs | |||
| @@ -7,7 +7,7 @@ teleprobe_meta::target!(b"pimoroni-pico-plus-2"); | |||
| 7 | 7 | ||
| 8 | use defmt::{info, unwrap}; | 8 | use defmt::{info, unwrap}; |
| 9 | use embassy_executor::Executor; | 9 | use embassy_executor::Executor; |
| 10 | use embassy_rp::multicore::{spawn_core1, Stack}; | 10 | use embassy_rp::multicore::{Stack, spawn_core1}; |
| 11 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 11 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| 12 | use embassy_sync::channel::Channel; | 12 | use embassy_sync::channel::Channel; |
| 13 | use static_cell::StaticCell; | 13 | use static_cell::StaticCell; |
diff --git a/tests/rp/src/bin/overclock.rs b/tests/rp/src/bin/overclock.rs index 167a26eb2..87a03b5e2 100644 --- a/tests/rp/src/bin/overclock.rs +++ b/tests/rp/src/bin/overclock.rs | |||
| @@ -8,7 +8,7 @@ teleprobe_meta::target!(b"pimoroni-pico-plus-2"); | |||
| 8 | 8 | ||
| 9 | use defmt::info; | 9 | use defmt::info; |
| 10 | use embassy_executor::Spawner; | 10 | use embassy_executor::Spawner; |
| 11 | use embassy_rp::clocks::{clk_sys_freq, core_voltage, ClockConfig, CoreVoltage}; | 11 | use embassy_rp::clocks::{ClockConfig, CoreVoltage, clk_sys_freq, core_voltage}; |
| 12 | use embassy_rp::config::Config; | 12 | use embassy_rp::config::Config; |
| 13 | use embassy_time::Instant; | 13 | use embassy_time::Instant; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
diff --git a/tests/rp/src/bin/pio_multi_load.rs b/tests/rp/src/bin/pio_multi_load.rs index aca476d56..82bbab272 100644 --- a/tests/rp/src/bin/pio_multi_load.rs +++ b/tests/rp/src/bin/pio_multi_load.rs | |||
| @@ -57,7 +57,9 @@ async fn main(_spawner: Spawner) { | |||
| 57 | assert_eq!(loaded2.wrap.target, 14); | 57 | assert_eq!(loaded2.wrap.target, 14); |
| 58 | 58 | ||
| 59 | // wrapping around the end of program space automatically works | 59 | // wrapping around the end of program space automatically works |
| 60 | let prg3 = pio_asm!("nop", "nop", "nop", "nop", "nop", "nop", "nop", "nop", "nop", "nop", "nop", "irq 2",); | 60 | let prg3 = pio_asm!( |
| 61 | "nop", "nop", "nop", "nop", "nop", "nop", "nop", "nop", "nop", "nop", "nop", "irq 2", | ||
| 62 | ); | ||
| 61 | let loaded3 = common.load_program(&prg3.program); | 63 | let loaded3 = common.load_program(&prg3.program); |
| 62 | assert_eq!(loaded3.origin, 24); | 64 | assert_eq!(loaded3.origin, 24); |
| 63 | assert_eq!(loaded3.wrap.source, 3); | 65 | assert_eq!(loaded3.wrap.source, 3); |
diff --git a/tests/rp/src/bin/rtc.rs b/tests/rp/src/bin/rtc.rs index c66981d95..e1def7b5b 100644 --- a/tests/rp/src/bin/rtc.rs +++ b/tests/rp/src/bin/rtc.rs | |||
| @@ -5,7 +5,7 @@ teleprobe_meta::target!(b"rpi-pico"); | |||
| 5 | 5 | ||
| 6 | use defmt::{assert, *}; | 6 | use defmt::{assert, *}; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_futures::select::{select, Either}; | 8 | use embassy_futures::select::{Either, select}; |
| 9 | use embassy_rp::bind_interrupts; | 9 | use embassy_rp::bind_interrupts; |
| 10 | use embassy_rp::rtc::{DateTime, DateTimeFilter, DayOfWeek, Rtc}; | 10 | use embassy_rp::rtc::{DateTime, DateTimeFilter, DayOfWeek, Rtc}; |
| 11 | use embassy_time::{Duration, Instant, Timer}; | 11 | use embassy_time::{Duration, Instant, Timer}; |
diff --git a/tests/rp/src/bin/spinlock_mutex_multicore.rs b/tests/rp/src/bin/spinlock_mutex_multicore.rs index c56d43ade..25c4faf37 100644 --- a/tests/rp/src/bin/spinlock_mutex_multicore.rs +++ b/tests/rp/src/bin/spinlock_mutex_multicore.rs | |||
| @@ -7,7 +7,7 @@ teleprobe_meta::target!(b"pimoroni-pico-plus-2"); | |||
| 7 | 7 | ||
| 8 | use defmt::{info, unwrap}; | 8 | use defmt::{info, unwrap}; |
| 9 | use embassy_executor::Executor; | 9 | use embassy_executor::Executor; |
| 10 | use embassy_rp::multicore::{spawn_core1, Stack}; | 10 | use embassy_rp::multicore::{Stack, spawn_core1}; |
| 11 | use embassy_rp::spinlock_mutex::SpinlockRawMutex; | 11 | use embassy_rp::spinlock_mutex::SpinlockRawMutex; |
| 12 | use embassy_sync::channel::Channel; | 12 | use embassy_sync::channel::Channel; |
| 13 | use static_cell::StaticCell; | 13 | use static_cell::StaticCell; |
diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index 891ec93fd..1161e827b 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2024" |
| 3 | name = "embassy-stm32-tests" | 3 | name = "embassy-stm32-tests" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
diff --git a/tests/stm32/src/bin/afio.rs b/tests/stm32/src/bin/afio.rs index cc44dc59c..d88765717 100644 --- a/tests/stm32/src/bin/afio.rs +++ b/tests/stm32/src/bin/afio.rs | |||
| @@ -12,10 +12,11 @@ use embassy_stm32::time::khz; | |||
| 12 | use embassy_stm32::timer::complementary_pwm::{ComplementaryPwm, ComplementaryPwmPin}; | 12 | use embassy_stm32::timer::complementary_pwm::{ComplementaryPwm, ComplementaryPwmPin}; |
| 13 | use embassy_stm32::timer::input_capture::{CapturePin, InputCapture}; | 13 | use embassy_stm32::timer::input_capture::{CapturePin, InputCapture}; |
| 14 | use embassy_stm32::timer::pwm_input::PwmInput; | 14 | use embassy_stm32::timer::pwm_input::PwmInput; |
| 15 | use embassy_stm32::timer::qei::{Qei, QeiPin}; | 15 | use embassy_stm32::timer::qei::Qei; |
| 16 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; | 16 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; |
| 17 | use embassy_stm32::timer::{Ch1, Ch2}; | ||
| 17 | use embassy_stm32::usart::{Uart, UartRx, UartTx}; | 18 | use embassy_stm32::usart::{Uart, UartRx, UartTx}; |
| 18 | use embassy_stm32::{bind_interrupts, Peripherals}; | 19 | use embassy_stm32::{Peripherals, bind_interrupts}; |
| 19 | 20 | ||
| 20 | #[cfg(not(feature = "afio-connectivity-line"))] | 21 | #[cfg(not(feature = "afio-connectivity-line"))] |
| 21 | bind_interrupts!(struct Irqs { | 22 | bind_interrupts!(struct Irqs { |
| @@ -258,10 +259,11 @@ async fn main(_spawner: Spawner) { | |||
| 258 | { | 259 | { |
| 259 | // partial remap | 260 | // partial remap |
| 260 | reset_afio_registers(); | 261 | reset_afio_registers(); |
| 261 | Qei::new::<AfioRemap<1>>( | 262 | Qei::new::<Ch1, Ch2, AfioRemap<1>>( |
| 262 | p.TIM1.reborrow(), | 263 | p.TIM1.reborrow(), |
| 263 | QeiPin::new(p.PA8.reborrow()), | 264 | p.PA8.reborrow(), |
| 264 | QeiPin::new(p.PA9.reborrow()), | 265 | p.PA9.reborrow(), |
| 266 | Default::default(), | ||
| 265 | ); | 267 | ); |
| 266 | defmt::assert_eq!(AFIO.mapr().read().tim1_remap(), 1); | 268 | defmt::assert_eq!(AFIO.mapr().read().tim1_remap(), 1); |
| 267 | } | 269 | } |
diff --git a/tests/stm32/src/bin/cryp.rs b/tests/stm32/src/bin/cryp.rs index f54c99cc3..640de50e3 100644 --- a/tests/stm32/src/bin/cryp.rs +++ b/tests/stm32/src/bin/cryp.rs | |||
| @@ -5,9 +5,9 @@ | |||
| 5 | #[path = "../common.rs"] | 5 | #[path = "../common.rs"] |
| 6 | mod common; | 6 | mod common; |
| 7 | 7 | ||
| 8 | use aes_gcm::Aes128Gcm; | ||
| 8 | use aes_gcm::aead::heapless::Vec; | 9 | use aes_gcm::aead::heapless::Vec; |
| 9 | use aes_gcm::aead::{AeadInPlace, KeyInit}; | 10 | use aes_gcm::aead::{AeadInPlace, KeyInit}; |
| 10 | use aes_gcm::Aes128Gcm; | ||
| 11 | use common::*; | 11 | use common::*; |
| 12 | use embassy_executor::Spawner; | 12 | use embassy_executor::Spawner; |
| 13 | use embassy_stm32::cryp::{self, *}; | 13 | use embassy_stm32::cryp::{self, *}; |
diff --git a/tests/stm32/src/bin/fdcan.rs b/tests/stm32/src/bin/fdcan.rs index c2a1a7bb8..d97f493df 100644 --- a/tests/stm32/src/bin/fdcan.rs +++ b/tests/stm32/src/bin/fdcan.rs | |||
| @@ -8,7 +8,7 @@ mod common; | |||
| 8 | use common::*; | 8 | use common::*; |
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_stm32::peripherals::*; | 10 | use embassy_stm32::peripherals::*; |
| 11 | use embassy_stm32::{bind_interrupts, can, Config}; | 11 | use embassy_stm32::{Config, bind_interrupts, can}; |
| 12 | use embassy_time::Duration; | 12 | use embassy_time::Duration; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
diff --git a/tests/stm32/src/bin/stop.rs b/tests/stm32/src/bin/stop.rs index 8119c1f39..833ca05d0 100644 --- a/tests/stm32/src/bin/stop.rs +++ b/tests/stm32/src/bin/stop.rs | |||
| @@ -9,10 +9,10 @@ use chrono::NaiveDate; | |||
| 9 | use common::*; | 9 | use common::*; |
| 10 | use cortex_m_rt::entry; | 10 | use cortex_m_rt::entry; |
| 11 | use embassy_executor::Spawner; | 11 | use embassy_executor::Spawner; |
| 12 | use embassy_stm32::low_power::{stop_ready, stop_with_rtc, Executor, StopMode}; | 12 | use embassy_stm32::Config; |
| 13 | use embassy_stm32::low_power::{Executor, StopMode, stop_ready, stop_with_rtc}; | ||
| 13 | use embassy_stm32::rcc::LsConfig; | 14 | use embassy_stm32::rcc::LsConfig; |
| 14 | use embassy_stm32::rtc::{Rtc, RtcConfig}; | 15 | use embassy_stm32::rtc::{Rtc, RtcConfig}; |
| 15 | use embassy_stm32::Config; | ||
| 16 | use embassy_time::Timer; | 16 | use embassy_time::Timer; |
| 17 | use static_cell::StaticCell; | 17 | use static_cell::StaticCell; |
| 18 | 18 | ||
diff --git a/tests/stm32/src/bin/ucpd.rs b/tests/stm32/src/bin/ucpd.rs index 97aefe1a0..c794afff8 100644 --- a/tests/stm32/src/bin/ucpd.rs +++ b/tests/stm32/src/bin/ucpd.rs | |||
| @@ -9,7 +9,7 @@ use defmt::{assert, assert_eq}; | |||
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_futures::join::join; | 10 | use embassy_futures::join::join; |
| 11 | use embassy_stm32::ucpd::{self, CcPhy, CcPull, CcSel, CcVState, RxError, Ucpd}; | 11 | use embassy_stm32::ucpd::{self, CcPhy, CcPull, CcSel, CcVState, RxError, Ucpd}; |
| 12 | use embassy_stm32::{bind_interrupts, peripherals, Peri}; | 12 | use embassy_stm32::{Peri, bind_interrupts, peripherals}; |
| 13 | use embassy_time::Timer; | 13 | use embassy_time::Timer; |
| 14 | 14 | ||
| 15 | bind_interrupts!(struct Irqs { | 15 | bind_interrupts!(struct Irqs { |
diff --git a/tests/stm32/src/bin/usart.rs b/tests/stm32/src/bin/usart.rs index 129c7b692..0b98d3eeb 100644 --- a/tests/stm32/src/bin/usart.rs +++ b/tests/stm32/src/bin/usart.rs | |||
| @@ -7,7 +7,7 @@ use common::*; | |||
| 7 | use defmt::{assert, assert_eq, unreachable}; | 7 | use defmt::{assert, assert_eq, unreachable}; |
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::usart::{Config, ConfigError, Error, Uart}; | 9 | use embassy_stm32::usart::{Config, ConfigError, Error, Uart}; |
| 10 | use embassy_time::{block_for, Duration, Instant}; | 10 | use embassy_time::{Duration, Instant, block_for}; |
| 11 | 11 | ||
| 12 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner) { | 13 | async fn main(_spawner: Spawner) { |
diff --git a/tests/stm32/src/bin/wpan_ble.rs b/tests/stm32/src/bin/wpan_ble.rs index 8957bfc04..0f396b848 100644 --- a/tests/stm32/src/bin/wpan_ble.rs +++ b/tests/stm32/src/bin/wpan_ble.rs | |||
| @@ -12,16 +12,16 @@ use embassy_executor::Spawner; | |||
| 12 | use embassy_stm32::bind_interrupts; | 12 | use embassy_stm32::bind_interrupts; |
| 13 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; | 13 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; |
| 14 | use embassy_stm32::rcc::WPAN_DEFAULT; | 14 | use embassy_stm32::rcc::WPAN_DEFAULT; |
| 15 | use embassy_stm32_wpan::TlMbox; | ||
| 16 | use embassy_stm32_wpan::hci::BdAddr; | ||
| 15 | use embassy_stm32_wpan::hci::host::uart::UartHci; | 17 | use embassy_stm32_wpan::hci::host::uart::UartHci; |
| 16 | use embassy_stm32_wpan::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; | 18 | use embassy_stm32_wpan::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; |
| 17 | use embassy_stm32_wpan::hci::types::AdvertisingType; | 19 | use embassy_stm32_wpan::hci::types::AdvertisingType; |
| 18 | use embassy_stm32_wpan::hci::vendor::command::gap::{AdvertisingDataType, DiscoverableParameters, GapCommands, Role}; | 20 | use embassy_stm32_wpan::hci::vendor::command::gap::{AdvertisingDataType, DiscoverableParameters, GapCommands, Role}; |
| 19 | use embassy_stm32_wpan::hci::vendor::command::gatt::GattCommands; | 21 | use embassy_stm32_wpan::hci::vendor::command::gatt::GattCommands; |
| 20 | use embassy_stm32_wpan::hci::vendor::command::hal::{ConfigData, HalCommands, PowerLevel}; | 22 | use embassy_stm32_wpan::hci::vendor::command::hal::{ConfigData, HalCommands, PowerLevel}; |
| 21 | use embassy_stm32_wpan::hci::BdAddr; | ||
| 22 | use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; | 23 | use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; |
| 23 | use embassy_stm32_wpan::sub::mm; | 24 | use embassy_stm32_wpan::sub::mm; |
| 24 | use embassy_stm32_wpan::TlMbox; | ||
| 25 | use {defmt_rtt as _, panic_probe as _}; | 25 | use {defmt_rtt as _, panic_probe as _}; |
| 26 | 26 | ||
| 27 | bind_interrupts!(struct Irqs{ | 27 | bind_interrupts!(struct Irqs{ |
diff --git a/tests/stm32/src/bin/wpan_mac.rs b/tests/stm32/src/bin/wpan_mac.rs index 79e13d524..f27146c44 100644 --- a/tests/stm32/src/bin/wpan_mac.rs +++ b/tests/stm32/src/bin/wpan_mac.rs | |||
| @@ -10,13 +10,13 @@ use embassy_executor::Spawner; | |||
| 10 | use embassy_stm32::bind_interrupts; | 10 | use embassy_stm32::bind_interrupts; |
| 11 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; | 11 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; |
| 12 | use embassy_stm32::rcc::WPAN_DEFAULT; | 12 | use embassy_stm32::rcc::WPAN_DEFAULT; |
| 13 | use embassy_stm32_wpan::TlMbox; | ||
| 13 | use embassy_stm32_wpan::mac::commands::{AssociateRequest, GetRequest, ResetRequest, SetRequest}; | 14 | use embassy_stm32_wpan::mac::commands::{AssociateRequest, GetRequest, ResetRequest, SetRequest}; |
| 14 | use embassy_stm32_wpan::mac::event::MacEvent; | 15 | use embassy_stm32_wpan::mac::event::MacEvent; |
| 15 | use embassy_stm32_wpan::mac::typedefs::{ | 16 | use embassy_stm32_wpan::mac::typedefs::{ |
| 16 | AddressMode, Capabilities, KeyIdMode, MacAddress, MacChannel, PanId, PibId, SecurityLevel, | 17 | AddressMode, Capabilities, KeyIdMode, MacAddress, MacChannel, PanId, PibId, SecurityLevel, |
| 17 | }; | 18 | }; |
| 18 | use embassy_stm32_wpan::sub::mm; | 19 | use embassy_stm32_wpan::sub::mm; |
| 19 | use embassy_stm32_wpan::TlMbox; | ||
| 20 | use {defmt_rtt as _, panic_probe as _}; | 20 | use {defmt_rtt as _, panic_probe as _}; |
| 21 | 21 | ||
| 22 | bind_interrupts!(struct Irqs{ | 22 | bind_interrupts!(struct Irqs{ |
diff --git a/tests/stm32/src/common.rs b/tests/stm32/src/common.rs index f800769ab..2bd934d6f 100644 --- a/tests/stm32/src/common.rs +++ b/tests/stm32/src/common.rs | |||
| @@ -1,11 +1,11 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | 2 | ||
| 3 | pub use defmt::*; | 3 | pub use defmt::*; |
| 4 | use embassy_stm32::Config; | ||
| 4 | #[allow(unused)] | 5 | #[allow(unused)] |
| 5 | use embassy_stm32::rcc::*; | 6 | use embassy_stm32::rcc::*; |
| 6 | #[allow(unused)] | 7 | #[allow(unused)] |
| 7 | use embassy_stm32::time::Hertz; | 8 | use embassy_stm32::time::Hertz; |
| 8 | use embassy_stm32::Config; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | #[cfg(feature = "stm32f103c8")] | 11 | #[cfg(feature = "stm32f103c8")] |
diff --git a/tests/utils/Cargo.toml b/tests/utils/Cargo.toml index ddb990e0f..da04a1f5d 100644 --- a/tests/utils/Cargo.toml +++ b/tests/utils/Cargo.toml | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "test-utils" | 2 | name = "test-utils" |
| 3 | version = "0.1.0" | 3 | version = "0.1.0" |
| 4 | edition = "2021" | 4 | edition = "2024" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | publish = false | 6 | publish = false |
| 7 | 7 | ||
diff --git a/tests/utils/src/bin/saturate_serial.rs b/tests/utils/src/bin/saturate_serial.rs index 85676b106..1c8a8b322 100644 --- a/tests/utils/src/bin/saturate_serial.rs +++ b/tests/utils/src/bin/saturate_serial.rs | |||
| @@ -2,7 +2,7 @@ use std::path::Path; | |||
| 2 | use std::time::Duration; | 2 | use std::time::Duration; |
| 3 | use std::{env, io, process, thread}; | 3 | use std::{env, io, process, thread}; |
| 4 | 4 | ||
| 5 | use rand::{rng, Rng}; | 5 | use rand::{Rng, rng}; |
| 6 | use serial::SerialPort; | 6 | use serial::SerialPort; |
| 7 | 7 | ||
| 8 | pub fn main() { | 8 | pub fn main() { |
