Wrapper for accessing built-in analog to digital conversion facilities.
More...
|
file | adc.h |
| Wrapper for accessing built-in analog to digital conversion facilities.
|
|
|
class | Avr::Adc |
| A C++ wrapper for accessing the built-in 10 bit Analog to Digital Conversion (ADC) facilities. More...
|
|
Wrapper for accessing built-in analog to digital conversion facilities.
◆ Avr::Adc
A C++ wrapper for accessing the built-in 10 bit Analog to Digital Conversion (ADC) facilities.
- Note
- Avr::Adc is currently limited to ADC mode Single Conversion.
-
The prescaler is automatically configured to the lowest possible value targeting a sample rate between 50 and 200 kHz for a good compromise between performance and accuracy.
Public Member Functions |
uint16_t | read (uint8_t channel, uint8_t nsamples=1) |
| Reads the (average) raw ADC value (in Single Conversion mode) for the given channel . More...
|
|
uint16_t | readMilliVolts (uint8_t channel, uint8_t nsamples=1) |
| Reads the (average) ADC voltage (in Single Conversion mode) for the given channel . More...
|
|
float | readVolts (uint8_t channel, uint8_t nsamples=1) |
| Reads the (average) ADC voltage (in Single Conversion mode) for the given channel . More...
|
|
Static Public Member Functions |
static Adc & | instance () |
| Returns the Avr::Adc instance. More...
|
|
◆ instance()
static Adc& Avr::Adc::instance |
( |
| ) |
|
|
inlinestatic |
◆ read()
uint16_t Avr::Adc::read |
( |
uint8_t |
channel, |
|
|
uint8_t |
nsamples = 1 |
|
) |
| |
|
inline |
Reads the (average) raw ADC value (in Single Conversion mode) for the given channel
.
- Parameters
-
channel | The ADC channel to read from. |
nsamples | Number of samples taken to build an average from. |
- Returns
- the raw ADC value.
◆ readMilliVolts()
uint16_t Avr::Adc::readMilliVolts |
( |
uint8_t |
channel, |
|
|
uint8_t |
nsamples = 1 |
|
) |
| |
|
inline |
Reads the (average) ADC voltage (in Single Conversion mode) for the given channel
.
- Parameters
-
channel | The ADC channel to read from. |
nsamples | Number of samples taken to build an average from. |
- Returns
- ADC value in millivolts.
◆ readVolts()
float Avr::Adc::readVolts |
( |
uint8_t |
channel, |
|
|
uint8_t |
nsamples = 1 |
|
) |
| |
|
inline |
Reads the (average) ADC voltage (in Single Conversion mode) for the given channel
.
- Parameters
-
channel | The ADC channel to read from. |
nsamples | Number of samples taken to build an average from. |
- Returns
- ADC value in volts.