LibDriver MAX30102
Loading...
Searching...
No Matches
driver_max30102.c
Go to the documentation of this file.
1
36
37#include "driver_max30102.h"
38
42#define CHIP_NAME "Maxim Integrated MAX30102"
43#define MANUFACTURER_NAME "Maxim Integrated"
44#define SUPPLY_VOLTAGE_MIN 1.7f
45#define SUPPLY_VOLTAGE_MAX 2.0f
46#define MAX_CURRENT 20.0f
47#define TEMPERATURE_MIN -40.0f
48#define TEMPERATURE_MAX 85.0f
49#define DRIVER_VERSION 1000
50
54#define MAX30102_ADDRESS 0xAE
55
59#define MAX30102_REG_INTERRUPT_STATUS_1 0x00
60#define MAX30102_REG_INTERRUPT_STATUS_2 0x01
61#define MAX30102_REG_INTERRUPT_ENABLE_1 0x02
62#define MAX30102_REG_INTERRUPT_ENABLE_2 0x03
63#define MAX30102_REG_FIFO_WRITE_POINTER 0x04
64#define MAX30102_REG_OVERFLOW_COUNTER 0x05
65#define MAX30102_REG_FIFO_READ_POINTER 0x06
66#define MAX30102_REG_FIFO_DATA_REGISTER 0x07
67#define MAX30102_REG_FIFO_CONFIG 0x08
68#define MAX30102_REG_MODE_CONFIG 0x09
69#define MAX30102_REG_SPO2_CONFIG 0x0A
70#define MAX30102_REG_LED_PULSE_1 0x0C
71#define MAX30102_REG_LED_PULSE_2 0x0D
72#define MAX30102_REG_MULTI_LED_MODE_CONTROL_1 0x11
73#define MAX30102_REG_MULTI_LED_MODE_CONTROL_2 0x12
74#define MAX30102_REG_DIE_TEMP_INTEGER 0x1F
75#define MAX30102_REG_DIE_TEMP_FRACTION 0x20
76#define MAX30102_REG_DIE_TEMP_CONFIG 0x21
77#define MAX30102_REG_REVISION_ID 0xFE
78#define MAX30102_REG_PART_ID 0xFF
79
94{
95 uint8_t res;
96 uint8_t prev;
97 uint8_t part_id;
98
99 if (handle == NULL) /* check handle */
100 {
101 return 2; /* return error */
102 }
103 if (handle->debug_print == NULL) /* check debug_print */
104 {
105 return 3; /* return error */
106 }
107 if (handle->iic_init == NULL) /* check iic_init */
108 {
109 handle->debug_print("max30102: iic_init is null.\n"); /* iic_init is null */
110
111 return 3; /* return error */
112 }
113 if (handle->iic_deinit == NULL) /* check iic_deinit */
114 {
115 handle->debug_print("max30102: iic_deinit is null.\n"); /* iic_deinit is null */
116
117 return 3; /* return error */
118 }
119 if (handle->iic_read == NULL) /* check iic_read */
120 {
121 handle->debug_print("max30102: iic_read is null.\n"); /* iic_read is null */
122
123 return 3; /* return error */
124 }
125 if (handle->iic_write == NULL) /* check iic_write */
126 {
127 handle->debug_print("max30102: iic_write is null.\n"); /* iic_write is null */
128
129 return 3; /* return error */
130 }
131 if (handle->receive_callback == NULL) /* check receive_callback */
132 {
133 handle->debug_print("max30102: receive_callback is null.\n"); /* receive_callback is null */
134
135 return 3; /* return error */
136 }
137 if (handle->delay_ms == NULL) /* check delay_ms */
138 {
139 handle->debug_print("max30102: delay_ms is null.\n"); /* delay_ms is null */
140
141 return 3; /* return error */
142 }
143
144 if (handle->iic_init() != 0) /* init iic */
145 {
146 handle->debug_print("max30102: iic init failed.\n"); /* iic init failed */
147
148 return 1; /* return error */
149 }
150 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_PART_ID, (uint8_t *)&part_id, 1); /* read part id */
151 if (res != 0) /* check result */
152 {
153 handle->debug_print("max30102: read part id failed.\n"); /* read part id failed */
154 (void)handle->iic_deinit(); /* iic deinit */
155
156 return 4; /* return error */
157 }
158 if (part_id != 0x15) /* check part id */
159 {
160 handle->debug_print("max30102: id is invalid.\n"); /* id is invalid */
161 (void)handle->iic_deinit(); /* iic deinit */
162
163 return 4; /* return error */
164 }
165 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_MODE_CONFIG, (uint8_t *)&prev, 1); /* read mode config */
166 if (res != 0) /* check result */
167 {
168 handle->debug_print("max30102: read mode config failed.\n"); /* read mode config failed */
169 (void)handle->iic_deinit(); /* iic deinit */
170
171 return 5; /* return error */
172 }
173 prev &= ~(1 << 6); /* clear config */
174 prev |= 1 << 6; /* set 1 */
175 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_MODE_CONFIG, (uint8_t *)&prev, 1); /* write mode config */
176 if (res != 0) /* check result */
177 {
178 handle->debug_print("max30102: write mode config failed.\n"); /* write mode config failed */
179 (void)handle->iic_deinit(); /* iic deinit */
180
181 return 5; /* return error */
182 }
183 handle->delay_ms(10); /* delay 10 ms */
184 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_MODE_CONFIG, (uint8_t *)&prev, 1); /* read mode config */
185 if (res != 0) /* check result */
186 {
187 handle->debug_print("max30102: read mode config failed.\n"); /* read mode config failed */
188 (void)handle->iic_deinit(); /* iic deinit */
189
190 return 5; /* return error */
191 }
192 if ((prev & (1 << 6)) != 0) /* check result */
193 {
194 handle->debug_print("max30102: reset failed.\n"); /* reset failed */
195 (void)handle->iic_deinit(); /* iic deinit */
196
197 return 5; /* return error */
198 }
199 prev = 0; /* set zero */
200 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_FIFO_READ_POINTER, (uint8_t *)&prev, 1); /* write fifo read pointer */
201 if (res != 0) /* check result */
202 {
203 handle->debug_print("max30102: write fifo read pointer failed.\n"); /* write fifo read pointer failed */
204 (void)handle->iic_deinit(); /* iic deinit */
205
206 return 6; /* return error */
207 }
208 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_FIFO_WRITE_POINTER, (uint8_t *)&prev, 1); /* write fifo write pointer */
209 if (res != 0) /* check result */
210 {
211 handle->debug_print("max30102: write fifo write pointer failed.\n"); /* write fifo write pointer failed */
212 (void)handle->iic_deinit(); /* iic deinit */
213
214 return 6; /* return error */
215 }
216 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_OVERFLOW_COUNTER, (uint8_t *)&prev, 1); /* write overflow counter */
217 if (res != 0) /* check result */
218 {
219 handle->debug_print("max30102: write overflow counter failed.\n"); /* write overflow counter failed */
220 (void)handle->iic_deinit(); /* iic deinit */
221
222 return 6; /* return error */
223 }
224 handle->inited = 1; /* flag finish initialization */
225
226 return 0; /* success return 0 */
227}
228
241{
242 uint8_t res;
243 uint8_t prev;
244
245 if (handle == NULL) /* check handle */
246 {
247 return 2; /* return error */
248 }
249 if (handle->inited != 1) /* check handle initialization */
250 {
251 return 3; /* return error */
252 }
253
254 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_MODE_CONFIG, (uint8_t *)&prev, 1); /* read mode config */
255 if (res != 0) /* check result */
256 {
257 handle->debug_print("max30102: read mode config failed.\n"); /* read mode config failed */
258
259 return 4; /* return error */
260 }
261 prev &= ~(1 << 7); /* clear config */
262 prev |= 1 << 7; /* set bool */
263 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_MODE_CONFIG, (uint8_t *)&prev, 1); /* write mode config */
264 if (res != 0) /* check result */
265 {
266 handle->debug_print("max30102: write mode config failed.\n"); /* write mode config failed */
267
268 return 4; /* return error */
269 }
270 if (handle->iic_deinit() != 0) /* iic deinit */
271 {
272 handle->debug_print("max30102: iic deinit failed.\n"); /* iic deinit failed */
273
274 return 1; /* return error */
275 }
276
277 handle->inited = 0; /* flag close */
278
279 return 0; /* success return 0 */
280}
281
293{
294 uint8_t res;
295 uint8_t prev;
296
297 if (handle == NULL) /* check handle */
298 {
299 return 2; /* return error */
300 }
301 if (handle->inited != 1) /* check handle initialization */
302 {
303 return 3; /* return error */
304 }
305
306 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_INTERRUPT_STATUS_1, (uint8_t *)&prev, 1); /* read interrupt status1 */
307 if (res != 0) /* check result */
308 {
309 handle->debug_print("max30102: read interrupt status1 failed.\n"); /* read interrupt status1 failed */
310
311 return 1; /* return error */
312 }
313 if ((prev & (1 << MAX30102_INTERRUPT_STATUS_FIFO_FULL)) != 0) /* check fifo full */
314 {
315 if (handle->receive_callback != NULL) /* if receive callback */
316 {
317 handle->receive_callback(MAX30102_INTERRUPT_STATUS_FIFO_FULL); /* run callback */
318 }
319 }
320 if ((prev & (1 << MAX30102_INTERRUPT_STATUS_PPG_RDY)) != 0) /* check ppg ready */
321 {
322 if (handle->receive_callback != NULL) /* if receive callback */
323 {
324 handle->receive_callback(MAX30102_INTERRUPT_STATUS_PPG_RDY); /* run callback */
325 }
326 }
327 if ((prev & (1 << MAX30102_INTERRUPT_STATUS_ALC_OVF)) != 0) /* check alc ovf */
328 {
329 if (handle->receive_callback != NULL) /* if receive callback */
330 {
331 handle->receive_callback(MAX30102_INTERRUPT_STATUS_ALC_OVF); /* run callback */
332 }
333 }
334 if ((prev & (1 << MAX30102_INTERRUPT_STATUS_PWR_RDY)) != 0) /* check pwr ready */
335 {
336 if (handle->receive_callback != NULL) /* if receive callback */
337 {
338 handle->receive_callback(MAX30102_INTERRUPT_STATUS_PWR_RDY); /* run callback */
339 }
340 }
341 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_INTERRUPT_STATUS_2, (uint8_t *)&prev, 1); /* read interrupt status2 */
342 if (res != 0) /* check result */
343 {
344 handle->debug_print("max30102: read interrupt status2 failed.\n"); /* read interrupt status2 failed */
345
346 return 1; /* return error */
347 }
348 if ((prev & (1 << MAX30102_INTERRUPT_STATUS_DIE_TEMP_RDY)) != 0) /* check die temp ready */
349 {
350 uint8_t prev1;
351
352 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_DIE_TEMP_INTEGER, (uint8_t *)&prev, 1); /* read die temp integer */
353 if (res != 0) /* check result */
354 {
355 handle->debug_print("max30102: read die temp integer failed.\n"); /* read die temp integer failed */
356
357 return 1; /* return error */
358 }
359 handle->raw = (uint16_t)prev << 4; /* set integer part */
360 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_DIE_TEMP_FRACTION, (uint8_t *)&prev1, 1); /* read die temp fraction */
361 if (res != 0) /* check result */
362 {
363 handle->debug_print("max30102: read die temp fraction failed.\n"); /* read die temp fraction failed */
364
365 return 1; /* return error */
366 }
367 handle->raw = handle->raw | prev1; /* set fraction part */
368 handle->temperature = (float)(prev) + (float)(prev1) * 0.0625f; /* set the temperature */
369 handle->finished_flag = 1; /* set flag */
370
371 if (handle->receive_callback != NULL) /* if receive callback */
372 {
374 }
375 }
376
377 return 0; /* success return 0 */
378}
379
395uint8_t max30102_read(max30102_handle_t *handle, uint32_t *raw_red, uint32_t *raw_ir, uint8_t *len)
396{
397 uint8_t res;
398 uint8_t prev;
399 uint8_t mode;
400 uint8_t k;
401 uint8_t read_point;
402 uint8_t write_point;
403 uint8_t l;
404 uint8_t bit;
405 uint8_t i;
406 uint8_t r;
407
408 if (handle == NULL) /* check handle */
409 {
410 return 2; /* return error */
411 }
412 if (handle->inited != 1) /* check handle initialization */
413 {
414 return 3; /* return error */
415 }
416
417 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_OVERFLOW_COUNTER, (uint8_t *)&prev, 1); /* read overflow counter */
418 if (res != 0) /* check result */
419 {
420 handle->debug_print("max30102: read overflow counter failed.\n"); /* read overflow counter failed */
421
422 return 1; /* return error */
423 }
424 r = 0; /* set 0 */
425 if (prev != 0) /* check overflow */
426 {
427 r = 4; /* set 4 */
428
429 handle->debug_print("max30102: fifo overrun.\n"); /* fifo overrun*/
430 }
431 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_FIFO_READ_POINTER, (uint8_t *)&read_point, 1); /* read fifo read point */
432 if (res != 0) /* check result */
433 {
434 handle->debug_print("max30102: read fifo read point failed.\n"); /* read fifo read point failed */
435
436 return 1; /* return error */
437 }
438 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_FIFO_WRITE_POINTER, (uint8_t *)&write_point, 1); /* read fifo write point */
439 if (res != 0) /* check result */
440 {
441 handle->debug_print("max30102: read fifo write point failed.\n"); /* read fifo write point failed */
442
443 return 1; /* return error */
444 }
445
446 if (write_point > read_point) /* check point */
447 {
448 l = write_point - read_point; /* get length */
449 }
450 else
451 {
452 l = 32 + write_point - read_point; /* get length */
453 }
454 *len = ((*len) > l) ? l : (*len); /* set read length */
455 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_MODE_CONFIG, (uint8_t *)&prev, 1); /* read mode config */
456 if (res != 0) /* check result */
457 {
458 handle->debug_print("max30102: read mode config failed.\n"); /* read mode config failed */
459
460 return 1; /* return error */
461 }
462 mode = (max30102_mode_t)(prev & 0x7); /* get mode */
463 if (mode == MAX30102_MODE_HEART_RATE) /* check heart rate mode */
464 {
465 k = 3; /* 3 */
466 }
467 else if (mode == MAX30102_MODE_SPO2) /* check spo2 mode*/
468 {
469 k = 6; /* 6 */
470 }
471 else if (mode == MAX30102_MODE_MULTI_LED) /* check multi led mode */
472 {
473 k = 6; /* 6 */
474 }
475 else
476 {
477 handle->debug_print("max30105: mode is invalid.\n"); /* mode is invalid */
478
479 return 5; /* return error */
480 }
481
482 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_FIFO_DATA_REGISTER, handle->buf, (*len) * k); /* read fifo read point */
483 if (res != 0) /* check result */
484 {
485 handle->debug_print("max30102: read fifo data register failed.\n"); /* read fifo data register failed */
486
487 return 1; /* return error */
488 }
489 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_SPO2_CONFIG, (uint8_t *)&prev, 1); /* read spo2 config */
490 if (res != 0) /* check result */
491 {
492 handle->debug_print("max30102: read spo2 config failed.\n"); /* read spo2 config failed */
493
494 return 1; /* return error */
495 }
496 prev = prev & 0x3; /* get config */
497 if (prev == 0) /* if 0 */
498 {
499 bit = 3; /* 15 bits */
500 }
501 else if (prev == 1) /* if 1 */
502 {
503 bit = 2; /* 16 bits */
504 }
505 else if (prev == 2) /* if 2 */
506 {
507 bit = 1; /* 17 bits */
508 }
509 else /* if 3 */
510 {
511 bit = 0; /* 18 bits */
512 }
513
514 for (i = 0; i < (*len); i++) /* copy data */
515 {
516 if (mode == MAX30102_MODE_HEART_RATE) /* check red mode */
517 {
518 raw_red[i] = ((uint32_t)handle->buf[i * 3 + 0] << 16) | /* get raw red data */
519 ((uint32_t)handle->buf[i * 3 + 1] << 8) | /* get raw red data */
520 ((uint32_t)handle->buf[i * 3 + 2] << 0); /* get raw red data */
521 raw_red[i] = raw_red[i] >> bit; /* right shift bit */
522 }
523 else
524 {
525 raw_red[i] = ((uint32_t)handle->buf[i * 6 + 0] << 16) | /* get raw red data */
526 ((uint32_t)handle->buf[i * 6 + 1] << 8) | /* get raw red data */
527 ((uint32_t)handle->buf[i * 6 + 2] << 0); /* get raw red data */
528 raw_red[i] = raw_red[i] >> bit; /* right shift bit */
529 raw_ir[i] = ((uint32_t)handle->buf[i * 6 + 3] << 16) | /* get raw ir data */
530 ((uint32_t)handle->buf[i * 6 + 4] << 8) | /* get raw ir data */
531 ((uint32_t)handle->buf[i * 6 + 5] << 0); /* get raw ir data */
532 raw_ir[i] = raw_ir[i] >> bit; /* right shift bit */
533 }
534 }
535
536 return r; /* success return 0 */
537}
538
551uint8_t max30102_read_temperature(max30102_handle_t *handle, uint16_t *raw, float *temp)
552{
553 uint8_t res;
554 uint8_t prev;
555 uint16_t timeout;
556
557 if (handle == NULL) /* check handle */
558 {
559 return 2; /* return error */
560 }
561 if (handle->inited != 1) /* check handle initialization */
562 {
563 return 3; /* return error */
564 }
565
566 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_INTERRUPT_ENABLE_2, (uint8_t *)&prev, 1); /* read interrupt enable2 */
567 if (res != 0) /* check result */
568 {
569 handle->debug_print("max30102: read interrupt enable2 failed.\n"); /* read interrupt enable2 failed */
570
571 return 1; /* return error */
572 }
573 if ((prev & (1 << 1)) == 0) /* check config */
574 {
575 prev &= ~(1 << 1); /* clear interrupt */
576 prev |= 1 << 1; /* set interrupt */
577 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_INTERRUPT_ENABLE_2, (uint8_t *)&prev, 1); /* write interrupt enable2 */
578 if (res != 0) /* check result */
579 {
580 handle->debug_print("max30102: write interrupt enable2 failed.\n"); /* write interrupt enable2 failed */
581
582 return 1; /* return error */
583 }
584 }
585
586 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_DIE_TEMP_CONFIG, (uint8_t *)&prev, 1); /* read die temp config */
587 if (res != 0) /* check result */
588 {
589 handle->debug_print("max30102: read die temp config failed.\n"); /* read die temp config failed */
590
591 return 1; /* return error */
592 }
593 prev &= ~(1 << 0); /* clear config */
594 prev |= (1 << 0); /* set bool */
595 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_DIE_TEMP_CONFIG, (uint8_t *)&prev, 1); /* write die temp config */
596 if (res != 0) /* check result */
597 {
598 handle->debug_print("max30102: write die temp config failed.\n"); /* write die temp config failed */
599
600 return 1; /* return error */
601 }
602
603 timeout = 5000; /* set 5000 ms */
604 handle->finished_flag = 0; /* clear finished flag */
605 while (timeout != 0) /* timeout */
606 {
607 handle->delay_ms(1); /* delay 1 ms */
608 timeout--; /* timeout */
609 if (handle->finished_flag != 0) /* check finished flag */
610 {
611 break; /* break */
612 }
613 }
614 if (timeout == 0) /* check timeout */
615 {
616 handle->debug_print("max30102: read timeout.\n"); /* read timeout */
617
618 return 1; /* return error */
619 }
620 *raw = handle->raw; /* get raw */
621 *temp = handle->temperature; /* get temperature */
622
623 return 0; /* success return 0 */
624}
625
639{
640 uint8_t res;
641 uint8_t prev;
642
643 if (handle == NULL) /* check handle */
644 {
645 return 2; /* return error */
646 }
647 if (handle->inited != 1) /* check handle initialization */
648 {
649 return 3; /* return error */
650 }
651
652 if (status == MAX30102_INTERRUPT_STATUS_DIE_TEMP_RDY) /* if die temp ready status */
653 {
654 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_INTERRUPT_STATUS_2, (uint8_t *)&prev, 1); /* read interrupt status2 */
655 if (res != 0) /* check result */
656 {
657 handle->debug_print("max30102: read interrupt status2 failed.\n"); /* read interrupt status2 failed */
658
659 return 1; /* return error */
660 }
661 *enable = (max30102_bool_t)((prev >> status) & 0x01); /* get bool */
662
663 return 0; /* success return 0 */
664 }
665 else
666 {
667 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_INTERRUPT_STATUS_1, (uint8_t *)&prev, 1); /* read interrupt status1 */
668 if (res != 0) /* check result */
669 {
670 handle->debug_print("max30102: read interrupt status1 failed.\n"); /* read interrupt status1 failed */
671
672 return 1; /* return error */
673 }
674 *enable = (max30102_bool_t)((prev >> status) & 0x01); /* get bool */
675
676 return 0; /* success return 0 */
677 }
678}
679
693{
694 uint8_t res;
695 uint8_t prev;
696
697 if (handle == NULL) /* check handle */
698 {
699 return 2; /* return error */
700 }
701 if (handle->inited != 1) /* check handle initialization */
702 {
703 return 3; /* return error */
704 }
705
706 if (type == MAX30102_INTERRUPT_DIE_TEMP_RDY_EN) /* if internal temperature enable */
707 {
708 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_INTERRUPT_ENABLE_2, (uint8_t *)&prev, 1); /* read interrupt enable2 */
709 if (res != 0) /* check result */
710 {
711 handle->debug_print("max30102: read interrupt enable2 failed.\n"); /* read interrupt enable2 failed */
712
713 return 1; /* return error */
714 }
715 prev &= ~(1 << type); /* clear interrupt */
716 prev |= enable << type; /* set interrupt */
717 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_INTERRUPT_ENABLE_2, (uint8_t *)&prev, 1); /* write interrupt enable2 */
718 if (res != 0) /* check result */
719 {
720 handle->debug_print("max30102: write interrupt enable2 failed.\n"); /* write interrupt enable2 failed */
721
722 return 1; /* return error */
723 }
724
725 return 0; /* success return 0 */
726 }
727 else
728 {
729 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_INTERRUPT_ENABLE_1, (uint8_t *)&prev, 1); /* read interrupt enable1 */
730 if (res != 0) /* check result */
731 {
732 handle->debug_print("max30102: read interrupt enable1 failed.\n"); /* read interrupt enable1 failed */
733
734 return 1; /* return error */
735 }
736 prev &= ~(1 << type); /* clear interrupt */
737 prev |= enable << type; /* set interrupt */
738 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_INTERRUPT_ENABLE_1, (uint8_t *)&prev, 1); /* write interrupt enable1 */
739 if (res != 0) /* check result */
740 {
741 handle->debug_print("max30102: write interrupt enable1 failed.\n"); /* write interrupt enable1 failed */
742
743 return 1; /* return error */
744 }
745
746 return 0; /* success return 0 */
747 }
748}
749
763{
764 uint8_t res;
765 uint8_t prev;
766
767 if (handle == NULL) /* check handle */
768 {
769 return 2; /* return error */
770 }
771 if (handle->inited != 1) /* check handle initialization */
772 {
773 return 3; /* return error */
774 }
775
776 if (type == MAX30102_INTERRUPT_DIE_TEMP_RDY_EN) /* if internal temperature enable */
777 {
778 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_INTERRUPT_ENABLE_2, (uint8_t *)&prev, 1); /* read interrupt enable2 */
779 if (res != 0) /* check result */
780 {
781 handle->debug_print("max30102: read interrupt enable2 failed.\n"); /* read interrupt enable2 failed */
782
783 return 1; /* return error */
784 }
785 *enable = (max30102_bool_t)((prev >> type) & 0x01); /* get bool */
786
787 return 0; /* success return 0 */
788 }
789 else
790 {
791 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_INTERRUPT_ENABLE_1, (uint8_t *)&prev, 1); /* read interrupt enable1 */
792 if (res != 0) /* check result */
793 {
794 handle->debug_print("max30102: read interrupt enable1 failed.\n"); /* read interrupt enable1 failed */
795
796 return 1; /* return error */
797 }
798 *enable = (max30102_bool_t)((prev >> type) & 0x01); /* get bool */
799
800 return 0; /* success return 0 */
801 }
802}
803
816uint8_t max30102_set_fifo_write_pointer(max30102_handle_t *handle, uint8_t pointer)
817{
818 uint8_t res;
819 uint8_t prev;
820
821 if (handle == NULL) /* check handle */
822 {
823 return 2; /* return error */
824 }
825 if (handle->inited != 1) /* check handle initialization */
826 {
827 return 3; /* return error */
828 }
829 if (pointer > 0x1F) /* check pointer */
830 {
831 handle->debug_print("max30102: pointer can't be over 0x1F.\n"); /* pointer can't be over 0x1F */
832
833 return 4; /* return error */
834 }
835
836 prev = pointer & 0x1F; /* set pointer */
837 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_FIFO_WRITE_POINTER, (uint8_t *)&prev, 1); /* write fifo write pointer */
838 if (res != 0) /* check result */
839 {
840 handle->debug_print("max30102: write fifo write pointer failed.\n"); /* write fifo write pointer failed */
841
842 return 1; /* return error */
843 }
844
845 return 0; /* success return 0 */
846}
847
859uint8_t max30102_get_fifo_write_pointer(max30102_handle_t *handle, uint8_t *pointer)
860{
861 uint8_t res;
862 uint8_t prev;
863
864 if (handle == NULL) /* check handle */
865 {
866 return 2; /* return error */
867 }
868 if (handle->inited != 1) /* check handle initialization */
869 {
870 return 3; /* return error */
871 }
872
873 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_FIFO_WRITE_POINTER, (uint8_t *)&prev, 1); /* read fifo write pointer */
874 if (res != 0) /* check result */
875 {
876 handle->debug_print("max30102: read fifo write pointer failed.\n"); /* read fifo write pointer failed */
877
878 return 1; /* return error */
879 }
880 *pointer = prev & 0x1F; /* get pointer */
881
882 return 0; /* success return 0 */
883}
884
898{
899 uint8_t res;
900 uint8_t prev;
901
902 if (handle == NULL) /* check handle */
903 {
904 return 2; /* return error */
905 }
906 if (handle->inited != 1) /* check handle initialization */
907 {
908 return 3; /* return error */
909 }
910 if (counter > 0x1F) /* check counter */
911 {
912 handle->debug_print("max30102: counter can't be over 0x1F.\n"); /* counter can't be over 0x1F */
913
914 return 4; /* return error */
915 }
916
917 prev = counter & 0x1F; /* set counter */
918 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_OVERFLOW_COUNTER, (uint8_t *)&prev, 1); /* set fifo overflow counter */
919 if (res != 0) /* check result */
920 {
921 handle->debug_print("max30102: set fifo overflow counter failed.\n"); /* set fifo overflow counter failed */
922
923 return 1; /* return error */
924 }
925
926 return 0; /* success return 0 */
927}
928
941{
942 uint8_t res;
943 uint8_t prev;
944
945 if (handle == NULL) /* check handle */
946 {
947 return 2; /* return error */
948 }
949 if (handle->inited != 1) /* check handle initialization */
950 {
951 return 3; /* return error */
952 }
953
954 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_OVERFLOW_COUNTER, (uint8_t *)&prev, 1); /* get fifo overflow counter */
955 if (res != 0) /* check result */
956 {
957 handle->debug_print("max30102: get fifo overflow counter failed.\n"); /* get fifo overflow counter failed */
958
959 return 1; /* return error */
960 }
961 *counter = prev & 0x1F; /* get pointer */
962
963 return 0; /* success return 0 */
964}
965
978uint8_t max30102_set_fifo_read_pointer(max30102_handle_t *handle, uint8_t pointer)
979{
980 uint8_t res;
981 uint8_t prev;
982
983 if (handle == NULL) /* check handle */
984 {
985 return 2; /* return error */
986 }
987 if (handle->inited != 1) /* check handle initialization */
988 {
989 return 3; /* return error */
990 }
991 if (pointer > 0x1F) /* check pointer */
992 {
993 handle->debug_print("max30102: pointer can't be over 0x1F.\n"); /* pointer can't be over 0x1F */
994
995 return 4; /* return error */
996 }
997
998 prev = pointer & 0x1F; /* set pointer */
999 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_FIFO_READ_POINTER, (uint8_t *)&prev, 1); /* write fifo read pointer */
1000 if (res != 0) /* check result */
1001 {
1002 handle->debug_print("max30102: write fifo read pointer failed.\n"); /* write fifo read pointer failed */
1003
1004 return 1; /* return error */
1005 }
1006
1007 return 0; /* success return 0 */
1008}
1009
1021uint8_t max30102_get_fifo_read_pointer(max30102_handle_t *handle, uint8_t *pointer)
1022{
1023 uint8_t res;
1024 uint8_t prev;
1025
1026 if (handle == NULL) /* check handle */
1027 {
1028 return 2; /* return error */
1029 }
1030 if (handle->inited != 1) /* check handle initialization */
1031 {
1032 return 3; /* return error */
1033 }
1034
1035 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_FIFO_READ_POINTER, (uint8_t *)&prev, 1); /* read fifo read pointer */
1036 if (res != 0) /* check result */
1037 {
1038 handle->debug_print("max30102: read fifo read pointer failed.\n"); /* read fifo read pointer failed */
1039
1040 return 1; /* return error */
1041 }
1042 *pointer = prev & 0x1F; /* get pointer */
1043
1044 return 0; /* success return 0 */
1045}
1046
1058uint8_t max30102_set_fifo_data(max30102_handle_t *handle, uint8_t data)
1059{
1060 uint8_t res;
1061
1062 if (handle == NULL) /* check handle */
1063 {
1064 return 2; /* return error */
1065 }
1066 if (handle->inited != 1) /* check handle initialization */
1067 {
1068 return 3; /* return error */
1069 }
1070
1071 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_FIFO_DATA_REGISTER, (uint8_t *)&data, 1); /* write fifo data register */
1072 if (res != 0) /* check result */
1073 {
1074 handle->debug_print("max30102: write fifo data register failed.\n"); /* write fifo data register failed */
1075
1076 return 1; /* return error */
1077 }
1078
1079 return 0; /* success return 0 */
1080}
1081
1093uint8_t max30102_get_fifo_data(max30102_handle_t *handle, uint8_t *data)
1094{
1095 uint8_t res;
1096
1097 if (handle == NULL) /* check handle */
1098 {
1099 return 2; /* return error */
1100 }
1101 if (handle->inited != 1) /* check handle initialization */
1102 {
1103 return 3; /* return error */
1104 }
1105
1106 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_FIFO_DATA_REGISTER, (uint8_t *)data, 1); /* read fifo data register */
1107 if (res != 0) /* check result */
1108 {
1109 handle->debug_print("max30102: read fifo data register failed.\n"); /* read fifo data register failed */
1110
1111 return 1; /* return error */
1112 }
1113
1114 return 0; /* success return 0 */
1115}
1116
1129{
1130 uint8_t res;
1131 uint8_t prev;
1132
1133 if (handle == NULL) /* check handle */
1134 {
1135 return 2; /* return error */
1136 }
1137 if (handle->inited != 1) /* check handle initialization */
1138 {
1139 return 3; /* return error */
1140 }
1141
1142 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_FIFO_CONFIG, (uint8_t *)&prev, 1); /* read fifo config */
1143 if (res != 0) /* check result */
1144 {
1145 handle->debug_print("max30102: read fifo config failed.\n"); /* read fifo config failed */
1146
1147 return 1; /* return error */
1148 }
1149 prev &= ~(0x7 << 5); /* clear config */
1150 prev |= sample << 5; /* set sample */
1151 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_FIFO_CONFIG, (uint8_t *)&prev, 1); /* write fifo config */
1152 if (res != 0) /* check result */
1153 {
1154 handle->debug_print("max30102: write fifo config failed.\n"); /* write fifo config failed */
1155
1156 return 1; /* return error */
1157 }
1158
1159 return 0; /* success return 0 */
1160}
1161
1174{
1175 uint8_t res;
1176 uint8_t prev;
1177
1178 if (handle == NULL) /* check handle */
1179 {
1180 return 2; /* return error */
1181 }
1182 if (handle->inited != 1) /* check handle initialization */
1183 {
1184 return 3; /* return error */
1185 }
1186
1187 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_FIFO_CONFIG, (uint8_t *)&prev, 1); /* read fifo config */
1188 if (res != 0) /* check result */
1189 {
1190 handle->debug_print("max30102: read fifo config failed.\n"); /* read fifo config failed */
1191
1192 return 1; /* return error */
1193 }
1194 *sample = (max30102_sample_averaging_t)(0x7 & (prev >> 5)); /* get sample averaging */
1195
1196 return 0; /* success return 0 */
1197}
1198
1211{
1212 uint8_t res;
1213 uint8_t prev;
1214
1215 if (handle == NULL) /* check handle */
1216 {
1217 return 2; /* return error */
1218 }
1219 if (handle->inited != 1) /* check handle initialization */
1220 {
1221 return 3; /* return error */
1222 }
1223
1224 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_FIFO_CONFIG, (uint8_t *)&prev, 1); /* read fifo config */
1225 if (res != 0) /* check result */
1226 {
1227 handle->debug_print("max30102: read fifo config failed.\n"); /* read fifo config failed */
1228
1229 return 1; /* return error */
1230 }
1231 prev &= ~(0x1 << 4); /* clear config */
1232 prev |= enable << 4; /* set enable */
1233 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_FIFO_CONFIG, (uint8_t *)&prev, 1); /* write fifo config */
1234 if (res != 0) /* check result */
1235 {
1236 handle->debug_print("max30102: write fifo config failed.\n"); /* write fifo config failed */
1237
1238 return 1; /* return error */
1239 }
1240
1241 return 0; /* success return 0 */
1242}
1243
1256{
1257 uint8_t res;
1258 uint8_t prev;
1259
1260 if (handle == NULL) /* check handle */
1261 {
1262 return 2; /* return error */
1263 }
1264 if (handle->inited != 1) /* check handle initialization */
1265 {
1266 return 3; /* return error */
1267 }
1268
1269 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_FIFO_CONFIG, (uint8_t *)&prev, 1); /* read fifo config */
1270 if (res != 0) /* check result */
1271 {
1272 handle->debug_print("max30102: read fifo config failed.\n"); /* read fifo config failed */
1273
1274 return 1; /* return error */
1275 }
1276 *enable = (max30102_bool_t)(0x1 & (prev >> 4)); /* get bool */
1277
1278 return 0; /* success return 0 */
1279}
1280
1294{
1295 uint8_t res;
1296 uint8_t prev;
1297
1298 if (handle == NULL) /* check handle */
1299 {
1300 return 2; /* return error */
1301 }
1302 if (handle->inited != 1) /* check handle initialization */
1303 {
1304 return 3; /* return error */
1305 }
1306 if (value > 0xF) /* check value */
1307 {
1308 handle->debug_print("max30102: value can't be over 0xF.\n"); /* value can't be over 0xF */
1309
1310 return 4; /* return error */
1311 }
1312
1313 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_FIFO_CONFIG, (uint8_t *)&prev, 1); /* read fifo config */
1314 if (res != 0) /* check result */
1315 {
1316 handle->debug_print("max30102: read fifo config failed.\n"); /* read fifo config failed */
1317
1318 return 1; /* return error */
1319 }
1320 prev &= ~(0xF << 0); /* clear config */
1321 prev |= value << 0; /* set value */
1322 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_FIFO_CONFIG, (uint8_t *)&prev, 1); /* write fifo config */
1323 if (res != 0) /* check result */
1324 {
1325 handle->debug_print("max30102: write fifo config failed.\n"); /* write fifo config failed */
1326
1327 return 1; /* return error */
1328 }
1329
1330 return 0; /* success return 0 */
1331}
1332
1344uint8_t max30102_get_fifo_almost_full(max30102_handle_t *handle, uint8_t *value)
1345{
1346 uint8_t res;
1347 uint8_t prev;
1348
1349 if (handle == NULL) /* check handle */
1350 {
1351 return 2; /* return error */
1352 }
1353 if (handle->inited != 1) /* check handle initialization */
1354 {
1355 return 3; /* return error */
1356 }
1357
1358 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_FIFO_CONFIG, (uint8_t *)&prev, 1); /* read fifo config */
1359 if (res != 0) /* check result */
1360 {
1361 handle->debug_print("max30102: read fifo config failed.\n"); /* read fifo config failed */
1362
1363 return 1; /* return error */
1364 }
1365 *value = prev & 0xF; /* get value */
1366
1367 return 0; /* success return 0 */
1368}
1369
1382{
1383 uint8_t res;
1384 uint8_t prev;
1385
1386 if (handle == NULL) /* check handle */
1387 {
1388 return 2; /* return error */
1389 }
1390 if (handle->inited != 1) /* check handle initialization */
1391 {
1392 return 3; /* return error */
1393 }
1394
1395 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_MODE_CONFIG, (uint8_t *)&prev, 1); /* read mode config */
1396 if (res != 0) /* check result */
1397 {
1398 handle->debug_print("max30102: read mode config failed.\n"); /* read mode config failed */
1399
1400 return 1; /* return error */
1401 }
1402 prev &= ~(1 << 7); /* clear config */
1403 prev |= enable << 7; /* set bool */
1404 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_MODE_CONFIG, (uint8_t *)&prev, 1); /* write mode config */
1405 if (res != 0) /* check result */
1406 {
1407 handle->debug_print("max30102: write mode config failed.\n"); /* write mode config failed */
1408
1409 return 1; /* return error */
1410 }
1411
1412 return 0; /* success return 0 */
1413}
1414
1427{
1428 uint8_t res;
1429 uint8_t prev;
1430
1431 if (handle == NULL) /* check handle */
1432 {
1433 return 2; /* return error */
1434 }
1435 if (handle->inited != 1) /* check handle initialization */
1436 {
1437 return 3; /* return error */
1438 }
1439
1440 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_MODE_CONFIG, (uint8_t *)&prev, 1); /* read mode config */
1441 if (res != 0) /* check result */
1442 {
1443 handle->debug_print("max30102: read mode config failed.\n"); /* read mode config failed */
1444
1445 return 1; /* return error */
1446 }
1447 *enable = (max30102_bool_t)((prev >> 7) & 0x01); /* get bool */
1448
1449 return 0; /* success return 0 */
1450}
1451
1463{
1464 uint8_t res;
1465 uint8_t prev;
1466
1467 if (handle == NULL) /* check handle */
1468 {
1469 return 2; /* return error */
1470 }
1471 if (handle->inited != 1) /* check handle initialization */
1472 {
1473 return 3; /* return error */
1474 }
1475
1476 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_MODE_CONFIG, (uint8_t *)&prev, 1); /* read mode config */
1477 if (res != 0) /* check result */
1478 {
1479 handle->debug_print("max30102: read mode config failed.\n"); /* read mode config failed */
1480
1481 return 1; /* return error */
1482 }
1483 prev &= ~(1 << 6); /* clear config */
1484 prev |= 1 << 6; /* set 1 */
1485 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_MODE_CONFIG, (uint8_t *)&prev, 1); /* write mode config */
1486 if (res != 0) /* check result */
1487 {
1488 handle->debug_print("max30102: write mode config failed.\n"); /* write mode config failed */
1489
1490 return 1; /* return error */
1491 }
1492
1493 return 0; /* success return 0 */
1494}
1495
1508{
1509 uint8_t res;
1510 uint8_t prev;
1511
1512 if (handle == NULL) /* check handle */
1513 {
1514 return 2; /* return error */
1515 }
1516 if (handle->inited != 1) /* check handle initialization */
1517 {
1518 return 3; /* return error */
1519 }
1520
1521 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_MODE_CONFIG, (uint8_t *)&prev, 1); /* read mode config */
1522 if (res != 0) /* check result */
1523 {
1524 handle->debug_print("max30102: read mode config failed.\n"); /* read mode config failed */
1525
1526 return 1; /* return error */
1527 }
1528 prev &= ~(7 << 0); /* clear config */
1529 prev |= mode << 0; /* set mode */
1530 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_MODE_CONFIG, (uint8_t *)&prev, 1); /* write mode config */
1531 if (res != 0) /* check result */
1532 {
1533 handle->debug_print("max30102: write mode config failed.\n"); /* write mode config failed */
1534
1535 return 1; /* return error */
1536 }
1537
1538 return 0; /* success return 0 */
1539}
1540
1553{
1554 uint8_t res;
1555 uint8_t prev;
1556
1557 if (handle == NULL) /* check handle */
1558 {
1559 return 2; /* return error */
1560 }
1561 if (handle->inited != 1) /* check handle initialization */
1562 {
1563 return 3; /* return error */
1564 }
1565
1566 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_MODE_CONFIG, (uint8_t *)&prev, 1); /* read mode config */
1567 if (res != 0) /* check result */
1568 {
1569 handle->debug_print("max30102: read mode config failed.\n"); /* read mode config failed */
1570
1571 return 1; /* return error */
1572 }
1573 *mode = (max30102_mode_t)(prev & 0x7); /* get mode */
1574
1575 return 0; /* success return 0 */
1576}
1577
1590{
1591 uint8_t res;
1592 uint8_t prev;
1593
1594 if (handle == NULL) /* check handle */
1595 {
1596 return 2; /* return error */
1597 }
1598 if (handle->inited != 1) /* check handle initialization */
1599 {
1600 return 3; /* return error */
1601 }
1602
1603 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_SPO2_CONFIG, (uint8_t *)&prev, 1); /* read spo2 config */
1604 if (res != 0) /* check result */
1605 {
1606 handle->debug_print("max30102: read spo2 config failed.\n"); /* read spo2 config failed */
1607
1608 return 1; /* return error */
1609 }
1610 prev &= ~(3 << 5); /* clear config */
1611 prev |= range << 5; /* set range */
1612 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_SPO2_CONFIG, (uint8_t *)&prev, 1); /* write spo2 config */
1613 if (res != 0) /* check result */
1614 {
1615 handle->debug_print("max30102: write spo2 config failed.\n"); /* write spo2 config failed */
1616
1617 return 1; /* return error */
1618 }
1619
1620 return 0; /* success return 0 */
1621}
1622
1635{
1636 uint8_t res;
1637 uint8_t prev;
1638
1639 if (handle == NULL) /* check handle */
1640 {
1641 return 2; /* return error */
1642 }
1643 if (handle->inited != 1) /* check handle initialization */
1644 {
1645 return 3; /* return error */
1646 }
1647
1648 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_SPO2_CONFIG, (uint8_t *)&prev, 1); /* read spo2 config */
1649 if (res != 0) /* check result */
1650 {
1651 handle->debug_print("max30102: read spo2 config failed.\n"); /* read spo2 config failed */
1652
1653 return 1; /* return error */
1654 }
1655 *range = (max30102_spo2_adc_range_t)((prev >> 5) & 0x3); /* get range */
1656
1657 return 0; /* success return 0 */
1658}
1659
1672{
1673 uint8_t res;
1674 uint8_t prev;
1675
1676 if (handle == NULL) /* check handle */
1677 {
1678 return 2; /* return error */
1679 }
1680 if (handle->inited != 1) /* check handle initialization */
1681 {
1682 return 3; /* return error */
1683 }
1684
1685 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_SPO2_CONFIG, (uint8_t *)&prev, 1); /* read spo2 config */
1686 if (res != 0) /* check result */
1687 {
1688 handle->debug_print("max30102: read spo2 config failed.\n"); /* read spo2 config failed */
1689
1690 return 1; /* return error */
1691 }
1692 prev &= ~(7 << 2); /* clear config */
1693 prev |= rate << 2; /* set sample rate */
1694 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_SPO2_CONFIG, (uint8_t *)&prev, 1); /* write spo2 config */
1695 if (res != 0) /* check result */
1696 {
1697 handle->debug_print("max30102: write spo2 config failed.\n"); /* write spo2 config failed */
1698
1699 return 1; /* return error */
1700 }
1701
1702 return 0; /* success return 0 */
1703}
1704
1717{
1718 uint8_t res;
1719 uint8_t prev;
1720
1721 if (handle == NULL) /* check handle */
1722 {
1723 return 2; /* return error */
1724 }
1725 if (handle->inited != 1) /* check handle initialization */
1726 {
1727 return 3; /* return error */
1728 }
1729
1730 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_SPO2_CONFIG, (uint8_t *)&prev, 1); /* read spo2 config */
1731 if (res != 0) /* check result */
1732 {
1733 handle->debug_print("max30102: read spo2 config failed.\n"); /* read spo2 config failed */
1734
1735 return 1; /* return error */
1736 }
1737 *rate = (max30102_spo2_sample_rate_t)((prev >> 2) & 0x7); /* get sample rate */
1738
1739 return 0; /* success return 0 */
1740}
1741
1754{
1755 uint8_t res;
1756 uint8_t prev;
1757
1758 if (handle == NULL) /* check handle */
1759 {
1760 return 2; /* return error */
1761 }
1762 if (handle->inited != 1) /* check handle initialization */
1763 {
1764 return 3; /* return error */
1765 }
1766
1767 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_SPO2_CONFIG, (uint8_t *)&prev, 1); /* read spo2 config */
1768 if (res != 0) /* check result */
1769 {
1770 handle->debug_print("max30102: read spo2 config failed.\n"); /* read spo2 config failed */
1771
1772 return 1; /* return error */
1773 }
1774 prev &= ~(3 << 0); /* clear config */
1775 prev |= resolution << 0; /* set adc resolution */
1776 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_SPO2_CONFIG, (uint8_t *)&prev, 1); /* write spo2 config */
1777 if (res != 0) /* check result */
1778 {
1779 handle->debug_print("max30102: write spo2 config failed.\n"); /* write spo2 config failed */
1780
1781 return 1; /* return error */
1782 }
1783
1784 return 0; /* success return 0 */
1785}
1786
1799{
1800 uint8_t res;
1801 uint8_t prev;
1802
1803 if (handle == NULL) /* check handle */
1804 {
1805 return 2; /* return error */
1806 }
1807 if (handle->inited != 1) /* check handle initialization */
1808 {
1809 return 3; /* return error */
1810 }
1811
1812 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_SPO2_CONFIG, (uint8_t *)&prev, 1); /* read spo2 config */
1813 if (res != 0) /* check result */
1814 {
1815 handle->debug_print("max30102: read spo2 config failed.\n"); /* read spo2 config failed */
1816
1817 return 1; /* return error */
1818 }
1819 *resolution = (max30102_adc_resolution_t)((prev >> 0) & 0x3); /* set adc resolution */
1820
1821 return 0; /* success return 0 */
1822}
1823
1836{
1837 uint8_t res;
1838
1839 if (handle == NULL) /* check handle */
1840 {
1841 return 2; /* return error */
1842 }
1843 if (handle->inited != 1) /* check handle initialization */
1844 {
1845 return 3; /* return error */
1846 }
1847
1848 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_LED_PULSE_1, (uint8_t *)&amp, 1); /* write led pulse 1 */
1849 if (res != 0) /* check result */
1850 {
1851 handle->debug_print("max30102: write led pulse 1 failed.\n"); /* write led pulse 1 failed */
1852
1853 return 1; /* return error */
1854 }
1855
1856 return 0; /* success return 0 */
1857}
1858
1871{
1872 uint8_t res;
1873
1874 if (handle == NULL) /* check handle */
1875 {
1876 return 2; /* return error */
1877 }
1878 if (handle->inited != 1) /* check handle initialization */
1879 {
1880 return 3; /* return error */
1881 }
1882
1883 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_LED_PULSE_1, (uint8_t *)amp, 1); /* read led pulse 1 */
1884 if (res != 0) /* check result */
1885 {
1886 handle->debug_print("max30102: read led pulse 1 failed.\n"); /* read led pulse 1 failed */
1887
1888 return 1; /* return error */
1889 }
1890
1891 return 0; /* success return 0 */
1892}
1893
1906{
1907 uint8_t res;
1908
1909 if (handle == NULL) /* check handle */
1910 {
1911 return 2; /* return error */
1912 }
1913 if (handle->inited != 1) /* check handle initialization */
1914 {
1915 return 3; /* return error */
1916 }
1917
1918 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_LED_PULSE_2, (uint8_t *)&amp, 1); /* write led pulse 2 */
1919 if (res != 0) /* check result */
1920 {
1921 handle->debug_print("max30102: write led pulse 2 failed.\n"); /* write led pulse 2 failed */
1922
1923 return 1; /* return error */
1924 }
1925
1926 return 0; /* success return 0 */
1927}
1928
1941{
1942 uint8_t res;
1943
1944 if (handle == NULL) /* check handle */
1945 {
1946 return 2; /* return error */
1947 }
1948 if (handle->inited != 1) /* check handle initialization */
1949 {
1950 return 3; /* return error */
1951 }
1952
1953 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_LED_PULSE_2, (uint8_t *)amp, 1); /* read led pulse 2 */
1954 if (res != 0) /* check result */
1955 {
1956 handle->debug_print("max30102: read led pulse 2 failed.\n"); /* read led pulse 2 failed */
1957
1958 return 1; /* return error */
1959 }
1960
1961 return 0; /* success return 0 */
1962}
1963
1977{
1978 uint8_t res;
1979 uint8_t prev;
1980
1981 if (handle == NULL) /* check handle */
1982 {
1983 return 2; /* return error */
1984 }
1985 if (handle->inited != 1) /* check handle initialization */
1986 {
1987 return 3; /* return error */
1988 }
1989
1990 if (slot == MAX30102_SLOT_1) /* slot 1 */
1991 {
1992 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_MULTI_LED_MODE_CONTROL_1, (uint8_t *)&prev, 1); /* read led slot */
1993 if (res != 0) /* check result */
1994 {
1995 handle->debug_print("max30102: read led slot failed.\n"); /* read led slot failed */
1996
1997 return 1; /* return error */
1998 }
1999 prev &= ~(0x7 << 0); /* clear config */
2000 prev |= led << 0; /* set led */
2001 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_MULTI_LED_MODE_CONTROL_1, (uint8_t *)&prev, 1); /* write led slot */
2002 if (res != 0) /* check result */
2003 {
2004 handle->debug_print("max30102: write led slot failed.\n"); /* write led slot failed */
2005
2006 return 1; /* return error */
2007 }
2008
2009 return 0; /* success return 0 */
2010 }
2011 else if (slot == MAX30102_SLOT_2) /* slot 2 */
2012 {
2013 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_MULTI_LED_MODE_CONTROL_1, (uint8_t *)&prev, 1); /* read led slot */
2014 if (res != 0) /* check result */
2015 {
2016 handle->debug_print("max30102: read led slot failed.\n"); /* read led slot failed */
2017
2018 return 1; /* return error */
2019 }
2020 prev &= ~(0x7 << 4); /* clear config */
2021 prev |= led << 4; /* set led */
2022 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_MULTI_LED_MODE_CONTROL_1, (uint8_t *)&prev, 1); /* write led slot */
2023 if (res != 0) /* check result */
2024 {
2025 handle->debug_print("max30102: write led slot failed.\n"); /* write led slot failed */
2026
2027 return 1; /* return error */
2028 }
2029
2030 return 0; /* success return 0 */
2031 }
2032 else if (slot == MAX30102_SLOT_3) /* slot 3 */
2033 {
2034 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_MULTI_LED_MODE_CONTROL_2, (uint8_t *)&prev, 1); /* read led slot */
2035 if (res != 0) /* check result */
2036 {
2037 handle->debug_print("max30102: read led slot failed.\n"); /* read led slot failed */
2038
2039 return 1; /* return error */
2040 }
2041 prev &= ~(0x7 << 0); /* clear config */
2042 prev |= led << 0; /* set led */
2043 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_MULTI_LED_MODE_CONTROL_2, (uint8_t *)&prev, 1); /* write led slot */
2044 if (res != 0) /* check result */
2045 {
2046 handle->debug_print("max30102: write led slot failed.\n"); /* write led slot failed */
2047
2048 return 1; /* return error */
2049 }
2050
2051 return 0; /* success return 0 */
2052 }
2053 else if (slot == MAX30102_SLOT_4) /* slot 4 */
2054 {
2055 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_MULTI_LED_MODE_CONTROL_2, (uint8_t *)&prev, 1); /* read led slot */
2056 if (res != 0) /* check result */
2057 {
2058 handle->debug_print("max30102: read led slot failed.\n"); /* read led slot failed */
2059
2060 return 1; /* return error */
2061 }
2062 prev &= ~(0x7 << 4); /* clear config */
2063 prev |= led << 4; /* set led */
2064 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_MULTI_LED_MODE_CONTROL_2, (uint8_t *)&prev, 1); /* write led slot */
2065 if (res != 0) /* check result */
2066 {
2067 handle->debug_print("max30102: write led slot failed.\n"); /* write led slot failed */
2068
2069 return 1; /* return error */
2070 }
2071
2072 return 0; /* success return 0 */
2073 }
2074 else /* unknown */
2075 {
2076 handle->debug_print("max30102: slot is invalid.\n"); /* slot is invalid */
2077
2078 return 1; /* return error */
2079 }
2080}
2081
2095{
2096 uint8_t res;
2097 uint8_t prev;
2098
2099 if (handle == NULL) /* check handle */
2100 {
2101 return 2; /* return error */
2102 }
2103 if (handle->inited != 1) /* check handle initialization */
2104 {
2105 return 3; /* return error */
2106 }
2107
2108 if (slot == MAX30102_SLOT_1) /* slot 1 */
2109 {
2110 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_MULTI_LED_MODE_CONTROL_1, (uint8_t *)&prev, 1); /* read led slot */
2111 if (res != 0) /* check result */
2112 {
2113 handle->debug_print("max30102: read led slot failed.\n"); /* read led slot failed */
2114
2115 return 1; /* return error */
2116 }
2117 *led = (max30102_led_t)((prev >> 0) & 0x7); /* get led */
2118
2119 return 0; /* success return 0 */
2120 }
2121 else if (slot == MAX30102_SLOT_2) /* slot 2 */
2122 {
2123 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_MULTI_LED_MODE_CONTROL_1, (uint8_t *)&prev, 1); /* read led slot */
2124 if (res != 0) /* check result */
2125 {
2126 handle->debug_print("max30102: read led slot failed.\n"); /* read led slot failed */
2127
2128 return 1; /* return error */
2129 }
2130 *led = (max30102_led_t)((prev >> 4) & 0x7); /* get led */
2131
2132 return 0; /* success return 0 */
2133 }
2134 else if (slot == MAX30102_SLOT_3) /* slot 3 */
2135 {
2136 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_MULTI_LED_MODE_CONTROL_2, (uint8_t *)&prev, 1); /* read led slot */
2137 if (res != 0) /* check result */
2138 {
2139 handle->debug_print("max30102: read led slot failed.\n"); /* read led slot failed */
2140
2141 return 1; /* return error */
2142 }
2143 *led = (max30102_led_t)((prev >> 0) & 0x7); /* get led */
2144
2145 return 0; /* success return 0 */
2146 }
2147 else if (slot == MAX30102_SLOT_4) /* slot 4 */
2148 {
2149 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_MULTI_LED_MODE_CONTROL_2, (uint8_t *)&prev, 1); /* read led slot */
2150 if (res != 0) /* check result */
2151 {
2152 handle->debug_print("max30102: read led slot failed.\n"); /* read led slot failed */
2153
2154 return 1; /* return error */
2155 }
2156 *led = (max30102_led_t)((prev >> 4) & 0x7); /* get led */
2157
2158 return 0; /* success return 0 */
2159 }
2160 else /* unknown */
2161 {
2162 handle->debug_print("max30102: slot is invalid.\n"); /* slot is invalid */
2163
2164 return 1; /* return error */
2165 }
2166}
2167
2180{
2181 uint8_t res;
2182 uint8_t prev;
2183
2184 if (handle == NULL) /* check handle */
2185 {
2186 return 2; /* return error */
2187 }
2188 if (handle->inited != 1) /* check handle initialization */
2189 {
2190 return 3; /* return error */
2191 }
2192
2193 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_DIE_TEMP_CONFIG, (uint8_t *)&prev, 1); /* read die temp config */
2194 if (res != 0) /* check result */
2195 {
2196 handle->debug_print("max30102: read die temp config failed.\n"); /* read die temp config failed */
2197
2198 return 1; /* return error */
2199 }
2200 prev &= ~(1 << 0); /* clear config */
2201 prev |= (enable << 0); /* set bool */
2202 res = handle->iic_write(MAX30102_ADDRESS, MAX30102_REG_DIE_TEMP_CONFIG, (uint8_t *)&prev, 1); /* write die temp config */
2203 if (res != 0) /* check result */
2204 {
2205 handle->debug_print("max30102: write die temp config failed.\n"); /* write die temp config failed */
2206
2207 return 1; /* return error */
2208 }
2209
2210 return 0; /* success return 0 */
2211}
2212
2225{
2226 uint8_t res;
2227 uint8_t prev;
2228
2229 if (handle == NULL) /* check handle */
2230 {
2231 return 2; /* return error */
2232 }
2233 if (handle->inited != 1) /* check handle initialization */
2234 {
2235 return 3; /* return error */
2236 }
2237
2238 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_DIE_TEMP_CONFIG, (uint8_t *)&prev, 1); /* read die temp config */
2239 if (res != 0) /* check result */
2240 {
2241 handle->debug_print("max30102: read die temp config failed.\n"); /* read die temp config failed */
2242
2243 return 1; /* return error */
2244 }
2245 *enable = (max30102_bool_t)((prev >> 0) & 0x1); /* get bool */
2246
2247 return 0; /* success return 0 */
2248}
2249
2262uint8_t max30102_get_id(max30102_handle_t *handle, uint8_t *revision_id, uint8_t *part_id)
2263{
2264 uint8_t res;
2265
2266 if (handle == NULL) /* check handle */
2267 {
2268 return 2; /* return error */
2269 }
2270 if (handle->inited != 1) /* check handle initialization */
2271 {
2272 return 3; /* return error */
2273 }
2274
2275 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_REVISION_ID, (uint8_t *)revision_id, 1); /* read revision id */
2276 if (res != 0) /* check result */
2277 {
2278 handle->debug_print("max30102: read revision id failed.\n"); /* read revision id failed */
2279
2280 return 1; /* return error */
2281 }
2282 res = handle->iic_read(MAX30102_ADDRESS, MAX30102_REG_PART_ID, (uint8_t *)part_id, 1); /* read part id */
2283 if (res != 0) /* check result */
2284 {
2285 handle->debug_print("max30102: read part id failed.\n"); /* read part id failed */
2286
2287 return 1; /* return error */
2288 }
2289
2290 return 0; /* success return 0 */
2291}
2292
2306uint8_t max30102_set_reg(max30102_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
2307{
2308 if (handle == NULL) /* check handle */
2309 {
2310 return 2; /* return error */
2311 }
2312 if (handle->inited != 1) /* check handle initialization */
2313 {
2314 return 3; /* return error */
2315 }
2316
2317 if (handle->iic_write(MAX30102_ADDRESS, reg, buf, len) != 0) /* write data */
2318 {
2319 return 1; /* return error */
2320 }
2321 else
2322 {
2323 return 0; /* success return 0 */
2324 }
2325}
2326
2340uint8_t max30102_get_reg(max30102_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
2341{
2342 if (handle == NULL) /* check handle */
2343 {
2344 return 2; /* return error */
2345 }
2346 if (handle->inited != 1) /* check handle initialization */
2347 {
2348 return 3; /* return error */
2349 }
2350
2351 if (handle->iic_read(MAX30102_ADDRESS, reg, buf, len) != 0) /* read data */
2352 {
2353 return 1; /* return error */
2354 }
2355 else
2356 {
2357 return 0; /* success return 0 */
2358 }
2359}
2360
2370{
2371 if (info == NULL) /* check handle */
2372 {
2373 return 2; /* return error */
2374 }
2375
2376 memset(info, 0, sizeof(max30102_info_t)); /* initialize max30102 info structure */
2377 strncpy(info->chip_name, CHIP_NAME, 32); /* copy chip name */
2378 strncpy(info->manufacturer_name, MANUFACTURER_NAME, 32); /* copy manufacturer name */
2379 strncpy(info->interface, "IIC", 8); /* copy interface name */
2380 info->supply_voltage_min_v = SUPPLY_VOLTAGE_MIN; /* set minimal supply voltage */
2381 info->supply_voltage_max_v = SUPPLY_VOLTAGE_MAX; /* set maximum supply voltage */
2382 info->max_current_ma = MAX_CURRENT; /* set maximum current */
2383 info->temperature_max = TEMPERATURE_MAX; /* set minimal temperature */
2384 info->temperature_min = TEMPERATURE_MIN; /* set maximum temperature */
2385 info->driver_version = DRIVER_VERSION; /* set driver version */
2386
2387 return 0; /* success return 0 */
2388}
#define MAX_CURRENT
#define MAX30102_REG_LED_PULSE_1
#define MAX30102_REG_INTERRUPT_STATUS_1
chip register definition
#define MAX30102_REG_DIE_TEMP_CONFIG
#define MAX30102_REG_REVISION_ID
#define MAX30102_REG_MODE_CONFIG
#define SUPPLY_VOLTAGE_MAX
#define MAX30102_REG_INTERRUPT_ENABLE_2
#define MAX30102_REG_PART_ID
#define MAX30102_REG_DIE_TEMP_INTEGER
#define MAX30102_REG_MULTI_LED_MODE_CONTROL_2
#define TEMPERATURE_MAX
#define MAX30102_REG_SPO2_CONFIG
#define MAX30102_REG_MULTI_LED_MODE_CONTROL_1
#define MAX30102_REG_LED_PULSE_2
#define MAX30102_REG_FIFO_READ_POINTER
#define MANUFACTURER_NAME
#define TEMPERATURE_MIN
#define SUPPLY_VOLTAGE_MIN
#define MAX30102_REG_OVERFLOW_COUNTER
#define MAX30102_REG_FIFO_CONFIG
#define MAX30102_REG_INTERRUPT_STATUS_2
#define MAX30102_REG_FIFO_WRITE_POINTER
#define MAX30102_REG_DIE_TEMP_FRACTION
#define MAX30102_REG_FIFO_DATA_REGISTER
#define MAX30102_ADDRESS
iic address definition
#define CHIP_NAME
chip information definition
#define DRIVER_VERSION
#define MAX30102_REG_INTERRUPT_ENABLE_1
driver max30102 header file
uint8_t max30102_set_slot(max30102_handle_t *handle, max30102_slot_t slot, max30102_led_t led)
set the led slot
uint8_t max30102_get_slot(max30102_handle_t *handle, max30102_slot_t slot, max30102_led_t *led)
get the led slot
uint8_t max30102_set_fifo_read_pointer(max30102_handle_t *handle, uint8_t pointer)
set the fifo read pointer
max30102_slot_t
max30102 slot enumeration definition
uint8_t max30102_set_die_temperature(max30102_handle_t *handle, max30102_bool_t enable)
enable or disable die temperature
max30102_bool_t
max30102 bool enumeration definition
uint8_t max30102_get_fifo_write_pointer(max30102_handle_t *handle, uint8_t *pointer)
get the fifo write pointer
uint8_t max30102_set_fifo_roll(max30102_handle_t *handle, max30102_bool_t enable)
enable or disable the fifo roll
uint8_t max30102_get_interrupt(max30102_handle_t *handle, max30102_interrupt_t type, max30102_bool_t *enable)
get the interrupt bool
uint8_t max30102_reset(max30102_handle_t *handle)
reset the chip
uint8_t max30102_get_mode(max30102_handle_t *handle, max30102_mode_t *mode)
get the mode
uint8_t max30102_get_fifo_roll(max30102_handle_t *handle, max30102_bool_t *enable)
get the fifo roll status
uint8_t max30102_get_fifo_data(max30102_handle_t *handle, uint8_t *data)
get the fifo data
uint8_t max30102_get_interrupt_status(max30102_handle_t *handle, max30102_interrupt_status_t status, max30102_bool_t *enable)
get the interrupt status
uint8_t max30102_set_fifo_almost_full(max30102_handle_t *handle, uint8_t value)
set the fifo almost full value
uint8_t max30102_get_led_red_pulse_amplitude(max30102_handle_t *handle, uint8_t *amp)
get the red led pulse amplitude
uint8_t max30102_info(max30102_info_t *info)
get chip's information
uint8_t max30102_set_fifo_sample_averaging(max30102_handle_t *handle, max30102_sample_averaging_t sample)
set the fifo sample averaging
uint8_t max30102_read_temperature(max30102_handle_t *handle, uint16_t *raw, float *temp)
read the temperature
uint8_t max30102_set_led_red_pulse_amplitude(max30102_handle_t *handle, uint8_t amp)
set the red led pulse amplitude
uint8_t max30102_get_fifo_sample_averaging(max30102_handle_t *handle, max30102_sample_averaging_t *sample)
get the fifo sample averaging
uint8_t max30102_set_mode(max30102_handle_t *handle, max30102_mode_t mode)
set the mode
uint8_t max30102_get_spo2_adc_range(max30102_handle_t *handle, max30102_spo2_adc_range_t *range)
get the spo2 adc range
uint8_t max30102_set_shutdown(max30102_handle_t *handle, max30102_bool_t enable)
set the shutdown
uint8_t max30102_read(max30102_handle_t *handle, uint32_t *raw_red, uint32_t *raw_ir, uint8_t *len)
read the data
uint8_t max30102_get_led_ir_pulse_amplitude(max30102_handle_t *handle, uint8_t *amp)
get the ir led pulse amplitude
uint8_t max30102_deinit(max30102_handle_t *handle)
close the chip
uint8_t max30102_set_spo2_adc_range(max30102_handle_t *handle, max30102_spo2_adc_range_t range)
set the spo2 adc range
uint8_t max30102_get_fifo_read_pointer(max30102_handle_t *handle, uint8_t *pointer)
get the fifo read pointer
max30102_spo2_adc_range_t
max30102 spo2 adc range enumeration definition
uint8_t max30102_set_spo2_sample_rate(max30102_handle_t *handle, max30102_spo2_sample_rate_t rate)
set the spo2 sample rate
uint8_t max30102_get_fifo_overflow_counter(max30102_handle_t *handle, uint8_t *counter)
get the fifo overflow counter
max30102_interrupt_t
max30102 interrupt enumeration definition
uint8_t max30102_set_interrupt(max30102_handle_t *handle, max30102_interrupt_t type, max30102_bool_t enable)
set the interrupt bool
uint8_t max30102_get_die_temperature(max30102_handle_t *handle, max30102_bool_t *enable)
get the die temperature status
uint8_t max30102_set_led_ir_pulse_amplitude(max30102_handle_t *handle, uint8_t amp)
set the ir led pulse amplitude
uint8_t max30102_get_id(max30102_handle_t *handle, uint8_t *revision_id, uint8_t *part_id)
get the chip id
struct max30102_info_s max30102_info_t
max30102 information structure definition
uint8_t max30102_init(max30102_handle_t *handle)
initialize the chip
max30102_spo2_sample_rate_t
max30102 spo2 sample rate enumeration definition
uint8_t max30102_set_fifo_data(max30102_handle_t *handle, uint8_t data)
set the fifo data
uint8_t max30102_get_spo2_sample_rate(max30102_handle_t *handle, max30102_spo2_sample_rate_t *rate)
get the spo2 sample rate
max30102_sample_averaging_t
max30102 sample averaging enumeration definition
struct max30102_handle_s max30102_handle_t
max30102 handle structure definition
uint8_t max30102_irq_handler(max30102_handle_t *handle)
irq handler
uint8_t max30102_set_adc_resolution(max30102_handle_t *handle, max30102_adc_resolution_t resolution)
set the adc resolution
uint8_t max30102_get_fifo_almost_full(max30102_handle_t *handle, uint8_t *value)
get the fifo almost full value
max30102_interrupt_status_t
max30102 interrupt status enumeration definition
uint8_t max30102_set_fifo_write_pointer(max30102_handle_t *handle, uint8_t pointer)
set the fifo write pointer
uint8_t max30102_set_fifo_overflow_counter(max30102_handle_t *handle, uint8_t counter)
set the fifo overflow counter
max30102_led_t
max30102 led enumeration definition
max30102_adc_resolution_t
max30102 adc resolution enumeration definition
uint8_t max30102_get_adc_resolution(max30102_handle_t *handle, max30102_adc_resolution_t *resolution)
get the adc resolution
max30102_mode_t
max30102 mode enumeration definition
uint8_t max30102_get_shutdown(max30102_handle_t *handle, max30102_bool_t *enable)
get the shutdown
@ MAX30102_SLOT_1
@ MAX30102_SLOT_4
@ MAX30102_SLOT_2
@ MAX30102_SLOT_3
@ MAX30102_INTERRUPT_DIE_TEMP_RDY_EN
@ MAX30102_INTERRUPT_STATUS_FIFO_FULL
@ MAX30102_INTERRUPT_STATUS_ALC_OVF
@ MAX30102_INTERRUPT_STATUS_DIE_TEMP_RDY
@ MAX30102_INTERRUPT_STATUS_PPG_RDY
@ MAX30102_INTERRUPT_STATUS_PWR_RDY
@ MAX30102_MODE_HEART_RATE
@ MAX30102_MODE_SPO2
@ MAX30102_MODE_MULTI_LED
uint8_t max30102_set_reg(max30102_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
uint8_t max30102_get_reg(max30102_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
void(* delay_ms)(uint32_t ms)
void(* receive_callback)(uint8_t type)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
char manufacturer_name[32]