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.
Fork of mbed-os-test by
MAX30205.h
00001 /******************************************************************************* 00002 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a 00005 * copy of this software and associated documentation files (the "Software"), 00006 * to deal in the Software without restriction, including without limitation 00007 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00008 * and/or sell copies of the Software, and to permit persons to whom the 00009 * Software is furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included 00012 * in all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00015 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00016 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00017 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES 00018 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00019 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00020 * OTHER DEALINGS IN THE SOFTWARE. 00021 * 00022 * Except as contained in this notice, the name of Maxim Integrated 00023 * Products, Inc. shall not be used except as stated in the Maxim Integrated 00024 * Products, Inc. Branding Policy. 00025 * 00026 * The mere transfer of this software does not imply any licenses 00027 * of trade secrets, proprietary technology, copyrights, patents, 00028 * trademarks, maskwork rights, or any other form of intellectual 00029 * property whatsoever. Maxim Integrated Products, Inc. retains all 00030 * ownership rights. 00031 ******************************************************************************* 00032 */ 00033 #ifndef __MAX30205_H_ 00034 #define __MAX30205_H_ 00035 00036 #include "mbed.h" 00037 00038 /** 00039 * Driver for the MAX30205 on the HSP Platform 00040 * 00041 * @code 00042 * #include <stdio.h> 00043 * #include "mbed.h" 00044 * #include "xxx.h" 00045 * 00046 * I2C i2c(I2C_SDA, I2C_SCL); 00047 * xxx xxx(&i2c); 00048 * 00049 * int main(void) { 00050 * printf("Initialized xxx\n"); 00051 * while(1) { 00052 * if (xxx.init() != 0) { 00053 * printf("Error communicating with xxx\n"); 00054 * } else { 00055 * printf("Initialized xxx\n"); 00056 * break; 00057 * } 00058 * wait(1); 00059 * } 00060 * 00061 * while(1) { 00062 * printf(""); 00063 * wait(1); 00064 * } 00065 * } 00066 * @endcode 00067 */ 00068 00069 class MAX30205 { 00070 public: 00071 /// MAX30205 Register Addresses 00072 typedef enum Registers { 00073 MAX30205_Temperature = 0x00, 00074 MAX30205_Configuration = 0x01, 00075 MAX30205_THYST = 0x02, 00076 MAX30205_TOS = 0x03 00077 }; 00078 00079 /** 00080 * @brief Constructor using I2C PinNames 00081 * @param sda Pinname for sda 00082 * @param scl Pinname for scl 00083 */ 00084 MAX30205(PinName sda, PinName scl, int slaveAddress); 00085 /** 00086 * @brief Constructor using pointer to I2C object 00087 * @param *i2c Pointer to I2C object 00088 */ 00089 MAX30205(I2C *i2c, int slaveAddress); 00090 00091 /** @brief Destructor */ 00092 ~MAX30205(void); 00093 00094 /** @brief Write a register into device at slave address 00095 * @param reg register address 00096 * @param value value to write 00097 */ 00098 int reg_write(char reg, char value); 00099 00100 /** 00101 * @brief Detect the second instance of the MAX30205 00102 * @param reg register address 00103 * @param value 8-bit value to writes 00104 */ 00105 int reg_read(char reg, char *value); 00106 00107 /** 00108 * @brief Write a 16-bit value into device at slave address 00109 * @param reg register address 00110 * @param value 16-bit value to write 00111 */ 00112 int reg_write16(char reg, uint16_t value); 00113 00114 /** 00115 * @brief Read a 16-bit value from a device at a slave address 00116 * @param reg register address 00117 * @param value pointer to store read value 00118 */ 00119 int reg_read16(char reg, uint16_t *value); 00120 00121 /** 00122 * @brief Read the temperature from the device into a 16 bit value 00123 * @param value pointer to a 16 bit short 00124 */ 00125 int readTemperature(uint16_t *value); 00126 00127 /** 00128 * @brief Read the THYST value from a specified device instance 00129 * @param value 16-bit pointer of value to read into 00130 */ 00131 int reg_THYST_Read(uint16_t *value); 00132 00133 /** 00134 * @brief Write the THYST to a device instance 00135 * @param value 16-bit value to write 00136 */ 00137 int reg_THYST_Write(uint16_t value); 00138 00139 /** 00140 * @brief Convert a raw temperature value into a float 00141 * @param rawTemp raw temperature value to convert 00142 * @return the convereted value in degrees C 00143 */ 00144 float toCelsius(unsigned int rawTemp); 00145 00146 /** 00147 * @brief Convert the passed in temperature in C to Fahrenheit 00148 * @param temperatureC Temperature in C to convert 00149 * @returns Returns the converted Fahrenheit value 00150 */ 00151 float toFahrenheit(float temperatureC); 00152 00153 private: 00154 /// I2C pointer 00155 I2C *i2c; 00156 /// Is this object the owner of the I2C object 00157 bool isOwner; 00158 /// Device slave address 00159 int slaveAddress; 00160 }; 00161 00162 #endif /* __MAX30205_H_ */
Generated on Wed Jul 13 2022 17:00:35 by
1.7.2
