Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

cpu/nrf5x: implement pm_off() for nRF53/9160 #20590

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions cpu/nrf5x_common/periph/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
}
Loading