Projet_BMC
/
MAX3010x_RD117_MBED_
MAXREFDES#117
Diff: main.cpp
- Revision:
- 5:e7b8e61b1fe1
- Parent:
- 4:5273ab1085ab
diff -r 5273ab1085ab -r e7b8e61b1fe1 main.cpp --- a/main.cpp Thu May 19 22:04:06 2016 +0000 +++ b/main.cpp Mon Jan 27 11:27:41 2020 +0000 @@ -74,6 +74,7 @@ #include "mbed.h" #include "algorithm.h" #include "MAX30102.h" +#include "USBSerial.h" #define MAX_BRIGHTNESS 255 @@ -86,7 +87,9 @@ int8_t ch_hr_valid; //indicator to show if the heart rate calculation is valid uint8_t uch_dummy; -Serial pc(USBTX, USBRX); //initializes the serial port +USBSerial pc; //initializes the serial port + +/* #ifdef TARGET_KL25Z PwmOut led(PTB18); //initializes the pwm output that connects to the on board LED DigitalIn INT(PTD1); //pin PTD1 connects to the interrupt output pin of the MAX30102 @@ -98,8 +101,10 @@ PwmOut led(LED_RED); //initializes the pwm output that connects to the on board LED DigitalIn INT(P2_0); //pin P20 connects to the interrupt output pin of the MAX30102 #endif +*/ // the setup routine runs once when you press reset: +// the setup routine runs once when you press reset: int main() { uint32_t un_min, un_max, un_prev_data; //variables to calculate the on-board LED brightness that reflects the heartbeats int i; @@ -108,21 +113,21 @@ maxim_max30102_reset(); //resets the MAX30102 // initialize serial communication at 115200 bits per second: - pc.baud(115200); - pc.format(8,SerialBase::None,1); + //pc.baud(115200); + //pc.format(8,SerialBase::None,1); wait(1); //read and clear status register - maxim_max30102_read_reg(0,&uch_dummy); + //maxim_max30102_read_reg(0,&uch_dummy); //wait until the user presses a key - while(pc.readable()==0) - { - pc.printf("\x1B[2J"); //clear terminal program screen - pc.printf("Press any key to start conversion\n\r"); - wait(1); - } - uch_dummy=getchar(); + //while(pc.readable()==0) + //{ + //pc.printf("\x1B[2J"); //clear terminal program screen + // pc.printf("Press any key to start conversion\n\r"); + // wait(1); + //} + //uch_dummy=getchar(); maxim_max30102_init(); //initializes the MAX30102 @@ -136,7 +141,7 @@ //read the first 500 samples, and determine the signal range for(i=0;i<n_ir_buffer_length;i++) { - while(INT.read()==1); //wait until the interrupt pin asserts + //while(INT.read()==1); //wait until the interrupt pin asserts maxim_max30102_read_fifo((aun_red_buffer+i), (aun_ir_buffer+i)); //read from MAX30102 FIFO @@ -179,7 +184,7 @@ for(i=400;i<500;i++) { un_prev_data=aun_red_buffer[i-1]; - while(INT.read()==1); + //while(INT.read()==1); maxim_max30102_read_fifo((aun_red_buffer+i), (aun_ir_buffer+i)); if(aun_red_buffer[i]>un_prev_data) @@ -212,8 +217,10 @@ pc.printf("HRvalid=%i, ", ch_hr_valid); pc.printf("SpO2=%i, ", n_sp02); pc.printf("SPO2Valid=%i\n\r", ch_spo2_valid); + wait(1); } maxim_heart_rate_and_oxygen_saturation(aun_ir_buffer, n_ir_buffer_length, aun_red_buffer, &n_sp02, &ch_spo2_valid, &n_heart_rate, &ch_hr_valid); } } - \ No newline at end of file + + \ No newline at end of file