Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MAX30101 max32630fthr
Fork of MAX30101_Demo_Plot by
Diff: main.cpp
- Revision:
- 5:2f708191f1bd
- Parent:
- 4:14d1b87cd3c4
- Child:
- 6:238d2eec53de
--- a/main.cpp Tue Aug 22 21:51:07 2017 +0000
+++ b/main.cpp Mon Aug 28 20:59:29 2017 +0000
@@ -1,3 +1,37 @@
+/*******************************************************************************
+ * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
+ * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of Maxim Integrated
+ * Products, Inc. shall not be used except as stated in the Maxim Integrated
+ * Products, Inc. Branding Policy.
+ *
+ * The mere transfer of this software does not imply any licenses
+ * of trade secrets, proprietary technology, copyrights, patents,
+ * trademarks, maskwork rights, or any other form of intellectual
+ * property whatsoever. Maxim Integrated Products, Inc. retains all
+ * ownership rights.
+ *******************************************************************************
+ */
+
+
#include "mbed.h"
#include "max32630fthr.h"
#include "MAX30101.h"
@@ -30,7 +64,9 @@
MAX30101 op_sensor(i2cBus); // Create new MAX30101 on i2cBus
int rc = op_sensor_config(op_sensor); // Config sensor, return 0 on success
- MAX30101::InterruptBitField_u ints;
+ MAX30101::InterruptBitField_u ints; // Read interrupt status to clear
+ rc = op_sensor.getInterruptStatus(ints); // power on interrupt
+
uint8_t fifoData[MAX30101::MAX_FIFO_BYTES];
uint16_t idx, readBytes;
int16_t opSample;
@@ -42,7 +78,6 @@
// Check if op_sensor interrupt asserted
if(op_sensorIntFlag) {
- pc.printf("Interrupt seen...\r\n");
op_sensorIntFlag = 0; // Lower interrupt flag
rc = op_sensor.getInterruptStatus(ints); // Read interrupt status
@@ -54,21 +89,18 @@
if(rc == 0) {
- pc.printf("FIFO Read, received %d samples\r\n\r\n", readBytes/3);
-
// Convert read bytes into samples
for(idx = 0; idx < readBytes; idx+=3) {
sample = (fifoData[idx]<<16) | (fifoData[idx+1]<<8) | (fifoData[idx+2]);
opSample = sample >> 8; // Sign extends sample to 16-bit opSample
- pc.printf("Op. Sample : %i\r\n", opSample); // Print results
+ pc.printf("%i\r\n", opSample); // Print results
}
- pc.printf("\r\n\r\n");
-
}
}
}
+ // If rc != 0, a communication error has occurred
} else {
pc.printf("Something went wrong, "
@@ -111,8 +143,8 @@
if(rc == 0)
{
fifoConfig.all = 0;
- fifoConfig.bits.fifo_a_full = 15; // Max level of 15 samples
- fifoConfig.bits.sample_average = MAX30101::AveragedSamples_8; // Average 8 samples
+ fifoConfig.bits.fifo_a_full = 15; // Max level of 15 samples
+ fifoConfig.bits.sample_average = MAX30101::AveragedSamples_8; // Average 8 samples
rc = op_sensor.setFIFOConfiguration(fifoConfig);
}
@@ -121,14 +153,14 @@
{
spo2Config.all = 0;
spo2Config.bits.spo2_sr = MAX30101::SR_400_Hz; // SpO2 SR = 400Hz
- spo2Config.bits.led_pw = 1;
+ spo2Config.bits.led_pw = 1; // 16-bit ADC resolution
rc = op_sensor.setSpO2Configuration(spo2Config);
}
//Set LED1 drive current
if(rc == 0)
{
- //Heart Rate only
+ // Heart Rate only, 1 LED channel, Pulse amp. = 0x1F
rc = op_sensor.setLEDPulseAmplitude(MAX30101::LED1_PA, 0x1F);
}
