My attempt at using the mbed without the mbed libraries.
Here is a main.cpp, that uses the registers library.
main.cpp
- Committer:
- elevatorguy
- Date:
- 2012-12-30
- Revision:
- 2:e26c096f1946
- Parent:
- 0:5fa5046f2ff5
- Child:
- 3:88da6c0412b0
File content as of revision 2:e26c096f1946:
#include "registers.h" DigitalOut led1(LED1); DigitalOut led2(LED2); DigitalOut led3(LED3); DigitalOut led4(LED4); DigitalIn switch1(p21); Serial pc; Timer t(1000); //ms resolution for a serial stopwatch demo int main() { //Timer demonstration switch1.mode(PULLDOWN); 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"); } }