
Repository for CDMS code
Dependencies: SimpleDMA mbed-rtos mbed eeprom
Fork of COM_MNG_TMTC_SIMPLE by
i2c.h@204:72f52e74e0e4, 2016-07-02 (annotated)
- Committer:
- ee12b079
- Date:
- Sat Jul 02 09:31:22 2016 +0000
- Revision:
- 204:72f52e74e0e4
- Parent:
- 198:17200a427e71
- Child:
- 209:63e9c8f8b5d2
testing obsrs tm
Who changed what in which revision?
User | Revision | Line number | New 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 | 198:17200a427e71 | 44 | int 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 | 198:17200a427e71 | 63 | return read_ack; |
ee12b079 | 162:48fda0b8d573 | 64 | } |
ee12b079 | 162:48fda0b8d573 | 65 | |
ee12b079 | 162:48fda0b8d573 | 66 | void FCTN_I2C_WRITE(char *data,uint8_t tc_len2) |
ee12b079 | 162:48fda0b8d573 | 67 | { |
ee12b079 | 162:48fda0b8d573 | 68 | CDMS_I2C_GPIO = 1; |
ee12b079 | 162:48fda0b8d573 | 69 | //t.start(); |
ee12b079 | 162:48fda0b8d573 | 70 | write_ack = master.write(addr_bae|0x00,data,tc_len2); |
ee12b079 | 162:48fda0b8d573 | 71 | //t.stop(); |
ee12b079 | 162:48fda0b8d573 | 72 | //if(write_ack == 0) |
ee12b079 | 162:48fda0b8d573 | 73 | //gPC.printf("\n\r data not sent \n"); |
ee12b079 | 162:48fda0b8d573 | 74 | |
ee12b079 | 162:48fda0b8d573 | 75 | if (write_ack == 1) |
ee12b079 | 162:48fda0b8d573 | 76 | { |
ee12b079 | 162:48fda0b8d573 | 77 | // led2 = 1; |
ee12b079 | 162:48fda0b8d573 | 78 | gPC.printf("\n\r data not sent \n"); |
ee12b079 | 162:48fda0b8d573 | 79 | // led2 = 0; |
ee12b079 | 162:48fda0b8d573 | 80 | } |
ee12b079 | 162:48fda0b8d573 | 81 | CDMS_I2C_GPIO = 0; |
ee12b079 | 162:48fda0b8d573 | 82 | //gPC.printf("\n\r %d \n",t.read_us()); |
ee12b079 | 162:48fda0b8d573 | 83 | //t.reset(); |
aniruddhv | 52:0bd68655c651 | 84 | } |