mirror of https://github.com/ARMmbed/mbed-os.git
[M2351] Remove peripheral sleep management from hal_sleep/hal_deepsleep
The upper layer has introduced Sleep Manager to handle the task.pull/7302/head
parent
6bfc90dc73
commit
236bf657b6
|
@ -15,8 +15,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sleep_api.h"
|
#include "sleep_api.h"
|
||||||
#include "serial_api.h"
|
|
||||||
#include "lp_ticker_api.h"
|
|
||||||
|
|
||||||
#if DEVICE_SLEEP
|
#if DEVICE_SLEEP
|
||||||
|
|
||||||
|
@ -25,85 +23,29 @@
|
||||||
#include "objects.h"
|
#include "objects.h"
|
||||||
#include "PeripheralPins.h"
|
#include "PeripheralPins.h"
|
||||||
|
|
||||||
static void mbed_enter_sleep(struct sleep_s *obj);
|
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
|
||||||
static void mbed_exit_sleep(struct sleep_s *obj);
|
|
||||||
|
|
||||||
int serial_allow_powerdown(void);
|
|
||||||
int spi_allow_powerdown(void);
|
|
||||||
int i2c_allow_powerdown(void);
|
|
||||||
int pwmout_allow_powerdown(void);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter Idle mode.
|
* Enter idle mode, in which just CPU is halted.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
|
|
||||||
__attribute__((cmse_nonsecure_entry))
|
__attribute__((cmse_nonsecure_entry))
|
||||||
void hal_sleep(void)
|
void hal_sleep(void)
|
||||||
{
|
{
|
||||||
struct sleep_s sleep_obj;
|
SYS_UnlockReg();
|
||||||
sleep_obj.powerdown = 0;
|
CLK_Idle();
|
||||||
mbed_enter_sleep(&sleep_obj);
|
SYS_LockReg();
|
||||||
mbed_exit_sleep(&sleep_obj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter Power-down mode while no peripheral is active; otherwise, enter Idle mode.
|
* Enter power-down mode, in which HXT/HIRC are halted.
|
||||||
*/
|
*/
|
||||||
__attribute__((cmse_nonsecure_entry))
|
__attribute__((cmse_nonsecure_entry))
|
||||||
void hal_deepsleep(void)
|
void hal_deepsleep(void)
|
||||||
{
|
{
|
||||||
struct sleep_s sleep_obj;
|
SYS_UnlockReg();
|
||||||
sleep_obj.powerdown = 1;
|
CLK_PowerDown();
|
||||||
mbed_enter_sleep(&sleep_obj);
|
SYS_LockReg();
|
||||||
mbed_exit_sleep(&sleep_obj);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void mbed_enter_sleep(struct sleep_s *obj)
|
|
||||||
{
|
|
||||||
#if 0
|
|
||||||
// Check if serial allows entering power-down mode
|
|
||||||
if (obj->powerdown) {
|
|
||||||
obj->powerdown = serial_allow_powerdown();
|
|
||||||
}
|
|
||||||
// Check if spi allows entering power-down mode
|
|
||||||
if (obj->powerdown) {
|
|
||||||
obj->powerdown = spi_allow_powerdown();
|
|
||||||
}
|
|
||||||
// Check if i2c allows entering power-down mode
|
|
||||||
if (obj->powerdown) {
|
|
||||||
obj->powerdown = i2c_allow_powerdown();
|
|
||||||
}
|
|
||||||
// Check if pwmout allows entering power-down mode
|
|
||||||
if (obj->powerdown) {
|
|
||||||
obj->powerdown = pwmout_allow_powerdown();
|
|
||||||
}
|
|
||||||
// TODO: Check if other peripherals allow entering power-down mode
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (obj->powerdown) { // Power-down mode (HIRC/HXT disabled, LIRC/LXT enabled)
|
|
||||||
SYS_UnlockReg();
|
|
||||||
CLK_PowerDown();
|
|
||||||
SYS_LockReg();
|
|
||||||
}
|
|
||||||
else { // CPU halt mode (HIRC/HXT enabled, LIRC/LXT enabled)
|
|
||||||
SYS_UnlockReg();
|
|
||||||
CLK_Idle();
|
|
||||||
SYS_LockReg();
|
|
||||||
}
|
|
||||||
__NOP();
|
|
||||||
__NOP();
|
|
||||||
__NOP();
|
|
||||||
__NOP();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mbed_exit_sleep(struct sleep_s *obj)
|
|
||||||
{
|
|
||||||
// TODO: TO BE CONTINUED
|
|
||||||
|
|
||||||
(void)obj;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue