diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-05-31 21:59:06 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-05-31 21:59:06 +0200 |
| commit | 7baa14371b3ee97b7008e2613489b07942d32582 (patch) | |
| tree | 84e68b0dd10e431e90e8085855e4522376673e0b | |
| parent | ba940017ee8cabbb2a371243adc040b3460cd71c (diff) | |
| parent | f594ddceecbf00022f1b76bec030fd32c0e03178 (diff) | |
Merge pull request #3027 from embassy-rs/check-cfg-fix
Fix all check-cfg errors, fix stm32 spi rxonly.
42 files changed, 116 insertions, 98 deletions
diff --git a/embassy-boot-nrf/Cargo.toml b/embassy-boot-nrf/Cargo.toml index e6bb27043..86bfc21f4 100644 --- a/embassy-boot-nrf/Cargo.toml +++ b/embassy-boot-nrf/Cargo.toml | |||
| @@ -22,6 +22,7 @@ target = "thumbv7em-none-eabi" | |||
| 22 | 22 | ||
| 23 | [dependencies] | 23 | [dependencies] |
| 24 | defmt = { version = "0.3", optional = true } | 24 | defmt = { version = "0.3", optional = true } |
| 25 | log = { version = "0.4.17", optional = true } | ||
| 25 | 26 | ||
| 26 | embassy-sync = { version = "0.6.0", path = "../embassy-sync" } | 27 | embassy-sync = { version = "0.6.0", path = "../embassy-sync" } |
| 27 | embassy-nrf = { version = "0.1.0", path = "../embassy-nrf", default-features = false } | 28 | embassy-nrf = { version = "0.1.0", path = "../embassy-nrf", default-features = false } |
diff --git a/embassy-boot-rp/Cargo.toml b/embassy-boot-rp/Cargo.toml index 0bd8abf4c..de2ae3780 100644 --- a/embassy-boot-rp/Cargo.toml +++ b/embassy-boot-rp/Cargo.toml | |||
| @@ -21,7 +21,6 @@ target = "thumbv6m-none-eabi" | |||
| 21 | 21 | ||
| 22 | [dependencies] | 22 | [dependencies] |
| 23 | defmt = { version = "0.3", optional = true } | 23 | defmt = { version = "0.3", optional = true } |
| 24 | defmt-rtt = { version = "0.4", optional = true } | ||
| 25 | log = { version = "0.4", optional = true } | 24 | log = { version = "0.4", optional = true } |
| 26 | 25 | ||
| 27 | embassy-sync = { version = "0.6.0", path = "../embassy-sync" } | 26 | embassy-sync = { version = "0.6.0", path = "../embassy-sync" } |
| @@ -46,7 +45,6 @@ log = [ | |||
| 46 | "embassy-boot/log", | 45 | "embassy-boot/log", |
| 47 | "embassy-rp/log", | 46 | "embassy-rp/log", |
| 48 | ] | 47 | ] |
| 49 | debug = ["defmt-rtt"] | ||
| 50 | 48 | ||
| 51 | [profile.dev] | 49 | [profile.dev] |
| 52 | debug = 2 | 50 | debug = 2 |
diff --git a/embassy-boot-rp/build.rs b/embassy-boot-rp/build.rs index 2cbc7ef5e..bfaee3503 100644 --- a/embassy-boot-rp/build.rs +++ b/embassy-boot-rp/build.rs | |||
| @@ -5,4 +5,5 @@ fn main() { | |||
| 5 | if target.starts_with("thumbv6m-") { | 5 | if target.starts_with("thumbv6m-") { |
| 6 | println!("cargo:rustc-cfg=armv6m"); | 6 | println!("cargo:rustc-cfg=armv6m"); |
| 7 | } | 7 | } |
| 8 | println!("cargo:rustc-check-cfg=cfg(armv6m)"); | ||
| 8 | } | 9 | } |
diff --git a/embassy-boot-stm32/Cargo.toml b/embassy-boot-stm32/Cargo.toml index a3661f6cb..d4525a6de 100644 --- a/embassy-boot-stm32/Cargo.toml +++ b/embassy-boot-stm32/Cargo.toml | |||
| @@ -22,7 +22,6 @@ target = "thumbv7em-none-eabi" | |||
| 22 | 22 | ||
| 23 | [dependencies] | 23 | [dependencies] |
| 24 | defmt = { version = "0.3", optional = true } | 24 | defmt = { version = "0.3", optional = true } |
| 25 | defmt-rtt = { version = "0.4", optional = true } | ||
| 26 | log = { version = "0.4", optional = true } | 25 | log = { version = "0.4", optional = true } |
| 27 | 26 | ||
| 28 | embassy-sync = { version = "0.6.0", path = "../embassy-sync" } | 27 | embassy-sync = { version = "0.6.0", path = "../embassy-sync" } |
| @@ -37,7 +36,6 @@ cfg-if = "1.0.0" | |||
| 37 | [features] | 36 | [features] |
| 38 | defmt = ["dep:defmt", "embassy-boot/defmt", "embassy-stm32/defmt"] | 37 | defmt = ["dep:defmt", "embassy-boot/defmt", "embassy-stm32/defmt"] |
| 39 | log = ["dep:log", "embassy-boot/log", "embassy-stm32/log"] | 38 | log = ["dep:log", "embassy-boot/log", "embassy-stm32/log"] |
| 40 | debug = ["defmt-rtt"] | ||
| 41 | 39 | ||
| 42 | [profile.dev] | 40 | [profile.dev] |
| 43 | debug = 2 | 41 | debug = 2 |
diff --git a/embassy-boot-stm32/build.rs b/embassy-boot-stm32/build.rs index 2cbc7ef5e..bfaee3503 100644 --- a/embassy-boot-stm32/build.rs +++ b/embassy-boot-stm32/build.rs | |||
| @@ -5,4 +5,5 @@ fn main() { | |||
| 5 | if target.starts_with("thumbv6m-") { | 5 | if target.starts_with("thumbv6m-") { |
| 6 | println!("cargo:rustc-cfg=armv6m"); | 6 | println!("cargo:rustc-cfg=armv6m"); |
| 7 | } | 7 | } |
| 8 | println!("cargo:rustc-check-cfg=cfg(armv6m)"); | ||
| 8 | } | 9 | } |
diff --git a/embassy-net-adin1110/Cargo.toml b/embassy-net-adin1110/Cargo.toml index 97579a467..4a856fac3 100644 --- a/embassy-net-adin1110/Cargo.toml +++ b/embassy-net-adin1110/Cargo.toml | |||
| @@ -29,7 +29,6 @@ critical-section = { version = "1.1.2", features = ["std"] } | |||
| 29 | futures-test = "0.3.28" | 29 | futures-test = "0.3.28" |
| 30 | 30 | ||
| 31 | [features] | 31 | [features] |
| 32 | default = [ ] | ||
| 33 | defmt = [ "dep:defmt", "embedded-hal-1/defmt-03" ] | 32 | defmt = [ "dep:defmt", "embedded-hal-1/defmt-03" ] |
| 34 | log = ["dep:log"] | 33 | log = ["dep:log"] |
| 35 | 34 | ||
diff --git a/embassy-net-adin1110/src/lib.rs b/embassy-net-adin1110/src/lib.rs index d98e98422..7f1c772e2 100644 --- a/embassy-net-adin1110/src/lib.rs +++ b/embassy-net-adin1110/src/lib.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #![cfg_attr(not(test), no_std)] | ||
| 1 | #![deny(clippy::pedantic)] | 2 | #![deny(clippy::pedantic)] |
| 2 | #![allow(async_fn_in_trait)] | 3 | #![allow(async_fn_in_trait)] |
| 3 | #![cfg_attr(not(any(test, feature = "std")), no_std)] | ||
| 4 | #![allow(clippy::module_name_repetitions)] | 4 | #![allow(clippy::module_name_repetitions)] |
| 5 | #![allow(clippy::missing_errors_doc)] | 5 | #![allow(clippy::missing_errors_doc)] |
| 6 | #![allow(clippy::missing_panics_doc)] | 6 | #![allow(clippy::missing_panics_doc)] |
diff --git a/embassy-stm32-wpan/Cargo.toml b/embassy-stm32-wpan/Cargo.toml index 11a0adab2..9c81a71f7 100644 --- a/embassy-stm32-wpan/Cargo.toml +++ b/embassy-stm32-wpan/Cargo.toml | |||
| @@ -28,6 +28,8 @@ embassy-embedded-hal = { version = "0.1.0", path = "../embassy-embedded-hal" } | |||
| 28 | embassy-net-driver = { version = "0.2.0", path = "../embassy-net-driver", optional=true } | 28 | embassy-net-driver = { version = "0.2.0", path = "../embassy-net-driver", optional=true } |
| 29 | 29 | ||
| 30 | defmt = { version = "0.3", optional = true } | 30 | defmt = { version = "0.3", optional = true } |
| 31 | log = { version = "0.4.17", optional = true } | ||
| 32 | |||
| 31 | cortex-m = "0.7.6" | 33 | cortex-m = "0.7.6" |
| 32 | heapless = "0.8" | 34 | heapless = "0.8" |
| 33 | aligned = "0.4.1" | 35 | aligned = "0.4.1" |
diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index af8e3fc30..3729ed8de 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs | |||
| @@ -148,9 +148,10 @@ impl<'d, M: PeriMode> Spi<'d, M> { | |||
| 148 | w.set_ssm(true); | 148 | w.set_ssm(true); |
| 149 | w.set_crcen(false); | 149 | w.set_crcen(false); |
| 150 | w.set_bidimode(vals::Bidimode::UNIDIRECTIONAL); | 150 | w.set_bidimode(vals::Bidimode::UNIDIRECTIONAL); |
| 151 | if mosi.is_none() { | 151 | // we're doing "fake rxonly", by actually writing one |
| 152 | w.set_rxonly(vals::Rxonly::OUTPUTDISABLED); | 152 | // byte to TXDR for each byte we want to receive. if we |
| 153 | } | 153 | // set OUTPUTDISABLED here, this hangs. |
| 154 | w.set_rxonly(vals::Rxonly::FULLDUPLEX); | ||
| 154 | w.set_dff(<u8 as SealedWord>::CONFIG) | 155 | w.set_dff(<u8 as SealedWord>::CONFIG) |
| 155 | }); | 156 | }); |
| 156 | } | 157 | } |
diff --git a/embassy-usb-dfu/Cargo.toml b/embassy-usb-dfu/Cargo.toml index 267e412c0..ca87bcb62 100644 --- a/embassy-usb-dfu/Cargo.toml +++ b/embassy-usb-dfu/Cargo.toml | |||
| @@ -26,9 +26,11 @@ flavors = [ | |||
| 26 | features = ["defmt", "cortex-m", "dfu"] | 26 | features = ["defmt", "cortex-m", "dfu"] |
| 27 | 27 | ||
| 28 | [dependencies] | 28 | [dependencies] |
| 29 | defmt = { version = "0.3.5", optional = true } | ||
| 30 | log = { version = "0.4.17", optional = true } | ||
| 31 | |||
| 29 | bitflags = "2.4.1" | 32 | bitflags = "2.4.1" |
| 30 | cortex-m = { version = "0.7.7", features = ["inline-asm"], optional = true } | 33 | cortex-m = { version = "0.7.7", features = ["inline-asm"], optional = true } |
| 31 | defmt = { version = "0.3.5", optional = true } | ||
| 32 | embassy-boot = { version = "0.2.0", path = "../embassy-boot" } | 34 | embassy-boot = { version = "0.2.0", path = "../embassy-boot" } |
| 33 | embassy-futures = { version = "0.1.1", path = "../embassy-futures" } | 35 | embassy-futures = { version = "0.1.1", path = "../embassy-futures" } |
| 34 | embassy-sync = { version = "0.6.0", path = "../embassy-sync" } | 36 | embassy-sync = { version = "0.6.0", path = "../embassy-sync" } |
diff --git a/examples/boot/application/nrf/Cargo.toml b/examples/boot/application/nrf/Cargo.toml index f0a710335..cf34bb7cf 100644 --- a/examples/boot/application/nrf/Cargo.toml +++ b/examples/boot/application/nrf/Cargo.toml | |||
| @@ -25,3 +25,10 @@ cortex-m-rt = "0.7.0" | |||
| 25 | ed25519-dalek = ["embassy-boot/ed25519-dalek"] | 25 | ed25519-dalek = ["embassy-boot/ed25519-dalek"] |
| 26 | ed25519-salty = ["embassy-boot/ed25519-salty"] | 26 | ed25519-salty = ["embassy-boot/ed25519-salty"] |
| 27 | skip-include = [] | 27 | skip-include = [] |
| 28 | defmt = [ | ||
| 29 | "dep:defmt", | ||
| 30 | "dep:defmt-rtt", | ||
| 31 | "embassy-nrf/defmt", | ||
| 32 | "embassy-boot-nrf/defmt", | ||
| 33 | "embassy-sync/defmt", | ||
| 34 | ] | ||
diff --git a/examples/boot/application/stm32f3/Cargo.toml b/examples/boot/application/stm32f3/Cargo.toml index fe1a6f5b1..9b79b01ce 100644 --- a/examples/boot/application/stm32f3/Cargo.toml +++ b/examples/boot/application/stm32f3/Cargo.toml | |||
| @@ -23,6 +23,7 @@ cortex-m-rt = "0.7.0" | |||
| 23 | [features] | 23 | [features] |
| 24 | defmt = [ | 24 | defmt = [ |
| 25 | "dep:defmt", | 25 | "dep:defmt", |
| 26 | "dep:defmt-rtt", | ||
| 26 | "embassy-stm32/defmt", | 27 | "embassy-stm32/defmt", |
| 27 | "embassy-boot-stm32/defmt", | 28 | "embassy-boot-stm32/defmt", |
| 28 | "embassy-sync/defmt", | 29 | "embassy-sync/defmt", |
diff --git a/examples/boot/application/stm32f3/src/bin/a.rs b/examples/boot/application/stm32f3/src/bin/a.rs index 8858ae3da..b608b2e01 100644 --- a/examples/boot/application/stm32f3/src/bin/a.rs +++ b/examples/boot/application/stm32f3/src/bin/a.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | #[cfg(feature = "defmt-rtt")] | 4 | #[cfg(feature = "defmt")] |
| 5 | use defmt_rtt::*; | 5 | use defmt_rtt::*; |
| 6 | use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig}; | 6 | use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig}; |
| 7 | use embassy_embedded_hal::adapter::BlockingAsync; | 7 | use embassy_embedded_hal::adapter::BlockingAsync; |
diff --git a/examples/boot/application/stm32f3/src/bin/b.rs b/examples/boot/application/stm32f3/src/bin/b.rs index 22ba82d5e..b1a505631 100644 --- a/examples/boot/application/stm32f3/src/bin/b.rs +++ b/examples/boot/application/stm32f3/src/bin/b.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | #[cfg(feature = "defmt-rtt")] | 4 | #[cfg(feature = "defmt")] |
| 5 | use defmt_rtt::*; | 5 | use defmt_rtt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
diff --git a/examples/boot/application/stm32f7/Cargo.toml b/examples/boot/application/stm32f7/Cargo.toml index 37e362824..0167dfb76 100644 --- a/examples/boot/application/stm32f7/Cargo.toml +++ b/examples/boot/application/stm32f7/Cargo.toml | |||
| @@ -24,6 +24,7 @@ cortex-m-rt = "0.7.0" | |||
| 24 | [features] | 24 | [features] |
| 25 | defmt = [ | 25 | defmt = [ |
| 26 | "dep:defmt", | 26 | "dep:defmt", |
| 27 | "dep:defmt-rtt", | ||
| 27 | "embassy-stm32/defmt", | 28 | "embassy-stm32/defmt", |
| 28 | "embassy-boot-stm32/defmt", | 29 | "embassy-boot-stm32/defmt", |
| 29 | "embassy-sync/defmt", | 30 | "embassy-sync/defmt", |
diff --git a/examples/boot/application/stm32f7/src/bin/a.rs b/examples/boot/application/stm32f7/src/bin/a.rs index d3df11fe4..172b4c235 100644 --- a/examples/boot/application/stm32f7/src/bin/a.rs +++ b/examples/boot/application/stm32f7/src/bin/a.rs | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | use core::cell::RefCell; | 4 | use core::cell::RefCell; |
| 5 | 5 | ||
| 6 | #[cfg(feature = "defmt-rtt")] | 6 | #[cfg(feature = "defmt")] |
| 7 | use defmt_rtt::*; | 7 | use defmt_rtt::*; |
| 8 | use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdaterConfig}; | 8 | use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdaterConfig}; |
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
diff --git a/examples/boot/application/stm32f7/src/bin/b.rs b/examples/boot/application/stm32f7/src/bin/b.rs index 190477204..6bc9c9ab8 100644 --- a/examples/boot/application/stm32f7/src/bin/b.rs +++ b/examples/boot/application/stm32f7/src/bin/b.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | #[cfg(feature = "defmt-rtt")] | 4 | #[cfg(feature = "defmt")] |
| 5 | use defmt_rtt::*; | 5 | use defmt_rtt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
diff --git a/examples/boot/application/stm32h7/Cargo.toml b/examples/boot/application/stm32h7/Cargo.toml index 52cd0b546..61643d485 100644 --- a/examples/boot/application/stm32h7/Cargo.toml +++ b/examples/boot/application/stm32h7/Cargo.toml | |||
| @@ -24,6 +24,7 @@ cortex-m-rt = "0.7.0" | |||
| 24 | [features] | 24 | [features] |
| 25 | defmt = [ | 25 | defmt = [ |
| 26 | "dep:defmt", | 26 | "dep:defmt", |
| 27 | "dep:defmt-rtt", | ||
| 27 | "embassy-stm32/defmt", | 28 | "embassy-stm32/defmt", |
| 28 | "embassy-boot-stm32/defmt", | 29 | "embassy-boot-stm32/defmt", |
| 29 | "embassy-sync/defmt", | 30 | "embassy-sync/defmt", |
diff --git a/examples/boot/application/stm32h7/src/bin/a.rs b/examples/boot/application/stm32h7/src/bin/a.rs index f61ac1f71..c1b1a267a 100644 --- a/examples/boot/application/stm32h7/src/bin/a.rs +++ b/examples/boot/application/stm32h7/src/bin/a.rs | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | use core::cell::RefCell; | 4 | use core::cell::RefCell; |
| 5 | 5 | ||
| 6 | #[cfg(feature = "defmt-rtt")] | 6 | #[cfg(feature = "defmt")] |
| 7 | use defmt_rtt::*; | 7 | use defmt_rtt::*; |
| 8 | use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdaterConfig}; | 8 | use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdaterConfig}; |
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
diff --git a/examples/boot/application/stm32h7/src/bin/b.rs b/examples/boot/application/stm32h7/src/bin/b.rs index 5f3f35207..13bdae1f1 100644 --- a/examples/boot/application/stm32h7/src/bin/b.rs +++ b/examples/boot/application/stm32h7/src/bin/b.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | #[cfg(feature = "defmt-rtt")] | 4 | #[cfg(feature = "defmt")] |
| 5 | use defmt_rtt::*; | 5 | use defmt_rtt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
diff --git a/examples/boot/application/stm32l0/Cargo.toml b/examples/boot/application/stm32l0/Cargo.toml index 0f3cbe654..2990089ac 100644 --- a/examples/boot/application/stm32l0/Cargo.toml +++ b/examples/boot/application/stm32l0/Cargo.toml | |||
| @@ -23,6 +23,7 @@ cortex-m-rt = "0.7.0" | |||
| 23 | [features] | 23 | [features] |
| 24 | defmt = [ | 24 | defmt = [ |
| 25 | "dep:defmt", | 25 | "dep:defmt", |
| 26 | "dep:defmt-rtt", | ||
| 26 | "embassy-stm32/defmt", | 27 | "embassy-stm32/defmt", |
| 27 | "embassy-boot-stm32/defmt", | 28 | "embassy-boot-stm32/defmt", |
| 28 | "embassy-sync/defmt", | 29 | "embassy-sync/defmt", |
diff --git a/examples/boot/application/stm32l0/src/bin/a.rs b/examples/boot/application/stm32l0/src/bin/a.rs index f066c1139..dcc10e5c6 100644 --- a/examples/boot/application/stm32l0/src/bin/a.rs +++ b/examples/boot/application/stm32l0/src/bin/a.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | #[cfg(feature = "defmt-rtt")] | 4 | #[cfg(feature = "defmt")] |
| 5 | use defmt_rtt::*; | 5 | use defmt_rtt::*; |
| 6 | use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig}; | 6 | use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig}; |
| 7 | use embassy_embedded_hal::adapter::BlockingAsync; | 7 | use embassy_embedded_hal::adapter::BlockingAsync; |
diff --git a/examples/boot/application/stm32l0/src/bin/b.rs b/examples/boot/application/stm32l0/src/bin/b.rs index 6bf00f41a..a59c6f540 100644 --- a/examples/boot/application/stm32l0/src/bin/b.rs +++ b/examples/boot/application/stm32l0/src/bin/b.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | #[cfg(feature = "defmt-rtt")] | 4 | #[cfg(feature = "defmt")] |
| 5 | use defmt_rtt::*; | 5 | use defmt_rtt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
diff --git a/examples/boot/application/stm32l1/Cargo.toml b/examples/boot/application/stm32l1/Cargo.toml index 3e964df9c..c07d71591 100644 --- a/examples/boot/application/stm32l1/Cargo.toml +++ b/examples/boot/application/stm32l1/Cargo.toml | |||
| @@ -23,6 +23,7 @@ cortex-m-rt = "0.7.0" | |||
| 23 | [features] | 23 | [features] |
| 24 | defmt = [ | 24 | defmt = [ |
| 25 | "dep:defmt", | 25 | "dep:defmt", |
| 26 | "dep:defmt-rtt", | ||
| 26 | "embassy-stm32/defmt", | 27 | "embassy-stm32/defmt", |
| 27 | "embassy-boot-stm32/defmt", | 28 | "embassy-boot-stm32/defmt", |
| 28 | "embassy-sync/defmt", | 29 | "embassy-sync/defmt", |
diff --git a/examples/boot/application/stm32l1/src/bin/a.rs b/examples/boot/application/stm32l1/src/bin/a.rs index f066c1139..dcc10e5c6 100644 --- a/examples/boot/application/stm32l1/src/bin/a.rs +++ b/examples/boot/application/stm32l1/src/bin/a.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | #[cfg(feature = "defmt-rtt")] | 4 | #[cfg(feature = "defmt")] |
| 5 | use defmt_rtt::*; | 5 | use defmt_rtt::*; |
| 6 | use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig}; | 6 | use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig}; |
| 7 | use embassy_embedded_hal::adapter::BlockingAsync; | 7 | use embassy_embedded_hal::adapter::BlockingAsync; |
diff --git a/examples/boot/application/stm32l1/src/bin/b.rs b/examples/boot/application/stm32l1/src/bin/b.rs index 6bf00f41a..a59c6f540 100644 --- a/examples/boot/application/stm32l1/src/bin/b.rs +++ b/examples/boot/application/stm32l1/src/bin/b.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | #[cfg(feature = "defmt-rtt")] | 4 | #[cfg(feature = "defmt")] |
| 5 | use defmt_rtt::*; | 5 | use defmt_rtt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
diff --git a/examples/boot/application/stm32l4/Cargo.toml b/examples/boot/application/stm32l4/Cargo.toml index b154403ac..72b937ca7 100644 --- a/examples/boot/application/stm32l4/Cargo.toml +++ b/examples/boot/application/stm32l4/Cargo.toml | |||
| @@ -23,6 +23,7 @@ cortex-m-rt = "0.7.0" | |||
| 23 | [features] | 23 | [features] |
| 24 | defmt = [ | 24 | defmt = [ |
| 25 | "dep:defmt", | 25 | "dep:defmt", |
| 26 | "dep:defmt-rtt", | ||
| 26 | "embassy-stm32/defmt", | 27 | "embassy-stm32/defmt", |
| 27 | "embassy-boot-stm32/defmt", | 28 | "embassy-boot-stm32/defmt", |
| 28 | "embassy-sync/defmt", | 29 | "embassy-sync/defmt", |
diff --git a/examples/boot/application/stm32l4/src/bin/a.rs b/examples/boot/application/stm32l4/src/bin/a.rs index a0079ee33..7f8015c04 100644 --- a/examples/boot/application/stm32l4/src/bin/a.rs +++ b/examples/boot/application/stm32l4/src/bin/a.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | #[cfg(feature = "defmt-rtt")] | 4 | #[cfg(feature = "defmt")] |
| 5 | use defmt_rtt::*; | 5 | use defmt_rtt::*; |
| 6 | use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig}; | 6 | use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig}; |
| 7 | use embassy_embedded_hal::adapter::BlockingAsync; | 7 | use embassy_embedded_hal::adapter::BlockingAsync; |
diff --git a/examples/boot/application/stm32l4/src/bin/b.rs b/examples/boot/application/stm32l4/src/bin/b.rs index 22ba82d5e..b1a505631 100644 --- a/examples/boot/application/stm32l4/src/bin/b.rs +++ b/examples/boot/application/stm32l4/src/bin/b.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | #[cfg(feature = "defmt-rtt")] | 4 | #[cfg(feature = "defmt")] |
| 5 | use defmt_rtt::*; | 5 | use defmt_rtt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
diff --git a/examples/boot/application/stm32wb-dfu/src/main.rs b/examples/boot/application/stm32wb-dfu/src/main.rs index 929d6802c..0ab99ff90 100644 --- a/examples/boot/application/stm32wb-dfu/src/main.rs +++ b/examples/boot/application/stm32wb-dfu/src/main.rs | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | use core::cell::RefCell; | 4 | use core::cell::RefCell; |
| 5 | 5 | ||
| 6 | #[cfg(feature = "defmt-rtt")] | 6 | #[cfg(feature = "defmt")] |
| 7 | use defmt_rtt::*; | 7 | use defmt_rtt::*; |
| 8 | use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareState, FirmwareUpdaterConfig}; | 8 | use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareState, FirmwareUpdaterConfig}; |
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
diff --git a/examples/boot/application/stm32wl/Cargo.toml b/examples/boot/application/stm32wl/Cargo.toml index 93ead617c..a5160b797 100644 --- a/examples/boot/application/stm32wl/Cargo.toml +++ b/examples/boot/application/stm32wl/Cargo.toml | |||
| @@ -23,6 +23,7 @@ cortex-m-rt = "0.7.0" | |||
| 23 | [features] | 23 | [features] |
| 24 | defmt = [ | 24 | defmt = [ |
| 25 | "dep:defmt", | 25 | "dep:defmt", |
| 26 | "dep:defmt-rtt", | ||
| 26 | "embassy-stm32/defmt", | 27 | "embassy-stm32/defmt", |
| 27 | "embassy-boot-stm32/defmt", | 28 | "embassy-boot-stm32/defmt", |
| 28 | "embassy-sync/defmt", | 29 | "embassy-sync/defmt", |
diff --git a/examples/boot/application/stm32wl/src/bin/a.rs b/examples/boot/application/stm32wl/src/bin/a.rs index 2fb16bdc4..9f4f0b238 100644 --- a/examples/boot/application/stm32wl/src/bin/a.rs +++ b/examples/boot/application/stm32wl/src/bin/a.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | #[cfg(feature = "defmt-rtt")] | 4 | #[cfg(feature = "defmt")] |
| 5 | use defmt_rtt::*; | 5 | use defmt_rtt::*; |
| 6 | use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig}; | 6 | use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig}; |
| 7 | use embassy_embedded_hal::adapter::BlockingAsync; | 7 | use embassy_embedded_hal::adapter::BlockingAsync; |
diff --git a/examples/boot/application/stm32wl/src/bin/b.rs b/examples/boot/application/stm32wl/src/bin/b.rs index 8dd15d8cd..e954d8b91 100644 --- a/examples/boot/application/stm32wl/src/bin/b.rs +++ b/examples/boot/application/stm32wl/src/bin/b.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | 3 | ||
| 4 | #[cfg(feature = "defmt-rtt")] | 4 | #[cfg(feature = "defmt")] |
| 5 | use defmt_rtt::*; | 5 | use defmt_rtt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
diff --git a/examples/boot/bootloader/nrf/Cargo.toml b/examples/boot/bootloader/nrf/Cargo.toml index 980149bea..9d5d51a13 100644 --- a/examples/boot/bootloader/nrf/Cargo.toml +++ b/examples/boot/bootloader/nrf/Cargo.toml | |||
| @@ -19,13 +19,13 @@ cfg-if = "1.0.0" | |||
| 19 | [features] | 19 | [features] |
| 20 | defmt = [ | 20 | defmt = [ |
| 21 | "dep:defmt", | 21 | "dep:defmt", |
| 22 | "dep:defmt-rtt", | ||
| 22 | "embassy-boot-nrf/defmt", | 23 | "embassy-boot-nrf/defmt", |
| 23 | "embassy-nrf/defmt", | 24 | "embassy-nrf/defmt", |
| 24 | ] | 25 | ] |
| 25 | softdevice = [ | 26 | softdevice = [ |
| 26 | "embassy-boot-nrf/softdevice", | 27 | "embassy-boot-nrf/softdevice", |
| 27 | ] | 28 | ] |
| 28 | debug = ["defmt-rtt", "defmt"] | ||
| 29 | 29 | ||
| 30 | [profile.dev] | 30 | [profile.dev] |
| 31 | debug = 2 | 31 | debug = 2 |
diff --git a/examples/boot/bootloader/rp/Cargo.toml b/examples/boot/bootloader/rp/Cargo.toml index 7eec3df1b..c15c980ca 100644 --- a/examples/boot/bootloader/rp/Cargo.toml +++ b/examples/boot/bootloader/rp/Cargo.toml | |||
| @@ -23,10 +23,10 @@ cfg-if = "1.0.0" | |||
| 23 | [features] | 23 | [features] |
| 24 | defmt = [ | 24 | defmt = [ |
| 25 | "dep:defmt", | 25 | "dep:defmt", |
| 26 | "dep:defmt-rtt", | ||
| 26 | "embassy-boot-rp/defmt", | 27 | "embassy-boot-rp/defmt", |
| 27 | "embassy-rp/defmt", | 28 | "embassy-rp/defmt", |
| 28 | ] | 29 | ] |
| 29 | debug = ["defmt-rtt", "defmt"] | ||
| 30 | 30 | ||
| 31 | [profile.release] | 31 | [profile.release] |
| 32 | debug = true | 32 | debug = true |
diff --git a/examples/boot/bootloader/stm32-dual-bank/Cargo.toml b/examples/boot/bootloader/stm32-dual-bank/Cargo.toml index 55adf84d7..b91b05412 100644 --- a/examples/boot/bootloader/stm32-dual-bank/Cargo.toml +++ b/examples/boot/bootloader/stm32-dual-bank/Cargo.toml | |||
| @@ -22,8 +22,7 @@ embedded-storage-async = "0.4.0" | |||
| 22 | cfg-if = "1.0.0" | 22 | cfg-if = "1.0.0" |
| 23 | 23 | ||
| 24 | [features] | 24 | [features] |
| 25 | defmt = ["dep:defmt", "embassy-boot-stm32/defmt", "embassy-stm32/defmt"] | 25 | defmt = ["dep:defmt", "dep:defmt-rtt", "embassy-boot-stm32/defmt", "embassy-stm32/defmt"] |
| 26 | debug = ["defmt-rtt", "defmt"] | ||
| 27 | 26 | ||
| 28 | [profile.dev] | 27 | [profile.dev] |
| 29 | debug = 2 | 28 | debug = 2 |
diff --git a/examples/boot/bootloader/stm32/Cargo.toml b/examples/boot/bootloader/stm32/Cargo.toml index ef2b99404..541186949 100644 --- a/examples/boot/bootloader/stm32/Cargo.toml +++ b/examples/boot/bootloader/stm32/Cargo.toml | |||
| @@ -21,10 +21,10 @@ cfg-if = "1.0.0" | |||
| 21 | [features] | 21 | [features] |
| 22 | defmt = [ | 22 | defmt = [ |
| 23 | "dep:defmt", | 23 | "dep:defmt", |
| 24 | "dep:defmt-rtt", | ||
| 24 | "embassy-boot-stm32/defmt", | 25 | "embassy-boot-stm32/defmt", |
| 25 | "embassy-stm32/defmt", | 26 | "embassy-stm32/defmt", |
| 26 | ] | 27 | ] |
| 27 | debug = ["defmt-rtt", "defmt"] | ||
| 28 | 28 | ||
| 29 | [profile.dev] | 29 | [profile.dev] |
| 30 | debug = 2 | 30 | debug = 2 |
diff --git a/examples/boot/bootloader/stm32wb-dfu/Cargo.toml b/examples/boot/bootloader/stm32wb-dfu/Cargo.toml index 93b5d8b34..9950ed7b6 100644 --- a/examples/boot/bootloader/stm32wb-dfu/Cargo.toml +++ b/examples/boot/bootloader/stm32wb-dfu/Cargo.toml | |||
| @@ -24,12 +24,12 @@ embassy-futures = { version = "0.1.1", path = "../../../../embassy-futures" } | |||
| 24 | [features] | 24 | [features] |
| 25 | defmt = [ | 25 | defmt = [ |
| 26 | "dep:defmt", | 26 | "dep:defmt", |
| 27 | "dep:defmt-rtt", | ||
| 27 | "embassy-boot-stm32/defmt", | 28 | "embassy-boot-stm32/defmt", |
| 28 | "embassy-stm32/defmt", | 29 | "embassy-stm32/defmt", |
| 29 | "embassy-usb/defmt", | 30 | "embassy-usb/defmt", |
| 30 | "embassy-usb-dfu/defmt" | 31 | "embassy-usb-dfu/defmt" |
| 31 | ] | 32 | ] |
| 32 | debug = ["defmt-rtt", "defmt"] | ||
| 33 | 33 | ||
| 34 | [profile.dev] | 34 | [profile.dev] |
| 35 | debug = 2 | 35 | debug = 2 |
diff --git a/tests/stm32/build.rs b/tests/stm32/build.rs index 176adff62..675115568 100644 --- a/tests/stm32/build.rs +++ b/tests/stm32/build.rs | |||
| @@ -14,6 +14,7 @@ fn main() -> Result<(), Box<dyn Error>> { | |||
| 14 | feature = "stm32c031c6", | 14 | feature = "stm32c031c6", |
| 15 | feature = "stm32wb55rg", | 15 | feature = "stm32wb55rg", |
| 16 | feature = "stm32l073rz", | 16 | feature = "stm32l073rz", |
| 17 | feature = "stm32h503rb", | ||
| 17 | // wrong ram size in stm32-data | 18 | // wrong ram size in stm32-data |
| 18 | feature = "stm32wl55jc", | 19 | feature = "stm32wl55jc", |
| 19 | feature = "stm32u5a5zj", | 20 | feature = "stm32u5a5zj", |
diff --git a/tests/stm32/src/bin/fdcan.rs b/tests/stm32/src/bin/fdcan.rs index 8534f92e8..8a397f661 100644 --- a/tests/stm32/src/bin/fdcan.rs +++ b/tests/stm32/src/bin/fdcan.rs | |||
| @@ -92,7 +92,7 @@ fn options() -> (Config, TestOptions) { | |||
| 92 | ) | 92 | ) |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | #[cfg(any(feature = "stm32g491re", feature = "stm32g431cb"))] | 95 | #[cfg(any(feature = "stm32g491re"))] |
| 96 | fn options() -> (Config, TestOptions) { | 96 | fn options() -> (Config, TestOptions) { |
| 97 | info!("G4 config"); | 97 | info!("G4 config"); |
| 98 | ( | 98 | ( |
diff --git a/tests/stm32/src/bin/spi.rs b/tests/stm32/src/bin/spi.rs index c1576bfeb..a0ca5284d 100644 --- a/tests/stm32/src/bin/spi.rs +++ b/tests/stm32/src/bin/spi.rs | |||
| @@ -6,6 +6,7 @@ mod common; | |||
| 6 | use common::*; | 6 | use common::*; |
| 7 | use defmt::assert_eq; | 7 | use defmt::assert_eq; |
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | ||
| 9 | use embassy_stm32::spi::{self, Spi}; | 10 | use embassy_stm32::spi::{self, Spi}; |
| 10 | use embassy_stm32::time::Hertz; | 11 | use embassy_stm32::time::Hertz; |
| 11 | 12 | ||
| @@ -14,18 +15,19 @@ async fn main(_spawner: Spawner) { | |||
| 14 | let p = embassy_stm32::init(config()); | 15 | let p = embassy_stm32::init(config()); |
| 15 | info!("Hello World!"); | 16 | info!("Hello World!"); |
| 16 | 17 | ||
| 17 | let spi = peri!(p, SPI); | 18 | let mut spi_peri = peri!(p, SPI); |
| 18 | let sck = peri!(p, SPI_SCK); | 19 | let mut sck = peri!(p, SPI_SCK); |
| 19 | let mosi = peri!(p, SPI_MOSI); | 20 | let mut mosi = peri!(p, SPI_MOSI); |
| 20 | let miso = peri!(p, SPI_MISO); | 21 | let mut miso = peri!(p, SPI_MISO); |
| 21 | 22 | ||
| 22 | let mut spi_config = spi::Config::default(); | 23 | let mut spi_config = spi::Config::default(); |
| 23 | spi_config.frequency = Hertz(1_000_000); | 24 | spi_config.frequency = Hertz(1_000_000); |
| 24 | 25 | ||
| 25 | let mut spi = Spi::new_blocking( | 26 | let mut spi = Spi::new_blocking( |
| 26 | spi, sck, // Arduino D13 | 27 | &mut spi_peri, |
| 27 | mosi, // Arduino D11 | 28 | &mut sck, // Arduino D13 |
| 28 | miso, // Arduino D12 | 29 | &mut mosi, // Arduino D11 |
| 30 | &mut miso, // Arduino D12 | ||
| 29 | spi_config, | 31 | spi_config, |
| 30 | ); | 32 | ); |
| 31 | 33 | ||
| @@ -66,6 +68,22 @@ async fn main(_spawner: Spawner) { | |||
| 66 | defmt::assert!(!embassy_stm32::pac::RCC.apb2enr().read().spi1en()); | 68 | defmt::assert!(!embassy_stm32::pac::RCC.apb2enr().read().spi1en()); |
| 67 | } | 69 | } |
| 68 | 70 | ||
| 71 | #[cfg(not(feature = "stm32f429zi"))] | ||
| 72 | core::mem::drop(spi); | ||
| 73 | |||
| 74 | // test rx-only configuration | ||
| 75 | let mut spi = Spi::new_blocking_rxonly(&mut spi_peri, &mut sck, &mut miso, spi_config); | ||
| 76 | |||
| 77 | let mut mosi = Output::new(&mut mosi, Level::Low, Speed::VeryHigh); | ||
| 78 | |||
| 79 | mosi.set_high(); | ||
| 80 | spi.blocking_read(&mut buf).unwrap(); | ||
| 81 | assert_eq!(buf, [0xff; 9]); | ||
| 82 | |||
| 83 | mosi.set_low(); | ||
| 84 | spi.blocking_read(&mut buf).unwrap(); | ||
| 85 | assert_eq!(buf, [0x00; 9]); | ||
| 86 | |||
| 69 | info!("Test OK"); | 87 | info!("Test OK"); |
| 70 | cortex_m::asm::bkpt(); | 88 | cortex_m::asm::bkpt(); |
| 71 | } | 89 | } |
diff --git a/tests/stm32/src/bin/spi_dma.rs b/tests/stm32/src/bin/spi_dma.rs index 30e679f2a..92f741af5 100644 --- a/tests/stm32/src/bin/spi_dma.rs +++ b/tests/stm32/src/bin/spi_dma.rs | |||
| @@ -6,34 +6,32 @@ mod common; | |||
| 6 | use common::*; | 6 | use common::*; |
| 7 | use defmt::assert_eq; | 7 | use defmt::assert_eq; |
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | ||
| 9 | use embassy_stm32::spi::{self, Spi}; | 10 | use embassy_stm32::spi::{self, Spi}; |
| 10 | use embassy_stm32::time::Hertz; | 11 | use embassy_stm32::time::Hertz; |
| 11 | use embassy_stm32::{into_ref, Peripheral as _}; | ||
| 12 | 12 | ||
| 13 | #[embassy_executor::main] | 13 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner) { | 14 | async fn main(_spawner: Spawner) { |
| 15 | let p = embassy_stm32::init(config()); | 15 | let p = embassy_stm32::init(config()); |
| 16 | info!("Hello World!"); | 16 | info!("Hello World!"); |
| 17 | 17 | ||
| 18 | let spi_peri = peri!(p, SPI); | 18 | let mut spi_peri = peri!(p, SPI); |
| 19 | let sck = peri!(p, SPI_SCK); | 19 | let mut sck = peri!(p, SPI_SCK); |
| 20 | let mosi = peri!(p, SPI_MOSI); | 20 | let mut mosi = peri!(p, SPI_MOSI); |
| 21 | let miso = peri!(p, SPI_MISO); | 21 | let mut miso = peri!(p, SPI_MISO); |
| 22 | let tx_dma = peri!(p, SPI_TX_DMA); | 22 | let mut tx_dma = peri!(p, SPI_TX_DMA); |
| 23 | let rx_dma = peri!(p, SPI_RX_DMA); | 23 | let mut rx_dma = peri!(p, SPI_RX_DMA); |
| 24 | |||
| 25 | into_ref!(spi_peri, sck, mosi, miso, tx_dma, rx_dma); | ||
| 26 | 24 | ||
| 27 | let mut spi_config = spi::Config::default(); | 25 | let mut spi_config = spi::Config::default(); |
| 28 | spi_config.frequency = Hertz(1_000_000); | 26 | spi_config.frequency = Hertz(1_000_000); |
| 29 | 27 | ||
| 30 | let mut spi = Spi::new( | 28 | let mut spi = Spi::new( |
| 31 | spi_peri.reborrow(), | 29 | &mut spi_peri, |
| 32 | sck.reborrow(), // Arduino D13 | 30 | &mut sck, // Arduino D13 |
| 33 | mosi.reborrow(), // Arduino D11 | 31 | &mut mosi, // Arduino D11 |
| 34 | miso.reborrow(), // Arduino D12 | 32 | &mut miso, // Arduino D12 |
| 35 | tx_dma.reborrow(), | 33 | &mut tx_dma, |
| 36 | rx_dma.reborrow(), | 34 | &mut rx_dma, |
| 37 | spi_config, | 35 | spi_config, |
| 38 | ); | 36 | ); |
| 39 | 37 | ||
| @@ -85,51 +83,36 @@ async fn main(_spawner: Spawner) { | |||
| 85 | core::mem::drop(spi); | 83 | core::mem::drop(spi); |
| 86 | 84 | ||
| 87 | // test rx-only configuration | 85 | // test rx-only configuration |
| 86 | let mut spi = Spi::new_rxonly( | ||
| 87 | &mut spi_peri, | ||
| 88 | &mut sck, | ||
| 89 | &mut miso, | ||
| 90 | // SPIv1/f1 requires txdma even if rxonly. | ||
| 91 | #[cfg(not(any( | ||
| 92 | feature = "stm32h503rb", | ||
| 93 | feature = "stm32h563zi", | ||
| 94 | feature = "stm32h753zi", | ||
| 95 | feature = "stm32h755zi", | ||
| 96 | feature = "stm32h7a3zi", | ||
| 97 | feature = "stm32h7s3l8", | ||
| 98 | feature = "stm32u585ai", | ||
| 99 | feature = "stm32u5a5zj", | ||
| 100 | feature = "stm32wba52cg", | ||
| 101 | )))] | ||
| 102 | &mut tx_dma, | ||
| 103 | &mut rx_dma, | ||
| 104 | spi_config, | ||
| 105 | ); | ||
| 106 | |||
| 107 | let mut mosi = Output::new(&mut mosi, Level::Low, Speed::VeryHigh); | ||
| 88 | 108 | ||
| 89 | // stm32f207zg - spi_v1 | 109 | mosi.set_high(); |
| 90 | // stm32f103c8 - spi_f1 | 110 | spi.read(&mut buf).await.unwrap(); |
| 91 | // stm32g491re - spi_v2 | 111 | assert_eq!(buf, [0xff; 9]); |
| 92 | // stm32h753zi - spi_v3 | 112 | |
| 93 | // stm32h563zi - spi_v4 | 113 | mosi.set_low(); |
| 94 | // stm32wba52cg - spi_v5 | 114 | spi.read(&mut buf).await.unwrap(); |
| 95 | 115 | assert_eq!(buf, [0x00; 9]); | |
| 96 | #[cfg(any(stm32f207zg, stm32f103c8, stm32g491re, stm32h753zi, stm32h563zi, stm32wba52cg))] | ||
| 97 | { | ||
| 98 | let mut spi = { | ||
| 99 | #[cfg(stm32f207zg, stm32f103c8, stm32g491re)] | ||
| 100 | { | ||
| 101 | Spi::new_rxonly( | ||
| 102 | spi_peri.reborrow(), | ||
| 103 | sck.reborrow(), | ||
| 104 | miso.reborrow(), | ||
| 105 | tx_dma.reborrow(), | ||
| 106 | rx_dma.reborrow(), | ||
| 107 | spi_config, | ||
| 108 | ) | ||
| 109 | } | ||
| 110 | #[cfg(stm32h753zi, stm32h563zi, stm32wba52cg)] | ||
| 111 | { | ||
| 112 | Spi::new_rxonly( | ||
| 113 | spi_peri.reborrow(), | ||
| 114 | sck.reborrow(), | ||
| 115 | miso.reborrow(), | ||
| 116 | rx_dma.reborrow(), | ||
| 117 | spi_config, | ||
| 118 | ) | ||
| 119 | } | ||
| 120 | }; | ||
| 121 | |||
| 122 | use embassy_stm32::gpio; | ||
| 123 | let mut mosi = gpio::Output::new(mosi.reborrow(), gpio::Level::Low, gpio::Speed::Low); | ||
| 124 | |||
| 125 | mosi.set_high(); | ||
| 126 | spi.read(&mut buf).await.unwrap(); | ||
| 127 | assert_eq!(buf, [0xff; 9]); | ||
| 128 | |||
| 129 | mosi.set_low(); | ||
| 130 | spi.read(&mut buf).await.unwrap(); | ||
| 131 | assert_eq!(buf, [0x00; 9]); | ||
| 132 | }; | ||
| 133 | 116 | ||
| 134 | info!("Test OK"); | 117 | info!("Test OK"); |
| 135 | cortex_m::asm::bkpt(); | 118 | cortex_m::asm::bkpt(); |
