2 * Copyright (c) 2014, Texas Instruments Incorporated
\r
3 * All rights reserved.
\r
5 * Redistribution and use in source and binary forms, with or without
\r
6 * modification, are permitted provided that the following conditions
\r
9 * * Redistributions of source code must retain the above copyright
\r
10 * notice, this list of conditions and the following disclaimer.
\r
12 * * Redistributions in binary form must reproduce the above copyright
\r
13 * notice, this list of conditions and the following disclaimer in the
\r
14 * documentation and/or other materials provided with the distribution.
\r
16 * * Neither the name of Texas Instruments Incorporated nor the names of
\r
17 * its contributors may be used to endorse or promote products derived
\r
18 * from this software without specific prior written permission.
\r
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
\r
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
\r
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
\r
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
\r
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
\r
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
\r
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
\r
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
\r
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
\r
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
\r
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
32 //*****************************************************************************
\r
34 // timer_b.h - Driver for the TIMER_B Module.
\r
36 //*****************************************************************************
\r
38 #ifndef __MSP430WARE_TIMER_B_H__
\r
39 #define __MSP430WARE_TIMER_B_H__
\r
41 #include "inc/hw_memmap.h"
\r
43 #ifdef __MSP430_HAS_TxB7__
\r
45 //*****************************************************************************
\r
47 // If building with a C++ compiler, make all of the definitions in this header
\r
48 // have a C binding.
\r
50 //*****************************************************************************
\r
56 #include "inc/hw_regaccess.h"
\r
57 //*****************************************************************************
\r
59 // The following is a parameter used for Timer_B_getCounterValue that
\r
60 // determines the maximum difference in counts of the TAxR register for a
\r
63 //*****************************************************************************
\r
64 #define TIMER_B_THRESHOLD 50
\r
66 //*****************************************************************************
\r
68 //! \brief Used in the Timer_B_outputPWM() function as the param parameter.
\r
70 //*****************************************************************************
\r
71 typedef struct Timer_B_outputPWMParam
\r
73 //! Selects the clock source
\r
74 //! \n Valid values are:
\r
75 //! - \b TIMER_B_CLOCKSOURCE_EXTERNAL_TXCLK [Default]
\r
76 //! - \b TIMER_B_CLOCKSOURCE_ACLK
\r
77 //! - \b TIMER_B_CLOCKSOURCE_SMCLK
\r
78 //! - \b TIMER_B_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK
\r
79 uint16_t clockSource;
\r
80 //! Is the divider for Clock source.
\r
81 //! \n Valid values are:
\r
82 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_1 [Default]
\r
83 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_2
\r
84 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_3
\r
85 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_4
\r
86 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_5
\r
87 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_6
\r
88 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_7
\r
89 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_8
\r
90 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_10
\r
91 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_12
\r
92 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_14
\r
93 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_16
\r
94 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_20
\r
95 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_24
\r
96 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_28
\r
97 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_32
\r
98 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_40
\r
99 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_48
\r
100 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_56
\r
101 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_64
\r
102 uint16_t clockSourceDivider;
\r
103 //! Selects the desired Timer_B period
\r
104 uint16_t timerPeriod;
\r
105 //! Selects the compare register being used. Refer to datasheet to ensure
\r
106 //! the device has the compare register being used.
\r
107 //! \n Valid values are:
\r
108 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
\r
109 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
\r
110 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
\r
111 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
\r
112 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
\r
113 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
\r
114 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
\r
115 uint16_t compareRegister;
\r
116 //! Specifies the output mode.
\r
117 //! \n Valid values are:
\r
118 //! - \b TIMER_B_OUTPUTMODE_OUTBITVALUE [Default]
\r
119 //! - \b TIMER_B_OUTPUTMODE_SET
\r
120 //! - \b TIMER_B_OUTPUTMODE_TOGGLE_RESET
\r
121 //! - \b TIMER_B_OUTPUTMODE_SET_RESET
\r
122 //! - \b TIMER_B_OUTPUTMODE_TOGGLE
\r
123 //! - \b TIMER_B_OUTPUTMODE_RESET
\r
124 //! - \b TIMER_B_OUTPUTMODE_TOGGLE_SET
\r
125 //! - \b TIMER_B_OUTPUTMODE_RESET_SET
\r
126 uint16_t compareOutputMode;
\r
127 //! Specifies the dutycycle for the generated waveform
\r
128 uint16_t dutyCycle;
\r
129 } Timer_B_outputPWMParam;
\r
131 //*****************************************************************************
\r
133 //! \brief Used in the Timer_B_initUpMode() function as the param parameter.
\r
135 //*****************************************************************************
\r
136 typedef struct Timer_B_initUpModeParam
\r
138 //! Selects the clock source
\r
139 //! \n Valid values are:
\r
140 //! - \b TIMER_B_CLOCKSOURCE_EXTERNAL_TXCLK [Default]
\r
141 //! - \b TIMER_B_CLOCKSOURCE_ACLK
\r
142 //! - \b TIMER_B_CLOCKSOURCE_SMCLK
\r
143 //! - \b TIMER_B_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK
\r
144 uint16_t clockSource;
\r
145 //! Is the divider for Clock source.
\r
146 //! \n Valid values are:
\r
147 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_1 [Default]
\r
148 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_2
\r
149 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_3
\r
150 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_4
\r
151 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_5
\r
152 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_6
\r
153 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_7
\r
154 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_8
\r
155 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_10
\r
156 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_12
\r
157 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_14
\r
158 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_16
\r
159 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_20
\r
160 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_24
\r
161 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_28
\r
162 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_32
\r
163 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_40
\r
164 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_48
\r
165 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_56
\r
166 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_64
\r
167 uint16_t clockSourceDivider;
\r
168 //! Is the specified Timer_B period. This is the value that gets written
\r
169 //! into the CCR0. Limited to 16 bits[uint16_t]
\r
170 uint16_t timerPeriod;
\r
171 //! Is to enable or disable Timer_B interrupt
\r
172 //! \n Valid values are:
\r
173 //! - \b TIMER_B_TBIE_INTERRUPT_ENABLE
\r
174 //! - \b TIMER_B_TBIE_INTERRUPT_DISABLE [Default]
\r
175 uint16_t timerInterruptEnable_TBIE;
\r
176 //! Is to enable or disable Timer_B CCR0 capture compare interrupt.
\r
177 //! \n Valid values are:
\r
178 //! - \b TIMER_B_CCIE_CCR0_INTERRUPT_ENABLE
\r
179 //! - \b TIMER_B_CCIE_CCR0_INTERRUPT_DISABLE [Default]
\r
180 uint16_t captureCompareInterruptEnable_CCR0_CCIE;
\r
181 //! Decides if Timer_B clock divider, count direction, count need to be
\r
183 //! \n Valid values are:
\r
184 //! - \b TIMER_B_DO_CLEAR
\r
185 //! - \b TIMER_B_SKIP_CLEAR [Default]
\r
186 uint16_t timerClear;
\r
187 //! Whether to start the timer immediately
\r
189 } Timer_B_initUpModeParam;
\r
191 //*****************************************************************************
\r
193 //! \brief Used in the Timer_B_initCaptureMode() function as the param
\r
196 //*****************************************************************************
\r
197 typedef struct Timer_B_initCaptureModeParam
\r
199 //! Selects the capture register being used. Refer to datasheet to ensure
\r
200 //! the device has the capture register being used.
\r
201 //! \n Valid values are:
\r
202 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
\r
203 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
\r
204 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
\r
205 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
\r
206 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
\r
207 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
\r
208 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
\r
209 uint16_t captureRegister;
\r
210 //! Is the capture mode selected.
\r
211 //! \n Valid values are:
\r
212 //! - \b TIMER_B_CAPTUREMODE_NO_CAPTURE [Default]
\r
213 //! - \b TIMER_B_CAPTUREMODE_RISING_EDGE
\r
214 //! - \b TIMER_B_CAPTUREMODE_FALLING_EDGE
\r
215 //! - \b TIMER_B_CAPTUREMODE_RISING_AND_FALLING_EDGE
\r
216 uint16_t captureMode;
\r
217 //! Decides the Input Select
\r
218 //! \n Valid values are:
\r
219 //! - \b TIMER_B_CAPTURE_INPUTSELECT_CCIxA [Default]
\r
220 //! - \b TIMER_B_CAPTURE_INPUTSELECT_CCIxB
\r
221 //! - \b TIMER_B_CAPTURE_INPUTSELECT_GND
\r
222 //! - \b TIMER_B_CAPTURE_INPUTSELECT_Vcc
\r
223 uint16_t captureInputSelect;
\r
224 //! Decides if capture source should be synchronized with Timer_B clock
\r
225 //! \n Valid values are:
\r
226 //! - \b TIMER_B_CAPTURE_ASYNCHRONOUS [Default]
\r
227 //! - \b TIMER_B_CAPTURE_SYNCHRONOUS
\r
228 uint16_t synchronizeCaptureSource;
\r
229 //! Is to enable or disable Timer_B capture compare interrupt.
\r
230 //! \n Valid values are:
\r
231 //! - \b TIMER_B_CAPTURECOMPARE_INTERRUPT_DISABLE [Default]
\r
232 //! - \b TIMER_B_CAPTURECOMPARE_INTERRUPT_ENABLE
\r
233 uint16_t captureInterruptEnable;
\r
234 //! Specifies the output mode.
\r
235 //! \n Valid values are:
\r
236 //! - \b TIMER_B_OUTPUTMODE_OUTBITVALUE [Default]
\r
237 //! - \b TIMER_B_OUTPUTMODE_SET
\r
238 //! - \b TIMER_B_OUTPUTMODE_TOGGLE_RESET
\r
239 //! - \b TIMER_B_OUTPUTMODE_SET_RESET
\r
240 //! - \b TIMER_B_OUTPUTMODE_TOGGLE
\r
241 //! - \b TIMER_B_OUTPUTMODE_RESET
\r
242 //! - \b TIMER_B_OUTPUTMODE_TOGGLE_SET
\r
243 //! - \b TIMER_B_OUTPUTMODE_RESET_SET
\r
244 uint16_t captureOutputMode;
\r
245 } Timer_B_initCaptureModeParam;
\r
247 //*****************************************************************************
\r
249 //! \brief Used in the Timer_B_initContinuousMode() function as the param
\r
252 //*****************************************************************************
\r
253 typedef struct Timer_B_initContinuousModeParam
\r
255 //! Selects the clock source
\r
256 //! \n Valid values are:
\r
257 //! - \b TIMER_B_CLOCKSOURCE_EXTERNAL_TXCLK [Default]
\r
258 //! - \b TIMER_B_CLOCKSOURCE_ACLK
\r
259 //! - \b TIMER_B_CLOCKSOURCE_SMCLK
\r
260 //! - \b TIMER_B_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK
\r
261 uint16_t clockSource;
\r
262 //! Is the divider for Clock source.
\r
263 //! \n Valid values are:
\r
264 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_1 [Default]
\r
265 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_2
\r
266 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_3
\r
267 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_4
\r
268 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_5
\r
269 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_6
\r
270 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_7
\r
271 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_8
\r
272 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_10
\r
273 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_12
\r
274 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_14
\r
275 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_16
\r
276 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_20
\r
277 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_24
\r
278 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_28
\r
279 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_32
\r
280 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_40
\r
281 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_48
\r
282 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_56
\r
283 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_64
\r
284 uint16_t clockSourceDivider;
\r
285 //! Is to enable or disable Timer_B interrupt
\r
286 //! \n Valid values are:
\r
287 //! - \b TIMER_B_TBIE_INTERRUPT_ENABLE
\r
288 //! - \b TIMER_B_TBIE_INTERRUPT_DISABLE [Default]
\r
289 uint16_t timerInterruptEnable_TBIE;
\r
290 //! Decides if Timer_B clock divider, count direction, count need to be
\r
292 //! \n Valid values are:
\r
293 //! - \b TIMER_B_DO_CLEAR
\r
294 //! - \b TIMER_B_SKIP_CLEAR [Default]
\r
295 uint16_t timerClear;
\r
296 //! Whether to start the timer immediately
\r
298 } Timer_B_initContinuousModeParam;
\r
300 //*****************************************************************************
\r
302 //! \brief Used in the Timer_B_initUpDownMode() function as the param
\r
305 //*****************************************************************************
\r
306 typedef struct Timer_B_initUpDownModeParam
\r
308 //! Selects the clock source
\r
309 //! \n Valid values are:
\r
310 //! - \b TIMER_B_CLOCKSOURCE_EXTERNAL_TXCLK [Default]
\r
311 //! - \b TIMER_B_CLOCKSOURCE_ACLK
\r
312 //! - \b TIMER_B_CLOCKSOURCE_SMCLK
\r
313 //! - \b TIMER_B_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK
\r
314 uint16_t clockSource;
\r
315 //! Is the divider for Clock source.
\r
316 //! \n Valid values are:
\r
317 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_1 [Default]
\r
318 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_2
\r
319 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_3
\r
320 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_4
\r
321 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_5
\r
322 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_6
\r
323 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_7
\r
324 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_8
\r
325 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_10
\r
326 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_12
\r
327 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_14
\r
328 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_16
\r
329 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_20
\r
330 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_24
\r
331 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_28
\r
332 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_32
\r
333 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_40
\r
334 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_48
\r
335 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_56
\r
336 //! - \b TIMER_B_CLOCKSOURCE_DIVIDER_64
\r
337 uint16_t clockSourceDivider;
\r
338 //! Is the specified Timer_B period
\r
339 uint16_t timerPeriod;
\r
340 //! Is to enable or disable Timer_B interrupt
\r
341 //! \n Valid values are:
\r
342 //! - \b TIMER_B_TBIE_INTERRUPT_ENABLE
\r
343 //! - \b TIMER_B_TBIE_INTERRUPT_DISABLE [Default]
\r
344 uint16_t timerInterruptEnable_TBIE;
\r
345 //! Is to enable or disable Timer_B CCR0 capture compare interrupt.
\r
346 //! \n Valid values are:
\r
347 //! - \b TIMER_B_CCIE_CCR0_INTERRUPT_ENABLE
\r
348 //! - \b TIMER_B_CCIE_CCR0_INTERRUPT_DISABLE [Default]
\r
349 uint16_t captureCompareInterruptEnable_CCR0_CCIE;
\r
350 //! Decides if Timer_B clock divider, count direction, count need to be
\r
352 //! \n Valid values are:
\r
353 //! - \b TIMER_B_DO_CLEAR
\r
354 //! - \b TIMER_B_SKIP_CLEAR [Default]
\r
355 uint16_t timerClear;
\r
356 //! Whether to start the timer immediately
\r
358 } Timer_B_initUpDownModeParam;
\r
360 //*****************************************************************************
\r
362 //! \brief Used in the Timer_B_initCompareMode() function as the param
\r
365 //*****************************************************************************
\r
366 typedef struct Timer_B_initCompareModeParam
\r
368 //! Selects the compare register being used. Refer to datasheet to ensure
\r
369 //! the device has the compare register being used.
\r
370 //! \n Valid values are:
\r
371 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
\r
372 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
\r
373 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
\r
374 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
\r
375 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
\r
376 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
\r
377 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
\r
378 uint16_t compareRegister;
\r
379 //! Is to enable or disable Timer_B capture compare interrupt.
\r
380 //! \n Valid values are:
\r
381 //! - \b TIMER_B_CAPTURECOMPARE_INTERRUPT_DISABLE [Default]
\r
382 //! - \b TIMER_B_CAPTURECOMPARE_INTERRUPT_ENABLE
\r
383 uint16_t compareInterruptEnable;
\r
384 //! Specifies the output mode.
\r
385 //! \n Valid values are:
\r
386 //! - \b TIMER_B_OUTPUTMODE_OUTBITVALUE [Default]
\r
387 //! - \b TIMER_B_OUTPUTMODE_SET
\r
388 //! - \b TIMER_B_OUTPUTMODE_TOGGLE_RESET
\r
389 //! - \b TIMER_B_OUTPUTMODE_SET_RESET
\r
390 //! - \b TIMER_B_OUTPUTMODE_TOGGLE
\r
391 //! - \b TIMER_B_OUTPUTMODE_RESET
\r
392 //! - \b TIMER_B_OUTPUTMODE_TOGGLE_SET
\r
393 //! - \b TIMER_B_OUTPUTMODE_RESET_SET
\r
394 uint16_t compareOutputMode;
\r
395 //! Is the count to be compared with in compare mode
\r
396 uint16_t compareValue;
\r
397 } Timer_B_initCompareModeParam;
\r
399 //*****************************************************************************
\r
401 // The following are values that can be passed to the param parameter for
\r
402 // functions: Timer_B_initContinuousMode(), Timer_B_initUpMode(),
\r
403 // Timer_B_initUpDownMode(), and Timer_B_outputPWM().
\r
405 //*****************************************************************************
\r
406 #define TIMER_B_CLOCKSOURCE_DIVIDER_1 0x00
\r
407 #define TIMER_B_CLOCKSOURCE_DIVIDER_2 0x08
\r
408 #define TIMER_B_CLOCKSOURCE_DIVIDER_3 0x02
\r
409 #define TIMER_B_CLOCKSOURCE_DIVIDER_4 0x10
\r
410 #define TIMER_B_CLOCKSOURCE_DIVIDER_5 0x04
\r
411 #define TIMER_B_CLOCKSOURCE_DIVIDER_6 0x05
\r
412 #define TIMER_B_CLOCKSOURCE_DIVIDER_7 0x06
\r
413 #define TIMER_B_CLOCKSOURCE_DIVIDER_8 0x18
\r
414 #define TIMER_B_CLOCKSOURCE_DIVIDER_10 0x0C
\r
415 #define TIMER_B_CLOCKSOURCE_DIVIDER_12 0x0D
\r
416 #define TIMER_B_CLOCKSOURCE_DIVIDER_14 0x0E
\r
417 #define TIMER_B_CLOCKSOURCE_DIVIDER_16 0x0F
\r
418 #define TIMER_B_CLOCKSOURCE_DIVIDER_20 0x14
\r
419 #define TIMER_B_CLOCKSOURCE_DIVIDER_24 0x15
\r
420 #define TIMER_B_CLOCKSOURCE_DIVIDER_28 0x16
\r
421 #define TIMER_B_CLOCKSOURCE_DIVIDER_32 0x17
\r
422 #define TIMER_B_CLOCKSOURCE_DIVIDER_40 0x1C
\r
423 #define TIMER_B_CLOCKSOURCE_DIVIDER_48 0x1D
\r
424 #define TIMER_B_CLOCKSOURCE_DIVIDER_56 0x1E
\r
425 #define TIMER_B_CLOCKSOURCE_DIVIDER_64 0x1F
\r
427 //*****************************************************************************
\r
429 // The following are values that can be passed to the timerMode parameter for
\r
430 // functions: Timer_B_startCounter().
\r
432 //*****************************************************************************
\r
433 #define TIMER_B_STOP_MODE MC_0
\r
434 #define TIMER_B_UP_MODE MC_1
\r
435 #define TIMER_B_CONTINUOUS_MODE MC_2
\r
436 #define TIMER_B_UPDOWN_MODE MC_3
\r
438 //*****************************************************************************
\r
440 // The following are values that can be passed to the param parameter for
\r
441 // functions: Timer_B_initContinuousMode(), Timer_B_initUpMode(), and
\r
442 // Timer_B_initUpDownMode().
\r
444 //*****************************************************************************
\r
445 #define TIMER_B_DO_CLEAR TBCLR
\r
446 #define TIMER_B_SKIP_CLEAR 0x00
\r
448 //*****************************************************************************
\r
450 // The following are values that can be passed to the param parameter for
\r
451 // functions: Timer_B_initContinuousMode(), Timer_B_initUpMode(),
\r
452 // Timer_B_initUpDownMode(), and Timer_B_outputPWM().
\r
454 //*****************************************************************************
\r
455 #define TIMER_B_CLOCKSOURCE_EXTERNAL_TXCLK TBSSEL__TACLK
\r
456 #define TIMER_B_CLOCKSOURCE_ACLK TBSSEL__ACLK
\r
457 #define TIMER_B_CLOCKSOURCE_SMCLK TBSSEL__SMCLK
\r
458 #define TIMER_B_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK TBSSEL__INCLK
\r
460 //*****************************************************************************
\r
462 // The following are values that can be passed to the param parameter for
\r
463 // functions: Timer_B_initContinuousMode(), Timer_B_initUpMode(), and
\r
464 // Timer_B_initUpDownMode().
\r
466 //*****************************************************************************
\r
467 #define TIMER_B_TBIE_INTERRUPT_ENABLE TBIE
\r
468 #define TIMER_B_TBIE_INTERRUPT_DISABLE 0x00
\r
470 //*****************************************************************************
\r
472 // The following are values that can be passed to the param parameter for
\r
473 // functions: Timer_B_initUpMode(), and Timer_B_initUpDownMode().
\r
475 //*****************************************************************************
\r
476 #define TIMER_B_CCIE_CCR0_INTERRUPT_ENABLE CCIE
\r
477 #define TIMER_B_CCIE_CCR0_INTERRUPT_DISABLE 0x00
\r
479 //*****************************************************************************
\r
481 // The following are values that can be passed to the param parameter for
\r
482 // functions: Timer_B_initCaptureMode(), and Timer_B_initCompareMode().
\r
484 //*****************************************************************************
\r
485 #define TIMER_B_CAPTURECOMPARE_INTERRUPT_DISABLE 0x00
\r
486 #define TIMER_B_CAPTURECOMPARE_INTERRUPT_ENABLE CCIE
\r
488 //*****************************************************************************
\r
490 // The following are values that can be passed to the param parameter for
\r
491 // functions: Timer_B_initCaptureMode().
\r
493 //*****************************************************************************
\r
494 #define TIMER_B_CAPTURE_INPUTSELECT_CCIxA CCIS_0
\r
495 #define TIMER_B_CAPTURE_INPUTSELECT_CCIxB CCIS_1
\r
496 #define TIMER_B_CAPTURE_INPUTSELECT_GND CCIS_2
\r
497 #define TIMER_B_CAPTURE_INPUTSELECT_Vcc CCIS_3
\r
499 //*****************************************************************************
\r
501 // The following are values that can be passed to the param parameter for
\r
502 // functions: Timer_B_initCaptureMode(), Timer_B_initCompareMode(), and
\r
503 // Timer_B_outputPWM().
\r
505 //*****************************************************************************
\r
506 #define TIMER_B_OUTPUTMODE_OUTBITVALUE OUTMOD_0
\r
507 #define TIMER_B_OUTPUTMODE_SET OUTMOD_1
\r
508 #define TIMER_B_OUTPUTMODE_TOGGLE_RESET OUTMOD_2
\r
509 #define TIMER_B_OUTPUTMODE_SET_RESET OUTMOD_3
\r
510 #define TIMER_B_OUTPUTMODE_TOGGLE OUTMOD_4
\r
511 #define TIMER_B_OUTPUTMODE_RESET OUTMOD_5
\r
512 #define TIMER_B_OUTPUTMODE_TOGGLE_SET OUTMOD_6
\r
513 #define TIMER_B_OUTPUTMODE_RESET_SET OUTMOD_7
\r
515 //*****************************************************************************
\r
517 // The following are values that can be passed to the compareRegister parameter
\r
518 // for functions: Timer_B_setCompareValue(), and
\r
519 // Timer_B_initCompareLatchLoadEvent(); the captureCompareRegister parameter
\r
520 // for functions: Timer_B_enableCaptureCompareInterrupt(),
\r
521 // Timer_B_disableCaptureCompareInterrupt(),
\r
522 // Timer_B_getCaptureCompareInterruptStatus(),
\r
523 // Timer_B_getSynchronizedCaptureCompareInput(),
\r
524 // Timer_B_getOutputForOutputModeOutBitValue(),
\r
525 // Timer_B_getCaptureCompareCount(),
\r
526 // Timer_B_setOutputForOutputModeOutBitValue(), and
\r
527 // Timer_B_clearCaptureCompareInterrupt(); the param parameter for functions:
\r
528 // Timer_B_initCaptureMode(), Timer_B_initCompareMode(), and
\r
529 // Timer_B_outputPWM().
\r
531 //*****************************************************************************
\r
532 #define TIMER_B_CAPTURECOMPARE_REGISTER_0 0x02
\r
533 #define TIMER_B_CAPTURECOMPARE_REGISTER_1 0x04
\r
534 #define TIMER_B_CAPTURECOMPARE_REGISTER_2 0x06
\r
535 #define TIMER_B_CAPTURECOMPARE_REGISTER_3 0x08
\r
536 #define TIMER_B_CAPTURECOMPARE_REGISTER_4 0x0A
\r
537 #define TIMER_B_CAPTURECOMPARE_REGISTER_5 0x0C
\r
538 #define TIMER_B_CAPTURECOMPARE_REGISTER_6 0x0E
\r
540 //*****************************************************************************
\r
542 // The following are values that can be passed to the param parameter for
\r
543 // functions: Timer_B_initCaptureMode().
\r
545 //*****************************************************************************
\r
546 #define TIMER_B_CAPTUREMODE_NO_CAPTURE CM_0
\r
547 #define TIMER_B_CAPTUREMODE_RISING_EDGE CM_1
\r
548 #define TIMER_B_CAPTUREMODE_FALLING_EDGE CM_2
\r
549 #define TIMER_B_CAPTUREMODE_RISING_AND_FALLING_EDGE CM_3
\r
551 //*****************************************************************************
\r
553 // The following are values that can be passed to the param parameter for
\r
554 // functions: Timer_B_initCaptureMode().
\r
556 //*****************************************************************************
\r
557 #define TIMER_B_CAPTURE_ASYNCHRONOUS 0x00
\r
558 #define TIMER_B_CAPTURE_SYNCHRONOUS SCS
\r
560 //*****************************************************************************
\r
562 // The following are values that can be passed to the mask parameter for
\r
563 // functions: Timer_B_getCaptureCompareInterruptStatus() as well as returned by
\r
564 // the Timer_B_getCaptureCompareInterruptStatus() function.
\r
566 //*****************************************************************************
\r
567 #define TIMER_B_CAPTURE_OVERFLOW COV
\r
568 #define TIMER_B_CAPTURECOMPARE_INTERRUPT_FLAG CCIFG
\r
570 //*****************************************************************************
\r
572 // The following are values that can be passed to the synchronized parameter
\r
573 // for functions: Timer_B_getSynchronizedCaptureCompareInput().
\r
575 //*****************************************************************************
\r
576 #define TIMER_B_READ_SYNCHRONIZED_CAPTURECOMPAREINPUT SCCI
\r
577 #define TIMER_B_READ_CAPTURE_COMPARE_INPUT CCI
\r
579 //*****************************************************************************
\r
581 // The following are values that can be passed toThe following are values that
\r
582 // can be returned by the Timer_B_getSynchronizedCaptureCompareInput()
\r
585 //*****************************************************************************
\r
586 #define TIMER_B_CAPTURECOMPARE_INPUT_HIGH 0x01
\r
587 #define TIMER_B_CAPTURECOMPARE_INPUT_LOW 0x00
\r
589 //*****************************************************************************
\r
591 // The following are values that can be passed to the outputModeOutBitValue
\r
592 // parameter for functions: Timer_B_setOutputForOutputModeOutBitValue() as well
\r
593 // as returned by the Timer_B_getOutputForOutputModeOutBitValue() function.
\r
595 //*****************************************************************************
\r
596 #define TIMER_B_OUTPUTMODE_OUTBITVALUE_HIGH OUT
\r
597 #define TIMER_B_OUTPUTMODE_OUTBITVALUE_LOW 0x00
\r
599 //*****************************************************************************
\r
601 // The following are values that can be passed to the counterLength parameter
\r
602 // for functions: Timer_B_selectCounterLength().
\r
604 //*****************************************************************************
\r
605 #define TIMER_B_COUNTER_16BIT CNTL_3
\r
606 #define TIMER_B_COUNTER_12BIT CNTL_2
\r
607 #define TIMER_B_COUNTER_10BIT CNTL_1
\r
608 #define TIMER_B_COUNTER_8BIT CNTL_0
\r
610 //*****************************************************************************
\r
612 // The following are values that can be passed to the groupLatch parameter for
\r
613 // functions: Timer_B_selectLatchingGroup().
\r
615 //*****************************************************************************
\r
616 #define TIMER_B_GROUP_NONE TBCLGRP_0
\r
617 #define TIMER_B_GROUP_CL12_CL23_CL56 TBCLGRP_1
\r
618 #define TIMER_B_GROUP_CL123_CL456 TBCLGRP_2
\r
619 #define TIMER_B_GROUP_ALL TBCLGRP_3
\r
621 //*****************************************************************************
\r
623 // The following are values that can be passed to the compareLatchLoadEvent
\r
624 // parameter for functions: Timer_B_initCompareLatchLoadEvent().
\r
626 //*****************************************************************************
\r
627 #define TIMER_B_LATCH_ON_WRITE_TO_TBxCCRn_COMPARE_REGISTER CLLD_0
\r
628 #define TIMER_B_LATCH_WHEN_COUNTER_COUNTS_TO_0_IN_UP_OR_CONT_MODE CLLD_1
\r
629 #define TIMER_B_LATCH_WHEN_COUNTER_COUNTS_TO_0_IN_UPDOWN_MODE CLLD_2
\r
630 #define TIMER_B_LATCH_WHEN_COUNTER_COUNTS_TO_CURRENT_COMPARE_LATCH_VALUE CLLD_3
\r
632 //*****************************************************************************
\r
634 // The following are values that can be passed toThe following are values that
\r
635 // can be returned by the Timer_B_getInterruptStatus() function.
\r
637 //*****************************************************************************
\r
638 #define TIMER_B_INTERRUPT_NOT_PENDING 0x00
\r
639 #define TIMER_B_INTERRUPT_PENDING 0x01
\r
641 //*****************************************************************************
\r
643 // Prototypes for the APIs.
\r
645 //*****************************************************************************
\r
647 //*****************************************************************************
\r
649 //! \brief Starts Timer_B counter
\r
651 //! This function assumes that the timer has been previously configured using
\r
652 //! Timer_B_configureContinuousMode, Timer_B_configureUpMode or
\r
653 //! Timer_B_configureUpDownMode.
\r
655 //! \param baseAddress is the base address of the TIMER_B module.
\r
656 //! \param timerMode selects the mode of the timer
\r
657 //! Valid values are:
\r
658 //! - \b TIMER_B_STOP_MODE
\r
659 //! - \b TIMER_B_UP_MODE
\r
660 //! - \b TIMER_B_CONTINUOUS_MODE [Default]
\r
661 //! - \b TIMER_B_UPDOWN_MODE
\r
663 //! Modified bits of \b TBxCTL register.
\r
667 //*****************************************************************************
\r
668 extern void Timer_B_startCounter(uint16_t baseAddress,
\r
669 uint16_t timerMode);
\r
671 //*****************************************************************************
\r
673 //! \brief Configures Timer_B in continuous mode.
\r
675 //! This API does not start the timer. Timer needs to be started when required
\r
676 //! using the Timer_B_startCounter API.
\r
678 //! \param baseAddress is the base address of the TIMER_B module.
\r
679 //! \param param is the pointer to struct for continuous mode initialization.
\r
681 //! Modified bits of \b TBxCTL register.
\r
685 //*****************************************************************************
\r
686 extern void Timer_B_initContinuousMode(uint16_t baseAddress,
\r
687 Timer_B_initContinuousModeParam *param);
\r
689 //*****************************************************************************
\r
691 //! \brief Configures Timer_B in up mode.
\r
693 //! This API does not start the timer. Timer needs to be started when required
\r
694 //! using the Timer_B_startCounter API.
\r
696 //! \param baseAddress is the base address of the TIMER_B module.
\r
697 //! \param param is the pointer to struct for up mode initialization.
\r
699 //! Modified bits of \b TBxCTL register, bits of \b TBxCCTL0 register and bits
\r
700 //! of \b TBxCCR0 register.
\r
704 //*****************************************************************************
\r
705 extern void Timer_B_initUpMode(uint16_t baseAddress,
\r
706 Timer_B_initUpModeParam *param);
\r
708 //*****************************************************************************
\r
710 //! \brief Configures Timer_B in up down mode.
\r
712 //! This API does not start the timer. Timer needs to be started when required
\r
713 //! using the Timer_B_startCounter API.
\r
715 //! \param baseAddress is the base address of the TIMER_B module.
\r
716 //! \param param is the pointer to struct for up-down mode initialization.
\r
718 //! Modified bits of \b TBxCTL register, bits of \b TBxCCTL0 register and bits
\r
719 //! of \b TBxCCR0 register.
\r
723 //*****************************************************************************
\r
724 extern void Timer_B_initUpDownMode(uint16_t baseAddress,
\r
725 Timer_B_initUpDownModeParam *param);
\r
727 //*****************************************************************************
\r
729 //! \brief Initializes Capture Mode
\r
731 //! \param baseAddress is the base address of the TIMER_B module.
\r
732 //! \param param is the pointer to struct for capture mode initialization.
\r
734 //! Modified bits of \b TBxCCTLn register.
\r
738 //*****************************************************************************
\r
739 extern void Timer_B_initCaptureMode(uint16_t baseAddress,
\r
740 Timer_B_initCaptureModeParam *param);
\r
742 //*****************************************************************************
\r
744 //! \brief Initializes Compare Mode
\r
746 //! \param baseAddress is the base address of the TIMER_B module.
\r
747 //! \param param is the pointer to struct for compare mode initialization.
\r
749 //! Modified bits of \b TBxCCTLn register and bits of \b TBxCCRn register.
\r
753 //*****************************************************************************
\r
754 extern void Timer_B_initCompareMode(uint16_t baseAddress,
\r
755 Timer_B_initCompareModeParam *param);
\r
757 //*****************************************************************************
\r
759 //! \brief Enable Timer_B interrupt
\r
761 //! Enables Timer_B interrupt. Does not clear interrupt flags.
\r
763 //! \param baseAddress is the base address of the TIMER_B module.
\r
765 //! Modified bits of \b TBxCTL register.
\r
769 //*****************************************************************************
\r
770 extern void Timer_B_enableInterrupt(uint16_t baseAddress);
\r
772 //*****************************************************************************
\r
774 //! \brief Disable Timer_B interrupt
\r
776 //! \param baseAddress is the base address of the TIMER_B module.
\r
778 //! Modified bits of \b TBxCTL register.
\r
782 //*****************************************************************************
\r
783 extern void Timer_B_disableInterrupt(uint16_t baseAddress);
\r
785 //*****************************************************************************
\r
787 //! \brief Get Timer_B interrupt status
\r
789 //! \param baseAddress is the base address of the TIMER_B module.
\r
791 //! \return One of the following:
\r
792 //! - \b Timer_B_INTERRUPT_NOT_PENDING
\r
793 //! - \b Timer_B_INTERRUPT_PENDING
\r
794 //! \n indicating the status of the Timer_B interrupt
\r
796 //*****************************************************************************
\r
797 extern uint32_t Timer_B_getInterruptStatus(uint16_t baseAddress);
\r
799 //*****************************************************************************
\r
801 //! \brief Enable capture compare interrupt
\r
803 //! \param baseAddress is the base address of the TIMER_B module.
\r
804 //! \param captureCompareRegister selects the capture compare register being
\r
805 //! used. Refer to datasheet to ensure the device has the capture
\r
806 //! compare register being used.
\r
807 //! Valid values are:
\r
808 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
\r
809 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
\r
810 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
\r
811 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
\r
812 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
\r
813 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
\r
814 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
\r
816 //! Modified bits of \b TBxCCTLn register.
\r
820 //*****************************************************************************
\r
821 extern void Timer_B_enableCaptureCompareInterrupt(uint16_t baseAddress,
\r
822 uint16_t captureCompareRegister);
\r
824 //*****************************************************************************
\r
826 //! \brief Disable capture compare interrupt
\r
828 //! \param baseAddress is the base address of the TIMER_B module.
\r
829 //! \param captureCompareRegister selects the capture compare register being
\r
830 //! used. Refer to datasheet to ensure the device has the capture
\r
831 //! compare register being used.
\r
832 //! Valid values are:
\r
833 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
\r
834 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
\r
835 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
\r
836 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
\r
837 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
\r
838 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
\r
839 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
\r
841 //! Modified bits of \b TBxCCTLn register.
\r
845 //*****************************************************************************
\r
846 extern void Timer_B_disableCaptureCompareInterrupt(uint16_t baseAddress,
\r
847 uint16_t captureCompareRegister);
\r
849 //*****************************************************************************
\r
851 //! \brief Return capture compare interrupt status
\r
853 //! \param baseAddress is the base address of the TIMER_B module.
\r
854 //! \param captureCompareRegister selects the capture compare register being
\r
855 //! used. Refer to datasheet to ensure the device has the capture
\r
856 //! compare register being used.
\r
857 //! Valid values are:
\r
858 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
\r
859 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
\r
860 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
\r
861 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
\r
862 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
\r
863 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
\r
864 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
\r
865 //! \param mask is the mask for the interrupt status
\r
866 //! Mask value is the logical OR of any of the following:
\r
867 //! - \b TIMER_B_CAPTURE_OVERFLOW
\r
868 //! - \b TIMER_B_CAPTURECOMPARE_INTERRUPT_FLAG
\r
870 //! \return Logical OR of any of the following:
\r
871 //! - \b Timer_B_CAPTURE_OVERFLOW
\r
872 //! - \b Timer_B_CAPTURECOMPARE_INTERRUPT_FLAG
\r
873 //! \n indicating the status of the masked interrupts
\r
875 //*****************************************************************************
\r
876 extern uint32_t Timer_B_getCaptureCompareInterruptStatus(uint16_t baseAddress,
\r
877 uint16_t captureCompareRegister,
\r
880 //*****************************************************************************
\r
882 //! \brief Reset/Clear the Timer_B clock divider, count direction, count
\r
884 //! \param baseAddress is the base address of the TIMER_B module.
\r
886 //! Modified bits of \b TBxCTL register.
\r
890 //*****************************************************************************
\r
891 extern void Timer_B_clear(uint16_t baseAddress);
\r
893 //*****************************************************************************
\r
895 //! \brief Get synchronized capturecompare input
\r
897 //! \param baseAddress is the base address of the TIMER_B module.
\r
898 //! \param captureCompareRegister selects the capture compare register being
\r
899 //! used. Refer to datasheet to ensure the device has the capture
\r
900 //! compare register being used.
\r
901 //! Valid values are:
\r
902 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
\r
903 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
\r
904 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
\r
905 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
\r
906 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
\r
907 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
\r
908 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
\r
909 //! \param synchronized selects the type of capture compare input
\r
910 //! Valid values are:
\r
911 //! - \b TIMER_B_READ_SYNCHRONIZED_CAPTURECOMPAREINPUT
\r
912 //! - \b TIMER_B_READ_CAPTURE_COMPARE_INPUT
\r
914 //! \return One of the following:
\r
915 //! - \b Timer_B_CAPTURECOMPARE_INPUT_HIGH
\r
916 //! - \b Timer_B_CAPTURECOMPARE_INPUT_LOW
\r
918 //*****************************************************************************
\r
919 extern uint8_t Timer_B_getSynchronizedCaptureCompareInput(uint16_t baseAddress,
\r
920 uint16_t captureCompareRegister,
\r
921 uint16_t synchronized);
\r
923 //*****************************************************************************
\r
925 //! \brief Get output bit for output mode
\r
927 //! \param baseAddress is the base address of the TIMER_B module.
\r
928 //! \param captureCompareRegister selects the capture compare register being
\r
929 //! used. Refer to datasheet to ensure the device has the capture
\r
930 //! compare register being used.
\r
931 //! Valid values are:
\r
932 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
\r
933 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
\r
934 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
\r
935 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
\r
936 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
\r
937 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
\r
938 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
\r
940 //! \return One of the following:
\r
941 //! - \b Timer_B_OUTPUTMODE_OUTBITVALUE_HIGH
\r
942 //! - \b Timer_B_OUTPUTMODE_OUTBITVALUE_LOW
\r
944 //*****************************************************************************
\r
945 extern uint8_t Timer_B_getOutputForOutputModeOutBitValue(uint16_t baseAddress,
\r
946 uint16_t captureCompareRegister);
\r
948 //*****************************************************************************
\r
950 //! \brief Get current capturecompare count
\r
952 //! \param baseAddress is the base address of the TIMER_B module.
\r
953 //! \param captureCompareRegister selects the capture compare register being
\r
954 //! used. Refer to datasheet to ensure the device has the capture
\r
955 //! compare register being used.
\r
956 //! Valid values are:
\r
957 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
\r
958 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
\r
959 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
\r
960 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
\r
961 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
\r
962 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
\r
963 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
\r
965 //! \return Current count as uint16_t
\r
967 //*****************************************************************************
\r
968 extern uint16_t Timer_B_getCaptureCompareCount(uint16_t baseAddress,
\r
969 uint16_t captureCompareRegister);
\r
971 //*****************************************************************************
\r
973 //! \brief Set output bit for output mode
\r
975 //! \param baseAddress is the base address of the TIMER_B module.
\r
976 //! \param captureCompareRegister selects the capture compare register being
\r
977 //! used. Refer to datasheet to ensure the device has the capture
\r
978 //! compare register being used.
\r
979 //! Valid values are:
\r
980 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
\r
981 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
\r
982 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
\r
983 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
\r
984 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
\r
985 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
\r
986 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
\r
987 //! \param outputModeOutBitValue the value to be set for out bit
\r
988 //! Valid values are:
\r
989 //! - \b TIMER_B_OUTPUTMODE_OUTBITVALUE_HIGH
\r
990 //! - \b TIMER_B_OUTPUTMODE_OUTBITVALUE_LOW
\r
992 //! Modified bits of \b TBxCCTLn register.
\r
996 //*****************************************************************************
\r
997 extern void Timer_B_setOutputForOutputModeOutBitValue(uint16_t baseAddress,
\r
998 uint16_t captureCompareRegister,
\r
999 uint8_t outputModeOutBitValue);
\r
1001 //*****************************************************************************
\r
1003 //! \brief Generate a PWM with Timer_B running in up mode
\r
1005 //! \param baseAddress is the base address of the TIMER_B module.
\r
1006 //! \param param is the pointer to struct for PWM configuration.
\r
1008 //! Modified bits of \b TBxCCTLn register, bits of \b TBxCTL register, bits of
\r
1009 //! \b TBxCCTL0 register and bits of \b TBxCCR0 register.
\r
1013 //*****************************************************************************
\r
1014 extern void Timer_B_outputPWM(uint16_t baseAddress,
\r
1015 Timer_B_outputPWMParam *param);
\r
1017 //*****************************************************************************
\r
1019 //! \brief Stops the Timer_B
\r
1021 //! \param baseAddress is the base address of the TIMER_B module.
\r
1023 //! Modified bits of \b TBxCTL register.
\r
1027 //*****************************************************************************
\r
1028 extern void Timer_B_stop(uint16_t baseAddress);
\r
1030 //*****************************************************************************
\r
1032 //! \brief Sets the value of the capture-compare register
\r
1034 //! \param baseAddress is the base address of the TIMER_B module.
\r
1035 //! \param compareRegister selects the compare register being used. Refer to
\r
1036 //! datasheet to ensure the device has the compare register being used.
\r
1037 //! Valid values are:
\r
1038 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
\r
1039 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
\r
1040 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
\r
1041 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
\r
1042 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
\r
1043 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
\r
1044 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
\r
1045 //! \param compareValue is the count to be compared with in compare mode
\r
1047 //! Modified bits of \b TBxCCRn register.
\r
1051 //*****************************************************************************
\r
1052 extern void Timer_B_setCompareValue(uint16_t baseAddress,
\r
1053 uint16_t compareRegister,
\r
1054 uint16_t compareValue);
\r
1056 //*****************************************************************************
\r
1058 //! \brief Clears the Timer_B TBIFG interrupt flag
\r
1060 //! \param baseAddress is the base address of the TIMER_B module.
\r
1062 //! Modified bits are \b TBIFG of \b TBxCTL register.
\r
1066 //*****************************************************************************
\r
1067 extern void Timer_B_clearTimerInterrupt(uint16_t baseAddress);
\r
1069 //*****************************************************************************
\r
1071 //! \brief Clears the capture-compare interrupt flag
\r
1073 //! \param baseAddress is the base address of the TIMER_B module.
\r
1074 //! \param captureCompareRegister selects the capture compare register being
\r
1075 //! used. Refer to datasheet to ensure the device has the capture
\r
1076 //! compare register being used.
\r
1077 //! Valid values are:
\r
1078 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
\r
1079 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
\r
1080 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
\r
1081 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
\r
1082 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
\r
1083 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
\r
1084 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
\r
1086 //! Modified bits are \b CCIFG of \b TBxCCTLn register.
\r
1090 //*****************************************************************************
\r
1091 extern void Timer_B_clearCaptureCompareInterrupt(uint16_t baseAddress,
\r
1092 uint16_t captureCompareRegister);
\r
1094 //*****************************************************************************
\r
1096 //! \brief Selects Timer_B counter length
\r
1098 //! \param baseAddress is the base address of the TIMER_B module.
\r
1099 //! \param counterLength selects the value of counter length.
\r
1100 //! Valid values are:
\r
1101 //! - \b TIMER_B_COUNTER_16BIT [Default]
\r
1102 //! - \b TIMER_B_COUNTER_12BIT
\r
1103 //! - \b TIMER_B_COUNTER_10BIT
\r
1104 //! - \b TIMER_B_COUNTER_8BIT
\r
1106 //! Modified bits are \b CNTL of \b TBxCTL register.
\r
1110 //*****************************************************************************
\r
1111 extern void Timer_B_selectCounterLength(uint16_t baseAddress,
\r
1112 uint16_t counterLength);
\r
1114 //*****************************************************************************
\r
1116 //! \brief Selects Timer_B Latching Group
\r
1118 //! \param baseAddress is the base address of the TIMER_B module.
\r
1119 //! \param groupLatch selects the latching group.
\r
1120 //! Valid values are:
\r
1121 //! - \b TIMER_B_GROUP_NONE [Default]
\r
1122 //! - \b TIMER_B_GROUP_CL12_CL23_CL56
\r
1123 //! - \b TIMER_B_GROUP_CL123_CL456
\r
1124 //! - \b TIMER_B_GROUP_ALL
\r
1126 //! Modified bits are \b TBCLGRP of \b TBxCTL register.
\r
1130 //*****************************************************************************
\r
1131 extern void Timer_B_selectLatchingGroup(uint16_t baseAddress,
\r
1132 uint16_t groupLatch);
\r
1134 //*****************************************************************************
\r
1136 //! \brief Selects Compare Latch Load Event
\r
1138 //! \param baseAddress is the base address of the TIMER_B module.
\r
1139 //! \param compareRegister selects the compare register being used. Refer to
\r
1140 //! datasheet to ensure the device has the compare register being used.
\r
1141 //! Valid values are:
\r
1142 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_0
\r
1143 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_1
\r
1144 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_2
\r
1145 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_3
\r
1146 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_4
\r
1147 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_5
\r
1148 //! - \b TIMER_B_CAPTURECOMPARE_REGISTER_6
\r
1149 //! \param compareLatchLoadEvent selects the latch load event
\r
1150 //! Valid values are:
\r
1151 //! - \b TIMER_B_LATCH_ON_WRITE_TO_TBxCCRn_COMPARE_REGISTER [Default]
\r
1152 //! - \b TIMER_B_LATCH_WHEN_COUNTER_COUNTS_TO_0_IN_UP_OR_CONT_MODE
\r
1153 //! - \b TIMER_B_LATCH_WHEN_COUNTER_COUNTS_TO_0_IN_UPDOWN_MODE
\r
1155 //! TIMER_B_LATCH_WHEN_COUNTER_COUNTS_TO_CURRENT_COMPARE_LATCH_VALUE
\r
1157 //! Modified bits are \b CLLD of \b TBxCCTLn register.
\r
1161 //*****************************************************************************
\r
1162 extern void Timer_B_initCompareLatchLoadEvent(uint16_t baseAddress,
\r
1163 uint16_t compareRegister,
\r
1164 uint16_t compareLatchLoadEvent);
\r
1166 //*****************************************************************************
\r
1168 //! \brief Reads the current timer count value
\r
1170 //! Reads the current count value of the timer. There is a majority vote system
\r
1171 //! in place to confirm an accurate value is returned. The Timer_B_THRESHOLD
\r
1172 //! #define in the associated header file can be modified so that the votes
\r
1173 //! must be closer together for a consensus to occur.
\r
1175 //! \param baseAddress is the base address of the Timer module.
\r
1177 //! \return Majority vote of timer count value
\r
1179 //*****************************************************************************
\r
1180 extern uint16_t Timer_B_getCounterValue(uint16_t baseAddress);
\r
1182 //*****************************************************************************
\r
1184 // Mark the end of the C bindings section for C++ compilers.
\r
1186 //*****************************************************************************
\r
1187 #ifdef __cplusplus
\r
1192 #endif // __MSP430WARE_TIMER_B_H__
\r