LibDriver JED1XX
Loading...
Searching...
No Matches
driver_jed1xx.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_JED1XX_H
38#define DRIVER_JED1XX_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
79
83typedef struct jed1xx_handle_s
84{
85 uint8_t (*iic_init)(void);
86 uint8_t (*iic_deinit)(void);
87 uint8_t (*iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
88 uint8_t (*iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
89 void (*delay_ms)(uint32_t ms);
90 void (*debug_print)(const char *const fmt, ...);
91 uint8_t inited;
92 uint32_t type;
94
110
114
121
128#define DRIVER_JED1XX_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
129
136#define DRIVER_JED1XX_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
137
144#define DRIVER_JED1XX_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
145
152#define DRIVER_JED1XX_LINK_IIC_READ(HANDLE, FUC) (HANDLE)->iic_read = FUC
153
160#define DRIVER_JED1XX_LINK_IIC_WRITE(HANDLE, FUC) (HANDLE)->iic_write = FUC
161
168#define DRIVER_JED1XX_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
169
176#define DRIVER_JED1XX_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
177
181
188
197uint8_t jed1xx_info(jed1xx_info_t *info);
198
208uint8_t jed1xx_set_type(jed1xx_handle_t *handle, jed1xx_type_t type);
209
219uint8_t jed1xx_get_type(jed1xx_handle_t *handle, jed1xx_type_t *type);
220
231uint8_t jed1xx_init(jed1xx_handle_t *handle);
232
243uint8_t jed1xx_deinit(jed1xx_handle_t *handle);
244
257uint8_t jed1xx_read(jed1xx_handle_t *handle, uint16_t *raw, float *ppm);
258
262
269
283uint8_t jed1xx_set_reg(jed1xx_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
284
298uint8_t jed1xx_get_reg(jed1xx_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
299
303
307
308#ifdef __cplusplus
309}
310#endif
311
312#endif
uint8_t jed1xx_deinit(jed1xx_handle_t *handle)
close the chip
struct jed1xx_handle_s jed1xx_handle_t
jed1xx handle structure definition
struct jed1xx_info_s jed1xx_info_t
jed1xx information structure definition
uint8_t jed1xx_set_type(jed1xx_handle_t *handle, jed1xx_type_t type)
set the chip type
uint8_t jed1xx_read(jed1xx_handle_t *handle, uint16_t *raw, float *ppm)
read data
jed1xx_type_t
jed1xx type enumeration definition
uint8_t jed1xx_info(jed1xx_info_t *info)
get chip's information
uint8_t jed1xx_init(jed1xx_handle_t *handle)
initialize the chip
uint8_t jed1xx_get_type(jed1xx_handle_t *handle, jed1xx_type_t *type)
get the chip type
@ JED1XX_TYPE_112_NO2
@ JED1XX_TYPE_103_H2
@ JED1XX_TYPE_131_O3
@ JED1XX_TYPE_107_C2H5OH
@ JED1XX_TYPE_115_SMOG
@ JED1XX_TYPE_138_C6H6
@ JED1XX_TYPE_101_VOC
@ JED1XX_TYPE_117_CH3COCH3
@ JED1XX_TYPE_109_C3H8
@ JED1XX_TYPE_104_C0
@ JED1XX_TYPE_110_CF2CL2
@ JED1XX_TYPE_105_NH3
@ JED1XX_TYPE_116_CH2O
@ JED1XX_TYPE_106_H2S
uint8_t jed1xx_get_reg(jed1xx_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
uint8_t jed1xx_set_reg(jed1xx_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
jed1xx handle structure definition
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
jed1xx information structure definition
float supply_voltage_max_v
uint32_t driver_version
char manufacturer_name[32]
float supply_voltage_min_v
char chip_name[32]