Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
simon
Date:
Thu Nov 26 16:00:28 2009 +0000
Commit message:

Changed in this revision

interfaces.cpp Show annotated file Show diff for this revision Revisions of this file
interfaces.h Show annotated file Show diff for this revision Revisions of this file
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
otheruser.cpp Show annotated file Show diff for this revision Revisions of this file
otheruser.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/interfaces.cpp	Thu Nov 26 16:00:28 2009 +0000
@@ -0,0 +1,6 @@
+#include "interfaces.h"
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/interfaces.h	Thu Nov 26 16:00:28 2009 +0000
@@ -0,0 +1,11 @@
+#ifndef INTERFACES_H
+#define INTERFACES_H
+
+#include "mbed.h"
+
+extern DigitalOut led1;
+extern DigitalOut led2;
+extern DigitalOut led3;
+extern DigitalOut led4;
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 26 16:00:28 2009 +0000
@@ -0,0 +1,21 @@
+// Example showing multiple files using the same mbed interface instances
+// sford
+//
+//  * The interfaces we want are in interfaces.h/cpp (e.g. our digital outputs)
+//    - they are instanced in the .cpp file so they exist
+//    - they are listed in the .h file as extern, so others can use them
+//  * Both main and otheruser include interfaces.h, so can both use it
+
+#include "mbed.h"
+#include "interfaces.h"
+#include "otheruser.h"
+
+int main() {
+    while(1) {
+		led1 = led3 = 0;	// main uses led1, defined in interfaces
+		led2 = led4 = 1;
+        wait(0.2);
+		otheruser();		// otheruser uses led1, defined in interfaces
+        wait(0.2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 26 16:00:28 2009 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/fcb9359f0959
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/otheruser.cpp	Thu Nov 26 16:00:28 2009 +0000
@@ -0,0 +1,8 @@
+#include "otheruser.h"
+
+#include "interfaces.h"
+
+void otheruser() {
+	led1 = led3 = 1;
+	led2 = led4 = 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/otheruser.h	Thu Nov 26 16:00:28 2009 +0000
@@ -0,0 +1,6 @@
+#ifndef OTHERUSER_H
+#define OTHERUSER_H
+
+void otheruser();
+
+#endif