openchronos-ng
opensource firmware for the ez430 chronos
|
00001 /* 00002 rtca.h: TI CC430 Hardware Realtime Clock (RTC_A) 00003 00004 Copyright (C) 2011-2012 Angelo Arrifano <miknix@gmail.com> 00005 00006 This program is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #ifndef __RTCA_H__ 00021 #define __RTCA_H__ 00022 00023 #include <openchronos.h> 00024 00025 enum rtca_tevent{ 00026 RTCA_EV_ALARM = BIT0, 00027 RTCA_EV_MINUTE = BIT1, 00028 RTCA_EV_HOUR = BIT2, 00029 RTCA_EV_DAY = BIT3, 00030 RTCA_EV_MONTH = BIT4, 00031 RTCA_EV_YEAR = BIT5 00032 }; 00033 00034 #define rtca_stop() RTCCTL01 |= RTCHOLD 00035 #define rtca_start() RTCCTL01 &= ~RTCHOLD 00036 00037 /* the ev variable holds the time event, see enum rtca_tevent for more info. 00038 please add -fshort-enums to CFLAGS to store rtca_tevent as only a byte */ 00039 void rtca_init(void); 00040 00041 void rtca_tevent_fn_register(void (*fn)(enum rtca_tevent)); 00042 void rtca_tevent_fn_unregister(void (*fn)(enum rtca_tevent)); 00043 00044 uint8_t rtca_get_max_days(uint8_t month, uint16_t year); 00045 uint32_t rtca_get_systime(void); 00046 00047 void rtca_get_time(uint8_t *hour, uint8_t *min, uint8_t *sec); 00048 void rtca_set_time(uint8_t hour, uint8_t min, uint8_t sec); 00049 00050 void rtca_get_date( 00051 uint16_t *year, 00052 uint8_t *mon, 00053 uint8_t *day, 00054 uint8_t *dow, 00055 char const **dow_str 00056 ); 00057 void rtca_set_date(uint16_t year, uint8_t mon, uint8_t day); 00058 00059 void rtca_get_alarm(uint8_t *hour, uint8_t *min); 00060 void rtca_set_alarm(uint8_t hour, uint8_t min); 00061 00062 void rtca_enable_alarm(); 00063 void rtca_disable_alarm(); 00064 00065 /* exclusive use by openchronos system */ 00066 volatile enum rtca_tevent rtca_last_event; 00067 00068 #endif /* __RTCA_H__ */