##// END OF EJS Templates
snapshots extraction fully functionnal in SBM1 and SBM2
paul -
r106:4b288e043b64 VHDLib206
parent child
Show More
@@ -1,6 +1,6
1 1 #############################################################################
2 2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Tue Mar 4 13:06:39 2014
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Tue Mar 11 15:58:37 2014
4 4 # Project: fsw-qt.pro
5 5 # Template: app
6 6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
@@ -10,7 +10,7
10 10
11 11 CC = sparc-rtems-gcc
12 12 CXX = sparc-rtems-g++
13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=3 -DPRINT_MESSAGES_ON_CONSOLE
13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=3 -DPRINT_MESSAGES_ON_CONSOLE -DDEBUG_MESSAGES
14 14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../../LFR_basic-parameters
@@ -1,7 +1,7
1 1 TEMPLATE = app
2 2 # CONFIG += console v8 sim
3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report
4 CONFIG += console verbose
3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev
4 CONFIG += console verbose debug_messages
5 5 CONFIG -= qt
6 6
7 7 include(./sparc.pri)
@@ -13,6 +13,10 DEFINES += SW_VERSION_N2=0 # minor
13 13 DEFINES += SW_VERSION_N3=0 # patch
14 14 DEFINES += SW_VERSION_N4=3 # internal
15 15
16 contains( CONFIG, vhdl_dev ) {
17 DEFINES += VHDL_DEV
18 }
19
16 20 contains( CONFIG, verbose ) {
17 21 DEFINES += PRINT_MESSAGES_ON_CONSOLE
18 22 }
@@ -1,6 +1,6
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 3.0.0, 2014-03-06T15:56:18. -->
3 <!-- Written by QtCreator 3.0.1, 2014-03-13T15:53:26. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -35,9 +35,6 typedef struct ring_node
35 35 #define NB_RING_NODES_F0 3 // AT LEAST 3
36 36 #define NB_RING_NODES_F1 5 // AT LEAST 3
37 37 #define NB_RING_NODES_F2 5 // AT LEAST 3
38 #define NB_RING_NODES_ASM_F0 12 // AT LEAST 3
39 #define NB_RING_NODES_ASM_F1 2 // AT LEAST 3
40 #define NB_RING_NODES_ASM_F2 2 // AT LEAST 3
41 38
42 39 //**********
43 40 // LFR MODES
@@ -107,8 +104,14 typedef struct ring_node
107 104 #define REGS_ADDR_GPTIMER 0x80000300
108 105 #define REGS_ADDR_GRSPW 0x80000500
109 106 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
107
108 #ifdef VHDL_DEV
109 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
110 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f40
111 #else
110 112 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
111 113 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f20
114 #endif
112 115
113 116 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
114 117 #define APBUART_CTRL_REG_MASK_TE 0x00000002
@@ -161,9 +164,9 typedef struct ring_node
161 164 #define TASK_PRIORITY_HOUS 30
162 165 #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together
163 166 #define TASK_PRIORITY_CWF2 35 //
167 #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it
164 168 #define TASK_PRIORITY_WFRM 40
165 169 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1
166 #define TASK_PRIORITY_SWBD 40
167 170 #define TASK_PRIORITY_SEND 45
168 171 #define TASK_PRIORITY_RECV 50
169 172 #define TASK_PRIORITY_ACTN 50
@@ -1,10 +1,13
1 1 #ifndef FSW_PARAMS_PROCESSING_H
2 2 #define FSW_PARAMS_PROCESSING_H
3 3
4 #define NB_BINS_PER_SM 128 //
5 #define NB_VALUES_PER_SM 25 //
6 #define TOTAL_SIZE_SM 3200 // 25 * 128
7 #define SM_HEADER 0 //
4 #define NB_BINS_PER_SM 128
5 #define NB_VALUES_PER_SM 25
6 #define TOTAL_SIZE_SM 3200 // 25 * 128
7 //
8 #define NB_RING_NODES_ASM_F0 12 // AT LEAST 3
9 #define NB_RING_NODES_ASM_F1 2 // AT LEAST 3
10 #define NB_RING_NODES_ASM_F2 2 // AT LEAST 3
8 11 //
9 12 #define NB_BINS_PER_ASM_F0 88
10 13 #define NB_BINS_PER_PKT_ASM_F0 44
@@ -12,9 +12,9
12 12 #include "fsw_spacewire.h"
13 13 #include "basic_parameters.h"
14 14
15 extern volatile int sm_f0[ ][ TIME_OFFSET + TOTAL_SIZE_SM ];
16 extern volatile int sm_f1[ ][ TIME_OFFSET + TOTAL_SIZE_SM ];
17 extern volatile int sm_f2[ ][ TIME_OFFSET + TOTAL_SIZE_SM ];
15 extern volatile int sm_f0[ ];
16 extern volatile int sm_f1[ ];
17 extern volatile int sm_f2[ ];
18 18
19 19 // parameters
20 20 extern struct param_local_str param_local;
@@ -81,6 +81,15 typedef struct {
81 81 volatile int matrixFO_Address1;
82 82 volatile int matrixF1_Address;
83 83 volatile int matrixF2_Address;
84 volatile int coarse_time_F0_0;
85 volatile int coarse_time_F0_1;
86 volatile int coarse_time_F1;
87 volatile int coarse_time_F2;
88 volatile int fine_time_FO_0;
89 volatile int fine_time_F0_1;
90 volatile int fine_time_F1;
91 volatile int fine_time_F2;
92 volatile int debug;
84 93 } spectral_matrix_regs_t;
85 94
86 95 #endif // GRLIB_REGS_H_INCLUDED
@@ -39,8 +39,8 int restart_science_tasks();
39 39 int suspend_science_tasks();
40 40 void launch_waveform_picker( unsigned char mode );
41 41 void launch_spectral_matrix( unsigned char mode );
42 void enable_irq_on_new_ready_matrix( void );
43 void disable_irq_on_new_ready_matrix( void );
42 void set_irq_on_new_ready_matrix(unsigned char value );
43 void set_run_matrix_spectral( unsigned char value );
44 44 void launch_spectral_matrix_simu( unsigned char mode );
45 45
46 46 // other functions
@@ -42,6 +42,7 extern unsigned char lfrCurrentMode;
42 42
43 43 //**********
44 44 // RTEMS_ISR
45 void reset_extractSWF( void );
45 46 rtems_isr waveforms_isr( rtems_vector_number vector );
46 47
47 48 //***********
@@ -69,7 +70,8 int send_waveform_CWF3_light( volatile i
69 70 //
70 71 void compute_acquisition_time(unsigned int coarseTime, unsigned int fineTime,
71 72 unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char *acquisitionTime );
72 void build_snapshot_from_ring( void );
73 void build_snapshot_from_ring(ring_node *ring_node_to_send , unsigned char frequencyChannel );
74 void build_acquisition_time( unsigned long long int * acquisitionTimeAslong, ring_node *current_ring_node );
73 75 //
74 76 rtems_id get_pkts_queue_id( void );
75 77
@@ -46,9 +46,10 volatile int wf_cont_f3_b [ (NB_SAMPL
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 // SPECTRAL MATRICES GLOBAL VARIABLES
49 volatile int sm_f0[ NB_RING_NODES_ASM_F0 ][ TIME_OFFSET + TOTAL_SIZE_SM + 62 ] __attribute__((aligned(0x100)));
50 volatile int sm_f1[ NB_RING_NODES_ASM_F1 ][ TIME_OFFSET + TOTAL_SIZE_SM + 62 ] __attribute__((aligned(0x100)));
51 volatile int sm_f2[ NB_RING_NODES_ASM_F2 ][ TIME_OFFSET + TOTAL_SIZE_SM + 62 ] __attribute__((aligned(0x100)));
49 // 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)));
52 53
53 54 // APB CONFIGURATION REGISTERS
54 55 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
@@ -36,20 +36,63 void init_sm_rings( void )
36 36 // F0 RING
37 37 sm_ring_f0[0].next = (ring_node*) &sm_ring_f0[1];
38 38 sm_ring_f0[0].previous = (ring_node*) &sm_ring_f0[NB_RING_NODES_ASM_F0-1];
39 sm_ring_f0[0].buffer_address = (int) &sm_f0[0][0];
39 sm_ring_f0[0].buffer_address =
40 (int) &sm_f0[ 0 ];
40 41
41 42 sm_ring_f0[NB_RING_NODES_ASM_F0-1].next = (ring_node*) &sm_ring_f0[0];
42 43 sm_ring_f0[NB_RING_NODES_ASM_F0-1].previous = (ring_node*) &sm_ring_f0[NB_RING_NODES_ASM_F0-2];
43 sm_ring_f0[NB_RING_NODES_ASM_F0-1].buffer_address = (int) &sm_f0[NB_RING_NODES_ASM_F0-1][0];
44 sm_ring_f0[NB_RING_NODES_ASM_F0-1].buffer_address =
45 (int) &sm_f0[ (NB_RING_NODES_ASM_F0-1) * TOTAL_SIZE_SM ];
44 46
45 47 for(i=1; i<NB_RING_NODES_ASM_F0-1; i++)
46 48 {
47 49 sm_ring_f0[i].next = (ring_node*) &sm_ring_f0[i+1];
48 50 sm_ring_f0[i].previous = (ring_node*) &sm_ring_f0[i-1];
49 sm_ring_f0[i].buffer_address = (int) &sm_f0[i][0];
51 sm_ring_f0[i].buffer_address =
52 (int) &sm_f0[ i * TOTAL_SIZE_SM ];
53 }
54
55 // F1 RING
56 sm_ring_f1[0].next = (ring_node*) &sm_ring_f1[1];
57 sm_ring_f1[0].previous = (ring_node*) &sm_ring_f1[NB_RING_NODES_ASM_F1-1];
58 sm_ring_f1[0].buffer_address =
59 (int) &sm_f1[ 0 ];
60
61 sm_ring_f1[NB_RING_NODES_ASM_F1-1].next = (ring_node*) &sm_ring_f1[0];
62 sm_ring_f1[NB_RING_NODES_ASM_F1-1].previous = (ring_node*) &sm_ring_f1[NB_RING_NODES_ASM_F1-2];
63 sm_ring_f1[NB_RING_NODES_ASM_F1-1].buffer_address =
64 (int) &sm_f1[ (NB_RING_NODES_ASM_F1-1) * TOTAL_SIZE_SM ];
65
66 for(i=1; i<NB_RING_NODES_ASM_F1-1; i++)
67 {
68 sm_ring_f1[i].next = (ring_node*) &sm_ring_f1[i+1];
69 sm_ring_f1[i].previous = (ring_node*) &sm_ring_f1[i-1];
70 sm_ring_f1[i].buffer_address =
71 (int) &sm_f1[ i * TOTAL_SIZE_SM ];
72 }
73
74 // F2 RING
75 sm_ring_f2[0].next = (ring_node*) &sm_ring_f2[1];
76 sm_ring_f2[0].previous = (ring_node*) &sm_ring_f2[NB_RING_NODES_ASM_F2-1];
77 sm_ring_f2[0].buffer_address =
78 (int) &sm_f2[ 0 ];
79
80 sm_ring_f2[NB_RING_NODES_ASM_F2-1].next = (ring_node*) &sm_ring_f2[0];
81 sm_ring_f2[NB_RING_NODES_ASM_F2-1].previous = (ring_node*) &sm_ring_f2[NB_RING_NODES_ASM_F2-2];
82 sm_ring_f2[NB_RING_NODES_ASM_F2-1].buffer_address =
83 (int) &sm_f2[ (NB_RING_NODES_ASM_F2-1) * TOTAL_SIZE_SM ];
84
85 for(i=1; i<NB_RING_NODES_ASM_F2-1; i++)
86 {
87 sm_ring_f2[i].next = (ring_node*) &sm_ring_f2[i+1];
88 sm_ring_f2[i].previous = (ring_node*) &sm_ring_f2[i-1];
89 sm_ring_f2[i].buffer_address =
90 (int) &sm_f2[ i * TOTAL_SIZE_SM ];
50 91 }
51 92
52 93 DEBUG_PRINTF1("asm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
94 DEBUG_PRINTF1("asm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
95 DEBUG_PRINTF1("asm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
53 96
54 97 spectral_matrix_regs->matrixF0_Address0 = sm_ring_f0[0].buffer_address;
55 98 DEBUG_PRINTF1("spectral_matrix_regs->matrixF0_Address0 @%x\n", spectral_matrix_regs->matrixF0_Address0)
@@ -57,7 +100,10 void init_sm_rings( void )
57 100
58 101 void reset_current_sm_ring_nodes( void )
59 102 {
60 current_ring_node_sm_f0 = sm_ring_f0;
103 current_ring_node_sm_f0 = sm_ring_f0;
104 current_ring_node_sm_f1 = sm_ring_f1;
105 current_ring_node_sm_f2 = sm_ring_f2;
106
61 107 ring_node_for_averaging_sm_f0 = sm_ring_f0;
62 108 }
63 109
@@ -112,31 +158,6 rtems_isr spectral_matrices_isr( rtems_v
112 158
113 159 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
114 160 {
115 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
116
117 if ( (spectral_matrix_regs->status & 0x1) == 0x01)
118 {
119 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
120 spectral_matrix_regs->matrixF0_Address0 = current_ring_node_sm_f0->buffer_address;
121 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe; // 1110
122 nb_sm_f0 = nb_sm_f0 + 1;
123 }
124 else if ( (spectral_matrix_regs->status & 0x2) == 0x02)
125 {
126 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
127 spectral_matrix_regs->matrixFO_Address1 = current_ring_node_sm_f0->buffer_address;
128 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd; // 1101
129 nb_sm_f0 = nb_sm_f0 + 1;
130 }
131
132 if ( (spectral_matrix_regs->status & 0x30) != 0x00)
133 {
134 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
135 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // 1100 1111
136 }
137
138 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff3; // 0011
139
140 161 if (nb_sm_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) )
141 162 {
142 163 ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0;
@@ -403,9 +403,13 int stop_current_mode(void)
403 403 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
404 404
405 405 // (3) reset registers
406 // waveform picker
406 407 reset_wfp_burst_enable(); // reset burst and enable bits
407 408 reset_wfp_status(); // reset all the status bits
408 disable_irq_on_new_ready_matrix(); // stop the spectral matrices
409 // spectral matrices
410 set_irq_on_new_ready_matrix( 0 ); // stop the spectral matrices
411 set_run_matrix_spectral( 0 ); // run_matrix_spectral is set to 0
412 reset_extractSWF(); // reset the extractSWF flag to false
409 413
410 414 // <Spectral Matrices simulator>
411 415 LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator
@@ -605,8 +609,10 void launch_waveform_picker( unsigned ch
605 609 reset_current_ring_nodes();
606 610 reset_waveform_picker_regs();
607 611 set_wfp_burst_enable_register( mode );
612
608 613 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
609 614 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
615
610 616 startDate = time_management_regs->coarse_time + 2;
611 617 waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
612 618 waveform_picker_regs->start_date = startDate;
@@ -618,23 +624,43 void launch_spectral_matrix( unsigned ch
618 624 reset_current_sm_ring_nodes();
619 625 reset_spectral_matrix_regs();
620 626
621 enable_irq_on_new_ready_matrix();
622
627 #ifdef VHDL_DEV
628 set_irq_on_new_ready_matrix( 1 );
623 629 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
624 630 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
631 set_run_matrix_spectral( 1 );
632 #else
633 // Spectral Matrices simulator
634 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
635 LEON_Clear_interrupt( IRQ_SM_SIMULATOR );
636 LEON_Unmask_interrupt( IRQ_SM_SIMULATOR );
637 #endif
625 638 }
626 639
627 void enable_irq_on_new_ready_matrix( void )
640 void set_irq_on_new_ready_matrix( unsigned char value )
628 641 {
629 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
642 if (value == 1)
643 {
644 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
645 }
646 else
647 {
648 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
649 }
630 650 }
631 651
632 void disable_irq_on_new_ready_matrix( void )
652 void set_run_matrix_spectral( unsigned char value )
633 653 {
634 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
654 if (value == 1)
655 {
656 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x4; // 0100 set run_matrix spectral to 1
657 }
658 else
659 {
660 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffb; // 1011 set run_matrix spectral to 0
661 }
635 662 }
636 663
637
638 664 void launch_spectral_matrix_simu( unsigned char mode )
639 665 {
640 666 reset_nb_sm_f0();
@@ -37,8 +37,22 ring_node *ring_node_to_send_swf_f2;
37 37 ring_node *ring_node_to_send_cwf_f2;
38 38
39 39 bool extractSWF = false;
40 bool swf_f0_ready = false;
41 bool swf_f1_ready = false;
42 bool swf_f2_ready = false;
40 43
41 int wf_snap_f1_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
44 int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) + TIME_OFFSET ];
45
46 //*********************
47 // Interrupt SubRoutine
48
49 void reset_extractSWF( void )
50 {
51 extractSWF = false;
52 swf_f0_ready = false;
53 swf_f1_ready = false;
54 swf_f2_ready = false;
55 }
42 56
43 57 rtems_isr waveforms_isr( rtems_vector_number vector )
44 58 {
@@ -50,6 +64,7 rtems_isr waveforms_isr( rtems_vector_nu
50 64 *
51 65 */
52 66
67 rtems_status_code status;
53 68 static unsigned char nb_swf = 0;
54 69
55 70 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
@@ -143,29 +158,36 rtems_isr waveforms_isr( rtems_vector_nu
143 158 if (extractSWF == true)
144 159 {
145 160 ring_node_to_send_swf_f1 = current_ring_node_f1;
146 if (rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
147 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
148 }
161 // extract the snapshot
162 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 );
149 163 extractSWF = false;
164 swf_f1_ready = true;
150 165 }
151 166 // (1) change the receiving buffer for the waveform picker
152 167 ring_node_to_send_cwf_f1 = current_ring_node_f1;
153 168 current_ring_node_f1 = current_ring_node_f1->next;
154 169 waveform_picker_regs->addr_data_f1 = current_ring_node_f1->buffer_address;
155 170 // (2) send an event for the the CWF1 task for transmission
156 if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) {
157 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
171 status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 );
172 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0
173 if (swf_f0_ready == true)
174 {
175 extractSWF = true;
176 swf_f0_ready = false;
158 177 }
159 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bits = 0
178 if ((swf_f1_ready == true) && (swf_f2_ready == true))
179 {
180 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 );
181 swf_f1_ready = false;
182 swf_f2_ready = false;
183 }
160 184 }
161 185 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
162 extractSWF = true;
186 swf_f0_ready = true;
163 187 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
164 188 }
165 189 if ( (waveform_picker_regs->status & 0x04) == 0x04 ) { // [0100] check the f2 full bit
166 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) {
167 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
168 }
190 swf_f2_ready = true;
169 191 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
170 192 }
171 193 break;
@@ -174,24 +196,38 rtems_isr waveforms_isr( rtems_vector_nu
174 196 // SBM2
175 197 case(LFR_MODE_SBM2):
176 198 if ( (waveform_picker_regs->status & 0x04) == 0x04 ){ // [0100] check the f2 full bit
199 // (0) launch snapshot extraction if needed
200 if (extractSWF == true)
201 {
202 ring_node_to_send_swf_f2 = current_ring_node_f2;
203 // extract the snapshot
204 status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM2 );
205 // send the snapshot when build, SWBD priority < WFRM priority
206 status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 );
207 extractSWF = false;
208 }
177 209 // (1) change the receiving buffer for the waveform picker
178 210 ring_node_to_send_cwf_f2 = current_ring_node_f2;
179 211 current_ring_node_f2 = current_ring_node_f2->next;
180 212 waveform_picker_regs->addr_data_f2 = current_ring_node_f2->buffer_address;
181 213 // (2) send an event for the waveforms transmission
182 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
183 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
214 status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 );
215 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
216 // (3) check whether swf_fo and swf_f& are ready or not
217 if (swf_f0_ready && swf_f1_ready)
218 {
219 extractSWF = true;
220 swf_f0_ready = false;
221 swf_f1_ready = false;
184 222 }
185 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
186 223 }
187 224 if ( (waveform_picker_regs->status & 0x01) == 0x01 ) { // [0001] check the f0 full bit
188 ring_node_to_send_swf_f2 = current_ring_node_f2->previous;
225 swf_f0_ready = true;
226 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffeee; // [1111 1110 1110 1110] f0 bits = 0
189 227 }
190 228 if ( (waveform_picker_regs->status & 0x02) == 0x02 ) { // [0010] check the f1 full bit
191 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
192 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
193 }
194 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
229 swf_f1_ready = true;
230 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1, f0 bits = 0
195 231 }
196 232 break;
197 233
@@ -202,6 +238,9 rtems_isr waveforms_isr( rtems_vector_nu
202 238 }
203 239 }
204 240
241 //************
242 // RTEMS TASKS
243
205 244 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
206 245 {
207 246 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
@@ -240,18 +279,25 rtems_task wfrm_task(rtems_task_argument
240 279 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
241 280 if (event_out == RTEMS_EVENT_MODE_NORMAL)
242 281 {
243 PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n")
282 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n")
244 283 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
245 284 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
246 285 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
247 286 }
248 287 if (event_out == RTEMS_EVENT_MODE_SBM1)
249 288 {
250 PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n")
289 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n")
251 290 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
252 send_waveform_SWF((volatile int*) wf_snap_f1_extracted , SID_NORM_SWF_F1, headerSWF_F1, queue_id);
291 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F1, headerSWF_F1, queue_id);
253 292 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f2->buffer_address, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
254 293 }
294 if (event_out == RTEMS_EVENT_MODE_SBM2)
295 {
296 DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n")
297 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f0->buffer_address, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
298 send_waveform_SWF((volatile int*) ring_node_to_send_swf_f1->buffer_address, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
299 send_waveform_SWF((volatile int*) wf_snap_extracted , SID_NORM_SWF_F2, headerSWF_F2, queue_id);
300 }
255 301 }
256 302 }
257 303
@@ -407,9 +453,20 rtems_task swbd_task(rtems_task_argument
407 453
408 454 while(1){
409 455 // wait for an RTEMS_EVENT
410 rtems_event_receive( RTEMS_EVENT_0,
456 rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2,
411 457 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
412 build_snapshot_from_ring();
458 if (event_out == RTEMS_EVENT_MODE_SBM1)
459 {
460 build_snapshot_from_ring( ring_node_to_send_swf_f1, 1 );
461 }
462 else if (event_out == RTEMS_EVENT_MODE_SBM2)
463 {
464 build_snapshot_from_ring( ring_node_to_send_swf_f2, 2 );
465 }
466 else
467 {
468 PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out)
469 }
413 470 }
414 471 }
415 472
@@ -677,9 +734,6 int send_waveform_SWF( volatile int *wav
677 734
678 735 ret = LFR_DEFAULT;
679 736
680 DEBUG_PRINTF1("sid = %d, ", sid)
681 DEBUG_PRINTF2("coarse = %x, fine = %x\n", waveform[0], waveform[1])
682
683 737 coarseTime = waveform[0];
684 738 fineTime = waveform[1];
685 739
@@ -935,45 +989,91 void compute_acquisition_time( unsigned
935 989
936 990 }
937 991
938 void build_snapshot_from_ring( void )
992 void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel )
939 993 {
940 994 unsigned int i;
941 995 unsigned long long int centerTime_asLong;
942 996 unsigned long long int acquisitionTimeF0_asLong;
943 unsigned long long int acquisitionTimeF1_asLong;
944 unsigned char *acquisitionTimeF0;
945 unsigned char *acquisitionTimeF1;
997 unsigned long long int acquisitionTime_asLong;
998 unsigned long long int bufferAcquisitionTime_asLong;
946 999 unsigned char *ptr1;
947 1000 unsigned char *ptr2;
1001 unsigned char nb_ring_nodes;
1002 unsigned long long int frequency_asLong;
1003 unsigned long long int nbTicksPerSample_asLong;
1004 unsigned long long int nbSamplesPart1_asLong;
1005 unsigned long long int sampleOffset_asLong;
948 1006
949 unsigned int deltaT;
1007 unsigned int deltaT_F0;
1008 unsigned int deltaT_F1;
1009 unsigned long long int deltaT_F2;
950 1010
951 deltaT = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
1011 deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667;
1012 deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384;
1013 deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144;
1014 sampleOffset_asLong = 0x00;
952 1015
953 acquisitionTimeF0 = (unsigned char*) current_ring_node_f0->buffer_address;
954 acquisitionTimeF1 = (unsigned char*) ring_node_to_send_cwf_f1->buffer_address;
1016 // get the f0 acquisition time
1017 build_acquisition_time( &acquisitionTimeF0_asLong, current_ring_node_f0 );
1018 PRINTF1("acquisitionTimeF0_asLong %llx \n", acquisitionTimeF0_asLong)
1019
1020 // compute the central reference time
1021 centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0;
1022 PRINTF1("centerTime_asLong %llx \n", centerTime_asLong)
955 1023
956 acquisitionTimeF0_asLong = 0x00;
957 acquisitionTimeF1_asLong = 0x00;
958 acquisitionTimeF0_asLong = ( acquisitionTimeF0[0] << 24 )
959 + ( acquisitionTimeF0[1] << 16 )
960 + ( (unsigned long long int) acquisitionTimeF0[2] << 40 )
961 + ( (unsigned long long int) acquisitionTimeF0[3] << 32 )
962 + ( acquisitionTimeF0[4] << 8 )
963 + ( acquisitionTimeF0[5] );
1024 // compute the acquisition time of the current snapshot
1025 switch(frequencyChannel)
1026 {
1027 case 1: // 1 is for F1 = 4096 Hz
1028 acquisitionTime_asLong = centerTime_asLong - deltaT_F1;
1029 nb_ring_nodes = NB_RING_NODES_F1;
1030 frequency_asLong = 4096;
1031 nbTicksPerSample_asLong = 16; // 65536 / 4096;
1032 break;
1033 case 2: // 2 is for F2 = 256 Hz
1034 acquisitionTime_asLong = centerTime_asLong - deltaT_F2;
1035 nb_ring_nodes = NB_RING_NODES_F2;
1036 frequency_asLong = 256;
1037 nbTicksPerSample_asLong = 256; // 65536 / 256;
1038 break;
1039 default:
1040 acquisitionTime_asLong = centerTime_asLong;
1041 frequency_asLong = 256;
1042 nbTicksPerSample_asLong = 256;
1043 break;
1044 }
1045 PRINTF1("acquisitionTime_asLong %llx\n", acquisitionTime_asLong)
964 1046
965 acquisitionTimeF1_asLong = ( acquisitionTimeF1[0] << 24 )
966 + ( acquisitionTimeF1[1] << 16 )
967 + ( (unsigned long long int) acquisitionTimeF1[2] << 40 )
968 + ( (unsigned long long int) acquisitionTimeF1[3] << 32 )
969 + ( acquisitionTimeF1[4] << 8 )
970 + ( acquisitionTimeF1[5] );
1047 //****************************************************************************
1048 // 1) search the ring_node with the acquisition time <= acquisitionTime_asLong
1049 for (i=0; i<nb_ring_nodes; i++)
1050 {
1051 PRINTF1("%d ... ", i)
1052 build_acquisition_time( &bufferAcquisitionTime_asLong, ring_node_to_send );
1053 if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong)
1054 {
1055 PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong)
1056 break;
1057 }
1058 ring_node_to_send = ring_node_to_send->previous;
1059 }
971 1060
972 centerTime_asLong = acquisitionTimeF0_asLong + deltaT;
1061 //*************************************************
1062 // (2) once the buffer is found, build the snapshot
1063
1064 // compute the number of samples to take in the current buffer
1065 sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16;
1066 nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong;
1067 PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1 = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong)
973 1068
974 ptr1 = (unsigned char*) &acquisitionTimeF1_asLong;
975 ptr2 = (unsigned char*) wf_snap_f1_extracted;
1069 // compute the final acquisition time
1070 acquisitionTime_asLong = bufferAcquisitionTime_asLong +
1071 sampleOffset_asLong * nbTicksPerSample_asLong;
1072 PRINTF1("FINAL acquisitionTime_asLong %llx\n\n", acquisitionTime_asLong)
976 1073
1074 // copy the acquisition time at the beginning of the extrated snapshot
1075 ptr1 = (unsigned char*) &acquisitionTime_asLong;
1076 ptr2 = (unsigned char*) wf_snap_extracted;
977 1077 ptr2[0] = ptr1[ 2 + 2 ];
978 1078 ptr2[1] = ptr1[ 3 + 2 ];
979 1079 ptr2[2] = ptr1[ 0 + 2 ];
@@ -981,12 +1081,39 void build_snapshot_from_ring( void )
981 1081 ptr2[4] = ptr1[ 4 + 2 ];
982 1082 ptr2[5] = ptr1[ 5 + 2 ];
983 1083
984 for (i=0; i<(NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ )
1084 // re set the synchronization bit
1085
1086
1087 // copy the part 1 of the snapshot in the extracted buffer
1088 for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ )
1089 {
1090 wf_snap_extracted[i + TIME_OFFSET] =
1091 ((int*) ring_node_to_send->buffer_address)[i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) + TIME_OFFSET];
1092 }
1093 // copy the part 2 of the snapshot in the extracted buffer
1094 ring_node_to_send = ring_node_to_send->next;
1095 for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ )
985 1096 {
986 wf_snap_f1_extracted[i + TIME_OFFSET] = ((int*)(ring_node_to_send_cwf_f1->buffer_address))[i + TIME_OFFSET];
1097 wf_snap_extracted[i + TIME_OFFSET] =
1098 ((int*) ring_node_to_send->buffer_address)[(i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) + TIME_OFFSET];
987 1099 }
988 1100 }
989 1101
1102 void build_acquisition_time( unsigned long long int *acquisitionTimeAslong, ring_node *current_ring_node )
1103 {
1104 unsigned char *acquisitionTimeCharPtr;
1105
1106 acquisitionTimeCharPtr = (unsigned char*) current_ring_node->buffer_address;
1107
1108 *acquisitionTimeAslong = 0x00;
1109 *acquisitionTimeAslong = ( acquisitionTimeCharPtr[0] << 24 )
1110 + ( acquisitionTimeCharPtr[1] << 16 )
1111 + ( (unsigned long long int) (acquisitionTimeCharPtr[2] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
1112 + ( (unsigned long long int) acquisitionTimeCharPtr[3] << 32 )
1113 + ( acquisitionTimeCharPtr[4] << 8 )
1114 + ( acquisitionTimeCharPtr[5] );
1115 }
1116
990 1117 //**************
991 1118 // wfp registers
992 1119 void reset_wfp_burst_enable(void)
General Comments 0
You need to be logged in to leave comments. Login now