forked from NaxdyOrg/NaxGCC-FW
chore(input): use AnyPin
This commit is contained in:
parent
d0aeafc069
commit
d4c88a4a60
2 changed files with 30 additions and 30 deletions
30
src/input.rs
30
src/input.rs
|
@ -2,7 +2,7 @@ use defmt::{debug, info, trace, Format};
|
||||||
use embassy_futures::{join::join, yield_now};
|
use embassy_futures::{join::join, yield_now};
|
||||||
use embassy_rp::{
|
use embassy_rp::{
|
||||||
flash::{Async, Flash},
|
flash::{Async, Flash},
|
||||||
gpio::{Input, Output, Pin},
|
gpio::{AnyPin, Input, Output, Pin},
|
||||||
peripherals::{
|
peripherals::{
|
||||||
FLASH, PIN_10, PIN_11, PIN_16, PIN_17, PIN_18, PIN_19, PIN_20, PIN_21, PIN_22, PIN_23,
|
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,
|
PIN_24, PIN_5, PIN_8, PIN_9, PWM_CH4, PWM_CH6, SPI0,
|
||||||
|
@ -385,23 +385,23 @@ fn update_button_states<
|
||||||
#[embassy_executor::task]
|
#[embassy_executor::task]
|
||||||
pub async fn input_loop(
|
pub async fn input_loop(
|
||||||
mut flash: Flash<'static, FLASH, Async, FLASH_SIZE>,
|
mut flash: Flash<'static, FLASH, Async, FLASH_SIZE>,
|
||||||
btn_z: Input<'static, PIN_20>,
|
btn_z: Input<'static, AnyPin>,
|
||||||
btn_a: Input<'static, PIN_17>,
|
btn_a: Input<'static, AnyPin>,
|
||||||
btn_b: Input<'static, PIN_16>,
|
btn_b: Input<'static, AnyPin>,
|
||||||
btn_dright: Input<'static, PIN_11>,
|
btn_dright: Input<'static, AnyPin>,
|
||||||
btn_dup: Input<'static, PIN_9>,
|
btn_dup: Input<'static, AnyPin>,
|
||||||
btn_ddown: Input<'static, PIN_10>,
|
btn_ddown: Input<'static, AnyPin>,
|
||||||
btn_dleft: Input<'static, PIN_8>,
|
btn_dleft: Input<'static, AnyPin>,
|
||||||
btn_l: Input<'static, PIN_22>,
|
btn_l: Input<'static, AnyPin>,
|
||||||
btn_r: Input<'static, PIN_21>,
|
btn_r: Input<'static, AnyPin>,
|
||||||
btn_x: Input<'static, PIN_18>,
|
btn_x: Input<'static, AnyPin>,
|
||||||
btn_y: Input<'static, PIN_19>,
|
btn_y: Input<'static, AnyPin>,
|
||||||
btn_start: Input<'static, PIN_5>,
|
btn_start: Input<'static, AnyPin>,
|
||||||
// pwm_rumble: Pwm<'static, PWM_CH4>,
|
// pwm_rumble: Pwm<'static, PWM_CH4>,
|
||||||
// pwm_brake: Pwm<'static, PWM_CH6>,
|
// pwm_brake: Pwm<'static, PWM_CH6>,
|
||||||
mut spi: Spi<'static, SPI0, embassy_rp::spi::Blocking>,
|
mut spi: Spi<'static, SPI0, embassy_rp::spi::Blocking>,
|
||||||
mut spi_acs: Output<'static, PIN_24>,
|
mut spi_acs: Output<'static, AnyPin>,
|
||||||
mut spi_ccs: Output<'static, PIN_23>,
|
mut spi_ccs: Output<'static, AnyPin>,
|
||||||
) {
|
) {
|
||||||
if btn_a.is_low() && btn_x.is_low() && btn_y.is_low() {
|
if btn_a.is_low() && btn_x.is_low() && btn_y.is_low() {
|
||||||
info!("Detected reset button press, booting into flash.");
|
info!("Detected reset button press, booting into flash.");
|
||||||
|
|
30
src/main.rs
30
src/main.rs
|
@ -16,7 +16,7 @@ use embassy_executor::Executor;
|
||||||
use embassy_rp::{
|
use embassy_rp::{
|
||||||
bind_interrupts,
|
bind_interrupts,
|
||||||
flash::{Async, Flash},
|
flash::{Async, Flash},
|
||||||
gpio::{self, Input},
|
gpio::{self, AnyPin, Input},
|
||||||
multicore::{spawn_core1, Stack},
|
multicore::{spawn_core1, Stack},
|
||||||
peripherals::USB,
|
peripherals::USB,
|
||||||
pwm::Pwm,
|
pwm::Pwm,
|
||||||
|
@ -76,8 +76,8 @@ fn main() -> ! {
|
||||||
|
|
||||||
let spi = Spi::new_blocking(p.SPI0, spi_clk, mosi, miso, spi_cfg);
|
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_acs = Output::new(AnyPin::from(p_acs), Level::High); // active low
|
||||||
let spi_ccs = Output::new(p_ccs, 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();
|
let mut pwm_config: embassy_rp::pwm::Config = Default::default();
|
||||||
pwm_config.top = 255;
|
pwm_config.top = 255;
|
||||||
|
@ -94,18 +94,18 @@ fn main() -> ! {
|
||||||
spawner
|
spawner
|
||||||
.spawn(input_loop(
|
.spawn(input_loop(
|
||||||
flash,
|
flash,
|
||||||
Input::new(p.PIN_20, gpio::Pull::Up),
|
Input::new(AnyPin::from(p.PIN_20), gpio::Pull::Up),
|
||||||
Input::new(p.PIN_17, gpio::Pull::Up),
|
Input::new(AnyPin::from(p.PIN_17), gpio::Pull::Up),
|
||||||
Input::new(p.PIN_16, gpio::Pull::Up),
|
Input::new(AnyPin::from(p.PIN_16), gpio::Pull::Up),
|
||||||
Input::new(p.PIN_11, gpio::Pull::Up),
|
Input::new(AnyPin::from(p.PIN_11), gpio::Pull::Up),
|
||||||
Input::new(p.PIN_9, gpio::Pull::Up),
|
Input::new(AnyPin::from(p.PIN_9), gpio::Pull::Up),
|
||||||
Input::new(p.PIN_10, gpio::Pull::Up),
|
Input::new(AnyPin::from(p.PIN_10), gpio::Pull::Up),
|
||||||
Input::new(p.PIN_8, gpio::Pull::Up),
|
Input::new(AnyPin::from(p.PIN_8), gpio::Pull::Up),
|
||||||
Input::new(p.PIN_22, gpio::Pull::Up),
|
Input::new(AnyPin::from(p.PIN_22), gpio::Pull::Up),
|
||||||
Input::new(p.PIN_21, gpio::Pull::Up),
|
Input::new(AnyPin::from(p.PIN_21), gpio::Pull::Up),
|
||||||
Input::new(p.PIN_18, gpio::Pull::Up),
|
Input::new(AnyPin::from(p.PIN_18), gpio::Pull::Up),
|
||||||
Input::new(p.PIN_19, gpio::Pull::Up),
|
Input::new(AnyPin::from(p.PIN_19), gpio::Pull::Up),
|
||||||
Input::new(p.PIN_5, gpio::Pull::Up),
|
Input::new(AnyPin::from(p.PIN_5), gpio::Pull::Up),
|
||||||
// pwm_rumble,
|
// pwm_rumble,
|
||||||
// pwm_brake,
|
// pwm_brake,
|
||||||
spi,
|
spi,
|
||||||
|
|
Loading…
Reference in a new issue