Events programming

Files at this revision

API Documentation at this revision

Comitter:
corsa1600
Date:
Thu Mar 28 18:15:10 2019 +0000
Parent:
3:26487f295213
Commit message:
verbesserte Version des Queue

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 26487f295213 -r 964e73eb0618 main.cpp
--- a/main.cpp	Thu Mar 28 17:56:13 2019 +0000
+++ b/main.cpp	Thu Mar 28 18:15:10 2019 +0000
@@ -7,10 +7,20 @@
  
 void fall_handler() {
     // this now runs in the context of eventThread, instead of in the ISR
-    led = !led;
-    printf("Toggle LED in context %p\r\n", Thread::gettid());
+    //led = !led;   //-> IRQ Routine
+    printf("Printf context %p\r\n", Thread::gettid());
 }
  
+void fall_handler_isr()
+{
+ led = !led; 
+ queue.call(&fall_handler);
+ printf("ISR context %p\r\n", Thread::gettid());    // sollte nicht hier stehen
+ 
+ 
+ }
+ 
+ 
 int main() {
     // create a thread that'll run the event queue's dispatch function
     Thread eventThread;
@@ -18,6 +28,7 @@
     printf("Using Event Queue starting in context %p\r\n", Thread::gettid());
     
 // wrap calls in queue.event to automatically defer to the queue's thread
-    btn.fall(queue.event(&fall_handler));
+    btn.fall(&fall_handler_isr);
+   // btn.fall(queue.event(&fall_handler_isr));
     wait(osWaitForever);
 }
\ No newline at end of file