Correct pad count.

This prevents running into the pins that cannot be reset. On 1011
it was off by one pin that isn't attached to the package. So,
having the USB pins forbidden prevented resetting to a NULL address.

Fixes #7952
This commit is contained in:
Scott Shawcroft 2023-05-11 15:02:56 -07:00
parent c75a768b59
commit a56174dc10
No known key found for this signature in database
GPG Key ID: 0DFD512649C052DA
15 changed files with 39 additions and 29 deletions

View File

@ -41,9 +41,6 @@ const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
&pin_GPIO_SD_08,
&pin_GPIO_SD_07,
&pin_GPIO_SD_06,
// USB Pins
&pin_USB_OTG1_DN,
&pin_USB_OTG1_DP,
NULL, // Must end in NULL.
};

View File

@ -40,9 +40,6 @@ const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
&pin_GPIO_SD_B1_09,
&pin_GPIO_SD_B1_10,
&pin_GPIO_SD_B1_11,
// USB Pins
&pin_USB_OTG1_DN,
&pin_USB_OTG1_DP,
NULL, // Must end in NULL.
};

View File

@ -42,10 +42,6 @@ const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
&pin_GPIO_SD_B1_09,
&pin_GPIO_SD_B1_10,
&pin_GPIO_SD_B1_11,
// USB Pins
&pin_USB_OTG1_DN,
&pin_USB_OTG1_DP,
NULL, // Must end in NULL.
};

View File

@ -44,9 +44,6 @@ const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
&pin_GPIO_SD_B1_10,
&pin_GPIO_SD_B1_11,
&pin_USB_OTG1_DN,
&pin_USB_OTG1_DP,
NULL, // Must end in NULL.
};

View File

@ -45,8 +45,8 @@ const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
&pin_GPIO_SD_B1_11,
// USB Pins
&pin_GPIO_AD_B0_01,
&pin_GPIO_AD_B0_03,
&pin_GPIO_AD_B0_01, // ID Pin
&pin_GPIO_AD_B0_03, // OC/Fault Pin
NULL, // Must end in NULL.
};

View File

@ -50,8 +50,8 @@ const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
&pin_GPIO_SD_B1_11,
// USB Pins
&pin_GPIO_AD_B0_01,
&pin_GPIO_AD_B0_03,
&pin_GPIO_AD_B0_01, // ID Pin
&pin_GPIO_AD_B0_03, // OC/Fault Pin
NULL, // Must end in NULL.
};

View File

@ -31,8 +31,8 @@
#include "py/gc.h"
STATIC bool claimed_pins[IOMUXC_SW_PAD_CTL_PAD_COUNT];
STATIC bool never_reset_pins[IOMUXC_SW_PAD_CTL_PAD_COUNT];
STATIC bool claimed_pins[PAD_COUNT];
STATIC bool never_reset_pins[PAD_COUNT];
// Default is that no pins are forbidden to reset.
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) {
// and GPIO port and number, used to store claimed and reset tagging. The two number
// systems are not related and one cannot determine the other without a pin object
void reset_all_pins(void) {
for (uint8_t i = 0; i < IOMUXC_SW_PAD_CTL_PAD_COUNT; i++) {
for (uint8_t i = 0; i < PAD_COUNT; i++) {
claimed_pins[i] = never_reset_pins[i];
}
for (uint8_t i = 0; i < IOMUXC_SW_PAD_CTL_PAD_COUNT; i++) {
for (uint8_t i = 0; i < PAD_COUNT; i++) {
mcu_pin_obj_t *pin = mcu_pin_globals.map.table[i].value;
if (never_reset_pins[pin->mux_idx]) {
continue;
@ -90,6 +90,11 @@ void common_hal_reset_pin(const mcu_pin_obj_t *pin) {
disable_pin_change_interrupt(pin);
never_reset_pins[pin->mux_idx] = false;
claimed_pins[pin->mux_idx] = false;
// This should never be true, but protect against it anyway.
if (pin->mux_reg == 0) {
return;
}
*(uint32_t *)pin->mux_reg = pin->mux_reset;
*(uint32_t *)pin->cfg_reg = pin->pad_reset;
}

View File

@ -40,5 +40,7 @@
#include "pin_names.h"
#undef FORMAT_PIN
#define PIN_COUNT (IOMUXC_SW_PAD_CTL_PAD_COUNT + 2)
// Pads can be reset. Other pins like USB cannot be.
#define PAD_COUNT (43)
#define PIN_COUNT (PAD_COUNT + 2)
extern const mcu_pin_obj_t mcu_pin_list[PIN_COUNT];

View File

@ -40,5 +40,7 @@
#include "pin_names.h"
#undef FORMAT_PIN
#define PIN_COUNT (IOMUXC_SW_PAD_CTL_PAD_COUNT + 2)
// Pads can be reset. Other pins like USB cannot be.
#define PAD_COUNT (56)
#define PIN_COUNT (PAD_COUNT + 2)
extern const mcu_pin_obj_t mcu_pin_list[PIN_COUNT];

View File

@ -40,5 +40,7 @@
#include "pin_names.h"
#undef FORMAT_PIN
#define PIN_COUNT (IOMUXC_SW_PAD_CTL_PAD_COUNT + 2)
// Pads can be reset. Other pins like USB cannot be.
#define PAD_COUNT (93)
#define PIN_COUNT (PAD_COUNT + 2)
extern const mcu_pin_obj_t mcu_pin_list[PIN_COUNT];

View File

@ -40,5 +40,7 @@
#include "pin_names.h"
#undef FORMAT_PIN
#define PIN_COUNT (IOMUXC_SW_PAD_CTL_PAD_COUNT + 2)
// Pads can be reset. Other pins like USB cannot be.
#define PAD_COUNT (112)
#define PIN_COUNT (PAD_COUNT + 2)
extern const mcu_pin_obj_t mcu_pin_list[PIN_COUNT];

View File

@ -40,5 +40,7 @@
#include "pin_names.h"
#undef FORMAT_PIN
#define PIN_COUNT (IOMUXC_SW_PAD_CTL_PAD_COUNT + 4)
// Pads can be reset. Other pins like USB cannot be.
#define PAD_COUNT (124)
#define PIN_COUNT (PAD_COUNT + 4)
extern const mcu_pin_obj_t mcu_pin_list[PIN_COUNT];

View File

@ -40,5 +40,7 @@
#include "pin_names.h"
#undef FORMAT_PIN
#define PIN_COUNT (IOMUXC_SW_PAD_CTL_PAD_COUNT + 4)
// Pads can be reset. Other pins like USB cannot be.
#define PAD_COUNT (124)
#define PIN_COUNT (PAD_COUNT + 4)
extern const mcu_pin_obj_t mcu_pin_list[PIN_COUNT];

View File

@ -40,5 +40,7 @@
#include "pin_names.h"
#undef FORMAT_PIN
#define PIN_COUNT (IOMUXC_SW_PAD_CTL_PAD_COUNT + 0)
// Pads can be reset. Other pins like USB cannot be.
#define PAD_COUNT (145)
#define PIN_COUNT (PAD_COUNT + 0)
extern const mcu_pin_obj_t mcu_pin_list[PIN_COUNT];

View File

@ -190,6 +190,7 @@ for device in devices:
split_pin = name.split("_")
pin_name = "_".join(split_pin[4:])
if pin_name not in all_pins:
print("skip", pin_name)
continue
gpio_base = "_".join(split_pin[4:-1])
@ -278,7 +279,10 @@ for device in devices:
pins_c.append("")
pins_h.append("")
pins_h.append(f"#define PIN_COUNT (IOMUXC_SW_PAD_CTL_PAD_COUNT + {len(usb_pins)})")
pins_h.append("// Pads can be reset. Other pins like USB cannot be.")
pins_h.append(f"#define PAD_COUNT ({pin_number})")
pins_h.append(f"#define PIN_COUNT (PAD_COUNT + {len(usb_pins)})")
pins_h.append(f"extern const mcu_pin_obj_t mcu_pin_list[PIN_COUNT];")
pins_h.append("")