aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/boot/application/nrf/Cargo.toml8
-rw-r--r--examples/boot/application/rp/Cargo.toml6
-rw-r--r--examples/boot/application/rp/src/bin/a.rs2
-rw-r--r--examples/boot/application/stm32f3/Cargo.toml4
-rw-r--r--examples/boot/application/stm32f7/Cargo.toml4
-rw-r--r--examples/boot/application/stm32h7/Cargo.toml4
-rw-r--r--examples/boot/application/stm32l0/Cargo.toml4
-rw-r--r--examples/boot/application/stm32l1/Cargo.toml4
-rw-r--r--examples/boot/application/stm32l4/Cargo.toml4
-rw-r--r--examples/boot/application/stm32wb-dfu/Cargo.toml6
-rw-r--r--examples/boot/application/stm32wl/Cargo.toml4
-rw-r--r--examples/boot/bootloader/stm32wb-dfu/Cargo.toml2
-rw-r--r--examples/lpc55s69/Cargo.toml2
-rw-r--r--examples/mimxrt1011/.cargo/config.toml8
-rw-r--r--examples/mimxrt1011/Cargo.toml29
-rw-r--r--examples/mimxrt1011/build.rs14
-rw-r--r--examples/mimxrt1011/src/bin/blinky.rs48
-rw-r--r--examples/mimxrt1011/src/bin/button.rs62
-rw-r--r--examples/mimxrt1011/src/lib.rs75
-rw-r--r--examples/mimxrt1062-evk/.cargo/config.toml8
-rw-r--r--examples/mimxrt1062-evk/Cargo.toml29
-rw-r--r--examples/mimxrt1062-evk/build.rs12
-rw-r--r--examples/mimxrt1062-evk/src/bin/blinky.rs25
-rw-r--r--examples/mimxrt1062-evk/src/bin/button.rs36
-rw-r--r--examples/mimxrt1062-evk/src/lib.rs60
-rw-r--r--examples/mspm0g3507/.cargo/config.toml2
-rw-r--r--examples/mspm0g3507/Cargo.toml2
-rw-r--r--examples/nrf-rtos-trace/Cargo.toml2
-rw-r--r--examples/nrf51/Cargo.toml2
-rw-r--r--examples/nrf52810/Cargo.toml2
-rw-r--r--examples/nrf52840-rtic/Cargo.toml2
-rw-r--r--examples/nrf52840/Cargo.toml4
-rw-r--r--examples/nrf52840/src/bin/self_spawn_current_executor.rs3
-rw-r--r--examples/nrf5340/Cargo.toml4
-rw-r--r--examples/nrf54l15/Cargo.toml2
-rw-r--r--examples/nrf9151/ns/Cargo.toml2
-rw-r--r--examples/nrf9151/s/Cargo.toml2
-rw-r--r--examples/nrf9160/Cargo.toml2
-rw-r--r--examples/rp/Cargo.toml22
-rw-r--r--examples/rp/src/bin/usb_raw_bulk.rs4
-rw-r--r--examples/rp/src/bin/usb_webusb.rs4
-rw-r--r--examples/rp235x/Cargo.toml19
-rw-r--r--examples/rp235x/memory.x4
-rw-r--r--examples/rp235x/src/bin/blinky_wifi.rs6
-rw-r--r--examples/rp235x/src/bin/usb_webusb.rs4
-rw-r--r--examples/stm32c0/Cargo.toml3
-rw-r--r--examples/stm32c0/src/bin/rtc.rs35
-rw-r--r--examples/stm32f0/src/bin/adc-watchdog.rs34
-rw-r--r--examples/stm32f1/Cargo.toml2
-rw-r--r--examples/stm32f1/src/bin/input_capture.rs2
-rw-r--r--examples/stm32f1/src/bin/pwm_input.rs2
-rw-r--r--examples/stm32f3/Cargo.toml2
-rw-r--r--examples/stm32f334/Cargo.toml2
-rw-r--r--examples/stm32f4/Cargo.toml2
-rw-r--r--examples/stm32f4/src/bin/input_capture.rs2
-rw-r--r--examples/stm32f4/src/bin/pwm.rs2
-rw-r--r--examples/stm32f4/src/bin/pwm_complementary.rs4
-rw-r--r--examples/stm32f4/src/bin/pwm_input.rs2
-rw-r--r--examples/stm32f4/src/bin/ws2812_pwm.rs2
-rw-r--r--examples/stm32f7/Cargo.toml2
-rw-r--r--examples/stm32f7/src/bin/cryp.rs4
-rw-r--r--examples/stm32f7/src/bin/qspi.rs1
-rw-r--r--examples/stm32g0/Cargo.toml2
-rw-r--r--examples/stm32g0/src/bin/hf_timer.rs4
-rw-r--r--examples/stm32g0/src/bin/input_capture.rs4
-rw-r--r--examples/stm32g0/src/bin/pwm_complementary.rs8
-rw-r--r--examples/stm32g0/src/bin/pwm_input.rs4
-rw-r--r--examples/stm32g4/Cargo.toml2
-rw-r--r--examples/stm32g4/src/bin/i2c_slave.rs149
-rw-r--r--examples/stm32g4/src/bin/pwm.rs2
-rw-r--r--examples/stm32h5/Cargo.toml2
-rw-r--r--examples/stm32h7/Cargo.toml4
-rw-r--r--examples/stm32h7/src/bin/i2c_shared.rs6
-rw-r--r--examples/stm32h7/src/bin/low_level_timer_api.rs10
-rw-r--r--examples/stm32h7/src/bin/pwm.rs2
-rw-r--r--examples/stm32h723/src/bin/spdifrx.rs24
-rw-r--r--examples/stm32h735/Cargo.toml2
-rw-r--r--examples/stm32h742/Cargo.toml2
-rw-r--r--examples/stm32h742/src/bin/qspi.rs1
-rw-r--r--examples/stm32h755cm4/Cargo.toml4
-rw-r--r--examples/stm32h755cm7/Cargo.toml4
-rw-r--r--examples/stm32h7b0/Cargo.toml4
-rw-r--r--examples/stm32h7rs/Cargo.toml2
-rw-r--r--examples/stm32h7rs/src/bin/xspi_memory_mapped.rs850
-rw-r--r--examples/stm32l0/src/bin/dds.rs4
-rw-r--r--examples/stm32l1/Cargo.toml2
-rw-r--r--examples/stm32l4/Cargo.toml4
-rw-r--r--examples/stm32l4/src/bin/spe_adin1110_http_server.rs2
-rw-r--r--examples/stm32l432/src/bin/qspi_mmap.rs3
-rw-r--r--examples/stm32l5/Cargo.toml2
-rw-r--r--examples/stm32u0/Cargo.toml2
-rw-r--r--examples/stm32u5/Cargo.toml2
-rw-r--r--examples/stm32wb/src/bin/gatt_server.rs9
-rw-r--r--examples/stm32wba/src/bin/adc.rs49
-rw-r--r--examples/stm32wl/Cargo.toml2
95 files changed, 1508 insertions, 322 deletions
diff --git a/examples/boot/application/nrf/Cargo.toml b/examples/boot/application/nrf/Cargo.toml
index 4d633e8a8..37183df97 100644
--- a/examples/boot/application/nrf/Cargo.toml
+++ b/examples/boot/application/nrf/Cargo.toml
@@ -8,10 +8,10 @@ license = "MIT OR Apache-2.0"
8embassy-sync = { version = "0.7.0", path = "../../../../embassy-sync" } 8embassy-sync = { version = "0.7.0", path = "../../../../embassy-sync" }
9embassy-executor = { version = "0.7.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "arch-cortex-m", "executor-thread"] } 9embassy-executor = { version = "0.7.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "arch-cortex-m", "executor-thread"] }
10embassy-time = { version = "0.4.0", path = "../../../../embassy-time", features = [] } 10embassy-time = { version = "0.4.0", path = "../../../../embassy-time", features = [] }
11embassy-nrf = { version = "0.3.1", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", ] } 11embassy-nrf = { version = "0.5.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", ] }
12embassy-boot = { version = "0.4.0", path = "../../../../embassy-boot", features = [] } 12embassy-boot = { version = "0.5.0", path = "../../../../embassy-boot", features = [] }
13embassy-boot-nrf = { version = "0.4.0", path = "../../../../embassy-boot-nrf", features = [] } 13embassy-boot-nrf = { version = "0.6.0", path = "../../../../embassy-boot-nrf", features = [] }
14embassy-embedded-hal = { version = "0.3.0", path = "../../../../embassy-embedded-hal" } 14embassy-embedded-hal = { version = "0.3.1", path = "../../../../embassy-embedded-hal" }
15 15
16defmt = { version = "1.0.1", optional = true } 16defmt = { version = "1.0.1", optional = true }
17defmt-rtt = { version = "1.0.0", optional = true } 17defmt-rtt = { version = "1.0.0", optional = true }
diff --git a/examples/boot/application/rp/Cargo.toml b/examples/boot/application/rp/Cargo.toml
index be283fb27..e5568f6bb 100644
--- a/examples/boot/application/rp/Cargo.toml
+++ b/examples/boot/application/rp/Cargo.toml
@@ -8,9 +8,9 @@ license = "MIT OR Apache-2.0"
8embassy-sync = { version = "0.7.0", path = "../../../../embassy-sync" } 8embassy-sync = { version = "0.7.0", path = "../../../../embassy-sync" }
9embassy-executor = { version = "0.7.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread"] } 9embassy-executor = { version = "0.7.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread"] }
10embassy-time = { version = "0.4.0", path = "../../../../embassy-time", features = [] } 10embassy-time = { version = "0.4.0", path = "../../../../embassy-time", features = [] }
11embassy-rp = { version = "0.4.0", path = "../../../../embassy-rp", features = ["time-driver", "rp2040"] } 11embassy-rp = { version = "0.6.0", path = "../../../../embassy-rp", features = ["time-driver", "rp2040"] }
12embassy-boot-rp = { version = "0.5.0", path = "../../../../embassy-boot-rp", features = [] } 12embassy-boot-rp = { version = "0.6.0", path = "../../../../embassy-boot-rp", features = [] }
13embassy-embedded-hal = { version = "0.3.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.3.1", path = "../../../../embassy-embedded-hal" }
14 14
15defmt = "1.0.1" 15defmt = "1.0.1"
16defmt-rtt = "1.0.0" 16defmt-rtt = "1.0.0"
diff --git a/examples/boot/application/rp/src/bin/a.rs b/examples/boot/application/rp/src/bin/a.rs
index ede0c07da..e6d7b3d4f 100644
--- a/examples/boot/application/rp/src/bin/a.rs
+++ b/examples/boot/application/rp/src/bin/a.rs
@@ -54,7 +54,7 @@ async fn main(_s: Spawner) {
54 for chunk in APP_B.chunks(4096) { 54 for chunk in APP_B.chunks(4096) {
55 buf.0[..chunk.len()].copy_from_slice(chunk); 55 buf.0[..chunk.len()].copy_from_slice(chunk);
56 defmt::info!("writing block at offset {}", offset); 56 defmt::info!("writing block at offset {}", offset);
57 writer.write(offset, &buf.0[..]).unwrap(); 57 writer.write(offset, &buf.0[..chunk.len()]).unwrap();
58 offset += chunk.len() as u32; 58 offset += chunk.len() as u32;
59 } 59 }
60 watchdog.feed(); 60 watchdog.feed();
diff --git a/examples/boot/application/stm32f3/Cargo.toml b/examples/boot/application/stm32f3/Cargo.toml
index b3466e288..be8b7bff1 100644
--- a/examples/boot/application/stm32f3/Cargo.toml
+++ b/examples/boot/application/stm32f3/Cargo.toml
@@ -9,8 +9,8 @@ embassy-sync = { version = "0.7.0", path = "../../../../embassy-sync" }
9embassy-executor = { version = "0.7.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread"] } 9embassy-executor = { version = "0.7.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread"] }
10embassy-time = { version = "0.4.0", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } 10embassy-time = { version = "0.4.0", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] }
11embassy-stm32 = { version = "0.2.0", path = "../../../../embassy-stm32", features = ["stm32f303re", "time-driver-any", "exti"] } 11embassy-stm32 = { version = "0.2.0", path = "../../../../embassy-stm32", features = ["stm32f303re", "time-driver-any", "exti"] }
12embassy-boot-stm32 = { version = "0.3.0", path = "../../../../embassy-boot-stm32" } 12embassy-boot-stm32 = { version = "0.4.0", path = "../../../../embassy-boot-stm32" }
13embassy-embedded-hal = { version = "0.3.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.3.1", path = "../../../../embassy-embedded-hal" }
14 14
15defmt = { version = "1.0.1", optional = true } 15defmt = { version = "1.0.1", optional = true }
16defmt-rtt = { version = "1.0.0", optional = true } 16defmt-rtt = { version = "1.0.0", optional = true }
diff --git a/examples/boot/application/stm32f7/Cargo.toml b/examples/boot/application/stm32f7/Cargo.toml
index 72dbded5f..2b0175a0c 100644
--- a/examples/boot/application/stm32f7/Cargo.toml
+++ b/examples/boot/application/stm32f7/Cargo.toml
@@ -9,8 +9,8 @@ embassy-sync = { version = "0.7.0", path = "../../../../embassy-sync" }
9embassy-executor = { version = "0.7.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread"] } 9embassy-executor = { version = "0.7.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread"] }
10embassy-time = { version = "0.4.0", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } 10embassy-time = { version = "0.4.0", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] }
11embassy-stm32 = { version = "0.2.0", path = "../../../../embassy-stm32", features = ["stm32f767zi", "time-driver-any", "exti", "single-bank"] } 11embassy-stm32 = { version = "0.2.0", path = "../../../../embassy-stm32", features = ["stm32f767zi", "time-driver-any", "exti", "single-bank"] }
12embassy-boot-stm32 = { version = "0.3.0", path = "../../../../embassy-boot-stm32", features = [] } 12embassy-boot-stm32 = { version = "0.4.0", path = "../../../../embassy-boot-stm32", features = [] }
13embassy-embedded-hal = { version = "0.3.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.3.1", path = "../../../../embassy-embedded-hal" }
14 14
15defmt = { version = "1.0.1", optional = true } 15defmt = { version = "1.0.1", optional = true }
16defmt-rtt = { version = "1.0.0", optional = true } 16defmt-rtt = { version = "1.0.0", optional = true }
diff --git a/examples/boot/application/stm32h7/Cargo.toml b/examples/boot/application/stm32h7/Cargo.toml
index 57fb8312c..3c88f4241 100644
--- a/examples/boot/application/stm32h7/Cargo.toml
+++ b/examples/boot/application/stm32h7/Cargo.toml
@@ -9,8 +9,8 @@ embassy-sync = { version = "0.7.0", path = "../../../../embassy-sync" }
9embassy-executor = { version = "0.7.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread"] } 9embassy-executor = { version = "0.7.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread"] }
10embassy-time = { version = "0.4.0", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } 10embassy-time = { version = "0.4.0", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] }
11embassy-stm32 = { version = "0.2.0", path = "../../../../embassy-stm32", features = ["stm32h743zi", "time-driver-any", "exti"] } 11embassy-stm32 = { version = "0.2.0", path = "../../../../embassy-stm32", features = ["stm32h743zi", "time-driver-any", "exti"] }
12embassy-boot-stm32 = { version = "0.3.0", path = "../../../../embassy-boot-stm32", features = [] } 12embassy-boot-stm32 = { version = "0.4.0", path = "../../../../embassy-boot-stm32", features = [] }
13embassy-embedded-hal = { version = "0.3.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.3.1", path = "../../../../embassy-embedded-hal" }
14 14
15defmt = { version = "1.0.1", optional = true } 15defmt = { version = "1.0.1", optional = true }
16defmt-rtt = { version = "1.0.0", optional = true } 16defmt-rtt = { version = "1.0.0", optional = true }
diff --git a/examples/boot/application/stm32l0/Cargo.toml b/examples/boot/application/stm32l0/Cargo.toml
index 7dbbba138..b4e7e090a 100644
--- a/examples/boot/application/stm32l0/Cargo.toml
+++ b/examples/boot/application/stm32l0/Cargo.toml
@@ -9,8 +9,8 @@ embassy-sync = { version = "0.7.0", path = "../../../../embassy-sync" }
9embassy-executor = { version = "0.7.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread"] } 9embassy-executor = { version = "0.7.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread"] }
10embassy-time = { version = "0.4.0", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } 10embassy-time = { version = "0.4.0", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] }
11embassy-stm32 = { version = "0.2.0", path = "../../../../embassy-stm32", features = ["stm32l072cz", "time-driver-any", "exti", "memory-x"] } 11embassy-stm32 = { version = "0.2.0", path = "../../../../embassy-stm32", features = ["stm32l072cz", "time-driver-any", "exti", "memory-x"] }
12embassy-boot-stm32 = { version = "0.3.0", path = "../../../../embassy-boot-stm32", features = [] } 12embassy-boot-stm32 = { version = "0.4.0", path = "../../../../embassy-boot-stm32", features = [] }
13embassy-embedded-hal = { version = "0.3.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.3.1", path = "../../../../embassy-embedded-hal" }
14 14
15defmt = { version = "1.0.1", optional = true } 15defmt = { version = "1.0.1", optional = true }
16defmt-rtt = { version = "1.0.0", optional = true } 16defmt-rtt = { version = "1.0.0", optional = true }
diff --git a/examples/boot/application/stm32l1/Cargo.toml b/examples/boot/application/stm32l1/Cargo.toml
index 9549b2048..394578e1a 100644
--- a/examples/boot/application/stm32l1/Cargo.toml
+++ b/examples/boot/application/stm32l1/Cargo.toml
@@ -9,8 +9,8 @@ embassy-sync = { version = "0.7.0", path = "../../../../embassy-sync" }
9embassy-executor = { version = "0.7.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread"] } 9embassy-executor = { version = "0.7.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread"] }
10embassy-time = { version = "0.4.0", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } 10embassy-time = { version = "0.4.0", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] }
11embassy-stm32 = { version = "0.2.0", path = "../../../../embassy-stm32", features = ["stm32l151cb-a", "time-driver-any", "exti"] } 11embassy-stm32 = { version = "0.2.0", path = "../../../../embassy-stm32", features = ["stm32l151cb-a", "time-driver-any", "exti"] }
12embassy-boot-stm32 = { version = "0.3.0", path = "../../../../embassy-boot-stm32", features = [] } 12embassy-boot-stm32 = { version = "0.4.0", path = "../../../../embassy-boot-stm32", features = [] }
13embassy-embedded-hal = { version = "0.3.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.3.1", path = "../../../../embassy-embedded-hal" }
14 14
15defmt = { version = "1.0.1", optional = true } 15defmt = { version = "1.0.1", optional = true }
16defmt-rtt = { version = "1.0.0", optional = true } 16defmt-rtt = { version = "1.0.0", optional = true }
diff --git a/examples/boot/application/stm32l4/Cargo.toml b/examples/boot/application/stm32l4/Cargo.toml
index 03daeb0bc..abe0451fd 100644
--- a/examples/boot/application/stm32l4/Cargo.toml
+++ b/examples/boot/application/stm32l4/Cargo.toml
@@ -9,8 +9,8 @@ embassy-sync = { version = "0.7.0", path = "../../../../embassy-sync" }
9embassy-executor = { version = "0.7.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread"] } 9embassy-executor = { version = "0.7.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread"] }
10embassy-time = { version = "0.4.0", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } 10embassy-time = { version = "0.4.0", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] }
11embassy-stm32 = { version = "0.2.0", path = "../../../../embassy-stm32", features = ["stm32l475vg", "time-driver-any", "exti"] } 11embassy-stm32 = { version = "0.2.0", path = "../../../../embassy-stm32", features = ["stm32l475vg", "time-driver-any", "exti"] }
12embassy-boot-stm32 = { version = "0.3.0", path = "../../../../embassy-boot-stm32", features = [] } 12embassy-boot-stm32 = { version = "0.4.0", path = "../../../../embassy-boot-stm32", features = [] }
13embassy-embedded-hal = { version = "0.3.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.3.1", path = "../../../../embassy-embedded-hal" }
14 14
15defmt = { version = "1.0.1", optional = true } 15defmt = { version = "1.0.1", optional = true }
16defmt-rtt = { version = "1.0.0", optional = true } 16defmt-rtt = { version = "1.0.0", optional = true }
diff --git a/examples/boot/application/stm32wb-dfu/Cargo.toml b/examples/boot/application/stm32wb-dfu/Cargo.toml
index e582628aa..bc4681f79 100644
--- a/examples/boot/application/stm32wb-dfu/Cargo.toml
+++ b/examples/boot/application/stm32wb-dfu/Cargo.toml
@@ -9,9 +9,9 @@ embassy-sync = { version = "0.7.0", path = "../../../../embassy-sync" }
9embassy-executor = { version = "0.7.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread"] } 9embassy-executor = { version = "0.7.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread"] }
10embassy-time = { version = "0.4.0", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } 10embassy-time = { version = "0.4.0", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] }
11embassy-stm32 = { version = "0.2.0", path = "../../../../embassy-stm32", features = ["stm32wb55rg", "time-driver-any", "exti"] } 11embassy-stm32 = { version = "0.2.0", path = "../../../../embassy-stm32", features = ["stm32wb55rg", "time-driver-any", "exti"] }
12embassy-boot-stm32 = { version = "0.3.0", path = "../../../../embassy-boot-stm32", features = [] } 12embassy-boot-stm32 = { version = "0.4.0", path = "../../../../embassy-boot-stm32", features = [] }
13embassy-embedded-hal = { version = "0.3.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.3.1", path = "../../../../embassy-embedded-hal" }
14embassy-usb = { version = "0.4.0", path = "../../../../embassy-usb" } 14embassy-usb = { version = "0.5.0", path = "../../../../embassy-usb" }
15embassy-usb-dfu = { version = "0.1.0", path = "../../../../embassy-usb-dfu", features = ["application", "cortex-m"] } 15embassy-usb-dfu = { version = "0.1.0", path = "../../../../embassy-usb-dfu", features = ["application", "cortex-m"] }
16 16
17defmt = { version = "1.0.1", optional = true } 17defmt = { version = "1.0.1", optional = true }
diff --git a/examples/boot/application/stm32wl/Cargo.toml b/examples/boot/application/stm32wl/Cargo.toml
index 3ed04b472..0552d109a 100644
--- a/examples/boot/application/stm32wl/Cargo.toml
+++ b/examples/boot/application/stm32wl/Cargo.toml
@@ -9,8 +9,8 @@ embassy-sync = { version = "0.7.0", path = "../../../../embassy-sync" }
9embassy-executor = { version = "0.7.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread"] } 9embassy-executor = { version = "0.7.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread"] }
10embassy-time = { version = "0.4.0", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] } 10embassy-time = { version = "0.4.0", path = "../../../../embassy-time", features = [ "tick-hz-32_768"] }
11embassy-stm32 = { version = "0.2.0", path = "../../../../embassy-stm32", features = ["stm32wl55jc-cm4", "time-driver-any", "exti"] } 11embassy-stm32 = { version = "0.2.0", path = "../../../../embassy-stm32", features = ["stm32wl55jc-cm4", "time-driver-any", "exti"] }
12embassy-boot-stm32 = { version = "0.3.0", path = "../../../../embassy-boot-stm32", features = [] } 12embassy-boot-stm32 = { version = "0.4.0", path = "../../../../embassy-boot-stm32", features = [] }
13embassy-embedded-hal = { version = "0.3.0", path = "../../../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.3.1", path = "../../../../embassy-embedded-hal" }
14 14
15defmt = { version = "1.0.1", optional = true } 15defmt = { version = "1.0.1", optional = true }
16defmt-rtt = { version = "1.0.0", optional = true } 16defmt-rtt = { version = "1.0.0", optional = true }
diff --git a/examples/boot/bootloader/stm32wb-dfu/Cargo.toml b/examples/boot/bootloader/stm32wb-dfu/Cargo.toml
index 0bb93b12e..d101e6ace 100644
--- a/examples/boot/bootloader/stm32wb-dfu/Cargo.toml
+++ b/examples/boot/bootloader/stm32wb-dfu/Cargo.toml
@@ -18,7 +18,7 @@ embedded-storage = "0.3.1"
18embedded-storage-async = "0.4.0" 18embedded-storage-async = "0.4.0"
19cfg-if = "1.0.0" 19cfg-if = "1.0.0"
20embassy-usb-dfu = { version = "0.1.0", path = "../../../../embassy-usb-dfu", features = ["dfu", "cortex-m"] } 20embassy-usb-dfu = { version = "0.1.0", path = "../../../../embassy-usb-dfu", features = ["dfu", "cortex-m"] }
21embassy-usb = { version = "0.4.0", path = "../../../../embassy-usb", default-features = false } 21embassy-usb = { version = "0.5.0", path = "../../../../embassy-usb", default-features = false }
22embassy-futures = { version = "0.1.1", path = "../../../../embassy-futures" } 22embassy-futures = { version = "0.1.1", path = "../../../../embassy-futures" }
23 23
24[features] 24[features]
diff --git a/examples/lpc55s69/Cargo.toml b/examples/lpc55s69/Cargo.toml
index 7f81e9c7f..1724a22d4 100644
--- a/examples/lpc55s69/Cargo.toml
+++ b/examples/lpc55s69/Cargo.toml
@@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0"
6 6
7 7
8[dependencies] 8[dependencies]
9embassy-nxp = { version = "0.1.0", path = "../../embassy-nxp", features = ["rt"] } 9embassy-nxp = { version = "0.1.0", path = "../../embassy-nxp", features = ["lpc55", "rt", "defmt"] }
10embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt"] } 10embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt"] }
11embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 11embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] } 12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] }
diff --git a/examples/mimxrt1011/.cargo/config.toml b/examples/mimxrt1011/.cargo/config.toml
new file mode 100644
index 000000000..12f4b27b2
--- /dev/null
+++ b/examples/mimxrt1011/.cargo/config.toml
@@ -0,0 +1,8 @@
1[target.thumbv7em-none-eabihf]
2runner = 'probe-rs run --chip MIMXRT1010'
3
4[build]
5target = "thumbv7em-none-eabihf" # Cortex-M7
6
7[env]
8DEFMT_LOG = "trace"
diff --git a/examples/mimxrt1011/Cargo.toml b/examples/mimxrt1011/Cargo.toml
new file mode 100644
index 000000000..cf4e4c163
--- /dev/null
+++ b/examples/mimxrt1011/Cargo.toml
@@ -0,0 +1,29 @@
1[package]
2name = "embassy-imxrt1011-examples"
3version = "0.1.0"
4edition = "2021"
5license = "MIT or Apache-2.0"
6
7[dependencies]
8cortex-m = { version = "0.7.7", features = ["inline-asm", "critical-section-single-core"] }
9cortex-m-rt = "0.7.3"
10defmt = "1.0.1"
11defmt-rtt = "1.0.0"
12
13embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
14embassy-futures = { version = "0.1.1", path = "../../embassy-futures" }
15embassy-nxp = { version = "0.1.0", path = "../../embassy-nxp", features = ["defmt", "mimxrt1011", "unstable-pac", "time-driver-pit"] }
16embassy-time = { version = "0.4", path = "../../embassy-time", features = ["defmt", ] } # "defmt-timestamp-uptime" # RT1011 hard faults currently with this enabled.
17embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
18embedded-hal-1 = { package = "embedded-hal", version = "1.0" }
19embedded-hal-async = "1.0.0"
20
21imxrt-boot-gen = { version = "0.3.4", features = ["imxrt1010"] }
22panic-probe = { version = "1.0.0", features = ["print-defmt"] }
23panic-semihosting = "0.6.0"
24
25[build-dependencies]
26imxrt-rt = { version = "0.1.7", features = ["device"] }
27
28[profile.release]
29debug = 2
diff --git a/examples/mimxrt1011/build.rs b/examples/mimxrt1011/build.rs
new file mode 100644
index 000000000..99e172aba
--- /dev/null
+++ b/examples/mimxrt1011/build.rs
@@ -0,0 +1,14 @@
1use imxrt_rt::{Family, RuntimeBuilder};
2
3fn main() {
4 // The IMXRT1010-EVK technically has 128M of flash, but we only ever use 8MB so that the examples
5 // will build fine on the Adafruit Metro M7 boards.
6 RuntimeBuilder::from_flexspi(Family::Imxrt1010, 8 * 1024 * 1024)
7 .build()
8 .unwrap();
9
10 println!("cargo:rustc-link-arg-bins=--nmagic");
11 println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
12 // Not link.x, as imxrt-rt needs to do some special things
13 println!("cargo:rustc-link-arg-bins=-Timxrt-link.x");
14}
diff --git a/examples/mimxrt1011/src/bin/blinky.rs b/examples/mimxrt1011/src/bin/blinky.rs
new file mode 100644
index 000000000..a5d5de6b3
--- /dev/null
+++ b/examples/mimxrt1011/src/bin/blinky.rs
@@ -0,0 +1,48 @@
1//! This example works on the following boards:
2//! - IMXRT1010-EVK
3//! - Adafruit Metro M7 (with microSD or with AirLift), requires an external button
4//! - Makerdiary iMX RT1011 Nano Kit (TODO: currently untested, please change this)
5//!
6//! Although beware you will need to change the GPIO pins being used (scroll down).
7
8#![no_std]
9#![no_main]
10
11use defmt::info;
12use embassy_executor::Spawner;
13use embassy_nxp::gpio::{Level, Output};
14use embassy_time::Timer;
15// Must include `embassy_imxrt1011_examples` to ensure the FCB gets linked.
16use {defmt_rtt as _, embassy_imxrt1011_examples as _, panic_probe as _};
17
18#[embassy_executor::main]
19async fn main(_spawner: Spawner) -> ! {
20 let p = embassy_nxp::init(Default::default());
21 info!("Hello world!");
22
23 /* Pick the pins to use depending on your board. */
24
25 // IMXRT1010-EVK
26 //
27 // LED (D25)
28 let led = p.GPIO_11;
29
30 // Adafruit Metro M7 (both microSD and AirLift variants)
31 //
32 // The LED is connected to D13 on the board.
33 // let led = p.GPIO_03;
34
35 // Makerdiary iMX RT1011 Nano Kit
36 //
37 // LED0
38 // let led = p.GPIO_SD_04;
39
40 let mut led = Output::new(led, Level::Low);
41
42 loop {
43 Timer::after_millis(500).await;
44
45 info!("Toggle");
46 led.toggle();
47 }
48}
diff --git a/examples/mimxrt1011/src/bin/button.rs b/examples/mimxrt1011/src/bin/button.rs
new file mode 100644
index 000000000..e63d7171d
--- /dev/null
+++ b/examples/mimxrt1011/src/bin/button.rs
@@ -0,0 +1,62 @@
1//! This example works on the following boards:
2//! - IMXRT1010-EVK
3//! - Adafruit Metro M7 (with microSD or with AirLift), requires an external button
4//! - Makerdiary iMX RT1011 Nano Kit (TODO: currently untested, please change this)
5//!
6//! Although beware you will need to change the GPIO pins being used (scroll down).
7
8#![no_std]
9#![no_main]
10
11use defmt::info;
12use embassy_executor::Spawner;
13use embassy_nxp::gpio::{Input, Level, Output, Pull};
14// Must include `embassy_imxrt1011_examples` to ensure the FCB gets linked.
15use {defmt_rtt as _, embassy_imxrt1011_examples as _, panic_probe as _};
16
17#[embassy_executor::main]
18async fn main(_spawner: Spawner) -> ! {
19 let p = embassy_nxp::init(Default::default());
20 info!("Hello world!");
21
22 /* Pick the pins to use depending on your board. */
23
24 // IMXRT1010-EVK
25 //
26 // LED (D25) and user button (SW4)
27 let (led, button) = (p.GPIO_11, p.GPIO_SD_05);
28
29 // Adafruit Metro M7 (both microSD and AirLift variants)
30 //
31 // The LED is connected to D13 on the board.
32 //
33 // In particular the Metro M7 has no board user buttons, so you will need to connect a button.
34 // Any other GPIO pin can be used. GPIO_04 is used for example since it is on pin D12.
35 // let (led, button) = (p.GPIO_03, p.GPIO_04);
36
37 // Makerdiary iMX RT1011 Nano Kit
38 //
39 // LED0 and user button.
40 // let (led, button) = (p.GPIO_SD_04, p.GPIO_SD_03);
41
42 let mut button = Input::new(button, Pull::Up100K);
43 let mut led = Output::new(led, Level::Low);
44 led.set_high();
45
46 loop {
47 button.wait_for_falling_edge().await;
48
49 info!("Toggled");
50 led.toggle();
51
52 // The RT1010EVK has a 100 nF debouncing capacitor which results in false positive events
53 // when listening for a falling edge in a loop, wait for the rising edge and then wait for
54 // stabilization.
55 button.wait_for_rising_edge().await;
56
57 // Stabilization.
58 for _ in 0..100_000 {
59 cortex_m::asm::nop();
60 }
61 }
62}
diff --git a/examples/mimxrt1011/src/lib.rs b/examples/mimxrt1011/src/lib.rs
new file mode 100644
index 000000000..f0391ef57
--- /dev/null
+++ b/examples/mimxrt1011/src/lib.rs
@@ -0,0 +1,75 @@
1//! FlexSPI configuration block (FCB) for iMXRT1011 boards.
2//!
3//! This is a generic FCB that should work with most QSPI flash.
4
5#![no_std]
6
7use imxrt_boot_gen::flexspi;
8use imxrt_boot_gen::flexspi::opcodes::sdr::*;
9use imxrt_boot_gen::flexspi::{
10 ColumnAddressWidth, Command, DeviceModeConfiguration, FlashPadType, Instr, LookupTable, Pads,
11 ReadSampleClockSource, Sequence, SequenceBuilder, SerialClockFrequency, SerialFlashRegion,
12 WaitTimeConfigurationCommands,
13};
14use imxrt_boot_gen::serial_flash::nor;
15
16/// While the IMXRT1010-EVK and Makerdiary iMX RT1011 Nano Kit have 128MBit of flash we limit to 64Mbit
17/// to allow the Metro M7 boards to use the same FCB configuration.
18const DENSITY_BITS: u32 = 64 * 1024 * 1024;
19const DENSITY_BYTES: u32 = DENSITY_BITS / 8;
20
21const SEQ_READ: Sequence = SequenceBuilder::new()
22 .instr(Instr::new(CMD, Pads::One, 0xEB))
23 .instr(Instr::new(RADDR, Pads::Four, 0x18))
24 .instr(Instr::new(DUMMY, Pads::Four, 0x06))
25 .instr(Instr::new(READ, Pads::Four, 0x04))
26 .build();
27
28const SEQ_READ_STATUS: Sequence = SequenceBuilder::new()
29 .instr(Instr::new(CMD, Pads::One, 0x05))
30 .instr(Instr::new(READ, Pads::One, 0x01))
31 .build();
32
33const SEQ_WRITE_ENABLE: Sequence = SequenceBuilder::new().instr(Instr::new(CMD, Pads::One, 0x06)).build();
34
35const SEQ_ERASE_SECTOR: Sequence = SequenceBuilder::new()
36 .instr(Instr::new(CMD, Pads::One, 0x20))
37 .instr(Instr::new(RADDR, Pads::One, 0x18))
38 .build();
39
40const SEQ_PAGE_PROGRAM: Sequence = SequenceBuilder::new()
41 .instr(Instr::new(CMD, Pads::One, 0x02))
42 .instr(Instr::new(RADDR, Pads::One, 0x18))
43 .instr(Instr::new(WRITE, Pads::One, 0x04))
44 .build();
45
46const SEQ_CHIP_ERASE: Sequence = SequenceBuilder::new().instr(Instr::new(CMD, Pads::One, 0x60)).build();
47
48const LUT: LookupTable = LookupTable::new()
49 .command(Command::Read, SEQ_READ)
50 .command(Command::ReadStatus, SEQ_READ_STATUS)
51 .command(Command::WriteEnable, SEQ_WRITE_ENABLE)
52 .command(Command::EraseSector, SEQ_ERASE_SECTOR)
53 .command(Command::PageProgram, SEQ_PAGE_PROGRAM)
54 .command(Command::ChipErase, SEQ_CHIP_ERASE);
55
56const COMMON_CONFIGURATION_BLOCK: flexspi::ConfigurationBlock = flexspi::ConfigurationBlock::new(LUT)
57 .read_sample_clk_src(ReadSampleClockSource::LoopbackFromDQSPad)
58 .cs_hold_time(0x03)
59 .cs_setup_time(0x03)
60 .column_address_width(ColumnAddressWidth::OtherDevices)
61 .device_mode_configuration(DeviceModeConfiguration::Disabled)
62 .wait_time_cfg_commands(WaitTimeConfigurationCommands::disable())
63 .flash_size(SerialFlashRegion::A1, DENSITY_BYTES)
64 .serial_clk_freq(SerialClockFrequency::MHz120)
65 .serial_flash_pad_type(FlashPadType::Quad);
66
67pub const SERIAL_NOR_CONFIGURATION_BLOCK: nor::ConfigurationBlock =
68 nor::ConfigurationBlock::new(COMMON_CONFIGURATION_BLOCK)
69 .page_size(256)
70 .sector_size(4096)
71 .ip_cmd_serial_clk_freq(nor::SerialClockFrequency::MHz30);
72
73#[unsafe(no_mangle)]
74#[cfg_attr(all(target_arch = "arm", target_os = "none"), link_section = ".fcb")]
75pub static FLEXSPI_CONFIGURATION_BLOCK: nor::ConfigurationBlock = SERIAL_NOR_CONFIGURATION_BLOCK;
diff --git a/examples/mimxrt1062-evk/.cargo/config.toml b/examples/mimxrt1062-evk/.cargo/config.toml
new file mode 100644
index 000000000..ca4c606dc
--- /dev/null
+++ b/examples/mimxrt1062-evk/.cargo/config.toml
@@ -0,0 +1,8 @@
1[target.thumbv7em-none-eabihf]
2runner = 'probe-rs run --chip MIMXRT1060'
3
4[build]
5target = "thumbv7em-none-eabihf" # Cortex-M7
6
7[env]
8DEFMT_LOG = "trace"
diff --git a/examples/mimxrt1062-evk/Cargo.toml b/examples/mimxrt1062-evk/Cargo.toml
new file mode 100644
index 000000000..430a26b41
--- /dev/null
+++ b/examples/mimxrt1062-evk/Cargo.toml
@@ -0,0 +1,29 @@
1[package]
2name = "embassy-imxrt1062-evk-examples"
3version = "0.1.0"
4edition = "2021"
5license = "MIT or Apache-2.0"
6
7[dependencies]
8cortex-m = { version = "0.7.7", features = ["inline-asm", "critical-section-single-core"] }
9cortex-m-rt = "0.7.3"
10defmt = "1.0.1"
11defmt-rtt = "1.0.0"
12
13embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
14embassy-futures = { version = "0.1.1", path = "../../embassy-futures" }
15embassy-nxp = { version = "0.1.0", path = "../../embassy-nxp", features = ["defmt", "mimxrt1062", "unstable-pac", "time-driver-pit"] }
16embassy-time = { version = "0.4", path = "../../embassy-time", features = ["defmt", ] } # "defmt-timestamp-uptime"
17embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
18embedded-hal-1 = { package = "embedded-hal", version = "1.0" }
19embedded-hal-async = "1.0.0"
20
21imxrt-boot-gen = { version = "0.3.4", features = ["imxrt1060"] }
22panic-probe = { version = "1.0.0", features = ["print-defmt"] }
23panic-semihosting = "0.6.0"
24
25[build-dependencies]
26imxrt-rt = { version = "0.1.7", features = ["device"] }
27
28[profile.release]
29debug = 2
diff --git a/examples/mimxrt1062-evk/build.rs b/examples/mimxrt1062-evk/build.rs
new file mode 100644
index 000000000..e0e0d547e
--- /dev/null
+++ b/examples/mimxrt1062-evk/build.rs
@@ -0,0 +1,12 @@
1use imxrt_rt::{Family, RuntimeBuilder};
2
3fn main() {
4 RuntimeBuilder::from_flexspi(Family::Imxrt1060, 8 * 1024 * 1024)
5 .build()
6 .unwrap();
7
8 println!("cargo:rustc-link-arg-bins=--nmagic");
9 println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
10 // Not link.x, as imxrt-rt needs to do some special things
11 println!("cargo:rustc-link-arg-bins=-Timxrt-link.x");
12}
diff --git a/examples/mimxrt1062-evk/src/bin/blinky.rs b/examples/mimxrt1062-evk/src/bin/blinky.rs
new file mode 100644
index 000000000..b6d90d94d
--- /dev/null
+++ b/examples/mimxrt1062-evk/src/bin/blinky.rs
@@ -0,0 +1,25 @@
1#![no_std]
2#![no_main]
3
4use defmt::info;
5use embassy_executor::Spawner;
6use embassy_nxp::gpio::{Level, Output};
7use embassy_time::Timer;
8// Must include `embassy_imxrt1062_evk_examples` to ensure the FCB gets linked.
9use {defmt_rtt as _, embassy_imxrt1062_evk_examples as _, panic_probe as _};
10
11#[embassy_executor::main]
12async fn main(_spawner: Spawner) -> ! {
13 let p = embassy_nxp::init(Default::default());
14 info!("Hello world!");
15
16 let led = p.GPIO_AD_B0_08;
17 let mut led = Output::new(led, Level::Low);
18
19 loop {
20 Timer::after_millis(500).await;
21
22 info!("Toggle");
23 led.toggle();
24 }
25}
diff --git a/examples/mimxrt1062-evk/src/bin/button.rs b/examples/mimxrt1062-evk/src/bin/button.rs
new file mode 100644
index 000000000..d60fa3dac
--- /dev/null
+++ b/examples/mimxrt1062-evk/src/bin/button.rs
@@ -0,0 +1,36 @@
1#![no_std]
2#![no_main]
3
4use defmt::info;
5use embassy_executor::Spawner;
6use embassy_nxp::gpio::{Input, Level, Output, Pull};
7use {defmt_rtt as _, embassy_imxrt1062_evk_examples as _, panic_probe as _};
8
9#[embassy_executor::main]
10async fn main(_spawner: Spawner) -> ! {
11 let p = embassy_nxp::init(Default::default());
12 info!("Hello world!");
13
14 // User LED (D8)
15 let led = p.GPIO_AD_B0_08;
16 // User button (SW5)
17 let button = p.WAKEUP;
18 let mut button = Input::new(button, Pull::Up100K);
19 let mut led = Output::new(led, Level::Low);
20 led.set_high();
21
22 loop {
23 button.wait_for_falling_edge().await;
24
25 info!("Toggled");
26 led.toggle();
27
28 // Software debounce.
29 button.wait_for_rising_edge().await;
30
31 // Stabilization.
32 for _ in 0..100_000 {
33 cortex_m::asm::nop();
34 }
35 }
36}
diff --git a/examples/mimxrt1062-evk/src/lib.rs b/examples/mimxrt1062-evk/src/lib.rs
new file mode 100644
index 000000000..3f99f9db3
--- /dev/null
+++ b/examples/mimxrt1062-evk/src/lib.rs
@@ -0,0 +1,60 @@
1//! FlexSPI configuration block (FCB) for the iMXRT1060-EVK
2//!
3//! This uses IS25WP QuadSPI flash.
4
5#![no_std]
6
7use imxrt_boot_gen::flexspi::opcodes::sdr::*;
8use imxrt_boot_gen::flexspi::{self, FlashPadType, ReadSampleClockSource, SerialClockFrequency, SerialFlashRegion, *};
9use imxrt_boot_gen::serial_flash::*;
10pub use nor::ConfigurationBlock;
11
12const SEQ_READ: Sequence = SequenceBuilder::new()
13 .instr(Instr::new(CMD, Pads::One, 0xEB))
14 .instr(Instr::new(RADDR, Pads::Four, 0x18))
15 .instr(Instr::new(DUMMY, Pads::Four, 0x06))
16 .instr(Instr::new(READ, Pads::Four, 0x04))
17 .build();
18const SEQ_READ_STATUS: Sequence = SequenceBuilder::new()
19 .instr(Instr::new(CMD, Pads::One, 0x05))
20 .instr(Instr::new(READ, Pads::One, 0x04))
21 .build();
22const SEQ_WRITE_ENABLE: Sequence = SequenceBuilder::new().instr(Instr::new(CMD, Pads::One, 0x06)).build();
23const SEQ_ERASE_SECTOR: Sequence = SequenceBuilder::new()
24 .instr(Instr::new(CMD, Pads::One, 0x20))
25 .instr(Instr::new(RADDR, Pads::One, 0x18))
26 .build();
27const SEQ_PAGE_PROGRAM: Sequence = SequenceBuilder::new()
28 .instr(Instr::new(CMD, Pads::One, 0x02))
29 .instr(Instr::new(RADDR, Pads::One, 0x18))
30 .instr(Instr::new(WRITE, Pads::One, 0x04))
31 .build();
32const SEQ_CHIP_ERASE: Sequence = SequenceBuilder::new().instr(Instr::new(CMD, Pads::One, 0x60)).build();
33
34const LUT: LookupTable = LookupTable::new()
35 .command(Command::Read, SEQ_READ)
36 .command(Command::ReadStatus, SEQ_READ_STATUS)
37 .command(Command::WriteEnable, SEQ_WRITE_ENABLE)
38 .command(Command::EraseSector, SEQ_ERASE_SECTOR)
39 .command(Command::PageProgram, SEQ_PAGE_PROGRAM)
40 .command(Command::ChipErase, SEQ_CHIP_ERASE);
41
42const COMMON_CONFIGURATION_BLOCK: flexspi::ConfigurationBlock = flexspi::ConfigurationBlock::new(LUT)
43 .version(Version::new(1, 4, 0))
44 .read_sample_clk_src(ReadSampleClockSource::LoopbackFromDQSPad)
45 .cs_hold_time(3)
46 .cs_setup_time(3)
47 .controller_misc_options(0x10)
48 .serial_flash_pad_type(FlashPadType::Quad)
49 .serial_clk_freq(SerialClockFrequency::MHz133)
50 .flash_size(SerialFlashRegion::A1, 8 * 1024 * 1024);
51
52pub const SERIAL_NOR_CONFIGURATION_BLOCK: nor::ConfigurationBlock =
53 nor::ConfigurationBlock::new(COMMON_CONFIGURATION_BLOCK)
54 .page_size(256)
55 .sector_size(4096)
56 .ip_cmd_serial_clk_freq(nor::SerialClockFrequency::MHz30);
57
58#[no_mangle]
59#[cfg_attr(all(target_arch = "arm", target_os = "none"), link_section = ".fcb")]
60pub static FLEXSPI_CONFIGURATION_BLOCK: nor::ConfigurationBlock = SERIAL_NOR_CONFIGURATION_BLOCK;
diff --git a/examples/mspm0g3507/.cargo/config.toml b/examples/mspm0g3507/.cargo/config.toml
index 34c720cdd..e711afaf2 100644
--- a/examples/mspm0g3507/.cargo/config.toml
+++ b/examples/mspm0g3507/.cargo/config.toml
@@ -6,4 +6,4 @@ runner = "probe-rs run --chip MSPM0G3507 --protocol=swd"
6target = "thumbv6m-none-eabi" 6target = "thumbv6m-none-eabi"
7 7
8[env] 8[env]
9DEFMT_LOG = "debug" 9DEFMT_LOG = "trace"
diff --git a/examples/mspm0g3507/Cargo.toml b/examples/mspm0g3507/Cargo.toml
index b6621c9c5..cc40b3109 100644
--- a/examples/mspm0g3507/Cargo.toml
+++ b/examples/mspm0g3507/Cargo.toml
@@ -17,5 +17,7 @@ defmt-rtt = "1.0.0"
17panic-probe = { version = "1.0.0", features = ["print-defmt"] } 17panic-probe = { version = "1.0.0", features = ["print-defmt"] }
18panic-semihosting = "0.6.0" 18panic-semihosting = "0.6.0"
19 19
20embedded-io-async = "0.6.1"
21
20[profile.release] 22[profile.release]
21debug = 2 23debug = 2
diff --git a/examples/nrf-rtos-trace/Cargo.toml b/examples/nrf-rtos-trace/Cargo.toml
index d9e8ca2f9..f1c40192d 100644
--- a/examples/nrf-rtos-trace/Cargo.toml
+++ b/examples/nrf-rtos-trace/Cargo.toml
@@ -18,7 +18,7 @@ log = [
18embassy-sync = { version = "0.7.0", path = "../../embassy-sync" } 18embassy-sync = { version = "0.7.0", path = "../../embassy-sync" }
19embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "rtos-trace"] } 19embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "rtos-trace"] }
20embassy-time = { version = "0.4.0", path = "../../embassy-time" } 20embassy-time = { version = "0.4.0", path = "../../embassy-time" }
21embassy-nrf = { version = "0.3.1", path = "../../embassy-nrf", features = ["nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } 21embassy-nrf = { version = "0.5.0", path = "../../embassy-nrf", features = ["nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] }
22 22
23cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } 23cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
24cortex-m-rt = "0.7.0" 24cortex-m-rt = "0.7.0"
diff --git a/examples/nrf51/Cargo.toml b/examples/nrf51/Cargo.toml
index 91f78737f..a21d7f6ce 100644
--- a/examples/nrf51/Cargo.toml
+++ b/examples/nrf51/Cargo.toml
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
7[dependencies] 7[dependencies]
8embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } 8embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
9embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } 9embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
10embassy-nrf = { version = "0.3.1", path = "../../embassy-nrf", features = ["defmt", "nrf51", "gpiote", "time-driver-rtc1", "unstable-pac", "time", "rt"] } 10embassy-nrf = { version = "0.5.0", path = "../../embassy-nrf", features = ["defmt", "nrf51", "gpiote", "time-driver-rtc1", "unstable-pac", "time", "rt"] }
11 11
12defmt = "1.0.1" 12defmt = "1.0.1"
13defmt-rtt = "1.0.0" 13defmt-rtt = "1.0.0"
diff --git a/examples/nrf52810/Cargo.toml b/examples/nrf52810/Cargo.toml
index 87da89efe..baa873f22 100644
--- a/examples/nrf52810/Cargo.toml
+++ b/examples/nrf52810/Cargo.toml
@@ -9,7 +9,7 @@ embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
9embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 9embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
10embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } 10embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
11embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } 11embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
12embassy-nrf = { version = "0.3.1", path = "../../embassy-nrf", features = ["defmt", "nrf52810", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } 12embassy-nrf = { version = "0.5.0", path = "../../embassy-nrf", features = ["defmt", "nrf52810", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] }
13 13
14defmt = "1.0.1" 14defmt = "1.0.1"
15defmt-rtt = "1.0.0" 15defmt-rtt = "1.0.0"
diff --git a/examples/nrf52840-rtic/Cargo.toml b/examples/nrf52840-rtic/Cargo.toml
index afd269f72..3e499e9bc 100644
--- a/examples/nrf52840-rtic/Cargo.toml
+++ b/examples/nrf52840-rtic/Cargo.toml
@@ -11,7 +11,7 @@ embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
11embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 11embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = [ "defmt", "defmt-timestamp-uptime"] } 12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = [ "defmt", "defmt-timestamp-uptime"] }
13embassy-time-queue-utils = { version = "0.1", path = "../../embassy-time-queue-utils", features = ["generic-queue-8"] } 13embassy-time-queue-utils = { version = "0.1", path = "../../embassy-time-queue-utils", features = ["generic-queue-8"] }
14embassy-nrf = { version = "0.3.1", path = "../../embassy-nrf", features = [ "defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } 14embassy-nrf = { version = "0.5.0", path = "../../embassy-nrf", features = [ "defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] }
15 15
16defmt = "1.0.1" 16defmt = "1.0.1"
17defmt-rtt = "1.0.0" 17defmt-rtt = "1.0.0"
diff --git a/examples/nrf52840/Cargo.toml b/examples/nrf52840/Cargo.toml
index 4140e49d2..d2baebf8e 100644
--- a/examples/nrf52840/Cargo.toml
+++ b/examples/nrf52840/Cargo.toml
@@ -9,9 +9,9 @@ embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
9embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 9embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
10embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } 10embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
11embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } 11embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
12embassy-nrf = { version = "0.3.1", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } 12embassy-nrf = { version = "0.5.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] }
13embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"] } 13embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"] }
14embassy-usb = { version = "0.4.0", path = "../../embassy-usb", features = ["defmt"] } 14embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = ["defmt"] }
15embedded-io = { version = "0.6.0", features = ["defmt-03"] } 15embedded-io = { version = "0.6.0", features = ["defmt-03"] }
16embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } 16embedded-io-async = { version = "0.6.1", features = ["defmt-03"] }
17embassy-net-esp-hosted = { version = "0.2.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] } 17embassy-net-esp-hosted = { version = "0.2.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] }
diff --git a/examples/nrf52840/src/bin/self_spawn_current_executor.rs b/examples/nrf52840/src/bin/self_spawn_current_executor.rs
index ec9569a64..ddb40dc53 100644
--- a/examples/nrf52840/src/bin/self_spawn_current_executor.rs
+++ b/examples/nrf52840/src/bin/self_spawn_current_executor.rs
@@ -10,7 +10,8 @@ use {defmt_rtt as _, panic_probe as _};
10async fn my_task(n: u32) { 10async fn my_task(n: u32) {
11 Timer::after_secs(1).await; 11 Timer::after_secs(1).await;
12 info!("Spawning self! {}", n); 12 info!("Spawning self! {}", n);
13 unwrap!(Spawner::for_current_executor().await.spawn(my_task(n + 1))); 13 let spawner = unsafe { Spawner::for_current_executor().await };
14 unwrap!(spawner.spawn(my_task(n + 1)));
14} 15}
15 16
16#[embassy_executor::main] 17#[embassy_executor::main]
diff --git a/examples/nrf5340/Cargo.toml b/examples/nrf5340/Cargo.toml
index dc4fba4fd..bdebd5386 100644
--- a/examples/nrf5340/Cargo.toml
+++ b/examples/nrf5340/Cargo.toml
@@ -9,9 +9,9 @@ embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
9embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 9embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
10embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } 10embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] }
11embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } 11embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
12embassy-nrf = { version = "0.3.1", path = "../../embassy-nrf", features = ["defmt", "nrf5340-app-s", "time-driver-rtc1", "gpiote", "unstable-pac"] } 12embassy-nrf = { version = "0.5.0", path = "../../embassy-nrf", features = ["defmt", "nrf5340-app-s", "time-driver-rtc1", "gpiote", "unstable-pac"] }
13embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"] } 13embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"] }
14embassy-usb = { version = "0.4.0", path = "../../embassy-usb", features = ["defmt"] } 14embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = ["defmt"] }
15embedded-io-async = { version = "0.6.1" } 15embedded-io-async = { version = "0.6.1" }
16 16
17defmt = "1.0.1" 17defmt = "1.0.1"
diff --git a/examples/nrf54l15/Cargo.toml b/examples/nrf54l15/Cargo.toml
index 4b229d06d..27d5babee 100644
--- a/examples/nrf54l15/Cargo.toml
+++ b/examples/nrf54l15/Cargo.toml
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
7[dependencies] 7[dependencies]
8embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } 8embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
9embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } 9embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
10embassy-nrf = { version = "0.3.1", path = "../../embassy-nrf", features = ["defmt", "nrf54l15-app-s", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } 10embassy-nrf = { version = "0.5.0", path = "../../embassy-nrf", features = ["defmt", "nrf54l15-app-s", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] }
11 11
12defmt = "1.0.1" 12defmt = "1.0.1"
13defmt-rtt = "1.0.0" 13defmt-rtt = "1.0.0"
diff --git a/examples/nrf9151/ns/Cargo.toml b/examples/nrf9151/ns/Cargo.toml
index a083aa5e7..2a492b595 100644
--- a/examples/nrf9151/ns/Cargo.toml
+++ b/examples/nrf9151/ns/Cargo.toml
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
7[dependencies] 7[dependencies]
8embassy-executor = { version = "0.7.0", path = "../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } 8embassy-executor = { version = "0.7.0", path = "../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
9embassy-time = { version = "0.4.0", path = "../../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } 9embassy-time = { version = "0.4.0", path = "../../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
10embassy-nrf = { version = "0.3.1", path = "../../../embassy-nrf", features = ["defmt", "nrf9120-ns", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } 10embassy-nrf = { version = "0.5.0", path = "../../../embassy-nrf", features = ["defmt", "nrf9120-ns", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] }
11 11
12defmt = "1.0.1" 12defmt = "1.0.1"
13defmt-rtt = "1.0.0" 13defmt-rtt = "1.0.0"
diff --git a/examples/nrf9151/s/Cargo.toml b/examples/nrf9151/s/Cargo.toml
index ae98631ef..62ef3e4ce 100644
--- a/examples/nrf9151/s/Cargo.toml
+++ b/examples/nrf9151/s/Cargo.toml
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
7[dependencies] 7[dependencies]
8embassy-executor = { version = "0.7.0", path = "../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } 8embassy-executor = { version = "0.7.0", path = "../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
9embassy-time = { version = "0.4.0", path = "../../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } 9embassy-time = { version = "0.4.0", path = "../../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
10embassy-nrf = { version = "0.3.1", path = "../../../embassy-nrf", features = ["defmt", "nrf9120-s", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } 10embassy-nrf = { version = "0.5.0", path = "../../../embassy-nrf", features = ["defmt", "nrf9120-s", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] }
11 11
12defmt = "1.0.1" 12defmt = "1.0.1"
13defmt-rtt = "1.0.0" 13defmt-rtt = "1.0.0"
diff --git a/examples/nrf9160/Cargo.toml b/examples/nrf9160/Cargo.toml
index 25aedf624..c896afdbe 100644
--- a/examples/nrf9160/Cargo.toml
+++ b/examples/nrf9160/Cargo.toml
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
7[dependencies] 7[dependencies]
8embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } 8embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
9embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } 9embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
10embassy-nrf = { version = "0.3.1", path = "../../embassy-nrf", features = ["defmt", "nrf9160-s", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } 10embassy-nrf = { version = "0.5.0", path = "../../embassy-nrf", features = ["defmt", "nrf9160-s", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] }
11embassy-net-nrf91 = { version = "0.1.0", path = "../../embassy-net-nrf91", features = ["defmt"] } 11embassy-net-nrf91 = { version = "0.1.0", path = "../../embassy-net-nrf91", features = ["defmt"] }
12embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "proto-ipv4", "medium-ip"] } 12embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "proto-ipv4", "medium-ip"] }
13 13
diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml
index c8a132a5e..eefd69315 100644
--- a/examples/rp/Cargo.toml
+++ b/examples/rp/Cargo.toml
@@ -6,18 +6,18 @@ license = "MIT OR Apache-2.0"
6 6
7 7
8[dependencies] 8[dependencies]
9embassy-embedded-hal = { version = "0.3.0", path = "../../embassy-embedded-hal", features = ["defmt"] } 9embassy-embedded-hal = { version = "0.3.1", path = "../../embassy-embedded-hal", features = ["defmt"] }
10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } 11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } 12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
13embassy-rp = { version = "0.4.0", path = "../../embassy-rp", features = ["defmt", "unstable-pac", "time-driver", "critical-section-impl", "rp2040"] } 13embassy-rp = { version = "0.6.0", path = "../../embassy-rp", features = ["defmt", "unstable-pac", "time-driver", "critical-section-impl", "rp2040"] }
14embassy-usb = { version = "0.4.0", path = "../../embassy-usb", features = ["defmt"] } 14embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = ["defmt"] }
15embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "icmp", "tcp", "udp", "raw", "dhcpv4", "medium-ethernet", "dns", "proto-ipv4", "proto-ipv6", "multicast"] } 15embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "icmp", "tcp", "udp", "raw", "dhcpv4", "medium-ethernet", "dns", "proto-ipv4", "proto-ipv6", "multicast"] }
16embassy-net-wiznet = { version = "0.2.0", path = "../../embassy-net-wiznet", features = ["defmt"] } 16embassy-net-wiznet = { version = "0.2.0", path = "../../embassy-net-wiznet", features = ["defmt"] }
17embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 17embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
18embassy-usb-logger = { version = "0.4.0", path = "../../embassy-usb-logger" } 18embassy-usb-logger = { version = "0.5.0", path = "../../embassy-usb-logger" }
19cyw43 = { version = "0.3.0", path = "../../cyw43", features = ["defmt", "firmware-logs"] } 19cyw43 = { version = "0.4.0", path = "../../cyw43", features = ["defmt", "firmware-logs"] }
20cyw43-pio = { version = "0.4.0", path = "../../cyw43-pio", features = ["defmt"] } 20cyw43-pio = { version = "0.5.1", path = "../../cyw43-pio", features = ["defmt"] }
21 21
22defmt = "1.0.1" 22defmt = "1.0.1"
23defmt-rtt = "1.0.0" 23defmt-rtt = "1.0.0"
@@ -58,11 +58,5 @@ rand = { version = "0.9.0", default-features = false }
58embedded-sdmmc = "0.7.0" 58embedded-sdmmc = "0.7.0"
59 59
60[profile.release] 60[profile.release]
61debug = 2 61# Enable generation of debug symbols even on release builds
62lto = true 62debug = true
63opt-level = 'z'
64
65[profile.dev]
66debug = 2
67lto = true
68opt-level = "z"
diff --git a/examples/rp/src/bin/usb_raw_bulk.rs b/examples/rp/src/bin/usb_raw_bulk.rs
index 103269791..0747901d1 100644
--- a/examples/rp/src/bin/usb_raw_bulk.rs
+++ b/examples/rp/src/bin/usb_raw_bulk.rs
@@ -96,8 +96,8 @@ async fn main(_spawner: Spawner) {
96 let mut function = builder.function(0xFF, 0, 0); 96 let mut function = builder.function(0xFF, 0, 0);
97 let mut interface = function.interface(); 97 let mut interface = function.interface();
98 let mut alt = interface.alt_setting(0xFF, 0, 0, None); 98 let mut alt = interface.alt_setting(0xFF, 0, 0, None);
99 let mut read_ep = alt.endpoint_bulk_out(64); 99 let mut read_ep = alt.endpoint_bulk_out(None, 64);
100 let mut write_ep = alt.endpoint_bulk_in(64); 100 let mut write_ep = alt.endpoint_bulk_in(None, 64);
101 drop(function); 101 drop(function);
102 102
103 // Build the builder. 103 // Build the builder.
diff --git a/examples/rp/src/bin/usb_webusb.rs b/examples/rp/src/bin/usb_webusb.rs
index a5dc94d5b..5cecb92f0 100644
--- a/examples/rp/src/bin/usb_webusb.rs
+++ b/examples/rp/src/bin/usb_webusb.rs
@@ -125,8 +125,8 @@ impl<'d, D: Driver<'d>> WebEndpoints<'d, D> {
125 let mut iface = func.interface(); 125 let mut iface = func.interface();
126 let mut alt = iface.alt_setting(0xff, 0x00, 0x00, None); 126 let mut alt = iface.alt_setting(0xff, 0x00, 0x00, None);
127 127
128 let write_ep = alt.endpoint_bulk_in(config.max_packet_size); 128 let write_ep = alt.endpoint_bulk_in(None, config.max_packet_size);
129 let read_ep = alt.endpoint_bulk_out(config.max_packet_size); 129 let read_ep = alt.endpoint_bulk_out(None, config.max_packet_size);
130 130
131 WebEndpoints { write_ep, read_ep } 131 WebEndpoints { write_ep, read_ep }
132 } 132 }
diff --git a/examples/rp235x/Cargo.toml b/examples/rp235x/Cargo.toml
index c81b79ae1..4d3dc77b5 100644
--- a/examples/rp235x/Cargo.toml
+++ b/examples/rp235x/Cargo.toml
@@ -6,18 +6,18 @@ license = "MIT OR Apache-2.0"
6 6
7 7
8[dependencies] 8[dependencies]
9embassy-embedded-hal = { version = "0.3.0", path = "../../embassy-embedded-hal", features = ["defmt"] } 9embassy-embedded-hal = { version = "0.3.1", path = "../../embassy-embedded-hal", features = ["defmt"] }
10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } 11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } 12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
13embassy-rp = { version = "0.4.0", path = "../../embassy-rp", features = ["defmt", "unstable-pac", "time-driver", "critical-section-impl", "rp235xa", "binary-info"] } 13embassy-rp = { version = "0.6.0", path = "../../embassy-rp", features = ["defmt", "unstable-pac", "time-driver", "critical-section-impl", "rp235xa", "binary-info"] }
14embassy-usb = { version = "0.4.0", path = "../../embassy-usb", features = ["defmt"] } 14embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = ["defmt"] }
15embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "raw", "dhcpv4", "medium-ethernet", "dns"] } 15embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "udp", "raw", "dhcpv4", "medium-ethernet", "dns"] }
16embassy-net-wiznet = { version = "0.2.0", path = "../../embassy-net-wiznet", features = ["defmt"] } 16embassy-net-wiznet = { version = "0.2.0", path = "../../embassy-net-wiznet", features = ["defmt"] }
17embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 17embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
18embassy-usb-logger = { version = "0.4.0", path = "../../embassy-usb-logger" } 18embassy-usb-logger = { version = "0.5.0", path = "../../embassy-usb-logger" }
19cyw43 = { version = "0.3.0", path = "../../cyw43", features = ["defmt", "firmware-logs"] } 19cyw43 = { version = "0.4.0", path = "../../cyw43", features = ["defmt", "firmware-logs"] }
20cyw43-pio = { version = "0.4.0", path = "../../cyw43-pio", features = ["defmt"] } 20cyw43-pio = { version = "0.5.1", path = "../../cyw43-pio", features = ["defmt"] }
21 21
22defmt = "1.0.1" 22defmt = "1.0.1"
23defmt-rtt = "1.0.0" 23defmt-rtt = "1.0.0"
@@ -58,8 +58,5 @@ log = "0.4"
58embedded-sdmmc = "0.7.0" 58embedded-sdmmc = "0.7.0"
59 59
60[profile.release] 60[profile.release]
61debug = 2 61# Enable generation of debug symbols even on release builds
62 62debug = true
63[profile.dev]
64lto = true
65opt-level = "z"
diff --git a/examples/rp235x/memory.x b/examples/rp235x/memory.x
index c803896f6..4382e2065 100644
--- a/examples/rp235x/memory.x
+++ b/examples/rp235x/memory.x
@@ -17,8 +17,8 @@ MEMORY {
17 * of access times. 17 * of access times.
18 * Example: Separate stacks for core0 and core1. 18 * Example: Separate stacks for core0 and core1.
19 */ 19 */
20 SRAM4 : ORIGIN = 0x20080000, LENGTH = 4K 20 SRAM8 : ORIGIN = 0x20080000, LENGTH = 4K
21 SRAM5 : ORIGIN = 0x20081000, LENGTH = 4K 21 SRAM9 : ORIGIN = 0x20081000, LENGTH = 4K
22} 22}
23 23
24SECTIONS { 24SECTIONS {
diff --git a/examples/rp235x/src/bin/blinky_wifi.rs b/examples/rp235x/src/bin/blinky_wifi.rs
index 8c352ebc4..ef6057a1c 100644
--- a/examples/rp235x/src/bin/blinky_wifi.rs
+++ b/examples/rp235x/src/bin/blinky_wifi.rs
@@ -5,7 +5,7 @@
5#![no_std] 5#![no_std]
6#![no_main] 6#![no_main]
7 7
8use cyw43_pio::{PioSpi, DEFAULT_CLOCK_DIVIDER}; 8use cyw43_pio::{PioSpi, RM2_CLOCK_DIVIDER};
9use defmt::*; 9use defmt::*;
10use embassy_executor::Spawner; 10use embassy_executor::Spawner;
11use embassy_rp::bind_interrupts; 11use embassy_rp::bind_interrupts;
@@ -58,7 +58,9 @@ async fn main(spawner: Spawner) {
58 let spi = PioSpi::new( 58 let spi = PioSpi::new(
59 &mut pio.common, 59 &mut pio.common,
60 pio.sm0, 60 pio.sm0,
61 DEFAULT_CLOCK_DIVIDER, 61 // SPI communication won't work if the speed is too high, so we use a divider larger than `DEFAULT_CLOCK_DIVIDER`.
62 // See: https://github.com/embassy-rs/embassy/issues/3960.
63 RM2_CLOCK_DIVIDER,
62 pio.irq0, 64 pio.irq0,
63 cs, 65 cs,
64 p.PIN_24, 66 p.PIN_24,
diff --git a/examples/rp235x/src/bin/usb_webusb.rs b/examples/rp235x/src/bin/usb_webusb.rs
index 75d28c853..a68163b61 100644
--- a/examples/rp235x/src/bin/usb_webusb.rs
+++ b/examples/rp235x/src/bin/usb_webusb.rs
@@ -125,8 +125,8 @@ impl<'d, D: Driver<'d>> WebEndpoints<'d, D> {
125 let mut iface = func.interface(); 125 let mut iface = func.interface();
126 let mut alt = iface.alt_setting(0xff, 0x00, 0x00, None); 126 let mut alt = iface.alt_setting(0xff, 0x00, 0x00, None);
127 127
128 let write_ep = alt.endpoint_bulk_in(config.max_packet_size); 128 let write_ep = alt.endpoint_bulk_in(None, config.max_packet_size);
129 let read_ep = alt.endpoint_bulk_out(config.max_packet_size); 129 let read_ep = alt.endpoint_bulk_out(None, config.max_packet_size);
130 130
131 WebEndpoints { write_ep, read_ep } 131 WebEndpoints { write_ep, read_ep }
132 } 132 }
diff --git a/examples/stm32c0/Cargo.toml b/examples/stm32c0/Cargo.toml
index 4cf07cef4..70a7b0895 100644
--- a/examples/stm32c0/Cargo.toml
+++ b/examples/stm32c0/Cargo.toml
@@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0"
6 6
7[dependencies] 7[dependencies]
8# Change stm32c031c6 to your chip name, if necessary. 8# Change stm32c031c6 to your chip name, if necessary.
9embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = [ "defmt", "time-driver-any", "stm32c031c6", "memory-x", "unstable-pac", "exti"] } 9embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = [ "defmt", "time-driver-any", "stm32c031c6", "memory-x", "unstable-pac", "exti", "chrono"] }
10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } 11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] }
12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
@@ -19,6 +19,7 @@ cortex-m-rt = "0.7.0"
19embedded-hal = "0.2.6" 19embedded-hal = "0.2.6"
20panic-probe = { version = "1.0.0", features = ["print-defmt"] } 20panic-probe = { version = "1.0.0", features = ["print-defmt"] }
21heapless = { version = "0.8", default-features = false } 21heapless = { version = "0.8", default-features = false }
22chrono = { version = "^0.4", default-features = false}
22 23
23[profile.release] 24[profile.release]
24debug = 2 25debug = 2
diff --git a/examples/stm32c0/src/bin/rtc.rs b/examples/stm32c0/src/bin/rtc.rs
new file mode 100644
index 000000000..82d8a37ba
--- /dev/null
+++ b/examples/stm32c0/src/bin/rtc.rs
@@ -0,0 +1,35 @@
1#![no_std]
2#![no_main]
3
4use chrono::{NaiveDate, NaiveDateTime};
5use defmt::*;
6use embassy_executor::Spawner;
7use embassy_stm32::rtc::{Rtc, RtcConfig};
8use embassy_stm32::Config;
9use embassy_time::Timer;
10use {defmt_rtt as _, panic_probe as _};
11
12#[embassy_executor::main]
13async fn main(_spawner: Spawner) {
14 let config = Config::default();
15 let p = embassy_stm32::init(config);
16
17 info!("Hello World!");
18
19 let now = NaiveDate::from_ymd_opt(2020, 5, 15)
20 .unwrap()
21 .and_hms_opt(10, 30, 15)
22 .unwrap();
23
24 let mut rtc = Rtc::new(p.RTC, RtcConfig::default());
25
26 rtc.set_datetime(now.into()).expect("datetime not set");
27
28 loop {
29 let now: NaiveDateTime = rtc.now().unwrap().into();
30
31 info!("{}", now.and_utc().timestamp());
32
33 Timer::after_millis(1000).await;
34 }
35}
diff --git a/examples/stm32f0/src/bin/adc-watchdog.rs b/examples/stm32f0/src/bin/adc-watchdog.rs
new file mode 100644
index 000000000..ff98aac8e
--- /dev/null
+++ b/examples/stm32f0/src/bin/adc-watchdog.rs
@@ -0,0 +1,34 @@
1#![no_std]
2#![no_main]
3
4use defmt::*;
5use embassy_executor::Spawner;
6use embassy_stm32::adc::{self, Adc, WatchdogChannels};
7use embassy_stm32::bind_interrupts;
8use embassy_stm32::peripherals::ADC1;
9use {defmt_rtt as _, panic_probe as _};
10
11bind_interrupts!(struct Irqs {
12 ADC1_COMP => adc::InterruptHandler<ADC1>;
13});
14
15#[embassy_executor::main]
16async fn main(_spawner: Spawner) {
17 let p = embassy_stm32::init(Default::default());
18 info!("ADC watchdog example");
19
20 let mut adc = Adc::new(p.ADC1, Irqs);
21 let pin = p.PC1;
22
23 loop {
24 // Wait for pin to go high
25 adc.init_watchdog(WatchdogChannels::from_channel(&pin), 0, 0x07F);
26 let v_high = adc.monitor_watchdog().await;
27 info!("ADC sample is high {}", v_high);
28
29 // Wait for pin to go low
30 adc.init_watchdog(WatchdogChannels::from_channel(&pin), 0x01f, 0xFFF);
31 let v_low = adc.monitor_watchdog().await;
32 info!("ADC sample is low {}", v_low);
33 }
34}
diff --git a/examples/stm32f1/Cargo.toml b/examples/stm32f1/Cargo.toml
index 261733305..01f4fd84a 100644
--- a/examples/stm32f1/Cargo.toml
+++ b/examples/stm32f1/Cargo.toml
@@ -10,7 +10,7 @@ embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = [
10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } 11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] }
12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-usb = { version = "0.4.0", path = "../../embassy-usb", features = ["defmt"] } 13embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = ["defmt"] }
14embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 14embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
15 15
16defmt = "1.0.1" 16defmt = "1.0.1"
diff --git a/examples/stm32f1/src/bin/input_capture.rs b/examples/stm32f1/src/bin/input_capture.rs
index 6fe8e0b50..84811fb95 100644
--- a/examples/stm32f1/src/bin/input_capture.rs
+++ b/examples/stm32f1/src/bin/input_capture.rs
@@ -39,7 +39,7 @@ async fn main(spawner: Spawner) {
39 39
40 unwrap!(spawner.spawn(blinky(p.PC13))); 40 unwrap!(spawner.spawn(blinky(p.PC13)));
41 41
42 let ch3 = CapturePin::new_ch3(p.PA2, Pull::None); 42 let ch3 = CapturePin::new(p.PA2, Pull::None);
43 let mut ic = InputCapture::new(p.TIM2, None, None, Some(ch3), None, Irqs, khz(1000), Default::default()); 43 let mut ic = InputCapture::new(p.TIM2, None, None, Some(ch3), None, Irqs, khz(1000), Default::default());
44 44
45 loop { 45 loop {
diff --git a/examples/stm32f1/src/bin/pwm_input.rs b/examples/stm32f1/src/bin/pwm_input.rs
index afbef3edb..aa6a11ff8 100644
--- a/examples/stm32f1/src/bin/pwm_input.rs
+++ b/examples/stm32f1/src/bin/pwm_input.rs
@@ -38,7 +38,7 @@ async fn main(spawner: Spawner) {
38 38
39 unwrap!(spawner.spawn(blinky(p.PC13))); 39 unwrap!(spawner.spawn(blinky(p.PC13)));
40 40
41 let mut pwm_input = PwmInput::new(p.TIM2, p.PA0, Pull::None, khz(10)); 41 let mut pwm_input = PwmInput::new_ch1(p.TIM2, p.PA0, Pull::None, khz(10));
42 pwm_input.enable(); 42 pwm_input.enable();
43 43
44 loop { 44 loop {
diff --git a/examples/stm32f3/Cargo.toml b/examples/stm32f3/Cargo.toml
index f675b0be1..ab7d6b255 100644
--- a/examples/stm32f3/Cargo.toml
+++ b/examples/stm32f3/Cargo.toml
@@ -10,7 +10,7 @@ embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = [
10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } 11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-usb = { version = "0.4.0", path = "../../embassy-usb", features = ["defmt"] } 13embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = ["defmt"] }
14embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 14embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
15 15
16defmt = "1.0.1" 16defmt = "1.0.1"
diff --git a/examples/stm32f334/Cargo.toml b/examples/stm32f334/Cargo.toml
index b47a81e1b..6595804e1 100644
--- a/examples/stm32f334/Cargo.toml
+++ b/examples/stm32f334/Cargo.toml
@@ -9,7 +9,7 @@ embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["de
9embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } 9embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
10embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 10embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
11embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = [ "defmt", "stm32f334r8", "unstable-pac", "memory-x", "time-driver-any", "exti"] } 11embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = [ "defmt", "stm32f334r8", "unstable-pac", "memory-x", "time-driver-any", "exti"] }
12embassy-usb = { version = "0.4.0", path = "../../embassy-usb", features = ["defmt"] } 12embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = ["defmt"] }
13embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 13embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
14 14
15defmt = "1.0.1" 15defmt = "1.0.1"
diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml
index edab9ea00..80c43f2ab 100644
--- a/examples/stm32f4/Cargo.toml
+++ b/examples/stm32f4/Cargo.toml
@@ -10,7 +10,7 @@ embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = ["
10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } 11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-usb = { version = "0.4.0", path = "../../embassy-usb", features = ["defmt" ] } 13embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = ["defmt" ] }
14embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] } 14embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] }
15embassy-net-wiznet = { version = "0.2.0", path = "../../embassy-net-wiznet", features = ["defmt"] } 15embassy-net-wiznet = { version = "0.2.0", path = "../../embassy-net-wiznet", features = ["defmt"] }
16embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 16embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
diff --git a/examples/stm32f4/src/bin/input_capture.rs b/examples/stm32f4/src/bin/input_capture.rs
index fe5e2bdfc..e15b4d26e 100644
--- a/examples/stm32f4/src/bin/input_capture.rs
+++ b/examples/stm32f4/src/bin/input_capture.rs
@@ -39,7 +39,7 @@ async fn main(spawner: Spawner) {
39 39
40 unwrap!(spawner.spawn(blinky(p.PB2))); 40 unwrap!(spawner.spawn(blinky(p.PB2)));
41 41
42 let ch3 = CapturePin::new_ch3(p.PB10, Pull::None); 42 let ch3 = CapturePin::new(p.PB10, Pull::None);
43 let mut ic = InputCapture::new(p.TIM2, None, None, Some(ch3), None, Irqs, khz(1000), Default::default()); 43 let mut ic = InputCapture::new(p.TIM2, None, None, Some(ch3), None, Irqs, khz(1000), Default::default());
44 44
45 loop { 45 loop {
diff --git a/examples/stm32f4/src/bin/pwm.rs b/examples/stm32f4/src/bin/pwm.rs
index 04811162b..e385842f0 100644
--- a/examples/stm32f4/src/bin/pwm.rs
+++ b/examples/stm32f4/src/bin/pwm.rs
@@ -14,7 +14,7 @@ async fn main(_spawner: Spawner) {
14 let p = embassy_stm32::init(Default::default()); 14 let p = embassy_stm32::init(Default::default());
15 info!("Hello World!"); 15 info!("Hello World!");
16 16
17 let ch1_pin = PwmPin::new_ch1(p.PE9, OutputType::PushPull); 17 let ch1_pin = PwmPin::new(p.PE9, OutputType::PushPull);
18 let mut pwm = SimplePwm::new(p.TIM1, Some(ch1_pin), None, None, None, khz(10), Default::default()); 18 let mut pwm = SimplePwm::new(p.TIM1, Some(ch1_pin), None, None, None, khz(10), Default::default());
19 let mut ch1 = pwm.ch1(); 19 let mut ch1 = pwm.ch1();
20 ch1.enable(); 20 ch1.enable();
diff --git a/examples/stm32f4/src/bin/pwm_complementary.rs b/examples/stm32f4/src/bin/pwm_complementary.rs
index 161f43c48..c981f1a76 100644
--- a/examples/stm32f4/src/bin/pwm_complementary.rs
+++ b/examples/stm32f4/src/bin/pwm_complementary.rs
@@ -16,8 +16,8 @@ async fn main(_spawner: Spawner) {
16 let p = embassy_stm32::init(Default::default()); 16 let p = embassy_stm32::init(Default::default());
17 info!("Hello World!"); 17 info!("Hello World!");
18 18
19 let ch1 = PwmPin::new_ch1(p.PE9, OutputType::PushPull); 19 let ch1 = PwmPin::new(p.PE9, OutputType::PushPull);
20 let ch1n = ComplementaryPwmPin::new_ch1(p.PA7, OutputType::PushPull); 20 let ch1n = ComplementaryPwmPin::new(p.PA7, OutputType::PushPull);
21 let mut pwm = ComplementaryPwm::new( 21 let mut pwm = ComplementaryPwm::new(
22 p.TIM1, 22 p.TIM1,
23 Some(ch1), 23 Some(ch1),
diff --git a/examples/stm32f4/src/bin/pwm_input.rs b/examples/stm32f4/src/bin/pwm_input.rs
index 465cbe4f5..74167cbf2 100644
--- a/examples/stm32f4/src/bin/pwm_input.rs
+++ b/examples/stm32f4/src/bin/pwm_input.rs
@@ -38,7 +38,7 @@ async fn main(spawner: Spawner) {
38 38
39 unwrap!(spawner.spawn(blinky(p.PB2))); 39 unwrap!(spawner.spawn(blinky(p.PB2)));
40 40
41 let mut pwm_input = PwmInput::new(p.TIM3, p.PA6, Pull::None, khz(10)); 41 let mut pwm_input = PwmInput::new_ch1(p.TIM3, p.PA6, Pull::None, khz(10));
42 pwm_input.enable(); 42 pwm_input.enable();
43 43
44 loop { 44 loop {
diff --git a/examples/stm32f4/src/bin/ws2812_pwm.rs b/examples/stm32f4/src/bin/ws2812_pwm.rs
index ca924e181..5153e1cfd 100644
--- a/examples/stm32f4/src/bin/ws2812_pwm.rs
+++ b/examples/stm32f4/src/bin/ws2812_pwm.rs
@@ -50,7 +50,7 @@ async fn main(_spawner: Spawner) {
50 50
51 let mut ws2812_pwm = SimplePwm::new( 51 let mut ws2812_pwm = SimplePwm::new(
52 dp.TIM3, 52 dp.TIM3,
53 Some(PwmPin::new_ch1(dp.PB4, OutputType::PushPull)), 53 Some(PwmPin::new(dp.PB4, OutputType::PushPull)),
54 None, 54 None,
55 None, 55 None,
56 None, 56 None,
diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml
index c5801ea90..5995211d2 100644
--- a/examples/stm32f7/Cargo.toml
+++ b/examples/stm32f7/Cargo.toml
@@ -12,7 +12,7 @@ embassy-executor = { version = "0.7.0", path = "../../embassy-executor", feature
12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"] } 13embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"] }
14embedded-io-async = { version = "0.6.1" } 14embedded-io-async = { version = "0.6.1" }
15embassy-usb = { version = "0.4.0", path = "../../embassy-usb", features = ["defmt"] } 15embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = ["defmt"] }
16embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 16embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
17 17
18defmt = "1.0.1" 18defmt = "1.0.1"
diff --git a/examples/stm32f7/src/bin/cryp.rs b/examples/stm32f7/src/bin/cryp.rs
index 235853cb9..a31e9b4f2 100644
--- a/examples/stm32f7/src/bin/cryp.rs
+++ b/examples/stm32f7/src/bin/cryp.rs
@@ -68,7 +68,9 @@ async fn main(_spawner: Spawner) -> ! {
68 ); 68 );
69 69
70 // Decrypt in software using AES-GCM 128-bit 70 // Decrypt in software using AES-GCM 128-bit
71 let _ = cipher.decrypt_in_place(&iv.into(), aad.into(), &mut payload_vec); 71 cipher
72 .decrypt_in_place(&iv.into(), aad.into(), &mut payload_vec)
73 .unwrap();
72 74
73 let sw_end_time = Instant::now(); 75 let sw_end_time = Instant::now();
74 let sw_execution_time = sw_end_time - sw_start_time; 76 let sw_execution_time = sw_end_time - sw_start_time;
diff --git a/examples/stm32f7/src/bin/qspi.rs b/examples/stm32f7/src/bin/qspi.rs
index bd3287964..ab29ddeff 100644
--- a/examples/stm32f7/src/bin/qspi.rs
+++ b/examples/stm32f7/src/bin/qspi.rs
@@ -279,6 +279,7 @@ async fn main(_spawner: Spawner) -> ! {
279 prescaler: 16, 279 prescaler: 16,
280 cs_high_time: ChipSelectHighTime::_1Cycle, 280 cs_high_time: ChipSelectHighTime::_1Cycle,
281 fifo_threshold: FIFOThresholdLevel::_16Bytes, 281 fifo_threshold: FIFOThresholdLevel::_16Bytes,
282 sample_shifting: SampleShifting::None,
282 }; 283 };
283 let driver = Qspi::new_bank1( 284 let driver = Qspi::new_bank1(
284 p.QUADSPI, p.PF8, p.PF9, p.PE2, p.PF6, p.PF10, p.PB10, p.DMA2_CH7, config, 285 p.QUADSPI, p.PF8, p.PF9, p.PE2, p.PF6, p.PF10, p.PB10, p.DMA2_CH7, config,
diff --git a/examples/stm32g0/Cargo.toml b/examples/stm32g0/Cargo.toml
index bf1e7250e..1c290fcfa 100644
--- a/examples/stm32g0/Cargo.toml
+++ b/examples/stm32g0/Cargo.toml
@@ -10,7 +10,7 @@ embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = [
10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } 11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] }
12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-usb = { version = "0.4.0", path = "../../embassy-usb", default-features = false, features = ["defmt"] } 13embassy-usb = { version = "0.5.0", path = "../../embassy-usb", default-features = false, features = ["defmt"] }
14embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 14embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
15 15
16defmt = "1.0.1" 16defmt = "1.0.1"
diff --git a/examples/stm32g0/src/bin/hf_timer.rs b/examples/stm32g0/src/bin/hf_timer.rs
index dfb6e0edc..705905f01 100644
--- a/examples/stm32g0/src/bin/hf_timer.rs
+++ b/examples/stm32g0/src/bin/hf_timer.rs
@@ -37,8 +37,8 @@ async fn main(_spawner: Spawner) {
37 } 37 }
38 let p = embassy_stm32::init(config); 38 let p = embassy_stm32::init(config);
39 39
40 let ch1 = PwmPin::new_ch1(p.PA8, OutputType::PushPull); 40 let ch1 = PwmPin::new(p.PA8, OutputType::PushPull);
41 let ch1n = ComplementaryPwmPin::new_ch1(p.PA7, OutputType::PushPull); 41 let ch1n = ComplementaryPwmPin::new(p.PA7, OutputType::PushPull);
42 42
43 let mut pwm = ComplementaryPwm::new( 43 let mut pwm = ComplementaryPwm::new(
44 p.TIM1, 44 p.TIM1,
diff --git a/examples/stm32g0/src/bin/input_capture.rs b/examples/stm32g0/src/bin/input_capture.rs
index 08df4e043..df339d541 100644
--- a/examples/stm32g0/src/bin/input_capture.rs
+++ b/examples/stm32g0/src/bin/input_capture.rs
@@ -47,12 +47,12 @@ async fn main(spawner: Spawner) {
47 unwrap!(spawner.spawn(blinky(p.PB1))); 47 unwrap!(spawner.spawn(blinky(p.PB1)));
48 48
49 // Connect PB1 and PA8 with a 1k Ohm resistor 49 // Connect PB1 and PA8 with a 1k Ohm resistor
50 let ch1_pin = PwmPin::new_ch1(p.PA8, OutputType::PushPull); 50 let ch1_pin = PwmPin::new(p.PA8, OutputType::PushPull);
51 let mut pwm = SimplePwm::new(p.TIM1, Some(ch1_pin), None, None, None, khz(1), Default::default()); 51 let mut pwm = SimplePwm::new(p.TIM1, Some(ch1_pin), None, None, None, khz(1), Default::default());
52 pwm.ch1().enable(); 52 pwm.ch1().enable();
53 pwm.ch1().set_duty_cycle(50); 53 pwm.ch1().set_duty_cycle(50);
54 54
55 let ch1 = CapturePin::new_ch1(p.PA0, Pull::None); 55 let ch1 = CapturePin::new(p.PA0, Pull::None);
56 let mut ic = InputCapture::new(p.TIM2, Some(ch1), None, None, None, Irqs, khz(1000), Default::default()); 56 let mut ic = InputCapture::new(p.TIM2, Some(ch1), None, None, None, Irqs, khz(1000), Default::default());
57 57
58 let mut old_capture = 0; 58 let mut old_capture = 0;
diff --git a/examples/stm32g0/src/bin/pwm_complementary.rs b/examples/stm32g0/src/bin/pwm_complementary.rs
index 97b163c40..dbd9194c9 100644
--- a/examples/stm32g0/src/bin/pwm_complementary.rs
+++ b/examples/stm32g0/src/bin/pwm_complementary.rs
@@ -26,10 +26,10 @@ use {defmt_rtt as _, panic_probe as _};
26async fn main(_spawner: Spawner) { 26async fn main(_spawner: Spawner) {
27 let p = embassy_stm32::init(Default::default()); 27 let p = embassy_stm32::init(Default::default());
28 28
29 let ch1 = PwmPin::new_ch1(p.PA8, OutputType::PushPull); 29 let ch1 = PwmPin::new(p.PA8, OutputType::PushPull);
30 let ch1n = ComplementaryPwmPin::new_ch1(p.PA7, OutputType::PushPull); 30 let ch1n = ComplementaryPwmPin::new(p.PA7, OutputType::PushPull);
31 let ch2 = PwmPin::new_ch2(p.PB3, OutputType::PushPull); 31 let ch2 = PwmPin::new(p.PB3, OutputType::PushPull);
32 let ch2n = ComplementaryPwmPin::new_ch2(p.PB0, OutputType::PushPull); 32 let ch2n = ComplementaryPwmPin::new(p.PB0, OutputType::PushPull);
33 33
34 let mut pwm = ComplementaryPwm::new( 34 let mut pwm = ComplementaryPwm::new(
35 p.TIM1, 35 p.TIM1,
diff --git a/examples/stm32g0/src/bin/pwm_input.rs b/examples/stm32g0/src/bin/pwm_input.rs
index 9d6b5fe97..fd4f53f1e 100644
--- a/examples/stm32g0/src/bin/pwm_input.rs
+++ b/examples/stm32g0/src/bin/pwm_input.rs
@@ -42,12 +42,12 @@ async fn main(spawner: Spawner) {
42 42
43 unwrap!(spawner.spawn(blinky(p.PB1))); 43 unwrap!(spawner.spawn(blinky(p.PB1)));
44 // Connect PA8 and PA6 with a 1k Ohm resistor 44 // Connect PA8 and PA6 with a 1k Ohm resistor
45 let ch1_pin = PwmPin::new_ch1(p.PA8, OutputType::PushPull); 45 let ch1_pin = PwmPin::new(p.PA8, OutputType::PushPull);
46 let mut pwm = SimplePwm::new(p.TIM1, Some(ch1_pin), None, None, None, khz(1), Default::default()); 46 let mut pwm = SimplePwm::new(p.TIM1, Some(ch1_pin), None, None, None, khz(1), Default::default());
47 pwm.ch1().set_duty_cycle_fraction(1, 4); 47 pwm.ch1().set_duty_cycle_fraction(1, 4);
48 pwm.ch1().enable(); 48 pwm.ch1().enable();
49 49
50 let mut pwm_input = PwmInput::new(p.TIM2, p.PA0, Pull::None, khz(1000)); 50 let mut pwm_input = PwmInput::new_ch1(p.TIM2, p.PA0, Pull::None, khz(1000));
51 pwm_input.enable(); 51 pwm_input.enable();
52 52
53 loop { 53 loop {
diff --git a/examples/stm32g4/Cargo.toml b/examples/stm32g4/Cargo.toml
index 3d2c2aa7d..a503420e5 100644
--- a/examples/stm32g4/Cargo.toml
+++ b/examples/stm32g4/Cargo.toml
@@ -10,7 +10,7 @@ embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = [
10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } 11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] }
12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-usb = { version = "0.4.0", path = "../../embassy-usb", features = ["defmt"] } 13embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = ["defmt"] }
14embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 14embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
15usbd-hid = "0.8.1" 15usbd-hid = "0.8.1"
16 16
diff --git a/examples/stm32g4/src/bin/i2c_slave.rs b/examples/stm32g4/src/bin/i2c_slave.rs
new file mode 100644
index 000000000..a723a0e18
--- /dev/null
+++ b/examples/stm32g4/src/bin/i2c_slave.rs
@@ -0,0 +1,149 @@
1//! This example shows how to use an stm32 as both a master and a slave.
2#![no_std]
3#![no_main]
4
5use defmt::*;
6use embassy_executor::Spawner;
7use embassy_stm32::i2c::{Address, OwnAddresses, SlaveCommandKind};
8use embassy_stm32::mode::Async;
9use embassy_stm32::time::Hertz;
10use embassy_stm32::{bind_interrupts, i2c, peripherals};
11use embassy_time::Timer;
12use {defmt_rtt as _, panic_probe as _};
13
14bind_interrupts!(struct Irqs {
15 I2C1_ER => i2c::ErrorInterruptHandler<peripherals::I2C1>;
16 I2C1_EV => i2c::EventInterruptHandler<peripherals::I2C1>;
17 I2C2_ER => i2c::ErrorInterruptHandler<peripherals::I2C2>;
18 I2C2_EV => i2c::EventInterruptHandler<peripherals::I2C2>;
19});
20
21const DEV_ADDR: u8 = 0x42;
22
23#[embassy_executor::task]
24async fn device_task(mut dev: i2c::I2c<'static, Async, i2c::MultiMaster>) -> ! {
25 info!("Device start");
26
27 let mut state = 0;
28
29 loop {
30 let mut buf = [0u8; 128];
31 match dev.listen().await {
32 Ok(i2c::SlaveCommand {
33 kind: SlaveCommandKind::Read,
34 address: Address::SevenBit(DEV_ADDR),
35 }) => match dev.respond_to_read(&[state]).await {
36 Ok(i2c::SendStatus::LeftoverBytes(x)) => info!("tried to write {} extra bytes", x),
37 Ok(i2c::SendStatus::Done) => {}
38 Err(e) => error!("error while responding {}", e),
39 },
40 Ok(i2c::SlaveCommand {
41 kind: SlaveCommandKind::Write,
42 address: Address::SevenBit(DEV_ADDR),
43 }) => match dev.respond_to_write(&mut buf).await {
44 Ok(len) => {
45 info!("Device received write: {}", buf[..len]);
46
47 if match buf[0] {
48 // Set the state
49 0xC2 => {
50 state = buf[1];
51 true
52 }
53 // Reset State
54 0xC8 => {
55 state = 0;
56 true
57 }
58 x => {
59 error!("Invalid Write Read {:x}", x);
60 false
61 }
62 } {
63 match dev.respond_to_read(&[state]).await {
64 Ok(read_status) => info!(
65 "This read is part of a write/read transaction. The response read status {}",
66 read_status
67 ),
68 Err(i2c::Error::Timeout) => {
69 info!("The device only performed a write and it not also do a read")
70 }
71 Err(e) => error!("error while responding {}", e),
72 }
73 }
74 }
75 Err(e) => error!("error while receiving {}", e),
76 },
77 Ok(i2c::SlaveCommand { address, .. }) => {
78 defmt::unreachable!(
79 "The slave matched address: {}, which it was not configured for",
80 address
81 );
82 }
83 Err(e) => error!("{}", e),
84 }
85 }
86}
87
88#[embassy_executor::task]
89async fn controller_task(mut con: i2c::I2c<'static, Async, i2c::Master>) {
90 info!("Controller start");
91
92 loop {
93 let mut resp_buff = [0u8; 1];
94 for i in 0..10 {
95 match con.write_read(DEV_ADDR, &[0xC2, i], &mut resp_buff).await {
96 Ok(_) => {
97 info!("write_read response: {}", resp_buff);
98 defmt::assert_eq!(resp_buff[0], i);
99 }
100 Err(e) => error!("Error writing {}", e),
101 }
102
103 Timer::after_millis(100).await;
104 }
105 match con.read(DEV_ADDR, &mut resp_buff).await {
106 Ok(_) => {
107 info!("read response: {}", resp_buff);
108 // assert that the state is the last index that was written
109 defmt::assert_eq!(resp_buff[0], 9);
110 }
111 Err(e) => error!("Error writing {}", e),
112 }
113 match con.write_read(DEV_ADDR, &[0xC8], &mut resp_buff).await {
114 Ok(_) => {
115 info!("write_read response: {}", resp_buff);
116 // assert that the state has been reset
117 defmt::assert_eq!(resp_buff[0], 0);
118 }
119 Err(e) => error!("Error writing {}", e),
120 }
121 Timer::after_millis(100).await;
122 }
123}
124
125#[embassy_executor::main]
126async fn main(spawner: Spawner) {
127 let p = embassy_stm32::init(Default::default());
128 info!("Hello World!");
129
130 let speed = Hertz::khz(400);
131 let config = i2c::Config::default();
132
133 let d_addr_config = i2c::SlaveAddrConfig {
134 addr: OwnAddresses::OA1(Address::SevenBit(DEV_ADDR)),
135 general_call: false,
136 };
137 let d_sda = p.PA8;
138 let d_scl = p.PA9;
139 let device = i2c::I2c::new(p.I2C2, d_scl, d_sda, Irqs, p.DMA1_CH1, p.DMA1_CH2, speed, config)
140 .into_slave_multimaster(d_addr_config);
141
142 unwrap!(spawner.spawn(device_task(device)));
143
144 let c_sda = p.PB8;
145 let c_scl = p.PB7;
146 let controller = i2c::I2c::new(p.I2C1, c_sda, c_scl, Irqs, p.DMA1_CH3, p.DMA1_CH4, speed, config);
147
148 unwrap!(spawner.spawn(controller_task(controller)));
149}
diff --git a/examples/stm32g4/src/bin/pwm.rs b/examples/stm32g4/src/bin/pwm.rs
index 6c965012c..5b4194927 100644
--- a/examples/stm32g4/src/bin/pwm.rs
+++ b/examples/stm32g4/src/bin/pwm.rs
@@ -14,7 +14,7 @@ async fn main(_spawner: Spawner) {
14 let p = embassy_stm32::init(Default::default()); 14 let p = embassy_stm32::init(Default::default());
15 info!("Hello World!"); 15 info!("Hello World!");
16 16
17 let ch1_pin = PwmPin::new_ch1(p.PC0, OutputType::PushPull); 17 let ch1_pin = PwmPin::new(p.PC0, OutputType::PushPull);
18 let mut pwm = SimplePwm::new(p.TIM1, Some(ch1_pin), None, None, None, khz(10), Default::default()); 18 let mut pwm = SimplePwm::new(p.TIM1, Some(ch1_pin), None, None, None, khz(10), Default::default());
19 let mut ch1 = pwm.ch1(); 19 let mut ch1 = pwm.ch1();
20 ch1.enable(); 20 ch1.enable();
diff --git a/examples/stm32h5/Cargo.toml b/examples/stm32h5/Cargo.toml
index f3fda7ff3..0ac9016d4 100644
--- a/examples/stm32h5/Cargo.toml
+++ b/examples/stm32h5/Cargo.toml
@@ -11,7 +11,7 @@ embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["de
11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } 11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] }
12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6"] } 13embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6"] }
14embassy-usb = { version = "0.4.0", path = "../../embassy-usb", features = ["defmt"] } 14embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = ["defmt"] }
15embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 15embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
16 16
17defmt = "1.0.1" 17defmt = "1.0.1"
diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml
index 27c59d980..9053289ea 100644
--- a/examples/stm32h7/Cargo.toml
+++ b/examples/stm32h7/Cargo.toml
@@ -8,11 +8,11 @@ license = "MIT OR Apache-2.0"
8# Change stm32h743bi to your chip name, if necessary. 8# Change stm32h743bi to your chip name, if necessary.
9embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = ["defmt", "stm32h743bi", "time-driver-tim2", "exti", "memory-x", "unstable-pac", "chrono"] } 9embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = ["defmt", "stm32h743bi", "time-driver-tim2", "exti", "memory-x", "unstable-pac", "chrono"] }
10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-embedded-hal = { version = "0.3.0", path = "../../embassy-embedded-hal" } 11embassy-embedded-hal = { version = "0.3.1", path = "../../embassy-embedded-hal" }
12embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } 12embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
13embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 13embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
14embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns"] } 14embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns"] }
15embassy-usb = { version = "0.4.0", path = "../../embassy-usb", features = ["defmt"] } 15embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = ["defmt"] }
16embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 16embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
17 17
18defmt = "1.0.1" 18defmt = "1.0.1"
diff --git a/examples/stm32h7/src/bin/i2c_shared.rs b/examples/stm32h7/src/bin/i2c_shared.rs
index 136b91eeb..655ff901f 100644
--- a/examples/stm32h7/src/bin/i2c_shared.rs
+++ b/examples/stm32h7/src/bin/i2c_shared.rs
@@ -25,7 +25,7 @@ const SHTC3_WAKEUP: [u8; 2] = [0x35, 0x17];
25const SHTC3_MEASURE_RH_FIRST: [u8; 2] = [0x5c, 0x24]; 25const SHTC3_MEASURE_RH_FIRST: [u8; 2] = [0x5c, 0x24];
26const SHTC3_SLEEP: [u8; 2] = [0xb0, 0x98]; 26const SHTC3_SLEEP: [u8; 2] = [0xb0, 0x98];
27 27
28static I2C_BUS: StaticCell<NoopMutex<RefCell<I2c<'static, Async>>>> = StaticCell::new(); 28static I2C_BUS: StaticCell<NoopMutex<RefCell<I2c<'static, Async, i2c::Master>>>> = StaticCell::new();
29 29
30bind_interrupts!(struct Irqs { 30bind_interrupts!(struct Irqs {
31 I2C1_EV => i2c::EventInterruptHandler<peripherals::I2C1>; 31 I2C1_EV => i2c::EventInterruptHandler<peripherals::I2C1>;
@@ -33,7 +33,7 @@ bind_interrupts!(struct Irqs {
33}); 33});
34 34
35#[embassy_executor::task] 35#[embassy_executor::task]
36async fn temperature(mut i2c: I2cDevice<'static, NoopRawMutex, I2c<'static, Async>>) { 36async fn temperature(mut i2c: I2cDevice<'static, NoopRawMutex, I2c<'static, Async, i2c::Master>>) {
37 let mut data = [0u8; 2]; 37 let mut data = [0u8; 2];
38 38
39 loop { 39 loop {
@@ -50,7 +50,7 @@ async fn temperature(mut i2c: I2cDevice<'static, NoopRawMutex, I2c<'static, Asyn
50} 50}
51 51
52#[embassy_executor::task] 52#[embassy_executor::task]
53async fn humidity(mut i2c: I2cDevice<'static, NoopRawMutex, I2c<'static, Async>>) { 53async fn humidity(mut i2c: I2cDevice<'static, NoopRawMutex, I2c<'static, Async, i2c::Master>>) {
54 let mut data = [0u8; 6]; 54 let mut data = [0u8; 6];
55 55
56 loop { 56 loop {
diff --git a/examples/stm32h7/src/bin/low_level_timer_api.rs b/examples/stm32h7/src/bin/low_level_timer_api.rs
index 8de31ea5b..12abb8693 100644
--- a/examples/stm32h7/src/bin/low_level_timer_api.rs
+++ b/examples/stm32h7/src/bin/low_level_timer_api.rs
@@ -6,7 +6,7 @@ use embassy_executor::Spawner;
6use embassy_stm32::gpio::{AfType, Flex, OutputType, Speed}; 6use embassy_stm32::gpio::{AfType, Flex, OutputType, Speed};
7use embassy_stm32::time::{khz, Hertz}; 7use embassy_stm32::time::{khz, Hertz};
8use embassy_stm32::timer::low_level::{OutputCompareMode, Timer as LLTimer}; 8use embassy_stm32::timer::low_level::{OutputCompareMode, Timer as LLTimer};
9use embassy_stm32::timer::{Channel, Channel1Pin, Channel2Pin, Channel3Pin, Channel4Pin, GeneralInstance32bit4Channel}; 9use embassy_stm32::timer::{Ch1, Ch2, Ch3, Ch4, Channel, GeneralInstance32bit4Channel, TimerPin};
10use embassy_stm32::{Config, Peri}; 10use embassy_stm32::{Config, Peri};
11use embassy_time::Timer; 11use embassy_time::Timer;
12use {defmt_rtt as _, panic_probe as _}; 12use {defmt_rtt as _, panic_probe as _};
@@ -67,10 +67,10 @@ pub struct SimplePwm32<'d, T: GeneralInstance32bit4Channel> {
67impl<'d, T: GeneralInstance32bit4Channel> SimplePwm32<'d, T> { 67impl<'d, T: GeneralInstance32bit4Channel> SimplePwm32<'d, T> {
68 pub fn new( 68 pub fn new(
69 tim: Peri<'d, T>, 69 tim: Peri<'d, T>,
70 ch1: Peri<'d, impl Channel1Pin<T>>, 70 ch1: Peri<'d, impl TimerPin<T, Ch1>>,
71 ch2: Peri<'d, impl Channel2Pin<T>>, 71 ch2: Peri<'d, impl TimerPin<T, Ch2>>,
72 ch3: Peri<'d, impl Channel3Pin<T>>, 72 ch3: Peri<'d, impl TimerPin<T, Ch3>>,
73 ch4: Peri<'d, impl Channel4Pin<T>>, 73 ch4: Peri<'d, impl TimerPin<T, Ch4>>,
74 freq: Hertz, 74 freq: Hertz,
75 ) -> Self { 75 ) -> Self {
76 let af1 = ch1.af_num(); 76 let af1 = ch1.af_num();
diff --git a/examples/stm32h7/src/bin/pwm.rs b/examples/stm32h7/src/bin/pwm.rs
index a1c53fc3f..73b43be69 100644
--- a/examples/stm32h7/src/bin/pwm.rs
+++ b/examples/stm32h7/src/bin/pwm.rs
@@ -36,7 +36,7 @@ async fn main(_spawner: Spawner) {
36 let p = embassy_stm32::init(config); 36 let p = embassy_stm32::init(config);
37 info!("Hello World!"); 37 info!("Hello World!");
38 38
39 let ch1_pin = PwmPin::new_ch1(p.PA6, OutputType::PushPull); 39 let ch1_pin = PwmPin::new(p.PA6, OutputType::PushPull);
40 let mut pwm = SimplePwm::new(p.TIM3, Some(ch1_pin), None, None, None, khz(10), Default::default()); 40 let mut pwm = SimplePwm::new(p.TIM3, Some(ch1_pin), None, None, None, khz(10), Default::default());
41 let mut ch1 = pwm.ch1(); 41 let mut ch1 = pwm.ch1();
42 ch1.enable(); 42 ch1.enable();
diff --git a/examples/stm32h723/src/bin/spdifrx.rs b/examples/stm32h723/src/bin/spdifrx.rs
index a04d7cb34..6d29e8a4d 100644
--- a/examples/stm32h723/src/bin/spdifrx.rs
+++ b/examples/stm32h723/src/bin/spdifrx.rs
@@ -7,9 +7,9 @@
7 7
8use defmt::{info, trace}; 8use defmt::{info, trace};
9use embassy_executor::Spawner; 9use embassy_executor::Spawner;
10use embassy_futures::select::{self, select, Either}; 10use embassy_futures::select::{select, Either};
11use embassy_stm32::spdifrx::{self, Spdifrx}; 11use embassy_stm32::spdifrx::{self, Spdifrx};
12use embassy_stm32::{bind_interrupts, peripherals, sai}; 12use embassy_stm32::{bind_interrupts, peripherals, sai, Peri};
13use grounded::uninit::GroundedArrayCell; 13use grounded::uninit::GroundedArrayCell;
14use hal::sai::*; 14use hal::sai::*;
15use {defmt_rtt as _, embassy_stm32 as hal, panic_probe as _}; 15use {defmt_rtt as _, embassy_stm32 as hal, panic_probe as _};
@@ -25,10 +25,10 @@ const DMA_BUFFER_LENGTH: usize = HALF_DMA_BUFFER_LENGTH * 2; // 2 half-blocks
25 25
26// DMA buffers must be in special regions. Refer https://embassy.dev/book/#_stm32_bdma_only_working_out_of_some_ram_regions 26// DMA buffers must be in special regions. Refer https://embassy.dev/book/#_stm32_bdma_only_working_out_of_some_ram_regions
27#[unsafe(link_section = ".sram1")] 27#[unsafe(link_section = ".sram1")]
28static mut SPDIFRX_BUFFER: GroundedArrayCell<u32, DMA_BUFFER_LENGTH> = GroundedArrayCell::uninit(); 28static SPDIFRX_BUFFER: GroundedArrayCell<u32, DMA_BUFFER_LENGTH> = GroundedArrayCell::uninit();
29 29
30#[unsafe(link_section = ".sram4")] 30#[unsafe(link_section = ".sram4")]
31static mut SAI_BUFFER: GroundedArrayCell<u32, DMA_BUFFER_LENGTH> = GroundedArrayCell::uninit(); 31static SAI_BUFFER: GroundedArrayCell<u32, DMA_BUFFER_LENGTH> = GroundedArrayCell::uninit();
32 32
33#[embassy_executor::main] 33#[embassy_executor::main]
34async fn main(_spawner: Spawner) { 34async fn main(_spawner: Spawner) {
@@ -144,9 +144,9 @@ async fn main(_spawner: Spawner) {
144/// 144///
145/// Used (again) after dropping the SPDIFRX instance, in case of errors (e.g. source disconnect). 145/// Used (again) after dropping the SPDIFRX instance, in case of errors (e.g. source disconnect).
146fn new_spdif_receiver<'d>( 146fn new_spdif_receiver<'d>(
147 spdifrx: &'d mut peripherals::SPDIFRX1, 147 spdifrx: Peri<'d, peripherals::SPDIFRX1>,
148 input_pin: &'d mut peripherals::PD7, 148 input_pin: Peri<'d, peripherals::PD7>,
149 dma: &'d mut peripherals::DMA2_CH7, 149 dma: Peri<'d, peripherals::DMA2_CH7>,
150 buf: &'d mut [u32], 150 buf: &'d mut [u32],
151) -> Spdifrx<'d, peripherals::SPDIFRX1> { 151) -> Spdifrx<'d, peripherals::SPDIFRX1> {
152 Spdifrx::new(spdifrx, Irqs, spdifrx::Config::default(), input_pin, dma, buf) 152 Spdifrx::new(spdifrx, Irqs, spdifrx::Config::default(), input_pin, dma, buf)
@@ -156,11 +156,11 @@ fn new_spdif_receiver<'d>(
156/// 156///
157/// Used (again) after dropping the SAI4 instance, in case of errors (e.g. buffer overrun). 157/// Used (again) after dropping the SAI4 instance, in case of errors (e.g. buffer overrun).
158fn new_sai_transmitter<'d>( 158fn new_sai_transmitter<'d>(
159 sai: &'d mut peripherals::SAI4, 159 sai: Peri<'d, peripherals::SAI4>,
160 sck: &'d mut peripherals::PD13, 160 sck: Peri<'d, peripherals::PD13>,
161 sd: &'d mut peripherals::PC1, 161 sd: Peri<'d, peripherals::PC1>,
162 fs: &'d mut peripherals::PD12, 162 fs: Peri<'d, peripherals::PD12>,
163 dma: &'d mut peripherals::BDMA_CH0, 163 dma: Peri<'d, peripherals::BDMA_CH0>,
164 buf: &'d mut [u32], 164 buf: &'d mut [u32],
165) -> Sai<'d, peripherals::SAI4, u32> { 165) -> Sai<'d, peripherals::SAI4, u32> {
166 let mut sai_config = hal::sai::Config::default(); 166 let mut sai_config = hal::sai::Config::default();
diff --git a/examples/stm32h735/Cargo.toml b/examples/stm32h735/Cargo.toml
index 8d23c346a..e4938e15b 100644
--- a/examples/stm32h735/Cargo.toml
+++ b/examples/stm32h735/Cargo.toml
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
7[dependencies] 7[dependencies]
8embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = ["defmt", "stm32h735ig", "time-driver-tim2", "exti", "memory-x", "unstable-pac", "chrono"] } 8embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = ["defmt", "stm32h735ig", "time-driver-tim2", "exti", "memory-x", "unstable-pac", "chrono"] }
9embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 9embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
10embassy-embedded-hal = { version = "0.3.0", path = "../../embassy-embedded-hal" } 10embassy-embedded-hal = { version = "0.3.1", path = "../../embassy-embedded-hal" }
11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } 11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 13embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
diff --git a/examples/stm32h742/Cargo.toml b/examples/stm32h742/Cargo.toml
index 31eff4379..efa71e144 100644
--- a/examples/stm32h742/Cargo.toml
+++ b/examples/stm32h742/Cargo.toml
@@ -34,7 +34,7 @@ embassy-net = { version = "0.7.0", path = "../../embassy-net", features = [
34 "medium-ethernet", 34 "medium-ethernet",
35] } 35] }
36embedded-io-async = { version = "0.6.1" } 36embedded-io-async = { version = "0.6.1" }
37embassy-usb = { version = "0.4.0", path = "../../embassy-usb", features = [ 37embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = [
38 "defmt", 38 "defmt",
39] } 39] }
40embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 40embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
diff --git a/examples/stm32h742/src/bin/qspi.rs b/examples/stm32h742/src/bin/qspi.rs
index aee07f3f2..50e37ec52 100644
--- a/examples/stm32h742/src/bin/qspi.rs
+++ b/examples/stm32h742/src/bin/qspi.rs
@@ -272,6 +272,7 @@ async fn main(_spawner: Spawner) -> ! {
272 prescaler: 16, 272 prescaler: 16,
273 cs_high_time: ChipSelectHighTime::_1Cycle, 273 cs_high_time: ChipSelectHighTime::_1Cycle,
274 fifo_threshold: FIFOThresholdLevel::_16Bytes, 274 fifo_threshold: FIFOThresholdLevel::_16Bytes,
275 sample_shifting: SampleShifting::None,
275 }; 276 };
276 let driver = Qspi::new_blocking_bank1(p.QUADSPI, p.PD11, p.PD12, p.PE2, p.PD13, p.PB2, p.PB10, config); 277 let driver = Qspi::new_blocking_bank1(p.QUADSPI, p.PD11, p.PD12, p.PE2, p.PD13, p.PB2, p.PB10, config);
277 let mut flash = FlashMemory::new(driver); 278 let mut flash = FlashMemory::new(driver);
diff --git a/examples/stm32h755cm4/Cargo.toml b/examples/stm32h755cm4/Cargo.toml
index 71bd50d60..eaaeb1ac0 100644
--- a/examples/stm32h755cm4/Cargo.toml
+++ b/examples/stm32h755cm4/Cargo.toml
@@ -8,11 +8,11 @@ license = "MIT OR Apache-2.0"
8# Change stm32h755zi-cm4 to your chip name, if necessary. 8# Change stm32h755zi-cm4 to your chip name, if necessary.
9embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = ["defmt", "stm32h755zi-cm4", "time-driver-tim2", "exti", "memory-x", "unstable-pac", "chrono"] } 9embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = ["defmt", "stm32h755zi-cm4", "time-driver-tim2", "exti", "memory-x", "unstable-pac", "chrono"] }
10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-embedded-hal = { version = "0.3.0", path = "../../embassy-embedded-hal" } 11embassy-embedded-hal = { version = "0.3.1", path = "../../embassy-embedded-hal" }
12embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } 12embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
13embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 13embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
14embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns"] } 14embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns"] }
15embassy-usb = { version = "0.4.0", path = "../../embassy-usb", features = ["defmt"] } 15embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = ["defmt"] }
16embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 16embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
17 17
18defmt = "1.0.1" 18defmt = "1.0.1"
diff --git a/examples/stm32h755cm7/Cargo.toml b/examples/stm32h755cm7/Cargo.toml
index 8e960932a..e7fc05948 100644
--- a/examples/stm32h755cm7/Cargo.toml
+++ b/examples/stm32h755cm7/Cargo.toml
@@ -8,11 +8,11 @@ license = "MIT OR Apache-2.0"
8# Change stm32h743bi to your chip name, if necessary. 8# Change stm32h743bi to your chip name, if necessary.
9embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = ["defmt", "stm32h755zi-cm7", "time-driver-tim3", "exti", "memory-x", "unstable-pac", "chrono"] } 9embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = ["defmt", "stm32h755zi-cm7", "time-driver-tim3", "exti", "memory-x", "unstable-pac", "chrono"] }
10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-embedded-hal = { version = "0.3.0", path = "../../embassy-embedded-hal" } 11embassy-embedded-hal = { version = "0.3.1", path = "../../embassy-embedded-hal" }
12embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } 12embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
13embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 13embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
14embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns"] } 14embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns"] }
15embassy-usb = { version = "0.4.0", path = "../../embassy-usb", features = ["defmt"] } 15embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = ["defmt"] }
16embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 16embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
17 17
18defmt = "1.0.1" 18defmt = "1.0.1"
diff --git a/examples/stm32h7b0/Cargo.toml b/examples/stm32h7b0/Cargo.toml
index 72f86e0cf..bfa7f9202 100644
--- a/examples/stm32h7b0/Cargo.toml
+++ b/examples/stm32h7b0/Cargo.toml
@@ -7,11 +7,11 @@ license = "MIT OR Apache-2.0"
7[dependencies] 7[dependencies]
8embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = ["defmt", "stm32h7b0vb", "time-driver-tim2", "exti", "memory-x", "unstable-pac", "chrono"] } 8embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = ["defmt", "stm32h7b0vb", "time-driver-tim2", "exti", "memory-x", "unstable-pac", "chrono"] }
9embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 9embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
10embassy-embedded-hal = { version = "0.3.0", path = "../../embassy-embedded-hal" } 10embassy-embedded-hal = { version = "0.3.1", path = "../../embassy-embedded-hal" }
11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } 11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns"] } 13embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns"] }
14embassy-usb = { version = "0.4.0", path = "../../embassy-usb", features = ["defmt"] } 14embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = ["defmt"] }
15embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 15embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
16 16
17defmt = "1.0.1" 17defmt = "1.0.1"
diff --git a/examples/stm32h7rs/Cargo.toml b/examples/stm32h7rs/Cargo.toml
index 5f1ce8dfc..9794c6dbd 100644
--- a/examples/stm32h7rs/Cargo.toml
+++ b/examples/stm32h7rs/Cargo.toml
@@ -11,7 +11,7 @@ embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["de
11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] } 11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt"] }
12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "udp", "medium-ethernet", "medium-ip", "proto-ipv4"] } 13embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "udp", "medium-ethernet", "medium-ip", "proto-ipv4"] }
14embassy-usb = { version = "0.4.0", path = "../../embassy-usb", features = ["defmt"] } 14embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = ["defmt"] }
15embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 15embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
16 16
17defmt = "1.0.1" 17defmt = "1.0.1"
diff --git a/examples/stm32h7rs/src/bin/xspi_memory_mapped.rs b/examples/stm32h7rs/src/bin/xspi_memory_mapped.rs
index 88d914180..59045ca2e 100644
--- a/examples/stm32h7rs/src/bin/xspi_memory_mapped.rs
+++ b/examples/stm32h7rs/src/bin/xspi_memory_mapped.rs
@@ -3,7 +3,8 @@
3 3
4//! For Nucleo STM32H7S3L8 MB1737, has MX25UW25645GXDI00 4//! For Nucleo STM32H7S3L8 MB1737, has MX25UW25645GXDI00
5//! 5//!
6//! TODO: Currently this only uses single SPI, pending flash chip documentation for octo SPI. 6
7use core::cmp::min;
7 8
8use defmt::info; 9use defmt::info;
9use embassy_executor::Spawner; 10use embassy_executor::Spawner;
@@ -52,14 +53,16 @@ async fn main(_spawner: Spawner) {
52 fifo_threshold: FIFOThresholdLevel::_4Bytes, 53 fifo_threshold: FIFOThresholdLevel::_4Bytes,
53 memory_type: MemoryType::Macronix, 54 memory_type: MemoryType::Macronix,
54 delay_hold_quarter_cycle: true, 55 delay_hold_quarter_cycle: true,
55 // memory_type: MemoryType::Micron,
56 // delay_hold_quarter_cycle: false,
57 device_size: MemorySize::_32MiB, 56 device_size: MemorySize::_32MiB,
58 chip_select_high_time: ChipSelectHighTime::_2Cycle, 57 chip_select_high_time: ChipSelectHighTime::_2Cycle,
59 free_running_clock: false, 58 free_running_clock: false,
60 clock_mode: false, 59 clock_mode: false,
61 wrap_size: WrapSize::None, 60 wrap_size: WrapSize::None,
62 // 300mhz / (4+1) = 60mhz. Unsure the limit, need to find a MX25UW25645GXDI00 datasheet. 61 // 300 MHz clock / (3 + 1) = 75 MHz. This is above the max for READ instructions so the
62 // FAST READ must be used. The nucleo board's flash can run at up to 133 MHz in SPI mode
63 // and 200 MHz in OPI mode. This clock prescaler must be even otherwise the clock will not
64 // have symmetric high and low times.
65 // The clock can also be fed by one of the PLLs to allow for more flexible clock rates.
63 clock_prescaler: 3, 66 clock_prescaler: 3,
64 sample_shifting: false, 67 sample_shifting: false,
65 chip_select_boundary: 0, 68 chip_select_boundary: 0,
@@ -71,28 +74,41 @@ async fn main(_spawner: Spawner) {
71 74
72 // Not necessary, but recommended if using XIP 75 // Not necessary, but recommended if using XIP
73 cor.SCB.enable_icache(); 76 cor.SCB.enable_icache();
77 // Note: Enabling data cache can cause issues with DMA transfers.
74 cor.SCB.enable_dcache(&mut cor.CPUID); 78 cor.SCB.enable_dcache(&mut cor.CPUID);
75 79
76 let xspi = embassy_stm32::xspi::Xspi::new_blocking_xspi( 80 let xspi = embassy_stm32::xspi::Xspi::new_blocking_xspi(
77 p.XSPI2, p.PN6, p.PN2, p.PN3, p.PN4, p.PN5, p.PN8, p.PN9, p.PN10, p.PN11, p.PN1, spi_config, 81 p.XSPI2, p.PN6, p.PN2, p.PN3, p.PN4, p.PN5, p.PN8, p.PN9, p.PN10, p.PN11, p.PN1, spi_config,
78 ); 82 );
79 83
80 let mut flash = FlashMemory::new(xspi).await; 84 let mut flash = SpiFlashMemory::new(xspi);
81 85
82 let flash_id = flash.read_id(); 86 let flash_id = flash.read_id();
83 info!("FLASH ID: {=[u8]:x}", flash_id); 87 info!("FLASH ID: {=[u8]:x}", flash_id);
84 88
85 let mut wr_buf = [0u8; 8]; 89 // Erase the first sector
86 for i in 0..8 { 90 flash.erase_sector(0);
87 wr_buf[i] = 0x90 + i as u8; 91
88 } 92 // Write some data into the flash. This writes more than one page to test that functionality.
89 let mut rd_buf = [0u8; 8]; 93 let mut wr_buf = [0u8; 512];
90 flash.erase_sector(0).await; 94 let base_number: u8 = 0x90;
91 flash.write_memory(0, &wr_buf, true).await; 95 for i in 0..512 {
92 flash.read_memory(0, &mut rd_buf, true); 96 wr_buf[i] = base_number.wrapping_add(i as u8);
93 info!("WRITE BUF: {=[u8]:#X}", wr_buf); 97 }
94 info!("READ BUF: {=[u8]:#X}", rd_buf); 98 flash.write_memory(0, &wr_buf);
95 flash.enable_mm().await; 99
100 // Read the data back and verify it.
101 let mut rd_buf = [0u8; 512];
102 let start_time = embassy_time::Instant::now();
103 flash.read_memory(0, &mut rd_buf);
104 let elapsed = start_time.elapsed();
105 info!("Read 512 bytes in {} us in SPI mode", elapsed.as_micros());
106 info!("WRITE BUF: {=[u8]:#X}", wr_buf[0..32]);
107 info!("READ BUF: {=[u8]:#X}", rd_buf[0..32]);
108
109 assert_eq!(wr_buf, rd_buf, "Read buffer does not match write buffer");
110
111 flash.enable_mm();
96 info!("Enabled memory mapped mode"); 112 info!("Enabled memory mapped mode");
97 113
98 let first_u32 = unsafe { *(0x70000000 as *const u32) }; 114 let first_u32 = unsafe { *(0x70000000 as *const u32) };
@@ -103,10 +119,53 @@ async fn main(_spawner: Spawner) {
103 assert_eq!(second_u32, 0x97969594); 119 assert_eq!(second_u32, 0x97969594);
104 info!("second_u32 {:08x}", first_u32); 120 info!("second_u32 {:08x}", first_u32);
105 121
106 flash.disable_mm().await; 122 flash.disable_mm();
107 info!("Disabled memory mapped mode"); 123 info!("Disabled memory mapped mode");
108 124
125 let flash_id = flash.read_id();
126 info!("FLASH ID: {=[u8]:x}", flash_id);
127
128 let mut flash = flash.into_octo();
129
130 Timer::after_millis(100).await;
131
132 let flash_id = flash.read_id();
133 info!("FLASH ID in OPI mode: {=[u8]:x}", flash_id);
134
135 flash.erase_sector(0);
136
137 let mut rd_buf = [0u8; 512];
138 flash.read_memory(0, &mut rd_buf);
139 info!("READ BUF after erase: {=[u8]:#X}", rd_buf[0..32]);
140
141 assert_eq!(rd_buf, [0xFF; 512], "Read buffer is not all 0xFF after erase");
142
143 flash.write_memory(0, &wr_buf);
144 let start = embassy_time::Instant::now();
145 flash.read_memory(0, &mut rd_buf);
146 let elapsed = start.elapsed();
147 info!("Read 512 bytes in {} us in OPI mode", elapsed.as_micros());
148 info!("READ BUF after write: {=[u8]:#X}", rd_buf[0..32]);
149 assert_eq!(wr_buf, rd_buf, "Read buffer does not match write buffer in OPI mode");
150
151 flash.enable_mm();
152 info!("Enabled memory mapped mode in OPI mode");
153 let first_u32 = unsafe { *(0x70000000 as *const u32) };
154 assert_eq!(first_u32, 0x93929190);
155 info!("first_u32 {:08x}", first_u32);
156 let second_u32 = unsafe { *(0x70000004 as *const u32) };
157 assert_eq!(second_u32, 0x97969594);
158 info!("second_u32 {:08x}", first_u32);
159 flash.disable_mm();
160 info!("Disabled memory mapped mode in OPI mode");
161
162 // Reset back to SPI mode
163 let mut flash = flash.into_spi();
164 let flash_id = flash.read_id();
165 info!("FLASH ID back in SPI mode: {=[u8]:x}", flash_id);
166
109 info!("DONE"); 167 info!("DONE");
168
110 // Output pin PE3 169 // Output pin PE3
111 let mut led = Output::new(p.PE3, Level::Low, Speed::Low); 170 let mut led = Output::new(p.PE3, Level::Low, Speed::Low);
112 171
@@ -116,80 +175,268 @@ async fn main(_spawner: Spawner) {
116 } 175 }
117} 176}
118 177
119const MEMORY_PAGE_SIZE: usize = 8; 178const MEMORY_PAGE_SIZE: usize = 256;
120
121const CMD_READ: u8 = 0x0B;
122const _CMD_QUAD_READ: u8 = 0x6B;
123
124const CMD_WRITE_PG: u8 = 0x02;
125const _CMD_QUAD_WRITE_PG: u8 = 0x32;
126
127const CMD_READ_ID: u8 = 0x9F;
128const CMD_READ_ID_OCTO: u16 = 0x9F60;
129 179
130const CMD_ENABLE_RESET: u8 = 0x66; 180/// Implementation of access to flash chip using SPI.
131const CMD_RESET: u8 = 0x99; 181///
132 182/// Chip commands are hardcoded as it depends on used chip.
133const CMD_WRITE_ENABLE: u8 = 0x06; 183/// This targets a MX25UW25645GXDI00.
134 184pub struct SpiFlashMemory<I: Instance> {
135const CMD_CHIP_ERASE: u8 = 0xC7; 185 xspi: Xspi<'static, I, Blocking>,
136const CMD_SECTOR_ERASE: u8 = 0x20; 186}
137const CMD_BLOCK_ERASE_32K: u8 = 0x52;
138const CMD_BLOCK_ERASE_64K: u8 = 0xD8;
139
140const CMD_READ_SR: u8 = 0x05;
141const CMD_READ_CR: u8 = 0x35;
142
143const CMD_WRITE_SR: u8 = 0x01;
144const CMD_WRITE_CR: u8 = 0x31;
145 187
146/// Implementation of access to flash chip. 188/// Implementation of access to flash chip using Octo SPI.
147/// 189///
148/// Chip commands are hardcoded as it depends on used chip. 190/// Chip commands are hardcoded as it depends on used chip.
149/// This targets a MX25UW25645GXDI00. 191/// This targets a MX25UW25645GXDI00.
150pub struct FlashMemory<I: Instance> { 192pub struct OpiFlashMemory<I: Instance> {
151 xspi: Xspi<'static, I, Blocking>, 193 xspi: Xspi<'static, I, Blocking>,
152} 194}
153 195
154impl<I: Instance> FlashMemory<I> { 196/// SPI mode commands for MX25UW25645G flash memory
155 pub async fn new(xspi: Xspi<'static, I, Blocking>) -> Self { 197#[allow(dead_code)]
156 let mut memory = Self { xspi }; 198#[repr(u8)]
199enum SpiCommand {
200 // Array access commands
201 /// Read data bytes using 3-byte address (up to 50 MHz)
202 Read3B = 0x03,
203 /// Fast read data bytes using 3-byte address with 8 dummy cycles (up to 133 MHz)
204 FastRead3B = 0x0B,
205 /// Program 1-256 bytes of data using 3-byte address
206 PageProgram3B = 0x02,
207 /// Erase 4KB sector using 3-byte address
208 SectorErase3B = 0x20,
209 /// Erase 64KB block using 3-byte address
210 BlockErase3B = 0xD8,
211 /// Read data bytes using 4-byte address (up to 50 MHz)
212 Read4B = 0x13,
213 /// Fast read data bytes using 4-byte address with 8 dummy cycles (up to 133 MHz)
214 FastRead4B = 0x0C,
215 /// Program 1-256 bytes of data using 4-byte address
216 PageProgram4B = 0x12,
217 /// Erase 4KB sector using 4-byte address
218 SectorErase4B = 0x21,
219 /// Erase 64KB block using 4-byte address
220 BlockErase4B = 0xDC,
221 /// Erase entire chip (only if no blocks are protected)
222 ChipErase = 0x60,
223
224 // Write Buffer Access commands
225 /// Read data from the 256-byte page buffer
226 ReadBuffer = 0x25,
227 /// Initialize write-to-buffer sequence, clears buffer and writes initial data
228 WriteBufferInitial = 0x22,
229 /// Continue writing data to buffer (used between WRBI and WRCF)
230 WriteBufferContinue = 0x24,
231 /// Confirm write operation, programs buffer contents to flash array
232 WriteBufferConfirm = 0x31,
233
234 // Device operation commands
235 /// Set Write Enable Latch (WEL) bit, required before write/program/erase operations
236 WriteEnable = 0x06,
237 /// Clear Write Enable Latch (WEL) bit
238 WriteDisable = 0x04,
239 /// Select write protection mode (BP mode or Advanced Sector Protection)
240 WriteProtectSelection = 0x68,
241 /// Suspend ongoing program or erase operation to allow read access
242 ProgramEraseSuspend = 0xB0,
243 /// Resume suspended program or erase operation
244 ProgramEraseResume = 0x30,
245 /// Enter deep power-down mode for minimum power consumption
246 DeepPowerDown = 0xB9,
247 /// Exit deep power-down mode and return to standby
248 ReleaseFromDeepPowerDown = 0xAB,
249 /// No operation, can terminate Reset Enable command
250 NoOperation = 0x00,
251 /// Enable reset operation (must precede Reset Memory command)
252 ResetEnable = 0x66,
253 /// Reset device to power-on state (requires prior Reset Enable)
254 ResetMemory = 0x99,
255 /// Protect all sectors using Dynamic Protection Bits (DPB)
256 GangBlockLock = 0x7E,
257 /// Unprotect all sectors by clearing Dynamic Protection Bits (DPB)
258 GangBlockUnlock = 0x98,
259
260 // Register Access commands
261 /// Read 3-byte device identification (manufacturer ID + device ID)
262 ReadIdentification = 0x9F,
263 /// Read Serial Flash Discoverable Parameters (SFDP) table
264 ReadSFDP = 0x5A,
265 /// Read 8-bit Status Register (WIP, WEL, BP bits, etc.)
266 ReadStatusRegister = 0x05,
267 /// Read 8-bit Configuration Register (ODS, TB, PBE bits)
268 ReadConfigurationRegister = 0x15,
269 /// Write Status and/or Configuration Register (1-2 bytes)
270 WriteStatusConfigurationRegister = 0x01,
271 /// Read Configuration Register 2 from specified 4-byte address
272 ReadConfigurationRegister2 = 0x71,
273 /// Write Configuration Register 2 to specified 4-byte address
274 WriteConfigurationRegister2 = 0x72,
275 /// Read 8-bit Security Register (protection status, suspend bits)
276 ReadSecurityRegister = 0x2B,
277 /// Write Security Register to set customer lock-down bit
278 WriteSecurityRegister = 0x2F,
279 /// Read 32-bit Fast Boot Register (boot address and configuration)
280 ReadFastBootRegister = 0x16,
281 /// Write 32-bit Fast Boot Register
282 WriteFastBootRegister = 0x17,
283 /// Erase Fast Boot Register (disable fast boot feature)
284 EraseFastBootRegister = 0x18,
285 /// Set burst/wrap length for read operations (16/32/64 bytes)
286 SetBurstLength = 0xC0,
287 /// Enter 8K-bit secured OTP mode for programming unique identifiers
288 EnterSecuredOTP = 0xB1,
289 /// Exit secured OTP mode and return to main array access
290 ExitSecuredOTP = 0xC1,
291 /// Write Lock Register to control SPB protection mode
292 WriteLockRegister = 0x2C,
293 /// Read Lock Register status
294 ReadLockRegister = 0x2D,
295 /// Program Solid Protection Bit (SPB) for specified sector/block
296 WriteSPB = 0xE3,
297 /// Erase all Solid Protection Bits (SPB)
298 EraseSPB = 0xE4,
299 /// Read Solid Protection Bit (SPB) status for specified sector/block
300 ReadSPB = 0xE2,
301 /// Write Dynamic Protection Bit (DPB) for specified sector
302 WriteDPB = 0xE1,
303 /// Read Dynamic Protection Bit (DPB) status for specified sector
304 ReadDPB = 0xE0,
305 /// Read 64-bit password register (only in Solid Protection mode)
306 ReadPassword = 0x27,
307 /// Write 64-bit password register
308 WritePassword = 0x28,
309 /// Unlock SPB operations using 64-bit password
310 PasswordUnlock = 0x29,
311}
157 312
158 memory.reset_memory().await; 313/// OPI mode commands for MX25UW25645G flash memory
159 memory.enable_octo(); 314#[allow(dead_code)]
160 memory 315#[repr(u16)]
161 } 316enum OpiCommand {
317 // Array access commands
318 /// Read data using 8 I/O lines in STR mode with configurable dummy cycles (up to 200 MHz)
319 OctaRead = 0xEC13,
320 /// Read data using 8 I/O lines in DTR mode with configurable dummy cycles (up to 200 MHz)
321 OctaDTRRead = 0xEE11,
322 /// Program 1-256 bytes using 4-byte address and 8 I/O lines
323 PageProgram4B = 0x12ED,
324 /// Erase 4KB sector using 4-byte address
325 SectorErase4B = 0x21DE,
326 /// Erase 64KB block using 4-byte address
327 BlockErase4B = 0xDC23,
328 /// Erase entire chip (only if no blocks are protected)
329 ChipErase = 0x609F,
330
331 // Write Buffer Access commands
332 /// Read data from the 256-byte page buffer using 4-byte address
333 ReadBuffer = 0x25DA,
334 /// Initialize interruptible write-to-buffer sequence with 4-byte address
335 WriteBufferInitial = 0x22DD,
336 /// Continue writing data to buffer during interruptible sequence
337 WriteBufferContinue = 0x24DB,
338 /// Confirm and execute write operation from buffer to flash array
339 WriteBufferConfirm = 0x31CE,
340
341 // Device operation commands
342 /// Set Write Enable Latch (WEL) bit, required before write/program/erase operations
343 WriteEnable = 0x06F9,
344 /// Clear Write Enable Latch (WEL) bit, aborts write-to-buffer sequence
345 WriteDisable = 0x04FB,
346 /// Select write protection mode (BP mode or Advanced Sector Protection) - OTP bit
347 WriteProtectSelection = 0x6897,
348 /// Suspend ongoing program or erase operation to allow read from other banks
349 ProgramEraseSuspend = 0xB04F,
350 /// Resume suspended program or erase operation
351 ProgramEraseResume = 0x30CF,
352 /// Enter deep power-down mode for minimum power consumption
353 DeepPowerDown = 0xB946,
354 /// Exit deep power-down mode and return to standby
355 ReleaseFromDeepPowerDown = 0xAB54,
356 /// No operation, can terminate Reset Enable command
357 NoOperation = 0x00FF,
358 /// Enable reset operation (must precede Reset Memory command)
359 ResetEnable = 0x6699,
360 /// Reset device to power-on state, clears volatile settings
361 ResetMemory = 0x9966,
362 /// Protect all sectors using Dynamic Protection Bits (DPB)
363 GangBlockLock = 0x7E81,
364 /// Unprotect all sectors by clearing Dynamic Protection Bits (DPB)
365 GangBlockUnlock = 0x9867,
366
367 // Register Access commands
368 /// Read 3-byte device identification with 4-byte dummy address
369 ReadIdentification = 0x9F60,
370 /// Read Serial Flash Discoverable Parameters (SFDP) table with 4-byte address
371 ReadSFDP = 0x5AA5,
372 /// Read 8-bit Status Register with 4-byte dummy address
373 ReadStatusRegister = 0x05FA,
374 /// Read 8-bit Configuration Register with specific address (00000001h)
375 ReadConfigurationRegister = 0x15EA,
376 /// Write 8-bit Status Register with specific address (00000000h) or Configuration Register with address (00000001h)
377 WriteStatusConfigurationRegister = 0x01FE,
378 /// Read Configuration Register 2 from specified 4-byte address
379 ReadConfigurationRegister2 = 0x718E,
380 /// Write Configuration Register 2 to specified 4-byte address
381 WriteConfigurationRegister2 = 0x728D,
382 /// Read 8-bit Security Register with 4-byte dummy address
383 ReadSecurityRegister = 0x2BD4,
384 /// Write Security Register to set customer lock-down bit
385 WriteSecurityRegister = 0x2FD0,
386 /// Set burst/wrap length for read operations with 4-byte dummy address
387 SetBurstLength = 0xC03F,
388 /// Read 32-bit Fast Boot Register with 4-byte dummy address
389 ReadFastBootRegister = 0x16E9,
390 /// Write 32-bit Fast Boot Register with 4-byte dummy address
391 WriteFastBootRegister = 0x17E8,
392 /// Erase Fast Boot Register (disable fast boot feature)
393 EraseFastBootRegister = 0x18E7,
394 /// Enter 8K-bit secured OTP mode for programming unique identifiers
395 EnterSecuredOTP = 0xB14E,
396 /// Exit secured OTP mode and return to main array access
397 ExitSecuredOTP = 0xC13E,
398 /// Write Lock Register to control SPB protection mode with 4-byte dummy address
399 WriteLockRegister = 0x2CD3,
400 /// Read Lock Register status with 4-byte dummy address
401 ReadLockRegister = 0x2DD2,
402 /// Program Solid Protection Bit (SPB) for specified 4-byte address
403 WriteSPB = 0xE31C,
404 /// Erase all Solid Protection Bits (SPB)
405 EraseSPB = 0xE41B,
406 /// Read Solid Protection Bit (SPB) status for specified 4-byte address
407 ReadSPB = 0xE21D,
408 /// Write Dynamic Protection Bit (DPB) for specified 4-byte address
409 WriteDPB = 0xE11E,
410 /// Read Dynamic Protection Bit (DPB) status for specified 4-byte address
411 ReadDPB = 0xE01F,
412 /// Read 64-bit password register with 4-byte dummy address and 20 dummy cycles
413 ReadPassword = 0x27D8,
414 /// Write 64-bit password register with 4-byte dummy address
415 WritePassword = 0x28D7,
416 /// Unlock SPB operations using 64-bit password with 4-byte dummy address
417 PasswordUnlock = 0x29D6,
418}
162 419
163 async fn qpi_mode(&mut self) { 420impl<I: Instance> SpiFlashMemory<I> {
164 // Enter qpi mode 421 pub fn new(xspi: Xspi<'static, I, Blocking>) -> Self {
165 self.exec_command(0x38).await; 422 let mut memory = Self { xspi };
166 423
167 // Set read param 424 memory.reset_memory();
168 let transaction = TransferConfig { 425 memory
169 iwidth: XspiWidth::QUAD,
170 dwidth: XspiWidth::QUAD,
171 instruction: Some(0xC0),
172 ..Default::default()
173 };
174 self.enable_write().await;
175 self.xspi.blocking_write(&[0x30_u8], transaction).unwrap();
176 self.wait_write_finish();
177 } 426 }
178 427
179 pub async fn disable_mm(&mut self) { 428 pub fn disable_mm(&mut self) {
180 self.xspi.disable_memory_mapped_mode(); 429 self.xspi.disable_memory_mapped_mode();
181 } 430 }
182 431
183 pub async fn enable_mm(&mut self) { 432 pub fn enable_mm(&mut self) {
184 self.qpi_mode().await;
185
186 let read_config = TransferConfig { 433 let read_config = TransferConfig {
187 iwidth: XspiWidth::SING, 434 iwidth: XspiWidth::SING,
188 isize: AddressSize::_8bit, 435 isize: AddressSize::_8bit,
189 adwidth: XspiWidth::SING, 436 adwidth: XspiWidth::SING,
190 adsize: AddressSize::_24bit, 437 adsize: AddressSize::_32bit,
191 dwidth: XspiWidth::SING, 438 dwidth: XspiWidth::SING,
192 instruction: Some(CMD_READ as u32), 439 instruction: Some(SpiCommand::FastRead4B as u32),
193 dummy: DummyCycles::_8, 440 dummy: DummyCycles::_8,
194 ..Default::default() 441 ..Default::default()
195 }; 442 };
@@ -198,42 +445,28 @@ impl<I: Instance> FlashMemory<I> {
198 iwidth: XspiWidth::SING, 445 iwidth: XspiWidth::SING,
199 isize: AddressSize::_8bit, 446 isize: AddressSize::_8bit,
200 adwidth: XspiWidth::SING, 447 adwidth: XspiWidth::SING,
201 adsize: AddressSize::_24bit, 448 adsize: AddressSize::_32bit,
202 dwidth: XspiWidth::SING, 449 dwidth: XspiWidth::SING,
203 instruction: Some(CMD_WRITE_PG as u32), 450 instruction: Some(SpiCommand::PageProgram4B as u32),
204 dummy: DummyCycles::_0, 451 dummy: DummyCycles::_0,
205 ..Default::default() 452 ..Default::default()
206 }; 453 };
207 self.xspi.enable_memory_mapped_mode(read_config, write_config).unwrap(); 454 self.xspi.enable_memory_mapped_mode(read_config, write_config).unwrap();
208 } 455 }
209 456
210 fn enable_octo(&mut self) { 457 fn into_octo(mut self) -> OpiFlashMemory<I> {
211 let cr = self.read_cr(); 458 self.enable_opi_mode();
212 // info!("Read cr: {:x}", cr); 459 OpiFlashMemory { xspi: self.xspi }
213 self.write_cr(cr | 0x02);
214 // info!("Read cr after writing: {:x}", cr);
215 } 460 }
216 461
217 pub fn disable_octo(&mut self) { 462 fn enable_opi_mode(&mut self) {
218 let cr = self.read_cr(); 463 let cr2_0 = self.read_cr2(0);
219 self.write_cr(cr & (!(0x02))); 464 info!("Read CR2 at 0x0: {:x}", cr2_0);
220 } 465 self.enable_write();
221 466 self.write_cr2(0, cr2_0 | 0x01); // Set bit 0 to enable octo SPI in STR
222 async fn exec_command_4(&mut self, cmd: u8) {
223 let transaction = TransferConfig {
224 iwidth: XspiWidth::QUAD,
225 adwidth: XspiWidth::NONE,
226 // adsize: AddressSize::_24bit,
227 dwidth: XspiWidth::NONE,
228 instruction: Some(cmd as u32),
229 address: None,
230 dummy: DummyCycles::_0,
231 ..Default::default()
232 };
233 self.xspi.blocking_command(&transaction).unwrap();
234 } 467 }
235 468
236 async fn exec_command(&mut self, cmd: u8) { 469 fn exec_command(&mut self, cmd: u8) {
237 let transaction = TransferConfig { 470 let transaction = TransferConfig {
238 iwidth: XspiWidth::SING, 471 iwidth: XspiWidth::SING,
239 adwidth: XspiWidth::NONE, 472 adwidth: XspiWidth::NONE,
@@ -248,16 +481,14 @@ impl<I: Instance> FlashMemory<I> {
248 self.xspi.blocking_command(&transaction).unwrap(); 481 self.xspi.blocking_command(&transaction).unwrap();
249 } 482 }
250 483
251 pub async fn reset_memory(&mut self) { 484 pub fn reset_memory(&mut self) {
252 self.exec_command_4(CMD_ENABLE_RESET).await; 485 self.exec_command(SpiCommand::ResetEnable as u8);
253 self.exec_command_4(CMD_RESET).await; 486 self.exec_command(SpiCommand::ResetMemory as u8);
254 self.exec_command(CMD_ENABLE_RESET).await;
255 self.exec_command(CMD_RESET).await;
256 self.wait_write_finish(); 487 self.wait_write_finish();
257 } 488 }
258 489
259 pub async fn enable_write(&mut self) { 490 pub fn enable_write(&mut self) {
260 self.exec_command(CMD_WRITE_ENABLE).await; 491 self.exec_command(SpiCommand::WriteEnable as u8);
261 } 492 }
262 493
263 pub fn read_id(&mut self) -> [u8; 3] { 494 pub fn read_id(&mut self) -> [u8; 3] {
@@ -266,92 +497,64 @@ impl<I: Instance> FlashMemory<I> {
266 iwidth: XspiWidth::SING, 497 iwidth: XspiWidth::SING,
267 isize: AddressSize::_8bit, 498 isize: AddressSize::_8bit,
268 adwidth: XspiWidth::NONE, 499 adwidth: XspiWidth::NONE,
269 // adsize: AddressSize::_24bit,
270 dwidth: XspiWidth::SING, 500 dwidth: XspiWidth::SING,
271 instruction: Some(CMD_READ_ID as u32), 501 instruction: Some(SpiCommand::ReadIdentification as u32),
272 ..Default::default() 502 ..Default::default()
273 }; 503 };
274 // info!("Reading id: 0x{:X}", transaction.instruction);
275 self.xspi.blocking_read(&mut buffer, transaction).unwrap(); 504 self.xspi.blocking_read(&mut buffer, transaction).unwrap();
276 buffer 505 buffer
277 } 506 }
278 507
279 pub fn read_id_8(&mut self) -> [u8; 3] { 508 pub fn read_memory(&mut self, addr: u32, buffer: &mut [u8]) {
280 let mut buffer = [0; 3];
281 let transaction: TransferConfig = TransferConfig {
282 iwidth: XspiWidth::OCTO,
283 isize: AddressSize::_16bit,
284 adwidth: XspiWidth::OCTO,
285 address: Some(0),
286 adsize: AddressSize::_32bit,
287 dwidth: XspiWidth::OCTO,
288 instruction: Some(CMD_READ_ID_OCTO as u32),
289 dummy: DummyCycles::_4,
290 ..Default::default()
291 };
292 info!("Reading id: {:#X}", transaction.instruction);
293 self.xspi.blocking_read(&mut buffer, transaction).unwrap();
294 buffer
295 }
296
297 pub fn read_memory(&mut self, addr: u32, buffer: &mut [u8], use_dma: bool) {
298 let transaction = TransferConfig { 509 let transaction = TransferConfig {
299 iwidth: XspiWidth::SING, 510 iwidth: XspiWidth::SING,
300 adwidth: XspiWidth::SING, 511 adwidth: XspiWidth::SING,
301 adsize: AddressSize::_24bit, 512 adsize: AddressSize::_32bit,
302 dwidth: XspiWidth::SING, 513 dwidth: XspiWidth::SING,
303 instruction: Some(CMD_READ as u32), 514 instruction: Some(SpiCommand::FastRead4B as u32),
304 dummy: DummyCycles::_8, 515 dummy: DummyCycles::_8,
305 // dwidth: XspiWidth::QUAD,
306 // instruction: Some(CMD_QUAD_READ as u32),
307 // dummy: DummyCycles::_8,
308 address: Some(addr), 516 address: Some(addr),
309 ..Default::default() 517 ..Default::default()
310 }; 518 };
311 if use_dma { 519
312 self.xspi.blocking_read(buffer, transaction).unwrap(); 520 self.xspi.blocking_read(buffer, transaction).unwrap();
313 } else {
314 self.xspi.blocking_read(buffer, transaction).unwrap();
315 }
316 } 521 }
317 522
318 fn wait_write_finish(&mut self) { 523 fn wait_write_finish(&mut self) {
319 while (self.read_sr() & 0x01) != 0 {} 524 while (self.read_sr() & 0x01) != 0 {}
320 } 525 }
321 526
322 async fn perform_erase(&mut self, addr: u32, cmd: u8) { 527 fn perform_erase(&mut self, addr: u32, cmd: u8) {
323 let transaction = TransferConfig { 528 let transaction = TransferConfig {
324 iwidth: XspiWidth::SING, 529 iwidth: XspiWidth::SING,
325 adwidth: XspiWidth::SING, 530 adwidth: XspiWidth::SING,
326 adsize: AddressSize::_24bit, 531 adsize: AddressSize::_32bit,
327 dwidth: XspiWidth::NONE, 532 dwidth: XspiWidth::NONE,
328 instruction: Some(cmd as u32), 533 instruction: Some(cmd as u32),
329 address: Some(addr), 534 address: Some(addr),
330 dummy: DummyCycles::_0, 535 dummy: DummyCycles::_0,
331 ..Default::default() 536 ..Default::default()
332 }; 537 };
333 self.enable_write().await; 538 self.enable_write();
334 self.xspi.blocking_command(&transaction).unwrap(); 539 self.xspi.blocking_command(&transaction).unwrap();
335 self.wait_write_finish(); 540 self.wait_write_finish();
336 } 541 }
337 542
338 pub async fn erase_sector(&mut self, addr: u32) { 543 pub fn erase_sector(&mut self, addr: u32) {
339 self.perform_erase(addr, CMD_SECTOR_ERASE).await; 544 self.perform_erase(addr, SpiCommand::SectorErase4B as u8);
340 } 545 }
341 546
342 pub async fn erase_block_32k(&mut self, addr: u32) { 547 pub fn erase_block_64k(&mut self, addr: u32) {
343 self.perform_erase(addr, CMD_BLOCK_ERASE_32K).await; 548 self.perform_erase(addr, SpiCommand::BlockErase4B as u8);
344 } 549 }
345 550
346 pub async fn erase_block_64k(&mut self, addr: u32) { 551 pub fn erase_chip(&mut self) {
347 self.perform_erase(addr, CMD_BLOCK_ERASE_64K).await; 552 self.enable_write();
348 } 553 self.exec_command(SpiCommand::ChipErase as u8);
349 554 self.wait_write_finish();
350 pub async fn erase_chip(&mut self) {
351 self.exec_command(CMD_CHIP_ERASE).await;
352 } 555 }
353 556
354 async fn write_page(&mut self, addr: u32, buffer: &[u8], len: usize, use_dma: bool) { 557 fn write_page(&mut self, addr: u32, buffer: &[u8], len: usize) {
355 assert!( 558 assert!(
356 (len as u32 + (addr & 0x000000ff)) <= MEMORY_PAGE_SIZE as u32, 559 (len as u32 + (addr & 0x000000ff)) <= MEMORY_PAGE_SIZE as u32,
357 "write_page(): page write length exceeds page boundary (len = {}, addr = {:X}", 560 "write_page(): page write length exceeds page boundary (len = {}, addr = {:X}",
@@ -361,48 +564,43 @@ impl<I: Instance> FlashMemory<I> {
361 564
362 let transaction = TransferConfig { 565 let transaction = TransferConfig {
363 iwidth: XspiWidth::SING, 566 iwidth: XspiWidth::SING,
364 adsize: AddressSize::_24bit, 567 adsize: AddressSize::_32bit,
365 adwidth: XspiWidth::SING, 568 adwidth: XspiWidth::SING,
366 dwidth: XspiWidth::SING, 569 dwidth: XspiWidth::SING,
367 instruction: Some(CMD_WRITE_PG as u32), 570 instruction: Some(SpiCommand::PageProgram4B as u32),
368 // dwidth: XspiWidth::QUAD,
369 // instruction: Some(CMD_QUAD_WRITE_PG as u32),
370 address: Some(addr), 571 address: Some(addr),
371 dummy: DummyCycles::_0, 572 dummy: DummyCycles::_0,
372 ..Default::default() 573 ..Default::default()
373 }; 574 };
374 self.enable_write().await; 575 self.enable_write();
375 if use_dma { 576 self.xspi.blocking_write(buffer, transaction).unwrap();
376 self.xspi.blocking_write(buffer, transaction).unwrap();
377 } else {
378 self.xspi.blocking_write(buffer, transaction).unwrap();
379 }
380 self.wait_write_finish(); 577 self.wait_write_finish();
381 } 578 }
382 579
383 pub async fn write_memory(&mut self, addr: u32, buffer: &[u8], use_dma: bool) { 580 pub fn write_memory(&mut self, addr: u32, buffer: &[u8]) {
384 let mut left = buffer.len(); 581 let mut left = buffer.len();
385 let mut place = addr; 582 let mut place = addr;
386 let mut chunk_start = 0; 583 let mut chunk_start = 0;
387 584
388 while left > 0 { 585 while left > 0 {
389 let max_chunk_size = MEMORY_PAGE_SIZE - (place & 0x000000ff) as usize; 586 let max_chunk_size = MEMORY_PAGE_SIZE - (place & 0x000000ff) as usize;
390 let chunk_size = if left >= max_chunk_size { max_chunk_size } else { left }; 587 let chunk_size = min(max_chunk_size, left);
391 let chunk = &buffer[chunk_start..(chunk_start + chunk_size)]; 588 let chunk = &buffer[chunk_start..(chunk_start + chunk_size)];
392 self.write_page(place, chunk, chunk_size, use_dma).await; 589 self.write_page(place, chunk, chunk_size);
393 place += chunk_size as u32; 590 place += chunk_size as u32;
394 left -= chunk_size; 591 left -= chunk_size;
395 chunk_start += chunk_size; 592 chunk_start += chunk_size;
396 } 593 }
397 } 594 }
398 595
596 // Note: read_register cannot be used to read the configuration register 2 since there is an
597 // address required for that read.
399 fn read_register(&mut self, cmd: u8) -> u8 { 598 fn read_register(&mut self, cmd: u8) -> u8 {
400 let mut buffer = [0; 1]; 599 let mut buffer = [0; 1];
401 let transaction: TransferConfig = TransferConfig { 600 let transaction: TransferConfig = TransferConfig {
402 iwidth: XspiWidth::SING, 601 iwidth: XspiWidth::SING,
403 isize: AddressSize::_8bit, 602 isize: AddressSize::_8bit,
404 adwidth: XspiWidth::NONE, 603 adwidth: XspiWidth::NONE,
405 adsize: AddressSize::_24bit,
406 dwidth: XspiWidth::SING, 604 dwidth: XspiWidth::SING,
407 instruction: Some(cmd as u32), 605 instruction: Some(cmd as u32),
408 address: None, 606 address: None,
@@ -410,39 +608,345 @@ impl<I: Instance> FlashMemory<I> {
410 ..Default::default() 608 ..Default::default()
411 }; 609 };
412 self.xspi.blocking_read(&mut buffer, transaction).unwrap(); 610 self.xspi.blocking_read(&mut buffer, transaction).unwrap();
413 // info!("Read w25q64 register: 0x{:x}", buffer[0]);
414 buffer[0] 611 buffer[0]
415 } 612 }
416 613
417 fn write_register(&mut self, cmd: u8, value: u8) { 614 pub fn read_sr(&mut self) -> u8 {
418 let buffer = [value; 1]; 615 self.read_register(SpiCommand::ReadStatusRegister as u8)
616 }
617
618 pub fn read_cr(&mut self) -> u8 {
619 self.read_register(SpiCommand::ReadConfigurationRegister as u8)
620 }
621
622 pub fn write_sr_cr(&mut self, sr: u8, cr: u8) {
623 let buffer = [sr, cr];
419 let transaction: TransferConfig = TransferConfig { 624 let transaction: TransferConfig = TransferConfig {
420 iwidth: XspiWidth::SING, 625 iwidth: XspiWidth::SING,
421 isize: AddressSize::_8bit, 626 isize: AddressSize::_8bit,
422 instruction: Some(cmd as u32), 627 instruction: Some(SpiCommand::WriteStatusConfigurationRegister as u32),
423 adsize: AddressSize::_24bit,
424 adwidth: XspiWidth::NONE, 628 adwidth: XspiWidth::NONE,
425 dwidth: XspiWidth::SING, 629 dwidth: XspiWidth::SING,
426 address: None, 630 address: None,
427 dummy: DummyCycles::_0, 631 dummy: DummyCycles::_0,
428 ..Default::default() 632 ..Default::default()
429 }; 633 };
634 self.enable_write();
635 self.xspi.blocking_write(&buffer, transaction).unwrap();
636 self.wait_write_finish();
637 }
638
639 pub fn read_cr2(&mut self, address: u32) -> u8 {
640 let mut buffer = [0; 1];
641 let transaction: TransferConfig = TransferConfig {
642 iwidth: XspiWidth::SING,
643 isize: AddressSize::_8bit,
644 instruction: Some(SpiCommand::ReadConfigurationRegister2 as u32),
645 adsize: AddressSize::_32bit,
646 adwidth: XspiWidth::SING,
647 dwidth: XspiWidth::SING,
648 address: Some(address),
649 dummy: DummyCycles::_0,
650 ..Default::default()
651 };
652 self.xspi.blocking_read(&mut buffer, transaction).unwrap();
653 buffer[0]
654 }
655
656 pub fn write_cr2(&mut self, address: u32, value: u8) {
657 let buffer = [value; 1];
658 let transaction: TransferConfig = TransferConfig {
659 iwidth: XspiWidth::SING,
660 isize: AddressSize::_8bit,
661 instruction: Some(SpiCommand::WriteConfigurationRegister2 as u32),
662 adsize: AddressSize::_32bit,
663 adwidth: XspiWidth::SING,
664 dwidth: XspiWidth::SING,
665 address: Some(address),
666 dummy: DummyCycles::_0,
667 ..Default::default()
668 };
430 self.xspi.blocking_write(&buffer, transaction).unwrap(); 669 self.xspi.blocking_write(&buffer, transaction).unwrap();
670 self.wait_write_finish();
671 }
672}
673
674impl<I: Instance> OpiFlashMemory<I> {
675 pub fn into_spi(mut self) -> SpiFlashMemory<I> {
676 self.disable_opi_mode();
677 SpiFlashMemory { xspi: self.xspi }
678 }
679
680 /// Disable OPI mode and return to SPI
681 pub fn disable_opi_mode(&mut self) {
682 // Clear SOPI and DOPI bits in CR2 volatile register
683 let cr2_0 = self.read_cr2(0x00000000);
684 self.write_cr2(0x00000000, cr2_0 & 0xFC); // Clear bits 0 and 1
685 }
686
687 /// Enable memory-mapped mode for OPI
688 pub fn enable_mm(&mut self) {
689 let read_config = TransferConfig {
690 iwidth: XspiWidth::OCTO,
691 isize: AddressSize::_16bit, // 2-byte command for OPI
692 adwidth: XspiWidth::OCTO,
693 adsize: AddressSize::_32bit,
694 dwidth: XspiWidth::OCTO,
695 instruction: Some(OpiCommand::OctaRead as u32),
696 dummy: DummyCycles::_20, // Default dummy cycles for OPI
697 ..Default::default()
698 };
699
700 let write_config = TransferConfig {
701 iwidth: XspiWidth::OCTO,
702 isize: AddressSize::_16bit,
703 adwidth: XspiWidth::OCTO,
704 adsize: AddressSize::_32bit,
705 dwidth: XspiWidth::OCTO,
706 instruction: Some(OpiCommand::PageProgram4B as u32),
707 dummy: DummyCycles::_0,
708 ..Default::default()
709 };
710
711 self.xspi.enable_memory_mapped_mode(read_config, write_config).unwrap();
712 }
713
714 pub fn disable_mm(&mut self) {
715 self.xspi.disable_memory_mapped_mode();
716 }
717
718 /// Execute OPI command (2-byte command)
719 fn exec_command(&mut self, cmd: OpiCommand) {
720 let transaction = TransferConfig {
721 iwidth: XspiWidth::OCTO,
722 isize: AddressSize::_16bit, // 2-byte command
723 adwidth: XspiWidth::NONE,
724 dwidth: XspiWidth::NONE,
725 instruction: Some(cmd as u32),
726 address: None,
727 dummy: DummyCycles::_0,
728 ..Default::default()
729 };
730 self.xspi.blocking_command(&transaction).unwrap();
731 }
732
733 /// Reset memory using OPI commands
734 pub fn reset_memory(&mut self) {
735 self.exec_command(OpiCommand::ResetEnable);
736 self.exec_command(OpiCommand::ResetMemory);
737 self.wait_write_finish();
431 } 738 }
432 739
740 /// Enable write using OPI command
741 pub fn enable_write(&mut self) {
742 self.exec_command(OpiCommand::WriteEnable);
743 }
744
745 /// Read device ID in OPI mode
746 pub fn read_id(&mut self) -> [u8; 3] {
747 let mut buffer = [0; 3];
748 let transaction = TransferConfig {
749 iwidth: XspiWidth::OCTO,
750 isize: AddressSize::_16bit,
751 adwidth: XspiWidth::OCTO,
752 adsize: AddressSize::_32bit,
753 dwidth: XspiWidth::OCTO,
754 instruction: Some(OpiCommand::ReadIdentification as u32),
755 address: Some(0x00000000), // Dummy address required
756 dummy: DummyCycles::_4,
757 ..Default::default()
758 };
759 self.xspi.blocking_read(&mut buffer, transaction).unwrap();
760 buffer
761 }
762
763 /// Read memory using OPI mode
764 pub fn read_memory(&mut self, addr: u32, buffer: &mut [u8]) {
765 let transaction = TransferConfig {
766 iwidth: XspiWidth::OCTO,
767 isize: AddressSize::_16bit,
768 adwidth: XspiWidth::OCTO,
769 adsize: AddressSize::_32bit,
770 dwidth: XspiWidth::OCTO,
771 instruction: Some(OpiCommand::OctaRead as u32),
772 address: Some(addr),
773 dummy: DummyCycles::_20, // Default for 200MHz operation
774 ..Default::default()
775 };
776 self.xspi.blocking_read(buffer, transaction).unwrap();
777 }
778
779 /// Wait for write completion using OPI status read
780 fn wait_write_finish(&mut self) {
781 while (self.read_sr() & 0x01) != 0 {}
782 }
783
784 /// Perform erase operation using OPI command
785 fn perform_erase(&mut self, addr: u32, cmd: OpiCommand) {
786 let transaction = TransferConfig {
787 iwidth: XspiWidth::OCTO,
788 isize: AddressSize::_16bit,
789 adwidth: XspiWidth::OCTO,
790 adsize: AddressSize::_32bit,
791 dwidth: XspiWidth::NONE,
792 instruction: Some(cmd as u32),
793 address: Some(addr),
794 dummy: DummyCycles::_0,
795 ..Default::default()
796 };
797 self.enable_write();
798 self.xspi.blocking_command(&transaction).unwrap();
799 self.wait_write_finish();
800 }
801
802 /// Erase 4KB sector using OPI
803 pub fn erase_sector(&mut self, addr: u32) {
804 self.perform_erase(addr, OpiCommand::SectorErase4B);
805 }
806
807 /// Erase 64KB block using OPI
808 pub fn erase_block_64k(&mut self, addr: u32) {
809 self.perform_erase(addr, OpiCommand::BlockErase4B);
810 }
811
812 /// Erase entire chip using OPI
813 pub fn erase_chip(&mut self) {
814 self.enable_write();
815 self.exec_command(OpiCommand::ChipErase);
816 self.wait_write_finish();
817 }
818
819 /// Write single page using OPI
820 fn write_page(&mut self, addr: u32, buffer: &[u8], len: usize) {
821 assert!(
822 (len as u32 + (addr & 0x000000ff)) <= MEMORY_PAGE_SIZE as u32,
823 "write_page(): page write length exceeds page boundary (len = {}, addr = {:X})",
824 len,
825 addr
826 );
827
828 let transaction = TransferConfig {
829 iwidth: XspiWidth::OCTO,
830 isize: AddressSize::_16bit,
831 adwidth: XspiWidth::OCTO,
832 adsize: AddressSize::_32bit,
833 dwidth: XspiWidth::OCTO,
834 instruction: Some(OpiCommand::PageProgram4B as u32),
835 address: Some(addr),
836 dummy: DummyCycles::_0,
837 ..Default::default()
838 };
839 self.enable_write();
840 self.xspi.blocking_write(buffer, transaction).unwrap();
841 self.wait_write_finish();
842 }
843
844 /// Write memory using OPI (handles page boundaries)
845 pub fn write_memory(&mut self, addr: u32, buffer: &[u8]) {
846 let mut left = buffer.len();
847 let mut place = addr;
848 let mut chunk_start = 0;
849
850 while left > 0 {
851 let max_chunk_size = MEMORY_PAGE_SIZE - (place & 0x000000ff) as usize;
852 let chunk_size = min(max_chunk_size, left);
853 let chunk = &buffer[chunk_start..(chunk_start + chunk_size)];
854 self.write_page(place, chunk, chunk_size);
855 place += chunk_size as u32;
856 left -= chunk_size;
857 chunk_start += chunk_size;
858 }
859 }
860
861 /// Read register using OPI mode
862 fn read_register(&mut self, cmd: OpiCommand, dummy_addr: u32, dummy_cycles: DummyCycles) -> u8 {
863 let mut buffer = [0; 1];
864 let transaction = TransferConfig {
865 iwidth: XspiWidth::OCTO,
866 isize: AddressSize::_16bit,
867 adwidth: XspiWidth::OCTO,
868 adsize: AddressSize::_32bit,
869 dwidth: XspiWidth::OCTO,
870 instruction: Some(cmd as u32),
871 address: Some(dummy_addr),
872 dummy: dummy_cycles,
873 ..Default::default()
874 };
875 self.xspi.blocking_read(&mut buffer, transaction).unwrap();
876 buffer[0]
877 }
878
879 /// Read Status Register using OPI
433 pub fn read_sr(&mut self) -> u8 { 880 pub fn read_sr(&mut self) -> u8 {
434 self.read_register(CMD_READ_SR) 881 self.read_register(
882 OpiCommand::ReadStatusRegister,
883 0x00000000, // Dummy address
884 DummyCycles::_4,
885 )
435 } 886 }
436 887
888 /// Read Configuration Register using OPI
437 pub fn read_cr(&mut self) -> u8 { 889 pub fn read_cr(&mut self) -> u8 {
438 self.read_register(CMD_READ_CR) 890 self.read_register(
891 OpiCommand::ReadConfigurationRegister,
892 0x00000001, // Address for CR
893 DummyCycles::_4,
894 )
439 } 895 }
440 896
441 pub fn write_sr(&mut self, value: u8) { 897 /// Write Status/Configuration Register using OPI
442 self.write_register(CMD_WRITE_SR, value); 898 pub fn write_sr_cr(&mut self, sr: u8, cr: u8) {
899 let transaction = TransferConfig {
900 iwidth: XspiWidth::OCTO,
901 isize: AddressSize::_16bit,
902 adwidth: XspiWidth::OCTO,
903 adsize: AddressSize::_32bit,
904 dwidth: XspiWidth::OCTO,
905 instruction: Some(OpiCommand::WriteStatusConfigurationRegister as u32),
906 address: Some(0x00000000),
907 dummy: DummyCycles::_0,
908 ..Default::default()
909 };
910
911 self.enable_write();
912 self.xspi.blocking_write(&[sr, cr], transaction).unwrap();
913 self.wait_write_finish();
914 }
915
916 /// Read Configuration Register 2 using OPI
917 pub fn read_cr2(&mut self, address: u32) -> u8 {
918 let mut buffer = [0; 1];
919 let transaction = TransferConfig {
920 iwidth: XspiWidth::OCTO,
921 isize: AddressSize::_16bit,
922 adwidth: XspiWidth::OCTO,
923 adsize: AddressSize::_32bit,
924 dwidth: XspiWidth::OCTO,
925 instruction: Some(OpiCommand::ReadConfigurationRegister2 as u32),
926 address: Some(address),
927 dummy: DummyCycles::_4,
928 ..Default::default()
929 };
930 self.xspi.blocking_read(&mut buffer, transaction).unwrap();
931 buffer[0]
443 } 932 }
444 933
445 pub fn write_cr(&mut self, value: u8) { 934 /// Write Configuration Register 2 using OPI
446 self.write_register(CMD_WRITE_CR, value); 935 pub fn write_cr2(&mut self, address: u32, value: u8) {
936 let transaction = TransferConfig {
937 iwidth: XspiWidth::OCTO,
938 isize: AddressSize::_16bit,
939 adwidth: XspiWidth::OCTO,
940 adsize: AddressSize::_32bit,
941 dwidth: XspiWidth::OCTO,
942 instruction: Some(OpiCommand::WriteConfigurationRegister2 as u32),
943 address: Some(address),
944 dummy: DummyCycles::_0,
945 ..Default::default()
946 };
947
948 self.enable_write();
949 self.xspi.blocking_write(&[value], transaction).unwrap();
950 self.wait_write_finish();
447 } 951 }
448} 952}
diff --git a/examples/stm32l0/src/bin/dds.rs b/examples/stm32l0/src/bin/dds.rs
index a54b28a93..eaa7a61a8 100644
--- a/examples/stm32l0/src/bin/dds.rs
+++ b/examples/stm32l0/src/bin/dds.rs
@@ -11,7 +11,7 @@ use embassy_stm32::rcc::*;
11use embassy_stm32::time::hz; 11use embassy_stm32::time::hz;
12use embassy_stm32::timer::low_level::{Timer as LLTimer, *}; 12use embassy_stm32::timer::low_level::{Timer as LLTimer, *};
13use embassy_stm32::timer::simple_pwm::PwmPin; 13use embassy_stm32::timer::simple_pwm::PwmPin;
14use embassy_stm32::timer::Channel; 14use embassy_stm32::timer::{Ch3, Channel};
15use embassy_stm32::{interrupt, pac, Config}; 15use embassy_stm32::{interrupt, pac, Config};
16use panic_probe as _; 16use panic_probe as _;
17 17
@@ -70,7 +70,7 @@ async fn main(_spawner: Spawner) {
70 let p = embassy_stm32::init(config); 70 let p = embassy_stm32::init(config);
71 71
72 // setup PWM pin in AF mode 72 // setup PWM pin in AF mode
73 let _ch3 = PwmPin::new_ch3(p.PA2, OutputType::PushPull); 73 let _ch3 = PwmPin::<_, Ch3>::new(p.PA2, OutputType::PushPull);
74 74
75 // initialize timer 75 // initialize timer
76 // we cannot use SimplePWM here because the Time is privately encapsulated 76 // we cannot use SimplePWM here because the Time is privately encapsulated
diff --git a/examples/stm32l1/Cargo.toml b/examples/stm32l1/Cargo.toml
index a0a7916a7..5d5d401f6 100644
--- a/examples/stm32l1/Cargo.toml
+++ b/examples/stm32l1/Cargo.toml
@@ -9,7 +9,7 @@ embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["de
9embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } 9embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] }
10embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 10embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
11embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = [ "defmt", "stm32l151cb-a", "time-driver-any", "memory-x"] } 11embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = [ "defmt", "stm32l151cb-a", "time-driver-any", "memory-x"] }
12embassy-usb = { version = "0.4.0", path = "../../embassy-usb", features = ["defmt"] } 12embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = ["defmt"] }
13embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 13embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
14 14
15defmt = "1.0.1" 15defmt = "1.0.1"
diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml
index 7da09e5b0..a6b4efcf8 100644
--- a/examples/stm32l4/Cargo.toml
+++ b/examples/stm32l4/Cargo.toml
@@ -10,8 +10,8 @@ embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = [
10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } 11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] }
12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768", ] } 12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768", ] }
13embassy-embedded-hal = { version = "0.3.0", path = "../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.3.1", path = "../../embassy-embedded-hal" }
14embassy-usb = { version = "0.4.0", path = "../../embassy-usb", features = ["defmt"] } 14embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = ["defmt"] }
15embassy-net-adin1110 = { version = "0.3.0", path = "../../embassy-net-adin1110" } 15embassy-net-adin1110 = { version = "0.3.0", path = "../../embassy-net-adin1110" }
16embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "udp", "tcp", "dhcpv4", "medium-ethernet"] } 16embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "udp", "tcp", "dhcpv4", "medium-ethernet"] }
17embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 17embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
diff --git a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs
index 354ac90b2..dc90a3b85 100644
--- a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs
+++ b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs
@@ -59,7 +59,7 @@ pub type SpeSpiCs = ExclusiveDevice<SpeSpi, Output<'static>, Delay>;
59pub type SpeInt = exti::ExtiInput<'static>; 59pub type SpeInt = exti::ExtiInput<'static>;
60pub type SpeRst = Output<'static>; 60pub type SpeRst = Output<'static>;
61pub type Adin1110T = ADIN1110<SpeSpiCs>; 61pub type Adin1110T = ADIN1110<SpeSpiCs>;
62pub type TempSensI2c = I2c<'static, Async>; 62pub type TempSensI2c = I2c<'static, Async, i2c::Master>;
63 63
64static TEMP: AtomicI32 = AtomicI32::new(0); 64static TEMP: AtomicI32 = AtomicI32::new(0);
65 65
diff --git a/examples/stm32l432/src/bin/qspi_mmap.rs b/examples/stm32l432/src/bin/qspi_mmap.rs
index 86a20eb3d..075458fe5 100644
--- a/examples/stm32l432/src/bin/qspi_mmap.rs
+++ b/examples/stm32l432/src/bin/qspi_mmap.rs
@@ -7,7 +7,7 @@
7use defmt::info; 7use defmt::info;
8use embassy_stm32::mode; 8use embassy_stm32::mode;
9use embassy_stm32::qspi::enums::{ 9use embassy_stm32::qspi::enums::{
10 AddressSize, ChipSelectHighTime, DummyCycles, FIFOThresholdLevel, MemorySize, QspiWidth, 10 AddressSize, ChipSelectHighTime, DummyCycles, FIFOThresholdLevel, MemorySize, QspiWidth, SampleShifting,
11}; 11};
12use embassy_stm32::qspi::{self, Instance, TransferConfig}; 12use embassy_stm32::qspi::{self, Instance, TransferConfig};
13pub struct FlashMemory<I: Instance> { 13pub struct FlashMemory<I: Instance> {
@@ -252,6 +252,7 @@ async fn main(_spawner: Spawner) {
252 prescaler: 200, 252 prescaler: 200,
253 cs_high_time: ChipSelectHighTime::_1Cycle, 253 cs_high_time: ChipSelectHighTime::_1Cycle,
254 fifo_threshold: FIFOThresholdLevel::_16Bytes, 254 fifo_threshold: FIFOThresholdLevel::_16Bytes,
255 sample_shifting: SampleShifting::None,
255 }; 256 };
256 let driver = qspi::Qspi::new_bank1(p.QUADSPI, p.PB1, p.PB0, p.PA7, p.PA6, p.PA3, p.PA2, p.DMA2_CH7, config); 257 let driver = qspi::Qspi::new_bank1(p.QUADSPI, p.PB1, p.PB0, p.PA7, p.PA6, p.PA3, p.PA2, p.DMA2_CH7, config);
257 let mut flash = FlashMemory::new(driver); 258 let mut flash = FlashMemory::new(driver);
diff --git a/examples/stm32l5/Cargo.toml b/examples/stm32l5/Cargo.toml
index 3ea3bcd5c..1379d963c 100644
--- a/examples/stm32l5/Cargo.toml
+++ b/examples/stm32l5/Cargo.toml
@@ -10,7 +10,7 @@ embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = [
10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } 11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] }
12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-usb = { version = "0.4.0", path = "../../embassy-usb", features = ["defmt"] } 13embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = ["defmt"] }
14embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"] } 14embassy-net = { version = "0.7.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"] }
15embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 15embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
16usbd-hid = "0.8.1" 16usbd-hid = "0.8.1"
diff --git a/examples/stm32u0/Cargo.toml b/examples/stm32u0/Cargo.toml
index 3aa45dc79..612d12ac2 100644
--- a/examples/stm32u0/Cargo.toml
+++ b/examples/stm32u0/Cargo.toml
@@ -10,7 +10,7 @@ embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = [
10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } 11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] }
12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-usb = { version = "0.4.0", path = "../../embassy-usb", default-features = false, features = ["defmt"] } 13embassy-usb = { version = "0.5.0", path = "../../embassy-usb", default-features = false, features = ["defmt"] }
14embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 14embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
15 15
16defmt = "1.0.1" 16defmt = "1.0.1"
diff --git a/examples/stm32u5/Cargo.toml b/examples/stm32u5/Cargo.toml
index 777d3ed4c..f92e85852 100644
--- a/examples/stm32u5/Cargo.toml
+++ b/examples/stm32u5/Cargo.toml
@@ -10,7 +10,7 @@ embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = ["
10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } 11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] }
12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-usb = { version = "0.4.0", path = "../../embassy-usb", features = ["defmt"] } 13embassy-usb = { version = "0.5.0", path = "../../embassy-usb", features = ["defmt"] }
14embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 14embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
15 15
16defmt = "1.0.1" 16defmt = "1.0.1"
diff --git a/examples/stm32wb/src/bin/gatt_server.rs b/examples/stm32wb/src/bin/gatt_server.rs
index 041dc0cf5..9864fa026 100644
--- a/examples/stm32wb/src/bin/gatt_server.rs
+++ b/examples/stm32wb/src/bin/gatt_server.rs
@@ -27,6 +27,7 @@ use embassy_stm32_wpan::hci::vendor::event::{self, AttributeHandle, VendorEvent}
27use embassy_stm32_wpan::hci::{BdAddr, Event}; 27use embassy_stm32_wpan::hci::{BdAddr, Event};
28use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; 28use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp;
29use embassy_stm32_wpan::sub::ble::Ble; 29use embassy_stm32_wpan::sub::ble::Ble;
30use embassy_stm32_wpan::sub::mm;
30use embassy_stm32_wpan::TlMbox; 31use embassy_stm32_wpan::TlMbox;
31use {defmt_rtt as _, panic_probe as _}; 32use {defmt_rtt as _, panic_probe as _};
32 33
@@ -38,7 +39,7 @@ bind_interrupts!(struct Irqs{
38const BLE_GAP_DEVICE_NAME_LENGTH: u8 = 7; 39const BLE_GAP_DEVICE_NAME_LENGTH: u8 = 7;
39 40
40#[embassy_executor::main] 41#[embassy_executor::main]
41async fn main(_spawner: Spawner) { 42async fn main(spawner: Spawner) {
42 /* 43 /*
43 How to make this work: 44 How to make this work:
44 45
@@ -70,6 +71,7 @@ async fn main(_spawner: Spawner) {
70 let config = Config::default(); 71 let config = Config::default();
71 let mut mbox = TlMbox::init(p.IPCC, Irqs, config); 72 let mut mbox = TlMbox::init(p.IPCC, Irqs, config);
72 73
74 spawner.spawn(run_mm_queue(mbox.mm_subsystem)).unwrap();
73 let sys_event = mbox.sys_subsystem.read().await; 75 let sys_event = mbox.sys_subsystem.read().await;
74 info!("sys event: {}", sys_event.payload()); 76 info!("sys event: {}", sys_event.payload());
75 77
@@ -221,6 +223,11 @@ async fn main(_spawner: Spawner) {
221 } 223 }
222} 224}
223 225
226#[embassy_executor::task]
227async fn run_mm_queue(memory_manager: mm::MemoryManager) {
228 memory_manager.run_queue().await;
229}
230
224fn get_bd_addr() -> BdAddr { 231fn get_bd_addr() -> BdAddr {
225 let mut bytes = [0u8; 6]; 232 let mut bytes = [0u8; 6];
226 233
diff --git a/examples/stm32wba/src/bin/adc.rs b/examples/stm32wba/src/bin/adc.rs
new file mode 100644
index 000000000..a9651d57e
--- /dev/null
+++ b/examples/stm32wba/src/bin/adc.rs
@@ -0,0 +1,49 @@
1#![no_std]
2#![no_main]
3
4use defmt::*;
5use embassy_stm32::adc::{adc4, AdcChannel};
6use {defmt_rtt as _, panic_probe as _};
7
8#[embassy_executor::main]
9async fn main(_spawner: embassy_executor::Spawner) {
10 let config = embassy_stm32::Config::default();
11
12 let mut p = embassy_stm32::init(config);
13
14 // **** ADC4 init ****
15 let mut adc4 = adc4::Adc4::new(p.ADC4);
16 let mut adc4_pin1 = p.PA0; // A4
17 let mut adc4_pin2 = p.PA1; // A5
18 adc4.set_resolution(adc4::Resolution::BITS12);
19 adc4.set_averaging(adc4::Averaging::Samples256);
20 adc4.set_sample_time(adc4::SampleTime::CYCLES1_5);
21 let max4 = adc4::resolution_to_max_count(adc4::Resolution::BITS12);
22
23 // **** ADC4 blocking read ****
24 let raw: u16 = adc4.blocking_read(&mut adc4_pin1);
25 let volt: f32 = 3.0 * raw as f32 / max4 as f32;
26 info!("Read adc4 pin 1 {}", volt);
27
28 let raw: u16 = adc4.blocking_read(&mut adc4_pin2);
29 let volt: f32 = 3.3 * raw as f32 / max4 as f32;
30 info!("Read adc4 pin 2 {}", volt);
31
32 // **** ADC4 async read ****
33 let mut degraded41 = adc4_pin1.degrade_adc();
34 let mut degraded42 = adc4_pin2.degrade_adc();
35 let mut measurements = [0u16; 2];
36
37 // The channels must be in ascending order and can't repeat for ADC4
38 adc4.read(
39 p.GPDMA1_CH1.reborrow(),
40 [&mut degraded42, &mut degraded41].into_iter(),
41 &mut measurements,
42 )
43 .await
44 .unwrap();
45 let volt2: f32 = 3.3 * measurements[0] as f32 / max4 as f32;
46 let volt1: f32 = 3.0 * measurements[1] as f32 / max4 as f32;
47 info!("Async read 4 pin 1 {}", volt1);
48 info!("Async read 4 pin 2 {}", volt2);
49}
diff --git a/examples/stm32wl/Cargo.toml b/examples/stm32wl/Cargo.toml
index 5ecd77443..1c5d9c07a 100644
--- a/examples/stm32wl/Cargo.toml
+++ b/examples/stm32wl/Cargo.toml
@@ -10,7 +10,7 @@ embassy-stm32 = { version = "0.2.0", path = "../../embassy-stm32", features = ["
10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.7.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] } 11embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt"] }
12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 12embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-embedded-hal = { version = "0.3.0", path = "../../embassy-embedded-hal" } 13embassy-embedded-hal = { version = "0.3.1", path = "../../embassy-embedded-hal" }
14 14
15defmt = "1.0.1" 15defmt = "1.0.1"
16defmt-rtt = "1.0.0" 16defmt-rtt = "1.0.0"