30 #ifndef __STM32F4xx_TIM_H
31 #define __STM32F4xx_TIM_H
38 #include "stm32f4xx.h"
57 uint16_t TIM_Prescaler;
60 uint16_t TIM_CounterMode;
67 uint16_t TIM_ClockDivision;
70 uint8_t TIM_RepetitionCounter;
89 uint16_t TIM_OutputState;
92 uint16_t TIM_OutputNState;
99 uint16_t TIM_OCPolarity;
102 uint16_t TIM_OCNPolarity;
106 uint16_t TIM_OCIdleState;
110 uint16_t TIM_OCNIdleState;
122 uint16_t TIM_Channel;
125 uint16_t TIM_ICPolarity;
128 uint16_t TIM_ICSelection;
131 uint16_t TIM_ICPrescaler;
134 uint16_t TIM_ICFilter;
146 uint16_t TIM_OSSRState;
149 uint16_t TIM_OSSIState;
152 uint16_t TIM_LOCKLevel;
155 uint16_t TIM_DeadTime;
162 uint16_t TIM_BreakPolarity;
165 uint16_t TIM_AutomaticOutput;
175 #define IS_TIM_ALL_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
176 ((PERIPH) == TIM2) || \
177 ((PERIPH) == TIM3) || \
178 ((PERIPH) == TIM4) || \
179 ((PERIPH) == TIM5) || \
180 ((PERIPH) == TIM6) || \
181 ((PERIPH) == TIM7) || \
182 ((PERIPH) == TIM8) || \
183 ((PERIPH) == TIM9) || \
184 ((PERIPH) == TIM10) || \
185 ((PERIPH) == TIM11) || \
186 ((PERIPH) == TIM12) || \
187 (((PERIPH) == TIM13) || \
188 ((PERIPH) == TIM14)))
190 #define IS_TIM_LIST1_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
191 ((PERIPH) == TIM2) || \
192 ((PERIPH) == TIM3) || \
193 ((PERIPH) == TIM4) || \
194 ((PERIPH) == TIM5) || \
195 ((PERIPH) == TIM8) || \
196 ((PERIPH) == TIM9) || \
197 ((PERIPH) == TIM10) || \
198 ((PERIPH) == TIM11) || \
199 ((PERIPH) == TIM12) || \
200 ((PERIPH) == TIM13) || \
204 #define IS_TIM_LIST2_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
205 ((PERIPH) == TIM2) || \
206 ((PERIPH) == TIM3) || \
207 ((PERIPH) == TIM4) || \
208 ((PERIPH) == TIM5) || \
209 ((PERIPH) == TIM8) || \
210 ((PERIPH) == TIM9) || \
213 #define IS_TIM_LIST3_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
214 ((PERIPH) == TIM2) || \
215 ((PERIPH) == TIM3) || \
216 ((PERIPH) == TIM4) || \
217 ((PERIPH) == TIM5) || \
220 #define IS_TIM_LIST4_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
223 #define IS_TIM_LIST5_PERIPH(PERIPH) (((PERIPH) == TIM1) || \
224 ((PERIPH) == TIM2) || \
225 ((PERIPH) == TIM3) || \
226 ((PERIPH) == TIM4) || \
227 ((PERIPH) == TIM5) || \
228 ((PERIPH) == TIM6) || \
229 ((PERIPH) == TIM7) || \
232 #define IS_TIM_LIST6_PERIPH(TIMx)(((TIMx) == TIM2) || \
233 ((TIMx) == TIM5) || \
240 #define TIM_OCMode_Timing ((uint16_t)0x0000)
241 #define TIM_OCMode_Active ((uint16_t)0x0010)
242 #define TIM_OCMode_Inactive ((uint16_t)0x0020)
243 #define TIM_OCMode_Toggle ((uint16_t)0x0030)
244 #define TIM_OCMode_PWM1 ((uint16_t)0x0060)
245 #define TIM_OCMode_PWM2 ((uint16_t)0x0070)
246 #define IS_TIM_OC_MODE(MODE) (((MODE) == TIM_OCMode_Timing) || \
247 ((MODE) == TIM_OCMode_Active) || \
248 ((MODE) == TIM_OCMode_Inactive) || \
249 ((MODE) == TIM_OCMode_Toggle)|| \
250 ((MODE) == TIM_OCMode_PWM1) || \
251 ((MODE) == TIM_OCMode_PWM2))
252 #define IS_TIM_OCM(MODE) (((MODE) == TIM_OCMode_Timing) || \
253 ((MODE) == TIM_OCMode_Active) || \
254 ((MODE) == TIM_OCMode_Inactive) || \
255 ((MODE) == TIM_OCMode_Toggle)|| \
256 ((MODE) == TIM_OCMode_PWM1) || \
257 ((MODE) == TIM_OCMode_PWM2) || \
258 ((MODE) == TIM_ForcedAction_Active) || \
259 ((MODE) == TIM_ForcedAction_InActive))
268 #define TIM_OPMode_Single ((uint16_t)0x0008)
269 #define TIM_OPMode_Repetitive ((uint16_t)0x0000)
270 #define IS_TIM_OPM_MODE(MODE) (((MODE) == TIM_OPMode_Single) || \
271 ((MODE) == TIM_OPMode_Repetitive))
280 #define TIM_Channel_1 ((uint16_t)0x0000)
281 #define TIM_Channel_2 ((uint16_t)0x0004)
282 #define TIM_Channel_3 ((uint16_t)0x0008)
283 #define TIM_Channel_4 ((uint16_t)0x000C)
285 #define IS_TIM_CHANNEL(CHANNEL) (((CHANNEL) == TIM_Channel_1) || \
286 ((CHANNEL) == TIM_Channel_2) || \
287 ((CHANNEL) == TIM_Channel_3) || \
288 ((CHANNEL) == TIM_Channel_4))
290 #define IS_TIM_PWMI_CHANNEL(CHANNEL) (((CHANNEL) == TIM_Channel_1) || \
291 ((CHANNEL) == TIM_Channel_2))
292 #define IS_TIM_COMPLEMENTARY_CHANNEL(CHANNEL) (((CHANNEL) == TIM_Channel_1) || \
293 ((CHANNEL) == TIM_Channel_2) || \
294 ((CHANNEL) == TIM_Channel_3))
303 #define TIM_CKD_DIV1 ((uint16_t)0x0000)
304 #define TIM_CKD_DIV2 ((uint16_t)0x0100)
305 #define TIM_CKD_DIV4 ((uint16_t)0x0200)
306 #define IS_TIM_CKD_DIV(DIV) (((DIV) == TIM_CKD_DIV1) || \
307 ((DIV) == TIM_CKD_DIV2) || \
308 ((DIV) == TIM_CKD_DIV4))
317 #define TIM_CounterMode_Up ((uint16_t)0x0000)
318 #define TIM_CounterMode_Down ((uint16_t)0x0010)
319 #define TIM_CounterMode_CenterAligned1 ((uint16_t)0x0020)
320 #define TIM_CounterMode_CenterAligned2 ((uint16_t)0x0040)
321 #define TIM_CounterMode_CenterAligned3 ((uint16_t)0x0060)
322 #define IS_TIM_COUNTER_MODE(MODE) (((MODE) == TIM_CounterMode_Up) || \
323 ((MODE) == TIM_CounterMode_Down) || \
324 ((MODE) == TIM_CounterMode_CenterAligned1) || \
325 ((MODE) == TIM_CounterMode_CenterAligned2) || \
326 ((MODE) == TIM_CounterMode_CenterAligned3))
335 #define TIM_OCPolarity_High ((uint16_t)0x0000)
336 #define TIM_OCPolarity_Low ((uint16_t)0x0002)
337 #define IS_TIM_OC_POLARITY(POLARITY) (((POLARITY) == TIM_OCPolarity_High) || \
338 ((POLARITY) == TIM_OCPolarity_Low))
347 #define TIM_OCNPolarity_High ((uint16_t)0x0000)
348 #define TIM_OCNPolarity_Low ((uint16_t)0x0008)
349 #define IS_TIM_OCN_POLARITY(POLARITY) (((POLARITY) == TIM_OCNPolarity_High) || \
350 ((POLARITY) == TIM_OCNPolarity_Low))
359 #define TIM_OutputState_Disable ((uint16_t)0x0000)
360 #define TIM_OutputState_Enable ((uint16_t)0x0001)
361 #define IS_TIM_OUTPUT_STATE(STATE) (((STATE) == TIM_OutputState_Disable) || \
362 ((STATE) == TIM_OutputState_Enable))
371 #define TIM_OutputNState_Disable ((uint16_t)0x0000)
372 #define TIM_OutputNState_Enable ((uint16_t)0x0004)
373 #define IS_TIM_OUTPUTN_STATE(STATE) (((STATE) == TIM_OutputNState_Disable) || \
374 ((STATE) == TIM_OutputNState_Enable))
383 #define TIM_CCx_Enable ((uint16_t)0x0001)
384 #define TIM_CCx_Disable ((uint16_t)0x0000)
385 #define IS_TIM_CCX(CCX) (((CCX) == TIM_CCx_Enable) || \
386 ((CCX) == TIM_CCx_Disable))
395 #define TIM_CCxN_Enable ((uint16_t)0x0004)
396 #define TIM_CCxN_Disable ((uint16_t)0x0000)
397 #define IS_TIM_CCXN(CCXN) (((CCXN) == TIM_CCxN_Enable) || \
398 ((CCXN) == TIM_CCxN_Disable))
407 #define TIM_Break_Enable ((uint16_t)0x1000)
408 #define TIM_Break_Disable ((uint16_t)0x0000)
409 #define IS_TIM_BREAK_STATE(STATE) (((STATE) == TIM_Break_Enable) || \
410 ((STATE) == TIM_Break_Disable))
419 #define TIM_BreakPolarity_Low ((uint16_t)0x0000)
420 #define TIM_BreakPolarity_High ((uint16_t)0x2000)
421 #define IS_TIM_BREAK_POLARITY(POLARITY) (((POLARITY) == TIM_BreakPolarity_Low) || \
422 ((POLARITY) == TIM_BreakPolarity_High))
431 #define TIM_AutomaticOutput_Enable ((uint16_t)0x4000)
432 #define TIM_AutomaticOutput_Disable ((uint16_t)0x0000)
433 #define IS_TIM_AUTOMATIC_OUTPUT_STATE(STATE) (((STATE) == TIM_AutomaticOutput_Enable) || \
434 ((STATE) == TIM_AutomaticOutput_Disable))
443 #define TIM_LOCKLevel_OFF ((uint16_t)0x0000)
444 #define TIM_LOCKLevel_1 ((uint16_t)0x0100)
445 #define TIM_LOCKLevel_2 ((uint16_t)0x0200)
446 #define TIM_LOCKLevel_3 ((uint16_t)0x0300)
447 #define IS_TIM_LOCK_LEVEL(LEVEL) (((LEVEL) == TIM_LOCKLevel_OFF) || \
448 ((LEVEL) == TIM_LOCKLevel_1) || \
449 ((LEVEL) == TIM_LOCKLevel_2) || \
450 ((LEVEL) == TIM_LOCKLevel_3))
459 #define TIM_OSSIState_Enable ((uint16_t)0x0400)
460 #define TIM_OSSIState_Disable ((uint16_t)0x0000)
461 #define IS_TIM_OSSI_STATE(STATE) (((STATE) == TIM_OSSIState_Enable) || \
462 ((STATE) == TIM_OSSIState_Disable))
471 #define TIM_OSSRState_Enable ((uint16_t)0x0800)
472 #define TIM_OSSRState_Disable ((uint16_t)0x0000)
473 #define IS_TIM_OSSR_STATE(STATE) (((STATE) == TIM_OSSRState_Enable) || \
474 ((STATE) == TIM_OSSRState_Disable))
483 #define TIM_OCIdleState_Set ((uint16_t)0x0100)
484 #define TIM_OCIdleState_Reset ((uint16_t)0x0000)
485 #define IS_TIM_OCIDLE_STATE(STATE) (((STATE) == TIM_OCIdleState_Set) || \
486 ((STATE) == TIM_OCIdleState_Reset))
495 #define TIM_OCNIdleState_Set ((uint16_t)0x0200)
496 #define TIM_OCNIdleState_Reset ((uint16_t)0x0000)
497 #define IS_TIM_OCNIDLE_STATE(STATE) (((STATE) == TIM_OCNIdleState_Set) || \
498 ((STATE) == TIM_OCNIdleState_Reset))
507 #define TIM_ICPolarity_Rising ((uint16_t)0x0000)
508 #define TIM_ICPolarity_Falling ((uint16_t)0x0002)
509 #define TIM_ICPolarity_BothEdge ((uint16_t)0x000A)
510 #define IS_TIM_IC_POLARITY(POLARITY) (((POLARITY) == TIM_ICPolarity_Rising) || \
511 ((POLARITY) == TIM_ICPolarity_Falling)|| \
512 ((POLARITY) == TIM_ICPolarity_BothEdge))
521 #define TIM_ICSelection_DirectTI ((uint16_t)0x0001)
523 #define TIM_ICSelection_IndirectTI ((uint16_t)0x0002)
525 #define TIM_ICSelection_TRC ((uint16_t)0x0003)
526 #define IS_TIM_IC_SELECTION(SELECTION) (((SELECTION) == TIM_ICSelection_DirectTI) || \
527 ((SELECTION) == TIM_ICSelection_IndirectTI) || \
528 ((SELECTION) == TIM_ICSelection_TRC))
537 #define TIM_ICPSC_DIV1 ((uint16_t)0x0000)
538 #define TIM_ICPSC_DIV2 ((uint16_t)0x0004)
539 #define TIM_ICPSC_DIV4 ((uint16_t)0x0008)
540 #define TIM_ICPSC_DIV8 ((uint16_t)0x000C)
541 #define IS_TIM_IC_PRESCALER(PRESCALER) (((PRESCALER) == TIM_ICPSC_DIV1) || \
542 ((PRESCALER) == TIM_ICPSC_DIV2) || \
543 ((PRESCALER) == TIM_ICPSC_DIV4) || \
544 ((PRESCALER) == TIM_ICPSC_DIV8))
553 #define TIM_IT_Update ((uint16_t)0x0001)
554 #define TIM_IT_CC1 ((uint16_t)0x0002)
555 #define TIM_IT_CC2 ((uint16_t)0x0004)
556 #define TIM_IT_CC3 ((uint16_t)0x0008)
557 #define TIM_IT_CC4 ((uint16_t)0x0010)
558 #define TIM_IT_COM ((uint16_t)0x0020)
559 #define TIM_IT_Trigger ((uint16_t)0x0040)
560 #define TIM_IT_Break ((uint16_t)0x0080)
561 #define IS_TIM_IT(IT) ((((IT) & (uint16_t)0xFF00) == 0x0000) && ((IT) != 0x0000))
563 #define IS_TIM_GET_IT(IT) (((IT) == TIM_IT_Update) || \
564 ((IT) == TIM_IT_CC1) || \
565 ((IT) == TIM_IT_CC2) || \
566 ((IT) == TIM_IT_CC3) || \
567 ((IT) == TIM_IT_CC4) || \
568 ((IT) == TIM_IT_COM) || \
569 ((IT) == TIM_IT_Trigger) || \
570 ((IT) == TIM_IT_Break))
579 #define TIM_DMABase_CR1 ((uint16_t)0x0000)
580 #define TIM_DMABase_CR2 ((uint16_t)0x0001)
581 #define TIM_DMABase_SMCR ((uint16_t)0x0002)
582 #define TIM_DMABase_DIER ((uint16_t)0x0003)
583 #define TIM_DMABase_SR ((uint16_t)0x0004)
584 #define TIM_DMABase_EGR ((uint16_t)0x0005)
585 #define TIM_DMABase_CCMR1 ((uint16_t)0x0006)
586 #define TIM_DMABase_CCMR2 ((uint16_t)0x0007)
587 #define TIM_DMABase_CCER ((uint16_t)0x0008)
588 #define TIM_DMABase_CNT ((uint16_t)0x0009)
589 #define TIM_DMABase_PSC ((uint16_t)0x000A)
590 #define TIM_DMABase_ARR ((uint16_t)0x000B)
591 #define TIM_DMABase_RCR ((uint16_t)0x000C)
592 #define TIM_DMABase_CCR1 ((uint16_t)0x000D)
593 #define TIM_DMABase_CCR2 ((uint16_t)0x000E)
594 #define TIM_DMABase_CCR3 ((uint16_t)0x000F)
595 #define TIM_DMABase_CCR4 ((uint16_t)0x0010)
596 #define TIM_DMABase_BDTR ((uint16_t)0x0011)
597 #define TIM_DMABase_DCR ((uint16_t)0x0012)
598 #define TIM_DMABase_OR ((uint16_t)0x0013)
599 #define IS_TIM_DMA_BASE(BASE) (((BASE) == TIM_DMABase_CR1) || \
600 ((BASE) == TIM_DMABase_CR2) || \
601 ((BASE) == TIM_DMABase_SMCR) || \
602 ((BASE) == TIM_DMABase_DIER) || \
603 ((BASE) == TIM_DMABase_SR) || \
604 ((BASE) == TIM_DMABase_EGR) || \
605 ((BASE) == TIM_DMABase_CCMR1) || \
606 ((BASE) == TIM_DMABase_CCMR2) || \
607 ((BASE) == TIM_DMABase_CCER) || \
608 ((BASE) == TIM_DMABase_CNT) || \
609 ((BASE) == TIM_DMABase_PSC) || \
610 ((BASE) == TIM_DMABase_ARR) || \
611 ((BASE) == TIM_DMABase_RCR) || \
612 ((BASE) == TIM_DMABase_CCR1) || \
613 ((BASE) == TIM_DMABase_CCR2) || \
614 ((BASE) == TIM_DMABase_CCR3) || \
615 ((BASE) == TIM_DMABase_CCR4) || \
616 ((BASE) == TIM_DMABase_BDTR) || \
617 ((BASE) == TIM_DMABase_DCR) || \
618 ((BASE) == TIM_DMABase_OR))
627 #define TIM_DMABurstLength_1Transfer ((uint16_t)0x0000)
628 #define TIM_DMABurstLength_2Transfers ((uint16_t)0x0100)
629 #define TIM_DMABurstLength_3Transfers ((uint16_t)0x0200)
630 #define TIM_DMABurstLength_4Transfers ((uint16_t)0x0300)
631 #define TIM_DMABurstLength_5Transfers ((uint16_t)0x0400)
632 #define TIM_DMABurstLength_6Transfers ((uint16_t)0x0500)
633 #define TIM_DMABurstLength_7Transfers ((uint16_t)0x0600)
634 #define TIM_DMABurstLength_8Transfers ((uint16_t)0x0700)
635 #define TIM_DMABurstLength_9Transfers ((uint16_t)0x0800)
636 #define TIM_DMABurstLength_10Transfers ((uint16_t)0x0900)
637 #define TIM_DMABurstLength_11Transfers ((uint16_t)0x0A00)
638 #define TIM_DMABurstLength_12Transfers ((uint16_t)0x0B00)
639 #define TIM_DMABurstLength_13Transfers ((uint16_t)0x0C00)
640 #define TIM_DMABurstLength_14Transfers ((uint16_t)0x0D00)
641 #define TIM_DMABurstLength_15Transfers ((uint16_t)0x0E00)
642 #define TIM_DMABurstLength_16Transfers ((uint16_t)0x0F00)
643 #define TIM_DMABurstLength_17Transfers ((uint16_t)0x1000)
644 #define TIM_DMABurstLength_18Transfers ((uint16_t)0x1100)
645 #define IS_TIM_DMA_LENGTH(LENGTH) (((LENGTH) == TIM_DMABurstLength_1Transfer) || \
646 ((LENGTH) == TIM_DMABurstLength_2Transfers) || \
647 ((LENGTH) == TIM_DMABurstLength_3Transfers) || \
648 ((LENGTH) == TIM_DMABurstLength_4Transfers) || \
649 ((LENGTH) == TIM_DMABurstLength_5Transfers) || \
650 ((LENGTH) == TIM_DMABurstLength_6Transfers) || \
651 ((LENGTH) == TIM_DMABurstLength_7Transfers) || \
652 ((LENGTH) == TIM_DMABurstLength_8Transfers) || \
653 ((LENGTH) == TIM_DMABurstLength_9Transfers) || \
654 ((LENGTH) == TIM_DMABurstLength_10Transfers) || \
655 ((LENGTH) == TIM_DMABurstLength_11Transfers) || \
656 ((LENGTH) == TIM_DMABurstLength_12Transfers) || \
657 ((LENGTH) == TIM_DMABurstLength_13Transfers) || \
658 ((LENGTH) == TIM_DMABurstLength_14Transfers) || \
659 ((LENGTH) == TIM_DMABurstLength_15Transfers) || \
660 ((LENGTH) == TIM_DMABurstLength_16Transfers) || \
661 ((LENGTH) == TIM_DMABurstLength_17Transfers) || \
662 ((LENGTH) == TIM_DMABurstLength_18Transfers))
671 #define TIM_DMA_Update ((uint16_t)0x0100)
672 #define TIM_DMA_CC1 ((uint16_t)0x0200)
673 #define TIM_DMA_CC2 ((uint16_t)0x0400)
674 #define TIM_DMA_CC3 ((uint16_t)0x0800)
675 #define TIM_DMA_CC4 ((uint16_t)0x1000)
676 #define TIM_DMA_COM ((uint16_t)0x2000)
677 #define TIM_DMA_Trigger ((uint16_t)0x4000)
678 #define IS_TIM_DMA_SOURCE(SOURCE) ((((SOURCE) & (uint16_t)0x80FF) == 0x0000) && ((SOURCE) != 0x0000))
688 #define TIM_ExtTRGPSC_OFF ((uint16_t)0x0000)
689 #define TIM_ExtTRGPSC_DIV2 ((uint16_t)0x1000)
690 #define TIM_ExtTRGPSC_DIV4 ((uint16_t)0x2000)
691 #define TIM_ExtTRGPSC_DIV8 ((uint16_t)0x3000)
692 #define IS_TIM_EXT_PRESCALER(PRESCALER) (((PRESCALER) == TIM_ExtTRGPSC_OFF) || \
693 ((PRESCALER) == TIM_ExtTRGPSC_DIV2) || \
694 ((PRESCALER) == TIM_ExtTRGPSC_DIV4) || \
695 ((PRESCALER) == TIM_ExtTRGPSC_DIV8))
704 #define TIM_TS_ITR0 ((uint16_t)0x0000)
705 #define TIM_TS_ITR1 ((uint16_t)0x0010)
706 #define TIM_TS_ITR2 ((uint16_t)0x0020)
707 #define TIM_TS_ITR3 ((uint16_t)0x0030)
708 #define TIM_TS_TI1F_ED ((uint16_t)0x0040)
709 #define TIM_TS_TI1FP1 ((uint16_t)0x0050)
710 #define TIM_TS_TI2FP2 ((uint16_t)0x0060)
711 #define TIM_TS_ETRF ((uint16_t)0x0070)
712 #define IS_TIM_TRIGGER_SELECTION(SELECTION) (((SELECTION) == TIM_TS_ITR0) || \
713 ((SELECTION) == TIM_TS_ITR1) || \
714 ((SELECTION) == TIM_TS_ITR2) || \
715 ((SELECTION) == TIM_TS_ITR3) || \
716 ((SELECTION) == TIM_TS_TI1F_ED) || \
717 ((SELECTION) == TIM_TS_TI1FP1) || \
718 ((SELECTION) == TIM_TS_TI2FP2) || \
719 ((SELECTION) == TIM_TS_ETRF))
720 #define IS_TIM_INTERNAL_TRIGGER_SELECTION(SELECTION) (((SELECTION) == TIM_TS_ITR0) || \
721 ((SELECTION) == TIM_TS_ITR1) || \
722 ((SELECTION) == TIM_TS_ITR2) || \
723 ((SELECTION) == TIM_TS_ITR3))
732 #define TIM_TIxExternalCLK1Source_TI1 ((uint16_t)0x0050)
733 #define TIM_TIxExternalCLK1Source_TI2 ((uint16_t)0x0060)
734 #define TIM_TIxExternalCLK1Source_TI1ED ((uint16_t)0x0040)
743 #define TIM_ExtTRGPolarity_Inverted ((uint16_t)0x8000)
744 #define TIM_ExtTRGPolarity_NonInverted ((uint16_t)0x0000)
745 #define IS_TIM_EXT_POLARITY(POLARITY) (((POLARITY) == TIM_ExtTRGPolarity_Inverted) || \
746 ((POLARITY) == TIM_ExtTRGPolarity_NonInverted))
755 #define TIM_PSCReloadMode_Update ((uint16_t)0x0000)
756 #define TIM_PSCReloadMode_Immediate ((uint16_t)0x0001)
757 #define IS_TIM_PRESCALER_RELOAD(RELOAD) (((RELOAD) == TIM_PSCReloadMode_Update) || \
758 ((RELOAD) == TIM_PSCReloadMode_Immediate))
767 #define TIM_ForcedAction_Active ((uint16_t)0x0050)
768 #define TIM_ForcedAction_InActive ((uint16_t)0x0040)
769 #define IS_TIM_FORCED_ACTION(ACTION) (((ACTION) == TIM_ForcedAction_Active) || \
770 ((ACTION) == TIM_ForcedAction_InActive))
779 #define TIM_EncoderMode_TI1 ((uint16_t)0x0001)
780 #define TIM_EncoderMode_TI2 ((uint16_t)0x0002)
781 #define TIM_EncoderMode_TI12 ((uint16_t)0x0003)
782 #define IS_TIM_ENCODER_MODE(MODE) (((MODE) == TIM_EncoderMode_TI1) || \
783 ((MODE) == TIM_EncoderMode_TI2) || \
784 ((MODE) == TIM_EncoderMode_TI12))
794 #define TIM_EventSource_Update ((uint16_t)0x0001)
795 #define TIM_EventSource_CC1 ((uint16_t)0x0002)
796 #define TIM_EventSource_CC2 ((uint16_t)0x0004)
797 #define TIM_EventSource_CC3 ((uint16_t)0x0008)
798 #define TIM_EventSource_CC4 ((uint16_t)0x0010)
799 #define TIM_EventSource_COM ((uint16_t)0x0020)
800 #define TIM_EventSource_Trigger ((uint16_t)0x0040)
801 #define TIM_EventSource_Break ((uint16_t)0x0080)
802 #define IS_TIM_EVENT_SOURCE(SOURCE) ((((SOURCE) & (uint16_t)0xFF00) == 0x0000) && ((SOURCE) != 0x0000))
812 #define TIM_UpdateSource_Global ((uint16_t)0x0000)
815 #define TIM_UpdateSource_Regular ((uint16_t)0x0001)
816 #define IS_TIM_UPDATE_SOURCE(SOURCE) (((SOURCE) == TIM_UpdateSource_Global) || \
817 ((SOURCE) == TIM_UpdateSource_Regular))
826 #define TIM_OCPreload_Enable ((uint16_t)0x0008)
827 #define TIM_OCPreload_Disable ((uint16_t)0x0000)
828 #define IS_TIM_OCPRELOAD_STATE(STATE) (((STATE) == TIM_OCPreload_Enable) || \
829 ((STATE) == TIM_OCPreload_Disable))
838 #define TIM_OCFast_Enable ((uint16_t)0x0004)
839 #define TIM_OCFast_Disable ((uint16_t)0x0000)
840 #define IS_TIM_OCFAST_STATE(STATE) (((STATE) == TIM_OCFast_Enable) || \
841 ((STATE) == TIM_OCFast_Disable))
851 #define TIM_OCClear_Enable ((uint16_t)0x0080)
852 #define TIM_OCClear_Disable ((uint16_t)0x0000)
853 #define IS_TIM_OCCLEAR_STATE(STATE) (((STATE) == TIM_OCClear_Enable) || \
854 ((STATE) == TIM_OCClear_Disable))
863 #define TIM_TRGOSource_Reset ((uint16_t)0x0000)
864 #define TIM_TRGOSource_Enable ((uint16_t)0x0010)
865 #define TIM_TRGOSource_Update ((uint16_t)0x0020)
866 #define TIM_TRGOSource_OC1 ((uint16_t)0x0030)
867 #define TIM_TRGOSource_OC1Ref ((uint16_t)0x0040)
868 #define TIM_TRGOSource_OC2Ref ((uint16_t)0x0050)
869 #define TIM_TRGOSource_OC3Ref ((uint16_t)0x0060)
870 #define TIM_TRGOSource_OC4Ref ((uint16_t)0x0070)
871 #define IS_TIM_TRGO_SOURCE(SOURCE) (((SOURCE) == TIM_TRGOSource_Reset) || \
872 ((SOURCE) == TIM_TRGOSource_Enable) || \
873 ((SOURCE) == TIM_TRGOSource_Update) || \
874 ((SOURCE) == TIM_TRGOSource_OC1) || \
875 ((SOURCE) == TIM_TRGOSource_OC1Ref) || \
876 ((SOURCE) == TIM_TRGOSource_OC2Ref) || \
877 ((SOURCE) == TIM_TRGOSource_OC3Ref) || \
878 ((SOURCE) == TIM_TRGOSource_OC4Ref))
887 #define TIM_SlaveMode_Reset ((uint16_t)0x0004)
888 #define TIM_SlaveMode_Gated ((uint16_t)0x0005)
889 #define TIM_SlaveMode_Trigger ((uint16_t)0x0006)
890 #define TIM_SlaveMode_External1 ((uint16_t)0x0007)
891 #define IS_TIM_SLAVE_MODE(MODE) (((MODE) == TIM_SlaveMode_Reset) || \
892 ((MODE) == TIM_SlaveMode_Gated) || \
893 ((MODE) == TIM_SlaveMode_Trigger) || \
894 ((MODE) == TIM_SlaveMode_External1))
903 #define TIM_MasterSlaveMode_Enable ((uint16_t)0x0080)
904 #define TIM_MasterSlaveMode_Disable ((uint16_t)0x0000)
905 #define IS_TIM_MSM_STATE(STATE) (((STATE) == TIM_MasterSlaveMode_Enable) || \
906 ((STATE) == TIM_MasterSlaveMode_Disable))
914 #define TIM2_TIM8_TRGO ((uint16_t)0x0000)
915 #define TIM2_ETH_PTP ((uint16_t)0x0400)
916 #define TIM2_USBFS_SOF ((uint16_t)0x0800)
917 #define TIM2_USBHS_SOF ((uint16_t)0x0C00)
919 #define TIM5_GPIO ((uint16_t)0x0000)
920 #define TIM5_LSI ((uint16_t)0x0040)
921 #define TIM5_LSE ((uint16_t)0x0080)
922 #define TIM5_RTC ((uint16_t)0x00C0)
924 #define TIM11_GPIO ((uint16_t)0x0000)
925 #define TIM11_HSE ((uint16_t)0x0002)
927 #define IS_TIM_REMAP(TIM_REMAP) (((TIM_REMAP) == TIM2_TIM8_TRGO)||\
928 ((TIM_REMAP) == TIM2_ETH_PTP)||\
929 ((TIM_REMAP) == TIM2_USBFS_SOF)||\
930 ((TIM_REMAP) == TIM2_USBHS_SOF)||\
931 ((TIM_REMAP) == TIM5_GPIO)||\
932 ((TIM_REMAP) == TIM5_LSI)||\
933 ((TIM_REMAP) == TIM5_LSE)||\
934 ((TIM_REMAP) == TIM5_RTC)||\
935 ((TIM_REMAP) == TIM11_GPIO)||\
936 ((TIM_REMAP) == TIM11_HSE))
945 #define TIM_FLAG_Update ((uint16_t)0x0001)
946 #define TIM_FLAG_CC1 ((uint16_t)0x0002)
947 #define TIM_FLAG_CC2 ((uint16_t)0x0004)
948 #define TIM_FLAG_CC3 ((uint16_t)0x0008)
949 #define TIM_FLAG_CC4 ((uint16_t)0x0010)
950 #define TIM_FLAG_COM ((uint16_t)0x0020)
951 #define TIM_FLAG_Trigger ((uint16_t)0x0040)
952 #define TIM_FLAG_Break ((uint16_t)0x0080)
953 #define TIM_FLAG_CC1OF ((uint16_t)0x0200)
954 #define TIM_FLAG_CC2OF ((uint16_t)0x0400)
955 #define TIM_FLAG_CC3OF ((uint16_t)0x0800)
956 #define TIM_FLAG_CC4OF ((uint16_t)0x1000)
957 #define IS_TIM_GET_FLAG(FLAG) (((FLAG) == TIM_FLAG_Update) || \
958 ((FLAG) == TIM_FLAG_CC1) || \
959 ((FLAG) == TIM_FLAG_CC2) || \
960 ((FLAG) == TIM_FLAG_CC3) || \
961 ((FLAG) == TIM_FLAG_CC4) || \
962 ((FLAG) == TIM_FLAG_COM) || \
963 ((FLAG) == TIM_FLAG_Trigger) || \
964 ((FLAG) == TIM_FLAG_Break) || \
965 ((FLAG) == TIM_FLAG_CC1OF) || \
966 ((FLAG) == TIM_FLAG_CC2OF) || \
967 ((FLAG) == TIM_FLAG_CC3OF) || \
968 ((FLAG) == TIM_FLAG_CC4OF))
978 #define IS_TIM_IC_FILTER(ICFILTER) ((ICFILTER) <= 0xF)
987 #define IS_TIM_EXT_FILTER(EXTFILTER) ((EXTFILTER) <= 0xF)
996 #define TIM_DMABurstLength_1Byte TIM_DMABurstLength_1Transfer
997 #define TIM_DMABurstLength_2Bytes TIM_DMABurstLength_2Transfers
998 #define TIM_DMABurstLength_3Bytes TIM_DMABurstLength_3Transfers
999 #define TIM_DMABurstLength_4Bytes TIM_DMABurstLength_4Transfers
1000 #define TIM_DMABurstLength_5Bytes TIM_DMABurstLength_5Transfers
1001 #define TIM_DMABurstLength_6Bytes TIM_DMABurstLength_6Transfers
1002 #define TIM_DMABurstLength_7Bytes TIM_DMABurstLength_7Transfers
1003 #define TIM_DMABurstLength_8Bytes TIM_DMABurstLength_8Transfers
1004 #define TIM_DMABurstLength_9Bytes TIM_DMABurstLength_9Transfers
1005 #define TIM_DMABurstLength_10Bytes TIM_DMABurstLength_10Transfers
1006 #define TIM_DMABurstLength_11Bytes TIM_DMABurstLength_11Transfers
1007 #define TIM_DMABurstLength_12Bytes TIM_DMABurstLength_12Transfers
1008 #define TIM_DMABurstLength_13Bytes TIM_DMABurstLength_13Transfers
1009 #define TIM_DMABurstLength_14Bytes TIM_DMABurstLength_14Transfers
1010 #define TIM_DMABurstLength_15Bytes TIM_DMABurstLength_15Transfers
1011 #define TIM_DMABurstLength_16Bytes TIM_DMABurstLength_16Transfers
1012 #define TIM_DMABurstLength_17Bytes TIM_DMABurstLength_17Transfers
1013 #define TIM_DMABurstLength_18Bytes TIM_DMABurstLength_18Transfers
1029 void TIM_PrescalerConfig(TIM_TypeDef* TIMx, uint16_t Prescaler, uint16_t TIM_PSCReloadMode);
1040 void TIM_Cmd(TIM_TypeDef* TIMx, FunctionalState NewState);
1048 void TIM_SelectOCxM(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_OCMode);
1076 void TIM_CCxCmd(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_CCx);
1077 void TIM_CCxNCmd(TIM_TypeDef* TIMx, uint16_t TIM_Channel, uint16_t TIM_CCxN);
1096 void TIM_SelectCOM(TIM_TypeDef* TIMx, FunctionalState NewState);
1100 void TIM_ITConfig(TIM_TypeDef* TIMx, uint16_t TIM_IT, FunctionalState NewState);
1106 void TIM_DMAConfig(TIM_TypeDef* TIMx, uint16_t TIM_DMABase, uint16_t TIM_DMABurstLength);
1107 void TIM_DMACmd(TIM_TypeDef* TIMx, uint16_t TIM_DMASource, FunctionalState NewState);
1114 uint16_t TIM_ICPolarity, uint16_t ICFilter);
1116 uint16_t ExtTRGFilter);
1118 uint16_t TIM_ExtTRGPolarity, uint16_t ExtTRGFilter);
1125 void TIM_ETRConfig(TIM_TypeDef* TIMx, uint16_t TIM_ExtTRGPrescaler, uint16_t TIM_ExtTRGPolarity,
1126 uint16_t ExtTRGFilter);
1130 uint16_t TIM_IC1Polarity, uint16_t TIM_IC2Polarity);