31
31
32
32
#include "py/gc.h"
33
33
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 ];
36
36
37
37
// Default is that no pins are forbidden to reset.
38
38
MP_WEAK const mcu_pin_obj_t * mimxrt10xx_reset_forbidden_pins [] = {
@@ -55,10 +55,10 @@ STATIC bool _reset_forbidden(const mcu_pin_obj_t *pin) {
55
55
// and GPIO port and number, used to store claimed and reset tagging. The two number
56
56
// systems are not related and one cannot determine the other without a pin object
57
57
void 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 ++ ) {
59
59
claimed_pins [i ] = never_reset_pins [i ];
60
60
}
61
- for (uint8_t i = 0 ; i < IOMUXC_SW_PAD_CTL_PAD_COUNT ; i ++ ) {
61
+ for (uint8_t i = 0 ; i < PAD_COUNT ; i ++ ) {
62
62
mcu_pin_obj_t * pin = mcu_pin_globals .map .table [i ].value ;
63
63
if (never_reset_pins [pin -> mux_idx ]) {
64
64
continue ;
@@ -90,6 +90,11 @@ void common_hal_reset_pin(const mcu_pin_obj_t *pin) {
90
90
disable_pin_change_interrupt (pin );
91
91
never_reset_pins [pin -> mux_idx ] = false;
92
92
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
+ }
93
98
* (uint32_t * )pin -> mux_reg = pin -> mux_reset ;
94
99
* (uint32_t * )pin -> cfg_reg = pin -> pad_reset ;
95
100
}
0 commit comments