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, i;
58 l3gd20h_info_t info;
59
60 /* link interface function */
73
74 /* get information */
75 res = l3gd20h_info(&info);
76 if (res != 0)
77 {
78 l3gd20h_interface_debug_print("l3gd20h: get info failed.\n");
79
80 return 1;
81 }
82 else
83 {
84 /* print chip info */
85 l3gd20h_interface_debug_print("l3gd20h: chip is %s.\n", info.chip_name);
86 l3gd20h_interface_debug_print("l3gd20h: manufacturer is %s.\n", info.manufacturer_name);
87 l3gd20h_interface_debug_print("l3gd20h: interface is %s.\n", info.interface);
88 l3gd20h_interface_debug_print("l3gd20h: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
89 l3gd20h_interface_debug_print("l3gd20h: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
90 l3gd20h_interface_debug_print("l3gd20h: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
91 l3gd20h_interface_debug_print("l3gd20h: max current is %0.2fmA.\n", info.max_current_ma);
92 l3gd20h_interface_debug_print("l3gd20h: max temperature is %0.1fC.\n", info.temperature_max);
93 l3gd20h_interface_debug_print("l3gd20h: min temperature is %0.1fC.\n", info.temperature_min);
94 }
95
96 /* start read test */
97 l3gd20h_interface_debug_print("l3gd20h: start read test.\n");
98
99 /* set the interface */
100 res = l3gd20h_set_interface(&gs_handle, interface);
101 if (res != 0)
102 {
103 l3gd20h_interface_debug_print("l3gd20h: set interface failed.\n");
104
105 return 1;
106 }
107
108 /* set the address pin */
109 res = l3gd20h_set_addr_pin(&gs_handle, addr_pin);
110 if (res != 0)
111 {
112 l3gd20h_interface_debug_print("l3gd20h: set addr pin failed.\n");
113
114 return 1;
115 }
116
117 /* init the l3gd20h */
118 res = l3gd20h_init(&gs_handle);
119 if (res != 0)
120 {
121 l3gd20h_interface_debug_print("l3gd20h: init failed.\n");
122
123 return 1;
124 }
125
126 /* set normal boot */
127 res = l3gd20h_set_boot(&gs_handle, L3GD20H_BOOT_NORMAL);
128 if (res != 0)
129 {
130 l3gd20h_interface_debug_print("l3gd20h: set boot failed.\n");
131 (void)l3gd20h_deinit(&gs_handle);
132
133 return 1;
134 }
135
136 /* enable x axis*/
138 if (res != 0)
139 {
140 l3gd20h_interface_debug_print("l3gd20h: set axis failed.\n");
141 (void)l3gd20h_deinit(&gs_handle);
142
143 return 1;
144 }
145
146 /* enable y axis*/
148 if (res != 0)
149 {
150 l3gd20h_interface_debug_print("l3gd20h: set axis failed.\n");
151 (void)l3gd20h_deinit(&gs_handle);
152
153 return 1;
154 }
155
156 /* enable z axis*/
158 if (res != 0)
159 {
160 l3gd20h_interface_debug_print("l3gd20h: set axis failed.\n");
161 (void)l3gd20h_deinit(&gs_handle);
162
163 return 1;
164 }
165
166 /* set 100 Hz rate bandwidth 12.5 Hz */
168 if (res != 0)
169 {
170 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
171 (void)l3gd20h_deinit(&gs_handle);
172
173 return 1;
174 }
175
176 /* disable edge trigger */
178 if (res != 0)
179 {
180 l3gd20h_interface_debug_print("l3gd20h: set edge trigger failed.\n");
181 (void)l3gd20h_deinit(&gs_handle);
182
183 return 1;
184 }
185
186 /* disable level trigger */
188 if (res != 0)
189 {
190 l3gd20h_interface_debug_print("l3gd20h: set level trigger failed.\n");
191 (void)l3gd20h_deinit(&gs_handle);
192
193 return 1;
194 }
195
196 /* enable latched */
198 if (res != 0)
199 {
200 l3gd20h_interface_debug_print("l3gd20h: set level sensitive latched failed.\n");
201 (void)l3gd20h_deinit(&gs_handle);
202
203 return 1;
204 }
205
206 /* normal mode */
208 if (res != 0)
209 {
210 l3gd20h_interface_debug_print("l3gd20h: set self test failed.\n");
211 (void)l3gd20h_deinit(&gs_handle);
212
213 return 1;
214 }
215
216 /* set high pass filter normal mode */
218 if (res != 0)
219 {
220 l3gd20h_interface_debug_print("l3gd20h: set high pass filter normal mode failed.\n");
221 (void)l3gd20h_deinit(&gs_handle);
222
223 return 1;
224 }
225
226 /* set high pass filter cut-off frequency 0 */
228 if (res != 0)
229 {
230 l3gd20h_interface_debug_print("l3gd20h: set high pass filter cut off frequency failed.\n");
231 (void)l3gd20h_deinit(&gs_handle);
232
233 return 1;
234 }
235
236 /* enable high pass filter */
238 if (res != 0)
239 {
240 l3gd20h_interface_debug_print("l3gd20h: set high pass filter failed.\n");
241 (void)l3gd20h_deinit(&gs_handle);
242
243 return 1;
244 }
245
246 /* disable block data update */
248 if (res != 0)
249 {
250 l3gd20h_interface_debug_print("l3gd20h: set block data update failed.\n");
251 (void)l3gd20h_deinit(&gs_handle);
252
253 return 1;
254 }
255
256 /* set LPF1-HPF-LPF2 */
258 if (res != 0)
259 {
260 l3gd20h_interface_debug_print("l3gd20h: set out selection failed.\n");
261 (void)l3gd20h_deinit(&gs_handle);
262
263 return 1;
264 }
265
266 /* set LPF1-HPF-LPF2 */
268 if (res != 0)
269 {
270 l3gd20h_interface_debug_print("l3gd20h: set interrupt selection failed.\n");
271 (void)l3gd20h_deinit(&gs_handle);
272
273 return 1;
274 }
275
276 /* set high pass filter reference 0x00 */
277 res = l3gd20h_set_high_pass_filter_reference(&gs_handle, 0x00);
278 if (res != 0)
279 {
280 l3gd20h_interface_debug_print("l3gd20h: set high pass filter reference failed.\n");
281 (void)l3gd20h_deinit(&gs_handle);
282
283 return 1;
284 }
285
286 /* bypass mode */
288 if (res != 0)
289 {
290 l3gd20h_interface_debug_print("l3gd20h: set fifo mode failed.\n");
291 (void)l3gd20h_deinit(&gs_handle);
292
293 return 1;
294 }
295
296 /* disable interrupt 1*/
298 if (res != 0)
299 {
300 l3gd20h_interface_debug_print("l3gd20h: set interrupt1 failed.\n");
301 (void)l3gd20h_deinit(&gs_handle);
302
303 return 1;
304 }
305
306 /* disable boot on interrupt 1*/
308 if (res != 0)
309 {
310 l3gd20h_interface_debug_print("l3gd20h: set boot on interrupt1 failed.\n");
311 (void)l3gd20h_deinit(&gs_handle);
312
313 return 1;
314 }
315
316 /* active level low */
318 if (res != 0)
319 {
320 l3gd20h_interface_debug_print("l3gd20h: set interrupt active level failed.\n");
321 (void)l3gd20h_deinit(&gs_handle);
322
323 return 1;
324 }
325
326 /* push-pull pin type */
328 if (res != 0)
329 {
330 l3gd20h_interface_debug_print("l3gd20h: set interrupt pin type failed.\n");
331 (void)l3gd20h_deinit(&gs_handle);
332
333 return 1;
334 }
335
336 /* disable data ready on interrupt2 */
338 if (res != 0)
339 {
340 l3gd20h_interface_debug_print("l3gd20h: set data ready on interrupt2 failed.\n");
341 (void)l3gd20h_deinit(&gs_handle);
342
343 return 1;
344 }
345
346 /* fifo threshold on interrupt2 */
348 if (res != 0)
349 {
350 l3gd20h_interface_debug_print("l3gd20h: set fifo threshold on interrupt2 failed.\n");
351 (void)l3gd20h_deinit(&gs_handle);
352
353 return 1;
354 }
355
356 /* fifo overrun on interrupt2 */
358 if (res != 0)
359 {
360 l3gd20h_interface_debug_print("l3gd20h: set fifo overrun on interrupt2 failed.\n");
361 (void)l3gd20h_deinit(&gs_handle);
362
363 return 1;
364 }
365
366 /* fifo empty on interrupt2 */
368 if (res != 0)
369 {
370 l3gd20h_interface_debug_print("l3gd20h: set fifo empty on interrupt2 failed.\n");
371 (void)l3gd20h_deinit(&gs_handle);
372
373 return 1;
374 }
375
376 /* disable L3GD20H_INTERRUPT_EVENT_AND_OR_COMBINATION */
378 if (res != 0)
379 {
380 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
381 (void)l3gd20h_deinit(&gs_handle);
382
383 return 1;
384 }
385
386 /* disable L3GD20H_INTERRUPT_EVENT_LATCH */
388 if (res != 0)
389 {
390 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
391 (void)l3gd20h_deinit(&gs_handle);
392
393 return 1;
394 }
395
396 /* disable L3GD20H_INTERRUPT_EVENT_Z_HIGH_EVENT */
398 if (res != 0)
399 {
400 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
401 (void)l3gd20h_deinit(&gs_handle);
402
403 return 1;
404 }
405
406 /* disable L3GD20H_INTERRUPT_EVENT_Z_LOW_EVENT */
408 if (res != 0)
409 {
410 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
411 (void)l3gd20h_deinit(&gs_handle);
412
413 return 1;
414 }
415
416 /* disable L3GD20H_INTERRUPT_EVENT_Y_HIGH_EVENT */
418 if (res != 0)
419 {
420 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
421 (void)l3gd20h_deinit(&gs_handle);
422
423 return 1;
424 }
425
426 /* disable L3GD20H_INTERRUPT_EVENT_Y_LOW_EVENT */
428 if (res != 0)
429 {
430 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
431 (void)l3gd20h_deinit(&gs_handle);
432
433 return 1;
434 }
435
436 /* disable L3GD20H_INTERRUPT_EVENT_X_HIGH_EVENT */
438 if (res != 0)
439 {
440 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
441 (void)l3gd20h_deinit(&gs_handle);
442
443 return 1;
444 }
445
446 /* disable L3GD20H_INTERRUPT_EVENT_X_LOW_EVENT */
448 if (res != 0)
449 {
450 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
451 (void)l3gd20h_deinit(&gs_handle);
452
453 return 1;
454 }
455
456 /* 0.0f */
457 dps_threshold = 0.0f;
458 res = l3gd20h_interrupt_threshold_convert_to_register(&gs_handle, dps_threshold, (uint16_t *)&threshold);
459 if (res != 0)
460 {
461 l3gd20h_interface_debug_print("l3gd20h: convert to register failed.\n");
462 (void)l3gd20h_deinit(&gs_handle);
463
464 return 1;
465 }
466
467 /* set x interrupt threshold */
468 res = l3gd20h_set_x_interrupt_threshold(&gs_handle, threshold);
469 if (res != 0)
470 {
471 l3gd20h_interface_debug_print("l3gd20h: set x interrupt threshold failed.\n");
472 (void)l3gd20h_deinit(&gs_handle);
473
474 return 1;
475 }
476
477 /* set y interrupt threshold */
478 res = l3gd20h_set_y_interrupt_threshold(&gs_handle, threshold);
479 if (res != 0)
480 {
481 l3gd20h_interface_debug_print("l3gd20h: set y interrupt threshold failed.\n");
482 (void)l3gd20h_deinit(&gs_handle);
483
484 return 1;
485 }
486
487 /* set z interrupt threshold */
488 res = l3gd20h_set_z_interrupt_threshold(&gs_handle, threshold);
489 if (res != 0)
490 {
491 l3gd20h_interface_debug_print("l3gd20h: set z interrupt threshold failed.\n");
492 (void)l3gd20h_deinit(&gs_handle);
493
494 return 1;
495 }
496
497 /* reset counter mode */
499 if (res != 0)
500 {
501 l3gd20h_interface_debug_print("l3gd20h: set counter mode failed.\n");
502 (void)l3gd20h_deinit(&gs_handle);
503
504 return 1;
505 }
506
507 /* enable wait */
508 res = l3gd20h_set_wait(&gs_handle, L3GD20H_BOOL_TRUE);
509 if (res != 0)
510 {
511 l3gd20h_interface_debug_print("l3gd20h: set wait failed.\n");
512 (void)l3gd20h_deinit(&gs_handle);
513
514 return 1;
515 }
516
517 /* set duration 0x01 */
518 res = l3gd20h_set_duration(&gs_handle, 0x01);
519 if (res != 0)
520 {
521 l3gd20h_interface_debug_print("l3gd20h: set duration failed.\n");
522 (void)l3gd20h_deinit(&gs_handle);
523
524 return 1;
525 }
526
527 /* set data ready active level low */
529 if (res != 0)
530 {
531 l3gd20h_interface_debug_print("l3gd20h: set data ready active level failed.\n");
532 (void)l3gd20h_deinit(&gs_handle);
533
534 return 1;
535 }
536
537 /* disable fifo */
538 res = l3gd20h_set_fifo(&gs_handle, L3GD20H_BOOL_FALSE);
539 if (res != 0)
540 {
541 l3gd20h_interface_debug_print("l3gd20h: set fifo failed.\n");
542 (void)l3gd20h_deinit(&gs_handle);
543
544 return 1;
545 }
546
547 /* enable stop on fifo threshold */
549 if (res != 0)
550 {
551 l3gd20h_interface_debug_print("l3gd20h: set stop on fifo threshold failed.\n");
552 (void)l3gd20h_deinit(&gs_handle);
553
554 return 1;
555 }
556
557 /* fifo threshold 16 */
558 res = l3gd20h_set_fifo_threshold(&gs_handle, 16);
559 if (res != 0)
560 {
561 l3gd20h_interface_debug_print("l3gd20h: set fifo threshold failed.\n");
562 (void)l3gd20h_deinit(&gs_handle);
563
564 return 1;
565 }
566
567 /* little endian */
569 if (res != 0)
570 {
571 l3gd20h_interface_debug_print("l3gd20h: set data format failed.\n");
572 (void)l3gd20h_deinit(&gs_handle);
573
574 return 1;
575 }
576
577 /* ±245 dps */
579 if (res != 0)
580 {
581 l3gd20h_interface_debug_print("l3gd20h: set full scale failed.\n");
582 (void)l3gd20h_deinit(&gs_handle);
583
584 return 1;
585 }
586
587 /* normal mode */
588 res = l3gd20h_set_mode(&gs_handle, L3GD20H_MODE_NORMAL);
589 if (res != 0)
590 {
591 l3gd20h_interface_debug_print("l3gd20h: set mode failed.\n");
592 (void)l3gd20h_deinit(&gs_handle);
593
594 return 1;
595 }
596
597 /* ±245 dps */
599 if (res != 0)
600 {
601 l3gd20h_interface_debug_print("l3gd20h: set full scale failed.\n");
602 (void)l3gd20h_deinit(&gs_handle);
603
604 return 1;
605 }
607
608 /* ±245 dps */
609 l3gd20h_interface_debug_print("l3gd20h: set full scale 245 dps.\n");
610 for (i = 0; i < times; i++)
611 {
612 int16_t raw[1][3];
613 float dps[1][3];
614 uint16_t len;
615
616 len = 1;
617 res = l3gd20h_read(&gs_handle, (int16_t (*)[3])(raw), (float (*)[3])(dps), (uint16_t *)&len);
618 if (res != 0)
619 {
620 l3gd20h_interface_debug_print("l3gd20h: read failed.\n");
621 (void)l3gd20h_deinit(&gs_handle);
622
623 return 1;
624 }
625 l3gd20h_interface_debug_print("l3gd20h: x %0.2f dps.\n", dps[0][0]);
626 l3gd20h_interface_debug_print("l3gd20h: y %0.2f dps.\n", dps[0][1]);
627 l3gd20h_interface_debug_print("l3gd20h: z %0.2f dps.\n", dps[0][2]);
629 }
630
631 /* ±500 dps */
633 if (res != 0)
634 {
635 l3gd20h_interface_debug_print("l3gd20h: set full scale failed.\n");
636 (void)l3gd20h_deinit(&gs_handle);
637
638 return 1;
639 }
641
642 /* ±500 dps */
643 l3gd20h_interface_debug_print("l3gd20h: set full scale 500 dps.\n");
644 for (i = 0; i < times; i++)
645 {
646 int16_t raw[1][3];
647 float dps[1][3];
648 uint16_t len;
649
650 len = 1;
651 res = l3gd20h_read(&gs_handle, (int16_t (*)[3])(raw), (float (*)[3])(dps), (uint16_t *)&len);
652 if (res != 0)
653 {
654 l3gd20h_interface_debug_print("l3gd20h: read failed.\n");
655 (void)l3gd20h_deinit(&gs_handle);
656
657 return 1;
658 }
659 l3gd20h_interface_debug_print("l3gd20h: x %0.2f dps.\n", dps[0][0]);
660 l3gd20h_interface_debug_print("l3gd20h: y %0.2f dps.\n", dps[0][1]);
661 l3gd20h_interface_debug_print("l3gd20h: z %0.2f dps.\n", dps[0][2]);
663 }
664
665 /* ±2000 dps */
667 if (res != 0)
668 {
669 l3gd20h_interface_debug_print("l3gd20h: set full scale failed.\n");
670 (void)l3gd20h_deinit(&gs_handle);
671
672 return 1;
673 }
675
676 /* ±2000 dps */
677 l3gd20h_interface_debug_print("l3gd20h: set full scale 2000 dps.\n");
678 for (i = 0; i < times; i++)
679 {
680 int16_t raw[1][3];
681 float dps[1][3];
682 uint16_t len;
683
684 len = 1;
685 res = l3gd20h_read(&gs_handle, (int16_t (*)[3])(raw), (float (*)[3])(dps), (uint16_t *)&len);
686 if (res != 0)
687 {
688 l3gd20h_interface_debug_print("l3gd20h: read failed.\n");
689 (void)l3gd20h_deinit(&gs_handle);
690
691 return 1;
692 }
693 l3gd20h_interface_debug_print("l3gd20h: x %0.2f dps.\n", dps[0][0]);
694 l3gd20h_interface_debug_print("l3gd20h: y %0.2f dps.\n", dps[0][1]);
695 l3gd20h_interface_debug_print("l3gd20h: z %0.2f dps.\n", dps[0][2]);
697 }
698
699 /* big endian */
701 if (res != 0)
702 {
703 l3gd20h_interface_debug_print("l3gd20h: set data format failed.\n");
704 (void)l3gd20h_deinit(&gs_handle);
705
706 return 1;
707 }
708
709 /* set big endian */
710 l3gd20h_interface_debug_print("l3gd20h: set big endian.\n");
711 for (i = 0; i < times; i++)
712 {
713 int16_t raw[1][3];
714 float dps[1][3];
715 uint16_t len;
716
717 len = 1;
718 res = l3gd20h_read(&gs_handle, (int16_t (*)[3])(raw), (float (*)[3])(dps), (uint16_t *)&len);
719 if (res != 0)
720 {
721 l3gd20h_interface_debug_print("l3gd20h: read failed.\n");
722 (void)l3gd20h_deinit(&gs_handle);
723
724 return 1;
725 }
726 l3gd20h_interface_debug_print("l3gd20h: x %0.2f dps.\n", dps[0][0]);
727 l3gd20h_interface_debug_print("l3gd20h: y %0.2f dps.\n", dps[0][1]);
728 l3gd20h_interface_debug_print("l3gd20h: z %0.2f dps.\n", dps[0][2]);
730 }
731
732 /* read the temperature */
733 l3gd20h_interface_debug_print("l3gd20h: read the temperature.\n");
734 for (i = 0; i < times; i++)
735 {
736 int8_t raw;
737 float temp;
738
739 res = l3gd20h_read_temperature(&gs_handle, (int8_t *)&raw, (float *)&temp);
740 if (res != 0)
741 {
742 l3gd20h_interface_debug_print("l3gd20h: read temperature failed.\n");
743 (void)l3gd20h_deinit(&gs_handle);
744
745 return 1;
746 }
747 l3gd20h_interface_debug_print("l3gd20h: temperature is %0.2fC.\n", temp);
749 }
750
751 /* finish read test */
752 l3gd20h_interface_debug_print("l3gd20h: finish read test.\n");
753 (void)l3gd20h_deinit(&gs_handle);
754
755 return 0;
756}
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]