Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef __HTBM_H__
00013 #define __HTBM_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 #pragma systemFile
00039
00040 #ifndef __COMMON_H__
00041 #include "common.h"
00042 #endif
00043
00044 #define HTBM_I2C_ADDR 0x02
00045 #define HTBM_OFFSET 0x42
00046 #define HTBM_TEMP_HIGH 0x00
00047 #define HTBM_TEMP_LOW 0x01
00048 #define HTBM_PRES_HIGH 0x02
00049 #define HTBM_PRES_LOW 0x03
00050
00051 const float mInHgtohPa = 0.03386389;
00052 const float mInHgtoPsi = 0.491098/1000;
00053
00054 long HTBMreadMInHg(tSensors link);
00055 float HTBMreadhPa(tSensors link);
00056 float HTBMreadPsi(tSensors link);
00057 float HTBMreadTemp(tSensors link);
00058 float HTBMreadTempF(tSensors link);
00059
00060 tByteArray HTBM_I2CRequest;
00061 tByteArray HTBM_I2CReply;
00062
00063
00064
00065
00066
00067
00068 long HTBMreadMInHg(tSensors link) {
00069 memset(HTBM_I2CRequest, 0, sizeof(tByteArray));
00070
00071 HTBM_I2CRequest[0] = 2;
00072 HTBM_I2CRequest[1] = HTBM_I2C_ADDR;
00073 HTBM_I2CRequest[2] = HTBM_OFFSET + HTBM_PRES_HIGH;
00074
00075 if (!writeI2C(link, HTBM_I2CRequest, HTBM_I2CReply, 2))
00076 return -255;
00077
00078 return (HTBM_I2CReply[0] << 8) + HTBM_I2CReply[1];
00079 }
00080
00081
00082
00083
00084
00085
00086
00087 float HTBMreadhPa(tSensors link) {
00088 return HTBMreadMInHg(link) * mInHgtohPa;
00089 }
00090
00091
00092
00093
00094
00095
00096
00097 float HTBMreadPsi(tSensors link) {
00098 return (float)HTBMreadMInHg(link) * mInHgtoPsi;
00099 }
00100
00101
00102
00103
00104
00105
00106
00107 float HTBMreadTemp(tSensors link) {
00108 float temp = 0.0;
00109 memset(HTBM_I2CRequest, 0, sizeof(tByteArray));
00110
00111 HTBM_I2CRequest[0] = 2;
00112 HTBM_I2CRequest[1] = HTBM_I2C_ADDR;
00113 HTBM_I2CRequest[2] = HTBM_OFFSET + HTBM_TEMP_HIGH;
00114
00115
00116 if (!writeI2C(link, HTBM_I2CRequest, HTBM_I2CReply, 2))
00117 return -255;
00118
00119 temp = (HTBM_I2CReply[0] << 8) + HTBM_I2CReply[1];
00120 temp /= 10;
00121 return temp;
00122 }
00123
00124
00125
00126
00127
00128
00129
00130 float HTBMreadTempF(tSensors link) {
00131 return (HTBMreadTemp(link) * 1.8) + 32;
00132 }
00133
00134
00135 #endif // __HTBM_H__
00136
00137
00138
00139
00140
00141