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