FM

Dependencies:   SimpleDMA eeprom mbed-rtos mbed FreescaleIAP

Fork of CDMS_CODE by shubham c

Revision:
145:fb800fecf128
Parent:
136:8074893cd24e
--- a/main.cpp	Thu Mar 10 15:26:50 2016 +0000
+++ b/main.cpp	Sat Apr 02 11:54:50 2016 +0000
@@ -2,11 +2,12 @@
 
 #include "mbed.h"
 
+char PL_I2C_DATA[150];//Payload i2c array
 uint8_t rcv_isr = 0; // flag for interrupt
 
-#define DEBUG 1
-#define SDCARD 1
-#define I2C_PL 0
+#define DEBUG 0
+#define SDCARD 0
+#define I2C_PL 1
 
 
 #include "SimpleDMA.h"
@@ -34,6 +35,33 @@
 
 //void set_sig(){gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);}
 
+char pia1 [13] ;
+
+void INIT_TC_TEMP (void)
+{
+    int i;
+    uint16_t CRC_VALUE = 0 ;
+    
+    pia1[0]    = 123  ;
+    pia1[1]    = 0x00 ;
+    pia1[2]    = 0x81 ;
+    pia1[3]    = 0xD0 ;
+    pia1[4]    = 0x00 ;
+    pia1[5]    = 0x00 ;
+    pia1[6]    = 0x00 ;
+    pia1[7]    = 0x00 ;
+    pia1[8]    = 0x00 ;
+    CRC_VALUE  = crc16_gen1(pia1,9); 
+    pia1[9]    = (char)((CRC_VALUE >> 8) & 0xff);
+    pia1[10]   = (char)((CRC_VALUE >> 0) & 0xff);
+    
+                for(i = 0; i < 13 ; i++)
+            {
+                PL_I2C_DATA[i]= 0;
+            }
+    
+    
+}
 
 int main()
 {
@@ -49,10 +77,10 @@
 //    gRX_CURRENT_PTR = gRX_CURRENT_DATA_NODE->values;
     RX1M.attach(&rx_read, Serial::RxIrq);
     
-    #if I2c
+    
     //I2C to Payload    (depends on pl interrupt design)
     PYLD_I2C_Int.rise(&isr_pyldtm);
-    #endif
+    
     
     // DEBUG
     //gPC.puts("welcome to mng_tm_tc\r\n");
@@ -111,28 +139,12 @@
     {delete gSCIENCE_THREAD;
     break;}
     }*/
-    #if I2c
+    INIT_TC_TEMP();
+    master.frequency(400000);
     int i =0 ;
     char test[1] ;
     test[0] = 7;
-    while(1)
-    {
-        
-        wait(5);
-        printf("Wriring to I2C\n");
-        master.write(addr_pl|0x00,test,1);
-        
-        if(rcv_isr == 1)
-        {
-            for(i = 0; i < 134 ; i++)
-            {
-                printf("%d\r\n",PL_I2C_DATA[i]);
-            }
-            rcv_isr = 0;
-        }
-        
-    }
-    #endif
+    
     while(true){
         Thread::wait(osWaitForever);
         //state = gCOM_MNG_TMTC_THREAD->get_state() + '0';