PYLD_CDMS

Dependencies:   mbed

Fork of PLYD_CDMS_1_2 by Siva ram

Revision:
3:d2307fb2455c
Parent:
2:623747e75e3c
Child:
4:ec3f71ef8732
--- a/main.cpp	Sat Oct 03 10:20:07 2015 +0000
+++ b/main.cpp	Sun Nov 01 09:38:31 2015 +0000
@@ -9,12 +9,12 @@
 void FUNC_MASTER_WRITE(void);
 const int addr = 0x20<<1;
 const int addr1 = (0x20<<1|0);
-Timer Siv ;
+//Timer Siv ;
 I2C master (D14,D15);
 InterruptIn PYLD_I2C_Int(PTA13);
 //DigitalIn test(PTA13);
 SPISlave device(PTD6, PTD7, PTD5,PTD4 ); // mosi, miso, sclk, ssel --> using SPI1
-InterruptIn PYLD_SPI_Interrupt(PTD2);
+//InterruptIn PYLD_SPI_Interrupt(PTD2);
 DigitalOut flash(LED4);
 int payloadBins = 3096;
 float Stability_delay = 0.005228 ;// 0.005228
@@ -44,7 +44,7 @@
     pc.printf("\r\n");
  
 } 
-int dt3;
+int dt3,pia = 0;
 bool f = 1;
 char rdata[30],rdata2;
 void readds()
@@ -57,31 +57,24 @@
      
              //while(!f)
              //{    
-               f=  master.read(addr1,rdata,26);
+     //          f=  master.read(addr1,rdata,26);
              //}
-    /*
-        for(int i = 0;i<10;i++)
-    {
      master.start();
-     master.write(addr1);
-     rdata[i] = master.read(1);
-     master.stop();
-     }
+        for(int i = 0;i<26;i++)
+            {
+     
+                master.write(addr1);
+                rdata[i] = master.read(1);
     
-               master.read(addr1,&rdata[0],1);
-               master.read(addr1,&rdata[1],1);
-               master.read(addr1,&rdata[2],1);
-               master.read(addr1,&rdata[3],1);
-               master.read(addr1,&rdata[4],1);
-               master.read(addr1,&rdata[5],1);
-               master.read(addr1,&rdata[6],1);
-               master.read(addr1,&rdata[7],1);
-               master.read(addr1,&rdata[8],1);
-               master.read(addr1,&rdata[9],1);
-               master.read(addr1,&rdata[10],1);
-               master.read(addr1,&rdata[11],1);
-               master.read(addr1,&rdata[12],1);
-      */       
+            }
+     
+      master.stop();
+ /*
+     for(pia = 0 ;pia<26;pia ++)
+      {
+               master.read(addr1,&rdata[pia],1); 
+    }
+     */        
               // dt3 = master.read(1);
                
                
@@ -95,9 +88,9 @@
 void FUNC_MASTER_WRITE(void)
 {  
 
-for (dt3 = 0;dt3 <11 ; dt3++)
+for (dt3 = 0;dt3 <15 ; dt3++)
 {
-test [dt3] = 1 ;
+test [dt3] = dt3 ;
 } 
   int data5 = pc.getc();      
       loop=1;
@@ -108,7 +101,9 @@
      while(loop)
      {
          
-         bool check = (bool)master.write(addr,test,135);
+         bool check = (bool)master.write(addr,test,13);
+        // bool check = (bool)master.write(addr,&test[3],1,false);
+         // check = (bool)master.write(addr,&test[4],1);
          
          //wait_us(10);
          
@@ -120,28 +115,56 @@
         // while(!test);
          
         // readds();
-         
-        //master.start();
-        //bool check1 = master.write(addr1);
+       /*
+         master.start();
+         master.write(addr1);   
+            
+        for(  pia = 0 ; pia<2 ; pia++)
+        {
+            
+            master.write(test[pia]);
+           //wait_us(2);
+            
+            
+        }
+        
+
+        
+        
+        for(  pia = 2 ; pia<13 ; pia++)
+        {
+            
+            master.write(test[pia]);
+           //wait_us(2);
+            
+            
+        }
+        master.stop();
+        
+        */
+        /*
+        master.start();
+        bool check1 = master.write(addr1);
        // wait_us(10);
-       // bool check2 = master.write(3);
+        bool check2 = master.write(1);
         //wait_us(10);
-        // check2 = master.write(1);
-        // master.write(97);
-         //master.write(107);
-         //master.write(116);
-         //master.write(104);
-         //master.write(105);
+         check2 = master.write(2);
+         master.write(3);
+         master.write(4);
+         master.write(5);
+         master.write(6);
+         master.write(7);
          //wait_us(10);
-         //master.write(32);
-         //master.write(80);
-         //master.write(114);
-         //master.write(105);
-         //master.write(121);
-         //master.write(97);
+         master.write(8);
+         master.write(9);
+         master.write(10);
+         master.write(11);
+         master.write(12);
+         master.write(13);
          
-        // master.stop();
+         master.stop();
          
+         */
          
 
          loop = 0;
@@ -150,12 +173,12 @@
 
 int main() {
     int dt1 = 0,dt2 = 0 ,P= 0;
-    device.format(16,0);  // SPI format --> 16 bits, mode = 0
-    device.frequency(1000000);
-   // master.frequency(400000);
+    //device.format(16,0);  // SPI format --> 16 bits, mode = 0
+    //device.frequency(1000000);
+    master.frequency(400000);
        
     pc.printf("Example code demonstarting Payload - CDMS SPI & I2C communication!\r\n");
-    PYLD_SPI_Interrupt.rise(&payloadProcess);
+    //PYLD_SPI_Interrupt.rise(&payloadProcess);
     PYLD_I2C_Int.rise(&readds);
     
     while(1)