MAX32620HSP (MAXREFDES100) RPC Example for Graphical User Interface

Dependencies:   USBDevice

Fork of HSP_Release by Jerry Bradshaw

This is an example program for the MAX32620HSP (MAXREFDES100 Health Sensor Platform). It demonstrates all the features of the platform and works with a companion graphical user interface (GUI) to help evaluate/configure/monitor the board. Go to the MAXREFDES100 product page and click on "design resources" to download the companion software. The GUI connects to the board through an RPC interface on a virtual serial port over the USB interface.

The RPC interface provides access to all the features of the board and is available to interface with other development environments such Matlab. This firmware provides realtime data streaming through the RPC interface over USB, and also provides the ability to log the data to flash for untethered battery operation. The data logging settings are configured through the GUI, and the GUI also provides the interface to download logged data.

Details on the RPC interface can be found here: HSP RPC Interface Documentation

Windows

With this program loaded, the MAX32620HSP will appear on your computer as a serial port. On Mac and Linux, this will happen by default. For Windows, you need to install a driver: HSP serial port windows driver

For more details about this platform and how to use it, see the MAXREFDES100 product page.

Committer:
jbradshaw
Date:
Fri Apr 21 12:12:30 2017 -0500
Revision:
1:9490836294ea
Parent:
0:e4a10ed6eb92
Flash device is now fully utilized for datalog of sensor data

Who changed what in which revision?

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