/* ADC Set the Sample Time for a Single Channel. 
The sampling time can be selected in ADC clock cycles from 1.5 to 239.5. */
void adc_set_sample_time(uint32_t adc, uint8_t channel, uint8_t time)
/* ADC Set the Sample Time for a Single Channel. 
The sampling time can be selected in ADC clock cycles from 1.5 to 239.5. */
void adc_set_sample_time(uint32_t adc, uint8_t channel, uint8_t time)
{
	uint32_t reg32;
	if (channel < 10) {
		reg32 = ADC_SMPR2(adc);
		reg32 &= ~(0x7 << (channel * 3));
		reg32 |= (time << (channel * 3));
		ADC_SMPR2(adc) = reg32;
	} else {
		reg32 = ADC_SMPR1(adc);
		reg32 &= ~(0x7 << ((channel - 10) * 3));
		reg32 |= (time << ((channel - 10) * 3));
		ADC_SMPR1(adc) = reg32;
	}
}