Example Host software for integration of MAX3266x chips (, MAX32664GWEB) equipped with Heart Rate from Wrist Algorithm. This is “stand-alone” software that runs on the MAX32630 low-power microcontroller to display heart rate on the display of the MAXREFDES101 reference design. It is intended provide a simple example of how to initialize and communicate with the sensor hub. Windows and Android communications are not supported.

Dependencies:   Maxim_Sensor_Hub_Communications BMI160 whrmDemoUI max32630hsp3

Fork of Host_Software_MAX32664GWEB_HR_wrist by mehmet gok

Revision:
13:3d1a6b947396
Parent:
12:9e3de2ece9c4
Child:
14:b2e4b71a9980
diff -r 9e3de2ece9c4 -r 3d1a6b947396 main.cpp
--- a/main.cpp	Thu Jan 03 09:48:12 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,208 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2018 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.
- *******************************************************************************
- */
-
-
-/**********************************************************************************
- *
- *  Desc: Example Code to get algorithm estimation results of Heart rate( HRM) and Blood
- *        Oxygen (SPo2) form sensor hub and display it on screen. Example starts by monitoring heart rate
- *        ans switches to blood oxygen monitoring via a button press (switch button)
- *
- *        Example,
- *
- *        1. Initializes user interface
- *                   initialize display screen and switch button for algo selection.
- *
- *        2. Initializes underlying hardware port for sensor hub communication:
- *                   setup i2c comm. inits reset pin and mfio event pin and connects interrupt to mfio pin.
- *
- *        3. When switched to a minitoring mode
- *                   disables previous algorithm, clears mfio event
- *                   calls default init function for the sensor whose data is used by enabled algorithms. Algorithms are
- *                   registered under sesnor instance for this example. Fcunction
- *                   	        1. initialize algorithm config struct enabled
- *                              2. enable data type to both raw sensor and algorithm data
- *                              3. get input fifo size to learn fifo capacity
- *                              4. set fifo threshold for mfio event frequency
- *                              5. reaenable sensor to acquire ppg data
- *                              6. enable accompanying accel sensor
- *                              7. enable switched algorithm
- *
- *     4. Sensor Hub now starts to write raw sensor/algorithm data to its data report FIFO which
- *        reports mfio event when data size determined by fifo threshold is written to report fifo.
- *
- *     5. Example calls SH_Max8614x_data_report_execute() which
- *                 1. calls SH API's sh_ss_execute_once() function which:
- *                            writes sensor hub's report fifo content (sensor/algorithm data samples) to a buffer(1).
- *                 2. calls CSTMR_SH_FeedAccDataIntoSH() to send accelerometer data to sensor hub which os required for heart rate
- *                    Note: SPo2 requires stablity so do not move/shake senor when taking SPo2 data.
- *                 3. Parses buffer(1) data to extract numeric sensor and algorithm samples according to enabled algorithms.
- *                    look: whrm_data_rx() , wspo2_data_rx() , max8614x_data_rx() and sample structs whrm_mode1_data, wspo2_mode1_data and max8614x_mode1_data
- *
- *     6. numeric values  are written to HrmResult, SPO2Result ... within MAX8614x  whrm_data_rx() ... and included as extern in main.cpp
- *
- *     7. Example calls demoUI_display_algo_estimations() to display result on watch screen
- *
- *
- ***********************************************************************************/
-
-#include <events/mbed_events.h>
-#include <mbed.h>
-#include "max32630hsp.h"
-#include "SHComm.h"
-#include "SH_Max8614x_BareMetal.h"
-#include "bmi160.h"
-
-#include "demoUI.h"
-
-
-extern uint16_t HrmResult;
-extern uint16_t SPO2Result;
-extern uint8_t  HrmConfidence;
-extern uint8_t  SPo2Confidence;
-
-DigitalOut led1(LED1, 1);
-// Hardware serial port over DAPLink
-Serial daplink(USBTX, USBRX, 115200);
-// ICARUS Board initialization
-InterruptIn interruptIn_PowerButton(P7_6);
-MAX32630HSP icarus(MAX32630HSP::VIO_1V8, &interruptIn_PowerButton);
-
-#define WAIT_SENSORHUB_STABLE_BOOTUP_MS  ((uint32_t)2000)
-
-
-static bool isWhrmInitialized = false;
-static bool isSpo2Initialized = false;
-
-int main() {
-
-	wait_ms(WAIT_SENSORHUB_STABLE_BOOTUP_MS);
-	//demoUI_display_set_algoMode(kAlgoModeHeartRate);
-
-	demoUI_init();
-
-	sh_init_hwcomm_interface();
-	sh_disable_irq_mfioevent();
-	sh_clear_mfio_event_flag();
-	sh_enable_irq_mfioevent();
-	int i = 0;
-
-#if 1
-
-	int displayMode;
-	uint16_t resultToDisplay;
-	uint8_t  confidenceToDisplay;
-
-	while(1) {
-
-		displayMode = demoUI_display_get_mode();
-
-        if( displayMode == kAlgoModeHeartRate ){
-             if( !isWhrmInitialized){
-#if defined(DEBUG_INFO)
-            	 printf(" WHRM inititalized \r\n");
-#endif
-            	 SH_Max8614x_stop();
-            	 SH_Max8614x_default_init(kAlgoModeHeartRate);
-            	 isWhrmInitialized = true;
-            	 isSpo2Initialized = false;
-            	 wait_ms(1000); /* for display screen*/
-             }
-             resultToDisplay     = HrmResult;
-             confidenceToDisplay = HrmConfidence;
-
-        }else{
-            if( !isSpo2Initialized){
-#if defined(DEBUG_INFO)
-            	printf(" WSPo2 inititalized \r\n");
-#endif
-            	SH_Max8614x_stop();
-            	SH_Max8614x_default_init(kAlgoModeSPO2);
-            	isWhrmInitialized = false;
-            	isSpo2Initialized = true;
-            	wait_ms(1000); /* for display screen*/
-            }
-            resultToDisplay = SPO2Result;
-            confidenceToDisplay = SPo2Confidence;
-        }
-
-		int cumSampleCNt = SH_Max8614x_data_report_execute();
-		if(cumSampleCNt){
-#if defined(DEBUG_INFO)
-			printf("estimate: =%d conf: %d dispMode: %d \r\n", resultToDisplay , confidenceToDisplay, displayMode);
-#endif
-            demoUI_display_algo_estimations(resultToDisplay);
-            //printf(" Display Mode : %d \r\n", displayMode );
-		}
-
-
-
-	}
-
-
-
-
-
-#else
-
-	while(1) {
-		SH_Max8614x_default_init(kAlgoModeHeartRate);
-
-		while(1){
-			++i;
-			int cumSampleCNt = SH_Max8614x_data_report_execute();
-			if(cumSampleCNt)
-			    printf("hr_cttt=%d   %d\r\n", HrmResult , HrmConfidence);
-			wait_ms(2);
-			led1 = !led1;
-			if(i == 24000) {
-				break;
-			}
-		}
-		i = 0;
-		SH_Max8614x_stop();
-		printf("Stopped\r\n");
-		while(1){
-			++i;
-			SH_Max8614x_data_report_execute();
-			wait_ms(2);
-			led1 = !led1;
-			if(i == 4000) {
-				break;
-			}
-		}
-		i = 0;
-	}
-#endif
-
-}