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.
main.cpp
00001 #include "mbed.h" 00002 #include "rtos.h" 00003 00004 InterruptIn button(USER_BUTTON0); 00005 DigitalOut led1(LED1); 00006 Thread * pTestTask = NULL; 00007 00008 static void idle_hook(void) { 00009 __WFI(); // Do not set when using SoftwareStandby. 00010 } 00011 00012 static void interrupt_button(void) { 00013 if (pTestTask != NULL) { 00014 pTestTask->signal_set(1); 00015 } 00016 } 00017 00018 void test_task(void) { 00019 int test_cnt = 0; 00020 00021 button.fall(&interrupt_button); 00022 button.rise(&interrupt_button); 00023 00024 while (true) { 00025 // It becomes sleep during idle task. 00026 Thread::signal_wait(1); 00027 led1 = !led1; 00028 printf("%d\n", test_cnt++); 00029 } 00030 } 00031 00032 int main() { 00033 Thread::attach_idle_hook(idle_hook); 00034 pTestTask = new Thread(); 00035 pTestTask->start(test_task); 00036 }
Generated on Fri Jul 15 2022 07:00:28 by
1.7.2