Siva ram
/
PLYD_CDMSee
PYLD_CDMS
Fork of PLYD_CDMS_1_2 by
Diff: main.cpp
- Revision:
- 4:ec3f71ef8732
- Parent:
- 3:d2307fb2455c
--- a/main.cpp Sun Nov 01 09:38:31 2015 +0000 +++ b/main.cpp Sat Nov 07 09:52:57 2015 +0000 @@ -5,16 +5,18 @@ // packet length = 32*16 bits (32 bins --> each 2 bytes) #include "mbed.h" +#include "MKL46Z4.h" //int f; void FUNC_MASTER_WRITE(void); const int addr = 0x20<<1; const int addr1 = (0x20<<1|0); +const int addr2 = (0x20<<1|1); //Timer Siv ; I2C master (D14,D15); InterruptIn PYLD_I2C_Int(PTA13); -//DigitalIn test(PTA13); +//gitalIn 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 @@ -46,7 +48,7 @@ } int dt3,pia = 0; bool f = 1; -char rdata[30],rdata2; +char rdata[140],ta2; void readds() { @@ -57,18 +59,21 @@ //while(!f) //{ - // f= master.read(addr1,rdata,26); + f= master.read(addr1,rdata,135); //} - master.start(); - for(int i = 0;i<26;i++) - { + // master.start(); + //for(int i = 0;i<26;i++) + //{ - master.write(addr1); - rdata[i] = master.read(1); + // master.write(addr2); + + // rdata[i] = master.read(1); + //wait_us(20); + - } + // } - master.stop(); + // master.stop(); /* for(pia = 0 ;pia<26;pia ++) { @@ -88,7 +93,7 @@ void FUNC_MASTER_WRITE(void) { -for (dt3 = 0;dt3 <15 ; dt3++) +for (dt3 = 0;dt3 <135 ; dt3++) { test [dt3] = dt3 ; } @@ -101,7 +106,7 @@ while(loop) { - bool check = (bool)master.write(addr,test,13); + bool check = (bool)master.write(addr,test,135); // bool check = (bool)master.write(addr,&test[3],1,false); // check = (bool)master.write(addr,&test[4],1); @@ -173,12 +178,12 @@ int main() { int dt1 = 0,dt2 = 0 ,P= 0; - //device.format(16,0); // SPI format --> 16 bits, mode = 0 - //device.frequency(1000000); + 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) @@ -187,10 +192,11 @@ wait(1); //dt1 = rdata[0] ; //dt2 = rdata[1] ; - for(P = 0 ; P < 26 ; P++ ) + for(P = 0 ; P < 135 ; P++ ) { pc.printf("Temperature %d \n\r",rdata[P]); } + pc.printf(" I2C data register %d \n", I2C1 -> S); // pc.printf("Temperature %d \n\r",dt1); // pc.printf("Temperature2 %d \n\r",dt2); //pc.printf("Temperature3 %d \n\r",dt3);