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:
Tue Oct 25 15:22:11 2016 +0000
Revision:
0:e4a10ed6eb92
Child:
1:9490836294ea
tewt

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 _LED_H_
jbradshaw 0:e4a10ed6eb92 34 #define _LED_H_
jbradshaw 0:e4a10ed6eb92 35
jbradshaw 0:e4a10ed6eb92 36 #include "mbed.h"
jbradshaw 0:e4a10ed6eb92 37
jbradshaw 0:e4a10ed6eb92 38 /**
jbradshaw 0:e4a10ed6eb92 39 * Driver for the HSP Led, supports different blink rates and patterns
jbradshaw 0:e4a10ed6eb92 40 *
jbradshaw 0:e4a10ed6eb92 41 * @code
jbradshaw 0:e4a10ed6eb92 42 * #include <stdio.h>
jbradshaw 0:e4a10ed6eb92 43 * #include "mbed.h"
jbradshaw 0:e4a10ed6eb92 44 * #include "xxx.h"
jbradshaw 0:e4a10ed6eb92 45 *
jbradshaw 0:e4a10ed6eb92 46 * I2C i2c(I2C_SDA, I2C_SCL);
jbradshaw 0:e4a10ed6eb92 47 * xxx xxx(&i2c);
jbradshaw 0:e4a10ed6eb92 48 *
jbradshaw 0:e4a10ed6eb92 49 * int main(void) {
jbradshaw 0:e4a10ed6eb92 50 * printf("Initialized xxx\n");
jbradshaw 0:e4a10ed6eb92 51 * while(1) {
jbradshaw 0:e4a10ed6eb92 52 * if (xxx.init() != 0) {
jbradshaw 0:e4a10ed6eb92 53 * printf("Error communicating with xxx\n");
jbradshaw 0:e4a10ed6eb92 54 * } else {
jbradshaw 0:e4a10ed6eb92 55 * printf("Initialized xxx\n");
jbradshaw 0:e4a10ed6eb92 56 * break;
jbradshaw 0:e4a10ed6eb92 57 * }
jbradshaw 0:e4a10ed6eb92 58 * wait(1);
jbradshaw 0:e4a10ed6eb92 59 * }
jbradshaw 0:e4a10ed6eb92 60 *
jbradshaw 0:e4a10ed6eb92 61 * while(1) {
jbradshaw 0:e4a10ed6eb92 62 * printf("");
jbradshaw 0:e4a10ed6eb92 63 * wait(1);
jbradshaw 0:e4a10ed6eb92 64 * }
jbradshaw 0:e4a10ed6eb92 65 * }
jbradshaw 0:e4a10ed6eb92 66 * @endcode
jbradshaw 0:e4a10ed6eb92 67 */
jbradshaw 0:e4a10ed6eb92 68
jbradshaw 0:e4a10ed6eb92 69 class HspLed {
jbradshaw 0:e4a10ed6eb92 70 public:
jbradshaw 0:e4a10ed6eb92 71 static const int LED_ON = 0;
jbradshaw 0:e4a10ed6eb92 72 static const int LED_OFF = 1;
jbradshaw 0:e4a10ed6eb92 73
jbradshaw 0:e4a10ed6eb92 74 /// define all of the modes the LED can support
jbradshaw 0:e4a10ed6eb92 75 typedef enum eMode {
jbradshaw 0:e4a10ed6eb92 76 eLedOn,
jbradshaw 0:e4a10ed6eb92 77 eLedOff,
jbradshaw 0:e4a10ed6eb92 78 eLedPeriod,
jbradshaw 0:e4a10ed6eb92 79 eLedPattern
jbradshaw 0:e4a10ed6eb92 80 } eMode;
jbradshaw 0:e4a10ed6eb92 81 /// define the values that turn the LED on or off at the pin
jbradshaw 0:e4a10ed6eb92 82 #define HSP_LED_ON 0
jbradshaw 0:e4a10ed6eb92 83 #define HSP_LED_OFF 1
jbradshaw 0:e4a10ed6eb92 84
jbradshaw 0:e4a10ed6eb92 85 /*
jbradshaw 0:e4a10ed6eb92 86 * @brief Constructor where you specify the LED pin name
jbradshaw 0:e4a10ed6eb92 87 */
jbradshaw 0:e4a10ed6eb92 88 HspLed(PinName ledPin);
jbradshaw 0:e4a10ed6eb92 89
jbradshaw 0:e4a10ed6eb92 90 /**
jbradshaw 0:e4a10ed6eb92 91 * Blink the HSP LED at a set time interval
jbradshaw 0:e4a10ed6eb92 92 * @param mSeconds Number of seconds to set the timer interval
jbradshaw 0:e4a10ed6eb92 93 */
jbradshaw 0:e4a10ed6eb92 94 void blink(uint32_t mSeconds);
jbradshaw 0:e4a10ed6eb92 95
jbradshaw 0:e4a10ed6eb92 96 /**
jbradshaw 0:e4a10ed6eb92 97 * @brief Start rotating the LED through a 32-bit pattern at a mS rate specified
jbradshaw 0:e4a10ed6eb92 98 * @param pattern 32-bit pattern to rotate through
jbradshaw 0:e4a10ed6eb92 99 * @param mSeconds the amount of time to take per bit in the pattern
jbradshaw 0:e4a10ed6eb92 100 */
jbradshaw 0:e4a10ed6eb92 101 void pattern(uint32_t pattern, uint32_t mSeconds);
jbradshaw 0:e4a10ed6eb92 102
jbradshaw 0:e4a10ed6eb92 103 /**
jbradshaw 0:e4a10ed6eb92 104 * @brief Turn the LED on
jbradshaw 0:e4a10ed6eb92 105 */
jbradshaw 0:e4a10ed6eb92 106 void on(void);
jbradshaw 0:e4a10ed6eb92 107
jbradshaw 0:e4a10ed6eb92 108 /**
jbradshaw 0:e4a10ed6eb92 109 * @brief Turn the LED off
jbradshaw 0:e4a10ed6eb92 110 */
jbradshaw 0:e4a10ed6eb92 111 void off(void);
jbradshaw 0:e4a10ed6eb92 112
jbradshaw 0:e4a10ed6eb92 113 /**
jbradshaw 0:e4a10ed6eb92 114 * @brief Update the LED
jbradshaw 0:e4a10ed6eb92 115 */
jbradshaw 0:e4a10ed6eb92 116 void service(void);
jbradshaw 0:e4a10ed6eb92 117
jbradshaw 0:e4a10ed6eb92 118 private:
jbradshaw 0:e4a10ed6eb92 119
jbradshaw 0:e4a10ed6eb92 120 /**
jbradshaw 0:e4a10ed6eb92 121 * Set the mode of the LED, the mode include blinking at a set rate or blinking
jbradshaw 0:e4a10ed6eb92 122 * according to a pattern
jbradshaw 0:e4a10ed6eb92 123 * @param mode Mode to set the LED to
jbradshaw 0:e4a10ed6eb92 124 */
jbradshaw 0:e4a10ed6eb92 125 void setMode(eMode state);
jbradshaw 0:e4a10ed6eb92 126
jbradshaw 0:e4a10ed6eb92 127 /**
jbradshaw 0:e4a10ed6eb92 128 * Toggle the state of the LED
jbradshaw 0:e4a10ed6eb92 129 */
jbradshaw 0:e4a10ed6eb92 130 void toggle(void);
jbradshaw 0:e4a10ed6eb92 131
jbradshaw 0:e4a10ed6eb92 132 /**
jbradshaw 0:e4a10ed6eb92 133 * Start the LED blinking or rotating through a pattern
jbradshaw 0:e4a10ed6eb92 134 */
jbradshaw 0:e4a10ed6eb92 135 void start(void);
jbradshaw 0:e4a10ed6eb92 136
jbradshaw 0:e4a10ed6eb92 137 /**
jbradshaw 0:e4a10ed6eb92 138 * Stop blinking or rotating through a pattern
jbradshaw 0:e4a10ed6eb92 139 */
jbradshaw 0:e4a10ed6eb92 140 void stop(void);
jbradshaw 0:e4a10ed6eb92 141
jbradshaw 0:e4a10ed6eb92 142 /**
jbradshaw 0:e4a10ed6eb92 143 * Write the LED pin to a state
jbradshaw 0:e4a10ed6eb92 144 * @param state A one or zero value to write to the LED pin
jbradshaw 0:e4a10ed6eb92 145 */
jbradshaw 0:e4a10ed6eb92 146 void state(int state);
jbradshaw 0:e4a10ed6eb92 147
jbradshaw 0:e4a10ed6eb92 148 /*
jbradshaw 0:e4a10ed6eb92 149 * @brief Single step through the pattern and output to the LED
jbradshaw 0:e4a10ed6eb92 150 */
jbradshaw 0:e4a10ed6eb92 151 void patternToLed(void);
jbradshaw 0:e4a10ed6eb92 152
jbradshaw 0:e4a10ed6eb92 153 /// timer interval in mS
jbradshaw 0:e4a10ed6eb92 154 float timerInterval;
jbradshaw 0:e4a10ed6eb92 155 /// last timer interval set to... used to prevent resetting the timer to the same value
jbradshaw 0:e4a10ed6eb92 156 float timerIntervalLast;
jbradshaw 0:e4a10ed6eb92 157 /// local state of the pattern to rotate through
jbradshaw 0:e4a10ed6eb92 158 uint32_t bitPattern;
jbradshaw 0:e4a10ed6eb92 159 /// current mode of the LED
jbradshaw 0:e4a10ed6eb92 160 eMode mode;
jbradshaw 0:e4a10ed6eb92 161 /// the LED digital output
jbradshaw 0:e4a10ed6eb92 162 DigitalOut redLed;
jbradshaw 0:e4a10ed6eb92 163 /// Timer service used to update the LED
jbradshaw 0:e4a10ed6eb92 164 Ticker ticker;
jbradshaw 0:e4a10ed6eb92 165 /// Flag to indicate if the timer has been started
jbradshaw 0:e4a10ed6eb92 166 bool isStarted;
jbradshaw 0:e4a10ed6eb92 167 };
jbradshaw 0:e4a10ed6eb92 168
jbradshaw 0:e4a10ed6eb92 169 #endif /* _LED_H_ */