Library for MAX3010x optical sensors

Dependents:   Temp_Prox_Demo

Committer:
switches
Date:
Thu Feb 16 22:01:02 2017 +0000
Revision:
1:411eb3796949
Parent:
0:62bc11b5bc43
Added class summary comments

Who changed what in which revision?

UserRevisionLine numberNew 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 1:411eb3796949 55 /**
switches 1:411eb3796949 56 * MAX30105 Optical Sensor
switches 1:411eb3796949 57 *
switches 1:411eb3796949 58 * @code
switches 1:411eb3796949 59 * #include "mbed.h"
switches 1:411eb3796949 60 * #include "MAX30105.h"
switches 1:411eb3796949 61 *
switches 1:411eb3796949 62 * I2C i2c(I2C_SDA, I2C_SCL);
switches 1:411eb3796949 63 * MAX30105 max30105(&i2c);
switches 1:411eb3796949 64 *
switches 1:411eb3796949 65 * int main(void) {
switches 1:411eb3796949 66 * int lastPrx = 0;
switches 1:411eb3796949 67 *
switches 1:411eb3796949 68 * max30105.softReset(); // reset the MAX30105
switches 1:411eb3796949 69 * max30105.shutDown(); // shut down while configuring
switches 1:411eb3796949 70 * max30105.enableIntr(MAX30105::INTR_PROX); // enable proximity interrupt
switches 1:411eb3796949 71 * max30105.setProx(0x40, 0x10); // set proximity pulse amplitude and threshold
switches 1:411eb3796949 72 * max30105.setSingleLED(); // configure single LED mode to initiate proximity detection
switches 1:411eb3796949 73 * max30105.wakeUp(); // exit shutdown to start sensing
switches 1:411eb3796949 74 *
switches 1:411eb3796949 75 * while(1) {
switches 1:411eb3796949 76 * if (max30105.getIntr1() & MAX30105::INTR_PROX) { // if the proximity interrupt occurs
switches 1:411eb3796949 77 * if (!lastPrx) {
switches 1:411eb3796949 78 * printf("Temperature = %02f\n", max30105.readTemperature());
switches 1:411eb3796949 79 * }
switches 1:411eb3796949 80 * max30105.writeReg(MAX30105::REG_MODE_CONFIG, MAX30105::MODE_1LED); // go back into proximity detection
switches 1:411eb3796949 81 * lastPrx = 1;
switches 1:411eb3796949 82 * } else {
switches 1:411eb3796949 83 * lastPrx = 0;
switches 1:411eb3796949 84 * }
switches 1:411eb3796949 85 * wait_ms(100);
switches 1:411eb3796949 86 * }
switches 1:411eb3796949 87 * }
switches 1:411eb3796949 88 * @endcode
switches 1:411eb3796949 89 */
switches 0:62bc11b5bc43 90 class MAX30105
switches 0:62bc11b5bc43 91 {
switches 0:62bc11b5bc43 92 public:
switches 0:62bc11b5bc43 93
switches 0:62bc11b5bc43 94 /**
switches 0:62bc11b5bc43 95 * @brief Register Addresses
switches 0:62bc11b5bc43 96 * @details Enumerated MAX30105 register addresses
switches 0:62bc11b5bc43 97 */
switches 0:62bc11b5bc43 98 enum registers_t {
switches 0:62bc11b5bc43 99 REG_INTR_STATUS_1 = 0x00, ///< Interrupt Status 1
switches 0:62bc11b5bc43 100 REG_INTR_STATUS_2 = 0x01, ///< Interrupt Status 2
switches 0:62bc11b5bc43 101 REG_INTR_ENABLE_1 = 0x02, ///< Interrupt Enable 1
switches 0:62bc11b5bc43 102 REG_INTR_ENABLE_2 = 0x03, ///< Interrupt Enable 2
switches 0:62bc11b5bc43 103 REG_FIFO_WR_PTR = 0x04, ///< FIFO Write Pointer
switches 0:62bc11b5bc43 104 REG_OVF_COUNTER = 0x05, ///< Overflow Counter
switches 0:62bc11b5bc43 105 REG_FIFO_RD_PTR = 0x06, ///< FIFO Read Pointer
switches 0:62bc11b5bc43 106 REG_FIFO_DATA = 0x07, ///< FIFO Data Register
switches 0:62bc11b5bc43 107 REG_FIFO_CONFIG = 0x08, ///< FIFO Configuration
switches 0:62bc11b5bc43 108 REG_MODE_CONFIG = 0x09, ///< Mode Configuration
switches 0:62bc11b5bc43 109 REG_SPO2_CONFIG = 0x0A, ///< Sensing Configuration
switches 0:62bc11b5bc43 110 REG_RSVD_0B = 0x0B, ///< Reserved 0x0B
switches 0:62bc11b5bc43 111 REG_LED1_PA = 0x0C, ///< LED1 Pulse Amplitude
switches 0:62bc11b5bc43 112 REG_LED2_PA = 0x0D, ///< LED2 Pulse Amplitude
switches 0:62bc11b5bc43 113 REG_LED3_PA = 0x0E, ///< LED3 Pulse Amplitude
switches 0:62bc11b5bc43 114 REG_RSVD_0F = 0x0F, ///< Reserved 0x0F
switches 0:62bc11b5bc43 115 REG_PILOT_PA = 0x10, ///< Proximity Mode LED Pulse Amplitude
switches 0:62bc11b5bc43 116 REG_MULTI_LED_CTRL1 = 0x11, ///< LED Slots 1 and 2
switches 0:62bc11b5bc43 117 REG_MULTI_LED_CTRL2 = 0x12, ///< LED Slots 3 and 4
switches 0:62bc11b5bc43 118 REG_TEMP_INT = 0x1F, ///< Die Temperature Ingteger
switches 0:62bc11b5bc43 119 REG_TEMP_FRAC = 0x20, ///< Die Temperature Fraction
switches 0:62bc11b5bc43 120 REG_TEMP_CONFIG = 0x21, ///< Die Temperature Configuration
switches 0:62bc11b5bc43 121 REG_PROX_INTR_THRESH = 0x30, ///< Proximity Interrupt Threshold
switches 0:62bc11b5bc43 122 REG_REV_ID = 0xFE, ///< Part Revision
switches 0:62bc11b5bc43 123 REG_PART_ID = 0xFF, ///< Part ID Code
switches 0:62bc11b5bc43 124 };
switches 0:62bc11b5bc43 125
switches 0:62bc11b5bc43 126 /**
switches 0:62bc11b5bc43 127 * @brief Sample Averaging
switches 0:62bc11b5bc43 128 * @details Number of samples to be averaged and decimated
switches 0:62bc11b5bc43 129 */
switches 0:62bc11b5bc43 130 enum smp_ave_t {
switches 0:62bc11b5bc43 131 SMP_AVE_1 = (0 << 5), ///< 1 (no averaging)
switches 0:62bc11b5bc43 132 SMP_AVE_2 = (1 << 5), ///< 2
switches 0:62bc11b5bc43 133 SMP_AVE_4 = (2 << 5), ///< 4
switches 0:62bc11b5bc43 134 SMP_AVE_8 = (3 << 5), ///< 8
switches 0:62bc11b5bc43 135 SMP_AVE_16 = (4 << 5), ///< 16
switches 0:62bc11b5bc43 136 SMP_AVE_32 = (5 << 5), ///< 32
switches 0:62bc11b5bc43 137 };
switches 0:62bc11b5bc43 138
switches 0:62bc11b5bc43 139 /**
switches 0:62bc11b5bc43 140 * @brief FIFO Almost Full Value
switches 0:62bc11b5bc43 141 * @details Number of empty spaces that triggers FIFO_A_FULL interrupt
switches 0:62bc11b5bc43 142 */
switches 0:62bc11b5bc43 143 enum fifo_a_full_t {
switches 0:62bc11b5bc43 144 FIFO_A_FULL_0 = 0x0, ///< 0 samples remaining, 32 used
switches 0:62bc11b5bc43 145 FIFO_A_FULL_1 = 0x1, ///< 1 samples remaining, 31 used
switches 0:62bc11b5bc43 146 FIFO_A_FULL_2 = 0x2, ///< 2 samples remaining, 30 used
switches 0:62bc11b5bc43 147 FIFO_A_FULL_3 = 0x3, ///< 3 samples remaining, 29 used
switches 0:62bc11b5bc43 148 FIFO_A_FULL_4 = 0x4, ///< 4 samples remaining, 28 used
switches 0:62bc11b5bc43 149 FIFO_A_FULL_5 = 0x5, ///< 5 samples remaining, 27 used
switches 0:62bc11b5bc43 150 FIFO_A_FULL_6 = 0x6, ///< 6 samples remaining, 26 used
switches 0:62bc11b5bc43 151 FIFO_A_FULL_7 = 0x7, ///< 7 samples remaining, 25 used
switches 0:62bc11b5bc43 152 FIFO_A_FULL_8 = 0x8, ///< 8 samples remaining, 24 used
switches 0:62bc11b5bc43 153 FIFO_A_FULL_9 = 0x9, ///< 9 samples remaining, 23 used
switches 0:62bc11b5bc43 154 FIFO_A_FULL_A = 0xA, ///< 10 samples remaining, 22 used
switches 0:62bc11b5bc43 155 FIFO_A_FULL_B = 0xB, ///< 11 samples remaining, 21 used
switches 0:62bc11b5bc43 156 FIFO_A_FULL_C = 0xC, ///< 12 samples remaining, 20 used
switches 0:62bc11b5bc43 157 FIFO_A_FULL_D = 0xD, ///< 13 samples remaining, 19 used
switches 0:62bc11b5bc43 158 FIFO_A_FULL_E = 0xE, ///< 14 samples remaining, 18 used
switches 0:62bc11b5bc43 159 FIFO_A_FULL_F = 0xF, ///< 15 samples remaining, 17 used
switches 0:62bc11b5bc43 160 };
switches 0:62bc11b5bc43 161
switches 0:62bc11b5bc43 162 /**
switches 0:62bc11b5bc43 163 * @brief Mode Control
switches 0:62bc11b5bc43 164 * @details Operating mode
switches 0:62bc11b5bc43 165 */
switches 0:62bc11b5bc43 166 enum mode_t {
switches 0:62bc11b5bc43 167 MODE_1LED = 0x2, ///< Single Red LED mode
switches 0:62bc11b5bc43 168 MODE_2LED = 0x3, ///< Red and IR LED mode
switches 0:62bc11b5bc43 169 MODE_MULTI = 0x7, ///< Multi LED mode Red, IR, and/or Green
switches 0:62bc11b5bc43 170 };
switches 0:62bc11b5bc43 171
switches 0:62bc11b5bc43 172 /**
switches 0:62bc11b5bc43 173 * @brief ADC Range
switches 0:62bc11b5bc43 174 * @details Sets the full scale range of the ADC
switches 0:62bc11b5bc43 175 */
switches 0:62bc11b5bc43 176 enum adc_rge_t {
switches 0:62bc11b5bc43 177 ADC_RGE_00 = (0 << 5), ///< 2048nA full scale, 7.81pA LSB
switches 0:62bc11b5bc43 178 ADC_RGE_01 = (1 << 5), ///< 4096nA full scale, 15.63pA LSB
switches 0:62bc11b5bc43 179 ADC_RGE_10 = (2 << 5), ///< 8192nA full scale, 31.25pA LSB
switches 0:62bc11b5bc43 180 ADC_RGE_11 = (3 << 5), ///< 16384nA full scale, 62.5pA LSB
switches 0:62bc11b5bc43 181 };
switches 0:62bc11b5bc43 182
switches 0:62bc11b5bc43 183 /**
switches 0:62bc11b5bc43 184 * @brief Sample Rate
switches 0:62bc11b5bc43 185 * @details Sets the sample rate of the pulses for each enabled LED
switches 0:62bc11b5bc43 186 */
switches 0:62bc11b5bc43 187 enum smp_rt_t {
switches 0:62bc11b5bc43 188 SMP_RT_50 = (0 << 2), ///< 50 Samples per second
switches 0:62bc11b5bc43 189 SMP_RT_100 = (1 << 2), ///< 100 Samples per second
switches 0:62bc11b5bc43 190 SMP_RT_200 = (2 << 2), ///< 200 Samples per second
switches 0:62bc11b5bc43 191 SMP_RT_400 = (3 << 2), ///< 400 Samples per second
switches 0:62bc11b5bc43 192 SMP_RT_800 = (4 << 2), ///< 800 Samples per second
switches 0:62bc11b5bc43 193 SMP_RT_1000 = (5 << 2), ///< 1000 Samples per second
switches 0:62bc11b5bc43 194 SMP_RT_1600 = (6 << 2), ///< 1600 Samples per second
switches 0:62bc11b5bc43 195 SMP_RT_3200 = (7 << 2), ///< 3200 Samples per second
switches 0:62bc11b5bc43 196 };
switches 0:62bc11b5bc43 197
switches 0:62bc11b5bc43 198 /**
switches 0:62bc11b5bc43 199 * @brief Pulse Width
switches 0:62bc11b5bc43 200 * @details Sets the pulse width for the channel
switches 0:62bc11b5bc43 201 */
switches 0:62bc11b5bc43 202 enum led_pw_t {
switches 0:62bc11b5bc43 203 LED_PW_15BIT = 0, ///< 69us, 15 bit resolution
switches 0:62bc11b5bc43 204 LED_PW_16BIT = 1, ///< 118us, 16 bit resolution
switches 0:62bc11b5bc43 205 LED_PW_17BIT = 2, ///< 215us, 17 bit resolution
switches 0:62bc11b5bc43 206 LED_PW_18BIT = 3, ///< 411us, 18 bit resolution
switches 0:62bc11b5bc43 207 };
switches 0:62bc11b5bc43 208
switches 0:62bc11b5bc43 209 /**
switches 0:62bc11b5bc43 210 * @brief Slot Control
switches 0:62bc11b5bc43 211 * @details Sets the active LED and pulse amplitude for the slot
switches 0:62bc11b5bc43 212 */
switches 0:62bc11b5bc43 213 enum slot_t {
switches 0:62bc11b5bc43 214 SLOT_DISABLED = 0, ///< No LED active
switches 0:62bc11b5bc43 215 SLOT_RED_LED1 = 1, ///< Red, LED1_PA
switches 0:62bc11b5bc43 216 SLOT_IR_LED2 = 2, ///< IR, LED3_PA
switches 0:62bc11b5bc43 217 SLOT_GREEN_LED3 = 3, ///< Green, LED3_PA
switches 0:62bc11b5bc43 218 SLOT_NONE = 4, ///< No LED active
switches 0:62bc11b5bc43 219 SLOT_RED_PILOT = 5, ///< Red, PILOT_PA
switches 0:62bc11b5bc43 220 SLOT_IR_PILOT = 6, ///< IR, PILOT_PA
switches 0:62bc11b5bc43 221 SLOT_GREEN_PILOT = 7, ///< Green, PILOT_PA
switches 0:62bc11b5bc43 222 };
switches 0:62bc11b5bc43 223
switches 0:62bc11b5bc43 224 static const char INTR_A_FULL = (1 <<7);
switches 0:62bc11b5bc43 225 static const char INTR_DATA_RDY = (1 <<6);
switches 0:62bc11b5bc43 226 static const char INTR_ALC_OVF = (1 <<5);
switches 0:62bc11b5bc43 227 static const char INTR_PROX = (1 <<4);
switches 0:62bc11b5bc43 228 static const char INTR_PWR_RDY = (1 <<0);
switches 0:62bc11b5bc43 229 static const char INTR_TEMP_RDY = (1 <<1);
switches 0:62bc11b5bc43 230
switches 0:62bc11b5bc43 231 static const char MASK_SMP_AVE = (7 <<5);
switches 0:62bc11b5bc43 232 static const char MASK_FIFO_ROLLOVER_EN = (1 <<4);
switches 0:62bc11b5bc43 233 static const char MASK_FIFO_A_FULL = (0xF <<0);
switches 0:62bc11b5bc43 234
switches 0:62bc11b5bc43 235 static const char MASK_SHDN = (1 <<7);
switches 0:62bc11b5bc43 236 static const char MASK_RESET = (1 <<6);
switches 0:62bc11b5bc43 237 static const char MASK_MODE = (7 <<0);
switches 0:62bc11b5bc43 238
switches 0:62bc11b5bc43 239 static const char MASK_ADC_RGE = (3 <<5);
switches 0:62bc11b5bc43 240 static const char MASK_SMP_RT = (7 <<2);
switches 0:62bc11b5bc43 241 static const char MASK_LED_PW = (3 <<0);
switches 0:62bc11b5bc43 242
switches 0:62bc11b5bc43 243 static const char MASK_SLOT2 = (7 <<4);
switches 0:62bc11b5bc43 244 static const char MASK_SLOT1 = (7 <<0);
switches 0:62bc11b5bc43 245 static const char MASK_SLOT4 = (7 <<4);
switches 0:62bc11b5bc43 246 static const char MASK_SLOT3 = (7 <<0);
switches 0:62bc11b5bc43 247
switches 0:62bc11b5bc43 248 /**
switches 0:62bc11b5bc43 249 * MAX30105 constructor.
switches 0:62bc11b5bc43 250 *
switches 0:62bc11b5bc43 251 * @param i2c I2C object to use.
switches 0:62bc11b5bc43 252 */
switches 0:62bc11b5bc43 253 MAX30105(I2C &i2c);
switches 0:62bc11b5bc43 254
switches 0:62bc11b5bc43 255 /**
switches 0:62bc11b5bc43 256 * MAX30105 destructor.
switches 0:62bc11b5bc43 257 */
switches 0:62bc11b5bc43 258 ~MAX30105();
switches 0:62bc11b5bc43 259
switches 0:62bc11b5bc43 260 /**
switches 0:62bc11b5bc43 261 * @brief Get Interrupt 1
switches 0:62bc11b5bc43 262 * @details Reads Interrupt 1
switches 0:62bc11b5bc43 263 * @returns contents of REG_INTR_STATUS_1, or -1 if error.
switches 0:62bc11b5bc43 264 */
switches 0:62bc11b5bc43 265 int getIntr1();
switches 0:62bc11b5bc43 266
switches 0:62bc11b5bc43 267 /**
switches 0:62bc11b5bc43 268 * @brief Get Interrupt 2
switches 0:62bc11b5bc43 269 * @details Reads Temp Interrupt
switches 0:62bc11b5bc43 270 * @returns contents of REG_INTR_STATUS_2, or -1 if error.
switches 0:62bc11b5bc43 271 */
switches 0:62bc11b5bc43 272 int getIntr2();
switches 0:62bc11b5bc43 273
switches 0:62bc11b5bc43 274 /**
switches 0:62bc11b5bc43 275 * @brief Enable Interrupt
switches 0:62bc11b5bc43 276 * @details Enables any interrupt whos bit is set
switches 0:62bc11b5bc43 277 * @param intrBits bit mask of interrupts to enable
switches 0:62bc11b5bc43 278 * @returns 0 if no errors, -1 if error.
switches 0:62bc11b5bc43 279 */
switches 0:62bc11b5bc43 280 int enableIntr(char intrBits);
switches 0:62bc11b5bc43 281
switches 0:62bc11b5bc43 282 /**
switches 0:62bc11b5bc43 283 * @brief Disable Interrupt
switches 0:62bc11b5bc43 284 * @details Disables any interrupt whos bit is set
switches 0:62bc11b5bc43 285 * @param intrBits bit mask of interrupts to disable
switches 0:62bc11b5bc43 286 * @returns 0 if no errors, -1 if error.
switches 0:62bc11b5bc43 287 */
switches 0:62bc11b5bc43 288 int disableIntr(char intrBits);
switches 0:62bc11b5bc43 289
switches 0:62bc11b5bc43 290 /**
switches 0:62bc11b5bc43 291 * @brief Configure Proximity Function
switches 0:62bc11b5bc43 292 * @details Sets amplitude and threshold for proximity detector
switches 0:62bc11b5bc43 293 * Set threshold to 0x00 to disable proximity detecotr
switches 0:62bc11b5bc43 294 * @param proxAmp The amplitude of the proximity pulse 50mA/255 steps
switches 0:62bc11b5bc43 295 * @param proxThresh The detect threshold to start sensing
switches 0:62bc11b5bc43 296 * @returns 0 if no errors, -1 if error.
switches 0:62bc11b5bc43 297 */
switches 0:62bc11b5bc43 298 int setProx(char proxAmp, char proxThresh);
switches 0:62bc11b5bc43 299
switches 0:62bc11b5bc43 300 /**
switches 0:62bc11b5bc43 301 * @brief Configure Single LED Mode
switches 0:62bc11b5bc43 302 * @details Configures part for single LED mode.
switches 0:62bc11b5bc43 303 * @param smpAve number of samples to average
switches 0:62bc11b5bc43 304 * @param fifoRollOver enables FIFO to roll over when full
switches 0:62bc11b5bc43 305 * @param fifoAFull sets FIFO almost full level
switches 0:62bc11b5bc43 306 * @param adcRange sets ADC range
switches 0:62bc11b5bc43 307 * @param smpRate sets sample rate
switches 0:62bc11b5bc43 308 * @param ledPW sets LED pulse width
switches 0:62bc11b5bc43 309 * @param led1PA sets pulse amplitude for LED1
switches 0:62bc11b5bc43 310 * @returns 0 if no errors, -1 if error.
switches 0:62bc11b5bc43 311 */
switches 0:62bc11b5bc43 312 int setSingleLED(smp_ave_t smpAve = SMP_AVE_1,
switches 0:62bc11b5bc43 313 bool fifoRollOver = false,
switches 0:62bc11b5bc43 314 fifo_a_full_t fifoAFull = FIFO_A_FULL_F,
switches 0:62bc11b5bc43 315 adc_rge_t adcRange = ADC_RGE_01,
switches 0:62bc11b5bc43 316 smp_rt_t smpRate = SMP_RT_100,
switches 0:62bc11b5bc43 317 led_pw_t ledPW = LED_PW_18BIT,
switches 0:62bc11b5bc43 318 char led1PA = MAX30105_DEFAULT_LED_PA);
switches 0:62bc11b5bc43 319
switches 0:62bc11b5bc43 320 /**
switches 0:62bc11b5bc43 321 * @brief Configure Dual LED Mode
switches 0:62bc11b5bc43 322 * @details Configures part for dual LED mode.
switches 0:62bc11b5bc43 323 * @param smpAve number of samples to average
switches 0:62bc11b5bc43 324 * @param fifoRollOver enables FIFO to roll over when full
switches 0:62bc11b5bc43 325 * @param fifoAFull sets FIFO almost full level
switches 0:62bc11b5bc43 326 * @param adcRange sets ADC range
switches 0:62bc11b5bc43 327 * @param smpRate sets sample rate
switches 0:62bc11b5bc43 328 * @param ledPW sets LED pulse width
switches 0:62bc11b5bc43 329 * @param led1PA sets pulse amplitude for LED1
switches 0:62bc11b5bc43 330 * @param led2PA sets pulse amplitude for LED2
switches 0:62bc11b5bc43 331 * @returns 0 if no errors, -1 if error.
switches 0:62bc11b5bc43 332 */
switches 0:62bc11b5bc43 333 int setDualLED(smp_ave_t smpAve = SMP_AVE_1,
switches 0:62bc11b5bc43 334 bool fifoRollOver = false,
switches 0:62bc11b5bc43 335 fifo_a_full_t fifoAFull = FIFO_A_FULL_F,
switches 0:62bc11b5bc43 336 adc_rge_t adcRange = ADC_RGE_01,
switches 0:62bc11b5bc43 337 smp_rt_t smpRate = SMP_RT_100,
switches 0:62bc11b5bc43 338 led_pw_t ledPW = LED_PW_18BIT,
switches 0:62bc11b5bc43 339 char led1PA = MAX30105_DEFAULT_LED_PA,
switches 0:62bc11b5bc43 340 char led2PA = MAX30105_DEFAULT_LED_PA);
switches 0:62bc11b5bc43 341
switches 0:62bc11b5bc43 342 /**
switches 0:62bc11b5bc43 343 * @brief Configure Multi LED Mode
switches 0:62bc11b5bc43 344 * @details Configures part for multi LED mode.
switches 0:62bc11b5bc43 345 * @param smpAve number of samples to average
switches 0:62bc11b5bc43 346 * @param fifoRollOver enables FIFO to roll over when full
switches 0:62bc11b5bc43 347 * @param fifoAFull sets FIFO almost full level
switches 0:62bc11b5bc43 348 * @param adcRange sets ADC range
switches 0:62bc11b5bc43 349 * @param smpRate sets sample rate
switches 0:62bc11b5bc43 350 * @param ledPW sets LED pulse width
switches 0:62bc11b5bc43 351 * @param led1PA sets pulse amplitude for LED1
switches 0:62bc11b5bc43 352 * @param led2PA sets pulse amplitude for LED2
switches 0:62bc11b5bc43 353 * @param led3PA sets pulse amplitude for LED3
switches 0:62bc11b5bc43 354 * @param pilotPA sets pulse amplitude for pilot
switches 0:62bc11b5bc43 355 * @param slot1 assigns LED and amplitude to slot 1
switches 0:62bc11b5bc43 356 * @param slot2 assigns LED and amplitude to slot 2
switches 0:62bc11b5bc43 357 * @param slot3 assigns LED and amplitude to slot 3
switches 0:62bc11b5bc43 358 * @param slot4 assigns LED and amplitude to slot 4
switches 0:62bc11b5bc43 359 * @returns 0 if no errors, -1 if error.
switches 0:62bc11b5bc43 360 */
switches 0:62bc11b5bc43 361 int setMultiLED(smp_ave_t smpAve = SMP_AVE_1,
switches 0:62bc11b5bc43 362 bool fifoRollOver = false,
switches 0:62bc11b5bc43 363 fifo_a_full_t fifoAFull = FIFO_A_FULL_F,
switches 0:62bc11b5bc43 364 adc_rge_t adcRange = ADC_RGE_01,
switches 0:62bc11b5bc43 365 smp_rt_t smpRate = SMP_RT_100,
switches 0:62bc11b5bc43 366 led_pw_t ledPW = LED_PW_18BIT,
switches 0:62bc11b5bc43 367 char led1PA = MAX30105_DEFAULT_LED_PA,
switches 0:62bc11b5bc43 368 char led2PA = MAX30105_DEFAULT_LED_PA,
switches 0:62bc11b5bc43 369 char led3PA = MAX30105_DEFAULT_LED_PA,
switches 0:62bc11b5bc43 370 char pilotPA = MAX30105_DEFAULT_PILOT_PA,
switches 0:62bc11b5bc43 371 slot_t slot1 = SLOT_RED_LED1,
switches 0:62bc11b5bc43 372 slot_t slot2 = SLOT_IR_LED2,
switches 0:62bc11b5bc43 373 slot_t slot3 = SLOT_GREEN_LED3,
switches 0:62bc11b5bc43 374 slot_t slot4 = SLOT_DISABLED);
switches 0:62bc11b5bc43 375
switches 0:62bc11b5bc43 376
switches 0:62bc11b5bc43 377 /**
switches 0:62bc11b5bc43 378 * @brief Initialize MAX30105
switches 0:62bc11b5bc43 379 * @details Intializes settings for the MAX30105
switches 0:62bc11b5bc43 380 * @returns 0 if no errors, -1 if error.
switches 0:62bc11b5bc43 381 */
switches 0:62bc11b5bc43 382 int init();
switches 0:62bc11b5bc43 383
switches 0:62bc11b5bc43 384 /**
switches 0:62bc11b5bc43 385 * @brief Read FIFOs
switches 0:62bc11b5bc43 386 * @details Reads from the red and IR FIFOs
switches 0:62bc11b5bc43 387 * @param redLED Pointer for where to store red LED data
switches 0:62bc11b5bc43 388 * @param irLED Pointer for where to store IR LED data
switches 0:62bc11b5bc43 389 * @returns 0 if no errors, -1 if error.
switches 0:62bc11b5bc43 390 */
switches 0:62bc11b5bc43 391 int readFIFO(uint32_t *redLED, uint32_t *irLED);
switches 0:62bc11b5bc43 392
switches 0:62bc11b5bc43 393 /**
switches 0:62bc11b5bc43 394 * @brief Read Temperature
switches 0:62bc11b5bc43 395 * @details Read the die temperature of the MAX30105
switches 0:62bc11b5bc43 396 * @returns Temperature in degrees C, or -999.0 if error
switches 0:62bc11b5bc43 397 */
switches 0:62bc11b5bc43 398 float readTemperature();
switches 0:62bc11b5bc43 399
switches 0:62bc11b5bc43 400 /**
switches 0:62bc11b5bc43 401 * @brief Reset MAX30105
switches 0:62bc11b5bc43 402 * @details Resets regsisters to their power on defaults
switches 0:62bc11b5bc43 403 * @returns 0 if no errors, -1 if error.
switches 0:62bc11b5bc43 404 */
switches 0:62bc11b5bc43 405 int softReset();
switches 0:62bc11b5bc43 406
switches 0:62bc11b5bc43 407 /**
switches 0:62bc11b5bc43 408 * @brief Shutdown MAX30105
switches 0:62bc11b5bc43 409 * @details Puts MAX30105 in power-save mode, retaining regsiter settings
switches 0:62bc11b5bc43 410 * @returns 0 if no errors, -1 if error.
switches 0:62bc11b5bc43 411 */
switches 0:62bc11b5bc43 412 int shutDown();
switches 0:62bc11b5bc43 413
switches 0:62bc11b5bc43 414 /**
switches 0:62bc11b5bc43 415 * @brief Wake Up MAX30105
switches 0:62bc11b5bc43 416 * @details Wakes MAX30105 from power-save mode
switches 0:62bc11b5bc43 417 * @returns 0 if no errors, -1 if error.
switches 0:62bc11b5bc43 418 */
switches 0:62bc11b5bc43 419 int wakeUp();
switches 0:62bc11b5bc43 420
switches 0:62bc11b5bc43 421 /**
switches 0:62bc11b5bc43 422 * @brief Write Register
switches 0:62bc11b5bc43 423 * @details Writes the given value to the specified register.
switches 0:62bc11b5bc43 424 * @param reg The register to be written
switches 0:62bc11b5bc43 425 * @param value The data to be written
switches 0:62bc11b5bc43 426 * @returns 0 if no errors, -1 if error.
switches 0:62bc11b5bc43 427 */
switches 0:62bc11b5bc43 428 int writeReg(registers_t reg, char value);
switches 0:62bc11b5bc43 429
switches 0:62bc11b5bc43 430 /**
switches 0:62bc11b5bc43 431 * @brief Read Register
switches 0:62bc11b5bc43 432 * @details Reads from the specified register
switches 0:62bc11b5bc43 433 * @param reg The register to be read
switches 0:62bc11b5bc43 434 * @param value Pointer for where to store the data
switches 0:62bc11b5bc43 435 * @returns 0 if no errors, -1 if error.
switches 0:62bc11b5bc43 436 */
switches 0:62bc11b5bc43 437 int readReg(registers_t reg, char *value);
switches 0:62bc11b5bc43 438
switches 0:62bc11b5bc43 439 private:
switches 0:62bc11b5bc43 440 // Internal Resources
switches 0:62bc11b5bc43 441 I2C _i2c;
switches 0:62bc11b5bc43 442
switches 0:62bc11b5bc43 443 // Configuration Register Cache
switches 0:62bc11b5bc43 444 char _interruptEnable1;
switches 0:62bc11b5bc43 445 char _interruptEnable2;
switches 0:62bc11b5bc43 446 char _fifoConfiguration;
switches 0:62bc11b5bc43 447 char _modeConfiguration;
switches 0:62bc11b5bc43 448 char _spo2Configuration;
switches 0:62bc11b5bc43 449 char _led1PulseAmplitude;
switches 0:62bc11b5bc43 450 char _led2PulseAmplitude;
switches 0:62bc11b5bc43 451 char _led3PulseAmplitude;
switches 0:62bc11b5bc43 452 char _pilotPulseAmplitude;
switches 0:62bc11b5bc43 453 char _multiLedControl1;
switches 0:62bc11b5bc43 454 char _multiLedControl2;
switches 0:62bc11b5bc43 455 char _proxIntThreshold;
switches 0:62bc11b5bc43 456 };
switches 0:62bc11b5bc43 457
switches 0:62bc11b5bc43 458 #endif /* _MAX30105_H_ */