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@8:0f55f59ca341, 2018-07-02 (annotated)
- Committer:
- keremsahin
- Date:
- Mon Jul 02 21:07:27 2018 +0000
- Revision:
- 8:0f55f59ca341
- Parent:
- 3:28fb38fe73c4
- Child:
- 10:022b2cad9e9b
MAX30001/MAX30205/MAX8614X driver updates; EcgComm/TempComm/MAX30101Comm updates; Bootloader updates; EventStats/LEDStatus updates
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 | |
Shaun Kelsey |
3:28fb38fe73c4 | 7 | #ifndef MAXIM_PLATFORM_NAME |
keremsahin | 8:0f55f59ca341 | 8 | #define MAXIM_PLATFORM_NAME "Pegasus" |
Shaun Kelsey |
3:28fb38fe73c4 | 9 | #endif |
Shaun Kelsey |
3:28fb38fe73c4 | 10 | |
Shaun Kelsey |
0:da5f5b56060a | 11 | #if ENABLE_LED_STATUS |
keremsahin | 8:0f55f59ca341 | 12 | #include "LEDStatus.h" |
Shaun Kelsey |
0:da5f5b56060a | 13 | //Set yellow light during boot |
keremsahin | 8:0f55f59ca341 | 14 | LEDStatus ledStatus(LED1, LED_ON, LED2, LED_ON, LED3, LED_OFF); |
Shaun Kelsey |
0:da5f5b56060a | 15 | #endif |
Shaun Kelsey |
0:da5f5b56060a | 16 | |
keremsahin | 8:0f55f59ca341 | 17 | |
keremsahin | 8:0f55f59ca341 | 18 | |
keremsahin | 8:0f55f59ca341 | 19 | #if defined(PLATFORM_MAX32630HSP) |
keremsahin | 8:0f55f59ca341 | 20 | #include "max32630hsp.h" |
keremsahin | 8:0f55f59ca341 | 21 | #ifdef ENABLE_BLE |
keremsahin | 8:0f55f59ca341 | 22 | #include "BLE_ICARUS.h" |
keremsahin | 8:0f55f59ca341 | 23 | #endif |
keremsahin | 8:0f55f59ca341 | 24 | MAX32630HSP icarus(MAX32630HSP::VIO_1V8); |
keremsahin | 8:0f55f59ca341 | 25 | //MAX32630HSP icarus(MAX32630HSP::VIO_3V3); |
keremsahin | 8:0f55f59ca341 | 26 | #elif defined(PLATFORM_MAX32630FTHR) |
keremsahin | 8:0f55f59ca341 | 27 | #include "max32630fthr.h" |
keremsahin | 8:0f55f59ca341 | 28 | MAX32630FTHR pegasus(MAX32630FTHR::VIO_1V8); |
keremsahin | 8:0f55f59ca341 | 29 | #endif |
Shaun Kelsey |
0:da5f5b56060a | 30 | |
Shaun Kelsey |
0:da5f5b56060a | 31 | // Virtual serial port over USB |
Shaun Kelsey |
0:da5f5b56060a | 32 | USBSerial microUSB(0x1f00, 0x2012, 0x0001, false); |
Shaun Kelsey |
0:da5f5b56060a | 33 | |
Shaun Kelsey |
0:da5f5b56060a | 34 | DSInterface dsInterface(µUSB); |
Shaun Kelsey |
0:da5f5b56060a | 35 | |
keremsahin | 8:0f55f59ca341 | 36 | #ifdef ENABLE_BLE |
keremsahin | 8:0f55f59ca341 | 37 | #include "BLE.h" |
keremsahin | 8:0f55f59ca341 | 38 | #include "BLE_ICARUS.h" |
keremsahin | 8:0f55f59ca341 | 39 | #ifdef ENABLE_BLETEST_COMM |
keremsahin | 8:0f55f59ca341 | 40 | #include "BleTestComm.h" |
keremsahin | 8:0f55f59ca341 | 41 | BleTestComm bleTestComm(µUSB); |
keremsahin | 8:0f55f59ca341 | 42 | #endif |
keremsahin | 8:0f55f59ca341 | 43 | #endif |
keremsahin | 8:0f55f59ca341 | 44 | |
keremsahin | 8:0f55f59ca341 | 45 | #ifdef LCD_LS013B7DH03 |
keremsahin | 8:0f55f59ca341 | 46 | // Sharp Display Configuration |
keremsahin | 8:0f55f59ca341 | 47 | #include "LS013B7DH03.h" |
keremsahin | 8:0f55f59ca341 | 48 | #include "mbed_logo.h" |
keremsahin | 8:0f55f59ca341 | 49 | volatile bool refreshed = false; |
keremsahin | 8:0f55f59ca341 | 50 | DigitalOut CS(P6_5); |
keremsahin | 8:0f55f59ca341 | 51 | DigitalOut EXTCOM(P6_4); |
keremsahin | 8:0f55f59ca341 | 52 | DigitalOut DISP(P6_6); |
keremsahin | 8:0f55f59ca341 | 53 | SPI displaySPI(P6_2, P6_3, P6_1, NC); |
keremsahin | 8:0f55f59ca341 | 54 | silabs::LS013B7DH03 display(&displaySPI, &CS, &EXTCOM); |
Shaun Kelsey |
0:da5f5b56060a | 55 | |
keremsahin | 8:0f55f59ca341 | 56 | void refreshCallback(void) { |
keremsahin | 8:0f55f59ca341 | 57 | refreshed = true; |
keremsahin | 8:0f55f59ca341 | 58 | } |
keremsahin | 8:0f55f59ca341 | 59 | #endif |
keremsahin | 8:0f55f59ca341 | 60 | |
keremsahin | 8:0f55f59ca341 | 61 | #ifdef ACCEL_BMI160 |
keremsahin | 8:0f55f59ca341 | 62 | #include "bmi160.h" |
keremsahin | 8:0f55f59ca341 | 63 | // Setup BMI160 Accelerometer |
keremsahin | 8:0f55f59ca341 | 64 | //Setup I2C bus for IMU |
keremsahin | 8:0f55f59ca341 | 65 | I2C I2CM2(P5_7, P6_0); /* SDA, SCL */ |
keremsahin | 8:0f55f59ca341 | 66 | BMI160_I2C bmi160_dev(&I2CM2, BMI160_I2C::I2C_ADRS_SDO_LO); |
keremsahin | 8:0f55f59ca341 | 67 | #endif |
keremsahin | 8:0f55f59ca341 | 68 | |
keremsahin | 8:0f55f59ca341 | 69 | /// Pressure Sensor |
keremsahin | 8:0f55f59ca341 | 70 | #if defined(ENABLE_BMP280) |
keremsahin | 8:0f55f59ca341 | 71 | #include "BMP280.h" |
keremsahin | 8:0f55f59ca341 | 72 | BMP280 bmp280_dev(&I2CM2, (0xEC)); |
keremsahin | 8:0f55f59ca341 | 73 | #endif |
keremsahin | 8:0f55f59ca341 | 74 | |
Shaun Kelsey |
0:da5f5b56060a | 75 | |
Shaun Kelsey |
0:da5f5b56060a | 76 | |
keremsahin | 8:0f55f59ca341 | 77 | #ifdef ENABLE_PPG |
keremsahin | 8:0f55f59ca341 | 78 | #include "PpgComm.h" |
keremsahin | 8:0f55f59ca341 | 79 | PpgComm ppgCommHandler(µUSB); |
keremsahin | 8:0f55f59ca341 | 80 | |
keremsahin | 8:0f55f59ca341 | 81 | #ifdef PPG_MAX8614X |
keremsahin | 8:0f55f59ca341 | 82 | #include "MAX8614X.h" |
keremsahin | 8:0f55f59ca341 | 83 | DigitalOut max8614x_cs(P5_3); |
keremsahin | 8:0f55f59ca341 | 84 | PinName max8614x_int = P3_2; |
keremsahin | 8:0f55f59ca341 | 85 | SPI max8614xSPI(P6_2, P6_3, P6_1, NC); |
keremsahin | 8:0f55f59ca341 | 86 | MAX8614X max8614x(max8614xSPI, max8614x_cs, max8614x_int); |
keremsahin | 8:0f55f59ca341 | 87 | #endif |
keremsahin | 8:0f55f59ca341 | 88 | #endif |
keremsahin | 8:0f55f59ca341 | 89 | |
keremsahin | 8:0f55f59ca341 | 90 | #ifdef ENABLE_ECG |
keremsahin | 8:0f55f59ca341 | 91 | #include "EcgComm.h" |
keremsahin | 8:0f55f59ca341 | 92 | EcgComm ecgCommHandler(µUSB); |
keremsahin | 8:0f55f59ca341 | 93 | |
keremsahin | 8:0f55f59ca341 | 94 | #ifdef ECG_MAX30001 |
keremsahin | 8:0f55f59ca341 | 95 | #include "MAX30001.h" |
keremsahin | 8:0f55f59ca341 | 96 | #include "MAX30001_Helper.h" |
keremsahin | 8:0f55f59ca341 | 97 | SPI max30001_spi(P5_1, P5_2, P5_0); |
keremsahin | 8:0f55f59ca341 | 98 | DigitalOut max30001_cs(P5_3); |
keremsahin | 8:0f55f59ca341 | 99 | MAX30001 max30001(&max30001_spi, &max30001_cs); |
keremsahin | 8:0f55f59ca341 | 100 | InterruptIn max30001_InterruptB(P5_5); |
keremsahin | 8:0f55f59ca341 | 101 | InterruptIn max30001_Interrupt2B(P6_2); |
keremsahin | 8:0f55f59ca341 | 102 | #endif |
keremsahin | 8:0f55f59ca341 | 103 | #endif |
keremsahin | 8:0f55f59ca341 | 104 | |
keremsahin | 8:0f55f59ca341 | 105 | #ifdef ENABLE_TP |
keremsahin | 8:0f55f59ca341 | 106 | #include "TempComm.h" |
keremsahin | 8:0f55f59ca341 | 107 | TempComm tpCommHandler(µUSB); |
keremsahin | 8:0f55f59ca341 | 108 | |
keremsahin | 8:0f55f59ca341 | 109 | #ifdef TP_MAX30205 |
keremsahin | 8:0f55f59ca341 | 110 | #include "MAX30205.h" |
keremsahin | 8:0f55f59ca341 | 111 | I2C i2c(P3_4, P3_5); |
keremsahin | 8:0f55f59ca341 | 112 | MAX30205 max30205(&i2c, (0x90 >> 1)); |
keremsahin | 8:0f55f59ca341 | 113 | //enable the LDO for temp sensor |
keremsahin | 8:0f55f59ca341 | 114 | DigitalOut max30205_LDO_EN(P7_1, 1); |
keremsahin | 8:0f55f59ca341 | 115 | #endif |
keremsahin | 8:0f55f59ca341 | 116 | #endif |
keremsahin | 8:0f55f59ca341 | 117 | |
keremsahin | 8:0f55f59ca341 | 118 | #ifdef ENABLE_SMARTSENSOR |
keremsahin | 8:0f55f59ca341 | 119 | #include "SSInterface.h" |
keremsahin | 8:0f55f59ca341 | 120 | I2C ssI2C(P3_4, P3_5); |
keremsahin | 8:0f55f59ca341 | 121 | PinName ss_mfio(P5_4); |
keremsahin | 8:0f55f59ca341 | 122 | PinName ss_reset(P5_6); |
keremsahin | 8:0f55f59ca341 | 123 | SSInterface ssInterface(ssI2C, ss_mfio, ss_reset); |
keremsahin | 8:0f55f59ca341 | 124 | |
keremsahin | 8:0f55f59ca341 | 125 | #ifdef ENABLE_SS_BOOTLOADER |
keremsahin | 8:0f55f59ca341 | 126 | #include "SSBootloaderComm.h" |
keremsahin | 8:0f55f59ca341 | 127 | SSBootloaderComm ssBoot(µUSB, &ssInterface, &dsInterface); |
keremsahin | 8:0f55f59ca341 | 128 | #endif |
keremsahin | 8:0f55f59ca341 | 129 | #ifdef ENABLE_SS_MAX30101 |
keremsahin | 8:0f55f59ca341 | 130 | #include "SSMAX30101Comm.h" |
keremsahin | 8:0f55f59ca341 | 131 | SSMAX30101Comm ssMAX30101(µUSB, &ssInterface, &dsInterface); |
keremsahin | 8:0f55f59ca341 | 132 | #endif |
keremsahin | 8:0f55f59ca341 | 133 | |
keremsahin | 8:0f55f59ca341 | 134 | #ifdef ENABLE_SS_MAX8614X |
keremsahin | 8:0f55f59ca341 | 135 | #include "SSMAX8614XComm.h" |
keremsahin | 8:0f55f59ca341 | 136 | SSMAX8614XComm ssMAX8614X(µUSB, &ssInterface, &dsInterface); |
keremsahin | 8:0f55f59ca341 | 137 | #endif |
keremsahin | 8:0f55f59ca341 | 138 | |
keremsahin | 8:0f55f59ca341 | 139 | #ifdef ENABLE_SS_GENERICMDCOMM |
keremsahin | 8:0f55f59ca341 | 140 | #include "SSGenericCmd.h" |
keremsahin | 8:0f55f59ca341 | 141 | SSGenericCmd ssGenericCmd(µUSB, &ssInterface, &dsInterface); |
keremsahin | 8:0f55f59ca341 | 142 | #endif |
keremsahin | 8:0f55f59ca341 | 143 | #endif |
keremsahin | 8:0f55f59ca341 | 144 | |
keremsahin | 8:0f55f59ca341 | 145 | // MX25U Flash Driver Definition |
keremsahin | 8:0f55f59ca341 | 146 | #ifdef ENABLE_MX25U |
keremsahin | 8:0f55f59ca341 | 147 | #define MHZ_VALUE 1000000 |
keremsahin | 8:0f55f59ca341 | 148 | #define SPI_MHZ 24 |
keremsahin | 8:0f55f59ca341 | 149 | #define SPI_FREQUENCY (SPI_MHZ * MHZ_VALUE) |
keremsahin | 8:0f55f59ca341 | 150 | #include "SPIFBlockDevice.h" |
keremsahin | 8:0f55f59ca341 | 151 | SPIFBlockDevice spif(P1_1, P1_2, P1_0, P1_3, SPI_FREQUENCY); |
keremsahin | 8:0f55f59ca341 | 152 | #endif |
keremsahin | 8:0f55f59ca341 | 153 | // Hardware serial port over DAPLink |
keremsahin | 8:0f55f59ca341 | 154 | Serial daplink(USBTX, USBRX, 115200); |
keremsahin | 8:0f55f59ca341 | 155 | |
keremsahin | 8:0f55f59ca341 | 156 | #ifdef ENABLE_TESTCOMM |
keremsahin | 8:0f55f59ca341 | 157 | #include "TestComm.h" |
keremsahin | 8:0f55f59ca341 | 158 | InterruptIn bmi160_int_pin(P3_6); |
keremsahin | 8:0f55f59ca341 | 159 | TestComm testCommHandler("test", µUSB, &max30001_InterruptB, &max30001_Interrupt2B, &bmi160_int_pin); |
keremsahin | 8:0f55f59ca341 | 160 | #endif |
keremsahin | 8:0f55f59ca341 | 161 | |
keremsahin | 8:0f55f59ca341 | 162 | #ifdef ENABLE_BLE |
keremsahin | 8:0f55f59ca341 | 163 | static void setup_ble() |
Shaun Kelsey |
0:da5f5b56060a | 164 | { |
keremsahin | 8:0f55f59ca341 | 165 | #if defined(PLATFORM_MAX32630HSP) || defined(PLATFORM_MAX32630FTHR) |
keremsahin | 8:0f55f59ca341 | 166 | //Set up BLE communication |
keremsahin | 8:0f55f59ca341 | 167 | BLE& ble = BLE::Instance(); |
keremsahin | 8:0f55f59ca341 | 168 | ble.init(bleInitComplete); |
keremsahin | 8:0f55f59ca341 | 169 | while (BLE::Instance().hasInitialized() == false) { /* spin loop */ } |
keremsahin | 8:0f55f59ca341 | 170 | BLE_Icarus_SetDSInterface(&dsInterface); |
keremsahin | 8:0f55f59ca341 | 171 | |
keremsahin | 8:0f55f59ca341 | 172 | char addr[6]; |
keremsahin | 8:0f55f59ca341 | 173 | BLE_ICARUS_Get_Mac_Address(addr); |
keremsahin | 8:0f55f59ca341 | 174 | printf("BLE MAC: %.2X:%.2X:%.2X:%.2X:%.2X:%.2X", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); |
keremsahin | 8:0f55f59ca341 | 175 | #endif |
keremsahin | 8:0f55f59ca341 | 176 | |
keremsahin | 8:0f55f59ca341 | 177 | } |
keremsahin | 8:0f55f59ca341 | 178 | |
keremsahin | 8:0f55f59ca341 | 179 | static void process_ble() |
keremsahin | 8:0f55f59ca341 | 180 | { |
keremsahin | 8:0f55f59ca341 | 181 | #if defined(PLATFORM_MAX32630HSP) || defined(PLATFORM_MAX32630FTHR) |
keremsahin | 8:0f55f59ca341 | 182 | if(BLE_Icarus_Interface_Exists()){ |
keremsahin | 8:0f55f59ca341 | 183 | BLE_Icarus_TransferDataFromQueue(); |
Shaun Kelsey |
0:da5f5b56060a | 184 | } |
keremsahin | 8:0f55f59ca341 | 185 | BLE::Instance().waitForEvent(); |
keremsahin | 8:0f55f59ca341 | 186 | #endif |
Shaun Kelsey |
0:da5f5b56060a | 187 | } |
Shaun Kelsey |
0:da5f5b56060a | 188 | #endif |
Shaun Kelsey |
0:da5f5b56060a | 189 | |
Shaun Kelsey |
0:da5f5b56060a | 190 | void print_build_version() |
Shaun Kelsey |
0:da5f5b56060a | 191 | { |
keremsahin | 8:0f55f59ca341 | 192 | printf("\n\nICARUS mBED EVKit\r\n"); |
Shaun Kelsey |
0:da5f5b56060a | 193 | printf("Fw version: %s, mbed version: %d\r\n", FIRMWARE_VERSION, MBED_VERSION); |
Shaun Kelsey |
0:da5f5b56060a | 194 | printf("Build source: (%s) %s\r\n", BUILD_SOURCE_BRANCH, BUILD_SOURCE_HASH); |
Shaun Kelsey |
0:da5f5b56060a | 195 | printf("Build time: %s %s\r\n\n", __TIME__, __DATE__); |
Shaun Kelsey |
0:da5f5b56060a | 196 | } |
Shaun Kelsey |
0:da5f5b56060a | 197 | |
keremsahin | 8:0f55f59ca341 | 198 | // main() runs in its own thread in the OS |
keremsahin | 8:0f55f59ca341 | 199 | // (note the calls to Thread::wait below for delays) |
Shaun Kelsey |
0:da5f5b56060a | 200 | int main() |
Shaun Kelsey |
0:da5f5b56060a | 201 | { |
keremsahin | 8:0f55f59ca341 | 202 | wait_ms(500); |
keremsahin | 8:0f55f59ca341 | 203 | // set NVIC priorities for GPIO to prevent priority inversion |
Shaun Kelsey |
0:da5f5b56060a | 204 | daplink.printf("Init NVIC Priorities...\r\n"); |
Shaun Kelsey |
0:da5f5b56060a | 205 | fflush(stdout); |
Shaun Kelsey |
0:da5f5b56060a | 206 | NVIC_SetPriority(GPIO_P0_IRQn, 5); |
Shaun Kelsey |
0:da5f5b56060a | 207 | NVIC_SetPriority(GPIO_P1_IRQn, 5); |
Shaun Kelsey |
0:da5f5b56060a | 208 | NVIC_SetPriority(GPIO_P2_IRQn, 5); |
Shaun Kelsey |
0:da5f5b56060a | 209 | NVIC_SetPriority(GPIO_P3_IRQn, 5); |
Shaun Kelsey |
0:da5f5b56060a | 210 | NVIC_SetPriority(GPIO_P4_IRQn, 5); |
Shaun Kelsey |
0:da5f5b56060a | 211 | NVIC_SetPriority(GPIO_P5_IRQn, 5); |
Shaun Kelsey |
0:da5f5b56060a | 212 | NVIC_SetPriority(GPIO_P6_IRQn, 5); |
keremsahin | 8:0f55f59ca341 | 213 | // used by the MAX30001 |
keremsahin | 8:0f55f59ca341 | 214 | NVIC_SetPriority(SPIM2_IRQn, 0); |
keremsahin | 8:0f55f59ca341 | 215 | //NVIC_SetPriority(SPIM2_IRQn, 0); |
Shaun Kelsey |
0:da5f5b56060a | 216 | print_build_version(); |
Shaun Kelsey |
0:da5f5b56060a | 217 | daplink.printf("daplink serial port\r\n"); |
Shaun Kelsey |
0:da5f5b56060a | 218 | microUSB.printf("micro USB serial port\r\n"); |
Shaun Kelsey |
0:da5f5b56060a | 219 | |
Shaun Kelsey |
0:da5f5b56060a | 220 | dsInterface.set_fw_version(FIRMWARE_VERSION); |
Shaun Kelsey |
0:da5f5b56060a | 221 | dsInterface.set_fw_platform(MAXIM_PLATFORM_NAME); |
Shaun Kelsey |
0:da5f5b56060a | 222 | Peripherals::setUSBSerial(µUSB); |
Shaun Kelsey |
0:da5f5b56060a | 223 | |
keremsahin | 8:0f55f59ca341 | 224 | #ifdef ENABLE_BLE |
keremsahin | 8:0f55f59ca341 | 225 | setup_ble(); |
keremsahin | 8:0f55f59ca341 | 226 | #ifdef ENABLE_BLETEST_COMM |
keremsahin | 8:0f55f59ca341 | 227 | dsInterface.add_sensor_comm(&bleTestComm); |
keremsahin | 8:0f55f59ca341 | 228 | #endif |
keremsahin | 8:0f55f59ca341 | 229 | #endif |
keremsahin | 8:0f55f59ca341 | 230 | |
keremsahin | 8:0f55f59ca341 | 231 | #ifdef LCD_LS013B7DH03 |
keremsahin | 8:0f55f59ca341 | 232 | // Push update to the display |
keremsahin | 8:0f55f59ca341 | 233 | display.showBMP((uint8_t*)maxim_integrated_logo, 128, 128, 0, 0); |
keremsahin | 8:0f55f59ca341 | 234 | refreshed = false; |
keremsahin | 8:0f55f59ca341 | 235 | display.update(refreshCallback); |
keremsahin | 8:0f55f59ca341 | 236 | // wait while doing the refreshing the screen |
keremsahin | 8:0f55f59ca341 | 237 | while(refreshed == false){ |
keremsahin | 8:0f55f59ca341 | 238 | // sleep(); |
keremsahin | 8:0f55f59ca341 | 239 | } |
keremsahin | 8:0f55f59ca341 | 240 | #endif |
keremsahin | 8:0f55f59ca341 | 241 | |
keremsahin | 8:0f55f59ca341 | 242 | |
keremsahin | 8:0f55f59ca341 | 243 | |
keremsahin | 8:0f55f59ca341 | 244 | #ifdef ENABLE_PPG |
keremsahin | 8:0f55f59ca341 | 245 | #ifdef PPG_MAX8614X |
keremsahin | 8:0f55f59ca341 | 246 | // |
keremsahin | 8:0f55f59ca341 | 247 | //MAX86140 |
keremsahin | 8:0f55f59ca341 | 248 | // |
keremsahin | 8:0f55f59ca341 | 249 | ppgCommHandler.comm_init(&max8614x); |
keremsahin | 8:0f55f59ca341 | 250 | //NOTE: setting SPI pin mapping here, since Sharp display uses same bus with different mapping |
keremsahin | 8:0f55f59ca341 | 251 | SPI spi(P5_1, P5_2, P5_0); /* mosi, miso, sclk */ |
keremsahin | 8:0f55f59ca341 | 252 | max8614x.init(); |
keremsahin | 8:0f55f59ca341 | 253 | printf("Sensor: %s\r\n", max8614x.get_sensor_part_name()); |
keremsahin | 8:0f55f59ca341 | 254 | #endif |
keremsahin | 8:0f55f59ca341 | 255 | #if ACCEL_BMI160 |
keremsahin | 8:0f55f59ca341 | 256 | ppgCommHandler.setBMI160(&bmi160_dev); |
keremsahin | 8:0f55f59ca341 | 257 | #endif |
keremsahin | 8:0f55f59ca341 | 258 | dsInterface.add_sensor_comm(&ppgCommHandler); |
keremsahin | 8:0f55f59ca341 | 259 | #endif |
keremsahin | 8:0f55f59ca341 | 260 | |
keremsahin | 8:0f55f59ca341 | 261 | #ifdef ENABLE_ECG |
keremsahin | 8:0f55f59ca341 | 262 | #ifdef ECG_MAX30001 |
keremsahin | 8:0f55f59ca341 | 263 | // |
keremsahin | 8:0f55f59ca341 | 264 | // MAX30001 |
keremsahin | 8:0f55f59ca341 | 265 | // |
keremsahin | 8:0f55f59ca341 | 266 | printf("Init MAX30001 callbacks, interrupts...\r\n"); |
keremsahin | 8:0f55f59ca341 | 267 | MAX30001_Helper m_max30001helper(&max30001, &max30001_InterruptB, &max30001_Interrupt2B); |
keremsahin | 8:0f55f59ca341 | 268 | Peripherals::setMAX30001(&max30001); |
keremsahin | 8:0f55f59ca341 | 269 | Peripherals::setMAX30001Helper(&m_max30001helper); |
keremsahin | 8:0f55f59ca341 | 270 | ecgCommHandler.comm_init(&m_max30001helper); |
keremsahin | 8:0f55f59ca341 | 271 | #endif |
keremsahin | 8:0f55f59ca341 | 272 | dsInterface.add_sensor_comm(&ecgCommHandler); |
keremsahin | 8:0f55f59ca341 | 273 | #endif |
keremsahin | 8:0f55f59ca341 | 274 | |
keremsahin | 8:0f55f59ca341 | 275 | #ifdef ENABLE_TP |
keremsahin | 8:0f55f59ca341 | 276 | #ifdef TP_MAX30205 |
keremsahin | 8:0f55f59ca341 | 277 | // |
keremsahin | 8:0f55f59ca341 | 278 | //MAX30205 |
keremsahin | 8:0f55f59ca341 | 279 | // |
keremsahin | 8:0f55f59ca341 | 280 | tpCommHandler.comm_init(&max30205); |
keremsahin | 8:0f55f59ca341 | 281 | #endif |
keremsahin | 8:0f55f59ca341 | 282 | dsInterface.add_sensor_comm(&tpCommHandler); |
keremsahin | 8:0f55f59ca341 | 283 | #endif |
keremsahin | 8:0f55f59ca341 | 284 | |
keremsahin | 8:0f55f59ca341 | 285 | #ifdef ENABLE_SMARTSENSOR |
keremsahin | 8:0f55f59ca341 | 286 | //Configure mfio as a level based interrupt (no mbed API for this, must use Maxim-specific code) |
keremsahin | 8:0f55f59ca341 | 287 | //gpio_cfg_t mfio_gpio_cfg = {PORT_5, PIN_4, GPIO_FUNC_GPIO, GPIO_PAD_INPUT_PULLUP}; |
keremsahin | 8:0f55f59ca341 | 288 | //GPIO_IntConfig(&mfio_gpio_cfg, GPIO_INT_LOW_LEVEL); |
Shaun Kelsey |
0:da5f5b56060a | 289 | ssI2C.frequency(400000); |
Shaun Kelsey |
0:da5f5b56060a | 290 | dsInterface.set_fw_platform(ssInterface.get_ss_platform_name()); |
Shaun Kelsey |
0:da5f5b56060a | 291 | dsInterface.set_fw_version(ssInterface.get_ss_fw_version()); |
keremsahin | 8:0f55f59ca341 | 292 | #ifdef ENABLE_SS_BOOTLOADER |
Shaun Kelsey |
0:da5f5b56060a | 293 | dsInterface.add_sensor_comm(&ssBoot); |
keremsahin | 8:0f55f59ca341 | 294 | #endif |
keremsahin | 8:0f55f59ca341 | 295 | #ifdef ENABLE_SS_MAX30101 |
Shaun Kelsey |
0:da5f5b56060a | 296 | dsInterface.add_sensor_comm(&ssMAX30101); |
keremsahin | 8:0f55f59ca341 | 297 | #endif |
keremsahin | 8:0f55f59ca341 | 298 | #ifdef ENABLE_SS_MAX8614X |
keremsahin | 8:0f55f59ca341 | 299 | dsInterface.add_sensor_comm(&ssMAX8614X); |
keremsahin | 8:0f55f59ca341 | 300 | #endif |
keremsahin | 8:0f55f59ca341 | 301 | #ifdef ENABLE_SS_GENERICMDCOMM |
keremsahin | 8:0f55f59ca341 | 302 | dsInterface.add_sensor_comm(&ssGenericCmd); |
keremsahin | 8:0f55f59ca341 | 303 | #endif |
keremsahin | 8:0f55f59ca341 | 304 | #endif |
Shaun Kelsey |
0:da5f5b56060a | 305 | |
Shaun Kelsey |
0:da5f5b56060a | 306 | #ifdef ENABLE_LED_STATUS |
keremsahin | 8:0f55f59ca341 | 307 | #ifdef ENABLE_SMARTSENSOR |
keremsahin | 8:0f55f59ca341 | 308 | //Blink green if SmartSensor is present, yellow otherwise |
keremsahin | 8:0f55f59ca341 | 309 | SS_STATUS status = ssInterface.ss_comm_check(); |
keremsahin | 8:0f55f59ca341 | 310 | if (status == SS_SUCCESS) |
keremsahin | 8:0f55f59ca341 | 311 | ledStatus.set_state(LED_OFF, LED_ON, LED_OFF); |
keremsahin | 8:0f55f59ca341 | 312 | else |
keremsahin | 8:0f55f59ca341 | 313 | ledStatus.set_state(LED_ON, LED_ON, LED_OFF); |
keremsahin | 8:0f55f59ca341 | 314 | ledStatus.blink(100, 1900); |
keremsahin | 8:0f55f59ca341 | 315 | #else |
keremsahin | 8:0f55f59ca341 | 316 | ledStatus.set_state(LED_OFF, LED_ON, LED_OFF); |
keremsahin | 8:0f55f59ca341 | 317 | #endif |
keremsahin | 8:0f55f59ca341 | 318 | ledStatus.blink(100, 1900); |
keremsahin | 8:0f55f59ca341 | 319 | #endif |
Shaun Kelsey |
0:da5f5b56060a | 320 | |
keremsahin | 8:0f55f59ca341 | 321 | #ifdef ENABLE_TESTCOMM |
keremsahin | 8:0f55f59ca341 | 322 | // |
keremsahin | 8:0f55f59ca341 | 323 | // Test class related variables |
keremsahin | 8:0f55f59ca341 | 324 | // |
keremsahin | 8:0f55f59ca341 | 325 | InterruptIn sw_one(P2_3); |
keremsahin | 8:0f55f59ca341 | 326 | InterruptIn sw_two(P4_1); |
keremsahin | 8:0f55f59ca341 | 327 | InterruptIn ss_mfio_int(P3_0); |
keremsahin | 8:0f55f59ca341 | 328 | DigitalOut ss_reset_pin(P5_6, 1); // should this be pinname? |
keremsahin | 8:0f55f59ca341 | 329 | testCommHandler.Test_AddAccBmi160(&bmi160_dev); |
keremsahin | 8:0f55f59ca341 | 330 | testCommHandler.Test_AddTempMax30205(&max30205); |
keremsahin | 8:0f55f59ca341 | 331 | testCommHandler.Test_AddFlashMx25U1(&spif); |
keremsahin | 8:0f55f59ca341 | 332 | testCommHandler.Test_AddPressBMP280(&bmp280_dev); |
keremsahin | 8:0f55f59ca341 | 333 | testCommHandler.Test_AddPmicMax20303(&icarus.max20303); |
keremsahin | 8:0f55f59ca341 | 334 | testCommHandler.Test_AddECGMax30001(&max30001); |
keremsahin | 8:0f55f59ca341 | 335 | testCommHandler.Test_AttachSWButtons(&sw_one, &sw_two); |
keremsahin | 8:0f55f59ca341 | 336 | testCommHandler.Test_SetSSParameter(&i2c, &ss_mfio_int, &ss_reset_pin); |
keremsahin | 8:0f55f59ca341 | 337 | dsInterface.add_sensor_comm(&testCommHandler); |
Shaun Kelsey |
0:da5f5b56060a | 338 | #endif |
Shaun Kelsey |
0:da5f5b56060a | 339 | |
Shaun Kelsey |
0:da5f5b56060a | 340 | while(1) { |
Shaun Kelsey |
0:da5f5b56060a | 341 | USBSerial *serial = µUSB; |
Shaun Kelsey |
0:da5f5b56060a | 342 | uint8_t ch; |
Shaun Kelsey |
0:da5f5b56060a | 343 | while (serial->readable()) { |
Shaun Kelsey |
0:da5f5b56060a | 344 | ch = serial->_getc(); |
keremsahin | 8:0f55f59ca341 | 345 | //dsInterface.enable_console_interface(); |
Shaun Kelsey |
0:da5f5b56060a | 346 | dsInterface.enable_console_interface(); |
Shaun Kelsey |
0:da5f5b56060a | 347 | dsInterface.build_command(ch); |
Shaun Kelsey |
0:da5f5b56060a | 348 | } |
Shaun Kelsey |
0:da5f5b56060a | 349 | |
Shaun Kelsey |
0:da5f5b56060a | 350 | dsInterface.data_report_execute(); |
keremsahin | 8:0f55f59ca341 | 351 | #ifdef ENABLE_BLE |
keremsahin | 8:0f55f59ca341 | 352 | process_ble(); |
keremsahin | 8:0f55f59ca341 | 353 | #endif |
Shaun Kelsey |
0:da5f5b56060a | 354 | #ifdef ENABLE_LED_STATUS |
keremsahin | 8:0f55f59ca341 | 355 | ledStatus.update(); |
Shaun Kelsey |
0:da5f5b56060a | 356 | #endif |
Shaun Kelsey |
0:da5f5b56060a | 357 | } |
Shaun Kelsey |
0:da5f5b56060a | 358 | } |