diff --git a/soc/st/stm32/stm32c0x/CMakeLists.txt b/soc/st/stm32/stm32c0x/CMakeLists.txt index eebd281cd96..8065e36bf13 100644 --- a/soc/st/stm32/stm32c0x/CMakeLists.txt +++ b/soc/st/stm32/stm32c0x/CMakeLists.txt @@ -5,6 +5,8 @@ zephyr_sources( soc.c ) +zephyr_sources_ifdef(CONFIG_POWEROFF poweroff.c) + zephyr_include_directories(.) set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_m/scripts/linker.ld CACHE INTERNAL "") diff --git a/soc/st/stm32/stm32c0x/Kconfig b/soc/st/stm32/stm32c0x/Kconfig index 8d8c1b89d18..d24fdd311d8 100644 --- a/soc/st/stm32/stm32c0x/Kconfig +++ b/soc/st/stm32/stm32c0x/Kconfig @@ -10,3 +10,4 @@ config SOC_SERIES_STM32C0X select CPU_HAS_ARM_MPU select HAS_STM32CUBE select CPU_CORTEX_M_HAS_SYSTICK + select HAS_POWEROFF diff --git a/soc/st/stm32/stm32c0x/poweroff.c b/soc/st/stm32/stm32c0x/poweroff.c new file mode 100644 index 00000000000..c9c4db49e9d --- /dev/null +++ b/soc/st/stm32/stm32c0x/poweroff.c @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 Kickmaker + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include + +#include +#include + +void z_sys_poweroff(void) +{ + LL_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN); + LL_LPM_EnableDeepSleep(); + + k_cpu_idle(); + + CODE_UNREACHABLE; +}