|
AVRTools
A Library for the AVR ATmega328 and ATmega2560 Microcontrollers
|
This file provides functions that access the analog-to-digital conversion capability of the ATmega328 and ATmega2560 microcontrollers. More...

Go to the source code of this file.
Macros | |
| #define | readGpioPinAnalog(pinName) |
| Read the analog value of the pin. | |
Enumerations | |
| enum | A2DVoltageReference { kA2dReferenceAREF , kA2dReferenceAVCC , kA2dReference11V , kA2dReference256V } |
| Constants representing voltage references. More... | |
Functions | |
| int | readA2D (int8_t channel) |
| Read an analog voltage value. | |
| uint16_t | readGpioPinAnalogV (const GpioPinVariable &pinVar) |
| Read the analog value of the pin. | |
| void | initA2D (uint8_t ref=kA2dReferenceAVCC) |
| Initialize the analog-to-digital system. | |
| void | turnOffA2D () |
| Turn off the analog-to-digital system. | |
| void | setA2DVoltageReference (A2DVoltageReference ref) |
| Set the voltage reference for the analog-to-digital system. | |
| void | setA2DVoltageReferenceAREF () |
| Set the voltage reference for the analog-to-digital system to AREF. | |
| void | setA2DVoltageReferenceAVCC () |
| Set the voltage reference for the analog-to-digital system to AREF. | |
| void | setA2DVoltageReference11V () |
| Set the voltage reference for the analog-to-digital system to AREF. | |
| void | setA2DVoltageReference256V () |
| Set the voltage reference for the analog-to-digital system to AREF. | |
This file provides functions that access the analog-to-digital conversion capability of the ATmega328 and ATmega2560 microcontrollers.
To use these functions, include Analog2Digital.h in your source code and link against Analog2Digital.cpp.
| #define readGpioPinAnalog | ( | pinName | ) |
Read the analog value of the pin.
This function returns a number between 0 and 1023 that corresponds to voltage between 0 and a maximum reference value. The reference value is set using one of the setA2DVoltageReferenceXXX() functions.
pinName a pin name macro generated by GpioPinAnalog().| enum A2DVoltageReference |
Constants representing voltage references.
| void initA2D | ( | uint8_t | ref = kA2dReferenceAVCC | ) |
Initialize the analog-to-digital system.
You must call this function before using any of the analog-to-digital functions.
ref provides the voltage reference to be used for analog-to-digital conversions. Pass one of the constants from enum A2DVoltageReference. If no value is provided, the default is kA2dReferenceAVCC.| int readA2D | ( | int8_t | channel | ) |
Read an analog voltage value.
Voltage is read relative to the currently set reference value.
channel is an ADC channel number (between 0 and 7 on ATmega328; between 0 and 15 on ATMega2560).
|
inline |
Read the analog value of the pin.
This function returns a number between 0 and 1023 that corresponds to voltage between 0 and a maximum reference value. The reference value is set using one of the setA2DVoltageReferenceXXX() functions.
pinVar a pin variable that has analog-to-digital capabilities (i.e., initialized with makeGpioVarFromGpioPinAnalog()).| void setA2DVoltageReference | ( | A2DVoltageReference | ref | ) |
Set the voltage reference for the analog-to-digital system.
After your have initialized the analog-to-digital system with initA2D(), you can use this function to change the voltage reference.
ref provides the voltage reference to be used for analog-to-digital conversions. Pass one of the constants from enum A2DVoltageReference.
|
inline |
Set the voltage reference for the analog-to-digital system to AREF.
This is an inline synonym for setA2DVoltageReference( kA2dReference11V )
|
inline |
Set the voltage reference for the analog-to-digital system to AREF.
This is an inline synonym for setA2DVoltageReference( kA2dReference256V )
|
inline |
Set the voltage reference for the analog-to-digital system to AREF.
This is an inline synonym for setA2DVoltageReference( kA2dReferenceAREF )
|
inline |
Set the voltage reference for the analog-to-digital system to AREF.
This is an inline synonym for setA2DVoltageReference( kA2dReferenceAVCC )