Simple version of COM_MNG_TMTC_CODE for IITMSAT.

Dependencies:   mbed-rtos mbed FreescaleIAP SimpleDMA

Committer:
ee12b079
Date:
Thu Apr 14 04:34:58 2016 +0000
Revision:
162:48fda0b8d573
Parent:
161:a63672bf4423
Child:
170:286ef9dad36a
Merged bae_i2c

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