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