File tree Expand file tree Collapse file tree 4 files changed +64
-0
lines changed Expand file tree Collapse file tree 4 files changed +64
-0
lines changed Original file line number Diff line number Diff line change @@ -10,3 +10,6 @@ zephyr_sources(
1010zephyr_include_directories(.)
1111
1212zephyr_sources_ifndef(CONFIG_BOOTLOADER_MCUBOOT hw_init.c)
13+
14+ zephyr_library_sources_ifdef(CONFIG_PM power.c)
15+ zephyr_library_sources_ifdef(CONFIG_POWEROFF poweroff.c)
Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ config SOC_SERIES_ESP32C2
1212 select RISCV_ISA_EXT_C
1313 select RISCV_ISA_EXT_ZICSR
1414 select HAS_ESPRESSIF_HAL
15+ select HAS_PM
16+ select HAS_POWEROFF
1517
1618if SOC_SERIES_ESP32C2
1719
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
3+ *
4+ * SPDX-License-Identifier: Apache-2.0
5+ */
6+
7+ #include <zephyr/pm/pm.h>
8+ #include <zephyr/irq.h>
9+ #include <esp_sleep.h>
10+
11+ #include <zephyr/logging/log.h>
12+ LOG_MODULE_DECLARE (soc , CONFIG_SOC_LOG_LEVEL );
13+
14+ /* Invoke Low Power/System Off specific Tasks */
15+ void pm_state_set (enum pm_state state , uint8_t substate_id )
16+ {
17+ ARG_UNUSED (substate_id );
18+
19+ switch (state ) {
20+ case PM_STATE_STANDBY :
21+ /* Nothing to do. */
22+ break ;
23+ default :
24+ LOG_DBG ("Unsupported power state %u" , state );
25+ break ;
26+ }
27+ }
28+
29+ /* Handle SOC specific activity after Low Power Mode Exit */
30+ void pm_state_exit_post_ops (enum pm_state state , uint8_t substate_id )
31+ {
32+ ARG_UNUSED (substate_id );
33+
34+ switch (state ) {
35+ case PM_STATE_STANDBY :
36+ irq_unlock (MSTATUS_IEN );
37+ __asm__ volatile ("wfi" );
38+ esp_light_sleep_start ();
39+ break ;
40+ default :
41+ LOG_DBG ("Unsupported power state %u" , state );
42+ break ;
43+ }
44+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
3+ * SPDX-License-Identifier: Apache-2.0
4+ */
5+
6+ #include <zephyr/sys/poweroff.h>
7+
8+ #include <esp_sleep.h>
9+
10+ void z_sys_poweroff (void )
11+ {
12+ /* Forces RTC domain to be always on */
13+ esp_sleep_pd_config (ESP_PD_DOMAIN_XTAL , ESP_PD_OPTION_ON );
14+ esp_deep_sleep_start ();
15+ }
You can’t perform that action at this time.
0 commit comments