aboutsummaryrefslogtreecommitdiffstats
path: root/testhal/STM32F4xx/RTC
diff options
context:
space:
mode:
Diffstat (limited to 'testhal/STM32F4xx/RTC')
-rw-r--r--testhal/STM32F4xx/RTC/Makefile3
-rw-r--r--testhal/STM32F4xx/RTC/main.c10
2 files changed, 6 insertions, 7 deletions
diff --git a/testhal/STM32F4xx/RTC/Makefile b/testhal/STM32F4xx/RTC/Makefile
index fedca622d..3b57b683a 100644
--- a/testhal/STM32F4xx/RTC/Makefile
+++ b/testhal/STM32F4xx/RTC/Makefile
@@ -88,7 +88,8 @@ CSRC = $(PORTSRC) \
$(CHIBIOS)/os/various/syscalls.c \
$(CHIBIOS)/os/various/shell.c \
$(CHIBIOS)/os/various/chprintf.c \
- main.c
+ $(CHIBIOS)/os/various/chrtclib.c \
+ main.c \
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
diff --git a/testhal/STM32F4xx/RTC/main.c b/testhal/STM32F4xx/RTC/main.c
index 5bc51c7b6..ce3e7f13f 100644
--- a/testhal/STM32F4xx/RTC/main.c
+++ b/testhal/STM32F4xx/RTC/main.c
@@ -43,11 +43,11 @@ int tm_isdst daylight savings indicator (1 = yes, 0 = no, -1 = unknown)
#include "shell.h"
#include "chprintf.h"
+#include "chrtclib.h"
#if WAKEUP_TEST
static RTCWakeup wakeupspec;
#endif
-static RTCTime timespec = {0,0,FALSE,0};
static RTCAlarm alarmspec;
static time_t unix_time;
@@ -147,15 +147,14 @@ static void cmd_date(BaseChannel *chp, int argc, char *argv[]){
}
if ((argc == 1) && (strcmp(argv[0], "get") == 0)){
- rtcGetTime(&RTCD1, &timespec);
- stm32_rtc_bcd2tm(&timp, &timespec);
- unix_time = mktime(&timp);
+ unix_time = rtcGetTimeUnixSec(&RTCD1);
if (unix_time == -1){
chprintf(chp, "incorrect time in RTC cell\r\n");
}
else{
chprintf(chp, "%D%s",unix_time," - unix time\r\n");
+ rtcGetTimeTm(&RTCD1, &timp);
chprintf(chp, "%s%s",asctime(&timp)," - formatted time string\r\n");
}
return;
@@ -164,8 +163,7 @@ static void cmd_date(BaseChannel *chp, int argc, char *argv[]){
if ((argc == 2) && (strcmp(argv[0], "set") == 0)){
unix_time = atol(argv[1]);
if (unix_time > 0){
- stm32_rtc_tm2bcd((localtime(&unix_time)), &timespec);
- rtcSetTime(&RTCD1, &timespec);
+ rtcSetTimeUnixSec(&RTCD1, unix_time);
return;
}
else{