mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #3607 from ARMmbed/feature_hal_sleep
Platform: Add sleep/deepsleep user facing functionspull/3651/head
commit
ade6722707
|
@ -23,7 +23,7 @@
|
||||||
// In this case, bits which are equal to 0 are the bits reserved in this register
|
// In this case, bits which are equal to 0 are the bits reserved in this register
|
||||||
#define SCB_ICSR_RESERVED_BITS_MASK 0x9E43F03F
|
#define SCB_ICSR_RESERVED_BITS_MASK 0x9E43F03F
|
||||||
|
|
||||||
void sleep(void)
|
void hal_sleep(void)
|
||||||
{
|
{
|
||||||
// ensure debug is disconnected if semihost is enabled....
|
// ensure debug is disconnected if semihost is enabled....
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ void sleep(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void deepsleep(void)
|
void hal_deepsleep(void)
|
||||||
{
|
{
|
||||||
sleep();
|
sleep();
|
||||||
// NRF_POWER->SYSTEMOFF=1;
|
// NRF_POWER->SYSTEMOFF=1;
|
||||||
|
|
|
@ -41,7 +41,7 @@ extern "C" {
|
||||||
* Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
|
* Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
|
||||||
* able to access the LocalFileSystem
|
* able to access the LocalFileSystem
|
||||||
*/
|
*/
|
||||||
void sleep(void);
|
void hal_sleep(void);
|
||||||
|
|
||||||
/** Send the microcontroller to deep sleep
|
/** Send the microcontroller to deep sleep
|
||||||
*
|
*
|
||||||
|
@ -56,7 +56,7 @@ void sleep(void);
|
||||||
* Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
|
* Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
|
||||||
* able to access the LocalFileSystem
|
* able to access the LocalFileSystem
|
||||||
*/
|
*/
|
||||||
void deepsleep(void);
|
void hal_deepsleep(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
1
mbed.h
1
mbed.h
|
@ -92,6 +92,7 @@
|
||||||
#include "drivers/InterruptIn.h"
|
#include "drivers/InterruptIn.h"
|
||||||
#include "platform/wait_api.h"
|
#include "platform/wait_api.h"
|
||||||
#include "hal/sleep_api.h"
|
#include "hal/sleep_api.h"
|
||||||
|
#include "platform/sleep.h"
|
||||||
#include "platform/rtc_time.h"
|
#include "platform/rtc_time.h"
|
||||||
|
|
||||||
// mbed Non-hardware components
|
// mbed Non-hardware components
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
|
||||||
|
/** \addtogroup platform */
|
||||||
|
/** @{*/
|
||||||
|
/* mbed Microcontroller Library
|
||||||
|
* Copyright (c) 2006-2017 ARM Limited
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
#ifndef MBED_SLEEP_H
|
||||||
|
#define MBED_SLEEP_H
|
||||||
|
|
||||||
|
#include "sleep_api.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** Send the microcontroller to sleep
|
||||||
|
*
|
||||||
|
* @note This function can be a noop if not implemented by the platform.
|
||||||
|
* @note This function will only put device to sleep in release mode (small profile or when NDEBUG is defined).
|
||||||
|
*
|
||||||
|
* The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the
|
||||||
|
* system clock to the core is stopped until a reset or an interrupt occurs. This eliminates
|
||||||
|
* dynamic power used by the processor, memory systems and buses. The processor, peripheral and
|
||||||
|
* memory state are maintained, and the peripherals continue to work and can generate interrupts.
|
||||||
|
*
|
||||||
|
* The processor can be woken up by any internal peripheral interrupt or external pin interrupt.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored.
|
||||||
|
* Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
|
||||||
|
* able to access the LocalFileSystem
|
||||||
|
*/
|
||||||
|
__INLINE static void sleep(void)
|
||||||
|
{
|
||||||
|
#ifdef NDEBUG
|
||||||
|
#if DEVICE_SLEEP
|
||||||
|
hal_sleep();
|
||||||
|
#endif /* DEVICE_SLEEP */
|
||||||
|
#endif /* NDEBUG */
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Send the microcontroller to deep sleep
|
||||||
|
*
|
||||||
|
* @note This function can be a noop if not implemented by the platform.
|
||||||
|
* @note This function will only put device to sleep in release mode (small profile or when NDEBUG is defined).
|
||||||
|
*
|
||||||
|
* This processor is setup ready for deep sleep, and sent to sleep using __WFI(). This mode
|
||||||
|
* has the same sleep features as sleep plus it powers down peripherals and clocks. All state
|
||||||
|
* is still maintained.
|
||||||
|
*
|
||||||
|
* The processor can only be woken up by an external interrupt on a pin or a watchdog timer.
|
||||||
|
*
|
||||||
|
* @note
|
||||||
|
* The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored.
|
||||||
|
* Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
|
||||||
|
* able to access the LocalFileSystem
|
||||||
|
*/
|
||||||
|
__INLINE static void deepsleep(void)
|
||||||
|
{
|
||||||
|
#ifdef NDEBUG
|
||||||
|
#if DEVICE_SLEEP
|
||||||
|
hal_deepsleep();
|
||||||
|
#endif /* DEVICE_SLEEP */
|
||||||
|
#endif /* NDEBUG */
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** @}*/
|
|
@ -16,13 +16,13 @@
|
||||||
#include "sleep_api.h"
|
#include "sleep_api.h"
|
||||||
#include "cmsis.h"
|
#include "cmsis.h"
|
||||||
|
|
||||||
void sleep(void)
|
void hal_sleep(void)
|
||||||
{
|
{
|
||||||
SystemPowerSuspend(POWER_MODE_SLEEP);
|
SystemPowerSuspend(POWER_MODE_SLEEP);
|
||||||
SystemPowerResume(POWER_MODE_SLEEP);
|
SystemPowerResume(POWER_MODE_SLEEP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void deepsleep(void)
|
void hal_deepsleep(void)
|
||||||
{
|
{
|
||||||
SystemPowerSuspend(POWER_MODE_DEEP_SLEEP);
|
SystemPowerSuspend(POWER_MODE_DEEP_SLEEP);
|
||||||
SystemPowerResume(POWER_MODE_DEEP_SLEEP);
|
SystemPowerResume(POWER_MODE_DEEP_SLEEP);
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
* @param[void] void
|
* @param[void] void
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void sleep(void)
|
void hal_sleep(void)
|
||||||
{
|
{
|
||||||
#if (SAMD21) || (SAMR21)
|
#if (SAMD21) || (SAMR21)
|
||||||
system_set_sleepmode(SYSTEM_SLEEPMODE_IDLE_2);
|
system_set_sleepmode(SYSTEM_SLEEPMODE_IDLE_2);
|
||||||
|
@ -43,7 +43,7 @@ void sleep(void)
|
||||||
* @param[void] void
|
* @param[void] void
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void deepsleep(void)
|
void hal_deepsleep(void)
|
||||||
{
|
{
|
||||||
system_set_sleepmode(SYSTEM_SLEEPMODE_STANDBY);
|
system_set_sleepmode(SYSTEM_SLEEPMODE_STANDBY);
|
||||||
system_sleep();
|
system_sleep();
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
* @param[void] void
|
* @param[void] void
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void sleep(void)
|
void hal_sleep(void)
|
||||||
{
|
{
|
||||||
enum sleepmgr_mode sleep_mode;
|
enum sleepmgr_mode sleep_mode;
|
||||||
|
|
||||||
|
@ -40,10 +40,10 @@ void sleep(void)
|
||||||
* @param[void] void
|
* @param[void] void
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void deepsleep(void)
|
void hal_deepsleep(void)
|
||||||
{
|
{
|
||||||
enum sleepmgr_mode sleep_mode;
|
enum sleepmgr_mode sleep_mode;
|
||||||
|
|
||||||
sleep_mode = SLEEPMGR_SLEEP_WFE;
|
sleep_mode = SLEEPMGR_SLEEP_WFE;
|
||||||
sleepmgr_sleep(sleep_mode);
|
sleepmgr_sleep(sleep_mode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "cmsis.h"
|
#include "cmsis.h"
|
||||||
|
|
||||||
//Normal wait mode
|
//Normal wait mode
|
||||||
void sleep(void)
|
void hal_sleep(void)
|
||||||
{
|
{
|
||||||
SMC->PMPROT = SMC_PMPROT_AVLLS_MASK | SMC_PMPROT_ALLS_MASK | SMC_PMPROT_AVLP_MASK;
|
SMC->PMPROT = SMC_PMPROT_AVLLS_MASK | SMC_PMPROT_ALLS_MASK | SMC_PMPROT_AVLP_MASK;
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ void sleep(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Very low-power stop mode
|
//Very low-power stop mode
|
||||||
void deepsleep(void)
|
void hal_deepsleep(void)
|
||||||
{
|
{
|
||||||
//Check if ADC is enabled and HS mode is set, if yes disable it (lowers power consumption by 60uA)
|
//Check if ADC is enabled and HS mode is set, if yes disable it (lowers power consumption by 60uA)
|
||||||
uint8_t ADC_HSC = 0;
|
uint8_t ADC_HSC = 0;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "PeripheralPins.h"
|
#include "PeripheralPins.h"
|
||||||
|
|
||||||
//Normal wait mode
|
//Normal wait mode
|
||||||
void sleep(void)
|
void hal_sleep(void)
|
||||||
{
|
{
|
||||||
SMC->PMPROT = SMC_PMPROT_AVLLS_MASK | SMC_PMPROT_ALLS_MASK | SMC_PMPROT_AVLP_MASK;
|
SMC->PMPROT = SMC_PMPROT_AVLLS_MASK | SMC_PMPROT_ALLS_MASK | SMC_PMPROT_AVLP_MASK;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ void sleep(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Very low-power stop mode
|
//Very low-power stop mode
|
||||||
void deepsleep(void)
|
void hal_deepsleep(void)
|
||||||
{
|
{
|
||||||
//Check if ADC is enabled and HS mode is set, if yes disable it (lowers power consumption by 60uA)
|
//Check if ADC is enabled and HS mode is set, if yes disable it (lowers power consumption by 60uA)
|
||||||
uint8_t ADC_HSC = 0;
|
uint8_t ADC_HSC = 0;
|
||||||
|
|
|
@ -18,14 +18,14 @@
|
||||||
#include "fsl_smc.h"
|
#include "fsl_smc.h"
|
||||||
#include "fsl_clock_config.h"
|
#include "fsl_clock_config.h"
|
||||||
|
|
||||||
void sleep(void)
|
void hal_sleep(void)
|
||||||
{
|
{
|
||||||
SMC_SetPowerModeProtection(SMC, kSMC_AllowPowerModeAll);
|
SMC_SetPowerModeProtection(SMC, kSMC_AllowPowerModeAll);
|
||||||
|
|
||||||
SMC_SetPowerModeWait(SMC);
|
SMC_SetPowerModeWait(SMC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void deepsleep(void)
|
void hal_deepsleep(void)
|
||||||
{
|
{
|
||||||
#if (defined(FSL_FEATURE_SOC_MCG_COUNT) && FSL_FEATURE_SOC_MCG_COUNT)
|
#if (defined(FSL_FEATURE_SOC_MCG_COUNT) && FSL_FEATURE_SOC_MCG_COUNT)
|
||||||
mcg_mode_t mode = CLOCK_GetMode();
|
mcg_mode_t mode = CLOCK_GetMode();
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
static mxc_uart_regs_t *stdio_uart = (mxc_uart_regs_t*)STDIO_UART;
|
static mxc_uart_regs_t *stdio_uart = (mxc_uart_regs_t*)STDIO_UART;
|
||||||
|
|
||||||
// Normal wait mode
|
// Normal wait mode
|
||||||
void sleep(void)
|
void hal_sleep(void)
|
||||||
{
|
{
|
||||||
// Normal sleep mode for ARM core
|
// Normal sleep mode for ARM core
|
||||||
SCB->SCR = 0;
|
SCB->SCR = 0;
|
||||||
|
@ -70,7 +70,7 @@ static void clearAllGPIOWUD(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Low-power stop mode
|
// Low-power stop mode
|
||||||
void deepsleep(void)
|
void hal_deepsleep(void)
|
||||||
{
|
{
|
||||||
__disable_irq();
|
__disable_irq();
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
static mxc_uart_regs_t *stdio_uart = (mxc_uart_regs_t*)STDIO_UART;
|
static mxc_uart_regs_t *stdio_uart = (mxc_uart_regs_t*)STDIO_UART;
|
||||||
|
|
||||||
// Normal wait mode
|
// Normal wait mode
|
||||||
void sleep(void)
|
void hal_sleep(void)
|
||||||
{
|
{
|
||||||
// Normal sleep mode for ARM core
|
// Normal sleep mode for ARM core
|
||||||
SCB->SCR = 0;
|
SCB->SCR = 0;
|
||||||
|
@ -70,7 +70,7 @@ static void clearAllGPIOWUD(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Low-power stop mode
|
// Low-power stop mode
|
||||||
void deepsleep(void)
|
void hal_deepsleep(void)
|
||||||
{
|
{
|
||||||
__disable_irq();
|
__disable_irq();
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ static mxc_uart_regs_t *stdio_uart = (mxc_uart_regs_t*)STDIO_UART;
|
||||||
static int restore_usb;
|
static int restore_usb;
|
||||||
static usb_state_t usb_state;
|
static usb_state_t usb_state;
|
||||||
|
|
||||||
void sleep(void)
|
void hal_sleep(void)
|
||||||
{
|
{
|
||||||
// Normal sleep mode for ARM core
|
// Normal sleep mode for ARM core
|
||||||
SCB->SCR = 0;
|
SCB->SCR = 0;
|
||||||
|
@ -109,7 +109,7 @@ static void usb_wakeup(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Low-power stop mode
|
// Low-power stop mode
|
||||||
void deepsleep(void)
|
void hal_deepsleep(void)
|
||||||
{
|
{
|
||||||
unsigned int part_rev = MXC_PWRMAN->mask_id0 & MXC_F_PWRMAN_MASK_ID0_REVISION_ID;
|
unsigned int part_rev = MXC_PWRMAN->mask_id0 & MXC_F_PWRMAN_MASK_ID0_REVISION_ID;
|
||||||
|
|
||||||
|
|
|
@ -34,13 +34,13 @@
|
||||||
#include "sleep_api.h"
|
#include "sleep_api.h"
|
||||||
#include "lp.h"
|
#include "lp.h"
|
||||||
|
|
||||||
void sleep(void)
|
void hal_sleep(void)
|
||||||
{
|
{
|
||||||
LP_EnterLP2();
|
LP_EnterLP2();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Low-power stop mode
|
// Low-power stop mode
|
||||||
void deepsleep(void)
|
void hal_deepsleep(void)
|
||||||
{
|
{
|
||||||
sleep();
|
hal_sleep();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "mbed_interface.h"
|
#include "mbed_interface.h"
|
||||||
#include "toolchain.h"
|
#include "toolchain.h"
|
||||||
|
|
||||||
MBED_WEAK void sleep(void)
|
void hal_sleep(void)
|
||||||
{
|
{
|
||||||
// ensure debug is disconnected if semihost is enabled....
|
// ensure debug is disconnected if semihost is enabled....
|
||||||
NRF_POWER->TASKS_LOWPWR = 1;
|
NRF_POWER->TASKS_LOWPWR = 1;
|
||||||
|
@ -26,8 +26,8 @@ MBED_WEAK void sleep(void)
|
||||||
__WFE();
|
__WFE();
|
||||||
}
|
}
|
||||||
|
|
||||||
MBED_WEAK void deepsleep(void)
|
void hal_deepsleep(void)
|
||||||
{
|
{
|
||||||
sleep();
|
hal_sleep();
|
||||||
// NRF_POWER->SYSTEMOFF=1;
|
// NRF_POWER->SYSTEMOFF=1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#define FPU_EXCEPTION_MASK 0x0000009F
|
#define FPU_EXCEPTION_MASK 0x0000009F
|
||||||
|
|
||||||
void sleep(void)
|
void hal_sleep(void)
|
||||||
{
|
{
|
||||||
// ensure debug is disconnected if semihost is enabled....
|
// ensure debug is disconnected if semihost is enabled....
|
||||||
|
|
||||||
|
@ -73,8 +73,8 @@ void sleep(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void deepsleep(void)
|
void hal_deepsleep(void)
|
||||||
{
|
{
|
||||||
sleep();
|
hal_sleep();
|
||||||
// NRF_POWER->SYSTEMOFF=1;
|
// NRF_POWER->SYSTEMOFF=1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ int pwmout_allow_powerdown(void);
|
||||||
/**
|
/**
|
||||||
* Enter Idle mode.
|
* Enter Idle mode.
|
||||||
*/
|
*/
|
||||||
void sleep(void)
|
void hal_sleep(void)
|
||||||
{
|
{
|
||||||
struct sleep_s sleep_obj;
|
struct sleep_s sleep_obj;
|
||||||
sleep_obj.powerdown = 0;
|
sleep_obj.powerdown = 0;
|
||||||
|
@ -49,7 +49,7 @@ void sleep(void)
|
||||||
/**
|
/**
|
||||||
* Enter Power-down mode while no peripheral is active; otherwise, enter Idle mode.
|
* Enter Power-down mode while no peripheral is active; otherwise, enter Idle mode.
|
||||||
*/
|
*/
|
||||||
void deepsleep(void)
|
void hal_deepsleep(void)
|
||||||
{
|
{
|
||||||
struct sleep_s sleep_obj;
|
struct sleep_s sleep_obj;
|
||||||
sleep_obj.powerdown = 1;
|
sleep_obj.powerdown = 1;
|
||||||
|
|
|
@ -38,7 +38,7 @@ int pwmout_allow_powerdown(void);
|
||||||
/**
|
/**
|
||||||
* Enter Idle mode.
|
* Enter Idle mode.
|
||||||
*/
|
*/
|
||||||
void sleep(void)
|
void hal_sleep(void)
|
||||||
{
|
{
|
||||||
struct sleep_s sleep_obj;
|
struct sleep_s sleep_obj;
|
||||||
sleep_obj.powerdown = 0;
|
sleep_obj.powerdown = 0;
|
||||||
|
@ -49,7 +49,7 @@ void sleep(void)
|
||||||
/**
|
/**
|
||||||
* Enter Power-down mode while no peripheral is active; otherwise, enter Idle mode.
|
* Enter Power-down mode while no peripheral is active; otherwise, enter Idle mode.
|
||||||
*/
|
*/
|
||||||
void deepsleep(void)
|
void hal_deepsleep(void)
|
||||||
{
|
{
|
||||||
struct sleep_s sleep_obj;
|
struct sleep_s sleep_obj;
|
||||||
sleep_obj.powerdown = 1;
|
sleep_obj.powerdown = 1;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#if DEVICE_SLEEP
|
#if DEVICE_SLEEP
|
||||||
|
|
||||||
void sleep(void) {
|
void hal_sleep(void) {
|
||||||
|
|
||||||
#if (DEVICE_SEMIHOST == 1)
|
#if (DEVICE_SEMIHOST == 1)
|
||||||
// ensure debug is disconnected
|
// ensure debug is disconnected
|
||||||
|
@ -37,7 +37,7 @@ void sleep(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void deepsleep(void) {
|
void hal_deepsleep(void) {
|
||||||
|
|
||||||
#if (DEVICE_SEMIHOST == 1)
|
#if (DEVICE_SEMIHOST == 1)
|
||||||
// ensure debug is disconnected
|
// ensure debug is disconnected
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "cmsis.h"
|
#include "cmsis.h"
|
||||||
#include "mbed_interface.h"
|
#include "mbed_interface.h"
|
||||||
|
|
||||||
void sleep(void) {
|
void hal_sleep(void) {
|
||||||
// ensure debug is disconnected
|
// ensure debug is disconnected
|
||||||
#if DEVICE_SEMIHOST
|
#if DEVICE_SEMIHOST
|
||||||
mbed_interface_disconnect();
|
mbed_interface_disconnect();
|
||||||
|
@ -59,7 +59,7 @@ void sleep(void) {
|
||||||
* We treat a deepsleep() as a normal sleep().
|
* We treat a deepsleep() as a normal sleep().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void deepsleep(void) {
|
void hal_deepsleep(void) {
|
||||||
// ensure debug is disconnected
|
// ensure debug is disconnected
|
||||||
#if DEVICE_SEMIHOST
|
#if DEVICE_SEMIHOST
|
||||||
mbed_interface_disconnect();
|
mbed_interface_disconnect();
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "cmsis.h"
|
#include "cmsis.h"
|
||||||
#include "mbed_interface.h"
|
#include "mbed_interface.h"
|
||||||
|
|
||||||
void sleep(void) {
|
void hal_sleep(void) {
|
||||||
|
|
||||||
// PCON[DPDEN] set to sleep
|
// PCON[DPDEN] set to sleep
|
||||||
LPC_PMU->PCON = 0x0;
|
LPC_PMU->PCON = 0x0;
|
||||||
|
@ -29,7 +29,7 @@ void sleep(void) {
|
||||||
__WFI();
|
__WFI();
|
||||||
}
|
}
|
||||||
|
|
||||||
void deepsleep(void) {
|
void hal_deepsleep(void) {
|
||||||
|
|
||||||
// PCON[DPDEN] set to deepsleep
|
// PCON[DPDEN] set to deepsleep
|
||||||
LPC_PMU->PCON = 0;
|
LPC_PMU->PCON = 0;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "cmsis.h"
|
#include "cmsis.h"
|
||||||
#include "mbed_interface.h"
|
#include "mbed_interface.h"
|
||||||
|
|
||||||
void sleep(void) {
|
void hal_sleep(void) {
|
||||||
// PCON[PD] set to sleep
|
// PCON[PD] set to sleep
|
||||||
LPC_PMU->PCON = 0x0;
|
LPC_PMU->PCON = 0x0;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ void sleep(void) {
|
||||||
__WFI();
|
__WFI();
|
||||||
}
|
}
|
||||||
|
|
||||||
void deepsleep(void) {
|
void hal_deepsleep(void) {
|
||||||
// PCON[PD] set to deepsleep
|
// PCON[PD] set to deepsleep
|
||||||
LPC_PMU->PCON = 0x1;
|
LPC_PMU->PCON = 0x1;
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "cmsis.h"
|
#include "cmsis.h"
|
||||||
#include "mbed_interface.h"
|
#include "mbed_interface.h"
|
||||||
|
|
||||||
void sleep(void) {
|
void hal_sleep(void) {
|
||||||
|
|
||||||
#if (DEVICE_SEMIHOST == 1)
|
#if (DEVICE_SEMIHOST == 1)
|
||||||
// ensure debug is disconnected
|
// ensure debug is disconnected
|
||||||
|
@ -60,7 +60,7 @@ void sleep(void) {
|
||||||
* We treat a deepsleep() as a normal sleep().
|
* We treat a deepsleep() as a normal sleep().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void deepsleep(void) {
|
void hal_deepsleep(void) {
|
||||||
|
|
||||||
#if (DEVICE_SEMIHOST == 1)
|
#if (DEVICE_SEMIHOST == 1)
|
||||||
// ensure debug is disconnected
|
// ensure debug is disconnected
|
||||||
|
@ -68,5 +68,5 @@ void deepsleep(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// PCON[PD] set to deepsleep
|
// PCON[PD] set to deepsleep
|
||||||
sleep();
|
hal_sleep();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "cmsis.h"
|
#include "cmsis.h"
|
||||||
#include "mbed_interface.h"
|
#include "mbed_interface.h"
|
||||||
|
|
||||||
void sleep(void) {
|
void hal_sleep(void) {
|
||||||
LPC_SC->PCON = 0x0;
|
LPC_SC->PCON = 0x0;
|
||||||
|
|
||||||
// SRC[SLEEPDEEP] set to 0 = sleep
|
// SRC[SLEEPDEEP] set to 0 = sleep
|
||||||
|
@ -52,6 +52,6 @@ void sleep(void) {
|
||||||
*
|
*
|
||||||
* We treat a deepsleep() as a normal sleep().
|
* We treat a deepsleep() as a normal sleep().
|
||||||
*/
|
*/
|
||||||
void deepsleep(void) {
|
void hal_deepsleep(void) {
|
||||||
sleep();
|
hal_sleep();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "cmsis.h"
|
#include "cmsis.h"
|
||||||
#include "mbed_interface.h"
|
#include "mbed_interface.h"
|
||||||
|
|
||||||
void sleep(void) {
|
void hal_sleep(void) {
|
||||||
|
|
||||||
// SRC[SLEEPDEEP] set to 0 = sleep
|
// SRC[SLEEPDEEP] set to 0 = sleep
|
||||||
SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk;
|
SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk;
|
||||||
|
@ -31,6 +31,6 @@ void sleep(void) {
|
||||||
/*
|
/*
|
||||||
* ToDo: Implement deepsleep()
|
* ToDo: Implement deepsleep()
|
||||||
*/
|
*/
|
||||||
void deepsleep(void) {
|
void hal_deepsleep(void) {
|
||||||
sleep();
|
hal_sleep();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
//#define DEEPSLEEP
|
//#define DEEPSLEEP
|
||||||
#define POWERDOWN
|
#define POWERDOWN
|
||||||
|
|
||||||
void sleep(void) {
|
void hal_sleep(void) {
|
||||||
//Normal sleep mode for PCON:
|
//Normal sleep mode for PCON:
|
||||||
LPC_PMU->PCON &= ~0x03;
|
LPC_PMU->PCON &= ~0x03;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ void sleep(void) {
|
||||||
//Deepsleep/powerdown modes assume the device is configured to use its internal RC oscillator directly
|
//Deepsleep/powerdown modes assume the device is configured to use its internal RC oscillator directly
|
||||||
|
|
||||||
#ifdef DEEPSLEEP
|
#ifdef DEEPSLEEP
|
||||||
void deepsleep(void) {
|
void hal_deepsleep(void) {
|
||||||
//Deep sleep in PCON
|
//Deep sleep in PCON
|
||||||
LPC_PMU->PCON &= ~0x03;
|
LPC_PMU->PCON &= ~0x03;
|
||||||
LPC_PMU->PCON |= 0x01;
|
LPC_PMU->PCON |= 0x01;
|
||||||
|
@ -59,7 +59,7 @@ void deepsleep(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef POWERDOWN
|
#ifdef POWERDOWN
|
||||||
void deepsleep(void) {
|
void hal_deepsleep(void) {
|
||||||
//Powerdown in PCON
|
//Powerdown in PCON
|
||||||
LPC_PMU->PCON &= ~0x03;
|
LPC_PMU->PCON &= ~0x03;
|
||||||
LPC_PMU->PCON |= 0x02;
|
LPC_PMU->PCON |= 0x02;
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
//#define DEEPSLEEP
|
//#define DEEPSLEEP
|
||||||
#define POWERDOWN
|
#define POWERDOWN
|
||||||
|
|
||||||
void sleep(void)
|
void hal_sleep(void)
|
||||||
{
|
{
|
||||||
//Normal sleep mode for PCON:
|
//Normal sleep mode for PCON:
|
||||||
LPC_PMU->PCON &= ~0x03;
|
LPC_PMU->PCON &= ~0x03;
|
||||||
|
@ -34,7 +34,7 @@ void sleep(void)
|
||||||
|
|
||||||
// Deepsleep/powerdown modes assume the device is configured to use its internal RC oscillator directly
|
// Deepsleep/powerdown modes assume the device is configured to use its internal RC oscillator directly
|
||||||
|
|
||||||
void deepsleep(void)
|
void hal_deepsleep(void)
|
||||||
{
|
{
|
||||||
//Deep sleep in PCON
|
//Deep sleep in PCON
|
||||||
LPC_PMU->PCON &= ~0x03;
|
LPC_PMU->PCON &= ~0x03;
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#include "cmsis.h"
|
#include "cmsis.h"
|
||||||
|
|
||||||
|
|
||||||
void sleep(void)
|
void hal_sleep(void)
|
||||||
{
|
{
|
||||||
// Stop HAL systick
|
// Stop HAL systick
|
||||||
HAL_SuspendTick();
|
HAL_SuspendTick();
|
||||||
|
@ -45,7 +45,7 @@ void sleep(void)
|
||||||
HAL_ResumeTick();
|
HAL_ResumeTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
void deepsleep(void)
|
void hal_deepsleep(void)
|
||||||
{
|
{
|
||||||
// Stop HAL systick
|
// Stop HAL systick
|
||||||
HAL_SuspendTick();
|
HAL_SuspendTick();
|
||||||
|
|
|
@ -35,7 +35,7 @@ uint32_t sleep_block_counter[NUM_SLEEP_MODES] = {0};
|
||||||
* Sleep mode.
|
* Sleep mode.
|
||||||
* Enter the lowest possible sleep mode that is not blocked by ongoing activity.
|
* Enter the lowest possible sleep mode that is not blocked by ongoing activity.
|
||||||
*/
|
*/
|
||||||
void sleep(void)
|
void hal_sleep(void)
|
||||||
{
|
{
|
||||||
if (sleep_block_counter[0] > 0) {
|
if (sleep_block_counter[0] > 0) {
|
||||||
/* Blocked everything below EM0, so just return */
|
/* Blocked everything below EM0, so just return */
|
||||||
|
@ -64,7 +64,7 @@ void sleep(void)
|
||||||
* consumption as low as 1.1 μA with RTC enabled. Power-on Reset, Brown-out
|
* consumption as low as 1.1 μA with RTC enabled. Power-on Reset, Brown-out
|
||||||
* Detection and full RAM and CPU retention is also included.
|
* Detection and full RAM and CPU retention is also included.
|
||||||
*/
|
*/
|
||||||
void deepsleep(void)
|
void hal_deepsleep(void)
|
||||||
{
|
{
|
||||||
EMU_EnterEM2(true);
|
EMU_EnterEM2(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,12 +31,12 @@
|
||||||
#include "cmsis.h"
|
#include "cmsis.h"
|
||||||
#include "mbed_interface.h"
|
#include "mbed_interface.h"
|
||||||
|
|
||||||
void sleep(void)
|
void hal_sleep(void)
|
||||||
{
|
{
|
||||||
// To Do
|
// To Do
|
||||||
}
|
}
|
||||||
|
|
||||||
void deepsleep(void)
|
void hal_deepsleep(void)
|
||||||
{
|
{
|
||||||
// To Do
|
// To Do
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,14 +40,14 @@
|
||||||
* MBED API CALLS
|
* MBED API CALLS
|
||||||
* ----------------------------------------------------------------*/
|
* ----------------------------------------------------------------*/
|
||||||
|
|
||||||
void sleep(void)
|
void hal_sleep(void)
|
||||||
{
|
{
|
||||||
__DSB();
|
__DSB();
|
||||||
__WFI();
|
__WFI();
|
||||||
__ISB();
|
__ISB();
|
||||||
}
|
}
|
||||||
|
|
||||||
void deepsleep()
|
void hal_deepsleep()
|
||||||
{
|
{
|
||||||
sleep();
|
hal_sleep();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue