LibDriver BA111
Loading...
Searching...
No Matches
driver_ba111_register_test.c
Go to the documentation of this file.
1
36
38
39static ba111_handle_t gs_handle;
40
49{
50 uint8_t res;
51 ba111_status_t status;
52 ba111_info_t info;
53
54 /* link interface function */
63
64 /* get ba111 information */
65 res = ba111_info(&info);
66 if (res != 0)
67 {
68 ba111_interface_debug_print("ba111: get info failed.\n");
69
70 return 1;
71 }
72 else
73 {
74 /* print chip information */
75 ba111_interface_debug_print("ba111: chip is %s.\n", info.chip_name);
76 ba111_interface_debug_print("ba111: manufacturer is %s.\n", info.manufacturer_name);
77 ba111_interface_debug_print("ba111: interface is %s.\n", info.interface);
78 ba111_interface_debug_print("ba111: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
79 ba111_interface_debug_print("ba111: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
80 ba111_interface_debug_print("ba111: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
81 ba111_interface_debug_print("ba111: max current is %0.2fmA.\n", info.max_current_ma);
82 ba111_interface_debug_print("ba111: max temperature is %0.1fC.\n", info.temperature_max);
83 ba111_interface_debug_print("ba111: min temperature is %0.1fC.\n", info.temperature_min);
84 }
85
86 /* start register test */
87 ba111_interface_debug_print("ba111: start register test.\n");
88
89 /* ba111 init */
90 res = ba111_init(&gs_handle);
91 if (res != 0)
92 {
93 ba111_interface_debug_print("ba111: init failed.\n");
94
95 return 1;
96 }
97
98 /* ba111_set_ntc_resistance test */
99 ba111_interface_debug_print("ba111: ba111_set_ntc_resistance test.\n");
100
101 /* set ntc resistance */
102 ba111_interface_debug_print("ba111: set ntc resistance 10k.\n");
103
104 /* set ntc resistance */
105 res = ba111_set_ntc_resistance(&gs_handle, 10 * 1000);
106 if (res != 0)
107 {
108 ba111_interface_debug_print("ba111: set ntc resistance failed.\n");
109 (void)ba111_deinit(&gs_handle);
110
111 return 1;
112 }
113 ba111_interface_debug_print("ba111: check ntc resistance %s.\n", res == 0 ? "ok" : "error");
114
115 /* ba111_set_ntc_b test */
116 ba111_interface_debug_print("ba111: ba111_set_ntc_b test.\n");
117
118 /* set ntc b */
119 ba111_interface_debug_print("ba111: set ntc b 3435.\n");
120
121 /* set ntc b */
122 res = ba111_set_ntc_b(&gs_handle, 3435);
123 if (res != 0)
124 {
125 ba111_interface_debug_print("ba111: set ntc b failed.\n");
126 (void)ba111_deinit(&gs_handle);
127
128 return 1;
129 }
130 ba111_interface_debug_print("ba111: check ntc b %s.\n", res == 0 ? "ok" : "error");
131
132#if (BA111_ENABLE_BASELINE_TEST != 0)
133 /* ba111_baseline_calibration test */
134 ba111_interface_debug_print("ba111: ba111_baseline_calibration test.\n");
135
136 /* baseline calibration */
137 ba111_interface_debug_print("ba111: baseline calibration.\n");
138
139 /* baseline calibration */
140 res = ba111_baseline_calibration(&gs_handle);
141 if (res != 0)
142 {
143 ba111_interface_debug_print("ba111: baseline calibration failed.\n");
144 (void)ba111_deinit(&gs_handle);
145
146 return 1;
147 }
148 ba111_interface_debug_print("ba111: check baseline calibration %s.\n", res == 0 ? "ok" : "error");
149#endif
150
151 /* ba111_get_last_status test */
152 ba111_interface_debug_print("ba111: ba111_get_last_status test.\n");
153
154 /* get last status */
155 res = ba111_get_last_status(&gs_handle, &status);
156 if (res != 0)
157 {
158 ba111_interface_debug_print("ba111: get last status failed.\n");
159 (void)ba111_deinit(&gs_handle);
160
161 return 1;
162 }
163 ba111_interface_debug_print("ba111: last status is 0x%02X.\n", (uint8_t)status);
164
165 /* finish register test */
166 ba111_interface_debug_print("ba111: finish register test.\n");
167 (void)ba111_deinit(&gs_handle);
168
169 return 0;
170}
driver ba111 register test header file
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_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
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
uint8_t ba111_register_test(void)
register test
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]