summaryrefslogtreecommitdiff
path: root/src/common/rtc.h
blob: e3793700d80f571773672f3e2739815436a45460 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef rtc_h
#define rtc_h
/* rtc.h */
/* binwatch - Tiny binary wristwatch. {{{
 *
 * Copyright (C) 2010 Nicolas Schodet
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 * Contact :
 *        Web: http://ni.fr.eu.org/
 *      Email: <nico at ni.fr.eu.org>
 * }}} */

/** Value returned by rtc_init on low voltage detection. */
#define RTC_LOW_VOLTAGE 2

/** Initialise RTC, return 0 on failure, 1 on success, RTC_LOW_VOLTAGE on
 * success with low voltage detected. */
uint8_t
rtc_init (void);

/** Get current timer. */
void
rtc_get_time (uint8_t *hour, uint8_t *minute, uint8_t *second);

/** Get current date. */
void
rtc_get_date (uint16_t *year, uint8_t *month, uint8_t *weekday, uint8_t *day);

/** Stop RTC, needed before time or date is changed. */
void
rtc_stop (void);

/** Resume RTC operation. */
void
rtc_go (void);

/** Set current time. */
void
rtc_set_time (uint8_t hour, uint8_t minute, uint8_t second);

/** Set current date. */
void
rtc_set_date (uint16_t year, uint8_t month, uint8_t weekday, uint8_t day);

#endif /* rtc_h */