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/rp235x/src/bin | |
| parent | 9edf5b7f049f95742b60b041e4443967d8a6b708 (diff) | |
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'examples/rp235x/src/bin')
| -rw-r--r-- | examples/rp235x/src/bin/adc_dma.rs | 4 | ||||
| -rw-r--r-- | examples/rp235x/src/bin/assign_resources.rs | 7 | ||||
| -rw-r--r-- | examples/rp235x/src/bin/blinky_two_channels.rs | 4 | ||||
| -rw-r--r-- | examples/rp235x/src/bin/blinky_two_tasks.rs | 4 | ||||
| -rw-r--r-- | examples/rp235x/src/bin/pio_async.rs | 4 | ||||
| -rw-r--r-- | examples/rp235x/src/bin/pio_dma.rs | 6 | ||||
| -rw-r--r-- | examples/rp235x/src/bin/pio_rotary_encoder_rxf.rs | 6 | ||||
| -rw-r--r-- | examples/rp235x/src/bin/pwm.rs | 5 | ||||
| -rw-r--r-- | examples/rp235x/src/bin/pwm_tb6612fng_motor_driver.rs | 2 | ||||
| -rw-r--r-- | examples/rp235x/src/bin/shared_bus.rs | 6 | ||||
| -rw-r--r-- | examples/rp235x/src/bin/zerocopy.rs | 9 |
11 files changed, 33 insertions, 24 deletions
diff --git a/examples/rp235x/src/bin/adc_dma.rs b/examples/rp235x/src/bin/adc_dma.rs index f755cf5bf..b42c13fde 100644 --- a/examples/rp235x/src/bin/adc_dma.rs +++ b/examples/rp235x/src/bin/adc_dma.rs | |||
| @@ -38,13 +38,13 @@ async fn main(_spawner: Spawner) { | |||
| 38 | // Read 100 samples from a single channel | 38 | // Read 100 samples from a single channel |
| 39 | let mut buf = [0_u16; BLOCK_SIZE]; | 39 | let mut buf = [0_u16; BLOCK_SIZE]; |
| 40 | let div = 479; // 100kHz sample rate (48Mhz / 100kHz - 1) | 40 | let div = 479; // 100kHz sample rate (48Mhz / 100kHz - 1) |
| 41 | adc.read_many(&mut pin, &mut buf, div, &mut dma).await.unwrap(); | 41 | adc.read_many(&mut pin, &mut buf, div, dma.reborrow()).await.unwrap(); |
| 42 | info!("single: {:?} ...etc", buf[..8]); | 42 | info!("single: {:?} ...etc", buf[..8]); |
| 43 | 43 | ||
| 44 | // Read 100 samples from 4 channels interleaved | 44 | // Read 100 samples from 4 channels interleaved |
| 45 | let mut buf = [0_u16; { BLOCK_SIZE * NUM_CHANNELS }]; | 45 | let mut buf = [0_u16; { BLOCK_SIZE * NUM_CHANNELS }]; |
| 46 | let div = 119; // 100kHz sample rate (48Mhz / 100kHz * 4ch - 1) | 46 | let div = 119; // 100kHz sample rate (48Mhz / 100kHz * 4ch - 1) |
| 47 | adc.read_many_multichannel(&mut pins, &mut buf, div, &mut dma) | 47 | adc.read_many_multichannel(&mut pins, &mut buf, div, dma.reborrow()) |
| 48 | .await | 48 | .await |
| 49 | .unwrap(); | 49 | .unwrap(); |
| 50 | info!("multi: {:?} ...etc", buf[..NUM_CHANNELS * 2]); | 50 | info!("multi: {:?} ...etc", buf[..NUM_CHANNELS * 2]); |
diff --git a/examples/rp235x/src/bin/assign_resources.rs b/examples/rp235x/src/bin/assign_resources.rs index ff6eff4a2..341f54d22 100644 --- a/examples/rp235x/src/bin/assign_resources.rs +++ b/examples/rp235x/src/bin/assign_resources.rs | |||
| @@ -16,6 +16,7 @@ use defmt::*; | |||
| 16 | use embassy_executor::Spawner; | 16 | use embassy_executor::Spawner; |
| 17 | use embassy_rp::gpio::{Level, Output}; | 17 | use embassy_rp::gpio::{Level, Output}; |
| 18 | use embassy_rp::peripherals::{self, PIN_20, PIN_21}; | 18 | use embassy_rp::peripherals::{self, PIN_20, PIN_21}; |
| 19 | use embassy_rp::Peri; | ||
| 19 | use embassy_time::Timer; | 20 | use embassy_time::Timer; |
| 20 | use {defmt_rtt as _, panic_probe as _}; | 21 | use {defmt_rtt as _, panic_probe as _}; |
| 21 | 22 | ||
| @@ -38,7 +39,11 @@ async fn main(spawner: Spawner) { | |||
| 38 | 39 | ||
| 39 | // 1) Assigning a resource to a task by passing parts of the peripherals. | 40 | // 1) Assigning a resource to a task by passing parts of the peripherals. |
| 40 | #[embassy_executor::task] | 41 | #[embassy_executor::task] |
| 41 | async fn double_blinky_manually_assigned(_spawner: Spawner, pin_20: PIN_20, pin_21: PIN_21) { | 42 | async fn double_blinky_manually_assigned( |
| 43 | _spawner: Spawner, | ||
| 44 | pin_20: Peri<'static, PIN_20>, | ||
| 45 | pin_21: Peri<'static, PIN_21>, | ||
| 46 | ) { | ||
| 42 | let mut led_20 = Output::new(pin_20, Level::Low); | 47 | let mut led_20 = Output::new(pin_20, Level::Low); |
| 43 | let mut led_21 = Output::new(pin_21, Level::High); | 48 | let mut led_21 = Output::new(pin_21, Level::High); |
| 44 | 49 | ||
diff --git a/examples/rp235x/src/bin/blinky_two_channels.rs b/examples/rp235x/src/bin/blinky_two_channels.rs index b2eec2a21..51e139e94 100644 --- a/examples/rp235x/src/bin/blinky_two_channels.rs +++ b/examples/rp235x/src/bin/blinky_two_channels.rs | |||
| @@ -11,7 +11,7 @@ use embassy_rp::gpio; | |||
| 11 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; | 11 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; |
| 12 | use embassy_sync::channel::{Channel, Sender}; | 12 | use embassy_sync::channel::{Channel, Sender}; |
| 13 | use embassy_time::{Duration, Ticker}; | 13 | use embassy_time::{Duration, Ticker}; |
| 14 | use gpio::{AnyPin, Level, Output}; | 14 | use gpio::{Level, Output}; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 16 | ||
| 17 | enum LedState { | 17 | enum LedState { |
| @@ -22,7 +22,7 @@ static CHANNEL: Channel<ThreadModeRawMutex, LedState, 64> = Channel::new(); | |||
| 22 | #[embassy_executor::main] | 22 | #[embassy_executor::main] |
| 23 | async fn main(spawner: Spawner) { | 23 | async fn main(spawner: Spawner) { |
| 24 | let p = embassy_rp::init(Default::default()); | 24 | let p = embassy_rp::init(Default::default()); |
| 25 | let mut led = Output::new(AnyPin::from(p.PIN_25), Level::High); | 25 | let mut led = Output::new(p.PIN_25, Level::High); |
| 26 | 26 | ||
| 27 | let dt = 100 * 1_000_000; | 27 | let dt = 100 * 1_000_000; |
| 28 | let k = 1.003; | 28 | let k = 1.003; |
diff --git a/examples/rp235x/src/bin/blinky_two_tasks.rs b/examples/rp235x/src/bin/blinky_two_tasks.rs index a57b513d6..67a9108c0 100644 --- a/examples/rp235x/src/bin/blinky_two_tasks.rs +++ b/examples/rp235x/src/bin/blinky_two_tasks.rs | |||
| @@ -11,7 +11,7 @@ use embassy_rp::gpio; | |||
| 11 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; | 11 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; |
| 12 | use embassy_sync::mutex::Mutex; | 12 | use embassy_sync::mutex::Mutex; |
| 13 | use embassy_time::{Duration, Ticker}; | 13 | use embassy_time::{Duration, Ticker}; |
| 14 | use gpio::{AnyPin, Level, Output}; | 14 | use gpio::{Level, Output}; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 16 | ||
| 17 | type LedType = Mutex<ThreadModeRawMutex, Option<Output<'static>>>; | 17 | type LedType = Mutex<ThreadModeRawMutex, Option<Output<'static>>>; |
| @@ -21,7 +21,7 @@ static LED: LedType = Mutex::new(None); | |||
| 21 | async fn main(spawner: Spawner) { | 21 | async fn main(spawner: Spawner) { |
| 22 | let p = embassy_rp::init(Default::default()); | 22 | let p = embassy_rp::init(Default::default()); |
| 23 | // set the content of the global LED reference to the real LED pin | 23 | // set the content of the global LED reference to the real LED pin |
| 24 | let led = Output::new(AnyPin::from(p.PIN_25), Level::High); | 24 | let led = Output::new(p.PIN_25, Level::High); |
| 25 | // inner scope is so that once the mutex is written to, the MutexGuard is dropped, thus the | 25 | // inner scope is so that once the mutex is written to, the MutexGuard is dropped, thus the |
| 26 | // Mutex is released | 26 | // Mutex is released |
| 27 | { | 27 | { |
diff --git a/examples/rp235x/src/bin/pio_async.rs b/examples/rp235x/src/bin/pio_async.rs index 08c702347..baf567b58 100644 --- a/examples/rp235x/src/bin/pio_async.rs +++ b/examples/rp235x/src/bin/pio_async.rs | |||
| @@ -4,10 +4,10 @@ | |||
| 4 | #![no_main] | 4 | #![no_main] |
| 5 | use defmt::info; | 5 | use defmt::info; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_rp::bind_interrupts; | ||
| 8 | use embassy_rp::peripherals::PIO0; | 7 | use embassy_rp::peripherals::PIO0; |
| 9 | use embassy_rp::pio::program::pio_asm; | 8 | use embassy_rp::pio::program::pio_asm; |
| 10 | use embassy_rp::pio::{Common, Config, InterruptHandler, Irq, Pio, PioPin, ShiftDirection, StateMachine}; | 9 | use embassy_rp::pio::{Common, Config, InterruptHandler, Irq, Pio, PioPin, ShiftDirection, StateMachine}; |
| 10 | use embassy_rp::{bind_interrupts, Peri}; | ||
| 11 | use fixed::traits::ToFixed; | 11 | use fixed::traits::ToFixed; |
| 12 | use fixed_macro::types::U56F8; | 12 | use fixed_macro::types::U56F8; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -16,7 +16,7 @@ bind_interrupts!(struct Irqs { | |||
| 16 | PIO0_IRQ_0 => InterruptHandler<PIO0>; | 16 | PIO0_IRQ_0 => InterruptHandler<PIO0>; |
| 17 | }); | 17 | }); |
| 18 | 18 | ||
| 19 | fn setup_pio_task_sm0<'a>(pio: &mut Common<'a, PIO0>, sm: &mut StateMachine<'a, PIO0, 0>, pin: impl PioPin) { | 19 | fn setup_pio_task_sm0<'a>(pio: &mut Common<'a, PIO0>, sm: &mut StateMachine<'a, PIO0, 0>, pin: Peri<'a, impl PioPin>) { |
| 20 | // Setup sm0 | 20 | // Setup sm0 |
| 21 | 21 | ||
| 22 | // Send data serially to pin | 22 | // Send data serially to pin |
diff --git a/examples/rp235x/src/bin/pio_dma.rs b/examples/rp235x/src/bin/pio_dma.rs index da6e47a1b..64d603ba4 100644 --- a/examples/rp235x/src/bin/pio_dma.rs +++ b/examples/rp235x/src/bin/pio_dma.rs | |||
| @@ -5,10 +5,10 @@ | |||
| 5 | use defmt::info; | 5 | use defmt::info; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_futures::join::join; | 7 | use embassy_futures::join::join; |
| 8 | use embassy_rp::bind_interrupts; | ||
| 8 | use embassy_rp::peripherals::PIO0; | 9 | use embassy_rp::peripherals::PIO0; |
| 9 | use embassy_rp::pio::program::pio_asm; | 10 | use embassy_rp::pio::program::pio_asm; |
| 10 | use embassy_rp::pio::{Config, InterruptHandler, Pio, ShiftConfig, ShiftDirection}; | 11 | use embassy_rp::pio::{Config, InterruptHandler, Pio, ShiftConfig, ShiftDirection}; |
| 11 | use embassy_rp::{bind_interrupts, Peripheral}; | ||
| 12 | use fixed::traits::ToFixed; | 12 | use fixed::traits::ToFixed; |
| 13 | use fixed_macro::types::U56F8; | 13 | use fixed_macro::types::U56F8; |
| 14 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -62,8 +62,8 @@ async fn main(_spawner: Spawner) { | |||
| 62 | sm.set_config(&cfg); | 62 | sm.set_config(&cfg); |
| 63 | sm.set_enable(true); | 63 | sm.set_enable(true); |
| 64 | 64 | ||
| 65 | let mut dma_out_ref = p.DMA_CH0.into_ref(); | 65 | let mut dma_out_ref = p.DMA_CH0; |
| 66 | let mut dma_in_ref = p.DMA_CH1.into_ref(); | 66 | let mut dma_in_ref = p.DMA_CH1; |
| 67 | let mut dout = [0x12345678u32; 29]; | 67 | let mut dout = [0x12345678u32; 29]; |
| 68 | for i in 1..dout.len() { | 68 | for i in 1..dout.len() { |
| 69 | dout[i] = (dout[i - 1] & 0x0fff_ffff) * 13 + 7; | 69 | dout[i] = (dout[i - 1] & 0x0fff_ffff) * 13 + 7; |
diff --git a/examples/rp235x/src/bin/pio_rotary_encoder_rxf.rs b/examples/rp235x/src/bin/pio_rotary_encoder_rxf.rs index 0216c131b..ccc601661 100644 --- a/examples/rp235x/src/bin/pio_rotary_encoder_rxf.rs +++ b/examples/rp235x/src/bin/pio_rotary_encoder_rxf.rs | |||
| @@ -9,7 +9,7 @@ use embassy_executor::Spawner; | |||
| 9 | use embassy_rp::gpio::Pull; | 9 | use embassy_rp::gpio::Pull; |
| 10 | use embassy_rp::peripherals::PIO0; | 10 | use embassy_rp::peripherals::PIO0; |
| 11 | use embassy_rp::pio::program::pio_asm; | 11 | use embassy_rp::pio::program::pio_asm; |
| 12 | use embassy_rp::{bind_interrupts, pio}; | 12 | use embassy_rp::{bind_interrupts, pio, Peri}; |
| 13 | use embassy_time::Timer; | 13 | use embassy_time::Timer; |
| 14 | use fixed::traits::ToFixed; | 14 | use fixed::traits::ToFixed; |
| 15 | use pio::{Common, Config, FifoJoin, Instance, InterruptHandler, Pio, PioPin, ShiftDirection, StateMachine}; | 15 | use pio::{Common, Config, FifoJoin, Instance, InterruptHandler, Pio, PioPin, ShiftDirection, StateMachine}; |
| @@ -37,8 +37,8 @@ impl<'d, T: Instance, const SM: usize> PioEncoder<'d, T, SM> { | |||
| 37 | pub fn new( | 37 | pub fn new( |
| 38 | pio: &mut Common<'d, T>, | 38 | pio: &mut Common<'d, T>, |
| 39 | mut sm: StateMachine<'d, T, SM>, | 39 | mut sm: StateMachine<'d, T, SM>, |
| 40 | pin_a: impl PioPin, | 40 | pin_a: Peri<'d, impl PioPin>, |
| 41 | pin_b: impl PioPin, | 41 | pin_b: Peri<'d, impl PioPin>, |
| 42 | ) -> Self { | 42 | ) -> Self { |
| 43 | let mut pin_a = pio.make_pio_pin(pin_a); | 43 | let mut pin_a = pio.make_pio_pin(pin_a); |
| 44 | let mut pin_b = pio.make_pio_pin(pin_b); | 44 | let mut pin_b = pio.make_pio_pin(pin_b); |
diff --git a/examples/rp235x/src/bin/pwm.rs b/examples/rp235x/src/bin/pwm.rs index a3c0f7e49..da1acc18a 100644 --- a/examples/rp235x/src/bin/pwm.rs +++ b/examples/rp235x/src/bin/pwm.rs | |||
| @@ -11,6 +11,7 @@ use defmt::*; | |||
| 11 | use embassy_executor::Spawner; | 11 | use embassy_executor::Spawner; |
| 12 | use embassy_rp::peripherals::{PIN_25, PIN_4, PWM_SLICE2, PWM_SLICE4}; | 12 | use embassy_rp::peripherals::{PIN_25, PIN_4, PWM_SLICE2, PWM_SLICE4}; |
| 13 | use embassy_rp::pwm::{Config, Pwm, SetDutyCycle}; | 13 | use embassy_rp::pwm::{Config, Pwm, SetDutyCycle}; |
| 14 | use embassy_rp::Peri; | ||
| 14 | use embassy_time::Timer; | 15 | use embassy_time::Timer; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 17 | ||
| @@ -26,7 +27,7 @@ async fn main(spawner: Spawner) { | |||
| 26 | /// Using the onboard led, if You are using a different Board than plain Pico2 (i.e. W variant) | 27 | /// Using the onboard led, if You are using a different Board than plain Pico2 (i.e. W variant) |
| 27 | /// you must use another slice & pin and an appropriate resistor. | 28 | /// you must use another slice & pin and an appropriate resistor. |
| 28 | #[embassy_executor::task] | 29 | #[embassy_executor::task] |
| 29 | async fn pwm_set_config(slice4: PWM_SLICE4, pin25: PIN_25) { | 30 | async fn pwm_set_config(slice4: Peri<'static, PWM_SLICE4>, pin25: Peri<'static, PIN_25>) { |
| 30 | let mut c = Config::default(); | 31 | let mut c = Config::default(); |
| 31 | c.top = 32_768; | 32 | c.top = 32_768; |
| 32 | c.compare_b = 8; | 33 | c.compare_b = 8; |
| @@ -44,7 +45,7 @@ async fn pwm_set_config(slice4: PWM_SLICE4, pin25: PIN_25) { | |||
| 44 | /// | 45 | /// |
| 45 | /// Using GP4 in Slice2, make sure to use an appropriate resistor. | 46 | /// Using GP4 in Slice2, make sure to use an appropriate resistor. |
| 46 | #[embassy_executor::task] | 47 | #[embassy_executor::task] |
| 47 | async fn pwm_set_dutycycle(slice2: PWM_SLICE2, pin4: PIN_4) { | 48 | async fn pwm_set_dutycycle(slice2: Peri<'static, PWM_SLICE2>, pin4: Peri<'static, PIN_4>) { |
| 48 | // If we aim for a specific frequency, here is how we can calculate the top value. | 49 | // If we aim for a specific frequency, here is how we can calculate the top value. |
| 49 | // The top value sets the period of the PWM cycle, so a counter goes from 0 to top and then wraps around to 0. | 50 | // The top value sets the period of the PWM cycle, so a counter goes from 0 to top and then wraps around to 0. |
| 50 | // Every such wraparound is one PWM cycle. So here is how we get 25KHz: | 51 | // Every such wraparound is one PWM cycle. So here is how we get 25KHz: |
diff --git a/examples/rp235x/src/bin/pwm_tb6612fng_motor_driver.rs b/examples/rp235x/src/bin/pwm_tb6612fng_motor_driver.rs index 3b700884c..2cfb2038d 100644 --- a/examples/rp235x/src/bin/pwm_tb6612fng_motor_driver.rs +++ b/examples/rp235x/src/bin/pwm_tb6612fng_motor_driver.rs | |||
| @@ -10,7 +10,7 @@ use defmt::*; | |||
| 10 | use embassy_executor::Spawner; | 10 | use embassy_executor::Spawner; |
| 11 | use embassy_rp::config::Config; | 11 | use embassy_rp::config::Config; |
| 12 | use embassy_rp::gpio::Output; | 12 | use embassy_rp::gpio::Output; |
| 13 | use embassy_rp::{gpio, peripherals, pwm}; | 13 | use embassy_rp::{gpio, peripherals, pwm, Peri}; |
| 14 | use embassy_time::{Duration, Timer}; | 14 | use embassy_time::{Duration, Timer}; |
| 15 | use tb6612fng::{DriveCommand, Motor, Tb6612fng}; | 15 | use tb6612fng::{DriveCommand, Motor, Tb6612fng}; |
| 16 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
diff --git a/examples/rp235x/src/bin/shared_bus.rs b/examples/rp235x/src/bin/shared_bus.rs index c6cb5d64c..9267dfccb 100644 --- a/examples/rp235x/src/bin/shared_bus.rs +++ b/examples/rp235x/src/bin/shared_bus.rs | |||
| @@ -8,7 +8,7 @@ use embassy_embedded_hal::shared_bus::asynch::i2c::I2cDevice; | |||
| 8 | use embassy_embedded_hal::shared_bus::asynch::spi::SpiDevice; | 8 | use embassy_embedded_hal::shared_bus::asynch::spi::SpiDevice; |
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_rp::bind_interrupts; | 10 | use embassy_rp::bind_interrupts; |
| 11 | use embassy_rp::gpio::{AnyPin, Level, Output}; | 11 | use embassy_rp::gpio::{Level, Output}; |
| 12 | use embassy_rp::i2c::{self, I2c, InterruptHandler}; | 12 | use embassy_rp::i2c::{self, I2c, InterruptHandler}; |
| 13 | use embassy_rp::peripherals::{I2C1, SPI1}; | 13 | use embassy_rp::peripherals::{I2C1, SPI1}; |
| 14 | use embassy_rp::spi::{self, Spi}; | 14 | use embassy_rp::spi::{self, Spi}; |
| @@ -45,8 +45,8 @@ async fn main(spawner: Spawner) { | |||
| 45 | let spi_bus = SPI_BUS.init(Mutex::new(spi)); | 45 | let spi_bus = SPI_BUS.init(Mutex::new(spi)); |
| 46 | 46 | ||
| 47 | // Chip select pins for the SPI devices | 47 | // Chip select pins for the SPI devices |
| 48 | let cs_a = Output::new(AnyPin::from(p.PIN_0), Level::High); | 48 | let cs_a = Output::new(p.PIN_0, Level::High); |
| 49 | let cs_b = Output::new(AnyPin::from(p.PIN_1), Level::High); | 49 | let cs_b = Output::new(p.PIN_1, Level::High); |
| 50 | 50 | ||
| 51 | spawner.must_spawn(spi_task_a(spi_bus, cs_a)); | 51 | spawner.must_spawn(spi_task_a(spi_bus, cs_a)); |
| 52 | spawner.must_spawn(spi_task_b(spi_bus, cs_b)); | 52 | spawner.must_spawn(spi_task_b(spi_bus, cs_b)); |
diff --git a/examples/rp235x/src/bin/zerocopy.rs b/examples/rp235x/src/bin/zerocopy.rs index 39f03c8e4..d1fb0eb00 100644 --- a/examples/rp235x/src/bin/zerocopy.rs +++ b/examples/rp235x/src/bin/zerocopy.rs | |||
| @@ -9,9 +9,9 @@ use core::sync::atomic::{AtomicU16, Ordering}; | |||
| 9 | use defmt::*; | 9 | use defmt::*; |
| 10 | use embassy_executor::Spawner; | 10 | use embassy_executor::Spawner; |
| 11 | use embassy_rp::adc::{self, Adc, Async, Config, InterruptHandler}; | 11 | use embassy_rp::adc::{self, Adc, Async, Config, InterruptHandler}; |
| 12 | use embassy_rp::bind_interrupts; | ||
| 13 | use embassy_rp::gpio::Pull; | 12 | use embassy_rp::gpio::Pull; |
| 14 | use embassy_rp::peripherals::DMA_CH0; | 13 | use embassy_rp::peripherals::DMA_CH0; |
| 14 | use embassy_rp::{bind_interrupts, Peri}; | ||
| 15 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | 15 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; |
| 16 | use embassy_sync::zerocopy_channel::{Channel, Receiver, Sender}; | 16 | use embassy_sync::zerocopy_channel::{Channel, Receiver, Sender}; |
| 17 | use embassy_time::{Duration, Ticker, Timer}; | 17 | use embassy_time::{Duration, Ticker, Timer}; |
| @@ -31,7 +31,7 @@ static MAX: AtomicU16 = AtomicU16::new(0); | |||
| 31 | struct AdcParts { | 31 | struct AdcParts { |
| 32 | adc: Adc<'static, Async>, | 32 | adc: Adc<'static, Async>, |
| 33 | pin: adc::Channel<'static>, | 33 | pin: adc::Channel<'static>, |
| 34 | dma: DMA_CH0, | 34 | dma: Peri<'static, DMA_CH0>, |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | #[embassy_executor::main] | 37 | #[embassy_executor::main] |
| @@ -70,7 +70,10 @@ async fn producer(mut sender: Sender<'static, NoopRawMutex, SampleBuffer>, mut a | |||
| 70 | let buf = sender.send().await; | 70 | let buf = sender.send().await; |
| 71 | 71 | ||
| 72 | // Fill it with data | 72 | // Fill it with data |
| 73 | adc.adc.read_many(&mut adc.pin, buf, 1, &mut adc.dma).await.unwrap(); | 73 | adc.adc |
| 74 | .read_many(&mut adc.pin, buf, 1, adc.dma.reborrow()) | ||
| 75 | .await | ||
| 76 | .unwrap(); | ||
| 74 | 77 | ||
| 75 | // Notify the channel that the buffer is now ready to be received | 78 | // Notify the channel that the buffer is now ready to be received |
| 76 | sender.send_done(); | 79 | sender.send_done(); |
