Daiki Kato
/
SoftwareStanby_test_use_OS
This is a sample to make Software Standby using OS.
Diff: main.cpp
- Revision:
- 2:c0f92fd0e8e9
- Parent:
- 1:29fa0989ec31
- Child:
- 3:64e8fa1b8787
--- a/main.cpp Fri Nov 18 10:40:19 2016 +0000 +++ b/main.cpp Mon Oct 07 03:38:30 2019 +0000 @@ -1,40 +1,9 @@ #include "mbed.h" -#include "rtos.h" -#include "RZ_A1_Init.h" InterruptIn button(USER_BUTTON0); DigitalOut led1(LED1); Thread * pTestTask = NULL; -#if(0) // Do not set when using SoftwareStandby. -static void idle_hook(void) { - __WFI(); // Do not set when using SoftwareStandby. -} -#endif - -void SoftwareStandby(void) { - volatile uint32_t dummy_32; - volatile uint8_t dummy_8; - - GIC_DisableIRQ(OSTMI0TINT_IRQn); - - // Set the standby_mode_en bit of the power control register in the PL310 to 1. - L2C.REG15_POWER_CTRL = 0x00000001uL; - dummy_32 = L2C.REG15_POWER_CTRL; - - // Clear the TME bit in the watchdog timer control/status register (WTCSR) of the watchdog timer to 0 to stop the watchdog timer. - WDT.WTCSR = 0xA518; - WDT.WTCNT = 0x5A00; - WDT.WTCSR = 0xA51D; // CKS[2:0] = b'101 : 1/1024xP0 (7.8ms) - - CPG.STBCR1 = 0x80; - dummy_8 = CPG.STBCR1; - - __WFI(); - - GIC_EnableIRQ(OSTMI0TINT_IRQn); -} - static void interrupt_button(void) { #if(0) // It may or may not be present. if (pTestTask != NULL) { @@ -50,21 +19,18 @@ button.rise(&interrupt_button); while (true) { - SoftwareStandby(); + sleep_manager_sleep_auto(); #if(0) // It may or may not be present. // It becomes sleep during idle task. Thread::signal_wait(1); #endif led1 = !led1; - printf("%d\n", test_cnt++); - wait_ms(2); // Wait for output completion of printf(). + printf("%d\r\n", test_cnt++); + ThisThread::sleep_for(5); // Wait for output completion of printf(). } } int main() { -#if(0) // Do not set when using SoftwareStandby. - Thread::attach_idle_hook(idle_hook); -#endif pTestTask = new Thread(); pTestTask->start(test_task); }