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: max32630fthr USBDevice
Fork of MAXREFDES220_HEART_RATE_MONITOR by
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

Diff: Interfaces/SmartSensor/SSInterface.h
- Revision:
- 5:e458409e913f
- Parent:
- 4:998fb975b0d7
- Child:
- 7:3e2a5545f1d8
--- a/Interfaces/SmartSensor/SSInterface.h Thu May 24 14:51:55 2018 -0700
+++ b/Interfaces/SmartSensor/SSInterface.h Thu May 24 14:54:28 2018 -0700
@@ -36,6 +36,7 @@
#include "mbed.h"
#include "MaximSensor.h"
+#include "EventStats.h"
#define SS_PLATFORM_MAX3263X "SmartSensor_MAX3263X"
#define SS_PLATFORM_MAX32660 "SmartSensor_MAX32660"
@@ -58,7 +59,7 @@
#define SS_ALGOIDX_AEC 0x01
#define SS_ALGOIDX_WHRM 0x02
#define SS_ALGOIDX_ECG 0x03
-
+#define SS_ALGOIDX_BPT 0x04
#define SS_FAM_R_STATUS 0x00
#define SS_CMDIDX_STATUS 0x00
@@ -120,6 +121,29 @@
//TODO: Fill in known configuration parameters
#define SS_FAM_W_ALGOCONFIG 0x50
#define SS_FAM_R_ALGOCONFIG 0x51
+ #define SS_CFGIDX_AGC_TARGET 0x00
+ #define SS_CFGIDX_AGC_CORR_COEFF 0x01
+ #define SS_CFGIDX_AGC_SENSITIVITY 0x02
+ #define SS_CFGIDX_AGC_SMP_AVG 0x03
+
+ #define SS_CFGIDX_WHRM_SR 0x00
+ #define SS_CFGIDX_WHRM_MAX_HEIGHT 0x01
+ #define SS_CFGIDX_WHRM_MAX_WEIGHT 0x02
+ #define SS_CFGIDX_WHRM_MAX_AGE 0x03
+ #define SS_CFGIDX_WHRM_MIN_HEIGHT 0x04
+ #define SS_CFGIDX_WHRM_MIN_WEIGHT 0x05
+ #define SS_CFGIDX_WHRM_MIN_AGE 0x06
+ #define SS_CFGIDX_WHRM_DEF_HEIGHT 0x07
+ #define SS_CFGIDX_WHRM_DEF_WEIGHT 0x08
+ #define SS_CFGIDX_WHRM_DEF_AGE 0x09
+ #define SS_CFGIDX_WHRM_INIT_HR 0x0A
+
+ #define SS_CFGIDX_BP_USE_MED 0x00
+ #define SS_CFGIDX_BP_SYS_BP_CAL 0x01
+ #define SS_CFGIDX_BP_DIA_BP_CAL 0x02
+ #define SS_CFGIDX_BP_CAL_DATA 0x03
+ #define SS_CFGIDX_BP_EST_DATE 0x04
+ #define SS_CFGIDX_BP_EST_NONREST 0x05
#define SS_FAM_W_ALGOMODE 0x52
#define SS_FAM_R_ALGOMODE 0x53
@@ -135,10 +159,24 @@
#define SS_CMDIDX_SETNUMPAGES 0x02
#define SS_CMDIDX_ERASE 0x03
#define SS_CMDIDX_SENDPAGE 0x04
+ #define SS_CMDIDX_ERASE_PAGE 0x05
+ #define SS_CMDIDX_STAY_IN_BTLRD 0x06
#define SS_FAM_R_BOOTLOADER 0x81
#define SS_CMDIDX_BOOTFWVERSION 0x00
#define SS_CMDIDX_PAGESIZE 0x01
+#define SS_FAM_W_BOOTLOADER_CFG 0x82
+#define SS_FAM_R_BOOTLOADER_CFG 0x83
+ #define SS_CMDIDX_BL_SAVE 0x00
+ #define SS_CMDIDX_BL_ENTRY 0x01
+ #define SS_BL_CFG_ENTER_BL_MODE 0x00
+ #define SS_BL_CFG_EBL_PIN 0x01
+ #define SS_BL_CFG_EBL_POL 0x02
+ #define SS_CMDIDX_BL_EXIT 0x02
+ #define SS_BL_CFG_EXIT_BL_MODE 0x00
+ #define SS_BL_CFG_TIMEOUT 0x01
+
+
#define SS_FAM_R_IDENTITY 0xFF
#define SS_CMDIDX_PLATTYPE 0x00
#define SS_CMDIDX_PARTID 0x01
@@ -162,7 +200,8 @@
SS_ERR_BTLDR_GENERAL=0x80,
SS_ERR_BTLDR_CHECKSUM=0x81,
- SS_ERR_UNKNOWN=0xFF
+ SS_ERR_TRY_AGAIN=0xFE,
+ SS_ERR_UNKNOWN=0xFF,
} SS_STATUS;
typedef enum {
@@ -175,6 +214,7 @@
#define FAILURE_INTERRUPT 0x02
#define SS_SMALL_BUF_SIZE 32
+#define SS_MED_BUF_SIZE 512
#define SS_LARGE_BUF_SIZE 8224
#define SS_RESET_TIME 10
@@ -182,6 +222,7 @@
#define SS_MAX_SUPPORTED_SENSOR_NUM 0xFE
#define SS_MAX_SUPPORTED_ALGO_NUM 0xFE
+#define SS_MAX_SUPPORTED_ALGO_CFG_NUM 0xFE
#define SS_MAX_SUPPORTED_MODE_NUM 0xFF
typedef struct {
@@ -398,6 +439,29 @@
*/
SS_STATUS disable_algo(int idx);
+ /**
+ * @brief Set the value of an algorithm configuration parameter
+ *
+ * @param[in] algo_idx Index of algorithm
+ * @param[in] cfg_idx Index of configuration parameter
+ * @param[in] cfg Array of configuration bytes
+ * @param[in] cfg_sz Size of cfg array
+ *
+ * @return SS_SUCCESS on success
+ */
+ SS_STATUS set_algo_cfg(int algo_idx, int cfg_idx, uint8_t *cfg, int cfg_sz);
+
+ /**
+ * @brief Get the value of an algorithm configuration parameter
+ *
+ * @param[in] algo_idx Index of algorithm
+ * @param[in] cfg_idx Index of configuration parameter
+ * @param[in] cfg Array of configuration bytes to be filled in
+ * @param[in] cfg_sz Number of bytes to be read
+ *
+ * @return SS_SUCCESS on success
+ */
+ SS_STATUS get_algo_cfg(int algo_idx, int cfg_idx, uint8_t *cfg, int cfg_sz);
/**
* @brief Set the CommChannel Output Mode options
@@ -425,12 +489,41 @@
*/
SS_STATUS get_data_type(int* data_type, bool *sc_en);
+ /**
+ * @brief Set the number of samples for the SmartSensor to collect
+ * before issuing an interrupt
+ *
+ * @param[in] thresh - Number of samples (1-255) to collect before interrupt
+ *
+ * @return SS_SUCCESS on success
+ */
+ SS_STATUS set_fifo_thresh(int thresh);
+
+ /**
+ * @brief Get the number of samples the SmartSensor will collect
+ * before issuing an interrupt
+ *
+ * @param[out] thresh - Number of samples (1-255) collected before interrupt
+ *
+ * @return SS_SUCCESS on success
+ */
+ SS_STATUS get_fifo_thresh(int *thresh);
+
+ /**
+ * @brief Check that the SmartSensor is connected
+ */
+ SS_STATUS ss_comm_check();
+
+
void enable_irq();
void disable_irq();
void mfio_selftest();
bool reset_mfio_irq();
+ void ss_execute_once();
+ void ss_clear_interrupt_flag();
+
private:
/* PRIVATE VARIABLES */
@@ -455,12 +548,17 @@
SS_STATUS write_cmd_small(uint8_t *cmd_bytes, int cmd_bytes_len,
uint8_t *data, int data_len,
int sleep_ms = SS_DEFAULT_CMD_SLEEP_MS);
+ SS_STATUS write_cmd_medium(uint8_t *cmd_bytes, int cmd_bytes_len,
+ uint8_t *data, int data_len,
+ int sleep_ms = SS_DEFAULT_CMD_SLEEP_MS);
SS_STATUS write_cmd_large(uint8_t *cmd_bytes, int cmd_bytes_len,
uint8_t *data, int data_len,
int sleep_ms = SS_DEFAULT_CMD_SLEEP_MS);
void cfg_mfio(PinDirection);
void irq_handler();
+ volatile bool m_irq_received_;
+
void irq_handler_selftest();
volatile bool mfio_int_happened;
@@ -468,6 +566,8 @@
SS_STATUS read_fifo_data(int num_samples, int sample_size, uint8_t* databuf, int databuf_sz);
SS_STATUS num_avail_samples(int* num_samples);
void fifo_sample_size(int data_type, int* sample_size);
+
+ EventStats irq_evt;
};

Heart Rate SpO2 Algorithm EvKit Health Monitor Development System Board MAXREFDES220