Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef __HTMAG_H__
00013 #define __HTMAG_H__
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #pragma systemFile
00036
00037 #ifndef __COMMON_H__
00038 #include "common.h"
00039 #endif
00040
00041 int HTMAGreadVal(tSensors link);
00042 int HTMAGreadRaw(tSensors link);
00043 int HTMAGstartCal(tSensors link);
00044 int HTMAGreadCal(tSensors link);
00045 void HTMAGsetCal(tSensors link, int bias);
00046
00047 #ifdef __HTSMUX_SUPPORT__
00048 int HTMAGreadVal(tMUXSensor muxsensor);
00049 int HTMAGreadRaw(tMUXSensor muxsensor);
00050 int HTMAGstartCal(tMUXSensor muxsensor);
00051 int HTMAGreadCal(tMUXSensor muxsensor);
00052 void HTMAGsetCal(tMUXSensor muxsensor, int bias);
00053 #endif
00054
00055 int HTMAG_bias[][] = {{512, 512, 512, 512},
00056 {512, 512, 512, 512},
00057 {512, 512, 512, 512},
00058 {512, 512, 512, 512}};
00059
00060
00061
00062
00063
00064
00065 int HTMAGreadVal(tSensors link) {
00066
00067 if (SensorType[link] != sensorRawValue) {
00068 SetSensorType(link, sensorRawValue);
00069 wait1Msec(100);
00070 }
00071
00072 return (SensorValue[link] - HTMAG_bias[link][0]);
00073 }
00074
00075
00076
00077
00078
00079
00080
00081 #ifdef __HTSMUX_SUPPORT__
00082 int HTMAGreadVal(tMUXSensor muxsensor) {
00083 return HTSMUXreadAnalogue(muxsensor) - HTMAG_bias[SPORT(muxsensor)][MPORT(muxsensor)];
00084 }
00085 #endif // __HTSMUX_SUPPORT__
00086
00087
00088
00089
00090
00091
00092
00093 int HTMAGreadRaw(tSensors link) {
00094
00095 if (SensorType[link] != sensorRawValue) {
00096 SetSensorType(link, sensorRawValue);
00097 wait1Msec(100);
00098 }
00099
00100 return SensorValue[link];
00101 }
00102
00103
00104
00105
00106
00107
00108
00109 #ifdef __HTSMUX_SUPPORT__
00110 int HTMAGreadRaw(tMUXSensor muxsensor) {
00111 return HTSMUXreadAnalogue(muxsensor);
00112 }
00113 #endif // __HTSMUX_SUPPORT__
00114
00115
00116
00117
00118
00119
00120
00121 int HTMAGstartCal(tSensors link) {
00122 int _avgdata = 0;
00123
00124
00125 if (SensorType[link] != sensorRawValue) {
00126 SetSensorType(link, sensorRawValue);
00127 wait1Msec(100);
00128 }
00129
00130
00131 for (int i = 0; i < 5; i++) {
00132 _avgdata += SensorValue[link];
00133 wait1Msec(50);
00134 }
00135
00136
00137 HTMAG_bias[link][0] = (_avgdata / 5);
00138
00139
00140 return HTMAG_bias[link][0];
00141 }
00142
00143
00144
00145
00146
00147
00148
00149 #ifdef __HTSMUX_SUPPORT__
00150 int HTMAGstartCal(tMUXSensor muxsensor) {
00151 int _avgdata = 0;
00152
00153
00154 for (int i = 0; i < 5; i++) {
00155 _avgdata += HTSMUXreadAnalogue(muxsensor);
00156 wait1Msec(50);
00157 }
00158
00159
00160 HTMAG_bias[SPORT(muxsensor)][MPORT(muxsensor)] = (_avgdata / 5);
00161
00162
00163 return HTMAG_bias[SPORT(muxsensor)][MPORT(muxsensor)];
00164 }
00165 #endif // __HTSMUX_SUPPORT__
00166
00167
00168
00169
00170
00171
00172
00173 void HTMAGsetCal(tSensors link, int bias) {
00174 HTMAG_bias[link][0] = bias;
00175 }
00176
00177
00178
00179
00180
00181
00182
00183 #ifdef __HTSMUX_SUPPORT__
00184 void HTMAGsetCal(tMUXSensor muxsensor, int bias) {
00185 HTMAG_bias[SPORT(muxsensor)][MPORT(muxsensor)] = bias;
00186 }
00187 #endif // __HTSMUX_SUPPORT__
00188
00189
00190
00191
00192
00193
00194
00195 int HTMAGreadCal(tSensors link) {
00196 return HTMAG_bias[link][0];
00197 }
00198
00199
00200
00201
00202
00203
00204
00205 #ifdef __HTSMUX_SUPPORT__
00206 int HTMAGreadCal(tMUXSensor muxsensor) {
00207 return HTMAG_bias[SPORT(muxsensor)][MPORT(muxsensor)];
00208 }
00209 #endif // __HTSMUX_SUPPORT__
00210
00211
00212 #endif // __HTMAG_H__
00213
00214
00215
00216
00217
00218