STM32L4xx_HAL_Driver  1.14.0
TIM Private Functions

Functions

void TIM_Base_SetConfig (TIM_TypeDef *TIMx, TIM_Base_InitTypeDef *Structure)
 Time Base configuration. More...
 
void TIM_TI1_SetConfig (TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection, uint32_t TIM_ICFilter)
 Configure the TI1 as Input. More...
 
void TIM_OC2_SetConfig (TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
 Timer Output Compare 2 configuration. More...
 
void TIM_ETR_SetConfig (TIM_TypeDef *TIMx, uint32_t TIM_ExtTRGPrescaler, uint32_t TIM_ExtTRGPolarity, uint32_t ExtTRGFilter)
 Configures the TIMx External Trigger (ETR). More...
 
void TIM_DMADelayPulseCplt (DMA_HandleTypeDef *hdma)
 TIM DMA Delay Pulse complete callback. More...
 
void TIM_DMADelayPulseHalfCplt (DMA_HandleTypeDef *hdma)
 TIM DMA Delay Pulse half complete callback. More...
 
void TIM_DMAError (DMA_HandleTypeDef *hdma)
 TIM DMA error callback. More...
 
void TIM_DMACaptureCplt (DMA_HandleTypeDef *hdma)
 TIM DMA Capture complete callback. More...
 
void TIM_DMACaptureHalfCplt (DMA_HandleTypeDef *hdma)
 TIM DMA Capture half complete callback. More...
 
void TIM_CCxChannelCmd (TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ChannelState)
 Enables or disables the TIM Capture Compare Channel x. More...
 
void TIM_ResetCallback (TIM_HandleTypeDef *htim)
 Reset interrupt callbacks to the legacy weak callbacks. More...
 
static void TIM_OC1_SetConfig (TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
 Timer Output Compare 1 configuration. More...
 
static void TIM_OC3_SetConfig (TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
 Timer Output Compare 3 configuration. More...
 
static void TIM_OC4_SetConfig (TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
 Timer Output Compare 4 configuration. More...
 
static void TIM_OC5_SetConfig (TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
 Timer Output Compare 5 configuration. More...
 
static void TIM_OC6_SetConfig (TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
 Timer Output Compare 6 configuration. More...
 
static void TIM_TI1_ConfigInputStage (TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICFilter)
 Configure the Polarity and Filter for TI1. More...
 
static void TIM_TI2_SetConfig (TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection, uint32_t TIM_ICFilter)
 Configure the TI2 as Input. More...
 
static void TIM_TI2_ConfigInputStage (TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICFilter)
 Configure the Polarity and Filter for TI2. More...
 
static void TIM_TI3_SetConfig (TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection, uint32_t TIM_ICFilter)
 Configure the TI3 as Input. More...
 
static void TIM_TI4_SetConfig (TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection, uint32_t TIM_ICFilter)
 Configure the TI4 as Input. More...
 
static void TIM_ITRx_SetConfig (TIM_TypeDef *TIMx, uint32_t InputTriggerSource)
 Selects the Input Trigger source. More...
 
static void TIM_DMAPeriodElapsedCplt (DMA_HandleTypeDef *hdma)
 TIM DMA Period Elapse complete callback. More...
 
static void TIM_DMAPeriodElapsedHalfCplt (DMA_HandleTypeDef *hdma)
 TIM DMA Period Elapse half complete callback. More...
 
static void TIM_DMATriggerCplt (DMA_HandleTypeDef *hdma)
 TIM DMA Trigger callback. More...
 
static void TIM_DMATriggerHalfCplt (DMA_HandleTypeDef *hdma)
 TIM DMA Trigger half complete callback. More...
 
static HAL_StatusTypeDef TIM_SlaveTimer_SetConfig (TIM_HandleTypeDef *htim, TIM_SlaveConfigTypeDef *sSlaveConfig)
 Slave Timer configuration function. More...
 

Detailed Description

Function Documentation

◆ TIM_Base_SetConfig()

void TIM_Base_SetConfig ( TIM_TypeDef *  TIMx,
TIM_Base_InitTypeDef Structure 
)

Time Base configuration.

Parameters
TIMxTIM peripheral
StructureTIM Base configuration structure
Return values
None

Definition at line 5951 of file stm32l4xx_hal_tim.c.

5952 {
5953  uint32_t tmpcr1;
5954  tmpcr1 = TIMx->CR1;
5955 
5956  /* Set TIM Time Base Unit parameters ---------------------------------------*/
5957  if (IS_TIM_COUNTER_MODE_SELECT_INSTANCE(TIMx))
5958  {
5959  /* Select the Counter Mode */
5960  tmpcr1 &= ~(TIM_CR1_DIR | TIM_CR1_CMS);
5961  tmpcr1 |= Structure->CounterMode;
5962  }
5963 
5964  if (IS_TIM_CLOCK_DIVISION_INSTANCE(TIMx))
5965  {
5966  /* Set the clock division */
5967  tmpcr1 &= ~TIM_CR1_CKD;
5968  tmpcr1 |= (uint32_t)Structure->ClockDivision;
5969  }
5970 
5971  /* Set the auto-reload preload */
5972  MODIFY_REG(tmpcr1, TIM_CR1_ARPE, Structure->AutoReloadPreload);
5973 
5974  TIMx->CR1 = tmpcr1;
5975 
5976  /* Set the Autoreload value */
5977  TIMx->ARR = (uint32_t)Structure->Period ;
5978 
5979  /* Set the Prescaler value */
5980  TIMx->PSC = Structure->Prescaler;
5981 
5982  if (IS_TIM_REPETITION_COUNTER_INSTANCE(TIMx))
5983  {
5984  /* Set the Repetition Counter value */
5985  TIMx->RCR = Structure->RepetitionCounter;
5986  }
5987 
5988  /* Generate an update event to reload the Prescaler
5989  and the repetition counter (only for advanced timer) value immediately */
5990  TIMx->EGR = TIM_EGR_UG;
5991 }
if(lpuartdiv >=LPUART_BRR_MIN_VALUE)
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)

◆ TIM_CCxChannelCmd()

void TIM_CCxChannelCmd ( TIM_TypeDef *  TIMx,
uint32_t  Channel,
uint32_t  ChannelState 
)

Enables or disables the TIM Capture Compare Channel x.

Parameters
TIMxto select the TIM peripheral
Channelspecifies the TIM Channel This parameter can be one of the following values:
  • TIM_CHANNEL_1: TIM Channel 1
  • TIM_CHANNEL_2: TIM Channel 2
  • TIM_CHANNEL_3: TIM Channel 3
  • TIM_CHANNEL_4: TIM Channel 4
  • TIM_CHANNEL_5: TIM Channel 5 selected
  • TIM_CHANNEL_6: TIM Channel 6 selected
ChannelStatespecifies the TIM Channel CCxE bit new state. This parameter can be: TIM_CCx_ENABLE or TIM_CCx_DISABLE.
Return values
None

Definition at line 6848 of file stm32l4xx_hal_tim.c.

6849 {
6850  uint32_t tmp;
6851 
6852  /* Check the parameters */
6853  assert_param(IS_TIM_CC1_INSTANCE(TIMx));
6854  assert_param(IS_TIM_CHANNELS(Channel));
6855 
6856  tmp = TIM_CCER_CC1E << (Channel & 0x1FU); /* 0x1FU = 31 bits max shift */
6857 
6858  /* Reset the CCxE Bit */
6859  TIMx->CCER &= ~tmp;
6860 
6861  /* Set or reset the CCxE Bit */
6862  TIMx->CCER |= (uint32_t)(ChannelState << (Channel & 0x1FU)); /* 0x1FU = 31 bits max shift */
6863 }
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ TIM_DMACaptureCplt()

void TIM_DMACaptureCplt ( DMA_HandleTypeDef hdma)

TIM DMA Capture complete callback.

Parameters
hdmapointer to DMA handle.
Return values
None

Definition at line 5796 of file stm32l4xx_hal_tim.c.

5797 {
5798  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
5799 
5800  htim->State = HAL_TIM_STATE_READY;
5801 
5802  if (hdma == htim->hdma[TIM_DMA_ID_CC1])
5803  {
5804  htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
5805  }
5806  else if (hdma == htim->hdma[TIM_DMA_ID_CC2])
5807  {
5808  htim->Channel = HAL_TIM_ACTIVE_CHANNEL_2;
5809  }
5810  else if (hdma == htim->hdma[TIM_DMA_ID_CC3])
5811  {
5812  htim->Channel = HAL_TIM_ACTIVE_CHANNEL_3;
5813  }
5814  else if (hdma == htim->hdma[TIM_DMA_ID_CC4])
5815  {
5816  htim->Channel = HAL_TIM_ACTIVE_CHANNEL_4;
5817  }
5818  else
5819  {
5820  /* nothing to do */
5821  }
5822 
5823 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
5824  htim->IC_CaptureCallback(htim);
5825 #else
5827 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
5828 
5829  htim->Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED;
5830 }
DMA handle Structure definition.
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
Input Capture callback in non-blocking mode.
struct __TIM_HandleTypeDef else typedef struct endif TIM_HandleTypeDef
TIM Time Base Handle Structure definition.

◆ TIM_DMACaptureHalfCplt()

void TIM_DMACaptureHalfCplt ( DMA_HandleTypeDef hdma)

TIM DMA Capture half complete callback.

Parameters
hdmapointer to DMA handle.
Return values
None

Definition at line 5837 of file stm32l4xx_hal_tim.c.

5838 {
5839  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
5840 
5841  htim->State = HAL_TIM_STATE_READY;
5842 
5843  if (hdma == htim->hdma[TIM_DMA_ID_CC1])
5844  {
5845  htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
5846  }
5847  else if (hdma == htim->hdma[TIM_DMA_ID_CC2])
5848  {
5849  htim->Channel = HAL_TIM_ACTIVE_CHANNEL_2;
5850  }
5851  else if (hdma == htim->hdma[TIM_DMA_ID_CC3])
5852  {
5853  htim->Channel = HAL_TIM_ACTIVE_CHANNEL_3;
5854  }
5855  else if (hdma == htim->hdma[TIM_DMA_ID_CC4])
5856  {
5857  htim->Channel = HAL_TIM_ACTIVE_CHANNEL_4;
5858  }
5859  else
5860  {
5861  /* nothing to do */
5862  }
5863 
5864 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
5865  htim->IC_CaptureHalfCpltCallback(htim);
5866 #else
5868 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
5869 
5870  htim->Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED;
5871 }
DMA handle Structure definition.
void HAL_TIM_IC_CaptureHalfCpltCallback(TIM_HandleTypeDef *htim)
Input Capture half complete callback in non-blocking mode.
struct __TIM_HandleTypeDef else typedef struct endif TIM_HandleTypeDef
TIM Time Base Handle Structure definition.

◆ TIM_DMADelayPulseCplt()

void TIM_DMADelayPulseCplt ( DMA_HandleTypeDef hdma)

TIM DMA Delay Pulse complete callback.

Parameters
hdmapointer to DMA handle.
Return values
None

Definition at line 5714 of file stm32l4xx_hal_tim.c.

5715 {
5716  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
5717 
5718  htim->State = HAL_TIM_STATE_READY;
5719 
5720  if (hdma == htim->hdma[TIM_DMA_ID_CC1])
5721  {
5722  htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
5723  }
5724  else if (hdma == htim->hdma[TIM_DMA_ID_CC2])
5725  {
5726  htim->Channel = HAL_TIM_ACTIVE_CHANNEL_2;
5727  }
5728  else if (hdma == htim->hdma[TIM_DMA_ID_CC3])
5729  {
5730  htim->Channel = HAL_TIM_ACTIVE_CHANNEL_3;
5731  }
5732  else if (hdma == htim->hdma[TIM_DMA_ID_CC4])
5733  {
5734  htim->Channel = HAL_TIM_ACTIVE_CHANNEL_4;
5735  }
5736  else
5737  {
5738  /* nothing to do */
5739  }
5740 
5741 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
5742  htim->PWM_PulseFinishedCallback(htim);
5743 #else
5745 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
5746 
5747  htim->Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED;
5748 }
DMA handle Structure definition.
void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim)
PWM Pulse finished callback in non-blocking mode.
struct __TIM_HandleTypeDef else typedef struct endif TIM_HandleTypeDef
TIM Time Base Handle Structure definition.

◆ TIM_DMADelayPulseHalfCplt()

void TIM_DMADelayPulseHalfCplt ( DMA_HandleTypeDef hdma)

TIM DMA Delay Pulse half complete callback.

Parameters
hdmapointer to DMA handle.
Return values
None

Definition at line 5755 of file stm32l4xx_hal_tim.c.

5756 {
5757  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
5758 
5759  htim->State = HAL_TIM_STATE_READY;
5760 
5761  if (hdma == htim->hdma[TIM_DMA_ID_CC1])
5762  {
5763  htim->Channel = HAL_TIM_ACTIVE_CHANNEL_1;
5764  }
5765  else if (hdma == htim->hdma[TIM_DMA_ID_CC2])
5766  {
5767  htim->Channel = HAL_TIM_ACTIVE_CHANNEL_2;
5768  }
5769  else if (hdma == htim->hdma[TIM_DMA_ID_CC3])
5770  {
5771  htim->Channel = HAL_TIM_ACTIVE_CHANNEL_3;
5772  }
5773  else if (hdma == htim->hdma[TIM_DMA_ID_CC4])
5774  {
5775  htim->Channel = HAL_TIM_ACTIVE_CHANNEL_4;
5776  }
5777  else
5778  {
5779  /* nothing to do */
5780  }
5781 
5782 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
5783  htim->PWM_PulseFinishedHalfCpltCallback(htim);
5784 #else
5786 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
5787 
5788  htim->Channel = HAL_TIM_ACTIVE_CHANNEL_CLEARED;
5789 }
void HAL_TIM_PWM_PulseFinishedHalfCpltCallback(TIM_HandleTypeDef *htim)
PWM Pulse finished half complete callback in non-blocking mode.
DMA handle Structure definition.
struct __TIM_HandleTypeDef else typedef struct endif TIM_HandleTypeDef
TIM Time Base Handle Structure definition.

◆ TIM_DMAError()

void TIM_DMAError ( DMA_HandleTypeDef hdma)

TIM DMA error callback.

Parameters
hdmapointer to DMA handle.
Return values
None

Definition at line 5696 of file stm32l4xx_hal_tim.c.

5697 {
5698  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
5699 
5700  htim->State = HAL_TIM_STATE_READY;
5701 
5702 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
5703  htim->ErrorCallback(htim);
5704 #else
5705  HAL_TIM_ErrorCallback(htim);
5706 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
5707 }
DMA handle Structure definition.
void HAL_TIM_ErrorCallback(TIM_HandleTypeDef *htim)
Timer error callback in non-blocking mode.
struct __TIM_HandleTypeDef else typedef struct endif TIM_HandleTypeDef
TIM Time Base Handle Structure definition.

◆ TIM_DMAPeriodElapsedCplt()

static void TIM_DMAPeriodElapsedCplt ( DMA_HandleTypeDef hdma)
static

TIM DMA Period Elapse complete callback.

Parameters
hdmapointer to DMA handle.
Return values
None

Definition at line 5878 of file stm32l4xx_hal_tim.c.

5879 {
5880  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
5881 
5882  htim->State = HAL_TIM_STATE_READY;
5883 
5884 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
5885  htim->PeriodElapsedCallback(htim);
5886 #else
5888 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
5889 }
DMA handle Structure definition.
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
Period elapsed callback in non-blocking mode.
struct __TIM_HandleTypeDef else typedef struct endif TIM_HandleTypeDef
TIM Time Base Handle Structure definition.

◆ TIM_DMAPeriodElapsedHalfCplt()

static void TIM_DMAPeriodElapsedHalfCplt ( DMA_HandleTypeDef hdma)
static

TIM DMA Period Elapse half complete callback.

Parameters
hdmapointer to DMA handle.
Return values
None

Definition at line 5896 of file stm32l4xx_hal_tim.c.

5897 {
5898  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
5899 
5900  htim->State = HAL_TIM_STATE_READY;
5901 
5902 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
5903  htim->PeriodElapsedHalfCpltCallback(htim);
5904 #else
5906 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
5907 }
DMA handle Structure definition.
struct __TIM_HandleTypeDef else typedef struct endif TIM_HandleTypeDef
TIM Time Base Handle Structure definition.
void HAL_TIM_PeriodElapsedHalfCpltCallback(TIM_HandleTypeDef *htim)
Period elapsed half complete callback in non-blocking mode.

◆ TIM_DMATriggerCplt()

static void TIM_DMATriggerCplt ( DMA_HandleTypeDef hdma)
static

TIM DMA Trigger callback.

Parameters
hdmapointer to DMA handle.
Return values
None

Definition at line 5914 of file stm32l4xx_hal_tim.c.

5915 {
5916  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
5917 
5918  htim->State = HAL_TIM_STATE_READY;
5919 
5920 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
5921  htim->TriggerCallback(htim);
5922 #else
5924 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
5925 }
DMA handle Structure definition.
struct __TIM_HandleTypeDef else typedef struct endif TIM_HandleTypeDef
TIM Time Base Handle Structure definition.
void HAL_TIM_TriggerCallback(TIM_HandleTypeDef *htim)
Hall Trigger detection callback in non-blocking mode.

◆ TIM_DMATriggerHalfCplt()

static void TIM_DMATriggerHalfCplt ( DMA_HandleTypeDef hdma)
static

TIM DMA Trigger half complete callback.

Parameters
hdmapointer to DMA handle.
Return values
None

Definition at line 5932 of file stm32l4xx_hal_tim.c.

5933 {
5934  TIM_HandleTypeDef *htim = (TIM_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
5935 
5936  htim->State = HAL_TIM_STATE_READY;
5937 
5938 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
5939  htim->TriggerHalfCpltCallback(htim);
5940 #else
5942 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
5943 }
DMA handle Structure definition.
void HAL_TIM_TriggerHalfCpltCallback(TIM_HandleTypeDef *htim)
Hall Trigger detection half complete callback in non-blocking mode.
struct __TIM_HandleTypeDef else typedef struct endif TIM_HandleTypeDef
TIM Time Base Handle Structure definition.

◆ TIM_ETR_SetConfig()

void TIM_ETR_SetConfig ( TIM_TypeDef *  TIMx,
uint32_t  TIM_ExtTRGPrescaler,
uint32_t  TIM_ExtTRGPolarity,
uint32_t  ExtTRGFilter 
)

Configures the TIMx External Trigger (ETR).

Parameters
TIMxto select the TIM peripheral
TIM_ExtTRGPrescalerThe external Trigger Prescaler. This parameter can be one of the following values:
  • TIM_ETRPRESCALER_DIV1: ETRP Prescaler OFF.
  • TIM_ETRPRESCALER_DIV2: ETRP frequency divided by 2.
  • TIM_ETRPRESCALER_DIV4: ETRP frequency divided by 4.
  • TIM_ETRPRESCALER_DIV8: ETRP frequency divided by 8.
TIM_ExtTRGPolarityThe external Trigger Polarity. This parameter can be one of the following values:
  • TIM_ETRPOLARITY_INVERTED: active low or falling edge active.
  • TIM_ETRPOLARITY_NONINVERTED: active high or rising edge active.
ExtTRGFilterExternal Trigger Filter. This parameter must be a value between 0x00 and 0x0F
Return values
None

Definition at line 6816 of file stm32l4xx_hal_tim.c.

6818 {
6819  uint32_t tmpsmcr;
6820 
6821  tmpsmcr = TIMx->SMCR;
6822 
6823  /* Reset the ETR Bits */
6824  tmpsmcr &= ~(TIM_SMCR_ETF | TIM_SMCR_ETPS | TIM_SMCR_ECE | TIM_SMCR_ETP);
6825 
6826  /* Set the Prescaler, the Filter value and the Polarity */
6827  tmpsmcr |= (uint32_t)(TIM_ExtTRGPrescaler | (TIM_ExtTRGPolarity | (ExtTRGFilter << 8U)));
6828 
6829  /* Write to TIMx SMCR */
6830  TIMx->SMCR = tmpsmcr;
6831 }

◆ TIM_ITRx_SetConfig()

static void TIM_ITRx_SetConfig ( TIM_TypeDef *  TIMx,
uint32_t  InputTriggerSource 
)
static

Selects the Input Trigger source.

Parameters
TIMxto select the TIM peripheral
InputTriggerSourceThe Input Trigger source. This parameter can be one of the following values:
  • TIM_TS_ITR0: Internal Trigger 0
  • TIM_TS_ITR1: Internal Trigger 1
  • TIM_TS_ITR2: Internal Trigger 2
  • TIM_TS_ITR3: Internal Trigger 3
  • TIM_TS_TI1F_ED: TI1 Edge Detector
  • TIM_TS_TI1FP1: Filtered Timer Input 1
  • TIM_TS_TI2FP2: Filtered Timer Input 2
  • TIM_TS_ETRF: External Trigger input
Return values
None

Definition at line 6786 of file stm32l4xx_hal_tim.c.

6787 {
6788  uint32_t tmpsmcr;
6789 
6790  /* Get the TIMx SMCR register value */
6791  tmpsmcr = TIMx->SMCR;
6792  /* Reset the TS Bits */
6793  tmpsmcr &= ~TIM_SMCR_TS;
6794  /* Set the Input Trigger source and the slave mode*/
6795  tmpsmcr |= (InputTriggerSource | TIM_SLAVEMODE_EXTERNAL1);
6796  /* Write to TIMx SMCR */
6797  TIMx->SMCR = tmpsmcr;
6798 }

◆ TIM_OC1_SetConfig()

static void TIM_OC1_SetConfig ( TIM_TypeDef *  TIMx,
TIM_OC_InitTypeDef OC_Config 
)
static

Timer Output Compare 1 configuration.

Parameters
TIMxto select the TIM peripheral
OC_ConfigThe ouput configuration structure
Return values
None

Definition at line 5999 of file stm32l4xx_hal_tim.c.

6000 {
6001  uint32_t tmpccmrx;
6002  uint32_t tmpccer;
6003  uint32_t tmpcr2;
6004 
6005  /* Disable the Channel 1: Reset the CC1E Bit */
6006  TIMx->CCER &= ~TIM_CCER_CC1E;
6007 
6008  /* Get the TIMx CCER register value */
6009  tmpccer = TIMx->CCER;
6010  /* Get the TIMx CR2 register value */
6011  tmpcr2 = TIMx->CR2;
6012 
6013  /* Get the TIMx CCMR1 register value */
6014  tmpccmrx = TIMx->CCMR1;
6015 
6016  /* Reset the Output Compare Mode Bits */
6017  tmpccmrx &= ~TIM_CCMR1_OC1M;
6018  tmpccmrx &= ~TIM_CCMR1_CC1S;
6019  /* Select the Output Compare Mode */
6020  tmpccmrx |= OC_Config->OCMode;
6021 
6022  /* Reset the Output Polarity level */
6023  tmpccer &= ~TIM_CCER_CC1P;
6024  /* Set the Output Compare Polarity */
6025  tmpccer |= OC_Config->OCPolarity;
6026 
6027  if (IS_TIM_CCXN_INSTANCE(TIMx, TIM_CHANNEL_1))
6028  {
6029  /* Check parameters */
6030  assert_param(IS_TIM_OCN_POLARITY(OC_Config->OCNPolarity));
6031 
6032  /* Reset the Output N Polarity level */
6033  tmpccer &= ~TIM_CCER_CC1NP;
6034  /* Set the Output N Polarity */
6035  tmpccer |= OC_Config->OCNPolarity;
6036  /* Reset the Output N State */
6037  tmpccer &= ~TIM_CCER_CC1NE;
6038  }
6039 
6040  if (IS_TIM_BREAK_INSTANCE(TIMx))
6041  {
6042  /* Check parameters */
6043  assert_param(IS_TIM_OCNIDLE_STATE(OC_Config->OCNIdleState));
6044  assert_param(IS_TIM_OCIDLE_STATE(OC_Config->OCIdleState));
6045 
6046  /* Reset the Output Compare and Output Compare N IDLE State */
6047  tmpcr2 &= ~TIM_CR2_OIS1;
6048  tmpcr2 &= ~TIM_CR2_OIS1N;
6049  /* Set the Output Idle state */
6050  tmpcr2 |= OC_Config->OCIdleState;
6051  /* Set the Output N Idle state */
6052  tmpcr2 |= OC_Config->OCNIdleState;
6053  }
6054 
6055  /* Write to TIMx CR2 */
6056  TIMx->CR2 = tmpcr2;
6057 
6058  /* Write to TIMx CCMR1 */
6059  TIMx->CCMR1 = tmpccmrx;
6060 
6061  /* Set the Capture Compare Register value */
6062  TIMx->CCR1 = OC_Config->Pulse;
6063 
6064  /* Write to TIMx CCER */
6065  TIMx->CCER = tmpccer;
6066 }
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ TIM_OC2_SetConfig()

void TIM_OC2_SetConfig ( TIM_TypeDef *  TIMx,
TIM_OC_InitTypeDef OC_Config 
)

Timer Output Compare 2 configuration.

Parameters
TIMxto select the TIM peripheral
OC_ConfigThe ouput configuration structure
Return values
None

Definition at line 6074 of file stm32l4xx_hal_tim.c.

6075 {
6076  uint32_t tmpccmrx;
6077  uint32_t tmpccer;
6078  uint32_t tmpcr2;
6079 
6080  /* Disable the Channel 2: Reset the CC2E Bit */
6081  TIMx->CCER &= ~TIM_CCER_CC2E;
6082 
6083  /* Get the TIMx CCER register value */
6084  tmpccer = TIMx->CCER;
6085  /* Get the TIMx CR2 register value */
6086  tmpcr2 = TIMx->CR2;
6087 
6088  /* Get the TIMx CCMR1 register value */
6089  tmpccmrx = TIMx->CCMR1;
6090 
6091  /* Reset the Output Compare mode and Capture/Compare selection Bits */
6092  tmpccmrx &= ~TIM_CCMR1_OC2M;
6093  tmpccmrx &= ~TIM_CCMR1_CC2S;
6094 
6095  /* Select the Output Compare Mode */
6096  tmpccmrx |= (OC_Config->OCMode << 8U);
6097 
6098  /* Reset the Output Polarity level */
6099  tmpccer &= ~TIM_CCER_CC2P;
6100  /* Set the Output Compare Polarity */
6101  tmpccer |= (OC_Config->OCPolarity << 4U);
6102 
6103  if (IS_TIM_CCXN_INSTANCE(TIMx, TIM_CHANNEL_2))
6104  {
6105  assert_param(IS_TIM_OCN_POLARITY(OC_Config->OCNPolarity));
6106 
6107  /* Reset the Output N Polarity level */
6108  tmpccer &= ~TIM_CCER_CC2NP;
6109  /* Set the Output N Polarity */
6110  tmpccer |= (OC_Config->OCNPolarity << 4U);
6111  /* Reset the Output N State */
6112  tmpccer &= ~TIM_CCER_CC2NE;
6113 
6114  }
6115 
6116  if (IS_TIM_BREAK_INSTANCE(TIMx))
6117  {
6118  /* Check parameters */
6119  assert_param(IS_TIM_OCNIDLE_STATE(OC_Config->OCNIdleState));
6120  assert_param(IS_TIM_OCIDLE_STATE(OC_Config->OCIdleState));
6121 
6122  /* Reset the Output Compare and Output Compare N IDLE State */
6123  tmpcr2 &= ~TIM_CR2_OIS2;
6124  tmpcr2 &= ~TIM_CR2_OIS2N;
6125  /* Set the Output Idle state */
6126  tmpcr2 |= (OC_Config->OCIdleState << 2U);
6127  /* Set the Output N Idle state */
6128  tmpcr2 |= (OC_Config->OCNIdleState << 2U);
6129  }
6130 
6131  /* Write to TIMx CR2 */
6132  TIMx->CR2 = tmpcr2;
6133 
6134  /* Write to TIMx CCMR1 */
6135  TIMx->CCMR1 = tmpccmrx;
6136 
6137  /* Set the Capture Compare Register value */
6138  TIMx->CCR2 = OC_Config->Pulse;
6139 
6140  /* Write to TIMx CCER */
6141  TIMx->CCER = tmpccer;
6142 }
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ TIM_OC3_SetConfig()

static void TIM_OC3_SetConfig ( TIM_TypeDef *  TIMx,
TIM_OC_InitTypeDef OC_Config 
)
static

Timer Output Compare 3 configuration.

Parameters
TIMxto select the TIM peripheral
OC_ConfigThe ouput configuration structure
Return values
None

Definition at line 6150 of file stm32l4xx_hal_tim.c.

6151 {
6152  uint32_t tmpccmrx;
6153  uint32_t tmpccer;
6154  uint32_t tmpcr2;
6155 
6156  /* Disable the Channel 3: Reset the CC2E Bit */
6157  TIMx->CCER &= ~TIM_CCER_CC3E;
6158 
6159  /* Get the TIMx CCER register value */
6160  tmpccer = TIMx->CCER;
6161  /* Get the TIMx CR2 register value */
6162  tmpcr2 = TIMx->CR2;
6163 
6164  /* Get the TIMx CCMR2 register value */
6165  tmpccmrx = TIMx->CCMR2;
6166 
6167  /* Reset the Output Compare mode and Capture/Compare selection Bits */
6168  tmpccmrx &= ~TIM_CCMR2_OC3M;
6169  tmpccmrx &= ~TIM_CCMR2_CC3S;
6170  /* Select the Output Compare Mode */
6171  tmpccmrx |= OC_Config->OCMode;
6172 
6173  /* Reset the Output Polarity level */
6174  tmpccer &= ~TIM_CCER_CC3P;
6175  /* Set the Output Compare Polarity */
6176  tmpccer |= (OC_Config->OCPolarity << 8U);
6177 
6178  if (IS_TIM_CCXN_INSTANCE(TIMx, TIM_CHANNEL_3))
6179  {
6180  assert_param(IS_TIM_OCN_POLARITY(OC_Config->OCNPolarity));
6181 
6182  /* Reset the Output N Polarity level */
6183  tmpccer &= ~TIM_CCER_CC3NP;
6184  /* Set the Output N Polarity */
6185  tmpccer |= (OC_Config->OCNPolarity << 8U);
6186  /* Reset the Output N State */
6187  tmpccer &= ~TIM_CCER_CC3NE;
6188  }
6189 
6190  if (IS_TIM_BREAK_INSTANCE(TIMx))
6191  {
6192  /* Check parameters */
6193  assert_param(IS_TIM_OCNIDLE_STATE(OC_Config->OCNIdleState));
6194  assert_param(IS_TIM_OCIDLE_STATE(OC_Config->OCIdleState));
6195 
6196  /* Reset the Output Compare and Output Compare N IDLE State */
6197  tmpcr2 &= ~TIM_CR2_OIS3;
6198  tmpcr2 &= ~TIM_CR2_OIS3N;
6199  /* Set the Output Idle state */
6200  tmpcr2 |= (OC_Config->OCIdleState << 4U);
6201  /* Set the Output N Idle state */
6202  tmpcr2 |= (OC_Config->OCNIdleState << 4U);
6203  }
6204 
6205  /* Write to TIMx CR2 */
6206  TIMx->CR2 = tmpcr2;
6207 
6208  /* Write to TIMx CCMR2 */
6209  TIMx->CCMR2 = tmpccmrx;
6210 
6211  /* Set the Capture Compare Register value */
6212  TIMx->CCR3 = OC_Config->Pulse;
6213 
6214  /* Write to TIMx CCER */
6215  TIMx->CCER = tmpccer;
6216 }
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ TIM_OC4_SetConfig()

static void TIM_OC4_SetConfig ( TIM_TypeDef *  TIMx,
TIM_OC_InitTypeDef OC_Config 
)
static

Timer Output Compare 4 configuration.

Parameters
TIMxto select the TIM peripheral
OC_ConfigThe ouput configuration structure
Return values
None

Definition at line 6224 of file stm32l4xx_hal_tim.c.

6225 {
6226  uint32_t tmpccmrx;
6227  uint32_t tmpccer;
6228  uint32_t tmpcr2;
6229 
6230  /* Disable the Channel 4: Reset the CC4E Bit */
6231  TIMx->CCER &= ~TIM_CCER_CC4E;
6232 
6233  /* Get the TIMx CCER register value */
6234  tmpccer = TIMx->CCER;
6235  /* Get the TIMx CR2 register value */
6236  tmpcr2 = TIMx->CR2;
6237 
6238  /* Get the TIMx CCMR2 register value */
6239  tmpccmrx = TIMx->CCMR2;
6240 
6241  /* Reset the Output Compare mode and Capture/Compare selection Bits */
6242  tmpccmrx &= ~TIM_CCMR2_OC4M;
6243  tmpccmrx &= ~TIM_CCMR2_CC4S;
6244 
6245  /* Select the Output Compare Mode */
6246  tmpccmrx |= (OC_Config->OCMode << 8U);
6247 
6248  /* Reset the Output Polarity level */
6249  tmpccer &= ~TIM_CCER_CC4P;
6250  /* Set the Output Compare Polarity */
6251  tmpccer |= (OC_Config->OCPolarity << 12U);
6252 
6253  if (IS_TIM_BREAK_INSTANCE(TIMx))
6254  {
6255  /* Check parameters */
6256  assert_param(IS_TIM_OCIDLE_STATE(OC_Config->OCIdleState));
6257 
6258  /* Reset the Output Compare IDLE State */
6259  tmpcr2 &= ~TIM_CR2_OIS4;
6260 
6261  /* Set the Output Idle state */
6262  tmpcr2 |= (OC_Config->OCIdleState << 6U);
6263  }
6264 
6265  /* Write to TIMx CR2 */
6266  TIMx->CR2 = tmpcr2;
6267 
6268  /* Write to TIMx CCMR2 */
6269  TIMx->CCMR2 = tmpccmrx;
6270 
6271  /* Set the Capture Compare Register value */
6272  TIMx->CCR4 = OC_Config->Pulse;
6273 
6274  /* Write to TIMx CCER */
6275  TIMx->CCER = tmpccer;
6276 }
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ TIM_OC5_SetConfig()

static void TIM_OC5_SetConfig ( TIM_TypeDef *  TIMx,
TIM_OC_InitTypeDef OC_Config 
)
static

Timer Output Compare 5 configuration.

Parameters
TIMxto select the TIM peripheral
OC_ConfigThe ouput configuration structure
Return values
None

Definition at line 6284 of file stm32l4xx_hal_tim.c.

6286 {
6287  uint32_t tmpccmrx;
6288  uint32_t tmpccer;
6289  uint32_t tmpcr2;
6290 
6291  /* Disable the output: Reset the CCxE Bit */
6292  TIMx->CCER &= ~TIM_CCER_CC5E;
6293 
6294  /* Get the TIMx CCER register value */
6295  tmpccer = TIMx->CCER;
6296  /* Get the TIMx CR2 register value */
6297  tmpcr2 = TIMx->CR2;
6298  /* Get the TIMx CCMR1 register value */
6299  tmpccmrx = TIMx->CCMR3;
6300 
6301  /* Reset the Output Compare Mode Bits */
6302  tmpccmrx &= ~(TIM_CCMR3_OC5M);
6303  /* Select the Output Compare Mode */
6304  tmpccmrx |= OC_Config->OCMode;
6305 
6306  /* Reset the Output Polarity level */
6307  tmpccer &= ~TIM_CCER_CC5P;
6308  /* Set the Output Compare Polarity */
6309  tmpccer |= (OC_Config->OCPolarity << 16U);
6310 
6311  if (IS_TIM_BREAK_INSTANCE(TIMx))
6312  {
6313  /* Reset the Output Compare IDLE State */
6314  tmpcr2 &= ~TIM_CR2_OIS5;
6315  /* Set the Output Idle state */
6316  tmpcr2 |= (OC_Config->OCIdleState << 8U);
6317  }
6318  /* Write to TIMx CR2 */
6319  TIMx->CR2 = tmpcr2;
6320 
6321  /* Write to TIMx CCMR3 */
6322  TIMx->CCMR3 = tmpccmrx;
6323 
6324  /* Set the Capture Compare Register value */
6325  TIMx->CCR5 = OC_Config->Pulse;
6326 
6327  /* Write to TIMx CCER */
6328  TIMx->CCER = tmpccer;
6329 }

◆ TIM_OC6_SetConfig()

static void TIM_OC6_SetConfig ( TIM_TypeDef *  TIMx,
TIM_OC_InitTypeDef OC_Config 
)
static

Timer Output Compare 6 configuration.

Parameters
TIMxto select the TIM peripheral
OC_ConfigThe ouput configuration structure
Return values
None

Definition at line 6337 of file stm32l4xx_hal_tim.c.

6339 {
6340  uint32_t tmpccmrx;
6341  uint32_t tmpccer;
6342  uint32_t tmpcr2;
6343 
6344  /* Disable the output: Reset the CCxE Bit */
6345  TIMx->CCER &= ~TIM_CCER_CC6E;
6346 
6347  /* Get the TIMx CCER register value */
6348  tmpccer = TIMx->CCER;
6349  /* Get the TIMx CR2 register value */
6350  tmpcr2 = TIMx->CR2;
6351  /* Get the TIMx CCMR1 register value */
6352  tmpccmrx = TIMx->CCMR3;
6353 
6354  /* Reset the Output Compare Mode Bits */
6355  tmpccmrx &= ~(TIM_CCMR3_OC6M);
6356  /* Select the Output Compare Mode */
6357  tmpccmrx |= (OC_Config->OCMode << 8U);
6358 
6359  /* Reset the Output Polarity level */
6360  tmpccer &= (uint32_t)~TIM_CCER_CC6P;
6361  /* Set the Output Compare Polarity */
6362  tmpccer |= (OC_Config->OCPolarity << 20U);
6363 
6364  if (IS_TIM_BREAK_INSTANCE(TIMx))
6365  {
6366  /* Reset the Output Compare IDLE State */
6367  tmpcr2 &= ~TIM_CR2_OIS6;
6368  /* Set the Output Idle state */
6369  tmpcr2 |= (OC_Config->OCIdleState << 10U);
6370  }
6371 
6372  /* Write to TIMx CR2 */
6373  TIMx->CR2 = tmpcr2;
6374 
6375  /* Write to TIMx CCMR3 */
6376  TIMx->CCMR3 = tmpccmrx;
6377 
6378  /* Set the Capture Compare Register value */
6379  TIMx->CCR6 = OC_Config->Pulse;
6380 
6381  /* Write to TIMx CCER */
6382  TIMx->CCER = tmpccer;
6383 }

◆ TIM_ResetCallback()

void TIM_ResetCallback ( TIM_HandleTypeDef htim)

Reset interrupt callbacks to the legacy weak callbacks.

Parameters
htimpointer to a TIM_HandleTypeDef structure that contains the configuration information for TIM module.
Return values
None

Definition at line 6872 of file stm32l4xx_hal_tim.c.

6873 {
6874  /* Reset the TIM callback to the legacy weak callbacks */
6875  htim->PeriodElapsedCallback = HAL_TIM_PeriodElapsedCallback; /* Legacy weak PeriodElapsedCallback */
6876  htim->PeriodElapsedHalfCpltCallback = HAL_TIM_PeriodElapsedHalfCpltCallback; /* Legacy weak PeriodElapsedHalfCpltCallback */
6877  htim->TriggerCallback = HAL_TIM_TriggerCallback; /* Legacy weak TriggerCallback */
6878  htim->TriggerHalfCpltCallback = HAL_TIM_TriggerHalfCpltCallback; /* Legacy weak TriggerHalfCpltCallback */
6879  htim->IC_CaptureCallback = HAL_TIM_IC_CaptureCallback; /* Legacy weak IC_CaptureCallback */
6880  htim->IC_CaptureHalfCpltCallback = HAL_TIM_IC_CaptureHalfCpltCallback; /* Legacy weak IC_CaptureHalfCpltCallback */
6881  htim->OC_DelayElapsedCallback = HAL_TIM_OC_DelayElapsedCallback; /* Legacy weak OC_DelayElapsedCallback */
6882  htim->PWM_PulseFinishedCallback = HAL_TIM_PWM_PulseFinishedCallback; /* Legacy weak PWM_PulseFinishedCallback */
6883  htim->PWM_PulseFinishedHalfCpltCallback = HAL_TIM_PWM_PulseFinishedHalfCpltCallback; /* Legacy weak PWM_PulseFinishedHalfCpltCallback */
6884  htim->ErrorCallback = HAL_TIM_ErrorCallback; /* Legacy weak ErrorCallback */
6885  htim->CommutationCallback = HAL_TIMEx_CommutCallback; /* Legacy weak CommutationCallback */
6886  htim->CommutationHalfCpltCallback = HAL_TIMEx_CommutHalfCpltCallback; /* Legacy weak CommutationHalfCpltCallback */
6887  htim->BreakCallback = HAL_TIMEx_BreakCallback; /* Legacy weak BreakCallback */
6888  htim->Break2Callback = HAL_TIMEx_Break2Callback; /* Legacy weak Break2Callback */
6889 }
void HAL_TIM_PWM_PulseFinishedHalfCpltCallback(TIM_HandleTypeDef *htim)
PWM Pulse finished half complete callback in non-blocking mode.
void HAL_TIMEx_BreakCallback(TIM_HandleTypeDef *htim)
Hall Break detection callback in non-blocking mode.
void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim)
PWM Pulse finished callback in non-blocking mode.
void HAL_TIM_ErrorCallback(TIM_HandleTypeDef *htim)
Timer error callback in non-blocking mode.
void HAL_TIM_IC_CaptureHalfCpltCallback(TIM_HandleTypeDef *htim)
Input Capture half complete callback in non-blocking mode.
void HAL_TIMEx_CommutCallback(TIM_HandleTypeDef *htim)
Hall commutation changed callback in non-blocking mode.
void HAL_TIMEx_CommutHalfCpltCallback(TIM_HandleTypeDef *htim)
Hall commutation changed half complete callback in non-blocking mode.
void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim)
Output Compare callback in non-blocking mode.
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
Period elapsed callback in non-blocking mode.
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
Input Capture callback in non-blocking mode.
void HAL_TIMEx_Break2Callback(TIM_HandleTypeDef *htim)
Hall Break2 detection callback in non blocking mode.
void HAL_TIM_TriggerHalfCpltCallback(TIM_HandleTypeDef *htim)
Hall Trigger detection half complete callback in non-blocking mode.
void HAL_TIM_PeriodElapsedHalfCpltCallback(TIM_HandleTypeDef *htim)
Period elapsed half complete callback in non-blocking mode.
void HAL_TIM_TriggerCallback(TIM_HandleTypeDef *htim)
Hall Trigger detection callback in non-blocking mode.

◆ TIM_SlaveTimer_SetConfig()

static HAL_StatusTypeDef TIM_SlaveTimer_SetConfig ( TIM_HandleTypeDef htim,
TIM_SlaveConfigTypeDef sSlaveConfig 
)
static

Slave Timer configuration function.

Parameters
htimTIM handle
sSlaveConfigSlave timer configuration
Return values
None

Definition at line 6391 of file stm32l4xx_hal_tim.c.

6393 {
6394  uint32_t tmpsmcr;
6395  uint32_t tmpccmr1;
6396  uint32_t tmpccer;
6397 
6398  /* Get the TIMx SMCR register value */
6399  tmpsmcr = htim->Instance->SMCR;
6400 
6401  /* Reset the Trigger Selection Bits */
6402  tmpsmcr &= ~TIM_SMCR_TS;
6403  /* Set the Input Trigger source */
6404  tmpsmcr |= sSlaveConfig->InputTrigger;
6405 
6406  /* Reset the slave mode Bits */
6407  tmpsmcr &= ~TIM_SMCR_SMS;
6408  /* Set the slave mode */
6409  tmpsmcr |= sSlaveConfig->SlaveMode;
6410 
6411  /* Write to TIMx SMCR */
6412  htim->Instance->SMCR = tmpsmcr;
6413 
6414  /* Configure the trigger prescaler, filter, and polarity */
6415  switch (sSlaveConfig->InputTrigger)
6416  {
6417  case TIM_TS_ETRF:
6418  {
6419  /* Check the parameters */
6420  assert_param(IS_TIM_CLOCKSOURCE_ETRMODE1_INSTANCE(htim->Instance));
6421  assert_param(IS_TIM_TRIGGERPRESCALER(sSlaveConfig->TriggerPrescaler));
6422  assert_param(IS_TIM_TRIGGERPOLARITY(sSlaveConfig->TriggerPolarity));
6423  assert_param(IS_TIM_TRIGGERFILTER(sSlaveConfig->TriggerFilter));
6424  /* Configure the ETR Trigger source */
6425  TIM_ETR_SetConfig(htim->Instance,
6426  sSlaveConfig->TriggerPrescaler,
6427  sSlaveConfig->TriggerPolarity,
6428  sSlaveConfig->TriggerFilter);
6429  break;
6430  }
6431 
6432  case TIM_TS_TI1F_ED:
6433  {
6434  /* Check the parameters */
6435  assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
6436  assert_param(IS_TIM_TRIGGERFILTER(sSlaveConfig->TriggerFilter));
6437 
6438  if(sSlaveConfig->SlaveMode == TIM_SLAVEMODE_GATED)
6439  {
6440  return HAL_ERROR;
6441  }
6442 
6443  /* Disable the Channel 1: Reset the CC1E Bit */
6444  tmpccer = htim->Instance->CCER;
6445  htim->Instance->CCER &= ~TIM_CCER_CC1E;
6446  tmpccmr1 = htim->Instance->CCMR1;
6447 
6448  /* Set the filter */
6449  tmpccmr1 &= ~TIM_CCMR1_IC1F;
6450  tmpccmr1 |= ((sSlaveConfig->TriggerFilter) << 4U);
6451 
6452  /* Write to TIMx CCMR1 and CCER registers */
6453  htim->Instance->CCMR1 = tmpccmr1;
6454  htim->Instance->CCER = tmpccer;
6455  break;
6456  }
6457 
6458  case TIM_TS_TI1FP1:
6459  {
6460  /* Check the parameters */
6461  assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
6462  assert_param(IS_TIM_TRIGGERPOLARITY(sSlaveConfig->TriggerPolarity));
6463  assert_param(IS_TIM_TRIGGERFILTER(sSlaveConfig->TriggerFilter));
6464 
6465  /* Configure TI1 Filter and Polarity */
6466  TIM_TI1_ConfigInputStage(htim->Instance,
6467  sSlaveConfig->TriggerPolarity,
6468  sSlaveConfig->TriggerFilter);
6469  break;
6470  }
6471 
6472  case TIM_TS_TI2FP2:
6473  {
6474  /* Check the parameters */
6475  assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
6476  assert_param(IS_TIM_TRIGGERPOLARITY(sSlaveConfig->TriggerPolarity));
6477  assert_param(IS_TIM_TRIGGERFILTER(sSlaveConfig->TriggerFilter));
6478 
6479  /* Configure TI2 Filter and Polarity */
6480  TIM_TI2_ConfigInputStage(htim->Instance,
6481  sSlaveConfig->TriggerPolarity,
6482  sSlaveConfig->TriggerFilter);
6483  break;
6484  }
6485 
6486  case TIM_TS_ITR0:
6487  case TIM_TS_ITR1:
6488  case TIM_TS_ITR2:
6489  case TIM_TS_ITR3:
6490  {
6491  /* Check the parameter */
6492  assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
6493  break;
6494  }
6495 
6496  default:
6497  break;
6498  }
6499  return HAL_OK;
6500 }
static void TIM_TI1_ConfigInputStage(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICFilter)
Configure the Polarity and Filter for TI1.
static void TIM_TI2_ConfigInputStage(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICFilter)
Configure the Polarity and Filter for TI2.
return HAL_OK
void TIM_ETR_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ExtTRGPrescaler, uint32_t TIM_ExtTRGPolarity, uint32_t ExtTRGFilter)
Configures the TIMx External Trigger (ETR).
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ TIM_TI1_ConfigInputStage()

static void TIM_TI1_ConfigInputStage ( TIM_TypeDef *  TIMx,
uint32_t  TIM_ICPolarity,
uint32_t  TIM_ICFilter 
)
static

Configure the Polarity and Filter for TI1.

Parameters
TIMxto select the TIM peripheral.
TIM_ICPolarityThe Input Polarity. This parameter can be one of the following values:
  • TIM_ICPOLARITY_RISING
  • TIM_ICPOLARITY_FALLING
  • TIM_ICPOLARITY_BOTHEDGE
TIM_ICFilterSpecifies the Input Capture Filter. This parameter must be a value between 0x00 and 0x0F.
Return values
None

Definition at line 6569 of file stm32l4xx_hal_tim.c.

6570 {
6571  uint32_t tmpccmr1;
6572  uint32_t tmpccer;
6573 
6574  /* Disable the Channel 1: Reset the CC1E Bit */
6575  tmpccer = TIMx->CCER;
6576  TIMx->CCER &= ~TIM_CCER_CC1E;
6577  tmpccmr1 = TIMx->CCMR1;
6578 
6579  /* Set the filter */
6580  tmpccmr1 &= ~TIM_CCMR1_IC1F;
6581  tmpccmr1 |= (TIM_ICFilter << 4U);
6582 
6583  /* Select the Polarity and set the CC1E Bit */
6584  tmpccer &= ~(TIM_CCER_CC1P | TIM_CCER_CC1NP);
6585  tmpccer |= TIM_ICPolarity;
6586 
6587  /* Write to TIMx CCMR1 and CCER registers */
6588  TIMx->CCMR1 = tmpccmr1;
6589  TIMx->CCER = tmpccer;
6590 }

◆ TIM_TI1_SetConfig()

void TIM_TI1_SetConfig ( TIM_TypeDef *  TIMx,
uint32_t  TIM_ICPolarity,
uint32_t  TIM_ICSelection,
uint32_t  TIM_ICFilter 
)

Configure the TI1 as Input.

Parameters
TIMxto select the TIM peripheral.
TIM_ICPolarityThe Input Polarity. This parameter can be one of the following values:
  • TIM_ICPOLARITY_RISING
  • TIM_ICPOLARITY_FALLING
  • TIM_ICPOLARITY_BOTHEDGE
TIM_ICSelectionspecifies the input to be used. This parameter can be one of the following values:
  • TIM_ICSELECTION_DIRECTTI: TIM Input 1 is selected to be connected to IC1.
  • TIM_ICSELECTION_INDIRECTTI: TIM Input 1 is selected to be connected to IC2.
  • TIM_ICSELECTION_TRC: TIM Input 1 is selected to be connected to TRC.
TIM_ICFilterSpecifies the Input Capture Filter. This parameter must be a value between 0x00 and 0x0F.
Return values
None
Note
TIM_ICFilter and TIM_ICPolarity are not used in INDIRECT mode as TI2FP1 (on channel2 path) is used as the input signal. Therefore CCMR1 must be protected against un-initialized filter and polarity values.

Definition at line 6522 of file stm32l4xx_hal_tim.c.

6524 {
6525  uint32_t tmpccmr1;
6526  uint32_t tmpccer;
6527 
6528  /* Disable the Channel 1: Reset the CC1E Bit */
6529  TIMx->CCER &= ~TIM_CCER_CC1E;
6530  tmpccmr1 = TIMx->CCMR1;
6531  tmpccer = TIMx->CCER;
6532 
6533  /* Select the Input */
6534  if (IS_TIM_CC2_INSTANCE(TIMx) != RESET)
6535  {
6536  tmpccmr1 &= ~TIM_CCMR1_CC1S;
6537  tmpccmr1 |= TIM_ICSelection;
6538  }
6539  else
6540  {
6541  tmpccmr1 |= TIM_CCMR1_CC1S_0;
6542  }
6543 
6544  /* Set the filter */
6545  tmpccmr1 &= ~TIM_CCMR1_IC1F;
6546  tmpccmr1 |= ((TIM_ICFilter << 4U) & TIM_CCMR1_IC1F);
6547 
6548  /* Select the Polarity and set the CC1E Bit */
6549  tmpccer &= ~(TIM_CCER_CC1P | TIM_CCER_CC1NP);
6550  tmpccer |= (TIM_ICPolarity & (TIM_CCER_CC1P | TIM_CCER_CC1NP));
6551 
6552  /* Write to TIMx CCMR1 and CCER registers */
6553  TIMx->CCMR1 = tmpccmr1;
6554  TIMx->CCER = tmpccer;
6555 }

◆ TIM_TI2_ConfigInputStage()

static void TIM_TI2_ConfigInputStage ( TIM_TypeDef *  TIMx,
uint32_t  TIM_ICPolarity,
uint32_t  TIM_ICFilter 
)
static

Configure the Polarity and Filter for TI2.

Parameters
TIMxto select the TIM peripheral.
TIM_ICPolarityThe Input Polarity. This parameter can be one of the following values:
  • TIM_ICPOLARITY_RISING
  • TIM_ICPOLARITY_FALLING
  • TIM_ICPOLARITY_BOTHEDGE
TIM_ICFilterSpecifies the Input Capture Filter. This parameter must be a value between 0x00 and 0x0F.
Return values
None

Definition at line 6652 of file stm32l4xx_hal_tim.c.

6653 {
6654  uint32_t tmpccmr1;
6655  uint32_t tmpccer;
6656 
6657  /* Disable the Channel 2: Reset the CC2E Bit */
6658  TIMx->CCER &= ~TIM_CCER_CC2E;
6659  tmpccmr1 = TIMx->CCMR1;
6660  tmpccer = TIMx->CCER;
6661 
6662  /* Set the filter */
6663  tmpccmr1 &= ~TIM_CCMR1_IC2F;
6664  tmpccmr1 |= (TIM_ICFilter << 12U);
6665 
6666  /* Select the Polarity and set the CC2E Bit */
6667  tmpccer &= ~(TIM_CCER_CC2P | TIM_CCER_CC2NP);
6668  tmpccer |= (TIM_ICPolarity << 4U);
6669 
6670  /* Write to TIMx CCMR1 and CCER registers */
6671  TIMx->CCMR1 = tmpccmr1 ;
6672  TIMx->CCER = tmpccer;
6673 }

◆ TIM_TI2_SetConfig()

static void TIM_TI2_SetConfig ( TIM_TypeDef *  TIMx,
uint32_t  TIM_ICPolarity,
uint32_t  TIM_ICSelection,
uint32_t  TIM_ICFilter 
)
static

Configure the TI2 as Input.

Parameters
TIMxto select the TIM peripheral
TIM_ICPolarityThe Input Polarity. This parameter can be one of the following values:
  • TIM_ICPOLARITY_RISING
  • TIM_ICPOLARITY_FALLING
  • TIM_ICPOLARITY_BOTHEDGE
TIM_ICSelectionspecifies the input to be used. This parameter can be one of the following values:
  • TIM_ICSELECTION_DIRECTTI: TIM Input 2 is selected to be connected to IC2.
  • TIM_ICSELECTION_INDIRECTTI: TIM Input 2 is selected to be connected to IC1.
  • TIM_ICSELECTION_TRC: TIM Input 2 is selected to be connected to TRC.
TIM_ICFilterSpecifies the Input Capture Filter. This parameter must be a value between 0x00 and 0x0F.
Return values
None
Note
TIM_ICFilter and TIM_ICPolarity are not used in INDIRECT mode as TI1FP2 (on channel1 path) is used as the input signal. Therefore CCMR1 must be protected against un-initialized filter and polarity values.

Definition at line 6612 of file stm32l4xx_hal_tim.c.

6614 {
6615  uint32_t tmpccmr1;
6616  uint32_t tmpccer;
6617 
6618  /* Disable the Channel 2: Reset the CC2E Bit */
6619  TIMx->CCER &= ~TIM_CCER_CC2E;
6620  tmpccmr1 = TIMx->CCMR1;
6621  tmpccer = TIMx->CCER;
6622 
6623  /* Select the Input */
6624  tmpccmr1 &= ~TIM_CCMR1_CC2S;
6625  tmpccmr1 |= (TIM_ICSelection << 8U);
6626 
6627  /* Set the filter */
6628  tmpccmr1 &= ~TIM_CCMR1_IC2F;
6629  tmpccmr1 |= ((TIM_ICFilter << 12U) & TIM_CCMR1_IC2F);
6630 
6631  /* Select the Polarity and set the CC2E Bit */
6632  tmpccer &= ~(TIM_CCER_CC2P | TIM_CCER_CC2NP);
6633  tmpccer |= ((TIM_ICPolarity << 4U) & (TIM_CCER_CC2P | TIM_CCER_CC2NP));
6634 
6635  /* Write to TIMx CCMR1 and CCER registers */
6636  TIMx->CCMR1 = tmpccmr1 ;
6637  TIMx->CCER = tmpccer;
6638 }

◆ TIM_TI3_SetConfig()

static void TIM_TI3_SetConfig ( TIM_TypeDef *  TIMx,
uint32_t  TIM_ICPolarity,
uint32_t  TIM_ICSelection,
uint32_t  TIM_ICFilter 
)
static

Configure the TI3 as Input.

Parameters
TIMxto select the TIM peripheral
TIM_ICPolarityThe Input Polarity. This parameter can be one of the following values:
  • TIM_ICPOLARITY_RISING
  • TIM_ICPOLARITY_FALLING
  • TIM_ICPOLARITY_BOTHEDGE
TIM_ICSelectionspecifies the input to be used. This parameter can be one of the following values:
  • TIM_ICSELECTION_DIRECTTI: TIM Input 3 is selected to be connected to IC3.
  • TIM_ICSELECTION_INDIRECTTI: TIM Input 3 is selected to be connected to IC4.
  • TIM_ICSELECTION_TRC: TIM Input 3 is selected to be connected to TRC.
TIM_ICFilterSpecifies the Input Capture Filter. This parameter must be a value between 0x00 and 0x0F.
Return values
None
Note
TIM_ICFilter and TIM_ICPolarity are not used in INDIRECT mode as TI3FP4 (on channel1 path) is used as the input signal. Therefore CCMR2 must be protected against un-initialized filter and polarity values.

Definition at line 6695 of file stm32l4xx_hal_tim.c.

6697 {
6698  uint32_t tmpccmr2;
6699  uint32_t tmpccer;
6700 
6701  /* Disable the Channel 3: Reset the CC3E Bit */
6702  TIMx->CCER &= ~TIM_CCER_CC3E;
6703  tmpccmr2 = TIMx->CCMR2;
6704  tmpccer = TIMx->CCER;
6705 
6706  /* Select the Input */
6707  tmpccmr2 &= ~TIM_CCMR2_CC3S;
6708  tmpccmr2 |= TIM_ICSelection;
6709 
6710  /* Set the filter */
6711  tmpccmr2 &= ~TIM_CCMR2_IC3F;
6712  tmpccmr2 |= ((TIM_ICFilter << 4U) & TIM_CCMR2_IC3F);
6713 
6714  /* Select the Polarity and set the CC3E Bit */
6715  tmpccer &= ~(TIM_CCER_CC3P | TIM_CCER_CC3NP);
6716  tmpccer |= ((TIM_ICPolarity << 8U) & (TIM_CCER_CC3P | TIM_CCER_CC3NP));
6717 
6718  /* Write to TIMx CCMR2 and CCER registers */
6719  TIMx->CCMR2 = tmpccmr2;
6720  TIMx->CCER = tmpccer;
6721 }

◆ TIM_TI4_SetConfig()

static void TIM_TI4_SetConfig ( TIM_TypeDef *  TIMx,
uint32_t  TIM_ICPolarity,
uint32_t  TIM_ICSelection,
uint32_t  TIM_ICFilter 
)
static

Configure the TI4 as Input.

Parameters
TIMxto select the TIM peripheral
TIM_ICPolarityThe Input Polarity. This parameter can be one of the following values:
  • TIM_ICPOLARITY_RISING
  • TIM_ICPOLARITY_FALLING
  • TIM_ICPOLARITY_BOTHEDGE
TIM_ICSelectionspecifies the input to be used. This parameter can be one of the following values:
  • TIM_ICSELECTION_DIRECTTI: TIM Input 4 is selected to be connected to IC4.
  • TIM_ICSELECTION_INDIRECTTI: TIM Input 4 is selected to be connected to IC3.
  • TIM_ICSELECTION_TRC: TIM Input 4 is selected to be connected to TRC.
TIM_ICFilterSpecifies the Input Capture Filter. This parameter must be a value between 0x00 and 0x0F.
Note
TIM_ICFilter and TIM_ICPolarity are not used in INDIRECT mode as TI4FP3 (on channel1 path) is used as the input signal. Therefore CCMR2 must be protected against un-initialized filter and polarity values.
Return values
None

Definition at line 6743 of file stm32l4xx_hal_tim.c.

6745 {
6746  uint32_t tmpccmr2;
6747  uint32_t tmpccer;
6748 
6749  /* Disable the Channel 4: Reset the CC4E Bit */
6750  TIMx->CCER &= ~TIM_CCER_CC4E;
6751  tmpccmr2 = TIMx->CCMR2;
6752  tmpccer = TIMx->CCER;
6753 
6754  /* Select the Input */
6755  tmpccmr2 &= ~TIM_CCMR2_CC4S;
6756  tmpccmr2 |= (TIM_ICSelection << 8U);
6757 
6758  /* Set the filter */
6759  tmpccmr2 &= ~TIM_CCMR2_IC4F;
6760  tmpccmr2 |= ((TIM_ICFilter << 12U) & TIM_CCMR2_IC4F);
6761 
6762  /* Select the Polarity and set the CC4E Bit */
6763  tmpccer &= ~(TIM_CCER_CC4P | TIM_CCER_CC4NP);
6764  tmpccer |= ((TIM_ICPolarity << 12U) & (TIM_CCER_CC4P | TIM_CCER_CC4NP));
6765 
6766  /* Write to TIMx CCMR2 and CCER registers */
6767  TIMx->CCMR2 = tmpccmr2;
6768  TIMx->CCER = tmpccer ;
6769 }