Merge pull request #7964 from tannewt/fix_imx_usb_reset
Correct pad count.
This commit is contained in:
commit
137e55696e
@ -41,9 +41,6 @@ const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
|
|||||||
&pin_GPIO_SD_08,
|
&pin_GPIO_SD_08,
|
||||||
&pin_GPIO_SD_07,
|
&pin_GPIO_SD_07,
|
||||||
&pin_GPIO_SD_06,
|
&pin_GPIO_SD_06,
|
||||||
// USB Pins
|
|
||||||
&pin_USB_OTG1_DN,
|
|
||||||
&pin_USB_OTG1_DP,
|
|
||||||
NULL, // Must end in NULL.
|
NULL, // Must end in NULL.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -40,9 +40,6 @@ const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
|
|||||||
&pin_GPIO_SD_B1_09,
|
&pin_GPIO_SD_B1_09,
|
||||||
&pin_GPIO_SD_B1_10,
|
&pin_GPIO_SD_B1_10,
|
||||||
&pin_GPIO_SD_B1_11,
|
&pin_GPIO_SD_B1_11,
|
||||||
// USB Pins
|
|
||||||
&pin_USB_OTG1_DN,
|
|
||||||
&pin_USB_OTG1_DP,
|
|
||||||
NULL, // Must end in NULL.
|
NULL, // Must end in NULL.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -42,10 +42,6 @@ const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
|
|||||||
&pin_GPIO_SD_B1_09,
|
&pin_GPIO_SD_B1_09,
|
||||||
&pin_GPIO_SD_B1_10,
|
&pin_GPIO_SD_B1_10,
|
||||||
&pin_GPIO_SD_B1_11,
|
&pin_GPIO_SD_B1_11,
|
||||||
|
|
||||||
// USB Pins
|
|
||||||
&pin_USB_OTG1_DN,
|
|
||||||
&pin_USB_OTG1_DP,
|
|
||||||
NULL, // Must end in NULL.
|
NULL, // Must end in NULL.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -44,9 +44,6 @@ const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
|
|||||||
&pin_GPIO_SD_B1_10,
|
&pin_GPIO_SD_B1_10,
|
||||||
&pin_GPIO_SD_B1_11,
|
&pin_GPIO_SD_B1_11,
|
||||||
|
|
||||||
&pin_USB_OTG1_DN,
|
|
||||||
&pin_USB_OTG1_DP,
|
|
||||||
|
|
||||||
NULL, // Must end in NULL.
|
NULL, // Must end in NULL.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
|
|||||||
&pin_GPIO_SD_B1_11,
|
&pin_GPIO_SD_B1_11,
|
||||||
|
|
||||||
// USB Pins
|
// USB Pins
|
||||||
&pin_GPIO_AD_B0_01,
|
&pin_GPIO_AD_B0_01, // ID Pin
|
||||||
&pin_GPIO_AD_B0_03,
|
&pin_GPIO_AD_B0_03, // OC/Fault Pin
|
||||||
NULL, // Must end in NULL.
|
NULL, // Must end in NULL.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -50,8 +50,8 @@ const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
|
|||||||
&pin_GPIO_SD_B1_11,
|
&pin_GPIO_SD_B1_11,
|
||||||
|
|
||||||
// USB Pins
|
// USB Pins
|
||||||
&pin_GPIO_AD_B0_01,
|
&pin_GPIO_AD_B0_01, // ID Pin
|
||||||
&pin_GPIO_AD_B0_03,
|
&pin_GPIO_AD_B0_03, // OC/Fault Pin
|
||||||
NULL, // Must end in NULL.
|
NULL, // Must end in NULL.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@
|
|||||||
|
|
||||||
#include "py/gc.h"
|
#include "py/gc.h"
|
||||||
|
|
||||||
STATIC bool claimed_pins[IOMUXC_SW_PAD_CTL_PAD_COUNT];
|
STATIC bool claimed_pins[PAD_COUNT];
|
||||||
STATIC bool never_reset_pins[IOMUXC_SW_PAD_CTL_PAD_COUNT];
|
STATIC bool never_reset_pins[PAD_COUNT];
|
||||||
|
|
||||||
// Default is that no pins are forbidden to reset.
|
// Default is that no pins are forbidden to reset.
|
||||||
MP_WEAK const mcu_pin_obj_t *mimxrt10xx_reset_forbidden_pins[] = {
|
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
|
// 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
|
// systems are not related and one cannot determine the other without a pin object
|
||||||
void reset_all_pins(void) {
|
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];
|
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;
|
mcu_pin_obj_t *pin = mcu_pin_globals.map.table[i].value;
|
||||||
if (never_reset_pins[pin->mux_idx]) {
|
if (never_reset_pins[pin->mux_idx]) {
|
||||||
continue;
|
continue;
|
||||||
@ -90,6 +90,11 @@ void common_hal_reset_pin(const mcu_pin_obj_t *pin) {
|
|||||||
disable_pin_change_interrupt(pin);
|
disable_pin_change_interrupt(pin);
|
||||||
never_reset_pins[pin->mux_idx] = false;
|
never_reset_pins[pin->mux_idx] = false;
|
||||||
claimed_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->mux_reg = pin->mux_reset;
|
||||||
*(uint32_t *)pin->cfg_reg = pin->pad_reset;
|
*(uint32_t *)pin->cfg_reg = pin->pad_reset;
|
||||||
}
|
}
|
||||||
|
@ -40,5 +40,7 @@
|
|||||||
#include "pin_names.h"
|
#include "pin_names.h"
|
||||||
#undef FORMAT_PIN
|
#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];
|
extern const mcu_pin_obj_t mcu_pin_list[PIN_COUNT];
|
||||||
|
@ -40,5 +40,7 @@
|
|||||||
#include "pin_names.h"
|
#include "pin_names.h"
|
||||||
#undef FORMAT_PIN
|
#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];
|
extern const mcu_pin_obj_t mcu_pin_list[PIN_COUNT];
|
||||||
|
@ -40,5 +40,7 @@
|
|||||||
#include "pin_names.h"
|
#include "pin_names.h"
|
||||||
#undef FORMAT_PIN
|
#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];
|
extern const mcu_pin_obj_t mcu_pin_list[PIN_COUNT];
|
||||||
|
@ -40,5 +40,7 @@
|
|||||||
#include "pin_names.h"
|
#include "pin_names.h"
|
||||||
#undef FORMAT_PIN
|
#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];
|
extern const mcu_pin_obj_t mcu_pin_list[PIN_COUNT];
|
||||||
|
@ -40,5 +40,7 @@
|
|||||||
#include "pin_names.h"
|
#include "pin_names.h"
|
||||||
#undef FORMAT_PIN
|
#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];
|
extern const mcu_pin_obj_t mcu_pin_list[PIN_COUNT];
|
||||||
|
@ -40,5 +40,7 @@
|
|||||||
#include "pin_names.h"
|
#include "pin_names.h"
|
||||||
#undef FORMAT_PIN
|
#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];
|
extern const mcu_pin_obj_t mcu_pin_list[PIN_COUNT];
|
||||||
|
@ -40,5 +40,7 @@
|
|||||||
#include "pin_names.h"
|
#include "pin_names.h"
|
||||||
#undef FORMAT_PIN
|
#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];
|
extern const mcu_pin_obj_t mcu_pin_list[PIN_COUNT];
|
||||||
|
@ -190,6 +190,7 @@ for device in devices:
|
|||||||
split_pin = name.split("_")
|
split_pin = name.split("_")
|
||||||
pin_name = "_".join(split_pin[4:])
|
pin_name = "_".join(split_pin[4:])
|
||||||
if pin_name not in all_pins:
|
if pin_name not in all_pins:
|
||||||
|
print("skip", pin_name)
|
||||||
continue
|
continue
|
||||||
gpio_base = "_".join(split_pin[4:-1])
|
gpio_base = "_".join(split_pin[4:-1])
|
||||||
|
|
||||||
@ -278,7 +279,10 @@ for device in devices:
|
|||||||
pins_c.append("")
|
pins_c.append("")
|
||||||
|
|
||||||
pins_h.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(f"extern const mcu_pin_obj_t mcu_pin_list[PIN_COUNT];")
|
||||||
pins_h.append("")
|
pins_h.append("")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user