heart modes, send, receive

Dependencies:   Terminal TextLCD mbed-rtos mbed

Fork of Heartnew by CIS541

Files at this revision

API Documentation at this revision

Comitter:
sanjeet25
Date:
Wed Dec 02 02:09:34 2015 +0000
Parent:
4:a64a0fea5266
Child:
6:cc4fcc38b9f0
Commit message:
heartnewer

Changed in this revision

heart.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/heart.cpp	Wed Dec 02 01:11:08 2015 +0000
+++ b/heart.cpp	Wed Dec 02 02:09:34 2015 +0000
@@ -237,53 +237,42 @@
 void HeartKeyBoardModeSwitch(void const* args)
 {
     while(1) {
-       // if(pc.readable()) {
-
-            //key_input = pc.getc();
+       // Thread::wait(0x02);
+        if((key_input=='r'||key_input=='R')&&flag_key==1) {
+        mode=Random;
+        pc.printf("Random");
+            HeartSend("s");
+            flag_key=0;
+        } else if((key_input=='m'||key_input=='M')&&flag_key) {
+        mode=Manual;
+        pc.printf("Manual");
+            flag_key=0;
+        } else if(mode==Manual&&(key_input=='v'||key_input=='V')&&flag_key==1) {
+        mode=Manual;
+        VSignalsend();
+            pc.printf("Ventricular");
+            flag_key=0;
+        } else if(mode==Manual&&flag_key==1&&(key_input=='a'||key_input=='A')) {
+        mode=Manual;
+        ASignalsend();
+            pc.printf("Atrial");
+             flag_key=0;
+        } else if((key_input=='o'||key_input=='O')&&flag_key==1) {
+        int a = 10 + rand() % 80;
+            mode=Observer;
+            pc.printf("Observer and %u",a);
+            heartInterval =a;
+            HeartSend("s");
+            flag_key=0;
 
-            if(key_input=='r'||key_input=='R') {
-                mode=Random;
-                pc.printf("Random");
-                HeartSend("s");
-                flag_key=0;
-            } else if(key_input=='t'||key_input=='T') {
-                mode=Test;
-                pc.printf("Test");
-                flag_key=0;
-            } else if(key_input=='m'||key_input=='M') {
-                mode=Manual;
-                pc.printf("Manual");
-                flag_key=0;
-            } else if(mode==Manual&&(key_input=='v'||key_input=='V')) {
-                mode=Manual;
-                VSignalsend();
-                pc.printf("Ventricular");
-                flag_key=0;
-            } else if(mode==Manual&&(key_input=='a'||key_input=='A')) {
-                mode=Manual;
-                ASignalsend();
-                pc.printf("Atrial");
-                flag_key=0;
-            } else if(key_input=='o'||key_input=='O') {
-                int a = 10 + rand() % 80;
-                mode=Observer;
-                pc.printf("Observer and %u",a);
-                heartInterval =a;
-                HeartSend("s");
-                flag_key=0;
-
-            } else if(key_input=='t'||key_input=='A') {
-                mode=Manual;
-                (*testmode).signal_set(0x03);
-                pc.printf("Atrial");
-                flag_key=0;
-            }
-            //else {
-//                pc.printf("Wrong key, sorry");
-//                fla
-//            }
+        } else if(flag_key==1&&(key_input=='t'||key_input=='T')) {
+        mode=Test;
+        (*testmode).signal_set(0x03);
+            pc.printf("Test");
+             flag_key=0;
         }
     }
+}
 
 
 void display(void const* args)
@@ -329,8 +318,8 @@
     test = true;
     switch(test) {
         case 1:
-        flag=0;
-            Thread::signal_wait(0x04); 
+            flag=0;
+            Thread::signal_wait(0x04);
             flag=1;
             t = 0;
             Thread::wait(vrp);
@@ -346,17 +335,17 @@
                 test=2;
             }
             break;
-            
-            case 2:
+
+        case 2:
             flag=0;
             Thread::signal_wait(0x04); //Send A after PVARP
             flag=1;
             t = 0;
             Thread::wait(pvarp);
             ASignalsend();
-            
+
             Thread::wait(uri-pvarp-delta);
-            
+
             if(test_result) {
                 pc.printf("Test %u passed", &test_result);
                 test=3;
@@ -393,9 +382,9 @@
             t = 0;
             Thread::wait(pvarp);
             ASignalsend();
-            
+
             Thread::wait(uri-pvarp-delta);
-            
+
             if(test_result) {
                 pc.printf("Test %u passed", &test_result);
                 test=5;
@@ -404,12 +393,12 @@
                 test=5;
             }
             break;
-            case 5:
+        case 5:
             flag=0;
             Thread::signal_wait(0x04); //Heart is dead
             flag=1;
             t = 0;
-            
+
             Thread::wait(lri);
             Thread::wait(lri);
             test = false;
@@ -421,8 +410,8 @@
                 test=6;
             }
             break;
-            
-            case 6:
+
+        case 6:
             flag=0;
             Thread::signal_wait(0x04); //Heart beating very fast. ASig, VSig
             flag=1;
@@ -437,10 +426,10 @@
             } else {
                 pc.printf("Test %u failed", &test_result);
                 test=7;
-            }            
+            }
             break;
-            
-            case 7:
+
+        case 7:
             flag=0;
             Thread::signal_wait(0x04); //Wait for VPace to be received
             flag=1;
@@ -454,11 +443,11 @@
             } else {
                 pc.printf("Test %u failed", &test_result);
                 test=8;
-            }            
-        
-        break;
-            
-            case 8:
+            }
+
+            break;
+
+        case 8:
             flag=0;
             Thread::signal_wait(0x04); //Send an extra V to see if LRI starts then
             flag=1;
@@ -472,24 +461,16 @@
             } else {
                 pc.printf("Test %u failed", &test_result);
                 test=0;
-            }       
+            }
             break;
 
     }
 }
 
-void Rx_interrupt()
-{
-    if(pc.readable())
-    {
-        key_input=LPC_UART0->RBR;                  //read uart buffer data and clear the interrupt flag
-        flag_key=1;    //initiate the serial thread to change the state of the timer
-    }
-}
 
 
 int main()
-{
+{   
     pc.baud(9600);
     VPace.rise(&VPacereceived);
     APace.rise(&APacereceived);
@@ -502,6 +483,13 @@
     Thread tmode(Testmode);
     testmode = &tmode;
 
-    while(1) {
-    }
+    while(1){
+    if(pc.readable()) {
+        key_input=pc.getc();                  //read uart buffer data and clear the interrupt flag
+        //initiate the serial thread to change the state of the timer
+        pc.printf("setting");
+        //(*testmode).signal_set(0x02);
+        flag_key=1;
+         pc.printf("set");
+    }}
 }
\ No newline at end of file