aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorCaleb Jamison <[email protected]>2024-10-09 11:37:15 -0400
committerCaleb Jamison <[email protected]>2024-10-09 11:37:15 -0400
commitfc978c2ee9dda07b9fe7113e2aa0f2d3fb33fd1b (patch)
tree8d9e3405979224c920e429144f31befe8bc7496d /examples
parent57c1fbf3089e2a2dc9fe5b7d1f1e094596566395 (diff)
Fix rp23 i2s example, boot_sel isn't supported yet.
Diffstat (limited to 'examples')
-rw-r--r--examples/rp23/src/bin/pio_i2s.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/rp23/src/bin/pio_i2s.rs b/examples/rp23/src/bin/pio_i2s.rs
index 90491fb45..1fd34357b 100644
--- a/examples/rp23/src/bin/pio_i2s.rs
+++ b/examples/rp23/src/bin/pio_i2s.rs
@@ -15,6 +15,7 @@ use core::mem;
15use embassy_executor::Spawner; 15use embassy_executor::Spawner;
16use embassy_rp::bind_interrupts; 16use embassy_rp::bind_interrupts;
17use embassy_rp::block::ImageDef; 17use embassy_rp::block::ImageDef;
18use embassy_rp::gpio::{Input, Pull};
18use embassy_rp::peripherals::PIO0; 19use embassy_rp::peripherals::PIO0;
19use embassy_rp::pio::{InterruptHandler, Pio}; 20use embassy_rp::pio::{InterruptHandler, Pio};
20use embassy_rp::pio_programs::i2s::{PioI2sOut, PioI2sOutProgram}; 21use embassy_rp::pio_programs::i2s::{PioI2sOut, PioI2sOutProgram};
@@ -35,7 +36,7 @@ const CHANNELS: u32 = 2;
35 36
36#[embassy_executor::main] 37#[embassy_executor::main]
37async fn main(_spawner: Spawner) { 38async fn main(_spawner: Spawner) {
38 let mut p = embassy_rp::init(Default::default()); 39 let p = embassy_rp::init(Default::default());
39 40
40 // Setup pio state machine for i2s output 41 // Setup pio state machine for i2s output
41 let Pio { mut common, sm0, .. } = Pio::new(p.PIO0, Irqs); 42 let Pio { mut common, sm0, .. } = Pio::new(p.PIO0, Irqs);
@@ -58,6 +59,8 @@ async fn main(_spawner: Spawner) {
58 &program, 59 &program,
59 ); 60 );
60 61
62 let fade_input = Input::new(p.PIN_0, Pull::Up);
63
61 // create two audio buffers (back and front) which will take turns being 64 // create two audio buffers (back and front) which will take turns being
62 // filled with new audio data and being sent to the pio fifo using dma 65 // filled with new audio data and being sent to the pio fifo using dma
63 const BUFFER_SIZE: usize = 960; 66 const BUFFER_SIZE: usize = 960;
@@ -75,7 +78,7 @@ async fn main(_spawner: Spawner) {
75 let dma_future = i2s.write(front_buffer); 78 let dma_future = i2s.write(front_buffer);
76 79
77 // fade in audio when bootsel is pressed 80 // fade in audio when bootsel is pressed
78 let fade_target = if p.BOOTSEL.is_pressed() { i32::MAX } else { 0 }; 81 let fade_target = if fade_input.is_low() { i32::MAX } else { 0 };
79 82
80 // fill back buffer with fresh audio samples before awaiting the dma future 83 // fill back buffer with fresh audio samples before awaiting the dma future
81 for s in back_buffer.iter_mut() { 84 for s in back_buffer.iter_mut() {