![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Part of the Pacemaker Project; this models the Pacemaker.
Dependencies: mbed TextLCD mbed-rtos
Diff: PacemakerController.cpp
- Revision:
- 17:c89cddf30925
- Parent:
- 14:a16b636c2bbc
- Parent:
- 16:ae9df4194011
- Child:
- 18:d4cd9d12345e
--- a/PacemakerController.cpp Mon Nov 30 21:01:11 2015 +0000 +++ b/PacemakerController.cpp Mon Nov 30 21:06:25 2015 +0000 @@ -15,7 +15,7 @@ int h_clock; int pm_clock; -int avi_clock; +Timer avi_clock; int LRI = 1000; int AVI = 150; @@ -36,15 +36,11 @@ int obs_int = 10; mode curr_mode = NORMAL; - - // alarms DigitalOut led_apace(LED1); DigitalOut led_vpace(LED2); DigitalOut Asense(LED3); DigitalOut Vsense(LED4); -DigitalOut apace(p22): -DigitalOut vpace(p21): // hardware interrupt handler, adapted from code in piazza post by Dagaen extern "C" void TIMER0_IRQHandler (void) @@ -168,30 +164,39 @@ while(1) { if (timer_count >= LRI-AVI) { - // PM_A! + + // PM_A! sets the LED high + led_apace = 1; + // avi_clk = 0 - //apace(); + avi_clk.reset(); + + apace(); } else if (timer_count < LRI - AVI) { + // avi_clk = 0 - // wait for Asense? + avi_clk.reset(); + + // wait for Asense? naaah } // At Atrial Event State - - //while (avi_clk < AVI); + while (avi_clk.read() < AVI); // Ventricular Event timer_count = 0; - // PM_V! + + // PM_V! sets the LED high + led_vpace = 1; + timer_count = 0; - // VPace! - - + vpace(); } } void apace() { + apace = 1; led_apace = 1; Thread::wait(10); @@ -200,22 +205,31 @@ } void vpace() { + vpace = 1; led_vpace = 1; Thread::wait(10); vpace = 0; + } int main() { - https://developer.mbed.org/users/chadnach1/code/PacemakerController/ + // https://developer.mbed.org/users/chadnach1/code/PacemakerController/ // connect the serial device (PC keybd) to the interrupt pc.attach(&keyboard_handler); + // Start LED's Off + led_apace = 0; + led_vpace = 0; + + // Start the avi_clock + avi_clk.start(); + Thread t3(pm_sense); Thread t4(pm_response); Thread t2(PM_ALARM); Thread t5(); -} +} \ No newline at end of file