Example #1
0
//**************************************************************************************
//
//!  adc_init
//!
//!  @param    ADCx: ADCx.ADC_CHANNEL, ADCx.ADC_PRESCALAR, ADCx.ADC_REF,
//!                           ADCx.ADC_MODE
//!
//!  @return   none
//!
//!  @brief    This function is used to initialize the ADC peripherial.
//
//**************************************************************************************
void adc_init(ADC_Init ADCx)
{
    adc_set_channel(ADCx.ADC_CHANNEL);
    adc_pin_init(ADCx.ADC_CHANNEL);
    adc_set_prescalar(ADCx.ADC_PRESCALAR);
    adc_set_ref(ADCx.ADC_REF);
    adc_set_mode(ADCx.ADC_MODE);
}
Example #2
0
int adc_init()
{
	/* set reference to Vcc */
	adc_set_ref(ADMUX_AVCC);

	/* set ADC prescalar to 128 - max resolution */
	adc_set_ps(0x7);

	/* disable all */
	adc_dis();

	return 0;
}