##// END OF EJS Templates
Sync...
paul -
r117:7ccc2641c507 VHDLib206
parent child
Show More
@@ -1,6 +1,6
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.1, 2014-04-07T06:54:09. -->
3 <!-- Written by QtCreator 3.0.1, 2014-04-11T12:08:35. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -209,8 +209,8 enum apid_destid{
209 209 #define PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 (126 - CCSDS_TC_TM_PACKET_OFFSET) // 11 * 9 + 27 - 7
210 210 #define PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 (356 - CCSDS_TC_TM_PACKET_OFFSET) // 11 * 30 + 25 - 7
211 211 #define PACKET_LENGTH_TM_LFR_SCIENCE_BURST_BP2_F1 (806 - CCSDS_TC_TM_PACKET_OFFSET) // 26 * 30 + 26 - 7
212 #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP1_F0 (224 - CCSDS_TC_TM_PACKET_OFFSET) // 22 * 9 + 26 - 7
213 #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM1_BP2_F0 (686 - CCSDS_TC_TM_PACKET_OFFSET) // 22 * 30 + 26 - 7
212 #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 (224 - CCSDS_TC_TM_PACKET_OFFSET) // 22 * 9 + 26 - 7
213 #define PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 (686 - CCSDS_TC_TM_PACKET_OFFSET) // 22 * 30 + 26 - 7
214 214
215 215 #define PACKET_LENGTH_DELTA 11 // 7 + 4
216 216
@@ -34,6 +34,7 rtems_task dumb_task( rtems_task_argumen
34 34 void init_housekeeping_parameters( void );
35 35 void increment_seq_counter( unsigned char *packet_sequence_control);
36 36 void getTime( unsigned char *time);
37 unsigned long long int getTimeAsUnsignedLongLongInt( );
37 38 void send_dumb_hk( void );
38 39
39 40 #endif // FSW_MISC_H_INCLUDED
@@ -18,6 +18,29 typedef struct ring_node
18 18 unsigned int status;
19 19 } ring_node;
20 20
21 typedef struct {
22 unsigned int f0;
23 unsigned int norm_bp1_f0;
24 unsigned int norm_bp2_f0;
25 unsigned int norm_asm_f0;
26 unsigned int sbm_bp1_f0;
27 unsigned int sbm_bp2_f0;
28 } nb_sm_t;
29
30 typedef struct {
31 unsigned int norm_bp1_f0;
32 unsigned int norm_bp2_f0;
33 unsigned int norm_asm_f0;
34 unsigned int burst_sbm_bp1_f0;
35 unsigned int burst_sbm_bp2_f0;
36 unsigned int burst_bp1_f0;
37 unsigned int burst_bp2_f0;
38 unsigned int sbm1_bp1_f0;
39 unsigned int sbm1_bp2_f0;
40 unsigned int sbm2_bp1_f0;
41 unsigned int sbm2_bp2_f0;
42 } nb_sm_before_bp_t;
43
21 44 //************************
22 45 // flight software version
23 46 // this parameters is handled by the Qt project options
@@ -55,17 +78,17 typedef struct ring_node
55 78 #define THR_MODE_NORMAL 1
56 79 #define THR_MODE_BURST 2
57 80
58 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
59 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
60 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
61 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
62 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
63 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
64 #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6
65 #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7
66 #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8
67 #define RTEMS_EVENT_SBM1_BP1_F0 RTEMS_EVENT_9
68 #define RTEMS_EVENT_SBM1_BP2_F0 RTEMS_EVENT_10
81 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
82 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
83 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
84 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
85 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
86 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
87 #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6
88 #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7
89 #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8
90 #define RTEMS_EVENT_BURST_SBM_BP1_F0 RTEMS_EVENT_9
91 #define RTEMS_EVENT_BURST_SBM_BP2_F0 RTEMS_EVENT_10
69 92
70 93 //****************************
71 94 // LFR DEFAULT MODE PARAMETERS
@@ -126,7 +149,7 typedef struct ring_node
126 149
127 150 //*****
128 151 // TIME
129 #define CLKDIV_SM_SIMULATOR (10000 - 1) // 10 ms
152 #define CLKDIV_SM_SIMULATOR (10416 - 1) // 10 ms => nominal is 1/96 = 0.010416667, 10417 - 1 = 10416
130 153 #define TIMER_SM_SIMULATOR 1
131 154 #define HK_PERIOD 100 // 100 * 10ms => 1s
132 155 #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000
@@ -12,10 +12,16
12 12 #define DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 8
13 13
14 14 // TC_LFR_LOAD_BURST_PAR
15 #define DATAFIELD_POS_SY_LFR_B_BP_P0 0
16 #define DATAFIELD_POS_SY_LFR_B_BP_P1 1
15 17
16 18 // TC_LFR_LOAD_SBM1_PAR
19 #define DATAFIELD_POS_SY_LFR_S1_BP_P0 0
20 #define DATAFIELD_POS_SY_LFR_S1_BP_P1 1
17 21
18 22 // TC_LFR_LOAD_SBM2_PAR
23 #define DATAFIELD_POS_SY_LFR_S2_BP_P0 0
24 #define DATAFIELD_POS_SY_LFR_S2_BP_P1 1
19 25
20 26 // TC_LFR_UPDATE_INFO
21 27 #define BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 34
@@ -9,11 +9,10
9 9 #define TOTAL_SIZE_NORM_BP1_F2 108 // 12 * 9 = 108
10 10 #define TOTAL_SIZE_SBM1_BP1_F0 198 // 22 * 9 = 198
11 11 //
12 #define NB_RING_NODES_ASM_F0 12 // AT LEAST 3
13 #define NB_RING_NODES_ASM_F1 2 // AT LEAST 3
14 #define NB_RING_NODES_ASM_F2 2 // AT LEAST 3
15 #define NB_RING_NODES_SBM1_BP1 10 // AT LEAST 3
16 #define NB_RING_NODES_SBM1_BP2 5 // AT LEAST 3
12 #define NB_RING_NODES_SM_F0 12 // AT LEAST 3
13 #define NB_RING_NODES_SM_F1 3 // AT LEAST 3
14 #define NB_RING_NODES_SM_F2 3 // AT LEAST 3
15 #define NB_RING_NODES_ASM_BURST_SBM_F0 10 // AT LEAST 3
17 16 //
18 17 #define NB_BINS_PER_ASM_F0 88
19 18 #define NB_BINS_PER_PKT_ASM_F0 44
@@ -36,22 +35,32
36 35 #define NB_BINS_COMPRESSED_SM_F0 11
37 36 #define NB_BINS_COMPRESSED_SM_F1 13
38 37 #define NB_BINS_COMPRESSED_SM_F2 12
39 #define NB_BINS_COMPRESSED_SM_SBM1_F0 22
38 #define NB_BINS_COMPRESSED_SM_SBM_F0 22
39
40 40 //
41 #define NB_BINS_TO_AVERAGE_ASM_F0 8
42 #define NB_BINS_TO_AVERAGE_ASM_F1 8
43 #define NB_BINS_TO_AVERAGE_ASM_F2 8
44 #define NB_BINS_TO_AVERAGE_ASM_SBM1_F0 4
41 #define NB_BINS_TO_AVERAGE_ASM_F0 8
42 #define NB_BINS_TO_AVERAGE_ASM_F1 8
43 #define NB_BINS_TO_AVERAGE_ASM_F2 8
44 #define NB_BINS_TO_AVERAGE_ASM_SBM_F0 4
45 45 //
46 46 #define TOTAL_SIZE_COMPRESSED_ASM_F0 275 // 11 * 25 WORDS
47 47 #define TOTAL_SIZE_COMPRESSED_ASM_F1 325 // 13 * 25 WORDS
48 48 #define TOTAL_SIZE_COMPRESSED_ASM_F2 300 // 12 * 25 WORDS
49 49 #define TOTAL_SIZE_COMPRESSED_ASM_SBM1 550 // 22 * 25 WORDS
50 // NORM
50 51 #define NB_SM_BEFORE_NORM_BP1_F0 384 // 96 * 4
51 52 #define NB_SM_BEFORE_NORM_BP2_F0 1920 // 96 * 20
52 53 #define NB_SM_BEFORE_NORM_ASM_F0 384 // 384 matrices at f0 = 4.00 second
53 #define NB_SM_BEFORE_SBM1_BP1_F0 24 // 24 matrices at f0 = 0.25 second
54 #define NB_SM_BEFORE_SBM1_BP2_F0 96 // 96 matrices at f0 = 1.00 second
54 // BURST
55 #define NB_SM_BEFORE_BURST_BP1_F0 96 // 96 matrices at f0 = 1.00 second
56 #define NB_SM_BEFORE_BURST_BP2_F0 480 // 480 matrices at f0 = 5.00 second
57 // SBM1
58 #define NB_SM_BEFORE_SBM1_BP1_F0 24 // 24 matrices at f0 = 0.25 second
59 #define NB_SM_BEFORE_SBM1_BP2_F0 96 // 96 matrices at f0 = 1.00 second
60 // SBM2
61 #define NB_SM_BEFORE_SBM2_BP1_F0 96 // 96 matrices at f0 = 1.00 second
62 #define NB_SM_BEFORE_SBM2_BP2_F0 480 // 480 matrices at f0 = 5.00 second
63 // GENERAL
55 64 #define NB_SM_BEFORE_AVF0 8
56 65
57 66 #endif // FSW_PARAMS_PROCESSING_H
@@ -14,34 +14,35
14 14 typedef struct ring_node_sm
15 15 {
16 16 struct ring_node_sm *previous;
17 struct ring_node_sm *next;
17 18 int buffer_address;
18 struct ring_node_sm *next;
19 19 unsigned int status;
20 20 unsigned int coarseTime;
21 21 unsigned int fineTime;
22 22 } ring_node_sm;
23 23
24 typedef struct ring_node_bp
24 typedef struct ring_node_asm
25 25 {
26 struct ring_node_bp *previous;
27 struct ring_node_bp *next;
26 struct ring_node_asm *previous;
27 struct ring_node_asm *next;
28 float asm_burst_sbm_f0[ TIME_OFFSET + TOTAL_SIZE_SM ];
28 29 unsigned int status;
29 unsigned int coarseTime;
30 unsigned int fineTime;
31 Header_TM_LFR_SCIENCE_BP_t header;
32 unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 TM_LFR_SCIENCE_BURST_BP2_F1
33 } ring_node_bp;
30 } ring_node_asm;
34 31
35 typedef struct ring_node_bp_with_spare
32 typedef struct bp_packet
36 33 {
37 struct ring_node_bp_with_spare *previous;
38 struct ring_node_bp_with_spare *next;
39 unsigned int status;
40 unsigned int coarseTime;
41 unsigned int fineTime;
34 Header_TM_LFR_SCIENCE_BP_t header;
35 unsigned char data[ 30 * 22 ]; // MAX size is 22 * 30 [TM_LFR_SCIENCE_BURST_BP2_F1]
36 } bp_packet;
37
38 typedef struct bp_packet_with_spare
39 {
42 40 Header_TM_LFR_SCIENCE_BP_with_spare_t header;
43 unsigned char data[ 9 * 22 ];
44 } ring_node_bp_with_spare;
41 unsigned char data[ 9 * 13 ]; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1
42 } bp_packet_with_spare;
43
44 extern nb_sm_t nb_sm;
45 extern nb_sm_before_bp_t nb_sm_before_bp;
45 46
46 47 extern volatile int sm_f0[ ];
47 48 extern volatile int sm_f1[ ];
@@ -57,23 +58,23 extern spectral_matrix_regs_t *spectral_
57 58 extern rtems_name misc_name[5];
58 59 extern rtems_id Task_id[20]; /* array of task ids */
59 60
60 void init_sm_rings( void );
61 void reset_current_sm_ring_nodes( void );
62 void reset_current_bp_ring_nodes( void );
63
64 61 // ISR
65 void reset_nb_sm_f0( void );
62 void reset_nb_sm_f0( unsigned char lfrMode );
66 63 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
67 64 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
68 65
69 66 // RTEMS TASKS
70 rtems_task avf0_task(rtems_task_argument argument);
71 rtems_task smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator
72 rtems_task matr_task(rtems_task_argument argument);
67 rtems_task smiq_task( rtems_task_argument argument ); // added to test the spectral matrix simulator
68 rtems_task avf0_task( rtems_task_argument lfrRequestedMode );
69 rtems_task matr_task( rtems_task_argument lfrRequestedMode );
73 70
74 //*****************************
75 // Spectral matrices processing
76
71 //******************
72 // Spectral Matrices
73 void SM_init_rings( void );
74 void ASM_init_ring( void );
75 void SM_reset_current_ring_nodes( void );
76 void ASM_reset_current_ring_node( void );
77 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header);
77 78 void SM_average(float *averaged_spec_mat_f0, float *averaged_spec_mat_f1,
78 79 ring_node_sm *ring_node_tab[],
79 80 unsigned int firstTimeF0, unsigned int firstTimeF1 );
@@ -86,23 +87,23 void ASM_convert(volatile float *input_m
86 87 void ASM_send(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
87 88 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
88 89
90 //*****************
91 // Basic Parameters
92
93 void BP_reset_current_ring_nodes( void );
94 void BP_init_header(Header_TM_LFR_SCIENCE_BP_t *header,
95 unsigned int apid, unsigned char sid,
96 unsigned int packetLength , unsigned char blkNr);
97 void BP_init_header_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
98 unsigned int apid, unsigned char sid,
99 unsigned int packetLength, unsigned char blkNr );
89 100 void BP_send(char *data,
90 101 rtems_id queue_id ,
91 102 unsigned int nbBytesToSend );
92 103
93 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header);
94 void init_bp_ring_sbm1_bp1( void );
95 void init_bp_ring_sbm1_bp2( void );
96 void init_headers_bp_ring_sbm1_bp1();
97 void init_header_bp(Header_TM_LFR_SCIENCE_BP_t *header,
98 unsigned int apid, unsigned char sid,
99 unsigned int packetLength , unsigned char blkNr);
100 void init_header_bp_with_spare(Header_TM_LFR_SCIENCE_BP_with_spare_t *header,
101 unsigned int apid, unsigned char sid,
102 unsigned int packetLength, unsigned char blkNr );
103
104 //******************
105 // general functions
104 106 void reset_spectral_matrix_regs( void );
105
106 void set_time( unsigned char *time, unsigned int coarseTime, unsigned int fineTime );
107 void set_time(unsigned char *time, unsigned char *timeInBuffer );
107 108
108 109 #endif // FSW_PROCESSING_H_INCLUDED
@@ -37,7 +37,7 int check_mode_transition( unsigned char
37 37 int check_transition_date( unsigned int transitionCoarseTime );
38 38 int stop_current_mode( void );
39 39 int enter_mode( unsigned char mode , unsigned int transitionCoarseTime );
40 int restart_science_tasks();
40 int restart_science_tasks(unsigned char lfrRequestedMode );
41 41 int suspend_science_tasks();
42 42 void launch_waveform_picker(unsigned char mode , unsigned int transitionCoarseTime);
43 43 void launch_spectral_matrix( unsigned char mode );
@@ -9,6 +9,9
9 9 #include "tm_lfr_tc_exe.h"
10 10 #include "fsw_misc.h"
11 11
12 extern nb_sm_t nb_sm;
13 extern nb_sm_before_bp_t nb_sm_before_bp;
14
12 15 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
13 16 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
14 17 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
@@ -16,6 +19,7 int action_load_sbm1_par(ccsdsTelecomman
16 19 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
17 20 int action_dump_par(rtems_id queue_id );
18 21
22 // NORMAL
19 23 int set_sy_lfr_n_swf_l(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
20 24 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time );
21 25 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
@@ -23,6 +27,18 int set_sy_lfr_n_bp_p0( ccsdsTelecommand
23 27 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
24 28 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
25 29
30 // BURST
31 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
32 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
33
34 // SBM1
35 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
36 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
37
38 // SBM2
39 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
40 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
41
26 42 // TC_LFR_UPDATE_INFO
27 43 unsigned int check_update_info_hk_lfr_mode( unsigned char mode );
28 44 unsigned int check_update_info_hk_tds_mode( unsigned char mode );
@@ -45,11 +45,16 volatile int wf_cont_f3_a [ (NB_SAMPL
45 45 volatile int wf_cont_f3_b [ (NB_SAMPLES_PER_SNAPSHOT) * NB_WORDS_SWF_BLK + TIME_OFFSET ] __attribute__((aligned(0x100)));
46 46 char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK + TIME_OFFSET_IN_BYTES ] __attribute__((aligned(0x100)));
47 47
48 //***********************************
48 49 // SPECTRAL MATRICES GLOBAL VARIABLES
50
51 nb_sm_t nb_sm;
52 nb_sm_before_bp_t nb_sm_before_bp;
53
49 54 // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00
50 volatile int sm_f0[ NB_RING_NODES_ASM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
51 volatile int sm_f1[ NB_RING_NODES_ASM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
52 volatile int sm_f2[ NB_RING_NODES_ASM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
55 volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
56 volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
57 volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
53 58
54 59 // APB CONFIGURATION REGISTERS
55 60 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
@@ -97,9 +97,8 rtems_task Init( rtems_task_argument ign
97 97 init_housekeeping_parameters();
98 98
99 99 init_waveform_rings(); // initialize the waveform rings
100 init_sm_rings(); // initialize spectral matrices rings
101 init_bp_ring_sbm1_bp1(); // initialize basic parameter ring for SBM1 BP1 set
102 init_bp_ring_sbm1_bp2(); // initialize basic parameter ring for SBM1 BP2 set
100 SM_init_rings(); // initialize spectral matrices rings
101 ASM_init_ring(); // initialize the average spectral matrix ring (just for burst, sbm1 and sbm2 asm @ f0 storage)
103 102
104 103 reset_wfp_burst_enable();
105 104 reset_wfp_status();
@@ -363,6 +363,19 void getTime( unsigned char *time)
363 363 time[5] = (unsigned char) (time_management_regs->fine_time);
364 364 }
365 365
366 unsigned long long int getTimeAsUnsignedLongLongInt( )
367 {
368 /** This function write the current local time in the time buffer passed in argument.
369 *
370 */
371 unsigned long long int time;
372
373 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
374 + time_management_regs->fine_time;
375
376 return time;
377 }
378
366 379 void send_dumb_hk( void )
367 380 {
368 381 Packet_TM_LFR_HK_t dummy_hk_packet;
This diff has been collapsed as it changes many lines, (963 lines changed) Show them Hide them
@@ -13,56 +13,426
13 13
14 14 //************************
15 15 // spectral matrices rings
16 ring_node_sm sm_ring_f0[ NB_RING_NODES_ASM_F0 ];
17 ring_node_sm sm_ring_f1[ NB_RING_NODES_ASM_F1 ];
18 ring_node_sm sm_ring_f2[ NB_RING_NODES_ASM_F2 ];
16 ring_node_sm sm_ring_f0[ NB_RING_NODES_SM_F0 ];
17 ring_node_sm sm_ring_f1[ NB_RING_NODES_SM_F1 ];
18 ring_node_sm sm_ring_f2[ NB_RING_NODES_SM_F2 ];
19 19 ring_node_sm *current_ring_node_sm_f0;
20 20 ring_node_sm *ring_node_for_averaging_sm_f0;
21 21 ring_node_sm *current_ring_node_sm_f1;
22 22 ring_node_sm *current_ring_node_sm_f2;
23 23
24 //**********************
25 // basic parameter rings
26 ring_node_bp *current_node_sbm1_bp1_f0;
27 ring_node_bp *current_node_sbm1_bp2_f0;
28 ring_node_bp bp_ring_sbm1_bp1[ NB_RING_NODES_SBM1_BP1 ];
29 ring_node_bp bp_ring_sbm1_bp2[ NB_RING_NODES_SBM1_BP2 ];
24 ring_node_asm asm_ring_burst_sbm_f0[ NB_RING_NODES_ASM_BURST_SBM_F0 ];
25 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
26 ring_node_asm *ring_node_for_processing_asm_burst_sbm_f0;
30 27
31 28 //*****
32 29 // NORM
33 30 // F0
34 31 float asm_norm_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
35 32 float asm_f0_reorganized [ TIME_OFFSET + TOTAL_SIZE_SM ];
36 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
33 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
37 34 float compressed_sm_norm_f0[ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_F0 ];
38 35
39 36 //*****
40 37 // SBM1
41 float asm_sbm1_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
42 float compressed_sm_sbm1[ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_SBM1 ];
38 float asm_sbm_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
39 float compressed_sm_sbm[ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_SBM1 ];
43 40
44 41 unsigned char LFR_BP1_F0[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F0 * 2 ];
45 42 unsigned char LFR_BP1_F1[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F1 ];
46 43 unsigned char LFR_BP1_F2[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F2 ];
47 44
48 unsigned int nb_sm_f0;
45 //***********************************************************
46 // Interrupt Service Routine for spectral matrices processing
47 void reset_nb_sm_f0( unsigned char lfrMode )
48 {
49 nb_sm.f0 = 0;
50 nb_sm.norm_bp1_f0 = 0;
51 nb_sm.norm_bp2_f0 = 0;
52 nb_sm.norm_asm_f0 = 0;
53 nb_sm.sbm_bp1_f0 = 0;
54 nb_sm.sbm_bp2_f0 = 0;
55
56 nb_sm_before_bp.norm_bp1_f0 = parameter_dump_packet.sy_lfr_n_bp_p0 * 96;
57 nb_sm_before_bp.norm_bp2_f0 = parameter_dump_packet.sy_lfr_n_bp_p1 * 96;
58 nb_sm_before_bp.norm_asm_f0 = (parameter_dump_packet.sy_lfr_n_asm_p[0] * 256 + parameter_dump_packet.sy_lfr_n_asm_p[1]) * 96;
59 nb_sm_before_bp.sbm1_bp1_f0 = parameter_dump_packet.sy_lfr_s1_bp_p0 * 24;
60 nb_sm_before_bp.sbm1_bp2_f0 = parameter_dump_packet.sy_lfr_s1_bp_p1 * 96;
61 nb_sm_before_bp.sbm2_bp1_f0 = parameter_dump_packet.sy_lfr_s2_bp_p0 * 96;
62 nb_sm_before_bp.sbm2_bp2_f0 = parameter_dump_packet.sy_lfr_s2_bp_p1 * 96;
63 nb_sm_before_bp.burst_bp1_f0 = parameter_dump_packet.sy_lfr_b_bp_p0 * 96;
64 nb_sm_before_bp.burst_bp2_f0 = parameter_dump_packet.sy_lfr_b_bp_p1 * 96;
65
66 if (lfrMode == LFR_MODE_SBM1)
67 {
68 nb_sm_before_bp.burst_sbm_bp1_f0 = nb_sm_before_bp.sbm1_bp1_f0;
69 nb_sm_before_bp.burst_sbm_bp2_f0 = nb_sm_before_bp.sbm1_bp2_f0;
70 }
71 else if (lfrMode == LFR_MODE_SBM2)
72 {
73 nb_sm_before_bp.burst_sbm_bp1_f0 = nb_sm_before_bp.sbm2_bp1_f0;
74 nb_sm_before_bp.burst_sbm_bp2_f0 = nb_sm_before_bp.sbm2_bp2_f0;
75 }
76 else if (lfrMode == LFR_MODE_BURST)
77 {
78 nb_sm_before_bp.burst_sbm_bp1_f0 = nb_sm_before_bp.burst_bp1_f0;
79 nb_sm_before_bp.burst_sbm_bp2_f0 = nb_sm_before_bp.burst_bp2_f0;
80 }
81 else
82 {
83 nb_sm_before_bp.burst_sbm_bp1_f0 = nb_sm_before_bp.burst_bp1_f0;
84 nb_sm_before_bp.burst_sbm_bp2_f0 = nb_sm_before_bp.burst_bp2_f0;
85 }
86 }
87
88 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
89 {
90 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
91
92 // if ( (spectral_matrix_regs->status & 0x1) == 0x01)
93 // {
94 // current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
95 // spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
96 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe; // 1110
97 // nb_sm_f0 = nb_sm_f0 + 1;
98 // }
99 // else if ( (spectral_matrix_regs->status & 0x2) == 0x02)
100 // {
101 // current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
102 // spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
103 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; // 1101
104 // nb_sm_f0 = nb_sm_f0 + 1;
105 // }
106
107 // if ( (spectral_matrix_regs->status & 0x30) != 0x00)
108 // {
109 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
110 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // 1100 1111
111 // }
112
113 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff3; // 0011
114
115 // if (nb_sm_f0 == (NB_SM_BEFORE_AVF0-1) )
116 // {
117 // ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
118 // if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
119 // {
120 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
121 // }
122 // nb_sm_f0 = 0;
123 // }
124 // else
125 // {
126 // nb_sm.nb_sm_f0 = nb_sm.nb_sm_f0 + 1;
127 // }
128 }
129
130 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
131 {
132 if (nb_sm.f0 == (NB_SM_BEFORE_AVF0-1) )
133 {
134 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
135 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
136 {
137 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
138 }
139 nb_sm.f0 = 0;
140 }
141 else
142 {
143 nb_sm.f0 = nb_sm.f0 + 1;
144 }
145 }
146
147 //************
148 // RTEMS TASKS
149
150 rtems_task smiq_task( rtems_task_argument argument ) // process the Spectral Matrices IRQ
151 {
152 rtems_event_set event_out;
153
154 BOOT_PRINTF("in SMIQ *** \n")
155
156 while(1){
157 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
158 }
159 }
160
161 rtems_task avf0_task( rtems_task_argument lfrRequestedMode )
162 {
163 int i;
164
165 rtems_event_set event_out;
166 rtems_event_set event_for_matr;
167 rtems_status_code status;
168 ring_node_sm *ring_node_tab[8];
169 unsigned long long int localTime;
170
171 reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
172
173 BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", lfrRequestedMode)
174
175 while(1){
176 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
177 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
178 for ( i = 2; i < (NB_SM_BEFORE_AVF0+1); i++ )
179 {
180 ring_node_for_averaging_sm_f0 = ring_node_for_averaging_sm_f0->previous;
181 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
182 }
183
184 localTime = getTimeAsUnsignedLongLongInt( );
185
186 // compute the average and store it in the averaged_sm_f1 buffer
187 SM_average( asm_norm_f0, current_ring_node_asm_burst_sbm_f0->asm_burst_sbm_f0,
188 ring_node_tab,
189 nb_sm.norm_bp1_f0, nb_sm.sbm_bp1_f0 );
190
191 localTime = getTimeAsUnsignedLongLongInt( ) - localTime;
192
193 // update nb_average
194 nb_sm.norm_bp1_f0 = nb_sm.norm_bp1_f0 + NB_SM_BEFORE_AVF0;
195 nb_sm.norm_bp2_f0 = nb_sm.norm_bp2_f0 + NB_SM_BEFORE_AVF0;
196 nb_sm.norm_asm_f0 = nb_sm.norm_asm_f0 + NB_SM_BEFORE_AVF0;
197 nb_sm.sbm_bp1_f0 = nb_sm.sbm_bp1_f0 + NB_SM_BEFORE_AVF0;
198 nb_sm.sbm_bp2_f0 = nb_sm.sbm_bp2_f0 + NB_SM_BEFORE_AVF0;
199
200 //***********************************************************
201 // build a composite event that will be sent to the MATR task
202 event_for_matr = 0x00;
203
204 if (nb_sm.sbm_bp1_f0 == nb_sm_before_bp.burst_sbm_bp1_f0)
205 {
206 nb_sm.sbm_bp1_f0 = 0;
207 // the ring node is ready for BP calculations
208 ring_node_for_processing_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0;
209 // set another ring for the ASM storage
210 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
211 if ( (lfrCurrentMode == LFR_MODE_BURST)
212 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
213 {
214 event_for_matr = event_for_matr | RTEMS_EVENT_BURST_SBM_BP1_F0;
215 }
216 }
217
218 if (nb_sm.sbm_bp2_f0 == nb_sm_before_bp.burst_sbm_bp2_f0)
219 {
220 nb_sm.sbm_bp2_f0 = 0;
221 if ( (lfrCurrentMode == LFR_MODE_BURST)
222 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
223 {
224 event_for_matr = event_for_matr | RTEMS_EVENT_BURST_SBM_BP2_F0;
225 }
226 }
49 227
50 void init_sm_rings( void )
228 if (nb_sm.norm_bp1_f0 == nb_sm_before_bp.norm_bp1_f0)
229 {
230 nb_sm.norm_bp1_f0 = 0;
231 if (lfrCurrentMode == LFR_MODE_NORMAL)
232 {
233 event_for_matr = event_for_matr | RTEMS_EVENT_NORM_BP1_F0;
234 }
235 }
236
237 if (nb_sm.norm_bp2_f0 == nb_sm_before_bp.norm_bp2_f0)
238 {
239 nb_sm.norm_bp2_f0 = 0;
240 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
241 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
242 {
243 event_for_matr = event_for_matr | RTEMS_EVENT_NORM_BP2_F0;
244 }
245 }
246
247 if (nb_sm.norm_asm_f0 == nb_sm_before_bp.norm_asm_f0)
248 {
249 nb_sm.norm_asm_f0 = 0;
250 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
251 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
252 {
253 // PRINTF1("%lld\n", localTime)
254 event_for_matr = event_for_matr | RTEMS_EVENT_NORM_ASM_F0;
255 }
256 }
257
258 //*********************************
259 // send the composite event to MATR
260 status = rtems_event_send( Task_id[TASKID_MATR], event_for_matr );
261 if (status != RTEMS_SUCCESSFUL) {
262 printf("in AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
263 }
264 }
265 }
266
267 rtems_task matr_task( rtems_task_argument lfrRequestedMode )
268 {
269 spw_ioctl_pkt_send spw_ioctl_send_ASM;
270 rtems_event_set event_out;
271 rtems_status_code status;
272 rtems_id queue_id;
273 Header_TM_LFR_SCIENCE_ASM_t headerASM;
274 bp_packet_with_spare current_node_norm_bp1_f0;
275 bp_packet current_node_norm_bp2_f0;
276 bp_packet current_node_sbm_bp1_f0;
277 bp_packet current_node_sbm_bp2_f0;
278 unsigned long long int localTime;
279
280 ASM_init_header( &headerASM );
281
282 //*************
283 // NORM headers
284 BP_init_header_with_spare( &current_node_norm_bp1_f0.header,
285 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP1_F0,
286 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0, NB_BINS_COMPRESSED_SM_F0 );
287 BP_init_header( &current_node_norm_bp2_f0.header,
288 APID_TM_SCIENCE_NORMAL_BURST, SID_NORM_BP2_F0,
289 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0, NB_BINS_COMPRESSED_SM_F0);
290
291 //****************************
292 // BURST SBM1 and SBM2 headers
293 if ( (lfrRequestedMode == LFR_MODE_BURST)
294 || (lfrRequestedMode == LFR_MODE_NORMAL) || (lfrRequestedMode == LFR_MODE_STANDBY) )
295 {
296 BP_init_header( &current_node_sbm_bp1_f0.header,
297 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP1_F0,
298 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
299 BP_init_header( &current_node_sbm_bp2_f0.header,
300 APID_TM_SCIENCE_NORMAL_BURST, SID_BURST_BP2_F0,
301 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
302 }
303 else if ( lfrRequestedMode == LFR_MODE_SBM1 )
304 {
305 BP_init_header( &current_node_sbm_bp1_f0.header,
306 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP1_F0,
307 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
308 BP_init_header( &current_node_sbm_bp2_f0.header,
309 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM1_BP2_F0,
310 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
311 }
312 else if ( lfrRequestedMode == LFR_MODE_SBM2 )
313 {
314 BP_init_header( &current_node_sbm_bp1_f0.header,
315 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP1_F0,
316 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
317 BP_init_header( &current_node_sbm_bp2_f0.header,
318 APID_TM_SCIENCE_SBM1_SBM2, SID_SBM2_BP2_F0,
319 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0, NB_BINS_COMPRESSED_SM_SBM_F0);
320 }
321 else
322 {
323 PRINTF1("ERR *** in MATR *** unexpected lfrRequestedMode passed as argument = %d\n", (unsigned int) lfrRequestedMode)
324 }
325
326 status = get_message_queue_id_send( &queue_id );
327 if (status != RTEMS_SUCCESSFUL)
328 {
329 PRINTF1("in MATR *** ERR get_message_queue_id_send %d\n", status)
330 }
331
332 BOOT_PRINTF1("in MATR *** lfrRequestedMode = %d\n", lfrRequestedMode)
333
334 while(1){
335 rtems_event_receive( RTEMS_EVENT_NORM_BP1_F0 | RTEMS_EVENT_NORM_BP2_F0 | RTEMS_EVENT_NORM_ASM_F0
336 | RTEMS_EVENT_BURST_SBM_BP1_F0 | RTEMS_EVENT_BURST_SBM_BP2_F0,
337 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
338 localTime = getTimeAsUnsignedLongLongInt( );
339 //****************
340 //****************
341 // BURST SBM1 SBM2
342 //****************
343 //****************
344 if ( event_out & RTEMS_EVENT_BURST_SBM_BP1_F0 )
345 {
346 // 1) compress the matrix for Basic Parameters calculation
347 ASM_compress_reorganize_and_divide( current_ring_node_asm_burst_sbm_f0->asm_burst_sbm_f0, compressed_sm_sbm,
348 nb_sm_before_bp.burst_sbm_bp1_f0,
349 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
350 ASM_F0_INDICE_START);
351 // 2) compute the BP1 set
352
353 // 3) send the BP1 set
354 set_time( current_node_sbm_bp1_f0.header.time, (unsigned char *) &compressed_sm_sbm );
355 set_time( current_node_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &compressed_sm_sbm );
356 BP_send( (char *) &current_node_sbm_bp1_f0.header, queue_id,
357 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA);
358 // 4) compute the BP2 set if needed
359 if ( event_out & RTEMS_EVENT_BURST_SBM_BP2_F0 )
360 {
361 // 1) compute the BP2 set
362
363 // 2) send the BP2 set
364 set_time( current_node_sbm_bp2_f0.header.time, (unsigned char *) &compressed_sm_sbm );
365 set_time( current_node_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &compressed_sm_sbm );
366 BP_send( (char *) &current_node_sbm_bp2_f0.header, queue_id,
367 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA);
368 }
369 }
370
371 //*****
372 //*****
373 // NORM
374 //*****
375 //*****
376 if (event_out & RTEMS_EVENT_NORM_BP1_F0)
377 {
378 // 1) compress the matrix for Basic Parameters calculation
379 ASM_compress_reorganize_and_divide( asm_norm_f0, compressed_sm_norm_f0,
380 nb_sm_before_bp.norm_bp1_f0,
381 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
382 ASM_F0_INDICE_START );
383 // 2) compute the BP1 set
384
385 // 3) send the BP1 set
386 set_time( current_node_norm_bp1_f0.header.time, (unsigned char *) &compressed_sm_norm_f0 );
387 set_time( current_node_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &compressed_sm_norm_f0 );
388 BP_send( (char *) &current_node_norm_bp1_f0.header, queue_id,
389 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA);
390 if (event_out & RTEMS_EVENT_NORM_BP2_F0)
391 {
392 // 1) compute the BP2 set
393
394 // 2) send the BP2 set
395 set_time( current_node_norm_bp2_f0.header.time, (unsigned char *) &compressed_sm_norm_f0 );
396 set_time( current_node_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &compressed_sm_norm_f0 );
397 BP_send( (char *) &current_node_norm_bp2_f0.header, queue_id,
398 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA);
399 }
400 }
401
402 if (event_out & RTEMS_EVENT_NORM_ASM_F0)
403 {
404 // 1) reorganize the ASM and divide
405 ASM_reorganize_and_divide( asm_norm_f0, asm_f0_reorganized, NB_SM_BEFORE_NORM_BP1_F0 );
406 // 2) convert the float array in a char array
407 ASM_convert( asm_f0_reorganized, asm_f0_char);
408 // 3) send the spectral matrix packets
409 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
410 // localTime = getTimeAsUnsignedLongLongInt( ) - localTime;
411 // PRINTF1("in MATR *** %lld\n", localTime)
412 }
413
414 }
415 }
416
417 //******************
418 // Spectral Matrices
419
420 void SM_init_rings( void )
51 421 {
52 422 unsigned char i;
53 423
54 424 // F0 RING
55 425 sm_ring_f0[0].next = (ring_node_sm*) &sm_ring_f0[1];
56 sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_ASM_F0-1];
426 sm_ring_f0[0].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-1];
57 427 sm_ring_f0[0].buffer_address =
58 428 (int) &sm_f0[ 0 ];
59 429
60 sm_ring_f0[NB_RING_NODES_ASM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0];
61 sm_ring_f0[NB_RING_NODES_ASM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_ASM_F0-2];
62 sm_ring_f0[NB_RING_NODES_ASM_F0-1].buffer_address =
63 (int) &sm_f0[ (NB_RING_NODES_ASM_F0-1) * TOTAL_SIZE_SM ];
430 sm_ring_f0[NB_RING_NODES_SM_F0-1].next = (ring_node_sm*) &sm_ring_f0[0];
431 sm_ring_f0[NB_RING_NODES_SM_F0-1].previous = (ring_node_sm*) &sm_ring_f0[NB_RING_NODES_SM_F0-2];
432 sm_ring_f0[NB_RING_NODES_SM_F0-1].buffer_address =
433 (int) &sm_f0[ (NB_RING_NODES_SM_F0-1) * TOTAL_SIZE_SM ];
64 434
65 for(i=1; i<NB_RING_NODES_ASM_F0-1; i++)
435 for(i=1; i<NB_RING_NODES_SM_F0-1; i++)
66 436 {
67 437 sm_ring_f0[i].next = (ring_node_sm*) &sm_ring_f0[i+1];
68 438 sm_ring_f0[i].previous = (ring_node_sm*) &sm_ring_f0[i-1];
@@ -72,16 +442,16 void init_sm_rings( void )
72 442
73 443 // F1 RING
74 444 sm_ring_f1[0].next = (ring_node_sm*) &sm_ring_f1[1];
75 sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_ASM_F1-1];
445 sm_ring_f1[0].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-1];
76 446 sm_ring_f1[0].buffer_address =
77 447 (int) &sm_f1[ 0 ];
78 448
79 sm_ring_f1[NB_RING_NODES_ASM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0];
80 sm_ring_f1[NB_RING_NODES_ASM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_ASM_F1-2];
81 sm_ring_f1[NB_RING_NODES_ASM_F1-1].buffer_address =
82 (int) &sm_f1[ (NB_RING_NODES_ASM_F1-1) * TOTAL_SIZE_SM ];
449 sm_ring_f1[NB_RING_NODES_SM_F1-1].next = (ring_node_sm*) &sm_ring_f1[0];
450 sm_ring_f1[NB_RING_NODES_SM_F1-1].previous = (ring_node_sm*) &sm_ring_f1[NB_RING_NODES_SM_F1-2];
451 sm_ring_f1[NB_RING_NODES_SM_F1-1].buffer_address =
452 (int) &sm_f1[ (NB_RING_NODES_SM_F1-1) * TOTAL_SIZE_SM ];
83 453
84 for(i=1; i<NB_RING_NODES_ASM_F1-1; i++)
454 for(i=1; i<NB_RING_NODES_SM_F1-1; i++)
85 455 {
86 456 sm_ring_f1[i].next = (ring_node_sm*) &sm_ring_f1[i+1];
87 457 sm_ring_f1[i].previous = (ring_node_sm*) &sm_ring_f1[i-1];
@@ -91,16 +461,16 void init_sm_rings( void )
91 461
92 462 // F2 RING
93 463 sm_ring_f2[0].next = (ring_node_sm*) &sm_ring_f2[1];
94 sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_ASM_F2-1];
464 sm_ring_f2[0].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-1];
95 465 sm_ring_f2[0].buffer_address =
96 466 (int) &sm_f2[ 0 ];
97 467
98 sm_ring_f2[NB_RING_NODES_ASM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0];
99 sm_ring_f2[NB_RING_NODES_ASM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_ASM_F2-2];
100 sm_ring_f2[NB_RING_NODES_ASM_F2-1].buffer_address =
101 (int) &sm_f2[ (NB_RING_NODES_ASM_F2-1) * TOTAL_SIZE_SM ];
468 sm_ring_f2[NB_RING_NODES_SM_F2-1].next = (ring_node_sm*) &sm_ring_f2[0];
469 sm_ring_f2[NB_RING_NODES_SM_F2-1].previous = (ring_node_sm*) &sm_ring_f2[NB_RING_NODES_SM_F2-2];
470 sm_ring_f2[NB_RING_NODES_SM_F2-1].buffer_address =
471 (int) &sm_f2[ (NB_RING_NODES_SM_F2-1) * TOTAL_SIZE_SM ];
102 472
103 for(i=1; i<NB_RING_NODES_ASM_F2-1; i++)
473 for(i=1; i<NB_RING_NODES_SM_F2-1; i++)
104 474 {
105 475 sm_ring_f2[i].next = (ring_node_sm*) &sm_ring_f2[i+1];
106 476 sm_ring_f2[i].previous = (ring_node_sm*) &sm_ring_f2[i-1];
@@ -116,7 +486,26 void init_sm_rings( void )
116 486 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->matrixF0_Address0)
117 487 }
118 488
119 void reset_current_sm_ring_nodes( void )
489 void ASM_init_ring( void )
490 {
491 unsigned char i;
492
493 asm_ring_burst_sbm_f0[0].next = (ring_node_asm*) &asm_ring_burst_sbm_f0[1];
494 asm_ring_burst_sbm_f0[0].previous = (ring_node_asm*) &asm_ring_burst_sbm_f0[NB_RING_NODES_ASM_BURST_SBM_F0-1];
495
496 asm_ring_burst_sbm_f0[NB_RING_NODES_ASM_BURST_SBM_F0-1].next
497 = (ring_node_asm*) &asm_ring_burst_sbm_f0[0];
498 asm_ring_burst_sbm_f0[NB_RING_NODES_ASM_BURST_SBM_F0-1].previous
499 = (ring_node_asm*) &asm_ring_burst_sbm_f0[NB_RING_NODES_ASM_BURST_SBM_F0-2];
500
501 for(i=1; i<NB_RING_NODES_ASM_BURST_SBM_F0-1; i++)
502 {
503 asm_ring_burst_sbm_f0[i].next = (ring_node_asm*) &asm_ring_burst_sbm_f0[i+1];
504 asm_ring_burst_sbm_f0[i].previous = (ring_node_asm*) &asm_ring_burst_sbm_f0[i-1];
505 }
506 }
507
508 void SM_reset_current_ring_nodes( void )
120 509 {
121 510 current_ring_node_sm_f0 = sm_ring_f0;
122 511 current_ring_node_sm_f1 = sm_ring_f1;
@@ -125,319 +514,51 void reset_current_sm_ring_nodes( void )
125 514 ring_node_for_averaging_sm_f0 = sm_ring_f0;
126 515 }
127 516
128 void reset_current_bp_ring_nodes( void )
129 {
130 current_node_sbm1_bp1_f0 = bp_ring_sbm1_bp1;
131 current_node_sbm1_bp2_f0 = bp_ring_sbm1_bp2;
132 }
133
134 //***********************************************************
135 // Interrupt Service Routine for spectral matrices processing
136 void reset_nb_sm_f0( void )
137 {
138 nb_sm_f0 = 0;
139 }
140
141 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
517 void ASM_reset_current_ring_node( void )
142 518 {
143 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
144
145 if ( (spectral_matrix_regs->status & 0x1) == 0x01)
146 {
147 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
148 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
149 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe; // 1110
150 nb_sm_f0 = nb_sm_f0 + 1;
151 }
152 else if ( (spectral_matrix_regs->status & 0x2) == 0x02)
153 {
154 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
155 spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
156 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; // 1101
157 nb_sm_f0 = nb_sm_f0 + 1;
158 }
159
160 if ( (spectral_matrix_regs->status & 0x30) != 0x00)
161 {
162 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
163 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // 1100 1111
164 }
165
166 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff3; // 0011
167
168 if (nb_sm_f0 == (NB_SM_BEFORE_AVF0-1) )
169 {
170 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
171 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
172 {
173 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
174 }
175 nb_sm_f0 = 0;
176 }
177 else
178 {
179 nb_sm_f0 = nb_sm_f0 + 1;
180 }
181 }
182
183 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
184 {
185 if (nb_sm_f0 == (NB_SM_BEFORE_AVF0-1) )
186 {
187 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
188 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
189 {