diff options
Diffstat (limited to 'examples/nrf/src')
| -rw-r--r-- | examples/nrf/src/bin/blinky.rs | 1 | ||||
| -rw-r--r-- | examples/nrf/src/bin/executor_fairness_test.rs | 3 | ||||
| -rw-r--r-- | examples/nrf/src/bin/gpiote_channel.rs | 3 | ||||
| -rw-r--r-- | examples/nrf/src/bin/gpiote_port.rs | 2 | ||||
| -rw-r--r-- | examples/nrf/src/bin/mpsc.rs | 1 | ||||
| -rw-r--r-- | examples/nrf/src/bin/multiprio.rs | 18 | ||||
| -rw-r--r-- | examples/nrf/src/bin/ppi.rs | 3 | ||||
| -rw-r--r-- | examples/nrf/src/bin/pwm.rs | 4 | ||||
| -rw-r--r-- | examples/nrf/src/bin/raw_spawn.rs | 15 | ||||
| -rw-r--r-- | examples/nrf/src/bin/timer.rs | 1 |
10 files changed, 9 insertions, 42 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 | ||
