Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00016
00017
00018
00019
00020
00021
00022
00023
00024
00048 #ifndef _CSL_RTC_H_
00049 #define _CSL_RTC_H_
00050
00051 #ifdef __cplusplus
00052 extern "C" {
00053 #endif
00054
00055 #include "cslr.h"
00056 #include "csl_error.h"
00057 #include "csl_types.h"
00058 #include "soc.h"
00059 #include "csl_general.h"
00060
00086
00087
00088
00089
00093 #define CSL_RTC_BIT_SET (1u)
00094
00095 #define CSL_RTC_BIT_RESET (0)
00096
00097 #define CSL_RTC_WAIT_CYCLE (50u)
00098
00099 #define CSL_RTC_SCRATCH1_MASK (0x8000u)
00100
00101 #define CSL_RTC_STATUS_MASK (0x803Fu)
00102
00103 #define CSL_RTC_DISPATCH_TABLE_SIZE (0x07u)
00104
00105 #define CSL_RTC_COMPENSATION_MAX (1024u)
00106
00107 #define CSL_RTC_TIME_OUT (0x1FFu)
00108
00112
00113
00114
00115
00125 typedef enum
00126 {
00127 CSL_RTC_DAY_PERIODIC_INTERRUPT,
00128 CSL_RTC_HR_PERIODIC_INTERRUPT,
00129 CSL_RTC_MINS_PERIODIC_INTERRUPT,
00130 CSL_RTC_SEC_PERIODIC_INTERRUPT,
00131 CSL_RTC_MS_PERIODIC_INTERRUPT
00132 } CSL_RTCPeriodicInterruptType;
00133
00140 typedef enum
00141 {
00142 CSL_RTC_MSEVENT_INTERRUPT,
00143 CSL_RTC_SECEVENT_INTERRUPT,
00144 CSL_RTC_MINSEVENT_INTERRUPT,
00145 CSL_RTC_HREVENT_INTERRUPT,
00146 CSL_RTC_DAYEVENT_INTERRUPT,
00147 CSL_RTC_EXTEVENT_INTERRUPT,
00148 CSL_RTC_ALARM_INTERRUPT,
00149 CSL_RTC_INTERRUPT_NONE
00150 } CSL_RTCEventType;
00151
00156 typedef enum
00157 {
00158 CSL_RTC_COMPENSATION_NEGATIVE = 0,
00159 CSL_RTC_COMPENSATION_POSITIVE,
00160 CSL_RTC_COMPENSATION_INVALID
00161 } CSL_RTCCompType;
00162
00174 typedef struct {
00175 Uint16 rtcmSec;
00176 Uint16 rtcsec;
00177 Uint16 rtcmin;
00178 Uint16 rtchour;
00179 Uint16 rtcday;
00180 Uint16 rtcmonth;
00181 Uint16 rtcyear;
00182 Uint16 rtcmSeca;
00183 Uint16 rtcseca;
00184 Uint16 rtcmina;
00185 Uint16 rtchoura;
00186 Uint16 rtcdaya;
00187 Uint16 rtcmontha;
00188 Uint16 rtcyeara;
00189 Uint16 rtcintcr;
00190 } CSL_RtcConfig;
00191
00196 typedef struct
00197 {
00198 Uint16 year;
00199 Uint16 month;
00200 Uint16 day;
00201 } CSL_RtcDate;
00202
00207 typedef struct {
00208 Uint16 hours;
00209 Uint16 mins;
00210 Uint16 secs;
00211 Uint16 mSecs;
00212 } CSL_RtcTime;
00213
00218 typedef struct {
00219 Uint16 year;
00220 Uint16 month;
00221 Uint16 day;
00222 Uint16 hours;
00223 Uint16 mins;
00224 Uint16 secs;
00225 Uint16 mSecs;
00226 } CSL_RtcAlarm;
00227
00231 typedef struct
00232 {
00233 void (*MilEvtAddr)(void);
00234 void (*SecEvtAddr)(void);
00235 void (*MinEvtAddr)(void);
00236 void (*HourEvtAddr)(void);
00237 void (*DayEvtAddr)(void);
00238 void (*ExtEvtAddr)(void);
00239 void (*AlarmEvtAddr)(void);
00240 } CSL_RtcIsrAddr;
00241
00246 typedef void (* CSL_RTCCallBackPtr)(void);
00247
00252 typedef struct {
00254 CSL_RTCCallBackPtr isr[CSL_RTC_DISPATCH_TABLE_SIZE];
00255 } CSL_RtcIsrDispatchTable;
00256
00260
00261
00262
00292 static inline
00293 Uint16 rtcDivFun(
00294 Uint16 dividend,
00295 Uint16 divisor )
00296 {
00297 Uint16 quoitient;
00298
00299 quoitient = 0;
00300 while (dividend >= divisor)
00301 {
00302 quoitient++;
00303 dividend = dividend - divisor;
00304 }
00305 return quoitient;
00306 }
00307
00334 static inline
00335 Uint16 rtcModuloDivFun(
00336 Uint16 dividend,
00337 Uint16 divisor )
00338 {
00339 while (dividend >= divisor)
00340 {
00341 dividend = dividend - divisor;
00342 }
00343 return dividend;
00344 }
00378 static inline
00379 Uint16 rtc_pow(
00380 Uint16 var,
00381 Uint16 pow )
00382 {
00383 Uint16 result;
00384 Uint16 looper;
00385
00386 result = 1;
00387 for (looper = 0 ; looper < pow; looper++)
00388 {
00389 result = result * var;
00390 }
00391 return result;
00392 }
00393
00397
00398
00399
00432 void RTC_reset(void);
00433
00463 void RTC_start(void);
00464
00494 void RTC_stop(void);
00495
00550 CSL_Status RTC_config (
00551 CSL_RtcConfig *pConfig);
00552
00589 CSL_Status RTC_getConfig (
00590 CSL_RtcConfig *pGetConfig);
00591
00634 CSL_Status RTC_setTime (
00635 CSL_RtcTime *pRtcTime);
00636
00673 CSL_Status RTC_getTime (
00674 CSL_RtcTime *pGetRtcTime);
00675
00717 CSL_Status RTC_setDate (
00718 CSL_RtcDate *pRtcDate);
00719
00756 CSL_Status RTC_getDate (
00757 CSL_RtcDate *pGetRtcDate);
00758
00803 CSL_Status RTC_setAlarm (
00804 CSL_RtcAlarm *pRtcAlarm);
00805
00844 CSL_Status RTC_setPeriodicInterval (
00845 CSL_RTCPeriodicInterruptType periodicInterruptType);
00846
00885 CSL_Status RTC_eventEnable (
00886 CSL_RTCEventType rtcEvent);
00887
00926 CSL_Status RTC_eventDisable (
00927 CSL_RTCEventType rtcEvent);
00928
00960 CSL_RTCEventType RTC_getEventId(void);
00961
00998 Uint16 RTC_decToBcd (
00999 Uint16 decVal);
01000
01038 Uint16 RTC_bcdToDec (
01039 Uint16 hexVal);
01040
01076 CSL_Status RTC_setCallback(
01077 CSL_RtcIsrDispatchTable *rtcDispatchTable,
01078 CSL_RtcIsrAddr *isrAddr );
01079
01129 CSL_Status RTC_setCompensation(CSL_RTCCompType compType,
01130 Uint16 compVal);
01131
01132
01137 #ifdef __cplusplus
01138 }
01139 #endif
01140 #endif
01141