STM32L443xx HAL User Manual
stm32l4xx_ll_tim.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32l4xx_ll_tim.c
00004   * @author  MCD Application Team
00005   * @brief   TIM LL module driver.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * Copyright (c) 2017 STMicroelectronics.
00010   * All rights reserved.
00011   *
00012   * This software is licensed under terms that can be found in the LICENSE file
00013   * in the root directory of this software component.
00014   * If no LICENSE file comes with this software, it is provided AS-IS.
00015   *
00016   ******************************************************************************
00017   */
00018 #if defined(USE_FULL_LL_DRIVER)
00019 
00020 /* Includes ------------------------------------------------------------------*/
00021 #include "stm32l4xx_ll_tim.h"
00022 #include "stm32l4xx_ll_bus.h"
00023 
00024 #ifdef  USE_FULL_ASSERT
00025 #include "stm32_assert.h"
00026 #else
00027 #define assert_param(expr) ((void)0U)
00028 #endif /* USE_FULL_ASSERT */
00029 
00030 /** @addtogroup STM32L4xx_LL_Driver
00031   * @{
00032   */
00033 
00034 #if defined (TIM1) || defined (TIM8) || defined (TIM2) || defined (TIM3) ||  defined (TIM4) || defined (TIM5) || defined (TIM15) || defined (TIM16) || defined (TIM17) || defined (TIM6) || defined (TIM7)
00035 
00036 /** @addtogroup TIM_LL
00037   * @{
00038   */
00039 
00040 /* Private types -------------------------------------------------------------*/
00041 /* Private variables ---------------------------------------------------------*/
00042 /* Private constants ---------------------------------------------------------*/
00043 /* Private macros ------------------------------------------------------------*/
00044 /** @addtogroup TIM_LL_Private_Macros
00045   * @{
00046   */
00047 #define IS_LL_TIM_COUNTERMODE(__VALUE__) (((__VALUE__) == LL_TIM_COUNTERMODE_UP) \
00048                                           || ((__VALUE__) == LL_TIM_COUNTERMODE_DOWN) \
00049                                           || ((__VALUE__) == LL_TIM_COUNTERMODE_CENTER_UP) \
00050                                           || ((__VALUE__) == LL_TIM_COUNTERMODE_CENTER_DOWN) \
00051                                           || ((__VALUE__) == LL_TIM_COUNTERMODE_CENTER_UP_DOWN))
00052 
00053 #define IS_LL_TIM_CLOCKDIVISION(__VALUE__) (((__VALUE__) == LL_TIM_CLOCKDIVISION_DIV1) \
00054                                             || ((__VALUE__) == LL_TIM_CLOCKDIVISION_DIV2) \
00055                                             || ((__VALUE__) == LL_TIM_CLOCKDIVISION_DIV4))
00056 
00057 #define IS_LL_TIM_OCMODE(__VALUE__) (((__VALUE__) == LL_TIM_OCMODE_FROZEN) \
00058                                      || ((__VALUE__) == LL_TIM_OCMODE_ACTIVE) \
00059                                      || ((__VALUE__) == LL_TIM_OCMODE_INACTIVE) \
00060                                      || ((__VALUE__) == LL_TIM_OCMODE_TOGGLE) \
00061                                      || ((__VALUE__) == LL_TIM_OCMODE_FORCED_INACTIVE) \
00062                                      || ((__VALUE__) == LL_TIM_OCMODE_FORCED_ACTIVE) \
00063                                      || ((__VALUE__) == LL_TIM_OCMODE_PWM1) \
00064                                      || ((__VALUE__) == LL_TIM_OCMODE_PWM2) \
00065                                      || ((__VALUE__) == LL_TIM_OCMODE_RETRIG_OPM1) \
00066                                      || ((__VALUE__) == LL_TIM_OCMODE_RETRIG_OPM2) \
00067                                      || ((__VALUE__) == LL_TIM_OCMODE_COMBINED_PWM1) \
00068                                      || ((__VALUE__) == LL_TIM_OCMODE_COMBINED_PWM2) \
00069                                      || ((__VALUE__) == LL_TIM_OCMODE_ASSYMETRIC_PWM1) \
00070                                      || ((__VALUE__) == LL_TIM_OCMODE_ASSYMETRIC_PWM2))
00071 
00072 #define IS_LL_TIM_OCSTATE(__VALUE__) (((__VALUE__) == LL_TIM_OCSTATE_DISABLE) \
00073                                       || ((__VALUE__) == LL_TIM_OCSTATE_ENABLE))
00074 
00075 #define IS_LL_TIM_OCPOLARITY(__VALUE__) (((__VALUE__) == LL_TIM_OCPOLARITY_HIGH) \
00076                                          || ((__VALUE__) == LL_TIM_OCPOLARITY_LOW))
00077 
00078 #define IS_LL_TIM_OCIDLESTATE(__VALUE__) (((__VALUE__) == LL_TIM_OCIDLESTATE_LOW) \
00079                                           || ((__VALUE__) == LL_TIM_OCIDLESTATE_HIGH))
00080 
00081 #define IS_LL_TIM_ACTIVEINPUT(__VALUE__) (((__VALUE__) == LL_TIM_ACTIVEINPUT_DIRECTTI) \
00082                                           || ((__VALUE__) == LL_TIM_ACTIVEINPUT_INDIRECTTI) \
00083                                           || ((__VALUE__) == LL_TIM_ACTIVEINPUT_TRC))
00084 
00085 #define IS_LL_TIM_ICPSC(__VALUE__) (((__VALUE__) == LL_TIM_ICPSC_DIV1) \
00086                                     || ((__VALUE__) == LL_TIM_ICPSC_DIV2) \
00087                                     || ((__VALUE__) == LL_TIM_ICPSC_DIV4) \
00088                                     || ((__VALUE__) == LL_TIM_ICPSC_DIV8))
00089 
00090 #define IS_LL_TIM_IC_FILTER(__VALUE__) (((__VALUE__) == LL_TIM_IC_FILTER_FDIV1) \
00091                                         || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV1_N2) \
00092                                         || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV1_N4) \
00093                                         || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV1_N8) \
00094                                         || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV2_N6) \
00095                                         || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV2_N8) \
00096                                         || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV4_N6) \
00097                                         || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV4_N8) \
00098                                         || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV8_N6) \
00099                                         || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV8_N8) \
00100                                         || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV16_N5) \
00101                                         || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV16_N6) \
00102                                         || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV16_N8) \
00103                                         || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV32_N5) \
00104                                         || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV32_N6) \
00105                                         || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV32_N8))
00106 
00107 #define IS_LL_TIM_IC_POLARITY(__VALUE__) (((__VALUE__) == LL_TIM_IC_POLARITY_RISING) \
00108                                           || ((__VALUE__) == LL_TIM_IC_POLARITY_FALLING) \
00109                                           || ((__VALUE__) == LL_TIM_IC_POLARITY_BOTHEDGE))
00110 
00111 #define IS_LL_TIM_ENCODERMODE(__VALUE__) (((__VALUE__) == LL_TIM_ENCODERMODE_X2_TI1) \
00112                                           || ((__VALUE__) == LL_TIM_ENCODERMODE_X2_TI2) \
00113                                           || ((__VALUE__) == LL_TIM_ENCODERMODE_X4_TI12))
00114 
00115 #define IS_LL_TIM_IC_POLARITY_ENCODER(__VALUE__) (((__VALUE__) == LL_TIM_IC_POLARITY_RISING) \
00116                                                   || ((__VALUE__) == LL_TIM_IC_POLARITY_FALLING))
00117 
00118 #define IS_LL_TIM_OSSR_STATE(__VALUE__) (((__VALUE__) == LL_TIM_OSSR_DISABLE) \
00119                                          || ((__VALUE__) == LL_TIM_OSSR_ENABLE))
00120 
00121 #define IS_LL_TIM_OSSI_STATE(__VALUE__) (((__VALUE__) == LL_TIM_OSSI_DISABLE) \
00122                                          || ((__VALUE__) == LL_TIM_OSSI_ENABLE))
00123 
00124 #define IS_LL_TIM_LOCK_LEVEL(__VALUE__) (((__VALUE__) == LL_TIM_LOCKLEVEL_OFF) \
00125                                          || ((__VALUE__) == LL_TIM_LOCKLEVEL_1)   \
00126                                          || ((__VALUE__) == LL_TIM_LOCKLEVEL_2)   \
00127                                          || ((__VALUE__) == LL_TIM_LOCKLEVEL_3))
00128 
00129 #define IS_LL_TIM_BREAK_STATE(__VALUE__) (((__VALUE__) == LL_TIM_BREAK_DISABLE) \
00130                                           || ((__VALUE__) == LL_TIM_BREAK_ENABLE))
00131 
00132 #define IS_LL_TIM_BREAK_POLARITY(__VALUE__) (((__VALUE__) == LL_TIM_BREAK_POLARITY_LOW) \
00133                                              || ((__VALUE__) == LL_TIM_BREAK_POLARITY_HIGH))
00134 
00135 #define IS_LL_TIM_BREAK_FILTER(__VALUE__) (((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV1)     \
00136                                            || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV1_N2)  \
00137                                            || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV1_N4)  \
00138                                            || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV1_N8)  \
00139                                            || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV2_N6)  \
00140                                            || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV2_N8)  \
00141                                            || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV4_N6)  \
00142                                            || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV4_N8)  \
00143                                            || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV8_N6)  \
00144                                            || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV8_N8)  \
00145                                            || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV16_N5) \
00146                                            || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV16_N6) \
00147                                            || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV16_N8) \
00148                                            || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV32_N5) \
00149                                            || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV32_N6) \
00150                                            || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV32_N8))
00151 
00152 #define IS_LL_TIM_BREAK2_STATE(__VALUE__) (((__VALUE__) == LL_TIM_BREAK2_DISABLE) \
00153                                            || ((__VALUE__) == LL_TIM_BREAK2_ENABLE))
00154 
00155 #define IS_LL_TIM_BREAK2_POLARITY(__VALUE__) (((__VALUE__) == LL_TIM_BREAK2_POLARITY_LOW) \
00156                                               || ((__VALUE__) == LL_TIM_BREAK2_POLARITY_HIGH))
00157 
00158 #define IS_LL_TIM_BREAK2_FILTER(__VALUE__) (((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV1)    \
00159                                             || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV1_N2)  \
00160                                             || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV1_N4)  \
00161                                             || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV1_N8)  \
00162                                             || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV2_N6)  \
00163                                             || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV2_N8)  \
00164                                             || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV4_N6)  \
00165                                             || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV4_N8)  \
00166                                             || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV8_N6)  \
00167                                             || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV8_N8)  \
00168                                             || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV16_N5) \
00169                                             || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV16_N6) \
00170                                             || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV16_N8) \
00171                                             || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV32_N5) \
00172                                             || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV32_N6) \
00173                                             || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV32_N8))
00174 
00175 #define IS_LL_TIM_AUTOMATIC_OUTPUT_STATE(__VALUE__) (((__VALUE__) == LL_TIM_AUTOMATICOUTPUT_DISABLE) \
00176                                                      || ((__VALUE__) == LL_TIM_AUTOMATICOUTPUT_ENABLE))
00177 /**
00178   * @}
00179   */
00180 
00181 
00182 /* Private function prototypes -----------------------------------------------*/
00183 /** @defgroup TIM_LL_Private_Functions TIM Private Functions
00184   * @{
00185   */
00186 static ErrorStatus OC1Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct);
00187 static ErrorStatus OC2Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct);
00188 static ErrorStatus OC3Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct);
00189 static ErrorStatus OC4Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct);
00190 static ErrorStatus OC5Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct);
00191 static ErrorStatus OC6Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct);
00192 static ErrorStatus IC1Config(TIM_TypeDef *TIMx, LL_TIM_IC_InitTypeDef *TIM_ICInitStruct);
00193 static ErrorStatus IC2Config(TIM_TypeDef *TIMx, LL_TIM_IC_InitTypeDef *TIM_ICInitStruct);
00194 static ErrorStatus IC3Config(TIM_TypeDef *TIMx, LL_TIM_IC_InitTypeDef *TIM_ICInitStruct);
00195 static ErrorStatus IC4Config(TIM_TypeDef *TIMx, LL_TIM_IC_InitTypeDef *TIM_ICInitStruct);
00196 /**
00197   * @}
00198   */
00199 
00200 /* Exported functions --------------------------------------------------------*/
00201 /** @addtogroup TIM_LL_Exported_Functions
00202   * @{
00203   */
00204 
00205 /** @addtogroup TIM_LL_EF_Init
00206   * @{
00207   */
00208 
00209 /**
00210   * @brief  Set TIMx registers to their reset values.
00211   * @param  TIMx Timer instance
00212   * @retval An ErrorStatus enumeration value:
00213   *          - SUCCESS: TIMx registers are de-initialized
00214   *          - ERROR: invalid TIMx instance
00215   */
00216 ErrorStatus LL_TIM_DeInit(TIM_TypeDef *TIMx)
00217 {
00218   ErrorStatus result = SUCCESS;
00219 
00220   /* Check the parameters */
00221   assert_param(IS_TIM_INSTANCE(TIMx));
00222 
00223   if (TIMx == TIM1)
00224   {
00225     LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_TIM1);
00226     LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_TIM1);
00227   }
00228   else if (TIMx == TIM2)
00229   {
00230     LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_TIM2);
00231     LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_TIM2);
00232   }
00233 #if defined(TIM3)
00234   else if (TIMx == TIM3)
00235   {
00236     LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_TIM3);
00237     LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_TIM3);
00238   }
00239 #endif /* TIM3 */
00240 #if defined(TIM4)
00241   else if (TIMx == TIM4)
00242   {
00243     LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_TIM4);
00244     LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_TIM4);
00245   }
00246 #endif /* TIM4 */
00247 #if defined(TIM5)
00248   else if (TIMx == TIM5)
00249   {
00250     LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_TIM5);
00251     LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_TIM5);
00252   }
00253 #endif /* TIM5 */
00254   else if (TIMx == TIM6)
00255   {
00256     LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_TIM6);
00257     LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_TIM6);
00258   }
00259 #if defined (TIM7)
00260   else if (TIMx == TIM7)
00261   {
00262     LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_TIM7);
00263     LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_TIM7);
00264   }
00265 #endif /* TIM7 */
00266 #if defined(TIM8)
00267   else if (TIMx == TIM8)
00268   {
00269     LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_TIM8);
00270     LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_TIM8);
00271   }
00272 #endif /* TIM8 */
00273   else if (TIMx == TIM15)
00274   {
00275     LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_TIM15);
00276     LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_TIM15);
00277   }
00278   else if (TIMx == TIM16)
00279   {
00280     LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_TIM16);
00281     LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_TIM16);
00282   }
00283 #if defined(TIM17)
00284   else if (TIMx == TIM17)
00285   {
00286     LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_TIM17);
00287     LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_TIM17);
00288   }
00289 #endif /* TIM17 */
00290   else
00291   {
00292     result = ERROR;
00293   }
00294 
00295   return result;
00296 }
00297 
00298 /**
00299   * @brief  Set the fields of the time base unit configuration data structure
00300   *         to their default values.
00301   * @param  TIM_InitStruct pointer to a @ref LL_TIM_InitTypeDef structure (time base unit configuration data structure)
00302   * @retval None
00303   */
00304 void LL_TIM_StructInit(LL_TIM_InitTypeDef *TIM_InitStruct)
00305 {
00306   /* Set the default configuration */
00307   TIM_InitStruct->Prescaler         = (uint16_t)0x0000;
00308   TIM_InitStruct->CounterMode       = LL_TIM_COUNTERMODE_UP;
00309   TIM_InitStruct->Autoreload        = 0xFFFFFFFFU;
00310   TIM_InitStruct->ClockDivision     = LL_TIM_CLOCKDIVISION_DIV1;
00311   TIM_InitStruct->RepetitionCounter = 0x00000000U;
00312 }
00313 
00314 /**
00315   * @brief  Configure the TIMx time base unit.
00316   * @param  TIMx Timer Instance
00317   * @param  TIM_InitStruct pointer to a @ref LL_TIM_InitTypeDef structure
00318   *         (TIMx time base unit configuration data structure)
00319   * @retval An ErrorStatus enumeration value:
00320   *          - SUCCESS: TIMx registers are de-initialized
00321   *          - ERROR: not applicable
00322   */
00323 ErrorStatus LL_TIM_Init(TIM_TypeDef *TIMx, LL_TIM_InitTypeDef *TIM_InitStruct)
00324 {
00325   uint32_t tmpcr1;
00326 
00327   /* Check the parameters */
00328   assert_param(IS_TIM_INSTANCE(TIMx));
00329   assert_param(IS_LL_TIM_COUNTERMODE(TIM_InitStruct->CounterMode));
00330   assert_param(IS_LL_TIM_CLOCKDIVISION(TIM_InitStruct->ClockDivision));
00331 
00332   tmpcr1 = LL_TIM_ReadReg(TIMx, CR1);
00333 
00334   if (IS_TIM_COUNTER_MODE_SELECT_INSTANCE(TIMx))
00335   {
00336     /* Select the Counter Mode */
00337     MODIFY_REG(tmpcr1, (TIM_CR1_DIR | TIM_CR1_CMS), TIM_InitStruct->CounterMode);
00338   }
00339 
00340   if (IS_TIM_CLOCK_DIVISION_INSTANCE(TIMx))
00341   {
00342     /* Set the clock division */
00343     MODIFY_REG(tmpcr1, TIM_CR1_CKD, TIM_InitStruct->ClockDivision);
00344   }
00345 
00346   /* Write to TIMx CR1 */
00347   LL_TIM_WriteReg(TIMx, CR1, tmpcr1);
00348 
00349   /* Set the Autoreload value */
00350   LL_TIM_SetAutoReload(TIMx, TIM_InitStruct->Autoreload);
00351 
00352   /* Set the Prescaler value */
00353   LL_TIM_SetPrescaler(TIMx, TIM_InitStruct->Prescaler);
00354 
00355   if (IS_TIM_REPETITION_COUNTER_INSTANCE(TIMx))
00356   {
00357     /* Set the Repetition Counter value */
00358     LL_TIM_SetRepetitionCounter(TIMx, TIM_InitStruct->RepetitionCounter);
00359   }
00360 
00361   /* Generate an update event to reload the Prescaler
00362      and the repetition counter value (if applicable) immediately */
00363   LL_TIM_GenerateEvent_UPDATE(TIMx);
00364 
00365   return SUCCESS;
00366 }
00367 
00368 /**
00369   * @brief  Set the fields of the TIMx output channel configuration data
00370   *         structure to their default values.
00371   * @param  TIM_OC_InitStruct pointer to a @ref LL_TIM_OC_InitTypeDef structure
00372   *         (the output channel configuration data structure)
00373   * @retval None
00374   */
00375 void LL_TIM_OC_StructInit(LL_TIM_OC_InitTypeDef *TIM_OC_InitStruct)
00376 {
00377   /* Set the default configuration */
00378   TIM_OC_InitStruct->OCMode       = LL_TIM_OCMODE_FROZEN;
00379   TIM_OC_InitStruct->OCState      = LL_TIM_OCSTATE_DISABLE;
00380   TIM_OC_InitStruct->OCNState     = LL_TIM_OCSTATE_DISABLE;
00381   TIM_OC_InitStruct->CompareValue = 0x00000000U;
00382   TIM_OC_InitStruct->OCPolarity   = LL_TIM_OCPOLARITY_HIGH;
00383   TIM_OC_InitStruct->OCNPolarity  = LL_TIM_OCPOLARITY_HIGH;
00384   TIM_OC_InitStruct->OCIdleState  = LL_TIM_OCIDLESTATE_LOW;
00385   TIM_OC_InitStruct->OCNIdleState = LL_TIM_OCIDLESTATE_LOW;
00386 }
00387 
00388 /**
00389   * @brief  Configure the TIMx output channel.
00390   * @param  TIMx Timer Instance
00391   * @param  Channel This parameter can be one of the following values:
00392   *         @arg @ref LL_TIM_CHANNEL_CH1
00393   *         @arg @ref LL_TIM_CHANNEL_CH2
00394   *         @arg @ref LL_TIM_CHANNEL_CH3
00395   *         @arg @ref LL_TIM_CHANNEL_CH4
00396   *         @arg @ref LL_TIM_CHANNEL_CH5
00397   *         @arg @ref LL_TIM_CHANNEL_CH6
00398   * @param  TIM_OC_InitStruct pointer to a @ref LL_TIM_OC_InitTypeDef structure (TIMx output channel configuration
00399   *         data structure)
00400   * @retval An ErrorStatus enumeration value:
00401   *          - SUCCESS: TIMx output channel is initialized
00402   *          - ERROR: TIMx output channel is not initialized
00403   */
00404 ErrorStatus LL_TIM_OC_Init(TIM_TypeDef *TIMx, uint32_t Channel, LL_TIM_OC_InitTypeDef *TIM_OC_InitStruct)
00405 {
00406   ErrorStatus result = ERROR;
00407 
00408   switch (Channel)
00409   {
00410     case LL_TIM_CHANNEL_CH1:
00411       result = OC1Config(TIMx, TIM_OC_InitStruct);
00412       break;
00413     case LL_TIM_CHANNEL_CH2:
00414       result = OC2Config(TIMx, TIM_OC_InitStruct);
00415       break;
00416     case LL_TIM_CHANNEL_CH3:
00417       result = OC3Config(TIMx, TIM_OC_InitStruct);
00418       break;
00419     case LL_TIM_CHANNEL_CH4:
00420       result = OC4Config(TIMx, TIM_OC_InitStruct);
00421       break;
00422     case LL_TIM_CHANNEL_CH5:
00423       result = OC5Config(TIMx, TIM_OC_InitStruct);
00424       break;
00425     case LL_TIM_CHANNEL_CH6:
00426       result = OC6Config(TIMx, TIM_OC_InitStruct);
00427       break;
00428     default:
00429       break;
00430   }
00431 
00432   return result;
00433 }
00434 
00435 /**
00436   * @brief  Set the fields of the TIMx input channel configuration data
00437   *         structure to their default values.
00438   * @param  TIM_ICInitStruct pointer to a @ref LL_TIM_IC_InitTypeDef structure (the input channel configuration
00439   *         data structure)
00440   * @retval None
00441   */
00442 void LL_TIM_IC_StructInit(LL_TIM_IC_InitTypeDef *TIM_ICInitStruct)
00443 {
00444   /* Set the default configuration */
00445   TIM_ICInitStruct->ICPolarity    = LL_TIM_IC_POLARITY_RISING;
00446   TIM_ICInitStruct->ICActiveInput = LL_TIM_ACTIVEINPUT_DIRECTTI;
00447   TIM_ICInitStruct->ICPrescaler   = LL_TIM_ICPSC_DIV1;
00448   TIM_ICInitStruct->ICFilter      = LL_TIM_IC_FILTER_FDIV1;
00449 }
00450 
00451 /**
00452   * @brief  Configure the TIMx input channel.
00453   * @param  TIMx Timer Instance
00454   * @param  Channel This parameter can be one of the following values:
00455   *         @arg @ref LL_TIM_CHANNEL_CH1
00456   *         @arg @ref LL_TIM_CHANNEL_CH2
00457   *         @arg @ref LL_TIM_CHANNEL_CH3
00458   *         @arg @ref LL_TIM_CHANNEL_CH4
00459   * @param  TIM_IC_InitStruct pointer to a @ref LL_TIM_IC_InitTypeDef structure (TIMx input channel configuration data
00460   *         structure)
00461   * @retval An ErrorStatus enumeration value:
00462   *          - SUCCESS: TIMx output channel is initialized
00463   *          - ERROR: TIMx output channel is not initialized
00464   */
00465 ErrorStatus LL_TIM_IC_Init(TIM_TypeDef *TIMx, uint32_t Channel, LL_TIM_IC_InitTypeDef *TIM_IC_InitStruct)
00466 {
00467   ErrorStatus result = ERROR;
00468 
00469   switch (Channel)
00470   {
00471     case LL_TIM_CHANNEL_CH1:
00472       result = IC1Config(TIMx, TIM_IC_InitStruct);
00473       break;
00474     case LL_TIM_CHANNEL_CH2:
00475       result = IC2Config(TIMx, TIM_IC_InitStruct);
00476       break;
00477     case LL_TIM_CHANNEL_CH3:
00478       result = IC3Config(TIMx, TIM_IC_InitStruct);
00479       break;
00480     case LL_TIM_CHANNEL_CH4:
00481       result = IC4Config(TIMx, TIM_IC_InitStruct);
00482       break;
00483     default:
00484       break;
00485   }
00486 
00487   return result;
00488 }
00489 
00490 /**
00491   * @brief  Fills each TIM_EncoderInitStruct field with its default value
00492   * @param  TIM_EncoderInitStruct pointer to a @ref LL_TIM_ENCODER_InitTypeDef structure (encoder interface
00493   *         configuration data structure)
00494   * @retval None
00495   */
00496 void LL_TIM_ENCODER_StructInit(LL_TIM_ENCODER_InitTypeDef *TIM_EncoderInitStruct)
00497 {
00498   /* Set the default configuration */
00499   TIM_EncoderInitStruct->EncoderMode    = LL_TIM_ENCODERMODE_X2_TI1;
00500   TIM_EncoderInitStruct->IC1Polarity    = LL_TIM_IC_POLARITY_RISING;
00501   TIM_EncoderInitStruct->IC1ActiveInput = LL_TIM_ACTIVEINPUT_DIRECTTI;
00502   TIM_EncoderInitStruct->IC1Prescaler   = LL_TIM_ICPSC_DIV1;
00503   TIM_EncoderInitStruct->IC1Filter      = LL_TIM_IC_FILTER_FDIV1;
00504   TIM_EncoderInitStruct->IC2Polarity    = LL_TIM_IC_POLARITY_RISING;
00505   TIM_EncoderInitStruct->IC2ActiveInput = LL_TIM_ACTIVEINPUT_DIRECTTI;
00506   TIM_EncoderInitStruct->IC2Prescaler   = LL_TIM_ICPSC_DIV1;
00507   TIM_EncoderInitStruct->IC2Filter      = LL_TIM_IC_FILTER_FDIV1;
00508 }
00509 
00510 /**
00511   * @brief  Configure the encoder interface of the timer instance.
00512   * @param  TIMx Timer Instance
00513   * @param  TIM_EncoderInitStruct pointer to a @ref LL_TIM_ENCODER_InitTypeDef structure (TIMx encoder interface
00514   *         configuration data structure)
00515   * @retval An ErrorStatus enumeration value:
00516   *          - SUCCESS: TIMx registers are de-initialized
00517   *          - ERROR: not applicable
00518   */
00519 ErrorStatus LL_TIM_ENCODER_Init(TIM_TypeDef *TIMx, LL_TIM_ENCODER_InitTypeDef *TIM_EncoderInitStruct)
00520 {
00521   uint32_t tmpccmr1;
00522   uint32_t tmpccer;
00523 
00524   /* Check the parameters */
00525   assert_param(IS_TIM_ENCODER_INTERFACE_INSTANCE(TIMx));
00526   assert_param(IS_LL_TIM_ENCODERMODE(TIM_EncoderInitStruct->EncoderMode));
00527   assert_param(IS_LL_TIM_IC_POLARITY_ENCODER(TIM_EncoderInitStruct->IC1Polarity));
00528   assert_param(IS_LL_TIM_ACTIVEINPUT(TIM_EncoderInitStruct->IC1ActiveInput));
00529   assert_param(IS_LL_TIM_ICPSC(TIM_EncoderInitStruct->IC1Prescaler));
00530   assert_param(IS_LL_TIM_IC_FILTER(TIM_EncoderInitStruct->IC1Filter));
00531   assert_param(IS_LL_TIM_IC_POLARITY_ENCODER(TIM_EncoderInitStruct->IC2Polarity));
00532   assert_param(IS_LL_TIM_ACTIVEINPUT(TIM_EncoderInitStruct->IC2ActiveInput));
00533   assert_param(IS_LL_TIM_ICPSC(TIM_EncoderInitStruct->IC2Prescaler));
00534   assert_param(IS_LL_TIM_IC_FILTER(TIM_EncoderInitStruct->IC2Filter));
00535 
00536   /* Disable the CC1 and CC2: Reset the CC1E and CC2E Bits */
00537   TIMx->CCER &= (uint32_t)~(TIM_CCER_CC1E | TIM_CCER_CC2E);
00538 
00539   /* Get the TIMx CCMR1 register value */
00540   tmpccmr1 = LL_TIM_ReadReg(TIMx, CCMR1);
00541 
00542   /* Get the TIMx CCER register value */
00543   tmpccer = LL_TIM_ReadReg(TIMx, CCER);
00544 
00545   /* Configure TI1 */
00546   tmpccmr1 &= (uint32_t)~(TIM_CCMR1_CC1S | TIM_CCMR1_IC1F  | TIM_CCMR1_IC1PSC);
00547   tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC1ActiveInput >> 16U);
00548   tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC1Filter >> 16U);
00549   tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC1Prescaler >> 16U);
00550 
00551   /* Configure TI2 */
00552   tmpccmr1 &= (uint32_t)~(TIM_CCMR1_CC2S | TIM_CCMR1_IC2F  | TIM_CCMR1_IC2PSC);
00553   tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC2ActiveInput >> 8U);
00554   tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC2Filter >> 8U);
00555   tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC2Prescaler >> 8U);
00556 
00557   /* Set TI1 and TI2 polarity and enable TI1 and TI2 */
00558   tmpccer &= (uint32_t)~(TIM_CCER_CC1P | TIM_CCER_CC1NP | TIM_CCER_CC2P | TIM_CCER_CC2NP);
00559   tmpccer |= (uint32_t)(TIM_EncoderInitStruct->IC1Polarity);
00560   tmpccer |= (uint32_t)(TIM_EncoderInitStruct->IC2Polarity << 4U);
00561   tmpccer |= (uint32_t)(TIM_CCER_CC1E | TIM_CCER_CC2E);
00562 
00563   /* Set encoder mode */
00564   LL_TIM_SetEncoderMode(TIMx, TIM_EncoderInitStruct->EncoderMode);
00565 
00566   /* Write to TIMx CCMR1 */
00567   LL_TIM_WriteReg(TIMx, CCMR1, tmpccmr1);
00568 
00569   /* Write to TIMx CCER */
00570   LL_TIM_WriteReg(TIMx, CCER, tmpccer);
00571 
00572   return SUCCESS;
00573 }
00574 
00575 /**
00576   * @brief  Set the fields of the TIMx Hall sensor interface configuration data
00577   *         structure to their default values.
00578   * @param  TIM_HallSensorInitStruct pointer to a @ref LL_TIM_HALLSENSOR_InitTypeDef structure (HALL sensor interface
00579   *         configuration data structure)
00580   * @retval None
00581   */
00582 void LL_TIM_HALLSENSOR_StructInit(LL_TIM_HALLSENSOR_InitTypeDef *TIM_HallSensorInitStruct)
00583 {
00584   /* Set the default configuration */
00585   TIM_HallSensorInitStruct->IC1Polarity       = LL_TIM_IC_POLARITY_RISING;
00586   TIM_HallSensorInitStruct->IC1Prescaler      = LL_TIM_ICPSC_DIV1;
00587   TIM_HallSensorInitStruct->IC1Filter         = LL_TIM_IC_FILTER_FDIV1;
00588   TIM_HallSensorInitStruct->CommutationDelay  = 0U;
00589 }
00590 
00591 /**
00592   * @brief  Configure the Hall sensor interface of the timer instance.
00593   * @note TIMx CH1, CH2 and CH3 inputs connected through a XOR
00594   *       to the TI1 input channel
00595   * @note TIMx slave mode controller is configured in reset mode.
00596           Selected internal trigger is TI1F_ED.
00597   * @note Channel 1 is configured as input, IC1 is mapped on TRC.
00598   * @note Captured value stored in TIMx_CCR1 correspond to the time elapsed
00599   *       between 2 changes on the inputs. It gives information about motor speed.
00600   * @note Channel 2 is configured in output PWM 2 mode.
00601   * @note Compare value stored in TIMx_CCR2 corresponds to the commutation delay.
00602   * @note OC2REF is selected as trigger output on TRGO.
00603   * @note LL_TIM_IC_POLARITY_BOTHEDGE must not be used for TI1 when it is used
00604   *       when TIMx operates in Hall sensor interface mode.
00605   * @param  TIMx Timer Instance
00606   * @param  TIM_HallSensorInitStruct pointer to a @ref LL_TIM_HALLSENSOR_InitTypeDef structure (TIMx HALL sensor
00607   *         interface configuration data structure)
00608   * @retval An ErrorStatus enumeration value:
00609   *          - SUCCESS: TIMx registers are de-initialized
00610   *          - ERROR: not applicable
00611   */
00612 ErrorStatus LL_TIM_HALLSENSOR_Init(TIM_TypeDef *TIMx, LL_TIM_HALLSENSOR_InitTypeDef *TIM_HallSensorInitStruct)
00613 {
00614   uint32_t tmpcr2;
00615   uint32_t tmpccmr1;
00616   uint32_t tmpccer;
00617   uint32_t tmpsmcr;
00618 
00619   /* Check the parameters */
00620   assert_param(IS_TIM_HALL_SENSOR_INTERFACE_INSTANCE(TIMx));
00621   assert_param(IS_LL_TIM_IC_POLARITY_ENCODER(TIM_HallSensorInitStruct->IC1Polarity));
00622   assert_param(IS_LL_TIM_ICPSC(TIM_HallSensorInitStruct->IC1Prescaler));
00623   assert_param(IS_LL_TIM_IC_FILTER(TIM_HallSensorInitStruct->IC1Filter));
00624 
00625   /* Disable the CC1 and CC2: Reset the CC1E and CC2E Bits */
00626   TIMx->CCER &= (uint32_t)~(TIM_CCER_CC1E | TIM_CCER_CC2E);
00627 
00628   /* Get the TIMx CR2 register value */
00629   tmpcr2 = LL_TIM_ReadReg(TIMx, CR2);
00630 
00631   /* Get the TIMx CCMR1 register value */
00632   tmpccmr1 = LL_TIM_ReadReg(TIMx, CCMR1);
00633 
00634   /* Get the TIMx CCER register value */
00635   tmpccer = LL_TIM_ReadReg(TIMx, CCER);
00636 
00637   /* Get the TIMx SMCR register value */
00638   tmpsmcr = LL_TIM_ReadReg(TIMx, SMCR);
00639 
00640   /* Connect TIMx_CH1, CH2 and CH3 pins to the TI1 input */
00641   tmpcr2 |= TIM_CR2_TI1S;
00642 
00643   /* OC2REF signal is used as trigger output (TRGO) */
00644   tmpcr2 |= LL_TIM_TRGO_OC2REF;
00645 
00646   /* Configure the slave mode controller */
00647   tmpsmcr &= (uint32_t)~(TIM_SMCR_TS | TIM_SMCR_SMS);
00648   tmpsmcr |= LL_TIM_TS_TI1F_ED;
00649   tmpsmcr |= LL_TIM_SLAVEMODE_RESET;
00650 
00651   /* Configure input channel 1 */
00652   tmpccmr1 &= (uint32_t)~(TIM_CCMR1_CC1S | TIM_CCMR1_IC1F  | TIM_CCMR1_IC1PSC);
00653   tmpccmr1 |= (uint32_t)(LL_TIM_ACTIVEINPUT_TRC >> 16U);
00654   tmpccmr1 |= (uint32_t)(TIM_HallSensorInitStruct->IC1Filter >> 16U);
00655   tmpccmr1 |= (uint32_t)(TIM_HallSensorInitStruct->IC1Prescaler >> 16U);
00656 
00657   /* Configure input channel 2 */
00658   tmpccmr1 &= (uint32_t)~(TIM_CCMR1_OC2M | TIM_CCMR1_OC2FE  | TIM_CCMR1_OC2PE  | TIM_CCMR1_OC2CE);
00659   tmpccmr1 |= (uint32_t)(LL_TIM_OCMODE_PWM2 << 8U);
00660 
00661   /* Set Channel 1 polarity and enable Channel 1 and Channel2 */
00662   tmpccer &= (uint32_t)~(TIM_CCER_CC1P | TIM_CCER_CC1NP | TIM_CCER_CC2P | TIM_CCER_CC2NP);
00663   tmpccer |= (uint32_t)(TIM_HallSensorInitStruct->IC1Polarity);
00664   tmpccer |= (uint32_t)(TIM_CCER_CC1E | TIM_CCER_CC2E);
00665 
00666   /* Write to TIMx CR2 */
00667   LL_TIM_WriteReg(TIMx, CR2, tmpcr2);
00668 
00669   /* Write to TIMx SMCR */
00670   LL_TIM_WriteReg(TIMx, SMCR, tmpsmcr);
00671 
00672   /* Write to TIMx CCMR1 */
00673   LL_TIM_WriteReg(TIMx, CCMR1, tmpccmr1);
00674 
00675   /* Write to TIMx CCER */
00676   LL_TIM_WriteReg(TIMx, CCER, tmpccer);
00677 
00678   /* Write to TIMx CCR2 */
00679   LL_TIM_OC_SetCompareCH2(TIMx, TIM_HallSensorInitStruct->CommutationDelay);
00680 
00681   return SUCCESS;
00682 }
00683 
00684 /**
00685   * @brief  Set the fields of the Break and Dead Time configuration data structure
00686   *         to their default values.
00687   * @param  TIM_BDTRInitStruct pointer to a @ref LL_TIM_BDTR_InitTypeDef structure (Break and Dead Time configuration
00688   *         data structure)
00689   * @retval None
00690   */
00691 void LL_TIM_BDTR_StructInit(LL_TIM_BDTR_InitTypeDef *TIM_BDTRInitStruct)
00692 {
00693   /* Set the default configuration */
00694   TIM_BDTRInitStruct->OSSRState       = LL_TIM_OSSR_DISABLE;
00695   TIM_BDTRInitStruct->OSSIState       = LL_TIM_OSSI_DISABLE;
00696   TIM_BDTRInitStruct->LockLevel       = LL_TIM_LOCKLEVEL_OFF;
00697   TIM_BDTRInitStruct->DeadTime        = (uint8_t)0x00;
00698   TIM_BDTRInitStruct->BreakState      = LL_TIM_BREAK_DISABLE;
00699   TIM_BDTRInitStruct->BreakPolarity   = LL_TIM_BREAK_POLARITY_LOW;
00700   TIM_BDTRInitStruct->BreakFilter     = LL_TIM_BREAK_FILTER_FDIV1;
00701   TIM_BDTRInitStruct->Break2State     = LL_TIM_BREAK2_DISABLE;
00702   TIM_BDTRInitStruct->Break2Polarity  = LL_TIM_BREAK2_POLARITY_LOW;
00703   TIM_BDTRInitStruct->Break2Filter    = LL_TIM_BREAK2_FILTER_FDIV1;
00704   TIM_BDTRInitStruct->AutomaticOutput = LL_TIM_AUTOMATICOUTPUT_DISABLE;
00705 }
00706 
00707 /**
00708   * @brief  Configure the Break and Dead Time feature of the timer instance.
00709   * @note As the bits BK2P, BK2E, BK2F[3:0], BKF[3:0], AOE, BKP, BKE, OSSI, OSSR
00710   *  and DTG[7:0] can be write-locked depending on the LOCK configuration, it
00711   *  can be necessary to configure all of them during the first write access to
00712   *  the TIMx_BDTR register.
00713   * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not
00714   *       a timer instance provides a break input.
00715   * @note Macro IS_TIM_BKIN2_INSTANCE(TIMx) can be used to check whether or not
00716   *       a timer instance provides a second break input.
00717   * @param  TIMx Timer Instance
00718   * @param  TIM_BDTRInitStruct pointer to a @ref LL_TIM_BDTR_InitTypeDef structure (Break and Dead Time configuration
00719   *         data structure)
00720   * @retval An ErrorStatus enumeration value:
00721   *          - SUCCESS: Break and Dead Time is initialized
00722   *          - ERROR: not applicable
00723   */
00724 ErrorStatus LL_TIM_BDTR_Init(TIM_TypeDef *TIMx, LL_TIM_BDTR_InitTypeDef *TIM_BDTRInitStruct)
00725 {
00726   uint32_t tmpbdtr = 0;
00727 
00728   /* Check the parameters */
00729   assert_param(IS_TIM_BREAK_INSTANCE(TIMx));
00730   assert_param(IS_LL_TIM_OSSR_STATE(TIM_BDTRInitStruct->OSSRState));
00731   assert_param(IS_LL_TIM_OSSI_STATE(TIM_BDTRInitStruct->OSSIState));
00732   assert_param(IS_LL_TIM_LOCK_LEVEL(TIM_BDTRInitStruct->LockLevel));
00733   assert_param(IS_LL_TIM_BREAK_STATE(TIM_BDTRInitStruct->BreakState));
00734   assert_param(IS_LL_TIM_BREAK_POLARITY(TIM_BDTRInitStruct->BreakPolarity));
00735   assert_param(IS_LL_TIM_AUTOMATIC_OUTPUT_STATE(TIM_BDTRInitStruct->AutomaticOutput));
00736 
00737   /* Set the Lock level, the Break enable Bit and the Polarity, the OSSR State,
00738   the OSSI State, the dead time value and the Automatic Output Enable Bit */
00739 
00740   /* Set the BDTR bits */
00741   MODIFY_REG(tmpbdtr, TIM_BDTR_DTG, TIM_BDTRInitStruct->DeadTime);
00742   MODIFY_REG(tmpbdtr, TIM_BDTR_LOCK, TIM_BDTRInitStruct->LockLevel);
00743   MODIFY_REG(tmpbdtr, TIM_BDTR_OSSI, TIM_BDTRInitStruct->OSSIState);
00744   MODIFY_REG(tmpbdtr, TIM_BDTR_OSSR, TIM_BDTRInitStruct->OSSRState);
00745   MODIFY_REG(tmpbdtr, TIM_BDTR_BKE, TIM_BDTRInitStruct->BreakState);
00746   MODIFY_REG(tmpbdtr, TIM_BDTR_BKP, TIM_BDTRInitStruct->BreakPolarity);
00747   MODIFY_REG(tmpbdtr, TIM_BDTR_AOE, TIM_BDTRInitStruct->AutomaticOutput);
00748   MODIFY_REG(tmpbdtr, TIM_BDTR_MOE, TIM_BDTRInitStruct->AutomaticOutput);
00749   if (IS_TIM_ADVANCED_INSTANCE(TIMx))
00750   {
00751     assert_param(IS_LL_TIM_BREAK_FILTER(TIM_BDTRInitStruct->BreakFilter));
00752     MODIFY_REG(tmpbdtr, TIM_BDTR_BKF, TIM_BDTRInitStruct->BreakFilter);
00753   }
00754 
00755   if (IS_TIM_BKIN2_INSTANCE(TIMx))
00756   {
00757     assert_param(IS_LL_TIM_BREAK2_STATE(TIM_BDTRInitStruct->Break2State));
00758     assert_param(IS_LL_TIM_BREAK2_POLARITY(TIM_BDTRInitStruct->Break2Polarity));
00759     assert_param(IS_LL_TIM_BREAK2_FILTER(TIM_BDTRInitStruct->Break2Filter));
00760 
00761     /* Set the BREAK2 input related BDTR bit-fields */
00762     MODIFY_REG(tmpbdtr, TIM_BDTR_BK2F, (TIM_BDTRInitStruct->Break2Filter));
00763     MODIFY_REG(tmpbdtr, TIM_BDTR_BK2E, TIM_BDTRInitStruct->Break2State);
00764     MODIFY_REG(tmpbdtr, TIM_BDTR_BK2P, TIM_BDTRInitStruct->Break2Polarity);
00765   }
00766 
00767   /* Set TIMx_BDTR */
00768   LL_TIM_WriteReg(TIMx, BDTR, tmpbdtr);
00769 
00770   return SUCCESS;
00771 }
00772 /**
00773   * @}
00774   */
00775 
00776 /**
00777   * @}
00778   */
00779 
00780 /** @addtogroup TIM_LL_Private_Functions TIM Private Functions
00781   *  @brief   Private functions
00782   * @{
00783   */
00784 /**
00785   * @brief  Configure the TIMx output channel 1.
00786   * @param  TIMx Timer Instance
00787   * @param  TIM_OCInitStruct pointer to the the TIMx output channel 1 configuration data structure
00788   * @retval An ErrorStatus enumeration value:
00789   *          - SUCCESS: TIMx registers are de-initialized
00790   *          - ERROR: not applicable
00791   */
00792 static ErrorStatus OC1Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct)
00793 {
00794   uint32_t tmpccmr1;
00795   uint32_t tmpccer;
00796   uint32_t tmpcr2;
00797 
00798   /* Check the parameters */
00799   assert_param(IS_TIM_CC1_INSTANCE(TIMx));
00800   assert_param(IS_LL_TIM_OCMODE(TIM_OCInitStruct->OCMode));
00801   assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCState));
00802   assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCPolarity));
00803   assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCNState));
00804   assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCNPolarity));
00805 
00806   /* Disable the Channel 1: Reset the CC1E Bit */
00807   CLEAR_BIT(TIMx->CCER, TIM_CCER_CC1E);
00808 
00809   /* Get the TIMx CCER register value */
00810   tmpccer = LL_TIM_ReadReg(TIMx, CCER);
00811 
00812   /* Get the TIMx CR2 register value */
00813   tmpcr2 = LL_TIM_ReadReg(TIMx, CR2);
00814 
00815   /* Get the TIMx CCMR1 register value */
00816   tmpccmr1 = LL_TIM_ReadReg(TIMx, CCMR1);
00817 
00818   /* Reset Capture/Compare selection Bits */
00819   CLEAR_BIT(tmpccmr1, TIM_CCMR1_CC1S);
00820 
00821   /* Set the Output Compare Mode */
00822   MODIFY_REG(tmpccmr1, TIM_CCMR1_OC1M, TIM_OCInitStruct->OCMode);
00823 
00824   /* Set the Output Compare Polarity */
00825   MODIFY_REG(tmpccer, TIM_CCER_CC1P, TIM_OCInitStruct->OCPolarity);
00826 
00827   /* Set the Output State */
00828   MODIFY_REG(tmpccer, TIM_CCER_CC1E, TIM_OCInitStruct->OCState);
00829 
00830   if (IS_TIM_BREAK_INSTANCE(TIMx))
00831   {
00832     assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCNIdleState));
00833     assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCIdleState));
00834 
00835     /* Set the complementary output Polarity */
00836     MODIFY_REG(tmpccer, TIM_CCER_CC1NP, TIM_OCInitStruct->OCNPolarity << 2U);
00837 
00838     /* Set the complementary output State */
00839     MODIFY_REG(tmpccer, TIM_CCER_CC1NE, TIM_OCInitStruct->OCNState << 2U);
00840 
00841     /* Set the Output Idle state */
00842     MODIFY_REG(tmpcr2, TIM_CR2_OIS1, TIM_OCInitStruct->OCIdleState);
00843 
00844     /* Set the complementary output Idle state */
00845     MODIFY_REG(tmpcr2, TIM_CR2_OIS1N, TIM_OCInitStruct->OCNIdleState << 1U);
00846   }
00847 
00848   /* Write to TIMx CR2 */
00849   LL_TIM_WriteReg(TIMx, CR2, tmpcr2);
00850 
00851   /* Write to TIMx CCMR1 */
00852   LL_TIM_WriteReg(TIMx, CCMR1, tmpccmr1);
00853 
00854   /* Set the Capture Compare Register value */
00855   LL_TIM_OC_SetCompareCH1(TIMx, TIM_OCInitStruct->CompareValue);
00856 
00857   /* Write to TIMx CCER */
00858   LL_TIM_WriteReg(TIMx, CCER, tmpccer);
00859 
00860   return SUCCESS;
00861 }
00862 
00863 /**
00864   * @brief  Configure the TIMx output channel 2.
00865   * @param  TIMx Timer Instance
00866   * @param  TIM_OCInitStruct pointer to the the TIMx output channel 2 configuration data structure
00867   * @retval An ErrorStatus enumeration value:
00868   *          - SUCCESS: TIMx registers are de-initialized
00869   *          - ERROR: not applicable
00870   */
00871 static ErrorStatus OC2Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct)
00872 {
00873   uint32_t tmpccmr1;
00874   uint32_t tmpccer;
00875   uint32_t tmpcr2;
00876 
00877   /* Check the parameters */
00878   assert_param(IS_TIM_CC2_INSTANCE(TIMx));
00879   assert_param(IS_LL_TIM_OCMODE(TIM_OCInitStruct->OCMode));
00880   assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCState));
00881   assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCPolarity));
00882   assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCNState));
00883   assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCNPolarity));
00884 
00885   /* Disable the Channel 2: Reset the CC2E Bit */
00886   CLEAR_BIT(TIMx->CCER, TIM_CCER_CC2E);
00887 
00888   /* Get the TIMx CCER register value */
00889   tmpccer =  LL_TIM_ReadReg(TIMx, CCER);
00890 
00891   /* Get the TIMx CR2 register value */
00892   tmpcr2 = LL_TIM_ReadReg(TIMx, CR2);
00893 
00894   /* Get the TIMx CCMR1 register value */
00895   tmpccmr1 = LL_TIM_ReadReg(TIMx, CCMR1);
00896 
00897   /* Reset Capture/Compare selection Bits */
00898   CLEAR_BIT(tmpccmr1, TIM_CCMR1_CC2S);
00899 
00900   /* Select the Output Compare Mode */
00901   MODIFY_REG(tmpccmr1, TIM_CCMR1_OC2M, TIM_OCInitStruct->OCMode << 8U);
00902 
00903   /* Set the Output Compare Polarity */
00904   MODIFY_REG(tmpccer, TIM_CCER_CC2P, TIM_OCInitStruct->OCPolarity << 4U);
00905 
00906   /* Set the Output State */
00907   MODIFY_REG(tmpccer, TIM_CCER_CC2E, TIM_OCInitStruct->OCState << 4U);
00908 
00909   if (IS_TIM_BREAK_INSTANCE(TIMx))
00910   {
00911     assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCNIdleState));
00912     assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCIdleState));
00913 
00914     /* Set the complementary output Polarity */
00915     MODIFY_REG(tmpccer, TIM_CCER_CC2NP, TIM_OCInitStruct->OCNPolarity << 6U);
00916 
00917     /* Set the complementary output State */
00918     MODIFY_REG(tmpccer, TIM_CCER_CC2NE, TIM_OCInitStruct->OCNState << 6U);
00919 
00920     /* Set the Output Idle state */
00921     MODIFY_REG(tmpcr2, TIM_CR2_OIS2, TIM_OCInitStruct->OCIdleState << 2U);
00922 
00923     /* Set the complementary output Idle state */
00924     MODIFY_REG(tmpcr2, TIM_CR2_OIS2N, TIM_OCInitStruct->OCNIdleState << 3U);
00925   }
00926 
00927   /* Write to TIMx CR2 */
00928   LL_TIM_WriteReg(TIMx, CR2, tmpcr2);
00929 
00930   /* Write to TIMx CCMR1 */
00931   LL_TIM_WriteReg(TIMx, CCMR1, tmpccmr1);
00932 
00933   /* Set the Capture Compare Register value */
00934   LL_TIM_OC_SetCompareCH2(TIMx, TIM_OCInitStruct->CompareValue);
00935 
00936   /* Write to TIMx CCER */
00937   LL_TIM_WriteReg(TIMx, CCER, tmpccer);
00938 
00939   return SUCCESS;
00940 }
00941 
00942 /**
00943   * @brief  Configure the TIMx output channel 3.
00944   * @param  TIMx Timer Instance
00945   * @param  TIM_OCInitStruct pointer to the the TIMx output channel 3 configuration data structure
00946   * @retval An ErrorStatus enumeration value:
00947   *          - SUCCESS: TIMx registers are de-initialized
00948   *          - ERROR: not applicable
00949   */
00950 static ErrorStatus OC3Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct)
00951 {
00952   uint32_t tmpccmr2;
00953   uint32_t tmpccer;
00954   uint32_t tmpcr2;
00955 
00956   /* Check the parameters */
00957   assert_param(IS_TIM_CC3_INSTANCE(TIMx));
00958   assert_param(IS_LL_TIM_OCMODE(TIM_OCInitStruct->OCMode));
00959   assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCState));
00960   assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCPolarity));
00961   assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCNState));
00962   assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCNPolarity));
00963 
00964   /* Disable the Channel 3: Reset the CC3E Bit */
00965   CLEAR_BIT(TIMx->CCER, TIM_CCER_CC3E);
00966 
00967   /* Get the TIMx CCER register value */
00968   tmpccer =  LL_TIM_ReadReg(TIMx, CCER);
00969 
00970   /* Get the TIMx CR2 register value */
00971   tmpcr2 = LL_TIM_ReadReg(TIMx, CR2);
00972 
00973   /* Get the TIMx CCMR2 register value */
00974   tmpccmr2 = LL_TIM_ReadReg(TIMx, CCMR2);
00975 
00976   /* Reset Capture/Compare selection Bits */
00977   CLEAR_BIT(tmpccmr2, TIM_CCMR2_CC3S);
00978 
00979   /* Select the Output Compare Mode */
00980   MODIFY_REG(tmpccmr2, TIM_CCMR2_OC3M, TIM_OCInitStruct->OCMode);
00981 
00982   /* Set the Output Compare Polarity */
00983   MODIFY_REG(tmpccer, TIM_CCER_CC3P, TIM_OCInitStruct->OCPolarity << 8U);
00984 
00985   /* Set the Output State */
00986   MODIFY_REG(tmpccer, TIM_CCER_CC3E, TIM_OCInitStruct->OCState << 8U);
00987 
00988   if (IS_TIM_BREAK_INSTANCE(TIMx))
00989   {
00990     assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCNIdleState));
00991     assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCIdleState));
00992 
00993     /* Set the complementary output Polarity */
00994     MODIFY_REG(tmpccer, TIM_CCER_CC3NP, TIM_OCInitStruct->OCNPolarity << 10U);
00995 
00996     /* Set the complementary output State */
00997     MODIFY_REG(tmpccer, TIM_CCER_CC3NE, TIM_OCInitStruct->OCNState << 10U);
00998 
00999     /* Set the Output Idle state */
01000     MODIFY_REG(tmpcr2, TIM_CR2_OIS3, TIM_OCInitStruct->OCIdleState << 4U);
01001 
01002     /* Set the complementary output Idle state */
01003     MODIFY_REG(tmpcr2, TIM_CR2_OIS3N, TIM_OCInitStruct->OCNIdleState << 5U);
01004   }
01005 
01006   /* Write to TIMx CR2 */
01007   LL_TIM_WriteReg(TIMx, CR2, tmpcr2);
01008 
01009   /* Write to TIMx CCMR2 */
01010   LL_TIM_WriteReg(TIMx, CCMR2, tmpccmr2);
01011 
01012   /* Set the Capture Compare Register value */
01013   LL_TIM_OC_SetCompareCH3(TIMx, TIM_OCInitStruct->CompareValue);
01014 
01015   /* Write to TIMx CCER */
01016   LL_TIM_WriteReg(TIMx, CCER, tmpccer);
01017 
01018   return SUCCESS;
01019 }
01020 
01021 /**
01022   * @brief  Configure the TIMx output channel 4.
01023   * @param  TIMx Timer Instance
01024   * @param  TIM_OCInitStruct pointer to the the TIMx output channel 4 configuration data structure
01025   * @retval An ErrorStatus enumeration value:
01026   *          - SUCCESS: TIMx registers are de-initialized
01027   *          - ERROR: not applicable
01028   */
01029 static ErrorStatus OC4Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct)
01030 {
01031   uint32_t tmpccmr2;
01032   uint32_t tmpccer;
01033   uint32_t tmpcr2;
01034 
01035   /* Check the parameters */
01036   assert_param(IS_TIM_CC4_INSTANCE(TIMx));
01037   assert_param(IS_LL_TIM_OCMODE(TIM_OCInitStruct->OCMode));
01038   assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCState));
01039   assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCPolarity));
01040   assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCNPolarity));
01041   assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCNState));
01042 
01043   /* Disable the Channel 4: Reset the CC4E Bit */
01044   CLEAR_BIT(TIMx->CCER, TIM_CCER_CC4E);
01045 
01046   /* Get the TIMx CCER register value */
01047   tmpccer = LL_TIM_ReadReg(TIMx, CCER);
01048 
01049   /* Get the TIMx CR2 register value */
01050   tmpcr2 =  LL_TIM_ReadReg(TIMx, CR2);
01051 
01052   /* Get the TIMx CCMR2 register value */
01053   tmpccmr2 = LL_TIM_ReadReg(TIMx, CCMR2);
01054 
01055   /* Reset Capture/Compare selection Bits */
01056   CLEAR_BIT(tmpccmr2, TIM_CCMR2_CC4S);
01057 
01058   /* Select the Output Compare Mode */
01059   MODIFY_REG(tmpccmr2, TIM_CCMR2_OC4M, TIM_OCInitStruct->OCMode << 8U);
01060 
01061   /* Set the Output Compare Polarity */
01062   MODIFY_REG(tmpccer, TIM_CCER_CC4P, TIM_OCInitStruct->OCPolarity << 12U);
01063 
01064   /* Set the Output State */
01065   MODIFY_REG(tmpccer, TIM_CCER_CC4E, TIM_OCInitStruct->OCState << 12U);
01066 
01067   if (IS_TIM_BREAK_INSTANCE(TIMx))
01068   {
01069     assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCNIdleState));
01070     assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCIdleState));
01071 
01072     /* Set the Output Idle state */
01073     MODIFY_REG(tmpcr2, TIM_CR2_OIS4, TIM_OCInitStruct->OCIdleState << 6U);
01074   }
01075 
01076   /* Write to TIMx CR2 */
01077   LL_TIM_WriteReg(TIMx, CR2, tmpcr2);
01078 
01079   /* Write to TIMx CCMR2 */
01080   LL_TIM_WriteReg(TIMx, CCMR2, tmpccmr2);
01081 
01082   /* Set the Capture Compare Register value */
01083   LL_TIM_OC_SetCompareCH4(TIMx, TIM_OCInitStruct->CompareValue);
01084 
01085   /* Write to TIMx CCER */
01086   LL_TIM_WriteReg(TIMx, CCER, tmpccer);
01087 
01088   return SUCCESS;
01089 }
01090 
01091 /**
01092   * @brief  Configure the TIMx output channel 5.
01093   * @param  TIMx Timer Instance
01094   * @param  TIM_OCInitStruct pointer to the the TIMx output channel 5 configuration data structure
01095   * @retval An ErrorStatus enumeration value:
01096   *          - SUCCESS: TIMx registers are de-initialized
01097   *          - ERROR: not applicable
01098   */
01099 static ErrorStatus OC5Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct)
01100 {
01101   uint32_t tmpccmr3;
01102   uint32_t tmpccer;
01103 
01104   /* Check the parameters */
01105   assert_param(IS_TIM_CC5_INSTANCE(TIMx));
01106   assert_param(IS_LL_TIM_OCMODE(TIM_OCInitStruct->OCMode));
01107   assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCState));
01108   assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCPolarity));
01109   assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCNPolarity));
01110   assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCNState));
01111 
01112   /* Disable the Channel 5: Reset the CC5E Bit */
01113   CLEAR_BIT(TIMx->CCER, TIM_CCER_CC5E);
01114 
01115   /* Get the TIMx CCER register value */
01116   tmpccer = LL_TIM_ReadReg(TIMx, CCER);
01117 
01118   /* Get the TIMx CCMR3 register value */
01119   tmpccmr3 = LL_TIM_ReadReg(TIMx, CCMR3);
01120 
01121   /* Select the Output Compare Mode */
01122   MODIFY_REG(tmpccmr3, TIM_CCMR3_OC5M, TIM_OCInitStruct->OCMode);
01123 
01124   /* Set the Output Compare Polarity */
01125   MODIFY_REG(tmpccer, TIM_CCER_CC5P, TIM_OCInitStruct->OCPolarity << 16U);
01126 
01127   /* Set the Output State */
01128   MODIFY_REG(tmpccer, TIM_CCER_CC5E, TIM_OCInitStruct->OCState << 16U);
01129 
01130   if (IS_TIM_BREAK_INSTANCE(TIMx))
01131   {
01132     assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCNIdleState));
01133     assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCIdleState));
01134 
01135     /* Set the Output Idle state */
01136     MODIFY_REG(TIMx->CR2, TIM_CR2_OIS5, TIM_OCInitStruct->OCIdleState << 8U);
01137 
01138   }
01139 
01140   /* Write to TIMx CCMR3 */
01141   LL_TIM_WriteReg(TIMx, CCMR3, tmpccmr3);
01142 
01143   /* Set the Capture Compare Register value */
01144   LL_TIM_OC_SetCompareCH5(TIMx, TIM_OCInitStruct->CompareValue);
01145 
01146   /* Write to TIMx CCER */
01147   LL_TIM_WriteReg(TIMx, CCER, tmpccer);
01148 
01149   return SUCCESS;
01150 }
01151 
01152 /**
01153   * @brief  Configure the TIMx output channel 6.
01154   * @param  TIMx Timer Instance
01155   * @param  TIM_OCInitStruct pointer to the the TIMx output channel 6 configuration data structure
01156   * @retval An ErrorStatus enumeration value:
01157   *          - SUCCESS: TIMx registers are de-initialized
01158   *          - ERROR: not applicable
01159   */
01160 static ErrorStatus OC6Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct)
01161 {
01162   uint32_t tmpccmr3;
01163   uint32_t tmpccer;
01164 
01165   /* Check the parameters */
01166   assert_param(IS_TIM_CC6_INSTANCE(TIMx));
01167   assert_param(IS_LL_TIM_OCMODE(TIM_OCInitStruct->OCMode));
01168   assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCState));
01169   assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCPolarity));
01170   assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCNPolarity));
01171   assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCNState));
01172 
01173   /* Disable the Channel 5: Reset the CC6E Bit */
01174   CLEAR_BIT(TIMx->CCER, TIM_CCER_CC6E);
01175 
01176   /* Get the TIMx CCER register value */
01177   tmpccer = LL_TIM_ReadReg(TIMx, CCER);
01178 
01179   /* Get the TIMx CCMR3 register value */
01180   tmpccmr3 = LL_TIM_ReadReg(TIMx, CCMR3);
01181 
01182   /* Select the Output Compare Mode */
01183   MODIFY_REG(tmpccmr3, TIM_CCMR3_OC6M, TIM_OCInitStruct->OCMode << 8U);
01184 
01185   /* Set the Output Compare Polarity */
01186   MODIFY_REG(tmpccer, TIM_CCER_CC6P, TIM_OCInitStruct->OCPolarity << 20U);
01187 
01188   /* Set the Output State */
01189   MODIFY_REG(tmpccer, TIM_CCER_CC6E, TIM_OCInitStruct->OCState << 20U);
01190 
01191   if (IS_TIM_BREAK_INSTANCE(TIMx))
01192   {
01193     assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCNIdleState));
01194     assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCIdleState));
01195 
01196     /* Set the Output Idle state */
01197     MODIFY_REG(TIMx->CR2, TIM_CR2_OIS6, TIM_OCInitStruct->OCIdleState << 10U);
01198   }
01199 
01200   /* Write to TIMx CCMR3 */
01201   LL_TIM_WriteReg(TIMx, CCMR3, tmpccmr3);
01202 
01203   /* Set the Capture Compare Register value */
01204   LL_TIM_OC_SetCompareCH6(TIMx, TIM_OCInitStruct->CompareValue);
01205 
01206   /* Write to TIMx CCER */
01207   LL_TIM_WriteReg(TIMx, CCER, tmpccer);
01208 
01209   return SUCCESS;
01210 }
01211 
01212 /**
01213   * @brief  Configure the TIMx input channel 1.
01214   * @param  TIMx Timer Instance
01215   * @param  TIM_ICInitStruct pointer to the the TIMx input channel 1 configuration data structure
01216   * @retval An ErrorStatus enumeration value:
01217   *          - SUCCESS: TIMx registers are de-initialized
01218   *          - ERROR: not applicable
01219   */
01220 static ErrorStatus IC1Config(TIM_TypeDef *TIMx, LL_TIM_IC_InitTypeDef *TIM_ICInitStruct)
01221 {
01222   /* Check the parameters */
01223   assert_param(IS_TIM_CC1_INSTANCE(TIMx));
01224   assert_param(IS_LL_TIM_IC_POLARITY(TIM_ICInitStruct->ICPolarity));
01225   assert_param(IS_LL_TIM_ACTIVEINPUT(TIM_ICInitStruct->ICActiveInput));
01226   assert_param(IS_LL_TIM_ICPSC(TIM_ICInitStruct->ICPrescaler));
01227   assert_param(IS_LL_TIM_IC_FILTER(TIM_ICInitStruct->ICFilter));
01228 
01229   /* Disable the Channel 1: Reset the CC1E Bit */
01230   TIMx->CCER &= (uint32_t)~TIM_CCER_CC1E;
01231 
01232   /* Select the Input and set the filter and the prescaler value */
01233   MODIFY_REG(TIMx->CCMR1,
01234              (TIM_CCMR1_CC1S | TIM_CCMR1_IC1F | TIM_CCMR1_IC1PSC),
01235              (TIM_ICInitStruct->ICActiveInput | TIM_ICInitStruct->ICFilter | TIM_ICInitStruct->ICPrescaler) >> 16U);
01236 
01237   /* Select the Polarity and set the CC1E Bit */
01238   MODIFY_REG(TIMx->CCER,
01239              (TIM_CCER_CC1P | TIM_CCER_CC1NP),
01240              (TIM_ICInitStruct->ICPolarity | TIM_CCER_CC1E));
01241 
01242   return SUCCESS;
01243 }
01244 
01245 /**
01246   * @brief  Configure the TIMx input channel 2.
01247   * @param  TIMx Timer Instance
01248   * @param  TIM_ICInitStruct pointer to the the TIMx input channel 2 configuration data structure
01249   * @retval An ErrorStatus enumeration value:
01250   *          - SUCCESS: TIMx registers are de-initialized
01251   *          - ERROR: not applicable
01252   */
01253 static ErrorStatus IC2Config(TIM_TypeDef *TIMx, LL_TIM_IC_InitTypeDef *TIM_ICInitStruct)
01254 {
01255   /* Check the parameters */
01256   assert_param(IS_TIM_CC2_INSTANCE(TIMx));
01257   assert_param(IS_LL_TIM_IC_POLARITY(TIM_ICInitStruct->ICPolarity));
01258   assert_param(IS_LL_TIM_ACTIVEINPUT(TIM_ICInitStruct->ICActiveInput));
01259   assert_param(IS_LL_TIM_ICPSC(TIM_ICInitStruct->ICPrescaler));
01260   assert_param(IS_LL_TIM_IC_FILTER(TIM_ICInitStruct->ICFilter));
01261 
01262   /* Disable the Channel 2: Reset the CC2E Bit */
01263   TIMx->CCER &= (uint32_t)~TIM_CCER_CC2E;
01264 
01265   /* Select the Input and set the filter and the prescaler value */
01266   MODIFY_REG(TIMx->CCMR1,
01267              (TIM_CCMR1_CC2S | TIM_CCMR1_IC2F | TIM_CCMR1_IC2PSC),
01268              (TIM_ICInitStruct->ICActiveInput | TIM_ICInitStruct->ICFilter | TIM_ICInitStruct->ICPrescaler) >> 8U);
01269 
01270   /* Select the Polarity and set the CC2E Bit */
01271   MODIFY_REG(TIMx->CCER,
01272              (TIM_CCER_CC2P | TIM_CCER_CC2NP),
01273              ((TIM_ICInitStruct->ICPolarity << 4U) | TIM_CCER_CC2E));
01274 
01275   return SUCCESS;
01276 }
01277 
01278 /**
01279   * @brief  Configure the TIMx input channel 3.
01280   * @param  TIMx Timer Instance
01281   * @param  TIM_ICInitStruct pointer to the the TIMx input channel 3 configuration data structure
01282   * @retval An ErrorStatus enumeration value:
01283   *          - SUCCESS: TIMx registers are de-initialized
01284   *          - ERROR: not applicable
01285   */
01286 static ErrorStatus IC3Config(TIM_TypeDef *TIMx, LL_TIM_IC_InitTypeDef *TIM_ICInitStruct)
01287 {
01288   /* Check the parameters */
01289   assert_param(IS_TIM_CC3_INSTANCE(TIMx));
01290   assert_param(IS_LL_TIM_IC_POLARITY(TIM_ICInitStruct->ICPolarity));
01291   assert_param(IS_LL_TIM_ACTIVEINPUT(TIM_ICInitStruct->ICActiveInput));
01292   assert_param(IS_LL_TIM_ICPSC(TIM_ICInitStruct->ICPrescaler));
01293   assert_param(IS_LL_TIM_IC_FILTER(TIM_ICInitStruct->ICFilter));
01294 
01295   /* Disable the Channel 3: Reset the CC3E Bit */
01296   TIMx->CCER &= (uint32_t)~TIM_CCER_CC3E;
01297 
01298   /* Select the Input and set the filter and the prescaler value */
01299   MODIFY_REG(TIMx->CCMR2,
01300              (TIM_CCMR2_CC3S | TIM_CCMR2_IC3F | TIM_CCMR2_IC3PSC),
01301              (TIM_ICInitStruct->ICActiveInput | TIM_ICInitStruct->ICFilter | TIM_ICInitStruct->ICPrescaler) >> 16U);
01302 
01303   /* Select the Polarity and set the CC3E Bit */
01304   MODIFY_REG(TIMx->CCER,
01305              (TIM_CCER_CC3P | TIM_CCER_CC3NP),
01306              ((TIM_ICInitStruct->ICPolarity << 8U) | TIM_CCER_CC3E));
01307 
01308   return SUCCESS;
01309 }
01310 
01311 /**
01312   * @brief  Configure the TIMx input channel 4.
01313   * @param  TIMx Timer Instance
01314   * @param  TIM_ICInitStruct pointer to the the TIMx input channel 4 configuration data structure
01315   * @retval An ErrorStatus enumeration value:
01316   *          - SUCCESS: TIMx registers are de-initialized
01317   *          - ERROR: not applicable
01318   */
01319 static ErrorStatus IC4Config(TIM_TypeDef *TIMx, LL_TIM_IC_InitTypeDef *TIM_ICInitStruct)
01320 {
01321   /* Check the parameters */
01322   assert_param(IS_TIM_CC4_INSTANCE(TIMx));
01323   assert_param(IS_LL_TIM_IC_POLARITY(TIM_ICInitStruct->ICPolarity));
01324   assert_param(IS_LL_TIM_ACTIVEINPUT(TIM_ICInitStruct->ICActiveInput));
01325   assert_param(IS_LL_TIM_ICPSC(TIM_ICInitStruct->ICPrescaler));
01326   assert_param(IS_LL_TIM_IC_FILTER(TIM_ICInitStruct->ICFilter));
01327 
01328   /* Disable the Channel 4: Reset the CC4E Bit */
01329   TIMx->CCER &= (uint32_t)~TIM_CCER_CC4E;
01330 
01331   /* Select the Input and set the filter and the prescaler value */
01332   MODIFY_REG(TIMx->CCMR2,
01333              (TIM_CCMR2_CC4S | TIM_CCMR2_IC4F | TIM_CCMR2_IC4PSC),
01334              (TIM_ICInitStruct->ICActiveInput | TIM_ICInitStruct->ICFilter | TIM_ICInitStruct->ICPrescaler) >> 8U);
01335 
01336   /* Select the Polarity and set the CC2E Bit */
01337   MODIFY_REG(TIMx->CCER,
01338              (TIM_CCER_CC4P | TIM_CCER_CC4NP),
01339              ((TIM_ICInitStruct->ICPolarity << 12U) | TIM_CCER_CC4E));
01340 
01341   return SUCCESS;
01342 }
01343 
01344 
01345 /**
01346   * @}
01347   */
01348 
01349 /**
01350   * @}
01351   */
01352 
01353 #endif /* TIM1 || TIM8 || TIM2 || TIM3 ||  TIM4 || TIM5 || TIM15 || TIM16 || TIM17 || TIM6 || TIM7 */
01354 
01355 /**
01356   * @}
01357   */
01358 
01359 #endif /* USE_FULL_LL_DRIVER */
01360