Library for MAX30101 SpO2 and heart rate sensor
Dependents: HeartRate HeartRate proj final_project_ee119 ... more
MAX30101.h@4:d1b50bd4065a, 2017-05-04 (annotated)
- Committer:
- j3
- Date:
- Thu May 04 23:46:46 2017 +0000
- Revision:
- 4:d1b50bd4065a
- Parent:
- 3:a2effad05c99
- Child:
- 5:be1dde31fe49
fixed readFifo docs
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
j3 | 0:2d0c91de9279 | 1 | /******************************************************************************* |
j3 | 0:2d0c91de9279 | 2 | * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved. |
j3 | 0:2d0c91de9279 | 3 | * |
j3 | 0:2d0c91de9279 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
j3 | 0:2d0c91de9279 | 5 | * copy of this software and associated documentation files (the "Software"), |
j3 | 0:2d0c91de9279 | 6 | * to deal in the Software without restriction, including without limitation |
j3 | 0:2d0c91de9279 | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
j3 | 0:2d0c91de9279 | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
j3 | 0:2d0c91de9279 | 9 | * Software is furnished to do so, subject to the following conditions: |
j3 | 0:2d0c91de9279 | 10 | * |
j3 | 0:2d0c91de9279 | 11 | * The above copyright notice and this permission notice shall be included |
j3 | 0:2d0c91de9279 | 12 | * in all copies or substantial portions of the Software. |
j3 | 0:2d0c91de9279 | 13 | * |
j3 | 0:2d0c91de9279 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
j3 | 0:2d0c91de9279 | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
j3 | 0:2d0c91de9279 | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
j3 | 0:2d0c91de9279 | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
j3 | 0:2d0c91de9279 | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
j3 | 0:2d0c91de9279 | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
j3 | 0:2d0c91de9279 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
j3 | 0:2d0c91de9279 | 21 | * |
j3 | 0:2d0c91de9279 | 22 | * Except as contained in this notice, the name of Maxim Integrated |
j3 | 0:2d0c91de9279 | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
j3 | 0:2d0c91de9279 | 24 | * Products, Inc. Branding Policy. |
j3 | 0:2d0c91de9279 | 25 | * |
j3 | 0:2d0c91de9279 | 26 | * The mere transfer of this software does not imply any licenses |
j3 | 0:2d0c91de9279 | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
j3 | 0:2d0c91de9279 | 28 | * trademarks, maskwork rights, or any other form of intellectual |
j3 | 0:2d0c91de9279 | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
j3 | 0:2d0c91de9279 | 30 | * ownership rights. |
j3 | 0:2d0c91de9279 | 31 | ******************************************************************************* |
j3 | 0:2d0c91de9279 | 32 | */ |
j3 | 0:2d0c91de9279 | 33 | #ifndef __MAX30101_H_ |
j3 | 0:2d0c91de9279 | 34 | #define __MAX30101_H_ |
j3 | 0:2d0c91de9279 | 35 | |
j3 | 0:2d0c91de9279 | 36 | #include "mbed.h" |
j3 | 0:2d0c91de9279 | 37 | |
j3 | 0:2d0c91de9279 | 38 | /** |
j3 | 0:2d0c91de9279 | 39 | * Driver for the MAX30101 |
j3 | 0:2d0c91de9279 | 40 | * |
j3 | 0:2d0c91de9279 | 41 | * @code |
j3 | 0:2d0c91de9279 | 42 | * #include "mbed.h" |
j3 | 0:2d0c91de9279 | 43 | * #include "max32630fthr.h" |
j3 | 0:2d0c91de9279 | 44 | * #include "MAX30101.h" |
j3 | 0:2d0c91de9279 | 45 | * |
j3 | 0:2d0c91de9279 | 46 | * MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); |
j3 | 0:2d0c91de9279 | 47 | * |
j3 | 0:2d0c91de9279 | 48 | * //Get I2C instance |
j3 | 0:2d0c91de9279 | 49 | * I2C i2cBus(P3_4, P3_5); |
j3 | 0:2d0c91de9279 | 50 | * |
j3 | 0:2d0c91de9279 | 51 | * //Get temp sensor instance |
j3 | 0:2d0c91de9279 | 52 | * MAX30101 op_sensor(i2cBus); //Constructor takes 7-bit slave adrs |
j3 | 0:2d0c91de9279 | 53 | * |
j3 | 0:2d0c91de9279 | 54 | * int main(void) |
j3 | 0:2d0c91de9279 | 55 | * { |
j3 | 0:2d0c91de9279 | 56 | * //use sensor |
j3 | 0:2d0c91de9279 | 57 | * } |
j3 | 0:2d0c91de9279 | 58 | * @endcode |
j3 | 0:2d0c91de9279 | 59 | */ |
j3 | 0:2d0c91de9279 | 60 | |
j3 | 0:2d0c91de9279 | 61 | class MAX30101 |
j3 | 0:2d0c91de9279 | 62 | { |
j3 | 0:2d0c91de9279 | 63 | public: |
j3 | 0:2d0c91de9279 | 64 | |
j3 | 0:2d0c91de9279 | 65 | ///7-bit slave address |
j3 | 0:2d0c91de9279 | 66 | static const uint8_t I2C_ADRS = 0x57; |
j3 | 0:2d0c91de9279 | 67 | ///8-bit write address |
j3 | 0:2d0c91de9279 | 68 | static const uint8_t I2C_W_ADRS = 0xAE; |
j3 | 0:2d0c91de9279 | 69 | ///8-bit read address |
j3 | 0:2d0c91de9279 | 70 | static const uint8_t I2C_R_ADRS = 0xAF; |
j3 | 3:a2effad05c99 | 71 | ///Max # Bytes in FIFO |
j3 | 3:a2effad05c99 | 72 | static const uint16_t MAX_FIFO_BYTES = 288; |
j3 | 3:a2effad05c99 | 73 | ///# of bytes per LED channel |
j3 | 3:a2effad05c99 | 74 | static const uint8_t BYTES_PER_CH = 3; |
j3 | 0:2d0c91de9279 | 75 | |
j3 | 0:2d0c91de9279 | 76 | ///MAX30101 Register Map |
j3 | 0:2d0c91de9279 | 77 | enum Registers_e |
j3 | 0:2d0c91de9279 | 78 | { |
j3 | 0:2d0c91de9279 | 79 | InterruptStatus1 = 0x00, |
j3 | 0:2d0c91de9279 | 80 | InterruptStatus2 = 0x01, |
j3 | 0:2d0c91de9279 | 81 | InterruptEnable1 = 0x02, |
j3 | 0:2d0c91de9279 | 82 | InterruptEnable2 = 0x03, |
j3 | 0:2d0c91de9279 | 83 | FIFO_WritePointer = 0x04, |
j3 | 0:2d0c91de9279 | 84 | OverflowCounter = 0x05, |
j3 | 0:2d0c91de9279 | 85 | FIFO_ReadPointer = 0x06, |
j3 | 0:2d0c91de9279 | 86 | FIFO_DataRegister = 0x07, |
j3 | 0:2d0c91de9279 | 87 | FIFO_Configuration = 0x08, |
j3 | 0:2d0c91de9279 | 88 | ModeConfiguration = 0x09, |
j3 | 0:2d0c91de9279 | 89 | SpO2Configuration = 0x0A, |
j3 | 0:2d0c91de9279 | 90 | LED1_PA = 0x0C, |
j3 | 0:2d0c91de9279 | 91 | LED2_PA = 0x0D, |
j3 | 0:2d0c91de9279 | 92 | LED3_PA = 0x0E, |
j3 | 0:2d0c91de9279 | 93 | ProxModeLED_PA = 0x10, |
j3 | 0:2d0c91de9279 | 94 | ModeControlReg1 = 0x11, |
j3 | 0:2d0c91de9279 | 95 | ModeControlReg2 = 0x12, |
j3 | 0:2d0c91de9279 | 96 | DieTempInt = 0x1F, |
j3 | 0:2d0c91de9279 | 97 | DieTempFrac = 0x20, |
j3 | 0:2d0c91de9279 | 98 | DieTempConfig = 0x21, |
j3 | 0:2d0c91de9279 | 99 | ProxIntThreshold = 0x30, |
j3 | 0:2d0c91de9279 | 100 | RevID = 0xFE, |
j3 | 0:2d0c91de9279 | 101 | PartID = 0xFF |
j3 | 0:2d0c91de9279 | 102 | }; |
j3 | 0:2d0c91de9279 | 103 | |
j3 | 3:a2effad05c99 | 104 | ///MAX30101 Operational Modes |
j3 | 3:a2effad05c99 | 105 | enum OpModes_e |
j3 | 3:a2effad05c99 | 106 | { |
j3 | 3:a2effad05c99 | 107 | HeartRateMode = 2, |
j3 | 3:a2effad05c99 | 108 | SpO2Mode = 3, |
j3 | 3:a2effad05c99 | 109 | MultiLedMode = 7 |
j3 | 3:a2effad05c99 | 110 | }; |
j3 | 3:a2effad05c99 | 111 | |
j3 | 0:2d0c91de9279 | 112 | ///Interrupt Status/Enable BitField |
j3 | 0:2d0c91de9279 | 113 | union InterruptBitField_u |
j3 | 0:2d0c91de9279 | 114 | { |
j3 | 0:2d0c91de9279 | 115 | uint8_t all; |
j3 | 0:2d0c91de9279 | 116 | |
j3 | 0:2d0c91de9279 | 117 | struct BitField_s |
j3 | 0:2d0c91de9279 | 118 | { |
j3 | 0:2d0c91de9279 | 119 | uint8_t pwr_rdy : 1; ///< Bit0 |
j3 | 0:2d0c91de9279 | 120 | uint8_t die_temp : 1; ///< Bit1 |
j3 | 0:2d0c91de9279 | 121 | uint8_t reserved : 2; ///< Bit3:2 |
j3 | 0:2d0c91de9279 | 122 | uint8_t prox_int : 1; ///< Bit4 |
j3 | 0:2d0c91de9279 | 123 | uint8_t alc_ovf : 1; ///< Bit5 |
j3 | 0:2d0c91de9279 | 124 | uint8_t ppg_rdy : 1; ///< Bit6 |
j3 | 0:2d0c91de9279 | 125 | uint8_t a_full : 1; ///< Bit7 |
j3 | 0:2d0c91de9279 | 126 | }bits; |
j3 | 0:2d0c91de9279 | 127 | }; |
j3 | 0:2d0c91de9279 | 128 | |
j3 | 0:2d0c91de9279 | 129 | ///FIFO Configuration BitField |
j3 | 0:2d0c91de9279 | 130 | union FIFO_Configuration_u |
j3 | 0:2d0c91de9279 | 131 | { |
j3 | 0:2d0c91de9279 | 132 | uint8_t all; |
j3 | 0:2d0c91de9279 | 133 | struct BitField_s |
j3 | 0:2d0c91de9279 | 134 | { |
j3 | 0:2d0c91de9279 | 135 | uint8_t fifo_a_full : 4; |
j3 | 0:2d0c91de9279 | 136 | uint8_t fifo_roll_over_en : 1; |
j3 | 0:2d0c91de9279 | 137 | uint8_t sample_average : 3; |
j3 | 0:2d0c91de9279 | 138 | }bits; |
j3 | 0:2d0c91de9279 | 139 | }; |
j3 | 0:2d0c91de9279 | 140 | |
j3 | 0:2d0c91de9279 | 141 | ///Mode Configuration BitField |
j3 | 0:2d0c91de9279 | 142 | union ModeConfiguration_u |
j3 | 0:2d0c91de9279 | 143 | { |
j3 | 0:2d0c91de9279 | 144 | uint8_t all; |
j3 | 0:2d0c91de9279 | 145 | struct BitField_s |
j3 | 0:2d0c91de9279 | 146 | { |
j3 | 0:2d0c91de9279 | 147 | uint8_t mode : 3; |
j3 | 0:2d0c91de9279 | 148 | uint8_t reserved : 3; |
j3 | 0:2d0c91de9279 | 149 | uint8_t reset : 1; |
j3 | 0:2d0c91de9279 | 150 | uint8_t shdn : 1; |
j3 | 0:2d0c91de9279 | 151 | }bits; |
j3 | 0:2d0c91de9279 | 152 | }; |
j3 | 0:2d0c91de9279 | 153 | |
j3 | 0:2d0c91de9279 | 154 | ///SpO2 Configuration BitField |
j3 | 0:2d0c91de9279 | 155 | union SpO2Configuration_u |
j3 | 0:2d0c91de9279 | 156 | { |
j3 | 0:2d0c91de9279 | 157 | uint8_t all; |
j3 | 0:2d0c91de9279 | 158 | struct BitField_s |
j3 | 0:2d0c91de9279 | 159 | { |
j3 | 0:2d0c91de9279 | 160 | uint8_t led_pw : 2; |
j3 | 0:2d0c91de9279 | 161 | uint8_t spo2_sr : 3; |
j3 | 0:2d0c91de9279 | 162 | uint8_t spo2_adc_range : 2; |
j3 | 0:2d0c91de9279 | 163 | uint8_t reserved : 1; |
j3 | 0:2d0c91de9279 | 164 | }bits; |
j3 | 0:2d0c91de9279 | 165 | }; |
j3 | 0:2d0c91de9279 | 166 | |
j3 | 0:2d0c91de9279 | 167 | ///Multi-LED Mode Control Register BitField |
j3 | 0:2d0c91de9279 | 168 | union ModeControlReg_u |
j3 | 0:2d0c91de9279 | 169 | { |
j3 | 0:2d0c91de9279 | 170 | uint8_t all; |
j3 | 0:2d0c91de9279 | 171 | struct BitField_s |
j3 | 0:2d0c91de9279 | 172 | { |
j3 | 0:2d0c91de9279 | 173 | uint8_t lo_slot : 3; |
j3 | 0:2d0c91de9279 | 174 | uint8_t reserved1 : 1; |
j3 | 0:2d0c91de9279 | 175 | uint8_t hi_slot : 3; |
j3 | 0:2d0c91de9279 | 176 | uint8_t reserved2 : 1; |
j3 | 0:2d0c91de9279 | 177 | }bits; |
j3 | 0:2d0c91de9279 | 178 | }; |
j3 | 0:2d0c91de9279 | 179 | |
j3 | 0:2d0c91de9279 | 180 | /** |
j3 | 0:2d0c91de9279 | 181 | * @brief Constructor using I2C PinNames |
j3 | 0:2d0c91de9279 | 182 | * @param sda - Pinname for sda |
j3 | 0:2d0c91de9279 | 183 | * @param scl - Pinname for scl |
j3 | 0:2d0c91de9279 | 184 | */ |
j3 | 0:2d0c91de9279 | 185 | MAX30101(PinName sda, PinName scl); |
j3 | 0:2d0c91de9279 | 186 | |
j3 | 0:2d0c91de9279 | 187 | /** |
j3 | 0:2d0c91de9279 | 188 | * @brief Constructor using reference to I2C object |
j3 | 0:2d0c91de9279 | 189 | * @param i2c - Reference to I2C object |
j3 | 0:2d0c91de9279 | 190 | */ |
j3 | 0:2d0c91de9279 | 191 | MAX30101(I2C &i2c); |
j3 | 0:2d0c91de9279 | 192 | |
j3 | 0:2d0c91de9279 | 193 | /** @brief Destructor */ |
j3 | 0:2d0c91de9279 | 194 | ~MAX30101(); |
j3 | 0:2d0c91de9279 | 195 | |
j3 | 0:2d0c91de9279 | 196 | /** |
j3 | 0:2d0c91de9279 | 197 | * @brief Writes appropriate bits to Interrupt Enable 1 and 2. |
j3 | 0:2d0c91de9279 | 198 | * |
j3 | 0:2d0c91de9279 | 199 | * @param data - Interrupts to enable |
j3 | 0:2d0c91de9279 | 200 | * @return 0 on success, non 0 otherwise |
j3 | 0:2d0c91de9279 | 201 | */ |
j3 | 0:2d0c91de9279 | 202 | int32_t enableInterrupts(const InterruptBitField_u data); |
j3 | 0:2d0c91de9279 | 203 | |
j3 | 0:2d0c91de9279 | 204 | /** |
j3 | 0:2d0c91de9279 | 205 | * @brief Reads interrupt status flags from Interrupt Status 1 and 2. |
j3 | 0:2d0c91de9279 | 206 | * |
j3 | 0:2d0c91de9279 | 207 | * @param[out] data - Contains interrupts status flags on success. |
j3 | 0:2d0c91de9279 | 208 | * @return 0 on success, non 0 otherwise |
j3 | 0:2d0c91de9279 | 209 | */ |
j3 | 0:2d0c91de9279 | 210 | int32_t getInterruptStatus(InterruptBitField_u &data); |
j3 | 0:2d0c91de9279 | 211 | |
j3 | 0:2d0c91de9279 | 212 | /** |
j3 | 0:2d0c91de9279 | 213 | * @brief Writes FIFO configuration register with given data |
j3 | 0:2d0c91de9279 | 214 | * |
j3 | 0:2d0c91de9279 | 215 | * @param config - FIFO Configuration |
j3 | 0:2d0c91de9279 | 216 | * @return 0 on success, non 0 otherwise |
j3 | 0:2d0c91de9279 | 217 | */ |
j3 | 0:2d0c91de9279 | 218 | int32_t setFIFOConfiguration(const FIFO_Configuration_u config); |
j3 | 0:2d0c91de9279 | 219 | |
j3 | 0:2d0c91de9279 | 220 | /** |
j3 | 0:2d0c91de9279 | 221 | * @brief Reads FIFO configuration register |
j3 | 0:2d0c91de9279 | 222 | * |
j3 | 0:2d0c91de9279 | 223 | * @param[out] config - FIFO Configuration on success |
j3 | 0:2d0c91de9279 | 224 | * @return 0 on success, non 0 otherwise |
j3 | 0:2d0c91de9279 | 225 | */ |
j3 | 0:2d0c91de9279 | 226 | int32_t getFIFOConfiguration(FIFO_Configuration_u &config); |
j3 | 0:2d0c91de9279 | 227 | |
j3 | 0:2d0c91de9279 | 228 | /** |
j3 | 0:2d0c91de9279 | 229 | * @brief Writes Mode configuration register with given data |
j3 | 0:2d0c91de9279 | 230 | * |
j3 | 0:2d0c91de9279 | 231 | * @param config - Mode Configuration |
j3 | 0:2d0c91de9279 | 232 | * @return 0 on success, non 0 otherwise |
j3 | 0:2d0c91de9279 | 233 | */ |
j3 | 0:2d0c91de9279 | 234 | int32_t setModeConfiguration(const ModeConfiguration_u config); |
j3 | 0:2d0c91de9279 | 235 | |
j3 | 0:2d0c91de9279 | 236 | /** |
j3 | 0:2d0c91de9279 | 237 | * @brief Reads Mode configuration register |
j3 | 0:2d0c91de9279 | 238 | * |
j3 | 0:2d0c91de9279 | 239 | * @param[out] config - Mode Configuration on success |
j3 | 0:2d0c91de9279 | 240 | * @return 0 on success, non 0 otherwise |
j3 | 0:2d0c91de9279 | 241 | */ |
j3 | 0:2d0c91de9279 | 242 | int32_t getModeConfiguration(ModeConfiguration_u &config); |
j3 | 0:2d0c91de9279 | 243 | |
j3 | 0:2d0c91de9279 | 244 | /** |
j3 | 0:2d0c91de9279 | 245 | * @brief Writes SpO2 configuration register with given data |
j3 | 0:2d0c91de9279 | 246 | * |
j3 | 0:2d0c91de9279 | 247 | * @param config - SpO2 Configuration |
j3 | 0:2d0c91de9279 | 248 | * @return 0 on success, non 0 otherwise |
j3 | 0:2d0c91de9279 | 249 | */ |
j3 | 0:2d0c91de9279 | 250 | int32_t setSpO2Configuration(const SpO2Configuration_u config); |
j3 | 0:2d0c91de9279 | 251 | |
j3 | 0:2d0c91de9279 | 252 | /** |
j3 | 0:2d0c91de9279 | 253 | * @brief Reads SpO2 configuration register |
j3 | 0:2d0c91de9279 | 254 | * |
j3 | 0:2d0c91de9279 | 255 | * @param[out] config - SpO2 Configuration on success |
j3 | 0:2d0c91de9279 | 256 | * @return 0 on success, non 0 otherwise |
j3 | 0:2d0c91de9279 | 257 | */ |
j3 | 0:2d0c91de9279 | 258 | int32_t getSpO2Configuration(SpO2Configuration_u &config); |
j3 | 0:2d0c91de9279 | 259 | |
j3 | 0:2d0c91de9279 | 260 | /** |
j3 | 0:2d0c91de9279 | 261 | * @brief Writes LEDx/Prox Pulse Amplitude register with given data |
j3 | 0:2d0c91de9279 | 262 | * |
j3 | 0:2d0c91de9279 | 263 | * @param reg - LEDx/Prox Pulse Amplitude register to write |
j3 | 0:2d0c91de9279 | 264 | * @param amp - LED pulse amplitude |
j3 | 0:2d0c91de9279 | 265 | * @return 0 on success, non 0 otherwise |
j3 | 0:2d0c91de9279 | 266 | */ |
j3 | 0:2d0c91de9279 | 267 | int32_t setLEDPulseAmplitude(Registers_e reg, const uint8_t amp); |
j3 | 0:2d0c91de9279 | 268 | |
j3 | 0:2d0c91de9279 | 269 | /** |
j3 | 0:2d0c91de9279 | 270 | * @brief Reads LEDx/Prox Pulse Amplitude register |
j3 | 0:2d0c91de9279 | 271 | * |
j3 | 0:2d0c91de9279 | 272 | * @param reg - LEDx/Prox Pulse Amplitude register to read |
j3 | 0:2d0c91de9279 | 273 | * @param[out] amp - LED pulse amplitude on success |
j3 | 0:2d0c91de9279 | 274 | * @return 0 on success, non 0 otherwise |
j3 | 0:2d0c91de9279 | 275 | */ |
j3 | 0:2d0c91de9279 | 276 | int32_t getLEDPulseAmplitude(Registers_e reg, uint8_t &); |
j3 | 0:2d0c91de9279 | 277 | |
j3 | 0:2d0c91de9279 | 278 | /** |
j3 | 0:2d0c91de9279 | 279 | * @brief Writes Multi-LED Mode Control Register |
j3 | 0:2d0c91de9279 | 280 | * |
j3 | 0:2d0c91de9279 | 281 | * @param reg - Multi-LED Mode Control register 1 or 2 |
j3 | 0:2d0c91de9279 | 282 | * @param data - Data to write to register |
j3 | 0:2d0c91de9279 | 283 | * @return 0 on success, non 0 otherwise |
j3 | 0:2d0c91de9279 | 284 | */ |
j3 | 0:2d0c91de9279 | 285 | int32_t setMultiLEDModeControl(Registers_e reg, const ModeControlReg_u data); |
j3 | 0:2d0c91de9279 | 286 | |
j3 | 0:2d0c91de9279 | 287 | /** |
j3 | 0:2d0c91de9279 | 288 | * @brief Reads Multi-LED Mode Control Register |
j3 | 0:2d0c91de9279 | 289 | * |
j3 | 0:2d0c91de9279 | 290 | * @param reg - Multi-LED Mode Control register 1 or 2 |
j3 | 0:2d0c91de9279 | 291 | * @param[out] data - Data read from register on success |
j3 | 0:2d0c91de9279 | 292 | * @return 0 on success, non 0 otherwise |
j3 | 0:2d0c91de9279 | 293 | */ |
j3 | 0:2d0c91de9279 | 294 | int32_t getMultiLEDModeControl(Registers_e reg, ModeControlReg_u &data); |
j3 | 0:2d0c91de9279 | 295 | |
j3 | 0:2d0c91de9279 | 296 | /** |
j3 | 2:0db1f3bec727 | 297 | * @brief Gets raw die temperature, interrupt must be enabled |
j3 | 0:2d0c91de9279 | 298 | * |
j3 | 0:2d0c91de9279 | 299 | * @param[out] data - Raw die temperature on success |
j3 | 0:2d0c91de9279 | 300 | * |
j3 | 0:2d0c91de9279 | 301 | * @return 0 on success, non 0 otherwise |
j3 | 0:2d0c91de9279 | 302 | */ |
j3 | 0:2d0c91de9279 | 303 | int32_t getDieTemperature(uint16_t &data); |
j3 | 0:2d0c91de9279 | 304 | |
j3 | 0:2d0c91de9279 | 305 | /** |
j3 | 2:0db1f3bec727 | 306 | * @brief Gets die temperature in celsius, interrupt must be enabled |
j3 | 0:2d0c91de9279 | 307 | * |
j3 | 0:2d0c91de9279 | 308 | * @param[out] data - Die temperature in celsius on success |
j3 | 0:2d0c91de9279 | 309 | * |
j3 | 0:2d0c91de9279 | 310 | * @return 0 on success, non 0 otherwise |
j3 | 0:2d0c91de9279 | 311 | */ |
j3 | 0:2d0c91de9279 | 312 | int32_t getDieTemperatureC(float &data); |
j3 | 0:2d0c91de9279 | 313 | |
j3 | 0:2d0c91de9279 | 314 | /** |
j3 | 0:2d0c91de9279 | 315 | * @brief Converts celsius to Fahrenheit |
j3 | 0:2d0c91de9279 | 316 | * |
j3 | 0:2d0c91de9279 | 317 | * @param c - Temperature in celsius |
j3 | 0:2d0c91de9279 | 318 | * |
j3 | 0:2d0c91de9279 | 319 | * @return Temperature in Fahrenheit |
j3 | 0:2d0c91de9279 | 320 | */ |
j3 | 0:2d0c91de9279 | 321 | float celsius2fahrenheit(float c); |
j3 | 0:2d0c91de9279 | 322 | |
j3 | 0:2d0c91de9279 | 323 | /** |
j3 | 0:2d0c91de9279 | 324 | * @brief Writes Proximity Interrupt Threshold Register |
j3 | 0:2d0c91de9279 | 325 | * |
j3 | 0:2d0c91de9279 | 326 | * @param data - Data to write to register |
j3 | 0:2d0c91de9279 | 327 | * @return 0 on success, non 0 otherwise |
j3 | 0:2d0c91de9279 | 328 | */ |
j3 | 0:2d0c91de9279 | 329 | int32_t setProxIntThreshold(const uint8_t data); |
j3 | 0:2d0c91de9279 | 330 | |
j3 | 0:2d0c91de9279 | 331 | /** |
j3 | 0:2d0c91de9279 | 332 | * @brief Reads Proximity Interrupt Threshold Register |
j3 | 0:2d0c91de9279 | 333 | * |
j3 | 0:2d0c91de9279 | 334 | * @param data - Data read on success |
j3 | 0:2d0c91de9279 | 335 | * @return 0 on success, non 0 otherwise |
j3 | 0:2d0c91de9279 | 336 | */ |
j3 | 0:2d0c91de9279 | 337 | int32_t getProxIntThreshold(uint8_t &data); |
j3 | 3:a2effad05c99 | 338 | |
j3 | 3:a2effad05c99 | 339 | /** |
j3 | 4:d1b50bd4065a | 340 | * @brief Attempts to read FIFO |
j3 | 3:a2effad05c99 | 341 | * |
j3 | 3:a2effad05c99 | 342 | * @param numLeds - Number of LED channels used; 0 < numLeds < 4 |
j3 | 3:a2effad05c99 | 343 | * @param data - pointer to buffer for holding read data |
j3 | 3:a2effad05c99 | 344 | * @param[out] readBytes - number of bytes read from fifo |
j3 | 3:a2effad05c99 | 345 | * |
j3 | 3:a2effad05c99 | 346 | * @return 0 on success, non 0 otherwise |
j3 | 3:a2effad05c99 | 347 | */ |
j3 | 3:a2effad05c99 | 348 | int32_t readFIFO(uint8_t numLeds, uint8_t *data, uint16_t &readBytes); |
j3 | 0:2d0c91de9279 | 349 | |
j3 | 0:2d0c91de9279 | 350 | protected: |
j3 | 0:2d0c91de9279 | 351 | |
j3 | 0:2d0c91de9279 | 352 | /** |
j3 | 0:2d0c91de9279 | 353 | * @brief Write register of device |
j3 | 0:2d0c91de9279 | 354 | * @param reg - Register address |
j3 | 0:2d0c91de9279 | 355 | * @param value - Value to write |
j3 | 0:2d0c91de9279 | 356 | * @return 0 on success, non-zero on failure |
j3 | 0:2d0c91de9279 | 357 | */ |
j3 | 0:2d0c91de9279 | 358 | int32_t writeRegister(Registers_e reg, uint8_t value); |
j3 | 0:2d0c91de9279 | 359 | |
j3 | 0:2d0c91de9279 | 360 | /** |
j3 | 0:2d0c91de9279 | 361 | * @brief Read register of device |
j3 | 0:2d0c91de9279 | 362 | * @param reg - Register address |
j3 | 0:2d0c91de9279 | 363 | * @param[out] value - Read data on success |
j3 | 0:2d0c91de9279 | 364 | * @return 0 on success, non-zero on failure |
j3 | 0:2d0c91de9279 | 365 | */ |
j3 | 0:2d0c91de9279 | 366 | int32_t readRegister(Registers_e reg, uint8_t &value); |
j3 | 0:2d0c91de9279 | 367 | |
j3 | 0:2d0c91de9279 | 368 | private: |
j3 | 0:2d0c91de9279 | 369 | |
j3 | 0:2d0c91de9279 | 370 | I2C m_i2cBus; |
j3 | 3:a2effad05c99 | 371 | uint8_t m_fifoReadPtr, m_fifoWritePtr, m_fifoNumBytes; |
j3 | 3:a2effad05c99 | 372 | |
j3 | 0:2d0c91de9279 | 373 | |
j3 | 0:2d0c91de9279 | 374 | }; |
j3 | 0:2d0c91de9279 | 375 | |
j3 | 0:2d0c91de9279 | 376 | #endif /* __MAX30101_H_ */ |
j3 | 0:2d0c91de9279 | 377 |