##// END OF EJS Templates
the interrupt sub routine related to the waveform picker is now lighter...
paul -
r112:5b5da8d2c053 VHDLib206
parent child
Show More
@@ -1,6 +1,6
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.1, 2014-03-28T16:51:27. -->
3 <!-- Written by QtCreator 3.0.1, 2014-03-31T06:56:28. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -106,13 +106,8 typedef struct ring_node
106 106 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
107 107 #define REGS_ADDR_GRGPIO 0x80000b00
108 108
109 #ifdef VHDL_DEV
110 109 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
111 110 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f40
112 #else
113 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
114 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f20
115 #endif
116 111
117 112 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
118 113 #define APBUART_CTRL_REG_MASK_TE 0x00000002
@@ -1,8 +1,6
1 1 #ifndef TM_BYTE_POSITIONS_H
2 2 #define TM_BYTE_POSITIONS_H
3 3
4 #define BYTE_POS_CP_LFR_MODE 11
5
6 4 // TC_LFR_LOAD_COMMON_PAR
7 5
8 6 // TC_LFR_LOAD_NORMAL_PAR
@@ -20,10 +18,11
20 18 // TC_LFR_LOAD_SBM2_PAR
21 19
22 20 // TC_LFR_UPDATE_INFO
23 #define BYTE_POS_HK_UPDATE_INFO_PAR_SET5 24 // 34 - 10
24 #define BYTE_POS_HK_UPDATE_INFO_PAR_SET6 25 // 35 - 10
21 #define BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 34
22 #define BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 35
25 23
26 24 // TC_LFR_ENTER_MODE
27 #define BYTE_POS_CP_LFR_ENTER_MODE_TIME 2 // 12 - 10
25 #define BYTE_POS_CP_MODE_LFR_SET 11
26 #define BYTE_POS_CP_LFR_ENTER_MODE_TIME 12
28 27
29 28 #endif // TM_BYTE_POSITIONS_H
@@ -12,7 +12,7 void GetCRCAsTwoBytes(unsigned char* dat
12 12
13 13 //*********************
14 14 // ACCEPTANCE FUNCTIONS
15 int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int TC_LEN_RCV, unsigned char *computed_CRC);
15 int tc_parser( ccsdsTelecommandPacket_t * TCPacket, unsigned int estimatedPacketLength, unsigned char *computed_CRC );
16 16 int tc_check_type( unsigned char packetType );
17 17 int tc_check_type_subtype( unsigned char packetType, unsigned char packetSubType );
18 18 int tc_check_sid( unsigned char sid );
@@ -14,7 +14,7 int send_tm_lfr_tc_exe_inconsistent( ccs
14 14 unsigned char byte_position, unsigned char rcv_value );
15 15 int send_tm_lfr_tc_exe_not_executable( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
16 16 int send_tm_lfr_tc_exe_not_implemented( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
17 int send_tm_lfr_tc_exe_error( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
17 int send_tm_lfr_tc_exe_error(ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
18 18 int send_tm_lfr_tc_exe_corrupted( ccsdsTelecommandPacket_t *TC, rtems_id queue_id,
19 19 unsigned char *computed_CRC, unsigned char *currentTC_LEN_RCV, unsigned char destinationID );
20 20
@@ -232,7 +232,7 void init_local_mode_parameters( void )
232 232
233 233 void reset_local_time( void )
234 234 {
235
235 time_management_regs->coarse_time_load = 0x80000000;
236 236 }
237 237
238 238 void create_names( void ) // create all names for tasks and queues
@@ -116,7 +116,7 rtems_task recv_task( rtems_task_argumen
116 116 unsigned char computed_CRC[ 2 ];
117 117 unsigned char currentTC_LEN_RCV[ 2 ];
118 118 unsigned char destinationID;
119 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
119 unsigned int estimatedPacketLength;
120 120 unsigned int parserCode;
121 121 rtems_status_code status;
122 122 rtems_id queue_recv_id;
@@ -149,11 +149,11 rtems_task recv_task( rtems_task_argumen
149 149 PRINTF("in RECV *** packet lenght too short\n")
150 150 }
151 151 else {
152 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
153 currentTC_LEN_RCV[ 0 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt >> 8);
154 currentTC_LEN_RCV[ 1 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt );
152 estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
153 currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8);
154 currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength );
155 155 // CHECK THE TC
156 parserCode = tc_parser( &currentTC, currentTC_LEN_RCV_AsUnsignedInt, computed_CRC ) ;
156 parserCode = tc_parser( &currentTC, estimatedPacketLength, computed_CRC ) ;
157 157 if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT)
158 158 || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE)
159 159 || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA)
@@ -181,7 +181,7 rtems_task recv_task( rtems_task_argumen
181 181 else
182 182 { // send valid TC to the action launcher
183 183 status = rtems_message_queue_send( queue_recv_id, &currentTC,
184 currentTC_LEN_RCV_AsUnsignedInt + CCSDS_TC_TM_PACKET_OFFSET + 3);
184 estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3);
185 185 }
186 186 }
187 187 }
@@ -93,12 +93,12 void GetCRCAsTwoBytes(unsigned char* dat
93 93
94 94 //*********************
95 95 // ACCEPTANCE FUNCTIONS
96 int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int TC_LEN_RCV, unsigned char *computed_CRC)
96 int tc_parser(ccsdsTelecommandPacket_t * TCPacket, unsigned int estimatedPacketLength, unsigned char *computed_CRC)
97 97 {
98 98 /** This function parses TeleCommands.
99 99 *
100 100 * @param TC points to the TeleCommand that will be parsed.
101 * @param TC_LEN_RCV is the received packet length.
101 * @param estimatedPacketLength is the PACKET_LENGTH field calculated from the effective length of the received packet.
102 102 *
103 103 * @return Status code of the parsing.
104 104 *
@@ -116,7 +116,7 int tc_parser(ccsdsTelecommandPacket_t *
116 116 int status_crc;
117 117 unsigned char pid;
118 118 unsigned char category;
119 unsigned int length;
119 unsigned int packetLength;
120 120 unsigned char packetType;
121 121 unsigned char packetSubtype;
122 122 unsigned char sid;
@@ -126,7 +126,7 int tc_parser(ccsdsTelecommandPacket_t *
126 126 // APID check *** APID on 2 bytes
127 127 pid = ((TCPacket->packetID[0] & 0x07)<<4) + ( (TCPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx
128 128 category = (TCPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210
129 length = (TCPacket->packetLength[0] * 256) + TCPacket->packetLength[1];
129 packetLength = (TCPacket->packetLength[0] * 256) + TCPacket->packetLength[1];
130 130 packetType = TCPacket->serviceType;
131 131 packetSubtype = TCPacket->serviceSubType;
132 132 sid = TCPacket->sourceID;
@@ -142,15 +142,15 int tc_parser(ccsdsTelecommandPacket_t *
142 142 status = ILLEGAL_APID;
143 143 }
144 144 }
145 if (status == CCSDS_TM_VALID) // CHECK THE PACKET LENGTH FIELD AND THE ACTUAL LENGTH COMPLIANCE
145 if (status == CCSDS_TM_VALID) // CHECK THE PACKET_LENGTH FIELD AND THE ESTIMATED PACKET_LENGTH COMPLIANCE
146 146 {
147 if (length != TC_LEN_RCV ) {
147 if (packetLength != estimatedPacketLength ) {
148 148 status = WRONG_LEN_PKT;
149 149 }
150 150 }
151 151 if (status == CCSDS_TM_VALID) // CHECK THAT THE PACKET DOES NOT EXCEED THE MAX SIZE
152 152 {
153 if ( length >= CCSDS_TC_PKT_MAX_SIZE ) {
153 if ( packetLength >= CCSDS_TC_PKT_MAX_SIZE ) {
154 154 status = WRONG_LEN_PKT;
155 155 }
156 156 }
@@ -168,9 +168,9 int tc_parser(ccsdsTelecommandPacket_t *
168 168 }
169 169 if (status == CCSDS_TM_VALID) // CHECK THE SUBTYPE AND LENGTH COMPLIANCE
170 170 {
171 status = tc_check_length( packetSubtype, length );
171 status = tc_check_length( packetSubtype, packetLength );
172 172 }
173 status_crc = tc_check_crc( TCPacket, length, computed_CRC );
173 status_crc = tc_check_crc( TCPacket, estimatedPacketLength, computed_CRC );
174 174 if (status == CCSDS_TM_VALID ) // CHECK CRC
175 175 {
176 176 status = status_crc;
@@ -162,16 +162,19 int action_enter_mode(ccsdsTelecommandPa
162 162 unsigned char requestedMode;
163 163 unsigned int *transitionCoarseTime_ptr;
164 164 unsigned int transitionCoarseTime;
165 unsigned char * bytePosPtr;
165 166
166 requestedMode = TC->dataAndCRC[1];
167 transitionCoarseTime_ptr = (unsigned int *) (&TC->dataAndCRC[BYTE_POS_CP_LFR_ENTER_MODE_TIME]);
167 bytePosPtr = (unsigned char *) &TC->packetID;
168
169 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
170 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
168 171 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
169 172
170 173 status = check_mode_value( requestedMode );
171 174
172 if ( status != LFR_SUCCESSFUL )
175 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
173 176 {
174 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode );
177 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
175 178 }
176 179 else // the mode value is consistent, check the transition
177 180 {
@@ -189,7 +192,9 int action_enter_mode(ccsdsTelecommandPa
189 192 if (status != LFR_SUCCESSFUL)
190 193 {
191 194 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n")
192 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
195 send_tm_lfr_tc_exe_inconsistent( TC, queue_id,
196 BYTE_POS_CP_LFR_ENTER_MODE_TIME,
197 bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] );
193 198 }
194 199 }
195 200
@@ -219,18 +224,21 int action_update_info(ccsdsTelecommandP
219 224 int result;
220 225 unsigned int status;
221 226 unsigned char mode;
227 unsigned char * bytePosPtr;
228
229 bytePosPtr = (unsigned char *) &TC->packetID;
222 230
223 231 // check LFR mode
224 mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET5 ] & 0x1e) >> 1;
232 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
225 233 status = check_update_info_hk_lfr_mode( mode );
226 234 if (status == LFR_SUCCESSFUL) // check TDS mode
227 235 {
228 mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET6 ] & 0xf0) >> 4;
236 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
229 237 status = check_update_info_hk_tds_mode( mode );
230 238 }
231 239 if (status == LFR_SUCCESSFUL) // check THR mode
232 240 {
233 mode = (TC->dataAndCRC[ BYTE_POS_HK_UPDATE_INFO_PAR_SET6 ] & 0x0f);
241 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
234 242 status = check_update_info_hk_thr_mode( mode );
235 243 }
236 244 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
@@ -420,7 +428,7 int check_transition_date( unsigned int
420 428 {
421 429 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
422 430
423 if ( transitionCoarseTime < localCoarseTime ) // SSS-CP-EQS-322
431 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
424 432 {
425 433 status = LFR_DEFAULT;
426 434 PRINTF2("ERR *** in check_transition_date *** transition = %x, local = %x\n", transitionCoarseTime, localCoarseTime)
@@ -840,6 +848,10 void close_action(ccsdsTelecommandPacket
840 848 updateLFRCurrentMode();
841 849 }
842 850 }
851 else
852 {
853 send_tm_lfr_tc_exe_error( TC, queue_id );
854 }
843 855 }
844 856
845 857 //***************************
@@ -164,7 +164,7 int action_load_sbm1_par(ccsdsTelecomman
164 164 result = LFR_DEFAULT;
165 165 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
166 166
167 if ( (lfrMode == LFR_MODE_SBM1) || (lfrMode == LFR_MODE_SBM2) ) {
167 if ( lfrMode == LFR_MODE_SBM1 ) {
168 168 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
169 169 result = LFR_DEFAULT;
170 170 }
@@ -194,7 +194,7 int action_load_sbm2_par(ccsdsTelecomman
194 194 result = LFR_DEFAULT;
195 195 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
196 196
197 if ( (lfrMode == LFR_MODE_SBM1) || (lfrMode == LFR_MODE_SBM2) ) {
197 if ( lfrMode == LFR_MODE_SBM2 ) {
198 198 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
199 199 result = LFR_DEFAULT;
200 200 }
@@ -282,7 +282,7 int send_tm_lfr_tc_exe_not_implemented(
282 282 return status;
283 283 }
284 284
285 int send_tm_lfr_tc_exe_error( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time )
285 int send_tm_lfr_tc_exe_error( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
286 286 {
287 287 /** This function sends a TM_LFR_TC_EXE_ERROR packet in the dedicated RTEMS message queue.
288 288 *
@@ -154,33 +154,13 rtems_isr waveforms_isr( rtems_vector_nu
154 154 // SBM1
155 155 case(LFR_MODE_SBM1):
156 156 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
157 // (0) launch snapshot extraction if needed
158 if (extractSWF == true)
159 {
160 ring_node_to_send_swf_f1 = current_ring_node_f1;
161 // extract the snapshot
162 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 );
163 extractSWF = false;
164 swf_f1_ready = true;
165 }
166 157 // (1) change the receiving buffer for the waveform picker
167 158 ring_node_to_send_cwf_f1 = current_ring_node_f1;
168 159 current_ring_node_f1 = current_ring_node_f1->next;
169 160 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
170 // (2) send an event for the the CWF1 task for transmission
161 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
171 162 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 );
172 163 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0
173 if (swf_f0_ready == true)
174 {
175 extractSWF = true;
176 swf_f0_ready = false;
177 }
178 if ((swf_f1_ready == true) && (swf_f2_ready == true))
179 {
180 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 );
181 swf_f1_ready = false;
182 swf_f2_ready = false;
183 }
184 164 }
185 165 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
186 166 swf_f0_ready = true;
@@ -196,16 +176,6 rtems_isr waveforms_isr( rtems_vector_nu
196 176 // SBM2
197 177 case(LFR_MODE_SBM2):
198 178 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
199 // (0) launch snapshot extraction if needed
200 if (extractSWF == true)
201 {
202 ring_node_to_send_swf_f2 = current_ring_node_f2;
203 // extract the snapshot
204 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM2 );
205 // send the snapshot when build, SWBD priority < WFRM priority
206 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
207 extractSWF = false;
208 }
209 179 // (1) change the receiving buffer for the waveform picker
210 180 ring_node_to_send_cwf_f2 = current_ring_node_f2;
211 181 current_ring_node_f2 = current_ring_node_f2->next;
@@ -213,13 +183,6 rtems_isr waveforms_isr( rtems_vector_nu
213 183 // (2) send an event for the waveforms transmission
214 184 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 );
215 185 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
216 // (3) check whether swf_fo and swf_f& are ready or not
217 if (swf_f0_ready && swf_f1_ready)
218 {
219 extractSWF = true;
220 swf_f0_ready = false;
221 swf_f1_ready = false;
222 }
223 186 }
224 187 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
225 188 swf_f0_ready = true;
@@ -402,6 +365,22 rtems_task cwf2_task(rtems_task_argument
402 365 if (event_out == RTEMS_EVENT_MODE_SBM2)
403 366 {
404 367 send_waveform_CWF( (volatile int *) ring_node_to_send_cwf_f2->buffer_address, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
368 // launch snapshot extraction if needed
369 if (extractSWF == true)
370 {
371 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
372 // extract the snapshot
373 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 );
374 // send the snapshot when built
375 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
376 extractSWF = false;
377 }
378 if (swf_f0_ready && swf_f1_ready)
379 {
380 extractSWF = true;
381 swf_f0_ready = false;
382 swf_f1_ready = false;
383 }
405 384 }
406 385 }
407 386 }
@@ -436,6 +415,25 rtems_task cwf1_task(rtems_task_argument
436 415 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
437 416 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
438 417 send_waveform_CWF( (volatile int*) ring_node_to_send_cwf_f1->buffer_address, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
418 // launch snapshot extraction if needed
419 if (extractSWF == true)
420 {
421 ring_node_to_send_swf_f1 = ring_node_to_send_cwf_f1;
422 // launch the snapshot extraction
423 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 );
424 extractSWF = false;
425 }
426 if (swf_f0_ready == true)
427 {
428 extractSWF = true;
429 swf_f0_ready = false; // this step shall be executed only one time
430 }
431 if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction
432 {
433 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 );
434 swf_f1_ready = false;
435 swf_f2_ready = false;
436 }
439 437 }
440 438 }
441 439
@@ -458,10 +456,7 rtems_task swbd_task(rtems_task_argument
458 456 if (event_out == RTEMS_EVENT_MODE_SBM1)
459 457 {
460 458 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 );
461 }
462 else if (event_out == RTEMS_EVENT_MODE_SBM2)
463 {
464 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 );
459 swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent
465 460 }
466 461 else
467 462 {
General Comments 0
You need to be logged in to leave comments. Login now