LibDriver L3GD20H
Loading...
Searching...
No Matches
driver_l3gd20h_read_test.c
Go to the documentation of this file.
1
37
39#include <stdlib.h>
40
41static l3gd20h_handle_t gs_handle;
42
53uint8_t l3gd20h_read_test(l3gd20h_interface_t interface, l3gd20h_address_t addr_pin, uint32_t times)
54{
55 uint8_t res;
56 float dps_threshold;
57 uint16_t threshold;
58 uint32_t i;
59 l3gd20h_info_t info;
60
61 /* link interface function */
74
75 /* get information */
76 res = l3gd20h_info(&info);
77 if (res != 0)
78 {
79 l3gd20h_interface_debug_print("l3gd20h: get info failed.\n");
80
81 return 1;
82 }
83 else
84 {
85 /* print chip info */
86 l3gd20h_interface_debug_print("l3gd20h: chip is %s.\n", info.chip_name);
87 l3gd20h_interface_debug_print("l3gd20h: manufacturer is %s.\n", info.manufacturer_name);
88 l3gd20h_interface_debug_print("l3gd20h: interface is %s.\n", info.interface);
89 l3gd20h_interface_debug_print("l3gd20h: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
90 l3gd20h_interface_debug_print("l3gd20h: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
91 l3gd20h_interface_debug_print("l3gd20h: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
92 l3gd20h_interface_debug_print("l3gd20h: max current is %0.2fmA.\n", info.max_current_ma);
93 l3gd20h_interface_debug_print("l3gd20h: max temperature is %0.1fC.\n", info.temperature_max);
94 l3gd20h_interface_debug_print("l3gd20h: min temperature is %0.1fC.\n", info.temperature_min);
95 }
96
97 /* start read test */
98 l3gd20h_interface_debug_print("l3gd20h: start read test.\n");
99
100 /* set the interface */
101 res = l3gd20h_set_interface(&gs_handle, interface);
102 if (res != 0)
103 {
104 l3gd20h_interface_debug_print("l3gd20h: set interface failed.\n");
105
106 return 1;
107 }
108
109 /* set the address pin */
110 res = l3gd20h_set_addr_pin(&gs_handle, addr_pin);
111 if (res != 0)
112 {
113 l3gd20h_interface_debug_print("l3gd20h: set addr pin failed.\n");
114
115 return 1;
116 }
117
118 /* init the l3gd20h */
119 res = l3gd20h_init(&gs_handle);
120 if (res != 0)
121 {
122 l3gd20h_interface_debug_print("l3gd20h: init failed.\n");
123
124 return 1;
125 }
126
127 /* set normal boot */
128 res = l3gd20h_set_boot(&gs_handle, L3GD20H_BOOT_NORMAL);
129 if (res != 0)
130 {
131 l3gd20h_interface_debug_print("l3gd20h: set boot failed.\n");
132 (void)l3gd20h_deinit(&gs_handle);
133
134 return 1;
135 }
136
137 /* enable x axis*/
139 if (res != 0)
140 {
141 l3gd20h_interface_debug_print("l3gd20h: set axis failed.\n");
142 (void)l3gd20h_deinit(&gs_handle);
143
144 return 1;
145 }
146
147 /* enable y axis*/
149 if (res != 0)
150 {
151 l3gd20h_interface_debug_print("l3gd20h: set axis failed.\n");
152 (void)l3gd20h_deinit(&gs_handle);
153
154 return 1;
155 }
156
157 /* enable z axis*/
159 if (res != 0)
160 {
161 l3gd20h_interface_debug_print("l3gd20h: set axis failed.\n");
162 (void)l3gd20h_deinit(&gs_handle);
163
164 return 1;
165 }
166
167 /* set 100 Hz rate bandwidth 12.5 Hz */
169 if (res != 0)
170 {
171 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
172 (void)l3gd20h_deinit(&gs_handle);
173
174 return 1;
175 }
176
177 /* disable edge trigger */
179 if (res != 0)
180 {
181 l3gd20h_interface_debug_print("l3gd20h: set edge trigger failed.\n");
182 (void)l3gd20h_deinit(&gs_handle);
183
184 return 1;
185 }
186
187 /* disable level trigger */
189 if (res != 0)
190 {
191 l3gd20h_interface_debug_print("l3gd20h: set level trigger failed.\n");
192 (void)l3gd20h_deinit(&gs_handle);
193
194 return 1;
195 }
196
197 /* enable latched */
199 if (res != 0)
200 {
201 l3gd20h_interface_debug_print("l3gd20h: set level sensitive latched failed.\n");
202 (void)l3gd20h_deinit(&gs_handle);
203
204 return 1;
205 }
206
207 /* normal mode */
209 if (res != 0)
210 {
211 l3gd20h_interface_debug_print("l3gd20h: set self test failed.\n");
212 (void)l3gd20h_deinit(&gs_handle);
213
214 return 1;
215 }
216
217 /* set high pass filter normal mode */
219 if (res != 0)
220 {
221 l3gd20h_interface_debug_print("l3gd20h: set high pass filter normal mode failed.\n");
222 (void)l3gd20h_deinit(&gs_handle);
223
224 return 1;
225 }
226
227 /* set high pass filter cut-off frequency 0 */
229 if (res != 0)
230 {
231 l3gd20h_interface_debug_print("l3gd20h: set high pass filter cut off frequency failed.\n");
232 (void)l3gd20h_deinit(&gs_handle);
233
234 return 1;
235 }
236
237 /* enable high pass filter */
239 if (res != 0)
240 {
241 l3gd20h_interface_debug_print("l3gd20h: set high pass filter failed.\n");
242 (void)l3gd20h_deinit(&gs_handle);
243
244 return 1;
245 }
246
247 /* disable block data update */
249 if (res != 0)
250 {
251 l3gd20h_interface_debug_print("l3gd20h: set block data update failed.\n");
252 (void)l3gd20h_deinit(&gs_handle);
253
254 return 1;
255 }
256
257 /* set LPF1-HPF-LPF2 */
259 if (res != 0)
260 {
261 l3gd20h_interface_debug_print("l3gd20h: set out selection failed.\n");
262 (void)l3gd20h_deinit(&gs_handle);
263
264 return 1;
265 }
266
267 /* set LPF1-HPF-LPF2 */
269 if (res != 0)
270 {
271 l3gd20h_interface_debug_print("l3gd20h: set interrupt selection failed.\n");
272 (void)l3gd20h_deinit(&gs_handle);
273
274 return 1;
275 }
276
277 /* set high pass filter reference 0x00 */
278 res = l3gd20h_set_high_pass_filter_reference(&gs_handle, 0x00);
279 if (res != 0)
280 {
281 l3gd20h_interface_debug_print("l3gd20h: set high pass filter reference failed.\n");
282 (void)l3gd20h_deinit(&gs_handle);
283
284 return 1;
285 }
286
287 /* bypass mode */
289 if (res != 0)
290 {
291 l3gd20h_interface_debug_print("l3gd20h: set fifo mode failed.\n");
292 (void)l3gd20h_deinit(&gs_handle);
293
294 return 1;
295 }
296
297 /* disable interrupt 1*/
299 if (res != 0)
300 {
301 l3gd20h_interface_debug_print("l3gd20h: set interrupt1 failed.\n");
302 (void)l3gd20h_deinit(&gs_handle);
303
304 return 1;
305 }
306
307 /* disable boot on interrupt 1*/
309 if (res != 0)
310 {
311 l3gd20h_interface_debug_print("l3gd20h: set boot on interrupt1 failed.\n");
312 (void)l3gd20h_deinit(&gs_handle);
313
314 return 1;
315 }
316
317 /* active level low */
319 if (res != 0)
320 {
321 l3gd20h_interface_debug_print("l3gd20h: set interrupt active level failed.\n");
322 (void)l3gd20h_deinit(&gs_handle);
323
324 return 1;
325 }
326
327 /* push-pull pin type */
329 if (res != 0)
330 {
331 l3gd20h_interface_debug_print("l3gd20h: set interrupt pin type failed.\n");
332 (void)l3gd20h_deinit(&gs_handle);
333
334 return 1;
335 }
336
337 /* disable data ready on interrupt2 */
339 if (res != 0)
340 {
341 l3gd20h_interface_debug_print("l3gd20h: set data ready on interrupt2 failed.\n");
342 (void)l3gd20h_deinit(&gs_handle);
343
344 return 1;
345 }
346
347 /* fifo threshold on interrupt2 */
349 if (res != 0)
350 {
351 l3gd20h_interface_debug_print("l3gd20h: set fifo threshold on interrupt2 failed.\n");
352 (void)l3gd20h_deinit(&gs_handle);
353
354 return 1;
355 }
356
357 /* fifo overrun on interrupt2 */
359 if (res != 0)
360 {
361 l3gd20h_interface_debug_print("l3gd20h: set fifo overrun on interrupt2 failed.\n");
362 (void)l3gd20h_deinit(&gs_handle);
363
364 return 1;
365 }
366
367 /* fifo empty on interrupt2 */
369 if (res != 0)
370 {
371 l3gd20h_interface_debug_print("l3gd20h: set fifo empty on interrupt2 failed.\n");
372 (void)l3gd20h_deinit(&gs_handle);
373
374 return 1;
375 }
376
377 /* disable L3GD20H_INTERRUPT_EVENT_AND_OR_COMBINATION */
379 if (res != 0)
380 {
381 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
382 (void)l3gd20h_deinit(&gs_handle);
383
384 return 1;
385 }
386
387 /* disable L3GD20H_INTERRUPT_EVENT_LATCH */
389 if (res != 0)
390 {
391 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
392 (void)l3gd20h_deinit(&gs_handle);
393
394 return 1;
395 }
396
397 /* disable L3GD20H_INTERRUPT_EVENT_Z_HIGH_EVENT */
399 if (res != 0)
400 {
401 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
402 (void)l3gd20h_deinit(&gs_handle);
403
404 return 1;
405 }
406
407 /* disable L3GD20H_INTERRUPT_EVENT_Z_LOW_EVENT */
409 if (res != 0)
410 {
411 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
412 (void)l3gd20h_deinit(&gs_handle);
413
414 return 1;
415 }
416
417 /* disable L3GD20H_INTERRUPT_EVENT_Y_HIGH_EVENT */
419 if (res != 0)
420 {
421 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
422 (void)l3gd20h_deinit(&gs_handle);
423
424 return 1;
425 }
426
427 /* disable L3GD20H_INTERRUPT_EVENT_Y_LOW_EVENT */
429 if (res != 0)
430 {
431 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
432 (void)l3gd20h_deinit(&gs_handle);
433
434 return 1;
435 }
436
437 /* disable L3GD20H_INTERRUPT_EVENT_X_HIGH_EVENT */
439 if (res != 0)
440 {
441 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
442 (void)l3gd20h_deinit(&gs_handle);
443
444 return 1;
445 }
446
447 /* disable L3GD20H_INTERRUPT_EVENT_X_LOW_EVENT */
449 if (res != 0)
450 {
451 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
452 (void)l3gd20h_deinit(&gs_handle);
453
454 return 1;
455 }
456
457 /* 0.0f */
458 dps_threshold = 0.0f;
459 res = l3gd20h_interrupt_threshold_convert_to_register(&gs_handle, dps_threshold, (uint16_t *)&threshold);
460 if (res != 0)
461 {
462 l3gd20h_interface_debug_print("l3gd20h: convert to register failed.\n");
463 (void)l3gd20h_deinit(&gs_handle);
464
465 return 1;
466 }
467
468 /* set x interrupt threshold */
469 res = l3gd20h_set_x_interrupt_threshold(&gs_handle, threshold);
470 if (res != 0)
471 {
472 l3gd20h_interface_debug_print("l3gd20h: set x interrupt threshold failed.\n");
473 (void)l3gd20h_deinit(&gs_handle);
474
475 return 1;
476 }
477
478 /* set y interrupt threshold */
479 res = l3gd20h_set_y_interrupt_threshold(&gs_handle, threshold);
480 if (res != 0)
481 {
482 l3gd20h_interface_debug_print("l3gd20h: set y interrupt threshold failed.\n");
483 (void)l3gd20h_deinit(&gs_handle);
484
485 return 1;
486 }
487
488 /* set z interrupt threshold */
489 res = l3gd20h_set_z_interrupt_threshold(&gs_handle, threshold);
490 if (res != 0)
491 {
492 l3gd20h_interface_debug_print("l3gd20h: set z interrupt threshold failed.\n");
493 (void)l3gd20h_deinit(&gs_handle);
494
495 return 1;
496 }
497
498 /* reset counter mode */
500 if (res != 0)
501 {
502 l3gd20h_interface_debug_print("l3gd20h: set counter mode failed.\n");
503 (void)l3gd20h_deinit(&gs_handle);
504
505 return 1;
506 }
507
508 /* enable wait */
509 res = l3gd20h_set_wait(&gs_handle, L3GD20H_BOOL_TRUE);
510 if (res != 0)
511 {
512 l3gd20h_interface_debug_print("l3gd20h: set wait failed.\n");
513 (void)l3gd20h_deinit(&gs_handle);
514
515 return 1;
516 }
517
518 /* set duration 0x01 */
519 res = l3gd20h_set_duration(&gs_handle, 0x01);
520 if (res != 0)
521 {
522 l3gd20h_interface_debug_print("l3gd20h: set duration failed.\n");
523 (void)l3gd20h_deinit(&gs_handle);
524
525 return 1;
526 }
527
528 /* set data ready active level low */
530 if (res != 0)
531 {
532 l3gd20h_interface_debug_print("l3gd20h: set data ready active level failed.\n");
533 (void)l3gd20h_deinit(&gs_handle);
534
535 return 1;
536 }
537
538 /* disable fifo */
539 res = l3gd20h_set_fifo(&gs_handle, L3GD20H_BOOL_FALSE);
540 if (res != 0)
541 {
542 l3gd20h_interface_debug_print("l3gd20h: set fifo failed.\n");
543 (void)l3gd20h_deinit(&gs_handle);
544
545 return 1;
546 }
547
548 /* enable stop on fifo threshold */
550 if (res != 0)
551 {
552 l3gd20h_interface_debug_print("l3gd20h: set stop on fifo threshold failed.\n");
553 (void)l3gd20h_deinit(&gs_handle);
554
555 return 1;
556 }
557
558 /* fifo threshold 16 */
559 res = l3gd20h_set_fifo_threshold(&gs_handle, 16);
560 if (res != 0)
561 {
562 l3gd20h_interface_debug_print("l3gd20h: set fifo threshold failed.\n");
563 (void)l3gd20h_deinit(&gs_handle);
564
565 return 1;
566 }
567
568 /* little endian */
570 if (res != 0)
571 {
572 l3gd20h_interface_debug_print("l3gd20h: set data format failed.\n");
573 (void)l3gd20h_deinit(&gs_handle);
574
575 return 1;
576 }
577
578 /* ±245 dps */
580 if (res != 0)
581 {
582 l3gd20h_interface_debug_print("l3gd20h: set full scale failed.\n");
583 (void)l3gd20h_deinit(&gs_handle);
584
585 return 1;
586 }
587
588 /* normal mode */
589 res = l3gd20h_set_mode(&gs_handle, L3GD20H_MODE_NORMAL);
590 if (res != 0)
591 {
592 l3gd20h_interface_debug_print("l3gd20h: set mode failed.\n");
593 (void)l3gd20h_deinit(&gs_handle);
594
595 return 1;
596 }
597
598 /* ±245 dps */
600 if (res != 0)
601 {
602 l3gd20h_interface_debug_print("l3gd20h: set full scale failed.\n");
603 (void)l3gd20h_deinit(&gs_handle);
604
605 return 1;
606 }
608
609 /* ±245 dps */
610 l3gd20h_interface_debug_print("l3gd20h: set full scale 245 dps.\n");
611 for (i = 0; i < times; i++)
612 {
613 int16_t raw[1][3];
614 float dps[1][3];
615 uint16_t len;
616
617 len = 1;
618 res = l3gd20h_read(&gs_handle, (int16_t (*)[3])(raw), (float (*)[3])(dps), (uint16_t *)&len);
619 if (res != 0)
620 {
621 l3gd20h_interface_debug_print("l3gd20h: read failed.\n");
622 (void)l3gd20h_deinit(&gs_handle);
623
624 return 1;
625 }
626 l3gd20h_interface_debug_print("l3gd20h: x %0.2f dps.\n", dps[0][0]);
627 l3gd20h_interface_debug_print("l3gd20h: y %0.2f dps.\n", dps[0][1]);
628 l3gd20h_interface_debug_print("l3gd20h: z %0.2f dps.\n", dps[0][2]);
630 }
631
632 /* ±500 dps */
634 if (res != 0)
635 {
636 l3gd20h_interface_debug_print("l3gd20h: set full scale failed.\n");
637 (void)l3gd20h_deinit(&gs_handle);
638
639 return 1;
640 }
642
643 /* ±500 dps */
644 l3gd20h_interface_debug_print("l3gd20h: set full scale 500 dps.\n");
645 for (i = 0; i < times; i++)
646 {
647 int16_t raw[1][3];
648 float dps[1][3];
649 uint16_t len;
650
651 len = 1;
652 res = l3gd20h_read(&gs_handle, (int16_t (*)[3])(raw), (float (*)[3])(dps), (uint16_t *)&len);
653 if (res != 0)
654 {
655 l3gd20h_interface_debug_print("l3gd20h: read failed.\n");
656 (void)l3gd20h_deinit(&gs_handle);
657
658 return 1;
659 }
660 l3gd20h_interface_debug_print("l3gd20h: x %0.2f dps.\n", dps[0][0]);
661 l3gd20h_interface_debug_print("l3gd20h: y %0.2f dps.\n", dps[0][1]);
662 l3gd20h_interface_debug_print("l3gd20h: z %0.2f dps.\n", dps[0][2]);
664 }
665
666 /* ±2000 dps */
668 if (res != 0)
669 {
670 l3gd20h_interface_debug_print("l3gd20h: set full scale failed.\n");
671 (void)l3gd20h_deinit(&gs_handle);
672
673 return 1;
674 }
676
677 /* ±2000 dps */
678 l3gd20h_interface_debug_print("l3gd20h: set full scale 2000 dps.\n");
679 for (i = 0; i < times; i++)
680 {
681 int16_t raw[1][3];
682 float dps[1][3];
683 uint16_t len;
684
685 len = 1;
686 res = l3gd20h_read(&gs_handle, (int16_t (*)[3])(raw), (float (*)[3])(dps), (uint16_t *)&len);
687 if (res != 0)
688 {
689 l3gd20h_interface_debug_print("l3gd20h: read failed.\n");
690 (void)l3gd20h_deinit(&gs_handle);
691
692 return 1;
693 }
694 l3gd20h_interface_debug_print("l3gd20h: x %0.2f dps.\n", dps[0][0]);
695 l3gd20h_interface_debug_print("l3gd20h: y %0.2f dps.\n", dps[0][1]);
696 l3gd20h_interface_debug_print("l3gd20h: z %0.2f dps.\n", dps[0][2]);
698 }
699
700 /* big endian */
702 if (res != 0)
703 {
704 l3gd20h_interface_debug_print("l3gd20h: set data format failed.\n");
705 (void)l3gd20h_deinit(&gs_handle);
706
707 return 1;
708 }
709
710 /* set big endian */
711 l3gd20h_interface_debug_print("l3gd20h: set big endian.\n");
712 for (i = 0; i < times; i++)
713 {
714 int16_t raw[1][3];
715 float dps[1][3];
716 uint16_t len;
717
718 len = 1;
719 res = l3gd20h_read(&gs_handle, (int16_t (*)[3])(raw), (float (*)[3])(dps), (uint16_t *)&len);
720 if (res != 0)
721 {
722 l3gd20h_interface_debug_print("l3gd20h: read failed.\n");
723 (void)l3gd20h_deinit(&gs_handle);
724
725 return 1;
726 }
727 l3gd20h_interface_debug_print("l3gd20h: x %0.2f dps.\n", dps[0][0]);
728 l3gd20h_interface_debug_print("l3gd20h: y %0.2f dps.\n", dps[0][1]);
729 l3gd20h_interface_debug_print("l3gd20h: z %0.2f dps.\n", dps[0][2]);
731 }
732
733 /* read the temperature */
734 l3gd20h_interface_debug_print("l3gd20h: read the temperature.\n");
735 for (i = 0; i < times; i++)
736 {
737 int8_t raw;
738 float temp;
739
740 res = l3gd20h_read_temperature(&gs_handle, (int8_t *)&raw, (float *)&temp);
741 if (res != 0)
742 {
743 l3gd20h_interface_debug_print("l3gd20h: read temperature failed.\n");
744 (void)l3gd20h_deinit(&gs_handle);
745
746 return 1;
747 }
748 l3gd20h_interface_debug_print("l3gd20h: temperature is %0.2fC.\n", temp);
750 }
751
752 /* finish read test */
753 l3gd20h_interface_debug_print("l3gd20h: finish read test.\n");
754 (void)l3gd20h_deinit(&gs_handle);
755
756 return 0;
757}
driver l3gd20h read test header file
uint8_t l3gd20h_set_high_pass_filter(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable high pass filter
uint8_t l3gd20h_set_data_format(l3gd20h_handle_t *handle, l3gd20h_data_format_t data_format)
set the data format
struct l3gd20h_info_s l3gd20h_info_t
l3gd20h information structure definition
uint8_t l3gd20h_set_block_data_update(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the block data update
uint8_t l3gd20h_set_mode(l3gd20h_handle_t *handle, l3gd20h_mode_t mode)
set the chip mode
uint8_t l3gd20h_info(l3gd20h_info_t *info)
get chip's information
uint8_t l3gd20h_read_temperature(l3gd20h_handle_t *handle, int8_t *raw, float *temp)
read the temperature
uint8_t l3gd20h_set_high_pass_filter_mode(l3gd20h_handle_t *handle, l3gd20h_high_pass_filter_mode_t mode)
set the high pass filter mode
uint8_t l3gd20h_set_rate_bandwidth(l3gd20h_handle_t *handle, l3gd20h_lodr_odr_bw_t rate_bandwidth)
set the rate bandwidth
uint8_t l3gd20h_set_level_sensitive_latched(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the level sensitive latched
uint8_t l3gd20h_read(l3gd20h_handle_t *handle, int16_t(*raw)[3], float(*dps)[3], uint16_t *len)
read the data
uint8_t l3gd20h_set_out_selection(l3gd20h_handle_t *handle, l3gd20h_selection_t selection)
set the out selection
uint8_t l3gd20h_set_boot(l3gd20h_handle_t *handle, l3gd20h_boot_t boot)
set the boot
uint8_t l3gd20h_set_addr_pin(l3gd20h_handle_t *handle, l3gd20h_address_t addr_pin)
set the iic address pin
l3gd20h_address_t
l3gd20h address enumeration definition
uint8_t l3gd20h_set_interface(l3gd20h_handle_t *handle, l3gd20h_interface_t interface)
set the chip interface
uint8_t l3gd20h_set_high_pass_filter_reference(l3gd20h_handle_t *handle, uint8_t value)
set the high pass filter reference
uint8_t l3gd20h_deinit(l3gd20h_handle_t *handle)
close the chip
uint8_t l3gd20h_set_edge_trigger(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the edge trigger
l3gd20h_interface_t
l3gd20h interface enumeration definition
uint8_t l3gd20h_set_full_scale(l3gd20h_handle_t *handle, l3gd20h_full_scale_t full_scale)
set the full scale
uint8_t l3gd20h_init(l3gd20h_handle_t *handle)
initialize the chip
uint8_t l3gd20h_set_level_trigger(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the level trigger
uint8_t l3gd20h_set_self_test(l3gd20h_handle_t *handle, l3gd20h_self_test_t self_test)
set the self test
uint8_t l3gd20h_set_high_pass_filter_cut_off_frequency(l3gd20h_handle_t *handle, l3gd20h_high_pass_filter_cut_off_frequency_t frequency)
set the high pass filter cut off frequency
uint8_t l3gd20h_set_axis(l3gd20h_handle_t *handle, l3gd20h_axis_t axis, l3gd20h_bool_t enable)
set the axis
struct l3gd20h_handle_s l3gd20h_handle_t
l3gd20h handle structure definition
@ L3GD20H_BOOT_NORMAL
@ L3GD20H_SELF_TEST_NORMAL
@ L3GD20H_FULL_SCALE_500_DPS
@ L3GD20H_FULL_SCALE_2000_DPS
@ L3GD20H_FULL_SCALE_245_DPS
@ L3GD20H_HIGH_PASS_FILTER_MODE_NORMAL
@ L3GD20H_DATA_FORMAT_LITTLE_ENDIAN
@ L3GD20H_DATA_FORMAT_BIG_ENDIAN
@ L3GD20H_HIGH_PASS_FILTER_CUT_OFF_FREQUENCY_0
@ L3GD20H_AXIS_X
@ L3GD20H_AXIS_Z
@ L3GD20H_AXIS_Y
@ L3GD20H_SELECTION_LPF1_HPF_LPF2
@ L3GD20H_MODE_NORMAL
@ L3GD20H_BOOL_FALSE
@ L3GD20H_BOOL_TRUE
@ L3GD20H_LOW_ODR_0_ODR_100HZ_BW_0_12P5HZ
uint8_t l3gd20h_set_stop_on_fifo_threshold(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable stop on fifo threshold
uint8_t l3gd20h_set_fifo_mode(l3gd20h_handle_t *handle, l3gd20h_fifo_mode_t fifo_mode)
set the fifo mode
uint8_t l3gd20h_set_fifo(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the fifo
uint8_t l3gd20h_set_fifo_threshold(l3gd20h_handle_t *handle, uint8_t threshold)
set the fifo threshold
@ L3GD20H_FIFO_MODE_BYPASS
void l3gd20h_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t l3gd20h_interface_iic_deinit(void)
interface iic bus deinit
uint8_t l3gd20h_interface_spi_read(uint8_t reg, uint8_t *buf, uint16_t len)
interface spi bus read
uint8_t l3gd20h_interface_iic_init(void)
interface iic bus init
uint8_t l3gd20h_interface_iic_read(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus read
uint8_t l3gd20h_interface_spi_init(void)
interface spi bus init
uint8_t l3gd20h_interface_iic_write(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus write
uint8_t l3gd20h_interface_spi_write(uint8_t reg, uint8_t *buf, uint16_t len)
interface spi bus write
uint8_t l3gd20h_interface_spi_deinit(void)
interface spi bus deinit
void l3gd20h_interface_receive_callback(uint8_t type)
interface receive callback
void l3gd20h_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t l3gd20h_set_interrupt_pin_type(l3gd20h_handle_t *handle, l3gd20h_pin_type_t pin_type)
set the interrupt pin type
uint8_t l3gd20h_set_data_ready_on_interrupt2(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the data ready on interrupt2
uint8_t l3gd20h_set_boot_on_interrupt1(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable boot on the interrupt1
uint8_t l3gd20h_set_x_interrupt_threshold(l3gd20h_handle_t *handle, uint16_t threshold)
set the x interrupt threshold
uint8_t l3gd20h_set_wait(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the wait
uint8_t l3gd20h_set_interrupt_event(l3gd20h_handle_t *handle, l3gd20h_interrupt_event_t interrupt_event, l3gd20h_bool_t enable)
set the interrupt event
uint8_t l3gd20h_set_duration(l3gd20h_handle_t *handle, uint8_t duration)
set the wait duration
uint8_t l3gd20h_set_fifo_threshold_on_interrupt2(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the fifo threshold on interrupt2
uint8_t l3gd20h_set_data_ready_active_level(l3gd20h_handle_t *handle, l3gd20h_interrupt_active_level_t level)
set the data ready active level
uint8_t l3gd20h_set_counter_mode(l3gd20h_handle_t *handle, l3gd20h_counter_mode_t counter_mode)
set the counter mode
uint8_t l3gd20h_set_interrupt_active_level(l3gd20h_handle_t *handle, l3gd20h_interrupt_active_level_t level)
set the interrupt active level
uint8_t l3gd20h_set_fifo_overrun_on_interrupt2(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the fifo overrun on interrupt2
uint8_t l3gd20h_interrupt_threshold_convert_to_register(l3gd20h_handle_t *handle, float dps, uint16_t *reg)
convert the interrupt threshold real data to the register raw data
uint8_t l3gd20h_set_interrupt_selection(l3gd20h_handle_t *handle, l3gd20h_selection_t selection)
set the interrupt selection
uint8_t l3gd20h_set_fifo_empty_on_interrupt2(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the fifo empty on interrupt2
uint8_t l3gd20h_set_z_interrupt_threshold(l3gd20h_handle_t *handle, uint16_t threshold)
set the z interrupt threshold
uint8_t l3gd20h_set_interrupt1(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the interrupt1
uint8_t l3gd20h_set_y_interrupt_threshold(l3gd20h_handle_t *handle, uint16_t threshold)
set the y interrupt threshold
@ L3GD20H_INTERRUPT_EVENT_Z_LOW_EVENT
@ L3GD20H_INTERRUPT_EVENT_Y_HIGH_EVENT
@ L3GD20H_INTERRUPT_EVENT_Y_LOW_EVENT
@ L3GD20H_INTERRUPT_EVENT_AND_OR_COMBINATION
@ L3GD20H_INTERRUPT_EVENT_LATCH
@ L3GD20H_INTERRUPT_EVENT_X_LOW_EVENT
@ L3GD20H_INTERRUPT_EVENT_Z_HIGH_EVENT
@ L3GD20H_INTERRUPT_EVENT_X_HIGH_EVENT
@ L3GD20H_COUNTER_MODE_RESET
@ L3GD20H_INTERRUPT_ACTIVE_LEVEL_LOW
@ L3GD20H_PIN_PUSH_PULL
uint8_t l3gd20h_read_test(l3gd20h_interface_t interface, l3gd20h_address_t addr_pin, uint32_t times)
read test
uint32_t driver_version
char manufacturer_name[32]