AnsweredAssumed Answered

Unused parameter: [F2] HAL_TIM_OnePulse_Start

Question asked by Valentin on May 6, 2017
Latest reply on May 8, 2017 by Valentin

I've just been pointed at this function by my compiler warnings and am wondering what's going on here?

The parameter uint32_t OutputChannel is clearly not used, instead channel 1 AND 2 are always started together.

 

This must either be intended behaviour for some hardware reason OR a bug.

In case 1: Please remove the parameter and explain the situation in the function comment.

Case 2: Please fix by actually using the parameter.

 

CubeMX 4.20.1

up-to-date F2 FW package

file: stm32f2xx_hal_tim.c line 2107

 

The same goes for:

- HAL_TIM_OnePulse_Stop

- HAL_TIM_OnePulse_Start_IT and

- HAL_TIM_OnePulse_Stop_IT

 

Thanks!

 

/**
  * @brief  Starts the TIM One Pulse signal generation.
  * @param  htim: pointer to a TIM_HandleTypeDef structure that contains
  *                the configuration information for TIM module.
  * @param  OutputChannel : TIM Channels to be enabled.
  *          This parameter can be one of the following values:
  *            @arg TIM_CHANNEL_1: TIM Channel 1 selected
  *            @arg TIM_CHANNEL_2: TIM Channel 2 selected
  * @retval HAL status
  */

HAL_StatusTypeDef HAL_TIM_OnePulse_Start(TIM_HandleTypeDef *htim, uint32_t OutputChannel)
{
  /* Enable the Capture compare and the Input Capture channels
    (in the OPM Mode the two possible channels that can be used are TIM_CHANNEL_1 and TIM_CHANNEL_2)
    if TIM_CHANNEL_1 is used as output, the TIM_CHANNEL_2 will be used as input and
    if TIM_CHANNEL_1 is used as input, the TIM_CHANNEL_2 will be used as output
    in all combinations, the TIM_CHANNEL_1 and TIM_CHANNEL_2 should be enabled together
   
    No need to enable the counter, it's enabled automatically by hardware
    (the counter starts in response to a stimulus and generate a pulse */

 
  TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
  TIM_CCxChannelCmd(htim->Instance, TIM_CHANNEL_2, TIM_CCx_ENABLE);
 
  if(IS_TIM_ADVANCED_INSTANCE(htim->Instance) != RESET) 
  {
    /* Enable the main output */
    __HAL_TIM_MOE_ENABLE(htim);
  }
 
  /* Return function status */
  return HAL_OK;
}

 

Btw, there are quite a bit of those unused parameters going on in the ST drivers alone.

 

-------------------------------------

 

I think that drivers and middleware intended for public use should be warning-free even in +wextra and +wpedantic mode. Does anybody disagree?

Outcomes