CIS441 Controller
Dependencies: TextLCD mbed-rtos mbed
Fork of PacemakerController by
PMTest.cpp
- Committer:
- lucastai
- Date:
- 2015-11-30
- Revision:
- 23:08456978fb78
- Parent:
- 20:dc272bfaa276
- Child:
- 25:18923916215b
File content as of revision 23:08456978fb78:
#include "mbed.h" #include "LPC17xx.h" #include "TextLCD.h" #include "rtos.h" #include "Thread.h" DigitalOut vsense(p23); DigitalOut asense(p24); DigitalIn apace(p22); DigitalIn vpace(p21); int timer_count; int curr_test; int minwaitV; int minwaitA; int needs_num_input = 0; struct mode{RANDOM,MANUAL,TEST}; mode curr_mode = RANDOM; Timer t; int[][] testfunc; void random_heart(){ t.reset(); t.start(); while(curr_mode == RANDOM){ int r = rand(); if(r%2 == 0){ if(t.read() > minwaitA){ asense = 1; Thread::wait(10); asense = 0; } }else{ if(t.read() > minwaitV){ vsense = 1; Thread::wait(10); vsense = 0; } } t.reset(); } } void kbd_intrp(){ char a = pc.getc(); if(needs_num_input){ // DO O handling needs_num_input = 0; return; } if(a = 'R'){ curr_mode = RANDOM; } } // interrupt function void interrupt_and_run_test(){ // zero timer, set for 1ms interrupt timer0_init(100000) // wait for atrial pulse while(apace != 1}{} // check if timer was within event if(timer_count < testfunc[curr_test][0]){ printf("ATRIAL PULSE FOR TEST " + curr_test + " WAS WITHIN BOUNDS\n"); } // send vsense while(timer_count < testfunc[curr_test][1]){}; vpace = 1; // send asense while(timer_count < testfunc[curr_test][2]){}; apace = 1; // check if timer was in event // wait for vpace // wait for atrial pulse while(vpace != 1}{} // check if timer was within event if(timer_count < testfunc[curr_test][0]){ printf("VENT PULSE FOR TEST " + curr_test + " WAS WITHIN BOUNDS\n"); }