From 6d39418f699edc6532d84bf1be53fe8d00d92752 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Mon, 1 Jul 2024 15:29:57 +0100 Subject: [PATCH] rp2: Add support for 48-pin RP2350 variant. Update NUM_GPIOS to match NUM_BANK0_GPIOS, and increase bit-width of variables that store pin numbers. Signed-off-by: Phil Howard --- ports/rp2/boards/make-pins.py | 2 +- ports/rp2/machine_pin.c | 2 +- ports/rp2/machine_pin.h | 2 +- ports/rp2/mphalport.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ports/rp2/boards/make-pins.py b/ports/rp2/boards/make-pins.py index 3acf5b9516..f4ce74e5a4 100755 --- a/ports/rp2/boards/make-pins.py +++ b/ports/rp2/boards/make-pins.py @@ -9,7 +9,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../../../tools")) import boardgen # This is NUM_BANK0_GPIOS. Pin indices are 0 to 29 (inclusive). -NUM_GPIOS = 30 +NUM_GPIOS = 48 # Up to 32 additional extended pins (e.g. via the wifi chip or io expanders). NUM_EXT_GPIOS = 32 diff --git a/ports/rp2/machine_pin.c b/ports/rp2/machine_pin.c index de21778569..e1a545a092 100644 --- a/ports/rp2/machine_pin.c +++ b/ports/rp2/machine_pin.c @@ -89,7 +89,7 @@ static const mp_irq_methods_t machine_pin_irq_methods; extern const machine_pin_obj_t machine_pin_obj_table[NUM_BANK0_GPIOS]; // Mask with "1" indicating that the corresponding pin is in simulated open-drain mode. -uint32_t machine_pin_open_drain_mask; +uint64_t machine_pin_open_drain_mask; #if MICROPY_HW_PIN_EXT_COUNT static inline bool is_ext_pin(__unused const machine_pin_obj_t *self) { diff --git a/ports/rp2/machine_pin.h b/ports/rp2/machine_pin.h index b3349188e8..196132019e 100644 --- a/ports/rp2/machine_pin.h +++ b/ports/rp2/machine_pin.h @@ -49,7 +49,7 @@ typedef struct _machine_pin_af_obj_t { typedef struct _machine_pin_obj_t { mp_obj_base_t base; qstr name; - uint8_t id : 5; + uint8_t id : 6; #if MICROPY_HW_PIN_EXT_COUNT uint8_t is_ext : 1; uint8_t is_output : 1; diff --git a/ports/rp2/mphalport.h b/ports/rp2/mphalport.h index 09ad54dd1e..1d260c8bd8 100644 --- a/ports/rp2/mphalport.h +++ b/ports/rp2/mphalport.h @@ -119,7 +119,7 @@ static inline mp_uint_t mp_hal_get_cpu_freq(void) { #define MP_HAL_PIN_PULL_UP (1) #define MP_HAL_PIN_PULL_DOWN (2) -extern uint32_t machine_pin_open_drain_mask; +extern uint64_t machine_pin_open_drain_mask; mp_hal_pin_obj_t mp_hal_get_pin_obj(mp_obj_t pin_in);