⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stm32f10x_tim1.lst

📁 完成数据的采集
💻 LST
📖 第 1 页 / 共 5 页
字号:
    631                         TIM1_ICInitStruct->TIM1_ICFilter);
    632          
    633              /* Set the Input Capture Prescaler value */
    634              TIM1_SetIC4Prescaler(TIM1_ICInitStruct->TIM1_ICPrescaler);
    635            }
    636          }
    637          
    638          /*******************************************************************************
    639          * Function Name  : TIM1_PWMIConfig
    640          * Description    : Configures the TIM1 peripheral in PWM Input Mode according 
    641          *                  to the specified parameters in the TIM1_ICInitStruct.
    642          * Input          : - TIM1_ICInitStruct: pointer to a TIM1_ICInitTypeDef structure
    643          *                    that contains the configuration information for the specified
    644          *                    TIM1 peripheral.
    645          * Output         : None
    646          * Return         : None
    647          *******************************************************************************/
    648          void TIM1_PWMIConfig(TIM1_ICInitTypeDef* TIM1_ICInitStruct)
    649          {
    650            u8 ICPolarity = TIM1_ICPolarity_Rising;
    651            u8 ICSelection = TIM1_ICSelection_DirectTI;
    652          
    653            /* Check the parameters */
    654            assert_param(IS_TIM1_PWMI_CHANNEL(TIM1_ICInitStruct->TIM1_Channel));
    655            assert_param(IS_TIM1_IC_POLARITY(TIM1_ICInitStruct->TIM1_ICPolarity));
    656            assert_param(IS_TIM1_IC_SELECTION(TIM1_ICInitStruct->TIM1_ICSelection));
    657            assert_param(IS_TIM1_IC_PRESCALER(TIM1_ICInitStruct->TIM1_ICPrescaler));
    658          
    659            /* Select the Opposite Input Polarity */
    660            if (TIM1_ICInitStruct->TIM1_ICPolarity == TIM1_ICPolarity_Rising)
    661            {
    662              ICPolarity = TIM1_ICPolarity_Falling;
    663            }
    664            else
    665            {
    666              ICPolarity = TIM1_ICPolarity_Rising;
    667            }
    668          
    669            /* Select the Opposite Input */
    670            if (TIM1_ICInitStruct->TIM1_ICSelection == TIM1_ICSelection_DirectTI)
    671            {
    672              ICSelection = TIM1_ICSelection_IndirectTI;
    673            }
    674            else
    675            {
    676              ICSelection = TIM1_ICSelection_DirectTI;
    677            }
    678          
    679            if (TIM1_ICInitStruct->TIM1_Channel == TIM1_Channel_1)
    680            {
    681              /* TI1 Configuration */
    682              TI1_Config(TIM1_ICInitStruct->TIM1_ICPolarity, TIM1_ICInitStruct->TIM1_ICSelection,
    683                         TIM1_ICInitStruct->TIM1_ICFilter);
    684          
    685              /* Set the Input Capture Prescaler value */
    686              TIM1_SetIC1Prescaler(TIM1_ICInitStruct->TIM1_ICPrescaler);
    687          
    688              /* TI2 Configuration */
    689              TI2_Config(ICPolarity, ICSelection, TIM1_ICInitStruct->TIM1_ICFilter);
    690          
    691              /* Set the Input Capture Prescaler value */
    692              TIM1_SetIC2Prescaler(TIM1_ICInitStruct->TIM1_ICPrescaler);
    693            }
    694            else
    695            {	 
    696              /* TI2 Configuration */
    697              TI2_Config(TIM1_ICInitStruct->TIM1_ICPolarity, TIM1_ICInitStruct->TIM1_ICSelection,
    698                         TIM1_ICInitStruct->TIM1_ICFilter);
    699          
    700              /* Set the Input Capture Prescaler value */
    701              TIM1_SetIC2Prescaler(TIM1_ICInitStruct->TIM1_ICPrescaler);
    702          
    703              /* TI1 Configuration */
    704              TI1_Config(ICPolarity, ICSelection, TIM1_ICInitStruct->TIM1_ICFilter);
    705          
    706              /* Set the Input Capture Prescaler value */
    707              TIM1_SetIC1Prescaler(TIM1_ICInitStruct->TIM1_ICPrescaler);
    708            }
    709          }
    710          /*******************************************************************************
    711          * Function Name  : TIM1_OCStructInit
    712          * Description    : Fills each TIM1_OCInitStruct member with its default value.
    713          * Input          : - TIM1_OCInitStruct : pointer to a TIM1_OCInitTypeDef structure
    714          *                    which will be initialized.
    715          * Output         : None
    716          * Return         : None
    717          *******************************************************************************/
    718          void TIM1_OCStructInit(TIM1_OCInitTypeDef* TIM1_OCInitStruct)
    719          {
    720            /* Set the default configuration */
    721            TIM1_OCInitStruct->TIM1_OCMode = TIM1_OCMode_Timing;
    722            TIM1_OCInitStruct->TIM1_OutputState = TIM1_OutputState_Disable;
    723            TIM1_OCInitStruct->TIM1_OutputNState = TIM1_OutputNState_Disable;
    724            TIM1_OCInitStruct->TIM1_Pulse = TIM1_Pulse_Reset_Mask;
    725            TIM1_OCInitStruct->TIM1_OCPolarity = TIM1_OCPolarity_High;
    726            TIM1_OCInitStruct->TIM1_OCNPolarity = TIM1_OCPolarity_High;
    727            TIM1_OCInitStruct->TIM1_OCIdleState = TIM1_OCIdleState_Reset;
    728            TIM1_OCInitStruct->TIM1_OCNIdleState = TIM1_OCNIdleState_Reset;
    729          }
    730          
    731          /*******************************************************************************
    732          * Function Name  : TIM1_ICStructInit
    733          * Description    : Fills each TIM1_ICInitStruct member with its default value.
    734          * Input          : - TIM1_ICInitStruct : pointer to a TIM1_ICInitTypeDef structure
    735          *                    which will be initialized.
    736          * Output         : None
    737          * Return         : None
    738          *******************************************************************************/
    739          void TIM1_ICStructInit(TIM1_ICInitTypeDef* TIM1_ICInitStruct)
    740          {
    741            /* Set the default configuration */
    742            TIM1_ICInitStruct->TIM1_Channel = TIM1_Channel_1;
    743            TIM1_ICInitStruct->TIM1_ICSelection = TIM1_ICSelection_DirectTI;
    744            TIM1_ICInitStruct->TIM1_ICPolarity = TIM1_ICPolarity_Rising;
    745            TIM1_ICInitStruct->TIM1_ICPrescaler = TIM1_ICPSC_DIV1;
    746            TIM1_ICInitStruct->TIM1_ICFilter = TIM1_ICFilter_Mask;
    747          }
    748          
    749          /*******************************************************************************
    750          * Function Name  : TIM1_TimeBaseStructInit
    751          * Description    : Fills each TIM1_TimeBaseInitStruct member with its default value.
    752          * Input          : - TIM1_TimeBaseInitStruct : pointer to a TIM1_TimeBaseInitTypeDef
    753          *                    structure which will be initialized.
    754          * Output         : None
    755          * Return         : None
    756          *******************************************************************************/
    757          void TIM1_TimeBaseStructInit(TIM1_TimeBaseInitTypeDef* TIM1_TimeBaseInitStruct)
    758          {
    759            /* Set the default configuration */
    760            TIM1_TimeBaseInitStruct->TIM1_Period = TIM1_Period_Reset_Mask;
    761            TIM1_TimeBaseInitStruct->TIM1_Prescaler = TIM1_Prescaler_Reset_Mask;
    762            TIM1_TimeBaseInitStruct->TIM1_ClockDivision = TIM1_CKD_DIV1;
    763            TIM1_TimeBaseInitStruct->TIM1_CounterMode = TIM1_CounterMode_Up;
    764            TIM1_TimeBaseInitStruct->TIM1_RepetitionCounter = TIM1_RepetitionCounter_Reset_Mask;
    765          }
    766          
    767          /*******************************************************************************
    768          * Function Name  : TIM1_BDTRStructInit
    769          * Description    : Fills each TIM1_BDTRInitStruct member with its default value.
    770          * Input          : - TIM1_BDTRInitStruct : pointer to a TIM1_BDTRInitTypeDef
    771          *                    structure which will be initialized.
    772          * Output         : None
    773          * Return         : None
    774          *******************************************************************************/
    775          void TIM1_BDTRStructInit(TIM1_BDTRInitTypeDef* TIM1_BDTRInitStruct)
    776          {
    777            /* Set the default configuration */
    778            TIM1_BDTRInitStruct->TIM1_OSSRState = TIM1_OSSRState_Disable;
    779            TIM1_BDTRInitStruct->TIM1_OSSIState = TIM1_OSSIState_Disable;
    780            TIM1_BDTRInitStruct->TIM1_LOCKLevel = TIM1_LOCKLevel_OFF;
    781            TIM1_BDTRInitStruct->TIM1_DeadTime = TIM1_DeadTime_Reset_Mask;
    782            TIM1_BDTRInitStruct->TIM1_Break = TIM1_Break_Disable;
    783            TIM1_BDTRInitStruct->TIM1_BreakPolarity = TIM1_BreakPolarity_Low;
    784            TIM1_BDTRInitStruct->TIM1_AutomaticOutput = TIM1_AutomaticOutput_Disable;
    785          }
    786          
    787          /*******************************************************************************
    788          * Function Name  : TIM1_Cmd
    789          * Description    : Enables or disables the TIM1 peripheral.
    790          * Input          : - Newstate: new state of the TIM1 peripheral.
    791          *                    This parameter can be: ENABLE or DISABLE.
    792          * Output         : None
    793          * Return         : None
    794          *******************************************************************************/
    795          void TIM1_Cmd(FunctionalState NewState)
    796          {
    797            /* Check the parameters */
    798            assert_param(IS_FUNCTIONAL_STATE(NewState));
    799          
    800            /* set or Reset the CEN Bit */
    801            *(vu32 *) CR1_CEN_BB = (u16)NewState;
    802          }
    803          
    804          /*******************************************************************************
    805          * Function Name  : TIM1_CtrlPWMOutputs
    806          * Description    : Enables or disables the TIM1 peripheral Main Outputs.
    807          * Input          : - Newstate: new state of the TIM1 peripheral Main Outputs.
    808          *                    This parameter can be: ENABLE or DISABLE.
    809          * Output         : None
    810          * Return         : None
    811          *******************************************************************************/
    812          void TIM1_CtrlPWMOutputs(FunctionalState Newstate)
    813          {
    814            /* Check the parameters */
    815            assert_param(IS_FUNCTIONAL_STATE(Newstate));
    816          
    817            /* Set or Reset the MOE Bit */
    818            *(vu32 *) BDTR_MOE_BB = (u16)Newstate;
    819          }
    820          
    821          /*******************************************************************************
    822          * Function Name  : TIM1_ITConfig
    823          * Description    : Enables or disables the specified TIM1 interrupts.
    824          * Input          : - TIM1_IT: specifies the TIM1 interrupts sources to be enabled
    825          *                    or disabled.
    826          *                    This parameter can be any combination of the following values:
    827          *                       - TIM1_IT_Update: TIM1 update Interrupt source
    828          *                       - TIM1_IT_CC1: TIM1 Capture Compare 1 Interrupt source
    829          *                       - TIM1_IT_CC2: TIM1 Capture Compare 2 Interrupt source
    830          *                       - TIM1_IT_CC3: TIM1 Capture Compare 3 Interrupt source
    831          *                       - TIM1_IT_CC4: TIM1 Capture Compare 4 Interrupt source
    832          *                       - TIM1_IT_CCUpdate: TIM1 Capture Compare Update Interrupt
    833          *                         source
    834          *                       - TIM1_IT_Trigger: TIM1 Trigger Interrupt source
    835          *                       - TIM1_IT_Break: TIM1 Break Interrupt source
    836          *                  - Newstate: new state of the TIM1 interrupts.
    837          *                    This parameter can be: ENABLE or DISABLE.
    838          * Output         : None
    839          * Return         : None
    840          *******************************************************************************/
    841          void TIM1_ITConfig(u16 TIM1_IT, FunctionalState NewState)
    842          {
    843            /* Check the parameters */
    844            assert_param(IS_TIM1_IT(TIM1_IT));
    845            assert_param(IS_FUNCTIONAL_STATE(NewState));
    846          
    847            if (NewState == ENABLE)
    848            {
    849              /* Enable the Interrupt sources */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -