예제 #1
0
/*******************************************************************************
* @fn          sensorHdc1000Read
*
* @brief       Get humidity sensor data
*
* @param       rawTemp - raw temperature value
*
* @param       rawHum - raw humidity value
*
* @return      true of I2C operations successful
*/
bool sensorHdc1000Read(uint16_t *rawTemp, uint16_t *rawHum)
{
  bool valid;

  if (success)
  {
    if (!SENSOR_SELECT())
      return false;

    success = bspI2cRead((uint8_t*)&data,sizeof(data));
    SENSOR_DESELECT();

    // Store temperature
    *rawTemp = SWAP(data.temp);

    // Store humidity
    *rawHum = SWAP(data.hum);
  }

  valid = success;
  success = true; // Ready for next cycle

  return valid;
}
/**************************************************************************************************
* @fn          sensorSht21ReadData
*
* @brief       This function implements the I2C protocol to read from the SHT21.
*
* @param       pBuf - pointer to buffer to place data
*
* @param       nBytes - number of bytes to read
*
* @return      TRUE if the required number of bytes are received
**************************************************************************************************/
static bool sensorSht21ReadData(uint8_t *pBuf, uint8_t nBytes)
{
  /* Read data */
  return bspI2cRead(pBuf,nBytes);
}