LibDriver BMP384
Loading...
Searching...
No Matches
driver_bmp384_register_test.c
Go to the documentation of this file.
1
36
38#include <stdlib.h>
39
40static bmp384_handle_t gs_handle;
41
52{
53 uint8_t res;
54 uint16_t fifo_watermark_in;
55 uint16_t fifo_watermark_out;
56 uint8_t subsampling_in;
57 uint8_t subsampling_out;
58 uint8_t err;
59 uint8_t status;
60 uint8_t data;
61 uint16_t length;
62 uint32_t sensortime;
63 bmp384_event_t event;
64 bmp384_info_t info;
65 bmp384_interface_t interface_test;
66 bmp384_address_t addr_pin_test;
67 bmp384_bool_t enable;
73 bmp384_mode_t mode;
74 bmp384_oversampling_t oversampling;
75 bmp384_odr_t odr;
77
78 /* link functions */
91
92 /* bmp384 info */
93 res = bmp384_info(&info);
94 if (res != 0)
95 {
96 bmp384_interface_debug_print("bmp384: get info failed.\n");
97
98 return 1;
99 }
100 else
101 {
102 /* print chip information */
103 bmp384_interface_debug_print("bmp384: chip is %s.\n", info.chip_name);
104 bmp384_interface_debug_print("bmp384: manufacturer is %s.\n", info.manufacturer_name);
105 bmp384_interface_debug_print("bmp384: interface is %s.\n", info.interface);
106 bmp384_interface_debug_print("bmp384: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
107 bmp384_interface_debug_print("bmp384: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
108 bmp384_interface_debug_print("bmp384: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
109 bmp384_interface_debug_print("bmp384: max current is %0.2fmA.\n", info.max_current_ma);
110 bmp384_interface_debug_print("bmp384: max temperature is %0.1fC.\n", info.temperature_max);
111 bmp384_interface_debug_print("bmp384: min temperature is %0.1fC.\n", info.temperature_min);
112 }
113
114 /* start register test */
115 bmp384_interface_debug_print("bmp384: start register test.\n");
116
117 /* bmp384_set_interface/bmp384_get_interface test */
118 bmp384_interface_debug_print("bmp384: bmp384_set_interface/bmp384_get_interface test.\n");
119
120 /* set iic */
122 if (res != 0)
123 {
124 bmp384_interface_debug_print("bmp384: set interface failed.\n");
125
126 return 1;
127 }
128 bmp384_interface_debug_print("bmp384: set interface iic.\n");
129 res = bmp384_get_interface(&gs_handle, &interface_test);
130 if (res != 0)
131 {
132 bmp384_interface_debug_print("bmp384: get interface failed.\n");
133
134 return 1;
135 }
136 bmp384_interface_debug_print("bmp384: check interface %s.\n", interface_test==BMP384_INTERFACE_IIC?"ok":"error");
137
138 /* set spi */
140 if (res != 0)
141 {
142 bmp384_interface_debug_print("bmp384: set interface failed.\n");
143
144 return 1;
145 }
146 bmp384_interface_debug_print("bmp384: set interface spi.\n");
147 res = bmp384_get_interface(&gs_handle, &interface_test);
148 if (res != 0)
149 {
150 bmp384_interface_debug_print("bmp384: get interface failed.\n");
151
152 return 1;
153 }
154 bmp384_interface_debug_print("bmp384: check interface %s.\n", interface_test==BMP384_INTERFACE_SPI?"ok":"error");
155
156 /* bmp384_set_addr_pin/bmp384_get_addr_pin test */
157 bmp384_interface_debug_print("bmp384: bmp384_set_addr_pin/bmp384_get_addr_pin test.\n");
158
159 /* set low */
161 if (res != 0)
162 {
163 bmp384_interface_debug_print("bmp384: set addr pin failed.\n");
164
165 return 1;
166 }
167 bmp384_interface_debug_print("bmp384: set addr pin low.\n");
168 res = bmp384_get_addr_pin(&gs_handle, &addr_pin_test);
169 if (res != 0)
170 {
171 bmp384_interface_debug_print("bmp384: get addr pin failed.\n");
172
173 return 1;
174 }
175 bmp384_interface_debug_print("bmp384: check addr pin %s.\n", addr_pin_test==BMP384_ADDRESS_ADO_LOW?"ok":"error");
176
177 /* set high */
179 if (res != 0)
180 {
181 bmp384_interface_debug_print("bmp384: set addr pin failed.\n");
182
183 return 1;
184 }
185 bmp384_interface_debug_print("bmp384: set addr pin high.\n");
186 res = bmp384_get_addr_pin(&gs_handle, &addr_pin_test);
187 if (res != 0)
188 {
189 bmp384_interface_debug_print("bmp384: get addr pin failed.\n");
190
191 return 1;
192 }
193 bmp384_interface_debug_print("bmp384: check addr pin %s.\n", addr_pin_test==BMP384_ADDRESS_ADO_HIGH?"ok":"error");
194
195 /* set interface */
196 res = bmp384_set_interface(&gs_handle, interface);
197 if (res != 0)
198 {
199 bmp384_interface_debug_print("bmp384: set interface failed.\n");
200
201 return 1;
202 }
203
204 /* set addr pin */
205 res = bmp384_set_addr_pin(&gs_handle, addr_pin);
206 if (res != 0)
207 {
208 bmp384_interface_debug_print("bmp384: set addr pin failed.\n");
209
210 return 1;
211 }
212
213 /* bmp384 init */
214 res = bmp384_init(&gs_handle);
215 if (res != 0)
216 {
217 bmp384_interface_debug_print("bmp384: init failed.\n");
218
219 return 1;
220 }
221
222 /* bmp384_set_fifo_watermark/bmp384_get_fifo_watermark test */
223 bmp384_interface_debug_print("bmp384: bmp384_set_fifo_watermark/bmp384_get_fifo_watermark test.\n");
224 fifo_watermark_in = rand()%256 + 256;
225 res = bmp384_set_fifo_watermark(&gs_handle, fifo_watermark_in);
226 if (res != 0)
227 {
228 bmp384_interface_debug_print("bmp384: set fifo watermark failed.\n");
229 (void)bmp384_deinit(&gs_handle);
230
231 return 1;
232 }
233 bmp384_interface_debug_print("bmp384: set fifo watermark %d.\n", fifo_watermark_in);
234 res = bmp384_get_fifo_watermark(&gs_handle, (uint16_t *)&fifo_watermark_out);
235 if (res != 0)
236 {
237 bmp384_interface_debug_print("bmp384: get fifo watermark failed.\n");
238 (void)bmp384_deinit(&gs_handle);
239
240 return 1;
241 }
242 bmp384_interface_debug_print("bmp384: check fifo watermark %s.\n", fifo_watermark_out==fifo_watermark_in?"ok":"error");
243
244 /* bmp384_set_fifo/bmp384_get_fifo test */
245 bmp384_interface_debug_print("bmp384: bmp384_set_fifo/bmp384_get_fifo test.\n");
246
247 /* enable */
248 res = bmp384_set_fifo(&gs_handle, BMP384_BOOL_TRUE);
249 if (res != 0)
250 {
251 bmp384_interface_debug_print("bmp384: set fifo failed.\n");
252 (void)bmp384_deinit(&gs_handle);
253
254 return 1;
255 }
256 bmp384_interface_debug_print("bmp384: set fifo enable.\n");
257 res = bmp384_get_fifo(&gs_handle, (bmp384_bool_t *)&enable);
258 if (res != 0)
259 {
260 bmp384_interface_debug_print("bmp384: get fifo failed.\n");
261 (void)bmp384_deinit(&gs_handle);
262
263 return 1;
264 }
265 bmp384_interface_debug_print("bmp384: check fifo %s.\n", enable==BMP384_BOOL_TRUE?"ok":"error");
266
267 /* disable */
268 res = bmp384_set_fifo(&gs_handle, BMP384_BOOL_FALSE);
269 if (res != 0)
270 {
271 bmp384_interface_debug_print("bmp384: set fifo failed.\n");
272 (void)bmp384_deinit(&gs_handle);
273
274 return 1;
275 }
276 bmp384_interface_debug_print("bmp384: set fifo disable.\n");
277 res = bmp384_get_fifo(&gs_handle, (bmp384_bool_t *)&enable);
278 if (res != 0)
279 {
280 bmp384_interface_debug_print("bmp384: get fifo failed.\n");
281 (void)bmp384_deinit(&gs_handle);
282
283 return 1;
284 }
285 bmp384_interface_debug_print("bmp384: check fifo %s.\n", enable==BMP384_BOOL_FALSE?"ok":"error");
286
287 /* bmp384_set_fifo_stop_on_full/bmp384_get_fifo_stop_on_full test */
288 bmp384_interface_debug_print("bmp384: bmp384_set_fifo_stop_on_full/bmp384_get_fifo_stop_on_full test.\n");
289
290 /* enable */
292 if (res != 0)
293 {
294 bmp384_interface_debug_print("bmp384: set fifo stop on full failed.\n");
295 (void)bmp384_deinit(&gs_handle);
296
297 return 1;
298 }
299 bmp384_interface_debug_print("bmp384: set fifo stop on full enable.\n");
300 res = bmp384_get_fifo_stop_on_full(&gs_handle, (bmp384_bool_t *)&enable);
301 if (res != 0)
302 {
303 bmp384_interface_debug_print("bmp384: get fifo stop on full failed.\n");
304 (void)bmp384_deinit(&gs_handle);
305
306 return 1;
307 }
308 bmp384_interface_debug_print("bmp384: check fifo stop on full %s.\n", enable==BMP384_BOOL_TRUE?"ok":"error");
309
310 /* disable */
312 if (res != 0)
313 {
314 bmp384_interface_debug_print("bmp384: set fifo stop on full failed.\n");
315 (void)bmp384_deinit(&gs_handle);
316
317 return 1;
318 }
319 bmp384_interface_debug_print("bmp384: set fifo stop on full disable.\n");
320 res = bmp384_get_fifo_stop_on_full(&gs_handle, (bmp384_bool_t *)&enable);
321 if (res != 0)
322 {
323 bmp384_interface_debug_print("bmp384: get fifo stop on full failed.\n");
324 (void)bmp384_deinit(&gs_handle);
325
326 return 1;
327 }
328 bmp384_interface_debug_print("bmp384: check fifo stop on full %s.\n", enable==BMP384_BOOL_FALSE?"ok":"error");
329
330 /* bmp384_set_fifo_sensortime_on/bmp384_get_fifo_sensortime_on test */
331 bmp384_interface_debug_print("bmp384: bmp384_set_fifo_sensortime_on/bmp384_get_fifo_sensortime_on test.\n");
332
333 /* enable */
335 if (res != 0)
336 {
337 bmp384_interface_debug_print("bmp384: set fifo sensor time on failed.\n");
338 (void)bmp384_deinit(&gs_handle);
339
340 return 1;
341 }
342 bmp384_interface_debug_print("bmp384: set fifo sensor time on enable.\n");
343 res = bmp384_get_fifo_sensortime_on(&gs_handle, (bmp384_bool_t *)&enable);
344 if (res != 0)
345 {
346 bmp384_interface_debug_print("bmp384: get fifo sensor time on failed.\n");
347 (void)bmp384_deinit(&gs_handle);
348
349 return 1;
350 }
351 bmp384_interface_debug_print("bmp384: check fifo sensor time on %s.\n", enable==BMP384_BOOL_TRUE?"ok":"error");
352
353 /* disable */
355 if (res != 0)
356 {
357 bmp384_interface_debug_print("bmp384: set fifo sensor time on failed.\n");
358 (void)bmp384_deinit(&gs_handle);
359
360 return 1;
361 }
362 bmp384_interface_debug_print("bmp384: set fifo sensor time on disable.\n");
363 res = bmp384_get_fifo_sensortime_on(&gs_handle, (bmp384_bool_t *)&enable);
364 if (res != 0)
365 {
366 bmp384_interface_debug_print("bmp384: get fifo sensor time on failed.\n");
367 (void)bmp384_deinit(&gs_handle);
368
369 return 1;
370 }
371 bmp384_interface_debug_print("bmp384: check fifo sensor time on %s.\n", enable==BMP384_BOOL_FALSE?"ok":"error");
372
373 /* bmp384_set_fifo_pressure_on/bmp384_get_fifo_pressure_on test */
374 bmp384_interface_debug_print("bmp384: bmp384_set_fifo_pressure_on/bmp384_get_fifo_pressure_on test.\n");
375
376 /* enable */
378 if (res != 0)
379 {
380 bmp384_interface_debug_print("bmp384: set fifo pressure on failed.\n");
381 (void)bmp384_deinit(&gs_handle);
382
383 return 1;
384 }
385 bmp384_interface_debug_print("bmp384: set fifo pressure on enable.\n");
386 res = bmp384_get_fifo_pressure_on(&gs_handle, (bmp384_bool_t *)&enable);
387 if (res != 0)
388 {
389 bmp384_interface_debug_print("bmp384: get fifo pressure on failed.\n");
390 (void)bmp384_deinit(&gs_handle);
391
392 return 1;
393 }
394 bmp384_interface_debug_print("bmp384: check fifo pressure on %s.\n", enable==BMP384_BOOL_TRUE?"ok":"error");
395
396 /* disable */
398 if (res != 0)
399 {
400 bmp384_interface_debug_print("bmp384: set fifo pressure on failed.\n");
401 (void)bmp384_deinit(&gs_handle);
402
403 return 1;
404 }
405 bmp384_interface_debug_print("bmp384: set fifo pressure on disable.\n");
406 res = bmp384_get_fifo_pressure_on(&gs_handle, (bmp384_bool_t *)&enable);
407 if (res != 0)
408 {
409 bmp384_interface_debug_print("bmp384: get fifo pressure on failed.\n");
410 (void)bmp384_deinit(&gs_handle);
411
412 return 1;
413 }
414 bmp384_interface_debug_print("bmp384: check fifo pressure on %s.\n", enable==BMP384_BOOL_FALSE?"ok":"error");
415
416 /* bmp384_set_fifo_temperature_on/bmp384_get_fifo_temperature_on test */
417 bmp384_interface_debug_print("bmp384: bmp384_set_fifo_temperature_on/bmp384_get_fifo_temperature_on test.\n");
418
419 /* enable */
421 if (res != 0)
422 {
423 bmp384_interface_debug_print("bmp384: set fifo temperature on failed.\n");
424 (void)bmp384_deinit(&gs_handle);
425
426 return 1;
427 }
428 bmp384_interface_debug_print("bmp384: set fifo temperature on enable.\n");
429 res = bmp384_get_fifo_temperature_on(&gs_handle, (bmp384_bool_t *)&enable);
430 if (res != 0)
431 {
432 bmp384_interface_debug_print("bmp384: get fifo temperature on failed.\n");
433 (void)bmp384_deinit(&gs_handle);
434
435 return 1;
436 }
437 bmp384_interface_debug_print("bmp384: check fifo temperature on %s.\n", enable==BMP384_BOOL_TRUE?"ok":"error");
438
439 /* disable */
441 if (res != 0)
442 {
443 bmp384_interface_debug_print("bmp384: set fifo temperature on failed.\n");
444 (void)bmp384_deinit(&gs_handle);
445
446 return 1;
447 }
448 bmp384_interface_debug_print("bmp384: set fifo temperature on disable.\n");
449 res = bmp384_get_fifo_temperature_on(&gs_handle, (bmp384_bool_t *)&enable);
450 if (res != 0)
451 {
452 bmp384_interface_debug_print("bmp384: get fifo temperature on failed.\n");
453 (void)bmp384_deinit(&gs_handle);
454
455 return 1;
456 }
457 bmp384_interface_debug_print("bmp384: check fifo temperature on %s.\n", enable==BMP384_BOOL_FALSE?"ok":"error");
458
459 /* bmp384_set_fifo_subsampling/bmp384_get_fifo_subsampling test */
460 bmp384_interface_debug_print("bmp384: bmp384_set_fifo_subsampling/bmp384_get_fifo_subsampling test.\n");
461 subsampling_in = rand()%7;
462 res = bmp384_set_fifo_subsampling(&gs_handle, subsampling_in);
463 if (res != 0)
464 {
465 bmp384_interface_debug_print("bmp384: set fifo subsampling failed.\n");
466 (void)bmp384_deinit(&gs_handle);
467
468 return 1;
469 }
470 bmp384_interface_debug_print("bmp384: set fifo subsampling %d.\n", subsampling_in);
471 res = bmp384_get_fifo_subsampling(&gs_handle, (uint8_t *)&subsampling_out);
472 if (res != 0)
473 {
474 bmp384_interface_debug_print("bmp384: get fifo subsampling failed.\n");
475 (void)bmp384_deinit(&gs_handle);
476
477 return 1;
478 }
479 bmp384_interface_debug_print("bmp384: check fifo subsampling on %s.\n", subsampling_in==subsampling_out?"ok":"error");
480
481 /* bmp384_set_fifo_data_source/bmp384_get_fifo_data_source test */
482 bmp384_interface_debug_print("bmp384: bmp384_set_fifo_data_source/bmp384_get_fifo_data_source test.\n");
483
484 /* set unfiltered */
486 if (res != 0)
487 {
488 bmp384_interface_debug_print("bmp384: set fifo data source failed.\n");
489 (void)bmp384_deinit(&gs_handle);
490
491 return 1;
492 }
493 bmp384_interface_debug_print("bmp384: set fifo data source unfiltered.\n");
494 res = bmp384_get_fifo_data_source(&gs_handle, (bmp384_fifo_data_source_t *)&source);
495 if (res != 0)
496 {
497 bmp384_interface_debug_print("bmp384: get fifo data source failed.\n");
498 (void)bmp384_deinit(&gs_handle);
499
500 return 1;
501 }
502 bmp384_interface_debug_print("bmp384: check fifo data source %s.\n", source==BMP384_FIFO_DATA_SOURCE_UNFILTERED?"ok":"error");
503
504 /* set filtered */
506 if (res != 0)
507 {
508 bmp384_interface_debug_print("bmp384: set fifo data source failed.\n");
509 (void)bmp384_deinit(&gs_handle);
510
511 return 1;
512 }
513 bmp384_interface_debug_print("bmp384: set fifo data source filtered.\n");
514 res = bmp384_get_fifo_data_source(&gs_handle, (bmp384_fifo_data_source_t *)&source);
515 if (res != 0)
516 {
517 bmp384_interface_debug_print("bmp384: get fifo data source failed.\n");
518 (void)bmp384_deinit(&gs_handle);
519
520 return 1;
521 }
522 bmp384_interface_debug_print("bmp384: check fifo data source %s.\n", source==BMP384_FIFO_DATA_SOURCE_FILTERED?"ok":"error");
523
524 /* bmp384_set_interrupt_pin_type/bmp384_get_interrupt_pin_type test */
525 bmp384_interface_debug_print("bmp384: bmp384_set_interrupt_pin_type/bmp384_get_interrupt_pin_type test.\n");
526
527 /* set push-pull */
529 if (res != 0)
530 {
531 bmp384_interface_debug_print("bmp384: set interrupt pin type failed.\n");
532 (void)bmp384_deinit(&gs_handle);
533
534 return 1;
535 }
536 bmp384_interface_debug_print("bmp384: set interrupt pin type push pull.\n");
537 res = bmp384_get_interrupt_pin_type(&gs_handle, (bmp384_interrupt_pin_type_t *)&pin_type);
538 if (res != 0)
539 {
540 bmp384_interface_debug_print("bmp384: get interrupt pin type failed.\n");
541 (void)bmp384_deinit(&gs_handle);
542
543 return 1;
544 }
545 bmp384_interface_debug_print("bmp384: check interrupt pin type %s.\n", pin_type==BMP384_INTERRUPT_PIN_TYPE_PUSH_PULL?"ok":"error");
546
547 /* set open drain */
549 if (res != 0)
550 {
551 bmp384_interface_debug_print("bmp384: set interrupt pin type failed.\n");
552 (void)bmp384_deinit(&gs_handle);
553
554 return 1;
555 }
556 bmp384_interface_debug_print("bmp384: set interrupt pin type open drain.\n");
557 res = bmp384_get_interrupt_pin_type(&gs_handle, (bmp384_interrupt_pin_type_t *)&pin_type);
558 if (res != 0)
559 {
560 bmp384_interface_debug_print("bmp384: get interrupt pin type failed.\n");
561 (void)bmp384_deinit(&gs_handle);
562
563 return 1;
564 }
565 bmp384_interface_debug_print("bmp384: check interrupt pin type %s.\n", pin_type==BMP384_INTERRUPT_PIN_TYPE_OPEN_DRAIN?"ok":"error");
566
567 /* bmp384_set_interrupt_active_level/bmp384_get_interrupt_active_level test */
568 bmp384_interface_debug_print("bmp384: bmp384_set_interrupt_active_level/bmp384_get_interrupt_active_level test.\n");
569
570 /* set lower */
572 if (res != 0)
573 {
574 bmp384_interface_debug_print("bmp384: set interrupt active level failed.\n");
575 (void)bmp384_deinit(&gs_handle);
576
577 return 1;
578 }
579 bmp384_interface_debug_print("bmp384: set interrupt active level lower.\n");
581 if (res != 0)
582 {
583 bmp384_interface_debug_print("bmp384: get interrupt active level failed.\n");
584 (void)bmp384_deinit(&gs_handle);
585
586 return 1;
587 }
588 bmp384_interface_debug_print("bmp384: check interrupt active level %s.\n", level==BMP384_INTERRUPT_ACTIVE_LEVEL_LOWER?"ok":"error");
589
590 /* set higher */
592 if (res != 0)
593 {
594 bmp384_interface_debug_print("bmp384: set interrupt active level failed.\n");
595 (void)bmp384_deinit(&gs_handle);
596
597 return 1;
598 }
599 bmp384_interface_debug_print("bmp384: set interrupt active level higher.\n");
601 if (res != 0)
602 {
603 bmp384_interface_debug_print("bmp384: get interrupt active level failed.\n");
604 (void)bmp384_deinit(&gs_handle);
605
606 return 1;
607 }
608 bmp384_interface_debug_print("bmp384: check interrupt active level %s.\n", level==BMP384_INTERRUPT_ACTIVE_LEVEL_HIGHER?"ok":"error");
609
610 /* bmp384_set_latch_interrupt_pin_and_interrupt_status/bmp384_get_latch_interrupt_pin_and_interrupt_status test */
611 bmp384_interface_debug_print("bmp384: bmp384_set_latch_interrupt_pin_and_interrupt_status/bmp384_get_latch_interrupt_pin_and_interrupt_status test.\n");
612
613 /* enable */
615 if (res != 0)
616 {
617 bmp384_interface_debug_print("bmp384: set latch interrupt pin and interrupt status failed.\n");
618 (void)bmp384_deinit(&gs_handle);
619
620 return 1;
621 }
622 bmp384_interface_debug_print("bmp384: set latch interrupt pin and interrupt status enable.\n");
624 if (res != 0)
625 {
626 bmp384_interface_debug_print("bmp384: get latch interrupt pin and interrupt status failed.\n");
627 (void)bmp384_deinit(&gs_handle);
628
629 return 1;
630 }
631 bmp384_interface_debug_print("bmp384: check latch interrupt pin and interrupt status %s.\n", enable==BMP384_BOOL_TRUE?"ok":"error");
632
633 /* disable */
635 if (res != 0)
636 {
637 bmp384_interface_debug_print("bmp384: set latch interrupt pin and interrupt status failed.\n");
638 (void)bmp384_deinit(&gs_handle);
639
640 return 1;
641 }
642 bmp384_interface_debug_print("bmp384: set latch interrupt pin and interrupt status disable.\n");
644 if (res != 0)
645 {
646 bmp384_interface_debug_print("bmp384: get latch interrupt pin and interrupt status failed.\n");
647 (void)bmp384_deinit(&gs_handle);
648
649 return 1;
650 }
651 bmp384_interface_debug_print("bmp384: check latch interrupt pin and interrupt status %s.\n", enable==BMP384_BOOL_FALSE?"ok":"error");
652
653 /* bmp384_set_interrupt_fifo_watermark/bmp384_get_interrupt_fifo_watermark test */
654 bmp384_interface_debug_print("bmp384: bmp384_set_interrupt_fifo_watermark/bmp384_get_interrupt_fifo_watermark test.\n");
655
656 /* enable */
658 if (res != 0)
659 {
660 bmp384_interface_debug_print("bmp384: set interrupt fifo watermark failed.\n");
661 (void)bmp384_deinit(&gs_handle);
662
663 return 1;
664 }
665 bmp384_interface_debug_print("bmp384: set interrupt fifo watermark enable.\n");
666 res = bmp384_get_interrupt_fifo_watermark(&gs_handle, (bmp384_bool_t *)&enable);
667 if (res != 0)
668 {
669 bmp384_interface_debug_print("bmp384: get interrupt fifo watermark failed.\n");
670 (void)bmp384_deinit(&gs_handle);
671
672 return 1;
673 }
674 bmp384_interface_debug_print("bmp384: check interrupt fifo watermark %s.\n", enable==BMP384_BOOL_TRUE?"ok":"error");
675
676 /* disable */
678 if (res != 0)
679 {
680 bmp384_interface_debug_print("bmp384: set interrupt fifo watermark failed.\n");
681 (void)bmp384_deinit(&gs_handle);
682
683 return 1;
684 }
685 bmp384_interface_debug_print("bmp384: set interrupt fifo watermark disable.\n");
686 res = bmp384_get_interrupt_fifo_watermark(&gs_handle, (bmp384_bool_t *)&enable);
687 if (res != 0)
688 {
689 bmp384_interface_debug_print("bmp384: get interrupt fifo watermark failed.\n");
690 (void)bmp384_deinit(&gs_handle);
691
692 return 1;
693 }
694 bmp384_interface_debug_print("bmp384: check interrupt fifo watermark %s.\n", enable==BMP384_BOOL_FALSE?"ok":"error");
695
696 /* bmp384_set_interrupt_fifo_full/bmp384_get_interrupt_fifo_full test */
697 bmp384_interface_debug_print("bmp384: bmp384_set_interrupt_fifo_full/bmp384_get_interrupt_fifo_full test.\n");
698
699 /* enable */
701 if (res != 0)
702 {
703 bmp384_interface_debug_print("bmp384: set interrupt fifo full failed.\n");
704 (void)bmp384_deinit(&gs_handle);
705
706 return 1;
707 }
708 bmp384_interface_debug_print("bmp384: set interrupt fifo full enable.\n");
709 res = bmp384_get_interrupt_fifo_full(&gs_handle, (bmp384_bool_t *)&enable);
710 if (res != 0)
711 {
712 bmp384_interface_debug_print("bmp384: get interrupt fifo full failed.\n");
713 (void)bmp384_deinit(&gs_handle);
714
715 return 1;
716 }
717 bmp384_interface_debug_print("bmp384: check interrupt fifo full %s.\n", enable==BMP384_BOOL_TRUE?"ok":"error");
718
719 /* disable */
721 if (res != 0)
722 {
723 bmp384_interface_debug_print("bmp384: set interrupt fifo full failed.\n");
724 (void)bmp384_deinit(&gs_handle);
725
726 return 1;
727 }
728 bmp384_interface_debug_print("bmp384: set interrupt fifo full disable.\n");
729 res = bmp384_get_interrupt_fifo_full(&gs_handle, (bmp384_bool_t *)&enable);
730 if (res != 0)
731 {
732 bmp384_interface_debug_print("bmp384: get interrupt fifo full failed.\n");
733 (void)bmp384_deinit(&gs_handle);
734
735 return 1;
736 }
737 bmp384_interface_debug_print("bmp384: check interrupt fifo full %s.\n", enable==BMP384_BOOL_FALSE?"ok":"error");
738
739 /* bmp384_set_interrupt_data_ready/bmp384_get_interrupt_fifo_data_ready test */
740 bmp384_interface_debug_print("bmp384: bmp384_set_interrupt_data_ready/bmp384_get_interrupt_fifo_data_ready test.\n");
741
742 /* enable */
744 if (res != 0)
745 {
746 bmp384_interface_debug_print("bmp384: set interrupt data ready failed.\n");
747 (void)bmp384_deinit(&gs_handle);
748
749 return 1;
750 }
751 bmp384_interface_debug_print("bmp384: set interrupt data ready enable.\n");
752 res = bmp384_get_interrupt_data_ready(&gs_handle, (bmp384_bool_t *)&enable);
753 if (res != 0)
754 {
755 bmp384_interface_debug_print("bmp384: get interrupt data ready failed.\n");
756 (void)bmp384_deinit(&gs_handle);
757
758 return 1;
759 }
760 bmp384_interface_debug_print("bmp384: check interrupt data ready %s.\n", enable==BMP384_BOOL_TRUE?"ok":"error");
761
762 /* disable */
764 if (res != 0)
765 {
766 bmp384_interface_debug_print("bmp384: set interrupt data ready failed.\n");
767 (void)bmp384_deinit(&gs_handle);
768
769 return 1;
770 }
771 bmp384_interface_debug_print("bmp384: set interrupt data ready disable.\n");
772 res = bmp384_get_interrupt_data_ready(&gs_handle, (bmp384_bool_t *)&enable);
773 if (res != 0)
774 {
775 bmp384_interface_debug_print("bmp384: get interrupt data ready failed.\n");
776 (void)bmp384_deinit(&gs_handle);
777
778 return 1;
779 }
780 bmp384_interface_debug_print("bmp384: check interrupt data ready %s.\n", enable==BMP384_BOOL_FALSE?"ok":"error");
781
782 /* bmp384_set_spi_wire/bmp384_get_spi_wire test */
783 bmp384_interface_debug_print("bmp384: bmp384_set_spi_wire/bmp384_get_spi_wire test.\n");
784
785 /* set 4 wire */
786 res = bmp384_set_spi_wire(&gs_handle, BMP384_SPI_WIRE_4);
787 if (res != 0)
788 {
789 bmp384_interface_debug_print("bmp384: set spi wire failed.\n");
790 (void)bmp384_deinit(&gs_handle);
791
792 return 1;
793 }
794 bmp384_interface_debug_print("bmp384: set spi 4 wire.\n");
795 res = bmp384_get_spi_wire(&gs_handle, (bmp384_spi_wire_t *)&wire);
796 if (res != 0)
797 {
798 bmp384_interface_debug_print("bmp384: get spi wire failed.\n");
799 (void)bmp384_deinit(&gs_handle);
800
801 return 1;
802 }
803 bmp384_interface_debug_print("bmp384: check spi wire %s.\n", wire==BMP384_SPI_WIRE_4?"ok":"error");
804 if (interface == BMP384_INTERFACE_IIC)
805 {
806 /* set 3 wire */
807 res = bmp384_set_spi_wire(&gs_handle, BMP384_SPI_WIRE_3);
808 if (res != 0)
809 {
810 bmp384_interface_debug_print("bmp384: set spi wire failed.\n");
811 (void)bmp384_deinit(&gs_handle);
812
813 return 1;
814 }
815 bmp384_interface_debug_print("bmp384: set spi 3 wire.\n");
816 res = bmp384_get_spi_wire(&gs_handle, (bmp384_spi_wire_t *)&wire);
817 if (res != 0)
818 {
819 bmp384_interface_debug_print("bmp384: get spi wire failed.\n");
820 (void)bmp384_deinit(&gs_handle);
821
822 return 1;
823 }
824 bmp384_interface_debug_print("bmp384: check spi wire %s.\n", wire==BMP384_SPI_WIRE_3?"ok":"error");
825 }
826
827 /* bmp384_set_iic_watchdog_timer/bmp384_get_iic_watchdog_timer test */
828 bmp384_interface_debug_print("bmp384: bmp384_set_iic_watchdog_timer/bmp384_get_iic_watchdog_timer test.\n");
829
830 /* enable */
832 if (res != 0)
833 {
834 bmp384_interface_debug_print("bmp384: set iic watchdog timer failed.\n");
835 (void)bmp384_deinit(&gs_handle);
836
837 return 1;
838 }
839 bmp384_interface_debug_print("bmp384: set iic watchdog timer enable.\n");
840 res = bmp384_get_iic_watchdog_timer(&gs_handle, (bmp384_bool_t *)&enable);
841 if (res != 0)
842 {
843 bmp384_interface_debug_print("bmp384: get iic watchdog timer failed.\n");
844 (void)bmp384_deinit(&gs_handle);
845
846 return 1;
847 }
848 bmp384_interface_debug_print("bmp384: check iic watchdog timer %s.\n", enable==BMP384_BOOL_TRUE?"ok":"error");
849
850 /* disable */
852 if (res != 0)
853 {
854 bmp384_interface_debug_print("bmp384: set iic watchdog timer failed.\n");
855 (void)bmp384_deinit(&gs_handle);
856
857 return 1;
858 }
859 bmp384_interface_debug_print("bmp384: set iic watchdog timer disable.\n");
860 res = bmp384_get_iic_watchdog_timer(&gs_handle, (bmp384_bool_t *)&enable);
861 if (res != 0)
862 {
863 bmp384_interface_debug_print("bmp384: get iic watchdog timer failed.\n");
864 (void)bmp384_deinit(&gs_handle);
865
866 return 1;
867 }
868 bmp384_interface_debug_print("bmp384: check iic watchdog timer %s.\n", enable==BMP384_BOOL_FALSE?"ok":"error");
869
870 /* bmp384_set_iic_watchdog_period/bmp384_get_iic_watchdog_period test */
871 bmp384_interface_debug_print("bmp384: bmp384_set_iic_watchdog_period/bmp384_get_iic_watchdog_period test.\n");
872
873 /* set 1.25ms period */
875 if (res != 0)
876 {
877 bmp384_interface_debug_print("bmp384: set iic watchdog period failed.\n");
878 (void)bmp384_deinit(&gs_handle);
879
880 return 1;
881 }
882 bmp384_interface_debug_print("bmp384: set iic watchdog period 1.25ms.\n");
884 if (res != 0)
885 {
886 bmp384_interface_debug_print("bmp384: get iic watchdog period failed.\n");
887 (void)bmp384_deinit(&gs_handle);
888
889 return 1;
890 }
891 bmp384_interface_debug_print("bmp384: check iic watchdog period %s.\n", period==BMP384_IIC_WATCHDOG_PERIOD_1P25_MS?"ok":"error");
892
893 /* set 40ms period */
895 if (res != 0)
896 {
897 bmp384_interface_debug_print("bmp384: set iic watchdog period failed.\n");
898 (void)bmp384_deinit(&gs_handle);
899
900 return 1;
901 }
902 bmp384_interface_debug_print("bmp384: set iic watchdog period 40ms.\n");
904 if (res != 0)
905 {
906 bmp384_interface_debug_print("bmp384: get iic watchdog period failed.\n");
907 (void)bmp384_deinit(&gs_handle);
908
909 return 1;
910 }
911 bmp384_interface_debug_print("bmp384: check iic watchdog period %s.\n", period==BMP384_IIC_WATCHDOG_PERIOD_40_MS?"ok":"error");
912
913 /* bmp384_set_pressure/bmp384_get_pressure test */
914 bmp384_interface_debug_print("bmp384: bmp384_set_pressure/bmp384_get_pressure test.\n");
915
916 /* disable */
917 res = bmp384_set_pressure(&gs_handle, BMP384_BOOL_FALSE);
918 if (res != 0)
919 {
920 bmp384_interface_debug_print("bmp384: set pressure failed.\n");
921 (void)bmp384_deinit(&gs_handle);
922
923 return 1;
924 }
925 bmp384_interface_debug_print("bmp384: set pressure disable.\n");
926 res = bmp384_get_pressure(&gs_handle, (bmp384_bool_t *)&enable);
927 if (res != 0)
928 {
929 bmp384_interface_debug_print("bmp384: get pressure failed.\n");
930 (void)bmp384_deinit(&gs_handle);
931
932 return 1;
933 }
934 bmp384_interface_debug_print("bmp384: check pressure %s.\n", enable==BMP384_BOOL_FALSE?"ok":"error");
935
936 /* enable */
937 res = bmp384_set_pressure(&gs_handle, BMP384_BOOL_TRUE);
938 if (res != 0)
939 {
940 bmp384_interface_debug_print("bmp384: set pressure failed.\n");
941 (void)bmp384_deinit(&gs_handle);
942
943 return 1;
944 }
945 bmp384_interface_debug_print("bmp384: set pressure enable.\n");
946 res = bmp384_get_pressure(&gs_handle, (bmp384_bool_t *)&enable);
947 if (res != 0)
948 {
949 bmp384_interface_debug_print("bmp384: get pressure failed.\n");
950 (void)bmp384_deinit(&gs_handle);
951
952 return 1;
953 }
954 bmp384_interface_debug_print("bmp384: check pressure %s.\n", enable==BMP384_BOOL_TRUE?"ok":"error");
955
956 /* bmp384_set_temperature/bmp384_get_temperature test */
957 bmp384_interface_debug_print("bmp384: bmp384_set_temperature/bmp384_get_temperature test.\n");
958
959 /* disable */
960 res = bmp384_set_temperature(&gs_handle, BMP384_BOOL_FALSE);
961 if (res != 0)
962 {
963 bmp384_interface_debug_print("bmp384: set temperature failed.\n");
964 (void)bmp384_deinit(&gs_handle);
965
966 return 1;
967 }
968 bmp384_interface_debug_print("bmp384: set temperature disable.\n");
969 res = bmp384_get_temperature(&gs_handle, (bmp384_bool_t *)&enable);
970 if (res != 0)
971 {
972 bmp384_interface_debug_print("bmp384: get temperature failed.\n");
973 (void)bmp384_deinit(&gs_handle);
974
975 return 1;
976 }
977 bmp384_interface_debug_print("bmp384: check temperature %s.\n", enable==BMP384_BOOL_FALSE?"ok":"error");
978
979 /* enable */
980 res = bmp384_set_temperature(&gs_handle, BMP384_BOOL_TRUE);
981 if (res != 0)
982 {
983 bmp384_interface_debug_print("bmp384: set temperature failed.\n");
984 (void)bmp384_deinit(&gs_handle);
985
986 return 1;
987 }
988 bmp384_interface_debug_print("bmp384: set temperature enable.\n");
989 res = bmp384_get_temperature(&gs_handle, (bmp384_bool_t *)&enable);
990 if (res != 0)
991 {
992 bmp384_interface_debug_print("bmp384: get temperature failed.\n");
993 (void)bmp384_deinit(&gs_handle);
994
995 return 1;
996 }
997 bmp384_interface_debug_print("bmp384: check temperature %s.\n", enable==BMP384_BOOL_TRUE?"ok":"error");
998
999 /* bmp384_set_mode/bmp384_get_mode test */
1000 bmp384_interface_debug_print("bmp384: bmp384_set_mode/bmp384_get_mode test.\n");
1001
1002 /* sleep */
1003 res = bmp384_set_mode(&gs_handle, BMP384_MODE_SLEEP_MODE);
1004 if (res != 0)
1005 {
1006 bmp384_interface_debug_print("bmp384: set mode failed.\n");
1007 (void)bmp384_deinit(&gs_handle);
1008
1009 return 1;
1010 }
1011 bmp384_interface_debug_print("bmp384: set mode sleep.\n");
1012 res = bmp384_get_mode(&gs_handle, (bmp384_mode_t *)&mode);
1013 if (res != 0)
1014 {
1015 bmp384_interface_debug_print("bmp384: get mode failed.\n");
1016 (void)bmp384_deinit(&gs_handle);
1017
1018 return 1;
1019 }
1020 bmp384_interface_debug_print("bmp384: check mode %s.\n", mode==BMP384_MODE_SLEEP_MODE?"ok":"error");
1021
1022 /* normal mode */
1023 res = bmp384_set_mode(&gs_handle, BMP384_MODE_NORMAL_MODE);
1024 if (res != 0)
1025 {
1026 bmp384_interface_debug_print("bmp384: set mode failed.\n");
1027 (void)bmp384_deinit(&gs_handle);
1028
1029 return 1;
1030 }
1031 bmp384_interface_debug_print("bmp384: set mode normal mode.\n");
1032 res = bmp384_get_mode(&gs_handle, (bmp384_mode_t *)&mode);
1033 if (res != 0)
1034 {
1035 bmp384_interface_debug_print("bmp384: get mode failed.\n");
1036 (void)bmp384_deinit(&gs_handle);
1037
1038 return 1;
1039 }
1040 bmp384_interface_debug_print("bmp384: check mode %s.\n", mode==BMP384_MODE_NORMAL_MODE?"ok":"error");
1041
1042 /* set forced mode */
1043 res = bmp384_set_mode(&gs_handle, BMP384_MODE_SLEEP_MODE);
1044 if (res != 0)
1045 {
1046 bmp384_interface_debug_print("bmp384: set mode failed.\n");
1047 (void)bmp384_deinit(&gs_handle);
1048
1049 return 1;
1050 }
1052 res = bmp384_set_mode(&gs_handle, BMP384_MODE_FORCED_MODE);
1053 if (res != 0)
1054 {
1055 bmp384_interface_debug_print("bmp384: set mode failed.\n");
1056 (void)bmp384_deinit(&gs_handle);
1057
1058 return 1;
1059 }
1060 bmp384_interface_debug_print("bmp384: set mode forced mode.\n");
1061 res = bmp384_get_mode(&gs_handle, (bmp384_mode_t *)&mode);
1062 if (res != 0)
1063 {
1064 bmp384_interface_debug_print("bmp384: get mode failed.\n");
1065 (void)bmp384_deinit(&gs_handle);
1066
1067 return 1;
1068 }
1069 bmp384_interface_debug_print("bmp384: check mode %s.\n", mode==BMP384_MODE_FORCED_MODE?"ok":"error");
1070
1071 /* bmp384_set_pressure_oversampling/bmp384_get_pressure_oversampling test */
1072 bmp384_interface_debug_print("bmp384: bmp384_set_pressure_oversampling/bmp384_get_pressure_oversampling test.\n");
1073
1074 /* set oversampling x1 */
1076 if (res != 0)
1077 {
1078 bmp384_interface_debug_print("bmp384: set pressure oversampling failed.\n");
1079 (void)bmp384_deinit(&gs_handle);
1080
1081 return 1;
1082 }
1083 bmp384_interface_debug_print("bmp384: set pressure oversampling x1.\n");
1084 res = bmp384_get_pressure_oversampling(&gs_handle, (bmp384_oversampling_t *)&oversampling);
1085 if (res != 0)
1086 {
1087 bmp384_interface_debug_print("bmp384: get pressure oversampling failed.\n");
1088 (void)bmp384_deinit(&gs_handle);
1089
1090 return 1;
1091 }
1092 bmp384_interface_debug_print("bmp384: check pressure oversampling %s.\n", oversampling==BMP384_OVERSAMPLING_x1?"ok":"error");
1093
1094 /* set oversampling x2 */
1096 if (res != 0)
1097 {
1098 bmp384_interface_debug_print("bmp384: set pressure oversampling failed.\n");
1099 (void)bmp384_deinit(&gs_handle);
1100
1101 return 1;
1102 }
1103 bmp384_interface_debug_print("bmp384: set pressure oversampling x2.\n");
1104 res = bmp384_get_pressure_oversampling(&gs_handle, (bmp384_oversampling_t *)&oversampling);
1105 if (res != 0)
1106 {
1107 bmp384_interface_debug_print("bmp384: get pressure oversampling failed.\n");
1108 (void)bmp384_deinit(&gs_handle);
1109
1110 return 1;
1111 }
1112 bmp384_interface_debug_print("bmp384: check pressure oversampling %s.\n", oversampling==BMP384_OVERSAMPLING_x2?"ok":"error");
1113
1114 /* set oversampling x4 */
1116 if (res != 0)
1117 {
1118 bmp384_interface_debug_print("bmp384: set pressure oversampling failed.\n");
1119 (void)bmp384_deinit(&gs_handle);
1120
1121 return 1;
1122 }
1123 bmp384_interface_debug_print("bmp384: set pressure oversampling x4.\n");
1124 res = bmp384_get_pressure_oversampling(&gs_handle, (bmp384_oversampling_t *)&oversampling);
1125 if (res != 0)
1126 {
1127 bmp384_interface_debug_print("bmp384: get pressure oversampling failed.\n");
1128 (void)bmp384_deinit(&gs_handle);
1129
1130 return 1;
1131 }
1132 bmp384_interface_debug_print("bmp384: check pressure oversampling %s.\n", oversampling==BMP384_OVERSAMPLING_x4?"ok":"error");
1133
1134 /* set oversampling x8 */
1136 if (res != 0)
1137 {
1138 bmp384_interface_debug_print("bmp384: set pressure oversampling failed.\n");
1139 (void)bmp384_deinit(&gs_handle);
1140
1141 return 1;
1142 }
1143 bmp384_interface_debug_print("bmp384: set pressure oversampling x8.\n");
1144 res = bmp384_get_pressure_oversampling(&gs_handle, (bmp384_oversampling_t *)&oversampling);
1145 if (res != 0)
1146 {
1147 bmp384_interface_debug_print("bmp384: get pressure oversampling failed.\n");
1148 (void)bmp384_deinit(&gs_handle);
1149
1150 return 1;
1151 }
1152 bmp384_interface_debug_print("bmp384: check pressure oversampling %s.\n", oversampling==BMP384_OVERSAMPLING_x8?"ok":"error");
1153
1154 /* set oversampling x16 */
1156 if (res != 0)
1157 {
1158 bmp384_interface_debug_print("bmp384: set pressure oversampling failed.\n");
1159 (void)bmp384_deinit(&gs_handle);
1160
1161 return 1;
1162 }
1163 bmp384_interface_debug_print("bmp384: set pressure oversampling x16.\n");
1164 res = bmp384_get_pressure_oversampling(&gs_handle, (bmp384_oversampling_t *)&oversampling);
1165 if (res != 0)
1166 {
1167 bmp384_interface_debug_print("bmp384: get pressure oversampling failed.\n");
1168 (void)bmp384_deinit(&gs_handle);
1169
1170 return 1;
1171 }
1172 bmp384_interface_debug_print("bmp384: check pressure oversampling %s.\n", oversampling==BMP384_OVERSAMPLING_x16?"ok":"error");
1173
1174 /* set oversampling x32 */
1176 if (res != 0)
1177 {
1178 bmp384_interface_debug_print("bmp384: set pressure oversampling failed.\n");
1179 (void)bmp384_deinit(&gs_handle);
1180
1181 return 1;
1182 }
1183 bmp384_interface_debug_print("bmp384: set pressure oversampling x32.\n");
1184 res = bmp384_get_pressure_oversampling(&gs_handle, (bmp384_oversampling_t *)&oversampling);
1185 if (res != 0)
1186 {
1187 bmp384_interface_debug_print("bmp384: get pressure oversampling failed.\n");
1188 (void)bmp384_deinit(&gs_handle);
1189
1190 return 1;
1191 }
1192 bmp384_interface_debug_print("bmp384: check pressure oversampling %s.\n", oversampling==BMP384_OVERSAMPLING_x32?"ok":"error");
1193
1194 /* bmp384_set_temperature_oversampling/bmp384_get_temperature_oversampling test */
1195 bmp384_interface_debug_print("bmp384: bmp384_set_temperature_oversampling/bmp384_get_temperature_oversampling test.\n");
1196
1197 /* oversampling x1 */
1199 if (res != 0)
1200 {
1201 bmp384_interface_debug_print("bmp384: set temperature oversampling failed.\n");
1202 (void)bmp384_deinit(&gs_handle);
1203
1204 return 1;
1205 }
1206 bmp384_interface_debug_print("bmp384: set temperature oversampling x1.\n");
1207 res = bmp384_get_temperature_oversampling(&gs_handle, (bmp384_oversampling_t *)&oversampling);
1208 if (res != 0)
1209 {
1210 bmp384_interface_debug_print("bmp384: get temperature oversampling failed.\n");
1211 (void)bmp384_deinit(&gs_handle);
1212
1213 return 1;
1214 }
1215 bmp384_interface_debug_print("bmp384: check temperature oversampling %s.\n", oversampling==BMP384_OVERSAMPLING_x1?"ok":"error");
1216
1217 /* set oversampling x2 */
1219 if (res != 0)
1220 {
1221 bmp384_interface_debug_print("bmp384: set temperature oversampling failed.\n");
1222 (void)bmp384_deinit(&gs_handle);
1223
1224 return 1;
1225 }
1226 bmp384_interface_debug_print("bmp384: set temperature oversampling x2.\n");
1227 res = bmp384_get_temperature_oversampling(&gs_handle, (bmp384_oversampling_t *)&oversampling);
1228 if (res != 0)
1229 {
1230 bmp384_interface_debug_print("bmp384: get temperature oversampling failed.\n");
1231 (void)bmp384_deinit(&gs_handle);
1232
1233 return 1;
1234 }
1235 bmp384_interface_debug_print("bmp384: check temperature oversampling %s.\n", oversampling==BMP384_OVERSAMPLING_x2?"ok":"error");
1236
1237 /* set oversampling x4 */
1239 if (res != 0)
1240 {
1241 bmp384_interface_debug_print("bmp384: set temperature oversampling failed.\n");
1242 (void)bmp384_deinit(&gs_handle);
1243
1244 return 1;
1245 }
1246 bmp384_interface_debug_print("bmp384: set temperature oversampling x4.\n");
1247 res = bmp384_get_temperature_oversampling(&gs_handle, (bmp384_oversampling_t *)&oversampling);
1248 if (res != 0)
1249 {
1250 bmp384_interface_debug_print("bmp384: get temperature oversampling failed.\n");
1251 (void)bmp384_deinit(&gs_handle);
1252
1253 return 1;
1254 }
1255 bmp384_interface_debug_print("bmp384: check temperature oversampling %s.\n", oversampling==BMP384_OVERSAMPLING_x4?"ok":"error");
1256
1257 /* set oversampling x8 */
1259 if (res != 0)
1260 {
1261 bmp384_interface_debug_print("bmp384: set temperature oversampling failed.\n");
1262 (void)bmp384_deinit(&gs_handle);
1263
1264 return 1;
1265 }
1266 bmp384_interface_debug_print("bmp384: set temperature oversampling x8.\n");
1267 res = bmp384_get_temperature_oversampling(&gs_handle, (bmp384_oversampling_t *)&oversampling);
1268 if (res != 0)
1269 {
1270 bmp384_interface_debug_print("bmp384: get temperature oversampling failed.\n");
1271 (void)bmp384_deinit(&gs_handle);
1272
1273 return 1;
1274 }
1275 bmp384_interface_debug_print("bmp384: check temperature oversampling %s.\n", oversampling==BMP384_OVERSAMPLING_x8?"ok":"error");
1276
1277 /* set oversampling x16 */
1279 if (res != 0)
1280 {
1281 bmp384_interface_debug_print("bmp384: set temperature oversampling failed.\n");
1282 (void)bmp384_deinit(&gs_handle);
1283
1284 return 1;
1285 }
1286 bmp384_interface_debug_print("bmp384: set temperature oversampling x16.\n");
1287 res = bmp384_get_temperature_oversampling(&gs_handle, (bmp384_oversampling_t *)&oversampling);
1288 if (res != 0)
1289 {
1290 bmp384_interface_debug_print("bmp384: get temperature oversampling failed.\n");
1291 (void)bmp384_deinit(&gs_handle);
1292
1293 return 1;
1294 }
1295 bmp384_interface_debug_print("bmp384: check temperature oversampling %s.\n", oversampling==BMP384_OVERSAMPLING_x16?"ok":"error");
1296
1297 /* set oversampling x32 */
1299 if (res != 0)
1300 {
1301 bmp384_interface_debug_print("bmp384: set temperature oversampling failed.\n");
1302 (void)bmp384_deinit(&gs_handle);
1303
1304 return 1;
1305 }
1306 bmp384_interface_debug_print("bmp384: set temperature oversampling x32.\n");
1307 res = bmp384_get_temperature_oversampling(&gs_handle, (bmp384_oversampling_t *)&oversampling);
1308 if (res != 0)
1309 {
1310 bmp384_interface_debug_print("bmp384: get temperature oversampling failed.\n");
1311 (void)bmp384_deinit(&gs_handle);
1312
1313 return 1;
1314 }
1315 bmp384_interface_debug_print("bmp384: check temperature oversampling %s.\n", oversampling==BMP384_OVERSAMPLING_x32?"ok":"error");
1316
1317 /* bmp384_set_odr/bmp384_get_odr test */
1318 bmp384_interface_debug_print("bmp384: bmp384_set_odr/bmp384_get_odr test.\n");
1319
1320 /* set odr 200Hz */
1321 res = bmp384_set_odr(&gs_handle, BMP384_ODR_200_HZ);
1322 if (res != 0)
1323 {
1324 bmp384_interface_debug_print("bmp384: set odr failed.\n");
1325 (void)bmp384_deinit(&gs_handle);
1326
1327 return 1;
1328 }
1329 bmp384_interface_debug_print("bmp384: set odr 200Hz.\n");
1330 res = bmp384_get_odr(&gs_handle, (bmp384_odr_t *)&odr);
1331 if (res != 0)
1332 {
1333 bmp384_interface_debug_print("bmp384: get odr failed.\n");
1334 (void)bmp384_deinit(&gs_handle);
1335
1336 return 1;
1337 }
1338 bmp384_interface_debug_print("bmp384: check odr %s.\n", odr==BMP384_ODR_200_HZ?"ok":"error");
1339
1340 /* set odr 100Hz */
1341 res = bmp384_set_odr(&gs_handle, BMP384_ODR_100_HZ);
1342 if (res != 0)
1343 {
1344 bmp384_interface_debug_print("bmp384: set odr failed.\n");
1345 (void)bmp384_deinit(&gs_handle);
1346
1347 return 1;
1348 }
1349 bmp384_interface_debug_print("bmp384: set odr 100Hz.\n");
1350 res = bmp384_get_odr(&gs_handle, (bmp384_odr_t *)&odr);
1351 if (res != 0)
1352 {
1353 bmp384_interface_debug_print("bmp384: get odr failed.\n");
1354 (void)bmp384_deinit(&gs_handle);
1355
1356 return 1;
1357 }
1358 bmp384_interface_debug_print("bmp384: check odr %s.\n", odr==BMP384_ODR_100_HZ?"ok":"error");
1359
1360 /* set odr 50Hz */
1361 res = bmp384_set_odr(&gs_handle, BMP384_ODR_50_HZ);
1362 if (res != 0)
1363 {
1364 bmp384_interface_debug_print("bmp384: set odr failed.\n");
1365 (void)bmp384_deinit(&gs_handle);
1366
1367 return 1;
1368 }
1369 bmp384_interface_debug_print("bmp384: set odr 50Hz.\n");
1370 res = bmp384_get_odr(&gs_handle, (bmp384_odr_t *)&odr);
1371 if (res != 0)
1372 {
1373 bmp384_interface_debug_print("bmp384: get odr failed.\n");
1374 (void)bmp384_deinit(&gs_handle);
1375
1376 return 1;
1377 }
1378 bmp384_interface_debug_print("bmp384: check odr %s.\n", odr==BMP384_ODR_50_HZ?"ok":"error");
1379
1380 /* set odr 25Hz */
1381 res = bmp384_set_odr(&gs_handle, BMP384_ODR_25_HZ);
1382 if (res != 0)
1383 {
1384 bmp384_interface_debug_print("bmp384: set odr failed.\n");
1385 (void)bmp384_deinit(&gs_handle);
1386
1387 return 1;
1388 }
1389 bmp384_interface_debug_print("bmp384: set odr 25Hz.\n");
1390 res = bmp384_get_odr(&gs_handle, (bmp384_odr_t *)&odr);
1391 if (res != 0)
1392 {
1393 bmp384_interface_debug_print("bmp384: get odr failed.\n");
1394 (void)bmp384_deinit(&gs_handle);
1395
1396 return 1;
1397 }
1398 bmp384_interface_debug_print("bmp384: check odr %s.\n", odr==BMP384_ODR_25_HZ?"ok":"error");
1399
1400 /* set odr 12.5Hz */
1401 res = bmp384_set_odr(&gs_handle, BMP384_ODR_12P5_HZ);
1402 if (res != 0)
1403 {
1404 bmp384_interface_debug_print("bmp384: set odr failed.\n");
1405 (void)bmp384_deinit(&gs_handle);
1406
1407 return 1;
1408 }
1409 bmp384_interface_debug_print("bmp384: set odr 12.5Hz.\n");
1410 res = bmp384_get_odr(&gs_handle, (bmp384_odr_t *)&odr);
1411 if (res != 0)
1412 {
1413 bmp384_interface_debug_print("bmp384: get odr failed.\n");
1414 (void)bmp384_deinit(&gs_handle);
1415
1416 return 1;
1417 }
1418 bmp384_interface_debug_print("bmp384: check odr %s.\n", odr==BMP384_ODR_12P5_HZ?"ok":"error");
1419
1420 /* set odr 6.25Hz */
1421 res = bmp384_set_odr(&gs_handle, BMP384_ODR_6P25_HZ);
1422 if (res != 0)
1423 {
1424 bmp384_interface_debug_print("bmp384: set odr failed.\n");
1425 (void)bmp384_deinit(&gs_handle);
1426
1427 return 1;
1428 }
1429 bmp384_interface_debug_print("bmp384: set odr 6.25Hz.\n");
1430 res = bmp384_get_odr(&gs_handle, (bmp384_odr_t *)&odr);
1431 if (res != 0)
1432 {
1433 bmp384_interface_debug_print("bmp384: get odr failed.\n");
1434 (void)bmp384_deinit(&gs_handle);
1435
1436 return 1;
1437 }
1438 bmp384_interface_debug_print("bmp384: check odr %s.\n", odr==BMP384_ODR_6P25_HZ?"ok":"error");
1439
1440 /* set odr 3.1Hz */
1441 res = bmp384_set_odr(&gs_handle, BMP384_ODR_3P1_HZ);
1442 if (res != 0)
1443 {
1444 bmp384_interface_debug_print("bmp384: set odr failed.\n");
1445 (void)bmp384_deinit(&gs_handle);
1446
1447 return 1;
1448 }
1449 bmp384_interface_debug_print("bmp384: set odr 3.1Hz.\n");
1450 res = bmp384_get_odr(&gs_handle, (bmp384_odr_t *)&odr);
1451 if (res != 0)
1452 {
1453 bmp384_interface_debug_print("bmp384: get odr failed.\n");
1454 (void)bmp384_deinit(&gs_handle);
1455
1456 return 1;
1457 }
1458 bmp384_interface_debug_print("bmp384: check odr %s.\n", odr==BMP384_ODR_3P1_HZ?"ok":"error");
1459
1460 /* set odr 1.5Hz */
1461 res = bmp384_set_odr(&gs_handle, BMP384_ODR_1P5_HZ);
1462 if (res != 0)
1463 {
1464 bmp384_interface_debug_print("bmp384: set odr failed.\n");
1465 (void)bmp384_deinit(&gs_handle);
1466
1467 return 1;
1468 }
1469 bmp384_interface_debug_print("bmp384: set odr 1.5Hz.\n");
1470 res = bmp384_get_odr(&gs_handle, (bmp384_odr_t *)&odr);
1471 if (res != 0)
1472 {
1473 bmp384_interface_debug_print("bmp384: get odr failed.\n");
1474 (void)bmp384_deinit(&gs_handle);
1475
1476 return 1;
1477 }
1478 bmp384_interface_debug_print("bmp384: check odr %s.\n", odr==BMP384_ODR_1P5_HZ?"ok":"error");
1479
1480 /* set odr 0.78Hz */
1481 res = bmp384_set_odr(&gs_handle, BMP384_ODR_0P78_HZ);
1482 if (res != 0)
1483 {
1484 bmp384_interface_debug_print("bmp384: set odr failed.\n");
1485 (void)bmp384_deinit(&gs_handle);
1486
1487 return 1;
1488 }
1489 bmp384_interface_debug_print("bmp384: set odr 0.78Hz.\n");
1490 res = bmp384_get_odr(&gs_handle, (bmp384_odr_t *)&odr);
1491 if (res != 0)
1492 {
1493 bmp384_interface_debug_print("bmp384: get odr failed.\n");
1494 (void)bmp384_deinit(&gs_handle);
1495
1496 return 1;
1497 }
1498 bmp384_interface_debug_print("bmp384: check odr %s.\n", odr==BMP384_ODR_0P78_HZ?"ok":"error");
1499
1500 /* set odr 0.39Hz */
1501 res = bmp384_set_odr(&gs_handle, BMP384_ODR_0P39_HZ);
1502 if (res != 0)
1503 {
1504 bmp384_interface_debug_print("bmp384: set odr failed.\n");
1505 (void)bmp384_deinit(&gs_handle);
1506
1507 return 1;
1508 }
1509 bmp384_interface_debug_print("bmp384: set odr 0.39Hz.\n");
1510 res = bmp384_get_odr(&gs_handle, (bmp384_odr_t *)&odr);
1511 if (res != 0)
1512 {
1513 bmp384_interface_debug_print("bmp384: get odr failed.\n");
1514 (void)bmp384_deinit(&gs_handle);
1515
1516 return 1;
1517 }
1518 bmp384_interface_debug_print("bmp384: check odr %s.\n", odr==BMP384_ODR_0P39_HZ?"ok":"error");
1519
1520 /* set odr 0.2Hz */
1521 res = bmp384_set_odr(&gs_handle, BMP384_ODR_0P2_HZ);
1522 if (res != 0)
1523 {
1524 bmp384_interface_debug_print("bmp384: set odr failed.\n");
1525 (void)bmp384_deinit(&gs_handle);
1526
1527 return 1;
1528 }
1529 bmp384_interface_debug_print("bmp384: set odr 0.2Hz.\n");
1530 res = bmp384_get_odr(&gs_handle, (bmp384_odr_t *)&odr);
1531 if (res != 0)
1532 {
1533 bmp384_interface_debug_print("bmp384: get odr failed.\n");
1534 (void)bmp384_deinit(&gs_handle);
1535
1536 return 1;
1537 }
1538 bmp384_interface_debug_print("bmp384: check odr %s.\n", odr==BMP384_ODR_0P2_HZ?"ok":"error");
1539
1540 /* set odr 0.1Hz */
1541 res = bmp384_set_odr(&gs_handle, BMP384_ODR_0P1_HZ);
1542 if (res != 0)
1543 {
1544 bmp384_interface_debug_print("bmp384: set odr failed.\n");
1545 (void)bmp384_deinit(&gs_handle);
1546
1547 return 1;
1548 }
1549 bmp384_interface_debug_print("bmp384: set odr 0.1Hz.\n");
1550 res = bmp384_get_odr(&gs_handle, (bmp384_odr_t *)&odr);
1551 if (res != 0)
1552 {
1553 bmp384_interface_debug_print("bmp384: get odr failed.\n");
1554 (void)bmp384_deinit(&gs_handle);
1555
1556 return 1;
1557 }
1558 bmp384_interface_debug_print("bmp384: check odr %s.\n", odr==BMP384_ODR_0P1_HZ?"ok":"error");
1559
1560 /* set odr 0.05Hz */
1561 res = bmp384_set_odr(&gs_handle, BMP384_ODR_0P05_HZ);
1562 if (res != 0)
1563 {
1564 bmp384_interface_debug_print("bmp384: set odr failed.\n");
1565 (void)bmp384_deinit(&gs_handle);
1566
1567 return 1;
1568 }
1569 bmp384_interface_debug_print("bmp384: set odr 0.05Hz.\n");
1570 res = bmp384_get_odr(&gs_handle, (bmp384_odr_t *)&odr);
1571 if (res != 0)
1572 {
1573 bmp384_interface_debug_print("bmp384: get odr failed.\n");
1574 (void)bmp384_deinit(&gs_handle);
1575
1576 return 1;
1577 }
1578 bmp384_interface_debug_print("bmp384: check odr %s.\n", odr==BMP384_ODR_0P05_HZ?"ok":"error");
1579
1580 /* set odr 0.02Hz */
1581 res = bmp384_set_odr(&gs_handle, BMP384_ODR_0P02_HZ);
1582 if (res != 0)
1583 {
1584 bmp384_interface_debug_print("bmp384: set odr failed.\n");
1585 (void)bmp384_deinit(&gs_handle);
1586
1587 return 1;
1588 }
1589 bmp384_interface_debug_print("bmp384: set odr 0.02Hz.\n");
1590 res = bmp384_get_odr(&gs_handle, (bmp384_odr_t *)&odr);
1591 if (res != 0)
1592 {
1593 bmp384_interface_debug_print("bmp384: get odr failed.\n");
1594 (void)bmp384_deinit(&gs_handle);
1595
1596 return 1;
1597 }
1598 bmp384_interface_debug_print("bmp384: check odr %s.\n", odr==BMP384_ODR_0P02_HZ?"ok":"error");
1599
1600 /* set odr 0.01Hz */
1601 res = bmp384_set_odr(&gs_handle, BMP384_ODR_0P01_HZ);
1602 if (res != 0)
1603 {
1604 bmp384_interface_debug_print("bmp384: set odr failed.\n");
1605 (void)bmp384_deinit(&gs_handle);
1606
1607 return 1;
1608 }
1609 bmp384_interface_debug_print("bmp384: set odr 0.01Hz.\n");
1610 res = bmp384_get_odr(&gs_handle, (bmp384_odr_t *)&odr);
1611 if (res != 0)
1612 {
1613 bmp384_interface_debug_print("bmp384: get odr failed.\n");
1614 (void)bmp384_deinit(&gs_handle);
1615
1616 return 1;
1617 }
1618 bmp384_interface_debug_print("bmp384: check odr %s.\n", odr==BMP384_ODR_0P01_HZ?"ok":"error");
1619
1620 /* set odr 0.006Hz */
1621 res = bmp384_set_odr(&gs_handle, BMP384_ODR_0P006_HZ);
1622 if (res != 0)
1623 {
1624 bmp384_interface_debug_print("bmp384: set odr failed.\n");
1625 (void)bmp384_deinit(&gs_handle);
1626
1627 return 1;
1628 }
1629 bmp384_interface_debug_print("bmp384: set odr 0.006Hz.\n");
1630 res = bmp384_get_odr(&gs_handle, (bmp384_odr_t *)&odr);
1631 if (res != 0)
1632 {
1633 bmp384_interface_debug_print("bmp384: get odr failed.\n");
1634 (void)bmp384_deinit(&gs_handle);
1635
1636 return 1;
1637 }
1638 bmp384_interface_debug_print("bmp384: check odr %s.\n", odr==BMP384_ODR_0P006_HZ?"ok":"error");
1639
1640 /* set odr 0.003Hz */
1641 res = bmp384_set_odr(&gs_handle, BMP384_ODR_0P003_HZ);
1642 if (res != 0)
1643 {
1644 bmp384_interface_debug_print("bmp384: set odr failed.\n");
1645 (void)bmp384_deinit(&gs_handle);
1646
1647 return 1;
1648 }
1649 bmp384_interface_debug_print("bmp384: set odr 0.003Hz.\n");
1650 res = bmp384_get_odr(&gs_handle, (bmp384_odr_t *)&odr);
1651 if (res != 0)
1652 {
1653 bmp384_interface_debug_print("bmp384: get odr failed.\n");
1654 (void)bmp384_deinit(&gs_handle);
1655
1656 return 1;
1657 }
1658 bmp384_interface_debug_print("bmp384: check odr %s.\n", odr==BMP384_ODR_0P003_HZ?"ok":"error");
1659
1660 /* set odr 0.0015Hz */
1661 res = bmp384_set_odr(&gs_handle, BMP384_ODR_0P0015_HZ);
1662 if (res != 0)
1663 {
1664 bmp384_interface_debug_print("bmp384: set odr failed.\n");
1665 (void)bmp384_deinit(&gs_handle);
1666
1667 return 1;
1668 }
1669 bmp384_interface_debug_print("bmp384: set odr 0.0015Hz.\n");
1670 res = bmp384_get_odr(&gs_handle, (bmp384_odr_t *)&odr);
1671 if (res != 0)
1672 {
1673 bmp384_interface_debug_print("bmp384: get odr failed.\n");
1674 (void)bmp384_deinit(&gs_handle);
1675
1676 return 1;
1677 }
1678 bmp384_interface_debug_print("bmp384: check odr %s.\n", odr==BMP384_ODR_0P0015_HZ?"ok":"error");
1679
1680 /* bmp384_set_filter_coefficient/bmp384_get_filter_coefficient test */
1681 bmp384_interface_debug_print("bmp384: bmp384_set_filter_coefficient/bmp384_get_filter_coefficient test.\n");
1682
1683 /* set coefficient 0 */
1685 if (res != 0)
1686 {
1687 bmp384_interface_debug_print("bmp384: set filter coefficient failed.\n");
1688 (void)bmp384_deinit(&gs_handle);
1689
1690 return 1;
1691 }
1692 bmp384_interface_debug_print("bmp384: set filter coefficient 0.\n");
1694 if (res != 0)
1695 {
1696 bmp384_interface_debug_print("bmp384: get filter coefficient failed.\n");
1697 (void)bmp384_deinit(&gs_handle);
1698
1699 return 1;
1700 }
1701 bmp384_interface_debug_print("bmp384: check filter coefficient %s.\n", coef==BMP384_FILTER_COEFFICIENT_0?"ok":"error");
1702
1703 /* set coefficient 1 */
1705 if (res != 0)
1706 {
1707 bmp384_interface_debug_print("bmp384: set filter coefficient failed.\n");
1708 (void)bmp384_deinit(&gs_handle);
1709
1710 return 1;
1711 }
1712 bmp384_interface_debug_print("bmp384: set filter coefficient 1.\n");
1714 if (res != 0)
1715 {
1716 bmp384_interface_debug_print("bmp384: get filter coefficient failed.\n");
1717 (void)bmp384_deinit(&gs_handle);
1718
1719 return 1;
1720 }
1721 bmp384_interface_debug_print("bmp384: check filter coefficient %s.\n", coef==BMP384_FILTER_COEFFICIENT_1?"ok":"error");
1722
1723 /* set coefficient 3 */
1725 if (res != 0)
1726 {
1727 bmp384_interface_debug_print("bmp384: set filter coefficient failed.\n");
1728 (void)bmp384_deinit(&gs_handle);
1729
1730 return 1;
1731 }
1732 bmp384_interface_debug_print("bmp384: set filter coefficient 3.\n");
1734 if (res != 0)
1735 {
1736 bmp384_interface_debug_print("bmp384: get filter coefficient failed.\n");
1737 (void)bmp384_deinit(&gs_handle);
1738
1739 return 1;
1740 }
1741 bmp384_interface_debug_print("bmp384: check filter coefficient %s.\n", coef==BMP384_FILTER_COEFFICIENT_3?"ok":"error");
1742
1743 /* set coefficient 7 */
1745 if (res != 0)
1746 {
1747 bmp384_interface_debug_print("bmp384: set filter coefficient failed.\n");
1748 (void)bmp384_deinit(&gs_handle);
1749
1750 return 1;
1751 }
1752 bmp384_interface_debug_print("bmp384: set filter coefficient 7.\n");
1754 if (res != 0)
1755 {
1756 bmp384_interface_debug_print("bmp384: get filter coefficient failed.\n");
1757 (void)bmp384_deinit(&gs_handle);
1758
1759 return 1;
1760 }
1761 bmp384_interface_debug_print("bmp384: check filter coefficient %s.\n", coef==BMP384_FILTER_COEFFICIENT_7?"ok":"error");
1762
1763 /* set coefficient 15 */
1765 if (res != 0)
1766 {
1767 bmp384_interface_debug_print("bmp384: set filter coefficient failed.\n");
1768 (void)bmp384_deinit(&gs_handle);
1769
1770 return 1;
1771 }
1772 bmp384_interface_debug_print("bmp384: set filter coefficient 15.\n");
1774 if (res != 0)
1775 {
1776 bmp384_interface_debug_print("bmp384: get filter coefficient failed.\n");
1777 (void)bmp384_deinit(&gs_handle);
1778
1779 return 1;
1780 }
1781 bmp384_interface_debug_print("bmp384: check filter coefficient %s.\n", coef==BMP384_FILTER_COEFFICIENT_15?"ok":"error");
1782
1783 /* set coefficient 31 */
1785 if (res != 0)
1786 {
1787 bmp384_interface_debug_print("bmp384: set filter coefficient failed.\n");
1788 (void)bmp384_deinit(&gs_handle);
1789
1790 return 1;
1791 }
1792 bmp384_interface_debug_print("bmp384: set filter coefficient 31.\n");
1794 if (res != 0)
1795 {
1796 bmp384_interface_debug_print("bmp384: get filter coefficient failed.\n");
1797 (void)bmp384_deinit(&gs_handle);
1798
1799 return 1;
1800 }
1801 bmp384_interface_debug_print("bmp384: check filter coefficient %s.\n", coef==BMP384_FILTER_COEFFICIENT_31?"ok":"error");
1802
1803 /* set coefficient 63 */
1805 if (res != 0)
1806 {
1807 bmp384_interface_debug_print("bmp384: set filter coefficient failed.\n");
1808 (void)bmp384_deinit(&gs_handle);
1809
1810 return 1;
1811 }
1812 bmp384_interface_debug_print("bmp384: set filter coefficient 63.\n");
1814 if (res != 0)
1815 {
1816 bmp384_interface_debug_print("bmp384: get filter coefficient failed.\n");
1817 (void)bmp384_deinit(&gs_handle);
1818
1819 return 1;
1820 }
1821 bmp384_interface_debug_print("bmp384: check filter coefficient %s.\n", coef==BMP384_FILTER_COEFFICIENT_63?"ok":"error");
1822
1823 /* set coefficient 127 */
1825 if (res != 0)
1826 {
1827 bmp384_interface_debug_print("bmp384: set filter coefficient failed.\n");
1828 (void)bmp384_deinit(&gs_handle);
1829
1830 return 1;
1831 }
1832 bmp384_interface_debug_print("bmp384: set filter coefficient 127.\n");
1834 if (res != 0)
1835 {
1836 bmp384_interface_debug_print("bmp384: get filter coefficient failed.\n");
1837 (void)bmp384_deinit(&gs_handle);
1838
1839 return 1;
1840 }
1841 bmp384_interface_debug_print("bmp384: check filter coefficient %s.\n", coef==BMP384_FILTER_COEFFICIENT_127?"ok":"error");
1842
1843 /* bmp384_get_error */
1844 bmp384_interface_debug_print("bmp384: bmp384_get_error.\n");
1845 res = bmp384_get_error(&gs_handle, (uint8_t *)&err);
1846 if (res != 0)
1847 {
1848 bmp384_interface_debug_print("bmp384: get err failed.\n");
1849 (void)bmp384_deinit(&gs_handle);
1850
1851 return 1;
1852 }
1853 bmp384_interface_debug_print("bmp384: err is 0x%02X.\n", (uint8_t)err);
1854
1855 /* bmp384_get_status */
1856 bmp384_interface_debug_print("bmp384: bmp384_get_status.\n");
1857 res = bmp384_get_status(&gs_handle, (uint8_t *)&status);
1858 if (res != 0)
1859 {
1860 bmp384_interface_debug_print("bmp384: get status failed.\n");
1861 (void)bmp384_deinit(&gs_handle);
1862
1863 return 1;
1864 }
1865 bmp384_interface_debug_print("bmp384: status is 0x%02X.\n", (uint8_t)status);
1866
1867 /* bmp384_get_sensortime */
1868 bmp384_interface_debug_print("bmp384: bmp384_get_sensortime.\n");
1869 res = bmp384_get_sensortime(&gs_handle, (uint32_t *)&sensortime);
1870 if (res != 0)
1871 {
1872 bmp384_interface_debug_print("bmp384: get sensor time failed.\n");
1873 (void)bmp384_deinit(&gs_handle);
1874
1875 return 1;
1876 }
1877 bmp384_interface_debug_print("bmp384: sensor time is 0x%06X.\n", (uint32_t)sensortime);
1878
1879 /* bmp384_get_event */
1880 bmp384_interface_debug_print("bmp384: bmp384_get_event.\n");
1881 res = bmp384_get_event(&gs_handle, &event);
1882 if (res != 0)
1883 {
1884 bmp384_interface_debug_print("bmp384: get event failed.\n");
1885 (void)bmp384_deinit(&gs_handle);
1886
1887 return 1;
1888 }
1889 bmp384_interface_debug_print("bmp384: event is %s.\n", event==BMP384_EVENT_NONE?"none":"power up or softrest");
1890
1891 /* bmp384_get_interrupt_status */
1892 bmp384_interface_debug_print("bmp384: bmp384_get_interrupt_status.\n");
1893 res = bmp384_get_interrupt_status(&gs_handle, (uint8_t *)&status);
1894 if (res != 0)
1895 {
1896 bmp384_interface_debug_print("bmp384: get interrupt status failed.\n");
1897 (void)bmp384_deinit(&gs_handle);
1898
1899 return 1;
1900 }
1901 bmp384_interface_debug_print("bmp384: interrupt status is 0x%02X.\n", (uint8_t)status);
1902
1903 /* bmp384_get_fifo_length */
1904 bmp384_interface_debug_print("bmp384: bmp384_get_fifo_length.\n");
1905 res = bmp384_get_fifo_length(&gs_handle, (uint16_t *)&length);
1906 if (res != 0)
1907 {
1908 bmp384_interface_debug_print("bmp384: get fifo length failed.\n");
1909 (void)bmp384_deinit(&gs_handle);
1910
1911 return 1;
1912 }
1913 bmp384_interface_debug_print("bmp384: get fifo length is 0x%04X.\n", (uint16_t)length);
1914
1915 /* bmp384_get_fifo_data */
1916 bmp384_interface_debug_print("bmp384: bmp384_get_fifo_data.\n");
1917 res = bmp384_get_fifo_data(&gs_handle, (uint8_t *)&data, 1);
1918 if (res != 0)
1919 {
1920 bmp384_interface_debug_print("bmp384: get fifo data failed.\n");
1921 (void)bmp384_deinit(&gs_handle);
1922
1923 return 1;
1924 }
1925 bmp384_interface_debug_print("bmp384: get fifo data is 0x%04X.\n", (uint8_t)data);
1926
1927 /* bmp384_flush_fifo */
1928 bmp384_interface_debug_print("bmp384: bmp384_flush_fifo.\n");
1929 res = bmp384_flush_fifo(&gs_handle);
1930 if (res != 0)
1931 {
1932 bmp384_interface_debug_print("bmp384: flush fifo failed.\n");
1933 (void)bmp384_deinit(&gs_handle);
1934
1935 return 1;
1936 }
1937 bmp384_interface_debug_print("bmp384: flush fifo %s.\n", res?"error":"ok");
1938
1939 /* bmp384_extmode_en_middle */
1940 bmp384_interface_debug_print("bmp384: bmp384_extmode_en_middle.\n");
1941 res = bmp384_extmode_en_middle(&gs_handle);
1942 if (res != 0)
1943 {
1944 bmp384_interface_debug_print("bmp384: extmode en middle failed.\n");
1945 (void)bmp384_deinit(&gs_handle);
1946
1947 return 1;
1948 }
1949 bmp384_interface_debug_print("bmp384: extmode en middle %s.\n", res?"error":"ok");
1950
1951 /* bmp384_softreset */
1952 bmp384_interface_debug_print("bmp384: bmp384_softreset.\n");
1953 res = bmp384_softreset(&gs_handle);
1954 if (res != 0)
1955 {
1956 bmp384_interface_debug_print("bmp384: bmp384 soft reset failed.\n");
1957 (void)bmp384_deinit(&gs_handle);
1958
1959 return 1;
1960 }
1961 bmp384_interface_debug_print("bmp384: soft reset %s.\n", res?"error":"ok");
1962
1963 /* finish register test */
1964 bmp384_interface_debug_print("bmp384: finish register test.\n");
1965 (void)bmp384_deinit(&gs_handle);
1966
1967 return 0;
1968}
driver bmp384 register test header file
uint8_t bmp384_get_iic_watchdog_timer(bmp384_handle_t *handle, bmp384_bool_t *enable)
get the iic watchdog timer status
uint8_t bmp384_deinit(bmp384_handle_t *handle)
close the chip
bmp384_event_t
bmp384 event enumeration definition
uint8_t bmp384_get_addr_pin(bmp384_handle_t *handle, bmp384_address_t *addr_pin)
get the iic address pin
uint8_t bmp384_get_spi_wire(bmp384_handle_t *handle, bmp384_spi_wire_t *wire)
get the spi wire
bmp384_mode_t
bmp384 mode enumeration definition
uint8_t bmp384_set_addr_pin(bmp384_handle_t *handle, bmp384_address_t addr_pin)
set the iic address pin
bmp384_interface_t
bmp384 interface enumeration definition
uint8_t bmp384_softreset(bmp384_handle_t *handle)
soft reset
uint8_t bmp384_get_filter_coefficient(bmp384_handle_t *handle, bmp384_filter_coefficient_t *coefficient)
get the filter coefficient
uint8_t bmp384_extmode_en_middle(bmp384_handle_t *handle)
extmode enable middle
uint8_t bmp384_get_pressure_oversampling(bmp384_handle_t *handle, bmp384_oversampling_t *oversampling)
get the pressure oversampling
bmp384_fifo_data_source_t
bmp384 fifo data source enumeration definition
uint8_t bmp384_get_pressure(bmp384_handle_t *handle, bmp384_bool_t *enable)
get the pressure status
uint8_t bmp384_get_status(bmp384_handle_t *handle, uint8_t *status)
get the status
uint8_t bmp384_set_interface(bmp384_handle_t *handle, bmp384_interface_t interface)
set the interface
uint8_t bmp384_set_pressure(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable the pressure
uint8_t bmp384_set_temperature(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable the temperature
bmp384_spi_wire_t
bmp384 spi wire enumeration definition
bmp384_bool_t
bmp384 bool enumeration definition
uint8_t bmp384_get_sensortime(bmp384_handle_t *handle, uint32_t *t)
get the sensor time
bmp384_interrupt_pin_type_t
bmp384 interrupt pin type enumeration definition
uint8_t bmp384_get_temperature_oversampling(bmp384_handle_t *handle, bmp384_oversampling_t *oversampling)
get the temperature oversampling
uint8_t bmp384_set_pressure_oversampling(bmp384_handle_t *handle, bmp384_oversampling_t oversampling)
set the pressure oversampling
uint8_t bmp384_get_interface(bmp384_handle_t *handle, bmp384_interface_t *interface)
get the interface
uint8_t bmp384_set_iic_watchdog_timer(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable the iic watchdog timer
uint8_t bmp384_get_event(bmp384_handle_t *handle, bmp384_event_t *event)
get the event
bmp384_odr_t
bmp384 output data rate enumeration definition
bmp384_address_t
bmp384 address enumeration definition
uint8_t bmp384_set_filter_coefficient(bmp384_handle_t *handle, bmp384_filter_coefficient_t coefficient)
set the filter coefficient
uint8_t bmp384_info(bmp384_info_t *info)
get chip's information
bmp384_filter_coefficient_t
bmp384 filter coefficient enumeration definition
uint8_t bmp384_get_mode(bmp384_handle_t *handle, bmp384_mode_t *mode)
get the chip mode
struct bmp384_info_s bmp384_info_t
bmp384 information structure definition
uint8_t bmp384_set_spi_wire(bmp384_handle_t *handle, bmp384_spi_wire_t wire)
set the spi wire
uint8_t bmp384_set_mode(bmp384_handle_t *handle, bmp384_mode_t mode)
set the chip mode
uint8_t bmp384_init(bmp384_handle_t *handle)
initialize the chip
bmp384_iic_watchdog_period_t
bmp384 iic watchdog period enumeration definition
uint8_t bmp384_set_iic_watchdog_period(bmp384_handle_t *handle, bmp384_iic_watchdog_period_t period)
set the iic watchdog period
uint8_t bmp384_get_iic_watchdog_period(bmp384_handle_t *handle, bmp384_iic_watchdog_period_t *period)
get the iic watchdog period
uint8_t bmp384_get_odr(bmp384_handle_t *handle, bmp384_odr_t *odr)
get the output data rate
bmp384_oversampling_t
bmp384 oversampling enumeration definition
uint8_t bmp384_set_temperature_oversampling(bmp384_handle_t *handle, bmp384_oversampling_t oversampling)
set the temperature oversampling
struct bmp384_handle_s bmp384_handle_t
bmp384 handle structure definition
uint8_t bmp384_set_odr(bmp384_handle_t *handle, bmp384_odr_t odr)
set the output data rate
uint8_t bmp384_get_temperature(bmp384_handle_t *handle, bmp384_bool_t *enable)
get the temperature status
uint8_t bmp384_get_error(bmp384_handle_t *handle, uint8_t *err)
get the error
bmp384_interrupt_active_level_t
bmp384 interrupt active level enumeration definition
@ BMP384_EVENT_NONE
@ BMP384_MODE_FORCED_MODE
@ BMP384_MODE_NORMAL_MODE
@ BMP384_MODE_SLEEP_MODE
@ BMP384_INTERFACE_SPI
@ BMP384_INTERFACE_IIC
@ BMP384_FIFO_DATA_SOURCE_UNFILTERED
@ BMP384_FIFO_DATA_SOURCE_FILTERED
@ BMP384_SPI_WIRE_3
@ BMP384_SPI_WIRE_4
@ BMP384_BOOL_TRUE
@ BMP384_BOOL_FALSE
@ BMP384_INTERRUPT_PIN_TYPE_PUSH_PULL
@ BMP384_INTERRUPT_PIN_TYPE_OPEN_DRAIN
@ BMP384_ODR_6P25_HZ
@ BMP384_ODR_1P5_HZ
@ BMP384_ODR_100_HZ
@ BMP384_ODR_50_HZ
@ BMP384_ODR_0P003_HZ
@ BMP384_ODR_0P78_HZ
@ BMP384_ODR_0P05_HZ
@ BMP384_ODR_12P5_HZ
@ BMP384_ODR_0P006_HZ
@ BMP384_ODR_25_HZ
@ BMP384_ODR_0P02_HZ
@ BMP384_ODR_200_HZ
@ BMP384_ODR_0P39_HZ
@ BMP384_ODR_3P1_HZ
@ BMP384_ODR_0P2_HZ
@ BMP384_ODR_0P1_HZ
@ BMP384_ODR_0P01_HZ
@ BMP384_ODR_0P0015_HZ
@ BMP384_ADDRESS_ADO_LOW
@ BMP384_ADDRESS_ADO_HIGH
@ BMP384_FILTER_COEFFICIENT_31
@ BMP384_FILTER_COEFFICIENT_63
@ BMP384_FILTER_COEFFICIENT_127
@ BMP384_FILTER_COEFFICIENT_7
@ BMP384_FILTER_COEFFICIENT_15
@ BMP384_FILTER_COEFFICIENT_0
@ BMP384_FILTER_COEFFICIENT_3
@ BMP384_FILTER_COEFFICIENT_1
@ BMP384_IIC_WATCHDOG_PERIOD_1P25_MS
@ BMP384_IIC_WATCHDOG_PERIOD_40_MS
@ BMP384_OVERSAMPLING_x1
@ BMP384_OVERSAMPLING_x32
@ BMP384_OVERSAMPLING_x2
@ BMP384_OVERSAMPLING_x16
@ BMP384_OVERSAMPLING_x4
@ BMP384_OVERSAMPLING_x8
@ BMP384_INTERRUPT_ACTIVE_LEVEL_LOWER
@ BMP384_INTERRUPT_ACTIVE_LEVEL_HIGHER
uint8_t bmp384_get_fifo_pressure_on(bmp384_handle_t *handle, bmp384_bool_t *enable)
get the fifo pressure on status
uint8_t bmp384_set_fifo_pressure_on(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable the fifo pressure on
uint8_t bmp384_set_fifo_data_source(bmp384_handle_t *handle, bmp384_fifo_data_source_t source)
set the fifo data source
uint8_t bmp384_get_fifo_length(bmp384_handle_t *handle, uint16_t *length)
get the fifo length
uint8_t bmp384_set_fifo_stop_on_full(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable the fifo stopping on full
uint8_t bmp384_set_fifo_sensortime_on(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable the fifo sensor time on
uint8_t bmp384_get_fifo_temperature_on(bmp384_handle_t *handle, bmp384_bool_t *enable)
get the fifo temperature on status
uint8_t bmp384_set_fifo(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable the fifo
uint8_t bmp384_get_fifo(bmp384_handle_t *handle, bmp384_bool_t *enable)
get the fifo status
uint8_t bmp384_get_fifo_stop_on_full(bmp384_handle_t *handle, bmp384_bool_t *enable)
get the fifo stopping on full status
uint8_t bmp384_get_fifo_sensortime_on(bmp384_handle_t *handle, bmp384_bool_t *enable)
get the fifo sensor time on status
uint8_t bmp384_flush_fifo(bmp384_handle_t *handle)
flush the fifo
uint8_t bmp384_set_fifo_temperature_on(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable the fifo temperature on
uint8_t bmp384_get_fifo_data_source(bmp384_handle_t *handle, bmp384_fifo_data_source_t *source)
get the fifo data source
uint8_t bmp384_get_fifo_watermark(bmp384_handle_t *handle, uint16_t *watermark)
get the fifo watermark
uint8_t bmp384_set_fifo_watermark(bmp384_handle_t *handle, uint16_t watermark)
set the fifo watermark
uint8_t bmp384_get_fifo_data(bmp384_handle_t *handle, uint8_t *data, uint16_t length)
get the fifo data
uint8_t bmp384_set_fifo_subsampling(bmp384_handle_t *handle, uint8_t subsample)
set the fifo subsampling
uint8_t bmp384_get_fifo_subsampling(bmp384_handle_t *handle, uint8_t *subsample)
get the fifo subsampling
uint8_t bmp384_interface_iic_write(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus write
void bmp384_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t bmp384_interface_spi_read(uint8_t reg, uint8_t *buf, uint16_t len)
interface spi bus read
void bmp384_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t bmp384_interface_iic_read(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus read
uint8_t bmp384_interface_iic_init(void)
interface iic bus init
uint8_t bmp384_interface_spi_init(void)
interface spi bus init
uint8_t bmp384_interface_spi_deinit(void)
interface spi bus deinit
void bmp384_interface_receive_callback(uint8_t type)
interface receive callback
uint8_t bmp384_interface_iic_deinit(void)
interface iic bus deinit
uint8_t bmp384_interface_spi_write(uint8_t reg, uint8_t *buf, uint16_t len)
interface spi bus write
uint8_t bmp384_set_interrupt_pin_type(bmp384_handle_t *handle, bmp384_interrupt_pin_type_t pin_type)
set the interrupt pin type
uint8_t bmp384_get_interrupt_active_level(bmp384_handle_t *handle, bmp384_interrupt_active_level_t *level)
get the interrupt active level
uint8_t bmp384_set_interrupt_active_level(bmp384_handle_t *handle, bmp384_interrupt_active_level_t level)
set the interrupt active level
uint8_t bmp384_get_interrupt_fifo_full(bmp384_handle_t *handle, bmp384_bool_t *enable)
get the interrupt fifo full
uint8_t bmp384_get_interrupt_status(bmp384_handle_t *handle, uint8_t *status)
get the interrupt status
uint8_t bmp384_set_interrupt_data_ready(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable the data ready interrupt
uint8_t bmp384_get_interrupt_pin_type(bmp384_handle_t *handle, bmp384_interrupt_pin_type_t *pin_type)
get the interrupt pin type
uint8_t bmp384_get_interrupt_fifo_watermark(bmp384_handle_t *handle, bmp384_bool_t *enable)
get the interrupt fifo watermark
uint8_t bmp384_set_interrupt_fifo_full(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable the fifo full interrupt
uint8_t bmp384_get_latch_interrupt_pin_and_interrupt_status(bmp384_handle_t *handle, bmp384_bool_t *enable)
get latching interrupt pin and interrupt status
uint8_t bmp384_set_interrupt_fifo_watermark(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable the fifo watermark interrupt
uint8_t bmp384_set_latch_interrupt_pin_and_interrupt_status(bmp384_handle_t *handle, bmp384_bool_t enable)
enable or disable latching interrupt pin and interrupt status
uint8_t bmp384_get_interrupt_data_ready(bmp384_handle_t *handle, bmp384_bool_t *enable)
get the interrupt data ready status
uint8_t bmp384_register_test(bmp384_interface_t interface, bmp384_address_t addr_pin)
register test
float supply_voltage_max_v
uint32_t driver_version
char manufacturer_name[32]
float supply_voltage_min_v
char chip_name[32]