LibDriver BA234
Loading...
Searching...
No Matches
driver_ba234.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_BA234_H
38#define DRIVER_BA234_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
62#ifndef BA234_READ_TIMEOUT
63 #define BA234_READ_TIMEOUT 2000
64#endif
65
76
95
99typedef struct ba234_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_flush)(void);
105 uint8_t (*uart_write)(uint8_t *buf, uint16_t len);
106 void (*delay_ms)(uint32_t ms);
107 void (*debug_print)(const char *const fmt, ...);
108 uint8_t inited;
109 uint8_t last_status;
111
127
131
138
145#define DRIVER_BA234_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
146
153#define DRIVER_BA234_LINK_UART_INIT(HANDLE, FUC) (HANDLE)->uart_init = FUC
154
161#define DRIVER_BA234_LINK_UART_DEINIT(HANDLE, FUC) (HANDLE)->uart_deinit = FUC
162
169#define DRIVER_BA234_LINK_UART_READ(HANDLE, FUC) (HANDLE)->uart_read = FUC
170
177#define DRIVER_BA234_LINK_UART_WRITE(HANDLE, FUC) (HANDLE)->uart_write = FUC
178
185#define DRIVER_BA234_LINK_UART_FLUSH(HANDLE, FUC) (HANDLE)->uart_flush = FUC
186
193#define DRIVER_BA234_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
194
201#define DRIVER_BA234_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
202
206
213
222uint8_t ba234_info(ba234_info_t *info);
223
234uint8_t ba234_init(ba234_handle_t *handle);
235
246uint8_t ba234_deinit(ba234_handle_t *handle);
247
260uint8_t ba234_read(ba234_handle_t *handle, ba234_data_t *data);
261
275
289uint8_t ba234_salinity_calibration(ba234_handle_t *handle, uint16_t value);
290
301uint8_t ba234_get_last_status(ba234_handle_t *handle, ba234_status_t *status);
302
314uint8_t ba234_salinity_convert_to_register(ba234_handle_t *handle, float percentage, uint16_t *reg);
315
327uint8_t ba234_salinity_convert_to_data(ba234_handle_t *handle, uint16_t reg, float *percentage);
328
332
339
352uint8_t ba234_set_buffer(ba234_handle_t *handle, uint8_t *buf, uint16_t len);
353
366uint8_t ba234_get_buffer(ba234_handle_t *handle, uint8_t *buf, uint16_t len);
367
371
375
376#ifdef __cplusplus
377}
378#endif
379
380#endif
struct ba234_info_s ba234_info_t
ba234 information structure definition
uint8_t ba234_info(ba234_info_t *info)
get chip's information
uint8_t ba234_get_last_status(ba234_handle_t *handle, ba234_status_t *status)
get last status
uint8_t ba234_init(ba234_handle_t *handle)
initialize the chip
uint8_t ba234_deinit(ba234_handle_t *handle)
close the chip
struct ba234_handle_s ba234_handle_t
ba234 handle structure definition
uint8_t ba234_salinity_calibration(ba234_handle_t *handle, uint16_t value)
salinity calibration
uint8_t ba234_baseline_calibration(ba234_handle_t *handle)
baseline calibration
uint8_t ba234_read(ba234_handle_t *handle, ba234_data_t *data)
read the data
struct ba234_data_s ba234_data_t
ba234 data structure definition
uint8_t ba234_salinity_convert_to_data(ba234_handle_t *handle, uint16_t reg, float *percentage)
convert the register raw data to the salinity
uint8_t ba234_salinity_convert_to_register(ba234_handle_t *handle, float percentage, uint16_t *reg)
convert the salinity to the register raw data
ba234_status_t
ba234 status enumeration definition
@ BA234_STATUS_OK
@ BA234_STATUS_BUSY
@ BA234_STATUS_CALIBRATION_ERROR
@ BA234_STATUS_FRAME_ERROR
uint8_t ba234_get_buffer(ba234_handle_t *handle, uint8_t *buf, uint16_t len)
get buffer
uint8_t ba234_set_buffer(ba234_handle_t *handle, uint8_t *buf, uint16_t len)
set buffer
ba234 data structure definition
float temperature_degrees_celsius
uint16_t temperature_raw
float specific_gravity
float electrical_conductivity_us_cm
float salinity_percentage
uint16_t specific_gravity_raw
float water_hardness_ppm
uint16_t salinity_raw
uint16_t water_hardness_raw
uint16_t tds_raw
uint32_t electrical_conductivity_raw
ba234 handle structure definition
uint8_t(* uart_flush)(void)
uint8_t(* uart_write)(uint8_t *buf, uint16_t len)
uint8_t last_status
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)
ba234 information structure definition
float temperature_max
float supply_voltage_max_v
uint32_t driver_version
float temperature_min
float max_current_ma
char manufacturer_name[32]
float supply_voltage_min_v
char interface[8]
char chip_name[32]