vr1.1

Dependencies:   FreescaleIAP mbed-rtos mbed

Fork of CDMS_RTOS_v1_1 by Team Fox

Files at this revision

API Documentation at this revision

Comitter:
cholletisaik777
Date:
Mon Jul 06 11:26:57 2015 +0000
Parent:
12:cb3ee1ac3638
Child:
14:cf9f12b6887d
Commit message:
FLAGS DONE FOR SCIENCE

Changed in this revision

Flags.h Show annotated file Show diff for this revision Revisions of this file
PL.cpp Show annotated file Show diff for this revision Revisions of this file
PL.h Show annotated file Show diff for this revision Revisions of this file
--- a/Flags.h	Mon Jul 06 10:31:29 2015 +0000
+++ b/Flags.h	Mon Jul 06 11:26:57 2015 +0000
@@ -38,6 +38,11 @@
 #define TIME_ELAPSED_LAST_SRP_INTERVAL_LOW        0x0000000000000010
 #define IS_PL_FRAME_SIZE_CORRECT                  0x0000000000000010
 #define IS_FIRST_TIME_SC_DATA                     0x0000000000000010 
+#define PL_STATE                                  0x0000000000000001
+#define IS_PL_SCHEDULE                            0x0000000000000002
+#define PL_PREV_STATE                             0x0000000000000004 
+#define IS_I2C_ACK                                0x0000000000000008 
+#define PL_STATUS                                 0x0000000000000010
 /*End*/
 
 /*TC_TM*/
--- a/PL.cpp	Mon Jul 06 10:31:29 2015 +0000
+++ b/PL.cpp	Mon Jul 06 11:26:57 2015 +0000
@@ -52,7 +52,7 @@
     {
         //FCTN_WR_SD(const uint8_t *, uint64_t)
         //FCTN_CDMS_WR_FLASH();
-          PL_SCIENCE_FLAG &=~(PL_FRAME_SIZE_CORRECT);
+          all_flags&=~(PL_FRAME_SIZE_CORRECT);
     }
     if(TIME_ELAPSED_LAST_SRP>4)
     {
@@ -74,13 +74,13 @@
     all_flags = all_flags|((all_flags&PL_STATE)<<2); //pl_prev_state = pl_state;
     if(all_flags&IS_PL_SCHEDULE == 1)  //is pl_schedule == 1
     {
-        (all_flags&PL_STATE) = pl_schedule_TC;
+        all_flags = (all_flags&(~PL_STATE))|pl_schedule_TC;
     } 
     else 
     {
         if((all_flags&PL_PREV_STATE) == PL_SCIENCE) 
         {
-            pl_state= PL_HIBERNATE;
+            all_flags = (all_flags&(~PL_STATUS))|PL_HIBERNATE;
         } 
         else
         {
@@ -116,35 +116,34 @@
             } 
             else 
             {
-                if(pl_prev_state!=PL_OFF) 
+                if(all_flags&PL_PREV_STATE!=PL_OFF) 
                 {
                     sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n");
                     sr.printf("Power OFF SPEED PMTs\r\n");
-                    if(I2C_acknowledgement==1) 
+                    if(all_flags&IS_I2C_ACK == 1) 
                     {
-                        pl_status=PL_STANDBY;
-                    } 
+                        all_flags = (all_flags&(~PL_STATUS))|PL_STANDBY;                   } 
                     else 
                     {
-                        pl_status=PL_ERR_I2C;
+                        all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C;
                     }
                     sr.printf("Disable SRP_INTERVAL_COUNTER\r\n");
-                    pl_main_flags&=~(PL_MAIN_STATUS);
+                    all_flags = all_flags&(~PL_MAIN_STATUS);
                 } 
                 else 
                 {
                     sr.printf("Power on SPPED DL\r\n");
                     sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n");
-                    if(I2C_acknowledgement==1) 
+                    if(all_flags&IS_I2C_ACK == 1) 
                     {
-                        pl_status=PL_STANDBY;
+                        all_flags = (all_flags&(~PL_STATUS))|PL_STANDBY;
                     } 
                     else 
                     {
-                        pl_status=PL_ERR_I2C;
+                        all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C;
                     }
                     sr.printf("Disable SRP_INTERVAL_COUNTER\r\n");
-                    pl_main_flags&=~(PL_MAIN_STATUS);
+                    all_flags = all_flags&(~PL_MAIN_STATUS);
                 }
             }
         }
@@ -152,195 +151,186 @@
         {
             if(power_level<1) 
             {
-                pl_main_flags|=PL_LOW_POWER;
+                all_flags = all_flags|PL_LOW_POWER;
                 if(power_level<0) 
                 {
-                    pl_main_flags|=PL_LOW_POWER;
-                    if(pl_prev_state!=PL_OFF) 
+                    if(all_flags&PL_PREV_STATE!=PL_OFF) 
                     {
                         sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n");
                     }
                     sr.printf("Power off SPEED\r\n");
-                    pl_status=PL_OFF;
+                    all_flags = (all_flags&(~PL_STATUS))|PL_OFF;
                     sr.printf("Disable SRP_INTERVAL_COUNTER\r\n");
-                    pl_main_flags&=~(PL_MAIN_STATUS);
+                    all_flags = all_flags&(~PL_MAIN_STATUS);
                 } 
                 else 
                 {
-                    if(pl_prev_state!=PL_OFF) 
+                    if(all_flags&PL_PREV_STATE!=PL_OFF) 
                     {
                         sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n");
                         sr.printf("Power OFF SPEED PMTs\r\n");
-                        if(I2C_acknowledgement==1) 
+                        if(all_flags&IS_I2C_ACK == 1) 
                         {
-                            pl_status=PL_STANDBY;
-                        } 
+                            all_flags = (all_flags&(~PL_STATUS))|PL_STANDBY;                   } 
                         else 
                         {
-                            pl_status=PL_ERR_I2C;
+                            all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C;
                         }
                         sr.printf("Disable SRP_INTERVAL_COUNTER\r\n");
-                        pl_main_flags&=~(PL_MAIN_STATUS);
+                        all_flags = all_flags&(~PL_MAIN_STATUS);
                     } 
                     else 
                     {
                         sr.printf("Power on SPPED DL\r\n");
                         sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n");
-                        if(I2C_acknowledgement==1) {
-                            pl_status=PL_STANDBY;
+                        if(all_flags&IS_I2C_ACK == 1) 
+                        {
+                            all_flags = (all_flags&(~PL_STATUS))|PL_STANDBY;
                         } 
                         else 
                         {
-                            pl_status=PL_ERR_I2C;
+                            all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C;
                         }
                         sr.printf("Disable SRP_INTERVAL_COUNTER\r\n");
-                        pl_main_flags&=~(PL_MAIN_STATUS);
+                        all_flags = all_flags&(~PL_MAIN_STATUS);
                     }
                 }
             }
-            if(power_level>1) 
+            else if(power_level>1) 
             {
-                if(pl_prev_state==PL_OFF) 
+                if(all_flags&PL_PREV_STATE==PL_OFF) 
                 {
                     sr.printf("Power on SPEED DL\r\n");
                 }
                 sr.printf("Power on Speed PMT with reduced Voltage\r\n");
                 sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n");
-                if(I2C_acknowledgement==1) 
+                if(all_flags&IS_I2C_ACK == 1) 
                 {
-                    pl_status=PL_HIBERNATE;
+                    all_flags = (all_flags&(~PL_STATUS))|PL_HIBERNATE;                   
                 } 
                 else 
                 {
-                    pl_status=PL_ERR_I2C;
+                    all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C;
                 }
                 sr.printf("Disable SRP_INTERVAL_COUNTER\r\n");
-                pl_main_flags&=~(PL_MAIN_STATUS);
+                all_flags = all_flags&(~PL_MAIN_STATUS);
             }
         }
-
         case PL_SCIENCE: 
         {
-
             if(power_level<2) 
             {
                 if(power_level<1) 
                 {
-                    pl_main_flags|=PL_LOW_POWER;
+                    all_flags = all_flags|PL_LOW_POWER;
                     if(power_level<0) 
                     {
-                        pl_main_flags|=PL_LOW_POWER;
-                        if(pl_prev_state!=PL_OFF) 
+                        if(all_flags&PL_PREV_STATE!=PL_OFF) 
                         {
                             sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n");
                         }
                         sr.printf("Power off SPEED\r\n");
-                        pl_status=PL_OFF;
+                        all_flags = (all_flags&(~PL_STATUS))|PL_OFF;
                         sr.printf("Disable SRP_INTERVAL_COUNTER\r\n");
-                        pl_main_flags&=~(PL_MAIN_STATUS);
+                        all_flags = all_flags&(~PL_MAIN_STATUS);
                     } 
                     else 
                     {
-                        if(pl_prev_state!=PL_OFF) 
+                        if(all_flags&PL_PREV_STATE!=PL_OFF) 
                         {
                             sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n");
                             sr.printf("Power OFF SPEED PMTs\r\n");
-                            if(I2C_acknowledgement==1) 
+                            if(all_flags&IS_I2C_ACK == 1) 
                             {
-                                pl_status=PL_STANDBY;
-                            } 
+                                all_flags = (all_flags&(~PL_STATUS))|PL_STANDBY;                   } 
                             else 
                             {
-                                pl_status=PL_ERR_I2C;
+                                all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C;
                             }
                             sr.printf("Disable SRP_INTERVAL_COUNTER\r\n");
-                            pl_main_flags&=~(PL_MAIN_STATUS);
+                            all_flags = all_flags&(~PL_MAIN_STATUS);
                         } 
                         else 
                         {
                             sr.printf("Power on SPPED DL\r\n");
                             sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n");
-                            if(I2C_acknowledgement==1) 
+                            if(all_flags&IS_I2C_ACK == 1) 
                             {
-                                pl_status=PL_STANDBY;
+                                all_flags = (all_flags&(~PL_STATUS))|PL_STANDBY;
                             } 
                             else 
                             {
-                                pl_status=PL_ERR_I2C;
+                                all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C;
                             }
                             sr.printf("Disable SRP_INTERVAL_COUNTER\r\n");
-                            pl_main_flags&=~(PL_MAIN_STATUS);
+                            all_flags = all_flags&(~PL_MAIN_STATUS);
                         }
                     }
                 }
-                if(power_level>1) 
+                else if(power_level>1) 
                 {
-                    if(pl_prev_state==PL_OFF) 
+                    if(all_flags&PL_PREV_STATE==PL_OFF) 
                     {
                         sr.printf("Power on SPEED DL\r\n");
                     }
                     sr.printf("Power on Speed PMT with reduced Voltage\r\n");
                     sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n");
-                    if(I2C_acknowledgement==1) 
+                    if(all_flags&IS_I2C_ACK == 1) 
+                    {
+                        all_flags = (all_flags&(~PL_STATUS))|PL_HIBERNATE;                   } 
+                    else 
                     {
-                        pl_status=PL_HIBERNATE;
+                        all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C;
+                    }
+                    sr.printf("Disable SRP_INTERVAL_COUNTER\r\n");
+                    all_flags = all_flags&(~PL_MAIN_STATUS);
+                }
+            }
+            else if(power_level>2) 
+            {
+                if(all_flags&PL_PREV_STATE==PL_SCIENCE) 
+                {
+                    all_flags = (all_flags&(~PL_STATUS))|PL_SCIENCE;
+                    all_flags = all_flags&(~PL_MAIN_STATUS);
+                } 
+                else if(all_flags&PL_PREV_STATE==PL_HIBERNATE) 
+                {
+                    sr.printf("Power on SPEED PMT with high voltage \r\n");
+                    sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n");
+                    if(all_flags&IS_I2C_ACK == 1) 
+                    {
+                        sr.printf("Enable SRP_INTERVAL_COUNTER\r\n");
+                        all_flags = (all_flags&(~PL_STATUS))|PL_SCIENCE;
+                        all_flags = all_flags&(~PL_MAIN_STATUS);
                     } 
                     else 
                     {
-                        pl_status=PL_ERR_I2C;
-                    }
-                    sr.printf("Disable SRP_INTERVAL_COUNTER\r\n");
-                    pl_main_flags&=~(PL_MAIN_STATUS);
-                }
-            }
-            if(power_level>2) 
-            {
-                if(pl_prev_state==PL_SCIENCE) 
-                {
-                    pl_status=PL_SCIENCE;
-                    pl_main_flags&=~(PL_MAIN_STATUS);
-                } 
-                else if(pl_prev_state==PL_HIBERNATE) 
-                {
-                    sr.printf("Power on SPEED PMT with high voltage \r\n");
-                    sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n");
-                    if(I2C_acknowledgement==1) 
-                    {
-                        sr.printf("Enable SRP_INTERVAL_COUNTER\r\n");
-                        pl_status=PL_SCIENCE;
-                        pl_main_flags&=~(PL_MAIN_STATUS);
-                    } 
-                    else 
-                    {
-                        pl_status=PL_ERR_I2C;
+                        all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C;
                         sr.printf("Disable SRP_INTERVAL_COUNTER\r\n");
-                        pl_main_flags&=~(PL_MAIN_STATUS);
+                        all_flags = all_flags&(~PL_MAIN_STATUS);
                     }
                 } 
                 else
 
                 {
-                    if(pl_prev_state==PL_OFF) 
+                    if(all_flags&PL_PREV_STATE!=PL_OFF) 
                     {
                         sr.printf("Power on SPEED DL\r\n");
                     }
                     sr.printf("Power on Speed PMT with reduced Voltage\r\n");
                     sr.printf("Command SPEED DL to go to Standby State (I2C) \r\n");
-                    if(I2C_acknowledgement==1) 
+                    if(all_flags&IS_I2C_ACK == 1) 
                     {
-                        pl_status=PL_HIBERNATE;
+                        all_flags = (all_flags&(~PL_STATUS))|PL_HIBERNATE;                   
                     } 
                     else 
                     {
-                        pl_status=PL_ERR_I2C;
+                        all_flags = (all_flags&(~PL_STATUS))|PL_ERR_I2C;
                     }
                     sr.printf("Disable SRP_INTERVAL_COUNTER\r\n");
-                    pl_main_flags&=~(PL_MAIN_STATUS);
+                    all_flags = all_flags&(~PL_MAIN_STATUS);
                 }
             }
-
-
         }
-
     }
 }
\ No newline at end of file
--- a/PL.h	Mon Jul 06 10:31:29 2015 +0000
+++ b/PL.h	Mon Jul 06 11:26:57 2015 +0000
@@ -1,19 +1,10 @@
-uint8_t pl_main_flags;
-uint8_t pl_state;
-uint8_t pl_prev_state;
-uint8_t pl_schedule_TC;
-uint8_t pl_status;
-bool pl_schedule;
+uint64_t pl_schedule_TC;
 int8_t power_level;
-bool I2C_acknowledgement;
 
 int payloadBins = 4;
 
-uint64_t PL_SCIENCE_FLAG;
 uint8_t scienceRawPacket[4];
 Timer SRP_INTER_VAL_COUNTER;
-bool First_Science_Data=0;
 float TIME_ELAPSED_LAST_SRP=0;
-bool PL_FRAME_SIZE_CORRECT;
 
 extern uint64_t all_flags;
\ No newline at end of file