EFM32 Gecko Software Documentation  efm32g-doc-5.1.2

Detailed Description

Si7021 driver and support functions.

Functions

uint32_t SI7021_cmdRead (uint8_t *cmd, size_t cmdLen, uint8_t *result, size_t resultLen)
 Sends a command and reads the result byte(s) over the I2C bus. More...
 
uint32_t SI7021_cmdWrite (uint8_t *cmd, size_t cmdLen, uint8_t *data, size_t dataLen)
 Sends a command and data to the chip over the I2C bus. More...
 
void SI7021_deInit (void)
 De-initializes the Si7021 chip. Disables the sensor power domain, this also disables other sensors. More...
 
uint32_t SI7021_getFwRev (uint8_t *fwRev)
 Reads the firmware revision of the Si7021 chip. More...
 
uint32_t SI7021_init (void)
 Initializes the Si7021 chip. More...
 
uint32_t SI7021_measure (uint32_t *rhData, int32_t *tData)
 Performs relative humidity and temperature measurements. More...
 

Function Documentation

uint32_t SI7021_cmdRead ( uint8_t *  cmd,
size_t  cmdLen,
uint8_t *  result,
size_t  resultLen 
)

Sends a command and reads the result byte(s) over the I2C bus.

Parameters
[in]cmdThe command to be sent
[in]cmdLenThe length of the command in bytes
[out]resultThe received bytes sent by the chip
[in]resultLenThe number of the bytes to read from the chip
Returns
Returns zero on OK, non-zero otherwise

Definition at line 188 of file si7021.c.

References I2C_TransferSeq_TypeDef::addr, I2C_TransferSeq_TypeDef::buf, I2C_TransferSeq_TypeDef::data, I2C_TransferSeq_TypeDef::flags, I2C_FLAG_READ, I2C_FLAG_WRITE_READ, I2CSPM_Transfer(), i2cTransferDone, i2cTransferNack, I2C_TransferSeq_TypeDef::len, SI7021_ERROR_I2C_TRANSFER_FAILED, SI7021_ERROR_I2C_TRANSFER_NACK, SI7021_I2C_BUS_ADDRESS, SI7021_I2C_DEVICE, and SI7021_OK.

Referenced by SI7021_getFwRev(), SI7021_init(), and SI7021_measure().

uint32_t SI7021_cmdWrite ( uint8_t *  cmd,
size_t  cmdLen,
uint8_t *  data,
size_t  dataLen 
)

Sends a command and data to the chip over the I2C bus.

Parameters
[in]cmdThe command to be sent
[in]cmdLenThe length of the command in bytes
[out]dataThe data byte(s) to be sent to the chip
[in]dataLenThe number of the bytes to be sent to the chip
Returns
Returns zero on OK, non-zero otherwise

Definition at line 247 of file si7021.c.

References I2C_TransferSeq_TypeDef::addr, I2C_TransferSeq_TypeDef::buf, I2C_TransferSeq_TypeDef::data, I2C_TransferSeq_TypeDef::flags, I2C_FLAG_WRITE, I2C_FLAG_WRITE_WRITE, I2CSPM_Transfer(), i2cTransferDone, i2cTransferNack, I2C_TransferSeq_TypeDef::len, SI7021_ERROR_I2C_TRANSFER_FAILED, SI7021_ERROR_I2C_TRANSFER_NACK, SI7021_I2C_BUS_ADDRESS, SI7021_I2C_DEVICE, and SI7021_OK.

Referenced by measureSupplyIR(), and SI7021_measure().

void SI7021_deInit ( void  )

De-initializes the Si7021 chip. Disables the sensor power domain, this also disables other sensors.

Returns
None

Definition at line 74 of file si7021.c.

Referenced by UTIL_supplyProbe().

uint32_t SI7021_getFwRev ( uint8_t *  fwRev)

Reads the firmware revision of the Si7021 chip.

Parameters
[out]fwRevThe firmware revision of the chip
Returns
Returns zero on OK, non-zero otherwise

Definition at line 157 of file si7021.c.

References SI7021_CMD_READ_FW_REV, and SI7021_cmdRead().

uint32_t SI7021_init ( void  )

Initializes the Si7021 chip.

Returns
Returns zero on OK, non-zero otherwise

Definition at line 41 of file si7021.c.

References BOARD_envSensEnable(), SI7021_CMD_READ_ID_BYTE2, SI7021_cmdRead(), SI7021_DEVICE_ID, SI7021_ERROR_INVALID_DEVICE_ID, SI7021_OK, and UTIL_delay().

Referenced by UTIL_supplyProbe().

uint32_t SI7021_measure ( uint32_t *  rhData,
int32_t *  tData 
)

Performs relative humidity and temperature measurements.

Parameters
[out]rhDataThe measured relative humidity value in milli-percent units
[out]tDataThe measured temperature value in milli-degree Celsius
Returns
Returns zero on OK, non-zero otherwise

Definition at line 94 of file si7021.c.

References SI7021_CMD_MEASURE_RH_NO_HOLD, SI7021_CMD_READ_TEMP, SI7021_cmdRead(), SI7021_cmdWrite(), SI7021_ERROR_I2C_TRANSFER_NACK, SI7021_ERROR_TIMEOUT, SI7021_OK, and UTIL_delay().