Skip to content

Commit 0550de7

Browse files
committed
[M2351] Fix hal_deepsleep with serial_can_deep_sleep
Add secure functions CLK_PowerDown_S/CLK_Idle_S
1 parent beb04a8 commit 0550de7

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

targets/TARGET_NUVOTON/TARGET_M2351/device/stddriver_secure.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,18 @@ void SYS_UnlockReg_S(void)
197197
SYS_UnlockReg();
198198
}
199199

200+
__NONSECURE_ENTRY
201+
void CLK_Idle_S(void)
202+
{
203+
CLK_Idle();
204+
}
205+
206+
__NONSECURE_ENTRY
207+
void CLK_PowerDown_S(void)
208+
{
209+
CLK_PowerDown();
210+
}
211+
200212
static bool check_mod_ns(int modclass, uint32_t modidx)
201213
{
202214
const nu_modidx_ns_t *modidx_ns = modidx_ns_tab;

targets/TARGET_NUVOTON/TARGET_M2351/device/stddriver_secure.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ void SYS_LockReg_S(void);
7171
__NONSECURE_ENTRY
7272
void SYS_UnlockReg_S(void);
7373

74+
/* Secure CLK_Idle */
75+
__NONSECURE_ENTRY
76+
void CLK_Idle_S(void);
77+
78+
/* Secure CLK_PowerDown */
79+
__NONSECURE_ENTRY
80+
void CLK_PowerDown_S(void);
81+
7482
#ifdef __cplusplus
7583
}
7684
#endif

targets/TARGET_NUVOTON/TARGET_M2351/sleep.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,29 @@
2424
#include "PeripheralPins.h"
2525
#include <stdbool.h>
2626

27-
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
28-
2927
#if DEVICE_SERIAL
3028
bool serial_can_deep_sleep(void);
3129
#endif
3230

3331
/**
3432
* Enter idle mode, in which just CPU is halted.
3533
*/
36-
__NONSECURE_ENTRY
3734
void hal_sleep(void)
3835
{
36+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
3937
SYS_UnlockReg();
4038
CLK_Idle();
4139
SYS_LockReg();
40+
#else
41+
SYS_UnlockReg_S();
42+
CLK_Idle_S();
43+
SYS_LockReg_S();
44+
#endif
4245
}
4346

4447
/**
4548
* Enter power-down mode, in which HXT/HIRC are halted.
4649
*/
47-
__NONSECURE_ENTRY
4850
void hal_deepsleep(void)
4951
{
5052
#if DEVICE_SERIAL
@@ -53,10 +55,15 @@ void hal_deepsleep(void)
5355
}
5456
#endif
5557

58+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
5659
SYS_UnlockReg();
5760
CLK_PowerDown();
5861
SYS_LockReg();
62+
#else
63+
SYS_UnlockReg_S();
64+
CLK_PowerDown_S();
65+
SYS_LockReg_S();
66+
#endif
5967
}
6068

6169
#endif
62-
#endif

0 commit comments

Comments
 (0)