Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
RTC.h
1 
6 #ifndef SMINGCORE_RTC_H_
7 #define SMINGCORE_RTC_H_
8 
9 #include "../Wiring/WiringFrameworkDependencies.h"
10 
11 #define RTC_MAGIC 0x55aaaa55
12 #define RTC_DES_ADDR 64
13 #define NS_PER_SECOND 1000000000
14 
18 typedef struct {
19  uint64_t time;
20  uint32_t magic;
21  uint32_t cycles;
22 } RtcData;
23 
28 class RtcClass
29 {
30 public:
33  RtcClass();
34 
38  uint64_t getRtcNanoseconds();
39 
44  uint32_t getRtcSeconds();
45 
50  bool setRtcNanoseconds(uint64_t nanoseconds);
51 
57  bool setRtcSeconds(uint32_t seconds);
58 
61 private:
62  bool hardwareReset;
63  bool saveTime(RtcData &data);
64  void updateTime(RtcData &data);
65  void loadTime(RtcData &data);
66 };
67 
75 extern RtcClass RTC;
76 #endif /* SMINGCORE_RTC_H_ */
RtcClass()
Instantiate real time clock object.
RtcClass RTC
Global instance of real time clock object.
uint32_t magic
Magic ID used to identify that RTC has been initialised.
Definition: RTC.h:20
Definition: RTC.h:28
uint32_t getRtcSeconds()
Get seconds from RTC.
bool setRtcSeconds(uint32_t seconds)
Set RTC.
bool setRtcNanoseconds(uint64_t nanoseconds)
Set RTC nanoseconds.
Definition: RTC.h:18
uint64_t time
Quantity of nanoseconds since epoch.
Definition: RTC.h:19
uint32_t cycles
Quantity of RTC cycles since last update.
Definition: RTC.h:21
uint64_t getRtcNanoseconds()
Get nanoseconds from RTC.