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