LibDriver ADXL345  2.0.0
ADXL345 full-featured driver
driver_adxl345_fifo.c
Go to the documentation of this file.
1 
38 #include "driver_adxl345_fifo.h"
39 
40 static adxl345_handle_t gs_handle;
41 static void (*a_callback)(float (*g)[3], uint16_t len) = NULL;
42 static int16_t gs_raw[32][3];
43 static float gs_data[32][3];
53 {
54  if (adxl345_irq_handler(&gs_handle) != 0)
55  {
56  return 1;
57  }
58  else
59  {
60  return 0;
61  }
62 }
63 
69 static void a_adxl345_fifo_receive_callback(uint8_t type)
70 {
71  switch (type)
72  {
74  {
75  uint16_t len;
76 
77  len = 32;
78  if (adxl345_read(&gs_handle, (int16_t (*)[3])gs_raw, (float (*)[3])gs_data, (uint16_t *)&len) != 0)
79  {
80  adxl345_interface_debug_print("adxl345: read failed.\n");
81 
82  return;
83  }
84  if (a_callback != NULL)
85  {
86  a_callback(gs_data, len);
87  }
88 
89  break;
90  }
91  default :
92  {
93  break;
94  }
95  }
96 }
97 
109  void (*callback)(float (*g)[3], uint16_t len))
110 {
111  uint8_t res;
112  uint8_t source;
113  uint8_t status;
114  int8_t reg;
115  uint16_t len;
116 
117  /* link interface function */
129  DRIVER_ADXL345_LINK_RECEIVE_CALLBACK(&gs_handle, a_adxl345_fifo_receive_callback);
130 
131  /* set the interface */
132  res = adxl345_set_interface(&gs_handle, interface);
133  if (res != 0)
134  {
135  adxl345_interface_debug_print("adxl345: set interface failed.\n");
136 
137  return 1;
138  }
139 
140  /* set addr pin */
141  res = adxl345_set_addr_pin(&gs_handle, addr_pin);
142  if (res != 0)
143  {
144  adxl345_interface_debug_print("adxl345: set addr pin failed.\n");
145 
146  return 1;
147  }
148 
149  /* adxl345 initialization */
150  res = adxl345_init(&gs_handle);
151  if (res != 0)
152  {
153  adxl345_interface_debug_print("adxl345: init failed.\n");
154 
155  return 1;
156  }
157 
158  /* set default rate */
159  res = adxl345_set_rate(&gs_handle, ADXL345_FIFO_DEFAULT_RATE);
160  if (res != 0)
161  {
162  adxl345_interface_debug_print("adxl345: set rate failed.\n");
163  (void)adxl345_deinit(&gs_handle);
164 
165  return 1;
166  }
167 
168  /* set default spi wire */
170  if (res != 0)
171  {
172  adxl345_interface_debug_print("adxl345: set spi wire failed.\n");
173  (void)adxl345_deinit(&gs_handle);
174 
175  return 1;
176  }
177 
178  /* set interrupt pin */
180  if (res != 0)
181  {
182  adxl345_interface_debug_print("adxl345: set adxl345 set interrupt active level failed.\n");
183  (void)adxl345_deinit(&gs_handle);
184 
185  return 1;
186  }
187 
188  /* set full resolution */
190  if (res != 0)
191  {
192  adxl345_interface_debug_print("adxl345: set full resolution failed.\n");
193  (void)adxl345_deinit(&gs_handle);
194 
195  return 1;
196  }
197 
198  /* set auto sleep */
200  if (res != 0)
201  {
202  adxl345_interface_debug_print("adxl345: set auto sleep failed.\n");
203  (void)adxl345_deinit(&gs_handle);
204 
205  return 1;
206  }
207 
208  /* set sleep */
210  if (res != 0)
211  {
212  adxl345_interface_debug_print("adxl345: set sleep failed.\n");
213  (void)adxl345_deinit(&gs_handle);
214 
215  return 1;
216  }
217 
218  /* set sleep frequency */
220  if (res != 0)
221  {
222  adxl345_interface_debug_print("adxl345: set sleep frequency failed.\n");
223  (void)adxl345_deinit(&gs_handle);
224 
225  return 1;
226  }
227 
228  /* set justify */
230  if (res != 0)
231  {
232  adxl345_interface_debug_print("adxl345: set justify failed.\n");
233  (void)adxl345_deinit(&gs_handle);
234 
235  return 1;
236  }
237 
238  /* set range */
240  if (res != 0)
241  {
242  adxl345_interface_debug_print("adxl345: set range failed.\n");
243  (void)adxl345_deinit(&gs_handle);
244 
245  return 1;
246  }
247 
248  /* set mode */
249  res = adxl345_set_mode(&gs_handle, ADXL345_MODE_FIFO);
250  if (res != 0)
251  {
252  adxl345_interface_debug_print("adxl345: set mode failed.\n");
253  (void)adxl345_deinit(&gs_handle);
254 
255  return 1;
256  }
257 
258  /* set trigger pin */
260  if (res != 0)
261  {
262  adxl345_interface_debug_print("adxl345: set trigger pin failed.\n");
263  (void)adxl345_deinit(&gs_handle);
264 
265  return 1;
266  }
267 
268  /* set watermark level */
270  if (res != 0)
271  {
272  adxl345_interface_debug_print("adxl345: set watermark failed.\n");
273  (void)adxl345_deinit(&gs_handle);
274 
275  return 1;
276  }
277 
278  /* set default offset */
279  res = adxl345_offset_convert_to_register(&gs_handle, ADXL345_FIFO_DEFAULT_OFFSET, (int8_t *)&reg);
280  if (res != 0)
281  {
282  adxl345_interface_debug_print("adxl345: offset convert to register failed.\n");
283  (void)adxl345_deinit(&gs_handle);
284 
285  return 1;
286  }
287  res = adxl345_set_offset(&gs_handle, reg, reg, reg);
288  if (res != 0)
289  {
290  adxl345_interface_debug_print("adxl345: set offset failed.\n");
291  (void)adxl345_deinit(&gs_handle);
292 
293  return 1;
294  }
295 
296  /* set default tap threshold */
298  if (res != 0)
299  {
300  adxl345_interface_debug_print("adxl345: tap threshold convert to register failed.\n");
301  (void)adxl345_deinit(&gs_handle);
302 
303  return 1;
304  }
305  res = adxl345_set_tap_threshold(&gs_handle, reg);
306  if (res != 0)
307  {
308  adxl345_interface_debug_print("adxl345: set tap threshold failed.\n");
309  (void)adxl345_deinit(&gs_handle);
310 
311  return 1;
312  }
313 
314  /* set default duration */
315  res = adxl345_duration_convert_to_register(&gs_handle, ADXL345_FIFO_DEFAULT_DURATION, (uint8_t *)&reg);
316  if (res != 0)
317  {
318  adxl345_interface_debug_print("adxl345: duration convert to register failed.\n");
319  (void)adxl345_deinit(&gs_handle);
320 
321  return 1;
322  }
323  res = adxl345_set_duration(&gs_handle, reg);
324  if (res != 0)
325  {
326  adxl345_interface_debug_print("adxl345: set duration failed.\n");
327  (void)adxl345_deinit(&gs_handle);
328 
329  return 1;
330  }
331 
332  /* set latent time */
333  res = adxl345_latent_convert_to_register(&gs_handle, ADXL345_FIFO_DEFAULT_LATENT, (uint8_t *)&reg);
334  if (res != 0)
335  {
336  adxl345_interface_debug_print("adxl345: latent convert to register failed.\n");
337  (void)adxl345_deinit(&gs_handle);
338 
339  return 1;
340  }
341  res = adxl345_set_latent(&gs_handle, reg);
342  if (res != 0)
343  {
344  adxl345_interface_debug_print("adxl345: set latent failed.\n");
345  (void)adxl345_deinit(&gs_handle);
346 
347  return 1;
348  }
349 
350  /* set window time */
351  res = adxl345_window_convert_to_register(&gs_handle, ADXL345_FIFO_DEFAULT_WINDOW, (uint8_t *)&reg);
352  if (res != 0)
353  {
354  adxl345_interface_debug_print("adxl345: window convert to register failed.\n");
355  (void)adxl345_deinit(&gs_handle);
356 
357  return 1;
358  }
359  res = adxl345_set_window(&gs_handle, reg);
360  if (res != 0)
361  {
362  adxl345_interface_debug_print("adxl345: set window failed.\n");
363  (void)adxl345_deinit(&gs_handle);
364 
365  return 1;
366  }
367 
368  /* disable tap */
370  if (res != 0)
371  {
372  adxl345_interface_debug_print("adxl345: set tap axis failed.\n");
373  (void)adxl345_deinit(&gs_handle);
374 
375  return 1;
376  }
378  if (res != 0)
379  {
380  adxl345_interface_debug_print("adxl345: set tap axis failed.\n");
381  (void)adxl345_deinit(&gs_handle);
382 
383  return 1;
384  }
386  if (res != 0)
387  {
388  adxl345_interface_debug_print("adxl345: set tap axis failed.\n");
389  (void)adxl345_deinit(&gs_handle);
390 
391  return 1;
392  }
393 
394  /* set default suppress */
396  if (res != 0)
397  {
398  adxl345_interface_debug_print("adxl345: set tap suppress failed.\n");
399  (void)adxl345_deinit(&gs_handle);
400 
401  return 1;
402  }
403 
404  /* set default single tap map */
406  if (res != 0)
407  {
408  adxl345_interface_debug_print("adxl345: set interrupt map failed.\n");
409  (void)adxl345_deinit(&gs_handle);
410 
411  return 1;
412  }
413 
414  /* disable single tap */
416  if (res != 0)
417  {
418  adxl345_interface_debug_print("adxl345: set interrupt failed.\n");
419  (void)adxl345_deinit(&gs_handle);
420 
421  return 1;
422  }
423 
424  /* set default double tap map */
426  if (res != 0)
427  {
428  adxl345_interface_debug_print("adxl345: set interrupt map failed.\n");
429  (void)adxl345_deinit(&gs_handle);
430 
431  return 1;
432  }
433 
434  /* disable double tap */
436  if (res != 0)
437  {
438  adxl345_interface_debug_print("adxl345: set interrupt failed.\n");
439  (void)adxl345_deinit(&gs_handle);
440 
441  return 1;
442  }
443 
444  /* set default linking activity and inactivity */
446  if (res != 0)
447  {
448  adxl345_interface_debug_print("adxl345: set link activity inactivity failed.\n");
449  (void)adxl345_deinit(&gs_handle);
450 
451  return 1;
452  }
453 
454  /* set default action threshold */
456  if (res != 0)
457  {
458  adxl345_interface_debug_print("adxl345: action threshold convert to register failed.\n");
459  (void)adxl345_deinit(&gs_handle);
460 
461  return 1;
462  }
463  res = adxl345_set_action_threshold(&gs_handle, reg);
464  if (res != 0)
465  {
466  adxl345_interface_debug_print("adxl345: set action threshold failed.\n");
467  (void)adxl345_deinit(&gs_handle);
468 
469  return 1;
470  }
471 
472  /* set default inaction threshold */
474  if (res != 0)
475  {
476  adxl345_interface_debug_print("adxl345: inaction threshold convert to register failed.\n");
477  (void)adxl345_deinit(&gs_handle);
478 
479  return 1;
480  }
481  res = adxl345_set_inaction_threshold(&gs_handle, reg);
482  if (res != 0)
483  {
484  adxl345_interface_debug_print("adxl345: set inaction threshold failed.\n");
485  (void)adxl345_deinit(&gs_handle);
486 
487  return 1;
488  }
489 
490  /* set default inaction time */
492  if (res != 0)
493  {
494  adxl345_interface_debug_print("adxl345: inaction time convert to register failed.\n");
495  (void)adxl345_deinit(&gs_handle);
496 
497  return 1;
498  }
499  res = adxl345_set_inaction_time(&gs_handle, reg);
500  if (res != 0)
501  {
502  adxl345_interface_debug_print("adxl345: set inaction time failed.\n");
503  (void)adxl345_deinit(&gs_handle);
504 
505  return 1;
506  }
507 
508  /* disable action */
510  if (res != 0)
511  {
512  adxl345_interface_debug_print("adxl345: set action inaction failed.\n");
513  (void)adxl345_deinit(&gs_handle);
514 
515  return 1;
516  }
518  if (res != 0)
519  {
520  adxl345_interface_debug_print("adxl345: set action inaction failed.\n");
521  (void)adxl345_deinit(&gs_handle);
522 
523  return 1;
524  }
526  if (res != 0)
527  {
528  adxl345_interface_debug_print("adxl345: set action inaction failed.\n");
529  (void)adxl345_deinit(&gs_handle);
530 
531  return 1;
532  }
534  if (res != 0)
535  {
536  adxl345_interface_debug_print("adxl345: set action inaction failed.\n");
537  (void)adxl345_deinit(&gs_handle);
538 
539  return 1;
540  }
542  if (res != 0)
543  {
544  adxl345_interface_debug_print("adxl345: set action inaction failed.\n");
545  (void)adxl345_deinit(&gs_handle);
546 
547  return 1;
548  }
550  if (res != 0)
551  {
552  adxl345_interface_debug_print("adxl345: set action inaction failed.\n");
553  (void)adxl345_deinit(&gs_handle);
554 
555  return 1;
556  }
557 
558  /* set default action coupled */
560  if (res != 0)
561  {
562  adxl345_interface_debug_print("adxl345: set action coupled failed.\n");
563  (void)adxl345_deinit(&gs_handle);
564 
565  return 1;
566  }
567 
568  /* set default inaction coupled */
570  if (res != 0)
571  {
572  adxl345_interface_debug_print("adxl345: set inaction coupled failed.\n");
573  (void)adxl345_deinit(&gs_handle);
574 
575  return 1;
576  }
577 
578  /* set default activity map */
580  if (res != 0)
581  {
582  adxl345_interface_debug_print("adxl345: set interrupt map failed.\n");
583  (void)adxl345_deinit(&gs_handle);
584 
585  return 1;
586  }
587 
588  /* disable activity interrupt */
590  if (res != 0)
591  {
592  adxl345_interface_debug_print("adxl345: set interrupt failed.\n");
593  (void)adxl345_deinit(&gs_handle);
594 
595  return 1;
596  }
597 
598  /* set default inactivity map */
600  if (res != 0)
601  {
602  adxl345_interface_debug_print("adxl345: set interrupt map failed.\n");
603  (void)adxl345_deinit(&gs_handle);
604 
605  return 1;
606  }
607 
608  /* disable inactivity interrupt */
610  if (res != 0)
611  {
612  adxl345_interface_debug_print("adxl345: set interrupt failed.\n");
613  (void)adxl345_deinit(&gs_handle);
614 
615  return 1;
616  }
617 
618  /* set free fall threshold */
620  if (res != 0)
621  {
622  adxl345_interface_debug_print("adxl345: free fall threshold convert to register failed.\n");
623  (void)adxl345_deinit(&gs_handle);
624 
625  return 1;
626  }
627  res = adxl345_set_free_fall_threshold(&gs_handle, reg);
628  if (res != 0)
629  {
630  adxl345_interface_debug_print("adxl345: set free fall threshold failed.\n");
631  (void)adxl345_deinit(&gs_handle);
632 
633  return 1;
634  }
635 
636  /* set free fall time */
638  if (res != 0)
639  {
640  adxl345_interface_debug_print("adxl345: free fall time convert to register failed.\n");
641  (void)adxl345_deinit(&gs_handle);
642 
643  return 1;
644  }
645  res = adxl345_set_free_fall_time(&gs_handle, reg);
646  if (res != 0)
647  {
648  adxl345_interface_debug_print("adxl345: set free fall time failed.\n");
649  (void)adxl345_deinit(&gs_handle);
650 
651  return 1;
652  }
653 
654  /* set default free fall map */
656  if (res != 0)
657  {
658  adxl345_interface_debug_print("adxl345: set interrupt map failed.\n");
659  (void)adxl345_deinit(&gs_handle);
660 
661  return 1;
662  }
663 
664  /* disable free fall interrupt */
666  if (res != 0)
667  {
668  adxl345_interface_debug_print("adxl345: set interrupt failed.\n");
669  (void)adxl345_deinit(&gs_handle);
670 
671  return 1;
672  }
673 
674  /* set default data ready map */
676  if (res != 0)
677  {
678  adxl345_interface_debug_print("adxl345: set interrupt map failed.\n");
679  (void)adxl345_deinit(&gs_handle);
680 
681  return 1;
682  }
684  if (res != 0)
685  {
686  adxl345_interface_debug_print("adxl345: set interrupt failed.\n");
687  (void)adxl345_deinit(&gs_handle);
688 
689  return 1;
690  }
691 
692  /* set default watermark map */
694  if (res != 0)
695  {
696  adxl345_interface_debug_print("adxl345: set interrupt map failed.\n");
697  (void)adxl345_deinit(&gs_handle);
698 
699  return 1;
700  }
702  if (res != 0)
703  {
704  adxl345_interface_debug_print("adxl345: set interrupt failed.\n");
705  (void)adxl345_deinit(&gs_handle);
706 
707  return 1;
708  }
709 
710  /* set default overrun map */
712  if (res != 0)
713  {
714  adxl345_interface_debug_print("adxl345: set interrupt map failed.\n");
715  (void)adxl345_deinit(&gs_handle);
716 
717  return 1;
718  }
720  if (res != 0)
721  {
722  adxl345_interface_debug_print("adxl345: set interrupt failed.\n");
723  (void)adxl345_deinit(&gs_handle);
724 
725  return 1;
726  }
727 
728  /* clear interrupt */
729  res = adxl345_get_interrupt_source(&gs_handle, &source);
730  if (res != 0)
731  {
732  adxl345_interface_debug_print("adxl345: get interrupt source failed.\n");
733  (void)adxl345_deinit(&gs_handle);
734 
735  return 1;
736  }
737 
738  /* get fifo status */
739  res = adxl345_get_watermark_level(&gs_handle, &status);
740  if (res != 0)
741  {
742  adxl345_interface_debug_print("adxl345: get watermark level failed.\n");
743  (void)adxl345_deinit(&gs_handle);
744 
745  return 1;
746  }
747 
748  /* start measure */
749  res = adxl345_set_measure(&gs_handle, ADXL345_BOOL_TRUE);
750  if (res != 0)
751  {
752  adxl345_interface_debug_print("adxl345: set measure failed.\n");
753  (void)adxl345_deinit(&gs_handle);
754 
755  return 1;
756  }
757 
758  /* delay 500ms */
760  len = 20;
761  if (adxl345_read(&gs_handle, (int16_t (*)[3])gs_raw, (float (*)[3])gs_data, (uint16_t *)&len) != 0)
762  {
763  adxl345_interface_debug_print("adxl345: read failed.\n");
764  (void)adxl345_deinit(&gs_handle);
765 
766  return 1;
767  }
768 
769  a_callback = callback;
770 
771  return 0;
772 }
773 
781 uint8_t adxl345_fifo_deinit(void)
782 {
783  if (adxl345_deinit(&gs_handle) != 0)
784  {
785  return 1;
786  }
787  else
788  {
789  return 0;
790  }
791 }
792 
driver adxl345 fifo 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_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_ACTION_Z
@ ADXL345_INACTION_Z
@ ADXL345_INACTION_X
@ ADXL345_INACTION_Y
@ ADXL345_ACTION_X
@ ADXL345_ACTION_Y
@ ADXL345_TAP_AXIS_Z
@ ADXL345_TAP_AXIS_Y
@ ADXL345_TAP_AXIS_X
@ ADXL345_BOOL_FALSE
@ ADXL345_BOOL_TRUE
@ ADXL345_MODE_FIFO
#define ADXL345_FIFO_DEFAULT_AUTO_SLEEP
#define ADXL345_FIFO_DEFAULT_RATE
adxl345 fifo example default definition
#define ADXL345_FIFO_DEFAULT_INTERRUPT_DATA_READY
#define ADXL345_FIFO_DEFAULT_TAP_THRESHOLD
#define ADXL345_FIFO_DEFAULT_TAP_SUPPRESS
#define ADXL345_FIFO_DEFAULT_INTERRUPT_INACTIVITY_MAP
#define ADXL345_FIFO_DEFAULT_INACTION_COUPLED
#define ADXL345_FIFO_DEFAULT_INTERRUPT_DATA_READY_MAP
#define ADXL345_FIFO_DEFAULT_WINDOW
#define ADXL345_FIFO_DEFAULT_RANGE
#define ADXL345_FIFO_DEFAULT_WATERMARK
#define ADXL345_FIFO_DEFAULT_INTERRUPT_WATERMARK_MAP
#define ADXL345_FIFO_DEFAULT_FULL_RESOLUTION
#define ADXL345_FIFO_DEFAULT_SLEEP
uint8_t adxl345_fifo_irq_handler(void)
fifo irq
uint8_t adxl345_fifo_init(adxl345_interface_t interface, adxl345_address_t addr_pin, void(*callback)(float(*g)[3], uint16_t len))
fifo example init
uint8_t adxl345_fifo_deinit(void)
fifo example deinit
#define ADXL345_FIFO_DEFAULT_DURATION
#define ADXL345_FIFO_DEFAULT_SPI_WIRE
#define ADXL345_FIFO_DEFAULT_INTERRUPT_OVERRUN_MAP
#define ADXL345_FIFO_DEFAULT_JUSTIFY
#define ADXL345_FIFO_DEFAULT_ACTION_COUPLED
#define ADXL345_FIFO_DEFAULT_INTERRUPT_FREE_FALL_MAP
#define ADXL345_FIFO_DEFAULT_INTERRUPT_ACTIVITY_MAP
#define ADXL345_FIFO_DEFAULT_ACTION_THRESHOLD
#define ADXL345_FIFO_DEFAULT_INTERRUPT_DOUBLE_TAP_MAP
#define ADXL345_FIFO_DEFAULT_INACTION_THRESHOLD
#define ADXL345_FIFO_DEFAULT_INTERRUPT_ACTIVE_LEVEL
#define ADXL345_FIFO_DEFAULT_OFFSET
#define ADXL345_FIFO_DEFAULT_LATENT
#define ADXL345_FIFO_DEFAULT_INACTION_TIME
#define ADXL345_FIFO_DEFAULT_TRIGGER_PIN
#define ADXL345_FIFO_DEFAULT_SLEEP_FREQUENCY
#define ADXL345_FIFO_DEFAULT_LINK_ACTIVITY_INACTIVITY
#define ADXL345_FIFO_DEFAULT_FREE_FALL_TIME
#define ADXL345_FIFO_DEFAULT_FREE_FALL_THRESHOLD
#define ADXL345_FIFO_DEFAULT_INTERRUPT_SINGLE_TAP_MAP
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_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
adxl345 handle structure definition