Fix hal_deepsleep with serial_can_deep_sleep

Add secure functions CLK_PowerDown_S/CLK_Idle_S
pull/8479/head
ccli8 2018-09-03 09:42:16 +08:00 committed by adbridge
parent bb3875049c
commit 0faad50f2c
3 changed files with 32 additions and 5 deletions

View File

@ -197,6 +197,18 @@ void SYS_UnlockReg_S(void)
SYS_UnlockReg();
}
__NONSECURE_ENTRY
void CLK_Idle_S(void)
{
CLK_Idle();
}
__NONSECURE_ENTRY
void CLK_PowerDown_S(void)
{
CLK_PowerDown();
}
static bool check_mod_ns(int modclass, uint32_t modidx)
{
const nu_modidx_ns_t *modidx_ns = modidx_ns_tab;

View File

@ -71,6 +71,14 @@ void SYS_LockReg_S(void);
__NONSECURE_ENTRY
void SYS_UnlockReg_S(void);
/* Secure CLK_Idle */
__NONSECURE_ENTRY
void CLK_Idle_S(void);
/* Secure CLK_PowerDown */
__NONSECURE_ENTRY
void CLK_PowerDown_S(void);
#ifdef __cplusplus
}
#endif

View File

@ -24,8 +24,6 @@
#include "PeripheralPins.h"
#include <stdbool.h>
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
#if DEVICE_SERIAL
bool serial_can_deep_sleep(void);
#endif
@ -33,18 +31,22 @@ bool serial_can_deep_sleep(void);
/**
* Enter idle mode, in which just CPU is halted.
*/
__NONSECURE_ENTRY
void hal_sleep(void)
{
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
SYS_UnlockReg();
CLK_Idle();
SYS_LockReg();
#else
SYS_UnlockReg_S();
CLK_Idle_S();
SYS_LockReg_S();
#endif
}
/**
* Enter power-down mode, in which HXT/HIRC are halted.
*/
__NONSECURE_ENTRY
void hal_deepsleep(void)
{
#if DEVICE_SERIAL
@ -53,10 +55,15 @@ void hal_deepsleep(void)
}
#endif
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
SYS_UnlockReg();
CLK_PowerDown();
SYS_LockReg();
#else
SYS_UnlockReg_S();
CLK_PowerDown_S();
SYS_LockReg_S();
#endif
}
#endif
#endif