Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
Revision 17:6eb9387f1fb8, committed 2016-01-01
- Comitter:
- shreeshas95
- Date:
- Fri Jan 01 06:36:18 2016 +0000
- Parent:
- 16:538de1b20b3a
- Commit message:
- testing Rtos timer in adf interrupt
Changed in this revision
--- a/COM_MNG_TMTC.h Thu Dec 31 18:35:59 2015 +0000
+++ b/COM_MNG_TMTC.h Fri Jan 01 06:36:18 2016 +0000
@@ -81,32 +81,21 @@
#define isit_obosc(tc_ptr, temp_obosc) {\
temp_obosc = 0x00;\
- if( GETapid(tc_ptr) == 2 ){\
- if( ((tc_ptr->TC_string[2]) >> 4) == 0xB ){\
- switch( (tc_ptr->TC_string[2]) & 0xf ){\
- case 1:\
- case 2:\
- case 5:\
- case 6:\
- case 15:\
- temp_obosc = 0x01;\
- }\
+ if( GETapid(tc_ptr) == APID_COM ){\
+ /*CHECK FOR SERVICE TYPE*/\
+ if( ((tc_ptr->TC_string[2]) >> 4) == SERVICE_OBOSC ){\
+ /*IRRESPECTIVE OF SERVICE SUBTYPE*/\
+ temp_obosc = 0x01;\
}\
}\
}
#define isit_sdcard(tc_ptr, temp_sdcard) {\
temp_sdcard = 0x00;\
- if( GETapid(tc_ptr) == 2 ){\
- if( ( (tc_ptr->TC_string[2]) >> 4) == 0xF ){\
- switch( (tc_ptr->TC_string[2]) & 0xf ){\
- case 0:\
- case 1:\
- case 2:\
- case 3:\
- case 4:\
- temp_sdcard = 0x01;\
- }\
+ if( GETapid(tc_ptr) == APID_COM ){\
+ if( ( (tc_ptr->TC_string[2]) >> 4) == SERVICE_OBSRS ){\
+ /*IRRESPECTIVE OF SERVICE SUBTYPE*/\
+ temp_sdcard = 0x01;\
}\
}\
}
@@ -188,7 +177,7 @@
uint16_t overflowCount = 0;\
returnHere = 0xFF;\
while( (overflowCount < TCL_OVERFLOW_CONSTANT) && (testTC != NULL) ){\
- if( (GETpacket_seq_count(testTC) == PSC_CALLSIGN) && (GETapid(testTC) == APID_CALLSIGN) ){\
+ if( (GETpacket_seq_count(testTC) == PSC_CALLSIGN) && (GETapid(testTC) == APID_COM) ){\
uint8_t temp8 = testTC->TC_string[1];\
if( temp8 & 0x04 ){\
for( int i = 2 ; i <= 8 ; ++i ){\
@@ -554,6 +543,7 @@
break;\
}\
}\
+ uint8_t obosc_executed_count = 0;\
for(uint8_t execute_psc = PSC_START_VALUE ; execute_psc < gTOTAL_VALID_TC ; ++execute_psc){\
Base_tc* current_TC = gHEAD_NODE_TCL;\
int overCount = 0;\
@@ -572,6 +562,7 @@
/*EXECUTION OF OBOSC TC*/\
/*WARNING: LARGE MEMORY UTILIZATION FOR TC-LIST-REPORT */\
execute_obosc_core(current_TC, obosc_tm_current->next_TM);\
+ ++obosc_executed_count;\
/*INCREMENT POINTER TO THE LAST NODE*/\
int overflowCountOBinside = 0;\
while( obosc_tm_current->next_TM != NULL ){\
@@ -598,22 +589,24 @@
}\
}\
}\
- obosc_tm_current = obosc_tm_head;\
- while( obosc_tm_current != NULL ){\
- int length = TM_SHORT_SIZE;\
- if( GETshort_or_long_tm(obosc_tm_current->fields) == SHORT_TM_CODE ){\
- length = TM_SHORT_SIZE;\
+ if( obosc_executed_count != 0 ){\
+ obosc_tm_current = obosc_tm_head;\
+ while( obosc_tm_current != NULL ){\
+ int length = TM_SHORT_SIZE;\
+ if( GETshort_or_long_tm(obosc_tm_current->fields) == SHORT_TM_CODE ){\
+ length = TM_SHORT_SIZE;\
+ }\
+ else{\
+ length = TM_LONG_SIZE;\
+ }\
+ for(int i = 0 ; i < length ; ++i){\
+ gPC.putc(obosc_tm_current->TM_string[i]);\
+ }\
+ obosc_tm_current = obosc_tm_current->next_TM;\
}\
- else{\
- length = TM_LONG_SIZE;\
- }\
- for(int i = 0 ; i < length ; ++i){\
- gPC.putc(obosc_tm_current->TM_string[i]);\
- }\
- obosc_tm_current = obosc_tm_current->next_TM;\
+ /*snd_tm.head_pointer(obosc_tm_head);*/\
+ /*adf_not_SDcard();*/\
}\
- /*snd_tm.head_pointer(obosc_tm_head);*/\
- /*adf_not_SDcard();*/\
/*DELETE THE TM AFTER USE*/\
obosc_tm_current = obosc_tm_head;\
int overCount = 0;\
@@ -647,7 +640,7 @@
/*gPC.printf("disabled or completed at %u\n", execute_psc);*/\
break;\
}\
- else if( (current_exec_status == TC_STATE_EXECUTION_FAILED) && (GETabort_on_nack(current_TC) == 1) ){\
+ else if( ((current_exec_status == TC_STATE_EXECUTION_FAILED) || (current_exec_status == TC_STATE_EXECUTION_UNKNOWN)) && (GETabort_on_nack(current_TC) == 1) ){\
/*gPC.printf("abort on nack at %u psc\r\n", execute_psc);*/\
gMASTER_STATE = TCL_STATE_ABORTED;\
break;\
--- a/DefinitionsAndGlobals.h Thu Dec 31 18:35:59 2015 +0000
+++ b/DefinitionsAndGlobals.h Fri Jan 01 06:36:18 2016 +0000
@@ -14,6 +14,8 @@
// COM_TX
#define COM_TX_CONFIG_LIMIT 3
+ #define COM_TX_TICKER_TIME 32
+ /*in millisecond*/
// ADF INTERRUPUT
#define ADF_IRQ PTA14
@@ -21,9 +23,8 @@
// TC LIST
#define TCL_STATE_INCOMPLETE 0x00
#define TCL_STATE_ABORTED 0x03
- #define TCL_STATE_EXECUTING 0x04
+ #define TCL_STATE_EXECUTING 0x04
#define TCL_STATE_COMPLETED 0x05
- #define TCL_STATE_EXCEEDED_LIMIT 0x06
// LIST OF FLAGS
#define UART_INT_FLAG 0x0001
@@ -51,7 +52,6 @@
// call sign
#define PSC_CALLSIGN 0x00
- #define APID_CALLSIGN 0x00
// max value of telecommands in a tcl
#define TCL_OVERFLOW_CONSTANT 256
@@ -61,10 +61,15 @@
#define PSC_START_VALUE 1
// APID list
+ #define APID_COM 0
#define APID_BAE 1
#define APID_CDMS 2
#define APID_SPEED 3
+ // SERVICE
+ #define SERVICE_OBOSC 0xB
+ #define SERVICE_OBSRS 0xF
+
// HIGH PRIORITY TC - priority list
// not correct values here
#define HPTC1 5
@@ -131,7 +136,9 @@
Timeout gRX_TIMEOUT;
Timeout gSESSION_TIMEOUT;
-// COM_MNG_TMTC
+// COM_TX
+ // REFER ADF.H FOR IRQ TICKER
+ InterruptIn gIRQ(ADF_IRQ);
// PA cooling timeout
Timeout gCOM_PA_COOLING_TIMEOUT;
--- a/Structures.h Thu Dec 31 18:35:59 2015 +0000 +++ b/Structures.h Fri Jan 01 06:36:18 2016 +0000 @@ -33,8 +33,9 @@ #define TC_STATE_UNEXECUTED 0x00 #define TC_STATE_SUCCESSFULLY_EXECUTED 0x01 #define TC_STATE_EXECUTION_FAILED 0x02 -#define TC_STATE_DISABLED 0x03 -#define TC_STATE_MARKED_RETRY 0x04 +#define TC_STATE_EXECUTION_UNKNOWN 0x03 +#define TC_STATE_DISABLED 0x04 +#define TC_STATE_MARKED_RETRY 0x05 //MASKS #define SHORT_LONG_TC_MASK 0x10
--- a/ThreadsAndFunctions.h Thu Dec 31 18:35:59 2015 +0000
+++ b/ThreadsAndFunctions.h Fri Jan 01 06:36:18 2016 +0000
@@ -37,10 +37,6 @@
gTOTAL_CRC_FAIL_TC = 0;\
gTOTAL_REPEATED_TC = 0;\
gTOTAL_VALID_TC = 0;\
- for(int i = 0 ; i < TM_LONG_SIZE ; ++i){\
- gLAST_TM[i] = 0x00;\
- }\
- gLAST_TM_SHORT_OR_LONG = SHORT_TM_CODE;\
COM_RX_DATA_NODE *dataptr = gRX_HEAD_DATA_NODE;\
while( dataptr != NULL ){\
COM_RX_DATA_NODE *temp = dataptr->next_node;\
--- a/adf.h Thu Dec 31 18:35:59 2015 +0000
+++ b/adf.h Fri Jan 01 06:36:18 2016 +0000
@@ -1,13 +1,19 @@
//without reset feature , with state checks.
-InterruptIn IRQ(ADF_IRQ);
-Ticker ticker;
+uint8_t signal = 0x00;
+
+void adf_irq_check(void const *n){
+ if(gIRQ){
+ gCOM_MNG_TMTC_THREAD->signal_set(signal);
+ }
+}
+
+RtosTimer gADF_TICKER(adf_irq_check, osTimerPeriodic, (void *)0);
bool sent_tmfrom_SDcard;
bool loop_on;
bool ADF_off;
bool buffer_state;
bool finish_write_data;
-uint8_t signal = 0x00;
unsigned char bbram_buffer[66]={0x19,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x00,0xF4,0xC2,0x10,0xC0,0x00,0x30,0x31,0x07,0x00,0x01,0x00,0x7F,0x00,0x0B,0x37,0x00,0x00,0x40,0x0C,0x00,0x05,0x00,0x00,0x18,0x12,0x34,0x56,0x10,0x10,0xC4,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00};
//int initialise_card();
@@ -418,15 +424,7 @@
finish_write_data = true;\
gPC.puts("adf_off\r\n");\
}\
-}
-
-
-void check(){
- if(IRQ){
- gCOM_MNG_TMTC_THREAD->signal_set(signal);
- }
-}
-
+}
#define send_data {\
if(sent_tmfrom_SDcard){\
@@ -464,7 +462,7 @@
spi.write(0xFF);\
gCS_ADF=1;\
SPI_mutex.unlock();\
- ticker.attach_us(&check,32000);\
+ gADF_TICKER.start(COM_TX_TICKER_TIME);\
}
@@ -486,7 +484,7 @@
gCOM_MNG_TMTC_THREAD->signal_wait(COM_MNG_TMTC_SIGNAL_ADF_SD);\
if(ADF_off){\
SPI_mutex.lock();\
- ticker.detach();\
+ gADF_TICKER.stop();\
gCS_ADF=0;\
spi.write(0xB1);\
gCS_ADF=1;\
@@ -552,7 +550,7 @@
if(finish_write_data){
if(ADF_off){
SPI_mutex.lock();
- ticker.detach();
+ gADF_TICKER.stop();
// wait_ms(35);
gCS_ADF=0;
spi.write(0xB1);
