Definition at line 119 of file adc.c. References AD_READIN_COUNT, and AD_REF_EXT. Referenced by current_Init(), current_Update(), current_UpdateAvg(), current_UpdateSum(), main(), switch_Get(), temp_Init(), temp_Update(), voltage_Init(), voltage_Update(), and voltage_UpdateAvg(). { UINT8 i; UINT16 retval; ADMUX = AD_REF_EXT | u8Channel; /* select channel */ ADCSRA |= (1<<ADEN); /* activate ADC */ /* dummy read */ ADCSRA |= (1<<ADSC); /* read ADC */ while (ADCSRA & (1<<ADSC)) { asm("nop"); /* wait for conversion end */ } retval = ADCW; /* actual meassure (averaged) */ retval = 0U; for(i=0U; i<AD_READIN_COUNT; i++) { ADCSRA |= (1<<ADSC); /* read ADC */ while (ADCSRA & (1<<ADSC)) { asm("nop"); /* wait for conversion end */ } retval += ADCW; /* add results */ } ADCSRA &= ~(1<<ADEN); /* deactivate ADC */ retval /= AD_READIN_COUNT; /* calculate average value */ return retval; } /* End: adc_Read() */
Here is the caller graph for this function:
![]() |