I've created a GitHub repository of the library:
https://github.com/pedvide/ADC
This is a list with the methods of the library:
int ADC::analogRead ( uint8_t pin )
Returns the analog value of the pin.
It waits until the value is read and then returns the result. If a comparison has been set up and fails, it will return ADC_ERROR_VALUE.
int ADC::analogReadContinuous ( )
Reads the analog value of a continuous conversion.
Set the continuous conversion with with analogStartContinuous(pin) or startContinuousDifferential(pinP, pinN)
Returns
the last converted value.
int ADC::analogReadDifferential ( uint8_t pinP,
uint8_t pinN )
Reads the differential analog value of two pins (pinP - pinN).
It waits until the value is read and then returns the result. If a comparison has been set up and fails, it will return ADC_ERROR_DIFF_VALUE.
void ADC::disableCompare ( )
Disable the compare function.
void ADC::disableDMA ( )
Disable ADC DMA request.
void ADC::disableInterrupts ( )
Disable interrupts.
void ADC::enableCompare ( int16_t compValue,
int greaterThan )
Enable the compare function to a single value.
A conversion will be completed only when the ADC value is >= compValue (greaterThan=1) or < compValue (greaterThan=0) Call it after changing the resolution Use with interrupts or poll conversion completion with isADC_Complete()
void ADC::enableCompareRange ( int16_t lowerLimit,
int16_t upperLimit,
int insideRange,
int inclusive )
Enable the compare function to a range.
A conversion will be completed only when the ADC value is inside (insideRange=1) or outside (=0) the range given by (lowerLimit, upperLimit),including (inclusive=1) the limits or not (inclusive=0). See Table 31-78, p. 617 of the freescale manual. Call it after changing the resolution Use with interrupts or poll conversion completion with isComplete()
void ADC::enableDMA ( )
Enable DMA request.
An ADC DMA request will be raised when the conversion is completed (including hardware averages and if the comparison (if any) is true).
void ADC::enableInterrupts ( )
Enable interrupts.
An IRQ_ADC0 Interrupt will be raised when the conversion is completed (including hardware averages and if the comparison (if any) is true).
double ADC::getMaxValue ( )
Returns the maximum value for a measurement, that is: 2^resolution.
int ADC::getResolution ( )
Returns the resolution of the ADC.
int ADC::isComplete ( )
Is an ADC conversion ready?
Returns
1 if yes, 0 if not. When a value is read this function returns 0 until a new value exists So it only makes sense to call it before analogRead(), analogReadContinuous() or analogReadDifferential()
int ADC::isConverting ( )
Is the ADC converting at the moment?
Returns
1 if yes, 0 if not
void ADC::setAveraging ( unsigned int num )
Set the number of averages.
Parameters
num can be 0, 4, 8, 16 or 32.
void ADC::setReference ( uint8_t type )
Set the voltage reference you prefer, default is vcc.
Parameters
type can be DEFAULT, EXTERNAL or INTERNAL
void ADC::setResolution ( unsigned int bits )
Change the resolution of the measurement.
Parameters
bits is the number of bits of resolution. For single-ended measurements: 8, 10, 12 or 16 bits. For differential measurements: 9, 11, 13 or 16 bits. If you want something in between (11 bits single-ended for example) select the inmediate higher and shift the result one to the right.
void ADC::startContinuous ( uint8_t pin )
Starts continuous conversion on the pin.
It returns as soon as the ADC is set, use analogReadContinuous() to read the value.
void ADC::startContinuousDifferential ( uint8_t pinP,
uint8_t pinN )
Starts continuous conversion between the pins (pinP-pinN).
It returns as soon as the ADC is set, use analogReadContinuous() to read the value.
void ADC::stopContinuous ( )
Stops continuous conversion.
Now I'm working on using IntervalTimer to program timed measurements and I'm also looking into the whole interrupt safe thing, so that if you make a measurement and an interrupt starts an other one, when the interrupt finishes the original reading is continued.