STM32F1 Standard Peripheral bibliotheek  1.0
ST Microelectronics bibliotheek documentatie voor de STM32F1 Standard Peripheral Library
 All Data Structures Files Functions Variables Enumerations Groups
stm32f10x_tim.h
Go to the documentation of this file.
1 
22 /* Define to prevent recursive inclusion -------------------------------------*/
23 #ifndef __STM32F10x_TIM_H
24 #define __STM32F10x_TIM_H
25 
26 #ifdef __cplusplus
27  extern "C" {
28 #endif
29 
30 /* Includes ------------------------------------------------------------------*/
31 #include "stm32f10x.h"
32 
50 typedef struct
51 {
52  uint16_t TIM_Prescaler;
55  uint16_t TIM_CounterMode;
58  uint16_t TIM_Period;
62  uint16_t TIM_ClockDivision;
65  uint8_t TIM_RepetitionCounter;
74 
79 typedef struct
80 {
81  uint16_t TIM_OCMode;
84  uint16_t TIM_OutputState;
87  uint16_t TIM_OutputNState;
91  uint16_t TIM_Pulse;
94  uint16_t TIM_OCPolarity;
97  uint16_t TIM_OCNPolarity;
101  uint16_t TIM_OCIdleState;
105  uint16_t TIM_OCNIdleState;
109 
114 typedef struct
115 {
116 
117  uint16_t TIM_Channel;
120  uint16_t TIM_ICPolarity;
123  uint16_t TIM_ICSelection;
126  uint16_t TIM_ICPrescaler;
129  uint16_t TIM_ICFilter;
132 
138 typedef struct
139 {
140 
141  uint16_t TIM_OSSRState;
144  uint16_t TIM_OSSIState;
147  uint16_t TIM_LOCKLevel;
150  uint16_t TIM_DeadTime;
154  uint16_t TIM_Break;
157  uint16_t TIM_BreakPolarity;
160  uint16_t TIM_AutomaticOutput;
163 
168 #define IS_TIM_ALL_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
169  ((PERIPH) == TIM2) || \
170  ((PERIPH) == TIM3) || \
171  ((PERIPH) == TIM4) || \
172  ((PERIPH) == TIM5) || \
173  ((PERIPH) == TIM6) || \
174  ((PERIPH) == TIM7) || \
175  ((PERIPH) == TIM8) || \
176  ((PERIPH) == TIM9) || \
177  ((PERIPH) == TIM10)|| \
178  ((PERIPH) == TIM11)|| \
179  ((PERIPH) == TIM12)|| \
180  ((PERIPH) == TIM13)|| \
181  ((PERIPH) == TIM14)|| \
182  ((PERIPH) == TIM15)|| \
183  ((PERIPH) == TIM16)|| \
184  ((PERIPH) == TIM17))
185 
186 /* LIST1: TIM 1 and 8 */
187 #define IS_TIM_LIST1_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
188  ((PERIPH) == TIM8))
189 
190 /* LIST2: TIM 1, 8, 15 16 and 17 */
191 #define IS_TIM_LIST2_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
192  ((PERIPH) == TIM8) || \
193  ((PERIPH) == TIM15)|| \
194  ((PERIPH) == TIM16)|| \
195  ((PERIPH) == TIM17))
196 
197 /* LIST3: TIM 1, 2, 3, 4, 5 and 8 */
198 #define IS_TIM_LIST3_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
199  ((PERIPH) == TIM2) || \
200  ((PERIPH) == TIM3) || \
201  ((PERIPH) == TIM4) || \
202  ((PERIPH) == TIM5) || \
203  ((PERIPH) == TIM8))
204 
205 /* LIST4: TIM 1, 2, 3, 4, 5, 8, 15, 16 and 17 */
206 #define IS_TIM_LIST4_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
207  ((PERIPH) == TIM2) || \
208  ((PERIPH) == TIM3) || \
209  ((PERIPH) == TIM4) || \
210  ((PERIPH) == TIM5) || \
211  ((PERIPH) == TIM8) || \
212  ((PERIPH) == TIM15)|| \
213  ((PERIPH) == TIM16)|| \
214  ((PERIPH) == TIM17))
215 
216 /* LIST5: TIM 1, 2, 3, 4, 5, 8 and 15 */
217 #define IS_TIM_LIST5_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
218  ((PERIPH) == TIM2) || \
219  ((PERIPH) == TIM3) || \
220  ((PERIPH) == TIM4) || \
221  ((PERIPH) == TIM5) || \
222  ((PERIPH) == TIM8) || \
223  ((PERIPH) == TIM15))
224 
225 /* LIST6: TIM 1, 2, 3, 4, 5, 8, 9, 12 and 15 */
226 #define IS_TIM_LIST6_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
227  ((PERIPH) == TIM2) || \
228  ((PERIPH) == TIM3) || \
229  ((PERIPH) == TIM4) || \
230  ((PERIPH) == TIM5) || \
231  ((PERIPH) == TIM8) || \
232  ((PERIPH) == TIM9) || \
233  ((PERIPH) == TIM12)|| \
234  ((PERIPH) == TIM15))
235 
236 /* LIST7: TIM 1, 2, 3, 4, 5, 6, 7, 8, 9, 12 and 15 */
237 #define IS_TIM_LIST7_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
238  ((PERIPH) == TIM2) || \
239  ((PERIPH) == TIM3) || \
240  ((PERIPH) == TIM4) || \
241  ((PERIPH) == TIM5) || \
242  ((PERIPH) == TIM6) || \
243  ((PERIPH) == TIM7) || \
244  ((PERIPH) == TIM8) || \
245  ((PERIPH) == TIM9) || \
246  ((PERIPH) == TIM12)|| \
247  ((PERIPH) == TIM15))
248 
249 /* LIST8: TIM 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16 and 17 */
250 #define IS_TIM_LIST8_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
251  ((PERIPH) == TIM2) || \
252  ((PERIPH) == TIM3) || \
253  ((PERIPH) == TIM4) || \
254  ((PERIPH) == TIM5) || \
255  ((PERIPH) == TIM8) || \
256  ((PERIPH) == TIM9) || \
257  ((PERIPH) == TIM10)|| \
258  ((PERIPH) == TIM11)|| \
259  ((PERIPH) == TIM12)|| \
260  ((PERIPH) == TIM13)|| \
261  ((PERIPH) == TIM14)|| \
262  ((PERIPH) == TIM15)|| \
263  ((PERIPH) == TIM16)|| \
264  ((PERIPH) == TIM17))
265 
266 /* LIST9: TIM 1, 2, 3, 4, 5, 6, 7, 8, 15, 16, and 17 */
267 #define IS_TIM_LIST9_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
268  ((PERIPH) == TIM2) || \
269  ((PERIPH) == TIM3) || \
270  ((PERIPH) == TIM4) || \
271  ((PERIPH) == TIM5) || \
272  ((PERIPH) == TIM6) || \
273  ((PERIPH) == TIM7) || \
274  ((PERIPH) == TIM8) || \
275  ((PERIPH) == TIM15)|| \
276  ((PERIPH) == TIM16)|| \
277  ((PERIPH) == TIM17))
278 
287 #define TIM_OCMode_Timing ((uint16_t)0x0000)
288 #define TIM_OCMode_Active ((uint16_t)0x0010)
289 #define TIM_OCMode_Inactive ((uint16_t)0x0020)
290 #define TIM_OCMode_Toggle ((uint16_t)0x0030)
291 #define TIM_OCMode_PWM1 ((uint16_t)0x0060)
292 #define TIM_OCMode_PWM2 ((uint16_t)0x0070)
293 #define IS_TIM_OC_MODE(MODE) (((MODE) == TIM_OCMode_Timing) || \
294  ((MODE) == TIM_OCMode_Active) || \
295  ((MODE) == TIM_OCMode_Inactive) || \
296  ((MODE) == TIM_OCMode_Toggle)|| \
297  ((MODE) == TIM_OCMode_PWM1) || \
298  ((MODE) == TIM_OCMode_PWM2))
299 #define IS_TIM_OCM(MODE) (((MODE) == TIM_OCMode_Timing) || \
300  ((MODE) == TIM_OCMode_Active) || \
301  ((MODE) == TIM_OCMode_Inactive) || \
302  ((MODE) == TIM_OCMode_Toggle)|| \
303  ((MODE) == TIM_OCMode_PWM1) || \
304  ((MODE) == TIM_OCMode_PWM2) || \
305  ((MODE) == TIM_ForcedAction_Active) || \
306  ((MODE) == TIM_ForcedAction_InActive))
307 
315 #define TIM_OPMode_Single ((uint16_t)0x0008)
316 #define TIM_OPMode_Repetitive ((uint16_t)0x0000)
317 #define IS_TIM_OPM_MODE(MODE) (((MODE) == TIM_OPMode_Single) || \
318  ((MODE) == TIM_OPMode_Repetitive))
319 
327 #define TIM_Channel_1 ((uint16_t)0x0000)
328 #define TIM_Channel_2 ((uint16_t)0x0004)
329 #define TIM_Channel_3 ((uint16_t)0x0008)
330 #define TIM_Channel_4 ((uint16_t)0x000C)
331 #define IS_TIM_CHANNEL(CHANNEL) (((CHANNEL) == TIM_Channel_1) || \
332  ((CHANNEL) == TIM_Channel_2) || \
333  ((CHANNEL) == TIM_Channel_3) || \
334  ((CHANNEL) == TIM_Channel_4))
335 #define IS_TIM_PWMI_CHANNEL(CHANNEL) (((CHANNEL) == TIM_Channel_1) || \
336  ((CHANNEL) == TIM_Channel_2))
337 #define IS_TIM_COMPLEMENTARY_CHANNEL(CHANNEL) (((CHANNEL) == TIM_Channel_1) || \
338  ((CHANNEL) == TIM_Channel_2) || \
339  ((CHANNEL) == TIM_Channel_3))
340 
348 #define TIM_CKD_DIV1 ((uint16_t)0x0000)
349 #define TIM_CKD_DIV2 ((uint16_t)0x0100)
350 #define TIM_CKD_DIV4 ((uint16_t)0x0200)
351 #define IS_TIM_CKD_DIV(DIV) (((DIV) == TIM_CKD_DIV1) || \
352  ((DIV) == TIM_CKD_DIV2) || \
353  ((DIV) == TIM_CKD_DIV4))
354 
362 #define TIM_CounterMode_Up ((uint16_t)0x0000)
363 #define TIM_CounterMode_Down ((uint16_t)0x0010)
364 #define TIM_CounterMode_CenterAligned1 ((uint16_t)0x0020)
365 #define TIM_CounterMode_CenterAligned2 ((uint16_t)0x0040)
366 #define TIM_CounterMode_CenterAligned3 ((uint16_t)0x0060)
367 #define IS_TIM_COUNTER_MODE(MODE) (((MODE) == TIM_CounterMode_Up) || \
368  ((MODE) == TIM_CounterMode_Down) || \
369  ((MODE) == TIM_CounterMode_CenterAligned1) || \
370  ((MODE) == TIM_CounterMode_CenterAligned2) || \
371  ((MODE) == TIM_CounterMode_CenterAligned3))
372 
380 #define TIM_OCPolarity_High ((uint16_t)0x0000)
381 #define TIM_OCPolarity_Low ((uint16_t)0x0002)
382 #define IS_TIM_OC_POLARITY(POLARITY) (((POLARITY) == TIM_OCPolarity_High) || \
383  ((POLARITY) == TIM_OCPolarity_Low))
384 
392 #define TIM_OCNPolarity_High ((uint16_t)0x0000)
393 #define TIM_OCNPolarity_Low ((uint16_t)0x0008)
394 #define IS_TIM_OCN_POLARITY(POLARITY) (((POLARITY) == TIM_OCNPolarity_High) || \
395  ((POLARITY) == TIM_OCNPolarity_Low))
396 
404 #define TIM_OutputState_Disable ((uint16_t)0x0000)
405 #define TIM_OutputState_Enable ((uint16_t)0x0001)
406 #define IS_TIM_OUTPUT_STATE(STATE) (((STATE) == TIM_OutputState_Disable) || \
407  ((STATE) == TIM_OutputState_Enable))
408 
416 #define TIM_OutputNState_Disable ((uint16_t)0x0000)
417 #define TIM_OutputNState_Enable ((uint16_t)0x0004)
418 #define IS_TIM_OUTPUTN_STATE(STATE) (((STATE) == TIM_OutputNState_Disable) || \
419  ((STATE) == TIM_OutputNState_Enable))
420 
428 #define TIM_CCx_Enable ((uint16_t)0x0001)
429 #define TIM_CCx_Disable ((uint16_t)0x0000)
430 #define IS_TIM_CCX(CCX) (((CCX) == TIM_CCx_Enable) || \
431  ((CCX) == TIM_CCx_Disable))
432 
440 #define TIM_CCxN_Enable ((uint16_t)0x0004)
441 #define TIM_CCxN_Disable ((uint16_t)0x0000)
442 #define IS_TIM_CCXN(CCXN) (((CCXN) == TIM_CCxN_Enable) || \
443  ((CCXN) == TIM_CCxN_Disable))
444 
452 #define TIM_Break_Enable ((uint16_t)0x1000)
453 #define TIM_Break_Disable ((uint16_t)0x0000)
454 #define IS_TIM_BREAK_STATE(STATE) (((STATE) == TIM_Break_Enable) || \
455  ((STATE) == TIM_Break_Disable))
456 
464 #define TIM_BreakPolarity_Low ((uint16_t)0x0000)
465 #define TIM_BreakPolarity_High ((uint16_t)0x2000)
466 #define IS_TIM_BREAK_POLARITY(POLARITY) (((POLARITY) == TIM_BreakPolarity_Low) || \
467  ((POLARITY) == TIM_BreakPolarity_High))
468 
476 #define TIM_AutomaticOutput_Enable ((uint16_t)0x4000)
477 #define TIM_AutomaticOutput_Disable ((uint16_t)0x0000)
478 #define IS_TIM_AUTOMATIC_OUTPUT_STATE(STATE) (((STATE) == TIM_AutomaticOutput_Enable) || \
479  ((STATE) == TIM_AutomaticOutput_Disable))
480 
488 #define TIM_LOCKLevel_OFF ((uint16_t)0x0000)
489 #define TIM_LOCKLevel_1 ((uint16_t)0x0100)
490 #define TIM_LOCKLevel_2 ((uint16_t)0x0200)
491 #define TIM_LOCKLevel_3 ((uint16_t)0x0300)
492 #define IS_TIM_LOCK_LEVEL(LEVEL) (((LEVEL) == TIM_LOCKLevel_OFF) || \
493  ((LEVEL) == TIM_LOCKLevel_1) || \
494  ((LEVEL) == TIM_LOCKLevel_2) || \
495  ((LEVEL) == TIM_LOCKLevel_3))
496 
504 #define TIM_OSSIState_Enable ((uint16_t)0x0400)
505 #define TIM_OSSIState_Disable ((uint16_t)0x0000)
506 #define IS_TIM_OSSI_STATE(STATE) (((STATE) == TIM_OSSIState_Enable) || \
507  ((STATE) == TIM_OSSIState_Disable))
508 
516 #define TIM_OSSRState_Enable ((uint16_t)0x0800)
517 #define TIM_OSSRState_Disable ((uint16_t)0x0000)
518 #define IS_TIM_OSSR_STATE(STATE) (((STATE) == TIM_OSSRState_Enable) || \
519  ((STATE) == TIM_OSSRState_Disable))
520 
528 #define TIM_OCIdleState_Set ((uint16_t)0x0100)
529 #define TIM_OCIdleState_Reset ((uint16_t)0x0000)
530 #define IS_TIM_OCIDLE_STATE(STATE) (((STATE) == TIM_OCIdleState_Set) || \
531  ((STATE) == TIM_OCIdleState_Reset))
532 
540 #define TIM_OCNIdleState_Set ((uint16_t)0x0200)
541 #define TIM_OCNIdleState_Reset ((uint16_t)0x0000)
542 #define IS_TIM_OCNIDLE_STATE(STATE) (((STATE) == TIM_OCNIdleState_Set) || \
543  ((STATE) == TIM_OCNIdleState_Reset))
544 
552 #define TIM_ICPolarity_Rising ((uint16_t)0x0000)
553 #define TIM_ICPolarity_Falling ((uint16_t)0x0002)
554 #define IS_TIM_IC_POLARITY(POLARITY) (((POLARITY) == TIM_ICPolarity_Rising) || \
555  ((POLARITY) == TIM_ICPolarity_Falling))
556 
564 #define TIM_ICSelection_DirectTI ((uint16_t)0x0001)
566 #define TIM_ICSelection_IndirectTI ((uint16_t)0x0002)
568 #define TIM_ICSelection_TRC ((uint16_t)0x0003)
569 #define IS_TIM_IC_SELECTION(SELECTION) (((SELECTION) == TIM_ICSelection_DirectTI) || \
570  ((SELECTION) == TIM_ICSelection_IndirectTI) || \
571  ((SELECTION) == TIM_ICSelection_TRC))
572 
580 #define TIM_ICPSC_DIV1 ((uint16_t)0x0000)
581 #define TIM_ICPSC_DIV2 ((uint16_t)0x0004)
582 #define TIM_ICPSC_DIV4 ((uint16_t)0x0008)
583 #define TIM_ICPSC_DIV8 ((uint16_t)0x000C)
584 #define IS_TIM_IC_PRESCALER(PRESCALER) (((PRESCALER) == TIM_ICPSC_DIV1) || \
585  ((PRESCALER) == TIM_ICPSC_DIV2) || \
586  ((PRESCALER) == TIM_ICPSC_DIV4) || \
587  ((PRESCALER) == TIM_ICPSC_DIV8))
588 
596 #define TIM_IT_Update ((uint16_t)0x0001)
597 #define TIM_IT_CC1 ((uint16_t)0x0002)
598 #define TIM_IT_CC2 ((uint16_t)0x0004)
599 #define TIM_IT_CC3 ((uint16_t)0x0008)
600 #define TIM_IT_CC4 ((uint16_t)0x0010)
601 #define TIM_IT_COM ((uint16_t)0x0020)
602 #define TIM_IT_Trigger ((uint16_t)0x0040)
603 #define TIM_IT_Break ((uint16_t)0x0080)
604 #define IS_TIM_IT(IT) ((((IT) & (uint16_t)0xFF00) == 0x0000) && ((IT) != 0x0000))
605 
606 #define IS_TIM_GET_IT(IT) (((IT) == TIM_IT_Update) || \
607  ((IT) == TIM_IT_CC1) || \
608  ((IT) == TIM_IT_CC2) || \
609  ((IT) == TIM_IT_CC3) || \
610  ((IT) == TIM_IT_CC4) || \
611  ((IT) == TIM_IT_COM) || \
612  ((IT) == TIM_IT_Trigger) || \
613  ((IT) == TIM_IT_Break))
614 
622 #define TIM_DMABase_CR1 ((uint16_t)0x0000)
623 #define TIM_DMABase_CR2 ((uint16_t)0x0001)
624 #define TIM_DMABase_SMCR ((uint16_t)0x0002)
625 #define TIM_DMABase_DIER ((uint16_t)0x0003)
626 #define TIM_DMABase_SR ((uint16_t)0x0004)
627 #define TIM_DMABase_EGR ((uint16_t)0x0005)
628 #define TIM_DMABase_CCMR1 ((uint16_t)0x0006)
629 #define TIM_DMABase_CCMR2 ((uint16_t)0x0007)
630 #define TIM_DMABase_CCER ((uint16_t)0x0008)
631 #define TIM_DMABase_CNT ((uint16_t)0x0009)
632 #define TIM_DMABase_PSC ((uint16_t)0x000A)
633 #define TIM_DMABase_ARR ((uint16_t)0x000B)
634 #define TIM_DMABase_RCR ((uint16_t)0x000C)
635 #define TIM_DMABase_CCR1 ((uint16_t)0x000D)
636 #define TIM_DMABase_CCR2 ((uint16_t)0x000E)
637 #define TIM_DMABase_CCR3 ((uint16_t)0x000F)
638 #define TIM_DMABase_CCR4 ((uint16_t)0x0010)
639 #define TIM_DMABase_BDTR ((uint16_t)0x0011)
640 #define TIM_DMABase_DCR ((uint16_t)0x0012)
641 #define IS_TIM_DMA_BASE(BASE) (((BASE) == TIM_DMABase_CR1) || \
642  ((BASE) == TIM_DMABase_CR2) || \
643  ((BASE) == TIM_DMABase_SMCR) || \
644  ((BASE) == TIM_DMABase_DIER) || \
645  ((BASE) == TIM_DMABase_SR) || \
646  ((BASE) == TIM_DMABase_EGR) || \
647  ((BASE) == TIM_DMABase_CCMR1) || \
648  ((BASE) == TIM_DMABase_CCMR2) || \
649  ((BASE) == TIM_DMABase_CCER) || \
650  ((BASE) == TIM_DMABase_CNT) || \
651  ((BASE) == TIM_DMABase_PSC) || \
652  ((BASE) == TIM_DMABase_ARR) || \
653  ((BASE) == TIM_DMABase_RCR) || \
654  ((BASE) == TIM_DMABase_CCR1) || \
655  ((BASE) == TIM_DMABase_CCR2) || \
656  ((BASE) == TIM_DMABase_CCR3) || \
657  ((BASE) == TIM_DMABase_CCR4) || \
658  ((BASE) == TIM_DMABase_BDTR) || \
659  ((BASE) == TIM_DMABase_DCR))
660 
668 #define TIM_DMABurstLength_1Byte ((uint16_t)0x0000)
669 #define TIM_DMABurstLength_2Bytes ((uint16_t)0x0100)
670 #define TIM_DMABurstLength_3Bytes ((uint16_t)0x0200)
671 #define TIM_DMABurstLength_4Bytes ((uint16_t)0x0300)
672 #define TIM_DMABurstLength_5Bytes ((uint16_t)0x0400)
673 #define TIM_DMABurstLength_6Bytes ((uint16_t)0x0500)
674 #define TIM_DMABurstLength_7Bytes ((uint16_t)0x0600)
675 #define TIM_DMABurstLength_8Bytes ((uint16_t)0x0700)
676 #define TIM_DMABurstLength_9Bytes ((uint16_t)0x0800)
677 #define TIM_DMABurstLength_10Bytes ((uint16_t)0x0900)
678 #define TIM_DMABurstLength_11Bytes ((uint16_t)0x0A00)
679 #define TIM_DMABurstLength_12Bytes ((uint16_t)0x0B00)
680 #define TIM_DMABurstLength_13Bytes ((uint16_t)0x0C00)
681 #define TIM_DMABurstLength_14Bytes ((uint16_t)0x0D00)
682 #define TIM_DMABurstLength_15Bytes ((uint16_t)0x0E00)
683 #define TIM_DMABurstLength_16Bytes ((uint16_t)0x0F00)
684 #define TIM_DMABurstLength_17Bytes ((uint16_t)0x1000)
685 #define TIM_DMABurstLength_18Bytes ((uint16_t)0x1100)
686 #define IS_TIM_DMA_LENGTH(LENGTH) (((LENGTH) == TIM_DMABurstLength_1Byte) || \
687  ((LENGTH) == TIM_DMABurstLength_2Bytes) || \
688  ((LENGTH) == TIM_DMABurstLength_3Bytes) || \
689  ((LENGTH) == TIM_DMABurstLength_4Bytes) || \
690  ((LENGTH) == TIM_DMABurstLength_5Bytes) || \
691  ((LENGTH) == TIM_DMABurstLength_6Bytes) || \
692  ((LENGTH) == TIM_DMABurstLength_7Bytes) || \
693  ((LENGTH) == TIM_DMABurstLength_8Bytes) || \
694  ((LENGTH) == TIM_DMABurstLength_9Bytes) || \
695  ((LENGTH) == TIM_DMABurstLength_10Bytes) || \
696  ((LENGTH) == TIM_DMABurstLength_11Bytes) || \
697  ((LENGTH) == TIM_DMABurstLength_12Bytes) || \
698  ((LENGTH) == TIM_DMABurstLength_13Bytes) || \
699  ((LENGTH) == TIM_DMABurstLength_14Bytes) || \
700  ((LENGTH) == TIM_DMABurstLength_15Bytes) || \
701  ((LENGTH) == TIM_DMABurstLength_16Bytes) || \
702  ((LENGTH) == TIM_DMABurstLength_17Bytes) || \
703  ((LENGTH) == TIM_DMABurstLength_18Bytes))
704 
712 #define TIM_DMA_Update ((uint16_t)0x0100)
713 #define TIM_DMA_CC1 ((uint16_t)0x0200)
714 #define TIM_DMA_CC2 ((uint16_t)0x0400)
715 #define TIM_DMA_CC3 ((uint16_t)0x0800)
716 #define TIM_DMA_CC4 ((uint16_t)0x1000)
717 #define TIM_DMA_COM ((uint16_t)0x2000)
718 #define TIM_DMA_Trigger ((uint16_t)0x4000)
719 #define IS_TIM_DMA_SOURCE(SOURCE) ((((SOURCE) & (uint16_t)0x80FF) == 0x0000) && ((SOURCE) != 0x0000))
720 
729 #define TIM_ExtTRGPSC_OFF ((uint16_t)0x0000)
730 #define TIM_ExtTRGPSC_DIV2 ((uint16_t)0x1000)
731 #define TIM_ExtTRGPSC_DIV4 ((uint16_t)0x2000)
732 #define TIM_ExtTRGPSC_DIV8 ((uint16_t)0x3000)
733 #define IS_TIM_EXT_PRESCALER(PRESCALER) (((PRESCALER) == TIM_ExtTRGPSC_OFF) || \
734  ((PRESCALER) == TIM_ExtTRGPSC_DIV2) || \
735  ((PRESCALER) == TIM_ExtTRGPSC_DIV4) || \
736  ((PRESCALER) == TIM_ExtTRGPSC_DIV8))
737 
745 #define TIM_TS_ITR0 ((uint16_t)0x0000)
746 #define TIM_TS_ITR1 ((uint16_t)0x0010)
747 #define TIM_TS_ITR2 ((uint16_t)0x0020)
748 #define TIM_TS_ITR3 ((uint16_t)0x0030)
749 #define TIM_TS_TI1F_ED ((uint16_t)0x0040)
750 #define TIM_TS_TI1FP1 ((uint16_t)0x0050)
751 #define TIM_TS_TI2FP2 ((uint16_t)0x0060)
752 #define TIM_TS_ETRF ((uint16_t)0x0070)
753 #define IS_TIM_TRIGGER_SELECTION(SELECTION) (((SELECTION) == TIM_TS_ITR0) || \
754  ((SELECTION) == TIM_TS_ITR1) || \
755  ((SELECTION) == TIM_TS_ITR2) || \
756  ((SELECTION) == TIM_TS_ITR3) || \
757  ((SELECTION) == TIM_TS_TI1F_ED) || \
758  ((SELECTION) == TIM_TS_TI1FP1) || \
759  ((SELECTION) == TIM_TS_TI2FP2) || \
760  ((SELECTION) == TIM_TS_ETRF))
761 #define IS_TIM_INTERNAL_TRIGGER_SELECTION(SELECTION) (((SELECTION) == TIM_TS_ITR0) || \
762  ((SELECTION) == TIM_TS_ITR1) || \
763  ((SELECTION) == TIM_TS_ITR2) || \
764  ((SELECTION) == TIM_TS_ITR3))
765 
773 #define TIM_TIxExternalCLK1Source_TI1 ((uint16_t)0x0050)
774 #define TIM_TIxExternalCLK1Source_TI2 ((uint16_t)0x0060)
775 #define TIM_TIxExternalCLK1Source_TI1ED ((uint16_t)0x0040)
776 #define IS_TIM_TIXCLK_SOURCE(SOURCE) (((SOURCE) == TIM_TIxExternalCLK1Source_TI1) || \
777  ((SOURCE) == TIM_TIxExternalCLK1Source_TI2) || \
778  ((SOURCE) == TIM_TIxExternalCLK1Source_TI1ED))
779 
786 #define TIM_ExtTRGPolarity_Inverted ((uint16_t)0x8000)
787 #define TIM_ExtTRGPolarity_NonInverted ((uint16_t)0x0000)
788 #define IS_TIM_EXT_POLARITY(POLARITY) (((POLARITY) == TIM_ExtTRGPolarity_Inverted) || \
789  ((POLARITY) == TIM_ExtTRGPolarity_NonInverted))
790 
798 #define TIM_PSCReloadMode_Update ((uint16_t)0x0000)
799 #define TIM_PSCReloadMode_Immediate ((uint16_t)0x0001)
800 #define IS_TIM_PRESCALER_RELOAD(RELOAD) (((RELOAD) == TIM_PSCReloadMode_Update) || \
801  ((RELOAD) == TIM_PSCReloadMode_Immediate))
802 
810 #define TIM_ForcedAction_Active ((uint16_t)0x0050)
811 #define TIM_ForcedAction_InActive ((uint16_t)0x0040)
812 #define IS_TIM_FORCED_ACTION(ACTION) (((ACTION) == TIM_ForcedAction_Active) || \
813  ((ACTION) == TIM_ForcedAction_InActive))
814 
822 #define TIM_EncoderMode_TI1 ((uint16_t)0x0001)
823 #define TIM_EncoderMode_TI2 ((uint16_t)0x0002)
824 #define TIM_EncoderMode_TI12 ((uint16_t)0x0003)
825 #define IS_TIM_ENCODER_MODE(MODE) (((MODE) == TIM_EncoderMode_TI1) || \
826  ((MODE) == TIM_EncoderMode_TI2) || \
827  ((MODE) == TIM_EncoderMode_TI12))
828 
837 #define TIM_EventSource_Update ((uint16_t)0x0001)
838 #define TIM_EventSource_CC1 ((uint16_t)0x0002)
839 #define TIM_EventSource_CC2 ((uint16_t)0x0004)
840 #define TIM_EventSource_CC3 ((uint16_t)0x0008)
841 #define TIM_EventSource_CC4 ((uint16_t)0x0010)
842 #define TIM_EventSource_COM ((uint16_t)0x0020)
843 #define TIM_EventSource_Trigger ((uint16_t)0x0040)
844 #define TIM_EventSource_Break ((uint16_t)0x0080)
845 #define IS_TIM_EVENT_SOURCE(SOURCE) ((((SOURCE) & (uint16_t)0xFF00) == 0x0000) && ((SOURCE) != 0x0000))
846 
855 #define TIM_UpdateSource_Global ((uint16_t)0x0000)
858 #define TIM_UpdateSource_Regular ((uint16_t)0x0001)
859 #define IS_TIM_UPDATE_SOURCE(SOURCE) (((SOURCE) == TIM_UpdateSource_Global) || \
860  ((SOURCE) == TIM_UpdateSource_Regular))
861 
869 #define TIM_OCPreload_Enable ((uint16_t)0x0008)
870 #define TIM_OCPreload_Disable ((uint16_t)0x0000)
871 #define IS_TIM_OCPRELOAD_STATE(STATE) (((STATE) == TIM_OCPreload_Enable) || \
872  ((STATE) == TIM_OCPreload_Disable))
873 
881 #define TIM_OCFast_Enable ((uint16_t)0x0004)
882 #define TIM_OCFast_Disable ((uint16_t)0x0000)
883 #define IS_TIM_OCFAST_STATE(STATE) (((STATE) == TIM_OCFast_Enable) || \
884  ((STATE) == TIM_OCFast_Disable))
885 
894 #define TIM_OCClear_Enable ((uint16_t)0x0080)
895 #define TIM_OCClear_Disable ((uint16_t)0x0000)
896 #define IS_TIM_OCCLEAR_STATE(STATE) (((STATE) == TIM_OCClear_Enable) || \
897  ((STATE) == TIM_OCClear_Disable))
898 
906 #define TIM_TRGOSource_Reset ((uint16_t)0x0000)
907 #define TIM_TRGOSource_Enable ((uint16_t)0x0010)
908 #define TIM_TRGOSource_Update ((uint16_t)0x0020)
909 #define TIM_TRGOSource_OC1 ((uint16_t)0x0030)
910 #define TIM_TRGOSource_OC1Ref ((uint16_t)0x0040)
911 #define TIM_TRGOSource_OC2Ref ((uint16_t)0x0050)
912 #define TIM_TRGOSource_OC3Ref ((uint16_t)0x0060)
913 #define TIM_TRGOSource_OC4Ref ((uint16_t)0x0070)
914 #define IS_TIM_TRGO_SOURCE(SOURCE) (((SOURCE) == TIM_TRGOSource_Reset) || \
915  ((SOURCE) == TIM_TRGOSource_Enable) || \
916  ((SOURCE) == TIM_TRGOSource_Update) || \
917  ((SOURCE) == TIM_TRGOSource_OC1) || \
918  ((SOURCE) == TIM_TRGOSource_OC1Ref) || \
919  ((SOURCE) == TIM_TRGOSource_OC2Ref) || \
920  ((SOURCE) == TIM_TRGOSource_OC3Ref) || \
921  ((SOURCE) == TIM_TRGOSource_OC4Ref))
922 
930 #define TIM_SlaveMode_Reset ((uint16_t)0x0004)
931 #define TIM_SlaveMode_Gated ((uint16_t)0x0005)
932 #define TIM_SlaveMode_Trigger ((uint16_t)0x0006)
933 #define TIM_SlaveMode_External1 ((uint16_t)0x0007)
934 #define IS_TIM_SLAVE_MODE(MODE) (((MODE) == TIM_SlaveMode_Reset) || \
935  ((MODE) == TIM_SlaveMode_Gated) || \
936  ((MODE) == TIM_SlaveMode_Trigger) || \
937  ((MODE) == TIM_SlaveMode_External1))
938 
946 #define TIM_MasterSlaveMode_Enable ((uint16_t)0x0080)
947 #define TIM_MasterSlaveMode_Disable ((uint16_t)0x0000)
948 #define IS_TIM_MSM_STATE(STATE) (((STATE) == TIM_MasterSlaveMode_Enable) || \
949  ((STATE) == TIM_MasterSlaveMode_Disable))
950 
958 #define TIM_FLAG_Update ((uint16_t)0x0001)
959 #define TIM_FLAG_CC1 ((uint16_t)0x0002)
960 #define TIM_FLAG_CC2 ((uint16_t)0x0004)
961 #define TIM_FLAG_CC3 ((uint16_t)0x0008)
962 #define TIM_FLAG_CC4 ((uint16_t)0x0010)
963 #define TIM_FLAG_COM ((uint16_t)0x0020)
964 #define TIM_FLAG_Trigger ((uint16_t)0x0040)
965 #define TIM_FLAG_Break ((uint16_t)0x0080)
966 #define TIM_FLAG_CC1OF ((uint16_t)0x0200)
967 #define TIM_FLAG_CC2OF ((uint16_t)0x0400)
968 #define TIM_FLAG_CC3OF ((uint16_t)0x0800)
969 #define TIM_FLAG_CC4OF ((uint16_t)0x1000)
970 #define IS_TIM_GET_FLAG(FLAG) (((FLAG) == TIM_FLAG_Update) || \
971  ((FLAG) == TIM_FLAG_CC1) || \
972  ((FLAG) == TIM_FLAG_CC2) || \
973  ((FLAG) == TIM_FLAG_CC3) || \
974  ((FLAG) == TIM_FLAG_CC4) || \
975  ((FLAG) == TIM_FLAG_COM) || \
976  ((FLAG) == TIM_FLAG_Trigger) || \
977  ((FLAG) == TIM_FLAG_Break) || \
978  ((FLAG) == TIM_FLAG_CC1OF) || \
979  ((FLAG) == TIM_FLAG_CC2OF) || \
980  ((FLAG) == TIM_FLAG_CC3OF) || \
981  ((FLAG) == TIM_FLAG_CC4OF))
982 
983 
984 #define IS_TIM_CLEAR_FLAG(TIM_FLAG) ((((TIM_FLAG) & (uint16_t)0xE100) == 0x0000) && ((TIM_FLAG) != 0x0000))
985 
993 #define IS_TIM_IC_FILTER(ICFILTER) ((ICFILTER) <= 0xF)
994 
1002 #define IS_TIM_EXT_FILTER(EXTFILTER) ((EXTFILTER) <= 0xF)
1003 
1023 void TIM_DeInit(TIM_TypeDef* TIMx);
1024 void TIM_TimeBaseInit(TIM_TypeDef* TIMx, TIM_TimeBaseInitTypeDef* TIM_TimeBaseInitStruct);
1025 void TIM_OC1Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct);
1026 void TIM_OC2Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct);
1027 void TIM_OC3Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct);
1028 void TIM_OC4Init(TIM_TypeDef* TIMx, TIM_OCInitTypeDef* TIM_OCInitStruct);
1029 void TIM_ICInit(TIM_TypeDef* TIMx, TIM_ICInitTypeDef* TIM_ICInitStruct);
1030 void TIM_PWMIConfig(TIM_TypeDef* TIMx, TIM_ICInitTypeDef* TIM_ICInitStruct);
1031 void TIM_BDTRConfig(TIM_TypeDef* TIMx, TIM_BDTRInitTypeDef *TIM_BDTRInitStruct);
1032 void TIM_TimeBaseStructInit(TIM_TimeBaseInitTypeDef* TIM_TimeBaseInitStruct);
1033 void TIM_OCStructInit(TIM_OCInitTypeDef* TIM_OCInitStruct);
1034 void TIM_ICStructInit(TIM_ICInitTypeDef* TIM_ICInitStruct);
1035 void TIM_BDTRStructInit(TIM_BDTRInitTypeDef* TIM_BDTRInitStruct);
1036 void TIM_Cmd(TIM_TypeDef* TIMx, FunctionalState NewState);
1037 void TIM_CtrlPWMOutputs(TIM_TypeDef* TIMx, FunctionalState NewState);
1038 void TIM_ITConfig(TIM_TypeDef* TIMx, uint16_t TIM_IT, FunctionalState NewState);
1039 void TIM_GenerateEvent(TIM_TypeDef* TIMx, uint16_t TIM_EventSource);
1040 void TIM_DMAConfig(TIM_TypeDef* TIMx, uint16_t TIM_DMABase, uint16_t TIM_DMABurstLength);
1041 void TIM_DMACmd(TIM_TypeDef* TIMx, uint16_t TIM_DMASource, FunctionalState NewState);
1042 void TIM_InternalClockConfig(TIM_TypeDef* TIMx);
1043 void TIM_ITRxExternalClockConfig(TIM_TypeDef* TIMx, uint16_t TIM_InputTriggerSource);
1044 void TIM_TIxExternalClockConfig(TIM_TypeDef* TIMx, uint16_t TIM_TIxExternalCLKSource,
1045  uint16_t TIM_ICPolarity, uint16_t ICFilter);
1046 void TIM_ETRClockMode1Config(TIM_TypeDef* TIMx, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity,
1047  uint16_t ExtTRGFilter);
1048 void TIM_ETRClockMode2Config(TIM_TypeDef* TIMx, uint16_t TIM_ExtTRGPrescaler,
1049  uint16_t TIM_ExtTRGPolarity, uint16_t ExtTRGFilter);
1050 void TIM_ETRConfig(TIM_TypeDef* TIMx, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity,
1051  uint16_t ExtTRGFilter);
1052 void TIM_PrescalerConfig(TIM_TypeDef* TIMx, uint16_t Prescaler, uint16_t TIM_PSCReloadMode);
1053 void TIM_CounterModeConfig(TIM_TypeDef* TIMx, uint16_t TIM_CounterMode);
1054 void TIM_SelectInputTrigger(TIM_TypeDef* TIMx, uint16_t TIM_InputTriggerSource);
1055 void TIM_EncoderInterfaceConfig(TIM_TypeDef* TIMx, uint16_t TIM_EncoderMode,
1056  uint16_t TIM_IC1Polarity, uint16_t TIM_IC2Polarity);
1057 void TIM_ForcedOC1Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction);
1058 void TIM_ForcedOC2Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction);
1059 void TIM_ForcedOC3Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction);
1060 void TIM_ForcedOC4Config(TIM_TypeDef* TIMx, uint16_t TIM_ForcedAction);
1061 void TIM_ARRPreloadConfig(TIM_TypeDef* TIMx, FunctionalState NewState);
1062 void TIM_SelectCOM(TIM_TypeDef* TIMx, FunctionalState NewState);
1063 void TIM_SelectCCDMA(TIM_TypeDef* TIMx, FunctionalState NewState);
1064 void TIM_CCPreloadControl(TIM_TypeDef* TIMx, FunctionalState NewState);
1065 void TIM_OC1PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload);
1066 void TIM_OC2PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload);
1067 void TIM_OC3PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload);
1068 void TIM_OC4PreloadConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPreload);
1069 void TIM_OC1FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast);
1070 void TIM_OC2FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast);
1071 void TIM_OC3FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast);
1072 void TIM_OC4FastConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCFast);
1073 void TIM_ClearOC1Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear);
1074 void TIM_ClearOC2Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear);
1075 void TIM_ClearOC3Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear);
1076 void TIM_ClearOC4Ref(TIM_TypeDef* TIMx, uint16_t TIM_OCClear);
1077 void TIM_OC1PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity);
1078 void TIM_OC1NPolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCNPolarity);
1079 void TIM_OC2PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity);
1080 void TIM_OC2NPolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCNPolarity);
1081 void TIM_OC3PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity);
1082 void TIM_OC3NPolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCNPolarity);
1083 void TIM_OC4PolarityConfig(TIM_TypeDef* TIMx, uint16_t TIM_OCPolarity);
1084 void TIM_CCxCmd(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_CCx);
1085 void TIM_CCxNCmd(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_CCxN);
1086 void TIM_SelectOCxM(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_OCMode);
1087 void TIM_UpdateDisableConfig(TIM_TypeDef* TIMx, FunctionalState NewState);
1088 void TIM_UpdateRequestConfig(TIM_TypeDef* TIMx, uint16_t TIM_UpdateSource);
1089 void TIM_SelectHallSensor(TIM_TypeDef* TIMx, FunctionalState NewState);
1090 void TIM_SelectOnePulseMode(TIM_TypeDef* TIMx, uint16_t TIM_OPMode);
1091 void TIM_SelectOutputTrigger(TIM_TypeDef* TIMx, uint16_t TIM_TRGOSource);
1092 void TIM_SelectSlaveMode(TIM_TypeDef* TIMx, uint16_t TIM_SlaveMode);
1093 void TIM_SelectMasterSlaveMode(TIM_TypeDef* TIMx, uint16_t TIM_MasterSlaveMode);
1094 void TIM_SetCounter(TIM_TypeDef* TIMx, uint16_t Counter);
1095 void TIM_SetAutoreload(TIM_TypeDef* TIMx, uint16_t Autoreload);
1096 void TIM_SetCompare1(TIM_TypeDef* TIMx, uint16_t Compare1);
1097 void TIM_SetCompare2(TIM_TypeDef* TIMx, uint16_t Compare2);
1098 void TIM_SetCompare3(TIM_TypeDef* TIMx, uint16_t Compare3);
1099 void TIM_SetCompare4(TIM_TypeDef* TIMx, uint16_t Compare4);
1100 void TIM_SetIC1Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC);
1101 void TIM_SetIC2Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC);
1102 void TIM_SetIC3Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC);
1103 void TIM_SetIC4Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC);
1104 void TIM_SetClockDivision(TIM_TypeDef* TIMx, uint16_t TIM_CKD);
1105 uint16_t TIM_GetCapture1(TIM_TypeDef* TIMx);
1106 uint16_t TIM_GetCapture2(TIM_TypeDef* TIMx);
1107 uint16_t TIM_GetCapture3(TIM_TypeDef* TIMx);
1108 uint16_t TIM_GetCapture4(TIM_TypeDef* TIMx);
1109 uint16_t TIM_GetCounter(TIM_TypeDef* TIMx);
1110 uint16_t TIM_GetPrescaler(TIM_TypeDef* TIMx);
1111 FlagStatus TIM_GetFlagStatus(TIM_TypeDef* TIMx, uint16_t TIM_FLAG);
1112 void TIM_ClearFlag(TIM_TypeDef* TIMx, uint16_t TIM_FLAG);
1113 ITStatus TIM_GetITStatus(TIM_TypeDef* TIMx, uint16_t TIM_IT);
1114 void TIM_ClearITPendingBit(TIM_TypeDef* TIMx, uint16_t TIM_IT);
1115 
1116 #ifdef __cplusplus
1117 }
1118 #endif
1119 
1120 #endif /*__STM32F10x_TIM_H */
1121 
1133 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/