1 /* --COPYRIGHT--,BSD 2 * Copyright (c) 2017, Texas Instruments Incorporated 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * * Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 12 * * Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * * Neither the name of Texas Instruments Incorporated nor the names of 17 * its contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * --/COPYRIGHT--*/ 32 #ifndef TIMERA_H_ 33 #define TIMERA_H_ 34 35 //***************************************************************************** 36 // 37 //! \addtogroup timera_api 38 //! @{ 39 // 40 //***************************************************************************** 41 42 //***************************************************************************** 43 // 44 // If building with a C++ compiler, make all of the definitions in this header 45 // have a C binding. 46 // 47 //***************************************************************************** 48 #ifdef __cplusplus 49 extern "C" 50 { 51 #endif 52 #include <stdint.h> 53 #include <ti/devices/msp432p4xx/inc/msp.h> 54 #include <stdbool.h> 55 56 //***************************************************************************** 57 // 58 // Timer_A Specific Parameters 59 // 60 //***************************************************************************** 61 #define TIMER_A_CMSIS(x) ((Timer_A_Type *) x) 62 63 #define TIMER_A_CCR0_INTERRUPT 0x00 64 #define TIMER_A_CCRX_AND_OVERFLOW_INTERRUPT 0x01 65 66 //***************************************************************************** 67 // 68 //! ypedef Timer_A_ContinuousModeConfig 69 //! \brief Type definition for \link _Timer_A_ContinuousModeConfig \endlink 70 //! structure 71 //! 72 //! \struct _Timer_A_ContinuousModeConfig 73 //! \brief Configuration structure for continuous mode in the \b Timer_A module. 74 //! See \link Timer_A_configureContinuousMode \endlink for parameter 75 //! documentation. 76 // 77 //***************************************************************************** 78 typedef struct _Timer_A_ContinuousModeConfig 79 { 80 uint_fast16_t clockSource; 81 uint_fast16_t clockSourceDivider; 82 uint_fast16_t timerInterruptEnable_TAIE; 83 uint_fast16_t timerClear; 84 } Timer_A_ContinuousModeConfig; 85 86 //***************************************************************************** 87 // 88 //! ypedef Timer_A_UpModeConfig 89 //! \brief Type definition for \link _Timer_A_UpModeConfig \endlink 90 //! structure 91 //! 92 //! \struct _Timer_A_UpModeConfig 93 //! \brief Configuration structure for Up mode in the \b Timer_A module. See 94 //! \link Timer_A_configureUpMode \endlink for parameter 95 //! documentation. 96 // 97 //***************************************************************************** 98 typedef struct _Timer_A_UpModeConfig 99 { 100 uint_fast16_t clockSource; 101 uint_fast16_t clockSourceDivider; 102 uint_fast16_t timerPeriod; 103 uint_fast16_t timerInterruptEnable_TAIE; 104 uint_fast16_t captureCompareInterruptEnable_CCR0_CCIE; 105 uint_fast16_t timerClear; 106 } Timer_A_UpModeConfig; 107 108 //***************************************************************************** 109 // 110 //! ypedef Timer_A_UpDownModeConfig 111 //! \brief Type definition for \link _Timer_A_UpDownModeConfig \endlink 112 //! structure 113 //! 114 //! \struct _Timer_A_UpDownModeConfig 115 //! \brief Configuration structure for UpDown mode in the \b Timer_A module. See 116 //! \link Timer_A_configureUpDownMode \endlink for parameter 117 //! documentation. 118 // 119 //***************************************************************************** 120 typedef struct _Timer_A_UpDownModeConfig 121 { 122 uint_fast16_t clockSource; 123 uint_fast16_t clockSourceDivider; 124 uint_fast16_t timerPeriod; 125 uint_fast16_t timerInterruptEnable_TAIE; 126 uint_fast16_t captureCompareInterruptEnable_CCR0_CCIE; 127 uint_fast16_t timerClear; 128 } Timer_A_UpDownModeConfig; 129 130 //***************************************************************************** 131 // 132 //! ypedef Timer_A_CaptureModeConfig 133 //! \brief Type definition for \link _Timer_A_CaptureModeConfig \endlink 134 //! structure 135 //! 136 //! \struct _Timer_A_CaptureModeConfig 137 //! \brief Configuration structure for capture mode in the \b Timer_A module. 138 //! See \link Timer_A_initCapture \endlink for parameter 139 //! documentation. 140 // 141 //***************************************************************************** 142 typedef struct _Timer_A_CaptureModeConfig 143 { 144 uint_fast16_t captureRegister; 145 uint_fast16_t captureMode; 146 uint_fast16_t captureInputSelect; 147 uint_fast16_t synchronizeCaptureSource; 148 uint_fast8_t captureInterruptEnable; 149 uint_fast16_t captureOutputMode; 150 } Timer_A_CaptureModeConfig; 151 152 //***************************************************************************** 153 // 154 //! ypedef Timer_A_CompareModeConfig 155 //! \brief Type definition for \link _Timer_A_CompareModeConfig \endlink 156 //! structure 157 //! 158 //! \struct _Timer_A_CompareModeConfig 159 //! \brief Configuration structure for compare mode in the \b Timer_A module. 160 //! See \link Timer_A_initCompare \endlink for parameter 161 //! documentation. 162 // 163 //***************************************************************************** 164 typedef struct _Timer_A_CompareModeConfig 165 { 166 uint_fast16_t compareRegister; 167 uint_fast16_t compareInterruptEnable; 168 uint_fast16_t compareOutputMode; 169 uint_fast16_t compareValue; 170 } Timer_A_CompareModeConfig; 171 172 //***************************************************************************** 173 // 174 //! ypedef Timer_A_PWMConfig 175 //! \brief Type definition for \link _Timer_A_PWMConfig \endlink 176 //! structure 177 //! 178 //! \struct _Timer_A_PWMConfig 179 //! \brief Configuration structure for PWM mode in the \b Timer_A module. See 180 //! \link Timer_A_generatePWM \endlink for parameter 181 //! documentation. 182 // 183 //***************************************************************************** 184 typedef struct _Timer_A_PWMConfig 185 { 186 uint_fast16_t clockSource; 187 uint_fast16_t clockSourceDivider; 188 uint_fast16_t timerPeriod; 189 uint_fast16_t compareRegister; 190 uint_fast16_t compareOutputMode; 191 uint_fast16_t dutyCycle; 192 } Timer_A_PWMConfig; 193 194 195 //***************************************************************************** 196 // 197 // The following is a parameter determines the maximum difference in counts of 198 // the TAxR register for a majority vote 199 // 200 //***************************************************************************** 201 #define TIMER_A_THRESHOLD 50 202 203 //***************************************************************************** 204 // 205 // The following are values that can be passed to the clockSourceDivider 206 // parameter 207 // 208 //***************************************************************************** 209 #define TIMER_A_CLOCKSOURCE_DIVIDER_1 0x01 210 #define TIMER_A_CLOCKSOURCE_DIVIDER_2 0x02 211 #define TIMER_A_CLOCKSOURCE_DIVIDER_4 0x04 212 #define TIMER_A_CLOCKSOURCE_DIVIDER_8 0x08 213 #define TIMER_A_CLOCKSOURCE_DIVIDER_3 0x03 214 #define TIMER_A_CLOCKSOURCE_DIVIDER_5 0x05 215 #define TIMER_A_CLOCKSOURCE_DIVIDER_6 0x06 216 #define TIMER_A_CLOCKSOURCE_DIVIDER_7 0x07 217 #define TIMER_A_CLOCKSOURCE_DIVIDER_10 0x0A 218 #define TIMER_A_CLOCKSOURCE_DIVIDER_12 0x0C 219 #define TIMER_A_CLOCKSOURCE_DIVIDER_14 0x0E 220 #define TIMER_A_CLOCKSOURCE_DIVIDER_16 0x10 221 #define TIMER_A_CLOCKSOURCE_DIVIDER_20 0x14 222 #define TIMER_A_CLOCKSOURCE_DIVIDER_24 0x18 223 #define TIMER_A_CLOCKSOURCE_DIVIDER_28 0x1C 224 #define TIMER_A_CLOCKSOURCE_DIVIDER_32 0x20 225 #define TIMER_A_CLOCKSOURCE_DIVIDER_40 0x28 226 #define TIMER_A_CLOCKSOURCE_DIVIDER_48 0x30 227 #define TIMER_A_CLOCKSOURCE_DIVIDER_56 0x38 228 #define TIMER_A_CLOCKSOURCE_DIVIDER_64 0x40 229 230 //***************************************************************************** 231 // 232 // The following are values that can be passed to the timerMode parameter 233 // 234 //***************************************************************************** 235 #define TIMER_A_STOP_MODE TIMER_A_CTL_MC_0 236 #define TIMER_A_UP_MODE TIMER_A_CTL_MC_1 237 #define TIMER_A_CONTINUOUS_MODE TIMER_A_CTL_MC_2 238 #define TIMER_A_UPDOWN_MODE TIMER_A_CTL_MC_3 239 240 //***************************************************************************** 241 // 242 // The following are values that can be passed to the timerClear parameter 243 // 244 //***************************************************************************** 245 #define TIMER_A_DO_CLEAR TIMER_A_CTL_CLR 246 #define TIMER_A_SKIP_CLEAR 0x00 247 248 //***************************************************************************** 249 // 250 // The following are values that can be passed to the clockSource parameter 251 // 252 //***************************************************************************** 253 #define TIMER_A_CLOCKSOURCE_EXTERNAL_TXCLK TIMER_A_CTL_SSEL__TACLK 254 #define TIMER_A_CLOCKSOURCE_ACLK TIMER_A_CTL_SSEL__ACLK 255 #define TIMER_A_CLOCKSOURCE_SMCLK TIMER_A_CTL_SSEL__SMCLK 256 #define TIMER_A_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK TIMER_A_CTL_SSEL__INCLK 257 258 //***************************************************************************** 259 // 260 // The following are values that can be passed to the timerInterruptEnable_TAIE 261 // parameter 262 // 263 //***************************************************************************** 264 #define TIMER_A_TAIE_INTERRUPT_ENABLE TIMER_A_CTL_IE 265 #define TIMER_A_TAIE_INTERRUPT_DISABLE 0x00 266 267 //***************************************************************************** 268 // 269 // The following are values that can be passed to the 270 // captureCompareInterruptEnable_CCR0_CCIE parameter 271 // 272 //***************************************************************************** 273 #define TIMER_A_CCIE_CCR0_INTERRUPT_ENABLE TIMER_A_CCTLN_CCIE 274 #define TIMER_A_CCIE_CCR0_INTERRUPT_DISABLE 0x00 275 276 //***************************************************************************** 277 // 278 // The following are values that can be passed to the captureInterruptEnable 279 // parameter 280 // 281 //***************************************************************************** 282 #define TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE 0x00 283 #define TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE TIMER_A_CCTLN_CCIE 284 285 //***************************************************************************** 286 // 287 // The following are values that can be passed to the captureInputSelect 288 // parameter 289 // 290 //***************************************************************************** 291 #define TIMER_A_CAPTURE_INPUTSELECT_CCIxA TIMER_A_CCTLN_CCIS_0 292 #define TIMER_A_CAPTURE_INPUTSELECT_CCIxB TIMER_A_CCTLN_CCIS_1 293 #define TIMER_A_CAPTURE_INPUTSELECT_GND TIMER_A_CCTLN_CCIS_2 294 #define TIMER_A_CAPTURE_INPUTSELECT_Vcc TIMER_A_CCTLN_CCIS_3 295 296 //***************************************************************************** 297 // 298 // The following are values that can be passed to the compareOutputMode 299 // parameter 300 // 301 //***************************************************************************** 302 #define TIMER_A_OUTPUTMODE_OUTBITVALUE TIMER_A_CCTLN_OUTMOD_0 303 #define TIMER_A_OUTPUTMODE_SET TIMER_A_CCTLN_OUTMOD_1 304 #define TIMER_A_OUTPUTMODE_TOGGLE_RESET TIMER_A_CCTLN_OUTMOD_2 305 #define TIMER_A_OUTPUTMODE_SET_RESET TIMER_A_CCTLN_OUTMOD_3 306 #define TIMER_A_OUTPUTMODE_TOGGLE TIMER_A_CCTLN_OUTMOD_4 307 #define TIMER_A_OUTPUTMODE_RESET TIMER_A_CCTLN_OUTMOD_5 308 #define TIMER_A_OUTPUTMODE_TOGGLE_SET TIMER_A_CCTLN_OUTMOD_6 309 #define TIMER_A_OUTPUTMODE_RESET_SET TIMER_A_CCTLN_OUTMOD_7 310 311 //***************************************************************************** 312 // 313 // The following are values that can be passed to the compareRegister parameter 314 // 315 //***************************************************************************** 316 #define TIMER_A_CAPTURECOMPARE_REGISTER_0 0x02 317 #define TIMER_A_CAPTURECOMPARE_REGISTER_1 0x04 318 #define TIMER_A_CAPTURECOMPARE_REGISTER_2 0x06 319 #define TIMER_A_CAPTURECOMPARE_REGISTER_3 0x08 320 #define TIMER_A_CAPTURECOMPARE_REGISTER_4 0x0A 321 #define TIMER_A_CAPTURECOMPARE_REGISTER_5 0x0C 322 #define TIMER_A_CAPTURECOMPARE_REGISTER_6 0x0E 323 324 //***************************************************************************** 325 // 326 // The following are values that can be passed to the captureMode parameter 327 // 328 //***************************************************************************** 329 #define TIMER_A_CAPTUREMODE_NO_CAPTURE TIMER_A_CCTLN_CM_0 330 #define TIMER_A_CAPTUREMODE_RISING_EDGE TIMER_A_CCTLN_CM_1 331 #define TIMER_A_CAPTUREMODE_FALLING_EDGE TIMER_A_CCTLN_CM_2 332 #define TIMER_A_CAPTUREMODE_RISING_AND_FALLING_EDGE TIMER_A_CCTLN_CM_3 333 334 //***************************************************************************** 335 // 336 // The following are values that can be passed to the synchronizeCaptureSource 337 // parameter 338 // 339 //***************************************************************************** 340 #define TIMER_A_CAPTURE_ASYNCHRONOUS 0x00 341 #define TIMER_A_CAPTURE_SYNCHRONOUS TIMER_A_CCTLN_SCS 342 343 //***************************************************************************** 344 // 345 // The following are values that can be passed to the mask parameter 346 // 347 //***************************************************************************** 348 #define TIMER_A_CAPTURE_OVERFLOW TIMER_A_CCTLN_COV 349 #define TIMER_A_CAPTURECOMPARE_INTERRUPT_FLAG TIMER_A_CCTLN_CCIFG 350 351 //***************************************************************************** 352 // 353 // The following are values that can be passed to the synchronized parameter 354 // 355 //***************************************************************************** 356 #define TIMER_A_READ_SYNCHRONIZED_CAPTURECOMPAREINPUT TIMER_A_CCTLN_SCCI 357 #define TIMER_A_READ_CAPTURE_COMPARE_INPUT TIMER_A_CCTLN_CCI 358 359 360 #define TIMER_A_CAPTURECOMPARE_INPUT_HIGH 0x01 361 #define TIMER_A_CAPTURECOMPARE_INPUT_LOW 0x00 362 363 //***************************************************************************** 364 // 365 // The following are values that can be passed to the outputModeOutBitValue 366 // parameter 367 // 368 //***************************************************************************** 369 #define TIMER_A_OUTPUTMODE_OUTBITVALUE_HIGH TIMER_A_CCTLN_OUT 370 #define TIMER_A_OUTPUTMODE_OUTBITVALUE_LOW 0x00 371 372 //***************************************************************************** 373 // 374 // The following are values that can be passed toThe following are values that 375 // can be returned by the interrupt functions 376 // 377 //***************************************************************************** 378 #define TIMER_A_INTERRUPT_NOT_PENDING 0x00 379 #define TIMER_A_INTERRUPT_PENDING 0x01 380 381 382 /* Convenience function for setting the PWM Duty Cycle */ 383 #define Timer_A_setDutyCycle(timer,dutyCycle) \ 384 Timer_A_setCompareValue(timer,dutyCycle) 385 386 //***************************************************************************** 387 // 388 //Prototypes for the APIs. 389 // 390 //***************************************************************************** 391 392 //***************************************************************************** 393 // 394 //! Starts Timer_A counter 395 //! 396 //! \param timer is the instance of the Timer_A module. Valid parameters 397 //! vary from part to part, but can include: 398 //! - \b TIMER_A0_BASE 399 //! - \b TIMER_A1_BASE 400 //! - \b TIMER_A2_BASE 401 //! - \b TIMER_A3_BASE 402 //! \param timerMode selects Clock source. Valid values are 403 //! - \b TIMER_A_CONTINUOUS_MODE [Default value] 404 //! - \b TIMER_A_UPDOWN_MODE 405 //! - \b TIMER_A_UP_MODE 406 //! 407 //! \note This function assumes that the timer has been previously configured 408 //! using Timer_A_configureContinuousMode, Timer_A_configureUpMode or 409 //! Timer_A_configureUpDownMode. 410 //! 411 //! \return None 412 // 413 //***************************************************************************** 414 extern void Timer_A_startCounter(uint32_t timer, uint_fast16_t timerMode); 415 416 //***************************************************************************** 417 // 418 //! Configures Timer_A in continuous mode. 419 //! 420 //! \param timer is the instance of the Timer_A module. Valid parameters 421 //! vary from part to part, but can include: 422 //! - \b TIMER_A0_BASE 423 //! - \b TIMER_A1_BASE 424 //! - \b TIMER_A2_BASE 425 //! - \b TIMER_A3_BASE 426 //! \param config Configuration structure for Timer_A continuous mode 427 //! 428 //! <hr> 429 //! <b>Configuration options for \link Timer_A_ContinuousModeConfig \endlink 430 //! structure.</b> 431 //! <hr> 432 //! 433 //! \param clockSource selects Clock source. Valid values are 434 //! - \b TIMER_A_CLOCKSOURCE_EXTERNAL_TXCLK [Default value] 435 //! - \b TIMER_A_CLOCKSOURCE_ACLK 436 //! - \b TIMER_A_CLOCKSOURCE_SMCLK 437 //! - \b TIMER_A_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK 438 //! \param timerInterruptEnable_TAIE is the divider for Clock source. 439 //! Valid values are: 440 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_1 [Default value] 441 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_2 442 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_4 443 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_8 444 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_3 445 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_5 446 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_6 447 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_7 448 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_10 449 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_12 450 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_14 451 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_16 452 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_20 453 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_24 454 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_28 455 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_32 456 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_40 457 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_48 458 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_56 459 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_64 460 //! \param timerInterruptEnable_TAIE is to enable or disable Timer_A 461 //! interrupt. Valid values are 462 //! - \b TIMER_A_TAIE_INTERRUPT_ENABLE 463 //! - \b TIMER_A_TAIE_INTERRUPT_DISABLE [Default value] 464 //! \param timerClear decides if Timer_A clock divider, count direction, 465 //! count need to be reset. Valid values are 466 //! - \b TIMER_A_DO_CLEAR 467 //! - \b TIMER_A_SKIP_CLEAR [Default value] 468 //! 469 //! \note This API does not start the timer. Timer needs to be started when 470 //! required using the Timer_A_startCounter API. 471 //! 472 //! \return None 473 // 474 //***************************************************************************** 475 extern void Timer_A_configureContinuousMode(uint32_t timer, 476 const Timer_A_ContinuousModeConfig *config); 477 478 //***************************************************************************** 479 // 480 //! Configures Timer_A in up mode. 481 //! 482 //! \param timer is the instance of the Timer_A module. Valid parameters 483 //! vary from part to part, but can include: 484 //! - \b TIMER_A0_BASE 485 //! - \b TIMER_A1_BASE 486 //! - \b TIMER_A2_BASE 487 //! - \b TIMER_A3_BASE 488 //! \param config Configuration structure for Timer_A Up mode 489 //! 490 //! <hr> 491 //! <b>Configuration options for \link Timer_A_UpModeConfig \endlink 492 //! structure.</b> 493 //! <hr> 494 //! \param clockSource selects Clock source. Valid values are 495 //! - \b TIMER_A_CLOCKSOURCE_EXTERNAL_TXCLK [Default value] 496 //! - \b TIMER_A_CLOCKSOURCE_ACLK 497 //! - \b TIMER_A_CLOCKSOURCE_SMCLK 498 //! - \b TIMER_A_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK 499 //! \param clockSourceDivider is the divider for Clock source. Valid values 500 //! are: 501 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_1 [Default value] 502 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_2 503 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_4 504 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_8 505 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_3 506 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_5 507 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_6 508 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_7 509 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_10 510 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_12 511 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_14 512 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_16 513 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_20 514 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_24 515 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_28 516 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_32 517 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_40 518 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_48 519 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_56 520 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_64 521 //! \param timerPeriod is the specified Timer_A period. This is the value 522 //! that gets written into the CCR0. Limited to 16 bits[uint16_t] 523 //! \param timerInterruptEnable_TAIE is to enable or disable Timer_A 524 //! interrupt. Valid values are: 525 //! - \b TIMER_A_TAIE_INTERRUPT_ENABLE and 526 //! - \b TIMER_A_TAIE_INTERRUPT_DISABLE [Default value] 527 //! \param captureCompareInterruptEnable_CCR0_CCIE is to enable or disable 528 //! Timer_A CCR0 captureComapre interrupt. Valid values are 529 //! - \b TIMER_A_CCIE_CCR0_INTERRUPT_ENABLE and 530 //! - \b TIMER_A_CCIE_CCR0_INTERRUPT_DISABLE [Default value] 531 //! \param timerClear decides if Timer_A clock divider, count direction, 532 //! count need to be reset. Valid values are 533 //! - \b TIMER_A_DO_CLEAR 534 //! - \b TIMER_A_SKIP_CLEAR [Default value] 535 //! 536 //!\note This API does not start the timer. Timer needs to be started when 537 //!required using the Timer_A_startCounter API. 538 //! 539 //! \return None 540 // 541 //***************************************************************************** 542 extern void Timer_A_configureUpMode(uint32_t timer, 543 const Timer_A_UpModeConfig *config); 544 545 //***************************************************************************** 546 // 547 //! Configures Timer_A in up down mode. 548 //! 549 //! \param timer is the instance of the Timer_A module. Valid parameters 550 //! vary from part to part, but can include: 551 //! - \b TIMER_A0_BASE 552 //! - \b TIMER_A1_BASE 553 //! - \b TIMER_A2_BASE 554 //! - \b TIMER_A3_BASE 555 //! \param config Configuration structure for Timer_A UpDown mode 556 //! 557 //! <hr> 558 //! <b>Configuration options for \link Timer_A_UpDownModeConfig \endlink 559 //! structure.</b> 560 //! <hr> 561 //! \param clockSource selects Clock source. Valid values are 562 //! - \b TIMER_A_CLOCKSOURCE_EXTERNAL_TXCLK [Default value] 563 //! - \b TIMER_A_CLOCKSOURCE_ACLK 564 //! - \b TIMER_A_CLOCKSOURCE_SMCLK 565 //! - \b TIMER_A_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK 566 //! \param clockSourceDivider is the divider for Clock source. Valid values 567 //! are: 568 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_1 [Default value] 569 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_2 570 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_4 571 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_8 572 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_3 573 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_5 574 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_6 575 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_7 576 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_10 577 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_12 578 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_14 579 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_16 580 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_20 581 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_24 582 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_28 583 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_32 584 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_40 585 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_48 586 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_56 587 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_64 588 //! \param timerPeriod is the specified Timer_A period 589 //! \param timerInterruptEnable_TAIE is to enable or disable Timer_A 590 //! interrupt. 591 //! Valid values are 592 //! - \b TIMER_A_TAIE_INTERRUPT_ENABLE 593 //! - \b TIMER_A_TAIE_INTERRUPT_DISABLE [Default value] 594 //! \param captureCompareInterruptEnable_CCR0_CCIE is to enable or disable 595 //! Timer_A CCR0 captureComapre interrupt. Valid values are 596 //! - \b TIMER_A_CCIE_CCR0_INTERRUPT_ENABLE and 597 //! - \b TIMER_A_CCIE_CCR0_INTERRUPT_DISABLE [Default value] 598 //! \param timerClear decides if Timer_A clock divider, count direction, count 599 //! need to be reset. Valid values are 600 //! - \b TIMER_A_DO_CLEAR 601 //! - \b TIMER_A_SKIP_CLEAR [Default value] 602 //! 603 //!This API does not start the timer. Timer needs to be started when required 604 //!using the Timer_A_startCounter API. 605 //! 606 //! \return None 607 // 608 //***************************************************************************** 609 extern void Timer_A_configureUpDownMode(uint32_t timer, 610 const Timer_A_UpDownModeConfig *config); 611 612 //***************************************************************************** 613 // 614 //! Initializes Capture Mode 615 //! 616 //! \param timer is the instance of the Timer_A module. Valid parameters 617 //! vary from part to part, but can include: 618 //! - \b TIMER_A0_BASE 619 //! - \b TIMER_A1_BASE 620 //! - \b TIMER_A2_BASE 621 //! - \b TIMER_A3_BASE 622 //! \param config Configuration structure for Timer_A capture mode 623 //! 624 //! <hr> 625 //! <b>Configuration options for \link Timer_A_CaptureModeConfig \endlink 626 //! structure.</b> 627 //! <hr> 628 //! \param captureRegister selects the Capture register being used. Valid 629 //! values are 630 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0 631 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1 632 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2 633 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_3 634 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_4 635 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_5 636 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_6 637 //! \n Refer to datasheet to ensure the device has the capture compare 638 //! register being used 639 //! \param captureMode is the capture mode selected. Valid values are 640 //! - \b TIMER_A_CAPTUREMODE_NO_CAPTURE [Default value] 641 //! - \b TIMER_A_CAPTUREMODE_RISING_EDGE 642 //! - \b TIMER_A_CAPTUREMODE_FALLING_EDGE 643 //! - \b TIMER_A_CAPTUREMODE_RISING_AND_FALLING_EDGE 644 //! \param captureInputSelect decides the Input Select 645 //! - \b TIMER_A_CAPTURE_INPUTSELECT_CCIxA [Default value] 646 //! - \b TIMER_A_CAPTURE_INPUTSELECT_CCIxB 647 //! - \b TIMER_A_CAPTURE_INPUTSELECT_GND 648 //! - \b TIMER_A_CAPTURE_INPUTSELECT_Vcc 649 //! \param synchronizeCaptureSource decides if capture source should be 650 //! synchronized with timer clock 651 //! Valid values are 652 //! - \b TIMER_A_CAPTURE_ASYNCHRONOUS [Default value] 653 //! - \b TIMER_A_CAPTURE_SYNCHRONOUS 654 //! \param captureInterruptEnable is to enable or disable 655 //! timer captureComapre interrupt. Valid values are 656 //! - \b TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE [Default value] 657 //! - \b TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE 658 //! \param captureOutputMode specifies the ouput mode. Valid values are 659 //! - \b TIMER_A_OUTPUTMODE_OUTBITVALUE [Default value], 660 //! - \b TIMER_A_OUTPUTMODE_SET, 661 //! - \b TIMER_A_OUTPUTMODE_TOGGLE_RESET, 662 //! - \b TIMER_A_OUTPUTMODE_SET_RESET 663 //! - \b TIMER_A_OUTPUTMODE_TOGGLE, 664 //! - \b TIMER_A_OUTPUTMODE_RESET, 665 //! - \b TIMER_A_OUTPUTMODE_TOGGLE_SET, 666 //! - \b TIMER_A_OUTPUTMODE_RESET_SET 667 //! 668 //! \return None 669 // 670 //***************************************************************************** 671 extern void Timer_A_initCapture(uint32_t timer, 672 const Timer_A_CaptureModeConfig *config); 673 674 //***************************************************************************** 675 // 676 //! Initializes Compare Mode 677 //! 678 //! \param timer is the instance of the Timer_A module. Valid parameters 679 //! vary from part to part, but can include: 680 //! - \b TIMER_A0_BASE 681 //! - \b TIMER_A1_BASE 682 //! - \b TIMER_A2_BASE 683 //! - \b TIMER_A3_BASE 684 //! \param config Configuration structure for Timer_A compare mode 685 //! 686 //! <hr> 687 //! <b>Configuration options for \link Timer_A_CompareModeConfig \endlink 688 //! structure.</b> 689 //! <hr> 690 //! \param compareRegister selects the Capture register being used. Valid 691 //! values are 692 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0 693 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1 694 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2 695 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_3 696 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_4 697 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_5 698 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_6 699 //! \n Refer to datasheet to ensure the device has the capture compare 700 //! register being used 701 //! \param compareInterruptEnable is to enable or disable 702 //! timer captureComapre interrupt. Valid values are 703 //! - \b TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE and 704 //! - \b TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE [Default value] 705 //! \param compareOutputMode specifies the output mode. Valid values are 706 //! - \b TIMER_A_OUTPUTMODE_OUTBITVALUE [Default value], 707 //! - \b TIMER_A_OUTPUTMODE_SET, 708 //! - \b TIMER_A_OUTPUTMODE_TOGGLE_RESET, 709 //! - \b TIMER_A_OUTPUTMODE_SET_RESET 710 //! - \b TIMER_A_OUTPUTMODE_TOGGLE, 711 //! - \b TIMER_A_OUTPUTMODE_RESET, 712 //! - \b TIMER_A_OUTPUTMODE_TOGGLE_SET, 713 //! - \b TIMER_A_OUTPUTMODE_RESET_SET 714 //! \param compareValue is the count to be compared with in compare mode 715 //! 716 //! \return None 717 // 718 //***************************************************************************** 719 extern void Timer_A_initCompare(uint32_t timer, 720 const Timer_A_CompareModeConfig *config); 721 722 //***************************************************************************** 723 // 724 //! Reset/Clear the timer clock divider, count direction, count 725 //! 726 //! \param timer is the instance of the Timer_A module. Valid parameters 727 //! vary from part to part, but can include: 728 //! - \b TIMER_A0_BASE 729 //! - \b TIMER_A1_BASE 730 //! - \b TIMER_A2_BASE 731 //! - \b TIMER_A3_BASE 732 //! 733 //! \returns None 734 // 735 //***************************************************************************** 736 extern void Timer_A_clearTimer(uint32_t timer); 737 738 //***************************************************************************** 739 // 740 //! Get synchronized capture compare input 741 //! 742 //! \param timer is the instance of the Timer_A module. Valid parameters 743 //! vary from part to part, but can include: 744 //! - \b TIMER_A0_BASE 745 //! - \b TIMER_A1_BASE 746 //! - \b TIMER_A2_BASE 747 //! - \b TIMER_A3_BASE 748 //! \param captureCompareRegister selects the Capture register being used. 749 //! Valid values are 750 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0 751 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1 752 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2 753 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_3 754 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_4 755 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_5 756 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_6 757 //! \n Refer to datasheet to ensure the device has the capture compare 758 //! register being used 759 //! \param synchronizedSetting is to select type of capture compare input. 760 //! Valid values are 761 //! - \b TIMER_A_READ_CAPTURE_COMPARE_INPUT 762 //! - \b TIMER_A_READ_SYNCHRONIZED_CAPTURECOMPAREINPUT 763 //! 764 //! \return \b TIMER_A_CAPTURECOMPARE_INPUT_HIGH or 765 //! - \b TIMER_A_CAPTURECOMPARE_INPUT_LOW 766 // 767 //***************************************************************************** 768 extern uint_fast8_t Timer_A_getSynchronizedCaptureCompareInput(uint32_t timer, 769 uint_fast16_t captureCompareRegister, 770 uint_fast16_t synchronizedSetting); 771 772 //***************************************************************************** 773 // 774 //! Get ouput bit for output mode 775 //! 776 //! \param timer is the instance of the Timer_A module. Valid parameters 777 //! vary from part to part, but can include: 778 //! - \b TIMER_A0_BASE 779 //! - \b TIMER_A1_BASE 780 //! - \b TIMER_A2_BASE 781 //! - \b TIMER_A3_BASE 782 //! \param captureCompareRegister selects the Capture register being used. 783 //! Valid values are 784 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0 785 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1 786 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2 787 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_3 788 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_4 789 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_5 790 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_6 791 //! \n Refer to datasheet to ensure the device has the capture compare 792 //! register being used 793 //! 794 //! \return \b TIMER_A_OUTPUTMODE_OUTBITVALUE_HIGH or 795 //! - \b TIMER_A_OUTPUTMODE_OUTBITVALUE_LOW 796 // 797 //***************************************************************************** 798 extern uint_fast8_t Timer_A_getOutputForOutputModeOutBitValue(uint32_t timer, 799 uint_fast16_t captureCompareRegister); 800 801 //***************************************************************************** 802 // 803 //! Get current capture compare count 804 //! 805 //! \param timer is the instance of the Timer_A module. Valid parameters 806 //! vary from part to part, but can include: 807 //! - \b TIMER_A0_BASE 808 //! - \b TIMER_A1_BASE 809 //! - \b TIMER_A2_BASE 810 //! - \b TIMER_A3_BASE 811 //! \param captureCompareRegister selects the Capture register being used. 812 //! Valid values are 813 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0 814 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1 815 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2 816 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_3 817 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_4 818 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_5 819 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_6 820 //! \n Refer to datasheet to ensure the device has the capture compare 821 //! register being used 822 //! 823 //! \return current count as uint16_t 824 // 825 //***************************************************************************** 826 extern uint_fast16_t Timer_A_getCaptureCompareCount(uint32_t timer, 827 uint_fast16_t captureCompareRegister); 828 829 //***************************************************************************** 830 // 831 //! Set ouput bit for output mode 832 //! 833 //! \param timer is the instance of the Timer_A module. Valid parameters 834 //! vary from part to part, but can include: 835 //! - \b TIMER_A0_BASE 836 //! - \b TIMER_A1_BASE 837 //! - \b TIMER_A2_BASE 838 //! - \b TIMER_A3_BASE 839 //! \param captureCompareRegister selects the Capture register being used. 840 //! are 841 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0 842 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1 843 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2 844 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_3 845 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_4 846 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_5 847 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_6 848 //! \n Refer to datasheet to ensure the device has the capture compare 849 //! register being used 850 //! \param outputModeOutBitValue the value to be set for out bit. 851 //! Valid values are: 852 //! - \b TIMER_A_OUTPUTMODE_OUTBITVALUE_HIGH 853 //! - \b TIMER_A_OUTPUTMODE_OUTBITVALUE_LOW 854 //! 855 //! \return None 856 // 857 //***************************************************************************** 858 extern void Timer_A_setOutputForOutputModeOutBitValue(uint32_t timer, 859 uint_fast16_t captureCompareRegister, 860 uint_fast8_t outputModeOutBitValue); 861 862 //***************************************************************************** 863 // 864 //! Generate a PWM with timer running in up mode 865 //! 866 //! \param timer is the instance of the Timer_A module. Valid parameters 867 //! vary from part to part, but can include: 868 //! - \b TIMER_A0_BASE 869 //! - \b TIMER_A1_BASE 870 //! - \b TIMER_A2_BASE 871 //! - \b TIMER_A3_BASE 872 //! \param config Configuration structure for Timer_A PWM mode 873 //! 874 //! <hr> 875 //! <b>Configuration options for \link Timer_A_PWMConfig \endlink 876 //! structure.</b> 877 //! <hr> 878 //! \param clockSource selects Clock source. Valid values are 879 //! - \b TIMER_A_CLOCKSOURCE_EXTERNAL_TXCLK 880 //! - \b TIMER_A_CLOCKSOURCE_ACLK 881 //! - \b TIMER_A_CLOCKSOURCE_SMCLK 882 //! - \b TIMER_A_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK 883 //! \param clockSourceDivider is the divider for Clock source. Valid values 884 //! are 885 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_1 886 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_2 887 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_4 888 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_8 889 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_3 890 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_5 891 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_6 892 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_7 893 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_10 894 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_12 895 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_14 896 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_16 897 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_20 898 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_24 899 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_28 900 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_32 901 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_40 902 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_48 903 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_56 904 //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_64 905 //! \param timerPeriod selects the desired timer period 906 //! \param compareRegister selects the compare register being used. 907 //! Valid values are 908 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0 909 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1 910 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2 911 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_3 912 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_4 913 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_5 914 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_6 915 //! <br>\n Refer to datasheet to ensure the device has the capture compare 916 //! register being used 917 //! \param compareOutputMode specifies the ouput mode. Valid values are: 918 //! - \b TIMER_A_OUTPUTMODE_OUTBITVALUE, 919 //! - \b TIMER_A_OUTPUTMODE_SET, 920 //! - \b TIMER_A_OUTPUTMODE_TOGGLE_RESET, 921 //! - \b TIMER_A_OUTPUTMODE_SET_RESET 922 //! - \b TIMER_A_OUTPUTMODE_TOGGLE, 923 //! - \b TIMER_A_OUTPUTMODE_RESET, 924 //! - \b TIMER_A_OUTPUTMODE_TOGGLE_SET, 925 //! - \b TIMER_A_OUTPUTMODE_RESET_SET 926 //! \param dutyCycle specifies the dutycycle for the generated waveform 927 //! 928 //! \return None 929 // 930 //***************************************************************************** 931 extern void Timer_A_generatePWM(uint32_t timer, 932 const Timer_A_PWMConfig *config); 933 934 //***************************************************************************** 935 // 936 //! Stops the timer 937 //! 938 //! \param timer is the instance of the Timer_A module. Valid parameters 939 //! vary from part to part, but can include: 940 //! - \b TIMER_A0_BASE 941 //! - \b TIMER_A1_BASE 942 //! - \b TIMER_A2_BASE 943 //! - \b TIMER_A3_BASE 944 //! 945 //! \returns None 946 // 947 //***************************************************************************** 948 extern void Timer_A_stopTimer(uint32_t timer); 949 950 //***************************************************************************** 951 // 952 //! Sets the value of the capture-compare register 953 //! 954 //! \param timer is the instance of the Timer_A module. Valid parameters 955 //! vary from part to part, but can include: 956 //! - \b TIMER_A0_BASE 957 //! - \b TIMER_A1_BASE 958 //! - \b TIMER_A2_BASE 959 //! - \b TIMER_A3_BASE 960 //! \param compareRegister selects the Capture register being used. Valid 961 //! values are 962 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0 963 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1 964 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2 965 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_3 966 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_4 967 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_5 968 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_6 969 //! <br>\n Refer to datasheet to ensure the device has the capture compare 970 //! register being used 971 //! \param compareValue is the count to be compared with in compare mode 972 //! 973 //! \return None 974 // 975 //***************************************************************************** 976 extern void Timer_A_setCompareValue(uint32_t timer, 977 uint_fast16_t compareRegister, uint_fast16_t compareValue); 978 979 //***************************************************************************** 980 // 981 //! Returns the current value of the specified timer. Note that according to 982 //! the Timer A user guide, reading the value of the counter is unreliable 983 //! if the system clock is asynchronous from the timer clock. The API addresses 984 //! this concern by reading the timer count register twice and then determining 985 //! the integrity of the value. If the two values are within 10 timer counts 986 //! of each other, the value is deemed safe and returned. If not, the process 987 //! is repeated until a reliable timer value is determined. 988 //! 989 //! \param timer is the instance of the Timer_A module. Valid parameters 990 //! vary from part to part, but can include: 991 //! - \b TIMER_A0_BASE 992 //! - \b TIMER_A1_BASE 993 //! - \b TIMER_A2_BASE 994 //! - \b TIMER_A3_BASE 995 //! 996 //! \returns The value of the specified timer 997 // 998 //***************************************************************************** 999 extern uint16_t Timer_A_getCounterValue(uint32_t timer); 1000 1001 //***************************************************************************** 1002 // 1003 //! Clears the Timer TAIFG interrupt flag 1004 //! 1005 //! \param timer is the instance of the Timer_A module. Valid parameters 1006 //! vary from part to part, but can include: 1007 //! - \b TIMER_A0_BASE 1008 //! - \b TIMER_A1_BASE 1009 //! - \b TIMER_A2_BASE 1010 //! - \b TIMER_A3_BASE 1011 //! 1012 //! \return None 1013 // 1014 //***************************************************************************** 1015 extern void Timer_A_clearInterruptFlag(uint32_t timer); 1016 1017 //***************************************************************************** 1018 // 1019 //! Clears the capture-compare interrupt flag 1020 //! 1021 //! \param timer is the instance of the Timer_A module. Valid parameters 1022 //! vary from part to part, but can include: 1023 //! - \b TIMER_A0_BASE 1024 //! - \b TIMER_A1_BASE 1025 //! - \b TIMER_A2_BASE 1026 //! - \b TIMER_A3_BASE 1027 //! \param captureCompareRegister selects the Capture-compare register being 1028 //! used. Valid values are 1029 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0 1030 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1 1031 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2 1032 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_3 1033 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_4 1034 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_5 1035 //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_6 1036 //! <br>Refer to the datasheet to ensure the device has the capture compare 1037 //! register being used 1038 //! 1039 //! \return None 1040 // 1041 //***************************************************************************** 1042 extern void Timer_A_clearCaptureCompareInterrupt(uint32_t timer, 1043 uint_fast16_t captureCompareRegister); 1044 1045 //***************************************************************************** 1046 // 1047 //! Enable timer interrupt 1048 //! 1049 //! \param timer is the instance of the Timer_A module. Valid parameters 1050 //! vary from part to part, but can include: 1051 //! - \b TIMER_A0_BASE 1052 //! - \b TIMER_A1_BASE 1053 //! - \b TIMER_A2_BASE 1054 //! - \b TIMER_A3_BASE 1055 //! 1056 //! \return None 1057 // 1058 //***************************************************************************** 1059 extern void Timer_A_enableInterrupt(uint32_t timer); 1060 1061 //***************************************************************************** 1062 // 1063 //! Disable timer interrupt 1064 //! 1065 //! \param timer is the instance of the Timer_A module. Valid parameters 1066 //! vary from part to part, but can include: 1067 //! - \b TIMER_A0_BASE 1068 //! - \b TIMER_A1_BASE 1069 //! - \b TIMER_A2_BASE 1070 //! - \b TIMER_A3_BASE 1071 //! 1072 //! \return None 1073 // 1074 //***************************************************************************** 1075 extern void Timer_A_disableInterrupt(uint32_t timer); 1076 1077 //***************************************************************************** 1078 // 1079 //! Get timer interrupt status 1080 //! 1081 //! \param timer is the instance of the Timer_A module. Valid parameters 1082 //! vary from part to part, but can include: 1083 //! - \b TIMER_A0_BASE 1084 //! - \b TIMER_A1_BASE 1085 //! - \b TIMER_A2_BASE 1086 //! - \b TIMER_A3_BASE 1087 //! 1088 //! \return uint32_t. Return interrupt status. Valid values are 1089 //! - \b TIMER_A_INTERRUPT_PENDING 1090 //! - \b TIMER_A_INTERRUPT_NOT_PENDING 1091 // 1092 //***************************************************************************** 1093 extern uint32_t Timer_A_getInterruptStatus(uint32_t timer); 1094 1095 //***************************************************************************** 1096 // 1097 //! Get timer interrupt status masked with the enabled interrupts. 1098 //! This function is useful to call in ISRs to get a list of pending 1099 //! interrupts that are actually enabled and could have caused 1100 //! the ISR. 1101 //! 1102 //! \param timer is the instance of the Timer_A module. Valid parameters 1103 //! vary from part to part, but can include: 1104 //! - \b TIMER_A0_BASE 1105 //! - \b TIMER_A1_BASE 1106 //! - \b TIMER_A2_BASE 1107 //! - \b TIMER_A3_BASE 1108 //! 1109 //! \return uint32_t. Return interrupt status. Valid values are 1110 //! - \b TIMER_A_INTERRUPT_PENDING 1111 //! - \b TIMER_A_INTERRUPT_NOT_PENDING 1112 // 1113 //***************************************************************************** 1114 extern uint32_t Timer_A_getEnabledInterruptStatus(uint32_t timer); 1115 1116 //***************************************************************************** 1117 // 1118 //! Enable capture compare interrupt 1119 //! 1120 //! \param timer is the instance of the Timer_A module. Valid parameters 1121 //! vary from part to part, but can include: 1122 //! - \b TIMER_A0_BASE 1123 //! - \b TIMER_A1_BASE 1124 //! - \b TIMER_A2_BASE 1125 //! - \b TIMER_A3_BASE 1126 //! \param captureCompareRegister is the selected capture compare register 1127 //! 1128 //! \return None 1129 // 1130 //***************************************************************************** 1131 extern void Timer_A_enableCaptureCompareInterrupt(uint32_t timer, 1132 uint_fast16_t captureCompareRegister); 1133 1134 //***************************************************************************** 1135 // 1136 //! Disable capture compare interrupt 1137 //! 1138 //! \param timer is the instance of the Timer_A module. Valid parameters 1139 //! vary from part to part, but can include: 1140 //! - \b TIMER_A0_BASE 1141 //! - \b TIMER_A1_BASE 1142 //! - \b TIMER_A2_BASE 1143 //! - \b TIMER_A3_BASE 1144 //! \param captureCompareRegister is the selected capture compare register 1145 //! 1146 //! \return None 1147 // 1148 //***************************************************************************** 1149 extern void Timer_A_disableCaptureCompareInterrupt(uint32_t timer, 1150 uint_fast16_t captureCompareRegister); 1151 1152 //***************************************************************************** 1153 // 1154 //! Return capture compare interrupt status 1155 //! 1156 //! \param timer is the instance of the Timer_A module. Valid parameters 1157 //! vary from part to part, but can include: 1158 //! - \b TIMER_A0_BASE 1159 //! - \b TIMER_A1_BASE 1160 //! - \b TIMER_A2_BASE 1161 //! - \b TIMER_A3_BASE 1162 //! \param captureCompareRegister is the selected capture compare register 1163 //! 1164 //! \param mask is the mask for the interrupt status 1165 //! Mask value is the logical OR of any of the following: 1166 //! - \b TIMER_A_CAPTURE_OVERFLOW 1167 //! - \b TIMER_A_CAPTURECOMPARE_INTERRUPT_FLAG 1168 //! 1169 //! \returns uint32_t. The mask of the set flags. 1170 //! Valid values is an OR of 1171 //! - \b TIMER_A_CAPTURE_OVERFLOW, 1172 //! - \b TIMER_A_CAPTURECOMPARE_INTERRUPT_FLAG 1173 // 1174 //***************************************************************************** 1175 extern uint32_t Timer_A_getCaptureCompareInterruptStatus(uint32_t timer, 1176 uint_fast16_t captureCompareRegister, uint_fast16_t mask); 1177 1178 //***************************************************************************** 1179 // 1180 //! Return capture compare interrupt status masked with the enabled interrupts. 1181 //! This function is useful to call in ISRs to get a list of pending 1182 //! interrupts that are actually enabled and could have caused 1183 //! the ISR. 1184 //! 1185 //! \param timer is the instance of the Timer_A module. Valid parameters 1186 //! vary from part to part, but can include: 1187 //! - \b TIMER_A0_BASE 1188 //! - \b TIMER_A1_BASE 1189 //! - \b TIMER_A2_BASE 1190 //! - \b TIMER_A3_BASE 1191 //! \param captureCompareRegister is the selected capture compare register 1192 //! 1193 //! \returns uint32_t. The mask of the set flags. 1194 //! Valid values is an OR of 1195 //! - \b TIMER_A_CAPTURE_OVERFLOW, 1196 //! - \b TIMER_A_CAPTURECOMPARE_INTERRUPT_FLAG 1197 // 1198 //***************************************************************************** 1199 extern uint32_t Timer_A_getCaptureCompareEnabledInterruptStatus(uint32_t timer, 1200 uint_fast16_t captureCompareRegister); 1201 1202 //***************************************************************************** 1203 // 1204 //! Registers an interrupt handler for the timer capture compare interrupt. 1205 //! 1206 //! \param timer is the instance of the Timer_A module. Valid parameters 1207 //! vary from part to part, but can include: 1208 //! - \b TIMER_A0_BASE 1209 //! - \b TIMER_A1_BASE 1210 //! - \b TIMER_A2_BASE 1211 //! - \b TIMER_A3_BASE 1212 //! 1213 //! \param interruptSelect Selects which timer interrupt handler to 1214 //! register. For the timer module, there are two separate interrupt handlers 1215 //! that can be registered: 1216 //! - \b TIMER_A_CCR0_INTERRUPT Corresponds to the interrupt for CCR0 1217 //! - \b TIMER_A_CCRX_AND_OVERFLOW_INTERRUPT Corresponds to the 1218 //! interrupt for CCR1-6, as well as the overflow interrupt. 1219 //! 1220 //! \param intHandler is a pointer to the function to be called when the 1221 //! timer capture compare interrupt occurs. 1222 //! 1223 //! This function registers the handler to be called when a timer 1224 //! interrupt occurs. This function enables the global interrupt in the 1225 //! interrupt controller; specific Timer_Ainterrupts must be enabled 1226 //! via Timer_A_enableInterrupt(). It is the interrupt handler's 1227 //! responsibility to clear the interrupt source 1228 //! via Timer_A_clearCaptureCompareInterrupt(). 1229 //! 1230 //! \return None. 1231 // 1232 //***************************************************************************** 1233 extern void Timer_A_registerInterrupt(uint32_t timer, 1234 uint_fast8_t interruptSelect, void (*intHandler)(void)); 1235 1236 //***************************************************************************** 1237 // 1238 //! Unregisters the interrupt handler for the timer 1239 //! 1240 //! \param timer is the instance of the Timer_A module. Valid parameters 1241 //! vary from part to part, but can include: 1242 //! - \b TIMER_A0_BASE 1243 //! - \b TIMER_A1_BASE 1244 //! - \b TIMER_A2_BASE 1245 //! - \b TIMER_A3_BASE 1246 //! 1247 //! \param interruptSelect Selects which timer interrupt handler to 1248 //! register. For the timer module, there are two separate interrupt handlers 1249 //! that can be registered: 1250 //! - \b TIMER_A_CCR0_INTERRUPT Corresponds to the interrupt for CCR0 1251 //! - \b TIMER_A_CCRX_AND_OVERFLOW_INTERRUPT Corresponds to the 1252 //! interrupt for CCR1-6, as well as the overflow interrupt. 1253 //! 1254 //! This function unregisters the handler to be called when timer 1255 //! interrupt occurs. This function also masks off the interrupt in the 1256 //! interrupt controller so that the interrupt handler no longer is called. 1257 //! 1258 //! \sa Interrupt_registerInterrupt() for important information about 1259 //! registering interrupt handlers. 1260 //! 1261 //! \return None. 1262 // 1263 //***************************************************************************** 1264 extern void Timer_A_unregisterInterrupt(uint32_t timer, 1265 uint_fast8_t interruptSelect); 1266 1267 /* Backwards Compatibility Layer */ 1268 #define Timer_A_clearTimerInterrupt Timer_A_clearInterruptFlag 1269 #define Timer_A_clear Timer_A_clearTimer 1270 #define Timer_A_initCaptureMode Timer_A_initCapture 1271 #define Timer_A_initCompareMode Timer_A_initCompare 1272 #define Timer_A_initContinuousMode Timer_A_configureContinuousMode 1273 #define Timer_A_initUpDownMode Timer_A_configureUpDownMode 1274 #define Timer_A_initUpMode Timer_A_configureUpMode 1275 #define Timer_A_outputPWM Timer_A_generatePWM 1276 #define Timer_A_stop Timer_A_stopTimer 1277 1278 //***************************************************************************** 1279 // 1280 // Mark the end of the C bindings section for C++ compilers. 1281 // 1282 //***************************************************************************** 1283 #ifdef __cplusplus 1284 } 1285 #endif 1286 1287 //***************************************************************************** 1288 // 1289 // Close the Doxygen group. 1290 //! @} 1291 // 1292 //***************************************************************************** 1293 1294 #endif /* TIMERA_H_ */ 1295