EFR32 Mighty Gecko 13 Software Documentation  efr32mg13-doc-5.1.2
ccs811.h
Go to the documentation of this file.
1 /***************************************************************************/
17 #ifndef __CCS811_H_
18 #define __CCS811_H_
19 
20 #include <stdbool.h>
21 
22 #include "ccs811_config.h"
23 
24  /**************************************************************************/
29 /***************************************************************************/
35 #ifndef CCS811_CONFIG_FIRMWARE_UPDATE
36  #define CCS811_CONFIG_FIRMWARE_UPDATE (0)
37 #endif
38 
39 #ifndef CCS811_CONFIG_I2C_BUS_TIMEOUT
40  #define CCS811_CONFIG_I2C_BUS_TIMEOUT (1000)
41 #endif
42 
43 #ifndef CCS811_CONFIG_I2C_DEVICE
44  #define CCS811_CONFIG_I2C_DEVICE (I2C0)
45 #endif
46 
47 #ifndef CCS811_CONFIG_I2C_BUS_ADDRESS
48  #define CCS811_CONFIG_I2C_BUS_ADDRESS (0xB4)
49 #endif
50 
51 #define CCS811_FIRMWARE_UPDATE (CCS811_CONFIG_FIRMWARE_UPDATE)
52 #define CCS811_I2C_DEVICE (CCS811_CONFIG_I2C_DEVICE)
53 #define CCS811_I2C_DEVICE_BUS_ADDRESS (CCS811_CONFIG_I2C_BUS_ADDRESS)
54 #define CCS811_I2C_DEVICE_BUS_TIMEOUT (CCS811_CONFIG_I2C_BUS_TIMEOUT)
55 #define CCS811_HW_ID 0x81
59 /***************************************************************************/
65 #define CCS811_OK 0x0000
66 #define CCS811_ERROR_APPLICATION_NOT_PRESENT 0x0001
67 #define CCS811_ERROR_NOT_IN_APPLICATION_MODE 0x0002
68 #define CCS811_ERROR_DRIVER_NOT_INITIALIZED 0x0003
69 #define CCS811_ERROR_I2C_TRANSACTION_FAILED 0x0004
70 #define CCS811_ERROR_INIT_FAILED 0x0005
71 #define CCS811_ERROR_FIRMWARE_UPDATE_FAILED 0x0006
75 /***************************************************************************/
81 #define CCS811_ADDR_STATUS 0x00
82 #define CCS811_ADDR_MEASURE_MODE 0x01
83 #define CCS811_ADDR_ALG_RESULT_DATA 0x02
84 #define CCS811_ADDR_RAW_DATA 0x03
85 #define CCS811_ADDR_ENV_DATA 0x05
86 #define CCS811_ADDR_NTC 0x06
87 #define CCS811_ADDR_THRESHOLDS 0x10
88 #define CCS811_ADDR_HW_ID 0x20
89 #define CCS811_ADDR_HW_VERSION 0x21
90 #define CCS811_ADDR_FW_BOOT_VERSION 0x23
91 #define CCS811_ADDR_FW_APP_VERSION 0x24
92 #define CCS811_ADDR_ERR_ID 0xE0
93 #define CCS811_ADDR_FW_ERASE 0xF1
94 #define CCS811_ADDR_FW_PROGRAM 0xF2
95 #define CCS811_ADDR_FW_VERIFY 0xF3
96 #define CCS811_ADDR_APP_START 0xF4
97 #define CCS811_ADDR_SW_RESET 0xFF
101 /***************************************************************************/
107 #define CCS811_MEASURE_MODE_DRIVE_MODE_SHIFT 4
108 #define CCS811_MEASURE_MODE_DRIVE_MODE_IDLE 0x00
109 #define CCS811_MEASURE_MODE_DRIVE_MODE_1SEC 0x10
110 #define CCS811_MEASURE_MODE_DRIVE_MODE_10SEC 0x20
111 #define CCS811_MEASURE_MODE_DRIVE_MODE_60SEC 0x30
112 #define CCS811_MEASURE_MODE_DRIVE_MODE_RAW 0x40
113 #define CCS811_MEASURE_MODE_INTERRUPT 0x08
114 #define CCS811_MEASURE_MODE_THRESH 0x04
118 /***************************************************************************/
124 uint32_t CCS811_init ( void );
125 uint32_t CCS811_deInit ( void );
126 uint32_t CCS811_getHardwareID ( uint8_t *hwID );
127 uint32_t CCS811_getStatus ( uint8_t *status );
128 uint32_t CCS811_readMailbox ( uint8_t id, uint8_t length, uint8_t *data );
129 uint32_t CCS811_startApplication ( void );
130 uint32_t CCS811_softwareReset ( void );
131 uint32_t CCS811_setMeasureMode ( uint8_t measMode );
132 void CCS811_dumpRegisters ( void );
133 
134 bool CCS811_isDataAvailable ( void );
135 uint32_t CCS811_getMeasurement ( uint16_t *eco2, uint16_t *tvoc );
136 uint32_t CCS811_getRawData ( uint16_t *current, uint16_t *rawData );
137 uint32_t CCS811_setEnvData ( int32_t tempData, uint32_t rhData );
138 
143 #endif /* __CCS811_H_ */
uint32_t CCS811_setMeasureMode(uint8_t measMode)
Sets the measurement mode of the CSS811 sensor.
Definition: ccs811.c:492
uint32_t CCS811_setEnvData(int32_t tempData, uint32_t rhData)
Writes temperature and humidity values to the environmental data regs.
Definition: ccs811.c:942
bool CCS811_isDataAvailable(void)
Checks if new measurement data available.
Definition: ccs811.c:166
uint32_t CCS811_getStatus(uint8_t *status)
Reads the status of the CSS811 sensor.
Definition: ccs811.c:148
uint32_t CCS811_softwareReset(void)
Performs software reset on the CCS811.
Definition: ccs811.c:443
uint32_t CCS811_getHardwareID(uint8_t *hardwareID)
Reads Hardware ID from the CSS811 sensor.
Definition: ccs811.c:127
uint32_t CCS811_startApplication(void)
Switches the CSS811 chip from boot to application mode.
Definition: ccs811.c:245
uint32_t CCS811_getMeasurement(uint16_t *eco2, uint16_t *tvoc)
Reads measurement data (eCO2 and TVOC) from the CSS811 sensor.
Definition: ccs811.c:339
uint32_t CCS811_readMailbox(uint8_t id, uint8_t length, uint8_t *data)
Reads data from a specific Mailbox address.
Definition: ccs811.c:290
uint32_t CCS811_getRawData(uint16_t *current, uint16_t *rawData)
Gets the latest readings from the sense resistor of the CSS811 sensor.
Definition: ccs811.c:394
uint32_t CCS811_deInit(void)
De-initializes the chip.
Definition: ccs811.c:106
void CCS811_dumpRegisters(void)
Dumps the registers of the CSS811.
Definition: ccs811.c:193