3#if defined(USE_ESP32) && (SOC_RISCV_COPROC_SUPPORTED || SOC_LP_CORE_SUPPORTED)
10#if SOC_RISCV_COPROC_SUPPORTED
14extern const uint8_t ULP_MAIN_BIN_START[]
asm(
"_binary_ulp_main_bin_start");
15extern const size_t ULP_MAIN_BIN_LENGTH
asm(
"ulp_main_bin_length");
24static RTC_DATA_ATTR
bool s_program_loaded =
false;
26#if SOC_RISCV_COPROC_SUPPORTED
27static constexpr const char *BACKEND =
"ULP RISC-V";
29static constexpr const char *BACKEND =
"LP core";
33 if (esp_sleep_get_wakeup_cause() == ESP_SLEEP_WAKEUP_ULP) {
34 ESP_LOGI(TAG,
"Woken from deep sleep by the %s", BACKEND);
36#if SOC_RISCV_COPROC_SUPPORTED
40 ESP_LOGE(TAG,
"ulp_set_wakeup_period failed: %s", esp_err_to_name(err));
48 if (esp_reset_reason() == ESP_RST_DEEPSLEEP && s_program_loaded) {
55 esp_err_t err = esp_sleep_enable_ulp_wakeup();
57 ESP_LOGW(TAG,
"esp_sleep_enable_ulp_wakeup failed: %s", esp_err_to_name(err));
66 " Program size: %u bytes\n"
67 " Wakeup period: %" PRIu32
" us\n"
69 " Wakeup from sleep: %s\n"
76 const size_t size = ULP_MAIN_BIN_LENGTH;
77#if SOC_RISCV_COPROC_SUPPORTED
81 esp_err_t err = ulp_riscv_load_binary(ULP_MAIN_BIN_START,
size);
83 esp_err_t err = ulp_lp_core_load_binary(ULP_MAIN_BIN_START,
size);
86 ESP_LOGE(TAG,
"Loading the program failed: %s", esp_err_to_name(err));
93 s_program_loaded =
true;
94 ESP_LOGD(TAG,
"Loaded and started %u byte program",
static_cast<unsigned>(
size));
99#if SOC_RISCV_COPROC_SUPPORTED
100 esp_err_t err = ulp_riscv_run();
102 ulp_lp_core_cfg_t cfg = {};
105 esp_err_t err = ulp_lp_core_run(&cfg);
108 ESP_LOGE(TAG,
"Starting the program failed: %s", esp_err_to_name(err));
115#if SOC_RISCV_COPROC_SUPPORTED
116 ulp_riscv_timer_stop();
126#if SOC_RISCV_COPROC_SUPPORTED
127 ulp_riscv_timer_resume();
void mark_failed()
Mark this component as failed.
void timer_resume()
Resume the coprocessor timer.
bool load_and_run()
Load the embedded program into the coprocessor memory and start it.
void timer_stop()
Stop the coprocessor timer so the program is not started again.
void dump_config() override
uint32_t wakeup_period_us_
ESPHOME_LOG_TAG(TAG, "esp32_ulp")