From 6d24440d7dffb8db7ec8a84034791282fb49ca4e Mon Sep 17 00:00:00 2001 From: windowsair Date: Sat, 10 Sep 2022 11:14:11 +0800 Subject: [PATCH] feat(esp32): Update esp-idf to v4.4 --- components/DAP/include/gpio_common.h | 36 +++++++++++ components/DAP/include/gpio_op.h | 22 ++----- components/DAP/source/spi_op.c | 16 +---- components/DAP/source/spi_switch.c | 20 +----- sdkconfig.defaults.esp32 | 96 +++++++++------------------- 5 files changed, 76 insertions(+), 114 deletions(-) create mode 100644 components/DAP/include/gpio_common.h diff --git a/components/DAP/include/gpio_common.h b/components/DAP/include/gpio_common.h new file mode 100644 index 0000000..ae77677 --- /dev/null +++ b/components/DAP/include/gpio_common.h @@ -0,0 +1,36 @@ +#ifndef __GPIO_COMMON_H__ +#define __GPIO_COMMON_H__ + +#include "sdkconfig.h" +#include "esp_idf_version.h" + +#ifdef CONFIG_IDF_TARGET_ESP8266 + #include "esp8266/spi_struct.h" + #include "gpio.h" + #include "esp8266/include/esp8266/gpio_struct.h" + #include "esp8266/include/esp8266/timer_struct.h" + #include "esp8266/pin_mux_register.h" + +#elif defined CONFIG_IDF_TARGET_ESP32 + #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0) + #include "soc/esp32/include/soc/gpio_struct.h" + #include "soc/esp32/include/soc/dport_access.h" + #include "soc/esp32/include/soc/dport_reg.h" + #include "soc/esp32/include/soc/periph_defs.h" + #include "soc/esp32/include/soc/spi_struct.h" + #include "soc/esp32/include/soc/spi_reg.h" + #else + #include "soc/soc/esp32/include/soc/gpio_struct.h" + #include "soc/soc/esp32/include/soc/dport_access.h" + #include "soc/soc/esp32/include/soc/dport_reg.h" + #include "soc/soc/esp32/include/soc/periph_defs.h" + #include "soc/soc/esp32/include/soc/spi_struct.h" + #include "soc/soc/esp32/include/soc/spi_reg.h" + #endif + #include "hal/gpio_types.h" +#else + #error unknown hardware +#endif + + +#endif \ No newline at end of file diff --git a/components/DAP/include/gpio_op.h b/components/DAP/include/gpio_op.h index 9223ac1..8389972 100644 --- a/components/DAP/include/gpio_op.h +++ b/components/DAP/include/gpio_op.h @@ -14,19 +14,7 @@ #include "sdkconfig.h" #include "components/DAP/include/cmsis_compiler.h" -#ifdef CONFIG_IDF_TARGET_ESP8266 - #include "gpio.h" - #include "esp8266/include/esp8266/gpio_struct.h" - #include "esp8266/include/esp8266/timer_struct.h" - #include "esp8266/pin_mux_register.h" -#elif defined CONFIG_IDF_TARGET_ESP32 - // soc register - // #include "soc/soc/esp32/rom/gpio.h" - #include "soc/soc/esp32/include/soc/gpio_struct.h" - #include "hal/gpio_types.h" -#else - #error unknown hardware -#endif +#include "components/DAP/include/gpio_common.h" @@ -50,7 +38,7 @@ __STATIC_INLINE __UNUSED void GPIO_FUNCTION_SET(int io_num) WRITE_PERI_REG(GPIO_PIN_REG(io_num), pin_reg.val); } #elif defined CONFIG_IDF_TARGET_ESP32 -__STATIC_INLINE void GPIO_FUNCTION_SET(int io_num) +__STATIC_INLINE __UNUSED void GPIO_FUNCTION_SET(int io_num) { // function number 2 is GPIO_FUNC for each pin // Note that the index starts at 0, so we are using function 3. @@ -59,14 +47,14 @@ __STATIC_INLINE void GPIO_FUNCTION_SET(int io_num) #endif #ifdef CONFIG_IDF_TARGET_ESP8266 -__UNUSED static void GPIO_SET_DIRECTION_NORMAL_OUT(int io_num) +__STATIC_INLINE __UNUSED void GPIO_SET_DIRECTION_NORMAL_OUT(int io_num) { GPIO.enable_w1ts |= (0x1 << io_num); // PP out GPIO.pin[io_num].driver = 0; } #elif defined CONFIG_IDF_TARGET_ESP32 -static void GPIO_SET_DIRECTION_NORMAL_OUT(int io_num) +__STATIC_INLINE __UNUSED void GPIO_SET_DIRECTION_NORMAL_OUT(int io_num) { GPIO.enable_w1ts = (0x1 << io_num); // PP out @@ -84,7 +72,7 @@ __STATIC_INLINE __UNUSED void GPIO_SET_LEVEL_HIGH(int io_num) #ifdef CONFIG_IDF_TARGET_ESP32 -__STATIC_INLINE void GPIO_PULL_UP_ONLY_SET(int io_num) +__STATIC_INLINE __UNUSED void GPIO_PULL_UP_ONLY_SET(int io_num) { // disable pull down REG_CLR_BIT(GPIO_PIN_MUX_REG[io_num], FUN_PD); diff --git a/components/DAP/source/spi_op.c b/components/DAP/source/spi_op.c index 7579ec9..8a0ada9 100644 --- a/components/DAP/source/spi_op.c +++ b/components/DAP/source/spi_op.c @@ -21,21 +21,11 @@ #include "components/DAP/include/cmsis_compiler.h" #include "components/DAP/include/spi_op.h" #include "components/DAP/include/spi_switch.h" +#include "components/DAP/include/gpio_common.h" #ifdef CONFIG_IDF_TARGET_ESP8266 -#include "esp8266/spi_struct.h" - -#define DAP_SPI SPI1 - #elif defined CONFIG_IDF_TARGET_ESP32 - #include "soc/soc/esp32/include/soc/gpio_struct.h" - #include "hal/gpio_types.h" - - #include "soc/soc/esp32/include/soc/dport_access.h" - #include "soc/soc/esp32/include/soc/dport_reg.h" - #include "soc/soc/esp32/include/soc/periph_defs.h" - #include "soc/soc/esp32/include/soc/spi_struct.h" - #include "soc/soc/esp32/include/soc/spi_reg.h" - + #define DAP_SPI SPI1 +#elif defined CONFIG_IDF_TARGET_ESP32 #define DAP_SPI SPI2 #else #error unknown hardware diff --git a/components/DAP/source/spi_switch.c b/components/DAP/source/spi_switch.c index da33a08..e334e11 100644 --- a/components/DAP/source/spi_switch.c +++ b/components/DAP/source/spi_switch.c @@ -16,31 +16,15 @@ #include "components/DAP/include/cmsis_compiler.h" #include "components/DAP/include/spi_switch.h" +#include "components/DAP/include/gpio_common.h" #ifdef CONFIG_IDF_TARGET_ESP8266 - #include "esp8266/spi_struct.h" - #include "esp8266/pin_mux_register.h" - #include "esp8266/gpio_struct.h" -#define DAP_SPI SPI1 - + #define DAP_SPI SPI1 #elif defined CONFIG_IDF_TARGET_ESP32 -// soc register - #include "soc/soc/esp32/include/soc/gpio_struct.h" - #include "hal/gpio_types.h" - - #include "soc/soc/esp32/include/soc/dport_access.h" - #include "soc/soc/esp32/include/soc/dport_reg.h" - #include "soc/soc/esp32/include/soc/periph_defs.h" - #include "soc/soc/esp32/include/soc/spi_struct.h" - #include "soc/soc/esp32/include/soc/spi_reg.h" - #define DAP_SPI SPI2 - // Note that the index starts at 0, so we are using function 2(SPI). #define FUNC_SPI 1 - #define SPI2_HOST 1 - #define SPI_LL_RST_MASK (SPI_OUT_RST | SPI_IN_RST | SPI_AHBM_RST | SPI_AHBM_FIFO_RST) #else diff --git a/sdkconfig.defaults.esp32 b/sdkconfig.defaults.esp32 index f145d06..4fb6814 100644 --- a/sdkconfig.defaults.esp32 +++ b/sdkconfig.defaults.esp32 @@ -1,7 +1,3 @@ -# -# Automatically generated file. DO NOT EDIT. -# Espressif IoT Development Framework (ESP-IDF) Project Configuration -# CONFIG_IDF_CMAKE=y CONFIG_IDF_TARGET="esp32" CONFIG_IDF_TARGET_ESP32=y @@ -157,15 +153,6 @@ CONFIG_APPTRACE_LOCK_ENABLE=y # Bluetooth # # CONFIG_BT_ENABLED is not set -CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF=0 -CONFIG_BTDM_CTRL_PCM_ROLE_EFF=0 -CONFIG_BTDM_CTRL_PCM_POLAR_EFF=0 -CONFIG_BTDM_CTRL_BLE_MAX_CONN_EFF=0 -CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF=0 -CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF=0 -CONFIG_BTDM_CTRL_PINNED_TO_CORE=0 -CONFIG_BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF=1 -CONFIG_BT_RESERVE_DRAM=0 # end of Bluetooth # @@ -251,7 +238,7 @@ CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR=y CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES=4 # CONFIG_ESP32_ULP_COPROC_ENABLED is not set CONFIG_ESP32_ULP_COPROC_RESERVE_MEM=0 -CONFIG_ESP32_DEBUG_OCDAWARE=y +# CONFIG_ESP32_DEBUG_OCDAWARE is not set CONFIG_ESP32_BROWNOUT_DET=y CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_0=y # CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_1 is not set @@ -262,7 +249,6 @@ CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_0=y # CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_6 is not set # CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_7 is not set CONFIG_ESP32_BROWNOUT_DET_LVL=0 -CONFIG_ESP32_REDUCE_PHY_TX_POWER=y CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1=y # CONFIG_ESP32_TIME_SYSCALL_USE_RTC is not set # CONFIG_ESP32_TIME_SYSCALL_USE_FRC1 is not set @@ -273,10 +259,6 @@ CONFIG_ESP32_RTC_CLK_SRC_INT_RC=y # CONFIG_ESP32_RTC_CLK_SRC_INT_8MD256 is not set CONFIG_ESP32_RTC_CLK_CAL_CYCLES=1024 CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=2000 -CONFIG_ESP32_XTAL_FREQ_40=y -# CONFIG_ESP32_XTAL_FREQ_26 is not set -# CONFIG_ESP32_XTAL_FREQ_AUTO is not set -CONFIG_ESP32_XTAL_FREQ=40 # CONFIG_ESP32_DISABLE_BASIC_ROM_CONSOLE is not set # CONFIG_ESP32_NO_BLOBS is not set # CONFIG_ESP32_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set @@ -329,18 +311,7 @@ CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y # Ethernet # CONFIG_ETH_ENABLED=y -CONFIG_ETH_USE_ESP32_EMAC=y -CONFIG_ETH_PHY_INTERFACE_RMII=y -# CONFIG_ETH_PHY_INTERFACE_MII is not set -CONFIG_ETH_RMII_CLK_INPUT=y -# CONFIG_ETH_RMII_CLK_OUTPUT is not set -CONFIG_ETH_RMII_CLK_IN_GPIO=0 -CONFIG_ETH_DMA_BUFFER_SIZE=512 -CONFIG_ETH_DMA_RX_BUFFER_NUM=10 -CONFIG_ETH_DMA_TX_BUFFER_NUM=10 -CONFIG_ETH_USE_SPI_ETHERNET=y -# CONFIG_ETH_SPI_ETHERNET_DM9051 is not set -# CONFIG_ETH_USE_OPENETH is not set +# CONFIG_ETH_USE_ESP32_EMAC is not set # end of Ethernet # @@ -396,6 +367,15 @@ CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER=y # end of ESP NETIF Adapter # +# PHY +# +CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y +# CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION is not set +CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=20 +CONFIG_ESP_PHY_MAX_TX_POWER=20 +# CONFIG_ESP_PHY_REDUCE_TX_POWER is not set + +# end of PHY # ESP System Settings # # CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set @@ -438,21 +418,14 @@ CONFIG_ESP32_WIFI_RX_IRAM_OPT=y CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y # end of Wi-Fi -# -# PHY -# -CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y -# CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set -CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 -CONFIG_ESP32_PHY_MAX_TX_POWER=20 -# end of PHY + # # Core dump # -# CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set -# CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set -CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y +# CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH is not set +# CONFIG_ESP_COREDUMP_ENABLE_TO_UART is not set +CONFIG_ESP_COREDUMP_ENABLE_TO_NONE=y # end of Core dump # @@ -492,24 +465,9 @@ CONFIG_FATFS_PER_FILE_CACHE=y # # Modbus configuration # -CONFIG_FMB_COMM_MODE_RTU_EN=y -CONFIG_FMB_COMM_MODE_ASCII_EN=y -CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND=150 -CONFIG_FMB_MASTER_DELAY_MS_CONVERT=200 -CONFIG_FMB_QUEUE_LENGTH=20 -CONFIG_FMB_SERIAL_TASK_STACK_SIZE=2048 -CONFIG_FMB_SERIAL_BUF_SIZE=256 -CONFIG_FMB_SERIAL_ASCII_BITS_PER_SYMB=8 -CONFIG_FMB_SERIAL_ASCII_TIMEOUT_RESPOND_MS=1000 -CONFIG_FMB_SERIAL_TASK_PRIO=10 -# CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT is not set -CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT=20 -CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE=20 -CONFIG_FMB_CONTROLLER_STACK_SIZE=4096 -CONFIG_FMB_EVENT_QUEUE_TIMEOUT=20 -CONFIG_FMB_TIMER_PORT_ENABLED=y -CONFIG_FMB_TIMER_GROUP=0 -CONFIG_FMB_TIMER_INDEX=0 +# CONFIG_FMB_COMM_MODE_TCP_EN is not set +# CONFIG_FMB_COMM_MODE_RTU_EN is not set +# CONFIG_FMB_COMM_MODE_ASCII_EN=y # CONFIG_FMB_TIMER_ISR_IN_IRAM is not set # end of Modbus configuration @@ -526,7 +484,7 @@ CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION=y # CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL is not set CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY=y # CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set -CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y +# CONFIG_FREERTOS_INTERRUPT_BACKTRACE is not set CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=1 CONFIG_FREERTOS_ASSERT_FAIL_ABORT=y # CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE is not set @@ -535,7 +493,6 @@ CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1536 CONFIG_FREERTOS_ISR_STACKSIZE=1536 # CONFIG_FREERTOS_LEGACY_HOOKS is not set CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16 -# CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION is not set CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1 CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048 CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10 @@ -544,8 +501,9 @@ CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0 # CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y # CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set -CONFIG_FREERTOS_DEBUG_OCDAWARE=y +# CONFIG_FREERTOS_DEBUG_OCDAWARE is not set # CONFIG_FREERTOS_FPU_IN_ISR is not set +# CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT is not set # end of FreeRTOS # @@ -613,7 +571,7 @@ CONFIG_LWIP_ESP_GRATUITOUS_ARP=y CONFIG_LWIP_GARP_TMR_INTERVAL=60 CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=50 CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y -# CONFIG_LWIP_DHCP_RESTORE_LAST_IP is not set +CONFIG_LWIP_DHCP_RESTORE_LAST_IP=y # # DHCP server @@ -624,8 +582,7 @@ CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8 # CONFIG_LWIP_AUTOIP is not set # CONFIG_LWIP_IPV6_AUTOCONFIG is not set -CONFIG_LWIP_NETIF_LOOPBACK=y -CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8 +# CONFIG_LWIP_NETIF_LOOPBACK is not set # # TCP @@ -939,6 +896,13 @@ CONFIG_USB_DESC_CUSTOM_PID=0x5678 # end of Descriptor configuration # end of TinyUSB +# +# Websocket +# +# CONFIG_WS_TRANSPORT is not set +# end of Websocket +# end of TCP Transport + # # Unity unit testing library #