LibDriver AOX4000
Loading...
Searching...
No Matches
driver_aox4000.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_AOX4000_H
38#define DRIVER_AOX4000_H
39
40#include <stdio.h>
41#include <stdint.h>
42#include <stdlib.h>
43#include <string.h>
44
45#ifdef __cplusplus
46extern "C"{
47#endif
48
54
59
63#ifndef AOX4000_UART_DELAY_MS
64 #define AOX4000_UART_DELAY_MS 200
65#endif
66
70#ifndef AOX4000_UART_POLL_DELAY_MS
71 #define AOX4000_UART_POLL_DELAY_MS 3500
72#endif
73
86
90typedef enum
91{
95
99typedef struct aox4000_handle_s
100{
101 uint8_t (*uart_init)(void);
102 uint8_t (*uart_deinit)(void);
103 uint16_t (*uart_read)(uint8_t *buf, uint16_t len);
104 uint8_t (*uart_write)(uint8_t *buf, uint16_t len);
105 uint8_t (*uart_flush)(void);
106 void (*delay_ms)(uint32_t ms);
107 void (*debug_print)(const char *const fmt, ...);
108 uint8_t mode;
109 uint8_t last_error;
110 uint8_t inited;
112
128
132
139
146#define DRIVER_AOX4000_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
147
154#define DRIVER_AOX4000_LINK_UART_INIT(HANDLE, FUC) (HANDLE)->uart_init = FUC
155
162#define DRIVER_AOX4000_LINK_UART_DEINIT(HANDLE, FUC) (HANDLE)->uart_deinit = FUC
163
170#define DRIVER_AOX4000_LINK_UART_READ(HANDLE, FUC) (HANDLE)->uart_read = FUC
171
178#define DRIVER_AOX4000_LINK_UART_WRITE(HANDLE, FUC) (HANDLE)->uart_write = FUC
179
186#define DRIVER_AOX4000_LINK_UART_FLUSH(HANDLE, FUC) (HANDLE)->uart_flush = FUC
187
194#define DRIVER_AOX4000_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
195
202#define DRIVER_AOX4000_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
203
207
214
223uint8_t aox4000_info(aox4000_info_t *info);
224
235uint8_t aox4000_init(aox4000_handle_t *handle);
236
247uint8_t aox4000_deinit(aox4000_handle_t *handle);
248
263uint8_t aox4000_read(aox4000_handle_t *handle, float *oxygen_ppo2_mbar,
264 float *oxygen_density_percentage,
265 float *temperature_degree, float *pressure_mbar);
266
278uint8_t aox4000_read_oxygen_ppo2(aox4000_handle_t *handle, float *mbar);
279
291uint8_t aox4000_read_oxygen_density(aox4000_handle_t *handle, float *percentage);
292
304uint8_t aox4000_read_temperature(aox4000_handle_t *handle, float *degree);
305
317uint8_t aox4000_read_pressure(aox4000_handle_t *handle, float *mbar);
318
331
343uint8_t aox4000_get_mode(aox4000_handle_t *handle, aox4000_mode_t *mode);
344
356
360
367
380uint8_t aox4000_command_read(aox4000_handle_t *handle, char *buf, uint16_t len);
381
394uint8_t aox4000_command_write(aox4000_handle_t *handle, char *buf, uint16_t len);
395
399
403
404#ifdef __cplusplus
405}
406#endif
407
408#endif
uint8_t aox4000_read(aox4000_handle_t *handle, float *oxygen_ppo2_mbar, float *oxygen_density_percentage, float *temperature_degree, float *pressure_mbar)
read data
uint8_t aox4000_read_oxygen_density(aox4000_handle_t *handle, float *percentage)
read oxygen density
uint8_t aox4000_info(aox4000_info_t *info)
get chip's information
struct aox4000_handle_s aox4000_handle_t
aox4000 handle structure definition
aox4000_status_t
aox4000 status enumeration definition
uint8_t aox4000_read_temperature(aox4000_handle_t *handle, float *degree)
read temperature
uint8_t aox4000_get_last_error(aox4000_handle_t *handle, aox4000_status_t *status)
get last error
uint8_t aox4000_deinit(aox4000_handle_t *handle)
close the chip
aox4000_mode_t
aox4000 mode enumeration definition
uint8_t aox4000_init(aox4000_handle_t *handle)
initialize the chip
struct aox4000_info_s aox4000_info_t
aox4000 information structure definition
uint8_t aox4000_read_oxygen_ppo2(aox4000_handle_t *handle, float *mbar)
read oxygen ppo2
uint8_t aox4000_read_pressure(aox4000_handle_t *handle, float *mbar)
read pressure
uint8_t aox4000_get_mode(aox4000_handle_t *handle, aox4000_mode_t *mode)
get mode
uint8_t aox4000_set_mode(aox4000_handle_t *handle, aox4000_mode_t mode)
set mode
@ AOX4000_STATUS_UNKNOWN
@ AOX4000_STATUS_INVALID_FRAME
@ AOX4000_STATUS_INVALID_PARAM
@ AOX4000_STATUS_OVERRUN
@ AOX4000_STATUS_INVALID_COMMAND
@ AOX4000_STATUS_OK
@ AOX4000_MODE_AUTO
@ AOX4000_MODE_REQUEST
uint8_t aox4000_command_read(aox4000_handle_t *handle, char *buf, uint16_t len)
command read
uint8_t aox4000_command_write(aox4000_handle_t *handle, char *buf, uint16_t len)
command write
aox4000 handle structure definition
uint8_t(* uart_flush)(void)
uint8_t(* uart_write)(uint8_t *buf, uint16_t len)
void(* delay_ms)(uint32_t ms)
uint8_t(* uart_deinit)(void)
void(* debug_print)(const char *const fmt,...)
uint16_t(* uart_read)(uint8_t *buf, uint16_t len)
uint8_t(* uart_init)(void)
aox4000 information structure definition
uint32_t driver_version
char manufacturer_name[32]