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 
9 #pragma once
10 
39 #include <stdbool.h>
40 #include <stdint.h>
41 #include <time.h>
42 #include "rtc_utils.h"
43 #include "periph_conf.h"
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 #if !defined(RIOT_EPOCH) || DOXYGEN
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 
104 int rtc_get_time_ms(struct tm *time, uint16_t *ms);
105 
124 int rtc_set_alarm(struct tm *time, rtc_alarm_cb_t cb, void *arg);
125 
134 int rtc_get_alarm(struct tm *time);
135 
139 void rtc_clear_alarm(void);
140 
144 void rtc_poweron(void);
145 
149 void rtc_poweroff(void);
150 
151 #ifdef __cplusplus
152 }
153 #endif
154 
void(* rtc_alarm_cb_t)(void *arg)
Signature for alarm Callback.
Definition: rtc.h:66
int rtc_set_alarm(struct tm *time, rtc_alarm_cb_t cb, void *arg)
Set an alarm for RTC to the specified value.
int rtc_get_alarm(struct tm *time)
Gets the current alarm setting.
void rtc_poweroff(void)
Turns the RTC hardware module off.
int rtc_set_time(struct tm *time)
Set RTC to given time.
void rtc_clear_alarm(void)
Clear any set alarm, do nothing if nothing set.
int rtc_get_time(struct tm *time)
Get current RTC time.
void rtc_init(void)
Initialize RTC module.
void rtc_poweron(void)
Turns the RTC hardware module on.
int rtc_get_time_ms(struct tm *time, uint16_t *ms)
Get current RTC time with sub-second component.