timerd.h
Go to the documentation of this file.
00001 #ifndef __MSP430WARE_TIMERD_H__
00002 #define __MSP430WARE_TIMERD_H__
00003 
00004 #define __MSP430_HAS_TxD7__
00005 //*****************************************************************************
00006 //
00007 //The following are values that can be passed to the
00008 //TimerD_startContinuousMode(), TimerD_startUpMode(), TimerD_startUpDownMode(),
00009 //TimerD_generatePWM() APIs as the clockSource parameter.
00010 //
00011 //*****************************************************************************
00012 #define TIMERD_CLOCKSOURCE_EXTERNAL_TDCLK            TDSSEL__TACLK
00013 #define TIMERD_CLOCKSOURCE_ACLK                      TDSSEL__ACLK
00014 #define TIMERD_CLOCKSOURCE_SMCLK                     TDSSEL__SMCLK
00015 #define TIMERD_CLOCKSOURCE_INVERTED_EXTERNAL_TDCLK   TDSSEL__INCLK
00016 
00017 //*****************************************************************************
00018 //
00019 //The following are values that can be passed to the
00020 //TimerD_startContinuousMode(), TimerD_startUpMode(), TimerD_startUpDownMode(),
00021 //TimerD_generatePWM() APIs as the clockSource parameter.
00022 //
00023 //*****************************************************************************
00024 #define TIMERD_CLOCKINGMODE_EXTERNAL_CLOCK                      TDCLKM_0
00025 #define TIMERD_CLOCKINGMODE_HIRES_LOCAL_CLOCK                   TDCLKM_1
00026 #define TIMERD_CLOCKINGMODE_AUXILIARY_CLK                       TDCLKM_2
00027 
00028 //*****************************************************************************
00029 //
00030 //The following are values that can be passed to the
00031 //TimerD_configureHighResGeneratorInRegulatedMode()
00032 // API as the highResMultiplyFactor parameter.
00033 //
00034 //*****************************************************************************
00035 #define TIMERD_HIGHRES_CLK_MULTIPLY_FACTOR_8x   TDHM_0
00036 #define TIMERD_HIGHRES_CLK_MULTIPLY_FACTOR_16x  TDHM_1
00037 
00038 //*****************************************************************************
00039 //
00040 //The following are values that can be passed to the
00041 //TimerD_startContinuousMode(), TimerD_startUpMode(), TimerD_startUpDownMode(),
00042 //TimerD_generatePWM() APIs as the clockSourceDivider parameter.
00043 //
00044 //*****************************************************************************
00045 #define TIMERD_CLOCKSOURCE_DIVIDER_1     0x01
00046 #define TIMERD_CLOCKSOURCE_DIVIDER_2     0x02
00047 #define TIMERD_CLOCKSOURCE_DIVIDER_4     0x04
00048 #define TIMERD_CLOCKSOURCE_DIVIDER_8     0x08
00049 #define TIMERD_CLOCKSOURCE_DIVIDER_3     0x03
00050 #define TIMERD_CLOCKSOURCE_DIVIDER_5     0x05
00051 #define TIMERD_CLOCKSOURCE_DIVIDER_6     0x06
00052 #define TIMERD_CLOCKSOURCE_DIVIDER_7     0x07
00053 #define TIMERD_CLOCKSOURCE_DIVIDER_10    0x0A
00054 #define TIMERD_CLOCKSOURCE_DIVIDER_12    0x0C
00055 #define TIMERD_CLOCKSOURCE_DIVIDER_14    0x0E
00056 #define TIMERD_CLOCKSOURCE_DIVIDER_16    0x10
00057 #define TIMERD_CLOCKSOURCE_DIVIDER_20    0x14
00058 #define TIMERD_CLOCKSOURCE_DIVIDER_24    0x18
00059 #define TIMERD_CLOCKSOURCE_DIVIDER_28    0x1C
00060 #define TIMERD_CLOCKSOURCE_DIVIDER_32    0x20
00061 #define TIMERD_CLOCKSOURCE_DIVIDER_40    0x28
00062 #define TIMERD_CLOCKSOURCE_DIVIDER_48    0x30
00063 #define TIMERD_CLOCKSOURCE_DIVIDER_56    0x38
00064 #define TIMERD_CLOCKSOURCE_DIVIDER_64    0x40
00065 
00066 //*****************************************************************************
00067 //
00068 //The following are values that can be passed to TimerD_startContinuousMode()
00069 //TimerD_startUpMode(),  TimerD_startUpDownMode() as the timerClear parameter.
00070 //
00071 //*****************************************************************************
00072 #define TIMERD_DO_CLEAR      TDCLR
00073 #define TIMERD_SKIP_CLEAR    0x00
00074 
00075 //*****************************************************************************
00076 //
00077 //The following are values that can be passed to the
00078 //TimerD_getSynchronizedCaptureCompareInput() API as the synchronized
00079 //parameter.
00080 //
00081 //*****************************************************************************
00082 #define TIMERD_CAPTURECOMPARE_INPUT     CCI
00083 
00084 //*****************************************************************************
00085 //
00086 //The following are values that is returned by the
00087 //TimerD_getSynchronizedCaptureCompareInput() API
00088 //
00089 //*****************************************************************************
00090 #define TIMERD_CAPTURECOMPARE_INPUT_HIGH    0x01
00091 #define TIMERD_CAPTURECOMPARE_INPUT_LOW     0x00
00092 
00093 
00094 //*****************************************************************************
00095 //
00096 //The following are values that is returned by the
00097 //TimerD_getOutputForOutputModeOutBitValue() and passed to
00098 //TimerD_setOutputForOutputModeOutBitValue() as
00099 //outputModeOutBitValue parameter
00100 //
00101 //*****************************************************************************
00102 #define TIMERD_OUTPUTMODE_OUTBITVALUE_HIGH    OUT
00103 #define TIMERD_OUTPUTMODE_OUTBITVALUE_LOW     0x00
00104 
00105 //*****************************************************************************
00106 //
00107 //The following are values can be passed to the mask parameter of
00108 //TimerD_captureCompareInterruptStatus() API
00109 //
00110 //*****************************************************************************
00111 #define TIMERD_CAPTURE_OVERFLOW                  COV
00112 #define TIMERD_CAPTURECOMPARE_INTERRUPT_FLAG     CCIFG
00113 
00114 //*****************************************************************************
00115 //
00116 //The following are values can be passed to the mask parameter of
00117 //TimerD_enableHighResInterrupt(), TimerD_getHighResInterruptStatus(),
00118 // TimerD_disableHighResInterrupt() API
00119 //
00120 //*****************************************************************************
00121 #define TIMERD_HIGH_RES_FREQUENCY_UNLOCK   TDHUNLKIE
00122 #define TIMERD_HIGH_RES_FREQUENCY_LOCK     TDHLKIE
00123 #define TIMERD_HIGH_RES_FAIL_HIGH          TDHFHIE
00124 #define TIMERD_HIGH_RES_FAIL_LOW          TDHFLIE
00125 
00126 //*****************************************************************************
00127 //
00128 //The following are values can be passed to the timerInterruptEnable_TDIE
00129 //parameter of TimerD_startContinuousMode(), TimerD_startUpMode(),
00130 //TimerD_startUpDownMode()
00131 //
00132 //*****************************************************************************
00133 #define TIMERD_TDIE_INTERRUPT_ENABLE            TDIE
00134 #define TIMERD_TDIE_INTERRUPT_DISABLE           0x00
00135 
00136 //*****************************************************************************
00137 //
00138 //The following are values can be passed to the
00139 //captureCompareInterruptEnable_CCR0_CCIE parameter of TimerD_startUpMode(),
00140 //TimerD_startUpDownMode API
00141 //
00142 //*****************************************************************************
00143 #define TIMERD_CCIE_CCR0_INTERRUPT_ENABLE   CCIE
00144 #define TIMERD_CCIE_CCR0_INTERRUPT_DISABLE  0x00
00145 
00146 //*****************************************************************************
00147 //
00148 //The following are timer modes possible.
00149 //
00150 //*****************************************************************************
00151 #define TIMERD_STOP_MODE         MC_0
00152 #define TIMERD_UP_MODE           MC_1
00153 #define TIMERD_CONTINUOUS_MODE   MC_2
00154 #define TIMERD_UPDOWN_MODE       MC_3
00155 
00156 //*****************************************************************************
00157 //
00158 //The following are values can be passed to the
00159 //compareRegister, captureCompareRegister or captureRegister parameter
00160 //of TimerD_initCapture(), TimerD_enableCaptureCompareInterrupt(),
00161 //TimerD_disableCaptureCompareInterrupt(),TimerD_captureCompareInterruptStatus(),
00162 //TimerD_getSynchronizedCaptureCompareInput(),TimerD_initCompare()
00163 //
00164 //*****************************************************************************
00165 #define TIMERD_CAPTURECOMPARE_REGISTER_0     0x08
00166 #define TIMERD_CAPTURECOMPARE_REGISTER_1     0x0E
00167 #define TIMERD_CAPTURECOMPARE_REGISTER_2     0x14
00168 #define TIMERD_CAPTURECOMPARE_REGISTER_3     0x1A
00169 #define TIMERD_CAPTURECOMPARE_REGISTER_4     0x20
00170 #define TIMERD_CAPTURECOMPARE_REGISTER_5     0x28
00171 #define TIMERD_CAPTURECOMPARE_REGISTER_6     0x2E
00172 
00173 //*****************************************************************************
00174 //
00175 //The following are values can be passed to the
00176 //captureMode parameter of TimerD_initCompare(), TimerD_initCapture(),
00177 //TimerD_generatePWM(),
00178 //
00179 //*****************************************************************************
00180 #define TIMERD_OUTPUTMODE_OUTBITVALUE        OUTMOD_0
00181 #define TIMERD_OUTPUTMODE_SET                OUTMOD_1
00182 #define TIMERD_OUTPUTMODE_TOGGLE_RESET       OUTMOD_2
00183 #define TIMERD_OUTPUTMODE_SET_RESET          OUTMOD_3
00184 #define TIMERD_OUTPUTMODE_TOGGLE             OUTMOD_4
00185 #define TIMERD_OUTPUTMODE_RESET              OUTMOD_5
00186 #define TIMERD_OUTPUTMODE_TOGGLE_SET         OUTMOD_6
00187 #define TIMERD_OUTPUTMODE_RESET_SET          OUTMOD_7
00188 
00189 //*****************************************************************************
00190 //
00191 //The following are values can be passed to the
00192 //captureMode parameter of TimerD_initCapture() API
00193 //
00194 //*****************************************************************************
00195 #define TIMERD_CAPTUREMODE_NO_CAPTURE                CM_0
00196 #define TIMERD_CAPTUREMODE_RISING_EDGE               CM_1
00197 #define TIMERD_CAPTUREMODE_FALLING_EDGE              CM_2
00198 #define TIMERD_CAPTUREMODE_RISING_AND_FALLING_EDGE   CM_3
00199 
00200 //*****************************************************************************
00201 //
00202 //The following are values can be passed to the
00203 //synchronizeCaptureSource parameter of TimerD_initCapture() API
00204 //
00205 //*****************************************************************************
00206 #define TIMERD_CAPTURE_ASYNCHRONOUS                  0x00
00207 #define TIMERD_CAPTURE_SYNCHRONOUS                   SCS
00208 
00209 //*****************************************************************************
00210 //
00211 //The following are values can be passed to the
00212 //channelCaptureMode parameter of TimerD_initCapture() API
00213 //
00214 //*****************************************************************************
00215 #define TIMERD_SINGLE_CAPTURE_MODE                 0x00
00216 #define TIMERD_DUAL_CAPTURE_MODE                   0x01
00217 //*****************************************************************************
00218 //
00219 //The following are values can be passed to the
00220 //captureInterruptEnable, compareInterruptEnable parameter of
00221 //TimerD_initCapture() API
00222 //
00223 //*****************************************************************************
00224 #define TIMERD_CAPTURECOMPARE_INTERRUPT_ENABLE       CCIE
00225 #define TIMERD_CAPTURECOMPARE_INTERRUPT_DISABLE      0x00
00226 
00227 //*****************************************************************************
00228 //
00229 //The following are values can be passed to the
00230 //captureInputSelect parameter of TimerD_initCapture() API
00231 //
00232 //*****************************************************************************
00233 #define TIMERD_CAPTURE_INPUTSELECT_CCIxA             CCIS_0
00234 #define TIMERD_CAPTURE_INPUTSELECT_CCIxB             CCIS_1
00235 #define TIMERD_CAPTURE_INPUTSELECT_GND               CCIS_2
00236 #define TIMERD_CAPTURE_INPUTSELECT_Vcc               CCIS_3
00237 
00238 //*****************************************************************************
00239 //
00240 //The following are values that may be returned by
00241 //TimerD_getInterruptStatus() API
00242 //
00243 //*****************************************************************************
00244 #define TIMERD_INTERRUPT_NOT_PENDING     0x00
00245 #define TIMERD_INTERRUPT_PENDING         0x01
00246 
00247 //*****************************************************************************
00248 //
00249 //The following are values can be passed to the
00250 //synchronized parameter of TimerD_getSynchronizedCaptureCompareInput() API
00251 //
00252 //*****************************************************************************
00253 #define TIMERD_READ_SYNCHRONIZED_CAPTURECOMPAREINPUT SCCI
00254 #define TIMERD_READ_CAPTURE_COMPARE_INPUT            CCI
00255 
00256 //*****************************************************************************
00257 //
00258 //The following are values can be passed to the
00259 //desiredHighResFrequency parameter of 
00260 //TimerD_configureHighResGeneratorInFreeRunningMode() API
00261 //
00262 //*****************************************************************************
00263 #define TIMERD_HIGHRES_64MHZ    0x00
00264 #define TIMERD_HIGHRES_128MHZ   0x01
00265 #define TIMERD_HIGHRES_200MHZ   0x02
00266 #define TIMERD_HIGHRES_256MHZ   0x03   
00267 
00268 //*****************************************************************************
00269 //
00270 //The following are values can be passed to the
00271 //TDOutput parameter of 
00272 //TimerD_combineTDCCRToGeneratePWM() API
00273 //
00274 //*****************************************************************************
00275 #define TIMERD_COMBINE_CCR1_CCR2        2
00276 #define TIMERD_COMBINE_CCR3_CCR4        4
00277 #define TIMERD_COMBINE_CCR5_CCR6        6
00278 
00279 //*****************************************************************************
00280 //
00281 //The following are values can be passed to the highResCoarseClockRange
00282 //parameter of  TimerD_selectHighResClockRange() API
00283 //
00284 //*****************************************************************************
00285 #define TIMERD_CLOCK_RANGE0             0x0000
00286 #define TIMERD_CLOCK_RANGE1                     0x2000
00287 #define TIMERD_CLOCK_RANGE2                     0x4000
00288 
00289 //*****************************************************************************
00290 //
00291 //The following are values can be passed to the
00292 //TDOutput parameter of
00293 //TimerD_selectHighResCoarseClockRange() API
00294 //
00295 //*****************************************************************************
00296 #define TIMERD_HIGHRES_BELOW_15MHz  0x00
00297 #define TIMERD_HIGHRES_ABOVE_15MHz  TDHCLKCR
00298 
00299 
00300 
00301 
00302 //*****************************************************************************
00303 //
00304 //Prototypes for the APIs.
00305 //
00306 //*****************************************************************************
00307 extern void TimerD_startCounter ( unsigned int baseAddress,
00308     unsigned int timerMode
00309     );
00310 extern void TimerD_configureContinuousMode ( unsigned int baseAddress,
00311     unsigned int clockSource,
00312     unsigned int clockSourceDivider,
00313     unsigned int clockingMode,
00314     unsigned int timerInterruptEnable_TDIE,
00315     unsigned int timerClear
00316     );
00317 extern void TimerD_configureUpMode (   unsigned int baseAddress,
00318     unsigned int clockSource,
00319     unsigned int clockSourceDivider,
00320     unsigned int clockingMode,
00321     unsigned int timerPeriod,
00322     unsigned int timerInterruptEnable_TDIE,
00323     unsigned int captureCompareInterruptEnable_CCR0_CCIE,
00324     unsigned int timerClear
00325     );
00326 extern void TimerD_configureUpDownMode (
00327     unsigned int baseAddress,
00328     unsigned int clockSource,
00329     unsigned int clockSourceDivider,
00330     unsigned int clockingMode,
00331     unsigned int timerPeriod,
00332     unsigned int timerInterruptEnable_TDIE,
00333     unsigned int captureCompareInterruptEnable_CCR0_CCIE,
00334     unsigned int timerClear
00335     );
00336 extern void TimerD_initCapture (unsigned int baseAddress,
00337     unsigned int captureRegister,
00338     unsigned int captureMode,
00339     unsigned int captureInputSelect,
00340     unsigned short synchronizeCaptureSource,
00341     unsigned short captureInterruptEnable,
00342     unsigned int captureOutputMode,
00343     unsigned char channelCaptureMode
00344     );
00345 extern void TimerD_initCompare (  unsigned int baseAddress,
00346     unsigned int compareRegister,
00347     unsigned short compareInterruptEnable,
00348     unsigned int compareOutputMode,
00349     unsigned int compareValue
00350     );
00351 extern void TimerD_enableTimerInterrupt (unsigned int baseAddress);
00352 extern void TimerD_enableHighResInterrupt (unsigned int baseAddress,
00353                                 unsigned int mask);
00354 extern void TimerD_disableTimerInterrupt (unsigned int baseAddress);
00355 
00356 extern void TimerD_disableHighResInterrupt (unsigned int baseAddress,
00357                                                 unsigned int mask);
00358 extern unsigned long TimerD_getTimerInterruptStatus (unsigned int baseAddress);
00359 extern void TimerD_enableCaptureCompareInterrupt (unsigned int baseAddress,
00360     unsigned int captureCompareRegister
00361     );
00362 extern void TimerD_disableCaptureCompareInterrupt (unsigned int baseAddress,
00363     unsigned int captureCompareRegister
00364     );
00365 extern unsigned long TimerD_getCaptureCompareInterruptStatus (unsigned int baseAddress,
00366             unsigned int captureCompareRegister,
00367             unsigned int mask
00368             );
00369 extern unsigned int TimerD_getHighResInterruptStatus (unsigned int baseAddress,
00370     unsigned int mask);
00371 
00372 extern void TimerD_clear (unsigned int baseAddress);
00373 extern void TimerD_clearHighResInterruptStatus (unsigned int baseAddress,
00374     unsigned int mask);
00375 extern unsigned short TimerD_getSynchronizedCaptureCompareInput
00376     (unsigned int baseAddress,
00377     unsigned int captureCompareRegister,
00378     unsigned short synchronized
00379     );
00380 extern unsigned char TimerD_getOutputForOutputModeOutBitValue
00381     (unsigned int baseAddress,
00382     unsigned int captureCompareRegister
00383     );
00384 extern unsigned int TimerD_getCaptureCompareCount
00385     (unsigned int baseAddress,
00386     unsigned int captureCompareRegister
00387     );
00388 extern unsigned int TimerD_getCaptureCompareLatchCount
00389     (unsigned int baseAddress,
00390     unsigned int captureCompareRegister
00391     );
00392 extern unsigned char TimerD_getCaptureCompareInputSignal
00393     (unsigned int baseAddress,
00394     unsigned int captureCompareRegister
00395     );
00396 extern void TimerD_setOutputForOutputModeOutBitValue
00397     (unsigned int baseAddress,
00398     unsigned int captureCompareRegister,
00399     unsigned char outputModeOutBitValue
00400     );
00401 extern void TimerD_generatePWM (  unsigned int baseAddress,
00402     unsigned int clockSource,
00403     unsigned int clockSourceDivider,
00404     unsigned int clockingMode,
00405     unsigned int timerPeriod,
00406     unsigned int compareRegister,
00407     unsigned int compareOutputMode,
00408     unsigned int dutyCycle
00409     );
00410 extern void TimerD_stop ( unsigned int baseAddress );
00411 extern void TimerD_setCompareValue (  unsigned int baseAddress,
00412     unsigned int compareRegister,
00413     unsigned int compareValue
00414     );
00415 extern void TimerD_clearTimerInterruptFlag (unsigned int baseAddress);
00416 extern void TimerD_clearCaptureCompareInterruptFlag (unsigned int baseAddress,
00417     unsigned int captureCompareRegister
00418     );
00419 extern unsigned char TimerD_configureHighResGeneratorInFreeRunningMode
00420         (unsigned int baseAddress,
00421     unsigned char desiredHighResFrequency
00422     );
00423 extern void TimerD_configureHighResGeneratorInRegulatedMode (unsigned int baseAddress,
00424      unsigned int clockSource, 
00425      unsigned int clockSourceDivider,
00426      unsigned int clockingMode, 
00427      unsigned char highResClockMultiplyFactor,
00428      unsigned char highResClockDivider
00429     );
00430 extern void TimerD_combineTDCCRToGeneratePWM (  unsigned int baseAddress,
00431             unsigned int clockSource,
00432             unsigned int clockSourceDivider,
00433             unsigned int clockingMode,
00434             unsigned int timerPeriod,
00435             unsigned int combineCCRRegistersCombination,
00436             unsigned int compareOutputMode,
00437             unsigned int dutyCycle1,
00438             unsigned int dutyCycle2
00439             );
00440 extern void TimerD_selectLatchingGroup(unsigned int  baseAddress,
00441                 unsigned int  groupLatch);
00442 extern void TimerD_selectCounterLength (unsigned int  baseAddress,
00443                 unsigned int counterLength
00444                 );
00445 extern void TimerD_initCompareLatchLoadEvent(unsigned int  baseAddress,
00446                 unsigned int  compareRegister,
00447                 unsigned int  compareLatchLoadEvent
00448                 );
00449 extern void TimerD_disableHighResFastWakeup (unsigned int baseAddress);
00450 extern void TimerD_enableHighResFastWakeup (unsigned int baseAddress);
00451 extern void TimerD_disableHighResClockEnhancedAccuracy (unsigned int baseAddress);
00452 extern void TimerD_enableHighResClockEnhancedAccuracy (unsigned int baseAddress);
00453 extern void TimerD_DisableHighResGeneratorForceON (unsigned int baseAddress);
00454 extern void TimerD_EnableHighResGeneratorForceON (unsigned int baseAddress);
00455 
00456 extern void TimerD_selectHighResCoarseClockRange (unsigned int baseAddress,
00457                 unsigned int highResCoarseClockRange
00458                 );
00459 extern void TimerD_selectHighResClockRange (unsigned int baseAddress,
00460                 unsigned int highResClockRange
00461                 );
00462 
00463 //*****************************************************************************
00464 //
00465 //Close the Doxygen group.
00467 //
00468 //*****************************************************************************
00469 
00470 #endif

Copyright 2012, Texas Instruments Incorporated