00001 /* ---------------------------------------------------------------------------- */ 00002 /* Atmel Microcontroller Software Support */ 00003 /* SAM Software Package License */ 00004 /* ---------------------------------------------------------------------------- */ 00005 /* Copyright (c) 2015, Atmel Corporation */ 00006 /* */ 00007 /* All rights reserved. */ 00008 /* */ 00009 /* Redistribution and use in source and binary forms, with or without */ 00010 /* modification, are permitted provided that the following condition is met: */ 00011 /* */ 00012 /* - Redistributions of source code must retain the above copyright notice, */ 00013 /* this list of conditions and the disclaimer below. */ 00014 /* */ 00015 /* Atmel's name may not be used to endorse or promote products derived from */ 00016 /* this software without specific prior written permission. */ 00017 /* */ 00018 /* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR */ 00019 /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ 00020 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE */ 00021 /* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, */ 00022 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ 00023 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ 00024 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */ 00025 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ 00026 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */ 00027 /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 00028 /* ---------------------------------------------------------------------------- */ 00029 00030 /** 00031 * \file 00032 * 00033 * Interface for Real Time Clock (RTC) controller. 00034 * 00035 */ 00036 00037 #ifndef _RTC_ 00038 #define _RTC_ 00039 00040 /*---------------------------------------------------------------------------- 00041 * Headers 00042 *----------------------------------------------------------------------------*/ 00043 #include "chip.h" 00044 00045 #include <stdint.h> 00046 00047 /*---------------------------------------------------------------------------- 00048 * Definitions 00049 *----------------------------------------------------------------------------*/ 00050 00051 #define RTC_HOUR_BIT_LEN_MASK 0x3F 00052 #define RTC_MIN_BIT_LEN_MASK 0x7F 00053 #define RTC_SEC_BIT_LEN_MASK 0x7F 00054 #define RTC_CENT_BIT_LEN_MASK 0x7F 00055 #define RTC_YEAR_BIT_LEN_MASK 0xFF 00056 #define RTC_MONTH_BIT_LEN_MASK 0x1F 00057 #define RTC_DATE_BIT_LEN_MASK 0x3F 00058 #define RTC_WEEK_BIT_LEN_MASK 0x07 00059 00060 /*---------------------------------------------------------------------------- 00061 * Exported functions 00062 *----------------------------------------------------------------------------*/ 00063 00064 #ifdef __cplusplus 00065 extern "C" { 00066 #endif 00067 00068 extern void RTC_SetHourMode(Rtc *pRtc, uint32_t dwMode); 00069 00070 extern uint32_t RTC_GetHourMode(Rtc *pRtc); 00071 00072 extern void RTC_EnableIt(Rtc *pRtc, uint32_t dwSources); 00073 00074 extern void RTC_DisableIt(Rtc *pRtc, uint32_t dwSources); 00075 00076 extern int RTC_SetTime(Rtc *pRtc, uint8_t ucHour, uint8_t ucMinute, 00077 uint8_t ucSecond); 00078 00079 extern void RTC_GetTime(Rtc *pRtc, uint8_t *pucHour, uint8_t *pucMinute, 00080 uint8_t *pucSecond); 00081 00082 extern int RTC_SetTimeAlarm(Rtc *pRtc, uint8_t *pucHour, uint8_t *pucMinute, 00083 uint8_t *pucSecond); 00084 00085 extern void RTC_GetDate(Rtc *pRtc, uint16_t *pwYear, uint8_t *pucMonth, 00086 uint8_t *pucDay, uint8_t *pucWeek); 00087 00088 extern int RTC_SetDate(Rtc *pRtc, uint16_t wYear, uint8_t ucMonth, 00089 uint8_t ucDay, uint8_t ucWeek); 00090 00091 extern int RTC_SetDateAlarm(Rtc *pRtc, uint8_t *pucMonth, uint8_t *pucDay); 00092 00093 extern void RTC_ClearSCCR(Rtc *pRtc, uint32_t dwMask); 00094 00095 extern uint32_t RTC_GetSR(Rtc *pRtc, uint32_t dwMask); 00096 00097 #ifdef __cplusplus 00098 } 00099 #endif 00100 00101 #endif /* #ifndef _RTC_ */ 00102