NuMaker tickless example

Committer:
ccli8
Date:
Fri Feb 21 11:19:30 2020 +0800
Revision:
16:ed2c228cbc9c
Parent:
10:d2e2c79389e1
Child:
18:e236110ce841
Update to mbed-os 5.15.1 and accompanying modifications

1. Remove OS_IDLE_THREAD_STACK_SIZE because mbed-os has has reasonable default value.
2. Configure tickless-from-us-ticker to false. It is needed to run tickless mode with lp_ticker instead of us_ticker for wake-up.
3. Disable WDT wake-up when Mbed OS watchog API is enabled.
4. Fix deprecated API.
5. Update readme.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ccli8 16:ed2c228cbc9c 1 /* Avoid conflict with Mbed OS watchdog API
ccli8 16:ed2c228cbc9c 2 *
ccli8 16:ed2c228cbc9c 3 * Mbed OS has defined watchdog API. To avoid conflict, disable this code when target has implemented Mbed OS watchdog API.
ccli8 16:ed2c228cbc9c 4 */
ccli8 16:ed2c228cbc9c 5 #if !defined(DEVICE_WATCHDOG) || !DEVICE_WATCHDOG
ccli8 16:ed2c228cbc9c 6
ccli8 1:eb1da9d36e12 7 #include "mbed.h"
ccli8 1:eb1da9d36e12 8 #include "wakeup.h"
ccli8 16:ed2c228cbc9c 9
ccli8 10:d2e2c79389e1 10 #if defined(TARGET_NUMAKER_PFM_NANO130)
ccli8 10:d2e2c79389e1 11 /* This target doesn't support relocating vector table and requires overriding
ccli8 10:d2e2c79389e1 12 * vector handler at link-time. */
ccli8 10:d2e2c79389e1 13 extern "C" void WDT_IRQHandler(void)
ccli8 10:d2e2c79389e1 14 #else
ccli8 1:eb1da9d36e12 15 void WDT_IRQHandler(void)
ccli8 10:d2e2c79389e1 16 #endif
ccli8 1:eb1da9d36e12 17 {
ccli8 1:eb1da9d36e12 18 /* Check WDT interrupt flag */
ccli8 1:eb1da9d36e12 19 if (WDT_GET_TIMEOUT_INT_FLAG()) {
ccli8 1:eb1da9d36e12 20 WDT_CLEAR_TIMEOUT_INT_FLAG();
ccli8 1:eb1da9d36e12 21 WDT_RESET_COUNTER();
ccli8 1:eb1da9d36e12 22 }
ccli8 1:eb1da9d36e12 23
ccli8 1:eb1da9d36e12 24 // Check WDT wake-up flag
ccli8 1:eb1da9d36e12 25 if (WDT_GET_TIMEOUT_WAKEUP_FLAG()) {
ccli8 1:eb1da9d36e12 26 WDT_CLEAR_TIMEOUT_WAKEUP_FLAG();
ccli8 1:eb1da9d36e12 27
ccli8 1:eb1da9d36e12 28 wakeup_eventflags.set(EventFlag_Wakeup_WDT_Timeout);
ccli8 1:eb1da9d36e12 29 }
ccli8 1:eb1da9d36e12 30 }
ccli8 1:eb1da9d36e12 31
ccli8 1:eb1da9d36e12 32 void config_wdt_wakeup()
ccli8 1:eb1da9d36e12 33 {
ccli8 1:eb1da9d36e12 34 /* Enable IP module clock */
ccli8 1:eb1da9d36e12 35 CLK_EnableModuleClock(WDT_MODULE);
ccli8 1:eb1da9d36e12 36
ccli8 1:eb1da9d36e12 37 /* Select IP clock source */
ccli8 10:d2e2c79389e1 38 #if defined(TARGET_NUMAKER_PFM_NANO130)
ccli8 10:d2e2c79389e1 39 CLK_SetModuleClock(WDT_MODULE, 0, 0);
ccli8 10:d2e2c79389e1 40 #else
ccli8 1:eb1da9d36e12 41 CLK_SetModuleClock(WDT_MODULE, CLK_CLKSEL1_WDTSEL_LIRC, 0);
ccli8 10:d2e2c79389e1 42 #endif
ccli8 1:eb1da9d36e12 43
ccli8 1:eb1da9d36e12 44 SYS_UnlockReg();
ccli8 1:eb1da9d36e12 45 /* Alarm every 2^14 LIRC clocks, disable system reset, enable system wake-up */
ccli8 1:eb1da9d36e12 46 WDT_Open(WDT_TIMEOUT_2POW14, 0, FALSE, TRUE);
ccli8 1:eb1da9d36e12 47 SYS_LockReg();
ccli8 10:d2e2c79389e1 48
ccli8 1:eb1da9d36e12 49 /* NOTE: The name of symbol WDT_IRQHandler is mangled in C++ and cannot override that in startup file in C.
ccli8 1:eb1da9d36e12 50 * So the NVIC_SetVector call cannot be left out. */
ccli8 1:eb1da9d36e12 51 NVIC_SetVector(WDT_IRQn, (uint32_t) WDT_IRQHandler);
ccli8 1:eb1da9d36e12 52 NVIC_EnableIRQ(WDT_IRQn);
ccli8 1:eb1da9d36e12 53 SYS_UnlockReg();
ccli8 1:eb1da9d36e12 54 /* Enable WDT timeout interrupt */
ccli8 1:eb1da9d36e12 55 WDT_EnableInt();
ccli8 1:eb1da9d36e12 56 SYS_LockReg();
ccli8 1:eb1da9d36e12 57 }
ccli8 16:ed2c228cbc9c 58
ccli8 16:ed2c228cbc9c 59 #else
ccli8 16:ed2c228cbc9c 60
ccli8 16:ed2c228cbc9c 61 void config_wdt_wakeup()
ccli8 16:ed2c228cbc9c 62 {
ccli8 16:ed2c228cbc9c 63 }
ccli8 16:ed2c228cbc9c 64
ccli8 16:ed2c228cbc9c 65 #endif /* #if !defined(DEVICE_WATCHDOG) || !DEVICE_WATCHDOG */