##// END OF EJS Templates
There is a message queue between AVFO and MATR...
paul -
r118:7b69e91ff96b VHDLib206
parent child
Show More
@@ -1,6 +1,6
1 #############################################################################
1 #############################################################################
2 # Makefile for building: bin/fsw
2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Thu Apr 3 13:43:01 2014
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Tue Apr 15 07:45:50 2014
4 # Project: fsw-qt.pro
4 # Project: fsw-qt.pro
5 # Template: app
5 # Template: app
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
@@ -13,7 +13,7 CXX = sparc-rtems-g++
13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=6 -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS
13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=6 -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS
14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../../LFR_basic-parameters
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../src/basic_parameters
17 LINK = sparc-rtems-g++
17 LINK = sparc-rtems-g++
18 LFLAGS =
18 LFLAGS =
19 LIBS = $(SUBLIBS)
19 LIBS = $(SUBLIBS)
@@ -53,7 +53,7 SOURCES = ../src/wf_handler.c \
53 ../src/tc_load_dump_parameters.c \
53 ../src/tc_load_dump_parameters.c \
54 ../src/tm_lfr_tc_exe.c \
54 ../src/tm_lfr_tc_exe.c \
55 ../src/tc_acceptance.c \
55 ../src/tc_acceptance.c \
56 ../../LFR_basic-parameters/basic_parameters.c
56 ../src/basic_parameters/basic_parameters.c
57 OBJECTS = obj/wf_handler.o \
57 OBJECTS = obj/wf_handler.o \
58 obj/tc_handler.o \
58 obj/tc_handler.o \
59 obj/fsw_processing.o \
59 obj/fsw_processing.o \
@@ -240,8 +240,8 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_ex
240 obj/tc_acceptance.o: ../src/tc_acceptance.c
240 obj/tc_acceptance.o: ../src/tc_acceptance.c
241 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
241 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
242
242
243 obj/basic_parameters.o: ../../LFR_basic-parameters/basic_parameters.c ../../LFR_basic-parameters/basic_parameters.h
243 obj/basic_parameters.o: ../src/basic_parameters/basic_parameters.c ../src/basic_parameters/basic_parameters.h
244 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../../LFR_basic-parameters/basic_parameters.c
244 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/basic_parameters/basic_parameters.c
245
245
246 ####### Install
246 ####### Install
247
247
@@ -50,7 +50,7 TARGET = fsw
50 INCLUDEPATH += \
50 INCLUDEPATH += \
51 ../src \
51 ../src \
52 ../header \
52 ../header \
53 ../../LFR_basic-parameters
53 ../src/basic_parameters
54
54
55 SOURCES += \
55 SOURCES += \
56 ../src/wf_handler.c \
56 ../src/wf_handler.c \
@@ -63,7 +63,7 SOURCES += \
63 ../src/tc_load_dump_parameters.c \
63 ../src/tc_load_dump_parameters.c \
64 ../src/tm_lfr_tc_exe.c \
64 ../src/tm_lfr_tc_exe.c \
65 ../src/tc_acceptance.c \
65 ../src/tc_acceptance.c \
66 ../../LFR_basic-parameters/basic_parameters.c
66 ../src/basic_parameters/basic_parameters.c
67
67
68
68
69 HEADERS += \
69 HEADERS += \
@@ -81,5 +81,5 HEADERS += \
81 ../header/tm_lfr_tc_exe.h \
81 ../header/tm_lfr_tc_exe.h \
82 ../header/tc_acceptance.h \
82 ../header/tc_acceptance.h \
83 ../header/fsw_params_nb_bytes.h \
83 ../header/fsw_params_nb_bytes.h \
84 ../../LFR_basic-parameters/basic_parameters.h
84 ../src/basic_parameters/basic_parameters.h
85
85
@@ -1,6 +1,6
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE QtCreatorProject>
2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.1, 2014-04-11T12:08:35. -->
3 <!-- Written by QtCreator 3.0.1, 2014-04-16T10:43:41. -->
4 <qtcreator>
4 <qtcreator>
5 <data>
5 <data>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -26,6 +26,7 int start_all_tasks( void );
26 rtems_status_code create_message_queues( void );
26 rtems_status_code create_message_queues( void );
27 rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
27 rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
28 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
28 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
29 rtems_status_code get_message_queue_id_matr( rtems_id *queue_id );
29 //
30 //
30 int start_recv_send_tasks( void );
31 int start_recv_send_tasks( void );
31 //
32 //
@@ -37,4 +37,6 void getTime( unsigned char *time);
37 unsigned long long int getTimeAsUnsignedLongLongInt( );
37 unsigned long long int getTimeAsUnsignedLongLongInt( );
38 void send_dumb_hk( void );
38 void send_dumb_hk( void );
39
39
40 extern int sched_yield( void );
41
40 #endif // FSW_MISC_H_INCLUDED
42 #endif // FSW_MISC_H_INCLUDED
@@ -198,14 +198,17 typedef struct {
198 #define TASK_PRIORITY_STAT 200
198 #define TASK_PRIORITY_STAT 200
199 #define TASK_PRIORITY_DUMB 200
199 #define TASK_PRIORITY_DUMB 200
200
200
201 #define ACTION_MSG_QUEUE_COUNT 10
201 #define MSG_QUEUE_COUNT_RECV 10
202 #define ACTION_MSG_PKTS_COUNT 50
202 #define MSG_QUEUE_COUNT_SEND 50
203 //#define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
203 #define MSG_QUEUE_COUNT_MATR 10
204 #define ACTION_MSG_PKTS_MAX_SIZE 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1
204 //#define MSG_QUEUE_SIZE_SEND (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
205 #define MSG_QUEUE_SIZE_SEND 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1
205 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
206 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
207 #define MSG_QUEUE_SIZE_MATR 20 // two pointers and one rtems_event + 2 integers
206
208
207 #define QUEUE_RECV 0
209 #define QUEUE_RECV 0
208 #define QUEUE_SEND 1
210 #define QUEUE_SEND 1
211 #define QUEUE_MATR 2
209
212
210 //*******
213 //*******
211 // MACROS
214 // MACROS
@@ -13,6 +13,7
13 #define NB_RING_NODES_SM_F1 3 // 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
14 #define NB_RING_NODES_SM_F2 3 // AT LEAST 3
15 #define NB_RING_NODES_ASM_BURST_SBM_F0 10 // AT LEAST 3
15 #define NB_RING_NODES_ASM_BURST_SBM_F0 10 // AT LEAST 3
16 #define NB_RING_NODES_ASM_NORM_F0 10 // AT LEAST 3
16 //
17 //
17 #define NB_BINS_PER_ASM_F0 88
18 #define NB_BINS_PER_ASM_F0 88
18 #define NB_BINS_PER_PKT_ASM_F0 44
19 #define NB_BINS_PER_PKT_ASM_F0 44
@@ -25,7 +25,7 typedef struct ring_node_asm
25 {
25 {
26 struct ring_node_asm *previous;
26 struct ring_node_asm *previous;
27 struct ring_node_asm *next;
27 struct ring_node_asm *next;
28 float asm_burst_sbm_f0[ TIME_OFFSET + TOTAL_SIZE_SM ];
28 float matrix[ TOTAL_SIZE_SM ];
29 unsigned int status;
29 unsigned int status;
30 } ring_node_asm;
30 } ring_node_asm;
31
31
@@ -41,6 +41,15 typedef struct bp_packet_with_spare
41 unsigned char data[ 9 * 13 ]; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1
41 unsigned char data[ 9 * 13 ]; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1
42 } bp_packet_with_spare;
42 } bp_packet_with_spare;
43
43
44 typedef struct asm_msg
45 {
46 ring_node_asm *norm_f0;
47 ring_node_asm *burst_sbmf0;
48 rtems_event_set event;
49 unsigned int coarseTime;
50 unsigned int fineTime;
51 } asm_msg;
52
44 extern nb_sm_t nb_sm;
53 extern nb_sm_t nb_sm;
45 extern nb_sm_before_bp_t nb_sm_before_bp;
54 extern nb_sm_before_bp_t nb_sm_before_bp;
46
55
@@ -71,7 +80,7 rtems_task matr_task( rtems_task_argumen
71 //******************
80 //******************
72 // Spectral Matrices
81 // Spectral Matrices
73 void SM_init_rings( void );
82 void SM_init_rings( void );
74 void ASM_init_ring( void );
83 void ASM_init_rings( void );
75 void SM_reset_current_ring_nodes( void );
84 void SM_reset_current_ring_nodes( void );
76 void ASM_reset_current_ring_node( void );
85 void ASM_reset_current_ring_node( void );
77 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header);
86 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header);
@@ -106,4 +115,6 void BP_send(char *data,
106 void reset_spectral_matrix_regs( void );
115 void reset_spectral_matrix_regs( void );
107 void set_time(unsigned char *time, unsigned char *timeInBuffer );
116 void set_time(unsigned char *time, unsigned char *timeInBuffer );
108
117
118 extern rtems_status_code get_message_queue_id_matr( rtems_id *queue_id );
119
109 #endif // FSW_PROCESSING_H_INCLUDED
120 #endif // FSW_PROCESSING_H_INCLUDED
@@ -40,10 +40,10 int enter_mode( unsigned char mode , uns
40 int restart_science_tasks(unsigned char lfrRequestedMode );
40 int restart_science_tasks(unsigned char lfrRequestedMode );
41 int suspend_science_tasks();
41 int suspend_science_tasks();
42 void launch_waveform_picker(unsigned char mode , unsigned int transitionCoarseTime);
42 void launch_waveform_picker(unsigned char mode , unsigned int transitionCoarseTime);
43 void launch_spectral_matrix( unsigned char mode );
43 void launch_spectral_matrix( void );
44 void launch_spectral_matrix_simu( void );
44 void set_irq_on_new_ready_matrix(unsigned char value );
45 void set_irq_on_new_ready_matrix(unsigned char value );
45 void set_run_matrix_spectral( unsigned char value );
46 void set_run_matrix_spectral( unsigned char value );
46 void launch_spectral_matrix_simu( unsigned char mode );
47
47
48 // other functions
48 // other functions
49 void updateLFRCurrentMode();
49 void updateLFRCurrentMode();
@@ -35,7 +35,7
35 #define CONFIGURE_MAXIMUM_DRIVERS 16
35 #define CONFIGURE_MAXIMUM_DRIVERS 16
36 #define CONFIGURE_MAXIMUM_PERIODS 5
36 #define CONFIGURE_MAXIMUM_PERIODS 5
37 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
37 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
38 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2
38 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 3
39 #ifdef PRINT_STACK_REPORT
39 #ifdef PRINT_STACK_REPORT
40 #define CONFIGURE_STACK_CHECKER_ENABLED
40 #define CONFIGURE_STACK_CHECKER_ENABLED
41 #endif
41 #endif
@@ -98,7 +98,7 rtems_task Init( rtems_task_argument ign
98
98
99 init_waveform_rings(); // initialize the waveform rings
99 init_waveform_rings(); // initialize the waveform rings
100 SM_init_rings(); // initialize spectral matrices rings
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)
101 ASM_init_rings(); // initialize the average spectral matrix ring (just for burst, sbm1 and sbm2 asm @ f0 storage)
102
102
103 reset_wfp_burst_enable();
103 reset_wfp_burst_enable();
104 reset_wfp_status();
104 reset_wfp_status();
@@ -268,6 +268,7 void create_names( void ) // create all
268
268
269 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
269 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
270 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
270 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
271 misc_name[QUEUE_MATR] = rtems_build_name( 'Q', '_', 'M', 'R' );
271 }
272 }
272
273
273 int create_all_tasks( void ) // create all tasks which run in the software
274 int create_all_tasks( void ) // create all tasks which run in the software
@@ -350,7 +351,7 int create_all_tasks( void ) // create a
350 if (status == RTEMS_SUCCESSFUL) // MATR
351 if (status == RTEMS_SUCCESSFUL) // MATR
351 {
352 {
352 status = rtems_task_create(
353 status = rtems_task_create(
353 Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE,
354 Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE * 2,
354 RTEMS_DEFAULT_MODES,
355 RTEMS_DEFAULT_MODES,
355 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR]
356 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR]
356 );
357 );
@@ -589,32 +590,48 rtems_status_code create_message_queues(
589 {
590 {
590 rtems_status_code status_recv;
591 rtems_status_code status_recv;
591 rtems_status_code status_send;
592 rtems_status_code status_send;
593 rtems_status_code status_matr;
592 rtems_status_code ret;
594 rtems_status_code ret;
593 rtems_id queue_id;
595 rtems_id queue_id;
594
596
597 //****************************************
595 // create the queue for handling valid TCs
598 // create the queue for handling valid TCs
596 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
599 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
597 ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
600 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
598 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
601 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
599 if ( status_recv != RTEMS_SUCCESSFUL ) {
602 if ( status_recv != RTEMS_SUCCESSFUL ) {
600 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
603 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
601 }
604 }
602
605
606 //************************************************
603 // create the queue for handling TM packet sending
607 // create the queue for handling TM packet sending
604 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
608 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
605 ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_MAX_SIZE,
609 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
606 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
610 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
607 if ( status_send != RTEMS_SUCCESSFUL ) {
611 if ( status_send != RTEMS_SUCCESSFUL ) {
608 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
612 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
609 }
613 }
610
614
615 //************************************************************************
616 // create the queue for handling averaged spectral matrices for processing
617 status_matr = rtems_message_queue_create( misc_name[QUEUE_MATR],
618 MSG_QUEUE_COUNT_MATR, MSG_QUEUE_SIZE_MATR,
619 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
620 if ( status_send != RTEMS_SUCCESSFUL ) {
621 PRINTF1("in create_message_queues *** ERR creating MATR queue, %d\n", status_matr)
622 }
623
611 if ( status_recv != RTEMS_SUCCESSFUL )
624 if ( status_recv != RTEMS_SUCCESSFUL )
612 {
625 {
613 ret = status_recv;
626 ret = status_recv;
614 }
627 }
628 else if( status_send != RTEMS_SUCCESSFUL )
629 {
630 ret = status_send;
631 }
615 else
632 else
616 {
633 {
617 ret = status_send;
634 ret = status_matr;
618 }
635 }
619
636
620 return ret;
637 return ret;
@@ -643,3 +660,15 rtems_status_code get_message_queue_id_r
643
660
644 return status;
661 return status;
645 }
662 }
663
664 rtems_status_code get_message_queue_id_matr( rtems_id *queue_id )
665 {
666 rtems_status_code status;
667 rtems_name queue_name;
668
669 queue_name = rtems_build_name( 'Q', '_', 'M', 'R' );
670
671 status = rtems_message_queue_ident( queue_name, 0, queue_id );
672
673 return status;
674 }
@@ -22,25 +22,15 ring_node_sm *current_ring_node_sm_f1;
22 ring_node_sm *current_ring_node_sm_f2;
22 ring_node_sm *current_ring_node_sm_f2;
23
23
24 ring_node_asm asm_ring_burst_sbm_f0[ NB_RING_NODES_ASM_BURST_SBM_F0 ];
24 ring_node_asm asm_ring_burst_sbm_f0[ NB_RING_NODES_ASM_BURST_SBM_F0 ];
25 ring_node_asm asm_ring_norm_f0 [ NB_RING_NODES_ASM_BURST_SBM_F0 ];
25 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
26 ring_node_asm *current_ring_node_asm_burst_sbm_f0;
26 ring_node_asm *ring_node_for_processing_asm_burst_sbm_f0;
27 ring_node_asm *current_ring_node_asm_norm_f0;
27
28
28 //*****
29 float asm_norm_f0 [ TOTAL_SIZE_SM ];
29 // NORM
30 float asm_f0_reorganized [ TOTAL_SIZE_SM ];
30 // F0
31 float asm_norm_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
32 float asm_f0_reorganized [ TIME_OFFSET + TOTAL_SIZE_SM ];
33 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
31 char asm_f0_char [ TIME_OFFSET_IN_BYTES + (TOTAL_SIZE_SM * 2) ];
34 float compressed_sm_norm_f0[ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_F0 ];
32 float compressed_sm_norm_f0[ TOTAL_SIZE_COMPRESSED_ASM_F0 ];
35
33 float compressed_sm_sbm [ TOTAL_SIZE_COMPRESSED_ASM_SBM1 ];
36 //*****
37 // SBM1
38 float asm_sbm_f0 [ TIME_OFFSET + TOTAL_SIZE_SM ];
39 float compressed_sm_sbm[ TIME_OFFSET + TOTAL_SIZE_COMPRESSED_ASM_SBM1 ];
40
41 unsigned char LFR_BP1_F0[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F0 * 2 ];
42 unsigned char LFR_BP1_F1[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F1 ];
43 unsigned char LFR_BP1_F2[ TIME_OFFSET_IN_BYTES + TOTAL_SIZE_NORM_BP1_F2 ];
44
34
45 //***********************************************************
35 //***********************************************************
46 // Interrupt Service Routine for spectral matrices processing
36 // Interrupt Service Routine for spectral matrices processing
@@ -87,44 +77,42 void reset_nb_sm_f0( unsigned char lfrMo
87
77
88 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
78 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
89 {
79 {
80 ring_node_sm *previous_ring_node_sm_f0;
81
90 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
82 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
91
83
92 // if ( (spectral_matrix_regs->status & 0x1) == 0x01)
84 previous_ring_node_sm_f0 = current_ring_node_sm_f0;
93 // {
85
94 // current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
86 if ( (spectral_matrix_regs->status & 0x2) == 0x02) // check ready matrix bit f0_1
95 // spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
87 {
96 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe; // 1110
88 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
97 // nb_sm_f0 = nb_sm_f0 + 1;
89 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
98 // }
90 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; // 1101
99 // else if ( (spectral_matrix_regs->status & 0x2) == 0x02)
91 nb_sm.f0 = nb_sm.f0 + 1;
100 // {
92 }
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
93
107 // if ( (spectral_matrix_regs->status & 0x30) != 0x00)
94 //************************
108 // {
95 // reset status error bits
109 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
96 if ( (spectral_matrix_regs->status & 0x30) != 0x00)
110 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // 1100 1111
97 {
111 // }
98 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
112
99 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // 1100 1111
113 // spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff3; // 0011
100 }
114
101
115 // if (nb_sm_f0 == (NB_SM_BEFORE_AVF0-1) )
102 //**************************************
116 // {
103 // reset ready matrix bits for f0_0, f1 and f2
117 // ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
104 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff2; // 0010
118 // if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
105
119 // {
106 if (nb_sm.f0 == NB_SM_BEFORE_AVF0)
120 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
107 {
121 // }
108 ring_node_for_averaging_sm_f0 = previous_ring_node_sm_f0;
122 // nb_sm_f0 = 0;
109 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
123 // }
110 {
124 // else
111 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
125 // {
112 }
126 // nb_sm.nb_sm_f0 = nb_sm.nb_sm_f0 + 1;
113 nb_sm.f0 = 0;
127 // }
114 }
115
128 }
116 }
129
117
130 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
118 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
@@ -163,15 +151,21 rtems_task avf0_task( rtems_task_argumen
163 int i;
151 int i;
164
152
165 rtems_event_set event_out;
153 rtems_event_set event_out;
166 rtems_event_set event_for_matr;
167 rtems_status_code status;
154 rtems_status_code status;
155 rtems_id queue_id_matr;
156 asm_msg msgForMATR;
168 ring_node_sm *ring_node_tab[8];
157 ring_node_sm *ring_node_tab[8];
169 unsigned long long int localTime;
170
158
171 reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
159 reset_nb_sm_f0( lfrRequestedMode ); // reset the sm counters that drive the BP and ASM computations / transmissions
172
160
173 BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", lfrRequestedMode)
161 BOOT_PRINTF1("in AVFO *** lfrRequestedMode = %d\n", lfrRequestedMode)
174
162
163 status = get_message_queue_id_matr( &queue_id_matr );
164 if (status != RTEMS_SUCCESSFUL)
165 {
166 PRINTF1("in MATR *** ERR get_message_queue_id_matr %d\n", status)
167 }
168
175 while(1){
169 while(1){
176 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
170 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;
171 ring_node_tab[NB_SM_BEFORE_AVF0-1] = ring_node_for_averaging_sm_f0;
@@ -181,14 +175,11 rtems_task avf0_task( rtems_task_argumen
181 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
175 ring_node_tab[NB_SM_BEFORE_AVF0-i] = ring_node_for_averaging_sm_f0;
182 }
176 }
183
177
184 localTime = getTimeAsUnsignedLongLongInt( );
185
186 // compute the average and store it in the averaged_sm_f1 buffer
178 // 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,
179 SM_average( current_ring_node_asm_norm_f0->matrix,
188 ring_node_tab,
180 current_ring_node_asm_burst_sbm_f0->matrix,
189 nb_sm.norm_bp1_f0, nb_sm.sbm_bp1_f0 );
181 ring_node_tab,
190
182 nb_sm.norm_bp1_f0, nb_sm.sbm_bp1_f0 );
191 localTime = getTimeAsUnsignedLongLongInt( ) - localTime;
192
183
193 // update nb_average
184 // update nb_average
194 nb_sm.norm_bp1_f0 = nb_sm.norm_bp1_f0 + NB_SM_BEFORE_AVF0;
185 nb_sm.norm_bp1_f0 = nb_sm.norm_bp1_f0 + NB_SM_BEFORE_AVF0;
@@ -197,21 +188,23 rtems_task avf0_task( rtems_task_argumen
197 nb_sm.sbm_bp1_f0 = nb_sm.sbm_bp1_f0 + NB_SM_BEFORE_AVF0;
188 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;
189 nb_sm.sbm_bp2_f0 = nb_sm.sbm_bp2_f0 + NB_SM_BEFORE_AVF0;
199
190
200 //***********************************************************
191 //****************************************
201 // build a composite event that will be sent to the MATR task
192 // initialize the mesage for the MATR task
202 event_for_matr = 0x00;
193 msgForMATR.event = 0x00; // this composite event will be sent to the MATR task
194 msgForMATR.burst_sbmf0 = current_ring_node_asm_burst_sbm_f0;
195 msgForMATR.norm_f0 = current_ring_node_asm_norm_f0;
196 msgForMATR.coarseTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[0];
197 msgForMATR.fineTime = ( (unsigned int *) (ring_node_tab[0]->buffer_address) )[1];
203
198
204 if (nb_sm.sbm_bp1_f0 == nb_sm_before_bp.burst_sbm_bp1_f0)
199 if (nb_sm.sbm_bp1_f0 == nb_sm_before_bp.burst_sbm_bp1_f0)
205 {
200 {
206 nb_sm.sbm_bp1_f0 = 0;
201 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
202 // set another ring for the ASM storage
210 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
203 current_ring_node_asm_burst_sbm_f0 = current_ring_node_asm_burst_sbm_f0->next;
211 if ( (lfrCurrentMode == LFR_MODE_BURST)
204 if ( (lfrCurrentMode == LFR_MODE_BURST)
212 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
205 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
213 {
206 {
214 event_for_matr = event_for_matr | RTEMS_EVENT_BURST_SBM_BP1_F0;
207 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP1_F0;
215 }
208 }
216 }
209 }
217
210
@@ -221,16 +214,18 rtems_task avf0_task( rtems_task_argumen
221 if ( (lfrCurrentMode == LFR_MODE_BURST)
214 if ( (lfrCurrentMode == LFR_MODE_BURST)
222 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
215 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
223 {
216 {
224 event_for_matr = event_for_matr | RTEMS_EVENT_BURST_SBM_BP2_F0;
217 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_BURST_SBM_BP2_F0;
225 }
218 }
226 }
219 }
227
220
228 if (nb_sm.norm_bp1_f0 == nb_sm_before_bp.norm_bp1_f0)
221 if (nb_sm.norm_bp1_f0 == nb_sm_before_bp.norm_bp1_f0)
229 {
222 {
230 nb_sm.norm_bp1_f0 = 0;
223 nb_sm.norm_bp1_f0 = 0;
224 // set another ring for the ASM storage
225 current_ring_node_asm_norm_f0 = current_ring_node_asm_norm_f0->next;
231 if (lfrCurrentMode == LFR_MODE_NORMAL)
226 if (lfrCurrentMode == LFR_MODE_NORMAL)
232 {
227 {
233 event_for_matr = event_for_matr | RTEMS_EVENT_NORM_BP1_F0;
228 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP1_F0;
234 }
229 }
235 }
230 }
236
231
@@ -240,7 +235,7 rtems_task avf0_task( rtems_task_argumen
240 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
235 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
241 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
236 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
242 {
237 {
243 event_for_matr = event_for_matr | RTEMS_EVENT_NORM_BP2_F0;
238 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_BP2_F0;
244 }
239 }
245 }
240 }
246
241
@@ -251,30 +246,39 rtems_task avf0_task( rtems_task_argumen
251 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
246 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
252 {
247 {
253 // PRINTF1("%lld\n", localTime)
248 // PRINTF1("%lld\n", localTime)
254 event_for_matr = event_for_matr | RTEMS_EVENT_NORM_ASM_F0;
249 msgForMATR.event = msgForMATR.event | RTEMS_EVENT_NORM_ASM_F0;
255 }
250 }
256 }
251 }
257
252
258 //*********************************
253 //*************************
259 // send the composite event to MATR
254 // send the message to MATR
260 status = rtems_event_send( Task_id[TASKID_MATR], event_for_matr );
255 if (msgForMATR.event != 0x00)
256 {
257 status = rtems_message_queue_send( queue_id_matr, (char *) & msgForMATR, MSG_QUEUE_SIZE_MATR);
258 }
259
261 if (status != RTEMS_SUCCESSFUL) {
260 if (status != RTEMS_SUCCESSFUL) {
262 printf("in AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
261 printf("in AVF0 *** Error sending message to MATR, code %d\n", status);
263 }
262 }
264 }
263 }
265 }
264 }
266
265
267 rtems_task matr_task( rtems_task_argument lfrRequestedMode )
266 rtems_task matr_task( rtems_task_argument lfrRequestedMode )
268 {
267 {
268 char incomingData[MSG_QUEUE_SIZE_SEND]; // incoming data buffer
269 size_t size; // size of the incoming TC packet
270 asm_msg *incomingMsg;
271 //
269 spw_ioctl_pkt_send spw_ioctl_send_ASM;
272 spw_ioctl_pkt_send spw_ioctl_send_ASM;
270 rtems_event_set event_out;
271 rtems_status_code status;
273 rtems_status_code status;
272 rtems_id queue_id;
274 rtems_id queue_id;
275 rtems_id queue_id_matr;
273 Header_TM_LFR_SCIENCE_ASM_t headerASM;
276 Header_TM_LFR_SCIENCE_ASM_t headerASM;
274 bp_packet_with_spare current_node_norm_bp1_f0;
277 bp_packet_with_spare current_node_norm_bp1_f0;
275 bp_packet current_node_norm_bp2_f0;
278 bp_packet current_node_norm_bp2_f0;
276 bp_packet current_node_sbm_bp1_f0;
279 bp_packet current_node_sbm_bp1_f0;
277 bp_packet current_node_sbm_bp2_f0;
280 bp_packet current_node_sbm_bp2_f0;
281
278 unsigned long long int localTime;
282 unsigned long long int localTime;
279
283
280 ASM_init_header( &headerASM );
284 ASM_init_header( &headerASM );
@@ -328,41 +332,48 rtems_task matr_task( rtems_task_argumen
328 {
332 {
329 PRINTF1("in MATR *** ERR get_message_queue_id_send %d\n", status)
333 PRINTF1("in MATR *** ERR get_message_queue_id_send %d\n", status)
330 }
334 }
335 status = get_message_queue_id_matr( &queue_id_matr);
336 if (status != RTEMS_SUCCESSFUL)
337 {
338 PRINTF1("in MATR *** ERR get_message_queue_id_matr %d\n", status)
339 }
331
340
332 BOOT_PRINTF1("in MATR *** lfrRequestedMode = %d\n", lfrRequestedMode)
341 BOOT_PRINTF1("in MATR *** lfrRequestedMode = %d\n", lfrRequestedMode)
333
342
334 while(1){
343 while(1){
335 rtems_event_receive( RTEMS_EVENT_NORM_BP1_F0 | RTEMS_EVENT_NORM_BP2_F0 | RTEMS_EVENT_NORM_ASM_F0
344 status = rtems_message_queue_receive( queue_id_matr, incomingData, &size, //************************************
336 | RTEMS_EVENT_BURST_SBM_BP1_F0 | RTEMS_EVENT_BURST_SBM_BP2_F0,
345 RTEMS_WAIT, RTEMS_NO_TIMEOUT ); // wait for a message coming from AVF0
337 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
346
347 incomingMsg = (asm_msg*) incomingData;
348
338 localTime = getTimeAsUnsignedLongLongInt( );
349 localTime = getTimeAsUnsignedLongLongInt( );
339 //****************
350 //****************
340 //****************
351 //****************
341 // BURST SBM1 SBM2
352 // BURST SBM1 SBM2
342 //****************
353 //****************
343 //****************
354 //****************
344 if ( event_out & RTEMS_EVENT_BURST_SBM_BP1_F0 )
355 if (incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP1_F0 )
345 {
356 {
346 // 1) compress the matrix for Basic Parameters calculation
357 // 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,
358 ASM_compress_reorganize_and_divide( incomingMsg->burst_sbmf0->matrix, compressed_sm_sbm,
348 nb_sm_before_bp.burst_sbm_bp1_f0,
359 nb_sm_before_bp.burst_sbm_bp1_f0,
349 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
360 NB_BINS_COMPRESSED_SM_SBM_F0, NB_BINS_TO_AVERAGE_ASM_SBM_F0,
350 ASM_F0_INDICE_START);
361 ASM_F0_INDICE_START);
351 // 2) compute the BP1 set
362 // 2) compute the BP1 set
352
363
353 // 3) send the BP1 set
364 // 3) send the BP1 set
354 set_time( current_node_sbm_bp1_f0.header.time, (unsigned char *) &compressed_sm_sbm );
365 set_time( current_node_sbm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
355 set_time( current_node_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &compressed_sm_sbm );
366 set_time( current_node_sbm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
356 BP_send( (char *) &current_node_sbm_bp1_f0.header, queue_id,
367 BP_send( (char *) &current_node_sbm_bp1_f0.header, queue_id,
357 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA);
368 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP1_F0 + PACKET_LENGTH_DELTA);
358 // 4) compute the BP2 set if needed
369 // 4) compute the BP2 set if needed
359 if ( event_out & RTEMS_EVENT_BURST_SBM_BP2_F0 )
370 if ( incomingMsg->event & RTEMS_EVENT_BURST_SBM_BP2_F0 )
360 {
371 {
361 // 1) compute the BP2 set
372 // 1) compute the BP2 set
362
373
363 // 2) send the BP2 set
374 // 2) send the BP2 set
364 set_time( current_node_sbm_bp2_f0.header.time, (unsigned char *) &compressed_sm_sbm );
375 set_time( current_node_sbm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
365 set_time( current_node_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &compressed_sm_sbm );
376 set_time( current_node_sbm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
366 BP_send( (char *) &current_node_sbm_bp2_f0.header, queue_id,
377 BP_send( (char *) &current_node_sbm_bp2_f0.header, queue_id,
367 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA);
378 PACKET_LENGTH_TM_LFR_SCIENCE_SBM_BP2_F0 + PACKET_LENGTH_DELTA);
368 }
379 }
@@ -373,42 +384,42 rtems_task matr_task( rtems_task_argumen
373 // NORM
384 // NORM
374 //*****
385 //*****
375 //*****
386 //*****
376 if (event_out & RTEMS_EVENT_NORM_BP1_F0)
387 if (incomingMsg->event & RTEMS_EVENT_NORM_BP1_F0)
377 {
388 {
378 // 1) compress the matrix for Basic Parameters calculation
389 // 1) compress the matrix for Basic Parameters calculation
379 ASM_compress_reorganize_and_divide( asm_norm_f0, compressed_sm_norm_f0,
390 ASM_compress_reorganize_and_divide( incomingMsg->norm_f0->matrix, compressed_sm_norm_f0,
380 nb_sm_before_bp.norm_bp1_f0,
391 nb_sm_before_bp.norm_bp1_f0,
381 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
392 NB_BINS_COMPRESSED_SM_F0, NB_BINS_TO_AVERAGE_ASM_F0,
382 ASM_F0_INDICE_START );
393 ASM_F0_INDICE_START );
383 // 2) compute the BP1 set
394 // 2) compute the BP1 set
384
395
385 // 3) send the BP1 set
396 // 3) send the BP1 set
386 set_time( current_node_norm_bp1_f0.header.time, (unsigned char *) &compressed_sm_norm_f0 );
397 set_time( current_node_norm_bp1_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
387 set_time( current_node_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &compressed_sm_norm_f0 );
398 set_time( current_node_norm_bp1_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
388 BP_send( (char *) &current_node_norm_bp1_f0.header, queue_id,
399 BP_send( (char *) &current_node_norm_bp1_f0.header, queue_id,
389 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA);
400 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP1_F0 + PACKET_LENGTH_DELTA);
390 if (event_out & RTEMS_EVENT_NORM_BP2_F0)
401 if (incomingMsg->event & RTEMS_EVENT_NORM_BP2_F0)
391 {
402 {
392 // 1) compute the BP2 set
403 // 1) compute the BP2 set
393
404
394 // 2) send the BP2 set
405 // 2) send the BP2 set
395 set_time( current_node_norm_bp2_f0.header.time, (unsigned char *) &compressed_sm_norm_f0 );
406 set_time( current_node_norm_bp2_f0.header.time, (unsigned char *) &incomingMsg->coarseTime );
396 set_time( current_node_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &compressed_sm_norm_f0 );
407 set_time( current_node_norm_bp2_f0.header.acquisitionTime, (unsigned char *) &incomingMsg->fineTime );
397 BP_send( (char *) &current_node_norm_bp2_f0.header, queue_id,
408 BP_send( (char *) &current_node_norm_bp2_f0.header, queue_id,
398 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA);
409 PACKET_LENGTH_TM_LFR_SCIENCE_NORM_BP2_F0 + PACKET_LENGTH_DELTA);
399 }
410 }
400 }
411 }
401
412
402 if (event_out & RTEMS_EVENT_NORM_ASM_F0)
413 if (incomingMsg->event & RTEMS_EVENT_NORM_ASM_F0)
403 {
414 {
404 // 1) reorganize the ASM and divide
415 // 1) reorganize the ASM and divide
405 ASM_reorganize_and_divide( asm_norm_f0, asm_f0_reorganized, NB_SM_BEFORE_NORM_BP1_F0 );
416 ASM_reorganize_and_divide( incomingMsg->norm_f0->matrix, asm_f0_reorganized, NB_SM_BEFORE_NORM_BP1_F0 );
406 // 2) convert the float array in a char array
417 // 2) convert the float array in a char array
407 ASM_convert( asm_f0_reorganized, asm_f0_char);
418 ASM_convert( asm_f0_reorganized, asm_f0_char);
408 // 3) send the spectral matrix packets
419 // 3) send the spectral matrix packets
420 set_time( headerASM.time , (unsigned char *) &incomingMsg->coarseTime );
421 set_time( headerASM.acquisitionTime, (unsigned char *) &incomingMsg->coarseTime );
409 ASM_send( &headerASM, asm_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
422 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 }
423 }
413
424
414 }
425 }
@@ -486,10 +497,12 void SM_init_rings( void )
486 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->matrixF0_Address0)
497 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->matrixF0_Address0)
487 }
498 }
488
499
489 void ASM_init_ring( void )
500 void ASM_init_rings( void )
490 {
501 {
491 unsigned char i;
502 unsigned char i;
492
503
504 //*************
505 // BURST_SBM_F0
493 asm_ring_burst_sbm_f0[0].next = (ring_node_asm*) &asm_ring_burst_sbm_f0[1];
506 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];
507 asm_ring_burst_sbm_f0[0].previous = (ring_node_asm*) &asm_ring_burst_sbm_f0[NB_RING_NODES_ASM_BURST_SBM_F0-1];
495
508
@@ -503,6 +516,22 void ASM_init_ring( void )
503 asm_ring_burst_sbm_f0[i].next = (ring_node_asm*) &asm_ring_burst_sbm_f0[i+1];
516 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];
517 asm_ring_burst_sbm_f0[i].previous = (ring_node_asm*) &asm_ring_burst_sbm_f0[i-1];
505 }
518 }
519
520 //*************
521 // NORM_F0
522 asm_ring_norm_f0[0].next = (ring_node_asm*) &asm_ring_norm_f0[1];
523 asm_ring_norm_f0[0].previous = (ring_node_asm*) &asm_ring_norm_f0[NB_RING_NODES_ASM_BURST_SBM_F0-1];
524
525 asm_ring_norm_f0[NB_RING_NODES_ASM_NORM_F0-1].next
526 = (ring_node_asm*) &asm_ring_norm_f0[0];
527 asm_ring_norm_f0[NB_RING_NODES_ASM_NORM_F0-1].previous
528 = (ring_node_asm*) &asm_ring_norm_f0[NB_RING_NODES_ASM_NORM_F0-2];
529
530 for(i=1; i<NB_RING_NODES_ASM_NORM_F0-1; i++)
531 {
532 asm_ring_norm_f0[i].next = (ring_node_asm*) &asm_ring_norm_f0[i+1];
533 asm_ring_norm_f0[i].previous = (ring_node_asm*) &asm_ring_norm_f0[i-1];
534 }
506 }
535 }
507
536
508 void SM_reset_current_ring_nodes( void )
537 void SM_reset_current_ring_nodes( void )
@@ -516,8 +545,8 void SM_reset_current_ring_nodes( void )
516
545
517 void ASM_reset_current_ring_node( void )
546 void ASM_reset_current_ring_node( void )
518 {
547 {
519 current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
548 current_ring_node_asm_norm_f0 = asm_ring_norm_f0;
520 ring_node_for_processing_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
549 current_ring_node_asm_burst_sbm_f0 = asm_ring_burst_sbm_f0;
521 }
550 }
522
551
523 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header)
552 void ASM_init_header( Header_TM_LFR_SCIENCE_ASM_t *header)
@@ -558,7 +587,6 void SM_average( float *averaged_spec_ma
558 {
587 {
559 float sum;
588 float sum;
560 unsigned int i;
589 unsigned int i;
561 unsigned char *ptr;
562
590
563 for(i=0; i<TOTAL_SIZE_SM; i++)
591 for(i=0; i<TOTAL_SIZE_SM; i++)
564 {
592 {
@@ -573,62 +601,45 void SM_average( float *averaged_spec_ma
573
601
574 if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) )
602 if ( (nbAverageNormF0 == 0) && (nbAverageSBM1F0 == 0) )
575 {
603 {
576 averaged_spec_mat_f0[ TIME_OFFSET + i ] = sum;
604 averaged_spec_mat_f0[ i ] = sum;
577 averaged_spec_mat_f1[ TIME_OFFSET + i ] = sum;
605 averaged_spec_mat_f1[ i ] = sum;
578 }
606 }
579 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 != 0) )
607 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 != 0) )
580 {
608 {
581 averaged_spec_mat_f0[ TIME_OFFSET + i ] = ( averaged_spec_mat_f0[ TIME_OFFSET + i ] + sum );
609 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
582 averaged_spec_mat_f1[ TIME_OFFSET + i ] = ( averaged_spec_mat_f1[ TIME_OFFSET + i ] + sum );
610 averaged_spec_mat_f1[ i ] = ( averaged_spec_mat_f1[ i ] + sum );
583 }
611 }
584 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 == 0) )
612 else if ( (nbAverageNormF0 != 0) && (nbAverageSBM1F0 == 0) )
585 {
613 {
586 averaged_spec_mat_f0[ TIME_OFFSET + i ] = ( averaged_spec_mat_f0[ TIME_OFFSET + i ] + sum );
614 averaged_spec_mat_f0[ i ] = ( averaged_spec_mat_f0[ i ] + sum );
587 averaged_spec_mat_f1[ TIME_OFFSET + i ] = sum;
615 <