1 /*
2  * Copyright (c) 2023 Balthazar Deliers
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef ZEPHYR_INCLUDE_DRIVERS_SENSOR_AGS10_H_
8 #define ZEPHYR_INCLUDE_DRIVERS_SENSOR_AGS10_H_
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 
14 #include <zephyr/device.h>
15 #include <zephyr/drivers/i2c.h>
16 
17 #define AGS10_CMD_DATA_ACQUISITION       0x00
18 #define AGS10_CMD_ZERO_POINT_CALIBRATION 0x01
19 #define AGS10_CMD_READ_VERSION           0x11
20 #define AGS10_CMD_READ_RESISTANCE        0x20
21 #define AGS10_CMD_MODIFY_SLAVE_ADDRESS   0x21
22 
23 #define AGS10_REG_ZERO_POINT_CALIBRATION_RESET 0xFFFF /* Reset to the factory value */
24 #define AGS10_REG_ZERO_POINT_CALIBRATION_SET   0x0000 /* Set sensor resistance to zero-point */
25 #define AGS10_REG_STATUS_NRDY_READY            0x00   /* Device is ready */
26 #define AGS10_REG_STATUS_CH_PPB                0x00   /* Unit is PPB */
27 
28 #define AGS10_MSK_STATUS      0x0F
29 #define AGS10_MSK_STATUS_NRDY 0x01
30 #define AGS10_MSK_STATUS_CH   0x0E
31 
32 struct ags10_config {
33 	struct i2c_dt_spec bus;
34 };
35 
36 struct ags10_data {
37 	uint32_t tvoc_ppb;
38 	uint8_t status;
39 	uint32_t version;
40 };
41 
42 #ifdef __cplusplus
43 }
44 #endif
45 
46 #endif /* ZEPHYR_INCLUDE_DRIVERS_SENSOR_AGS10_H_ */
47