Library for MAX3010x optical sensors
MAX30105.h@0:62bc11b5bc43, 2017-02-08 (annotated)
- Committer:
- switches
- Date:
- Wed Feb 08 00:22:28 2017 +0000
- Revision:
- 0:62bc11b5bc43
- Child:
- 1:411eb3796949
Initial commit for review
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
switches | 0:62bc11b5bc43 | 1 | /** \file max30105.h ****************************************************** |
switches | 0:62bc11b5bc43 | 2 | * |
switches | 0:62bc11b5bc43 | 3 | * Project: MAXREFDES117# |
switches | 0:62bc11b5bc43 | 4 | * Filename: max30105.h |
switches | 0:62bc11b5bc43 | 5 | * Description: This module is an embedded controller driver header file for MAX30105 |
switches | 0:62bc11b5bc43 | 6 | * |
switches | 0:62bc11b5bc43 | 7 | * ------------------------------------------------------------------------- */ |
switches | 0:62bc11b5bc43 | 8 | /******************************************************************************* |
switches | 0:62bc11b5bc43 | 9 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
switches | 0:62bc11b5bc43 | 10 | * |
switches | 0:62bc11b5bc43 | 11 | * Permission is hereby granted, free of charge, to any person obtaining a |
switches | 0:62bc11b5bc43 | 12 | * copy of this software and associated documentation files (the "Software"), |
switches | 0:62bc11b5bc43 | 13 | * to deal in the Software without restriction, including without limitation |
switches | 0:62bc11b5bc43 | 14 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
switches | 0:62bc11b5bc43 | 15 | * and/or sell copies of the Software, and to permit persons to whom the |
switches | 0:62bc11b5bc43 | 16 | * Software is furnished to do so, subject to the following conditions: |
switches | 0:62bc11b5bc43 | 17 | * |
switches | 0:62bc11b5bc43 | 18 | * The above copyright notice and this permission notice shall be included |
switches | 0:62bc11b5bc43 | 19 | * in all copies or substantial portions of the Software. |
switches | 0:62bc11b5bc43 | 20 | * |
switches | 0:62bc11b5bc43 | 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
switches | 0:62bc11b5bc43 | 22 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
switches | 0:62bc11b5bc43 | 23 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
switches | 0:62bc11b5bc43 | 24 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
switches | 0:62bc11b5bc43 | 25 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
switches | 0:62bc11b5bc43 | 26 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
switches | 0:62bc11b5bc43 | 27 | * OTHER DEALINGS IN THE SOFTWARE. |
switches | 0:62bc11b5bc43 | 28 | * |
switches | 0:62bc11b5bc43 | 29 | * Except as contained in this notice, the name of Maxim Integrated |
switches | 0:62bc11b5bc43 | 30 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
switches | 0:62bc11b5bc43 | 31 | * Products, Inc. Branding Policy. |
switches | 0:62bc11b5bc43 | 32 | * |
switches | 0:62bc11b5bc43 | 33 | * The mere transfer of this software does not imply any licenses |
switches | 0:62bc11b5bc43 | 34 | * of trade secrets, proprietary technology, copyrights, patents, |
switches | 0:62bc11b5bc43 | 35 | * trademarks, maskwork rights, or any other form of intellectual |
switches | 0:62bc11b5bc43 | 36 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
switches | 0:62bc11b5bc43 | 37 | * ownership rights. |
switches | 0:62bc11b5bc43 | 38 | ******************************************************************************* |
switches | 0:62bc11b5bc43 | 39 | */ |
switches | 0:62bc11b5bc43 | 40 | #ifndef _MAX30105_H_ |
switches | 0:62bc11b5bc43 | 41 | #define _MAX30105_H_ |
switches | 0:62bc11b5bc43 | 42 | |
switches | 0:62bc11b5bc43 | 43 | #include "mbed.h" |
switches | 0:62bc11b5bc43 | 44 | |
switches | 0:62bc11b5bc43 | 45 | #define MAX30105_NO_ERROR 0 |
switches | 0:62bc11b5bc43 | 46 | #define MAX30105_ERROR -1 |
switches | 0:62bc11b5bc43 | 47 | #define MAX30105_TEMP_ERROR -999.0 |
switches | 0:62bc11b5bc43 | 48 | |
switches | 0:62bc11b5bc43 | 49 | #define MAX30105_I2C_ADDR 0xAE |
switches | 0:62bc11b5bc43 | 50 | #define MAX30105_PART_ID 0x15 |
switches | 0:62bc11b5bc43 | 51 | |
switches | 0:62bc11b5bc43 | 52 | #define MAX30105_DEFAULT_LED_PA 0x20 |
switches | 0:62bc11b5bc43 | 53 | #define MAX30105_DEFAULT_PILOT_PA 0x40 |
switches | 0:62bc11b5bc43 | 54 | |
switches | 0:62bc11b5bc43 | 55 | class MAX30105 |
switches | 0:62bc11b5bc43 | 56 | { |
switches | 0:62bc11b5bc43 | 57 | public: |
switches | 0:62bc11b5bc43 | 58 | |
switches | 0:62bc11b5bc43 | 59 | /** |
switches | 0:62bc11b5bc43 | 60 | * @brief Register Addresses |
switches | 0:62bc11b5bc43 | 61 | * @details Enumerated MAX30105 register addresses |
switches | 0:62bc11b5bc43 | 62 | */ |
switches | 0:62bc11b5bc43 | 63 | enum registers_t { |
switches | 0:62bc11b5bc43 | 64 | REG_INTR_STATUS_1 = 0x00, ///< Interrupt Status 1 |
switches | 0:62bc11b5bc43 | 65 | REG_INTR_STATUS_2 = 0x01, ///< Interrupt Status 2 |
switches | 0:62bc11b5bc43 | 66 | REG_INTR_ENABLE_1 = 0x02, ///< Interrupt Enable 1 |
switches | 0:62bc11b5bc43 | 67 | REG_INTR_ENABLE_2 = 0x03, ///< Interrupt Enable 2 |
switches | 0:62bc11b5bc43 | 68 | REG_FIFO_WR_PTR = 0x04, ///< FIFO Write Pointer |
switches | 0:62bc11b5bc43 | 69 | REG_OVF_COUNTER = 0x05, ///< Overflow Counter |
switches | 0:62bc11b5bc43 | 70 | REG_FIFO_RD_PTR = 0x06, ///< FIFO Read Pointer |
switches | 0:62bc11b5bc43 | 71 | REG_FIFO_DATA = 0x07, ///< FIFO Data Register |
switches | 0:62bc11b5bc43 | 72 | REG_FIFO_CONFIG = 0x08, ///< FIFO Configuration |
switches | 0:62bc11b5bc43 | 73 | REG_MODE_CONFIG = 0x09, ///< Mode Configuration |
switches | 0:62bc11b5bc43 | 74 | REG_SPO2_CONFIG = 0x0A, ///< Sensing Configuration |
switches | 0:62bc11b5bc43 | 75 | REG_RSVD_0B = 0x0B, ///< Reserved 0x0B |
switches | 0:62bc11b5bc43 | 76 | REG_LED1_PA = 0x0C, ///< LED1 Pulse Amplitude |
switches | 0:62bc11b5bc43 | 77 | REG_LED2_PA = 0x0D, ///< LED2 Pulse Amplitude |
switches | 0:62bc11b5bc43 | 78 | REG_LED3_PA = 0x0E, ///< LED3 Pulse Amplitude |
switches | 0:62bc11b5bc43 | 79 | REG_RSVD_0F = 0x0F, ///< Reserved 0x0F |
switches | 0:62bc11b5bc43 | 80 | REG_PILOT_PA = 0x10, ///< Proximity Mode LED Pulse Amplitude |
switches | 0:62bc11b5bc43 | 81 | REG_MULTI_LED_CTRL1 = 0x11, ///< LED Slots 1 and 2 |
switches | 0:62bc11b5bc43 | 82 | REG_MULTI_LED_CTRL2 = 0x12, ///< LED Slots 3 and 4 |
switches | 0:62bc11b5bc43 | 83 | REG_TEMP_INT = 0x1F, ///< Die Temperature Ingteger |
switches | 0:62bc11b5bc43 | 84 | REG_TEMP_FRAC = 0x20, ///< Die Temperature Fraction |
switches | 0:62bc11b5bc43 | 85 | REG_TEMP_CONFIG = 0x21, ///< Die Temperature Configuration |
switches | 0:62bc11b5bc43 | 86 | REG_PROX_INTR_THRESH = 0x30, ///< Proximity Interrupt Threshold |
switches | 0:62bc11b5bc43 | 87 | REG_REV_ID = 0xFE, ///< Part Revision |
switches | 0:62bc11b5bc43 | 88 | REG_PART_ID = 0xFF, ///< Part ID Code |
switches | 0:62bc11b5bc43 | 89 | }; |
switches | 0:62bc11b5bc43 | 90 | |
switches | 0:62bc11b5bc43 | 91 | /** |
switches | 0:62bc11b5bc43 | 92 | * @brief Sample Averaging |
switches | 0:62bc11b5bc43 | 93 | * @details Number of samples to be averaged and decimated |
switches | 0:62bc11b5bc43 | 94 | */ |
switches | 0:62bc11b5bc43 | 95 | enum smp_ave_t { |
switches | 0:62bc11b5bc43 | 96 | SMP_AVE_1 = (0 << 5), ///< 1 (no averaging) |
switches | 0:62bc11b5bc43 | 97 | SMP_AVE_2 = (1 << 5), ///< 2 |
switches | 0:62bc11b5bc43 | 98 | SMP_AVE_4 = (2 << 5), ///< 4 |
switches | 0:62bc11b5bc43 | 99 | SMP_AVE_8 = (3 << 5), ///< 8 |
switches | 0:62bc11b5bc43 | 100 | SMP_AVE_16 = (4 << 5), ///< 16 |
switches | 0:62bc11b5bc43 | 101 | SMP_AVE_32 = (5 << 5), ///< 32 |
switches | 0:62bc11b5bc43 | 102 | }; |
switches | 0:62bc11b5bc43 | 103 | |
switches | 0:62bc11b5bc43 | 104 | /** |
switches | 0:62bc11b5bc43 | 105 | * @brief FIFO Almost Full Value |
switches | 0:62bc11b5bc43 | 106 | * @details Number of empty spaces that triggers FIFO_A_FULL interrupt |
switches | 0:62bc11b5bc43 | 107 | */ |
switches | 0:62bc11b5bc43 | 108 | enum fifo_a_full_t { |
switches | 0:62bc11b5bc43 | 109 | FIFO_A_FULL_0 = 0x0, ///< 0 samples remaining, 32 used |
switches | 0:62bc11b5bc43 | 110 | FIFO_A_FULL_1 = 0x1, ///< 1 samples remaining, 31 used |
switches | 0:62bc11b5bc43 | 111 | FIFO_A_FULL_2 = 0x2, ///< 2 samples remaining, 30 used |
switches | 0:62bc11b5bc43 | 112 | FIFO_A_FULL_3 = 0x3, ///< 3 samples remaining, 29 used |
switches | 0:62bc11b5bc43 | 113 | FIFO_A_FULL_4 = 0x4, ///< 4 samples remaining, 28 used |
switches | 0:62bc11b5bc43 | 114 | FIFO_A_FULL_5 = 0x5, ///< 5 samples remaining, 27 used |
switches | 0:62bc11b5bc43 | 115 | FIFO_A_FULL_6 = 0x6, ///< 6 samples remaining, 26 used |
switches | 0:62bc11b5bc43 | 116 | FIFO_A_FULL_7 = 0x7, ///< 7 samples remaining, 25 used |
switches | 0:62bc11b5bc43 | 117 | FIFO_A_FULL_8 = 0x8, ///< 8 samples remaining, 24 used |
switches | 0:62bc11b5bc43 | 118 | FIFO_A_FULL_9 = 0x9, ///< 9 samples remaining, 23 used |
switches | 0:62bc11b5bc43 | 119 | FIFO_A_FULL_A = 0xA, ///< 10 samples remaining, 22 used |
switches | 0:62bc11b5bc43 | 120 | FIFO_A_FULL_B = 0xB, ///< 11 samples remaining, 21 used |
switches | 0:62bc11b5bc43 | 121 | FIFO_A_FULL_C = 0xC, ///< 12 samples remaining, 20 used |
switches | 0:62bc11b5bc43 | 122 | FIFO_A_FULL_D = 0xD, ///< 13 samples remaining, 19 used |
switches | 0:62bc11b5bc43 | 123 | FIFO_A_FULL_E = 0xE, ///< 14 samples remaining, 18 used |
switches | 0:62bc11b5bc43 | 124 | FIFO_A_FULL_F = 0xF, ///< 15 samples remaining, 17 used |
switches | 0:62bc11b5bc43 | 125 | }; |
switches | 0:62bc11b5bc43 | 126 | |
switches | 0:62bc11b5bc43 | 127 | /** |
switches | 0:62bc11b5bc43 | 128 | * @brief Mode Control |
switches | 0:62bc11b5bc43 | 129 | * @details Operating mode |
switches | 0:62bc11b5bc43 | 130 | */ |
switches | 0:62bc11b5bc43 | 131 | enum mode_t { |
switches | 0:62bc11b5bc43 | 132 | MODE_1LED = 0x2, ///< Single Red LED mode |
switches | 0:62bc11b5bc43 | 133 | MODE_2LED = 0x3, ///< Red and IR LED mode |
switches | 0:62bc11b5bc43 | 134 | MODE_MULTI = 0x7, ///< Multi LED mode Red, IR, and/or Green |
switches | 0:62bc11b5bc43 | 135 | }; |
switches | 0:62bc11b5bc43 | 136 | |
switches | 0:62bc11b5bc43 | 137 | /** |
switches | 0:62bc11b5bc43 | 138 | * @brief ADC Range |
switches | 0:62bc11b5bc43 | 139 | * @details Sets the full scale range of the ADC |
switches | 0:62bc11b5bc43 | 140 | */ |
switches | 0:62bc11b5bc43 | 141 | enum adc_rge_t { |
switches | 0:62bc11b5bc43 | 142 | ADC_RGE_00 = (0 << 5), ///< 2048nA full scale, 7.81pA LSB |
switches | 0:62bc11b5bc43 | 143 | ADC_RGE_01 = (1 << 5), ///< 4096nA full scale, 15.63pA LSB |
switches | 0:62bc11b5bc43 | 144 | ADC_RGE_10 = (2 << 5), ///< 8192nA full scale, 31.25pA LSB |
switches | 0:62bc11b5bc43 | 145 | ADC_RGE_11 = (3 << 5), ///< 16384nA full scale, 62.5pA LSB |
switches | 0:62bc11b5bc43 | 146 | }; |
switches | 0:62bc11b5bc43 | 147 | |
switches | 0:62bc11b5bc43 | 148 | /** |
switches | 0:62bc11b5bc43 | 149 | * @brief Sample Rate |
switches | 0:62bc11b5bc43 | 150 | * @details Sets the sample rate of the pulses for each enabled LED |
switches | 0:62bc11b5bc43 | 151 | */ |
switches | 0:62bc11b5bc43 | 152 | enum smp_rt_t { |
switches | 0:62bc11b5bc43 | 153 | SMP_RT_50 = (0 << 2), ///< 50 Samples per second |
switches | 0:62bc11b5bc43 | 154 | SMP_RT_100 = (1 << 2), ///< 100 Samples per second |
switches | 0:62bc11b5bc43 | 155 | SMP_RT_200 = (2 << 2), ///< 200 Samples per second |
switches | 0:62bc11b5bc43 | 156 | SMP_RT_400 = (3 << 2), ///< 400 Samples per second |
switches | 0:62bc11b5bc43 | 157 | SMP_RT_800 = (4 << 2), ///< 800 Samples per second |
switches | 0:62bc11b5bc43 | 158 | SMP_RT_1000 = (5 << 2), ///< 1000 Samples per second |
switches | 0:62bc11b5bc43 | 159 | SMP_RT_1600 = (6 << 2), ///< 1600 Samples per second |
switches | 0:62bc11b5bc43 | 160 | SMP_RT_3200 = (7 << 2), ///< 3200 Samples per second |
switches | 0:62bc11b5bc43 | 161 | }; |
switches | 0:62bc11b5bc43 | 162 | |
switches | 0:62bc11b5bc43 | 163 | /** |
switches | 0:62bc11b5bc43 | 164 | * @brief Pulse Width |
switches | 0:62bc11b5bc43 | 165 | * @details Sets the pulse width for the channel |
switches | 0:62bc11b5bc43 | 166 | */ |
switches | 0:62bc11b5bc43 | 167 | enum led_pw_t { |
switches | 0:62bc11b5bc43 | 168 | LED_PW_15BIT = 0, ///< 69us, 15 bit resolution |
switches | 0:62bc11b5bc43 | 169 | LED_PW_16BIT = 1, ///< 118us, 16 bit resolution |
switches | 0:62bc11b5bc43 | 170 | LED_PW_17BIT = 2, ///< 215us, 17 bit resolution |
switches | 0:62bc11b5bc43 | 171 | LED_PW_18BIT = 3, ///< 411us, 18 bit resolution |
switches | 0:62bc11b5bc43 | 172 | }; |
switches | 0:62bc11b5bc43 | 173 | |
switches | 0:62bc11b5bc43 | 174 | /** |
switches | 0:62bc11b5bc43 | 175 | * @brief Slot Control |
switches | 0:62bc11b5bc43 | 176 | * @details Sets the active LED and pulse amplitude for the slot |
switches | 0:62bc11b5bc43 | 177 | */ |
switches | 0:62bc11b5bc43 | 178 | enum slot_t { |
switches | 0:62bc11b5bc43 | 179 | SLOT_DISABLED = 0, ///< No LED active |
switches | 0:62bc11b5bc43 | 180 | SLOT_RED_LED1 = 1, ///< Red, LED1_PA |
switches | 0:62bc11b5bc43 | 181 | SLOT_IR_LED2 = 2, ///< IR, LED3_PA |
switches | 0:62bc11b5bc43 | 182 | SLOT_GREEN_LED3 = 3, ///< Green, LED3_PA |
switches | 0:62bc11b5bc43 | 183 | SLOT_NONE = 4, ///< No LED active |
switches | 0:62bc11b5bc43 | 184 | SLOT_RED_PILOT = 5, ///< Red, PILOT_PA |
switches | 0:62bc11b5bc43 | 185 | SLOT_IR_PILOT = 6, ///< IR, PILOT_PA |
switches | 0:62bc11b5bc43 | 186 | SLOT_GREEN_PILOT = 7, ///< Green, PILOT_PA |
switches | 0:62bc11b5bc43 | 187 | }; |
switches | 0:62bc11b5bc43 | 188 | |
switches | 0:62bc11b5bc43 | 189 | static const char INTR_A_FULL = (1 <<7); |
switches | 0:62bc11b5bc43 | 190 | static const char INTR_DATA_RDY = (1 <<6); |
switches | 0:62bc11b5bc43 | 191 | static const char INTR_ALC_OVF = (1 <<5); |
switches | 0:62bc11b5bc43 | 192 | static const char INTR_PROX = (1 <<4); |
switches | 0:62bc11b5bc43 | 193 | static const char INTR_PWR_RDY = (1 <<0); |
switches | 0:62bc11b5bc43 | 194 | static const char INTR_TEMP_RDY = (1 <<1); |
switches | 0:62bc11b5bc43 | 195 | |
switches | 0:62bc11b5bc43 | 196 | static const char MASK_SMP_AVE = (7 <<5); |
switches | 0:62bc11b5bc43 | 197 | static const char MASK_FIFO_ROLLOVER_EN = (1 <<4); |
switches | 0:62bc11b5bc43 | 198 | static const char MASK_FIFO_A_FULL = (0xF <<0); |
switches | 0:62bc11b5bc43 | 199 | |
switches | 0:62bc11b5bc43 | 200 | static const char MASK_SHDN = (1 <<7); |
switches | 0:62bc11b5bc43 | 201 | static const char MASK_RESET = (1 <<6); |
switches | 0:62bc11b5bc43 | 202 | static const char MASK_MODE = (7 <<0); |
switches | 0:62bc11b5bc43 | 203 | |
switches | 0:62bc11b5bc43 | 204 | static const char MASK_ADC_RGE = (3 <<5); |
switches | 0:62bc11b5bc43 | 205 | static const char MASK_SMP_RT = (7 <<2); |
switches | 0:62bc11b5bc43 | 206 | static const char MASK_LED_PW = (3 <<0); |
switches | 0:62bc11b5bc43 | 207 | |
switches | 0:62bc11b5bc43 | 208 | static const char MASK_SLOT2 = (7 <<4); |
switches | 0:62bc11b5bc43 | 209 | static const char MASK_SLOT1 = (7 <<0); |
switches | 0:62bc11b5bc43 | 210 | static const char MASK_SLOT4 = (7 <<4); |
switches | 0:62bc11b5bc43 | 211 | static const char MASK_SLOT3 = (7 <<0); |
switches | 0:62bc11b5bc43 | 212 | |
switches | 0:62bc11b5bc43 | 213 | /** |
switches | 0:62bc11b5bc43 | 214 | * MAX30105 constructor. |
switches | 0:62bc11b5bc43 | 215 | * |
switches | 0:62bc11b5bc43 | 216 | * @param i2c I2C object to use. |
switches | 0:62bc11b5bc43 | 217 | */ |
switches | 0:62bc11b5bc43 | 218 | MAX30105(I2C &i2c); |
switches | 0:62bc11b5bc43 | 219 | |
switches | 0:62bc11b5bc43 | 220 | /** |
switches | 0:62bc11b5bc43 | 221 | * MAX30105 destructor. |
switches | 0:62bc11b5bc43 | 222 | */ |
switches | 0:62bc11b5bc43 | 223 | ~MAX30105(); |
switches | 0:62bc11b5bc43 | 224 | |
switches | 0:62bc11b5bc43 | 225 | /** |
switches | 0:62bc11b5bc43 | 226 | * @brief Get Interrupt 1 |
switches | 0:62bc11b5bc43 | 227 | * @details Reads Interrupt 1 |
switches | 0:62bc11b5bc43 | 228 | * @returns contents of REG_INTR_STATUS_1, or -1 if error. |
switches | 0:62bc11b5bc43 | 229 | */ |
switches | 0:62bc11b5bc43 | 230 | int getIntr1(); |
switches | 0:62bc11b5bc43 | 231 | |
switches | 0:62bc11b5bc43 | 232 | /** |
switches | 0:62bc11b5bc43 | 233 | * @brief Get Interrupt 2 |
switches | 0:62bc11b5bc43 | 234 | * @details Reads Temp Interrupt |
switches | 0:62bc11b5bc43 | 235 | * @returns contents of REG_INTR_STATUS_2, or -1 if error. |
switches | 0:62bc11b5bc43 | 236 | */ |
switches | 0:62bc11b5bc43 | 237 | int getIntr2(); |
switches | 0:62bc11b5bc43 | 238 | |
switches | 0:62bc11b5bc43 | 239 | /** |
switches | 0:62bc11b5bc43 | 240 | * @brief Enable Interrupt |
switches | 0:62bc11b5bc43 | 241 | * @details Enables any interrupt whos bit is set |
switches | 0:62bc11b5bc43 | 242 | * @param intrBits bit mask of interrupts to enable |
switches | 0:62bc11b5bc43 | 243 | * @returns 0 if no errors, -1 if error. |
switches | 0:62bc11b5bc43 | 244 | */ |
switches | 0:62bc11b5bc43 | 245 | int enableIntr(char intrBits); |
switches | 0:62bc11b5bc43 | 246 | |
switches | 0:62bc11b5bc43 | 247 | /** |
switches | 0:62bc11b5bc43 | 248 | * @brief Disable Interrupt |
switches | 0:62bc11b5bc43 | 249 | * @details Disables any interrupt whos bit is set |
switches | 0:62bc11b5bc43 | 250 | * @param intrBits bit mask of interrupts to disable |
switches | 0:62bc11b5bc43 | 251 | * @returns 0 if no errors, -1 if error. |
switches | 0:62bc11b5bc43 | 252 | */ |
switches | 0:62bc11b5bc43 | 253 | int disableIntr(char intrBits); |
switches | 0:62bc11b5bc43 | 254 | |
switches | 0:62bc11b5bc43 | 255 | /** |
switches | 0:62bc11b5bc43 | 256 | * @brief Configure Proximity Function |
switches | 0:62bc11b5bc43 | 257 | * @details Sets amplitude and threshold for proximity detector |
switches | 0:62bc11b5bc43 | 258 | * Set threshold to 0x00 to disable proximity detecotr |
switches | 0:62bc11b5bc43 | 259 | * @param proxAmp The amplitude of the proximity pulse 50mA/255 steps |
switches | 0:62bc11b5bc43 | 260 | * @param proxThresh The detect threshold to start sensing |
switches | 0:62bc11b5bc43 | 261 | * @returns 0 if no errors, -1 if error. |
switches | 0:62bc11b5bc43 | 262 | */ |
switches | 0:62bc11b5bc43 | 263 | int setProx(char proxAmp, char proxThresh); |
switches | 0:62bc11b5bc43 | 264 | |
switches | 0:62bc11b5bc43 | 265 | /** |
switches | 0:62bc11b5bc43 | 266 | * @brief Configure Single LED Mode |
switches | 0:62bc11b5bc43 | 267 | * @details Configures part for single LED mode. |
switches | 0:62bc11b5bc43 | 268 | * @param smpAve number of samples to average |
switches | 0:62bc11b5bc43 | 269 | * @param fifoRollOver enables FIFO to roll over when full |
switches | 0:62bc11b5bc43 | 270 | * @param fifoAFull sets FIFO almost full level |
switches | 0:62bc11b5bc43 | 271 | * @param adcRange sets ADC range |
switches | 0:62bc11b5bc43 | 272 | * @param smpRate sets sample rate |
switches | 0:62bc11b5bc43 | 273 | * @param ledPW sets LED pulse width |
switches | 0:62bc11b5bc43 | 274 | * @param led1PA sets pulse amplitude for LED1 |
switches | 0:62bc11b5bc43 | 275 | * @returns 0 if no errors, -1 if error. |
switches | 0:62bc11b5bc43 | 276 | */ |
switches | 0:62bc11b5bc43 | 277 | int setSingleLED(smp_ave_t smpAve = SMP_AVE_1, |
switches | 0:62bc11b5bc43 | 278 | bool fifoRollOver = false, |
switches | 0:62bc11b5bc43 | 279 | fifo_a_full_t fifoAFull = FIFO_A_FULL_F, |
switches | 0:62bc11b5bc43 | 280 | adc_rge_t adcRange = ADC_RGE_01, |
switches | 0:62bc11b5bc43 | 281 | smp_rt_t smpRate = SMP_RT_100, |
switches | 0:62bc11b5bc43 | 282 | led_pw_t ledPW = LED_PW_18BIT, |
switches | 0:62bc11b5bc43 | 283 | char led1PA = MAX30105_DEFAULT_LED_PA); |
switches | 0:62bc11b5bc43 | 284 | |
switches | 0:62bc11b5bc43 | 285 | /** |
switches | 0:62bc11b5bc43 | 286 | * @brief Configure Dual LED Mode |
switches | 0:62bc11b5bc43 | 287 | * @details Configures part for dual LED mode. |
switches | 0:62bc11b5bc43 | 288 | * @param smpAve number of samples to average |
switches | 0:62bc11b5bc43 | 289 | * @param fifoRollOver enables FIFO to roll over when full |
switches | 0:62bc11b5bc43 | 290 | * @param fifoAFull sets FIFO almost full level |
switches | 0:62bc11b5bc43 | 291 | * @param adcRange sets ADC range |
switches | 0:62bc11b5bc43 | 292 | * @param smpRate sets sample rate |
switches | 0:62bc11b5bc43 | 293 | * @param ledPW sets LED pulse width |
switches | 0:62bc11b5bc43 | 294 | * @param led1PA sets pulse amplitude for LED1 |
switches | 0:62bc11b5bc43 | 295 | * @param led2PA sets pulse amplitude for LED2 |
switches | 0:62bc11b5bc43 | 296 | * @returns 0 if no errors, -1 if error. |
switches | 0:62bc11b5bc43 | 297 | */ |
switches | 0:62bc11b5bc43 | 298 | int setDualLED(smp_ave_t smpAve = SMP_AVE_1, |
switches | 0:62bc11b5bc43 | 299 | bool fifoRollOver = false, |
switches | 0:62bc11b5bc43 | 300 | fifo_a_full_t fifoAFull = FIFO_A_FULL_F, |
switches | 0:62bc11b5bc43 | 301 | adc_rge_t adcRange = ADC_RGE_01, |
switches | 0:62bc11b5bc43 | 302 | smp_rt_t smpRate = SMP_RT_100, |
switches | 0:62bc11b5bc43 | 303 | led_pw_t ledPW = LED_PW_18BIT, |
switches | 0:62bc11b5bc43 | 304 | char led1PA = MAX30105_DEFAULT_LED_PA, |
switches | 0:62bc11b5bc43 | 305 | char led2PA = MAX30105_DEFAULT_LED_PA); |
switches | 0:62bc11b5bc43 | 306 | |
switches | 0:62bc11b5bc43 | 307 | /** |
switches | 0:62bc11b5bc43 | 308 | * @brief Configure Multi LED Mode |
switches | 0:62bc11b5bc43 | 309 | * @details Configures part for multi LED mode. |
switches | 0:62bc11b5bc43 | 310 | * @param smpAve number of samples to average |
switches | 0:62bc11b5bc43 | 311 | * @param fifoRollOver enables FIFO to roll over when full |
switches | 0:62bc11b5bc43 | 312 | * @param fifoAFull sets FIFO almost full level |
switches | 0:62bc11b5bc43 | 313 | * @param adcRange sets ADC range |
switches | 0:62bc11b5bc43 | 314 | * @param smpRate sets sample rate |
switches | 0:62bc11b5bc43 | 315 | * @param ledPW sets LED pulse width |
switches | 0:62bc11b5bc43 | 316 | * @param led1PA sets pulse amplitude for LED1 |
switches | 0:62bc11b5bc43 | 317 | * @param led2PA sets pulse amplitude for LED2 |
switches | 0:62bc11b5bc43 | 318 | * @param led3PA sets pulse amplitude for LED3 |
switches | 0:62bc11b5bc43 | 319 | * @param pilotPA sets pulse amplitude for pilot |
switches | 0:62bc11b5bc43 | 320 | * @param slot1 assigns LED and amplitude to slot 1 |
switches | 0:62bc11b5bc43 | 321 | * @param slot2 assigns LED and amplitude to slot 2 |
switches | 0:62bc11b5bc43 | 322 | * @param slot3 assigns LED and amplitude to slot 3 |
switches | 0:62bc11b5bc43 | 323 | * @param slot4 assigns LED and amplitude to slot 4 |
switches | 0:62bc11b5bc43 | 324 | * @returns 0 if no errors, -1 if error. |
switches | 0:62bc11b5bc43 | 325 | */ |
switches | 0:62bc11b5bc43 | 326 | int setMultiLED(smp_ave_t smpAve = SMP_AVE_1, |
switches | 0:62bc11b5bc43 | 327 | bool fifoRollOver = false, |
switches | 0:62bc11b5bc43 | 328 | fifo_a_full_t fifoAFull = FIFO_A_FULL_F, |
switches | 0:62bc11b5bc43 | 329 | adc_rge_t adcRange = ADC_RGE_01, |
switches | 0:62bc11b5bc43 | 330 | smp_rt_t smpRate = SMP_RT_100, |
switches | 0:62bc11b5bc43 | 331 | led_pw_t ledPW = LED_PW_18BIT, |
switches | 0:62bc11b5bc43 | 332 | char led1PA = MAX30105_DEFAULT_LED_PA, |
switches | 0:62bc11b5bc43 | 333 | char led2PA = MAX30105_DEFAULT_LED_PA, |
switches | 0:62bc11b5bc43 | 334 | char led3PA = MAX30105_DEFAULT_LED_PA, |
switches | 0:62bc11b5bc43 | 335 | char pilotPA = MAX30105_DEFAULT_PILOT_PA, |
switches | 0:62bc11b5bc43 | 336 | slot_t slot1 = SLOT_RED_LED1, |
switches | 0:62bc11b5bc43 | 337 | slot_t slot2 = SLOT_IR_LED2, |
switches | 0:62bc11b5bc43 | 338 | slot_t slot3 = SLOT_GREEN_LED3, |
switches | 0:62bc11b5bc43 | 339 | slot_t slot4 = SLOT_DISABLED); |
switches | 0:62bc11b5bc43 | 340 | |
switches | 0:62bc11b5bc43 | 341 | |
switches | 0:62bc11b5bc43 | 342 | /** |
switches | 0:62bc11b5bc43 | 343 | * @brief Initialize MAX30105 |
switches | 0:62bc11b5bc43 | 344 | * @details Intializes settings for the MAX30105 |
switches | 0:62bc11b5bc43 | 345 | * @returns 0 if no errors, -1 if error. |
switches | 0:62bc11b5bc43 | 346 | */ |
switches | 0:62bc11b5bc43 | 347 | int init(); |
switches | 0:62bc11b5bc43 | 348 | |
switches | 0:62bc11b5bc43 | 349 | /** |
switches | 0:62bc11b5bc43 | 350 | * @brief Read FIFOs |
switches | 0:62bc11b5bc43 | 351 | * @details Reads from the red and IR FIFOs |
switches | 0:62bc11b5bc43 | 352 | * @param redLED Pointer for where to store red LED data |
switches | 0:62bc11b5bc43 | 353 | * @param irLED Pointer for where to store IR LED data |
switches | 0:62bc11b5bc43 | 354 | * @returns 0 if no errors, -1 if error. |
switches | 0:62bc11b5bc43 | 355 | */ |
switches | 0:62bc11b5bc43 | 356 | int readFIFO(uint32_t *redLED, uint32_t *irLED); |
switches | 0:62bc11b5bc43 | 357 | |
switches | 0:62bc11b5bc43 | 358 | /** |
switches | 0:62bc11b5bc43 | 359 | * @brief Read Temperature |
switches | 0:62bc11b5bc43 | 360 | * @details Read the die temperature of the MAX30105 |
switches | 0:62bc11b5bc43 | 361 | * @returns Temperature in degrees C, or -999.0 if error |
switches | 0:62bc11b5bc43 | 362 | */ |
switches | 0:62bc11b5bc43 | 363 | float readTemperature(); |
switches | 0:62bc11b5bc43 | 364 | |
switches | 0:62bc11b5bc43 | 365 | /** |
switches | 0:62bc11b5bc43 | 366 | * @brief Reset MAX30105 |
switches | 0:62bc11b5bc43 | 367 | * @details Resets regsisters to their power on defaults |
switches | 0:62bc11b5bc43 | 368 | * @returns 0 if no errors, -1 if error. |
switches | 0:62bc11b5bc43 | 369 | */ |
switches | 0:62bc11b5bc43 | 370 | int softReset(); |
switches | 0:62bc11b5bc43 | 371 | |
switches | 0:62bc11b5bc43 | 372 | /** |
switches | 0:62bc11b5bc43 | 373 | * @brief Shutdown MAX30105 |
switches | 0:62bc11b5bc43 | 374 | * @details Puts MAX30105 in power-save mode, retaining regsiter settings |
switches | 0:62bc11b5bc43 | 375 | * @returns 0 if no errors, -1 if error. |
switches | 0:62bc11b5bc43 | 376 | */ |
switches | 0:62bc11b5bc43 | 377 | int shutDown(); |
switches | 0:62bc11b5bc43 | 378 | |
switches | 0:62bc11b5bc43 | 379 | /** |
switches | 0:62bc11b5bc43 | 380 | * @brief Wake Up MAX30105 |
switches | 0:62bc11b5bc43 | 381 | * @details Wakes MAX30105 from power-save mode |
switches | 0:62bc11b5bc43 | 382 | * @returns 0 if no errors, -1 if error. |
switches | 0:62bc11b5bc43 | 383 | */ |
switches | 0:62bc11b5bc43 | 384 | int wakeUp(); |
switches | 0:62bc11b5bc43 | 385 | |
switches | 0:62bc11b5bc43 | 386 | /** |
switches | 0:62bc11b5bc43 | 387 | * @brief Write Register |
switches | 0:62bc11b5bc43 | 388 | * @details Writes the given value to the specified register. |
switches | 0:62bc11b5bc43 | 389 | * @param reg The register to be written |
switches | 0:62bc11b5bc43 | 390 | * @param value The data to be written |
switches | 0:62bc11b5bc43 | 391 | * @returns 0 if no errors, -1 if error. |
switches | 0:62bc11b5bc43 | 392 | */ |
switches | 0:62bc11b5bc43 | 393 | int writeReg(registers_t reg, char value); |
switches | 0:62bc11b5bc43 | 394 | |
switches | 0:62bc11b5bc43 | 395 | /** |
switches | 0:62bc11b5bc43 | 396 | * @brief Read Register |
switches | 0:62bc11b5bc43 | 397 | * @details Reads from the specified register |
switches | 0:62bc11b5bc43 | 398 | * @param reg The register to be read |
switches | 0:62bc11b5bc43 | 399 | * @param value Pointer for where to store the data |
switches | 0:62bc11b5bc43 | 400 | * @returns 0 if no errors, -1 if error. |
switches | 0:62bc11b5bc43 | 401 | */ |
switches | 0:62bc11b5bc43 | 402 | int readReg(registers_t reg, char *value); |
switches | 0:62bc11b5bc43 | 403 | |
switches | 0:62bc11b5bc43 | 404 | private: |
switches | 0:62bc11b5bc43 | 405 | // Internal Resources |
switches | 0:62bc11b5bc43 | 406 | I2C _i2c; |
switches | 0:62bc11b5bc43 | 407 | |
switches | 0:62bc11b5bc43 | 408 | // Configuration Register Cache |
switches | 0:62bc11b5bc43 | 409 | char _interruptEnable1; |
switches | 0:62bc11b5bc43 | 410 | char _interruptEnable2; |
switches | 0:62bc11b5bc43 | 411 | char _fifoConfiguration; |
switches | 0:62bc11b5bc43 | 412 | char _modeConfiguration; |
switches | 0:62bc11b5bc43 | 413 | char _spo2Configuration; |
switches | 0:62bc11b5bc43 | 414 | char _led1PulseAmplitude; |
switches | 0:62bc11b5bc43 | 415 | char _led2PulseAmplitude; |
switches | 0:62bc11b5bc43 | 416 | char _led3PulseAmplitude; |
switches | 0:62bc11b5bc43 | 417 | char _pilotPulseAmplitude; |
switches | 0:62bc11b5bc43 | 418 | char _multiLedControl1; |
switches | 0:62bc11b5bc43 | 419 | char _multiLedControl2; |
switches | 0:62bc11b5bc43 | 420 | char _proxIntThreshold; |
switches | 0:62bc11b5bc43 | 421 | }; |
switches | 0:62bc11b5bc43 | 422 | |
switches | 0:62bc11b5bc43 | 423 | #endif /* _MAX30105_H_ */ |