Merge pull request #14878 from benpicco/cpu/fe310/rtc_mktime
cpu/fe310: RTC: use rtc_mktime()
This commit is contained in:
commit
a1473431da
@ -17,10 +17,6 @@
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "cpu.h"
|
||||
#include "periph_cpu.h"
|
||||
#include "periph_conf.h"
|
||||
@ -46,38 +42,38 @@ void rtc_init(void)
|
||||
|
||||
int rtc_set_time(struct tm *time)
|
||||
{
|
||||
time_t t = mktime(time);
|
||||
uint32_t t = rtc_mktime(time);
|
||||
|
||||
rtt_set_counter((uint32_t)t);
|
||||
rtt_set_counter(t);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rtc_get_time(struct tm *time)
|
||||
{
|
||||
time_t t = (time_t)rtt_get_counter();
|
||||
uint32_t t = rtt_get_counter();
|
||||
|
||||
gmtime_r(&t, time);
|
||||
rtc_localtime(t, time);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rtc_set_alarm(struct tm *time, rtc_alarm_cb_t cb, void *arg)
|
||||
{
|
||||
time_t t = mktime(time);
|
||||
uint32_t t = rtc_mktime(time);
|
||||
|
||||
rtc_callback.cb = cb;
|
||||
|
||||
rtt_set_alarm((uint32_t)t, rtc_cb, arg);
|
||||
rtt_set_alarm(t, rtc_cb, arg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rtc_get_alarm(struct tm *time)
|
||||
{
|
||||
time_t t = (time_t)rtt_get_alarm();
|
||||
uint32_t t = rtt_get_alarm();
|
||||
|
||||
gmtime_r(&t, time);
|
||||
rtc_localtime(t, time);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user