rtc.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Thomas Eichinger <thomas.eichinger@fu-berlin.de>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser General
5  * Public License v2.1. See the file LICENSE in the top level directory for more
6  * details.
7  */
8 
37 #ifndef PERIPH_RTC_H
38 #define PERIPH_RTC_H
39 
40 #include <stdbool.h>
41 #include <stdint.h>
42 #include <time.h>
43 #include "periph_conf.h"
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 #if !defined(RIOT_EPOCH) || DOXYGEN
50 
58 #define RIOT_EPOCH (2020)
59 #endif
60 
66 typedef void(*rtc_alarm_cb_t)(void *arg);
67 
71 void rtc_init(void);
72 
81 int rtc_set_time(struct tm *time);
82 
91 int rtc_get_time(struct tm *time);
92 
106 int rtc_set_alarm(struct tm *time, rtc_alarm_cb_t cb, void *arg);
107 
116 int rtc_get_alarm(struct tm *time);
117 
121 void rtc_clear_alarm(void);
122 
126 void rtc_poweron(void);
127 
131 void rtc_poweroff(void);
132 
146 void rtc_tm_normalize(struct tm *time);
147 
162 int rtc_tm_compare(const struct tm *a, const struct tm *b);
163 
175 uint32_t rtc_mktime(struct tm *t);
176 
183 void rtc_localtime(uint32_t time, struct tm *t);
184 
196 bool rtc_tm_valid(const struct tm *t);
197 
198 #ifdef __cplusplus
199 }
200 #endif
201 
202 #endif /* PERIPH_RTC_H */
203 
rtc_tm_normalize
void rtc_tm_normalize(struct tm *time)
Normalize the time struct.
rtc_get_time
int rtc_get_time(struct tm *time)
Get current RTC time.
rtc_init
void rtc_init(void)
Initialize RTC module.
rtc_clear_alarm
void rtc_clear_alarm(void)
Clear any set alarm, do nothing if nothing set.
rtc_tm_valid
bool rtc_tm_valid(const struct tm *t)
Verify that a time struct t contains valid data.
rtc_set_time
int rtc_set_time(struct tm *time)
Set RTC to given time.
rtc_poweron
void rtc_poweron(void)
Turns the RTC hardware module on.
rtc_mktime
uint32_t rtc_mktime(struct tm *t)
Convert time struct into timestamp.
rtc_poweroff
void rtc_poweroff(void)
Turns the RTC hardware module off.
rtc_localtime
void rtc_localtime(uint32_t time, struct tm *t)
Converts an RTC timestamp into a time struct.
rtc_alarm_cb_t
void(* rtc_alarm_cb_t)(void *arg)
Signature for alarm Callback.
Definition: rtc.h:66
rtc_get_alarm
int rtc_get_alarm(struct tm *time)
Gets the current alarm setting.
rtc_set_alarm
int rtc_set_alarm(struct tm *time, rtc_alarm_cb_t cb, void *arg)
Set an alarm for RTC to the specified value.
rtc_tm_compare
int rtc_tm_compare(const struct tm *a, const struct tm *b)
Compare two time structs.