Skip to content

Commit f88f9fd

Browse files
committed
more fake RTC code ... adafruit#1046
(works if MP_WEAK common_hal_rtc_get_time is removed)
1 parent 4a5c52f commit f88f9fd

File tree

1 file changed

+12
-8
lines changed
  • ports/nrf/common-hal/rtc

1 file changed

+12
-8
lines changed

ports/nrf/common-hal/rtc/RTC.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,25 @@
3232
#include "shared-bindings/rtc/__init__.h"
3333
#include "supervisor/shared/translate.h"
3434

35+
#include "nrfx_rtc.h"
36+
37+
static uint32_t _rtc_seconds = 0;
38+
39+
void rtc_handler(nrfx_rtc_int_type_t int_type) {
40+
41+
}
42+
3543
void rtc_init(void) {
3644
}
3745

3846
void common_hal_rtc_get_time(timeutils_struct_time_t *tm) {
39-
tm->tm_year = 2000;
40-
tm->tm_mon = 1;
41-
tm->tm_mday = 2;
42-
tm->tm_hour = 3;
43-
tm->tm_min = 4;
44-
tm->tm_sec = 5;
45-
tm->tm_wday = 6;
46-
tm->tm_yday = 2;
47+
timeutils_seconds_since_2000_to_struct_time(_rtc_seconds, tm);
4748
}
4849

4950
void common_hal_rtc_set_time(timeutils_struct_time_t *tm) {
51+
_rtc_seconds = timeutils_seconds_since_2000(
52+
tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec
53+
);
5054
}
5155

5256
// A positive value speeds up the clock by removing clock cycles.

0 commit comments

Comments
 (0)