An attempt to provide a Real Time Clock for the nRF51-DK. This code provides rtc.time and rtc.set_time replacements for the similarly named C standard methods (unimplemented for nRF51-DK last I checked). Not very well tested, but it seems to work for simple applications.

Dependents:   nRF51_rtc_example LoRa_PIR BLE_Lightning_sensor BLE_AlarmWatch ... more

Revision:
0:3677a016109b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nrf51_rtc.h	Sun Feb 08 01:28:47 2015 +0000
@@ -0,0 +1,22 @@
+#ifndef NRF51_RTC_H
+#define NRF51_RTC_H
+
+#include "mbed.h"
+
+static class nrf51_rtc {
+    // class to create equivalent of time() and set_time()
+    //   ...depends upon RTC1 to be running and to never stop -- a byproduct of instantiation of mbed library's "ticker"
+    public:
+    nrf51_rtc();
+    time_t time();
+    int set_time(time_t rawtime);
+    
+    // these should be private
+    private:
+    time_t time_base;
+    unsigned int rtc_previous;
+    unsigned int ticks_per_second, counter_size_in_seconds;
+    void update_rtc(); // similar to "time" but doesn't return the value, just updates underlying variables
+
+} rtc;
+#endif
\ No newline at end of file