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

📄 stm32f10x_tim.lst

📁 STM32利用正交编码器实现电机的控制
💻 LST
📖 第 1 页 / 共 5 页
字号:
    848          * Function Name  : TIM_ForcedOC1Config
    849          * Description    : Forces the TIMx output 1 waveform to active or inactive level.
    850          * Input          : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
    851          *                  - TIM_ForcedAction: specifies the forced Action to be set to
    852          *                    the output waveform.
    853          *                    This parameter can be one of the following values:
    854          *                       - TIM_ForcedAction_Active: Force active level on OC1REF
    855          *                       - TIM_ForcedAction_InActive: Force inactive level on
    856          *                         OC1REF.
    857          * Output         : None
    858          * Return         : None
    859          *******************************************************************************/
    860          void TIM_ForcedOC1Config(TIM_TypeDef* TIMx, u16 TIM_ForcedAction)
    861          {
    862            u32 tmpccmr1 = 0;
    863          
    864            /* Check the parameters */
    865            assert(IS_TIM_FORCED_ACTION(TIM_ForcedAction));
    866          
    867            tmpccmr1 = TIMx->CCMR1;
    868          
    869            /* Reset the OCM Bits */
    870            tmpccmr1 &= CCMR_OCM13_Mask;
    871          
    872            /* Configure The Forced output Mode */
    873            tmpccmr1 |= TIM_ForcedAction;
    874          
    875            TIMx->CCMR1 = (u16)tmpccmr1;
    876          }
    877          
    878          /*******************************************************************************
    879          * Function Name  : TIM_ForcedOC2Config
    880          * Description    : Forces the TIMx output 2 waveform to active or inactive level.
    881          * Input          : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
    882          *                  - TIM_ForcedAction: specifies the forced Action to be set to
    883          *                    the output waveform.
    884          *                    This parameter can be one of the following values:
    885          *                       - TIM_ForcedAction_Active: Force active level on OC2REF
    886          *                       - TIM_ForcedAction_InActive: Force inactive level on
    887          *                         OC2REF.
    888          * Output         : None
    889          * Return         : None
    890          *******************************************************************************/
    891          void TIM_ForcedOC2Config(TIM_TypeDef* TIMx, u16 TIM_ForcedAction)
    892          {
    893            u32 tmpccmr1 = 0;
    894          
    895            /* Check the parameters */
    896            assert(IS_TIM_FORCED_ACTION(TIM_ForcedAction));
    897          
    898            tmpccmr1 = TIMx->CCMR1;
    899          
    900            /* Reset the OCM Bits */
    901            tmpccmr1 &= CCMR_OCM24_Mask;
    902          
    903            /* Configure The Forced output Mode */
    904            tmpccmr1 |= (u16)(TIM_ForcedAction << 8);
    905          
    906            TIMx->CCMR1 = (u16)tmpccmr1;
    907          }
    908          
    909          /*******************************************************************************
    910          * Function Name  : TIM_ForcedOC3Config
    911          * Description    : Forces the TIMx output 3 waveform to active or inactive level.
    912          * Input          : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
    913          *                  - TIM_ForcedAction: specifies the forced Action to be set to
    914          *                    the output waveform.
    915          *                    This parameter can be one of the following values:
    916          *                       - TIM_ForcedAction_Active: Force active level on OC3REF
    917          *                       - TIM_ForcedAction_InActive: Force inactive level on
    918          *                         OC3REF.
    919          * Output         : None
    920          * Return         : None
    921          *******************************************************************************/
    922          void TIM_ForcedOC3Config(TIM_TypeDef* TIMx, u16 TIM_ForcedAction)
    923          {
    924            u32 tmpccmr2 = 0;
    925          
    926            /* Check the parameters */
    927            assert(IS_TIM_FORCED_ACTION(TIM_ForcedAction));
    928          
    929            tmpccmr2 = TIMx->CCMR2;
    930          
    931            /* Reset the OCM Bits */
    932            tmpccmr2 &= CCMR_OCM13_Mask;
    933          
    934            /* Configure The Forced output Mode */
    935            tmpccmr2 |= TIM_ForcedAction;
    936          
    937            TIMx->CCMR2 = (u16)tmpccmr2;
    938          }
    939          
    940          /*******************************************************************************
    941          * Function Name  : TIM_ForcedOC4Config
    942          * Description    : Forces the TIMx output 4 waveform to active or inactive level.
    943          * Input          : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
    944          *                  - TIM_ForcedAction: specifies the forced Action to be set to
    945          *                    the output waveform.
    946          *                    This parameter can be one of the following values:
    947          *                       - TIM_ForcedAction_Active: Force active level on OC4REF
    948          *                       - TIM_ForcedAction_InActive: Force inactive level on
    949          *                         OC4REF.
    950          * Output         : None
    951          * Return         : None
    952          *******************************************************************************/
    953          void TIM_ForcedOC4Config(TIM_TypeDef* TIMx, u16 TIM_ForcedAction)
    954          {
    955            u32 tmpccmr2 = 0;
    956          
    957            /* Check the parameters */
    958            assert(IS_TIM_FORCED_ACTION(TIM_ForcedAction));
    959          
    960            tmpccmr2 = TIMx->CCMR2;
    961          
    962            /* Reset the OCM Bits */
    963            tmpccmr2 &= CCMR_OCM24_Mask;
    964          
    965            /* Configure The Forced output Mode */
    966            tmpccmr2 |= (u16)(TIM_ForcedAction << 8);
    967          
    968            TIMx->CCMR2 = (u16)tmpccmr2;
    969          }
    970          
    971          /*******************************************************************************
    972          * Function Name  : TIM_ARRPreloadConfig
    973          * Description    : Enables or disables TIMx peripheral Preload register on ARR.
    974          * Input          : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
    975          *                  - Newstate: new state of the TIMx peripheral Preload register
    976          *                    This parameter can be: ENABLE or DISABLE.
    977          * Output         : None
    978          * Return         : None
    979          *******************************************************************************/
    980          void TIM_ARRPreloadConfig(TIM_TypeDef* TIMx, FunctionalState Newstate)
    981          {
    982            u32 tmpcr1 = 0;
    983            
    984            /* Check the parameters */
    985            assert(IS_FUNCTIONAL_STATE(Newstate));
    986          
    987            tmpcr1 = TIMx->CR1;
    988          
    989            if (Newstate != DISABLE)
    990            {
    991              /* Set the ARR Preload Bit */
    992              tmpcr1 |= CR1_ARPE_Set;
    993            }
    994            else
    995            {
    996              /* Reset the ARR Preload Bit */
    997              tmpcr1 &= CR1_ARPE_Reset;
    998            }
    999          
   1000            TIMx->CR1 = (u16)tmpcr1;
   1001          }
   1002          
   1003          /*******************************************************************************
   1004          * Function Name  : TIM_SelectCCDMA
   1005          * Description    : Selects the TIMx peripheral Capture Compare DMA source.
   1006          * Input          : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
   1007          *                  - Newstate: new state of the Capture Compare DMA source
   1008          *                    This parameter can be: ENABLE or DISABLE.
   1009          * Output         : None
   1010          * Return         : None
   1011          *******************************************************************************/
   1012          void TIM_SelectCCDMA(TIM_TypeDef* TIMx, FunctionalState Newstate)
   1013          {
   1014            u32 tmpcr2 = 0;
   1015          
   1016            /* Check the parameters */
   1017            assert(IS_FUNCTIONAL_STATE(Newstate));
   1018          
   1019            tmpcr2 = TIMx->CR2;
   1020          
   1021            if (Newstate != DISABLE)
   1022            {
   1023              /* Set the CCDS Bit */
   1024              tmpcr2 |= CR2_CCDS_Set;
   1025            }
   1026            else
   1027            {
   1028              /* Reset the CCDS Bit */
   1029              tmpcr2 &= CR2_CCDS_Reset;
   1030            }
   1031          
   1032            TIMx->CR2 = (u16)tmpcr2;
   1033          }
   1034          
   1035          /*******************************************************************************
   1036          * Function Name  : TIM_OC1PreloadConfig
   1037          * Description    : Enables or disables the TIMx peripheral Preload register on CCR1.
   1038          * Input          : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
   1039          *                  - TIM_OCPreload: new state of the TIMx peripheral Preload
   1040          *                    register
   1041          *                    This parameter can be one of the following values:
   1042          *                       - TIM_OCPreload_Enable
   1043          *                       - TIM_OCPreload_Disable
   1044          * Output         : None
   1045          * Return         : None
   1046          *******************************************************************************/
   1047          void TIM_OC1PreloadConfig(TIM_TypeDef* TIMx, u16 TIM_OCPreload)
   1048          {
   1049            u32 tmpccmr1 = 0;
   1050          
   1051            /* Check the parameters */
   1052            assert(IS_TIM_OCPRELOAD_STATE(TIM_OCPreload));
   1053          
   1054            tmpccmr1 = TIMx->CCMR1;
   1055          
   1056            /* Reset the OCPE Bit */
   1057            tmpccmr1 &= CCMR_OC13PE_Mask;
   1058          
   1059            /* Enable or Disable the Output Compare Preload feature */
   1060            tmpccmr1 |= TIM_OCPreload;
   1061          
   1062            TIMx->CCMR1 = (u16)tmpccmr1;
   1063          }
   1064          
   1065          /*******************************************************************************
   1066          * Function Name  : TIM_OC2PreloadConfig
   1067          * Description    : Enables or disables the TIMx peripheral Preload register on CCR2.
   1068          * Input          : - TIMx: where x can be 2, 3 or 4 to select the TIM peripheral.
   1069          *   

⌨️ 快捷键说明

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