LibDriver ADXL362
Loading...
Searching...
No Matches
driver_adxl362_read_test.c
Go to the documentation of this file.
1
36
38
39static adxl362_handle_t gs_handle;
40
49uint8_t adxl362_read_test(uint32_t times)
50{
51 uint8_t res;
52 uint32_t i;
53 adxl362_info_t info;
54
55 /* link interface function */
65
66 /* get information */
67 res = adxl362_info(&info);
68 if (res != 0)
69 {
70 adxl362_interface_debug_print("adxl362: get info failed.\n");
71
72 return 1;
73 }
74 else
75 {
76 /* print chip info */
77 adxl362_interface_debug_print("adxl362: chip is %s.\n", info.chip_name);
78 adxl362_interface_debug_print("adxl362: manufacturer is %s.\n", info.manufacturer_name);
79 adxl362_interface_debug_print("adxl362: interface is %s.\n", info.interface);
80 adxl362_interface_debug_print("adxl362: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
81 adxl362_interface_debug_print("adxl362: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
82 adxl362_interface_debug_print("adxl362: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
83 adxl362_interface_debug_print("adxl362: max current is %0.2fmA.\n", info.max_current_ma);
84 adxl362_interface_debug_print("adxl362: max temperature is %0.1fC.\n", info.temperature_max);
85 adxl362_interface_debug_print("adxl362: min temperature is %0.1fC.\n", info.temperature_min);
86 }
87
88 /* start read test */
89 adxl362_interface_debug_print("adxl362: start read test.\n");
90
91 /* init the adxl362 */
92 res = adxl362_init(&gs_handle);
93 if (res != 0)
94 {
95 adxl362_interface_debug_print("adxl362: init failed.\n");
96
97 return 1;
98 }
99
100 /* disable fifo temperature */
102 if (res != 0)
103 {
104 adxl362_interface_debug_print("adxl362: set fifo temperature failed.\n");
105 (void)adxl362_deinit(&gs_handle);
106
107 return 1;
108 }
109
110 /* disable fifo */
112 if (res != 0)
113 {
114 adxl362_interface_debug_print("adxl362: set fifo mode failed.\n");
115 (void)adxl362_deinit(&gs_handle);
116
117 return 1;
118 }
119
120 /* set fifo sample 0 */
121 res = adxl362_set_fifo_sample(&gs_handle, 0);
122 if (res != 0)
123 {
124 adxl362_interface_debug_print("adxl362: set fifo sample failed.\n");
125 (void)adxl362_deinit(&gs_handle);
126
127 return 1;
128 }
129
130 /* set interrupt pin1 active level low */
132 if (res != 0)
133 {
134 adxl362_interface_debug_print("adxl362: set interrupt pin1 active level failed.\n");
135 (void)adxl362_deinit(&gs_handle);
136
137 return 1;
138 }
139
140 /* disable awake map */
142 if (res != 0)
143 {
144 adxl362_interface_debug_print("adxl362: set interrupt pin1 map failed.\n");
145 (void)adxl362_deinit(&gs_handle);
146
147 return 1;
148 }
149
150 /* disable inact map */
152 if (res != 0)
153 {
154 adxl362_interface_debug_print("adxl362: set interrupt pin1 map failed.\n");
155 (void)adxl362_deinit(&gs_handle);
156
157 return 1;
158 }
159
160 /* disable act map */
162 if (res != 0)
163 {
164 adxl362_interface_debug_print("adxl362: set interrupt pin1 map failed.\n");
165 (void)adxl362_deinit(&gs_handle);
166
167 return 1;
168 }
169
170 /* disable fifo overrun map */
172 if (res != 0)
173 {
174 adxl362_interface_debug_print("adxl362: set interrupt pin1 map failed.\n");
175 (void)adxl362_deinit(&gs_handle);
176
177 return 1;
178 }
179
180 /* disable fifo watermark map */
182 if (res != 0)
183 {
184 adxl362_interface_debug_print("adxl362: set interrupt pin1 map failed.\n");
185 (void)adxl362_deinit(&gs_handle);
186
187 return 1;
188 }
189
190 /* disable fifo ready map */
192 if (res != 0)
193 {
194 adxl362_interface_debug_print("adxl362: set interrupt pin1 map failed.\n");
195 (void)adxl362_deinit(&gs_handle);
196
197 return 1;
198 }
199
200 /* disable data ready map */
202 if (res != 0)
203 {
204 adxl362_interface_debug_print("adxl362: set interrupt pin1 map failed.\n");
205 (void)adxl362_deinit(&gs_handle);
206
207 return 1;
208 }
209
210 /* set interrupt pin2 active level low */
212 if (res != 0)
213 {
214 adxl362_interface_debug_print("adxl362: set interrupt pin2 active level failed.\n");
215 (void)adxl362_deinit(&gs_handle);
216
217 return 1;
218 }
219
220 /* disable awake map */
222 if (res != 0)
223 {
224 adxl362_interface_debug_print("adxl362: set interrupt pin2 map failed.\n");
225 (void)adxl362_deinit(&gs_handle);
226
227 return 1;
228 }
229
230 /* disable inact map */
232 if (res != 0)
233 {
234 adxl362_interface_debug_print("adxl362: set interrupt pin2 map failed.\n");
235 (void)adxl362_deinit(&gs_handle);
236
237 return 1;
238 }
239
240 /* disable act map */
242 if (res != 0)
243 {
244 adxl362_interface_debug_print("adxl362: set interrupt pin2 map failed.\n");
245 (void)adxl362_deinit(&gs_handle);
246
247 return 1;
248 }
249
250 /* disable fifo overrun map */
252 if (res != 0)
253 {
254 adxl362_interface_debug_print("adxl362: set interrupt pin2 map failed.\n");
255 (void)adxl362_deinit(&gs_handle);
256
257 return 1;
258 }
259
260 /* disable fifo watermark map */
262 if (res != 0)
263 {
264 adxl362_interface_debug_print("adxl362: set interrupt pin2 map failed.\n");
265 (void)adxl362_deinit(&gs_handle);
266
267 return 1;
268 }
269
270 /* disable fifo ready map */
272 if (res != 0)
273 {
274 adxl362_interface_debug_print("adxl362: set interrupt pin2 map failed.\n");
275 (void)adxl362_deinit(&gs_handle);
276
277 return 1;
278 }
279
280 /* disable data ready map */
282 if (res != 0)
283 {
284 adxl362_interface_debug_print("adxl362: set interrupt pin2 map failed.\n");
285 (void)adxl362_deinit(&gs_handle);
286
287 return 1;
288 }
289
290 /* odr 1/2 */
292 if (res != 0)
293 {
294 adxl362_interface_debug_print("adxl362: set bandwidth failed.\n");
295 (void)adxl362_deinit(&gs_handle);
296
297 return 1;
298 }
299
300 /* normal mode */
302 if (res != 0)
303 {
304 adxl362_interface_debug_print("adxl362: set noise mode failed.\n");
305 (void)adxl362_deinit(&gs_handle);
306
307 return 1;
308 }
309
310 /* disable wake up */
311 res = adxl362_set_wake_up(&gs_handle, ADXL362_BOOL_FALSE);
312 if (res != 0)
313 {
314 adxl362_interface_debug_print("adxl362: set wake up failed.\n");
315 (void)adxl362_deinit(&gs_handle);
316
317 return 1;
318 }
319
320 /* disable auto sleep */
322 if (res != 0)
323 {
324 adxl362_interface_debug_print("adxl362: set auto sleep failed.\n");
325 (void)adxl362_deinit(&gs_handle);
326
327 return 1;
328 }
329
330 /* disable interrupt pin2 as external sampling trigger */
332 if (res != 0)
333 {
334 adxl362_interface_debug_print("adxl362: set interrupt pin2 as external sampling trigger failed.\n");
335 (void)adxl362_deinit(&gs_handle);
336
337 return 1;
338 }
339
340 /* disable interrupt pin1 as external clock */
342 if (res != 0)
343 {
344 adxl362_interface_debug_print("adxl362: set interrupt pin1 as external clock failed.\n");
345 (void)adxl362_deinit(&gs_handle);
346
347 return 1;
348 }
349
350 /* set activity threshold 0x0000 */
351 res = adxl362_set_activity_threshold(&gs_handle, 0x0000);
352 if (res != 0)
353 {
354 adxl362_interface_debug_print("adxl362: set activity threshold failed.\n");
355 (void)adxl362_deinit(&gs_handle);
356
357 return 1;
358 }
359
360 /* set activity time 0x00 */
361 res = adxl362_set_activity_time(&gs_handle, 0x00);
362 if (res != 0)
363 {
364 adxl362_interface_debug_print("adxl362: set activity time failed.\n");
365 (void)adxl362_deinit(&gs_handle);
366
367 return 1;
368 }
369
370 /* set inactivity threshold 0x0000 */
371 res = adxl362_set_inactivity_threshold(&gs_handle, 0x0000);
372 if (res != 0)
373 {
374 adxl362_interface_debug_print("adxl362: set inactivity threshold failed.\n");
375 (void)adxl362_deinit(&gs_handle);
376
377 return 1;
378 }
379
380 /* set inactivity time 0x0000 */
381 res = adxl362_set_inactivity_time(&gs_handle, 0x0000);
382 if (res != 0)
383 {
384 adxl362_interface_debug_print("adxl362: set inactivity time failed.\n");
385 (void)adxl362_deinit(&gs_handle);
386
387 return 1;
388 }
389
390 /* set detect link mode */
392 if (res != 0)
393 {
394 adxl362_interface_debug_print("adxl362: set detect mode failed.\n");
395 (void)adxl362_deinit(&gs_handle);
396
397 return 1;
398 }
399
400 /* set inactivity detect trigger */
402 if (res != 0)
403 {
404 adxl362_interface_debug_print("adxl362: set inactivity detect trigger failed.\n");
405 (void)adxl362_deinit(&gs_handle);
406
407 return 1;
408 }
409
410 /* set activity detect trigger */
412 if (res != 0)
413 {
414 adxl362_interface_debug_print("adxl362: set activity detect trigger failed.\n");
415 (void)adxl362_deinit(&gs_handle);
416
417 return 1;
418 }
419
420 /* disable inactivity */
422 if (res != 0)
423 {
424 adxl362_interface_debug_print("adxl362: set inactivity failed.\n");
425 (void)adxl362_deinit(&gs_handle);
426
427 return 1;
428 }
429
430 /* disable activity */
431 res = adxl362_set_activity(&gs_handle, ADXL362_BOOL_FALSE);
432 if (res != 0)
433 {
434 adxl362_interface_debug_print("adxl362: set activity failed.\n");
435 (void)adxl362_deinit(&gs_handle);
436
437 return 1;
438 }
439
440 /* disable self test */
441 res = adxl362_set_self_test(&gs_handle, ADXL362_BOOL_FALSE);
442 if (res != 0)
443 {
444 adxl362_interface_debug_print("adxl362: set self test failed.\n");
445 (void)adxl362_deinit(&gs_handle);
446
447 return 1;
448 }
449
450 /* set 12.5Hz */
451 res = adxl362_set_odr(&gs_handle, ADXL362_ODR_12P5HZ);
452 if (res != 0)
453 {
454 adxl362_interface_debug_print("adxl362: set odr failed.\n");
455 (void)adxl362_deinit(&gs_handle);
456
457 return 1;
458 }
459
460 /* set 2g */
461 res = adxl362_set_range(&gs_handle, ADXL362_RANGE_2G);
462 if (res != 0)
463 {
464 adxl362_interface_debug_print("adxl362: set range failed.\n");
465 (void)adxl362_deinit(&gs_handle);
466
467 return 1;
468 }
469
470 /* start measurement */
472 if (res != 0)
473 {
474 adxl362_interface_debug_print("adxl362: set mode failed.\n");
475 (void)adxl362_deinit(&gs_handle);
476
477 return 1;
478 }
479
480 /* 2g range */
481 adxl362_interface_debug_print("adxl362: 2g range test.\n");
482
483 /* loop */
484 for (i = 0; i < times; i++)
485 {
486 int8_t raw_short[3];
487 int16_t raw[3];
488 float g[3];
489
490 /* delay 1000ms */
492
493 /* read */
494 res = adxl362_read(&gs_handle, raw, g);
495 if (res != 0)
496 {
497 adxl362_interface_debug_print("adxl362: read failed.\n");
498 (void)adxl362_deinit(&gs_handle);
499
500 return 1;
501 }
502
503 /* output */
504 adxl362_interface_debug_print("adxl362: x is %0.2fg.\n", g[0]);
505 adxl362_interface_debug_print("adxl362: y is %0.2fg.\n", g[1]);
506 adxl362_interface_debug_print("adxl362: z is %0.2fg.\n", g[2]);
507
508 /* read 8msb */
509 res = adxl362_read_8msb(&gs_handle, raw_short, g);
510 if (res != 0)
511 {
512 adxl362_interface_debug_print("adxl362: read 8msb failed.\n");
513 (void)adxl362_deinit(&gs_handle);
514
515 return 1;
516 }
517
518 /* output */
519 adxl362_interface_debug_print("adxl362: x 8msb is %0.2fg.\n", g[0]);
520 adxl362_interface_debug_print("adxl362: y 8msb is %0.2fg.\n", g[1]);
521 adxl362_interface_debug_print("adxl362: z 8msb is %0.2fg.\n", g[2]);
522 }
523
524 /* delay 1000ms */
526
527 /* set 4g */
528 res = adxl362_set_range(&gs_handle, ADXL362_RANGE_4G);
529 if (res != 0)
530 {
531 adxl362_interface_debug_print("adxl362: set range failed.\n");
532 (void)adxl362_deinit(&gs_handle);
533
534 return 1;
535 }
536
537 /* 4g range */
538 adxl362_interface_debug_print("adxl362: 4g range test.\n");
539
540 /* loop */
541 for (i = 0; i < times; i++)
542 {
543 int8_t raw_short[3];
544 int16_t raw[3];
545 float g[3];
546
547 /* delay 1000ms */
549
550 /* read */
551 res = adxl362_read(&gs_handle, raw, g);
552 if (res != 0)
553 {
554 adxl362_interface_debug_print("adxl362: read failed.\n");
555 (void)adxl362_deinit(&gs_handle);
556
557 return 1;
558 }
559
560 /* output */
561 adxl362_interface_debug_print("adxl362: x is %0.2fg.\n", g[0]);
562 adxl362_interface_debug_print("adxl362: y is %0.2fg.\n", g[1]);
563 adxl362_interface_debug_print("adxl362: z is %0.2fg.\n", g[2]);
564
565 /* read 8msb */
566 res = adxl362_read_8msb(&gs_handle, raw_short, g);
567 if (res != 0)
568 {
569 adxl362_interface_debug_print("adxl362: read 8msb failed.\n");
570 (void)adxl362_deinit(&gs_handle);
571
572 return 1;
573 }
574
575 /* output */
576 adxl362_interface_debug_print("adxl362: x 8msb is %0.2fg.\n", g[0]);
577 adxl362_interface_debug_print("adxl362: y 8msb is %0.2fg.\n", g[1]);
578 adxl362_interface_debug_print("adxl362: z 8msb is %0.2fg.\n", g[2]);
579 }
580
581 /* delay 1000ms */
583
584 /* set 8g */
585 res = adxl362_set_range(&gs_handle, ADXL362_RANGE_8G);
586 if (res != 0)
587 {
588 adxl362_interface_debug_print("adxl362: set range failed.\n");
589 (void)adxl362_deinit(&gs_handle);
590
591 return 1;
592 }
593
594 /* 8g range */
595 adxl362_interface_debug_print("adxl362: 8g range test.\n");
596
597 /* loop */
598 for (i = 0; i < times; i++)
599 {
600 int8_t raw_short[3];
601 int16_t raw[3];
602 float g[3];
603
604 /* delay 1000ms */
606
607 /* read */
608 res = adxl362_read(&gs_handle, raw, g);
609 if (res != 0)
610 {
611 adxl362_interface_debug_print("adxl362: read failed.\n");
612 (void)adxl362_deinit(&gs_handle);
613
614 return 1;
615 }
616
617 /* output */
618 adxl362_interface_debug_print("adxl362: x is %0.2fg.\n", g[0]);
619 adxl362_interface_debug_print("adxl362: y is %0.2fg.\n", g[1]);
620 adxl362_interface_debug_print("adxl362: z is %0.2fg.\n", g[2]);
621
622 /* read 8msb */
623 res = adxl362_read_8msb(&gs_handle, raw_short, g);
624 if (res != 0)
625 {
626 adxl362_interface_debug_print("adxl362: read 8msb failed.\n");
627 (void)adxl362_deinit(&gs_handle);
628
629 return 1;
630 }
631
632 /* output */
633 adxl362_interface_debug_print("adxl362: x 8msb is %0.2fg.\n", g[0]);
634 adxl362_interface_debug_print("adxl362: y 8msb is %0.2fg.\n", g[1]);
635 adxl362_interface_debug_print("adxl362: z 8msb is %0.2fg.\n", g[2]);
636 }
637
638 /* delay 1000ms */
640
641 /* read temperature test */
642 adxl362_interface_debug_print("adxl362: read temperature test.\n");
643
644 /* loop */
645 for (i = 0; i < times; i++)
646 {
647 int16_t raw;
648 float temp;
649
650 /* read temperature */
651 res = adxl362_read_temperature(&gs_handle, &raw, &temp);
652 if (res != 0)
653 {
654 adxl362_interface_debug_print("adxl362: read temperature failed.\n");
655 (void)adxl362_deinit(&gs_handle);
656
657 return 1;
658 }
659
660 /* delay 1000ms */
662
663 /* output */
664 adxl362_interface_debug_print("adxl362: temperature is %0.2fC.\n", temp);
665 }
666
667 /* delay 1000ms */
669
670 /* set 12.5Hz */
671 res = adxl362_set_odr(&gs_handle, ADXL362_ODR_12P5HZ);
672 if (res != 0)
673 {
674 adxl362_interface_debug_print("adxl362: set odr failed.\n");
675 (void)adxl362_deinit(&gs_handle);
676
677 return 1;
678 }
679
680 /* 12.5 Hz */
681 adxl362_interface_debug_print("adxl362: 12.5 Hz output rate test.\n");
682
683 /* loop */
684 for (i = 0; i < times; i++)
685 {
686 int8_t raw_short[3];
687 int16_t raw[3];
688 float g[3];
689
690 /* delay 1000ms */
692
693 /* read */
694 res = adxl362_read(&gs_handle, raw, g);
695 if (res != 0)
696 {
697 adxl362_interface_debug_print("adxl362: read failed.\n");
698 (void)adxl362_deinit(&gs_handle);
699
700 return 1;
701 }
702
703 /* output */
704 adxl362_interface_debug_print("adxl362: x is %0.2fg.\n", g[0]);
705 adxl362_interface_debug_print("adxl362: y is %0.2fg.\n", g[1]);
706 adxl362_interface_debug_print("adxl362: z is %0.2fg.\n", g[2]);
707
708 /* read 8msb */
709 res = adxl362_read_8msb(&gs_handle, raw_short, g);
710 if (res != 0)
711 {
712 adxl362_interface_debug_print("adxl362: read 8msb failed.\n");
713 (void)adxl362_deinit(&gs_handle);
714
715 return 1;
716 }
717
718 /* output */
719 adxl362_interface_debug_print("adxl362: x 8msb is %0.2fg.\n", g[0]);
720 adxl362_interface_debug_print("adxl362: y 8msb is %0.2fg.\n", g[1]);
721 adxl362_interface_debug_print("adxl362: z 8msb is %0.2fg.\n", g[2]);
722 }
723
724 /* delay 1000ms */
726
727 /* set 25Hz */
728 res = adxl362_set_odr(&gs_handle, ADXL362_ODR_25HZ);
729 if (res != 0)
730 {
731 adxl362_interface_debug_print("adxl362: set odr failed.\n");
732 (void)adxl362_deinit(&gs_handle);
733
734 return 1;
735 }
736
737 /* 25Hz */
738 adxl362_interface_debug_print("adxl362: 25Hz output rate test.\n");
739
740 /* loop */
741 for (i = 0; i < times; i++)
742 {
743 int8_t raw_short[3];
744 int16_t raw[3];
745 float g[3];
746
747 /* delay 1000ms */
749
750 /* read */
751 res = adxl362_read(&gs_handle, raw, g);
752 if (res != 0)
753 {
754 adxl362_interface_debug_print("adxl362: read failed.\n");
755 (void)adxl362_deinit(&gs_handle);
756
757 return 1;
758 }
759
760 /* output */
761 adxl362_interface_debug_print("adxl362: x is %0.2fg.\n", g[0]);
762 adxl362_interface_debug_print("adxl362: y is %0.2fg.\n", g[1]);
763 adxl362_interface_debug_print("adxl362: z is %0.2fg.\n", g[2]);
764
765 /* read 8msb */
766 res = adxl362_read_8msb(&gs_handle, raw_short, g);
767 if (res != 0)
768 {
769 adxl362_interface_debug_print("adxl362: read 8msb failed.\n");
770 (void)adxl362_deinit(&gs_handle);
771
772 return 1;
773 }
774
775 /* output */
776 adxl362_interface_debug_print("adxl362: x 8msb is %0.2fg.\n", g[0]);
777 adxl362_interface_debug_print("adxl362: y 8msb is %0.2fg.\n", g[1]);
778 adxl362_interface_debug_print("adxl362: z 8msb is %0.2fg.\n", g[2]);
779 }
780
781 /* delay 1000ms */
783
784 /* set 50Hz */
785 res = adxl362_set_odr(&gs_handle, ADXL362_ODR_50HZ);
786 if (res != 0)
787 {
788 adxl362_interface_debug_print("adxl362: set odr failed.\n");
789 (void)adxl362_deinit(&gs_handle);
790
791 return 1;
792 }
793
794 /* 50Hz */
795 adxl362_interface_debug_print("adxl362: 50Hz output rate test.\n");
796
797 /* loop */
798 for (i = 0; i < times; i++)
799 {
800 int8_t raw_short[3];
801 int16_t raw[3];
802 float g[3];
803
804 /* delay 1000ms */
806
807 /* read */
808 res = adxl362_read(&gs_handle, raw, g);
809 if (res != 0)
810 {
811 adxl362_interface_debug_print("adxl362: read failed.\n");
812 (void)adxl362_deinit(&gs_handle);
813
814 return 1;
815 }
816
817 /* output */
818 adxl362_interface_debug_print("adxl362: x is %0.2fg.\n", g[0]);
819 adxl362_interface_debug_print("adxl362: y is %0.2fg.\n", g[1]);
820 adxl362_interface_debug_print("adxl362: z is %0.2fg.\n", g[2]);
821
822 /* read 8msb */
823 res = adxl362_read_8msb(&gs_handle, raw_short, g);
824 if (res != 0)
825 {
826 adxl362_interface_debug_print("adxl362: read 8msb failed.\n");
827 (void)adxl362_deinit(&gs_handle);
828
829 return 1;
830 }
831
832 /* output */
833 adxl362_interface_debug_print("adxl362: x 8msb is %0.2fg.\n", g[0]);
834 adxl362_interface_debug_print("adxl362: y 8msb is %0.2fg.\n", g[1]);
835 adxl362_interface_debug_print("adxl362: z 8msb is %0.2fg.\n", g[2]);
836 }
837
838 /* delay 1000ms */
840
841 /* set 100Hz */
842 res = adxl362_set_odr(&gs_handle, ADXL362_ODR_100HZ);
843 if (res != 0)
844 {
845 adxl362_interface_debug_print("adxl362: set odr failed.\n");
846 (void)adxl362_deinit(&gs_handle);
847
848 return 1;
849 }
850
851 /* 100Hz */
852 adxl362_interface_debug_print("adxl362: 100Hz output rate test.\n");
853
854 /* loop */
855 for (i = 0; i < times; i++)
856 {
857 int8_t raw_short[3];
858 int16_t raw[3];
859 float g[3];
860
861 /* delay 1000ms */
863
864 /* read */
865 res = adxl362_read(&gs_handle, raw, g);
866 if (res != 0)
867 {
868 adxl362_interface_debug_print("adxl362: read failed.\n");
869 (void)adxl362_deinit(&gs_handle);
870
871 return 1;
872 }
873
874 /* output */
875 adxl362_interface_debug_print("adxl362: x is %0.2fg.\n", g[0]);
876 adxl362_interface_debug_print("adxl362: y is %0.2fg.\n", g[1]);
877 adxl362_interface_debug_print("adxl362: z is %0.2fg.\n", g[2]);
878
879 /* read 8msb */
880 res = adxl362_read_8msb(&gs_handle, raw_short, g);
881 if (res != 0)
882 {
883 adxl362_interface_debug_print("adxl362: read 8msb failed.\n");
884 (void)adxl362_deinit(&gs_handle);
885
886 return 1;
887 }
888
889 /* output */
890 adxl362_interface_debug_print("adxl362: x 8msb is %0.2fg.\n", g[0]);
891 adxl362_interface_debug_print("adxl362: y 8msb is %0.2fg.\n", g[1]);
892 adxl362_interface_debug_print("adxl362: z 8msb is %0.2fg.\n", g[2]);
893 }
894
895 /* delay 1000ms */
897
898 /* set 200Hz */
899 res = adxl362_set_odr(&gs_handle, ADXL362_ODR_200HZ);
900 if (res != 0)
901 {
902 adxl362_interface_debug_print("adxl362: set odr failed.\n");
903 (void)adxl362_deinit(&gs_handle);
904
905 return 1;
906 }
907
908 /* 200Hz */
909 adxl362_interface_debug_print("adxl362: 200Hz output rate test.\n");
910
911 /* loop */
912 for (i = 0; i < times; i++)
913 {
914 int8_t raw_short[3];
915 int16_t raw[3];
916 float g[3];
917
918 /* delay 1000ms */
920
921 /* read */
922 res = adxl362_read(&gs_handle, raw, g);
923 if (res != 0)
924 {
925 adxl362_interface_debug_print("adxl362: read failed.\n");
926 (void)adxl362_deinit(&gs_handle);
927
928 return 1;
929 }
930
931 /* output */
932 adxl362_interface_debug_print("adxl362: x is %0.2fg.\n", g[0]);
933 adxl362_interface_debug_print("adxl362: y is %0.2fg.\n", g[1]);
934 adxl362_interface_debug_print("adxl362: z is %0.2fg.\n", g[2]);
935
936 /* read 8msb */
937 res = adxl362_read_8msb(&gs_handle, raw_short, g);
938 if (res != 0)
939 {
940 adxl362_interface_debug_print("adxl362: read 8msb failed.\n");
941 (void)adxl362_deinit(&gs_handle);
942
943 return 1;
944 }
945
946 /* output */
947 adxl362_interface_debug_print("adxl362: x 8msb is %0.2fg.\n", g[0]);
948 adxl362_interface_debug_print("adxl362: y 8msb is %0.2fg.\n", g[1]);
949 adxl362_interface_debug_print("adxl362: z 8msb is %0.2fg.\n", g[2]);
950 }
951
952 /* delay 1000ms */
954
955 /* set 400Hz */
956 res = adxl362_set_odr(&gs_handle, ADXL362_ODR_400HZ);
957 if (res != 0)
958 {
959 adxl362_interface_debug_print("adxl362: set odr failed.\n");
960 (void)adxl362_deinit(&gs_handle);
961
962 return 1;
963 }
964
965 /* 400Hz */
966 adxl362_interface_debug_print("adxl362: 400Hz output rate test.\n");
967
968 /* loop */
969 for (i = 0; i < times; i++)
970 {
971 int8_t raw_short[3];
972 int16_t raw[3];
973 float g[3];
974
975 /* delay 1000ms */
977
978 /* read */
979 res = adxl362_read(&gs_handle, raw, g);
980 if (res != 0)
981 {
982 adxl362_interface_debug_print("adxl362: read failed.\n");
983 (void)adxl362_deinit(&gs_handle);
984
985 return 1;
986 }
987
988 /* output */
989 adxl362_interface_debug_print("adxl362: x is %0.2fg.\n", g[0]);
990 adxl362_interface_debug_print("adxl362: y is %0.2fg.\n", g[1]);
991 adxl362_interface_debug_print("adxl362: z is %0.2fg.\n", g[2]);
992
993 /* read 8msb */
994 res = adxl362_read_8msb(&gs_handle, raw_short, g);
995 if (res != 0)
996 {
997 adxl362_interface_debug_print("adxl362: read 8msb failed.\n");
998 (void)adxl362_deinit(&gs_handle);
999
1000 return 1;
1001 }
1002
1003 /* output */
1004 adxl362_interface_debug_print("adxl362: x 8msb is %0.2fg.\n", g[0]);
1005 adxl362_interface_debug_print("adxl362: y 8msb is %0.2fg.\n", g[1]);
1006 adxl362_interface_debug_print("adxl362: z 8msb is %0.2fg.\n", g[2]);
1007 }
1008
1009 /* finish read test */
1010 adxl362_interface_debug_print("adxl362: finish read test.\n");
1011 (void)adxl362_deinit(&gs_handle);
1012
1013 return 0;
1014}
driver adxl362 read test header file
uint8_t adxl362_set_range(adxl362_handle_t *handle, adxl362_range_t range)
set the measurement range
uint8_t adxl362_read_8msb(adxl362_handle_t *handle, int8_t raw[3], float g[3])
read the data with eight most significant bits
uint8_t adxl362_set_interrupt_pin2_map(adxl362_handle_t *handle, adxl362_interrupt_map_t map, adxl362_bool_t enable)
set the interrupt pin2 map
uint8_t adxl362_set_inactivity_detect_trigger(adxl362_handle_t *handle, adxl362_detect_trigger_t trigger)
set the inactivity detect trigger mode
uint8_t adxl362_set_fifo_sample(adxl362_handle_t *handle, uint16_t sample)
set the fifo sample
uint8_t adxl362_set_inactivity_time(adxl362_handle_t *handle, uint16_t tim)
set the inactivity time
struct adxl362_info_s adxl362_info_t
adxl362 information structure definition
uint8_t adxl362_set_fifo_mode(adxl362_handle_t *handle, adxl362_fifo_mode_t mode)
set the fifo mode
uint8_t adxl362_info(adxl362_info_t *info)
get chip's information
uint8_t adxl362_set_self_test(adxl362_handle_t *handle, adxl362_bool_t enable)
enable or disable the self test
uint8_t adxl362_init(adxl362_handle_t *handle)
initialize the chip
uint8_t adxl362_set_detect_mode(adxl362_handle_t *handle, adxl362_detect_mode_t mode)
set the detect mode
uint8_t adxl362_set_interrupt_pin2_active_level(adxl362_handle_t *handle, adxl362_interrupt_pin_level_t level)
set the interrupt pin2 active level
struct adxl362_handle_s adxl362_handle_t
adxl362 handle structure definition
uint8_t adxl362_set_wake_up(adxl362_handle_t *handle, adxl362_bool_t enable)
enable or disable chip wake up
uint8_t adxl362_set_inactivity_threshold(adxl362_handle_t *handle, uint16_t threshold)
set the inactivity threshold
uint8_t adxl362_read(adxl362_handle_t *handle, int16_t raw[3], float g[3])
read the data
uint8_t adxl362_set_interrupt_pin1_map(adxl362_handle_t *handle, adxl362_interrupt_map_t map, adxl362_bool_t enable)
set the interrupt pin1 map
uint8_t adxl362_set_noise_mode(adxl362_handle_t *handle, adxl362_noise_mode_t mode)
set the noise mode
uint8_t adxl362_set_activity_threshold(adxl362_handle_t *handle, uint16_t threshold)
set the activity threshold
uint8_t adxl362_set_activity_time(adxl362_handle_t *handle, uint8_t tim)
set the activity time
uint8_t adxl362_set_interrupt_pin1_active_level(adxl362_handle_t *handle, adxl362_interrupt_pin_level_t level)
set the interrupt pin1 active level
uint8_t adxl362_set_fifo_temperature(adxl362_handle_t *handle, adxl362_bool_t enable)
enable or disable saving temperature data to fifo
uint8_t adxl362_set_activity_detect_trigger(adxl362_handle_t *handle, adxl362_detect_trigger_t trigger)
set the activity detect trigger mode
uint8_t adxl362_set_interrupt_pin1_as_external_clock(adxl362_handle_t *handle, adxl362_bool_t enable)
enable or disable interrupt pin1 as the external clock
uint8_t adxl362_set_mode(adxl362_handle_t *handle, adxl362_mode_t mode)
set the chip mode
uint8_t adxl362_set_inactivity(adxl362_handle_t *handle, adxl362_bool_t enable)
enable or disable inactivity
uint8_t adxl362_set_interrupt_pin2_as_external_sampling_trigger(adxl362_handle_t *handle, adxl362_bool_t enable)
enable or disable interrupt pin2 as the external sampling trigger
uint8_t adxl362_set_activity(adxl362_handle_t *handle, adxl362_bool_t enable)
enable or disable activity
uint8_t adxl362_set_auto_sleep(adxl362_handle_t *handle, adxl362_bool_t enable)
enable or disable auto sleep
uint8_t adxl362_read_temperature(adxl362_handle_t *handle, int16_t *raw, float *temp)
read the temperature
uint8_t adxl362_set_bandwidth(adxl362_handle_t *handle, adxl362_bandwidth_t bandwidth)
set the filter bandwidth
uint8_t adxl362_deinit(adxl362_handle_t *handle)
close the chip
uint8_t adxl362_set_odr(adxl362_handle_t *handle, adxl362_odr_t odr)
set the output data rate
@ ADXL362_DETECT_MODE_LINK
@ ADXL362_FIFO_MODE_DISABLE
@ ADXL362_BANDWIDTH_ODR_DIV_2
@ ADXL362_ODR_50HZ
@ ADXL362_ODR_12P5HZ
@ ADXL362_ODR_25HZ
@ ADXL362_ODR_200HZ
@ ADXL362_ODR_100HZ
@ ADXL362_ODR_400HZ
@ ADXL362_INTERRUPT_MAP_FIFO_READY
@ ADXL362_INTERRUPT_MAP_ACT
@ ADXL362_INTERRUPT_MAP_FIFO_OVERRUN
@ ADXL362_INTERRUPT_MAP_FIFO_WATERMARK
@ ADXL362_INTERRUPT_MAP_DATA_READY
@ ADXL362_INTERRUPT_MAP_AWAKE
@ ADXL362_INTERRUPT_MAP_INACT
@ ADXL362_MODE_MEASUREMENT
@ ADXL362_NOISE_MODE_NORMAL
@ ADXL362_BOOL_FALSE
@ ADXL362_RANGE_4G
@ ADXL362_RANGE_8G
@ ADXL362_RANGE_2G
@ ADXL362_DETECT_TRIGGER_REFERENCED
@ ADXL362_INTERRUPT_PIN_LOW
uint8_t adxl362_interface_spi_read(uint8_t reg, uint8_t *buf, uint16_t len)
interface spi bus read
uint8_t adxl362_interface_spi_deinit(void)
interface spi bus deinit
uint8_t adxl362_interface_spi_init(void)
interface spi bus init
void adxl362_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t adxl362_interface_spi_write_address16(uint16_t addr, uint8_t *buf, uint16_t len)
interface spi bus write
void adxl362_interface_debug_print(const char *const fmt,...)
interface print format data
void adxl362_interface_receive_callback(uint8_t type)
interface receive callback
uint8_t adxl362_interface_spi_read_address16(uint16_t addr, uint8_t *buf, uint16_t len)
interface spi bus read
uint8_t adxl362_read_test(uint32_t times)
read test
uint32_t driver_version
char manufacturer_name[32]