diff options
Diffstat (limited to 'examples')
28 files changed, 19 insertions, 117 deletions
diff --git a/examples/nrf/src/bin/blinky.rs b/examples/nrf/src/bin/blinky.rs index 77b08b09b..6d4561beb 100644 --- a/examples/nrf/src/bin/blinky.rs +++ b/examples/nrf/src/bin/blinky.rs | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | #[path = "../example_common.rs"] | 6 | #[path = "../example_common.rs"] |
| 7 | mod example_common; | 7 | mod example_common; |
| 8 | 8 | ||
| 9 | use defmt::panic; | ||
| 10 | use embassy::executor::Spawner; | 9 | use embassy::executor::Spawner; |
| 11 | use embassy::time::{Duration, Timer}; | 10 | use embassy::time::{Duration, Timer}; |
| 12 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | 11 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; |
diff --git a/examples/nrf/src/bin/executor_fairness_test.rs b/examples/nrf/src/bin/executor_fairness_test.rs index d874013f6..2d81a7551 100644 --- a/examples/nrf/src/bin/executor_fairness_test.rs +++ b/examples/nrf/src/bin/executor_fairness_test.rs | |||
| @@ -8,10 +8,9 @@ mod example_common; | |||
| 8 | use example_common::*; | 8 | use example_common::*; |
| 9 | 9 | ||
| 10 | use core::task::Poll; | 10 | use core::task::Poll; |
| 11 | use defmt::panic; | ||
| 12 | use embassy::executor::Spawner; | 11 | use embassy::executor::Spawner; |
| 13 | use embassy::time::{Duration, Instant, Timer}; | 12 | use embassy::time::{Duration, Instant, Timer}; |
| 14 | use embassy_nrf::{interrupt, Peripherals}; | 13 | use embassy_nrf::Peripherals; |
| 15 | 14 | ||
| 16 | #[embassy::task] | 15 | #[embassy::task] |
| 17 | async fn run1() { | 16 | async fn run1() { |
diff --git a/examples/nrf/src/bin/gpiote_channel.rs b/examples/nrf/src/bin/gpiote_channel.rs index a132f846e..a96523e65 100644 --- a/examples/nrf/src/bin/gpiote_channel.rs +++ b/examples/nrf/src/bin/gpiote_channel.rs | |||
| @@ -7,11 +7,10 @@ | |||
| 7 | mod example_common; | 7 | mod example_common; |
| 8 | use example_common::*; | 8 | use example_common::*; |
| 9 | 9 | ||
| 10 | use defmt::panic; | ||
| 11 | use embassy::executor::Spawner; | 10 | use embassy::executor::Spawner; |
| 12 | use embassy_nrf::gpio::{Input, Pull}; | 11 | use embassy_nrf::gpio::{Input, Pull}; |
| 13 | use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity}; | 12 | use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity}; |
| 14 | use embassy_nrf::{interrupt, Peripherals}; | 13 | use embassy_nrf::Peripherals; |
| 15 | 14 | ||
| 16 | #[embassy::main] | 15 | #[embassy::main] |
| 17 | async fn main(_spawner: Spawner, p: Peripherals) { | 16 | async fn main(_spawner: Spawner, p: Peripherals) { |
diff --git a/examples/nrf/src/bin/gpiote_port.rs b/examples/nrf/src/bin/gpiote_port.rs index a782d8935..700247d37 100644 --- a/examples/nrf/src/bin/gpiote_port.rs +++ b/examples/nrf/src/bin/gpiote_port.rs | |||
| @@ -6,12 +6,10 @@ | |||
| 6 | #[path = "../example_common.rs"] | 6 | #[path = "../example_common.rs"] |
| 7 | mod example_common; | 7 | mod example_common; |
| 8 | 8 | ||
| 9 | use defmt::panic; | ||
| 10 | use embassy::executor::Spawner; | 9 | use embassy::executor::Spawner; |
| 11 | use embassy::traits::gpio::{WaitForHigh, WaitForLow}; | 10 | use embassy::traits::gpio::{WaitForHigh, WaitForLow}; |
| 12 | use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull}; | 11 | use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull}; |
| 13 | use embassy_nrf::gpiote::PortInput; | 12 | use embassy_nrf::gpiote::PortInput; |
| 14 | use embassy_nrf::interrupt; | ||
| 15 | use embassy_nrf::Peripherals; | 13 | use embassy_nrf::Peripherals; |
| 16 | use example_common::*; | 14 | use example_common::*; |
| 17 | 15 | ||
diff --git a/examples/nrf/src/bin/mpsc.rs b/examples/nrf/src/bin/mpsc.rs index c4c0572bd..e31754eb8 100644 --- a/examples/nrf/src/bin/mpsc.rs +++ b/examples/nrf/src/bin/mpsc.rs | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | #[path = "../example_common.rs"] | 6 | #[path = "../example_common.rs"] |
| 7 | mod example_common; | 7 | mod example_common; |
| 8 | 8 | ||
| 9 | use defmt::panic; | ||
| 10 | use embassy::executor::Spawner; | 9 | use embassy::executor::Spawner; |
| 11 | use embassy::time::{Duration, Timer}; | 10 | use embassy::time::{Duration, Timer}; |
| 12 | use embassy::util::mpsc::TryRecvError; | 11 | use embassy::util::mpsc::TryRecvError; |
diff --git a/examples/nrf/src/bin/multiprio.rs b/examples/nrf/src/bin/multiprio.rs index 7ce79168b..b91bbb740 100644 --- a/examples/nrf/src/bin/multiprio.rs +++ b/examples/nrf/src/bin/multiprio.rs | |||
| @@ -68,7 +68,7 @@ use embassy::executor::{Executor, InterruptExecutor}; | |||
| 68 | use embassy::interrupt::InterruptExt; | 68 | use embassy::interrupt::InterruptExt; |
| 69 | use embassy::time::{Duration, Instant, Timer}; | 69 | use embassy::time::{Duration, Instant, Timer}; |
| 70 | use embassy::util::Forever; | 70 | use embassy::util::Forever; |
| 71 | use embassy_nrf::{interrupt, peripherals, rtc}; | 71 | use embassy_nrf::interrupt; |
| 72 | 72 | ||
| 73 | #[embassy::task] | 73 | #[embassy::task] |
| 74 | async fn run_high() { | 74 | async fn run_high() { |
| @@ -112,30 +112,20 @@ async fn run_low() { | |||
| 112 | } | 112 | } |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | static RTC: Forever<rtc::RTC<peripherals::RTC1>> = Forever::new(); | ||
| 116 | static ALARM_HIGH: Forever<rtc::Alarm<peripherals::RTC1>> = Forever::new(); | ||
| 117 | static EXECUTOR_HIGH: Forever<InterruptExecutor<interrupt::SWI1_EGU1>> = Forever::new(); | 115 | static EXECUTOR_HIGH: Forever<InterruptExecutor<interrupt::SWI1_EGU1>> = Forever::new(); |
| 118 | static ALARM_MED: Forever<rtc::Alarm<peripherals::RTC1>> = Forever::new(); | ||
| 119 | static EXECUTOR_MED: Forever<InterruptExecutor<interrupt::SWI0_EGU0>> = Forever::new(); | 116 | static EXECUTOR_MED: Forever<InterruptExecutor<interrupt::SWI0_EGU0>> = Forever::new(); |
| 120 | static ALARM_LOW: Forever<rtc::Alarm<peripherals::RTC1>> = Forever::new(); | ||
| 121 | static EXECUTOR_LOW: Forever<Executor> = Forever::new(); | 117 | static EXECUTOR_LOW: Forever<Executor> = Forever::new(); |
| 122 | 118 | ||
| 123 | #[entry] | 119 | #[entry] |
| 124 | fn main() -> ! { | 120 | fn main() -> ! { |
| 125 | info!("Hello World!"); | 121 | info!("Hello World!"); |
| 126 | 122 | ||
| 127 | let p = embassy_nrf::init(Default::default()); | 123 | let _p = embassy_nrf::init(Default::default()); |
| 128 | |||
| 129 | let rtc = RTC.put(rtc::RTC::new(p.RTC1, interrupt::take!(RTC1))); | ||
| 130 | rtc.start(); | ||
| 131 | unsafe { embassy::time::set_clock(rtc) }; | ||
| 132 | 124 | ||
| 133 | // High-priority executor: SWI1_EGU1, priority level 6 | 125 | // High-priority executor: SWI1_EGU1, priority level 6 |
| 134 | let irq = interrupt::take!(SWI1_EGU1); | 126 | let irq = interrupt::take!(SWI1_EGU1); |
| 135 | irq.set_priority(interrupt::Priority::P6); | 127 | irq.set_priority(interrupt::Priority::P6); |
| 136 | let alarm = ALARM_HIGH.put(rtc.alarm2()); | ||
| 137 | let executor = EXECUTOR_HIGH.put(InterruptExecutor::new(irq)); | 128 | let executor = EXECUTOR_HIGH.put(InterruptExecutor::new(irq)); |
| 138 | executor.set_alarm(alarm); | ||
| 139 | executor.start(|spawner| { | 129 | executor.start(|spawner| { |
| 140 | unwrap!(spawner.spawn(run_high())); | 130 | unwrap!(spawner.spawn(run_high())); |
| 141 | }); | 131 | }); |
| @@ -143,17 +133,13 @@ fn main() -> ! { | |||
| 143 | // Medium-priority executor: SWI0_EGU0, priority level 7 | 133 | // Medium-priority executor: SWI0_EGU0, priority level 7 |
| 144 | let irq = interrupt::take!(SWI0_EGU0); | 134 | let irq = interrupt::take!(SWI0_EGU0); |
| 145 | irq.set_priority(interrupt::Priority::P7); | 135 | irq.set_priority(interrupt::Priority::P7); |
| 146 | let alarm = ALARM_MED.put(rtc.alarm1()); | ||
| 147 | let executor = EXECUTOR_MED.put(InterruptExecutor::new(irq)); | 136 | let executor = EXECUTOR_MED.put(InterruptExecutor::new(irq)); |
| 148 | executor.set_alarm(alarm); | ||
| 149 | executor.start(|spawner| { | 137 | executor.start(|spawner| { |
| 150 | unwrap!(spawner.spawn(run_med())); | 138 | unwrap!(spawner.spawn(run_med())); |
| 151 | }); | 139 | }); |
| 152 | 140 | ||
| 153 | // Low priority executor: runs in thread mode, using WFE/SEV | 141 | // Low priority executor: runs in thread mode, using WFE/SEV |
| 154 | let alarm = ALARM_LOW.put(rtc.alarm0()); | ||
| 155 | let executor = EXECUTOR_LOW.put(Executor::new()); | 142 | let executor = EXECUTOR_LOW.put(Executor::new()); |
| 156 | executor.set_alarm(alarm); | ||
| 157 | executor.run(|spawner| { | 143 | executor.run(|spawner| { |
| 158 | unwrap!(spawner.spawn(run_low())); | 144 | unwrap!(spawner.spawn(run_low())); |
| 159 | }); | 145 | }); |
diff --git a/examples/nrf/src/bin/ppi.rs b/examples/nrf/src/bin/ppi.rs index 0bac875bd..2dc3fe1b7 100644 --- a/examples/nrf/src/bin/ppi.rs +++ b/examples/nrf/src/bin/ppi.rs | |||
| @@ -8,12 +8,11 @@ mod example_common; | |||
| 8 | use example_common::*; | 8 | use example_common::*; |
| 9 | 9 | ||
| 10 | use core::future::pending; | 10 | use core::future::pending; |
| 11 | use defmt::panic; | ||
| 12 | use embassy::executor::Spawner; | 11 | use embassy::executor::Spawner; |
| 13 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; | 12 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; |
| 14 | use embassy_nrf::gpiote::{self, InputChannel, InputChannelPolarity}; | 13 | use embassy_nrf::gpiote::{self, InputChannel, InputChannelPolarity}; |
| 15 | use embassy_nrf::ppi::Ppi; | 14 | use embassy_nrf::ppi::Ppi; |
| 16 | use embassy_nrf::{interrupt, Peripherals}; | 15 | use embassy_nrf::Peripherals; |
| 17 | use gpiote::{OutputChannel, OutputChannelPolarity}; | 16 | use gpiote::{OutputChannel, OutputChannelPolarity}; |
| 18 | 17 | ||
| 19 | #[embassy::main] | 18 | #[embassy::main] |
diff --git a/examples/nrf/src/bin/pwm.rs b/examples/nrf/src/bin/pwm.rs index d2bc81cea..f30ad8f52 100644 --- a/examples/nrf/src/bin/pwm.rs +++ b/examples/nrf/src/bin/pwm.rs | |||
| @@ -5,11 +5,11 @@ | |||
| 5 | 5 | ||
| 6 | #[path = "../example_common.rs"] | 6 | #[path = "../example_common.rs"] |
| 7 | mod example_common; | 7 | mod example_common; |
| 8 | use defmt::{panic, *}; | 8 | use defmt::*; |
| 9 | use embassy::executor::Spawner; | 9 | use embassy::executor::Spawner; |
| 10 | use embassy::time::{Duration, Timer}; | 10 | use embassy::time::{Duration, Timer}; |
| 11 | use embassy_nrf::pwm::{Prescaler, Pwm}; | 11 | use embassy_nrf::pwm::{Prescaler, Pwm}; |
| 12 | use embassy_nrf::{interrupt, Peripherals}; | 12 | use embassy_nrf::Peripherals; |
| 13 | 13 | ||
| 14 | // for i in range(1024): print(int((math.sin(i/512*math.pi)*0.4+0.5)**2*32767), ', ', end='') | 14 | // for i in range(1024): print(int((math.sin(i/512*math.pi)*0.4+0.5)**2*32767), ', ', end='') |
| 15 | static DUTY: [u16; 1024] = [ | 15 | static DUTY: [u16; 1024] = [ |
diff --git a/examples/nrf/src/bin/raw_spawn.rs b/examples/nrf/src/bin/raw_spawn.rs index 78de7b100..326dd9aac 100644 --- a/examples/nrf/src/bin/raw_spawn.rs +++ b/examples/nrf/src/bin/raw_spawn.rs | |||
| @@ -7,13 +7,11 @@ use example_common::*; | |||
| 7 | 7 | ||
| 8 | use core::mem; | 8 | use core::mem; |
| 9 | use cortex_m_rt::entry; | 9 | use cortex_m_rt::entry; |
| 10 | use defmt::panic; | 10 | |
| 11 | use embassy::executor::raw::Task; | 11 | use embassy::executor::raw::Task; |
| 12 | use embassy::executor::Executor; | 12 | use embassy::executor::Executor; |
| 13 | use embassy::time::{Duration, Timer}; | 13 | use embassy::time::{Duration, Timer}; |
| 14 | use embassy::util::Forever; | 14 | use embassy::util::Forever; |
| 15 | use embassy_nrf::peripherals; | ||
| 16 | use embassy_nrf::{interrupt, rtc}; | ||
| 17 | 15 | ||
| 18 | async fn run1() { | 16 | async fn run1() { |
| 19 | loop { | 17 | loop { |
| @@ -29,23 +27,14 @@ async fn run2() { | |||
| 29 | } | 27 | } |
| 30 | } | 28 | } |
| 31 | 29 | ||
| 32 | static RTC: Forever<rtc::RTC<peripherals::RTC1>> = Forever::new(); | ||
| 33 | static ALARM: Forever<rtc::Alarm<peripherals::RTC1>> = Forever::new(); | ||
| 34 | static EXECUTOR: Forever<Executor> = Forever::new(); | 30 | static EXECUTOR: Forever<Executor> = Forever::new(); |
| 35 | 31 | ||
| 36 | #[entry] | 32 | #[entry] |
| 37 | fn main() -> ! { | 33 | fn main() -> ! { |
| 38 | info!("Hello World!"); | 34 | info!("Hello World!"); |
| 39 | 35 | ||
| 40 | let p = embassy_nrf::init(Default::default()); | 36 | let _p = embassy_nrf::init(Default::default()); |
| 41 | |||
| 42 | let rtc = RTC.put(rtc::RTC::new(p.RTC1, interrupt::take!(RTC1))); | ||
| 43 | rtc.start(); | ||
| 44 | unsafe { embassy::time::set_clock(rtc) }; | ||
| 45 | |||
| 46 | let alarm = ALARM.put(rtc.alarm0()); | ||
| 47 | let executor = EXECUTOR.put(Executor::new()); | 37 | let executor = EXECUTOR.put(Executor::new()); |
| 48 | executor.set_alarm(alarm); | ||
| 49 | 38 | ||
| 50 | let run1_task = Task::new(); | 39 | let run1_task = Task::new(); |
| 51 | let run2_task = Task::new(); | 40 | let run2_task = Task::new(); |
diff --git a/examples/nrf/src/bin/timer.rs b/examples/nrf/src/bin/timer.rs index 630ea87a5..60cbe5a0f 100644 --- a/examples/nrf/src/bin/timer.rs +++ b/examples/nrf/src/bin/timer.rs | |||
| @@ -8,7 +8,6 @@ mod example_common; | |||
| 8 | use embassy_nrf::Peripherals; | 8 | use embassy_nrf::Peripherals; |
| 9 | use example_common::*; | 9 | use example_common::*; |
| 10 | 10 | ||
| 11 | use defmt::panic; | ||
| 12 | use embassy::executor::Spawner; | 11 | use embassy::executor::Spawner; |
| 13 | use embassy::time::{Duration, Timer}; | 12 | use embassy::time::{Duration, Timer}; |
| 14 | 13 | ||
diff --git a/examples/stm32f4/src/bin/blinky.rs b/examples/stm32f4/src/bin/blinky.rs index 9c695a809..00eab761e 100644 --- a/examples/stm32f4/src/bin/blinky.rs +++ b/examples/stm32f4/src/bin/blinky.rs | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | 6 | ||
| 7 | #[path = "../example_common.rs"] | 7 | #[path = "../example_common.rs"] |
| 8 | mod example_common; | 8 | mod example_common; |
| 9 | use defmt::panic; | ||
| 10 | use embassy::executor::Spawner; | 9 | use embassy::executor::Spawner; |
| 11 | use embassy::time::{Duration, Timer}; | 10 | use embassy::time::{Duration, Timer}; |
| 12 | use embassy_stm32::dbgmcu::Dbgmcu; | 11 | use embassy_stm32::dbgmcu::Dbgmcu; |
diff --git a/examples/stm32f4/src/bin/button_exti.rs b/examples/stm32f4/src/bin/button_exti.rs index caebdac1f..ee43fa7d9 100644 --- a/examples/stm32f4/src/bin/button_exti.rs +++ b/examples/stm32f4/src/bin/button_exti.rs | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | 6 | ||
| 7 | #[path = "../example_common.rs"] | 7 | #[path = "../example_common.rs"] |
| 8 | mod example_common; | 8 | mod example_common; |
| 9 | use defmt::panic; | ||
| 10 | use embassy::executor::Spawner; | 9 | use embassy::executor::Spawner; |
| 11 | use embassy_stm32::dbgmcu::Dbgmcu; | 10 | use embassy_stm32::dbgmcu::Dbgmcu; |
| 12 | use embassy_stm32::exti::ExtiInput; | 11 | use embassy_stm32::exti::ExtiInput; |
diff --git a/examples/stm32f4/src/bin/hello.rs b/examples/stm32f4/src/bin/hello.rs index 41d808406..1b8730aea 100644 --- a/examples/stm32f4/src/bin/hello.rs +++ b/examples/stm32f4/src/bin/hello.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | #![feature(type_alias_impl_trait)] | 4 | #![feature(type_alias_impl_trait)] |
| 5 | #![allow(incomplete_features)] | 5 | #![allow(incomplete_features)] |
| 6 | 6 | ||
| 7 | use defmt::{info, panic}; | 7 | use defmt::info; |
| 8 | use embassy::executor::Spawner; | 8 | use embassy::executor::Spawner; |
| 9 | use embassy::time::{Duration, Timer}; | 9 | use embassy::time::{Duration, Timer}; |
| 10 | use embassy_stm32::time::Hertz; | 10 | use embassy_stm32::time::Hertz; |
diff --git a/examples/stm32f4/src/bin/spi_dma.rs b/examples/stm32f4/src/bin/spi_dma.rs index 9f7101122..a965bef70 100644 --- a/examples/stm32f4/src/bin/spi_dma.rs +++ b/examples/stm32f4/src/bin/spi_dma.rs | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | mod example_common; | 8 | mod example_common; |
| 9 | use core::fmt::Write; | 9 | use core::fmt::Write; |
| 10 | use core::str::from_utf8; | 10 | use core::str::from_utf8; |
| 11 | use defmt::panic; | ||
| 12 | use embassy::executor::Spawner; | 11 | use embassy::executor::Spawner; |
| 13 | use embassy_stm32::dbgmcu::Dbgmcu; | 12 | use embassy_stm32::dbgmcu::Dbgmcu; |
| 14 | use embassy_stm32::spi::{Config, Spi}; | 13 | use embassy_stm32::spi::{Config, Spi}; |
diff --git a/examples/stm32f4/src/bin/usart_dma.rs b/examples/stm32f4/src/bin/usart_dma.rs index 5023075ff..05a550e95 100644 --- a/examples/stm32f4/src/bin/usart_dma.rs +++ b/examples/stm32f4/src/bin/usart_dma.rs | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | #[path = "../example_common.rs"] | 7 | #[path = "../example_common.rs"] |
| 8 | mod example_common; | 8 | mod example_common; |
| 9 | use core::fmt::Write; | 9 | use core::fmt::Write; |
| 10 | use defmt::panic; | ||
| 11 | use embassy::executor::Spawner; | 10 | use embassy::executor::Spawner; |
| 12 | use embassy_stm32::dbgmcu::Dbgmcu; | 11 | use embassy_stm32::dbgmcu::Dbgmcu; |
| 13 | use embassy_stm32::dma::NoDma; | 12 | use embassy_stm32::dma::NoDma; |
diff --git a/examples/stm32h7/src/bin/blinky.rs b/examples/stm32h7/src/bin/blinky.rs index 3291f5e81..b5e0c18a5 100644 --- a/examples/stm32h7/src/bin/blinky.rs +++ b/examples/stm32h7/src/bin/blinky.rs | |||
| @@ -6,30 +6,29 @@ | |||
| 6 | 6 | ||
| 7 | #[path = "../example_common.rs"] | 7 | #[path = "../example_common.rs"] |
| 8 | mod example_common; | 8 | mod example_common; |
| 9 | use embassy::executor::Spawner; | ||
| 10 | use embassy::time::{Duration, Timer}; | ||
| 11 | use embassy_stm32::dbgmcu::Dbgmcu; | ||
| 9 | use embassy_stm32::gpio::{Level, Output, Speed}; | 12 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 13 | use embassy_stm32::Peripherals; | ||
| 10 | use embedded_hal::digital::v2::OutputPin; | 14 | use embedded_hal::digital::v2::OutputPin; |
| 11 | use example_common::*; | 15 | use example_common::*; |
| 12 | 16 | ||
| 13 | use cortex_m_rt::entry; | 17 | #[embassy::main] |
| 14 | use embassy_stm32::dbgmcu::Dbgmcu; | 18 | async fn main(_spawner: Spawner, p: Peripherals) { |
| 15 | |||
| 16 | #[entry] | ||
| 17 | fn main() -> ! { | ||
| 18 | info!("Hello World!"); | 19 | info!("Hello World!"); |
| 19 | 20 | ||
| 20 | unsafe { Dbgmcu::enable_all() }; | 21 | unsafe { Dbgmcu::enable_all() }; |
| 21 | 22 | ||
| 22 | let p = embassy_stm32::init(Default::default()); | ||
| 23 | |||
| 24 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); | 23 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); |
| 25 | 24 | ||
| 26 | loop { | 25 | loop { |
| 27 | info!("high"); | 26 | info!("high"); |
| 28 | led.set_high().unwrap(); | 27 | led.set_high().unwrap(); |
| 29 | cortex_m::asm::delay(10_000_000); | 28 | Timer::after(Duration::from_millis(500)).await; |
| 30 | 29 | ||
| 31 | info!("low"); | 30 | info!("low"); |
| 32 | led.set_low().unwrap(); | 31 | led.set_low().unwrap(); |
| 33 | cortex_m::asm::delay(10_000_000); | 32 | Timer::after(Duration::from_millis(500)).await; |
| 34 | } | 33 | } |
| 35 | } | 34 | } |
diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index 6c4ba6eb9..e8d13876a 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs | |||
| @@ -19,7 +19,6 @@ use embassy_macros::interrupt_take; | |||
| 19 | use embassy_net::{ | 19 | use embassy_net::{ |
| 20 | Config as NetConfig, Ipv4Address, Ipv4Cidr, StackResources, StaticConfigurator, TcpSocket, | 20 | Config as NetConfig, Ipv4Address, Ipv4Cidr, StackResources, StaticConfigurator, TcpSocket, |
| 21 | }; | 21 | }; |
| 22 | use embassy_stm32::clock::{Alarm, Clock}; | ||
| 23 | use embassy_stm32::dbgmcu::Dbgmcu; | 22 | use embassy_stm32::dbgmcu::Dbgmcu; |
| 24 | use embassy_stm32::eth::lan8742a::LAN8742A; | 23 | use embassy_stm32::eth::lan8742a::LAN8742A; |
| 25 | use embassy_stm32::eth::{Ethernet, State}; | 24 | use embassy_stm32::eth::{Ethernet, State}; |
| @@ -27,7 +26,7 @@ use embassy_stm32::rng::Random; | |||
| 27 | use embassy_stm32::{interrupt, peripherals}; | 26 | use embassy_stm32::{interrupt, peripherals}; |
| 28 | use heapless::Vec; | 27 | use heapless::Vec; |
| 29 | use panic_probe as _; | 28 | use panic_probe as _; |
| 30 | use peripherals::{RNG, TIM2}; | 29 | use peripherals::RNG; |
| 31 | 30 | ||
| 32 | #[embassy::task] | 31 | #[embassy::task] |
| 33 | async fn main_task( | 32 | async fn main_task( |
| @@ -86,8 +85,6 @@ fn _embassy_rand(buf: &mut [u8]) { | |||
| 86 | static mut RNG_INST: Option<Random<RNG>> = None; | 85 | static mut RNG_INST: Option<Random<RNG>> = None; |
| 87 | 86 | ||
| 88 | static EXECUTOR: Forever<Executor> = Forever::new(); | 87 | static EXECUTOR: Forever<Executor> = Forever::new(); |
| 89 | static TIMER_RTC: Forever<Clock<TIM2>> = Forever::new(); | ||
| 90 | static ALARM: Forever<Alarm<TIM2>> = Forever::new(); | ||
| 91 | static STATE: Forever<State<'static, 4, 4>> = Forever::new(); | 88 | static STATE: Forever<State<'static, 4, 4>> = Forever::new(); |
| 92 | static ETH: Forever<Ethernet<'static, LAN8742A, 4, 4>> = Forever::new(); | 89 | static ETH: Forever<Ethernet<'static, LAN8742A, 4, 4>> = Forever::new(); |
| 93 | static CONFIG: Forever<StaticConfigurator> = Forever::new(); | 90 | static CONFIG: Forever<StaticConfigurator> = Forever::new(); |
| @@ -105,13 +102,6 @@ fn main() -> ! { | |||
| 105 | 102 | ||
| 106 | let p = embassy_stm32::init(config()); | 103 | let p = embassy_stm32::init(config()); |
| 107 | 104 | ||
| 108 | let rtc_int = interrupt_take!(TIM2); | ||
| 109 | let rtc = TIMER_RTC.put(Clock::new(p.TIM2, rtc_int)); | ||
| 110 | rtc.start(); | ||
| 111 | let alarm = ALARM.put(rtc.alarm1()); | ||
| 112 | |||
| 113 | unsafe { embassy::time::set_clock(rtc) }; | ||
| 114 | |||
| 115 | let rng = Random::new(p.RNG); | 105 | let rng = Random::new(p.RNG); |
| 116 | unsafe { | 106 | unsafe { |
| 117 | RNG_INST.replace(rng); | 107 | RNG_INST.replace(rng); |
| @@ -136,7 +126,6 @@ fn main() -> ! { | |||
| 136 | let config = CONFIG.put(config); | 126 | let config = CONFIG.put(config); |
| 137 | 127 | ||
| 138 | let executor = EXECUTOR.put(Executor::new()); | 128 | let executor = EXECUTOR.put(Executor::new()); |
| 139 | executor.set_alarm(alarm); | ||
| 140 | 129 | ||
| 141 | executor.run(move |spawner| { | 130 | executor.run(move |spawner| { |
| 142 | unwrap!(spawner.spawn(main_task(eth, config, spawner))); | 131 | unwrap!(spawner.spawn(main_task(eth, config, spawner))); |
diff --git a/examples/stm32h7/src/bin/spi.rs b/examples/stm32h7/src/bin/spi.rs index 5175538df..047b65849 100644 --- a/examples/stm32h7/src/bin/spi.rs +++ b/examples/stm32h7/src/bin/spi.rs | |||
| @@ -9,7 +9,6 @@ mod example_common; | |||
| 9 | 9 | ||
| 10 | use core::fmt::Write; | 10 | use core::fmt::Write; |
| 11 | use embassy::executor::Executor; | 11 | use embassy::executor::Executor; |
| 12 | use embassy::time::Clock; | ||
| 13 | use embassy::util::Forever; | 12 | use embassy::util::Forever; |
| 14 | use embassy_stm32::dma::NoDma; | 13 | use embassy_stm32::dma::NoDma; |
| 15 | use embassy_stm32::spi; | 14 | use embassy_stm32::spi; |
| @@ -38,14 +37,6 @@ async fn main_task(mut spi: spi::Spi<'static, SPI3, NoDma, NoDma>) { | |||
| 38 | } | 37 | } |
| 39 | } | 38 | } |
| 40 | 39 | ||
| 41 | struct ZeroClock; | ||
| 42 | |||
| 43 | impl Clock for ZeroClock { | ||
| 44 | fn now(&self) -> u64 { | ||
| 45 | 0 | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | static EXECUTOR: Forever<Executor> = Forever::new(); | 40 | static EXECUTOR: Forever<Executor> = Forever::new(); |
| 50 | 41 | ||
| 51 | #[entry] | 42 | #[entry] |
| @@ -69,7 +60,6 @@ fn main() -> ! { | |||
| 69 | spi::Config::default(), | 60 | spi::Config::default(), |
| 70 | ); | 61 | ); |
| 71 | 62 | ||
| 72 | unsafe { embassy::time::set_clock(&ZeroClock) }; | ||
| 73 | let executor = EXECUTOR.put(Executor::new()); | 63 | let executor = EXECUTOR.put(Executor::new()); |
| 74 | 64 | ||
| 75 | executor.run(|spawner| { | 65 | executor.run(|spawner| { |
diff --git a/examples/stm32h7/src/bin/spi_dma.rs b/examples/stm32h7/src/bin/spi_dma.rs index 3b9043bc2..f11b7eb45 100644 --- a/examples/stm32h7/src/bin/spi_dma.rs +++ b/examples/stm32h7/src/bin/spi_dma.rs | |||
| @@ -9,7 +9,6 @@ mod example_common; | |||
| 9 | 9 | ||
| 10 | use core::fmt::Write; | 10 | use core::fmt::Write; |
| 11 | use embassy::executor::Executor; | 11 | use embassy::executor::Executor; |
| 12 | use embassy::time::Clock; | ||
| 13 | use embassy::util::Forever; | 12 | use embassy::util::Forever; |
| 14 | use embassy_stm32::time::U32Ext; | 13 | use embassy_stm32::time::U32Ext; |
| 15 | use embassy_traits::spi::FullDuplex; | 14 | use embassy_traits::spi::FullDuplex; |
| @@ -34,14 +33,6 @@ async fn main_task(mut spi: spi::Spi<'static, SPI3, DMA1_CH3, DMA1_CH4>) { | |||
| 34 | } | 33 | } |
| 35 | } | 34 | } |
| 36 | 35 | ||
| 37 | struct ZeroClock; | ||
| 38 | |||
| 39 | impl Clock for ZeroClock { | ||
| 40 | fn now(&self) -> u64 { | ||
| 41 | 0 | ||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 45 | static EXECUTOR: Forever<Executor> = Forever::new(); | 36 | static EXECUTOR: Forever<Executor> = Forever::new(); |
| 46 | 37 | ||
| 47 | #[entry] | 38 | #[entry] |
| @@ -65,7 +56,6 @@ fn main() -> ! { | |||
| 65 | spi::Config::default(), | 56 | spi::Config::default(), |
| 66 | ); | 57 | ); |
| 67 | 58 | ||
| 68 | unsafe { embassy::time::set_clock(&ZeroClock) }; | ||
| 69 | let executor = EXECUTOR.put(Executor::new()); | 59 | let executor = EXECUTOR.put(Executor::new()); |
| 70 | 60 | ||
| 71 | executor.run(|spawner| { | 61 | executor.run(|spawner| { |
diff --git a/examples/stm32h7/src/bin/usart.rs b/examples/stm32h7/src/bin/usart.rs index 5fa21b6a2..9c93d3f22 100644 --- a/examples/stm32h7/src/bin/usart.rs +++ b/examples/stm32h7/src/bin/usart.rs | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | mod example_common; | 8 | mod example_common; |
| 9 | use cortex_m::prelude::_embedded_hal_blocking_serial_Write; | 9 | use cortex_m::prelude::_embedded_hal_blocking_serial_Write; |
| 10 | use embassy::executor::Executor; | 10 | use embassy::executor::Executor; |
| 11 | use embassy::time::Clock; | ||
| 12 | use embassy::util::Forever; | 11 | use embassy::util::Forever; |
| 13 | use embassy_stm32::dma::NoDma; | 12 | use embassy_stm32::dma::NoDma; |
| 14 | use embassy_stm32::usart::{Config, Uart}; | 13 | use embassy_stm32::usart::{Config, Uart}; |
| @@ -34,14 +33,6 @@ async fn main_task() { | |||
| 34 | } | 33 | } |
| 35 | } | 34 | } |
| 36 | 35 | ||
| 37 | struct ZeroClock; | ||
| 38 | |||
| 39 | impl Clock for ZeroClock { | ||
| 40 | fn now(&self) -> u64 { | ||
| 41 | 0 | ||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 45 | static EXECUTOR: Forever<Executor> = Forever::new(); | 36 | static EXECUTOR: Forever<Executor> = Forever::new(); |
| 46 | 37 | ||
| 47 | #[entry] | 38 | #[entry] |
| @@ -52,8 +43,6 @@ fn main() -> ! { | |||
| 52 | Dbgmcu::enable_all(); | 43 | Dbgmcu::enable_all(); |
| 53 | } | 44 | } |
| 54 | 45 | ||
| 55 | unsafe { embassy::time::set_clock(&ZeroClock) }; | ||
| 56 | |||
| 57 | let executor = EXECUTOR.put(Executor::new()); | 46 | let executor = EXECUTOR.put(Executor::new()); |
| 58 | 47 | ||
| 59 | executor.run(|spawner| { | 48 | executor.run(|spawner| { |
diff --git a/examples/stm32h7/src/bin/usart_dma.rs b/examples/stm32h7/src/bin/usart_dma.rs index 26cc3c5da..3f70a82b0 100644 --- a/examples/stm32h7/src/bin/usart_dma.rs +++ b/examples/stm32h7/src/bin/usart_dma.rs | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | mod example_common; | 8 | mod example_common; |
| 9 | use core::fmt::Write; | 9 | use core::fmt::Write; |
| 10 | use embassy::executor::Executor; | 10 | use embassy::executor::Executor; |
| 11 | use embassy::time::Clock; | ||
| 12 | use embassy::util::Forever; | 11 | use embassy::util::Forever; |
| 13 | use embassy_stm32::dbgmcu::Dbgmcu; | 12 | use embassy_stm32::dbgmcu::Dbgmcu; |
| 14 | use embassy_stm32::dma::NoDma; | 13 | use embassy_stm32::dma::NoDma; |
| @@ -36,14 +35,6 @@ async fn main_task() { | |||
| 36 | } | 35 | } |
| 37 | } | 36 | } |
| 38 | 37 | ||
| 39 | struct ZeroClock; | ||
| 40 | |||
| 41 | impl Clock for ZeroClock { | ||
| 42 | fn now(&self) -> u64 { | ||
| 43 | 0 | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 | static EXECUTOR: Forever<Executor> = Forever::new(); | 38 | static EXECUTOR: Forever<Executor> = Forever::new(); |
| 48 | 39 | ||
| 49 | #[entry] | 40 | #[entry] |
| @@ -54,8 +45,6 @@ fn main() -> ! { | |||
| 54 | Dbgmcu::enable_all(); | 45 | Dbgmcu::enable_all(); |
| 55 | } | 46 | } |
| 56 | 47 | ||
| 57 | unsafe { embassy::time::set_clock(&ZeroClock) }; | ||
| 58 | |||
| 59 | let executor = EXECUTOR.put(Executor::new()); | 48 | let executor = EXECUTOR.put(Executor::new()); |
| 60 | 49 | ||
| 61 | executor.run(|spawner| { | 50 | executor.run(|spawner| { |
diff --git a/examples/stm32l0/src/bin/blinky.rs b/examples/stm32l0/src/bin/blinky.rs index 27060edca..faa42896b 100644 --- a/examples/stm32l0/src/bin/blinky.rs +++ b/examples/stm32l0/src/bin/blinky.rs | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | #[path = "../example_common.rs"] | 7 | #[path = "../example_common.rs"] |
| 8 | mod example_common; | 8 | mod example_common; |
| 9 | 9 | ||
| 10 | use defmt::panic; | ||
| 11 | use embassy::executor::Spawner; | 10 | use embassy::executor::Spawner; |
| 12 | use embassy::time::{Duration, Timer}; | 11 | use embassy::time::{Duration, Timer}; |
| 13 | use embassy_stm32::gpio::{Level, Output, Speed}; | 12 | use embassy_stm32::gpio::{Level, Output, Speed}; |
diff --git a/examples/stm32l0/src/bin/button_exti.rs b/examples/stm32l0/src/bin/button_exti.rs index 9f0b0bde6..40e25b088 100644 --- a/examples/stm32l0/src/bin/button_exti.rs +++ b/examples/stm32l0/src/bin/button_exti.rs | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | #[path = "../example_common.rs"] | 7 | #[path = "../example_common.rs"] |
| 8 | mod example_common; | 8 | mod example_common; |
| 9 | 9 | ||
| 10 | use defmt::panic; | ||
| 11 | use embassy::executor::Spawner; | 10 | use embassy::executor::Spawner; |
| 12 | use embassy_stm32::exti::ExtiInput; | 11 | use embassy_stm32::exti::ExtiInput; |
| 13 | use embassy_stm32::gpio::{Input, Pull}; | 12 | use embassy_stm32::gpio::{Input, Pull}; |
diff --git a/examples/stm32l0/src/bin/usart_dma.rs b/examples/stm32l0/src/bin/usart_dma.rs index 2c0690d0e..39a605174 100644 --- a/examples/stm32l0/src/bin/usart_dma.rs +++ b/examples/stm32l0/src/bin/usart_dma.rs | |||
| @@ -9,7 +9,6 @@ mod example_common; | |||
| 9 | 9 | ||
| 10 | use example_common::*; | 10 | use example_common::*; |
| 11 | 11 | ||
| 12 | use defmt::panic; | ||
| 13 | use embassy::executor::Spawner; | 12 | use embassy::executor::Spawner; |
| 14 | use embassy_stm32::usart::{Config, Uart}; | 13 | use embassy_stm32::usart::{Config, Uart}; |
| 15 | use embassy_stm32::{rcc, Peripherals}; | 14 | use embassy_stm32::{rcc, Peripherals}; |
diff --git a/examples/stm32l4/src/bin/blinky.rs b/examples/stm32l4/src/bin/blinky.rs index c929335dc..fc86b11eb 100644 --- a/examples/stm32l4/src/bin/blinky.rs +++ b/examples/stm32l4/src/bin/blinky.rs | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | 6 | ||
| 7 | #[path = "../example_common.rs"] | 7 | #[path = "../example_common.rs"] |
| 8 | mod example_common; | 8 | mod example_common; |
| 9 | use defmt::panic; | ||
| 10 | use embassy::executor::Spawner; | 9 | use embassy::executor::Spawner; |
| 11 | use embassy::time::{Duration, Timer}; | 10 | use embassy::time::{Duration, Timer}; |
| 12 | use embassy_stm32::dbgmcu::Dbgmcu; | 11 | use embassy_stm32::dbgmcu::Dbgmcu; |
diff --git a/examples/stm32l4/src/bin/button_exti.rs b/examples/stm32l4/src/bin/button_exti.rs index a702b5ba1..8a78b2589 100644 --- a/examples/stm32l4/src/bin/button_exti.rs +++ b/examples/stm32l4/src/bin/button_exti.rs | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | 6 | ||
| 7 | #[path = "../example_common.rs"] | 7 | #[path = "../example_common.rs"] |
| 8 | mod example_common; | 8 | mod example_common; |
| 9 | use defmt::panic; | ||
| 10 | use embassy::executor::Spawner; | 9 | use embassy::executor::Spawner; |
| 11 | use embassy_stm32::dbgmcu::Dbgmcu; | 10 | use embassy_stm32::dbgmcu::Dbgmcu; |
| 12 | use embassy_stm32::exti::ExtiInput; | 11 | use embassy_stm32::exti::ExtiInput; |
diff --git a/examples/stm32l4/src/bin/spi_dma.rs b/examples/stm32l4/src/bin/spi_dma.rs index aa0762589..ba77331be 100644 --- a/examples/stm32l4/src/bin/spi_dma.rs +++ b/examples/stm32l4/src/bin/spi_dma.rs | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | #[path = "../example_common.rs"] | 7 | #[path = "../example_common.rs"] |
| 8 | mod example_common; | 8 | mod example_common; |
| 9 | 9 | ||
| 10 | use defmt::panic; | ||
| 11 | use embassy::executor::Spawner; | 10 | use embassy::executor::Spawner; |
| 12 | use embassy_stm32::dbgmcu::Dbgmcu; | 11 | use embassy_stm32::dbgmcu::Dbgmcu; |
| 13 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 12 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
diff --git a/examples/stm32l4/src/bin/usart_dma.rs b/examples/stm32l4/src/bin/usart_dma.rs index b15bba76e..f74a0e06b 100644 --- a/examples/stm32l4/src/bin/usart_dma.rs +++ b/examples/stm32l4/src/bin/usart_dma.rs | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | #[path = "../example_common.rs"] | 7 | #[path = "../example_common.rs"] |
| 8 | mod example_common; | 8 | mod example_common; |
| 9 | use core::fmt::Write; | 9 | use core::fmt::Write; |
| 10 | use defmt::panic; | ||
| 11 | use embassy::executor::Spawner; | 10 | use embassy::executor::Spawner; |
| 12 | use embassy_stm32::dbgmcu::Dbgmcu; | 11 | use embassy_stm32::dbgmcu::Dbgmcu; |
| 13 | use embassy_stm32::dma::NoDma; | 12 | use embassy_stm32::dma::NoDma; |
