LibDriver ADXL345
Loading...
Searching...
No Matches
driver_adxl345_fifo_test.c
Go to the documentation of this file.
1
37
39
40static adxl345_handle_t gs_handle;
41static uint8_t gs_watermark_flag;
42static int16_t gs_raw_test[20][3];
43static float gs_test[20][3];
44
53{
54 if (adxl345_irq_handler(&gs_handle) != 0)
55 {
56 return 1;
57 }
58 else
59 {
60 return 0;
61 }
62}
63
69static void a_adxl345_interface_test_receive_callback(uint8_t type)
70{
71 switch (type)
72 {
74 {
75 break;
76 }
78 {
79 uint16_t len;
80
81 len = 20;
82 if (adxl345_read(&gs_handle, (int16_t (*)[3])gs_raw_test, (float (*)[3])gs_test, (uint16_t *)&len) != 0)
83 {
84 adxl345_interface_debug_print("adxl345: read failed.\n");
85
86 return;
87 }
88 else
89 {
90 gs_watermark_flag++;
91 if (gs_watermark_flag > 2)
92 {
93 if (adxl345_set_measure(&gs_handle, ADXL345_BOOL_FALSE) != 0)
94 {
95 adxl345_interface_debug_print("adxl345: set measure failed.\n");
96
97 return;
98 }
99 }
100 }
101 adxl345_interface_debug_print("adxl345: irq water mark with %d.\n", len);
102
103 break;
104 }
106 {
107 break;
108 }
109 default :
110 {
111 break;
112 }
113 }
114}
115
126{
127 uint8_t res;
128 uint8_t timeout;
129 uint8_t source;
130 uint8_t status;
131 int8_t reg;
132 uint16_t len;
133 adxl345_info_t info;
134
135 /* link interface function */
147 DRIVER_ADXL345_LINK_RECEIVE_CALLBACK(&gs_handle, a_adxl345_interface_test_receive_callback);
148
149 /* get information */
150 res = adxl345_info(&info);
151 if (res != 0)
152 {
153 adxl345_interface_debug_print("adxl345: get info failed.\n");
154
155 return 1;
156 }
157 else
158 {
159 /* print chip info */
160 adxl345_interface_debug_print("adxl345: chip is %s.\n", info.chip_name);
161 adxl345_interface_debug_print("adxl345: manufacturer is %s.\n", info.manufacturer_name);
162 adxl345_interface_debug_print("adxl345: interface is %s.\n", info.interface);
163 adxl345_interface_debug_print("adxl345: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
164 adxl345_interface_debug_print("adxl345: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
165 adxl345_interface_debug_print("adxl345: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
166 adxl345_interface_debug_print("adxl345: max current is %0.2fmA.\n", info.max_current_ma);
167 adxl345_interface_debug_print("adxl345: max temperature is %0.1fC.\n", info.temperature_max);
168 adxl345_interface_debug_print("adxl345: min temperature is %0.1fC.\n", info.temperature_min);
169 }
170
171 /* set interface */
172 res = adxl345_set_interface(&gs_handle, interface);
173 if (res != 0)
174 {
175 adxl345_interface_debug_print("adxl345: set interface failed.\n");
176
177 return 1;
178 }
179
180 /* set address pin */
181 res = adxl345_set_addr_pin(&gs_handle, addr_pin);
182 if (res != 0)
183 {
184 adxl345_interface_debug_print("adxl345: set addr pin failed.\n");
185
186 return 1;
187 }
188
189 /* adxl345 initialization */
190 res = adxl345_init(&gs_handle);
191 if (res != 0)
192 {
193 adxl345_interface_debug_print("adxl345: init failed.\n");
194
195 return 1;
196 }
197
198 /* set 12.5Hz rate */
199 res = adxl345_set_rate(&gs_handle, ADXL345_RATE_12P5);
200 if (res != 0)
201 {
202 adxl345_interface_debug_print("adxl345: set rate failed.\n");
203 (void)adxl345_deinit(&gs_handle);
204
205 return 1;
206 }
207
208 /* set 4 wire */
209 res = adxl345_set_spi_wire(&gs_handle, ADXL345_SPI_WIRE_4);
210 if (res != 0)
211 {
212 adxl345_interface_debug_print("adxl345: set spi wire failed.\n");
213 (void)adxl345_deinit(&gs_handle);
214
215 return 1;
216 }
217
218 /* set interrupt low */
220 if (res != 0)
221 {
222 adxl345_interface_debug_print("adxl345: set interrupt active level failed.\n");
223 (void)adxl345_deinit(&gs_handle);
224
225 return 1;
226 }
227
228 /* set full resolution */
230 if (res != 0)
231 {
232 adxl345_interface_debug_print("adxl345: set full resolution failed.\n");
233 (void)adxl345_deinit(&gs_handle);
234
235 return 1;
236 }
237
238 /* disable auto sleep */
240 if (res != 0)
241 {
242 adxl345_interface_debug_print("adxl345: set auto sleep failed.\n");
243 (void)adxl345_deinit(&gs_handle);
244
245 return 1;
246 }
247
248 /* disable sleep */
249 res = adxl345_set_sleep(&gs_handle, ADXL345_BOOL_FALSE);
250 if (res != 0)
251 {
252 adxl345_interface_debug_print("adxl345: set sleep failed.\n");
253 (void)adxl345_deinit(&gs_handle);
254
255 return 1;
256 }
257
258 /* set sleep 1Hz */
260 if (res != 0)
261 {
262 adxl345_interface_debug_print("adxl345: set sleep frequency failed.\n");
263 (void)adxl345_deinit(&gs_handle);
264
265 return 1;
266 }
267
268 /* set justify right */
270 if (res != 0)
271 {
272 adxl345_interface_debug_print("adxl345: set justify failed.\n");
273 (void)adxl345_deinit(&gs_handle);
274
275 return 1;
276 }
277
278 /* set range 16g */
279 res = adxl345_set_range(&gs_handle, ADXL345_RANGE_16G);
280 if (res != 0)
281 {
282 adxl345_interface_debug_print("adxl345: set range failed.\n");
283 (void)adxl345_deinit(&gs_handle);
284
285 return 1;
286 }
287
288 /* set fifo mode */
289 res = adxl345_set_mode(&gs_handle, ADXL345_MODE_FIFO);
290 if (res != 0)
291 {
292 adxl345_interface_debug_print("adxl345: set mode failed.\n");
293 (void)adxl345_deinit(&gs_handle);
294
295 return 1;
296 }
297
298 /* set trigger pin int 2 */
300 if (res != 0)
301 {
302 adxl345_interface_debug_print("adxl345: set trigger pin failed.\n");
303 (void)adxl345_deinit(&gs_handle);
304
305 return 1;
306 }
307
308 /* set watermark 16 level */
309 res = adxl345_set_watermark(&gs_handle, 16);
310 if (res != 0)
311 {
312 adxl345_interface_debug_print("adxl345: set watermark failed.\n");
313 (void)adxl345_deinit(&gs_handle);
314
315 return 1;
316 }
317
318 /* set offset */
319 res = adxl345_offset_convert_to_register(&gs_handle, 0.0f, (int8_t *)&reg);
320 if (res != 0)
321 {
322 adxl345_interface_debug_print("adxl345: offset convert to register failed.\n");
323 (void)adxl345_deinit(&gs_handle);
324
325 return 1;
326 }
327 res = adxl345_set_offset(&gs_handle, reg, reg, reg);
328 if (res != 0)
329 {
330 adxl345_interface_debug_print("adxl345: set offset failed.\n");
331 (void)adxl345_deinit(&gs_handle);
332
333 return 1;
334 }
335
336 /* set tap 3g */
337 res = adxl345_tap_threshold_convert_to_register(&gs_handle, 3.0f, (uint8_t *)&reg);
338 if (res != 0)
339 {
340 adxl345_interface_debug_print("adxl345: tap threshold convert to register failed.\n");
341 (void)adxl345_deinit(&gs_handle);
342
343 return 1;
344 }
345
346 /* set tap threshold */
347 res = adxl345_set_tap_threshold(&gs_handle, reg);
348 if (res != 0)
349 {
350 adxl345_interface_debug_print("adxl345: set tap threshold failed.\n");
351 (void)adxl345_deinit(&gs_handle);
352
353 return 1;
354 }
355
356 /* set 10 ms */
357 res = adxl345_duration_convert_to_register(&gs_handle, 10 * 1000, (uint8_t *)&reg);
358 if (res != 0)
359 {
360 adxl345_interface_debug_print("adxl345: duration convert to register failed.\n");
361 (void)adxl345_deinit(&gs_handle);
362
363 return 1;
364 }
365 res = adxl345_set_duration(&gs_handle, reg);
366 if (res != 0)
367 {
368 adxl345_interface_debug_print("adxl345: set duration failed.\n");
369 (void)adxl345_deinit(&gs_handle);
370
371 return 1;
372 }
373
374 /* set 20 ms latent */
375 res = adxl345_latent_convert_to_register(&gs_handle, 20.0f, (uint8_t *)&reg);
376 if (res != 0)
377 {
378 adxl345_interface_debug_print("adxl345: latent convert to register failed.\n");
379 (void)adxl345_deinit(&gs_handle);
380
381 return 1;
382 }
383 res = adxl345_set_latent(&gs_handle, reg);
384 if (res != 0)
385 {
386 adxl345_interface_debug_print("adxl345: set latent failed.\n");
387 (void)adxl345_deinit(&gs_handle);
388
389 return 1;
390 }
391
392 /* set 80ms window */
393 res = adxl345_window_convert_to_register(&gs_handle, 80.0f, (uint8_t *)&reg);
394 if (res != 0)
395 {
396 adxl345_interface_debug_print("adxl345: window convert to register failed.\n");
397 (void)adxl345_deinit(&gs_handle);
398
399 return 1;
400 }
401
402 /* set window */
403 res = adxl345_set_window(&gs_handle, reg);
404 if (res != 0)
405 {
406 adxl345_interface_debug_print("adxl345: set window failed.\n");
407 (void)adxl345_deinit(&gs_handle);
408
409 return 1;
410 }
411
412 /* set x axis */
414 if (res != 0)
415 {
416 adxl345_interface_debug_print("adxl345: set tap axis failed.\n");
417 (void)adxl345_deinit(&gs_handle);
418
419 return 1;
420 }
421
422 /* set y axis */
424 if (res != 0)
425 {
426 adxl345_interface_debug_print("adxl345: set tap axis failed.\n");
427 (void)adxl345_deinit(&gs_handle);
428
429 return 1;
430 }
431
432 /* set z axis */
434 if (res != 0)
435 {
436 adxl345_interface_debug_print("adxl345: set tap axis failed.\n");
437 (void)adxl345_deinit(&gs_handle);
438
439 return 1;
440 }
441
442 /* disable suppress */
444 if (res != 0)
445 {
446 adxl345_interface_debug_print("adxl345: set tap suppress failed.\n");
447 (void)adxl345_deinit(&gs_handle);
448
449 return 1;
450 }
451
452 /* map int 1 */
454 if (res != 0)
455 {
456 adxl345_interface_debug_print("adxl345: set interrupt map failed.\n");
457 (void)adxl345_deinit(&gs_handle);
458
459 return 1;
460 }
461
462 /* set single tap */
464 if (res != 0)
465 {
466 adxl345_interface_debug_print("adxl345: set interrupt failed.\n");
467 (void)adxl345_deinit(&gs_handle);
468
469 return 1;
470 }
471
472 /* map int 1 */
474 if (res != 0)
475 {
476 adxl345_interface_debug_print("adxl345: set interrupt map failed.\n");
477 (void)adxl345_deinit(&gs_handle);
478
479 return 1;
480 }
481
482 /* set double tap */
484 if (res != 0)
485 {
486 adxl345_interface_debug_print("adxl345: set interrupt failed.\n");
487 (void)adxl345_deinit(&gs_handle);
488
489 return 1;
490 }
491
492 /* link activity and inactivity */
494 if (res != 0)
495 {
496 adxl345_interface_debug_print("adxl345: set link activity inactivity failed.\n");
497 (void)adxl345_deinit(&gs_handle);
498
499 return 1;
500 }
501
502 /* set action threshold */
503 res = adxl345_action_threshold_convert_to_register(&gs_handle, 2.0f, (uint8_t *)&reg);
504 if (res != 0)
505 {
506 adxl345_interface_debug_print("adxl345: action threshold convert to register failed.\n");
507 (void)adxl345_deinit(&gs_handle);
508
509 return 1;
510 }
511 res = adxl345_set_action_threshold(&gs_handle, reg);
512 if (res != 0)
513 {
514 adxl345_interface_debug_print("adxl345: set action threshold failed.\n");
515 (void)adxl345_deinit(&gs_handle);
516
517 return 1;
518 }
519
520 /* set inaction threshold */
521 res = adxl345_inaction_threshold_convert_to_register(&gs_handle, 1.0f, (uint8_t *)&reg);
522 if (res != 0)
523 {
524 adxl345_interface_debug_print("adxl345: inaction threshold convert to register failed.\n");
525 (void)adxl345_deinit(&gs_handle);
526
527 return 1;
528 }
529 res = adxl345_set_inaction_threshold(&gs_handle, reg);
530 if (res != 0)
531 {
532 adxl345_interface_debug_print("adxl345: set inaction threshold failed.\n");
533 (void)adxl345_deinit(&gs_handle);
534
535 return 1;
536 }
537
538 /* set inaction time 3s */
539 res = adxl345_inaction_time_convert_to_register(&gs_handle, 3, (uint8_t *)&reg);
540 if (res != 0)
541 {
542 adxl345_interface_debug_print("adxl345: inaction time convert to register failed.\n");
543 (void)adxl345_deinit(&gs_handle);
544
545 return 1;
546 }
547 res = adxl345_set_inaction_time(&gs_handle, reg);
548 if (res != 0)
549 {
550 adxl345_interface_debug_print("adxl345: set inaction time failed.\n");
551 (void)adxl345_deinit(&gs_handle);
552
553 return 1;
554 }
555
556 /* set linking action inaction x */
558 if (res != 0)
559 {
560 adxl345_interface_debug_print("adxl345: set action inaction failed.\n");
561 (void)adxl345_deinit(&gs_handle);
562
563 return 1;
564 }
565
566 /* set linking action inaction y */
568 if (res != 0)
569 {
570 adxl345_interface_debug_print("adxl345: set action inaction failed.\n");
571 (void)adxl345_deinit(&gs_handle);
572
573 return 1;
574 }
575
576 /* set linking action inaction z */
578 if (res != 0)
579 {
580 adxl345_interface_debug_print("adxl345: set action inaction failed.\n");
581 (void)adxl345_deinit(&gs_handle);
582
583 return 1;
584 }
585
586 /* set linking action inaction x */
588 if (res != 0)
589 {
590 adxl345_interface_debug_print("adxl345: set action inaction failed.\n");
591 (void)adxl345_deinit(&gs_handle);
592
593 return 1;
594 }
595
596 /* set linking action inaction y */
598 if (res != 0)
599 {
600 adxl345_interface_debug_print("adxl345: set action inaction failed.\n");
601 (void)adxl345_deinit(&gs_handle);
602
603 return 1;
604 }
605
606 /* set linking action inaction z */
608 if (res != 0)
609 {
610 adxl345_interface_debug_print("adxl345: set action inaction failed.\n");
611 (void)adxl345_deinit(&gs_handle);
612
613 return 1;
614 }
615
616 /* set action ac coupled */
618 if (res != 0)
619 {
620 adxl345_interface_debug_print("adxl345: set action coupled failed.\n");
621 (void)adxl345_deinit(&gs_handle);
622
623 return 1;
624 }
625
626 /* set inaction dc coupled */
628 if (res != 0)
629 {
630 adxl345_interface_debug_print("adxl345: set inaction coupled failed.\n");
631 (void)adxl345_deinit(&gs_handle);
632
633 return 1;
634 }
635
636 /* map int 1 */
638 if (res != 0)
639 {
640 adxl345_interface_debug_print("adxl345: set interrupt map failed.\n");
641 (void)adxl345_deinit(&gs_handle);
642
643 return 1;
644 }
645
646 /* set activity interrupt */
648 if (res != 0)
649 {
650 adxl345_interface_debug_print("adxl345: set interrupt failed.\n");
651 (void)adxl345_deinit(&gs_handle);
652
653 return 1;
654 }
655
656 /* set map int 1 */
658 if (res != 0)
659 {
660 adxl345_interface_debug_print("adxl345: set interrupt map failed.\n");
661 (void)adxl345_deinit(&gs_handle);
662
663 return 1;
664 }
665
666 /* set inactivity interrupt */
668 if (res != 0)
669 {
670 adxl345_interface_debug_print("adxl345: set interrupt failed.\n");
671 (void)adxl345_deinit(&gs_handle);
672
673 return 1;
674 }
675
676 /* set free fall threshold */
677 res = adxl345_free_fall_threshold_convert_to_register(&gs_handle, 0.8f, (uint8_t *)&reg);
678 if (res != 0)
679 {
680 adxl345_interface_debug_print("adxl345: free fall threshold convert to register failed.\n");
681 (void)adxl345_deinit(&gs_handle);
682
683 return 1;
684 }
685 res = adxl345_set_free_fall_threshold(&gs_handle, reg);
686 if (res != 0)
687 {
688 adxl345_interface_debug_print("adxl345: set free fall threshold failed.\n");
689 (void)adxl345_deinit(&gs_handle);
690
691 return 1;
692 }
693
694 /* set free all time */
695 res = adxl345_free_fall_time_convert_to_register(&gs_handle, 10, (uint8_t *)&reg);
696 if (res != 0)
697 {
698 adxl345_interface_debug_print("adxl345: free fall time convert to register failed.\n");
699 (void)adxl345_deinit(&gs_handle);
700
701 return 1;
702 }
703 res = adxl345_set_free_fall_time(&gs_handle, reg);
704 if (res != 0)
705 {
706 adxl345_interface_debug_print("adxl345: set free fall time failed.\n");
707 (void)adxl345_deinit(&gs_handle);
708
709 return 1;
710 }
711
712 /* set interrupt 1 free fall */
714 if (res != 0)
715 {
716 adxl345_interface_debug_print("adxl345: set interrupt map failed.\n");
717 (void)adxl345_deinit(&gs_handle);
718
719 return 1;
720 }
722 if (res != 0)
723 {
724 adxl345_interface_debug_print("adxl345: set interrupt failed.\n");
725 (void)adxl345_deinit(&gs_handle);
726
727 return 1;
728 }
729
730 /* set interrupt 1 data ready */
732 if (res != 0)
733 {
734 adxl345_interface_debug_print("adxl345: set interrupt map failed.\n");
735 (void)adxl345_deinit(&gs_handle);
736
737 return 1;
738 }
740 if (res != 0)
741 {
742 adxl345_interface_debug_print("adxl345: set interrupt failed.\n");
743 (void)adxl345_deinit(&gs_handle);
744
745 return 1;
746 }
747
748 /* set interrupt 1 watermark */
750 if (res != 0)
751 {
752 adxl345_interface_debug_print("adxl345: set interrupt map failed.\n");
753 (void)adxl345_deinit(&gs_handle);
754
755 return 1;
756 }
758 if (res != 0)
759 {
760 adxl345_interface_debug_print("adxl345: set interrupt failed.\n");
761 (void)adxl345_deinit(&gs_handle);
762
763 return 1;
764 }
765
766 /* set interrupt 1 overrun */
768 if (res != 0)
769 {
770 adxl345_interface_debug_print("adxl345: set interrupt map failed.\n");
771 (void)adxl345_deinit(&gs_handle);
772
773 return 1;
774 }
776 if (res != 0)
777 {
778 adxl345_interface_debug_print("adxl345: set interrupt failed.\n");
779 (void)adxl345_deinit(&gs_handle);
780
781 return 1;
782 }
784
785 /* start fifo test */
786 adxl345_interface_debug_print("adxl345: start fifo test.\n");
787 gs_watermark_flag = 0;
788 timeout = 0;
789
790 /* clear interrupt */
791 res = adxl345_get_interrupt_source(&gs_handle, &source);
792 if (res != 0)
793 {
794 adxl345_interface_debug_print("adxl345: get interrupt source failed.\n");
795 (void)adxl345_deinit(&gs_handle);
796
797 return 1;
798 }
799
800 /* get fifo status */
801 res = adxl345_get_watermark_level(&gs_handle, &status);
802 if (res != 0)
803 {
804 adxl345_interface_debug_print("adxl345: get watermark level failed.\n");
805 (void)adxl345_deinit(&gs_handle);
806
807 return 1;
808 }
809
810 /* start measure */
811 res = adxl345_set_measure(&gs_handle, ADXL345_BOOL_TRUE);
812 if (res != 0)
813 {
814 adxl345_interface_debug_print("adxl345: set measure failed.\n");
815 (void)adxl345_deinit(&gs_handle);
816
817 return 1;
818 }
819
820 /* delay 500ms */
822 len = 20;
823 if (adxl345_read(&gs_handle, (int16_t (*)[3])gs_raw_test, (float (*)[3])gs_test, (uint16_t *)&len) != 0)
824 {
825 adxl345_interface_debug_print("adxl345: read failed.\n");
826 (void)adxl345_deinit(&gs_handle);
827
828 return 1;
829 }
830
831 while (gs_watermark_flag < 3)
832 {
833 timeout++;
834 if (timeout > 10)
835 {
836 adxl345_interface_debug_print("adxl345: fifo test timeout.\n");
837 (void)adxl345_deinit(&gs_handle);
838
839 return 1;
840 }
842 }
843
844 /* finish fifo test */
845 adxl345_interface_debug_print("adxl345: finish fifo test.\n");
846 (void)adxl345_deinit(&gs_handle);
847
848 return 0;
849}
driver adxl345 fifo test header file
adxl345_interface_t
adxl345 interface enumeration definition
uint8_t adxl345_inaction_time_convert_to_register(adxl345_handle_t *handle, uint8_t s, uint8_t *reg)
convert the inaction time to the register raw data
uint8_t adxl345_duration_convert_to_register(adxl345_handle_t *handle, uint32_t us, uint8_t *reg)
convert the duration to the register raw data
struct adxl345_info_s adxl345_info_t
adxl345 information structure definition
uint8_t adxl345_inaction_threshold_convert_to_register(adxl345_handle_t *handle, float g, uint8_t *reg)
convert the inaction threshold to the register raw data
uint8_t adxl345_set_full_resolution(adxl345_handle_t *handle, adxl345_bool_t enable)
enable or disable the full resolution
uint8_t adxl345_set_inaction_time(adxl345_handle_t *handle, uint8_t t)
set the inaction time
uint8_t adxl345_deinit(adxl345_handle_t *handle)
close the chip
uint8_t adxl345_set_inaction_coupled(adxl345_handle_t *handle, adxl345_coupled_t coupled)
set the inaction coupled
uint8_t adxl345_set_spi_wire(adxl345_handle_t *handle, adxl345_spi_wire_t wire)
set the chip spi wire
uint8_t adxl345_set_measure(adxl345_handle_t *handle, adxl345_bool_t enable)
enable or disable the measure
uint8_t adxl345_set_trigger_pin(adxl345_handle_t *handle, adxl345_interrupt_pin_t pin)
set the trigger pin
uint8_t adxl345_irq_handler(adxl345_handle_t *handle)
irq handler
uint8_t adxl345_set_link_activity_inactivity(adxl345_handle_t *handle, adxl345_bool_t enable)
enable or disable the activity and inactivity linking
uint8_t adxl345_set_action_threshold(adxl345_handle_t *handle, uint8_t threshold)
set the action threshold
uint8_t adxl345_set_free_fall_threshold(adxl345_handle_t *handle, uint8_t threshold)
set the free fall threshold
uint8_t adxl345_set_sleep(adxl345_handle_t *handle, adxl345_bool_t enable)
enable or disable the sleep mode
uint8_t adxl345_read(adxl345_handle_t *handle, int16_t(*raw)[3], float(*g)[3], uint16_t *len)
read the data
uint8_t adxl345_set_offset(adxl345_handle_t *handle, int8_t x, int8_t y, int8_t z)
set the axis offset
uint8_t adxl345_set_latent(adxl345_handle_t *handle, uint8_t t)
set the latent
uint8_t adxl345_set_rate(adxl345_handle_t *handle, adxl345_rate_t rate)
set the sampling rate
uint8_t adxl345_set_inaction_threshold(adxl345_handle_t *handle, uint8_t threshold)
set the inaction threshold
uint8_t adxl345_set_addr_pin(adxl345_handle_t *handle, adxl345_address_t addr_pin)
set the iic address pin
uint8_t adxl345_free_fall_time_convert_to_register(adxl345_handle_t *handle, uint16_t ms, uint8_t *reg)
convert the free fall time to the register raw data
uint8_t adxl345_set_action_inaction(adxl345_handle_t *handle, adxl345_action_inaction_t type, adxl345_bool_t enable)
enable or disable the action or inaction
uint8_t adxl345_free_fall_threshold_convert_to_register(adxl345_handle_t *handle, float g, uint8_t *reg)
convert the free fall threshold to the register raw data
uint8_t adxl345_window_convert_to_register(adxl345_handle_t *handle, float ms, uint8_t *reg)
convert the window time to the register raw data
uint8_t adxl345_set_duration(adxl345_handle_t *handle, uint8_t t)
set the duration
uint8_t adxl345_tap_threshold_convert_to_register(adxl345_handle_t *handle, float g, uint8_t *reg)
convert the tap threshold to the register raw data
uint8_t adxl345_set_tap_suppress(adxl345_handle_t *handle, adxl345_bool_t enable)
enable or disable the tap suppress
uint8_t adxl345_set_auto_sleep(adxl345_handle_t *handle, adxl345_bool_t enable)
enable or disable the auto sleep
uint8_t adxl345_set_tap_axis(adxl345_handle_t *handle, adxl345_tap_axis_t axis, adxl345_bool_t enable)
enable or disable the tap axis
uint8_t adxl345_set_free_fall_time(adxl345_handle_t *handle, uint8_t t)
set the free fall time
uint8_t adxl345_set_window(adxl345_handle_t *handle, uint8_t t)
set the window
uint8_t adxl345_action_threshold_convert_to_register(adxl345_handle_t *handle, float g, uint8_t *reg)
convert the action threshold to the register raw data
uint8_t adxl345_set_sleep_frequency(adxl345_handle_t *handle, adxl345_sleep_frequency_t sleep_frequency)
set the sleep frequency
adxl345_address_t
adxl345 address enumeration definition
uint8_t adxl345_latent_convert_to_register(adxl345_handle_t *handle, float ms, uint8_t *reg)
convert the latent to the register raw data
uint8_t adxl345_offset_convert_to_register(adxl345_handle_t *handle, float g, int8_t *reg)
convert the offset to the register raw data
uint8_t adxl345_init(adxl345_handle_t *handle)
initialize the chip
struct adxl345_handle_s adxl345_handle_t
adxl345 handle structure definition
uint8_t adxl345_set_action_coupled(adxl345_handle_t *handle, adxl345_coupled_t coupled)
set the action coupled
uint8_t adxl345_set_justify(adxl345_handle_t *handle, adxl345_justify_t enable)
enable or disable the justify
uint8_t adxl345_set_interface(adxl345_handle_t *handle, adxl345_interface_t interface)
set the chip interface
uint8_t adxl345_set_mode(adxl345_handle_t *handle, adxl345_mode_t mode)
set the chip mode
uint8_t adxl345_info(adxl345_info_t *info)
get chip's information
uint8_t adxl345_set_tap_threshold(adxl345_handle_t *handle, uint8_t threshold)
set the tap threshold
uint8_t adxl345_set_range(adxl345_handle_t *handle, adxl345_range_t range)
set the chip range
@ ADXL345_SPI_WIRE_4
@ ADXL345_JUSTIFY_RIGHT
@ ADXL345_ACTION_Z
@ ADXL345_INACTION_Z
@ ADXL345_INACTION_X
@ ADXL345_INACTION_Y
@ ADXL345_ACTION_X
@ ADXL345_ACTION_Y
@ ADXL345_RANGE_16G
@ ADXL345_RATE_12P5
@ ADXL345_TAP_AXIS_Z
@ ADXL345_TAP_AXIS_Y
@ ADXL345_TAP_AXIS_X
@ ADXL345_COUPLED_DC
@ ADXL345_COUPLED_AC
@ ADXL345_BOOL_FALSE
@ ADXL345_BOOL_TRUE
@ ADXL345_SLEEP_FREQUENCY_1HZ
@ ADXL345_MODE_FIFO
uint8_t adxl345_get_watermark_level(adxl345_handle_t *handle, uint8_t *level)
get the current fifo watermark level
uint8_t adxl345_set_watermark(adxl345_handle_t *handle, uint8_t level)
set the fifo watermark
uint8_t adxl345_interface_iic_write(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus write
uint8_t adxl345_interface_spi_deinit(void)
interface spi bus deinit
uint8_t adxl345_interface_iic_deinit(void)
interface iic bus deinit
uint8_t adxl345_interface_spi_read(uint8_t reg, uint8_t *buf, uint16_t len)
interface spi bus read
uint8_t adxl345_interface_iic_init(void)
interface iic bus init
uint8_t adxl345_interface_spi_init(void)
interface spi bus init
uint8_t adxl345_interface_iic_read(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus read
void adxl345_interface_delay_ms(uint32_t ms)
interface delay ms
void adxl345_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t adxl345_interface_spi_write(uint8_t reg, uint8_t *buf, uint16_t len)
interface spi bus write
uint8_t adxl345_get_interrupt_source(adxl345_handle_t *handle, uint8_t *source)
get the interrupt source
uint8_t adxl345_set_interrupt(adxl345_handle_t *handle, adxl345_interrupt_t type, adxl345_bool_t enable)
enable or disable the interrupt
uint8_t adxl345_set_interrupt_map(adxl345_handle_t *handle, adxl345_interrupt_t type, adxl345_interrupt_pin_t pin)
set the interrupt map
uint8_t adxl345_set_interrupt_active_level(adxl345_handle_t *handle, adxl345_interrupt_active_level_t active_level)
set the interrupt active level
@ ADXL345_INTERRUPT_ACTIVE_LEVEL_LOW
@ ADXL345_INTERRUPT_PIN2
@ ADXL345_INTERRUPT_PIN1
@ ADXL345_INTERRUPT_DATA_READY
@ ADXL345_INTERRUPT_DOUBLE_TAP
@ ADXL345_INTERRUPT_ACTIVITY
@ ADXL345_INTERRUPT_SINGLE_TAP
@ ADXL345_INTERRUPT_INACTIVITY
@ ADXL345_INTERRUPT_WATERMARK
@ ADXL345_INTERRUPT_OVERRUN
@ ADXL345_INTERRUPT_FREE_FALL
uint8_t adxl345_fifo_test(adxl345_interface_t interface, adxl345_address_t addr_pin)
fifo test
uint8_t adxl345_fifo_test_irq_handler(void)
fifo test irq
uint32_t driver_version
char manufacturer_name[32]