
Repository for CDMS code
Dependencies: SimpleDMA mbed-rtos mbed eeprom
Fork of COM_MNG_TMTC_SIMPLE by
Revision 145:fb800fecf128, committed 2016-04-02
- Comitter:
- ee12b079
- Date:
- Sat Apr 02 11:54:50 2016 +0000
- Parent:
- 136:8074893cd24e
- Commit message:
- worked for PL
Changed in this revision
--- a/COM_MNG_TMTC.h Thu Mar 10 15:26:50 2016 +0000 +++ b/COM_MNG_TMTC.h Sat Apr 02 11:54:50 2016 +0000 @@ -1022,11 +1022,14 @@ t_pl.start(); if(rcv_isr == 1) { + #if DEBUG gPC.printf("read_ack = %d",read_ack); + #endif t_pl.stop(); + gPC.printf("data:\n"); //gPC.printf("i2c_t = %d",t_pl.read_ms()); - for(int i = 0;i< PL_TM_SIZE;i++) - tm_pointer->TM_string[i] = PL_I2C_DATA[i]; + for(int i = 0;i< 134;i++) + gPC.printf("%d\n",PL_I2C_DATA[i]); rcv_isr = 0; break; }
--- a/COM_SND_TM.h Thu Mar 10 15:26:50 2016 +0000 +++ b/COM_SND_TM.h Sat Apr 02 11:54:50 2016 +0000 @@ -45,7 +45,7 @@ #define print_tm(ptr) {\ for( int i = 0; i < 134; i++ ){\ - gPC.putc(ptr[i]);\ + /* gPC.printf("%d\n",ptr[i]);*/\ }\ } @@ -266,6 +266,8 @@ DS_state = !DS_state;\ if (DS_f){\ DS_f = false;\ + if(bypass_adf)\ + print_tm(ptr);\ exor(ptr);\ convolution(ptr);\ interleave(convoluted_frame,interleave_data[0]);\
--- a/adf.h Thu Mar 10 15:26:50 2016 +0000 +++ b/adf.h Sat Apr 02 11:54:50 2016 +0000 @@ -215,8 +215,6 @@ spi.write(0x20);\ for(unsigned char i=0; i<112;i++){\ spi.write(buffer_112[i]);\ - if(bypass_adf == 1)\ - gPC.putc(buffer_112[i]);\ }\ }\ else{\ @@ -224,8 +222,6 @@ spi.write(0x90);\ for(unsigned char i=0; i<112;i++){\ spi.write(buffer_112[i]);\ - if(bypass_adf == 1)\ - gPC.putc(buffer_112[i]);\ }\ }\ gCS_ADF=1;\
--- a/crc.h Thu Mar 10 15:26:50 2016 +0000 +++ b/crc.h Sat Apr 02 11:54:50 2016 +0000 @@ -74,4 +74,39 @@ } return remainder; -} \ No newline at end of file +} + +uint16_t crc16_gen1( char message[], unsigned int nBytes){ + crctype16 remainder = 0xffff; + int byte; + char bit; + + for( byte = 0 ; byte < nBytes ; byte++ ){ + /* + Bring the data byte by byte + each time only one byte is brought + 0 xor x = x + */ + remainder = remainder ^ ( message[byte] << 8 ); + + for( bit = 8 ; bit > 0 ; bit--){ + /* + for each bit, xor the remainder with polynomial + if the MSB is 1 + */ + if(remainder & TOPBIT16){ + remainder = (remainder << 1) ^ POLYNOMIAL16; + /* + each time the remainder is xor-ed with polynomial, the MSB is made zero + hence the first digit of the remainder is ignored in the loop + */ + } + else{ + remainder = (remainder << 1); + } + } + } + + return remainder; +} +
--- a/i2c.h Thu Mar 10 15:26:50 2016 +0000 +++ b/i2c.h Sat Apr 02 11:54:50 2016 +0000 @@ -12,7 +12,7 @@ bool read_ack = true; -char PL_I2C_DATA[134];//Payload i2c array + uint8_t PL_TM_SIZE;//size of data to bev read from i2c void FCTN_I2C_WRITE_PL(char *data2,uint8_t tc_len2) @@ -93,6 +93,8 @@ } +const int addr1 = (0x20<<1|0); +const int addr2 = (0x20<<1|1); @@ -103,8 +105,7 @@ void isr_pyldtm() { - - read_ack = master.read(addr_pl|1,PL_I2C_DATA,134); gLEDR=!gLEDR; + read_ack = master.read(addr1,PL_I2C_DATA,134); rcv_isr = 1; } \ No newline at end of file
--- a/main.cpp Thu Mar 10 15:26:50 2016 +0000 +++ b/main.cpp Sat Apr 02 11:54:50 2016 +0000 @@ -2,11 +2,12 @@ #include "mbed.h" +char PL_I2C_DATA[150];//Payload i2c array uint8_t rcv_isr = 0; // flag for interrupt -#define DEBUG 1 -#define SDCARD 1 -#define I2C_PL 0 +#define DEBUG 0 +#define SDCARD 0 +#define I2C_PL 1 #include "SimpleDMA.h" @@ -34,6 +35,33 @@ //void set_sig(){gSCIENCE_THREAD->signal_set(SCIENCE_SIGNAL);} +char pia1 [13] ; + +void INIT_TC_TEMP (void) +{ + int i; + uint16_t CRC_VALUE = 0 ; + + pia1[0] = 123 ; + pia1[1] = 0x00 ; + pia1[2] = 0x81 ; + pia1[3] = 0xD0 ; + pia1[4] = 0x00 ; + pia1[5] = 0x00 ; + pia1[6] = 0x00 ; + pia1[7] = 0x00 ; + pia1[8] = 0x00 ; + CRC_VALUE = crc16_gen1(pia1,9); + pia1[9] = (char)((CRC_VALUE >> 8) & 0xff); + pia1[10] = (char)((CRC_VALUE >> 0) & 0xff); + + for(i = 0; i < 13 ; i++) + { + PL_I2C_DATA[i]= 0; + } + + +} int main() { @@ -49,10 +77,10 @@ // gRX_CURRENT_PTR = gRX_CURRENT_DATA_NODE->values; RX1M.attach(&rx_read, Serial::RxIrq); - #if I2c + //I2C to Payload (depends on pl interrupt design) PYLD_I2C_Int.rise(&isr_pyldtm); - #endif + // DEBUG //gPC.puts("welcome to mng_tm_tc\r\n"); @@ -111,28 +139,12 @@ {delete gSCIENCE_THREAD; break;} }*/ - #if I2c + INIT_TC_TEMP(); + master.frequency(400000); int i =0 ; char test[1] ; test[0] = 7; - while(1) - { - - wait(5); - printf("Wriring to I2C\n"); - master.write(addr_pl|0x00,test,1); - - if(rcv_isr == 1) - { - for(i = 0; i < 134 ; i++) - { - printf("%d\r\n",PL_I2C_DATA[i]); - } - rcv_isr = 0; - } - - } - #endif + while(true){ Thread::wait(osWaitForever); //state = gCOM_MNG_TMTC_THREAD->get_state() + '0';