LibDriver BA111
Loading...
Searching...
No Matches
driver_ba111_basic.c
Go to the documentation of this file.
1
36
37#include "driver_ba111_basic.h"
38
39static ba111_handle_t gs_handle;
40
48uint8_t ba111_basic_init(void)
49{
50 uint8_t res;
51
52 /* link interface function */
61
62 /* ba111 init */
63 res = ba111_init(&gs_handle);
64 if (res != 0)
65 {
66 ba111_interface_debug_print("ba111: init failed.\n");
67
68 return 1;
69 }
70
71#if (BA111_BASIC_SEND_CONFIG != 0)
72 /* set default ntc resistance */
74 if (res != 0)
75 {
76 ba111_interface_debug_print("ba111: set ntc resistance failed.\n");
77 (void)ba111_deinit(&gs_handle);
78
79 return 1;
80 }
81
82 /* set default ntc b */
84 if (res != 0)
85 {
86 ba111_interface_debug_print("ba111: set ntc b failed.\n");
87 (void)ba111_deinit(&gs_handle);
88
89 return 1;
90 }
91#endif
92
93 return 0;
94}
95
105uint8_t ba111_basic_read(uint16_t *tds_ppm, float *temperature_deg)
106{
107 uint8_t res;
108 uint16_t tds_raw;
109 uint16_t temperature_raw;
110
111 /* read */
112 res = ba111_read(&gs_handle, &tds_raw, tds_ppm, &temperature_raw, temperature_deg);
113 if (res != 0)
114 {
115 return 1;
116 }
117
118 return 0;
119}
120
129{
130 /* deinit ba111 */
131 if (ba111_deinit(&gs_handle) != 0)
132 {
133 return 1;
134 }
135
136 return 0;
137}
138
147{
148 /* baseline calibration */
149 if (ba111_baseline_calibration(&gs_handle) != 0)
150 {
151 return 1;
152 }
153
154 return 0;
155}
156
166{
167 /* get last status */
168 if (ba111_get_last_status(&gs_handle, status) != 0)
169 {
170 return 1;
171 }
172
173 return 0;
174}
driver ba111 basic header file
struct ba111_handle_s ba111_handle_t
ba111 handle structure definition
uint8_t ba111_init(ba111_handle_t *handle)
initialize the chip
uint8_t ba111_set_ntc_resistance(ba111_handle_t *handle, uint32_t ohm)
set ntc resistance
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
uint8_t ba111_basic_baseline_calibration(void)
basic example baseline calibration
uint8_t ba111_basic_read(uint16_t *tds_ppm, float *temperature_deg)
basic example read
#define BA111_BASIC_DEFAULT_NTC_B
uint8_t ba111_basic_get_last_status(ba111_status_t *status)
basic example get last status
uint8_t ba111_basic_init(void)
basic example init
uint8_t ba111_basic_deinit(void)
basic example deinit
#define BA111_BASIC_DEFAULT_NTC_RESISTANCE
ba111 basic example default definition
uint16_t ba111_interface_uart_read(uint8_t *buf, uint16_t len)
interface uart read
uint8_t ba111_interface_uart_write(uint8_t *buf, uint16_t len)
interface uart write
uint8_t ba111_interface_uart_init(void)
interface uart init
void ba111_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t ba111_interface_uart_deinit(void)
interface uart deinit
uint8_t ba111_interface_uart_flush(void)
interface uart flush
void ba111_interface_debug_print(const char *const fmt,...)
interface print format data