Advertisement
rickybenevelli12

Implementing of switch state-machine

Oct 1st, 2022
938
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. switch (state)
  2.     {
  3.     case a:
  4.       HAL_ADC_Start(&hadc1);
  5.       HAL_ADC_PollForConversion(&hadc1, 1);
  6.       raw = HAL_ADC_GetValue(&hadc1);
  7.       raw_to_volt = (raw * 3.3) / 4095;
  8.       HAL_ADC_Stop(&hadc1);
  9.  
  10.       sprintf(msg, "(%lu) Hall sensor:  %.4f [V]\r\n", HAL_GetTick()/100, raw_to_volt);
  11.       HAL_UART_Transmit(&hlpuart1, (uint8_t*)msg, strlen(msg), 10);
  12.       flag_sensor = 0;
  13.  
  14.       break;
  15.  
  16.     case b:
  17.       /* reading tension and checking the value */
  18.       break;
  19.  
  20.     case c:
  21.       /* danger state code */
  22.       break;
  23.  
  24.     case d:
  25.       /* waiting state code */
  26.       break;
  27.  
  28.     default:
  29.       break;
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement