My attempt at using the mbed without the mbed libraries.

Dependencies:   ARM registers

Here is a main.cpp, that uses the registers library.

Revision:
2:e26c096f1946
Parent:
0:5fa5046f2ff5
Child:
3:88da6c0412b0
--- a/main.cpp	Fri Dec 21 01:58:51 2012 +0000
+++ b/main.cpp	Sun Dec 30 04:58:42 2012 +0000
@@ -1,12 +1,76 @@
-#include "registers.h" // oneliner: ain't that sexy!
+#include "registers.h"
 DigitalOut led1(LED1);
 DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
 DigitalIn switch1(p21);
 
-int main() {  
+Serial pc;
+Timer t(1000); //ms resolution for a serial stopwatch demo
+
+int main() {  //Timer demonstration
     switch1.mode(PULLDOWN);
-    while(1) {
-        led1 = switch1;
-        led2 = !led1;
+    t.start();
+
+    while(1)
+    {
+        double time = t;
+        int h = 0;
+        int m = 0;
+        while(time > 3600)
+        {
+            time = time - 3600;
+            h = h + 1;
+        }
+        while(time > 60)
+        {
+            time = time - 60;
+            m = m + 1;
+        }
+        if(h < 10.0)
+        {
+            pc.putc('0');
+        }
+        if(h != 0)
+        {
+            pc.printf(h);
+        }
+        else
+        {
+            pc.putc('0');
+        }
+        pc.putc(':');
+        if(m < 10.0)
+        {
+            pc.putc('0');
+        }
+        if(m != 0)
+        {
+            pc.printf(m);
+        }
+        else
+        {
+            pc.putc('0');
+        }
+        pc.putc(':');
+        if(time < 10.0)
+        {
+            pc.putc('0');
+        }
+        if(time < 1.0)
+        {
+            pc.putc('0');
+        }
+        pc.printf(time, 100);
+        int timeAsInt = time;
+        if((time-timeAsInt)*100 < 10.0)
+        {
+            pc.putc('0');
+        }
+        if((time-timeAsInt)*100 < 1.0)
+        {
+            pc.putc('0');
+        }
+        pc.printf("\r\n");
     }
 }
\ No newline at end of file