@@ -1,2 +1,2 | |||
|
1 | 1 | 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters |
|
2 | 321ffad81ce675a1ad47d6fec71f04137fd44501 header/lfr_common_headers | |
|
2 | 0adeb6c86feb96a126ce48641604949b87c70481 header/lfr_common_headers |
@@ -1,171 +1,157 | |||
|
1 | 1 | #ifndef FSW_MISC_H_INCLUDED |
|
2 | 2 | #define FSW_MISC_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <stdio.h> |
|
6 | 6 | #include <grspw.h> |
|
7 | 7 | #include <grlib_regs.h> |
|
8 | 8 | |
|
9 | 9 | #include "fsw_params.h" |
|
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 | 13 | #define WATCHDOG_LOOP_PRINTF 10 |
|
15 | 14 | #define WATCHDOG_LOOP_DEBUG 3 |
|
16 | 15 | |
|
17 | #define DUMB_MESSAGE_NB 15 | |
|
18 | 16 | #define NB_RTEMS_EVENTS 32 |
|
19 | 17 | #define EVENT_12 12 |
|
20 | 18 | #define EVENT_13 13 |
|
21 | 19 | #define EVENT_14 14 |
|
22 | #define DUMB_MESSAGE_0 "in DUMB *** default" | |
|
23 | 20 | #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 | 21 | #define DUMB_MESSAGE_12 "WATCHDOG timer" |
|
35 | 22 | #define DUMB_MESSAGE_13 "TIMECODE timer" |
|
36 | #define DUMB_MESSAGE_14 "TIMECODE ISR" | |
|
37 | 23 | |
|
38 | 24 | enum lfr_reset_cause_t{ |
|
39 | 25 | UNKNOWN_CAUSE, |
|
40 | 26 | POWER_ON, |
|
41 | 27 | TC_RESET, |
|
42 | 28 | WATCHDOG, |
|
43 | 29 | ERROR_RESET, |
|
44 | 30 | UNEXP_RESET |
|
45 | 31 | }; |
|
46 | 32 | |
|
47 | 33 | typedef struct{ |
|
48 | 34 | unsigned char dpu_spw_parity; |
|
49 | 35 | unsigned char dpu_spw_disconnect; |
|
50 | 36 | unsigned char dpu_spw_escape; |
|
51 | 37 | unsigned char dpu_spw_credit; |
|
52 | 38 | unsigned char dpu_spw_write_sync; |
|
53 | 39 | unsigned char timecode_erroneous; |
|
54 | 40 | unsigned char timecode_missing; |
|
55 | 41 | unsigned char timecode_invalid; |
|
56 | 42 | unsigned char time_timecode_it; |
|
57 | 43 | unsigned char time_not_synchro; |
|
58 | 44 | unsigned char time_timecode_ctr; |
|
59 | 45 | unsigned char ahb_correctable; |
|
60 | 46 | } hk_lfr_le_t; |
|
61 | 47 | |
|
62 | 48 | typedef struct{ |
|
63 | 49 | unsigned char dpu_spw_early_eop; |
|
64 | 50 | unsigned char dpu_spw_invalid_addr; |
|
65 | 51 | unsigned char dpu_spw_eep; |
|
66 | 52 | unsigned char dpu_spw_rx_too_big; |
|
67 | 53 | } hk_lfr_me_t; |
|
68 | 54 | |
|
69 | 55 | #define B00 196 |
|
70 | 56 | #define B01 196 |
|
71 | 57 | #define B02 0 |
|
72 | 58 | #define B10 131 |
|
73 | 59 | #define B11 -244 |
|
74 | 60 | #define B12 131 |
|
75 | 61 | #define B20 161 |
|
76 | 62 | #define B21 -314 |
|
77 | 63 | #define B22 161 |
|
78 | 64 | |
|
79 | 65 | #define A00 1 |
|
80 | 66 | #define A01 -925 |
|
81 | 67 | #define A02 0 |
|
82 | 68 | #define A10 1 |
|
83 | 69 | #define A11 -947 |
|
84 | 70 | #define A12 439 |
|
85 | 71 | #define A20 1 |
|
86 | 72 | #define A21 -993 |
|
87 | 73 | #define A22 486 |
|
88 | 74 | |
|
89 | 75 | #define GAIN_B0 12 |
|
90 | 76 | #define GAIN_B1 11 |
|
91 | 77 | #define GAIN_B2 10 |
|
92 | 78 | |
|
93 | 79 | #define GAIN_A0 10 |
|
94 | 80 | #define GAIN_A1 9 |
|
95 | 81 | #define GAIN_A2 9 |
|
96 | 82 | |
|
97 | 83 | #define NB_COEFFS 3 |
|
98 | 84 | #define COEFF0 0 |
|
99 | 85 | #define COEFF1 1 |
|
100 | 86 | #define COEFF2 2 |
|
101 | 87 | |
|
102 | 88 | typedef struct filter_ctx |
|
103 | 89 | { |
|
104 | 90 | int W[NB_COEFFS][NB_COEFFS]; |
|
105 | 91 | }filter_ctx; |
|
106 | 92 | |
|
107 | 93 | extern gptimer_regs_t *gptimer_regs; |
|
108 | 94 | extern void ASR16_get_FPRF_IURF_ErrorCounters( unsigned int*, unsigned int* ); |
|
109 | 95 | extern void CCR_getInstructionAndDataErrorCounters( unsigned int*, unsigned int* ); |
|
110 | 96 | |
|
111 | 97 | extern rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic |
|
112 | 98 | extern rtems_id HK_id;// id of the HK rate monotonic period |
|
113 | 99 | extern rtems_name name_avgv_rate_monotonic; // name of the AVGV rate monotonic |
|
114 | 100 | extern rtems_id AVGV_id;// id of the AVGV rate monotonic period |
|
115 | 101 | |
|
116 | 102 | void timer_configure( unsigned char timer, unsigned int clock_divider, |
|
117 | 103 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ); |
|
118 | 104 | void timer_start( unsigned char timer ); |
|
119 | 105 | void timer_stop( unsigned char timer ); |
|
120 | 106 | void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider); |
|
121 | 107 | |
|
122 | 108 | // WATCHDOG |
|
123 | 109 | rtems_isr watchdog_isr( rtems_vector_number vector ); |
|
124 | 110 | void watchdog_configure(void); |
|
125 | 111 | void watchdog_stop(void); |
|
126 | 112 | void watchdog_reload(void); |
|
127 | 113 | void watchdog_start(void); |
|
128 | 114 | |
|
129 | 115 | // SERIAL LINK |
|
130 | 116 | int send_console_outputs_on_apbuart_port( void ); |
|
131 | 117 | int enable_apbuart_transmitter( void ); |
|
132 | 118 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value); |
|
133 | 119 | |
|
134 | 120 | // RTEMS TASKS |
|
135 | 121 | rtems_task load_task( rtems_task_argument argument ); |
|
136 | 122 | rtems_task hous_task( rtems_task_argument argument ); |
|
137 | 123 | rtems_task avgv_task( rtems_task_argument argument ); |
|
138 | 124 | rtems_task dumb_task( rtems_task_argument unused ); |
|
139 | 125 | rtems_task scrubbing_task( rtems_task_argument unused ); |
|
140 | 126 | rtems_task calibration_sweep_task( rtems_task_argument unused ); |
|
141 | 127 | |
|
142 | 128 | void init_housekeeping_parameters( void ); |
|
143 | 129 | void increment_seq_counter(unsigned short *packetSequenceControl); |
|
144 | 130 | void getTime( unsigned char *time); |
|
145 | 131 | unsigned long long int getTimeAsUnsignedLongLongInt( ); |
|
146 | 132 | void send_dumb_hk( void ); |
|
147 | 133 | void get_temperatures( unsigned char *temperatures ); |
|
148 | 134 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ); |
|
149 | 135 | void get_cpu_load( unsigned char *resource_statistics ); |
|
150 | 136 | void set_hk_lfr_sc_potential_flag( bool state ); |
|
151 | 137 | void set_sy_lfr_pas_filter_enabled( bool state ); |
|
152 | 138 | void set_sy_lfr_watchdog_enabled( bool state ); |
|
153 | 139 | void set_hk_lfr_calib_enable( bool state ); |
|
154 | 140 | void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ); |
|
155 | 141 | void hk_lfr_le_me_he_update(); |
|
156 | 142 | void set_hk_lfr_time_not_synchro(); |
|
157 | 143 | |
|
158 | 144 | extern int sched_yield( void ); |
|
159 | 145 | extern void rtems_cpu_usage_reset(); |
|
160 | 146 | extern ring_node *current_ring_node_f3; |
|
161 | 147 | extern ring_node *ring_node_to_send_cwf_f3; |
|
162 | 148 | extern ring_node waveform_ring_f3[]; |
|
163 | 149 | extern unsigned short sequenceCounterHK; |
|
164 | 150 | |
|
165 | 151 | extern unsigned char hk_lfr_q_sd_fifo_size_max; |
|
166 | 152 | extern unsigned char hk_lfr_q_rv_fifo_size_max; |
|
167 | 153 | extern unsigned char hk_lfr_q_p0_fifo_size_max; |
|
168 | 154 | extern unsigned char hk_lfr_q_p1_fifo_size_max; |
|
169 | 155 | extern unsigned char hk_lfr_q_p2_fifo_size_max; |
|
170 | 156 | |
|
171 | 157 | #endif // FSW_MISC_H_INCLUDED |
@@ -1,38 +1,37 | |||
|
1 | 1 | #ifndef LFR_CPU_USAGE_REPORT_H |
|
2 | 2 | #define LFR_CPU_USAGE_REPORT_H |
|
3 | 3 | |
|
4 | 4 | #ifdef HAVE_CONFIG_H |
|
5 | 5 | #include "config.h" |
|
6 | 6 | #endif |
|
7 | 7 | |
|
8 | 8 | #include <rtems.h> |
|
9 | 9 | |
|
10 | 10 | #include <assert.h> |
|
11 | 11 | #include <string.h> |
|
12 | 12 | #include <stdlib.h> |
|
13 | 13 | #include <stdio.h> |
|
14 | 14 | #include <ctype.h> |
|
15 | 15 | #include <inttypes.h> |
|
16 | 16 | |
|
17 | 17 | #include <rtems/cpuuse.h> |
|
18 | 18 | #include <rtems/bspIo.h> |
|
19 | 19 | |
|
20 | 20 | #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ |
|
21 | 21 | #include <rtems/score/timestamp.h> |
|
22 | 22 | #endif |
|
23 | 23 | |
|
24 | 24 | #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__ |
|
25 | 25 | extern Timestamp_Control CPU_usage_Uptime_at_last_reset; |
|
26 | 26 | #else |
|
27 | 27 | extern uint32_t CPU_usage_Ticks_at_last_reset; |
|
28 | 28 | #endif |
|
29 | 29 | |
|
30 | 30 | unsigned char lfr_rtems_cpu_usage_report( void ); |
|
31 | 31 | |
|
32 | 32 | #define CONST_10 10 |
|
33 | 33 | #define CONST_100 100 |
|
34 | 34 | #define CONST_255 255 |
|
35 | 35 | #define CONST_1000 1000 |
|
36 | #define CONST_100000 100000 | |
|
37 | 36 | |
|
38 | 37 | #endif // LFR_CPU_USAGE_REPORT_H |
@@ -1,373 +1,364 | |||
|
1 | 1 | #ifndef FSW_PROCESSING_H_INCLUDED |
|
2 | 2 | #define FSW_PROCESSING_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <grspw.h> |
|
6 | 6 | #include <math.h> |
|
7 | 7 | #include <stdlib.h> // abs() is in the stdlib |
|
8 | 8 | #include <stdio.h> |
|
9 | 9 | #include <math.h> |
|
10 | 10 | #include <grlib_regs.h> |
|
11 | 11 | |
|
12 | 12 | #include "fsw_params.h" |
|
13 | 13 | |
|
14 | 14 | #define SBM_COEFF_PER_NORM_COEFF 2 |
|
15 | 15 | #define MAX_SRC_DATA 780 // MAX size is 26 bins * 30 Bytes [TM_LFR_SCIENCE_BURST_BP2_F1] |
|
16 | 16 | #define MAX_SRC_DATA_WITH_SPARE 143 // 13 bins * 11 Bytes |
|
17 | 17 | |
|
18 | #define NODE_0 0 | |
|
19 | #define NODE_1 1 | |
|
20 | #define NODE_2 2 | |
|
21 | #define NODE_3 3 | |
|
22 | #define NODE_4 4 | |
|
23 | #define NODE_5 5 | |
|
24 | #define NODE_6 6 | |
|
25 | #define NODE_7 7 | |
|
26 | ||
|
27 | 18 | typedef struct ring_node_asm |
|
28 | 19 | { |
|
29 | 20 | struct ring_node_asm *next; |
|
30 | 21 | float matrix[ TOTAL_SIZE_SM ]; |
|
31 | 22 | unsigned int status; |
|
32 | 23 | } ring_node_asm; |
|
33 | 24 | |
|
34 | 25 | typedef struct |
|
35 | 26 | { |
|
36 | 27 | unsigned char targetLogicalAddress; |
|
37 | 28 | unsigned char protocolIdentifier; |
|
38 | 29 | unsigned char reserved; |
|
39 | 30 | unsigned char userApplication; |
|
40 | 31 | unsigned char packetID[BYTES_PER_PACKETID]; |
|
41 | 32 | unsigned char packetSequenceControl[BYTES_PER_SEQ_CTRL]; |
|
42 | 33 | unsigned char packetLength[BYTES_PER_PKT_LEN]; |
|
43 | 34 | // DATA FIELD HEADER |
|
44 | 35 | unsigned char spare1_pusVersion_spare2; |
|
45 | 36 | unsigned char serviceType; |
|
46 | 37 | unsigned char serviceSubType; |
|
47 | 38 | unsigned char destinationID; |
|
48 | 39 | unsigned char time[BYTES_PER_TIME]; |
|
49 | 40 | // AUXILIARY HEADER |
|
50 | 41 | unsigned char sid; |
|
51 | 42 | unsigned char pa_bia_status_info; |
|
52 | 43 | unsigned char sy_lfr_common_parameters_spare; |
|
53 | 44 | unsigned char sy_lfr_common_parameters; |
|
54 | 45 | unsigned char acquisitionTime[BYTES_PER_TIME]; |
|
55 | 46 | unsigned char pa_lfr_bp_blk_nr[BYTES_PER_BLKNR]; |
|
56 | 47 | // SOURCE DATA |
|
57 | 48 | unsigned char data[ MAX_SRC_DATA ]; // MAX size is 26 bins * 30 Bytes [TM_LFR_SCIENCE_BURST_BP2_F1] |
|
58 | 49 | } bp_packet; |
|
59 | 50 | |
|
60 | 51 | typedef struct |
|
61 | 52 | { |
|
62 | 53 | unsigned char targetLogicalAddress; |
|
63 | 54 | unsigned char protocolIdentifier; |
|
64 | 55 | unsigned char reserved; |
|
65 | 56 | unsigned char userApplication; |
|
66 | 57 | unsigned char packetID[BYTES_PER_PACKETID]; |
|
67 | 58 | unsigned char packetSequenceControl[BYTES_PER_SEQ_CTRL]; |
|
68 | 59 | unsigned char packetLength[BYTES_PER_PKT_LEN]; |
|
69 | 60 | // DATA FIELD HEADER |
|
70 | 61 | unsigned char spare1_pusVersion_spare2; |
|
71 | 62 | unsigned char serviceType; |
|
72 | 63 | unsigned char serviceSubType; |
|
73 | 64 | unsigned char destinationID; |
|
74 | 65 | unsigned char time[BYTES_PER_TIME]; |
|
75 | 66 | // AUXILIARY HEADER |
|
76 | 67 | unsigned char sid; |
|
77 | 68 | unsigned char pa_bia_status_info; |
|
78 | 69 | unsigned char sy_lfr_common_parameters_spare; |
|
79 | 70 | unsigned char sy_lfr_common_parameters; |
|
80 | 71 | unsigned char acquisitionTime[BYTES_PER_TIME]; |
|
81 | 72 | unsigned char source_data_spare; |
|
82 | 73 | unsigned char pa_lfr_bp_blk_nr[BYTES_PER_BLKNR]; |
|
83 | 74 | // SOURCE DATA |
|
84 | 75 | unsigned char data[ MAX_SRC_DATA_WITH_SPARE ]; // 13 bins * 11 Bytes |
|
85 | 76 | } bp_packet_with_spare; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1 |
|
86 | 77 | |
|
87 | 78 | typedef struct asm_msg |
|
88 | 79 | { |
|
89 | 80 | ring_node_asm *norm; |
|
90 | 81 | ring_node_asm *burst_sbm; |
|
91 | 82 | rtems_event_set event; |
|
92 | 83 | unsigned int coarseTimeNORM; |
|
93 | 84 | unsigned int fineTimeNORM; |
|
94 | 85 | unsigned int coarseTimeSBM; |
|
95 | 86 | unsigned int fineTimeSBM; |
|
96 | 87 | unsigned int numberOfSMInASMNORM; |
|
97 | 88 | unsigned int numberOfSMInASMSBM; |
|
98 | 89 | } asm_msg; |
|
99 | 90 | |
|
100 | 91 | extern unsigned char thisIsAnASMRestart; |
|
101 | 92 | |
|
102 | 93 | extern volatile int sm_f0[ ]; |
|
103 | 94 | extern volatile int sm_f1[ ]; |
|
104 | 95 | extern volatile int sm_f2[ ]; |
|
105 | 96 | extern unsigned int acquisitionDurations[]; |
|
106 | 97 | |
|
107 | 98 | // parameters |
|
108 | 99 | extern struct param_local_str param_local; |
|
109 | 100 | extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; |
|
110 | 101 | |
|
111 | 102 | // registers |
|
112 | 103 | extern time_management_regs_t *time_management_regs; |
|
113 | 104 | extern volatile spectral_matrix_regs_t *spectral_matrix_regs; |
|
114 | 105 | |
|
115 | 106 | extern rtems_name misc_name[]; |
|
116 | 107 | extern rtems_id Task_id[]; /* array of task ids */ |
|
117 | 108 | |
|
118 | 109 | ring_node * getRingNodeForAveraging( unsigned char frequencyChannel); |
|
119 | 110 | // ISR |
|
120 | 111 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ); |
|
121 | 112 | |
|
122 | 113 | //****************** |
|
123 | 114 | // Spectral Matrices |
|
124 | 115 | void reset_nb_sm( void ); |
|
125 | 116 | // SM |
|
126 | 117 | void SM_init_rings( void ); |
|
127 | 118 | void SM_reset_current_ring_nodes( void ); |
|
128 | 119 | // ASM |
|
129 | 120 | void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes ); |
|
130 | 121 | |
|
131 | 122 | //***************** |
|
132 | 123 | // Basic Parameters |
|
133 | 124 | |
|
134 | 125 | void BP_reset_current_ring_nodes( void ); |
|
135 | 126 | void BP_init_header(bp_packet *packet, |
|
136 | 127 | unsigned int apid, unsigned char sid, |
|
137 | 128 | unsigned int packetLength , unsigned char blkNr); |
|
138 | 129 | void BP_init_header_with_spare(bp_packet_with_spare *packet, |
|
139 | 130 | unsigned int apid, unsigned char sid, |
|
140 | 131 | unsigned int packetLength, unsigned char blkNr ); |
|
141 | 132 | void BP_send( char *data, |
|
142 | 133 | rtems_id queue_id, |
|
143 | 134 | unsigned int nbBytesToSend , unsigned int sid ); |
|
144 | 135 | void BP_send_s1_s2(char *data, |
|
145 | 136 | rtems_id queue_id, |
|
146 | 137 | unsigned int nbBytesToSend, unsigned int sid ); |
|
147 | 138 | |
|
148 | 139 | //****************** |
|
149 | 140 | // general functions |
|
150 | 141 | void reset_sm_status( void ); |
|
151 | 142 | void reset_spectral_matrix_regs( void ); |
|
152 | 143 | void set_time(unsigned char *time, unsigned char *timeInBuffer ); |
|
153 | 144 | unsigned long long int get_acquisition_time( unsigned char *timePtr ); |
|
154 | 145 | unsigned char getSID( rtems_event_set event ); |
|
155 | 146 | |
|
156 | 147 | extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ); |
|
157 | 148 | extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ); |
|
158 | 149 | |
|
159 | 150 | //*************************************** |
|
160 | 151 | // DEFINITIONS OF STATIC INLINE FUNCTIONS |
|
161 | 152 | static inline void SM_average(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, |
|
162 | 153 | ring_node *ring_node_tab[], |
|
163 | 154 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, |
|
164 | 155 | asm_msg *msgForMATR , unsigned char channel); |
|
165 | 156 | |
|
166 | 157 | void ASM_patch( float *inputASM, float *outputASM ); |
|
167 | 158 | |
|
168 | 159 | void extractReImVectors(float *inputASM, float *outputASM, unsigned int asmComponent ); |
|
169 | 160 | |
|
170 | 161 | static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized, |
|
171 | 162 | float divider ); |
|
172 | 163 | |
|
173 | 164 | static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat, |
|
174 | 165 | float divider, |
|
175 | 166 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart); |
|
176 | 167 | |
|
177 | 168 | static inline void ASM_convert(volatile float *input_matrix, char *output_matrix); |
|
178 | 169 | |
|
179 | 170 | unsigned char isPolluted( u_int64_t t0, u_int64_t t1, u_int64_t tbad0, u_int64_t tbad1 ); |
|
180 | 171 | |
|
181 | 172 | unsigned char acquisitionTimeIsValid(unsigned int coarseTime, unsigned int fineTime, unsigned char channel); |
|
182 | 173 | |
|
183 | 174 | void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, |
|
184 | 175 | ring_node *ring_node_tab[], |
|
185 | 176 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, |
|
186 | 177 | asm_msg *msgForMATR, unsigned char channel ) |
|
187 | 178 | { |
|
188 | 179 | float sum; |
|
189 | 180 | unsigned int i; |
|
190 | 181 | unsigned int k; |
|
191 | 182 | unsigned char incomingSMIsValid[NB_SM_BEFORE_AVF0_F1]; |
|
192 | 183 | unsigned int numberOfValidSM; |
|
193 | 184 | unsigned char isValid; |
|
194 | 185 | |
|
195 | 186 | //************** |
|
196 | 187 | // PAS FILTERING |
|
197 | 188 | // check acquisitionTime of the incoming data |
|
198 | 189 | numberOfValidSM = 0; |
|
199 | 190 | for (k=0; k<NB_SM_BEFORE_AVF0_F1; k++) |
|
200 | 191 | { |
|
201 | 192 | isValid = acquisitionTimeIsValid( ring_node_tab[k]->coarseTime, ring_node_tab[k]->fineTime, channel ); |
|
202 | 193 | incomingSMIsValid[k] = isValid; |
|
203 | 194 | numberOfValidSM = numberOfValidSM + isValid; |
|
204 | 195 | } |
|
205 | 196 | |
|
206 | 197 | //************************ |
|
207 | 198 | // AVERAGE SPECTRAL MATRIX |
|
208 | 199 | for(i=0; i<TOTAL_SIZE_SM; i++) |
|
209 | 200 | { |
|
210 | 201 | sum = INIT_FLOAT; |
|
211 | 202 | for ( k = 0; k < NB_SM_BEFORE_AVF0_F1; k++ ) |
|
212 | 203 | { |
|
213 | 204 | if (incomingSMIsValid[k] == MATRIX_IS_NOT_POLLUTED) |
|
214 | 205 | { |
|
215 | 206 | sum = sum + ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ] ; |
|
216 | 207 | } |
|
217 | 208 | } |
|
218 | 209 | |
|
219 | 210 | if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) ) |
|
220 | 211 | { |
|
221 | 212 | averaged_spec_mat_NORM[ i ] = sum; |
|
222 | 213 | averaged_spec_mat_SBM[ i ] = sum; |
|
223 | 214 | msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime; |
|
224 | 215 | msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime; |
|
225 | 216 | msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime; |
|
226 | 217 | msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime; |
|
227 | 218 | } |
|
228 | 219 | else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) ) |
|
229 | 220 | { |
|
230 | 221 | averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum ); |
|
231 | 222 | averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum ); |
|
232 | 223 | } |
|
233 | 224 | else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) ) |
|
234 | 225 | { |
|
235 | 226 | averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum ); |
|
236 | 227 | averaged_spec_mat_SBM[ i ] = sum; |
|
237 | 228 | msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime; |
|
238 | 229 | msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime; |
|
239 | 230 | } |
|
240 | 231 | else |
|
241 | 232 | { |
|
242 | 233 | averaged_spec_mat_NORM[ i ] = sum; |
|
243 | 234 | averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum ); |
|
244 | 235 | msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime; |
|
245 | 236 | msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime; |
|
246 | 237 | // PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM) |
|
247 | 238 | } |
|
248 | 239 | } |
|
249 | 240 | |
|
250 | 241 | //******************* |
|
251 | 242 | // UPDATE SM COUNTERS |
|
252 | 243 | if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) ) |
|
253 | 244 | { |
|
254 | 245 | msgForMATR->numberOfSMInASMNORM = numberOfValidSM; |
|
255 | 246 | msgForMATR->numberOfSMInASMSBM = numberOfValidSM; |
|
256 | 247 | } |
|
257 | 248 | else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) ) |
|
258 | 249 | { |
|
259 | 250 | msgForMATR->numberOfSMInASMNORM = msgForMATR->numberOfSMInASMNORM + numberOfValidSM; |
|
260 | 251 | msgForMATR->numberOfSMInASMSBM = msgForMATR->numberOfSMInASMSBM + numberOfValidSM; |
|
261 | 252 | } |
|
262 | 253 | else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) ) |
|
263 | 254 | { |
|
264 | 255 | msgForMATR->numberOfSMInASMNORM = msgForMATR->numberOfSMInASMNORM + numberOfValidSM; |
|
265 | 256 | msgForMATR->numberOfSMInASMSBM = numberOfValidSM; |
|
266 | 257 | } |
|
267 | 258 | else |
|
268 | 259 | { |
|
269 | 260 | msgForMATR->numberOfSMInASMNORM = numberOfValidSM; |
|
270 | 261 | msgForMATR->numberOfSMInASMSBM = msgForMATR->numberOfSMInASMSBM + numberOfValidSM; |
|
271 | 262 | } |
|
272 | 263 | } |
|
273 | 264 | |
|
274 | 265 | void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider ) |
|
275 | 266 | { |
|
276 | 267 | int frequencyBin; |
|
277 | 268 | int asmComponent; |
|
278 | 269 | unsigned int offsetASM; |
|
279 | 270 | unsigned int offsetASMReorganized; |
|
280 | 271 | |
|
281 | 272 | // BUILD DATA |
|
282 | 273 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) |
|
283 | 274 | { |
|
284 | 275 | for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ ) |
|
285 | 276 | { |
|
286 | 277 | offsetASMReorganized = |
|
287 | 278 | (frequencyBin * NB_VALUES_PER_SM) |
|
288 | 279 | + asmComponent; |
|
289 | 280 | offsetASM = |
|
290 | 281 | (asmComponent * NB_BINS_PER_SM) |
|
291 | 282 | + frequencyBin; |
|
292 | 283 | if ( divider != INIT_FLOAT ) |
|
293 | 284 | { |
|
294 | 285 | averaged_spec_mat_reorganized[offsetASMReorganized ] = averaged_spec_mat[ offsetASM ] / divider; |
|
295 | 286 | } |
|
296 | 287 | else |
|
297 | 288 | { |
|
298 | 289 | averaged_spec_mat_reorganized[offsetASMReorganized ] = INIT_FLOAT; |
|
299 | 290 | } |
|
300 | 291 | } |
|
301 | 292 | } |
|
302 | 293 | } |
|
303 | 294 | |
|
304 | 295 | void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider, |
|
305 | 296 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart ) |
|
306 | 297 | { |
|
307 | 298 | int frequencyBin; |
|
308 | 299 | int asmComponent; |
|
309 | 300 | int offsetASM; |
|
310 | 301 | int offsetCompressed; |
|
311 | 302 | int k; |
|
312 | 303 | |
|
313 | 304 | // BUILD DATA |
|
314 | 305 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) |
|
315 | 306 | { |
|
316 | 307 | for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ ) |
|
317 | 308 | { |
|
318 | 309 | offsetCompressed = // NO TIME OFFSET |
|
319 | 310 | (frequencyBin * NB_VALUES_PER_SM) |
|
320 | 311 | + asmComponent; |
|
321 | 312 | offsetASM = // NO TIME OFFSET |
|
322 | 313 | (asmComponent * NB_BINS_PER_SM) |
|
323 | 314 | + ASMIndexStart |
|
324 | 315 | + (frequencyBin * nbBinsToAverage); |
|
325 | 316 | compressed_spec_mat[ offsetCompressed ] = 0; |
|
326 | 317 | for ( k = 0; k < nbBinsToAverage; k++ ) |
|
327 | 318 | { |
|
328 | 319 | compressed_spec_mat[offsetCompressed ] = |
|
329 | 320 | ( compressed_spec_mat[ offsetCompressed ] |
|
330 | 321 | + averaged_spec_mat[ offsetASM + k ] ); |
|
331 | 322 | } |
|
332 | 323 | compressed_spec_mat[ offsetCompressed ] = |
|
333 | 324 | compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage); |
|
334 | 325 | } |
|
335 | 326 | } |
|
336 | 327 | } |
|
337 | 328 | |
|
338 | 329 | void ASM_convert( volatile float *input_matrix, char *output_matrix) |
|
339 | 330 | { |
|
340 | 331 | unsigned int frequencyBin; |
|
341 | 332 | unsigned int asmComponent; |
|
342 | 333 | char * pt_char_input; |
|
343 | 334 | char * pt_char_output; |
|
344 | 335 | unsigned int offsetInput; |
|
345 | 336 | unsigned int offsetOutput; |
|
346 | 337 | |
|
347 | 338 | pt_char_input = (char*) &input_matrix; |
|
348 | 339 | pt_char_output = (char*) &output_matrix; |
|
349 | 340 | |
|
350 | 341 | // convert all other data |
|
351 | 342 | for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++) |
|
352 | 343 | { |
|
353 | 344 | for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++) |
|
354 | 345 | { |
|
355 | 346 | offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ; |
|
356 | 347 | offsetOutput = SM_BYTES_PER_VAL * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ; |
|
357 | 348 | pt_char_input = (char*) &input_matrix [ offsetInput ]; |
|
358 | 349 | pt_char_output = (char*) &output_matrix[ offsetOutput ]; |
|
359 | 350 | pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float |
|
360 | 351 | pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float |
|
361 | 352 | } |
|
362 | 353 | } |
|
363 | 354 | } |
|
364 | 355 | |
|
365 | 356 | void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat, |
|
366 | 357 | float divider, |
|
367 | 358 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart, unsigned char channel); |
|
368 | 359 | |
|
369 | 360 | int getFBinMask(int k, unsigned char channel); |
|
370 | 361 | |
|
371 | 362 | void init_kcoeff_sbm_from_kcoeff_norm( float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm); |
|
372 | 363 | |
|
373 | 364 | #endif // FSW_PROCESSING_H_INCLUDED |
@@ -1,124 +1,114 | |||
|
1 | 1 | #ifndef TC_LOAD_DUMP_PARAMETERS_H |
|
2 | 2 | #define TC_LOAD_DUMP_PARAMETERS_H |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <stdio.h> |
|
6 | 6 | |
|
7 | 7 | #include "fsw_params.h" |
|
8 | 8 | #include "wf_handler.h" |
|
9 | 9 | #include "tm_lfr_tc_exe.h" |
|
10 | 10 | #include "fsw_misc.h" |
|
11 | 11 | #include "basic_parameters_params.h" |
|
12 | 12 | #include "avf0_prc0.h" |
|
13 | 13 | |
|
14 | 14 | #define FLOAT_EQUAL_ZERO 0.001 |
|
15 | 15 | #define NB_BINS_TO_REMOVE 3 |
|
16 | 16 | #define FI_INTERVAL_COEFF 0.285 |
|
17 | 17 | #define BIN_MIN 0 |
|
18 | 18 | #define BIN_MAX 127 |
|
19 | 19 | #define DELTAF_F0 96. |
|
20 | 20 | #define DELTAF_F1 16. |
|
21 | 21 | #define DELTAF_F2 1. |
|
22 | #define DELTAF_DIV 2. | |
|
23 | ||
|
24 | #define BIT_RW1_F1 0x80 | |
|
25 | #define BIT_RW1_F2 0x40 | |
|
26 | #define BIT_RW2_F1 0x20 | |
|
27 | #define BIT_RW2_F2 0x10 | |
|
28 | #define BIT_RW3_F1 0x08 | |
|
29 | #define BIT_RW3_F2 0x04 | |
|
30 | #define BIT_RW4_F1 0x02 | |
|
31 | #define BIT_RW4_F2 0x01 | |
|
32 | 22 | |
|
33 | 23 | #define WHEEL_1 1 |
|
34 | 24 | #define WHEEL_2 2 |
|
35 | 25 | #define WHEEL_3 3 |
|
36 | 26 | #define WHEEL_4 4 |
|
37 | 27 | #define FREQ_1 1 |
|
38 | 28 | #define FREQ_2 2 |
|
39 | 29 | #define FREQ_3 3 |
|
40 | 30 | #define FREQ_4 4 |
|
41 | 31 | #define FLAG_OFFSET_WHEELS_1_3 8 |
|
42 | 32 | #define FLAG_OFFSET_WHEELS_2_4 4 |
|
43 | 33 | |
|
44 | 34 | #define FLAG_NAN 0 // Not A NUMBER |
|
45 | 35 | #define FLAG_IAN 1 // Is A Number |
|
46 | 36 | |
|
47 | 37 | #define SBM_KCOEFF_PER_NORM_KCOEFF 2 |
|
48 | 38 | |
|
49 | 39 | extern unsigned short sequenceCounterParameterDump; |
|
50 | 40 | extern unsigned short sequenceCounters_TM_DUMP[]; |
|
51 | 41 | extern float k_coeff_intercalib_f0_norm[ ]; |
|
52 | 42 | extern float k_coeff_intercalib_f0_sbm[ ]; |
|
53 | 43 | extern float k_coeff_intercalib_f1_norm[ ]; |
|
54 | 44 | extern float k_coeff_intercalib_f1_sbm[ ]; |
|
55 | 45 | extern float k_coeff_intercalib_f2[ ]; |
|
56 | 46 | extern fbins_masks_t fbins_masks; |
|
57 | 47 | |
|
58 | 48 | int action_load_common_par( ccsdsTelecommandPacket_t *TC ); |
|
59 | 49 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
60 | 50 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
61 | 51 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
62 | 52 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
63 | 53 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
64 | 54 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
65 | 55 | int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
66 | 56 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
67 | 57 | int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
68 | 58 | |
|
69 | 59 | // NORMAL |
|
70 | 60 | int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
71 | 61 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ); |
|
72 | 62 | int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC ); |
|
73 | 63 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ); |
|
74 | 64 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
75 | 65 | int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
76 | 66 | int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC ); |
|
77 | 67 | |
|
78 | 68 | // BURST |
|
79 | 69 | int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
80 | 70 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
81 | 71 | |
|
82 | 72 | // SBM1 |
|
83 | 73 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
84 | 74 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
85 | 75 | |
|
86 | 76 | // SBM2 |
|
87 | 77 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
88 | 78 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
89 | 79 | |
|
90 | 80 | // TC_LFR_UPDATE_INFO |
|
91 | 81 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ); |
|
92 | 82 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ); |
|
93 | 83 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ); |
|
94 | 84 | void set_hk_lfr_sc_rw_f_flag( unsigned char wheel, unsigned char freq, float value ); |
|
95 | 85 | void set_hk_lfr_sc_rw_f_flags( void ); |
|
96 | 86 | int check_sy_lfr_rw_f( ccsdsTelecommandPacket_t *TC, int offset, int* pos, float* value ); |
|
97 | 87 | int check_all_sy_lfr_rw_f( ccsdsTelecommandPacket_t *TC, int *pos, float*value ); |
|
98 | 88 | void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC ); |
|
99 | 89 | void setFBinMask(unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, float sy_lfr_rw_k ); |
|
100 | 90 | void build_sy_lfr_rw_mask( unsigned int channel ); |
|
101 | 91 | void build_sy_lfr_rw_masks(); |
|
102 | 92 | void merge_fbins_masks( void ); |
|
103 | 93 | |
|
104 | 94 | // FBINS_MASK |
|
105 | 95 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ); |
|
106 | 96 | |
|
107 | 97 | // TC_LFR_LOAD_PARS_FILTER_PAR |
|
108 | 98 | int check_sy_lfr_rw_k( ccsdsTelecommandPacket_t *TC, int offset, int* pos, float* value ); |
|
109 | 99 | int check_all_sy_lfr_rw_k( ccsdsTelecommandPacket_t *TC, int *pos, float*value ); |
|
110 | 100 | int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
111 | 101 | |
|
112 | 102 | // KCOEFFICIENTS |
|
113 | 103 | int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id); |
|
114 | 104 | void copyFloatByChar( unsigned char *destination, unsigned char *source ); |
|
115 | 105 | void copyInt32ByChar( unsigned char *destination, unsigned char *source ); |
|
116 | 106 | void copyInt16ByChar( unsigned char *destination, unsigned char *source ); |
|
117 | 107 | void floatToChar( float value, unsigned char* ptr); |
|
118 | 108 | |
|
119 | 109 | void init_parameter_dump( void ); |
|
120 | 110 | void init_kcoefficients_dump( void ); |
|
121 | 111 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ); |
|
122 | 112 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ); |
|
123 | 113 | |
|
124 | 114 | #endif // TC_LOAD_DUMP_PARAMETERS_H |
@@ -1,116 +1,115 | |||
|
1 | 1 | #ifndef WF_HANDLER_H_INCLUDED |
|
2 | 2 | #define WF_HANDLER_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <grspw.h> |
|
6 | 6 | #include <stdio.h> |
|
7 | 7 | #include <math.h> |
|
8 | 8 | #include <fsw_params.h> |
|
9 | 9 | |
|
10 | 10 | #include "fsw_init.h" |
|
11 | 11 | #include "fsw_params_wf_handler.h" |
|
12 | 12 | |
|
13 | 13 | #define pi 3.14159265359 |
|
14 | 14 | #define T0_IN_FINETIME ( 65536. / 24576. ) |
|
15 | 15 | #define T1_IN_FINETIME ( 65536. / 4096. ) |
|
16 | 16 | #define T2_IN_FINETIME ( 65536. / 256. ) |
|
17 | 17 | #define T3_IN_FINETIME ( 65536. / 16. ) |
|
18 | 18 | |
|
19 | 19 | #define TICKS_PER_T1 16 |
|
20 | 20 | #define TICKS_PER_T2 256 |
|
21 | 21 | #define TICKS_PER_S 65536. |
|
22 | 22 | #define MS_PER_S 1000. |
|
23 | 23 | |
|
24 | 24 | #define FREQ_F0 24576. |
|
25 | 25 | #define FREQ_F1 4096. |
|
26 | 26 | #define FREQ_F2 256. |
|
27 | #define FREQ_F3 16. | |
|
28 | 27 | |
|
29 | 28 | #define DELTAT_F0 2731 // (2048. / 24576. / 2.) * 65536. = 2730.667; |
|
30 | 29 | #define DELTAT_F1 16384 // (2048. / 4096. / 2.) * 65536. = 16384; |
|
31 | 30 | #define DELTAT_F2 262144 // (2048. / 256. / 2.) * 65536. = 262144; |
|
32 | 31 | |
|
33 | 32 | #define OFFSET_2_BYTES 2 |
|
34 | 33 | |
|
35 | 34 | #define ONE_TICK_CORR_INTERVAL_0_MIN 0.5 |
|
36 | 35 | #define ONE_TICK_CORR_INTERVAL_0_MAX 1.0 |
|
37 | 36 | #define ONE_TICK_CORR_INTERVAL_1_MIN -1.0 |
|
38 | 37 | #define ONE_TICK_CORR_INTERVAL_1_MAX -0.5 |
|
39 | 38 | #define ONE_TICK_CORR 1 |
|
40 | 39 | #define CORR_MULT 2 |
|
41 | 40 | |
|
42 | 41 | extern int fdSPW; |
|
43 | 42 | |
|
44 | 43 | //***************** |
|
45 | 44 | // waveform buffers |
|
46 | 45 | extern volatile int wf_buffer_f0[ ]; |
|
47 | 46 | extern volatile int wf_buffer_f1[ ]; |
|
48 | 47 | extern volatile int wf_buffer_f2[ ]; |
|
49 | 48 | extern volatile int wf_buffer_f3[ ]; |
|
50 | 49 | |
|
51 | 50 | extern waveform_picker_regs_0_1_18_t *waveform_picker_regs; |
|
52 | 51 | extern time_management_regs_t *time_management_regs; |
|
53 | 52 | extern Packet_TM_LFR_HK_t housekeeping_packet; |
|
54 | 53 | extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; |
|
55 | 54 | extern struct param_local_str param_local; |
|
56 | 55 | |
|
57 | 56 | extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST; |
|
58 | 57 | extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2; |
|
59 | 58 | |
|
60 | 59 | extern rtems_id Task_id[]; /* array of task ids */ |
|
61 | 60 | |
|
62 | 61 | extern unsigned char lfrCurrentMode; |
|
63 | 62 | |
|
64 | 63 | //********** |
|
65 | 64 | // RTEMS_ISR |
|
66 | 65 | void reset_extractSWF( void ); |
|
67 | 66 | rtems_isr waveforms_isr( rtems_vector_number vector ); |
|
68 | 67 | |
|
69 | 68 | //*********** |
|
70 | 69 | // RTEMS_TASK |
|
71 | 70 | rtems_task wfrm_task( rtems_task_argument argument ); |
|
72 | 71 | rtems_task cwf3_task( rtems_task_argument argument ); |
|
73 | 72 | rtems_task cwf2_task( rtems_task_argument argument ); |
|
74 | 73 | rtems_task cwf1_task( rtems_task_argument argument ); |
|
75 | 74 | rtems_task swbd_task( rtems_task_argument argument ); |
|
76 | 75 | |
|
77 | 76 | //****************** |
|
78 | 77 | // general functions |
|
79 | 78 | void WFP_init_rings( void ); |
|
80 | 79 | void init_ring( ring_node ring[], unsigned char nbNodes, volatile int buffer[] , unsigned int bufferSize ); |
|
81 | 80 | void WFP_reset_current_ring_nodes( void ); |
|
82 | 81 | // |
|
83 | 82 | int init_header_continuous_cwf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF ); |
|
84 | 83 | // |
|
85 | 84 | int send_waveform_CWF3_light(ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id ); |
|
86 | 85 | // |
|
87 | 86 | void compute_acquisition_time(unsigned int coarseTime, unsigned int fineTime, |
|
88 | 87 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char *acquisitionTime ); |
|
89 | 88 | void build_snapshot_from_ring(ring_node *ring_node_to_send, unsigned char frequencyChannel , |
|
90 | 89 | unsigned long long acquisitionTimeF0_asLong, ring_node *ring_node_swf_extracted, int *swf_extracted); |
|
91 | 90 | double computeCorrection( unsigned char *timePtr ); |
|
92 | 91 | void applyCorrection( double correction ); |
|
93 | 92 | void snapshot_resynchronization( unsigned char *timePtr ); |
|
94 | 93 | // |
|
95 | 94 | rtems_id get_pkts_queue_id( void ); |
|
96 | 95 | |
|
97 | 96 | //************** |
|
98 | 97 | // wfp registers |
|
99 | 98 | // RESET |
|
100 | 99 | void reset_wfp_burst_enable( void ); |
|
101 | 100 | void reset_wfp_status( void ); |
|
102 | 101 | void reset_wfp_buffer_addresses( void ); |
|
103 | 102 | void reset_waveform_picker_regs( void ); |
|
104 | 103 | // SET |
|
105 | 104 | void set_wfp_data_shaping(void); |
|
106 | 105 | void set_wfp_burst_enable_register( unsigned char mode ); |
|
107 | 106 | void set_wfp_delta_snapshot( void ); |
|
108 | 107 | void set_wfp_delta_f0_f0_2( void ); |
|
109 | 108 | void set_wfp_delta_f1( void ); |
|
110 | 109 | void set_wfp_delta_f2( void ); |
|
111 | 110 | |
|
112 | 111 | //***************** |
|
113 | 112 | // local parameters |
|
114 | 113 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ); |
|
115 | 114 | |
|
116 | 115 | #endif // WF_HANDLER_H_INCLUDED |
@@ -1,94 +1,93 | |||
|
1 | 1 | #define NB_VALUES_PER_SM 25 |
|
2 | 2 | #define NB_BINS_PER_SM 128 |
|
3 | 3 | |
|
4 | 4 | #define NB_BINS_COMPRESSED_SM_F0 11 |
|
5 | 5 | #define ASM_F0_INDICE_START 17 // 88 bins |
|
6 | #define ASM_F0_INDICE_STOP 104 // 2 packets of 44 bins | |
|
7 | 6 | #define NB_BINS_TO_AVERAGE_ASM_F0 8 |
|
8 | 7 | |
|
9 | 8 | void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider ) |
|
10 | 9 | { |
|
11 | 10 | int frequencyBin; |
|
12 | 11 | int asmComponent; |
|
13 | 12 | unsigned int offsetASM; |
|
14 | 13 | unsigned int offsetASMReorganized; |
|
15 | 14 | |
|
16 | 15 | // BUILD DATA |
|
17 | 16 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) |
|
18 | 17 | { |
|
19 | 18 | for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ ) |
|
20 | 19 | { |
|
21 | 20 | offsetASMReorganized = |
|
22 | 21 | frequencyBin * NB_VALUES_PER_SM |
|
23 | 22 | + asmComponent; |
|
24 | 23 | offsetASM = |
|
25 | 24 | asmComponent * NB_BINS_PER_SM |
|
26 | 25 | + frequencyBin; |
|
27 | 26 | averaged_spec_mat_reorganized[offsetASMReorganized ] = |
|
28 | 27 | averaged_spec_mat[ offsetASM ] / divider; |
|
29 | 28 | } |
|
30 | 29 | } |
|
31 | 30 | } |
|
32 | 31 | |
|
33 | 32 | void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider, |
|
34 | 33 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart ) |
|
35 | 34 | { |
|
36 | 35 | int frequencyBin; |
|
37 | 36 | int asmComponent; |
|
38 | 37 | int offsetASM; |
|
39 | 38 | int offsetCompressed; |
|
40 | 39 | int k; |
|
41 | 40 | |
|
42 | 41 | // BUILD DATA |
|
43 | 42 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) |
|
44 | 43 | { |
|
45 | 44 | for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ ) |
|
46 | 45 | { |
|
47 | 46 | offsetCompressed = // NO TIME OFFSET |
|
48 | 47 | frequencyBin * NB_VALUES_PER_SM |
|
49 | 48 | + asmComponent; |
|
50 | 49 | offsetASM = // NO TIME OFFSET |
|
51 | 50 | asmComponent * NB_BINS_PER_SM |
|
52 | 51 | + ASMIndexStart |
|
53 | 52 | + frequencyBin * nbBinsToAverage; |
|
54 | 53 | compressed_spec_mat[ offsetCompressed ] = 0; |
|
55 | 54 | for ( k = 0; k < nbBinsToAverage; k++ ) |
|
56 | 55 | { |
|
57 | 56 | compressed_spec_mat[offsetCompressed ] = |
|
58 | 57 | ( compressed_spec_mat[ offsetCompressed ] |
|
59 | 58 | + averaged_spec_mat[ offsetASM + k ] ); |
|
60 | 59 | } |
|
61 | 60 | compressed_spec_mat[ offsetCompressed ] = |
|
62 | 61 | compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage); |
|
63 | 62 | } |
|
64 | 63 | } |
|
65 | 64 | } |
|
66 | 65 | |
|
67 | 66 | void extractReImVectors( float *inputASM, float *outputASM, unsigned int asmComponent ) |
|
68 | 67 | { |
|
69 | 68 | unsigned int i; |
|
70 | 69 | float re; |
|
71 | 70 | float im; |
|
72 | 71 | |
|
73 | 72 | for (i=0; i<NB_BINS_PER_SM; i++){ |
|
74 | 73 | re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 ]; |
|
75 | 74 | im = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 + 1]; |
|
76 | 75 | outputASM[ (asmComponent *NB_BINS_PER_SM) + i] = re; |
|
77 | 76 | outputASM[ (asmComponent+1)*NB_BINS_PER_SM + i] = im; |
|
78 | 77 | } |
|
79 | 78 | |
|
80 | 79 | } |
|
81 | 80 | |
|
82 | 81 | void ASM_patch( float *inputASM, float *outputASM ) |
|
83 | 82 | { |
|
84 | 83 | extractReImVectors( inputASM, outputASM, 1); // b1b2 |
|
85 | 84 | extractReImVectors( inputASM, outputASM, 3 ); // b1b3 |
|
86 | 85 | extractReImVectors( inputASM, outputASM, 5 ); // b1e1 |
|
87 | 86 | extractReImVectors( inputASM, outputASM, 7 ); // b1e2 |
|
88 | 87 | extractReImVectors( inputASM, outputASM, 10 ); // b2b3 |
|
89 | 88 | extractReImVectors( inputASM, outputASM, 12 ); // b2e1 |
|
90 | 89 | extractReImVectors( inputASM, outputASM, 14 ); // b2e2 |
|
91 | 90 | extractReImVectors( inputASM, outputASM, 17 ); // b3e1 |
|
92 | 91 | extractReImVectors( inputASM, outputASM, 19 ); // b3e2 |
|
93 | 92 | extractReImVectors( inputASM, outputASM, 22 ); // e1e2 |
|
94 | 93 | } |
General Comments 0
You need to be logged in to leave comments.
Login now