Example host software for the Maxim Integrated MAX30101 high sensitivity Heart Rate Monitor chip. Hosted on the MAX32630FTHR FeatherWing micro-controller board.

Dependencies:   MAX30101_Finger_Heart_Rate_SpO2_Monitor_Driver_Source_Code USBDevice max32630fthr

Committer:
phonemacro
Date:
Sat Jul 21 07:11:45 2018 +0000
Revision:
0:ec8835052a84
Child:
1:9bb3378a9060
Initial commit, branched off from MAXREFDES100, MAX32620HSP

Who changed what in which revision?

UserRevisionLine numberNew contents of line
phonemacro 0:ec8835052a84 1 /*******************************************************************************
phonemacro 0:ec8835052a84 2 * Copyright (C) 2018 Maxim Integrated Products, Inc., All Rights Reserved.
phonemacro 0:ec8835052a84 3 *
phonemacro 0:ec8835052a84 4 * Permission is hereby granted, free of charge, to any person obtaining a
phonemacro 0:ec8835052a84 5 * copy of this software and associated documentation files (the "Software"),
phonemacro 0:ec8835052a84 6 * to deal in the Software without restriction, including without limitation
phonemacro 0:ec8835052a84 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
phonemacro 0:ec8835052a84 8 * and/or sell copies of the Software, and to permit persons to whom the
phonemacro 0:ec8835052a84 9 * Software is furnished to do so, subject to the following conditions:
phonemacro 0:ec8835052a84 10 *
phonemacro 0:ec8835052a84 11 * The above copyright notice and this permission notice shall be included
phonemacro 0:ec8835052a84 12 * in all copies or substantial portions of the Software.
phonemacro 0:ec8835052a84 13 *
phonemacro 0:ec8835052a84 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
phonemacro 0:ec8835052a84 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
phonemacro 0:ec8835052a84 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
phonemacro 0:ec8835052a84 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
phonemacro 0:ec8835052a84 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
phonemacro 0:ec8835052a84 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
phonemacro 0:ec8835052a84 20 * OTHER DEALINGS IN THE SOFTWARE.
phonemacro 0:ec8835052a84 21 *
phonemacro 0:ec8835052a84 22 * Except as contained in this notice, the name of Maxim Integrated
phonemacro 0:ec8835052a84 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
phonemacro 0:ec8835052a84 24 * Products, Inc. Branding Policy.
phonemacro 0:ec8835052a84 25 *
phonemacro 0:ec8835052a84 26 * The mere transfer of this software does not imply any licenses
phonemacro 0:ec8835052a84 27 * of trade secrets, proprietary technology, copyrights, patents,
phonemacro 0:ec8835052a84 28 * trademarks, maskwork rights, or any other form of intellectual
phonemacro 0:ec8835052a84 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
phonemacro 0:ec8835052a84 30 * ownership rights.
phonemacro 0:ec8835052a84 31 *******************************************************************************
phonemacro 0:ec8835052a84 32 */
phonemacro 0:ec8835052a84 33 #include "mbed.h"
phonemacro 0:ec8835052a84 34 #include "max32630fthr.h"
phonemacro 0:ec8835052a84 35 #include "MAX30101.h"
phonemacro 0:ec8835052a84 36
phonemacro 0:ec8835052a84 37 #include "USBSerial.h"
phonemacro 0:ec8835052a84 38 #include "max3263x.h"
phonemacro 0:ec8835052a84 39 #include "ioman_regs.h"
phonemacro 0:ec8835052a84 40 #include "PinNames.h"
phonemacro 0:ec8835052a84 41 MAX32630FTHR pegasus(MAX32630FTHR::VIO_1V8); // Change the GPIOs from 3.3V to 1.8V
phonemacro 0:ec8835052a84 42
phonemacro 0:ec8835052a84 43 DigitalOut rLED(LED1);
phonemacro 0:ec8835052a84 44 DigitalOut gLED(LED2);
phonemacro 0:ec8835052a84 45 DigitalOut bLED(LED3);
phonemacro 0:ec8835052a84 46 #define MAX30101_I2C_SLAVE_ADDR (0xAE)
phonemacro 0:ec8835052a84 47 MAX30101 HrSensor(P3_4, P3_5, MAX30101_I2C_SLAVE_ADDR); // SDA, SCL, i2c 7-bit address
phonemacro 0:ec8835052a84 48
phonemacro 0:ec8835052a84 49 // main() runs in its own thread in the OS
phonemacro 0:ec8835052a84 50 // (note the calls to Thread::wait below for delays)
phonemacro 0:ec8835052a84 51 /**
phonemacro 0:ec8835052a84 52 * @brief Sample main program for MAX30101
phonemacro 0:ec8835052a84 53 * @version 1.0000.0
phonemacro 0:ec8835052a84 54 *
phonemacro 0:ec8835052a84 55 * @details Sample main program for MAX30101.
phonemacro 0:ec8835052a84 56 * The prints are sent to the terminal window (9600, 8n1).
phonemacro 0:ec8835052a84 57 * The program sets the GPIOs to 1.8V and the program
phonemacro 0:ec8835052a84 58 * blinks green if it's able to communicate with
phonemacro 0:ec8835052a84 59 * the MAX30101, otherwise, it blinks red.
phonemacro 0:ec8835052a84 60 * To run the program, drag and drop the .bin file into the
phonemacro 0:ec8835052a84 61 * DAPLINK folder. After it finishes flashing, cycle the power or
phonemacro 0:ec8835052a84 62 * reset the Pegasus after flashing by pressing the button on
phonemacro 0:ec8835052a84 63 * the Pegasus next to the battery connector or the button
phonemacro 0:ec8835052a84 64 * on the MAXREFDES100HDK.
phonemacro 0:ec8835052a84 65 */
phonemacro 0:ec8835052a84 66 int main()
phonemacro 0:ec8835052a84 67 {
phonemacro 0:ec8835052a84 68 char value=0;
phonemacro 0:ec8835052a84 69 int ret;
phonemacro 0:ec8835052a84 70
phonemacro 0:ec8835052a84 71 DigitalOut rLED(LED1, LED_OFF);
phonemacro 0:ec8835052a84 72 DigitalOut gLED(LED2, LED_OFF);
phonemacro 0:ec8835052a84 73 DigitalOut bLED(LED3, LED_OFF);
phonemacro 0:ec8835052a84 74
phonemacro 0:ec8835052a84 75 while (true) { // Blink the blue-green LED
phonemacro 0:ec8835052a84 76 ret = HrSensor.i2c_reg_read(MAX30101::REG_ID,&value);
phonemacro 0:ec8835052a84 77 if (value == 0x15) {
phonemacro 0:ec8835052a84 78 printf("MAX30101 Heart Rate Sensor Part ID = %#X\r\n", value);
phonemacro 0:ec8835052a84 79 rLED = LED_OFF;
phonemacro 0:ec8835052a84 80 gLED = !gLED;
phonemacro 0:ec8835052a84 81 }else {
phonemacro 0:ec8835052a84 82 printf("Error, MAX30101 Part ID %#X is not correct, ret = %d\r\n", value, ret);
phonemacro 0:ec8835052a84 83 gLED = LED_OFF;
phonemacro 0:ec8835052a84 84 rLED = !rLED;
phonemacro 0:ec8835052a84 85 }
phonemacro 0:ec8835052a84 86 printf("\r\n");
phonemacro 0:ec8835052a84 87 wait(1.0);
phonemacro 0:ec8835052a84 88 }
phonemacro 0:ec8835052a84 89 }
phonemacro 0:ec8835052a84 90