diff options
| author | Ghaith Oueslati <[email protected]> | 2023-06-12 14:28:23 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-06-12 14:28:23 +0100 |
| commit | cf83f6820cf2c6ece607cd60cfdab9d5e47efd04 (patch) | |
| tree | 6485dacac7e61c4378ac522e709edb0a86bd7523 /examples/stm32f0 | |
| parent | 2dd5ce83ec0421564e85b667f5dabd592f313e5c (diff) | |
| parent | 2d89cfb18f00aefbfa108728dfea3398e80ea3e4 (diff) | |
Merge pull request #3 from OueslatiGhaith/master
fix merge conflicts
Diffstat (limited to 'examples/stm32f0')
| -rw-r--r-- | examples/stm32f0/Cargo.toml | 2 | ||||
| -rw-r--r-- | examples/stm32f0/src/bin/multiprio.rs | 14 |
2 files changed, 6 insertions, 10 deletions
diff --git a/examples/stm32f0/Cargo.toml b/examples/stm32f0/Cargo.toml index ff134bb0e..8d2248ed0 100644 --- a/examples/stm32f0/Cargo.toml +++ b/examples/stm32f0/Cargo.toml | |||
| @@ -13,7 +13,7 @@ defmt = "0.3" | |||
| 13 | defmt-rtt = "0.4" | 13 | defmt-rtt = "0.4" |
| 14 | panic-probe = "0.3" | 14 | panic-probe = "0.3" |
| 15 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 15 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 16 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } | 16 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } |
| 17 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 17 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 18 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "memory-x", "stm32f091rc", "time-driver-any", "exti", "unstable-pac"] } | 18 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "memory-x", "stm32f091rc", "time-driver-any", "exti", "unstable-pac"] } |
| 19 | static_cell = { version = "1.1", features = ["nightly"]} | 19 | static_cell = { version = "1.1", features = ["nightly"]} |
diff --git a/examples/stm32f0/src/bin/multiprio.rs b/examples/stm32f0/src/bin/multiprio.rs index 430a805fc..988ffeef1 100644 --- a/examples/stm32f0/src/bin/multiprio.rs +++ b/examples/stm32f0/src/bin/multiprio.rs | |||
| @@ -57,14 +57,11 @@ | |||
| 57 | #![no_main] | 57 | #![no_main] |
| 58 | #![feature(type_alias_impl_trait)] | 58 | #![feature(type_alias_impl_trait)] |
| 59 | 59 | ||
| 60 | use core::mem; | ||
| 61 | |||
| 62 | use cortex_m::peripheral::NVIC; | ||
| 63 | use cortex_m_rt::entry; | 60 | use cortex_m_rt::entry; |
| 64 | use defmt::*; | 61 | use defmt::*; |
| 65 | use embassy_executor::{Executor, InterruptExecutor}; | 62 | use embassy_executor::{Executor, InterruptExecutor}; |
| 66 | use embassy_stm32::interrupt; | 63 | use embassy_stm32::interrupt; |
| 67 | use embassy_stm32::pac::Interrupt; | 64 | use embassy_stm32::interrupt::{InterruptExt, Priority}; |
| 68 | use embassy_time::{Duration, Instant, Timer}; | 65 | use embassy_time::{Duration, Instant, Timer}; |
| 69 | use static_cell::StaticCell; | 66 | use static_cell::StaticCell; |
| 70 | use {defmt_rtt as _, panic_probe as _}; | 67 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -129,16 +126,15 @@ unsafe fn USART2() { | |||
| 129 | fn main() -> ! { | 126 | fn main() -> ! { |
| 130 | // Initialize and create handle for devicer peripherals | 127 | // Initialize and create handle for devicer peripherals |
| 131 | let _p = embassy_stm32::init(Default::default()); | 128 | let _p = embassy_stm32::init(Default::default()); |
| 132 | let mut nvic: NVIC = unsafe { mem::transmute(()) }; | ||
| 133 | 129 | ||
| 134 | // High-priority executor: USART1, priority level 6 | 130 | // High-priority executor: USART1, priority level 6 |
| 135 | unsafe { nvic.set_priority(Interrupt::USART1, 6 << 4) }; | 131 | interrupt::USART1.set_priority(Priority::P6); |
| 136 | let spawner = EXECUTOR_HIGH.start(Interrupt::USART1); | 132 | let spawner = EXECUTOR_HIGH.start(interrupt::USART1); |
| 137 | unwrap!(spawner.spawn(run_high())); | 133 | unwrap!(spawner.spawn(run_high())); |
| 138 | 134 | ||
| 139 | // Medium-priority executor: USART2, priority level 7 | 135 | // Medium-priority executor: USART2, priority level 7 |
| 140 | unsafe { nvic.set_priority(Interrupt::USART2, 7 << 4) }; | 136 | interrupt::USART2.set_priority(Priority::P7); |
| 141 | let spawner = EXECUTOR_MED.start(Interrupt::USART2); | 137 | let spawner = EXECUTOR_MED.start(interrupt::USART2); |
| 142 | unwrap!(spawner.spawn(run_med())); | 138 | unwrap!(spawner.spawn(run_med())); |
| 143 | 139 | ||
| 144 | // Low priority executor: runs in thread mode, using WFE/SEV | 140 | // Low priority executor: runs in thread mode, using WFE/SEV |
