Ken DelRaso / Mbed 2 deprecated interruptExample

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
kdelraso
Date:
Tue Oct 05 19:17:00 2010 +0000
Commit message:

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 ec454e4339e4 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Oct 05 19:17:00 2010 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+
+// A class for flip()-ing a DigitalOut 
+class Flipper {
+public:
+    Flipper(PinName pin) : _pin(pin) {
+        _pin = 0;
+    }
+    void flip() {
+        _pin = !_pin;
+    }
+private:
+    DigitalOut _pin;
+};
+
+DigitalOut led1(LED1);
+DigitalOut led3(LED3);
+
+Flipper f(LED2);
+Ticker t;
+
+int main() {
+    t.attach_us(&f, &Flipper::flip, 25); // the address of the object, member function, and interval
+                                            // 25 us = 40kHz
+    led3 = 1;
+
+    // spin in a main loop. flipper will interrupt it to call flip
+    while(1) {
+        led1 = !led1;
+        wait(0.2);
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r ec454e4339e4 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Oct 05 19:17:00 2010 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e