MAX32620HSP (MAXREFDES100) RPC Example for Graphical User Interface

Dependencies:   USBDevice

Fork of HSP_Release by Jerry Bradshaw

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MAX30205.h Source File

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  * @brief Driver for the MAX30205 on the HSP Platform
00040  */
00041 
00042 class MAX30205 {
00043 public:
00044   ///< MAX30205 Register Addresses
00045   typedef enum Registers {
00046     MAX30205_Temperature   = 0x00,
00047     MAX30205_Configuration = 0x01,
00048     MAX30205_THYST         = 0x02,
00049     MAX30205_TOS           = 0x03
00050   } Registers_t;
00051 
00052   /**
00053   * @brief  Constructor using I2C PinNames
00054   * @param sda Pinname for sda
00055   * @param scl Pinname for scl
00056   */
00057   MAX30205(PinName sda, PinName scl, int slaveAddress);
00058   /**
00059   * @brief  Constructor using pointer to I2C object
00060   * @param *i2c Pointer to I2C object
00061   */
00062   MAX30205(I2C *i2c, int slaveAddress);
00063 
00064   /** @brief Destructor */
00065   ~MAX30205(void);
00066 
00067   /** @brief Write a register into device at slave address
00068   * @param reg register address
00069   * @param value value to write
00070   */
00071   int reg_write(char reg, char value);
00072 
00073   /**
00074   * @brief  Detect the second instance of the MAX30205
00075   * @param reg register address
00076   * @param value 8-bit value to writes
00077   */
00078   int reg_read(char reg, char *value);
00079 
00080   /**
00081   * @brief Write a 16-bit value into device at slave address
00082   * @param reg register address
00083   * @param value 16-bit value to write
00084   */
00085   int reg_write16(char reg, uint16_t value);
00086 
00087   /**
00088   * @brief Read a 16-bit value from a device at a slave address
00089   * @param reg register address
00090   * @param value pointer to store read value
00091   */
00092   int reg_read16(char reg, uint16_t *value);
00093 
00094   /**
00095   * @brief Read the temperature from the device into a 16 bit value
00096   * @param value pointer to a 16 bit short
00097   */
00098   int readTemperature(uint16_t *value);
00099 
00100   /**
00101   * @brief Read the THYST value from a specified device instance
00102   * @param value 16-bit pointer of value to read into
00103   */
00104   int reg_THYST_Read(uint16_t *value);
00105 
00106   /**
00107   * @brief Write the THYST to a device instance
00108   * @param value 16-bit value to write
00109   */
00110   int reg_THYST_Write(uint16_t value);
00111 
00112   /**
00113   * @brief Convert a raw temperature value into a float
00114   * @param rawTemp raw temperature value to convert
00115   * @return the convereted value in degrees C
00116   */
00117   float toCelsius(unsigned int rawTemp);
00118 
00119   /**
00120   * @brief Convert the passed in temperature in C to Fahrenheit
00121   * @param temperatureC Temperature in C to convert
00122   * @returns Returns the converted Fahrenheit value
00123   */
00124   float toFahrenheit(float temperatureC);
00125 
00126 private:
00127   /**
00128    * @brief I2C pointer
00129    */
00130   I2C *i2c;
00131   /**
00132    * @brief Is this object the owner of the I2C object
00133    */
00134   bool isOwner;
00135   /**
00136    * @brief Device slave address
00137    */
00138   int slaveAddress;
00139 };
00140 
00141 #endif /* __MAX30205_H_ */