📄 stm32f10x_tim1.lst
字号:
613 /* TI2 Configuration */
614 TI2_Config(TIM1_ICInitStruct->TIM1_ICPolarity,
615 TIM1_ICInitStruct->TIM1_ICSelection,
616 TIM1_ICInitStruct->TIM1_ICFilter);
617
618 /* Set the Input Capture Prescaler value */
619 TIM1_SetIC2Prescaler(TIM1_ICInitStruct->TIM1_ICPrescaler);
620 }
621 else if (TIM1_ICInitStruct->TIM1_Channel == TIM1_Channel_3)
622 {
623 /* TI3 Configuration */
624 TI3_Config(TIM1_ICInitStruct->TIM1_ICPolarity,
625 TIM1_ICInitStruct->TIM1_ICSelection,
626 TIM1_ICInitStruct->TIM1_ICFilter);
627
628 /* Set the Input Capture Prescaler value */
629 TIM1_SetIC3Prescaler(TIM1_ICInitStruct->TIM1_ICPrescaler);
630 }
631 else
632 {
633 /* TI4 Configuration */
634 TI4_Config(TIM1_ICInitStruct->TIM1_ICPolarity,
635 TIM1_ICInitStruct->TIM1_ICSelection,
636 TIM1_ICInitStruct->TIM1_ICFilter);
637
638 /* Set the Input Capture Prescaler value */
639 TIM1_SetIC4Prescaler(TIM1_ICInitStruct->TIM1_ICPrescaler);
640 }
641 }
642
643 /*******************************************************************************
644 * Function Name : TIM1_PWMIConfig
645 * Description : Configures the TIM1 peripheral in PWM Input Mode according
646 * to the specified parameters in the TIM1_ICInitStruct.
647 * Input : - TIM1_ICInitStruct: pointer to a TIM1_ICInitTypeDef structure
648 * that contains the configuration information for the specified
649 * TIM1 peripheral.
650 * Output : None
651 * Return : None
652 *******************************************************************************/
653 void TIM1_PWMIConfig(TIM1_ICInitTypeDef* TIM1_ICInitStruct)
654 {
655 u8 ICPolarity = TIM1_ICPolarity_Rising;
656 u8 ICSelection = TIM1_ICSelection_DirectTI;
657
658 /* Check the parameters */
659 assert(IS_TIM1_PWMI_CHANNEL(TIM1_ICInitStruct->TIM1_Channel));
660 assert(IS_TIM1_IC_POLARITY(TIM1_ICInitStruct->TIM1_ICPolarity));
661 assert(IS_TIM1_IC_SELECTION(TIM1_ICInitStruct->TIM1_ICSelection));
662 assert(IS_TIM1_IC_PRESCALER(TIM1_ICInitStruct->TIM1_ICPrescaler));
663
664 /* Select the Opposite Input Polarity */
665 if (TIM1_ICInitStruct->TIM1_ICPolarity == TIM1_ICPolarity_Rising)
666 {
667 ICPolarity = TIM1_ICPolarity_Falling;
668 }
669 else
670 {
671 ICPolarity = TIM1_ICPolarity_Rising;
672 }
673
674 /* Select the Opposite Input */
675 if (TIM1_ICInitStruct->TIM1_ICSelection == TIM1_ICSelection_DirectTI)
676 {
677 ICSelection = TIM1_ICSelection_IndirectTI;
678 }
679 else
680 {
681 ICSelection = TIM1_ICSelection_DirectTI;
682 }
683
684 if (TIM1_ICInitStruct->TIM1_Channel == TIM1_Channel_1)
685 {
686 /* TI1 Configuration */
687 TI1_Config(TIM1_ICInitStruct->TIM1_ICPolarity, TIM1_ICInitStruct->TIM1_ICSelection,
688 TIM1_ICInitStruct->TIM1_ICFilter);
689
690 /* Set the Input Capture Prescaler value */
691 TIM1_SetIC1Prescaler(TIM1_ICInitStruct->TIM1_ICPrescaler);
692
693 /* TI2 Configuration */
694 TI2_Config(ICPolarity, ICSelection, TIM1_ICInitStruct->TIM1_ICFilter);
695
696 /* Set the Input Capture Prescaler value */
697 TIM1_SetIC2Prescaler(TIM1_ICInitStruct->TIM1_ICPrescaler);
698 }
699 else
700 {
701 /* TI2 Configuration */
702 TI2_Config(TIM1_ICInitStruct->TIM1_ICPolarity, TIM1_ICInitStruct->TIM1_ICSelection,
703 TIM1_ICInitStruct->TIM1_ICFilter);
704
705 /* Set the Input Capture Prescaler value */
706 TIM1_SetIC2Prescaler(TIM1_ICInitStruct->TIM1_ICPrescaler);
707
708 /* TI1 Configuration */
709 TI1_Config(ICPolarity, ICSelection, TIM1_ICInitStruct->TIM1_ICFilter);
710
711 /* Set the Input Capture Prescaler value */
712 TIM1_SetIC1Prescaler(TIM1_ICInitStruct->TIM1_ICPrescaler);
713 }
714 }
715 /*******************************************************************************
716 * Function Name : TIM1_OCStructInit
717 * Description : Fills each TIM1_OCInitStruct member with its default value.
718 * Input : - TIM1_OCInitStruct : pointer to a TIM1_OCInitTypeDef structure
719 * which will be initialized.
720 * Output : None
721 * Return : None
722 *******************************************************************************/
723 void TIM1_OCStructInit(TIM1_OCInitTypeDef* TIM1_OCInitStruct)
724 {
725 /* Set the default configuration */
726 TIM1_OCInitStruct->TIM1_OCMode = TIM1_OCMode_Timing;
727 TIM1_OCInitStruct->TIM1_OutputState = TIM1_OutputState_Disable;
728 TIM1_OCInitStruct->TIM1_OutputNState = TIM1_OutputNState_Disable;
729 TIM1_OCInitStruct->TIM1_Pulse = TIM1_Pulse_Reset_Mask;
730 TIM1_OCInitStruct->TIM1_OCPolarity = TIM1_OCPolarity_High;
731 TIM1_OCInitStruct->TIM1_OCNPolarity = TIM1_OCPolarity_High;
732 TIM1_OCInitStruct->TIM1_OCIdleState = TIM1_OCIdleState_Reset;
733 TIM1_OCInitStruct->TIM1_OCNIdleState = TIM1_OCNIdleState_Reset;
734 }
735
736 /*******************************************************************************
737 * Function Name : TIM1_ICStructInit
738 * Description : Fills each TIM1_ICInitStruct member with its default value.
739 * Input : - TIM1_ICInitStruct : pointer to a TIM1_ICInitTypeDef structure
740 * which will be initialized.
741 * Output : None
742 * Return : None
743 *******************************************************************************/
744 void TIM1_ICStructInit(TIM1_ICInitTypeDef* TIM1_ICInitStruct)
745 {
746 /* Set the default configuration */
747 TIM1_ICInitStruct->TIM1_Channel = TIM1_Channel_1;
748 TIM1_ICInitStruct->TIM1_ICSelection = TIM1_ICSelection_DirectTI;
749 TIM1_ICInitStruct->TIM1_ICPolarity = TIM1_ICPolarity_Rising;
750 TIM1_ICInitStruct->TIM1_ICPrescaler = TIM1_ICPSC_DIV1;
751 TIM1_ICInitStruct->TIM1_ICFilter = TIM1_ICFilter_Mask;
752 }
753
754 /*******************************************************************************
755 * Function Name : TIM1_TimeBaseStructInit
756 * Description : Fills each TIM1_TimeBaseInitStruct member with its default value.
757 * Input : - TIM1_TimeBaseInitStruct : pointer to a TIM1_TimeBaseInitTypeDef
758 * structure which will be initialized.
759 * Output : None
760 * Return : None
761 *******************************************************************************/
762 void TIM1_TimeBaseStructInit(TIM1_TimeBaseInitTypeDef* TIM1_TimeBaseInitStruct)
763 {
764 /* Set the default configuration */
765 TIM1_TimeBaseInitStruct->TIM1_Period = TIM1_Period_Reset_Mask;
766 TIM1_TimeBaseInitStruct->TIM1_Prescaler = TIM1_Prescaler_Reset_Mask;
767 TIM1_TimeBaseInitStruct->TIM1_ClockDivision = TIM1_CKD_DIV1;
768 TIM1_TimeBaseInitStruct->TIM1_CounterMode = TIM1_CounterMode_Up;
769 TIM1_TimeBaseInitStruct->TIM1_RepetitionCounter = TIM1_RepetitionCounter_Reset_Mask;
770 }
771
772 /*******************************************************************************
773 * Function Name : TIM1_BDTRStructInit
774 * Description : Fills each TIM1_BDTRInitStruct member with its default value.
775 * Input : - TIM1_BDTRInitStruct : pointer to a TIM1_BDTRInitTypeDef
776 * structure which will be initialized.
777 * Output : None
778 * Return : None
779 *******************************************************************************/
780 void TIM1_BDTRStructInit(TIM1_BDTRInitTypeDef* TIM1_BDTRInitStruct)
781 {
782 /* Set the default configuration */
783 TIM1_BDTRInitStruct->TIM1_OSSRState = TIM1_OSSRState_Disable;
784 TIM1_BDTRInitStruct->TIM1_OSSIState = TIM1_OSSIState_Disable;
785 TIM1_BDTRInitStruct->TIM1_LOCKLevel = TIM1_LOCKLevel_OFF;
786 TIM1_BDTRInitStruct->TIM1_DeadTime = TIM1_DeadTime_Reset_Mask;
787 TIM1_BDTRInitStruct->TIM1_Break = TIM1_Break_Disable;
788 TIM1_BDTRInitStruct->TIM1_BreakPolarity = TIM1_BreakPolarity_Low;
789 TIM1_BDTRInitStruct->TIM1_AutomaticOutput = TIM1_AutomaticOutput_Disable;
790 }
791
792 /*******************************************************************************
793 * Function Name : TIM1_Cmd
794 * Description : Enables or disables the TIM1 peripheral.
795 * Input : - Newstate: new state of the TIM1 peripheral.
796 * This parameter can be: ENABLE or DISABLE.
797 * Output : None
798 * Return : None
799 *******************************************************************************/
800 void TIM1_Cmd(FunctionalState NewState)
801 {
802 /* Check the parameters */
803 assert(IS_FUNCTIONAL_STATE(NewState));
804
805 /* set or Reset the CEN Bit */
806 *(vu32 *) CR1_CEN_BB = (u16)NewState;
807 }
808
809 /*******************************************************************************
810 * Function Name : TIM1_CtrlPWMOutputs
811 * Description : Enables or disables the TIM1 peripheral Main Outputs.
812 * Input : - Newstate: new state of the TIM1 peripheral Main Outputs.
813 * This parameter can be: ENABLE or DISABLE.
814 * Output : None
815 * Return : None
816 *******************************************************************************/
817 void TIM1_CtrlPWMOutputs(FunctionalState Newstate)
818 {
819 /* Check the parameters */
820 assert(IS_FUNCTIONAL_STATE(Newstate));
821
822 /* Set or Reset the MOE Bit */
823 *(vu32 *) BDTR_MOE_BB = (u16)Newstate;
824 }
825
826 /*******************************************************************************
827 * Function Name : TIM1_ITConfig
828 * Description : Enables or disables the specified TIM1 interrupts.
829 * Input : - TIM1_IT: specifies the TIM1 interrupts sources to be enabled
830 * or disabled.
831 * This parameter can be any combination of the following values:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -