LibDriver L3GD20H
Loading...
Searching...
No Matches
driver_l3gd20h_register_test.c
Go to the documentation of this file.
1
37
39#include <stdlib.h>
40
41static l3gd20h_handle_t gs_handle;
42
53{
54 uint8_t res;
55 uint8_t value, value_check;
56 uint8_t duration, duration_check;
57 uint16_t threshold, threshold_check;
58 float dps, dps_check;
59 uint16_t reg;
60 l3gd20h_info_t info;
61 l3gd20h_boot_t boot;
62 l3gd20h_interface_t interface_test;
64 l3gd20h_mode_t mode;
65 l3gd20h_bool_t enable;
66 l3gd20h_lodr_odr_bw_t rate_bandwidth;
69 l3gd20h_data_format_t data_format;
70 l3gd20h_full_scale_t full_scale;
71 l3gd20h_self_test_t self_test;
72 l3gd20h_spi_wire_t spi_wire;
73 l3gd20h_selection_t selection;
75 l3gd20h_pin_type_t pin_type;
76 l3gd20h_counter_mode_t counter_mode;
78 l3gd20h_fifo_mode_t fifo_mode;
79
80 /* link interface function */
93
94 /* get information */
95 res = l3gd20h_info(&info);
96 if (res != 0)
97 {
98 l3gd20h_interface_debug_print("l3gd20h: get info failed.\n");
99
100 return 1;
101 }
102 else
103 {
104 /* print chip info */
105 l3gd20h_interface_debug_print("l3gd20h: chip is %s.\n", info.chip_name);
106 l3gd20h_interface_debug_print("l3gd20h: manufacturer is %s.\n", info.manufacturer_name);
107 l3gd20h_interface_debug_print("l3gd20h: interface is %s.\n", info.interface);
108 l3gd20h_interface_debug_print("l3gd20h: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
109 l3gd20h_interface_debug_print("l3gd20h: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
110 l3gd20h_interface_debug_print("l3gd20h: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
111 l3gd20h_interface_debug_print("l3gd20h: max current is %0.2fmA.\n", info.max_current_ma);
112 l3gd20h_interface_debug_print("l3gd20h: max temperature is %0.1fC.\n", info.temperature_max);
113 l3gd20h_interface_debug_print("l3gd20h: min temperature is %0.1fC.\n", info.temperature_min);
114 }
115
116 /* start register test */
117 l3gd20h_interface_debug_print("l3gd20h: start register test.\n");
118
119 /* l3gd20h_set_interface/l3gd20h_get_interface test */
120 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_interface/l3gd20h_get_interface test.\n");
121
122 /* set IIC interface */
124 if (res != 0)
125 {
126 l3gd20h_interface_debug_print("l3gd20h: set interface failed.\n");
127
128 return 1;
129 }
130 l3gd20h_interface_debug_print("l3gd20h: set interface iic.\n");
131 res = l3gd20h_get_interface(&gs_handle, &interface_test);
132 if (res != 0)
133 {
134 l3gd20h_interface_debug_print("l3gd20h: get interface failed.\n");
135
136 return 1;
137 }
138 l3gd20h_interface_debug_print("l3gd20h: check interface %s.\n", interface_test == L3GD20H_INTERFACE_IIC ? "ok" : "error");
139
140 /* set SPI interface */
142 if (res != 0)
143 {
144 l3gd20h_interface_debug_print("l3gd20h: set interface failed.\n");
145
146 return 1;
147 }
148 l3gd20h_interface_debug_print("l3gd20h: set interface spi.\n");
149 res = l3gd20h_get_interface(&gs_handle, &interface_test);
150 if (res != 0)
151 {
152 l3gd20h_interface_debug_print("l3gd20h: get interface failed.\n");
153
154 return 1;
155 }
156 l3gd20h_interface_debug_print("l3gd20h: check interface %s.\n", interface_test == L3GD20H_INTERFACE_SPI ? "ok" : "error");
157
158 /* l3gd20h_set_addr_pin/l3gd20h_get_addr_pin test */
159 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_addr_pin/l3gd20h_get_addr_pin test.\n");
160
161 /* sdo 0 */
163 if (res != 0)
164 {
165 l3gd20h_interface_debug_print("l3gd20h: set addr pin failed.\n");
166
167 return 1;
168 }
169 l3gd20h_interface_debug_print("l3gd20h: set addr pin sdo0.\n");
170 res = l3gd20h_get_addr_pin(&gs_handle, &addr);
171 if (res != 0)
172 {
173 l3gd20h_interface_debug_print("l3gd20h: get addr pin failed.\n");
174
175 return 1;
176 }
177 l3gd20h_interface_debug_print("l3gd20h: check addr pin %s.\n", addr == L3GD20H_ADDRESS_SDO_0 ? "ok" : "error");
178
179 /* sdo 1 */
181 if (res != 0)
182 {
183 l3gd20h_interface_debug_print("l3gd20h: set addr pin failed.\n");
184
185 return 1;
186 }
187 l3gd20h_interface_debug_print("l3gd20h: set addr pin sdo1.\n");
188 res = l3gd20h_get_addr_pin(&gs_handle, &addr);
189 if (res != 0)
190 {
191 l3gd20h_interface_debug_print("l3gd20h: get addr pin failed.\n");
192
193 return 1;
194 }
195 l3gd20h_interface_debug_print("l3gd20h: check addr pin %s.\n", addr == L3GD20H_ADDRESS_SDO_1 ? "ok" : "error");
196
197 /* set the interface */
198 res = l3gd20h_set_interface(&gs_handle, interface);
199 if (res != 0)
200 {
201 l3gd20h_interface_debug_print("l3gd20h: set interface failed.\n");
202
203 return 1;
204 }
205
206 /* set the address pin */
207 res = l3gd20h_set_addr_pin(&gs_handle, addr_pin);
208 if (res != 0)
209 {
210 l3gd20h_interface_debug_print("l3gd20h: set addr pin failed.\n");
211
212 return 1;
213 }
214
215 /* init the l3gd20h */
216 res = l3gd20h_init(&gs_handle);
217 if (res != 0)
218 {
219 l3gd20h_interface_debug_print("l3gd20h: init failed.\n");
220
221 return 1;
222 }
223
224 /* l3gd20h_set_mode/l3gd20h_get_mode test */
225 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_mode/l3gd20h_get_mode test.\n");
226
227 /* power down mode */
228 res = l3gd20h_set_mode(&gs_handle, L3GD20H_MODE_POWER_DOWN);
229 if (res != 0)
230 {
231 l3gd20h_interface_debug_print("l3gd20h: set mode failed.\n");
232 (void)l3gd20h_deinit(&gs_handle);
233
234 return 1;
235 }
236 l3gd20h_interface_debug_print("l3gd20h: set power down mode.\n");
237 res = l3gd20h_get_mode(&gs_handle, &mode);
238 if (res != 0)
239 {
240 l3gd20h_interface_debug_print("l3gd20h: get mode failed.\n");
241 (void)l3gd20h_deinit(&gs_handle);
242
243 return 1;
244 }
245 l3gd20h_interface_debug_print("l3gd20h: check mode %s.\n", mode == L3GD20H_MODE_POWER_DOWN ? "ok" : "error");
246
247 /* sleep mode */
248 res = l3gd20h_set_mode(&gs_handle, L3GD20H_MODE_SLEEP);
249 if (res != 0)
250 {
251 l3gd20h_interface_debug_print("l3gd20h: set mode failed.\n");
252 (void)l3gd20h_deinit(&gs_handle);
253
254 return 1;
255 }
256 l3gd20h_interface_debug_print("l3gd20h: set sleep mode.\n");
257 res = l3gd20h_get_mode(&gs_handle, &mode);
258 if (res != 0)
259 {
260 l3gd20h_interface_debug_print("l3gd20h: get mode failed.\n");
261 (void)l3gd20h_deinit(&gs_handle);
262
263 return 1;
264 }
265 l3gd20h_interface_debug_print("l3gd20h: check mode %s.\n", mode == L3GD20H_MODE_SLEEP ? "ok" : "error");
266
267 /* normal mode */
268 res = l3gd20h_set_mode(&gs_handle, L3GD20H_MODE_NORMAL);
269 if (res != 0)
270 {
271 l3gd20h_interface_debug_print("l3gd20h: set mode failed.\n");
272 (void)l3gd20h_deinit(&gs_handle);
273
274 return 1;
275 }
276 l3gd20h_interface_debug_print("l3gd20h: set normal mode.\n");
277 res = l3gd20h_get_mode(&gs_handle, &mode);
278 if (res != 0)
279 {
280 l3gd20h_interface_debug_print("l3gd20h: get mode failed.\n");
281 (void)l3gd20h_deinit(&gs_handle);
282
283 return 1;
284 }
285 l3gd20h_interface_debug_print("l3gd20h: check mode %s.\n", mode == L3GD20H_MODE_NORMAL ? "ok" : "error");
286
287 /* l3gd20h_set_axis/l3gd20h_get_axis test */
288 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_axis/l3gd20h_get_axis test.\n");
289
290 /* axis x false */
292 if (res != 0)
293 {
294 l3gd20h_interface_debug_print("l3gd20h: set axis failed.\n");
295 (void)l3gd20h_deinit(&gs_handle);
296
297 return 1;
298 }
299 l3gd20h_interface_debug_print("l3gd20h: set axis x false.\n");
300 res = l3gd20h_get_axis(&gs_handle, L3GD20H_AXIS_X, &enable);
301 if (res != 0)
302 {
303 l3gd20h_interface_debug_print("l3gd20h: get axis failed.\n");
304 (void)l3gd20h_deinit(&gs_handle);
305
306 return 1;
307 }
308 l3gd20h_interface_debug_print("l3gd20h: check axis %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
309
310 /* axis x true */
312 if (res != 0)
313 {
314 l3gd20h_interface_debug_print("l3gd20h: set axis failed.\n");
315 (void)l3gd20h_deinit(&gs_handle);
316
317 return 1;
318 }
319 l3gd20h_interface_debug_print("l3gd20h: set axis x true.\n");
320 res = l3gd20h_get_axis(&gs_handle, L3GD20H_AXIS_X, &enable);
321 if (res != 0)
322 {
323 l3gd20h_interface_debug_print("l3gd20h: get axis failed.\n");
324 (void)l3gd20h_deinit(&gs_handle);
325
326 return 1;
327 }
328 l3gd20h_interface_debug_print("l3gd20h: check axis %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
329
330 /* axis y false */
332 if (res != 0)
333 {
334 l3gd20h_interface_debug_print("l3gd20h: set axis failed.\n");
335 (void)l3gd20h_deinit(&gs_handle);
336
337 return 1;
338 }
339 l3gd20h_interface_debug_print("l3gd20h: set axis y false.\n");
340 res = l3gd20h_get_axis(&gs_handle, L3GD20H_AXIS_Y, &enable);
341 if (res != 0)
342 {
343 l3gd20h_interface_debug_print("l3gd20h: get axis failed.\n");
344 (void)l3gd20h_deinit(&gs_handle);
345
346 return 1;
347 }
348 l3gd20h_interface_debug_print("l3gd20h: check axis %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
349
350 /* axis y true */
352 if (res != 0)
353 {
354 l3gd20h_interface_debug_print("l3gd20h: set axis failed.\n");
355 (void)l3gd20h_deinit(&gs_handle);
356
357 return 1;
358 }
359 l3gd20h_interface_debug_print("l3gd20h: set axis y true.\n");
360 res = l3gd20h_get_axis(&gs_handle, L3GD20H_AXIS_Y, &enable);
361 if (res != 0)
362 {
363 l3gd20h_interface_debug_print("l3gd20h: get axis failed.\n");
364 (void)l3gd20h_deinit(&gs_handle);
365
366 return 1;
367 }
368 l3gd20h_interface_debug_print("l3gd20h: check axis %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
369
370 /* axis z false */
372 if (res != 0)
373 {
374 l3gd20h_interface_debug_print("l3gd20h: set axis failed.\n");
375 (void)l3gd20h_deinit(&gs_handle);
376
377 return 1;
378 }
379 l3gd20h_interface_debug_print("l3gd20h: set axis z false.\n");
380 res = l3gd20h_get_axis(&gs_handle, L3GD20H_AXIS_Z, &enable);
381 if (res != 0)
382 {
383 l3gd20h_interface_debug_print("l3gd20h: get axis failed.\n");
384 (void)l3gd20h_deinit(&gs_handle);
385
386 return 1;
387 }
388 l3gd20h_interface_debug_print("l3gd20h: check axis %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
389
390 /* axis z true */
392 if (res != 0)
393 {
394 l3gd20h_interface_debug_print("l3gd20h: set axis failed.\n");
395 (void)l3gd20h_deinit(&gs_handle);
396
397 return 1;
398 }
399 l3gd20h_interface_debug_print("l3gd20h: set axis z true.\n");
400 res = l3gd20h_get_axis(&gs_handle, L3GD20H_AXIS_Z, &enable);
401 if (res != 0)
402 {
403 l3gd20h_interface_debug_print("l3gd20h: get axis failed.\n");
404 (void)l3gd20h_deinit(&gs_handle);
405
406 return 1;
407 }
408 l3gd20h_interface_debug_print("l3gd20h: check axis %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
409
410 /* l3gd20h_set_rate_bandwidth/l3gd20h_get_rate_bandwidth test */
411 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_rate_bandwidth/l3gd20h_get_rate_bandwidth test.\n");
412
413 /* rate 100Hz bandwidth 12.5Hz */
415 if (res != 0)
416 {
417 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
418 (void)l3gd20h_deinit(&gs_handle);
419
420 return 1;
421 }
422 l3gd20h_interface_debug_print("l3gd20h: set rate 100Hz bandwidth 12.5Hz.\n");
423 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
424 if (res != 0)
425 {
426 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
427 (void)l3gd20h_deinit(&gs_handle);
428
429 return 1;
430 }
431 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_0_ODR_100HZ_BW_0_12P5HZ ? "ok" : "error");
432
433 /* rate 100Hz bandwidth 25Hz */
435 if (res != 0)
436 {
437 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
438 (void)l3gd20h_deinit(&gs_handle);
439
440 return 1;
441 }
442 l3gd20h_interface_debug_print("l3gd20h: set rate 100Hz bandwidth 25Hz.\n");
443 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
444 if (res != 0)
445 {
446 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
447 (void)l3gd20h_deinit(&gs_handle);
448
449 return 1;
450 }
451 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_0_ODR_100HZ_BW_1_25HZ ? "ok" : "error");
452
453 /* rate 100Hz bandwidth 25Hz */
455 if (res != 0)
456 {
457 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
458 (void)l3gd20h_deinit(&gs_handle);
459
460 return 1;
461 }
462 l3gd20h_interface_debug_print("l3gd20h: set rate 100Hz bandwidth 25Hz.\n");
463 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
464 if (res != 0)
465 {
466 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
467 (void)l3gd20h_deinit(&gs_handle);
468
469 return 1;
470 }
471 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_0_ODR_100HZ_BW_2_25HZ ? "ok" : "error");
472
473 /* rate 100Hz bandwidth 25Hz */
475 if (res != 0)
476 {
477 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
478 (void)l3gd20h_deinit(&gs_handle);
479
480 return 1;
481 }
482 l3gd20h_interface_debug_print("l3gd20h: set rate 100Hz bandwidth 25Hz.\n");
483 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
484 if (res != 0)
485 {
486 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
487 (void)l3gd20h_deinit(&gs_handle);
488
489 return 1;
490 }
491 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_0_ODR_100HZ_BW_3_25HZ ? "ok" : "error");
492
493 /* rate 200Hz bandwidth NA */
495 if (res != 0)
496 {
497 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
498 (void)l3gd20h_deinit(&gs_handle);
499
500 return 1;
501 }
502 l3gd20h_interface_debug_print("l3gd20h: set rate 200Hz bandwidth NA.\n");
503 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
504 if (res != 0)
505 {
506 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
507 (void)l3gd20h_deinit(&gs_handle);
508
509 return 1;
510 }
511 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_0_ODR_200HZ_BW_1_NA ? "ok" : "error");
512
513 /* rate 200Hz bandwidth NA */
515 if (res != 0)
516 {
517 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
518 (void)l3gd20h_deinit(&gs_handle);
519
520 return 1;
521 }
522 l3gd20h_interface_debug_print("l3gd20h: set rate 200Hz bandwidth NA.\n");
523 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
524 if (res != 0)
525 {
526 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
527 (void)l3gd20h_deinit(&gs_handle);
528
529 return 1;
530 }
531 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_0_ODR_200HZ_BW_2_NA ? "ok" : "error");
532
533 /* rate 200Hz bandwidth 70Hz */
535 if (res != 0)
536 {
537 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
538 (void)l3gd20h_deinit(&gs_handle);
539
540 return 1;
541 }
542 l3gd20h_interface_debug_print("l3gd20h: set rate 200Hz bandwidth 70Hz.\n");
543 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
544 if (res != 0)
545 {
546 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
547 (void)l3gd20h_deinit(&gs_handle);
548
549 return 1;
550 }
551 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_0_ODR_200HZ_BW_3_70HZ ? "ok" : "error");
552
553 /* rate 400Hz bandwidth 20Hz */
555 if (res != 0)
556 {
557 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
558 (void)l3gd20h_deinit(&gs_handle);
559
560 return 1;
561 }
562 l3gd20h_interface_debug_print("l3gd20h: set rate 400Hz bandwidth 20Hz.\n");
563 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
564 if (res != 0)
565 {
566 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
567 (void)l3gd20h_deinit(&gs_handle);
568
569 return 1;
570 }
571 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_0_ODR_400HZ_BW_0_20HZ ? "ok" : "error");
572
573 /* rate 400Hz bandwidth 25Hz */
575 if (res != 0)
576 {
577 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
578 (void)l3gd20h_deinit(&gs_handle);
579
580 return 1;
581 }
582 l3gd20h_interface_debug_print("l3gd20h: set rate 400Hz bandwidth 25Hz.\n");
583 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
584 if (res != 0)
585 {
586 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
587 (void)l3gd20h_deinit(&gs_handle);
588
589 return 1;
590 }
591 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_0_ODR_400HZ_BW_1_25HZ ? "ok" : "error");
592
593 /* rate 400Hz bandwidth 50Hz */
595 if (res != 0)
596 {
597 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
598 (void)l3gd20h_deinit(&gs_handle);
599
600 return 1;
601 }
602 l3gd20h_interface_debug_print("l3gd20h: set rate 400Hz bandwidth 50Hz.\n");
603 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
604 if (res != 0)
605 {
606 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
607 (void)l3gd20h_deinit(&gs_handle);
608
609 return 1;
610 }
611 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_0_ODR_400HZ_BW_2_50HZ ? "ok" : "error");
612
613 /* rate 400Hz bandwidth 110Hz */
615 if (res != 0)
616 {
617 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
618 (void)l3gd20h_deinit(&gs_handle);
619
620 return 1;
621 }
622 l3gd20h_interface_debug_print("l3gd20h: set rate 400Hz bandwidth 110Hz.\n");
623 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
624 if (res != 0)
625 {
626 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
627 (void)l3gd20h_deinit(&gs_handle);
628
629 return 1;
630 }
631 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_0_ODR_400HZ_BW_3_110HZ ? "ok" : "error");
632
633 /* rate 800Hz bandwidth 30Hz */
635 if (res != 0)
636 {
637 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
638 (void)l3gd20h_deinit(&gs_handle);
639
640 return 1;
641 }
642 l3gd20h_interface_debug_print("l3gd20h: set rate 800Hz bandwidth 30Hz.\n");
643 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
644 if (res != 0)
645 {
646 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
647 (void)l3gd20h_deinit(&gs_handle);
648
649 return 1;
650 }
651 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_0_ODR_800HZ_BW_0_30HZ ? "ok" : "error");
652
653 /* rate 800Hz bandwidth 35Hz */
655 if (res != 0)
656 {
657 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
658 (void)l3gd20h_deinit(&gs_handle);
659
660 return 1;
661 }
662 l3gd20h_interface_debug_print("l3gd20h: set rate 800Hz bandwidth 35Hz.\n");
663 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
664 if (res != 0)
665 {
666 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
667 (void)l3gd20h_deinit(&gs_handle);
668
669 return 1;
670 }
671 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_0_ODR_800HZ_BW_1_35HZ ? "ok" : "error");
672
673 /* rate 800Hz bandwidth NA */
675 if (res != 0)
676 {
677 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
678 (void)l3gd20h_deinit(&gs_handle);
679
680 return 1;
681 }
682 l3gd20h_interface_debug_print("l3gd20h: set rate 800Hz bandwidth NA.\n");
683 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
684 if (res != 0)
685 {
686 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
687 (void)l3gd20h_deinit(&gs_handle);
688
689 return 1;
690 }
691 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_0_ODR_800HZ_BW_2_NA ? "ok" : "error");
692
693 /* rate 800Hz bandwidth 100Hz */
695 if (res != 0)
696 {
697 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
698 (void)l3gd20h_deinit(&gs_handle);
699
700 return 1;
701 }
702 l3gd20h_interface_debug_print("l3gd20h: set rate 800Hz bandwidth 100Hz.\n");
703 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
704 if (res != 0)
705 {
706 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
707 (void)l3gd20h_deinit(&gs_handle);
708
709 return 1;
710 }
711 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_0_ODR_800HZ_BW_3_100HZ ? "ok" : "error");
712
713 /* low power rate 12.5Hz bandwidth NA */
715 if (res != 0)
716 {
717 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
718 (void)l3gd20h_deinit(&gs_handle);
719
720 return 1;
721 }
722 l3gd20h_interface_debug_print("l3gd20h: set low power rate 12.5Hz bandwidth NA.\n");
723 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
724 if (res != 0)
725 {
726 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
727 (void)l3gd20h_deinit(&gs_handle);
728
729 return 1;
730 }
731 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_1_ODR_12P5HZ_BW_0_NA ? "ok" : "error");
732
733 /* low power rate 12.5Hz bandwidth NA */
735 if (res != 0)
736 {
737 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
738 (void)l3gd20h_deinit(&gs_handle);
739
740 return 1;
741 }
742 l3gd20h_interface_debug_print("l3gd20h: set low power rate 12.5Hz bandwidth NA.\n");
743 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
744 if (res != 0)
745 {
746 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
747 (void)l3gd20h_deinit(&gs_handle);
748
749 return 1;
750 }
751 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_1_ODR_12P5HZ_BW_1_NA ? "ok" : "error");
752
753 /* low power rate 12.5Hz bandwidth NA */
755 if (res != 0)
756 {
757 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
758 (void)l3gd20h_deinit(&gs_handle);
759
760 return 1;
761 }
762 l3gd20h_interface_debug_print("l3gd20h: set low power rate 12.5Hz bandwidth NA.\n");
763 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
764 if (res != 0)
765 {
766 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
767 (void)l3gd20h_deinit(&gs_handle);
768
769 return 1;
770 }
771 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_1_ODR_12P5HZ_BW_2_NA ? "ok" : "error");
772
773 /* low power rate 12.5Hz bandwidth NA */
775 if (res != 0)
776 {
777 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
778 (void)l3gd20h_deinit(&gs_handle);
779
780 return 1;
781 }
782 l3gd20h_interface_debug_print("l3gd20h: set low power rate 12.5Hz bandwidth NA.\n");
783 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
784 if (res != 0)
785 {
786 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
787 (void)l3gd20h_deinit(&gs_handle);
788
789 return 1;
790 }
791 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_1_ODR_12P5HZ_BW_3_NA ? "ok" : "error");
792
793 /* low power rate 25Hz bandwidth NA */
795 if (res != 0)
796 {
797 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
798 (void)l3gd20h_deinit(&gs_handle);
799
800 return 1;
801 }
802 l3gd20h_interface_debug_print("l3gd20h: set low power rate 25Hz bandwidth NA.\n");
803 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
804 if (res != 0)
805 {
806 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
807 (void)l3gd20h_deinit(&gs_handle);
808
809 return 1;
810 }
811 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_1_ODR_25HZ_BW_0_NA ? "ok" : "error");
812
813 /* low power rate 25Hz bandwidth NA */
815 if (res != 0)
816 {
817 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
818 (void)l3gd20h_deinit(&gs_handle);
819
820 return 1;
821 }
822 l3gd20h_interface_debug_print("l3gd20h: set low power rate 25Hz bandwidth NA.\n");
823 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
824 if (res != 0)
825 {
826 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
827 (void)l3gd20h_deinit(&gs_handle);
828
829 return 1;
830 }
831 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_1_ODR_25HZ_BW_1_NA ? "ok" : "error");
832
833 /* low power rate 25Hz bandwidth NA */
835 if (res != 0)
836 {
837 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
838 (void)l3gd20h_deinit(&gs_handle);
839
840 return 1;
841 }
842 l3gd20h_interface_debug_print("l3gd20h: set low power rate 25Hz bandwidth NA.\n");
843 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
844 if (res != 0)
845 {
846 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
847 (void)l3gd20h_deinit(&gs_handle);
848
849 return 1;
850 }
851 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_1_ODR_25HZ_BW_2_NA ? "ok" : "error");
852
853 /* low power rate 25Hz bandwidth NA */
855 if (res != 0)
856 {
857 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
858 (void)l3gd20h_deinit(&gs_handle);
859
860 return 1;
861 }
862 l3gd20h_interface_debug_print("l3gd20h: set low power rate 25Hz bandwidth NA.\n");
863 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
864 if (res != 0)
865 {
866 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
867 (void)l3gd20h_deinit(&gs_handle);
868
869 return 1;
870 }
871 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_1_ODR_25HZ_BW_3_NA ? "ok" : "error");
872
873 /* low power rate 50Hz bandwidth 16.6Hz */
875 if (res != 0)
876 {
877 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
878 (void)l3gd20h_deinit(&gs_handle);
879
880 return 1;
881 }
882 l3gd20h_interface_debug_print("l3gd20h: set low power rate 50Hz bandwidth 16.6Hz.\n");
883 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
884 if (res != 0)
885 {
886 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
887 (void)l3gd20h_deinit(&gs_handle);
888
889 return 1;
890 }
891 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_1_ODR_50HZ_BW_0_16P6HZ ? "ok" : "error");
892
893 /* low power rate 50Hz bandwidth 16.6Hz */
895 if (res != 0)
896 {
897 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
898 (void)l3gd20h_deinit(&gs_handle);
899
900 return 1;
901 }
902 l3gd20h_interface_debug_print("l3gd20h: set low power rate 50Hz bandwidth 16.6Hz.\n");
903 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
904 if (res != 0)
905 {
906 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
907 (void)l3gd20h_deinit(&gs_handle);
908
909 return 1;
910 }
911 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_1_ODR_50HZ_BW_1_16P6HZ ? "ok" : "error");
912
913 /* low power rate 50Hz bandwidth 16.6Hz */
915 if (res != 0)
916 {
917 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
918 (void)l3gd20h_deinit(&gs_handle);
919
920 return 1;
921 }
922 l3gd20h_interface_debug_print("l3gd20h: set low power rate 50Hz bandwidth 16.6Hz.\n");
923 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
924 if (res != 0)
925 {
926 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
927 (void)l3gd20h_deinit(&gs_handle);
928
929 return 1;
930 }
931 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_1_ODR_50HZ_BW_2_16P6HZ ? "ok" : "error");
932
933 /* low power rate 50Hz bandwidth 16.6Hz */
935 if (res != 0)
936 {
937 l3gd20h_interface_debug_print("l3gd20h: set rate bandwidth failed.\n");
938 (void)l3gd20h_deinit(&gs_handle);
939
940 return 1;
941 }
942 l3gd20h_interface_debug_print("l3gd20h: set low power rate 50Hz bandwidth 16.6Hz.\n");
943 res = l3gd20h_get_rate_bandwidth(&gs_handle, &rate_bandwidth);
944 if (res != 0)
945 {
946 l3gd20h_interface_debug_print("l3gd20h: get rate bandwidth failed.\n");
947 (void)l3gd20h_deinit(&gs_handle);
948
949 return 1;
950 }
951 l3gd20h_interface_debug_print("l3gd20h: check rate bandwidth %s.\n", rate_bandwidth == L3GD20H_LOW_ODR_1_ODR_50HZ_BW_3_16P6HZ ? "ok" : "error");
952
953 /* l3gd20h_set_edge_trigger/l3gd20h_get_edge_trigger test */
954 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_edge_trigger/l3gd20h_get_edge_trigger test.\n");
955
956 /* enable */
958 if (res != 0)
959 {
960 l3gd20h_interface_debug_print("l3gd20h: set edge trigger failed.\n");
961 (void)l3gd20h_deinit(&gs_handle);
962
963 return 1;
964 }
965 l3gd20h_interface_debug_print("l3gd20h: enable edge trigger.\n");
966 res = l3gd20h_get_edge_trigger(&gs_handle, &enable);
967 if (res != 0)
968 {
969 l3gd20h_interface_debug_print("l3gd20h: get edge trigger failed.\n");
970 (void)l3gd20h_deinit(&gs_handle);
971
972 return 1;
973 }
974 l3gd20h_interface_debug_print("l3gd20h: check edge trigger %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
975
976 /* disable */
978 if (res != 0)
979 {
980 l3gd20h_interface_debug_print("l3gd20h: set edge trigger failed.\n");
981 (void)l3gd20h_deinit(&gs_handle);
982
983 return 1;
984 }
985 l3gd20h_interface_debug_print("l3gd20h: disable edge trigger.\n");
986 res = l3gd20h_get_edge_trigger(&gs_handle, &enable);
987 if (res != 0)
988 {
989 l3gd20h_interface_debug_print("l3gd20h: get edge trigger failed.\n");
990 (void)l3gd20h_deinit(&gs_handle);
991
992 return 1;
993 }
994 l3gd20h_interface_debug_print("l3gd20h: check edge trigger %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
995
996 /* l3gd20h_set_level_trigger/l3gd20h_get_level_trigger test */
997 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_level_trigger/l3gd20h_get_level_trigger test.\n");
998
999 /* enable */
1001 if (res != 0)
1002 {
1003 l3gd20h_interface_debug_print("l3gd20h: set level trigger failed.\n");
1004 (void)l3gd20h_deinit(&gs_handle);
1005
1006 return 1;
1007 }
1008 l3gd20h_interface_debug_print("l3gd20h: enable level trigger.\n");
1009 res = l3gd20h_get_level_trigger(&gs_handle, &enable);
1010 if (res != 0)
1011 {
1012 l3gd20h_interface_debug_print("l3gd20h: get level trigger failed.\n");
1013 (void)l3gd20h_deinit(&gs_handle);
1014
1015 return 1;
1016 }
1017 l3gd20h_interface_debug_print("l3gd20h: check level trigger %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
1018
1019 /* disable */
1021 if (res != 0)
1022 {
1023 l3gd20h_interface_debug_print("l3gd20h: set level trigger failed.\n");
1024 (void)l3gd20h_deinit(&gs_handle);
1025
1026 return 1;
1027 }
1028 l3gd20h_interface_debug_print("l3gd20h: disable level trigger.\n");
1029 res = l3gd20h_get_level_trigger(&gs_handle, &enable);
1030 if (res != 0)
1031 {
1032 l3gd20h_interface_debug_print("l3gd20h: get level trigger failed.\n");
1033 (void)l3gd20h_deinit(&gs_handle);
1034
1035 return 1;
1036 }
1037 l3gd20h_interface_debug_print("l3gd20h: check level trigger %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
1038
1039 /* l3gd20h_set_high_pass_filter_mode/l3gd20h_get_high_pass_filter_mode test */
1040 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_high_pass_filter_mode/l3gd20h_get_high_pass_filter_mode test.\n");
1041
1042 /* normal reset mode*/
1044 if (res != 0)
1045 {
1046 l3gd20h_interface_debug_print("l3gd20h: set high pass filter mode failed.\n");
1047 (void)l3gd20h_deinit(&gs_handle);
1048
1049 return 1;
1050 }
1051 l3gd20h_interface_debug_print("l3gd20h: set high pass filter normal reset mode.\n");
1052 res = l3gd20h_get_high_pass_filter_mode(&gs_handle, &high_mode);
1053 if (res != 0)
1054 {
1055 l3gd20h_interface_debug_print("l3gd20h: get high pass filter mode failed.\n");
1056 (void)l3gd20h_deinit(&gs_handle);
1057
1058 return 1;
1059 }
1060 l3gd20h_interface_debug_print("l3gd20h: check high pass filter mode %s.\n", high_mode == L3GD20H_HIGH_PASS_FILTER_MODE_NORMAL_RESET ? "ok" : "error");
1061
1062 /* reference signal mode */
1064 if (res != 0)
1065 {
1066 l3gd20h_interface_debug_print("l3gd20h: set high pass filter mode failed.\n");
1067 (void)l3gd20h_deinit(&gs_handle);
1068
1069 return 1;
1070 }
1071 l3gd20h_interface_debug_print("l3gd20h: set high pass filter reference signal mode.\n");
1072 res = l3gd20h_get_high_pass_filter_mode(&gs_handle, &high_mode);
1073 if (res != 0)
1074 {
1075 l3gd20h_interface_debug_print("l3gd20h: get high pass filter mode failed.\n");
1076 (void)l3gd20h_deinit(&gs_handle);
1077
1078 return 1;
1079 }
1080 l3gd20h_interface_debug_print("l3gd20h: check high pass filter mode %s.\n", high_mode == L3GD20H_HIGH_PASS_FILTER_MODE_REFERENCE_SIGNAL ? "ok" : "error");
1081
1082 /* normal mode */
1084 if (res != 0)
1085 {
1086 l3gd20h_interface_debug_print("l3gd20h: set high pass filter mode failed.\n");
1087 (void)l3gd20h_deinit(&gs_handle);
1088
1089 return 1;
1090 }
1091 l3gd20h_interface_debug_print("l3gd20h: set high pass filter normal mode.\n");
1092 res = l3gd20h_get_high_pass_filter_mode(&gs_handle, &high_mode);
1093 if (res != 0)
1094 {
1095 l3gd20h_interface_debug_print("l3gd20h: get high pass filter mode failed.\n");
1096 (void)l3gd20h_deinit(&gs_handle);
1097
1098 return 1;
1099 }
1100 l3gd20h_interface_debug_print("l3gd20h: check high pass filter mode %s.\n", high_mode == L3GD20H_HIGH_PASS_FILTER_MODE_NORMAL ? "ok" : "error");
1101
1102 /* auto reset on int mode */
1104 if (res != 0)
1105 {
1106 l3gd20h_interface_debug_print("l3gd20h: set high pass filter mode failed.\n");
1107 (void)l3gd20h_deinit(&gs_handle);
1108
1109 return 1;
1110 }
1111 l3gd20h_interface_debug_print("l3gd20h: set high pass filter auto reset on int mode.\n");
1112 res = l3gd20h_get_high_pass_filter_mode(&gs_handle, &high_mode);
1113 if (res != 0)
1114 {
1115 l3gd20h_interface_debug_print("l3gd20h: get high pass filter mode failed.\n");
1116 (void)l3gd20h_deinit(&gs_handle);
1117
1118 return 1;
1119 }
1120 l3gd20h_interface_debug_print("l3gd20h: check high pass filter mode %s.\n", high_mode == L3GD20H_HIGH_PASS_FILTER_MODE_AUTORESET_ON_INT ? "ok" : "error");
1121
1122 /* l3gd20h_set_high_pass_filter_cut_off_frequency/l3gd20h_get_high_pass_filter_cut_off_frequency test */
1123 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_high_pass_filter_cut_off_frequency/l3gd20h_get_high_pass_filter_cut_off_frequency test.\n");
1124
1125 /* cut-off frequency 0 */
1127 if (res != 0)
1128 {
1129 l3gd20h_interface_debug_print("l3gd20h: set high pass filter cut off frequency failed.\n");
1130 (void)l3gd20h_deinit(&gs_handle);
1131
1132 return 1;
1133 }
1134 l3gd20h_interface_debug_print("l3gd20h: set high pass filter cut off frequency 0.\n");
1135 res = l3gd20h_get_high_pass_filter_cut_off_frequency(&gs_handle, &frequency);
1136 if (res != 0)
1137 {
1138 l3gd20h_interface_debug_print("l3gd20h: get high pass filter cut off frequency failed.\n");
1139 (void)l3gd20h_deinit(&gs_handle);
1140
1141 return 1;
1142 }
1143 l3gd20h_interface_debug_print("l3gd20h: check high pass filter cut off frequency %s.\n", frequency == L3GD20H_HIGH_PASS_FILTER_CUT_OFF_FREQUENCY_0 ? "ok" : "error");
1144
1145 /* cut-off frequency 1 */
1147 if (res != 0)
1148 {
1149 l3gd20h_interface_debug_print("l3gd20h: set high pass filter cut off frequency failed.\n");
1150 (void)l3gd20h_deinit(&gs_handle);
1151
1152 return 1;
1153 }
1154 l3gd20h_interface_debug_print("l3gd20h: set high pass filter cut off frequency 1.\n");
1155 res = l3gd20h_get_high_pass_filter_cut_off_frequency(&gs_handle, &frequency);
1156 if (res != 0)
1157 {
1158 l3gd20h_interface_debug_print("l3gd20h: get high pass filter cut off frequency failed.\n");
1159 (void)l3gd20h_deinit(&gs_handle);
1160
1161 return 1;
1162 }
1163 l3gd20h_interface_debug_print("l3gd20h: check high pass filter cut off frequency %s.\n", frequency == L3GD20H_HIGH_PASS_FILTER_CUT_OFF_FREQUENCY_1 ? "ok" : "error");
1164
1165 /* cut-off frequency 2 */
1167 if (res != 0)
1168 {
1169 l3gd20h_interface_debug_print("l3gd20h: set high pass filter cut off frequency failed.\n");
1170 (void)l3gd20h_deinit(&gs_handle);
1171
1172 return 1;
1173 }
1174 l3gd20h_interface_debug_print("l3gd20h: set high pass filter cut off frequency 2.\n");
1175 res = l3gd20h_get_high_pass_filter_cut_off_frequency(&gs_handle, &frequency);
1176 if (res != 0)
1177 {
1178 l3gd20h_interface_debug_print("l3gd20h: get high pass filter cut off frequency failed.\n");
1179 (void)l3gd20h_deinit(&gs_handle);
1180
1181 return 1;
1182 }
1183 l3gd20h_interface_debug_print("l3gd20h: check high pass filter cut off frequency %s.\n", frequency == L3GD20H_HIGH_PASS_FILTER_CUT_OFF_FREQUENCY_2 ? "ok" : "error");
1184
1185 /* cut-off frequency 3 */
1187 if (res != 0)
1188 {
1189 l3gd20h_interface_debug_print("l3gd20h: set high pass filter cut off frequency failed.\n");
1190 (void)l3gd20h_deinit(&gs_handle);
1191
1192 return 1;
1193 }
1194 l3gd20h_interface_debug_print("l3gd20h: set high pass filter cut off frequency 3.\n");
1195 res = l3gd20h_get_high_pass_filter_cut_off_frequency(&gs_handle, &frequency);
1196 if (res != 0)
1197 {
1198 l3gd20h_interface_debug_print("l3gd20h: get high pass filter cut off frequency failed.\n");
1199 (void)l3gd20h_deinit(&gs_handle);
1200
1201 return 1;
1202 }
1203 l3gd20h_interface_debug_print("l3gd20h: check high pass filter cut off frequency %s.\n", frequency == L3GD20H_HIGH_PASS_FILTER_CUT_OFF_FREQUENCY_3 ? "ok" : "error");
1204
1205 /* cut-off frequency 4 */
1207 if (res != 0)
1208 {
1209 l3gd20h_interface_debug_print("l3gd20h: set high pass filter cut off frequency failed.\n");
1210 (void)l3gd20h_deinit(&gs_handle);
1211
1212 return 1;
1213 }
1214 l3gd20h_interface_debug_print("l3gd20h: set high pass filter cut off frequency 4.\n");
1215 res = l3gd20h_get_high_pass_filter_cut_off_frequency(&gs_handle, &frequency);
1216 if (res != 0)
1217 {
1218 l3gd20h_interface_debug_print("l3gd20h: get high pass filter cut off frequency failed.\n");
1219 (void)l3gd20h_deinit(&gs_handle);
1220
1221 return 1;
1222 }
1223 l3gd20h_interface_debug_print("l3gd20h: check high pass filter cut off frequency %s.\n", frequency == L3GD20H_HIGH_PASS_FILTER_CUT_OFF_FREQUENCY_4 ? "ok" : "error");
1224
1225 /* cut-off frequency 5 */
1227 if (res != 0)
1228 {
1229 l3gd20h_interface_debug_print("l3gd20h: set high pass filter cut off frequency failed.\n");
1230 (void)l3gd20h_deinit(&gs_handle);
1231
1232 return 1;
1233 }
1234 l3gd20h_interface_debug_print("l3gd20h: set high pass filter cut off frequency 5.\n");
1235 res = l3gd20h_get_high_pass_filter_cut_off_frequency(&gs_handle, &frequency);
1236 if (res != 0)
1237 {
1238 l3gd20h_interface_debug_print("l3gd20h: get high pass filter cut off frequency failed.\n");
1239 (void)l3gd20h_deinit(&gs_handle);
1240
1241 return 1;
1242 }
1243 l3gd20h_interface_debug_print("l3gd20h: check high pass filter cut off frequency %s.\n", frequency == L3GD20H_HIGH_PASS_FILTER_CUT_OFF_FREQUENCY_5 ? "ok" : "error");
1244
1245 /* cut-off frequency 6 */
1247 if (res != 0)
1248 {
1249 l3gd20h_interface_debug_print("l3gd20h: set high pass filter cut off frequency failed.\n");
1250 (void)l3gd20h_deinit(&gs_handle);
1251
1252 return 1;
1253 }
1254 l3gd20h_interface_debug_print("l3gd20h: set high pass filter cut off frequency 6.\n");
1255 res = l3gd20h_get_high_pass_filter_cut_off_frequency(&gs_handle, &frequency);
1256 if (res != 0)
1257 {
1258 l3gd20h_interface_debug_print("l3gd20h: get high pass filter cut off frequency failed.\n");
1259 (void)l3gd20h_deinit(&gs_handle);
1260
1261 return 1;
1262 }
1263 l3gd20h_interface_debug_print("l3gd20h: check high pass filter cut off frequency %s.\n", frequency == L3GD20H_HIGH_PASS_FILTER_CUT_OFF_FREQUENCY_6 ? "ok" : "error");
1264
1265 /* cut-off frequency 7 */
1267 if (res != 0)
1268 {
1269 l3gd20h_interface_debug_print("l3gd20h: set high pass filter cut off frequency failed.\n");
1270 (void)l3gd20h_deinit(&gs_handle);
1271
1272 return 1;
1273 }
1274 l3gd20h_interface_debug_print("l3gd20h: set high pass filter cut off frequency 7.\n");
1275 res = l3gd20h_get_high_pass_filter_cut_off_frequency(&gs_handle, &frequency);
1276 if (res != 0)
1277 {
1278 l3gd20h_interface_debug_print("l3gd20h: get high pass filter cut off frequency failed.\n");
1279 (void)l3gd20h_deinit(&gs_handle);
1280
1281 return 1;
1282 }
1283 l3gd20h_interface_debug_print("l3gd20h: check high pass filter cut off frequency %s.\n", frequency == L3GD20H_HIGH_PASS_FILTER_CUT_OFF_FREQUENCY_7 ? "ok" : "error");
1284
1285 /* cut-off frequency 8 */
1287 if (res != 0)
1288 {
1289 l3gd20h_interface_debug_print("l3gd20h: set high pass filter cut off frequency failed.\n");
1290 (void)l3gd20h_deinit(&gs_handle);
1291
1292 return 1;
1293 }
1294 l3gd20h_interface_debug_print("l3gd20h: set high pass filter cut off frequency 8.\n");
1295 res = l3gd20h_get_high_pass_filter_cut_off_frequency(&gs_handle, &frequency);
1296 if (res != 0)
1297 {
1298 l3gd20h_interface_debug_print("l3gd20h: get high pass filter cut off frequency failed.\n");
1299 (void)l3gd20h_deinit(&gs_handle);
1300
1301 return 1;
1302 }
1303 l3gd20h_interface_debug_print("l3gd20h: check high pass filter cut off frequency %s.\n", frequency == L3GD20H_HIGH_PASS_FILTER_CUT_OFF_FREQUENCY_8 ? "ok" : "error");
1304
1305 /* cut-off frequency 9 */
1307 if (res != 0)
1308 {
1309 l3gd20h_interface_debug_print("l3gd20h: set high pass filter cut off frequency failed.\n");
1310 (void)l3gd20h_deinit(&gs_handle);
1311
1312 return 1;
1313 }
1314 l3gd20h_interface_debug_print("l3gd20h: set high pass filter cut off frequency 9.\n");
1315 res = l3gd20h_get_high_pass_filter_cut_off_frequency(&gs_handle, &frequency);
1316 if (res != 0)
1317 {
1318 l3gd20h_interface_debug_print("l3gd20h: get high pass filter cut off frequency failed.\n");
1319 (void)l3gd20h_deinit(&gs_handle);
1320
1321 return 1;
1322 }
1323 l3gd20h_interface_debug_print("l3gd20h: check high pass filter cut off frequency %s.\n", frequency == L3GD20H_HIGH_PASS_FILTER_CUT_OFF_FREQUENCY_9 ? "ok" : "error");
1324
1325 /* l3gd20h_set_block_data_update/l3gd20h_get_block_data_update test */
1326 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_block_data_update/l3gd20h_get_block_data_update test.\n");
1327
1328 /* enable */
1330 if (res != 0)
1331 {
1332 l3gd20h_interface_debug_print("l3gd20h: set block data update failed.\n");
1333 (void)l3gd20h_deinit(&gs_handle);
1334
1335 return 1;
1336 }
1337 l3gd20h_interface_debug_print("l3gd20h: enable block data update.\n");
1338 res = l3gd20h_get_block_data_update(&gs_handle, &enable);
1339 if (res != 0)
1340 {
1341 l3gd20h_interface_debug_print("l3gd20h: get block data update failed.\n");
1342 (void)l3gd20h_deinit(&gs_handle);
1343
1344 return 1;
1345 }
1346 l3gd20h_interface_debug_print("l3gd20h: check block data update %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
1347
1348 /* disable */
1350 if (res != 0)
1351 {
1352 l3gd20h_interface_debug_print("l3gd20h: set block data update failed.\n");
1353 (void)l3gd20h_deinit(&gs_handle);
1354
1355 return 1;
1356 }
1357 l3gd20h_interface_debug_print("l3gd20h: disable block data update.\n");
1358 res = l3gd20h_get_block_data_update(&gs_handle, &enable);
1359 if (res != 0)
1360 {
1361 l3gd20h_interface_debug_print("l3gd20h: get block data update failed.\n");
1362 (void)l3gd20h_deinit(&gs_handle);
1363
1364 return 1;
1365 }
1366 l3gd20h_interface_debug_print("l3gd20h: check block data update %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
1367
1368 /* l3gd20h_set_data_format/l3gd20h_get_data_format test */
1369 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_data_format/l3gd20h_get_data_format test.\n");
1370
1371 /* big endian */
1373 if (res != 0)
1374 {
1375 l3gd20h_interface_debug_print("l3gd20h: set data format failed.\n");
1376 (void)l3gd20h_deinit(&gs_handle);
1377
1378 return 1;
1379 }
1380 l3gd20h_interface_debug_print("l3gd20h: set data format big endian.\n");
1381 res = l3gd20h_get_data_format(&gs_handle, &data_format);
1382 if (res != 0)
1383 {
1384 l3gd20h_interface_debug_print("l3gd20h: get data format failed.\n");
1385 (void)l3gd20h_deinit(&gs_handle);
1386
1387 return 1;
1388 }
1389 l3gd20h_interface_debug_print("l3gd20h: check data format %s.\n", data_format == L3GD20H_DATA_FORMAT_BIG_ENDIAN ? "ok" : "error");
1390
1391 /* little endian */
1393 if (res != 0)
1394 {
1395 l3gd20h_interface_debug_print("l3gd20h: set data format failed.\n");
1396 (void)l3gd20h_deinit(&gs_handle);
1397
1398 return 1;
1399 }
1400 l3gd20h_interface_debug_print("l3gd20h: set data format little endian.\n");
1401 res = l3gd20h_get_data_format(&gs_handle, &data_format);
1402 if (res != 0)
1403 {
1404 l3gd20h_interface_debug_print("l3gd20h: get data format failed.\n");
1405 (void)l3gd20h_deinit(&gs_handle);
1406
1407 return 1;
1408 }
1409 l3gd20h_interface_debug_print("l3gd20h: check data format %s.\n", data_format == L3GD20H_DATA_FORMAT_LITTLE_ENDIAN ? "ok" : "error");
1410
1411 /* l3gd20h_set_full_scale/l3gd20h_get_full_scale test */
1412 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_full_scale/l3gd20h_get_full_scale test.\n");
1413
1414 /* ±245 dps */
1416 if (res != 0)
1417 {
1418 l3gd20h_interface_debug_print("l3gd20h: set full scale failed.\n");
1419 (void)l3gd20h_deinit(&gs_handle);
1420
1421 return 1;
1422 }
1423 l3gd20h_interface_debug_print("l3gd20h: set full scale ± 245 dps.\n");
1424 res = l3gd20h_get_full_scale(&gs_handle, &full_scale);
1425 if (res != 0)
1426 {
1427 l3gd20h_interface_debug_print("l3gd20h: get full scale failed.\n");
1428 (void)l3gd20h_deinit(&gs_handle);
1429
1430 return 1;
1431 }
1432 l3gd20h_interface_debug_print("l3gd20h: check full scale %s.\n", full_scale == L3GD20H_FULL_SCALE_245_DPS ? "ok" : "error");
1433
1434 /* ±500 dps */
1436 if (res != 0)
1437 {
1438 l3gd20h_interface_debug_print("l3gd20h: set full scale failed.\n");
1439 (void)l3gd20h_deinit(&gs_handle);
1440
1441 return 1;
1442 }
1443 l3gd20h_interface_debug_print("l3gd20h: set full scale ± 500 dps.\n");
1444 res = l3gd20h_get_full_scale(&gs_handle, &full_scale);
1445 if (res != 0)
1446 {
1447 l3gd20h_interface_debug_print("l3gd20h: get full scale failed.\n");
1448 (void)l3gd20h_deinit(&gs_handle);
1449
1450 return 1;
1451 }
1452 l3gd20h_interface_debug_print("l3gd20h: check full scale %s.\n", full_scale == L3GD20H_FULL_SCALE_500_DPS ? "ok" : "error");
1453
1454 /* ±2000 dps */
1456 if (res != 0)
1457 {
1458 l3gd20h_interface_debug_print("l3gd20h: set full scale failed.\n");
1459 (void)l3gd20h_deinit(&gs_handle);
1460
1461 return 1;
1462 }
1463 l3gd20h_interface_debug_print("l3gd20h: set full scale ± 2000 dps.\n");
1464 res = l3gd20h_get_full_scale(&gs_handle, &full_scale);
1465 if (res != 0)
1466 {
1467 l3gd20h_interface_debug_print("l3gd20h: get full scale failed.\n");
1468 (void)l3gd20h_deinit(&gs_handle);
1469
1470 return 1;
1471 }
1472 l3gd20h_interface_debug_print("l3gd20h: check full scale %s.\n", full_scale == L3GD20H_FULL_SCALE_2000_DPS ? "ok" : "error");
1473
1474
1475 /* l3gd20h_set_level_sensitive_latched/l3gd20h_get_level_sensitive_latched test */
1476 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_level_sensitive_latched/l3gd20h_get_level_sensitive_latched test.\n");
1477
1478 /* disable */
1480 if (res != 0)
1481 {
1482 l3gd20h_interface_debug_print("l3gd20h: set level sensitive latched failed.\n");
1483 (void)l3gd20h_deinit(&gs_handle);
1484
1485 return 1;
1486 }
1487 l3gd20h_interface_debug_print("l3gd20h: disable level sensitive latched.\n");
1488 res = l3gd20h_get_level_sensitive_latched(&gs_handle, &enable);
1489 if (res != 0)
1490 {
1491 l3gd20h_interface_debug_print("l3gd20h: get level sensitive latched failed.\n");
1492 (void)l3gd20h_deinit(&gs_handle);
1493
1494 return 1;
1495 }
1496 l3gd20h_interface_debug_print("l3gd20h: check level sensitive latched %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
1497
1498 /* enable */
1500 if (res != 0)
1501 {
1502 l3gd20h_interface_debug_print("l3gd20h: set level sensitive latched failed.\n");
1503 (void)l3gd20h_deinit(&gs_handle);
1504
1505 return 1;
1506 }
1507 l3gd20h_interface_debug_print("l3gd20h: enable level sensitive latched.\n");
1508 res = l3gd20h_get_level_sensitive_latched(&gs_handle, &enable);
1509 if (res != 0)
1510 {
1511 l3gd20h_interface_debug_print("l3gd20h: get level sensitive latched failed.\n");
1512 (void)l3gd20h_deinit(&gs_handle);
1513
1514 return 1;
1515 }
1516 l3gd20h_interface_debug_print("l3gd20h: check level sensitive latched %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
1517
1518 /* l3gd20h_set_self_test/l3gd20h_get_self_test test */
1519 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_self_test/l3gd20h_get_self_test test.\n");
1520
1521 /* self test 0 */
1522 res = l3gd20h_set_self_test(&gs_handle, L3GD20H_SELF_TEST_0);
1523 if (res != 0)
1524 {
1525 l3gd20h_interface_debug_print("l3gd20h: set self test failed.\n");
1526 (void)l3gd20h_deinit(&gs_handle);
1527
1528 return 1;
1529 }
1530 l3gd20h_interface_debug_print("l3gd20h: set self test 0.\n");
1531 res = l3gd20h_get_self_test(&gs_handle, &self_test);
1532 if (res != 0)
1533 {
1534 l3gd20h_interface_debug_print("l3gd20h: get self test failed.\n");
1535 (void)l3gd20h_deinit(&gs_handle);
1536
1537 return 1;
1538 }
1539 l3gd20h_interface_debug_print("l3gd20h: check self test %s.\n", self_test == L3GD20H_SELF_TEST_0 ? "ok" : "error");
1540
1541 /* self test 1 */
1542 res = l3gd20h_set_self_test(&gs_handle, L3GD20H_SELF_TEST_1);
1543 if (res != 0)
1544 {
1545 l3gd20h_interface_debug_print("l3gd20h: set self test failed.\n");
1546 (void)l3gd20h_deinit(&gs_handle);
1547
1548 return 1;
1549 }
1550 l3gd20h_interface_debug_print("l3gd20h: set self test 1.\n");
1551 res = l3gd20h_get_self_test(&gs_handle, &self_test);
1552 if (res != 0)
1553 {
1554 l3gd20h_interface_debug_print("l3gd20h: get self test failed.\n");
1555 (void)l3gd20h_deinit(&gs_handle);
1556
1557 return 1;
1558 }
1559 l3gd20h_interface_debug_print("l3gd20h: check self test %s.\n", self_test == L3GD20H_SELF_TEST_1 ? "ok" : "error");
1560
1561 /* self test normal */
1563 if (res != 0)
1564 {
1565 l3gd20h_interface_debug_print("l3gd20h: set self test failed.\n");
1566 (void)l3gd20h_deinit(&gs_handle);
1567
1568 return 1;
1569 }
1570 l3gd20h_interface_debug_print("l3gd20h: set self test normal.\n");
1571 res = l3gd20h_get_self_test(&gs_handle, &self_test);
1572 if (res != 0)
1573 {
1574 l3gd20h_interface_debug_print("l3gd20h: get self test failed.\n");
1575 (void)l3gd20h_deinit(&gs_handle);
1576
1577 return 1;
1578 }
1579 l3gd20h_interface_debug_print("l3gd20h: check self test %s.\n", self_test == L3GD20H_SELF_TEST_NORMAL ? "ok" : "error");
1580
1581 /* if iic interface */
1582 if (interface == L3GD20H_INTERFACE_IIC)
1583 {
1584 /* l3gd20h_set_spi_wire/l3gd20h_get_spi_wire test */
1585 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_spi_wire/l3gd20h_get_spi_wire test.\n");
1586
1587 /* spi wire 3 */
1588 res = l3gd20h_set_spi_wire(&gs_handle, L3GD20H_SPI_WIRE_3);
1589 if (res != 0)
1590 {
1591 l3gd20h_interface_debug_print("l3gd20h: set spi wire failed.\n");
1592 (void)l3gd20h_deinit(&gs_handle);
1593
1594 return 1;
1595 }
1596 l3gd20h_interface_debug_print("l3gd20h: set spi wire 3.\n");
1597 res = l3gd20h_get_spi_wire(&gs_handle, &spi_wire);
1598 if (res != 0)
1599 {
1600 l3gd20h_interface_debug_print("l3gd20h: get spi wire failed.\n");
1601 (void)l3gd20h_deinit(&gs_handle);
1602
1603 return 1;
1604 }
1605 l3gd20h_interface_debug_print("l3gd20h: check spi wire %s.\n", spi_wire == L3GD20H_SPI_WIRE_3 ? "ok" : "error");
1606
1607 /* spi wire 4 */
1608 res = l3gd20h_set_spi_wire(&gs_handle, L3GD20H_SPI_WIRE_4);
1609 if (res != 0)
1610 {
1611 l3gd20h_interface_debug_print("l3gd20h: set spi wire failed.\n");
1612 (void)l3gd20h_deinit(&gs_handle);
1613
1614 return 1;
1615 }
1616 l3gd20h_interface_debug_print("l3gd20h: set spi wire 4.\n");
1617 res = l3gd20h_get_spi_wire(&gs_handle, &spi_wire);
1618 if (res != 0)
1619 {
1620 l3gd20h_interface_debug_print("l3gd20h: get spi wire failed.\n");
1621 (void)l3gd20h_deinit(&gs_handle);
1622
1623 return 1;
1624 }
1625 l3gd20h_interface_debug_print("l3gd20h: check spi wire %s.\n", spi_wire == L3GD20H_SPI_WIRE_4 ? "ok" : "error");
1626 }
1627
1628 /* l3gd20h_set_high_pass_filter/l3gd20h_get_high_pass_filter test */
1629 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_high_pass_filter/l3gd20h_get_high_pass_filter test.\n");
1630
1631 /* disable */
1633 if (res != 0)
1634 {
1635 l3gd20h_interface_debug_print("l3gd20h: set high pass filter failed.\n");
1636 (void)l3gd20h_deinit(&gs_handle);
1637
1638 return 1;
1639 }
1640 l3gd20h_interface_debug_print("l3gd20h: disable high pass filter.\n");
1641 res = l3gd20h_get_high_pass_filter(&gs_handle, &enable);
1642 if (res != 0)
1643 {
1644 l3gd20h_interface_debug_print("l3gd20h: get high pass filter failed.\n");
1645 (void)l3gd20h_deinit(&gs_handle);
1646
1647 return 1;
1648 }
1649 l3gd20h_interface_debug_print("l3gd20h: check high pass filter %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
1650
1651 /* enable */
1653 if (res != 0)
1654 {
1655 l3gd20h_interface_debug_print("l3gd20h: set high pass filter failed.\n");
1656 (void)l3gd20h_deinit(&gs_handle);
1657
1658 return 1;
1659 }
1660 l3gd20h_interface_debug_print("l3gd20h: enable high pass filter.\n");
1661 res = l3gd20h_get_high_pass_filter(&gs_handle, &enable);
1662 if (res != 0)
1663 {
1664 l3gd20h_interface_debug_print("l3gd20h: get high pass filter failed.\n");
1665 (void)l3gd20h_deinit(&gs_handle);
1666
1667 return 1;
1668 }
1669 l3gd20h_interface_debug_print("l3gd20h: check high pass filter %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
1670
1671 /* l3gd20h_set_out_selection/l3gd20h_get_out_selection test */
1672 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_out_selection/l3gd20h_get_out_selection test.\n");
1673
1674 /* LPF1 */
1676 if (res != 0)
1677 {
1678 l3gd20h_interface_debug_print("l3gd20h: set out selection failed.\n");
1679 (void)l3gd20h_deinit(&gs_handle);
1680
1681 return 1;
1682 }
1683 l3gd20h_interface_debug_print("l3gd20h: set out selection LPF1.\n");
1684 res = l3gd20h_get_out_selection(&gs_handle, &selection);
1685 if (res != 0)
1686 {
1687 l3gd20h_interface_debug_print("l3gd20h: get out selection failed.\n");
1688 (void)l3gd20h_deinit(&gs_handle);
1689
1690 return 1;
1691 }
1692 l3gd20h_interface_debug_print("l3gd20h: check out selection %s.\n", selection == L3GD20H_SELECTION_LPF1 ? "ok" : "error");
1693
1694 /* LPF1 HPF */
1696 if (res != 0)
1697 {
1698 l3gd20h_interface_debug_print("l3gd20h: set out selection failed.\n");
1699 (void)l3gd20h_deinit(&gs_handle);
1700
1701 return 1;
1702 }
1703 l3gd20h_interface_debug_print("l3gd20h: set out selection LPF1-HPF.\n");
1704 res = l3gd20h_get_out_selection(&gs_handle, &selection);
1705 if (res != 0)
1706 {
1707 l3gd20h_interface_debug_print("l3gd20h: get out selection failed.\n");
1708 (void)l3gd20h_deinit(&gs_handle);
1709
1710 return 1;
1711 }
1712 l3gd20h_interface_debug_print("l3gd20h: check out selection %s.\n", selection == L3GD20H_SELECTION_LPF1_HPF ? "ok" : "error");
1713
1714 /* LPF1 HPF LPF2 */
1716 if (res != 0)
1717 {
1718 l3gd20h_interface_debug_print("l3gd20h: set out selection failed.\n");
1719 (void)l3gd20h_deinit(&gs_handle);
1720
1721 return 1;
1722 }
1723 l3gd20h_interface_debug_print("l3gd20h: set out selection LPF1-HPF-LPF2.\n");
1724 res = l3gd20h_get_out_selection(&gs_handle, &selection);
1725 if (res != 0)
1726 {
1727 l3gd20h_interface_debug_print("l3gd20h: get out selection failed.\n");
1728 (void)l3gd20h_deinit(&gs_handle);
1729
1730 return 1;
1731 }
1732 l3gd20h_interface_debug_print("l3gd20h: check out selection %s.\n", selection == L3GD20H_SELECTION_LPF1_HPF_LPF2 ? "ok" : "error");
1733
1734 /* l3gd20h_set_high_pass_filter_reference/l3gd20h_get_high_pass_filter_reference test */
1735 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_high_pass_filter_reference/l3gd20h_get_high_pass_filter_reference test.\n");
1736
1737 /* set high pass filter reference */
1738 value = rand() % 256;
1739 res = l3gd20h_set_high_pass_filter_reference(&gs_handle, value);
1740 if (res != 0)
1741 {
1742 l3gd20h_interface_debug_print("l3gd20h: set high pass filter reference failed.\n");
1743 (void)l3gd20h_deinit(&gs_handle);
1744
1745 return 1;
1746 }
1747 l3gd20h_interface_debug_print("l3gd20h: set high pass filter reference 0x%02X.\n", value);
1748 res = l3gd20h_get_high_pass_filter_reference(&gs_handle, (uint8_t *)&value_check);
1749 if (res != 0)
1750 {
1751 l3gd20h_interface_debug_print("l3gd20h: get high pass filter reference failed.\n");
1752 (void)l3gd20h_deinit(&gs_handle);
1753
1754 return 1;
1755 }
1756 l3gd20h_interface_debug_print("l3gd20h: check high pass filter reference %s.\n", value_check == value ? "ok" : "error");
1757
1758 /* if spi interface */
1759 if (interface == L3GD20H_INTERFACE_SPI)
1760 {
1761 /* l3gd20h_set_iic/l3gd20h_get_iic test */
1762 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_iic/l3gd20h_get_iic test.\n");
1763
1764 /* disable */
1765 res = l3gd20h_set_iic(&gs_handle, L3GD20H_BOOL_FALSE);
1766 if (res != 0)
1767 {
1768 l3gd20h_interface_debug_print("l3gd20h: set iic failed.\n");
1769 (void)l3gd20h_deinit(&gs_handle);
1770
1771 return 1;
1772 }
1773 l3gd20h_interface_debug_print("l3gd20h: disable iic.\n");
1774 res = l3gd20h_get_iic(&gs_handle, &enable);
1775 if (res != 0)
1776 {
1777 l3gd20h_interface_debug_print("l3gd20h: get iic failed.\n");
1778 (void)l3gd20h_deinit(&gs_handle);
1779
1780 return 1;
1781 }
1782 l3gd20h_interface_debug_print("l3gd20h: check iic %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
1783
1784 /* enable */
1785 res = l3gd20h_set_iic(&gs_handle, L3GD20H_BOOL_TRUE);
1786 if (res != 0)
1787 {
1788 l3gd20h_interface_debug_print("l3gd20h: set iic failed.\n");
1789 (void)l3gd20h_deinit(&gs_handle);
1790
1791 return 1;
1792 }
1793 l3gd20h_interface_debug_print("l3gd20h: enable iic.\n");
1794 res = l3gd20h_get_iic(&gs_handle, &enable);
1795 if (res != 0)
1796 {
1797 l3gd20h_interface_debug_print("l3gd20h: get iic failed.\n");
1798 (void)l3gd20h_deinit(&gs_handle);
1799
1800 return 1;
1801 }
1802 l3gd20h_interface_debug_print("l3gd20h: check iic %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
1803 }
1804
1805 /* l3gd20h_set_interrupt1/l3gd20h_get_interrupt1 test */
1806 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_interrupt1/l3gd20h_get_interrupt1 test.\n");
1807
1808 /* enable */
1809 res = l3gd20h_set_interrupt1(&gs_handle, L3GD20H_BOOL_TRUE);
1810 if (res != 0)
1811 {
1812 l3gd20h_interface_debug_print("l3gd20h: set interrupt1 failed.\n");
1813 (void)l3gd20h_deinit(&gs_handle);
1814
1815 return 1;
1816 }
1817 l3gd20h_interface_debug_print("l3gd20h: enable interrupt1.\n");
1818 res = l3gd20h_get_interrupt1(&gs_handle, &enable);
1819 if (res != 0)
1820 {
1821 l3gd20h_interface_debug_print("l3gd20h: get interrupt1 failed.\n");
1822 (void)l3gd20h_deinit(&gs_handle);
1823
1824 return 1;
1825 }
1826 l3gd20h_interface_debug_print("l3gd20h: check interrupt1 %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
1827
1828 /* disable */
1829 res = l3gd20h_set_interrupt1(&gs_handle, L3GD20H_BOOL_FALSE);
1830 if (res != 0)
1831 {
1832 l3gd20h_interface_debug_print("l3gd20h: set interrupt1 failed.\n");
1833 (void)l3gd20h_deinit(&gs_handle);
1834
1835 return 1;
1836 }
1837 l3gd20h_interface_debug_print("l3gd20h: disable interrupt1.\n");
1838 res = l3gd20h_get_interrupt1(&gs_handle, &enable);
1839 if (res != 0)
1840 {
1841 l3gd20h_interface_debug_print("l3gd20h: get interrupt1 failed.\n");
1842 (void)l3gd20h_deinit(&gs_handle);
1843
1844 return 1;
1845 }
1846 l3gd20h_interface_debug_print("l3gd20h: check interrupt1 %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
1847
1848 /* l3gd20h_set_boot_on_interrupt1/l3gd20h_get_boot_on_interrupt1 test */
1849 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_boot_on_interrupt1/l3gd20h_get_boot_on_interrupt1 test.\n");
1850
1851 /* enable */
1853 if (res != 0)
1854 {
1855 l3gd20h_interface_debug_print("l3gd20h: set boot on interrupt1 failed.\n");
1856 (void)l3gd20h_deinit(&gs_handle);
1857
1858 return 1;
1859 }
1860 l3gd20h_interface_debug_print("l3gd20h: enable boot on interrupt1.\n");
1861 res = l3gd20h_get_boot_on_interrupt1(&gs_handle, &enable);
1862 if (res != 0)
1863 {
1864 l3gd20h_interface_debug_print("l3gd20h: get boot on interrupt1 failed.\n");
1865 (void)l3gd20h_deinit(&gs_handle);
1866
1867 return 1;
1868 }
1869 l3gd20h_interface_debug_print("l3gd20h: check boot on interrupt1 %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
1870
1871 /* disable */
1873 if (res != 0)
1874 {
1875 l3gd20h_interface_debug_print("l3gd20h: set boot on interrupt1 failed.\n");
1876 (void)l3gd20h_deinit(&gs_handle);
1877
1878 return 1;
1879 }
1880 l3gd20h_interface_debug_print("l3gd20h: disable boot on interrupt1.\n");
1881 res = l3gd20h_get_boot_on_interrupt1(&gs_handle, &enable);
1882 if (res != 0)
1883 {
1884 l3gd20h_interface_debug_print("l3gd20h: get boot on interrupt1 failed.\n");
1885 (void)l3gd20h_deinit(&gs_handle);
1886
1887 return 1;
1888 }
1889 l3gd20h_interface_debug_print("l3gd20h: check boot on interrupt1 %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
1890
1891 /* l3gd20h_set_interrupt_active_level/l3gd20h_get_interrupt_active_level test */
1892 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_interrupt_active_level/l3gd20h_get_interrupt_active_level test.\n");
1893
1894 /* high */
1896 if (res != 0)
1897 {
1898 l3gd20h_interface_debug_print("l3gd20h: set interrupt active level failed.\n");
1899 (void)l3gd20h_deinit(&gs_handle);
1900
1901 return 1;
1902 }
1903 l3gd20h_interface_debug_print("l3gd20h: set interrupt active level high.\n");
1904 res = l3gd20h_get_interrupt_active_level(&gs_handle, &level);
1905 if (res != 0)
1906 {
1907 l3gd20h_interface_debug_print("l3gd20h: get interrupt active level failed.\n");
1908 (void)l3gd20h_deinit(&gs_handle);
1909
1910 return 1;
1911 }
1912 l3gd20h_interface_debug_print("l3gd20h: check interrupt active level %s.\n", level == L3GD20H_INTERRUPT_ACTIVE_LEVEL_HIGH ? "ok" : "error");
1913
1914 /* low */
1916 if (res != 0)
1917 {
1918 l3gd20h_interface_debug_print("l3gd20h: set interrupt active level failed.\n");
1919 (void)l3gd20h_deinit(&gs_handle);
1920
1921 return 1;
1922 }
1923 l3gd20h_interface_debug_print("l3gd20h: set interrupt active level low.\n");
1924 res = l3gd20h_get_interrupt_active_level(&gs_handle, &level);
1925 if (res != 0)
1926 {
1927 l3gd20h_interface_debug_print("l3gd20h: get interrupt active level failed.\n");
1928 (void)l3gd20h_deinit(&gs_handle);
1929
1930 return 1;
1931 }
1932 l3gd20h_interface_debug_print("l3gd20h: check interrupt active level %s.\n", level == L3GD20H_INTERRUPT_ACTIVE_LEVEL_LOW ? "ok" : "error");
1933
1934 /* l3gd20h_set_interrupt_pin_type/l3gd20h_get_interrupt_pin_type test */
1935 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_interrupt_pin_type/l3gd20h_get_interrupt_pin_type test.\n");
1936
1937 /* push-pull */
1939 if (res != 0)
1940 {
1941 l3gd20h_interface_debug_print("l3gd20h: set interrupt pin type failed.\n");
1942 (void)l3gd20h_deinit(&gs_handle);
1943
1944 return 1;
1945 }
1946 l3gd20h_interface_debug_print("l3gd20h: set push pull pin type.\n");
1947 res = l3gd20h_get_interrupt_pin_type(&gs_handle, &pin_type);
1948 if (res != 0)
1949 {
1950 l3gd20h_interface_debug_print("l3gd20h: get interrupt pin type failed.\n");
1951 (void)l3gd20h_deinit(&gs_handle);
1952
1953 return 1;
1954 }
1955 l3gd20h_interface_debug_print("l3gd20h: check interrupt pin type %s.\n", pin_type == L3GD20H_PIN_PUSH_PULL ? "ok" : "error");
1956
1957 /* open drain */
1959 if (res != 0)
1960 {
1961 l3gd20h_interface_debug_print("l3gd20h: set interrupt pin type failed.\n");
1962 (void)l3gd20h_deinit(&gs_handle);
1963
1964 return 1;
1965 }
1966 l3gd20h_interface_debug_print("l3gd20h: set open drain pin type.\n");
1967 res = l3gd20h_get_interrupt_pin_type(&gs_handle, &pin_type);
1968 if (res != 0)
1969 {
1970 l3gd20h_interface_debug_print("l3gd20h: get interrupt pin type failed.\n");
1971 (void)l3gd20h_deinit(&gs_handle);
1972
1973 return 1;
1974 }
1975 l3gd20h_interface_debug_print("l3gd20h: check interrupt pin type %s.\n", pin_type == L3GD20H_PIN_OPEN_DRAIN ? "ok" : "error");
1976
1977 /* l3gd20h_set_data_ready_on_interrupt2/l3gd20h_get_data_ready_on_interrupt2 test */
1978 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_data_ready_on_interrupt2/l3gd20h_get_data_ready_on_interrupt2 test.\n");
1979
1980 /* disable */
1982 if (res != 0)
1983 {
1984 l3gd20h_interface_debug_print("l3gd20h: set data ready on interrupt2 failed.\n");
1985 (void)l3gd20h_deinit(&gs_handle);
1986
1987 return 1;
1988 }
1989 l3gd20h_interface_debug_print("l3gd20h: disable data ready on interrupt2.\n");
1990 res = l3gd20h_get_data_ready_on_interrupt2(&gs_handle, &enable);
1991 if (res != 0)
1992 {
1993 l3gd20h_interface_debug_print("l3gd20h: get data ready on interrupt2 failed.\n");
1994 (void)l3gd20h_deinit(&gs_handle);
1995
1996 return 1;
1997 }
1998 l3gd20h_interface_debug_print("l3gd20h: check data ready on interrupt2 %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
1999
2000 /* enable */
2002 if (res != 0)
2003 {
2004 l3gd20h_interface_debug_print("l3gd20h: set data ready on interrupt2 failed.\n");
2005 (void)l3gd20h_deinit(&gs_handle);
2006
2007 return 1;
2008 }
2009 l3gd20h_interface_debug_print("l3gd20h: enable data ready on interrupt2.\n");
2010 res = l3gd20h_get_data_ready_on_interrupt2(&gs_handle, &enable);
2011 if (res != 0)
2012 {
2013 l3gd20h_interface_debug_print("l3gd20h: get data ready on interrupt2 failed.\n");
2014 (void)l3gd20h_deinit(&gs_handle);
2015
2016 return 1;
2017 }
2018 l3gd20h_interface_debug_print("l3gd20h: check data ready on interrupt2 %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
2019
2020 /* l3gd20h_set_fifo_threshold_on_interrupt2/l3gd20h_get_fifo_threshold_on_interrupt2 test */
2021 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_fifo_threshold_on_interrupt2/l3gd20h_get_fifo_threshold_on_interrupt2 test.\n");
2022
2023 /* disable */
2025 if (res != 0)
2026 {
2027 l3gd20h_interface_debug_print("l3gd20h: set fifo threshold on interrupt2 failed.\n");
2028 (void)l3gd20h_deinit(&gs_handle);
2029
2030 return 1;
2031 }
2032 l3gd20h_interface_debug_print("l3gd20h: disable fifo threshold on interrupt2.\n");
2033 res = l3gd20h_get_fifo_threshold_on_interrupt2(&gs_handle, &enable);
2034 if (res != 0)
2035 {
2036 l3gd20h_interface_debug_print("l3gd20h: get fifo threshold on interrupt2 failed.\n");
2037 (void)l3gd20h_deinit(&gs_handle);
2038
2039 return 1;
2040 }
2041 l3gd20h_interface_debug_print("l3gd20h: check fifo threshold on interrupt2 %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
2042
2043 /* enable */
2045 if (res != 0)
2046 {
2047 l3gd20h_interface_debug_print("l3gd20h: set fifo threshold on interrupt2 failed.\n");
2048 (void)l3gd20h_deinit(&gs_handle);
2049
2050 return 1;
2051 }
2052 l3gd20h_interface_debug_print("l3gd20h: enable fifo threshold on interrupt2.\n");
2053 res = l3gd20h_get_fifo_threshold_on_interrupt2(&gs_handle, &enable);
2054 if (res != 0)
2055 {
2056 l3gd20h_interface_debug_print("l3gd20h: get fifo threshold on interrupt2 failed.\n");
2057 (void)l3gd20h_deinit(&gs_handle);
2058
2059 return 1;
2060 }
2061 l3gd20h_interface_debug_print("l3gd20h: check fifo threshold on interrupt2 %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
2062
2063 /* l3gd20h_set_fifo_threshold_on_interrupt2/l3gd20h_get_fifo_threshold_on_interrupt2 test */
2064 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_fifo_overrun_on_interrupt2/l3gd20h_get_fifo_overrun_on_interrupt2 test.\n");
2065
2066 /* enable */
2068 if (res != 0)
2069 {
2070 l3gd20h_interface_debug_print("l3gd20h: set fifo overrun on interrupt2 failed.\n");
2071 (void)l3gd20h_deinit(&gs_handle);
2072
2073 return 1;
2074 }
2075 l3gd20h_interface_debug_print("l3gd20h: enable fifo overrun on interrupt2.\n");
2076 res = l3gd20h_get_fifo_overrun_on_interrupt2(&gs_handle, &enable);
2077 if (res != 0)
2078 {
2079 l3gd20h_interface_debug_print("l3gd20h: get fifo overrun on interrupt2 failed.\n");
2080 (void)l3gd20h_deinit(&gs_handle);
2081
2082 return 1;
2083 }
2084 l3gd20h_interface_debug_print("l3gd20h: check fifo overrun on interrupt2 %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
2085
2086 /* disable */
2088 if (res != 0)
2089 {
2090 l3gd20h_interface_debug_print("l3gd20h: set fifo overrun on interrupt2 failed.\n");
2091 (void)l3gd20h_deinit(&gs_handle);
2092
2093 return 1;
2094 }
2095 l3gd20h_interface_debug_print("l3gd20h: disable fifo overrun on interrupt2.\n");
2096 res = l3gd20h_get_fifo_overrun_on_interrupt2(&gs_handle, &enable);
2097 if (res != 0)
2098 {
2099 l3gd20h_interface_debug_print("l3gd20h: get fifo overrun on interrupt2 failed.\n");
2100 (void)l3gd20h_deinit(&gs_handle);
2101
2102 return 1;
2103 }
2104 l3gd20h_interface_debug_print("l3gd20h: check fifo overrun on interrupt2 %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
2105
2106 /* l3gd20h_set_fifo_empty_on_interrupt2/l3gd20h_get_fifo_empty_on_interrupt2 test */
2107 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_fifo_empty_on_interrupt2/l3gd20h_get_fifo_empty_on_interrupt2 test.\n");
2108
2109 /* enable */
2111 if (res != 0)
2112 {
2113 l3gd20h_interface_debug_print("l3gd20h: set fifo empty on interrupt2 failed.\n");
2114 (void)l3gd20h_deinit(&gs_handle);
2115
2116 return 1;
2117 }
2118 l3gd20h_interface_debug_print("l3gd20h: enable fifo empty on interrupt2.\n");
2119 res = l3gd20h_get_fifo_empty_on_interrupt2(&gs_handle, &enable);
2120 if (res != 0)
2121 {
2122 l3gd20h_interface_debug_print("l3gd20h: get fifo empty on interrupt2 failed.\n");
2123 (void)l3gd20h_deinit(&gs_handle);
2124
2125 return 1;
2126 }
2127 l3gd20h_interface_debug_print("l3gd20h: check fifo empty on interrupt2 %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
2128
2129 /* disable */
2131 if (res != 0)
2132 {
2133 l3gd20h_interface_debug_print("l3gd20h: set fifo empty on interrupt2 failed.\n");
2134 (void)l3gd20h_deinit(&gs_handle);
2135
2136 return 1;
2137 }
2138 l3gd20h_interface_debug_print("l3gd20h: disable fifo empty on interrupt2.\n");
2139 res = l3gd20h_get_fifo_empty_on_interrupt2(&gs_handle, &enable);
2140 if (res != 0)
2141 {
2142 l3gd20h_interface_debug_print("l3gd20h: get fifo empty on interrupt2 failed.\n");
2143 (void)l3gd20h_deinit(&gs_handle);
2144
2145 return 1;
2146 }
2147 l3gd20h_interface_debug_print("l3gd20h: check fifo empty on interrupt2 %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
2148
2149 /* l3gd20h_set_interrupt_selection/l3gd20h_get_interrupt_selection test */
2150 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_interrupt_selection/l3gd20h_get_interrupt_selection test.\n");
2151
2152 /* LPF1 */
2154 if (res != 0)
2155 {
2156 l3gd20h_interface_debug_print("l3gd20h: set interrupt selection failed.\n");
2157 (void)l3gd20h_deinit(&gs_handle);
2158
2159 return 1;
2160 }
2161 l3gd20h_interface_debug_print("l3gd20h: set interrupt selection LPF1.\n");
2162 res = l3gd20h_get_interrupt_selection(&gs_handle, &selection);
2163 if (res != 0)
2164 {
2165 l3gd20h_interface_debug_print("l3gd20h: get interrupt selection failed.\n");
2166 (void)l3gd20h_deinit(&gs_handle);
2167
2168 return 1;
2169 }
2170 l3gd20h_interface_debug_print("l3gd20h: check interrupt selection %s.\n", selection == L3GD20H_SELECTION_LPF1 ? "ok" : "error");
2171
2172 /* LPF1 HPF */
2174 if (res != 0)
2175 {
2176 l3gd20h_interface_debug_print("l3gd20h: set interrupt selection failed.\n");
2177 (void)l3gd20h_deinit(&gs_handle);
2178
2179 return 1;
2180 }
2181 l3gd20h_interface_debug_print("l3gd20h: set interrupt selection LPF1-HPF.\n");
2182 res = l3gd20h_get_interrupt_selection(&gs_handle, &selection);
2183 if (res != 0)
2184 {
2185 l3gd20h_interface_debug_print("l3gd20h: get interrupt selection failed.\n");
2186 (void)l3gd20h_deinit(&gs_handle);
2187
2188 return 1;
2189 }
2190 l3gd20h_interface_debug_print("l3gd20h: check interrupt selection %s.\n", selection == L3GD20H_SELECTION_LPF1_HPF ? "ok" : "error");
2191
2192 /* LPF1 HPF LPF2 */
2194 if (res != 0)
2195 {
2196 l3gd20h_interface_debug_print("l3gd20h: set interrupt selection failed.\n");
2197 (void)l3gd20h_deinit(&gs_handle);
2198
2199 return 1;
2200 }
2201 l3gd20h_interface_debug_print("l3gd20h: set interrupt selection LPF1-HPF-LPF2.\n");
2202 res = l3gd20h_get_interrupt_selection(&gs_handle, &selection);
2203 if (res != 0)
2204 {
2205 l3gd20h_interface_debug_print("l3gd20h: get interrupt selection failed.\n");
2206 (void)l3gd20h_deinit(&gs_handle);
2207
2208 return 1;
2209 }
2210 l3gd20h_interface_debug_print("l3gd20h: check interrupt selection %s.\n", selection == L3GD20H_SELECTION_LPF1_HPF_LPF2 ? "ok" : "error");
2211
2212 /* l3gd20h_set_interrupt_event/l3gd20h_get_interrupt_event test */
2213 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_interrupt_event/l3gd20h_get_interrupt_event test.\n");
2214
2215 /* L3GD20H_INTERRUPT_EVENT_AND_OR_COMBINATION enable */
2217 if (res != 0)
2218 {
2219 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
2220 (void)l3gd20h_deinit(&gs_handle);
2221
2222 return 1;
2223 }
2224 l3gd20h_interface_debug_print("l3gd20h: enable interrupt event L3GD20H_INTERRUPT_EVENT_AND_OR_COMBINATION.\n");
2226 if (res != 0)
2227 {
2228 l3gd20h_interface_debug_print("l3gd20h: get interrupt event failed.\n");
2229 (void)l3gd20h_deinit(&gs_handle);
2230
2231 return 1;
2232 }
2233 l3gd20h_interface_debug_print("l3gd20h: check interrupt event %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
2234
2235 /* L3GD20H_INTERRUPT_EVENT_AND_OR_COMBINATION disable */
2237 if (res != 0)
2238 {
2239 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
2240 (void)l3gd20h_deinit(&gs_handle);
2241
2242 return 1;
2243 }
2244 l3gd20h_interface_debug_print("l3gd20h: disable interrupt event L3GD20H_INTERRUPT_EVENT_AND_OR_COMBINATION.\n");
2246 if (res != 0)
2247 {
2248 l3gd20h_interface_debug_print("l3gd20h: get interrupt event failed.\n");
2249 (void)l3gd20h_deinit(&gs_handle);
2250
2251 return 1;
2252 }
2253 l3gd20h_interface_debug_print("l3gd20h: check interrupt event %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
2254
2255 /* L3GD20H_INTERRUPT_EVENT_LATCH enable */
2257 if (res != 0)
2258 {
2259 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
2260 (void)l3gd20h_deinit(&gs_handle);
2261
2262 return 1;
2263 }
2264 l3gd20h_interface_debug_print("l3gd20h: enable interrupt event L3GD20H_INTERRUPT_EVENT_LATCH.\n");
2266 if (res != 0)
2267 {
2268 l3gd20h_interface_debug_print("l3gd20h: get interrupt event failed.\n");
2269 (void)l3gd20h_deinit(&gs_handle);
2270
2271 return 1;
2272 }
2273 l3gd20h_interface_debug_print("l3gd20h: check interrupt event %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
2274
2275 /* L3GD20H_INTERRUPT_EVENT_LATCH disable */
2277 if (res != 0)
2278 {
2279 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
2280 (void)l3gd20h_deinit(&gs_handle);
2281
2282 return 1;
2283 }
2284 l3gd20h_interface_debug_print("l3gd20h: disable interrupt event L3GD20H_INTERRUPT_EVENT_LATCH.\n");
2286 if (res != 0)
2287 {
2288 l3gd20h_interface_debug_print("l3gd20h: get interrupt event failed.\n");
2289 (void)l3gd20h_deinit(&gs_handle);
2290
2291 return 1;
2292 }
2293 l3gd20h_interface_debug_print("l3gd20h: check interrupt event %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
2294
2295 /* L3GD20H_INTERRUPT_EVENT_Z_HIGH_EVENT enable */
2297 if (res != 0)
2298 {
2299 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
2300 (void)l3gd20h_deinit(&gs_handle);
2301
2302 return 1;
2303 }
2304 l3gd20h_interface_debug_print("l3gd20h: enable interrupt event L3GD20H_INTERRUPT_EVENT_Z_HIGH_EVENT.\n");
2306 if (res != 0)
2307 {
2308 l3gd20h_interface_debug_print("l3gd20h: get interrupt event failed.\n");
2309 (void)l3gd20h_deinit(&gs_handle);
2310
2311 return 1;
2312 }
2313 l3gd20h_interface_debug_print("l3gd20h: check interrupt event %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
2314
2315 /* L3GD20H_INTERRUPT_EVENT_Z_HIGH_EVENT disable */
2317 if (res != 0)
2318 {
2319 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
2320 (void)l3gd20h_deinit(&gs_handle);
2321
2322 return 1;
2323 }
2324 l3gd20h_interface_debug_print("l3gd20h: disable interrupt event L3GD20H_INTERRUPT_EVENT_Z_HIGH_EVENT.\n");
2326 if (res != 0)
2327 {
2328 l3gd20h_interface_debug_print("l3gd20h: get interrupt event failed.\n");
2329 (void)l3gd20h_deinit(&gs_handle);
2330
2331 return 1;
2332 }
2333 l3gd20h_interface_debug_print("l3gd20h: check interrupt event %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
2334
2335 /* L3GD20H_INTERRUPT_EVENT_Z_LOW_EVENT enable */
2337 if (res != 0)
2338 {
2339 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
2340 (void)l3gd20h_deinit(&gs_handle);
2341
2342 return 1;
2343 }
2344 l3gd20h_interface_debug_print("l3gd20h: enable interrupt event L3GD20H_INTERRUPT_EVENT_Z_LOW_EVENT.\n");
2346 if (res != 0)
2347 {
2348 l3gd20h_interface_debug_print("l3gd20h: get interrupt event failed.\n");
2349 (void)l3gd20h_deinit(&gs_handle);
2350
2351 return 1;
2352 }
2353 l3gd20h_interface_debug_print("l3gd20h: check interrupt event %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
2354
2355 /* L3GD20H_INTERRUPT_EVENT_Z_LOW_EVENT disable */
2357 if (res != 0)
2358 {
2359 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
2360 (void)l3gd20h_deinit(&gs_handle);
2361
2362 return 1;
2363 }
2364 l3gd20h_interface_debug_print("l3gd20h: disable interrupt event L3GD20H_INTERRUPT_EVENT_Z_LOW_EVENT.\n");
2366 if (res != 0)
2367 {
2368 l3gd20h_interface_debug_print("l3gd20h: get interrupt event failed.\n");
2369 (void)l3gd20h_deinit(&gs_handle);
2370
2371 return 1;
2372 }
2373 l3gd20h_interface_debug_print("l3gd20h: check interrupt event %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
2374
2375 /* L3GD20H_INTERRUPT_EVENT_Y_HIGH_EVENT enable */
2377 if (res != 0)
2378 {
2379 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
2380 (void)l3gd20h_deinit(&gs_handle);
2381
2382 return 1;
2383 }
2384 l3gd20h_interface_debug_print("l3gd20h: enable interrupt event L3GD20H_INTERRUPT_EVENT_Y_HIGH_EVENT.\n");
2386 if (res != 0)
2387 {
2388 l3gd20h_interface_debug_print("l3gd20h: get interrupt event failed.\n");
2389 (void)l3gd20h_deinit(&gs_handle);
2390
2391 return 1;
2392 }
2393 l3gd20h_interface_debug_print("l3gd20h: check interrupt event %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
2394
2395 /* L3GD20H_INTERRUPT_EVENT_Y_HIGH_EVENT disable */
2397 if (res != 0)
2398 {
2399 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
2400 (void)l3gd20h_deinit(&gs_handle);
2401
2402 return 1;
2403 }
2404 l3gd20h_interface_debug_print("l3gd20h: disable interrupt event L3GD20H_INTERRUPT_EVENT_Y_HIGH_EVENT.\n");
2406 if (res != 0)
2407 {
2408 l3gd20h_interface_debug_print("l3gd20h: get interrupt event failed.\n");
2409 (void)l3gd20h_deinit(&gs_handle);
2410
2411 return 1;
2412 }
2413 l3gd20h_interface_debug_print("l3gd20h: check interrupt event %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
2414
2415 /* L3GD20H_INTERRUPT_EVENT_Y_LOW_EVENT enable */
2417 if (res != 0)
2418 {
2419 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
2420 (void)l3gd20h_deinit(&gs_handle);
2421
2422 return 1;
2423 }
2424 l3gd20h_interface_debug_print("l3gd20h: enable interrupt event L3GD20H_INTERRUPT_EVENT_Y_LOW_EVENT.\n");
2426 if (res != 0)
2427 {
2428 l3gd20h_interface_debug_print("l3gd20h: get interrupt event failed.\n");
2429 (void)l3gd20h_deinit(&gs_handle);
2430
2431 return 1;
2432 }
2433 l3gd20h_interface_debug_print("l3gd20h: check interrupt event %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
2434
2435 /* L3GD20H_INTERRUPT_EVENT_Y_LOW_EVENT disable */
2437 if (res != 0)
2438 {
2439 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
2440 (void)l3gd20h_deinit(&gs_handle);
2441
2442 return 1;
2443 }
2444 l3gd20h_interface_debug_print("l3gd20h: disable interrupt event L3GD20H_INTERRUPT_EVENT_Y_LOW_EVENT.\n");
2446 if (res != 0)
2447 {
2448 l3gd20h_interface_debug_print("l3gd20h: get interrupt event failed.\n");
2449 (void)l3gd20h_deinit(&gs_handle);
2450
2451 return 1;
2452 }
2453 l3gd20h_interface_debug_print("l3gd20h: check interrupt event %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
2454
2455 /* L3GD20H_INTERRUPT_EVENT_X_HIGH_EVENT enable */
2457 if (res != 0)
2458 {
2459 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
2460 (void)l3gd20h_deinit(&gs_handle);
2461
2462 return 1;
2463 }
2464 l3gd20h_interface_debug_print("l3gd20h: enable interrupt event L3GD20H_INTERRUPT_EVENT_X_HIGH_EVENT.\n");
2466 if (res != 0)
2467 {
2468 l3gd20h_interface_debug_print("l3gd20h: get interrupt event failed.\n");
2469 (void)l3gd20h_deinit(&gs_handle);
2470
2471 return 1;
2472 }
2473 l3gd20h_interface_debug_print("l3gd20h: check interrupt event %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
2474
2475 /* L3GD20H_INTERRUPT_EVENT_X_HIGH_EVENT disable */
2477 if (res != 0)
2478 {
2479 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
2480 (void)l3gd20h_deinit(&gs_handle);
2481
2482 return 1;
2483 }
2484 l3gd20h_interface_debug_print("l3gd20h: disable interrupt event L3GD20H_INTERRUPT_EVENT_X_HIGH_EVENT.\n");
2486 if (res != 0)
2487 {
2488 l3gd20h_interface_debug_print("l3gd20h: get interrupt event failed.\n");
2489 (void)l3gd20h_deinit(&gs_handle);
2490
2491 return 1;
2492 }
2493 l3gd20h_interface_debug_print("l3gd20h: check interrupt event %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
2494
2495 /* L3GD20H_INTERRUPT_EVENT_X_LOW_EVENT enable */
2497 if (res != 0)
2498 {
2499 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
2500 (void)l3gd20h_deinit(&gs_handle);
2501
2502 return 1;
2503 }
2504 l3gd20h_interface_debug_print("l3gd20h: enable interrupt event L3GD20H_INTERRUPT_EVENT_X_LOW_EVENT.\n");
2506 if (res != 0)
2507 {
2508 l3gd20h_interface_debug_print("l3gd20h: get interrupt event failed.\n");
2509 (void)l3gd20h_deinit(&gs_handle);
2510
2511 return 1;
2512 }
2513 l3gd20h_interface_debug_print("l3gd20h: check interrupt event %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
2514
2515 /* L3GD20H_INTERRUPT_EVENT_X_LOW_EVENT disable */
2517 if (res != 0)
2518 {
2519 l3gd20h_interface_debug_print("l3gd20h: set interrupt event failed.\n");
2520 (void)l3gd20h_deinit(&gs_handle);
2521
2522 return 1;
2523 }
2524 l3gd20h_interface_debug_print("l3gd20h: disable interrupt event L3GD20H_INTERRUPT_EVENT_X_LOW_EVENT.\n");
2526 if (res != 0)
2527 {
2528 l3gd20h_interface_debug_print("l3gd20h: get interrupt event failed.\n");
2529 (void)l3gd20h_deinit(&gs_handle);
2530
2531 return 1;
2532 }
2533 l3gd20h_interface_debug_print("l3gd20h: check interrupt event %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
2534
2535 /* l3gd20h_set_x_interrupt_threshold/l3gd20h_get_x_interrupt_threshold test */
2536 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_x_interrupt_threshold/l3gd20h_get_x_interrupt_threshold test.\n");
2537 threshold = rand() % 32768;
2538 res = l3gd20h_set_x_interrupt_threshold(&gs_handle, threshold);
2539 if (res != 0)
2540 {
2541 l3gd20h_interface_debug_print("l3gd20h: set x interrupt threshold failed.\n");
2542 (void)l3gd20h_deinit(&gs_handle);
2543
2544 return 1;
2545 }
2546 l3gd20h_interface_debug_print("l3gd20h: set x interrupt threshold %d.\n", threshold);
2547 res = l3gd20h_get_x_interrupt_threshold(&gs_handle, (uint16_t *)&threshold_check);
2548 if (res != 0)
2549 {
2550 l3gd20h_interface_debug_print("l3gd20h: get x interrupt threshold failed.\n");
2551 (void)l3gd20h_deinit(&gs_handle);
2552
2553 return 1;
2554 }
2555 l3gd20h_interface_debug_print("l3gd20h: check x interrupt threshold %s.\n", threshold == threshold_check ? "ok" : "error");
2556
2557 /* l3gd20h_set_y_interrupt_threshold/l3gd20h_get_y_interrupt_threshold test */
2558 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_y_interrupt_threshold/l3gd20h_get_y_interrupt_threshold test.\n");
2559 threshold = rand() % 32768;
2560 res = l3gd20h_set_y_interrupt_threshold(&gs_handle, threshold);
2561 if (res != 0)
2562 {
2563 l3gd20h_interface_debug_print("l3gd20h: set y interrupt threshold failed.\n");
2564 (void)l3gd20h_deinit(&gs_handle);
2565
2566 return 1;
2567 }
2568 l3gd20h_interface_debug_print("l3gd20h: set y interrupt threshold %d.\n", threshold);
2569 res = l3gd20h_get_y_interrupt_threshold(&gs_handle, (uint16_t *)&threshold_check);
2570 if (res != 0)
2571 {
2572 l3gd20h_interface_debug_print("l3gd20h: get y interrupt threshold failed.\n");
2573 (void)l3gd20h_deinit(&gs_handle);
2574
2575 return 1;
2576 }
2577 l3gd20h_interface_debug_print("l3gd20h: check y interrupt threshold %s.\n", threshold == threshold_check ? "ok" : "error");
2578
2579 /* l3gd20h_set_z_interrupt_threshold/l3gd20h_get_z_interrupt_threshold test */
2580 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_z_interrupt_threshold/l3gd20h_get_z_interrupt_threshold test.\n");
2581 threshold = rand() % 32768;
2582 res = l3gd20h_set_z_interrupt_threshold(&gs_handle, threshold);
2583 if (res != 0)
2584 {
2585 l3gd20h_interface_debug_print("l3gd20h: set z interrupt threshold failed.\n");
2586 (void)l3gd20h_deinit(&gs_handle);
2587
2588 return 1;
2589 }
2590 l3gd20h_interface_debug_print("l3gd20h: set z interrupt threshold %d.\n", threshold);
2591 res = l3gd20h_get_z_interrupt_threshold(&gs_handle, (uint16_t *)&threshold_check);
2592 if (res != 0)
2593 {
2594 l3gd20h_interface_debug_print("l3gd20h: get z interrupt threshold failed.\n");
2595 (void)l3gd20h_deinit(&gs_handle);
2596
2597 return 1;
2598 }
2599 l3gd20h_interface_debug_print("l3gd20h: check z interrupt threshold %s.\n", threshold == threshold_check ? "ok" : "error");
2600
2601 /* l3gd20h_interrupt_threshold_convert_to_register/l3gd20h_interrupt_threshold_convert_to_data test */
2602 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_interrupt_threshold_convert_to_register/l3gd20h_interrupt_threshold_convert_to_data test.\n");
2603
2604 /* ±245 dps */
2606 if (res != 0)
2607 {
2608 l3gd20h_interface_debug_print("l3gd20h: set full scale failed.\n");
2609 (void)l3gd20h_deinit(&gs_handle);
2610
2611 return 1;
2612 }
2613 l3gd20h_interface_debug_print("l3gd20h: ±245 dps full scale.\n");
2614 dps = (float)(rand() % 2000) / 10.0f;
2615 res = l3gd20h_interrupt_threshold_convert_to_register(&gs_handle, dps, (uint16_t *)&reg);
2616 if (res != 0)
2617 {
2618 l3gd20h_interface_debug_print("l3gd20h: interrupt threshold convert to register failed.\n");
2619 (void)l3gd20h_deinit(&gs_handle);
2620
2621 return 1;
2622 }
2623 res = l3gd20h_interrupt_threshold_convert_to_data(&gs_handle, reg, (float *)&dps_check);
2624 if (res != 0)
2625 {
2626 l3gd20h_interface_debug_print("l3gd20h: interrupt threshold convert to data failed.\n");
2627 (void)l3gd20h_deinit(&gs_handle);
2628
2629 return 1;
2630 }
2631 l3gd20h_interface_debug_print("l3gd20h: %0.4f to %0.4f with reg 0x%04d.\n", dps, dps_check, reg);
2632
2633 /* ±500 dps */
2635 if (res != 0)
2636 {
2637 l3gd20h_interface_debug_print("l3gd20h: set full scale failed.\n");
2638 (void)l3gd20h_deinit(&gs_handle);
2639
2640 return 1;
2641 }
2642 l3gd20h_interface_debug_print("l3gd20h: ±500 dps full scale.\n");
2643 dps = (float)(rand() % 2000) / 10.0f;
2644 res = l3gd20h_interrupt_threshold_convert_to_register(&gs_handle, dps, (uint16_t *)&reg);
2645 if (res != 0)
2646 {
2647 l3gd20h_interface_debug_print("l3gd20h: interrupt threshold convert to register failed.\n");
2648 (void)l3gd20h_deinit(&gs_handle);
2649
2650 return 1;
2651 }
2652 res = l3gd20h_interrupt_threshold_convert_to_data(&gs_handle, reg, (float *)&dps_check);
2653 if (res != 0)
2654 {
2655 l3gd20h_interface_debug_print("l3gd20h: interrupt threshold convert to data failed.\n");
2656 (void)l3gd20h_deinit(&gs_handle);
2657
2658 return 1;
2659 }
2660 l3gd20h_interface_debug_print("l3gd20h: %0.4f to %0.4f with reg 0x%04d.\n", dps, dps_check, reg);
2661
2662 /* ±2000 dps */
2664 if (res != 0)
2665 {
2666 l3gd20h_interface_debug_print("l3gd20h: set full scale failed.\n");
2667 (void)l3gd20h_deinit(&gs_handle);
2668
2669 return 1;
2670 }
2671 l3gd20h_interface_debug_print("l3gd20h: ±2000 dps full scale.\n");
2672 dps = (float)(rand() % 2000) / 10.0f;
2673 res = l3gd20h_interrupt_threshold_convert_to_register(&gs_handle, dps, (uint16_t *)&reg);
2674 if (res != 0)
2675 {
2676 l3gd20h_interface_debug_print("l3gd20h: interrupt threshold convert to register failed.\n");
2677 (void)l3gd20h_deinit(&gs_handle);
2678
2679 return 1;
2680 }
2681 res = l3gd20h_interrupt_threshold_convert_to_data(&gs_handle, reg, (float *)&dps_check);
2682 if (res != 0)
2683 {
2684 l3gd20h_interface_debug_print("l3gd20h: interrupt threshold convert to data failed.\n");
2685 (void)l3gd20h_deinit(&gs_handle);
2686
2687 return 1;
2688 }
2689 l3gd20h_interface_debug_print("l3gd20h: %0.4f to %0.4f with reg 0x%04d.\n", dps, dps_check, reg);
2690
2691 /* l3gd20h_set_counter_mode/l3gd20h_get_counter_mode test */
2692 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_counter_mode/l3gd20h_get_counter_mode test.\n");
2693
2694 /* decrement mode */
2696 if (res != 0)
2697 {
2698 l3gd20h_interface_debug_print("l3gd20h: set counter mode failed.\n");
2699 (void)l3gd20h_deinit(&gs_handle);
2700
2701 return 1;
2702 }
2703 l3gd20h_interface_debug_print("l3gd20h: set decrement counter mode.\n");
2704 res = l3gd20h_get_counter_mode(&gs_handle, &counter_mode);
2705 if (res != 0)
2706 {
2707 l3gd20h_interface_debug_print("l3gd20h: get counter mode failed.\n");
2708 (void)l3gd20h_deinit(&gs_handle);
2709
2710 return 1;
2711 }
2712 l3gd20h_interface_debug_print("l3gd20h: check counter mode %s.\n", counter_mode == L3GD20H_COUNTER_MODE_DECREMENT ? "ok" : "error");
2713
2714 /* reset mode */
2716 if (res != 0)
2717 {
2718 l3gd20h_interface_debug_print("l3gd20h: set counter mode failed.\n");
2719 (void)l3gd20h_deinit(&gs_handle);
2720
2721 return 1;
2722 }
2723 l3gd20h_interface_debug_print("l3gd20h: set reset counter mode.\n");
2724 res = l3gd20h_get_counter_mode(&gs_handle, &counter_mode);
2725 if (res != 0)
2726 {
2727 l3gd20h_interface_debug_print("l3gd20h: get counter mode failed.\n");
2728 (void)l3gd20h_deinit(&gs_handle);
2729
2730 return 1;
2731 }
2732 l3gd20h_interface_debug_print("l3gd20h: check counter mode %s.\n", counter_mode == L3GD20H_COUNTER_MODE_RESET ? "ok" : "error");
2733
2734 /* l3gd20h_set_wait/l3gd20h_get_wait test */
2735 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_wait/l3gd20h_get_wait test.\n");
2736
2737 /* enable */
2738 res = l3gd20h_set_wait(&gs_handle, L3GD20H_BOOL_TRUE);
2739 if (res != 0)
2740 {
2741 l3gd20h_interface_debug_print("l3gd20h: set wait failed.\n");
2742 (void)l3gd20h_deinit(&gs_handle);
2743
2744 return 1;
2745 }
2746 l3gd20h_interface_debug_print("l3gd20h: enable wait.\n");
2747 res = l3gd20h_get_wait(&gs_handle, &enable);
2748 if (res != 0)
2749 {
2750 l3gd20h_interface_debug_print("l3gd20h: get wait failed.\n");
2751 (void)l3gd20h_deinit(&gs_handle);
2752
2753 return 1;
2754 }
2755 l3gd20h_interface_debug_print("l3gd20h: check wait %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
2756
2757 /* disable */
2758 res = l3gd20h_set_wait(&gs_handle, L3GD20H_BOOL_FALSE);
2759 if (res != 0)
2760 {
2761 l3gd20h_interface_debug_print("l3gd20h: set wait failed.\n");
2762 (void)l3gd20h_deinit(&gs_handle);
2763
2764 return 1;
2765 }
2766 l3gd20h_interface_debug_print("l3gd20h: disable wait.\n");
2767 res = l3gd20h_get_wait(&gs_handle, &enable);
2768 if (res != 0)
2769 {
2770 l3gd20h_interface_debug_print("l3gd20h: get wait failed.\n");
2771 (void)l3gd20h_deinit(&gs_handle);
2772
2773 return 1;
2774 }
2775 l3gd20h_interface_debug_print("l3gd20h: check wait %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
2776
2777 /* l3gd20h_set_duration/l3gd20h_get_duration test */
2778 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_duration/l3gd20h_get_duration test.\n");
2779 duration = rand() % 128;
2780 res = l3gd20h_set_duration(&gs_handle, duration);
2781 if (res != 0)
2782 {
2783 l3gd20h_interface_debug_print("l3gd20h: set duration failed.\n");
2784 (void)l3gd20h_deinit(&gs_handle);
2785
2786 return 1;
2787 }
2788 l3gd20h_interface_debug_print("l3gd20h: set duration 0x%02X.\n", duration);
2789 res = l3gd20h_get_duration(&gs_handle, (uint8_t *)&duration_check);
2790 if (res != 0)
2791 {
2792 l3gd20h_interface_debug_print("l3gd20h: get duration failed.\n");
2793 (void)l3gd20h_deinit(&gs_handle);
2794
2795 return 1;
2796 }
2797 l3gd20h_interface_debug_print("l3gd20h: check duration %s.\n", duration_check == duration ? "ok" : "error");
2798
2799 /* l3gd20h_set_data_ready_active_level/l3gd20h_get_data_ready_active_level test */
2800 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_data_ready_active_level/l3gd20h_get_data_ready_active_level test.\n");
2801
2802 /* active level high */
2804 if (res != 0)
2805 {
2806 l3gd20h_interface_debug_print("l3gd20h: set data ready active level failed.\n");
2807 (void)l3gd20h_deinit(&gs_handle);
2808
2809 return 1;
2810 }
2811 l3gd20h_interface_debug_print("l3gd20h: set data ready active level high.\n");
2812 res = l3gd20h_get_data_ready_active_level(&gs_handle, &active_level);
2813 if (res != 0)
2814 {
2815 l3gd20h_interface_debug_print("l3gd20h: get data ready active level failed.\n");
2816 (void)l3gd20h_deinit(&gs_handle);
2817
2818 return 1;
2819 }
2820 l3gd20h_interface_debug_print("l3gd20h: check data ready active level %s.\n", active_level == L3GD20H_INTERRUPT_ACTIVE_LEVEL_HIGH ? "ok" : "error");
2821
2822 /* active level low */
2824 if (res != 0)
2825 {
2826 l3gd20h_interface_debug_print("l3gd20h: set data ready active level failed.\n");
2827 (void)l3gd20h_deinit(&gs_handle);
2828
2829 return 1;
2830 }
2831 l3gd20h_interface_debug_print("l3gd20h: set data ready active level low.\n");
2832 res = l3gd20h_get_data_ready_active_level(&gs_handle, &active_level);
2833 if (res != 0)
2834 {
2835 l3gd20h_interface_debug_print("l3gd20h: get data ready active level failed.\n");
2836 (void)l3gd20h_deinit(&gs_handle);
2837
2838 return 1;
2839 }
2840 l3gd20h_interface_debug_print("l3gd20h: check data ready active level %s.\n", active_level == L3GD20H_INTERRUPT_ACTIVE_LEVEL_LOW ? "ok" : "error");
2841
2842 /* l3gd20h_set_fifo/l3gd20h_get_fifo test */
2843 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_fifo/l3gd20h_get_fifo test.\n");
2844
2845 /* enable */
2846 res = l3gd20h_set_fifo(&gs_handle, L3GD20H_BOOL_TRUE);
2847 if (res != 0)
2848 {
2849 l3gd20h_interface_debug_print("l3gd20h: set fifo failed.\n");
2850 (void)l3gd20h_deinit(&gs_handle);
2851
2852 return 1;
2853 }
2854 l3gd20h_interface_debug_print("l3gd20h: enable fifo.\n");
2855 res = l3gd20h_get_fifo(&gs_handle, &enable);
2856 if (res != 0)
2857 {
2858 l3gd20h_interface_debug_print("l3gd20h: get fifo failed.\n");
2859 (void)l3gd20h_deinit(&gs_handle);
2860
2861 return 1;
2862 }
2863 l3gd20h_interface_debug_print("l3gd20h: check fifo %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
2864
2865 /* disable */
2866 res = l3gd20h_set_fifo(&gs_handle, L3GD20H_BOOL_FALSE);
2867 if (res != 0)
2868 {
2869 l3gd20h_interface_debug_print("l3gd20h: set fifo failed.\n");
2870 (void)l3gd20h_deinit(&gs_handle);
2871
2872 return 1;
2873 }
2874 l3gd20h_interface_debug_print("l3gd20h: disable fifo.\n");
2875 res = l3gd20h_get_fifo(&gs_handle, &enable);
2876 if (res != 0)
2877 {
2878 l3gd20h_interface_debug_print("l3gd20h: get fifo failed.\n");
2879 (void)l3gd20h_deinit(&gs_handle);
2880
2881 return 1;
2882 }
2883 l3gd20h_interface_debug_print("l3gd20h: check fifo %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
2884
2885 /* l3gd20h_set_stop_on_fifo_threshold/l3gd20h_get_stop_on_fifo_threshold test */
2886 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_stop_on_fifo_threshold/l3gd20h_get_stop_on_fifo_threshold test.\n");
2887
2888 /* enable */
2890 if (res != 0)
2891 {
2892 l3gd20h_interface_debug_print("l3gd20h: set stop on fifo threshold failed.\n");
2893 (void)l3gd20h_deinit(&gs_handle);
2894
2895 return 1;
2896 }
2897 l3gd20h_interface_debug_print("l3gd20h: enable stop on fifo threshold.\n");
2898 res = l3gd20h_get_stop_on_fifo_threshold(&gs_handle, &enable);
2899 if (res != 0)
2900 {
2901 l3gd20h_interface_debug_print("l3gd20h: get stop on fifo threshold failed.\n");
2902 (void)l3gd20h_deinit(&gs_handle);
2903
2904 return 1;
2905 }
2906 l3gd20h_interface_debug_print("l3gd20h: check stop on fifo threshold %s.\n", enable == L3GD20H_BOOL_TRUE ? "ok" : "error");
2907
2908 /* disable */
2910 if (res != 0)
2911 {
2912 l3gd20h_interface_debug_print("l3gd20h: set stop on fifo threshold failed.\n");
2913 (void)l3gd20h_deinit(&gs_handle);
2914
2915 return 1;
2916 }
2917 l3gd20h_interface_debug_print("l3gd20h: disable stop on fifo threshold.\n");
2918 res = l3gd20h_get_stop_on_fifo_threshold(&gs_handle, &enable);
2919 if (res != 0)
2920 {
2921 l3gd20h_interface_debug_print("l3gd20h: get stop on fifo threshold failed.\n");
2922 (void)l3gd20h_deinit(&gs_handle);
2923
2924 return 1;
2925 }
2926 l3gd20h_interface_debug_print("l3gd20h: check stop on fifo threshold %s.\n", enable == L3GD20H_BOOL_FALSE ? "ok" : "error");
2927
2928 /* l3gd20h_set_fifo_mode/l3gd20h_get_fifo_mode test */
2929 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_fifo_mode/l3gd20h_get_fifo_mode test.\n");
2930
2931 /* bypass fifo mode */
2933 if (res != 0)
2934 {
2935 l3gd20h_interface_debug_print("l3gd20h: set fifo mode failed.\n");
2936 (void)l3gd20h_deinit(&gs_handle);
2937
2938 return 1;
2939 }
2940 l3gd20h_interface_debug_print("l3gd20h: set fifo mode bypass.\n");
2941 res = l3gd20h_get_fifo_mode(&gs_handle, &fifo_mode);
2942 if (res != 0)
2943 {
2944 l3gd20h_interface_debug_print("l3gd20h: get fifo mode failed.\n");
2945 (void)l3gd20h_deinit(&gs_handle);
2946
2947 return 1;
2948 }
2949 l3gd20h_interface_debug_print("l3gd20h: check fifo mode %s.\n", fifo_mode == L3GD20H_FIFO_MODE_BYPASS ? "ok" : "error");
2950
2951 /* fifo fifo mode */
2953 if (res != 0)
2954 {
2955 l3gd20h_interface_debug_print("l3gd20h: set fifo mode failed.\n");
2956 (void)l3gd20h_deinit(&gs_handle);
2957
2958 return 1;
2959 }
2960 l3gd20h_interface_debug_print("l3gd20h: set fifo mode fifo.\n");
2961 res = l3gd20h_get_fifo_mode(&gs_handle, &fifo_mode);
2962 if (res != 0)
2963 {
2964 l3gd20h_interface_debug_print("l3gd20h: get fifo mode failed.\n");
2965 (void)l3gd20h_deinit(&gs_handle);
2966
2967 return 1;
2968 }
2969 l3gd20h_interface_debug_print("l3gd20h: check fifo mode %s.\n", fifo_mode == L3GD20H_FIFO_MODE_FIFO ? "ok" : "error");
2970
2971 /* stream fifo mode */
2973 if (res != 0)
2974 {
2975 l3gd20h_interface_debug_print("l3gd20h: set fifo mode failed.\n");
2976 (void)l3gd20h_deinit(&gs_handle);
2977
2978 return 1;
2979 }
2980 l3gd20h_interface_debug_print("l3gd20h: set fifo mode stream.\n");
2981 res = l3gd20h_get_fifo_mode(&gs_handle, &fifo_mode);
2982 if (res != 0)
2983 {
2984 l3gd20h_interface_debug_print("l3gd20h: get fifo mode failed.\n");
2985 (void)l3gd20h_deinit(&gs_handle);
2986
2987 return 1;
2988 }
2989 l3gd20h_interface_debug_print("l3gd20h: check fifo mode %s.\n", fifo_mode == L3GD20H_FIFO_MODE_STREAM ? "ok" : "error");
2990
2991 /* stream to fifo mode */
2993 if (res != 0)
2994 {
2995 l3gd20h_interface_debug_print("l3gd20h: set fifo mode failed.\n");
2996 (void)l3gd20h_deinit(&gs_handle);
2997
2998 return 1;
2999 }
3000 l3gd20h_interface_debug_print("l3gd20h: set fifo mode stream to fifo.\n");
3001 res = l3gd20h_get_fifo_mode(&gs_handle, &fifo_mode);
3002 if (res != 0)
3003 {
3004 l3gd20h_interface_debug_print("l3gd20h: get fifo mode failed.\n");
3005 (void)l3gd20h_deinit(&gs_handle);
3006
3007 return 1;
3008 }
3009 l3gd20h_interface_debug_print("l3gd20h: check fifo mode %s.\n", fifo_mode == L3GD20H_FIFO_MODE_STREAM_TO_FIFO ? "ok" : "error");
3010
3011 /* bypass to stream fifo mode */
3013 if (res != 0)
3014 {
3015 l3gd20h_interface_debug_print("l3gd20h: set fifo mode failed.\n");
3016 (void)l3gd20h_deinit(&gs_handle);
3017
3018 return 1;
3019 }
3020 l3gd20h_interface_debug_print("l3gd20h: set fifo mode bypass to stream.\n");
3021 res = l3gd20h_get_fifo_mode(&gs_handle, &fifo_mode);
3022 if (res != 0)
3023 {
3024 l3gd20h_interface_debug_print("l3gd20h: get fifo mode failed.\n");
3025 (void)l3gd20h_deinit(&gs_handle);
3026
3027 return 1;
3028 }
3029 l3gd20h_interface_debug_print("l3gd20h: check fifo mode %s.\n", fifo_mode == L3GD20H_FIFO_MODE_BYPASS_TO_STREAM ? "ok" : "error");
3030
3031 /* dynamic stream fifo mode */
3033 if (res != 0)
3034 {
3035 l3gd20h_interface_debug_print("l3gd20h: set fifo mode failed.\n");
3036 (void)l3gd20h_deinit(&gs_handle);
3037
3038 return 1;
3039 }
3040 l3gd20h_interface_debug_print("l3gd20h: set fifo mode dynamic stream.\n");
3041 res = l3gd20h_get_fifo_mode(&gs_handle, &fifo_mode);
3042 if (res != 0)
3043 {
3044 l3gd20h_interface_debug_print("l3gd20h: get fifo mode failed.\n");
3045 (void)l3gd20h_deinit(&gs_handle);
3046
3047 return 1;
3048 }
3049 l3gd20h_interface_debug_print("l3gd20h: check fifo mode %s.\n", fifo_mode == L3GD20H_FIFO_MODE_DYNAMIC_STREAM ? "ok" : "error");
3050
3051 /* bypass to fifo mode */
3053 if (res != 0)
3054 {
3055 l3gd20h_interface_debug_print("l3gd20h: set fifo mode failed.\n");
3056 (void)l3gd20h_deinit(&gs_handle);
3057
3058 return 1;
3059 }
3060 l3gd20h_interface_debug_print("l3gd20h: set fifo mode bypass to fifo.\n");
3061 res = l3gd20h_get_fifo_mode(&gs_handle, &fifo_mode);
3062 if (res != 0)
3063 {
3064 l3gd20h_interface_debug_print("l3gd20h: get fifo mode failed.\n");
3065 (void)l3gd20h_deinit(&gs_handle);
3066
3067 return 1;
3068 }
3069 l3gd20h_interface_debug_print("l3gd20h: check fifo mode %s.\n", fifo_mode == L3GD20H_FIFO_MODE_BYPASS_TO_FIFO ? "ok" : "error");
3070
3071 /* l3gd20h_set_fifo_threshold/l3gd20h_get_fifo_threshold test */
3072 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_fifo_threshold/l3gd20h_get_fifo_threshold test.\n");
3073 value = rand() % 31;
3074 res = l3gd20h_set_fifo_threshold(&gs_handle, value);
3075 if (res != 0)
3076 {
3077 l3gd20h_interface_debug_print("l3gd20h: set fifo threshold failed.\n");
3078 (void)l3gd20h_deinit(&gs_handle);
3079
3080 return 1;
3081 }
3082 l3gd20h_interface_debug_print("l3gd20h: set fifo threshold %d.\n", value);
3083 res = l3gd20h_get_fifo_threshold(&gs_handle, (uint8_t *)&value_check);
3084 if (res != 0)
3085 {
3086 l3gd20h_interface_debug_print("l3gd20h: get fifo threshold failed.\n");
3087 (void)l3gd20h_deinit(&gs_handle);
3088
3089 return 1;
3090 }
3091 l3gd20h_interface_debug_print("l3gd20h: check fifo threshold %s.\n", value == value_check ? "ok" : "error");
3092
3093 /* l3gd20h_get_fifo_level test */
3094 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_get_fifo_level test.\n");
3095
3096 /* get fifo level */
3097 res = l3gd20h_get_fifo_level(&gs_handle, (uint8_t *)&value);
3098 if (res != 0)
3099 {
3100 l3gd20h_interface_debug_print("l3gd20h: get fifo level failed.\n");
3101 (void)l3gd20h_deinit(&gs_handle);
3102
3103 return 1;
3104 }
3105 l3gd20h_interface_debug_print("l3gd20h: fifo level is %d.\n", value);
3106
3107 /* l3gd20h_get_status test */
3108 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_get_status test.\n");
3109
3110 /* get status */
3111 res = l3gd20h_get_status(&gs_handle, (uint8_t *)&value);
3112 if (res != 0)
3113 {
3114 l3gd20h_interface_debug_print("l3gd20h: get status failed.\n");
3115 (void)l3gd20h_deinit(&gs_handle);
3116
3117 return 1;
3118 }
3119 l3gd20h_interface_debug_print("l3gd20h: status is %d.\n", value);
3120
3121 /* l3gd20h_get_interrupt_source test */
3122 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_get_interrupt_source test.\n");
3123
3124 /* get interrupt source */
3125 res = l3gd20h_get_interrupt_source(&gs_handle, (uint8_t *)&value);
3126 if (res != 0)
3127 {
3128 l3gd20h_interface_debug_print("l3gd20h: get interrupt source failed.\n");
3129 (void)l3gd20h_deinit(&gs_handle);
3130
3131 return 1;
3132 }
3133 l3gd20h_interface_debug_print("l3gd20h: interrupt source is 0x%02X.\n", value);
3134
3135 /* l3gd20h_set_boot/l3gd20h_get_boot test */
3136 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_set_boot/l3gd20h_get_boot test.\n");
3137
3138 /* normal */
3139 res = l3gd20h_set_boot(&gs_handle, L3GD20H_BOOT_NORMAL);
3140 if (res != 0)
3141 {
3142 l3gd20h_interface_debug_print("l3gd20h: set boot failed.\n");
3143 (void)l3gd20h_deinit(&gs_handle);
3144
3145 return 1;
3146 }
3147 l3gd20h_interface_debug_print("l3gd20h: set normal boot.\n");
3148 res = l3gd20h_get_boot(&gs_handle, &boot);
3149 if (res != 0)
3150 {
3151 l3gd20h_interface_debug_print("l3gd20h: get boot failed.\n");
3152 (void)l3gd20h_deinit(&gs_handle);
3153
3154 return 1;
3155 }
3156 l3gd20h_interface_debug_print("l3gd20h: check boot %s.\n", boot == L3GD20H_BOOT_NORMAL ? "ok" : "error");
3157
3158 /* reboot */
3159 res = l3gd20h_set_boot(&gs_handle, L3GD20H_BOOT_REBOOT);
3160 if (res != 0)
3161 {
3162 l3gd20h_interface_debug_print("l3gd20h: set boot failed.\n");
3163 (void)l3gd20h_deinit(&gs_handle);
3164
3165 return 1;
3166 }
3167 l3gd20h_interface_debug_print("l3gd20h: set reboot.\n");
3169 res = l3gd20h_get_boot(&gs_handle, &boot);
3170 if (res != 0)
3171 {
3172 l3gd20h_interface_debug_print("l3gd20h: get boot failed.\n");
3173 (void)l3gd20h_deinit(&gs_handle);
3174
3175 return 1;
3176 }
3177 l3gd20h_interface_debug_print("l3gd20h: check boot %s.\n", boot == L3GD20H_BOOT_NORMAL ? "ok" : "error");
3178
3179 /* l3gd20h_soft_reset test */
3180 l3gd20h_interface_debug_print("l3gd20h: l3gd20h_soft_reset test.\n");
3181
3182 l3gd20h_interface_debug_print("l3gd20h: soft reset.\n");
3183
3184 /* soft reset */
3185 res = l3gd20h_soft_reset(&gs_handle);
3186 if (res != 0)
3187 {
3188 l3gd20h_interface_debug_print("l3gd20h: soft reset failed.\n");
3189 (void)l3gd20h_deinit(&gs_handle);
3190
3191 return 1;
3192 }
3194
3195 /* finish register test */
3196 l3gd20h_interface_debug_print("l3gd20h: finish register test.\n");
3197 (void)l3gd20h_deinit(&gs_handle);
3198
3199 return 0;
3200}
driver l3gd20h register 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
uint8_t l3gd20h_get_status(l3gd20h_handle_t *handle, uint8_t *status)
get the chip status
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_soft_reset(l3gd20h_handle_t *handle)
soft reset the device
l3gd20h_boot_t
l3gd20h boot enumeration definition
uint8_t l3gd20h_set_mode(l3gd20h_handle_t *handle, l3gd20h_mode_t mode)
set the chip mode
uint8_t l3gd20h_get_boot(l3gd20h_handle_t *handle, l3gd20h_boot_t *boot)
get the boot
uint8_t l3gd20h_get_high_pass_filter_reference(l3gd20h_handle_t *handle, uint8_t *value)
get the high pass filter reference
uint8_t l3gd20h_get_axis(l3gd20h_handle_t *handle, l3gd20h_axis_t axis, l3gd20h_bool_t *enable)
get the axis
uint8_t l3gd20h_get_mode(l3gd20h_handle_t *handle, l3gd20h_mode_t *mode)
get the chip mode
uint8_t l3gd20h_get_out_selection(l3gd20h_handle_t *handle, l3gd20h_selection_t *selection)
get the out selection
uint8_t l3gd20h_info(l3gd20h_info_t *info)
get chip's information
l3gd20h_spi_wire_t
l3gd20h spi wire enumeration definition
uint8_t l3gd20h_get_full_scale(l3gd20h_handle_t *handle, l3gd20h_full_scale_t *full_scale)
get the full scale
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
l3gd20h_self_test_t
l3gd20h self test type enumeration definition
uint8_t l3gd20h_set_rate_bandwidth(l3gd20h_handle_t *handle, l3gd20h_lodr_odr_bw_t rate_bandwidth)
set the rate bandwidth
uint8_t l3gd20h_get_rate_bandwidth(l3gd20h_handle_t *handle, l3gd20h_lodr_odr_bw_t *rate_bandwidth)
get 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_set_out_selection(l3gd20h_handle_t *handle, l3gd20h_selection_t selection)
set the out selection
l3gd20h_full_scale_t
l3gd20h full scale type enumeration definition
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_iic(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the iic interface
l3gd20h_high_pass_filter_mode_t
l3gd20h high pass filter mode enumeration definition
uint8_t l3gd20h_get_level_trigger(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the level trigger status
l3gd20h_data_format_t
l3gd20h data format enumeration definition
l3gd20h_high_pass_filter_cut_off_frequency_t
l3gd20h high pass filter cut off frequency enumeration definition
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_get_addr_pin(l3gd20h_handle_t *handle, l3gd20h_address_t *addr_pin)
get the iic address pin
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
l3gd20h_selection_t
l3gd20h selection enumeration definition
uint8_t l3gd20h_get_high_pass_filter_cut_off_frequency(l3gd20h_handle_t *handle, l3gd20h_high_pass_filter_cut_off_frequency_t *frequency)
get the high pass filter cut off frequency
uint8_t l3gd20h_init(l3gd20h_handle_t *handle)
initialize the chip
uint8_t l3gd20h_get_high_pass_filter(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get high pass filter status
uint8_t l3gd20h_get_data_format(l3gd20h_handle_t *handle, l3gd20h_data_format_t *data_format)
get the data format
uint8_t l3gd20h_get_interface(l3gd20h_handle_t *handle, l3gd20h_interface_t *interface)
get the chip interface
uint8_t l3gd20h_get_high_pass_filter_mode(l3gd20h_handle_t *handle, l3gd20h_high_pass_filter_mode_t *mode)
get the high pass filter mode
l3gd20h_mode_t
l3gd20h mode enumeration definition
uint8_t l3gd20h_set_spi_wire(l3gd20h_handle_t *handle, l3gd20h_spi_wire_t spi_wire)
set the spi wire
uint8_t l3gd20h_set_level_trigger(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the level trigger
uint8_t l3gd20h_get_block_data_update(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the block data update status
l3gd20h_bool_t
l3gd20h bool enumeration definition
uint8_t l3gd20h_get_edge_trigger(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the edge trigger status
l3gd20h_lodr_odr_bw_t
l3gd20h low odr odr bw enumeration definition
uint8_t l3gd20h_get_spi_wire(l3gd20h_handle_t *handle, l3gd20h_spi_wire_t *spi_wire)
get the spi wire
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
uint8_t l3gd20h_get_level_sensitive_latched(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the level sensitive latched status
uint8_t l3gd20h_get_iic(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the iic interface status
uint8_t l3gd20h_get_self_test(l3gd20h_handle_t *handle, l3gd20h_self_test_t *self_test)
get the self test
struct l3gd20h_handle_s l3gd20h_handle_t
l3gd20h handle structure definition
@ L3GD20H_BOOT_NORMAL
@ L3GD20H_BOOT_REBOOT
@ L3GD20H_SPI_WIRE_3
@ L3GD20H_SPI_WIRE_4
@ L3GD20H_SELF_TEST_NORMAL
@ L3GD20H_SELF_TEST_1
@ L3GD20H_SELF_TEST_0
@ L3GD20H_FULL_SCALE_500_DPS
@ L3GD20H_FULL_SCALE_2000_DPS
@ L3GD20H_FULL_SCALE_245_DPS
@ L3GD20H_ADDRESS_SDO_1
@ L3GD20H_ADDRESS_SDO_0
@ L3GD20H_HIGH_PASS_FILTER_MODE_NORMAL
@ L3GD20H_HIGH_PASS_FILTER_MODE_AUTORESET_ON_INT
@ L3GD20H_HIGH_PASS_FILTER_MODE_NORMAL_RESET
@ L3GD20H_HIGH_PASS_FILTER_MODE_REFERENCE_SIGNAL
@ L3GD20H_DATA_FORMAT_LITTLE_ENDIAN
@ L3GD20H_DATA_FORMAT_BIG_ENDIAN
@ L3GD20H_HIGH_PASS_FILTER_CUT_OFF_FREQUENCY_3
@ L3GD20H_HIGH_PASS_FILTER_CUT_OFF_FREQUENCY_6
@ L3GD20H_HIGH_PASS_FILTER_CUT_OFF_FREQUENCY_7
@ L3GD20H_HIGH_PASS_FILTER_CUT_OFF_FREQUENCY_4
@ L3GD20H_HIGH_PASS_FILTER_CUT_OFF_FREQUENCY_1
@ L3GD20H_HIGH_PASS_FILTER_CUT_OFF_FREQUENCY_9
@ L3GD20H_HIGH_PASS_FILTER_CUT_OFF_FREQUENCY_2
@ L3GD20H_HIGH_PASS_FILTER_CUT_OFF_FREQUENCY_8
@ L3GD20H_HIGH_PASS_FILTER_CUT_OFF_FREQUENCY_0
@ L3GD20H_HIGH_PASS_FILTER_CUT_OFF_FREQUENCY_5
@ L3GD20H_INTERFACE_SPI
@ L3GD20H_INTERFACE_IIC
@ L3GD20H_AXIS_X
@ L3GD20H_AXIS_Z
@ L3GD20H_AXIS_Y
@ L3GD20H_SELECTION_LPF1
@ L3GD20H_SELECTION_LPF1_HPF_LPF2
@ L3GD20H_SELECTION_LPF1_HPF
@ L3GD20H_MODE_POWER_DOWN
@ L3GD20H_MODE_NORMAL
@ L3GD20H_MODE_SLEEP
@ L3GD20H_BOOL_FALSE
@ L3GD20H_BOOL_TRUE
@ L3GD20H_LOW_ODR_0_ODR_200HZ_BW_3_70HZ
@ L3GD20H_LOW_ODR_1_ODR_25HZ_BW_3_NA
@ L3GD20H_LOW_ODR_0_ODR_200HZ_BW_1_NA
@ L3GD20H_LOW_ODR_1_ODR_12P5HZ_BW_2_NA
@ L3GD20H_LOW_ODR_1_ODR_50HZ_BW_0_16P6HZ
@ L3GD20H_LOW_ODR_0_ODR_400HZ_BW_3_110HZ
@ L3GD20H_LOW_ODR_0_ODR_400HZ_BW_1_25HZ
@ L3GD20H_LOW_ODR_1_ODR_50HZ_BW_3_16P6HZ
@ L3GD20H_LOW_ODR_1_ODR_12P5HZ_BW_0_NA
@ L3GD20H_LOW_ODR_0_ODR_100HZ_BW_3_25HZ
@ L3GD20H_LOW_ODR_1_ODR_50HZ_BW_1_16P6HZ
@ L3GD20H_LOW_ODR_0_ODR_800HZ_BW_1_35HZ
@ L3GD20H_LOW_ODR_0_ODR_800HZ_BW_0_30HZ
@ L3GD20H_LOW_ODR_0_ODR_100HZ_BW_2_25HZ
@ L3GD20H_LOW_ODR_0_ODR_800HZ_BW_2_NA
@ L3GD20H_LOW_ODR_0_ODR_200HZ_BW_2_NA
@ L3GD20H_LOW_ODR_1_ODR_25HZ_BW_2_NA
@ L3GD20H_LOW_ODR_1_ODR_50HZ_BW_2_16P6HZ
@ L3GD20H_LOW_ODR_0_ODR_100HZ_BW_1_25HZ
@ L3GD20H_LOW_ODR_0_ODR_400HZ_BW_2_50HZ
@ L3GD20H_LOW_ODR_0_ODR_100HZ_BW_0_12P5HZ
@ L3GD20H_LOW_ODR_1_ODR_12P5HZ_BW_3_NA
@ L3GD20H_LOW_ODR_1_ODR_25HZ_BW_0_NA
@ L3GD20H_LOW_ODR_1_ODR_25HZ_BW_1_NA
@ L3GD20H_LOW_ODR_1_ODR_12P5HZ_BW_1_NA
@ L3GD20H_LOW_ODR_0_ODR_400HZ_BW_0_20HZ
@ L3GD20H_LOW_ODR_0_ODR_800HZ_BW_3_100HZ
uint8_t l3gd20h_get_fifo_mode(l3gd20h_handle_t *handle, l3gd20h_fifo_mode_t *fifo_mode)
get the fifo mode
uint8_t l3gd20h_get_fifo_threshold(l3gd20h_handle_t *handle, uint8_t *threshold)
get the fifo threshold
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_get_fifo_level(l3gd20h_handle_t *handle, uint8_t *level)
get the fifo level
uint8_t l3gd20h_set_fifo(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the fifo
l3gd20h_fifo_mode_t
l3gd20h fifo mode enumeration definition
uint8_t l3gd20h_set_fifo_threshold(l3gd20h_handle_t *handle, uint8_t threshold)
set the fifo threshold
uint8_t l3gd20h_get_fifo(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the fifo status
uint8_t l3gd20h_get_stop_on_fifo_threshold(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get stop on fifo threshold status
@ L3GD20H_FIFO_MODE_FIFO
@ L3GD20H_FIFO_MODE_DYNAMIC_STREAM
@ L3GD20H_FIFO_MODE_BYPASS_TO_STREAM
@ L3GD20H_FIFO_MODE_STREAM
@ L3GD20H_FIFO_MODE_BYPASS_TO_FIFO
@ L3GD20H_FIFO_MODE_BYPASS
@ L3GD20H_FIFO_MODE_STREAM_TO_FIFO
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_get_interrupt_source(l3gd20h_handle_t *handle, uint8_t *src)
get the interrupt source
uint8_t l3gd20h_get_interrupt_active_level(l3gd20h_handle_t *handle, l3gd20h_interrupt_active_level_t *level)
get the interrupt active level
uint8_t l3gd20h_get_duration(l3gd20h_handle_t *handle, uint8_t *duration)
get the wait duration
uint8_t l3gd20h_get_interrupt_event(l3gd20h_handle_t *handle, l3gd20h_interrupt_event_t interrupt_event, l3gd20h_bool_t *enable)
get the interrupt event
uint8_t l3gd20h_get_x_interrupt_threshold(l3gd20h_handle_t *handle, uint16_t *threshold)
get the x interrupt threshold
uint8_t l3gd20h_get_fifo_empty_on_interrupt2(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the fifo empty on interrupt2 status
uint8_t l3gd20h_get_interrupt_pin_type(l3gd20h_handle_t *handle, l3gd20h_pin_type_t *pin_type)
get the interrupt pin type
uint8_t l3gd20h_get_counter_mode(l3gd20h_handle_t *handle, l3gd20h_counter_mode_t *counter_mode)
get the counter mode
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_interrupt_threshold_convert_to_data(l3gd20h_handle_t *handle, uint16_t reg, float *dps)
convert the interrupt threshold register raw data to the real data
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
l3gd20h_counter_mode_t
l3gd20h counter mode enumeration definition
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_get_y_interrupt_threshold(l3gd20h_handle_t *handle, uint16_t *threshold)
get the y interrupt threshold
uint8_t l3gd20h_get_fifo_threshold_on_interrupt2(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the fifo threshold on interrupt2 status
uint8_t l3gd20h_get_wait(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the wait status
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_get_fifo_overrun_on_interrupt2(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the fifo overrun on interrupt2 status
uint8_t l3gd20h_set_counter_mode(l3gd20h_handle_t *handle, l3gd20h_counter_mode_t counter_mode)
set the counter mode
uint8_t l3gd20h_get_data_ready_on_interrupt2(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the data ready on interrupt2 status
uint8_t l3gd20h_get_boot_on_interrupt1(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the boot on the interrupt1 status
uint8_t l3gd20h_get_interrupt1(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the interrupt1 status
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
l3gd20h_interrupt_active_level_t
l3gd20h interrupt active level enumeration definition
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_get_z_interrupt_threshold(l3gd20h_handle_t *handle, uint16_t *threshold)
get the z interrupt threshold
uint8_t l3gd20h_set_interrupt_selection(l3gd20h_handle_t *handle, l3gd20h_selection_t selection)
set the interrupt selection
uint8_t l3gd20h_get_interrupt_selection(l3gd20h_handle_t *handle, l3gd20h_selection_t *selection)
get 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_get_data_ready_active_level(l3gd20h_handle_t *handle, l3gd20h_interrupt_active_level_t *level)
get the data ready active level
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_pin_type_t
l3gd20h interrupt pin type enumeration definition
@ 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_DECREMENT
@ L3GD20H_COUNTER_MODE_RESET
@ L3GD20H_INTERRUPT_ACTIVE_LEVEL_LOW
@ L3GD20H_INTERRUPT_ACTIVE_LEVEL_HIGH
@ L3GD20H_PIN_OPEN_DRAIN
@ L3GD20H_PIN_PUSH_PULL
uint8_t l3gd20h_register_test(l3gd20h_interface_t interface, l3gd20h_address_t addr_pin)
register test
uint32_t driver_version
char manufacturer_name[32]