LibDriver ADXL345  2.0.0
ADXL345 full-featured driver
driver_adxl345_tap_action_fall_test.c
Go to the documentation of this file.
1 
39 
40 static adxl345_handle_t gs_handle;
41 static uint8_t gs_tap_action_fall_flag;
51 {
52  if (adxl345_irq_handler(&gs_handle) != 0)
53  {
54  return 1;
55  }
56  else
57  {
58  return 0;
59  }
60 }
61 
67 static void a_adxl345_interface_test_receive_callback(uint8_t type)
68 {
69  switch (type)
70  {
72  {
73  break;
74  }
76  {
77  gs_tap_action_fall_flag |= 1 << 0;
78  adxl345_interface_debug_print("adxl345: irq single tap.\n");
79 
80  break;
81  }
83  {
84  gs_tap_action_fall_flag |= 1 << 1;
85  adxl345_interface_debug_print("adxl345: irq double tap.\n");
86 
87  break;
88  }
90  {
91  gs_tap_action_fall_flag |= 1 << 2;
92  adxl345_interface_debug_print("adxl345: irq activity.\n");
93 
94  break;
95  }
97  {
98  gs_tap_action_fall_flag |= 1 << 3;
99  adxl345_interface_debug_print("adxl345: irq inactivity.\n");
100 
101  break;
102  }
104  {
105  gs_tap_action_fall_flag |= 1 << 4;
106  adxl345_interface_debug_print("adxl345: irq free fall.\n");
107 
108  break;
109  }
111  {
112  break;
113  }
114  default :
115  {
116  break;
117  }
118  }
119 }
120 
128 static uint8_t a_adxl345_test_server(void)
129 {
130  int16_t raw[3];
131  float g_out[3];
132  uint16_t len;
133 
134  len = 1;
135 
136  /* read data */
137  if (adxl345_read(&gs_handle, (int16_t (*)[3])&raw, (float (*)[3])&g_out, (uint16_t *)&len) != 0)
138  {
139  adxl345_interface_debug_print("adxl345: read failed.\n");
140 
141  return 1;
142  }
143 
144  return 0;
145 }
146 
157 {
158  uint8_t res;
159  uint8_t source;
160  int8_t reg;
161  adxl345_info_t info;
162 
163  /* link interface function */
175  DRIVER_ADXL345_LINK_RECEIVE_CALLBACK(&gs_handle, a_adxl345_interface_test_receive_callback);
176 
177  /* get information */
178  res = adxl345_info(&info);
179  if (res != 0)
180  {
181  adxl345_interface_debug_print("adxl345: get info failed.\n");
182 
183  return 1;
184  }
185  else
186  {
187  /* print chip info */
188  adxl345_interface_debug_print("adxl345: chip is %s.\n", info.chip_name);
189  adxl345_interface_debug_print("adxl345: manufacturer is %s.\n", info.manufacturer_name);
190  adxl345_interface_debug_print("adxl345: interface is %s.\n", info.interface);
191  adxl345_interface_debug_print("adxl345: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
192  adxl345_interface_debug_print("adxl345: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
193  adxl345_interface_debug_print("adxl345: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
194  adxl345_interface_debug_print("adxl345: max current is %0.2fmA.\n", info.max_current_ma);
195  adxl345_interface_debug_print("adxl345: max temperature is %0.1fC.\n", info.temperature_max);
196  adxl345_interface_debug_print("adxl345: min temperature is %0.1fC.\n", info.temperature_min);
197  }
198 
199  /* set interface */
200  res = adxl345_set_interface(&gs_handle, interface);
201  if (res != 0)
202  {
203  adxl345_interface_debug_print("adxl345: set interface failed.\n");
204 
205  return 1;
206  }
207 
208  /* set address pin */
209  res = adxl345_set_addr_pin(&gs_handle, addr_pin);
210  if (res != 0)
211  {
212  adxl345_interface_debug_print("adxl345: set addr pin failed.\n");
213 
214  return 1;
215  }
216 
217  /* adxl345 initialization */
218  res = adxl345_init(&gs_handle);
219  if (res != 0)
220  {
221  adxl345_interface_debug_print("adxl345: init failed.\n");
222 
223  return 1;
224  }
225 
226  /* set 12.5 rate */
227  res = adxl345_set_rate(&gs_handle, ADXL345_RATE_12P5);
228  if (res != 0)
229  {
230  adxl345_interface_debug_print("adxl345: set rate failed.\n");
231  (void)adxl345_deinit(&gs_handle);
232 
233  return 1;
234  }
235 
236  /* set 4 wire */
237  res = adxl345_set_spi_wire(&gs_handle, ADXL345_SPI_WIRE_4);
238  if (res != 0)
239  {
240  adxl345_interface_debug_print("adxl345: set spi wire failed.\n");
241  (void)adxl345_deinit(&gs_handle);
242 
243  return 1;
244  }
245 
246  /* set interrupt low */
248  if (res != 0)
249  {
250  adxl345_interface_debug_print("adxl345: set interrupt active level failed.\n");
251  (void)adxl345_deinit(&gs_handle);
252 
253  return 1;
254  }
255 
256  /* set full resolution */
258  if (res != 0)
259  {
260  adxl345_interface_debug_print("adxl345: set full resolution failed.\n");
261  (void)adxl345_deinit(&gs_handle);
262 
263  return 1;
264  }
265 
266  /* disable auto sleep */
267  res = adxl345_set_auto_sleep(&gs_handle, ADXL345_BOOL_FALSE);
268  if (res != 0)
269  {
270  adxl345_interface_debug_print("adxl345: set auto sleep failed.\n");
271  (void)adxl345_deinit(&gs_handle);
272 
273  return 1;
274  }
275 
276  /* disable sleep */
277  res = adxl345_set_sleep(&gs_handle, ADXL345_BOOL_FALSE);
278  if (res != 0)
279  {
280  adxl345_interface_debug_print("adxl345: set sleep failed.\n");
281  (void)adxl345_deinit(&gs_handle);
282 
283  return 1;
284  }
285 
286  /* set sleep 1Hz */
288  if (res != 0)
289  {
290  adxl345_interface_debug_print("adxl345: set sleep frequency failed.\n");
291  (void)adxl345_deinit(&gs_handle);
292 
293  return 1;
294  }
295 
296  /* set justify right */
297  res = adxl345_set_justify(&gs_handle, ADXL345_JUSTIFY_RIGHT);
298  if (res != 0)
299  {
300  adxl345_interface_debug_print("adxl345: set justify failed.\n");
301  (void)adxl345_deinit(&gs_handle);
302 
303  return 1;
304  }
305 
306  /* set range 16g */
307  res = adxl345_set_range(&gs_handle, ADXL345_RANGE_16G);
308  if (res != 0)
309  {
310  adxl345_interface_debug_print("adxl345: set range failed.\n");
311  (void)adxl345_deinit(&gs_handle);
312 
313  return 1;
314  }
315 
316  /* set bypass mode */
317  res = adxl345_set_mode(&gs_handle, ADXL345_MODE_BYPASS);
318  if (res != 0)
319  {
320  adxl345_interface_debug_print("adxl345: set mode failed.\n");
321  (void)adxl345_deinit(&gs_handle);
322 
323  return 1;
324  }
325 
326  /* set trigger pin int 2 */
328  if (res != 0)
329  {
330  adxl345_interface_debug_print("adxl345: set trigger pin failed.\n");
331  (void)adxl345_deinit(&gs_handle);
332 
333  return 1;
334  }
335 
336  /* set watermark 16 level */
337  res = adxl345_set_watermark(&gs_handle, 16);
338  if (res != 0)
339  {
340  adxl345_interface_debug_print("adxl345: set watermark failed.\n");
341  (void)adxl345_deinit(&gs_handle);
342 
343  return 1;
344  }
345 
346  /* set offset */
347  res = adxl345_offset_convert_to_register(&gs_handle, 0.0f, (int8_t *)&reg);
348  if (res != 0)
349  {
350  adxl345_interface_debug_print("adxl345: offset convert to register failed.\n");
351  (void)adxl345_deinit(&gs_handle);
352 
353  return 1;
354  }
355  res = adxl345_set_offset(&gs_handle, reg, reg, reg);
356  if (res != 0)
357  {
358  adxl345_interface_debug_print("adxl345: set offset failed.\n");
359  (void)adxl345_deinit(&gs_handle);
360 
361  return 1;
362  }
363 
364  /* set tap */
365  res = adxl345_tap_threshold_convert_to_register(&gs_handle, 3.0f, (uint8_t *)&reg);
366  if (res != 0)
367  {
368  adxl345_interface_debug_print("adxl345: tap threshold convert to register failed.\n");
369  (void)adxl345_deinit(&gs_handle);
370 
371  return 1;
372  }
373  res = adxl345_set_tap_threshold(&gs_handle, reg);
374  if (res != 0)
375  {
376  adxl345_interface_debug_print("adxl345: set tap threshold failed.\n");
377  (void)adxl345_deinit(&gs_handle);
378 
379  return 1;
380  }
381 
382  /* set duration time */
383  res = adxl345_duration_convert_to_register(&gs_handle, 10*1000, (uint8_t *)&reg);
384  if (res != 0)
385  {
386  adxl345_interface_debug_print("adxl345: duration convert to register failed.\n");
387  (void)adxl345_deinit(&gs_handle);
388 
389  return 1;
390  }
391  res = adxl345_set_duration(&gs_handle, reg);
392  if (res != 0)
393  {
394  adxl345_interface_debug_print("adxl345: set duration failed.\n");
395  (void)adxl345_deinit(&gs_handle);
396 
397  return 1;
398  }
399 
400  /* set latent time */
401  res = adxl345_latent_convert_to_register(&gs_handle, 20.0f, (uint8_t *)&reg);
402  if (res != 0)
403  {
404  adxl345_interface_debug_print("adxl345: latent convert to register failed.\n");
405  (void)adxl345_deinit(&gs_handle);
406 
407  return 1;
408  }
409  res = adxl345_set_latent(&gs_handle, reg);
410  if (res != 0)
411  {
412  adxl345_interface_debug_print("adxl345: set latent failed.\n");
413  (void)adxl345_deinit(&gs_handle);
414 
415  return 1;
416  }
417 
418  /* set window */
419  res = adxl345_window_convert_to_register(&gs_handle, 80.0f, (uint8_t *)&reg);
420  if (res != 0)
421  {
422  adxl345_interface_debug_print("adxl345: window convert to register failed.\n");
423  (void)adxl345_deinit(&gs_handle);
424 
425  return 1;
426  }
427  res = adxl345_set_window(&gs_handle, reg);
428  if (res != 0)
429  {
430  adxl345_interface_debug_print("adxl345: set window failed.\n");
431  (void)adxl345_deinit(&gs_handle);
432 
433  return 1;
434  }
435 
436  /* set tap x */
438  if (res != 0)
439  {
440  adxl345_interface_debug_print("adxl345: set tap axis failed.\n");
441  (void)adxl345_deinit(&gs_handle);
442 
443  return 1;
444  }
446  if (res != 0)
447  {
448  adxl345_interface_debug_print("adxl345: set tap axis failed.\n");
449  (void)adxl345_deinit(&gs_handle);
450 
451  return 1;
452  }
454  if (res != 0)
455  {
456  adxl345_interface_debug_print("adxl345: set tap axis failed.\n");
457  (void)adxl345_deinit(&gs_handle);
458 
459  return 1;
460  }
461 
462  /* disable suppress */
463  res = adxl345_set_tap_suppress(&gs_handle, ADXL345_BOOL_FALSE);
464  if (res != 0)
465  {
466  adxl345_interface_debug_print("adxl345: set tap suppress 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 single 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  /* map int 1 */
494  if (res != 0)
495  {
496  adxl345_interface_debug_print("adxl345: set interrupt map failed.\n");
497  (void)adxl345_deinit(&gs_handle);
498 
499  return 1;
500  }
501 
502  /* set double tap */
504  if (res != 0)
505  {
506  adxl345_interface_debug_print("adxl345: set interrupt failed.\n");
507  (void)adxl345_deinit(&gs_handle);
508 
509  return 1;
510  }
511 
512  /* link activity and inactivity */
514  if (res != 0)
515  {
516  adxl345_interface_debug_print("adxl345: set link activity inactivity failed.\n");
517  (void)adxl345_deinit(&gs_handle);
518 
519  return 1;
520  }
521 
522  /* set action threshold */
523  res = adxl345_action_threshold_convert_to_register(&gs_handle, 2.0f, (uint8_t *)&reg);
524  if (res != 0)
525  {
526  adxl345_interface_debug_print("adxl345: action threshold convert to register failed.\n");
527  (void)adxl345_deinit(&gs_handle);
528 
529  return 1;
530  }
531  res = adxl345_set_action_threshold(&gs_handle, reg);
532  if (res != 0)
533  {
534  adxl345_interface_debug_print("adxl345: set action threshold failed.\n");
535  (void)adxl345_deinit(&gs_handle);
536 
537  return 1;
538  }
539 
540  /* set inaction threshold */
541  res = adxl345_inaction_threshold_convert_to_register(&gs_handle, 1.0f, (uint8_t *)&reg);
542  if (res != 0)
543  {
544  adxl345_interface_debug_print("adxl345: inaction threshold convert to register failed.\n");
545  (void)adxl345_deinit(&gs_handle);
546 
547  return 1;
548  }
549  res = adxl345_set_inaction_threshold(&gs_handle, reg);
550  if (res != 0)
551  {
552  adxl345_interface_debug_print("adxl345: set inaction threshold failed.\n");
553  (void)adxl345_deinit(&gs_handle);
554 
555  return 1;
556  }
557 
558  /* set inaction time */
559  res = adxl345_inaction_time_convert_to_register(&gs_handle, 3, (uint8_t *)&reg);
560  if (res != 0)
561  {
562  adxl345_interface_debug_print("adxl345: inaction time convert to register failed.\n");
563  (void)adxl345_deinit(&gs_handle);
564 
565  return 1;
566  }
567  res = adxl345_set_inaction_time(&gs_handle, reg);
568  if (res != 0)
569  {
570  adxl345_interface_debug_print("adxl345: set inaction time failed.\n");
571  (void)adxl345_deinit(&gs_handle);
572 
573  return 1;
574  }
575 
576  /* set action x */
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 action y */
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 action z */
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 inaction x */
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 inaction y */
618  if (res != 0)
619  {
620  adxl345_interface_debug_print("adxl345: set action inaction failed.\n");
621  (void)adxl345_deinit(&gs_handle);
622 
623  return 1;
624  }
625 
626  /* set inaction z */
628  if (res != 0)
629  {
630  adxl345_interface_debug_print("adxl345: set action inaction failed.\n");
631  (void)adxl345_deinit(&gs_handle);
632 
633  return 1;
634  }
635 
636  /* set action ac coupled */
638  if (res != 0)
639  {
640  adxl345_interface_debug_print("adxl345: set action coupled failed.\n");
641  (void)adxl345_deinit(&gs_handle);
642 
643  return 1;
644  }
645 
646  /* set inaction dc coupled */
648  if (res != 0)
649  {
650  adxl345_interface_debug_print("adxl345: set inaction coupled failed.\n");
651  (void)adxl345_deinit(&gs_handle);
652 
653  return 1;
654  }
655 
656  /* 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 activity */
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  /* map int 1 */
678  if (res != 0)
679  {
680  adxl345_interface_debug_print("adxl345: set interrupt map failed.\n");
681  (void)adxl345_deinit(&gs_handle);
682 
683  return 1;
684  }
685 
686  /* set inactivity */
688  if (res != 0)
689  {
690  adxl345_interface_debug_print("adxl345: set interrupt failed.\n");
691  (void)adxl345_deinit(&gs_handle);
692 
693  return 1;
694  }
695 
696  /* set free fall */
697  res = adxl345_free_fall_threshold_convert_to_register(&gs_handle, 0.8f, (uint8_t *)&reg);
698  if (res != 0)
699  {
700  adxl345_interface_debug_print("adxl345: free fall threshold convert to register failed.\n");
701  (void)adxl345_deinit(&gs_handle);
702 
703  return 1;
704  }
705  res = adxl345_set_free_fall_threshold(&gs_handle, reg);
706  if (res != 0)
707  {
708  adxl345_interface_debug_print("adxl345: set free fall threshold failed.\n");
709  (void)adxl345_deinit(&gs_handle);
710 
711  return 1;
712  }
713 
714  /* set free fall time */
715  res = adxl345_free_fall_time_convert_to_register(&gs_handle, 10, (uint8_t *)&reg);
716  if (res != 0)
717  {
718  adxl345_interface_debug_print("adxl345: free fall time convert to register failed.\n");
719  (void)adxl345_deinit(&gs_handle);
720 
721  return 1;
722  }
723  res = adxl345_set_free_fall_time(&gs_handle, reg);
724  if (res != 0)
725  {
726  adxl345_interface_debug_print("adxl345: set free fall time failed.\n");
727  (void)adxl345_deinit(&gs_handle);
728 
729  return 1;
730  }
731 
732  /* set interrupt 1 */
734  if (res != 0)
735  {
736  adxl345_interface_debug_print("adxl345: set interrupt map failed.\n");
737  (void)adxl345_deinit(&gs_handle);
738 
739  return 1;
740  }
741 
742  /* set free fall */
744  if (res != 0)
745  {
746  adxl345_interface_debug_print("adxl345: set interrupt failed.\n");
747  (void)adxl345_deinit(&gs_handle);
748 
749  return 1;
750  }
751 
752  /* set interrupt 1 */
754  if (res != 0)
755  {
756  adxl345_interface_debug_print("adxl345: set interrupt map failed.\n");
757  (void)adxl345_deinit(&gs_handle);
758 
759  return 1;
760  }
761 
762  /* set data ready */
764  if (res != 0)
765  {
766  adxl345_interface_debug_print("adxl345: set interrupt failed.\n");
767  (void)adxl345_deinit(&gs_handle);
768 
769  return 1;
770  }
771 
772  /* set interrupt 1 */
774  if (res != 0)
775  {
776  adxl345_interface_debug_print("adxl345: set interrupt map failed.\n");
777  (void)adxl345_deinit(&gs_handle);
778 
779  return 1;
780  }
781 
782  /* set data ready */
784  if (res != 0)
785  {
786  adxl345_interface_debug_print("adxl345: set interrupt failed.\n");
787  (void)adxl345_deinit(&gs_handle);
788 
789  return 1;
790  }
791 
792  /* set interrupt 1 */
794  if (res != 0)
795  {
796  adxl345_interface_debug_print("adxl345: set interrupt map failed.\n");
797  (void)adxl345_deinit(&gs_handle);
798 
799  return 1;
800  }
801 
802  /* set overrun */
804  if (res != 0)
805  {
806  adxl345_interface_debug_print("adxl345: set interrupt failed.\n");
807  (void)adxl345_deinit(&gs_handle);
808 
809  return 1;
810  }
811 
812  /* clear interrupt */
813  res = adxl345_get_interrupt_source(&gs_handle, &source);
814  if (res != 0)
815  {
816  adxl345_interface_debug_print("adxl345: get interrupt source failed.\n");
817  (void)adxl345_deinit(&gs_handle);
818 
819  return 1;
820  }
821 
822  /* start measure */
823  res = adxl345_set_measure(&gs_handle, ADXL345_BOOL_TRUE);
824  if (res != 0)
825  {
826  adxl345_interface_debug_print("adxl345: set measure failed.\n");
827  (void)adxl345_deinit(&gs_handle);
828 
829  return 1;
830  }
832 
833  /* start tap action fall test */
834  adxl345_interface_debug_print("adxl345: start tap action fall test.\n");
835 
836  /* single tap test */
837  adxl345_interface_debug_print("adxl345: please single tap.\n");
838  gs_tap_action_fall_flag = 0;
839  while (1)
840  {
841  if ((gs_tap_action_fall_flag & (1 << 0)) == (1 << 0))
842  {
843  adxl345_interface_debug_print("adxl345: detect single tap.\n");
844 
845  break;
846  }
847  if (a_adxl345_test_server() != 0)
848  {
849  return 1;
850  }
852  }
853 
854  /* double tap test */
855  adxl345_interface_debug_print("adxl345: please double tap.\n");
856  gs_tap_action_fall_flag = 0;
857  while (1)
858  {
859  if ((gs_tap_action_fall_flag & (1 << 1)) == (1 << 1))
860  {
861  adxl345_interface_debug_print("adxl345: detect double tap.\n");
862 
863  break;
864  }
865  if (a_adxl345_test_server() != 0)
866  {
867  return 1;
868  }
870  }
871 
872  /* action */
873  adxl345_interface_debug_print("adxl345: please action.\n");
874  gs_tap_action_fall_flag = 0;
875  while (1)
876  {
877  if ((gs_tap_action_fall_flag & (1 << 2)) == (1 << 2))
878  {
879  adxl345_interface_debug_print("adxl345: detect action.\n");
880 
881  break;
882  }
883  if (a_adxl345_test_server() != 0)
884  {
885  return 1;
886  }
888  }
889 
890  /* inaction */
891  adxl345_interface_debug_print("adxl345: please stop action.\n");
892  gs_tap_action_fall_flag = 0;
893  while (1)
894  {
895  if ((gs_tap_action_fall_flag & (1 << 3)) == (1 << 3))
896  {
897  adxl345_interface_debug_print("adxl345: detect stop.\n");
898 
899  break;
900  }
901  if (a_adxl345_test_server() != 0)
902  {
903  return 1;
904  }
906  }
907 
908  /* free fall */
909  adxl345_interface_debug_print("adxl345: please free fall.\n");
910  gs_tap_action_fall_flag = 0;
911  while (1)
912  {
913  if ((gs_tap_action_fall_flag & (1 << 4)) == (1 << 4))
914  {
915  adxl345_interface_debug_print("adxl345: detect free fall.\n");
916 
917  break;
918  }
919  if (a_adxl345_test_server() != 0)
920  {
921  return 1;
922  }
924  }
925  adxl345_interface_debug_print("adxl345: finish tap action fall test.\n");
926  (void)adxl345_deinit(&gs_handle);
927 
928  return 0;
929 }
driver adxl345 tap action fall 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
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
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_BYPASS
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_action_test_irq_handler(void)
action test irq
uint8_t adxl345_tap_action_fall_test(adxl345_interface_t interface, adxl345_address_t addr_pin)
tap action fall test
adxl345 handle structure definition
adxl345 information structure definition
float supply_voltage_max_v
uint32_t driver_version
char manufacturer_name[32]
float supply_voltage_min_v
char chip_name[32]