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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers nrf51_rtc.h Source File

nrf51_rtc.h

00001 #ifndef NRF51_RTC_H
00002 #define NRF51_RTC_H
00003 
00004 #include "mbed.h"
00005 
00006 static class nrf51_rtc {
00007     // class to create equivalent of time() and set_time()
00008     //   ...depends upon RTC1 to be running and to never stop -- a byproduct of instantiation of mbed library's "ticker"
00009     public:
00010     nrf51_rtc();
00011     time_t time();
00012     int set_time(time_t rawtime);
00013     
00014     // these should be private
00015     private:
00016     time_t time_base;
00017     unsigned int rtc_previous;
00018     unsigned int ticks_per_second, counter_size_in_seconds;
00019     void update_rtc(); // similar to "time" but doesn't return the value, just updates underlying variables
00020 
00021 } rtc;
00022 #endif