![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Part of the Pacemaker Project; this models the Pacemaker.
Dependencies: mbed TextLCD mbed-rtos
PMTest.cpp
- Committer:
- lucastai
- Date:
- 2015-12-02
- Revision:
- 26:64e2bc7d544a
- Parent:
- 25:18923916215b
- Child:
- 28:5c5552cd472b
File content as of revision 26:64e2bc7d544a:
#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); Serial pc(USBTX, USBRX); int timer_count; int curr_test; int minwaitV; int minwaitA; int needs_num_input = 0; enum mode{RANDOM,MANUAL,TEST}; mode curr_mode = RANDOM; Timer t; 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; }else if(a == 'T'){ curr_mode = TEST; }else if(a == 'M'){ curr_mode = MANUAL; } if(a == 'A' && curr_mode == MANUAL){ asense = 1; Thread::wait(10); asense = 0; } if(a == 'V' && curr_mode == MANUAL){ vsense = 1; Thread::wait(10); vsense = 0; } } // interrupt function void interrupt_and_run_test(){ // zero timer, set for 1ms interrupt // wait for atrial pulse // check if timer was within event // send vsense // send asense // check if timer was in event // wait for vpace // wait for atrial pulse // check if timer was within event }