3131
3232#include "py/gc.h"
3333
34- STATIC bool claimed_pins [IOMUXC_SW_PAD_CTL_PAD_COUNT ];
35- STATIC bool never_reset_pins [IOMUXC_SW_PAD_CTL_PAD_COUNT ];
34+ STATIC bool claimed_pins [PAD_COUNT ];
35+ STATIC bool never_reset_pins [PAD_COUNT ];
3636
3737// Default is that no pins are forbidden to reset.
3838MP_WEAK const mcu_pin_obj_t * mimxrt10xx_reset_forbidden_pins [] = {
@@ -55,10 +55,10 @@ STATIC bool _reset_forbidden(const mcu_pin_obj_t *pin) {
5555// and GPIO port and number, used to store claimed and reset tagging. The two number
5656// systems are not related and one cannot determine the other without a pin object
5757void reset_all_pins (void ) {
58- for (uint8_t i = 0 ; i < IOMUXC_SW_PAD_CTL_PAD_COUNT ; i ++ ) {
58+ for (uint8_t i = 0 ; i < PAD_COUNT ; i ++ ) {
5959 claimed_pins [i ] = never_reset_pins [i ];
6060 }
61- for (uint8_t i = 0 ; i < IOMUXC_SW_PAD_CTL_PAD_COUNT ; i ++ ) {
61+ for (uint8_t i = 0 ; i < PAD_COUNT ; i ++ ) {
6262 mcu_pin_obj_t * pin = mcu_pin_globals .map .table [i ].value ;
6363 if (never_reset_pins [pin -> mux_idx ]) {
6464 continue ;
@@ -90,6 +90,11 @@ void common_hal_reset_pin(const mcu_pin_obj_t *pin) {
9090 disable_pin_change_interrupt (pin );
9191 never_reset_pins [pin -> mux_idx ] = false;
9292 claimed_pins [pin -> mux_idx ] = false;
93+
94+ // This should never be true, but protect against it anyway.
95+ if (pin -> mux_reg == 0 ) {
96+ return ;
97+ }
9398 * (uint32_t * )pin -> mux_reg = pin -> mux_reset ;
9499 * (uint32_t * )pin -> cfg_reg = pin -> pad_reset ;
95100}
0 commit comments