RTC
|
RTC.h
Go to the documentation of this file.
00001 00053 #ifndef RTC_H 00054 #define RTC_H 00055 00056 00057 /*********************************************************************************************************************** 00058 * HEADER FILES 00059 **********************************************************************************************************************/ 00060 #include <xmc_scu.h> 00061 #include <xmc_rtc.h> 00062 #include "rtc_conf.h" 00063 #include <DAVE_Common.h> 00064 00065 /*********************************************************************************************************************** 00066 * MACROS 00067 **********************************************************************************************************************/ 00068 #if (!((XMC_LIB_MAJOR_VERSION == 2U) && \ 00069 (XMC_LIB_MINOR_VERSION >= 0U) && \ 00070 (XMC_LIB_PATCH_VERSION >= 0U))) 00071 #error "RTC APP requires XMC Peripheral Library v2.0.0 or higher" 00072 #endif 00073 00074 /*********************************************************************************************************************** 00075 * ENUMS 00076 **********************************************************************************************************************/ 00082 typedef enum RTC_STATUS 00083 { 00084 RTC_STATUS_SUCCESS = 0U, 00085 RTC_STATUS_FAILURE = 1U 00086 } RTC_STATUS_t; 00087 00092 typedef enum RTC_START 00093 { 00094 RTC_START_DISABLE = 0x0U, 00095 RTC_START_ENABLE = 0x1U 00096 } RTC_START_t; 00097 00098 00104 typedef enum RTC_INT 00105 { 00106 RTC_INT_PERIODIC_SEC_DISABLE = 0x0U, 00107 RTC_INT_PERIODIC_SEC_ENABLE = 0x1U, 00108 RTC_INT_PERIODIC_MIN_DISABLE = 0x0U, 00109 RTC_INT_PERIODIC_MIN_ENABLE = 0x1U, 00110 RTC_INT_PERIODIC_HOUR_DISABLE = 0x0U, 00111 RTC_INT_PERIODIC_HOUR_ENABLE = 0x1U, 00112 RTC_INT_PERIODIC_DAY_DISABLE = 0x0U, 00113 RTC_INT_PERIODIC_DAY_ENABLE = 0x1U, 00114 RTC_INT_PERIODIC_MONTH_DISABLE = 0x0U, 00115 RTC_INT_PERIODIC_MONTH_ENABLE = 0x1U, 00116 RTC_INT_PERIODIC_YEAR_DISABLE = 0x0U, 00117 RTC_INT_PERIODIC_YEAR_ENABLE = 0x1U, 00118 RTC_INT_ALARM_DISABLE = 0x0U, 00119 RTC_INT_ALARM_ENABLE = 0x1U 00120 } RTC_INT_t; 00121 00122 /*********************************************************************************************************************** 00123 * DATA STRUCTURES 00124 ***********************************************************************************************************************/ 00134 typedef struct RTC_CONFIG 00135 { 00136 RTC_START_t start; 00138 RTC_INT_t periodic_sec_intr; 00139 RTC_INT_t periodic_min_intr; 00140 RTC_INT_t periodic_hour_intr; 00141 RTC_INT_t periodic_day_intr; 00142 RTC_INT_t periodic_month_intr; 00143 RTC_INT_t periodic_year_intr; 00145 RTC_INT_t alarm_intr; 00147 #if ((UC_FAMILY == XMC4) && (RTC_INTERRUPT_ENABLED == 1)) 00148 GLOBAL_SCU_XMC4_EVENT_HANDLER_t pi_listener; 00149 GLOBAL_SCU_XMC4_EVENT_HANDLER_t ai_listener; 00150 #endif 00151 00152 #if ((UC_FAMILY == XMC1) && (RTC_INTERRUPT_ENABLED == 1)) 00153 GLOBAL_SCU_XMC1_EVENT_HANDLER_t pi_listener; 00154 GLOBAL_SCU_XMC1_EVENT_HANDLER_t ai_listener; 00155 #endif 00156 } RTC_CONFIG_t; 00157 00161 typedef struct RealTimeClock 00162 { 00163 const XMC_RTC_CONFIG_t *const time_alarm_config; 00164 const RTC_CONFIG_t *const config; 00165 bool initialized; 00166 } RTC_t; 00171 #ifdef __cplusplus 00172 extern "C" { 00173 #endif 00174 /********************************************************************************************************************** 00175 * API PROTOTYPES 00176 ***********************************************************************************************************************/ 00177 00206 DAVE_APP_VERSION_t RTC_GetAppVersion(void); 00207 00208 00231 RTC_STATUS_t RTC_Init(RTC_t *const handle); 00232 00258 RTC_STATUS_t RTC_Time(time_t* time_value) ; 00259 00288 __STATIC_INLINE void RTC_Start(void) 00289 { 00290 XMC_RTC_Start(); 00291 } 00292 00324 __STATIC_INLINE void RTC_Stop(void) 00325 { 00326 XMC_RTC_Stop(); 00327 } 00328 00363 RTC_STATUS_t RTC_SetTime(XMC_RTC_TIME_t *time); 00398 RTC_STATUS_t RTC_SetAlarmTime(XMC_RTC_ALARM_t *alarm); 00434 void RTC_GetTime(XMC_RTC_TIME_t *time); 00469 void RTC_GetAlarmTime(XMC_RTC_ALARM_t *alarm); 00490 uint32_t RTC_GetFlagStatus(void); 00491 00496 #include "rtc_extern.h" 00497 00498 #ifdef __cplusplus 00499 } 00500 #endif 00501 00502 #endif 00503 00504