SWEventClass

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Reichi19
Date:
Thu Nov 15 17:22:54 2018 +0000
Commit message:
SWEventClass

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 15 17:22:54 2018 +0000
@@ -0,0 +1,56 @@
+
+#include <mbed.h>
+    
+ class SerialEvent{
+    
+    private:   
+    Serial _isr;
+    volatile int16_t _pressed;  
+    char _str;
+    void _risingISR();
+    
+    public:
+    int checkFlag(); 
+    void read(char& zeichen);
+    
+    SerialEvent(PinName tx, PinName rx) : _isr(tx, rx){
+         _isr.attach(callback(this, &SerialEvent::_risingISR));
+        }
+};
+
+
+
+void SerialEvent::_risingISR(){
+    _str = _isr.getc();
+    _pressed =1;
+    }
+
+int SerialEvent::checkFlag(){
+    if(_pressed){
+    _pressed =0;
+    return true;
+    }
+    
+    else 
+        return false;
+    }
+    
+
+void SerialEvent::read(char& zeichen){
+    zeichen = _str;                             
+    }
+
+SerialEvent pc(USBTX, USBRX);
+
+main(){
+    
+   
+    char z;
+    while(1){
+    if(pc.checkFlag())
+    pc.read(z);
+    printf("Zeichen: %c", z);
+    }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 15 17:22:54 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file