Serial

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
mexx
Date:
Thu Nov 15 17:24:05 2018 +0000
Commit message:
Serial

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 645979190d77 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 15 17:24:05 2018 +0000
@@ -0,0 +1,57 @@
+#include "mbed.h"
+ 
+ 
+ class SerialEvent
+ {
+    private:
+     Serial _isr;                       // für serielles einlesen
+     volatile int16_t _pressed;    // wegen multicore unterstützung
+     void _risingISR();             // prototyping
+     char _str;                      // str ist nur eine Variable, könnte auch zeichen heißen
+     
+    public:
+     int checkFlag();
+     void read(char& zeichen);
+     SerialEvent(PinName tx, PinName rx): _isr(tx,rx)       //Konstruktor
+     {
+         _isr.attach(callback(this, &SerialEvent::_risingISR));
+     }
+    };
+      
+     void SerialEvent :: read(char& zeichen)
+     {
+         zeichen= _str;
+     }
+        
+     
+     void SerialEvent :: _risingISR()
+     {
+         _str = _isr.getc();
+         _pressed=1;
+     }
+     
+     int SerialEvent :: checkFlag ()
+     {
+         if(_pressed)
+         {
+         _pressed=0;
+         return true;
+         }
+         else
+         return false;
+     }
+         
+         SerialEvent pc(USBTX, USBRX);  //pc ist wieder nur irgendeine Variable
+  
+  
+  
+  
+  main()
+  {
+     
+     char z;
+     if( pc.checkFlag())
+     pc.read(z);
+     printf("Zeichen: %c",z);
+     
+     }
\ No newline at end of file
diff -r 000000000000 -r 645979190d77 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 15 17:24:05 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file