Simple version of COM_MNG_TMTC_CODE for IITMSAT.

Dependencies:   mbed-rtos mbed FreescaleIAP SimpleDMA

Committer:
ee12b079
Date:
Wed Apr 20 12:58:58 2016 +0000
Revision:
171:31bdf83591a1
Parent:
170:286ef9dad36a
Testing OBSRS TC

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 162:48fda0b8d573 28 void FCTN_I2C_READ(char *data,int length)
ee12b079 162:48fda0b8d573 29 {
ee12b079 162:48fda0b8d573 30 CDMS_I2C_GPIO = 1;
ee12b079 162:48fda0b8d573 31 //t_read.start();
ee12b079 162:48fda0b8d573 32 read_ack = master.read(addr_bae|1,data,length);
ee12b079 162:48fda0b8d573 33 //t_read.stop();
ee12b079 162:48fda0b8d573 34
ee12b079 162:48fda0b8d573 35 if(read_ack == 0)
ee12b079 170:286ef9dad36a 36 gPC.printf("\n\rData received from BAE \n");
ee12b079 162:48fda0b8d573 37 if (read_ack == 1)
ee12b079 162:48fda0b8d573 38 {
ee12b079 170:286ef9dad36a 39 gPC.printf("\n \r data not received \n");
ee12b079 162:48fda0b8d573 40 }
ee12b079 162:48fda0b8d573 41 //if(read_ack == 1)
ee12b079 162:48fda0b8d573 42 //pc.printf("\n \r data not received \n");
ee12b079 162:48fda0b8d573 43
ee12b079 162:48fda0b8d573 44 CDMS_I2C_GPIO = 0;
ee12b079 162:48fda0b8d573 45 //printf("\n\r %d \n",t.read_us());
ee12b079 162:48fda0b8d573 46 //t.reset();
ee12b079 162:48fda0b8d573 47 }
ee12b079 162:48fda0b8d573 48
ee12b079 162:48fda0b8d573 49 void FCTN_I2C_WRITE(char *data,uint8_t tc_len2)
ee12b079 162:48fda0b8d573 50 {
ee12b079 162:48fda0b8d573 51 CDMS_I2C_GPIO = 1;
ee12b079 162:48fda0b8d573 52 //t.start();
ee12b079 162:48fda0b8d573 53 write_ack = master.write(addr_bae|0x00,data,tc_len2);
ee12b079 162:48fda0b8d573 54 //t.stop();
ee12b079 162:48fda0b8d573 55 //if(write_ack == 0)
ee12b079 162:48fda0b8d573 56 //gPC.printf("\n\r data not sent \n");
ee12b079 162:48fda0b8d573 57
ee12b079 162:48fda0b8d573 58 if (write_ack == 1)
ee12b079 162:48fda0b8d573 59 {
ee12b079 162:48fda0b8d573 60 // led2 = 1;
ee12b079 162:48fda0b8d573 61 gPC.printf("\n\r data not sent \n");
ee12b079 162:48fda0b8d573 62 // led2 = 0;
ee12b079 162:48fda0b8d573 63 }
ee12b079 162:48fda0b8d573 64 CDMS_I2C_GPIO = 0;
ee12b079 162:48fda0b8d573 65 //gPC.printf("\n\r %d \n",t.read_us());
ee12b079 162:48fda0b8d573 66 //t.reset();
ee12b079 162:48fda0b8d573 67 }
ee12b079 162:48fda0b8d573 68
ee12b079 161:a63672bf4423 69 void isr_pyldtm()
aniruddhv 52:0bd68655c651 70 {
aniruddhv 52:0bd68655c651 71
ee12b079 161:a63672bf4423 72 read_ack = master.read(addr_pl|1,PL_I2C_DATA,134);
ee12b079 161:a63672bf4423 73 gLEDR=!gLEDR;
ee12b079 161:a63672bf4423 74 rcv_isr = 1;
aniruddhv 52:0bd68655c651 75 }