##// END OF EJS Templates
AVGV modified...
paul -
r352:c07c16776bd4 R3++ draft
parent child
Show More
@@ -1,2 +1,2
1 1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
2 e01ac8bd125a79a7af38b0e3ba0330f5be1a3c92 header/lfr_common_headers
2 7ee7da2ed42fbc9cd673ae7f3a865345cea0f83f header/lfr_common_headers
@@ -175,12 +175,9 typedef struct{
175 175 //
176 176 unsigned int buffer_length; // 0x8c = buffer length in burst 2688 / 16 = 168
177 177 //
178 volatile int16_t v_dummy; // 0x90
179 volatile int16_t v; // 0x90
180 volatile int16_t e1_dummy; // 0x94
181 volatile int16_t e1; // 0x94
182 volatile int16_t e2_dummy; // 0x98
183 volatile int16_t e2; // 0x98
178 volatile int v; // 0x90
179 volatile int e1; // 0x94
180 volatile int e2; // 0x98
184 181 } waveform_picker_regs_0_1_18_t;
185 182
186 183 //*********************
@@ -93,6 +93,8 unsigned int check_update_info_hk_tds_mo
93 93 unsigned int check_update_info_hk_thr_mode( unsigned char mode );
94 94 void set_hk_lfr_sc_rw_f_flag( unsigned char wheel, unsigned char freq, float value );
95 95 void set_hk_lfr_sc_rw_f_flags( void );
96 int check_sy_lfr_rw_f( ccsdsTelecommandPacket_t *TC, int offset, int* pos, float* value );
97 int check_all_sy_lfr_rw_f( ccsdsTelecommandPacket_t *TC, int *pos, float*value );
96 98 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC );
97 99 void setFBinMask(unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, float sy_lfr_rw_k );
98 100 void build_sy_lfr_rw_mask( unsigned int channel );
@@ -80,12 +80,12 unsigned char hk_lfr_q_p0_fifo_size_max
80 80 unsigned char hk_lfr_q_p1_fifo_size_max = 0;
81 81 unsigned char hk_lfr_q_p2_fifo_size_max = 0;
82 82 // sequence counters are incremented by APID (PID + CAT) and destination ID
83 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST = 0;
84 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2 = 0;
85 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID] = {0};
86 unsigned short sequenceCounters_TM_DUMP[SEQ_CNT_NB_DEST_ID] = {0};
87 unsigned short sequenceCounterHK = {0};
88 spw_stats grspw_stats = {0};
83 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST __attribute__((aligned(0x4))) = 0;
84 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2 __attribute__((aligned(0x4))) = 0;
85 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID] __attribute__((aligned(0x4))) = {0};
86 unsigned short sequenceCounters_TM_DUMP[SEQ_CNT_NB_DEST_ID] __attribute__((aligned(0x4))) = {0};
87 unsigned short sequenceCounterHK __attribute__((aligned(0x4))) = {0};
88 spw_stats grspw_stats __attribute__((aligned(0x4))) = {0};
89 89
90 90 // TC_LFR_UPDATE_INFO
91 91 rw_f_t rw_f;
@@ -34,8 +34,8
34 34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
35 35 #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
36 36 #define CONFIGURE_MAXIMUM_DRIVERS 16
37 #define CONFIGURE_MAXIMUM_PERIODS 5 // [hous] [load] [avgv]
38 #define CONFIGURE_MAXIMUM_TIMERS 5 // [spiq] [link] [spacewire_reset_link]
37 #define CONFIGURE_MAXIMUM_PERIODS 6 // [hous] [load] [avgv]
38 #define CONFIGURE_MAXIMUM_TIMERS 6 // [spiq] [link] [spacewire_reset_link]
39 39 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
40 40 #ifdef PRINT_STACK_REPORT
41 41 #define CONFIGURE_STACK_CHECKER_ENABLED
@@ -347,6 +347,24 rtems_task hous_task(rtems_task_argument
347 347 return;
348 348 }
349 349
350 int32_t getIntFromShort( int reg )
351 {
352 int16_t ret_as_int16;
353 int32_t ret_as_int32;
354 char *regPtr;
355 char *ret_as_int16_ptr;
356
357 regPtr = (char*) ®
358 ret_as_int16_ptr = (char*) &ret_as_int16;
359
360 ret_as_int16_ptr[BYTE_0] = regPtr[BYTE_3];
361 ret_as_int16_ptr[BYTE_1] = regPtr[BYTE_4];
362
363 ret_as_int32 = (int32_t) ret_as_int16;
364
365 return ret_as_int32;
366 }
367
350 368 rtems_task avgv_task(rtems_task_argument argument)
351 369 {
352 370 #define MOVING_AVERAGE 16
@@ -401,9 +419,9 rtems_task avgv_task(rtems_task_argument
401 419 else
402 420 {
403 421 // get new values
404 newValue_v = (int32_t) waveform_picker_regs->v;
405 newValue_e1 = (int32_t) waveform_picker_regs->e1;
406 newValue_e2 = (int32_t) waveform_picker_regs->e2;
422 newValue_v = getIntFromShort( waveform_picker_regs->v );
423 newValue_e1 = getIntFromShort( waveform_picker_regs->e1 );
424 newValue_e2 = getIntFromShort( waveform_picker_regs->e2 );
407 425
408 426 // compute the moving average
409 427 average_v = average_v + newValue_v - v[k];
@@ -764,6 +764,7 unsigned char acquisitionTimeIsValid( un
764 764 + offsetInFineTime
765 765 + shiftInFineTime
766 766 - acquisitionDurations[channel];
767
767 768 acquisitionTimeRangeMax =
768 769 timecodeReference
769 770 + offsetInFineTime
@@ -256,10 +256,16 int action_update_info(ccsdsTelecommandP
256 256 */
257 257
258 258 unsigned int val;
259 int result;
260 259 unsigned int status;
261 260 unsigned char mode;
262 261 unsigned char * bytePosPtr;
262 int pos;
263 float value;
264
265 pos = INIT_CHAR;
266 value = INIT_FLOAT;
267
268 status = LFR_DEFAULT;
263 269
264 270 bytePosPtr = (unsigned char *) &TC->packetID;
265 271
@@ -276,37 +282,45 int action_update_info(ccsdsTelecommandP
276 282 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & BITS_THR_MODE);
277 283 status = check_update_info_hk_thr_mode( mode );
278 284 }
279 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
285 if (status == LFR_SUCCESSFUL) // check reaction wheels frequencies
280 286 {
281 val = (housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * CONST_256)
282 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
283 val++;
284 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE);
285 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
287 status = check_all_sy_lfr_rw_f(TC, &pos, &value);
286 288 }
287 289
288 // pa_bia_status_info
289 // => pa_bia_mode_mux_set 3 bits
290 // => pa_bia_mode_hv_enabled 1 bit
291 // => pa_bia_mode_bias1_enabled 1 bit
292 // => pa_bia_mode_bias2_enabled 1 bit
293 // => pa_bia_mode_bias3_enabled 1 bit
294 // => pa_bia_on_off (cp_dpu_bias_on_off)
295 pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & BITS_BIA; // [1111 1110]
296 pa_bia_status_info = pa_bia_status_info
297 | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 1);
290 // if the parameters checking succeeds, udpate all parameters
291 if (status == LFR_SUCCESSFUL)
292 {
293 // pa_bia_status_info
294 // => pa_bia_mode_mux_set 3 bits
295 // => pa_bia_mode_hv_enabled 1 bit
296 // => pa_bia_mode_bias1_enabled 1 bit
297 // => pa_bia_mode_bias2_enabled 1 bit
298 // => pa_bia_mode_bias3_enabled 1 bit
299 // => pa_bia_on_off (cp_dpu_bias_on_off)
300 pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & BITS_BIA; // [1111 1110]
301 pa_bia_status_info = pa_bia_status_info
302 | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 1);
298 303
299 // REACTION_WHEELS_FREQUENCY, copy the incoming parameters in the local variable (to be copied in HK packets)
300 getReactionWheelsFrequencies( TC );
301 set_hk_lfr_sc_rw_f_flags();
302 build_sy_lfr_rw_masks();
304 // REACTION_WHEELS_FREQUENCY, copy the incoming parameters in the local variable (to be copied in HK packets)
305 getReactionWheelsFrequencies( TC );
306 set_hk_lfr_sc_rw_f_flags();
307 build_sy_lfr_rw_masks();
308
309 // once the masks are built, they have to be merged with the fbins_mask
310 merge_fbins_masks();
303 311
304 // once the masks are built, they have to be merged with the fbins_mask
305 merge_fbins_masks();
312 // increase the TC_LFR_UPDATE_INFO counter
313 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
314 {
315 val = (housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * CONST_256)
316 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
317 val++;
318 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE);
319 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
320 }
321 }
306 322
307 result = status;
308
309 return result;
323 return status;
310 324 }
311 325
312 326 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
@@ -791,6 +791,7 int set_sy_lfr_n_cwf_long_f3(ccsdsTeleco
791 791
792 792 //**********************
793 793 // BURST MODE PARAMETERS
794
794 795 int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC)
795 796 {
796 797 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0).
@@ -829,6 +830,7 int set_sy_lfr_b_bp_p1( ccsdsTelecommand
829 830
830 831 //*********************
831 832 // SBM1 MODE PARAMETERS
833
832 834 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC )
833 835 {
834 836 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0).
@@ -867,6 +869,7 int set_sy_lfr_s1_bp_p1( ccsdsTelecomman
867 869
868 870 //*********************
869 871 // SBM2 MODE PARAMETERS
872
870 873 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC )
871 874 {
872 875 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0).
@@ -905,6 +908,7 int set_sy_lfr_s2_bp_p1( ccsdsTelecomman
905 908
906 909 //*******************
907 910 // TC_LFR_UPDATE_INFO
911
908 912 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
909 913 {
910 914 unsigned int status;
@@ -1040,6 +1044,113 void set_hk_lfr_sc_rw_f_flags( void )
1040 1044 set_hk_lfr_sc_rw_f_flag( WHEEL_4, FREQ_4, rw_f.cp_rpw_sc_rw4_f4 );
1041 1045 }
1042 1046
1047 int check_sy_lfr_rw_f( ccsdsTelecommandPacket_t *TC, int offset, int* pos, float* value )
1048 {
1049 float rw_k;
1050 int ret;
1051
1052 ret = LFR_SUCCESSFUL;
1053 rw_k = INIT_FLOAT;
1054
1055 copyFloatByChar( (unsigned char*) &rw_k, (unsigned char*) &TC->packetID[ offset ] );
1056
1057 *pos = offset;
1058 *value = rw_k;
1059
1060 if (rw_k < MIN_SY_LFR_RW_F)
1061 {
1062 ret = WRONG_APP_DATA;
1063 }
1064
1065 return ret;
1066 }
1067
1068 int check_all_sy_lfr_rw_f( ccsdsTelecommandPacket_t *TC, int *pos, float*value )
1069 {
1070 int ret;
1071
1072 ret = LFR_SUCCESSFUL;
1073
1074 //****
1075 //****
1076 // RW1
1077 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1, pos, value ); // F1
1078 if (ret == LFR_SUCCESSFUL) // F2
1079 {
1080 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2, pos, value );
1081 }
1082 if (ret == LFR_SUCCESSFUL) // F3
1083 {
1084 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F3, pos, value );
1085 }
1086 if (ret == LFR_SUCCESSFUL) // F4
1087 {
1088 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F4, pos, value );
1089 }
1090
1091 //****
1092 //****
1093 // RW2
1094 if (ret == LFR_SUCCESSFUL) // F1
1095 {
1096 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1, pos, value );
1097 }
1098 if (ret == LFR_SUCCESSFUL) // F2
1099 {
1100 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2, pos, value );
1101 }
1102 if (ret == LFR_SUCCESSFUL) // F3
1103 {
1104 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F3, pos, value );
1105 }
1106 if (ret == LFR_SUCCESSFUL) // F4
1107 {
1108 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F4, pos, value );
1109 }
1110
1111 //****
1112 //****
1113 // RW3
1114 if (ret == LFR_SUCCESSFUL) // F1
1115 {
1116 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1, pos, value );
1117 }
1118 if (ret == LFR_SUCCESSFUL) // F2
1119 {
1120 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2, pos, value );
1121 }
1122 if (ret == LFR_SUCCESSFUL) // F3
1123 {
1124 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F3, pos, value );
1125 }
1126 if (ret == LFR_SUCCESSFUL) // F4
1127 {
1128 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F4, pos, value );
1129 }
1130
1131 //****
1132 //****
1133 // RW4
1134 if (ret == LFR_SUCCESSFUL) // F1
1135 {
1136 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1, pos, value );
1137 }
1138 if (ret == LFR_SUCCESSFUL) // F2
1139 {
1140 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2, pos, value );
1141 }
1142 if (ret == LFR_SUCCESSFUL) // F3
1143 {
1144 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F3, pos, value );
1145 }
1146 if (ret == LFR_SUCCESSFUL) // F4
1147 {
1148 ret = check_sy_lfr_rw_f( TC, BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F4, pos, value );
1149 }
1150
1151 return ret;
1152 }
1153
1043 1154 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC )
1044 1155 {
1045 1156 /** This function get the reaction wheels frequencies in the incoming TC_LFR_UPDATE_INFO and copy the values locally.
@@ -1345,7 +1456,7 int check_sy_lfr_rw_k( ccsdsTelecommandP
1345 1456 *pos = offset;
1346 1457 *value = rw_k;
1347 1458
1348 if (rw_k < MIN_SY_LFR_RW_K)
1459 if (rw_k < MIN_SY_LFR_RW_F)
1349 1460 {
1350 1461 ret = WRONG_APP_DATA;
1351 1462 }
@@ -1353,7 +1464,7 int check_sy_lfr_rw_k( ccsdsTelecommandP
1353 1464 return ret;
1354 1465 }
1355 1466
1356 int check_all_sy_lfr_rw_k( ccsdsTelecommandPacket_t *TC, int *pos, float*value )
1467 int check_all_sy_lfr_rw_k( ccsdsTelecommandPacket_t *TC, int *pos, float *value )
1357 1468 {
1358 1469 int ret;
1359 1470
@@ -1436,8 +1547,6 int check_all_sy_lfr_rw_k( ccsdsTelecomm
1436 1547 ret = check_sy_lfr_rw_k( TC, DATAFIELD_POS_SY_LFR_RW4_K4, pos, value );
1437 1548 }
1438 1549
1439
1440
1441 1550 return ret;
1442 1551 }
1443 1552
@@ -1453,19 +1562,16 int check_sy_lfr_filter_parameters( ccsd
1453 1562 float sy_lfr_pas_filter_shift;
1454 1563 float sy_lfr_sc_rw_delta_f;
1455 1564 char *parPtr;
1456 int *datafield_pos;
1457 float *rw_k;
1565 int datafield_pos;
1566 float rw_k;
1458 1567
1459 1568 flag = LFR_SUCCESSFUL;
1460 1569 sy_lfr_pas_filter_tbad = INIT_FLOAT;
1461 1570 sy_lfr_pas_filter_shift = INIT_FLOAT;
1462 1571 sy_lfr_sc_rw_delta_f = INIT_FLOAT;
1463 1572 parPtr = NULL;
1464 datafield_pos = NULL;
1465 rw_k = NULL;
1466
1467 *datafield_pos = LFR_DEFAULT_ALT;
1468 *rw_k = INIT_FLOAT;
1573 datafield_pos = INIT_INT;
1574 rw_k = INIT_FLOAT;
1469 1575
1470 1576 //***************
1471 1577 // get parameters
@@ -1502,11 +1608,14 int check_sy_lfr_filter_parameters( ccsd
1502 1608
1503 1609 //***********************
1504 1610 // sy_lfr_pas_filter_tbad
1505 if ( (sy_lfr_pas_filter_tbad < MIN_PAS_FILTER_TBAD) || (sy_lfr_pas_filter_tbad > MAX_PAS_FILTER_TBAD) )
1611 if (flag == LFR_SUCCESSFUL)
1506 1612 {
1507 parPtr = (char*) &sy_lfr_pas_filter_tbad;
1508 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] );
1509 flag = WRONG_APP_DATA;
1613 if ( (sy_lfr_pas_filter_tbad < MIN_PAS_FILTER_TBAD) || (sy_lfr_pas_filter_tbad > MAX_PAS_FILTER_TBAD) )
1614 {
1615 parPtr = (char*) &sy_lfr_pas_filter_tbad;
1616 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] );
1617 flag = WRONG_APP_DATA;
1618 }
1510 1619 }
1511 1620
1512 1621 //*************************
@@ -1549,6 +1658,7 int check_sy_lfr_filter_parameters( ccsd
1549 1658 {
1550 1659 if ( sy_lfr_sc_rw_delta_f < MIN_SY_LFR_SC_RW_DELTA_F )
1551 1660 {
1661 parPtr = (char*) &sy_lfr_pas_filter_shift;
1552 1662 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + DATAFIELD_OFFSET, sy_lfr_sc_rw_delta_f );
1553 1663 flag = WRONG_APP_DATA;
1554 1664 }
@@ -1558,14 +1668,14 int check_sy_lfr_filter_parameters( ccsd
1558 1668 // sy_lfr_rw_k
1559 1669 if (flag == LFR_SUCCESSFUL)
1560 1670 {
1561 flag = check_all_sy_lfr_rw_k( TC, datafield_pos, rw_k );
1671 flag = check_all_sy_lfr_rw_k( TC, &datafield_pos, &rw_k );
1562 1672 if (flag != LFR_SUCCESSFUL)
1563 1673 {
1564 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, *datafield_pos + DATAFIELD_OFFSET, *rw_k );
1674 parPtr = (char*) &sy_lfr_pas_filter_shift;
1675 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, datafield_pos + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] );
1565 1676 }
1566 1677 }
1567 1678
1568
1569 1679 return flag;
1570 1680 }
1571 1681
General Comments 0
You need to be logged in to leave comments. Login now