Nuvoton
/
NuMaker-mbed-tickless-example
NuMaker tickless example
Diff: wakeup_pwrctl.cpp
- Revision:
- 10:d2e2c79389e1
- Parent:
- 1:eb1da9d36e12
- Child:
- 20:759aab916d47
--- a/wakeup_pwrctl.cpp Thu Oct 26 17:44:48 2017 +0800 +++ b/wakeup_pwrctl.cpp Mon Oct 02 11:24:10 2017 +0800 @@ -1,6 +1,31 @@ #include "mbed.h" #include "wakeup.h" + +#if defined(TARGET_NUMAKER_PFM_NANO130) +/* Power-down wake-up interrupt handler */ +/* This target doesn't support relocating vector table and requires overriding + * vector handler at link-time. */ +extern "C" void PDWU_IRQHandler(void) +{ + CLK->WK_INTSTS = CLK_WK_INTSTS_PD_WK_IS_Msk; + + wakeup_eventflags.set(EventFlag_Wakeup_UnID); +} + +void config_pwrctl(void) +{ + SYS_UnlockReg(); + CLK->PWRCTL |= CLK_PWRCTL_PD_WK_IE_Msk; + SYS_LockReg(); + /* NOTE: The name of symbol PDWU_IRQHandler is mangled in C++ and cannot override that in startup file in C. + * So the NVIC_SetVector call cannot be left out. */ + NVIC_SetVector(PDWU_IRQn, (uint32_t) PDWU_IRQHandler); + NVIC_EnableIRQ(PDWU_IRQn); +} + +#else + /* Power-down wake-up interrupt handler */ void PWRWU_IRQHandler(void) { @@ -19,3 +44,5 @@ NVIC_SetVector(PWRWU_IRQn, (uint32_t) PWRWU_IRQHandler); NVIC_EnableIRQ(PWRWU_IRQn); } + +#endif