EFM32 Happy Gecko Software Documentation  efm32hg-doc-5.1.2

Detailed Description

CCS811 driver and support functions.

Functions

uint32_t CCS811_deInit (void)
 De-initializes the chip. More...
 
void CCS811_dumpRegisters (void)
 Dumps the registers of the CSS811. More...
 
uint32_t CCS811_getHardwareID (uint8_t *hardwareID)
 Reads Hardware ID from the CSS811 sensor. More...
 
uint32_t CCS811_getMeasurement (uint16_t *eco2, uint16_t *tvoc)
 Reads measurement data (eCO2 and TVOC) from the CSS811 sensor. More...
 
uint32_t CCS811_getRawData (uint16_t *current, uint16_t *rawData)
 Gets the latest readings from the sense resistor of the CSS811 sensor. More...
 
uint32_t CCS811_getStatus (uint8_t *status)
 Reads the status of the CSS811 sensor. More...
 
uint32_t CCS811_init (void)
 Initializes the chip and performs firmware upgrade if required. More...
 
bool CCS811_isDataAvailable (void)
 Checks if new measurement data available. More...
 
uint32_t CCS811_readMailbox (uint8_t id, uint8_t length, uint8_t *data)
 Reads data from a specific Mailbox address. More...
 
uint32_t CCS811_setEnvData (int32_t tempData, uint32_t rhData)
 Writes temperature and humidity values to the environmental data regs. More...
 
uint32_t CCS811_setMeasureMode (uint8_t measMode)
 Sets the measurement mode of the CSS811 sensor. More...
 
uint32_t CCS811_softwareReset (void)
 Performs software reset on the CCS811. More...
 
uint32_t CCS811_startApplication (void)
 Switches the CSS811 chip from boot to application mode. More...
 

Function Documentation

uint32_t CCS811_deInit ( void  )

De-initializes the chip.

Returns
Returns zero on OK, non-zero otherwise

Definition at line 106 of file ccs811.c.

References BOARD_gasSensorEnable(), BOARD_gasSensorWake(), and CCS811_OK.

uint32_t CCS811_getHardwareID ( uint8_t *  hardwareID)

Reads Hardware ID from the CSS811 sensor.

Parameters
[out]hardwareIDThe Hardware ID of the chip (should be 0x81)
Returns
Returns zero on OK, non-zero otherwise

Definition at line 127 of file ccs811.c.

References CCS811_ADDR_HW_ID, and CCS811_readMailbox().

Referenced by CCS811_init().

uint32_t CCS811_getMeasurement ( uint16_t *  eco2,
uint16_t *  tvoc 
)

Reads measurement data (eCO2 and TVOC) from the CSS811 sensor.

Parameters
[out]eco2The eCO2 level read from the sensor
[out]tvocThe TVOC level read from the sensor
Returns
Returns zero on OK, non-zero otherwise

Definition at line 339 of file ccs811.c.

References I2C_TransferSeq_TypeDef::addr, BOARD_gasSensorWake(), I2C_TransferSeq_TypeDef::buf, CCS811_ADDR_ALG_RESULT_DATA, CCS811_ERROR_I2C_TRANSACTION_FAILED, CCS811_I2C_DEVICE, CCS811_I2C_DEVICE_BUS_ADDRESS, CCS811_OK, I2C_TransferSeq_TypeDef::data, I2C_TransferSeq_TypeDef::flags, I2C_FLAG_WRITE_READ, I2CSPM_Transfer(), i2cTransferDone, and I2C_TransferSeq_TypeDef::len.

uint32_t CCS811_getRawData ( uint16_t *  current,
uint16_t *  rawData 
)

Gets the latest readings from the sense resistor of the CSS811 sensor.

Parameters
[out]currentThe value of current through the sensor
[out]rawDataThe raw ADC reading of the voltage across the sensor with the selected current
Returns
Returns zero on OK, non-zero otherwise

Definition at line 394 of file ccs811.c.

References I2C_TransferSeq_TypeDef::addr, BOARD_gasSensorWake(), I2C_TransferSeq_TypeDef::buf, CCS811_ADDR_RAW_DATA, CCS811_ERROR_I2C_TRANSACTION_FAILED, CCS811_I2C_DEVICE, CCS811_I2C_DEVICE_BUS_ADDRESS, CCS811_OK, I2C_TransferSeq_TypeDef::data, I2C_TransferSeq_TypeDef::flags, I2C_FLAG_WRITE_READ, I2CSPM_Transfer(), i2cTransferDone, and I2C_TransferSeq_TypeDef::len.

uint32_t CCS811_getStatus ( uint8_t *  status)

Reads the status of the CSS811 sensor.

Parameters
[out]statusThe content of the CSS811 Status Register
Returns
Returns zero on OK, non-zero otherwise.

Definition at line 148 of file ccs811.c.

References CCS811_ADDR_STATUS, and CCS811_readMailbox().

Referenced by CCS811_isDataAvailable().

uint32_t CCS811_init ( void  )

Initializes the chip and performs firmware upgrade if required.

DO_NOT_INCLUDE_WITH_DOXYGEN

Returns
Returns zero on OK, non-zero otherwise

Definition at line 67 of file ccs811.c.

References BOARD_gasSensorEnable(), BOARD_gasSensorWake(), CCS811_ERROR_INIT_FAILED, CCS811_getHardwareID(), CCS811_HW_ID, CCS811_OK, and UTIL_delay().

bool CCS811_isDataAvailable ( void  )

Checks if new measurement data available.

Returns
True if new data available, otherwise false

Definition at line 166 of file ccs811.c.

References CCS811_getStatus(), and CCS811_OK.

uint32_t CCS811_readMailbox ( uint8_t  id,
uint8_t  length,
uint8_t *  data 
)

Reads data from a specific Mailbox address.

Parameters
[in]idThe address of the Mailbox register
[in]lengthThe number of bytes to read
[out]dataThe data read from the sensor
Returns
Returns zero on OK, non-zero otherwise

Definition at line 290 of file ccs811.c.

References I2C_TransferSeq_TypeDef::addr, BOARD_gasSensorWake(), I2C_TransferSeq_TypeDef::buf, CCS811_ERROR_I2C_TRANSACTION_FAILED, CCS811_I2C_DEVICE, CCS811_I2C_DEVICE_BUS_ADDRESS, CCS811_OK, I2C_TransferSeq_TypeDef::data, I2C_TransferSeq_TypeDef::flags, I2C_FLAG_WRITE_READ, I2CSPM_Transfer(), i2cTransferDone, and I2C_TransferSeq_TypeDef::len.

Referenced by CCS811_dumpRegisters(), CCS811_getHardwareID(), CCS811_getStatus(), and CCS811_startApplication().

uint32_t CCS811_setEnvData ( int32_t  tempData,
uint32_t  rhData 
)

Writes temperature and humidity values to the environmental data regs.

Parameters
[in]tempDataThe environmental temperature in milli-Celsius
[in]rhDataThe relative humidity in milli-percent
Returns
Returns zero on OK, non-zero otherwise

Definition at line 942 of file ccs811.c.

References I2C_TransferSeq_TypeDef::addr, BOARD_gasSensorWake(), I2C_TransferSeq_TypeDef::buf, CCS811_ADDR_ENV_DATA, CCS811_ERROR_I2C_TRANSACTION_FAILED, CCS811_I2C_DEVICE, CCS811_I2C_DEVICE_BUS_ADDRESS, CCS811_OK, I2C_TransferSeq_TypeDef::data, I2C_TransferSeq_TypeDef::flags, I2C_FLAG_WRITE, I2CSPM_Transfer(), i2cTransferDone, and I2C_TransferSeq_TypeDef::len.

uint32_t CCS811_setMeasureMode ( uint8_t  measMode)
uint32_t CCS811_startApplication ( void  )

Switches the CSS811 chip from boot to application mode.

Returns
Returns zero on OK, non-zero otherwise

Definition at line 245 of file ccs811.c.

References CCS811_ADDR_STATUS, CCS811_ERROR_APPLICATION_NOT_PRESENT, CCS811_ERROR_NOT_IN_APPLICATION_MODE, and CCS811_readMailbox().