takuya okada
/
test
疑似的な脈波・呼吸・いびきを出力するプログラムです。
Diff: main.cpp
- Revision:
- 1:97c5a956a371
- Parent:
- 0:63339e4deacf
- Child:
- 2:1e0021f8eb7d
--- a/main.cpp Tue Nov 08 02:43:21 2016 +0000 +++ b/main.cpp Mon Dec 12 07:48:43 2016 +0000 @@ -1,266 +1,405 @@ #include "mbed.h" -#include "math.h" + +//Serial Port Setting +Serial pc(p13, p14); // シリアルポートのインスタンス + +//PWM Port Setting +PwmOut signal_1(p21); +PwmOut signal_2(p22); +PwmOut signal_3(p23); + +//Ticker +Ticker timer; + +//Digital Out +DigitalOut ledch1(LED1); +DigitalOut test(p20); + +//Cos Wave +float coswave[256]; + +//status flug +int status1 =0; //suatus1 : 0=波形出力停止中, 1=波形出力中 + +//User set Wave Paramater 初期値 +int sample_dt = 100; //microsec 10kHz +float hb_carr_freq = 8.7; //Hz +float hb_mod_freq = 1; //Hz +float hb_carr_level = 0.083; //min=0 max=0.5 0.5以上ではMOD 50%以上で振幅が飽和する +float hb_mod_ratio = 63; //0-100 % +float resp_freq = 0.3; //Hz +float resp_level = 0.56; //min=0 max=1 +float snore_freq = 200; //Hz +float snore_level = 1; //min=0 max=1 +int snore_oncycle = 10000; //On Time = snore_oncycle * sample_dt +int snore_allcycle = 30000; //ALL Time = snore_allcycle * sample_dt , snore_oncycle < snore_allcycle; +int snore_onoff = 0; + +//Set wave paramater +//HB_carr +float hb_carr_period = 1000000*1/hb_carr_freq; //microSec +float hb_carr_n = 1; +float hb_carr_n_sample = 0; //The maximum number of sampling points in the signal +float hb_carr_tend = 0; //The remainder of sampling points in the signal +float hb_carr_tstart = 0; //start offset of sampling time +float hb_carr_t_samplepoint = 0; // +float hb_carr_table_dt = hb_carr_period/255; +float hb_carr_n_samplepoint = 0; +float hb_carr_rem_samplepoint=0; +float hb_carr_v_samplepoint = 0; + +//HB_mod +float hb_modp_period = 1000000*1/(hb_carr_freq + hb_mod_freq); +float hb_modp_n = 1; +float hb_modp_n_sample = 0; //The maximum number of sampling points in the signal +float hb_modp_tend = 0; //The remainder of sampling points in the signal +float hb_modp_tstart = 0; //start offset of sampling time +float hb_modp_t_samplepoint = 0; // +float hb_modp_table_dt = hb_modp_period/255; +float hb_modp_n_samplepoint = 0; +float hb_modp_rem_samplepoint= 0; +float hb_modp_v_samplepoint = 0; + +float hb_modm_period = 1000000*1/(hb_carr_freq - hb_mod_freq); +float hb_modm_n = 1; +float hb_modm_n_sample = 0; //The maximum number of sampling points in the signal +float hb_modm_tend = 0; //The remainder of sampling points in the signal +float hb_modm_tstart = 0; //start offset of sampling time +float hb_modm_t_samplepoint = 0; // +float hb_modm_table_dt = hb_modm_period/255; +float hb_modm_n_samplepoint = 0; +float hb_modm_rem_samplepoint= 0; +float hb_modm_v_samplepoint = 0; + +float hb_mod_ra = hb_mod_ratio / 100; +float hb_signal = 0; -AnalogOut signal(p18); +//RESP +float resp_period = 1000000*1/resp_freq; //microSec +float resp_n = 1; +float resp_n_sample = 0; //The maximum number of sampling points in the signal +float resp_tend = 0; //The remainder of sampling points in the signal +float resp_tstart = 0; //start offset of sampling time +float resp_t_samplepoint = 0; +float resp_table_dt = resp_period/255; +float resp_n_samplepoint = 0; +float resp_rem_samplepoint = 0; +float resp_v_samplepoint = 0; +float resp_signal = 0; + +//SNORE Paramater +float snore_period = 1000000*1/snore_freq; //microSec +float snore_n = 0; //2016/12/12 1->0 +float snore_n_sample = 0; //The maximum number of sampling points in the signal +float snore_tend = 0; //The remainder of sampling points in the signal +float snore_tstart = 0; //start offset of sampling time +float snore_t_samplepoint = 0; // +float snore_table_dt = snore_period/256; //2016/12/12 255->256 +float snore_n_samplepoint = 0; +float snore_rem_samplepoint = 0; +float snore_v_samplepoint = 0; +int snore_cycle = 0; +float snore_signal = 0; + +int pwidth_1 = 0; +int pwidth_2 = 0; +int pwidth_3 = 0; + +//Signal Culcurate +void signal_culc(){ + +//HB section +//HB_carr + hb_carr_n_sample = (hb_carr_period - hb_carr_tstart) / sample_dt; + hb_carr_tend = fmod((hb_carr_period - hb_carr_tstart) , sample_dt); + hb_carr_t_samplepoint = hb_carr_tstart + sample_dt * hb_carr_n; //time of sampling point + hb_carr_n_samplepoint = hb_carr_t_samplepoint / hb_carr_table_dt; + hb_carr_rem_samplepoint = fmod(hb_carr_t_samplepoint , hb_carr_table_dt); + hb_carr_v_samplepoint = (hb_carr_rem_samplepoint/hb_carr_table_dt)*(coswave[(int)hb_carr_n_samplepoint+1]-coswave[(int)hb_carr_n_samplepoint])+coswave[(int)hb_carr_n_samplepoint]; + if(hb_carr_n == (int)hb_carr_n_sample) { + hb_carr_n =1; + hb_carr_tstart = sample_dt - hb_carr_tend; + } + else { + hb_carr_n++; + } +//HB_mod +//Acosωct+(Ama/2)cos(ωc+ωm)t+(Ama/2)cos(ωc-ωm)t Acosωct = fcarr(t),ma = modulation ratio, + hb_modp_n_sample = (hb_modp_period - hb_modp_tstart) / sample_dt; + hb_modp_tend = fmod((hb_modp_period - hb_modp_tstart) , sample_dt); + hb_modp_t_samplepoint = hb_modp_tstart + sample_dt * hb_modp_n; //time of sampling point + hb_modp_n_samplepoint = hb_modp_t_samplepoint / hb_modp_table_dt; + hb_modp_rem_samplepoint = fmod(hb_modp_t_samplepoint , hb_modp_table_dt); + hb_modp_v_samplepoint = hb_mod_ra*((hb_modp_rem_samplepoint/hb_modp_table_dt)*(coswave[(int)hb_modp_n_samplepoint+1]-coswave[(int)hb_modp_n_samplepoint])+coswave[(int)hb_modp_n_samplepoint]); + if(hb_modp_n == (int)hb_modp_n_sample) { + hb_modp_n =1; + hb_modp_tstart = sample_dt - hb_modp_tend; + } + else { + hb_modp_n++; + } + + hb_modm_n_sample = (hb_modm_period - hb_modm_tstart) / sample_dt; + hb_modm_tend = fmod((hb_modm_period - hb_modm_tstart) , sample_dt); + hb_modm_t_samplepoint = hb_modm_tstart + sample_dt * hb_modm_n; //time of sampling point + hb_modm_n_samplepoint = hb_modm_t_samplepoint / hb_modm_table_dt; + hb_modm_rem_samplepoint = fmod(hb_modm_t_samplepoint , hb_modm_table_dt); + hb_modm_v_samplepoint = hb_mod_ra*((hb_modm_rem_samplepoint/hb_modm_table_dt)*(coswave[(int)hb_modm_n_samplepoint+1]-coswave[(int)hb_modm_n_samplepoint])+coswave[(int)hb_modm_n_samplepoint]); + if(hb_modm_n == (int)hb_modm_n_sample) { + hb_modm_n =1; + hb_modm_tstart = sample_dt - hb_modm_tend; + } + else { + hb_modm_n++; + } + +//HB_AM MOD + hb_signal = hb_carr_level*(hb_carr_v_samplepoint + (0.5*hb_modp_v_samplepoint)+(0.5*hb_modm_v_samplepoint))+0.5;//0-1 -> 0V-3.3V -float sample_freq; -float hb_carr_freq; -float hb_mod_freq; -float hb_carr_level; -float hb_mod_ratio; -float resp_freq; -float resp_level; -float snore_freq; -float snore_level; -int snore_oncycle; -int snore_allcycle; //snore_oncycle < snore_cycle; +//RESP section + resp_n_sample = (resp_period - resp_tstart) / sample_dt; + resp_tend = fmod((resp_period - resp_tstart) , sample_dt); + resp_t_samplepoint = resp_tstart + sample_dt * resp_n; //time of sampling point + resp_n_samplepoint = resp_t_samplepoint / resp_table_dt; + resp_rem_samplepoint = fmod(resp_t_samplepoint , resp_table_dt); + resp_v_samplepoint = resp_level*((resp_rem_samplepoint/resp_table_dt)*(coswave[(int)resp_n_samplepoint+1]-coswave[(int)resp_n_samplepoint])+coswave[(int)resp_n_samplepoint]); + resp_signal = resp_v_samplepoint+0.5; //0-1 -> 0V-3.3V + if(resp_n == (int)resp_n_sample) { + resp_n =1; + resp_tstart = sample_dt - resp_tend; + } + else { + resp_n++; + } + +//SNORE section + snore_n_sample = (snore_period - snore_tstart) / sample_dt; // + snore_tend = fmod((snore_period - snore_tstart) , sample_dt); + if(snore_tend == 0){ + snore_n_sample = snore_n_sample-1; + } + else { + } + snore_t_samplepoint = snore_tstart + sample_dt * snore_n; //time of sampling point + snore_n_samplepoint = snore_t_samplepoint / snore_table_dt; + snore_rem_samplepoint = fmod(snore_t_samplepoint , snore_table_dt); + snore_v_samplepoint = snore_level*(coswave[(int)snore_n_samplepoint]-(snore_rem_samplepoint/snore_table_dt)*(coswave[(int)snore_n_samplepoint]-coswave[(int)snore_n_samplepoint+1])); + if(snore_n == (int)snore_n_sample) { + snore_n =0; //2016/12/12 1->0 + snore_tstart = sample_dt - snore_tend; + } + else { + snore_n++; + } + if(snore_onoff==0){ + } + else if(snore_onoff==1){ + if (snore_cycle <= snore_oncycle) { + snore_cycle++; + } + else if (snore_cycle>snore_oncycle && snore_cycle <= snore_allcycle){ + snore_v_samplepoint = 0; + snore_cycle++; + } + else { + snore_cycle = 0; + } + } + snore_signal = snore_v_samplepoint+0.5; //0-1 -> 0V-3.3V + +//PWM Output Pulse width + pwidth_1 = hb_signal * sample_dt; + pwidth_2 = resp_signal * sample_dt; + pwidth_3 = snore_signal * sample_dt; + + signal_1.pulsewidth_us(pwidth_1); + signal_2.pulsewidth_us(pwidth_2); + signal_3.pulsewidth_us(pwidth_3); +} + +//チッカー割り込みハンドラ +void attime(){ + if(status1==1){ + ledch1=0; + signal_culc(); + } + else{ + ledch1=!ledch1; + } + } + +//Serial 受信割り込みハンドラ +void isrRx() { + + /* UART受信コマンド + start: 波形出力スタート + stop: 波形出力ストップ + St: 割り込み周期[μsec] + carrf: 脈波AM変調波搬送波周波数[Hz] + modf: 脈波AM変調波変調周波数[Hz] + carrl: 脈波振幅 + modr: 脈波変調波変調率[%] + respf: 呼吸周波数[Hz] + respl: 呼吸振幅 + snorf: 体動・イビキ周波数[Hz] + snorl: 体動・イビキ振幅 + snon: 体動・イビキONサイクル + snall: 体動・イビキALLサイクル + sncn: 体動・イビキ断続制御 + */ + + char scan[10]; + float para; -float coswave[257]; + pc.scanf("%s",scan); // 文字列受信バッファより取り出し +// pc.printf("read = %s\n",scan); + + if(strcmp(scan,"start")==0){ + pc.printf("go\n"); + status1=1; //波形出力状態へ遷移 + } + else if(strcmp(scan,"stop")==0){ + pc.printf("end\n"); + status1=0; //波形出力停止へ遷移 + } + else if(strcmp(scan,"St")==0){ + pc.scanf("%f",¶); + sample_dt = para; + pc.printf("dt = %f\n",sample_dt); + } + else if(strcmp(scan,"carrf")==0){ + pc.scanf("%f",¶); + hb_carr_freq = para; + hb_carr_period = 1000000*1/hb_carr_freq; //microSec + hb_carr_n = 1; + hb_carr_n_sample = 0; //The maximum number of sampling points in the signal + hb_carr_tend = 0; //The remainder of sampling points in the signal + hb_carr_tstart = 0; //start offset of sampling time + hb_carr_t_samplepoint = 0; // + hb_carr_table_dt = hb_carr_period/255; + hb_carr_n_samplepoint = 0; + hb_carr_rem_samplepoint=0; + hb_carr_v_samplepoint = 0; + pc.printf("carrf = %f\n",hb_carr_table_dt); + } + else if(strcmp(scan,"modf")==0){ + pc.scanf("%f",¶); + hb_mod_freq = para; + hb_modp_n = 1; + hb_modp_n_sample = 0; //The maximum number of sampling points in the signal + hb_modp_tend = 0; //The remainder of sampling points in the signal + hb_modp_tstart = 0; //start offset of sampling time + hb_modp_t_samplepoint = 0; // + hb_modp_table_dt = hb_modp_period/255; + hb_modp_n_samplepoint = 0; + hb_modp_rem_samplepoint= 0; + hb_modp_v_samplepoint = 0; + hb_modm_period = 1000000*1/(hb_carr_freq - hb_mod_freq); + hb_modm_n = 1; + hb_modm_n_sample = 0; //The maximum number of sampling points in the signal + hb_modm_tend = 0; //The remainder of sampling points in the signal + hb_modm_tstart = 0; //start offset of sampling time + hb_modm_t_samplepoint = 0; // + hb_modm_table_dt = hb_modm_period/255; + hb_modm_n_samplepoint = 0; + hb_modm_rem_samplepoint= 0; + hb_modm_v_samplepoint = 0; + pc.printf("modf = %f\n",hb_modm_table_dt); + } + else if(strcmp(scan,"carrl")==0){ + pc.scanf("%f",¶); + hb_carr_level = para; + pc.printf("carrl = %f\n",hb_carr_level); + } + else if(strcmp(scan,"modr")==0){ + pc.scanf("%f",¶); + hb_mod_ratio = para; + hb_mod_ra = hb_mod_ratio *0.01; + pc.printf("modr = %f\n",hb_mod_ra); + } + else if(strcmp(scan,"respf")==0){ + pc.scanf("%f",¶); + resp_freq = para; + resp_period = 1000000*1/resp_freq; //microSec + resp_n = 1; + resp_n_sample = 0; //The maximum number of sampling points in the signal + resp_tend = 0; //The remainder of sampling points in the signal + resp_tstart = 0; //start offset of sampling time + resp_t_samplepoint = 0; + resp_table_dt = resp_period/255; + resp_n_samplepoint = 0; + resp_rem_samplepoint = 0; + resp_v_samplepoint = 0; + pc.printf("respf = %f\n",resp_table_dt); + } + else if(strcmp(scan,"respl")==0){ + pc.scanf("%f",¶); + resp_level = para; + pc.printf("respl = %f\n",resp_level); + } + else if(strcmp(scan,"snorf")==0){ + pc.scanf("%f",¶); + snore_freq = para; + snore_period = 1000000*1/snore_freq; //microSec + snore_n = 0; //2016/12/12 1->0 + snore_n_sample = 0; //The maximum number of sampling points in the signal + snore_tend = 0; //The remainder of sampling points in the signal + snore_tstart = 0; //start offset of sampling time + snore_t_samplepoint = 0; // + snore_table_dt = snore_period/256; //2016/12/12 255->256 + snore_n_samplepoint = 0; + snore_rem_samplepoint = 0; + snore_v_samplepoint = 0; + snore_cycle = 0; + pc.printf("snorf = %f\n",snore_table_dt); + } + else if(strcmp(scan,"snorl")==0){ + pc.scanf("%f",¶); + snore_level = para; + pc.printf("snorl = %f\n",snore_level); + } + else if(strcmp(scan,"snon")==0){ + pc.scanf("%f",¶); + snore_oncycle = (int)para; + pc.printf("snon = %d\n",snore_oncycle); + } + else if(strcmp(scan,"snall")==0){ + pc.scanf("%f",¶); + snore_allcycle = (int)para; + pc.printf("snall = %d\n",snore_allcycle); + } + else if(strcmp(scan,"sncn")==0){ + pc.scanf("%f",¶); + snore_onoff = (int)para; + pc.printf("sncn = %d\n",snore_onoff); + } + else { + pc.printf("Command Error\n"); + } +} int main() { - - -sample_freq = 10000; -hb_carr_freq = 10; -hb_mod_freq = 2; -hb_carr_level = 0.005; -hb_mod_ratio = 100; -resp_freq = 0.3; -resp_level = 0.01; -snore_freq = 150; -snore_level = 0.003; -snore_oncycle = 10000; -snore_allcycle = 30000; - - -// coswave +//Make Cos wave int i; - - for(i=0;i<=256;i++){ - coswave[i]=0.5*(cos(2.0*3.1415*i/256)); + for(i=0;i<=255;i++){ //256->255 + coswave[i]=0.5*(cos(2.0*3.1415*i/256)); //256->256 } i = 0; - -// sampling - float sample_dt; - sample_dt = 1/sample_freq; - -// hb_carr - float hb_carr_period; - hb_carr_period = 1/hb_carr_freq; - - float hb_carr_n; - hb_carr_n = 1; - - float hb_carr_n_sample; //The maximum number of sampling points in the signal - float hb_carr_tend = 0; //The remainder of sampling points in the signal - float hb_carr_tstart = 0; //start offset of sampling time - float hb_carr_t_samplepoint; // - float hb_carr_table_dt; - hb_carr_table_dt = hb_carr_period/256; - - float hb_carr_n_samplepoint; - float hb_carr_rem_samplepoint; - float hb_carr_v_samplepoint; - -// hb_mod - float hb_mod_period; - hb_mod_period = 1/hb_mod_freq; - - float hb_mod_n; - hb_mod_n = 1; - - float hb_mod_n_sample; //The maximum number of sampling points in the signal - float hb_mod_tend = 0; //The remainder of sampling points in the signal - float hb_mod_tstart = 0; //start offset of sampling time - float hb_mod_t_samplepoint; // - - float hb_mod_table_dt; - hb_mod_table_dt = hb_mod_period/256; - - float hb_mod_n_samplepoint; - float hb_mod_rem_samplepoint; - float hb_mod_v_samplepoint; - - float hb_mod_ra; - hb_mod_ra = hb_mod_ratio / 100; - - float hb_signal; - -// resp - float resp_period; - resp_period = 1/resp_freq; - - float resp_n; - resp_n = 1; - - float resp_n_sample; //The maximum number of sampling points in the signal - float resp_tend = 0; //The remainder of sampling points in the signal - float resp_tstart = 0; //start offset of sampling time - float resp_t_samplepoint; // - - float resp_table_dt; - resp_table_dt = resp_period/256; - - float resp_n_samplepoint; - float resp_rem_samplepoint; - float resp_v_samplepoint; - -// snore - float snore_period; - snore_period = 1/snore_freq; - - float snore_n; - snore_n = 1; - - float snore_n_sample; //The maximum number of sampling points in the signal - float snore_tend = 0; //The remainder of sampling points in the signal - float snore_tstart = 0; //start offset of sampling time - float snore_t_samplepoint; // - - float snore_table_dt; - snore_table_dt = snore_period/256; - - float snore_n_samplepoint; - float snore_rem_samplepoint; - float snore_v_samplepoint; - - int snore_cycle; - snore_cycle = 0; - -// etc. - - float signalout; - - - while(1){ - - //hb section - //hb_carr + signal_1.period_us(sample_dt); //Pulse_cycle = 100usec = 10kHz + signal_2.period_us(sample_dt); + signal_2.period_us(sample_dt); - hb_carr_n_sample = (hb_carr_period - hb_carr_tstart) / sample_dt; - hb_carr_tend = fmod((hb_carr_period - hb_carr_tstart) , sample_dt); - - hb_carr_t_samplepoint = hb_carr_tstart + sample_dt * hb_carr_n; //time of sampling point - - hb_carr_n_samplepoint = hb_carr_t_samplepoint / hb_carr_table_dt; - hb_carr_rem_samplepoint = fmod(hb_carr_t_samplepoint , hb_carr_table_dt); - - hb_carr_v_samplepoint = hb_carr_level*((hb_carr_rem_samplepoint/hb_carr_table_dt)*(coswave[(int)hb_carr_n_samplepoint+1]-coswave[(int)hb_carr_n_samplepoint])+coswave[(int)hb_carr_n_samplepoint]); - -// signal = hb_carr_v_samplepoint+0.5; //0-1 -> 0V-3.3V -// printf("V= %f \n",hb_carr_v_samplepoint); - - if(hb_carr_n == (int)hb_carr_n_sample) { - hb_carr_n =1; - hb_carr_tstart = sample_dt - hb_carr_tend; - } - - else { - hb_carr_n++; - } - //hb_mod + int j; + j = sample_dt; + timer.attach_us(&attime,j); //⇒UART割り込み”START”に移動 - hb_mod_n_sample = (hb_mod_period - hb_mod_tstart) / sample_dt; - hb_mod_tend = fmod((hb_mod_period - hb_mod_tstart) , sample_dt); - - hb_mod_t_samplepoint = hb_mod_tstart + sample_dt * hb_mod_n; //time of sampling point - - hb_mod_n_samplepoint = hb_mod_t_samplepoint / hb_mod_table_dt; - hb_mod_rem_samplepoint = fmod(hb_mod_t_samplepoint , hb_mod_table_dt); - - hb_mod_v_samplepoint = hb_mod_ra*((hb_mod_rem_samplepoint/hb_mod_table_dt)*(coswave[(int)hb_mod_n_samplepoint+1]-coswave[(int)hb_mod_n_samplepoint])+coswave[(int)hb_mod_n_samplepoint]); - -// signal = hb_mod_v_samplepoint+0.5; //0-1 -> 0V-3.3V -// printf("V= %f \n",hb_mod_v_samplepoint); - - if(hb_mod_n == (int)hb_mod_n_sample) { - hb_mod_n =1; - hb_mod_tstart = sample_dt - hb_mod_tend; - } - - else { - hb_mod_n++; - } - - //hb_AM MOD - hb_signal = hb_carr_v_samplepoint + hb_mod_v_samplepoint*hb_carr_v_samplepoint; - -// signal = hb_signal+0.5; - - //resp section - - resp_n_sample = (resp_period - resp_tstart) / sample_dt; - resp_tend = fmod((resp_period - resp_tstart) , sample_dt); - - resp_t_samplepoint = resp_tstart + sample_dt * resp_n; //time of sampling point - - resp_n_samplepoint = resp_t_samplepoint / resp_table_dt; - resp_rem_samplepoint = fmod(resp_t_samplepoint , resp_table_dt); - - resp_v_samplepoint = resp_level*((resp_rem_samplepoint/resp_table_dt)*(coswave[(int)resp_n_samplepoint+1]-coswave[(int)resp_n_samplepoint])+coswave[(int)resp_n_samplepoint]); - -// signal = resp_v_samplepoint+0.5; //0-1 -> 0V-3.3V -// printf("V= %f \n",resp_v_samplepoint); - - if(resp_n == (int)resp_n_sample) { - resp_n =1; - resp_tstart = sample_dt - resp_tend; - } - - else { - resp_n++; - - } - - //snore section - - snore_n_sample = (snore_period - snore_tstart) / sample_dt; - snore_tend = fmod((snore_period - snore_tstart) , sample_dt); - - snore_t_samplepoint = snore_tstart + sample_dt * snore_n; //time of sampling point - - snore_n_samplepoint = snore_t_samplepoint / snore_table_dt; - snore_rem_samplepoint = fmod(snore_t_samplepoint , snore_table_dt); - - snore_v_samplepoint = snore_level*((snore_rem_samplepoint/snore_table_dt)*(coswave[(int)snore_n_samplepoint+1]-coswave[(int)snore_n_samplepoint])+coswave[(int)snore_n_samplepoint]); - -// signal = snore_v_samplepoint+0.5; //0-1 -> 0V-3.3V -// printf("V= %f \n",snore_v_samplepoint); - - if(snore_n == (int)snore_n_sample) { - snore_n =1; - snore_tstart = sample_dt - snore_tend; - } - - else { - snore_n++; - - } - - if (snore_cycle <= snore_oncycle) { - snore_cycle++; - } - else if (snore_cycle>snore_oncycle && snore_cycle <= snore_allcycle){ - snore_v_samplepoint = 0; - snore_cycle++; - } - else { - snore_cycle = 0; - } - - - signalout = (hb_signal + resp_v_samplepoint + snore_v_samplepoint); - signal = signalout +0.5; //0-1 -> 0V-3.3V - - wait(sample_dt); - -char msg[10]; -printf(msg, "%d", SystemCoreClock ); + pc.attach(isrRx, Serial::RxIrq); // 割込みハンドラ登録 + NVIC_SetPriority(UART1_IRQn,1); + while(1) { - } + } }