Host software for the MAXREFDES220 Heart Rate Monitor Smart Sensor. Hosted on the MAX32630FTHR.
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
main.cpp@3:28fb38fe73c4, 2018-04-11 (annotated)
- Committer:
- Shaun Kelsey
- Date:
- Wed Apr 11 16:55:26 2018 -0700
- Revision:
- 3:28fb38fe73c4
- Parent:
- 0:da5f5b56060a
- Child:
- 8:0f55f59ca341
Define MAXIM_PLATFORM_NAME
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Shaun Kelsey |
0:da5f5b56060a | 1 | #include "mbed.h" |
Shaun Kelsey |
0:da5f5b56060a | 2 | #include "USBSerial.h" |
Shaun Kelsey |
0:da5f5b56060a | 3 | #include "version.h" |
Shaun Kelsey |
0:da5f5b56060a | 4 | #include "DSInterface.h" |
Shaun Kelsey |
0:da5f5b56060a | 5 | #include "Peripherals.h" |
Shaun Kelsey |
0:da5f5b56060a | 6 | #include "max32630fthr.h" |
Shaun Kelsey |
0:da5f5b56060a | 7 | #include "SSInterface.h" |
Shaun Kelsey |
0:da5f5b56060a | 8 | #include "SSBootloaderComm.h" |
Shaun Kelsey |
0:da5f5b56060a | 9 | #include "SSMAX30101Comm.h" |
Shaun Kelsey |
0:da5f5b56060a | 10 | |
Shaun Kelsey |
3:28fb38fe73c4 | 11 | #ifndef MAXIM_PLATFORM_NAME |
Shaun Kelsey |
3:28fb38fe73c4 | 12 | #define MAXIM_PLATFORM_NAME "Pegasus" |
Shaun Kelsey |
3:28fb38fe73c4 | 13 | #endif |
Shaun Kelsey |
3:28fb38fe73c4 | 14 | |
Shaun Kelsey |
0:da5f5b56060a | 15 | #if ENABLE_LED_STATUS |
Shaun Kelsey |
0:da5f5b56060a | 16 | //Set yellow light during boot |
Shaun Kelsey |
0:da5f5b56060a | 17 | DigitalOut rLED(LED1, LED_ON); |
Shaun Kelsey |
0:da5f5b56060a | 18 | DigitalOut gLED(LED2, LED_ON); |
Shaun Kelsey |
0:da5f5b56060a | 19 | DigitalOut bLED(LED3, LED_OFF); |
Shaun Kelsey |
0:da5f5b56060a | 20 | #endif |
Shaun Kelsey |
0:da5f5b56060a | 21 | |
Shaun Kelsey |
0:da5f5b56060a | 22 | MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); |
Shaun Kelsey |
0:da5f5b56060a | 23 | |
Shaun Kelsey |
0:da5f5b56060a | 24 | // Virtual serial port over USB |
Shaun Kelsey |
0:da5f5b56060a | 25 | USBSerial microUSB(0x1f00, 0x2012, 0x0001, false); |
Shaun Kelsey |
0:da5f5b56060a | 26 | // Hardware serial port over DAPLink |
Shaun Kelsey |
0:da5f5b56060a | 27 | Serial daplink(USBRX, USBTX, 115200); |
Shaun Kelsey |
0:da5f5b56060a | 28 | |
Shaun Kelsey |
0:da5f5b56060a | 29 | //GUI/Terminal Interface |
Shaun Kelsey |
0:da5f5b56060a | 30 | DSInterface dsInterface(µUSB); |
Shaun Kelsey |
0:da5f5b56060a | 31 | |
Shaun Kelsey |
0:da5f5b56060a | 32 | //SmartSensor Interface |
Shaun Kelsey |
0:da5f5b56060a | 33 | I2C ssI2C(P3_4, P3_5); |
Shaun Kelsey |
0:da5f5b56060a | 34 | PinName ss_mfio(P5_4); |
Shaun Kelsey |
0:da5f5b56060a | 35 | PinName ss_reset(P5_6); |
Shaun Kelsey |
0:da5f5b56060a | 36 | SSInterface ssInterface(ssI2C, ss_mfio, ss_reset); |
Shaun Kelsey |
0:da5f5b56060a | 37 | |
Shaun Kelsey |
0:da5f5b56060a | 38 | SSBootloaderComm ssBoot(µUSB, &ssInterface, &dsInterface); |
Shaun Kelsey |
0:da5f5b56060a | 39 | SSMAX30101Comm ssMAX30101(µUSB, &ssInterface, &dsInterface); |
Shaun Kelsey |
0:da5f5b56060a | 40 | |
Shaun Kelsey |
0:da5f5b56060a | 41 | |
Shaun Kelsey |
0:da5f5b56060a | 42 | #ifdef ENABLE_LED_STATUS |
Shaun Kelsey |
0:da5f5b56060a | 43 | static int led_on_ms = 100; |
Shaun Kelsey |
0:da5f5b56060a | 44 | static int led_off_ms = 1900; |
Shaun Kelsey |
0:da5f5b56060a | 45 | static Timer blink_timer; |
Shaun Kelsey |
0:da5f5b56060a | 46 | static int current_state = 0; |
Shaun Kelsey |
0:da5f5b56060a | 47 | void update_led_state() |
Shaun Kelsey |
0:da5f5b56060a | 48 | { |
Shaun Kelsey |
0:da5f5b56060a | 49 | if (current_state == LED_ON) { |
Shaun Kelsey |
0:da5f5b56060a | 50 | if (blink_timer.read_ms() > led_on_ms) { |
Shaun Kelsey |
0:da5f5b56060a | 51 | gLED = LED_OFF; |
Shaun Kelsey |
0:da5f5b56060a | 52 | current_state = LED_OFF; |
Shaun Kelsey |
0:da5f5b56060a | 53 | blink_timer.reset(); |
Shaun Kelsey |
0:da5f5b56060a | 54 | } |
Shaun Kelsey |
0:da5f5b56060a | 55 | } |
Shaun Kelsey |
0:da5f5b56060a | 56 | else |
Shaun Kelsey |
0:da5f5b56060a | 57 | { |
Shaun Kelsey |
0:da5f5b56060a | 58 | if (blink_timer.read_ms() > led_off_ms) { |
Shaun Kelsey |
0:da5f5b56060a | 59 | gLED = LED_ON; |
Shaun Kelsey |
0:da5f5b56060a | 60 | current_state = LED_ON; |
Shaun Kelsey |
0:da5f5b56060a | 61 | blink_timer.reset(); |
Shaun Kelsey |
0:da5f5b56060a | 62 | } |
Shaun Kelsey |
0:da5f5b56060a | 63 | } |
Shaun Kelsey |
0:da5f5b56060a | 64 | } |
Shaun Kelsey |
0:da5f5b56060a | 65 | #endif |
Shaun Kelsey |
0:da5f5b56060a | 66 | |
Shaun Kelsey |
0:da5f5b56060a | 67 | void print_build_version() |
Shaun Kelsey |
0:da5f5b56060a | 68 | { |
Shaun Kelsey |
0:da5f5b56060a | 69 | printf("\n\nPegasus mBED EVKit\r\n"); |
Shaun Kelsey |
0:da5f5b56060a | 70 | printf("Fw version: %s, mbed version: %d\r\n", FIRMWARE_VERSION, MBED_VERSION); |
Shaun Kelsey |
0:da5f5b56060a | 71 | printf("Build source: (%s) %s\r\n", BUILD_SOURCE_BRANCH, BUILD_SOURCE_HASH); |
Shaun Kelsey |
0:da5f5b56060a | 72 | printf("Build time: %s %s\r\n\n", __TIME__, __DATE__); |
Shaun Kelsey |
0:da5f5b56060a | 73 | } |
Shaun Kelsey |
0:da5f5b56060a | 74 | |
Shaun Kelsey |
0:da5f5b56060a | 75 | int main() |
Shaun Kelsey |
0:da5f5b56060a | 76 | { |
Shaun Kelsey |
0:da5f5b56060a | 77 | daplink.printf("Init NVIC Priorities...\r\n"); |
Shaun Kelsey |
0:da5f5b56060a | 78 | fflush(stdout); |
Shaun Kelsey |
0:da5f5b56060a | 79 | NVIC_SetPriority(GPIO_P0_IRQn, 5); |
Shaun Kelsey |
0:da5f5b56060a | 80 | NVIC_SetPriority(GPIO_P1_IRQn, 5); |
Shaun Kelsey |
0:da5f5b56060a | 81 | NVIC_SetPriority(GPIO_P2_IRQn, 5); |
Shaun Kelsey |
0:da5f5b56060a | 82 | NVIC_SetPriority(GPIO_P3_IRQn, 5); |
Shaun Kelsey |
0:da5f5b56060a | 83 | NVIC_SetPriority(GPIO_P4_IRQn, 5); |
Shaun Kelsey |
0:da5f5b56060a | 84 | NVIC_SetPriority(GPIO_P5_IRQn, 5); |
Shaun Kelsey |
0:da5f5b56060a | 85 | NVIC_SetPriority(GPIO_P6_IRQn, 5); |
Shaun Kelsey |
0:da5f5b56060a | 86 | print_build_version(); |
Shaun Kelsey |
0:da5f5b56060a | 87 | daplink.printf("daplink serial port\r\n"); |
Shaun Kelsey |
0:da5f5b56060a | 88 | microUSB.printf("micro USB serial port\r\n"); |
Shaun Kelsey |
0:da5f5b56060a | 89 | |
Shaun Kelsey |
0:da5f5b56060a | 90 | dsInterface.set_fw_version(FIRMWARE_VERSION); |
Shaun Kelsey |
0:da5f5b56060a | 91 | dsInterface.set_fw_platform(MAXIM_PLATFORM_NAME); |
Shaun Kelsey |
0:da5f5b56060a | 92 | Peripherals::setUSBSerial(µUSB); |
Shaun Kelsey |
0:da5f5b56060a | 93 | |
Shaun Kelsey |
0:da5f5b56060a | 94 | ssI2C.frequency(400000); |
Shaun Kelsey |
0:da5f5b56060a | 95 | dsInterface.set_fw_platform(ssInterface.get_ss_platform_name()); |
Shaun Kelsey |
0:da5f5b56060a | 96 | dsInterface.set_fw_version(ssInterface.get_ss_fw_version()); |
Shaun Kelsey |
0:da5f5b56060a | 97 | dsInterface.add_sensor_comm(&ssBoot); |
Shaun Kelsey |
0:da5f5b56060a | 98 | dsInterface.add_sensor_comm(&ssMAX30101); |
Shaun Kelsey |
0:da5f5b56060a | 99 | |
Shaun Kelsey |
0:da5f5b56060a | 100 | #ifdef ENABLE_LED_STATUS |
Shaun Kelsey |
0:da5f5b56060a | 101 | //Indicate we're done with setup |
Shaun Kelsey |
0:da5f5b56060a | 102 | rLED = LED_OFF; |
Shaun Kelsey |
0:da5f5b56060a | 103 | gLED = LED_OFF; |
Shaun Kelsey |
0:da5f5b56060a | 104 | bLED = LED_OFF; |
Shaun Kelsey |
0:da5f5b56060a | 105 | |
Shaun Kelsey |
0:da5f5b56060a | 106 | blink_timer.start(); |
Shaun Kelsey |
0:da5f5b56060a | 107 | #endif |
Shaun Kelsey |
0:da5f5b56060a | 108 | |
Shaun Kelsey |
0:da5f5b56060a | 109 | while(1) { |
Shaun Kelsey |
0:da5f5b56060a | 110 | USBSerial *serial = µUSB; |
Shaun Kelsey |
0:da5f5b56060a | 111 | uint8_t ch; |
Shaun Kelsey |
0:da5f5b56060a | 112 | while (serial->readable()) { |
Shaun Kelsey |
0:da5f5b56060a | 113 | ch = serial->_getc(); |
Shaun Kelsey |
0:da5f5b56060a | 114 | dsInterface.enable_console_interface(); |
Shaun Kelsey |
0:da5f5b56060a | 115 | dsInterface.build_command(ch); |
Shaun Kelsey |
0:da5f5b56060a | 116 | } |
Shaun Kelsey |
0:da5f5b56060a | 117 | |
Shaun Kelsey |
0:da5f5b56060a | 118 | dsInterface.data_report_execute(); |
Shaun Kelsey |
0:da5f5b56060a | 119 | #ifdef ENABLE_LED_STATUS |
Shaun Kelsey |
0:da5f5b56060a | 120 | update_led_state(); |
Shaun Kelsey |
0:da5f5b56060a | 121 | #endif |
Shaun Kelsey |
0:da5f5b56060a | 122 | } |
Shaun Kelsey |
0:da5f5b56060a | 123 | } |