/* Initialize a Timer to emulate an encoder sensor.  */
static void Init_TIM_Emulator(TIM_HandleTypeDef *htim)
/* Initialize a Timer to emulate an encoder sensor.  */
static void Init_TIM_Emulator(TIM_HandleTypeDef *htim)
{
  htim->Instance = TIM3;
  htim->Init.Period        = EMU_PERIOD;
  htim->Init.Prescaler     = 0;
  htim->Init.ClockDivision = 0;
  htim->Init.CounterMode   = TIM_COUNTERMODE_UP;
  if(HAL_TIM_OC_Init(htim) != HAL_OK)
  {
    Error_Handler();
  }
  sConfig.OCMode = TIM_OCMODE_TOGGLE;
  sConfig.Pulse = (EMU_PERIOD * 1 )/4;
  sConfig.OCPolarity = TIM_OCPOLARITY_LOW;
  if(HAL_TIM_OC_ConfigChannel(htim, &sConfig, TIM_CHANNEL_1) != HAL_OK)
  {
    Error_Handler();
  }
  sConfig.Pulse = (EMU_PERIOD * 3 )/4;
  if(HAL_TIM_OC_ConfigChannel(htim, &sConfig, TIM_CHANNEL_2) != HAL_OK)
  {
    Error_Handler();
  }
}