My attempt at using the mbed without the mbed libraries.
Here is a main.cpp, that uses the registers library.
Revision 7:411ae6b21c9b, committed 2013-01-03
- Comitter:
- elevatorguy
- Date:
- Thu Jan 03 05:25:38 2013 +0000
- Parent:
- 6:d40cd917854d
- Commit message:
- off by 1 error
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
registers.lib | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Jan 03 05:10:49 2013 +0000 +++ b/main.cpp Thu Jan 03 05:25:38 2013 +0000 @@ -1,6 +1,6 @@ #include "registers.h" DigitalOut led1(p20); -DigitalOut led2(LED2); +DigitalOut led2(p19); DigitalOut led3(LED3); DigitalOut led4(LED4); DigitalIn switch1(p21); @@ -10,6 +10,7 @@ Timeout tock; Ticker tock2; +Ticker tock3; extern "C" void turnOff(void) { led1 = 0; @@ -17,13 +18,19 @@ extern "C" void turnOn(void) { led1 = 1; - tock.attach(&turnOff, 0.05); + tock.attach(&turnOff, 0.0001); +} + +extern "C" void led2flip(void) +{ + led2 = !led2; } int main() { //Timer and Ticker demonstration switch1.mode(PULLDOWN); t.start(); - tock2.attach(&turnOn, 0.5); + tock2.attach(&turnOn, 0.005); + tock3.attach(&led2flip, 0.0025); while(1) { double time = t;
--- a/registers.lib Thu Jan 03 05:10:49 2013 +0000 +++ b/registers.lib Thu Jan 03 05:25:38 2013 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/elevatorguy/code/registers/#0b44a0a56f92 +http://mbed.org/users/elevatorguy/code/registers/#276fb0fe230c