Simple version of COM_MNG_TMTC_CODE for IITMSAT.

Dependencies:   mbed-rtos mbed FreescaleIAP SimpleDMA

Committer:
shreeshas95
Date:
Fri Jan 29 17:36:10 2016 +0000
Revision:
103:b55559925dc1
Parent:
96:4ca92f9775e0
Child:
105:5ce0337e7c15
Integrated HK : YET TO BE TESTED

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 DigitalOut irpt_2_slv(PIN67); //I2C interrupt to CDMS
aniruddhv 52:0bd68655c651 6 I2C master(PIN32,PIN31);
ee12b079 96:4ca92f9775e0 7 //DigitalOut led1(PIN46);
ee12b079 96:4ca92f9775e0 8 //DigitalOut led2(PIN95);
aniruddhv 52:0bd68655c651 9 const int addr = 0x20; //slave address
aniruddhv 52:0bd68655c651 10 char telecommand[tc_len];
aniruddhv 52:0bd68655c651 11 char telemetry[tm_len];
ee12b079 96:4ca92f9775e0 12 //Timer test;
ee12b079 96:4ca92f9775e0 13 //Timer t_read;
aniruddhv 52:0bd68655c651 14 bool write_ack = true;
aniruddhv 52:0bd68655c651 15 bool read_ack = true;
aniruddhv 52:0bd68655c651 16
aniruddhv 52:0bd68655c651 17 int count = 0;
aniruddhv 52:0bd68655c651 18
aniruddhv 52:0bd68655c651 19 void FCTN_I2C_WRITE(char *data)
aniruddhv 52:0bd68655c651 20 {
aniruddhv 52:0bd68655c651 21 irpt_2_slv = 1;
aniruddhv 52:0bd68655c651 22 //t.start();
aniruddhv 52:0bd68655c651 23 write_ack = master.write(addr|0x00,data,tc_len);
aniruddhv 52:0bd68655c651 24 //t.stop();
aniruddhv 52:0bd68655c651 25 //if(write_ack == 0)
aniruddhv 69:20f09a0c3fd2 26 //gPC.printf("\n\r data not sent \n");
aniruddhv 52:0bd68655c651 27
aniruddhv 52:0bd68655c651 28 if (write_ack == 1)
aniruddhv 52:0bd68655c651 29 {
ee12b079 96:4ca92f9775e0 30 // led2 = 1;
aniruddhv 69:20f09a0c3fd2 31 //gPC.printf("\n\r data not sent \n");
ee12b079 96:4ca92f9775e0 32 // led2 = 0;
aniruddhv 52:0bd68655c651 33 }
aniruddhv 52:0bd68655c651 34 irpt_2_slv = 0;
aniruddhv 69:20f09a0c3fd2 35 //gPC.printf("\n\r %d \n",t.read_us());
aniruddhv 52:0bd68655c651 36 //t.reset();
aniruddhv 52:0bd68655c651 37 }
aniruddhv 52:0bd68655c651 38
aniruddhv 52:0bd68655c651 39
shreeshas95 103:b55559925dc1 40 void FCTN_I2C_READ(char *data,int length)
aniruddhv 52:0bd68655c651 41 {
shreeshas95 103:b55559925dc1 42 irpt_2_slv = 1;
shreeshas95 103:b55559925dc1 43 //t_read.start();
shreeshas95 103:b55559925dc1 44 read_ack = master.read(addr|1,data,length);
shreeshas95 103:b55559925dc1 45 //t_read.stop();
shreeshas95 103:b55559925dc1 46
aniruddhv 52:0bd68655c651 47 //if(read_ack == 0)
shreeshas95 103:b55559925dc1 48 // printf("\n\rData received from BAE %s \n",data);
aniruddhv 52:0bd68655c651 49 if (read_ack == 1)
aniruddhv 52:0bd68655c651 50 {
shreeshas95 103:b55559925dc1 51 gLEDR = 1;
shreeshas95 103:b55559925dc1 52 printf("\n \r data not received \n");
shreeshas95 103:b55559925dc1 53 gLEDR = 0;
aniruddhv 52:0bd68655c651 54 }
aniruddhv 52:0bd68655c651 55 //if(read_ack == 1)
shreeshas95 103:b55559925dc1 56 //pc.printf("\n \r data not received \n");
aniruddhv 52:0bd68655c651 57
aniruddhv 52:0bd68655c651 58 irpt_2_slv = 0;
shreeshas95 103:b55559925dc1 59 //printf("\n\r %d \n",t.read_us());
aniruddhv 52:0bd68655c651 60 //t.reset();
aniruddhv 52:0bd68655c651 61 }