Functions

ADC Low Level Fucntions
[ADC]

ADC Low Level Functions. More...

Functions

void init_adc (void)
 Configures the ADC accordingly to the ADC Define Configuration values.

Detailed Description

ADC Low Level Functions.


Function Documentation

void init_adc ( void   )

Configures the ADC accordingly to the ADC Define Configuration values.

Take care that you have to select the ports which will be converted as analog inputs thanks to the DIDR0 and DIDR1 registers.

Configures the ADC accordingly to the ADC Define Configuration values.

Configures the ADC accordingly to the ADC Define Configuration values. Take care that you have to select the ports which will be converted as analog inputs thanks to the DIDR0 and DIDR1 registers.

Definition at line 65 of file adc_drv.c.

References Disable_adc_high_speed_mode, Disable_adc_it, Enable_adc, Enable_adc_high_speed_mode, Enable_adc_it, Enable_all_it, Enable_internal_vref, Enable_vcc_vref, Left_adjust_adc_result, Right_adjust_adc_result, and Set_adc_prescaler.

Referenced by main().

{
    Enable_adc();
#   if (ADC_RIGHT_ADJUST_RESULT == 1)
       Right_adjust_adc_result();
#   elif (ADC_RIGHT_ADJUST_RESULT == 0)
       Left_adjust_adc_result();
#   else
#      error (ADC_RIGHT_ADJUST_RESULT should be 0 or 1... See config.h file)
#   endif

#   if (ADC_HIGH_SPEED_MODE == 1)
       Enable_adc_high_speed_mode();
#   elif (ADC_HIGH_SPEED_MODE == 0)
       Disable_adc_high_speed_mode();
#   else
#      error (ADC_HIGH_SPEED_MODE should be 0 or 1... See config.h file)
#   endif

#   if (ADC_INTERNAL_VREF == 2)
       Enable_vcc_vref();
#   elif (ADC_INTERNAL_VREF == 1)
       Enable_internal_vref();
#   elif (ADC_INTERNAL_VREF == 0)
       Enable_vcc_vref();
#   else
#      error (ADC_INTERNAL_VREF should be 0, 1 or 2... See config.h file)
#   endif

#   if (ADC_IT == 1)
       Enable_all_it();
       Enable_adc_it();
#   elif (ADC_IT == 0)
       Disable_adc_it();
#   else
#      error (ADC_IT should be 0 or 1... See config.h file)
#   endif

#   if (ADC_PRESCALER == 128)
       Set_adc_prescaler(7);
#   elif (ADC_PRESCALER == 64)
       Set_adc_prescaler(6);
#   elif (ADC_PRESCALER == 32)
       Set_adc_prescaler(5);
#   elif (ADC_PRESCALER == 16)
       Set_adc_prescaler(4);
#   elif (ADC_PRESCALER ==  8)
       Set_adc_prescaler( 3);
#   elif (ADC_PRESCALER ==  4)
       Set_adc_prescaler( 2);
#   elif (ADC_PRESCALER ==  2)
       Set_adc_prescaler( 1);
#   else
#      error (ADC_PRESCALER should be 2, 4, 8, 16, 32, 64 or 128... See config.h file)
#   endif
}

Here is the caller graph for this function: