LibDriver STCC4
Loading...
Searching...
No Matches
driver_stcc4.c File Reference

driver stcc4 source file More...

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

Go to the source code of this file.

Macros

#define CHIP_NAME   "Sensirion STCC4"
 chip information definition
#define MANUFACTURER_NAME   "Sensirion"
#define SUPPLY_VOLTAGE_MIN   2.7f
#define SUPPLY_VOLTAGE_MAX   5.5f
#define MAX_CURRENT   4.2f
#define TEMPERATURE_MIN   -40.0f
#define TEMPERATURE_MAX   85.0f
#define DRIVER_VERSION   1000
#define STCC4_COMMAND_START_CONTINUOUS_MEASUREMENT   0x218BU
 chip command definition
#define STCC4_COMMAND_STOP_CONTINUOUS_MEASUREMENT   0x3F86U
#define STCC4_COMMAND_READ_MEASUREMENT   0xEC05U
#define STCC4_COMMAND_SET_RHT_COMPENSATION   0xE000U
#define STCC4_COMMAND_SET_PRESSURER_COMPENSATION   0xE016U
#define STCC4_COMMAND_MEASURE_SINGLE_SHOT   0x219DU
#define STCC4_COMMAND_ENTER_SLEEP_MODE   0x3650U
#define STCC4_COMMAND_EXIT_SLEEP_MODE   0x00U
#define STCC4_COMMAND_PERFORM_CONDITIONING   0x29BCU
#define STCC4_COMMAND_PERFORM_SOFT_RESET   0x06U
#define STCC4_COMMAND_PERFORM_FACTORY_RESET   0x3632U
#define STCC4_COMMAND_PERFORM_SELF_TEST   0x278CU
#define STCC4_COMMAND_ENABLE_TESTING_MODE   0x3FBCU
#define STCC4_COMMAND_DISABLE_TESTING_MODE   0x3F3DU
#define STCC4_COMMAND_PERFORM_FORCED_RECALIBRATION   0x362FU
#define STCC4_COMMAND_GET_PRODUCT_ID   0x365BU
#define STCC4_CRC8_POLYNOMIAL   0x31
 crc8 definition
#define STCC4_CRC8_INIT   0xFF

Functions

uint8_t stcc4_set_address_pin (stcc4_handle_t *handle, stcc4_address_t address)
 set address pin
uint8_t stcc4_get_address_pin (stcc4_handle_t *handle, stcc4_address_t *address)
 get address pin
uint8_t stcc4_start_continuous_measurement (stcc4_handle_t *handle)
 start continuous measurement
uint8_t stcc4_stop_continuous_measurement (stcc4_handle_t *handle)
 stop continuous measurement
uint8_t stcc4_set_rht_compensation (stcc4_handle_t *handle, uint16_t temperature_raw, uint16_t humidity_raw)
 set rht compensation
uint8_t stcc4_set_pressure_compensation (stcc4_handle_t *handle, uint16_t pressure_raw)
 set pressure compensation
uint8_t stcc4_measure_single_shot (stcc4_handle_t *handle)
 measure single shot
uint8_t stcc4_enter_sleep_mode (stcc4_handle_t *handle)
 enter sleep mode
uint8_t stcc4_exit_sleep_mode (stcc4_handle_t *handle)
 exit sleep mode
uint8_t stcc4_perform_conditioning (stcc4_handle_t *handle)
 perform conditioning
uint8_t stcc4_perform_soft_reset (stcc4_handle_t *handle)
 perform soft reset
uint8_t stcc4_perform_factory_reset (stcc4_handle_t *handle)
 perform factory reset
uint8_t stcc4_perform_self_test (stcc4_handle_t *handle, uint16_t *result)
 perform self test
uint8_t stcc4_enable_testing_mode (stcc4_handle_t *handle)
 enable testing mode
uint8_t stcc4_disable_testing_mode (stcc4_handle_t *handle)
 disable testing mode
uint8_t stcc4_perform_forced_recalibration (stcc4_handle_t *handle, uint16_t target_co2, uint16_t *correct_co2)
 perform forced recalibration
uint8_t stcc4_get_product_id (stcc4_handle_t *handle, uint32_t *product_id, uint8_t unique_serial_number[8])
 get product id
uint8_t stcc4_read (stcc4_handle_t *handle, int16_t *co2_raw, int16_t *co2_ppm, uint16_t *temperature_raw, float *temperature_s, uint16_t *humidity_raw, float *humidity_s, uint16_t *sensor_status)
 read data
uint8_t stcc4_init (stcc4_handle_t *handle)
 initialize the chip
uint8_t stcc4_deinit (stcc4_handle_t *handle)
 close the chip
uint8_t stcc4_frc_co2_convert_to_register (stcc4_handle_t *handle, float ppm, uint16_t *reg)
 convert the frc co2 to the register raw data
uint8_t stcc4_frc_co2_convert_to_data (stcc4_handle_t *handle, uint16_t reg, float *ppm)
 convert the register raw data to frc co2 ppm
uint8_t stcc4_humidity_convert_to_register (stcc4_handle_t *handle, float percentage, uint16_t *reg)
 convert the humidity to the register raw data
uint8_t stcc4_humidity_convert_to_data (stcc4_handle_t *handle, uint16_t reg, float *percentage)
 convert the register raw data to humidity
uint8_t stcc4_temperature_convert_to_register (stcc4_handle_t *handle, float deg, uint16_t *reg)
 convert the temperature to the register raw data
uint8_t stcc4_temperature_convert_to_data (stcc4_handle_t *handle, uint16_t reg, float *deg)
 convert the register raw data to temperature
uint8_t stcc4_pressure_convert_to_register (stcc4_handle_t *handle, float pa, uint16_t *reg)
 convert the pressure to the register raw data
uint8_t stcc4_pressure_convert_to_data (stcc4_handle_t *handle, uint16_t reg, float *pa)
 convert the register raw data to pressure
uint8_t stcc4_set_reg (stcc4_handle_t *handle, uint16_t reg, uint8_t *buf, uint16_t len)
 set the chip register
uint8_t stcc4_get_reg (stcc4_handle_t *handle, uint16_t reg, uint8_t *buf, uint16_t len, uint16_t delay_ms)
 get the chip register
uint8_t stcc4_info (stcc4_info_t *info)
 get chip information

Detailed Description

driver stcc4 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-10-25

history

Date Version Author Description
2025/10/25 1.0 Shifeng Li first upload

Definition in file driver_stcc4.c.

Macro Definition Documentation

◆ CHIP_NAME

#define CHIP_NAME   "Sensirion STCC4"

chip information definition

chip name

Definition at line 42 of file driver_stcc4.c.

◆ DRIVER_VERSION

#define DRIVER_VERSION   1000

driver version

Definition at line 49 of file driver_stcc4.c.

◆ MANUFACTURER_NAME

#define MANUFACTURER_NAME   "Sensirion"

manufacturer name

Definition at line 43 of file driver_stcc4.c.

◆ MAX_CURRENT

#define MAX_CURRENT   4.2f

chip max current

Definition at line 46 of file driver_stcc4.c.

◆ STCC4_COMMAND_DISABLE_TESTING_MODE

#define STCC4_COMMAND_DISABLE_TESTING_MODE   0x3F3DU

disable testing mode command

Definition at line 67 of file driver_stcc4.c.

◆ STCC4_COMMAND_ENABLE_TESTING_MODE

#define STCC4_COMMAND_ENABLE_TESTING_MODE   0x3FBCU

enable testing mode command

Definition at line 66 of file driver_stcc4.c.

◆ STCC4_COMMAND_ENTER_SLEEP_MODE

#define STCC4_COMMAND_ENTER_SLEEP_MODE   0x3650U

enter sleep mode command

Definition at line 60 of file driver_stcc4.c.

◆ STCC4_COMMAND_EXIT_SLEEP_MODE

#define STCC4_COMMAND_EXIT_SLEEP_MODE   0x00U

exit sleep mode command

Definition at line 61 of file driver_stcc4.c.

◆ STCC4_COMMAND_GET_PRODUCT_ID

#define STCC4_COMMAND_GET_PRODUCT_ID   0x365BU

get product id command

Definition at line 69 of file driver_stcc4.c.

◆ STCC4_COMMAND_MEASURE_SINGLE_SHOT

#define STCC4_COMMAND_MEASURE_SINGLE_SHOT   0x219DU

measure single shot command

Definition at line 59 of file driver_stcc4.c.

◆ STCC4_COMMAND_PERFORM_CONDITIONING

#define STCC4_COMMAND_PERFORM_CONDITIONING   0x29BCU

perform conditioning command

Definition at line 62 of file driver_stcc4.c.

◆ STCC4_COMMAND_PERFORM_FACTORY_RESET

#define STCC4_COMMAND_PERFORM_FACTORY_RESET   0x3632U

perform factory reset command

Definition at line 64 of file driver_stcc4.c.

◆ STCC4_COMMAND_PERFORM_FORCED_RECALIBRATION

#define STCC4_COMMAND_PERFORM_FORCED_RECALIBRATION   0x362FU

perform forced recalibration command

Definition at line 68 of file driver_stcc4.c.

◆ STCC4_COMMAND_PERFORM_SELF_TEST

#define STCC4_COMMAND_PERFORM_SELF_TEST   0x278CU

perform self test command

Definition at line 65 of file driver_stcc4.c.

◆ STCC4_COMMAND_PERFORM_SOFT_RESET

#define STCC4_COMMAND_PERFORM_SOFT_RESET   0x06U

perform soft reset command

Definition at line 63 of file driver_stcc4.c.

◆ STCC4_COMMAND_READ_MEASUREMENT

#define STCC4_COMMAND_READ_MEASUREMENT   0xEC05U

read measurement command

Definition at line 56 of file driver_stcc4.c.

◆ STCC4_COMMAND_SET_PRESSURER_COMPENSATION

#define STCC4_COMMAND_SET_PRESSURER_COMPENSATION   0xE016U

set pressure compensation command

Definition at line 58 of file driver_stcc4.c.

◆ STCC4_COMMAND_SET_RHT_COMPENSATION

#define STCC4_COMMAND_SET_RHT_COMPENSATION   0xE000U

set rht compensation command

Definition at line 57 of file driver_stcc4.c.

◆ STCC4_COMMAND_START_CONTINUOUS_MEASUREMENT

#define STCC4_COMMAND_START_CONTINUOUS_MEASUREMENT   0x218BU

chip command definition

start continuous measurement command

Definition at line 54 of file driver_stcc4.c.

◆ STCC4_COMMAND_STOP_CONTINUOUS_MEASUREMENT

#define STCC4_COMMAND_STOP_CONTINUOUS_MEASUREMENT   0x3F86U

stop continuous measurement command

Definition at line 55 of file driver_stcc4.c.

◆ STCC4_CRC8_INIT

#define STCC4_CRC8_INIT   0xFF

Definition at line 75 of file driver_stcc4.c.

◆ STCC4_CRC8_POLYNOMIAL

#define STCC4_CRC8_POLYNOMIAL   0x31

crc8 definition

Definition at line 74 of file driver_stcc4.c.

◆ SUPPLY_VOLTAGE_MAX

#define SUPPLY_VOLTAGE_MAX   5.5f

chip max supply voltage

Definition at line 45 of file driver_stcc4.c.

◆ SUPPLY_VOLTAGE_MIN

#define SUPPLY_VOLTAGE_MIN   2.7f

chip min supply voltage

Definition at line 44 of file driver_stcc4.c.

◆ TEMPERATURE_MAX

#define TEMPERATURE_MAX   85.0f

chip max operating temperature

Definition at line 48 of file driver_stcc4.c.

◆ TEMPERATURE_MIN

#define TEMPERATURE_MIN   -40.0f

chip min operating temperature

Definition at line 47 of file driver_stcc4.c.