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.
Revision 0:7c7d5b625e59, committed 2017-12-18
- Comitter:
- deepikabhavnani
- Date:
- Mon Dec 18 16:50:19 2017 +0000
- Commit message:
- Shared event example: deferring from interrupt context
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Mon Dec 18 16:50:19 2017 +0000 @@ -0,0 +1,4 @@ +.build +.mbed +projectfiles +*.py*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Dec 18 16:50:19 2017 +0000
@@ -0,0 +1,26 @@
+#include "mbed.h"
+#include "mbed_events.h"
+
+DigitalOut led1(LED1);
+InterruptIn sw(SW2);
+
+void rise_handler(void) {
+ // Toggle LED
+ led1 = !led1;
+}
+
+void fall_handler(void) {
+ printf("fall_handler in context %p\r\n", Thread::gettid());
+ // Toggle LED
+ led1 = !led1;
+}
+
+int main() {
+ // Request the shared queue
+ EventQueue *queue = mbed_event_queue();
+ printf("Starting in context %p\r\n", Thread::gettid());
+ // The 'rise' handler will execute in IRQ context
+ sw.rise(rise_handler);
+ // The 'fall' handler will execute in the context of the shared queue thread
+ sw.fall(queue->event(fall_handler));
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Mon Dec 18 16:50:19 2017 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#5f6572179d66ce4c09d6517b659ac51133cc980d