chore(input): use AnyPin

This commit is contained in:
Naxdy 2024-03-28 18:12:02 +01:00
parent d0aeafc069
commit d4c88a4a60
Signed by: Naxdy
GPG key ID: CC15075846BCE91B
2 changed files with 30 additions and 30 deletions

View file

@ -2,7 +2,7 @@ use defmt::{debug, info, trace, Format};
use embassy_futures::{join::join, yield_now};
use embassy_rp::{
flash::{Async, Flash},
gpio::{Input, Output, Pin},
gpio::{AnyPin, Input, Output, Pin},
peripherals::{
FLASH, PIN_10, PIN_11, PIN_16, PIN_17, PIN_18, PIN_19, PIN_20, PIN_21, PIN_22, PIN_23,
PIN_24, PIN_5, PIN_8, PIN_9, PWM_CH4, PWM_CH6, SPI0,
@ -385,23 +385,23 @@ fn update_button_states<
#[embassy_executor::task]
pub async fn input_loop(
mut flash: Flash<'static, FLASH, Async, FLASH_SIZE>,
btn_z: Input<'static, PIN_20>,
btn_a: Input<'static, PIN_17>,
btn_b: Input<'static, PIN_16>,
btn_dright: Input<'static, PIN_11>,
btn_dup: Input<'static, PIN_9>,
btn_ddown: Input<'static, PIN_10>,
btn_dleft: Input<'static, PIN_8>,
btn_l: Input<'static, PIN_22>,
btn_r: Input<'static, PIN_21>,
btn_x: Input<'static, PIN_18>,
btn_y: Input<'static, PIN_19>,
btn_start: Input<'static, PIN_5>,
btn_z: Input<'static, AnyPin>,
btn_a: Input<'static, AnyPin>,
btn_b: Input<'static, AnyPin>,
btn_dright: Input<'static, AnyPin>,
btn_dup: Input<'static, AnyPin>,
btn_ddown: Input<'static, AnyPin>,
btn_dleft: Input<'static, AnyPin>,
btn_l: Input<'static, AnyPin>,
btn_r: Input<'static, AnyPin>,
btn_x: Input<'static, AnyPin>,
btn_y: Input<'static, AnyPin>,
btn_start: Input<'static, AnyPin>,
// pwm_rumble: Pwm<'static, PWM_CH4>,
// pwm_brake: Pwm<'static, PWM_CH6>,
mut spi: Spi<'static, SPI0, embassy_rp::spi::Blocking>,
mut spi_acs: Output<'static, PIN_24>,
mut spi_ccs: Output<'static, PIN_23>,
mut spi_acs: Output<'static, AnyPin>,
mut spi_ccs: Output<'static, AnyPin>,
) {
if btn_a.is_low() && btn_x.is_low() && btn_y.is_low() {
info!("Detected reset button press, booting into flash.");

View file

@ -16,7 +16,7 @@ use embassy_executor::Executor;
use embassy_rp::{
bind_interrupts,
flash::{Async, Flash},
gpio::{self, Input},
gpio::{self, AnyPin, Input},
multicore::{spawn_core1, Stack},
peripherals::USB,
pwm::Pwm,
@ -76,8 +76,8 @@ fn main() -> ! {
let spi = Spi::new_blocking(p.SPI0, spi_clk, mosi, miso, spi_cfg);
let spi_acs = Output::new(p_acs, Level::High); // active low
let spi_ccs = Output::new(p_ccs, Level::High); // active low
let spi_acs = Output::new(AnyPin::from(p_acs), Level::High); // active low
let spi_ccs = Output::new(AnyPin::from(p_ccs), Level::High); // active low
let mut pwm_config: embassy_rp::pwm::Config = Default::default();
pwm_config.top = 255;
@ -94,18 +94,18 @@ fn main() -> ! {
spawner
.spawn(input_loop(
flash,
Input::new(p.PIN_20, gpio::Pull::Up),
Input::new(p.PIN_17, gpio::Pull::Up),
Input::new(p.PIN_16, gpio::Pull::Up),
Input::new(p.PIN_11, gpio::Pull::Up),
Input::new(p.PIN_9, gpio::Pull::Up),
Input::new(p.PIN_10, gpio::Pull::Up),
Input::new(p.PIN_8, gpio::Pull::Up),
Input::new(p.PIN_22, gpio::Pull::Up),
Input::new(p.PIN_21, gpio::Pull::Up),
Input::new(p.PIN_18, gpio::Pull::Up),
Input::new(p.PIN_19, gpio::Pull::Up),
Input::new(p.PIN_5, gpio::Pull::Up),
Input::new(AnyPin::from(p.PIN_20), gpio::Pull::Up),
Input::new(AnyPin::from(p.PIN_17), gpio::Pull::Up),
Input::new(AnyPin::from(p.PIN_16), gpio::Pull::Up),
Input::new(AnyPin::from(p.PIN_11), gpio::Pull::Up),
Input::new(AnyPin::from(p.PIN_9), gpio::Pull::Up),
Input::new(AnyPin::from(p.PIN_10), gpio::Pull::Up),
Input::new(AnyPin::from(p.PIN_8), gpio::Pull::Up),
Input::new(AnyPin::from(p.PIN_22), gpio::Pull::Up),
Input::new(AnyPin::from(p.PIN_21), gpio::Pull::Up),
Input::new(AnyPin::from(p.PIN_18), gpio::Pull::Up),
Input::new(AnyPin::from(p.PIN_19), gpio::Pull::Up),
Input::new(AnyPin::from(p.PIN_5), gpio::Pull::Up),
// pwm_rumble,
// pwm_brake,
spi,