CDMS code for testing sbc

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Committer:
ee12b079
Date:
Thu Jun 30 10:51:38 2016 +0000
Revision:
197:1369ef45b49e
Parent:
184:d75cea6f5d49
Child:
198:17200a427e71
latest revision (before sdcard testing) ready to be tested bypassing COM

Who changed what in which revision?

UserRevisionLine numberNew contents of line
aniruddhv 52:0bd68655c651 1 #define tm_len 134
aniruddhv 52:0bd68655c651 2 #define tc_len 135
aniruddhv 52:0bd68655c651 3 #define tc_test_len 135
aniruddhv 52:0bd68655c651 4
aniruddhv 52:0bd68655c651 5 const int addr = 0x20; //slave address
ee12b079 161:a63672bf4423 6 bool write_ack = false;
ee12b079 161:a63672bf4423 7 bool read_ack = false;
ee12b079 161:a63672bf4423 8 const int addr_pl = 0x20<<1; //PL address
ee12b079 162:48fda0b8d573 9 const int addr_bae = 0x20; ///bae address
ee12b079 161:a63672bf4423 10 uint8_t rcv_isr = 0;
aniruddhv 52:0bd68655c651 11
aniruddhv 52:0bd68655c651 12 int count = 0;
aniruddhv 52:0bd68655c651 13
ee12b079 161:a63672bf4423 14 char PL_I2C_DATA[134];//Payload i2c array
ee12b079 161:a63672bf4423 15 uint8_t PL_TM_SIZE;//size of data to bev read from i2c
ee12b079 161:a63672bf4423 16
ee12b079 161:a63672bf4423 17 void FCTN_I2C_WRITE_PL(char *data2,uint8_t tc_len2)
aniruddhv 52:0bd68655c651 18 {
ee12b079 161:a63672bf4423 19 write_ack = master.write(addr_pl|0x00,data2,tc_len2);//address to be defined in payload
ee12b079 171:31bdf83591a1 20 if(write_ack == 0)
ee12b079 171:31bdf83591a1 21 {gPC.printf("\n\rData sent to PL \n");}
ee12b079 161:a63672bf4423 22 if(write_ack == 1)
aniruddhv 52:0bd68655c651 23 {
ee12b079 170:286ef9dad36a 24 gPC.printf("\n\rdata not sent\n");
ee12b079 161:a63672bf4423 25 }
aniruddhv 52:0bd68655c651 26 }
aniruddhv 52:0bd68655c651 27
ee12b079 184:d75cea6f5d49 28 void FCTN_I2C_READ_PL(char *data,int length)
ee12b079 184:d75cea6f5d49 29 {
ee12b079 184:d75cea6f5d49 30 PYLD_I2C_GPIO = 1;
ee12b079 184:d75cea6f5d49 31 //t_read.start();
ee12b079 184:d75cea6f5d49 32 read_ack = master.read(addr_pl|1,data,length);
ee12b079 184:d75cea6f5d49 33 //t_read.stop();
ee12b079 184:d75cea6f5d49 34
ee12b079 184:d75cea6f5d49 35 if(read_ack == 0)
ee12b079 184:d75cea6f5d49 36 gPC.printf("\n\rData received from PL \n");
ee12b079 184:d75cea6f5d49 37 if (read_ack == 1)
ee12b079 184:d75cea6f5d49 38 {
ee12b079 184:d75cea6f5d49 39 gPC.printf("\n \r data not received \n");
ee12b079 184:d75cea6f5d49 40 }
ee12b079 184:d75cea6f5d49 41 PYLD_I2C_GPIO = 0;
ee12b079 184:d75cea6f5d49 42 }
ee12b079 184:d75cea6f5d49 43
ee12b079 162:48fda0b8d573 44 void FCTN_I2C_READ(char *data,int length)
ee12b079 162:48fda0b8d573 45 {
ee12b079 162:48fda0b8d573 46 CDMS_I2C_GPIO = 1;
ee12b079 162:48fda0b8d573 47 //t_read.start();
ee12b079 162:48fda0b8d573 48 read_ack = master.read(addr_bae|1,data,length);
ee12b079 162:48fda0b8d573 49 //t_read.stop();
ee12b079 162:48fda0b8d573 50
ee12b079 162:48fda0b8d573 51 if(read_ack == 0)
ee12b079 170:286ef9dad36a 52 gPC.printf("\n\rData received from BAE \n");
ee12b079 162:48fda0b8d573 53 if (read_ack == 1)
ee12b079 162:48fda0b8d573 54 {
ee12b079 170:286ef9dad36a 55 gPC.printf("\n \r data not received \n");
ee12b079 162:48fda0b8d573 56 }
ee12b079 162:48fda0b8d573 57 //if(read_ack == 1)
ee12b079 162:48fda0b8d573 58 //pc.printf("\n \r data not received \n");
ee12b079 162:48fda0b8d573 59
ee12b079 162:48fda0b8d573 60 CDMS_I2C_GPIO = 0;
ee12b079 197:1369ef45b49e 61 //gPC.printf("\n\r %d \n",t.read_us());
ee12b079 162:48fda0b8d573 62 //t.reset();
ee12b079 162:48fda0b8d573 63 }
ee12b079 162:48fda0b8d573 64
ee12b079 162:48fda0b8d573 65 void FCTN_I2C_WRITE(char *data,uint8_t tc_len2)
ee12b079 162:48fda0b8d573 66 {
ee12b079 162:48fda0b8d573 67 CDMS_I2C_GPIO = 1;
ee12b079 162:48fda0b8d573 68 //t.start();
ee12b079 162:48fda0b8d573 69 write_ack = master.write(addr_bae|0x00,data,tc_len2);
ee12b079 162:48fda0b8d573 70 //t.stop();
ee12b079 162:48fda0b8d573 71 //if(write_ack == 0)
ee12b079 162:48fda0b8d573 72 //gPC.printf("\n\r data not sent \n");
ee12b079 162:48fda0b8d573 73
ee12b079 162:48fda0b8d573 74 if (write_ack == 1)
ee12b079 162:48fda0b8d573 75 {
ee12b079 162:48fda0b8d573 76 // led2 = 1;
ee12b079 162:48fda0b8d573 77 gPC.printf("\n\r data not sent \n");
ee12b079 162:48fda0b8d573 78 // led2 = 0;
ee12b079 162:48fda0b8d573 79 }
ee12b079 162:48fda0b8d573 80 CDMS_I2C_GPIO = 0;
ee12b079 162:48fda0b8d573 81 //gPC.printf("\n\r %d \n",t.read_us());
ee12b079 162:48fda0b8d573 82 //t.reset();
aniruddhv 52:0bd68655c651 83 }