Siva ram
/
PLYD_CDMS_1
PYLD_CDMS Integration done
Fork of PLYD_CDMS by
Revision 2:623747e75e3c, committed 2015-10-03
- Comitter:
- Piasiv1206
- Date:
- Sat Oct 03 10:20:07 2015 +0000
- Parent:
- 1:72227bdac415
- Commit message:
- pinnochio
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Jul 01 08:36:55 2015 +0000 +++ b/main.cpp Sat Oct 03 10:20:07 2015 +0000 @@ -5,16 +5,18 @@ // packet length = 32*16 bits (32 bins --> each 2 bytes) #include "mbed.h" - +//int f; void FUNC_MASTER_WRITE(void); const int addr = 0x20<<1; const int addr1 = (0x20<<1|0); 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); -int payloadBins = 32; +DigitalOut flash(LED4); +int payloadBins = 3096; float Stability_delay = 0.005228 ;// 0.005228 Serial pc(USBTX, USBRX); // tx, rx --> serial feedback for debug @@ -44,13 +46,42 @@ } int dt3; bool f = 1; -char rdata[10],rdata2; +char rdata[30],rdata2; void readds() { //wait(Stability_delay); + flash = !flash; + - f = master.read(addr,rdata,2); + + //while(!f) + //{ + 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(); + } + + 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); + */ // dt3 = master.read(1); @@ -58,10 +89,17 @@ int loop=1; char *writedata = new char; -char data[100]= "kitten"; +char data = 1,data1 = 2, data2 = 3, test[136] ; + void FUNC_MASTER_WRITE(void) -{ int data1 = pc.getc(); +{ + +for (dt3 = 0;dt3 <11 ; dt3++) +{ +test [dt3] = 1 ; +} + int data5 = pc.getc(); loop=1; @@ -69,37 +107,52 @@ *writedata = data1; while(loop) { - // bool check = (bool)master.write(addr,data,8); - bool check = (bool)master.write(addr,data,13); - /* - master.start(); - bool check1 = master.write(addr1); - bool check2 = master.write(83); - master.write(97); - //wait(1); - master.write(107); - master.write(116); - master.write(104); - master.write(105); - master.write(32); - master.write(80); - master.write(114); - master.write(105); - master.write(121); - master.write(97); + + bool check = (bool)master.write(addr,test,135); + + //wait_us(10); + + //check = (bool)master.write(addr,&data1,1); + // check = (bool)master.write(addr,&data1,1); + //check = (bool)master.write(addr,&data2,1); + //bool check = master.write(addr,test,3); + + // while(!test); + + // readds(); - master.stop(); - */ + //master.start(); + //bool check1 = master.write(addr1); + // wait_us(10); + // bool check2 = master.write(3); + //wait_us(10); + // check2 = master.write(1); + // master.write(97); + //master.write(107); + //master.write(116); + //master.write(104); + //master.write(105); + //wait_us(10); + //master.write(32); + //master.write(80); + //master.write(114); + //master.write(105); + //master.write(121); + //master.write(97); + + // master.stop(); + loop = 0; } } + int main() { - int dt1 = 0,dt2 = 0; + int dt1 = 0,dt2 = 0 ,P= 0; device.format(16,0); // SPI format --> 16 bits, mode = 0 device.frequency(1000000); - master.frequency(400000); + // master.frequency(400000); pc.printf("Example code demonstarting Payload - CDMS SPI & I2C communication!\r\n"); PYLD_SPI_Interrupt.rise(&payloadProcess); @@ -109,11 +162,14 @@ { FUNC_MASTER_WRITE(); wait(1); - dt1 = rdata[0] ; - dt2 = rdata[1] ; - //pc.printf("Temperature %d \n\r",rdata); - pc.printf("Temperature %d \n\r",dt1); - pc.printf("Temperature2 %d \n\r",dt2); + //dt1 = rdata[0] ; + //dt2 = rdata[1] ; + for(P = 0 ; P < 26 ; P++ ) + { + pc.printf("Temperature %d \n\r",rdata[P]); + } + // pc.printf("Temperature %d \n\r",dt1); + // pc.printf("Temperature2 %d \n\r",dt2); //pc.printf("Temperature3 %d \n\r",dt3);