Skip to content

Commit 137e556

Browse files
authored
Merge pull request #7964 from tannewt/fix_imx_usb_reset
Correct pad count.
2 parents 99a7047 + a56174d commit 137e556

File tree

15 files changed

+39
-29
lines changed

15 files changed

+39
-29
lines changed

ports/mimxrt10xx/boards/imxrt1010_evk/board.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
4141
&pin_GPIO_SD_08,
4242
&pin_GPIO_SD_07,
4343
&pin_GPIO_SD_06,
44-
// USB Pins
45-
&pin_USB_OTG1_DN,
46-
&pin_USB_OTG1_DP,
4744
NULL, // Must end in NULL.
4845
};
4946

ports/mimxrt10xx/boards/imxrt1015_evk/board.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
4040
&pin_GPIO_SD_B1_09,
4141
&pin_GPIO_SD_B1_10,
4242
&pin_GPIO_SD_B1_11,
43-
// USB Pins
44-
&pin_USB_OTG1_DN,
45-
&pin_USB_OTG1_DP,
4643
NULL, // Must end in NULL.
4744
};
4845

ports/mimxrt10xx/boards/imxrt1020_evk/board.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
4242
&pin_GPIO_SD_B1_09,
4343
&pin_GPIO_SD_B1_10,
4444
&pin_GPIO_SD_B1_11,
45-
46-
// USB Pins
47-
&pin_USB_OTG1_DN,
48-
&pin_USB_OTG1_DP,
4945
NULL, // Must end in NULL.
5046
};
5147

ports/mimxrt10xx/boards/imxrt1040_evk/board.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
4444
&pin_GPIO_SD_B1_10,
4545
&pin_GPIO_SD_B1_11,
4646

47-
&pin_USB_OTG1_DN,
48-
&pin_USB_OTG1_DP,
49-
5047
NULL, // Must end in NULL.
5148
};
5249

ports/mimxrt10xx/boards/imxrt1050_evkb/board.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
4545
&pin_GPIO_SD_B1_11,
4646

4747
// USB Pins
48-
&pin_GPIO_AD_B0_01,
49-
&pin_GPIO_AD_B0_03,
48+
&pin_GPIO_AD_B0_01, // ID Pin
49+
&pin_GPIO_AD_B0_03, // OC/Fault Pin
5050
NULL, // Must end in NULL.
5151
};
5252

ports/mimxrt10xx/boards/imxrt1060_evk/board.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
5050
&pin_GPIO_SD_B1_11,
5151

5252
// USB Pins
53-
&pin_GPIO_AD_B0_01,
54-
&pin_GPIO_AD_B0_03,
53+
&pin_GPIO_AD_B0_01, // ID Pin
54+
&pin_GPIO_AD_B0_03, // OC/Fault Pin
5555
NULL, // Must end in NULL.
5656
};
5757

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
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.
3838
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) {
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
5757
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++) {
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
}

ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/pins.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,7 @@
4040
#include "pin_names.h"
4141
#undef FORMAT_PIN
4242

43-
#define PIN_COUNT (IOMUXC_SW_PAD_CTL_PAD_COUNT + 2)
43+
// Pads can be reset. Other pins like USB cannot be.
44+
#define PAD_COUNT (43)
45+
#define PIN_COUNT (PAD_COUNT + 2)
4446
extern const mcu_pin_obj_t mcu_pin_list[PIN_COUNT];

ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1015/pins.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,7 @@
4040
#include "pin_names.h"
4141
#undef FORMAT_PIN
4242

43-
#define PIN_COUNT (IOMUXC_SW_PAD_CTL_PAD_COUNT + 2)
43+
// Pads can be reset. Other pins like USB cannot be.
44+
#define PAD_COUNT (56)
45+
#define PIN_COUNT (PAD_COUNT + 2)
4446
extern const mcu_pin_obj_t mcu_pin_list[PIN_COUNT];

ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/pins.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,7 @@
4040
#include "pin_names.h"
4141
#undef FORMAT_PIN
4242

43-
#define PIN_COUNT (IOMUXC_SW_PAD_CTL_PAD_COUNT + 2)
43+
// Pads can be reset. Other pins like USB cannot be.
44+
#define PAD_COUNT (93)
45+
#define PIN_COUNT (PAD_COUNT + 2)
4446
extern const mcu_pin_obj_t mcu_pin_list[PIN_COUNT];

0 commit comments

Comments
 (0)