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:
phonemacro
Date:
Fri Feb 05 01:59:25 2021 +0000
Revision:
14:3fdc09d9017b
Parent:
5:e458409e913f
Remove code for EventStats irq_evt - it no longer compiles on mBed

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 #include "utils.h"
Shaun Kelsey 0:da5f5b56060a 35 #include <ctype.h>
Shaun Kelsey 5:e458409e913f 36 #include "Peripherals.h"
Shaun Kelsey 0:da5f5b56060a 37
Shaun Kelsey 0:da5f5b56060a 38 /*
Shaun Kelsey 0:da5f5b56060a 39 * @brief Parse DeviceStudio get_reg command
Shaun Kelsey 0:da5f5b56060a 40 * @details format is "get_reg <type> <addr>"
Shaun Kelsey 0:da5f5b56060a 41 *
Shaun Kelsey 0:da5f5b56060a 42 * @return 0 on success, -1 on failure
Shaun Kelsey 0:da5f5b56060a 43 */
Shaun Kelsey 0:da5f5b56060a 44 int parse_get_reg_cmd(const char* str, const char* dev_type, uint8_t* addr)
Shaun Kelsey 0:da5f5b56060a 45 {
Shaun Kelsey 0:da5f5b56060a 46 const char* num_start = str + strlen("get_reg") + strlen(dev_type) + 2;
Shaun Kelsey 0:da5f5b56060a 47 unsigned int addr32;
Shaun Kelsey 0:da5f5b56060a 48
Shaun Kelsey 0:da5f5b56060a 49 int num_found = sscanf(num_start, "%x", &addr32);
Shaun Kelsey 0:da5f5b56060a 50 if (num_found == 1) {
Shaun Kelsey 0:da5f5b56060a 51 *addr = (uint8_t)addr32;
Shaun Kelsey 0:da5f5b56060a 52 return 0;
Shaun Kelsey 0:da5f5b56060a 53 } else {
Shaun Kelsey 0:da5f5b56060a 54 return -1;
Shaun Kelsey 0:da5f5b56060a 55 }
Shaun Kelsey 0:da5f5b56060a 56 }
Shaun Kelsey 0:da5f5b56060a 57
Shaun Kelsey 0:da5f5b56060a 58 /*
Shaun Kelsey 0:da5f5b56060a 59 * @brief Parse DeviceStudio set_reg command
Shaun Kelsey 0:da5f5b56060a 60 * @details format is "set_reg <type> <addr> <val>"
Shaun Kelsey 0:da5f5b56060a 61 *
Shaun Kelsey 0:da5f5b56060a 62 * @return 0 on success, -1 on failure
Shaun Kelsey 0:da5f5b56060a 63 */
Shaun Kelsey 0:da5f5b56060a 64 int parse_set_reg_cmd(const char* str, const char* dev_type, uint8_t* addr, uint8_t* val)
Shaun Kelsey 0:da5f5b56060a 65 {
Shaun Kelsey 0:da5f5b56060a 66 const char* num_start = str + strlen("set_reg") + strlen(dev_type) + 2;
Shaun Kelsey 0:da5f5b56060a 67 unsigned int addr32, val32;
Shaun Kelsey 0:da5f5b56060a 68
Shaun Kelsey 0:da5f5b56060a 69 int num_found = sscanf(num_start, "%x %x", &addr32, &val32);
Shaun Kelsey 0:da5f5b56060a 70 if (num_found == 2) {
Shaun Kelsey 0:da5f5b56060a 71 *addr = (uint8_t)addr32;
Shaun Kelsey 0:da5f5b56060a 72 *val = (uint8_t)val32;
Shaun Kelsey 0:da5f5b56060a 73 return 0;
Shaun Kelsey 0:da5f5b56060a 74 } else {
Shaun Kelsey 0:da5f5b56060a 75 return -1;
Shaun Kelsey 0:da5f5b56060a 76 }
Shaun Kelsey 0:da5f5b56060a 77 }
Shaun Kelsey 0:da5f5b56060a 78 int parse_set_reg_cmd(const char* str, const char* dev_type, uint8_t* addr, uint16_t* val)
Shaun Kelsey 0:da5f5b56060a 79 {
Shaun Kelsey 0:da5f5b56060a 80 const char* num_start = str + strlen("set_reg") + strlen(dev_type) + 2;
Shaun Kelsey 0:da5f5b56060a 81 unsigned int addr32, val32;
Shaun Kelsey 0:da5f5b56060a 82
Shaun Kelsey 0:da5f5b56060a 83 int num_found = sscanf(num_start, "%x %x", &addr32, &val32);
Shaun Kelsey 0:da5f5b56060a 84 if (num_found == 2) {
Shaun Kelsey 0:da5f5b56060a 85 *addr = (uint8_t)addr32;
Shaun Kelsey 5:e458409e913f 86 *val = (uint16_t)val32;
Shaun Kelsey 0:da5f5b56060a 87 return 0;
Shaun Kelsey 0:da5f5b56060a 88 } else {
Shaun Kelsey 0:da5f5b56060a 89 return -1;
Shaun Kelsey 0:da5f5b56060a 90 }
Shaun Kelsey 0:da5f5b56060a 91 }
Shaun Kelsey 0:da5f5b56060a 92 int parse_set_reg_cmd(const char* str, const char* dev_type, uint8_t* addr, uint32_t* val)
Shaun Kelsey 0:da5f5b56060a 93 {
Shaun Kelsey 0:da5f5b56060a 94 const char* num_start = str + strlen("set_reg") + strlen(dev_type) + 2;
Shaun Kelsey 0:da5f5b56060a 95 unsigned int addr32, val32;
Shaun Kelsey 0:da5f5b56060a 96
Shaun Kelsey 0:da5f5b56060a 97 int num_found = sscanf(num_start, "%x %x", &addr32, &val32);
Shaun Kelsey 0:da5f5b56060a 98 if (num_found == 2) {
Shaun Kelsey 0:da5f5b56060a 99 *addr = (uint8_t)addr32;
Shaun Kelsey 5:e458409e913f 100 *val = val32;
Shaun Kelsey 0:da5f5b56060a 101 return 0;
Shaun Kelsey 0:da5f5b56060a 102 } else {
Shaun Kelsey 0:da5f5b56060a 103 return -1;
Shaun Kelsey 0:da5f5b56060a 104 }
Shaun Kelsey 0:da5f5b56060a 105 }
Shaun Kelsey 5:e458409e913f 106
Shaun Kelsey 5:e458409e913f 107 int parse_cmd_data(const char* str, const char* cmd, uint8_t *vals, int vals_sz, bool hex)
Shaun Kelsey 5:e458409e913f 108 {
Shaun Kelsey 5:e458409e913f 109 const char* sptr = str + strlen(cmd);
Shaun Kelsey 5:e458409e913f 110 int found = 0;
Shaun Kelsey 5:e458409e913f 111 int ssfound;
Shaun Kelsey 5:e458409e913f 112 unsigned int val32;
Shaun Kelsey 5:e458409e913f 113
Shaun Kelsey 5:e458409e913f 114 while (found < vals_sz) {
Shaun Kelsey 5:e458409e913f 115 while (*sptr != ' ' && *sptr != '\0') { sptr++; }
Shaun Kelsey 5:e458409e913f 116 if (*sptr == '\0')
Shaun Kelsey 5:e458409e913f 117 break;
Shaun Kelsey 5:e458409e913f 118 sptr++;
Shaun Kelsey 5:e458409e913f 119
Shaun Kelsey 5:e458409e913f 120 if (hex)
Shaun Kelsey 5:e458409e913f 121 ssfound = sscanf(sptr, "%x", &val32);
Shaun Kelsey 5:e458409e913f 122 else
Shaun Kelsey 5:e458409e913f 123 ssfound = sscanf(sptr, "%d", &val32);
Shaun Kelsey 5:e458409e913f 124 if (ssfound != 1)
Shaun Kelsey 5:e458409e913f 125 break;
Shaun Kelsey 5:e458409e913f 126 *(vals + found) = (uint8_t)val32;
Shaun Kelsey 5:e458409e913f 127 found++;
Shaun Kelsey 5:e458409e913f 128 }
Shaun Kelsey 5:e458409e913f 129
Shaun Kelsey 5:e458409e913f 130 return found;
Shaun Kelsey 5:e458409e913f 131 }
Shaun Kelsey 5:e458409e913f 132
Shaun Kelsey 5:e458409e913f 133 int parse_cmd_data(const char* str, const char* cmd, uint16_t *vals, int vals_sz, bool hex)
Shaun Kelsey 5:e458409e913f 134 {
Shaun Kelsey 5:e458409e913f 135 const char* sptr = str + strlen(cmd);
Shaun Kelsey 5:e458409e913f 136 int found = 0;
Shaun Kelsey 5:e458409e913f 137 int ssfound;
Shaun Kelsey 5:e458409e913f 138 unsigned int val32;
Shaun Kelsey 5:e458409e913f 139
Shaun Kelsey 5:e458409e913f 140 while (found < vals_sz) {
Shaun Kelsey 5:e458409e913f 141 while (*sptr != ' ' && *sptr != '\0') { sptr++; }
Shaun Kelsey 5:e458409e913f 142 if (*sptr == '\0')
Shaun Kelsey 5:e458409e913f 143 break;
Shaun Kelsey 5:e458409e913f 144 sptr++;
Shaun Kelsey 5:e458409e913f 145
Shaun Kelsey 5:e458409e913f 146 if (hex)
Shaun Kelsey 5:e458409e913f 147 ssfound = sscanf(sptr, "%x", &val32);
Shaun Kelsey 5:e458409e913f 148 else
Shaun Kelsey 5:e458409e913f 149 ssfound = sscanf(sptr, "%d", &val32);
Shaun Kelsey 5:e458409e913f 150 if (ssfound != 1)
Shaun Kelsey 5:e458409e913f 151 break;
Shaun Kelsey 5:e458409e913f 152 *(vals + found) = (uint16_t)val32;
Shaun Kelsey 5:e458409e913f 153 found++;
Shaun Kelsey 5:e458409e913f 154 }
Shaun Kelsey 5:e458409e913f 155
Shaun Kelsey 5:e458409e913f 156 return found;
Shaun Kelsey 5:e458409e913f 157 }
Shaun Kelsey 5:e458409e913f 158
Shaun Kelsey 5:e458409e913f 159 int parse_cmd_data(const char* str, const char* cmd, uint32_t *vals, int vals_sz, bool hex)
Shaun Kelsey 5:e458409e913f 160 {
Shaun Kelsey 5:e458409e913f 161 const char* sptr = str + strlen(cmd);
Shaun Kelsey 5:e458409e913f 162 int found = 0;
Shaun Kelsey 5:e458409e913f 163 int ssfound;
Shaun Kelsey 5:e458409e913f 164
Shaun Kelsey 5:e458409e913f 165 while (found < vals_sz) {
Shaun Kelsey 5:e458409e913f 166 while (*sptr != ' ' && *sptr != '\0') { sptr++; }
Shaun Kelsey 5:e458409e913f 167 if (*sptr == '\0')
Shaun Kelsey 5:e458409e913f 168 break;
Shaun Kelsey 5:e458409e913f 169 sptr++;
Shaun Kelsey 5:e458409e913f 170
Shaun Kelsey 5:e458409e913f 171 if (hex)
Shaun Kelsey 5:e458409e913f 172 ssfound = sscanf(sptr, "%x", vals + found);
Shaun Kelsey 5:e458409e913f 173 else
Shaun Kelsey 5:e458409e913f 174 ssfound = sscanf(sptr, "%d", vals + found);
Shaun Kelsey 5:e458409e913f 175 if (ssfound != 1)
Shaun Kelsey 5:e458409e913f 176 break;
Shaun Kelsey 5:e458409e913f 177 found++;
Shaun Kelsey 5:e458409e913f 178 }
Shaun Kelsey 5:e458409e913f 179
Shaun Kelsey 5:e458409e913f 180 return found;
Shaun Kelsey 5:e458409e913f 181 }
Shaun Kelsey 5:e458409e913f 182
Shaun Kelsey 5:e458409e913f 183 bool starts_with(const char* str1, const char* str2)
Shaun Kelsey 5:e458409e913f 184 {
Shaun Kelsey 5:e458409e913f 185 while (*str1 && *str2) {
Shaun Kelsey 5:e458409e913f 186 if (*str1 != *str2)
Shaun Kelsey 5:e458409e913f 187 return false;
Shaun Kelsey 5:e458409e913f 188 str1++;
Shaun Kelsey 5:e458409e913f 189 str2++;
Shaun Kelsey 5:e458409e913f 190 }
Shaun Kelsey 5:e458409e913f 191
Shaun Kelsey 5:e458409e913f 192 if (*str2)
Shaun Kelsey 5:e458409e913f 193 return false;
Shaun Kelsey 5:e458409e913f 194
Shaun Kelsey 5:e458409e913f 195 return true;
Shaun Kelsey 5:e458409e913f 196 }