summaryrefslogtreecommitdiff
path: root/src/common/rtc.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/rtc.h')
-rw-r--r--src/common/rtc.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/common/rtc.h b/src/common/rtc.h
new file mode 100644
index 0000000..e379370
--- /dev/null
+++ b/src/common/rtc.h
@@ -0,0 +1,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 */