Skip to content

Commit a9227e1

Browse files
authored
Merge pull request adafruit#4063 from dhalbert/rp2040-gp15
2 parents 13812a7 + be4cfdd commit a9227e1

File tree

2 files changed

+7
-15
lines changed
  • ports/raspberrypi
    • boards/raspberry_pi_pico
    • common-hal/microcontroller

2 files changed

+7
-15
lines changed

ports/raspberrypi/boards/raspberry_pi_pico/pins.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
1616
{ MP_ROM_QSTR(MP_QSTR_GP12), MP_ROM_PTR(&pin_GPIO12) },
1717
{ MP_ROM_QSTR(MP_QSTR_GP13), MP_ROM_PTR(&pin_GPIO13) },
1818
{ MP_ROM_QSTR(MP_QSTR_GP14), MP_ROM_PTR(&pin_GPIO14) },
19+
{ MP_ROM_QSTR(MP_QSTR_GP15), MP_ROM_PTR(&pin_GPIO15) },
1920
{ MP_ROM_QSTR(MP_QSTR_GP16), MP_ROM_PTR(&pin_GPIO16) },
2021
{ MP_ROM_QSTR(MP_QSTR_GP17), MP_ROM_PTR(&pin_GPIO17) },
2122
{ MP_ROM_QSTR(MP_QSTR_GP18), MP_ROM_PTR(&pin_GPIO18) },

ports/raspberrypi/common-hal/microcontroller/Pin.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include "py/runtime.h"
2828

29+
#include "common-hal/microcontroller/__init__.h"
2930
#include "shared-bindings/microcontroller/Pin.h"
3031

3132
#include "supervisor/shared/rgb_led_status.h"
@@ -46,7 +47,7 @@ bool speaker_enable_in_use;
4647
STATIC uint32_t never_reset_pins;
4748

4849
void reset_all_pins(void) {
49-
for (size_t i = 0; i < 30; i++) {
50+
for (size_t i = 0; i < TOTAL_GPIO_COUNT; i++) {
5051
if ((never_reset_pins & (1 << i)) != 0) {
5152
continue;
5253
}
@@ -55,20 +56,15 @@ void reset_all_pins(void) {
5556
}
5657

5758
void never_reset_pin_number(uint8_t pin_number) {
58-
if (pin_number >= 32) {
59+
if (pin_number >= TOTAL_GPIO_COUNT) {
5960
return;
6061
}
6162

6263
never_reset_pins |= 1 << pin_number;
6364
}
6465

6566
void reset_pin_number(uint8_t pin_number) {
66-
if (pin_number >= 32
67-
#if TUD_OPT_RP2040_USB_DEVICE_ENUMERATION_FIX
68-
// Pin 15 is used for Errata so we don't mess with it.
69-
|| pin_number == 15
70-
#endif
71-
) {
67+
if (pin_number >= TOTAL_GPIO_COUNT) {
7268
return;
7369
}
7470

@@ -139,15 +135,10 @@ void claim_pin(const mcu_pin_obj_t* pin) {
139135
}
140136

141137
bool pin_number_is_free(uint8_t pin_number) {
142-
if (pin_number >= 30) {
138+
if (pin_number >= TOTAL_GPIO_COUNT) {
143139
return false;
144140
}
145-
#if TUD_OPT_RP2040_USB_DEVICE_ENUMERATION_FIX
146-
// Pin 15 is used for Errata so we don't mess with it.
147-
if (pin_number == 15) {
148-
return true;
149-
}
150-
#endif
141+
151142
uint32_t pad_state = padsbank0_hw->io[pin_number];
152143
return (pad_state & PADS_BANK0_GPIO0_IE_BITS) == 0 &&
153144
(pad_state & PADS_BANK0_GPIO0_OD_BITS) != 0;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy