##// END OF EJS Templates
Many corrections, mainly related to 807 Don_Enumeration
paul -
r318:d3701d39af11 R3_plus draft
parent child
Show More
@@ -1,2 +1,2
1 1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
2 3e4216a0e6981bead8bcb201012ebadb53f60dff header/lfr_common_headers
2 6bab694410c69700e3455ffba21ce58dbb4da870 header/lfr_common_headers
@@ -10,6 +10,30
10 10 #include "fsw_spacewire.h"
11 11 #include "lfr_cpu_usage_report.h"
12 12
13 #define LFR_RESET_CAUSE_UNKNOWN_CAUSE 0
14 #define WATCHDOG_LOOP_PRINTF 10
15 #define WATCHDOG_LOOP_DEBUG 3
16
17 #define DUMB_MESSAGE_NB 15
18 #define NB_RTEMS_EVENTS 32
19 #define EVENT_12 12
20 #define EVENT_13 13
21 #define EVENT_14 14
22 #define DUMB_MESSAGE_0 "in DUMB *** default"
23 #define DUMB_MESSAGE_1 "in DUMB *** timecode_irq_handler"
24 #define DUMB_MESSAGE_2 "in DUMB *** f3 buffer changed"
25 #define DUMB_MESSAGE_3 "in DUMB *** in SMIQ *** Error sending event to AVF0"
26 #define DUMB_MESSAGE_4 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ"
27 #define DUMB_MESSAGE_5 "in DUMB *** waveforms_simulator_isr"
28 #define DUMB_MESSAGE_6 "VHDL SM *** two buffers f0 ready"
29 #define DUMB_MESSAGE_7 "ready for dump"
30 #define DUMB_MESSAGE_8 "VHDL ERR *** spectral matrix"
31 #define DUMB_MESSAGE_9 "tick"
32 #define DUMB_MESSAGE_10 "VHDL ERR *** waveform picker"
33 #define DUMB_MESSAGE_11 "VHDL ERR *** unexpected ready matrix values"
34 #define DUMB_MESSAGE_12 "WATCHDOG timer"
35 #define DUMB_MESSAGE_13 "TIMECODE timer"
36 #define DUMB_MESSAGE_14 "TIMECODE ISR"
13 37
14 38 enum lfr_reset_cause_t{
15 39 UNKNOWN_CAUSE,
@@ -46,8 +70,6 extern gptimer_regs_t *gptimer_regs;
46 70 extern void ASR16_get_FPRF_IURF_ErrorCounters( unsigned int*, unsigned int* );
47 71 extern void CCR_getInstructionAndDataErrorCounters( unsigned int*, unsigned int* );
48 72
49 #define LFR_RESET_CAUSE_UNKNOWN_CAUSE 0
50
51 73 rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic
52 74 rtems_id HK_id; // id of the HK rate monotonic period
53 75 rtems_name name_avgv_rate_monotonic; // name of the AVGV rate monotonic
@@ -13,6 +13,15
13 13 #include "tc_handler.h"
14 14 #include "fsw_init.h"
15 15
16 #define SPW_LINK_OK 5
17 #define CONF_TCODE_CTRL 0x0909 // [Time Rx : Time Tx : Link error : Tick-out IRQ]
18 #define SPW_BIT_NP 0x00100000 // [NP] set the No port force bit
19 #define SPW_BIT_NP_MASK 0xffdfffff
20 #define SPW_BIT_RE 0x00010000 // [RE] set the RMAP Enable bit
21 #define SPW_BIT_RE_MASK 0xfffdffff
22 #define SPW_LINK_STAT_POS 21
23 #define SPW_TIMECODE_MAX 63
24
16 25 extern spw_stats grspw_stats;
17 26 extern rtems_name timecode_timer_name;
18 27 extern rtems_id timecode_timer_id;
@@ -30,6 +30,18 typedef struct {
30 30 volatile unsigned int unused;
31 31 } timer_regs_t;
32 32
33 //*************
34 //*************
35 // GPTIMER_REGS
36
37 #define GPTIMER_CLEAR_IRQ 0x00000010 // clear pending IRQ if any
38 #define GPTIMER_LD 0x00000004 // LD load value from the reload register
39 #define GPTIMER_EN 0x00000001 // EN enable the timer
40 #define GPTIMER_EN_MASK 0xfffffffe // EN enable the timer
41 #define GPTIMER_RS 0x00000002 // RS restart
42 #define GPTIMER_IE 0x00000008 // IE interrupt enable
43 #define GPTIMER_IE_MASK 0xffffffef // IE interrupt enable
44
33 45 typedef struct {
34 46 volatile unsigned int scaler_value;
35 47 volatile unsigned int scaler_reload;
@@ -38,6 +50,25 typedef struct {
38 50 timer_regs_t timer[NB_GPTIMER];
39 51 } gptimer_regs_t;
40 52
53 //*********************
54 //*********************
55 // TIME_MANAGEMENT_REGS
56
57 #define VAL_SOFTWARE_RESET 0x02 // [0010] software reset
58 #define VAL_LFR_SYNCHRONIZED 0x80000000
59 #define BIT_SYNCHRONIZATION 31
60 #define COARSE_TIME_MASK 0x7fffffff
61 #define SYNC_BIT_MASK 0x7f
62 #define SYNC_BIT 0x80
63 #define BIT_CAL_RELOAD 0x00000010
64 #define MASK_CAL_RELOAD 0xffffffef // [1110 1111]
65 #define BIT_CAL_ENABLE 0x00000040
66 #define MASK_CAL_ENABLE 0xffffffbf // [1011 1111]
67 #define BIT_SET_INTERLEAVED 0x00000020 // [0010 0000]
68 #define MASK_SET_INTERLEAVED 0xffffffdf // [1101 1111]
69 #define BIT_SOFT_RESET 0x00000004 // [0100]
70 #define MASK_SOFT_RESET 0xfffffffb // [1011]
71
41 72 typedef struct {
42 73 volatile int ctrl; // bit 0 forces the load of the coarse_time_load value and resets the fine_time
43 74 // bit 1 is the soft reset for the time management module
@@ -57,6 +88,45 typedef struct {
57 88 volatile unsigned int calData;
58 89 } time_management_regs_t;
59 90
91 //*********************
92 //*********************
93 // WAVEFORM_PICKER_REGS
94
95 #define BITS_WFP_STATUS_F3 0xc0 // [1100 0000] check the f3 full bits
96 #define BIT_WFP_BUF_F3_0 0x40 // [0100 0000] f3 buffer 0 is full
97 #define BIT_WFP_BUF_F3_1 0x80 // [1000 0000] f3 buffer 1 is full
98 #define RST_WFP_F3_0 0x00008840 // [1000 1000 0100 0000]
99 #define RST_WFP_F3_1 0x00008880 // [1000 1000 1000 0000]
100
101 #define BITS_WFP_STATUS_F2 0x30 // [0011 0000] get the status bits for f2
102 #define SHIFT_WFP_STATUS_F2 4
103 #define BIT_WFP_BUF_F2_0 0x10 // [0001 0000] f2 buffer 0 is full
104 #define BIT_WFP_BUF_F2_1 0x20 // [0010 0000] f2 buffer 1 is full
105 #define RST_WFP_F2_0 0x00004410 // [0100 0100 0001 0000]
106 #define RST_WFP_F2_1 0x00004420 // [0100 0100 0010 0000]
107
108 #define BITS_WFP_STATUS_F1 0x0c // [0000 1100] check the f1 full bits
109 #define BIT_WFP_BUF_F1_0 0x04 // [0000 0100] f1 buffer 0 is full
110 #define BIT_WFP_BUF_F1_1 0x08 // [0000 1000] f1 buffer 1 is full
111 #define RST_WFP_F1_0 0x00002204 // [0010 0010 0000 0100] f1 bits = 0
112 #define RST_WFP_F1_1 0x00002208 // [0010 0010 0000 1000] f1 bits = 0
113
114 #define BITS_WFP_STATUS_F0 0x03 // [0000 0011] check the f0 full bits
115 #define RST_WFP_F0_0 0x00001101 // [0001 0001 0000 0001]
116 #define RST_WFP_F0_1 0x00001102 // [0001 0001 0000 0010]
117
118 #define BIT_WFP_BUFFER_0 0x01
119 #define BIT_WFP_BUFFER_1 0x02
120
121 #define RST_BITS_RUN_BURST_EN 0x80 // [1000 0000] burst f2, f1, f0 enable f3, f2, f1, f0
122 #define RUN_BURST_ENABLE_SBM2 0x60 // [0110 0000] enable f2 and f1 burst
123 #define RUN_BURST_ENABLE_BURST 0x40 // [0100 0000] f2 burst enabled
124
125 #define DFLT_WFP_NB_DATA_BY_BUFFER 0xa7f // 0x30 *** 2688 - 1 => nb samples -1
126 #define DFLT_WFP_SNAPSHOT_PARAM 0xa80 // 0x34 *** 2688 => nb samples
127 #define DFLT_WFP_BUFFER_LENGTH 0x1f8 // buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8
128 #define DFLT_WFP_DELTA_F0_2 0x30 // 48 = 11 0000, max 7 bits
129
60 130 // PDB >= 0.1.28, 0x80000f54
61 131 typedef struct{
62 132 int data_shaping; // 0x00 00 *** R2 R1 R0 SP1 SP0 BW
@@ -106,6 +176,29 typedef struct{
106 176 volatile unsigned int e2; // 0x98
107 177 } waveform_picker_regs_0_1_18_t;
108 178
179 //*********************
180 //*********************
181 // SPECTRAL_MATRIX_REGS
182
183 #define BITS_STATUS_F0 0x03 // [0011]
184 #define BITS_STATUS_F1 0x0c // [1100]
185 #define BITS_STATUS_F2 0x30 // [0011 0000]
186 #define BITS_HK_AA_SM 0x780 // [0111 1000 0000]
187 #define BITS_SM_ERR 0x7c0 // [0111 1100 0000]
188 #define BITS_STATUS_REG 0x7ff // [0111 1111 1111]
189 #define BIT_READY_0 0x1 // [01]
190 #define BIT_READY_1 0x2 // [10]
191 #define BIT_READY_0_1 0x3 // [11]
192 #define BIT_STATUS_F1_0 0x04 // [0100]
193 #define BIT_STATUS_F1_1 0x08 // [1000]
194 #define BIT_STATUS_F2_0 0x10 // [0001 0000]
195 #define BIT_STATUS_F2_1 0x20 // [0010 0000]
196 #define DEFAULT_MATRIX_LENGTH 0xc8 // 25 * 128 / 16 = 200 = 0xc8
197 #define BIT_IRQ_ON_NEW_MATRIX 0x01
198 #define MASK_IRQ_ON_NEW_MATRIX 0xfffffffe
199 #define BIT_IRQ_ON_ERROR 0x02
200 #define MASK_IRQ_ON_ERROR 0xfffffffd
201
109 202 typedef struct {
110 203 volatile int config; // 0x00
111 204 volatile int status; // 0x04
@@ -29,4 +29,8
29 29
30 30 unsigned char lfr_rtems_cpu_usage_report( void );
31 31
32 #define CONST_100 100
33 #define CONST_1000 1000
34 #define CONST_100000 100000
35
32 36 #endif // LFR_CPU_USAGE_REPORT_H
@@ -11,6 +11,10
11 11
12 12 #include "fsw_params.h"
13 13
14 #define SBM_COEFF_PER_NORM_COEFF 2
15 #define MAX_SRC_DATA 780 // MAX size is 26 bins * 30 Bytes [TM_LFR_SCIENCE_BURST_BP2_F1]
16 #define MAX_SRC_DATA_WITH_SPARE 143 // 13 bins * 11 Bytes
17
14 18 typedef struct ring_node_asm
15 19 {
16 20 struct ring_node_asm *next;
@@ -24,24 +28,24 typedef struct
24 28 unsigned char protocolIdentifier;
25 29 unsigned char reserved;
26 30 unsigned char userApplication;
27 unsigned char packetID[2];
28 unsigned char packetSequenceControl[2];
29 unsigned char packetLength[2];
31 unsigned char packetID[BYTES_PER_PACKETID];
32 unsigned char packetSequenceControl[BYTES_PER_SEQ_CTRL];
33 unsigned char packetLength[BYTES_PER_PKT_LEN];
30 34 // DATA FIELD HEADER
31 35 unsigned char spare1_pusVersion_spare2;
32 36 unsigned char serviceType;
33 37 unsigned char serviceSubType;
34 38 unsigned char destinationID;
35 unsigned char time[6];
39 unsigned char time[BYTES_PER_TIME];
36 40 // AUXILIARY HEADER
37 41 unsigned char sid;
38 42 unsigned char pa_bia_status_info;
39 43 unsigned char sy_lfr_common_parameters_spare;
40 44 unsigned char sy_lfr_common_parameters;
41 unsigned char acquisitionTime[6];
42 unsigned char pa_lfr_bp_blk_nr[2];
45 unsigned char acquisitionTime[BYTES_PER_TIME];
46 unsigned char pa_lfr_bp_blk_nr[BYTES_PER_BLKNR];
43 47 // SOURCE DATA
44 unsigned char data[ 780 ]; // MAX size is 26 bins * 30 Bytes [TM_LFR_SCIENCE_BURST_BP2_F1]
48 unsigned char data[ MAX_SRC_DATA ]; // MAX size is 26 bins * 30 Bytes [TM_LFR_SCIENCE_BURST_BP2_F1]
45 49 } bp_packet;
46 50
47 51 typedef struct
@@ -50,25 +54,25 typedef struct
50 54 unsigned char protocolIdentifier;
51 55 unsigned char reserved;
52 56 unsigned char userApplication;
53 unsigned char packetID[2];
54 unsigned char packetSequenceControl[2];
55 unsigned char packetLength[2];
57 unsigned char packetID[BYTES_PER_PACKETID];
58 unsigned char packetSequenceControl[BYTES_PER_SEQ_CTRL];
59 unsigned char packetLength[BYTES_PER_PKT_LEN];
56 60 // DATA FIELD HEADER
57 61 unsigned char spare1_pusVersion_spare2;
58 62 unsigned char serviceType;
59 63 unsigned char serviceSubType;
60 64 unsigned char destinationID;
61 unsigned char time[6];
65 unsigned char time[BYTES_PER_TIME];
62 66 // AUXILIARY HEADER
63 67 unsigned char sid;
64 68 unsigned char pa_bia_status_info;
65 69 unsigned char sy_lfr_common_parameters_spare;
66 70 unsigned char sy_lfr_common_parameters;
67 unsigned char acquisitionTime[6];
71 unsigned char acquisitionTime[BYTES_PER_TIME];
68 72 unsigned char source_data_spare;
69 unsigned char pa_lfr_bp_blk_nr[2];
73 unsigned char pa_lfr_bp_blk_nr[BYTES_PER_BLKNR];
70 74 // SOURCE DATA
71 unsigned char data[ 143 ]; // 13 bins * 11 Bytes
75 unsigned char data[ MAX_SRC_DATA_WITH_SPARE ]; // 13 bins * 11 Bytes
72 76 } bp_packet_with_spare; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1
73 77
74 78 typedef struct asm_msg
@@ -99,8 +103,8 extern Packet_TM_LFR_PARAMETER_DUMP_t pa
99 103 extern time_management_regs_t *time_management_regs;
100 104 extern volatile spectral_matrix_regs_t *spectral_matrix_regs;
101 105
102 extern rtems_name misc_name[5];
103 extern rtems_id Task_id[20]; /* array of task ids */
106 extern rtems_name misc_name[];
107 extern rtems_id Task_id[]; /* array of task ids */
104 108
105 109 ring_node * getRingNodeForAveraging( unsigned char frequencyChannel);
106 110 // ISR
@@ -173,7 +177,7 void SM_average( float *averaged_spec_ma
173 177 float sum;
174 178 unsigned int i;
175 179 unsigned int k;
176 unsigned char incomingSMIsValid[8];
180 unsigned char incomingSMIsValid[NB_SM_BEFORE_AVF0_F1];
177 181 unsigned int numberOfValidSM;
178 182 unsigned char isValid;
179 183
@@ -181,7 +185,7 void SM_average( float *averaged_spec_ma
181 185 // PAS FILTERING
182 186 // check acquisitionTime of the incoming data
183 187 numberOfValidSM = 0;
184 for (k=0; k<8; k++)
188 for (k=0; k<NB_SM_BEFORE_AVF0_F1; k++)
185 189 {
186 190 isValid = acquisitionTimeIsValid( ring_node_tab[k]->coarseTime, ring_node_tab[k]->fineTime, channel );
187 191 incomingSMIsValid[k] = isValid;
@@ -201,14 +205,14 void SM_average( float *averaged_spec_ma
201 205 // + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ]
202 206 // + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ];
203 207
204 sum = ( (incomingSMIsValid[0] == 1) ? ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ] : 0.0 )
205 + ( (incomingSMIsValid[1] == 1) ? ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ] : 0.0 )
206 + ( (incomingSMIsValid[2] == 1) ? ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ] : 0.0 )
207 + ( (incomingSMIsValid[3] == 1) ? ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ] : 0.0 )
208 + ( (incomingSMIsValid[4] == 1) ? ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ] : 0.0 )
209 + ( (incomingSMIsValid[5] == 1) ? ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ] : 0.0 )
210 + ( (incomingSMIsValid[6] == 1) ? ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ] : 0.0 )
211 + ( (incomingSMIsValid[7] == 1) ? ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ] : 0.0 );
208 sum = ( incomingSMIsValid[0] * ((int *)(ring_node_tab[0]->buffer_address) )[ i ] )
209 + ( incomingSMIsValid[1] * ((int *)(ring_node_tab[1]->buffer_address) )[ i ] )
210 + ( incomingSMIsValid[2] * ((int *)(ring_node_tab[2]->buffer_address) )[ i ] )
211 + ( incomingSMIsValid[3] * ((int *)(ring_node_tab[3]->buffer_address) )[ i ] )
212 + ( incomingSMIsValid[4] * ((int *)(ring_node_tab[4]->buffer_address) )[ i ] )
213 + ( incomingSMIsValid[5] * ((int *)(ring_node_tab[5]->buffer_address) )[ i ] )
214 + ( incomingSMIsValid[6] * ((int *)(ring_node_tab[6]->buffer_address) )[ i ] )
215 + ( incomingSMIsValid[7] * ((int *)(ring_node_tab[7]->buffer_address) )[ i ] );
212 216
213 217 if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) )
214 218 {
@@ -278,13 +282,19 void ASM_reorganize_and_divide( float *a
278 282 for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ )
279 283 {
280 284 offsetASMReorganized =
281 frequencyBin * NB_VALUES_PER_SM
285 (frequencyBin * NB_VALUES_PER_SM)
282 286 + asmComponent;
283 287 offsetASM =
284 asmComponent * NB_BINS_PER_SM
288 (asmComponent * NB_BINS_PER_SM)
285 289 + frequencyBin;
286 averaged_spec_mat_reorganized[offsetASMReorganized ] =
287 (divider != 0.0) ? averaged_spec_mat[ offsetASM ] / divider : 0.0;
290 if ( divider != INIT_FLOAT )
291 {
292 averaged_spec_mat_reorganized[offsetASMReorganized ] = averaged_spec_mat[ offsetASM ] / divider;
293 }
294 else
295 {
296 averaged_spec_mat_reorganized[offsetASMReorganized ] = INIT_FLOAT;
297 }
288 298 }
289 299 }
290 300 }
@@ -304,12 +314,12 void ASM_compress_reorganize_and_divide(
304 314 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
305 315 {
306 316 offsetCompressed = // NO TIME OFFSET
307 frequencyBin * NB_VALUES_PER_SM
317 (frequencyBin * NB_VALUES_PER_SM)
308 318 + asmComponent;
309 319 offsetASM = // NO TIME OFFSET
310 asmComponent * NB_BINS_PER_SM
320 (asmComponent * NB_BINS_PER_SM)
311 321 + ASMIndexStart
312 + frequencyBin * nbBinsToAverage;
322 + (frequencyBin * nbBinsToAverage);
313 323 compressed_spec_mat[ offsetCompressed ] = 0;
314 324 for ( k = 0; k < nbBinsToAverage; k++ )
315 325 {
@@ -340,8 +350,8 void ASM_convert( volatile float *input_
340 350 {
341 351 for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++)
342 352 {
343 offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ;
344 offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ;
353 offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ;
354 offsetOutput = SM_BYTES_PER_VAL * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ;
345 355 pt_char_input = (char*) &input_matrix [ offsetInput ];
346 356 pt_char_output = (char*) &output_matrix[ offsetOutput ];
347 357 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
@@ -1,9 +1,28
1 1 #ifndef TC_ACCEPTANCE_H_INCLUDED
2 2 #define TC_ACCEPTANCE_H_INCLUDED
3 3
4 //#include "tm_lfr_tc_exe.h"
5 4 #include "fsw_params.h"
6 5
6 #define BIT_0 0x01
7 #define BIT_1 0x02
8 #define BIT_2 0x04
9 #define BIT_3 0x08
10 #define BIT_4 0x10
11 #define BIT_5 0x20
12 #define BIT_6 0x40
13 #define BIT_7 0x80
14
15 #define CONST_CRC_0 0x1021
16 #define CONST_CRC_1 0x2042
17 #define CONST_CRC_2 0x4084
18 #define CONST_CRC_3 0x8108
19 #define CONST_CRC_4 0x1231
20 #define CONST_CRC_5 0x2462
21 #define CONST_CRC_6 0x48c4
22 #define CONST_CRC_7 0x9188
23
24 #define CRC_RESET 0xffff
25
7 26 //**********************
8 27 // GENERAL USE FUNCTIONS
9 28 unsigned int Crc_opt( unsigned char D, unsigned int Chk);
@@ -12,6 +12,36
12 12
13 13 #include "lfr_cpu_usage_report.h"
14 14
15 #define MAX_DELTA_COARSE_TIME 3
16 #define NB_SCIENCE_TASKS 10
17 #define NB_ASM_TASKS 6
18 #define STATUS_0 0
19 #define STATUS_1 1
20 #define STATUS_2 2
21 #define STATUS_3 3
22 #define STATUS_4 4
23 #define STATUS_5 5
24 #define STATUS_6 6
25 #define STATUS_7 7
26 #define STATUS_8 8
27 #define STATUS_9 9
28
29 #define CAL_F0 625
30 #define CAL_F1 10000
31 #define CAL_FS 160256.410
32 #define CAL_SCALE_FACTOR (0.250 / 0.000654) // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV
33 #define CAL_NB_PTS 256
34 #define CAL_DATA_MASK 0xfff
35 #define CAL_F_DIVISOR 38 // 25 MHz => 160 256 (39 - 1)
36 // INTERLEAVED MODE
37 #define CAL_FS_INTER 240384.615
38 #define CAL_NB_PTS_INTER 384
39 #define CAL_DATA_MASK_INTER 0x3f
40 #define CAL_DATA_SHIFT_INTER 12
41 #define BYTES_FOR_2_SAMPLES 3 // one need 3 bytes = 24 bits to store 3 samples of 12 bits in interleaved mode
42 #define STEPS_FOR_STORAGE_INTER 128
43 #define CAL_F_DIVISOR_INTER 26 // 25 MHz => 240 384
44
15 45 extern unsigned int lastValidEnterModeTime;
16 46 extern unsigned char oneTcLfrUpdateTimeReceived;
17 47
@@ -11,7 +11,25
11 11 #include "basic_parameters_params.h"
12 12 #include "avf0_prc0.h"
13 13
14 #define FLOAT_EQUAL_ZERO 0.001
14 #define FLOAT_EQUAL_ZERO 0.001
15 #define NB_BINS_TO_REMOVE 3
16 #define FI_INTERVAL_COEFF 0.285
17 #define BIN_MIN 0
18 #define BIN_MAX 127
19 #define DELTAF_F0 96.
20 #define DELTAF_F1 16.
21 #define DELTAF_F2 1.
22
23 #define BIT_RW1_F1 0x80
24 #define BIT_RW1_F2 0x40
25 #define BIT_RW2_F1 0x20
26 #define BIT_RW2_F2 0x10
27 #define BIT_RW3_F1 0x08
28 #define BIT_RW3_F2 0x04
29 #define BIT_RW4_F1 0x02
30 #define BIT_RW4_F2 0x01
31
32 #define SBM_KCOEFF_PER_NORM_KCOEFF 2
15 33
16 34 extern unsigned short sequenceCounterParameterDump;
17 35 extern unsigned short sequenceCounters_TM_DUMP[];
@@ -11,6 +11,33
11 11 #include "fsw_params_wf_handler.h"
12 12
13 13 #define pi 3.14159265359
14 #define T0_IN_FINETIME ( 65536. / 24576. )
15 #define T1_IN_FINETIME ( 65536. / 4096. )
16 #define T2_IN_FINETIME ( 65536. / 256. )
17 #define T3_IN_FINETIME ( 65536. / 16. )
18
19 #define TICKS_PER_T1 16
20 #define TICKS_PER_T2 256
21 #define TICKS_PER_S 65536.
22 #define MS_PER_S 1000.
23
24 #define FREQ_F0 24576.
25 #define FREQ_F1 4096.
26 #define FREQ_F2 256.
27 #define FREQ_F3 16.
28
29 #define DELTAT_F0 2731 // (2048. / 24576. / 2.) * 65536. = 2730.667;
30 #define DELTAT_F1 16384 // (2048. / 4096. / 2.) * 65536. = 16384;
31 #define DELTAT_F2 262144 // (2048. / 256. / 2.) * 65536. = 262144;
32
33 #define OFFSET_2_BYTES 2
34
35 #define ONE_TICK_CORR_INTERVAL_0_MIN 0.5
36 #define ONE_TICK_CORR_INTERVAL_0_MAX 1.0
37 #define ONE_TICK_CORR_INTERVAL_1_MIN -1.0
38 #define ONE_TICK_CORR_INTERVAL_1_MAX -0.5
39 #define ONE_TICK_CORR 1
40 #define CORR_MULT 2
14 41
15 42 extern int fdSPW;
16 43
@@ -30,7 +57,7 extern struct param_local_str param_loca
30 57 extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
31 58 extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
32 59
33 extern rtems_id Task_id[20]; /* array of task ids */
60 extern rtems_id Task_id[]; /* array of task ids */
34 61
35 62 extern unsigned char lfrCurrentMode;
36 63
@@ -1,15 +1,16
1 1 #include <drvmgr/ambapp_bus.h>
2 2 #include <drvmgr/drvmgr.h>
3 #include <ccsds_types.h>
3 4
4 5 // GRSPW0 resources
5 6 struct drvmgr_key grlib_grspw_0n1_res[] =
6 7 {
7 {"txBdCnt", KEY_TYPE_INT, {(unsigned int)50}}, // 7 SWF_F0, 7 SWF_F1, 7 SWF_F2, 7 CWF_F3, 7 CWF_F1 ou 7 CWF_F2
8 {"rxBdCnt", KEY_TYPE_INT, {(unsigned int)10}},
9 {"txDataSize", KEY_TYPE_INT, {(unsigned int)4096}},
10 {"txHdrSize", KEY_TYPE_INT, {(unsigned int)34}},
11 {"rxPktSize", KEY_TYPE_INT, {(unsigned int)200}},
12 KEY_EMPTY
8 {"txBdCnt", KEY_TYPE_INT, {(unsigned int)TXBDCNT}}, // 7 SWF_F0, 7 SWF_F1, 7 SWF_F2, 7 CWF_F3, 7 CWF_F1 ou 7 CWF_F2
9 {"rxBdCnt", KEY_TYPE_INT, {(unsigned int)RXBDCNT}},
10 {"txDataSize", KEY_TYPE_INT, {(unsigned int)TXDATASIZE}},
11 {"txHdrSize", KEY_TYPE_INT, {(unsigned int)TXHDRSIZE}},
12 {"rxPktSize", KEY_TYPE_INT, {(unsigned int)RXPKTSIZE}},
13 KEY_EMPTY
13 14 };
14 15
15 16 // If RTEMS_DRVMGR_STARTUP is defined we override the "weak defaults" that is defined by the LEON3 BSP.
@@ -22,10 +22,13
22 22 #include "fsw_params.h"
23 23 #include "fsw_params_wf_handler.h"
24 24
25 #define NB_OF_TASKS 20
26 #define NB_OF_MISC_NAMES 5
27
25 28 // RTEMS GLOBAL VARIABLES
26 rtems_name misc_name[5];
27 rtems_name Task_name[20]; /* array of task names */
28 rtems_id Task_id[20]; /* array of task ids */
29 rtems_name misc_name[NB_OF_MISC_NAMES];
30 rtems_name Task_name[NB_OF_TASKS]; /* array of task names */
31 rtems_id Task_id[NB_OF_TASKS]; /* array of task ids */
29 32 rtems_name timecode_timer_name;
30 33 rtems_id timecode_timer_id;
31 34 int fdSPW = 0;
@@ -95,4 +98,5 float cp_rpw_sc_rw4_f2;
95 98 filterPar_t filterPar;
96 99
97 100 fbins_masks_t fbins_masks;
98 unsigned int acquisitionDurations[3] = {ACQUISITION_DURATION_F0, ACQUISITION_DURATION_F1, ACQUISITION_DURATION_F2};
101 unsigned int acquisitionDurations[NB_ACQUISITION_DURATION]
102 = {ACQUISITION_DURATION_F0, ACQUISITION_DURATION_F1, ACQUISITION_DURATION_F2};
@@ -164,16 +164,16 rtems_task Init( rtems_task_argument ign
164 164 init_k_coefficients_prc0();
165 165 init_k_coefficients_prc1();
166 166 init_k_coefficients_prc2();
167 pa_bia_status_info = 0x00;
168 cp_rpw_sc_rw_f_flags = 0x00;
169 cp_rpw_sc_rw1_f1 = 0.0;
170 cp_rpw_sc_rw1_f2 = 0.0;
171 cp_rpw_sc_rw2_f1 = 0.0;
172 cp_rpw_sc_rw2_f2 = 0.0;
173 cp_rpw_sc_rw3_f1 = 0.0;
174 cp_rpw_sc_rw3_f2 = 0.0;
175 cp_rpw_sc_rw4_f1 = 0.0;
176 cp_rpw_sc_rw4_f2 = 0.0;
167 pa_bia_status_info = INIT_CHAR;
168 cp_rpw_sc_rw_f_flags = INIT_CHAR;
169 cp_rpw_sc_rw1_f1 = INIT_FLOAT;
170 cp_rpw_sc_rw1_f2 = INIT_FLOAT;
171 cp_rpw_sc_rw2_f1 = INIT_FLOAT;
172 cp_rpw_sc_rw2_f2 = INIT_FLOAT;
173 cp_rpw_sc_rw3_f1 = INIT_FLOAT;
174 cp_rpw_sc_rw3_f2 = INIT_FLOAT;
175 cp_rpw_sc_rw4_f1 = INIT_FLOAT;
176 cp_rpw_sc_rw4_f2 = INIT_FLOAT;
177 177 // initialize filtering parameters
178 178 filterPar.spare_sy_lfr_pas_filter_enabled = DEFAULT_SY_LFR_PAS_FILTER_ENABLED;
179 179 filterPar.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
@@ -319,17 +319,17 void init_local_mode_parameters( void )
319 319
320 320 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
321 321 {
322 sequenceCounters_TC_EXE[i] = 0x00;
323 sequenceCounters_TM_DUMP[i] = 0x00;
322 sequenceCounters_TC_EXE[i] = INIT_CHAR;
323 sequenceCounters_TM_DUMP[i] = INIT_CHAR;
324 324 }
325 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
326 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
327 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
325 sequenceCounters_SCIENCE_NORMAL_BURST = INIT_CHAR;
326 sequenceCounters_SCIENCE_SBM1_SBM2 = INIT_CHAR;
327 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << TM_PACKET_SEQ_SHIFT;
328 328 }
329 329
330 330 void reset_local_time( void )
331 331 {
332 time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000
332 time_management_regs->ctrl = time_management_regs->ctrl | VAL_SOFTWARE_RESET; // [0010] software reset, coarse time = 0x80000000
333 333 }
334 334
335 335 void create_names( void ) // create all names for tasks and queues
@@ -403,7 +403,7 int create_all_tasks( void ) // create a
403 403 if (status == RTEMS_SUCCESSFUL) // SEND
404 404 {
405 405 status = rtems_task_create(
406 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2,
406 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT,
407 407 RTEMS_DEFAULT_MODES,
408 408 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND]
409 409 );
@@ -446,7 +446,7 int create_all_tasks( void ) // create a
446 446 if (status == RTEMS_SUCCESSFUL) // PRC0
447 447 {
448 448 status = rtems_task_create(
449 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
449 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT,
450 450 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
451 451 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
452 452 );
@@ -462,7 +462,7 int create_all_tasks( void ) // create a
462 462 if (status == RTEMS_SUCCESSFUL) // PRC1
463 463 {
464 464 status = rtems_task_create(
465 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
465 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT,
466 466 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
467 467 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
468 468 );
@@ -478,7 +478,7 int create_all_tasks( void ) // create a
478 478 if (status == RTEMS_SUCCESSFUL) // PRC2
479 479 {
480 480 status = rtems_task_create(
481 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
481 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT,
482 482 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
483 483 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
484 484 );
@@ -913,10 +913,10 void init_ring(ring_node ring[], unsigne
913 913 // BUFFER ADDRESS
914 914 for(i=0; i<nbNodes; i++)
915 915 {
916 ring[i].coarseTime = 0xffffffff;
917 ring[i].fineTime = 0xffffffff;
918 ring[i].sid = 0x00;
919 ring[i].status = 0x00;
916 ring[i].coarseTime = INT32_ALL_F;
917 ring[i].fineTime = INT32_ALL_F;
918 ring[i].sid = INIT_CHAR;
919 ring[i].status = INIT_CHAR;
920 920 ring[i].buffer_address = (int) &buffer[ i * bufferSize ];
921 921 }
922 922
@@ -25,7 +25,7 void timer_configure(unsigned char timer
25 25 rtems_status_code status;
26 26 rtems_isr_entry old_isr_handler;
27 27
28 gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register
28 gptimer_regs->timer[timer].ctrl = INIT_CHAR; // reset the control register
29 29
30 30 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
31 31 if (status!=RTEMS_SUCCESSFUL)
@@ -45,11 +45,11 void timer_start(unsigned char timer)
45 45 *
46 46 */
47 47
48 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
49 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
50 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
51 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
52 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
48 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_CLEAR_IRQ;
49 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_LD;
50 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_EN;
51 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_RS;
52 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_IE;
53 53 }
54 54
55 55 void timer_stop(unsigned char timer)
@@ -61,9 +61,9 void timer_stop(unsigned char timer)
61 61 *
62 62 */
63 63
64 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer
65 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable
66 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
64 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & GPTIMER_EN_MASK;
65 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & GPTIMER_IE_MASK;
66 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_CLEAR_IRQ;
67 67 }
68 68
69 69 void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider)
@@ -127,7 +127,7 void watchdog_reload(void)
127 127 *
128 128 */
129 129
130 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000004; // LD load value from the reload register
130 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_LD;
131 131 }
132 132
133 133 void watchdog_start(void)
@@ -141,10 +141,10 void watchdog_start(void)
141 141
142 142 LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG );
143 143
144 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000010; // clear pending IRQ if any
145 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000004; // LD load value from the reload register
146 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000001; // EN enable the timer
147 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000008; // IE interrupt enable
144 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_CLEAR_IRQ;
145 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_LD;
146 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_EN;
147 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_IE;
148 148
149 149 LEON_Unmask_interrupt( IRQ_GPTIMER_WATCHDOG );
150 150
@@ -210,14 +210,14 rtems_task load_task(rtems_task_argument
210 210 status = rtems_rate_monotonic_period( watchdog_period_id, WATCHDOG_PERIOD );
211 211 watchdog_reload();
212 212 i = i + 1;
213 if ( i == 10 )
213 if ( i == WATCHDOG_LOOP_PRINTF )
214 214 {
215 215 i = 0;
216 216 j = j + 1;
217 217 PRINTF1("%d\n", j)
218 218 }
219 219 #ifdef DEBUG_WATCHDOG
220 if (j == 3 )
220 if (j == WATCHDOG_LOOP_DEBUG )
221 221 {
222 222 status = rtems_task_delete(RTEMS_SELF);
223 223 }
@@ -261,15 +261,15 rtems_task hous_task(rtems_task_argument
261 261 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
262 262 while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway
263 263 {
264 if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization
264 if ((time_management_regs->coarse_time & VAL_LFR_SYNCHRONIZED) == INT32_ALL_0) // check time synchronization
265 265 {
266 266 break; // break if LFR is synchronized
267 267 }
268 268 else
269 269 {
270 270 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
271 // sched_yield();
272 status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms
271
272 status = rtems_task_wake_after( HK_SYNC_WAIT ); // wait HK_SYNCH_WAIT 100 ms = 10 * 10 ms
273 273 }
274 274 }
275 275 status = rtems_rate_monotonic_cancel(HK_id);
@@ -284,16 +284,16 rtems_task hous_task(rtems_task_argument
284 284 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
285 285 }
286 286 else {
287 housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8);
288 housekeeping_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterHK );
287 housekeeping_packet.packetSequenceControl[BYTE_0] = (unsigned char) (sequenceCounterHK >> SHIFT_1_BYTE);
288 housekeeping_packet.packetSequenceControl[BYTE_1] = (unsigned char) (sequenceCounterHK );
289 289 increment_seq_counter( &sequenceCounterHK );
290 290
291 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
292 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
293 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
294 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
295 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
296 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
291 housekeeping_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
292 housekeeping_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
293 housekeeping_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
294 housekeeping_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
295 housekeeping_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
296 housekeeping_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
297 297
298 298 spacewire_update_hk_lfr_link_state( &housekeeping_packet.lfr_status_word[0] );
299 299
@@ -436,22 +436,22 rtems_task dumb_task( rtems_task_argumen
436 436 unsigned int fine_time = 0;
437 437 rtems_event_set event_out;
438 438
439 char *DumbMessages[15] = {"in DUMB *** default", // RTEMS_EVENT_0
440 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
441 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
442 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
443 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
444 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
445 "VHDL SM *** two buffers f0 ready", // RTEMS_EVENT_6
446 "ready for dump", // RTEMS_EVENT_7
447 "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8
448 "tick", // RTEMS_EVENT_9
449 "VHDL ERR *** waveform picker", // RTEMS_EVENT_10
450 "VHDL ERR *** unexpected ready matrix values", // RTEMS_EVENT_11
451 "WATCHDOG timer", // RTEMS_EVENT_12
452 "TIMECODE timer", // RTEMS_EVENT_13
453 "TIMECODE ISR" // RTEMS_EVENT_14
454 };
439 char *DumbMessages[DUMB_MESSAGE_NB] = {DUMB_MESSAGE_0, // RTEMS_EVENT_0
440 DUMB_MESSAGE_1, // RTEMS_EVENT_1
441 DUMB_MESSAGE_2, // RTEMS_EVENT_2
442 DUMB_MESSAGE_3, // RTEMS_EVENT_3
443 DUMB_MESSAGE_4, // RTEMS_EVENT_4
444 DUMB_MESSAGE_5, // RTEMS_EVENT_5
445 DUMB_MESSAGE_6, // RTEMS_EVENT_6
446 DUMB_MESSAGE_7, // RTEMS_EVENT_7
447 DUMB_MESSAGE_8, // RTEMS_EVENT_8
448 DUMB_MESSAGE_9, // RTEMS_EVENT_9
449 DUMB_MESSAGE_10, // RTEMS_EVENT_10
450 DUMB_MESSAGE_11, // RTEMS_EVENT_11
451 DUMB_MESSAGE_12, // RTEMS_EVENT_12
452 DUMB_MESSAGE_13, // RTEMS_EVENT_13
453 DUMB_MESSAGE_14 // RTEMS_EVENT_14
454 };
455 455
456 456 BOOT_PRINTF("in DUMB *** \n")
457 457
@@ -462,23 +462,23 rtems_task dumb_task( rtems_task_argumen
462 462 | RTEMS_EVENT_14,
463 463 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
464 464 intEventOut = (unsigned int) event_out;
465 for ( i=0; i<32; i++)
465 for ( i=0; i<NB_RTEMS_EVENTS; i++)
466 466 {
467 if ( ((intEventOut >> i) & 0x0001) != 0)
467 if ( ((intEventOut >> i) & 1) != 0)
468 468 {
469 469 coarse_time = time_management_regs->coarse_time;
470 470 fine_time = time_management_regs->fine_time;
471 if (i==12)
471 if (i==EVENT_12)
472 472 {
473 PRINTF1("%s\n", DumbMessages[12])
473 PRINTF1("%s\n", DUMB_MESSAGE_12)
474 474 }
475 if (i==13)
475 if (i==EVENT_13)
476 476 {
477 PRINTF1("%s\n", DumbMessages[13])
477 PRINTF1("%s\n", DUMB_MESSAGE_13)
478 478 }
479 if (i==14)
479 if (i==EVENT_14)
480 480 {
481 PRINTF1("%s\n", DumbMessages[1])
481 PRINTF1("%s\n", DUMB_MESSAGE_1)
482 482 }
483 483 }
484 484 }
@@ -504,18 +504,18 void init_housekeeping_parameters( void
504 504
505 505 for(i = 0; i< sizeOfHK; i++)
506 506 {
507 parameters[i] = 0x00;
507 parameters[i] = INIT_CHAR;
508 508 }
509 509
510 510 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
511 511 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
512 512 housekeeping_packet.reserved = DEFAULT_RESERVED;
513 513 housekeeping_packet.userApplication = CCSDS_USER_APP;
514 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
514 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> SHIFT_1_BYTE);
515 515 housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK);
516 516 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
517 517 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
518 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
518 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> SHIFT_1_BYTE);
519 519 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
520 520 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
521 521 housekeeping_packet.serviceType = TM_TYPE_HK;
@@ -529,13 +529,13 void init_housekeeping_parameters( void
529 529 // init software version
530 530 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
531 531 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
532 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
533 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
532 housekeeping_packet.lfr_sw_version[BYTE_2] = SW_VERSION_N3;
533 housekeeping_packet.lfr_sw_version[BYTE_3] = SW_VERSION_N4;
534 534 // init fpga version
535 535 parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
536 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
537 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
538 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
536 housekeeping_packet.lfr_fpga_version[BYTE_0] = parameters[BYTE_1]; // n1
537 housekeeping_packet.lfr_fpga_version[BYTE_1] = parameters[BYTE_2]; // n2
538 housekeeping_packet.lfr_fpga_version[BYTE_2] = parameters[BYTE_3]; // n3
539 539
540 540 housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND;
541 541 housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV;
@@ -555,8 +555,8 void increment_seq_counter( unsigned sho
555 555 unsigned short segmentation_grouping_flag;
556 556 unsigned short sequence_cnt;
557 557
558 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
559 sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111]
558 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE; // keep bits 7 downto 6
559 sequence_cnt = (*packetSequenceControl) & SEQ_CNT_MASK; // [0011 1111 1111 1111]
560 560
561 561 if ( sequence_cnt < SEQ_CNT_MAX)
562 562 {
@@ -576,11 +576,11 void getTime( unsigned char *time)
576 576 *
577 577 */
578 578
579 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
580 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
581 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
579 time[0] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_3_BYTES);
580 time[1] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_2_BYTES);
581 time[2] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_1_BYTE);
582 582 time[3] = (unsigned char) (time_management_regs->coarse_time);
583 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
583 time[4] = (unsigned char) (time_management_regs->fine_time>>SHIFT_1_BYTE);
584 584 time[5] = (unsigned char) (time_management_regs->fine_time);
585 585 }
586 586
@@ -591,7 +591,7 unsigned long long int getTimeAsUnsigned
591 591 */
592 592 unsigned long long int time;
593 593
594 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
594 time = ( (unsigned long long int) (time_management_regs->coarse_time & COARSE_TIME_MASK) << SHIFT_2_BYTES )
595 595 + time_management_regs->fine_time;
596 596
597 597 return time;
@@ -608,43 +608,43 void send_dumb_hk( void )
608 608 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
609 609 dummy_hk_packet.reserved = DEFAULT_RESERVED;
610 610 dummy_hk_packet.userApplication = CCSDS_USER_APP;
611 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
611 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> SHIFT_1_BYTE);
612 612 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
613 613 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
614 614 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
615 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
615 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> SHIFT_1_BYTE);
616 616 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
617 617 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
618 618 dummy_hk_packet.serviceType = TM_TYPE_HK;
619 619 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
620 620 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
621 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
622 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
623 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
624 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
625 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
626 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
621 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
622 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
623 dummy_hk_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
624 dummy_hk_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
625 dummy_hk_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
626 dummy_hk_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
627 627 dummy_hk_packet.sid = SID_HK;
628 628
629 629 // init status word
630 dummy_hk_packet.lfr_status_word[0] = 0xff;
631 dummy_hk_packet.lfr_status_word[1] = 0xff;
630 dummy_hk_packet.lfr_status_word[0] = INT8_ALL_F;
631 dummy_hk_packet.lfr_status_word[1] = INT8_ALL_F;
632 632 // init software version
633 633 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
634 634 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
635 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
636 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
635 dummy_hk_packet.lfr_sw_version[BYTE_2] = SW_VERSION_N3;
636 dummy_hk_packet.lfr_sw_version[BYTE_3] = SW_VERSION_N4;
637 637 // init fpga version
638 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
639 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
640 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
641 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
638 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + APB_OFFSET_VHDL_REV);
639 dummy_hk_packet.lfr_fpga_version[BYTE_0] = parameters[BYTE_1]; // n1
640 dummy_hk_packet.lfr_fpga_version[BYTE_1] = parameters[BYTE_2]; // n2
641 dummy_hk_packet.lfr_fpga_version[BYTE_2] = parameters[BYTE_3]; // n3
642 642
643 643 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
644 644
645 for (i=0; i<100; i++)
645 for (i=0; i<(BYTE_POS_HK_REACTION_WHEELS_FREQUENCY - BYTE_POS_HK_LFR_CPU_LOAD); i++)
646 646 {
647 parameters[i] = 0xff;
647 parameters[i] = INT8_ALL_F;
648 648 }
649 649
650 650 get_message_queue_id_send( &queue_id );
@@ -668,12 +668,12 void get_temperatures( unsigned char *te
668 668 temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb;
669 669 temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga;
670 670
671 temperatures[0] = temp_scm_ptr[2];
672 temperatures[1] = temp_scm_ptr[3];
673 temperatures[2] = temp_pcb_ptr[2];
674 temperatures[3] = temp_pcb_ptr[3];
675 temperatures[4] = temp_fpga_ptr[2];
676 temperatures[5] = temp_fpga_ptr[3];
671 temperatures[ BYTE_0 ] = temp_scm_ptr[ BYTE_2 ];
672 temperatures[ BYTE_1 ] = temp_scm_ptr[ BYTE_3 ];
673 temperatures[ BYTE_2 ] = temp_pcb_ptr[ BYTE_2 ];
674 temperatures[ BYTE_3 ] = temp_pcb_ptr[ BYTE_3 ];
675 temperatures[ BYTE_4 ] = temp_fpga_ptr[ BYTE_2 ];
676 temperatures[ BYTE_5 ] = temp_fpga_ptr[ BYTE_3 ];
677 677 }
678 678
679 679 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
@@ -686,12 +686,12 void get_v_e1_e2_f3( unsigned char *spac
686 686 e1_ptr = (unsigned char *) &waveform_picker_regs->e1;
687 687 e2_ptr = (unsigned char *) &waveform_picker_regs->e2;
688 688
689 spacecraft_potential[0] = v_ptr[2];
690 spacecraft_potential[1] = v_ptr[3];
691 spacecraft_potential[2] = e1_ptr[2];
692 spacecraft_potential[3] = e1_ptr[3];
693 spacecraft_potential[4] = e2_ptr[2];
694 spacecraft_potential[5] = e2_ptr[3];
689 spacecraft_potential[ BYTE_0 ] = v_ptr[ BYTE_2 ];
690 spacecraft_potential[ BYTE_1 ] = v_ptr[ BYTE_3 ];
691 spacecraft_potential[ BYTE_2 ] = e1_ptr[ BYTE_2 ];
692 spacecraft_potential[ BYTE_3 ] = e1_ptr[ BYTE_3 ];
693 spacecraft_potential[ BYTE_4 ] = e2_ptr[ BYTE_2 ];
694 spacecraft_potential[ BYTE_5 ] = e2_ptr[ BYTE_3 ];
695 695 }
696 696
697 697 void get_cpu_load( unsigned char *resource_statistics )
@@ -710,7 +710,7 void get_cpu_load( unsigned char *resour
710 710 }
711 711
712 712 // CPU_LOAD_AVE
713 resource_statistics[2] = 0;
713 resource_statistics[BYTE_2] = 0;
714 714
715 715 #ifndef PRINT_TASK_STATISTICS
716 716 rtems_cpu_usage_reset();
@@ -722,11 +722,13 void set_hk_lfr_sc_potential_flag( bool
722 722 {
723 723 if (state == true)
724 724 {
725 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x40; // [0100 0000]
725 housekeeping_packet.lfr_status_word[1] =
726 housekeeping_packet.lfr_status_word[1] | STATUS_WORD_SC_POTENTIAL_FLAG_BIT; // [0100 0000]
726 727 }
727 728 else
728 729 {
729 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xbf; // [1011 1111]
730 housekeeping_packet.lfr_status_word[1] =
731 housekeeping_packet.lfr_status_word[1] & STATUS_WORD_SC_POTENTIAL_FLAG_MASK; // [1011 1111]
730 732 }
731 733 }
732 734
@@ -734,11 +736,13 void set_sy_lfr_pas_filter_enabled( bool
734 736 {
735 737 if (state == true)
736 738 {
737 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x20; // [0010 0000]
739 housekeeping_packet.lfr_status_word[1] =
740 housekeeping_packet.lfr_status_word[1] | STATUS_WORD_SC_POTENTIAL_FLAG_BIT; // [0010 0000]
738 741 }
739 742 else
740 743 {
741 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xdf; // [1101 1111]
744 housekeeping_packet.lfr_status_word[1] =
745 housekeeping_packet.lfr_status_word[1] & STATUS_WORD_SC_POTENTIAL_FLAG_MASK; // [1101 1111]
742 746 }
743 747 }
744 748
@@ -746,11 +750,13 void set_sy_lfr_watchdog_enabled( bool s
746 750 {
747 751 if (state == true)
748 752 {
749 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x10; // [0001 0000]
753 housekeeping_packet.lfr_status_word[1] =
754 housekeeping_packet.lfr_status_word[1] | STATUS_WORD_WATCHDOG_BIT; // [0001 0000]
750 755 }
751 756 else
752 757 {
753 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xef; // [1110 1111]
758 housekeeping_packet.lfr_status_word[1] =
759 housekeeping_packet.lfr_status_word[1] & STATUS_WORD_WATCHDOG_MASK; // [1110 1111]
754 760 }
755 761 }
756 762
@@ -758,20 +764,23 void set_hk_lfr_calib_enable( bool state
758 764 {
759 765 if (state == true)
760 766 {
761 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x08; // [0000 1000]
767 housekeeping_packet.lfr_status_word[1] =
768 housekeeping_packet.lfr_status_word[1] | STATUS_WORD_CALIB_BIT; // [0000 1000]
762 769 }
763 770 else
764 771 {
765 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf7; // [1111 0111]
772 housekeeping_packet.lfr_status_word[1] =
773 housekeeping_packet.lfr_status_word[1] & STATUS_WORD_CALIB_MASK; // [1111 0111]
766 774 }
767 775 }
768 776
769 777 void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause )
770 778 {
771 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf8; // [1111 1000]
779 housekeeping_packet.lfr_status_word[1] =
780 housekeeping_packet.lfr_status_word[1] & STATUS_WORD_RESET_CAUSE_MASK; // [1111 1000]
772 781
773 782 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1]
774 | (lfr_reset_cause & 0x07 ); // [0000 0111]
783 | (lfr_reset_cause & STATUS_WORD_RESET_CAUSE_BITS ); // [0000 0111]
775 784
776 785 }
777 786
@@ -799,7 +808,7 void hk_lfr_le_update( void )
799 808 hk_lfr_le_t new_hk_lfr_le;
800 809 unsigned int counter;
801 810
802 counter = ((unsigned int) housekeeping_packet.hk_lfr_le_cnt[0]) * 256 + housekeeping_packet.hk_lfr_le_cnt[1];
811 counter = (((unsigned int) housekeeping_packet.hk_lfr_le_cnt[0]) * 256) + housekeeping_packet.hk_lfr_le_cnt[1];
803 812
804 813 // DPU
805 814 new_hk_lfr_le.dpu_spw_parity = housekeeping_packet.hk_lfr_dpu_spw_parity;
@@ -822,21 +831,21 void hk_lfr_le_update( void )
822 831
823 832 // update the le counter
824 833 // DPU
825 increment_hk_counter( new_hk_lfr_le.dpu_spw_parity, old_hk_lfr_le.dpu_spw_parity, counter );
826 increment_hk_counter( new_hk_lfr_le.dpu_spw_disconnect,old_hk_lfr_le.dpu_spw_disconnect, counter );
827 increment_hk_counter( new_hk_lfr_le.dpu_spw_escape, old_hk_lfr_le.dpu_spw_escape, counter );
828 increment_hk_counter( new_hk_lfr_le.dpu_spw_credit, old_hk_lfr_le.dpu_spw_credit, counter );
829 increment_hk_counter( new_hk_lfr_le.dpu_spw_write_sync,old_hk_lfr_le.dpu_spw_write_sync, counter );
834 increment_hk_counter( new_hk_lfr_le.dpu_spw_parity, old_hk_lfr_le.dpu_spw_parity, &counter );
835 increment_hk_counter( new_hk_lfr_le.dpu_spw_disconnect,old_hk_lfr_le.dpu_spw_disconnect, &counter );
836 increment_hk_counter( new_hk_lfr_le.dpu_spw_escape, old_hk_lfr_le.dpu_spw_escape, &counter );
837 increment_hk_counter( new_hk_lfr_le.dpu_spw_credit, old_hk_lfr_le.dpu_spw_credit, &counter );
838 increment_hk_counter( new_hk_lfr_le.dpu_spw_write_sync,old_hk_lfr_le.dpu_spw_write_sync, &counter );
830 839 // TIMECODE
831 increment_hk_counter( new_hk_lfr_le.timecode_erroneous,old_hk_lfr_le.timecode_erroneous, counter );
832 increment_hk_counter( new_hk_lfr_le.timecode_missing, old_hk_lfr_le.timecode_missing, counter );
833 increment_hk_counter( new_hk_lfr_le.timecode_invalid, old_hk_lfr_le.timecode_invalid, counter );
840 increment_hk_counter( new_hk_lfr_le.timecode_erroneous,old_hk_lfr_le.timecode_erroneous, &counter );
841 increment_hk_counter( new_hk_lfr_le.timecode_missing, old_hk_lfr_le.timecode_missing, &counter );
842 increment_hk_counter( new_hk_lfr_le.timecode_invalid, old_hk_lfr_le.timecode_invalid, &counter );
834 843 // TIME
835 increment_hk_counter( new_hk_lfr_le.time_timecode_it, old_hk_lfr_le.time_timecode_it, counter );
836 increment_hk_counter( new_hk_lfr_le.time_not_synchro, old_hk_lfr_le.time_not_synchro, counter );
837 increment_hk_counter( new_hk_lfr_le.time_timecode_ctr, old_hk_lfr_le.time_timecode_ctr, counter );
844 increment_hk_counter( new_hk_lfr_le.time_timecode_it, old_hk_lfr_le.time_timecode_it, &counter );
845 increment_hk_counter( new_hk_lfr_le.time_not_synchro, old_hk_lfr_le.time_not_synchro, &counter );
846 increment_hk_counter( new_hk_lfr_le.time_timecode_ctr, old_hk_lfr_le.time_timecode_ctr, &counter );
838 847 // AHB
839 increment_hk_counter( new_hk_lfr_le.ahb_correctable, old_hk_lfr_le.ahb_correctable, counter );
848 increment_hk_counter( new_hk_lfr_le.ahb_correctable, old_hk_lfr_le.ahb_correctable, &counter );
840 849
841 850 // DPU
842 851 old_hk_lfr_le.dpu_spw_parity = new_hk_lfr_le.dpu_spw_parity;
@@ -859,8 +868,8 void hk_lfr_le_update( void )
859 868
860 869 // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers
861 870 // LE
862 housekeeping_packet.hk_lfr_le_cnt[0] = (unsigned char) ((hk_lfr_le_cnt & 0xff00) >> 8);
863 housekeeping_packet.hk_lfr_le_cnt[1] = (unsigned char) (hk_lfr_le_cnt & 0x00ff);
871 housekeeping_packet.hk_lfr_le_cnt[0] = (unsigned char) ((counter & BYTE0_MASK) >> SHIFT_1_BYTE);
872 housekeeping_packet.hk_lfr_le_cnt[1] = (unsigned char) (counter & BYTE1_MASK);
864 873 }
865 874
866 875 void hk_lfr_me_update( void )
@@ -869,7 +878,7 void hk_lfr_me_update( void )
869 878 hk_lfr_me_t new_hk_lfr_me;
870 879 unsigned int counter;
871 880
872 counter = ((unsigned int) housekeeping_packet.hk_lfr_me_cnt[0]) * 256 + housekeeping_packet.hk_lfr_me_cnt[1];
881 counter = (((unsigned int) housekeeping_packet.hk_lfr_me_cnt[0]) * 256) + housekeeping_packet.hk_lfr_me_cnt[1];
873 882
874 883 // get the current values
875 884 new_hk_lfr_me.dpu_spw_early_eop = housekeeping_packet.hk_lfr_dpu_spw_early_eop;
@@ -878,10 +887,10 void hk_lfr_me_update( void )
878 887 new_hk_lfr_me.dpu_spw_rx_too_big = housekeeping_packet.hk_lfr_dpu_spw_rx_too_big;
879 888
880 889 // update the me counter
881 increment_hk_counter( new_hk_lfr_me.dpu_spw_early_eop, old_hk_lfr_me.dpu_spw_early_eop, counter );
882 increment_hk_counter( new_hk_lfr_me.dpu_spw_invalid_addr, old_hk_lfr_me.dpu_spw_invalid_addr, counter );
883 increment_hk_counter( new_hk_lfr_me.dpu_spw_eep, old_hk_lfr_me.dpu_spw_eep, counter );
884 increment_hk_counter( new_hk_lfr_me.dpu_spw_rx_too_big, old_hk_lfr_me.dpu_spw_rx_too_big, counter );
890 increment_hk_counter( new_hk_lfr_me.dpu_spw_early_eop, old_hk_lfr_me.dpu_spw_early_eop, &counter );
891 increment_hk_counter( new_hk_lfr_me.dpu_spw_invalid_addr, old_hk_lfr_me.dpu_spw_invalid_addr, &counter );
892 increment_hk_counter( new_hk_lfr_me.dpu_spw_eep, old_hk_lfr_me.dpu_spw_eep, &counter );
893 increment_hk_counter( new_hk_lfr_me.dpu_spw_rx_too_big, old_hk_lfr_me.dpu_spw_rx_too_big, &counter );
885 894
886 895 // store the counters for the next time
887 896 old_hk_lfr_me.dpu_spw_early_eop = new_hk_lfr_me.dpu_spw_early_eop;
@@ -891,8 +900,8 void hk_lfr_me_update( void )
891 900
892 901 // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers
893 902 // ME
894 housekeeping_packet.hk_lfr_me_cnt[0] = (unsigned char) ((hk_lfr_me_cnt & 0xff00) >> 8);
895 housekeeping_packet.hk_lfr_me_cnt[1] = (unsigned char) (hk_lfr_me_cnt & 0x00ff);
903 housekeeping_packet.hk_lfr_me_cnt[0] = (unsigned char) ((counter & BYTE0_MASK) >> SHIFT_1_BYTE);
904 housekeeping_packet.hk_lfr_me_cnt[1] = (unsigned char) (counter & BYTE1_MASK);
896 905 }
897 906
898 907 void hk_lfr_le_me_he_update()
@@ -913,8 +922,8 void hk_lfr_le_me_he_update()
913 922
914 923 // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers
915 924 // HE
916 housekeeping_packet.hk_lfr_he_cnt[0] = (unsigned char) ((hk_lfr_he_cnt & 0xff00) >> 8);
917 housekeeping_packet.hk_lfr_he_cnt[1] = (unsigned char) (hk_lfr_he_cnt & 0x00ff);
925 housekeeping_packet.hk_lfr_he_cnt[0] = (unsigned char) ((hk_lfr_he_cnt & BYTE0_MASK) >> SHIFT_1_BYTE);
926 housekeeping_packet.hk_lfr_he_cnt[1] = (unsigned char) (hk_lfr_he_cnt & BYTE1_MASK);
918 927
919 928 }
920 929
@@ -924,7 +933,8 void set_hk_lfr_time_not_synchro()
924 933 int synchronizationBit;
925 934
926 935 // get the synchronization bit
927 synchronizationBit = (time_management_regs->coarse_time & 0x80000000) >> 31; // 1000 0000 0000 0000
936 synchronizationBit =
937 (time_management_regs->coarse_time & VAL_LFR_SYNCHRONIZED) >> BIT_SYNCHRONIZATION; // 1000 0000 0000 0000
928 938
929 939 switch (synchronizationBit)
930 940 {
@@ -978,6 +988,6 void set_hk_lfr_ahb_correctable() // C
978 988 + iurfErrorCounter
979 989 + housekeeping_packet.hk_lfr_ahb_correctable;
980 990
981 housekeeping_packet.hk_lfr_ahb_correctable = (unsigned char) (ahb_correctable & 0xff); // [1111 1111]
991 housekeeping_packet.hk_lfr_ahb_correctable = (unsigned char) (ahb_correctable & INT8_ALL_F); // [1111 1111]
982 992
983 993 }
@@ -57,14 +57,14 rtems_task spiq_task(rtems_task_argument
57 57
58 58 // [1] CHECK THE LINK
59 59 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1)
60 if ( linkStatus != 5) {
60 if ( linkStatus != SPW_LINK_OK) {
61 61 PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus)
62 62 status = rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms
63 63 }
64 64
65 65 // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT
66 66 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2)
67 if ( linkStatus != 5 ) // [2.a] not in run state, reset the link
67 if ( linkStatus != SPW_LINK_OK ) // [2.a] not in run state, reset the link
68 68 {
69 69 spacewire_read_statistics();
70 70 status = spacewire_several_connect_attemps( );
@@ -122,8 +122,8 rtems_task recv_task( rtems_task_argumen
122 122
123 123 int len;
124 124 ccsdsTelecommandPacket_t currentTC;
125 unsigned char computed_CRC[ 2 ];
126 unsigned char currentTC_LEN_RCV[ 2 ];
125 unsigned char computed_CRC[ BYTES_PER_CRC ];
126 unsigned char currentTC_LEN_RCV[ BYTES_PER_PKT_LEN ];
127 127 unsigned char destinationID;
128 128 unsigned int estimatedPacketLength;
129 129 unsigned int parserCode;
@@ -158,9 +158,9 rtems_task recv_task( rtems_task_argumen
158 158 PRINTF("in RECV *** packet lenght too short\n")
159 159 }
160 160 else {
161 estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
161 estimatedPacketLength = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - PROTID_RES_APP); // => -3 is for Prot ID, Reserved and User App bytes
162 162 //PRINTF1("incoming TC with Length (byte): %d\n", len - 3);
163 currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> 8);
163 currentTC_LEN_RCV[ 0 ] = (unsigned char) (estimatedPacketLength >> SHIFT_1_BYTE);
164 164 currentTC_LEN_RCV[ 1 ] = (unsigned char) (estimatedPacketLength );
165 165 // CHECK THE TC
166 166 parserCode = tc_parser( &currentTC, estimatedPacketLength, computed_CRC ) ;
@@ -191,7 +191,7 rtems_task recv_task( rtems_task_argumen
191 191 else
192 192 { // send valid TC to the action launcher
193 193 status = rtems_message_queue_send( queue_recv_id, &currentTC,
194 estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + 3);
194 estimatedPacketLength + CCSDS_TC_TM_PACKET_OFFSET + PROTID_RES_APP);
195 195 }
196 196 }
197 197 }
@@ -260,8 +260,8 rtems_task send_task( rtems_task_argumen
260 260 {
261 261 charPtr[0] = incomingData[0];
262 262 charPtr[1] = incomingData[1];
263 charPtr[2] = incomingData[2];
264 charPtr[3] = incomingData[3];
263 charPtr[BYTE_2] = incomingData[BYTE_2];
264 charPtr[BYTE_3] = incomingData[BYTE_3];
265 265 incomingRingNodePtr = (ring_node*) ring_node_address;
266 266 sid = incomingRingNodePtr->sid;
267 267 if ( (sid==SID_NORM_CWF_LONG_F3)
@@ -346,9 +346,9 rtems_task link_task( rtems_task_argumen
346 346 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
347 347 PRINTF("in LINK *** wait for the link\n")
348 348 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
349 while( linkStatus != 5) // wait for the link
349 while( linkStatus != SPW_LINK_OK) // wait for the link
350 350 {
351 status = rtems_task_wake_after( 10 ); // monitor the link each 100ms
351 status = rtems_task_wake_after( SPW_LINK_WAIT ); // monitor the link each 100ms
352 352 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
353 353 watchdog_reload();
354 354 }
@@ -447,9 +447,9 int spacewire_configure_link( int fd )
447 447 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
448 448 spw_ioctl_packetsize packetsize;
449 449
450 packetsize.rxsize = 228;
451 packetsize.txdsize = 4096;
452 packetsize.txhsize = 34;
450 packetsize.rxsize = SPW_RXSIZE;
451 packetsize.txdsize = SPW_TXDSIZE;
452 packetsize.txhsize = SPW_TXHSIZE;
453 453
454 454 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
455 455 if (status!=RTEMS_SUCCESSFUL) {
@@ -481,7 +481,7 int spacewire_configure_link( int fd )
481 481 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
482 482 }
483 483 //
484 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ]
484 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, CONF_TCODE_CTRL); // [Time Rx : Time Tx : Link error : Tick-out IRQ]
485 485 if (status!=RTEMS_SUCCESSFUL) {
486 486 PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
487 487 }
@@ -546,10 +546,10 void spacewire_set_NP( unsigned char val
546 546 unsigned int *spwptr = (unsigned int*) regAddr;
547 547
548 548 if (val == 1) {
549 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
549 *spwptr = *spwptr | SPW_BIT_NP; // [NP] set the No port force bit
550 550 }
551 551 if (val== 0) {
552 *spwptr = *spwptr & 0xffdfffff;
552 *spwptr = *spwptr & SPW_BIT_NP_MASK;
553 553 }
554 554 }
555 555
@@ -568,11 +568,11 void spacewire_set_RE( unsigned char val
568 568
569 569 if (val == 1)
570 570 {
571 *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit
571 *spwptr = *spwptr | SPW_BIT_RE; // [RE] set the RMAP Enable bit
572 572 }
573 573 if (val== 0)
574 574 {
575 *spwptr = *spwptr & 0xfffdffff;
575 *spwptr = *spwptr & SPW_BIT_RE_MASK;
576 576 }
577 577 }
578 578
@@ -775,24 +775,24 void update_hk_lfr_last_er_fields(unsign
775 775 coarseTimePtr = (unsigned char*) &time_management_regs->coarse_time;
776 776 fineTimePtr = (unsigned char*) &time_management_regs->fine_time;
777 777
778 housekeeping_packet.hk_lfr_last_er_rid[0] = (unsigned char) ((rid & 0xff00) >> 8 );
779 housekeeping_packet.hk_lfr_last_er_rid[1] = (unsigned char) (rid & 0x00ff);
778 housekeeping_packet.hk_lfr_last_er_rid[0] = (unsigned char) ((rid & BYTE0_MASK) >> SHIFT_1_BYTE );
779 housekeeping_packet.hk_lfr_last_er_rid[1] = (unsigned char) (rid & BYTE1_MASK);
780 780 housekeeping_packet.hk_lfr_last_er_code = code;
781 781 housekeeping_packet.hk_lfr_last_er_time[0] = coarseTimePtr[0];
782 782 housekeeping_packet.hk_lfr_last_er_time[1] = coarseTimePtr[1];
783 housekeeping_packet.hk_lfr_last_er_time[2] = coarseTimePtr[2];
784 housekeeping_packet.hk_lfr_last_er_time[3] = coarseTimePtr[3];
785 housekeeping_packet.hk_lfr_last_er_time[4] = fineTimePtr[2];
786 housekeeping_packet.hk_lfr_last_er_time[5] = fineTimePtr[3];
783 housekeeping_packet.hk_lfr_last_er_time[BYTE_2] = coarseTimePtr[BYTE_2];
784 housekeeping_packet.hk_lfr_last_er_time[BYTE_3] = coarseTimePtr[BYTE_3];
785 housekeeping_packet.hk_lfr_last_er_time[BYTE_4] = fineTimePtr[BYTE_2];
786 housekeeping_packet.hk_lfr_last_er_time[BYTE_5] = fineTimePtr[BYTE_3];
787 787 }
788 788
789 789 void update_hk_with_grspw_stats( void )
790 790 {
791 791 //****************************
792 792 // DPU_SPACEWIRE_IF_STATISTICS
793 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (grspw_stats.packets_received >> 8);
793 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (grspw_stats.packets_received >> SHIFT_1_BYTE);
794 794 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (grspw_stats.packets_received);
795 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (grspw_stats.packets_sent >> 8);
795 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (grspw_stats.packets_sent >> SHIFT_1_BYTE);
796 796 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (grspw_stats.packets_sent);
797 797
798 798 //******************************************
@@ -817,9 +817,10 void spacewire_update_hk_lfr_link_state(
817 817 unsigned char linkState;
818 818
819 819 statusRegisterPtr = (unsigned int *) (REGS_ADDR_GRSPW + APB_OFFSET_GRSPW_STATUS_REGISTER);
820 linkState = (unsigned char) ( ( (*statusRegisterPtr) >> 21) & 0x07); // [0000 0111]
820 linkState =
821 (unsigned char) ( ( (*statusRegisterPtr) >> SPW_LINK_STAT_POS) & STATUS_WORD_LINK_STATE_BITS); // [0000 0111]
821 822
822 *hk_lfr_status_word_0 = *hk_lfr_status_word_0 & 0xf8; // [1111 1000] set link state to 0
823 *hk_lfr_status_word_0 = *hk_lfr_status_word_0 & STATUS_WORD_LINK_STATE_MASK; // [1111 1000] set link state to 0
823 824
824 825 *hk_lfr_status_word_0 = *hk_lfr_status_word_0 | linkState; // update hk_lfr_dpu_spw_link_state
825 826 }
@@ -827,7 +828,7 void spacewire_update_hk_lfr_link_state(
827 828 void increase_unsigned_char_counter( unsigned char *counter )
828 829 {
829 830 // update the number of valid timecodes that have been received
830 if (*counter == 255)
831 if (*counter == UINT8_MAX)
831 832 {
832 833 *counter = 0;
833 834 }
@@ -858,7 +859,7 unsigned int check_timecode_and_previous
858 859 {
859 860 if (currentTimecodeCtr == 0)
860 861 {
861 if (previousTimecodeCtr == 63)
862 if (previousTimecodeCtr == SPW_TIMECODE_MAX)
862 863 {
863 864 ret = LFR_SUCCESSFUL;
864 865 }
@@ -1017,24 +1018,24 void init_header_cwf( Header_TM_LFR_SCIE
1017 1018 header->userApplication = CCSDS_USER_APP;
1018 1019 header->packetSequenceControl[0]= TM_PACKET_SEQ_CTRL_STANDALONE;
1019 1020 header->packetSequenceControl[1]= TM_PACKET_SEQ_CNT_DEFAULT;
1020 header->packetLength[0] = 0x00;
1021 header->packetLength[1] = 0x00;
1021 header->packetLength[0] = INIT_CHAR;
1022 header->packetLength[1] = INIT_CHAR;
1022 1023 // DATA FIELD HEADER
1023 1024 header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
1024 1025 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
1025 1026 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype
1026 1027 header->destinationID = TM_DESTINATION_ID_GROUND;
1027 header->time[0] = 0x00;
1028 header->time[0] = 0x00;
1029 header->time[0] = 0x00;
1030 header->time[0] = 0x00;
1031 header->time[0] = 0x00;
1032 header->time[0] = 0x00;
1028 header->time[BYTE_0] = INIT_CHAR;
1029 header->time[BYTE_1] = INIT_CHAR;
1030 header->time[BYTE_2] = INIT_CHAR;
1031 header->time[BYTE_3] = INIT_CHAR;
1032 header->time[BYTE_4] = INIT_CHAR;
1033 header->time[BYTE_5] = INIT_CHAR;
1033 1034 // AUXILIARY DATA HEADER
1034 header->sid = 0x00;
1035 header->sid = INIT_CHAR;
1035 1036 header->pa_bia_status_info = DEFAULT_HKBIA;
1036 header->blkNr[0] = 0x00;
1037 header->blkNr[1] = 0x00;
1037 header->blkNr[0] = INIT_CHAR;
1038 header->blkNr[1] = INIT_CHAR;
1038 1039 }
1039 1040
1040 1041 void init_header_swf( Header_TM_LFR_SCIENCE_SWF_t *header )
@@ -1043,29 +1044,29 void init_header_swf( Header_TM_LFR_SCIE
1043 1044 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
1044 1045 header->reserved = DEFAULT_RESERVED;
1045 1046 header->userApplication = CCSDS_USER_APP;
1046 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
1047 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> SHIFT_1_BYTE);
1047 1048 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
1048 1049 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1049 1050 header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1050 header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
1051 header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> SHIFT_1_BYTE);
1051 1052 header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 );
1052 1053 // DATA FIELD HEADER
1053 1054 header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
1054 1055 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
1055 1056 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6; // service subtype
1056 1057 header->destinationID = TM_DESTINATION_ID_GROUND;
1057 header->time[0] = 0x00;
1058 header->time[0] = 0x00;
1059 header->time[0] = 0x00;
1060 header->time[0] = 0x00;
1061 header->time[0] = 0x00;
1062 header->time[0] = 0x00;
1058 header->time[BYTE_0] = INIT_CHAR;
1059 header->time[BYTE_1] = INIT_CHAR;
1060 header->time[BYTE_2] = INIT_CHAR;
1061 header->time[BYTE_3] = INIT_CHAR;
1062 header->time[BYTE_4] = INIT_CHAR;
1063 header->time[BYTE_5] = INIT_CHAR;
1063 1064 // AUXILIARY DATA HEADER
1064 header->sid = 0x00;
1065 header->sid = INIT_CHAR;
1065 1066 header->pa_bia_status_info = DEFAULT_HKBIA;
1066 header->pktCnt = DEFAULT_PKTCNT; // PKT_CNT
1067 header->pktNr = 0x00;
1068 header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8);
1067 header->pktCnt = PKTCNT_SWF; // PKT_CNT
1068 header->pktNr = INIT_CHAR;
1069 header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> SHIFT_1_BYTE);
1069 1070 header->blkNr[1] = (unsigned char) (BLK_NR_CWF );
1070 1071 }
1071 1072
@@ -1075,30 +1076,30 void init_header_asm( Header_TM_LFR_SCIE
1075 1076 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
1076 1077 header->reserved = DEFAULT_RESERVED;
1077 1078 header->userApplication = CCSDS_USER_APP;
1078 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
1079 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> SHIFT_1_BYTE);
1079 1080 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
1080 1081 header->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1081 1082 header->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1082 header->packetLength[0] = 0x00;
1083 header->packetLength[1] = 0x00;
1083 header->packetLength[0] = INIT_CHAR;
1084 header->packetLength[1] = INIT_CHAR;
1084 1085 // DATA FIELD HEADER
1085 1086 header->spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
1086 1087 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
1087 1088 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype
1088 1089 header->destinationID = TM_DESTINATION_ID_GROUND;
1089 header->time[0] = 0x00;
1090 header->time[0] = 0x00;
1091 header->time[0] = 0x00;
1092 header->time[0] = 0x00;
1093 header->time[0] = 0x00;
1094 header->time[0] = 0x00;
1090 header->time[BYTE_0] = INIT_CHAR;
1091 header->time[BYTE_1] = INIT_CHAR;
1092 header->time[BYTE_2] = INIT_CHAR;
1093 header->time[BYTE_3] = INIT_CHAR;
1094 header->time[BYTE_4] = INIT_CHAR;
1095 header->time[BYTE_5] = INIT_CHAR;
1095 1096 // AUXILIARY DATA HEADER
1096 header->sid = 0x00;
1097 header->pa_bia_status_info = 0x00;
1098 header->pa_lfr_pkt_cnt_asm = 0x00;
1099 header->pa_lfr_pkt_nr_asm = 0x00;
1100 header->pa_lfr_asm_blk_nr[0] = 0x00;
1101 header->pa_lfr_asm_blk_nr[1] = 0x00;
1097 header->sid = INIT_CHAR;
1098 header->pa_bia_status_info = INIT_CHAR;
1099 header->pa_lfr_pkt_cnt_asm = INIT_CHAR;
1100 header->pa_lfr_pkt_nr_asm = INIT_CHAR;
1101 header->pa_lfr_asm_blk_nr[0] = INIT_CHAR;
1102 header->pa_lfr_asm_blk_nr[1] = INIT_CHAR;
1102 1103 }
1103 1104
1104 1105 int spw_send_waveform_CWF( ring_node *ring_node_to_send,
@@ -1135,11 +1136,11 int spw_send_waveform_CWF( ring_node *ri
1135 1136 fineTime = ring_node_to_send->fineTime;
1136 1137 dataPtr = (int*) ring_node_to_send->buffer_address;
1137 1138
1138 header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> 8);
1139 header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_336 >> SHIFT_1_BYTE);
1139 1140 header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_336 );
1140 1141 header->pa_bia_status_info = pa_bia_status_info;
1141 1142 header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
1142 header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> 8);
1143 header->blkNr[0] = (unsigned char) (BLK_NR_CWF >> SHIFT_1_BYTE);
1143 1144 header->blkNr[1] = (unsigned char) (BLK_NR_CWF );
1144 1145
1145 1146 for (i=0; i<NB_PACKETS_PER_GROUP_OF_CWF; i++) // send waveform
@@ -1160,20 +1161,20 int spw_send_waveform_CWF( ring_node *ri
1160 1161 //
1161 1162 header->time[0] = header->acquisitionTime[0];
1162 1163 header->time[1] = header->acquisitionTime[1];
1163 header->time[2] = header->acquisitionTime[2];
1164 header->time[3] = header->acquisitionTime[3];
1165 header->time[4] = header->acquisitionTime[4];
1166 header->time[5] = header->acquisitionTime[5];
1164 header->time[BYTE_2] = header->acquisitionTime[BYTE_2];
1165 header->time[BYTE_3] = header->acquisitionTime[BYTE_3];
1166 header->time[BYTE_4] = header->acquisitionTime[BYTE_4];
1167 header->time[BYTE_5] = header->acquisitionTime[BYTE_5];
1167 1168
1168 1169 // SET PACKET ID
1169 1170 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
1170 1171 {
1171 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> 8);
1172 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2 >> SHIFT_1_BYTE);
1172 1173 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_SBM1_SBM2);
1173 1174 }
1174 1175 else
1175 1176 {
1176 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
1177 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> SHIFT_1_BYTE);
1177 1178 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
1178 1179 }
1179 1180
@@ -1223,7 +1224,7 int spw_send_waveform_SWF( ring_node *ri
1223 1224 header->pa_bia_status_info = pa_bia_status_info;
1224 1225 header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
1225 1226
1226 for (i=0; i<7; i++) // send waveform
1227 for (i=0; i<PKTCNT_SWF; i++) // send waveform
1227 1228 {
1228 1229 spw_ioctl_send_SWF.data = (char*) &dataPtr[ (i * BLK_NR_304 * NB_WORDS_SWF_BLK) ];
1229 1230 spw_ioctl_send_SWF.hdr = (char*) header;
@@ -1232,32 +1233,32 int spw_send_waveform_SWF( ring_node *ri
1232 1233 increment_seq_counter_source_id( header->packetSequenceControl, sid );
1233 1234
1234 1235 // SET PACKET LENGTH AND BLKNR
1235 if (i == 6)
1236 if (i == (PKTCNT_SWF-1))
1236 1237 {
1237 1238 spw_ioctl_send_SWF.dlen = BLK_NR_224 * NB_BYTES_SWF_BLK;
1238 header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> 8);
1239 header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_224 >> SHIFT_1_BYTE);
1239 1240 header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_224 );
1240 header->blkNr[0] = (unsigned char) (BLK_NR_224 >> 8);
1241 header->blkNr[0] = (unsigned char) (BLK_NR_224 >> SHIFT_1_BYTE);
1241 1242 header->blkNr[1] = (unsigned char) (BLK_NR_224 );
1242 1243 }
1243 1244 else
1244 1245 {
1245 1246 spw_ioctl_send_SWF.dlen = BLK_NR_304 * NB_BYTES_SWF_BLK;
1246 header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> 8);
1247 header->packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_304 >> SHIFT_1_BYTE);
1247 1248 header->packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_304 );
1248 header->blkNr[0] = (unsigned char) (BLK_NR_304 >> 8);
1249 header->blkNr[0] = (unsigned char) (BLK_NR_304 >> SHIFT_1_BYTE);
1249 1250 header->blkNr[1] = (unsigned char) (BLK_NR_304 );
1250 1251 }
1251 1252
1252 1253 // SET PACKET TIME
1253 1254 compute_acquisition_time( coarseTime, fineTime, sid, i, header->acquisitionTime );
1254 1255 //
1255 header->time[0] = header->acquisitionTime[0];
1256 header->time[1] = header->acquisitionTime[1];
1257 header->time[2] = header->acquisitionTime[2];
1258 header->time[3] = header->acquisitionTime[3];
1259 header->time[4] = header->acquisitionTime[4];
1260 header->time[5] = header->acquisitionTime[5];
1256 header->time[BYTE_0] = header->acquisitionTime[BYTE_0];
1257 header->time[BYTE_1] = header->acquisitionTime[BYTE_1];
1258 header->time[BYTE_2] = header->acquisitionTime[BYTE_2];
1259 header->time[BYTE_3] = header->acquisitionTime[BYTE_3];
1260 header->time[BYTE_4] = header->acquisitionTime[BYTE_4];
1261 header->time[BYTE_5] = header->acquisitionTime[BYTE_5];
1261 1262
1262 1263 // SET SID
1263 1264 header->sid = sid;
@@ -1309,11 +1310,11 int spw_send_waveform_CWF3_light( ring_n
1309 1310 fineTime = ring_node_to_send->fineTime;
1310 1311 dataPtr = (char*) ring_node_to_send->buffer_address;
1311 1312
1312 header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> 8);
1313 header->packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_672 >> SHIFT_1_BYTE);
1313 1314 header->packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_672 );
1314 1315 header->pa_bia_status_info = pa_bia_status_info;
1315 1316 header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
1316 header->blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> 8);
1317 header->blkNr[0] = (unsigned char) (BLK_NR_CWF_SHORT_F3 >> SHIFT_1_BYTE);
1317 1318 header->blkNr[1] = (unsigned char) (BLK_NR_CWF_SHORT_F3 );
1318 1319
1319 1320 //*********************
@@ -1334,15 +1335,15 int spw_send_waveform_CWF3_light( ring_n
1334 1335 // SET PACKET TIME
1335 1336 compute_acquisition_time( coarseTime, fineTime, SID_NORM_CWF_F3, i, header->acquisitionTime );
1336 1337 //
1337 header->time[0] = header->acquisitionTime[0];
1338 header->time[1] = header->acquisitionTime[1];
1339 header->time[2] = header->acquisitionTime[2];
1340 header->time[3] = header->acquisitionTime[3];
1341 header->time[4] = header->acquisitionTime[4];
1342 header->time[5] = header->acquisitionTime[5];
1338 header->time[BYTE_0] = header->acquisitionTime[BYTE_0];
1339 header->time[BYTE_1] = header->acquisitionTime[BYTE_1];
1340 header->time[BYTE_2] = header->acquisitionTime[BYTE_2];
1341 header->time[BYTE_3] = header->acquisitionTime[BYTE_3];
1342 header->time[BYTE_4] = header->acquisitionTime[BYTE_4];
1343 header->time[BYTE_5] = header->acquisitionTime[BYTE_5];
1343 1344
1344 1345 // SET PACKET ID
1345 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> 8);
1346 header->packetID[0] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST >> SHIFT_1_BYTE);
1346 1347 header->packetID[1] = (unsigned char) (APID_TM_SCIENCE_NORMAL_BURST);
1347 1348
1348 1349 // SEND PACKET
@@ -1375,7 +1376,7 void spw_send_asm_f0( ring_node *ring_no
1375 1376 header->pa_bia_status_info = pa_bia_status_info;
1376 1377 header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
1377 1378
1378 for (i=0; i<3; i++)
1379 for (i=0; i<PKTCNT_ASM; i++)
1379 1380 {
1380 1381 if ((i==0) || (i==1))
1381 1382 {
@@ -1385,7 +1386,7 void spw_send_asm_f0( ring_node *ring_no
1385 1386 ];
1386 1387 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_1;
1387 1388 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6;
1388 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_1) >> 8 ); // BLK_NR MSB
1389 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_1) >> SHIFT_1_BYTE ); // BLK_NR MSB
1389 1390 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_1); // BLK_NR LSB
1390 1391 }
1391 1392 else
@@ -1396,7 +1397,7 void spw_send_asm_f0( ring_node *ring_no
1396 1397 ];
1397 1398 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F0_2;
1398 1399 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6;
1399 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_2) >> 8 ); // BLK_NR MSB
1400 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F0_2) >> SHIFT_1_BYTE ); // BLK_NR MSB
1400 1401 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F0_2); // BLK_NR LSB
1401 1402 }
1402 1403
@@ -1406,26 +1407,26 void spw_send_asm_f0( ring_node *ring_no
1406 1407
1407 1408 // (2) BUILD THE HEADER
1408 1409 increment_seq_counter_source_id( header->packetSequenceControl, sid );
1409 header->packetLength[0] = (unsigned char) (length>>8);
1410 header->packetLength[0] = (unsigned char) (length >> SHIFT_1_BYTE);
1410 1411 header->packetLength[1] = (unsigned char) (length);
1411 1412 header->sid = (unsigned char) sid; // SID
1412 header->pa_lfr_pkt_cnt_asm = 3;
1413 header->pa_lfr_pkt_cnt_asm = PKTCNT_ASM;
1413 1414 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
1414 1415
1415 1416 // (3) SET PACKET TIME
1416 header->time[0] = (unsigned char) (coarseTime>>24);
1417 header->time[1] = (unsigned char) (coarseTime>>16);
1418 header->time[2] = (unsigned char) (coarseTime>>8);
1419 header->time[3] = (unsigned char) (coarseTime);
1420 header->time[4] = (unsigned char) (fineTime>>8);
1421 header->time[5] = (unsigned char) (fineTime);
1417 header->time[BYTE_0] = (unsigned char) (coarseTime >> SHIFT_3_BYTES);
1418 header->time[BYTE_1] = (unsigned char) (coarseTime >> SHIFT_2_BYTES);
1419 header->time[BYTE_2] = (unsigned char) (coarseTime >> SHIFT_1_BYTE);
1420 header->time[BYTE_3] = (unsigned char) (coarseTime);
1421 header->time[BYTE_4] = (unsigned char) (fineTime >> SHIFT_1_BYTE);
1422 header->time[BYTE_5] = (unsigned char) (fineTime);
1422 1423 //
1423 header->acquisitionTime[0] = header->time[0];
1424 header->acquisitionTime[1] = header->time[1];
1425 header->acquisitionTime[2] = header->time[2];
1426 header->acquisitionTime[3] = header->time[3];
1427 header->acquisitionTime[4] = header->time[4];
1428 header->acquisitionTime[5] = header->time[5];
1424 header->acquisitionTime[BYTE_0] = header->time[BYTE_0];
1425 header->acquisitionTime[BYTE_1] = header->time[BYTE_1];
1426 header->acquisitionTime[BYTE_2] = header->time[BYTE_2];
1427 header->acquisitionTime[BYTE_3] = header->time[BYTE_3];
1428 header->acquisitionTime[BYTE_4] = header->time[BYTE_4];
1429 header->acquisitionTime[BYTE_5] = header->time[BYTE_5];
1429 1430
1430 1431 // (4) SEND PACKET
1431 1432 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM );
@@ -1455,7 +1456,7 void spw_send_asm_f1( ring_node *ring_no
1455 1456 header->pa_bia_status_info = pa_bia_status_info;
1456 1457 header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
1457 1458
1458 for (i=0; i<3; i++)
1459 for (i=0; i<PKTCNT_ASM; i++)
1459 1460 {
1460 1461 if ((i==0) || (i==1))
1461 1462 {
@@ -1465,7 +1466,7 void spw_send_asm_f1( ring_node *ring_no
1465 1466 ];
1466 1467 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_1;
1467 1468 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6;
1468 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_1) >> 8 ); // BLK_NR MSB
1469 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_1) >> SHIFT_1_BYTE ); // BLK_NR MSB
1469 1470 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_1); // BLK_NR LSB
1470 1471 }
1471 1472 else
@@ -1476,7 +1477,7 void spw_send_asm_f1( ring_node *ring_no
1476 1477 ];
1477 1478 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F1_2;
1478 1479 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_6;
1479 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_2) >> 8 ); // BLK_NR MSB
1480 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F1_2) >> SHIFT_1_BYTE ); // BLK_NR MSB
1480 1481 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F1_2); // BLK_NR LSB
1481 1482 }
1482 1483
@@ -1486,26 +1487,26 void spw_send_asm_f1( ring_node *ring_no
1486 1487
1487 1488 // (2) BUILD THE HEADER
1488 1489 increment_seq_counter_source_id( header->packetSequenceControl, sid );
1489 header->packetLength[0] = (unsigned char) (length>>8);
1490 header->packetLength[0] = (unsigned char) (length >> SHIFT_1_BYTE);
1490 1491 header->packetLength[1] = (unsigned char) (length);
1491 1492 header->sid = (unsigned char) sid; // SID
1492 header->pa_lfr_pkt_cnt_asm = 3;
1493 header->pa_lfr_pkt_cnt_asm = PKTCNT_ASM;
1493 1494 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
1494 1495
1495 1496 // (3) SET PACKET TIME
1496 header->time[0] = (unsigned char) (coarseTime>>24);
1497 header->time[1] = (unsigned char) (coarseTime>>16);
1498 header->time[2] = (unsigned char) (coarseTime>>8);
1499 header->time[3] = (unsigned char) (coarseTime);
1500 header->time[4] = (unsigned char) (fineTime>>8);
1501 header->time[5] = (unsigned char) (fineTime);
1497 header->time[BYTE_0] = (unsigned char) (coarseTime >> SHIFT_3_BYTES);
1498 header->time[BYTE_1] = (unsigned char) (coarseTime >> SHIFT_2_BYTES);
1499 header->time[BYTE_2] = (unsigned char) (coarseTime >> SHIFT_1_BYTE);
1500 header->time[BYTE_3] = (unsigned char) (coarseTime);
1501 header->time[BYTE_4] = (unsigned char) (fineTime >> SHIFT_1_BYTE);
1502 header->time[BYTE_5] = (unsigned char) (fineTime);
1502 1503 //
1503 header->acquisitionTime[0] = header->time[0];
1504 header->acquisitionTime[1] = header->time[1];
1505 header->acquisitionTime[2] = header->time[2];
1506 header->acquisitionTime[3] = header->time[3];
1507 header->acquisitionTime[4] = header->time[4];
1508 header->acquisitionTime[5] = header->time[5];
1504 header->acquisitionTime[BYTE_0] = header->time[BYTE_0];
1505 header->acquisitionTime[BYTE_1] = header->time[BYTE_1];
1506 header->acquisitionTime[BYTE_2] = header->time[BYTE_2];
1507 header->acquisitionTime[BYTE_3] = header->time[BYTE_3];
1508 header->acquisitionTime[BYTE_4] = header->time[BYTE_4];
1509 header->acquisitionTime[BYTE_5] = header->time[BYTE_5];
1509 1510
1510 1511 // (4) SEND PACKET
1511 1512 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM );
@@ -1535,7 +1536,7 void spw_send_asm_f2( ring_node *ring_no
1535 1536 header->pa_bia_status_info = pa_bia_status_info;
1536 1537 header->sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
1537 1538
1538 for (i=0; i<3; i++)
1539 for (i=0; i<PKTCNT_ASM; i++)
1539 1540 {
1540 1541
1541 1542 spw_ioctl_send_ASM.dlen = DLEN_ASM_F2_PKT;
@@ -1544,7 +1545,7 void spw_send_asm_f2( ring_node *ring_no
1544 1545 ];
1545 1546 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM_F2;
1546 1547 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3;
1547 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> 8 ); // BLK_NR MSB
1548 header->pa_lfr_asm_blk_nr[0] = (unsigned char) ( (NB_BINS_PER_PKT_ASM_F2) >> SHIFT_1_BYTE ); // BLK_NR MSB
1548 1549 header->pa_lfr_asm_blk_nr[1] = (unsigned char) (NB_BINS_PER_PKT_ASM_F2); // BLK_NR LSB
1549 1550
1550 1551 spw_ioctl_send_ASM.hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM;
@@ -1553,26 +1554,26 void spw_send_asm_f2( ring_node *ring_no
1553 1554
1554 1555 // (2) BUILD THE HEADER
1555 1556 increment_seq_counter_source_id( header->packetSequenceControl, sid );
1556 header->packetLength[0] = (unsigned char) (length>>8);
1557 header->packetLength[0] = (unsigned char) (length >> SHIFT_1_BYTE);
1557 1558 header->packetLength[1] = (unsigned char) (length);
1558 1559 header->sid = (unsigned char) sid; // SID
1559 header->pa_lfr_pkt_cnt_asm = 3;
1560 header->pa_lfr_pkt_cnt_asm = PKTCNT_ASM;
1560 1561 header->pa_lfr_pkt_nr_asm = (unsigned char) (i+1);
1561 1562
1562 1563 // (3) SET PACKET TIME
1563 header->time[0] = (unsigned char) (coarseTime>>24);
1564 header->time[1] = (unsigned char) (coarseTime>>16);
1565 header->time[2] = (unsigned char) (coarseTime>>8);
1566 header->time[3] = (unsigned char) (coarseTime);
1567 header->time[4] = (unsigned char) (fineTime>>8);
1568 header->time[5] = (unsigned char) (fineTime);
1564 header->time[BYTE_0] = (unsigned char) (coarseTime >> SHIFT_3_BYTES);
1565 header->time[BYTE_1] = (unsigned char) (coarseTime >> SHIFT_2_BYTES);
1566 header->time[BYTE_2] = (unsigned char) (coarseTime >> SHIFT_1_BYTE);
1567 header->time[BYTE_3] = (unsigned char) (coarseTime);
1568 header->time[BYTE_4] = (unsigned char) (fineTime >> SHIFT_1_BYTE);
1569 header->time[BYTE_5] = (unsigned char) (fineTime);
1569 1570 //
1570 header->acquisitionTime[0] = header->time[0];
1571 header->acquisitionTime[1] = header->time[1];
1572 header->acquisitionTime[2] = header->time[2];
1573 header->acquisitionTime[3] = header->time[3];
1574 header->acquisitionTime[4] = header->time[4];
1575 header->acquisitionTime[5] = header->time[5];
1571 header->acquisitionTime[BYTE_0] = header->time[BYTE_0];
1572 header->acquisitionTime[BYTE_1] = header->time[BYTE_1];
1573 header->acquisitionTime[BYTE_2] = header->time[BYTE_2];
1574 header->acquisitionTime[BYTE_3] = header->time[BYTE_3];
1575 header->acquisitionTime[BYTE_4] = header->time[BYTE_4];
1576 header->acquisitionTime[BYTE_5] = header->time[BYTE_5];
1576 1577
1577 1578 // (4) SEND PACKET
1578 1579 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send_ASM );
@@ -1593,7 +1594,7 void spw_send_k_dump( ring_node *ring_no
1593 1594
1594 1595 kcoefficients_dump = (Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *) ring_node_to_send->buffer_address;
1595 1596
1596 packetLength = kcoefficients_dump->packetLength[0] * 256 + kcoefficients_dump->packetLength[1];
1597 packetLength = (kcoefficients_dump->packetLength[0] * CONST_256) + kcoefficients_dump->packetLength[1];
1597 1598
1598 1599 size = packetLength + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
1599 1600
@@ -1605,5 +1606,5 void spw_send_k_dump( ring_node *ring_no
1605 1606 PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size)
1606 1607 }
1607 1608
1608 ring_node_to_send->status = 0x00;
1609 ring_node_to_send->status = INIT_CHAR;
1609 1610 }
@@ -18,7 +18,8 unsigned char lfr_rtems_cpu_usage_report
18 18 uint32_t api_index;
19 19 Thread_Control *the_thread;
20 20 Objects_Information *information;
21 uint32_t ival, fval;
21 uint32_t ival;
22 uint32_t fval;
22 23 #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
23 24 Timestamp_Control uptime;
24 25 Timestamp_Control total;
@@ -92,7 +93,7 unsigned char lfr_rtems_cpu_usage_report
92 93 uint64_t ival_64;
93 94
94 95 ival_64 = the_thread->cpu_time_used;
95 ival_64 *= 100000;
96 ival_64 *= CONST_100000;
96 97 ival = ival_64 / total_units;
97 98 }
98 99 else
@@ -100,14 +101,14 unsigned char lfr_rtems_cpu_usage_report
100 101 ival = 0;
101 102 }
102 103
103 fval = ival % 1000;
104 ival /= 1000;
104 fval = ival % CONST_1000;
105 ival /= CONST_1000;
105 106 #endif
106 107 }
107 108 }
108 109 }
109 110 }
110 cpu_load = (unsigned char) (100 - ival);
111 cpu_load = (unsigned char) (CONST_100 - ival);
111 112
112 113 return cpu_load;
113 114 }
@@ -24,7 +24,6 float asm_f0_patched_norm [ TOTAL_
24 24 float asm_f0_patched_burst_sbm [ TOTAL_SIZE_SM ];
25 25 float asm_f0_reorganized [ TOTAL_SIZE_SM ];
26 26
27 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
28 27 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F0];
29 28 float compressed_sm_sbm_f0 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F0 ];
30 29
@@ -43,7 +42,7 rtems_task avf0_task( rtems_task_argumen
43 42 rtems_id queue_id_prc0;
44 43 asm_msg msgForPRC;
45 44 ring_node *nodeForAveraging;
46 ring_node *ring_node_tab[8];
45 ring_node *ring_node_tab[NB_SM_BEFORE_AVF0_F1];
47 46 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
48 47 ring_node_asm *current_ring_node_asm_norm_f0;
49 48
@@ -80,17 +79,17 rtems_task avf0_task( rtems_task_argumen
80 79 // initialize the mesage for the MATR task
81 80 msgForPRC.norm = current_ring_node_asm_norm_f0;
82 81 msgForPRC.burst_sbm = current_ring_node_asm_burst_sbm_f0;
83 msgForPRC.event = 0x00; // this composite event will be sent to the PRC0 task
82 msgForPRC.event = EVENT_SETS_NONE_PENDING; // this composite event will be sent to the PRC0 task
84 83 //
85 84 //****************************************
86 85
87 86 nodeForAveraging = getRingNodeForAveraging( 0 );
88 87
89 ring_node_tab[NB_SM_BEFORE_AVF0-1] = nodeForAveraging;
90 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
88 ring_node_tab[NB_SM_BEFORE_AVF0_F1-1] = nodeForAveraging;
89 for ( i = 1; i < (NB_SM_BEFORE_AVF0_F1); i++ )
91 90 {
92 91 nodeForAveraging = nodeForAveraging->previous;
93 ring_node_tab[NB_SM_BEFORE_AVF0-i] = nodeForAveraging;
92 ring_node_tab[NB_SM_BEFORE_AVF0_F1-i] = nodeForAveraging;
94 93 }
95 94
96 95 // compute the average and store it in the averaged_sm_f1 buffer
@@ -101,11 +100,11 rtems_task avf0_task( rtems_task_argumen
101 100 &msgForPRC, 0 ); // 0 => frequency channel 0
102 101
103 102 // update nb_average
104 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0;
105 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0;
106 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0;
107 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0;
108 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0;
103 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0_F1;
104 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0_F1;
105 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0_F1;
106 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0_F1;
107 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0_F1;
109 108
110 109 if (nb_sbm_bp1 == nb_sm_before_f0.burst_sbm_bp1)
111 110 {
@@ -169,7 +168,7 rtems_task avf0_task( rtems_task_argumen
169 168
170 169 //*************************
171 170 // send the message to PRC
172 if (msgForPRC.event != 0x00)
171 if (msgForPRC.event != EVENT_SETS_NONE_PENDING)
173 172 {
174 173 status = rtems_message_queue_send( queue_id_prc0, (char *) &msgForPRC, MSG_QUEUE_SIZE_PRC0);
175 174 }
@@ -373,15 +372,16 rtems_task prc0_task( rtems_task_argumen
373 372
374 373 void reset_nb_sm_f0( unsigned char lfrMode )
375 374 {
376 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
377 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
378 nb_sm_before_f0.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96;
379 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24; // 0.25 s per digit
380 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
381 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
382 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
383 nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96;
384 nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96;
375 nb_sm_before_f0.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * NB_SM_PER_S_F0;
376 nb_sm_before_f0.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * NB_SM_PER_S_F0;
377 nb_sm_before_f0.norm_asm =
378 ( (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256) + parameter_dump_packet.sy_lfr_n_asm_p[1]) * NB_SM_PER_S_F0;
379 nb_sm_before_f0.sbm1_bp1 = parameter_dump_packet.sy_lfr_s1_bp_p0 * NB_SM_PER_S1_BP_P0; // 0.25 s per digit
380 nb_sm_before_f0.sbm1_bp2 = parameter_dump_packet.sy_lfr_s1_bp_p1 * NB_SM_PER_S_F0;
381 nb_sm_before_f0.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * NB_SM_PER_S_F0;
382 nb_sm_before_f0.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * NB_SM_PER_S_F0;
383 nb_sm_before_f0.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * NB_SM_PER_S_F0;
384 nb_sm_before_f0.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * NB_SM_PER_S_F0;
385 385
386 386 if (lfrMode == LFR_MODE_SBM1)
387 387 {
@@ -25,7 +25,6 float asm_f1_patched_norm [ TOTAL_
25 25 float asm_f1_patched_burst_sbm [ TOTAL_SIZE_SM ];
26 26 float asm_f1_reorganized [ TOTAL_SIZE_SM ];
27 27
28 char asm_f1_char [ TOTAL_SIZE_SM * 2 ];
29 28 float compressed_sm_norm_f1[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F1];
30 29 float compressed_sm_sbm_f1 [ TOTAL_SIZE_COMPRESSED_ASM_SBM_F1 ];
31 30
@@ -44,7 +43,7 rtems_task avf1_task( rtems_task_argumen
44 43 rtems_id queue_id_prc1;
45 44 asm_msg msgForPRC;
46 45 ring_node *nodeForAveraging;
47 ring_node *ring_node_tab[NB_SM_BEFORE_AVF0];
46 ring_node *ring_node_tab[NB_SM_BEFORE_AVF0_F1];
48 47 ring_node_asm *current_ring_node_asm_burst_sbm_f1;
49 48 ring_node_asm *current_ring_node_asm_norm_f1;
50 49
@@ -81,17 +80,17 rtems_task avf1_task( rtems_task_argumen
81 80 // initialize the mesage for the MATR task
82 81 msgForPRC.norm = current_ring_node_asm_norm_f1;
83 82 msgForPRC.burst_sbm = current_ring_node_asm_burst_sbm_f1;
84 msgForPRC.event = 0x00; // this composite event will be sent to the PRC1 task
83 msgForPRC.event = EVENT_SETS_NONE_PENDING; // this composite event will be sent to the PRC1 task
85 84 //
86 85 //****************************************
87 86
88 87 nodeForAveraging = getRingNodeForAveraging( 1 );
89 88
90 ring_node_tab[NB_SM_BEFORE_AVF1-1] = nodeForAveraging;
91 for ( i = 2; i < (NB_SM_BEFORE_AVF1+1); i++ )
89 ring_node_tab[NB_SM_BEFORE_AVF0_F1-1] = nodeForAveraging;
90 for ( i = 1; i < (NB_SM_BEFORE_AVF0_F1); i++ )
92 91 {
93 92 nodeForAveraging = nodeForAveraging->previous;
94 ring_node_tab[NB_SM_BEFORE_AVF1-i] = nodeForAveraging;
93 ring_node_tab[NB_SM_BEFORE_AVF0_F1-i] = nodeForAveraging;
95 94 }
96 95
97 96 // compute the average and store it in the averaged_sm_f1 buffer
@@ -102,11 +101,11 rtems_task avf1_task( rtems_task_argumen
102 101 &msgForPRC, 1 ); // 1 => frequency channel 1
103 102
104 103 // update nb_average
105 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF1;
106 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF1;
107 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF1;
108 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF1;
109 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF1;
104 nb_norm_bp1 = nb_norm_bp1 + NB_SM_BEFORE_AVF0_F1;
105 nb_norm_bp2 = nb_norm_bp2 + NB_SM_BEFORE_AVF0_F1;
106 nb_norm_asm = nb_norm_asm + NB_SM_BEFORE_AVF0_F1;
107 nb_sbm_bp1 = nb_sbm_bp1 + NB_SM_BEFORE_AVF0_F1;
108 nb_sbm_bp2 = nb_sbm_bp2 + NB_SM_BEFORE_AVF0_F1;
110 109
111 110 if (nb_sbm_bp1 == nb_sm_before_f1.burst_sbm_bp1)
112 111 {
@@ -170,7 +169,7 rtems_task avf1_task( rtems_task_argumen
170 169
171 170 //*************************
172 171 // send the message to PRC
173 if (msgForPRC.event != 0x00)
172 if (msgForPRC.event != EVENT_SETS_NONE_PENDING)
174 173 {
175 174 status = rtems_message_queue_send( queue_id_prc1, (char *) &msgForPRC, MSG_QUEUE_SIZE_PRC1);
176 175 }
@@ -365,13 +364,14 rtems_task prc1_task( rtems_task_argumen
365 364
366 365 void reset_nb_sm_f1( unsigned char lfrMode )
367 366 {
368 nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * 16;
369 nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * 16;
370 nb_sm_before_f1.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 16;
371 nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 16;
372 nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 16;
373 nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * 16;
374 nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * 16;
367 nb_sm_before_f1.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0 * NB_SM_PER_S_F1;
368 nb_sm_before_f1.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1 * NB_SM_PER_S_F1;
369 nb_sm_before_f1.norm_asm =
370 ( (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256) + parameter_dump_packet.sy_lfr_n_asm_p[1]) * NB_SM_PER_S_F1;
371 nb_sm_before_f1.sbm2_bp1 = parameter_dump_packet.sy_lfr_s2_bp_p0 * NB_SM_PER_S_F1;
372 nb_sm_before_f1.sbm2_bp2 = parameter_dump_packet.sy_lfr_s2_bp_p1 * NB_SM_PER_S_F1;
373 nb_sm_before_f1.burst_bp1 = parameter_dump_packet.sy_lfr_b_bp_p0 * NB_SM_PER_S_F1;
374 nb_sm_before_f1.burst_bp2 = parameter_dump_packet.sy_lfr_b_bp_p1 * NB_SM_PER_S_F1;
375 375
376 376 if (lfrMode == LFR_MODE_SBM2)
377 377 {
@@ -23,7 +23,6 int buffer_asm_f2 [ NB_
23 23 float asm_f2_patched_norm [ TOTAL_SIZE_SM ];
24 24 float asm_f2_reorganized [ TOTAL_SIZE_SM ];
25 25
26 char asm_f2_char [ TOTAL_SIZE_SM * 2 ];
27 26 float compressed_sm_norm_f2[ TOTAL_SIZE_COMPRESSED_ASM_NORM_F2];
28 27
29 28 float k_coeff_intercalib_f2[ NB_BINS_COMPRESSED_SM_F2 * NB_K_COEFF_PER_BIN ]; // 12 * 32 = 384
@@ -69,11 +68,11 rtems_task avf2_task( rtems_task_argumen
69 68 // initialize the mesage for the MATR task
70 69 msgForPRC.norm = current_ring_node_asm_norm_f2;
71 70 msgForPRC.burst_sbm = NULL;
72 msgForPRC.event = 0x00; // this composite event will be sent to the PRC2 task
71 msgForPRC.event = EVENT_SETS_NONE_PENDING; // this composite event will be sent to the PRC2 task
73 72 //
74 73 //****************************************
75 74
76 nodeForAveraging = getRingNodeForAveraging( 2 );
75 nodeForAveraging = getRingNodeForAveraging( CHANNELF2 );
77 76
78 77 // compute the average and store it in the averaged_sm_f2 buffer
79 78 SM_average_f2( current_ring_node_asm_norm_f2->matrix,
@@ -120,7 +119,7 rtems_task avf2_task( rtems_task_argumen
120 119
121 120 //*************************
122 121 // send the message to PRC2
123 if (msgForPRC.event != 0x00)
122 if (msgForPRC.event != EVENT_SETS_NONE_PENDING)
124 123 {
125 124 status = rtems_message_queue_send( queue_id_prc2, (char *) &msgForPRC, MSG_QUEUE_SIZE_PRC2);
126 125 }
@@ -253,7 +252,7 void reset_nb_sm_f2( void )
253 252 {
254 253 nb_sm_before_f2.norm_bp1 = parameter_dump_packet.sy_lfr_n_bp_p0;
255 254 nb_sm_before_f2.norm_bp2 = parameter_dump_packet.sy_lfr_n_bp_p1;
256 nb_sm_before_f2.norm_asm = parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1];
255 nb_sm_before_f2.norm_asm = (parameter_dump_packet.sy_lfr_n_asm_p[0] * CONST_256) + parameter_dump_packet.sy_lfr_n_asm_p[1];
257 256 }
258 257
259 258 void SM_average_f2( float *averaged_spec_mat_f2,
@@ -266,7 +265,7 void SM_average_f2( float *averaged_spec
266 265 unsigned char keepMatrix;
267 266
268 267 // test acquisitionTime validity
269 keepMatrix = acquisitionTimeIsValid( ring_node->coarseTime, ring_node->fineTime, 2 );
268 keepMatrix = acquisitionTimeIsValid( ring_node->coarseTime, ring_node->fineTime, CHANNELF2 );
270 269
271 270 for(i=0; i<TOTAL_SIZE_SM; i++)
272 271 {
@@ -279,7 +278,7 void SM_average_f2( float *averaged_spec
279 278 }
280 279 else // drop the matrix and initialize the average
281 280 {
282 averaged_spec_mat_f2[ i ] = 0.;
281 averaged_spec_mat_f2[ i ] = INIT_FLOAT;
283 282 }
284 283 msgForMATR->coarseTimeNORM = ring_node->coarseTime;
285 284 msgForMATR->fineTimeNORM = ring_node->fineTime;
@@ -42,13 +42,13 ring_node * getRingNodeForAveraging( uns
42 42
43 43 node = NULL;
44 44 switch ( frequencyChannel ) {
45 case 0:
45 case CHANNELF0:
46 46 node = ring_node_for_averaging_sm_f0;
47 47 break;
48 case 1:
48 case CHANNELF1:
49 49 node = ring_node_for_averaging_sm_f1;
50 50 break;
51 case 2:
51 case CHANNELF2:
52 52 node = ring_node_for_averaging_sm_f2;
53 53 break;
54 54 default:
@@ -67,18 +67,18 void spectral_matrices_isr_f0( int statu
67 67 rtems_status_code status_code;
68 68 ring_node *full_ring_node;
69 69
70 status = (unsigned char) (statusReg & 0x03); // [0011] get the status_ready_matrix_f0_x bits
70 status = (unsigned char) (statusReg & BITS_STATUS_F0); // [0011] get the status_ready_matrix_f0_x bits
71 71
72 72 switch(status)
73 73 {
74 74 case 0:
75 75 break;
76 case 3:
76 case BIT_READY_0_1:
77 77 // UNEXPECTED VALUE
78 spectral_matrix_regs->status = 0x03; // [0011]
78 spectral_matrix_regs->status = BIT_READY_0_1; // [0011]
79 79 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
80 80 break;
81 case 1:
81 case BIT_READY_0:
82 82 full_ring_node = current_ring_node_sm_f0->previous;
83 83 full_ring_node->coarseTime = spectral_matrix_regs->f0_0_coarse_time;
84 84 full_ring_node->fineTime = spectral_matrix_regs->f0_0_fine_time;
@@ -86,7 +86,7 void spectral_matrices_isr_f0( int statu
86 86 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
87 87 // if there are enough ring nodes ready, wake up an AVFx task
88 88 nb_sm_f0 = nb_sm_f0 + 1;
89 if (nb_sm_f0 == NB_SM_BEFORE_AVF0)
89 if (nb_sm_f0 == NB_SM_BEFORE_AVF0_F1)
90 90 {
91 91 ring_node_for_averaging_sm_f0 = full_ring_node;
92 92 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
@@ -95,9 +95,9 void spectral_matrices_isr_f0( int statu
95 95 }
96 96 nb_sm_f0 = 0;
97 97 }
98 spectral_matrix_regs->status = 0x01; // [0000 0001]
98 spectral_matrix_regs->status = BIT_READY_0; // [0000 0001]
99 99 break;
100 case 2:
100 case BIT_READY_1:
101 101 full_ring_node = current_ring_node_sm_f0->previous;
102 102 full_ring_node->coarseTime = spectral_matrix_regs->f0_1_coarse_time;
103 103 full_ring_node->fineTime = spectral_matrix_regs->f0_1_fine_time;
@@ -105,7 +105,7 void spectral_matrices_isr_f0( int statu
105 105 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
106 106 // if there are enough ring nodes ready, wake up an AVFx task
107 107 nb_sm_f0 = nb_sm_f0 + 1;
108 if (nb_sm_f0 == NB_SM_BEFORE_AVF0)
108 if (nb_sm_f0 == NB_SM_BEFORE_AVF0_F1)
109 109 {
110 110 ring_node_for_averaging_sm_f0 = full_ring_node;
111 111 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
@@ -114,7 +114,7 void spectral_matrices_isr_f0( int statu
114 114 }
115 115 nb_sm_f0 = 0;
116 116 }
117 spectral_matrix_regs->status = 0x02; // [0000 0010]
117 spectral_matrix_regs->status = BIT_READY_1; // [0000 0010]
118 118 break;
119 119 }
120 120 }
@@ -125,18 +125,18 void spectral_matrices_isr_f1( int statu
125 125 unsigned char status;
126 126 ring_node *full_ring_node;
127 127
128 status = (unsigned char) ((statusReg & 0x0c) >> 2); // [1100] get the status_ready_matrix_f1_x bits
128 status = (unsigned char) ((statusReg & BITS_STATUS_F1) >> SHIFT_2_BITS); // [1100] get the status_ready_matrix_f1_x bits
129 129
130 130 switch(status)
131 131 {
132 132 case 0:
133 133 break;
134 case 3:
134 case BIT_READY_0_1:
135 135 // UNEXPECTED VALUE
136 spectral_matrix_regs->status = 0xc0; // [1100]
136 spectral_matrix_regs->status = BITS_STATUS_F1; // [1100]
137 137 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
138 138 break;
139 case 1:
139 case BIT_READY_0:
140 140 full_ring_node = current_ring_node_sm_f1->previous;
141 141 full_ring_node->coarseTime = spectral_matrix_regs->f1_0_coarse_time;
142 142 full_ring_node->fineTime = spectral_matrix_regs->f1_0_fine_time;
@@ -144,7 +144,7 void spectral_matrices_isr_f1( int statu
144 144 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
145 145 // if there are enough ring nodes ready, wake up an AVFx task
146 146 nb_sm_f1 = nb_sm_f1 + 1;
147 if (nb_sm_f1 == NB_SM_BEFORE_AVF1)
147 if (nb_sm_f1 == NB_SM_BEFORE_AVF0_F1)
148 148 {
149 149 ring_node_for_averaging_sm_f1 = full_ring_node;
150 150 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
@@ -153,9 +153,9 void spectral_matrices_isr_f1( int statu
153 153 }
154 154 nb_sm_f1 = 0;
155 155 }
156 spectral_matrix_regs->status = 0x04; // [0000 0100]
156 spectral_matrix_regs->status = BIT_STATUS_F1_0; // [0000 0100]
157 157 break;
158 case 2:
158 case BIT_READY_1:
159 159 full_ring_node = current_ring_node_sm_f1->previous;
160 160 full_ring_node->coarseTime = spectral_matrix_regs->f1_1_coarse_time;
161 161 full_ring_node->fineTime = spectral_matrix_regs->f1_1_fine_time;
@@ -163,7 +163,7 void spectral_matrices_isr_f1( int statu
163 163 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
164 164 // if there are enough ring nodes ready, wake up an AVFx task
165 165 nb_sm_f1 = nb_sm_f1 + 1;
166 if (nb_sm_f1 == NB_SM_BEFORE_AVF1)
166 if (nb_sm_f1 == NB_SM_BEFORE_AVF0_F1)
167 167 {
168 168 ring_node_for_averaging_sm_f1 = full_ring_node;
169 169 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
@@ -172,7 +172,7 void spectral_matrices_isr_f1( int statu
172 172 }
173 173 nb_sm_f1 = 0;
174 174 }
175 spectral_matrix_regs->status = 0x08; // [1000 0000]
175 spectral_matrix_regs->status = BIT_STATUS_F1_1; // [1000 0000]
176 176 break;
177 177 }
178 178 }
@@ -182,36 +182,36 void spectral_matrices_isr_f2( int statu
182 182 unsigned char status;
183 183 rtems_status_code status_code;
184 184
185 status = (unsigned char) ((statusReg & 0x30) >> 4); // [0011 0000] get the status_ready_matrix_f2_x bits
185 status = (unsigned char) ((statusReg & BITS_STATUS_F2) >> SHIFT_4_BITS); // [0011 0000] get the status_ready_matrix_f2_x bits
186 186
187 187 switch(status)
188 188 {
189 189 case 0:
190 190 break;
191 case 3:
191 case BIT_READY_0_1:
192 192 // UNEXPECTED VALUE
193 spectral_matrix_regs->status = 0x30; // [0011 0000]
193 spectral_matrix_regs->status = BITS_STATUS_F2; // [0011 0000]
194 194 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
195 195 break;
196 case 1:
196 case BIT_READY_0:
197 197 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous;
198 198 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
199 199 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time;
200 200 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time;
201 201 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
202 spectral_matrix_regs->status = 0x10; // [0001 0000]
202 spectral_matrix_regs->status = BIT_STATUS_F2_0; // [0001 0000]
203 203 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
204 204 {
205 205 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
206 206 }
207 207 break;
208 case 2:
208 case BIT_READY_1:
209 209 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous;
210 210 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
211 211 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time;
212 212 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time;
213 213 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
214 spectral_matrix_regs->status = 0x20; // [0010 0000]
214 spectral_matrix_regs->status = BIT_STATUS_F2_1; // [0010 0000]
215 215 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
216 216 {
217 217 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
@@ -233,14 +233,14 void spectral_matrix_isr_error_handler(
233 233
234 234 //***************************************************
235 235 // the ASM status register is copied in the HK packet
236 housekeeping_packet.hk_lfr_vhdl_aa_sm = (unsigned char) (statusReg & 0x780 >> 7); // [0111 1000 0000]
236 housekeeping_packet.hk_lfr_vhdl_aa_sm = (unsigned char) ((statusReg & BITS_HK_AA_SM) >> SHIFT_7_BITS); // [0111 1000 0000]
237 237
238 if (statusReg & 0x7c0) // [0111 1100 0000]
238 if (statusReg & BITS_SM_ERR) // [0111 1100 0000]
239 239 {
240 240 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
241 241 }
242 242
243 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x7c0;
243 spectral_matrix_regs->status = spectral_matrix_regs->status & BITS_SM_ERR;
244 244
245 245 }
246 246
@@ -270,19 +270,19 rtems_isr spectral_matrices_isr( rtems_v
270 270 { // a restart sequence has to be launched
271 271 switch (state) {
272 272 case WAIT_FOR_F2:
273 if ((statusReg & 0x30) != 0x00) // [0011 0000] check the status_ready_matrix_f2_x bits
273 if ((statusReg & BITS_STATUS_F2) != INIT_CHAR) // [0011 0000] check the status_ready_matrix_f2_x bits
274 274 {
275 275 state = WAIT_FOR_F1;
276 276 }
277 277 break;
278 278 case WAIT_FOR_F1:
279 if ((statusReg & 0x0c) != 0x00) // [0000 1100] check the status_ready_matrix_f1_x bits
279 if ((statusReg & BITS_STATUS_F1) != INIT_CHAR) // [0000 1100] check the status_ready_matrix_f1_x bits
280 280 {
281 281 state = WAIT_FOR_F0;
282 282 }
283 283 break;
284 284 case WAIT_FOR_F0:
285 if ((statusReg & 0x03) != 0x00) // [0000 0011] check the status_ready_matrix_f0_x bits
285 if ((statusReg & BITS_STATUS_F0) != INIT_CHAR) // [0000 0011] check the status_ready_matrix_f0_x bits
286 286 {
287 287 state = WAIT_FOR_F2;
288 288 thisIsAnASMRestart = 0;
@@ -357,37 +357,37 void BP_init_header( bp_packet *packet,
357 357 {
358 358 packet->targetLogicalAddress = CCSDS_DESTINATION_ID;
359 359 packet->protocolIdentifier = CCSDS_PROTOCOLE_ID;
360 packet->reserved = 0x00;
360 packet->reserved = INIT_CHAR;
361 361 packet->userApplication = CCSDS_USER_APP;
362 packet->packetID[0] = (unsigned char) (apid >> 8);
362 packet->packetID[0] = (unsigned char) (apid >> SHIFT_1_BYTE);
363 363 packet->packetID[1] = (unsigned char) (apid);
364 364 packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
365 packet->packetSequenceControl[1] = 0x00;
366 packet->packetLength[0] = (unsigned char) (packetLength >> 8);
365 packet->packetSequenceControl[1] = INIT_CHAR;
366 packet->packetLength[0] = (unsigned char) (packetLength >> SHIFT_1_BYTE);
367 367 packet->packetLength[1] = (unsigned char) (packetLength);
368 368 // DATA FIELD HEADER
369 packet->spare1_pusVersion_spare2 = 0x10;
369 packet->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
370 370 packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type
371 371 packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype
372 372 packet->destinationID = TM_DESTINATION_ID_GROUND;
373 packet->time[0] = 0x00;
374 packet->time[1] = 0x00;
375 packet->time[2] = 0x00;
376 packet->time[3] = 0x00;
377 packet->time[4] = 0x00;
378 packet->time[5] = 0x00;
373 packet->time[BYTE_0] = INIT_CHAR;
374 packet->time[BYTE_1] = INIT_CHAR;
375 packet->time[BYTE_2] = INIT_CHAR;
376 packet->time[BYTE_3] = INIT_CHAR;
377 packet->time[BYTE_4] = INIT_CHAR;
378 packet->time[BYTE_5] = INIT_CHAR;
379 379 // AUXILIARY DATA HEADER
380 380 packet->sid = sid;
381 packet->pa_bia_status_info = 0x00;
382 packet->sy_lfr_common_parameters_spare = 0x00;
383 packet->sy_lfr_common_parameters = 0x00;
384 packet->acquisitionTime[0] = 0x00;
385 packet->acquisitionTime[1] = 0x00;
386 packet->acquisitionTime[2] = 0x00;
387 packet->acquisitionTime[3] = 0x00;
388 packet->acquisitionTime[4] = 0x00;
389 packet->acquisitionTime[5] = 0x00;
390 packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
381 packet->pa_bia_status_info = INIT_CHAR;
382 packet->sy_lfr_common_parameters_spare = INIT_CHAR;
383 packet->sy_lfr_common_parameters = INIT_CHAR;
384 packet->acquisitionTime[BYTE_0] = INIT_CHAR;
385 packet->acquisitionTime[BYTE_1] = INIT_CHAR;
386 packet->acquisitionTime[BYTE_2] = INIT_CHAR;
387 packet->acquisitionTime[BYTE_3] = INIT_CHAR;
388 packet->acquisitionTime[BYTE_4] = INIT_CHAR;
389 packet->acquisitionTime[BYTE_5] = INIT_CHAR;
390 packet->pa_lfr_bp_blk_nr[0] = INIT_CHAR; // BLK_NR MSB
391 391 packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
392 392 }
393 393
@@ -397,32 +397,32 void BP_init_header_with_spare( bp_packe
397 397 {
398 398 packet->targetLogicalAddress = CCSDS_DESTINATION_ID;
399 399 packet->protocolIdentifier = CCSDS_PROTOCOLE_ID;
400 packet->reserved = 0x00;
400 packet->reserved = INIT_CHAR;
401 401 packet->userApplication = CCSDS_USER_APP;
402 packet->packetID[0] = (unsigned char) (apid >> 8);
402 packet->packetID[0] = (unsigned char) (apid >> SHIFT_1_BYTE);
403 403 packet->packetID[1] = (unsigned char) (apid);
404 404 packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
405 packet->packetSequenceControl[1] = 0x00;
406 packet->packetLength[0] = (unsigned char) (packetLength >> 8);
405 packet->packetSequenceControl[1] = INIT_CHAR;
406 packet->packetLength[0] = (unsigned char) (packetLength >> SHIFT_1_BYTE);
407 407 packet->packetLength[1] = (unsigned char) (packetLength);
408 408 // DATA FIELD HEADER
409 packet->spare1_pusVersion_spare2 = 0x10;
409 packet->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
410 410 packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type
411 411 packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype
412 412 packet->destinationID = TM_DESTINATION_ID_GROUND;
413 413 // AUXILIARY DATA HEADER
414 414 packet->sid = sid;
415 packet->pa_bia_status_info = 0x00;
416 packet->sy_lfr_common_parameters_spare = 0x00;
417 packet->sy_lfr_common_parameters = 0x00;
418 packet->time[0] = 0x00;
419 packet->time[0] = 0x00;
420 packet->time[0] = 0x00;
421 packet->time[0] = 0x00;
422 packet->time[0] = 0x00;
423 packet->time[0] = 0x00;
424 packet->source_data_spare = 0x00;
425 packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
415 packet->pa_bia_status_info = INIT_CHAR;
416 packet->sy_lfr_common_parameters_spare = INIT_CHAR;
417 packet->sy_lfr_common_parameters = INIT_CHAR;
418 packet->time[BYTE_0] = INIT_CHAR;
419 packet->time[BYTE_1] = INIT_CHAR;
420 packet->time[BYTE_2] = INIT_CHAR;
421 packet->time[BYTE_3] = INIT_CHAR;
422 packet->time[BYTE_4] = INIT_CHAR;
423 packet->time[BYTE_5] = INIT_CHAR;
424 packet->source_data_spare = INIT_CHAR;
425 packet->pa_lfr_bp_blk_nr[0] = INIT_CHAR; // BLK_NR MSB
426 426 packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
427 427 }
428 428
@@ -477,7 +477,7 void reset_sm_status( void )
477 477 // ---------- 5 -- 4 -- 3 -- 2 -- 1 -- 0 --
478 478 // ready bits f2_1 f2_0 f1_1 f1_1 f0_1 f0_0
479 479
480 spectral_matrix_regs->status = 0x7ff; // [0111 1111 1111]
480 spectral_matrix_regs->status = BITS_STATUS_REG; // [0111 1111 1111]
481 481 }
482 482
483 483 void reset_spectral_matrix_regs( void )
@@ -511,29 +511,30 void reset_spectral_matrix_regs( void )
511 511 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address;
512 512 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
513 513
514 spectral_matrix_regs->matrix_length = 0xc8; // 25 * 128 / 16 = 200 = 0xc8
514 spectral_matrix_regs->matrix_length = DEFAULT_MATRIX_LENGTH; // 25 * 128 / 16 = 200 = 0xc8
515 515 }
516 516
517 517 void set_time( unsigned char *time, unsigned char * timeInBuffer )
518 518 {
519 time[0] = timeInBuffer[0];
520 time[1] = timeInBuffer[1];
521 time[2] = timeInBuffer[2];
522 time[3] = timeInBuffer[3];
523 time[4] = timeInBuffer[6];
524 time[5] = timeInBuffer[7];
519 time[BYTE_0] = timeInBuffer[BYTE_0];
520 time[BYTE_1] = timeInBuffer[BYTE_1];
521 time[BYTE_2] = timeInBuffer[BYTE_2];
522 time[BYTE_3] = timeInBuffer[BYTE_3];
523 time[BYTE_4] = timeInBuffer[BYTE_6];
524 time[BYTE_5] = timeInBuffer[BYTE_7];
525 525 }
526 526
527 527 unsigned long long int get_acquisition_time( unsigned char *timePtr )
528 528 {
529 529 unsigned long long int acquisitionTimeAslong;
530 acquisitionTimeAslong = 0x00;
531 acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
532 + ( (unsigned long long int) timePtr[1] << 32 )
533 + ( (unsigned long long int) timePtr[2] << 24 )
534 + ( (unsigned long long int) timePtr[3] << 16 )
535 + ( (unsigned long long int) timePtr[6] << 8 )
536 + ( (unsigned long long int) timePtr[7] );
530 acquisitionTimeAslong = INIT_CHAR;
531 acquisitionTimeAslong =
532 ( (unsigned long long int) (timePtr[BYTE_0] & SYNC_BIT_MASK) << SHIFT_5_BYTES ) // [0111 1111] mask the synchronization bit
533 + ( (unsigned long long int) timePtr[BYTE_1] << SHIFT_4_BYTES )
534 + ( (unsigned long long int) timePtr[BYTE_2] << SHIFT_3_BYTES )
535 + ( (unsigned long long int) timePtr[BYTE_3] << SHIFT_2_BYTES )
536 + ( (unsigned long long int) timePtr[BYTE_6] << SHIFT_1_BYTE )
537 + ( (unsigned long long int) timePtr[BYTE_7] );
537 538 return acquisitionTimeAslong;
538 539 }
539 540
@@ -581,10 +582,10 void extractReImVectors( float *inputASM
581 582 float im;
582 583
583 584 for (i=0; i<NB_BINS_PER_SM; i++){
584 re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 ];
585 im = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 + 1];
586 outputASM[ (asmComponent *NB_BINS_PER_SM) + i] = re;
587 outputASM[ (asmComponent+1)*NB_BINS_PER_SM + i] = im;
585 re = inputASM[ (asmComponent*NB_BINS_PER_SM) + (i * SM_BYTES_PER_VAL) ];
586 im = inputASM[ (asmComponent*NB_BINS_PER_SM) + (i * SM_BYTES_PER_VAL) + 1];
587 outputASM[ ( asmComponent *NB_BINS_PER_SM) + i] = re;
588 outputASM[ ((asmComponent+1)*NB_BINS_PER_SM) + i] = im;
588 589 }
589 590 }
590 591
@@ -601,22 +602,22 void copyReVectors( float *inputASM, flo
601 602
602 603 void ASM_patch( float *inputASM, float *outputASM )
603 604 {
604 extractReImVectors( inputASM, outputASM, 1); // b1b2
605 extractReImVectors( inputASM, outputASM, 3 ); // b1b3
606 extractReImVectors( inputASM, outputASM, 5 ); // b1e1
607 extractReImVectors( inputASM, outputASM, 7 ); // b1e2
608 extractReImVectors( inputASM, outputASM, 10 ); // b2b3
609 extractReImVectors( inputASM, outputASM, 12 ); // b2e1
610 extractReImVectors( inputASM, outputASM, 14 ); // b2e2
611 extractReImVectors( inputASM, outputASM, 17 ); // b3e1
612 extractReImVectors( inputASM, outputASM, 19 ); // b3e2
613 extractReImVectors( inputASM, outputASM, 22 ); // e1e2
605 extractReImVectors( inputASM, outputASM, ASM_COMP_B1B2); // b1b2
606 extractReImVectors( inputASM, outputASM, ASM_COMP_B1B3 ); // b1b3
607 extractReImVectors( inputASM, outputASM, ASM_COMP_B1E1 ); // b1e1
608 extractReImVectors( inputASM, outputASM, ASM_COMP_B1E2 ); // b1e2
609 extractReImVectors( inputASM, outputASM, ASM_COMP_B2B3 ); // b2b3
610 extractReImVectors( inputASM, outputASM, ASM_COMP_B2E1 ); // b2e1
611 extractReImVectors( inputASM, outputASM, ASM_COMP_B2E2 ); // b2e2
612 extractReImVectors( inputASM, outputASM, ASM_COMP_B3E1 ); // b3e1
613 extractReImVectors( inputASM, outputASM, ASM_COMP_B3E2 ); // b3e2
614 extractReImVectors( inputASM, outputASM, ASM_COMP_E1E2 ); // e1e2
614 615
615 copyReVectors(inputASM, outputASM, 0 ); // b1b1
616 copyReVectors(inputASM, outputASM, 9 ); // b2b2
617 copyReVectors(inputASM, outputASM, 16); // b3b3
618 copyReVectors(inputASM, outputASM, 21); // e1e1
619 copyReVectors(inputASM, outputASM, 24); // e2e2
616 copyReVectors(inputASM, outputASM, ASM_COMP_B1B1 ); // b1b1
617 copyReVectors(inputASM, outputASM, ASM_COMP_B2B2 ); // b2b2
618 copyReVectors(inputASM, outputASM, ASM_COMP_B3B3); // b3b3
619 copyReVectors(inputASM, outputASM, ASM_COMP_E1E1); // e1e1
620 copyReVectors(inputASM, outputASM, ASM_COMP_E2E2); // e2e2
620 621 }
621 622
622 623 void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
@@ -649,21 +650,20 void ASM_compress_reorganize_and_divide_
649 650 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
650 651 {
651 652 offsetCompressed = // NO TIME OFFSET
652 frequencyBin * NB_VALUES_PER_SM
653 (frequencyBin * NB_VALUES_PER_SM)
653 654 + asmComponent;
654 655 offsetASM = // NO TIME OFFSET
655 asmComponent * NB_BINS_PER_SM
656 (asmComponent * NB_BINS_PER_SM)
656 657 + ASMIndexStart
657 + frequencyBin * nbBinsToAverage;
658 + (frequencyBin * nbBinsToAverage);
658 659 offsetFBin = ASMIndexStart
659 + frequencyBin * nbBinsToAverage;
660 + (frequencyBin * nbBinsToAverage);
660 661 compressed_spec_mat[ offsetCompressed ] = 0;
661 662 for ( k = 0; k < nbBinsToAverage; k++ )
662 663 {
663 664 fBinMask = getFBinMask( offsetFBin + k, channel );
664 compressed_spec_mat[offsetCompressed ] =
665 ( compressed_spec_mat[ offsetCompressed ]
666 + averaged_spec_mat[ offsetASM + k ] * fBinMask );
665 compressed_spec_mat[offsetCompressed ] = compressed_spec_mat[ offsetCompressed ]
666 + (averaged_spec_mat[ offsetASM + k ] * fBinMask);
667 667 }
668 668 if (divider != 0)
669 669 {
@@ -671,7 +671,7 void ASM_compress_reorganize_and_divide_
671 671 }
672 672 else
673 673 {
674 compressed_spec_mat[ offsetCompressed ] = 0.0;
674 compressed_spec_mat[ offsetCompressed ] = INIT_FLOAT;
675 675 }
676 676 }
677 677 }
@@ -689,23 +689,23 int getFBinMask( int index, unsigned cha
689 689
690 690 switch(channel)
691 691 {
692 case 0:
692 case CHANNELF0:
693 693 sy_lfr_fbins_fx_word1 = fbins_masks.merged_fbins_mask_f0;
694 694 break;
695 case 1:
695 case CHANNELF1:
696 696 sy_lfr_fbins_fx_word1 = fbins_masks.merged_fbins_mask_f1;
697 697 break;
698 case 2:
698 case CHANNELF2:
699 699 sy_lfr_fbins_fx_word1 = fbins_masks.merged_fbins_mask_f2;
700 700 break;
701 701 default:
702 702 PRINTF("ERR *** in getFBinMask, wrong frequency channel")
703 703 }
704 704
705 indexInChar = index >> 3;
706 indexInTheChar = index - indexInChar * 8;
705 indexInChar = index >> SHIFT_3_BITS;
706 indexInTheChar = index - (indexInChar * BITS_PER_BYTE);
707 707
708 fbin = (int) ((sy_lfr_fbins_fx_word1[ NB_BYTES_PER_FREQ_MASK - 1 - indexInChar] >> indexInTheChar) & 0x1);
708 fbin = (int) ((sy_lfr_fbins_fx_word1[ BYTES_PER_MASK - 1 - indexInChar] >> indexInTheChar) & 1);
709 709
710 710 return fbin;
711 711 }
@@ -722,21 +722,21 unsigned char acquisitionTimeIsValid( un
722 722 unsigned char pasFilteringIsEnabled;
723 723 unsigned char ret;
724 724
725 pasFilteringIsEnabled = (filterPar.spare_sy_lfr_pas_filter_enabled & 0x01); // [0000 0001]
725 pasFilteringIsEnabled = (filterPar.spare_sy_lfr_pas_filter_enabled & 1); // [0000 0001]
726 726 ret = 1;
727 727
728 728 // compute acquisition time from caoarseTime and fineTime
729 acquisitionTime = ( ((u_int64_t)coarseTime) << 16 )
729 acquisitionTime = ( ((u_int64_t)coarseTime) << SHIFT_2_BYTES )
730 730 + (u_int64_t) fineTime;
731 731
732 732 // compute the timecode reference
733 timecodeReference = (u_int64_t) (floor( ((double) coarseTime) / ((double) filterPar.sy_lfr_pas_filter_modulus) )
734 * ((double) filterPar.sy_lfr_pas_filter_modulus)) * 65536;
733 timecodeReference = (u_int64_t) ( (floor( ((double) coarseTime) / ((double) filterPar.sy_lfr_pas_filter_modulus) )
734 * ((double) filterPar.sy_lfr_pas_filter_modulus)) * CONST_65536 );
735 735
736 736 // compute the acquitionTime range
737 offsetInFineTime = ((double) filterPar.sy_lfr_pas_filter_offset) * 65536;
738 shiftInFineTime = ((double) filterPar.sy_lfr_pas_filter_shift) * 65536;
739 tBadInFineTime = ((double) filterPar.sy_lfr_pas_filter_tbad) * 65536;
737 offsetInFineTime = ((double) filterPar.sy_lfr_pas_filter_offset) * CONST_65536;
738 shiftInFineTime = ((double) filterPar.sy_lfr_pas_filter_shift) * CONST_65536;
739 tBadInFineTime = ((double) filterPar.sy_lfr_pas_filter_tbad) * CONST_65536;
740 740
741 741 acquisitionTimeRangeMin =
742 742 timecodeReference
@@ -785,8 +785,10 void init_kcoeff_sbm_from_kcoeff_norm(fl
785 785 {
786 786 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
787 787 {
788 output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ];
789 output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 + 1 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ];
788 output_kcoeff[ ( ( bin * NB_K_COEFF_PER_BIN ) + kcoeff ) * SBM_COEFF_PER_NORM_COEFF ]
789 = input_kcoeff[ (bin*NB_K_COEFF_PER_BIN) + kcoeff ];
790 output_kcoeff[ ( ( bin * NB_K_COEFF_PER_BIN ) + kcoeff ) * SBM_COEFF_PER_NORM_COEFF + 1 ]
791 = input_kcoeff[ (bin*NB_K_COEFF_PER_BIN) + kcoeff ];
790 792 }
791 793 }
792 794 }
@@ -10,7 +10,7
10 10 #include "tc_acceptance.h"
11 11 #include <stdio.h>
12 12
13 unsigned int lookUpTableForCRC[256];
13 unsigned int lookUpTableForCRC[CONST_256];
14 14
15 15 //**********************
16 16 // GENERAL USE FUNCTIONS
@@ -25,7 +25,7 unsigned int Crc_opt( unsigned char D, u
25 25 *
26 26 */
27 27
28 return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]);
28 return(((Chk << SHIFT_1_BYTE) & BYTE0_MASK)^lookUpTableForCRC [(((Chk >> SHIFT_1_BYTE)^D) & BYTE1_MASK)]);
29 29 }
30 30
31 31 void initLookUpTableForCRC( void )
@@ -39,32 +39,32 void initLookUpTableForCRC( void )
39 39 unsigned int i;
40 40 unsigned int tmp;
41 41
42 for (i=0; i<256; i++)
42 for (i=0; i<CONST_256; i++)
43 43 {
44 44 tmp = 0;
45 if((i & 1) != 0) {
46 tmp = tmp ^ 0x1021;
45 if((i & BIT_0) != 0) {
46 tmp = tmp ^ CONST_CRC_0;
47 47 }
48 if((i & 2) != 0) {
49 tmp = tmp ^ 0x2042;
48 if((i & BIT_1) != 0) {
49 tmp = tmp ^ CONST_CRC_1;
50 50 }
51 if((i & 4) != 0) {
52 tmp = tmp ^ 0x4084;
51 if((i & BIT_2) != 0) {
52 tmp = tmp ^ CONST_CRC_2;
53 53 }
54 if((i & 8) != 0) {
55 tmp = tmp ^ 0x8108;
54 if((i & BIT_3) != 0) {
55 tmp = tmp ^ CONST_CRC_3;
56 56 }
57 if((i & 16) != 0) {
58 tmp = tmp ^ 0x1231;
57 if((i & BIT_4) != 0) {
58 tmp = tmp ^ CONST_CRC_4;
59 59 }
60 if((i & 32) != 0) {
61 tmp = tmp ^ 0x2462;
60 if((i & BIT_5) != 0) {
61 tmp = tmp ^ CONST_CRC_5;
62 62 }
63 if((i & 64) != 0) {
64 tmp = tmp ^ 0x48c4;
63 if((i & BIT_6) != 0) {
64 tmp = tmp ^ CONST_CRC_6;
65 65 }
66 if((i & 128) != 0) {
67 tmp = tmp ^ 0x9188;
66 if((i & BIT_7) != 0) {
67 tmp = tmp ^ CONST_CRC_7;
68 68 }
69 69 lookUpTableForCRC[i] = tmp;
70 70 }
@@ -84,12 +84,12 void GetCRCAsTwoBytes(unsigned char* dat
84 84
85 85 unsigned int Chk;
86 86 int j;
87 Chk = 0xffff; // reset the syndrom to all ones
87 Chk = CRC_RESET; // reset the syndrom to all ones
88 88 for (j=0; j<sizeOfData; j++) {
89 89 Chk = Crc_opt(data[j], Chk);
90 90 }
91 crcAsTwoBytes[0] = (unsigned char) (Chk >> 8);
92 crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff);
91 crcAsTwoBytes[0] = (unsigned char) (Chk >> SHIFT_1_BYTE);
92 crcAsTwoBytes[1] = (unsigned char) (Chk & BYTE1_MASK);
93 93 }
94 94
95 95 //*********************
@@ -125,9 +125,10 int tc_parser(ccsdsTelecommandPacket_t *
125 125 status = CCSDS_TM_VALID;
126 126
127 127 // APID check *** APID on 2 bytes
128 pid = ((TCPacket->packetID[0] & 0x07)<<4) + ( (TCPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx
129 category = (TCPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210
130 packetLength = (TCPacket->packetLength[0] * 256) + TCPacket->packetLength[1];
128 pid = ((TCPacket->packetID[0] & BITS_PID_0) << SHIFT_4_BITS)
129 + ( (TCPacket->packetID[1] >> SHIFT_4_BITS) & BITS_PID_1 ); // PID = 11 *** 7 bits xxxxx210 7654xxxx
130 category = (TCPacket->packetID[1] & BITS_CAT); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210
131 packetLength = (TCPacket->packetLength[0] * CONST_256) + TCPacket->packetLength[1];
131 132 packetType = TCPacket->serviceType;
132 133 packetSubtype = TCPacket->serviceSubType;
133 134 sid = TCPacket->sourceID;
@@ -455,9 +456,9 int tc_check_crc( ccsdsTelecommandPacket
455 456 unsigned char * CCSDSContent;
456 457
457 458 CCSDSContent = (unsigned char*) TCPacket->packetID;
458 GetCRCAsTwoBytes(CCSDSContent, computed_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC
459 GetCRCAsTwoBytes(CCSDSContent, computed_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - BYTES_PER_CRC); // 2 CRC bytes removed from the calculation of the CRC
459 460
460 if (computed_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) {
461 if (computed_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET - BYTES_PER_CRC]) {
461 462 status = INCOR_CHECKSUM;
462 463 }
463 464 else if (computed_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) {
@@ -32,7 +32,7 rtems_task actn_task( rtems_task_argumen
32 32 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
33 33 size_t size; // size of the incoming TC packet
34 34 unsigned char subtype; // subtype of the current TC packet
35 unsigned char time[6];
35 unsigned char time[BYTES_PER_TIME];
36 36 rtems_id queue_rcv_id;
37 37 rtems_id queue_snd_id;
38 38
@@ -177,7 +177,7 int action_enter_mode(ccsdsTelecommandPa
177 177
178 178 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
179 179 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
180 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
180 transitionCoarseTime = (*transitionCoarseTime_ptr) & COARSE_TIME_MASK;
181 181
182 182 status = check_mode_value( requestedMode );
183 183
@@ -262,24 +262,24 int action_update_info(ccsdsTelecommandP
262 262 bytePosPtr = (unsigned char *) &TC->packetID;
263 263
264 264 // check LFR mode
265 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
265 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & BITS_LFR_MODE) >> SHIFT_LFR_MODE;
266 266 status = check_update_info_hk_lfr_mode( mode );
267 267 if (status == LFR_SUCCESSFUL) // check TDS mode
268 268 {
269 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
269 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & BITS_TDS_MODE) >> SHIFT_TDS_MODE;
270 270 status = check_update_info_hk_tds_mode( mode );
271 271 }
272 272 if (status == LFR_SUCCESSFUL) // check THR mode
273 273 {
274 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
274 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & BITS_THR_MODE);
275 275 status = check_update_info_hk_thr_mode( mode );
276 276 }
277 277 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
278 278 {
279 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
279 val = (housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * CONST_256)
280 280 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
281 281 val++;
282 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
282 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE);
283 283 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
284 284 }
285 285
@@ -290,9 +290,9 int action_update_info(ccsdsTelecommandP
290 290 // => pa_bia_mode_bias2_enabled 1 bit
291 291 // => pa_bia_mode_bias3_enabled 1 bit
292 292 // => pa_bia_on_off (cp_dpu_bias_on_off)
293 pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & 0xfe; // [1111 1110]
293 pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & BITS_BIA; // [1111 1110]
294 294 pa_bia_status_info = pa_bia_status_info
295 | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1);
295 | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 1);
296 296
297 297 // REACTION_WHEELS_FREQUENCY, copy the incoming parameters in the local variable (to be copied in HK packets)
298 298
@@ -361,15 +361,15 int action_update_time(ccsdsTelecommandP
361 361
362 362 unsigned int val;
363 363
364 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
365 + (TC->dataAndCRC[1] << 16)
366 + (TC->dataAndCRC[2] << 8)
367 + TC->dataAndCRC[3];
364 time_management_regs->coarse_time_load = (TC->dataAndCRC[BYTE_0] << SHIFT_3_BYTES)
365 + (TC->dataAndCRC[BYTE_1] << SHIFT_2_BYTES)
366 + (TC->dataAndCRC[BYTE_2] << SHIFT_1_BYTE)
367 + TC->dataAndCRC[BYTE_3];
368 368
369 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
369 val = (housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * CONST_256)
370 370 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
371 371 val++;
372 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
372 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE);
373 373 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
374 374
375 375 oneTcLfrUpdateTimeReceived = 1;
@@ -490,7 +490,7 int check_transition_date( unsigned int
490 490 }
491 491 else
492 492 {
493 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
493 localCoarseTime = time_management_regs->coarse_time & COARSE_TIME_MASK;
494 494
495 495 PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime);
496 496
@@ -503,7 +503,7 int check_transition_date( unsigned int
503 503 if (status == LFR_SUCCESSFUL)
504 504 {
505 505 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
506 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
506 if ( deltaCoarseTime > MAX_DELTA_COARSE_TIME ) // SSS-CP-EQS-323
507 507 {
508 508 status = LFR_DEFAULT;
509 509 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
@@ -906,76 +906,76 int restart_science_tasks( unsigned char
906 906 *
907 907 */
908 908
909 rtems_status_code status[10];
909 rtems_status_code status[NB_SCIENCE_TASKS];
910 910 rtems_status_code ret;
911 911
912 912 ret = RTEMS_SUCCESSFUL;
913 913
914 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
915 if (status[0] != RTEMS_SUCCESSFUL)
914 status[STATUS_0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
915 if (status[STATUS_0] != RTEMS_SUCCESSFUL)
916 916 {
917 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
917 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[STATUS_0])
918 918 }
919 919
920 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
921 if (status[1] != RTEMS_SUCCESSFUL)
920 status[STATUS_1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
921 if (status[STATUS_1] != RTEMS_SUCCESSFUL)
922 922 {
923 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
923 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[STATUS_1])
924 924 }
925 925
926 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
927 if (status[2] != RTEMS_SUCCESSFUL)
926 status[STATUS_2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
927 if (status[STATUS_2] != RTEMS_SUCCESSFUL)
928 928 {
929 PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2])
929 PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[STATUS_2])
930 930 }
931 931
932 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
933 if (status[3] != RTEMS_SUCCESSFUL)
932 status[STATUS_3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
933 if (status[STATUS_3] != RTEMS_SUCCESSFUL)
934 934 {
935 PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3])
935 PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[STATUS_3])
936 936 }
937 937
938 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
939 if (status[4] != RTEMS_SUCCESSFUL)
938 status[STATUS_4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
939 if (status[STATUS_4] != RTEMS_SUCCESSFUL)
940 940 {
941 PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4])
941 PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[STATUS_4])
942 942 }
943 943
944 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
945 if (status[5] != RTEMS_SUCCESSFUL)
944 status[STATUS_5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
945 if (status[STATUS_5] != RTEMS_SUCCESSFUL)
946 946 {
947 PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5])
947 PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[STATUS_5])
948 948 }
949 949
950 status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
951 if (status[6] != RTEMS_SUCCESSFUL)
950 status[STATUS_6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
951 if (status[STATUS_6] != RTEMS_SUCCESSFUL)
952 952 {
953 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6])
953 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[STATUS_6])
954 954 }
955 955
956 status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
957 if (status[7] != RTEMS_SUCCESSFUL)
956 status[STATUS_7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
957 if (status[STATUS_7] != RTEMS_SUCCESSFUL)
958 958 {
959 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7])
959 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[STATUS_7])
960 960 }
961 961
962 status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
963 if (status[8] != RTEMS_SUCCESSFUL)
962 status[STATUS_8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
963 if (status[STATUS_8] != RTEMS_SUCCESSFUL)
964 964 {
965 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8])
965 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[STATUS_8])
966 966 }
967 967
968 status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
969 if (status[9] != RTEMS_SUCCESSFUL)
968 status[STATUS_9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
969 if (status[STATUS_9] != RTEMS_SUCCESSFUL)
970 970 {
971 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9])
971 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[STATUS_9])
972 972 }
973 973
974 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
975 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
976 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ||
977 (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) ||
978 (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) )
974 if ( (status[STATUS_0] != RTEMS_SUCCESSFUL) || (status[STATUS_1] != RTEMS_SUCCESSFUL) ||
975 (status[STATUS_2] != RTEMS_SUCCESSFUL) || (status[STATUS_3] != RTEMS_SUCCESSFUL) ||
976 (status[STATUS_4] != RTEMS_SUCCESSFUL) || (status[STATUS_5] != RTEMS_SUCCESSFUL) ||
977 (status[STATUS_6] != RTEMS_SUCCESSFUL) || (status[STATUS_7] != RTEMS_SUCCESSFUL) ||
978 (status[STATUS_8] != RTEMS_SUCCESSFUL) || (status[STATUS_9] != RTEMS_SUCCESSFUL) )
979 979 {
980 980 ret = RTEMS_UNSATISFIED;
981 981 }
@@ -997,50 +997,50 int restart_asm_tasks( unsigned char lfr
997 997 *
998 998 */
999 999
1000 rtems_status_code status[6];
1000 rtems_status_code status[NB_ASM_TASKS];
1001 1001 rtems_status_code ret;
1002 1002
1003 1003 ret = RTEMS_SUCCESSFUL;
1004 1004
1005 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
1006 if (status[0] != RTEMS_SUCCESSFUL)
1005 status[STATUS_0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
1006 if (status[STATUS_0] != RTEMS_SUCCESSFUL)
1007 1007 {
1008 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
1008 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[STATUS_0])
1009 1009 }
1010 1010
1011 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
1012 if (status[1] != RTEMS_SUCCESSFUL)
1011 status[STATUS_1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
1012 if (status[STATUS_1] != RTEMS_SUCCESSFUL)
1013 1013 {
1014 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
1014 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[STATUS_1])
1015 1015 }
1016 1016
1017 status[2] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
1018 if (status[2] != RTEMS_SUCCESSFUL)
1017 status[STATUS_2] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
1018 if (status[STATUS_2] != RTEMS_SUCCESSFUL)
1019 1019 {
1020 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[2])
1020 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[STATUS_2])
1021 1021 }
1022 1022
1023 status[3] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
1024 if (status[3] != RTEMS_SUCCESSFUL)
1023 status[STATUS_3] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
1024 if (status[STATUS_3] != RTEMS_SUCCESSFUL)
1025 1025 {
1026 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[3])
1026 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[STATUS_3])
1027 1027 }
1028 1028
1029 status[4] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
1030 if (status[4] != RTEMS_SUCCESSFUL)
1029 status[STATUS_4] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
1030 if (status[STATUS_4] != RTEMS_SUCCESSFUL)
1031 1031 {
1032 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[4])
1032 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[STATUS_4])
1033 1033 }
1034 1034
1035 status[5] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
1036 if (status[5] != RTEMS_SUCCESSFUL)
1035 status[STATUS_5] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
1036 if (status[STATUS_5] != RTEMS_SUCCESSFUL)
1037 1037 {
1038 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[5])
1038 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[STATUS_5])
1039 1039 }
1040 1040
1041 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
1042 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
1043 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
1041 if ( (status[STATUS_0] != RTEMS_SUCCESSFUL) || (status[STATUS_1] != RTEMS_SUCCESSFUL) ||
1042 (status[STATUS_2] != RTEMS_SUCCESSFUL) || (status[STATUS_3] != RTEMS_SUCCESSFUL) ||
1043 (status[STATUS_4] != RTEMS_SUCCESSFUL) || (status[STATUS_5] != RTEMS_SUCCESSFUL) )
1044 1044 {
1045 1045 ret = RTEMS_UNSATISFIED;
1046 1046 }
@@ -1323,11 +1323,11 void set_sm_irq_onNewMatrix( unsigned ch
1323 1323 {
1324 1324 if (value == 1)
1325 1325 {
1326 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
1326 spectral_matrix_regs->config = spectral_matrix_regs->config | BIT_IRQ_ON_NEW_MATRIX;
1327 1327 }
1328 1328 else
1329 1329 {
1330 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
1330 spectral_matrix_regs->config = spectral_matrix_regs->config & MASK_IRQ_ON_NEW_MATRIX; // 1110
1331 1331 }
1332 1332 }
1333 1333
@@ -1335,11 +1335,11 void set_sm_irq_onError( unsigned char v
1335 1335 {
1336 1336 if (value == 1)
1337 1337 {
1338 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02;
1338 spectral_matrix_regs->config = spectral_matrix_regs->config | BIT_IRQ_ON_ERROR;
1339 1339 }
1340 1340 else
1341 1341 {
1342 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101
1342 spectral_matrix_regs->config = spectral_matrix_regs->config & MASK_IRQ_ON_ERROR; // 1101
1343 1343 }
1344 1344 }
1345 1345
@@ -1358,67 +1358,75 void setCalibrationDivisor( unsigned int
1358 1358 time_management_regs->calDivisor = divisionFactor;
1359 1359 }
1360 1360
1361 void setCalibrationData( void ){
1361 void setCalibrationData( void )
1362 {
1363 /** This function is used to store the values used to drive the DAC in order to generate the SCM calibration signal
1364 *
1365 * @param void
1366 *
1367 * @return void
1368 *
1369 */
1370
1362 1371 unsigned int k;
1363 1372 unsigned short data;
1364 1373 float val;
1365 float f0;
1366 float f1;
1367 float fs;
1368 1374 float Ts;
1369 float scaleFactor;
1370 1375
1371 f0 = 625;
1372 f1 = 10000;
1373 fs = 160256.410;
1374 Ts = 1. / fs;
1375 scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV
1376
1377 time_management_regs->calDataPtr = 0x00;
1376 time_management_regs->calDataPtr = INIT_CHAR;
1378 1377
1379 1378 // build the signal for the SCM calibration
1380 for (k=0; k<256; k++)
1379 for (k = 0; k < CAL_NB_PTS; k++)
1381 1380 {
1382 val = sin( 2 * pi * f0 * k * Ts )
1383 + sin( 2 * pi * f1 * k * Ts );
1384 data = (unsigned short) ((val * scaleFactor) + 2048);
1385 time_management_regs->calData = data & 0xfff;
1381 val = sin( 2 * pi * CAL_F0 * k * Ts )
1382 + sin( 2 * pi * CAL_F1 * k * Ts );
1383 data = (unsigned short) ((val * CAL_SCALE_FACTOR) + CONST_2048);
1384 time_management_regs->calData = data & CAL_DATA_MASK;
1386 1385 }
1387 1386 }
1388 1387
1389 void setCalibrationDataInterleaved( void ){
1388 void setCalibrationDataInterleaved( void )
1389 {
1390 /** This function is used to store the values used to drive the DAC in order to generate the SCM calibration signal
1391 *
1392 * @param void
1393 *
1394 * @return void
1395 *
1396 * In interleaved mode, one can store more values than in normal mode.
1397 * The data are stored in bunch of 18 bits, 12 bits from one sample and 6 bits from another sample.
1398 * T store 3 values, one need two write operations.
1399 * s1 [ b11 b10 b9 b8 b7 b6 ] s0 [ b11 b10 b9 b8 b7 b6 b5 b3 b2 b1 b0 ]
1400 * s1 [ b5 b4 b3 b2 b1 b0 ] s2 [ b11 b10 b9 b8 b7 b6 b5 b3 b2 b1 b0 ]
1401 *
1402 */
1403
1390 1404 unsigned int k;
1391 1405 float val;
1392 float f0;
1393 float f1;
1394 float fs;
1395 1406 float Ts;
1396 unsigned short data[384];
1407 unsigned short data[CAL_NB_PTS_INTER];
1397 1408 unsigned char *dataPtr;
1398 1409
1399 f0 = 625;
1400 f1 = 10000;
1401 fs = 240384.615;
1402 Ts = 1. / fs;
1410 Ts = 1. / CAL_FS_INTER;
1403 1411
1404 time_management_regs->calDataPtr = 0x00;
1412 time_management_regs->calDataPtr = INIT_CHAR;
1405 1413
1406 1414 // build the signal for the SCM calibration
1407 for (k=0; k<384; k++)
1415 for (k=0; k<CAL_NB_PTS_INTER; k++)
1408 1416 {
1409 val = sin( 2 * pi * f0 * k * Ts )
1410 + sin( 2 * pi * f1 * k * Ts );
1411 data[k] = (unsigned short) (val * 512 + 2048);
1417 val = sin( 2 * pi * CAL_F0 * k * Ts )
1418 + sin( 2 * pi * CAL_F1 * k * Ts );
1419 data[k] = (unsigned short) ((val * CONST_512) + CONST_2048);
1412 1420 }
1413 1421
1414 1422 // write the signal in interleaved mode
1415 for (k=0; k<128; k++)
1423 for (k=0; k < STEPS_FOR_STORAGE_INTER; k++)
1416 1424 {
1417 dataPtr = (unsigned char*) &data[k*3 + 2];
1418 time_management_regs->calData = (data[k*3] & 0xfff)
1419 + ( (dataPtr[0] & 0x3f) << 12);
1420 time_management_regs->calData = (data[k*3 + 1] & 0xfff)
1421 + ( (dataPtr[1] & 0x3f) << 12);
1425 dataPtr = (unsigned char*) &data[ (k * BYTES_FOR_2_SAMPLES) + 2 ];
1426 time_management_regs->calData = ( data[ k * BYTES_FOR_2_SAMPLES ] & CAL_DATA_MASK )
1427 + ( (dataPtr[0] & CAL_DATA_MASK_INTER) << CAL_DATA_SHIFT_INTER);
1428 time_management_regs->calData = ( data[(k * BYTES_FOR_2_SAMPLES) + 1] & CAL_DATA_MASK )
1429 + ( (dataPtr[1] & CAL_DATA_MASK_INTER) << CAL_DATA_SHIFT_INTER);
1422 1430 }
1423 1431 }
1424 1432
@@ -1426,11 +1434,11 void setCalibrationReload( bool state)
1426 1434 {
1427 1435 if (state == true)
1428 1436 {
1429 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000]
1437 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | BIT_CAL_RELOAD; // [0001 0000]
1430 1438 }
1431 1439 else
1432 1440 {
1433 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111]
1441 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & MASK_CAL_RELOAD; // [1110 1111]
1434 1442 }
1435 1443 }
1436 1444
@@ -1439,11 +1447,11 void setCalibrationEnable( bool state )
1439 1447 // this bit drives the multiplexer
1440 1448 if (state == true)
1441 1449 {
1442 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000]
1450 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | BIT_CAL_ENABLE; // [0100 0000]
1443 1451 }
1444 1452 else
1445 1453 {
1446 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111]
1454 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & MASK_CAL_ENABLE; // [1011 1111]
1447 1455 }
1448 1456 }
1449 1457
@@ -1452,11 +1460,11 void setCalibrationInterleaved( bool sta
1452 1460 // this bit drives the multiplexer
1453 1461 if (state == true)
1454 1462 {
1455 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000]
1463 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | BIT_SET_INTERLEAVED; // [0010 0000]
1456 1464 }
1457 1465 else
1458 1466 {
1459 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111]
1467 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & MASK_SET_INTERLEAVED; // [1101 1111]
1460 1468 }
1461 1469 }
1462 1470
@@ -1482,14 +1490,14 void configureCalibration( bool interlea
1482 1490 if ( interleaved == true )
1483 1491 {
1484 1492 setCalibrationInterleaved( true );
1485 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1486 setCalibrationDivisor( 26 ); // => 240 384
1493 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1494 setCalibrationDivisor( CAL_F_DIVISOR_INTER ); // => 240 384
1487 1495 setCalibrationDataInterleaved();
1488 1496 }
1489 1497 else
1490 1498 {
1491 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1492 setCalibrationDivisor( 38 ); // => 160 256 (39 - 1)
1499 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1500 setCalibrationDivisor( CAL_F_DIVISOR ); // => 160 256 (39 - 1)
1493 1501 setCalibrationData();
1494 1502 }
1495 1503 }
@@ -1509,20 +1517,20 void update_last_TC_exe( ccsdsTelecomman
1509 1517
1510 1518 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
1511 1519 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
1512 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
1520 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = INIT_CHAR;
1513 1521 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
1514 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
1522 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = INIT_CHAR;
1515 1523 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
1516 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
1517 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
1518 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
1519 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
1520 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
1521 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
1524 housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_0] = time[BYTE_0];
1525 housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_1] = time[BYTE_1];
1526 housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_2] = time[BYTE_2];
1527 housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_3] = time[BYTE_3];
1528 housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_4] = time[BYTE_4];
1529 housekeeping_packet.hk_lfr_last_exe_tc_time[BYTE_5] = time[BYTE_5];
1522 1530
1523 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
1531 val = (housekeeping_packet.hk_lfr_exe_tc_cnt[0] * CONST_256) + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
1524 1532 val++;
1525 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
1533 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE);
1526 1534 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
1527 1535 }
1528 1536
@@ -1539,20 +1547,20 void update_last_TC_rej(ccsdsTelecommand
1539 1547
1540 1548 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
1541 1549 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
1542 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
1550 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = INIT_CHAR;
1543 1551 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
1544 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
1552 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = INIT_CHAR;
1545 1553 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
1546 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
1547 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
1548 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
1549 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
1550 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
1551 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
1554 housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_0] = time[BYTE_0];
1555 housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_1] = time[BYTE_1];
1556 housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_2] = time[BYTE_2];
1557 housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_3] = time[BYTE_3];
1558 housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_4] = time[BYTE_4];
1559 housekeeping_packet.hk_lfr_last_rej_tc_time[BYTE_5] = time[BYTE_5];
1552 1560
1553 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
1561 val = (housekeeping_packet.hk_lfr_rej_tc_cnt[0] * CONST_256) + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
1554 1562 val++;
1555 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
1563 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> SHIFT_1_BYTE);
1556 1564 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
1557 1565 }
1558 1566
@@ -1619,7 +1627,8 void updateLFRCurrentMode( unsigned char
1619 1627 */
1620 1628
1621 1629 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
1622 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
1630 housekeeping_packet.lfr_status_word[0] = (housekeeping_packet.lfr_status_word[0] & STATUS_WORD_LFR_MODE_MASK)
1631 + (unsigned char) ( requestedMode << STATUS_WORD_LFR_MODE_SHIFT );
1623 1632 lfrCurrentMode = requestedMode;
1624 1633 }
1625 1634
@@ -1627,11 +1636,11 void set_lfr_soft_reset( unsigned char v
1627 1636 {
1628 1637 if (value == 1)
1629 1638 {
1630 time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100]
1639 time_management_regs->ctrl = time_management_regs->ctrl | BIT_SOFT_RESET; // [0100]
1631 1640 }
1632 1641 else
1633 1642 {
1634 time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011]
1643 time_management_regs->ctrl = time_management_regs->ctrl & MASK_SOFT_RESET; // [1011]
1635 1644 }
1636 1645 }
1637 1646
@@ -105,7 +105,7 int action_load_burst_par(ccsdsTelecomma
105 105 {
106 106 if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 )
107 107 {
108 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
108 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0 + DATAFIELD_OFFSET, sy_lfr_b_bp_p0 );
109 109 flag = WRONG_APP_DATA;
110 110 }
111 111 }
@@ -114,7 +114,7 int action_load_burst_par(ccsdsTelecomma
114 114 {
115 115 if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 )
116 116 {
117 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, sy_lfr_b_bp_p1 );
117 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1 + DATAFIELD_OFFSET, sy_lfr_b_bp_p1 );
118 118 flag = WRONG_APP_DATA;
119 119 }
120 120 }
@@ -127,7 +127,7 int action_load_burst_par(ccsdsTelecomma
127 127 aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0);
128 128 if (aux > FLOAT_EQUAL_ZERO)
129 129 {
130 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
130 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0 + DATAFIELD_OFFSET, sy_lfr_b_bp_p0 );
131 131 flag = LFR_DEFAULT;
132 132 }
133 133 }
@@ -172,7 +172,7 int action_load_sbm1_par(ccsdsTelecomman
172 172 {
173 173 if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 )
174 174 {
175 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
175 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s1_bp_p0 );
176 176 flag = WRONG_APP_DATA;
177 177 }
178 178 }
@@ -181,7 +181,7 int action_load_sbm1_par(ccsdsTelecomman
181 181 {
182 182 if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 )
183 183 {
184 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, sy_lfr_s1_bp_p1 );
184 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1 + DATAFIELD_OFFSET, sy_lfr_s1_bp_p1 );
185 185 flag = WRONG_APP_DATA;
186 186 }
187 187 }
@@ -189,10 +189,11 int action_load_sbm1_par(ccsdsTelecomman
189 189 // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1
190 190 if (flag == LFR_SUCCESSFUL)
191 191 {
192 aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25));
192 aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0 * S1_BP_P0_SCALE) )
193 - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0 * S1_BP_P0_SCALE));
193 194 if (aux > FLOAT_EQUAL_ZERO)
194 195 {
195 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
196 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s1_bp_p0 );
196 197 flag = LFR_DEFAULT;
197 198 }
198 199 }
@@ -237,7 +238,7 int action_load_sbm2_par(ccsdsTelecomman
237 238 {
238 239 if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 )
239 240 {
240 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
241 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s2_bp_p0 );
241 242 flag = WRONG_APP_DATA;
242 243 }
243 244 }
@@ -246,7 +247,7 int action_load_sbm2_par(ccsdsTelecomman
246 247 {
247 248 if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 )
248 249 {
249 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, sy_lfr_s2_bp_p1 );
250 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1 + DATAFIELD_OFFSET, sy_lfr_s2_bp_p1 );
250 251 flag = WRONG_APP_DATA;
251 252 }
252 253 }
@@ -259,7 +260,7 int action_load_sbm2_par(ccsdsTelecomman
259 260 aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0);
260 261 if (aux > FLOAT_EQUAL_ZERO)
261 262 {
262 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
263 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0 + DATAFIELD_OFFSET, sy_lfr_s2_bp_p0 );
263 264 flag = LFR_DEFAULT;
264 265 }
265 266 }
@@ -332,25 +333,25 int action_load_filter_par(ccsdsTelecomm
332 333 {
333 334 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ];
334 335 parameter_dump_packet.sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
335 parameter_dump_packet.sy_lfr_pas_filter_tbad[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 0 ];
336 parameter_dump_packet.sy_lfr_pas_filter_tbad[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 1 ];
337 parameter_dump_packet.sy_lfr_pas_filter_tbad[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 2 ];
338 parameter_dump_packet.sy_lfr_pas_filter_tbad[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 3 ];
336 parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_0 ];
337 parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_1 ];
338 parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_2 ];
339 parameter_dump_packet.sy_lfr_pas_filter_tbad[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + BYTE_3 ];
339 340 parameter_dump_packet.sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
340 parameter_dump_packet.sy_lfr_pas_filter_shift[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 0 ];
341 parameter_dump_packet.sy_lfr_pas_filter_shift[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 1 ];
342 parameter_dump_packet.sy_lfr_pas_filter_shift[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 2 ];
343 parameter_dump_packet.sy_lfr_pas_filter_shift[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 3 ];
344 parameter_dump_packet.sy_lfr_sc_rw_delta_f[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 0 ];
345 parameter_dump_packet.sy_lfr_sc_rw_delta_f[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 1 ];
346 parameter_dump_packet.sy_lfr_sc_rw_delta_f[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 2 ];
347 parameter_dump_packet.sy_lfr_sc_rw_delta_f[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 3 ];
341 parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_0 ];
342 parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_1 ];
343 parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_2 ];
344 parameter_dump_packet.sy_lfr_pas_filter_shift[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + BYTE_3 ];
345 parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_0 ];
346 parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_1 ];
347 parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_2 ];
348 parameter_dump_packet.sy_lfr_sc_rw_delta_f[BYTE_3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + BYTE_3 ];
348 349
349 350 //****************************
350 351 // store PAS filter parameters
351 352 // sy_lfr_pas_filter_enabled
352 353 filterPar.spare_sy_lfr_pas_filter_enabled = parameter_dump_packet.spare_sy_lfr_pas_filter_enabled;
353 set_sy_lfr_pas_filter_enabled( parameter_dump_packet.spare_sy_lfr_pas_filter_enabled & 0x01 );
354 set_sy_lfr_pas_filter_enabled( parameter_dump_packet.spare_sy_lfr_pas_filter_enabled & BIT_PAS_FILTER_ENABLED );
354 355 // sy_lfr_pas_filter_modulus
355 356 filterPar.sy_lfr_pas_filter_modulus = parameter_dump_packet.sy_lfr_pas_filter_modulus;
356 357 // sy_lfr_pas_filter_tbad
@@ -399,54 +400,60 int action_dump_kcoefficients(ccsdsTelec
399 400 // 11 F0 bins, 13 F1 bins and 6 F2 bins
400 401 kcoefficients_dump_1.destinationID = TC->sourceID;
401 402 increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID );
402 for( freq=0;
403 freq<NB_BINS_COMPRESSED_SM_F0;
403 for( freq = 0;
404 freq < NB_BINS_COMPRESSED_SM_F0;
404 405 freq++ )
405 406 {
406 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq;
407 kcoefficients_dump_1.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1] = freq;
407 408 bin = freq;
408 409 // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm);
409 410 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
410 411 {
411 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
412 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[
413 (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ
414 ]; // 2 for the kcoeff_frequency
412 415 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
413 416 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
414 417 }
415 418 }
416 for( freq=NB_BINS_COMPRESSED_SM_F0;
417 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
419 for( freq = NB_BINS_COMPRESSED_SM_F0;
420 freq < ( NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 );
418 421 freq++ )
419 422 {
420 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
423 kcoefficients_dump_1.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1 ] = freq;
421 424 bin = freq - NB_BINS_COMPRESSED_SM_F0;
422 425 // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm);
423 426 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
424 427 {
425 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
428 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[
429 (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ
430 ]; // 2 for the kcoeff_frequency
426 431 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
427 432 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
428 433 }
429 434 }
430 for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
431 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6);
435 for( freq = ( NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 );
436 freq < KCOEFF_BLK_NR_PKT1 ;
432 437 freq++ )
433 438 {
434 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
435 bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
439 kcoefficients_dump_1.kcoeff_blks[ (freq * KCOEFF_BLK_SIZE) + 1 ] = freq;
440 bin = freq - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1);
436 441 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
437 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
442 for ( coeff = 0; coeff <NB_K_COEFF_PER_BIN; coeff++ )
438 443 {
439 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
444 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[
445 (freq * KCOEFF_BLK_SIZE) + (coeff * NB_BYTES_PER_FLOAT) + KCOEFF_FREQ
446 ]; // 2 for the kcoeff_frequency
440 447 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
441 448 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
442 449 }
443 450 }
444 kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
445 kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
446 kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
447 kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time);
448 kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
449 kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time);
451 kcoefficients_dump_1.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
452 kcoefficients_dump_1.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
453 kcoefficients_dump_1.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
454 kcoefficients_dump_1.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
455 kcoefficients_dump_1.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
456 kcoefficients_dump_1.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
450 457 // SEND DATA
451 458 kcoefficient_node_1.status = 1;
452 459 address = (unsigned int) &kcoefficient_node_1;
@@ -460,24 +467,27 int action_dump_kcoefficients(ccsdsTelec
460 467 // 6 F2 bins
461 468 kcoefficients_dump_2.destinationID = TC->sourceID;
462 469 increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID );
463 for( freq=0; freq<6; freq++ )
470 for( freq = 0;
471 freq < KCOEFF_BLK_NR_PKT2;
472 freq++ )
464 473 {
465 kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq;
466 bin = freq + 6;
474 kcoefficients_dump_2.kcoeff_blks[ (freq*KCOEFF_BLK_SIZE) + 1 ] = KCOEFF_BLK_NR_PKT1 + freq;
475 bin = freq + KCOEFF_BLK_NR_PKT2;
467 476 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
468 477 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
469 478 {
470 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
479 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[
480 (freq*KCOEFF_BLK_SIZE) + (coeff*NB_BYTES_PER_FLOAT) + KCOEFF_FREQ ]; // 2 for the kcoeff_frequency
471 481 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
472 482 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
473 483 }
474 484 }
475 kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
476 kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
477 kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
478 kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time);
479 kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
480 kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time);
485 kcoefficients_dump_2.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
486 kcoefficients_dump_2.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
487 kcoefficients_dump_2.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
488 kcoefficients_dump_2.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
489 kcoefficients_dump_2.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
490 kcoefficients_dump_2.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
481 491 // SEND DATA
482 492 kcoefficient_node_2.status = 1;
483 493 address = (unsigned int) &kcoefficient_node_2;
@@ -511,12 +521,12 int action_dump_par( ccsdsTelecommandPac
511 521 parameter_dump_packet.destinationID = TC->sourceID;
512 522
513 523 // UPDATE TIME
514 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
515 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
516 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
517 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
518 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
519 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
524 parameter_dump_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
525 parameter_dump_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
526 parameter_dump_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
527 parameter_dump_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
528 parameter_dump_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
529 parameter_dump_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
520 530 // SEND DATA
521 531 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
522 532 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
@@ -551,15 +561,15 int check_normal_par_consistency( ccsdsT
551 561 // get parameters
552 562 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
553 563 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
554 sy_lfr_n_swf_l = msb * 256 + lsb;
564 sy_lfr_n_swf_l = (msb * CONST_256) + lsb;
555 565
556 566 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
557 567 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
558 sy_lfr_n_swf_p = msb * 256 + lsb;
568 sy_lfr_n_swf_p = (msb * CONST_256) + lsb;
559 569
560 570 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
561 571 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
562 sy_lfr_n_asm_p = msb * 256 + lsb;
572 sy_lfr_n_asm_p = (msb * CONST_256) + lsb;
563 573
564 574 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
565 575
@@ -570,17 +580,17 int check_normal_par_consistency( ccsdsT
570 580 //******************
571 581 // check consistency
572 582 // sy_lfr_n_swf_l
573 if (sy_lfr_n_swf_l != 2048)
583 if (sy_lfr_n_swf_l != DFLT_SY_LFR_N_SWF_L)
574 584 {
575 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l );
585 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L + DATAFIELD_OFFSET, sy_lfr_n_swf_l );
576 586 flag = WRONG_APP_DATA;
577 587 }
578 588 // sy_lfr_n_swf_p
579 589 if (flag == LFR_SUCCESSFUL)
580 590 {
581 if ( sy_lfr_n_swf_p < 22 )
591 if ( sy_lfr_n_swf_p < MIN_SY_LFR_N_SWF_P )
582 592 {
583 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p );
593 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P + DATAFIELD_OFFSET, sy_lfr_n_swf_p );
584 594 flag = WRONG_APP_DATA;
585 595 }
586 596 }
@@ -589,7 +599,7 int check_normal_par_consistency( ccsdsT
589 599 {
590 600 if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0)
591 601 {
592 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 );
602 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0 + DATAFIELD_OFFSET, sy_lfr_n_bp_p0 );
593 603 flag = WRONG_APP_DATA;
594 604 }
595 605 }
@@ -598,7 +608,7 int check_normal_par_consistency( ccsdsT
598 608 {
599 609 if (sy_lfr_n_asm_p == 0)
600 610 {
601 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
611 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P + DATAFIELD_OFFSET, sy_lfr_n_asm_p );
602 612 flag = WRONG_APP_DATA;
603 613 }
604 614 }
@@ -608,7 +618,7 int check_normal_par_consistency( ccsdsT
608 618 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
609 619 if (aux > FLOAT_EQUAL_ZERO)
610 620 {
611 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
621 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P + DATAFIELD_OFFSET, sy_lfr_n_asm_p );
612 622 flag = WRONG_APP_DATA;
613 623 }
614 624 }
@@ -617,7 +627,7 int check_normal_par_consistency( ccsdsT
617 627 {
618 628 if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1)
619 629 {
620 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
630 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1 + DATAFIELD_OFFSET, sy_lfr_n_bp_p1 );
621 631 flag = WRONG_APP_DATA;
622 632 }
623 633 }
@@ -627,7 +637,7 int check_normal_par_consistency( ccsdsT
627 637 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
628 638 if (aux > FLOAT_EQUAL_ZERO)
629 639 {
630 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
640 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1 + DATAFIELD_OFFSET, sy_lfr_n_bp_p1 );
631 641 flag = LFR_DEFAULT;
632 642 }
633 643 }
@@ -988,19 +998,20 void setFBinMask( unsigned char *fbins_m
988 998 unsigned int whichByte;
989 999 int selectedByte;
990 1000 int bin;
991 int binToRemove[3];
1001 int binToRemove[NB_BINS_TO_REMOVE];
992 1002 int k;
993 1003
994 1004 whichByte = 0;
995 1005 bin = 0;
996 1006
997 binToRemove[0] = -1;
998 binToRemove[1] = -1;
999 binToRemove[2] = -1;
1007 for (k = 0; k < NB_BINS_TO_REMOVE; k++)
1008 {
1009 binToRemove[k] = -1;
1010 }
1000 1011
1001 1012 // compute the frequency range to filter [ rw_f - delta_f/2; rw_f + delta_f/2 ]
1002 f_RW_min = rw_f - filterPar.sy_lfr_sc_rw_delta_f / 2.;
1003 f_RW_MAX = rw_f + filterPar.sy_lfr_sc_rw_delta_f / 2.;
1013 f_RW_min = rw_f - (filterPar.sy_lfr_sc_rw_delta_f / 2.);
1014 f_RW_MAX = rw_f + (filterPar.sy_lfr_sc_rw_delta_f / 2.);
1004 1015
1005 1016 // compute the index of the frequency bin immediately below rw_f
1006 1017 binBelow = (int) ( floor( ((double) rw_f) / ((double) deltaFreq)) );
@@ -1022,8 +1033,8 void setFBinMask( unsigned char *fbins_m
1022 1033
1023 1034 // compute the fi interval [fi - deltaFreq * 0.285, fi + deltaFreq * 0.285]
1024 1035 fi = closestBin * deltaFreq;
1025 fi_min = fi - (deltaFreq * 0.285);
1026 fi_MAX = fi + (deltaFreq * 0.285);
1036 fi_min = fi - (deltaFreq * FI_INTERVAL_COEFF);
1037 fi_MAX = fi + (deltaFreq * FI_INTERVAL_COEFF);
1027 1038
1028 1039 //**************************************************************************************
1029 1040 // be careful here, one shall take into account that the bin 0 IS DROPPED in the spectra
@@ -1047,16 +1058,17 void setFBinMask( unsigned char *fbins_m
1047 1058 binToRemove[2] = (-1);
1048 1059 }
1049 1060
1050 for (k = 0; k < 3; k++)
1061 for (k = 0; k < NB_BINS_TO_REMOVE; k++)
1051 1062 {
1052 1063 bin = binToRemove[k];
1053 if ( (bin >= 0) && (bin <= 127) )
1064 if ( (bin >= BIN_MIN) && (bin <= BIN_MAX) )
1054 1065 {
1055 1066 if (flag == 1)
1056 1067 {
1057 whichByte = (bin >> 3); // division by 8
1058 selectedByte = ( 1 << (bin - (whichByte * 8)) );
1059 fbins_mask[15 - whichByte] = fbins_mask[15 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets
1068 whichByte = (bin >> SHIFT_3_BITS); // division by 8
1069 selectedByte = ( 1 << (bin - (whichByte * BITS_PER_BYTE)) );
1070 fbins_mask[BYTES_PER_MASK - 1 - whichByte] =
1071 fbins_mask[BYTES_PER_MASK - 1 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets
1060 1072 }
1061 1073 }
1062 1074 }
@@ -1064,7 +1076,7 void setFBinMask( unsigned char *fbins_m
1064 1076
1065 1077 void build_sy_lfr_rw_mask( unsigned int channel )
1066 1078 {
1067 unsigned char local_rw_fbins_mask[16];
1079 unsigned char local_rw_fbins_mask[BYTES_PER_MASK];
1068 1080 unsigned char *maskPtr;
1069 1081 double deltaF;
1070 1082 unsigned k;
@@ -1072,59 +1084,59 void build_sy_lfr_rw_mask( unsigned int
1072 1084 k = 0;
1073 1085
1074 1086 maskPtr = NULL;
1075 deltaF = 1.;
1087 deltaF = DELTAF_F2;
1076 1088
1077 1089 switch (channel)
1078 1090 {
1079 case 0:
1091 case CHANNELF0:
1080 1092 maskPtr = parameter_dump_packet.sy_lfr_rw_mask.fx.f0_word1;
1081 deltaF = 96.;
1093 deltaF = DELTAF_F0;
1082 1094 break;
1083 case 1:
1095 case CHANNELF1:
1084 1096 maskPtr = parameter_dump_packet.sy_lfr_rw_mask.fx.f1_word1;
1085 deltaF = 16.;
1097 deltaF = DELTAF_F1;
1086 1098 break;
1087 case 2:
1099 case CHANNELF2:
1088 1100 maskPtr = parameter_dump_packet.sy_lfr_rw_mask.fx.f2_word1;
1089 deltaF = 1.;
1101 deltaF = DELTAF_F2;
1090 1102 break;
1091 1103 default:
1092 1104 break;
1093 1105 }
1094 1106
1095 for (k = 0; k < 16; k++)
1107 for (k = 0; k < BYTES_PER_MASK; k++)
1096 1108 {
1097 local_rw_fbins_mask[k] = 0xff;
1109 local_rw_fbins_mask[k] = INT8_ALL_F;
1098 1110 }
1099 1111
1100 1112 // RW1 F1
1101 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x80) >> 7 ); // [1000 0000]
1113 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f1, deltaF, (cp_rpw_sc_rw_f_flags & BIT_RW1_F1) >> SHIFT_7_BITS ); // [1000 0000]
1102 1114
1103 1115 // RW1 F2
1104 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x40) >> 6 ); // [0100 0000]
1116 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f2, deltaF, (cp_rpw_sc_rw_f_flags & BIT_RW1_F2) >> SHIFT_6_BITS ); // [0100 0000]
1105 1117
1106 1118 // RW2 F1
1107 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x20) >> 5 ); // [0010 0000]
1119 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f1, deltaF, (cp_rpw_sc_rw_f_flags & BIT_RW2_F1) >> SHIFT_5_BITS ); // [0010 0000]
1108 1120
1109 1121 // RW2 F2
1110 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x10) >> 4 ); // [0001 0000]
1122 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f2, deltaF, (cp_rpw_sc_rw_f_flags & BIT_RW2_F2) >> SHIFT_4_BITS ); // [0001 0000]
1111 1123
1112 1124 // RW3 F1
1113 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x08) >> 3 ); // [0000 1000]
1125 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f1, deltaF, (cp_rpw_sc_rw_f_flags & BIT_RW3_F1) >> SHIFT_3_BITS ); // [0000 1000]
1114 1126
1115 1127 // RW3 F2
1116 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x04) >> 2 ); // [0000 0100]
1128 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f2, deltaF, (cp_rpw_sc_rw_f_flags & BIT_RW3_F2) >> SHIFT_2_BITS ); // [0000 0100]
1117 1129
1118 1130 // RW4 F1
1119 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw4_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x02) >> 1 ); // [0000 0010]
1131 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw4_f1, deltaF, (cp_rpw_sc_rw_f_flags & BIT_RW4_F1) >> 1 ); // [0000 0010]
1120 1132
1121 1133 // RW4 F2
1122 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw4_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x01) ); // [0000 0001]
1134 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw4_f2, deltaF, (cp_rpw_sc_rw_f_flags & BIT_RW4_F2) ); // [0000 0001]
1123 1135
1124 1136 // update the value of the fbins related to reaction wheels frequency filtering
1125 1137 if (maskPtr != NULL)
1126 1138 {
1127 for (k = 0; k < 16; k++)
1139 for (k = 0; k < BYTES_PER_MASK; k++)
1128 1140 {
1129 1141 maskPtr[k] = local_rw_fbins_mask[k];
1130 1142 }
@@ -1133,9 +1145,9 void build_sy_lfr_rw_mask( unsigned int
1133 1145
1134 1146 void build_sy_lfr_rw_masks( void )
1135 1147 {
1136 build_sy_lfr_rw_mask( 0 );
1137 build_sy_lfr_rw_mask( 1 );
1138 build_sy_lfr_rw_mask( 2 );
1148 build_sy_lfr_rw_mask( CHANNELF0 );
1149 build_sy_lfr_rw_mask( CHANNELF1 );
1150 build_sy_lfr_rw_mask( CHANNELF2 );
1139 1151 }
1140 1152
1141 1153 void merge_fbins_masks( void )
@@ -1156,7 +1168,7 void merge_fbins_masks( void )
1156 1168 rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask.fx.f1_word1;
1157 1169 rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask.fx.f2_word1;
1158 1170
1159 for( k=0; k < 16; k++ )
1171 for( k=0; k < BYTES_PER_MASK; k++ )
1160 1172 {
1161 1173 fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k];
1162 1174 fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k];
@@ -1179,7 +1191,7 int set_sy_lfr_fbins( ccsdsTelecommandPa
1179 1191 fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins.raw;
1180 1192 fbins_mask_TC = TC->dataAndCRC;
1181 1193
1182 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1194 for (k=0; k < BYTES_PER_MASKS_SET; k++)
1183 1195 {
1184 1196 fbins_mask_dump[k] = fbins_mask_TC[k];
1185 1197 }
@@ -1204,14 +1216,14 int check_sy_lfr_filter_parameters( ccsd
1204 1216 char *parPtr;
1205 1217
1206 1218 flag = LFR_SUCCESSFUL;
1207 sy_lfr_pas_filter_tbad = 0.0;
1208 sy_lfr_pas_filter_shift = 0.0;
1209 sy_lfr_sc_rw_delta_f = 0.0;
1219 sy_lfr_pas_filter_tbad = INIT_FLOAT;
1220 sy_lfr_pas_filter_shift = INIT_FLOAT;
1221 sy_lfr_sc_rw_delta_f = INIT_FLOAT;
1210 1222 parPtr = NULL;
1211 1223
1212 1224 //***************
1213 1225 // get parameters
1214 sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & 0x01; // [0000 0001]
1226 sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & BIT_PAS_FILTER_ENABLED; // [0000 0001]
1215 1227 sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
1216 1228 copyFloatByChar(
1217 1229 (unsigned char*) &sy_lfr_pas_filter_tbad,
@@ -1236,18 +1248,18 int check_sy_lfr_filter_parameters( ccsd
1236 1248
1237 1249 //**************************
1238 1250 // sy_lfr_pas_filter_modulus
1239 if ( (sy_lfr_pas_filter_modulus < 4) || (sy_lfr_pas_filter_modulus > 8) )
1251 if ( (sy_lfr_pas_filter_modulus < MIN_PAS_FILTER_MODULUS) || (sy_lfr_pas_filter_modulus > MAX_PAS_FILTER_MODULUS) )
1240 1252 {
1241 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS+10, sy_lfr_pas_filter_modulus );
1253 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS + DATAFIELD_OFFSET, sy_lfr_pas_filter_modulus );
1242 1254 flag = WRONG_APP_DATA;
1243 1255 }
1244 1256
1245 1257 //***********************
1246 1258 // sy_lfr_pas_filter_tbad
1247 if ( (sy_lfr_pas_filter_tbad < 0.0) || (sy_lfr_pas_filter_tbad > 4.0) )
1259 if ( (sy_lfr_pas_filter_tbad < MIN_PAS_FILTER_TBAD) || (sy_lfr_pas_filter_tbad > MAX_PAS_FILTER_TBAD) )
1248 1260 {
1249 1261 parPtr = (char*) &sy_lfr_pas_filter_tbad;
1250 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD+10, parPtr[3] );
1262 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] );
1251 1263 flag = WRONG_APP_DATA;
1252 1264 }
1253 1265
@@ -1255,20 +1267,34 int check_sy_lfr_filter_parameters( ccsd
1255 1267 // sy_lfr_pas_filter_offset
1256 1268 if (flag == LFR_SUCCESSFUL)
1257 1269 {
1258 if ( (sy_lfr_pas_filter_offset < 0) || (sy_lfr_pas_filter_offset > 7) )
1270 if ( (sy_lfr_pas_filter_offset < MIN_PAS_FILTER_OFFSET) || (sy_lfr_pas_filter_offset > MAX_PAS_FILTER_OFFSET) )
1259 1271 {
1260 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET+10, sy_lfr_pas_filter_offset );
1272 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET + DATAFIELD_OFFSET, sy_lfr_pas_filter_offset );
1261 1273 flag = WRONG_APP_DATA;
1262 1274 }
1263 1275 }
1264 1276
1265 1277 //************************
1266 1278 // sy_lfr_pas_filter_shift
1267 if ( (sy_lfr_pas_filter_shift < 0.0) || (sy_lfr_pas_filter_shift > 1.0) )
1279 if (flag == LFR_SUCCESSFUL)
1268 1280 {
1269 parPtr = (char*) &sy_lfr_pas_filter_shift;
1270 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT+10, parPtr[3] );
1271 flag = WRONG_APP_DATA;
1281 if ( (sy_lfr_pas_filter_shift < MIN_PAS_FILTER_SHIFT) || (sy_lfr_pas_filter_shift > MAX_PAS_FILTER_SHIFT) )
1282 {
1283 parPtr = (char*) &sy_lfr_pas_filter_shift;
1284 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + DATAFIELD_OFFSET, parPtr[FLOAT_LSBYTE] );
1285 flag = WRONG_APP_DATA;
1286 }
1287 }
1288
1289 //*************************************
1290 // check global coherency of the values
1291 if (flag == LFR_SUCCESSFUL)
1292 {
1293 if ( (sy_lfr_pas_filter_tbad + sy_lfr_pas_filter_offset + sy_lfr_pas_filter_shift) > sy_lfr_pas_filter_modulus )
1294 {
1295 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS + DATAFIELD_OFFSET, sy_lfr_pas_filter_modulus );
1296 flag = WRONG_APP_DATA;
1297 }
1272 1298 }
1273 1299
1274 1300 //*********************
@@ -1306,7 +1332,7 int set_sy_lfr_kcoeff( ccsdsTelecommandP
1306 1332 if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM )
1307 1333 {
1308 1334 PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency)
1309 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1,
1335 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + DATAFIELD_OFFSET + 1,
1310 1336 TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB
1311 1337 status = LFR_DEFAULT;
1312 1338 }
@@ -1342,7 +1368,7 int set_sy_lfr_kcoeff( ccsdsTelecommandP
1342 1368 // destination
1343 1369 kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ];
1344 1370 // source
1345 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
1371 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + (NB_BYTES_PER_FLOAT * kcoeff)];
1346 1372 // copy source to destination
1347 1373 copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr );
1348 1374 }
@@ -1353,10 +1379,10 int set_sy_lfr_kcoeff( ccsdsTelecommandP
1353 1379 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1354 1380 {
1355 1381 // destination
1356 kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ];
1357 kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ];
1382 kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * SBM_COEFF_PER_NORM_COEFF ];
1383 kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ (((bin * NB_K_COEFF_PER_BIN) + kcoeff) * SBM_KCOEFF_PER_NORM_KCOEFF) + 1 ];
1358 1384 // source
1359 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
1385 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + (NB_BYTES_PER_FLOAT * kcoeff)];
1360 1386 // copy source to destination
1361 1387 copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr );
1362 1388 copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr );
@@ -1370,10 +1396,10 int set_sy_lfr_kcoeff( ccsdsTelecommandP
1370 1396
1371 1397 void copyFloatByChar( unsigned char *destination, unsigned char *source )
1372 1398 {
1373 destination[0] = source[0];
1374 destination[1] = source[1];
1375 destination[2] = source[2];
1376 destination[3] = source[3];
1399 destination[BYTE_0] = source[BYTE_0];
1400 destination[BYTE_1] = source[BYTE_1];
1401 destination[BYTE_2] = source[BYTE_2];
1402 destination[BYTE_3] = source[BYTE_3];
1377 1403 }
1378 1404
1379 1405 void floatToChar( float value, unsigned char* ptr)
@@ -1381,10 +1407,10 void floatToChar( float value, unsigned
1381 1407 unsigned char* valuePtr;
1382 1408
1383 1409 valuePtr = (unsigned char*) &value;
1384 ptr[0] = valuePtr[0];
1385 ptr[1] = valuePtr[1];
1386 ptr[2] = valuePtr[2];
1387 ptr[3] = valuePtr[3];
1410 ptr[BYTE_0] = valuePtr[BYTE_0];
1411 ptr[BYTE_1] = valuePtr[BYTE_1];
1412 ptr[BYTE_2] = valuePtr[BYTE_2];
1413 ptr[BYTE_3] = valuePtr[BYTE_3];
1388 1414 }
1389 1415
1390 1416 //**********
@@ -1402,23 +1428,23 void init_parameter_dump( void )
1402 1428 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1403 1429 parameter_dump_packet.reserved = CCSDS_RESERVED;
1404 1430 parameter_dump_packet.userApplication = CCSDS_USER_APP;
1405 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
1431 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> SHIFT_1_BYTE);
1406 1432 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1407 1433 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1408 1434 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1409 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
1435 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> SHIFT_1_BYTE);
1410 1436 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
1411 1437 // DATA FIELD HEADER
1412 1438 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1413 1439 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
1414 1440 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
1415 1441 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
1416 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1417 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1418 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1419 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
1420 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1421 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
1442 parameter_dump_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
1443 parameter_dump_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
1444 parameter_dump_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
1445 parameter_dump_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
1446 parameter_dump_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
1447 parameter_dump_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
1422 1448 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
1423 1449
1424 1450 //******************
@@ -1428,11 +1454,11 void init_parameter_dump( void )
1428 1454
1429 1455 //******************
1430 1456 // NORMAL PARAMETERS
1431 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8);
1457 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> SHIFT_1_BYTE);
1432 1458 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L );
1433 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8);
1459 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> SHIFT_1_BYTE);
1434 1460 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P );
1435 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8);
1461 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> SHIFT_1_BYTE);
1436 1462 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P );
1437 1463 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0;
1438 1464 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1;
@@ -1455,14 +1481,14 void init_parameter_dump( void )
1455 1481
1456 1482 //************
1457 1483 // FBINS MASKS
1458 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1484 for (k=0; k < BYTES_PER_MASKS_SET; k++)
1459 1485 {
1460 parameter_dump_packet.sy_lfr_fbins.raw[k] = 0xff;
1486 parameter_dump_packet.sy_lfr_fbins.raw[k] = INT8_ALL_F;
1461 1487 }
1462 1488
1463 1489 // PAS FILTER PARAMETERS
1464 parameter_dump_packet.pa_rpw_spare8_2 = 0x00;
1465 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = 0x00;
1490 parameter_dump_packet.pa_rpw_spare8_2 = INIT_CHAR;
1491 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = INIT_CHAR;
1466 1492 parameter_dump_packet.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
1467 1493 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_TBAD, parameter_dump_packet.sy_lfr_pas_filter_tbad );
1468 1494 parameter_dump_packet.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
@@ -1470,9 +1496,9 void init_parameter_dump( void )
1470 1496 floatToChar( DEFAULT_SY_LFR_SC_RW_DELTA_F, parameter_dump_packet.sy_lfr_sc_rw_delta_f );
1471 1497
1472 1498 // LFR_RW_MASK
1473 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1499 for (k=0; k < BYTES_PER_MASKS_SET; k++)
1474 1500 {
1475 parameter_dump_packet.sy_lfr_rw_mask.raw[k] = 0xff;
1501 parameter_dump_packet.sy_lfr_rw_mask.raw[k] = INT8_ALL_F;
1476 1502 }
1477 1503
1478 1504 // once the reaction wheels masks have been initialized, they have to be merged with the fbins masks
@@ -1481,24 +1507,24 void init_parameter_dump( void )
1481 1507
1482 1508 void init_kcoefficients_dump( void )
1483 1509 {
1484 init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 );
1485 init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 );
1510 init_kcoefficients_dump_packet( &kcoefficients_dump_1, PKTNR_1, KCOEFF_BLK_NR_PKT1 );
1511 init_kcoefficients_dump_packet( &kcoefficients_dump_2, PKTNR_2, KCOEFF_BLK_NR_PKT2 );
1486 1512
1487 1513 kcoefficient_node_1.previous = NULL;
1488 1514 kcoefficient_node_1.next = NULL;
1489 1515 kcoefficient_node_1.sid = TM_CODE_K_DUMP;
1490 kcoefficient_node_1.coarseTime = 0x00;
1491 kcoefficient_node_1.fineTime = 0x00;
1516 kcoefficient_node_1.coarseTime = INIT_CHAR;
1517 kcoefficient_node_1.fineTime = INIT_CHAR;
1492 1518 kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1;
1493 kcoefficient_node_1.status = 0x00;
1519 kcoefficient_node_1.status = INIT_CHAR;
1494 1520
1495 1521 kcoefficient_node_2.previous = NULL;
1496 1522 kcoefficient_node_2.next = NULL;
1497 1523 kcoefficient_node_2.sid = TM_CODE_K_DUMP;
1498 kcoefficient_node_2.coarseTime = 0x00;
1499 kcoefficient_node_2.fineTime = 0x00;
1524 kcoefficient_node_2.coarseTime = INIT_CHAR;
1525 kcoefficient_node_2.fineTime = INIT_CHAR;
1500 1526 kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2;
1501 kcoefficient_node_2.status = 0x00;
1527 kcoefficient_node_2.status = INIT_CHAR;
1502 1528 }
1503 1529
1504 1530 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr )
@@ -1506,41 +1532,42 void init_kcoefficients_dump_packet( Pac
1506 1532 unsigned int k;
1507 1533 unsigned int packetLength;
1508 1534
1509 packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header
1535 packetLength =
1536 ((blk_nr * KCOEFF_BLK_SIZE) + BYTE_POS_KCOEFFICIENTS_PARAMETES) - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header
1510 1537
1511 1538 kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID;
1512 1539 kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID;
1513 1540 kcoefficients_dump->reserved = CCSDS_RESERVED;
1514 1541 kcoefficients_dump->userApplication = CCSDS_USER_APP;
1515 kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);;
1516 kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;;
1542 kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> SHIFT_1_BYTE);
1543 kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1517 1544 kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1518 1545 kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1519 kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8);
1546 kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> SHIFT_1_BYTE);
1520 1547 kcoefficients_dump->packetLength[1] = (unsigned char) packetLength;
1521 1548 // DATA FIELD HEADER
1522 1549 kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1523 1550 kcoefficients_dump->serviceType = TM_TYPE_K_DUMP;
1524 1551 kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP;
1525 1552 kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND;
1526 kcoefficients_dump->time[0] = 0x00;
1527 kcoefficients_dump->time[1] = 0x00;
1528 kcoefficients_dump->time[2] = 0x00;
1529 kcoefficients_dump->time[3] = 0x00;
1530 kcoefficients_dump->time[4] = 0x00;
1531 kcoefficients_dump->time[5] = 0x00;
1553 kcoefficients_dump->time[BYTE_0] = INIT_CHAR;
1554 kcoefficients_dump->time[BYTE_1] = INIT_CHAR;
1555 kcoefficients_dump->time[BYTE_2] = INIT_CHAR;
1556 kcoefficients_dump->time[BYTE_3] = INIT_CHAR;
1557 kcoefficients_dump->time[BYTE_4] = INIT_CHAR;
1558 kcoefficients_dump->time[BYTE_5] = INIT_CHAR;
1532 1559 kcoefficients_dump->sid = SID_K_DUMP;
1533 1560
1534 kcoefficients_dump->pkt_cnt = 2;
1535 kcoefficients_dump->pkt_nr = pkt_nr;
1561 kcoefficients_dump->pkt_cnt = KCOEFF_PKTCNT;
1562 kcoefficients_dump->pkt_nr = PKTNR_1;
1536 1563 kcoefficients_dump->blk_nr = blk_nr;
1537 1564
1538 1565 //******************
1539 1566 // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR]
1540 1567 // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900)
1541 for (k=0; k<3900; k++)
1568 for (k=0; k<(KCOEFF_BLK_NR_PKT1 * KCOEFF_BLK_SIZE); k++)
1542 1569 {
1543 kcoefficients_dump->kcoeff_blks[k] = 0x00;
1570 kcoefficients_dump->kcoeff_blks[k] = INIT_CHAR;
1544 1571 }
1545 1572 }
1546 1573
@@ -1603,12 +1630,12 void increment_seq_counter_destination_i
1603 1630 break;
1604 1631 }
1605 1632
1606 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1607 sequence_cnt = sequenceCounters_TM_DUMP[ i ] & 0x3fff;
1633 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE;
1634 sequence_cnt = sequenceCounters_TM_DUMP[ i ] & SEQ_CNT_MASK;
1608 1635
1609 1636 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
1610 1637
1611 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1638 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> SHIFT_1_BYTE);
1612 1639 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1613 1640
1614 1641 // increment the sequence counter
@@ -41,22 +41,22 int send_tm_lfr_tc_exe_success( ccsdsTel
41 41 TM.reserved = DEFAULT_RESERVED;
42 42 TM.userApplication = CCSDS_USER_APP;
43 43 // PACKET HEADER
44 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
44 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> SHIFT_1_BYTE);
45 45 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
46 46 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
47 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS >> 8);
47 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS >> SHIFT_1_BYTE);
48 48 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_SUCCESS );
49 49 // DATA FIELD HEADER
50 50 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
51 51 TM.serviceType = TM_TYPE_TC_EXE;
52 52 TM.serviceSubType = TM_SUBTYPE_EXE_OK;
53 53 TM.destinationID = TC->sourceID;
54 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
55 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
56 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
57 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
58 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
59 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
54 TM.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
55 TM.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
56 TM.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
57 TM.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
58 TM.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
59 TM.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
60 60 //
61 61 TM.telecommand_pkt_id[0] = TC->packetID[0];
62 62 TM.telecommand_pkt_id[1] = TC->packetID[1];
@@ -106,24 +106,24 int send_tm_lfr_tc_exe_inconsistent( ccs
106 106 TM.reserved = DEFAULT_RESERVED;
107 107 TM.userApplication = CCSDS_USER_APP;
108 108 // PACKET HEADER
109 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
109 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> SHIFT_1_BYTE);
110 110 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
111 111 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
112 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT >> 8);
112 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT >> SHIFT_1_BYTE);
113 113 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_INCONSISTENT );
114 114 // DATA FIELD HEADER
115 115 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
116 116 TM.serviceType = TM_TYPE_TC_EXE;
117 117 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
118 118 TM.destinationID = TC->sourceID;
119 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
120 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
121 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
122 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
123 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
124 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
119 TM.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
120 TM.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
121 TM.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
122 TM.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
123 TM.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
124 TM.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
125 125 //
126 TM.tc_failure_code[0] = (char) (WRONG_APP_DATA >> 8);
126 TM.tc_failure_code[0] = (char) (WRONG_APP_DATA >> SHIFT_1_BYTE);
127 127 TM.tc_failure_code[1] = (char) (WRONG_APP_DATA );
128 128 TM.telecommand_pkt_id[0] = TC->packetID[0];
129 129 TM.telecommand_pkt_id[1] = TC->packetID[1];
@@ -174,24 +174,24 int send_tm_lfr_tc_exe_not_executable( c
174 174 TM.reserved = DEFAULT_RESERVED;
175 175 TM.userApplication = CCSDS_USER_APP;
176 176 // PACKET HEADER
177 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
177 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> SHIFT_1_BYTE);
178 178 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
179 179 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
180 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE >> 8);
180 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE >> SHIFT_1_BYTE);
181 181 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE );
182 182 // DATA FIELD HEADER
183 183 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
184 184 TM.serviceType = TM_TYPE_TC_EXE;
185 185 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
186 186 TM.destinationID = TC->sourceID; // default destination id
187 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
188 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
189 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
190 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
191 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
192 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
187 TM.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
188 TM.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
189 TM.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
190 TM.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
191 TM.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
192 TM.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
193 193 //
194 TM.tc_failure_code[0] = (char) (TC_NOT_EXE >> 8);
194 TM.tc_failure_code[0] = (char) (TC_NOT_EXE >> SHIFT_1_BYTE);
195 195 TM.tc_failure_code[1] = (char) (TC_NOT_EXE );
196 196 TM.telecommand_pkt_id[0] = TC->packetID[0];
197 197 TM.telecommand_pkt_id[1] = TC->packetID[1];
@@ -242,24 +242,24 int send_tm_lfr_tc_exe_not_implemented(
242 242 TM.reserved = DEFAULT_RESERVED;
243 243 TM.userApplication = CCSDS_USER_APP;
244 244 // PACKET HEADER
245 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
245 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> SHIFT_1_BYTE);
246 246 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
247 247 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
248 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED >> 8);
248 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED >> SHIFT_1_BYTE);
249 249 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED );
250 250 // DATA FIELD HEADER
251 251 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
252 252 TM.serviceType = TM_TYPE_TC_EXE;
253 253 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
254 254 TM.destinationID = TC->sourceID; // default destination id
255 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
256 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
257 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
258 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
259 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
260 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
255 TM.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
256 TM.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
257 TM.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
258 TM.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
259 TM.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
260 TM.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
261 261 //
262 TM.tc_failure_code[0] = (char) (FUNCT_NOT_IMPL >> 8);
262 TM.tc_failure_code[0] = (char) (FUNCT_NOT_IMPL >> SHIFT_1_BYTE);
263 263 TM.tc_failure_code[1] = (char) (FUNCT_NOT_IMPL );
264 264 TM.telecommand_pkt_id[0] = TC->packetID[0];
265 265 TM.telecommand_pkt_id[1] = TC->packetID[1];
@@ -308,24 +308,24 int send_tm_lfr_tc_exe_error( ccsdsTelec
308 308 TM.reserved = DEFAULT_RESERVED;
309 309 TM.userApplication = CCSDS_USER_APP;
310 310 // PACKET HEADER
311 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
311 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> SHIFT_1_BYTE);
312 312 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
313 313 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
314 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR >> 8);
314 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR >> SHIFT_1_BYTE);
315 315 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_ERROR );
316 316 // DATA FIELD HEADER
317 317 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
318 318 TM.serviceType = TM_TYPE_TC_EXE;
319 319 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
320 320 TM.destinationID = TC->sourceID; // default destination id
321 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
322 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
323 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
324 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
325 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
326 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
321 TM.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
322 TM.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
323 TM.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
324 TM.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
325 TM.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
326 TM.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
327 327 //
328 TM.tc_failure_code[0] = (char) (FAIL_DETECTED >> 8);
328 TM.tc_failure_code[0] = (char) (FAIL_DETECTED >> SHIFT_1_BYTE);
329 329 TM.tc_failure_code[1] = (char) (FAIL_DETECTED );
330 330 TM.telecommand_pkt_id[0] = TC->packetID[0];
331 331 TM.telecommand_pkt_id[1] = TC->packetID[1];
@@ -376,8 +376,8 int send_tm_lfr_tc_exe_corrupted(ccsdsTe
376 376 unsigned int estimatedPacketLength;
377 377 unsigned char *packetDataField;
378 378
379 packetLength = (TC->packetLength[0] * 256) + TC->packetLength[1]; // compute the packet length parameter written in the TC
380 estimatedPacketLength = (unsigned int) (currentTC_LEN_RCV[0] * 256 + currentTC_LEN_RCV[1]);
379 packetLength = (TC->packetLength[0] * CONST_256) + TC->packetLength[1]; // compute the packet length parameter written in the TC
380 estimatedPacketLength = (unsigned int) ((currentTC_LEN_RCV[0] * CONST_256) + currentTC_LEN_RCV[1]);
381 381 packetDataField = (unsigned char *) &TC->headerFlag_pusVersion_Ack; // get the beginning of the data field
382 382
383 383 TM.targetLogicalAddress = CCSDS_DESTINATION_ID;
@@ -385,24 +385,24 int send_tm_lfr_tc_exe_corrupted(ccsdsTe
385 385 TM.reserved = DEFAULT_RESERVED;
386 386 TM.userApplication = CCSDS_USER_APP;
387 387 // PACKET HEADER
388 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> 8);
388 TM.packetID[0] = (unsigned char) (APID_TM_TC_EXE >> SHIFT_1_BYTE);
389 389 TM.packetID[1] = (unsigned char) (APID_TM_TC_EXE );
390 390 increment_seq_counter_destination_id( TM.packetSequenceControl, TC->sourceID );
391 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED >> 8);
391 TM.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED >> SHIFT_1_BYTE);
392 392 TM.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED );
393 393 // DATA FIELD HEADER
394 394 TM.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
395 395 TM.serviceType = TM_TYPE_TC_EXE;
396 396 TM.serviceSubType = TM_SUBTYPE_EXE_NOK;
397 397 TM.destinationID = destinationID;
398 TM.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
399 TM.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
400 TM.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
401 TM.time[3] = (unsigned char) (time_management_regs->coarse_time);
402 TM.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
403 TM.time[5] = (unsigned char) (time_management_regs->fine_time);
398 TM.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES);
399 TM.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES);
400 TM.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE);
401 TM.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time);
402 TM.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE);
403 TM.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time);
404 404 //
405 TM.tc_failure_code[0] = (unsigned char) (CORRUPTED >> 8);
405 TM.tc_failure_code[0] = (unsigned char) (CORRUPTED >> SHIFT_1_BYTE);
406 406 TM.tc_failure_code[1] = (unsigned char) (CORRUPTED );
407 407 TM.telecommand_pkt_id[0] = TC->packetID[0];
408 408 TM.telecommand_pkt_id[1] = TC->packetID[1];
@@ -494,12 +494,12 void increment_seq_counter_destination_i
494 494 break;
495 495 }
496 496
497 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
498 sequence_cnt = sequenceCounters_TC_EXE[ i ] & 0x3fff;
497 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE;
498 sequence_cnt = sequenceCounters_TC_EXE[ i ] & SEQ_CNT_MASK;
499 499
500 500 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
501 501
502 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
502 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> SHIFT_1_BYTE);
503 503 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
504 504
505 505 // increment the sequence counter
@@ -58,13 +58,13 ring_node * getRingNodeToSendCWF( unsign
58 58
59 59 node = NULL;
60 60 switch ( frequencyChannel ) {
61 case 1:
61 case CHANNELF1:
62 62 node = ring_node_to_send_cwf_f1;
63 63 break;
64 case 2:
64 case CHANNELF2:
65 65 node = ring_node_to_send_cwf_f2;
66 66 break;
67 case 3:
67 case CHANNELF3:
68 68 node = ring_node_to_send_cwf_f3;
69 69 break;
70 70 default:
@@ -80,13 +80,13 ring_node * getRingNodeToSendSWF( unsign
80 80
81 81 node = NULL;
82 82 switch ( frequencyChannel ) {
83 case 0:
83 case CHANNELF0:
84 84 node = ring_node_to_send_swf_f0;
85 85 break;
86 case 1:
86 case CHANNELF1:
87 87 node = ring_node_to_send_swf_f1;
88 88 break;
89 case 2:
89 case CHANNELF2:
90 90 node = ring_node_to_send_swf_f2;
91 91 break;
92 92 default:
@@ -115,20 +115,20 inline void waveforms_isr_f3( void )
115 115 { // in modes other than STANDBY and BURST, send the CWF_F3 data
116 116 //***
117 117 // F3
118 if ( (waveform_picker_regs->status & 0xc0) != 0x00 ) { // [1100 0000] check the f3 full bits
118 if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F3) != INIT_CHAR ) { // [1100 0000] check the f3 full bits
119 119 ring_node_to_send_cwf_f3 = current_ring_node_f3->previous;
120 120 current_ring_node_f3 = current_ring_node_f3->next;
121 if ((waveform_picker_regs->status & 0x40) == 0x40){ // [0100 0000] f3 buffer 0 is full
121 if ((waveform_picker_regs->status & BIT_WFP_BUF_F3_0) == BIT_WFP_BUF_F3_0){ // [0100 0000] f3 buffer 0 is full
122 122 ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time;
123 123 ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time;
124 124 waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address;
125 waveform_picker_regs->status = waveform_picker_regs->status & 0x00008840; // [1000 1000 0100 0000]
125 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F3_0; // [1000 1000 0100 0000]
126 126 }
127 else if ((waveform_picker_regs->status & 0x80) == 0x80){ // [1000 0000] f3 buffer 1 is full
127 else if ((waveform_picker_regs->status & BIT_WFP_BUF_F3_1) == BIT_WFP_BUF_F3_1){ // [1000 0000] f3 buffer 1 is full
128 128 ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time;
129 129 ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time;
130 130 waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address;
131 waveform_picker_regs->status = waveform_picker_regs->status & 0x00008880; // [1000 1000 1000 0000]
131 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F3_1; // [1000 1000 1000 0000]
132 132 }
133 133 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
134 134 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
@@ -142,12 +142,11 inline void waveforms_isr_burst( void )
142 142 unsigned char status;
143 143 rtems_status_code spare_status;
144 144
145 status = (waveform_picker_regs->status & 0x30) >> 4; // [0011 0000] get the status bits for f2
146
145 status = (waveform_picker_regs->status & BITS_WFP_STATUS_F2) >> SHIFT_WFP_STATUS_F2; // [0011 0000] get the status bits for f2
147 146
148 147 switch(status)
149 148 {
150 case 1:
149 case BIT_WFP_BUFFER_0:
151 150 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
152 151 ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2;
153 152 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
@@ -157,9 +156,9 inline void waveforms_isr_burst( void )
157 156 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
158 157 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
159 158 }
160 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
159 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_0; // [0100 0100 0001 0000]
161 160 break;
162 case 2:
161 case BIT_WFP_BUFFER_1:
163 162 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
164 163 ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2;
165 164 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
@@ -169,7 +168,7 inline void waveforms_isr_burst( void )
169 168 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
170 169 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 );
171 170 }
172 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
171 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_1; // [0100 0100 0010 0000]
173 172 break;
174 173 default:
175 174 break;
@@ -182,26 +181,26 inline void waveform_isr_normal_sbm1_sbm
182 181
183 182 //***
184 183 // F0
185 if ( (waveform_picker_regs->status & 0x03) != 0x00 ) // [0000 0011] check the f0 full bits
184 if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F0) != INIT_CHAR ) // [0000 0011] check the f0 full bits
186 185 {
187 186 swf0_ready_flag_f1 = true;
188 187 swf0_ready_flag_f2 = true;
189 188 ring_node_to_send_swf_f0 = current_ring_node_f0->previous;
190 189 current_ring_node_f0 = current_ring_node_f0->next;
191 if ( (waveform_picker_regs->status & 0x01) == 0x01)
190 if ( (waveform_picker_regs->status & BIT_WFP_BUFFER_0) == BIT_WFP_BUFFER_0)
192 191 {
193 192
194 193 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time;
195 194 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time;
196 195 waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address;
197 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001]
196 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F0_0; // [0001 0001 0000 0001]
198 197 }
199 else if ( (waveform_picker_regs->status & 0x02) == 0x02)
198 else if ( (waveform_picker_regs->status & BIT_WFP_BUFFER_1) == BIT_WFP_BUFFER_1)
200 199 {
201 200 ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time;
202 201 ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time;
203 202 waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address;
204 waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010]
203 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F0_1; // [0001 0001 0000 0010]
205 204 }
206 205 // send an event to the WFRM task for resynchro activities
207 206 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_SWF_RESYNCH );
@@ -209,23 +208,23 inline void waveform_isr_normal_sbm1_sbm
209 208
210 209 //***
211 210 // F1
212 if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bits
211 if ( (waveform_picker_regs->status & 0x0c) != INIT_CHAR ) { // [0000 1100] check the f1 full bits
213 212 // (1) change the receiving buffer for the waveform picker
214 213 ring_node_to_send_cwf_f1 = current_ring_node_f1->previous;
215 214 current_ring_node_f1 = current_ring_node_f1->next;
216 if ( (waveform_picker_regs->status & 0x04) == 0x04)
215 if ( (waveform_picker_regs->status & BIT_WFP_BUF_F1_0) == BIT_WFP_BUF_F1_0)
217 216 {
218 217 ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time;
219 218 ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time;
220 219 waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address;
221 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0
220 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F1_0; // [0010 0010 0000 0100] f1 bits = 0
222 221 }
223 else if ( (waveform_picker_regs->status & 0x08) == 0x08)
222 else if ( (waveform_picker_regs->status & BIT_WFP_BUF_F1_1) == BIT_WFP_BUF_F1_1)
224 223 {
225 224 ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time;
226 225 ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time;
227 226 waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address;
228 waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0
227 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F1_1; // [0010 0010 0000 1000] f1 bits = 0
229 228 }
230 229 // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed)
231 230 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_NORM_S1_S2 );
@@ -233,24 +232,24 inline void waveform_isr_normal_sbm1_sbm
233 232
234 233 //***
235 234 // F2
236 if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bit
235 if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F2) != INIT_CHAR ) { // [0011 0000] check the f2 full bit
237 236 // (1) change the receiving buffer for the waveform picker
238 237 ring_node_to_send_cwf_f2 = current_ring_node_f2->previous;
239 238 ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2;
240 239 current_ring_node_f2 = current_ring_node_f2->next;
241 if ( (waveform_picker_regs->status & 0x10) == 0x10)
240 if ( (waveform_picker_regs->status & BIT_WFP_BUF_F2_0) == BIT_WFP_BUF_F2_0)
242 241 {
243 242 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time;
244 243 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time;
245 244 waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address;
246 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000]
245 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_0; // [0100 0100 0001 0000]
247 246 }
248 else if ( (waveform_picker_regs->status & 0x20) == 0x20)
247 else if ( (waveform_picker_regs->status & BIT_WFP_BUF_F2_1) == BIT_WFP_BUF_F2_1)
249 248 {
250 249 ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time;
251 250 ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time;
252 251 waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address;
253 waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000]
252 waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_1; // [0100 0100 0010 0000]
254 253 }
255 254 // (2) send an event for the waveforms transmission
256 255 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_NORM_S1_S2 );
@@ -283,9 +282,9 rtems_isr waveforms_isr( rtems_vector_nu
283 282 //*************************************************
284 283 // copy the status bits in the housekeeping packets
285 284 housekeeping_packet.hk_lfr_vhdl_iir_cal =
286 (unsigned char) ((waveform_picker_regs->status & 0xff00) >> 8);
285 (unsigned char) ((waveform_picker_regs->status & BYTE0_MASK) >> SHIFT_1_BYTE);
287 286
288 if ( (waveform_picker_regs->status & 0xff00) != 0x00) // [1111 1111 0000 0000] check the error bits
287 if ( (waveform_picker_regs->status & BYTE0_MASK) != INIT_CHAR) // [1111 1111 0000 0000] check the error bits
289 288 {
290 289 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 );
291 290 }
@@ -397,12 +396,12 rtems_task cwf3_task(rtems_task_argument
397 396
398 397 // init the ring_node_cwf3_light structure
399 398 ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light;
400 ring_node_cwf3_light.coarseTime = 0x00;
401 ring_node_cwf3_light.fineTime = 0x00;
399 ring_node_cwf3_light.coarseTime = INIT_CHAR;
400 ring_node_cwf3_light.fineTime = INIT_CHAR;
402 401 ring_node_cwf3_light.next = NULL;
403 402 ring_node_cwf3_light.previous = NULL;
404 403 ring_node_cwf3_light.sid = SID_NORM_CWF_F3;
405 ring_node_cwf3_light.status = 0x00;
404 ring_node_cwf3_light.status = INIT_CHAR;
406 405
407 406 BOOT_PRINTF("in CWF3 ***\n");
408 407
@@ -413,8 +412,8 rtems_task cwf3_task(rtems_task_argument
413 412 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
414 413 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) )
415 414 {
416 ring_node_to_send_cwf = getRingNodeToSendCWF( 3 );
417 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01)
415 ring_node_to_send_cwf = getRingNodeToSendCWF( CHANNELF3 );
416 if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & BIT_CWF_LONG_F3) == BIT_CWF_LONG_F3)
418 417 {
419 418 PRINTF("send CWF_LONG_F3\n");
420 419 ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3;
@@ -452,7 +451,7 rtems_task cwf2_task(rtems_task_argument
452 451 ring_node *ring_node_to_send;
453 452 unsigned long long int acquisitionTimeF0_asLong;
454 453
455 acquisitionTimeF0_asLong = 0x00;
454 acquisitionTimeF0_asLong = INIT_CHAR;
456 455
457 456 status = get_message_queue_id_send( &queue_id );
458 457 if (status != RTEMS_SUCCESSFUL)
@@ -467,7 +466,7 rtems_task cwf2_task(rtems_task_argument
467 466 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
468 467 rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2 | RTEMS_EVENT_MODE_BURST,
469 468 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
470 ring_node_to_send = getRingNodeToSendCWF( 2 );
469 ring_node_to_send = getRingNodeToSendCWF( CHANNELF2 );
471 470 if (event_out == RTEMS_EVENT_MODE_BURST)
472 471 { // data are sent whatever the transition time
473 472 status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) );
@@ -487,7 +486,7 rtems_task cwf2_task(rtems_task_argument
487 486 {
488 487 ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2;
489 488 // extract the snapshot
490 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2, acquisitionTimeF0_asLong,
489 build_snapshot_from_ring( ring_node_to_send_swf_f2, CHANNELF2, acquisitionTimeF0_asLong,
491 490 &ring_node_swf2_extracted, swf2_extracted );
492 491 extractSWF2 = false;
493 492 swf2_ready = true; // once the snapshot at f2 is ready the CWF1 task will send an event to WFRM
@@ -575,7 +574,7 rtems_task swbd_task(rtems_task_argument
575 574 rtems_event_set event_out;
576 575 unsigned long long int acquisitionTimeF0_asLong;
577 576
578 acquisitionTimeF0_asLong = 0x00;
577 acquisitionTimeF0_asLong = INIT_CHAR;
579 578
580 579 BOOT_PRINTF("in SWBD ***\n")
581 580
@@ -656,6 +655,7 int send_waveform_CWF3_light( ring_node
656 655 */
657 656
658 657 unsigned int i;
658 unsigned int j;
659 659 int ret;
660 660 rtems_status_code status;
661 661
@@ -674,12 +674,10 int send_waveform_CWF3_light( ring_node
674 674 for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
675 675 {
676 676 sample = (char*) &dataPtr[ (i * NB_WORDS_SWF_BLK) ];
677 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ];
678 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ];
679 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ];
680 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ];
681 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ];
682 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ];
677 for (j=0; j < CWF_BLK_SIZE; j++)
678 {
679 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + j] = sample[ j ];
680 }
683 681 }
684 682
685 683 // SEND PACKET
@@ -695,57 +693,57 void compute_acquisition_time( unsigned
695 693 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime )
696 694 {
697 695 unsigned long long int acquisitionTimeAsLong;
698 unsigned char localAcquisitionTime[6];
696 unsigned char localAcquisitionTime[BYTES_PER_TIME];
699 697 double deltaT;
700 698
701 deltaT = 0.;
699 deltaT = INIT_FLOAT;
702 700
703 localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 24 );
704 localAcquisitionTime[1] = (unsigned char) ( coarseTime >> 16 );
705 localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 8 );
706 localAcquisitionTime[3] = (unsigned char) ( coarseTime );
707 localAcquisitionTime[4] = (unsigned char) ( fineTime >> 8 );
708 localAcquisitionTime[5] = (unsigned char) ( fineTime );
701 localAcquisitionTime[BYTE_0] = (unsigned char) ( coarseTime >> SHIFT_3_BYTES );
702 localAcquisitionTime[BYTE_1] = (unsigned char) ( coarseTime >> SHIFT_2_BYTES );
703 localAcquisitionTime[BYTE_2] = (unsigned char) ( coarseTime >> SHIFT_1_BYTE );
704 localAcquisitionTime[BYTE_3] = (unsigned char) ( coarseTime );
705 localAcquisitionTime[BYTE_4] = (unsigned char) ( fineTime >> SHIFT_1_BYTE );
706 localAcquisitionTime[BYTE_5] = (unsigned char) ( fineTime );
709 707
710 acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 )
711 + ( (unsigned long long int) localAcquisitionTime[1] << 32 )
712 + ( (unsigned long long int) localAcquisitionTime[2] << 24 )
713 + ( (unsigned long long int) localAcquisitionTime[3] << 16 )
714 + ( (unsigned long long int) localAcquisitionTime[4] << 8 )
715 + ( (unsigned long long int) localAcquisitionTime[5] );
708 acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[BYTE_0] << SHIFT_5_BYTES )
709 + ( (unsigned long long int) localAcquisitionTime[BYTE_1] << SHIFT_4_BYTES )
710 + ( (unsigned long long int) localAcquisitionTime[BYTE_2] << SHIFT_3_BYTES )
711 + ( (unsigned long long int) localAcquisitionTime[BYTE_3] << SHIFT_2_BYTES )
712 + ( (unsigned long long int) localAcquisitionTime[BYTE_4] << SHIFT_1_BYTE )
713 + ( (unsigned long long int) localAcquisitionTime[BYTE_5] );
716 714
717 715 switch( sid )
718 716 {
719 717 case SID_NORM_SWF_F0:
720 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ;
718 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * T0_IN_FINETIME ;
721 719 break;
722 720
723 721 case SID_NORM_SWF_F1:
724 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ;
722 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * T1_IN_FINETIME ;
725 723 break;
726 724
727 725 case SID_NORM_SWF_F2:
728 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ;
726 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * T2_IN_FINETIME ;
729 727 break;
730 728
731 729 case SID_SBM1_CWF_F1:
732 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ;
730 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T1_IN_FINETIME ;
733 731 break;
734 732
735 733 case SID_SBM2_CWF_F2:
736 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
734 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T2_IN_FINETIME ;
737 735 break;
738 736
739 737 case SID_BURST_CWF_F2:
740 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ;
738 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T2_IN_FINETIME ;
741 739 break;
742 740
743 741 case SID_NORM_CWF_F3:
744 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ;
742 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * T3_IN_FINETIME ;
745 743 break;
746 744
747 745 case SID_NORM_CWF_LONG_F3:
748 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ;
746 deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T3_IN_FINETIME ;
749 747 break;
750 748
751 749 default:
@@ -756,12 +754,12 void compute_acquisition_time( unsigned
756 754
757 755 acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT;
758 756 //
759 acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40);
760 acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32);
761 acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24);
762 acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16);
763 acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 );
764 acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong );
757 acquisitionTime[BYTE_0] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_5_BYTES);
758 acquisitionTime[BYTE_1] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_4_BYTES);
759 acquisitionTime[BYTE_2] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_3_BYTES);
760 acquisitionTime[BYTE_3] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_2_BYTES);
761 acquisitionTime[BYTE_4] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_1_BYTE );
762 acquisitionTime[BYTE_5] = (unsigned char) (acquisitionTimeAsLong );
765 763
766 764 }
767 765
@@ -788,10 +786,10 void build_snapshot_from_ring( ring_node
788 786 unsigned int deltaT_F1;
789 787 unsigned long long int deltaT_F2;
790 788
791 deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
792 deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384;
793 deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144;
794 sampleOffset_asLong = 0x00;
789 deltaT_F0 = DELTAT_F0;
790 deltaT_F1 = DELTAF_F1;
791 deltaT_F2 = DELTAF_F2;
792 sampleOffset_asLong = INIT_CHAR;
795 793
796 794 // (1) get the f0 acquisition time => the value is passed in argument
797 795
@@ -801,22 +799,22 void build_snapshot_from_ring( ring_node
801 799 // (3) compute the acquisition time of the current snapshot
802 800 switch(frequencyChannel)
803 801 {
804 case 1: // 1 is for F1 = 4096 Hz
802 case CHANNELF1: // 1 is for F1 = 4096 Hz
805 803 acquisitionTime_asLong = centerTime_asLong - deltaT_F1;
806 804 nb_ring_nodes = NB_RING_NODES_F1;
807 frequency_asLong = 4096;
808 nbTicksPerSample_asLong = 16; // 65536 / 4096;
805 frequency_asLong = FREQ_F1;
806 nbTicksPerSample_asLong = TICKS_PER_T1; // 65536 / 4096;
809 807 break;
810 case 2: // 2 is for F2 = 256 Hz
808 case CHANNELF2: // 2 is for F2 = 256 Hz
811 809 acquisitionTime_asLong = centerTime_asLong - deltaT_F2;
812 810 nb_ring_nodes = NB_RING_NODES_F2;
813 frequency_asLong = 256;
814 nbTicksPerSample_asLong = 256; // 65536 / 256;
811 frequency_asLong = FREQ_F2;
812 nbTicksPerSample_asLong = TICKS_PER_T2; // 65536 / 256;
815 813 break;
816 814 default:
817 815 acquisitionTime_asLong = centerTime_asLong;
818 frequency_asLong = 256;
819 nbTicksPerSample_asLong = 256;
816 frequency_asLong = FREQ_F2;
817 nbTicksPerSample_asLong = TICKS_PER_T2;
820 818 break;
821 819 }
822 820
@@ -835,30 +833,30 void build_snapshot_from_ring( ring_node
835 833 }
836 834
837 835 // (5) compute the number of samples to take in the current buffer
838 sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16;
836 sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> SHIFT_2_BYTES;
839 837 nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
840 838 //PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong);
841 839
842 // (6) compute the final acquisition time
843 acquisitionTime_asLong = bufferAcquisitionTime_asLong +
844 sampleOffset_asLong * nbTicksPerSample_asLong;
840 // (6) compute the final acquisition time
841 acquisitionTime_asLong = bufferAcquisitionTime_asLong +
842 (sampleOffset_asLong * nbTicksPerSample_asLong);
845 843
846 844 // (7) copy the acquisition time at the beginning of the extrated snapshot
847 845 ptr1 = (unsigned char*) &acquisitionTime_asLong;
848 846 // fine time
849 847 ptr2 = (unsigned char*) &ring_node_swf_extracted->fineTime;
850 ptr2[2] = ptr1[ 4 + 2 ];
851 ptr2[3] = ptr1[ 5 + 2 ];
848 ptr2[BYTE_2] = ptr1[ BYTE_4 + OFFSET_2_BYTES ];
849 ptr2[BYTE_3] = ptr1[ BYTE_5 + OFFSET_2_BYTES ];
852 850 // coarse time
853 851 ptr2 = (unsigned char*) &ring_node_swf_extracted->coarseTime;
854 ptr2[0] = ptr1[ 0 + 2 ];
855 ptr2[1] = ptr1[ 1 + 2 ];
856 ptr2[2] = ptr1[ 2 + 2 ];
857 ptr2[3] = ptr1[ 3 + 2 ];
852 ptr2[BYTE_0] = ptr1[ BYTE_0 + OFFSET_2_BYTES ];
853 ptr2[BYTE_1] = ptr1[ BYTE_1 + OFFSET_2_BYTES ];
854 ptr2[BYTE_2] = ptr1[ BYTE_2 + OFFSET_2_BYTES ];
855 ptr2[BYTE_3] = ptr1[ BYTE_3 + OFFSET_2_BYTES ];
858 856
859 857 // re set the synchronization bit
860 858 timeCharPtr = (unsigned char*) &ring_node_to_send->coarseTime;
861 ptr2[0] = ptr2[0] | (timeCharPtr[0] & 0x80); // [1000 0000]
859 ptr2[0] = ptr2[0] | (timeCharPtr[0] & SYNC_BIT); // [1000 0000]
862 860
863 861 if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) )
864 862 {
@@ -895,15 +893,15 double computeCorrection( unsigned char
895 893 acquisitionTime = get_acquisition_time( timePtr );
896 894
897 895 // compute center time
898 centerTime = acquisitionTime + 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
899 previousTick = centerTime - (centerTime & 0xffff);
900 nextTick = previousTick + 65536;
896 centerTime = acquisitionTime + DELTAT_F0; // (2048. / 24576. / 2.) * 65536. = 2730.667;
897 previousTick = centerTime - (centerTime & INT16_ALL_F);
898 nextTick = previousTick + TICKS_PER_S;
901 899
902 900 deltaPreviousTick = centerTime - previousTick;
903 901 deltaNextTick = nextTick - centerTime;
904 902
905 deltaPrevious_ms = ((double) deltaPreviousTick) / 65536. * 1000.;
906 deltaNext_ms = ((double) deltaNextTick) / 65536. * 1000.;
903 deltaPrevious_ms = (((double) deltaPreviousTick) / TICKS_PER_S) * MS_PER_S;
904 deltaNext_ms = (((double) deltaNextTick) / TICKS_PER_S) * MS_PER_S;
907 905
908 906 PRINTF2(" delta previous = %.3f ms, delta next = %.2f ms\n", deltaPrevious_ms, deltaNext_ms);
909 907
@@ -911,12 +909,12 double computeCorrection( unsigned char
911 909 if (deltaPreviousTick > deltaNextTick)
912 910 {
913 911 // the snapshot center is just before the second => increase delta_snapshot
914 correctionInF2 = + (deltaNext_ms * 256. / 1000. );
912 correctionInF2 = + (deltaNext_ms * FREQ_F2 / MS_PER_S );
915 913 }
916 914 else
917 915 {
918 916 // the snapshot center is just after the second => decrease delta_snapshot
919 correctionInF2 = - (deltaPrevious_ms * 256. / 1000. );
917 correctionInF2 = - (deltaPrevious_ms * FREQ_F2 / MS_PER_S );
920 918 }
921 919
922 920 PRINTF1(" correctionInF2 = %.2f\n", correctionInF2);
@@ -930,24 +928,24 void applyCorrection( double correction
930 928
931 929 if (correction >= 0.)
932 930 {
933 if ( (1. > correction) && (correction > 0.5) )
931 if ( (ONE_TICK_CORR_INTERVAL_0_MIN < correction) && (correction < ONE_TICK_CORR_INTERVAL_0_MAX) )
934 932 {
935 correctionInt = 1;
933 correctionInt = ONE_TICK_CORR;
936 934 }
937 935 else
938 936 {
939 correctionInt = 2 * floor(correction);
937 correctionInt = CORR_MULT * floor(correction);
940 938 }
941 939 }
942 940 else
943 941 {
944 if ( (-1. < correction) && (correction < -0.5) )
942 if ( (ONE_TICK_CORR_INTERVAL_1_MIN < correction) && (correction < ONE_TICK_CORR_INTERVAL_1_MAX) )
945 943 {
946 correctionInt = -1;
944 correctionInt = -ONE_TICK_CORR;
947 945 }
948 946 else
949 947 {
950 correctionInt = 2 * ceil(correction);
948 correctionInt = CORR_MULT * ceil(correction);
951 949 }
952 950 }
953 951 waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + correctionInt;
@@ -964,7 +962,7 void snapshot_resynchronization( unsigne
964 962 *
965 963 */
966 964
967 static double correction = 0.;
965 static double correction = INIT_FLOAT;
968 966 static resynchro_state state = MEASURE;
969 967 static unsigned int nbSnapshots = 0;
970 968
@@ -1015,7 +1013,7 void reset_wfp_burst_enable( void )
1015 1013 */
1016 1014
1017 1015 // [1000 000] burst f2, f1, f0 enable f3, f2, f1, f0
1018 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable & 0x80;
1016 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable & RST_BITS_RUN_BURST_EN;
1019 1017 }
1020 1018
1021 1019 void reset_wfp_status( void )
@@ -1026,7 +1024,7 void reset_wfp_status( void )
1026 1024 *
1027 1025 */
1028 1026
1029 waveform_picker_regs->status = 0xffff;
1027 waveform_picker_regs->status = INT16_ALL_F;
1030 1028 }
1031 1029
1032 1030 void reset_wfp_buffer_addresses( void )
@@ -1091,13 +1089,13 void reset_waveform_picker_regs( void )
1091 1089 DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1);
1092 1090 DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2);
1093 1091 // 2688 = 8 * 336
1094 waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1
1095 waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples
1096 waveform_picker_regs->start_date = 0x7fffffff; // 0x38
1092 waveform_picker_regs->nb_data_by_buffer = DFLT_WFP_NB_DATA_BY_BUFFER; // 0x30 *** 2688 - 1 => nb samples -1
1093 waveform_picker_regs->snapshot_param = DFLT_WFP_SNAPSHOT_PARAM; // 0x34 *** 2688 => nb samples
1094 waveform_picker_regs->start_date = COARSE_TIME_MASK;
1097 1095 //
1098 1096 // coarse time and fine time registers are not initialized, they are volatile
1099 1097 //
1100 waveform_picker_regs->buffer_length = 0x1f8;// buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8
1098 waveform_picker_regs->buffer_length = DFLT_WFP_BUFFER_LENGTH; // buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8
1101 1099 }
1102 1100
1103 1101 void set_wfp_data_shaping( void )
@@ -1117,12 +1115,12 void set_wfp_data_shaping( void )
1117 1115 data_shaping = parameter_dump_packet.sy_lfr_common_parameters;
1118 1116
1119 1117 waveform_picker_regs->data_shaping =
1120 ( (data_shaping & 0x20) >> 5 ) // BW
1121 + ( (data_shaping & 0x10) >> 3 ) // SP0
1122 + ( (data_shaping & 0x08) >> 1 ) // SP1
1123 + ( (data_shaping & 0x04) << 1 ) // R0
1124 + ( (data_shaping & 0x02) << 3 ) // R1
1125 + ( (data_shaping & 0x01) << 5 ); // R2
1118 ( (data_shaping & BIT_5) >> SHIFT_5_BITS ) // BW
1119 + ( (data_shaping & BIT_4) >> SHIFT_3_BITS ) // SP0
1120 + ( (data_shaping & BIT_3) >> 1 ) // SP1
1121 + ( (data_shaping & BIT_2) << 1 ) // R0
1122 + ( (data_shaping & BIT_1) << SHIFT_3_BITS ) // R1
1123 + ( (data_shaping & BIT_0) << SHIFT_5_BITS ); // R2
1126 1124 }
1127 1125
1128 1126 void set_wfp_burst_enable_register( unsigned char mode )
@@ -1141,15 +1139,15 void set_wfp_burst_enable_register( unsi
1141 1139 case LFR_MODE_NORMAL:
1142 1140 case LFR_MODE_SBM1:
1143 1141 case LFR_MODE_SBM2:
1144 waveform_picker_regs->run_burst_enable = 0x60; // [0110 0000] enable f2 and f1 burst
1142 waveform_picker_regs->run_burst_enable = RUN_BURST_ENABLE_SBM2; // [0110 0000] enable f2 and f1 burst
1145 1143 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1146 1144 break;
1147 1145 case LFR_MODE_BURST:
1148 waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1146 waveform_picker_regs->run_burst_enable = RUN_BURST_ENABLE_BURST; // [0100 0000] f2 burst enabled
1149 1147 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 and f2
1150 1148 break;
1151 1149 default:
1152 waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1150 waveform_picker_regs->run_burst_enable = INIT_CHAR; // [0000 0000] no burst enabled, no waveform enabled
1153 1151 break;
1154 1152 }
1155 1153 }
@@ -1167,10 +1165,10 void set_wfp_delta_snapshot( void )
1167 1165 unsigned int delta_snapshot;
1168 1166 unsigned int delta_snapshot_in_T2;
1169 1167
1170 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
1168 delta_snapshot = (parameter_dump_packet.sy_lfr_n_swf_p[0] * CONST_256)
1171 1169 + parameter_dump_packet.sy_lfr_n_swf_p[1];
1172 1170
1173 delta_snapshot_in_T2 = delta_snapshot * 256;
1171 delta_snapshot_in_T2 = delta_snapshot * FREQ_F2;
1174 1172 waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes
1175 1173 }
1176 1174
@@ -1181,11 +1179,11 void set_wfp_delta_f0_f0_2( void )
1181 1179 float delta_f0_in_float;
1182 1180
1183 1181 delta_snapshot = waveform_picker_regs->delta_snapshot;
1184 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1185 delta_f0_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.;
1182 nb_samples_per_snapshot = (parameter_dump_packet.sy_lfr_n_swf_l[0] * CONST_256) + parameter_dump_packet.sy_lfr_n_swf_l[1];
1183 delta_f0_in_float = (nb_samples_per_snapshot / 2.) * ( (1. / FREQ_F2) - (1. / FREQ_F0) ) * FREQ_F2;
1186 1184
1187 1185 waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float );
1188 waveform_picker_regs->delta_f0_2 = 0x30; // 48 = 11 0000, max 7 bits
1186 waveform_picker_regs->delta_f0_2 = DFLT_WFP_DELTA_F0_2; // 48 = 11 0000, max 7 bits
1189 1187 }
1190 1188
1191 1189 void set_wfp_delta_f1( void )
@@ -1205,8 +1203,8 void set_wfp_delta_f1( void )
1205 1203 float delta_f1_in_float;
1206 1204
1207 1205 delta_snapshot = waveform_picker_regs->delta_snapshot;
1208 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1209 delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.;
1206 nb_samples_per_snapshot = (parameter_dump_packet.sy_lfr_n_swf_l[0] * CONST_256) + parameter_dump_packet.sy_lfr_n_swf_l[1];
1207 delta_f1_in_float = (nb_samples_per_snapshot / 2.) * ( (1. / FREQ_F2) - (1. / FREQ_F1) ) * FREQ_F2;
1210 1208
1211 1209 waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float );
1212 1210 }
@@ -1228,9 +1226,9 void set_wfp_delta_f2( void ) // param
1228 1226 unsigned int nb_samples_per_snapshot;
1229 1227
1230 1228 delta_snapshot = waveform_picker_regs->delta_snapshot;
1231 nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1];
1229 nb_samples_per_snapshot = (parameter_dump_packet.sy_lfr_n_swf_l[0] * CONST_256) + parameter_dump_packet.sy_lfr_n_swf_l[1];
1232 1230
1233 waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2 - 1;
1231 waveform_picker_regs->delta_f2 = delta_snapshot - (nb_samples_per_snapshot / 2) - 1;
1234 1232 }
1235 1233
1236 1234 //*****************
@@ -1289,12 +1287,12 void increment_seq_counter_source_id( un
1289 1287
1290 1288 if (sequence_cnt != NULL)
1291 1289 {
1292 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1293 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1290 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE;
1291 *sequence_cnt = (*sequence_cnt) & SEQ_CNT_MASK;
1294 1292
1295 1293 new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ;
1296 1294
1297 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1295 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> SHIFT_1_BYTE);
1298 1296 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1299 1297
1300 1298 // increment the sequence counter
General Comments 0
You need to be logged in to leave comments. Login now