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
00049 #pragma systemFile
00050
00051 #ifndef __COMMON_H__
00052 #include "common.h"
00053 #endif
00054
00055 #define HTIRS_I2C_ADDR 0x02
00056 #define HTIRS_OFFSET 0x42
00057 #define HTIRS_DIR 0x00
00058 #define HTIRS_SSTR1 0x01
00059 #define HTIRS_SSTR2 0x02
00060 #define HTIRS_SSTR3 0x03
00061 #define HTIRS_SSTR4 0x04
00062 #define HTIRS_SSTR5 0x05
00063
00064 int HTIRSreadDir(tSensors link);
00065 bool HTIRSreadAllStrength(tSensors link, int &dcS1, int &dcS2, int &dcS3, int &dcS4, int &dcS5);
00066
00067 #ifdef __HTSMUX_SUPPORT__
00068 int HTIRSreadDir(tMUXSensor muxsensor);
00069 bool HTIRSreadAllStrength(tMUXSensor muxsensor, int &dcS1, int &dcS2, int &dcS3, int &dcS4, int &dcS5);
00070
00071 tConfigParams HTIRS_config = {HTSMUX_CHAN_I2C, 7, 0x02, 0x42};
00072 #endif // __HTSMUX_SUPPORT__
00073
00074 tByteArray HTIRS_I2CRequest;
00075 tByteArray HTIRS_I2CReply;
00076
00077
00078
00079
00080
00081
00082 int HTIRSreadDir(tSensors link) {
00083 memset(HTIRS_I2CRequest, 0, sizeof(tByteArray));
00084
00085 HTIRS_I2CRequest[0] = 2;
00086 HTIRS_I2CRequest[1] = HTIRS_I2C_ADDR;
00087 HTIRS_I2CRequest[2] = HTIRS_OFFSET + HTIRS_DIR;
00088
00089 if (!writeI2C(link, HTIRS_I2CRequest, HTIRS_I2CReply, 1))
00090 return -1;
00091
00092 return (int)HTIRS_I2CReply[0];
00093 }
00094
00095
00096
00097
00098
00099
00100
00101 #ifdef __HTSMUX_SUPPORT__
00102 int HTIRSreadDir(tMUXSensor muxsensor) {
00103 memset(HTIRS_I2CReply, 0, sizeof(tByteArray));
00104
00105 if (HTSMUXSensorTypes[muxsensor] != HTSMUXSensorCustom)
00106 HTSMUXconfigChannel(muxsensor, HTIRS_config);
00107
00108 if (!HTSMUXreadPort(muxsensor, HTIRS_I2CReply, 1, HTIRS_DIR))
00109 return -1;
00110
00111 return (int)HTIRS_I2CReply[0];
00112 }
00113 #endif // __HTSMUX_SUPPORT__
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 bool HTIRSreadAllStrength(tSensors link, int &dcS1, int &dcS2, int &dcS3, int &dcS4, int &dcS5) {
00127 memset(HTIRS_I2CRequest, 0, sizeof(tByteArray));
00128
00129 HTIRS_I2CRequest[0] = 2;
00130 HTIRS_I2CRequest[1] = HTIRS_I2C_ADDR;
00131 HTIRS_I2CRequest[2] = HTIRS_OFFSET + HTIRS_SSTR1;
00132
00133 if (!writeI2C(link, HTIRS_I2CRequest, HTIRS_I2CReply, 5))
00134 return false;
00135
00136 dcS1 = (int)HTIRS_I2CReply[0];
00137 dcS2 = (int)HTIRS_I2CReply[1];
00138 dcS3 = (int)HTIRS_I2CReply[2];
00139 dcS4 = (int)HTIRS_I2CReply[3];
00140 dcS5 = (int)HTIRS_I2CReply[4];
00141
00142 return true;
00143 }
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156 #ifdef __HTSMUX_SUPPORT__
00157 bool HTIRSreadAllStrength(tMUXSensor muxsensor, int &dcS1, int &dcS2, int &dcS3, int &dcS4, int &dcS5) {
00158 memset(HTIRS_I2CReply, 0, sizeof(tByteArray));
00159
00160 if (HTSMUXSensorTypes[muxsensor] != HTSMUXSensorCustom)
00161 HTSMUXconfigChannel(muxsensor, HTIRS_config);
00162
00163 if (!HTSMUXreadPort(muxsensor, HTIRS_I2CReply, 5, HTIRS_SSTR1))
00164 return false;
00165
00166 dcS1 = (int)HTIRS_I2CReply[0];
00167 dcS2 = (int)HTIRS_I2CReply[1];
00168 dcS3 = (int)HTIRS_I2CReply[2];
00169 dcS4 = (int)HTIRS_I2CReply[3];
00170 dcS5 = (int)HTIRS_I2CReply[4];
00171 return true;
00172 }
00173 #endif // __HTSMUX_SUPPORT__
00174
00175 #endif // __HTIRS_H__
00176
00177
00178
00179
00180
00181