Пример #1
0
void lineSensorsStop(void)
{
	lineSensors.active_state = FALSE;
	HAL_GPIO_WritePin(GPIOA, TX_LINESENSORS, RESET);
	HAL_ADCEx_InjectedStop_IT(&hadc2);
	HAL_ADCEx_InjectedStop_IT(&hadc3);
}
Пример #2
0
void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc)
{
	/*ADC2 injected group
	conversion is finished*/
	/*count the amount of samples collected*/
	sampleCounter[1]--;
	/*collect samples into accumulator*/
	adcAccumulator[3] += HAL_ADCEx_InjectedGetValue(hadc, ADC_INJECTED_RANK_1);
	adcAccumulator[4] += HAL_ADCEx_InjectedGetValue(hadc, ADC_INJECTED_RANK_2);
	adcAccumulator[5] += HAL_ADCEx_InjectedGetValue(hadc, ADC_INJECTED_RANK_3);
	if(sampleCounter[1] == 0)
	{
		/*if required number of samples is collected
		calculate average data
		and turn off ADC */
		HAL_ADCEx_InjectedStop_IT(&hadc2);
		xCurr = adcAccumulator[3]/ADC2_SAMPL_NUMBER;
		yCurr = adcAccumulator[4]/ADC2_SAMPL_NUMBER;
		zCurr = adcAccumulator[5]/ADC2_SAMPL_NUMBER;
		
	}
	else
	{
		/*perform next conversion cycle otherwise*/
		HAL_ADCEx_InjectedStart_IT(&hadc2);
	}
}