00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef __HTIRS_H__
00013 #define __HTIRS_H__
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #pragma systemFile
00049
00050 #ifndef __COMMON_H__
00051 #include "common.h"
00052 #endif
00053
00054 #define HTIRS_I2C_ADDR 0x02
00055 #define HTIRS_OFFSET 0x42
00056 #define HTIRS_DIR 0x00
00057 #define HTIRS_SSTR1 0x01
00058 #define HTIRS_SSTR2 0x02
00059 #define HTIRS_SSTR3 0x03
00060 #define HTIRS_SSTR4 0x04
00061 #define HTIRS_SSTR5 0x05
00062
00063 int HTIRSreadDir(tSensors link);
00064 bool HTIRSreadAllStrength(tSensors link, int &dcS1, int &dcS2, int &dcS3, int &dcS4, int &dcS5);
00065
00066 #ifdef __HTSMUX_SUPPORT__
00067 int HTIRSreadDir(tMUXSensor muxsensor);
00068 bool HTIRSreadAllStrength(tMUXSensor muxsensor, int &dcS1, int &dcS2, int &dcS3, int &dcS4, int &dcS5);
00069
00070 tConfigParams HTIRS_config = {HTSMUX_CHAN_I2C, 7, 0x02, 0x42};
00071 #endif // __HTSMUX_SUPPORT__
00072
00073 tByteArray HTIRS_I2CRequest;
00074 tByteArray HTIRS_I2CReply;
00075
00076
00077
00078
00079
00080
00081 int HTIRSreadDir(tSensors link) {
00082 memset(HTIRS_I2CRequest, 0, sizeof(tByteArray));
00083
00084 HTIRS_I2CRequest[0] = 2;
00085 HTIRS_I2CRequest[1] = HTIRS_I2C_ADDR;
00086 HTIRS_I2CRequest[2] = HTIRS_OFFSET + HTIRS_DIR;
00087
00088 if (!writeI2C(link, HTIRS_I2CRequest, 1))
00089 return -1;
00090
00091 if (!readI2C(link, HTIRS_I2CReply, 1))
00092 return -1;
00093
00094 return (int)HTIRS_I2CReply[0];
00095 }
00096
00097
00098
00099
00100
00101
00102
00103 #ifdef __HTSMUX_SUPPORT__
00104 int HTIRSreadDir(tMUXSensor muxsensor) {
00105 memset(HTIRS_I2CReply, 0, sizeof(tByteArray));
00106
00107 if (HTSMUXSensorTypes[muxsensor] != HTSMUXSensorCustom)
00108 HTSMUXconfigChannel(muxsensor, HTIRS_config);
00109
00110 if (!HTSMUXreadPort(muxsensor, HTIRS_I2CReply, 1, HTIRS_DIR))
00111 return -1;
00112
00113 return (int)HTIRS_I2CReply[0];
00114 }
00115 #endif // __HTSMUX_SUPPORT__
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128 bool HTIRSreadAllStrength(tSensors link, int &dcS1, int &dcS2, int &dcS3, int &dcS4, int &dcS5) {
00129 memset(HTIRS_I2CRequest, 0, sizeof(tByteArray));
00130
00131 HTIRS_I2CRequest[0] = 2;
00132 HTIRS_I2CRequest[1] = HTIRS_I2C_ADDR;
00133 HTIRS_I2CRequest[2] = HTIRS_OFFSET + HTIRS_SSTR1;
00134
00135 if (!writeI2C(link, HTIRS_I2CRequest, 5))
00136 return false;
00137
00138 if (!readI2C(link, HTIRS_I2CReply, 5))
00139 return false;
00140
00141 dcS1 = (int)HTIRS_I2CReply[0];
00142 dcS2 = (int)HTIRS_I2CReply[1];
00143 dcS3 = (int)HTIRS_I2CReply[2];
00144 dcS4 = (int)HTIRS_I2CReply[3];
00145 dcS5 = (int)HTIRS_I2CReply[4];
00146
00147 return true;
00148 }
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161 #ifdef __HTSMUX_SUPPORT__
00162 bool HTIRSreadAllStrength(tMUXSensor muxsensor, int &dcS1, int &dcS2, int &dcS3, int &dcS4, int &dcS5) {
00163 memset(HTIRS_I2CReply, 0, sizeof(tByteArray));
00164
00165 if (HTSMUXSensorTypes[muxsensor] != HTSMUXSensorCustom)
00166 HTSMUXconfigChannel(muxsensor, HTIRS_config);
00167
00168 if (!HTSMUXreadPort(muxsensor, HTIRS_I2CReply, 5, HTIRS_SSTR1))
00169 return false;
00170
00171 dcS1 = (int)HTIRS_I2CReply[0];
00172 dcS2 = (int)HTIRS_I2CReply[1];
00173 dcS3 = (int)HTIRS_I2CReply[2];
00174 dcS4 = (int)HTIRS_I2CReply[3];
00175 dcS5 = (int)HTIRS_I2CReply[4];
00176 return true;
00177 }
00178 #endif // __HTSMUX_SUPPORT__
00179
00180 #endif // __HTIRS_H__
00181
00182
00183
00184
00185
00186