CDMS code for testing sbc

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Files at this revision

API Documentation at this revision

Comitter:
chaithanyarss
Date:
Mon Jul 04 20:27:37 2016 +0000
Parent:
224:3ac1f91e0ebc
Commit message:
comparing with standalone;

Changed in this revision

COM_MNG_TMTC.h Show annotated file Show diff for this revision Revisions of this file
DefinitionsAndGlobals.h Show annotated file Show diff for this revision Revisions of this file
FreescaleIAP.lib Show annotated file Show diff for this revision Revisions of this file
i2c.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/COM_MNG_TMTC.h	Mon Jul 04 14:31:30 2016 +0000
+++ b/COM_MNG_TMTC.h	Mon Jul 04 20:27:37 2016 +0000
@@ -12,7 +12,7 @@
 
 //#include "Flash.h"
 
-DigitalIn tm_status_4m_slv(PIN39); //I2C interrupt to CDMS from BAE
+//DigitalIn tm_status_4m_slv(PIN39); //I2C interrupt to CDMS from BAE
 //DigitalIn tm_status_4m_pl(PIN61); //I2C interrupt to CDMS from PL
 #define RESET_CDMS NVIC_SystemReset()
 
@@ -359,12 +359,13 @@
         {
             BAE_I2C_mutex.lock();
             gPC.printf("Telecommand is for BAE\r\n");
-            gPC.printf("Sending TC to BAE...\r\n"); //interrupt to be sent to the bae
-            y = FCTN_I2C_WRITE((char*)tc_ptr->TC_string,TC_LONG_SIZE);                         // Check for SHORT and LONG TC and then send
+            //gPC.printf("Sending TC to BAE...\r\n"); //interrupt to be sent to the bae
+            y = FCTN_I2C_WRITE((char*)tc_ptr->TC_string,135);                         // Check for SHORT and LONG TC and then send
                 
             if(y==1)                                                            
             {                                                                               
                 ACK_L234(tm_ptr_short,0x03,GETpacket_seq_count(tc_ptr));
+                BAE_I2C_mutex.unlock();
                 return tm_ptr_short;
             }                                  
             else if(y==0)
@@ -380,16 +381,18 @@
                 {
                     gPC.printf("BAE_I2C_GPIO is high\r\n");
                     
-                    y=FCTN_I2C_READ((char*)tm_pointer->TM_string,TM_LONG_SIZE);            //rify later about the size
+                    y=FCTN_I2C_READ((char*)tm_pointer->TM_string,134);            //rify later about the size
                     if(y==0)
                     {
                         tm_pointer->next_TM=NULL;
+                        BAE_I2C_mutex.unlock();
                         return tm_ptr;
                     }
                     else if(y==1)
                     {
                         ACK_L234(tm_ptr_short,0x85,GETpacket_seq_count(tc_ptr));                
                         //gPC.printf("\n\rPTE->PDIR = 0x%08X",PTE->PDIR);
+                        BAE_I2C_mutex.unlock();
                         return tm_ptr_short;
                         break;  
                     }
@@ -398,10 +401,10 @@
                 {
                     gPC.printf("BAE_I2C_GPIO is not high\r\n");                    
                     ACK_L234(tm_ptr_short,0x84,GETpacket_seq_count(tc_ptr));
+                    BAE_I2C_mutex.unlock();
                     return tm_ptr_short;
                 }
-            }
-            BAE_I2C_mutex.unlock();
+            }          
         }
 
         case 2: // APID = 2 corresponds to CDMS
--- a/DefinitionsAndGlobals.h	Mon Jul 04 14:31:30 2016 +0000
+++ b/DefinitionsAndGlobals.h	Mon Jul 04 20:27:37 2016 +0000
@@ -31,8 +31,8 @@
     DigitalOut PL_I2C_GPIO(PTC1);
             
 //I2C - CDMS to BAE
-    DigitalIn BAE_I2C_GPIO(PIN39);
-    DigitalOut CDMS_I2C_GPIO(PIN67);
+    DigitalIn BAE_I2C_GPIO(PIN67);
+    DigitalOut CDMS_I2C_GPIO(PIN39);
 
 // TC LIST
     #define TCL_STATE_INCOMPLETE 0x00
@@ -102,8 +102,8 @@
     // Add more entries above
     
     // SIZE of tc in bytes
-    #define TC_SHORT_SIZE 11
-    #define TC_LONG_SIZE 135
+//    #define TC_SHORT_SIZE 11
+//    #define TC_LONG_SIZE 135
     
     // TMID list
     #define TMID_ACK_L1 0xA
--- a/FreescaleIAP.lib	Mon Jul 04 14:31:30 2016 +0000
+++ b/FreescaleIAP.lib	Mon Jul 04 20:27:37 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/Sissors/code/FreescaleIAP/#6749f7702fa5
+https://developer.mbed.org/teams/iitmsat/code/I2Ccomparewithstandalone/#6749f7702fa5
--- a/i2c.h	Mon Jul 04 14:31:30 2016 +0000
+++ b/i2c.h	Mon Jul 04 20:27:37 2016 +0000
@@ -128,33 +128,35 @@
 }
 
 bool FCTN_I2C_WRITE(char *data,int tc_len2)       // Returns 0 for success
-{    
+{
     CDMS_I2C_GPIO = 1;
-    write_ack = master.write(addr_bae|0x00,data,tc_len2);    
-    Thread::wait(1);    //As per the tests Thread::wait is not required on master side but its safe to give 1ms
+    write_ack = master.write(addr_bae|0x00,data,tc_len2);
+    wait_ms(1);    //As per the tests Thread::wait is not required on master side but its safe to give 1ms
     pdirw1=PTE->PDIR;
     uint8_t i2c_count = 0;
     if(write_ack == 0)
     {
         while(((pdirw1 & 0x03000000)!=0x03000000)&& i2c_count<10)
         {
-            Thread::wait(1);
+            wait_ms(1);
             pdirw1=PTE->PDIR;
             i2c_count++;
         }
         if(((pdirw1 & 0x03000000)==0x03000000))
         {
-            gPC.printf("\n\r Data sent");        
+            gPC.printf("\n\r Data sent");
         }
         else
         {
             I2C_busreset();
+            gPC.printf("\n\rData not sent");
             write_ack = 1;
         }
     }      
     if (write_ack == 1)
     {
         I2C_busreset();
+        gPC.printf("\n\rData not sent");
     }
     CDMS_I2C_GPIO = 0;
     i2c_count = 0;
--- a/main.cpp	Mon Jul 04 14:31:30 2016 +0000
+++ b/main.cpp	Mon Jul 04 20:27:37 2016 +0000
@@ -37,23 +37,23 @@
 #include "TEST_PL.h"
 
 #define PL_TC(tm_ptr){\
-    Base_tc *beacon_tc = new Short_tc;\
+    Base_tc *beacon_tc = new Long_tc;\
     beacon_tc->next_TC = NULL;\
     PUTshort_or_long(beacon_tc,SHORT_TC_CODE);\
     PUTcrc_pass(beacon_tc,0x1);\
     PUTexec_status(beacon_tc,0);\
     beacon_tc->TC_string[0] = 0x01;\
-    beacon_tc->TC_string[1] = 0xE0;\
+    beacon_tc->TC_string[1] = 0x60;\
     beacon_tc->TC_string[2] = 0x81;\
-    beacon_tc->TC_string[3] = 0xD0;\
+    beacon_tc->TC_string[3] = 0x21;\
     beacon_tc->TC_string[4] = 0x00;\
     beacon_tc->TC_string[5] = 0;\
     beacon_tc->TC_string[6] = 0;\
     beacon_tc->TC_string[7] = 0;\
     beacon_tc->TC_string[8] = 0;\
-    uint16_t crc16 = crc16_gen(beacon_tc->TC_string, 9);\
-    beacon_tc->TC_string[9]  = (crc16 & 0xFF00)>>8;\
-    beacon_tc->TC_string[10] = (crc16 & 0x00FF);\
+    beacon_tc->TC_string[9] = 0x1d;\
+    beacon_tc->TC_string[10] = 0xd9;\
+    for(uint8_t z=11;z<135;z++){beacon_tc->TC_string[z] = 0;}\
     tm_ptr =  FCTN_CDMS_RLY_TMTC(beacon_tc);\
 }
 #define OBSRS_TC(tm_ptr){\
@@ -106,7 +106,7 @@
     
     // DEBUG
     //gPC.puts("welcome to mng_tm_tc\r\n");
-    gPC.baud(115200);//changed for bypassing COM
+    gPC.baud(9600);//changed for bypassing COM
     
     // COMMON SPI
     spi.format(8,0);
@@ -145,20 +145,26 @@
     
     
     master.frequency(400000);
-    PL_wo_dma = new RtosTimer(payload_isr_fun_dma, osTimerPeriodic,(void * )NULL);
+    //PL_wo_dma = new RtosTimer(payload_isr_fun_dma, osTimerPeriodic,(void * )NULL);
     //PL_wo_dma->start(6000);//
-    gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);
+    //gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);
     
-    
-    
+    while(1)
+    {
+        CDMS_I2C_GPIO = ~CDMS_I2C_GPIO;
+        wait(2);
+    }
     
-    /*gPC.printf("PL_TC sending\r\n");
+    while(1)
+    {
+        wait(5);
+        gPC.printf("PL_TC sending\r\n");    
+        Base_tm *tm_ptr = new Long_tm;
+        PL_TC(tm_ptr);
+    }
     
-    Base_tm *tm_ptr = new Short_tm;
-    OBSRS_TC(tm_ptr);
+    //gPC.printf("PL_TC sent");
     
-    gPC.printf("PL_TC sent");
-    */
     // *******************INITIALISATIONS END********************
     
     FCTN_CDMS_HK_MAIN((void *)NULL);