Skip to content

Commit 090e460

Browse files
committed
RTC: refactor library
Former-commit-id: 8e814ad
1 parent 5988c40 commit 090e460

File tree

5 files changed

+191
-217
lines changed

5 files changed

+191
-217
lines changed

cores/arduino/rtc.cpp

Lines changed: 0 additions & 181 deletions
This file was deleted.

cores/arduino/rtc.h

Lines changed: 0 additions & 24 deletions
This file was deleted.

libraries/RTC/examples/Test_RTC/Test_RTC.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "RTClock.h"
1+
#include "RTC.h"
22

33
const int LED_ON_INTERRUPT = 22;
44

libraries/RTC/src/RTClock.h renamed to libraries/RTC/src/RTC.h

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@
44
#include <ctime>
55
#include "r_rtc_api.h"
66

7+
struct timeval {
8+
time_t tv_sec;
9+
useconds_t tv_usec;
10+
};
11+
12+
#ifdef __cplusplus
13+
extern "C" {
14+
#endif
15+
16+
void set_time(time_t t);
17+
void attach_rtc(time_t (*read_rtc)(void), void (*write_rtc)(time_t), void (*init_rtc)(void), int (*isenabled_rtc)(void));
18+
int gettimeofday(struct timeval *tv, void *tz);
19+
int settimeofday(const struct timeval *tv, const struct timezone *tz);
20+
21+
#ifdef __cplusplus
22+
}
23+
#endif
24+
25+
726
using stime_t = struct tm;
827
using rtc_cbk_t = void (*)();
928

@@ -138,14 +157,12 @@ class RTClock {
138157
private:
139158
bool is_initialized;
140159

141-
142-
143160
public:
144161
RTClock();
145162
~RTClock();
146163

147164
bool begin();
148-
165+
149166
bool getTime(RTCTime &t);
150167

151168
bool setPeriodicCallback(rtc_cbk_t fnc, Period p);

0 commit comments

Comments
 (0)