LibDriver MAX30105
Loading...
Searching...
No Matches
driver_max30105_register_test.c
Go to the documentation of this file.
1
36
38#include <stdlib.h>
39
40static max30105_handle_t gs_handle;
41
50{
51 uint8_t res;
52 uint8_t pointer;
53 uint8_t pointer_check;
54 uint8_t threshold;
55 uint8_t threshold_check;
56 uint8_t value;
57 uint8_t value_check;
58 uint32_t adc;
59 uint32_t adc_check;
60 uint8_t revision_id;
61 uint8_t part_id;
62 max30105_info_t info;
63 max30105_bool_t enable;
66 max30105_mode_t mode;
70
71 /* link interface function */
80
81 /* get information */
82 res = max30105_info(&info);
83 if (res != 0)
84 {
85 max30105_interface_debug_print("max30105: get info failed.\n");
86
87 return 1;
88 }
89 else
90 {
91 /* print chip info */
92 max30105_interface_debug_print("max30105: chip is %s.\n", info.chip_name);
93 max30105_interface_debug_print("max30105: manufacturer is %s.\n", info.manufacturer_name);
94 max30105_interface_debug_print("max30105: interface is %s.\n", info.interface);
95 max30105_interface_debug_print("max30105: driver version is %d.%d.\n", info.driver_version / 1000, (info.driver_version % 1000) / 100);
96 max30105_interface_debug_print("max30105: min supply voltage is %0.1fV.\n", info.supply_voltage_min_v);
97 max30105_interface_debug_print("max30105: max supply voltage is %0.1fV.\n", info.supply_voltage_max_v);
98 max30105_interface_debug_print("max30105: max current is %0.2fmA.\n", info.max_current_ma);
99 max30105_interface_debug_print("max30105: max temperature is %0.1fC.\n", info.temperature_max);
100 max30105_interface_debug_print("max30105: min temperature is %0.1fC.\n", info.temperature_min);
101 }
102
103 /* start register test */
104 max30105_interface_debug_print("max30105: start register test.\n");
105
106 /* init the max30105 */
107 res = max30105_init(&gs_handle);
108 if (res != 0)
109 {
110 max30105_interface_debug_print("max30105: init failed.\n");
111
112 return 1;
113 }
114
115 /* max30105_set_interrupt/max30105_get_interrupt test */
116 max30105_interface_debug_print("max30105: max30105_set_interrupt/max30105_get_interrupt test.\n");
117
118 /* enable fifo full */
120 if (res != 0)
121 {
122 max30105_interface_debug_print("max30105: set interrupt failed.\n");
123 (void)max30105_deinit(&gs_handle);
124
125 return 1;
126 }
127 max30105_interface_debug_print("max30105: enable fifo full.\n");
129 if (res != 0)
130 {
131 max30105_interface_debug_print("max30105: get interrupt failed.\n");
132 (void)max30105_deinit(&gs_handle);
133
134 return 1;
135 }
136 max30105_interface_debug_print("max30105: check interrupt %s.\n", enable == MAX30105_BOOL_TRUE ? "ok" : "error");
137
138 /* disable fifo full */
140 if (res != 0)
141 {
142 max30105_interface_debug_print("max30105: set interrupt failed.\n");
143 (void)max30105_deinit(&gs_handle);
144
145 return 1;
146 }
147 max30105_interface_debug_print("max30105: disable fifo full.\n");
149 if (res != 0)
150 {
151 max30105_interface_debug_print("max30105: get interrupt failed.\n");
152 (void)max30105_deinit(&gs_handle);
153
154 return 1;
155 }
156 max30105_interface_debug_print("max30105: check interrupt %s.\n", enable == MAX30105_BOOL_FALSE ? "ok" : "error");
157
158 /* enable data ready */
160 if (res != 0)
161 {
162 max30105_interface_debug_print("max30105: set interrupt failed.\n");
163 (void)max30105_deinit(&gs_handle);
164
165 return 1;
166 }
167 max30105_interface_debug_print("max30105: enable data ready.\n");
168 res = max30105_get_interrupt(&gs_handle, MAX30105_INTERRUPT_DATA_RDY_EN, &enable);
169 if (res != 0)
170 {
171 max30105_interface_debug_print("max30105: get interrupt failed.\n");
172 (void)max30105_deinit(&gs_handle);
173
174 return 1;
175 }
176 max30105_interface_debug_print("max30105: check interrupt %s.\n", enable == MAX30105_BOOL_TRUE ? "ok" : "error");
177
178 /* disable data ready */
180 if (res != 0)
181 {
182 max30105_interface_debug_print("max30105: set interrupt failed.\n");
183 (void)max30105_deinit(&gs_handle);
184
185 return 1;
186 }
187 max30105_interface_debug_print("max30105: disable data ready.\n");
188 res = max30105_get_interrupt(&gs_handle, MAX30105_INTERRUPT_DATA_RDY_EN, &enable);
189 if (res != 0)
190 {
191 max30105_interface_debug_print("max30105: get interrupt failed.\n");
192 (void)max30105_deinit(&gs_handle);
193
194 return 1;
195 }
196 max30105_interface_debug_print("max30105: check interrupt %s.\n", enable == MAX30105_BOOL_FALSE ? "ok" : "error");
197
198 /* enable alc ovf */
200 if (res != 0)
201 {
202 max30105_interface_debug_print("max30105: set interrupt failed.\n");
203 (void)max30105_deinit(&gs_handle);
204
205 return 1;
206 }
207 max30105_interface_debug_print("max30105: enable alc ovf.\n");
208 res = max30105_get_interrupt(&gs_handle, MAX30105_INTERRUPT_ALC_OVF_EN, &enable);
209 if (res != 0)
210 {
211 max30105_interface_debug_print("max30105: get interrupt failed.\n");
212 (void)max30105_deinit(&gs_handle);
213
214 return 1;
215 }
216 max30105_interface_debug_print("max30105: check interrupt %s.\n", enable == MAX30105_BOOL_TRUE ? "ok" : "error");
217
218 /* disable alc ovf */
220 if (res != 0)
221 {
222 max30105_interface_debug_print("max30105: set interrupt failed.\n");
223 (void)max30105_deinit(&gs_handle);
224
225 return 1;
226 }
227 max30105_interface_debug_print("max30105: disable alc ovf.\n");
228 res = max30105_get_interrupt(&gs_handle, MAX30105_INTERRUPT_ALC_OVF_EN, &enable);
229 if (res != 0)
230 {
231 max30105_interface_debug_print("max30105: get interrupt failed.\n");
232 (void)max30105_deinit(&gs_handle);
233
234 return 1;
235 }
236 max30105_interface_debug_print("max30105: check interrupt %s.\n", enable == MAX30105_BOOL_FALSE ? "ok" : "error");
237
238 /* enable proximity threshold interrupt */
240 if (res != 0)
241 {
242 max30105_interface_debug_print("max30105: set interrupt failed.\n");
243 (void)max30105_deinit(&gs_handle);
244
245 return 1;
246 }
247 max30105_interface_debug_print("max30105: enable proximity threshold interrupt.\n");
248 res = max30105_get_interrupt(&gs_handle, MAX30105_INTERRUPT_PROX_INT_EN, &enable);
249 if (res != 0)
250 {
251 max30105_interface_debug_print("max30105: get interrupt failed.\n");
252 (void)max30105_deinit(&gs_handle);
253
254 return 1;
255 }
256 max30105_interface_debug_print("max30105: check interrupt %s.\n", enable == MAX30105_BOOL_TRUE ? "ok" : "error");
257
258 /* disable proximity threshold interrupt */
260 if (res != 0)
261 {
262 max30105_interface_debug_print("max30105: set interrupt failed.\n");
263 (void)max30105_deinit(&gs_handle);
264
265 return 1;
266 }
267 max30105_interface_debug_print("max30105: disable proximity threshold interrupt.\n");
268 res = max30105_get_interrupt(&gs_handle, MAX30105_INTERRUPT_PROX_INT_EN, &enable);
269 if (res != 0)
270 {
271 max30105_interface_debug_print("max30105: get interrupt failed.\n");
272 (void)max30105_deinit(&gs_handle);
273
274 return 1;
275 }
276 max30105_interface_debug_print("max30105: check interrupt %s.\n", enable == MAX30105_BOOL_FALSE ? "ok" : "error");
277
278 /* enable die temp ready */
280 if (res != 0)
281 {
282 max30105_interface_debug_print("max30105: set interrupt failed.\n");
283 (void)max30105_deinit(&gs_handle);
284
285 return 1;
286 }
287 max30105_interface_debug_print("max30105: enable die temp ready.\n");
289 if (res != 0)
290 {
291 max30105_interface_debug_print("max30105: get interrupt failed.\n");
292 (void)max30105_deinit(&gs_handle);
293
294 return 1;
295 }
296 max30105_interface_debug_print("max30105: check interrupt %s.\n", enable == MAX30105_BOOL_TRUE ? "ok" : "error");
297
298 /* disable die temp ready */
300 if (res != 0)
301 {
302 max30105_interface_debug_print("max30105: set interrupt failed.\n");
303 (void)max30105_deinit(&gs_handle);
304
305 return 1;
306 }
307 max30105_interface_debug_print("max30105: disable die temp ready.\n");
309 if (res != 0)
310 {
311 max30105_interface_debug_print("max30105: get interrupt failed.\n");
312 (void)max30105_deinit(&gs_handle);
313
314 return 1;
315 }
316 max30105_interface_debug_print("max30105: check interrupt %s.\n", enable == MAX30105_BOOL_FALSE ? "ok" : "error");
317
318 /* max30105_set_fifo_write_pointer/max30105_get_fifo_write_pointer test */
319 max30105_interface_debug_print("max30105: max30105_set_fifo_write_pointer/max30105_get_fifo_write_pointer test.\n");
320
321 pointer = rand() % 0x1F;
322 res = max30105_set_fifo_write_pointer(&gs_handle, pointer);
323 if (res != 0)
324 {
325 max30105_interface_debug_print("max30105: set fifo write pointer failed.\n");
326 (void)max30105_deinit(&gs_handle);
327
328 return 1;
329 }
330 max30105_interface_debug_print("max30105: set fifo write pointer %d.\n", pointer);
331 res = max30105_get_fifo_write_pointer(&gs_handle, (uint8_t *)&pointer_check);
332 if (res != 0)
333 {
334 max30105_interface_debug_print("max30105: get fifo write pointer failed.\n");
335 (void)max30105_deinit(&gs_handle);
336
337 return 1;
338 }
339
340 /* max30105_set_fifo_overflow_counter/max30105_get_fifo_overflow_counter test */
341 max30105_interface_debug_print("max30105: max30105_set_fifo_overflow_counter/max30105_get_fifo_overflow_counter test.\n");
342
343 pointer = rand() % 0x1F;
344 res = max30105_set_fifo_overflow_counter(&gs_handle, pointer);
345 if (res != 0)
346 {
347 max30105_interface_debug_print("max30105: set fifo overflow counter failed.\n");
348 (void)max30105_deinit(&gs_handle);
349
350 return 1;
351 }
352 max30105_interface_debug_print("max30105: set fifo overflow counter %d.\n", pointer);
353 res = max30105_get_fifo_overflow_counter(&gs_handle, (uint8_t *)&pointer_check);
354 if (res != 0)
355 {
356 max30105_interface_debug_print("max30105: get fifo overflow counter failed.\n");
357 (void)max30105_deinit(&gs_handle);
358
359 return 1;
360 }
361
362 /* max30105_set_fifo_read_pointer/max30105_get_fifo_read_pointer test */
363 max30105_interface_debug_print("max30105: max30105_set_fifo_read_pointer/max30105_get_fifo_read_pointer test.\n");
364
365 pointer = rand() % 0x1F;
366 res = max30105_set_fifo_read_pointer(&gs_handle, pointer);
367 if (res != 0)
368 {
369 max30105_interface_debug_print("max30105: set fifo read pointer failed.\n");
370 (void)max30105_deinit(&gs_handle);
371
372 return 1;
373 }
374 max30105_interface_debug_print("max30105: set fifo read pointer %d.\n", pointer);
375 res = max30105_get_fifo_read_pointer(&gs_handle, (uint8_t *)&pointer_check);
376 if (res != 0)
377 {
378 max30105_interface_debug_print("max30105: get fifo read pointer failed.\n");
379 (void)max30105_deinit(&gs_handle);
380
381 return 1;
382 }
383
384 /* max30105_set_fifo_data/max30105_get_fifo_data test */
385 max30105_interface_debug_print("max30105: max30105_set_fifo_data/max30105_get_fifo_data test.\n");
386
387 pointer = rand() % 0x1F;
388 res = max30105_set_fifo_data(&gs_handle, pointer);
389 if (res != 0)
390 {
391 max30105_interface_debug_print("max30105: set fifo data failed.\n");
392 (void)max30105_deinit(&gs_handle);
393
394 return 1;
395 }
396 max30105_interface_debug_print("max30105: set fifo data %d.\n", pointer);
397 res = max30105_get_fifo_data(&gs_handle, (uint8_t *)&pointer_check);
398 if (res != 0)
399 {
400 max30105_interface_debug_print("max30105: get fifo data failed.\n");
401 (void)max30105_deinit(&gs_handle);
402
403 return 1;
404 }
405
406 /* max30105_set_fifo_sample_averaging/max30105_get_fifo_sample_averaging test */
407 max30105_interface_debug_print("max30105: max30105_set_fifo_sample_averaging/max30105_get_fifo_sample_averaging test.\n");
408
409 /* set sample averaging 1 */
411 if (res != 0)
412 {
413 max30105_interface_debug_print("max30105: set fifo sample averaging failed.\n");
414 (void)max30105_deinit(&gs_handle);
415
416 return 1;
417 }
418 max30105_interface_debug_print("max30105: set sample averaging 1.\n");
419 res = max30105_get_fifo_sample_averaging(&gs_handle, &sample);
420 if (res != 0)
421 {
422 max30105_interface_debug_print("max30105: get fifo sample averaging failed.\n");
423 (void)max30105_deinit(&gs_handle);
424
425 return 1;
426 }
427 max30105_interface_debug_print("max30105: check sample %s.\n", sample == MAX30105_SAMPLE_AVERAGING_1 ? "ok" : "error");
428
429 /* set sample averaging 2 */
431 if (res != 0)
432 {
433 max30105_interface_debug_print("max30105: set fifo sample averaging failed.\n");
434 (void)max30105_deinit(&gs_handle);
435
436 return 1;
437 }
438 max30105_interface_debug_print("max30105: set sample averaging 2.\n");
439 res = max30105_get_fifo_sample_averaging(&gs_handle, &sample);
440 if (res != 0)
441 {
442 max30105_interface_debug_print("max30105: get fifo sample averaging failed.\n");
443 (void)max30105_deinit(&gs_handle);
444
445 return 1;
446 }
447 max30105_interface_debug_print("max30105: check sample %s.\n", sample == MAX30105_SAMPLE_AVERAGING_2 ? "ok" : "error");
448
449 /* set sample averaging 4 */
451 if (res != 0)
452 {
453 max30105_interface_debug_print("max30105: set fifo sample averaging failed.\n");
454 (void)max30105_deinit(&gs_handle);
455
456 return 1;
457 }
458 max30105_interface_debug_print("max30105: set sample averaging 4.\n");
459 res = max30105_get_fifo_sample_averaging(&gs_handle, &sample);
460 if (res != 0)
461 {
462 max30105_interface_debug_print("max30105: get fifo sample averaging failed.\n");
463 (void)max30105_deinit(&gs_handle);
464
465 return 1;
466 }
467 max30105_interface_debug_print("max30105: check sample %s.\n", sample == MAX30105_SAMPLE_AVERAGING_4 ? "ok" : "error");
468
469 /* set sample averaging 8 */
471 if (res != 0)
472 {
473 max30105_interface_debug_print("max30105: set fifo sample averaging failed.\n");
474 (void)max30105_deinit(&gs_handle);
475
476 return 1;
477 }
478 max30105_interface_debug_print("max30105: set sample averaging 8.\n");
479 res = max30105_get_fifo_sample_averaging(&gs_handle, &sample);
480 if (res != 0)
481 {
482 max30105_interface_debug_print("max30105: get fifo sample averaging failed.\n");
483 (void)max30105_deinit(&gs_handle);
484
485 return 1;
486 }
487 max30105_interface_debug_print("max30105: check sample %s.\n", sample == MAX30105_SAMPLE_AVERAGING_8 ? "ok" : "error");
488
489 /* set sample averaging 16 */
491 if (res != 0)
492 {
493 max30105_interface_debug_print("max30105: set fifo sample averaging failed.\n");
494 (void)max30105_deinit(&gs_handle);
495
496 return 1;
497 }
498 max30105_interface_debug_print("max30105: set sample averaging 16.\n");
499 res = max30105_get_fifo_sample_averaging(&gs_handle, &sample);
500 if (res != 0)
501 {
502 max30105_interface_debug_print("max30105: get fifo sample averaging failed.\n");
503 (void)max30105_deinit(&gs_handle);
504
505 return 1;
506 }
507 max30105_interface_debug_print("max30105: check sample %s.\n", sample == MAX30105_SAMPLE_AVERAGING_16 ? "ok" : "error");
508
509 /* set sample averaging 32 */
511 if (res != 0)
512 {
513 max30105_interface_debug_print("max30105: set fifo sample averaging failed.\n");
514 (void)max30105_deinit(&gs_handle);
515
516 return 1;
517 }
518 max30105_interface_debug_print("max30105: set sample averaging 32.\n");
519 res = max30105_get_fifo_sample_averaging(&gs_handle, &sample);
520 if (res != 0)
521 {
522 max30105_interface_debug_print("max30105: get fifo sample averaging failed.\n");
523 (void)max30105_deinit(&gs_handle);
524
525 return 1;
526 }
527 max30105_interface_debug_print("max30105: check sample %s.\n", sample == MAX30105_SAMPLE_AVERAGING_32 ? "ok" : "error");
528
529 /* max30105_set_fifo_roll/max30105_get_fifo_roll test */
530 max30105_interface_debug_print("max30105: max30105_set_fifo_roll/max30105_get_fifo_roll test.\n");
531
532 /* enable fifo roll */
534 if (res != 0)
535 {
536 max30105_interface_debug_print("max30105: set fifo roll failed.\n");
537 (void)max30105_deinit(&gs_handle);
538
539 return 1;
540 }
541 max30105_interface_debug_print("max30105: enable fifo roll.\n");
542 res = max30105_get_fifo_roll(&gs_handle, &enable);
543 if (res != 0)
544 {
545 max30105_interface_debug_print("max30105: get fifo roll failed.\n");
546 (void)max30105_deinit(&gs_handle);
547
548 return 1;
549 }
550 max30105_interface_debug_print("max30105: check roll %s.\n", enable == MAX30105_BOOL_TRUE ? "ok" : "error");
551
552 /* disable fifo roll */
554 if (res != 0)
555 {
556 max30105_interface_debug_print("max30105: set fifo roll failed.\n");
557 (void)max30105_deinit(&gs_handle);
558
559 return 1;
560 }
561 max30105_interface_debug_print("max30105: disable fifo roll.\n");
562 res = max30105_get_fifo_roll(&gs_handle, &enable);
563 if (res != 0)
564 {
565 max30105_interface_debug_print("max30105: get fifo roll failed.\n");
566 (void)max30105_deinit(&gs_handle);
567
568 return 1;
569 }
570 max30105_interface_debug_print("max30105: check roll %s.\n", enable == MAX30105_BOOL_FALSE ? "ok" : "error");
571
572 /* max30105_set_fifo_almost_full/max30105_get_fifo_almost_full test */
573 max30105_interface_debug_print("max30105: max30105_set_fifo_almost_full/max30105_get_fifo_almost_full test.\n");
574
575 value = rand() % 0xF;
576 res = max30105_set_fifo_almost_full(&gs_handle, value);
577 if (res != 0)
578 {
579 max30105_interface_debug_print("max30105: set fifo almost full failed.\n");
580 (void)max30105_deinit(&gs_handle);
581
582 return 1;
583 }
584 max30105_interface_debug_print("max30105: set fifo almost full %d.\n", value);
585 res = max30105_get_fifo_almost_full(&gs_handle, (uint8_t *)&value_check);
586 if (res != 0)
587 {
588 max30105_interface_debug_print("max30105: get fifo almost full failed.\n");
589 (void)max30105_deinit(&gs_handle);
590
591 return 1;
592 }
593 max30105_interface_debug_print("max30105: check fifo almost full %s.\n", value_check == value ? "ok" : "error");
594
595 /* max30105_set_shutdown/max30105_get_shutdown test */
596 max30105_interface_debug_print("max30105: max30105_set_shutdown/max30105_get_shutdown test.\n");
597
598 /* enable shutdown */
599 res = max30105_set_shutdown(&gs_handle, MAX30105_BOOL_TRUE);
600 if (res != 0)
601 {
602 max30105_interface_debug_print("max30105: set shutdown failed.\n");
603 (void)max30105_deinit(&gs_handle);
604
605 return 1;
606 }
607 max30105_interface_debug_print("max30105: enable shutdown.\n");
608 res = max30105_get_shutdown(&gs_handle, &enable);
609 if (res != 0)
610 {
611 max30105_interface_debug_print("max30105: get shutdown failed.\n");
612 (void)max30105_deinit(&gs_handle);
613
614 return 1;
615 }
616 max30105_interface_debug_print("max30105: check shutdown %s.\n", enable == MAX30105_BOOL_TRUE ? "ok" : "error");
617
618 /* disable shutdown */
620 if (res != 0)
621 {
622 max30105_interface_debug_print("max30105: set shutdown failed.\n");
623 (void)max30105_deinit(&gs_handle);
624
625 return 1;
626 }
627 max30105_interface_debug_print("max30105: disable shutdown.\n");
628 res = max30105_get_shutdown(&gs_handle, &enable);
629 if (res != 0)
630 {
631 max30105_interface_debug_print("max30105: get shutdown failed.\n");
632 (void)max30105_deinit(&gs_handle);
633
634 return 1;
635 }
636 max30105_interface_debug_print("max30105: check shutdown %s.\n", enable == MAX30105_BOOL_FALSE ? "ok" : "error");
637
638 /* max30105_set_mode/max30105_get_mode test */
639 max30105_interface_debug_print("max30105: max30105_set_mode/max30105_get_mode test.\n");
640
641 /* red mode */
642 res = max30105_set_mode(&gs_handle, MAX30105_MODE_RED);
643 if (res != 0)
644 {
645 max30105_interface_debug_print("max30105: set mode failed.\n");
646 (void)max30105_deinit(&gs_handle);
647
648 return 1;
649 }
650 max30105_interface_debug_print("max30105: set red mode.\n");
651 res = max30105_get_mode(&gs_handle, &mode);
652 if (res != 0)
653 {
654 max30105_interface_debug_print("max30105: get mode failed.\n");
655 (void)max30105_deinit(&gs_handle);
656
657 return 1;
658 }
659 max30105_interface_debug_print("max30105: check mode %s.\n", mode == MAX30105_MODE_RED ? "ok" : "error");
660
661 /* red ir mode */
662 res = max30105_set_mode(&gs_handle, MAX30105_MODE_RED_IR);
663 if (res != 0)
664 {
665 max30105_interface_debug_print("max30105: set mode failed.\n");
666 (void)max30105_deinit(&gs_handle);
667
668 return 1;
669 }
670 max30105_interface_debug_print("max30105: set red ir mode.\n");
671 res = max30105_get_mode(&gs_handle, &mode);
672 if (res != 0)
673 {
674 max30105_interface_debug_print("max30105: get mode failed.\n");
675 (void)max30105_deinit(&gs_handle);
676
677 return 1;
678 }
679 max30105_interface_debug_print("max30105: check mode %s.\n", mode == MAX30105_MODE_RED_IR ? "ok" : "error");
680
681 /* red ir green */
683 if (res != 0)
684 {
685 max30105_interface_debug_print("max30105: set mode failed.\n");
686 (void)max30105_deinit(&gs_handle);
687
688 return 1;
689 }
690 max30105_interface_debug_print("max30105: set red ir green mode.\n");
691 res = max30105_get_mode(&gs_handle, &mode);
692 if (res != 0)
693 {
694 max30105_interface_debug_print("max30105: get mode failed.\n");
695 (void)max30105_deinit(&gs_handle);
696
697 return 1;
698 }
699 max30105_interface_debug_print("max30105: check mode %s.\n", mode == MAX30105_MODE_GREEN_RED_IR ? "ok" : "error");
700
701 /* max30105_set_particle_sensing_adc_range/max30105_get_particle_sensing_adc_range test */
702 max30105_interface_debug_print("max30105: max30105_set_particle_sensing_adc_range/max30105_get_particle_sensing_adc_range test.\n");
703
704 /* 2048 */
706 if (res != 0)
707 {
708 max30105_interface_debug_print("max30105: set particle sensing adc range failed.\n");
709 (void)max30105_deinit(&gs_handle);
710
711 return 1;
712 }
713 max30105_interface_debug_print("max30105: set particle sensing adc range 2048.\n");
714 res = max30105_get_particle_sensing_adc_range(&gs_handle, &range);
715 if (res != 0)
716 {
717 max30105_interface_debug_print("max30105: get particle sensing adc range failed.\n");
718 (void)max30105_deinit(&gs_handle);
719
720 return 1;
721 }
722 max30105_interface_debug_print("max30105: check particle sensing adc range %s.\n", range == MAX30105_PARTICLE_SENSING_ADC_RANGE_2048 ? "ok" : "error");
723
724 /* 4096 */
726 if (res != 0)
727 {
728 max30105_interface_debug_print("max30105: set particle sensing adc range failed.\n");
729 (void)max30105_deinit(&gs_handle);
730
731 return 1;
732 }
733 max30105_interface_debug_print("max30105: set particle sensing adc range 4096.\n");
734 res = max30105_get_particle_sensing_adc_range(&gs_handle, &range);
735 if (res != 0)
736 {
737 max30105_interface_debug_print("max30105: get particle sensing adc range failed.\n");
738 (void)max30105_deinit(&gs_handle);
739
740 return 1;
741 }
742 max30105_interface_debug_print("max30105: check particle sensing adc range %s.\n", range == MAX30105_PARTICLE_SENSING_ADC_RANGE_4096 ? "ok" : "error");
743
744 /* 8192 */
746 if (res != 0)
747 {
748 max30105_interface_debug_print("max30105: set particle sensing adc range failed.\n");
749 (void)max30105_deinit(&gs_handle);
750
751 return 1;
752 }
753 max30105_interface_debug_print("max30105: set particle sensing adc range 8192.\n");
754 res = max30105_get_particle_sensing_adc_range(&gs_handle, &range);
755 if (res != 0)
756 {
757 max30105_interface_debug_print("max30105: get particle sensing adc range failed.\n");
758 (void)max30105_deinit(&gs_handle);
759
760 return 1;
761 }
762 max30105_interface_debug_print("max30105: check particle sensing adc range %s.\n", range == MAX30105_PARTICLE_SENSING_ADC_RANGE_8192 ? "ok" : "error");
763
764 /* 16384 */
766 if (res != 0)
767 {
768 max30105_interface_debug_print("max30105: set particle sensing adc range failed.\n");
769 (void)max30105_deinit(&gs_handle);
770
771 return 1;
772 }
773 max30105_interface_debug_print("max30105: set particle sensing adc range 16384.\n");
774 res = max30105_get_particle_sensing_adc_range(&gs_handle, &range);
775 if (res != 0)
776 {
777 max30105_interface_debug_print("max30105: get particle sensing adc range failed.\n");
778 (void)max30105_deinit(&gs_handle);
779
780 return 1;
781 }
782 max30105_interface_debug_print("max30105: check particle sensing adc range %s.\n", range == MAX30105_PARTICLE_SENSING_ADC_RANGE_16384 ? "ok" : "error");
783
784 /* max30105_set_particle_sensing_sample_rate/max30105_get_particle_sensing_sample_rate test */
785 max30105_interface_debug_print("max30105: max30105_set_particle_sensing_sample_rate/max30105_get_particle_sensing_sample_rate test.\n");
786
787 /* 50Hz */
789 if (res != 0)
790 {
791 max30105_interface_debug_print("max30105: set particle sensing sample rate failed.\n");
792 (void)max30105_deinit(&gs_handle);
793
794 return 1;
795 }
796 max30105_interface_debug_print("max30105: set particle sensing sample rate 50Hz.\n");
797 res = max30105_get_particle_sensing_sample_rate(&gs_handle, &rate);
798 if (res != 0)
799 {
800 max30105_interface_debug_print("max30105: get particle sensing sample rate failed.\n");
801 (void)max30105_deinit(&gs_handle);
802
803 return 1;
804 }
805 max30105_interface_debug_print("max30105: check particle sensing sample rate %s.\n", rate == MAX30105_PARTICLE_SENSING_SAMPLE_RATE_50_HZ ? "ok" : "error");
806
807 /* 100Hz */
809 if (res != 0)
810 {
811 max30105_interface_debug_print("max30105: set particle sensing sample rate failed.\n");
812 (void)max30105_deinit(&gs_handle);
813
814 return 1;
815 }
816 max30105_interface_debug_print("max30105: set particle sensing sample rate 100Hz.\n");
817 res = max30105_get_particle_sensing_sample_rate(&gs_handle, &rate);
818 if (res != 0)
819 {
820 max30105_interface_debug_print("max30105: get particle sensing sample rate failed.\n");
821 (void)max30105_deinit(&gs_handle);
822
823 return 1;
824 }
825 max30105_interface_debug_print("max30105: check particle sensing sample rate %s.\n", rate == MAX30105_PARTICLE_SENSING_SAMPLE_RATE_100_HZ ? "ok" : "error");
826
827 /* 200Hz */
829 if (res != 0)
830 {
831 max30105_interface_debug_print("max30105: set particle sensing sample rate failed.\n");
832 (void)max30105_deinit(&gs_handle);
833
834 return 1;
835 }
836 max30105_interface_debug_print("max30105: set particle sensing sample rate 200Hz.\n");
837 res = max30105_get_particle_sensing_sample_rate(&gs_handle, &rate);
838 if (res != 0)
839 {
840 max30105_interface_debug_print("max30105: get particle sensing sample rate failed.\n");
841 (void)max30105_deinit(&gs_handle);
842
843 return 1;
844 }
845 max30105_interface_debug_print("max30105: check particle sensing sample rate %s.\n", rate == MAX30105_PARTICLE_SENSING_SAMPLE_RATE_200_HZ ? "ok" : "error");
846
847 /* 400Hz */
849 if (res != 0)
850 {
851 max30105_interface_debug_print("max30105: set particle sensing sample rate failed.\n");
852 (void)max30105_deinit(&gs_handle);
853
854 return 1;
855 }
856 max30105_interface_debug_print("max30105: set particle sensing sample rate 400Hz.\n");
857 res = max30105_get_particle_sensing_sample_rate(&gs_handle, &rate);
858 if (res != 0)
859 {
860 max30105_interface_debug_print("max30105: get particle sensing sample rate failed.\n");
861 (void)max30105_deinit(&gs_handle);
862
863 return 1;
864 }
865 max30105_interface_debug_print("max30105: check particle sensing sample rate %s.\n", rate == MAX30105_PARTICLE_SENSING_SAMPLE_RATE_400_HZ ? "ok" : "error");
866
867 /* 800Hz */
869 if (res != 0)
870 {
871 max30105_interface_debug_print("max30105: set particle sensing sample rate failed.\n");
872 (void)max30105_deinit(&gs_handle);
873
874 return 1;
875 }
876 max30105_interface_debug_print("max30105: set particle sensing sample rate 800Hz.\n");
877 res = max30105_get_particle_sensing_sample_rate(&gs_handle, &rate);
878 if (res != 0)
879 {
880 max30105_interface_debug_print("max30105: get particle sensing sample rate failed.\n");
881 (void)max30105_deinit(&gs_handle);
882
883 return 1;
884 }
885 max30105_interface_debug_print("max30105: check particle sensing sample rate %s.\n", rate == MAX30105_PARTICLE_SENSING_SAMPLE_RATE_800_HZ ? "ok" : "error");
886
887 /* 1000Hz */
889 if (res != 0)
890 {
891 max30105_interface_debug_print("max30105: set particle sensing sample rate failed.\n");
892 (void)max30105_deinit(&gs_handle);
893
894 return 1;
895 }
896 max30105_interface_debug_print("max30105: set particle sensing sample rate 1000Hz.\n");
897 res = max30105_get_particle_sensing_sample_rate(&gs_handle, &rate);
898 if (res != 0)
899 {
900 max30105_interface_debug_print("max30105: get particle sensing sample rate failed.\n");
901 (void)max30105_deinit(&gs_handle);
902
903 return 1;
904 }
905 max30105_interface_debug_print("max30105: check particle sensing sample rate %s.\n", rate == MAX30105_PARTICLE_SENSING_SAMPLE_RATE_1000_HZ ? "ok" : "error");
906
907 /* 1600Hz */
909 if (res != 0)
910 {
911 max30105_interface_debug_print("max30105: set particle sensing sample rate failed.\n");
912 (void)max30105_deinit(&gs_handle);
913
914 return 1;
915 }
916 max30105_interface_debug_print("max30105: set particle sensing sample rate 1600Hz.\n");
917 res = max30105_get_particle_sensing_sample_rate(&gs_handle, &rate);
918 if (res != 0)
919 {
920 max30105_interface_debug_print("max30105: get particle sensing sample rate failed.\n");
921 (void)max30105_deinit(&gs_handle);
922
923 return 1;
924 }
925 max30105_interface_debug_print("max30105: check particle sensing sample rate %s.\n", rate == MAX30105_PARTICLE_SENSING_SAMPLE_RATE_1600_HZ ? "ok" : "error");
926
927 /* 3200Hz */
929 if (res != 0)
930 {
931 max30105_interface_debug_print("max30105: set particle sensing sample rate failed.\n");
932 (void)max30105_deinit(&gs_handle);
933
934 return 1;
935 }
936 max30105_interface_debug_print("max30105: set particle sensing sample rate 3200Hz.\n");
937 res = max30105_get_particle_sensing_sample_rate(&gs_handle, &rate);
938 if (res != 0)
939 {
940 max30105_interface_debug_print("max30105: get particle sensing sample rate failed.\n");
941 (void)max30105_deinit(&gs_handle);
942
943 return 1;
944 }
945 max30105_interface_debug_print("max30105: check particle sensing sample rate %s.\n", rate == MAX30105_PARTICLE_SENSING_SAMPLE_RATE_3200_HZ ? "ok" : "error");
946
947 /* max30105_set_adc_resolution/max30105_get_adc_resolution test */
948 max30105_interface_debug_print("max30105: max30105_set_adc_resolution/max30105_get_adc_resolution test.\n");
949
950 /* 15 bits */
952 if (res != 0)
953 {
954 max30105_interface_debug_print("max30105: set adc resolution failed.\n");
955 (void)max30105_deinit(&gs_handle);
956
957 return 1;
958 }
959 max30105_interface_debug_print("max30105: set adc resolution 15 bits.\n");
960 res = max30105_get_adc_resolution(&gs_handle, &resolution);
961 if (res != 0)
962 {
963 max30105_interface_debug_print("max30105: get adc resolution failed.\n");
964 (void)max30105_deinit(&gs_handle);
965
966 return 1;
967 }
968 max30105_interface_debug_print("max30105: check adc resolution %s.\n", resolution == MAX30105_ADC_RESOLUTION_15_BIT ? "ok" : "error");
969
970 /* 16 bits */
972 if (res != 0)
973 {
974 max30105_interface_debug_print("max30105: set adc resolution failed.\n");
975 (void)max30105_deinit(&gs_handle);
976
977 return 1;
978 }
979 max30105_interface_debug_print("max30105: set adc resolution 16 bits.\n");
980 res = max30105_get_adc_resolution(&gs_handle, &resolution);
981 if (res != 0)
982 {
983 max30105_interface_debug_print("max30105: get adc resolution failed.\n");
984 (void)max30105_deinit(&gs_handle);
985
986 return 1;
987 }
988 max30105_interface_debug_print("max30105: check adc resolution %s.\n", resolution == MAX30105_ADC_RESOLUTION_16_BIT ? "ok" : "error");
989
990 /* 17 bits */
992 if (res != 0)
993 {
994 max30105_interface_debug_print("max30105: set adc resolution failed.\n");
995 (void)max30105_deinit(&gs_handle);
996
997 return 1;
998 }
999 max30105_interface_debug_print("max30105: set adc resolution 17 bits.\n");
1000 res = max30105_get_adc_resolution(&gs_handle, &resolution);
1001 if (res != 0)
1002 {
1003 max30105_interface_debug_print("max30105: get adc resolution failed.\n");
1004 (void)max30105_deinit(&gs_handle);
1005
1006 return 1;
1007 }
1008 max30105_interface_debug_print("max30105: check adc resolution %s.\n", resolution == MAX30105_ADC_RESOLUTION_17_BIT ? "ok" : "error");
1009
1010 /* 18 bits */
1012 if (res != 0)
1013 {
1014 max30105_interface_debug_print("max30105: set adc resolution failed.\n");
1015 (void)max30105_deinit(&gs_handle);
1016
1017 return 1;
1018 }
1019 max30105_interface_debug_print("max30105: set adc resolution 18 bits.\n");
1020 res = max30105_get_adc_resolution(&gs_handle, &resolution);
1021 if (res != 0)
1022 {
1023 max30105_interface_debug_print("max30105: get adc resolution failed.\n");
1024 (void)max30105_deinit(&gs_handle);
1025
1026 return 1;
1027 }
1028 max30105_interface_debug_print("max30105: check adc resolution %s.\n", resolution == MAX30105_ADC_RESOLUTION_18_BIT ? "ok" : "error");
1029
1030 /* max30105_set_led_red_pulse_amplitude/max30105_get_led_red_pulse_amplitude test */
1031 max30105_interface_debug_print("max30105: max30105_set_led_red_pulse_amplitude/max30105_get_led_red_pulse_amplitude test.\n");
1032
1033 value = rand() % 256;
1034 res = max30105_set_led_red_pulse_amplitude(&gs_handle, value);
1035 if (res != 0)
1036 {
1037 max30105_interface_debug_print("max30105: set led red pulse amplitude failed.\n");
1038 (void)max30105_deinit(&gs_handle);
1039
1040 return 1;
1041 }
1042 max30105_interface_debug_print("max30105: set led red pulse amplitude %d.\n", value);
1043 res = max30105_get_led_red_pulse_amplitude(&gs_handle, (uint8_t *)&value_check);
1044 if (res != 0)
1045 {
1046 max30105_interface_debug_print("max30105: get led red pulse amplitude failed.\n");
1047 (void)max30105_deinit(&gs_handle);
1048
1049 return 1;
1050 }
1051 max30105_interface_debug_print("max30105: check led red pulse amplitude %s.\n", value_check == value ? "ok" : "error");
1052
1053 /* max30105_set_led_ir_pulse_amplitude/max30105_get_led_ir_pulse_amplitude test */
1054 max30105_interface_debug_print("max30105: max30105_set_led_ir_pulse_amplitude/max30105_get_led_ir_pulse_amplitude test.\n");
1055
1056 value = rand() % 256;
1057 res = max30105_set_led_ir_pulse_amplitude(&gs_handle, value);
1058 if (res != 0)
1059 {
1060 max30105_interface_debug_print("max30105: set led ir pulse amplitude failed.\n");
1061 (void)max30105_deinit(&gs_handle);
1062
1063 return 1;
1064 }
1065 max30105_interface_debug_print("max30105: set led ir pulse amplitude %d.\n", value);
1066 res = max30105_get_led_ir_pulse_amplitude(&gs_handle, (uint8_t *)&value_check);
1067 if (res != 0)
1068 {
1069 max30105_interface_debug_print("max30105: get led ir pulse amplitude failed.\n");
1070 (void)max30105_deinit(&gs_handle);
1071
1072 return 1;
1073 }
1074 max30105_interface_debug_print("max30105: check led ir pulse amplitude %s.\n", value_check == value ? "ok" : "error");
1075
1076 /* max30105_set_led_green_pulse_amplitude/max30105_get_led_green_pulse_amplitude test */
1077 max30105_interface_debug_print("max30105: max30105_set_led_green_pulse_amplitude/max30105_get_led_green_pulse_amplitude test.\n");
1078
1079 value = rand() % 256;
1080 res = max30105_set_led_green_pulse_amplitude(&gs_handle, value);
1081 if (res != 0)
1082 {
1083 max30105_interface_debug_print("max30105: set led green pulse amplitude failed.\n");
1084 (void)max30105_deinit(&gs_handle);
1085
1086 return 1;
1087 }
1088 max30105_interface_debug_print("max30105: set led green pulse amplitude %d.\n", value);
1089 res = max30105_get_led_green_pulse_amplitude(&gs_handle, (uint8_t *)&value_check);
1090 if (res != 0)
1091 {
1092 max30105_interface_debug_print("max30105: get led green pulse amplitude failed.\n");
1093 (void)max30105_deinit(&gs_handle);
1094
1095 return 1;
1096 }
1097 max30105_interface_debug_print("max30105: check led green pulse amplitude %s.\n", value_check == value ? "ok" : "error");
1098
1099 /* max30105_set_led_proximity_pulse_amplitude/max30105_get_led_proximity_pulse_amplitude test */
1100 max30105_interface_debug_print("max30105: max30105_set_led_proximity_pulse_amplitude/max30105_get_led_proximity_pulse_amplitude test.\n");
1101
1102 value = rand() % 256;
1103 res = max30105_set_led_proximity_pulse_amplitude(&gs_handle, value);
1104 if (res != 0)
1105 {
1106 max30105_interface_debug_print("max30105: set led proximity pulse amplitude failed.\n");
1107 (void)max30105_deinit(&gs_handle);
1108
1109 return 1;
1110 }
1111 max30105_interface_debug_print("max30105: set led proximity pulse amplitude %d.\n", value);
1112 res = max30105_get_led_proximity_pulse_amplitude(&gs_handle, (uint8_t *)&value_check);
1113 if (res != 0)
1114 {
1115 max30105_interface_debug_print("max30105: get led proximity pulse amplitude failed.\n");
1116 (void)max30105_deinit(&gs_handle);
1117
1118 return 1;
1119 }
1120 max30105_interface_debug_print("max30105: check led proximity pulse amplitude %s.\n", value_check == value ? "ok" : "error");
1121
1122 /* max30105_set_slot/max30105_get_slot test */
1123 max30105_interface_debug_print("max30105: max30105_set_slot/max30105_get_slot test.\n");
1124
1125 /* slot1 led none */
1127 if (res != 0)
1128 {
1129 max30105_interface_debug_print("max30105: set slot failed.\n");
1130 (void)max30105_deinit(&gs_handle);
1131
1132 return 1;
1133 }
1134 max30105_interface_debug_print("max30105: set slot1 led none.\n");
1135 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_1, &led);
1136 if (res != 0)
1137 {
1138 max30105_interface_debug_print("max30105: get slot failed.\n");
1139 (void)max30105_deinit(&gs_handle);
1140
1141 return 1;
1142 }
1143 max30105_interface_debug_print("max30105: check slot1 %s.\n", led == MAX30105_LED_NONE ? "ok" : "error");
1144
1145 /* slot1 red led1 pa */
1147 if (res != 0)
1148 {
1149 max30105_interface_debug_print("max30105: set slot failed.\n");
1150 (void)max30105_deinit(&gs_handle);
1151
1152 return 1;
1153 }
1154 max30105_interface_debug_print("max30105: set slot1 red led1 pa.\n");
1155 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_1, &led);
1156 if (res != 0)
1157 {
1158 max30105_interface_debug_print("max30105: get slot failed.\n");
1159 (void)max30105_deinit(&gs_handle);
1160
1161 return 1;
1162 }
1163 max30105_interface_debug_print("max30105: check slot1 %s.\n", led == MAX30105_LED_RED_LED1_PA ? "ok" : "error");
1164
1165 /* slot1 ir led2 pa */
1167 if (res != 0)
1168 {
1169 max30105_interface_debug_print("max30105: set slot failed.\n");
1170 (void)max30105_deinit(&gs_handle);
1171
1172 return 1;
1173 }
1174 max30105_interface_debug_print("max30105: set slot1 ir led2 pa.\n");
1175 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_1, &led);
1176 if (res != 0)
1177 {
1178 max30105_interface_debug_print("max30105: get slot failed.\n");
1179 (void)max30105_deinit(&gs_handle);
1180
1181 return 1;
1182 }
1183 max30105_interface_debug_print("max30105: check slot1 %s.\n", led == MAX30105_LED_IR_LED2_PA ? "ok" : "error");
1184
1185 /* slot1 green led3 pa */
1187 if (res != 0)
1188 {
1189 max30105_interface_debug_print("max30105: set slot failed.\n");
1190 (void)max30105_deinit(&gs_handle);
1191
1192 return 1;
1193 }
1194 max30105_interface_debug_print("max30105: set slot1 green led3 pa.\n");
1195 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_1, &led);
1196 if (res != 0)
1197 {
1198 max30105_interface_debug_print("max30105: get slot failed.\n");
1199 (void)max30105_deinit(&gs_handle);
1200
1201 return 1;
1202 }
1203 max30105_interface_debug_print("max30105: check slot1 %s.\n", led == MAX30105_LED_GREEN_LED3_PA ? "ok" : "error");
1204
1205 /* slot1 red pilot pa */
1207 if (res != 0)
1208 {
1209 max30105_interface_debug_print("max30105: set slot failed.\n");
1210 (void)max30105_deinit(&gs_handle);
1211
1212 return 1;
1213 }
1214 max30105_interface_debug_print("max30105: set slot1 red pilot pa.\n");
1215 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_1, &led);
1216 if (res != 0)
1217 {
1218 max30105_interface_debug_print("max30105: get slot failed.\n");
1219 (void)max30105_deinit(&gs_handle);
1220
1221 return 1;
1222 }
1223 max30105_interface_debug_print("max30105: check slot1 %s.\n", led == MAX30105_LED_RED_PILOT_PA ? "ok" : "error");
1224
1225 /* slot1 ir pilot pa */
1227 if (res != 0)
1228 {
1229 max30105_interface_debug_print("max30105: set slot failed.\n");
1230 (void)max30105_deinit(&gs_handle);
1231
1232 return 1;
1233 }
1234 max30105_interface_debug_print("max30105: set slot1 ir pilot pa.\n");
1235 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_1, &led);
1236 if (res != 0)
1237 {
1238 max30105_interface_debug_print("max30105: get slot failed.\n");
1239 (void)max30105_deinit(&gs_handle);
1240
1241 return 1;
1242 }
1243 max30105_interface_debug_print("max30105: check slot1 %s.\n", led == MAX30105_LED_IR_PILOT_PA ? "ok" : "error");
1244
1245 /* slot1 green pilot pa */
1247 if (res != 0)
1248 {
1249 max30105_interface_debug_print("max30105: set slot failed.\n");
1250 (void)max30105_deinit(&gs_handle);
1251
1252 return 1;
1253 }
1254 max30105_interface_debug_print("max30105: set slot1 green pilot pa.\n");
1255 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_1, &led);
1256 if (res != 0)
1257 {
1258 max30105_interface_debug_print("max30105: get slot failed.\n");
1259 (void)max30105_deinit(&gs_handle);
1260
1261 return 1;
1262 }
1263 max30105_interface_debug_print("max30105: check slot1 %s.\n", led == MAX30105_LED_GREEN_PILOT_PA ? "ok" : "error");
1264
1265 /* slot2 led none */
1267 if (res != 0)
1268 {
1269 max30105_interface_debug_print("max30105: set slot failed.\n");
1270 (void)max30105_deinit(&gs_handle);
1271
1272 return 1;
1273 }
1274 max30105_interface_debug_print("max30105: set slot2 led none.\n");
1275 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_2, &led);
1276 if (res != 0)
1277 {
1278 max30105_interface_debug_print("max30105: get slot failed.\n");
1279 (void)max30105_deinit(&gs_handle);
1280
1281 return 1;
1282 }
1283 max30105_interface_debug_print("max30105: check slot2 %s.\n", led == MAX30105_LED_NONE ? "ok" : "error");
1284
1285 /* slot2 red led1 pa */
1287 if (res != 0)
1288 {
1289 max30105_interface_debug_print("max30105: set slot failed.\n");
1290 (void)max30105_deinit(&gs_handle);
1291
1292 return 1;
1293 }
1294 max30105_interface_debug_print("max30105: set slot2 red led1 pa.\n");
1295 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_2, &led);
1296 if (res != 0)
1297 {
1298 max30105_interface_debug_print("max30105: get slot failed.\n");
1299 (void)max30105_deinit(&gs_handle);
1300
1301 return 1;
1302 }
1303 max30105_interface_debug_print("max30105: check slot2 %s.\n", led == MAX30105_LED_RED_LED1_PA ? "ok" : "error");
1304
1305 /* slot2 ir led2 pa */
1307 if (res != 0)
1308 {
1309 max30105_interface_debug_print("max30105: set slot failed.\n");
1310 (void)max30105_deinit(&gs_handle);
1311
1312 return 1;
1313 }
1314 max30105_interface_debug_print("max30105: set slot2 ir led2 pa.\n");
1315 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_2, &led);
1316 if (res != 0)
1317 {
1318 max30105_interface_debug_print("max30105: get slot failed.\n");
1319 (void)max30105_deinit(&gs_handle);
1320
1321 return 1;
1322 }
1323 max30105_interface_debug_print("max30105: check slot2 %s.\n", led == MAX30105_LED_IR_LED2_PA ? "ok" : "error");
1324
1325 /* slot2 green led3 pa */
1327 if (res != 0)
1328 {
1329 max30105_interface_debug_print("max30105: set slot failed.\n");
1330 (void)max30105_deinit(&gs_handle);
1331
1332 return 1;
1333 }
1334 max30105_interface_debug_print("max30105: set slot2 green led3 pa.\n");
1335 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_2, &led);
1336 if (res != 0)
1337 {
1338 max30105_interface_debug_print("max30105: get slot failed.\n");
1339 (void)max30105_deinit(&gs_handle);
1340
1341 return 1;
1342 }
1343 max30105_interface_debug_print("max30105: check slot2 %s.\n", led == MAX30105_LED_GREEN_LED3_PA ? "ok" : "error");
1344
1345 /* slot2 red pilot pa */
1347 if (res != 0)
1348 {
1349 max30105_interface_debug_print("max30105: set slot failed.\n");
1350 (void)max30105_deinit(&gs_handle);
1351
1352 return 1;
1353 }
1354 max30105_interface_debug_print("max30105: set slot2 red pilot pa.\n");
1355 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_2, &led);
1356 if (res != 0)
1357 {
1358 max30105_interface_debug_print("max30105: get slot failed.\n");
1359 (void)max30105_deinit(&gs_handle);
1360
1361 return 1;
1362 }
1363 max30105_interface_debug_print("max30105: check slot2 %s.\n", led == MAX30105_LED_RED_PILOT_PA ? "ok" : "error");
1364
1365 /* slot2 ir pilot pa */
1367 if (res != 0)
1368 {
1369 max30105_interface_debug_print("max30105: set slot failed.\n");
1370 (void)max30105_deinit(&gs_handle);
1371
1372 return 1;
1373 }
1374 max30105_interface_debug_print("max30105: set slot2 ir pilot pa.\n");
1375 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_2, &led);
1376 if (res != 0)
1377 {
1378 max30105_interface_debug_print("max30105: get slot failed.\n");
1379 (void)max30105_deinit(&gs_handle);
1380
1381 return 1;
1382 }
1383 max30105_interface_debug_print("max30105: check slot2 %s.\n", led == MAX30105_LED_IR_PILOT_PA ? "ok" : "error");
1384
1385 /* slot2 green pilot pa */
1387 if (res != 0)
1388 {
1389 max30105_interface_debug_print("max30105: set slot failed.\n");
1390 (void)max30105_deinit(&gs_handle);
1391
1392 return 1;
1393 }
1394 max30105_interface_debug_print("max30105: set slot2 green pilot pa.\n");
1395 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_2, &led);
1396 if (res != 0)
1397 {
1398 max30105_interface_debug_print("max30105: get slot failed.\n");
1399 (void)max30105_deinit(&gs_handle);
1400
1401 return 1;
1402 }
1403 max30105_interface_debug_print("max30105: check slot2 %s.\n", led == MAX30105_LED_GREEN_PILOT_PA ? "ok" : "error");
1404
1405 /* slot3 led none */
1407 if (res != 0)
1408 {
1409 max30105_interface_debug_print("max30105: set slot failed.\n");
1410 (void)max30105_deinit(&gs_handle);
1411
1412 return 1;
1413 }
1414 max30105_interface_debug_print("max30105: set slot3 led none.\n");
1415 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_3, &led);
1416 if (res != 0)
1417 {
1418 max30105_interface_debug_print("max30105: get slot failed.\n");
1419 (void)max30105_deinit(&gs_handle);
1420
1421 return 1;
1422 }
1423 max30105_interface_debug_print("max30105: check slot3 %s.\n", led == MAX30105_LED_NONE ? "ok" : "error");
1424
1425 /* slot3 red led1 pa */
1427 if (res != 0)
1428 {
1429 max30105_interface_debug_print("max30105: set slot failed.\n");
1430 (void)max30105_deinit(&gs_handle);
1431
1432 return 1;
1433 }
1434 max30105_interface_debug_print("max30105: set slot3 red led1 pa.\n");
1435 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_3, &led);
1436 if (res != 0)
1437 {
1438 max30105_interface_debug_print("max30105: get slot failed.\n");
1439 (void)max30105_deinit(&gs_handle);
1440
1441 return 1;
1442 }
1443 max30105_interface_debug_print("max30105: check slot3 %s.\n", led == MAX30105_LED_RED_LED1_PA ? "ok" : "error");
1444
1445 /* slot3 ir led2 pa */
1447 if (res != 0)
1448 {
1449 max30105_interface_debug_print("max30105: set slot failed.\n");
1450 (void)max30105_deinit(&gs_handle);
1451
1452 return 1;
1453 }
1454 max30105_interface_debug_print("max30105: set slot3 ir led2 pa.\n");
1455 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_3, &led);
1456 if (res != 0)
1457 {
1458 max30105_interface_debug_print("max30105: get slot failed.\n");
1459 (void)max30105_deinit(&gs_handle);
1460
1461 return 1;
1462 }
1463 max30105_interface_debug_print("max30105: check slot3 %s.\n", led == MAX30105_LED_IR_LED2_PA ? "ok" : "error");
1464
1465 /* slot3 green led3 pa */
1467 if (res != 0)
1468 {
1469 max30105_interface_debug_print("max30105: set slot failed.\n");
1470 (void)max30105_deinit(&gs_handle);
1471
1472 return 1;
1473 }
1474 max30105_interface_debug_print("max30105: set slot3 green led3 pa.\n");
1475 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_3, &led);
1476 if (res != 0)
1477 {
1478 max30105_interface_debug_print("max30105: get slot failed.\n");
1479 (void)max30105_deinit(&gs_handle);
1480
1481 return 1;
1482 }
1483 max30105_interface_debug_print("max30105: check slot3 %s.\n", led == MAX30105_LED_GREEN_LED3_PA ? "ok" : "error");
1484
1485 /* slot3 red pilot pa */
1487 if (res != 0)
1488 {
1489 max30105_interface_debug_print("max30105: set slot failed.\n");
1490 (void)max30105_deinit(&gs_handle);
1491
1492 return 1;
1493 }
1494 max30105_interface_debug_print("max30105: set slot3 red pilot pa.\n");
1495 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_3, &led);
1496 if (res != 0)
1497 {
1498 max30105_interface_debug_print("max30105: get slot failed.\n");
1499 (void)max30105_deinit(&gs_handle);
1500
1501 return 1;
1502 }
1503 max30105_interface_debug_print("max30105: check slot3 %s.\n", led == MAX30105_LED_RED_PILOT_PA ? "ok" : "error");
1504
1505 /* slot3 ir pilot pa */
1507 if (res != 0)
1508 {
1509 max30105_interface_debug_print("max30105: set slot failed.\n");
1510 (void)max30105_deinit(&gs_handle);
1511
1512 return 1;
1513 }
1514 max30105_interface_debug_print("max30105: set slot3 ir pilot pa.\n");
1515 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_3, &led);
1516 if (res != 0)
1517 {
1518 max30105_interface_debug_print("max30105: get slot failed.\n");
1519 (void)max30105_deinit(&gs_handle);
1520
1521 return 1;
1522 }
1523 max30105_interface_debug_print("max30105: check slot3 %s.\n", led == MAX30105_LED_IR_PILOT_PA ? "ok" : "error");
1524
1525 /* slot3 green pilot pa */
1527 if (res != 0)
1528 {
1529 max30105_interface_debug_print("max30105: set slot failed.\n");
1530 (void)max30105_deinit(&gs_handle);
1531
1532 return 1;
1533 }
1534 max30105_interface_debug_print("max30105: set slot3 green pilot pa.\n");
1535 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_3, &led);
1536 if (res != 0)
1537 {
1538 max30105_interface_debug_print("max30105: get slot failed.\n");
1539 (void)max30105_deinit(&gs_handle);
1540
1541 return 1;
1542 }
1543 max30105_interface_debug_print("max30105: check slot3 %s.\n", led == MAX30105_LED_GREEN_PILOT_PA ? "ok" : "error");
1544
1545 /* slot4 led none */
1547 if (res != 0)
1548 {
1549 max30105_interface_debug_print("max30105: set slot failed.\n");
1550 (void)max30105_deinit(&gs_handle);
1551
1552 return 1;
1553 }
1554 max30105_interface_debug_print("max30105: set slot4 led none.\n");
1555 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_4, &led);
1556 if (res != 0)
1557 {
1558 max30105_interface_debug_print("max30105: get slot failed.\n");
1559 (void)max30105_deinit(&gs_handle);
1560
1561 return 1;
1562 }
1563 max30105_interface_debug_print("max30105: check slot4 %s.\n", led == MAX30105_LED_NONE ? "ok" : "error");
1564
1565 /* slot4 red led1 pa */
1567 if (res != 0)
1568 {
1569 max30105_interface_debug_print("max30105: set slot failed.\n");
1570 (void)max30105_deinit(&gs_handle);
1571
1572 return 1;
1573 }
1574 max30105_interface_debug_print("max30105: set slot4 red led1 pa.\n");
1575 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_4, &led);
1576 if (res != 0)
1577 {
1578 max30105_interface_debug_print("max30105: get slot failed.\n");
1579 (void)max30105_deinit(&gs_handle);
1580
1581 return 1;
1582 }
1583 max30105_interface_debug_print("max30105: check slot4 %s.\n", led == MAX30105_LED_RED_LED1_PA ? "ok" : "error");
1584
1585 /* slot4 ir led2 pa */
1587 if (res != 0)
1588 {
1589 max30105_interface_debug_print("max30105: set slot failed.\n");
1590 (void)max30105_deinit(&gs_handle);
1591
1592 return 1;
1593 }
1594 max30105_interface_debug_print("max30105: set slot4 ir led2 pa.\n");
1595 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_4, &led);
1596 if (res != 0)
1597 {
1598 max30105_interface_debug_print("max30105: get slot failed.\n");
1599 (void)max30105_deinit(&gs_handle);
1600
1601 return 1;
1602 }
1603 max30105_interface_debug_print("max30105: check slot4 %s.\n", led == MAX30105_LED_IR_LED2_PA ? "ok" : "error");
1604
1605 /* slot4 green led3 pa */
1607 if (res != 0)
1608 {
1609 max30105_interface_debug_print("max30105: set slot failed.\n");
1610 (void)max30105_deinit(&gs_handle);
1611
1612 return 1;
1613 }
1614 max30105_interface_debug_print("max30105: set slot4 green led3 pa.\n");
1615 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_4, &led);
1616 if (res != 0)
1617 {
1618 max30105_interface_debug_print("max30105: get slot failed.\n");
1619 (void)max30105_deinit(&gs_handle);
1620
1621 return 1;
1622 }
1623 max30105_interface_debug_print("max30105: check slot4 %s.\n", led == MAX30105_LED_GREEN_LED3_PA ? "ok" : "error");
1624
1625 /* slot4 red pilot pa */
1627 if (res != 0)
1628 {
1629 max30105_interface_debug_print("max30105: set slot failed.\n");
1630 (void)max30105_deinit(&gs_handle);
1631
1632 return 1;
1633 }
1634 max30105_interface_debug_print("max30105: set slot4 red pilot pa.\n");
1635 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_4, &led);
1636 if (res != 0)
1637 {
1638 max30105_interface_debug_print("max30105: get slot failed.\n");
1639 (void)max30105_deinit(&gs_handle);
1640
1641 return 1;
1642 }
1643 max30105_interface_debug_print("max30105: check slot4 %s.\n", led == MAX30105_LED_RED_PILOT_PA ? "ok" : "error");
1644
1645 /* slot4 ir pilot pa */
1647 if (res != 0)
1648 {
1649 max30105_interface_debug_print("max30105: set slot failed.\n");
1650 (void)max30105_deinit(&gs_handle);
1651
1652 return 1;
1653 }
1654 max30105_interface_debug_print("max30105: set slot4 ir pilot pa.\n");
1655 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_4, &led);
1656 if (res != 0)
1657 {
1658 max30105_interface_debug_print("max30105: get slot failed.\n");
1659 (void)max30105_deinit(&gs_handle);
1660
1661 return 1;
1662 }
1663 max30105_interface_debug_print("max30105: check slot4 %s.\n", led == MAX30105_LED_IR_PILOT_PA ? "ok" : "error");
1664
1665 /* slot4 green pilot pa */
1667 if (res != 0)
1668 {
1669 max30105_interface_debug_print("max30105: set slot failed.\n");
1670 (void)max30105_deinit(&gs_handle);
1671
1672 return 1;
1673 }
1674 max30105_interface_debug_print("max30105: set slot4 green pilot pa.\n");
1675 res = max30105_get_slot(&gs_handle, MAX30105_SLOT_4, &led);
1676 if (res != 0)
1677 {
1678 max30105_interface_debug_print("max30105: get slot failed.\n");
1679 (void)max30105_deinit(&gs_handle);
1680
1681 return 1;
1682 }
1683 max30105_interface_debug_print("max30105: check slot4 %s.\n", led == MAX30105_LED_GREEN_PILOT_PA ? "ok" : "error");
1684
1685 /* max30105_set_die_temperature/max30105_get_die_temperature test */
1686 max30105_interface_debug_print("max30105: max30105_set_die_temperature/max30105_get_die_temperature test.\n");
1687
1688 /* disable */
1690 if (res != 0)
1691 {
1692 max30105_interface_debug_print("max30105: set die temperature failed.\n");
1693 (void)max30105_deinit(&gs_handle);
1694
1695 return 1;
1696 }
1697 max30105_interface_debug_print("max30105: disable die temperature.\n");
1698 res = max30105_get_die_temperature(&gs_handle, &enable);
1699 if (res != 0)
1700 {
1701 max30105_interface_debug_print("max30105: get die temperature failed.\n");
1702 (void)max30105_deinit(&gs_handle);
1703
1704 return 1;
1705 }
1706 max30105_interface_debug_print("max30105: check die temperature %s.\n", enable == MAX30105_BOOL_FALSE ? "ok" : "error");
1707
1708 /* enable */
1710 if (res != 0)
1711 {
1712 max30105_interface_debug_print("max30105: set die temperature failed.\n");
1713 (void)max30105_deinit(&gs_handle);
1714
1715 return 1;
1716 }
1717 max30105_interface_debug_print("max30105: enable die temperature.\n");
1718 res = max30105_get_die_temperature(&gs_handle, &enable);
1719 if (res != 0)
1720 {
1721 max30105_interface_debug_print("max30105: get die temperature failed.\n");
1722 (void)max30105_deinit(&gs_handle);
1723
1724 return 1;
1725 }
1726 max30105_interface_debug_print("max30105: check die temperature %s.\n", res == 0 ? "ok" : "error");
1727
1728 /* max30105_set_proximity_interrupt_threshold/max30105_get_proximity_interrupt_threshold test */
1729 max30105_interface_debug_print("max30105: max30105_set_proximity_interrupt_threshold/max30105_get_proximity_interrupt_threshold test.\n");
1730
1731 threshold = rand() % 256;
1732 res = max30105_set_proximity_interrupt_threshold(&gs_handle, threshold);
1733 if (res != 0)
1734 {
1735 max30105_interface_debug_print("max30105: set proximity interrupt threshold failed.\n");
1736 (void)max30105_deinit(&gs_handle);
1737
1738 return 1;
1739 }
1740 max30105_interface_debug_print("max30105: set proximity interrupt threshold %d.\n", threshold);
1741 res = max30105_get_proximity_interrupt_threshold(&gs_handle, (uint8_t *)&threshold_check);
1742 if (res != 0)
1743 {
1744 max30105_interface_debug_print("max30105: get proximity interrupt threshold failed.\n");
1745 (void)max30105_deinit(&gs_handle);
1746
1747 return 1;
1748 }
1749
1750 /* max30105_proximity_threshold_convert_to_register/max30105_proximity_threshold_convert_to_data test */
1751 max30105_interface_debug_print("max30105: max30105_proximity_threshold_convert_to_register/max30105_proximity_threshold_convert_to_data test.\n");
1752
1753 adc = rand() % 256 * 1023;
1754 res = max30105_proximity_threshold_convert_to_register(&gs_handle, adc, (uint8_t *)&value);
1755 if (res != 0)
1756 {
1757 max30105_interface_debug_print("max30105: proximity threshold convert to register failed.\n");
1758 (void)max30105_deinit(&gs_handle);
1759
1760 return 1;
1761 }
1762 max30105_interface_debug_print("max30105: adc is %d.\n", adc);
1763 res = max30105_proximity_threshold_convert_to_data(&gs_handle, value, (uint32_t *)&adc_check);
1764 if (res != 0)
1765 {
1766 max30105_interface_debug_print("max30105: proximity threshold convert to data failed.\n");
1767 (void)max30105_deinit(&gs_handle);
1768
1769 return 1;
1770 }
1771 max30105_interface_debug_print("max30105: check adc is %d.\n", adc_check);
1772
1773 /* max30105_get_id test */
1774 max30105_interface_debug_print("max30105: max30105_get_id test.\n");
1775
1776 /* get id */
1777 res = max30105_get_id(&gs_handle, (uint8_t *)&revision_id, (uint8_t *)&part_id);
1778 if (res != 0)
1779 {
1780 max30105_interface_debug_print("max30105: get id failed.\n");
1781 (void)max30105_deinit(&gs_handle);
1782
1783 return 1;
1784 }
1785 max30105_interface_debug_print("max30105: revision id is 0x%02X part id is 0x%02X.\n", revision_id, part_id);
1786
1787 /* max30105_get_interrupt_status test */
1788 max30105_interface_debug_print("max30105: max30105_get_interrupt_status test.\n");
1789
1790 /* get fifo full */
1792 if (res != 0)
1793 {
1794 max30105_interface_debug_print("max30105: get interrupt status failed.\n");
1795 (void)max30105_deinit(&gs_handle);
1796
1797 return 1;
1798 }
1799 max30105_interface_debug_print("max30105: interrupt status fifo full is %d.\n", enable);
1800
1801 /* get data ready */
1803 if (res != 0)
1804 {
1805 max30105_interface_debug_print("max30105: get interrupt status failed.\n");
1806 (void)max30105_deinit(&gs_handle);
1807
1808 return 1;
1809 }
1810 max30105_interface_debug_print("max30105: interrupt status data ready is %d.\n", enable);
1811
1812 /* get alc ovf */
1814 if (res != 0)
1815 {
1816 max30105_interface_debug_print("max30105: get interrupt status failed.\n");
1817 (void)max30105_deinit(&gs_handle);
1818
1819 return 1;
1820 }
1821 max30105_interface_debug_print("max30105: interrupt status alc ovf is %d.\n", enable);
1822
1823 /* get proximity threshold */
1825 if (res != 0)
1826 {
1827 max30105_interface_debug_print("max30105: get interrupt status failed.\n");
1828 (void)max30105_deinit(&gs_handle);
1829
1830 return 1;
1831 }
1832 max30105_interface_debug_print("max30105: interrupt status proximity threshold is %d.\n", enable);
1833
1834 /* get pwr ready */
1836 if (res != 0)
1837 {
1838 max30105_interface_debug_print("max30105: get interrupt status failed.\n");
1839 (void)max30105_deinit(&gs_handle);
1840
1841 return 1;
1842 }
1843 max30105_interface_debug_print("max30105: interrupt status pwr ready is %d.\n", enable);
1844
1845 /* get die temp ready */
1847 if (res != 0)
1848 {
1849 max30105_interface_debug_print("max30105: get interrupt status failed.\n");
1850 (void)max30105_deinit(&gs_handle);
1851
1852 return 1;
1853 }
1854 max30105_interface_debug_print("max30105: interrupt status die temp ready is %d.\n", enable);
1855
1856 /* max30105_reset test */
1857 max30105_interface_debug_print("max30105: max30105_reset test.\n");
1858
1859 /* reset */
1860 res = max30105_reset(&gs_handle);
1861 if (res != 0)
1862 {
1863 max30105_interface_debug_print("max30105: reset failed.\n");
1864 (void)max30105_deinit(&gs_handle);
1865
1866 return 1;
1867 }
1868 max30105_interface_debug_print("max30105: check reset %s.\n", res == 0 ? "ok" : "error");
1870
1871 /* finish register test */
1872 max30105_interface_debug_print("max30105: finish register test.\n");
1873 (void)max30105_deinit(&gs_handle);
1874
1875 return 0;
1876}
driver max30105 register test header file
uint8_t max30105_set_fifo_data(max30105_handle_t *handle, uint8_t data)
set the fifo data
uint8_t max30105_init(max30105_handle_t *handle)
initialize the chip
uint8_t max30105_proximity_threshold_convert_to_data(max30105_handle_t *handle, uint8_t reg, uint32_t *adc)
convert the register raw data to the proximity threshold
uint8_t max30105_get_fifo_roll(max30105_handle_t *handle, max30105_bool_t *enable)
get the fifo roll status
uint8_t max30105_get_led_red_pulse_amplitude(max30105_handle_t *handle, uint8_t *amp)
get the red led pulse amplitude
uint8_t max30105_get_adc_resolution(max30105_handle_t *handle, max30105_adc_resolution_t *resolution)
get the adc resolution
uint8_t max30105_get_id(max30105_handle_t *handle, uint8_t *revision_id, uint8_t *part_id)
get the chip id
uint8_t max30105_get_interrupt(max30105_handle_t *handle, max30105_interrupt_t type, max30105_bool_t *enable)
get the interrupt bool
uint8_t max30105_set_fifo_sample_averaging(max30105_handle_t *handle, max30105_sample_averaging_t sample)
set the fifo sample averaging
uint8_t max30105_get_fifo_sample_averaging(max30105_handle_t *handle, max30105_sample_averaging_t *sample)
get the fifo sample averaging
uint8_t max30105_set_fifo_almost_full(max30105_handle_t *handle, uint8_t value)
set the fifo almost full value
uint8_t max30105_get_led_ir_pulse_amplitude(max30105_handle_t *handle, uint8_t *amp)
get the ir led pulse amplitude
uint8_t max30105_info(max30105_info_t *info)
get chip's information
uint8_t max30105_set_led_red_pulse_amplitude(max30105_handle_t *handle, uint8_t amp)
set the red led pulse amplitude
uint8_t max30105_get_die_temperature(max30105_handle_t *handle, max30105_bool_t *enable)
get the die temperature status
uint8_t max30105_get_particle_sensing_adc_range(max30105_handle_t *handle, max30105_particle_sensing_adc_range_t *range)
get the particle sensing adc range
uint8_t max30105_set_shutdown(max30105_handle_t *handle, max30105_bool_t enable)
set the shutdown
uint8_t max30105_get_fifo_data(max30105_handle_t *handle, uint8_t *data)
get the fifo data
uint8_t max30105_get_mode(max30105_handle_t *handle, max30105_mode_t *mode)
get the mode
uint8_t max30105_get_fifo_write_pointer(max30105_handle_t *handle, uint8_t *pointer)
get the fifo write pointer
uint8_t max30105_set_fifo_overflow_counter(max30105_handle_t *handle, uint8_t counter)
set the fifo overflow counter
struct max30105_handle_s max30105_handle_t
max30105 handle structure definition
uint8_t max30105_reset(max30105_handle_t *handle)
reset the chip
uint8_t max30105_proximity_threshold_convert_to_register(max30105_handle_t *handle, uint32_t adc, uint8_t *reg)
convert the proximity threshold to the register raw data
uint8_t max30105_get_fifo_read_pointer(max30105_handle_t *handle, uint8_t *pointer)
get the fifo read pointer
max30105_particle_sensing_sample_rate_t
max30105 particle sensing sample rate enumeration definition
uint8_t max30105_set_mode(max30105_handle_t *handle, max30105_mode_t mode)
set the mode
uint8_t max30105_get_shutdown(max30105_handle_t *handle, max30105_bool_t *enable)
get the shutdown
uint8_t max30105_get_proximity_interrupt_threshold(max30105_handle_t *handle, uint8_t *threshold)
get the proximity interrupt threshold
uint8_t max30105_set_fifo_roll(max30105_handle_t *handle, max30105_bool_t enable)
enable or disable the fifo roll
max30105_bool_t
max30105 bool enumeration definition
max30105_sample_averaging_t
max30105 sample averaging enumeration definition
uint8_t max30105_get_slot(max30105_handle_t *handle, max30105_slot_t slot, max30105_led_t *led)
get the led slot
max30105_adc_resolution_t
max30105 adc resolution enumeration definition
uint8_t max30105_get_led_proximity_pulse_amplitude(max30105_handle_t *handle, uint8_t *amp)
get the proximity led pulse amplitude
uint8_t max30105_set_led_proximity_pulse_amplitude(max30105_handle_t *handle, uint8_t amp)
set the proximity led pulse amplitude
uint8_t max30105_get_particle_sensing_sample_rate(max30105_handle_t *handle, max30105_particle_sensing_sample_rate_t *rate)
get the particle sensing sample rate
uint8_t max30105_get_fifo_almost_full(max30105_handle_t *handle, uint8_t *value)
get the fifo almost full value
uint8_t max30105_set_interrupt(max30105_handle_t *handle, max30105_interrupt_t type, max30105_bool_t enable)
set the interrupt bool
max30105_mode_t
max30105 mode enumeration definition
uint8_t max30105_set_fifo_read_pointer(max30105_handle_t *handle, uint8_t pointer)
set the fifo read pointer
uint8_t max30105_set_led_green_pulse_amplitude(max30105_handle_t *handle, uint8_t amp)
set the green led pulse amplitude
max30105_particle_sensing_adc_range_t
max30105 particle sensing adc range enumeration definition
uint8_t max30105_set_adc_resolution(max30105_handle_t *handle, max30105_adc_resolution_t resolution)
set the adc resolution
uint8_t max30105_set_particle_sensing_adc_range(max30105_handle_t *handle, max30105_particle_sensing_adc_range_t range)
set the particle sensing adc range
uint8_t max30105_set_proximity_interrupt_threshold(max30105_handle_t *handle, uint8_t threshold)
set the proximity interrupt threshold
uint8_t max30105_set_particle_sensing_sample_rate(max30105_handle_t *handle, max30105_particle_sensing_sample_rate_t rate)
set the particle sensing sample rate
max30105_led_t
max30105 led enumeration definition
struct max30105_info_s max30105_info_t
max30105 information structure definition
uint8_t max30105_get_led_green_pulse_amplitude(max30105_handle_t *handle, uint8_t *amp)
get the green led pulse amplitude
uint8_t max30105_get_fifo_overflow_counter(max30105_handle_t *handle, uint8_t *counter)
get the fifo overflow counter
uint8_t max30105_get_interrupt_status(max30105_handle_t *handle, max30105_interrupt_status_t status, max30105_bool_t *enable)
get the interrupt status
uint8_t max30105_deinit(max30105_handle_t *handle)
close the chip
uint8_t max30105_set_fifo_write_pointer(max30105_handle_t *handle, uint8_t pointer)
set the fifo write pointer
uint8_t max30105_set_led_ir_pulse_amplitude(max30105_handle_t *handle, uint8_t amp)
set the ir led pulse amplitude
uint8_t max30105_set_die_temperature(max30105_handle_t *handle, max30105_bool_t enable)
enable or disable die temperature
uint8_t max30105_set_slot(max30105_handle_t *handle, max30105_slot_t slot, max30105_led_t led)
set the led slot
@ MAX30105_INTERRUPT_FIFO_FULL_EN
@ MAX30105_INTERRUPT_DIE_TEMP_RDY_EN
@ MAX30105_INTERRUPT_ALC_OVF_EN
@ MAX30105_INTERRUPT_DATA_RDY_EN
@ MAX30105_INTERRUPT_PROX_INT_EN
@ MAX30105_INTERRUPT_STATUS_ALC_OVF
@ MAX30105_INTERRUPT_STATUS_DIE_TEMP_RDY
@ MAX30105_INTERRUPT_STATUS_FIFO_FULL
@ MAX30105_INTERRUPT_STATUS_DATA_RDY
@ MAX30105_INTERRUPT_STATUS_PWR_RDY
@ MAX30105_INTERRUPT_STATUS_PROX_INT
@ MAX30105_PARTICLE_SENSING_SAMPLE_RATE_1600_HZ
@ MAX30105_PARTICLE_SENSING_SAMPLE_RATE_50_HZ
@ MAX30105_PARTICLE_SENSING_SAMPLE_RATE_200_HZ
@ MAX30105_PARTICLE_SENSING_SAMPLE_RATE_3200_HZ
@ MAX30105_PARTICLE_SENSING_SAMPLE_RATE_800_HZ
@ MAX30105_PARTICLE_SENSING_SAMPLE_RATE_400_HZ
@ MAX30105_PARTICLE_SENSING_SAMPLE_RATE_1000_HZ
@ MAX30105_PARTICLE_SENSING_SAMPLE_RATE_100_HZ
@ MAX30105_BOOL_TRUE
@ MAX30105_BOOL_FALSE
@ MAX30105_SAMPLE_AVERAGING_1
@ MAX30105_SAMPLE_AVERAGING_8
@ MAX30105_SAMPLE_AVERAGING_2
@ MAX30105_SAMPLE_AVERAGING_4
@ MAX30105_SAMPLE_AVERAGING_32
@ MAX30105_SAMPLE_AVERAGING_16
@ MAX30105_ADC_RESOLUTION_15_BIT
@ MAX30105_ADC_RESOLUTION_17_BIT
@ MAX30105_ADC_RESOLUTION_18_BIT
@ MAX30105_ADC_RESOLUTION_16_BIT
@ MAX30105_MODE_RED_IR
@ MAX30105_MODE_RED
@ MAX30105_MODE_GREEN_RED_IR
@ MAX30105_SLOT_2
@ MAX30105_SLOT_4
@ MAX30105_SLOT_1
@ MAX30105_SLOT_3
@ MAX30105_PARTICLE_SENSING_ADC_RANGE_16384
@ MAX30105_PARTICLE_SENSING_ADC_RANGE_4096
@ MAX30105_PARTICLE_SENSING_ADC_RANGE_2048
@ MAX30105_PARTICLE_SENSING_ADC_RANGE_8192
@ MAX30105_LED_GREEN_PILOT_PA
@ MAX30105_LED_IR_LED2_PA
@ MAX30105_LED_RED_LED1_PA
@ MAX30105_LED_NONE
@ MAX30105_LED_IR_PILOT_PA
@ MAX30105_LED_GREEN_LED3_PA
@ MAX30105_LED_RED_PILOT_PA
void max30105_interface_delay_ms(uint32_t ms)
interface delay ms
void max30105_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t max30105_interface_iic_write(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus write
uint8_t max30105_interface_iic_deinit(void)
interface iic bus deinit
uint8_t max30105_interface_iic_read(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus read
void max30105_interface_receive_callback(uint8_t type)
interface receive callback
uint8_t max30105_interface_iic_init(void)
interface iic bus init
uint8_t max30105_register_test(void)
register test
char manufacturer_name[32]