diff options
| author | Mathias <[email protected]> | 2022-10-24 12:14:26 +0200 |
|---|---|---|
| committer | Mathias <[email protected]> | 2022-10-24 12:14:26 +0200 |
| commit | 8d809c96ecf2fabf77f0fb72f2a59acd18306bf2 (patch) | |
| tree | da3e28e491bbaadbc448b9a021291e2164b7531e /examples | |
| parent | 7152031229da19005e5b0d52c8c72d359d3e0daa (diff) | |
| parent | ce1cba761c2942b7faa27f4098487c6468784729 (diff) | |
Merge branch 'master' of https://github.com/embassy-rs/embassy into embassy-rp/flash
Diffstat (limited to 'examples')
54 files changed, 500 insertions, 33 deletions
diff --git a/examples/boot/application/nrf/Cargo.toml b/examples/boot/application/nrf/Cargo.toml index b9ff92578..a5d82b601 100644 --- a/examples/boot/application/nrf/Cargo.toml +++ b/examples/boot/application/nrf/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [dependencies] | 7 | [dependencies] |
| 7 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync" } | 8 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync" } |
diff --git a/examples/boot/application/stm32f3/Cargo.toml b/examples/boot/application/stm32f3/Cargo.toml index ce1e6fe4a..3a1843562 100644 --- a/examples/boot/application/stm32f3/Cargo.toml +++ b/examples/boot/application/stm32f3/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [dependencies] | 7 | [dependencies] |
| 7 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } |
diff --git a/examples/boot/application/stm32f3/src/bin/a.rs b/examples/boot/application/stm32f3/src/bin/a.rs index fdbd5ab99..d92d59b29 100644 --- a/examples/boot/application/stm32f3/src/bin/a.rs +++ b/examples/boot/application/stm32f3/src/bin/a.rs | |||
| @@ -17,7 +17,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin"); | |||
| 17 | #[embassy_executor::main] | 17 | #[embassy_executor::main] |
| 18 | async fn main(_spawner: Spawner) { | 18 | async fn main(_spawner: Spawner) { |
| 19 | let p = embassy_stm32::init(Default::default()); | 19 | let p = embassy_stm32::init(Default::default()); |
| 20 | let flash = Flash::unlock(p.FLASH); | 20 | let flash = Flash::new(p.FLASH); |
| 21 | let mut flash = BlockingAsync::new(flash); | 21 | let mut flash = BlockingAsync::new(flash); |
| 22 | 22 | ||
| 23 | let button = Input::new(p.PC13, Pull::Up); | 23 | let button = Input::new(p.PC13, Pull::Up); |
diff --git a/examples/boot/application/stm32f7/Cargo.toml b/examples/boot/application/stm32f7/Cargo.toml index 2fc7ae834..8d9c4490e 100644 --- a/examples/boot/application/stm32f7/Cargo.toml +++ b/examples/boot/application/stm32f7/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [dependencies] | 7 | [dependencies] |
| 7 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } |
diff --git a/examples/boot/application/stm32f7/src/bin/a.rs b/examples/boot/application/stm32f7/src/bin/a.rs index 77b897b0f..79ab80e09 100644 --- a/examples/boot/application/stm32f7/src/bin/a.rs +++ b/examples/boot/application/stm32f7/src/bin/a.rs | |||
| @@ -16,7 +16,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin"); | |||
| 16 | #[embassy_executor::main] | 16 | #[embassy_executor::main] |
| 17 | async fn main(_spawner: Spawner) { | 17 | async fn main(_spawner: Spawner) { |
| 18 | let p = embassy_stm32::init(Default::default()); | 18 | let p = embassy_stm32::init(Default::default()); |
| 19 | let mut flash = Flash::unlock(p.FLASH); | 19 | let mut flash = Flash::new(p.FLASH); |
| 20 | 20 | ||
| 21 | let button = Input::new(p.PC13, Pull::Down); | 21 | let button = Input::new(p.PC13, Pull::Down); |
| 22 | let mut button = ExtiInput::new(button, p.EXTI13); | 22 | let mut button = ExtiInput::new(button, p.EXTI13); |
diff --git a/examples/boot/application/stm32h7/Cargo.toml b/examples/boot/application/stm32h7/Cargo.toml index fd809714a..b4314aa72 100644 --- a/examples/boot/application/stm32h7/Cargo.toml +++ b/examples/boot/application/stm32h7/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [dependencies] | 7 | [dependencies] |
| 7 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync" } | 8 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync" } |
diff --git a/examples/boot/application/stm32h7/src/bin/a.rs b/examples/boot/application/stm32h7/src/bin/a.rs index 0fe598a5d..8b452be34 100644 --- a/examples/boot/application/stm32h7/src/bin/a.rs +++ b/examples/boot/application/stm32h7/src/bin/a.rs | |||
| @@ -16,7 +16,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin"); | |||
| 16 | #[embassy_executor::main] | 16 | #[embassy_executor::main] |
| 17 | async fn main(_spawner: Spawner) { | 17 | async fn main(_spawner: Spawner) { |
| 18 | let p = embassy_stm32::init(Default::default()); | 18 | let p = embassy_stm32::init(Default::default()); |
| 19 | let mut flash = Flash::unlock(p.FLASH); | 19 | let mut flash = Flash::new(p.FLASH); |
| 20 | 20 | ||
| 21 | let button = Input::new(p.PC13, Pull::Down); | 21 | let button = Input::new(p.PC13, Pull::Down); |
| 22 | let mut button = ExtiInput::new(button, p.EXTI13); | 22 | let mut button = ExtiInput::new(button, p.EXTI13); |
diff --git a/examples/boot/application/stm32l0/Cargo.toml b/examples/boot/application/stm32l0/Cargo.toml index 470eca52a..a17d336a6 100644 --- a/examples/boot/application/stm32l0/Cargo.toml +++ b/examples/boot/application/stm32l0/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [dependencies] | 7 | [dependencies] |
| 7 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } |
diff --git a/examples/boot/application/stm32l0/src/bin/a.rs b/examples/boot/application/stm32l0/src/bin/a.rs index f0b0b80e3..59ca34386 100644 --- a/examples/boot/application/stm32l0/src/bin/a.rs +++ b/examples/boot/application/stm32l0/src/bin/a.rs | |||
| @@ -18,7 +18,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin"); | |||
| 18 | #[embassy_executor::main] | 18 | #[embassy_executor::main] |
| 19 | async fn main(_spawner: Spawner) { | 19 | async fn main(_spawner: Spawner) { |
| 20 | let p = embassy_stm32::init(Default::default()); | 20 | let p = embassy_stm32::init(Default::default()); |
| 21 | let flash = Flash::unlock(p.FLASH); | 21 | let flash = Flash::new(p.FLASH); |
| 22 | let mut flash = BlockingAsync::new(flash); | 22 | let mut flash = BlockingAsync::new(flash); |
| 23 | 23 | ||
| 24 | let button = Input::new(p.PB2, Pull::Up); | 24 | let button = Input::new(p.PB2, Pull::Up); |
diff --git a/examples/boot/application/stm32l1/Cargo.toml b/examples/boot/application/stm32l1/Cargo.toml index 2b4b29357..683f2c860 100644 --- a/examples/boot/application/stm32l1/Cargo.toml +++ b/examples/boot/application/stm32l1/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [dependencies] | 7 | [dependencies] |
| 7 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } |
diff --git a/examples/boot/application/stm32l1/src/bin/a.rs b/examples/boot/application/stm32l1/src/bin/a.rs index f0b0b80e3..59ca34386 100644 --- a/examples/boot/application/stm32l1/src/bin/a.rs +++ b/examples/boot/application/stm32l1/src/bin/a.rs | |||
| @@ -18,7 +18,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin"); | |||
| 18 | #[embassy_executor::main] | 18 | #[embassy_executor::main] |
| 19 | async fn main(_spawner: Spawner) { | 19 | async fn main(_spawner: Spawner) { |
| 20 | let p = embassy_stm32::init(Default::default()); | 20 | let p = embassy_stm32::init(Default::default()); |
| 21 | let flash = Flash::unlock(p.FLASH); | 21 | let flash = Flash::new(p.FLASH); |
| 22 | let mut flash = BlockingAsync::new(flash); | 22 | let mut flash = BlockingAsync::new(flash); |
| 23 | 23 | ||
| 24 | let button = Input::new(p.PB2, Pull::Up); | 24 | let button = Input::new(p.PB2, Pull::Up); |
diff --git a/examples/boot/application/stm32l4/Cargo.toml b/examples/boot/application/stm32l4/Cargo.toml index 40bddd194..b879c0d76 100644 --- a/examples/boot/application/stm32l4/Cargo.toml +++ b/examples/boot/application/stm32l4/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [dependencies] | 7 | [dependencies] |
| 7 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } |
diff --git a/examples/boot/application/stm32l4/src/bin/a.rs b/examples/boot/application/stm32l4/src/bin/a.rs index 5119bad2e..6cddc6cc8 100644 --- a/examples/boot/application/stm32l4/src/bin/a.rs +++ b/examples/boot/application/stm32l4/src/bin/a.rs | |||
| @@ -17,7 +17,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin"); | |||
| 17 | #[embassy_executor::main] | 17 | #[embassy_executor::main] |
| 18 | async fn main(_spawner: Spawner) { | 18 | async fn main(_spawner: Spawner) { |
| 19 | let p = embassy_stm32::init(Default::default()); | 19 | let p = embassy_stm32::init(Default::default()); |
| 20 | let flash = Flash::unlock(p.FLASH); | 20 | let flash = Flash::new(p.FLASH); |
| 21 | let mut flash = BlockingAsync::new(flash); | 21 | let mut flash = BlockingAsync::new(flash); |
| 22 | 22 | ||
| 23 | let button = Input::new(p.PC13, Pull::Up); | 23 | let button = Input::new(p.PC13, Pull::Up); |
diff --git a/examples/boot/application/stm32wl/Cargo.toml b/examples/boot/application/stm32wl/Cargo.toml index 5b4a61e8f..e3bc0e49c 100644 --- a/examples/boot/application/stm32wl/Cargo.toml +++ b/examples/boot/application/stm32wl/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [dependencies] | 7 | [dependencies] |
| 7 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] } |
diff --git a/examples/boot/application/stm32wl/src/bin/a.rs b/examples/boot/application/stm32wl/src/bin/a.rs index faa650778..1ff47eddd 100644 --- a/examples/boot/application/stm32wl/src/bin/a.rs +++ b/examples/boot/application/stm32wl/src/bin/a.rs | |||
| @@ -17,7 +17,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin"); | |||
| 17 | #[embassy_executor::main] | 17 | #[embassy_executor::main] |
| 18 | async fn main(_spawner: Spawner) { | 18 | async fn main(_spawner: Spawner) { |
| 19 | let p = embassy_stm32::init(Default::default()); | 19 | let p = embassy_stm32::init(Default::default()); |
| 20 | let flash = Flash::unlock(p.FLASH); | 20 | let flash = Flash::new(p.FLASH); |
| 21 | let mut flash = BlockingAsync::new(flash); | 21 | let mut flash = BlockingAsync::new(flash); |
| 22 | 22 | ||
| 23 | let button = Input::new(p.PA0, Pull::Up); | 23 | let button = Input::new(p.PA0, Pull::Up); |
diff --git a/examples/boot/bootloader/nrf/Cargo.toml b/examples/boot/bootloader/nrf/Cargo.toml index aa2a13ecb..b417a40d1 100644 --- a/examples/boot/bootloader/nrf/Cargo.toml +++ b/examples/boot/bootloader/nrf/Cargo.toml | |||
| @@ -3,6 +3,7 @@ edition = "2021" | |||
| 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" |
| 6 | license = "MIT OR Apache-2.0" | ||
| 6 | 7 | ||
| 7 | [dependencies] | 8 | [dependencies] |
| 8 | defmt = { version = "0.3", optional = true } | 9 | defmt = { version = "0.3", optional = true } |
diff --git a/examples/boot/bootloader/stm32/Cargo.toml b/examples/boot/bootloader/stm32/Cargo.toml index 491777103..4ddd1c99c 100644 --- a/examples/boot/bootloader/stm32/Cargo.toml +++ b/examples/boot/bootloader/stm32/Cargo.toml | |||
| @@ -3,6 +3,7 @@ edition = "2021" | |||
| 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" |
| 6 | license = "MIT OR Apache-2.0" | ||
| 6 | 7 | ||
| 7 | [dependencies] | 8 | [dependencies] |
| 8 | defmt = { version = "0.3", optional = true } | 9 | defmt = { version = "0.3", optional = true } |
diff --git a/examples/boot/bootloader/stm32/src/main.rs b/examples/boot/bootloader/stm32/src/main.rs index 294464d1c..4b17cd799 100644 --- a/examples/boot/bootloader/stm32/src/main.rs +++ b/examples/boot/bootloader/stm32/src/main.rs | |||
| @@ -20,7 +20,7 @@ fn main() -> ! { | |||
| 20 | */ | 20 | */ |
| 21 | 21 | ||
| 22 | let mut bl: BootLoader<ERASE_SIZE, WRITE_SIZE> = BootLoader::default(); | 22 | let mut bl: BootLoader<ERASE_SIZE, WRITE_SIZE> = BootLoader::default(); |
| 23 | let flash = Flash::unlock(p.FLASH); | 23 | let flash = Flash::new(p.FLASH); |
| 24 | let mut flash = BootFlash::<_, ERASE_SIZE, ERASE_VALUE>::new(flash); | 24 | let mut flash = BootFlash::<_, ERASE_SIZE, ERASE_VALUE>::new(flash); |
| 25 | let start = bl.prepare(&mut SingleFlashConfig::new(&mut flash)); | 25 | let start = bl.prepare(&mut SingleFlashConfig::new(&mut flash)); |
| 26 | core::mem::drop(flash); | 26 | core::mem::drop(flash); |
diff --git a/examples/nrf-rtos-trace/Cargo.toml b/examples/nrf-rtos-trace/Cargo.toml index 87c9f33f5..d8c24dfad 100644 --- a/examples/nrf-rtos-trace/Cargo.toml +++ b/examples/nrf-rtos-trace/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [features] | 7 | [features] |
| 7 | default = ["log", "nightly"] | 8 | default = ["log", "nightly"] |
diff --git a/examples/nrf/Cargo.toml b/examples/nrf/Cargo.toml index a5d340c69..6949042e2 100644 --- a/examples/nrf/Cargo.toml +++ b/examples/nrf/Cargo.toml | |||
| @@ -2,10 +2,12 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [features] | 7 | [features] |
| 7 | default = ["nightly"] | 8 | default = ["nightly"] |
| 8 | nightly = ["embassy-executor/nightly", "embassy-nrf/nightly", "embassy-net/nightly", "embassy-nrf/unstable-traits", "embassy-usb", "embedded-io/async", "embassy-net"] | 9 | nightly = ["embassy-executor/nightly", "embassy-nrf/nightly", "embassy-net/nightly", "embassy-nrf/unstable-traits", "embassy-usb", "embedded-io/async", "embassy-net", |
| 10 | "embassy-lora", "lorawan-device", "lorawan"] | ||
| 9 | 11 | ||
| 10 | [dependencies] | 12 | [dependencies] |
| 11 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | 13 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } |
| @@ -16,6 +18,10 @@ embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defm | |||
| 16 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16"], optional = true } | 18 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16"], optional = true } |
| 17 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"], optional = true } | 19 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"], optional = true } |
| 18 | embedded-io = "0.3.0" | 20 | embedded-io = "0.3.0" |
| 21 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["sx126x", "time", "defmt"], optional = true } | ||
| 22 | |||
| 23 | lorawan-device = { version = "0.8.0", default-features = false, features = ["async"], optional = true } | ||
| 24 | lorawan = { version = "0.7.1", default-features = false, features = ["default-crypto"], optional = true } | ||
| 19 | 25 | ||
| 20 | defmt = "0.3" | 26 | defmt = "0.3" |
| 21 | defmt-rtt = "0.3" | 27 | defmt-rtt = "0.3" |
diff --git a/examples/nrf/src/bin/lora_p2p_report.rs b/examples/nrf/src/bin/lora_p2p_report.rs new file mode 100644 index 000000000..d512b83f6 --- /dev/null +++ b/examples/nrf/src/bin/lora_p2p_report.rs | |||
| @@ -0,0 +1,78 @@ | |||
| 1 | //! This example runs on the RAK4631 WisBlock, which has an nRF52840 MCU and Semtech Sx126x radio. | ||
| 2 | //! Other nrf/sx126x combinations may work with appropriate pin modifications. | ||
| 3 | //! It demonstates LORA P2P functionality in conjunction with example lora_p2p_sense.rs. | ||
| 4 | #![no_std] | ||
| 5 | #![no_main] | ||
| 6 | #![macro_use] | ||
| 7 | #![allow(dead_code)] | ||
| 8 | #![feature(type_alias_impl_trait)] | ||
| 9 | |||
| 10 | use defmt::*; | ||
| 11 | use embassy_executor::Spawner; | ||
| 12 | use embassy_lora::sx126x::*; | ||
| 13 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull}; | ||
| 14 | use embassy_nrf::{interrupt, spim}; | ||
| 15 | use embassy_time::{Duration, Timer}; | ||
| 16 | use lorawan_device::async_device::radio::{Bandwidth, CodingRate, PhyRxTx, RfConfig, SpreadingFactor}; | ||
| 17 | use {defmt_rtt as _, panic_probe as _}; | ||
| 18 | |||
| 19 | #[embassy_executor::main] | ||
| 20 | async fn main(_spawner: Spawner) { | ||
| 21 | let p = embassy_nrf::init(Default::default()); | ||
| 22 | let mut spi_config = spim::Config::default(); | ||
| 23 | spi_config.frequency = spim::Frequency::M16; | ||
| 24 | |||
| 25 | let mut radio = { | ||
| 26 | let irq = interrupt::take!(SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1); | ||
| 27 | let spim = spim::Spim::new(p.TWISPI1, irq, p.P1_11, p.P1_13, p.P1_12, spi_config); | ||
| 28 | |||
| 29 | let cs = Output::new(p.P1_10.degrade(), Level::High, OutputDrive::Standard); | ||
| 30 | let reset = Output::new(p.P1_06.degrade(), Level::High, OutputDrive::Standard); | ||
| 31 | let dio1 = Input::new(p.P1_15.degrade(), Pull::Down); | ||
| 32 | let busy = Input::new(p.P1_14.degrade(), Pull::Down); | ||
| 33 | let antenna_rx = Output::new(p.P1_05.degrade(), Level::Low, OutputDrive::Standard); | ||
| 34 | let antenna_tx = Output::new(p.P1_07.degrade(), Level::Low, OutputDrive::Standard); | ||
| 35 | |||
| 36 | match Sx126xRadio::new(spim, cs, reset, antenna_rx, antenna_tx, dio1, busy, false).await { | ||
| 37 | Ok(r) => r, | ||
| 38 | Err(err) => { | ||
| 39 | info!("Sx126xRadio error = {}", err); | ||
| 40 | return; | ||
| 41 | } | ||
| 42 | } | ||
| 43 | }; | ||
| 44 | |||
| 45 | let mut debug_indicator = Output::new(p.P1_03, Level::Low, OutputDrive::Standard); | ||
| 46 | let mut start_indicator = Output::new(p.P1_04, Level::Low, OutputDrive::Standard); | ||
| 47 | |||
| 48 | start_indicator.set_high(); | ||
| 49 | Timer::after(Duration::from_secs(5)).await; | ||
| 50 | start_indicator.set_low(); | ||
| 51 | |||
| 52 | loop { | ||
| 53 | let rf_config = RfConfig { | ||
| 54 | frequency: 903900000, // channel in Hz | ||
| 55 | bandwidth: Bandwidth::_250KHz, | ||
| 56 | spreading_factor: SpreadingFactor::_10, | ||
| 57 | coding_rate: CodingRate::_4_8, | ||
| 58 | }; | ||
| 59 | |||
| 60 | let mut buffer = [00u8; 100]; | ||
| 61 | |||
| 62 | // P2P receive | ||
| 63 | match radio.rx(rf_config, &mut buffer).await { | ||
| 64 | Ok((buffer_len, rx_quality)) => info!( | ||
| 65 | "RX received = {:?} with length = {} rssi = {} snr = {}", | ||
| 66 | &buffer[0..buffer_len], | ||
| 67 | buffer_len, | ||
| 68 | rx_quality.rssi(), | ||
| 69 | rx_quality.snr() | ||
| 70 | ), | ||
| 71 | Err(err) => info!("RX error = {}", err), | ||
| 72 | } | ||
| 73 | |||
| 74 | debug_indicator.set_high(); | ||
| 75 | Timer::after(Duration::from_secs(2)).await; | ||
| 76 | debug_indicator.set_low(); | ||
| 77 | } | ||
| 78 | } | ||
diff --git a/examples/nrf/src/bin/lora_p2p_sense.rs b/examples/nrf/src/bin/lora_p2p_sense.rs new file mode 100644 index 000000000..b9768874b --- /dev/null +++ b/examples/nrf/src/bin/lora_p2p_sense.rs | |||
| @@ -0,0 +1,125 @@ | |||
| 1 | //! This example runs on the RAK4631 WisBlock, which has an nRF52840 MCU and Semtech Sx126x radio. | ||
| 2 | //! Other nrf/sx126x combinations may work with appropriate pin modifications. | ||
| 3 | //! It demonstates LORA P2P functionality in conjunction with example lora_p2p_report.rs. | ||
| 4 | #![no_std] | ||
| 5 | #![no_main] | ||
| 6 | #![macro_use] | ||
| 7 | #![feature(type_alias_impl_trait)] | ||
| 8 | #![feature(alloc_error_handler)] | ||
| 9 | #![allow(incomplete_features)] | ||
| 10 | |||
| 11 | use defmt::*; | ||
| 12 | use embassy_executor::Spawner; | ||
| 13 | use embassy_lora::sx126x::*; | ||
| 14 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pin as _, Pull}; | ||
| 15 | use embassy_nrf::{interrupt, spim}; | ||
| 16 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | ||
| 17 | use embassy_sync::pubsub::{PubSubChannel, Publisher}; | ||
| 18 | use embassy_time::{Duration, Timer}; | ||
| 19 | use lorawan_device::async_device::radio::{Bandwidth, CodingRate, PhyRxTx, RfConfig, SpreadingFactor, TxConfig}; | ||
| 20 | use {defmt_rtt as _, panic_probe as _, panic_probe as _}; | ||
| 21 | |||
| 22 | // Message bus: queue of 2, 1 subscriber (Lora P2P), 2 publishers (temperature, motion detection) | ||
| 23 | static MESSAGE_BUS: PubSubChannel<CriticalSectionRawMutex, Message, 2, 1, 2> = PubSubChannel::new(); | ||
| 24 | |||
| 25 | #[derive(Clone, defmt::Format)] | ||
| 26 | enum Message { | ||
| 27 | Temperature(i32), | ||
| 28 | MotionDetected, | ||
| 29 | } | ||
| 30 | |||
| 31 | #[embassy_executor::task] | ||
| 32 | async fn temperature_task(publisher: Publisher<'static, CriticalSectionRawMutex, Message, 2, 1, 2>) { | ||
| 33 | // Publish a fake temperature every 43 seconds, minimizing LORA traffic. | ||
| 34 | loop { | ||
| 35 | Timer::after(Duration::from_secs(43)).await; | ||
| 36 | publisher.publish(Message::Temperature(9)).await; | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | #[embassy_executor::task] | ||
| 41 | async fn motion_detection_task(publisher: Publisher<'static, CriticalSectionRawMutex, Message, 2, 1, 2>) { | ||
| 42 | // Publish a fake motion detection every 79 seconds, minimizing LORA traffic. | ||
| 43 | loop { | ||
| 44 | Timer::after(Duration::from_secs(79)).await; | ||
| 45 | publisher.publish(Message::MotionDetected).await; | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | #[embassy_executor::main] | ||
| 50 | async fn main(spawner: Spawner) { | ||
| 51 | let p = embassy_nrf::init(Default::default()); | ||
| 52 | // set up to funnel temperature and motion detection events to the Lora Tx task | ||
| 53 | let mut lora_tx_subscriber = unwrap!(MESSAGE_BUS.subscriber()); | ||
| 54 | let temperature_publisher = unwrap!(MESSAGE_BUS.publisher()); | ||
| 55 | let motion_detection_publisher = unwrap!(MESSAGE_BUS.publisher()); | ||
| 56 | |||
| 57 | let mut spi_config = spim::Config::default(); | ||
| 58 | spi_config.frequency = spim::Frequency::M16; | ||
| 59 | |||
| 60 | let mut radio = { | ||
| 61 | let irq = interrupt::take!(SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1); | ||
| 62 | let spim = spim::Spim::new(p.TWISPI1, irq, p.P1_11, p.P1_13, p.P1_12, spi_config); | ||
| 63 | |||
| 64 | let cs = Output::new(p.P1_10.degrade(), Level::High, OutputDrive::Standard); | ||
| 65 | let reset = Output::new(p.P1_06.degrade(), Level::High, OutputDrive::Standard); | ||
| 66 | let dio1 = Input::new(p.P1_15.degrade(), Pull::Down); | ||
| 67 | let busy = Input::new(p.P1_14.degrade(), Pull::Down); | ||
| 68 | let antenna_rx = Output::new(p.P1_05.degrade(), Level::Low, OutputDrive::Standard); | ||
| 69 | let antenna_tx = Output::new(p.P1_07.degrade(), Level::Low, OutputDrive::Standard); | ||
| 70 | |||
| 71 | match Sx126xRadio::new(spim, cs, reset, antenna_rx, antenna_tx, dio1, busy, false).await { | ||
| 72 | Ok(r) => r, | ||
| 73 | Err(err) => { | ||
| 74 | info!("Sx126xRadio error = {}", err); | ||
| 75 | return; | ||
| 76 | } | ||
| 77 | } | ||
| 78 | }; | ||
| 79 | |||
| 80 | let mut start_indicator = Output::new(p.P1_04, Level::Low, OutputDrive::Standard); | ||
| 81 | |||
| 82 | start_indicator.set_high(); | ||
| 83 | Timer::after(Duration::from_secs(5)).await; | ||
| 84 | start_indicator.set_low(); | ||
| 85 | |||
| 86 | match radio.lora.sleep().await { | ||
| 87 | Ok(()) => info!("Sleep successful"), | ||
| 88 | Err(err) => info!("Sleep unsuccessful = {}", err), | ||
| 89 | } | ||
| 90 | |||
| 91 | unwrap!(spawner.spawn(temperature_task(temperature_publisher))); | ||
| 92 | unwrap!(spawner.spawn(motion_detection_task(motion_detection_publisher))); | ||
| 93 | |||
| 94 | loop { | ||
| 95 | let message = lora_tx_subscriber.next_message_pure().await; | ||
| 96 | |||
| 97 | let tx_config = TxConfig { | ||
| 98 | // 11 byte maximum payload for Bandwidth 125 and SF 10 | ||
| 99 | pw: 10, // up to 20 | ||
| 100 | rf: RfConfig { | ||
| 101 | frequency: 903900000, // channel in Hz, not MHz | ||
| 102 | bandwidth: Bandwidth::_250KHz, | ||
| 103 | spreading_factor: SpreadingFactor::_10, | ||
| 104 | coding_rate: CodingRate::_4_8, | ||
| 105 | }, | ||
| 106 | }; | ||
| 107 | |||
| 108 | let mut buffer = [0x00u8]; | ||
| 109 | match message { | ||
| 110 | Message::Temperature(temperature) => buffer[0] = temperature as u8, | ||
| 111 | Message::MotionDetected => buffer[0] = 0x01u8, | ||
| 112 | }; | ||
| 113 | |||
| 114 | // unencrypted | ||
| 115 | match radio.tx(tx_config, &buffer).await { | ||
| 116 | Ok(ret_val) => info!("TX ret_val = {}", ret_val), | ||
| 117 | Err(err) => info!("TX error = {}", err), | ||
| 118 | } | ||
| 119 | |||
| 120 | match radio.lora.sleep().await { | ||
| 121 | Ok(()) => info!("Sleep successful"), | ||
| 122 | Err(err) => info!("Sleep unsuccessful = {}", err), | ||
| 123 | } | ||
| 124 | } | ||
| 125 | } | ||
diff --git a/examples/nrf/src/bin/pdm.rs b/examples/nrf/src/bin/pdm.rs new file mode 100644 index 000000000..7388580fb --- /dev/null +++ b/examples/nrf/src/bin/pdm.rs | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt::info; | ||
| 6 | use embassy_executor::Spawner; | ||
| 7 | use embassy_nrf::interrupt; | ||
| 8 | use embassy_nrf::pdm::{Config, Pdm}; | ||
| 9 | use embassy_time::{Duration, Timer}; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | ||
| 11 | |||
| 12 | #[embassy_executor::main] | ||
| 13 | async fn main(_p: Spawner) { | ||
| 14 | let p = embassy_nrf::init(Default::default()); | ||
| 15 | let config = Config::default(); | ||
| 16 | let mut pdm = Pdm::new(p.PDM, interrupt::take!(PDM), p.P0_01, p.P0_00, config); | ||
| 17 | |||
| 18 | loop { | ||
| 19 | pdm.start().await; | ||
| 20 | |||
| 21 | // wait some time till the microphon settled | ||
| 22 | Timer::after(Duration::from_millis(1000)).await; | ||
| 23 | |||
| 24 | const SAMPLES: usize = 2048; | ||
| 25 | let mut buf = [0i16; SAMPLES]; | ||
| 26 | pdm.sample(&mut buf).await.unwrap(); | ||
| 27 | |||
| 28 | info!("samples: {:?}", &buf); | ||
| 29 | |||
| 30 | pdm.stop().await; | ||
| 31 | Timer::after(Duration::from_millis(100)).await; | ||
| 32 | } | ||
| 33 | } | ||
diff --git a/examples/nrf/src/bin/uart_idle.rs b/examples/nrf/src/bin/uart_idle.rs index 09ec624c0..6af4f7097 100644 --- a/examples/nrf/src/bin/uart_idle.rs +++ b/examples/nrf/src/bin/uart_idle.rs | |||
| @@ -15,7 +15,8 @@ async fn main(_spawner: Spawner) { | |||
| 15 | config.baudrate = uarte::Baudrate::BAUD115200; | 15 | config.baudrate = uarte::Baudrate::BAUD115200; |
| 16 | 16 | ||
| 17 | let irq = interrupt::take!(UARTE0_UART0); | 17 | let irq = interrupt::take!(UARTE0_UART0); |
| 18 | let mut uart = uarte::UarteWithIdle::new(p.UARTE0, p.TIMER0, p.PPI_CH0, p.PPI_CH1, irq, p.P0_08, p.P0_06, config); | 18 | let uart = uarte::Uarte::new(p.UARTE0, irq, p.P0_08, p.P0_06, config); |
| 19 | let (mut tx, mut rx) = uart.split_with_idle(p.TIMER0, p.PPI_CH0, p.PPI_CH1); | ||
| 19 | 20 | ||
| 20 | info!("uarte initialized!"); | 21 | info!("uarte initialized!"); |
| 21 | 22 | ||
| @@ -23,12 +24,12 @@ async fn main(_spawner: Spawner) { | |||
| 23 | let mut buf = [0; 8]; | 24 | let mut buf = [0; 8]; |
| 24 | buf.copy_from_slice(b"Hello!\r\n"); | 25 | buf.copy_from_slice(b"Hello!\r\n"); |
| 25 | 26 | ||
| 26 | unwrap!(uart.write(&buf).await); | 27 | unwrap!(tx.write(&buf).await); |
| 27 | info!("wrote hello in uart!"); | 28 | info!("wrote hello in uart!"); |
| 28 | 29 | ||
| 29 | loop { | 30 | loop { |
| 30 | info!("reading..."); | 31 | info!("reading..."); |
| 31 | let n = unwrap!(uart.read_until_idle(&mut buf).await); | 32 | let n = unwrap!(rx.read_until_idle(&mut buf).await); |
| 32 | info!("got {} bytes", n); | 33 | info!("got {} bytes", n); |
| 33 | } | 34 | } |
| 34 | } | 35 | } |
diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index 3c8f923e7..747dde515 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | 7 | ||
| 7 | [dependencies] | 8 | [dependencies] |
| @@ -26,7 +27,10 @@ st7789 = "0.6.1" | |||
| 26 | display-interface = "0.4.1" | 27 | display-interface = "0.4.1" |
| 27 | byte-slice-cast = { version = "1.2.0", default-features = false } | 28 | byte-slice-cast = { version = "1.2.0", default-features = false } |
| 28 | 29 | ||
| 29 | embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } | 30 | embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9" } |
| 30 | embedded-hal-async = { version = "0.1.0-alpha.1" } | 31 | embedded-hal-async = { version = "0.1.0-alpha.1" } |
| 31 | embedded-io = { version = "0.3.0", features = ["async", "defmt"] } | 32 | embedded-io = { version = "0.3.0", features = ["async", "defmt"] } |
| 32 | static_cell = "1.0.0" | 33 | static_cell = "1.0.0" |
| 34 | |||
| 35 | [profile.release] | ||
| 36 | debug = true | ||
diff --git a/examples/rp/src/bin/i2c_async.rs b/examples/rp/src/bin/i2c_async.rs new file mode 100644 index 000000000..d1a2e3cd7 --- /dev/null +++ b/examples/rp/src/bin/i2c_async.rs | |||
| @@ -0,0 +1,102 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt::*; | ||
| 6 | use embassy_executor::Spawner; | ||
| 7 | use embassy_rp::i2c::{self, Config}; | ||
| 8 | use embassy_rp::interrupt; | ||
| 9 | use embassy_time::{Duration, Timer}; | ||
| 10 | use embedded_hal_async::i2c::I2c; | ||
| 11 | use {defmt_rtt as _, panic_probe as _}; | ||
| 12 | |||
| 13 | #[allow(dead_code)] | ||
| 14 | mod mcp23017 { | ||
| 15 | pub const ADDR: u8 = 0x20; // default addr | ||
| 16 | |||
| 17 | macro_rules! mcpregs { | ||
| 18 | ($($name:ident : $val:expr),* $(,)?) => { | ||
| 19 | $( | ||
| 20 | pub const $name: u8 = $val; | ||
| 21 | )* | ||
| 22 | |||
| 23 | pub fn regname(reg: u8) -> &'static str { | ||
| 24 | match reg { | ||
| 25 | $( | ||
| 26 | $val => stringify!($name), | ||
| 27 | )* | ||
| 28 | _ => panic!("bad reg"), | ||
| 29 | } | ||
| 30 | } | ||
| 31 | } | ||
| 32 | } | ||
| 33 | |||
| 34 | // These are correct for IOCON.BANK=0 | ||
| 35 | mcpregs! { | ||
| 36 | IODIRA: 0x00, | ||
| 37 | IPOLA: 0x02, | ||
| 38 | GPINTENA: 0x04, | ||
| 39 | DEFVALA: 0x06, | ||
| 40 | INTCONA: 0x08, | ||
| 41 | IOCONA: 0x0A, | ||
| 42 | GPPUA: 0x0C, | ||
| 43 | INTFA: 0x0E, | ||
| 44 | INTCAPA: 0x10, | ||
| 45 | GPIOA: 0x12, | ||
| 46 | OLATA: 0x14, | ||
| 47 | IODIRB: 0x01, | ||
| 48 | IPOLB: 0x03, | ||
| 49 | GPINTENB: 0x05, | ||
| 50 | DEFVALB: 0x07, | ||
| 51 | INTCONB: 0x09, | ||
| 52 | IOCONB: 0x0B, | ||
| 53 | GPPUB: 0x0D, | ||
| 54 | INTFB: 0x0F, | ||
| 55 | INTCAPB: 0x11, | ||
| 56 | GPIOB: 0x13, | ||
| 57 | OLATB: 0x15, | ||
| 58 | } | ||
| 59 | } | ||
| 60 | |||
| 61 | #[embassy_executor::main] | ||
| 62 | async fn main(_spawner: Spawner) { | ||
| 63 | let p = embassy_rp::init(Default::default()); | ||
| 64 | |||
| 65 | let sda = p.PIN_14; | ||
| 66 | let scl = p.PIN_15; | ||
| 67 | let irq = interrupt::take!(I2C1_IRQ); | ||
| 68 | |||
| 69 | info!("set up i2c "); | ||
| 70 | let mut i2c = i2c::I2c::new_async(p.I2C1, scl, sda, irq, Config::default()); | ||
| 71 | |||
| 72 | use mcp23017::*; | ||
| 73 | |||
| 74 | info!("init mcp23017 config for IxpandO"); | ||
| 75 | // init - a outputs, b inputs | ||
| 76 | i2c.write(ADDR, &[IODIRA, 0x00]).await.unwrap(); | ||
| 77 | i2c.write(ADDR, &[IODIRB, 0xff]).await.unwrap(); | ||
| 78 | i2c.write(ADDR, &[GPPUB, 0xff]).await.unwrap(); // pullups | ||
| 79 | |||
| 80 | let mut val = 1; | ||
| 81 | loop { | ||
| 82 | let mut portb = [0]; | ||
| 83 | |||
| 84 | i2c.write_read(mcp23017::ADDR, &[GPIOB], &mut portb).await.unwrap(); | ||
| 85 | info!("portb = {:02x}", portb[0]); | ||
| 86 | i2c.write(mcp23017::ADDR, &[GPIOA, val | portb[0]]).await.unwrap(); | ||
| 87 | val = val.rotate_left(1); | ||
| 88 | |||
| 89 | // get a register dump | ||
| 90 | info!("getting register dump"); | ||
| 91 | let mut regs = [0; 22]; | ||
| 92 | i2c.write_read(ADDR, &[0], &mut regs).await.unwrap(); | ||
| 93 | // always get the regdump but only display it if portb'0 is set | ||
| 94 | if portb[0] & 1 != 0 { | ||
| 95 | for (idx, reg) in regs.into_iter().enumerate() { | ||
| 96 | info!("{} => {:02x}", regname(idx as u8), reg); | ||
| 97 | } | ||
| 98 | } | ||
| 99 | |||
| 100 | Timer::after(Duration::from_millis(100)).await; | ||
| 101 | } | ||
| 102 | } | ||
diff --git a/examples/rp/src/bin/i2c_blocking.rs b/examples/rp/src/bin/i2c_blocking.rs new file mode 100644 index 000000000..7623e33c8 --- /dev/null +++ b/examples/rp/src/bin/i2c_blocking.rs | |||
| @@ -0,0 +1,70 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt::*; | ||
| 6 | use embassy_executor::Spawner; | ||
| 7 | use embassy_rp::i2c::{self, Config}; | ||
| 8 | use embassy_time::{Duration, Timer}; | ||
| 9 | use embedded_hal_1::i2c::I2c; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | ||
| 11 | |||
| 12 | #[allow(dead_code)] | ||
| 13 | mod mcp23017 { | ||
| 14 | pub const ADDR: u8 = 0x20; // default addr | ||
| 15 | |||
| 16 | pub const IODIRA: u8 = 0x00; | ||
| 17 | pub const IPOLA: u8 = 0x02; | ||
| 18 | pub const GPINTENA: u8 = 0x04; | ||
| 19 | pub const DEFVALA: u8 = 0x06; | ||
| 20 | pub const INTCONA: u8 = 0x08; | ||
| 21 | pub const IOCONA: u8 = 0x0A; | ||
| 22 | pub const GPPUA: u8 = 0x0C; | ||
| 23 | pub const INTFA: u8 = 0x0E; | ||
| 24 | pub const INTCAPA: u8 = 0x10; | ||
| 25 | pub const GPIOA: u8 = 0x12; | ||
| 26 | pub const OLATA: u8 = 0x14; | ||
| 27 | pub const IODIRB: u8 = 0x01; | ||
| 28 | pub const IPOLB: u8 = 0x03; | ||
| 29 | pub const GPINTENB: u8 = 0x05; | ||
| 30 | pub const DEFVALB: u8 = 0x07; | ||
| 31 | pub const INTCONB: u8 = 0x09; | ||
| 32 | pub const IOCONB: u8 = 0x0B; | ||
| 33 | pub const GPPUB: u8 = 0x0D; | ||
| 34 | pub const INTFB: u8 = 0x0F; | ||
| 35 | pub const INTCAPB: u8 = 0x11; | ||
| 36 | pub const GPIOB: u8 = 0x13; | ||
| 37 | pub const OLATB: u8 = 0x15; | ||
| 38 | } | ||
| 39 | |||
| 40 | #[embassy_executor::main] | ||
| 41 | async fn main(_spawner: Spawner) { | ||
| 42 | let p = embassy_rp::init(Default::default()); | ||
| 43 | |||
| 44 | let sda = p.PIN_14; | ||
| 45 | let scl = p.PIN_15; | ||
| 46 | |||
| 47 | info!("set up i2c "); | ||
| 48 | let mut i2c = i2c::I2c::new_blocking(p.I2C1, scl, sda, Config::default()); | ||
| 49 | |||
| 50 | use mcp23017::*; | ||
| 51 | |||
| 52 | info!("init mcp23017 config for IxpandO"); | ||
| 53 | // init - a outputs, b inputs | ||
| 54 | i2c.write(ADDR, &[IODIRA, 0x00]).unwrap(); | ||
| 55 | i2c.write(ADDR, &[IODIRB, 0xff]).unwrap(); | ||
| 56 | i2c.write(ADDR, &[GPPUB, 0xff]).unwrap(); // pullups | ||
| 57 | |||
| 58 | let mut val = 0xaa; | ||
| 59 | loop { | ||
| 60 | let mut portb = [0]; | ||
| 61 | |||
| 62 | i2c.write(mcp23017::ADDR, &[GPIOA, val]).unwrap(); | ||
| 63 | i2c.write_read(mcp23017::ADDR, &[GPIOB], &mut portb).unwrap(); | ||
| 64 | |||
| 65 | info!("portb = {:02x}", portb[0]); | ||
| 66 | val = !val; | ||
| 67 | |||
| 68 | Timer::after(Duration::from_secs(1)).await; | ||
| 69 | } | ||
| 70 | } | ||
diff --git a/examples/rp/src/bin/spi_display.rs b/examples/rp/src/bin/spi_display.rs index 23cd4355e..778cad3fa 100644 --- a/examples/rp/src/bin/spi_display.rs +++ b/examples/rp/src/bin/spi_display.rs | |||
| @@ -108,9 +108,9 @@ mod shared_spi { | |||
| 108 | use core::cell::RefCell; | 108 | use core::cell::RefCell; |
| 109 | use core::fmt::Debug; | 109 | use core::fmt::Debug; |
| 110 | 110 | ||
| 111 | use embedded_hal_1::digital::blocking::OutputPin; | 111 | use embedded_hal_1::digital::OutputPin; |
| 112 | use embedded_hal_1::spi; | 112 | use embedded_hal_1::spi; |
| 113 | use embedded_hal_1::spi::blocking::SpiDevice; | 113 | use embedded_hal_1::spi::SpiDevice; |
| 114 | 114 | ||
| 115 | #[derive(Copy, Clone, Eq, PartialEq, Debug)] | 115 | #[derive(Copy, Clone, Eq, PartialEq, Debug)] |
| 116 | pub enum SpiDeviceWithCsError<BUS, CS> { | 116 | pub enum SpiDeviceWithCsError<BUS, CS> { |
| @@ -153,7 +153,7 @@ mod shared_spi { | |||
| 153 | 153 | ||
| 154 | impl<'a, BUS, CS> SpiDevice for SpiDeviceWithCs<'a, BUS, CS> | 154 | impl<'a, BUS, CS> SpiDevice for SpiDeviceWithCs<'a, BUS, CS> |
| 155 | where | 155 | where |
| 156 | BUS: spi::blocking::SpiBusFlush, | 156 | BUS: spi::SpiBusFlush, |
| 157 | CS: OutputPin, | 157 | CS: OutputPin, |
| 158 | { | 158 | { |
| 159 | type Bus = BUS; | 159 | type Bus = BUS; |
| @@ -182,7 +182,7 @@ mod shared_spi { | |||
| 182 | 182 | ||
| 183 | /// Driver for the XPT2046 resistive touchscreen sensor | 183 | /// Driver for the XPT2046 resistive touchscreen sensor |
| 184 | mod touch { | 184 | mod touch { |
| 185 | use embedded_hal_1::spi::blocking::{SpiBus, SpiBusRead, SpiBusWrite, SpiDevice}; | 185 | use embedded_hal_1::spi::{SpiBus, SpiBusRead, SpiBusWrite, SpiDevice}; |
| 186 | 186 | ||
| 187 | struct Calibration { | 187 | struct Calibration { |
| 188 | x1: i32, | 188 | x1: i32, |
| @@ -246,8 +246,8 @@ mod touch { | |||
| 246 | 246 | ||
| 247 | mod my_display_interface { | 247 | mod my_display_interface { |
| 248 | use display_interface::{DataFormat, DisplayError, WriteOnlyDataCommand}; | 248 | use display_interface::{DataFormat, DisplayError, WriteOnlyDataCommand}; |
| 249 | use embedded_hal_1::digital::blocking::OutputPin; | 249 | use embedded_hal_1::digital::OutputPin; |
| 250 | use embedded_hal_1::spi::blocking::{SpiBusWrite, SpiDevice}; | 250 | use embedded_hal_1::spi::{SpiBusWrite, SpiDevice}; |
| 251 | 251 | ||
| 252 | /// SPI display interface. | 252 | /// SPI display interface. |
| 253 | /// | 253 | /// |
diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index dbfd9d625..b9bd1e718 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [dependencies] | 7 | [dependencies] |
| 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["log"] } | 8 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["log"] } |
diff --git a/examples/stm32f0/Cargo.toml b/examples/stm32f0/Cargo.toml index c82b79c86..a56c546ee 100644 --- a/examples/stm32f0/Cargo.toml +++ b/examples/stm32f0/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 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 = "2021" |
| 5 | license = "MIT OR Apache-2.0" | ||
| 5 | 6 | ||
| 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html |
| 7 | 8 | ||
diff --git a/examples/stm32f1/Cargo.toml b/examples/stm32f1/Cargo.toml index e6553789a..6be131f30 100644 --- a/examples/stm32f1/Cargo.toml +++ b/examples/stm32f1/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [dependencies] | 7 | [dependencies] |
| 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
diff --git a/examples/stm32f2/Cargo.toml b/examples/stm32f2/Cargo.toml index 60cd54bd9..f6adda2a3 100644 --- a/examples/stm32f2/Cargo.toml +++ b/examples/stm32f2/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [dependencies] | 7 | [dependencies] |
| 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
diff --git a/examples/stm32f3/Cargo.toml b/examples/stm32f3/Cargo.toml index f5b0b880c..27188dd19 100644 --- a/examples/stm32f3/Cargo.toml +++ b/examples/stm32f3/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [dependencies] | 7 | [dependencies] |
| 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
diff --git a/examples/stm32f3/src/bin/flash.rs b/examples/stm32f3/src/bin/flash.rs index 2cf24dbd3..baa7484d0 100644 --- a/examples/stm32f3/src/bin/flash.rs +++ b/examples/stm32f3/src/bin/flash.rs | |||
| @@ -15,7 +15,7 @@ async fn main(_spawner: Spawner) { | |||
| 15 | 15 | ||
| 16 | const ADDR: u32 = 0x26000; | 16 | const ADDR: u32 = 0x26000; |
| 17 | 17 | ||
| 18 | let mut f = Flash::unlock(p.FLASH); | 18 | let mut f = Flash::new(p.FLASH); |
| 19 | 19 | ||
| 20 | info!("Reading..."); | 20 | info!("Reading..."); |
| 21 | let mut buf = [0u8; 8]; | 21 | let mut buf = [0u8; 8]; |
diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml index ea5c47a43..6d4f09fba 100644 --- a/examples/stm32f4/Cargo.toml +++ b/examples/stm32f4/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | 7 | ||
| 7 | [dependencies] | 8 | [dependencies] |
diff --git a/examples/stm32f4/src/bin/adc.rs b/examples/stm32f4/src/bin/adc.rs index 871185074..1d030f7dc 100644 --- a/examples/stm32f4/src/bin/adc.rs +++ b/examples/stm32f4/src/bin/adc.rs | |||
| @@ -2,9 +2,10 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use cortex_m::prelude::_embedded_hal_blocking_delay_DelayUs; | ||
| 5 | use defmt::*; | 6 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::adc::Adc; | 8 | use embassy_stm32::adc::{Adc, Temperature, VrefInt}; |
| 8 | use embassy_time::{Delay, Duration, Timer}; | 9 | use embassy_time::{Delay, Duration, Timer}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 11 | ||
| @@ -13,12 +14,30 @@ async fn main(_spawner: Spawner) { | |||
| 13 | let p = embassy_stm32::init(Default::default()); | 14 | let p = embassy_stm32::init(Default::default()); |
| 14 | info!("Hello World!"); | 15 | info!("Hello World!"); |
| 15 | 16 | ||
| 16 | let mut adc = Adc::new(p.ADC1, &mut Delay); | 17 | let mut delay = Delay; |
| 18 | let mut adc = Adc::new(p.ADC1, &mut delay); | ||
| 17 | let mut pin = p.PC1; | 19 | let mut pin = p.PC1; |
| 18 | 20 | ||
| 21 | let mut vrefint = adc.enable_vrefint(); | ||
| 22 | let mut temp = adc.enable_temperature(); | ||
| 23 | |||
| 24 | // Startup delay can be combined to the maximum of either | ||
| 25 | delay.delay_us(Temperature::start_time_us().max(VrefInt::start_time_us())); | ||
| 26 | |||
| 19 | loop { | 27 | loop { |
| 28 | // Read pin | ||
| 20 | let v = adc.read(&mut pin); | 29 | let v = adc.read(&mut pin); |
| 21 | info!("--> {} - {} mV", v, adc.to_millivolts(v)); | 30 | info!("PC1: {} ({} mV)", v, adc.to_millivolts(v)); |
| 31 | |||
| 32 | // Read internal temperature | ||
| 33 | let v = adc.read_internal(&mut temp); | ||
| 34 | let celcius = Temperature::to_celcius(adc.to_millivolts(v)); | ||
| 35 | info!("Internal temp: {} ({} C)", v, celcius); | ||
| 36 | |||
| 37 | // Read internal voltage reference | ||
| 38 | let v = adc.read_internal(&mut vrefint); | ||
| 39 | info!("VrefInt: {} ({} mV)", v, adc.to_millivolts(v)); | ||
| 40 | |||
| 22 | Timer::after(Duration::from_millis(100)).await; | 41 | Timer::after(Duration::from_millis(100)).await; |
| 23 | } | 42 | } |
| 24 | } | 43 | } |
diff --git a/examples/stm32f4/src/bin/flash.rs b/examples/stm32f4/src/bin/flash.rs index 393d61e86..7ea068a42 100644 --- a/examples/stm32f4/src/bin/flash.rs +++ b/examples/stm32f4/src/bin/flash.rs | |||
| @@ -13,7 +13,7 @@ async fn main(_spawner: Spawner) { | |||
| 13 | let p = embassy_stm32::init(Default::default()); | 13 | let p = embassy_stm32::init(Default::default()); |
| 14 | info!("Hello Flash!"); | 14 | info!("Hello Flash!"); |
| 15 | 15 | ||
| 16 | let mut f = Flash::unlock(p.FLASH); | 16 | let mut f = Flash::new(p.FLASH); |
| 17 | 17 | ||
| 18 | // Sector 5 | 18 | // Sector 5 |
| 19 | test_flash(&mut f, 128 * 1024, 128 * 1024); | 19 | test_flash(&mut f, 128 * 1024, 128 * 1024); |
diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml index 6c2f846fe..dad92c0fc 100644 --- a/examples/stm32f7/Cargo.toml +++ b/examples/stm32f7/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [dependencies] | 7 | [dependencies] |
| 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
diff --git a/examples/stm32f7/src/bin/flash.rs b/examples/stm32f7/src/bin/flash.rs index c10781d0c..4a7bca1fa 100644 --- a/examples/stm32f7/src/bin/flash.rs +++ b/examples/stm32f7/src/bin/flash.rs | |||
| @@ -19,7 +19,7 @@ async fn main(_spawner: Spawner) { | |||
| 19 | // wait a bit before accessing the flash | 19 | // wait a bit before accessing the flash |
| 20 | Timer::after(Duration::from_millis(300)).await; | 20 | Timer::after(Duration::from_millis(300)).await; |
| 21 | 21 | ||
| 22 | let mut f = Flash::unlock(p.FLASH); | 22 | let mut f = Flash::new(p.FLASH); |
| 23 | 23 | ||
| 24 | info!("Reading..."); | 24 | info!("Reading..."); |
| 25 | let mut buf = [0u8; 32]; | 25 | let mut buf = [0u8; 32]; |
diff --git a/examples/stm32g0/Cargo.toml b/examples/stm32g0/Cargo.toml index 6baf17f36..f5673718d 100644 --- a/examples/stm32g0/Cargo.toml +++ b/examples/stm32g0/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [dependencies] | 7 | [dependencies] |
| 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
diff --git a/examples/stm32g4/Cargo.toml b/examples/stm32g4/Cargo.toml index d8c05a979..ecda28805 100644 --- a/examples/stm32g4/Cargo.toml +++ b/examples/stm32g4/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [dependencies] | 7 | [dependencies] |
| 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index fc60d7a88..1a05b9ecb 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [dependencies] | 7 | [dependencies] |
| 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
| @@ -17,8 +18,8 @@ defmt-rtt = "0.3" | |||
| 17 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } | 18 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 18 | cortex-m-rt = "0.7.0" | 19 | cortex-m-rt = "0.7.0" |
| 19 | embedded-hal = "0.2.6" | 20 | embedded-hal = "0.2.6" |
| 20 | embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } | 21 | embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9" } |
| 21 | embedded-hal-async = { version = "0.1.0-alpha.1" } | 22 | embedded-hal-async = { version = "=0.1.0-alpha.2" } |
| 22 | embedded-nal-async = "0.2.0" | 23 | embedded-nal-async = "0.2.0" |
| 23 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 24 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 24 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | 25 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } |
diff --git a/examples/stm32h7/src/bin/flash.rs b/examples/stm32h7/src/bin/flash.rs index 6682c64d5..ee86bdbf6 100644 --- a/examples/stm32h7/src/bin/flash.rs +++ b/examples/stm32h7/src/bin/flash.rs | |||
| @@ -19,7 +19,7 @@ async fn main(_spawner: Spawner) { | |||
| 19 | // wait a bit before accessing the flash | 19 | // wait a bit before accessing the flash |
| 20 | Timer::after(Duration::from_millis(300)).await; | 20 | Timer::after(Duration::from_millis(300)).await; |
| 21 | 21 | ||
| 22 | let mut f = Flash::unlock(p.FLASH); | 22 | let mut f = Flash::new(p.FLASH); |
| 23 | 23 | ||
| 24 | info!("Reading..."); | 24 | info!("Reading..."); |
| 25 | let mut buf = [0u8; 32]; | 25 | let mut buf = [0u8; 32]; |
diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index 7e61f0c19..7e1120f48 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [features] | 7 | [features] |
| 7 | default = ["nightly"] | 8 | default = ["nightly"] |
diff --git a/examples/stm32l0/src/bin/flash.rs b/examples/stm32l0/src/bin/flash.rs index 867cb4d3e..ffe4fb10b 100644 --- a/examples/stm32l0/src/bin/flash.rs +++ b/examples/stm32l0/src/bin/flash.rs | |||
| @@ -15,7 +15,7 @@ async fn main(_spawner: Spawner) { | |||
| 15 | 15 | ||
| 16 | const ADDR: u32 = 0x26000; | 16 | const ADDR: u32 = 0x26000; |
| 17 | 17 | ||
| 18 | let mut f = Flash::unlock(p.FLASH); | 18 | let mut f = Flash::new(p.FLASH); |
| 19 | 19 | ||
| 20 | info!("Reading..."); | 20 | info!("Reading..."); |
| 21 | let mut buf = [0u8; 8]; | 21 | let mut buf = [0u8; 8]; |
diff --git a/examples/stm32l1/Cargo.toml b/examples/stm32l1/Cargo.toml index a943c73d2..9460febf5 100644 --- a/examples/stm32l1/Cargo.toml +++ b/examples/stm32l1/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [dependencies] | 7 | [dependencies] |
| 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
diff --git a/examples/stm32l1/src/bin/flash.rs b/examples/stm32l1/src/bin/flash.rs index a76b9879f..476ed51a4 100644 --- a/examples/stm32l1/src/bin/flash.rs +++ b/examples/stm32l1/src/bin/flash.rs | |||
| @@ -15,7 +15,7 @@ async fn main(_spawner: Spawner) { | |||
| 15 | 15 | ||
| 16 | const ADDR: u32 = 0x26000; | 16 | const ADDR: u32 = 0x26000; |
| 17 | 17 | ||
| 18 | let mut f = Flash::unlock(p.FLASH); | 18 | let mut f = Flash::new(p.FLASH); |
| 19 | 19 | ||
| 20 | info!("Reading..."); | 20 | info!("Reading..."); |
| 21 | let mut buf = [0u8; 8]; | 21 | let mut buf = [0u8; 8]; |
diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml index 35a9c20f0..657605ebe 100644 --- a/examples/stm32l4/Cargo.toml +++ b/examples/stm32l4/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 3 | name = "embassy-stm32l4-examples" | 3 | name = "embassy-stm32l4-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.0" |
| 5 | license = "MIT OR Apache-2.0" | ||
| 5 | 6 | ||
| 6 | [features] | 7 | [features] |
| 7 | 8 | ||
| @@ -18,8 +19,8 @@ defmt-rtt = "0.3" | |||
| 18 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } | 19 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 19 | cortex-m-rt = "0.7.0" | 20 | cortex-m-rt = "0.7.0" |
| 20 | embedded-hal = "0.2.6" | 21 | embedded-hal = "0.2.6" |
| 21 | embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } | 22 | embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9" } |
| 22 | embedded-hal-async = { version = "0.1.0-alpha.1" } | 23 | embedded-hal-async = { version = "=0.1.0-alpha.2" } |
| 23 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 24 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 24 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | 25 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } |
| 25 | heapless = { version = "0.7.5", default-features = false } | 26 | heapless = { version = "0.7.5", default-features = false } |
diff --git a/examples/stm32l5/Cargo.toml b/examples/stm32l5/Cargo.toml index 9ebab6476..63eac3ed2 100644 --- a/examples/stm32l5/Cargo.toml +++ b/examples/stm32l5/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [features] | 7 | [features] |
| 7 | 8 | ||
diff --git a/examples/stm32u5/Cargo.toml b/examples/stm32u5/Cargo.toml index 164940586..3d704011b 100644 --- a/examples/stm32u5/Cargo.toml +++ b/examples/stm32u5/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [dependencies] | 7 | [dependencies] |
| 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
diff --git a/examples/stm32wb/Cargo.toml b/examples/stm32wb/Cargo.toml index 923833e46..5b96fa191 100644 --- a/examples/stm32wb/Cargo.toml +++ b/examples/stm32wb/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [dependencies] | 7 | [dependencies] |
| 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
diff --git a/examples/stm32wl/Cargo.toml b/examples/stm32wl/Cargo.toml index 94e0fb830..c827d2b71 100644 --- a/examples/stm32wl/Cargo.toml +++ b/examples/stm32wl/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [dependencies] | 7 | [dependencies] |
| 7 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
diff --git a/examples/stm32wl/src/bin/flash.rs b/examples/stm32wl/src/bin/flash.rs index eb7489760..2a8880624 100644 --- a/examples/stm32wl/src/bin/flash.rs +++ b/examples/stm32wl/src/bin/flash.rs | |||
| @@ -15,7 +15,7 @@ async fn main(_spawner: Spawner) { | |||
| 15 | 15 | ||
| 16 | const ADDR: u32 = 0x36000; | 16 | const ADDR: u32 = 0x36000; |
| 17 | 17 | ||
| 18 | let mut f = Flash::unlock(p.FLASH); | 18 | let mut f = Flash::new(p.FLASH); |
| 19 | 19 | ||
| 20 | info!("Reading..."); | 20 | info!("Reading..."); |
| 21 | let mut buf = [0u8; 8]; | 21 | let mut buf = [0u8; 8]; |
diff --git a/examples/wasm/Cargo.toml b/examples/wasm/Cargo.toml index ea61fb921..e0e799a34 100644 --- a/examples/wasm/Cargo.toml +++ b/examples/wasm/Cargo.toml | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | edition = "2021" | 2 | edition = "2021" |
| 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 | 6 | ||
| 6 | [lib] | 7 | [lib] |
| 7 | crate-type = ["cdylib"] | 8 | crate-type = ["cdylib"] |
