mbed library sources. Supersedes mbed-src.
Fork of mbed-dev by
Diff: targets/TARGET_NUVOTON/TARGET_M451/sleep.c
- Revision:
- 159:612c381a210f
- Parent:
- 149:156823d33999
- Child:
- 160:d5399cc887bb
diff -r b23ee177fd68 -r 612c381a210f targets/TARGET_NUVOTON/TARGET_M451/sleep.c --- a/targets/TARGET_NUVOTON/TARGET_M451/sleep.c Tue Feb 14 14:44:10 2017 +0000 +++ b/targets/TARGET_NUVOTON/TARGET_M451/sleep.c Tue Feb 28 17:13:35 2017 +0000 @@ -25,8 +25,6 @@ #include "objects.h" #include "PeripheralPins.h" -void us_ticker_prepare_sleep(struct sleep_s *obj); -void us_ticker_wakeup_from_sleep(struct sleep_s *obj); static void mbed_enter_sleep(struct sleep_s *obj); static void mbed_exit_sleep(struct sleep_s *obj); @@ -57,8 +55,7 @@ mbed_exit_sleep(&sleep_obj); } - -void mbed_enter_sleep(struct sleep_s *obj) +static void mbed_enter_sleep(struct sleep_s *obj) { // Check if serial allows entering power-down mode if (obj->powerdown) { @@ -77,16 +74,7 @@ obj->powerdown = pwmout_allow_powerdown(); } // TODO: Check if other peripherals allow entering power-down mode - - obj->start_us = lp_ticker_read(); - // Let us_ticker prepare for power-down or reject it. - us_ticker_prepare_sleep(obj); - - // NOTE(STALE): To pass mbed-drivers test, timer requires to be fine-grained, so its implementation needs HIRC rather than LIRC/LXT as its clock source. - // But as CLK_PowerDown()/CLK_Idle() is called, HIRC will be disabled and timer cannot keep counting and alarm. To overcome the dilemma, - // just make CPU halt and compromise power saving. - // NOTE: As CLK_PowerDown()/CLK_Idle() is called, HIRC/HXT will be disabled in normal mode, but not in ICE mode. This may cause confusion in development. - + if (obj->powerdown) { // Power-down mode (HIRC/HXT disabled, LIRC/LXT enabled) SYS_UnlockReg(); CLK_PowerDown(); @@ -101,14 +89,9 @@ __NOP(); __NOP(); __NOP(); - - obj->end_us = lp_ticker_read(); - obj->period_us = (obj->end_us > obj->start_us) ? (obj->end_us - obj->start_us) : (uint32_t) ((uint64_t) obj->end_us + 0xFFFFFFFFu - obj->start_us); - // Let us_ticker recover from power-down. - us_ticker_wakeup_from_sleep(obj); } -void mbed_exit_sleep(struct sleep_s *obj) +static void mbed_exit_sleep(struct sleep_s *obj) { // TODO: TO BE CONTINUED