my implementation of mbed-like classes using the LPC1768 register access.

Dependents:   registers-example RedWireBridge

This is just to satisfy my curiosity on how the mbed libraries work. I put it here just in case others are too. Every time I learn how another internal register works, I'll keep it here to save myself from future coding headaches.

working

  • DigitalIn
  • DigitalOut
  • wait()

mostly working

  • Serial
  • Timer
  • Ticker
  • Timeout

Serial doesn't have all the methods that mbed had, but it works for me. (only UART0, so only over USB to the pc for now) Timer has the same limitations of mbed for default resolution (30 min limit), and if you start at the end of resolution and stop after it rolls back to 0, it doesn't take that into account. But I added the option to change resolution, so I can have longer timers.

For Ticker, I used a 100 microsecond timer instead of a 1 microsecond Timer, so the smallest interval in between function calls is 100 microseconds. (10KHz) However, this means that the maximum interval in between function calls is 59 hours. (untested)

The Timeout class, simply uses a Ticker, but then marks it as nonactive after the first function call. Automatically calls the detach() function when attaching it again, so no don't need to worry about it.

Files at this revision

API Documentation at this revision

Comitter:
elevatorguy
Date:
Thu Jan 03 05:25:18 2013 +0000
Parent:
1:0b44a0a56f92
Commit message:
fix

Changed in this revision

Ticker.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 0b44a0a56f92 -r 276fb0fe230c Ticker.cpp
--- a/Ticker.cpp	Thu Jan 03 05:10:21 2013 +0000
+++ b/Ticker.cpp	Thu Jan 03 05:25:18 2013 +0000
@@ -83,7 +83,7 @@
     {
         func = (uint32_t)funcaddr; //pointer to function address
         interval = secinterval*10000;
-        remaining = secinterval*10000 - 1; // 100 microsecond resolution
+        remaining = secinterval*10000; // 100 microsecond resolution
         tickers[active_tickers] = this;
         active_tickers = active_tickers + 1;
         active = true;