acs bea hk together

Dependencies:   mbed-rtos mbed

Fork of BAE_vr3honeycomb1_christmas by green rosh

Files at this revision

API Documentation at this revision

Comitter:
sakthipriya
Date:
Fri Dec 26 07:48:09 2014 +0000
Parent:
2:edd107ea4740
Commit message:
acs_bea_hk together

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r edd107ea4740 -r 98447c508ba1 main.cpp
--- a/main.cpp	Fri Dec 26 06:12:09 2014 +0000
+++ b/main.cpp	Fri Dec 26 07:48:09 2014 +0000
@@ -13,23 +13,21 @@
 InterruptIn interrupt(D9);
 InterruptIn master_reset(D8);
 
+int beacon_sc=3;
 
 Timer t;                                                        //To know the time of execution each thread
 Timer t1;
                                                        //To know the time of entering  of each thread
+void F_HK_ACQ();
+void F_ACS();
+void F_BEA();
 
 
 
 
 
-
+Thread *ptr_t_abh;
 
-Thread *ptr_t_hk_acq;
-Thread *ptr_t_acs;
-//Thread *ptr_t_acs_write2flash;
-Thread *ptr_t_bea;
-//Thread *ptr_t_bea_telecommand;
-//Thread *ptr_t_fault;
 Thread *ptr_t_i2c;
 Thread *ptr_t_wdt;  
 
@@ -58,17 +56,50 @@
 Mail<i2c_data,16> i2c_data_send;
 
 //--------------------------------------------------------------------------------------------------------------------------------------------------
+//ACS BEA HK togethr
+//--------------------------------------------------------------------------------------------------------------------------------------------------
+uint16_t tcount=1;
+float *mag_field;
+float *omega;
+float *moment;
+
+void T_ACS_BEA_HK(void const *args)
+{
+   
+   while(1)
+   {
+        
+        Thread::signal_wait(0x1);
+        if(tcount == 65532)                         //to reset the counter
+        {
+        tcount = 0;
+        }
+        if(tcount%1==0)
+        {
+        F_ACS();
+      
+        }
+        if(tcount%3==0)
+        {
+        F_BEA();
+        }
+        if(tcount%2==0)
+        {
+        F_HK_ACQ();
+        }
+        tcount++;
+   } 
+}
+
+//--------------------------------------------------------------------------------------------------------------------------------------------------
 //TASK 2 : HK
 //--------------------------------------------------------------------------------------------------------------------------------------------------
 
 char hk_data[25];
 extern SensorDataQuantised SensorQuantised;
-void T_HK_ACQ(void const *args)
+void F_HK_ACQ()
 {
-    
-    while(1)
-    {
-        Thread::signal_wait(0x2);
+        
         SensorQuantised.power_mode='3';
         printf("\nTHIS IS HK    %f\n",t1.read());
         t.start();
@@ -81,7 +112,7 @@
         t.stop();
         printf("The time to execute hk_acq is %f seconds\n",t.read());
         t.reset();
-    }
+    
 }
 
 //---------------------------------------------------------------------------------------------------------------------------------------
@@ -89,14 +120,9 @@
 //---------------------------------------------------------------------------------------------------------------------------------------
 
 int acs_pflag = 1;
-void T_ACS(void const *args)
+void F_ACS()
 {
-    float *mag_field;
-    float *omega;
-    float *moment;
-    while(1)
-    {
-        Thread::signal_wait(0x1);
+       
         printf("\nTHIS IS ACS   %f\n",t1.read());
         t.start();
         mag_field= FUNC_ACS_MAG_EXEC();                              //actual execution
@@ -111,7 +137,7 @@
         }
        
         t.reset();
-    }
+
 }
 /*
 void T_ACS_WRITE2FLASH(void const *args)
@@ -147,12 +173,8 @@
 }
 */
 
-void T_BEA(void const *args)
+void F_BEA()
 {
-    
-    while(1)
-    {
-        Thread::signal_wait(0x3);
         printf("\nTHIS IS BEACON    %f\n",t1.read());
         t.start();
         
@@ -169,7 +191,6 @@
         
         printf("The time to execute beacon thread is %f seconds\n",t.read());
         t.reset();
-    }
 }
 
 //---------------------------------------------------------------------------------------------------------------------------------------------------
@@ -378,37 +399,12 @@
 //------------------------------------------------------------------------------------------------------------------------------------------------
 //SCHEDULER
 //------------------------------------------------------------------------------------------------------------------------------------------------
-int beacon_sc = 3;
-uint16_t schedcount=1;
+
 void T_SC(void const *args)
 {
-    //DRDY=0;
-    printf("The value of i in scheduler is %d\n",schedcount);
-    if(schedcount == 65532)                         //to reset the counter
-    {
-        schedcount = 0;
-    }
-    
-    if(schedcount%1==0)
-    {
-        ptr_t_acs -> signal_set(0x1);
+        ptr_t_abh -> signal_set(0x1);
         ptr_t_wdt -> signal_set(0x5);
-    }
-    if(schedcount%2==0)
-    {
-        //ptr_t_fault -> signal_set(0x2);
-        ptr_t_hk_acq -> signal_set(0x2);
-        
-    }
-    if(schedcount%beacon_sc==0)
-    {
-        if(beac_flag==0)
-        {
-            
-            //ptr_t_bea -> signal_set(0x3);
-        }
-    }
-    schedcount++;
+
 }
     
 //---------------------------------------------------------------------------------------------------------------------------------------------
@@ -420,35 +416,29 @@
      FUNC_ACS_MAG_INIT();
      FUNC_ACS_INIT_GYR();
 
-    ptr_t_hk_acq = new Thread(T_HK_ACQ);
-    ptr_t_acs = new Thread(T_ACS);
-    //ptr_t_acs_write2flash = new Thread(T_ACS_WRITE2FLASH);
-    ptr_t_bea = new Thread(T_BEA);
-    //ptr_t_bea_telecommand = new Thread(T_BEA_TELECOMMAND);
-    //ptr_t_fault = new Thread(T_FAULT);
+    ptr_t_abh = new Thread(T_ACS_BEA_HK);
     ptr_t_i2c = new Thread(T_I2C_BAE);
-    //ptr_t_sc = new Thread(T_SC);
     ptr_t_wdt = new Thread(T_WDT);
   
     interrupt_fault();
     
     //ptr_t_fault -> set_priority(osPriorityRealtime);
-    ptr_t_acs->set_priority(osPriorityAboveNormal);
+    ptr_t_abh->set_priority(osPriorityAboveNormal);
     ptr_t_i2c->set_priority(osPriorityHigh);
-    ptr_t_hk_acq->set_priority(osPriorityAboveNormal);
+    //ptr_t_hk_acq->set_priority(osPriorityAboveNormal);
     //ptr_t_acs_write2flash->set_priority(osPriorityBelowNormal);
-    ptr_t_bea->set_priority(osPriorityAboveNormal);
+    //ptr_t_bea->set_priority(osPriorityAboveNormal);
     //ptr_t_bea_telecommand->set_priority(osPriorityIdle);
     //ptr_t_sc->set_priority(osPriorityAboveNormal);
     ptr_t_wdt -> set_priority(osPriorityIdle);
     
   
    // ----------------------------------------------------------------------------------------------
-    //printf("\n T_FAULT priority is %d",ptr_t_fault->get_priority()); 
-    printf("\n T_ACS priority is %d",ptr_t_acs->get_priority());
-    printf("\n T_HK_ACQ priority is %d",ptr_t_hk_acq->get_priority());
+    printf("\n T_WDT priority is %d",ptr_t_wdt->get_priority()); 
+    printf("\n T_T_ACS_BEA_HK priority is %d",ptr_t_abh->get_priority());
+    //printf("\n T_HK_ACQ priority is %d",ptr_t_hk_acq->get_priority());
     //printf("\n T_ACS_WRITE2FLASH priority is %d",ptr_t_acs_write2flash->get_priority());
-    printf("\n T_BEA priority is %d",ptr_t_bea->get_priority());  
+    printf("\n T_I2C priority is %d",ptr_t_i2c->get_priority());  
     RtosTimer t_sc_timer(T_SC,osTimerPeriodic);
     t_sc_timer.start(10000);
     printf("\n%f\n",t1.read()); 
@@ -460,10 +450,8 @@
        
     while(1)
     {   
-        //Thread::wait(10000);
-         //ir2master(); 
-         //DRDY = 0;
-         Thread::wait(5000);
+        ;
+       
     }
     
 }