Advertisement
Guest User

Untitled

a guest
Feb 16th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim3)
  2. {
  3.  
  4.     if (!TIMER_ACT) {
  5.        
  6.         HAL_ADC_Start(&hadc1);
  7.         HAL_ADC_PollForConversion(&hadc1,1000);
  8.        
  9.         adcResult = HAL_ADC_GetValue(&hadc1);
  10.         t_buffer[0] = (uint8_t)((adcResult & 0xFF00) >> 8);
  11.         t_buffer[1] = (uint8_t)(adcResult & 0x00FF);
  12.         HAL_ADC_Stop(&hadc1);
  13.         CDC_Transmit_FS(t_buffer, 2);
  14.     } else {
  15.         HAL_ADC_Start_DMA(&hadc1,(uint32_t*) &ADC_Data,DMA_BUF_SIZE);
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement