
publishing to check changes in cdms code
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE_samp_23SEP_DMA_flag by
Revision 126:b7c024b5632d, committed 2016-02-10
- Comitter:
- ee12b079
- Date:
- Wed Feb 10 17:01:26 2016 +0000
- Parent:
- 125:a3b95a9c16ef
- Child:
- 128:a232a4352664
- Commit message:
- I2C code integrated, to be tested with PL
Changed in this revision
--- a/COM_MNG_TMTC.h Mon Feb 08 14:24:08 2016 +0000 +++ b/COM_MNG_TMTC.h Wed Feb 10 17:01:26 2016 +0000 @@ -13,8 +13,9 @@ //#include "Flash.h" #include "cdms_rtc.h" -DigitalIn tm_status_4m_slv(PIN39); //I2C interrupt to CDMS from BAE -//DigitalIn tm_status_4m_pl(PIN61); //I2C interrupt to CDMS from PL +//defined in definations and globals, need to mapped with the final ones. +//DigitalIn tm_status_4m_slv(PIN39); //I2C interrupt to CDMS from BAE +//DigitalIn tm_status_4m_pl(PIN61); //I2C interrupt to CDMS from PL uint8_t received = 0; uint16_t mid1; @@ -397,7 +398,7 @@ // CDMS TEAM CODE START inline Base_tm* FCTN_CDMS_RLY_TMTC(Base_tc *tc_ptr){ - uint8_t ACKCODE = 0x00; + uint8_t ACKCODE = 0xB0; //printf("\rTC execution in progress\r\n"); Base_tm *tm_pointer = new Long_tm; Base_tm *tm_ptr = tm_pointer; @@ -408,54 +409,54 @@ { //printf("Telecommand is for BAE\r\n"); //printf("Sending TC to BAE...\r\n"); //interrupt to be sent to the bae - FCTN_I2C_WRITE((char*)tc_ptr->TC_string); - while(1) - { - wait(1); //TimeOut instead of wait - if(tm_status_4m_slv == 1) - { - //printf("receiving...\r\n"); - FCTN_I2C_READ((char*)tm_pointer->TM_string,134); - //printf("%s", tm_pointer->TM_string); - received+=1; - tm_pointer = tm_pointer->next_TM; - break; //only for testing purpose - } - else - { - break; - } - } - if(received >= 1 ) - { - //printf("Telemetry is received from BAE\r\n"); - Base_tm *tm_print = tm_ptr; - for(uint8_t i=0;i<received;i++) - { - //printf("%s", tm_print->TM_string); - tm_print = tm_print->next_TM; //for check - } - received = 0; + //FCTN_I2C_WRITE((char*)tc_ptr->TC_string); +// while(1) +// { +// wait(1); //TimeOut instead of wait +// if(tm_status_4m_slv == 1) +// { +// //printf("receiving...\r\n"); +// FCTN_I2C_READ((char*)tm_pointer->TM_string,134); +// //printf("%s", tm_pointer->TM_string); +// received+=1; +// tm_pointer = tm_pointer->next_TM; +// break; //only for testing purpose +// } +// else +// { +// break; +// } +// } +// if(received >= 1 ) +// { +// //printf("Telemetry is received from BAE\r\n"); +// Base_tm *tm_print = tm_ptr; +// for(uint8_t i=0;i<received;i++) +// { +// //printf("%s", tm_print->TM_string); +// tm_print = tm_print->next_TM; //for check +// } +// received = 0; +// tm_pointer->next_TM = NULL; return tm_ptr; +// } +// else +// { +// //printf("Telemetry is not received from BAE\r\n"); +// //tm_pointer = new Short_tm; +// tm_pointer->TM_string[0] = 0xB0; +// tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); +// tm_pointer->TM_string[2] = 0x01; +// tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided +// tm_pointer->TM_string[4] = 0x01; +// for(uint8_t i=0;i<6;i++) +// { +// tm_pointer->TM_string[i+5] = 0; +// } +// crc16 = crc16_gen(tm_ptr->TM_string,11); +// tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); +// tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); tm_pointer->next_TM = NULL; return tm_ptr; - } - else - { - //printf("Telemetry is not received from BAE\r\n"); - //tm_pointer = new Short_tm; - tm_pointer->TM_string[0] = 0xB0; - tm_pointer->TM_string[1] = GETpacket_seq_count(tc_ptr); - tm_pointer->TM_string[2] = 0x01; - tm_pointer->TM_string[3] = ACKCODE; //ackcode to be decided - tm_pointer->TM_string[4] = 0x01; - for(uint8_t i=0;i<6;i++) - { - tm_pointer->TM_string[i+5] = 0; - } - crc16 = crc16_gen(tm_ptr->TM_string,11); - tm_pointer->TM_string[11] = (uint8_t)((crc16&0xFF00)>>8); - tm_pointer->TM_string[12] = (uint8_t)(crc16&0x00FF); - tm_pointer->next_TM = NULL; return tm_ptr; - } +// } break; } case 2: @@ -988,6 +989,9 @@ } case 3: { + + + //printf("Telecommand is for PL\r\n"); // printf("Informing PL about TC using I2C\r\n"); //interrupt to be sent to the bae // FCTN_I2C_WRITE((char*)tc_ptr->TC_string); @@ -1411,9 +1415,7 @@ }\ /*SEND call sign, ACK_L1, NON OBSRS TM TO GS*/\ snd_tm.head_pointer(tm_ptr_head);\ - gPC.puts("enter_adf\r\n");\ transmit_adf;\ - gPC.puts("exit_adf\r\n");\ /*DELETE THE TM AFTER USE*/\ tm_ptr = tm_ptr_head;\ overflowCountExecute = 0;\ @@ -1439,9 +1441,7 @@ /*execute_obsrs(current_TC, put_tm_here)*/\ /*read_TC(current_TC);*/\ execute_OBSRS_TC(current_TC);\ - gPC.puts("en_adf");\ transmit_adf;\ - gPC.puts("ex_adf");\ uint8_t tempExec = TC_STATE_SUCCESSFULLY_EXECUTED;\ PUTexec_status(current_TC, tempExec);\ /*PENDING: ABORT ON NACK CHECK, gMASTER_STATE VERIFICATION WITH SD CARD, session timeout, last executed ack l234*/\
--- a/Compression.h Mon Feb 08 14:24:08 2016 +0000 +++ b/Compression.h Wed Feb 10 17:01:26 2016 +0000 @@ -70,7 +70,9 @@ void srp(unsigned char * head){ //sci_time = FCTN_CDMS_RD_RTC(); sci_time = 0; + #if DEBUG gPC.puts("enter srp"); + #endif for (int i = 0; i < 52 ; i++){ scp_bin[i] = 0; @@ -305,11 +307,17 @@ frames[id][132] = temp_crc>>8; frames[id][133] = temp_crc & 0xff; if(test_cntr++ == 0){ + #if DEBUG gPC.puts("frame start\r\n"); + #endif for(int i = 0; i<134; i++){ + #if DEBUG gPC.printf("%02X",frames[id][i]); + #endif } + #if DEBUG gPC.puts("frame ends\r\n"); + #endif } exor(frames[id]); convolution(frames[id]); @@ -384,8 +392,9 @@ if(scp_bin[i]>0) ezf = 0; } - + #if DEBUG gPC.puts("scp\r\n"); + #endif pointer = scp; debug_cntr = 0; space = 8; unsigned char packet_pp = 1; //where to get this packet present bit---------------------------------------------------------------------------------- @@ -525,8 +534,9 @@ } } }//----------------------------------------------------------------------------------------------------------------------------------------------------- - + #if DEBUG gPC.puts("sci frame starts\r\n"); + #endif //time to make scp frame id = 0; @@ -593,5 +603,7 @@ frames[id][4] = (length-1) - j; } } + #if DEBUG gPC.puts("end srp"); + #endif }//srp fucntion end bracket \ No newline at end of file
--- a/DefinitionsAndGlobals.h Mon Feb 08 14:24:08 2016 +0000 +++ b/DefinitionsAndGlobals.h Wed Feb 10 17:01:26 2016 +0000 @@ -1,6 +1,6 @@ // **************DEFINITIONS********************* -#define bypass_adf 0 +#define bypass_adf 1 // COM_RX #define RX_TIMEOUT_LIMIT 0.5 @@ -24,6 +24,10 @@ // ADF INTERRUPUT #define ADF_IRQ PTA14 + +//I2C - Payload to CDMS (need to change while using CDMS hardware) +I2C master (D7,D6); +InterruptIn PYLD_I2C_Int(PTA13); // TC LIST #define TCL_STATE_INCOMPLETE 0x00 @@ -173,4 +177,8 @@ CDMS_HK_actual actual_data; CDMS_HK_quant quant_data; CDMS_HK_min_max min_max_data; -bool firstCount=true; \ No newline at end of file +bool firstCount=true; + +//I2C thread +Thread* ptr_t_pyldtm = NULL; +
--- a/OBSRS.h Mon Feb 08 14:24:08 2016 +0000 +++ b/OBSRS.h Wed Feb 10 17:01:26 2016 +0000 @@ -198,7 +198,6 @@ }\ }\ else{\ - gPC.printf("error in send_Ack_andcallsign()");\ }\ } #define send_S_frame {\ @@ -367,16 +366,13 @@ } } else if(T_frames_sent > T_frames_in_segment){ - gPC.printf("error in enable T_frame"); } } } else if(T_frames_sent > T_frames_in_segment){ - gPC.printf("error in if(read_success)"); } } else{ - gPC.printf("error in enable T_frame"); } } else if(adf_limit){ @@ -497,10 +493,14 @@ if( GETshort_or_long_tc(tcp) == SHORT_TC_CODE ){ short_TC = true; + #if DEBUG gPC.printf("it is short TC\r\n"); + #endif } else{ + #if DEBUG gPC.printf("it is long TC\r\n"); + #endif short_TC = false; } /* reading SID from TC */ @@ -520,10 +520,11 @@ list_of_FSC[i] = tcp->TC_string[4+i]; } } - + #if DEBUG gPC.printf("sid = %u \r\n",SID); gPC.printf("FSC = %u\r\n",FSC); gPC.puts("exit_sdcard"); + #endif // SID = 0x0; // FSC = 10; // no_of_frames = 2;
--- a/ThreadsAndFunctions.h Mon Feb 08 14:24:08 2016 +0000 +++ b/ThreadsAndFunctions.h Wed Feb 10 17:01:26 2016 +0000 @@ -102,7 +102,9 @@ } } else if( gFLAGS & NEW_TC_RECEIVED ){ + #if DEBUG gPC.puts("NEW TC RECEIVED\r\n"); + #endif // DEBUF_PRINT("NEW TC RECEIVED\r\n"); Thread::wait(10000); /*To be removed in flight model*/ gFLAGS = gFLAGS & (~NEW_TC_RECEIVED); @@ -143,7 +145,9 @@ if( tempPAHot == 0xFF ){ gFLAGS = gFLAGS & ~(COM_PA_HOT_FLAG); gCOM_PA_COOLING_TIMEOUT.detach(); + #if DEBUG gPC.puts("EXECUTING TELECOMMANDS\r\n"); + #endif // DEBUF_PRINT("EXECUTING TELECOMMANDS\r\n"); EXECUTE_OBOSC_ONLY; EXECUTE_TC; @@ -284,11 +288,37 @@ gPAY_SPI.bulkRead_start(); while(true){ + #if DEBUG gPC.puts("entering sci\r\n"); + #endif gSCIENCE_THREAD->signal_wait(SCIENCE_SIGNAL); + #if DEBUG gPC.puts("sig_set\r\n"); + #endif srp(gPAYLOAD_BUFFER); + #if DEBUG gPC.puts("exit_srp\r\n"); + #endif gPAY_SPI.bulkRead_start(); } +} + +//I2C from CDMS to PL +const int addr1 = (0x20<<1|0); + +bool f = 1; + +void isr_pyldtm() +{ + ptr_t_pyldtm->signal_set(0x4); +} + +char rdata[134]; +void pyldtm(void const *args) +{ + while(1) + { + Thread::signal_wait(0x4); + f= master.read(addr1,rdata,134); + } } \ No newline at end of file
--- a/adf.h Mon Feb 08 14:24:08 2016 +0000 +++ b/adf.h Wed Feb 10 17:01:26 2016 +0000 @@ -312,7 +312,6 @@ gCS_ADF=1;\ SPI_mutex.unlock();\ loop_on = false;\ - gPC.puts("Transmission done\r\n");\ gLEDR = 1;\ }\ else{\
--- a/main.cpp Mon Feb 08 14:24:08 2016 +0000 +++ b/main.cpp Wed Feb 10 17:01:26 2016 +0000 @@ -2,7 +2,7 @@ #include "mbed.h" -#define DEBUG 1 +#define DEBUG 0 #include "SimpleDMA.h" #include "dmaSPIslave.h" @@ -13,7 +13,7 @@ #include "pinconfig.h" #include "DefinitionsAndGlobals.h" #include "crc.h" -#include "i2c.h" +//#include "i2c.h" #include "COM_SND_TM_functions.h" #include "COM_SND_TM.h" #include "cdms_sd.h" @@ -42,6 +42,10 @@ // gRX_CURRENT_PTR = gRX_CURRENT_DATA_NODE->values; RX1M.attach(&rx_read, Serial::RxIrq); + //I2C to Payload + PYLD_I2C_Int.rise(&isr_pyldtm); + + // DEBUG //gPC.puts("welcome to mng_tm_tc\r\n"); gPC.baud(1200); @@ -71,10 +75,17 @@ gSCIENCE_THREAD = new Thread(SCIENCE_FUN); // gPC.puts("step one complete\r\n"); gSCIENCE_THREAD->set_priority(osPriorityBelowNormal); + + //thread for I2C + ptr_t_pyldtm = new Thread(pyldtm); + gSCIENCE_THREAD->set_priority(osPriorityLow);//need to check the priorities + + #if DEBUG gPC.puts("competed allocating threads\r\n"); #endif + // *******************INITIALISATIONS END******************** //RtosTimer gCDMS_HK_TIMER(FCTN_CDMS_HK_MAIN, osTimerPeriodic);