soc: stm32c0: add poweroff mode

Add poweroff mode support for STM32C0
Fixes #73371

Signed-off-by: Romain Pelletant <romainp@kickmaker.net>
This commit is contained in:
Romain Pelletant 2024-05-27 23:22:14 +02:00 committed by Henrik Brix Andersen
commit 202c16008f
3 changed files with 24 additions and 0 deletions

View file

@ -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 "")

View file

@ -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

View file

@ -0,0 +1,21 @@
/*
* Copyright (c) 2024 Kickmaker
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/kernel.h>
#include <zephyr/sys/poweroff.h>
#include <zephyr/toolchain.h>
#include <stm32_ll_cortex.h>
#include <stm32_ll_pwr.h>
void z_sys_poweroff(void)
{
LL_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN);
LL_LPM_EnableDeepSleep();
k_cpu_idle();
CODE_UNREACHABLE;
}