Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MAX30205/MAX30205.h@12:2ad10c36f820, 2019-11-11 (annotated)
- Committer:
- AhmadAlkaff
- Date:
- Mon Nov 11 17:38:48 2019 +0000
- Revision:
- 12:2ad10c36f820
- Parent:
- 0:7b5d37ca532f
Code Cleanup
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| AhmadAlkaff | 0:7b5d37ca532f | 1 | /******************************************************************************* |
| AhmadAlkaff | 0:7b5d37ca532f | 2 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
| AhmadAlkaff | 0:7b5d37ca532f | 3 | * |
| AhmadAlkaff | 0:7b5d37ca532f | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| AhmadAlkaff | 0:7b5d37ca532f | 5 | * copy of this software and associated documentation files (the "Software"), |
| AhmadAlkaff | 0:7b5d37ca532f | 6 | * to deal in the Software without restriction, including without limitation |
| AhmadAlkaff | 0:7b5d37ca532f | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| AhmadAlkaff | 0:7b5d37ca532f | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| AhmadAlkaff | 0:7b5d37ca532f | 9 | * Software is furnished to do so, subject to the following conditions: |
| AhmadAlkaff | 0:7b5d37ca532f | 10 | * |
| AhmadAlkaff | 0:7b5d37ca532f | 11 | * The above copyright notice and this permission notice shall be included |
| AhmadAlkaff | 0:7b5d37ca532f | 12 | * in all copies or substantial portions of the Software. |
| AhmadAlkaff | 0:7b5d37ca532f | 13 | * |
| AhmadAlkaff | 0:7b5d37ca532f | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| AhmadAlkaff | 0:7b5d37ca532f | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| AhmadAlkaff | 0:7b5d37ca532f | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| AhmadAlkaff | 0:7b5d37ca532f | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
| AhmadAlkaff | 0:7b5d37ca532f | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| AhmadAlkaff | 0:7b5d37ca532f | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| AhmadAlkaff | 0:7b5d37ca532f | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| AhmadAlkaff | 0:7b5d37ca532f | 21 | * |
| AhmadAlkaff | 0:7b5d37ca532f | 22 | * Except as contained in this notice, the name of Maxim Integrated |
| AhmadAlkaff | 0:7b5d37ca532f | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
| AhmadAlkaff | 0:7b5d37ca532f | 24 | * Products, Inc. Branding Policy. |
| AhmadAlkaff | 0:7b5d37ca532f | 25 | * |
| AhmadAlkaff | 0:7b5d37ca532f | 26 | * The mere transfer of this software does not imply any licenses |
| AhmadAlkaff | 0:7b5d37ca532f | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
| AhmadAlkaff | 0:7b5d37ca532f | 28 | * trademarks, maskwork rights, or any other form of intellectual |
| AhmadAlkaff | 0:7b5d37ca532f | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
| AhmadAlkaff | 0:7b5d37ca532f | 30 | * ownership rights. |
| AhmadAlkaff | 0:7b5d37ca532f | 31 | ******************************************************************************* |
| AhmadAlkaff | 0:7b5d37ca532f | 32 | */ |
| AhmadAlkaff | 0:7b5d37ca532f | 33 | #ifndef __MAX30205_H_ |
| AhmadAlkaff | 0:7b5d37ca532f | 34 | #define __MAX30205_H_ |
| AhmadAlkaff | 0:7b5d37ca532f | 35 | |
| AhmadAlkaff | 0:7b5d37ca532f | 36 | #include "mbed.h" |
| AhmadAlkaff | 0:7b5d37ca532f | 37 | |
| AhmadAlkaff | 0:7b5d37ca532f | 38 | /** |
| AhmadAlkaff | 0:7b5d37ca532f | 39 | * @brief Driver for the MAX30205 on the HSP Platform |
| AhmadAlkaff | 0:7b5d37ca532f | 40 | */ |
| AhmadAlkaff | 0:7b5d37ca532f | 41 | |
| AhmadAlkaff | 0:7b5d37ca532f | 42 | class MAX30205 { |
| AhmadAlkaff | 0:7b5d37ca532f | 43 | public: |
| AhmadAlkaff | 0:7b5d37ca532f | 44 | ///< MAX30205 Register Addresses |
| AhmadAlkaff | 0:7b5d37ca532f | 45 | typedef enum Registers { |
| AhmadAlkaff | 0:7b5d37ca532f | 46 | MAX30205_Temperature = 0x00, |
| AhmadAlkaff | 0:7b5d37ca532f | 47 | MAX30205_Configuration = 0x01, |
| AhmadAlkaff | 0:7b5d37ca532f | 48 | MAX30205_THYST = 0x02, |
| AhmadAlkaff | 0:7b5d37ca532f | 49 | MAX30205_TOS = 0x03 |
| AhmadAlkaff | 0:7b5d37ca532f | 50 | } Registers_t; |
| AhmadAlkaff | 0:7b5d37ca532f | 51 | |
| AhmadAlkaff | 0:7b5d37ca532f | 52 | /** |
| AhmadAlkaff | 0:7b5d37ca532f | 53 | * @brief Constructor using I2C PinNames |
| AhmadAlkaff | 0:7b5d37ca532f | 54 | * @param sda Pinname for sda |
| AhmadAlkaff | 0:7b5d37ca532f | 55 | * @param scl Pinname for scl |
| AhmadAlkaff | 0:7b5d37ca532f | 56 | */ |
| AhmadAlkaff | 0:7b5d37ca532f | 57 | MAX30205(PinName sda, PinName scl, int slaveAddress); |
| AhmadAlkaff | 0:7b5d37ca532f | 58 | /** |
| AhmadAlkaff | 0:7b5d37ca532f | 59 | * @brief Constructor using pointer to I2C object |
| AhmadAlkaff | 0:7b5d37ca532f | 60 | * @param *i2c Pointer to I2C object |
| AhmadAlkaff | 0:7b5d37ca532f | 61 | */ |
| AhmadAlkaff | 0:7b5d37ca532f | 62 | MAX30205(I2C *i2c, int slaveAddress); |
| AhmadAlkaff | 0:7b5d37ca532f | 63 | |
| AhmadAlkaff | 0:7b5d37ca532f | 64 | /** @brief Destructor */ |
| AhmadAlkaff | 0:7b5d37ca532f | 65 | ~MAX30205(void); |
| AhmadAlkaff | 0:7b5d37ca532f | 66 | |
| AhmadAlkaff | 0:7b5d37ca532f | 67 | /** @brief Write a register into device at slave address |
| AhmadAlkaff | 0:7b5d37ca532f | 68 | * @param reg register address |
| AhmadAlkaff | 0:7b5d37ca532f | 69 | * @param value value to write |
| AhmadAlkaff | 0:7b5d37ca532f | 70 | */ |
| AhmadAlkaff | 0:7b5d37ca532f | 71 | int reg_write(char reg, char value); |
| AhmadAlkaff | 0:7b5d37ca532f | 72 | |
| AhmadAlkaff | 0:7b5d37ca532f | 73 | /** |
| AhmadAlkaff | 0:7b5d37ca532f | 74 | * @brief Detect the second instance of the MAX30205 |
| AhmadAlkaff | 0:7b5d37ca532f | 75 | * @param reg register address |
| AhmadAlkaff | 0:7b5d37ca532f | 76 | * @param value 8-bit value to writes |
| AhmadAlkaff | 0:7b5d37ca532f | 77 | */ |
| AhmadAlkaff | 0:7b5d37ca532f | 78 | int reg_read(char reg, char *value); |
| AhmadAlkaff | 0:7b5d37ca532f | 79 | |
| AhmadAlkaff | 0:7b5d37ca532f | 80 | /** |
| AhmadAlkaff | 0:7b5d37ca532f | 81 | * @brief Write a 16-bit value into device at slave address |
| AhmadAlkaff | 0:7b5d37ca532f | 82 | * @param reg register address |
| AhmadAlkaff | 0:7b5d37ca532f | 83 | * @param value 16-bit value to write |
| AhmadAlkaff | 0:7b5d37ca532f | 84 | */ |
| AhmadAlkaff | 0:7b5d37ca532f | 85 | int reg_write16(char reg, uint16_t value); |
| AhmadAlkaff | 0:7b5d37ca532f | 86 | |
| AhmadAlkaff | 0:7b5d37ca532f | 87 | /** |
| AhmadAlkaff | 0:7b5d37ca532f | 88 | * @brief Read a 16-bit value from a device at a slave address |
| AhmadAlkaff | 0:7b5d37ca532f | 89 | * @param reg register address |
| AhmadAlkaff | 0:7b5d37ca532f | 90 | * @param value pointer to store read value |
| AhmadAlkaff | 0:7b5d37ca532f | 91 | */ |
| AhmadAlkaff | 0:7b5d37ca532f | 92 | int reg_read16(char reg, uint16_t *value); |
| AhmadAlkaff | 0:7b5d37ca532f | 93 | |
| AhmadAlkaff | 0:7b5d37ca532f | 94 | /** |
| AhmadAlkaff | 0:7b5d37ca532f | 95 | * @brief Read the temperature from the device into a 16 bit value |
| AhmadAlkaff | 0:7b5d37ca532f | 96 | * @param value pointer to a 16 bit short |
| AhmadAlkaff | 0:7b5d37ca532f | 97 | */ |
| AhmadAlkaff | 0:7b5d37ca532f | 98 | int readTemperature(uint16_t *value); |
| AhmadAlkaff | 0:7b5d37ca532f | 99 | |
| AhmadAlkaff | 0:7b5d37ca532f | 100 | /** |
| AhmadAlkaff | 0:7b5d37ca532f | 101 | * @brief Read the THYST value from a specified device instance |
| AhmadAlkaff | 0:7b5d37ca532f | 102 | * @param value 16-bit pointer of value to read into |
| AhmadAlkaff | 0:7b5d37ca532f | 103 | */ |
| AhmadAlkaff | 0:7b5d37ca532f | 104 | int reg_THYST_Read(uint16_t *value); |
| AhmadAlkaff | 0:7b5d37ca532f | 105 | |
| AhmadAlkaff | 0:7b5d37ca532f | 106 | /** |
| AhmadAlkaff | 0:7b5d37ca532f | 107 | * @brief Write the THYST to a device instance |
| AhmadAlkaff | 0:7b5d37ca532f | 108 | * @param value 16-bit value to write |
| AhmadAlkaff | 0:7b5d37ca532f | 109 | */ |
| AhmadAlkaff | 0:7b5d37ca532f | 110 | int reg_THYST_Write(uint16_t value); |
| AhmadAlkaff | 0:7b5d37ca532f | 111 | |
| AhmadAlkaff | 0:7b5d37ca532f | 112 | /** |
| AhmadAlkaff | 0:7b5d37ca532f | 113 | * @brief Convert a raw temperature value into a float |
| AhmadAlkaff | 0:7b5d37ca532f | 114 | * @param rawTemp raw temperature value to convert |
| AhmadAlkaff | 0:7b5d37ca532f | 115 | * @return the convereted value in degrees C |
| AhmadAlkaff | 0:7b5d37ca532f | 116 | */ |
| AhmadAlkaff | 0:7b5d37ca532f | 117 | float toCelsius(unsigned int rawTemp); |
| AhmadAlkaff | 0:7b5d37ca532f | 118 | |
| AhmadAlkaff | 0:7b5d37ca532f | 119 | /** |
| AhmadAlkaff | 0:7b5d37ca532f | 120 | * @brief Convert the passed in temperature in C to Fahrenheit |
| AhmadAlkaff | 0:7b5d37ca532f | 121 | * @param temperatureC Temperature in C to convert |
| AhmadAlkaff | 0:7b5d37ca532f | 122 | * @returns Returns the converted Fahrenheit value |
| AhmadAlkaff | 0:7b5d37ca532f | 123 | */ |
| AhmadAlkaff | 0:7b5d37ca532f | 124 | float toFahrenheit(float temperatureC); |
| AhmadAlkaff | 0:7b5d37ca532f | 125 | |
| AhmadAlkaff | 0:7b5d37ca532f | 126 | private: |
| AhmadAlkaff | 0:7b5d37ca532f | 127 | /** |
| AhmadAlkaff | 0:7b5d37ca532f | 128 | * @brief I2C pointer |
| AhmadAlkaff | 0:7b5d37ca532f | 129 | */ |
| AhmadAlkaff | 0:7b5d37ca532f | 130 | I2C *i2c; |
| AhmadAlkaff | 0:7b5d37ca532f | 131 | /** |
| AhmadAlkaff | 0:7b5d37ca532f | 132 | * @brief Is this object the owner of the I2C object |
| AhmadAlkaff | 0:7b5d37ca532f | 133 | */ |
| AhmadAlkaff | 0:7b5d37ca532f | 134 | bool isOwner; |
| AhmadAlkaff | 0:7b5d37ca532f | 135 | /** |
| AhmadAlkaff | 0:7b5d37ca532f | 136 | * @brief Device slave address |
| AhmadAlkaff | 0:7b5d37ca532f | 137 | */ |
| AhmadAlkaff | 0:7b5d37ca532f | 138 | int slaveAddress; |
| AhmadAlkaff | 0:7b5d37ca532f | 139 | }; |
| AhmadAlkaff | 0:7b5d37ca532f | 140 | |
| AhmadAlkaff | 0:7b5d37ca532f | 141 | #endif /* __MAX30205_H_ */ |
