Interrup

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
mexx
Date:
Thu Nov 15 17:26:14 2018 +0000
Commit message:
interrup

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 f597b6aec8fb main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 15 17:26:14 2018 +0000
@@ -0,0 +1,45 @@
+#include "mbed.h"
+
+DigitalOut led (LED1);
+
+
+class SwEvent
+{
+    private:
+        InterruptIn  _isr;
+        bool _check;
+    public:    
+        SwEvent(PinName isr):_isr(isr) 
+        {
+            _isr.rise(callback(this, &SwEvent::setFlag));    
+        }
+        
+        bool checkFlag(void);
+        void setFlag(void);
+};
+
+
+
+void SwEvent::setFlag(void)
+{
+    _check = !_check;
+}
+
+bool SwEvent::checkFlag(void)
+{
+    
+        if (_check == 0) led = 1;
+        else if (_check == 1) led = 0;  
+        
+        return _check;
+}
+
+SwEvent checker(p15);
+
+int main() {
+    while(1) {
+        checker.checkFlag();
+        printf("Aktueller Status: %d \n", checker.checkFlag());
+        wait_ms(10);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f597b6aec8fb mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 15 17:26:14 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file