Maxim Integrated MAX30205 C, C++ source code driver software: MAX30205 is accurate to +-0.1°C over the range of 37.0°C to 39.0°C. One-shot, shutdown modes are available for reduced power usage. Thermostat thresholds allow for temperature hysteresis or for alarm settings. The MAX30205 is available in a compact 3x3 mm, 8-pin TDFN package. Operating supply voltage range is 2.7V to 3.3V. Typical applications are for clinical digital thermometers, thermostats with hysteresis, and temperature alarms.
Dependents: MAX30205_Human_Body_Temperature_Sensor
max30205_cpp.h@10:9c5dc1393570, 2019-04-17 (annotated)
- Committer:
- phonemacro
- Date:
- Wed Apr 17 21:13:54 2019 +0000
- Revision:
- 10:9c5dc1393570
- Parent:
- 9:d98e4a80a866
Updated comments
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
phonemacro | 9:d98e4a80a866 | 1 | /******************************************************************************* |
phonemacro | 9:d98e4a80a866 | 2 | * Copyright (C) 2019 Maxim Integrated Products, Inc., All Rights Reserved. |
phonemacro | 9:d98e4a80a866 | 3 | * |
phonemacro | 9:d98e4a80a866 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
phonemacro | 9:d98e4a80a866 | 5 | * copy of this software and associated documentation files (the "Software"), |
phonemacro | 9:d98e4a80a866 | 6 | * to deal in the Software without restriction, including without limitation |
phonemacro | 9:d98e4a80a866 | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
phonemacro | 9:d98e4a80a866 | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
phonemacro | 9:d98e4a80a866 | 9 | * Software is furnished to do so, subject to the following conditions: |
phonemacro | 9:d98e4a80a866 | 10 | * |
phonemacro | 9:d98e4a80a866 | 11 | * The above copyright notice and this permission notice shall be included |
phonemacro | 9:d98e4a80a866 | 12 | * in all copies or substantial portions of the Software. |
phonemacro | 9:d98e4a80a866 | 13 | * |
phonemacro | 9:d98e4a80a866 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
phonemacro | 9:d98e4a80a866 | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
phonemacro | 9:d98e4a80a866 | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
phonemacro | 9:d98e4a80a866 | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
phonemacro | 9:d98e4a80a866 | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
phonemacro | 9:d98e4a80a866 | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
phonemacro | 9:d98e4a80a866 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
phonemacro | 9:d98e4a80a866 | 21 | * |
phonemacro | 9:d98e4a80a866 | 22 | * Except as contained in this notice, the name of Maxim Integrated |
phonemacro | 9:d98e4a80a866 | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
phonemacro | 9:d98e4a80a866 | 24 | * Products, Inc. Branding Policy. |
phonemacro | 9:d98e4a80a866 | 25 | * |
phonemacro | 9:d98e4a80a866 | 26 | * The mere transfer of this software does not imply any licenses |
phonemacro | 9:d98e4a80a866 | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
phonemacro | 9:d98e4a80a866 | 28 | * trademarks, maskwork rights, or any other form of intellectual |
phonemacro | 9:d98e4a80a866 | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
phonemacro | 9:d98e4a80a866 | 30 | * ownership rights. |
phonemacro | 9:d98e4a80a866 | 31 | ******************************************************************************* |
phonemacro | 9:d98e4a80a866 | 32 | * @file max30205_cpp.h |
phonemacro | 9:d98e4a80a866 | 33 | ******************************************************************************* |
phonemacro | 9:d98e4a80a866 | 34 | */ |
phonemacro | 9:d98e4a80a866 | 35 | #ifndef MAX30205_CPP_H |
phonemacro | 9:d98e4a80a866 | 36 | #define MAX30205_CPP_H |
phonemacro | 9:d98e4a80a866 | 37 | #include "mbed.h" |
phonemacro | 9:d98e4a80a866 | 38 | |
phonemacro | 9:d98e4a80a866 | 39 | |
phonemacro | 9:d98e4a80a866 | 40 | /** |
phonemacro | 9:d98e4a80a866 | 41 | * @brief Digital thermometer, thermostat, temperature sensor. |
phonemacro | 9:d98e4a80a866 | 42 | * @version 1.0001.0000 |
phonemacro | 9:d98e4a80a866 | 43 | * |
phonemacro | 10:9c5dc1393570 | 44 | * @details The MAX30205 temperature sensors |
phonemacro | 10:9c5dc1393570 | 45 | * provides accurate temperature measurements of +-0.1°C |
phonemacro | 10:9c5dc1393570 | 46 | * over the range of 37°C to 39°C (98.6°F to 102.2°F) |
phonemacro | 9:d98e4a80a866 | 47 | * The MAX30205 can operate in a low powered mode by utilizing |
phonemacro | 9:d98e4a80a866 | 48 | * the shutdown and one-shot mode. |
phonemacro | 9:d98e4a80a866 | 49 | * 8-pin TQDFN 3x3 mm package |
phonemacro | 10:9c5dc1393570 | 50 | * Operating temperature: 0°C to 50°C (+32°F to +122°). |
phonemacro | 10:9c5dc1393570 | 51 | * VDD: 2.7V to 3.7V. |
phonemacro | 9:d98e4a80a866 | 52 | * |
phonemacro | 9:d98e4a80a866 | 53 | * @code |
phonemacro | 9:d98e4a80a866 | 54 | * #include "mbed.h" |
phonemacro | 9:d98e4a80a866 | 55 | * #include "max32630fthr.h" |
phonemacro | 9:d98e4a80a866 | 56 | * #include "max30205.h" |
phonemacro | 10:9c5dc1393570 | 57 | * #include "max30205_cpp.h" |
phonemacro | 10:9c5dc1393570 | 58 | * #include "max30205_c.h" |
phonemacro | 9:d98e4a80a866 | 59 | * #include "USBSerial.h" |
phonemacro | 10:9c5dc1393570 | 60 | * Serial pc(USBTX, USBRX); // Use USB debug probe for serial link |
phonemacro | 10:9c5dc1393570 | 61 | * Serial uart(P2_1, P2_0); |
phonemacro | 10:9c5dc1393570 | 62 | * void wait_sec_prompt(uint8_t time) |
phonemacro | 10:9c5dc1393570 | 63 | * { |
phonemacro | 10:9c5dc1393570 | 64 | * // Ports and serial connections |
phonemacro | 10:9c5dc1393570 | 65 | * uint32_t i; |
phonemacro | 10:9c5dc1393570 | 66 | * for (i = 0; i < time; i++) { |
phonemacro | 10:9c5dc1393570 | 67 | * pc.printf("."); |
phonemacro | 10:9c5dc1393570 | 68 | * wait(1); |
phonemacro | 10:9c5dc1393570 | 69 | * } |
phonemacro | 10:9c5dc1393570 | 70 | * pc.printf("\r\n"); |
phonemacro | 10:9c5dc1393570 | 71 | * } |
phonemacro | 9:d98e4a80a866 | 72 | * MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); |
phonemacro | 10:9c5dc1393570 | 73 | * DigitalOut rLED(LED1); |
phonemacro | 10:9c5dc1393570 | 74 | * DigitalOut gLED(LED2); |
phonemacro | 10:9c5dc1393570 | 75 | * DigitalOut bLED(LED3); |
phonemacro | 10:9c5dc1393570 | 76 | * I2C i2cBus(P3_4, P3_5) |
phonemacro | 9:d98e4a80a866 | 77 | * int main() |
phonemacro | 9:d98e4a80a866 | 78 | * { |
phonemacro | 10:9c5dc1393570 | 79 | * uint8_t i2c_addr = MAX30205_I2C_SLAVE_ADR_00; |
phonemacro | 9:d98e4a80a866 | 80 | * float temperature; |
phonemacro | 9:d98e4a80a866 | 81 | * DigitalOut rLED(LED1, LED_OFF); |
phonemacro | 9:d98e4a80a866 | 82 | * DigitalOut gLED(LED2, LED_OFF); |
phonemacro | 9:d98e4a80a866 | 83 | * DigitalOut bLED(LED3, LED_OFF); |
phonemacro | 9:d98e4a80a866 | 84 | * gLED = LED_ON; |
phonemacro | 10:9c5dc1393570 | 85 | * MAX30205 temp_sensor(i2cBus, i2c_addr); |
phonemacro | 9:d98e4a80a866 | 86 | * i2cBus.frequency(400000); |
phonemacro | 10:9c5dc1393570 | 87 | * temperature = |
phonemacro | 10:9c5dc1393570 | 88 | * temp_sensor.read_reg_as_temperature(MAX30205_REG_TEMPERATURE); |
phonemacro | 10:9c5dc1393570 | 89 | * pc.printf("Temperature = %3.4f Celsius, %3.4f Fahrenheit\r\n", |
phonemacro | 10:9c5dc1393570 | 90 | * temperature, temp_sensor.celsius_to_fahrenheit(temperature)); |
phonemacro | 9:d98e4a80a866 | 91 | * } |
phonemacro | 9:d98e4a80a866 | 92 | * @endcode |
phonemacro | 9:d98e4a80a866 | 93 | */ |
phonemacro | 9:d98e4a80a866 | 94 | |
phonemacro | 9:d98e4a80a866 | 95 | class MAX30205 |
phonemacro | 9:d98e4a80a866 | 96 | { |
phonemacro | 9:d98e4a80a866 | 97 | public: |
phonemacro | 9:d98e4a80a866 | 98 | |
phonemacro | 9:d98e4a80a866 | 99 | /**********************************************************//** |
phonemacro | 9:d98e4a80a866 | 100 | * @brief Constructor for MAX30205 Class. |
phonemacro | 9:d98e4a80a866 | 101 | * |
phonemacro | 9:d98e4a80a866 | 102 | * @details Allows user to use existing I2C object |
phonemacro | 9:d98e4a80a866 | 103 | * |
phonemacro | 9:d98e4a80a866 | 104 | * On Entry: |
phonemacro | 9:d98e4a80a866 | 105 | * @param[in] i2c_bus - pointer to existing I2C object |
phonemacro | 9:d98e4a80a866 | 106 | * @param[in] i2c_adrs - 7-bit slave address of MAX30205 |
phonemacro | 9:d98e4a80a866 | 107 | * |
phonemacro | 9:d98e4a80a866 | 108 | * On Exit: |
phonemacro | 9:d98e4a80a866 | 109 | * |
phonemacro | 9:d98e4a80a866 | 110 | * @return None |
phonemacro | 9:d98e4a80a866 | 111 | **************************************************************/ |
phonemacro | 9:d98e4a80a866 | 112 | MAX30205(I2C &i2c_bus, uint8_t slave_address); |
phonemacro | 9:d98e4a80a866 | 113 | |
phonemacro | 9:d98e4a80a866 | 114 | /**********************************************************//** |
phonemacro | 9:d98e4a80a866 | 115 | * @brief Default destructor for MAX30205 Class. |
phonemacro | 9:d98e4a80a866 | 116 | * |
phonemacro | 9:d98e4a80a866 | 117 | * @details Destroys I2C object if owner |
phonemacro | 9:d98e4a80a866 | 118 | * |
phonemacro | 9:d98e4a80a866 | 119 | * On Entry: |
phonemacro | 9:d98e4a80a866 | 120 | * |
phonemacro | 9:d98e4a80a866 | 121 | * On Exit: |
phonemacro | 9:d98e4a80a866 | 122 | * |
phonemacro | 9:d98e4a80a866 | 123 | * @return None |
phonemacro | 9:d98e4a80a866 | 124 | **************************************************************/ |
phonemacro | 9:d98e4a80a866 | 125 | ~MAX30205(); |
phonemacro | 9:d98e4a80a866 | 126 | |
phonemacro | 9:d98e4a80a866 | 127 | /** |
phonemacro | 9:d98e4a80a866 | 128 | * @brief Read register of device at slave address |
phonemacro | 9:d98e4a80a866 | 129 | * @param[out] value - Read data on success |
phonemacro | 9:d98e4a80a866 | 130 | * @return 0 on success, negative number on failure |
phonemacro | 9:d98e4a80a866 | 131 | */ |
phonemacro | 9:d98e4a80a866 | 132 | int read_cfg_reg(uint8_t *value); |
phonemacro | 9:d98e4a80a866 | 133 | |
phonemacro | 9:d98e4a80a866 | 134 | /** |
phonemacro | 9:d98e4a80a866 | 135 | * @brief Read register of device at slave address |
phonemacro | 9:d98e4a80a866 | 136 | * @param[out] value - Read data on success |
phonemacro | 9:d98e4a80a866 | 137 | * @param reg - Register address |
phonemacro | 9:d98e4a80a866 | 138 | * @return 0 on success, negative number on failure |
phonemacro | 9:d98e4a80a866 | 139 | */ |
phonemacro | 9:d98e4a80a866 | 140 | int read_reg16(int16_t *value, char reg); |
phonemacro | 9:d98e4a80a866 | 141 | |
phonemacro | 9:d98e4a80a866 | 142 | /** |
phonemacro | 9:d98e4a80a866 | 143 | * @brief Reads the temperature registers |
phonemacro | 9:d98e4a80a866 | 144 | * @param reg - the address of the temperature register |
phonemacro | 9:d98e4a80a866 | 145 | * @return temperature in degrees Celsius |
phonemacro | 9:d98e4a80a866 | 146 | */ |
phonemacro | 9:d98e4a80a866 | 147 | float read_reg_as_temperature(uint8_t reg); |
phonemacro | 9:d98e4a80a866 | 148 | |
phonemacro | 9:d98e4a80a866 | 149 | /** |
phonemacro | 9:d98e4a80a866 | 150 | * @brief Writes to the configuration register |
phonemacro | 9:d98e4a80a866 | 151 | * @param cfg - configurate word |
phonemacro | 9:d98e4a80a866 | 152 | * @return 0 on success, negative number on failure |
phonemacro | 9:d98e4a80a866 | 153 | */ |
phonemacro | 9:d98e4a80a866 | 154 | int write_cfg_reg(uint8_t cfg); |
phonemacro | 9:d98e4a80a866 | 155 | |
phonemacro | 9:d98e4a80a866 | 156 | /** |
phonemacro | 9:d98e4a80a866 | 157 | * @brief Writes to the THYST register |
phonemacro | 9:d98e4a80a866 | 158 | * @param temperature - the temperature in Celsius degrees |
phonemacro | 9:d98e4a80a866 | 159 | * @return 0 on success, negative number on failure |
phonemacro | 9:d98e4a80a866 | 160 | */ |
phonemacro | 9:d98e4a80a866 | 161 | int write_trip_low_thyst(float temperature); |
phonemacro | 9:d98e4a80a866 | 162 | |
phonemacro | 9:d98e4a80a866 | 163 | /** |
phonemacro | 9:d98e4a80a866 | 164 | * @brief Writes to the TOS register |
phonemacro | 9:d98e4a80a866 | 165 | * @param temperature - the temperature in Celsius degrees |
phonemacro | 9:d98e4a80a866 | 166 | * @return 0 on success, negative number on failure |
phonemacro | 9:d98e4a80a866 | 167 | */ |
phonemacro | 9:d98e4a80a866 | 168 | int write_trip_high_tos(float temperature); |
phonemacro | 9:d98e4a80a866 | 169 | |
phonemacro | 9:d98e4a80a866 | 170 | /** |
phonemacro | 9:d98e4a80a866 | 171 | * @brief Converts Celsius degrees to Fahrenheit |
phonemacro | 9:d98e4a80a866 | 172 | * @param temp_c - the temperature in Celsius degrees |
phonemacro | 9:d98e4a80a866 | 173 | * @return temperature in Celsius degrees |
phonemacro | 9:d98e4a80a866 | 174 | */ |
phonemacro | 9:d98e4a80a866 | 175 | float celsius_to_fahrenheit(float temp_c); |
phonemacro | 9:d98e4a80a866 | 176 | |
phonemacro | 9:d98e4a80a866 | 177 | protected: |
phonemacro | 9:d98e4a80a866 | 178 | /** |
phonemacro | 9:d98e4a80a866 | 179 | * @brief Write a value to a register |
phonemacro | 9:d98e4a80a866 | 180 | * @param value - value to write to the register |
phonemacro | 9:d98e4a80a866 | 181 | * @param reg - register address |
phonemacro | 9:d98e4a80a866 | 182 | * @return 0 on success, negative number on failure |
phonemacro | 9:d98e4a80a866 | 183 | */ |
phonemacro | 9:d98e4a80a866 | 184 | int write_reg16(int16_t value, char reg); |
phonemacro | 9:d98e4a80a866 | 185 | |
phonemacro | 9:d98e4a80a866 | 186 | private: |
phonemacro | 9:d98e4a80a866 | 187 | /** @var m_i2c |
phonemacro | 9:d98e4a80a866 | 188 | * @brief I2C object |
phonemacro | 9:d98e4a80a866 | 189 | */ |
phonemacro | 9:d98e4a80a866 | 190 | I2C &m_i2c; |
phonemacro | 9:d98e4a80a866 | 191 | /** @var m_write_address, m_read_address |
phonemacro | 9:d98e4a80a866 | 192 | * @brief I2C address |
phonemacro | 9:d98e4a80a866 | 193 | */ |
phonemacro | 9:d98e4a80a866 | 194 | uint8_t m_write_address, m_read_address; |
phonemacro | 9:d98e4a80a866 | 195 | /** @var m_extended_format |
phonemacro | 9:d98e4a80a866 | 196 | * @brief Extended format, add 64°C to the temperature reading |
phonemacro | 9:d98e4a80a866 | 197 | */ |
phonemacro | 9:d98e4a80a866 | 198 | uint32_t max30205_extended_format; |
phonemacro | 9:d98e4a80a866 | 199 | |
phonemacro | 9:d98e4a80a866 | 200 | }; |
phonemacro | 9:d98e4a80a866 | 201 | |
phonemacro | 10:9c5dc1393570 | 202 | #endif/* MAX30205_CPP */ |