STM32L4xx_HAL_Driver  1.14.0
TIM One Pulse functions

TIM One Pulse functions. More...

Functions

HAL_StatusTypeDef HAL_TIM_OnePulse_Init (TIM_HandleTypeDef *htim, uint32_t OnePulseMode)
 Initializes the TIM One Pulse Time Base according to the specified parameters in the TIM_HandleTypeDef and initializes the associated handle. More...
 
HAL_StatusTypeDef HAL_TIM_OnePulse_DeInit (TIM_HandleTypeDef *htim)
 DeInitializes the TIM One Pulse. More...
 
void HAL_TIM_OnePulse_MspInit (TIM_HandleTypeDef *htim)
 Initializes the TIM One Pulse MSP. More...
 
void HAL_TIM_OnePulse_MspDeInit (TIM_HandleTypeDef *htim)
 DeInitializes TIM One Pulse MSP. More...
 
HAL_StatusTypeDef HAL_TIM_OnePulse_Start (TIM_HandleTypeDef *htim, uint32_t OutputChannel)
 Starts the TIM One Pulse signal generation. More...
 
HAL_StatusTypeDef HAL_TIM_OnePulse_Stop (TIM_HandleTypeDef *htim, uint32_t OutputChannel)
 Stops the TIM One Pulse signal generation. More...
 
HAL_StatusTypeDef HAL_TIM_OnePulse_Start_IT (TIM_HandleTypeDef *htim, uint32_t OutputChannel)
 Starts the TIM One Pulse signal generation in interrupt mode. More...
 
HAL_StatusTypeDef HAL_TIM_OnePulse_Stop_IT (TIM_HandleTypeDef *htim, uint32_t OutputChannel)
 Stops the TIM One Pulse signal generation in interrupt mode. More...
 

Detailed Description

TIM One Pulse functions.

  ==============================================================================
                        ##### TIM One Pulse functions #####
  ==============================================================================
  [..]
    This section provides functions allowing to:
    (+) Initialize and configure the TIM One Pulse.
    (+) De-initialize the TIM One Pulse.
    (+) Start the TIM One Pulse.
    (+) Stop the TIM One Pulse.
    (+) Start the TIM One Pulse and enable interrupt.
    (+) Stop the TIM One Pulse and disable interrupt.
    (+) Start the TIM One Pulse and enable DMA transfer.
    (+) Stop the TIM One Pulse and disable DMA transfer.

Function Documentation

◆ HAL_TIM_OnePulse_DeInit()

HAL_StatusTypeDef HAL_TIM_OnePulse_DeInit ( TIM_HandleTypeDef htim)

DeInitializes the TIM One Pulse.

Parameters
htimTIM One Pulse handle
Return values
HALstatus

Definition at line 2353 of file stm32l4xx_hal_tim.c.

2354 {
2355  /* Check the parameters */
2356  assert_param(IS_TIM_INSTANCE(htim->Instance));
2357 
2358  htim->State = HAL_TIM_STATE_BUSY;
2359 
2360  /* Disable the TIM Peripheral Clock */
2361  __HAL_TIM_DISABLE(htim);
2362 
2363 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
2364  if (htim->OnePulse_MspDeInitCallback == NULL)
2365  {
2366  htim->OnePulse_MspDeInitCallback = HAL_TIM_OnePulse_MspDeInit;
2367  }
2368  /* DeInit the low level hardware */
2369  htim->OnePulse_MspDeInitCallback(htim);
2370 #else
2371  /* DeInit the low level hardware: GPIO, CLOCK, NVIC */
2373 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
2374 
2375  /* Change TIM state */
2376  htim->State = HAL_TIM_STATE_RESET;
2377 
2378  /* Release Lock */
2379  __HAL_UNLOCK(htim);
2380 
2381  return HAL_OK;
2382 }
__HAL_UNLOCK(hrtc)
void HAL_TIM_OnePulse_MspDeInit(TIM_HandleTypeDef *htim)
DeInitializes TIM One Pulse MSP.
return HAL_OK
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_TIM_OnePulse_Init()

HAL_StatusTypeDef HAL_TIM_OnePulse_Init ( TIM_HandleTypeDef htim,
uint32_t  OnePulseMode 
)

Initializes the TIM One Pulse Time Base according to the specified parameters in the TIM_HandleTypeDef and initializes the associated handle.

Note
Switching from Center Aligned counter mode to Edge counter mode (or reverse) requires a timer reset to avoid unexpected direction due to DIR bit readonly in center aligned mode. Ex: call HAL_TIM_OnePulse_DeInit() before HAL_TIM_OnePulse_Init()
Parameters
htimTIM One Pulse handle
OnePulseModeSelect the One pulse mode. This parameter can be one of the following values:
  • TIM_OPMODE_SINGLE: Only one pulse will be generated.
  • TIM_OPMODE_REPETITIVE: Repetitive pulses will be generated.
Return values
HALstatus

Definition at line 2294 of file stm32l4xx_hal_tim.c.

2295 {
2296  /* Check the TIM handle allocation */
2297  if (htim == NULL)
2298  {
2299  return HAL_ERROR;
2300  }
2301 
2302  /* Check the parameters */
2303  assert_param(IS_TIM_INSTANCE(htim->Instance));
2304  assert_param(IS_TIM_COUNTER_MODE(htim->Init.CounterMode));
2305  assert_param(IS_TIM_CLOCKDIVISION_DIV(htim->Init.ClockDivision));
2306  assert_param(IS_TIM_OPM_MODE(OnePulseMode));
2307  assert_param(IS_TIM_AUTORELOAD_PRELOAD(htim->Init.AutoReloadPreload));
2308 
2309  if (htim->State == HAL_TIM_STATE_RESET)
2310  {
2311  /* Allocate lock resource and initialize it */
2312  htim->Lock = HAL_UNLOCKED;
2313 
2314 #if (USE_HAL_TIM_REGISTER_CALLBACKS == 1)
2315  /* Reset interrupt callbacks to legacy weak callbacks */
2316  TIM_ResetCallback(htim);
2317 
2318  if (htim->OnePulse_MspInitCallback == NULL)
2319  {
2320  htim->OnePulse_MspInitCallback = HAL_TIM_OnePulse_MspInit;
2321  }
2322  /* Init the low level hardware : GPIO, CLOCK, NVIC */
2323  htim->OnePulse_MspInitCallback(htim);
2324 #else
2325  /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
2327 #endif /* USE_HAL_TIM_REGISTER_CALLBACKS */
2328  }
2329 
2330  /* Set the TIM state */
2331  htim->State = HAL_TIM_STATE_BUSY;
2332 
2333  /* Configure the Time base in the One Pulse Mode */
2334  TIM_Base_SetConfig(htim->Instance, &htim->Init);
2335 
2336  /* Reset the OPM Bit */
2337  htim->Instance->CR1 &= ~TIM_CR1_OPM;
2338 
2339  /* Configure the OPM Mode */
2340  htim->Instance->CR1 |= OnePulseMode;
2341 
2342  /* Initialize the TIM state*/
2343  htim->State = HAL_TIM_STATE_READY;
2344 
2345  return HAL_OK;
2346 }
void TIM_Base_SetConfig(TIM_TypeDef *TIMx, TIM_Base_InitTypeDef *Structure)
Time Base configuration.
void TIM_ResetCallback(TIM_HandleTypeDef *htim)
Reset interrupt callbacks to the legacy weak callbacks.
return HAL_OK
void HAL_TIM_OnePulse_MspInit(TIM_HandleTypeDef *htim)
Initializes the TIM One Pulse MSP.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_TIM_OnePulse_MspDeInit()

__weak void HAL_TIM_OnePulse_MspDeInit ( TIM_HandleTypeDef htim)

DeInitializes TIM One Pulse MSP.

Parameters
htimTIM One Pulse handle
Return values
None

Definition at line 2404 of file stm32l4xx_hal_tim.c.

2405 {
2406  /* Prevent unused argument(s) compilation warning */
2407  UNUSED(htim);
2408 
2409  /* NOTE : This function should not be modified, when the callback is needed,
2410  the HAL_TIM_OnePulse_MspDeInit could be implemented in the user file
2411  */
2412 }

◆ HAL_TIM_OnePulse_MspInit()

__weak void HAL_TIM_OnePulse_MspInit ( TIM_HandleTypeDef htim)

Initializes the TIM One Pulse MSP.

Parameters
htimTIM One Pulse handle
Return values
None

Definition at line 2389 of file stm32l4xx_hal_tim.c.

2390 {
2391  /* Prevent unused argument(s) compilation warning */
2392  UNUSED(htim);
2393 
2394  /* NOTE : This function should not be modified, when the callback is needed,
2395  the HAL_TIM_OnePulse_MspInit could be implemented in the user file
2396  */
2397 }

◆ HAL_TIM_OnePulse_Start()

HAL_StatusTypeDef HAL_TIM_OnePulse_Start ( TIM_HandleTypeDef htim,
uint32_t  OutputChannel 
)

Starts the TIM One Pulse signal generation.

Parameters
htimTIM One Pulse handle
OutputChannelTIM Channels to be enabled This parameter can be one of the following values:
  • TIM_CHANNEL_1: TIM Channel 1 selected
  • TIM_CHANNEL_2: TIM Channel 2 selected
Return values
HALstatus

Definition at line 2423 of file stm32l4xx_hal_tim.c.

2424 {
2425  /* Prevent unused argument(s) compilation warning */
2426  UNUSED(OutputChannel);
2427 
2428  /* Enable the Capture compare and the Input Capture channels
2429  (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
2430  if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
2431  if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
2432  in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be enabled together
2433 
2434  No need to enable the counter, it's enabled automatically by hardware
2435  (the counter starts in response to a stimulus and generate a pulse */
2436 
2437  TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
2438  TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
2439 
2440  if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
2441  {
2442  /* Enable the main output */
2443  __HAL_TIM_MOE_ENABLE(htim);
2444  }
2445 
2446  /* Return function status */
2447  return HAL_OK;
2448 }
return HAL_OK
void TIM_CCxChannelCmd(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ChannelState)
Enables or disables the TIM Capture Compare Channel x.

◆ HAL_TIM_OnePulse_Start_IT()

HAL_StatusTypeDef HAL_TIM_OnePulse_Start_IT ( TIM_HandleTypeDef htim,
uint32_t  OutputChannel 
)

Starts the TIM One Pulse signal generation in interrupt mode.

Parameters
htimTIM One Pulse handle
OutputChannelTIM Channels to be enabled This parameter can be one of the following values:
  • TIM_CHANNEL_1: TIM Channel 1 selected
  • TIM_CHANNEL_2: TIM Channel 2 selected
Return values
HALstatus

Definition at line 2495 of file stm32l4xx_hal_tim.c.

2496 {
2497  /* Prevent unused argument(s) compilation warning */
2498  UNUSED(OutputChannel);
2499 
2500  /* Enable the Capture compare and the Input Capture channels
2501  (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
2502  if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
2503  if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
2504  in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be enabled together
2505 
2506  No need to enable the counter, it's enabled automatically by hardware
2507  (the counter starts in response to a stimulus and generate a pulse */
2508 
2509  /* Enable the TIM Capture/Compare 1 interrupt */
2510  __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC1);
2511 
2512  /* Enable the TIM Capture/Compare 2 interrupt */
2513  __HAL_TIM_ENABLE_IT(htim, TIM_IT_CC2);
2514 
2515  TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
2516  TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
2517 
2518  if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
2519  {
2520  /* Enable the main output */
2521  __HAL_TIM_MOE_ENABLE(htim);
2522  }
2523 
2524  /* Return function status */
2525  return HAL_OK;
2526 }
return HAL_OK
void TIM_CCxChannelCmd(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ChannelState)
Enables or disables the TIM Capture Compare Channel x.

◆ HAL_TIM_OnePulse_Stop()

HAL_StatusTypeDef HAL_TIM_OnePulse_Stop ( TIM_HandleTypeDef htim,
uint32_t  OutputChannel 
)

Stops the TIM One Pulse signal generation.

Parameters
htimTIM One Pulse handle
OutputChannelTIM Channels to be disable This parameter can be one of the following values:
  • TIM_CHANNEL_1: TIM Channel 1 selected
  • TIM_CHANNEL_2: TIM Channel 2 selected
Return values
HALstatus

Definition at line 2459 of file stm32l4xx_hal_tim.c.

2460 {
2461  /* Prevent unused argument(s) compilation warning */
2462  UNUSED(OutputChannel);
2463 
2464  /* Disable the Capture compare and the Input Capture channels
2465  (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
2466  if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
2467  if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
2468  in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be disabled together */
2469 
2470  TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
2471  TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_DISABLE);
2472 
2473  if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
2474  {
2475  /* Disable the Main Output */
2476  __HAL_TIM_MOE_DISABLE(htim);
2477  }
2478 
2479  /* Disable the Peripheral */
2480  __HAL_TIM_DISABLE(htim);
2481 
2482  /* Return function status */
2483  return HAL_OK;
2484 }
return HAL_OK
void TIM_CCxChannelCmd(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ChannelState)
Enables or disables the TIM Capture Compare Channel x.

◆ HAL_TIM_OnePulse_Stop_IT()

HAL_StatusTypeDef HAL_TIM_OnePulse_Stop_IT ( TIM_HandleTypeDef htim,
uint32_t  OutputChannel 
)

Stops the TIM One Pulse signal generation in interrupt mode.

Parameters
htimTIM One Pulse handle
OutputChannelTIM Channels to be enabled This parameter can be one of the following values:
  • TIM_CHANNEL_1: TIM Channel 1 selected
  • TIM_CHANNEL_2: TIM Channel 2 selected
Return values
HALstatus

Definition at line 2537 of file stm32l4xx_hal_tim.c.

2538 {
2539  /* Prevent unused argument(s) compilation warning */
2540  UNUSED(OutputChannel);
2541 
2542  /* Disable the TIM Capture/Compare 1 interrupt */
2543  __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC1);
2544 
2545  /* Disable the TIM Capture/Compare 2 interrupt */
2546  __HAL_TIM_DISABLE_IT(htim, TIM_IT_CC2);
2547 
2548  /* Disable the Capture compare and the Input Capture channels
2549  (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
2550  if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
2551  if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
2552  in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be disabled together */
2553  TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_DISABLE);
2554  TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_DISABLE);
2555 
2556  if (IS_TIM_BREAK_INSTANCE(htim->Instance) != RESET)
2557  {
2558  /* Disable the Main Output */
2559  __HAL_TIM_MOE_DISABLE(htim);
2560  }
2561 
2562  /* Disable the Peripheral */
2563  __HAL_TIM_DISABLE(htim);
2564 
2565  /* Return function status */
2566  return HAL_OK;
2567 }
return HAL_OK
void TIM_CCxChannelCmd(TIM_TypeDef *TIMx, uint32_t Channel, uint32_t ChannelState)
Enables or disables the TIM Capture Compare Channel x.