by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
robt
Date:
Sun Jun 16 15:41:02 2013 +0000
Commit message:
by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"

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 71c5512ccb49 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Jun 16 15:41:02 2013 +0000
@@ -0,0 +1,34 @@
+/*Program Example 14.1: Sets up a digital output pin using control registers, and flashes an led.
+                                                                         */
+// function prototypes
+void delay(void);
+
+//Define addresses of digital i/o control registers, as pointers to volatile data
+#define FIO2DIR0       (*(volatile unsigned char *)(0x2009C040))
+#define FIO2PIN0       (*(volatile unsigned char *)(0x2009C054))
+#define FIO0PIN0 (*( volatile unsigned char *)(0x2009C014))
+
+int main()
+{
+    FIO2DIR0=0xFF;     // set port 2, lowest byte to output
+    while(1) {
+        for (int i=1; i<=3; i++) {
+            FIO0PIN0 |= 0x02;       // set port 2 pin 1 high (mbed pin 25)
+            delay();
+            FIO0PIN0 &= ~0x02;      // set port 2 pin 1 low
+            delay();
+        }
+
+    }
+}
+//delay function
+void delay(void)
+{
+    int j;                      //loop variable j
+    for (j=0; j<1000000; j++) {
+        j++;
+        j--;                      //waste time
+    }
+}
+
+
diff -r 000000000000 -r 71c5512ccb49 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Jun 16 15:41:02 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/b3110cd2dd17
\ No newline at end of file