CIS441 Controller
Dependencies: TextLCD mbed-rtos mbed
Fork of PacemakerController by
PMTest.cpp
- Committer:
- lucastai
- Date:
- 2015-11-30
- Revision:
- 22:365d51eb3783
- Parent:
- 8:5924b2048a27
File content as of revision 22:365d51eb3783:
#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 obs_int; Timer t; struct mode{RANDOM,MANUAL,TEST}; // state variables mode current_mode = RANDOM; int[][] testfunc; void random_heart(){ t.reset(); t.start(); while(curr_mode == NORMAL){ if(rand()% 2 == 1){ if(t.read() < minwaitA){ asense = 1; Thread::wait(10); asense = 0; } }else{ if(t.read() < minwaitV){ vsense = 1; Thread::wait(10); vsense = 0; } } } } void man_interrupt(){ char a = pc.getc(); if (keyboard_needs_numeric) { if (a >= '0' && a <= '9') { // update observation interval obs_int = (a - '0' + 1) * 5; } else { pc.printf("Expected numeric key\n"); } keyboard_needs_numeric = 0; }else if(a == 'N'){ curr_mode = NORMAL; }else if (a == 'M'){ curr_mode = MANUAL; }else if (a == 'T'){ curr_mode = TEST; }else if (a == 'O'){ keyboard_needs_number = 1; } if(curr_mode == MANUAL){ if(a == 'A'){ asense = 1; Thread::wait(10); asense = 0; }else if(a == "V"){ vsense = 1; Thread::wait(10); vsense = 0; } } keyboard_needs_number = 0; } // 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"); }