rtc.h
Go to the documentation of this file.
00001 #ifndef __MSP430WARE_RTC_H__
00002 #define __MSP430WARE_RTC_H__
00003 
00004 //*****************************************************************************
00005 //
00006 //The following are the defines to include the required modules for this
00007 //peripheral in msp430xgeneric.h file
00008 //
00009 //*****************************************************************************
00010 #define __MSP430_HAS_RTC__
00011 #define __MSP430_HAS_RTC_B__
00012 
00013 //*****************************************************************************
00014 //
00015 //The following is a struct that can be passed to RTC_CalendarInit() in the
00016 //CalendarTime parameter, as well as returned by RTC_getCalendarTime()
00017 //
00018 //*****************************************************************************
00019 typedef struct {
00020     unsigned char Seconds;
00021     unsigned char Minutes;
00022     unsigned char Hours;
00023     unsigned char DayOfWeek;
00024     unsigned char DayOfMonth;
00025     unsigned char Month;
00026     unsigned int Year;
00027 } Calendar;
00028 
00029 //*****************************************************************************
00030 //
00031 //The following are values that can be passed to RTC_setCalibrationData()
00032 //in the offsetDirection parameter.
00033 //
00034 //*****************************************************************************
00035 #define RTC_CALIBRATIONFREQ_OFF   (RTCCALF_0)
00036 #define RTC_CALIBRATIONFREQ_512HZ (RTCCALF_1)
00037 #define RTC_CALIBRATIONFREQ_256HZ (RTCCALF_2)
00038 #define RTC_CALIBRATIONFREQ_1HZ   (RTCCALF_3)
00039 
00040 //*****************************************************************************
00041 //
00042 //The following are values that can be passed to RTC_setCalibrationData()
00043 //in the offsetDirection parameter.
00044 //
00045 //*****************************************************************************
00046 #define RTC_CALIBRATION_DOWN2PPM  ( !(RTCCALS) )
00047 #define RTC_CALIBRATION_UP4PPM    (RTCCALS)
00048 
00049 //*****************************************************************************
00050 //
00051 //The following are values that can be passed to RTC_setClockRegistersFormat()
00052 //in the formatSelect parameter.
00053 //
00054 //*****************************************************************************
00055 #define RTC_FORMAT_BINARY  ( !(RTCBCD) )
00056 #define RTC_FORMAT_BCD     (RTCBCD)
00057 
00058 //*****************************************************************************
00059 //
00060 //The following are values that can be passed to RTC_counterInit()
00061 //in the clockSelect parameter.
00062 //
00063 //*****************************************************************************
00064 #define RTC_CLOCKSELECT_ACLK  (RTCSSEL_0)
00065 #define RTC_CLOCKSELECT_SMCLK (RTCSSEL_1)
00066 #define RTC_CLOCKSELECT_RT1PS (RTCSSEL_2)
00067 
00068 //*****************************************************************************
00069 //
00070 //The following are values that can be passed to RTC_counterInit()
00071 //in the counterSizeSelect parameter.
00072 //
00073 //*****************************************************************************
00074 #define RTC_COUNTERSIZE_8BIT  (RTCTEV_0)
00075 #define RTC_COUNTERSIZE_16BIT (RTCTEV_1)
00076 #define RTC_COUNTERSIZE_24BIT (RTCTEV_2)
00077 #define RTC_COUNTERSIZE_32BIT (RTCTEV_3)
00078 
00079 //*****************************************************************************
00080 //
00081 //The following is a value that can be passed to RTC_setCalendarAlarm() in the
00082 //minutesAlarm, hoursAlarm, dayOfWeekAlarm, and dayOfMonthAlarm parameters.
00083 //
00084 //*****************************************************************************
00085 #define RTC_ALARMCONDITION_OFF  (0x80)
00086 
00087 //*****************************************************************************
00088 //
00089 //The following are values that can be passed to RTC_setCalendarEvent()
00090 //in the eventSelect parameter.
00091 //
00092 //*****************************************************************************
00093 #define RTC_CALENDAREVENT_MINUTECHANGE  (RTCTEV_0)
00094 #define RTC_CALENDAREVENT_HOURCHANGE    (RTCTEV_1)
00095 #define RTC_CALENDAREVENT_NOON          (RTCTEV_2)
00096 #define RTC_CALENDAREVENT_MIDNIGHT      (RTCTEV_3)
00097 
00098 //*****************************************************************************
00099 //
00100 //The following are values that can be passed to RTC_counterPrescaleInit(),
00101 //RTC_definePreScaleEvent(), RTC_readPrescaleCounterValue(), and
00102 //RTC_setPrescaleCounterValue() in the prescaleSelect parameter.
00103 //
00104 //*****************************************************************************
00105 #define RTC_PRESCALE_0  (0x0)
00106 #define RTC_PRESCALE_1  (0x2)
00107 
00108 //*****************************************************************************
00109 //
00110 //The following are values that can be passed to RTC_counterPrescaleInit()
00111 //in the prescaleClockSelect parameter.
00112 //
00113 //*****************************************************************************
00114 #define RTC_PSCLOCKSELECT_ACLK  (RT1SSEL_0)
00115 #define RTC_PSCLOCKSELECT_SMCLK (RT1SSEL_1)
00116 #define RTC_PSCLOCKSELECT_RT0PS (RT1SSEL_2)
00117 
00118 //*****************************************************************************
00119 //
00120 //The following are values that can be passed to RTC_counterPrescaleInit()
00121 //in the prescaleDivider parameter.
00122 //
00123 //*****************************************************************************
00124 #define RTC_PSDIVIDER_2   (RT0PSDIV_0)
00125 #define RTC_PSDIVIDER_4   (RT0PSDIV_1)
00126 #define RTC_PSDIVIDER_8   (RT0PSDIV_2)
00127 #define RTC_PSDIVIDER_16  (RT0PSDIV_3)
00128 #define RTC_PSDIVIDER_32  (RT0PSDIV_4)
00129 #define RTC_PSDIVIDER_64  (RT0PSDIV_5)
00130 #define RTC_PSDIVIDER_128 (RT0PSDIV_6)
00131 #define RTC_PSDIVIDER_256 (RT0PSDIV_7)
00132 
00133 //*****************************************************************************
00134 //
00135 //The following are values that can be passed to RTC_definePrescaleEvent()
00136 //in the prescaleEventDivider parameter.
00137 //
00138 //*****************************************************************************
00139 #define RTC_PSEVENTDIVIDER_2   (RT0IP_0)
00140 #define RTC_PSEVENTDIVIDER_4   (RT0IP_1)
00141 #define RTC_PSEVENTDIVIDER_8   (RT0IP_2)
00142 #define RTC_PSEVENTDIVIDER_16  (RT0IP_3)
00143 #define RTC_PSEVENTDIVIDER_32  (RT0IP_4)
00144 #define RTC_PSEVENTDIVIDER_64  (RT0IP_5)
00145 #define RTC_PSEVENTDIVIDER_128 (RT0IP_6)
00146 #define RTC_PSEVENTDIVIDER_256 (RT0IP_7)
00147 
00148 //*****************************************************************************
00149 //
00150 //The following are values that can be passed to RTC_getInterruptStatus(),
00151 //RTC_clearInterrupt(), RTC_enableInterrupt(),  RTC_disableInterrupt()
00152 //in the interruptFlagMask parameter.
00153 //
00154 //*****************************************************************************
00155 #define RTC_OSCILLATOR_FAULT_INTERRUPT  RTCOFIE   
00156 #define RTC_TIME_EVENT_INTERRUPT        RTCTEVIE  
00157 #define RTC_CLOCK_ALARM_INTERRUPT       RTCAIE    
00158 #define RTC_CLOCK_READ_READY_INTERRUPT  RTCRDYIE  
00159 #define RTC_PRESCALE_TIMER0_INTERRUPT   0x02
00160 #define RTC_PRESCALE_TIMER1_INTERRUPT   0x01
00161 
00162 
00163 //*****************************************************************************
00164 //
00165 //Prototypes for the APIs.
00166 //
00167 //*****************************************************************************
00168 extern void RTC_startClock (unsigned int baseAddress);
00169 
00170 extern void RTC_holdClock (unsigned int baseAddress);
00171 
00172 extern void RTC_setCalibrationFrequency (unsigned int baseAddress,
00173     unsigned int frequencySelect);
00174 
00175 extern void RTC_setCalibrationData (unsigned int baseAddress,
00176     unsigned char offsetDirection,
00177     unsigned char offsetValue);
00178 
00179 extern void RTC_counterInit (unsigned int baseAddress,
00180     unsigned int clockSelect,
00181     unsigned int counterSizeSelect);
00182 
00183 extern void RTC_calendarInit (unsigned int baseAddress,
00184     Calendar CalendarTime,
00185     unsigned int formatSelect);
00186 
00187 extern Calendar RTC_getCalendarTime (unsigned int baseAddress);
00188 
00189 extern void RTC_setCalendarAlarm (unsigned int baseAddress,
00190     unsigned char minutesAlarm,
00191     unsigned char hoursAlarm,
00192     unsigned char dayOfWeekAlarm,
00193     unsigned char dayOfMonthAlarm);
00194 
00195 extern void RTC_setCalendarEvent (unsigned int baseAddress,
00196     unsigned int eventSelect);
00197 
00198 extern unsigned long RTC_getCounterValue (unsigned int baseAddress);
00199 
00200 extern void RTC_setCounterValue (unsigned int baseAddress,
00201     unsigned long counterSizeSelect);
00202 
00203 extern void RTC_counterPrescaleInit (unsigned int baseAddress,
00204     unsigned char prescaleSelect,
00205     unsigned int prescaleClockSelect,
00206     unsigned int prescaleDivider);
00207 
00208 extern void RTC_counterPrescaleHold (unsigned int baseAddress,
00209     unsigned char prescaleSelect);
00210 
00211 extern void RTC_counterPrescaleStart (unsigned int baseAddress,
00212     unsigned char prescaleSelect);
00213 
00214 extern void RTC_definePrescaleEvent (unsigned int baseAddress,
00215     unsigned char prescaleSelect,
00216     unsigned char prescaleEventDivider);
00217 
00218 extern unsigned char RTC_getPrescaleValue (unsigned int baseAddress,
00219     unsigned char prescaleSelect);
00220 
00221 extern void RTC_setPrescaleValue (unsigned int baseAddress,
00222     unsigned char prescaleSelect,
00223     unsigned char prescaleCounterValue);
00224 
00225 extern void RTC_enableInterrupt (unsigned int baseAddress,
00226     unsigned char interruptMask);
00227 
00228 extern void RTC_disableInterrupt (unsigned int baseAddress,
00229     unsigned char interruptMask);
00230 
00231 extern unsigned char RTC_getInterruptStatus (unsigned int baseAddress,
00232     unsigned char interruptFlagMask);
00233 
00234 extern void RTC_clearInterrupt (unsigned int baseAddress,
00235     unsigned char interruptFlagMask);
00236 
00237 extern unsigned int RTC_convertBCDToBinary (unsigned int baseAddressu,
00238     unsigned int valueToConvert);
00239 
00240 extern unsigned int RTC_convertBinaryToBCD (unsigned int baseAddress,
00241     unsigned int valueToConvert);
00242 
00243 #endif

Copyright 2012, Texas Instruments Incorporated