First try

Dependencies:   BLE_API BLE_Driver I2C_Driver MAX30100 millis mbed nRF51822

Fork of BLE_Driver_Example by TESIS SATUROMETRICA

Committer:
Ferszt
Date:
Tue May 30 00:20:34 2017 +0000
Revision:
3:cb0290a123d2
commit 1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Ferszt 3:cb0290a123d2 1 #include "mbed.h"
Ferszt 3:cb0290a123d2 2 #include "Ticker.h"
Ferszt 3:cb0290a123d2 3 #include "BLE_Driver.h"
Ferszt 3:cb0290a123d2 4 #include "MAX30100_RaivisStrogonovs.h"
Ferszt 3:cb0290a123d2 5 #include "I2C_Driver.h"
Ferszt 3:cb0290a123d2 6 #include "millis.h"
Ferszt 3:cb0290a123d2 7
Ferszt 3:cb0290a123d2 8 #define nRF51DK
Ferszt 3:cb0290a123d2 9 //#define nRF52DK
Ferszt 3:cb0290a123d2 10
Ferszt 3:cb0290a123d2 11
Ferszt 3:cb0290a123d2 12 #ifdef nRF52DK
Ferszt 3:cb0290a123d2 13 #define SCL 28
Ferszt 3:cb0290a123d2 14 #define SDA 29
Ferszt 3:cb0290a123d2 15 #endif
Ferszt 3:cb0290a123d2 16
Ferszt 3:cb0290a123d2 17 #ifdef nRF51DK
Ferszt 3:cb0290a123d2 18 #define SCL 7
Ferszt 3:cb0290a123d2 19 #define SDA 6
Ferszt 3:cb0290a123d2 20 #endif
Ferszt 3:cb0290a123d2 21
Ferszt 3:cb0290a123d2 22
Ferszt 3:cb0290a123d2 23 InterruptIn SMPRDY(p1);
Ferszt 3:cb0290a123d2 24 DigitalOut LIVE_LED(p21, 1);
Ferszt 3:cb0290a123d2 25 DigitalOut CONECT_LED(p22, 1);
Ferszt 3:cb0290a123d2 26 DigitalOut TEST_LED(p23, 1);
Ferszt 3:cb0290a123d2 27 DigitalOut LED(p24, 1);
Ferszt 3:cb0290a123d2 28 DigitalIn TEST_BUTTON(p17,PullUp);
Ferszt 3:cb0290a123d2 29
Ferszt 3:cb0290a123d2 30 Ticker Flasher;
Ferszt 3:cb0290a123d2 31 MAX30100* pulseOxymeter;
Ferszt 3:cb0290a123d2 32
Ferszt 3:cb0290a123d2 33 char show[10];
Ferszt 3:cb0290a123d2 34
Ferszt 3:cb0290a123d2 35 void callbackBLE(int event) {
Ferszt 3:cb0290a123d2 36 switch (event){
Ferszt 3:cb0290a123d2 37 case 1: CONECT_LED = 1; break;
Ferszt 3:cb0290a123d2 38 case 2: CONECT_LED = 0; break;
Ferszt 3:cb0290a123d2 39 default: break;
Ferszt 3:cb0290a123d2 40 }
Ferszt 3:cb0290a123d2 41 }
Ferszt 3:cb0290a123d2 42
Ferszt 3:cb0290a123d2 43 void periodicCallback(void){
Ferszt 3:cb0290a123d2 44 uint8_t a;
Ferszt 3:cb0290a123d2 45 a = getBLE();
Ferszt 3:cb0290a123d2 46 }
Ferszt 3:cb0290a123d2 47
Ferszt 3:cb0290a123d2 48 int main(void){
Ferszt 3:cb0290a123d2 49 millisStart();
Ferszt 3:cb0290a123d2 50 pulseoxymeter_t result;
Ferszt 3:cb0290a123d2 51 //SMPRDY.fall(&sample);
Ferszt 3:cb0290a123d2 52 Flasher.attach(periodicCallback, 1);
Ferszt 3:cb0290a123d2 53 ini_i2c(SCL, SDA);
Ferszt 3:cb0290a123d2 54 iniBLE("Sigfried");
Ferszt 3:cb0290a123d2 55 pulseOxymeter = new MAX30100( DEFAULT_OPERATING_MODE, DEFAULT_SAMPLING_RATE, DEFAULT_LED_PULSE_WIDTH, DEFAULT_IR_LED_CURRENT, true, true );
Ferszt 3:cb0290a123d2 56 while(1){
Ferszt 3:cb0290a123d2 57 result = pulseOxymeter->update();
Ferszt 3:cb0290a123d2 58
Ferszt 3:cb0290a123d2 59 if( result.pulseDetected == true )
Ferszt 3:cb0290a123d2 60 {
Ferszt 3:cb0290a123d2 61 putBLE("Registers: \n");
Ferszt 3:cb0290a123d2 62 putBLE("BEAT");
Ferszt 3:cb0290a123d2 63
Ferszt 3:cb0290a123d2 64 putBLE( "BPM: " );
Ferszt 3:cb0290a123d2 65 sprintf(show, "%f", result.heartBPM );
Ferszt 3:cb0290a123d2 66 putBLE(show);
Ferszt 3:cb0290a123d2 67 putBLE( " | " );
Ferszt 3:cb0290a123d2 68
Ferszt 3:cb0290a123d2 69 putBLE( "SaO2: " );
Ferszt 3:cb0290a123d2 70 sprintf(show, "%f", result.SaO2 );
Ferszt 3:cb0290a123d2 71 putBLE(show);
Ferszt 3:cb0290a123d2 72 putBLE( "%" );
Ferszt 3:cb0290a123d2 73
Ferszt 3:cb0290a123d2 74 putBLE("{P2|BPM|255,40,0|");
Ferszt 3:cb0290a123d2 75 sprintf(show, "%f", result.heartBPM );
Ferszt 3:cb0290a123d2 76 putBLE(show);
Ferszt 3:cb0290a123d2 77 putBLE("|SaO2|0,0,255|");
Ferszt 3:cb0290a123d2 78 sprintf(show, "%f", result.SaO2 );
Ferszt 3:cb0290a123d2 79 putBLE(show);
Ferszt 3:cb0290a123d2 80 putBLE("}");
Ferszt 3:cb0290a123d2 81 }
Ferszt 3:cb0290a123d2 82 }
Ferszt 3:cb0290a123d2 83 }
Ferszt 3:cb0290a123d2 84
Ferszt 3:cb0290a123d2 85