diff options
| author | Tyler <[email protected]> | 2023-09-29 20:02:24 -0600 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-09-29 20:02:24 -0600 |
| commit | 2f9b59c5cf21f1e2761a9ccefdfd86f0edea829c (patch) | |
| tree | 8964744b4fb753cf98f6f413464106c4d2a72976 /examples | |
| parent | ce91fb2bfc846570ef543a09396c428d70675245 (diff) | |
| parent | 95b3d9eb3b3657de3d7bc9c04f8fb83eae901640 (diff) | |
Merge branch 'main' into issue-1974-add-sai-driver
Diffstat (limited to 'examples')
116 files changed, 1550 insertions, 345 deletions
diff --git a/examples/boot/application/nrf/Cargo.toml b/examples/boot/application/nrf/Cargo.toml index 46ce7ba9b..435a33919 100644 --- a/examples/boot/application/nrf/Cargo.toml +++ b/examples/boot/application/nrf/Cargo.toml | |||
| @@ -5,9 +5,9 @@ version = "0.1.0" | |||
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../../../embassy-sync" } | 8 | embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" } |
| 9 | embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers", "arch-cortex-m", "executor-thread"] } | 9 | embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers", "arch-cortex-m", "executor-thread"] } |
| 10 | embassy-time = { version = "0.1.2", path = "../../../../embassy-time", features = ["nightly"] } | 10 | embassy-time = { version = "0.1.3", path = "../../../../embassy-time", features = ["nightly"] } |
| 11 | embassy-nrf = { version = "0.1.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly"] } | 11 | embassy-nrf = { version = "0.1.0", path = "../../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly"] } |
| 12 | embassy-boot = { version = "0.1.0", path = "../../../../embassy-boot/boot", features = ["nightly"] } | 12 | embassy-boot = { version = "0.1.0", path = "../../../../embassy-boot/boot", features = ["nightly"] } |
| 13 | embassy-boot-nrf = { version = "0.1.0", path = "../../../../embassy-boot/nrf", features = ["nightly"] } | 13 | embassy-boot-nrf = { version = "0.1.0", path = "../../../../embassy-boot/nrf", features = ["nightly"] } |
diff --git a/examples/boot/application/rp/Cargo.toml b/examples/boot/application/rp/Cargo.toml index be85f4437..01cfc5994 100644 --- a/examples/boot/application/rp/Cargo.toml +++ b/examples/boot/application/rp/Cargo.toml | |||
| @@ -5,9 +5,9 @@ version = "0.1.0" | |||
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../../../embassy-sync" } | 8 | embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" } |
| 9 | embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers", "arch-cortex-m", "executor-thread"] } | 9 | embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers", "arch-cortex-m", "executor-thread"] } |
| 10 | embassy-time = { version = "0.1.2", path = "../../../../embassy-time", features = ["nightly"] } | 10 | embassy-time = { version = "0.1.3", path = "../../../../embassy-time", features = ["nightly"] } |
| 11 | embassy-rp = { version = "0.1.0", path = "../../../../embassy-rp", features = ["time-driver", "unstable-traits", "nightly"] } | 11 | embassy-rp = { version = "0.1.0", path = "../../../../embassy-rp", features = ["time-driver", "unstable-traits", "nightly"] } |
| 12 | embassy-boot-rp = { version = "0.1.0", path = "../../../../embassy-boot/rp", features = ["nightly"] } | 12 | embassy-boot-rp = { version = "0.1.0", path = "../../../../embassy-boot/rp", features = ["nightly"] } |
| 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } | 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } |
| @@ -27,6 +27,7 @@ default = ["panic-reset"] | |||
| 27 | debug = [ | 27 | debug = [ |
| 28 | "embassy-rp/defmt", | 28 | "embassy-rp/defmt", |
| 29 | "embassy-boot-rp/defmt", | 29 | "embassy-boot-rp/defmt", |
| 30 | "embassy-sync/defmt", | ||
| 30 | "panic-probe" | 31 | "panic-probe" |
| 31 | ] | 32 | ] |
| 32 | skip-include = [] | 33 | skip-include = [] |
diff --git a/examples/boot/application/rp/src/bin/a.rs b/examples/boot/application/rp/src/bin/a.rs index 15fdaca82..a4602a7ed 100644 --- a/examples/boot/application/rp/src/bin/a.rs +++ b/examples/boot/application/rp/src/bin/a.rs | |||
| @@ -38,7 +38,7 @@ async fn main(_s: Spawner) { | |||
| 38 | let flash = Mutex::new(RefCell::new(flash)); | 38 | let flash = Mutex::new(RefCell::new(flash)); |
| 39 | 39 | ||
| 40 | let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash); | 40 | let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash); |
| 41 | let mut aligned = AlignedBuffer([0; 4]); | 41 | let mut aligned = AlignedBuffer([0; 1]); |
| 42 | let mut updater = BlockingFirmwareUpdater::new(config, &mut aligned.0); | 42 | let mut updater = BlockingFirmwareUpdater::new(config, &mut aligned.0); |
| 43 | 43 | ||
| 44 | Timer::after(Duration::from_secs(5)).await; | 44 | Timer::after(Duration::from_secs(5)).await; |
diff --git a/examples/boot/application/stm32f3/Cargo.toml b/examples/boot/application/stm32f3/Cargo.toml index ea8789332..a0649cf83 100644 --- a/examples/boot/application/stm32f3/Cargo.toml +++ b/examples/boot/application/stm32f3/Cargo.toml | |||
| @@ -5,9 +5,9 @@ version = "0.1.0" | |||
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" } |
| 9 | embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } | 9 | embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.2", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.3", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f303re", "time-driver-any", "exti"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f303re", "time-driver-any", "exti"] } |
| 12 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } | 12 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } |
| 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } | 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } |
| @@ -25,5 +25,6 @@ defmt = [ | |||
| 25 | "dep:defmt", | 25 | "dep:defmt", |
| 26 | "embassy-stm32/defmt", | 26 | "embassy-stm32/defmt", |
| 27 | "embassy-boot-stm32/defmt", | 27 | "embassy-boot-stm32/defmt", |
| 28 | "embassy-sync/defmt", | ||
| 28 | ] | 29 | ] |
| 29 | skip-include = [] | 30 | skip-include = [] |
diff --git a/examples/boot/application/stm32f7/Cargo.toml b/examples/boot/application/stm32f7/Cargo.toml index b39bc2922..ca1c0c424 100644 --- a/examples/boot/application/stm32f7/Cargo.toml +++ b/examples/boot/application/stm32f7/Cargo.toml | |||
| @@ -5,9 +5,9 @@ version = "0.1.0" | |||
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" } |
| 9 | embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } | 9 | embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.2", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.3", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f767zi", "time-driver-any", "exti"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f767zi", "time-driver-any", "exti"] } |
| 12 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } | 12 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } |
| 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } | 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } |
| @@ -26,5 +26,6 @@ defmt = [ | |||
| 26 | "dep:defmt", | 26 | "dep:defmt", |
| 27 | "embassy-stm32/defmt", | 27 | "embassy-stm32/defmt", |
| 28 | "embassy-boot-stm32/defmt", | 28 | "embassy-boot-stm32/defmt", |
| 29 | "embassy-sync/defmt", | ||
| 29 | ] | 30 | ] |
| 30 | skip-include = [] | 31 | skip-include = [] |
diff --git a/examples/boot/application/stm32h7/Cargo.toml b/examples/boot/application/stm32h7/Cargo.toml index f015b2cae..e50c8c415 100644 --- a/examples/boot/application/stm32h7/Cargo.toml +++ b/examples/boot/application/stm32h7/Cargo.toml | |||
| @@ -5,9 +5,9 @@ version = "0.1.0" | |||
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../../../embassy-sync" } | 8 | embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" } |
| 9 | embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } | 9 | embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.2", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.3", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32h743zi", "time-driver-any", "exti"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32h743zi", "time-driver-any", "exti"] } |
| 12 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } | 12 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } |
| 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } | 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } |
| @@ -26,5 +26,6 @@ defmt = [ | |||
| 26 | "dep:defmt", | 26 | "dep:defmt", |
| 27 | "embassy-stm32/defmt", | 27 | "embassy-stm32/defmt", |
| 28 | "embassy-boot-stm32/defmt", | 28 | "embassy-boot-stm32/defmt", |
| 29 | "embassy-sync/defmt", | ||
| 29 | ] | 30 | ] |
| 30 | skip-include = [] | 31 | skip-include = [] |
diff --git a/examples/boot/application/stm32l0/Cargo.toml b/examples/boot/application/stm32l0/Cargo.toml index f221e1de7..1f1a0f3cf 100644 --- a/examples/boot/application/stm32l0/Cargo.toml +++ b/examples/boot/application/stm32l0/Cargo.toml | |||
| @@ -5,9 +5,9 @@ version = "0.1.0" | |||
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" } |
| 9 | embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } | 9 | embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.2", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.3", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l072cz", "time-driver-any", "exti", "memory-x"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l072cz", "time-driver-any", "exti", "memory-x"] } |
| 12 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } | 12 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } |
| 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } | 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } |
| @@ -25,5 +25,6 @@ defmt = [ | |||
| 25 | "dep:defmt", | 25 | "dep:defmt", |
| 26 | "embassy-stm32/defmt", | 26 | "embassy-stm32/defmt", |
| 27 | "embassy-boot-stm32/defmt", | 27 | "embassy-boot-stm32/defmt", |
| 28 | "embassy-sync/defmt", | ||
| 28 | ] | 29 | ] |
| 29 | skip-include = [] | 30 | skip-include = [] |
diff --git a/examples/boot/application/stm32l1/Cargo.toml b/examples/boot/application/stm32l1/Cargo.toml index 2896afa3e..45b12813e 100644 --- a/examples/boot/application/stm32l1/Cargo.toml +++ b/examples/boot/application/stm32l1/Cargo.toml | |||
| @@ -5,9 +5,9 @@ version = "0.1.0" | |||
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" } |
| 9 | embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } | 9 | embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.2", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.3", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l151cb-a", "time-driver-any", "exti"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l151cb-a", "time-driver-any", "exti"] } |
| 12 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } | 12 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } |
| 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } | 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } |
| @@ -25,5 +25,6 @@ defmt = [ | |||
| 25 | "dep:defmt", | 25 | "dep:defmt", |
| 26 | "embassy-stm32/defmt", | 26 | "embassy-stm32/defmt", |
| 27 | "embassy-boot-stm32/defmt", | 27 | "embassy-boot-stm32/defmt", |
| 28 | "embassy-sync/defmt", | ||
| 28 | ] | 29 | ] |
| 29 | skip-include = [] | 30 | skip-include = [] |
diff --git a/examples/boot/application/stm32l4/Cargo.toml b/examples/boot/application/stm32l4/Cargo.toml index 50d8967a1..d0d0d0fbe 100644 --- a/examples/boot/application/stm32l4/Cargo.toml +++ b/examples/boot/application/stm32l4/Cargo.toml | |||
| @@ -5,9 +5,9 @@ version = "0.1.0" | |||
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" } |
| 9 | embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } | 9 | embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.2", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.3", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l475vg", "time-driver-any", "exti"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l475vg", "time-driver-any", "exti"] } |
| 12 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } | 12 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } |
| 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } | 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } |
| @@ -25,5 +25,6 @@ defmt = [ | |||
| 25 | "dep:defmt", | 25 | "dep:defmt", |
| 26 | "embassy-stm32/defmt", | 26 | "embassy-stm32/defmt", |
| 27 | "embassy-boot-stm32/defmt", | 27 | "embassy-boot-stm32/defmt", |
| 28 | "embassy-sync/defmt", | ||
| 28 | ] | 29 | ] |
| 29 | skip-include = [] | 30 | skip-include = [] |
diff --git a/examples/boot/application/stm32wl/Cargo.toml b/examples/boot/application/stm32wl/Cargo.toml index 275414391..3265b9f1a 100644 --- a/examples/boot/application/stm32wl/Cargo.toml +++ b/examples/boot/application/stm32wl/Cargo.toml | |||
| @@ -5,9 +5,9 @@ version = "0.1.0" | |||
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.3.0", path = "../../../../embassy-sync" } |
| 9 | embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } | 9 | embassy-executor = { version = "0.3.0", path = "../../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "nightly", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.2", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.3", path = "../../../../embassy-time", features = ["nightly", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32wl55jc-cm4", "time-driver-any", "exti"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32wl55jc-cm4", "time-driver-any", "exti"] } |
| 12 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } | 12 | embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32", features = ["nightly"] } |
| 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } | 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" } |
| @@ -25,5 +25,6 @@ defmt = [ | |||
| 25 | "dep:defmt", | 25 | "dep:defmt", |
| 26 | "embassy-stm32/defmt", | 26 | "embassy-stm32/defmt", |
| 27 | "embassy-boot-stm32/defmt", | 27 | "embassy-boot-stm32/defmt", |
| 28 | "embassy-sync/defmt", | ||
| 28 | ] | 29 | ] |
| 29 | skip-include = [] | 30 | skip-include = [] |
diff --git a/examples/boot/bootloader/nrf/Cargo.toml b/examples/boot/bootloader/nrf/Cargo.toml index 40656f359..42391778d 100644 --- a/examples/boot/bootloader/nrf/Cargo.toml +++ b/examples/boot/bootloader/nrf/Cargo.toml | |||
| @@ -25,7 +25,7 @@ defmt = [ | |||
| 25 | softdevice = [ | 25 | softdevice = [ |
| 26 | "embassy-boot-nrf/softdevice", | 26 | "embassy-boot-nrf/softdevice", |
| 27 | ] | 27 | ] |
| 28 | debug = ["defmt-rtt"] | 28 | debug = ["defmt-rtt", "defmt"] |
| 29 | 29 | ||
| 30 | [profile.dev] | 30 | [profile.dev] |
| 31 | debug = 2 | 31 | debug = 2 |
diff --git a/examples/boot/bootloader/stm32/Cargo.toml b/examples/boot/bootloader/stm32/Cargo.toml index 6436f2fee..9175768d6 100644 --- a/examples/boot/bootloader/stm32/Cargo.toml +++ b/examples/boot/bootloader/stm32/Cargo.toml | |||
| @@ -24,7 +24,7 @@ defmt = [ | |||
| 24 | "embassy-boot-stm32/defmt", | 24 | "embassy-boot-stm32/defmt", |
| 25 | "embassy-stm32/defmt", | 25 | "embassy-stm32/defmt", |
| 26 | ] | 26 | ] |
| 27 | debug = ["defmt-rtt"] | 27 | debug = ["defmt-rtt", "defmt"] |
| 28 | 28 | ||
| 29 | [profile.dev] | 29 | [profile.dev] |
| 30 | debug = 2 | 30 | debug = 2 |
diff --git a/examples/nrf-rtos-trace/Cargo.toml b/examples/nrf-rtos-trace/Cargo.toml index b06722f5c..e402e49f4 100644 --- a/examples/nrf-rtos-trace/Cargo.toml +++ b/examples/nrf-rtos-trace/Cargo.toml | |||
| @@ -16,9 +16,9 @@ log = [ | |||
| 16 | ] | 16 | ] |
| 17 | 17 | ||
| 18 | [dependencies] | 18 | [dependencies] |
| 19 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync" } | 19 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync" } |
| 20 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "rtos-trace", "rtos-trace-interrupt", "integrated-timers"] } | 20 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "rtos-trace", "rtos-trace-interrupt", "integrated-timers"] } |
| 21 | embassy-time = { version = "0.1.2", path = "../../embassy-time" } | 21 | embassy-time = { version = "0.1.3", path = "../../embassy-time" } |
| 22 | embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } | 22 | embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } |
| 23 | 23 | ||
| 24 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } | 24 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } |
diff --git a/examples/nrf52840-rtic/Cargo.toml b/examples/nrf52840-rtic/Cargo.toml index 715f1ecfe..c588b807e 100644 --- a/examples/nrf52840-rtic/Cargo.toml +++ b/examples/nrf52840-rtic/Cargo.toml | |||
| @@ -8,8 +8,8 @@ license = "MIT OR Apache-2.0" | |||
| 8 | rtic = { version = "2", features = ["thumbv7-backend"] } | 8 | rtic = { version = "2", features = ["thumbv7-backend"] } |
| 9 | 9 | ||
| 10 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | 10 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } |
| 11 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 11 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } |
| 12 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime", "generic-queue"] } | 12 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime", "generic-queue"] } |
| 13 | embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["nightly", "unstable-traits", "defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } | 13 | embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["nightly", "unstable-traits", "defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } |
| 14 | 14 | ||
| 15 | defmt = "0.3" | 15 | defmt = "0.3" |
diff --git a/examples/nrf52840/Cargo.toml b/examples/nrf52840/Cargo.toml index 1b2f1eb11..d45e006c7 100644 --- a/examples/nrf52840/Cargo.toml +++ b/examples/nrf52840/Cargo.toml | |||
| @@ -29,18 +29,18 @@ nightly = [ | |||
| 29 | 29 | ||
| 30 | [dependencies] | 30 | [dependencies] |
| 31 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | 31 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } |
| 32 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 32 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } |
| 33 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } | 33 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } |
| 34 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } | 34 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } |
| 35 | embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } | 35 | embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } |
| 36 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"], optional = true } | 36 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"], optional = true } |
| 37 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt", "msos-descriptor",], optional = true } | 37 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt", "msos-descriptor",], optional = true } |
| 38 | embedded-io = { version = "0.5.0", features = ["defmt-03"] } | 38 | embedded-io = { version = "0.5.0", features = ["defmt-03"] } |
| 39 | embedded-io-async = { version = "0.5.0", optional = true, features = ["defmt-03"] } | 39 | embedded-io-async = { version = "0.5.0", optional = true, features = ["defmt-03"] } |
| 40 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["time", "defmt"], optional = true } | 40 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["time", "defmt"], optional = true } |
| 41 | lora-phy = { version = "1", optional = true } | 41 | lora-phy = { version = "2", optional = true } |
| 42 | lorawan-device = { version = "0.10.0", default-features = false, features = ["async", "external-lora-phy"], optional = true } | 42 | lorawan-device = { version = "0.11.0", default-features = false, features = ["async", "external-lora-phy"], optional = true } |
| 43 | lorawan = { version = "0.7.3", default-features = false, features = ["default-crypto"], optional = true } | 43 | lorawan = { version = "0.7.4", default-features = false, features = ["default-crypto"], optional = true } |
| 44 | embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"], optional = true } | 44 | embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"], optional = true } |
| 45 | embassy-net-enc28j60 = { version = "0.1.0", path = "../../embassy-net-enc28j60", features = ["defmt"], optional = true } | 45 | embassy-net-enc28j60 = { version = "0.1.0", path = "../../embassy-net-enc28j60", features = ["defmt"], optional = true } |
| 46 | 46 | ||
| @@ -65,6 +65,3 @@ microfft = "0.5.0" | |||
| 65 | 65 | ||
| 66 | [profile.release] | 66 | [profile.release] |
| 67 | debug = 2 | 67 | debug = 2 |
| 68 | |||
| 69 | [patch.crates-io] | ||
| 70 | lora-phy = { git = "https://github.com/embassy-rs/lora-phy", rev = "1323eccc1c470d4259f95f4f315d1be830d572a3"} \ No newline at end of file | ||
diff --git a/examples/nrf52840/src/bin/lora_cad.rs b/examples/nrf52840/src/bin/lora_cad.rs index beca061ed..3a98133c9 100644 --- a/examples/nrf52840/src/bin/lora_cad.rs +++ b/examples/nrf52840/src/bin/lora_cad.rs | |||
| @@ -41,10 +41,8 @@ async fn main(_spawner: Spawner) { | |||
| 41 | let iv = | 41 | let iv = |
| 42 | GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); | 42 | GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); |
| 43 | 43 | ||
| 44 | let mut delay = Delay; | ||
| 45 | |||
| 46 | let mut lora = { | 44 | let mut lora = { |
| 47 | match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, &mut delay).await { | 45 | match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, Delay).await { |
| 48 | Ok(l) => l, | 46 | Ok(l) => l, |
| 49 | Err(err) => { | 47 | Err(err) => { |
| 50 | info!("Radio error = {}", err); | 48 | info!("Radio error = {}", err); |
diff --git a/examples/nrf52840/src/bin/lora_lorawan.rs b/examples/nrf52840/src/bin/lora_lorawan.rs index c953680c6..666330ba1 100644 --- a/examples/nrf52840/src/bin/lora_lorawan.rs +++ b/examples/nrf52840/src/bin/lora_lorawan.rs | |||
| @@ -20,6 +20,7 @@ use lora_phy::LoRa; | |||
| 20 | use lorawan::default_crypto::DefaultFactory as Crypto; | 20 | use lorawan::default_crypto::DefaultFactory as Crypto; |
| 21 | use lorawan_device::async_device::lora_radio::LoRaRadio; | 21 | use lorawan_device::async_device::lora_radio::LoRaRadio; |
| 22 | use lorawan_device::async_device::{region, Device, JoinMode}; | 22 | use lorawan_device::async_device::{region, Device, JoinMode}; |
| 23 | use lorawan_device::{AppEui, AppKey, DevEui}; | ||
| 23 | use {defmt_rtt as _, panic_probe as _}; | 24 | use {defmt_rtt as _, panic_probe as _}; |
| 24 | 25 | ||
| 25 | const LORAWAN_REGION: region::Region = region::Region::EU868; // warning: set this appropriately for the region | 26 | const LORAWAN_REGION: region::Region = region::Region::EU868; // warning: set this appropriately for the region |
| @@ -47,10 +48,8 @@ async fn main(_spawner: Spawner) { | |||
| 47 | let iv = | 48 | let iv = |
| 48 | GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); | 49 | GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); |
| 49 | 50 | ||
| 50 | let mut delay = Delay; | ||
| 51 | |||
| 52 | let lora = { | 51 | let lora = { |
| 53 | match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), true, &mut delay).await { | 52 | match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), true, Delay).await { |
| 54 | Ok(l) => l, | 53 | Ok(l) => l, |
| 55 | Err(err) => { | 54 | Err(err) => { |
| 56 | info!("Radio error = {}", err); | 55 | info!("Radio error = {}", err); |
| @@ -68,9 +67,9 @@ async fn main(_spawner: Spawner) { | |||
| 68 | // TODO: Adjust the EUI and Keys according to your network credentials | 67 | // TODO: Adjust the EUI and Keys according to your network credentials |
| 69 | match device | 68 | match device |
| 70 | .join(&JoinMode::OTAA { | 69 | .join(&JoinMode::OTAA { |
| 71 | deveui: [0, 0, 0, 0, 0, 0, 0, 0], | 70 | deveui: DevEui::from([0, 0, 0, 0, 0, 0, 0, 0]), |
| 72 | appeui: [0, 0, 0, 0, 0, 0, 0, 0], | 71 | appeui: AppEui::from([0, 0, 0, 0, 0, 0, 0, 0]), |
| 73 | appkey: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | 72 | appkey: AppKey::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), |
| 74 | }) | 73 | }) |
| 75 | .await | 74 | .await |
| 76 | { | 75 | { |
diff --git a/examples/nrf52840/src/bin/lora_p2p_receive.rs b/examples/nrf52840/src/bin/lora_p2p_receive.rs index 563fe42ec..1d293c6bf 100644 --- a/examples/nrf52840/src/bin/lora_p2p_receive.rs +++ b/examples/nrf52840/src/bin/lora_p2p_receive.rs | |||
| @@ -41,10 +41,8 @@ async fn main(_spawner: Spawner) { | |||
| 41 | let iv = | 41 | let iv = |
| 42 | GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); | 42 | GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); |
| 43 | 43 | ||
| 44 | let mut delay = Delay; | ||
| 45 | |||
| 46 | let mut lora = { | 44 | let mut lora = { |
| 47 | match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, &mut delay).await { | 45 | match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, Delay).await { |
| 48 | Ok(l) => l, | 46 | Ok(l) => l, |
| 49 | Err(err) => { | 47 | Err(err) => { |
| 50 | info!("Radio error = {}", err); | 48 | info!("Radio error = {}", err); |
| @@ -88,7 +86,7 @@ async fn main(_spawner: Spawner) { | |||
| 88 | }; | 86 | }; |
| 89 | 87 | ||
| 90 | match lora | 88 | match lora |
| 91 | .prepare_for_rx(&mdltn_params, &rx_pkt_params, None, true, false, 0, 0x00ffffffu32) | 89 | .prepare_for_rx(&mdltn_params, &rx_pkt_params, None, None, false) |
| 92 | .await | 90 | .await |
| 93 | { | 91 | { |
| 94 | Ok(()) => {} | 92 | Ok(()) => {} |
diff --git a/examples/nrf52840/src/bin/lora_p2p_receive_duty_cycle.rs b/examples/nrf52840/src/bin/lora_p2p_receive_duty_cycle.rs index 1fd8f61a2..eee4d20e7 100644 --- a/examples/nrf52840/src/bin/lora_p2p_receive_duty_cycle.rs +++ b/examples/nrf52840/src/bin/lora_p2p_receive_duty_cycle.rs | |||
| @@ -41,10 +41,8 @@ async fn main(_spawner: Spawner) { | |||
| 41 | let iv = | 41 | let iv = |
| 42 | GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); | 42 | GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); |
| 43 | 43 | ||
| 44 | let mut delay = Delay; | ||
| 45 | |||
| 46 | let mut lora = { | 44 | let mut lora = { |
| 47 | match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, &mut delay).await { | 45 | match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, Delay).await { |
| 48 | Ok(l) => l, | 46 | Ok(l) => l, |
| 49 | Err(err) => { | 47 | Err(err) => { |
| 50 | info!("Radio error = {}", err); | 48 | info!("Radio error = {}", err); |
| @@ -92,14 +90,12 @@ async fn main(_spawner: Spawner) { | |||
| 92 | .prepare_for_rx( | 90 | .prepare_for_rx( |
| 93 | &mdltn_params, | 91 | &mdltn_params, |
| 94 | &rx_pkt_params, | 92 | &rx_pkt_params, |
| 93 | None, | ||
| 95 | Some(&DutyCycleParams { | 94 | Some(&DutyCycleParams { |
| 96 | rx_time: 300_000, // 300_000 units * 15.625 us/unit = 4.69 s | 95 | rx_time: 300_000, // 300_000 units * 15.625 us/unit = 4.69 s |
| 97 | sleep_time: 200_000, // 200_000 units * 15.625 us/unit = 3.13 s | 96 | sleep_time: 200_000, // 200_000 units * 15.625 us/unit = 3.13 s |
| 98 | }), | 97 | }), |
| 99 | false, | 98 | false, |
| 100 | false, | ||
| 101 | 0, | ||
| 102 | 0, | ||
| 103 | ) | 99 | ) |
| 104 | .await | 100 | .await |
| 105 | { | 101 | { |
diff --git a/examples/nrf52840/src/bin/lora_p2p_send.rs b/examples/nrf52840/src/bin/lora_p2p_send.rs index 1c8bbc27a..676221a27 100644 --- a/examples/nrf52840/src/bin/lora_p2p_send.rs +++ b/examples/nrf52840/src/bin/lora_p2p_send.rs | |||
| @@ -41,10 +41,8 @@ async fn main(_spawner: Spawner) { | |||
| 41 | let iv = | 41 | let iv = |
| 42 | GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); | 42 | GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, Some(rf_switch_rx), Some(rf_switch_tx)).unwrap(); |
| 43 | 43 | ||
| 44 | let mut delay = Delay; | ||
| 45 | |||
| 46 | let mut lora = { | 44 | let mut lora = { |
| 47 | match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, &mut delay).await { | 45 | match LoRa::new(SX1261_2::new(BoardType::Rak4631Sx1262, spim, iv), false, Delay).await { |
| 48 | Ok(l) => l, | 46 | Ok(l) => l, |
| 49 | Err(err) => { | 47 | Err(err) => { |
| 50 | info!("Radio error = {}", err); | 48 | info!("Radio error = {}", err); |
| @@ -97,7 +95,7 @@ async fn main(_spawner: Spawner) { | |||
| 97 | } | 95 | } |
| 98 | }; | 96 | }; |
| 99 | 97 | ||
| 100 | match lora.sleep(&mut delay).await { | 98 | match lora.sleep(false).await { |
| 101 | Ok(()) => info!("Sleep successful"), | 99 | Ok(()) => info!("Sleep successful"), |
| 102 | Err(err) => info!("Sleep unsuccessful = {}", err), | 100 | Err(err) => info!("Sleep unsuccessful = {}", err), |
| 103 | } | 101 | } |
diff --git a/examples/nrf5340/Cargo.toml b/examples/nrf5340/Cargo.toml index 4968a79aa..86d969ed5 100644 --- a/examples/nrf5340/Cargo.toml +++ b/examples/nrf5340/Cargo.toml | |||
| @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | 8 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } |
| 9 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = [ | 9 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = [ |
| 10 | "defmt", | 10 | "defmt", |
| 11 | ] } | 11 | ] } |
| 12 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", | 12 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", |
| @@ -14,7 +14,7 @@ embassy-executor = { version = "0.3.0", path = "../../embassy-executor", feature | |||
| 14 | "defmt", | 14 | "defmt", |
| 15 | "integrated-timers", | 15 | "integrated-timers", |
| 16 | ] } | 16 | ] } |
| 17 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = [ | 17 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = [ |
| 18 | "defmt", | 18 | "defmt", |
| 19 | "defmt-timestamp-uptime", | 19 | "defmt-timestamp-uptime", |
| 20 | ] } | 20 | ] } |
diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index 3efc804ac..2677e0402 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml | |||
| @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" | |||
| 7 | 7 | ||
| 8 | [dependencies] | 8 | [dependencies] |
| 9 | embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal", features = ["defmt"] } | 9 | embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal", features = ["defmt"] } |
| 10 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } | 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } |
| 12 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime"] } | 12 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime"] } |
| 13 | embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["defmt", "unstable-traits", "nightly", "unstable-pac", "time-driver", "critical-section-impl"] } | 13 | embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["defmt", "unstable-traits", "nightly", "unstable-pac", "time-driver", "critical-section-impl"] } |
| 14 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } | 14 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } |
| 15 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "udp", "dhcpv4", "medium-ethernet"] } | 15 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "udp", "dhcpv4", "medium-ethernet"] } |
| @@ -17,9 +17,9 @@ embassy-net-wiznet = { version = "0.1.0", path = "../../embassy-net-wiznet", fea | |||
| 17 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | 17 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } |
| 18 | embassy-usb-logger = { version = "0.1.0", path = "../../embassy-usb-logger" } | 18 | embassy-usb-logger = { version = "0.1.0", path = "../../embassy-usb-logger" } |
| 19 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["time", "defmt"] } | 19 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["time", "defmt"] } |
| 20 | lora-phy = { version = "1" } | 20 | lora-phy = { version = "2" } |
| 21 | lorawan-device = { version = "0.10.0", default-features = false, features = ["async", "external-lora-phy"] } | 21 | lorawan-device = { version = "0.11.0", default-features = false, features = ["async", "external-lora-phy"] } |
| 22 | lorawan = { version = "0.7.3", default-features = false, features = ["default-crypto"] } | 22 | lorawan = { version = "0.7.4", default-features = false, features = ["default-crypto"] } |
| 23 | cyw43 = { path = "../../cyw43", features = ["defmt", "firmware-logs"] } | 23 | cyw43 = { path = "../../cyw43", features = ["defmt", "firmware-logs"] } |
| 24 | cyw43-pio = { path = "../../cyw43-pio", features = ["defmt", "overclock"] } | 24 | cyw43-pio = { path = "../../cyw43-pio", features = ["defmt", "overclock"] } |
| 25 | 25 | ||
| @@ -55,6 +55,3 @@ rand = { version = "0.8.5", default-features = false } | |||
| 55 | 55 | ||
| 56 | [profile.release] | 56 | [profile.release] |
| 57 | debug = 2 | 57 | debug = 2 |
| 58 | |||
| 59 | [patch.crates-io] | ||
| 60 | lora-phy = { git = "https://github.com/embassy-rs/lora-phy", rev = "1323eccc1c470d4259f95f4f315d1be830d572a3"} \ No newline at end of file | ||
diff --git a/examples/rp/src/bin/i2c_slave.rs b/examples/rp/src/bin/i2c_slave.rs new file mode 100644 index 000000000..7de300fb8 --- /dev/null +++ b/examples/rp/src/bin/i2c_slave.rs | |||
| @@ -0,0 +1,118 @@ | |||
| 1 | //! This example shows how to use the 2040 as an i2c slave. | ||
| 2 | #![no_std] | ||
| 3 | #![no_main] | ||
| 4 | #![feature(type_alias_impl_trait)] | ||
| 5 | |||
| 6 | use defmt::*; | ||
| 7 | use embassy_executor::Spawner; | ||
| 8 | use embassy_rp::peripherals::{I2C0, I2C1}; | ||
| 9 | use embassy_rp::{bind_interrupts, i2c, i2c_slave}; | ||
| 10 | use embassy_time::{Duration, Timer}; | ||
| 11 | use embedded_hal_async::i2c::I2c; | ||
| 12 | use {defmt_rtt as _, panic_probe as _}; | ||
| 13 | |||
| 14 | bind_interrupts!(struct Irqs { | ||
| 15 | I2C0_IRQ => i2c::InterruptHandler<I2C0>; | ||
| 16 | I2C1_IRQ => i2c::InterruptHandler<I2C1>; | ||
| 17 | }); | ||
| 18 | |||
| 19 | const DEV_ADDR: u8 = 0x42; | ||
| 20 | |||
| 21 | #[embassy_executor::task] | ||
| 22 | async fn device_task(mut dev: i2c_slave::I2cSlave<'static, I2C1>) -> ! { | ||
| 23 | info!("Device start"); | ||
| 24 | |||
| 25 | let mut state = 0; | ||
| 26 | |||
| 27 | loop { | ||
| 28 | let mut buf = [0u8; 128]; | ||
| 29 | match dev.listen(&mut buf).await { | ||
| 30 | Ok(i2c_slave::Command::GeneralCall(len)) => info!("Device recieved general call write: {}", buf[..len]), | ||
| 31 | Ok(i2c_slave::Command::Read) => loop { | ||
| 32 | match dev.respond_to_read(&[state]).await { | ||
| 33 | Ok(x) => match x { | ||
| 34 | i2c_slave::ReadStatus::Done => break, | ||
| 35 | i2c_slave::ReadStatus::NeedMoreBytes => (), | ||
| 36 | i2c_slave::ReadStatus::LeftoverBytes(x) => { | ||
| 37 | info!("tried to write {} extra bytes", x); | ||
| 38 | break; | ||
| 39 | } | ||
| 40 | }, | ||
| 41 | Err(e) => error!("error while responding {}", e), | ||
| 42 | } | ||
| 43 | }, | ||
| 44 | Ok(i2c_slave::Command::Write(len)) => info!("Device recieved write: {}", buf[..len]), | ||
| 45 | Ok(i2c_slave::Command::WriteRead(len)) => { | ||
| 46 | info!("device recieved write read: {:x}", buf[..len]); | ||
| 47 | match buf[0] { | ||
| 48 | // Set the state | ||
| 49 | 0xC2 => { | ||
| 50 | state = buf[1]; | ||
| 51 | match dev.respond_and_fill(&[state], 0x00).await { | ||
| 52 | Ok(read_status) => info!("response read status {}", read_status), | ||
| 53 | Err(e) => error!("error while responding {}", e), | ||
| 54 | } | ||
| 55 | } | ||
| 56 | // Reset State | ||
| 57 | 0xC8 => { | ||
| 58 | state = 0; | ||
| 59 | match dev.respond_and_fill(&[state], 0x00).await { | ||
| 60 | Ok(read_status) => info!("response read status {}", read_status), | ||
| 61 | Err(e) => error!("error while responding {}", e), | ||
| 62 | } | ||
| 63 | } | ||
| 64 | x => error!("Invalid Write Read {:x}", x), | ||
| 65 | } | ||
| 66 | } | ||
| 67 | Err(e) => error!("{}", e), | ||
| 68 | } | ||
| 69 | } | ||
| 70 | } | ||
| 71 | |||
| 72 | #[embassy_executor::task] | ||
| 73 | async fn controller_task(mut con: i2c::I2c<'static, I2C0, i2c::Async>) { | ||
| 74 | info!("Controller start"); | ||
| 75 | |||
| 76 | loop { | ||
| 77 | let mut resp_buff = [0u8; 2]; | ||
| 78 | for i in 0..10 { | ||
| 79 | match con.write_read(DEV_ADDR, &[0xC2, i], &mut resp_buff).await { | ||
| 80 | Ok(_) => info!("write_read response: {}", resp_buff), | ||
| 81 | Err(e) => error!("Error writing {}", e), | ||
| 82 | } | ||
| 83 | |||
| 84 | Timer::after(Duration::from_millis(100)).await; | ||
| 85 | } | ||
| 86 | match con.read(DEV_ADDR, &mut resp_buff).await { | ||
| 87 | Ok(_) => info!("read response: {}", resp_buff), | ||
| 88 | Err(e) => error!("Error writing {}", e), | ||
| 89 | } | ||
| 90 | match con.write_read(DEV_ADDR, &[0xC8], &mut resp_buff).await { | ||
| 91 | Ok(_) => info!("write_read response: {}", resp_buff), | ||
| 92 | Err(e) => error!("Error writing {}", e), | ||
| 93 | } | ||
| 94 | Timer::after(Duration::from_millis(100)).await; | ||
| 95 | } | ||
| 96 | } | ||
| 97 | |||
| 98 | #[embassy_executor::main] | ||
| 99 | async fn main(spawner: Spawner) { | ||
| 100 | let p = embassy_rp::init(Default::default()); | ||
| 101 | info!("Hello World!"); | ||
| 102 | |||
| 103 | let d_sda = p.PIN_3; | ||
| 104 | let d_scl = p.PIN_2; | ||
| 105 | let mut config = i2c_slave::Config::default(); | ||
| 106 | config.addr = DEV_ADDR as u16; | ||
| 107 | let device = i2c_slave::I2cSlave::new(p.I2C1, d_sda, d_scl, Irqs, config); | ||
| 108 | |||
| 109 | unwrap!(spawner.spawn(device_task(device))); | ||
| 110 | |||
| 111 | let c_sda = p.PIN_1; | ||
| 112 | let c_scl = p.PIN_0; | ||
| 113 | let mut config = i2c::Config::default(); | ||
| 114 | config.frequency = 5_000; | ||
| 115 | let controller = i2c::I2c::new_async(p.I2C0, c_sda, c_scl, Irqs, config); | ||
| 116 | |||
| 117 | unwrap!(spawner.spawn(controller_task(controller))); | ||
| 118 | } | ||
diff --git a/examples/rp/src/bin/lora_lorawan.rs b/examples/rp/src/bin/lora_lorawan.rs index d631fafa1..e7e81863e 100644 --- a/examples/rp/src/bin/lora_lorawan.rs +++ b/examples/rp/src/bin/lora_lorawan.rs | |||
| @@ -19,6 +19,7 @@ use lora_phy::LoRa; | |||
| 19 | use lorawan::default_crypto::DefaultFactory as Crypto; | 19 | use lorawan::default_crypto::DefaultFactory as Crypto; |
| 20 | use lorawan_device::async_device::lora_radio::LoRaRadio; | 20 | use lorawan_device::async_device::lora_radio::LoRaRadio; |
| 21 | use lorawan_device::async_device::{region, Device, JoinMode}; | 21 | use lorawan_device::async_device::{region, Device, JoinMode}; |
| 22 | use lorawan_device::{AppEui, AppKey, DevEui}; | ||
| 22 | use {defmt_rtt as _, panic_probe as _}; | 23 | use {defmt_rtt as _, panic_probe as _}; |
| 23 | 24 | ||
| 24 | const LORAWAN_REGION: region::Region = region::Region::EU868; // warning: set this appropriately for the region | 25 | const LORAWAN_REGION: region::Region = region::Region::EU868; // warning: set this appropriately for the region |
| @@ -39,16 +40,8 @@ async fn main(_spawner: Spawner) { | |||
| 39 | 40 | ||
| 40 | let iv = GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, None, None).unwrap(); | 41 | let iv = GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, None, None).unwrap(); |
| 41 | 42 | ||
| 42 | let mut delay = Delay; | ||
| 43 | |||
| 44 | let lora = { | 43 | let lora = { |
| 45 | match LoRa::new( | 44 | match LoRa::new(SX1261_2::new(BoardType::RpPicoWaveshareSx1262, spi, iv), true, Delay).await { |
| 46 | SX1261_2::new(BoardType::RpPicoWaveshareSx1262, spi, iv), | ||
| 47 | true, | ||
| 48 | &mut delay, | ||
| 49 | ) | ||
| 50 | .await | ||
| 51 | { | ||
| 52 | Ok(l) => l, | 45 | Ok(l) => l, |
| 53 | Err(err) => { | 46 | Err(err) => { |
| 54 | info!("Radio error = {}", err); | 47 | info!("Radio error = {}", err); |
| @@ -66,9 +59,9 @@ async fn main(_spawner: Spawner) { | |||
| 66 | // TODO: Adjust the EUI and Keys according to your network credentials | 59 | // TODO: Adjust the EUI and Keys according to your network credentials |
| 67 | match device | 60 | match device |
| 68 | .join(&JoinMode::OTAA { | 61 | .join(&JoinMode::OTAA { |
| 69 | deveui: [0, 0, 0, 0, 0, 0, 0, 0], | 62 | deveui: DevEui::from([0, 0, 0, 0, 0, 0, 0, 0]), |
| 70 | appeui: [0, 0, 0, 0, 0, 0, 0, 0], | 63 | appeui: AppEui::from([0, 0, 0, 0, 0, 0, 0, 0]), |
| 71 | appkey: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | 64 | appkey: AppKey::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), |
| 72 | }) | 65 | }) |
| 73 | .await | 66 | .await |
| 74 | { | 67 | { |
diff --git a/examples/rp/src/bin/lora_p2p_receive.rs b/examples/rp/src/bin/lora_p2p_receive.rs index 396d669de..5891826fd 100644 --- a/examples/rp/src/bin/lora_p2p_receive.rs +++ b/examples/rp/src/bin/lora_p2p_receive.rs | |||
| @@ -35,16 +35,8 @@ async fn main(_spawner: Spawner) { | |||
| 35 | 35 | ||
| 36 | let iv = GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, None, None).unwrap(); | 36 | let iv = GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, None, None).unwrap(); |
| 37 | 37 | ||
| 38 | let mut delay = Delay; | ||
| 39 | |||
| 40 | let mut lora = { | 38 | let mut lora = { |
| 41 | match LoRa::new( | 39 | match LoRa::new(SX1261_2::new(BoardType::RpPicoWaveshareSx1262, spi, iv), false, Delay).await { |
| 42 | SX1261_2::new(BoardType::RpPicoWaveshareSx1262, spi, iv), | ||
| 43 | false, | ||
| 44 | &mut delay, | ||
| 45 | ) | ||
| 46 | .await | ||
| 47 | { | ||
| 48 | Ok(l) => l, | 40 | Ok(l) => l, |
| 49 | Err(err) => { | 41 | Err(err) => { |
| 50 | info!("Radio error = {}", err); | 42 | info!("Radio error = {}", err); |
| @@ -83,7 +75,7 @@ async fn main(_spawner: Spawner) { | |||
| 83 | }; | 75 | }; |
| 84 | 76 | ||
| 85 | match lora | 77 | match lora |
| 86 | .prepare_for_rx(&mdltn_params, &rx_pkt_params, None, true, false, 0, 0x00ffffffu32) | 78 | .prepare_for_rx(&mdltn_params, &rx_pkt_params, None, None, false) |
| 87 | .await | 79 | .await |
| 88 | { | 80 | { |
| 89 | Ok(()) => {} | 81 | Ok(()) => {} |
diff --git a/examples/rp/src/bin/lora_p2p_send.rs b/examples/rp/src/bin/lora_p2p_send.rs index a0f70fa5c..94bdb4e92 100644 --- a/examples/rp/src/bin/lora_p2p_send.rs +++ b/examples/rp/src/bin/lora_p2p_send.rs | |||
| @@ -35,16 +35,8 @@ async fn main(_spawner: Spawner) { | |||
| 35 | 35 | ||
| 36 | let iv = GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, None, None).unwrap(); | 36 | let iv = GenericSx126xInterfaceVariant::new(nss, reset, dio1, busy, None, None).unwrap(); |
| 37 | 37 | ||
| 38 | let mut delay = Delay; | ||
| 39 | |||
| 40 | let mut lora = { | 38 | let mut lora = { |
| 41 | match LoRa::new( | 39 | match LoRa::new(SX1261_2::new(BoardType::RpPicoWaveshareSx1262, spi, iv), false, Delay).await { |
| 42 | SX1261_2::new(BoardType::RpPicoWaveshareSx1262, spi, iv), | ||
| 43 | false, | ||
| 44 | &mut delay, | ||
| 45 | ) | ||
| 46 | .await | ||
| 47 | { | ||
| 48 | Ok(l) => l, | 40 | Ok(l) => l, |
| 49 | Err(err) => { | 41 | Err(err) => { |
| 50 | info!("Radio error = {}", err); | 42 | info!("Radio error = {}", err); |
| @@ -97,7 +89,7 @@ async fn main(_spawner: Spawner) { | |||
| 97 | } | 89 | } |
| 98 | }; | 90 | }; |
| 99 | 91 | ||
| 100 | match lora.sleep(&mut delay).await { | 92 | match lora.sleep(false).await { |
| 101 | Ok(()) => info!("Sleep successful"), | 93 | Ok(()) => info!("Sleep successful"), |
| 102 | Err(err) => info!("Sleep unsuccessful = {}", err), | 94 | Err(err) => info!("Sleep unsuccessful = {}", err), |
| 103 | } | 95 | } |
diff --git a/examples/rp/src/bin/lora_p2p_send_multicore.rs b/examples/rp/src/bin/lora_p2p_send_multicore.rs index b54cc92f6..e31aa62a2 100644 --- a/examples/rp/src/bin/lora_p2p_send_multicore.rs +++ b/examples/rp/src/bin/lora_p2p_send_multicore.rs | |||
| @@ -69,16 +69,9 @@ async fn core1_task( | |||
| 69 | iv: GenericSx126xInterfaceVariant<Output<'static, AnyPin>, Input<'static, AnyPin>>, | 69 | iv: GenericSx126xInterfaceVariant<Output<'static, AnyPin>, Input<'static, AnyPin>>, |
| 70 | ) { | 70 | ) { |
| 71 | info!("Hello from core 1"); | 71 | info!("Hello from core 1"); |
| 72 | let mut delay = Delay; | ||
| 73 | 72 | ||
| 74 | let mut lora = { | 73 | let mut lora = { |
| 75 | match LoRa::new( | 74 | match LoRa::new(SX1261_2::new(BoardType::RpPicoWaveshareSx1262, spi, iv), false, Delay).await { |
| 76 | SX1261_2::new(BoardType::RpPicoWaveshareSx1262, spi, iv), | ||
| 77 | false, | ||
| 78 | &mut delay, | ||
| 79 | ) | ||
| 80 | .await | ||
| 81 | { | ||
| 82 | Ok(l) => l, | 75 | Ok(l) => l, |
| 83 | Err(err) => { | 76 | Err(err) => { |
| 84 | info!("Radio error = {}", err); | 77 | info!("Radio error = {}", err); |
| @@ -132,7 +125,7 @@ async fn core1_task( | |||
| 132 | } | 125 | } |
| 133 | }; | 126 | }; |
| 134 | 127 | ||
| 135 | match lora.sleep(&mut delay).await { | 128 | match lora.sleep(false).await { |
| 136 | Ok(()) => info!("Sleep successful"), | 129 | Ok(()) => info!("Sleep successful"), |
| 137 | Err(err) => info!("Sleep unsuccessful = {}", err), | 130 | Err(err) => info!("Sleep unsuccessful = {}", err), |
| 138 | } | 131 | } |
diff --git a/examples/rp/src/bin/pio_uart.rs b/examples/rp/src/bin/pio_uart.rs index 707c99b78..aa9e52cbd 100644 --- a/examples/rp/src/bin/pio_uart.rs +++ b/examples/rp/src/bin/pio_uart.rs | |||
| @@ -91,13 +91,11 @@ async fn main(_spawner: Spawner) { | |||
| 91 | let (mut uart_tx, mut uart_rx) = uart.split(); | 91 | let (mut uart_tx, mut uart_rx) = uart.split(); |
| 92 | 92 | ||
| 93 | // Pipe setup | 93 | // Pipe setup |
| 94 | let usb_pipe: Pipe<NoopRawMutex, 20> = Pipe::new(); | 94 | let mut usb_pipe: Pipe<NoopRawMutex, 20> = Pipe::new(); |
| 95 | let mut usb_pipe_writer = usb_pipe.writer(); | 95 | let (mut usb_pipe_reader, mut usb_pipe_writer) = usb_pipe.split(); |
| 96 | let mut usb_pipe_reader = usb_pipe.reader(); | ||
| 97 | 96 | ||
| 98 | let uart_pipe: Pipe<NoopRawMutex, 20> = Pipe::new(); | 97 | let mut uart_pipe: Pipe<NoopRawMutex, 20> = Pipe::new(); |
| 99 | let mut uart_pipe_writer = uart_pipe.writer(); | 98 | let (mut uart_pipe_reader, mut uart_pipe_writer) = uart_pipe.split(); |
| 100 | let mut uart_pipe_reader = uart_pipe.reader(); | ||
| 101 | 99 | ||
| 102 | let (mut usb_tx, mut usb_rx) = class.split(); | 100 | let (mut usb_tx, mut usb_rx) = class.split(); |
| 103 | 101 | ||
diff --git a/examples/rp/src/bin/pio_ws2812.rs b/examples/rp/src/bin/pio_ws2812.rs index bc87016ec..5c0c60246 100644 --- a/examples/rp/src/bin/pio_ws2812.rs +++ b/examples/rp/src/bin/pio_ws2812.rs | |||
| @@ -138,8 +138,9 @@ async fn main(_spawner: Spawner) { | |||
| 138 | const NUM_LEDS: usize = 1; | 138 | const NUM_LEDS: usize = 1; |
| 139 | let mut data = [RGB8::default(); NUM_LEDS]; | 139 | let mut data = [RGB8::default(); NUM_LEDS]; |
| 140 | 140 | ||
| 141 | // For the thing plus, use pin 8 | 141 | // Common neopixel pins: |
| 142 | // For the feather, use pin 16 | 142 | // Thing plus: 8 |
| 143 | // Adafruit Feather: 16; Adafruit Feather+RFM95: 4 | ||
| 143 | let mut ws2812 = Ws2812::new(&mut common, sm0, p.DMA_CH0, p.PIN_16); | 144 | let mut ws2812 = Ws2812::new(&mut common, sm0, p.DMA_CH0, p.PIN_16); |
| 144 | 145 | ||
| 145 | // Loop forever making RGB values and pushing them out to the WS2812. | 146 | // Loop forever making RGB values and pushing them out to the WS2812. |
| @@ -152,7 +153,7 @@ async fn main(_spawner: Spawner) { | |||
| 152 | } | 153 | } |
| 153 | ws2812.write(&data).await; | 154 | ws2812.write(&data).await; |
| 154 | 155 | ||
| 155 | Timer::after(Duration::from_micros(5)).await; | 156 | Timer::after(Duration::from_millis(10)).await; |
| 156 | } | 157 | } |
| 157 | } | 158 | } |
| 158 | } | 159 | } |
diff --git a/examples/std/Cargo.toml b/examples/std/Cargo.toml index 0d4d5fa12..e54f36980 100644 --- a/examples/std/Cargo.toml +++ b/examples/std/Cargo.toml | |||
| @@ -5,14 +5,16 @@ version = "0.1.0" | |||
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["log"] } | 8 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["log"] } |
| 9 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-std", "executor-thread", "log", "nightly", "integrated-timers"] } | 9 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-std", "executor-thread", "log", "nightly", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["log", "std", "nightly"] } | 10 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["log", "std", "nightly"] } |
| 11 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features=[ "std", "nightly", "log", "medium-ethernet", "tcp", "udp", "dns", "dhcpv4", "proto-ipv6"] } | 11 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features=[ "std", "nightly", "log", "medium-ethernet", "medium-ip", "tcp", "udp", "dns", "dhcpv4", "proto-ipv6"] } |
| 12 | embassy-net-tuntap = { version = "0.1.0", path = "../../embassy-net-tuntap" } | 12 | embassy-net-tuntap = { version = "0.1.0", path = "../../embassy-net-tuntap" } |
| 13 | embassy-net-ppp = { version = "0.1.0", path = "../../embassy-net-ppp", features = ["log"]} | ||
| 13 | embedded-io-async = { version = "0.5.0" } | 14 | embedded-io-async = { version = "0.5.0" } |
| 14 | embedded-io-adapters = { version = "0.5.0", features = ["futures-03"] } | 15 | embedded-io-adapters = { version = "0.5.0", features = ["futures-03"] } |
| 15 | critical-section = { version = "1.1", features = ["std"] } | 16 | critical-section = { version = "1.1", features = ["std"] } |
| 17 | smoltcp = { version = "0.10.0", features = ["dns-max-server-count-4"] } | ||
| 16 | 18 | ||
| 17 | async-io = "1.6.0" | 19 | async-io = "1.6.0" |
| 18 | env_logger = "0.9.0" | 20 | env_logger = "0.9.0" |
diff --git a/examples/std/src/bin/net_ppp.rs b/examples/std/src/bin/net_ppp.rs new file mode 100644 index 000000000..9cf6e19df --- /dev/null +++ b/examples/std/src/bin/net_ppp.rs | |||
| @@ -0,0 +1,218 @@ | |||
| 1 | //! Testing against pppd: | ||
| 2 | //! | ||
| 3 | //! echo myuser $(hostname) mypass 192.168.7.10 >> /etc/ppp/pap-secrets | ||
| 4 | //! socat -v -x PTY,link=pty1,rawer PTY,link=pty2,rawer | ||
| 5 | //! sudo pppd $PWD/pty1 115200 192.168.7.1: ms-dns 8.8.4.4 ms-dns 8.8.8.8 nodetach debug local persist silent noproxyarp | ||
| 6 | //! RUST_LOG=trace cargo run --bin net_ppp -- --device pty2 | ||
| 7 | //! ping 192.168.7.10 | ||
| 8 | //! nc 192.168.7.10 1234 | ||
| 9 | |||
| 10 | #![feature(type_alias_impl_trait)] | ||
| 11 | #![feature(async_fn_in_trait, impl_trait_projections)] | ||
| 12 | |||
| 13 | #[path = "../serial_port.rs"] | ||
| 14 | mod serial_port; | ||
| 15 | |||
| 16 | use async_io::Async; | ||
| 17 | use clap::Parser; | ||
| 18 | use embassy_executor::{Executor, Spawner}; | ||
| 19 | use embassy_net::tcp::TcpSocket; | ||
| 20 | use embassy_net::{Config, ConfigV4, Ipv4Address, Ipv4Cidr, Stack, StackResources}; | ||
| 21 | use embassy_net_ppp::Runner; | ||
| 22 | use embedded_io_async::Write; | ||
| 23 | use futures::io::BufReader; | ||
| 24 | use heapless::Vec; | ||
| 25 | use log::*; | ||
| 26 | use nix::sys::termios; | ||
| 27 | use rand_core::{OsRng, RngCore}; | ||
| 28 | use static_cell::{make_static, StaticCell}; | ||
| 29 | |||
| 30 | use crate::serial_port::SerialPort; | ||
| 31 | |||
| 32 | #[derive(Parser)] | ||
| 33 | #[clap(version = "1.0")] | ||
| 34 | struct Opts { | ||
| 35 | /// Serial port device name | ||
| 36 | #[clap(short, long)] | ||
| 37 | device: String, | ||
| 38 | } | ||
| 39 | |||
| 40 | #[embassy_executor::task] | ||
| 41 | async fn net_task(stack: &'static Stack<embassy_net_ppp::Device<'static>>) -> ! { | ||
| 42 | stack.run().await | ||
| 43 | } | ||
| 44 | |||
| 45 | #[embassy_executor::task] | ||
| 46 | async fn ppp_task( | ||
| 47 | stack: &'static Stack<embassy_net_ppp::Device<'static>>, | ||
| 48 | mut runner: Runner<'static>, | ||
| 49 | port: SerialPort, | ||
| 50 | ) -> ! { | ||
| 51 | let port = Async::new(port).unwrap(); | ||
| 52 | let port = BufReader::new(port); | ||
| 53 | let port = adapter::FromFutures::new(port); | ||
| 54 | |||
| 55 | let config = embassy_net_ppp::Config { | ||
| 56 | username: b"myuser", | ||
| 57 | password: b"mypass", | ||
| 58 | }; | ||
| 59 | |||
| 60 | runner | ||
| 61 | .run(port, config, |ipv4| { | ||
| 62 | let Some(addr) = ipv4.address else { | ||
| 63 | warn!("PPP did not provide an IP address."); | ||
| 64 | return; | ||
| 65 | }; | ||
| 66 | let mut dns_servers = Vec::new(); | ||
| 67 | for s in ipv4.dns_servers.iter().flatten() { | ||
| 68 | let _ = dns_servers.push(Ipv4Address::from_bytes(&s.0)); | ||
| 69 | } | ||
| 70 | let config = ConfigV4::Static(embassy_net::StaticConfigV4 { | ||
| 71 | address: Ipv4Cidr::new(Ipv4Address::from_bytes(&addr.0), 0), | ||
| 72 | gateway: None, | ||
| 73 | dns_servers, | ||
| 74 | }); | ||
| 75 | stack.set_config_v4(config); | ||
| 76 | }) | ||
| 77 | .await | ||
| 78 | .unwrap(); | ||
| 79 | unreachable!() | ||
| 80 | } | ||
| 81 | |||
| 82 | #[embassy_executor::task] | ||
| 83 | async fn main_task(spawner: Spawner) { | ||
| 84 | let opts: Opts = Opts::parse(); | ||
| 85 | |||
| 86 | // Open serial port | ||
| 87 | let baudrate = termios::BaudRate::B115200; | ||
| 88 | let port = SerialPort::new(opts.device.as_str(), baudrate).unwrap(); | ||
| 89 | |||
| 90 | // Init network device | ||
| 91 | let state = make_static!(embassy_net_ppp::State::<4, 4>::new()); | ||
| 92 | let (device, runner) = embassy_net_ppp::new(state); | ||
| 93 | |||
| 94 | // Generate random seed | ||
| 95 | let mut seed = [0; 8]; | ||
| 96 | OsRng.fill_bytes(&mut seed); | ||
| 97 | let seed = u64::from_le_bytes(seed); | ||
| 98 | |||
| 99 | // Init network stack | ||
| 100 | let stack = &*make_static!(Stack::new( | ||
| 101 | device, | ||
| 102 | Config::default(), // don't configure IP yet | ||
| 103 | make_static!(StackResources::<3>::new()), | ||
| 104 | seed | ||
| 105 | )); | ||
| 106 | |||
| 107 | // Launch network task | ||
| 108 | spawner.spawn(net_task(stack)).unwrap(); | ||
| 109 | spawner.spawn(ppp_task(stack, runner, port)).unwrap(); | ||
| 110 | |||
| 111 | // Then we can use it! | ||
| 112 | let mut rx_buffer = [0; 4096]; | ||
| 113 | let mut tx_buffer = [0; 4096]; | ||
| 114 | let mut buf = [0; 4096]; | ||
| 115 | |||
| 116 | loop { | ||
| 117 | let mut socket = TcpSocket::new(stack, &mut rx_buffer, &mut tx_buffer); | ||
| 118 | socket.set_timeout(Some(embassy_time::Duration::from_secs(10))); | ||
| 119 | |||
| 120 | info!("Listening on TCP:1234..."); | ||
| 121 | if let Err(e) = socket.accept(1234).await { | ||
| 122 | warn!("accept error: {:?}", e); | ||
| 123 | continue; | ||
| 124 | } | ||
| 125 | |||
| 126 | info!("Received connection from {:?}", socket.remote_endpoint()); | ||
| 127 | |||
| 128 | loop { | ||
| 129 | let n = match socket.read(&mut buf).await { | ||
| 130 | Ok(0) => { | ||
| 131 | warn!("read EOF"); | ||
| 132 | break; | ||
| 133 | } | ||
| 134 | Ok(n) => n, | ||
| 135 | Err(e) => { | ||
| 136 | warn!("read error: {:?}", e); | ||
| 137 | break; | ||
| 138 | } | ||
| 139 | }; | ||
| 140 | |||
| 141 | info!("rxd {:02x?}", &buf[..n]); | ||
| 142 | |||
| 143 | match socket.write_all(&buf[..n]).await { | ||
| 144 | Ok(()) => {} | ||
| 145 | Err(e) => { | ||
| 146 | warn!("write error: {:?}", e); | ||
| 147 | break; | ||
| 148 | } | ||
| 149 | }; | ||
| 150 | } | ||
| 151 | } | ||
| 152 | } | ||
| 153 | |||
| 154 | static EXECUTOR: StaticCell<Executor> = StaticCell::new(); | ||
| 155 | |||
| 156 | fn main() { | ||
| 157 | env_logger::builder() | ||
| 158 | .filter_level(log::LevelFilter::Trace) | ||
| 159 | .filter_module("polling", log::LevelFilter::Info) | ||
| 160 | .filter_module("async_io", log::LevelFilter::Info) | ||
| 161 | .format_timestamp_nanos() | ||
| 162 | .init(); | ||
| 163 | |||
| 164 | let executor = EXECUTOR.init(Executor::new()); | ||
| 165 | executor.run(|spawner| { | ||
| 166 | spawner.spawn(main_task(spawner)).unwrap(); | ||
| 167 | }); | ||
| 168 | } | ||
| 169 | |||
| 170 | mod adapter { | ||
| 171 | use core::future::poll_fn; | ||
| 172 | use core::pin::Pin; | ||
| 173 | |||
| 174 | use futures::AsyncBufReadExt; | ||
| 175 | |||
| 176 | /// Adapter from `futures::io` traits. | ||
| 177 | #[derive(Clone)] | ||
| 178 | pub struct FromFutures<T: ?Sized> { | ||
| 179 | inner: T, | ||
| 180 | } | ||
| 181 | |||
| 182 | impl<T> FromFutures<T> { | ||
| 183 | /// Create a new adapter. | ||
| 184 | pub fn new(inner: T) -> Self { | ||
| 185 | Self { inner } | ||
| 186 | } | ||
| 187 | } | ||
| 188 | |||
| 189 | impl<T: ?Sized> embedded_io_async::ErrorType for FromFutures<T> { | ||
| 190 | type Error = std::io::Error; | ||
| 191 | } | ||
| 192 | |||
| 193 | impl<T: futures::io::AsyncRead + Unpin + ?Sized> embedded_io_async::Read for FromFutures<T> { | ||
| 194 | async fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error> { | ||
| 195 | poll_fn(|cx| Pin::new(&mut self.inner).poll_read(cx, buf)).await | ||
| 196 | } | ||
| 197 | } | ||
| 198 | |||
| 199 | impl<T: futures::io::AsyncBufRead + Unpin + ?Sized> embedded_io_async::BufRead for FromFutures<T> { | ||
| 200 | async fn fill_buf(&mut self) -> Result<&[u8], Self::Error> { | ||
| 201 | self.inner.fill_buf().await | ||
| 202 | } | ||
| 203 | |||
| 204 | fn consume(&mut self, amt: usize) { | ||
| 205 | Pin::new(&mut self.inner).consume(amt) | ||
| 206 | } | ||
| 207 | } | ||
| 208 | |||
| 209 | impl<T: futures::io::AsyncWrite + Unpin + ?Sized> embedded_io_async::Write for FromFutures<T> { | ||
| 210 | async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> { | ||
| 211 | poll_fn(|cx| Pin::new(&mut self.inner).poll_write(cx, buf)).await | ||
| 212 | } | ||
| 213 | |||
| 214 | async fn flush(&mut self) -> Result<(), Self::Error> { | ||
| 215 | poll_fn(|cx| Pin::new(&mut self.inner).poll_flush(cx)).await | ||
| 216 | } | ||
| 217 | } | ||
| 218 | } | ||
diff --git a/examples/stm32c0/Cargo.toml b/examples/stm32c0/Cargo.toml index 9d188513a..89ecc4995 100644 --- a/examples/stm32c0/Cargo.toml +++ b/examples/stm32c0/Cargo.toml | |||
| @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" | |||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | # Change stm32c031c6 to your chip name, if necessary. | 8 | # Change stm32c031c6 to your chip name, if necessary. |
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32c031c6", "memory-x", "unstable-pac", "exti"] } | 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32c031c6", "memory-x", "unstable-pac", "exti"] } |
| 10 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 12 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 12 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 13 | 13 | ||
| 14 | defmt = "0.3" | 14 | defmt = "0.3" |
| 15 | defmt-rtt = "0.4" | 15 | defmt-rtt = "0.4" |
diff --git a/examples/stm32f0/Cargo.toml b/examples/stm32f0/Cargo.toml index ca9ab1cf8..db9a24d73 100644 --- a/examples/stm32f0/Cargo.toml +++ b/examples/stm32f0/Cargo.toml | |||
| @@ -14,9 +14,9 @@ cortex-m-rt = "0.7.0" | |||
| 14 | defmt = "0.3" | 14 | defmt = "0.3" |
| 15 | defmt-rtt = "0.4" | 15 | defmt-rtt = "0.4" |
| 16 | panic-probe = "0.3" | 16 | panic-probe = "0.3" |
| 17 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 17 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } |
| 18 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } | 18 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } |
| 19 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 19 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 20 | static_cell = { version = "1.1", features = ["nightly"]} | 20 | static_cell = { version = "1.1", features = ["nightly"]} |
| 21 | 21 | ||
| 22 | [profile.release] | 22 | [profile.release] |
diff --git a/examples/stm32f0/src/bin/adc.rs b/examples/stm32f0/src/bin/adc.rs index 8ed9f98f8..1564ecfc0 100644 --- a/examples/stm32f0/src/bin/adc.rs +++ b/examples/stm32f0/src/bin/adc.rs | |||
| @@ -5,20 +5,26 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::adc::{Adc, SampleTime}; | 7 | use embassy_stm32::adc::{Adc, SampleTime}; |
| 8 | use embassy_stm32::peripherals::ADC; | ||
| 9 | use embassy_stm32::{adc, bind_interrupts}; | ||
| 8 | use embassy_time::{Delay, Duration, Timer}; | 10 | use embassy_time::{Delay, Duration, Timer}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 12 | ||
| 13 | bind_interrupts!(struct Irqs { | ||
| 14 | ADC1_COMP => adc::InterruptHandler<ADC>; | ||
| 15 | }); | ||
| 16 | |||
| 11 | #[embassy_executor::main] | 17 | #[embassy_executor::main] |
| 12 | async fn main(_spawner: Spawner) { | 18 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | 19 | let p = embassy_stm32::init(Default::default()); |
| 14 | info!("Hello World!"); | 20 | info!("Hello World!"); |
| 15 | 21 | ||
| 16 | let mut adc = Adc::new(p.ADC, &mut Delay); | 22 | let mut adc = Adc::new(p.ADC, Irqs, &mut Delay); |
| 17 | adc.set_sample_time(SampleTime::Cycles71_5); | 23 | adc.set_sample_time(SampleTime::Cycles71_5); |
| 18 | let mut pin = p.PA1; | 24 | let mut pin = p.PA1; |
| 19 | 25 | ||
| 20 | let mut vrefint = adc.enable_vref(&mut Delay); | 26 | let mut vrefint = adc.enable_vref(&mut Delay); |
| 21 | let vrefint_sample = adc.read_internal(&mut vrefint); | 27 | let vrefint_sample = adc.read(&mut vrefint).await; |
| 22 | let convert_to_millivolts = |sample| { | 28 | let convert_to_millivolts = |sample| { |
| 23 | // From https://www.st.com/resource/en/datasheet/stm32f031c6.pdf | 29 | // From https://www.st.com/resource/en/datasheet/stm32f031c6.pdf |
| 24 | // 6.3.4 Embedded reference voltage | 30 | // 6.3.4 Embedded reference voltage |
| @@ -28,7 +34,7 @@ async fn main(_spawner: Spawner) { | |||
| 28 | }; | 34 | }; |
| 29 | 35 | ||
| 30 | loop { | 36 | loop { |
| 31 | let v = adc.read(&mut pin); | 37 | let v = adc.read(&mut pin).await; |
| 32 | info!("--> {} - {} mV", v, convert_to_millivolts(v)); | 38 | info!("--> {} - {} mV", v, convert_to_millivolts(v)); |
| 33 | Timer::after(Duration::from_millis(100)).await; | 39 | Timer::after(Duration::from_millis(100)).await; |
| 34 | } | 40 | } |
diff --git a/examples/stm32f1/Cargo.toml b/examples/stm32f1/Cargo.toml index 16796841e..b032ba817 100644 --- a/examples/stm32f1/Cargo.toml +++ b/examples/stm32f1/Cargo.toml | |||
| @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" | |||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | # Change stm32f103c8 to your chip name, if necessary. | 8 | # Change stm32f103c8 to your chip name, if necessary. |
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f103c8", "unstable-pac", "memory-x", "time-driver-any", "unstable-traits" ] } | 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f103c8", "unstable-pac", "memory-x", "time-driver-any", "unstable-traits" ] } |
| 10 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 12 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 12 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 13 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } | 13 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } |
| 14 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | 14 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } |
| 15 | 15 | ||
diff --git a/examples/stm32f1/src/bin/adc.rs b/examples/stm32f1/src/bin/adc.rs index ed59e2799..30947c3c2 100644 --- a/examples/stm32f1/src/bin/adc.rs +++ b/examples/stm32f1/src/bin/adc.rs | |||
| @@ -5,9 +5,15 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::adc::Adc; | 7 | use embassy_stm32::adc::Adc; |
| 8 | use embassy_stm32::peripherals::ADC1; | ||
| 9 | use embassy_stm32::{adc, bind_interrupts}; | ||
| 8 | use embassy_time::{Delay, Duration, Timer}; | 10 | use embassy_time::{Delay, Duration, Timer}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 12 | ||
| 13 | bind_interrupts!(struct Irqs { | ||
| 14 | ADC1_2 => adc::InterruptHandler<ADC1>; | ||
| 15 | }); | ||
| 16 | |||
| 11 | #[embassy_executor::main] | 17 | #[embassy_executor::main] |
| 12 | async fn main(_spawner: Spawner) { | 18 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | 19 | let p = embassy_stm32::init(Default::default()); |
| @@ -17,7 +23,7 @@ async fn main(_spawner: Spawner) { | |||
| 17 | let mut pin = p.PB1; | 23 | let mut pin = p.PB1; |
| 18 | 24 | ||
| 19 | let mut vrefint = adc.enable_vref(&mut Delay); | 25 | let mut vrefint = adc.enable_vref(&mut Delay); |
| 20 | let vrefint_sample = adc.read(&mut vrefint); | 26 | let vrefint_sample = adc.read(&mut vrefint).await; |
| 21 | let convert_to_millivolts = |sample| { | 27 | let convert_to_millivolts = |sample| { |
| 22 | // From http://www.st.com/resource/en/datasheet/CD00161566.pdf | 28 | // From http://www.st.com/resource/en/datasheet/CD00161566.pdf |
| 23 | // 5.3.4 Embedded reference voltage | 29 | // 5.3.4 Embedded reference voltage |
| @@ -27,7 +33,7 @@ async fn main(_spawner: Spawner) { | |||
| 27 | }; | 33 | }; |
| 28 | 34 | ||
| 29 | loop { | 35 | loop { |
| 30 | let v = adc.read(&mut pin); | 36 | let v = adc.read(&mut pin).await; |
| 31 | info!("--> {} - {} mV", v, convert_to_millivolts(v)); | 37 | info!("--> {} - {} mV", v, convert_to_millivolts(v)); |
| 32 | Timer::after(Duration::from_millis(100)).await; | 38 | Timer::after(Duration::from_millis(100)).await; |
| 33 | } | 39 | } |
diff --git a/examples/stm32f2/Cargo.toml b/examples/stm32f2/Cargo.toml index 54eadd1a9..1314b6b12 100644 --- a/examples/stm32f2/Cargo.toml +++ b/examples/stm32f2/Cargo.toml | |||
| @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" | |||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | # Change stm32f207zg to your chip name, if necessary. | 8 | # Change stm32f207zg to your chip name, if necessary. |
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f207zg", "unstable-pac", "memory-x", "time-driver-any", "exti"] } | 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f207zg", "unstable-pac", "memory-x", "time-driver-any", "exti"] } |
| 10 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 12 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 12 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 13 | 13 | ||
| 14 | defmt = "0.3" | 14 | defmt = "0.3" |
| 15 | defmt-rtt = "0.4" | 15 | defmt-rtt = "0.4" |
diff --git a/examples/stm32f2/src/bin/pll.rs b/examples/stm32f2/src/bin/pll.rs index 17f09538c..894937614 100644 --- a/examples/stm32f2/src/bin/pll.rs +++ b/examples/stm32f2/src/bin/pll.rs | |||
| @@ -39,9 +39,9 @@ async fn main(_spawner: Spawner) { | |||
| 39 | // System clock comes from PLL (= the 120 MHz main PLL output) | 39 | // System clock comes from PLL (= the 120 MHz main PLL output) |
| 40 | config.rcc.mux = ClockSrc::PLL; | 40 | config.rcc.mux = ClockSrc::PLL; |
| 41 | // 120 MHz / 4 = 30 MHz APB1 frequency | 41 | // 120 MHz / 4 = 30 MHz APB1 frequency |
| 42 | config.rcc.apb1_pre = APBPrescaler::Div4; | 42 | config.rcc.apb1_pre = APBPrescaler::DIV4; |
| 43 | // 120 MHz / 2 = 60 MHz APB2 frequency | 43 | // 120 MHz / 2 = 60 MHz APB2 frequency |
| 44 | config.rcc.apb2_pre = APBPrescaler::Div2; | 44 | config.rcc.apb2_pre = APBPrescaler::DIV2; |
| 45 | 45 | ||
| 46 | let _p = embassy_stm32::init(config); | 46 | let _p = embassy_stm32::init(config); |
| 47 | 47 | ||
diff --git a/examples/stm32f3/Cargo.toml b/examples/stm32f3/Cargo.toml index 5d8f5f74c..534e783de 100644 --- a/examples/stm32f3/Cargo.toml +++ b/examples/stm32f3/Cargo.toml | |||
| @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" | |||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | # Change stm32f303ze to your chip name, if necessary. | 8 | # Change stm32f303ze to your chip name, if necessary. |
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f303ze", "unstable-pac", "memory-x", "time-driver-any", "exti"] } | 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f303ze", "unstable-pac", "memory-x", "time-driver-any", "exti"] } |
| 10 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } | 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } |
| 12 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 12 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 13 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } | 13 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } |
| 14 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | 14 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } |
| 15 | 15 | ||
diff --git a/examples/stm32f3/src/bin/usart_dma.rs b/examples/stm32f3/src/bin/usart_dma.rs index 85f01a69e..ce8c212ae 100644 --- a/examples/stm32f3/src/bin/usart_dma.rs +++ b/examples/stm32f3/src/bin/usart_dma.rs | |||
| @@ -22,7 +22,7 @@ async fn main(_spawner: Spawner) { | |||
| 22 | info!("Hello World!"); | 22 | info!("Hello World!"); |
| 23 | 23 | ||
| 24 | let config = Config::default(); | 24 | let config = Config::default(); |
| 25 | let mut usart = Uart::new(p.USART1, p.PE1, p.PE0, Irqs, p.DMA1_CH4, NoDma, config); | 25 | let mut usart = Uart::new(p.USART1, p.PE1, p.PE0, Irqs, p.DMA1_CH4, NoDma, config).unwrap(); |
| 26 | 26 | ||
| 27 | for n in 0u32.. { | 27 | for n in 0u32.. { |
| 28 | let mut s: String<128> = String::new(); | 28 | let mut s: String<128> = String::new(); |
diff --git a/examples/stm32f334/Cargo.toml b/examples/stm32f334/Cargo.toml index 65183b88f..239c58b34 100644 --- a/examples/stm32f334/Cargo.toml +++ b/examples/stm32f334/Cargo.toml | |||
| @@ -5,7 +5,7 @@ version = "0.1.0" | |||
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } | 9 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f334r8", "unstable-pac", "memory-x", "time-driver-any", "exti"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f334r8", "unstable-pac", "memory-x", "time-driver-any", "exti"] } |
diff --git a/examples/stm32f334/src/bin/adc.rs b/examples/stm32f334/src/bin/adc.rs new file mode 100644 index 000000000..ed246a7db --- /dev/null +++ b/examples/stm32f334/src/bin/adc.rs | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt::info; | ||
| 6 | use embassy_executor::Spawner; | ||
| 7 | use embassy_stm32::adc::{Adc, SampleTime}; | ||
| 8 | use embassy_stm32::peripherals::ADC1; | ||
| 9 | use embassy_stm32::rcc::AdcClockSource; | ||
| 10 | use embassy_stm32::time::mhz; | ||
| 11 | use embassy_stm32::{adc, bind_interrupts, Config}; | ||
| 12 | use embassy_time::{Delay, Duration, Timer}; | ||
| 13 | use {defmt_rtt as _, panic_probe as _}; | ||
| 14 | |||
| 15 | bind_interrupts!(struct Irqs { | ||
| 16 | ADC1_2 => adc::InterruptHandler<ADC1>; | ||
| 17 | }); | ||
| 18 | |||
| 19 | #[embassy_executor::main] | ||
| 20 | async fn main(_spawner: Spawner) -> ! { | ||
| 21 | let mut config = Config::default(); | ||
| 22 | config.rcc.sysclk = Some(mhz(64)); | ||
| 23 | config.rcc.hclk = Some(mhz(64)); | ||
| 24 | config.rcc.pclk1 = Some(mhz(32)); | ||
| 25 | config.rcc.pclk2 = Some(mhz(64)); | ||
| 26 | config.rcc.adc = Some(AdcClockSource::PllDiv1); | ||
| 27 | |||
| 28 | let mut p = embassy_stm32::init(config); | ||
| 29 | |||
| 30 | info!("create adc..."); | ||
| 31 | |||
| 32 | let mut adc = Adc::new(p.ADC1, Irqs, &mut Delay); | ||
| 33 | |||
| 34 | adc.set_sample_time(SampleTime::Cycles601_5); | ||
| 35 | |||
| 36 | info!("enable vrefint..."); | ||
| 37 | |||
| 38 | let mut vrefint = adc.enable_vref(&mut Delay); | ||
| 39 | let mut temperature = adc.enable_temperature(); | ||
| 40 | |||
| 41 | loop { | ||
| 42 | let vref = adc.read(&mut vrefint).await; | ||
| 43 | info!("read vref: {} (should be {})", vref, vrefint.value()); | ||
| 44 | |||
| 45 | let temp = adc.read(&mut temperature).await; | ||
| 46 | info!("read temperature: {}", temp); | ||
| 47 | |||
| 48 | let pin = adc.read(&mut p.PA0).await; | ||
| 49 | info!("read pin: {}", pin); | ||
| 50 | |||
| 51 | let pin_mv = (pin as u32 * vrefint.value() as u32 / vref as u32) * 3300 / 4095; | ||
| 52 | info!("computed pin mv: {}", pin_mv); | ||
| 53 | |||
| 54 | Timer::after(Duration::from_millis(500)).await; | ||
| 55 | } | ||
| 56 | } | ||
diff --git a/examples/stm32f334/src/bin/pwm.rs b/examples/stm32f334/src/bin/pwm.rs index 2660b10c5..aebc421b3 100644 --- a/examples/stm32f334/src/bin/pwm.rs +++ b/examples/stm32f334/src/bin/pwm.rs | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::hrtim::*; | 7 | use embassy_stm32::hrtim::*; |
| 8 | use embassy_stm32::rcc::HrtimClockSource; | ||
| 8 | use embassy_stm32::time::{khz, mhz}; | 9 | use embassy_stm32::time::{khz, mhz}; |
| 9 | use embassy_stm32::Config; | 10 | use embassy_stm32::Config; |
| 10 | use embassy_time::{Duration, Timer}; | 11 | use embassy_time::{Duration, Timer}; |
| @@ -17,6 +18,7 @@ async fn main(_spawner: Spawner) { | |||
| 17 | config.rcc.hclk = Some(mhz(64)); | 18 | config.rcc.hclk = Some(mhz(64)); |
| 18 | config.rcc.pclk1 = Some(mhz(32)); | 19 | config.rcc.pclk1 = Some(mhz(32)); |
| 19 | config.rcc.pclk2 = Some(mhz(64)); | 20 | config.rcc.pclk2 = Some(mhz(64)); |
| 21 | config.rcc.hrtim = HrtimClockSource::PllClk; | ||
| 20 | 22 | ||
| 21 | let p = embassy_stm32::init(config); | 23 | let p = embassy_stm32::init(config); |
| 22 | info!("Hello World!"); | 24 | info!("Hello World!"); |
diff --git a/examples/stm32f4/Cargo.toml b/examples/stm32f4/Cargo.toml index ed456c5cb..4b4fb479b 100644 --- a/examples/stm32f4/Cargo.toml +++ b/examples/stm32f4/Cargo.toml | |||
| @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" | |||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | # Change stm32f429zi to your chip name, if necessary. | 8 | # Change stm32f429zi to your chip name, if necessary. |
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti", "embedded-sdmmc", "chrono"] } | 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti", "embedded-sdmmc", "chrono"] } |
| 10 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } | 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } |
| 12 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] } | 12 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] } |
| 13 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } | 13 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } |
| 14 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "nightly"] } | 14 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "nightly"] } |
| 15 | 15 | ||
diff --git a/examples/stm32f4/src/bin/adc.rs b/examples/stm32f4/src/bin/adc.rs index 1c9a0b35d..dd10385c4 100644 --- a/examples/stm32f4/src/bin/adc.rs +++ b/examples/stm32f4/src/bin/adc.rs | |||
| @@ -24,7 +24,7 @@ async fn main(_spawner: Spawner) { | |||
| 24 | // Startup delay can be combined to the maximum of either | 24 | // Startup delay can be combined to the maximum of either |
| 25 | delay.delay_us(Temperature::start_time_us().max(VrefInt::start_time_us())); | 25 | delay.delay_us(Temperature::start_time_us().max(VrefInt::start_time_us())); |
| 26 | 26 | ||
| 27 | let vrefint_sample = adc.read_internal(&mut vrefint); | 27 | let vrefint_sample = adc.read(&mut vrefint); |
| 28 | 28 | ||
| 29 | let convert_to_millivolts = |sample| { | 29 | let convert_to_millivolts = |sample| { |
| 30 | // From http://www.st.com/resource/en/datasheet/DM00071990.pdf | 30 | // From http://www.st.com/resource/en/datasheet/DM00071990.pdf |
| @@ -55,12 +55,12 @@ async fn main(_spawner: Spawner) { | |||
| 55 | info!("PC1: {} ({} mV)", v, convert_to_millivolts(v)); | 55 | info!("PC1: {} ({} mV)", v, convert_to_millivolts(v)); |
| 56 | 56 | ||
| 57 | // Read internal temperature | 57 | // Read internal temperature |
| 58 | let v = adc.read_internal(&mut temp); | 58 | let v = adc.read(&mut temp); |
| 59 | let celcius = convert_to_celcius(v); | 59 | let celcius = convert_to_celcius(v); |
| 60 | info!("Internal temp: {} ({} C)", v, celcius); | 60 | info!("Internal temp: {} ({} C)", v, celcius); |
| 61 | 61 | ||
| 62 | // Read internal voltage reference | 62 | // Read internal voltage reference |
| 63 | let v = adc.read_internal(&mut vrefint); | 63 | let v = adc.read(&mut vrefint); |
| 64 | info!("VrefInt: {}", v); | 64 | info!("VrefInt: {}", v); |
| 65 | 65 | ||
| 66 | Timer::after(Duration::from_millis(100)).await; | 66 | Timer::after(Duration::from_millis(100)).await; |
diff --git a/examples/stm32f4/src/bin/eth.rs b/examples/stm32f4/src/bin/eth.rs index 393e60b73..16bf5d949 100644 --- a/examples/stm32f4/src/bin/eth.rs +++ b/examples/stm32f4/src/bin/eth.rs | |||
| @@ -79,7 +79,10 @@ async fn main(spawner: Spawner) -> ! { | |||
| 79 | )); | 79 | )); |
| 80 | 80 | ||
| 81 | // Launch network task | 81 | // Launch network task |
| 82 | unwrap!(spawner.spawn(net_task(&stack))); | 82 | unwrap!(spawner.spawn(net_task(stack))); |
| 83 | |||
| 84 | // Ensure DHCP configuration is up before trying connect | ||
| 85 | stack.wait_config_up().await; | ||
| 83 | 86 | ||
| 84 | info!("Network task initialized"); | 87 | info!("Network task initialized"); |
| 85 | 88 | ||
| @@ -97,6 +100,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 97 | let r = socket.connect(remote_endpoint).await; | 100 | let r = socket.connect(remote_endpoint).await; |
| 98 | if let Err(e) = r { | 101 | if let Err(e) = r { |
| 99 | info!("connect error: {:?}", e); | 102 | info!("connect error: {:?}", e); |
| 103 | Timer::after(Duration::from_secs(1)).await; | ||
| 100 | continue; | 104 | continue; |
| 101 | } | 105 | } |
| 102 | info!("connected!"); | 106 | info!("connected!"); |
| @@ -105,7 +109,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 105 | let r = socket.write_all(&buf).await; | 109 | let r = socket.write_all(&buf).await; |
| 106 | if let Err(e) = r { | 110 | if let Err(e) = r { |
| 107 | info!("write error: {:?}", e); | 111 | info!("write error: {:?}", e); |
| 108 | continue; | 112 | break; |
| 109 | } | 113 | } |
| 110 | Timer::after(Duration::from_secs(1)).await; | 114 | Timer::after(Duration::from_secs(1)).await; |
| 111 | } | 115 | } |
diff --git a/examples/stm32f4/src/bin/rtc.rs b/examples/stm32f4/src/bin/rtc.rs index 0eca58203..e33746008 100644 --- a/examples/stm32f4/src/bin/rtc.rs +++ b/examples/stm32f4/src/bin/rtc.rs | |||
| @@ -5,13 +5,18 @@ | |||
| 5 | use chrono::{NaiveDate, NaiveDateTime}; | 5 | use chrono::{NaiveDate, NaiveDateTime}; |
| 6 | use defmt::*; | 6 | use defmt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::rtc::{Rtc, RtcConfig}; | 8 | use embassy_stm32::rtc::{Rtc, RtcClockSource, RtcConfig}; |
| 9 | use embassy_stm32::Config; | ||
| 9 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::{Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 12 | ||
| 12 | #[embassy_executor::main] | 13 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner) { | 14 | async fn main(_spawner: Spawner) { |
| 14 | let p = embassy_stm32::init(Default::default()); | 15 | let mut config = Config::default(); |
| 16 | config.rcc.lsi = true; | ||
| 17 | config.rcc.rtc = Option::Some(RtcClockSource::LSI); | ||
| 18 | let p = embassy_stm32::init(config); | ||
| 19 | |||
| 15 | info!("Hello World!"); | 20 | info!("Hello World!"); |
| 16 | 21 | ||
| 17 | let now = NaiveDate::from_ymd_opt(2020, 5, 15) | 22 | let now = NaiveDate::from_ymd_opt(2020, 5, 15) |
| @@ -23,8 +28,11 @@ async fn main(_spawner: Spawner) { | |||
| 23 | 28 | ||
| 24 | rtc.set_datetime(now.into()).expect("datetime not set"); | 29 | rtc.set_datetime(now.into()).expect("datetime not set"); |
| 25 | 30 | ||
| 26 | // In reality the delay would be much longer | 31 | loop { |
| 27 | Timer::after(Duration::from_millis(20000)).await; | 32 | let now: NaiveDateTime = rtc.now().unwrap().into(); |
| 33 | |||
| 34 | info!("{}", now.timestamp()); | ||
| 28 | 35 | ||
| 29 | let _then: NaiveDateTime = rtc.now().unwrap().into(); | 36 | Timer::after(Duration::from_millis(1000)).await; |
| 37 | } | ||
| 30 | } | 38 | } |
diff --git a/examples/stm32f4/src/bin/usart.rs b/examples/stm32f4/src/bin/usart.rs index 7680fe845..45e94715f 100644 --- a/examples/stm32f4/src/bin/usart.rs +++ b/examples/stm32f4/src/bin/usart.rs | |||
| @@ -20,7 +20,7 @@ fn main() -> ! { | |||
| 20 | let p = embassy_stm32::init(Default::default()); | 20 | let p = embassy_stm32::init(Default::default()); |
| 21 | 21 | ||
| 22 | let config = Config::default(); | 22 | let config = Config::default(); |
| 23 | let mut usart = Uart::new(p.USART3, p.PD9, p.PD8, Irqs, NoDma, NoDma, config); | 23 | let mut usart = Uart::new(p.USART3, p.PD9, p.PD8, Irqs, NoDma, NoDma, config).unwrap(); |
| 24 | 24 | ||
| 25 | unwrap!(usart.blocking_write(b"Hello Embassy World!\r\n")); | 25 | unwrap!(usart.blocking_write(b"Hello Embassy World!\r\n")); |
| 26 | info!("wrote Hello, starting echo"); | 26 | info!("wrote Hello, starting echo"); |
diff --git a/examples/stm32f4/src/bin/usart_buffered.rs b/examples/stm32f4/src/bin/usart_buffered.rs index c0a64d94b..71abc2893 100644 --- a/examples/stm32f4/src/bin/usart_buffered.rs +++ b/examples/stm32f4/src/bin/usart_buffered.rs | |||
| @@ -22,7 +22,7 @@ async fn main(_spawner: Spawner) { | |||
| 22 | 22 | ||
| 23 | let mut tx_buf = [0u8; 32]; | 23 | let mut tx_buf = [0u8; 32]; |
| 24 | let mut rx_buf = [0u8; 32]; | 24 | let mut rx_buf = [0u8; 32]; |
| 25 | let mut buf_usart = BufferedUart::new(p.USART3, Irqs, p.PD9, p.PD8, &mut tx_buf, &mut rx_buf, config); | 25 | let mut buf_usart = BufferedUart::new(p.USART3, Irqs, p.PD9, p.PD8, &mut tx_buf, &mut rx_buf, config).unwrap(); |
| 26 | 26 | ||
| 27 | loop { | 27 | loop { |
| 28 | let buf = buf_usart.fill_buf().await.unwrap(); | 28 | let buf = buf_usart.fill_buf().await.unwrap(); |
diff --git a/examples/stm32f4/src/bin/usart_dma.rs b/examples/stm32f4/src/bin/usart_dma.rs index 3408ec370..dca25a78c 100644 --- a/examples/stm32f4/src/bin/usart_dma.rs +++ b/examples/stm32f4/src/bin/usart_dma.rs | |||
| @@ -22,7 +22,7 @@ async fn main(_spawner: Spawner) { | |||
| 22 | info!("Hello World!"); | 22 | info!("Hello World!"); |
| 23 | 23 | ||
| 24 | let config = Config::default(); | 24 | let config = Config::default(); |
| 25 | let mut usart = Uart::new(p.USART3, p.PD9, p.PD8, Irqs, p.DMA1_CH3, NoDma, config); | 25 | let mut usart = Uart::new(p.USART3, p.PD9, p.PD8, Irqs, p.DMA1_CH3, NoDma, config).unwrap(); |
| 26 | 26 | ||
| 27 | for n in 0u32.. { | 27 | for n in 0u32.. { |
| 28 | let mut s: String<128> = String::new(); | 28 | let mut s: String<128> = String::new(); |
diff --git a/examples/stm32f7/Cargo.toml b/examples/stm32f7/Cargo.toml index b658a9640..bf8f413d8 100644 --- a/examples/stm32f7/Cargo.toml +++ b/examples/stm32f7/Cargo.toml | |||
| @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" | |||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | # Change stm32f767zi to your chip name, if necessary. | 8 | # Change stm32f767zi to your chip name, if necessary. |
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f767zi", "memory-x", "unstable-pac", "time-driver-any", "exti"] } | 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32f767zi", "memory-x", "unstable-pac", "time-driver-any", "exti"] } |
| 10 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 12 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 12 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 13 | embassy-net = { path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet"] } | 13 | embassy-net = { path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet"] } |
| 14 | embedded-io-async = { version = "0.5.0" } | 14 | embedded-io-async = { version = "0.5.0" } |
| 15 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } | 15 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } |
diff --git a/examples/stm32f7/src/bin/adc.rs b/examples/stm32f7/src/bin/adc.rs index 70b3b2a75..bc4ed2892 100644 --- a/examples/stm32f7/src/bin/adc.rs +++ b/examples/stm32f7/src/bin/adc.rs | |||
| @@ -17,7 +17,7 @@ async fn main(_spawner: Spawner) { | |||
| 17 | let mut pin = p.PA3; | 17 | let mut pin = p.PA3; |
| 18 | 18 | ||
| 19 | let mut vrefint = adc.enable_vrefint(); | 19 | let mut vrefint = adc.enable_vrefint(); |
| 20 | let vrefint_sample = adc.read_internal(&mut vrefint); | 20 | let vrefint_sample = adc.read(&mut vrefint); |
| 21 | let convert_to_millivolts = |sample| { | 21 | let convert_to_millivolts = |sample| { |
| 22 | // From http://www.st.com/resource/en/datasheet/DM00273119.pdf | 22 | // From http://www.st.com/resource/en/datasheet/DM00273119.pdf |
| 23 | // 6.3.27 Reference voltage | 23 | // 6.3.27 Reference voltage |
diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs index f0e280c35..93c97c8ee 100644 --- a/examples/stm32f7/src/bin/eth.rs +++ b/examples/stm32f7/src/bin/eth.rs | |||
| @@ -80,7 +80,10 @@ async fn main(spawner: Spawner) -> ! { | |||
| 80 | )); | 80 | )); |
| 81 | 81 | ||
| 82 | // Launch network task | 82 | // Launch network task |
| 83 | unwrap!(spawner.spawn(net_task(&stack))); | 83 | unwrap!(spawner.spawn(net_task(stack))); |
| 84 | |||
| 85 | // Ensure DHCP configuration is up before trying connect | ||
| 86 | stack.wait_config_up().await; | ||
| 84 | 87 | ||
| 85 | info!("Network task initialized"); | 88 | info!("Network task initialized"); |
| 86 | 89 | ||
| @@ -98,6 +101,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 98 | let r = socket.connect(remote_endpoint).await; | 101 | let r = socket.connect(remote_endpoint).await; |
| 99 | if let Err(e) = r { | 102 | if let Err(e) = r { |
| 100 | info!("connect error: {:?}", e); | 103 | info!("connect error: {:?}", e); |
| 104 | Timer::after(Duration::from_secs(1)).await; | ||
| 101 | continue; | 105 | continue; |
| 102 | } | 106 | } |
| 103 | info!("connected!"); | 107 | info!("connected!"); |
| @@ -106,7 +110,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 106 | let r = socket.write_all(&buf).await; | 110 | let r = socket.write_all(&buf).await; |
| 107 | if let Err(e) = r { | 111 | if let Err(e) = r { |
| 108 | info!("write error: {:?}", e); | 112 | info!("write error: {:?}", e); |
| 109 | continue; | 113 | break; |
| 110 | } | 114 | } |
| 111 | Timer::after(Duration::from_secs(1)).await; | 115 | Timer::after(Duration::from_secs(1)).await; |
| 112 | } | 116 | } |
diff --git a/examples/stm32f7/src/bin/usart_dma.rs b/examples/stm32f7/src/bin/usart_dma.rs index 4700287a7..ba064081e 100644 --- a/examples/stm32f7/src/bin/usart_dma.rs +++ b/examples/stm32f7/src/bin/usart_dma.rs | |||
| @@ -20,7 +20,7 @@ bind_interrupts!(struct Irqs { | |||
| 20 | async fn main(_spawner: Spawner) { | 20 | async fn main(_spawner: Spawner) { |
| 21 | let p = embassy_stm32::init(Default::default()); | 21 | let p = embassy_stm32::init(Default::default()); |
| 22 | let config = Config::default(); | 22 | let config = Config::default(); |
| 23 | let mut usart = Uart::new(p.UART7, p.PA8, p.PA15, Irqs, p.DMA1_CH1, NoDma, config); | 23 | let mut usart = Uart::new(p.UART7, p.PA8, p.PA15, Irqs, p.DMA1_CH1, NoDma, config).unwrap(); |
| 24 | 24 | ||
| 25 | for n in 0u32.. { | 25 | for n in 0u32.. { |
| 26 | let mut s: String<128> = String::new(); | 26 | let mut s: String<128> = String::new(); |
diff --git a/examples/stm32g0/Cargo.toml b/examples/stm32g0/Cargo.toml index 4e88151a5..b4b423d58 100644 --- a/examples/stm32g0/Cargo.toml +++ b/examples/stm32g0/Cargo.toml | |||
| @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" | |||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | # Change stm32g071rb to your chip name, if necessary. | 8 | # Change stm32g071rb to your chip name, if necessary. |
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g071rb", "memory-x", "unstable-pac", "exti"] } | 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g071rb", "memory-x", "unstable-pac", "exti"] } |
| 10 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 12 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 12 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 13 | 13 | ||
| 14 | defmt = "0.3" | 14 | defmt = "0.3" |
| 15 | defmt-rtt = "0.4" | 15 | defmt-rtt = "0.4" |
diff --git a/examples/stm32g4/Cargo.toml b/examples/stm32g4/Cargo.toml index 7bb05dbc8..59da06283 100644 --- a/examples/stm32g4/Cargo.toml +++ b/examples/stm32g4/Cargo.toml | |||
| @@ -7,10 +7,12 @@ license = "MIT OR Apache-2.0" | |||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | # Change stm32g491re to your chip name, if necessary. | 8 | # Change stm32g491re to your chip name, if necessary. |
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g491re", "memory-x", "unstable-pac", "exti"] } | 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "time-driver-any", "stm32g491re", "memory-x", "unstable-pac", "exti"] } |
| 10 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 12 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 12 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 13 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } | 13 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } |
| 14 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | ||
| 15 | usbd-hid = "0.6.0" | ||
| 14 | 16 | ||
| 15 | defmt = "0.3" | 17 | defmt = "0.3" |
| 16 | defmt-rtt = "0.4" | 18 | defmt-rtt = "0.4" |
diff --git a/examples/stm32g4/src/bin/adc.rs b/examples/stm32g4/src/bin/adc.rs new file mode 100644 index 000000000..a792748bc --- /dev/null +++ b/examples/stm32g4/src/bin/adc.rs | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt::*; | ||
| 6 | use embassy_executor::Spawner; | ||
| 7 | use embassy_stm32::adc::{Adc, SampleTime}; | ||
| 8 | use embassy_stm32::rcc::{AdcClockSource, ClockSrc, Pll, PllM, PllN, PllR, PllSrc}; | ||
| 9 | use embassy_stm32::Config; | ||
| 10 | use embassy_time::{Delay, Duration, Timer}; | ||
| 11 | use {defmt_rtt as _, panic_probe as _}; | ||
| 12 | |||
| 13 | #[embassy_executor::main] | ||
| 14 | async fn main(_spawner: Spawner) { | ||
| 15 | let mut config = Config::default(); | ||
| 16 | |||
| 17 | config.rcc.pll = Some(Pll { | ||
| 18 | source: PllSrc::HSI16, | ||
| 19 | prediv_m: PllM::Div4, | ||
| 20 | mul_n: PllN::Mul85, | ||
| 21 | div_p: None, | ||
| 22 | div_q: None, | ||
| 23 | // Main system clock at 170 MHz | ||
| 24 | div_r: Some(PllR::Div2), | ||
| 25 | }); | ||
| 26 | |||
| 27 | config.rcc.adc12_clock_source = AdcClockSource::SysClk; | ||
| 28 | config.rcc.mux = ClockSrc::PLL; | ||
| 29 | |||
| 30 | let mut p = embassy_stm32::init(config); | ||
| 31 | info!("Hello World!"); | ||
| 32 | |||
| 33 | let mut adc = Adc::new(p.ADC2, &mut Delay); | ||
| 34 | adc.set_sample_time(SampleTime::Cycles32_5); | ||
| 35 | |||
| 36 | loop { | ||
| 37 | let measured = adc.read(&mut p.PA7); | ||
| 38 | info!("measured: {}", measured); | ||
| 39 | Timer::after(Duration::from_millis(500)).await; | ||
| 40 | } | ||
| 41 | } | ||
diff --git a/examples/stm32h5/Cargo.toml b/examples/stm32h5/Cargo.toml index f7a1de63e..42a426185 100644 --- a/examples/stm32h5/Cargo.toml +++ b/examples/stm32h5/Cargo.toml | |||
| @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" | |||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | # Change stm32h563zi to your chip name, if necessary. | 8 | # Change stm32h563zi to your chip name, if necessary. |
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h563zi", "memory-x", "time-driver-any", "exti", "unstable-pac", "unstable-traits"] } | 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h563zi", "memory-x", "time-driver-any", "exti", "unstable-pac", "unstable-traits"] } |
| 10 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 12 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] } | 12 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] } |
| 13 | embassy-net = { path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6"] } | 13 | embassy-net = { path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6"] } |
| 14 | embedded-io-async = { version = "0.5.0" } | 14 | embedded-io-async = { version = "0.5.0" } |
| 15 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } | 15 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } |
| @@ -29,7 +29,7 @@ heapless = { version = "0.7.5", default-features = false } | |||
| 29 | rand_core = "0.6.3" | 29 | rand_core = "0.6.3" |
| 30 | critical-section = "1.1" | 30 | critical-section = "1.1" |
| 31 | micromath = "2.0.0" | 31 | micromath = "2.0.0" |
| 32 | stm32-fmc = "0.2.4" | 32 | stm32-fmc = "0.3.0" |
| 33 | embedded-storage = "0.3.0" | 33 | embedded-storage = "0.3.0" |
| 34 | static_cell = { version = "1.1", features = ["nightly"]} | 34 | static_cell = { version = "1.1", features = ["nightly"]} |
| 35 | 35 | ||
diff --git a/examples/stm32h5/src/bin/eth.rs b/examples/stm32h5/src/bin/eth.rs index 763520ab8..4e92d0647 100644 --- a/examples/stm32h5/src/bin/eth.rs +++ b/examples/stm32h5/src/bin/eth.rs | |||
| @@ -48,10 +48,10 @@ async fn main(spawner: Spawner) -> ! { | |||
| 48 | divq: Some(2), | 48 | divq: Some(2), |
| 49 | divr: None, | 49 | divr: None, |
| 50 | }); | 50 | }); |
| 51 | config.rcc.ahb_pre = AHBPrescaler::NotDivided; | 51 | config.rcc.ahb_pre = AHBPrescaler::DIV1; |
| 52 | config.rcc.apb1_pre = APBPrescaler::NotDivided; | 52 | config.rcc.apb1_pre = APBPrescaler::DIV1; |
| 53 | config.rcc.apb2_pre = APBPrescaler::NotDivided; | 53 | config.rcc.apb2_pre = APBPrescaler::DIV1; |
| 54 | config.rcc.apb3_pre = APBPrescaler::NotDivided; | 54 | config.rcc.apb3_pre = APBPrescaler::DIV1; |
| 55 | config.rcc.sys = Sysclk::Pll1P; | 55 | config.rcc.sys = Sysclk::Pll1P; |
| 56 | config.rcc.voltage_scale = VoltageScale::Scale0; | 56 | config.rcc.voltage_scale = VoltageScale::Scale0; |
| 57 | let p = embassy_stm32::init(config); | 57 | let p = embassy_stm32::init(config); |
| @@ -101,6 +101,9 @@ async fn main(spawner: Spawner) -> ! { | |||
| 101 | // Launch network task | 101 | // Launch network task |
| 102 | unwrap!(spawner.spawn(net_task(&stack))); | 102 | unwrap!(spawner.spawn(net_task(&stack))); |
| 103 | 103 | ||
| 104 | // Ensure DHCP configuration is up before trying connect | ||
| 105 | stack.wait_config_up().await; | ||
| 106 | |||
| 104 | info!("Network task initialized"); | 107 | info!("Network task initialized"); |
| 105 | 108 | ||
| 106 | // Then we can use it! | 109 | // Then we can use it! |
| @@ -125,7 +128,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 125 | let r = socket.write_all(b"Hello\n").await; | 128 | let r = socket.write_all(b"Hello\n").await; |
| 126 | if let Err(e) = r { | 129 | if let Err(e) = r { |
| 127 | info!("write error: {:?}", e); | 130 | info!("write error: {:?}", e); |
| 128 | continue; | 131 | break; |
| 129 | } | 132 | } |
| 130 | Timer::after(Duration::from_secs(1)).await; | 133 | Timer::after(Duration::from_secs(1)).await; |
| 131 | } | 134 | } |
diff --git a/examples/stm32h5/src/bin/usart.rs b/examples/stm32h5/src/bin/usart.rs index 0abb94abb..db04d4e55 100644 --- a/examples/stm32h5/src/bin/usart.rs +++ b/examples/stm32h5/src/bin/usart.rs | |||
| @@ -20,7 +20,7 @@ async fn main_task() { | |||
| 20 | let p = embassy_stm32::init(Default::default()); | 20 | let p = embassy_stm32::init(Default::default()); |
| 21 | 21 | ||
| 22 | let config = Config::default(); | 22 | let config = Config::default(); |
| 23 | let mut usart = Uart::new(p.UART7, p.PF6, p.PF7, Irqs, NoDma, NoDma, config); | 23 | let mut usart = Uart::new(p.UART7, p.PF6, p.PF7, Irqs, NoDma, NoDma, config).unwrap(); |
| 24 | 24 | ||
| 25 | unwrap!(usart.blocking_write(b"Hello Embassy World!\r\n")); | 25 | unwrap!(usart.blocking_write(b"Hello Embassy World!\r\n")); |
| 26 | info!("wrote Hello, starting echo"); | 26 | info!("wrote Hello, starting echo"); |
diff --git a/examples/stm32h5/src/bin/usart_dma.rs b/examples/stm32h5/src/bin/usart_dma.rs index 48264f884..bafe50839 100644 --- a/examples/stm32h5/src/bin/usart_dma.rs +++ b/examples/stm32h5/src/bin/usart_dma.rs | |||
| @@ -23,7 +23,7 @@ async fn main_task() { | |||
| 23 | let p = embassy_stm32::init(Default::default()); | 23 | let p = embassy_stm32::init(Default::default()); |
| 24 | 24 | ||
| 25 | let config = Config::default(); | 25 | let config = Config::default(); |
| 26 | let mut usart = Uart::new(p.UART7, p.PF6, p.PF7, Irqs, p.GPDMA1_CH0, NoDma, config); | 26 | let mut usart = Uart::new(p.UART7, p.PF6, p.PF7, Irqs, p.GPDMA1_CH0, NoDma, config).unwrap(); |
| 27 | 27 | ||
| 28 | for n in 0u32.. { | 28 | for n in 0u32.. { |
| 29 | let mut s: String<128> = String::new(); | 29 | let mut s: String<128> = String::new(); |
diff --git a/examples/stm32h5/src/bin/usart_split.rs b/examples/stm32h5/src/bin/usart_split.rs index a6b2e690b..d9037c014 100644 --- a/examples/stm32h5/src/bin/usart_split.rs +++ b/examples/stm32h5/src/bin/usart_split.rs | |||
| @@ -36,7 +36,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 36 | info!("Hello World!"); | 36 | info!("Hello World!"); |
| 37 | 37 | ||
| 38 | let config = Config::default(); | 38 | let config = Config::default(); |
| 39 | let mut usart = Uart::new(p.UART7, p.PF6, p.PF7, Irqs, p.GPDMA1_CH0, p.GPDMA1_CH1, config); | 39 | let mut usart = Uart::new(p.UART7, p.PF6, p.PF7, Irqs, p.GPDMA1_CH0, p.GPDMA1_CH1, config).unwrap(); |
| 40 | unwrap!(usart.blocking_write(b"Type 8 chars to echo!\r\n")); | 40 | unwrap!(usart.blocking_write(b"Type 8 chars to echo!\r\n")); |
| 41 | 41 | ||
| 42 | let (mut tx, rx) = usart.split(); | 42 | let (mut tx, rx) = usart.split(); |
diff --git a/examples/stm32h5/src/bin/usb_serial.rs b/examples/stm32h5/src/bin/usb_serial.rs index 336eed644..cbe540a06 100644 --- a/examples/stm32h5/src/bin/usb_serial.rs +++ b/examples/stm32h5/src/bin/usb_serial.rs | |||
| @@ -35,10 +35,10 @@ async fn main(_spawner: Spawner) { | |||
| 35 | divq: None, | 35 | divq: None, |
| 36 | divr: None, | 36 | divr: None, |
| 37 | }); | 37 | }); |
| 38 | config.rcc.ahb_pre = AHBPrescaler::Div2; | 38 | config.rcc.ahb_pre = AHBPrescaler::DIV2; |
| 39 | config.rcc.apb1_pre = APBPrescaler::Div4; | 39 | config.rcc.apb1_pre = APBPrescaler::DIV4; |
| 40 | config.rcc.apb2_pre = APBPrescaler::Div2; | 40 | config.rcc.apb2_pre = APBPrescaler::DIV2; |
| 41 | config.rcc.apb3_pre = APBPrescaler::Div4; | 41 | config.rcc.apb3_pre = APBPrescaler::DIV4; |
| 42 | config.rcc.sys = Sysclk::Pll1P; | 42 | config.rcc.sys = Sysclk::Pll1P; |
| 43 | config.rcc.voltage_scale = VoltageScale::Scale0; | 43 | config.rcc.voltage_scale = VoltageScale::Scale0; |
| 44 | let p = embassy_stm32::init(config); | 44 | let p = embassy_stm32::init(config); |
diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml index 1ee11b07f..c1d49963c 100644 --- a/examples/stm32h7/Cargo.toml +++ b/examples/stm32h7/Cargo.toml | |||
| @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" | |||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | # Change stm32h743bi to your chip name, if necessary. | 8 | # Change stm32h743bi to your chip name, if necessary. |
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h743bi", "time-driver-any", "exti", "memory-x", "unstable-pac", "unstable-traits"] } | 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32h743bi", "time-driver-any", "exti", "memory-x", "unstable-pac", "unstable-traits"] } |
| 10 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 12 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] } | 12 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] } |
| 13 | embassy-net = { path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6"] } | 13 | embassy-net = { path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6"] } |
| 14 | embedded-io-async = { version = "0.5.0" } | 14 | embedded-io-async = { version = "0.5.0" } |
| 15 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } | 15 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } |
| @@ -29,7 +29,7 @@ heapless = { version = "0.7.5", default-features = false } | |||
| 29 | rand_core = "0.6.3" | 29 | rand_core = "0.6.3" |
| 30 | critical-section = "1.1" | 30 | critical-section = "1.1" |
| 31 | micromath = "2.0.0" | 31 | micromath = "2.0.0" |
| 32 | stm32-fmc = "0.2.4" | 32 | stm32-fmc = "0.3.0" |
| 33 | embedded-storage = "0.3.0" | 33 | embedded-storage = "0.3.0" |
| 34 | static_cell = { version = "1.1", features = ["nightly"]} | 34 | static_cell = { version = "1.1", features = ["nightly"]} |
| 35 | 35 | ||
diff --git a/examples/stm32h7/src/bin/adc.rs b/examples/stm32h7/src/bin/adc.rs index 0e1e28c72..77922d4bc 100644 --- a/examples/stm32h7/src/bin/adc.rs +++ b/examples/stm32h7/src/bin/adc.rs | |||
| @@ -5,8 +5,6 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::adc::{Adc, SampleTime}; | 7 | use embassy_stm32::adc::{Adc, SampleTime}; |
| 8 | use embassy_stm32::rcc::AdcClockSource; | ||
| 9 | use embassy_stm32::time::mhz; | ||
| 10 | use embassy_stm32::Config; | 8 | use embassy_stm32::Config; |
| 11 | use embassy_time::{Delay, Duration, Timer}; | 9 | use embassy_time::{Delay, Duration, Timer}; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -14,10 +12,34 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 14 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 15 | async fn main(_spawner: Spawner) { | 13 | async fn main(_spawner: Spawner) { |
| 16 | let mut config = Config::default(); | 14 | let mut config = Config::default(); |
| 17 | config.rcc.sys_ck = Some(mhz(400)); | 15 | { |
| 18 | config.rcc.hclk = Some(mhz(200)); | 16 | use embassy_stm32::rcc::*; |
| 19 | config.rcc.per_ck = Some(mhz(64)); | 17 | config.rcc.hsi = Some(Hsi::Mhz64); |
| 20 | config.rcc.adc_clock_source = AdcClockSource::PerCk; | 18 | config.rcc.csi = true; |
| 19 | config.rcc.pll_src = PllSource::Hsi; | ||
| 20 | config.rcc.pll1 = Some(Pll { | ||
| 21 | prediv: 4, | ||
| 22 | mul: 50, | ||
| 23 | divp: Some(2), | ||
| 24 | divq: Some(8), // SPI1 cksel defaults to pll1_q | ||
| 25 | divr: None, | ||
| 26 | }); | ||
| 27 | config.rcc.pll2 = Some(Pll { | ||
| 28 | prediv: 4, | ||
| 29 | mul: 50, | ||
| 30 | divp: Some(8), // 100mhz | ||
| 31 | divq: None, | ||
| 32 | divr: None, | ||
| 33 | }); | ||
| 34 | config.rcc.sys = Sysclk::Pll1P; // 400 Mhz | ||
| 35 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 200 Mhz | ||
| 36 | config.rcc.apb1_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 37 | config.rcc.apb2_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 38 | config.rcc.apb3_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 39 | config.rcc.apb4_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 40 | config.rcc.voltage_scale = VoltageScale::Scale1; | ||
| 41 | config.rcc.adc_clock_source = AdcClockSource::PLL2_P; | ||
| 42 | } | ||
| 21 | let mut p = embassy_stm32::init(config); | 43 | let mut p = embassy_stm32::init(config); |
| 22 | 44 | ||
| 23 | info!("Hello World!"); | 45 | info!("Hello World!"); |
diff --git a/examples/stm32h7/src/bin/camera.rs b/examples/stm32h7/src/bin/camera.rs index 6f75a0630..de8ddc292 100644 --- a/examples/stm32h7/src/bin/camera.rs +++ b/examples/stm32h7/src/bin/camera.rs | |||
| @@ -6,8 +6,8 @@ use embassy_executor::Spawner; | |||
| 6 | use embassy_stm32::dcmi::{self, *}; | 6 | use embassy_stm32::dcmi::{self, *}; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_stm32::i2c::I2c; | 8 | use embassy_stm32::i2c::I2c; |
| 9 | use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; | 9 | use embassy_stm32::rcc::{Mco, Mco1Source}; |
| 10 | use embassy_stm32::time::{khz, mhz}; | 10 | use embassy_stm32::time::khz; |
| 11 | use embassy_stm32::{bind_interrupts, i2c, peripherals, Config}; | 11 | use embassy_stm32::{bind_interrupts, i2c, peripherals, Config}; |
| 12 | use embassy_time::{Duration, Timer}; | 12 | use embassy_time::{Duration, Timer}; |
| 13 | use ov7725::*; | 13 | use ov7725::*; |
| @@ -26,17 +26,30 @@ bind_interrupts!(struct Irqs { | |||
| 26 | #[embassy_executor::main] | 26 | #[embassy_executor::main] |
| 27 | async fn main(_spawner: Spawner) { | 27 | async fn main(_spawner: Spawner) { |
| 28 | let mut config = Config::default(); | 28 | let mut config = Config::default(); |
| 29 | config.rcc.sys_ck = Some(mhz(400)); | 29 | { |
| 30 | config.rcc.hclk = Some(mhz(400)); | 30 | use embassy_stm32::rcc::*; |
| 31 | config.rcc.pll1.q_ck = Some(mhz(100)); | 31 | config.rcc.hsi = Some(Hsi::Mhz64); |
| 32 | config.rcc.pclk1 = Some(mhz(100)); | 32 | config.rcc.csi = true; |
| 33 | config.rcc.pclk2 = Some(mhz(100)); | 33 | config.rcc.pll_src = PllSource::Hsi; |
| 34 | config.rcc.pclk3 = Some(mhz(100)); | 34 | config.rcc.pll1 = Some(Pll { |
| 35 | config.rcc.pclk4 = Some(mhz(100)); | 35 | prediv: 4, |
| 36 | mul: 50, | ||
| 37 | divp: Some(2), | ||
| 38 | divq: Some(8), // 100mhz | ||
| 39 | divr: None, | ||
| 40 | }); | ||
| 41 | config.rcc.sys = Sysclk::Pll1P; // 400 Mhz | ||
| 42 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 200 Mhz | ||
| 43 | config.rcc.apb1_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 44 | config.rcc.apb2_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 45 | config.rcc.apb3_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 46 | config.rcc.apb4_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 47 | config.rcc.voltage_scale = VoltageScale::Scale1; | ||
| 48 | } | ||
| 36 | let p = embassy_stm32::init(config); | 49 | let p = embassy_stm32::init(config); |
| 37 | 50 | ||
| 38 | defmt::info!("Hello World!"); | 51 | defmt::info!("Hello World!"); |
| 39 | let mco = Mco::new(p.MCO1, p.PA8, Mco1Source::Hsi, McoClock::Divided(3)); | 52 | let mco = Mco::new(p.MCO1, p.PA8, Mco1Source::HSI, 3); |
| 40 | 53 | ||
| 41 | let mut led = Output::new(p.PE3, Level::High, Speed::Low); | 54 | let mut led = Output::new(p.PE3, Level::High, Speed::Low); |
| 42 | let cam_i2c = I2c::new( | 55 | let cam_i2c = I2c::new( |
diff --git a/examples/stm32h7/src/bin/dac.rs b/examples/stm32h7/src/bin/dac.rs index ee078286b..93df7a319 100644 --- a/examples/stm32h7/src/bin/dac.rs +++ b/examples/stm32h7/src/bin/dac.rs | |||
| @@ -6,7 +6,6 @@ use cortex_m_rt::entry; | |||
| 6 | use defmt::*; | 6 | use defmt::*; |
| 7 | use embassy_stm32::dac::{DacCh1, DacChannel, Value}; | 7 | use embassy_stm32::dac::{DacCh1, DacChannel, Value}; |
| 8 | use embassy_stm32::dma::NoDma; | 8 | use embassy_stm32::dma::NoDma; |
| 9 | use embassy_stm32::time::mhz; | ||
| 10 | use embassy_stm32::Config; | 9 | use embassy_stm32::Config; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 11 | ||
| @@ -15,9 +14,34 @@ fn main() -> ! { | |||
| 15 | info!("Hello World, dude!"); | 14 | info!("Hello World, dude!"); |
| 16 | 15 | ||
| 17 | let mut config = Config::default(); | 16 | let mut config = Config::default(); |
| 18 | config.rcc.sys_ck = Some(mhz(400)); | 17 | { |
| 19 | config.rcc.hclk = Some(mhz(200)); | 18 | use embassy_stm32::rcc::*; |
| 20 | config.rcc.pll1.q_ck = Some(mhz(100)); | 19 | config.rcc.hsi = Some(Hsi::Mhz64); |
| 20 | config.rcc.csi = true; | ||
| 21 | config.rcc.pll_src = PllSource::Hsi; | ||
| 22 | config.rcc.pll1 = Some(Pll { | ||
| 23 | prediv: 4, | ||
| 24 | mul: 50, | ||
| 25 | divp: Some(2), | ||
| 26 | divq: Some(8), // SPI1 cksel defaults to pll1_q | ||
| 27 | divr: None, | ||
| 28 | }); | ||
| 29 | config.rcc.pll2 = Some(Pll { | ||
| 30 | prediv: 4, | ||
| 31 | mul: 50, | ||
| 32 | divp: Some(8), // 100mhz | ||
| 33 | divq: None, | ||
| 34 | divr: None, | ||
| 35 | }); | ||
| 36 | config.rcc.sys = Sysclk::Pll1P; // 400 Mhz | ||
| 37 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 200 Mhz | ||
| 38 | config.rcc.apb1_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 39 | config.rcc.apb2_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 40 | config.rcc.apb3_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 41 | config.rcc.apb4_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 42 | config.rcc.voltage_scale = VoltageScale::Scale1; | ||
| 43 | config.rcc.adc_clock_source = AdcClockSource::PLL2_P; | ||
| 44 | } | ||
| 21 | let p = embassy_stm32::init(config); | 45 | let p = embassy_stm32::init(config); |
| 22 | 46 | ||
| 23 | let mut dac = DacCh1::new(p.DAC1, NoDma, p.PA4); | 47 | let mut dac = DacCh1::new(p.DAC1, NoDma, p.PA4); |
diff --git a/examples/stm32h7/src/bin/dac_dma.rs b/examples/stm32h7/src/bin/dac_dma.rs index a9cb5d1ed..8c921abca 100644 --- a/examples/stm32h7/src/bin/dac_dma.rs +++ b/examples/stm32h7/src/bin/dac_dma.rs | |||
| @@ -8,7 +8,7 @@ use embassy_stm32::dac::{DacChannel, ValueArray}; | |||
| 8 | use embassy_stm32::pac::timer::vals::{Mms, Opm}; | 8 | use embassy_stm32::pac::timer::vals::{Mms, Opm}; |
| 9 | use embassy_stm32::peripherals::{TIM6, TIM7}; | 9 | use embassy_stm32::peripherals::{TIM6, TIM7}; |
| 10 | use embassy_stm32::rcc::low_level::RccPeripheral; | 10 | use embassy_stm32::rcc::low_level::RccPeripheral; |
| 11 | use embassy_stm32::time::{mhz, Hertz}; | 11 | use embassy_stm32::time::Hertz; |
| 12 | use embassy_stm32::timer::low_level::Basic16bitInstance; | 12 | use embassy_stm32::timer::low_level::Basic16bitInstance; |
| 13 | use micromath::F32Ext; | 13 | use micromath::F32Ext; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -22,9 +22,34 @@ pub type Dac2Type = | |||
| 22 | #[embassy_executor::main] | 22 | #[embassy_executor::main] |
| 23 | async fn main(spawner: Spawner) { | 23 | async fn main(spawner: Spawner) { |
| 24 | let mut config = embassy_stm32::Config::default(); | 24 | let mut config = embassy_stm32::Config::default(); |
| 25 | config.rcc.sys_ck = Some(mhz(400)); | 25 | { |
| 26 | config.rcc.hclk = Some(mhz(100)); | 26 | use embassy_stm32::rcc::*; |
| 27 | config.rcc.pll1.q_ck = Some(mhz(100)); | 27 | config.rcc.hsi = Some(Hsi::Mhz64); |
| 28 | config.rcc.csi = true; | ||
| 29 | config.rcc.pll_src = PllSource::Hsi; | ||
| 30 | config.rcc.pll1 = Some(Pll { | ||
| 31 | prediv: 4, | ||
| 32 | mul: 50, | ||
| 33 | divp: Some(2), | ||
| 34 | divq: Some(8), // SPI1 cksel defaults to pll1_q | ||
| 35 | divr: None, | ||
| 36 | }); | ||
| 37 | config.rcc.pll2 = Some(Pll { | ||
| 38 | prediv: 4, | ||
| 39 | mul: 50, | ||
| 40 | divp: Some(8), // 100mhz | ||
| 41 | divq: None, | ||
| 42 | divr: None, | ||
| 43 | }); | ||
| 44 | config.rcc.sys = Sysclk::Pll1P; // 400 Mhz | ||
| 45 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 200 Mhz | ||
| 46 | config.rcc.apb1_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 47 | config.rcc.apb2_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 48 | config.rcc.apb3_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 49 | config.rcc.apb4_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 50 | config.rcc.voltage_scale = VoltageScale::Scale1; | ||
| 51 | config.rcc.adc_clock_source = AdcClockSource::PLL2_P; | ||
| 52 | } | ||
| 28 | 53 | ||
| 29 | // Initialize the board and obtain a Peripherals instance | 54 | // Initialize the board and obtain a Peripherals instance |
| 30 | let p: embassy_stm32::Peripherals = embassy_stm32::init(config); | 55 | let p: embassy_stm32::Peripherals = embassy_stm32::init(config); |
diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index 26a386e49..1b5d71ed3 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs | |||
| @@ -10,7 +10,6 @@ use embassy_stm32::eth::generic_smi::GenericSMI; | |||
| 10 | use embassy_stm32::eth::{Ethernet, PacketQueue}; | 10 | use embassy_stm32::eth::{Ethernet, PacketQueue}; |
| 11 | use embassy_stm32::peripherals::ETH; | 11 | use embassy_stm32::peripherals::ETH; |
| 12 | use embassy_stm32::rng::Rng; | 12 | use embassy_stm32::rng::Rng; |
| 13 | use embassy_stm32::time::mhz; | ||
| 14 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 13 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; |
| 15 | use embassy_time::{Duration, Timer}; | 14 | use embassy_time::{Duration, Timer}; |
| 16 | use embedded_io_async::Write; | 15 | use embedded_io_async::Write; |
| @@ -33,9 +32,27 @@ async fn net_task(stack: &'static Stack<Device>) -> ! { | |||
| 33 | #[embassy_executor::main] | 32 | #[embassy_executor::main] |
| 34 | async fn main(spawner: Spawner) -> ! { | 33 | async fn main(spawner: Spawner) -> ! { |
| 35 | let mut config = Config::default(); | 34 | let mut config = Config::default(); |
| 36 | config.rcc.sys_ck = Some(mhz(400)); | 35 | { |
| 37 | config.rcc.hclk = Some(mhz(200)); | 36 | use embassy_stm32::rcc::*; |
| 38 | config.rcc.pll1.q_ck = Some(mhz(100)); | 37 | config.rcc.hsi = Some(Hsi::Mhz64); |
| 38 | config.rcc.csi = true; | ||
| 39 | config.rcc.hsi48 = true; // needed for RNG | ||
| 40 | config.rcc.pll_src = PllSource::Hsi; | ||
| 41 | config.rcc.pll1 = Some(Pll { | ||
| 42 | prediv: 4, | ||
| 43 | mul: 50, | ||
| 44 | divp: Some(2), | ||
| 45 | divq: None, | ||
| 46 | divr: None, | ||
| 47 | }); | ||
| 48 | config.rcc.sys = Sysclk::Pll1P; // 400 Mhz | ||
| 49 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 200 Mhz | ||
| 50 | config.rcc.apb1_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 51 | config.rcc.apb2_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 52 | config.rcc.apb3_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 53 | config.rcc.apb4_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 54 | config.rcc.voltage_scale = VoltageScale::Scale1; | ||
| 55 | } | ||
| 39 | let p = embassy_stm32::init(config); | 56 | let p = embassy_stm32::init(config); |
| 40 | info!("Hello World!"); | 57 | info!("Hello World!"); |
| 41 | 58 | ||
| @@ -83,6 +100,9 @@ async fn main(spawner: Spawner) -> ! { | |||
| 83 | // Launch network task | 100 | // Launch network task |
| 84 | unwrap!(spawner.spawn(net_task(&stack))); | 101 | unwrap!(spawner.spawn(net_task(&stack))); |
| 85 | 102 | ||
| 103 | // Ensure DHCP configuration is up before trying connect | ||
| 104 | stack.wait_config_up().await; | ||
| 105 | |||
| 86 | info!("Network task initialized"); | 106 | info!("Network task initialized"); |
| 87 | 107 | ||
| 88 | // Then we can use it! | 108 | // Then we can use it! |
| @@ -99,6 +119,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 99 | let r = socket.connect(remote_endpoint).await; | 119 | let r = socket.connect(remote_endpoint).await; |
| 100 | if let Err(e) = r { | 120 | if let Err(e) = r { |
| 101 | info!("connect error: {:?}", e); | 121 | info!("connect error: {:?}", e); |
| 122 | Timer::after(Duration::from_secs(1)).await; | ||
| 102 | continue; | 123 | continue; |
| 103 | } | 124 | } |
| 104 | info!("connected!"); | 125 | info!("connected!"); |
| @@ -106,7 +127,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 106 | let r = socket.write_all(b"Hello\n").await; | 127 | let r = socket.write_all(b"Hello\n").await; |
| 107 | if let Err(e) = r { | 128 | if let Err(e) = r { |
| 108 | info!("write error: {:?}", e); | 129 | info!("write error: {:?}", e); |
| 109 | continue; | 130 | break; |
| 110 | } | 131 | } |
| 111 | Timer::after(Duration::from_secs(1)).await; | 132 | Timer::after(Duration::from_secs(1)).await; |
| 112 | } | 133 | } |
diff --git a/examples/stm32h7/src/bin/eth_client.rs b/examples/stm32h7/src/bin/eth_client.rs index 6664410c8..3abd31c73 100644 --- a/examples/stm32h7/src/bin/eth_client.rs +++ b/examples/stm32h7/src/bin/eth_client.rs | |||
| @@ -10,7 +10,6 @@ use embassy_stm32::eth::generic_smi::GenericSMI; | |||
| 10 | use embassy_stm32::eth::{Ethernet, PacketQueue}; | 10 | use embassy_stm32::eth::{Ethernet, PacketQueue}; |
| 11 | use embassy_stm32::peripherals::ETH; | 11 | use embassy_stm32::peripherals::ETH; |
| 12 | use embassy_stm32::rng::Rng; | 12 | use embassy_stm32::rng::Rng; |
| 13 | use embassy_stm32::time::mhz; | ||
| 14 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 13 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; |
| 15 | use embassy_time::{Duration, Timer}; | 14 | use embassy_time::{Duration, Timer}; |
| 16 | use embedded_io_async::Write; | 15 | use embedded_io_async::Write; |
| @@ -34,9 +33,27 @@ async fn net_task(stack: &'static Stack<Device>) -> ! { | |||
| 34 | #[embassy_executor::main] | 33 | #[embassy_executor::main] |
| 35 | async fn main(spawner: Spawner) -> ! { | 34 | async fn main(spawner: Spawner) -> ! { |
| 36 | let mut config = Config::default(); | 35 | let mut config = Config::default(); |
| 37 | config.rcc.sys_ck = Some(mhz(400)); | 36 | { |
| 38 | config.rcc.hclk = Some(mhz(200)); | 37 | use embassy_stm32::rcc::*; |
| 39 | config.rcc.pll1.q_ck = Some(mhz(100)); | 38 | config.rcc.hsi = Some(Hsi::Mhz64); |
| 39 | config.rcc.csi = true; | ||
| 40 | config.rcc.hsi48 = true; // needed for RNG | ||
| 41 | config.rcc.pll_src = PllSource::Hsi; | ||
| 42 | config.rcc.pll1 = Some(Pll { | ||
| 43 | prediv: 4, | ||
| 44 | mul: 50, | ||
| 45 | divp: Some(2), | ||
| 46 | divq: None, | ||
| 47 | divr: None, | ||
| 48 | }); | ||
| 49 | config.rcc.sys = Sysclk::Pll1P; // 400 Mhz | ||
| 50 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 200 Mhz | ||
| 51 | config.rcc.apb1_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 52 | config.rcc.apb2_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 53 | config.rcc.apb3_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 54 | config.rcc.apb4_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 55 | config.rcc.voltage_scale = VoltageScale::Scale1; | ||
| 56 | } | ||
| 40 | let p = embassy_stm32::init(config); | 57 | let p = embassy_stm32::init(config); |
| 41 | info!("Hello World!"); | 58 | info!("Hello World!"); |
| 42 | 59 | ||
| @@ -82,12 +99,12 @@ async fn main(spawner: Spawner) -> ! { | |||
| 82 | )); | 99 | )); |
| 83 | 100 | ||
| 84 | // Launch network task | 101 | // Launch network task |
| 85 | unwrap!(spawner.spawn(net_task(&stack))); | 102 | unwrap!(spawner.spawn(net_task(stack))); |
| 86 | 103 | ||
| 87 | info!("Network task initialized"); | 104 | // Ensure DHCP configuration is up before trying connect |
| 105 | stack.wait_config_up().await; | ||
| 88 | 106 | ||
| 89 | // To ensure DHCP configuration before trying connect | 107 | info!("Network task initialized"); |
| 90 | Timer::after(Duration::from_secs(20)).await; | ||
| 91 | 108 | ||
| 92 | static STATE: TcpClientState<1, 1024, 1024> = TcpClientState::new(); | 109 | static STATE: TcpClientState<1, 1024, 1024> = TcpClientState::new(); |
| 93 | let client = TcpClient::new(&stack, &STATE); | 110 | let client = TcpClient::new(&stack, &STATE); |
| @@ -108,7 +125,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 108 | let r = connection.write_all(b"Hello\n").await; | 125 | let r = connection.write_all(b"Hello\n").await; |
| 109 | if let Err(e) = r { | 126 | if let Err(e) = r { |
| 110 | info!("write error: {:?}", e); | 127 | info!("write error: {:?}", e); |
| 111 | continue; | 128 | break; |
| 112 | } | 129 | } |
| 113 | Timer::after(Duration::from_secs(1)).await; | 130 | Timer::after(Duration::from_secs(1)).await; |
| 114 | } | 131 | } |
diff --git a/examples/stm32h7/src/bin/fmc.rs b/examples/stm32h7/src/bin/fmc.rs index 85c690fe6..de0b351df 100644 --- a/examples/stm32h7/src/bin/fmc.rs +++ b/examples/stm32h7/src/bin/fmc.rs | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::fmc::Fmc; | 7 | use embassy_stm32::fmc::Fmc; |
| 8 | use embassy_stm32::time::mhz; | ||
| 9 | use embassy_stm32::Config; | 8 | use embassy_stm32::Config; |
| 10 | use embassy_time::{Delay, Duration, Timer}; | 9 | use embassy_time::{Delay, Duration, Timer}; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -13,9 +12,26 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 13 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 14 | async fn main(_spawner: Spawner) { | 13 | async fn main(_spawner: Spawner) { |
| 15 | let mut config = Config::default(); | 14 | let mut config = Config::default(); |
| 16 | config.rcc.sys_ck = Some(mhz(400)); | 15 | { |
| 17 | config.rcc.hclk = Some(mhz(200)); | 16 | use embassy_stm32::rcc::*; |
| 18 | config.rcc.pll1.q_ck = Some(mhz(100)); | 17 | config.rcc.hsi = Some(Hsi::Mhz64); |
| 18 | config.rcc.csi = true; | ||
| 19 | config.rcc.pll_src = PllSource::Hsi; | ||
| 20 | config.rcc.pll1 = Some(Pll { | ||
| 21 | prediv: 4, | ||
| 22 | mul: 50, | ||
| 23 | divp: Some(2), | ||
| 24 | divq: Some(8), // 100mhz | ||
| 25 | divr: None, | ||
| 26 | }); | ||
| 27 | config.rcc.sys = Sysclk::Pll1P; // 400 Mhz | ||
| 28 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 200 Mhz | ||
| 29 | config.rcc.apb1_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 30 | config.rcc.apb2_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 31 | config.rcc.apb3_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 32 | config.rcc.apb4_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 33 | config.rcc.voltage_scale = VoltageScale::Scale1; | ||
| 34 | } | ||
| 19 | let p = embassy_stm32::init(config); | 35 | let p = embassy_stm32::init(config); |
| 20 | 36 | ||
| 21 | info!("Hello World!"); | 37 | info!("Hello World!"); |
diff --git a/examples/stm32h7/src/bin/low_level_timer_api.rs b/examples/stm32h7/src/bin/low_level_timer_api.rs index 45b0872b5..a1e955c39 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 defmt::*; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::low_level::AFType; | 7 | use embassy_stm32::gpio::low_level::AFType; |
| 8 | use embassy_stm32::gpio::Speed; | 8 | use embassy_stm32::gpio::Speed; |
| 9 | use embassy_stm32::time::{khz, mhz, Hertz}; | 9 | use embassy_stm32::time::{khz, Hertz}; |
| 10 | use embassy_stm32::timer::*; | 10 | use embassy_stm32::timer::*; |
| 11 | use embassy_stm32::{into_ref, Config, Peripheral, PeripheralRef}; | 11 | use embassy_stm32::{into_ref, Config, Peripheral, PeripheralRef}; |
| 12 | use embassy_time::{Duration, Timer}; | 12 | use embassy_time::{Duration, Timer}; |
| @@ -15,13 +15,27 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 15 | #[embassy_executor::main] | 15 | #[embassy_executor::main] |
| 16 | async fn main(_spawner: Spawner) { | 16 | async fn main(_spawner: Spawner) { |
| 17 | let mut config = Config::default(); | 17 | let mut config = Config::default(); |
| 18 | config.rcc.sys_ck = Some(mhz(400)); | 18 | { |
| 19 | config.rcc.hclk = Some(mhz(400)); | 19 | use embassy_stm32::rcc::*; |
| 20 | config.rcc.pll1.q_ck = Some(mhz(100)); | 20 | config.rcc.hsi = Some(Hsi::Mhz64); |
| 21 | config.rcc.pclk1 = Some(mhz(100)); | 21 | config.rcc.csi = true; |
| 22 | config.rcc.pclk2 = Some(mhz(100)); | 22 | config.rcc.hsi48 = true; // needed for RNG |
| 23 | config.rcc.pclk3 = Some(mhz(100)); | 23 | config.rcc.pll_src = PllSource::Hsi; |
| 24 | config.rcc.pclk4 = Some(mhz(100)); | 24 | config.rcc.pll1 = Some(Pll { |
| 25 | prediv: 4, | ||
| 26 | mul: 50, | ||
| 27 | divp: Some(2), | ||
| 28 | divq: Some(8), // 100 Mhz | ||
| 29 | divr: None, | ||
| 30 | }); | ||
| 31 | config.rcc.sys = Sysclk::Pll1P; // 400 Mhz | ||
| 32 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 200 Mhz | ||
| 33 | config.rcc.apb1_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 34 | config.rcc.apb2_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 35 | config.rcc.apb3_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 36 | config.rcc.apb4_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 37 | config.rcc.voltage_scale = VoltageScale::Scale1; | ||
| 38 | } | ||
| 25 | let p = embassy_stm32::init(config); | 39 | let p = embassy_stm32::init(config); |
| 26 | 40 | ||
| 27 | info!("Hello World!"); | 41 | info!("Hello World!"); |
diff --git a/examples/stm32h7/src/bin/mco.rs b/examples/stm32h7/src/bin/mco.rs index 036455d5e..9d6d805ae 100644 --- a/examples/stm32h7/src/bin/mco.rs +++ b/examples/stm32h7/src/bin/mco.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | 7 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 8 | use embassy_stm32::rcc::{Mco, Mco1Source, McoClock}; | 8 | use embassy_stm32::rcc::{Mco, Mco1Source}; |
| 9 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::{Duration, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 11 | ||
| @@ -16,7 +16,7 @@ async fn main(_spawner: Spawner) { | |||
| 16 | 16 | ||
| 17 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); | 17 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); |
| 18 | 18 | ||
| 19 | let _mco = Mco::new(p.MCO1, p.PA8, Mco1Source::Hsi, McoClock::Divided(8)); | 19 | let _mco = Mco::new(p.MCO1, p.PA8, Mco1Source::HSI, 8); |
| 20 | 20 | ||
| 21 | loop { | 21 | loop { |
| 22 | info!("high"); | 22 | info!("high"); |
diff --git a/examples/stm32h7/src/bin/pwm.rs b/examples/stm32h7/src/bin/pwm.rs index aa5ec1bcf..5c8e57aa2 100644 --- a/examples/stm32h7/src/bin/pwm.rs +++ b/examples/stm32h7/src/bin/pwm.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::OutputType; | 7 | use embassy_stm32::gpio::OutputType; |
| 8 | use embassy_stm32::time::{khz, mhz}; | 8 | use embassy_stm32::time::khz; |
| 9 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; | 9 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; |
| 10 | use embassy_stm32::timer::Channel; | 10 | use embassy_stm32::timer::Channel; |
| 11 | use embassy_stm32::Config; | 11 | use embassy_stm32::Config; |
| @@ -15,13 +15,26 @@ use {defmt_rtt as _, panic_probe as _}; | |||
| 15 | #[embassy_executor::main] | 15 | #[embassy_executor::main] |
| 16 | async fn main(_spawner: Spawner) { | 16 | async fn main(_spawner: Spawner) { |
| 17 | let mut config = Config::default(); | 17 | let mut config = Config::default(); |
| 18 | config.rcc.sys_ck = Some(mhz(400)); | 18 | { |
| 19 | config.rcc.hclk = Some(mhz(400)); | 19 | use embassy_stm32::rcc::*; |
| 20 | config.rcc.pll1.q_ck = Some(mhz(100)); | 20 | config.rcc.hsi = Some(Hsi::Mhz64); |
| 21 | config.rcc.pclk1 = Some(mhz(100)); | 21 | config.rcc.csi = true; |
| 22 | config.rcc.pclk2 = Some(mhz(100)); | 22 | config.rcc.pll_src = PllSource::Hsi; |
| 23 | config.rcc.pclk3 = Some(mhz(100)); | 23 | config.rcc.pll1 = Some(Pll { |
| 24 | config.rcc.pclk4 = Some(mhz(100)); | 24 | prediv: 4, |
| 25 | mul: 50, | ||
| 26 | divp: Some(2), | ||
| 27 | divq: None, | ||
| 28 | divr: None, | ||
| 29 | }); | ||
| 30 | config.rcc.sys = Sysclk::Pll1P; // 400 Mhz | ||
| 31 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 200 Mhz | ||
| 32 | config.rcc.apb1_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 33 | config.rcc.apb2_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 34 | config.rcc.apb3_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 35 | config.rcc.apb4_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 36 | config.rcc.voltage_scale = VoltageScale::Scale1; | ||
| 37 | } | ||
| 25 | let p = embassy_stm32::init(config); | 38 | let p = embassy_stm32::init(config); |
| 26 | info!("Hello World!"); | 39 | info!("Hello World!"); |
| 27 | 40 | ||
diff --git a/examples/stm32h7/src/bin/rng.rs b/examples/stm32h7/src/bin/rng.rs index 7c8c50eca..af1d6ebb8 100644 --- a/examples/stm32h7/src/bin/rng.rs +++ b/examples/stm32h7/src/bin/rng.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::rng::Rng; | 7 | use embassy_stm32::rng::Rng; |
| 8 | use embassy_stm32::{bind_interrupts, peripherals, rng}; | 8 | use embassy_stm32::{bind_interrupts, peripherals, rng, Config}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| 11 | bind_interrupts!(struct Irqs { | 11 | bind_interrupts!(struct Irqs { |
| @@ -14,7 +14,9 @@ bind_interrupts!(struct Irqs { | |||
| 14 | 14 | ||
| 15 | #[embassy_executor::main] | 15 | #[embassy_executor::main] |
| 16 | async fn main(_spawner: Spawner) { | 16 | async fn main(_spawner: Spawner) { |
| 17 | let p = embassy_stm32::init(Default::default()); | 17 | let mut config = Config::default(); |
| 18 | config.rcc.hsi48 = true; // needed for RNG. | ||
| 19 | let p = embassy_stm32::init(config); | ||
| 18 | info!("Hello World!"); | 20 | info!("Hello World!"); |
| 19 | 21 | ||
| 20 | let mut rng = Rng::new(p.RNG, Irqs); | 22 | let mut rng = Rng::new(p.RNG, Irqs); |
diff --git a/examples/stm32h7/src/bin/sdmmc.rs b/examples/stm32h7/src/bin/sdmmc.rs index ce91b6b1c..752aefdf7 100644 --- a/examples/stm32h7/src/bin/sdmmc.rs +++ b/examples/stm32h7/src/bin/sdmmc.rs | |||
| @@ -16,7 +16,26 @@ bind_interrupts!(struct Irqs { | |||
| 16 | #[embassy_executor::main] | 16 | #[embassy_executor::main] |
| 17 | async fn main(_spawner: Spawner) -> ! { | 17 | async fn main(_spawner: Spawner) -> ! { |
| 18 | let mut config = Config::default(); | 18 | let mut config = Config::default(); |
| 19 | config.rcc.sys_ck = Some(mhz(200)); | 19 | { |
| 20 | use embassy_stm32::rcc::*; | ||
| 21 | config.rcc.hsi = Some(Hsi::Mhz64); | ||
| 22 | config.rcc.csi = true; | ||
| 23 | config.rcc.pll_src = PllSource::Hsi; | ||
| 24 | config.rcc.pll1 = Some(Pll { | ||
| 25 | prediv: 4, | ||
| 26 | mul: 50, | ||
| 27 | divp: Some(2), | ||
| 28 | divq: Some(4), // default clock chosen by SDMMCSEL. 200 Mhz | ||
| 29 | divr: None, | ||
| 30 | }); | ||
| 31 | config.rcc.sys = Sysclk::Pll1P; // 400 Mhz | ||
| 32 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 200 Mhz | ||
| 33 | config.rcc.apb1_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 34 | config.rcc.apb2_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 35 | config.rcc.apb3_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 36 | config.rcc.apb4_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 37 | config.rcc.voltage_scale = VoltageScale::Scale1; | ||
| 38 | } | ||
| 20 | let p = embassy_stm32::init(config); | 39 | let p = embassy_stm32::init(config); |
| 21 | info!("Hello World!"); | 40 | info!("Hello World!"); |
| 22 | 41 | ||
diff --git a/examples/stm32h7/src/bin/spi.rs b/examples/stm32h7/src/bin/spi.rs index 28bba2b8d..9fe46f031 100644 --- a/examples/stm32h7/src/bin/spi.rs +++ b/examples/stm32h7/src/bin/spi.rs | |||
| @@ -38,9 +38,26 @@ fn main() -> ! { | |||
| 38 | info!("Hello World!"); | 38 | info!("Hello World!"); |
| 39 | 39 | ||
| 40 | let mut config = Config::default(); | 40 | let mut config = Config::default(); |
| 41 | config.rcc.sys_ck = Some(mhz(400)); | 41 | { |
| 42 | config.rcc.hclk = Some(mhz(200)); | 42 | use embassy_stm32::rcc::*; |
| 43 | config.rcc.pll1.q_ck = Some(mhz(100)); | 43 | config.rcc.hsi = Some(Hsi::Mhz64); |
| 44 | config.rcc.csi = true; | ||
| 45 | config.rcc.pll_src = PllSource::Hsi; | ||
| 46 | config.rcc.pll1 = Some(Pll { | ||
| 47 | prediv: 4, | ||
| 48 | mul: 50, | ||
| 49 | divp: Some(2), | ||
| 50 | divq: Some(4), // used by SPI3. 100Mhz. | ||
| 51 | divr: None, | ||
| 52 | }); | ||
| 53 | config.rcc.sys = Sysclk::Pll1P; // 400 Mhz | ||
| 54 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 200 Mhz | ||
| 55 | config.rcc.apb1_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 56 | config.rcc.apb2_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 57 | config.rcc.apb3_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 58 | config.rcc.apb4_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 59 | config.rcc.voltage_scale = VoltageScale::Scale1; | ||
| 60 | } | ||
| 44 | let p = embassy_stm32::init(config); | 61 | let p = embassy_stm32::init(config); |
| 45 | 62 | ||
| 46 | let mut spi_config = spi::Config::default(); | 63 | let mut spi_config = spi::Config::default(); |
diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs index f6e30cfa5..88d65d5be 100644 --- a/examples/stm32h7/src/bin/spi_dma.rs +++ b/examples/stm32h7/src/bin/spi_dma.rs | |||
| @@ -34,9 +34,26 @@ fn main() -> ! { | |||
| 34 | info!("Hello World!"); | 34 | info!("Hello World!"); |
| 35 | 35 | ||
| 36 | let mut config = Config::default(); | 36 | let mut config = Config::default(); |
| 37 | config.rcc.sys_ck = Some(mhz(400)); | 37 | { |
| 38 | config.rcc.hclk = Some(mhz(200)); | 38 | use embassy_stm32::rcc::*; |
| 39 | config.rcc.pll1.q_ck = Some(mhz(100)); | 39 | config.rcc.hsi = Some(Hsi::Mhz64); |
| 40 | config.rcc.csi = true; | ||
| 41 | config.rcc.pll_src = PllSource::Hsi; | ||
| 42 | config.rcc.pll1 = Some(Pll { | ||
| 43 | prediv: 4, | ||
| 44 | mul: 50, | ||
| 45 | divp: Some(2), | ||
| 46 | divq: Some(4), // used by SPI3. 100Mhz. | ||
| 47 | divr: None, | ||
| 48 | }); | ||
| 49 | config.rcc.sys = Sysclk::Pll1P; // 400 Mhz | ||
| 50 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 200 Mhz | ||
| 51 | config.rcc.apb1_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 52 | config.rcc.apb2_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 53 | config.rcc.apb3_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 54 | config.rcc.apb4_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 55 | config.rcc.voltage_scale = VoltageScale::Scale1; | ||
| 56 | } | ||
| 40 | let p = embassy_stm32::init(config); | 57 | let p = embassy_stm32::init(config); |
| 41 | 58 | ||
| 42 | let mut spi_config = spi::Config::default(); | 59 | let mut spi_config = spi::Config::default(); |
diff --git a/examples/stm32h7/src/bin/usart.rs b/examples/stm32h7/src/bin/usart.rs index 0abb94abb..db04d4e55 100644 --- a/examples/stm32h7/src/bin/usart.rs +++ b/examples/stm32h7/src/bin/usart.rs | |||
| @@ -20,7 +20,7 @@ async fn main_task() { | |||
| 20 | let p = embassy_stm32::init(Default::default()); | 20 | let p = embassy_stm32::init(Default::default()); |
| 21 | 21 | ||
| 22 | let config = Config::default(); | 22 | let config = Config::default(); |
| 23 | let mut usart = Uart::new(p.UART7, p.PF6, p.PF7, Irqs, NoDma, NoDma, config); | 23 | let mut usart = Uart::new(p.UART7, p.PF6, p.PF7, Irqs, NoDma, NoDma, config).unwrap(); |
| 24 | 24 | ||
| 25 | unwrap!(usart.blocking_write(b"Hello Embassy World!\r\n")); | 25 | unwrap!(usart.blocking_write(b"Hello Embassy World!\r\n")); |
| 26 | info!("wrote Hello, starting echo"); | 26 | info!("wrote Hello, starting echo"); |
diff --git a/examples/stm32h7/src/bin/usart_dma.rs b/examples/stm32h7/src/bin/usart_dma.rs index f1fe7fce6..249050fd1 100644 --- a/examples/stm32h7/src/bin/usart_dma.rs +++ b/examples/stm32h7/src/bin/usart_dma.rs | |||
| @@ -23,7 +23,7 @@ async fn main_task() { | |||
| 23 | let p = embassy_stm32::init(Default::default()); | 23 | let p = embassy_stm32::init(Default::default()); |
| 24 | 24 | ||
| 25 | let config = Config::default(); | 25 | let config = Config::default(); |
| 26 | let mut usart = Uart::new(p.UART7, p.PF6, p.PF7, Irqs, p.DMA1_CH0, NoDma, config); | 26 | let mut usart = Uart::new(p.UART7, p.PF6, p.PF7, Irqs, p.DMA1_CH0, NoDma, config).unwrap(); |
| 27 | 27 | ||
| 28 | for n in 0u32.. { | 28 | for n in 0u32.. { |
| 29 | let mut s: String<128> = String::new(); | 29 | let mut s: String<128> = String::new(); |
diff --git a/examples/stm32h7/src/bin/usart_split.rs b/examples/stm32h7/src/bin/usart_split.rs index aa0753450..61c9f1954 100644 --- a/examples/stm32h7/src/bin/usart_split.rs +++ b/examples/stm32h7/src/bin/usart_split.rs | |||
| @@ -36,7 +36,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 36 | info!("Hello World!"); | 36 | info!("Hello World!"); |
| 37 | 37 | ||
| 38 | let config = Config::default(); | 38 | let config = Config::default(); |
| 39 | let mut usart = Uart::new(p.UART7, p.PF6, p.PF7, Irqs, p.DMA1_CH0, p.DMA1_CH1, config); | 39 | let mut usart = Uart::new(p.UART7, p.PF6, p.PF7, Irqs, p.DMA1_CH0, p.DMA1_CH1, config).unwrap(); |
| 40 | unwrap!(usart.blocking_write(b"Type 8 chars to echo!\r\n")); | 40 | unwrap!(usart.blocking_write(b"Type 8 chars to echo!\r\n")); |
| 41 | 41 | ||
| 42 | let (mut tx, rx) = usart.split(); | 42 | let (mut tx, rx) = usart.split(); |
diff --git a/examples/stm32h7/src/bin/usb_serial.rs b/examples/stm32h7/src/bin/usb_serial.rs index 97291f60c..14de43568 100644 --- a/examples/stm32h7/src/bin/usb_serial.rs +++ b/examples/stm32h7/src/bin/usb_serial.rs | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::{panic, *}; | 5 | use defmt::{panic, *}; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::time::mhz; | ||
| 8 | use embassy_stm32::usb_otg::{Driver, Instance}; | 7 | use embassy_stm32::usb_otg::{Driver, Instance}; |
| 9 | use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config}; | 8 | use embassy_stm32::{bind_interrupts, peripherals, usb_otg, Config}; |
| 10 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 9 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| @@ -22,9 +21,27 @@ async fn main(_spawner: Spawner) { | |||
| 22 | info!("Hello World!"); | 21 | info!("Hello World!"); |
| 23 | 22 | ||
| 24 | let mut config = Config::default(); | 23 | let mut config = Config::default(); |
| 25 | config.rcc.sys_ck = Some(mhz(400)); | 24 | { |
| 26 | config.rcc.hclk = Some(mhz(200)); | 25 | use embassy_stm32::rcc::*; |
| 27 | config.rcc.pll1.q_ck = Some(mhz(100)); | 26 | config.rcc.hsi = Some(Hsi::Mhz64); |
| 27 | config.rcc.csi = true; | ||
| 28 | config.rcc.hsi48 = true; // needed for USB | ||
| 29 | config.rcc.pll_src = PllSource::Hsi; | ||
| 30 | config.rcc.pll1 = Some(Pll { | ||
| 31 | prediv: 4, | ||
| 32 | mul: 50, | ||
| 33 | divp: Some(2), | ||
| 34 | divq: None, | ||
| 35 | divr: None, | ||
| 36 | }); | ||
| 37 | config.rcc.sys = Sysclk::Pll1P; // 400 Mhz | ||
| 38 | config.rcc.ahb_pre = AHBPrescaler::DIV2; // 200 Mhz | ||
| 39 | config.rcc.apb1_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 40 | config.rcc.apb2_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 41 | config.rcc.apb3_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 42 | config.rcc.apb4_pre = APBPrescaler::DIV2; // 100 Mhz | ||
| 43 | config.rcc.voltage_scale = VoltageScale::Scale1; | ||
| 44 | } | ||
| 28 | let p = embassy_stm32::init(config); | 45 | let p = embassy_stm32::init(config); |
| 29 | 46 | ||
| 30 | // Create the driver, from the HAL. | 47 | // Create the driver, from the HAL. |
diff --git a/examples/stm32l0/Cargo.toml b/examples/stm32l0/Cargo.toml index d4e0da0bb..502ebfc8d 100644 --- a/examples/stm32l0/Cargo.toml +++ b/examples/stm32l0/Cargo.toml | |||
| @@ -12,13 +12,13 @@ nightly = ["embassy-stm32/nightly", "embassy-time/nightly", "embassy-time/unstab | |||
| 12 | [dependencies] | 12 | [dependencies] |
| 13 | # Change stm32l072cz to your chip name, if necessary. | 13 | # Change stm32l072cz to your chip name, if necessary. |
| 14 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "unstable-traits", "memory-x"] } | 14 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "unstable-traits", "memory-x"] } |
| 15 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 15 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } |
| 16 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 16 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 17 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 17 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 18 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["time", "defmt"], optional = true } | 18 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["time", "defmt"], optional = true } |
| 19 | lora-phy = { version = "1", optional = true } | 19 | lora-phy = { version = "2", optional = true } |
| 20 | lorawan-device = { version = "0.10.0", default-features = false, features = ["async", "external-lora-phy"], optional = true } | 20 | lorawan-device = { version = "0.11.0", default-features = false, features = ["async", "external-lora-phy"], optional = true } |
| 21 | lorawan = { version = "0.7.3", default-features = false, features = ["default-crypto"], optional = true } | 21 | lorawan = { version = "0.7.4", default-features = false, features = ["default-crypto"], optional = true } |
| 22 | 22 | ||
| 23 | defmt = "0.3" | 23 | defmt = "0.3" |
| 24 | defmt-rtt = "0.4" | 24 | defmt-rtt = "0.4" |
| @@ -37,6 +37,3 @@ static_cell = "1.1" | |||
| 37 | 37 | ||
| 38 | [profile.release] | 38 | [profile.release] |
| 39 | debug = 2 | 39 | debug = 2 |
| 40 | |||
| 41 | [patch.crates-io] | ||
| 42 | lora-phy = { git = "https://github.com/embassy-rs/lora-phy", rev = "1323eccc1c470d4259f95f4f315d1be830d572a3"} \ No newline at end of file | ||
diff --git a/examples/stm32l0/src/bin/lora_cad.rs b/examples/stm32l0/src/bin/lora_cad.rs index 7729b4163..900848fd8 100644 --- a/examples/stm32l0/src/bin/lora_cad.rs +++ b/examples/stm32l0/src/bin/lora_cad.rs | |||
| @@ -41,10 +41,8 @@ async fn main(_spawner: Spawner) { | |||
| 41 | 41 | ||
| 42 | let iv = Stm32l0InterfaceVariant::new(nss, reset, irq, None, None).unwrap(); | 42 | let iv = Stm32l0InterfaceVariant::new(nss, reset, irq, None, None).unwrap(); |
| 43 | 43 | ||
| 44 | let mut delay = Delay; | ||
| 45 | |||
| 46 | let mut lora = { | 44 | let mut lora = { |
| 47 | match LoRa::new(SX1276_7_8_9::new(BoardType::Stm32l0Sx1276, spi, iv), false, &mut delay).await { | 45 | match LoRa::new(SX1276_7_8_9::new(BoardType::Stm32l0Sx1276, spi, iv), false, Delay).await { |
| 48 | Ok(l) => l, | 46 | Ok(l) => l, |
| 49 | Err(err) => { | 47 | Err(err) => { |
| 50 | info!("Radio error = {}", err); | 48 | info!("Radio error = {}", err); |
diff --git a/examples/stm32l0/src/bin/lora_lorawan.rs b/examples/stm32l0/src/bin/lora_lorawan.rs index 10608aebf..7a93737e1 100644 --- a/examples/stm32l0/src/bin/lora_lorawan.rs +++ b/examples/stm32l0/src/bin/lora_lorawan.rs | |||
| @@ -21,6 +21,7 @@ use lora_phy::LoRa; | |||
| 21 | use lorawan::default_crypto::DefaultFactory as Crypto; | 21 | use lorawan::default_crypto::DefaultFactory as Crypto; |
| 22 | use lorawan_device::async_device::lora_radio::LoRaRadio; | 22 | use lorawan_device::async_device::lora_radio::LoRaRadio; |
| 23 | use lorawan_device::async_device::{region, Device, JoinMode}; | 23 | use lorawan_device::async_device::{region, Device, JoinMode}; |
| 24 | use lorawan_device::{AppEui, AppKey, DevEui}; | ||
| 24 | use {defmt_rtt as _, panic_probe as _}; | 25 | use {defmt_rtt as _, panic_probe as _}; |
| 25 | 26 | ||
| 26 | bind_interrupts!(struct Irqs { | 27 | bind_interrupts!(struct Irqs { |
| @@ -50,10 +51,8 @@ async fn main(_spawner: Spawner) { | |||
| 50 | 51 | ||
| 51 | let iv = Stm32l0InterfaceVariant::new(nss, reset, irq, None, None).unwrap(); | 52 | let iv = Stm32l0InterfaceVariant::new(nss, reset, irq, None, None).unwrap(); |
| 52 | 53 | ||
| 53 | let mut delay = Delay; | ||
| 54 | |||
| 55 | let lora = { | 54 | let lora = { |
| 56 | match LoRa::new(SX1276_7_8_9::new(BoardType::Stm32l0Sx1276, spi, iv), true, &mut delay).await { | 55 | match LoRa::new(SX1276_7_8_9::new(BoardType::Stm32l0Sx1276, spi, iv), true, Delay).await { |
| 57 | Ok(l) => l, | 56 | Ok(l) => l, |
| 58 | Err(err) => { | 57 | Err(err) => { |
| 59 | info!("Radio error = {}", err); | 58 | info!("Radio error = {}", err); |
| @@ -71,9 +70,9 @@ async fn main(_spawner: Spawner) { | |||
| 71 | // TODO: Adjust the EUI and Keys according to your network credentials | 70 | // TODO: Adjust the EUI and Keys according to your network credentials |
| 72 | match device | 71 | match device |
| 73 | .join(&JoinMode::OTAA { | 72 | .join(&JoinMode::OTAA { |
| 74 | deveui: [0, 0, 0, 0, 0, 0, 0, 0], | 73 | deveui: DevEui::from([0, 0, 0, 0, 0, 0, 0, 0]), |
| 75 | appeui: [0, 0, 0, 0, 0, 0, 0, 0], | 74 | appeui: AppEui::from([0, 0, 0, 0, 0, 0, 0, 0]), |
| 76 | appkey: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | 75 | appkey: AppKey::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), |
| 77 | }) | 76 | }) |
| 78 | .await | 77 | .await |
| 79 | { | 78 | { |
diff --git a/examples/stm32l0/src/bin/lora_p2p_receive.rs b/examples/stm32l0/src/bin/lora_p2p_receive.rs index 0f9f60952..edd14bb81 100644 --- a/examples/stm32l0/src/bin/lora_p2p_receive.rs +++ b/examples/stm32l0/src/bin/lora_p2p_receive.rs | |||
| @@ -41,10 +41,8 @@ async fn main(_spawner: Spawner) { | |||
| 41 | 41 | ||
| 42 | let iv = Stm32l0InterfaceVariant::new(nss, reset, irq, None, None).unwrap(); | 42 | let iv = Stm32l0InterfaceVariant::new(nss, reset, irq, None, None).unwrap(); |
| 43 | 43 | ||
| 44 | let mut delay = Delay; | ||
| 45 | |||
| 46 | let mut lora = { | 44 | let mut lora = { |
| 47 | match LoRa::new(SX1276_7_8_9::new(BoardType::Stm32l0Sx1276, spi, iv), false, &mut delay).await { | 45 | match LoRa::new(SX1276_7_8_9::new(BoardType::Stm32l0Sx1276, spi, iv), false, Delay).await { |
| 48 | Ok(l) => l, | 46 | Ok(l) => l, |
| 49 | Err(err) => { | 47 | Err(err) => { |
| 50 | info!("Radio error = {}", err); | 48 | info!("Radio error = {}", err); |
| @@ -88,7 +86,7 @@ async fn main(_spawner: Spawner) { | |||
| 88 | }; | 86 | }; |
| 89 | 87 | ||
| 90 | match lora | 88 | match lora |
| 91 | .prepare_for_rx(&mdltn_params, &rx_pkt_params, None, true, false, 0, 0x00ffffffu32) | 89 | .prepare_for_rx(&mdltn_params, &rx_pkt_params, None, None, false) |
| 92 | .await | 90 | .await |
| 93 | { | 91 | { |
| 94 | Ok(()) => {} | 92 | Ok(()) => {} |
diff --git a/examples/stm32l0/src/bin/lora_p2p_send.rs b/examples/stm32l0/src/bin/lora_p2p_send.rs index c85c3c2b6..23cc1c6f7 100644 --- a/examples/stm32l0/src/bin/lora_p2p_send.rs +++ b/examples/stm32l0/src/bin/lora_p2p_send.rs | |||
| @@ -41,10 +41,8 @@ async fn main(_spawner: Spawner) { | |||
| 41 | 41 | ||
| 42 | let iv = Stm32l0InterfaceVariant::new(nss, reset, irq, None, None).unwrap(); | 42 | let iv = Stm32l0InterfaceVariant::new(nss, reset, irq, None, None).unwrap(); |
| 43 | 43 | ||
| 44 | let mut delay = Delay; | ||
| 45 | |||
| 46 | let mut lora = { | 44 | let mut lora = { |
| 47 | match LoRa::new(SX1276_7_8_9::new(BoardType::Stm32l0Sx1276, spi, iv), false, &mut delay).await { | 45 | match LoRa::new(SX1276_7_8_9::new(BoardType::Stm32l0Sx1276, spi, iv), false, Delay).await { |
| 48 | Ok(l) => l, | 46 | Ok(l) => l, |
| 49 | Err(err) => { | 47 | Err(err) => { |
| 50 | info!("Radio error = {}", err); | 48 | info!("Radio error = {}", err); |
| @@ -97,7 +95,7 @@ async fn main(_spawner: Spawner) { | |||
| 97 | } | 95 | } |
| 98 | }; | 96 | }; |
| 99 | 97 | ||
| 100 | match lora.sleep(&mut delay).await { | 98 | match lora.sleep(false).await { |
| 101 | Ok(()) => info!("Sleep successful"), | 99 | Ok(()) => info!("Sleep successful"), |
| 102 | Err(err) => info!("Sleep unsuccessful = {}", err), | 100 | Err(err) => info!("Sleep unsuccessful = {}", err), |
| 103 | } | 101 | } |
diff --git a/examples/stm32l0/src/bin/usart_dma.rs b/examples/stm32l0/src/bin/usart_dma.rs index eae8f3452..62c9b5595 100644 --- a/examples/stm32l0/src/bin/usart_dma.rs +++ b/examples/stm32l0/src/bin/usart_dma.rs | |||
| @@ -15,7 +15,7 @@ bind_interrupts!(struct Irqs { | |||
| 15 | #[embassy_executor::main] | 15 | #[embassy_executor::main] |
| 16 | async fn main(_spawner: Spawner) { | 16 | async fn main(_spawner: Spawner) { |
| 17 | let p = embassy_stm32::init(Default::default()); | 17 | let p = embassy_stm32::init(Default::default()); |
| 18 | let mut usart = Uart::new(p.USART1, p.PB7, p.PB6, Irqs, p.DMA1_CH2, p.DMA1_CH3, Config::default()); | 18 | let mut usart = Uart::new(p.USART1, p.PB7, p.PB6, Irqs, p.DMA1_CH2, p.DMA1_CH3, Config::default()).unwrap(); |
| 19 | 19 | ||
| 20 | usart.write(b"Hello Embassy World!\r\n").await.unwrap(); | 20 | usart.write(b"Hello Embassy World!\r\n").await.unwrap(); |
| 21 | info!("wrote Hello, starting echo"); | 21 | info!("wrote Hello, starting echo"); |
diff --git a/examples/stm32l0/src/bin/usart_irq.rs b/examples/stm32l0/src/bin/usart_irq.rs index f5dabcc42..5107a1a0a 100644 --- a/examples/stm32l0/src/bin/usart_irq.rs +++ b/examples/stm32l0/src/bin/usart_irq.rs | |||
| @@ -18,13 +18,11 @@ async fn main(_spawner: Spawner) { | |||
| 18 | let p = embassy_stm32::init(Default::default()); | 18 | let p = embassy_stm32::init(Default::default()); |
| 19 | info!("Hi!"); | 19 | info!("Hi!"); |
| 20 | 20 | ||
| 21 | static mut TX_BUFFER: [u8; 8] = [0; 8]; | ||
| 22 | static mut RX_BUFFER: [u8; 256] = [0; 256]; | ||
| 23 | |||
| 24 | let mut config = Config::default(); | 21 | let mut config = Config::default(); |
| 25 | config.baudrate = 9600; | 22 | config.baudrate = 9600; |
| 26 | 23 | let mut tx_buf = [0u8; 256]; | |
| 27 | let mut usart = unsafe { BufferedUart::new(p.USART2, Irqs, p.PA3, p.PA2, &mut TX_BUFFER, &mut RX_BUFFER, config) }; | 24 | let mut rx_buf = [0u8; 256]; |
| 25 | let mut usart = BufferedUart::new(p.USART2, Irqs, p.PA3, p.PA2, &mut tx_buf, &mut rx_buf, config).unwrap(); | ||
| 28 | 26 | ||
| 29 | usart.write_all(b"Hello Embassy World!\r\n").await.unwrap(); | 27 | usart.write_all(b"Hello Embassy World!\r\n").await.unwrap(); |
| 30 | info!("wrote Hello, starting echo"); | 28 | info!("wrote Hello, starting echo"); |
diff --git a/examples/stm32l1/Cargo.toml b/examples/stm32l1/Cargo.toml index 192fd3e39..a75275a0b 100644 --- a/examples/stm32l1/Cargo.toml +++ b/examples/stm32l1/Cargo.toml | |||
| @@ -5,9 +5,9 @@ version = "0.1.0" | |||
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 9 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32l151cb-a", "time-driver-any", "memory-x"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32l151cb-a", "time-driver-any", "memory-x"] } |
| 12 | 12 | ||
| 13 | defmt = "0.3" | 13 | defmt = "0.3" |
diff --git a/examples/stm32l4/.cargo/config.toml b/examples/stm32l4/.cargo/config.toml index 36e74e5a5..db3a7ceff 100644 --- a/examples/stm32l4/.cargo/config.toml +++ b/examples/stm32l4/.cargo/config.toml | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | # replace STM32F429ZITx with your chip as listed in `probe-rs chip list` | 2 | # replace STM32F429ZITx with your chip as listed in `probe-rs chip list` |
| 3 | #runner = "probe-rs run --chip STM32L475VGT6" | 3 | #runner = "probe-rs run --chip STM32L475VGT6" |
| 4 | #runner = "probe-rs run --chip STM32L475VG" | 4 | #runner = "probe-rs run --chip STM32L475VG" |
| 5 | runner = "probe-rs run --chip STM32L4S5VI" | 5 | runner = "probe-run --chip STM32L4S5QI" |
| 6 | 6 | ||
| 7 | [build] | 7 | [build] |
| 8 | target = "thumbv7em-none-eabi" | 8 | target = "thumbv7em-none-eabi" |
diff --git a/examples/stm32l4/Cargo.toml b/examples/stm32l4/Cargo.toml index f552a6109..59e89c537 100644 --- a/examples/stm32l4/Cargo.toml +++ b/examples/stm32l4/Cargo.toml | |||
| @@ -1,17 +1,22 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | edition = "2021" | 2 | edition = "2021" |
| 3 | name = "embassy-stm32l4-examples" | 3 | name = "embassy-stm32l4-examples" |
| 4 | version = "0.1.0" | 4 | version = "0.1.1" |
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | # Change stm32l4s5vi to your chip name, if necessary. | 8 | # Change stm32l4s5vi to your chip name, if necessary. |
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l4s5vi", "memory-x", "time-driver-any", "exti", "unstable-traits", "chrono"] } | 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l4s5qi", "memory-x", "time-driver-any", "exti", "unstable-traits", "chrono"] } |
| 10 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 12 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 12 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768", "unstable-traits", "nightly"] } |
| 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } | 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } |
| 14 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } | 14 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } |
| 15 | embassy-net-adin1110 = { version = "0.2.0", path = "../../embassy-net-adin1110" } | ||
| 16 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "nightly", "udp", "tcp", "dhcpv4", "medium-ethernet"] } | ||
| 17 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | ||
| 18 | embedded-io-async = { version = "0.5.0", features = ["defmt-03"] } | ||
| 19 | embedded-io = { version = "0.5.0", features = ["defmt-03"] } | ||
| 15 | 20 | ||
| 16 | defmt = "0.3" | 21 | defmt = "0.3" |
| 17 | defmt-rtt = "0.4" | 22 | defmt-rtt = "0.4" |
| @@ -21,10 +26,13 @@ cortex-m-rt = "0.7.0" | |||
| 21 | embedded-hal = "0.2.6" | 26 | embedded-hal = "0.2.6" |
| 22 | embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1" } | 27 | embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1" } |
| 23 | embedded-hal-async = { version = "=1.0.0-rc.1" } | 28 | embedded-hal-async = { version = "=1.0.0-rc.1" } |
| 29 | embedded-hal-bus = { version = "=0.1.0-rc.1", features = ["async"] } | ||
| 24 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 30 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 25 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | 31 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } |
| 26 | heapless = { version = "0.7.5", default-features = false } | 32 | heapless = { version = "0.7.5", default-features = false } |
| 27 | chrono = { version = "^0.4", default-features = false } | 33 | chrono = { version = "^0.4", default-features = false } |
| 34 | rand = { version = "0.8.5", default-features = false } | ||
| 35 | static_cell = {version = "1.1", features = ["nightly"]} | ||
| 28 | 36 | ||
| 29 | micromath = "2.0.0" | 37 | micromath = "2.0.0" |
| 30 | 38 | ||
diff --git a/examples/stm32l4/src/bin/rtc.rs b/examples/stm32l4/src/bin/rtc.rs index 294ea456c..eb1eed012 100644 --- a/examples/stm32l4/src/bin/rtc.rs +++ b/examples/stm32l4/src/bin/rtc.rs | |||
| @@ -23,7 +23,8 @@ async fn main(_spawner: Spawner) { | |||
| 23 | PLLMul::Mul20, | 23 | PLLMul::Mul20, |
| 24 | None, | 24 | None, |
| 25 | ); | 25 | ); |
| 26 | config.rcc.rtc_mux = rcc::RtcClockSource::LSE32; | 26 | config.rcc.lse = Some(Hertz(32_768)); |
| 27 | config.rcc.rtc_mux = rcc::RtcClockSource::LSE; | ||
| 27 | embassy_stm32::init(config) | 28 | embassy_stm32::init(config) |
| 28 | }; | 29 | }; |
| 29 | info!("Hello World!"); | 30 | info!("Hello World!"); |
diff --git a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs new file mode 100644 index 000000000..287521582 --- /dev/null +++ b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs | |||
| @@ -0,0 +1,450 @@ | |||
| 1 | #![deny(clippy::pedantic)] | ||
| 2 | #![allow(clippy::doc_markdown)] | ||
| 3 | #![no_main] | ||
| 4 | #![no_std] | ||
| 5 | // Needed unitl https://github.com/rust-lang/rust/issues/63063 is stablised. | ||
| 6 | #![feature(type_alias_impl_trait)] | ||
| 7 | #![feature(associated_type_bounds)] | ||
| 8 | #![allow(clippy::missing_errors_doc)] | ||
| 9 | |||
| 10 | // This example works on a ANALOG DEVICE EVAL-ADIN110EBZ board. | ||
| 11 | // Settings switch S201 "HW CFG": | ||
| 12 | // - Without SPI CRC: OFF-ON-OFF-OFF-OFF | ||
| 13 | // - With SPI CRC: ON -ON-OFF-OFF-OFF | ||
| 14 | // Settings switch S303 "uC CFG": | ||
| 15 | // - CFG0: On = static ip, Off = Dhcp | ||
| 16 | // - CFG1: Ethernet `FCS` on TX path: On, Off | ||
| 17 | // The webserver shows the actual temperature of the onboard i2c temp sensor. | ||
| 18 | |||
| 19 | use core::marker::PhantomData; | ||
| 20 | use core::sync::atomic::{AtomicI32, Ordering}; | ||
| 21 | |||
| 22 | use defmt::{error, info, println, unwrap, Format}; | ||
| 23 | use defmt_rtt as _; // global logger | ||
| 24 | use embassy_executor::Spawner; | ||
| 25 | use embassy_futures::select::{select, Either}; | ||
| 26 | use embassy_futures::yield_now; | ||
| 27 | use embassy_net::tcp::TcpSocket; | ||
| 28 | use embassy_net::{Ipv4Address, Ipv4Cidr, Stack, StackResources, StaticConfigV4}; | ||
| 29 | use embassy_time::{Delay, Duration, Ticker, Timer}; | ||
| 30 | use embedded_hal_async::i2c::I2c as I2cBus; | ||
| 31 | use embedded_io::Write as bWrite; | ||
| 32 | use embedded_io_async::Write; | ||
| 33 | use hal::gpio::{Input, Level, Output, Speed}; | ||
| 34 | use hal::i2c::{self, I2c}; | ||
| 35 | use hal::rcc::{self}; | ||
| 36 | use hal::rng::{self, Rng}; | ||
| 37 | use hal::{bind_interrupts, exti, pac, peripherals}; | ||
| 38 | use heapless::Vec; | ||
| 39 | use rand::RngCore; | ||
| 40 | use static_cell::make_static; | ||
| 41 | use {embassy_stm32 as hal, panic_probe as _}; | ||
| 42 | |||
| 43 | bind_interrupts!(struct Irqs { | ||
| 44 | I2C3_EV => i2c::InterruptHandler<peripherals::I2C3>; | ||
| 45 | RNG => rng::InterruptHandler<peripherals::RNG>; | ||
| 46 | }); | ||
| 47 | |||
| 48 | use embassy_net_adin1110::{self, Device, Runner, ADIN1110}; | ||
| 49 | use embedded_hal_bus::spi::ExclusiveDevice; | ||
| 50 | use hal::gpio::Pull; | ||
| 51 | use hal::i2c::Config as I2C_Config; | ||
| 52 | use hal::rcc::{ClockSrc, PLLClkDiv, PLLMul, PLLSource, PLLSrcDiv}; | ||
| 53 | use hal::spi::{Config as SPI_Config, Spi}; | ||
| 54 | use hal::time::Hertz; | ||
| 55 | |||
| 56 | // Basic settings | ||
| 57 | // MAC-address used by the adin1110 | ||
| 58 | const MAC: [u8; 6] = [0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff]; | ||
| 59 | // Static IP settings | ||
| 60 | const IP_ADDRESS: Ipv4Cidr = Ipv4Cidr::new(Ipv4Address([192, 168, 1, 5]), 24); | ||
| 61 | // Listen port for the webserver | ||
| 62 | const HTTP_LISTEN_PORT: u16 = 80; | ||
| 63 | |||
| 64 | pub type SpeSpi = Spi<'static, peripherals::SPI2, peripherals::DMA1_CH1, peripherals::DMA1_CH2>; | ||
| 65 | pub type SpeSpiCs = ExclusiveDevice<SpeSpi, Output<'static, peripherals::PB12>, Delay>; | ||
| 66 | pub type SpeInt = exti::ExtiInput<'static, peripherals::PB11>; | ||
| 67 | pub type SpeRst = Output<'static, peripherals::PC7>; | ||
| 68 | pub type Adin1110T = ADIN1110<SpeSpiCs>; | ||
| 69 | pub type TempSensI2c = I2c<'static, peripherals::I2C3, peripherals::DMA1_CH6, peripherals::DMA1_CH7>; | ||
| 70 | |||
| 71 | static TEMP: AtomicI32 = AtomicI32::new(0); | ||
| 72 | |||
| 73 | #[embassy_executor::main] | ||
| 74 | async fn main(spawner: Spawner) { | ||
| 75 | defmt::println!("Start main()"); | ||
| 76 | |||
| 77 | let mut config = embassy_stm32::Config::default(); | ||
| 78 | |||
| 79 | // 80Mhz clock (Source: 8 / SrcDiv: 1 * PLLMul 20 / ClkDiv 2) | ||
| 80 | // 80MHz highest frequency for flash 0 wait. | ||
| 81 | config.rcc.mux = ClockSrc::PLL( | ||
| 82 | PLLSource::HSE(Hertz(8_000_000)), | ||
| 83 | PLLClkDiv::Div2, | ||
| 84 | PLLSrcDiv::Div1, | ||
| 85 | PLLMul::Mul20, | ||
| 86 | None, | ||
| 87 | ); | ||
| 88 | config.rcc.hsi48 = true; // needed for rng | ||
| 89 | config.rcc.rtc_mux = rcc::RtcClockSource::LSI; | ||
| 90 | |||
| 91 | let dp = embassy_stm32::init(config); | ||
| 92 | |||
| 93 | // RM0432rev9, 5.1.2: Independent I/O supply rail | ||
| 94 | // After reset, the I/Os supplied by VDDIO2 are logically and electrically isolated and | ||
| 95 | // therefore are not available. The isolation must be removed before using any I/O from | ||
| 96 | // PG[15:2], by setting the IOSV bit in the PWR_CR2 register, once the VDDIO2 supply is present | ||
| 97 | pac::PWR.cr2().modify(|w| w.set_iosv(true)); | ||
| 98 | |||
| 99 | let reset_status = pac::RCC.bdcr().read().0; | ||
| 100 | defmt::println!("bdcr before: 0x{:X}", reset_status); | ||
| 101 | |||
| 102 | defmt::println!("Setup IO pins"); | ||
| 103 | |||
| 104 | // Setup LEDs | ||
| 105 | let _led_uc1_green = Output::new(dp.PC13, Level::Low, Speed::Low); | ||
| 106 | let mut led_uc2_red = Output::new(dp.PE2, Level::High, Speed::Low); | ||
| 107 | let led_uc3_yellow = Output::new(dp.PE6, Level::High, Speed::Low); | ||
| 108 | let led_uc4_blue = Output::new(dp.PG15, Level::High, Speed::Low); | ||
| 109 | |||
| 110 | // Read the uc_cfg switches | ||
| 111 | let uc_cfg0 = Input::new(dp.PB2, Pull::None); | ||
| 112 | let uc_cfg1 = Input::new(dp.PF11, Pull::None); | ||
| 113 | let _uc_cfg2 = Input::new(dp.PG6, Pull::None); | ||
| 114 | let _uc_cfg3 = Input::new(dp.PG11, Pull::None); | ||
| 115 | |||
| 116 | // Setup I2C pins | ||
| 117 | let temp_sens_i2c = I2c::new( | ||
| 118 | dp.I2C3, | ||
| 119 | dp.PG7, | ||
| 120 | dp.PG8, | ||
| 121 | Irqs, | ||
| 122 | dp.DMA1_CH6, | ||
| 123 | dp.DMA1_CH7, | ||
| 124 | Hertz(100_000), | ||
| 125 | I2C_Config::default(), | ||
| 126 | ); | ||
| 127 | |||
| 128 | // Setup IO and SPI for the SPE chip | ||
| 129 | let spe_reset_n = Output::new(dp.PC7, Level::Low, Speed::Low); | ||
| 130 | let spe_cfg0 = Input::new(dp.PC8, Pull::None); | ||
| 131 | let spe_cfg1 = Input::new(dp.PC9, Pull::None); | ||
| 132 | let _spe_ts_capt = Output::new(dp.PC6, Level::Low, Speed::Low); | ||
| 133 | |||
| 134 | let spe_int = Input::new(dp.PB11, Pull::None); | ||
| 135 | let spe_int = exti::ExtiInput::new(spe_int, dp.EXTI11); | ||
| 136 | |||
| 137 | let spe_spi_cs_n = Output::new(dp.PB12, Level::High, Speed::High); | ||
| 138 | let spe_spi_sclk = dp.PB13; | ||
| 139 | let spe_spi_miso = dp.PB14; | ||
| 140 | let spe_spi_mosi = dp.PB15; | ||
| 141 | |||
| 142 | // Don't turn the clock to high, clock must fit within the system clock as we get a runtime panic. | ||
| 143 | let mut spi_config = SPI_Config::default(); | ||
| 144 | spi_config.frequency = Hertz(25_000_000); | ||
| 145 | |||
| 146 | let spe_spi: SpeSpi = Spi::new( | ||
| 147 | dp.SPI2, | ||
| 148 | spe_spi_sclk, | ||
| 149 | spe_spi_mosi, | ||
| 150 | spe_spi_miso, | ||
| 151 | dp.DMA1_CH1, | ||
| 152 | dp.DMA1_CH2, | ||
| 153 | spi_config, | ||
| 154 | ); | ||
| 155 | let spe_spi = SpeSpiCs::new(spe_spi, spe_spi_cs_n, Delay); | ||
| 156 | |||
| 157 | let cfg0_without_crc = spe_cfg0.is_high(); | ||
| 158 | let cfg1_spi_mode = spe_cfg1.is_high(); | ||
| 159 | let uc_cfg1_fcs_en = uc_cfg1.is_low(); | ||
| 160 | |||
| 161 | defmt::println!( | ||
| 162 | "ADIN1110: CFG SPI-MODE 1-{}, CRC-bit 0-{} FCS-{}", | ||
| 163 | cfg1_spi_mode, | ||
| 164 | cfg0_without_crc, | ||
| 165 | uc_cfg1_fcs_en | ||
| 166 | ); | ||
| 167 | |||
| 168 | // Check the SPI mode selected with the "HW CFG" dip-switch | ||
| 169 | if !cfg1_spi_mode { | ||
| 170 | error!("Driver doesn´t support SPI Protolcol \"OPEN Alliance\".\nplease use the \"Generic SPI\"! Turn On \"HW CFG\": \"SPI_CFG1\""); | ||
| 171 | loop { | ||
| 172 | led_uc2_red.toggle(); | ||
| 173 | Timer::after(Duration::from_hz(10)).await; | ||
| 174 | } | ||
| 175 | }; | ||
| 176 | |||
| 177 | let state = make_static!(embassy_net_adin1110::State::<8, 8>::new()); | ||
| 178 | |||
| 179 | let (device, runner) = embassy_net_adin1110::new( | ||
| 180 | MAC, | ||
| 181 | state, | ||
| 182 | spe_spi, | ||
| 183 | spe_int, | ||
| 184 | spe_reset_n, | ||
| 185 | !cfg0_without_crc, | ||
| 186 | uc_cfg1_fcs_en, | ||
| 187 | ) | ||
| 188 | .await; | ||
| 189 | |||
| 190 | // Start task blink_led | ||
| 191 | unwrap!(spawner.spawn(heartbeat_led(led_uc3_yellow))); | ||
| 192 | // Start task temperature measurement | ||
| 193 | unwrap!(spawner.spawn(temp_task(temp_sens_i2c, led_uc4_blue))); | ||
| 194 | // Start ethernet task | ||
| 195 | unwrap!(spawner.spawn(ethernet_task(runner))); | ||
| 196 | |||
| 197 | let mut rng = Rng::new(dp.RNG, Irqs); | ||
| 198 | // Generate random seed | ||
| 199 | let seed = rng.next_u64(); | ||
| 200 | |||
| 201 | let ip_cfg = if uc_cfg0.is_low() { | ||
| 202 | println!("Waiting for DHCP..."); | ||
| 203 | let dhcp4_config = embassy_net::DhcpConfig::default(); | ||
| 204 | embassy_net::Config::dhcpv4(dhcp4_config) | ||
| 205 | } else { | ||
| 206 | embassy_net::Config::ipv4_static(StaticConfigV4 { | ||
| 207 | address: IP_ADDRESS, | ||
| 208 | gateway: None, | ||
| 209 | dns_servers: Vec::new(), | ||
| 210 | }) | ||
| 211 | }; | ||
| 212 | |||
| 213 | // Init network stack | ||
| 214 | let stack = &*make_static!(Stack::new( | ||
| 215 | device, | ||
| 216 | ip_cfg, | ||
| 217 | make_static!(StackResources::<2>::new()), | ||
| 218 | seed | ||
| 219 | )); | ||
| 220 | |||
| 221 | // Launch network task | ||
| 222 | unwrap!(spawner.spawn(net_task(stack))); | ||
| 223 | |||
| 224 | let cfg = wait_for_config(stack).await; | ||
| 225 | let local_addr = cfg.address.address(); | ||
| 226 | |||
| 227 | // Then we can use it! | ||
| 228 | let mut rx_buffer = [0; 4096]; | ||
| 229 | let mut tx_buffer = [0; 4096]; | ||
| 230 | let mut mb_buf = [0; 4096]; | ||
| 231 | loop { | ||
| 232 | let mut socket = TcpSocket::new(stack, &mut rx_buffer, &mut tx_buffer); | ||
| 233 | socket.set_timeout(Some(Duration::from_secs(1))); | ||
| 234 | |||
| 235 | info!("Listening on http://{}:{}...", local_addr, HTTP_LISTEN_PORT); | ||
| 236 | if let Err(e) = socket.accept(HTTP_LISTEN_PORT).await { | ||
| 237 | defmt::error!("accept error: {:?}", e); | ||
| 238 | continue; | ||
| 239 | } | ||
| 240 | |||
| 241 | loop { | ||
| 242 | let _n = match socket.read(&mut mb_buf).await { | ||
| 243 | Ok(0) => { | ||
| 244 | defmt::info!("read EOF"); | ||
| 245 | break; | ||
| 246 | } | ||
| 247 | Ok(n) => n, | ||
| 248 | Err(e) => { | ||
| 249 | defmt::error!("{:?}", e); | ||
| 250 | break; | ||
| 251 | } | ||
| 252 | }; | ||
| 253 | led_uc2_red.set_low(); | ||
| 254 | |||
| 255 | let status_line = "HTTP/1.1 200 OK"; | ||
| 256 | let contents = PAGE; | ||
| 257 | let length = contents.len(); | ||
| 258 | |||
| 259 | let _ = write!( | ||
| 260 | &mut mb_buf[..], | ||
| 261 | "{status_line}\r\nContent-Length: {length}\r\n\r\n{contents}\r\n\0" | ||
| 262 | ); | ||
| 263 | let loc = mb_buf.iter().position(|v| *v == b'#').unwrap(); | ||
| 264 | |||
| 265 | let temp = TEMP.load(Ordering::Relaxed); | ||
| 266 | let cel = temp / 1000; | ||
| 267 | let mcel = temp % 1000; | ||
| 268 | |||
| 269 | info!("{}.{}", cel, mcel); | ||
| 270 | |||
| 271 | let _ = write!(&mut mb_buf[loc..loc + 7], "{cel}.{mcel}"); | ||
| 272 | |||
| 273 | let n = mb_buf.iter().position(|v| *v == 0).unwrap(); | ||
| 274 | |||
| 275 | if let Err(e) = socket.write_all(&mb_buf[..n]).await { | ||
| 276 | error!("write error: {:?}", e); | ||
| 277 | break; | ||
| 278 | } | ||
| 279 | |||
| 280 | led_uc2_red.set_high(); | ||
| 281 | } | ||
| 282 | } | ||
| 283 | } | ||
| 284 | |||
| 285 | async fn wait_for_config(stack: &'static Stack<Device<'static>>) -> embassy_net::StaticConfigV4 { | ||
| 286 | loop { | ||
| 287 | if let Some(config) = stack.config_v4() { | ||
| 288 | return config; | ||
| 289 | } | ||
| 290 | yield_now().await; | ||
| 291 | } | ||
| 292 | } | ||
| 293 | |||
| 294 | #[embassy_executor::task] | ||
| 295 | async fn heartbeat_led(mut led: Output<'static, peripherals::PE6>) { | ||
| 296 | let mut tmr = Ticker::every(Duration::from_hz(3)); | ||
| 297 | loop { | ||
| 298 | led.toggle(); | ||
| 299 | tmr.next().await; | ||
| 300 | } | ||
| 301 | } | ||
| 302 | |||
| 303 | // ADT7422 | ||
| 304 | #[embassy_executor::task] | ||
| 305 | async fn temp_task(temp_dev_i2c: TempSensI2c, mut led: Output<'static, peripherals::PG15>) -> ! { | ||
| 306 | let mut tmr = Ticker::every(Duration::from_hz(1)); | ||
| 307 | let mut temp_sens = ADT7422::new(temp_dev_i2c, 0x48).unwrap(); | ||
| 308 | |||
| 309 | loop { | ||
| 310 | led.set_low(); | ||
| 311 | match select(temp_sens.read_temp(), Timer::after(Duration::from_millis(500))).await { | ||
| 312 | Either::First(i2c_ret) => match i2c_ret { | ||
| 313 | Ok(value) => { | ||
| 314 | led.set_high(); | ||
| 315 | let temp = i32::from(value); | ||
| 316 | println!("TEMP: {:04x}, {}", temp, temp * 78 / 10); | ||
| 317 | TEMP.store(temp * 78 / 10, Ordering::Relaxed); | ||
| 318 | } | ||
| 319 | Err(e) => defmt::println!("ADT7422: {}", e), | ||
| 320 | }, | ||
| 321 | Either::Second(_) => println!("Timeout"), | ||
| 322 | } | ||
| 323 | |||
| 324 | tmr.next().await; | ||
| 325 | } | ||
| 326 | } | ||
| 327 | |||
| 328 | #[embassy_executor::task] | ||
| 329 | async fn ethernet_task(runner: Runner<'static, SpeSpiCs, SpeInt, SpeRst>) -> ! { | ||
| 330 | runner.run().await | ||
| 331 | } | ||
| 332 | |||
| 333 | #[embassy_executor::task] | ||
| 334 | async fn net_task(stack: &'static Stack<Device<'static>>) -> ! { | ||
| 335 | stack.run().await | ||
| 336 | } | ||
| 337 | |||
| 338 | // same panicking *behavior* as `panic-probe` but doesn't print a panic message | ||
| 339 | // this prevents the panic message being printed *twice* when `defmt::panic` is invoked | ||
| 340 | #[defmt::panic_handler] | ||
| 341 | fn panic() -> ! { | ||
| 342 | cortex_m::asm::udf() | ||
| 343 | } | ||
| 344 | |||
| 345 | #[allow(non_camel_case_types)] | ||
| 346 | #[repr(C)] | ||
| 347 | pub enum Registers { | ||
| 348 | Temp_MSB = 0x00, | ||
| 349 | Temp_LSB, | ||
| 350 | Status, | ||
| 351 | Cfg, | ||
| 352 | T_HIGH_MSB, | ||
| 353 | T_HIGH_LSB, | ||
| 354 | T_LOW_MSB, | ||
| 355 | T_LOW_LSB, | ||
| 356 | T_CRIT_MSB, | ||
| 357 | T_CRIT_LSB, | ||
| 358 | T_HYST, | ||
| 359 | ID, | ||
| 360 | SW_RESET = 0x2F, | ||
| 361 | } | ||
| 362 | |||
| 363 | pub struct ADT7422<'d, BUS: I2cBus> { | ||
| 364 | addr: u8, | ||
| 365 | phantom: PhantomData<&'d ()>, | ||
| 366 | bus: BUS, | ||
| 367 | } | ||
| 368 | |||
| 369 | #[derive(Debug, Format)] | ||
| 370 | pub enum Error<I2cError: Format> { | ||
| 371 | I2c(I2cError), | ||
| 372 | Address, | ||
| 373 | } | ||
| 374 | |||
| 375 | impl<'d, BUS> ADT7422<'d, BUS> | ||
| 376 | where | ||
| 377 | BUS: I2cBus, | ||
| 378 | BUS::Error: Format, | ||
| 379 | { | ||
| 380 | pub fn new(bus: BUS, addr: u8) -> Result<Self, Error<BUS::Error>> { | ||
| 381 | if !(0x48..=0x4A).contains(&addr) { | ||
| 382 | return Err(Error::Address); | ||
| 383 | } | ||
| 384 | |||
| 385 | Ok(Self { | ||
| 386 | bus, | ||
| 387 | phantom: PhantomData, | ||
| 388 | addr, | ||
| 389 | }) | ||
| 390 | } | ||
| 391 | |||
| 392 | pub async fn init(&mut self) -> Result<(), Error<BUS::Error>> { | ||
| 393 | let mut cfg = 0b000_0000; | ||
| 394 | // if self.int.is_some() { | ||
| 395 | // // Set 1 SPS mode | ||
| 396 | // cfg |= 0b10 << 5; | ||
| 397 | // } else { | ||
| 398 | // One shot mode | ||
| 399 | cfg |= 0b01 << 5; | ||
| 400 | // } | ||
| 401 | |||
| 402 | self.write_cfg(cfg).await | ||
| 403 | } | ||
| 404 | |||
| 405 | pub async fn read(&mut self, reg: Registers) -> Result<u8, Error<BUS::Error>> { | ||
| 406 | let mut buffer = [0u8; 1]; | ||
| 407 | self.bus | ||
| 408 | .write_read(self.addr, &[reg as u8], &mut buffer) | ||
| 409 | .await | ||
| 410 | .map_err(Error::I2c)?; | ||
| 411 | Ok(buffer[0]) | ||
| 412 | } | ||
| 413 | |||
| 414 | pub async fn write_cfg(&mut self, cfg: u8) -> Result<(), Error<BUS::Error>> { | ||
| 415 | let buf = [Registers::Cfg as u8, cfg]; | ||
| 416 | self.bus.write(self.addr, &buf).await.map_err(Error::I2c) | ||
| 417 | } | ||
| 418 | |||
| 419 | pub async fn read_temp(&mut self) -> Result<i16, Error<BUS::Error>> { | ||
| 420 | let mut buffer = [0u8; 2]; | ||
| 421 | |||
| 422 | // if let Some(int) = &mut self.int { | ||
| 423 | // // Wait for interrupt | ||
| 424 | // int.wait_for_low().await.unwrap(); | ||
| 425 | // } else { | ||
| 426 | // Start: One shot | ||
| 427 | let cfg = 0b01 << 5; | ||
| 428 | self.write_cfg(cfg).await?; | ||
| 429 | Timer::after(Duration::from_millis(250)).await; | ||
| 430 | self.bus | ||
| 431 | .write_read(self.addr, &[Registers::Temp_MSB as u8], &mut buffer) | ||
| 432 | .await | ||
| 433 | .map_err(Error::I2c)?; | ||
| 434 | Ok(i16::from_be_bytes(buffer)) | ||
| 435 | } | ||
| 436 | } | ||
| 437 | |||
| 438 | // Web page | ||
| 439 | const PAGE: &str = r#"<!DOCTYPE html> | ||
| 440 | <html lang="en"> | ||
| 441 | <head> | ||
| 442 | <meta charset="utf-8"> | ||
| 443 | <meta http-equiv="refresh" content="1" > | ||
| 444 | <title>ADIN1110 with Rust</title> | ||
| 445 | </head> | ||
| 446 | <body> | ||
| 447 | <p>EVAL-ADIN1110EBZ</p> | ||
| 448 | <table><td>Temp Sensor ADT7422:</td><td> #00.00 °C</td></table> | ||
| 449 | </body> | ||
| 450 | </html>"#; | ||
diff --git a/examples/stm32l4/src/bin/usart.rs b/examples/stm32l4/src/bin/usart.rs index beb5ec558..f4da6b5ae 100644 --- a/examples/stm32l4/src/bin/usart.rs +++ b/examples/stm32l4/src/bin/usart.rs | |||
| @@ -19,7 +19,7 @@ fn main() -> ! { | |||
| 19 | let p = embassy_stm32::init(Default::default()); | 19 | let p = embassy_stm32::init(Default::default()); |
| 20 | 20 | ||
| 21 | let config = Config::default(); | 21 | let config = Config::default(); |
| 22 | let mut usart = Uart::new(p.UART4, p.PA1, p.PA0, Irqs, NoDma, NoDma, config); | 22 | let mut usart = Uart::new(p.UART4, p.PA1, p.PA0, Irqs, NoDma, NoDma, config).unwrap(); |
| 23 | 23 | ||
| 24 | unwrap!(usart.blocking_write(b"Hello Embassy World!\r\n")); | 24 | unwrap!(usart.blocking_write(b"Hello Embassy World!\r\n")); |
| 25 | info!("wrote Hello, starting echo"); | 25 | info!("wrote Hello, starting echo"); |
diff --git a/examples/stm32l4/src/bin/usart_dma.rs b/examples/stm32l4/src/bin/usart_dma.rs index b7d4cb01e..2f3b2a0f0 100644 --- a/examples/stm32l4/src/bin/usart_dma.rs +++ b/examples/stm32l4/src/bin/usart_dma.rs | |||
| @@ -22,7 +22,7 @@ async fn main(_spawner: Spawner) { | |||
| 22 | info!("Hello World!"); | 22 | info!("Hello World!"); |
| 23 | 23 | ||
| 24 | let config = Config::default(); | 24 | let config = Config::default(); |
| 25 | let mut usart = Uart::new(p.UART4, p.PA1, p.PA0, Irqs, p.DMA1_CH3, NoDma, config); | 25 | let mut usart = Uart::new(p.UART4, p.PA1, p.PA0, Irqs, p.DMA1_CH3, NoDma, config).unwrap(); |
| 26 | 26 | ||
| 27 | for n in 0u32.. { | 27 | for n in 0u32.. { |
| 28 | let mut s: String<128> = String::new(); | 28 | let mut s: String<128> = String::new(); |
diff --git a/examples/stm32l5/Cargo.toml b/examples/stm32l5/Cargo.toml index b46c25701..583e1a776 100644 --- a/examples/stm32l5/Cargo.toml +++ b/examples/stm32l5/Cargo.toml | |||
| @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" | |||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | # Change stm32l552ze to your chip name, if necessary. | 8 | # Change stm32l552ze to your chip name, if necessary. |
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l552ze", "time-driver-any", "exti", "unstable-traits", "memory-x"] } | 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32l552ze", "time-driver-any", "exti", "unstable-traits", "memory-x"] } |
| 10 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 12 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 12 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 13 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } | 13 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } |
| 14 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet"] } | 14 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "dhcpv4", "medium-ethernet"] } |
| 15 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | 15 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } |
diff --git a/examples/stm32u5/Cargo.toml b/examples/stm32u5/Cargo.toml index f928e7a6c..e361856c5 100644 --- a/examples/stm32u5/Cargo.toml +++ b/examples/stm32u5/Cargo.toml | |||
| @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0" | |||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | # Change stm32u585ai to your chip name, if necessary. | 8 | # Change stm32u585ai to your chip name, if necessary. |
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32u585ai", "time-driver-any", "memory-x" ] } | 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "stm32u585ai", "time-driver-any", "memory-x" ] } |
| 10 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 12 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 12 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 13 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } | 13 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] } |
| 14 | 14 | ||
| 15 | defmt = "0.3" | 15 | defmt = "0.3" |
diff --git a/examples/stm32wb/Cargo.toml b/examples/stm32wb/Cargo.toml index f58a5189e..320678ddc 100644 --- a/examples/stm32wb/Cargo.toml +++ b/examples/stm32wb/Cargo.toml | |||
| @@ -8,10 +8,10 @@ license = "MIT OR Apache-2.0" | |||
| 8 | # Change stm32wb55rg to your chip name in both dependencies, if necessary. | 8 | # Change stm32wb55rg to your chip name in both dependencies, if necessary. |
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wb55rg", "time-driver-any", "memory-x", "exti"] } | 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wb55rg", "time-driver-any", "memory-x", "exti"] } |
| 10 | embassy-stm32-wpan = { version = "0.1.0", path = "../../embassy-stm32-wpan", features = ["defmt", "stm32wb55rg"] } | 10 | embassy-stm32-wpan = { version = "0.1.0", path = "../../embassy-stm32-wpan", features = ["defmt", "stm32wb55rg"] } |
| 11 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 11 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } |
| 12 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 12 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 13 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 13 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 14 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "udp", "medium-ieee802154", "nightly"], optional=true } | 14 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "udp", "proto-ipv6", "medium-ieee802154", "nightly"], optional=true } |
| 15 | 15 | ||
| 16 | defmt = "0.3" | 16 | defmt = "0.3" |
| 17 | defmt-rtt = "0.4" | 17 | defmt-rtt = "0.4" |
diff --git a/examples/stm32wb/src/bin/eddystone_beacon.rs b/examples/stm32wb/src/bin/eddystone_beacon.rs index ea150c67e..e58da8e35 100644 --- a/examples/stm32wb/src/bin/eddystone_beacon.rs +++ b/examples/stm32wb/src/bin/eddystone_beacon.rs | |||
| @@ -36,7 +36,7 @@ async fn main(_spawner: Spawner) { | |||
| 36 | 36 | ||
| 37 | - Obtain a NUCLEO-STM32WB55 from your preferred supplier. | 37 | - Obtain a NUCLEO-STM32WB55 from your preferred supplier. |
| 38 | - Download and Install STM32CubeProgrammer. | 38 | - Download and Install STM32CubeProgrammer. |
| 39 | - Download stm32wb5x_FUS_fw.bin, stm32wb5x_BLE_Stack_full_fw.bin, and Release_Notes.html from | 39 | - Download stm32wb5x_FUS_fw.bin, stm32wb5x_BLE_Mac_802_15_4_fw.bin, and Release_Notes.html from |
| 40 | gh:STMicroelectronics/STM32CubeWB@2234d97/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x | 40 | gh:STMicroelectronics/STM32CubeWB@2234d97/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x |
| 41 | - Open STM32CubeProgrammer | 41 | - Open STM32CubeProgrammer |
| 42 | - On the right-hand pane, click "firmware upgrade" to upgrade the st-link firmware. | 42 | - On the right-hand pane, click "firmware upgrade" to upgrade the st-link firmware. |
| @@ -45,7 +45,7 @@ async fn main(_spawner: Spawner) { | |||
| 45 | - In the Release_Notes.html, find the memory address that corresponds to your device for the stm32wb5x_FUS_fw.bin file | 45 | - In the Release_Notes.html, find the memory address that corresponds to your device for the stm32wb5x_FUS_fw.bin file |
| 46 | - Select that file, the memory address, "verify download", and then "Firmware Upgrade". | 46 | - Select that file, the memory address, "verify download", and then "Firmware Upgrade". |
| 47 | - Once complete, in the Release_Notes.html, find the memory address that corresponds to your device for the | 47 | - Once complete, in the Release_Notes.html, find the memory address that corresponds to your device for the |
| 48 | stm32wb5x_BLE_Stack_full_fw.bin file. It should not be the same memory address. | 48 | stm32wb5x_BLE_Mac_802_15_4_fw.bin file. It should not be the same memory address. |
| 49 | - Select that file, the memory address, "verify download", and then "Firmware Upgrade". | 49 | - Select that file, the memory address, "verify download", and then "Firmware Upgrade". |
| 50 | - Select "Start Wireless Stack". | 50 | - Select "Start Wireless Stack". |
| 51 | - Disconnect from the device. | 51 | - Disconnect from the device. |
diff --git a/examples/stm32wb/src/bin/gatt_server.rs b/examples/stm32wb/src/bin/gatt_server.rs index dd67249c7..80e835c1d 100644 --- a/examples/stm32wb/src/bin/gatt_server.rs +++ b/examples/stm32wb/src/bin/gatt_server.rs | |||
| @@ -44,7 +44,7 @@ async fn main(_spawner: Spawner) { | |||
| 44 | 44 | ||
| 45 | - Obtain a NUCLEO-STM32WB55 from your preferred supplier. | 45 | - Obtain a NUCLEO-STM32WB55 from your preferred supplier. |
| 46 | - Download and Install STM32CubeProgrammer. | 46 | - Download and Install STM32CubeProgrammer. |
| 47 | - Download stm32wb5x_FUS_fw.bin, stm32wb5x_BLE_Stack_full_fw.bin, and Release_Notes.html from | 47 | - Download stm32wb5x_FUS_fw.bin, stm32wb5x_BLE_Mac_802_15_4_fw.bin, and Release_Notes.html from |
| 48 | gh:STMicroelectronics/STM32CubeWB@2234d97/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x | 48 | gh:STMicroelectronics/STM32CubeWB@2234d97/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x |
| 49 | - Open STM32CubeProgrammer | 49 | - Open STM32CubeProgrammer |
| 50 | - On the right-hand pane, click "firmware upgrade" to upgrade the st-link firmware. | 50 | - On the right-hand pane, click "firmware upgrade" to upgrade the st-link firmware. |
| @@ -53,7 +53,7 @@ async fn main(_spawner: Spawner) { | |||
| 53 | - In the Release_Notes.html, find the memory address that corresponds to your device for the stm32wb5x_FUS_fw.bin file | 53 | - In the Release_Notes.html, find the memory address that corresponds to your device for the stm32wb5x_FUS_fw.bin file |
| 54 | - Select that file, the memory address, "verify download", and then "Firmware Upgrade". | 54 | - Select that file, the memory address, "verify download", and then "Firmware Upgrade". |
| 55 | - Once complete, in the Release_Notes.html, find the memory address that corresponds to your device for the | 55 | - Once complete, in the Release_Notes.html, find the memory address that corresponds to your device for the |
| 56 | stm32wb5x_BLE_Stack_full_fw.bin file. It should not be the same memory address. | 56 | stm32wb5x_BLE_Mac_802_15_4_fw.bin file. It should not be the same memory address. |
| 57 | - Select that file, the memory address, "verify download", and then "Firmware Upgrade". | 57 | - Select that file, the memory address, "verify download", and then "Firmware Upgrade". |
| 58 | - Select "Start Wireless Stack". | 58 | - Select "Start Wireless Stack". |
| 59 | - Disconnect from the device. | 59 | - Disconnect from the device. |
diff --git a/examples/stm32wb/src/bin/tl_mbox.rs b/examples/stm32wb/src/bin/tl_mbox.rs index fc49c3c4a..2f53f5df8 100644 --- a/examples/stm32wb/src/bin/tl_mbox.rs +++ b/examples/stm32wb/src/bin/tl_mbox.rs | |||
| @@ -23,7 +23,7 @@ async fn main(_spawner: Spawner) { | |||
| 23 | 23 | ||
| 24 | - Obtain a NUCLEO-STM32WB55 from your preferred supplier. | 24 | - Obtain a NUCLEO-STM32WB55 from your preferred supplier. |
| 25 | - Download and Install STM32CubeProgrammer. | 25 | - Download and Install STM32CubeProgrammer. |
| 26 | - Download stm32wb5x_FUS_fw.bin, stm32wb5x_BLE_Stack_full_fw.bin, and Release_Notes.html from | 26 | - Download stm32wb5x_FUS_fw.bin, stm32wb5x_BLE_Mac_802_15_4_fw.bin, and Release_Notes.html from |
| 27 | gh:STMicroelectronics/STM32CubeWB@2234d97/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x | 27 | gh:STMicroelectronics/STM32CubeWB@2234d97/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x |
| 28 | - Open STM32CubeProgrammer | 28 | - Open STM32CubeProgrammer |
| 29 | - On the right-hand pane, click "firmware upgrade" to upgrade the st-link firmware. | 29 | - On the right-hand pane, click "firmware upgrade" to upgrade the st-link firmware. |
| @@ -32,7 +32,7 @@ async fn main(_spawner: Spawner) { | |||
| 32 | - In the Release_Notes.html, find the memory address that corresponds to your device for the stm32wb5x_FUS_fw.bin file | 32 | - In the Release_Notes.html, find the memory address that corresponds to your device for the stm32wb5x_FUS_fw.bin file |
| 33 | - Select that file, the memory address, "verify download", and then "Firmware Upgrade". | 33 | - Select that file, the memory address, "verify download", and then "Firmware Upgrade". |
| 34 | - Once complete, in the Release_Notes.html, find the memory address that corresponds to your device for the | 34 | - Once complete, in the Release_Notes.html, find the memory address that corresponds to your device for the |
| 35 | stm32wb5x_BLE_Stack_full_fw.bin file. It should not be the same memory address. | 35 | stm32wb5x_BLE_Mac_802_15_4_fw.bin file. It should not be the same memory address. |
| 36 | - Select that file, the memory address, "verify download", and then "Firmware Upgrade". | 36 | - Select that file, the memory address, "verify download", and then "Firmware Upgrade". |
| 37 | - Select "Start Wireless Stack". | 37 | - Select "Start Wireless Stack". |
| 38 | - Disconnect from the device. | 38 | - Disconnect from the device. |
diff --git a/examples/stm32wb/src/bin/tl_mbox_ble.rs b/examples/stm32wb/src/bin/tl_mbox_ble.rs index 5745ebd02..12c6aeebb 100644 --- a/examples/stm32wb/src/bin/tl_mbox_ble.rs +++ b/examples/stm32wb/src/bin/tl_mbox_ble.rs | |||
| @@ -22,7 +22,7 @@ async fn main(_spawner: Spawner) { | |||
| 22 | 22 | ||
| 23 | - Obtain a NUCLEO-STM32WB55 from your preferred supplier. | 23 | - Obtain a NUCLEO-STM32WB55 from your preferred supplier. |
| 24 | - Download and Install STM32CubeProgrammer. | 24 | - Download and Install STM32CubeProgrammer. |
| 25 | - Download stm32wb5x_FUS_fw.bin, stm32wb5x_BLE_Stack_full_fw.bin, and Release_Notes.html from | 25 | - Download stm32wb5x_FUS_fw.bin, stm32wb5x_BLE_Mac_802_15_4_fw.bin, and Release_Notes.html from |
| 26 | gh:STMicroelectronics/STM32CubeWB@2234d97/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x | 26 | gh:STMicroelectronics/STM32CubeWB@2234d97/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x |
| 27 | - Open STM32CubeProgrammer | 27 | - Open STM32CubeProgrammer |
| 28 | - On the right-hand pane, click "firmware upgrade" to upgrade the st-link firmware. | 28 | - On the right-hand pane, click "firmware upgrade" to upgrade the st-link firmware. |
| @@ -31,7 +31,7 @@ async fn main(_spawner: Spawner) { | |||
| 31 | - In the Release_Notes.html, find the memory address that corresponds to your device for the stm32wb5x_FUS_fw.bin file | 31 | - In the Release_Notes.html, find the memory address that corresponds to your device for the stm32wb5x_FUS_fw.bin file |
| 32 | - Select that file, the memory address, "verify download", and then "Firmware Upgrade". | 32 | - Select that file, the memory address, "verify download", and then "Firmware Upgrade". |
| 33 | - Once complete, in the Release_Notes.html, find the memory address that corresponds to your device for the | 33 | - Once complete, in the Release_Notes.html, find the memory address that corresponds to your device for the |
| 34 | stm32wb5x_BLE_Stack_full_fw.bin file. It should not be the same memory address. | 34 | stm32wb5x_BLE_Mac_802_15_4_fw.bin file. It should not be the same memory address. |
| 35 | - Select that file, the memory address, "verify download", and then "Firmware Upgrade". | 35 | - Select that file, the memory address, "verify download", and then "Firmware Upgrade". |
| 36 | - Select "Start Wireless Stack". | 36 | - Select "Start Wireless Stack". |
| 37 | - Disconnect from the device. | 37 | - Disconnect from the device. |
diff --git a/examples/stm32wba/.cargo/config.toml b/examples/stm32wba/.cargo/config.toml new file mode 100644 index 000000000..477413397 --- /dev/null +++ b/examples/stm32wba/.cargo/config.toml | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] | ||
| 2 | runner = "probe-rs run --chip STM32WBA52CGUxT" | ||
| 3 | |||
| 4 | [build] | ||
| 5 | target = "thumbv8m.main-none-eabihf" | ||
| 6 | |||
| 7 | [env] | ||
| 8 | DEFMT_LOG = "trace" | ||
diff --git a/examples/stm32wba/Cargo.toml b/examples/stm32wba/Cargo.toml new file mode 100644 index 000000000..26fcce26b --- /dev/null +++ b/examples/stm32wba/Cargo.toml | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | [package] | ||
| 2 | edition = "2021" | ||
| 3 | name = "embassy-stm32wba-examples" | ||
| 4 | version = "0.1.0" | ||
| 5 | license = "MIT OR Apache-2.0" | ||
| 6 | |||
| 7 | [dependencies] | ||
| 8 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wba52cg", "time-driver-any", "memory-x", "exti"] } | ||
| 9 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } | ||
| 10 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | ||
| 11 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | ||
| 12 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "udp", "proto-ipv6", "medium-ieee802154", "nightly"], optional=true } | ||
| 13 | |||
| 14 | defmt = "0.3" | ||
| 15 | defmt-rtt = "0.4" | ||
| 16 | |||
| 17 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } | ||
| 18 | cortex-m-rt = "0.7.0" | ||
| 19 | embedded-hal = "0.2.6" | ||
| 20 | panic-probe = { version = "0.3", features = ["print-defmt"] } | ||
| 21 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | ||
| 22 | heapless = { version = "0.7.5", default-features = false } | ||
| 23 | static_cell = { version = "1.1", features = ["nightly"]} | ||
| 24 | |||
| 25 | [profile.release] | ||
| 26 | debug = 2 | ||
diff --git a/examples/stm32wba/build.rs b/examples/stm32wba/build.rs new file mode 100644 index 000000000..8fc6faab8 --- /dev/null +++ b/examples/stm32wba/build.rs | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | use std::error::Error; | ||
| 2 | |||
| 3 | fn main() -> Result<(), Box<dyn Error>> { | ||
| 4 | println!("cargo:rerun-if-changed=link.x"); | ||
| 5 | println!("cargo:rustc-link-arg-bins=--nmagic"); | ||
| 6 | println!("cargo:rustc-link-arg-bins=-Tlink.x"); | ||
| 7 | println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); | ||
| 8 | |||
| 9 | Ok(()) | ||
| 10 | } | ||
diff --git a/examples/stm32wba/src/bin/blinky.rs b/examples/stm32wba/src/bin/blinky.rs new file mode 100644 index 000000000..530746296 --- /dev/null +++ b/examples/stm32wba/src/bin/blinky.rs | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt::*; | ||
| 6 | use embassy_executor::Spawner; | ||
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | ||
| 8 | use embassy_time::{Duration, Timer}; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | ||
| 10 | |||
| 11 | #[embassy_executor::main] | ||
| 12 | async fn main(_spawner: Spawner) { | ||
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | ||
| 15 | |||
| 16 | let mut led = Output::new(p.PB4, Level::High, Speed::Low); | ||
| 17 | |||
| 18 | loop { | ||
| 19 | info!("high"); | ||
| 20 | led.set_high(); | ||
| 21 | Timer::after(Duration::from_millis(500)).await; | ||
| 22 | |||
| 23 | info!("low"); | ||
| 24 | led.set_low(); | ||
| 25 | Timer::after(Duration::from_millis(500)).await; | ||
| 26 | } | ||
| 27 | } | ||
diff --git a/examples/stm32wba/src/bin/button_exti.rs b/examples/stm32wba/src/bin/button_exti.rs new file mode 100644 index 000000000..ef32d4c4a --- /dev/null +++ b/examples/stm32wba/src/bin/button_exti.rs | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt::*; | ||
| 6 | use embassy_executor::Spawner; | ||
| 7 | use embassy_stm32::exti::ExtiInput; | ||
| 8 | use embassy_stm32::gpio::{Input, Pull}; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | ||
| 10 | |||
| 11 | #[embassy_executor::main] | ||
| 12 | async fn main(_spawner: Spawner) { | ||
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | ||
| 15 | |||
| 16 | let button = Input::new(p.PC13, Pull::Up); | ||
| 17 | let mut button = ExtiInput::new(button, p.EXTI13); | ||
| 18 | |||
| 19 | info!("Press the USER button..."); | ||
| 20 | |||
| 21 | loop { | ||
| 22 | button.wait_for_falling_edge().await; | ||
| 23 | info!("Pressed!"); | ||
| 24 | button.wait_for_rising_edge().await; | ||
| 25 | info!("Released!"); | ||
| 26 | } | ||
| 27 | } | ||
diff --git a/examples/stm32wl/Cargo.toml b/examples/stm32wl/Cargo.toml index 1c771ddce..f47a9a906 100644 --- a/examples/stm32wl/Cargo.toml +++ b/examples/stm32wl/Cargo.toml | |||
| @@ -7,14 +7,14 @@ license = "MIT OR Apache-2.0" | |||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | # Change stm32wl55jc-cm4 to your chip name, if necessary. | 8 | # Change stm32wl55jc-cm4 to your chip name, if necessary. |
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32wl55jc-cm4", "time-driver-any", "memory-x", "unstable-pac", "exti", "chrono"] } | 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32wl55jc-cm4", "time-driver-any", "memory-x", "unstable-pac", "exti", "chrono"] } |
| 10 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 11 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 12 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 12 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["nightly", "unstable-traits", "defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } | 13 | embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } |
| 14 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["stm32wl", "time", "defmt"] } | 14 | embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["stm32wl", "time", "defmt"] } |
| 15 | lora-phy = { version = "1" } | 15 | lora-phy = { version = "2" } |
| 16 | lorawan-device = { version = "0.10.0", default-features = false, features = ["async", "external-lora-phy"] } | 16 | lorawan-device = { version = "0.11.0", default-features = false, features = ["async", "external-lora-phy"] } |
| 17 | lorawan = { version = "0.7.3", default-features = false, features = ["default-crypto"] } | 17 | lorawan = { version = "0.7.4", default-features = false, features = ["default-crypto"] } |
| 18 | 18 | ||
| 19 | defmt = "0.3" | 19 | defmt = "0.3" |
| 20 | defmt-rtt = "0.4" | 20 | defmt-rtt = "0.4" |
| @@ -30,6 +30,3 @@ chrono = { version = "^0.4", default-features = false } | |||
| 30 | 30 | ||
| 31 | [profile.release] | 31 | [profile.release] |
| 32 | debug = 2 | 32 | debug = 2 |
| 33 | |||
| 34 | [patch.crates-io] | ||
| 35 | lora-phy = { git = "https://github.com/embassy-rs/lora-phy", rev = "1323eccc1c470d4259f95f4f315d1be830d572a3"} \ No newline at end of file | ||
diff --git a/examples/stm32wl/src/bin/lora_lorawan.rs b/examples/stm32wl/src/bin/lora_lorawan.rs index 2c9c98861..fb2495326 100644 --- a/examples/stm32wl/src/bin/lora_lorawan.rs +++ b/examples/stm32wl/src/bin/lora_lorawan.rs | |||
| @@ -20,6 +20,7 @@ use lora_phy::LoRa; | |||
| 20 | use lorawan::default_crypto::DefaultFactory as Crypto; | 20 | use lorawan::default_crypto::DefaultFactory as Crypto; |
| 21 | use lorawan_device::async_device::lora_radio::LoRaRadio; | 21 | use lorawan_device::async_device::lora_radio::LoRaRadio; |
| 22 | use lorawan_device::async_device::{region, Device, JoinMode}; | 22 | use lorawan_device::async_device::{region, Device, JoinMode}; |
| 23 | use lorawan_device::{AppEui, AppKey, DevEui}; | ||
| 23 | use {defmt_rtt as _, panic_probe as _}; | 24 | use {defmt_rtt as _, panic_probe as _}; |
| 24 | 25 | ||
| 25 | const LORAWAN_REGION: region::Region = region::Region::EU868; // warning: set this appropriately for the region | 26 | const LORAWAN_REGION: region::Region = region::Region::EU868; // warning: set this appropriately for the region |
| @@ -33,7 +34,7 @@ bind_interrupts!(struct Irqs{ | |||
| 33 | async fn main(_spawner: Spawner) { | 34 | async fn main(_spawner: Spawner) { |
| 34 | let mut config = embassy_stm32::Config::default(); | 35 | let mut config = embassy_stm32::Config::default(); |
| 35 | config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSE32; | 36 | config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSE32; |
| 36 | config.rcc.enable_lsi = true; // enable RNG | 37 | config.rcc.rtc_mux = embassy_stm32::rcc::RtcClockSource::LSI; |
| 37 | let p = embassy_stm32::init(config); | 38 | let p = embassy_stm32::init(config); |
| 38 | 39 | ||
| 39 | pac::RCC.ccipr().modify(|w| w.set_rngsel(0b01)); | 40 | pac::RCC.ccipr().modify(|w| w.set_rngsel(0b01)); |
| @@ -46,10 +47,8 @@ async fn main(_spawner: Spawner) { | |||
| 46 | let _ctrl3 = Output::new(p.PC3.degrade(), Level::High, Speed::High); | 47 | let _ctrl3 = Output::new(p.PC3.degrade(), Level::High, Speed::High); |
| 47 | let iv = Stm32wlInterfaceVariant::new(Irqs, None, Some(ctrl2)).unwrap(); | 48 | let iv = Stm32wlInterfaceVariant::new(Irqs, None, Some(ctrl2)).unwrap(); |
| 48 | 49 | ||
| 49 | let mut delay = Delay; | ||
| 50 | |||
| 51 | let lora = { | 50 | let lora = { |
| 52 | match LoRa::new(SX1261_2::new(BoardType::Stm32wlSx1262, spi, iv), true, &mut delay).await { | 51 | match LoRa::new(SX1261_2::new(BoardType::Stm32wlSx1262, spi, iv), true, Delay).await { |
| 53 | Ok(l) => l, | 52 | Ok(l) => l, |
| 54 | Err(err) => { | 53 | Err(err) => { |
| 55 | info!("Radio error = {}", err); | 54 | info!("Radio error = {}", err); |
| @@ -66,9 +65,9 @@ async fn main(_spawner: Spawner) { | |||
| 66 | // TODO: Adjust the EUI and Keys according to your network credentials | 65 | // TODO: Adjust the EUI and Keys according to your network credentials |
| 67 | match device | 66 | match device |
| 68 | .join(&JoinMode::OTAA { | 67 | .join(&JoinMode::OTAA { |
| 69 | deveui: [0, 0, 0, 0, 0, 0, 0, 0], | 68 | deveui: DevEui::from([0, 0, 0, 0, 0, 0, 0, 0]), |
| 70 | appeui: [0, 0, 0, 0, 0, 0, 0, 0], | 69 | appeui: AppEui::from([0, 0, 0, 0, 0, 0, 0, 0]), |
| 71 | appkey: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | 70 | appkey: AppKey::from([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), |
| 72 | }) | 71 | }) |
| 73 | .await | 72 | .await |
| 74 | { | 73 | { |
diff --git a/examples/stm32wl/src/bin/lora_p2p_receive.rs b/examples/stm32wl/src/bin/lora_p2p_receive.rs index d3f051b1c..3d8c31ff3 100644 --- a/examples/stm32wl/src/bin/lora_p2p_receive.rs +++ b/examples/stm32wl/src/bin/lora_p2p_receive.rs | |||
| @@ -37,10 +37,8 @@ async fn main(_spawner: Spawner) { | |||
| 37 | let _ctrl3 = Output::new(p.PC3.degrade(), Level::High, Speed::High); | 37 | let _ctrl3 = Output::new(p.PC3.degrade(), Level::High, Speed::High); |
| 38 | let iv = Stm32wlInterfaceVariant::new(Irqs, None, Some(ctrl2)).unwrap(); | 38 | let iv = Stm32wlInterfaceVariant::new(Irqs, None, Some(ctrl2)).unwrap(); |
| 39 | 39 | ||
| 40 | let mut delay = Delay; | ||
| 41 | |||
| 42 | let mut lora = { | 40 | let mut lora = { |
| 43 | match LoRa::new(SX1261_2::new(BoardType::Stm32wlSx1262, spi, iv), false, &mut delay).await { | 41 | match LoRa::new(SX1261_2::new(BoardType::Stm32wlSx1262, spi, iv), false, Delay).await { |
| 44 | Ok(l) => l, | 42 | Ok(l) => l, |
| 45 | Err(err) => { | 43 | Err(err) => { |
| 46 | info!("Radio error = {}", err); | 44 | info!("Radio error = {}", err); |
| @@ -84,7 +82,7 @@ async fn main(_spawner: Spawner) { | |||
| 84 | }; | 82 | }; |
| 85 | 83 | ||
| 86 | match lora | 84 | match lora |
| 87 | .prepare_for_rx(&mdltn_params, &rx_pkt_params, None, true, false, 0, 0x00ffffffu32) | 85 | .prepare_for_rx(&mdltn_params, &rx_pkt_params, None, None, false) |
| 88 | .await | 86 | .await |
| 89 | { | 87 | { |
| 90 | Ok(()) => {} | 88 | Ok(()) => {} |
diff --git a/examples/stm32wl/src/bin/lora_p2p_send.rs b/examples/stm32wl/src/bin/lora_p2p_send.rs index fc5205c85..fbd0b0320 100644 --- a/examples/stm32wl/src/bin/lora_p2p_send.rs +++ b/examples/stm32wl/src/bin/lora_p2p_send.rs | |||
| @@ -37,10 +37,8 @@ async fn main(_spawner: Spawner) { | |||
| 37 | let _ctrl3 = Output::new(p.PC3.degrade(), Level::High, Speed::High); | 37 | let _ctrl3 = Output::new(p.PC3.degrade(), Level::High, Speed::High); |
| 38 | let iv = Stm32wlInterfaceVariant::new(Irqs, None, Some(ctrl2)).unwrap(); | 38 | let iv = Stm32wlInterfaceVariant::new(Irqs, None, Some(ctrl2)).unwrap(); |
| 39 | 39 | ||
| 40 | let mut delay = Delay; | ||
| 41 | |||
| 42 | let mut lora = { | 40 | let mut lora = { |
| 43 | match LoRa::new(SX1261_2::new(BoardType::Stm32wlSx1262, spi, iv), false, &mut delay).await { | 41 | match LoRa::new(SX1261_2::new(BoardType::Stm32wlSx1262, spi, iv), false, Delay).await { |
| 44 | Ok(l) => l, | 42 | Ok(l) => l, |
| 45 | Err(err) => { | 43 | Err(err) => { |
| 46 | info!("Radio error = {}", err); | 44 | info!("Radio error = {}", err); |
| @@ -93,7 +91,7 @@ async fn main(_spawner: Spawner) { | |||
| 93 | } | 91 | } |
| 94 | }; | 92 | }; |
| 95 | 93 | ||
| 96 | match lora.sleep(&mut delay).await { | 94 | match lora.sleep(false).await { |
| 97 | Ok(()) => info!("Sleep successful"), | 95 | Ok(()) => info!("Sleep successful"), |
| 98 | Err(err) => info!("Sleep unsuccessful = {}", err), | 96 | Err(err) => info!("Sleep unsuccessful = {}", err), |
| 99 | } | 97 | } |
diff --git a/examples/stm32wl/src/bin/random.rs b/examples/stm32wl/src/bin/random.rs index 592e65f40..18eeac4fa 100644 --- a/examples/stm32wl/src/bin/random.rs +++ b/examples/stm32wl/src/bin/random.rs | |||
| @@ -16,7 +16,7 @@ bind_interrupts!(struct Irqs{ | |||
| 16 | async fn main(_spawner: Spawner) { | 16 | async fn main(_spawner: Spawner) { |
| 17 | let mut config = embassy_stm32::Config::default(); | 17 | let mut config = embassy_stm32::Config::default(); |
| 18 | config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSE32; | 18 | config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSE32; |
| 19 | config.rcc.enable_lsi = true; //Needed for RNG to work | 19 | config.rcc.rtc_mux = embassy_stm32::rcc::RtcClockSource::LSI; |
| 20 | 20 | ||
| 21 | let p = embassy_stm32::init(config); | 21 | let p = embassy_stm32::init(config); |
| 22 | pac::RCC.ccipr().modify(|w| { | 22 | pac::RCC.ccipr().modify(|w| { |
diff --git a/examples/stm32wl/src/bin/rtc.rs b/examples/stm32wl/src/bin/rtc.rs index fb1bc6e3d..11734e4b6 100644 --- a/examples/stm32wl/src/bin/rtc.rs +++ b/examples/stm32wl/src/bin/rtc.rs | |||
| @@ -5,8 +5,9 @@ | |||
| 5 | use chrono::{NaiveDate, NaiveDateTime}; | 5 | use chrono::{NaiveDate, NaiveDateTime}; |
| 6 | use defmt::*; | 6 | use defmt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_stm32::rcc::{self, ClockSrc}; | 8 | use embassy_stm32::rcc::ClockSrc; |
| 9 | use embassy_stm32::rtc::{Rtc, RtcConfig}; | 9 | use embassy_stm32::rtc::{Rtc, RtcClockSource, RtcConfig}; |
| 10 | use embassy_stm32::time::Hertz; | ||
| 10 | use embassy_stm32::Config; | 11 | use embassy_stm32::Config; |
| 11 | use embassy_time::{Duration, Timer}; | 12 | use embassy_time::{Duration, Timer}; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -16,8 +17,8 @@ async fn main(_spawner: Spawner) { | |||
| 16 | let p = { | 17 | let p = { |
| 17 | let mut config = Config::default(); | 18 | let mut config = Config::default(); |
| 18 | config.rcc.mux = ClockSrc::HSE32; | 19 | config.rcc.mux = ClockSrc::HSE32; |
| 19 | config.rcc.rtc_mux = rcc::RtcClockSource::LSE32; | 20 | config.rcc.lse = Some(Hertz(32_768)); |
| 20 | config.rcc.enable_rtc_apb = true; | 21 | config.rcc.rtc_mux = RtcClockSource::LSE; |
| 21 | embassy_stm32::init(config) | 22 | embassy_stm32::init(config) |
| 22 | }; | 23 | }; |
| 23 | info!("Hello World!"); | 24 | info!("Hello World!"); |
diff --git a/examples/stm32wl/src/bin/uart_async.rs b/examples/stm32wl/src/bin/uart_async.rs index 07b0f9d2c..2c9b7c691 100644 --- a/examples/stm32wl/src/bin/uart_async.rs +++ b/examples/stm32wl/src/bin/uart_async.rs | |||
| @@ -33,10 +33,10 @@ async fn main(_spawner: Spawner) { | |||
| 33 | config2.baudrate = 9600; | 33 | config2.baudrate = 9600; |
| 34 | 34 | ||
| 35 | //RX/TX connected to USB/UART Bridge on LoRa-E5 mini v1.0 | 35 | //RX/TX connected to USB/UART Bridge on LoRa-E5 mini v1.0 |
| 36 | let mut usart1 = Uart::new(p.USART1, p.PB7, p.PB6, Irqs, p.DMA1_CH3, p.DMA1_CH4, config1); | 36 | let mut usart1 = Uart::new(p.USART1, p.PB7, p.PB6, Irqs, p.DMA1_CH3, p.DMA1_CH4, config1).unwrap(); |
| 37 | 37 | ||
| 38 | //RX1/TX1 (LPUART) on LoRa-E5 mini v1.0 | 38 | //RX1/TX1 (LPUART) on LoRa-E5 mini v1.0 |
| 39 | let mut usart2 = Uart::new(p.LPUART1, p.PC0, p.PC1, Irqs, p.DMA1_CH5, p.DMA1_CH6, config2); | 39 | let mut usart2 = Uart::new(p.LPUART1, p.PC0, p.PC1, Irqs, p.DMA1_CH5, p.DMA1_CH6, config2).unwrap(); |
| 40 | 40 | ||
| 41 | unwrap!(usart1.write(b"Hello Embassy World!\r\n").await); | 41 | unwrap!(usart1.write(b"Hello Embassy World!\r\n").await); |
| 42 | unwrap!(usart2.write(b"Hello Embassy World!\r\n").await); | 42 | unwrap!(usart2.write(b"Hello Embassy World!\r\n").await); |
diff --git a/examples/wasm/Cargo.toml b/examples/wasm/Cargo.toml index 5b206d716..12b2e2bd4 100644 --- a/examples/wasm/Cargo.toml +++ b/examples/wasm/Cargo.toml | |||
| @@ -8,9 +8,9 @@ license = "MIT OR Apache-2.0" | |||
| 8 | crate-type = ["cdylib"] | 8 | crate-type = ["cdylib"] |
| 9 | 9 | ||
| 10 | [dependencies] | 10 | [dependencies] |
| 11 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["log"] } | 11 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["log"] } |
| 12 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-wasm", "executor-thread", "log", "nightly", "integrated-timers"] } | 12 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-wasm", "executor-thread", "log", "nightly", "integrated-timers"] } |
| 13 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["log", "wasm", "nightly"] } | 13 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["log", "wasm", "nightly"] } |
| 14 | 14 | ||
| 15 | wasm-logger = "0.2.0" | 15 | wasm-logger = "0.2.0" |
| 16 | wasm-bindgen = "0.2" | 16 | wasm-bindgen = "0.2" |
