![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Interrupt
Dependencies: BLE_API BLE_Driver I2C_Driver MAX30100 PROCESAMIENTO_DATOS_SP02 mbed nRF51822 millis
Fork of MAX30100_FirstTry by
mainbletest.cpp
- Committer:
- Ferszt
- Date:
- 2017-03-28
- Revision:
- 3:98ca4bf2e74a
- Parent:
- 2:065060bb55f2
- Child:
- 5:c2ce7b743efa
File content as of revision 3:98ca4bf2e74a:
#include "mbed.h" #include "Ticker.h" #include "BLE_Driver.h" #include "MAX30100.h" #include "I2C_Driver.h" #include "PROCESAMIENTO_SPO2_FC.h" #define nRF51DK //#define nRF52DK #ifdef nRF52DK #define SCL 28 #define SDA 29 #endif #ifdef nRF51DK #define SCL 7 #define SDA 6 #endif //************************** int muestras_RED[200]; int muestras_IR[200]; int samples_index = 0; int max_min_period[2]; int pico_pico,cresta, valle, cantidad; float frecuencia,periodo; int index, aux1, nmuestra; char show[10]; //****************** InterruptIn SMPRDY(p0); DigitalOut LIVE_LED(p21, 1); DigitalOut CONECT_LED(p22, 1); DigitalOut TEST_LED(p23, 1); DigitalOut LED(p24, 1); //DigitalIn TEST_BUTTON(p17,PullUp); Ticker Flasher; MAX30100 sensor; void callbackBLE(int event) { switch (event){ case 1: CONECT_LED = 1; break; case 2: CONECT_LED = 0; break; default: break; } } void periodicCallback(void){ LIVE_LED =! LIVE_LED; } void store_Samples(void){ if (samples_index == 200){ periodo = valores(muestras_IR,max_min_period); frecuencia=60/(periodo*0.02); samples_index = 0; sprintf(show, "%f", frecuencia); putBLE(show); putBLE("\n"); } else{ muestras_RED[samples_index] = sensor.RED; muestras_IR[samples_index] = sensor.IR; sprintf(show, "%d", muestras_IR[samples_index]); putBLE(show); putBLE("\n"); samples_index++; } } void sample(void){ LED = 0; sensor.readSensor(); sprintf(show, "%d", sensor.IR); putBLE(show); putBLE("\n"); } int main(void){ SMPRDY.fall(&sample); Flasher.attach(periodicCallback, 1); ini_i2c(SCL, SDA); sensor.begin(pw1600, i17, sr50 ); iniBLE("Sigfried"); while(1){ //sensor.readSensor(); //store_Samples(); //wait(0.019); } }