Maxim Integrated's IoT development kit
Dependencies: MAX30101 MAX30003 MAX113XX_Pixi MAX30205 max32630fthr USBDevice
Diff: main.cpp
- Revision:
- 5:ff721fa88519
- Parent:
- 4:cc427aa37aee
- Child:
- 6:aeb5a4c194c3
--- a/main.cpp Fri Mar 16 23:51:18 2018 +0300
+++ b/main.cpp Mon Mar 19 17:22:37 2018 +0300
@@ -118,8 +118,8 @@
#if defined(LIB_MAX113XX_PIXI)
UUID uuidADC("00001527-1d66-11e8-b467-0ed5f89f718b");
-static uint16_t ADCInitValue = 0;
-ReadOnlyGattCharacteristic<uint16_t> gattCharADC(uuidADC, &ADCInitValue,
+static float ADCInitValue = 0;
+ReadOnlyGattCharacteristic<float> gattCharADC(uuidADC, &ADCInitValue,
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY);
#endif
@@ -844,48 +844,55 @@
// Read back ECG samples from the FIFO
thread_max30003_reader.signal_wait(MAX30003_IRQ_ASSERTED_SIGNAL_ID);
- /* Read back ECG samples from the FIFO */
- status = max30003.readRegister( MAX30003::STATUS ); // Read the STATUS register
+ while (1) {
+ /* Read back ECG samples from the FIFO */
+ status = max30003.readRegister( MAX30003::STATUS ); // Read the STATUS register
+
+ if (status & (RTOR_STATUS | EINT_STATUS) == 0) {
+ break;
+ }
- // Check if R-to-R interrupt asserted
- if ((status & RTOR_STATUS) == RTOR_STATUS) {
+ // Check if R-to-R interrupt asserted
+ if ((status & RTOR_STATUS) == RTOR_STATUS) {
+
+ daplink.printf("R-to-R Interrupt \r\n");
- daplink.printf("R-to-R Interrupt \r\n");
+ // Read RtoR register
+ RtoR = max30003.readRegister( MAX30003::RTOR ) >> RTOR_REG_OFFSET;
+
+ // Convert to BPM
+ BPM = 1.0f / ( RtoR * RTOR_LSB_RES / 60.0f );
+
+ daplink.printf("BPM: %.2f\r\n", BPM);
- // Read RtoR register
- RtoR = max30003.readRegister( MAX30003::RTOR ) >> RTOR_REG_OFFSET;
+ if (bleNotifyTimer.read_ms() >= (MAX30003_BLE_NOTIFY_PERIOD_SEC * 1000)) {
+ bleGattAttrWrite(gattCharBPM.getValueHandle(), (uint8_t *)&BPM, sizeof(BPM));
+ bleNotifyTimer.reset();
+ }
+ }
- // Convert to BPM
- BPM = 1.0f / ( RtoR * RTOR_LSB_RES / 60.0f );
+ // Check if EINT interrupt asserted
+ if ((status & EINT_STATUS) == EINT_STATUS) {
+ readECGSamples = 0; // Reset sample counter
- daplink.printf("BPM: %.2f\r\n", BPM);
+ do {
+ ecgFIFO = max30003.readRegister( MAX30003::ECG_FIFO ); // Read FIFO
+ ecgSample[readECGSamples] = ecgFIFO >> 8; // Isolate voltage data
+ ETAG[readECGSamples] = ( ecgFIFO >> 3 ) & ETAG_BITS; // Isolate ETAG
+ readECGSamples++; // Increment sample counter
- if (bleNotifyTimer.read_ms() >= (MAX30003_BLE_NOTIFY_PERIOD_SEC * 1000)) {
- bleGattAttrWrite(gattCharBPM.getValueHandle(), (uint8_t *)&BPM, sizeof(BPM));
- bleNotifyTimer.reset();
+ // Check that sample is not last sample in FIFO
+ } while (ETAG[readECGSamples-1] == FIFO_VALID_SAMPLE ||
+ ETAG[readECGSamples-1] == FIFO_FAST_SAMPLE);
+
+ // Check if FIFO has overflowed
+ if (ETAG[readECGSamples - 1] == FIFO_OVF){
+ max30003.writeRegister( MAX30003::FIFO_RST , 0); // Reset FIFO
+ rLED = 1;
+ }
}
}
- // Check if EINT interrupt asserted
- if ((status & EINT_STATUS) == EINT_STATUS) {
- readECGSamples = 0; // Reset sample counter
-
- do {
- ecgFIFO = max30003.readRegister( MAX30003::ECG_FIFO ); // Read FIFO
- ecgSample[readECGSamples] = ecgFIFO >> 8; // Isolate voltage data
- ETAG[readECGSamples] = ( ecgFIFO >> 3 ) & ETAG_BITS; // Isolate ETAG
- readECGSamples++; // Increment sample counter
-
- // Check that sample is not last sample in FIFO
- } while (ETAG[readECGSamples-1] == FIFO_VALID_SAMPLE ||
- ETAG[readECGSamples-1] == FIFO_FAST_SAMPLE);
-
- // Check if FIFO has overflowed
- if (ETAG[readECGSamples - 1] == FIFO_OVF){
- max30003.writeRegister( MAX30003::FIFO_RST , 0); // Reset FIFO
- rLED = 1;
- }
- }
}
}
@@ -919,7 +926,7 @@
daplink.printf("ADC Read is : %i,\tVoltage is %1.3f V \r\n", adcData, adcVoltage);
- bleGattAttrWrite(gattCharADC.getValueHandle(), (uint8_t *)&adcData, sizeof(adcData));
+ bleGattAttrWrite(gattCharADC.getValueHandle(), (uint8_t *)&adcVoltage, sizeof(adcVoltage));
Thread::wait(MAX113XX_PIXI_BLE_NOTIFY_PERIOD_SEC * 1000);
}