1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu/nrf5x_common/periph/pm.c
Dylan Laduranty 7aa7e7954e cpu/nrf5x: implement pm_off() for nRF53/9160
Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
2024-04-18 13:33:36 +02:00

49 lines
1.3 KiB
C

/*
* Copyright (C) 2017 Kaspar Schleiser <kaspar@schleiser.de>
* 2014-2017 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup cpu_nrf5x_common
* @ingroup drivers_periph_pm
* @{
*
* @file
* @brief NRF5x specific power management implementations
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*
* @}
*/
#include "cpu.h"
#ifdef NRF_POWER_S
#define NRF_POWER NRF_POWER_S
#endif
/* Workaround inconsistency between nRF9160 / nRF53 headers */
#ifdef REGULATORS_SYSTEMOFF_SYSTEMOFF_Enable
#define REGULATORS_SYSTEMOFF_SYSTEMOFF_Enter REGULATORS_SYSTEMOFF_SYSTEMOFF_Enable
#endif
void pm_off(void)
{
#if defined(REGULATORS_SYSTEMOFF_SYSTEMOFF_Enter)
NRF_REGULATORS_S->SYSTEMOFF = REGULATORS_SYSTEMOFF_SYSTEMOFF_Enter;
#elif defined(CPU_FAM_NRF51)
NRF_POWER->RAMON = 0;
#else
for (unsigned int i = 0; i < ARRAY_SIZE(NRF_POWER->RAM); i++) {
NRF_POWER->RAM[i].POWERCLR = (POWER_RAM_POWERCLR_S1RETENTION_Msk |
POWER_RAM_POWERCLR_S0RETENTION_Msk);
}
#endif
while (1) {}
}