|
|
@ -40,6 +40,10 @@ |
|
|
|
#include "machine_rtc.h" |
|
|
|
#include "modesp32.h" |
|
|
|
|
|
|
|
#if CONFIG_IDF_TARGET_ESP32C3 |
|
|
|
#include "hal/gpio_ll.h" |
|
|
|
#endif |
|
|
|
|
|
|
|
// Used to implement a range of pull capabilities
|
|
|
|
#define GPIO_PULL_DOWN (1) |
|
|
|
#define GPIO_PULL_UP (2) |
|
|
@ -99,6 +103,31 @@ STATIC const machine_pin_obj_t machine_pin_obj[] = { |
|
|
|
{{&machine_pin_type}, GPIO_NUM_38}, |
|
|
|
{{&machine_pin_type}, GPIO_NUM_39}, |
|
|
|
|
|
|
|
#elif CONFIG_IDF_TARGET_ESP32C3 |
|
|
|
|
|
|
|
{{&machine_pin_type}, GPIO_NUM_0}, |
|
|
|
{{&machine_pin_type}, GPIO_NUM_1}, |
|
|
|
{{&machine_pin_type}, GPIO_NUM_2}, |
|
|
|
{{&machine_pin_type}, GPIO_NUM_3}, |
|
|
|
{{&machine_pin_type}, GPIO_NUM_4}, |
|
|
|
{{&machine_pin_type}, GPIO_NUM_5}, |
|
|
|
{{&machine_pin_type}, GPIO_NUM_6}, |
|
|
|
{{&machine_pin_type}, GPIO_NUM_7}, |
|
|
|
{{&machine_pin_type}, GPIO_NUM_8}, |
|
|
|
{{&machine_pin_type}, GPIO_NUM_9}, |
|
|
|
{{&machine_pin_type}, GPIO_NUM_10}, |
|
|
|
{{&machine_pin_type}, GPIO_NUM_11}, |
|
|
|
{{&machine_pin_type}, GPIO_NUM_12}, |
|
|
|
{{&machine_pin_type}, GPIO_NUM_13}, |
|
|
|
{{&machine_pin_type}, GPIO_NUM_14}, |
|
|
|
{{&machine_pin_type}, GPIO_NUM_15}, |
|
|
|
{{&machine_pin_type}, GPIO_NUM_16}, |
|
|
|
{{&machine_pin_type}, GPIO_NUM_17}, |
|
|
|
{{&machine_pin_type}, GPIO_NUM_18}, |
|
|
|
{{&machine_pin_type}, GPIO_NUM_19}, |
|
|
|
{{&machine_pin_type}, GPIO_NUM_20}, |
|
|
|
{{&machine_pin_type}, GPIO_NUM_21}, |
|
|
|
|
|
|
|
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 |
|
|
|
|
|
|
|
{{&machine_pin_type}, GPIO_NUM_0}, |
|
|
@ -213,10 +242,18 @@ STATIC mp_obj_t machine_pin_obj_init_helper(const machine_pin_obj_t *self, size_ |
|
|
|
// reset the pin to digital if this is a mode-setting init (grab it back from ADC)
|
|
|
|
if (args[ARG_mode].u_obj != mp_const_none) { |
|
|
|
if (rtc_gpio_is_valid_gpio(self->id)) { |
|
|
|
#if !CONFIG_IDF_TARGET_ESP32C3 |
|
|
|
rtc_gpio_deinit(self->id); |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#if CONFIG_IDF_TARGET_ESP32C3 |
|
|
|
if (self->id == 18 || self->id == 19) { |
|
|
|
CLEAR_PERI_REG_MASK(USB_DEVICE_CONF0_REG, USB_DEVICE_USB_PAD_ENABLE); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
// configure the pin for gpio
|
|
|
|
gpio_pad_select_gpio(self->id); |
|
|
|
|
|
|
@ -494,6 +531,31 @@ STATIC const machine_pin_irq_obj_t machine_pin_irq_object[] = { |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_38}, |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_39}, |
|
|
|
|
|
|
|
#elif CONFIG_IDF_TARGET_ESP32C3 |
|
|
|
|
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_0}, |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_1}, |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_2}, |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_3}, |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_4}, |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_5}, |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_6}, |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_7}, |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_8}, |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_9}, |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_10}, |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_11}, |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_12}, |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_13}, |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_14}, |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_15}, |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_16}, |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_17}, |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_18}, |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_19}, |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_20}, |
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_21}, |
|
|
|
|
|
|
|
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 |
|
|
|
|
|
|
|
{{&machine_pin_irq_type}, GPIO_NUM_0}, |
|
|
|