Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
environment2_drv.h File Reference
#include "drv_digital_in.h"
#include "drv_digital_out.h"
#include "drv_i2c_master.h"
Include dependency graph for environment2_drv.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  environment2_t
 Environment 2 Click context object. More...
 
struct  environment2_cfg_t
 Environment 2 Click configuration object. More...
 
struct  environment2_voc_algorithm_params
 Environment 2 Click VOC algorithm object. More...
 

Macros

#define ENVIRONMENT2_SGP40_CMD_MEASURE_RAW   0x260F
 Environment 2 SGP40 description commands. More...
 
#define ENVIRONMENT2_SGP40_CMD_MEASURE_TEST   0x280E
 
#define ENVIRONMENT2_SGP40_CMD_HEATER_OFF   0x3615
 
#define ENVIRONMENT2_SGP40_CMD_SOFT_RESET   0x0006
 
#define ENVIRONMENT2_SHT40_CMD_MEASURE_T_RH_HIGH_PRECISION   0xFD
 Environment 2 SHT40 description commands. More...
 
#define ENVIRONMENT2_SHT40_CMD_MEASURE_T_RH_MEDIUM_PRECISION   0xF6
 
#define ENVIRONMENT2_SHT40_CMD_MEASURE_T_RH_LOWEST_PRECISION   0xE0
 
#define ENVIRONMENT2_SHT40_CMD_READ_SERIAL   0x89
 
#define ENVIRONMENT2_SHT40_CMD_SOFT_RESET   0x94
 
#define ENVIRONMENT2_SHT40_CMD_ACTIVATE_HIGHEST_HEATER_1SEC   0x39
 
#define ENVIRONMENT2_SHT40_CMD_ACTIVATE_HIGHEST_HEATER_0_1SEC   0x32
 
#define ENVIRONMENT2_SHT40_CMD_ACTIVATE_MEDIUM_HEATER_1SEC   0x2F
 
#define ENVIRONMENT2_SHT40_CMD_ACTIVATE_MEDIUM_HEATER_0_1SEC   0x24
 
#define ENVIRONMENT2_SHT40_CMD_ACTIVATE_LOWEST_HEATER_1SEC   0x1E
 
#define ENVIRONMENT2_SHT40_CMD_ACTIVATE_LOWEST_HEATER_0_1SEC   0x15
 
#define ENVIRONMENT2_SGP40_SET_DEV_ADDR   0x59
 Environment 2 device address setting. More...
 
#define ENVIRONMENT2_SHT40_SET_DEV_ADDR   0x44
 
#define ENVIRONMENT2_SEL_SGP40   0x00
 Environment 2 device selection. More...
 
#define ENVIRONMENT2_SEL_SHT40   0x01
 
#define F16(x)   ((fix16_t)(((x) >= 0) ? ((x)*65536.0 + 0.5) : ((x)*65536.0 - 0.5)))
 Environment 2 fixed point arithmetic parts. More...
 
#define VocAlgorithm_SAMPLING_INTERVAL   ((float)(sgp40_sampling_interval) / 1000.0)
 
#define VocAlgorithm_INITIAL_BLACKOUT   (45.)
 
#define VocAlgorithm_VOC_INDEX_GAIN   (230.)
 
#define VocAlgorithm_SRAW_STD_INITIAL   (50.)
 
#define VocAlgorithm_SRAW_STD_BONUS   (220.)
 
#define VocAlgorithm_TAU_MEAN_VARIANCE_HOURS   (12.)
 
#define VocAlgorithm_TAU_INITIAL_MEAN   (20.)
 
#define VocAlgorithm_INIT_DURATION_MEAN   ((3600. * 0.75))
 
#define VocAlgorithm_INIT_TRANSITION_MEAN   (0.01)
 
#define VocAlgorithm_TAU_INITIAL_VARIANCE   (2500.)
 
#define VocAlgorithm_INIT_DURATION_VARIANCE   ((3600. * 1.45))
 
#define VocAlgorithm_INIT_TRANSITION_VARIANCE   (0.01)
 
#define VocAlgorithm_GATING_THRESHOLD   (340.)
 
#define VocAlgorithm_GATING_THRESHOLD_INITIAL   (510.)
 
#define VocAlgorithm_GATING_THRESHOLD_TRANSITION   (0.09)
 
#define VocAlgorithm_GATING_MAX_DURATION_MINUTES   ((60. * 3.))
 
#define VocAlgorithm_GATING_MAX_RATIO   (0.3)
 
#define VocAlgorithm_SIGMOID_L   (500.)
 
#define VocAlgorithm_SIGMOID_K   (-0.0065)
 
#define VocAlgorithm_SIGMOID_X0   (213.)
 
#define VocAlgorithm_VOC_INDEX_OFFSET_DEFAULT   (100.)
 
#define VocAlgorithm_LP_TAU_FAST   (20.0)
 
#define VocAlgorithm_LP_TAU_SLOW   (500.0)
 
#define VocAlgorithm_LP_ALPHA   (-0.2)
 
#define VocAlgorithm_PERSISTENCE_UPTIME_GAMMA   ((3. * 3600.))
 
#define VocAlgorithm_MEAN_VARIANCE_ESTIMATOR__GAMMA_SCALING   (64.)
 
#define VocAlgorithm_MEAN_VARIANCE_ESTIMATOR__FIX16_MAX   (32767.)
 
#define ENVIRONMENT2_SGP40_TEST_PASSED   0xD400
 Environment 2 SGP40 description setting. More...
 
#define ENVIRONMENT2_SGP40_TEST_FAILED   0x4B00
 

Typedefs

typedef int32_t fix16_t
 

Functions

void environment2_voc_config (void)
 
void environment2_voc_algorithm (int32_t sraw, int32_t *voc_index)
 

Variables

uint32_t sgp40_sampling_interval
 

Macro Definition Documentation

◆ ENVIRONMENT2_SEL_SGP40

#define ENVIRONMENT2_SEL_SGP40   0x00

Environment 2 device selection.

Specified selection for device slave address of Environment 2 Click driver.

◆ ENVIRONMENT2_SEL_SHT40

#define ENVIRONMENT2_SEL_SHT40   0x01

◆ ENVIRONMENT2_SGP40_CMD_HEATER_OFF

#define ENVIRONMENT2_SGP40_CMD_HEATER_OFF   0x3615

◆ ENVIRONMENT2_SGP40_CMD_MEASURE_RAW

#define ENVIRONMENT2_SGP40_CMD_MEASURE_RAW   0x260F

Environment 2 SGP40 description commands.

Specified SGP40 commands for description of Environment 2 Click driver.

◆ ENVIRONMENT2_SGP40_CMD_MEASURE_TEST

#define ENVIRONMENT2_SGP40_CMD_MEASURE_TEST   0x280E

◆ ENVIRONMENT2_SGP40_CMD_SOFT_RESET

#define ENVIRONMENT2_SGP40_CMD_SOFT_RESET   0x0006

◆ ENVIRONMENT2_SGP40_SET_DEV_ADDR

#define ENVIRONMENT2_SGP40_SET_DEV_ADDR   0x59

Environment 2 device address setting.

Specified setting for device slave address selection of Environment 2 Click driver.

◆ ENVIRONMENT2_SGP40_TEST_FAILED

#define ENVIRONMENT2_SGP40_TEST_FAILED   0x4B00

◆ ENVIRONMENT2_SGP40_TEST_PASSED

#define ENVIRONMENT2_SGP40_TEST_PASSED   0xD400

Environment 2 SGP40 description setting.

Specified SGP40 setting for description of Environment 2 Click driver.

◆ ENVIRONMENT2_SHT40_CMD_ACTIVATE_HIGHEST_HEATER_0_1SEC

#define ENVIRONMENT2_SHT40_CMD_ACTIVATE_HIGHEST_HEATER_0_1SEC   0x32

◆ ENVIRONMENT2_SHT40_CMD_ACTIVATE_HIGHEST_HEATER_1SEC

#define ENVIRONMENT2_SHT40_CMD_ACTIVATE_HIGHEST_HEATER_1SEC   0x39

◆ ENVIRONMENT2_SHT40_CMD_ACTIVATE_LOWEST_HEATER_0_1SEC

#define ENVIRONMENT2_SHT40_CMD_ACTIVATE_LOWEST_HEATER_0_1SEC   0x15

◆ ENVIRONMENT2_SHT40_CMD_ACTIVATE_LOWEST_HEATER_1SEC

#define ENVIRONMENT2_SHT40_CMD_ACTIVATE_LOWEST_HEATER_1SEC   0x1E

◆ ENVIRONMENT2_SHT40_CMD_ACTIVATE_MEDIUM_HEATER_0_1SEC

#define ENVIRONMENT2_SHT40_CMD_ACTIVATE_MEDIUM_HEATER_0_1SEC   0x24

◆ ENVIRONMENT2_SHT40_CMD_ACTIVATE_MEDIUM_HEATER_1SEC

#define ENVIRONMENT2_SHT40_CMD_ACTIVATE_MEDIUM_HEATER_1SEC   0x2F

◆ ENVIRONMENT2_SHT40_CMD_MEASURE_T_RH_HIGH_PRECISION

#define ENVIRONMENT2_SHT40_CMD_MEASURE_T_RH_HIGH_PRECISION   0xFD

Environment 2 SHT40 description commands.

Specified SHT40 commands for description of Environment 2 Click driver.

◆ ENVIRONMENT2_SHT40_CMD_MEASURE_T_RH_LOWEST_PRECISION

#define ENVIRONMENT2_SHT40_CMD_MEASURE_T_RH_LOWEST_PRECISION   0xE0

◆ ENVIRONMENT2_SHT40_CMD_MEASURE_T_RH_MEDIUM_PRECISION

#define ENVIRONMENT2_SHT40_CMD_MEASURE_T_RH_MEDIUM_PRECISION   0xF6

◆ ENVIRONMENT2_SHT40_CMD_READ_SERIAL

#define ENVIRONMENT2_SHT40_CMD_READ_SERIAL   0x89

◆ ENVIRONMENT2_SHT40_CMD_SOFT_RESET

#define ENVIRONMENT2_SHT40_CMD_SOFT_RESET   0x94

◆ ENVIRONMENT2_SHT40_SET_DEV_ADDR

#define ENVIRONMENT2_SHT40_SET_DEV_ADDR   0x44

◆ F16

#define F16 (   x)    ((fix16_t)(((x) >= 0) ? ((x)*65536.0 + 0.5) : ((x)*65536.0 - 0.5)))

Environment 2 fixed point arithmetic parts.

Specified the fixed point arithmetic parts for VOC algorithm of Environment 2 Click driver.

◆ VocAlgorithm_GATING_MAX_DURATION_MINUTES

#define VocAlgorithm_GATING_MAX_DURATION_MINUTES   ((60. * 3.))

◆ VocAlgorithm_GATING_MAX_RATIO

#define VocAlgorithm_GATING_MAX_RATIO   (0.3)

◆ VocAlgorithm_GATING_THRESHOLD

#define VocAlgorithm_GATING_THRESHOLD   (340.)

◆ VocAlgorithm_GATING_THRESHOLD_INITIAL

#define VocAlgorithm_GATING_THRESHOLD_INITIAL   (510.)

◆ VocAlgorithm_GATING_THRESHOLD_TRANSITION

#define VocAlgorithm_GATING_THRESHOLD_TRANSITION   (0.09)

◆ VocAlgorithm_INIT_DURATION_MEAN

#define VocAlgorithm_INIT_DURATION_MEAN   ((3600. * 0.75))

◆ VocAlgorithm_INIT_DURATION_VARIANCE

#define VocAlgorithm_INIT_DURATION_VARIANCE   ((3600. * 1.45))

◆ VocAlgorithm_INIT_TRANSITION_MEAN

#define VocAlgorithm_INIT_TRANSITION_MEAN   (0.01)

◆ VocAlgorithm_INIT_TRANSITION_VARIANCE

#define VocAlgorithm_INIT_TRANSITION_VARIANCE   (0.01)

◆ VocAlgorithm_INITIAL_BLACKOUT

#define VocAlgorithm_INITIAL_BLACKOUT   (45.)

◆ VocAlgorithm_LP_ALPHA

#define VocAlgorithm_LP_ALPHA   (-0.2)

◆ VocAlgorithm_LP_TAU_FAST

#define VocAlgorithm_LP_TAU_FAST   (20.0)

◆ VocAlgorithm_LP_TAU_SLOW

#define VocAlgorithm_LP_TAU_SLOW   (500.0)

◆ VocAlgorithm_MEAN_VARIANCE_ESTIMATOR__FIX16_MAX

#define VocAlgorithm_MEAN_VARIANCE_ESTIMATOR__FIX16_MAX   (32767.)

◆ VocAlgorithm_MEAN_VARIANCE_ESTIMATOR__GAMMA_SCALING

#define VocAlgorithm_MEAN_VARIANCE_ESTIMATOR__GAMMA_SCALING   (64.)

◆ VocAlgorithm_PERSISTENCE_UPTIME_GAMMA

#define VocAlgorithm_PERSISTENCE_UPTIME_GAMMA   ((3. * 3600.))

◆ VocAlgorithm_SAMPLING_INTERVAL

#define VocAlgorithm_SAMPLING_INTERVAL   ((float)(sgp40_sampling_interval) / 1000.0)

◆ VocAlgorithm_SIGMOID_K

#define VocAlgorithm_SIGMOID_K   (-0.0065)

◆ VocAlgorithm_SIGMOID_L

#define VocAlgorithm_SIGMOID_L   (500.)

◆ VocAlgorithm_SIGMOID_X0

#define VocAlgorithm_SIGMOID_X0   (213.)

◆ VocAlgorithm_SRAW_STD_BONUS

#define VocAlgorithm_SRAW_STD_BONUS   (220.)

◆ VocAlgorithm_SRAW_STD_INITIAL

#define VocAlgorithm_SRAW_STD_INITIAL   (50.)

◆ VocAlgorithm_TAU_INITIAL_MEAN

#define VocAlgorithm_TAU_INITIAL_MEAN   (20.)

◆ VocAlgorithm_TAU_INITIAL_VARIANCE

#define VocAlgorithm_TAU_INITIAL_VARIANCE   (2500.)

◆ VocAlgorithm_TAU_MEAN_VARIANCE_HOURS

#define VocAlgorithm_TAU_MEAN_VARIANCE_HOURS   (12.)

◆ VocAlgorithm_VOC_INDEX_GAIN

#define VocAlgorithm_VOC_INDEX_GAIN   (230.)

◆ VocAlgorithm_VOC_INDEX_OFFSET_DEFAULT

#define VocAlgorithm_VOC_INDEX_OFFSET_DEFAULT   (100.)

Typedef Documentation

◆ fix16_t

typedef int32_t fix16_t

Function Documentation

◆ environment2_voc_algorithm()

void environment2_voc_algorithm ( int32_t  sraw,
int32_t *  voc_index 
)

◆ environment2_voc_config()

void environment2_voc_config ( void  )

Variable Documentation

◆ sgp40_sampling_interval

uint32_t sgp40_sampling_interval
extern