24 #ifndef __STM32F10x_TIM_H
25 #define __STM32F10x_TIM_H
169 #define IS_TIM_ALL_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
170 ((PERIPH) == TIM2) || \
171 ((PERIPH) == TIM3) || \
172 ((PERIPH) == TIM4) || \
173 ((PERIPH) == TIM5) || \
174 ((PERIPH) == TIM6) || \
175 ((PERIPH) == TIM7) || \
176 ((PERIPH) == TIM8) || \
177 ((PERIPH) == TIM9) || \
178 ((PERIPH) == TIM10)|| \
179 ((PERIPH) == TIM11)|| \
180 ((PERIPH) == TIM12)|| \
181 ((PERIPH) == TIM13)|| \
182 ((PERIPH) == TIM14)|| \
183 ((PERIPH) == TIM15)|| \
184 ((PERIPH) == TIM16)|| \
188 #define IS_TIM_LIST1_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
192 #define IS_TIM_LIST2_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
193 ((PERIPH) == TIM8) || \
194 ((PERIPH) == TIM15)|| \
195 ((PERIPH) == TIM16)|| \
199 #define IS_TIM_LIST3_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
200 ((PERIPH) == TIM2) || \
201 ((PERIPH) == TIM3) || \
202 ((PERIPH) == TIM4) || \
203 ((PERIPH) == TIM5) || \
207 #define IS_TIM_LIST4_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
208 ((PERIPH) == TIM2) || \
209 ((PERIPH) == TIM3) || \
210 ((PERIPH) == TIM4) || \
211 ((PERIPH) == TIM5) || \
212 ((PERIPH) == TIM8) || \
213 ((PERIPH) == TIM15)|| \
214 ((PERIPH) == TIM16)|| \
218 #define IS_TIM_LIST5_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
219 ((PERIPH) == TIM2) || \
220 ((PERIPH) == TIM3) || \
221 ((PERIPH) == TIM4) || \
222 ((PERIPH) == TIM5) || \
223 ((PERIPH) == TIM8) || \
227 #define IS_TIM_LIST6_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
228 ((PERIPH) == TIM2) || \
229 ((PERIPH) == TIM3) || \
230 ((PERIPH) == TIM4) || \
231 ((PERIPH) == TIM5) || \
232 ((PERIPH) == TIM8) || \
233 ((PERIPH) == TIM9) || \
234 ((PERIPH) == TIM12)|| \
238 #define IS_TIM_LIST7_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
239 ((PERIPH) == TIM2) || \
240 ((PERIPH) == TIM3) || \
241 ((PERIPH) == TIM4) || \
242 ((PERIPH) == TIM5) || \
243 ((PERIPH) == TIM6) || \
244 ((PERIPH) == TIM7) || \
245 ((PERIPH) == TIM8) || \
246 ((PERIPH) == TIM9) || \
247 ((PERIPH) == TIM12)|| \
251 #define IS_TIM_LIST8_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
252 ((PERIPH) == TIM2) || \
253 ((PERIPH) == TIM3) || \
254 ((PERIPH) == TIM4) || \
255 ((PERIPH) == TIM5) || \
256 ((PERIPH) == TIM8) || \
257 ((PERIPH) == TIM9) || \
258 ((PERIPH) == TIM10)|| \
259 ((PERIPH) == TIM11)|| \
260 ((PERIPH) == TIM12)|| \
261 ((PERIPH) == TIM13)|| \
262 ((PERIPH) == TIM14)|| \
263 ((PERIPH) == TIM15)|| \
264 ((PERIPH) == TIM16)|| \
268 #define IS_TIM_LIST9_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
269 ((PERIPH) == TIM2) || \
270 ((PERIPH) == TIM3) || \
271 ((PERIPH) == TIM4) || \
272 ((PERIPH) == TIM5) || \
273 ((PERIPH) == TIM6) || \
274 ((PERIPH) == TIM7) || \
275 ((PERIPH) == TIM8) || \
276 ((PERIPH) == TIM15)|| \
277 ((PERIPH) == TIM16)|| \
288 #define TIM_OCMode_Timing ((uint16_t)0x0000)
289 #define TIM_OCMode_Active ((uint16_t)0x0010)
290 #define TIM_OCMode_Inactive ((uint16_t)0x0020)
291 #define TIM_OCMode_Toggle ((uint16_t)0x0030)
292 #define TIM_OCMode_PWM1 ((uint16_t)0x0060)
293 #define TIM_OCMode_PWM2 ((uint16_t)0x0070)
294 #define IS_TIM_OC_MODE(MODE) (((MODE) == TIM_OCMode_Timing) || \
295 ((MODE) == TIM_OCMode_Active) || \
296 ((MODE) == TIM_OCMode_Inactive) || \
297 ((MODE) == TIM_OCMode_Toggle)|| \
298 ((MODE) == TIM_OCMode_PWM1) || \
299 ((MODE) == TIM_OCMode_PWM2))
300 #define IS_TIM_OCM(MODE) (((MODE) == TIM_OCMode_Timing) || \
301 ((MODE) == TIM_OCMode_Active) || \
302 ((MODE) == TIM_OCMode_Inactive) || \
303 ((MODE) == TIM_OCMode_Toggle)|| \
304 ((MODE) == TIM_OCMode_PWM1) || \
305 ((MODE) == TIM_OCMode_PWM2) || \
306 ((MODE) == TIM_ForcedAction_Active) || \
307 ((MODE) == TIM_ForcedAction_InActive))
316 #define TIM_OPMode_Single ((uint16_t)0x0008)
317 #define TIM_OPMode_Repetitive ((uint16_t)0x0000)
318 #define IS_TIM_OPM_MODE(MODE) (((MODE) == TIM_OPMode_Single) || \
319 ((MODE) == TIM_OPMode_Repetitive))
328 #define TIM_Channel_1 ((uint16_t)0x0000)
329 #define TIM_Channel_2 ((uint16_t)0x0004)
330 #define TIM_Channel_3 ((uint16_t)0x0008)
331 #define TIM_Channel_4 ((uint16_t)0x000C)
332 #define IS_TIM_CHANNEL(CHANNEL) (((CHANNEL) == TIM_Channel_1) || \
333 ((CHANNEL) == TIM_Channel_2) || \
334 ((CHANNEL) == TIM_Channel_3) || \
335 ((CHANNEL) == TIM_Channel_4))
336 #define IS_TIM_PWMI_CHANNEL(CHANNEL) (((CHANNEL) == TIM_Channel_1) || \
337 ((CHANNEL) == TIM_Channel_2))
338 #define IS_TIM_COMPLEMENTARY_CHANNEL(CHANNEL) (((CHANNEL) == TIM_Channel_1) || \
339 ((CHANNEL) == TIM_Channel_2) || \
340 ((CHANNEL) == TIM_Channel_3))
349 #define TIM_CKD_DIV1 ((uint16_t)0x0000)
350 #define TIM_CKD_DIV2 ((uint16_t)0x0100)
351 #define TIM_CKD_DIV4 ((uint16_t)0x0200)
352 #define IS_TIM_CKD_DIV(DIV) (((DIV) == TIM_CKD_DIV1) || \
353 ((DIV) == TIM_CKD_DIV2) || \
354 ((DIV) == TIM_CKD_DIV4))
363 #define TIM_CounterMode_Up ((uint16_t)0x0000)
364 #define TIM_CounterMode_Down ((uint16_t)0x0010)
365 #define TIM_CounterMode_CenterAligned1 ((uint16_t)0x0020)
366 #define TIM_CounterMode_CenterAligned2 ((uint16_t)0x0040)
367 #define TIM_CounterMode_CenterAligned3 ((uint16_t)0x0060)
368 #define IS_TIM_COUNTER_MODE(MODE) (((MODE) == TIM_CounterMode_Up) || \
369 ((MODE) == TIM_CounterMode_Down) || \
370 ((MODE) == TIM_CounterMode_CenterAligned1) || \
371 ((MODE) == TIM_CounterMode_CenterAligned2) || \
372 ((MODE) == TIM_CounterMode_CenterAligned3))
381 #define TIM_OCPolarity_High ((uint16_t)0x0000)
382 #define TIM_OCPolarity_Low ((uint16_t)0x0002)
383 #define IS_TIM_OC_POLARITY(POLARITY) (((POLARITY) == TIM_OCPolarity_High) || \
384 ((POLARITY) == TIM_OCPolarity_Low))
393 #define TIM_OCNPolarity_High ((uint16_t)0x0000)
394 #define TIM_OCNPolarity_Low ((uint16_t)0x0008)
395 #define IS_TIM_OCN_POLARITY(POLARITY) (((POLARITY) == TIM_OCNPolarity_High) || \
396 ((POLARITY) == TIM_OCNPolarity_Low))
405 #define TIM_OutputState_Disable ((uint16_t)0x0000)
406 #define TIM_OutputState_Enable ((uint16_t)0x0001)
407 #define IS_TIM_OUTPUT_STATE(STATE) (((STATE) == TIM_OutputState_Disable) || \
408 ((STATE) == TIM_OutputState_Enable))
417 #define TIM_OutputNState_Disable ((uint16_t)0x0000)
418 #define TIM_OutputNState_Enable ((uint16_t)0x0004)
419 #define IS_TIM_OUTPUTN_STATE(STATE) (((STATE) == TIM_OutputNState_Disable) || \
420 ((STATE) == TIM_OutputNState_Enable))
429 #define TIM_CCx_Enable ((uint16_t)0x0001)
430 #define TIM_CCx_Disable ((uint16_t)0x0000)
431 #define IS_TIM_CCX(CCX) (((CCX) == TIM_CCx_Enable) || \
432 ((CCX) == TIM_CCx_Disable))
441 #define TIM_CCxN_Enable ((uint16_t)0x0004)
442 #define TIM_CCxN_Disable ((uint16_t)0x0000)
443 #define IS_TIM_CCXN(CCXN) (((CCXN) == TIM_CCxN_Enable) || \
444 ((CCXN) == TIM_CCxN_Disable))
453 #define TIM_Break_Enable ((uint16_t)0x1000)
454 #define TIM_Break_Disable ((uint16_t)0x0000)
455 #define IS_TIM_BREAK_STATE(STATE) (((STATE) == TIM_Break_Enable) || \
456 ((STATE) == TIM_Break_Disable))
465 #define TIM_BreakPolarity_Low ((uint16_t)0x0000)
466 #define TIM_BreakPolarity_High ((uint16_t)0x2000)
467 #define IS_TIM_BREAK_POLARITY(POLARITY) (((POLARITY) == TIM_BreakPolarity_Low) || \
468 ((POLARITY) == TIM_BreakPolarity_High))
477 #define TIM_AutomaticOutput_Enable ((uint16_t)0x4000)
478 #define TIM_AutomaticOutput_Disable ((uint16_t)0x0000)
479 #define IS_TIM_AUTOMATIC_OUTPUT_STATE(STATE) (((STATE) == TIM_AutomaticOutput_Enable) || \
480 ((STATE) == TIM_AutomaticOutput_Disable))
489 #define TIM_LOCKLevel_OFF ((uint16_t)0x0000)
490 #define TIM_LOCKLevel_1 ((uint16_t)0x0100)
491 #define TIM_LOCKLevel_2 ((uint16_t)0x0200)
492 #define TIM_LOCKLevel_3 ((uint16_t)0x0300)
493 #define IS_TIM_LOCK_LEVEL(LEVEL) (((LEVEL) == TIM_LOCKLevel_OFF) || \
494 ((LEVEL) == TIM_LOCKLevel_1) || \
495 ((LEVEL) == TIM_LOCKLevel_2) || \
496 ((LEVEL) == TIM_LOCKLevel_3))
505 #define TIM_OSSIState_Enable ((uint16_t)0x0400)
506 #define TIM_OSSIState_Disable ((uint16_t)0x0000)
507 #define IS_TIM_OSSI_STATE(STATE) (((STATE) == TIM_OSSIState_Enable) || \
508 ((STATE) == TIM_OSSIState_Disable))
517 #define TIM_OSSRState_Enable ((uint16_t)0x0800)
518 #define TIM_OSSRState_Disable ((uint16_t)0x0000)
519 #define IS_TIM_OSSR_STATE(STATE) (((STATE) == TIM_OSSRState_Enable) || \
520 ((STATE) == TIM_OSSRState_Disable))
529 #define TIM_OCIdleState_Set ((uint16_t)0x0100)
530 #define TIM_OCIdleState_Reset ((uint16_t)0x0000)
531 #define IS_TIM_OCIDLE_STATE(STATE) (((STATE) == TIM_OCIdleState_Set) || \
532 ((STATE) == TIM_OCIdleState_Reset))
541 #define TIM_OCNIdleState_Set ((uint16_t)0x0200)
542 #define TIM_OCNIdleState_Reset ((uint16_t)0x0000)
543 #define IS_TIM_OCNIDLE_STATE(STATE) (((STATE) == TIM_OCNIdleState_Set) || \
544 ((STATE) == TIM_OCNIdleState_Reset))
553 #define TIM_ICPolarity_Rising ((uint16_t)0x0000)
554 #define TIM_ICPolarity_Falling ((uint16_t)0x0002)
555 #define TIM_ICPolarity_BothEdge ((uint16_t)0x000A)
556 #define IS_TIM_IC_POLARITY(POLARITY) (((POLARITY) == TIM_ICPolarity_Rising) || \
557 ((POLARITY) == TIM_ICPolarity_Falling))
558 #define IS_TIM_IC_POLARITY_LITE(POLARITY) (((POLARITY) == TIM_ICPolarity_Rising) || \
559 ((POLARITY) == TIM_ICPolarity_Falling)|| \
560 ((POLARITY) == TIM_ICPolarity_BothEdge))
569 #define TIM_ICSelection_DirectTI ((uint16_t)0x0001)
571 #define TIM_ICSelection_IndirectTI ((uint16_t)0x0002)
573 #define TIM_ICSelection_TRC ((uint16_t)0x0003)
574 #define IS_TIM_IC_SELECTION(SELECTION) (((SELECTION) == TIM_ICSelection_DirectTI) || \
575 ((SELECTION) == TIM_ICSelection_IndirectTI) || \
576 ((SELECTION) == TIM_ICSelection_TRC))
585 #define TIM_ICPSC_DIV1 ((uint16_t)0x0000)
586 #define TIM_ICPSC_DIV2 ((uint16_t)0x0004)
587 #define TIM_ICPSC_DIV4 ((uint16_t)0x0008)
588 #define TIM_ICPSC_DIV8 ((uint16_t)0x000C)
589 #define IS_TIM_IC_PRESCALER(PRESCALER) (((PRESCALER) == TIM_ICPSC_DIV1) || \
590 ((PRESCALER) == TIM_ICPSC_DIV2) || \
591 ((PRESCALER) == TIM_ICPSC_DIV4) || \
592 ((PRESCALER) == TIM_ICPSC_DIV8))
601 #define TIM_IT_Update ((uint16_t)0x0001)
602 #define TIM_IT_CC1 ((uint16_t)0x0002)
603 #define TIM_IT_CC2 ((uint16_t)0x0004)
604 #define TIM_IT_CC3 ((uint16_t)0x0008)
605 #define TIM_IT_CC4 ((uint16_t)0x0010)
606 #define TIM_IT_COM ((uint16_t)0x0020)
607 #define TIM_IT_Trigger ((uint16_t)0x0040)
608 #define TIM_IT_Break ((uint16_t)0x0080)
609 #define IS_TIM_IT(IT) ((((IT) & (uint16_t)0xFF00) == 0x0000) && ((IT) != 0x0000))
611 #define IS_TIM_GET_IT(IT) (((IT) == TIM_IT_Update) || \
612 ((IT) == TIM_IT_CC1) || \
613 ((IT) == TIM_IT_CC2) || \
614 ((IT) == TIM_IT_CC3) || \
615 ((IT) == TIM_IT_CC4) || \
616 ((IT) == TIM_IT_COM) || \
617 ((IT) == TIM_IT_Trigger) || \
618 ((IT) == TIM_IT_Break))
627 #define TIM_DMABase_CR1 ((uint16_t)0x0000)
628 #define TIM_DMABase_CR2 ((uint16_t)0x0001)
629 #define TIM_DMABase_SMCR ((uint16_t)0x0002)
630 #define TIM_DMABase_DIER ((uint16_t)0x0003)
631 #define TIM_DMABase_SR ((uint16_t)0x0004)
632 #define TIM_DMABase_EGR ((uint16_t)0x0005)
633 #define TIM_DMABase_CCMR1 ((uint16_t)0x0006)
634 #define TIM_DMABase_CCMR2 ((uint16_t)0x0007)
635 #define TIM_DMABase_CCER ((uint16_t)0x0008)
636 #define TIM_DMABase_CNT ((uint16_t)0x0009)
637 #define TIM_DMABase_PSC ((uint16_t)0x000A)
638 #define TIM_DMABase_ARR ((uint16_t)0x000B)
639 #define TIM_DMABase_RCR ((uint16_t)0x000C)
640 #define TIM_DMABase_CCR1 ((uint16_t)0x000D)
641 #define TIM_DMABase_CCR2 ((uint16_t)0x000E)
642 #define TIM_DMABase_CCR3 ((uint16_t)0x000F)
643 #define TIM_DMABase_CCR4 ((uint16_t)0x0010)
644 #define TIM_DMABase_BDTR ((uint16_t)0x0011)
645 #define TIM_DMABase_DCR ((uint16_t)0x0012)
646 #define IS_TIM_DMA_BASE(BASE) (((BASE) == TIM_DMABase_CR1) || \
647 ((BASE) == TIM_DMABase_CR2) || \
648 ((BASE) == TIM_DMABase_SMCR) || \
649 ((BASE) == TIM_DMABase_DIER) || \
650 ((BASE) == TIM_DMABase_SR) || \
651 ((BASE) == TIM_DMABase_EGR) || \
652 ((BASE) == TIM_DMABase_CCMR1) || \
653 ((BASE) == TIM_DMABase_CCMR2) || \
654 ((BASE) == TIM_DMABase_CCER) || \
655 ((BASE) == TIM_DMABase_CNT) || \
656 ((BASE) == TIM_DMABase_PSC) || \
657 ((BASE) == TIM_DMABase_ARR) || \
658 ((BASE) == TIM_DMABase_RCR) || \
659 ((BASE) == TIM_DMABase_CCR1) || \
660 ((BASE) == TIM_DMABase_CCR2) || \
661 ((BASE) == TIM_DMABase_CCR3) || \
662 ((BASE) == TIM_DMABase_CCR4) || \
663 ((BASE) == TIM_DMABase_BDTR) || \
664 ((BASE) == TIM_DMABase_DCR))
673 #define TIM_DMABurstLength_1Transfer ((uint16_t)0x0000)
674 #define TIM_DMABurstLength_2Transfers ((uint16_t)0x0100)
675 #define TIM_DMABurstLength_3Transfers ((uint16_t)0x0200)
676 #define TIM_DMABurstLength_4Transfers ((uint16_t)0x0300)
677 #define TIM_DMABurstLength_5Transfers ((uint16_t)0x0400)
678 #define TIM_DMABurstLength_6Transfers ((uint16_t)0x0500)
679 #define TIM_DMABurstLength_7Transfers ((uint16_t)0x0600)
680 #define TIM_DMABurstLength_8Transfers ((uint16_t)0x0700)
681 #define TIM_DMABurstLength_9Transfers ((uint16_t)0x0800)
682 #define TIM_DMABurstLength_10Transfers ((uint16_t)0x0900)
683 #define TIM_DMABurstLength_11Transfers ((uint16_t)0x0A00)
684 #define TIM_DMABurstLength_12Transfers ((uint16_t)0x0B00)
685 #define TIM_DMABurstLength_13Transfers ((uint16_t)0x0C00)
686 #define TIM_DMABurstLength_14Transfers ((uint16_t)0x0D00)
687 #define TIM_DMABurstLength_15Transfers ((uint16_t)0x0E00)
688 #define TIM_DMABurstLength_16Transfers ((uint16_t)0x0F00)
689 #define TIM_DMABurstLength_17Transfers ((uint16_t)0x1000)
690 #define TIM_DMABurstLength_18Transfers ((uint16_t)0x1100)
691 #define IS_TIM_DMA_LENGTH(LENGTH) (((LENGTH) == TIM_DMABurstLength_1Transfer) || \
692 ((LENGTH) == TIM_DMABurstLength_2Transfers) || \
693 ((LENGTH) == TIM_DMABurstLength_3Transfers) || \
694 ((LENGTH) == TIM_DMABurstLength_4Transfers) || \
695 ((LENGTH) == TIM_DMABurstLength_5Transfers) || \
696 ((LENGTH) == TIM_DMABurstLength_6Transfers) || \
697 ((LENGTH) == TIM_DMABurstLength_7Transfers) || \
698 ((LENGTH) == TIM_DMABurstLength_8Transfers) || \
699 ((LENGTH) == TIM_DMABurstLength_9Transfers) || \
700 ((LENGTH) == TIM_DMABurstLength_10Transfers) || \
701 ((LENGTH) == TIM_DMABurstLength_11Transfers) || \
702 ((LENGTH) == TIM_DMABurstLength_12Transfers) || \
703 ((LENGTH) == TIM_DMABurstLength_13Transfers) || \
704 ((LENGTH) == TIM_DMABurstLength_14Transfers) || \
705 ((LENGTH) == TIM_DMABurstLength_15Transfers) || \
706 ((LENGTH) == TIM_DMABurstLength_16Transfers) || \
707 ((LENGTH) == TIM_DMABurstLength_17Transfers) || \
708 ((LENGTH) == TIM_DMABurstLength_18Transfers))
717 #define TIM_DMA_Update ((uint16_t)0x0100)
718 #define TIM_DMA_CC1 ((uint16_t)0x0200)
719 #define TIM_DMA_CC2 ((uint16_t)0x0400)
720 #define TIM_DMA_CC3 ((uint16_t)0x0800)
721 #define TIM_DMA_CC4 ((uint16_t)0x1000)
722 #define TIM_DMA_COM ((uint16_t)0x2000)
723 #define TIM_DMA_Trigger ((uint16_t)0x4000)
724 #define IS_TIM_DMA_SOURCE(SOURCE) ((((SOURCE) & (uint16_t)0x80FF) == 0x0000) && ((SOURCE) != 0x0000))
734 #define TIM_ExtTRGPSC_OFF ((uint16_t)0x0000)
735 #define TIM_ExtTRGPSC_DIV2 ((uint16_t)0x1000)
736 #define TIM_ExtTRGPSC_DIV4 ((uint16_t)0x2000)
737 #define TIM_ExtTRGPSC_DIV8 ((uint16_t)0x3000)
738 #define IS_TIM_EXT_PRESCALER(PRESCALER) (((PRESCALER) == TIM_ExtTRGPSC_OFF) || \
739 ((PRESCALER) == TIM_ExtTRGPSC_DIV2) || \
740 ((PRESCALER) == TIM_ExtTRGPSC_DIV4) || \
741 ((PRESCALER) == TIM_ExtTRGPSC_DIV8))
750 #define TIM_TS_ITR0 ((uint16_t)0x0000)
751 #define TIM_TS_ITR1 ((uint16_t)0x0010)
752 #define TIM_TS_ITR2 ((uint16_t)0x0020)
753 #define TIM_TS_ITR3 ((uint16_t)0x0030)
754 #define TIM_TS_TI1F_ED ((uint16_t)0x0040)
755 #define TIM_TS_TI1FP1 ((uint16_t)0x0050)
756 #define TIM_TS_TI2FP2 ((uint16_t)0x0060)
757 #define TIM_TS_ETRF ((uint16_t)0x0070)
758 #define IS_TIM_TRIGGER_SELECTION(SELECTION) (((SELECTION) == TIM_TS_ITR0) || \
759 ((SELECTION) == TIM_TS_ITR1) || \
760 ((SELECTION) == TIM_TS_ITR2) || \
761 ((SELECTION) == TIM_TS_ITR3) || \
762 ((SELECTION) == TIM_TS_TI1F_ED) || \
763 ((SELECTION) == TIM_TS_TI1FP1) || \
764 ((SELECTION) == TIM_TS_TI2FP2) || \
765 ((SELECTION) == TIM_TS_ETRF))
766 #define IS_TIM_INTERNAL_TRIGGER_SELECTION(SELECTION) (((SELECTION) == TIM_TS_ITR0) || \
767 ((SELECTION) == TIM_TS_ITR1) || \
768 ((SELECTION) == TIM_TS_ITR2) || \
769 ((SELECTION) == TIM_TS_ITR3))
778 #define TIM_TIxExternalCLK1Source_TI1 ((uint16_t)0x0050)
779 #define TIM_TIxExternalCLK1Source_TI2 ((uint16_t)0x0060)
780 #define TIM_TIxExternalCLK1Source_TI1ED ((uint16_t)0x0040)
781 #define IS_TIM_TIXCLK_SOURCE(SOURCE) (((SOURCE) == TIM_TIxExternalCLK1Source_TI1) || \
782 ((SOURCE) == TIM_TIxExternalCLK1Source_TI2) || \
783 ((SOURCE) == TIM_TIxExternalCLK1Source_TI1ED))
791 #define TIM_ExtTRGPolarity_Inverted ((uint16_t)0x8000)
792 #define TIM_ExtTRGPolarity_NonInverted ((uint16_t)0x0000)
793 #define IS_TIM_EXT_POLARITY(POLARITY) (((POLARITY) == TIM_ExtTRGPolarity_Inverted) || \
794 ((POLARITY) == TIM_ExtTRGPolarity_NonInverted))
803 #define TIM_PSCReloadMode_Update ((uint16_t)0x0000)
804 #define TIM_PSCReloadMode_Immediate ((uint16_t)0x0001)
805 #define IS_TIM_PRESCALER_RELOAD(RELOAD) (((RELOAD) == TIM_PSCReloadMode_Update) || \
806 ((RELOAD) == TIM_PSCReloadMode_Immediate))
815 #define TIM_ForcedAction_Active ((uint16_t)0x0050)
816 #define TIM_ForcedAction_InActive ((uint16_t)0x0040)
817 #define IS_TIM_FORCED_ACTION(ACTION) (((ACTION) == TIM_ForcedAction_Active) || \
818 ((ACTION) == TIM_ForcedAction_InActive))
827 #define TIM_EncoderMode_TI1 ((uint16_t)0x0001)
828 #define TIM_EncoderMode_TI2 ((uint16_t)0x0002)
829 #define TIM_EncoderMode_TI12 ((uint16_t)0x0003)
830 #define IS_TIM_ENCODER_MODE(MODE) (((MODE) == TIM_EncoderMode_TI1) || \
831 ((MODE) == TIM_EncoderMode_TI2) || \
832 ((MODE) == TIM_EncoderMode_TI12))
842 #define TIM_EventSource_Update ((uint16_t)0x0001)
843 #define TIM_EventSource_CC1 ((uint16_t)0x0002)
844 #define TIM_EventSource_CC2 ((uint16_t)0x0004)
845 #define TIM_EventSource_CC3 ((uint16_t)0x0008)
846 #define TIM_EventSource_CC4 ((uint16_t)0x0010)
847 #define TIM_EventSource_COM ((uint16_t)0x0020)
848 #define TIM_EventSource_Trigger ((uint16_t)0x0040)
849 #define TIM_EventSource_Break ((uint16_t)0x0080)
850 #define IS_TIM_EVENT_SOURCE(SOURCE) ((((SOURCE) & (uint16_t)0xFF00) == 0x0000) && ((SOURCE) != 0x0000))
860 #define TIM_UpdateSource_Global ((uint16_t)0x0000)
863 #define TIM_UpdateSource_Regular ((uint16_t)0x0001)
864 #define IS_TIM_UPDATE_SOURCE(SOURCE) (((SOURCE) == TIM_UpdateSource_Global) || \
865 ((SOURCE) == TIM_UpdateSource_Regular))
874 #define TIM_OCPreload_Enable ((uint16_t)0x0008)
875 #define TIM_OCPreload_Disable ((uint16_t)0x0000)
876 #define IS_TIM_OCPRELOAD_STATE(STATE) (((STATE) == TIM_OCPreload_Enable) || \
877 ((STATE) == TIM_OCPreload_Disable))
886 #define TIM_OCFast_Enable ((uint16_t)0x0004)
887 #define TIM_OCFast_Disable ((uint16_t)0x0000)
888 #define IS_TIM_OCFAST_STATE(STATE) (((STATE) == TIM_OCFast_Enable) || \
889 ((STATE) == TIM_OCFast_Disable))
899 #define TIM_OCClear_Enable ((uint16_t)0x0080)
900 #define TIM_OCClear_Disable ((uint16_t)0x0000)
901 #define IS_TIM_OCCLEAR_STATE(STATE) (((STATE) == TIM_OCClear_Enable) || \
902 ((STATE) == TIM_OCClear_Disable))
911 #define TIM_TRGOSource_Reset ((uint16_t)0x0000)
912 #define TIM_TRGOSource_Enable ((uint16_t)0x0010)
913 #define TIM_TRGOSource_Update ((uint16_t)0x0020)
914 #define TIM_TRGOSource_OC1 ((uint16_t)0x0030)
915 #define TIM_TRGOSource_OC1Ref ((uint16_t)0x0040)
916 #define TIM_TRGOSource_OC2Ref ((uint16_t)0x0050)
917 #define TIM_TRGOSource_OC3Ref ((uint16_t)0x0060)
918 #define TIM_TRGOSource_OC4Ref ((uint16_t)0x0070)
919 #define IS_TIM_TRGO_SOURCE(SOURCE) (((SOURCE) == TIM_TRGOSource_Reset) || \
920 ((SOURCE) == TIM_TRGOSource_Enable) || \
921 ((SOURCE) == TIM_TRGOSource_Update) || \
922 ((SOURCE) == TIM_TRGOSource_OC1) || \
923 ((SOURCE) == TIM_TRGOSource_OC1Ref) || \
924 ((SOURCE) == TIM_TRGOSource_OC2Ref) || \
925 ((SOURCE) == TIM_TRGOSource_OC3Ref) || \
926 ((SOURCE) == TIM_TRGOSource_OC4Ref))
935 #define TIM_SlaveMode_Reset ((uint16_t)0x0004)
936 #define TIM_SlaveMode_Gated ((uint16_t)0x0005)
937 #define TIM_SlaveMode_Trigger ((uint16_t)0x0006)
938 #define TIM_SlaveMode_External1 ((uint16_t)0x0007)
939 #define IS_TIM_SLAVE_MODE(MODE) (((MODE) == TIM_SlaveMode_Reset) || \
940 ((MODE) == TIM_SlaveMode_Gated) || \
941 ((MODE) == TIM_SlaveMode_Trigger) || \
942 ((MODE) == TIM_SlaveMode_External1))
951 #define TIM_MasterSlaveMode_Enable ((uint16_t)0x0080)
952 #define TIM_MasterSlaveMode_Disable ((uint16_t)0x0000)
953 #define IS_TIM_MSM_STATE(STATE) (((STATE) == TIM_MasterSlaveMode_Enable) || \
954 ((STATE) == TIM_MasterSlaveMode_Disable))
963 #define TIM_FLAG_Update ((uint16_t)0x0001)
964 #define TIM_FLAG_CC1 ((uint16_t)0x0002)
965 #define TIM_FLAG_CC2 ((uint16_t)0x0004)
966 #define TIM_FLAG_CC3 ((uint16_t)0x0008)
967 #define TIM_FLAG_CC4 ((uint16_t)0x0010)
968 #define TIM_FLAG_COM ((uint16_t)0x0020)
969 #define TIM_FLAG_Trigger ((uint16_t)0x0040)
970 #define TIM_FLAG_Break ((uint16_t)0x0080)
971 #define TIM_FLAG_CC1OF ((uint16_t)0x0200)
972 #define TIM_FLAG_CC2OF ((uint16_t)0x0400)
973 #define TIM_FLAG_CC3OF ((uint16_t)0x0800)
974 #define TIM_FLAG_CC4OF ((uint16_t)0x1000)
975 #define IS_TIM_GET_FLAG(FLAG) (((FLAG) == TIM_FLAG_Update) || \
976 ((FLAG) == TIM_FLAG_CC1) || \
977 ((FLAG) == TIM_FLAG_CC2) || \
978 ((FLAG) == TIM_FLAG_CC3) || \
979 ((FLAG) == TIM_FLAG_CC4) || \
980 ((FLAG) == TIM_FLAG_COM) || \
981 ((FLAG) == TIM_FLAG_Trigger) || \
982 ((FLAG) == TIM_FLAG_Break) || \
983 ((FLAG) == TIM_FLAG_CC1OF) || \
984 ((FLAG) == TIM_FLAG_CC2OF) || \
985 ((FLAG) == TIM_FLAG_CC3OF) || \
986 ((FLAG) == TIM_FLAG_CC4OF))
989 #define IS_TIM_CLEAR_FLAG(TIM_FLAG) ((((TIM_FLAG) & (uint16_t)0xE100) == 0x0000) && ((TIM_FLAG) != 0x0000))
998 #define IS_TIM_IC_FILTER(ICFILTER) ((ICFILTER) <= 0xF)
1007 #define IS_TIM_EXT_FILTER(EXTFILTER) ((EXTFILTER) <= 0xF)
1016 #define TIM_DMABurstLength_1Byte TIM_DMABurstLength_1Transfer
1017 #define TIM_DMABurstLength_2Bytes TIM_DMABurstLength_2Transfers
1018 #define TIM_DMABurstLength_3Bytes TIM_DMABurstLength_3Transfers
1019 #define TIM_DMABurstLength_4Bytes TIM_DMABurstLength_4Transfers
1020 #define TIM_DMABurstLength_5Bytes TIM_DMABurstLength_5Transfers
1021 #define TIM_DMABurstLength_6Bytes TIM_DMABurstLength_6Transfers
1022 #define TIM_DMABurstLength_7Bytes TIM_DMABurstLength_7Transfers
1023 #define TIM_DMABurstLength_8Bytes TIM_DMABurstLength_8Transfers
1024 #define TIM_DMABurstLength_9Bytes TIM_DMABurstLength_9Transfers
1025 #define TIM_DMABurstLength_10Bytes TIM_DMABurstLength_10Transfers
1026 #define TIM_DMABurstLength_11Bytes TIM_DMABurstLength_11Transfers
1027 #define TIM_DMABurstLength_12Bytes TIM_DMABurstLength_12Transfers
1028 #define TIM_DMABurstLength_13Bytes TIM_DMABurstLength_13Transfers
1029 #define TIM_DMABurstLength_14Bytes TIM_DMABurstLength_14Transfers
1030 #define TIM_DMABurstLength_15Bytes TIM_DMABurstLength_15Transfers
1031 #define TIM_DMABurstLength_16Bytes TIM_DMABurstLength_16Transfers
1032 #define TIM_DMABurstLength_17Bytes TIM_DMABurstLength_17Transfers
1033 #define TIM_DMABurstLength_18Bytes TIM_DMABurstLength_18Transfers
1076 uint16_t TIM_ICPolarity, uint16_t ICFilter);
1078 uint16_t ExtTRGFilter);
1080 uint16_t TIM_ExtTRGPolarity, uint16_t ExtTRGFilter);
1082 uint16_t ExtTRGFilter);
1087 uint16_t TIM_IC1Polarity, uint16_t TIM_IC2Polarity);