47 lines
993 B
C
47 lines
993 B
C
/*
|
|
* sgp4x.h
|
|
*
|
|
* Created on: Jan 9, 2022
|
|
* Author: david
|
|
*/
|
|
|
|
#ifndef INC_SGP40_H_
|
|
#define INC_SGP40_H_
|
|
|
|
|
|
#include "stdint.h"
|
|
|
|
/*
|
|
* Defines & macros
|
|
*/
|
|
|
|
#define SGP40_I2C_ADDRESS 0x59
|
|
#define SGP40_MAX_MEAS_DURATION_MS 50
|
|
|
|
/*
|
|
* Return values
|
|
*/
|
|
|
|
#define SGP40_OK 0
|
|
#define SGP40_ERROR -1 // generic error
|
|
#define SGP40_CRC8_ERROR -2 // checksum failed
|
|
|
|
typedef enum {
|
|
SGP40_MEASURE_RAW_SIGNAL = 0x260F,
|
|
SGP40_EXECUTE_SELF_TEST = 0x280E,
|
|
SGP40_TURN_HEATER_OFF = 0x3615,
|
|
SGP40_GET_SERIAL_NUMBER = 0x3682,
|
|
SGP40_SOFT_RESET = 0x0006
|
|
} sgp40_cmd_t;
|
|
|
|
int8_t sgp40_send_cmd(sgp40_cmd_t cmd);
|
|
|
|
int8_t sgp40_measure_raw_signal (uint16_t * voc_ticks);
|
|
int8_t sgp40_measure_raw_signal_compensated (uint16_t * voc_ticks, uint16_t relative_humidity, int16_t temperature);
|
|
int8_t sgp40_execute_self_test ( uint8_t * test_result);
|
|
int8_t sgp40_get_serial_number ( uint8_t serial[6]);
|
|
int8_t sgp40_turn_heater_off ( void );
|
|
int8_t sgp40_soft_reset ( void );
|
|
|
|
#endif /* INC_SGP40_H_ */
|