LibDriver AGS02MA
Loading...
Searching...
No Matches
driver_ags02ma.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_AGS02MA_H
38#define DRIVER_AGS02MA_H
39
40#include <stdio.h>
41#include <stdint.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
62typedef struct ags02ma_handle_s
63{
64 uint8_t (*iic_init)(void);
65 uint8_t (*iic_deinit)(void);
66 uint8_t (*iic_read_cmd)(uint8_t addr, uint8_t *buf, uint16_t len);
67 uint8_t (*iic_write_cmd)(uint8_t addr, uint8_t *buf, uint16_t len);
68 uint8_t (*iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
69 void (*delay_ms)(uint32_t ms);
70 void (*debug_print)(const char *const fmt, ...);
71 uint8_t inited;
72 uint8_t iic_addr;
74
90
94
101
108#define DRIVER_AGS02MA_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
109
116#define DRIVER_AGS02MA_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
117
124#define DRIVER_AGS02MA_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
125
132#define DRIVER_AGS02MA_LINK_IIC_READ_COMMAND(HANDLE, FUC) (HANDLE)->iic_read_cmd = FUC
133
140#define DRIVER_AGS02MA_LINK_IIC_WRITE_COMMAND(HANDLE, FUC) (HANDLE)->iic_write_cmd = FUC
141
148#define DRIVER_AGS02MA_LINK_IIC_WRITE(HANDLE, FUC) (HANDLE)->iic_write = FUC
149
156#define DRIVER_AGS02MA_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
157
164#define DRIVER_AGS02MA_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
165
169
176
185uint8_t ags02ma_info(ags02ma_info_t *info);
186
197uint8_t ags02ma_init(ags02ma_handle_t *handle);
198
209uint8_t ags02ma_deinit(ags02ma_handle_t *handle);
210
225uint8_t ags02ma_read_tvoc(ags02ma_handle_t *handle, uint32_t *raw, uint32_t *ppb);
226
238
252uint8_t ags02ma_get_resistance(ags02ma_handle_t *handle, uint32_t *raw, double *ohm);
253
266uint8_t ags02ma_get_version(ags02ma_handle_t *handle, uint8_t *version);
267
279uint8_t ags02ma_modify_slave_address(ags02ma_handle_t *handle, uint8_t addr_7bit);
280
291uint8_t ags02ma_set_slave_address(ags02ma_handle_t *handle, uint8_t addr);
292
303uint8_t ags02ma_get_slave_address(ags02ma_handle_t *handle, uint8_t *addr);
304
308
315
329uint8_t ags02ma_set_reg(ags02ma_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
330
344uint8_t ags02ma_get_reg(ags02ma_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
345
349
353
354#ifdef __cplusplus
355}
356#endif
357
358#endif
uint8_t ags02ma_info(ags02ma_info_t *info)
get chip's information
uint8_t ags02ma_set_slave_address(ags02ma_handle_t *handle, uint8_t addr)
set slave address
uint8_t ags02ma_modify_slave_address(ags02ma_handle_t *handle, uint8_t addr_7bit)
modify slave address
uint8_t ags02ma_get_version(ags02ma_handle_t *handle, uint8_t *version)
get version
uint8_t ags02ma_read_tvoc(ags02ma_handle_t *handle, uint32_t *raw, uint32_t *ppb)
read tvoc
uint8_t ags02ma_get_slave_address(ags02ma_handle_t *handle, uint8_t *addr)
get slave address
struct ags02ma_info_s ags02ma_info_t
ags02ma information structure definition
uint8_t ags02ma_deinit(ags02ma_handle_t *handle)
close the chip
uint8_t ags02ma_get_resistance(ags02ma_handle_t *handle, uint32_t *raw, double *ohm)
get resistance
uint8_t ags02ma_init(ags02ma_handle_t *handle)
initialize the chip
uint8_t ags02ma_zero_point_calibration(ags02ma_handle_t *handle)
zero point calibration
struct ags02ma_handle_s ags02ma_handle_t
ags02ma handle structure definition
uint8_t ags02ma_set_reg(ags02ma_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
uint8_t ags02ma_get_reg(ags02ma_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
ags02ma handle structure definition
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_read_cmd)(uint8_t addr, uint8_t *buf, uint16_t len)
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
uint8_t(* iic_write_cmd)(uint8_t addr, uint8_t *buf, uint16_t len)
ags02ma information structure definition
float supply_voltage_max_v
uint32_t driver_version
char manufacturer_name[32]
float supply_voltage_min_v