Fix rp23 i2s example, boot_sel isn't supported yet.

This commit is contained in:
Caleb Jamison 2024-10-09 11:37:15 -04:00
parent 57c1fbf308
commit fc978c2ee9

View File

@ -15,6 +15,7 @@ use core::mem;
use embassy_executor::Spawner; use embassy_executor::Spawner;
use embassy_rp::bind_interrupts; use embassy_rp::bind_interrupts;
use embassy_rp::block::ImageDef; use embassy_rp::block::ImageDef;
use embassy_rp::gpio::{Input, Pull};
use embassy_rp::peripherals::PIO0; use embassy_rp::peripherals::PIO0;
use embassy_rp::pio::{InterruptHandler, Pio}; use embassy_rp::pio::{InterruptHandler, Pio};
use embassy_rp::pio_programs::i2s::{PioI2sOut, PioI2sOutProgram}; use embassy_rp::pio_programs::i2s::{PioI2sOut, PioI2sOutProgram};
@ -35,7 +36,7 @@ const CHANNELS: u32 = 2;
#[embassy_executor::main] #[embassy_executor::main]
async fn main(_spawner: Spawner) { async fn main(_spawner: Spawner) {
let mut p = embassy_rp::init(Default::default()); let p = embassy_rp::init(Default::default());
// Setup pio state machine for i2s output // Setup pio state machine for i2s output
let Pio { mut common, sm0, .. } = Pio::new(p.PIO0, Irqs); let Pio { mut common, sm0, .. } = Pio::new(p.PIO0, Irqs);
@ -58,6 +59,8 @@ async fn main(_spawner: Spawner) {
&program, &program,
); );
let fade_input = Input::new(p.PIN_0, Pull::Up);
// create two audio buffers (back and front) which will take turns being // create two audio buffers (back and front) which will take turns being
// filled with new audio data and being sent to the pio fifo using dma // filled with new audio data and being sent to the pio fifo using dma
const BUFFER_SIZE: usize = 960; const BUFFER_SIZE: usize = 960;
@ -75,7 +78,7 @@ async fn main(_spawner: Spawner) {
let dma_future = i2s.write(front_buffer); let dma_future = i2s.write(front_buffer);
// fade in audio when bootsel is pressed // fade in audio when bootsel is pressed
let fade_target = if p.BOOTSEL.is_pressed() { i32::MAX } else { 0 }; let fade_target = if fade_input.is_low() { i32::MAX } else { 0 };
// fill back buffer with fresh audio samples before awaiting the dma future // fill back buffer with fresh audio samples before awaiting the dma future
for s in back_buffer.iter_mut() { for s in back_buffer.iter_mut() {