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

Fork of MAX30101_Heart_Rate_Sp02_Sensor_Chip by David Jung

Committer:
phonemacro
Date:
Sat Jul 21 09:33:16 2018 +0000
Revision:
2:ac57776eee7d
Parent:
1:9bb3378a9060
Added Interrupt pin.

Who changed what in which revision?

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