diff --git a/components/esp_system/include/esp_sleep.h b/components/esp_system/include/esp_sleep.h index bcfe6227e6..5b90614cc3 100644 --- a/components/esp_system/include/esp_sleep.h +++ b/components/esp_system/include/esp_sleep.h @@ -68,6 +68,7 @@ typedef enum { ESP_SLEEP_WAKEUP_WIFI, //!< Wakeup caused by WIFI (light sleep only) ESP_SLEEP_WAKEUP_COCPU, //!< Wakeup caused by COCPU int ESP_SLEEP_WAKEUP_COCPU_TRAP_TRIG, //!< Wakeup caused by COCPU crash + ESP_SLEEP_WAKEUP_BT, //!< Wakeup caused by BT (light sleep only) } esp_sleep_source_t; /* Leave this type define for compatibility */ diff --git a/components/esp_system/include/esp_system.h b/components/esp_system/include/esp_system.h index ea3e914159..c251b41635 100644 --- a/components/esp_system/include/esp_system.h +++ b/components/esp_system/include/esp_system.h @@ -42,6 +42,8 @@ typedef enum { #define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES #elif CONFIG_IDF_TARGET_ESP32S2 #define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32S2_UNIVERSAL_MAC_ADDRESSES +#elif CONFIG_IDF_TARGET_ESP32C3 +#define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES #endif /** @endcond */ diff --git a/components/esp_system/intr_alloc.c b/components/esp_system/intr_alloc.c index d440ca9f24..22650cfc25 100644 --- a/components/esp_system/intr_alloc.c +++ b/components/esp_system/intr_alloc.c @@ -585,6 +585,13 @@ esp_err_t esp_intr_alloc_intrstatus(int source, int flags, uint32_t intrstatusre esp_intr_disable(ret); } +#if CONFIG_IDF_TARGET_ESP32C3 + // TODO ESP32-C3 IDF-2126, these need to be set or the new interrupt won't fire, but are currently hard-coded + // for priority and level... + esprv_intc_int_set_priority(intr, 1); + esprv_intc_int_set_type(BIT(intr), INTR_TYPE_LEVEL); +#endif + portEXIT_CRITICAL(&spinlock); //Fill return handle if needed, otherwise free handle. diff --git a/components/esp_system/test/test_intr_alloc.c b/components/esp_system/test/test_intr_alloc.c index 67bb6b039f..a917a79c4d 100644 --- a/components/esp_system/test/test_intr_alloc.c +++ b/components/esp_system/test/test_intr_alloc.c @@ -9,17 +9,15 @@ #include "freertos/task.h" #include "freertos/semphr.h" #include "freertos/queue.h" -#include "freertos/xtensa_api.h" #include "unity.h" #include "soc/uart_periph.h" -#include "soc/dport_reg.h" #include "soc/gpio_periph.h" #include "esp_intr_alloc.h" #include "driver/periph_ctrl.h" #include "driver/timer.h" #include "sdkconfig.h" -#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S3) +#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S3,ESP32C3) #define TIMER_DIVIDER 16 /*!< Hardware timer clock divider */ #define TIMER_SCALE (TIMER_BASE_CLK / TIMER_DIVIDER) /*!< used to calculate counter value */ diff --git a/components/esp_system/test/test_sleep.c b/components/esp_system/test/test_sleep.c index fdc438fd53..18ae86d897 100644 --- a/components/esp_system/test/test_sleep.c +++ b/components/esp_system/test/test_sleep.c @@ -19,6 +19,7 @@ #include "sdkconfig.h" #include "esp_rom_sys.h" +#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C3, ESP32S3) #if CONFIG_IDF_TARGET_ESP32 #include "esp32/clk.h" @@ -31,8 +32,6 @@ #include "esp32s3/rom/rtc.h" #endif -#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S3) - #define ESP_EXT0_WAKEUP_LEVEL_LOW 0 #define ESP_EXT0_WAKEUP_LEVEL_HIGH 1 @@ -63,7 +62,7 @@ TEST_CASE("wake up from deep sleep using timer", "[deepsleep][reset=DEEPSLEEP_RE esp_deep_sleep_start(); } -#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S2) +#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S2, ESP32C3) TEST_CASE("light sleep followed by deep sleep", "[deepsleep][reset=DEEPSLEEP_RESET]") { esp_sleep_enable_timer_wakeup(1000000); @@ -82,7 +81,7 @@ TEST_CASE("wake up from light sleep using timer", "[deepsleep]") (tv_stop.tv_usec - tv_start.tv_usec) * 1e-3f; TEST_ASSERT_INT32_WITHIN(500, 2000, (int) dt); } -#endif // !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S2) +#endif // !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S2, ESP32C3) static void test_light_sleep(void* arg) { @@ -417,7 +416,7 @@ __attribute__((unused)) static uint32_t get_cause(void) return wakeup_cause; } -#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S2) +#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S2, ESP32C3) // This test case verifies deactivation of trigger for wake up sources TEST_CASE("disable source trigger behavior", "[deepsleep]") { @@ -490,7 +489,7 @@ TEST_CASE("disable source trigger behavior", "[deepsleep]") // Disable ext0 wakeup source, as this might interfere with other tests ESP_ERROR_CHECK(esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_EXT0)); } -#endif // !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S2) +#endif // !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S2, ESP32C3) static RTC_DATA_ATTR struct timeval start; static void trigger_deepsleep(void) @@ -527,4 +526,4 @@ static void check_time_deepsleep(void) TEST_CASE_MULTIPLE_STAGES("check a time after wakeup from deep sleep", "[deepsleep][reset=DEEPSLEEP_RESET]", trigger_deepsleep, check_time_deepsleep); -#endif // #if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S3) +#endif // #if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C3, ESP32S3)