soc: stm32g0x: add poweroff implementation
Same implementation as stm32c0x and stm32l4x. This is required for wake-up from sleep. Signed-off-by: Martin Jäger <martin@libre.solar>
This commit is contained in:
parent
d65149e210
commit
bb0e580be4
3 changed files with 36 additions and 3 deletions
|
@ -6,9 +6,8 @@ zephyr_sources(
|
|||
soc.c
|
||||
)
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_PM
|
||||
power.c
|
||||
)
|
||||
zephyr_sources_ifdef(CONFIG_PM power.c)
|
||||
zephyr_sources_ifdef(CONFIG_POWEROFF poweroff.c)
|
||||
|
||||
zephyr_include_directories(.)
|
||||
|
||||
|
|
|
@ -12,4 +12,5 @@ config SOC_SERIES_STM32G0X
|
|||
select HAS_STM32CUBE
|
||||
select CPU_CORTEX_M_HAS_SYSTICK
|
||||
select HAS_PM
|
||||
select HAS_POWEROFF
|
||||
select SOC_EARLY_INIT_HOOK
|
||||
|
|
33
soc/st/stm32/stm32g0x/poweroff.c
Normal file
33
soc/st/stm32/stm32g0x/poweroff.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Nordic Semiconductor ASA
|
||||
* Copyright (c) 2024 STMicroelectronics
|
||||
* Copyright (c) 2025 A Labs GmbH
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/sys/poweroff.h>
|
||||
#include <zephyr/toolchain.h>
|
||||
#include <zephyr/drivers/misc/stm32_wkup_pins/stm32_wkup_pins.h>
|
||||
|
||||
#include <stm32_ll_cortex.h>
|
||||
#include <stm32_ll_pwr.h>
|
||||
#include <stm32_ll_system.h>
|
||||
|
||||
void z_sys_poweroff(void)
|
||||
{
|
||||
#ifdef CONFIG_STM32_WKUP_PINS
|
||||
stm32_pwr_wkup_pin_cfg_pupd();
|
||||
|
||||
LL_PWR_ClearFlag_WU();
|
||||
#endif /* CONFIG_STM32_WKUP_PINS */
|
||||
|
||||
LL_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN);
|
||||
LL_LPM_EnableDeepSleep();
|
||||
LL_DBGMCU_DisableDBGStandbyMode();
|
||||
|
||||
k_cpu_idle();
|
||||
|
||||
CODE_UNREACHABLE;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue