Merge pull request #6346 from haukepetersen/opt_pm_cortexmsleep

cpu/cortexm: added shared cortexm_sleep() function
pr/spi.typo
Kaspar Schleiser 7 years ago committed by GitHub
commit 079a6ec5f4

@ -90,6 +90,25 @@ static inline void cpu_sleep_until_event(void)
__WFE();
}
/**
* @brief Put the CPU into (deep) sleep mode, using the `WFI` instruction
*
* @param[in] deep !=0 for deep sleep, 0 for light sleep
*/
static inline void cortexm_sleep(int deep)
{
if (deep) {
SCB->SCR |= (SCB_SCR_SLEEPDEEP_Msk);
}
else {
SCB->SCR &= ~(SCB_SCR_SLEEPDEEP_Msk);
}
/* ensure that all memory accesses have completed and trigger sleeping */
__DSB();
__WFI();
}
/**
* @brief Trigger a conditional context scheduler run / context switch
*

@ -1,5 +1,6 @@
/*
* Copyright (C) 2017 Kaspar Schleiser <kaspar@schleiser.de>
* Copyright (C) 2017 Kaspar Schleiser <kaspar@schleiser.de
* 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
@ -14,22 +15,18 @@
* @brief common periph/pm functions
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*
* @}
*/
#include <stdio.h>
#include "cpu.h"
#include "periph/pm.h"
#ifndef FEATURES_PERIPH_PM
void pm_set_lowest(void)
{
/* Executes a device DSB (Data Synchronization Barrier) */
__DSB();
/* Enter standby mode */
__WFI();
cortexm_sleep(0);
}
#endif

Loading…
Cancel
Save