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 00003 DigitalOut led1(LED1); 00004 InterruptIn button(USER_BUTTON); 00005 EventQueue queue(32 * EVENTS_EVENT_SIZE); 00006 Thread t; 00007 00008 volatile time_t first_seconds = 0; 00009 00010 void fall_handler_thread_context(void) { 00011 printf("rise_handler_thread_context in context %p\r\n", Thread::gettid()); 00012 printf("firt_seconds: %d\n", first_seconds); 00013 time_t seconds = time(NULL); 00014 if (first_seconds != 0 && ((seconds - first_seconds) < 2)) { 00015 led1 = !led1; 00016 } 00017 printf("seconds: %d\n", seconds); 00018 first_seconds = seconds; 00019 } 00020 00021 void fall_handler_iterrupt_context(void) { 00022 queue.call(fall_handler_thread_context); 00023 } 00024 00025 00026 int main() { 00027 // Start the event queue 00028 t.start(callback(&queue, &EventQueue::dispatch_forever)); 00029 printf("Starting in context %p\r\n", Thread::gettid()); 00030 button.fall(fall_handler_iterrupt_context); 00031 }
Generated on Thu Jul 14 2022 22:47:08 by
1.7.2