Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: TextLCD mbed-rtos mbed
Fork of PacemakerController by
PMTest.cpp
00001 #include "mbed.h" 00002 #include "LPC17xx.h" 00003 #include "TextLCD.h" 00004 #include "rtos.h" 00005 #include "Thread.h" 00006 00007 DigitalOut vsense(p23); 00008 DigitalOut asense(p24); 00009 DigitalIn apace(p22); 00010 DigitalIn vpace(p21); 00011 00012 Serial serial_in(USBTX, USBRX); 00013 00014 00015 int test_time_count; 00016 int curr_test; 00017 int minwaitV; 00018 int minwaitA; 00019 00020 int needs_num_input = 0; 00021 00022 enum mode{RANDOM,MANUAL,TEST}; 00023 mode test_curr_mode = RANDOM; 00024 Timer t; 00025 00026 00027 00028 00029 00030 void random_heart(){ 00031 t.reset(); 00032 t.start(); 00033 00034 while(test_curr_mode == RANDOM){ 00035 int r = rand(); 00036 00037 if(r%2 == 0){ 00038 if(t.read() > minwaitA){ 00039 asense = 1; 00040 Thread::wait(10); 00041 asense = 0; 00042 } 00043 }else{ 00044 if(t.read() > minwaitV){ 00045 vsense = 1; 00046 Thread::wait(10); 00047 vsense = 0; 00048 } 00049 } 00050 00051 00052 t.reset(); 00053 00054 } 00055 } 00056 00057 00058 void kbd_intrp(){ 00059 char a = serial_in.getc(); 00060 00061 if(needs_num_input){ 00062 // DO O handling 00063 needs_num_input = 0; 00064 return; 00065 } 00066 00067 if(a == 'R'){ 00068 test_curr_mode = RANDOM; 00069 }else if(a == 'T'){ 00070 test_curr_mode = TEST; 00071 }else if(a == 'M'){ 00072 test_curr_mode = MANUAL; 00073 } 00074 00075 if(a == 'A' && test_curr_mode == MANUAL){ 00076 asense = 1; 00077 Thread::wait(10); 00078 asense = 0; 00079 } 00080 00081 if(a == 'V' && test_curr_mode == MANUAL){ 00082 vsense = 1; 00083 Thread::wait(10); 00084 vsense = 0; 00085 } 00086 00087 00088 00089 00090 } 00091 00092 00093 00094 // interrupt function 00095 void interrupt_and_run_test(){ 00096 // zero timer, set for 1ms interrupt 00097 00098 // wait for atrial pulse 00099 00100 // check if timer was within event 00101 00102 00103 // send vsense 00104 00105 00106 // send asense 00107 00108 // check if timer was in event 00109 00110 // wait for vpace 00111 00112 // wait for atrial pulse 00113 00114 // check if timer was within event 00115 }
Generated on Tue Jul 26 2022 07:29:25 by
1.7.2
