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

📄 stm32f10x_tim.lst

📁 完成数据的采集
💻 LST
📖 第 1 页 / 共 5 页
字号:
    422          * Description    : Enables or disables the specified TIM peripheral.
    423          * Input          : - TIMx: where x can be 2, 3 or 4 to select the TIMx peripheral.
    424          *                  - Newstate: new state of the TIMx peripheral.
    425          *                    This parameter can be: ENABLE or DISABLE.
    426          * Output         : None
    427          * Return         : None
    428          *******************************************************************************/
    429          void TIM_Cmd(TIM_TypeDef* TIMx, FunctionalState NewState)
    430          {
    431            /* Check the parameters */
    432            assert_param(IS_FUNCTIONAL_STATE(NewState));
    433            
    434            if (NewState != DISABLE)
    435            {
    436              /* Enable the TIM Counter */
    437              TIMx->CR1 |= CR1_CEN_Set;
    438            }
    439            else
    440            {
    441              /* Disable the TIM Counter */
    442              TIMx->CR1 &= CR1_CEN_Reset;
    443            }
    444          }
    445          
    446          /*******************************************************************************
    447          * Function Name  : TIM_ITConfig
    448          * Description    : Enables or disables the TIMx interrupts.
    449          * Input          : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
    450          *                  - TIM_IT: specifies the TIM interrupts sources to be enabled
    451          *                    or disabled.
    452          *                    This parameter can be any combination of the following values:
    453          *                       - TIM_IT_Update: Timer update Interrupt
    454          *                       - TIM_IT_CC1: Capture Compare 1 Interrupt
    455          *                       - TIM_IT_CC2: Capture Compare 2 Interrupt
    456          *                       - TIM_IT_CC3: Capture Compare 3 Interrupt
    457          *                       - TIM_IT_CC4: Capture Compare 4 Interrupt
    458          *                       - TIM_IT_Trigger: Trigger Interrupt
    459          *                  - Newstate: new state of the specified TIMx interrupts.
    460          *                    This parameter can be: ENABLE or DISABLE.
    461          * Output         : None
    462          * Return         : None
    463          *******************************************************************************/
    464          void TIM_ITConfig(TIM_TypeDef* TIMx, u16 TIM_IT, FunctionalState NewState)
    465          {
    466            /* Check the parameters */
    467            assert_param(IS_TIM_IT(TIM_IT));
    468            assert_param(IS_FUNCTIONAL_STATE(NewState));
    469            
    470            if (NewState != DISABLE)
    471            {
    472              /* Enable the Interrupt sources */
    473              TIMx->DIER |= TIM_IT;
    474            }
    475            else
    476            {
    477              /* Disable the Interrupt sources */
    478              TIMx->DIER &= (u16)(~TIM_IT);
    479            }
    480          }
    481          
    482          /*******************************************************************************
    483          * Function Name  : TIM_DMAConfig
    484          * Description    : Configures the TIMx抯 DMA interface.
    485          * Input          : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
    486          *                  - TIM_DMABase: DMA Base address.
    487          *                    This parameter can be one of the following values:
    488          *                       - TIM_DMABase_CR1, TIM_DMABase_CR2, TIM_DMABase_SMCR,
    489          *                         TIM_DMABase_DIER, TIM_DMABase_SR, TIM_DMABase_EGR,
    490          *                         TIM_DMABase_CCMR1, TIM_DMABase_CCMR2, TIM_DMABase_CCER,
    491          *                         TIM_DMABase_CNT, TIM_DMABase_PSC, TIM_DMABase_ARR,
    492          *                         TIM_DMABase_CCR1, TIM_DMABase_CCR2, TIM_DMABase_CCR3,
    493          *                         TIM_DMABase_CCR4, TIM_DMABase_DCR.
    494          *                  - TIM_DMABurstLength: DMA Burst length.
    495          *                    This parameter can be one value between:
    496          *                    TIM_DMABurstLength_1Byte and TIM_DMABurstLength_18Bytes.
    497          * Output         : None
    498          * Return         : None
    499          *******************************************************************************/
    500          void TIM_DMAConfig(TIM_TypeDef* TIMx, u16 TIM_DMABase, u16 TIM_DMABurstLength)
    501          {
    502            u32 tmpdcr = 0;
    503          
    504            /* Check the parameters */
    505            assert_param(IS_TIM_DMA_BASE(TIM_DMABase));
    506            assert_param(IS_TIM_DMA_LENGTH(TIM_DMABurstLength));
    507            
    508            tmpdcr = TIMx->DCR;
    509          
    510            /* Reset the DBA and the DBL Bits */
    511            tmpdcr &= DCR_DMA_Mask;
    512          
    513            /* Set the DMA Base and the DMA Burst Length */
    514            tmpdcr |= TIM_DMABase | TIM_DMABurstLength;
    515          
    516            TIMx->DCR = (u16)tmpdcr;
    517          }
    518          
    519          /*******************************************************************************
    520          * Function Name  : TIM_DMACmd
    521          * Description    : Enables or disables the TIMx抯 DMA Requests.
    522          * Input          : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
    523          *                  - TIM_DMASources: specifies the DMA Request sources.
    524          *                    This parameter can be any combination of the following values:
    525          *                       - TIM_DMA_CC1: Capture Compare 1 DMA source
    526          *                       - TIM_DMA_CC2: Capture Compare 2 DMA source
    527          *                       - TIM_DMA_CC3: Capture Compare 3 DMA source
    528          *                       - TIM_DMA_CC4: Capture Compare 4 DMA source
    529          *                       - TIM_DMA_Trigger: Trigger DMA source
    530          *                  - Newstate: new state of the DMA Request sources.
    531          *                    This parameter can be: ENABLE or DISABLE.
    532          * Output         : None
    533          * Return         : None
    534          *******************************************************************************/
    535          void TIM_DMACmd(TIM_TypeDef* TIMx, u16 TIM_DMASource, FunctionalState Newstate)
    536          {
    537            u32 tmpdier = 0;
    538            
    539            /* Check the parameters */
    540            assert_param(IS_TIM_DMA_SOURCE(TIM_DMASource));
    541            assert_param(IS_FUNCTIONAL_STATE(Newstate));
    542          
    543            tmpdier = TIMx->DIER;
    544          
    545            if (Newstate != DISABLE)
    546            {
    547              /* Enable the DMA sources */
    548              tmpdier |= TIM_DMASource;
    549            }
    550            else
    551            {
    552              /* Disable the DMA sources */
    553              tmpdier &= (u16)(~TIM_DMASource);
    554            }
    555            TIMx->DIER = (u16)tmpdier;
    556          }
    557          
    558          /*******************************************************************************
    559          * Function Name  : TIM_InternalClockConfig
    560          * Description    : Configures the TIMx interrnal Clock
    561          * Input          : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
    562          * Output         : None
    563          * Return         : None
    564          *******************************************************************************/
    565          void TIM_InternalClockConfig(TIM_TypeDef* TIMx)
    566          {
    567            /* Disable slave mode to clock the prescaler directly with the internal clock */
    568            TIMx->SMCR &=  SMCR_SMS_Mask;
    569          }
    570          /*******************************************************************************
    571          * Function Name  : TIM_ITRxExternalClockConfig
    572          * Description    : Configures the TIMx Internal Trigger as External Clock
    573          * Input          : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
    574          *                  - TIM_ITRSource: Trigger source.
    575          *                    This parameter can be one of the following values:
    576          *                       - TIM_TS_ITR0: Internal Trigger 0
    577          *                       - TIM_TS_ITR1: Internal Trigger 1
    578          *                       - TIM_TS_ITR2: Internal Trigger 2
    579          *                       - TIM_TS_ITR3: Internal Trigger 3
    580          * Output         : None
    581          * Return         : None
    582          *******************************************************************************/
    583          void TIM_ITRxExternalClockConfig(TIM_TypeDef* TIMx, u16 TIM_InputTriggerSource)
    584          {
    585            /* Check the parameters */
    586            assert_param(IS_TIM_INTERNAL_TRIGGER_SELECTION(TIM_InputTriggerSource));
    587          
    588            /* Select the Internal Trigger */
    589            TIM_SelectInputTrigger(TIMx, TIM_InputTriggerSource);
    590          
    591            /* Select the External clock mode1 */
    592            TIMx->SMCR |= TIM_SlaveMode_External1;
    593          }
    594          /*******************************************************************************
    595          * Function Name  : TIM_TIxExternalClockConfig
    596          * Description    : Configures the TIMx Trigger as External Clock
    597          * Input          : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
    598          *                  - TIM_TIxExternalCLKSource: Trigger source.
    599          *                    This parameter can be one of the following values:
    600          *                       - TIM_TIxExternalCLK1Source_TI1ED: TI1 Edge Detector
    601          *                       - TIM_TIxExternalCLK1Source_TI1: Filtered Timer Input 1
    602          *                       - TIM_TIxExternalCLK1Source_TI2: Filtered Timer Input 2
    603          *                  - TIM_ICPolarity: specifies the TIx Polarity.
    604          *                    This parameter can be:
    605          *                       - TIM_ICPolarity_Rising
    606          *                       - TIM_ICPolarity_Falling
    607          *                   - ICFilter : specifies the filter value.
    608          *                     This parameter must be a value between 0x0 and 0xF.
    609          * Output         : None
    610          * Return         : None
    611          *******************************************************************************/
    612          void TIM_TIxExternalClockConfig(TIM_TypeDef* TIMx, u16 TIM_TIxExternalCLKSource,
    613                                          u16 TIM_ICPolarity, u8 ICFilter)
    614          {
    615            /* Check the parameters */
    616            assert_param(IS_TIM_TIXCLK_SOURCE(TIM_TIxExternalCLKSource));
    617            assert_param(IS_TIM_IC_POLARITY(TIM_ICPolarity));
    618            assert_param(IS_TIM_IC_FILTER(ICFilter));
    619          
    620            /* Configure the Timer Input Clock Source */
    621            if (TIM_TIxExternalCLKSource == TIM_TIxExternalCLK1Source_TI2)
    622            {
    623              TI2_Config(TIMx, TIM_ICPolarity, TIM_ICSelection_DirectTI, ICFilter);
    624            }
    625            else
    626            {
    627              TI1_Config(TIMx, TIM_ICPolarity, TIM_ICSelection_DirectTI, ICFilter);
    628            }
    629          
    630            /* Select the Trigger source */
    631            TIM_SelectInputTrigger(TIMx, TIM_TIxExternalCLKSource);
    632          
    633            /* Select the External clock mode1 */
    634            TIMx->SMCR |= TIM_SlaveMode_External1;
    635          }
    636          
    637          /*******************************************************************************
    638          * Function Name  : TIM_ETRClockMode1Config
    639          * Description    : Configures the External clock Mode1
    640          * Input          : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
    641          *                  - TIM_ExtTRGPrescaler: The external Trigger Prescaler.
    642          *                    It can be one of the following values:
    643          *                       - TIM_ExtTRGPSC_OFF
    644          *                       - TIM_ExtTRGPSC_DIV2
    645          *                       - TIM_ExtTRGPSC_DIV4

⌨️ 快捷键说明

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