3 * @purpose Implementation of Pressure reading functions
6 #include "microphone.h"
7 #include "../bbb_pin.h"
8 #include "../log.h" // For Fatal()
12 double adc_raw[] = {524,668,733,991,1121,1264,1300,1437,1645,1789,1932,2033,2105,2148,2284,2528,3089};
13 double mic_cal[] = {70,73,75,76.8,77.7,80,81.2,83.3,85.5,87.5,90.7,92.6,94.3,96.2,100,102,125};
15 bool Microphone_Init(const char * name, int id)
17 assert(sizeof(adc_raw) == sizeof(mic_cal));
18 return ADC_Export(MIC_ADC);
21 bool Microphone_Cleanup(int id)
23 ADC_Unexport(MIC_ADC);
27 bool Microphone_Read(int id, double * value)
30 if (!ADC_Read(MIC_ADC, &adc))
33 *value = Data_Calibrate((double)adc, adc_raw, mic_cal, sizeof(adc_raw)/sizeof(double));
37 bool Microphone_Sanity(int id, double value)