1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #20590 from dylad/pr/cpu/nrf53/pm_off

cpu/nrf5x: implement pm_off() for nRF53/9160
This commit is contained in:
Dylan Laduranty 2024-04-18 14:06:07 +00:00 committed by GitHub
commit c4157585e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -27,19 +27,22 @@
#define NRF_POWER NRF_POWER_S
#endif
/* TODO: implement proper pm_off for nRF9160 */
/* 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(CPU_FAM_NRF9160) && !defined(CPU_FAM_NRF53))
#ifdef CPU_FAM_NRF51
#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 (int i = 0; i < 8; i++) {
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
NRF_POWER->SYSTEMOFF = 1;
while (1) {}
#endif /* ndef CPU_FAM_NRF9160 */
}