Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
631
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1. void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
  2. {
  3.  
  4.     if (__HAL_TIM_GET_IT_SOURCE(&htim15, TIM_IT_UPDATE) != RESET)
  5.     {
  6.         static uint8_t one_occur = 0;
  7.         static uint8_t break_bits_counter = 0;
  8.  
  9.         if (break_bits_counter == 0)
  10.             one_occur = 0;
  11.  
  12.         break_bits_counter++;
  13.  
  14.         if (HAL_GPIO_ReadPin(USART2_RX_GPIO_Port, USART2_RX_Pin) == GPIO_PIN_SET &&
  15.             (break_bits_counter < DMX_BREAK_TIME))
  16.         {
  17.             HAL_TIM_Base_Stop_IT(&htim15);
  18.             one_occur = 1;
  19.             break_bits_counter = 0;
  20.         }
  21.  
  22.         if (break_bits_counter >= DMX_BREAK_TIME && (one_occur == 0))
  23.         {
  24.             uart_active_start = false;
  25.             HAL_UART_Receive_IT(&huart2, DMXframe.RecBuf, SERIAL_LENGTH);
  26.  
  27.             break_bits_counter = 0;
  28.             HAL_TIM_Base_Stop_IT(&htim15);
  29.         }
  30.  
  31.         __HAL_TIM_CLEAR_IT(&htim15, TIM_IT_UPDATE);
  32.  
  33.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement