mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
esp32c3: Apply one-liner/small changes for ESP32-C3
This commit is contained in:
parent
f80bcb733a
commit
5228d9f9ce
@ -156,9 +156,12 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "soc/soc.h"
|
||||
#include "soc/dport_access.h"
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "soc/dport_reg.h"
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "soc/sensitive_reg.h"
|
||||
#endif
|
||||
#if __XTENSA__
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include "esp32s2/clk.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/clk.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/clk.h"
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -2,7 +2,10 @@ idf_component_register(SRCS "bootloader_start.c"
|
||||
REQUIRES bootloader bootloader_support)
|
||||
|
||||
idf_build_get_property(target IDF_TARGET)
|
||||
set(scripts "ld/${target}/bootloader.ld"
|
||||
"ld/${target}/bootloader.rom.ld")
|
||||
set(scripts "ld/${target}/bootloader.ld")
|
||||
|
||||
if(NOT CONFIG_IDF_TARGET_ESP32C3)
|
||||
list(APPEND scripts "ld/${target}/bootloader.rom.ld")
|
||||
endif()
|
||||
|
||||
target_linker_script(${COMPONENT_LIB} INTERFACE "${scripts}")
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include "esp32s2/rom/rtc.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/rtc.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/rtc.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -23,6 +23,7 @@ typedef enum {
|
||||
ESP_CHIP_ID_ESP32 = 0x0000, /*!< chip ID: ESP32 */
|
||||
ESP_CHIP_ID_ESP32S2 = 0x0002, /*!< chip ID: ESP32-S2 */
|
||||
ESP_CHIP_ID_ESP32S3 = 0x0004, /*!< chip ID: ESP32-S3 */
|
||||
ESP_CHIP_ID_ESP32C3 = 0x0005, /*!< chip ID: ESP32-C3 */
|
||||
ESP_CHIP_ID_INVALID = 0xFFFF /*!< Invalid chip ID (we defined it to make sure the esp_chip_id_t is 2 bytes size) */
|
||||
} __attribute__((packed)) esp_chip_id_t;
|
||||
|
||||
|
@ -52,7 +52,7 @@ static inline /** @cond */ IRAM_ATTR /** @endcond */ bool esp_flash_encryption_e
|
||||
uint32_t flash_crypt_cnt = 0;
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
flash_crypt_cnt = REG_GET_FIELD(EFUSE_BLK0_RDATA0_REG, EFUSE_RD_FLASH_CRYPT_CNT);
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#else
|
||||
flash_crypt_cnt = REG_GET_FIELD(EFUSE_RD_REPEAT_DATA1_REG, EFUSE_SPI_BOOT_CRYPT_CNT);
|
||||
#endif
|
||||
/* __builtin_parity is in flash, so we calculate parity inline */
|
||||
|
@ -22,6 +22,10 @@
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/rom/efuse.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/efuse.h"
|
||||
#endif
|
||||
|
||||
typedef struct ets_secure_boot_signature ets_secure_boot_signature_t;
|
||||
|
@ -14,19 +14,22 @@
|
||||
#include "sdkconfig.h"
|
||||
#include "soc/soc.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "soc/efuse_periph.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
|
||||
#define CPU_RESET_REASON RTC_SW_CPU_RESET
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
#include "soc/dport_reg.h"
|
||||
#include "esp32/rom/rtc.h"
|
||||
#undef CPU_RESET_REASON
|
||||
#define CPU_RESET_REASON SW_CPU_RESET
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/rom/rtc.h"
|
||||
#define CPU_RESET_REASON RTC_SW_CPU_RESET
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#define CPU_RESET_REASON RTC_SW_CPU_RESET
|
||||
#include "esp32s3/rom/rtc.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/rtc.h"
|
||||
#endif
|
||||
#include "esp_rom_uart.h"
|
||||
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include "esp32s2/rom/spi_flash.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/spi_flash.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/spi_flash.h"
|
||||
#endif
|
||||
#include "esp_rom_crc.h"
|
||||
#include "esp_rom_gpio.h"
|
||||
|
@ -35,6 +35,8 @@
|
||||
#include "esp32s2/rom/spi_flash.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/spi_flash.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/spi_flash.h"
|
||||
#endif
|
||||
|
||||
|
||||
@ -89,8 +91,8 @@ esp_err_t bootloader_flash_write(size_t dest_addr, void *src, size_t size, bool
|
||||
if (write_encrypted) {
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
return spi_flash_write_encrypted(dest_addr, src, size);
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
return SPI_Encrypt_Write(dest_addr, src, size);
|
||||
#else
|
||||
return esp_rom_spiflash_write_encrypted(dest_addr, src, size);
|
||||
#endif
|
||||
} else {
|
||||
return spi_flash_write(dest_addr, src, size);
|
||||
@ -109,7 +111,6 @@ esp_err_t bootloader_flash_erase_range(uint32_t start_addr, uint32_t size)
|
||||
|
||||
#else
|
||||
/* Bootloader version, uses ROM functions only */
|
||||
#include "soc/dport_reg.h"
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32/rom/spi_flash.h"
|
||||
#include "esp32/rom/cache.h"
|
||||
@ -121,6 +122,10 @@ esp_err_t bootloader_flash_erase_range(uint32_t start_addr, uint32_t size)
|
||||
#include "esp32s3/rom/spi_flash.h"
|
||||
#include "esp32s3/rom/cache.h"
|
||||
#include "soc/cache_memory.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/spi_flash.h"
|
||||
#include "esp32c3/rom/cache.h"
|
||||
#include "soc/cache_memory.h"
|
||||
#endif
|
||||
static const char *TAG = "bootloader_flash";
|
||||
|
||||
@ -132,7 +137,9 @@ static const char *TAG = "bootloader_flash";
|
||||
#define MMU_SIZE (0x320000)
|
||||
#define MMU_BLOCK50_VADDR (MMU_BLOCK0_VADDR + MMU_SIZE)
|
||||
#define FLASH_READ_VADDR MMU_BLOCK50_VADDR
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
|
||||
#else // !CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
/* Use first 63 blocks in MMU for bootloader_mmap,
|
||||
63th block for bootloader_flash_read
|
||||
*/
|
||||
@ -180,6 +187,9 @@ const void *bootloader_mmap(uint32_t src_addr, uint32_t size)
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
uint32_t autoload = Cache_Suspend_DCache();
|
||||
Cache_Invalidate_DCache_All();
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
uint32_t autoload = Cache_Suspend_ICache();
|
||||
Cache_Invalidate_ICache_All();
|
||||
#endif
|
||||
ESP_LOGD(TAG, "mmu set paddr=%08x count=%d size=%x src_addr=%x src_addr_aligned=%x",
|
||||
src_addr & MMU_FLASH_MASK, count, size, src_addr, src_addr_aligned );
|
||||
@ -187,7 +197,7 @@ const void *bootloader_mmap(uint32_t src_addr, uint32_t size)
|
||||
int e = cache_flash_mmu_set(0, 0, MMU_BLOCK0_VADDR, src_addr_aligned, 64, count);
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
int e = Cache_Ibus_MMU_Set(MMU_ACCESS_FLASH, MMU_BLOCK0_VADDR, src_addr_aligned, 64, count, 0);
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#else // S3, C3
|
||||
int e = Cache_Dbus_MMU_Set(MMU_ACCESS_FLASH, MMU_BLOCK0_VADDR, src_addr_aligned, 64, count, 0);
|
||||
#endif
|
||||
if (e != 0) {
|
||||
@ -198,6 +208,8 @@ const void *bootloader_mmap(uint32_t src_addr, uint32_t size)
|
||||
Cache_Resume_ICache(autoload);
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
Cache_Resume_DCache(autoload);
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
Cache_Resume_ICache(autoload);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
@ -207,6 +219,8 @@ const void *bootloader_mmap(uint32_t src_addr, uint32_t size)
|
||||
Cache_Resume_ICache(autoload);
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
Cache_Resume_DCache(autoload);
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
Cache_Resume_ICache(autoload);
|
||||
#endif
|
||||
|
||||
mapped = true;
|
||||
@ -228,10 +242,14 @@ void bootloader_munmap(const void *mapping)
|
||||
Cache_Invalidate_ICache_All();
|
||||
Cache_MMU_Init();
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
//TODO, save the autoload value.
|
||||
Cache_Suspend_DCache();
|
||||
Cache_Invalidate_DCache_All();
|
||||
Cache_MMU_Init();
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
//TODO, save the autoload value.
|
||||
Cache_Suspend_ICache();
|
||||
Cache_Invalidate_ICache_All();
|
||||
Cache_MMU_Init();
|
||||
#endif
|
||||
mapped = false;
|
||||
current_read_mapping = UINT32_MAX;
|
||||
@ -261,6 +279,8 @@ static esp_err_t bootloader_flash_read_no_decrypt(size_t src_addr, void *dest, s
|
||||
uint32_t autoload = Cache_Suspend_ICache();
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
uint32_t autoload = Cache_Suspend_DCache();
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
uint32_t autoload = Cache_Suspend_ICache();
|
||||
#endif
|
||||
esp_rom_spiflash_result_t r = esp_rom_spiflash_read(src_addr, dest, size);
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
@ -269,6 +289,8 @@ static esp_err_t bootloader_flash_read_no_decrypt(size_t src_addr, void *dest, s
|
||||
Cache_Resume_ICache(autoload);
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
Cache_Resume_DCache(autoload);
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
Cache_Resume_ICache(autoload);
|
||||
#endif
|
||||
|
||||
return spi_to_esp_err(r);
|
||||
@ -293,6 +315,9 @@ static esp_err_t bootloader_flash_read_allow_decrypt(size_t src_addr, void *dest
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
uint32_t autoload = Cache_Suspend_DCache();
|
||||
Cache_Invalidate_DCache_All();
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
uint32_t autoload = Cache_Suspend_ICache();
|
||||
Cache_Invalidate_ICache_All();
|
||||
#endif
|
||||
ESP_LOGD(TAG, "mmu set block paddr=0x%08x (was 0x%08x)", map_at, current_read_mapping);
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
@ -301,6 +326,8 @@ static esp_err_t bootloader_flash_read_allow_decrypt(size_t src_addr, void *dest
|
||||
int e = Cache_Ibus_MMU_Set(MMU_ACCESS_FLASH, MMU_BLOCK63_VADDR, map_at, 64, 1, 0);
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
int e = Cache_Dbus_MMU_Set(MMU_ACCESS_FLASH, MMU_BLOCK63_VADDR, map_at, 64, 1, 0);
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
int e = Cache_Dbus_MMU_Set(MMU_ACCESS_FLASH, MMU_BLOCK63_VADDR, map_at, 64, 1, 0);
|
||||
#endif
|
||||
if (e != 0) {
|
||||
ESP_LOGE(TAG, "cache_flash_mmu_set failed: %d\n", e);
|
||||
@ -310,6 +337,8 @@ static esp_err_t bootloader_flash_read_allow_decrypt(size_t src_addr, void *dest
|
||||
Cache_Resume_ICache(autoload);
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
Cache_Resume_DCache(autoload);
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
Cache_Resume_ICache(autoload);
|
||||
#endif
|
||||
return ESP_FAIL;
|
||||
}
|
||||
@ -320,6 +349,8 @@ static esp_err_t bootloader_flash_read_allow_decrypt(size_t src_addr, void *dest
|
||||
Cache_Resume_ICache(autoload);
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
Cache_Resume_DCache(autoload);
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
Cache_Resume_ICache(autoload);
|
||||
#endif
|
||||
}
|
||||
map_ptr = (uint32_t *)(FLASH_READ_VADDR + (word_src - map_at));
|
||||
@ -422,7 +453,7 @@ uint32_t bootloader_execute_flash_command(uint8_t command, uint32_t mosi_data, u
|
||||
uint32_t old_ctrl_reg = SPIFLASH.ctrl.val;
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
SPIFLASH.ctrl.val = SPI_WP_REG_M; // keep WP high while idle, otherwise leave DIO mode
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#else
|
||||
SPIFLASH.ctrl.val = SPI_MEM_WP_REG_M; // keep WP high while idle, otherwise leave DIO mode
|
||||
#endif
|
||||
SPIFLASH.user.usr_dummy = 0;
|
||||
@ -434,13 +465,13 @@ uint32_t bootloader_execute_flash_command(uint8_t command, uint32_t mosi_data, u
|
||||
SPIFLASH.user.usr_miso = miso_len > 0;
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
SPIFLASH.miso_dlen.usr_miso_dbitlen = miso_len ? (miso_len - 1) : 0;
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#else
|
||||
SPIFLASH.miso_dlen.usr_miso_bit_len = miso_len ? (miso_len - 1) : 0;
|
||||
#endif
|
||||
SPIFLASH.user.usr_mosi = mosi_len > 0;
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
SPIFLASH.mosi_dlen.usr_mosi_dbitlen = mosi_len ? (mosi_len - 1) : 0;
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#else
|
||||
SPIFLASH.mosi_dlen.usr_mosi_bit_len = mosi_len ? (mosi_len - 1) : 0;
|
||||
#endif
|
||||
SPIFLASH.data_buf[0] = mosi_data;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "esp_rom_sys.h"
|
||||
#include "esp_rom_uart.h"
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "soc/dport_reg.h"
|
||||
#include "esp32/rom/cache.h"
|
||||
#include "esp32/rom/spi_flash.h"
|
||||
#include "esp32/rom/rtc.h"
|
||||
@ -40,14 +41,25 @@
|
||||
#include "esp32s3/rom/secure_boot.h"
|
||||
#include "soc/extmem_reg.h"
|
||||
#include "soc/cache_memory.h"
|
||||
#else
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/cache.h"
|
||||
#include "esp32c3/rom/efuse.h"
|
||||
#include "esp32c3/rom/ets_sys.h"
|
||||
#include "esp32c3/rom/spi_flash.h"
|
||||
#include "esp32c3/rom/crc.h"
|
||||
#include "esp32c3/rom/rtc.h"
|
||||
#include "esp32c3/rom/uart.h"
|
||||
#include "esp32c3/rom/gpio.h"
|
||||
#include "esp32c3/rom/secure_boot.h"
|
||||
#include "soc/extmem_reg.h"
|
||||
#include "soc/cache_memory.h"
|
||||
#else // CONFIG_IDF_TARGET_*
|
||||
#error "Unsupported IDF_TARGET"
|
||||
#endif
|
||||
|
||||
#include "soc/soc.h"
|
||||
#include "soc/cpu.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "soc/gpio_periph.h"
|
||||
#include "soc/efuse_periph.h"
|
||||
#include "soc/rtc_periph.h"
|
||||
@ -693,6 +705,9 @@ static void set_cache_and_start_app(
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
uint32_t autoload = Cache_Suspend_DCache();
|
||||
Cache_Invalidate_DCache_All();
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
uint32_t autoload = Cache_Suspend_ICache();
|
||||
Cache_Invalidate_ICache_All();
|
||||
#endif
|
||||
|
||||
/* Clear the MMU entries that are already set up,
|
||||
@ -702,7 +717,7 @@ static void set_cache_and_start_app(
|
||||
for (int i = 0; i < DPORT_FLASH_MMU_TABLE_SIZE; i++) {
|
||||
DPORT_PRO_FLASH_MMU_TABLE[i] = DPORT_FLASH_MMU_TABLE_INVALID_VAL;
|
||||
}
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||
#else
|
||||
for (int i = 0; i < FLASH_MMU_TABLE_SIZE; i++) {
|
||||
FLASH_MMU_TABLE[i] = MMU_TABLE_INVALID_VAL;
|
||||
}
|
||||
@ -717,6 +732,8 @@ static void set_cache_and_start_app(
|
||||
rc = Cache_Ibus_MMU_Set(MMU_ACCESS_FLASH, drom_load_addr & 0xffff0000, drom_addr & 0xffff0000, 64, drom_page_count, 0);
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
rc = Cache_Dbus_MMU_Set(MMU_ACCESS_FLASH, drom_load_addr & 0xffff0000, drom_addr & 0xffff0000, 64, drom_page_count, 0);
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
rc = Cache_Dbus_MMU_Set(MMU_ACCESS_FLASH, drom_load_addr & 0xffff0000, drom_addr & 0xffff0000, 64, drom_page_count, 0);
|
||||
#endif
|
||||
ESP_LOGV(TAG, "rc=%d", rc);
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
@ -742,6 +759,8 @@ static void set_cache_and_start_app(
|
||||
rc = Cache_Ibus_MMU_Set(MMU_ACCESS_FLASH, irom_load_addr & 0xffff0000, irom_addr & 0xffff0000, 64, irom_page_count, 0);
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
rc = Cache_Ibus_MMU_Set(MMU_ACCESS_FLASH, irom_load_addr & 0xffff0000, irom_addr & 0xffff0000, 64, irom_page_count, 0);
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
rc = Cache_Ibus_MMU_Set(MMU_ACCESS_FLASH, irom_load_addr & 0xffff0000, irom_addr & 0xffff0000, 64, irom_page_count, 0);
|
||||
#endif
|
||||
ESP_LOGV(TAG, "rc=%d", rc);
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
@ -762,6 +781,9 @@ static void set_cache_and_start_app(
|
||||
#if !CONFIG_FREERTOS_UNICORE
|
||||
REG_CLR_BIT(EXTMEM_DCACHE_CTRL1_REG, EXTMEM_DCACHE_SHUT_CORE1_BUS);
|
||||
#endif
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
REG_CLR_BIT(EXTMEM_ICACHE_CTRL1_REG, EXTMEM_ICACHE_SHUT_IBUS);
|
||||
REG_CLR_BIT(EXTMEM_ICACHE_CTRL1_REG, EXTMEM_ICACHE_SHUT_DBUS);
|
||||
#endif
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
Cache_Read_Enable(0);
|
||||
@ -769,6 +791,8 @@ static void set_cache_and_start_app(
|
||||
Cache_Resume_ICache(autoload);
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
Cache_Resume_DCache(autoload);
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
Cache_Resume_ICache(autoload);
|
||||
#endif
|
||||
// Application will need to do Cache_Flush(1) and Cache_Read_Enable(1)
|
||||
|
||||
|
@ -35,6 +35,9 @@
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/rtc.h"
|
||||
#include "esp32s3/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/rtc.h"
|
||||
#include "esp32c3/rom/secure_boot.h"
|
||||
#endif
|
||||
|
||||
/* Checking signatures as part of verifying images is necessary:
|
||||
|
@ -29,6 +29,9 @@
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#define CRYPT_CNT ESP_EFUSE_SPI_BOOT_CRYPT_CNT
|
||||
#define WR_DIS_CRYPT_CNT ESP_EFUSE_WR_DIS_SPI_BOOT_CRYPT_CNT
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#define CRYPT_CNT ESP_EFUSE_WR_DIS_SPI_BOOT_CRYPT_CNT
|
||||
#define WR_DIS_CRYPT_CNT ESP_EFUSE_WR_DIS_SPI_BOOT_CRYPT_CNT
|
||||
#endif
|
||||
|
||||
#ifndef BOOTLOADER_BUILD
|
||||
|
@ -14,8 +14,14 @@
|
||||
#include <string.h>
|
||||
#include "esp_flash_partitions.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp32/rom/spi_flash.h"
|
||||
#include "esp_rom_md5.h"
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/spi_flash.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/rom/spi_flash.h"
|
||||
#else
|
||||
#include "esp32/rom/spi_flash.h"
|
||||
#endif
|
||||
|
||||
static const char *TAG = "flash_parts";
|
||||
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include "esp32s2/rom/spi_flash.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/spi_flash.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/spi_flash.h"
|
||||
#endif
|
||||
#include "soc/efuse_periph.h"
|
||||
#include "soc/io_mux_reg.h"
|
||||
@ -195,7 +197,7 @@ static esp_err_t enable_qio_mode(read_status_fn_t read_status_fn,
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
int wp_pin = bootloader_flash_get_wp_pin();
|
||||
esp_rom_spiflash_select_qio_pins(wp_pin, spiconfig);
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#else
|
||||
esp_rom_spiflash_select_qio_pins(esp_rom_efuse_get_flash_wp_gpio(), spiconfig);
|
||||
#endif
|
||||
return ESP_OK;
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/timers.h"
|
||||
#include "esp_log.h"
|
||||
@ -31,6 +30,8 @@
|
||||
|
||||
#include "hal/adc_types.h"
|
||||
#include "hal/adc_hal.h"
|
||||
|
||||
#if !CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "hal/dac_hal.h"
|
||||
#include "hal/adc_hal_conf.h"
|
||||
|
||||
@ -83,14 +84,14 @@ static _lock_t adc2_wifi_lock;
|
||||
#define ADC2_WIFI_LOCK_TRY_ACQUIRE() _lock_try_acquire( &adc2_wifi_lock )
|
||||
#define ADC2_WIFI_LOCK_CHECK() ((uint32_t *)adc2_wifi_lock != NULL)
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||
#else // !CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
#define ADC2_WIFI_LOCK_ACQUIRE()
|
||||
#define ADC2_WIFI_LOCK_RELEASE()
|
||||
#define ADC2_WIFI_LOCK_TRY_ACQUIRE() (0) //WIFI controller and rtc controller have independent parameter configuration.
|
||||
#define ADC2_WIFI_LOCK_CHECK() (true)
|
||||
|
||||
#endif
|
||||
#endif // CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
//prevent ADC2 being used by tasks (regardless of WIFI)
|
||||
static portMUX_TYPE adc2_spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
@ -102,11 +103,11 @@ static _lock_t adc1_dma_lock;
|
||||
#define ADC1_DMA_LOCK_ACQUIRE() _lock_acquire( &adc1_dma_lock )
|
||||
#define ADC1_DMA_LOCK_RELEASE() _lock_release( &adc1_dma_lock )
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#if !CONFIG_IDF_TARGET_ESP32
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
static esp_pm_lock_handle_t s_adc2_arbiter_lock;
|
||||
#endif //CONFIG_PM_ENABLE
|
||||
#endif //CONFIG_IDF_TARGET_ESP32S2
|
||||
#endif // !CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
ADC Common
|
||||
@ -176,19 +177,15 @@ esp_err_t adc_gpio_init(adc_unit_t adc_unit, adc_channel_t channel)
|
||||
if (adc_unit & ADC_UNIT_1) {
|
||||
ADC_CHANNEL_CHECK(ADC_NUM_1, channel);
|
||||
gpio_num = ADC_GET_IO_NUM(ADC_NUM_1, channel);
|
||||
ADC_CHECK_RET(rtc_gpio_init(gpio_num));
|
||||
ADC_CHECK_RET(rtc_gpio_set_direction(gpio_num, RTC_GPIO_MODE_DISABLED));
|
||||
ADC_CHECK_RET(rtc_gpio_pulldown_dis(gpio_num));
|
||||
ADC_CHECK_RET(rtc_gpio_pullup_dis(gpio_num));
|
||||
}
|
||||
if (adc_unit & ADC_UNIT_2) {
|
||||
ADC_CHANNEL_CHECK(ADC_NUM_2, channel);
|
||||
gpio_num = ADC_GET_IO_NUM(ADC_NUM_2, channel);
|
||||
}
|
||||
ADC_CHECK_RET(rtc_gpio_init(gpio_num));
|
||||
ADC_CHECK_RET(rtc_gpio_set_direction(gpio_num, RTC_GPIO_MODE_DISABLED));
|
||||
ADC_CHECK_RET(rtc_gpio_pulldown_dis(gpio_num));
|
||||
ADC_CHECK_RET(rtc_gpio_pullup_dis(gpio_num));
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@ -210,8 +207,8 @@ esp_err_t adc_set_data_width(adc_unit_t adc_unit, adc_bits_width_t bits)
|
||||
{
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
ADC_CHECK(bits < ADC_WIDTH_MAX, "WIDTH ERR: ESP32 support 9 ~ 12 bit width", ESP_ERR_INVALID_ARG);
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||
ADC_CHECK(bits == ADC_WIDTH_BIT_13, "WIDTH ERR: ESP32S2 support 13 bit width", ESP_ERR_INVALID_ARG);
|
||||
#else
|
||||
ADC_CHECK(bits == ADC_WIDTH_BIT_13, "WIDTH ERR: " CONFIG_IDF_TARGET " support 13 bit width", ESP_ERR_INVALID_ARG);
|
||||
#endif
|
||||
|
||||
ADC_ENTER_CRITICAL();
|
||||
@ -232,7 +229,7 @@ esp_err_t adc_set_data_width(adc_unit_t adc_unit, adc_bits_width_t bits)
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
*/
|
||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#if !CONFIG_IDF_TARGET_ESP32
|
||||
esp_err_t adc_rtc_reset(void)
|
||||
{
|
||||
ADC_ENTER_CRITICAL();
|
||||
@ -284,8 +281,8 @@ esp_err_t adc1_config_width(adc_bits_width_t width_bit)
|
||||
{
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
ADC_CHECK(width_bit < ADC_WIDTH_MAX, "WIDTH ERR: ESP32 support 9 ~ 12 bit width", ESP_ERR_INVALID_ARG);
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||
ADC_CHECK(width_bit == ADC_WIDTH_BIT_13, "WIDTH ERR: ESP32S2 support 13 bit width", ESP_ERR_INVALID_ARG);
|
||||
#elif !defined(CONFIG_IDF_TARGET_ESP32)
|
||||
ADC_CHECK(width_bit == ADC_WIDTH_BIT_13, "WIDTH ERR: " CONFIG_IDF_TARGET " support 13 bit width", ESP_ERR_INVALID_ARG);
|
||||
#endif
|
||||
|
||||
ADC_ENTER_CRITICAL();
|
||||
@ -345,13 +342,13 @@ int adc1_get_raw(adc1_channel_t channel)
|
||||
adc_hal_hall_disable(); //Disable other peripherals.
|
||||
adc_hal_amp_disable(); //Currently the LNA is not open, close it by default.
|
||||
#endif
|
||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#if !CONFIG_IDF_TARGET_ESP32
|
||||
adc_set_init_code(ADC_NUM_1, channel); // calibration for adc
|
||||
#endif
|
||||
adc_hal_set_controller(ADC_NUM_1, ADC_CTRL_RTC); //Set controller
|
||||
adc_hal_convert(ADC_NUM_1, channel, &adc_value); //Start conversion, For ADC1, the data always valid.
|
||||
ADC_EXIT_CRITICAL();
|
||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#if !CONFIG_IDF_TARGET_ESP32
|
||||
adc_hal_rtc_reset(); //Reset FSM of rtc controller
|
||||
#endif
|
||||
|
||||
@ -364,6 +361,7 @@ int adc1_get_voltage(adc1_channel_t channel) //Deprecated. Use adc1_get_raw()
|
||||
return adc1_get_raw(channel);
|
||||
}
|
||||
|
||||
#if SOC_ULP_SUPPORTED
|
||||
void adc1_ulp_enable(void)
|
||||
{
|
||||
adc_power_on();
|
||||
@ -379,6 +377,7 @@ void adc1_ulp_enable(void)
|
||||
#endif
|
||||
ADC_EXIT_CRITICAL();
|
||||
}
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
ADC2
|
||||
@ -438,7 +437,7 @@ esp_err_t adc2_config_channel_atten(adc2_channel_t channel, adc_atten_t atten)
|
||||
|
||||
static inline void adc2_config_width(adc_bits_width_t width_bit)
|
||||
{
|
||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#if !CONFIG_IDF_TARGET_ESP32
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
/* Lock APB clock. */
|
||||
if (s_adc2_arbiter_lock == NULL) {
|
||||
@ -459,7 +458,7 @@ static inline void adc2_dac_disable( adc2_channel_t channel)
|
||||
} else if ( channel == ADC2_CHANNEL_9 ) {
|
||||
dac_output_disable(DAC_CHANNEL_2);
|
||||
}
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||
#else
|
||||
if ( channel == ADC2_CHANNEL_6 ) { // the same as DAC channel 1
|
||||
dac_output_disable(DAC_CHANNEL_1);
|
||||
} else if ( channel == ADC2_CHANNEL_7 ) {
|
||||
@ -482,7 +481,7 @@ esp_err_t adc2_get_raw(adc2_channel_t channel, adc_bits_width_t width_bit, int *
|
||||
ADC_CHECK(channel < ADC2_CHANNEL_MAX, "ADC Channel Err", ESP_ERR_INVALID_ARG);
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
ADC_CHECK(width_bit < ADC_WIDTH_MAX, "WIDTH ERR: ESP32 support 9 ~ 12 bit width", ESP_ERR_INVALID_ARG);
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||
#else
|
||||
ADC_CHECK(width_bit == ADC_WIDTH_BIT_13, "WIDTH ERR: ESP32S2 support 13 bit width", ESP_ERR_INVALID_ARG);
|
||||
#endif
|
||||
|
||||
@ -498,12 +497,12 @@ esp_err_t adc2_get_raw(adc2_channel_t channel, adc_bits_width_t width_bit, int *
|
||||
adc2_dac_disable(channel); //disable other peripherals
|
||||
#endif
|
||||
adc2_config_width(width_bit); // in critical section with whole rtc module. because the PWDET use the same registers, place it here.
|
||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3
|
||||
adc_set_init_code(ADC_NUM_2, channel); // calibration for adc
|
||||
#endif
|
||||
adc_hal_set_controller(ADC_NUM_2, ADC_CTRL_RTC);// set controller
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#if !CONFIG_IDF_TARGET_ESP32
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (s_adc2_arbiter_lock) {
|
||||
esp_pm_lock_acquire(s_adc2_arbiter_lock);
|
||||
@ -527,7 +526,7 @@ esp_err_t adc2_get_raw(adc2_channel_t channel, adc_bits_width_t width_bit, int *
|
||||
ADC2_WIFI_LOCK_RELEASE();
|
||||
ADC2_EXIT_CRITICAL();
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#if !CONFIG_IDF_TARGET_ESP32
|
||||
adc_rtc_reset();
|
||||
#endif
|
||||
|
||||
@ -572,3 +571,5 @@ esp_err_t adc_vref_to_gpio(adc_unit_t adc_unit, gpio_num_t gpio)
|
||||
adc_gpio_init(ADC_UNIT_2, ch);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#endif // !CONFIG_IDF_TARGET_ESP32C3
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include <esp_types.h>
|
||||
#include "esp_err.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/rtc_io.h"
|
||||
#include "soc/soc.h"
|
||||
@ -87,7 +86,11 @@ esp_err_t gpio_pullup_en(gpio_num_t gpio_num)
|
||||
gpio_hal_pullup_en(gpio_context.gpio_hal, gpio_num);
|
||||
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
} else {
|
||||
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
rtc_gpio_pullup_en(gpio_num);
|
||||
#else
|
||||
abort(); // This should be eliminated as unreachable, unless a programming error has occured
|
||||
#endif
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
@ -102,7 +105,11 @@ esp_err_t gpio_pullup_dis(gpio_num_t gpio_num)
|
||||
gpio_hal_pullup_dis(gpio_context.gpio_hal, gpio_num);
|
||||
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
} else {
|
||||
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
rtc_gpio_pullup_dis(gpio_num);
|
||||
#else
|
||||
abort(); // This should be eliminated as unreachable, unless a programming error has occured
|
||||
#endif
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
@ -117,7 +124,11 @@ esp_err_t gpio_pulldown_en(gpio_num_t gpio_num)
|
||||
gpio_hal_pulldown_en(gpio_context.gpio_hal, gpio_num);
|
||||
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
} else {
|
||||
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
rtc_gpio_pulldown_en(gpio_num);
|
||||
#else
|
||||
abort(); // This should be eliminated as unreachable, unless a programming error has occured
|
||||
#endif
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
@ -132,7 +143,11 @@ esp_err_t gpio_pulldown_dis(gpio_num_t gpio_num)
|
||||
gpio_hal_pulldown_dis(gpio_context.gpio_hal, gpio_num);
|
||||
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
} else {
|
||||
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
rtc_gpio_pulldown_dis(gpio_num);
|
||||
#else
|
||||
abort(); // This should be eliminated as unreachable, unless a programming error has occured
|
||||
#endif
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
@ -326,9 +341,11 @@ esp_err_t gpio_config(const gpio_config_t *pGPIOConfig)
|
||||
if (((gpio_pin_mask >> io_num) & BIT(0))) {
|
||||
assert(io_reg != (intptr_t)NULL);
|
||||
|
||||
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
if (rtc_gpio_is_valid_gpio(io_num)) {
|
||||
rtc_gpio_deinit(io_num);
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((pGPIOConfig->mode) & GPIO_MODE_DEF_INPUT) {
|
||||
input_en = 1;
|
||||
@ -576,7 +593,11 @@ esp_err_t gpio_set_drive_capability(gpio_num_t gpio_num, gpio_drive_cap_t streng
|
||||
gpio_hal_set_drive_capability(gpio_context.gpio_hal, gpio_num, strength);
|
||||
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
} else {
|
||||
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
ret = rtc_gpio_set_drive_capability(gpio_num, strength);
|
||||
#else
|
||||
abort(); // This should be eliminated as unreachable, unless a programming error has occured
|
||||
#endif
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -593,7 +614,11 @@ esp_err_t gpio_get_drive_capability(gpio_num_t gpio_num, gpio_drive_cap_t *stren
|
||||
gpio_hal_get_drive_capability(gpio_context.gpio_hal, gpio_num, strength);
|
||||
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
|
||||
} else {
|
||||
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
ret = rtc_gpio_get_drive_capability(gpio_num, strength);
|
||||
#else
|
||||
abort(); // This should be eliminated as unreachable, unless a programming error has occured
|
||||
#endif
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -20,10 +20,8 @@
|
||||
#include "malloc.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/ringbuf.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "esp_pm.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
#include "hal/i2c_hal.h"
|
||||
@ -176,7 +174,9 @@ typedef struct
|
||||
|
||||
static i2c_context_t i2c_context[I2C_NUM_MAX] = {
|
||||
I2C_CONTEX_INIT_DEF(I2C_NUM_0),
|
||||
#if I2C_NUM_MAX > 1
|
||||
I2C_CONTEX_INIT_DEF(I2C_NUM_1),
|
||||
#endif
|
||||
};
|
||||
|
||||
// i2c clock characteristic, The order is the same as i2c_sclk_t.
|
||||
|
@ -19,19 +19,19 @@
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
#include "soc/lldesc.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/i2s.h"
|
||||
|
||||
#if SOC_I2S_SUPPORTS_ADC_DAC
|
||||
#include "driver/dac.h"
|
||||
#include "hal/i2s_hal.h"
|
||||
#include "adc1_private.h"
|
||||
#endif
|
||||
|
||||
#include "soc/rtc.h"
|
||||
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_attr.h"
|
||||
@ -40,6 +40,8 @@
|
||||
#include "esp_efuse.h"
|
||||
#include "esp_rom_gpio.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
static const char* I2S_TAG = "I2S";
|
||||
|
||||
#define I2S_CHECK(a, str, ret) if (!(a)) { \
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include "esp32/rom/gpio.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/rom/gpio.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/gpio.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LEGACY_INCLUDE_COMMON_HEADERS
|
||||
|
@ -24,7 +24,6 @@ extern "C" {
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/ringbuf.h"
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/rtc_io_periph.h"
|
||||
#include "hal/rtc_io_types.h"
|
||||
#ifdef __cplusplus
|
||||
@ -32,8 +33,11 @@ extern "C" {
|
||||
*/
|
||||
static inline bool rtc_gpio_is_valid_gpio(gpio_num_t gpio_num)
|
||||
{
|
||||
return (gpio_num < GPIO_PIN_COUNT
|
||||
&& rtc_io_num_map[gpio_num] >= 0);
|
||||
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
return (gpio_num < GPIO_PIN_COUNT && rtc_io_num_map[gpio_num] >= 0);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#define RTC_GPIO_IS_VALID_GPIO(gpio_num) rtc_gpio_is_valid_gpio(gpio_num) // Deprecated, use rtc_gpio_is_valid_gpio()
|
||||
@ -48,9 +52,15 @@ static inline bool rtc_gpio_is_valid_gpio(gpio_num_t gpio_num)
|
||||
*/
|
||||
static inline int rtc_io_number_get(gpio_num_t gpio_num)
|
||||
{
|
||||
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
return rtc_io_num_map[gpio_num];
|
||||
#else
|
||||
return gpio_num;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
|
||||
/**
|
||||
* @brief Init a GPIO as RTC GPIO
|
||||
*
|
||||
@ -186,6 +196,34 @@ esp_err_t rtc_gpio_pullup_dis(gpio_num_t gpio_num);
|
||||
*/
|
||||
esp_err_t rtc_gpio_pulldown_dis(gpio_num_t gpio_num);
|
||||
|
||||
/**
|
||||
* @brief Set RTC GPIO pad drive capability
|
||||
*
|
||||
* @param gpio_num GPIO number, only support output GPIOs
|
||||
* @param strength Drive capability of the pad
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t rtc_gpio_set_drive_capability(gpio_num_t gpio_num, gpio_drive_cap_t strength);
|
||||
|
||||
/**
|
||||
* @brief Get RTC GPIO pad drive capability
|
||||
*
|
||||
* @param gpio_num GPIO number, only support output GPIOs
|
||||
* @param strength Pointer to accept drive capability of the pad
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t rtc_gpio_get_drive_capability(gpio_num_t gpio_num, gpio_drive_cap_t* strength);
|
||||
|
||||
#endif // SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
|
||||
#if SOC_RTCIO_HOLD_SUPPORTED
|
||||
|
||||
/**
|
||||
* @brief Enable hold function on an RTC IO pad
|
||||
*
|
||||
@ -249,29 +287,9 @@ esp_err_t rtc_gpio_force_hold_all(void);
|
||||
*/
|
||||
esp_err_t rtc_gpio_force_hold_dis_all(void);
|
||||
|
||||
/**
|
||||
* @brief Set RTC GPIO pad drive capability
|
||||
*
|
||||
* @param gpio_num GPIO number, only support output GPIOs
|
||||
* @param strength Drive capability of the pad
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t rtc_gpio_set_drive_capability(gpio_num_t gpio_num, gpio_drive_cap_t strength);
|
||||
#endif // SOC_RTCIO_HOLD_SUPPORTED
|
||||
|
||||
/**
|
||||
* @brief Get RTC GPIO pad drive capability
|
||||
*
|
||||
* @param gpio_num GPIO number, only support output GPIOs
|
||||
* @param strength Pointer to accept drive capability of the pad
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t rtc_gpio_get_drive_capability(gpio_num_t gpio_num, gpio_drive_cap_t* strength);
|
||||
#if SOC_RTCIO_WAKE_SUPPORTED
|
||||
|
||||
/**
|
||||
* @brief Enable wakeup from sleep mode using specific GPIO
|
||||
@ -294,6 +312,8 @@ esp_err_t rtc_gpio_wakeup_enable(gpio_num_t gpio_num, gpio_int_type_t intr_type)
|
||||
*/
|
||||
esp_err_t rtc_gpio_wakeup_disable(gpio_num_t gpio_num);
|
||||
|
||||
#endif // SOC_RTCIO_WAKE_SUPPORTED
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -23,7 +23,6 @@ extern "C" {
|
||||
#include "soc/soc_caps.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/ringbuf.h"
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include <esp_types.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "esp_log.h"
|
||||
#include "soc/gpio_periph.h"
|
||||
#include "soc/ledc_periph.h"
|
||||
|
@ -11,7 +11,6 @@
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "esp_log.h"
|
||||
|
@ -34,6 +34,8 @@ extern portMUX_TYPE rtc_spinlock; //TODO: Will be placed in the appropriate posi
|
||||
#define RTCIO_ENTER_CRITICAL() portENTER_CRITICAL(&rtc_spinlock)
|
||||
#define RTCIO_EXIT_CRITICAL() portEXIT_CRITICAL(&rtc_spinlock)
|
||||
|
||||
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
RTC IO
|
||||
---------------------------------------------------------------*/
|
||||
@ -156,6 +158,8 @@ esp_err_t rtc_gpio_pulldown_dis(gpio_num_t gpio_num)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#endif // SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
|
||||
esp_err_t rtc_gpio_hold_en(gpio_num_t gpio_num)
|
||||
{
|
||||
RTCIO_CHECK(rtc_gpio_is_valid_gpio(gpio_num), "RTCIO number error", ESP_ERR_INVALID_ARG);
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/periph_defs.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/timers.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "esp_err.h"
|
||||
#include "soc/soc.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "soc/lldesc.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/periph_ctrl.h"
|
||||
@ -33,9 +32,14 @@
|
||||
#include "hal/spi_hal.h"
|
||||
#include "esp_rom_gpio.h"
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "soc/dport_reg.h"
|
||||
#endif
|
||||
|
||||
//This GDMA related part will be introduced by GDMA dedicated APIs in the future. Here we temporarily use macros.
|
||||
#if SOC_GDMA_SUPPORTED
|
||||
#include "hal/gdma_ll.h"
|
||||
#include "soc/spi_caps.h"
|
||||
|
||||
#define spi_dma_set_rx_channel_priority(gdma_chan, priority) gdma_ll_rx_set_priority(&GDMA, gdma_chan, priority);
|
||||
#define spi_dma_set_tx_channel_priority(gdma_chan, priority) gdma_ll_tx_set_priority(&GDMA, gdma_chan, priority);
|
||||
@ -134,7 +138,7 @@ int spicommon_irqdma_source_for_host(spi_host_device_t host)
|
||||
return spi_periph_signal[host].irq_dma;
|
||||
}
|
||||
|
||||
static inline uint32_t get_dma_periph(int dma_chan)
|
||||
static inline periph_module_t get_dma_periph(int dma_chan)
|
||||
{
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
if (dma_chan == 1) {
|
||||
@ -223,9 +227,11 @@ void spicommon_connect_spi_and_dma(spi_host_device_t host, int dma_chan)
|
||||
if (dma_chan == 1) {
|
||||
gdma_chan = SOC_GDMA_SPI2_DMA_CHANNEL;
|
||||
periph_id = GDMA_LL_TRIG_SRC_SPI2;
|
||||
#ifdef GDMA_LL_TRIG_SRC_SPI3
|
||||
} else if (dma_chan == 2) {
|
||||
gdma_chan = SOC_GDMA_SPI3_DMA_CHANNEL;
|
||||
periph_id = GDMA_LL_TRIG_SRC_SPI3;
|
||||
#endif
|
||||
} else {
|
||||
abort();
|
||||
}
|
||||
@ -240,15 +246,25 @@ void spicommon_connect_spi_and_dma(spi_host_device_t host, int dma_chan)
|
||||
static bool bus_uses_iomux_pins(spi_host_device_t host, const spi_bus_config_t* bus_config)
|
||||
{
|
||||
if (bus_config->sclk_io_num>=0 &&
|
||||
bus_config->sclk_io_num != spi_periph_signal[host].spiclk_iomux_pin) return false;
|
||||
bus_config->sclk_io_num != spi_periph_signal[host].spiclk_iomux_pin) {
|
||||
return false;
|
||||
}
|
||||
if (bus_config->quadwp_io_num>=0 &&
|
||||
bus_config->quadwp_io_num != spi_periph_signal[host].spiwp_iomux_pin) return false;
|
||||
bus_config->quadwp_io_num != spi_periph_signal[host].spiwp_iomux_pin) {
|
||||
return false;
|
||||
}
|
||||
if (bus_config->quadhd_io_num>=0 &&
|
||||
bus_config->quadhd_io_num != spi_periph_signal[host].spihd_iomux_pin) return false;
|
||||
bus_config->quadhd_io_num != spi_periph_signal[host].spihd_iomux_pin) {
|
||||
return false;
|
||||
}
|
||||
if (bus_config->mosi_io_num >= 0 &&
|
||||
bus_config->mosi_io_num != spi_periph_signal[host].spid_iomux_pin) return false;
|
||||
bus_config->mosi_io_num != spi_periph_signal[host].spid_iomux_pin) {
|
||||
return false;
|
||||
}
|
||||
if (bus_config->miso_io_num>=0 &&
|
||||
bus_config->miso_io_num != spi_periph_signal[host].spiq_iomux_pin) return false;
|
||||
bus_config->miso_io_num != spi_periph_signal[host].spiq_iomux_pin) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -441,11 +457,7 @@ void spicommon_cs_initialize(spi_host_device_t host, int cs_io_num, int cs_num,
|
||||
if (!force_gpio_matrix && cs_io_num == spi_periph_signal[host].spics0_iomux_pin && cs_num == 0) {
|
||||
//The cs0s for all SPI peripherals map to pin mux source 1, so we use that instead of a define.
|
||||
gpio_iomux_in(cs_io_num, spi_periph_signal[host].spics_in);
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
gpio_iomux_out(cs_io_num, spi_periph_signal[host].func, false);
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
gpio_iomux_out(cs_io_num, spi_periph_signal[host].func, false);
|
||||
#endif
|
||||
} else {
|
||||
//Use GPIO matrix
|
||||
if (GPIO_IS_VALID_OUTPUT_GPIO(cs_io_num)) {
|
||||
|
@ -128,6 +128,7 @@ We have two bits to control the interrupt:
|
||||
#include "soc/soc_memory_layout.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "hal/spi_hal.h"
|
||||
#include "esp_heap_caps.h"
|
||||
|
||||
|
||||
typedef struct spi_device_t spi_device_t;
|
||||
@ -189,8 +190,8 @@ static inline bool is_valid_host(spi_host_device_t host)
|
||||
{
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
return host >= SPI1_HOST && host <= SPI3_HOST;
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
// SPI_HOST (SPI1_HOST) is not supported by the SPI Master driver on ESP32-S2
|
||||
#else
|
||||
// SPI_HOST (SPI1_HOST) is not supported by the SPI Master driver on ESP32-S2 and later
|
||||
return host >= SPI2_HOST && host <= SPI3_HOST;
|
||||
#endif
|
||||
}
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "hal/spi_slave_hal.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "freertos/task.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
@ -82,8 +81,8 @@ static inline bool is_valid_host(spi_host_device_t host)
|
||||
{
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
return host >= SPI1_HOST && host <= SPI3_HOST;
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
// SPI_HOST (SPI1_HOST) is not supported by the SPI Slave driver on ESP32-S2
|
||||
#else
|
||||
// SPI_HOST (SPI1_HOST) is not supported by the SPI Slave driver on ESP32-S2 & later
|
||||
return host >= SPI2_HOST && host <= SPI3_HOST;
|
||||
#endif
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !DISABLED_FOR_TARGETS(ESP8266, ESP32) // This testcase for ESP32S2
|
||||
/* Common header for ESP32-S2 ADC/DAC tests */
|
||||
|
||||
/**
|
||||
* SPI DMA type.
|
||||
@ -63,5 +63,3 @@ void adc_dac_dma_linker_stop(spi_dma_link_type_t type);
|
||||
* Deinit SPI3 DMA. Disable interrupt, stop DMA trans.
|
||||
*/
|
||||
void adc_dac_dma_linker_deinit(void);
|
||||
|
||||
#endif
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include "param_test.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
*/
|
||||
#include "esp_system.h"
|
||||
#include "driver/adc.h"
|
||||
#include "driver/dac.h"
|
||||
#include "unity.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_event.h"
|
||||
@ -12,7 +11,8 @@
|
||||
#include "nvs_flash.h"
|
||||
#include "test_utils.h"
|
||||
|
||||
#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S3)
|
||||
#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S3, ESP32C3)
|
||||
#include "driver/dac.h"
|
||||
|
||||
static const char* TAG = "test_adc2";
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
*/
|
||||
#include "esp_system.h"
|
||||
#include "driver/adc.h"
|
||||
#include "driver/dac.h"
|
||||
#include "driver/rtc_io.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "unity.h"
|
||||
@ -15,7 +14,8 @@
|
||||
#include "test_utils.h"
|
||||
#include "soc/adc_periph.h"
|
||||
|
||||
#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S3)
|
||||
#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S3,ESP32C3)
|
||||
#include "driver/dac.h"
|
||||
|
||||
static const char *TAG = "test_adc";
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include "esp_system.h"
|
||||
|
||||
#include "driver/adc.h"
|
||||
#include "driver/dac.h"
|
||||
#include "unity.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_event.h"
|
||||
@ -14,7 +13,8 @@
|
||||
#include "test_utils.h"
|
||||
#include "driver/i2s.h"
|
||||
|
||||
#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S3)
|
||||
#if !DISABLED_FOR_TARGETS(ESP32C3) && !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S3)
|
||||
#include "driver/dac.h"
|
||||
#include "esp_adc_cal.h"
|
||||
|
||||
static const char *TAG = "test_dac";
|
||||
@ -182,4 +182,4 @@ TEST_CASE("esp32s2 adc2-dac with adc2 calibration", "[adc-dac]")
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif // !DISABLED_FOR_TARGETS(ESP32C3) && !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S3)
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "esp_rom_uart.h"
|
||||
#include "esp_rom_sys.h"
|
||||
|
||||
#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S3)
|
||||
#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S3, ESP32C3)
|
||||
|
||||
#define WAKE_UP_IGNORE 1 // gpio_wakeup function development is not completed yet, set it deprecated.
|
||||
|
||||
|
@ -217,7 +217,7 @@ static void do_nec_tx_rx(uint32_t flags)
|
||||
{
|
||||
RingbufHandle_t rb = NULL;
|
||||
rmt_item32_t *items = NULL;
|
||||
uint32_t length = 0;
|
||||
size_t length = 0;
|
||||
uint32_t addr = 0x10;
|
||||
uint32_t cmd = 0x20;
|
||||
bool repeat = false;
|
||||
@ -313,7 +313,7 @@ TEST_CASE("RMT TX stop", "[rmt]")
|
||||
{
|
||||
RingbufHandle_t rb = NULL;
|
||||
rmt_item32_t *frames = NULL;
|
||||
uint32_t length = 0;
|
||||
size_t length = 0;
|
||||
uint32_t count = 10;
|
||||
uint32_t addr = 0x10;
|
||||
uint32_t cmd = 0x20;
|
||||
@ -409,7 +409,7 @@ TEST_CASE("RMT Ping-Pong operation", "[rmt]")
|
||||
TEST_ESP_OK(rmt_write_items(tx_channel, frames, size, true));
|
||||
|
||||
// parse received data
|
||||
uint32_t length = 0;
|
||||
size_t length = 0;
|
||||
rmt_item32_t *items = (rmt_item32_t *) xRingbufferReceive(rb, &length, 1000);
|
||||
if (items) {
|
||||
vRingbufferReturnItem(rb, (void *) items);
|
||||
@ -490,7 +490,7 @@ TEST_CASE("RMT TX loop", "[rmt]")
|
||||
{
|
||||
RingbufHandle_t rb = NULL;
|
||||
rmt_item32_t *items = NULL;
|
||||
uint32_t length = 0;
|
||||
size_t length = 0;
|
||||
uint32_t addr = 0x10;
|
||||
uint32_t cmd = 0x20;
|
||||
bool repeat = false;
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "unity.h"
|
||||
#include "driver/spi_master.h"
|
||||
#include "driver/spi_slave.h"
|
||||
@ -40,7 +39,7 @@ static void check_spi_pre_n_for(int clk, int pre, int n)
|
||||
.clock_speed_hz=clk,
|
||||
.duty_cycle_pos=128,
|
||||
.mode=0,
|
||||
.spics_io_num=21,
|
||||
.spics_io_num=PIN_NUM_CS,
|
||||
.queue_size=3
|
||||
};
|
||||
char sendbuf[16]="";
|
||||
@ -65,7 +64,6 @@ static void check_spi_pre_n_for(int clk, int pre, int n)
|
||||
TEST_ASSERT(ret==ESP_OK);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("SPI Master clockdiv calculation routines", "[spi]")
|
||||
{
|
||||
spi_bus_config_t buscfg={
|
||||
@ -86,7 +84,7 @@ TEST_CASE("SPI Master clockdiv calculation routines", "[spi]")
|
||||
check_spi_pre_n_for(100000, 16, 50);
|
||||
check_spi_pre_n_for(333333, 4, 60);
|
||||
check_spi_pre_n_for(900000, 2, 44);
|
||||
check_spi_pre_n_for(1, 8192, 64); //Actually should generate the minimum clock speed, 152Hz
|
||||
check_spi_pre_n_for(1, SOC_SPI_MAX_PRE_DIVIDER, 64); //Actually should generate the minimum clock speed, 152Hz
|
||||
check_spi_pre_n_for(26000000, 1, 3);
|
||||
|
||||
ret=spi_bus_free(TEST_SPI_HOST);
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "unity.h"
|
||||
#include "driver/spi_master.h"
|
||||
#include "driver/spi_slave.h"
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "malloc.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "freertos/ringbuf.h"
|
||||
#include "hal/uart_hal.h"
|
||||
#include "soc/uart_periph.h"
|
||||
@ -38,6 +37,8 @@
|
||||
#include "esp32s2/clk.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/clk.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/clk.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_UART_ISR_IN_IRAM
|
||||
|
@ -29,6 +29,8 @@ extern "C" {
|
||||
#include "esp32s2/esp_efuse.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/esp_efuse.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/esp_efuse.h"
|
||||
#endif
|
||||
|
||||
#define ESP_ERR_EFUSE 0x1600 /*!< Base error code for efuse api. */
|
||||
|
@ -29,6 +29,8 @@ extern "C" {
|
||||
#include "esp32s2/esp_efuse_utility.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/esp_efuse_utility.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/esp_efuse_utility.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -262,6 +262,7 @@ typedef enum {
|
||||
CHIP_ESP32 = 1, //!< ESP32
|
||||
CHIP_ESP32S2 = 2, //!< ESP32-S2
|
||||
CHIP_ESP32S3 = 4, //!< ESP32-S3
|
||||
CHIP_ESP32C3 = 5, //!< ESP32-C3
|
||||
} esp_chip_model_t;
|
||||
|
||||
/* Chip feature flags, used in esp_chip_info_t */
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "soc/dport_reg.h"
|
||||
#include "esp32/rtc.h"
|
||||
#include "esp32/cache_err_int.h"
|
||||
#include "esp32/rom/cache.h"
|
||||
@ -55,6 +56,13 @@
|
||||
#include "esp32s3/memprot.h"
|
||||
#include "soc/assist_debug_reg.h"
|
||||
#include "soc/cache_memory.h"
|
||||
#include "soc/system_reg.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rtc.h"
|
||||
#include "esp32c3/cache_err_int.h"
|
||||
#include "esp32s3/rom/cache.h"
|
||||
#include "esp32c3/rom/rtc.h"
|
||||
#include "soc/cache_memory.h"
|
||||
#endif
|
||||
|
||||
#include "bootloader_flash_config.h"
|
||||
@ -64,7 +72,6 @@
|
||||
#include "hal/rtc_io_hal.h"
|
||||
#include "hal/wdt_hal.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/periph_defs.h"
|
||||
#include "soc/cpu.h"
|
||||
@ -434,7 +441,7 @@ void IRAM_ATTR call_start_cpu0(void)
|
||||
|
||||
#ifdef CONFIG_ESP_CONSOLE_UART
|
||||
uint32_t clock_hz = rtc_clk_apb_freq_get();
|
||||
#if CONFIG_IDF_TARGET_ESP32S3
|
||||
#if CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3
|
||||
clock_hz = UART_CLK_FREQ_ROM; // From esp32-s3 on, UART clock source is selected to XTAL in ROM
|
||||
#endif
|
||||
esp_rom_uart_set_clock_baudrate(CONFIG_ESP_CONSOLE_UART_NUM, clock_hz, CONFIG_ESP_CONSOLE_UART_BAUDRATE);
|
||||
|
@ -13,6 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
@ -27,19 +28,23 @@
|
||||
#include "freertos/task.h"
|
||||
#include "driver/touch_sensor.h"
|
||||
#include "driver/touch_sensor_common.h"
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
#include "driver/rtc_io.h"
|
||||
#include "hal/rtc_io_hal.h"
|
||||
|
||||
#include "driver/uart.h"
|
||||
|
||||
#include "soc/cpu.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
#include "hal/wdt_hal.h"
|
||||
#include "hal/rtc_io_hal.h"
|
||||
#include "hal/rtc_hal.h"
|
||||
#include "hal/uart_hal.h"
|
||||
#if SOC_TOUCH_SENSOR_NUM > 0
|
||||
#include "hal/touch_sensor_hal.h"
|
||||
#endif
|
||||
#include "hal/clk_gate_ll.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
@ -59,6 +64,11 @@
|
||||
#include "esp32s3/rom/cache.h"
|
||||
#include "esp32s3/rom/rtc.h"
|
||||
#include "soc/extmem_reg.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/clk.h"
|
||||
#include "esp32s3/rom/cache.h"
|
||||
#include "esp32c3/rom/rtc.h"
|
||||
#include "soc/extmem_reg.h"
|
||||
#endif
|
||||
|
||||
// If light sleep time is less than that, don't power down flash
|
||||
@ -73,6 +83,8 @@
|
||||
#define DEFAULT_CPU_FREQ_MHZ CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#define DEFAULT_CPU_FREQ_MHZ CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#define DEFAULT_CPU_FREQ_MHZ CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32)
|
||||
@ -93,6 +105,15 @@
|
||||
#define DEEP_SLEEP_TIME_OVERHEAD_US (250 + 100 * 240 / DEFAULT_CPU_FREQ_MHZ)
|
||||
#endif // CONFIG_ESP32S2_RTC_CLK_SRC_EXT_CRYS
|
||||
|
||||
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
|
||||
#ifdef CONFIG_ESP32C3_RTC_CLK_SRC_EXT_CRYS
|
||||
#define LIGHT_SLEEP_TIME_OVERHEAD_US (650 + 30 * 240 / CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ)
|
||||
#define DEEP_SLEEP_TIME_OVERHEAD_US (650 + 100 * 240 / CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ)
|
||||
#else
|
||||
#define LIGHT_SLEEP_TIME_OVERHEAD_US (250 + 30 * 240 / CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ)
|
||||
#define DEEP_SLEEP_TIME_OVERHEAD_US (250 + 100 * 240 / CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ)
|
||||
#endif // CONFIG_ESP32C3_RTC_CLK_SRC_EXT_CRYS
|
||||
|
||||
#else // other target
|
||||
#define LIGHT_SLEEP_TIME_OVERHEAD_US 0
|
||||
#define DEEP_SLEEP_TIME_OVERHEAD_US 0
|
||||
@ -678,18 +699,22 @@ static void ext1_wakeup_prepare(void)
|
||||
if ((rtc_gpio_mask & BIT(rtc_pin)) == 0) {
|
||||
continue;
|
||||
}
|
||||
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
// Route pad to RTC
|
||||
rtcio_hal_function_select(rtc_pin, RTCIO_FUNC_RTC);
|
||||
// set input enable in sleep mode
|
||||
rtcio_hal_input_enable(rtc_pin);
|
||||
#endif
|
||||
|
||||
// Pad configuration depends on RTC_PERIPH state in sleep mode
|
||||
if (s_config.pd_options[ESP_PD_DOMAIN_RTC_PERIPH] != ESP_PD_OPTION_ON) {
|
||||
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
// RTC_PERIPH will be powered down, so RTC_IO_ registers will
|
||||
// loose their state. Lock pad configuration.
|
||||
// Pullups/pulldowns also need to be disabled.
|
||||
rtcio_hal_pullup_disable(rtc_pin);
|
||||
rtcio_hal_pulldown_disable(rtc_pin);
|
||||
#endif
|
||||
rtcio_hal_hold_enable(rtc_pin);
|
||||
}
|
||||
// Keep track of pins which are processed to bail out early
|
||||
@ -725,10 +750,12 @@ uint64_t esp_sleep_get_ext1_wakeup_status(void)
|
||||
|
||||
esp_err_t esp_sleep_enable_gpio_wakeup(void)
|
||||
{
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
if (s_config.wakeup_triggers & (RTC_TOUCH_TRIG_EN | RTC_ULP_TRIG_EN)) {
|
||||
ESP_LOGE(TAG, "Conflicting wake-up triggers: touch / ULP");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
#endif
|
||||
s_config.wakeup_triggers |= RTC_GPIO_TRIG_EN;
|
||||
return ESP_OK;
|
||||
}
|
||||
@ -780,8 +807,10 @@ esp_sleep_wakeup_cause_t esp_sleep_get_wakeup_cause(void)
|
||||
return ESP_SLEEP_WAKEUP_TIMER;
|
||||
} else if (wakeup_cause & RTC_TOUCH_TRIG_EN) {
|
||||
return ESP_SLEEP_WAKEUP_TOUCHPAD;
|
||||
#if SOC_ULP_SUPPORTED
|
||||
} else if (wakeup_cause & RTC_ULP_TRIG_EN) {
|
||||
return ESP_SLEEP_WAKEUP_ULP;
|
||||
#endif
|
||||
} else if (wakeup_cause & RTC_GPIO_TRIG_EN) {
|
||||
return ESP_SLEEP_WAKEUP_GPIO;
|
||||
} else if (wakeup_cause & (RTC_UART0_TRIG_EN | RTC_UART1_TRIG_EN)) {
|
||||
@ -818,6 +847,7 @@ static uint32_t get_power_down_flags(void)
|
||||
// If there is any data placed into .rtc.data or .rtc.bss segments, and
|
||||
// RTC_SLOW_MEM is Auto, keep it powered up as well.
|
||||
|
||||
#if SOC_RTC_SLOW_MEM_SUPPORTED && SOC_ULP_SUPPORTED
|
||||
// Labels are defined in the linker script
|
||||
extern int _rtc_slow_length;
|
||||
|
||||
@ -826,6 +856,7 @@ static uint32_t get_power_down_flags(void)
|
||||
(s_config.wakeup_triggers & RTC_ULP_TRIG_EN))) {
|
||||
s_config.pd_options[ESP_PD_DOMAIN_RTC_SLOW_MEM] = ESP_PD_OPTION_ON;
|
||||
}
|
||||
#endif
|
||||
|
||||
// RTC_FAST_MEM is needed for deep sleep stub.
|
||||
// If RTC_FAST_MEM is Auto, keep it powered on, so that deep sleep stub
|
||||
@ -839,9 +870,13 @@ static uint32_t get_power_down_flags(void)
|
||||
// RTC_PERIPH is needed for EXT0 wakeup and GPIO wakeup.
|
||||
// If RTC_PERIPH is auto, and EXT0/GPIO aren't enabled, power down RTC_PERIPH.
|
||||
if (s_config.pd_options[ESP_PD_DOMAIN_RTC_PERIPH] == ESP_PD_OPTION_AUTO) {
|
||||
uint32_t wakeup_source = RTC_TOUCH_TRIG_EN;
|
||||
#if SOC_ULP_SUPPORTED
|
||||
wakeup_source |= RTC_ULP_TRIG_EN;
|
||||
#endif
|
||||
if (s_config.wakeup_triggers & (RTC_EXT0_TRIG_EN | RTC_GPIO_TRIG_EN)) {
|
||||
s_config.pd_options[ESP_PD_DOMAIN_RTC_PERIPH] = ESP_PD_OPTION_ON;
|
||||
} else if (s_config.wakeup_triggers & (RTC_TOUCH_TRIG_EN | RTC_ULP_TRIG_EN)) {
|
||||
} else if (s_config.wakeup_triggers & wakeup_source) {
|
||||
// In both rev. 0 and rev. 1 of ESP32, forcing power up of RTC_PERIPH
|
||||
// prevents ULP timer and touch FSMs from working correctly.
|
||||
s_config.pd_options[ESP_PD_DOMAIN_RTC_PERIPH] = ESP_PD_OPTION_OFF;
|
||||
@ -853,19 +888,22 @@ static uint32_t get_power_down_flags(void)
|
||||
}
|
||||
|
||||
const char* option_str[] = {"OFF", "ON", "AUTO(OFF)" /* Auto works as OFF */};
|
||||
ESP_LOGD(TAG, "RTC_PERIPH: %s, RTC_SLOW_MEM: %s, RTC_FAST_MEM: %s",
|
||||
option_str[s_config.pd_options[ESP_PD_DOMAIN_RTC_PERIPH]],
|
||||
option_str[s_config.pd_options[ESP_PD_DOMAIN_RTC_SLOW_MEM]],
|
||||
option_str[s_config.pd_options[ESP_PD_DOMAIN_RTC_FAST_MEM]]);
|
||||
ESP_LOGD(TAG, "RTC_PERIPH: %s", option_str[s_config.pd_options[ESP_PD_DOMAIN_RTC_PERIPH]]);
|
||||
#if SOC_RTC_SLOW_MEM_SUPPORTED
|
||||
ESP_LOGD(TAG, "RTC_SLOW_MEM: %s", option_str[s_config.pd_options[ESP_PD_DOMAIN_RTC_SLOW_MEM]]);
|
||||
#endif
|
||||
ESP_LOGD(TAG, "RTC_FAST_MEM: %s", option_str[s_config.pd_options[ESP_PD_DOMAIN_RTC_FAST_MEM]]);
|
||||
|
||||
// Prepare flags based on the selected options
|
||||
uint32_t pd_flags = 0;
|
||||
if (s_config.pd_options[ESP_PD_DOMAIN_RTC_FAST_MEM] != ESP_PD_OPTION_ON) {
|
||||
pd_flags |= RTC_SLEEP_PD_RTC_FAST_MEM;
|
||||
}
|
||||
#if SOC_RTC_SLOW_MEM_SUPPORTED
|
||||
if (s_config.pd_options[ESP_PD_DOMAIN_RTC_SLOW_MEM] != ESP_PD_OPTION_ON) {
|
||||
pd_flags |= RTC_SLEEP_PD_RTC_SLOW_MEM;
|
||||
}
|
||||
#endif
|
||||
if (s_config.pd_options[ESP_PD_DOMAIN_RTC_PERIPH] != ESP_PD_OPTION_ON) {
|
||||
pd_flags |= RTC_SLEEP_PD_RTC_PERIPH;
|
||||
}
|
||||
|
@ -70,6 +70,9 @@
|
||||
#include "esp32s3/clk.h"
|
||||
#include "esp32s3/spiram.h"
|
||||
#include "esp32s3/brownout.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/clk.h"
|
||||
#include "esp32c3/brownout.h"
|
||||
#endif
|
||||
/***********************************************/
|
||||
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include "esp32s2/memprot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/memprot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/memprot.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include "esp32s2/rtc.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rtc.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rtc.h"
|
||||
#endif
|
||||
|
||||
#include "esp_private/startup_internal.h"
|
||||
|
@ -37,6 +37,8 @@
|
||||
#include "esp32s2/rtc.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rtc.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rtc.h"
|
||||
#endif
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
@ -7,12 +7,15 @@
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "esp_spi_flash.h"
|
||||
#include "esp_rom_sys.h"
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32/rom/ets_sys.h" // for ETSTimer type
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/rom/ets_sys.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/ets_sys.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/ets_sys.h"
|
||||
#endif
|
||||
|
||||
TEST_CASE("ets_timer produces correct delay", "[ets_timer]")
|
||||
@ -26,7 +29,7 @@ TEST_CASE("ets_timer produces correct delay", "[ets_timer]")
|
||||
ETSTimer timer1 = {0};
|
||||
|
||||
const int delays_ms[] = {20, 100, 200, 250};
|
||||
const size_t delays_count = sizeof(delays_ms)/sizeof(delays_ms[0]);
|
||||
const size_t delays_count = sizeof(delays_ms) / sizeof(delays_ms[0]);
|
||||
|
||||
for (size_t i = 0; i < delays_count; ++i) {
|
||||
struct timeval tv_end = {0};
|
||||
@ -54,15 +57,14 @@ TEST_CASE("periodic ets_timer produces correct delays", "[ets_timer]")
|
||||
#define NUM_INTERVALS 16
|
||||
|
||||
typedef struct {
|
||||
ETSTimer* timer;
|
||||
ETSTimer *timer;
|
||||
size_t cur_interval;
|
||||
int intervals[NUM_INTERVALS];
|
||||
struct timeval tv_start;
|
||||
} test_args_t;
|
||||
|
||||
void timer_func(void* arg)
|
||||
{
|
||||
test_args_t* p_args = (test_args_t*) arg;
|
||||
void timer_func(void *arg) {
|
||||
test_args_t *p_args = (test_args_t *) arg;
|
||||
struct timeval tv_now;
|
||||
gettimeofday(&tv_now, NULL);
|
||||
int32_t ms_diff = (tv_now.tv_sec - p_args->tv_start.tv_sec) * 1000 +
|
||||
@ -71,7 +73,7 @@ TEST_CASE("periodic ets_timer produces correct delays", "[ets_timer]")
|
||||
p_args->intervals[p_args->cur_interval++] = ms_diff;
|
||||
// Deliberately make timer handler run longer.
|
||||
// We check that this doesn't affect the result.
|
||||
esp_rom_delay_us(10*1000);
|
||||
esp_rom_delay_us(10 * 1000);
|
||||
if (p_args->cur_interval == NUM_INTERVALS) {
|
||||
printf("done\n");
|
||||
ets_timer_disarm(p_args->timer);
|
||||
|
@ -80,6 +80,7 @@
|
||||
#include "sdkconfig.h"
|
||||
#include "portmacro.h"
|
||||
#include "riscv/interrupt.h"
|
||||
#include "riscv/rvruntime-frames.h"
|
||||
#include "soc/periph_defs.h"
|
||||
#include "soc/system_reg.h"
|
||||
#include "soc/interrupt_reg.h"
|
||||
@ -220,8 +221,9 @@ StackType_t *pxPortInitialiseStack(StackType_t *pxTopOfStack, TaskFunction_t pxC
|
||||
|
||||
/* Simulate the stack frame as it would be created by a context switch
|
||||
interrupt. */
|
||||
pxTopOfStack -= RV_STK_FRMSZ;
|
||||
|
||||
RvExcFrame *frame = (RvExcFrame *)pxTopOfStack;
|
||||
frame--;
|
||||
frame->ra = (UBaseType_t)prvTaskExitError;
|
||||
frame->mepc = (UBaseType_t)pxCode;
|
||||
frame->a0 = (UBaseType_t)pvParameters;
|
||||
|
@ -127,6 +127,8 @@ int xt_clock_freq(void) __attribute__((deprecated));
|
||||
#include "esp32s2/rom/ets_sys.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/ets_sys.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/ets_sys.h"
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_FREERTOS_ASSERT_DISABLE)
|
||||
|
@ -40,6 +40,7 @@ extern "C" {
|
||||
#define MALLOC_CAP_INTERNAL (1<<11) ///< Memory must be internal; specifically it should not disappear when flash/spiram cache is switched off
|
||||
#define MALLOC_CAP_DEFAULT (1<<12) ///< Memory can be returned in a non-capability-specific memory allocation (e.g. malloc(), calloc()) call
|
||||
#define MALLOC_CAP_IRAM_8BIT (1<<13) ///< Memory must be in IRAM and allow unaligned access
|
||||
#define MALLOC_CAP_RETENTION (1<<14)
|
||||
|
||||
#define MALLOC_CAP_INVALID (1<<31) ///< Memory can't be used / list end marker
|
||||
|
||||
|
@ -92,8 +92,6 @@ inline static void multi_heap_assert(bool condition, const char *format, int lin
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
typedef int multi_heap_lock_t;
|
||||
|
||||
#define MULTI_HEAP_PRINTF printf
|
||||
#define MULTI_HEAP_STDERR_PRINTF(MSG, ...) fprintf(stderr, MSG, __VA_ARGS__)
|
||||
#define MULTI_HEAP_LOCK(PLOCK) (void) (PLOCK)
|
||||
|
@ -125,7 +125,9 @@
|
||||
#endif
|
||||
|
||||
// Some performance value based on the test against GD chip with single_core config.
|
||||
// IDF_PERFORMANCE_MIN_FLASH_SPEED_BYTE_PER_SEC_EXT_WR_4B in target file
|
||||
#ifndef IDF_PERFORMANCE_MIN_FLASH_SPEED_BYTE_PER_SEC_EXT_WR_4B
|
||||
#define IDF_PERFORMANCE_MIN_FLASH_SPEED_BYTE_PER_SEC_EXT_WR_4B 64900
|
||||
#endif
|
||||
// IDF_PERFORMANCE_MIN_FLASH_SPEED_BYTE_PER_SEC_EXT_RD_4B in target file
|
||||
#ifndef IDF_PERFORMANCE_MIN_FLASH_SPEED_BYTE_PER_SEC_EXT_WR_2KB
|
||||
#define IDF_PERFORMANCE_MIN_FLASH_SPEED_BYTE_PER_SEC_EXT_WR_2KB (475*1000)
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "esp32s2/rom/ets_sys.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/ets_sys.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/ets_sys.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include "soc/hwcrypto_periph.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "driver/periph_ctrl.h"
|
||||
#include <mbedtls/bignum.h>
|
||||
#include "bignum_impl.h"
|
||||
|
@ -44,6 +44,8 @@
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/aes.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/aes.h"
|
||||
#endif
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32S3
|
||||
|
@ -34,6 +34,8 @@ extern "C" {
|
||||
#include "esp32s2/aes.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/aes.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/aes.h"
|
||||
#endif
|
||||
|
||||
typedef esp_aes_context mbedtls_aes_context;
|
||||
|
@ -29,8 +29,12 @@ extern "C" {
|
||||
|
||||
#if defined(MBEDTLS_GCM_ALT)
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32S3
|
||||
#if CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32s3/gcm.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/gcm.h"
|
||||
#endif
|
||||
|
||||
|
||||
typedef esp_gcm_context mbedtls_gcm_context;
|
||||
@ -44,7 +48,7 @@ typedef esp_gcm_context mbedtls_gcm_context;
|
||||
#define mbedtls_gcm_auth_decrypt esp_aes_gcm_auth_decrypt
|
||||
#define mbedtls_gcm_crypt_and_tag esp_aes_gcm_crypt_and_tag
|
||||
|
||||
#endif // CONFIG_IDF_TARGET_ESP32S3
|
||||
#endif // CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/gcm.h"
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "esp_log.h"
|
||||
#include "esp_crypto_lock.h"
|
||||
#include "soc/lldesc.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "soc/cache_memory.h"
|
||||
#include "soc/periph_defs.h"
|
||||
|
||||
@ -50,6 +49,8 @@
|
||||
#include "esp32s2/rom/cache.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/cache.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32s3/rom/cache.h"
|
||||
#endif
|
||||
|
||||
#if SOC_SHA_GENERAL_DMA
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "lwip/priv/tcpip_priv.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_event.h"
|
||||
#if CONFIG_ETH_ENABLED
|
||||
#include "esp_eth.h"
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include "esp_event_base.h"
|
||||
#include "esp_task.h"
|
||||
#include "esp_timer.h"
|
||||
|
||||
//#define MDNS_ENABLE_DEBUG
|
||||
|
||||
|
@ -39,6 +39,10 @@
|
||||
#include "esp32s3/rom/rtc.h"
|
||||
#include "esp32s3/clk.h"
|
||||
#include "esp32s3/rtc.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/rtc.h"
|
||||
#include "esp32c3/clk.h"
|
||||
#include "esp32c3/rtc.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -26,6 +26,9 @@
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/clk.h"
|
||||
#define TARGET_DEFAULT_CPU_FREQ_MHZ CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/clk.h"
|
||||
#define TARGET_DEFAULT_CPU_FREQ_MHZ CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ
|
||||
#endif
|
||||
|
||||
#if portNUM_PROCESSORS == 2
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <freertos/task.h>
|
||||
#include <freertos/semphr.h>
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "soc/dport_reg.h"
|
||||
#include <esp32/rom/spi_flash.h>
|
||||
#include <esp32/rom/cache.h>
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
@ -33,9 +34,13 @@
|
||||
#include "esp32s3/rom/cache.h"
|
||||
#include "soc/extmem_reg.h"
|
||||
#include "soc/cache_memory.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/spi_flash.h"
|
||||
#include "esp32c3/rom/cache.h"
|
||||
#include "soc/extmem_reg.h"
|
||||
#include "soc/cache_memory.h"
|
||||
#endif
|
||||
#include <soc/soc.h>
|
||||
#include <soc/dport_reg.h>
|
||||
#include "sdkconfig.h"
|
||||
#ifndef CONFIG_FREERTOS_UNICORE
|
||||
#include "esp_ipc.h"
|
||||
@ -314,6 +319,10 @@ static void IRAM_ATTR spi_flash_disable_cache(uint32_t cpuid, uint32_t *saved_st
|
||||
icache_state = Cache_Suspend_ICache() << 16;
|
||||
dcache_state = Cache_Suspend_DCache();
|
||||
*saved_state = icache_state | dcache_state;
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
uint32_t icache_state;
|
||||
icache_state = Cache_Suspend_ICache() << 16;
|
||||
*saved_state = icache_state;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -336,6 +345,8 @@ static void IRAM_ATTR spi_flash_restore_cache(uint32_t cpuid, uint32_t saved_sta
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
Cache_Resume_DCache(saved_state & 0xffff);
|
||||
Cache_Resume_ICache(saved_state >> 16);
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
Cache_Resume_ICache(saved_state >> 16);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -348,7 +359,7 @@ IRAM_ATTR bool spi_flash_cache_enabled(void)
|
||||
#endif
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
bool result = (REG_GET_BIT(EXTMEM_PRO_ICACHE_CTRL_REG, EXTMEM_PRO_ICACHE_ENABLE) != 0);
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3
|
||||
bool result = (REG_GET_BIT(EXTMEM_ICACHE_CTRL_REG, EXTMEM_ICACHE_ENABLE) != 0);
|
||||
#endif
|
||||
return result;
|
||||
@ -463,19 +474,19 @@ esp_err_t esp_enable_cache_wrap(bool icache_wrap_enable, bool dcache_wrap_enable
|
||||
int i;
|
||||
bool flash_spiram_wrap_together, flash_support_wrap = true, spiram_support_wrap = true;
|
||||
uint32_t drom0_in_icache = 1;//always 1 in esp32s2
|
||||
#if CONFIG_IDF_TARGET_ESP32S3
|
||||
#if CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32C3
|
||||
drom0_in_icache = 0;
|
||||
#endif
|
||||
|
||||
if (icache_wrap_enable) {
|
||||
#if CONFIG_ESP32S2_INSTRUCTION_CACHE_LINE_16B || CONFIG_ESP32S3_INSTRUCTION_CACHE_LINE_16B
|
||||
#if CONFIG_ESP32S2_INSTRUCTION_CACHE_LINE_16B || CONFIG_ESP32S3_INSTRUCTION_CACHE_LINE_16B || CONFIG_ESP32C3_INSTRUCTION_CACHE_LINE_16B
|
||||
icache_wrap_size = 16;
|
||||
#else
|
||||
icache_wrap_size = 32;
|
||||
#endif
|
||||
}
|
||||
if (dcache_wrap_enable) {
|
||||
#if CONFIG_ESP32S2_DATA_CACHE_LINE_16B || CONFIG_ESP32S3_DATA_CACHE_LINE_16B
|
||||
#if CONFIG_ESP32S2_DATA_CACHE_LINE_16B || CONFIG_ESP32S3_DATA_CACHE_LINE_16B || CONFIG_ESP32C3_INSTRUCTION_CACHE_LINE_16B
|
||||
dcache_wrap_size = 16;
|
||||
#else
|
||||
dcache_wrap_size = 32;
|
||||
|
@ -15,6 +15,7 @@
|
||||
#ifndef ESP_SPI_FLASH_CACHE_UTILS_H
|
||||
#define ESP_SPI_FLASH_CACHE_UTILS_H
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
@ -57,10 +58,10 @@ void spi_flash_enable_interrupts_caches_no_os(void);
|
||||
//
|
||||
// Only call this while holding spi_flash_op_lock()
|
||||
// Returns true if cache was flushed, false otherwise
|
||||
bool spi_flash_check_and_flush_cache(uint32_t start_addr, uint32_t length);
|
||||
bool spi_flash_check_and_flush_cache(size_t start_addr, size_t length);
|
||||
|
||||
//config cache mode
|
||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#if !CONFIG_IDF_TARGET_ESP32
|
||||
//config instrcutin cache size and cache block size by menuconfig
|
||||
void esp_config_instruction_cache_mode(void);
|
||||
//config data cache size and cache block size by menuconfig
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include "esp32s2/rom/spi_flash.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/spi_flash.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/spi_flash.h"
|
||||
#endif
|
||||
|
||||
__attribute__((unused)) static const char TAG[] = "spi_flash";
|
||||
@ -224,7 +226,7 @@ esp_err_t esp_flash_init_default_chip(void)
|
||||
{
|
||||
memspi_host_config_t cfg = ESP_FLASH_HOST_CONFIG_DEFAULT();
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#if !CONFIG_IDF_TARGET_ESP32
|
||||
// For esp32s2 spi IOs are configured as from IO MUX by default
|
||||
cfg.iomux = esp_rom_efuse_get_flash_gpio_info() == 0 ? true : false;
|
||||
#endif
|
||||
|
@ -20,22 +20,24 @@
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/task.h>
|
||||
#include <freertos/semphr.h>
|
||||
#include <soc/soc.h>
|
||||
#include <soc/dport_reg.h>
|
||||
#include <soc/soc_memory_layout.h>
|
||||
#include "soc/soc.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
#include "soc/dport_access.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_spi_flash.h"
|
||||
#include "esp_flash_encrypt.h"
|
||||
#include "esp_log.h"
|
||||
#include "cache_utils.h"
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32/rom/spi_flash.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "esp32/rom/cache.h"
|
||||
#include "esp32/rom/spi_flash.h"
|
||||
#include "esp32/spiram.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/rom/spi_flash.h"
|
||||
#include "esp32s2/rom/cache.h"
|
||||
#include "esp32s2/rom/spi_flash.h"
|
||||
#include "esp32s2/spiram.h"
|
||||
#include "soc/extmem_reg.h"
|
||||
#include "soc/cache_memory.h"
|
||||
@ -45,6 +47,10 @@
|
||||
#include "esp32s3/spiram.h"
|
||||
#include "soc/extmem_reg.h"
|
||||
#include "soc/cache_memory.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/cache.h"
|
||||
#include "esp32c3/rom/spi_flash.h"
|
||||
#include "soc/cache_memory.h"
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
@ -274,7 +280,7 @@ esp_err_t IRAM_ATTR spi_flash_mmap_pages(const int *pages, size_t page_count, sp
|
||||
DPORT_APP_FLASH_MMU_TABLE[i] = pages[pageno];
|
||||
#endif
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#if !CONFIG_IDF_TARGET_ESP32
|
||||
Cache_Invalidate_Addr(region_addr + (i - region_begin) * SPI_FLASH_MMU_PAGE_SIZE, SPI_FLASH_MMU_PAGE_SIZE);
|
||||
#endif
|
||||
need_flush = true;
|
||||
@ -300,14 +306,14 @@ esp_err_t IRAM_ATTR spi_flash_mmap_pages(const int *pages, size_t page_count, sp
|
||||
*/
|
||||
if (need_flush) {
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
# if CONFIG_SPIRAM
|
||||
#if CONFIG_SPIRAM
|
||||
esp_spiram_writeback_cache();
|
||||
# endif
|
||||
#endif // CONFIG_SPIRAM
|
||||
Cache_Flush(0);
|
||||
# if !CONFIG_FREERTOS_UNICORE
|
||||
#if !CONFIG_FREERTOS_UNICORE
|
||||
Cache_Flush(1);
|
||||
# endif
|
||||
#endif
|
||||
#endif // !CONFIG_FREERTOS_UNICORE
|
||||
#endif // CONFIG_IDF_TARGET_ESP32
|
||||
}
|
||||
|
||||
spi_flash_enable_interrupts_caches_and_other_cpu();
|
||||
@ -438,7 +444,7 @@ uint32_t spi_flash_cache2phys(const void *cached)
|
||||
return phys_offs | (c & (SPI_FLASH_MMU_PAGE_SIZE-1));
|
||||
}
|
||||
|
||||
const void *IRAM_ATTR spi_flash_phys2cache(uint32_t phys_offs, spi_flash_mmap_memory_t memory)
|
||||
const void *IRAM_ATTR spi_flash_phys2cache(size_t phys_offs, spi_flash_mmap_memory_t memory)
|
||||
{
|
||||
uint32_t phys_page = phys_offs / SPI_FLASH_MMU_PAGE_SIZE;
|
||||
int start, end, page_delta;
|
||||
@ -506,7 +512,7 @@ static bool IRAM_ATTR is_page_mapped_in_cache(uint32_t phys_page, const void **o
|
||||
for (int j = 0; j < 2; j++) {
|
||||
for (int i = start[j]; i < end[j]; i++) {
|
||||
if (DPORT_SEQUENCE_REG_READ((uint32_t)&DPORT_PRO_FLASH_MMU_TABLE[i]) == PAGE_IN_FLASH(phys_page)) {
|
||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#if !CONFIG_IDF_TARGET_ESP32
|
||||
if (j == 0) { /* SPI_FLASH_MMAP_DATA */
|
||||
*out_ptr = (const void *)(VADDR0_START_ADDR + SPI_FLASH_MMU_PAGE_SIZE * (i - start[0]));
|
||||
} else { /* SPI_FLASH_MMAP_INST */
|
||||
@ -547,12 +553,12 @@ IRAM_ATTR bool spi_flash_check_and_flush_cache(size_t start_addr, size_t length)
|
||||
Cache_Flush(1);
|
||||
#endif
|
||||
return true;
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#else // CONFIG_IDF_TARGET_ESP32
|
||||
if (vaddr != NULL) {
|
||||
Cache_Invalidate_Addr((uint32_t)vaddr, SPI_FLASH_MMU_PAGE_SIZE);
|
||||
ret = true;
|
||||
}
|
||||
#endif
|
||||
#endif // CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <freertos/task.h>
|
||||
#include <freertos/semphr.h>
|
||||
#include <soc/soc.h>
|
||||
#include <soc/dport_reg.h>
|
||||
#include <soc/soc_memory_layout.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_attr.h"
|
||||
@ -30,17 +29,21 @@
|
||||
#include "esp_log.h"
|
||||
#include "esp_private/system_internal.h"
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32/rom/spi_flash.h"
|
||||
#include "esp32/rom/cache.h"
|
||||
#include "esp32/rom/spi_flash.h"
|
||||
#include "esp32/clk.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/rom/spi_flash.h"
|
||||
#include "esp32s2/rom/cache.h"
|
||||
#include "esp32s2/rom/spi_flash.h"
|
||||
#include "esp32s2/clk.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/spi_flash.h"
|
||||
#include "esp32s3/rom/cache.h"
|
||||
#include "esp32s3/clk.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/cache.h"
|
||||
#include "esp32c3/rom/spi_flash.h"
|
||||
#include "esp32c3/clk.h"
|
||||
#endif
|
||||
#include "esp_flash_partitions.h"
|
||||
#include "cache_utils.h"
|
||||
@ -68,11 +71,11 @@ static const char *TAG __attribute__((unused)) = "spi_flash";
|
||||
#if CONFIG_SPI_FLASH_ENABLE_COUNTERS
|
||||
static spi_flash_counters_t s_flash_stats;
|
||||
|
||||
#define COUNTER_START() uint32_t ts_begin = xthal_get_ccount()
|
||||
#define COUNTER_START() uint32_t ts_begin = cpu_hal_get_cycle_count()
|
||||
#define COUNTER_STOP(counter) \
|
||||
do{ \
|
||||
s_flash_stats.counter.count++; \
|
||||
s_flash_stats.counter.time += (xthal_get_ccount() - ts_begin) / (esp_clk_cpu_freq() / 1000000); \
|
||||
s_flash_stats.counter.time += (cpu_hal_get_cycle_count() - ts_begin) / (esp_clk_cpu_freq() / 1000000); \
|
||||
} while(0)
|
||||
|
||||
#define COUNTER_ADD_BYTES(counter, size) \
|
||||
@ -784,8 +787,7 @@ void spi_flash_dump_counters(void)
|
||||
|
||||
#endif //CONFIG_SPI_FLASH_ENABLE_COUNTERS
|
||||
|
||||
|
||||
#if defined(CONFIG_SPI_FLASH_USE_LEGACY_IMPL) && (defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3))
|
||||
// TODO esp32s2: Remove once ESP32S2 has new SPI Flash API support
|
||||
#if CONFIG_SPI_FLASH_USE_LEGACY_IMPL && !CONFIG_IDF_TARGET_ESP32
|
||||
// TODO esp32s2: Remove once ESP32-S2 & later chips has new SPI Flash API support
|
||||
esp_flash_t *esp_flash_default_chip = NULL;
|
||||
#endif
|
||||
|
@ -25,6 +25,9 @@
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/ets_sys.h"
|
||||
#include "esp32s3/rom/cache.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/ets_sys.h"
|
||||
#include "esp32c3/rom/cache.h"
|
||||
#endif
|
||||
|
||||
#include "esp_attr.h"
|
||||
@ -63,6 +66,10 @@ static IRAM_ATTR esp_err_t end(void *arg)
|
||||
Cache_Invalidate_ICache_All();
|
||||
Cache_Resume_ICache(spi_arg->icache_autoload);
|
||||
Cache_Resume_DCache(spi_arg->dcache_autoload);
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
spi_noos_arg_t *spi_arg = arg;
|
||||
Cache_Invalidate_ICache_All();
|
||||
Cache_Resume_ICache(spi_arg->icache_autoload);
|
||||
#endif
|
||||
return ESP_OK;
|
||||
}
|
||||
@ -88,7 +95,7 @@ esp_err_t IRAM_ATTR esp_flash_app_disable_os_functions(esp_flash_t* chip)
|
||||
{
|
||||
chip->os_func = &esp_flash_noos_functions;
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#if !CONFIG_IDF_TARGET_ESP32
|
||||
chip->os_func_data = &spi_arg;
|
||||
#endif
|
||||
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include "esp32s2/clk.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/clk.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/clk.h"
|
||||
#endif
|
||||
|
||||
static uint32_t s_test_start, s_test_stop;
|
||||
|
@ -162,7 +162,7 @@ static void uart_tx_char(int fd, int c)
|
||||
}
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
uart->fifo.rw_byte = c;
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#else // CONFIG_IDF_TARGET_ESP32
|
||||
uart->ahb_fifo.rw_byte = c;
|
||||
#endif
|
||||
}
|
||||
@ -181,7 +181,7 @@ static int uart_rx_char(int fd)
|
||||
}
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
return uart->fifo.rw_byte;
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#else // CONFIG_IDF_TARGET_ESP32
|
||||
return READ_PERI_REG(UART_FIFO_AHB_REG(fd));
|
||||
#endif
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
* GPIO4/5 are from low speed channel group.
|
||||
*
|
||||
*/
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#define LEDC_HS_TIMER LEDC_TIMER_0
|
||||
#define LEDC_HS_MODE LEDC_HIGH_SPEED_MODE
|
||||
#define LEDC_HS_CH0_GPIO (18)
|
||||
@ -43,7 +43,7 @@
|
||||
#endif
|
||||
#define LEDC_LS_TIMER LEDC_TIMER_1
|
||||
#define LEDC_LS_MODE LEDC_LOW_SPEED_MODE
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32S2
|
||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32C3
|
||||
#define LEDC_LS_CH0_GPIO (18)
|
||||
#define LEDC_LS_CH0_CHANNEL LEDC_CHANNEL_0
|
||||
#define LEDC_LS_CH1_GPIO (19)
|
||||
@ -95,7 +95,7 @@ void app_main(void)
|
||||
* will be the same
|
||||
*/
|
||||
ledc_channel_config_t ledc_channel[LEDC_TEST_CH_NUM] = {
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
{
|
||||
.channel = LEDC_HS_CH0_CHANNEL,
|
||||
.duty = 0,
|
||||
@ -112,7 +112,7 @@ void app_main(void)
|
||||
.hpoint = 0,
|
||||
.timer_sel = LEDC_HS_TIMER
|
||||
},
|
||||
#elif defined CONFIG_IDF_TARGET_ESP32S2
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32C3
|
||||
{
|
||||
.channel = LEDC_LS_CH0_CHANNEL,
|
||||
.duty = 0,
|
||||
|
@ -130,7 +130,7 @@ struct ir_builder_s {
|
||||
* - ESP_ERR_INVALID_ARG: Get result data failed because of invalid arguments
|
||||
* - ESP_FAIL: Get result data failed because some other errors occurred
|
||||
*/
|
||||
esp_err_t (*get_result)(ir_builder_t *builder, void *result, uint32_t *length);
|
||||
esp_err_t (*get_result)(ir_builder_t *builder, void *result, size_t *length);
|
||||
|
||||
/**
|
||||
* @brief Free resources used by IR builder
|
||||
|
@ -142,7 +142,7 @@ static esp_err_t nec_build_repeat_frame(ir_builder_t *builder)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t nec_builder_get_result(ir_builder_t *builder, void *result, uint32_t *length)
|
||||
static esp_err_t nec_builder_get_result(ir_builder_t *builder, void *result, size_t *length)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
nec_builder_t *nec_builder = __containerof(builder, nec_builder_t, parent);
|
||||
|
@ -135,7 +135,7 @@ static esp_err_t rc5_build_repeat_frame(ir_builder_t *builder)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t rc5_builder_get_result(ir_builder_t *builder, void *result, uint32_t *length)
|
||||
static esp_err_t rc5_builder_get_result(ir_builder_t *builder, void *result, size_t *length)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
rc5_builder_t *rc5_builder = __containerof(builder, rc5_builder_t, parent);
|
||||
|
@ -18,7 +18,7 @@
|
||||
static const char *TAG = "example";
|
||||
|
||||
static rmt_channel_t example_tx_channel = RMT_CHANNEL_0;
|
||||
static rmt_channel_t example_rx_channel = RMT_CHANNEL_1;
|
||||
static rmt_channel_t example_rx_channel = RMT_CHANNEL_2;
|
||||
|
||||
/**
|
||||
* @brief RMT Receive Task
|
||||
|
@ -29,6 +29,9 @@ static const char* TAG = "example";
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#define TARGET_CRYPT_CNT_EFUSE ESP_EFUSE_SPI_BOOT_CRYPT_CNT
|
||||
#define TARGET_CRYPT_CNT_WIDTH 3
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#define TARGET_CRYPT_CNT_EFUSE ESP_EFUSE_WR_DIS_SPI_BOOT_CRYPT_CNT
|
||||
#define TARGET_CRYPT_CNT_WIDTH 3
|
||||
#endif
|
||||
|
||||
void app_main(void)
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include "esp32s2/clk.h"
|
||||
#elif CONFIG_IDF_TARTGET_ESP32S3
|
||||
#include "esp32s3/clk.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/clk.h"
|
||||
#endif
|
||||
|
||||
#include "unity.h"
|
||||
@ -36,6 +38,11 @@ static const char* TAG = "test_ccomp_timer";
|
||||
#define CACHE_LINE_SIZE 32
|
||||
#define CACHE_SIZE (1 << 13)
|
||||
#define TEST_SIZE (CACHE_SIZE)
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#define CACHE_WAYS 8
|
||||
#define CACHE_LINE_SIZE 32
|
||||
#define CACHE_SIZE (1 << 14)
|
||||
#define TEST_SIZE (CACHE_SIZE)
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
|
@ -23,6 +23,10 @@
|
||||
#define CACHE_WAYS 8
|
||||
#define CACHE_LINE_SIZE 32
|
||||
#define CACHE_SIZE (1 << 13)
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#define CACHE_WAYS 8
|
||||
#define CACHE_LINE_SIZE 32
|
||||
#define CACHE_SIZE (1 << 14)
|
||||
#endif
|
||||
|
||||
typedef void (*ccomp_test_func_t)(void);
|
||||
|
Loading…
Reference in New Issue
Block a user