summaryrefslogtreecommitdiff
path: root/ports/raspberrypi/common-hal/microcontroller
diff options
context:
space:
mode:
Diffstat (limited to 'ports/raspberrypi/common-hal/microcontroller')
-rw-r--r--ports/raspberrypi/common-hal/microcontroller/Pin.c21
-rw-r--r--ports/raspberrypi/common-hal/microcontroller/__init__.c11
2 files changed, 17 insertions, 15 deletions
diff --git a/ports/raspberrypi/common-hal/microcontroller/Pin.c b/ports/raspberrypi/common-hal/microcontroller/Pin.c
index 90c327406..ca5cf5a04 100644
--- a/ports/raspberrypi/common-hal/microcontroller/Pin.c
+++ b/ports/raspberrypi/common-hal/microcontroller/Pin.c
@@ -26,6 +26,7 @@
#include "py/runtime.h"
+#include "common-hal/microcontroller/__init__.h"
#include "shared-bindings/microcontroller/Pin.h"
#include "supervisor/shared/rgb_led_status.h"
@@ -46,7 +47,7 @@ bool speaker_enable_in_use;
STATIC uint32_t never_reset_pins;
void reset_all_pins(void) {
- for (size_t i = 0; i < 30; i++) {
+ for (size_t i = 0; i < TOTAL_GPIO_COUNT; i++) {
if ((never_reset_pins & (1 << i)) != 0) {
continue;
}
@@ -55,7 +56,7 @@ void reset_all_pins(void) {
}
void never_reset_pin_number(uint8_t pin_number) {
- if (pin_number >= 32) {
+ if (pin_number >= TOTAL_GPIO_COUNT) {
return;
}
@@ -63,12 +64,7 @@ void never_reset_pin_number(uint8_t pin_number) {
}
void reset_pin_number(uint8_t pin_number) {
- if (pin_number >= 32
-#if TUD_OPT_RP2040_USB_DEVICE_ENUMERATION_FIX
- // Pin 15 is used for Errata so we don't mess with it.
- || pin_number == 15
-#endif
- ) {
+ if (pin_number >= TOTAL_GPIO_COUNT) {
return;
}
@@ -139,15 +135,10 @@ void claim_pin(const mcu_pin_obj_t* pin) {
}
bool pin_number_is_free(uint8_t pin_number) {
- if (pin_number >= 30) {
+ if (pin_number >= TOTAL_GPIO_COUNT) {
return false;
}
-#if TUD_OPT_RP2040_USB_DEVICE_ENUMERATION_FIX
- // Pin 15 is used for Errata so we don't mess with it.
- if (pin_number == 15) {
- return true;
- }
-#endif
+
uint32_t pad_state = padsbank0_hw->io[pin_number];
return (pad_state & PADS_BANK0_GPIO0_IE_BITS) == 0 &&
(pad_state & PADS_BANK0_GPIO0_OD_BITS) != 0;
diff --git a/ports/raspberrypi/common-hal/microcontroller/__init__.c b/ports/raspberrypi/common-hal/microcontroller/__init__.c
index e454ffa1b..774e313bb 100644
--- a/ports/raspberrypi/common-hal/microcontroller/__init__.c
+++ b/ports/raspberrypi/common-hal/microcontroller/__init__.c
@@ -112,6 +112,17 @@ const nvm_bytearray_obj_t common_hal_mcu_nvm_obj = {
};
#endif
+#if CIRCUITPY_WATCHDOG
+// The singleton watchdog.WatchDogTimer object.
+watchdog_watchdogtimer_obj_t common_hal_mcu_watchdogtimer_obj = {
+ .base = {
+ .type = &watchdog_watchdogtimer_type,
+ },
+ .timeout = 0.0f,
+ .mode = WATCHDOGMODE_NONE,
+};
+#endif
+
// This maps MCU pin names to pin objects.
const mp_rom_map_elem_t mcu_pin_global_dict_table[TOTAL_GPIO_COUNT] = {
{ MP_ROM_QSTR(MP_QSTR_GPIO0), MP_ROM_PTR(&pin_GPIO0) },