Example for using the MAX1472 RF Transmitter for low power data transmission.

Dependencies:   mbed-dev2 max32630fthr USBDevice

Committer:
tlyp
Date:
Fri Sep 04 20:41:34 2020 +0000
Revision:
4:2e3db197b7e2
Parent:
2:33b3b46a9c0d
Cleaned up header

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tlyp 2:33b3b46a9c0d 1 /*******************************************************************************
tlyp 2:33b3b46a9c0d 2 * Copyright (C) Maxim Integrated Products, Inc., All Rights Reserved.
tlyp 2:33b3b46a9c0d 3 *
tlyp 2:33b3b46a9c0d 4 * Permission is hereby granted, free of charge, to any person obtaining a
tlyp 2:33b3b46a9c0d 5 * copy of this software and associated documentation files (the "Software"),
tlyp 2:33b3b46a9c0d 6 * to deal in the Software without restriction, including without limitation
tlyp 2:33b3b46a9c0d 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
tlyp 2:33b3b46a9c0d 8 * and/or sell copies of the Software, and to permit persons to whom the
tlyp 2:33b3b46a9c0d 9 * Software is furnished to do so, subject to the following conditions:
tlyp 2:33b3b46a9c0d 10 *
tlyp 2:33b3b46a9c0d 11 * The above copyright notice and this permission notice shall be included
tlyp 2:33b3b46a9c0d 12 * in all copies or substantial portions of the Software.
tlyp 2:33b3b46a9c0d 13 *
tlyp 2:33b3b46a9c0d 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
tlyp 2:33b3b46a9c0d 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
tlyp 2:33b3b46a9c0d 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
tlyp 2:33b3b46a9c0d 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
tlyp 2:33b3b46a9c0d 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
tlyp 2:33b3b46a9c0d 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
tlyp 2:33b3b46a9c0d 20 * OTHER DEALINGS IN THE SOFTWARE.
tlyp 2:33b3b46a9c0d 21 *
tlyp 2:33b3b46a9c0d 22 * Except as contained in this notice, the name of Maxim Integrated
tlyp 2:33b3b46a9c0d 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
tlyp 2:33b3b46a9c0d 24 * Products, Inc. Branding Policy.
tlyp 2:33b3b46a9c0d 25 *
tlyp 2:33b3b46a9c0d 26 * The mere transfer of this software does not imply any licenses
tlyp 2:33b3b46a9c0d 27 * of trade secrets, proprietary technology, copyrights, patents,
tlyp 2:33b3b46a9c0d 28 * trademarks, maskwork rights, or any other form of intellectual
tlyp 2:33b3b46a9c0d 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
tlyp 2:33b3b46a9c0d 30 * ownership rights.
tlyp 2:33b3b46a9c0d 31 *******************************************************************************
tlyp 2:33b3b46a9c0d 32 * @file MAX30208.h
tlyp 2:33b3b46a9c0d 33 * @brief This is the header file used for the MAX30208 human body temperature sensor library.
tlyp 2:33b3b46a9c0d 34 * @version 1.0
tlyp 2:33b3b46a9c0d 35 * @notes This file needs to be imported along with MAX30208.cpp for the program to work properly. This is library containing basic functions to be used in conjunction with the MAX30208. This library does not support any other devices. This is an MBed tested library.
tlyp 2:33b3b46a9c0d 36 *****************************************************************************/
tlyp 2:33b3b46a9c0d 37
tlyp 2:33b3b46a9c0d 38 #ifndef __MAX30208_H_
tlyp 2:33b3b46a9c0d 39 #define __MAX30208_H_
tlyp 2:33b3b46a9c0d 40
tlyp 2:33b3b46a9c0d 41 #include "mbed.h"
tlyp 2:33b3b46a9c0d 42
tlyp 2:33b3b46a9c0d 43 /**
tlyp 2:33b3b46a9c0d 44 * @brief Library for the MAX30208
tlyp 2:33b3b46a9c0d 45 *
tlyp 2:33b3b46a9c0d 46 * @code
tlyp 2:33b3b46a9c0d 47 * #include "mbed.h"
tlyp 2:33b3b46a9c0d 48 * #include "max32630fthr.h"
tlyp 2:33b3b46a9c0d 49 * #include "MAX30208.h"
tlyp 2:33b3b46a9c0d 50 *
tlyp 2:33b3b46a9c0d 51 * MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
tlyp 2:33b3b46a9c0d 52 *
tlyp 2:33b3b46a9c0d 53 * //Get I2C instance
tlyp 2:33b3b46a9c0d 54 * I2C i2cBus(I2C1_SDA, I2C1_SCL);
tlyp 2:33b3b46a9c0d 55 *
tlyp 2:33b3b46a9c0d 56 * //Get temp sensor instance
tlyp 2:33b3b46a9c0d 57 * MAX30208 BodyTempSensor(i2cBus, 0x50); //Constructor takes 7-bit slave adress. 0x50 is default slave address for MAX30208 Ev-Kit
tlyp 2:33b3b46a9c0d 58 *
tlyp 2:33b3b46a9c0d 59 * int main(void)
tlyp 2:33b3b46a9c0d 60 * {
tlyp 2:33b3b46a9c0d 61 * //use sensor
tlyp 2:33b3b46a9c0d 62 * }
tlyp 2:33b3b46a9c0d 63 * @endcode
tlyp 2:33b3b46a9c0d 64 */
tlyp 2:33b3b46a9c0d 65
tlyp 2:33b3b46a9c0d 66 class MAX30208
tlyp 2:33b3b46a9c0d 67 {
tlyp 2:33b3b46a9c0d 68
tlyp 2:33b3b46a9c0d 69 public:
tlyp 2:33b3b46a9c0d 70 /// MAX30208 Register Addresses
tlyp 2:33b3b46a9c0d 71 enum Registers_e {
tlyp 2:33b3b46a9c0d 72 Status = 0x00,
tlyp 2:33b3b46a9c0d 73 Interrupt_Enable = 0x01,
tlyp 2:33b3b46a9c0d 74 FIFO_Write_Pointer = 0x04,
tlyp 2:33b3b46a9c0d 75 FIFO_Read_Pointer = 0x05,
tlyp 2:33b3b46a9c0d 76 FIFO_Overflow_Counter = 0x06,
tlyp 2:33b3b46a9c0d 77 FIFO_Data_Counter = 0x07,
tlyp 2:33b3b46a9c0d 78 FIFO_Data = 0x08,
tlyp 2:33b3b46a9c0d 79 FIFO_Config1 = 0x09,
tlyp 2:33b3b46a9c0d 80 FIFO_Config2 = 0x0A,
tlyp 2:33b3b46a9c0d 81 System_Control = 0x0C,
tlyp 2:33b3b46a9c0d 82 Alarm_High_MSB = 0x10,
tlyp 2:33b3b46a9c0d 83 Alarm_Low_MSB = 0x12,
tlyp 2:33b3b46a9c0d 84 Temp_Sensor_Setup = 0x14,
tlyp 2:33b3b46a9c0d 85 GPIO_Setup = 0x20,
tlyp 2:33b3b46a9c0d 86 GPIO_Control = 0x21
tlyp 2:33b3b46a9c0d 87 };
tlyp 2:33b3b46a9c0d 88
tlyp 2:33b3b46a9c0d 89 //Intterupt Register Config
tlyp 2:33b3b46a9c0d 90 union Configuration_InterruptEnable{
tlyp 2:33b3b46a9c0d 91 uint8_t all;
tlyp 2:33b3b46a9c0d 92 struct BitField_s{
tlyp 2:33b3b46a9c0d 93 uint8_t TEMP_RDY_EN : 1;
tlyp 2:33b3b46a9c0d 94 uint8_t TEMP_HI_EN : 1;
tlyp 2:33b3b46a9c0d 95 uint8_t TEMP_LO_EN : 1;
tlyp 2:33b3b46a9c0d 96 uint8_t : 4; //unused bits
tlyp 2:33b3b46a9c0d 97 uint8_t A_FULL_EN : 1;
tlyp 2:33b3b46a9c0d 98 }config;
tlyp 2:33b3b46a9c0d 99 };
tlyp 2:33b3b46a9c0d 100
tlyp 2:33b3b46a9c0d 101 //FIFO Config 2 Register
tlyp 2:33b3b46a9c0d 102 union Configuration_FIFOConfig2{
tlyp 2:33b3b46a9c0d 103 uint8_t all;
tlyp 2:33b3b46a9c0d 104 struct BitField_s{
tlyp 2:33b3b46a9c0d 105 uint8_t : 1; //unused bit
tlyp 2:33b3b46a9c0d 106 uint8_t FIFO_RO : 1;
tlyp 2:33b3b46a9c0d 107 uint8_t A_FULL_TYPE : 1;
tlyp 2:33b3b46a9c0d 108 uint8_t FIFO_STAT_CLR : 1;
tlyp 2:33b3b46a9c0d 109 uint8_t FLUSH_FIFO : 1;
tlyp 2:33b3b46a9c0d 110 uint8_t : 0; //unused bits
tlyp 2:33b3b46a9c0d 111 }config;
tlyp 2:33b3b46a9c0d 112 };
tlyp 2:33b3b46a9c0d 113
tlyp 2:33b3b46a9c0d 114 //GPIO Setup Register
tlyp 2:33b3b46a9c0d 115 union Configuration_GPIOSetup{
tlyp 2:33b3b46a9c0d 116 uint8_t all;
tlyp 2:33b3b46a9c0d 117 struct BitField_s{
tlyp 2:33b3b46a9c0d 118 uint8_t GPIO0_MODE : 2;
tlyp 2:33b3b46a9c0d 119 uint8_t : 4; //unused bits
tlyp 2:33b3b46a9c0d 120 uint8_t GPIO1_MODE : 2;
tlyp 2:33b3b46a9c0d 121 }config;
tlyp 2:33b3b46a9c0d 122 };
tlyp 2:33b3b46a9c0d 123
tlyp 2:33b3b46a9c0d 124 //GPIO Control Register
tlyp 2:33b3b46a9c0d 125 union Configuration_GPIOControl{
tlyp 2:33b3b46a9c0d 126 uint8_t all;
tlyp 2:33b3b46a9c0d 127 struct BitField_s{
tlyp 2:33b3b46a9c0d 128 uint8_t GPIO0_LL : 1;
tlyp 2:33b3b46a9c0d 129 uint8_t : 2; //unused bits
tlyp 2:33b3b46a9c0d 130 uint8_t GPIO1_LL : 1;
tlyp 2:33b3b46a9c0d 131 uint8_t : 0; //unused bits
tlyp 2:33b3b46a9c0d 132 }config;
tlyp 2:33b3b46a9c0d 133 };
tlyp 2:33b3b46a9c0d 134
tlyp 2:33b3b46a9c0d 135 /**
tlyp 2:33b3b46a9c0d 136 * @brief Constructor using reference to I2C object
tlyp 2:33b3b46a9c0d 137 * @param i2c - Reference to I2C object
tlyp 2:33b3b46a9c0d 138 * @param slaveAddress - 7-bit I2C address
tlyp 2:33b3b46a9c0d 139 */
tlyp 2:33b3b46a9c0d 140 MAX30208(I2C &i2c, uint8_t slaveAddress);
tlyp 2:33b3b46a9c0d 141
tlyp 2:33b3b46a9c0d 142 /** @brief Destructor */
tlyp 2:33b3b46a9c0d 143 ~MAX30208(void);
tlyp 2:33b3b46a9c0d 144
tlyp 2:33b3b46a9c0d 145 /**
tlyp 2:33b3b46a9c0d 146 * @brief Write Interrupt Register
tlyp 2:33b3b46a9c0d 147 * @param config - Reference to Configuration type, config.all is written upon succesful register write
tlyp 2:33b3b46a9c0d 148 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 149 */
tlyp 2:33b3b46a9c0d 150 int32_t writeInterruptRegister(Configuration_InterruptEnable config);
tlyp 2:33b3b46a9c0d 151
tlyp 2:33b3b46a9c0d 152 /**
tlyp 2:33b3b46a9c0d 153 * @brief Read Interrupt Register Configuration
tlyp 2:33b3b46a9c0d 154 * @param config - Reference to Configuration type, config.all is updated upon succesful register read
tlyp 2:33b3b46a9c0d 155 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 156 */
tlyp 2:33b3b46a9c0d 157 int32_t readInterruptRegister(Configuration_InterruptEnable &config);
tlyp 2:33b3b46a9c0d 158
tlyp 2:33b3b46a9c0d 159 /**
tlyp 2:33b3b46a9c0d 160 * @brief Read Status Register
tlyp 2:33b3b46a9c0d 161 * @param[out] value - Status Register Value on succesful read
tlyp 2:33b3b46a9c0d 162 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 163 */
tlyp 2:33b3b46a9c0d 164 int32_t readStatus(uint16_t &value);
tlyp 2:33b3b46a9c0d 165
tlyp 2:33b3b46a9c0d 166 /**
tlyp 2:33b3b46a9c0d 167 * @brief Read FIFO Write Pointer Value
tlyp 2:33b3b46a9c0d 168 * @param[out] value - FIFO Write Pointer value on succesful read
tlyp 2:33b3b46a9c0d 169 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 170 */
tlyp 2:33b3b46a9c0d 171 int32_t readWritePointer(uint16_t &value);
tlyp 2:33b3b46a9c0d 172
tlyp 2:33b3b46a9c0d 173 /**
tlyp 2:33b3b46a9c0d 174 * @brief Read FIFO Read Pointer Value
tlyp 2:33b3b46a9c0d 175 * @param[out] value - FIFO Read Pointer value on succesful read
tlyp 2:33b3b46a9c0d 176 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 177 */
tlyp 2:33b3b46a9c0d 178 int32_t readReadPointer(uint16_t &value);
tlyp 2:33b3b46a9c0d 179
tlyp 2:33b3b46a9c0d 180 /**
tlyp 2:33b3b46a9c0d 181 * @brief Write FIFO Read Pointer Value
tlyp 2:33b3b46a9c0d 182 * @param config - New FIFO Read Pointer value on succesful write
tlyp 2:33b3b46a9c0d 183 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 184 */
tlyp 2:33b3b46a9c0d 185 int32_t writeReadPointer(uint8_t config);
tlyp 2:33b3b46a9c0d 186
tlyp 2:33b3b46a9c0d 187 /**
tlyp 2:33b3b46a9c0d 188 * @brief Read FIFO Overflow Register
tlyp 2:33b3b46a9c0d 189 * @param[out] value - Overflow Counter value on succesful read
tlyp 2:33b3b46a9c0d 190 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 191 */
tlyp 2:33b3b46a9c0d 192 int32_t readOverflow(uint16_t &value);
tlyp 2:33b3b46a9c0d 193
tlyp 2:33b3b46a9c0d 194 /**
tlyp 2:33b3b46a9c0d 195 * @brief Read Data Counter Register
tlyp 2:33b3b46a9c0d 196 * @param[out] value - Data Count register value on succesful read
tlyp 2:33b3b46a9c0d 197 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 198 */
tlyp 2:33b3b46a9c0d 199 int32_t readDataCounter(uint16_t &value);
tlyp 2:33b3b46a9c0d 200
tlyp 2:33b3b46a9c0d 201 /**
tlyp 2:33b3b46a9c0d 202 * @brief Read FIFO Data at FIFO Read Pointer
tlyp 2:33b3b46a9c0d 203 * @param[out] value - Temperature value from FIFO data register on succesful read
tlyp 2:33b3b46a9c0d 204 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 205 */
tlyp 2:33b3b46a9c0d 206 int32_t readData(uint16_t &value);
tlyp 2:33b3b46a9c0d 207
tlyp 2:33b3b46a9c0d 208 /**
tlyp 2:33b3b46a9c0d 209 * @brief Take a new temperature reading
tlyp 2:33b3b46a9c0d 210 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 211 */
tlyp 2:33b3b46a9c0d 212 int32_t takeDataMeasurment();
tlyp 2:33b3b46a9c0d 213
tlyp 2:33b3b46a9c0d 214 /**
tlyp 2:33b3b46a9c0d 215 * @brief Read FIFO Config1 Register
tlyp 2:33b3b46a9c0d 216 * @param[out] value - FIFO Config1 value on succesful read
tlyp 2:33b3b46a9c0d 217 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 218 */
tlyp 2:33b3b46a9c0d 219 int32_t readFIFOConfig1(uint16_t &value);
tlyp 2:33b3b46a9c0d 220
tlyp 2:33b3b46a9c0d 221 /**
tlyp 2:33b3b46a9c0d 222 * @brief Write FIFO Config1 register
tlyp 2:33b3b46a9c0d 223 * @param config - FIFO Config1 register data to write
tlyp 2:33b3b46a9c0d 224 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 225 */
tlyp 2:33b3b46a9c0d 226 int32_t writeFIFOConfig1(uint8_t config);
tlyp 2:33b3b46a9c0d 227
tlyp 2:33b3b46a9c0d 228 /**
tlyp 2:33b3b46a9c0d 229 * @brief Read FIFO Config2 register
tlyp 2:33b3b46a9c0d 230 * @param[out] config - Reference to Configuration type, config.all is updated upon succesful register read
tlyp 2:33b3b46a9c0d 231 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 232 */
tlyp 2:33b3b46a9c0d 233 int32_t readFIFOConfig2(Configuration_FIFOConfig2 &config);
tlyp 2:33b3b46a9c0d 234
tlyp 2:33b3b46a9c0d 235 /**
tlyp 2:33b3b46a9c0d 236 * @brief Read FIFO Config2 register
tlyp 2:33b3b46a9c0d 237 * @param config - Reference to Configuration type, config.all is written upon succesful register write
tlyp 2:33b3b46a9c0d 238 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 239 */
tlyp 2:33b3b46a9c0d 240 int32_t writeFIFOConfig2(Configuration_FIFOConfig2 config);
tlyp 2:33b3b46a9c0d 241
tlyp 2:33b3b46a9c0d 242 /**
tlyp 2:33b3b46a9c0d 243 * @brief Reset Device to factory default
tlyp 2:33b3b46a9c0d 244 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 245 */
tlyp 2:33b3b46a9c0d 246 int32_t resetDevice(); //set bit 0 in system register to 1 to factory reset
tlyp 2:33b3b46a9c0d 247
tlyp 2:33b3b46a9c0d 248 /**
tlyp 2:33b3b46a9c0d 249 * @brief Read High Temperature Alarm Value
tlyp 2:33b3b46a9c0d 250 * @param[out] temp - High Temperature Alarm Value
tlyp 2:33b3b46a9c0d 251 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 252 */
tlyp 2:33b3b46a9c0d 253 int32_t readAlarmHigh(uint16_t &temp);
tlyp 2:33b3b46a9c0d 254
tlyp 2:33b3b46a9c0d 255 /**
tlyp 2:33b3b46a9c0d 256 * @brief Write High Temperature Alarm Value
tlyp 2:33b3b46a9c0d 257 * @param temp - 16-bit High Temperature Value to Write
tlyp 2:33b3b46a9c0d 258 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 259 */
tlyp 2:33b3b46a9c0d 260 int32_t writeAlarmHigh(uint16_t temp);
tlyp 2:33b3b46a9c0d 261
tlyp 2:33b3b46a9c0d 262 /**
tlyp 2:33b3b46a9c0d 263 * @brief Read Low Temperature Alarm Value
tlyp 2:33b3b46a9c0d 264 * @param[out] temp - Low Temperature Alarm Value
tlyp 2:33b3b46a9c0d 265 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 266 */
tlyp 2:33b3b46a9c0d 267 int32_t readAlarmLow(uint16_t &value);
tlyp 2:33b3b46a9c0d 268
tlyp 2:33b3b46a9c0d 269 /**
tlyp 2:33b3b46a9c0d 270 * @brief Write Low Temperature Alarm Value
tlyp 2:33b3b46a9c0d 271 * @param temp - 16-bit Low Temperature Value to Write
tlyp 2:33b3b46a9c0d 272 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 273 */
tlyp 2:33b3b46a9c0d 274 int32_t writeAlarmLow(uint16_t temp);
tlyp 2:33b3b46a9c0d 275
tlyp 2:33b3b46a9c0d 276 /**
tlyp 2:33b3b46a9c0d 277 * @brief Read GPIO Setup register
tlyp 2:33b3b46a9c0d 278 * @param config - Reference to Configuration type, config.all is updated upon succesful register read
tlyp 2:33b3b46a9c0d 279 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 280 */
tlyp 2:33b3b46a9c0d 281 int32_t readGPIOSetup(Configuration_GPIOSetup &config);
tlyp 2:33b3b46a9c0d 282
tlyp 2:33b3b46a9c0d 283 /**
tlyp 2:33b3b46a9c0d 284 * @brief Write GPIO Setup register
tlyp 2:33b3b46a9c0d 285 * @param config - Reference to Configuration type, config.all is written to register upon succesful register write
tlyp 2:33b3b46a9c0d 286 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 287 */
tlyp 2:33b3b46a9c0d 288 int32_t writeGPIOSetup(Configuration_GPIOSetup config);
tlyp 2:33b3b46a9c0d 289
tlyp 2:33b3b46a9c0d 290 /**
tlyp 2:33b3b46a9c0d 291 * @brief Read GPIO Control register
tlyp 2:33b3b46a9c0d 292 * @param config - Reference to Configuration type, config.all is updated upon succesful register read
tlyp 2:33b3b46a9c0d 293 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 294 */
tlyp 2:33b3b46a9c0d 295 int32_t readGPIOControl(Configuration_GPIOControl &config);
tlyp 2:33b3b46a9c0d 296
tlyp 2:33b3b46a9c0d 297 /**
tlyp 2:33b3b46a9c0d 298 * @brief Write GPIO Control register
tlyp 2:33b3b46a9c0d 299 * @param config - Reference to Configuration type, config.all is written to register upon succesful register write
tlyp 2:33b3b46a9c0d 300 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 301 */
tlyp 2:33b3b46a9c0d 302 int32_t writeGPIOControl(Configuration_GPIOControl config);
tlyp 2:33b3b46a9c0d 303
tlyp 2:33b3b46a9c0d 304 /**
tlyp 2:33b3b46a9c0d 305 * @brief Convert Raw Sensor Data to degrees Celisus
tlyp 2:33b3b46a9c0d 306 * @param rawTemp - 16 bit raw temperature data
tlyp 2:33b3b46a9c0d 307 * @return Returns the converted Celsius Temperature
tlyp 2:33b3b46a9c0d 308 */
tlyp 2:33b3b46a9c0d 309 float toCelsius(uint16_t rawTemp);
tlyp 2:33b3b46a9c0d 310
tlyp 2:33b3b46a9c0d 311 /**
tlyp 2:33b3b46a9c0d 312 * @brief Convert Celsius Temperature to Fahrenheit
tlyp 2:33b3b46a9c0d 313 * @param temperatureC - Temperature in degrees Celsius that will be converted
tlyp 2:33b3b46a9c0d 314 * @return Returns the converted Fahrenheit temperature
tlyp 2:33b3b46a9c0d 315 */
tlyp 2:33b3b46a9c0d 316 float toFahrenheit(float temperatureC);
tlyp 2:33b3b46a9c0d 317
tlyp 2:33b3b46a9c0d 318 protected:
tlyp 2:33b3b46a9c0d 319
tlyp 2:33b3b46a9c0d 320 /**
tlyp 2:33b3b46a9c0d 321 * @brief Write register of device at slave address
tlyp 2:33b3b46a9c0d 322 * @param reg - char array that contains address of register and write value
tlyp 2:33b3b46a9c0d 323 * @param value - Data written to register on sucessful write
tlyp 2:33b3b46a9c0d 324 * @param bytesWritten - Number of bytes to write
tlyp 2:33b3b46a9c0d 325 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 326 */
tlyp 2:33b3b46a9c0d 327 int32_t writeRegister(Registers_e reg, uint16_t value, int bytesWritten);
tlyp 2:33b3b46a9c0d 328 /**
tlyp 2:33b3b46a9c0d 329 * @brief Read register of device at slave address
tlyp 2:33b3b46a9c0d 330 * @param reg - Register address
tlyp 2:33b3b46a9c0d 331 * @param[out] value - Read data on successful read
tlyp 2:33b3b46a9c0d 332 * @param bytesRead - Number of bytes to read
tlyp 2:33b3b46a9c0d 333 * @return 0 on success, non-zero on failure
tlyp 2:33b3b46a9c0d 334 */
tlyp 2:33b3b46a9c0d 335 int32_t readRegister(Registers_e reg, uint16_t &value, int bytesRead);
tlyp 2:33b3b46a9c0d 336
tlyp 2:33b3b46a9c0d 337 private:
tlyp 2:33b3b46a9c0d 338 /// I2C object
tlyp 2:33b3b46a9c0d 339 I2C & m_i2c;
tlyp 2:33b3b46a9c0d 340 /// Device slave addresses
tlyp 2:33b3b46a9c0d 341 uint8_t m_writeAddress, m_readAddress;
tlyp 2:33b3b46a9c0d 342 };
tlyp 2:33b3b46a9c0d 343
tlyp 2:33b3b46a9c0d 344 #endif /* __MAX30208_H_ */