![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Intento 4
Dependencies: BLE_API BLE_Driver I2C_Driver MAX30100 PROCESAMIENTO_DATOS_SP02 mbed millis nRF51822
Fork of MAX30100_FirstTry by
mainbletest.cpp@3:98ca4bf2e74a, 2017-03-28 (annotated)
- Committer:
- Ferszt
- Date:
- Tue Mar 28 23:16:39 2017 +0000
- Revision:
- 3:98ca4bf2e74a
- Parent:
- 2:065060bb55f2
- Child:
- 5:c2ce7b743efa
Interrupt not working
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Ferszt | 0:882170680817 | 1 | #include "mbed.h" |
Ferszt | 1:33d65d13c46a | 2 | #include "Ticker.h" |
Ferszt | 0:882170680817 | 3 | #include "BLE_Driver.h" |
Ferszt | 1:33d65d13c46a | 4 | #include "MAX30100.h" |
Ferszt | 1:33d65d13c46a | 5 | #include "I2C_Driver.h" |
Ferszt | 1:33d65d13c46a | 6 | #include "PROCESAMIENTO_SPO2_FC.h" |
Ferszt | 1:33d65d13c46a | 7 | |
Ferszt | 1:33d65d13c46a | 8 | #define nRF51DK |
Ferszt | 1:33d65d13c46a | 9 | //#define nRF52DK |
Ferszt | 1:33d65d13c46a | 10 | |
Ferszt | 1:33d65d13c46a | 11 | |
Ferszt | 1:33d65d13c46a | 12 | #ifdef nRF52DK |
Ferszt | 1:33d65d13c46a | 13 | #define SCL 28 |
Ferszt | 1:33d65d13c46a | 14 | #define SDA 29 |
Ferszt | 1:33d65d13c46a | 15 | #endif |
Ferszt | 1:33d65d13c46a | 16 | |
Ferszt | 1:33d65d13c46a | 17 | #ifdef nRF51DK |
Ferszt | 1:33d65d13c46a | 18 | #define SCL 7 |
Ferszt | 1:33d65d13c46a | 19 | #define SDA 6 |
Ferszt | 1:33d65d13c46a | 20 | #endif |
Ferszt | 0:882170680817 | 21 | |
Ferszt | 1:33d65d13c46a | 22 | //************************** |
Ferszt | 1:33d65d13c46a | 23 | int muestras_RED[200]; |
Ferszt | 1:33d65d13c46a | 24 | int muestras_IR[200]; |
Ferszt | 1:33d65d13c46a | 25 | int samples_index = 0; |
cesarcazal | 2:065060bb55f2 | 26 | int max_min_period[2]; |
Ferszt | 1:33d65d13c46a | 27 | int pico_pico,cresta, valle, cantidad; |
Ferszt | 1:33d65d13c46a | 28 | float frecuencia,periodo; |
Ferszt | 1:33d65d13c46a | 29 | |
Ferszt | 1:33d65d13c46a | 30 | int index, aux1, nmuestra; |
Ferszt | 1:33d65d13c46a | 31 | |
Ferszt | 3:98ca4bf2e74a | 32 | char show[10]; |
cesarcazal | 2:065060bb55f2 | 33 | |
Ferszt | 1:33d65d13c46a | 34 | //****************** |
Ferszt | 1:33d65d13c46a | 35 | |
Ferszt | 3:98ca4bf2e74a | 36 | InterruptIn SMPRDY(p0); |
Ferszt | 3:98ca4bf2e74a | 37 | DigitalOut LIVE_LED(p21, 1); |
Ferszt | 3:98ca4bf2e74a | 38 | DigitalOut CONECT_LED(p22, 1); |
Ferszt | 3:98ca4bf2e74a | 39 | DigitalOut TEST_LED(p23, 1); |
Ferszt | 3:98ca4bf2e74a | 40 | DigitalOut LED(p24, 1); |
Ferszt | 3:98ca4bf2e74a | 41 | //DigitalIn TEST_BUTTON(p17,PullUp); |
Ferszt | 1:33d65d13c46a | 42 | |
Ferszt | 1:33d65d13c46a | 43 | Ticker Flasher; |
Ferszt | 1:33d65d13c46a | 44 | MAX30100 sensor; |
Ferszt | 0:882170680817 | 45 | |
Ferszt | 0:882170680817 | 46 | void callbackBLE(int event) { |
Ferszt | 0:882170680817 | 47 | switch (event){ |
Ferszt | 1:33d65d13c46a | 48 | case 1: CONECT_LED = 1; break; |
Ferszt | 1:33d65d13c46a | 49 | case 2: CONECT_LED = 0; break; |
Ferszt | 0:882170680817 | 50 | default: break; |
Ferszt | 0:882170680817 | 51 | } |
Ferszt | 0:882170680817 | 52 | } |
Ferszt | 0:882170680817 | 53 | |
Ferszt | 0:882170680817 | 54 | void periodicCallback(void){ |
Ferszt | 0:882170680817 | 55 | LIVE_LED =! LIVE_LED; |
Ferszt | 0:882170680817 | 56 | } |
Ferszt | 0:882170680817 | 57 | |
Ferszt | 1:33d65d13c46a | 58 | void store_Samples(void){ |
Ferszt | 1:33d65d13c46a | 59 | if (samples_index == 200){ |
cesarcazal | 2:065060bb55f2 | 60 | periodo = valores(muestras_IR,max_min_period); |
Ferszt | 1:33d65d13c46a | 61 | frecuencia=60/(periodo*0.02); |
Ferszt | 1:33d65d13c46a | 62 | samples_index = 0; |
Ferszt | 1:33d65d13c46a | 63 | sprintf(show, "%f", frecuencia); |
Ferszt | 1:33d65d13c46a | 64 | putBLE(show); |
Ferszt | 1:33d65d13c46a | 65 | putBLE("\n"); |
Ferszt | 1:33d65d13c46a | 66 | } |
Ferszt | 1:33d65d13c46a | 67 | else{ |
Ferszt | 1:33d65d13c46a | 68 | muestras_RED[samples_index] = sensor.RED; |
Ferszt | 1:33d65d13c46a | 69 | muestras_IR[samples_index] = sensor.IR; |
cesarcazal | 2:065060bb55f2 | 70 | sprintf(show, "%d", muestras_IR[samples_index]); |
cesarcazal | 2:065060bb55f2 | 71 | putBLE(show); |
cesarcazal | 2:065060bb55f2 | 72 | putBLE("\n"); |
Ferszt | 1:33d65d13c46a | 73 | samples_index++; |
Ferszt | 1:33d65d13c46a | 74 | } |
Ferszt | 1:33d65d13c46a | 75 | } |
Ferszt | 3:98ca4bf2e74a | 76 | |
Ferszt | 3:98ca4bf2e74a | 77 | void sample(void){ |
Ferszt | 3:98ca4bf2e74a | 78 | LED = 0; |
Ferszt | 3:98ca4bf2e74a | 79 | sensor.readSensor(); |
Ferszt | 3:98ca4bf2e74a | 80 | sprintf(show, "%d", sensor.IR); |
Ferszt | 3:98ca4bf2e74a | 81 | putBLE(show); |
Ferszt | 3:98ca4bf2e74a | 82 | putBLE("\n"); |
Ferszt | 3:98ca4bf2e74a | 83 | } |
Ferszt | 0:882170680817 | 84 | int main(void){ |
Ferszt | 3:98ca4bf2e74a | 85 | SMPRDY.fall(&sample); |
Ferszt | 0:882170680817 | 86 | Flasher.attach(periodicCallback, 1); |
Ferszt | 1:33d65d13c46a | 87 | ini_i2c(SCL, SDA); |
Ferszt | 1:33d65d13c46a | 88 | sensor.begin(pw1600, i17, sr50 ); |
Ferszt | 0:882170680817 | 89 | iniBLE("Sigfried"); |
Ferszt | 0:882170680817 | 90 | while(1){ |
Ferszt | 3:98ca4bf2e74a | 91 | //sensor.readSensor(); |
Ferszt | 3:98ca4bf2e74a | 92 | //store_Samples(); |
Ferszt | 3:98ca4bf2e74a | 93 | //wait(0.019); |
Ferszt | 0:882170680817 | 94 | } |
Ferszt | 0:882170680817 | 95 | } |
Ferszt | 0:882170680817 | 96 | |
Ferszt | 1:33d65d13c46a | 97 |