
BlinkButton2Sec assignment
Revision 0:30bd725c73f0, committed 2018-11-29
- Comitter:
- framtk
- Date:
- Thu Nov 29 19:31:29 2018 +0000
- Commit message:
- done
Changed in this revision
diff -r 000000000000 -r 30bd725c73f0 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Nov 29 19:31:29 2018 +0000 @@ -0,0 +1,31 @@ +#include "mbed.h" + +DigitalOut led1(LED1); +InterruptIn button(USER_BUTTON); +EventQueue queue(32 * EVENTS_EVENT_SIZE); +Thread t; + +volatile time_t first_seconds = 0; + +void fall_handler_thread_context(void) { + printf("rise_handler_thread_context in context %p\r\n", Thread::gettid()); + printf("firt_seconds: %d\n", first_seconds); + time_t seconds = time(NULL); + if (first_seconds != 0 && ((seconds - first_seconds) < 2)) { + led1 = !led1; + } + printf("seconds: %d\n", seconds); + first_seconds = seconds; +} + +void fall_handler_iterrupt_context(void) { + queue.call(fall_handler_thread_context); +} + + +int main() { + // Start the event queue + t.start(callback(&queue, &EventQueue::dispatch_forever)); + printf("Starting in context %p\r\n", Thread::gettid()); + button.fall(fall_handler_iterrupt_context); +} \ No newline at end of file
diff -r 000000000000 -r 30bd725c73f0 mbed-os.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Thu Nov 29 19:31:29 2018 +0000 @@ -0,0 +1,1 @@ +https://github.com/armmbed/mbed-os/#bf6f2c3c6434a6de9eb9511feffa5948b3d1f20f
diff -r 000000000000 -r 30bd725c73f0 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Nov 29 19:31:29 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/22da6e220af6 \ No newline at end of file