mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-25 14:33:52 +01:00
Merge pull request #13751 from benpicco/sam0-pm
cpu/sam0_common: fix handling of PM_NUM_MODES
This commit is contained in:
commit
4eb9b9b9df
@ -96,17 +96,6 @@ enum {
|
||||
*/
|
||||
#define GPIO_MODE(pr, ie, pe) (pr | (ie << 1) | (pe << 2))
|
||||
|
||||
/**
|
||||
* @name Power mode configuration
|
||||
* @{
|
||||
*/
|
||||
#ifdef CPU_SAML1X
|
||||
#define PM_NUM_MODES (2)
|
||||
#else
|
||||
#define PM_NUM_MODES (3)
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
#ifndef DOXYGEN
|
||||
/**
|
||||
* @brief Override GPIO modes
|
||||
|
||||
@ -28,6 +28,13 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name Power mode configuration
|
||||
* @{
|
||||
*/
|
||||
#define PM_NUM_MODES (3)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Override the default initial PM blocker
|
||||
* @todo Idle modes are enabled by default, deep sleep mode blocked
|
||||
|
||||
@ -43,6 +43,13 @@ extern "C" {
|
||||
*/
|
||||
#define SAM0_DPLL_FREQ_MAX_HZ (200000000U)
|
||||
|
||||
/**
|
||||
* @name Power mode configuration
|
||||
* @{
|
||||
*/
|
||||
#define PM_NUM_MODES (3)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name SAMD5x GCLK definitions
|
||||
* @{
|
||||
|
||||
@ -26,6 +26,13 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name Power mode configuration
|
||||
* @{
|
||||
*/
|
||||
#define PM_NUM_MODES (1)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Override the default initial PM blocker
|
||||
* @todo Idle modes are enabled by default, deep sleep mode blocked
|
||||
|
||||
@ -26,26 +26,24 @@
|
||||
|
||||
void pm_set(unsigned mode)
|
||||
{
|
||||
if (mode < PM_NUM_MODES) {
|
||||
uint32_t _mode;
|
||||
uint32_t _mode;
|
||||
|
||||
switch (mode) {
|
||||
case 0:
|
||||
DEBUG_PUTS("pm_set(): setting STANDBY mode.");
|
||||
_mode = PM_SLEEPCFG_SLEEPMODE_STANDBY;
|
||||
break;
|
||||
default: /* Falls through */
|
||||
case 1:
|
||||
DEBUG_PUTS("pm_set(): setting IDLE mode.");
|
||||
_mode = PM_SLEEPCFG_SLEEPMODE_IDLE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* write sleep configuration */
|
||||
PM->SLEEPCFG.bit.SLEEPMODE = _mode;
|
||||
/* make sure value has been set */
|
||||
while (PM->SLEEPCFG.bit.SLEEPMODE != _mode) {}
|
||||
switch (mode) {
|
||||
case 0:
|
||||
DEBUG_PUTS("pm_set(): setting STANDBY mode.");
|
||||
_mode = PM_SLEEPCFG_SLEEPMODE_STANDBY;
|
||||
break;
|
||||
default: /* Falls through */
|
||||
case 1:
|
||||
DEBUG_PUTS("pm_set(): setting IDLE mode.");
|
||||
_mode = PM_SLEEPCFG_SLEEPMODE_IDLE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* write sleep configuration */
|
||||
PM->SLEEPCFG.bit.SLEEPMODE = _mode;
|
||||
/* make sure value has been set */
|
||||
while (PM->SLEEPCFG.bit.SLEEPMODE != _mode) {}
|
||||
|
||||
sam0_cortexm_sleep(0);
|
||||
}
|
||||
|
||||
@ -31,6 +31,13 @@ extern "C" {
|
||||
*/
|
||||
#define CPU_BACKUP_RAM_NOT_RETAINED (1)
|
||||
|
||||
/**
|
||||
* @name Power mode configuration
|
||||
* @{
|
||||
*/
|
||||
#define PM_NUM_MODES (2)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name SAML21 GCLK definitions
|
||||
* @{
|
||||
|
||||
@ -26,34 +26,32 @@
|
||||
|
||||
void pm_set(unsigned mode)
|
||||
{
|
||||
if (mode < PM_NUM_MODES) {
|
||||
uint32_t _mode;
|
||||
uint32_t _mode;
|
||||
|
||||
switch (mode) {
|
||||
case 0:
|
||||
DEBUG_PUTS("pm_set(): setting BACKUP mode.");
|
||||
_mode = PM_SLEEPCFG_SLEEPMODE_BACKUP;
|
||||
break;
|
||||
case 1:
|
||||
DEBUG_PUTS("pm_set(): setting STANDBY mode.");
|
||||
_mode = PM_SLEEPCFG_SLEEPMODE_STANDBY;
|
||||
break;
|
||||
default: /* Falls through */
|
||||
case 2:
|
||||
DEBUG_PUTS("pm_set(): setting IDLE mode.");
|
||||
switch (mode) {
|
||||
case 0:
|
||||
DEBUG_PUTS("pm_set(): setting BACKUP mode.");
|
||||
_mode = PM_SLEEPCFG_SLEEPMODE_BACKUP;
|
||||
break;
|
||||
case 1:
|
||||
DEBUG_PUTS("pm_set(): setting STANDBY mode.");
|
||||
_mode = PM_SLEEPCFG_SLEEPMODE_STANDBY;
|
||||
break;
|
||||
default: /* Falls through */
|
||||
case 2:
|
||||
DEBUG_PUTS("pm_set(): setting IDLE mode.");
|
||||
#if !defined(PM_SLEEPCFG_SLEEPMODE_IDLE2)
|
||||
_mode = PM_SLEEPCFG_SLEEPMODE_IDLE;
|
||||
_mode = PM_SLEEPCFG_SLEEPMODE_IDLE;
|
||||
#else
|
||||
_mode = PM_SLEEPCFG_SLEEPMODE_IDLE2;
|
||||
_mode = PM_SLEEPCFG_SLEEPMODE_IDLE2;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
/* write sleep configuration */
|
||||
PM->SLEEPCFG.bit.SLEEPMODE = _mode;
|
||||
/* make sure value has been set */
|
||||
while (PM->SLEEPCFG.bit.SLEEPMODE != _mode) {}
|
||||
break;
|
||||
}
|
||||
|
||||
/* write sleep configuration */
|
||||
PM->SLEEPCFG.bit.SLEEPMODE = _mode;
|
||||
/* make sure value has been set */
|
||||
while (PM->SLEEPCFG.bit.SLEEPMODE != _mode) {}
|
||||
|
||||
sam0_cortexm_sleep(0);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user