ATmega64M1 AVR UART, ADC and DAC  v2.0
UART, ADC and DAC libraries for the ATmega16M1, ATmega32M1 and ATmega64M1.
adc.h
Go to the documentation of this file.
1 
13 #ifndef ADC_H_
14 #define ADC_H_
15 
16 // ##### Includes #####
17 #include <avr/io.h>
18 #include <stdio.h>
19 
20 
21 // ##### Definitions #####
28 enum ADC_REF {
39  };
40 
41 
63  };
64 
65 
72 enum ADC_CH {
73  ADC0 = 0,
74  ADC1 = 1,
75  ADC2 = 2,
76  ADC3 = 3,
77  ADC4 = 4,
78  ADC5 = 5,
79  ADC6 = 6,
80  ADC7 = 7,
81  ADC8 = 8,
82  ADC9 = 9,
83  ADC10 = 10,
84  VCC_4 = 12,
85  AMP0 = 14,
86  AMP1 = 15,
87  AMP2 = 16,
88  BANDGAP = 17,
89  GND = 18,
90  };
91 
98 enum ADC_GAIN {
99  ADC_GAIN5 = 0,
100  ADC_GAIN10 = 1,
101  ADC_GAIN20 = 2,
102  ADC_GAIN40 = 3,
103  };
104 
105 
106 // ##### Functions #####
107 void adcReference(ADC_REF mode);
108 void adcInit(ADC_CLK_DIV clk_div_value);
109 uint16_t adcRead(ADC_CH channel);
110 int16_t adcReadDiff(ADC_CH channel, ADC_GAIN gain);
111 int8_t adcTempRead(void);
112 void adcTempOffset(int8_t offset);
114 
115 
116 #endif /* ADC_H_ */
Clock divider: 32.
Definition: adc.h:58
int16_t adcReadDiff(ADC_CH channel, ADC_GAIN gain)
Function to read differential ADC value.
Definition: adc.cpp:147
Internal 2.56V reference voltage.
Definition: adc.h:38
uint16_t adcRead(ADC_CH channel)
Function to read ADC value.
Definition: adc.cpp:125
ADC_REF adcGetReference(void)
Function to read the current ADC/DAC voltage reference selection.
Definition: adc.cpp:252
void adcTempOffset(int8_t offset)
Function to set a offset correction of internal temperature measurement Parameter should be stored in...
Definition: adc.cpp:335
Clock divider: 8.
Definition: adc.h:54
ADC_CLK_DIV
Enum class for possible ADC Prescaler Selection Bits.
Definition: adc.h:48
Clock divider: 64.
Definition: adc.h:60
ADC_REF
Enum class for possible ADC Vref Selection Bits.
Definition: adc.h:28
AVcc (no external capacitor connected on the AREF pin)
Definition: adc.h:34
ADC_GAIN
Enum class for possible ADC Input Gain Selection.
Definition: adc.h:98
int8_t adcTempRead(void)
Function to read internal temperature sensor.
Definition: adc.cpp:289
void adcInit(ADC_CLK_DIV clk_div_value)
Function to initialize ADC.
Definition: adc.cpp:68
External Vref on AREF pin, Internal Vref is switched off.
Definition: adc.h:30
Clock divider: 128.
Definition: adc.h:62
Clock divider: 16.
Definition: adc.h:56
Internal 2.56V reference voltage with external capacitor connected on the AREF pin.
Definition: adc.h:36
void adcReference(ADC_REF mode)
Function to set the ADC/DAC voltage reference selection The configuration of the voltage reference se...
Definition: adc.cpp:23
Clock divider: 4.
Definition: adc.h:52
Clock divider: 2.
Definition: adc.h:50
ADC_CH
Enum class for possible ADC Input Channel Selection.
Definition: adc.h:72
AVcc with external capacitor connected on the AREF pin.
Definition: adc.h:32