OpenPicoRTOS
OpenPicoRTOS copied to clipboard
ADC: improve calibration by using a polynomial
Calibration can be improved by using some kind of polynomial.
As not all architectures support floating point, it might take the form of a series of fractions, like:
struct adc_polynomial {
unsigned long numerator;
unsigned long denominator;
};
While calibrating the ADC, it might look like:
static struct adc_polynomial poly[3] = {
{ 64, 73 }, { 2442, 10000 }, { 32, 37 }
};
(void)adc_set_polynomial(&ADCx, poly, (size_t)3);
This might be a upper layer, and make adc_read return uint16_t, for example