CDMS_CODE_samp_23SEP_DMA_flag

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE_samp_23SEP_DMA by iitm sat

Revision:
130:d5b53088270b
Parent:
105:5ce0337e7c15
Child:
131:8745e6041ebc
Child:
132:d4a4461214ad
diff -r a232a4352664 -r d5b53088270b i2c.h
--- a/i2c.h	Fri Feb 26 13:29:33 2016 +0000
+++ b/i2c.h	Sat Feb 27 07:12:04 2016 +0000
@@ -4,13 +4,11 @@
 
 InterruptIn irpt_4m_slv(D3);                                      //I2c interrupt from CDMS
 DigitalOut irpt_2_slv(D4);                                        //I2C interrupt to CDMS
-//I2C master(PIN32,PIN31);
-I2C master(PTC9,PTC8);
-//DigitalOut led1(PIN46);
-//DigitalOut led2(PIN95);
+//I2C master(PTC9,PTC8);
 const int addr = 0x20;                                            //slave address 
-char telecommand[tc_len];
-char telemetry[tm_len];
+const int addr_pl = 0x20<<1;                                            //PL slave address
+//char telecommand[tc_len];
+//char telemetry[tm_len];
 //Timer test;
 //Timer t_read;
 bool write_ack = true;
@@ -18,29 +16,44 @@
 
 int count = 0;
 
-void FCTN_I2C_WRITE(char *data)
+void FCTN_I2C_WRITE_PL(char *data2,uint8_t tc_len2)
 {
-    irpt_2_slv = 1;
-    //t.start();
-    write_ack = master.write(addr|0x00,data,tc_len);
-    //t.stop();
-    //if(write_ack == 0)
-        //gPC.printf("\n\r data not sent \n");
-       
-if (write_ack == 1)
+    write_ack = master.write(addr_pl|0x00,data2,tc_len2);//address to be defined in payload
+    if(write_ack == 0)
+    {
+        #if DEBUG
+        gPC.printf("\n\r data not sent \n");
+        #endif
+        }
+    else
     {
-//        led2 = 1;
-        //gPC.printf("\n\r data not sent \n");
-//        led2 = 0;    
-    }
-    irpt_2_slv = 0;
-    //gPC.printf("\n\r %d \n",t.read_us());
+        #if DEBUG
+        gPC.printf("\n\r data sent \n");
+        #endif
+        }
+}
+void FCTN_I2C_READ_PL(char *data,int length)
+{   
+    //t_read.start();
+    read_ack = master.read(addr_pl|1,data,length);
+    //t_read.stop();
+  
+    //if(read_ack == 0)
+      //  printf("\n\rData received from BAE %s \n",data);
+ //if (read_ack == 1)
+//    {
+//        gLEDR = 1;
+//        printf("\n \r data not received \n");
+//        gLEDR = 0;
+//    }
+//if(read_ack == 1)
+//pc.printf("\n \r data not received \n");
+    //printf("\n\r %d \n",t.read_us());
     //t.reset();
 }
 
-
-void FCTN_I2C_READ(char *data,int length)
-{
+void FCTN_I2C_READ(char *data,int length, int addr)
+{   
     irpt_2_slv = 1;
     //t_read.start();
     read_ack = master.read(addr|1,data,length);
@@ -60,4 +73,24 @@
     irpt_2_slv = 0;
     //printf("\n\r %d \n",t.read_us());
     //t.reset();
+}
+
+void FCTN_I2C_WRITE(char *data)
+{
+    irpt_2_slv = 1;
+    //t.start();
+    write_ack = master.write(addr|0x00,data,tc_len);
+    //t.stop();
+    //if(write_ack == 0)
+        //gPC.printf("\n\r data not sent \n");
+       
+if (write_ack == 0)
+    {
+//        led2 = 1;
+        //gPC.printf("\n\r data not sent \n");
+//        led2 = 0;    
+    }
+    irpt_2_slv = 0;
+    //gPC.printf("\n\r %d \n",t.read_us());
+    //t.reset();
 }
\ No newline at end of file