Working
Dependencies: MAX30003 max32630fthr
Diff: main.cpp
- Revision:
- 21:193a10530741
- Parent:
- 20:2e999e6568c1
- Child:
- 22:07eec382c267
--- a/main.cpp Wed Jun 23 20:32:39 2021 +0000 +++ b/main.cpp Tue Jun 29 16:16:56 2021 +0000 @@ -31,6 +31,10 @@ DigitalOut S2(P3_3); DigitalOut S3(P3_2); +DigitalIn AB(P5_7); +DigitalIn AC(P6_0); + + void ecg_config(MAX30003 &ecgAFE); @@ -53,26 +57,11 @@ ecgFIFOIntFlag = 1; } -time_t asUnixTime(int year, int mon, int mday, int hour, int min, int sec) { - struct tm t; - t.tm_year = year - 1900; - t.tm_mon = mon - 1; // convert to 0 based month - t.tm_mday = mday; - t.tm_hour = hour; - t.tm_min = min; - t.tm_sec = sec; - t.tm_isdst = -1; // Is Daylight saving time on? 1 = yes, 0 = no, -1 = unknown - - return mktime(&t); // returns seconds elapsed since January 1, 1970 (begin of the Epoch) -} + int main(void) { int t=0; -// -// EN=0; -// EN=1; -// A0=0; -// A1=1; + S0=0; S1=0; @@ -95,14 +84,14 @@ uint16_t rtn_val; //time = 12:00:00 AM 12hr mode - ds3231_time_t time = {50,10,16,1,0}; //seconds, min, hours, am_pm, mode + ds3231_time_t time = {50,20,10,1,0}; //seconds, min, hours, am_pm, mode rtn_val = rtc.set_time(time); //see datasheet for calendar format - ds3231_calendar_t calendar = {4,23,6,21}; //day date month year + ds3231_calendar_t calendar = {3,29,6,21}; //day date month year rtn_val = rtc.set_calendar(calendar); @@ -143,7 +132,7 @@ uint32_t ecgFIFO, readECGSamples, idx, ETAG[32], status; int16_t ecgSample[32]; //bool timerflag = false; - int16_t ecgSample_1sec[200]; + int16_t ecgSample_1sec[250]; uint8_t ecg_1 = 0; uint8_t ecg_2 = 0; uint16_t onesec_counter = 0; @@ -277,9 +266,22 @@ S3=0; channel_num[0]= {0}; t=0;} - - - + + if (AB ==0) //5_7 = P17 + {t=50; + S0=1; + S1=0; + S2=0; + S3=0; + channel_num[0]= {1};} + + if (AC==0) // 6_0 = P18 + {t=60; + S0=0; + S1=1; + S2=0; + S3=0; + channel_num[0]= {2};} } // Read back ECG samples from the FIFO @@ -360,6 +362,7 @@ // General config register setting MAX30003::GeneralConfiguration_u CNFG_GEN_r; CNFG_GEN_r.bits.en_ecg = 1; // Enable ECG channel + CNFG_GEN_r.bits.fmstr = 1; // set frequency to 32000kHz CNFG_GEN_r.bits.rbiasn = 1; // Enable resistive bias on negative input CNFG_GEN_r.bits.rbiasp = 1; // Enable resistive bias on positive input CNFG_GEN_r.bits.en_rbias = 1; // Enable resistive bias @@ -374,7 +377,7 @@ CNFG_ECG_r.bits.dlpf = 1; // Digital LPF cutoff = 40Hz CNFG_ECG_r.bits.dhpf = 1; // Digital HPF cutoff = 0.5Hz CNFG_ECG_r.bits.gain = 3; // ECG gain = 160V/V - CNFG_ECG_r.bits.rate = 2; // Sample rate = 128 sps + CNFG_ECG_r.bits.rate = 2; // Sample rate = 125 sps ecgAFE.writeRegister( MAX30003::CNFG_ECG , CNFG_ECG_r.all);