SpO2 algorithm used in MAX30101 onboard MAX32620HSP. Algorithm is not perfect but it works
Dependencies: mbed MAX14720 USBDevice
MAX30102/MAX30102.h@0:af4d13000e95, 2019-03-28 (annotated)
- Committer:
- douqan93
- Date:
- Thu Mar 28 08:07:54 2019 +0000
- Revision:
- 0:af4d13000e95
This program for MAX32620HSP's onboard SpO2 sensor (MAX30101). Algorithm is not perfect but it works.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| douqan93 | 0:af4d13000e95 | 1 | /** \file max30102.h ****************************************************** |
| douqan93 | 0:af4d13000e95 | 2 | * |
| douqan93 | 0:af4d13000e95 | 3 | * Project: MAXREFDES117# |
| douqan93 | 0:af4d13000e95 | 4 | * Filename: max30102.h |
| douqan93 | 0:af4d13000e95 | 5 | * Description: This module is an embedded controller driver header file for MAX30102 |
| douqan93 | 0:af4d13000e95 | 6 | * |
| douqan93 | 0:af4d13000e95 | 7 | * |
| douqan93 | 0:af4d13000e95 | 8 | * -------------------------------------------------------------------- |
| douqan93 | 0:af4d13000e95 | 9 | * |
| douqan93 | 0:af4d13000e95 | 10 | * This code follows the following naming conventions: |
| douqan93 | 0:af4d13000e95 | 11 | * |
| douqan93 | 0:af4d13000e95 | 12 | * char ch_pmod_value |
| douqan93 | 0:af4d13000e95 | 13 | * char (array) s_pmod_s_string[16] |
| douqan93 | 0:af4d13000e95 | 14 | * float f_pmod_value |
| douqan93 | 0:af4d13000e95 | 15 | * int32_t n_pmod_value |
| douqan93 | 0:af4d13000e95 | 16 | * int32_t (array) an_pmod_value[16] |
| douqan93 | 0:af4d13000e95 | 17 | * int16_t w_pmod_value |
| douqan93 | 0:af4d13000e95 | 18 | * int16_t (array) aw_pmod_value[16] |
| douqan93 | 0:af4d13000e95 | 19 | * uint16_t uw_pmod_value |
| douqan93 | 0:af4d13000e95 | 20 | * uint16_t (array) auw_pmod_value[16] |
| douqan93 | 0:af4d13000e95 | 21 | * uint8_t uch_pmod_value |
| douqan93 | 0:af4d13000e95 | 22 | * uint8_t (array) auch_pmod_buffer[16] |
| douqan93 | 0:af4d13000e95 | 23 | * uint32_t un_pmod_value |
| douqan93 | 0:af4d13000e95 | 24 | * int32_t * pn_pmod_value |
| douqan93 | 0:af4d13000e95 | 25 | * |
| douqan93 | 0:af4d13000e95 | 26 | * ------------------------------------------------------------------------- */ |
| douqan93 | 0:af4d13000e95 | 27 | /******************************************************************************* |
| douqan93 | 0:af4d13000e95 | 28 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
| douqan93 | 0:af4d13000e95 | 29 | * |
| douqan93 | 0:af4d13000e95 | 30 | * Permission is hereby granted, free of charge, to any person obtaining a |
| douqan93 | 0:af4d13000e95 | 31 | * copy of this software and associated documentation files (the "Software"), |
| douqan93 | 0:af4d13000e95 | 32 | * to deal in the Software without restriction, including without limitation |
| douqan93 | 0:af4d13000e95 | 33 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| douqan93 | 0:af4d13000e95 | 34 | * and/or sell copies of the Software, and to permit persons to whom the |
| douqan93 | 0:af4d13000e95 | 35 | * Software is furnished to do so, subject to the following conditions: |
| douqan93 | 0:af4d13000e95 | 36 | * |
| douqan93 | 0:af4d13000e95 | 37 | * The above copyright notice and this permission notice shall be included |
| douqan93 | 0:af4d13000e95 | 38 | * in all copies or substantial portions of the Software. |
| douqan93 | 0:af4d13000e95 | 39 | * |
| douqan93 | 0:af4d13000e95 | 40 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| douqan93 | 0:af4d13000e95 | 41 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| douqan93 | 0:af4d13000e95 | 42 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| douqan93 | 0:af4d13000e95 | 43 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
| douqan93 | 0:af4d13000e95 | 44 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| douqan93 | 0:af4d13000e95 | 45 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| douqan93 | 0:af4d13000e95 | 46 | * OTHER DEALINGS IN THE SOFTWARE. |
| douqan93 | 0:af4d13000e95 | 47 | * |
| douqan93 | 0:af4d13000e95 | 48 | * Except as contained in this notice, the name of Maxim Integrated |
| douqan93 | 0:af4d13000e95 | 49 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
| douqan93 | 0:af4d13000e95 | 50 | * Products, Inc. Branding Policy. |
| douqan93 | 0:af4d13000e95 | 51 | * |
| douqan93 | 0:af4d13000e95 | 52 | * The mere transfer of this software does not imply any licenses |
| douqan93 | 0:af4d13000e95 | 53 | * of trade secrets, proprietary technology, copyrights, patents, |
| douqan93 | 0:af4d13000e95 | 54 | * trademarks, maskwork rights, or any other form of intellectual |
| douqan93 | 0:af4d13000e95 | 55 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
| douqan93 | 0:af4d13000e95 | 56 | * ownership rights. |
| douqan93 | 0:af4d13000e95 | 57 | ******************************************************************************* |
| douqan93 | 0:af4d13000e95 | 58 | */ |
| douqan93 | 0:af4d13000e95 | 59 | #ifndef MAX30102_H_ |
| douqan93 | 0:af4d13000e95 | 60 | #define MAX30102_H_ |
| douqan93 | 0:af4d13000e95 | 61 | |
| douqan93 | 0:af4d13000e95 | 62 | #include "mbed.h" |
| douqan93 | 0:af4d13000e95 | 63 | |
| douqan93 | 0:af4d13000e95 | 64 | #define I2C_WRITE_ADDR 0xAE |
| douqan93 | 0:af4d13000e95 | 65 | #define I2C_READ_ADDR 0xAF |
| douqan93 | 0:af4d13000e95 | 66 | |
| douqan93 | 0:af4d13000e95 | 67 | //register addresses |
| douqan93 | 0:af4d13000e95 | 68 | #define REG_INTR_STATUS_1 0x00 |
| douqan93 | 0:af4d13000e95 | 69 | #define REG_INTR_STATUS_2 0x01 |
| douqan93 | 0:af4d13000e95 | 70 | #define REG_INTR_ENABLE_1 0x02 |
| douqan93 | 0:af4d13000e95 | 71 | #define REG_INTR_ENABLE_2 0x03 |
| douqan93 | 0:af4d13000e95 | 72 | #define REG_FIFO_WR_PTR 0x04 |
| douqan93 | 0:af4d13000e95 | 73 | #define REG_OVF_COUNTER 0x05 |
| douqan93 | 0:af4d13000e95 | 74 | #define REG_FIFO_RD_PTR 0x06 |
| douqan93 | 0:af4d13000e95 | 75 | #define REG_FIFO_DATA 0x07 |
| douqan93 | 0:af4d13000e95 | 76 | #define REG_FIFO_CONFIG 0x08 |
| douqan93 | 0:af4d13000e95 | 77 | #define REG_MODE_CONFIG 0x09 |
| douqan93 | 0:af4d13000e95 | 78 | #define REG_SPO2_CONFIG 0x0A |
| douqan93 | 0:af4d13000e95 | 79 | #define REG_LED1_PA 0x0C |
| douqan93 | 0:af4d13000e95 | 80 | #define REG_LED2_PA 0x0D |
| douqan93 | 0:af4d13000e95 | 81 | #define REG_PILOT_PA 0x10 |
| douqan93 | 0:af4d13000e95 | 82 | #define REG_MULTI_LED_CTRL1 0x11 |
| douqan93 | 0:af4d13000e95 | 83 | #define REG_MULTI_LED_CTRL2 0x12 |
| douqan93 | 0:af4d13000e95 | 84 | #define REG_TEMP_INTR 0x1F |
| douqan93 | 0:af4d13000e95 | 85 | #define REG_TEMP_FRAC 0x20 |
| douqan93 | 0:af4d13000e95 | 86 | #define REG_TEMP_CONFIG 0x21 |
| douqan93 | 0:af4d13000e95 | 87 | #define REG_PROX_INT_THRESH 0x30 |
| douqan93 | 0:af4d13000e95 | 88 | #define REG_REV_ID 0xFE |
| douqan93 | 0:af4d13000e95 | 89 | #define REG_PART_ID 0xFF |
| douqan93 | 0:af4d13000e95 | 90 | |
| douqan93 | 0:af4d13000e95 | 91 | bool maxim_max30102_init(); |
| douqan93 | 0:af4d13000e95 | 92 | bool maxim_max30102_soft_init(); |
| douqan93 | 0:af4d13000e95 | 93 | bool maxim_max30102_read_fifo(uint32_t *pun_red_led, uint32_t *pun_ir_led); |
| douqan93 | 0:af4d13000e95 | 94 | bool maxim_max30102_write_reg(uint8_t uch_addr, uint8_t uch_data); |
| douqan93 | 0:af4d13000e95 | 95 | bool maxim_max30102_read_reg(uint8_t uch_addr, uint8_t *puch_data); |
| douqan93 | 0:af4d13000e95 | 96 | bool maxim_max30102_reset(void); |
| douqan93 | 0:af4d13000e95 | 97 | |
| douqan93 | 0:af4d13000e95 | 98 | #endif /* MAX30102_H_ */ |