/************************************************************************************************** * @fn HalIRTempTurnOn * * @brief Turn the sensor on * * @return none **************************************************************************************************/ void HalIRTempTurnOn(void) { HalDcDcControl(ST_IRTEMP,true); HalIRTempSelect(); if (HalSensorWriteReg(TMP006_REG_ADDR_CONFIG, configSensorOn, IRTEMP_REG_LEN)) { irtSensorState = TMP006_IDLE; } }
/************************************************************************************************** * @fn HalIRTempTurnOff * * @brief Turn the sensor off * * @return none **************************************************************************************************/ void HalIRTempTurnOff(void) { HalIRTempSelect(); if (HalSensorWriteReg(TMP006_REG_ADDR_CONFIG, configSensorOff, IRTEMP_REG_LEN)) { irtSensorState = TMP006_OFF; } HalDcDcControl(ST_IRTEMP,false); }
/************************************************************************************************** * @fn HalHumiExecMeasurementStep * * @brief Execute measurement step * * @return none */ bool HalHumiExecMeasurementStep(uint8 state) { HalHumiSelect(); switch (state) { case 0: // Turn on DC-DC control HalDcDcControl(ST_HUMID,true); // Start temperature read success = HalHumiWriteCmd(SHT21_CMD_TEMP_T_NH); break; case 1: // Read and store temperature value if (success) { success = HalHumiReadData(buf, DATA_LEN); // Start for humidity read if (success) { success = HalHumiWriteCmd(SHT21_CMD_HUMI_T_NH); } } break; case 2: // Read and store humidity value if (success) { success = HalHumiReadData(buf+DATA_LEN, DATA_LEN); } // Turn of DC-DC control HalDcDcControl(ST_HUMID,false); break; } return success; }
/************************************************************************************************** * @fn HalIRTempRead * * @brief Read the sensor voltage and sensor temperature registers * * @param Voltage and temperature in raw format (2 + 2 bytes) * * @return TRUE if valid data **************************************************************************************************/ bool HalIRTempRead(uint8 *pBuf) { uint16 v; uint16 t; bool success; if (irtSensorState != TMP006_DATA_READY) { return FALSE; } HalIRTempSelect(); // Read the sensor registers success = HalSensorReadReg(TMP006_REG_ADDR_VOLTAGE, (uint8 *)&v,IRTEMP_REG_LEN ); if (success) { success = HalSensorReadReg(TMP006_REG_ADDR_TEMPERATURE, (uint8 *)&t,IRTEMP_REG_LEN ); } if (success) { // Store values pBuf[0] = HI_UINT16( v ); pBuf[1] = LO_UINT16( v ); pBuf[2] = HI_UINT16( t ); pBuf[3] = LO_UINT16( t ); } // Turn off sensor if (HalSensorWriteReg(TMP006_REG_ADDR_CONFIG, configSensorOff, IRTEMP_REG_LEN)) { irtSensorState = TMP006_OFF; } HalDcDcControl(ST_IRTEMP,false); return success; }