Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
Diff: targets/TARGET_NUVOTON/TARGET_NANO100/sleep.c
- Revision:
- 176:447f873cad2f
- Parent:
- 174:b96e65c34a4d
- Child:
- 188:bcfe06ba3d64
diff -r af195413fb11 -r 447f873cad2f targets/TARGET_NUVOTON/TARGET_NANO100/sleep.c
--- a/targets/TARGET_NUVOTON/TARGET_NANO100/sleep.c Wed Oct 11 12:45:49 2017 +0100
+++ b/targets/TARGET_NUVOTON/TARGET_NANO100/sleep.c Wed Oct 25 14:53:38 2017 +0100
@@ -15,8 +15,6 @@
*/
#include "sleep_api.h"
-#include "serial_api.h"
-#include "lp_ticker_api.h"
#if DEVICE_SLEEP
@@ -25,74 +23,24 @@
#include "objects.h"
#include "PeripheralPins.h"
-static void mbed_enter_sleep(struct sleep_s *obj);
-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.
*/
void hal_sleep(void)
{
- struct sleep_s sleep_obj;
- sleep_obj.powerdown = 0;
- mbed_enter_sleep(&sleep_obj);
- mbed_exit_sleep(&sleep_obj);
+ SYS_UnlockReg();
+ CLK_Idle();
+ SYS_LockReg();
}
/**
- * Enter Power-down mode while no peripheral is active; otherwise, enter Idle mode.
+ * Enter power-down mode, in which HXT/HIRC are halted.
*/
void hal_deepsleep(void)
{
- struct sleep_s sleep_obj;
- sleep_obj.powerdown = 1;
- mbed_enter_sleep(&sleep_obj);
- mbed_exit_sleep(&sleep_obj);
-}
-
-static void mbed_enter_sleep(struct sleep_s *obj)
-{
- // 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
-
- 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)
-{
- (void)obj;
+ SYS_UnlockReg();
+ CLK_PowerDown();
+ SYS_LockReg();
}
#endif


