Merge pull request #14879 from benpicco/cpu/kinetis/rtc_mktimr
cpu/kinetis: RTC use rtc_mktime()
This commit is contained in:
commit
6a2b2aab5d
@ -20,8 +20,6 @@
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
#include "cpu.h"
|
||||
#include "periph/rtc.h"
|
||||
#include "periph/rtt.h"
|
||||
@ -50,38 +48,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