udpated n,e,s modeswitch

Dependencies:   TextLCD mbed-rtos mbed

Fork of pacemaker_v5 by Pacemaker

Revision:
4:4572cbbb6c15
Parent:
3:39870b37d0c4
--- a/main.cpp	Wed Dec 03 23:33:38 2014 +0000
+++ b/main.cpp	Wed Dec 03 23:45:53 2014 +0000
@@ -226,25 +226,24 @@
 void listen_Vget(void const *args) {
     while (1) {
         if (VGet==1) {
-            status_mutex.lock();
+            
             if (!isVRP && waitingForV){
                 t_mutex.lock();
                 tv.start();
                 ta.reset();
                 ta.stop();
-                
+                t_mutex.unlock();
+                status_mutex.lock();
                 isVRP = 1;
                 isPVARP = 1;
                 waitingForV = 0;
-                
+                status_mutex.unlock();
                 VRP_timer->start(VRP);
                 PVARP_timer->start(PVARP);
                 beats++;
                 
                 flashLED(3);
-                t_mutex.unlock();
             }
-            status_mutex.unlock();
             while(VGet == 1);
         }
     }
@@ -253,19 +252,17 @@
 void listen_Aget(void const *args) {
     while (1) {
         if (AGet == 1) {
-            status_mutex.lock();
             if (!isPVARP && !waitingForV) {
                 t_mutex.lock();
                 ta.start();
                 tv.reset();
                 tv.stop();
-                
+                t_mutex.unlock();
+                status_mutex.lock();
                 waitingForV = 1;
-
-                t_mutex.unlock();
+                status_mutex.unlock();
                 flashLED(4);
             }
-            status_mutex.unlock();
             while(AGet == 1);
         }
     }