STM32L4xx_HAL_Driver  1.14.0
Initialisation and deinitialisation functions

Functions

ErrorStatus LL_TIM_DeInit (TIM_TypeDef *TIMx)
 Set TIMx registers to their reset values. More...
 
void LL_TIM_StructInit (LL_TIM_InitTypeDef *TIM_InitStruct)
 Set the fields of the time base unit configuration data structure to their default values. More...
 
ErrorStatus LL_TIM_Init (TIM_TypeDef *TIMx, LL_TIM_InitTypeDef *TIM_InitStruct)
 Configure the TIMx time base unit. More...
 
void LL_TIM_OC_StructInit (LL_TIM_OC_InitTypeDef *TIM_OC_InitStruct)
 Set the fields of the TIMx output channel configuration data structure to their default values. More...
 
ErrorStatus LL_TIM_OC_Init (TIM_TypeDef *TIMx, uint32_t Channel, LL_TIM_OC_InitTypeDef *TIM_OC_InitStruct)
 Configure the TIMx output channel. More...
 
void LL_TIM_IC_StructInit (LL_TIM_IC_InitTypeDef *TIM_ICInitStruct)
 Set the fields of the TIMx input channel configuration data structure to their default values. More...
 
ErrorStatus LL_TIM_IC_Init (TIM_TypeDef *TIMx, uint32_t Channel, LL_TIM_IC_InitTypeDef *TIM_IC_InitStruct)
 Configure the TIMx input channel. More...
 
void LL_TIM_ENCODER_StructInit (LL_TIM_ENCODER_InitTypeDef *TIM_EncoderInitStruct)
 Fills each TIM_EncoderInitStruct field with its default value. More...
 
ErrorStatus LL_TIM_ENCODER_Init (TIM_TypeDef *TIMx, LL_TIM_ENCODER_InitTypeDef *TIM_EncoderInitStruct)
 Configure the encoder interface of the timer instance. More...
 
void LL_TIM_HALLSENSOR_StructInit (LL_TIM_HALLSENSOR_InitTypeDef *TIM_HallSensorInitStruct)
 Set the fields of the TIMx Hall sensor interface configuration data structure to their default values. More...
 
ErrorStatus LL_TIM_HALLSENSOR_Init (TIM_TypeDef *TIMx, LL_TIM_HALLSENSOR_InitTypeDef *TIM_HallSensorInitStruct)
 Configure the Hall sensor interface of the timer instance. More...
 
void LL_TIM_BDTR_StructInit (LL_TIM_BDTR_InitTypeDef *TIM_BDTRInitStruct)
 Set the fields of the Break and Dead Time configuration data structure to their default values. More...
 
ErrorStatus LL_TIM_BDTR_Init (TIM_TypeDef *TIMx, LL_TIM_BDTR_InitTypeDef *TIM_BDTRInitStruct)
 Configure the Break and Dead Time feature of the timer instance. More...
 

Detailed Description

Function Documentation

◆ LL_TIM_BDTR_Init()

ErrorStatus LL_TIM_BDTR_Init ( TIM_TypeDef *  TIMx,
LL_TIM_BDTR_InitTypeDef TIM_BDTRInitStruct 
)

Configure the Break and Dead Time feature of the timer instance.

Note
As the bits BK2P, BK2E, BK2F[3:0], BKF[3:0], AOE, BKP, BKE, OSSI, OSSR and DTG[7:0] can be write-locked depending on the LOCK configuration, it can be necessary to configure all of them during the first write access to the TIMx_BDTR register.
Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not a timer instance provides a break input.
Macro IS_TIM_BKIN2_INSTANCE(TIMx) can be used to check whether or not a timer instance provides a second break input.
Parameters
TIMxTimer Instance
TIM_BDTRInitStructpointer to a LL_TIM_BDTR_InitTypeDef structure (Break and Dead Time configuration data structure)
Return values
AnErrorStatus enumeration value:
  • SUCCESS: Break and Dead Time is initialized
  • ERROR: not applicable

Definition at line 714 of file stm32l4xx_ll_tim.c.

715 {
716  uint32_t tmpbdtr = 0;
717 
718  /* Check the parameters */
719  assert_param(IS_TIM_BREAK_INSTANCE(TIMx));
720  assert_param(IS_LL_TIM_OSSR_STATE(TIM_BDTRInitStruct->OSSRState));
721  assert_param(IS_LL_TIM_OSSI_STATE(TIM_BDTRInitStruct->OSSIState));
722  assert_param(IS_LL_TIM_LOCK_LEVEL(TIM_BDTRInitStruct->LockLevel));
723  assert_param(IS_LL_TIM_BREAK_STATE(TIM_BDTRInitStruct->BreakState));
724  assert_param(IS_LL_TIM_BREAK_POLARITY(TIM_BDTRInitStruct->BreakPolarity));
725  assert_param(IS_LL_TIM_AUTOMATIC_OUTPUT_STATE(TIM_BDTRInitStruct->AutomaticOutput));
726 
727  /* Set the Lock level, the Break enable Bit and the Polarity, the OSSR State,
728  the OSSI State, the dead time value and the Automatic Output Enable Bit */
729 
730  /* Set the BDTR bits */
731  MODIFY_REG(tmpbdtr, TIM_BDTR_DTG, TIM_BDTRInitStruct->DeadTime);
732  MODIFY_REG(tmpbdtr, TIM_BDTR_LOCK, TIM_BDTRInitStruct->LockLevel);
733  MODIFY_REG(tmpbdtr, TIM_BDTR_OSSI, TIM_BDTRInitStruct->OSSIState);
734  MODIFY_REG(tmpbdtr, TIM_BDTR_OSSR, TIM_BDTRInitStruct->OSSRState);
735  MODIFY_REG(tmpbdtr, TIM_BDTR_BKE, TIM_BDTRInitStruct->BreakState);
736  MODIFY_REG(tmpbdtr, TIM_BDTR_BKP, TIM_BDTRInitStruct->BreakPolarity);
737  MODIFY_REG(tmpbdtr, TIM_BDTR_AOE, TIM_BDTRInitStruct->AutomaticOutput);
738  MODIFY_REG(tmpbdtr, TIM_BDTR_MOE, TIM_BDTRInitStruct->AutomaticOutput);
739  if (IS_TIM_ADVANCED_INSTANCE(TIMx))
740  {
741  assert_param(IS_LL_TIM_BREAK_FILTER(TIM_BDTRInitStruct->BreakFilter));
742  MODIFY_REG(tmpbdtr, TIM_BDTR_BKF, TIM_BDTRInitStruct->BreakFilter);
743  }
744 
745  if (IS_TIM_BKIN2_INSTANCE(TIMx))
746  {
747  assert_param(IS_LL_TIM_BREAK2_STATE(TIM_BDTRInitStruct->Break2State));
748  assert_param(IS_LL_TIM_BREAK2_POLARITY(TIM_BDTRInitStruct->Break2Polarity));
749  assert_param(IS_LL_TIM_BREAK2_FILTER(TIM_BDTRInitStruct->Break2Filter));
750 
751  /* Set the BREAK2 input related BDTR bit-fields */
752  MODIFY_REG(tmpbdtr, TIM_BDTR_BK2F, (TIM_BDTRInitStruct->Break2Filter));
753  MODIFY_REG(tmpbdtr, TIM_BDTR_BK2E, TIM_BDTRInitStruct->Break2State);
754  MODIFY_REG(tmpbdtr, TIM_BDTR_BK2P, TIM_BDTRInitStruct->Break2Polarity);
755  }
756 
757  /* Set TIMx_BDTR */
758  LL_TIM_WriteReg(TIMx, BDTR, tmpbdtr);
759 
760  return SUCCESS;
761 }
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ LL_TIM_BDTR_StructInit()

void LL_TIM_BDTR_StructInit ( LL_TIM_BDTR_InitTypeDef TIM_BDTRInitStruct)

Set the fields of the Break and Dead Time configuration data structure to their default values.

Parameters
TIM_BDTRInitStructpointer to a LL_TIM_BDTR_InitTypeDef structure (Break and Dead Time configuration data structure)
Return values
None

Definition at line 682 of file stm32l4xx_ll_tim.c.

683 {
684  /* Set the default configuration */
685  TIM_BDTRInitStruct->OSSRState = LL_TIM_OSSR_DISABLE;
686  TIM_BDTRInitStruct->OSSIState = LL_TIM_OSSI_DISABLE;
687  TIM_BDTRInitStruct->LockLevel = LL_TIM_LOCKLEVEL_OFF;
688  TIM_BDTRInitStruct->DeadTime = (uint8_t)0x00;
689  TIM_BDTRInitStruct->BreakState = LL_TIM_BREAK_DISABLE;
690  TIM_BDTRInitStruct->BreakPolarity = LL_TIM_BREAK_POLARITY_LOW;
691  TIM_BDTRInitStruct->BreakFilter = LL_TIM_BREAK_FILTER_FDIV1;
692  TIM_BDTRInitStruct->Break2State = LL_TIM_BREAK2_DISABLE;
693  TIM_BDTRInitStruct->Break2Polarity = LL_TIM_BREAK2_POLARITY_LOW;
694  TIM_BDTRInitStruct->Break2Filter = LL_TIM_BREAK2_FILTER_FDIV1;
695  TIM_BDTRInitStruct->AutomaticOutput = LL_TIM_AUTOMATICOUTPUT_DISABLE;
696 }

◆ LL_TIM_DeInit()

ErrorStatus LL_TIM_DeInit ( TIM_TypeDef *  TIMx)

Set TIMx registers to their reset values.

Parameters
TIMxTimer instance
Return values
AnErrorStatus enumeration value:
  • SUCCESS: TIMx registers are de-initialized
  • ERROR: invalid TIMx instance

Definition at line 217 of file stm32l4xx_ll_tim.c.

218 {
219  ErrorStatus result = SUCCESS;
220 
221  /* Check the parameters */
222  assert_param(IS_TIM_INSTANCE(TIMx));
223 
224  if (TIMx == TIM1)
225  {
226  LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_TIM1);
227  LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_TIM1);
228  }
229  else if (TIMx == TIM2)
230  {
231  LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_TIM2);
232  LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_TIM2);
233  }
234 #if defined(TIM3)
235  else if (TIMx == TIM3)
236  {
237  LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_TIM3);
238  LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_TIM3);
239  }
240 #endif
241 #if defined(TIM4)
242  else if (TIMx == TIM4)
243  {
244  LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_TIM4);
245  LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_TIM4);
246  }
247 #endif
248 #if defined(TIM5)
249  else if (TIMx == TIM5)
250  {
251  LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_TIM5);
252  LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_TIM5);
253  }
254 #endif
255  else if (TIMx == TIM6)
256  {
257  LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_TIM6);
258  LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_TIM6);
259  }
260 #if defined (TIM7)
261  else if (TIMx == TIM7)
262  {
263  LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_TIM7);
264  LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_TIM7);
265  }
266 #endif
267 #if defined(TIM8)
268  else if (TIMx == TIM8)
269  {
270  LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_TIM8);
271  LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_TIM8);
272  }
273 #endif
274  else if (TIMx == TIM15)
275  {
276  LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_TIM15);
277  LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_TIM15);
278  }
279  else if (TIMx == TIM16)
280  {
281  LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_TIM16);
282  LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_TIM16);
283  }
284 #if defined(TIM17)
285  else if (TIMx == TIM17)
286  {
287  LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_TIM17);
288  LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_TIM17);
289  }
290 #endif
291  else
292  {
293  result = ERROR;
294  }
295 
296  return result;
297 }
__STATIC_INLINE void LL_APB2_GRP1_ReleaseReset(uint32_t Periphs)
Release APB2 peripherals reset. APB2RSTR SYSCFGRST LL_APB2_GRP1_ReleaseReset APB2RSTR SDMMC1RST LL_...
__STATIC_INLINE void LL_APB1_GRP1_ReleaseReset(uint32_t Periphs)
Release APB1 peripherals reset. APB1RSTR1 TIM2RST LL_APB1_GRP1_ReleaseReset APB1RSTR1 TIM3RST LL_AP...
__STATIC_INLINE void LL_APB2_GRP1_ForceReset(uint32_t Periphs)
Force APB2 peripherals reset. APB2RSTR SYSCFGRST LL_APB2_GRP1_ForceReset APB2RSTR SDMMC1RST LL_APB2...
__STATIC_INLINE void LL_APB1_GRP1_ForceReset(uint32_t Periphs)
Force APB1 peripherals reset. APB1RSTR1 TIM2RST LL_APB1_GRP1_ForceReset APB1RSTR1 TIM3RST LL_APB1_G...
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ LL_TIM_ENCODER_Init()

ErrorStatus LL_TIM_ENCODER_Init ( TIM_TypeDef *  TIMx,
LL_TIM_ENCODER_InitTypeDef TIM_EncoderInitStruct 
)

Configure the encoder interface of the timer instance.

Parameters
TIMxTimer Instance
TIM_EncoderInitStructpointer to a LL_TIM_ENCODER_InitTypeDef structure (TIMx encoder interface configuration data structure)
Return values
AnErrorStatus enumeration value:
  • SUCCESS: TIMx registers are de-initialized
  • ERROR: not applicable

Definition at line 513 of file stm32l4xx_ll_tim.c.

514 {
515  uint32_t tmpccmr1;
516  uint32_t tmpccer;
517 
518  /* Check the parameters */
519  assert_param(IS_TIM_ENCODER_INTERFACE_INSTANCE(TIMx));
520  assert_param(IS_LL_TIM_ENCODERMODE(TIM_EncoderInitStruct->EncoderMode));
521  assert_param(IS_LL_TIM_IC_POLARITY_ENCODER(TIM_EncoderInitStruct->IC1Polarity));
522  assert_param(IS_LL_TIM_ACTIVEINPUT(TIM_EncoderInitStruct->IC1ActiveInput));
523  assert_param(IS_LL_TIM_ICPSC(TIM_EncoderInitStruct->IC1Prescaler));
524  assert_param(IS_LL_TIM_IC_FILTER(TIM_EncoderInitStruct->IC1Filter));
525  assert_param(IS_LL_TIM_IC_POLARITY_ENCODER(TIM_EncoderInitStruct->IC2Polarity));
526  assert_param(IS_LL_TIM_ACTIVEINPUT(TIM_EncoderInitStruct->IC2ActiveInput));
527  assert_param(IS_LL_TIM_ICPSC(TIM_EncoderInitStruct->IC2Prescaler));
528  assert_param(IS_LL_TIM_IC_FILTER(TIM_EncoderInitStruct->IC2Filter));
529 
530  /* Disable the CC1 and CC2: Reset the CC1E and CC2E Bits */
531  TIMx->CCER &= (uint32_t)~(TIM_CCER_CC1E | TIM_CCER_CC2E);
532 
533  /* Get the TIMx CCMR1 register value */
534  tmpccmr1 = LL_TIM_ReadReg(TIMx, CCMR1);
535 
536  /* Get the TIMx CCER register value */
537  tmpccer = LL_TIM_ReadReg(TIMx, CCER);
538 
539  /* Configure TI1 */
540  tmpccmr1 &= (uint32_t)~(TIM_CCMR1_CC1S | TIM_CCMR1_IC1F | TIM_CCMR1_IC1PSC);
541  tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC1ActiveInput >> 16U);
542  tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC1Filter >> 16U);
543  tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC1Prescaler >> 16U);
544 
545  /* Configure TI2 */
546  tmpccmr1 &= (uint32_t)~(TIM_CCMR1_CC2S | TIM_CCMR1_IC2F | TIM_CCMR1_IC2PSC);
547  tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC2ActiveInput >> 8U);
548  tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC2Filter >> 8U);
549  tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC2Prescaler >> 8U);
550 
551  /* Set TI1 and TI2 polarity and enable TI1 and TI2 */
552  tmpccer &= (uint32_t)~(TIM_CCER_CC1P | TIM_CCER_CC1NP | TIM_CCER_CC2P | TIM_CCER_CC2NP);
553  tmpccer |= (uint32_t)(TIM_EncoderInitStruct->IC1Polarity);
554  tmpccer |= (uint32_t)(TIM_EncoderInitStruct->IC2Polarity << 4U);
555  tmpccer |= (uint32_t)(TIM_CCER_CC1E | TIM_CCER_CC2E);
556 
557  /* Set encoder mode */
558  LL_TIM_SetEncoderMode(TIMx, TIM_EncoderInitStruct->EncoderMode);
559 
560  /* Write to TIMx CCMR1 */
561  LL_TIM_WriteReg(TIMx, CCMR1, tmpccmr1);
562 
563  /* Write to TIMx CCER */
564  LL_TIM_WriteReg(TIMx, CCER, tmpccer);
565 
566  return SUCCESS;
567 }
__STATIC_INLINE void LL_TIM_SetEncoderMode(TIM_TypeDef *TIMx, uint32_t EncoderMode)
Set the encoder interface mode.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ LL_TIM_ENCODER_StructInit()

void LL_TIM_ENCODER_StructInit ( LL_TIM_ENCODER_InitTypeDef TIM_EncoderInitStruct)

Fills each TIM_EncoderInitStruct field with its default value.

Parameters
TIM_EncoderInitStructpointer to a LL_TIM_ENCODER_InitTypeDef structure (encoder interface configuration data structure)
Return values
None

Definition at line 491 of file stm32l4xx_ll_tim.c.

492 {
493  /* Set the default configuration */
494  TIM_EncoderInitStruct->EncoderMode = LL_TIM_ENCODERMODE_X2_TI1;
495  TIM_EncoderInitStruct->IC1Polarity = LL_TIM_IC_POLARITY_RISING;
496  TIM_EncoderInitStruct->IC1ActiveInput = LL_TIM_ACTIVEINPUT_DIRECTTI;
497  TIM_EncoderInitStruct->IC1Prescaler = LL_TIM_ICPSC_DIV1;
498  TIM_EncoderInitStruct->IC1Filter = LL_TIM_IC_FILTER_FDIV1;
499  TIM_EncoderInitStruct->IC2Polarity = LL_TIM_IC_POLARITY_RISING;
500  TIM_EncoderInitStruct->IC2ActiveInput = LL_TIM_ACTIVEINPUT_DIRECTTI;
501  TIM_EncoderInitStruct->IC2Prescaler = LL_TIM_ICPSC_DIV1;
502  TIM_EncoderInitStruct->IC2Filter = LL_TIM_IC_FILTER_FDIV1;
503 }

◆ LL_TIM_HALLSENSOR_Init()

ErrorStatus LL_TIM_HALLSENSOR_Init ( TIM_TypeDef *  TIMx,
LL_TIM_HALLSENSOR_InitTypeDef TIM_HallSensorInitStruct 
)

Configure the Hall sensor interface of the timer instance.

Note
TIMx CH1, CH2 and CH3 inputs connected through a XOR to the TI1 input channel
TIMx slave mode controller is configured in reset mode. Selected internal trigger is TI1F_ED.
Channel 1 is configured as input, IC1 is mapped on TRC.
Captured value stored in TIMx_CCR1 correspond to the time elapsed between 2 changes on the inputs. It gives information about motor speed.
Channel 2 is configured in output PWM 2 mode.
Compare value stored in TIMx_CCR2 corresponds to the commutation delay.
OC2REF is selected as trigger output on TRGO.
LL_TIM_IC_POLARITY_BOTHEDGE must not be used for TI1 when it is used when TIMx operates in Hall sensor interface mode.
Parameters
TIMxTimer Instance
TIM_HallSensorInitStructpointer to a LL_TIM_HALLSENSOR_InitTypeDef structure (TIMx HALL sensor interface configuration data structure)
Return values
AnErrorStatus enumeration value:
  • SUCCESS: TIMx registers are de-initialized
  • ERROR: not applicable

Definition at line 604 of file stm32l4xx_ll_tim.c.

605 {
606  uint32_t tmpcr2;
607  uint32_t tmpccmr1;
608  uint32_t tmpccer;
609  uint32_t tmpsmcr;
610 
611  /* Check the parameters */
612  assert_param(IS_TIM_HALL_SENSOR_INTERFACE_INSTANCE(TIMx));
613  assert_param(IS_LL_TIM_IC_POLARITY_ENCODER(TIM_HallSensorInitStruct->IC1Polarity));
614  assert_param(IS_LL_TIM_ICPSC(TIM_HallSensorInitStruct->IC1Prescaler));
615  assert_param(IS_LL_TIM_IC_FILTER(TIM_HallSensorInitStruct->IC1Filter));
616 
617  /* Disable the CC1 and CC2: Reset the CC1E and CC2E Bits */
618  TIMx->CCER &= (uint32_t)~(TIM_CCER_CC1E | TIM_CCER_CC2E);
619 
620  /* Get the TIMx CR2 register value */
621  tmpcr2 = LL_TIM_ReadReg(TIMx, CR2);
622 
623  /* Get the TIMx CCMR1 register value */
624  tmpccmr1 = LL_TIM_ReadReg(TIMx, CCMR1);
625 
626  /* Get the TIMx CCER register value */
627  tmpccer = LL_TIM_ReadReg(TIMx, CCER);
628 
629  /* Get the TIMx SMCR register value */
630  tmpsmcr = LL_TIM_ReadReg(TIMx, SMCR);
631 
632  /* Connect TIMx_CH1, CH2 and CH3 pins to the TI1 input */
633  tmpcr2 |= TIM_CR2_TI1S;
634 
635  /* OC2REF signal is used as trigger output (TRGO) */
636  tmpcr2 |= LL_TIM_TRGO_OC2REF;
637 
638  /* Configure the slave mode controller */
639  tmpsmcr &= (uint32_t)~(TIM_SMCR_TS | TIM_SMCR_SMS);
640  tmpsmcr |= LL_TIM_TS_TI1F_ED;
641  tmpsmcr |= LL_TIM_SLAVEMODE_RESET;
642 
643  /* Configure input channel 1 */
644  tmpccmr1 &= (uint32_t)~(TIM_CCMR1_CC1S | TIM_CCMR1_IC1F | TIM_CCMR1_IC1PSC);
645  tmpccmr1 |= (uint32_t)(LL_TIM_ACTIVEINPUT_TRC >> 16U);
646  tmpccmr1 |= (uint32_t)(TIM_HallSensorInitStruct->IC1Filter >> 16U);
647  tmpccmr1 |= (uint32_t)(TIM_HallSensorInitStruct->IC1Prescaler >> 16U);
648 
649  /* Configure input channel 2 */
650  tmpccmr1 &= (uint32_t)~(TIM_CCMR1_OC2M | TIM_CCMR1_OC2FE | TIM_CCMR1_OC2PE | TIM_CCMR1_OC2CE);
651  tmpccmr1 |= (uint32_t)(LL_TIM_OCMODE_PWM2 << 8U);
652 
653  /* Set Channel 1 polarity and enable Channel 1 and Channel2 */
654  tmpccer &= (uint32_t)~(TIM_CCER_CC1P | TIM_CCER_CC1NP | TIM_CCER_CC2P | TIM_CCER_CC2NP);
655  tmpccer |= (uint32_t)(TIM_HallSensorInitStruct->IC1Polarity);
656  tmpccer |= (uint32_t)(TIM_CCER_CC1E | TIM_CCER_CC2E);
657 
658  /* Write to TIMx CR2 */
659  LL_TIM_WriteReg(TIMx, CR2, tmpcr2);
660 
661  /* Write to TIMx SMCR */
662  LL_TIM_WriteReg(TIMx, SMCR, tmpsmcr);
663 
664  /* Write to TIMx CCMR1 */
665  LL_TIM_WriteReg(TIMx, CCMR1, tmpccmr1);
666 
667  /* Write to TIMx CCER */
668  LL_TIM_WriteReg(TIMx, CCER, tmpccer);
669 
670  /* Write to TIMx CCR2 */
671  LL_TIM_OC_SetCompareCH2(TIMx, TIM_HallSensorInitStruct->CommutationDelay);
672 
673  return SUCCESS;
674 }
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
__STATIC_INLINE void LL_TIM_OC_SetCompareCH2(TIM_TypeDef *TIMx, uint32_t CompareValue)
Set compare value for output channel 2 (TIMx_CCR2).

◆ LL_TIM_HALLSENSOR_StructInit()

void LL_TIM_HALLSENSOR_StructInit ( LL_TIM_HALLSENSOR_InitTypeDef TIM_HallSensorInitStruct)

Set the fields of the TIMx Hall sensor interface configuration data structure to their default values.

Parameters
TIM_HallSensorInitStructpointer to a LL_TIM_HALLSENSOR_InitTypeDef structure (HALL sensor interface configuration data structure)
Return values
None

Definition at line 575 of file stm32l4xx_ll_tim.c.

576 {
577  /* Set the default configuration */
578  TIM_HallSensorInitStruct->IC1Polarity = LL_TIM_IC_POLARITY_RISING;
579  TIM_HallSensorInitStruct->IC1Prescaler = LL_TIM_ICPSC_DIV1;
580  TIM_HallSensorInitStruct->IC1Filter = LL_TIM_IC_FILTER_FDIV1;
581  TIM_HallSensorInitStruct->CommutationDelay = 0U;
582 }

◆ LL_TIM_IC_Init()

ErrorStatus LL_TIM_IC_Init ( TIM_TypeDef *  TIMx,
uint32_t  Channel,
LL_TIM_IC_InitTypeDef TIM_IC_InitStruct 
)

Configure the TIMx input channel.

Parameters
TIMxTimer Instance
ChannelThis parameter can be one of the following values:
  • LL_TIM_CHANNEL_CH1
  • LL_TIM_CHANNEL_CH2
  • LL_TIM_CHANNEL_CH3
  • LL_TIM_CHANNEL_CH4
TIM_IC_InitStructpointer to a LL_TIM_IC_InitTypeDef structure (TIMx input channel configuration data structure)
Return values
AnErrorStatus enumeration value:
  • SUCCESS: TIMx output channel is initialized
  • ERROR: TIMx output channel is not initialized

Definition at line 461 of file stm32l4xx_ll_tim.c.

462 {
463  ErrorStatus result = ERROR;
464 
465  switch (Channel)
466  {
467  case LL_TIM_CHANNEL_CH1:
468  result = IC1Config(TIMx, TIM_IC_InitStruct);
469  break;
470  case LL_TIM_CHANNEL_CH2:
471  result = IC2Config(TIMx, TIM_IC_InitStruct);
472  break;
473  case LL_TIM_CHANNEL_CH3:
474  result = IC3Config(TIMx, TIM_IC_InitStruct);
475  break;
476  case LL_TIM_CHANNEL_CH4:
477  result = IC4Config(TIMx, TIM_IC_InitStruct);
478  break;
479  default:
480  break;
481  }
482 
483  return result;
484 }
static ErrorStatus IC2Config(TIM_TypeDef *TIMx, LL_TIM_IC_InitTypeDef *TIM_ICInitStruct)
Configure the TIMx input channel 2.
static ErrorStatus IC4Config(TIM_TypeDef *TIMx, LL_TIM_IC_InitTypeDef *TIM_ICInitStruct)
Configure the TIMx input channel 4.
static ErrorStatus IC1Config(TIM_TypeDef *TIMx, LL_TIM_IC_InitTypeDef *TIM_ICInitStruct)
Configure the TIMx input channel 1.
static ErrorStatus IC3Config(TIM_TypeDef *TIMx, LL_TIM_IC_InitTypeDef *TIM_ICInitStruct)
Configure the TIMx input channel 3.

◆ LL_TIM_IC_StructInit()

void LL_TIM_IC_StructInit ( LL_TIM_IC_InitTypeDef TIM_ICInitStruct)

Set the fields of the TIMx input channel configuration data structure to their default values.

Parameters
TIM_ICInitStructpointer to a LL_TIM_IC_InitTypeDef structure (the input channel configuration data structure)
Return values
None

Definition at line 439 of file stm32l4xx_ll_tim.c.

440 {
441  /* Set the default configuration */
442  TIM_ICInitStruct->ICPolarity = LL_TIM_IC_POLARITY_RISING;
443  TIM_ICInitStruct->ICActiveInput = LL_TIM_ACTIVEINPUT_DIRECTTI;
444  TIM_ICInitStruct->ICPrescaler = LL_TIM_ICPSC_DIV1;
445  TIM_ICInitStruct->ICFilter = LL_TIM_IC_FILTER_FDIV1;
446 }

◆ LL_TIM_Init()

ErrorStatus LL_TIM_Init ( TIM_TypeDef *  TIMx,
LL_TIM_InitTypeDef TIM_InitStruct 
)

Configure the TIMx time base unit.

Parameters
TIMxTimer Instance
TIM_InitStructpointer to a LL_TIM_InitTypeDef structure (TIMx time base unit configuration data structure)
Return values
AnErrorStatus enumeration value:
  • SUCCESS: TIMx registers are de-initialized
  • ERROR: not applicable

Definition at line 323 of file stm32l4xx_ll_tim.c.

324 {
325  uint32_t tmpcr1;
326 
327  /* Check the parameters */
328  assert_param(IS_TIM_INSTANCE(TIMx));
329  assert_param(IS_LL_TIM_COUNTERMODE(TIM_InitStruct->CounterMode));
330  assert_param(IS_LL_TIM_CLOCKDIVISION(TIM_InitStruct->ClockDivision));
331 
332  tmpcr1 = LL_TIM_ReadReg(TIMx, CR1);
333 
334  if (IS_TIM_COUNTER_MODE_SELECT_INSTANCE(TIMx))
335  {
336  /* Select the Counter Mode */
337  MODIFY_REG(tmpcr1, (TIM_CR1_DIR | TIM_CR1_CMS), TIM_InitStruct->CounterMode);
338  }
339 
340  if (IS_TIM_CLOCK_DIVISION_INSTANCE(TIMx))
341  {
342  /* Set the clock division */
343  MODIFY_REG(tmpcr1, TIM_CR1_CKD, TIM_InitStruct->ClockDivision);
344  }
345 
346  /* Write to TIMx CR1 */
347  LL_TIM_WriteReg(TIMx, CR1, tmpcr1);
348 
349  /* Set the Autoreload value */
350  LL_TIM_SetAutoReload(TIMx, TIM_InitStruct->Autoreload);
351 
352  /* Set the Prescaler value */
353  LL_TIM_SetPrescaler(TIMx, TIM_InitStruct->Prescaler);
354 
355  if (IS_TIM_REPETITION_COUNTER_INSTANCE(TIMx))
356  {
357  /* Set the Repetition Counter value */
358  LL_TIM_SetRepetitionCounter(TIMx, TIM_InitStruct->RepetitionCounter);
359  }
360 
361  /* Generate an update event to reload the Prescaler
362  and the repetition counter value (if applicable) immediately */
364 
365  return SUCCESS;
366 }
__STATIC_INLINE void LL_TIM_GenerateEvent_UPDATE(TIM_TypeDef *TIMx)
Generate an update event. EGR UG LL_TIM_GenerateEvent_UPDATE.
__STATIC_INLINE void LL_TIM_SetPrescaler(TIM_TypeDef *TIMx, uint32_t Prescaler)
Set the prescaler value.
__STATIC_INLINE void LL_TIM_SetRepetitionCounter(TIM_TypeDef *TIMx, uint32_t RepetitionCounter)
Set the repetition counter value.
__STATIC_INLINE void LL_TIM_SetAutoReload(TIM_TypeDef *TIMx, uint32_t AutoReload)
Set the auto-reload value.
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ LL_TIM_OC_Init()

ErrorStatus LL_TIM_OC_Init ( TIM_TypeDef *  TIMx,
uint32_t  Channel,
LL_TIM_OC_InitTypeDef TIM_OC_InitStruct 
)

Configure the TIMx output channel.

Parameters
TIMxTimer Instance
ChannelThis parameter can be one of the following values:
  • LL_TIM_CHANNEL_CH1
  • LL_TIM_CHANNEL_CH2
  • LL_TIM_CHANNEL_CH3
  • LL_TIM_CHANNEL_CH4
  • LL_TIM_CHANNEL_CH5
  • LL_TIM_CHANNEL_CH6
TIM_OC_InitStructpointer to a LL_TIM_OC_InitTypeDef structure (TIMx output channel configuration data structure)
Return values
AnErrorStatus enumeration value:
  • SUCCESS: TIMx output channel is initialized
  • ERROR: TIMx output channel is not initialized

Definition at line 402 of file stm32l4xx_ll_tim.c.

403 {
404  ErrorStatus result = ERROR;
405 
406  switch (Channel)
407  {
408  case LL_TIM_CHANNEL_CH1:
409  result = OC1Config(TIMx, TIM_OC_InitStruct);
410  break;
411  case LL_TIM_CHANNEL_CH2:
412  result = OC2Config(TIMx, TIM_OC_InitStruct);
413  break;
414  case LL_TIM_CHANNEL_CH3:
415  result = OC3Config(TIMx, TIM_OC_InitStruct);
416  break;
417  case LL_TIM_CHANNEL_CH4:
418  result = OC4Config(TIMx, TIM_OC_InitStruct);
419  break;
420  case LL_TIM_CHANNEL_CH5:
421  result = OC5Config(TIMx, TIM_OC_InitStruct);
422  break;
423  case LL_TIM_CHANNEL_CH6:
424  result = OC6Config(TIMx, TIM_OC_InitStruct);
425  break;
426  default:
427  break;
428  }
429 
430  return result;
431 }
static ErrorStatus OC1Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct)
Configure the TIMx output channel 1.
static ErrorStatus OC5Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct)
Configure the TIMx output channel 5.
static ErrorStatus OC6Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct)
Configure the TIMx output channel 6.
static ErrorStatus OC4Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct)
Configure the TIMx output channel 4.
static ErrorStatus OC3Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct)
Configure the TIMx output channel 3.
static ErrorStatus OC2Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct)
Configure the TIMx output channel 2.

◆ LL_TIM_OC_StructInit()

void LL_TIM_OC_StructInit ( LL_TIM_OC_InitTypeDef TIM_OC_InitStruct)

Set the fields of the TIMx output channel configuration data structure to their default values.

Parameters
TIM_OC_InitStructpointer to a LL_TIM_OC_InitTypeDef structure (the output channel configuration data structure)
Return values
None

Definition at line 374 of file stm32l4xx_ll_tim.c.

375 {
376  /* Set the default configuration */
377  TIM_OC_InitStruct->OCMode = LL_TIM_OCMODE_FROZEN;
378  TIM_OC_InitStruct->OCState = LL_TIM_OCSTATE_DISABLE;
379  TIM_OC_InitStruct->OCNState = LL_TIM_OCSTATE_DISABLE;
380  TIM_OC_InitStruct->CompareValue = 0x00000000U;
381  TIM_OC_InitStruct->OCPolarity = LL_TIM_OCPOLARITY_HIGH;
382  TIM_OC_InitStruct->OCNPolarity = LL_TIM_OCPOLARITY_HIGH;
383  TIM_OC_InitStruct->OCIdleState = LL_TIM_OCIDLESTATE_LOW;
384  TIM_OC_InitStruct->OCNIdleState = LL_TIM_OCIDLESTATE_LOW;
385 }

◆ LL_TIM_StructInit()

void LL_TIM_StructInit ( LL_TIM_InitTypeDef TIM_InitStruct)

Set the fields of the time base unit configuration data structure to their default values.

Parameters
TIM_InitStructpointer to a LL_TIM_InitTypeDef structure (time base unit configuration data structure)
Return values
None

Definition at line 305 of file stm32l4xx_ll_tim.c.

306 {
307  /* Set the default configuration */
308  TIM_InitStruct->Prescaler = (uint16_t)0x0000;
309  TIM_InitStruct->CounterMode = LL_TIM_COUNTERMODE_UP;
310  TIM_InitStruct->Autoreload = 0xFFFFFFFFU;
311  TIM_InitStruct->ClockDivision = LL_TIM_CLOCKDIVISION_DIV1;
312  TIM_InitStruct->RepetitionCounter = (uint8_t)0x00;
313 }