LibDriver BA111
Loading...
Searching...
No Matches
driver_ba111.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_BA111_H
38#define DRIVER_BA111_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
70
74typedef struct ba111_handle_s
75{
76 uint8_t (*uart_init)(void);
77 uint8_t (*uart_deinit)(void);
78 uint16_t (*uart_read)(uint8_t *buf, uint16_t len);
79 uint8_t (*uart_flush)(void);
80 uint8_t (*uart_write)(uint8_t *buf, uint16_t len);
81 void (*delay_ms)(uint32_t ms);
82 void (*debug_print)(const char *const fmt, ...);
83 uint8_t inited;
84 uint8_t last_status;
86
102
106
113
120#define DRIVER_BA111_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
121
128#define DRIVER_BA111_LINK_UART_INIT(HANDLE, FUC) (HANDLE)->uart_init = FUC
129
136#define DRIVER_BA111_LINK_UART_DEINIT(HANDLE, FUC) (HANDLE)->uart_deinit = FUC
137
144#define DRIVER_BA111_LINK_UART_READ(HANDLE, FUC) (HANDLE)->uart_read = FUC
145
152#define DRIVER_BA111_LINK_UART_WRITE(HANDLE, FUC) (HANDLE)->uart_write = FUC
153
160#define DRIVER_BA111_LINK_UART_FLUSH(HANDLE, FUC) (HANDLE)->uart_flush = FUC
161
168#define DRIVER_BA111_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
169
176#define DRIVER_BA111_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
177
181
188
197uint8_t ba111_info(ba111_info_t *info);
198
209uint8_t ba111_init(ba111_handle_t *handle);
210
221uint8_t ba111_deinit(ba111_handle_t *handle);
222
238uint8_t ba111_read(ba111_handle_t *handle, uint16_t *tds_raw, uint16_t *tds_ppm,
239 uint16_t *temperature_raw, float *temperature);
240
254
268uint8_t ba111_set_ntc_resistance(ba111_handle_t *handle, uint32_t ohm);
269
283uint8_t ba111_set_ntc_b(ba111_handle_t *handle, uint16_t value);
284
295uint8_t ba111_get_last_status(ba111_handle_t *handle, ba111_status_t *status);
296
300
307
320uint8_t ba111_set_buffer(ba111_handle_t *handle, uint8_t *buf, uint16_t len);
321
334uint8_t ba111_get_buffer(ba111_handle_t *handle, uint8_t *buf, uint16_t len);
335
339
343
344#ifdef __cplusplus
345}
346#endif
347
348#endif
struct ba111_handle_s ba111_handle_t
ba111 handle structure definition
uint8_t ba111_init(ba111_handle_t *handle)
initialize the chip
struct ba111_info_s ba111_info_t
ba111 information structure definition
uint8_t ba111_set_ntc_resistance(ba111_handle_t *handle, uint32_t ohm)
set ntc resistance
uint8_t ba111_info(ba111_info_t *info)
get chip's information
ba111_status_t
ba111 status enumeration definition
uint8_t ba111_baseline_calibration(ba111_handle_t *handle)
baseline calibration
uint8_t ba111_read(ba111_handle_t *handle, uint16_t *tds_raw, uint16_t *tds_ppm, uint16_t *temperature_raw, float *temperature)
read the data
uint8_t ba111_deinit(ba111_handle_t *handle)
close the chip
uint8_t ba111_set_ntc_b(ba111_handle_t *handle, uint16_t value)
set ntc b
uint8_t ba111_get_last_status(ba111_handle_t *handle, ba111_status_t *status)
get last status
@ BA111_STATUS_OK
@ BA111_STATUS_BUSY
@ BA111_STATUS_TEMPERATURE_OUT_OF_RANGE
@ BA111_STATUS_CHECK_ERROR
@ BA111_STATUS_FRAME_ERROR
uint8_t ba111_set_buffer(ba111_handle_t *handle, uint8_t *buf, uint16_t len)
set buffer
uint8_t ba111_get_buffer(ba111_handle_t *handle, uint8_t *buf, uint16_t len)
get buffer
ba111 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)
ba111 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]