LibDriver CCS811
Loading...
Searching...
No Matches
ccs811 base driver function

ccs811 base driver modules More...

Collaboration diagram for ccs811 base driver function:

Data Structures

struct  ccs811_handle_s
 ccs811 handle structure definition More...
struct  ccs811_info_s
 ccs811 information structure definition More...

Typedefs

typedef struct ccs811_handle_s ccs811_handle_t
 ccs811 handle structure definition
typedef struct ccs811_info_s ccs811_info_t
 ccs811 information structure definition

Enumerations

enum  ccs811_address_t { CCS811_ADDRESS_GND = (0x5A << 1) , CCS811_ADDRESS_VCC = (0x5B << 1) }
 ccs811 address enumeration definition More...
enum  ccs811_bool_t { CCS811_BOOL_FALSE = 0x00 , CCS811_BOOL_TRUE = 0x01 }
 ccs811 bool enumeration definition More...
enum  ccs811_mode_t {
  CCS811_MODE_IDLE = 0x00 , CCS811_MODE_CONSTANT_POWER = 0x01 , CCS811_MODE_PULSE_HEATING = 0x02 , CCS811_MODE_LOW_POWER_PULSE_HEATING = 0x03 ,
  CCS811_MODE_HIGH_CONSTANT_POWER = 0x04
}
 ccs811 mode enumeration definition More...
enum  ccs811_status_t { CCS811_STATUS_FW_MODE = (1 << 7) , CCS811_STATUS_APP_VALID = (1 << 4) , CCS811_STATUS_DATA_READY = (1 << 3) , CCS811_STATUS_ERROR = (1 << 0) }
 ccs811 status enumeration definition More...
enum  ccs811_interrupt { CCS811_INTERRUPT_READY = 0x03 , CCS811_INTERRUPT_THRESHOLD = 0x02 }
 ccs811 interrupt enumeration definition More...
enum  ccs811_error_t {
  CCS811_ERROR_WRITE_REG_INVALID = (1 << 0) , CCS811_ERROR_READ_REG_INVALID = (1 << 1) , CCS811_ERROR_MEASMODE_INVALID = (1 << 2) , CCS811_ERROR_MAX_RESISTANCE = (1 << 3) ,
  CCS811_ERROR_HEATER_FAULT = (1 << 4) , CCS811_ERROR_HEATER_SUPPLY = (1 << 5)
}
 ccs811 error enumeration definition More...

Functions

uint8_t ccs811_info (ccs811_info_t *info)
 get chip information
uint8_t ccs811_set_addr_pin (ccs811_handle_t *handle, ccs811_address_t addr_pin)
 set address pin
uint8_t ccs811_get_addr_pin (ccs811_handle_t *handle, ccs811_address_t *addr_pin)
 get address pin
uint8_t ccs811_init (ccs811_handle_t *handle)
 initialize the chip
uint8_t ccs811_deinit (ccs811_handle_t *handle)
 close the chip
uint8_t ccs811_read (ccs811_handle_t *handle, uint16_t *eco2_ppm, uint16_t *tvoc_ppb, uint16_t *raw)
 read data
uint8_t ccs811_get_raw_data (ccs811_handle_t *handle, uint16_t *raw, uint8_t *ua, uint16_t *adc_raw, float *adc_v)
 get raw data
uint8_t ccs811_get_status (ccs811_handle_t *handle, uint8_t *status)
 get status
uint8_t ccs811_set_mode (ccs811_handle_t *handle, ccs811_mode_t mode)
 set mode
uint8_t ccs811_get_mode (ccs811_handle_t *handle, ccs811_mode_t *mode)
 get mode
uint8_t ccs811_set_interrupt_data_ready (ccs811_handle_t *handle, ccs811_bool_t enable)
 enable or disable interrupt data ready
uint8_t ccs811_get_interrupt_data_ready (ccs811_handle_t *handle, ccs811_bool_t *enable)
 get interrupt data ready status
uint8_t ccs811_set_interrupt_threshold (ccs811_handle_t *handle, ccs811_bool_t enable)
 enable or disable interrupt threshold
uint8_t ccs811_get_interrupt_threshold (ccs811_handle_t *handle, ccs811_bool_t *enable)
 get interrupt threshold status
uint8_t ccs811_set_environment_data (ccs811_handle_t *handle, uint16_t humidity_raw, uint16_t temperature_raw)
 set environment data
uint8_t ccs811_set_eco2_threshold (ccs811_handle_t *handle, uint16_t low_medium_ppm, uint16_t medium_high_ppm, uint8_t hysteresis)
 set eco2 threshold
uint8_t ccs811_set_baseline (ccs811_handle_t *handle, uint16_t baseline)
 set baseline
uint8_t ccs811_get_baseline (ccs811_handle_t *handle, uint16_t *baseline)
 get baseline
uint8_t ccs811_get_error_id (ccs811_handle_t *handle, uint8_t *id)
 get error id
uint8_t ccs811_get_hardware_id (ccs811_handle_t *handle, uint8_t *id)
 get hardware id
uint8_t ccs811_get_hardware_version (ccs811_handle_t *handle, uint8_t *version)
 get hardware version
uint8_t ccs811_get_firmware_bootloader_version (ccs811_handle_t *handle, uint8_t *major, uint8_t *minor, uint8_t *trivial)
 get firmware bootloader version
uint8_t ccs811_get_firmware_application_version (ccs811_handle_t *handle, uint8_t *major, uint8_t *minor, uint8_t *trivial)
 get firmware application version
uint8_t ccs811_soft_reset (ccs811_handle_t *handle)
 soft reset
uint8_t ccs811_wake_up (ccs811_handle_t *handle, ccs811_bool_t enable)
 wake up
uint8_t ccs811_hard_reset (ccs811_handle_t *handle)
 hard reset
uint8_t ccs811_environment_humidity_convert_to_register (ccs811_handle_t *handle, float humidity, uint16_t *reg)
 convert real data format to register data format
uint8_t ccs811_environment_humidity_convert_to_data (ccs811_handle_t *handle, uint16_t reg, float *humidity)
 convert register data to real data format
uint8_t ccs811_environment_temperature_convert_to_register (ccs811_handle_t *handle, float temperature, uint16_t *reg)
 convert real data format to register data format
uint8_t ccs811_environment_temperature_convert_to_data (ccs811_handle_t *handle, uint16_t reg, float *temperature)
 convert register data to real data format

Detailed Description

ccs811 base driver modules

Typedef Documentation

◆ ccs811_handle_t

ccs811 handle structure definition

◆ ccs811_info_t

typedef struct ccs811_info_s ccs811_info_t

ccs811 information structure definition

Enumeration Type Documentation

◆ ccs811_address_t

ccs811 address enumeration definition

Enumerator
CCS811_ADDRESS_GND 

addr pin connected to the GND

CCS811_ADDRESS_VCC 

addr pin connected to the VCC

Definition at line 62 of file driver_ccs811.h.

◆ ccs811_bool_t

ccs811 bool enumeration definition

Enumerator
CCS811_BOOL_FALSE 

disable

CCS811_BOOL_TRUE 

true

Definition at line 71 of file driver_ccs811.h.

◆ ccs811_error_t

ccs811 error enumeration definition

Enumerator
CCS811_ERROR_WRITE_REG_INVALID 

write register invalid

CCS811_ERROR_READ_REG_INVALID 

read register invalid

CCS811_ERROR_MEASMODE_INVALID 

meas mode invalid

CCS811_ERROR_MAX_RESISTANCE 

max resistance

CCS811_ERROR_HEATER_FAULT 

heater fault

CCS811_ERROR_HEATER_SUPPLY 

heater supply

Definition at line 112 of file driver_ccs811.h.

◆ ccs811_interrupt

ccs811 interrupt enumeration definition

Enumerator
CCS811_INTERRUPT_READY 

ready

CCS811_INTERRUPT_THRESHOLD 

threshold

Definition at line 103 of file driver_ccs811.h.

◆ ccs811_mode_t

ccs811 mode enumeration definition

Enumerator
CCS811_MODE_IDLE 

idle

CCS811_MODE_CONSTANT_POWER 

constant power

CCS811_MODE_PULSE_HEATING 

pulse heating

CCS811_MODE_LOW_POWER_PULSE_HEATING 

low power pulse heating

CCS811_MODE_HIGH_CONSTANT_POWER 

high constant power

Definition at line 80 of file driver_ccs811.h.

◆ ccs811_status_t

ccs811 status enumeration definition

Enumerator
CCS811_STATUS_FW_MODE 

fw mode

CCS811_STATUS_APP_VALID 

app valid

CCS811_STATUS_DATA_READY 

data ready

CCS811_STATUS_ERROR 

error

Definition at line 92 of file driver_ccs811.h.

Function Documentation

◆ ccs811_deinit()

uint8_t ccs811_deinit ( ccs811_handle_t * handle)

close the chip

Parameters
[in]*handlepointer to a ccs811 handle structure
Returns
status code
  • 0 success
  • 1 deinit failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 reset failed
Note
none

Definition at line 1961 of file driver_ccs811.c.

◆ ccs811_environment_humidity_convert_to_data()

uint8_t ccs811_environment_humidity_convert_to_data ( ccs811_handle_t * handle,
uint16_t reg,
float * humidity )

convert register data to real data format

Parameters
[in]*handlepointer to a ccs811 handle structure
[in]regregister data
[out]*humiditypointer to a real data buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1287 of file driver_ccs811.c.

◆ ccs811_environment_humidity_convert_to_register()

uint8_t ccs811_environment_humidity_convert_to_register ( ccs811_handle_t * handle,
float humidity,
uint16_t * reg )

convert real data format to register data format

Parameters
[in]*handlepointer to a ccs811 handle structure
[in]humidityhumidity in percentage
[out]*regpointer to a converted data buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1260 of file driver_ccs811.c.

◆ ccs811_environment_temperature_convert_to_data()

uint8_t ccs811_environment_temperature_convert_to_data ( ccs811_handle_t * handle,
uint16_t reg,
float * temperature )

convert register data to real data format

Parameters
[in]*handlepointer to a ccs811 handle structure
[in]regregister data
[out]*temperaturepointer to a real data buffer in degrees
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1341 of file driver_ccs811.c.

◆ ccs811_environment_temperature_convert_to_register()

uint8_t ccs811_environment_temperature_convert_to_register ( ccs811_handle_t * handle,
float temperature,
uint16_t * reg )

convert real data format to register data format

Parameters
[in]*handlepointer to a ccs811 handle structure
[in]temperaturetemperature in degrees
[out]*regpointer to a converted data buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1314 of file driver_ccs811.c.

◆ ccs811_get_addr_pin()

uint8_t ccs811_get_addr_pin ( ccs811_handle_t * handle,
ccs811_address_t * addr_pin )

get address pin

Parameters
[in]*handlepointer to a ccs811 handle structure
[out]*addr_pinpointer to an address pin buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 144 of file driver_ccs811.c.

◆ ccs811_get_baseline()

uint8_t ccs811_get_baseline ( ccs811_handle_t * handle,
uint16_t * baseline )

get baseline

Parameters
[in]*handlepointer to a ccs811 handle structure
[out]*baselinepointer to a baseline buffer
Returns
status code
  • 0 success
  • 1 get baseline failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 696 of file driver_ccs811.c.

◆ ccs811_get_error_id()

uint8_t ccs811_get_error_id ( ccs811_handle_t * handle,
uint8_t * id )

get error id

Parameters
[in]*handlepointer to a ccs811 handle structure
[out]*idpointer to an id buffer
Returns
status code
  • 0 success
  • 1 get error id failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 885 of file driver_ccs811.c.

◆ ccs811_get_firmware_application_version()

uint8_t ccs811_get_firmware_application_version ( ccs811_handle_t * handle,
uint8_t * major,
uint8_t * minor,
uint8_t * trivial )

get firmware application version

Parameters
[in]*handlepointer to a ccs811 handle structure
[out]*majorpointer to a major buffer
[out]*minorpointer to a minor buffer
[out]*trivialpointer to a trivial buffer
Returns
status code
  • 0 success
  • 1 get firmware application version failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 846 of file driver_ccs811.c.

◆ ccs811_get_firmware_bootloader_version()

uint8_t ccs811_get_firmware_bootloader_version ( ccs811_handle_t * handle,
uint8_t * major,
uint8_t * minor,
uint8_t * trivial )

get firmware bootloader version

Parameters
[in]*handlepointer to a ccs811 handle structure
[out]*majorpointer to a major buffer
[out]*minorpointer to a minor buffer
[out]*trivialpointer to a trivial buffer
Returns
status code
  • 0 success
  • 1 get firmware bootloader version failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 805 of file driver_ccs811.c.

◆ ccs811_get_hardware_id()

uint8_t ccs811_get_hardware_id ( ccs811_handle_t * handle,
uint8_t * id )

get hardware id

Parameters
[in]*handlepointer to a ccs811 handle structure
[out]*idpointer to an id buffer
Returns
status code
  • 0 success
  • 1 get hardware id failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 733 of file driver_ccs811.c.

◆ ccs811_get_hardware_version()

uint8_t ccs811_get_hardware_version ( ccs811_handle_t * handle,
uint8_t * version )

get hardware version

Parameters
[in]*handlepointer to a ccs811 handle structure
[out]*versionpointer to a version buffer
Returns
status code
  • 0 success
  • 1 get hardware version failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 768 of file driver_ccs811.c.

◆ ccs811_get_interrupt_data_ready()

uint8_t ccs811_get_interrupt_data_ready ( ccs811_handle_t * handle,
ccs811_bool_t * enable )

get interrupt data ready status

Parameters
[in]*handlepointer to a ccs811 handle structure
[out]*enablepointer to a bool value
Returns
status code
  • 0 success
  • 1 get interrupt data ready failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 329 of file driver_ccs811.c.

◆ ccs811_get_interrupt_threshold()

uint8_t ccs811_get_interrupt_threshold ( ccs811_handle_t * handle,
ccs811_bool_t * enable )

get interrupt threshold status

Parameters
[in]*handlepointer to a ccs811 handle structure
[out]*enablepointer to a bool value
Returns
status code
  • 0 success
  • 1 get interrupt threshold failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 411 of file driver_ccs811.c.

◆ ccs811_get_mode()

uint8_t ccs811_get_mode ( ccs811_handle_t * handle,
ccs811_mode_t * mode )

get mode

Parameters
[in]*handlepointer to a ccs811 handle structure
[out]*modepointer to a mode buffer
Returns
status code
  • 0 success
  • 1 get mode failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 247 of file driver_ccs811.c.

◆ ccs811_get_raw_data()

uint8_t ccs811_get_raw_data ( ccs811_handle_t * handle,
uint16_t * raw,
uint8_t * ua,
uint16_t * adc_raw,
float * adc_v )

get raw data

Parameters
[in]*handlepointer to a ccs811 handle structure
[out]*rawpointer to a raw buffer
[out]*uapointer to a ua buffer
[out]*adc_rawpointer to an adc raw buffer
[out]*adc_vpointer to an adc converted data buffer in voltage
Returns
status code
  • 0 success
  • 1 read failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 find error
  • 5 data is not ready
Note
none

Definition at line 511 of file driver_ccs811.c.

◆ ccs811_get_status()

uint8_t ccs811_get_status ( ccs811_handle_t * handle,
uint8_t * status )

get status

Parameters
[in]*handlepointer to a ccs811 handle structure
[out]*statuspointer to a status buffer
Returns
status code
  • 0 success
  • 1 get status failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 167 of file driver_ccs811.c.

◆ ccs811_hard_reset()

uint8_t ccs811_hard_reset ( ccs811_handle_t * handle)

hard reset

Parameters
[in]*handlepointer to a ccs811 handle structure
Returns
status code
  • 0 success
  • 1 hard reset failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1217 of file driver_ccs811.c.

◆ ccs811_info()

uint8_t ccs811_info ( ccs811_info_t * info)

get chip information

Parameters
[out]*infopointer to a ccs811 info structure
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 2074 of file driver_ccs811.c.

◆ ccs811_init()

uint8_t ccs811_init ( ccs811_handle_t * handle)

initialize the chip

Parameters
[in]*handlepointer to a ccs811 handle structure
Returns
status code
  • 0 success
  • 1 iic or gpio initialization failed
  • 2 handle is NULL
  • 3 linked functions is NULL
  • 4 id is error
  • 5 firmware loaded failed
Note
none

Definition at line 1528 of file driver_ccs811.c.

◆ ccs811_read()

uint8_t ccs811_read ( ccs811_handle_t * handle,
uint16_t * eco2_ppm,
uint16_t * tvoc_ppb,
uint16_t * raw )

read data

Parameters
[in]*handlepointer to a ccs811 handle structure
[out]*eco2_ppmpointer to an eco2 ppm buffer
[out]*tvoc_ppbpointer to a tvoc ppb buffer
[out]*rawpointer to a raw buffer
Returns
status code
  • 0 success
  • 1 read failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 find error
  • 5 data is not ready
Note
none

Definition at line 452 of file driver_ccs811.c.

◆ ccs811_set_addr_pin()

uint8_t ccs811_set_addr_pin ( ccs811_handle_t * handle,
ccs811_address_t addr_pin )

set address pin

Parameters
[in]*handlepointer to a ccs811 handle structure
[in]addr_pinaddress pin
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 123 of file driver_ccs811.c.

◆ ccs811_set_baseline()

uint8_t ccs811_set_baseline ( ccs811_handle_t * handle,
uint16_t baseline )

set baseline

Parameters
[in]*handlepointer to a ccs811 handle structure
[in]baselineinput baseline
Returns
status code
  • 0 success
  • 1 set baseline failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 658 of file driver_ccs811.c.

◆ ccs811_set_eco2_threshold()

uint8_t ccs811_set_eco2_threshold ( ccs811_handle_t * handle,
uint16_t low_medium_ppm,
uint16_t medium_high_ppm,
uint8_t hysteresis )

set eco2 threshold

Parameters
[in]*handlepointer to a ccs811 handle structure
[in]low_medium_ppmlow to medium threshold in ppm
[in]medium_high_ppmmedium to high threshold in ppm
[in]hysteresisinput hysteresis
Returns
status code
  • 0 success
  • 1 set eco2 threshold failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 617 of file driver_ccs811.c.

◆ ccs811_set_environment_data()

uint8_t ccs811_set_environment_data ( ccs811_handle_t * handle,
uint16_t humidity_raw,
uint16_t temperature_raw )

set environment data

Parameters
[in]*handlepointer to a ccs811 handle structure
[in]humidity_rawinput humidity raw
[in]temperature_rawinput temperature raw
Returns
status code
  • 0 success
  • 1 set environment data failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 575 of file driver_ccs811.c.

◆ ccs811_set_interrupt_data_ready()

uint8_t ccs811_set_interrupt_data_ready ( ccs811_handle_t * handle,
ccs811_bool_t enable )

enable or disable interrupt data ready

Parameters
[in]*handlepointer to a ccs811 handle structure
[in]enablebool value
Returns
status code
  • 0 success
  • 1 set interrupt data ready failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 284 of file driver_ccs811.c.

◆ ccs811_set_interrupt_threshold()

uint8_t ccs811_set_interrupt_threshold ( ccs811_handle_t * handle,
ccs811_bool_t enable )

enable or disable interrupt threshold

Parameters
[in]*handlepointer to a ccs811 handle structure
[in]enablebool value
Returns
status code
  • 0 success
  • 1 set interrupt threshold failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 366 of file driver_ccs811.c.

◆ ccs811_set_mode()

uint8_t ccs811_set_mode ( ccs811_handle_t * handle,
ccs811_mode_t mode )

set mode

Parameters
[in]*handlepointer to a ccs811 handle structure
[in]modechip mode
Returns
status code
  • 0 success
  • 1 set mode failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 202 of file driver_ccs811.c.

◆ ccs811_soft_reset()

uint8_t ccs811_soft_reset ( ccs811_handle_t * handle)

soft reset

Parameters
[in]*handlepointer to a ccs811 handle structure
Returns
status code
  • 0 success
  • 1 soft reset failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 919 of file driver_ccs811.c.

◆ ccs811_wake_up()

uint8_t ccs811_wake_up ( ccs811_handle_t * handle,
ccs811_bool_t enable )

wake up

Parameters
[in]*handlepointer to a ccs811 handle structure
[in]enablebool value
Returns
status code
  • 0 success
  • 1 wake up failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1170 of file driver_ccs811.c.