From 0f114677d56c729db4a81cf420c30f54f5dc555a Mon Sep 17 00:00:00 2001 From: Hmvp Date: Thu, 23 Jun 2022 09:19:32 +0000 Subject: [PATCH] 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 --- README.md | 2 +- boards/pimoroni-pico-explorer/src/lib.rs | 16 ++++++++++------ rp2040-hal/src/timer.rs | 8 ++++---- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4757b33..ed97ae1 100644 --- a/README.md +++ b/README.md @@ -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] 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. This crate includes the [rp2040-hal], but also configures each pin of the diff --git a/boards/pimoroni-pico-explorer/src/lib.rs b/boards/pimoroni-pico-explorer/src/lib.rs index cad63d2..eaddc8e 100644 --- a/boards/pimoroni-pico-explorer/src/lib.rs +++ b/boards/pimoroni-pico-explorer/src/lib.rs @@ -10,6 +10,9 @@ pub use hal::entry; /// 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. +/// +/// 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")] #[link_section = ".boot2"] #[no_mangle] @@ -45,7 +48,7 @@ use hal::{ }; use st7789::ST7789; -mod internal_pins { +pub mod all_pins { hal::bsp_pins!( Gpio0 { name: gpio0 }, 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 gpio0: Pin::Reset>, pub gpio1: Pin::Reset>, @@ -160,10 +164,10 @@ pub type Screen = ST7789< >; pub struct PicoExplorer { - a: Pin, - b: Pin, - x: Pin, - y: Pin, + pub a: Pin, + pub b: Pin, + pub x: Pin, + pub y: Pin, adc: Adc, pub screen: Screen, } @@ -190,7 +194,7 @@ impl PicoExplorer { resets: &mut RESETS, delay: &mut impl DelayUs, ) -> (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 b = internal_pins.switch_b.into_pull_up_input(); diff --git a/rp2040-hal/src/timer.rs b/rp2040-hal/src/timer.rs index 57b3033..100d609 100644 --- a/rp2040-hal/src/timer.rs +++ b/rp2040-hal/src/timer.rs @@ -288,27 +288,27 @@ pub enum ScheduleAlarmError { impl_alarm!(Alarm0 { rb: alarm0, int: alarm_0, - int_name: "IRQ_TIMER_0", + int_name: "TIMER_IRQ_0", armed_bit_mask: 0b0001 }); impl_alarm!(Alarm1 { rb: alarm1, int: alarm_1, - int_name: "IRQ_TIMER_1", + int_name: "TIMER_IRQ_1", armed_bit_mask: 0b0010 }); impl_alarm!(Alarm2 { rb: alarm2, int: alarm_2, - int_name: "IRQ_TIMER_2", + int_name: "TIMER_IRQ_2", armed_bit_mask: 0b0100 }); impl_alarm!(Alarm3 { rb: alarm3, int: alarm_3, - int_name: "IRQ_TIMER_3", + int_name: "TIMER_IRQ_3", armed_bit_mask: 0b1000 });