mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2024-12-23 20:51:31 +11:00
Explorer base improvements (#363)
* Improve comments * Expose pins and all pins naming struct. This allows users to set the interrupts on the button pins and to skip the PicoExplorer struct but still use proper naming * Use correct interrupt names in timer::alarms macro in HAL
This commit is contained in:
parent
6ae0698b7a
commit
0f114677d5
|
@ -193,7 +193,7 @@ RP2040 chip according to how it is connected up on the Trinkey.
|
||||||
### [pimoroni-pico-explorer] - Board Support for the [Pimoroni Pico Explorer]
|
### [pimoroni-pico-explorer] - Board Support for the [Pimoroni Pico Explorer]
|
||||||
|
|
||||||
You should include this crate if you are writing code that you want to run on
|
You should include this crate if you are writing code that you want to run on
|
||||||
a [Pimoroni Pico Explorer] - a board featuring a small LCD screen, a
|
a [Pimoroni Pico Explorer] - a breakout board for the [Raspberry Pi Pico] featuring a small LCD screen, a
|
||||||
breadboard and some breakout headers.
|
breadboard and some breakout headers.
|
||||||
|
|
||||||
This crate includes the [rp2040-hal], but also configures each pin of the
|
This crate includes the [rp2040-hal], but also configures each pin of the
|
||||||
|
|
|
@ -10,6 +10,9 @@ pub use hal::entry;
|
||||||
|
|
||||||
/// The linker will place this boot block at the start of our program image. We
|
/// The linker will place this boot block at the start of our program image. We
|
||||||
/// need this to help the ROM bootloader get our code up and running.
|
/// need this to help the ROM bootloader get our code up and running.
|
||||||
|
///
|
||||||
|
/// This currently assumes an rp-pico or pimoroni-pico-lipo is used as the brains.
|
||||||
|
/// Currently those are the only boards that have the right pin out to be able to be used
|
||||||
#[cfg(feature = "boot2")]
|
#[cfg(feature = "boot2")]
|
||||||
#[link_section = ".boot2"]
|
#[link_section = ".boot2"]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -45,7 +48,7 @@ use hal::{
|
||||||
};
|
};
|
||||||
use st7789::ST7789;
|
use st7789::ST7789;
|
||||||
|
|
||||||
mod internal_pins {
|
pub mod all_pins {
|
||||||
hal::bsp_pins!(
|
hal::bsp_pins!(
|
||||||
Gpio0 { name: gpio0 },
|
Gpio0 { name: gpio0 },
|
||||||
Gpio1 { name: gpio1 },
|
Gpio1 { name: gpio1 },
|
||||||
|
@ -112,6 +115,7 @@ mod internal_pins {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Can't use `hal::bsp_pins!` here because some pins are not set to their reset state
|
||||||
pub struct Pins {
|
pub struct Pins {
|
||||||
pub gpio0: Pin<Gpio0, <Gpio0 as PinId>::Reset>,
|
pub gpio0: Pin<Gpio0, <Gpio0 as PinId>::Reset>,
|
||||||
pub gpio1: Pin<Gpio1, <Gpio1 as PinId>::Reset>,
|
pub gpio1: Pin<Gpio1, <Gpio1 as PinId>::Reset>,
|
||||||
|
@ -160,10 +164,10 @@ pub type Screen = ST7789<
|
||||||
>;
|
>;
|
||||||
|
|
||||||
pub struct PicoExplorer {
|
pub struct PicoExplorer {
|
||||||
a: Pin<Gpio12, PullUpInput>,
|
pub a: Pin<Gpio12, PullUpInput>,
|
||||||
b: Pin<Gpio13, PullUpInput>,
|
pub b: Pin<Gpio13, PullUpInput>,
|
||||||
x: Pin<Gpio14, PullUpInput>,
|
pub x: Pin<Gpio14, PullUpInput>,
|
||||||
y: Pin<Gpio15, PullUpInput>,
|
pub y: Pin<Gpio15, PullUpInput>,
|
||||||
adc: Adc,
|
adc: Adc,
|
||||||
pub screen: Screen,
|
pub screen: Screen,
|
||||||
}
|
}
|
||||||
|
@ -190,7 +194,7 @@ impl PicoExplorer {
|
||||||
resets: &mut RESETS,
|
resets: &mut RESETS,
|
||||||
delay: &mut impl DelayUs<u32>,
|
delay: &mut impl DelayUs<u32>,
|
||||||
) -> (Self, Pins) {
|
) -> (Self, Pins) {
|
||||||
let internal_pins = internal_pins::Pins::new(io, pads, sio, resets);
|
let internal_pins = all_pins::Pins::new(io, pads, sio, resets);
|
||||||
|
|
||||||
let a = internal_pins.switch_a.into_pull_up_input();
|
let a = internal_pins.switch_a.into_pull_up_input();
|
||||||
let b = internal_pins.switch_b.into_pull_up_input();
|
let b = internal_pins.switch_b.into_pull_up_input();
|
||||||
|
|
|
@ -288,27 +288,27 @@ pub enum ScheduleAlarmError {
|
||||||
impl_alarm!(Alarm0 {
|
impl_alarm!(Alarm0 {
|
||||||
rb: alarm0,
|
rb: alarm0,
|
||||||
int: alarm_0,
|
int: alarm_0,
|
||||||
int_name: "IRQ_TIMER_0",
|
int_name: "TIMER_IRQ_0",
|
||||||
armed_bit_mask: 0b0001
|
armed_bit_mask: 0b0001
|
||||||
});
|
});
|
||||||
|
|
||||||
impl_alarm!(Alarm1 {
|
impl_alarm!(Alarm1 {
|
||||||
rb: alarm1,
|
rb: alarm1,
|
||||||
int: alarm_1,
|
int: alarm_1,
|
||||||
int_name: "IRQ_TIMER_1",
|
int_name: "TIMER_IRQ_1",
|
||||||
armed_bit_mask: 0b0010
|
armed_bit_mask: 0b0010
|
||||||
});
|
});
|
||||||
|
|
||||||
impl_alarm!(Alarm2 {
|
impl_alarm!(Alarm2 {
|
||||||
rb: alarm2,
|
rb: alarm2,
|
||||||
int: alarm_2,
|
int: alarm_2,
|
||||||
int_name: "IRQ_TIMER_2",
|
int_name: "TIMER_IRQ_2",
|
||||||
armed_bit_mask: 0b0100
|
armed_bit_mask: 0b0100
|
||||||
});
|
});
|
||||||
|
|
||||||
impl_alarm!(Alarm3 {
|
impl_alarm!(Alarm3 {
|
||||||
rb: alarm3,
|
rb: alarm3,
|
||||||
int: alarm_3,
|
int: alarm_3,
|
||||||
int_name: "IRQ_TIMER_3",
|
int_name: "TIMER_IRQ_3",
|
||||||
armed_bit_mask: 0b1000
|
armed_bit_mask: 0b1000
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue