update espressif port

- update esp-idf to v4.4
- add esp32s3 support
- add analogio on esp32c3
- disable rgbmatrix on all espressif soc

Co-authored-by: Scott Shawcroft <scott@adafruit.com>
Co-authored-by: Seon Rozenblum <seon@unexpectedmaker.com>
This commit is contained in:
microDev 2021-11-24 00:00:00 +05:30
parent 387a8a46b3
commit 7ba5513f9a
No known key found for this signature in database
GPG Key ID: 2C0867BE60967730
18 changed files with 243 additions and 57 deletions

2
.gitmodules vendored
View File

@ -149,7 +149,7 @@
[submodule "ports/espressif/esp-idf"] [submodule "ports/espressif/esp-idf"]
path = ports/espressif/esp-idf path = ports/espressif/esp-idf
url = https://github.com/espressif/esp-idf.git url = https://github.com/espressif/esp-idf.git
branch = release/v4.3 branch = release/v4.4
[submodule "ports/espressif/certificates/nina-fw"] [submodule "ports/espressif/certificates/nina-fw"]
path = ports/espressif/certificates/nina-fw path = ports/espressif/certificates/nina-fw
url = https://github.com/adafruit/nina-fw.git url = https://github.com/adafruit/nina-fw.git

View File

@ -59,12 +59,12 @@ include $(TOP)/supervisor/supervisor.mk
# Include make rules and variables common across CircuitPython builds. # Include make rules and variables common across CircuitPython builds.
include $(TOP)/py/circuitpy_defns.mk include $(TOP)/py/circuitpy_defns.mk
ifeq ($(IDF_TARGET),esp32s2) ifeq ($(IDF_TARGET),esp32c3)
IDF_TARGET_ARCH = xtensa
CROSS_COMPILE = xtensa-$(IDF_TARGET)-elf-
else ifeq ($(IDF_TARGET),esp32c3)
IDF_TARGET_ARCH = riscv IDF_TARGET_ARCH = riscv
CROSS_COMPILE = riscv32-esp-elf- CROSS_COMPILE = riscv32-esp-elf-
else
IDF_TARGET_ARCH = xtensa
CROSS_COMPILE = xtensa-$(IDF_TARGET)-elf-
endif endif
####################################### #######################################
@ -92,6 +92,7 @@ INC += -I.\
-isystem esp-idf/components/esp_common/include \ -isystem esp-idf/components/esp_common/include \
-isystem esp-idf/components/esp_event/include \ -isystem esp-idf/components/esp_event/include \
-isystem esp-idf/components/esp_hw_support/include \ -isystem esp-idf/components/esp_hw_support/include \
-isystem esp-idf/components/esp_hw_support/include/soc \
-isystem esp-idf/components/esp_netif/include \ -isystem esp-idf/components/esp_netif/include \
-isystem esp-idf/components/esp_pm/include \ -isystem esp-idf/components/esp_pm/include \
-isystem esp-idf/components/esp_ringbuf/include \ -isystem esp-idf/components/esp_ringbuf/include \
@ -101,6 +102,8 @@ INC += -I.\
-isystem esp-idf/components/esp_wifi/include \ -isystem esp-idf/components/esp_wifi/include \
-isystem esp-idf/components/freertos/include \ -isystem esp-idf/components/freertos/include \
-isystem esp-idf/components/freertos/include/freertos \ -isystem esp-idf/components/freertos/include/freertos \
-isystem esp-idf/components/freertos/include/esp_additions \
-isystem esp-idf/components/freertos/include/esp_additions/freertos \
-isystem esp-idf/components/freertos/port/$(IDF_TARGET_ARCH)/include \ -isystem esp-idf/components/freertos/port/$(IDF_TARGET_ARCH)/include \
-isystem esp-idf/components/hal/include \ -isystem esp-idf/components/hal/include \
-isystem esp-idf/components/hal/$(IDF_TARGET)/include \ -isystem esp-idf/components/hal/$(IDF_TARGET)/include \
@ -158,12 +161,11 @@ endif
LDFLAGS = $(CFLAGS) -Wl,-nostdlib -Wl,-Map=$@.map -Wl,-cref -Wl,--undefined=uxTopUsedPriority LDFLAGS = $(CFLAGS) -Wl,-nostdlib -Wl,-Map=$@.map -Wl,-cref -Wl,--undefined=uxTopUsedPriority
LDFLAGS += -L$(BUILD)/esp-idf/esp-idf/$(IDF_TARGET) \ LDFLAGS += -L$(BUILD)/esp-idf/esp-idf/esp_system/ld \
-L$(BUILD)/esp-idf/esp-idf/$(IDF_TARGET)/ld \
-Lesp-idf/components/$(IDF_TARGET)/ld \
-Lesp-idf/components/esp_rom/$(IDF_TARGET)/ld \ -Lesp-idf/components/esp_rom/$(IDF_TARGET)/ld \
-T$(IDF_TARGET)_out.ld \ -Lesp-idf/components/soc/$(IDF_TARGET)/ld \
-T$(IDF_TARGET).project.ld \ -Tmemory.ld \
-Tsections.ld \
-T$(IDF_TARGET).peripherals.ld \ -T$(IDF_TARGET).peripherals.ld \
-T$(IDF_TARGET).rom.ld \ -T$(IDF_TARGET).rom.ld \
-T$(IDF_TARGET).rom.api.ld \ -T$(IDF_TARGET).rom.api.ld \
@ -174,10 +176,13 @@ ifeq ($(IDF_TARGET),esp32c3)
LDFLAGS += -Tesp32c3.rom.newlib.ld \ LDFLAGS += -Tesp32c3.rom.newlib.ld \
-Tesp32c3.rom.version.ld \ -Tesp32c3.rom.version.ld \
-Tesp32c3.rom.eco3.ld -Tesp32c3.rom.eco3.ld
else else ifeq ($(IDF_TARGET),esp32s2)
LDFLAGS += -T$(IDF_TARGET).rom.newlib-data.ld \ LDFLAGS += -T$(IDF_TARGET).rom.newlib-data.ld \
-T$(IDF_TARGET).rom.newlib-funcs.ld \ -T$(IDF_TARGET).rom.newlib-funcs.ld \
-T$(IDF_TARGET).rom.spiflash.ld -T$(IDF_TARGET).rom.spiflash.ld
else ifeq ($(IDF_TARGET),esp32s3)
LDFLAGS += -Tesp32s3.rom.newlib.ld \
-Tesp32s3.rom.version.ld
endif endif
LDFLAGS += -Wl,-Bstatic \ LDFLAGS += -Wl,-Bstatic \
@ -224,10 +229,14 @@ SRC_C += \
peripherals/timer.c \ peripherals/timer.c \
peripherals/$(IDF_TARGET)/pins.c peripherals/$(IDF_TARGET)/pins.c
ifneq ($(IDF_TARGET),esp32c3) ifeq ($(IDF_TARGET),esp32s2)
SRC_C += \ SRC_C += \
cam.c \ cam.c \
i2s_lcd_esp32s2_driver.c \ i2s_lcd_esp32s2_driver.c
endif
ifneq ($(IDF_TARGET),esp32c3)
SRC_C += \
peripherals/pcnt.c \ peripherals/pcnt.c \
peripherals/touch.c peripherals/touch.c
endif endif
@ -315,20 +324,15 @@ menuconfig: $(BUILD)/esp-idf/config
# qstr builds include headers so we need to make sure they are up to date # qstr builds include headers so we need to make sure they are up to date
$(HEADER_BUILD)/qstr.split: | $(BUILD)/esp-idf/config/sdkconfig.h $(HEADER_BUILD)/qstr.split: | $(BUILD)/esp-idf/config/sdkconfig.h
ESP_IDF_COMPONENTS_LINK = $(IDF_TARGET) $(IDF_TARGET_ARCH) app_update bootloader_support driver efuse esp_adc_cal esp_common esp_event esp_hw_support esp_netif esp_pm esp_ringbuf esp_rom esp_system esp_timer esp-tls esp_wifi freertos hal heap log lwip mbedtls newlib nvs_flash pthread soc spi_flash vfs wpa_supplicant BINARY_WIFI_BLOBS = libcoexist.a libcore.a libespnow.a libmesh.a libnet80211.a libpp.a libsmartconfig.a libwapi.a
BINARY_BLOBS = esp-idf/components/esp_phy/lib/$(IDF_TARGET)/libphy.a $(addprefix esp-idf/components/esp_wifi/lib/$(IDF_TARGET)/, $(BINARY_WIFI_BLOBS))
ESP_IDF_COMPONENTS_LINK = $(IDF_TARGET_ARCH) app_update bootloader_support driver efuse esp_adc_cal esp_common esp_event esp_hw_support esp_ipc esp_netif esp_pm esp_phy esp_ringbuf esp_rom esp_system esp_timer esp-tls esp_wifi freertos hal heap log lwip mbedtls newlib nvs_flash pthread soc spi_flash vfs wpa_supplicant
ESP_IDF_COMPONENTS_EXPANDED = $(foreach component, $(ESP_IDF_COMPONENTS_LINK), $(BUILD)/esp-idf/esp-idf/$(component)/lib$(component).a) ESP_IDF_COMPONENTS_EXPANDED = $(foreach component, $(ESP_IDF_COMPONENTS_LINK), $(BUILD)/esp-idf/esp-idf/$(component)/lib$(component).a)
ESP_IDF_WIFI_COMPONENTS_EXPANDED = $(foreach component, $(ESP_IDF_WIFI_COMPONENTS_LINK), $(BUILD)/esp-idf/esp-idf/$(component)/lib$(component).a)
MBEDTLS_COMPONENTS_LINK = crypto tls x509 MBEDTLS_COMPONENTS_LINK = crypto tls x509
MBEDTLS_COMPONENTS_LINK_EXPANDED = $(foreach component, $(MBEDTLS_COMPONENTS_LINK), $(BUILD)/esp-idf/esp-idf/mbedtls/mbedtls/library/libmbed$(component).a) MBEDTLS_COMPONENTS_LINK_EXPANDED = $(foreach component, $(MBEDTLS_COMPONENTS_LINK), $(BUILD)/esp-idf/esp-idf/mbedtls/mbedtls/library/libmbed$(component).a)
BINARY_WIFI_BLOBS = libcoexist.a libcore.a libespnow.a libmesh.a libnet80211.a libpp.a libsmartconfig.a libphy.a
ifneq ($(IDF_TARGET),esp32c3)
BINARY_WIFI_BLOBS += librtc.a
endif
BINARY_BLOBS = $(addprefix esp-idf/components/esp_wifi/lib/$(IDF_TARGET)/, $(BINARY_WIFI_BLOBS))
ifeq ($(IDF_TARGET_ARCH),xtensa) ifeq ($(IDF_TARGET_ARCH),xtensa)
BINARY_BLOBS += esp-idf/components/xtensa/$(IDF_TARGET)/libxt_hal.a BINARY_BLOBS += esp-idf/components/xtensa/$(IDF_TARGET)/libxt_hal.a
ESP_IDF_COMPONENTS_EXPANDED += esp-idf/components/xtensa/$(IDF_TARGET)/libxt_hal.a ESP_IDF_COMPONENTS_EXPANDED += esp-idf/components/xtensa/$(IDF_TARGET)/libxt_hal.a
@ -360,17 +364,18 @@ endif
esp-idf-stamp: $(BUILD)/esp-idf/config/sdkconfig.h esp-idf-stamp: $(BUILD)/esp-idf/config/sdkconfig.h
$(Q)ninja -C $(BUILD)/esp-idf \ $(Q)ninja -C $(BUILD)/esp-idf \
bootloader/bootloader.bin \ bootloader/bootloader.bin \
esp-idf/esp_system/__ldgen_output_sections.ld \
esp-idf/app_update/libapp_update.a \ esp-idf/app_update/libapp_update.a \
esp-idf/bootloader_support/libbootloader_support.a \ esp-idf/bootloader_support/libbootloader_support.a \
esp-idf/driver/libdriver.a \ esp-idf/driver/libdriver.a \
esp-idf/efuse/libefuse.a \ esp-idf/efuse/libefuse.a \
esp-idf/$(IDF_TARGET)/lib$(IDF_TARGET).a \
esp-idf/$(IDF_TARGET)/ld/$(IDF_TARGET).project.ld \
esp-idf/esp_adc_cal/libesp_adc_cal.a \ esp-idf/esp_adc_cal/libesp_adc_cal.a \
esp-idf/esp_common/libesp_common.a \ esp-idf/esp_common/libesp_common.a \
esp-idf/esp_event/libesp_event.a \ esp-idf/esp_event/libesp_event.a \
esp-idf/esp_hw_support/libesp_hw_support.a \ esp-idf/esp_hw_support/libesp_hw_support.a \
esp-idf/esp_ipc/libesp_ipc.a \
esp-idf/esp_netif/libesp_netif.a \ esp-idf/esp_netif/libesp_netif.a \
esp-idf/esp_phy/libesp_phy.a \
esp-idf/esp_pm/libesp_pm.a \ esp-idf/esp_pm/libesp_pm.a \
esp-idf/esp_ringbuf/libesp_ringbuf.a \ esp-idf/esp_ringbuf/libesp_ringbuf.a \
esp-idf/esp_rom/libesp_rom.a \ esp-idf/esp_rom/libesp_rom.a \

View File

@ -21,8 +21,13 @@
#include "esp_log.h" #include "esp_log.h"
#include "soc/i2s_struct.h" #include "soc/i2s_struct.h"
#include "soc/apb_ctrl_reg.h" #include "soc/apb_ctrl_reg.h"
#ifdef CONFIG_IDF_TARGET_ESP32S2
#include "esp32s2/rom/lldesc.h" #include "esp32s2/rom/lldesc.h"
#include "esp32s2/rom/cache.h" #include "esp32s2/rom/cache.h"
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
#include "esp32s3/rom/lldesc.h"
#include "esp32s3/rom/cache.h"
#endif
#include "soc/dport_access.h" #include "soc/dport_access.h"
#include "soc/dport_reg.h" #include "soc/dport_reg.h"
#include "driver/ledc.h" #include "driver/ledc.h"

View File

@ -32,11 +32,11 @@
#include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/__init__.h"
#include "esp_sleep.h"
#include "hal/gpio_ll.h" #include "hal/gpio_ll.h"
#include "esp_debug_helpers.h" #include "esp_debug_helpers.h"
#include "components/driver/include/driver/rtc_io.h" #include "components/driver/include/driver/rtc_io.h"
#include "components/esp_system/include/esp_sleep.h"
#include "components/freertos/include/freertos/FreeRTOS.h" #include "components/freertos/include/freertos/FreeRTOS.h"
void common_hal_alarm_pin_pinalarm_construct(alarm_pin_pinalarm_obj_t *self, const mcu_pin_obj_t *pin, bool value, bool edge, bool pull) { void common_hal_alarm_pin_pinalarm_construct(alarm_pin_pinalarm_obj_t *self, const mcu_pin_obj_t *pin, bool value, bool edge, bool pull) {

View File

@ -40,7 +40,13 @@
#define DEFAULT_VREF 1100 #define DEFAULT_VREF 1100
#define NO_OF_SAMPLES 2 #define NO_OF_SAMPLES 2
#define ATTENUATION ADC_ATTEN_DB_11 #define ATTENUATION ADC_ATTEN_DB_11
#ifdef CONFIG_IDF_TARGET_ESP32C3
#define DATA_WIDTH ADC_WIDTH_BIT_12
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
#define DATA_WIDTH ADC_WIDTH_BIT_13 #define DATA_WIDTH ADC_WIDTH_BIT_13
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
#define DATA_WIDTH ADC_WIDTH_BIT_12
#endif
void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self, void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self,
const mcu_pin_obj_t *pin) { const mcu_pin_obj_t *pin) {

View File

@ -41,6 +41,7 @@
void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self, void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self,
const mcu_pin_obj_t *pin) { const mcu_pin_obj_t *pin) {
#ifdef CONFIG_IDF_TARGET_ESP32S2
if (pin == &pin_GPIO17) { if (pin == &pin_GPIO17) {
self->channel = DAC_CHANNEL_1; self->channel = DAC_CHANNEL_1;
} else if (pin == &pin_GPIO18) { } else if (pin == &pin_GPIO18) {
@ -49,6 +50,9 @@ void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self,
mp_raise_ValueError(translate("Invalid DAC pin supplied")); mp_raise_ValueError(translate("Invalid DAC pin supplied"));
} }
dac_output_enable(self->channel); dac_output_enable(self->channel);
#else
mp_raise_NotImplementedError(NULL);
#endif
} }
bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) { bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) {
@ -56,18 +60,24 @@ bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) {
} }
void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) { void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) {
#ifdef CONFIG_IDF_TARGET_ESP32S2
dac_output_disable(self->channel); dac_output_disable(self->channel);
self->channel = DAC_CHANNEL_MAX; self->channel = DAC_CHANNEL_MAX;
#endif
} }
void common_hal_analogio_analogout_set_value(analogio_analogout_obj_t *self, void common_hal_analogio_analogout_set_value(analogio_analogout_obj_t *self,
uint16_t value) { uint16_t value) {
#ifdef CONFIG_IDF_TARGET_ESP32S2
uint8_t dac_value = (value * 255) / 65535; uint8_t dac_value = (value * 255) / 65535;
dac_output_enable(self->channel); dac_output_enable(self->channel);
dac_output_voltage(self->channel, dac_value); dac_output_voltage(self->channel, dac_value);
#endif
} }
void analogout_reset(void) { void analogout_reset(void) {
#ifdef CONFIG_IDF_TARGET_ESP32S2
dac_output_disable(DAC_CHANNEL_1); dac_output_disable(DAC_CHANNEL_1);
dac_output_disable(DAC_CHANNEL_2); dac_output_disable(DAC_CHANNEL_2);
#endif
} }

View File

@ -56,11 +56,15 @@ static void IRAM_ATTR timer_interrupt_handler(void *self_in) {
// reset interrupt // reset interrupt
timg_dev_t *device = self->timer.group ? &(TIMERG1) : &(TIMERG0); timg_dev_t *device = self->timer.group ? &(TIMERG1) : &(TIMERG0);
if (self->timer.idx) { if (self->timer.idx) {
device->int_clr.t1 = 1; device->int_clr_timers.t1_int_clr = 1;
} else { } else {
device->int_clr.t0 = 1; device->int_clr_timers.t0_int_clr = 1;
} }
device->hw_timer[self->timer.idx].config.alarm_en = 1; #ifdef CONFIG_IDF_TARGET_ESP32S2
device->hw_timer[self->timer.idx].config.tx_alarm_en = 1;
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
device->hw_timer[self->timer.idx].config.tn_alarm_en = 1;
#endif
} }
static void init_pcnt(frequencyio_frequencyin_obj_t *self) { static void init_pcnt(frequencyio_frequencyin_obj_t *self) {

View File

@ -43,11 +43,15 @@
float common_hal_mcu_processor_get_temperature(void) { float common_hal_mcu_processor_get_temperature(void) {
float tsens_out; float tsens_out;
#ifdef CONFIG_IDF_TARGET_ESP32S3
mp_raise_NotImplementedError(NULL);
#else
temp_sensor_config_t temp_sensor = TSENS_CONFIG_DEFAULT(); // DEFAULT: range:-10℃ ~ 80℃, error < 1℃. temp_sensor_config_t temp_sensor = TSENS_CONFIG_DEFAULT(); // DEFAULT: range:-10℃ ~ 80℃, error < 1℃.
temp_sensor_set_config(temp_sensor); temp_sensor_set_config(temp_sensor);
temp_sensor_start(); temp_sensor_start();
temp_sensor_read_celsius(&tsens_out); temp_sensor_read_celsius(&tsens_out);
temp_sensor_stop(); temp_sensor_stop();
#endif
return tsens_out; return tsens_out;
} }

View File

@ -47,13 +47,16 @@
#ifdef CONFIG_IDF_TARGET_ESP32C3 #ifdef CONFIG_IDF_TARGET_ESP32C3
#include "esp32c3/rom/rtc.h" #include "esp32c3/rom/rtc.h"
#elif CONFIG_IDF_TARGET_ESP32S2 #elif defined(CONFIG_IDF_TARGET_ESP32S2)
#include "esp32s2/rom/rtc.h" #include "esp32s2/rom/rtc.h"
#include "esp32s2/rom/usb/usb_persist.h" #include "esp32s2/rom/usb/usb_persist.h"
#include "esp32s2/rom/usb/chip_usb_dw_wrapper.h" #include "esp32s2/rom/usb/chip_usb_dw_wrapper.h"
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
#include "esp32s3/rom/rtc.h"
#include "esp32s3/rom/usb/usb_persist.h"
#include "esp32s3/rom/usb/chip_usb_dw_wrapper.h"
#endif #endif
void common_hal_mcu_delay_us(uint32_t delay) { void common_hal_mcu_delay_us(uint32_t delay) {
mp_hal_delay_us(delay); mp_hal_delay_us(delay);
} }

@ -1 +1 @@
Subproject commit e493a4c30e1b2f7c54a376327388b9e12262cbbf Subproject commit ddc44956bf718540d5451e17e1becf6c7dffe5b8

View File

@ -26,7 +26,7 @@ CIRCUITPY_FRAMEBUFFERIO ?= 1
CIRCUITPY_FREQUENCYIO ?= 1 CIRCUITPY_FREQUENCYIO ?= 1
CIRCUITPY_IMAGECAPTURE ?= 1 CIRCUITPY_IMAGECAPTURE ?= 1
CIRCUITPY_I2CPERIPHERAL ?= 1 CIRCUITPY_I2CPERIPHERAL ?= 1
CIRCUITPY_RGBMATRIX ?= 1 CIRCUITPY_RGBMATRIX ?= 0
CIRCUITPY_ROTARYIO ?= 1 CIRCUITPY_ROTARYIO ?= 1
CIRCUITPY_NVM ?= 1 CIRCUITPY_NVM ?= 1
CIRCUITPY_PS2IO ?= 1 CIRCUITPY_PS2IO ?= 1
@ -43,17 +43,18 @@ CIRCUITPY_USB = 0
CIRCUITPY_ALARM = 0 CIRCUITPY_ALARM = 0
CIRCUITPY_COUNTIO = 0 CIRCUITPY_COUNTIO = 0
CIRCUITPY_ROTARYIO = 0 CIRCUITPY_ROTARYIO = 0
CIRCUITPY_ANALOGIO = 0
CIRCUITPY_RGBMATRIX = 0
CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_IMAGECAPTURE = 0 CIRCUITPY_IMAGECAPTURE = 0
CIRCUITPY_PARALLELDISPLAY = 0 CIRCUITPY_PARALLELDISPLAY = 0
CIRCUITPY_TOUCHIO ?= 1 CIRCUITPY_TOUCHIO ?= 1
CIRCUITPY_TOUCHIO_USE_NATIVE = 0 CIRCUITPY_TOUCHIO_USE_NATIVE = 0
else ifeq ($(IDF_TARGET),esp32s3)
CIRCUITPY_IMAGECAPTURE = 0
CIRCUITPY_PARALLELDISPLAY = 0
endif endif
# From the ESP32-S2 datasheet: # From ESP32-S2/S3 Technical Reference Manual:
# #
# Endpoint number 0 always present (bi-directional, consisting of EP0 IN and EP0 OUT) # Endpoint number 0 always present (bi-directional, consisting of EP0 IN and EP0 OUT)
# Six additional endpoints (endpoint numbers 1 to 6), configurable as IN or OUT # Six additional endpoints (endpoint numbers 1 to 6), configurable as IN or OUT

View File

@ -25,22 +25,17 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include <string.h>
#include "py/mphal.h" #include "py/mphal.h"
#include "py/mpstate.h" #include "supervisor/cpu.h"
#include "py/gc.h"
#include "esp_debug_helpers.h"
#ifdef CONFIG_IDF_TARGET_ESP32C3 #ifdef CONFIG_IDF_TARGET_ESP32C3
#include "components/esp_rom/include/esp32c3/rom/ets_sys.h" #include "components/esp_rom/include/esp32c3/rom/ets_sys.h"
#elif CONFIG_IDF_TARGET_ESP32S2 #elif defined(CONFIG_IDF_TARGET_ESP32S2)
#include "components/esp_rom/include/esp32s2/rom/ets_sys.h" #include "components/esp_rom/include/esp32s2/rom/ets_sys.h"
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
#include "components/esp_rom/include/esp32s3/rom/ets_sys.h"
#endif #endif
#include "supervisor/cpu.h"
void mp_hal_delay_us(mp_uint_t delay) { void mp_hal_delay_us(mp_uint_t delay) {
ets_delay_us(delay); ets_delay_us(delay);
} }

View File

@ -0,0 +1,73 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2021 microDev
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "peripherals/pins.h"
const mcu_pin_obj_t pin_GPIO0 = PIN(0, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO1 = PIN(1, ADC_UNIT_1, ADC_CHANNEL_0, TOUCH_PAD_NUM1);
const mcu_pin_obj_t pin_GPIO2 = PIN(2, ADC_UNIT_1, ADC_CHANNEL_1, TOUCH_PAD_NUM2);
const mcu_pin_obj_t pin_GPIO3 = PIN(3, ADC_UNIT_1, ADC_CHANNEL_2, TOUCH_PAD_NUM3);
const mcu_pin_obj_t pin_GPIO4 = PIN(4, ADC_UNIT_1, ADC_CHANNEL_3, TOUCH_PAD_NUM4);
const mcu_pin_obj_t pin_GPIO5 = PIN(5, ADC_UNIT_1, ADC_CHANNEL_4, TOUCH_PAD_NUM5);
const mcu_pin_obj_t pin_GPIO6 = PIN(6, ADC_UNIT_1, ADC_CHANNEL_5, TOUCH_PAD_NUM6);
const mcu_pin_obj_t pin_GPIO7 = PIN(7, ADC_UNIT_1, ADC_CHANNEL_6, TOUCH_PAD_NUM7);
const mcu_pin_obj_t pin_GPIO8 = PIN(8, ADC_UNIT_1, ADC_CHANNEL_7, TOUCH_PAD_NUM8);
const mcu_pin_obj_t pin_GPIO9 = PIN(9, ADC_UNIT_1, ADC_CHANNEL_8, TOUCH_PAD_NUM9);
const mcu_pin_obj_t pin_GPIO10 = PIN(10, ADC_UNIT_1, ADC_CHANNEL_9, TOUCH_PAD_NUM10);
const mcu_pin_obj_t pin_GPIO11 = PIN(11, ADC_UNIT_2, ADC_CHANNEL_0, TOUCH_PAD_NUM11);
const mcu_pin_obj_t pin_GPIO12 = PIN(12, ADC_UNIT_2, ADC_CHANNEL_1, TOUCH_PAD_NUM12);
const mcu_pin_obj_t pin_GPIO13 = PIN(13, ADC_UNIT_2, ADC_CHANNEL_2, TOUCH_PAD_NUM13);
const mcu_pin_obj_t pin_GPIO14 = PIN(14, ADC_UNIT_2, ADC_CHANNEL_3, TOUCH_PAD_NUM14);
const mcu_pin_obj_t pin_GPIO15 = PIN(15, ADC_UNIT_2, ADC_CHANNEL_4, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO16 = PIN(16, ADC_UNIT_2, ADC_CHANNEL_5, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO17 = PIN(17, ADC_UNIT_2, ADC_CHANNEL_6, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO18 = PIN(18, ADC_UNIT_2, ADC_CHANNEL_7, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO19 = PIN(19, ADC_UNIT_2, ADC_CHANNEL_8, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO20 = PIN(20, ADC_UNIT_2, ADC_CHANNEL_9, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO21 = PIN(21, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO26 = PIN(26, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO27 = PIN(27, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO28 = PIN(28, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO29 = PIN(29, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO30 = PIN(30, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO31 = PIN(31, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO32 = PIN(32, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO33 = PIN(33, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO34 = PIN(34, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO35 = PIN(35, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO36 = PIN(36, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO37 = PIN(37, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO38 = PIN(38, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO39 = PIN(39, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO40 = PIN(40, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO41 = PIN(41, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO42 = PIN(42, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO43 = PIN(43, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO44 = PIN(44, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO45 = PIN(45, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO46 = PIN(46, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO47 = PIN(47, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);
const mcu_pin_obj_t pin_GPIO48 = PIN(48, NO_ADC, NO_ADC_CHANNEL, NO_TOUCH_CHANNEL);

View File

@ -0,0 +1,80 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2021 microDev
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
// DO NOT include this file directly.
// Use shared-bindings/microcontroller/Pin.h instead.
// This ensures that all necessary includes are already included.
#ifndef MICROPY_INCLUDED_ESPRESSIF_PERIPHERALS_ESP32S3_PINS_H
#define MICROPY_INCLUDED_ESPRESSIF_PERIPHERALS_ESP32S3_PINS_H
extern const mcu_pin_obj_t pin_GPIO0;
extern const mcu_pin_obj_t pin_GPIO1;
extern const mcu_pin_obj_t pin_GPIO2;
extern const mcu_pin_obj_t pin_GPIO3;
extern const mcu_pin_obj_t pin_GPIO4;
extern const mcu_pin_obj_t pin_GPIO5;
extern const mcu_pin_obj_t pin_GPIO6;
extern const mcu_pin_obj_t pin_GPIO7;
extern const mcu_pin_obj_t pin_GPIO8;
extern const mcu_pin_obj_t pin_GPIO9;
extern const mcu_pin_obj_t pin_GPIO10;
extern const mcu_pin_obj_t pin_GPIO11;
extern const mcu_pin_obj_t pin_GPIO12;
extern const mcu_pin_obj_t pin_GPIO13;
extern const mcu_pin_obj_t pin_GPIO14;
extern const mcu_pin_obj_t pin_GPIO15;
extern const mcu_pin_obj_t pin_GPIO16;
extern const mcu_pin_obj_t pin_GPIO17;
extern const mcu_pin_obj_t pin_GPIO18;
extern const mcu_pin_obj_t pin_GPIO19;
extern const mcu_pin_obj_t pin_GPIO20;
extern const mcu_pin_obj_t pin_GPIO21;
extern const mcu_pin_obj_t pin_GPIO26;
extern const mcu_pin_obj_t pin_GPIO27;
extern const mcu_pin_obj_t pin_GPIO28;
extern const mcu_pin_obj_t pin_GPIO29;
extern const mcu_pin_obj_t pin_GPIO30;
extern const mcu_pin_obj_t pin_GPIO31;
extern const mcu_pin_obj_t pin_GPIO32;
extern const mcu_pin_obj_t pin_GPIO33;
extern const mcu_pin_obj_t pin_GPIO34;
extern const mcu_pin_obj_t pin_GPIO35;
extern const mcu_pin_obj_t pin_GPIO36;
extern const mcu_pin_obj_t pin_GPIO37;
extern const mcu_pin_obj_t pin_GPIO38;
extern const mcu_pin_obj_t pin_GPIO39;
extern const mcu_pin_obj_t pin_GPIO40;
extern const mcu_pin_obj_t pin_GPIO41;
extern const mcu_pin_obj_t pin_GPIO42;
extern const mcu_pin_obj_t pin_GPIO43;
extern const mcu_pin_obj_t pin_GPIO44;
extern const mcu_pin_obj_t pin_GPIO45;
extern const mcu_pin_obj_t pin_GPIO46;
extern const mcu_pin_obj_t pin_GPIO47;
extern const mcu_pin_obj_t pin_GPIO48;
#endif // MICROPY_INCLUDED_ESPRESSIF_PERIPHERALS_ESP32S3_PINS_H

View File

@ -28,6 +28,7 @@
#define MICROPY_INCLUDED_ESPRESSIF_PERIPHERALS_PCNT_HANDLER_H #define MICROPY_INCLUDED_ESPRESSIF_PERIPHERALS_PCNT_HANDLER_H
#include "driver/pcnt.h" #include "driver/pcnt.h"
#include "soc/pcnt_struct.h"
extern int peripherals_pcnt_init(pcnt_config_t pcnt_config); extern int peripherals_pcnt_init(pcnt_config_t pcnt_config);
extern void peripherals_pcnt_deinit(pcnt_unit_t *unit); extern void peripherals_pcnt_deinit(pcnt_unit_t *unit);

View File

@ -67,8 +67,10 @@ extern const mp_obj_type_t mcu_pin_type;
// Choose based on chip // Choose based on chip
#ifdef CONFIG_IDF_TARGET_ESP32C3 #ifdef CONFIG_IDF_TARGET_ESP32C3
#include "esp32c3/pins.h" #include "esp32c3/pins.h"
#elif CONFIG_IDF_TARGET_ESP32S2 #elif defined(CONFIG_IDF_TARGET_ESP32S2)
#include "esp32s2/pins.h" #include "esp32s2/pins.h"
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
#include "esp32s3/pins.h"
#endif #endif
#endif // MICROPY_INCLUDED_ESPRESSIF_PERIPHERALS_PINS_H #endif // MICROPY_INCLUDED_ESPRESSIF_PERIPHERALS_PINS_H

View File

@ -58,6 +58,9 @@
#if CIRCUITPY_COUNTIO || CIRCUITPY_ROTARYIO || CIRCUITPY_FREQUENCYIO #if CIRCUITPY_COUNTIO || CIRCUITPY_ROTARYIO || CIRCUITPY_FREQUENCYIO
#include "peripherals/pcnt.h" #include "peripherals/pcnt.h"
#endif
#if CIRCUITPY_TOUCHIO_USE_NATIVE
#include "peripherals/touch.h" #include "peripherals/touch.h"
#endif #endif
@ -69,17 +72,10 @@
#include "cam.h" #include "cam.h"
#endif #endif
#include "esp_heap_caps.h"
#include "esp_debug_helpers.h"
#include "soc/cache_memory.h" #include "soc/cache_memory.h"
#include "soc/rtc_cntl_reg.h" #include "soc/rtc_cntl_reg.h"
#ifdef CONFIG_IDF_TARGET_ESP32C3 #include "esp_debug_helpers.h"
#include "components/esp_rom/include/esp32c3/rom/ets_sys.h"
#elif CONFIG_IDF_TARGET_ESP32S2
#include "components/esp_rom/include/esp32s2/rom/ets_sys.h"
#endif
#define HEAP_SIZE (48 * 1024) #define HEAP_SIZE (48 * 1024)
@ -136,7 +132,7 @@ safe_mode_t port_init(void) {
#ifdef CONFIG_IDF_TARGET_ESP32C3 #ifdef CONFIG_IDF_TARGET_ESP32C3
common_hal_never_reset_pin(&pin_GPIO20); common_hal_never_reset_pin(&pin_GPIO20);
common_hal_never_reset_pin(&pin_GPIO21); common_hal_never_reset_pin(&pin_GPIO21);
#elif CONFIG_IDF_TARGET_ESP32S2 #elif defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)
common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO43);
common_hal_never_reset_pin(&pin_GPIO44); common_hal_never_reset_pin(&pin_GPIO44);
#endif #endif
@ -153,7 +149,7 @@ safe_mode_t port_init(void) {
common_hal_never_reset_pin(&pin_GPIO5); common_hal_never_reset_pin(&pin_GPIO5);
common_hal_never_reset_pin(&pin_GPIO6); common_hal_never_reset_pin(&pin_GPIO6);
common_hal_never_reset_pin(&pin_GPIO7); common_hal_never_reset_pin(&pin_GPIO7);
#elif CONFIG_IDF_TARGET_ESP32S2 #elif defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)
common_hal_never_reset_pin(&pin_GPIO39); common_hal_never_reset_pin(&pin_GPIO39);
common_hal_never_reset_pin(&pin_GPIO40); common_hal_never_reset_pin(&pin_GPIO40);
common_hal_never_reset_pin(&pin_GPIO41); common_hal_never_reset_pin(&pin_GPIO41);

View File

@ -33,6 +33,7 @@
#include "shared/readline/readline.h" #include "shared/readline/readline.h"
#include "hal/gpio_ll.h" #include "hal/gpio_ll.h"
#include "hal/usb_hal.h"
#include "soc/usb_periph.h" #include "soc/usb_periph.h"
#include "components/driver/include/driver/gpio.h" #include "components/driver/include/driver/gpio.h"
@ -40,15 +41,15 @@
#ifdef CONFIG_IDF_TARGET_ESP32C3 #ifdef CONFIG_IDF_TARGET_ESP32C3
#include "components/esp_rom/include/esp32c3/rom/gpio.h" #include "components/esp_rom/include/esp32c3/rom/gpio.h"
#elif CONFIG_IDF_TARGET_ESP32S2 #elif defined(CONFIG_IDF_TARGET_ESP32S2)
#include "components/esp_rom/include/esp32s2/rom/gpio.h" #include "components/esp_rom/include/esp32s2/rom/gpio.h"
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
#include "components/esp_rom/include/esp32s3/rom/gpio.h"
#endif #endif
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "hal/usb_hal.h"
#include "tusb.h" #include "tusb.h"
#ifdef CFG_TUSB_DEBUG #ifdef CFG_TUSB_DEBUG