Host software for the MAXREFDES220 Heart Rate Monitor Smart Sensor. Hosted on the MAX32630FTHR.

Dependencies:   max32630fthr USBDevice

Fork of MAXREFDES220_HEART_RATE_MONITOR by Maxim Integrated

Finger Heart Rate Monitor and SpO2 Monitor

The MAXREFDES220 Smart Sensor FeatherWing board is a integrated solution for providing finger-based heart rate measurements and SpO2 (blood oxygen saturation). This evaluation board interfaces to the host computer using the I2C interface. Heart rate outpu is available in beats per minute (BPM) and SpO2 is reported in percentages.; the PPG (photoplethysmography) raw data is also available. The board has an MAX30101 chip which is a low power heart rate monitor with adjustable sample rates and adjustable LED currents. The low cost MAX32664 microcontroller is pre-flashed with C code for finger-based pulse rate and SpO2 monitoring. Bootloader software is included to allow for future algorithms or updates to the algorithm from Maxim Integrated.

Ordering information will be available soon.

Note: SpO2 values are not calibrated. Calibration should be performed using the final end product.

Warning

The MAXREFDES220 source code listed is dated and only compatible with the 1.2.8a.msbl. The latest sample host source code is available on the MAX32664 website.

MAXREFDES220 FeatherWing Pinout Connections

/media/uploads/phonemacro/maxrefdes220_pinouts_heart_rate_monitor.jpg

Committer:
keremsahin
Date:
Mon Jul 02 21:07:27 2018 +0000
Revision:
8:0f55f59ca341
Parent:
5:e458409e913f
MAX30001/MAX30205/MAX8614X driver updates; EcgComm/TempComm/MAX30101Comm updates; Bootloader updates; EventStats/LEDStatus updates

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Shaun Kelsey 0:da5f5b56060a 1 /*******************************************************************************
Shaun Kelsey 0:da5f5b56060a 2 * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
Shaun Kelsey 0:da5f5b56060a 3 *
Shaun Kelsey 0:da5f5b56060a 4 * Permission is hereby granted, free of charge, to any person obtaining a
Shaun Kelsey 0:da5f5b56060a 5 * copy of this software and associated documentation files (the "Software"),
Shaun Kelsey 0:da5f5b56060a 6 * to deal in the Software without restriction, including without limitation
Shaun Kelsey 0:da5f5b56060a 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
Shaun Kelsey 0:da5f5b56060a 8 * and/or sell copies of the Software, and to permit persons to whom the
Shaun Kelsey 0:da5f5b56060a 9 * Software is furnished to do so, subject to the following conditions:
Shaun Kelsey 0:da5f5b56060a 10 *
Shaun Kelsey 0:da5f5b56060a 11 * The above copyright notice and this permission notice shall be included
Shaun Kelsey 0:da5f5b56060a 12 * in all copies or substantial portions of the Software.
Shaun Kelsey 0:da5f5b56060a 13 *
Shaun Kelsey 0:da5f5b56060a 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
Shaun Kelsey 0:da5f5b56060a 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Shaun Kelsey 0:da5f5b56060a 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
Shaun Kelsey 0:da5f5b56060a 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
Shaun Kelsey 0:da5f5b56060a 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
Shaun Kelsey 0:da5f5b56060a 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
Shaun Kelsey 0:da5f5b56060a 20 * OTHER DEALINGS IN THE SOFTWARE.
Shaun Kelsey 0:da5f5b56060a 21 *
Shaun Kelsey 0:da5f5b56060a 22 * Except as contained in this notice, the name of Maxim Integrated
Shaun Kelsey 0:da5f5b56060a 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
Shaun Kelsey 0:da5f5b56060a 24 * Products, Inc. Branding Policy.
Shaun Kelsey 0:da5f5b56060a 25 *
Shaun Kelsey 0:da5f5b56060a 26 * The mere transfer of this software does not imply any licenses
Shaun Kelsey 0:da5f5b56060a 27 * of trade secrets, proprietary technology, copyrights, patents,
Shaun Kelsey 0:da5f5b56060a 28 * trademarks, maskwork rights, or any other form of intellectual
Shaun Kelsey 0:da5f5b56060a 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
Shaun Kelsey 0:da5f5b56060a 30 * ownership rights.
Shaun Kelsey 0:da5f5b56060a 31 *******************************************************************************
Shaun Kelsey 0:da5f5b56060a 32 */
Shaun Kelsey 0:da5f5b56060a 33
Shaun Kelsey 0:da5f5b56060a 34 #ifndef _DSINTERFACE_H_
Shaun Kelsey 0:da5f5b56060a 35 #define _DSINTERFACE_H_
Shaun Kelsey 0:da5f5b56060a 36
Shaun Kelsey 0:da5f5b56060a 37 #include "mbed.h"
Shaun Kelsey 0:da5f5b56060a 38 #include <stdint.h>
Shaun Kelsey 0:da5f5b56060a 39 #include "SensorComm.h"
Shaun Kelsey 0:da5f5b56060a 40 #include "MaximSensor.h"
Shaun Kelsey 0:da5f5b56060a 41 #include "USBSerial.h"
Shaun Kelsey 0:da5f5b56060a 42
Shaun Kelsey 0:da5f5b56060a 43 #define COMM_SUCCESS 0
Shaun Kelsey 0:da5f5b56060a 44 #define COMM_GENERAL_ERROR -1
Shaun Kelsey 0:da5f5b56060a 45 #define COMM_INVALID_PARAM -254
Shaun Kelsey 0:da5f5b56060a 46 #define COMM_NOT_RECOGNIZED -255
Shaun Kelsey 0:da5f5b56060a 47
Shaun Kelsey 0:da5f5b56060a 48 #define FLASH_ERR_GENERAL -1
Shaun Kelsey 0:da5f5b56060a 49 #define FLASH_ERR_CHECKSUM -2
Shaun Kelsey 0:da5f5b56060a 50 #define FLASH_ERR_AUTH -3
Shaun Kelsey 0:da5f5b56060a 51
Shaun Kelsey 0:da5f5b56060a 52 #define DS_MAX_NUM_SENSORCOMMS 8
Shaun Kelsey 0:da5f5b56060a 53
Shaun Kelsey 0:da5f5b56060a 54 #define DS_BINARY_PACKET_START_BYTE 0xAA
Shaun Kelsey 0:da5f5b56060a 55
Shaun Kelsey 0:da5f5b56060a 56 /**
Shaun Kelsey 0:da5f5b56060a 57 * @brief DSInterface is Maxim's DeviceStudio Interface class
Shaun Kelsey 0:da5f5b56060a 58 */
Shaun Kelsey 0:da5f5b56060a 59 class DSInterface
Shaun Kelsey 0:da5f5b56060a 60 {
Shaun Kelsey 0:da5f5b56060a 61 public:
Shaun Kelsey 0:da5f5b56060a 62
Shaun Kelsey 0:da5f5b56060a 63 /* PUBLIC FUNCTION DECLARATIONS */
Shaun Kelsey 0:da5f5b56060a 64 /**
Shaun Kelsey 0:da5f5b56060a 65 * @brief DSInterface constructor.
Shaun Kelsey 0:da5f5b56060a 66 *
Shaun Kelsey 0:da5f5b56060a 67 * @param[in] fw_version Firmware version number.
Shaun Kelsey 0:da5f5b56060a 68 * @param[in] fw_platform Firmware platform name.
Shaun Kelsey 0:da5f5b56060a 69 * @param[in] USB Pointer to USBSerial device
Shaun Kelsey 0:da5f5b56060a 70 */
Shaun Kelsey 0:da5f5b56060a 71 DSInterface(USBSerial* USB);
Shaun Kelsey 0:da5f5b56060a 72
Shaun Kelsey 0:da5f5b56060a 73 /**
Shaun Kelsey 0:da5f5b56060a 74 * @brief DSInterface destructor.
Shaun Kelsey 0:da5f5b56060a 75 *
Shaun Kelsey 0:da5f5b56060a 76 */
Shaun Kelsey 0:da5f5b56060a 77 virtual ~DSInterface();
Shaun Kelsey 0:da5f5b56060a 78
Shaun Kelsey 0:da5f5b56060a 79 /**
Shaun Kelsey 0:da5f5b56060a 80 * @brief Add SensorComm for DSInterface to pass commands to
Shaun Kelsey 0:da5f5b56060a 81 *
Shaun Kelsey 0:da5f5b56060a 82 * @param[in] s SensorComm instance to handle sensor commands.
Shaun Kelsey 0:da5f5b56060a 83 */
Shaun Kelsey 0:da5f5b56060a 84 void add_sensor_comm(SensorComm *s);
Shaun Kelsey 0:da5f5b56060a 85
Shaun Kelsey 0:da5f5b56060a 86 /**
Shaun Kelsey 0:da5f5b56060a 87 * @brief Command builder from i/o device.
Shaun Kelsey 0:da5f5b56060a 88 * @details Reads character and builds command from DeviceStudio commands.
Shaun Kelsey 0:da5f5b56060a 89 *
Shaun Kelsey 0:da5f5b56060a 90 * @param[in] ch Input character from i/o device.
Shaun Kelsey 0:da5f5b56060a 91 */
Shaun Kelsey 0:da5f5b56060a 92 void build_command(char ch);
Shaun Kelsey 0:da5f5b56060a 93
Shaun Kelsey 0:da5f5b56060a 94 /**
Shaun Kelsey 0:da5f5b56060a 95 * @brief Prints latest sensor data to USB stream
Shaun Kelsey 0:da5f5b56060a 96 * @details Should be called on every pass thorugh the main loop in main.cpp
Shaun Kelsey 0:da5f5b56060a 97 *
Shaun Kelsey 0:da5f5b56060a 98 */
Shaun Kelsey 0:da5f5b56060a 99 void data_report_execute();
Shaun Kelsey 0:da5f5b56060a 100
Shaun Kelsey 0:da5f5b56060a 101 /**
Shaun Kelsey 0:da5f5b56060a 102 * @brief Set the fw version which DSInterface will replay with for "get_device_info" command
Shaun Kelsey 0:da5f5b56060a 103 *
Shaun Kelsey 0:da5f5b56060a 104 * @param[in] fw_version Firmware version number.
Shaun Kelsey 0:da5f5b56060a 105 */
Shaun Kelsey 0:da5f5b56060a 106 void set_fw_version(const char *fw_version);
Shaun Kelsey 0:da5f5b56060a 107
Shaun Kelsey 0:da5f5b56060a 108 /**
Shaun Kelsey 0:da5f5b56060a 109 * @brief Set the fw platform which DSInterface will replay with for "get_device_info" command
Shaun Kelsey 0:da5f5b56060a 110 *
Shaun Kelsey 0:da5f5b56060a 111 * @param[in] fw_platform Firmware platform name.
Shaun Kelsey 0:da5f5b56060a 112 */
Shaun Kelsey 0:da5f5b56060a 113 void set_fw_platform(const char *fw_platform);
Shaun Kelsey 0:da5f5b56060a 114
Shaun Kelsey 0:da5f5b56060a 115 /**
Shaun Kelsey 0:da5f5b56060a 116 * @brief Enable data output on the console interface (USB)
Shaun Kelsey 0:da5f5b56060a 117 */
Shaun Kelsey 0:da5f5b56060a 118 void enable_console_interface();
Shaun Kelsey 0:da5f5b56060a 119
Shaun Kelsey 0:da5f5b56060a 120
Shaun Kelsey 0:da5f5b56060a 121
Shaun Kelsey 0:da5f5b56060a 122 protected:
Shaun Kelsey 0:da5f5b56060a 123
Shaun Kelsey 0:da5f5b56060a 124 /* PROTECTED FUNCTION DECLARATIONS */
Shaun Kelsey 0:da5f5b56060a 125 /**
Shaun Kelsey 0:da5f5b56060a 126 * @brief Parses DeviceStudio commands.
Shaun Kelsey 0:da5f5b56060a 127 * @details Parses and executes commands. Prints return code to i/o device.
Shaun Kelsey 0:da5f5b56060a 128 */
Shaun Kelsey 0:da5f5b56060a 129 void parse_command();
Shaun Kelsey 0:da5f5b56060a 130
Shaun Kelsey 0:da5f5b56060a 131
Shaun Kelsey 0:da5f5b56060a 132 /* PROTECTED VARIABLES */
Shaun Kelsey 0:da5f5b56060a 133 USBSerial *m_USB;
Shaun Kelsey 0:da5f5b56060a 134 Mutex comm_mutex;
Shaun Kelsey 0:da5f5b56060a 135
Shaun Kelsey 0:da5f5b56060a 136 int num_sensors;
Shaun Kelsey 0:da5f5b56060a 137 SensorComm* sensor_list[DS_MAX_NUM_SENSORCOMMS];
Shaun Kelsey 0:da5f5b56060a 138
keremsahin 8:0f55f59ca341 139 volatile uint8_t ds_console_interface_exists_;
Shaun Kelsey 0:da5f5b56060a 140
Shaun Kelsey 0:da5f5b56060a 141 const char* platform_name;
Shaun Kelsey 0:da5f5b56060a 142 const char* firmware_version;
Shaun Kelsey 0:da5f5b56060a 143
Shaun Kelsey 5:e458409e913f 144 static const uint32_t CONSOLE_STR_BUF_SZ = 1024;
Shaun Kelsey 0:da5f5b56060a 145
Shaun Kelsey 5:e458409e913f 146 char cmd_str[CONSOLE_STR_BUF_SZ];
Shaun Kelsey 0:da5f5b56060a 147 int cmd_idx;
Shaun Kelsey 0:da5f5b56060a 148 bool silent_mode;
Shaun Kelsey 0:da5f5b56060a 149 bool pause_mode;
Shaun Kelsey 0:da5f5b56060a 150 };
Shaun Kelsey 0:da5f5b56060a 151
Shaun Kelsey 0:da5f5b56060a 152 #endif /* _DSINTERFACE_H_ */