diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-03-26 16:01:37 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2025-03-27 15:18:06 +0100 |
| commit | d41eeeae79388f219bf6a84e2f7bde9f6b532516 (patch) | |
| tree | 678b6fc732216e529dc38e6f65b72a309917ac32 /examples/nrf52840 | |
| parent | 9edf5b7f049f95742b60b041e4443967d8a6b708 (diff) | |
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'examples/nrf52840')
| -rw-r--r-- | examples/nrf52840/src/bin/channel_sender_receiver.rs | 7 | ||||
| -rw-r--r-- | examples/nrf52840/src/bin/pdm_continuous.rs | 4 | ||||
| -rw-r--r-- | examples/nrf52840/src/bin/qspi_lowpower.rs | 14 | ||||
| -rw-r--r-- | examples/nrf52840/src/bin/saadc.rs | 2 | ||||
| -rw-r--r-- | examples/nrf52840/src/bin/saadc_continuous.rs | 12 | ||||
| -rw-r--r-- | examples/nrf52840/src/bin/twim_lowpower.rs | 8 |
6 files changed, 27 insertions, 20 deletions
diff --git a/examples/nrf52840/src/bin/channel_sender_receiver.rs b/examples/nrf52840/src/bin/channel_sender_receiver.rs index 29f70f91c..74c62ca20 100644 --- a/examples/nrf52840/src/bin/channel_sender_receiver.rs +++ b/examples/nrf52840/src/bin/channel_sender_receiver.rs | |||
| @@ -3,7 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::unwrap; | 4 | use defmt::unwrap; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin}; | 6 | use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive}; |
| 7 | use embassy_nrf::Peri; | ||
| 7 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | 8 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; |
| 8 | use embassy_sync::channel::{Channel, Receiver, Sender}; | 9 | use embassy_sync::channel::{Channel, Receiver, Sender}; |
| 9 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| @@ -28,7 +29,7 @@ async fn send_task(sender: Sender<'static, NoopRawMutex, LedState, 1>) { | |||
| 28 | } | 29 | } |
| 29 | 30 | ||
| 30 | #[embassy_executor::task] | 31 | #[embassy_executor::task] |
| 31 | async fn recv_task(led: AnyPin, receiver: Receiver<'static, NoopRawMutex, LedState, 1>) { | 32 | async fn recv_task(led: Peri<'static, AnyPin>, receiver: Receiver<'static, NoopRawMutex, LedState, 1>) { |
| 32 | let mut led = Output::new(led, Level::Low, OutputDrive::Standard); | 33 | let mut led = Output::new(led, Level::Low, OutputDrive::Standard); |
| 33 | 34 | ||
| 34 | loop { | 35 | loop { |
| @@ -45,5 +46,5 @@ async fn main(spawner: Spawner) { | |||
| 45 | let channel = CHANNEL.init(Channel::new()); | 46 | let channel = CHANNEL.init(Channel::new()); |
| 46 | 47 | ||
| 47 | unwrap!(spawner.spawn(send_task(channel.sender()))); | 48 | unwrap!(spawner.spawn(send_task(channel.sender()))); |
| 48 | unwrap!(spawner.spawn(recv_task(p.P0_13.degrade(), channel.receiver()))); | 49 | unwrap!(spawner.spawn(recv_task(p.P0_13.into(), channel.receiver()))); |
| 49 | } | 50 | } |
diff --git a/examples/nrf52840/src/bin/pdm_continuous.rs b/examples/nrf52840/src/bin/pdm_continuous.rs index e948203a5..0d76636b0 100644 --- a/examples/nrf52840/src/bin/pdm_continuous.rs +++ b/examples/nrf52840/src/bin/pdm_continuous.rs | |||
| @@ -20,14 +20,14 @@ bind_interrupts!(struct Irqs { | |||
| 20 | 20 | ||
| 21 | #[embassy_executor::main] | 21 | #[embassy_executor::main] |
| 22 | async fn main(_p: Spawner) { | 22 | async fn main(_p: Spawner) { |
| 23 | let mut p = embassy_nrf::init(Default::default()); | 23 | let p = embassy_nrf::init(Default::default()); |
| 24 | let mut config = Config::default(); | 24 | let mut config = Config::default(); |
| 25 | // Pins are correct for the onboard microphone on the Feather nRF52840 Sense. | 25 | // Pins are correct for the onboard microphone on the Feather nRF52840 Sense. |
| 26 | config.frequency = Frequency::_1280K; // 16 kHz sample rate | 26 | config.frequency = Frequency::_1280K; // 16 kHz sample rate |
| 27 | config.ratio = Ratio::RATIO80; | 27 | config.ratio = Ratio::RATIO80; |
| 28 | config.operation_mode = OperationMode::Mono; | 28 | config.operation_mode = OperationMode::Mono; |
| 29 | config.gain_left = I7F1::from_bits(5); // 2.5 dB | 29 | config.gain_left = I7F1::from_bits(5); // 2.5 dB |
| 30 | let mut pdm = Pdm::new(p.PDM, Irqs, &mut p.P0_00, &mut p.P0_01, config); | 30 | let mut pdm = Pdm::new(p.PDM, Irqs, p.P0_00, p.P0_01, config); |
| 31 | 31 | ||
| 32 | let mut bufs = [[0; 1024]; 2]; | 32 | let mut bufs = [[0; 1024]; 2]; |
| 33 | 33 | ||
diff --git a/examples/nrf52840/src/bin/qspi_lowpower.rs b/examples/nrf52840/src/bin/qspi_lowpower.rs index 516c9b481..238a0d941 100644 --- a/examples/nrf52840/src/bin/qspi_lowpower.rs +++ b/examples/nrf52840/src/bin/qspi_lowpower.rs | |||
| @@ -37,14 +37,14 @@ async fn main(_p: Spawner) { | |||
| 37 | }); | 37 | }); |
| 38 | 38 | ||
| 39 | let mut q = qspi::Qspi::new( | 39 | let mut q = qspi::Qspi::new( |
| 40 | &mut p.QSPI, | 40 | p.QSPI.reborrow(), |
| 41 | Irqs, | 41 | Irqs, |
| 42 | &mut p.P0_19, | 42 | p.P0_19.reborrow(), |
| 43 | &mut p.P0_17, | 43 | p.P0_17.reborrow(), |
| 44 | &mut p.P0_20, | 44 | p.P0_20.reborrow(), |
| 45 | &mut p.P0_21, | 45 | p.P0_21.reborrow(), |
| 46 | &mut p.P0_22, | 46 | p.P0_22.reborrow(), |
| 47 | &mut p.P0_23, | 47 | p.P0_23.reborrow(), |
| 48 | config, | 48 | config, |
| 49 | ); | 49 | ); |
| 50 | 50 | ||
diff --git a/examples/nrf52840/src/bin/saadc.rs b/examples/nrf52840/src/bin/saadc.rs index 653b7d606..cf2d860ab 100644 --- a/examples/nrf52840/src/bin/saadc.rs +++ b/examples/nrf52840/src/bin/saadc.rs | |||
| @@ -16,7 +16,7 @@ bind_interrupts!(struct Irqs { | |||
| 16 | async fn main(_p: Spawner) { | 16 | async fn main(_p: Spawner) { |
| 17 | let mut p = embassy_nrf::init(Default::default()); | 17 | let mut p = embassy_nrf::init(Default::default()); |
| 18 | let config = Config::default(); | 18 | let config = Config::default(); |
| 19 | let channel_config = ChannelConfig::single_ended(&mut p.P0_02); | 19 | let channel_config = ChannelConfig::single_ended(p.P0_02.reborrow()); |
| 20 | let mut saadc = Saadc::new(p.SAADC, Irqs, config, [channel_config]); | 20 | let mut saadc = Saadc::new(p.SAADC, Irqs, config, [channel_config]); |
| 21 | 21 | ||
| 22 | loop { | 22 | loop { |
diff --git a/examples/nrf52840/src/bin/saadc_continuous.rs b/examples/nrf52840/src/bin/saadc_continuous.rs index f76fa3570..e8f169c8c 100644 --- a/examples/nrf52840/src/bin/saadc_continuous.rs +++ b/examples/nrf52840/src/bin/saadc_continuous.rs | |||
| @@ -18,9 +18,9 @@ bind_interrupts!(struct Irqs { | |||
| 18 | async fn main(_p: Spawner) { | 18 | async fn main(_p: Spawner) { |
| 19 | let mut p = embassy_nrf::init(Default::default()); | 19 | let mut p = embassy_nrf::init(Default::default()); |
| 20 | let config = Config::default(); | 20 | let config = Config::default(); |
| 21 | let channel_1_config = ChannelConfig::single_ended(&mut p.P0_02); | 21 | let channel_1_config = ChannelConfig::single_ended(p.P0_02.reborrow()); |
| 22 | let channel_2_config = ChannelConfig::single_ended(&mut p.P0_03); | 22 | let channel_2_config = ChannelConfig::single_ended(p.P0_03.reborrow()); |
| 23 | let channel_3_config = ChannelConfig::single_ended(&mut p.P0_04); | 23 | let channel_3_config = ChannelConfig::single_ended(p.P0_04.reborrow()); |
| 24 | let mut saadc = Saadc::new( | 24 | let mut saadc = Saadc::new( |
| 25 | p.SAADC, | 25 | p.SAADC, |
| 26 | Irqs, | 26 | Irqs, |
| @@ -40,9 +40,9 @@ async fn main(_p: Spawner) { | |||
| 40 | 40 | ||
| 41 | saadc | 41 | saadc |
| 42 | .run_task_sampler( | 42 | .run_task_sampler( |
| 43 | &mut p.TIMER0, | 43 | p.TIMER0.reborrow(), |
| 44 | &mut p.PPI_CH0, | 44 | p.PPI_CH0.reborrow(), |
| 45 | &mut p.PPI_CH1, | 45 | p.PPI_CH1.reborrow(), |
| 46 | Frequency::F1MHz, | 46 | Frequency::F1MHz, |
| 47 | 1000, // We want to sample at 1KHz | 47 | 1000, // We want to sample at 1KHz |
| 48 | &mut bufs, | 48 | &mut bufs, |
diff --git a/examples/nrf52840/src/bin/twim_lowpower.rs b/examples/nrf52840/src/bin/twim_lowpower.rs index e2efbdd8d..8a6f958eb 100644 --- a/examples/nrf52840/src/bin/twim_lowpower.rs +++ b/examples/nrf52840/src/bin/twim_lowpower.rs | |||
| @@ -32,7 +32,13 @@ async fn main(_p: Spawner) { | |||
| 32 | let config = twim::Config::default(); | 32 | let config = twim::Config::default(); |
| 33 | 33 | ||
| 34 | // Create the TWIM instance with borrowed singletons, so they're not consumed. | 34 | // Create the TWIM instance with borrowed singletons, so they're not consumed. |
| 35 | let mut twi = Twim::new(&mut p.TWISPI0, Irqs, &mut p.P0_03, &mut p.P0_04, config); | 35 | let mut twi = Twim::new( |
| 36 | p.TWISPI0.reborrow(), | ||
| 37 | Irqs, | ||
| 38 | p.P0_03.reborrow(), | ||
| 39 | p.P0_04.reborrow(), | ||
| 40 | config, | ||
| 41 | ); | ||
| 36 | 42 | ||
| 37 | info!("Reading..."); | 43 | info!("Reading..."); |
| 38 | 44 | ||
