Go to the documentation of this file.00001 #ifndef AP_ADC_HIL_H
00002 #define AP_ADC_HIL_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <inttypes.h>
00016 #include "AP_ADC.h"
00017
00019
00020
00021 class AP_ADC_HIL : public AP_ADC
00022 {
00023 public:
00024
00026
00027 AP_ADC_HIL();
00028
00030
00031 void Init();
00032
00034
00035 int Ch(unsigned char ch_num);
00036
00038
00039
00040 int setHIL(int16_t p, int16_t q, int16_t r, int16_t gyroTemp,
00041 int16_t aX, int16_t aY, int16_t aZ, int16_t diffPress);
00042
00043 private:
00044
00046
00047 uint16_t adcValue[8];
00048
00050
00051
00052
00053 static const uint8_t sensors[6];
00054 static const float gyroBias[3];
00055 static const float gyroScale[3];
00056 static const float accelBias[3];
00057 static const float accelScale[3];
00058 static const int8_t sensorSign[6];
00059
00061
00062
00063
00064 inline void setGyro(uint8_t index, int16_t val) {
00065 int16_t temp = val * gyroScale[index] / 1000 + gyroBias[index];
00066 adcValue[sensors[index]] = (sensorSign[index] < 0) ? -temp : temp;
00067 }
00068
00070
00071
00072
00073 inline void setAccel(uint8_t index, int16_t val) {
00074 int16_t temp = val * accelScale[index] / 1000 + accelBias[index];
00075 adcValue[sensors[index+3]] = (sensors[index+3] < 0) ? -temp : temp;
00076 }
00077
00079
00080
00081 void setPressure(int16_t val) {}
00082
00084
00085
00086 void setGyroTemp(int16_t val) {}
00087 };
00088
00089 #endif