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