LibDriver CCS811
Loading...
Searching...
No Matches
driver_ccs811.c File Reference

driver ccs811 source file More...

#include "driver_ccs811.h"
Include dependency graph for driver_ccs811.c:

Go to the source code of this file.

Macros

#define CHIP_NAME   "AMS CCS811"
 chip information definition
#define MANUFACTURER_NAME   "AMS"
#define SUPPLY_VOLTAGE_MIN   1.8f
#define SUPPLY_VOLTAGE_MAX   3.6f
#define MAX_CURRENT   54.0f
#define TEMPERATURE_MIN   -40.0f
#define TEMPERATURE_MAX   85.0f
#define DRIVER_VERSION   1000
#define CCS811_REG_STATUS   0x00
 chip register definition
#define CCS811_REG_MEAS_MODE   0x01
#define CCS811_REG_ALG_RESULT_DATA   0x02
#define CCS811_REG_RAW_DATA   0x03
#define CCS811_REG_ENV_DATA   0x05
#define CCS811_REG_THRESHOLDS   0x10
#define CCS811_REG_BASELINE   0x11
#define CCS811_REG_APP_ERASE   0xF1
#define CCS811_REG_APP_DATA   0xF2
#define CCS811_REG_APP_VERIFY   0xF3
#define CCS811_REG_APP_START   0xF4
#define CCS811_REG_HW_ID   0x20
#define CCS811_REG_HW_VERSION   0x21
#define CCS811_REG_FW_BOOT_VERSION   0x23
#define CCS811_REG_FW_APP_VERSION   0x24
#define CCS811_REG_ERROR_ID   0xE0
#define CCS811_REG_SW_RESET   0xFF

Functions

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_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_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_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_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_get_error_id (ccs811_handle_t *handle, uint8_t *id)
 get error id
uint8_t ccs811_soft_reset (ccs811_handle_t *handle)
 soft reset
uint8_t ccs811_app_erase (ccs811_handle_t *handle)
 app erase
uint8_t ccs811_app_verify (ccs811_handle_t *handle)
 app verify
uint8_t ccs811_app_start (ccs811_handle_t *handle)
 app start
uint8_t ccs811_app_program (ccs811_handle_t *handle, uint8_t *rom, uint32_t len)
 app program
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
uint8_t ccs811_app_firmware_update (ccs811_handle_t *handle, char *path)
 app firmware update
uint8_t ccs811_init (ccs811_handle_t *handle)
 initialize the chip
uint8_t ccs811_app_firmware_init (ccs811_handle_t *handle)
 app firmware initialize
uint8_t ccs811_deinit (ccs811_handle_t *handle)
 close the chip
uint8_t ccs811_set_reg (ccs811_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
 set the chip register
uint8_t ccs811_get_reg (ccs811_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
 get the chip register
uint8_t ccs811_info (ccs811_info_t *info)
 get chip information

Detailed Description

driver ccs811 source file

Copyright (c) 2015 - present LibDriver All rights reserved

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version
1.0.0
Author
Shifeng Li
Date
2025-06-30

history

Date Version Author Description
2025/06/30 1.0 Shifeng Li first upload

Definition in file driver_ccs811.c.

Macro Definition Documentation

◆ CCS811_REG_ALG_RESULT_DATA

#define CCS811_REG_ALG_RESULT_DATA   0x02

alg result data register

Definition at line 56 of file driver_ccs811.c.

◆ CCS811_REG_APP_DATA

#define CCS811_REG_APP_DATA   0xF2

app data register

Definition at line 62 of file driver_ccs811.c.

◆ CCS811_REG_APP_ERASE

#define CCS811_REG_APP_ERASE   0xF1

app erase register

Definition at line 61 of file driver_ccs811.c.

◆ CCS811_REG_APP_START

#define CCS811_REG_APP_START   0xF4

app start register

Definition at line 64 of file driver_ccs811.c.

◆ CCS811_REG_APP_VERIFY

#define CCS811_REG_APP_VERIFY   0xF3

app verify register

Definition at line 63 of file driver_ccs811.c.

◆ CCS811_REG_BASELINE

#define CCS811_REG_BASELINE   0x11

baseline register

Definition at line 60 of file driver_ccs811.c.

◆ CCS811_REG_ENV_DATA

#define CCS811_REG_ENV_DATA   0x05

env data register

Definition at line 58 of file driver_ccs811.c.

◆ CCS811_REG_ERROR_ID

#define CCS811_REG_ERROR_ID   0xE0

error id register

Definition at line 69 of file driver_ccs811.c.

◆ CCS811_REG_FW_APP_VERSION

#define CCS811_REG_FW_APP_VERSION   0x24

fw app version register

Definition at line 68 of file driver_ccs811.c.

◆ CCS811_REG_FW_BOOT_VERSION

#define CCS811_REG_FW_BOOT_VERSION   0x23

fw boot version register

Definition at line 67 of file driver_ccs811.c.

◆ CCS811_REG_HW_ID

#define CCS811_REG_HW_ID   0x20

hw id register

Definition at line 65 of file driver_ccs811.c.

◆ CCS811_REG_HW_VERSION

#define CCS811_REG_HW_VERSION   0x21

hw version register

Definition at line 66 of file driver_ccs811.c.

◆ CCS811_REG_MEAS_MODE

#define CCS811_REG_MEAS_MODE   0x01

meas mode register

Definition at line 55 of file driver_ccs811.c.

◆ CCS811_REG_RAW_DATA

#define CCS811_REG_RAW_DATA   0x03

raw data register

Definition at line 57 of file driver_ccs811.c.

◆ CCS811_REG_STATUS

#define CCS811_REG_STATUS   0x00

chip register definition

status register

Definition at line 54 of file driver_ccs811.c.

◆ CCS811_REG_SW_RESET

#define CCS811_REG_SW_RESET   0xFF

sw reset register

Definition at line 70 of file driver_ccs811.c.

◆ CCS811_REG_THRESHOLDS

#define CCS811_REG_THRESHOLDS   0x10

thresholds register

Definition at line 59 of file driver_ccs811.c.

◆ CHIP_NAME

#define CHIP_NAME   "AMS CCS811"

chip information definition

chip name

Definition at line 42 of file driver_ccs811.c.

◆ DRIVER_VERSION

#define DRIVER_VERSION   1000

driver version

Definition at line 49 of file driver_ccs811.c.

◆ MANUFACTURER_NAME

#define MANUFACTURER_NAME   "AMS"

manufacturer name

Definition at line 43 of file driver_ccs811.c.

◆ MAX_CURRENT

#define MAX_CURRENT   54.0f

chip max current

Definition at line 46 of file driver_ccs811.c.

◆ SUPPLY_VOLTAGE_MAX

#define SUPPLY_VOLTAGE_MAX   3.6f

chip max supply voltage

Definition at line 45 of file driver_ccs811.c.

◆ SUPPLY_VOLTAGE_MIN

#define SUPPLY_VOLTAGE_MIN   1.8f

chip min supply voltage

Definition at line 44 of file driver_ccs811.c.

◆ TEMPERATURE_MAX

#define TEMPERATURE_MAX   85.0f

chip max operating temperature

Definition at line 48 of file driver_ccs811.c.

◆ TEMPERATURE_MIN

#define TEMPERATURE_MIN   -40.0f

chip min operating temperature

Definition at line 47 of file driver_ccs811.c.