@@ -1,869 +1,869 | |||||
1 | /** This is the RTEMS initialization module. |
|
1 | /** This is the RTEMS initialization module. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * This module contains two very different information: |
|
6 | * This module contains two very different information: | |
7 | * - specific instructions to configure the compilation of the RTEMS executive |
|
7 | * - specific instructions to configure the compilation of the RTEMS executive | |
8 | * - functions related to the fligth softwre initialization, especially the INIT RTEMS task |
|
8 | * - functions related to the fligth softwre initialization, especially the INIT RTEMS task | |
9 | * |
|
9 | * | |
10 | */ |
|
10 | */ | |
11 |
|
11 | |||
12 | //************************* |
|
12 | //************************* | |
13 | // GPL reminder to be added |
|
13 | // GPL reminder to be added | |
14 | //************************* |
|
14 | //************************* | |
15 |
|
15 | |||
16 | #include <rtems.h> |
|
16 | #include <rtems.h> | |
17 |
|
17 | |||
18 | /* configuration information */ |
|
18 | /* configuration information */ | |
19 |
|
19 | |||
20 | #define CONFIGURE_INIT |
|
20 | #define CONFIGURE_INIT | |
21 |
|
21 | |||
22 | #include <bsp.h> /* for device driver prototypes */ |
|
22 | #include <bsp.h> /* for device driver prototypes */ | |
23 |
|
23 | |||
24 | /* configuration information */ |
|
24 | /* configuration information */ | |
25 |
|
25 | |||
26 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
26 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER | |
27 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
27 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER | |
28 |
|
28 | |||
29 | #define CONFIGURE_MAXIMUM_TASKS 20 |
|
29 | #define CONFIGURE_MAXIMUM_TASKS 20 | |
30 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
|
30 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE | |
31 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) |
|
31 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) | |
32 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 |
|
32 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 | |
33 | #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 |
|
33 | #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 | |
34 | #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) |
|
34 | #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) | |
35 | #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT) |
|
35 | #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT) | |
36 | #define CONFIGURE_MAXIMUM_DRIVERS 16 |
|
36 | #define CONFIGURE_MAXIMUM_DRIVERS 16 | |
37 | #define CONFIGURE_MAXIMUM_PERIODS 5 |
|
37 | #define CONFIGURE_MAXIMUM_PERIODS 5 | |
38 | #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s) |
|
38 | #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s) | |
39 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5 |
|
39 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5 | |
40 | #ifdef PRINT_STACK_REPORT |
|
40 | #ifdef PRINT_STACK_REPORT | |
41 | #define CONFIGURE_STACK_CHECKER_ENABLED |
|
41 | #define CONFIGURE_STACK_CHECKER_ENABLED | |
42 | #endif |
|
42 | #endif | |
43 |
|
43 | |||
44 | #include <rtems/confdefs.h> |
|
44 | #include <rtems/confdefs.h> | |
45 |
|
45 | |||
46 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ |
|
46 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ | |
47 | #ifdef RTEMS_DRVMGR_STARTUP |
|
47 | #ifdef RTEMS_DRVMGR_STARTUP | |
48 | #ifdef LEON3 |
|
48 | #ifdef LEON3 | |
49 | /* Add Timer and UART Driver */ |
|
49 | /* Add Timer and UART Driver */ | |
50 | #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
50 | #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER | |
51 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER |
|
51 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER | |
52 | #endif |
|
52 | #endif | |
53 | #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
53 | #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER | |
54 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART |
|
54 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART | |
55 | #endif |
|
55 | #endif | |
56 | #endif |
|
56 | #endif | |
57 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ |
|
57 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ | |
58 | #include <drvmgr/drvmgr_confdefs.h> |
|
58 | #include <drvmgr/drvmgr_confdefs.h> | |
59 | #endif |
|
59 | #endif | |
60 |
|
60 | |||
61 | #include "fsw_init.h" |
|
61 | #include "fsw_init.h" | |
62 | #include "fsw_config.c" |
|
62 | #include "fsw_config.c" | |
63 | #include "GscMemoryLPP.hpp" |
|
63 | #include "GscMemoryLPP.hpp" | |
64 |
|
64 | |||
65 | void initCache() |
|
65 | void initCache() | |
66 | { |
|
66 | { | |
67 | unsigned int cacheControlRegister; |
|
67 | unsigned int cacheControlRegister; | |
68 |
|
68 | |||
69 | cacheControlRegister = getCacheControlRegister(); |
|
69 | cacheControlRegister = getCacheControlRegister(); | |
70 | printf("(0) cacheControlRegister = %x\n", cacheControlRegister); |
|
70 | printf("(0) cacheControlRegister = %x\n", cacheControlRegister); | |
71 |
|
71 | |||
72 | resetCacheControlRegister(); |
|
72 | resetCacheControlRegister(); | |
73 |
|
73 | |||
74 | enableInstructionCache(); |
|
74 | enableInstructionCache(); | |
75 | enableDataCache(); |
|
75 | enableDataCache(); | |
76 | enableInstructionBurstFetch(); |
|
76 | enableInstructionBurstFetch(); | |
77 |
|
77 | |||
78 | cacheControlRegister = getCacheControlRegister(); |
|
78 | cacheControlRegister = getCacheControlRegister(); | |
79 | printf("(1) cacheControlRegister = %x\n", cacheControlRegister); |
|
79 | printf("(1) cacheControlRegister = %x\n", cacheControlRegister); | |
80 | } |
|
80 | } | |
81 |
|
81 | |||
82 | rtems_task Init( rtems_task_argument ignored ) |
|
82 | rtems_task Init( rtems_task_argument ignored ) | |
83 | { |
|
83 | { | |
84 | /** This is the RTEMS INIT taks, it is the first task launched by the system. |
|
84 | /** This is the RTEMS INIT taks, it is the first task launched by the system. | |
85 | * |
|
85 | * | |
86 | * @param unused is the starting argument of the RTEMS task |
|
86 | * @param unused is the starting argument of the RTEMS task | |
87 | * |
|
87 | * | |
88 | * The INIT task create and run all other RTEMS tasks. |
|
88 | * The INIT task create and run all other RTEMS tasks. | |
89 | * |
|
89 | * | |
90 | */ |
|
90 | */ | |
91 |
|
91 | |||
92 | //*********** |
|
92 | //*********** | |
93 | // INIT CACHE |
|
93 | // INIT CACHE | |
94 |
|
94 | |||
95 | unsigned char *vhdlVersion; |
|
95 | unsigned char *vhdlVersion; | |
96 |
|
96 | |||
97 | reset_lfr(); |
|
97 | reset_lfr(); | |
98 |
|
98 | |||
99 | reset_local_time(); |
|
99 | reset_local_time(); | |
100 |
|
100 | |||
101 | rtems_cpu_usage_reset(); |
|
101 | rtems_cpu_usage_reset(); | |
102 |
|
102 | |||
103 | rtems_status_code status; |
|
103 | rtems_status_code status; | |
104 | rtems_status_code status_spw; |
|
104 | rtems_status_code status_spw; | |
105 | rtems_isr_entry old_isr_handler; |
|
105 | rtems_isr_entry old_isr_handler; | |
106 |
|
106 | |||
107 | // UART settings |
|
107 | // UART settings | |
108 | send_console_outputs_on_apbuart_port(); |
|
108 | send_console_outputs_on_apbuart_port(); | |
109 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); |
|
109 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); | |
110 | enable_apbuart_transmitter(); |
|
110 | enable_apbuart_transmitter(); | |
111 |
|
111 | |||
112 | DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") |
|
112 | DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") | |
113 |
|
113 | |||
114 |
|
114 | |||
115 | PRINTF("\n\n\n\n\n") |
|
115 | PRINTF("\n\n\n\n\n") | |
116 |
|
116 | |||
117 | initCache(); |
|
117 | initCache(); | |
118 |
|
118 | |||
119 | PRINTF("*************************\n") |
|
119 | PRINTF("*************************\n") | |
120 | PRINTF("** LFR Flight Software **\n") |
|
120 | PRINTF("** LFR Flight Software **\n") | |
121 | PRINTF1("** %d.", SW_VERSION_N1) |
|
121 | PRINTF1("** %d.", SW_VERSION_N1) | |
122 | PRINTF1("%d." , SW_VERSION_N2) |
|
122 | PRINTF1("%d." , SW_VERSION_N2) | |
123 | PRINTF1("%d." , SW_VERSION_N3) |
|
123 | PRINTF1("%d." , SW_VERSION_N3) | |
124 | PRINTF1("%d **\n", SW_VERSION_N4) |
|
124 | PRINTF1("%d **\n", SW_VERSION_N4) | |
125 |
|
125 | |||
126 | vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION); |
|
126 | vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION); | |
127 | PRINTF("** VHDL **\n") |
|
127 | PRINTF("** VHDL **\n") | |
128 | PRINTF1("** %d.", vhdlVersion[1]) |
|
128 | PRINTF1("** %d.", vhdlVersion[1]) | |
129 | PRINTF1("%d." , vhdlVersion[2]) |
|
129 | PRINTF1("%d." , vhdlVersion[2]) | |
130 | PRINTF1("%d **\n", vhdlVersion[3]) |
|
130 | PRINTF1("%d **\n", vhdlVersion[3]) | |
131 | PRINTF("*************************\n") |
|
131 | PRINTF("*************************\n") | |
132 | PRINTF("\n\n") |
|
132 | PRINTF("\n\n") | |
133 |
|
133 | |||
134 | init_parameter_dump(); |
|
134 | init_parameter_dump(); | |
135 | init_kcoefficients_dump(); |
|
135 | init_kcoefficients_dump(); | |
136 | init_local_mode_parameters(); |
|
136 | init_local_mode_parameters(); | |
137 | init_housekeeping_parameters(); |
|
137 | init_housekeeping_parameters(); | |
138 | init_k_coefficients_f0(); |
|
138 | init_k_coefficients_f0(); | |
139 | init_k_coefficients_f1(); |
|
139 | init_k_coefficients_f1(); | |
140 | init_k_coefficients_f2(); |
|
140 | init_k_coefficients_f2(); | |
141 |
|
141 | |||
142 | // waveform picker initialization |
|
142 | // waveform picker initialization | |
143 | WFP_init_rings(); // initialize the waveform rings |
|
143 | WFP_init_rings(); // initialize the waveform rings | |
144 | WFP_reset_current_ring_nodes(); |
|
144 | WFP_reset_current_ring_nodes(); | |
145 | reset_waveform_picker_regs(); |
|
145 | reset_waveform_picker_regs(); | |
146 |
|
146 | |||
147 | // spectral matrices initialization |
|
147 | // spectral matrices initialization | |
148 | SM_init_rings(); // initialize spectral matrices rings |
|
148 | SM_init_rings(); // initialize spectral matrices rings | |
149 | SM_reset_current_ring_nodes(); |
|
149 | SM_reset_current_ring_nodes(); | |
150 | reset_spectral_matrix_regs(); |
|
150 | reset_spectral_matrix_regs(); | |
151 |
|
151 | |||
152 | // configure calibration |
|
152 | // configure calibration | |
153 | configureCalibration( false ); // true means interleaved mode, false is for normal mode |
|
153 | configureCalibration( false ); // true means interleaved mode, false is for normal mode | |
154 |
|
154 | |||
155 | updateLFRCurrentMode(); |
|
155 | updateLFRCurrentMode(); | |
156 |
|
156 | |||
157 | BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode) |
|
157 | BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode) | |
158 |
|
158 | |||
159 | create_names(); // create all names |
|
159 | create_names(); // create all names | |
160 |
|
160 | |||
161 | status = create_message_queues(); // create message queues |
|
161 | status = create_message_queues(); // create message queues | |
162 | if (status != RTEMS_SUCCESSFUL) |
|
162 | if (status != RTEMS_SUCCESSFUL) | |
163 | { |
|
163 | { | |
164 | PRINTF1("in INIT *** ERR in create_message_queues, code %d", status) |
|
164 | PRINTF1("in INIT *** ERR in create_message_queues, code %d", status) | |
165 | } |
|
165 | } | |
166 |
|
166 | |||
167 | status = create_all_tasks(); // create all tasks |
|
167 | status = create_all_tasks(); // create all tasks | |
168 | if (status != RTEMS_SUCCESSFUL) |
|
168 | if (status != RTEMS_SUCCESSFUL) | |
169 | { |
|
169 | { | |
170 | PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status) |
|
170 | PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status) | |
171 | } |
|
171 | } | |
172 |
|
172 | |||
173 | // ************************** |
|
173 | // ************************** | |
174 | // <SPACEWIRE INITIALIZATION> |
|
174 | // <SPACEWIRE INITIALIZATION> | |
175 | grspw_timecode_callback = &timecode_irq_handler; |
|
175 | grspw_timecode_callback = &timecode_irq_handler; | |
176 |
|
176 | |||
177 | status_spw = spacewire_open_link(); // (1) open the link |
|
177 | status_spw = spacewire_open_link(); // (1) open the link | |
178 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
178 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
179 | { |
|
179 | { | |
180 | PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw ) |
|
180 | PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw ) | |
181 | } |
|
181 | } | |
182 |
|
182 | |||
183 | if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link |
|
183 | if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link | |
184 | { |
|
184 | { | |
185 | status_spw = spacewire_configure_link( fdSPW ); |
|
185 | status_spw = spacewire_configure_link( fdSPW ); | |
186 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
186 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
187 | { |
|
187 | { | |
188 | PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw ) |
|
188 | PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw ) | |
189 | } |
|
189 | } | |
190 | } |
|
190 | } | |
191 |
|
191 | |||
192 | if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link |
|
192 | if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link | |
193 | { |
|
193 | { | |
194 | status_spw = spacewire_start_link( fdSPW ); |
|
194 | status_spw = spacewire_start_link( fdSPW ); | |
195 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
195 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
196 | { |
|
196 | { | |
197 | PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw ) |
|
197 | PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw ) | |
198 | } |
|
198 | } | |
199 | } |
|
199 | } | |
200 | // </SPACEWIRE INITIALIZATION> |
|
200 | // </SPACEWIRE INITIALIZATION> | |
201 | // *************************** |
|
201 | // *************************** | |
202 |
|
202 | |||
203 | status = start_all_tasks(); // start all tasks |
|
203 | status = start_all_tasks(); // start all tasks | |
204 | if (status != RTEMS_SUCCESSFUL) |
|
204 | if (status != RTEMS_SUCCESSFUL) | |
205 | { |
|
205 | { | |
206 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) |
|
206 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) | |
207 | } |
|
207 | } | |
208 |
|
208 | |||
209 | // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization |
|
209 | // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization | |
210 | status = start_recv_send_tasks(); |
|
210 | status = start_recv_send_tasks(); | |
211 | if ( status != RTEMS_SUCCESSFUL ) |
|
211 | if ( status != RTEMS_SUCCESSFUL ) | |
212 | { |
|
212 | { | |
213 | PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status ) |
|
213 | PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status ) | |
214 | } |
|
214 | } | |
215 |
|
215 | |||
216 | // suspend science tasks, they will be restarted later depending on the mode |
|
216 | // suspend science tasks, they will be restarted later depending on the mode | |
217 | status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY) |
|
217 | status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY) | |
218 | if (status != RTEMS_SUCCESSFUL) |
|
218 | if (status != RTEMS_SUCCESSFUL) | |
219 | { |
|
219 | { | |
220 | PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
220 | PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status) | |
221 | } |
|
221 | } | |
222 |
|
222 | |||
223 | //****************************** |
|
223 | //****************************** | |
224 | // <SPECTRAL MATRICES SIMULATOR> |
|
224 | // <SPECTRAL MATRICES SIMULATOR> | |
225 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); |
|
225 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); | |
226 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR, |
|
226 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR, | |
227 | IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu ); |
|
227 | IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu ); | |
228 | // </SPECTRAL MATRICES SIMULATOR> |
|
228 | // </SPECTRAL MATRICES SIMULATOR> | |
229 | //******************************* |
|
229 | //******************************* | |
230 |
|
230 | |||
231 | // configure IRQ handling for the waveform picker unit |
|
231 | // configure IRQ handling for the waveform picker unit | |
232 | status = rtems_interrupt_catch( waveforms_isr, |
|
232 | status = rtems_interrupt_catch( waveforms_isr, | |
233 | IRQ_SPARC_WAVEFORM_PICKER, |
|
233 | IRQ_SPARC_WAVEFORM_PICKER, | |
234 | &old_isr_handler) ; |
|
234 | &old_isr_handler) ; | |
235 | // configure IRQ handling for the spectral matrices unit |
|
235 | // configure IRQ handling for the spectral matrices unit | |
236 | status = rtems_interrupt_catch( spectral_matrices_isr, |
|
236 | status = rtems_interrupt_catch( spectral_matrices_isr, | |
237 | IRQ_SPARC_SPECTRAL_MATRIX, |
|
237 | IRQ_SPARC_SPECTRAL_MATRIX, | |
238 | &old_isr_handler) ; |
|
238 | &old_isr_handler) ; | |
239 |
|
239 | |||
240 | // if the spacewire link is not up then send an event to the SPIQ task for link recovery |
|
240 | // if the spacewire link is not up then send an event to the SPIQ task for link recovery | |
241 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
241 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
242 | { |
|
242 | { | |
243 | status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ); |
|
243 | status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ); | |
244 | if ( status != RTEMS_SUCCESSFUL ) { |
|
244 | if ( status != RTEMS_SUCCESSFUL ) { | |
245 | PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status ) |
|
245 | PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status ) | |
246 | } |
|
246 | } | |
247 | } |
|
247 | } | |
248 |
|
248 | |||
249 | BOOT_PRINTF("delete INIT\n") |
|
249 | BOOT_PRINTF("delete INIT\n") | |
250 |
|
250 | |||
251 | status = rtems_task_delete(RTEMS_SELF); |
|
251 | status = rtems_task_delete(RTEMS_SELF); | |
252 |
|
252 | |||
253 | } |
|
253 | } | |
254 |
|
254 | |||
255 | void init_local_mode_parameters( void ) |
|
255 | void init_local_mode_parameters( void ) | |
256 | { |
|
256 | { | |
257 | /** This function initialize the param_local global variable with default values. |
|
257 | /** This function initialize the param_local global variable with default values. | |
258 | * |
|
258 | * | |
259 | */ |
|
259 | */ | |
260 |
|
260 | |||
261 | unsigned int i; |
|
261 | unsigned int i; | |
262 |
|
262 | |||
263 | // LOCAL PARAMETERS |
|
263 | // LOCAL PARAMETERS | |
264 |
|
264 | |||
265 | BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) |
|
265 | BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) | |
266 | BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) |
|
266 | BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) | |
267 | BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX) |
|
267 | BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX) | |
268 |
|
268 | |||
269 | // init sequence counters |
|
269 | // init sequence counters | |
270 |
|
270 | |||
271 | for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++) |
|
271 | for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++) | |
272 | { |
|
272 | { | |
273 | sequenceCounters_TC_EXE[i] = 0x00; |
|
273 | sequenceCounters_TC_EXE[i] = 0x00; | |
274 | } |
|
274 | } | |
275 | sequenceCounters_SCIENCE_NORMAL_BURST = 0x00; |
|
275 | sequenceCounters_SCIENCE_NORMAL_BURST = 0x00; | |
276 | sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00; |
|
276 | sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00; | |
277 | sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
277 | sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8; | |
278 | sequenceCounterParameterDump = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
278 | sequenceCounterParameterDump = TM_PACKET_SEQ_CTRL_STANDALONE << 8; | |
279 | } |
|
279 | } | |
280 |
|
280 | |||
281 | void reset_local_time( void ) |
|
281 | void reset_local_time( void ) | |
282 | { |
|
282 | { | |
283 | time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000 |
|
283 | time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000 | |
284 | } |
|
284 | } | |
285 |
|
285 | |||
286 | void create_names( void ) // create all names for tasks and queues |
|
286 | void create_names( void ) // create all names for tasks and queues | |
287 | { |
|
287 | { | |
288 | /** This function creates all RTEMS names used in the software for tasks and queues. |
|
288 | /** This function creates all RTEMS names used in the software for tasks and queues. | |
289 | * |
|
289 | * | |
290 | * @return RTEMS directive status codes: |
|
290 | * @return RTEMS directive status codes: | |
291 | * - RTEMS_SUCCESSFUL - successful completion |
|
291 | * - RTEMS_SUCCESSFUL - successful completion | |
292 | * |
|
292 | * | |
293 | */ |
|
293 | */ | |
294 |
|
294 | |||
295 | // task names |
|
295 | // task names | |
296 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); |
|
296 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); | |
297 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); |
|
297 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); | |
298 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); |
|
298 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); | |
299 | Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' ); |
|
299 | Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' ); | |
300 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); |
|
300 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); | |
301 | Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' ); |
|
301 | Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' ); | |
302 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); |
|
302 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); | |
303 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); |
|
303 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); | |
304 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
304 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); | |
305 | Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' ); |
|
305 | Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' ); | |
306 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); |
|
306 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); | |
307 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); |
|
307 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); | |
308 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); |
|
308 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); | |
309 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); |
|
309 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); | |
310 | Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' ); |
|
310 | Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' ); | |
311 | Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' ); |
|
311 | Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' ); | |
312 | Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' ); |
|
312 | Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' ); | |
313 | Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' ); |
|
313 | Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' ); | |
314 | Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' ); |
|
314 | Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' ); | |
315 |
|
315 | |||
316 | // rate monotonic period names |
|
316 | // rate monotonic period names | |
317 | name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
317 | name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' ); | |
318 |
|
318 | |||
319 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
319 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); | |
320 | misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
320 | misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); | |
321 | misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' ); |
|
321 | misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' ); | |
322 | misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' ); |
|
322 | misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' ); | |
323 | misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' ); |
|
323 | misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' ); | |
324 | } |
|
324 | } | |
325 |
|
325 | |||
326 | int create_all_tasks( void ) // create all tasks which run in the software |
|
326 | int create_all_tasks( void ) // create all tasks which run in the software | |
327 | { |
|
327 | { | |
328 | /** This function creates all RTEMS tasks used in the software. |
|
328 | /** This function creates all RTEMS tasks used in the software. | |
329 | * |
|
329 | * | |
330 | * @return RTEMS directive status codes: |
|
330 | * @return RTEMS directive status codes: | |
331 | * - RTEMS_SUCCESSFUL - task created successfully |
|
331 | * - RTEMS_SUCCESSFUL - task created successfully | |
332 | * - RTEMS_INVALID_ADDRESS - id is NULL |
|
332 | * - RTEMS_INVALID_ADDRESS - id is NULL | |
333 | * - RTEMS_INVALID_NAME - invalid task name |
|
333 | * - RTEMS_INVALID_NAME - invalid task name | |
334 | * - RTEMS_INVALID_PRIORITY - invalid task priority |
|
334 | * - RTEMS_INVALID_PRIORITY - invalid task priority | |
335 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured |
|
335 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured | |
336 | * - RTEMS_TOO_MANY - too many tasks created |
|
336 | * - RTEMS_TOO_MANY - too many tasks created | |
337 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context |
|
337 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context | |
338 | * - RTEMS_TOO_MANY - too many global objects |
|
338 | * - RTEMS_TOO_MANY - too many global objects | |
339 | * |
|
339 | * | |
340 | */ |
|
340 | */ | |
341 |
|
341 | |||
342 | rtems_status_code status; |
|
342 | rtems_status_code status; | |
343 |
|
343 | |||
344 | //********** |
|
344 | //********** | |
345 | // SPACEWIRE |
|
345 | // SPACEWIRE | |
346 | // RECV |
|
346 | // RECV | |
347 | status = rtems_task_create( |
|
347 | status = rtems_task_create( | |
348 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, |
|
348 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, | |
349 | RTEMS_DEFAULT_MODES, |
|
349 | RTEMS_DEFAULT_MODES, | |
350 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] |
|
350 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] | |
351 | ); |
|
351 | ); | |
352 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
352 | if (status == RTEMS_SUCCESSFUL) // SEND | |
353 | { |
|
353 | { | |
354 | status = rtems_task_create( |
|
354 | status = rtems_task_create( | |
355 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
355 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2, | |
356 | RTEMS_DEFAULT_MODES, |
|
356 | RTEMS_DEFAULT_MODES, | |
357 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND] |
|
357 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND] | |
358 | ); |
|
358 | ); | |
359 | } |
|
359 | } | |
360 | if (status == RTEMS_SUCCESSFUL) // WTDG |
|
360 | if (status == RTEMS_SUCCESSFUL) // WTDG | |
361 | { |
|
361 | { | |
362 | status = rtems_task_create( |
|
362 | status = rtems_task_create( | |
363 | Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE, |
|
363 | Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE, | |
364 | RTEMS_DEFAULT_MODES, |
|
364 | RTEMS_DEFAULT_MODES, | |
365 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG] |
|
365 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG] | |
366 | ); |
|
366 | ); | |
367 | } |
|
367 | } | |
368 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
368 | if (status == RTEMS_SUCCESSFUL) // ACTN | |
369 | { |
|
369 | { | |
370 | status = rtems_task_create( |
|
370 | status = rtems_task_create( | |
371 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, |
|
371 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, | |
372 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
372 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
373 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] |
|
373 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] | |
374 | ); |
|
374 | ); | |
375 | } |
|
375 | } | |
376 | if (status == RTEMS_SUCCESSFUL) // SPIQ |
|
376 | if (status == RTEMS_SUCCESSFUL) // SPIQ | |
377 | { |
|
377 | { | |
378 | status = rtems_task_create( |
|
378 | status = rtems_task_create( | |
379 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, |
|
379 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, | |
380 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
380 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
381 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] |
|
381 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] | |
382 | ); |
|
382 | ); | |
383 | } |
|
383 | } | |
384 |
|
384 | |||
385 | //****************** |
|
385 | //****************** | |
386 | // SPECTRAL MATRICES |
|
386 | // SPECTRAL MATRICES | |
387 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
387 | if (status == RTEMS_SUCCESSFUL) // AVF0 | |
388 | { |
|
388 | { | |
389 | status = rtems_task_create( |
|
389 | status = rtems_task_create( | |
390 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, |
|
390 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, | |
391 | RTEMS_DEFAULT_MODES, |
|
391 | RTEMS_DEFAULT_MODES, | |
392 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] |
|
392 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] | |
393 | ); |
|
393 | ); | |
394 | } |
|
394 | } | |
395 | if (status == RTEMS_SUCCESSFUL) // PRC0 |
|
395 | if (status == RTEMS_SUCCESSFUL) // PRC0 | |
396 | { |
|
396 | { | |
397 | status = rtems_task_create( |
|
397 | status = rtems_task_create( | |
398 | Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
398 | Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2, | |
399 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
399 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
400 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0] |
|
400 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0] | |
401 | ); |
|
401 | ); | |
402 | } |
|
402 | } | |
403 | if (status == RTEMS_SUCCESSFUL) // AVF1 |
|
403 | if (status == RTEMS_SUCCESSFUL) // AVF1 | |
404 | { |
|
404 | { | |
405 | status = rtems_task_create( |
|
405 | status = rtems_task_create( | |
406 | Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE, |
|
406 | Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE, | |
407 | RTEMS_DEFAULT_MODES, |
|
407 | RTEMS_DEFAULT_MODES, | |
408 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1] |
|
408 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1] | |
409 | ); |
|
409 | ); | |
410 | } |
|
410 | } | |
411 | if (status == RTEMS_SUCCESSFUL) // PRC1 |
|
411 | if (status == RTEMS_SUCCESSFUL) // PRC1 | |
412 | { |
|
412 | { | |
413 | status = rtems_task_create( |
|
413 | status = rtems_task_create( | |
414 | Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
414 | Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2, | |
415 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
415 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
416 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1] |
|
416 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1] | |
417 | ); |
|
417 | ); | |
418 | } |
|
418 | } | |
419 | if (status == RTEMS_SUCCESSFUL) // AVF2 |
|
419 | if (status == RTEMS_SUCCESSFUL) // AVF2 | |
420 | { |
|
420 | { | |
421 | status = rtems_task_create( |
|
421 | status = rtems_task_create( | |
422 | Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE, |
|
422 | Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE, | |
423 | RTEMS_DEFAULT_MODES, |
|
423 | RTEMS_DEFAULT_MODES, | |
424 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2] |
|
424 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2] | |
425 | ); |
|
425 | ); | |
426 | } |
|
426 | } | |
427 | if (status == RTEMS_SUCCESSFUL) // PRC2 |
|
427 | if (status == RTEMS_SUCCESSFUL) // PRC2 | |
428 | { |
|
428 | { | |
429 | status = rtems_task_create( |
|
429 | status = rtems_task_create( | |
430 | Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
430 | Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2, | |
431 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
431 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
432 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2] |
|
432 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2] | |
433 | ); |
|
433 | ); | |
434 | } |
|
434 | } | |
435 |
|
435 | |||
436 | //**************** |
|
436 | //**************** | |
437 | // WAVEFORM PICKER |
|
437 | // WAVEFORM PICKER | |
438 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
438 | if (status == RTEMS_SUCCESSFUL) // WFRM | |
439 | { |
|
439 | { | |
440 | status = rtems_task_create( |
|
440 | status = rtems_task_create( | |
441 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, |
|
441 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, | |
442 | RTEMS_DEFAULT_MODES, |
|
442 | RTEMS_DEFAULT_MODES, | |
443 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] |
|
443 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] | |
444 | ); |
|
444 | ); | |
445 | } |
|
445 | } | |
446 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
446 | if (status == RTEMS_SUCCESSFUL) // CWF3 | |
447 | { |
|
447 | { | |
448 | status = rtems_task_create( |
|
448 | status = rtems_task_create( | |
449 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, |
|
449 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, | |
450 | RTEMS_DEFAULT_MODES, |
|
450 | RTEMS_DEFAULT_MODES, | |
451 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3] |
|
451 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3] | |
452 | ); |
|
452 | ); | |
453 | } |
|
453 | } | |
454 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
454 | if (status == RTEMS_SUCCESSFUL) // CWF2 | |
455 | { |
|
455 | { | |
456 | status = rtems_task_create( |
|
456 | status = rtems_task_create( | |
457 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, |
|
457 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, | |
458 | RTEMS_DEFAULT_MODES, |
|
458 | RTEMS_DEFAULT_MODES, | |
459 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2] |
|
459 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2] | |
460 | ); |
|
460 | ); | |
461 | } |
|
461 | } | |
462 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
462 | if (status == RTEMS_SUCCESSFUL) // CWF1 | |
463 | { |
|
463 | { | |
464 | status = rtems_task_create( |
|
464 | status = rtems_task_create( | |
465 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, |
|
465 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, | |
466 | RTEMS_DEFAULT_MODES, |
|
466 | RTEMS_DEFAULT_MODES, | |
467 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1] |
|
467 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1] | |
468 | ); |
|
468 | ); | |
469 | } |
|
469 | } | |
470 | if (status == RTEMS_SUCCESSFUL) // SWBD |
|
470 | if (status == RTEMS_SUCCESSFUL) // SWBD | |
471 | { |
|
471 | { | |
472 | status = rtems_task_create( |
|
472 | status = rtems_task_create( | |
473 | Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE, |
|
473 | Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE, | |
474 | RTEMS_DEFAULT_MODES, |
|
474 | RTEMS_DEFAULT_MODES, | |
475 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD] |
|
475 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD] | |
476 | ); |
|
476 | ); | |
477 | } |
|
477 | } | |
478 |
|
478 | |||
479 | //***** |
|
479 | //***** | |
480 | // MISC |
|
480 | // MISC | |
481 | if (status == RTEMS_SUCCESSFUL) // STAT |
|
481 | if (status == RTEMS_SUCCESSFUL) // STAT | |
482 | { |
|
482 | { | |
483 | status = rtems_task_create( |
|
483 | status = rtems_task_create( | |
484 | Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE, |
|
484 | Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE, | |
485 | RTEMS_DEFAULT_MODES, |
|
485 | RTEMS_DEFAULT_MODES, | |
486 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT] |
|
486 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT] | |
487 | ); |
|
487 | ); | |
488 | } |
|
488 | } | |
489 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
489 | if (status == RTEMS_SUCCESSFUL) // DUMB | |
490 | { |
|
490 | { | |
491 | status = rtems_task_create( |
|
491 | status = rtems_task_create( | |
492 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, |
|
492 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, | |
493 | RTEMS_DEFAULT_MODES, |
|
493 | RTEMS_DEFAULT_MODES, | |
494 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] |
|
494 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] | |
495 | ); |
|
495 | ); | |
496 | } |
|
496 | } | |
497 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
497 | if (status == RTEMS_SUCCESSFUL) // HOUS | |
498 | { |
|
498 | { | |
499 | status = rtems_task_create( |
|
499 | status = rtems_task_create( | |
500 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, |
|
500 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, | |
501 | RTEMS_DEFAULT_MODES, |
|
501 | RTEMS_DEFAULT_MODES, | |
502 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS] |
|
502 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS] | |
503 | ); |
|
503 | ); | |
504 | } |
|
504 | } | |
505 |
|
505 | |||
506 | return status; |
|
506 | return status; | |
507 | } |
|
507 | } | |
508 |
|
508 | |||
509 | int start_recv_send_tasks( void ) |
|
509 | int start_recv_send_tasks( void ) | |
510 | { |
|
510 | { | |
511 | rtems_status_code status; |
|
511 | rtems_status_code status; | |
512 |
|
512 | |||
513 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); |
|
513 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); | |
514 | if (status!=RTEMS_SUCCESSFUL) { |
|
514 | if (status!=RTEMS_SUCCESSFUL) { | |
515 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") |
|
515 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") | |
516 | } |
|
516 | } | |
517 |
|
517 | |||
518 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
518 | if (status == RTEMS_SUCCESSFUL) // SEND | |
519 | { |
|
519 | { | |
520 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); |
|
520 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); | |
521 | if (status!=RTEMS_SUCCESSFUL) { |
|
521 | if (status!=RTEMS_SUCCESSFUL) { | |
522 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") |
|
522 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") | |
523 | } |
|
523 | } | |
524 | } |
|
524 | } | |
525 |
|
525 | |||
526 | return status; |
|
526 | return status; | |
527 | } |
|
527 | } | |
528 |
|
528 | |||
529 | int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS |
|
529 | int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS | |
530 | { |
|
530 | { | |
531 | /** This function starts all RTEMS tasks used in the software. |
|
531 | /** This function starts all RTEMS tasks used in the software. | |
532 | * |
|
532 | * | |
533 | * @return RTEMS directive status codes: |
|
533 | * @return RTEMS directive status codes: | |
534 | * - RTEMS_SUCCESSFUL - ask started successfully |
|
534 | * - RTEMS_SUCCESSFUL - ask started successfully | |
535 | * - RTEMS_INVALID_ADDRESS - invalid task entry point |
|
535 | * - RTEMS_INVALID_ADDRESS - invalid task entry point | |
536 | * - RTEMS_INVALID_ID - invalid task id |
|
536 | * - RTEMS_INVALID_ID - invalid task id | |
537 | * - RTEMS_INCORRECT_STATE - task not in the dormant state |
|
537 | * - RTEMS_INCORRECT_STATE - task not in the dormant state | |
538 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task |
|
538 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task | |
539 | * |
|
539 | * | |
540 | */ |
|
540 | */ | |
541 | // starts all the tasks fot eh flight software |
|
541 | // starts all the tasks fot eh flight software | |
542 |
|
542 | |||
543 | rtems_status_code status; |
|
543 | rtems_status_code status; | |
544 |
|
544 | |||
545 | //********** |
|
545 | //********** | |
546 | // SPACEWIRE |
|
546 | // SPACEWIRE | |
547 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); |
|
547 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); | |
548 | if (status!=RTEMS_SUCCESSFUL) { |
|
548 | if (status!=RTEMS_SUCCESSFUL) { | |
549 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") |
|
549 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") | |
550 | } |
|
550 | } | |
551 |
|
551 | |||
552 | if (status == RTEMS_SUCCESSFUL) // WTDG |
|
552 | if (status == RTEMS_SUCCESSFUL) // WTDG | |
553 | { |
|
553 | { | |
554 | status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 ); |
|
554 | status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 ); | |
555 | if (status!=RTEMS_SUCCESSFUL) { |
|
555 | if (status!=RTEMS_SUCCESSFUL) { | |
556 | BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n") |
|
556 | BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n") | |
557 | } |
|
557 | } | |
558 | } |
|
558 | } | |
559 |
|
559 | |||
560 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
560 | if (status == RTEMS_SUCCESSFUL) // ACTN | |
561 | { |
|
561 | { | |
562 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); |
|
562 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); | |
563 | if (status!=RTEMS_SUCCESSFUL) { |
|
563 | if (status!=RTEMS_SUCCESSFUL) { | |
564 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") |
|
564 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") | |
565 | } |
|
565 | } | |
566 | } |
|
566 | } | |
567 |
|
567 | |||
568 | //****************** |
|
568 | //****************** | |
569 | // SPECTRAL MATRICES |
|
569 | // SPECTRAL MATRICES | |
570 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
570 | if (status == RTEMS_SUCCESSFUL) // AVF0 | |
571 | { |
|
571 | { | |
572 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY ); |
|
572 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY ); | |
573 | if (status!=RTEMS_SUCCESSFUL) { |
|
573 | if (status!=RTEMS_SUCCESSFUL) { | |
574 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") |
|
574 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") | |
575 | } |
|
575 | } | |
576 | } |
|
576 | } | |
577 | if (status == RTEMS_SUCCESSFUL) // PRC0 |
|
577 | if (status == RTEMS_SUCCESSFUL) // PRC0 | |
578 | { |
|
578 | { | |
579 | status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY ); |
|
579 | status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY ); | |
580 | if (status!=RTEMS_SUCCESSFUL) { |
|
580 | if (status!=RTEMS_SUCCESSFUL) { | |
581 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n") |
|
581 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n") | |
582 | } |
|
582 | } | |
583 | } |
|
583 | } | |
584 | if (status == RTEMS_SUCCESSFUL) // AVF1 |
|
584 | if (status == RTEMS_SUCCESSFUL) // AVF1 | |
585 | { |
|
585 | { | |
586 | status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY ); |
|
586 | status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY ); | |
587 | if (status!=RTEMS_SUCCESSFUL) { |
|
587 | if (status!=RTEMS_SUCCESSFUL) { | |
588 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n") |
|
588 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n") | |
589 | } |
|
589 | } | |
590 | } |
|
590 | } | |
591 | if (status == RTEMS_SUCCESSFUL) // PRC1 |
|
591 | if (status == RTEMS_SUCCESSFUL) // PRC1 | |
592 | { |
|
592 | { | |
593 | status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY ); |
|
593 | status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY ); | |
594 | if (status!=RTEMS_SUCCESSFUL) { |
|
594 | if (status!=RTEMS_SUCCESSFUL) { | |
595 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n") |
|
595 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n") | |
596 | } |
|
596 | } | |
597 | } |
|
597 | } | |
598 | if (status == RTEMS_SUCCESSFUL) // AVF2 |
|
598 | if (status == RTEMS_SUCCESSFUL) // AVF2 | |
599 | { |
|
599 | { | |
600 | status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 ); |
|
600 | status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 ); | |
601 | if (status!=RTEMS_SUCCESSFUL) { |
|
601 | if (status!=RTEMS_SUCCESSFUL) { | |
602 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n") |
|
602 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n") | |
603 | } |
|
603 | } | |
604 | } |
|
604 | } | |
605 | if (status == RTEMS_SUCCESSFUL) // PRC2 |
|
605 | if (status == RTEMS_SUCCESSFUL) // PRC2 | |
606 | { |
|
606 | { | |
607 | status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 ); |
|
607 | status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 ); | |
608 | if (status!=RTEMS_SUCCESSFUL) { |
|
608 | if (status!=RTEMS_SUCCESSFUL) { | |
609 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n") |
|
609 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n") | |
610 | } |
|
610 | } | |
611 | } |
|
611 | } | |
612 |
|
612 | |||
613 | //**************** |
|
613 | //**************** | |
614 | // WAVEFORM PICKER |
|
614 | // WAVEFORM PICKER | |
615 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
615 | if (status == RTEMS_SUCCESSFUL) // WFRM | |
616 | { |
|
616 | { | |
617 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); |
|
617 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); | |
618 | if (status!=RTEMS_SUCCESSFUL) { |
|
618 | if (status!=RTEMS_SUCCESSFUL) { | |
619 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") |
|
619 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") | |
620 | } |
|
620 | } | |
621 | } |
|
621 | } | |
622 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
622 | if (status == RTEMS_SUCCESSFUL) // CWF3 | |
623 | { |
|
623 | { | |
624 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); |
|
624 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); | |
625 | if (status!=RTEMS_SUCCESSFUL) { |
|
625 | if (status!=RTEMS_SUCCESSFUL) { | |
626 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") |
|
626 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") | |
627 | } |
|
627 | } | |
628 | } |
|
628 | } | |
629 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
629 | if (status == RTEMS_SUCCESSFUL) // CWF2 | |
630 | { |
|
630 | { | |
631 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); |
|
631 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); | |
632 | if (status!=RTEMS_SUCCESSFUL) { |
|
632 | if (status!=RTEMS_SUCCESSFUL) { | |
633 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") |
|
633 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") | |
634 | } |
|
634 | } | |
635 | } |
|
635 | } | |
636 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
636 | if (status == RTEMS_SUCCESSFUL) // CWF1 | |
637 | { |
|
637 | { | |
638 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); |
|
638 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); | |
639 | if (status!=RTEMS_SUCCESSFUL) { |
|
639 | if (status!=RTEMS_SUCCESSFUL) { | |
640 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") |
|
640 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") | |
641 | } |
|
641 | } | |
642 | } |
|
642 | } | |
643 | if (status == RTEMS_SUCCESSFUL) // SWBD |
|
643 | if (status == RTEMS_SUCCESSFUL) // SWBD | |
644 | { |
|
644 | { | |
645 | status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 ); |
|
645 | status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 ); | |
646 | if (status!=RTEMS_SUCCESSFUL) { |
|
646 | if (status!=RTEMS_SUCCESSFUL) { | |
647 | BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n") |
|
647 | BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n") | |
648 | } |
|
648 | } | |
649 | } |
|
649 | } | |
650 |
|
650 | |||
651 | //***** |
|
651 | //***** | |
652 | // MISC |
|
652 | // MISC | |
653 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
653 | if (status == RTEMS_SUCCESSFUL) // HOUS | |
654 | { |
|
654 | { | |
655 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); |
|
655 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); | |
656 | if (status!=RTEMS_SUCCESSFUL) { |
|
656 | if (status!=RTEMS_SUCCESSFUL) { | |
657 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") |
|
657 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") | |
658 | } |
|
658 | } | |
659 | } |
|
659 | } | |
660 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
660 | if (status == RTEMS_SUCCESSFUL) // DUMB | |
661 | { |
|
661 | { | |
662 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); |
|
662 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); | |
663 | if (status!=RTEMS_SUCCESSFUL) { |
|
663 | if (status!=RTEMS_SUCCESSFUL) { | |
664 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") |
|
664 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") | |
665 | } |
|
665 | } | |
666 | } |
|
666 | } | |
667 | if (status == RTEMS_SUCCESSFUL) // STAT |
|
667 | if (status == RTEMS_SUCCESSFUL) // STAT | |
668 | { |
|
668 | { | |
669 | status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 ); |
|
669 | status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 ); | |
670 | if (status!=RTEMS_SUCCESSFUL) { |
|
670 | if (status!=RTEMS_SUCCESSFUL) { | |
671 | BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n") |
|
671 | BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n") | |
672 | } |
|
672 | } | |
673 | } |
|
673 | } | |
674 |
|
674 | |||
675 | return status; |
|
675 | return status; | |
676 | } |
|
676 | } | |
677 |
|
677 | |||
678 | rtems_status_code create_message_queues( void ) // create the two message queues used in the software |
|
678 | rtems_status_code create_message_queues( void ) // create the two message queues used in the software | |
679 | { |
|
679 | { | |
680 | rtems_status_code status_recv; |
|
680 | rtems_status_code status_recv; | |
681 | rtems_status_code status_send; |
|
681 | rtems_status_code status_send; | |
682 | rtems_status_code status_q_p0; |
|
682 | rtems_status_code status_q_p0; | |
683 | rtems_status_code status_q_p1; |
|
683 | rtems_status_code status_q_p1; | |
684 | rtems_status_code status_q_p2; |
|
684 | rtems_status_code status_q_p2; | |
685 | rtems_status_code ret; |
|
685 | rtems_status_code ret; | |
686 | rtems_id queue_id; |
|
686 | rtems_id queue_id; | |
687 |
|
687 | |||
688 | //**************************************** |
|
688 | //**************************************** | |
689 | // create the queue for handling valid TCs |
|
689 | // create the queue for handling valid TCs | |
690 | status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV], |
|
690 | status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV], | |
691 | MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE, |
|
691 | MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE, | |
692 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
692 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
693 | if ( status_recv != RTEMS_SUCCESSFUL ) { |
|
693 | if ( status_recv != RTEMS_SUCCESSFUL ) { | |
694 | PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv) |
|
694 | PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv) | |
695 | } |
|
695 | } | |
696 |
|
696 | |||
697 | //************************************************ |
|
697 | //************************************************ | |
698 | // create the queue for handling TM packet sending |
|
698 | // create the queue for handling TM packet sending | |
699 | status_send = rtems_message_queue_create( misc_name[QUEUE_SEND], |
|
699 | status_send = rtems_message_queue_create( misc_name[QUEUE_SEND], | |
700 | MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND, |
|
700 | MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND, | |
701 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
701 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
702 | if ( status_send != RTEMS_SUCCESSFUL ) { |
|
702 | if ( status_send != RTEMS_SUCCESSFUL ) { | |
703 | PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send) |
|
703 | PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send) | |
704 | } |
|
704 | } | |
705 |
|
705 | |||
706 | //***************************************************************************** |
|
706 | //***************************************************************************** | |
707 | // create the queue for handling averaged spectral matrices for processing @ f0 |
|
707 | // create the queue for handling averaged spectral matrices for processing @ f0 | |
708 | status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0], |
|
708 | status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0], | |
709 | MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0, |
|
709 | MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0, | |
710 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
710 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
711 | if ( status_q_p0 != RTEMS_SUCCESSFUL ) { |
|
711 | if ( status_q_p0 != RTEMS_SUCCESSFUL ) { | |
712 | PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0) |
|
712 | PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0) | |
713 | } |
|
713 | } | |
714 |
|
714 | |||
715 | //***************************************************************************** |
|
715 | //***************************************************************************** | |
716 | // create the queue for handling averaged spectral matrices for processing @ f1 |
|
716 | // create the queue for handling averaged spectral matrices for processing @ f1 | |
717 | status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1], |
|
717 | status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1], | |
718 | MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1, |
|
718 | MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1, | |
719 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
719 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
720 | if ( status_q_p1 != RTEMS_SUCCESSFUL ) { |
|
720 | if ( status_q_p1 != RTEMS_SUCCESSFUL ) { | |
721 | PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1) |
|
721 | PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1) | |
722 | } |
|
722 | } | |
723 |
|
723 | |||
724 | //***************************************************************************** |
|
724 | //***************************************************************************** | |
725 | // create the queue for handling averaged spectral matrices for processing @ f2 |
|
725 | // create the queue for handling averaged spectral matrices for processing @ f2 | |
726 | status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2], |
|
726 | status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2], | |
727 | MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2, |
|
727 | MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2, | |
728 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
728 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
729 | if ( status_q_p2 != RTEMS_SUCCESSFUL ) { |
|
729 | if ( status_q_p2 != RTEMS_SUCCESSFUL ) { | |
730 | PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2) |
|
730 | PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2) | |
731 | } |
|
731 | } | |
732 |
|
732 | |||
733 | if ( status_recv != RTEMS_SUCCESSFUL ) |
|
733 | if ( status_recv != RTEMS_SUCCESSFUL ) | |
734 | { |
|
734 | { | |
735 | ret = status_recv; |
|
735 | ret = status_recv; | |
736 | } |
|
736 | } | |
737 | else if( status_send != RTEMS_SUCCESSFUL ) |
|
737 | else if( status_send != RTEMS_SUCCESSFUL ) | |
738 | { |
|
738 | { | |
739 | ret = status_send; |
|
739 | ret = status_send; | |
740 | } |
|
740 | } | |
741 | else if( status_q_p0 != RTEMS_SUCCESSFUL ) |
|
741 | else if( status_q_p0 != RTEMS_SUCCESSFUL ) | |
742 | { |
|
742 | { | |
743 | ret = status_q_p0; |
|
743 | ret = status_q_p0; | |
744 | } |
|
744 | } | |
745 | else if( status_q_p1 != RTEMS_SUCCESSFUL ) |
|
745 | else if( status_q_p1 != RTEMS_SUCCESSFUL ) | |
746 | { |
|
746 | { | |
747 | ret = status_q_p1; |
|
747 | ret = status_q_p1; | |
748 | } |
|
748 | } | |
749 | else |
|
749 | else | |
750 | { |
|
750 | { | |
751 | ret = status_q_p2; |
|
751 | ret = status_q_p2; | |
752 | } |
|
752 | } | |
753 |
|
753 | |||
754 | return ret; |
|
754 | return ret; | |
755 | } |
|
755 | } | |
756 |
|
756 | |||
757 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ) |
|
757 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ) | |
758 | { |
|
758 | { | |
759 | rtems_status_code status; |
|
759 | rtems_status_code status; | |
760 | rtems_name queue_name; |
|
760 | rtems_name queue_name; | |
761 |
|
761 | |||
762 | queue_name = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
762 | queue_name = rtems_build_name( 'Q', '_', 'S', 'D' ); | |
763 |
|
763 | |||
764 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
764 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
765 |
|
765 | |||
766 | return status; |
|
766 | return status; | |
767 | } |
|
767 | } | |
768 |
|
768 | |||
769 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ) |
|
769 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ) | |
770 | { |
|
770 | { | |
771 | rtems_status_code status; |
|
771 | rtems_status_code status; | |
772 | rtems_name queue_name; |
|
772 | rtems_name queue_name; | |
773 |
|
773 | |||
774 | queue_name = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
774 | queue_name = rtems_build_name( 'Q', '_', 'R', 'V' ); | |
775 |
|
775 | |||
776 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
776 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
777 |
|
777 | |||
778 | return status; |
|
778 | return status; | |
779 | } |
|
779 | } | |
780 |
|
780 | |||
781 | rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id ) |
|
781 | rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id ) | |
782 | { |
|
782 | { | |
783 | rtems_status_code status; |
|
783 | rtems_status_code status; | |
784 | rtems_name queue_name; |
|
784 | rtems_name queue_name; | |
785 |
|
785 | |||
786 | queue_name = rtems_build_name( 'Q', '_', 'P', '0' ); |
|
786 | queue_name = rtems_build_name( 'Q', '_', 'P', '0' ); | |
787 |
|
787 | |||
788 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
788 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
789 |
|
789 | |||
790 | return status; |
|
790 | return status; | |
791 | } |
|
791 | } | |
792 |
|
792 | |||
793 | rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ) |
|
793 | rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ) | |
794 | { |
|
794 | { | |
795 | rtems_status_code status; |
|
795 | rtems_status_code status; | |
796 | rtems_name queue_name; |
|
796 | rtems_name queue_name; | |
797 |
|
797 | |||
798 | queue_name = rtems_build_name( 'Q', '_', 'P', '1' ); |
|
798 | queue_name = rtems_build_name( 'Q', '_', 'P', '1' ); | |
799 |
|
799 | |||
800 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
800 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
801 |
|
801 | |||
802 | return status; |
|
802 | return status; | |
803 | } |
|
803 | } | |
804 |
|
804 | |||
805 | rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ) |
|
805 | rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ) | |
806 | { |
|
806 | { | |
807 | rtems_status_code status; |
|
807 | rtems_status_code status; | |
808 | rtems_name queue_name; |
|
808 | rtems_name queue_name; | |
809 |
|
809 | |||
810 | queue_name = rtems_build_name( 'Q', '_', 'P', '2' ); |
|
810 | queue_name = rtems_build_name( 'Q', '_', 'P', '2' ); | |
811 |
|
811 | |||
812 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
812 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
813 |
|
813 | |||
814 | return status; |
|
814 | return status; | |
815 | } |
|
815 | } | |
816 |
|
816 | |||
817 | void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max ) |
|
817 | void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max ) | |
818 | { |
|
818 | { | |
819 | u_int32_t count; |
|
819 | u_int32_t count; | |
820 | rtems_status_code status; |
|
820 | rtems_status_code status; | |
821 |
|
821 | |||
822 | status = rtems_message_queue_get_number_pending( queue_id, &count ); |
|
822 | status = rtems_message_queue_get_number_pending( queue_id, &count ); | |
823 |
|
823 | |||
824 | count = count + 1; |
|
824 | count = count + 1; | |
825 |
|
825 | |||
826 | if (status != RTEMS_SUCCESSFUL) |
|
826 | if (status != RTEMS_SUCCESSFUL) | |
827 | { |
|
827 | { | |
828 | PRINTF1("in update_queue_max_count *** ERR = %d\n", status) |
|
828 | PRINTF1("in update_queue_max_count *** ERR = %d\n", status) | |
829 | } |
|
829 | } | |
830 | else |
|
830 | else | |
831 | { |
|
831 | { | |
832 | if (count > *fifo_size_max) |
|
832 | if (count > *fifo_size_max) | |
833 | { |
|
833 | { | |
834 | *fifo_size_max = count; |
|
834 | *fifo_size_max = count; | |
835 | } |
|
835 | } | |
836 | } |
|
836 | } | |
837 | } |
|
837 | } | |
838 |
|
838 | |||
839 | void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize ) |
|
839 | void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize ) | |
840 | { |
|
840 | { | |
841 | unsigned char i; |
|
841 | unsigned char i; | |
842 |
|
842 | |||
843 | //*************** |
|
843 | //*************** | |
844 | // BUFFER ADDRESS |
|
844 | // BUFFER ADDRESS | |
845 | for(i=0; i<nbNodes; i++) |
|
845 | for(i=0; i<nbNodes; i++) | |
846 | { |
|
846 | { | |
847 |
ring[i].coarseTime = 0x |
|
847 | ring[i].coarseTime = 0xffffffff; | |
848 |
ring[i].fineTime = 0x |
|
848 | ring[i].fineTime = 0xffffffff; | |
849 | ring[i].sid = 0x00; |
|
849 | ring[i].sid = 0x00; | |
850 | ring[i].status = 0x00; |
|
850 | ring[i].status = 0x00; | |
851 | ring[i].buffer_address = (int) &buffer[ i * bufferSize ]; |
|
851 | ring[i].buffer_address = (int) &buffer[ i * bufferSize ]; | |
852 | } |
|
852 | } | |
853 |
|
853 | |||
854 | //***** |
|
854 | //***** | |
855 | // NEXT |
|
855 | // NEXT | |
856 | ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ]; |
|
856 | ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ]; | |
857 | for(i=0; i<nbNodes-1; i++) |
|
857 | for(i=0; i<nbNodes-1; i++) | |
858 | { |
|
858 | { | |
859 | ring[i].next = (ring_node*) &ring[ i + 1 ]; |
|
859 | ring[i].next = (ring_node*) &ring[ i + 1 ]; | |
860 | } |
|
860 | } | |
861 |
|
861 | |||
862 | //********* |
|
862 | //********* | |
863 | // PREVIOUS |
|
863 | // PREVIOUS | |
864 | ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ]; |
|
864 | ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ]; | |
865 | for(i=1; i<nbNodes; i++) |
|
865 | for(i=1; i<nbNodes; i++) | |
866 | { |
|
866 | { | |
867 | ring[i].previous = (ring_node*) &ring[ i - 1 ]; |
|
867 | ring[i].previous = (ring_node*) &ring[ i - 1 ]; | |
868 | } |
|
868 | } | |
869 | } |
|
869 | } |
@@ -1,1370 +1,1372 | |||||
1 | /** Functions and tasks related to waveform packet generation. |
|
1 | /** Functions and tasks related to waveform packet generation. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle waveforms, in snapshot or continuous format.\n |
|
6 | * A group of functions to handle waveforms, in snapshot or continuous format.\n | |
7 | * |
|
7 | * | |
8 | */ |
|
8 | */ | |
9 |
|
9 | |||
10 | #include "wf_handler.h" |
|
10 | #include "wf_handler.h" | |
11 |
|
11 | |||
12 | //*************** |
|
12 | //*************** | |
13 | // waveform rings |
|
13 | // waveform rings | |
14 | // F0 |
|
14 | // F0 | |
15 | ring_node waveform_ring_f0[NB_RING_NODES_F0]; |
|
15 | ring_node waveform_ring_f0[NB_RING_NODES_F0]; | |
16 | ring_node *current_ring_node_f0; |
|
16 | ring_node *current_ring_node_f0; | |
17 | ring_node *ring_node_to_send_swf_f0; |
|
17 | ring_node *ring_node_to_send_swf_f0; | |
18 | // F1 |
|
18 | // F1 | |
19 | ring_node waveform_ring_f1[NB_RING_NODES_F1]; |
|
19 | ring_node waveform_ring_f1[NB_RING_NODES_F1]; | |
20 | ring_node *current_ring_node_f1; |
|
20 | ring_node *current_ring_node_f1; | |
21 | ring_node *ring_node_to_send_swf_f1; |
|
21 | ring_node *ring_node_to_send_swf_f1; | |
22 | ring_node *ring_node_to_send_cwf_f1; |
|
22 | ring_node *ring_node_to_send_cwf_f1; | |
23 | // F2 |
|
23 | // F2 | |
24 | ring_node waveform_ring_f2[NB_RING_NODES_F2]; |
|
24 | ring_node waveform_ring_f2[NB_RING_NODES_F2]; | |
25 | ring_node *current_ring_node_f2; |
|
25 | ring_node *current_ring_node_f2; | |
26 | ring_node *ring_node_to_send_swf_f2; |
|
26 | ring_node *ring_node_to_send_swf_f2; | |
27 | ring_node *ring_node_to_send_cwf_f2; |
|
27 | ring_node *ring_node_to_send_cwf_f2; | |
28 | // F3 |
|
28 | // F3 | |
29 | ring_node waveform_ring_f3[NB_RING_NODES_F3]; |
|
29 | ring_node waveform_ring_f3[NB_RING_NODES_F3]; | |
30 | ring_node *current_ring_node_f3; |
|
30 | ring_node *current_ring_node_f3; | |
31 | ring_node *ring_node_to_send_cwf_f3; |
|
31 | ring_node *ring_node_to_send_cwf_f3; | |
32 | char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK ]; |
|
32 | char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK ]; | |
33 |
|
33 | |||
34 | bool extractSWF = false; |
|
34 | bool extractSWF = false; | |
35 | bool swf_f0_ready = false; |
|
35 | bool swf_f0_ready = false; | |
36 | bool swf_f1_ready = false; |
|
36 | bool swf_f1_ready = false; | |
37 | bool swf_f2_ready = false; |
|
37 | bool swf_f2_ready = false; | |
38 |
|
38 | |||
39 | int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ]; |
|
39 | int wf_snap_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ]; | |
40 | ring_node ring_node_wf_snap_extracted; |
|
40 | ring_node ring_node_wf_snap_extracted; | |
41 |
|
41 | |||
42 | //********************* |
|
42 | //********************* | |
43 | // Interrupt SubRoutine |
|
43 | // Interrupt SubRoutine | |
44 |
|
44 | |||
45 | ring_node * getRingNodeToSendCWF( unsigned char frequencyChannel) |
|
45 | ring_node * getRingNodeToSendCWF( unsigned char frequencyChannel) | |
46 | { |
|
46 | { | |
47 | ring_node *node; |
|
47 | ring_node *node; | |
48 |
|
48 | |||
49 | node = NULL; |
|
49 | node = NULL; | |
50 | switch ( frequencyChannel ) { |
|
50 | switch ( frequencyChannel ) { | |
51 | case 1: |
|
51 | case 1: | |
52 | node = ring_node_to_send_cwf_f1; |
|
52 | node = ring_node_to_send_cwf_f1; | |
53 | break; |
|
53 | break; | |
54 | case 2: |
|
54 | case 2: | |
55 | node = ring_node_to_send_cwf_f2; |
|
55 | node = ring_node_to_send_cwf_f2; | |
56 | break; |
|
56 | break; | |
57 | case 3: |
|
57 | case 3: | |
58 | node = ring_node_to_send_cwf_f3; |
|
58 | node = ring_node_to_send_cwf_f3; | |
59 | break; |
|
59 | break; | |
60 | default: |
|
60 | default: | |
61 | break; |
|
61 | break; | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | return node; |
|
64 | return node; | |
65 | } |
|
65 | } | |
66 |
|
66 | |||
67 | ring_node * getRingNodeToSendSWF( unsigned char frequencyChannel) |
|
67 | ring_node * getRingNodeToSendSWF( unsigned char frequencyChannel) | |
68 | { |
|
68 | { | |
69 | ring_node *node; |
|
69 | ring_node *node; | |
70 |
|
70 | |||
71 | node = NULL; |
|
71 | node = NULL; | |
72 | switch ( frequencyChannel ) { |
|
72 | switch ( frequencyChannel ) { | |
73 | case 0: |
|
73 | case 0: | |
74 | node = ring_node_to_send_swf_f0; |
|
74 | node = ring_node_to_send_swf_f0; | |
75 | break; |
|
75 | break; | |
76 | case 1: |
|
76 | case 1: | |
77 | node = ring_node_to_send_swf_f1; |
|
77 | node = ring_node_to_send_swf_f1; | |
78 | break; |
|
78 | break; | |
79 | case 2: |
|
79 | case 2: | |
80 | node = ring_node_to_send_swf_f2; |
|
80 | node = ring_node_to_send_swf_f2; | |
81 | break; |
|
81 | break; | |
82 | default: |
|
82 | default: | |
83 | break; |
|
83 | break; | |
84 | } |
|
84 | } | |
85 |
|
85 | |||
86 | return node; |
|
86 | return node; | |
87 | } |
|
87 | } | |
88 |
|
88 | |||
89 | void reset_extractSWF( void ) |
|
89 | void reset_extractSWF( void ) | |
90 | { |
|
90 | { | |
91 | extractSWF = false; |
|
91 | extractSWF = false; | |
92 | swf_f0_ready = false; |
|
92 | swf_f0_ready = false; | |
93 | swf_f1_ready = false; |
|
93 | swf_f1_ready = false; | |
94 | swf_f2_ready = false; |
|
94 | swf_f2_ready = false; | |
95 | } |
|
95 | } | |
96 |
|
96 | |||
97 | inline void waveforms_isr_f3( void ) |
|
97 | inline void waveforms_isr_f3( void ) | |
98 | { |
|
98 | { | |
99 | rtems_status_code spare_status; |
|
99 | rtems_status_code spare_status; | |
100 |
|
100 | |||
101 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_BURST) // in BURST the data are used to place v, e1 and e2 in the HK packet |
|
101 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_BURST) // in BURST the data are used to place v, e1 and e2 in the HK packet | |
102 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
102 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
103 | { // in modes other than STANDBY and BURST, send the CWF_F3 data |
|
103 | { // in modes other than STANDBY and BURST, send the CWF_F3 data | |
104 | //*** |
|
104 | //*** | |
105 | // F3 |
|
105 | // F3 | |
106 | if ( (waveform_picker_regs->status & 0xc0) != 0x00 ) { // [1100 0000] check the f3 full bits |
|
106 | if ( (waveform_picker_regs->status & 0xc0) != 0x00 ) { // [1100 0000] check the f3 full bits | |
107 | ring_node_to_send_cwf_f3 = current_ring_node_f3->previous; |
|
107 | ring_node_to_send_cwf_f3 = current_ring_node_f3->previous; | |
108 | current_ring_node_f3 = current_ring_node_f3->next; |
|
108 | current_ring_node_f3 = current_ring_node_f3->next; | |
109 | if ((waveform_picker_regs->status & 0x40) == 0x40){ // [0100 0000] f3 buffer 0 is full |
|
109 | if ((waveform_picker_regs->status & 0x40) == 0x40){ // [0100 0000] f3 buffer 0 is full | |
110 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time; |
|
110 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time; | |
111 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time; |
|
111 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time; | |
112 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address; |
|
112 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address; | |
113 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00008840; // [1000 1000 0100 0000] |
|
113 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00008840; // [1000 1000 0100 0000] | |
114 | } |
|
114 | } | |
115 | else if ((waveform_picker_regs->status & 0x80) == 0x80){ // [1000 0000] f3 buffer 1 is full |
|
115 | else if ((waveform_picker_regs->status & 0x80) == 0x80){ // [1000 0000] f3 buffer 1 is full | |
116 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time; |
|
116 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time; | |
117 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time; |
|
117 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time; | |
118 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; |
|
118 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; | |
119 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00008880; // [1000 1000 1000 0000] |
|
119 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00008880; // [1000 1000 1000 0000] | |
120 | } |
|
120 | } | |
121 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
121 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
122 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); |
|
122 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); | |
123 | } |
|
123 | } | |
124 | } |
|
124 | } | |
125 | } |
|
125 | } | |
126 | } |
|
126 | } | |
127 |
|
127 | |||
128 | inline void waveforms_isr_normal( void ) |
|
128 | inline void waveforms_isr_normal( void ) | |
129 | { |
|
129 | { | |
130 | rtems_status_code status; |
|
130 | rtems_status_code status; | |
131 |
|
131 | |||
132 | if ( ( (waveform_picker_regs->status & 0x30) != 0x00 ) // [0011 0000] check the f2 full bits |
|
132 | if ( ( (waveform_picker_regs->status & 0x30) != 0x00 ) // [0011 0000] check the f2 full bits | |
133 | && ( (waveform_picker_regs->status & 0x0c) != 0x00 ) // [0000 1100] check the f1 full bits |
|
133 | && ( (waveform_picker_regs->status & 0x0c) != 0x00 ) // [0000 1100] check the f1 full bits | |
134 | && ( (waveform_picker_regs->status & 0x03) != 0x00 )) // [0000 0011] check the f0 full bits |
|
134 | && ( (waveform_picker_regs->status & 0x03) != 0x00 )) // [0000 0011] check the f0 full bits | |
135 | { |
|
135 | { | |
136 | //*** |
|
136 | //*** | |
137 | // F0 |
|
137 | // F0 | |
138 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; |
|
138 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; | |
139 | current_ring_node_f0 = current_ring_node_f0->next; |
|
139 | current_ring_node_f0 = current_ring_node_f0->next; | |
140 | if ( (waveform_picker_regs->status & 0x01) == 0x01) |
|
140 | if ( (waveform_picker_regs->status & 0x01) == 0x01) | |
141 | { |
|
141 | { | |
142 |
|
142 | |||
143 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; |
|
143 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; | |
144 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; |
|
144 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; | |
145 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; |
|
145 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; | |
146 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001] |
|
146 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001] | |
147 | } |
|
147 | } | |
148 | else if ( (waveform_picker_regs->status & 0x02) == 0x02) |
|
148 | else if ( (waveform_picker_regs->status & 0x02) == 0x02) | |
149 | { |
|
149 | { | |
150 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; |
|
150 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; | |
151 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; |
|
151 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; | |
152 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; |
|
152 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; | |
153 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010] |
|
153 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010] | |
154 | } |
|
154 | } | |
155 |
|
155 | |||
156 | //*** |
|
156 | //*** | |
157 | // F1 |
|
157 | // F1 | |
158 | ring_node_to_send_swf_f1 = current_ring_node_f1->previous; |
|
158 | ring_node_to_send_swf_f1 = current_ring_node_f1->previous; | |
159 | current_ring_node_f1 = current_ring_node_f1->next; |
|
159 | current_ring_node_f1 = current_ring_node_f1->next; | |
160 | if ( (waveform_picker_regs->status & 0x04) == 0x04) |
|
160 | if ( (waveform_picker_regs->status & 0x04) == 0x04) | |
161 | { |
|
161 | { | |
162 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; |
|
162 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; | |
163 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; |
|
163 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; | |
164 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; |
|
164 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; | |
165 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0 |
|
165 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0 | |
166 | } |
|
166 | } | |
167 | else if ( (waveform_picker_regs->status & 0x08) == 0x08) |
|
167 | else if ( (waveform_picker_regs->status & 0x08) == 0x08) | |
168 | { |
|
168 | { | |
169 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; |
|
169 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; | |
170 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; |
|
170 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; | |
171 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; |
|
171 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; | |
172 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0 |
|
172 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0 | |
173 | } |
|
173 | } | |
174 |
|
174 | |||
175 | //*** |
|
175 | //*** | |
176 | // F2 |
|
176 | // F2 | |
177 | ring_node_to_send_swf_f2 = current_ring_node_f2->previous; |
|
177 | ring_node_to_send_swf_f2 = current_ring_node_f2->previous; | |
178 | current_ring_node_f2 = current_ring_node_f2->next; |
|
178 | current_ring_node_f2 = current_ring_node_f2->next; | |
179 | if ( (waveform_picker_regs->status & 0x10) == 0x10) |
|
179 | if ( (waveform_picker_regs->status & 0x10) == 0x10) | |
180 | { |
|
180 | { | |
181 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; |
|
181 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; | |
182 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; |
|
182 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; | |
183 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; |
|
183 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; | |
184 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] |
|
184 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] | |
185 | } |
|
185 | } | |
186 | else if ( (waveform_picker_regs->status & 0x20) == 0x20) |
|
186 | else if ( (waveform_picker_regs->status & 0x20) == 0x20) | |
187 | { |
|
187 | { | |
188 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; |
|
188 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; | |
189 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; |
|
189 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; | |
190 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; |
|
190 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; | |
191 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] |
|
191 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] | |
192 | } |
|
192 | } | |
193 | // |
|
193 | // | |
194 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ); |
|
194 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ); | |
195 | if ( status != RTEMS_SUCCESSFUL) |
|
195 | if ( status != RTEMS_SUCCESSFUL) | |
196 | { |
|
196 | { | |
197 | status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); |
|
197 | status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); | |
198 | } |
|
198 | } | |
199 | } |
|
199 | } | |
200 | } |
|
200 | } | |
201 |
|
201 | |||
202 | inline void waveforms_isr_burst( void ) |
|
202 | inline void waveforms_isr_burst( void ) | |
203 | { |
|
203 | { | |
204 | unsigned char status; |
|
204 | unsigned char status; | |
205 | rtems_status_code spare_status; |
|
205 | rtems_status_code spare_status; | |
206 |
|
206 | |||
207 | status = (waveform_picker_regs->status & 0x30) >> 4; // [0011 0000] get the status bits for f2 |
|
207 | status = (waveform_picker_regs->status & 0x30) >> 4; // [0011 0000] get the status bits for f2 | |
208 |
|
208 | |||
209 |
|
209 | |||
210 | switch(status) |
|
210 | switch(status) | |
211 | { |
|
211 | { | |
212 | case 1: |
|
212 | case 1: | |
213 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; |
|
213 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; | |
214 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; |
|
214 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; | |
215 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; |
|
215 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; | |
216 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; |
|
216 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; | |
217 | current_ring_node_f2 = current_ring_node_f2->next; |
|
217 | current_ring_node_f2 = current_ring_node_f2->next; | |
218 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; |
|
218 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; | |
219 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { |
|
219 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { | |
220 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); |
|
220 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); | |
221 | } |
|
221 | } | |
222 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] |
|
222 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] | |
223 | break; |
|
223 | break; | |
224 | case 2: |
|
224 | case 2: | |
225 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; |
|
225 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; | |
226 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; |
|
226 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; | |
227 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; |
|
227 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; | |
228 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; |
|
228 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; | |
229 | current_ring_node_f2 = current_ring_node_f2->next; |
|
229 | current_ring_node_f2 = current_ring_node_f2->next; | |
230 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; |
|
230 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; | |
231 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { |
|
231 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { | |
232 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); |
|
232 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); | |
233 | } |
|
233 | } | |
234 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] |
|
234 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] | |
235 | break; |
|
235 | break; | |
236 | default: |
|
236 | default: | |
237 | break; |
|
237 | break; | |
238 | } |
|
238 | } | |
239 | } |
|
239 | } | |
240 |
|
240 | |||
241 | inline void waveforms_isr_sbm1( void ) |
|
241 | inline void waveforms_isr_sbm1( void ) | |
242 | { |
|
242 | { | |
243 | rtems_status_code status; |
|
243 | rtems_status_code status; | |
244 |
|
244 | |||
245 | //*** |
|
245 | //*** | |
246 | // F1 |
|
246 | // F1 | |
247 | if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bits |
|
247 | if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bits | |
248 | // (1) change the receiving buffer for the waveform picker |
|
248 | // (1) change the receiving buffer for the waveform picker | |
249 | ring_node_to_send_cwf_f1 = current_ring_node_f1->previous; |
|
249 | ring_node_to_send_cwf_f1 = current_ring_node_f1->previous; | |
250 | current_ring_node_f1 = current_ring_node_f1->next; |
|
250 | current_ring_node_f1 = current_ring_node_f1->next; | |
251 | if ( (waveform_picker_regs->status & 0x04) == 0x04) |
|
251 | if ( (waveform_picker_regs->status & 0x04) == 0x04) | |
252 | { |
|
252 | { | |
253 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; |
|
253 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; | |
254 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; |
|
254 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; | |
255 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; |
|
255 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; | |
256 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0 |
|
256 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0 | |
257 | } |
|
257 | } | |
258 | else if ( (waveform_picker_regs->status & 0x08) == 0x08) |
|
258 | else if ( (waveform_picker_regs->status & 0x08) == 0x08) | |
259 | { |
|
259 | { | |
260 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; |
|
260 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; | |
261 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; |
|
261 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; | |
262 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; |
|
262 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; | |
263 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0 |
|
263 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0 | |
264 | } |
|
264 | } | |
265 | // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed) |
|
265 | // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed) | |
266 | status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ); |
|
266 | status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ); | |
267 | } |
|
267 | } | |
268 |
|
268 | |||
269 | //*** |
|
269 | //*** | |
270 | // F0 |
|
270 | // F0 | |
271 | if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] check the f0 full bits |
|
271 | if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] check the f0 full bits | |
272 | swf_f0_ready = true; |
|
272 | swf_f0_ready = true; | |
273 | // change f0 buffer |
|
273 | // change f0 buffer | |
274 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; |
|
274 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; | |
275 | current_ring_node_f0 = current_ring_node_f0->next; |
|
275 | current_ring_node_f0 = current_ring_node_f0->next; | |
276 | if ( (waveform_picker_regs->status & 0x01) == 0x01) |
|
276 | if ( (waveform_picker_regs->status & 0x01) == 0x01) | |
277 | { |
|
277 | { | |
278 |
|
278 | |||
279 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; |
|
279 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; | |
280 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; |
|
280 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; | |
281 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; |
|
281 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; | |
282 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001] |
|
282 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001] | |
283 | } |
|
283 | } | |
284 | else if ( (waveform_picker_regs->status & 0x02) == 0x02) |
|
284 | else if ( (waveform_picker_regs->status & 0x02) == 0x02) | |
285 | { |
|
285 | { | |
286 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; |
|
286 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; | |
287 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; |
|
287 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; | |
288 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; |
|
288 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; | |
289 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010] |
|
289 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010] | |
290 | } |
|
290 | } | |
291 | } |
|
291 | } | |
292 |
|
292 | |||
293 | //*** |
|
293 | //*** | |
294 | // F2 |
|
294 | // F2 | |
295 | if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bits |
|
295 | if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bits | |
296 | swf_f2_ready = true; |
|
296 | swf_f2_ready = true; | |
297 | // change f2 buffer |
|
297 | // change f2 buffer | |
298 | ring_node_to_send_swf_f2 = current_ring_node_f2->previous; |
|
298 | ring_node_to_send_swf_f2 = current_ring_node_f2->previous; | |
299 | current_ring_node_f2 = current_ring_node_f2->next; |
|
299 | current_ring_node_f2 = current_ring_node_f2->next; | |
300 | if ( (waveform_picker_regs->status & 0x10) == 0x10) |
|
300 | if ( (waveform_picker_regs->status & 0x10) == 0x10) | |
301 | { |
|
301 | { | |
302 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; |
|
302 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; | |
303 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; |
|
303 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; | |
304 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; |
|
304 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; | |
305 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] |
|
305 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] | |
306 | } |
|
306 | } | |
307 | else if ( (waveform_picker_regs->status & 0x20) == 0x20) |
|
307 | else if ( (waveform_picker_regs->status & 0x20) == 0x20) | |
308 | { |
|
308 | { | |
309 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; |
|
309 | ring_node_to_send_swf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; | |
310 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; |
|
310 | ring_node_to_send_swf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; | |
311 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; |
|
311 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; | |
312 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] |
|
312 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] | |
313 | } |
|
313 | } | |
314 | } |
|
314 | } | |
315 | } |
|
315 | } | |
316 |
|
316 | |||
317 | inline void waveforms_isr_sbm2( void ) |
|
317 | inline void waveforms_isr_sbm2( void ) | |
318 | { |
|
318 | { | |
319 | rtems_status_code status; |
|
319 | rtems_status_code status; | |
320 |
|
320 | |||
321 | //*** |
|
321 | //*** | |
322 | // F2 |
|
322 | // F2 | |
323 | if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bit |
|
323 | if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bit | |
324 | // (1) change the receiving buffer for the waveform picker |
|
324 | // (1) change the receiving buffer for the waveform picker | |
325 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; |
|
325 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; | |
326 | ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2; |
|
326 | ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2; | |
327 | current_ring_node_f2 = current_ring_node_f2->next; |
|
327 | current_ring_node_f2 = current_ring_node_f2->next; | |
328 | if ( (waveform_picker_regs->status & 0x10) == 0x10) |
|
328 | if ( (waveform_picker_regs->status & 0x10) == 0x10) | |
329 | { |
|
329 | { | |
330 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; |
|
330 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; | |
331 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; |
|
331 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; | |
332 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; |
|
332 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; | |
333 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] |
|
333 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] | |
334 | } |
|
334 | } | |
335 | else if ( (waveform_picker_regs->status & 0x20) == 0x20) |
|
335 | else if ( (waveform_picker_regs->status & 0x20) == 0x20) | |
336 | { |
|
336 | { | |
337 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; |
|
337 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; | |
338 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; |
|
338 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; | |
339 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; |
|
339 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; | |
340 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] |
|
340 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] | |
341 | } |
|
341 | } | |
342 | // (2) send an event for the waveforms transmission |
|
342 | // (2) send an event for the waveforms transmission | |
343 | status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ); |
|
343 | status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ); | |
344 | } |
|
344 | } | |
345 |
|
345 | |||
346 | //*** |
|
346 | //*** | |
347 | // F0 |
|
347 | // F0 | |
348 | if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] check the f0 full bit |
|
348 | if ( (waveform_picker_regs->status & 0x03) != 0x00 ) { // [0000 0011] check the f0 full bit | |
349 | swf_f0_ready = true; |
|
349 | swf_f0_ready = true; | |
350 | // change f0 buffer |
|
350 | // change f0 buffer | |
351 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; |
|
351 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; | |
352 | current_ring_node_f0 = current_ring_node_f0->next; |
|
352 | current_ring_node_f0 = current_ring_node_f0->next; | |
353 | if ( (waveform_picker_regs->status & 0x01) == 0x01) |
|
353 | if ( (waveform_picker_regs->status & 0x01) == 0x01) | |
354 | { |
|
354 | { | |
355 |
|
355 | |||
356 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; |
|
356 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; | |
357 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; |
|
357 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; | |
358 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; |
|
358 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; | |
359 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001] |
|
359 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001] | |
360 | } |
|
360 | } | |
361 | else if ( (waveform_picker_regs->status & 0x02) == 0x02) |
|
361 | else if ( (waveform_picker_regs->status & 0x02) == 0x02) | |
362 | { |
|
362 | { | |
363 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; |
|
363 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; | |
364 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; |
|
364 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; | |
365 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; |
|
365 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; | |
366 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010] |
|
366 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010] | |
367 | } |
|
367 | } | |
368 | } |
|
368 | } | |
369 |
|
369 | |||
370 | //*** |
|
370 | //*** | |
371 | // F1 |
|
371 | // F1 | |
372 | if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bit |
|
372 | if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bit | |
373 | swf_f1_ready = true; |
|
373 | swf_f1_ready = true; | |
374 | ring_node_to_send_swf_f1 = current_ring_node_f1->previous; |
|
374 | ring_node_to_send_swf_f1 = current_ring_node_f1->previous; | |
375 | current_ring_node_f1 = current_ring_node_f1->next; |
|
375 | current_ring_node_f1 = current_ring_node_f1->next; | |
376 | if ( (waveform_picker_regs->status & 0x04) == 0x04) |
|
376 | if ( (waveform_picker_regs->status & 0x04) == 0x04) | |
377 | { |
|
377 | { | |
378 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; |
|
378 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; | |
379 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; |
|
379 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; | |
380 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; |
|
380 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; | |
381 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0 |
|
381 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0 | |
382 | } |
|
382 | } | |
383 | else if ( (waveform_picker_regs->status & 0x08) == 0x08) |
|
383 | else if ( (waveform_picker_regs->status & 0x08) == 0x08) | |
384 | { |
|
384 | { | |
385 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; |
|
385 | ring_node_to_send_swf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; | |
386 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; |
|
386 | ring_node_to_send_swf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; | |
387 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; |
|
387 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; | |
388 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0 |
|
388 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0 | |
389 | } |
|
389 | } | |
390 | } |
|
390 | } | |
391 | } |
|
391 | } | |
392 |
|
392 | |||
393 | rtems_isr waveforms_isr( rtems_vector_number vector ) |
|
393 | rtems_isr waveforms_isr( rtems_vector_number vector ) | |
394 | { |
|
394 | { | |
395 | /** This is the interrupt sub routine called by the waveform picker core. |
|
395 | /** This is the interrupt sub routine called by the waveform picker core. | |
396 | * |
|
396 | * | |
397 | * This ISR launch different actions depending mainly on two pieces of information: |
|
397 | * This ISR launch different actions depending mainly on two pieces of information: | |
398 | * 1. the values read in the registers of the waveform picker. |
|
398 | * 1. the values read in the registers of the waveform picker. | |
399 | * 2. the current LFR mode. |
|
399 | * 2. the current LFR mode. | |
400 | * |
|
400 | * | |
401 | */ |
|
401 | */ | |
402 |
|
402 | |||
403 | // STATUS |
|
403 | // STATUS | |
404 | // new error error buffer full |
|
404 | // new error error buffer full | |
405 | // 15 14 13 12 11 10 9 8 |
|
405 | // 15 14 13 12 11 10 9 8 | |
406 | // f3 f2 f1 f0 f3 f2 f1 f0 |
|
406 | // f3 f2 f1 f0 f3 f2 f1 f0 | |
407 | // |
|
407 | // | |
408 | // ready buffer |
|
408 | // ready buffer | |
409 | // 7 6 5 4 3 2 1 0 |
|
409 | // 7 6 5 4 3 2 1 0 | |
410 | // f3_1 f3_0 f2_1 f2_0 f1_1 f1_0 f0_1 f0_0 |
|
410 | // f3_1 f3_0 f2_1 f2_0 f1_1 f1_0 f0_1 f0_0 | |
411 |
|
411 | |||
412 | rtems_status_code spare_status; |
|
412 | rtems_status_code spare_status; | |
413 |
|
413 | |||
414 | waveforms_isr_f3(); |
|
414 | waveforms_isr_f3(); | |
415 |
|
415 | |||
416 | if ( (waveform_picker_regs->status & 0xff00) != 0x00) // [1111 1111 0000 0000] check the error bits |
|
416 | if ( (waveform_picker_regs->status & 0xff00) != 0x00) // [1111 1111 0000 0000] check the error bits | |
417 | { |
|
417 | { | |
418 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 ); |
|
418 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 ); | |
419 | } |
|
419 | } | |
420 |
|
420 | |||
421 | switch(lfrCurrentMode) |
|
421 | switch(lfrCurrentMode) | |
422 | { |
|
422 | { | |
423 | //******** |
|
423 | //******** | |
424 | // STANDBY |
|
424 | // STANDBY | |
425 | case(LFR_MODE_STANDBY): |
|
425 | case(LFR_MODE_STANDBY): | |
426 | break; |
|
426 | break; | |
427 |
|
427 | |||
428 | //****** |
|
428 | //****** | |
429 | // NORMAL |
|
429 | // NORMAL | |
430 | case(LFR_MODE_NORMAL): |
|
430 | case(LFR_MODE_NORMAL): | |
431 | waveforms_isr_normal(); |
|
431 | waveforms_isr_normal(); | |
432 | break; |
|
432 | break; | |
433 |
|
433 | |||
434 | //****** |
|
434 | //****** | |
435 | // BURST |
|
435 | // BURST | |
436 | case(LFR_MODE_BURST): |
|
436 | case(LFR_MODE_BURST): | |
437 | waveforms_isr_burst(); |
|
437 | waveforms_isr_burst(); | |
438 | break; |
|
438 | break; | |
439 |
|
439 | |||
440 | //***** |
|
440 | //***** | |
441 | // SBM1 |
|
441 | // SBM1 | |
442 | case(LFR_MODE_SBM1): |
|
442 | case(LFR_MODE_SBM1): | |
443 | waveforms_isr_sbm1(); |
|
443 | waveforms_isr_sbm1(); | |
444 | break; |
|
444 | break; | |
445 |
|
445 | |||
446 | //***** |
|
446 | //***** | |
447 | // SBM2 |
|
447 | // SBM2 | |
448 | case(LFR_MODE_SBM2): |
|
448 | case(LFR_MODE_SBM2): | |
449 | waveforms_isr_sbm2(); |
|
449 | waveforms_isr_sbm2(); | |
450 | break; |
|
450 | break; | |
451 |
|
451 | |||
452 | //******** |
|
452 | //******** | |
453 | // DEFAULT |
|
453 | // DEFAULT | |
454 | default: |
|
454 | default: | |
455 | break; |
|
455 | break; | |
456 | } |
|
456 | } | |
457 | } |
|
457 | } | |
458 |
|
458 | |||
459 | //************ |
|
459 | //************ | |
460 | // RTEMS TASKS |
|
460 | // RTEMS TASKS | |
461 |
|
461 | |||
462 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
462 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP | |
463 | { |
|
463 | { | |
464 | /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode. |
|
464 | /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode. | |
465 | * |
|
465 | * | |
466 | * @param unused is the starting argument of the RTEMS task |
|
466 | * @param unused is the starting argument of the RTEMS task | |
467 | * |
|
467 | * | |
468 | * The following data packets are sent by this task: |
|
468 | * The following data packets are sent by this task: | |
469 | * - TM_LFR_SCIENCE_NORMAL_SWF_F0 |
|
469 | * - TM_LFR_SCIENCE_NORMAL_SWF_F0 | |
470 | * - TM_LFR_SCIENCE_NORMAL_SWF_F1 |
|
470 | * - TM_LFR_SCIENCE_NORMAL_SWF_F1 | |
471 | * - TM_LFR_SCIENCE_NORMAL_SWF_F2 |
|
471 | * - TM_LFR_SCIENCE_NORMAL_SWF_F2 | |
472 | * |
|
472 | * | |
473 | */ |
|
473 | */ | |
474 |
|
474 | |||
475 | rtems_event_set event_out; |
|
475 | rtems_event_set event_out; | |
476 | rtems_id queue_id; |
|
476 | rtems_id queue_id; | |
477 | rtems_status_code status; |
|
477 | rtems_status_code status; | |
478 | bool resynchronisationEngaged; |
|
478 | bool resynchronisationEngaged; | |
479 | ring_node *ring_node_wf_snap_extracted_ptr; |
|
479 | ring_node *ring_node_wf_snap_extracted_ptr; | |
480 |
|
480 | |||
481 | ring_node_wf_snap_extracted_ptr = (ring_node *) &ring_node_wf_snap_extracted; |
|
481 | ring_node_wf_snap_extracted_ptr = (ring_node *) &ring_node_wf_snap_extracted; | |
482 |
|
482 | |||
483 | resynchronisationEngaged = false; |
|
483 | resynchronisationEngaged = false; | |
484 |
|
484 | |||
485 | status = get_message_queue_id_send( &queue_id ); |
|
485 | status = get_message_queue_id_send( &queue_id ); | |
486 | if (status != RTEMS_SUCCESSFUL) |
|
486 | if (status != RTEMS_SUCCESSFUL) | |
487 | { |
|
487 | { | |
488 | PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status) |
|
488 | PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status) | |
489 | } |
|
489 | } | |
490 |
|
490 | |||
491 | BOOT_PRINTF("in WFRM ***\n") |
|
491 | BOOT_PRINTF("in WFRM ***\n") | |
492 |
|
492 | |||
493 | while(1){ |
|
493 | while(1){ | |
494 | // wait for an RTEMS_EVENT |
|
494 | // wait for an RTEMS_EVENT | |
495 | rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1 |
|
495 | rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1 | |
496 | | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM, |
|
496 | | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM, | |
497 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
497 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
498 | if(resynchronisationEngaged == false) |
|
498 | if(resynchronisationEngaged == false) | |
499 | { // engage resynchronisation |
|
499 | { // engage resynchronisation | |
500 | snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); |
|
500 | snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); | |
501 | resynchronisationEngaged = true; |
|
501 | resynchronisationEngaged = true; | |
502 | } |
|
502 | } | |
503 | else |
|
503 | else | |
504 | { // reset delta_snapshot to the nominal value |
|
504 | { // reset delta_snapshot to the nominal value | |
505 | PRINTF("no resynchronisation, reset delta_snapshot to the nominal value\n") |
|
505 | PRINTF("no resynchronisation, reset delta_snapshot to the nominal value\n") | |
506 | set_wfp_delta_snapshot(); |
|
506 | set_wfp_delta_snapshot(); | |
507 | resynchronisationEngaged = false; |
|
507 | resynchronisationEngaged = false; | |
508 | } |
|
508 | } | |
509 | // |
|
509 | // | |
510 |
|
510 | |||
511 | if (event_out == RTEMS_EVENT_MODE_NORMAL) |
|
511 | if (event_out == RTEMS_EVENT_MODE_NORMAL) | |
512 | { |
|
512 | { | |
513 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n") |
|
513 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_NORMAL\n") | |
514 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; |
|
514 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; | |
515 | ring_node_to_send_swf_f1->sid = SID_NORM_SWF_F1; |
|
515 | ring_node_to_send_swf_f1->sid = SID_NORM_SWF_F1; | |
516 | ring_node_to_send_swf_f2->sid = SID_NORM_SWF_F2; |
|
516 | ring_node_to_send_swf_f2->sid = SID_NORM_SWF_F2; | |
517 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); |
|
517 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); | |
518 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f1, sizeof( ring_node* ) ); |
|
518 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f1, sizeof( ring_node* ) ); | |
519 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f2, sizeof( ring_node* ) ); |
|
519 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f2, sizeof( ring_node* ) ); | |
520 | } |
|
520 | } | |
521 | if (event_out == RTEMS_EVENT_MODE_SBM1) |
|
521 | if (event_out == RTEMS_EVENT_MODE_SBM1) | |
522 | { |
|
522 | { | |
523 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n") |
|
523 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM1\n") | |
524 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; |
|
524 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; | |
525 | ring_node_wf_snap_extracted_ptr->sid = SID_NORM_SWF_F1; |
|
525 | ring_node_wf_snap_extracted_ptr->sid = SID_NORM_SWF_F1; | |
526 | ring_node_to_send_swf_f2->sid = SID_NORM_SWF_F2; |
|
526 | ring_node_to_send_swf_f2->sid = SID_NORM_SWF_F2; | |
527 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); |
|
527 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); | |
528 | status = rtems_message_queue_send( queue_id, &ring_node_wf_snap_extracted_ptr, sizeof( ring_node* ) ); |
|
528 | status = rtems_message_queue_send( queue_id, &ring_node_wf_snap_extracted_ptr, sizeof( ring_node* ) ); | |
529 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f2, sizeof( ring_node* ) ); |
|
529 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f2, sizeof( ring_node* ) ); | |
530 | } |
|
530 | } | |
531 | if (event_out == RTEMS_EVENT_MODE_SBM2) |
|
531 | if (event_out == RTEMS_EVENT_MODE_SBM2) | |
532 | { |
|
532 | { | |
533 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n") |
|
533 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n") | |
534 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; |
|
534 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; | |
535 | ring_node_to_send_swf_f1->sid = SID_NORM_SWF_F1; |
|
535 | ring_node_to_send_swf_f1->sid = SID_NORM_SWF_F1; | |
536 | ring_node_wf_snap_extracted_ptr->sid = SID_NORM_SWF_F2; |
|
536 | ring_node_wf_snap_extracted_ptr->sid = SID_NORM_SWF_F2; | |
537 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); |
|
537 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); | |
538 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f1, sizeof( ring_node* ) ); |
|
538 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f1, sizeof( ring_node* ) ); | |
539 | status = rtems_message_queue_send( queue_id, &ring_node_wf_snap_extracted_ptr, sizeof( ring_node* ) ); |
|
539 | status = rtems_message_queue_send( queue_id, &ring_node_wf_snap_extracted_ptr, sizeof( ring_node* ) ); | |
540 | } |
|
540 | } | |
541 | } |
|
541 | } | |
542 | } |
|
542 | } | |
543 |
|
543 | |||
544 | rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
544 | rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP | |
545 | { |
|
545 | { | |
546 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3. |
|
546 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3. | |
547 | * |
|
547 | * | |
548 | * @param unused is the starting argument of the RTEMS task |
|
548 | * @param unused is the starting argument of the RTEMS task | |
549 | * |
|
549 | * | |
550 | * The following data packet is sent by this task: |
|
550 | * The following data packet is sent by this task: | |
551 | * - TM_LFR_SCIENCE_NORMAL_CWF_F3 |
|
551 | * - TM_LFR_SCIENCE_NORMAL_CWF_F3 | |
552 | * |
|
552 | * | |
553 | */ |
|
553 | */ | |
554 |
|
554 | |||
555 | rtems_event_set event_out; |
|
555 | rtems_event_set event_out; | |
556 | rtems_id queue_id; |
|
556 | rtems_id queue_id; | |
557 | rtems_status_code status; |
|
557 | rtems_status_code status; | |
558 | ring_node ring_node_cwf3_light; |
|
558 | ring_node ring_node_cwf3_light; | |
|
559 | ring_node *ring_node_to_send_cwf; | |||
559 |
|
560 | |||
560 | status = get_message_queue_id_send( &queue_id ); |
|
561 | status = get_message_queue_id_send( &queue_id ); | |
561 | if (status != RTEMS_SUCCESSFUL) |
|
562 | if (status != RTEMS_SUCCESSFUL) | |
562 | { |
|
563 | { | |
563 | PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status) |
|
564 | PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status) | |
564 | } |
|
565 | } | |
565 |
|
566 | |||
566 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; |
|
567 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; | |
567 |
|
568 | |||
568 | // init the ring_node_cwf3_light structure |
|
569 | // init the ring_node_cwf3_light structure | |
569 | ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light; |
|
570 | ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light; | |
570 | ring_node_cwf3_light.coarseTime = 0x00; |
|
571 | ring_node_cwf3_light.coarseTime = 0x00; | |
571 | ring_node_cwf3_light.fineTime = 0x00; |
|
572 | ring_node_cwf3_light.fineTime = 0x00; | |
572 | ring_node_cwf3_light.next = NULL; |
|
573 | ring_node_cwf3_light.next = NULL; | |
573 | ring_node_cwf3_light.previous = NULL; |
|
574 | ring_node_cwf3_light.previous = NULL; | |
574 | ring_node_cwf3_light.sid = SID_NORM_CWF_F3; |
|
575 | ring_node_cwf3_light.sid = SID_NORM_CWF_F3; | |
575 | ring_node_cwf3_light.status = 0x00; |
|
576 | ring_node_cwf3_light.status = 0x00; | |
576 |
|
577 | |||
577 | BOOT_PRINTF("in CWF3 ***\n") |
|
578 | BOOT_PRINTF("in CWF3 ***\n") | |
578 |
|
579 | |||
579 | while(1){ |
|
580 | while(1){ | |
580 | // wait for an RTEMS_EVENT |
|
581 | // wait for an RTEMS_EVENT | |
581 | rtems_event_receive( RTEMS_EVENT_0, |
|
582 | rtems_event_receive( RTEMS_EVENT_0, | |
582 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
583 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
583 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
584 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
584 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) ) |
|
585 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) ) | |
585 | { |
|
586 | { | |
|
587 | ring_node_to_send_cwf = getRingNodeToSendCWF( 3 ); | |||
586 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) |
|
588 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) | |
587 | { |
|
589 | { | |
588 | PRINTF("send CWF_LONG_F3\n") |
|
590 | PRINTF("send CWF_LONG_F3\n") | |
589 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; |
|
591 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; | |
590 |
status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf |
|
592 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); | |
591 | } |
|
593 | } | |
592 | else |
|
594 | else | |
593 | { |
|
595 | { | |
594 | PRINTF("send CWF_F3 (light)\n") |
|
596 | PRINTF("send CWF_F3 (light)\n") | |
595 |
send_waveform_CWF3_light( ring_node_to_send_cwf |
|
597 | send_waveform_CWF3_light( ring_node_to_send_cwf, &ring_node_cwf3_light, queue_id ); | |
596 | } |
|
598 | } | |
597 |
|
599 | |||
598 | } |
|
600 | } | |
599 | else |
|
601 | else | |
600 | { |
|
602 | { | |
601 | PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode) |
|
603 | PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode) | |
602 | } |
|
604 | } | |
603 | } |
|
605 | } | |
604 | } |
|
606 | } | |
605 |
|
607 | |||
606 | rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2 |
|
608 | rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2 | |
607 | { |
|
609 | { | |
608 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2. |
|
610 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2. | |
609 | * |
|
611 | * | |
610 | * @param unused is the starting argument of the RTEMS task |
|
612 | * @param unused is the starting argument of the RTEMS task | |
611 | * |
|
613 | * | |
612 | * The following data packet is sent by this function: |
|
614 | * The following data packet is sent by this function: | |
613 | * - TM_LFR_SCIENCE_BURST_CWF_F2 |
|
615 | * - TM_LFR_SCIENCE_BURST_CWF_F2 | |
614 | * - TM_LFR_SCIENCE_SBM2_CWF_F2 |
|
616 | * - TM_LFR_SCIENCE_SBM2_CWF_F2 | |
615 | * |
|
617 | * | |
616 | */ |
|
618 | */ | |
617 |
|
619 | |||
618 | rtems_event_set event_out; |
|
620 | rtems_event_set event_out; | |
619 | rtems_id queue_id; |
|
621 | rtems_id queue_id; | |
620 | rtems_status_code status; |
|
622 | rtems_status_code status; | |
621 | ring_node *ring_node_to_send; |
|
623 | ring_node *ring_node_to_send; | |
622 | unsigned long long int acquisitionTimeF0_asLong; |
|
624 | unsigned long long int acquisitionTimeF0_asLong; | |
623 |
|
625 | |||
624 | acquisitionTimeF0_asLong = 0x00; |
|
626 | acquisitionTimeF0_asLong = 0x00; | |
625 |
|
627 | |||
626 | status = get_message_queue_id_send( &queue_id ); |
|
628 | status = get_message_queue_id_send( &queue_id ); | |
627 | if (status != RTEMS_SUCCESSFUL) |
|
629 | if (status != RTEMS_SUCCESSFUL) | |
628 | { |
|
630 | { | |
629 | PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status) |
|
631 | PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status) | |
630 | } |
|
632 | } | |
631 |
|
633 | |||
632 | BOOT_PRINTF("in CWF2 ***\n") |
|
634 | BOOT_PRINTF("in CWF2 ***\n") | |
633 |
|
635 | |||
634 | while(1){ |
|
636 | while(1){ | |
635 | // wait for an RTEMS_EVENT |
|
637 | // wait for an RTEMS_EVENT | |
636 | rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2, |
|
638 | rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2, | |
637 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
639 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
638 | ring_node_to_send = getRingNodeToSendCWF( 2 ); |
|
640 | ring_node_to_send = getRingNodeToSendCWF( 2 ); | |
639 | if (event_out == RTEMS_EVENT_MODE_BURST) |
|
641 | if (event_out == RTEMS_EVENT_MODE_BURST) | |
640 | { |
|
642 | { | |
641 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); |
|
643 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); | |
642 | } |
|
644 | } | |
643 | if (event_out == RTEMS_EVENT_MODE_SBM2) |
|
645 | if (event_out == RTEMS_EVENT_MODE_SBM2) | |
644 | { |
|
646 | { | |
645 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); |
|
647 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); | |
646 | // launch snapshot extraction if needed |
|
648 | // launch snapshot extraction if needed | |
647 | if (extractSWF == true) |
|
649 | if (extractSWF == true) | |
648 | { |
|
650 | { | |
649 | ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2; |
|
651 | ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2; | |
650 | // extract the snapshot |
|
652 | // extract the snapshot | |
651 | build_snapshot_from_ring( ring_node_to_send_swf_f2, 2, acquisitionTimeF0_asLong ); |
|
653 | build_snapshot_from_ring( ring_node_to_send_swf_f2, 2, acquisitionTimeF0_asLong ); | |
652 | // send the snapshot when built |
|
654 | // send the snapshot when built | |
653 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ); |
|
655 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ); | |
654 | extractSWF = false; |
|
656 | extractSWF = false; | |
655 | } |
|
657 | } | |
656 | if (swf_f0_ready && swf_f1_ready) |
|
658 | if (swf_f0_ready && swf_f1_ready) | |
657 | { |
|
659 | { | |
658 | extractSWF = true; |
|
660 | extractSWF = true; | |
659 | // record the acquition time of the fΓ snapshot to use to build the snapshot at f2 |
|
661 | // record the acquition time of the fΓ snapshot to use to build the snapshot at f2 | |
660 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); |
|
662 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); | |
661 | swf_f0_ready = false; |
|
663 | swf_f0_ready = false; | |
662 | swf_f1_ready = false; |
|
664 | swf_f1_ready = false; | |
663 | } |
|
665 | } | |
664 | } |
|
666 | } | |
665 | } |
|
667 | } | |
666 | } |
|
668 | } | |
667 |
|
669 | |||
668 | rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1 |
|
670 | rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1 | |
669 | { |
|
671 | { | |
670 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1. |
|
672 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1. | |
671 | * |
|
673 | * | |
672 | * @param unused is the starting argument of the RTEMS task |
|
674 | * @param unused is the starting argument of the RTEMS task | |
673 | * |
|
675 | * | |
674 | * The following data packet is sent by this function: |
|
676 | * The following data packet is sent by this function: | |
675 | * - TM_LFR_SCIENCE_SBM1_CWF_F1 |
|
677 | * - TM_LFR_SCIENCE_SBM1_CWF_F1 | |
676 | * |
|
678 | * | |
677 | */ |
|
679 | */ | |
678 |
|
680 | |||
679 | rtems_event_set event_out; |
|
681 | rtems_event_set event_out; | |
680 | rtems_id queue_id; |
|
682 | rtems_id queue_id; | |
681 | rtems_status_code status; |
|
683 | rtems_status_code status; | |
682 |
|
684 | |||
683 | ring_node *ring_node_to_send_cwf; |
|
685 | ring_node *ring_node_to_send_cwf; | |
684 |
|
686 | |||
685 | status = get_message_queue_id_send( &queue_id ); |
|
687 | status = get_message_queue_id_send( &queue_id ); | |
686 | if (status != RTEMS_SUCCESSFUL) |
|
688 | if (status != RTEMS_SUCCESSFUL) | |
687 | { |
|
689 | { | |
688 | PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status) |
|
690 | PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status) | |
689 | } |
|
691 | } | |
690 |
|
692 | |||
691 | BOOT_PRINTF("in CWF1 ***\n") |
|
693 | BOOT_PRINTF("in CWF1 ***\n") | |
692 |
|
694 | |||
693 | while(1){ |
|
695 | while(1){ | |
694 | // wait for an RTEMS_EVENT |
|
696 | // wait for an RTEMS_EVENT | |
695 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1, |
|
697 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1, | |
696 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
698 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
697 | ring_node_to_send_cwf = getRingNodeToSendCWF( 1 ); |
|
699 | ring_node_to_send_cwf = getRingNodeToSendCWF( 1 ); | |
698 | ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1; |
|
700 | ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1; | |
699 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); |
|
701 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); | |
700 | if (status != 0) |
|
702 | if (status != 0) | |
701 | printf("cwf sending failed\n"); |
|
703 | printf("cwf sending failed\n"); | |
702 | // launch snapshot extraction if needed |
|
704 | // launch snapshot extraction if needed | |
703 | if (extractSWF == true) |
|
705 | if (extractSWF == true) | |
704 | { |
|
706 | { | |
705 | ring_node_to_send_swf_f1 = ring_node_to_send_cwf; |
|
707 | ring_node_to_send_swf_f1 = ring_node_to_send_cwf; | |
706 | // launch the snapshot extraction |
|
708 | // launch the snapshot extraction | |
707 | status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 ); |
|
709 | status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_SBM1 ); | |
708 | extractSWF = false; |
|
710 | extractSWF = false; | |
709 | } |
|
711 | } | |
710 | if (swf_f0_ready == true) |
|
712 | if (swf_f0_ready == true) | |
711 | { |
|
713 | { | |
712 | extractSWF = true; |
|
714 | extractSWF = true; | |
713 | swf_f0_ready = false; // this step shall be executed only one time |
|
715 | swf_f0_ready = false; // this step shall be executed only one time | |
714 | } |
|
716 | } | |
715 | if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction |
|
717 | if ((swf_f1_ready == true) && (swf_f2_ready == true)) // swf_f1 is ready after the extraction | |
716 | { |
|
718 | { | |
717 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 ); |
|
719 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 ); | |
718 | swf_f1_ready = false; |
|
720 | swf_f1_ready = false; | |
719 | swf_f2_ready = false; |
|
721 | swf_f2_ready = false; | |
720 | } |
|
722 | } | |
721 | } |
|
723 | } | |
722 | } |
|
724 | } | |
723 |
|
725 | |||
724 | rtems_task swbd_task(rtems_task_argument argument) |
|
726 | rtems_task swbd_task(rtems_task_argument argument) | |
725 | { |
|
727 | { | |
726 | /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers. |
|
728 | /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers. | |
727 | * |
|
729 | * | |
728 | * @param unused is the starting argument of the RTEMS task |
|
730 | * @param unused is the starting argument of the RTEMS task | |
729 | * |
|
731 | * | |
730 | */ |
|
732 | */ | |
731 |
|
733 | |||
732 | rtems_event_set event_out; |
|
734 | rtems_event_set event_out; | |
733 | unsigned long long int acquisitionTimeF0_asLong; |
|
735 | unsigned long long int acquisitionTimeF0_asLong; | |
734 |
|
736 | |||
735 | acquisitionTimeF0_asLong = 0x00; |
|
737 | acquisitionTimeF0_asLong = 0x00; | |
736 |
|
738 | |||
737 | BOOT_PRINTF("in SWBD ***\n") |
|
739 | BOOT_PRINTF("in SWBD ***\n") | |
738 |
|
740 | |||
739 | while(1){ |
|
741 | while(1){ | |
740 | // wait for an RTEMS_EVENT |
|
742 | // wait for an RTEMS_EVENT | |
741 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2, |
|
743 | rtems_event_receive( RTEMS_EVENT_MODE_SBM1 | RTEMS_EVENT_MODE_SBM2, | |
742 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
744 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
743 | if (event_out == RTEMS_EVENT_MODE_SBM1) |
|
745 | if (event_out == RTEMS_EVENT_MODE_SBM1) | |
744 | { |
|
746 | { | |
745 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); |
|
747 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); | |
746 | build_snapshot_from_ring( ring_node_to_send_swf_f1, 1, acquisitionTimeF0_asLong ); |
|
748 | build_snapshot_from_ring( ring_node_to_send_swf_f1, 1, acquisitionTimeF0_asLong ); | |
747 | swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent |
|
749 | swf_f1_ready = true; // the snapshot has been extracted and is ready to be sent | |
748 | } |
|
750 | } | |
749 | else |
|
751 | else | |
750 | { |
|
752 | { | |
751 | PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out) |
|
753 | PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out) | |
752 | } |
|
754 | } | |
753 | } |
|
755 | } | |
754 | } |
|
756 | } | |
755 |
|
757 | |||
756 | //****************** |
|
758 | //****************** | |
757 | // general functions |
|
759 | // general functions | |
758 |
|
760 | |||
759 | void WFP_init_rings( void ) |
|
761 | void WFP_init_rings( void ) | |
760 | { |
|
762 | { | |
761 | // F0 RING |
|
763 | // F0 RING | |
762 | init_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_buffer_f0, WFRM_BUFFER ); |
|
764 | init_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_buffer_f0, WFRM_BUFFER ); | |
763 | // F1 RING |
|
765 | // F1 RING | |
764 | init_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_buffer_f1, WFRM_BUFFER ); |
|
766 | init_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_buffer_f1, WFRM_BUFFER ); | |
765 | // F2 RING |
|
767 | // F2 RING | |
766 | init_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_buffer_f2, WFRM_BUFFER ); |
|
768 | init_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_buffer_f2, WFRM_BUFFER ); | |
767 | // F3 RING |
|
769 | // F3 RING | |
768 | init_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_buffer_f3, WFRM_BUFFER ); |
|
770 | init_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_buffer_f3, WFRM_BUFFER ); | |
769 |
|
771 | |||
770 | ring_node_wf_snap_extracted.buffer_address = (int) wf_snap_extracted; |
|
772 | ring_node_wf_snap_extracted.buffer_address = (int) wf_snap_extracted; | |
771 |
|
773 | |||
772 | DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0) |
|
774 | DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0) | |
773 | DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1) |
|
775 | DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1) | |
774 | DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2) |
|
776 | DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2) | |
775 | DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3) |
|
777 | DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3) | |
776 | DEBUG_PRINTF1("wf_buffer_f0 @%x\n", (unsigned int) wf_buffer_f0) |
|
778 | DEBUG_PRINTF1("wf_buffer_f0 @%x\n", (unsigned int) wf_buffer_f0) | |
777 | DEBUG_PRINTF1("wf_buffer_f1 @%x\n", (unsigned int) wf_buffer_f1) |
|
779 | DEBUG_PRINTF1("wf_buffer_f1 @%x\n", (unsigned int) wf_buffer_f1) | |
778 | DEBUG_PRINTF1("wf_buffer_f2 @%x\n", (unsigned int) wf_buffer_f2) |
|
780 | DEBUG_PRINTF1("wf_buffer_f2 @%x\n", (unsigned int) wf_buffer_f2) | |
779 | DEBUG_PRINTF1("wf_buffer_f3 @%x\n", (unsigned int) wf_buffer_f3) |
|
781 | DEBUG_PRINTF1("wf_buffer_f3 @%x\n", (unsigned int) wf_buffer_f3) | |
780 |
|
782 | |||
781 | } |
|
783 | } | |
782 |
|
784 | |||
783 | void WFP_reset_current_ring_nodes( void ) |
|
785 | void WFP_reset_current_ring_nodes( void ) | |
784 | { |
|
786 | { | |
785 | current_ring_node_f0 = waveform_ring_f0[0].next; |
|
787 | current_ring_node_f0 = waveform_ring_f0[0].next; | |
786 | current_ring_node_f1 = waveform_ring_f1[0].next; |
|
788 | current_ring_node_f1 = waveform_ring_f1[0].next; | |
787 | current_ring_node_f2 = waveform_ring_f2[0].next; |
|
789 | current_ring_node_f2 = waveform_ring_f2[0].next; | |
788 | current_ring_node_f3 = waveform_ring_f3[0].next; |
|
790 | current_ring_node_f3 = waveform_ring_f3[0].next; | |
789 |
|
791 | |||
790 | ring_node_to_send_swf_f0 = waveform_ring_f0; |
|
792 | ring_node_to_send_swf_f0 = waveform_ring_f0; | |
791 | ring_node_to_send_swf_f1 = waveform_ring_f1; |
|
793 | ring_node_to_send_swf_f1 = waveform_ring_f1; | |
792 | ring_node_to_send_swf_f2 = waveform_ring_f2; |
|
794 | ring_node_to_send_swf_f2 = waveform_ring_f2; | |
793 |
|
795 | |||
794 | ring_node_to_send_cwf_f1 = waveform_ring_f1; |
|
796 | ring_node_to_send_cwf_f1 = waveform_ring_f1; | |
795 | ring_node_to_send_cwf_f2 = waveform_ring_f2; |
|
797 | ring_node_to_send_cwf_f2 = waveform_ring_f2; | |
796 | ring_node_to_send_cwf_f3 = waveform_ring_f3; |
|
798 | ring_node_to_send_cwf_f3 = waveform_ring_f3; | |
797 | } |
|
799 | } | |
798 |
|
800 | |||
799 | int send_waveform_CWF3_light( ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id ) |
|
801 | int send_waveform_CWF3_light( ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id ) | |
800 | { |
|
802 | { | |
801 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. |
|
803 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. | |
802 | * |
|
804 | * | |
803 | * @param waveform points to the buffer containing the data that will be send. |
|
805 | * @param waveform points to the buffer containing the data that will be send. | |
804 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
806 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
805 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
807 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
806 | * contain information to setup the transmission of the data packets. |
|
808 | * contain information to setup the transmission of the data packets. | |
807 | * |
|
809 | * | |
808 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer |
|
810 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer | |
809 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. |
|
811 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. | |
810 | * |
|
812 | * | |
811 | */ |
|
813 | */ | |
812 |
|
814 | |||
813 | unsigned int i; |
|
815 | unsigned int i; | |
814 | int ret; |
|
816 | int ret; | |
815 | rtems_status_code status; |
|
817 | rtems_status_code status; | |
816 |
|
818 | |||
817 | char *sample; |
|
819 | char *sample; | |
818 | int *dataPtr; |
|
820 | int *dataPtr; | |
819 |
|
821 | |||
820 | ret = LFR_DEFAULT; |
|
822 | ret = LFR_DEFAULT; | |
821 |
|
823 | |||
822 | dataPtr = (int*) ring_node_to_send->buffer_address; |
|
824 | dataPtr = (int*) ring_node_to_send->buffer_address; | |
823 |
|
825 | |||
824 | ring_node_cwf3_light->coarseTime = ring_node_to_send->coarseTime; |
|
826 | ring_node_cwf3_light->coarseTime = ring_node_to_send->coarseTime; | |
825 | ring_node_cwf3_light->fineTime = ring_node_to_send->fineTime; |
|
827 | ring_node_cwf3_light->fineTime = ring_node_to_send->fineTime; | |
826 |
|
828 | |||
827 | //********************** |
|
829 | //********************** | |
828 | // BUILD CWF3_light DATA |
|
830 | // BUILD CWF3_light DATA | |
829 | for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) |
|
831 | for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) | |
830 | { |
|
832 | { | |
831 | sample = (char*) &dataPtr[ (i * NB_WORDS_SWF_BLK) ]; |
|
833 | sample = (char*) &dataPtr[ (i * NB_WORDS_SWF_BLK) ]; | |
832 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ]; |
|
834 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ]; | |
833 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ]; |
|
835 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ]; | |
834 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ]; |
|
836 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ]; | |
835 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ]; |
|
837 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ]; | |
836 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ]; |
|
838 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ]; | |
837 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ]; |
|
839 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ]; | |
838 | } |
|
840 | } | |
839 |
|
841 | |||
840 | // SEND PACKET |
|
842 | // SEND PACKET | |
841 | status = rtems_message_queue_send( queue_id, &ring_node_cwf3_light, sizeof( ring_node* ) ); |
|
843 | status = rtems_message_queue_send( queue_id, &ring_node_cwf3_light, sizeof( ring_node* ) ); | |
842 | if (status != RTEMS_SUCCESSFUL) { |
|
844 | if (status != RTEMS_SUCCESSFUL) { | |
843 | printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status); |
|
845 | printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status); | |
844 | ret = LFR_DEFAULT; |
|
846 | ret = LFR_DEFAULT; | |
845 | } |
|
847 | } | |
846 |
|
848 | |||
847 | return ret; |
|
849 | return ret; | |
848 | } |
|
850 | } | |
849 |
|
851 | |||
850 | void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime, |
|
852 | void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime, | |
851 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime ) |
|
853 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime ) | |
852 | { |
|
854 | { | |
853 | unsigned long long int acquisitionTimeAsLong; |
|
855 | unsigned long long int acquisitionTimeAsLong; | |
854 | unsigned char localAcquisitionTime[6]; |
|
856 | unsigned char localAcquisitionTime[6]; | |
855 | double deltaT; |
|
857 | double deltaT; | |
856 |
|
858 | |||
857 | deltaT = 0.; |
|
859 | deltaT = 0.; | |
858 |
|
860 | |||
859 | localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 24 ); |
|
861 | localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 24 ); | |
860 | localAcquisitionTime[1] = (unsigned char) ( coarseTime >> 16 ); |
|
862 | localAcquisitionTime[1] = (unsigned char) ( coarseTime >> 16 ); | |
861 | localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 8 ); |
|
863 | localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 8 ); | |
862 | localAcquisitionTime[3] = (unsigned char) ( coarseTime ); |
|
864 | localAcquisitionTime[3] = (unsigned char) ( coarseTime ); | |
863 | localAcquisitionTime[4] = (unsigned char) ( fineTime >> 8 ); |
|
865 | localAcquisitionTime[4] = (unsigned char) ( fineTime >> 8 ); | |
864 | localAcquisitionTime[5] = (unsigned char) ( fineTime ); |
|
866 | localAcquisitionTime[5] = (unsigned char) ( fineTime ); | |
865 |
|
867 | |||
866 | acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 ) |
|
868 | acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 ) | |
867 | + ( (unsigned long long int) localAcquisitionTime[1] << 32 ) |
|
869 | + ( (unsigned long long int) localAcquisitionTime[1] << 32 ) | |
868 | + ( (unsigned long long int) localAcquisitionTime[2] << 24 ) |
|
870 | + ( (unsigned long long int) localAcquisitionTime[2] << 24 ) | |
869 | + ( (unsigned long long int) localAcquisitionTime[3] << 16 ) |
|
871 | + ( (unsigned long long int) localAcquisitionTime[3] << 16 ) | |
870 | + ( (unsigned long long int) localAcquisitionTime[4] << 8 ) |
|
872 | + ( (unsigned long long int) localAcquisitionTime[4] << 8 ) | |
871 | + ( (unsigned long long int) localAcquisitionTime[5] ); |
|
873 | + ( (unsigned long long int) localAcquisitionTime[5] ); | |
872 |
|
874 | |||
873 | switch( sid ) |
|
875 | switch( sid ) | |
874 | { |
|
876 | { | |
875 | case SID_NORM_SWF_F0: |
|
877 | case SID_NORM_SWF_F0: | |
876 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ; |
|
878 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ; | |
877 | break; |
|
879 | break; | |
878 |
|
880 | |||
879 | case SID_NORM_SWF_F1: |
|
881 | case SID_NORM_SWF_F1: | |
880 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ; |
|
882 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ; | |
881 | break; |
|
883 | break; | |
882 |
|
884 | |||
883 | case SID_NORM_SWF_F2: |
|
885 | case SID_NORM_SWF_F2: | |
884 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ; |
|
886 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ; | |
885 | break; |
|
887 | break; | |
886 |
|
888 | |||
887 | case SID_SBM1_CWF_F1: |
|
889 | case SID_SBM1_CWF_F1: | |
888 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ; |
|
890 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ; | |
889 | break; |
|
891 | break; | |
890 |
|
892 | |||
891 | case SID_SBM2_CWF_F2: |
|
893 | case SID_SBM2_CWF_F2: | |
892 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; |
|
894 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; | |
893 | break; |
|
895 | break; | |
894 |
|
896 | |||
895 | case SID_BURST_CWF_F2: |
|
897 | case SID_BURST_CWF_F2: | |
896 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; |
|
898 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; | |
897 | break; |
|
899 | break; | |
898 |
|
900 | |||
899 | case SID_NORM_CWF_F3: |
|
901 | case SID_NORM_CWF_F3: | |
900 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ; |
|
902 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ; | |
901 | break; |
|
903 | break; | |
902 |
|
904 | |||
903 | case SID_NORM_CWF_LONG_F3: |
|
905 | case SID_NORM_CWF_LONG_F3: | |
904 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ; |
|
906 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ; | |
905 | break; |
|
907 | break; | |
906 |
|
908 | |||
907 | default: |
|
909 | default: | |
908 | PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d\n", sid) |
|
910 | PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d\n", sid) | |
909 | deltaT = 0.; |
|
911 | deltaT = 0.; | |
910 | break; |
|
912 | break; | |
911 | } |
|
913 | } | |
912 |
|
914 | |||
913 | acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT; |
|
915 | acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT; | |
914 | // |
|
916 | // | |
915 | acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40); |
|
917 | acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40); | |
916 | acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32); |
|
918 | acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32); | |
917 | acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24); |
|
919 | acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24); | |
918 | acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16); |
|
920 | acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16); | |
919 | acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 ); |
|
921 | acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 ); | |
920 | acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong ); |
|
922 | acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong ); | |
921 |
|
923 | |||
922 | } |
|
924 | } | |
923 |
|
925 | |||
924 | void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel, unsigned long long int acquisitionTimeF0_asLong ) |
|
926 | void build_snapshot_from_ring( ring_node *ring_node_to_send, unsigned char frequencyChannel, unsigned long long int acquisitionTimeF0_asLong ) | |
925 | { |
|
927 | { | |
926 | unsigned int i; |
|
928 | unsigned int i; | |
927 | unsigned long long int centerTime_asLong; |
|
929 | unsigned long long int centerTime_asLong; | |
928 | unsigned long long int acquisitionTime_asLong; |
|
930 | unsigned long long int acquisitionTime_asLong; | |
929 | unsigned long long int bufferAcquisitionTime_asLong; |
|
931 | unsigned long long int bufferAcquisitionTime_asLong; | |
930 | unsigned char *ptr1; |
|
932 | unsigned char *ptr1; | |
931 | unsigned char *ptr2; |
|
933 | unsigned char *ptr2; | |
932 | unsigned char *timeCharPtr; |
|
934 | unsigned char *timeCharPtr; | |
933 | unsigned char nb_ring_nodes; |
|
935 | unsigned char nb_ring_nodes; | |
934 | unsigned long long int frequency_asLong; |
|
936 | unsigned long long int frequency_asLong; | |
935 | unsigned long long int nbTicksPerSample_asLong; |
|
937 | unsigned long long int nbTicksPerSample_asLong; | |
936 | unsigned long long int nbSamplesPart1_asLong; |
|
938 | unsigned long long int nbSamplesPart1_asLong; | |
937 | unsigned long long int sampleOffset_asLong; |
|
939 | unsigned long long int sampleOffset_asLong; | |
938 |
|
940 | |||
939 | unsigned int deltaT_F0; |
|
941 | unsigned int deltaT_F0; | |
940 | unsigned int deltaT_F1; |
|
942 | unsigned int deltaT_F1; | |
941 | unsigned long long int deltaT_F2; |
|
943 | unsigned long long int deltaT_F2; | |
942 |
|
944 | |||
943 | deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; |
|
945 | deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; | |
944 | deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384; |
|
946 | deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384; | |
945 | deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144; |
|
947 | deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144; | |
946 | sampleOffset_asLong = 0x00; |
|
948 | sampleOffset_asLong = 0x00; | |
947 |
|
949 | |||
948 | // (1) get the f0 acquisition time => the value is passed in argument |
|
950 | // (1) get the f0 acquisition time => the value is passed in argument | |
949 |
|
951 | |||
950 | // (2) compute the central reference time |
|
952 | // (2) compute the central reference time | |
951 | centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0; |
|
953 | centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0; | |
952 |
|
954 | |||
953 | // (3) compute the acquisition time of the current snapshot |
|
955 | // (3) compute the acquisition time of the current snapshot | |
954 | switch(frequencyChannel) |
|
956 | switch(frequencyChannel) | |
955 | { |
|
957 | { | |
956 | case 1: // 1 is for F1 = 4096 Hz |
|
958 | case 1: // 1 is for F1 = 4096 Hz | |
957 | acquisitionTime_asLong = centerTime_asLong - deltaT_F1; |
|
959 | acquisitionTime_asLong = centerTime_asLong - deltaT_F1; | |
958 | nb_ring_nodes = NB_RING_NODES_F1; |
|
960 | nb_ring_nodes = NB_RING_NODES_F1; | |
959 | frequency_asLong = 4096; |
|
961 | frequency_asLong = 4096; | |
960 | nbTicksPerSample_asLong = 16; // 65536 / 4096; |
|
962 | nbTicksPerSample_asLong = 16; // 65536 / 4096; | |
961 | break; |
|
963 | break; | |
962 | case 2: // 2 is for F2 = 256 Hz |
|
964 | case 2: // 2 is for F2 = 256 Hz | |
963 | acquisitionTime_asLong = centerTime_asLong - deltaT_F2; |
|
965 | acquisitionTime_asLong = centerTime_asLong - deltaT_F2; | |
964 | nb_ring_nodes = NB_RING_NODES_F2; |
|
966 | nb_ring_nodes = NB_RING_NODES_F2; | |
965 | frequency_asLong = 256; |
|
967 | frequency_asLong = 256; | |
966 | nbTicksPerSample_asLong = 256; // 65536 / 256; |
|
968 | nbTicksPerSample_asLong = 256; // 65536 / 256; | |
967 | break; |
|
969 | break; | |
968 | default: |
|
970 | default: | |
969 | acquisitionTime_asLong = centerTime_asLong; |
|
971 | acquisitionTime_asLong = centerTime_asLong; | |
970 | frequency_asLong = 256; |
|
972 | frequency_asLong = 256; | |
971 | nbTicksPerSample_asLong = 256; |
|
973 | nbTicksPerSample_asLong = 256; | |
972 | break; |
|
974 | break; | |
973 | } |
|
975 | } | |
974 |
|
976 | |||
975 | //**************************************************************************** |
|
977 | //**************************************************************************** | |
976 | // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong |
|
978 | // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong | |
977 | for (i=0; i<nb_ring_nodes; i++) |
|
979 | for (i=0; i<nb_ring_nodes; i++) | |
978 | { |
|
980 | { | |
979 | PRINTF1("%d ... ", i) |
|
981 | PRINTF1("%d ... ", i) | |
980 | bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send->coarseTime ); |
|
982 | bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send->coarseTime ); | |
981 | if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong) |
|
983 | if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong) | |
982 | { |
|
984 | { | |
983 | PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong) |
|
985 | PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong) | |
984 | break; |
|
986 | break; | |
985 | } |
|
987 | } | |
986 | ring_node_to_send = ring_node_to_send->previous; |
|
988 | ring_node_to_send = ring_node_to_send->previous; | |
987 | } |
|
989 | } | |
988 |
|
990 | |||
989 | // (5) compute the number of samples to take in the current buffer |
|
991 | // (5) compute the number of samples to take in the current buffer | |
990 | sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16; |
|
992 | sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16; | |
991 | nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong; |
|
993 | nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong; | |
992 | PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong) |
|
994 | PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong) | |
993 |
|
995 | |||
994 | // (6) compute the final acquisition time |
|
996 | // (6) compute the final acquisition time | |
995 | acquisitionTime_asLong = bufferAcquisitionTime_asLong + |
|
997 | acquisitionTime_asLong = bufferAcquisitionTime_asLong + | |
996 | sampleOffset_asLong * nbTicksPerSample_asLong; |
|
998 | sampleOffset_asLong * nbTicksPerSample_asLong; | |
997 |
|
999 | |||
998 | // (7) copy the acquisition time at the beginning of the extrated snapshot |
|
1000 | // (7) copy the acquisition time at the beginning of the extrated snapshot | |
999 | ptr1 = (unsigned char*) &acquisitionTime_asLong; |
|
1001 | ptr1 = (unsigned char*) &acquisitionTime_asLong; | |
1000 | // fine time |
|
1002 | // fine time | |
1001 | ptr2 = (unsigned char*) &ring_node_wf_snap_extracted.fineTime; |
|
1003 | ptr2 = (unsigned char*) &ring_node_wf_snap_extracted.fineTime; | |
1002 | ptr2[2] = ptr1[ 4 + 2 ]; |
|
1004 | ptr2[2] = ptr1[ 4 + 2 ]; | |
1003 | ptr2[3] = ptr1[ 5 + 2 ]; |
|
1005 | ptr2[3] = ptr1[ 5 + 2 ]; | |
1004 | // coarse time |
|
1006 | // coarse time | |
1005 | ptr2 = (unsigned char*) &ring_node_wf_snap_extracted.coarseTime; |
|
1007 | ptr2 = (unsigned char*) &ring_node_wf_snap_extracted.coarseTime; | |
1006 | ptr2[0] = ptr1[ 0 + 2 ]; |
|
1008 | ptr2[0] = ptr1[ 0 + 2 ]; | |
1007 | ptr2[1] = ptr1[ 1 + 2 ]; |
|
1009 | ptr2[1] = ptr1[ 1 + 2 ]; | |
1008 | ptr2[2] = ptr1[ 2 + 2 ]; |
|
1010 | ptr2[2] = ptr1[ 2 + 2 ]; | |
1009 | ptr2[3] = ptr1[ 3 + 2 ]; |
|
1011 | ptr2[3] = ptr1[ 3 + 2 ]; | |
1010 |
|
1012 | |||
1011 | // re set the synchronization bit |
|
1013 | // re set the synchronization bit | |
1012 | timeCharPtr = (unsigned char*) &ring_node_to_send->coarseTime; |
|
1014 | timeCharPtr = (unsigned char*) &ring_node_to_send->coarseTime; | |
1013 | ptr2[0] = ptr2[0] | (timeCharPtr[0] & 0x80); // [1000 0000] |
|
1015 | ptr2[0] = ptr2[0] | (timeCharPtr[0] & 0x80); // [1000 0000] | |
1014 |
|
1016 | |||
1015 | if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) ) |
|
1017 | if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) ) | |
1016 | { |
|
1018 | { | |
1017 | nbSamplesPart1_asLong = 0; |
|
1019 | nbSamplesPart1_asLong = 0; | |
1018 | } |
|
1020 | } | |
1019 | // copy the part 1 of the snapshot in the extracted buffer |
|
1021 | // copy the part 1 of the snapshot in the extracted buffer | |
1020 | for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ ) |
|
1022 | for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ ) | |
1021 | { |
|
1023 | { | |
1022 | wf_snap_extracted[i] = |
|
1024 | wf_snap_extracted[i] = | |
1023 | ((int*) ring_node_to_send->buffer_address)[ i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) ]; |
|
1025 | ((int*) ring_node_to_send->buffer_address)[ i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) ]; | |
1024 | } |
|
1026 | } | |
1025 | // copy the part 2 of the snapshot in the extracted buffer |
|
1027 | // copy the part 2 of the snapshot in the extracted buffer | |
1026 | ring_node_to_send = ring_node_to_send->next; |
|
1028 | ring_node_to_send = ring_node_to_send->next; | |
1027 | for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ ) |
|
1029 | for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ ) | |
1028 | { |
|
1030 | { | |
1029 | wf_snap_extracted[i] = |
|
1031 | wf_snap_extracted[i] = | |
1030 | ((int*) ring_node_to_send->buffer_address)[ (i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) ]; |
|
1032 | ((int*) ring_node_to_send->buffer_address)[ (i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) ]; | |
1031 | } |
|
1033 | } | |
1032 | } |
|
1034 | } | |
1033 |
|
1035 | |||
1034 | void snapshot_resynchronization( unsigned char *timePtr ) |
|
1036 | void snapshot_resynchronization( unsigned char *timePtr ) | |
1035 | { |
|
1037 | { | |
1036 | unsigned long long int acquisitionTime; |
|
1038 | unsigned long long int acquisitionTime; | |
1037 | unsigned long long int centerTime; |
|
1039 | unsigned long long int centerTime; | |
1038 | unsigned long long int previousTick; |
|
1040 | unsigned long long int previousTick; | |
1039 | unsigned long long int nextTick; |
|
1041 | unsigned long long int nextTick; | |
1040 | unsigned long long int deltaPreviousTick; |
|
1042 | unsigned long long int deltaPreviousTick; | |
1041 | unsigned long long int deltaNextTick; |
|
1043 | unsigned long long int deltaNextTick; | |
1042 | unsigned int deltaTickInF2; |
|
1044 | unsigned int deltaTickInF2; | |
1043 | double deltaPrevious; |
|
1045 | double deltaPrevious; | |
1044 | double deltaNext; |
|
1046 | double deltaNext; | |
1045 |
|
1047 | |||
1046 | acquisitionTime = get_acquisition_time( timePtr ); |
|
1048 | acquisitionTime = get_acquisition_time( timePtr ); | |
1047 |
|
1049 | |||
1048 | // compute center time |
|
1050 | // compute center time | |
1049 | centerTime = acquisitionTime + 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; |
|
1051 | centerTime = acquisitionTime + 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; | |
1050 | previousTick = centerTime - (centerTime & 0xffff); |
|
1052 | previousTick = centerTime - (centerTime & 0xffff); | |
1051 | nextTick = previousTick + 65536; |
|
1053 | nextTick = previousTick + 65536; | |
1052 |
|
1054 | |||
1053 | deltaPreviousTick = centerTime - previousTick; |
|
1055 | deltaPreviousTick = centerTime - previousTick; | |
1054 | deltaNextTick = nextTick - centerTime; |
|
1056 | deltaNextTick = nextTick - centerTime; | |
1055 |
|
1057 | |||
1056 | deltaPrevious = ((double) deltaPreviousTick) / 65536. * 1000.; |
|
1058 | deltaPrevious = ((double) deltaPreviousTick) / 65536. * 1000.; | |
1057 | deltaNext = ((double) deltaNextTick) / 65536. * 1000.; |
|
1059 | deltaNext = ((double) deltaNextTick) / 65536. * 1000.; | |
1058 |
|
1060 | |||
1059 | PRINTF2("delta previous = %f ms, delta next = %f ms\n", deltaPrevious, deltaNext) |
|
1061 | PRINTF2("delta previous = %f ms, delta next = %f ms\n", deltaPrevious, deltaNext) | |
1060 | PRINTF2("delta previous = %llu, delta next = %llu\n", deltaPreviousTick, deltaNextTick) |
|
1062 | PRINTF2("delta previous = %llu, delta next = %llu\n", deltaPreviousTick, deltaNextTick) | |
1061 |
|
1063 | |||
1062 | // which tick is the closest |
|
1064 | // which tick is the closest | |
1063 | if (deltaPreviousTick > deltaNextTick) |
|
1065 | if (deltaPreviousTick > deltaNextTick) | |
1064 | { |
|
1066 | { | |
1065 | deltaTickInF2 = floor( (deltaNext * 256. / 1000.) ); // the division by 2 is important here |
|
1067 | deltaTickInF2 = floor( (deltaNext * 256. / 1000.) ); // the division by 2 is important here | |
1066 | waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + deltaTickInF2; |
|
1068 | waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + deltaTickInF2; | |
1067 | printf("correction of = + %u\n", deltaTickInF2); |
|
1069 | printf("correction of = + %u\n", deltaTickInF2); | |
1068 | } |
|
1070 | } | |
1069 | else |
|
1071 | else | |
1070 | { |
|
1072 | { | |
1071 | deltaTickInF2 = floor( (deltaPrevious * 256. / 1000.) ); // the division by 2 is important here |
|
1073 | deltaTickInF2 = floor( (deltaPrevious * 256. / 1000.) ); // the division by 2 is important here | |
1072 | waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot - deltaTickInF2; |
|
1074 | waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot - deltaTickInF2; | |
1073 | printf("correction of = - %u\n", deltaTickInF2); |
|
1075 | printf("correction of = - %u\n", deltaTickInF2); | |
1074 | } |
|
1076 | } | |
1075 | } |
|
1077 | } | |
1076 |
|
1078 | |||
1077 | //************** |
|
1079 | //************** | |
1078 | // wfp registers |
|
1080 | // wfp registers | |
1079 | void reset_wfp_burst_enable( void ) |
|
1081 | void reset_wfp_burst_enable( void ) | |
1080 | { |
|
1082 | { | |
1081 | /** This function resets the waveform picker burst_enable register. |
|
1083 | /** This function resets the waveform picker burst_enable register. | |
1082 | * |
|
1084 | * | |
1083 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. |
|
1085 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. | |
1084 | * |
|
1086 | * | |
1085 | */ |
|
1087 | */ | |
1086 |
|
1088 | |||
1087 | // [1000 000] burst f2, f1, f0 enable f3, f2, f1, f0 |
|
1089 | // [1000 000] burst f2, f1, f0 enable f3, f2, f1, f0 | |
1088 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable & 0x80; |
|
1090 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable & 0x80; | |
1089 | } |
|
1091 | } | |
1090 |
|
1092 | |||
1091 | void reset_wfp_status( void ) |
|
1093 | void reset_wfp_status( void ) | |
1092 | { |
|
1094 | { | |
1093 | /** This function resets the waveform picker status register. |
|
1095 | /** This function resets the waveform picker status register. | |
1094 | * |
|
1096 | * | |
1095 | * All status bits are set to 0 [new_err full_err full]. |
|
1097 | * All status bits are set to 0 [new_err full_err full]. | |
1096 | * |
|
1098 | * | |
1097 | */ |
|
1099 | */ | |
1098 |
|
1100 | |||
1099 | waveform_picker_regs->status = 0xffff; |
|
1101 | waveform_picker_regs->status = 0xffff; | |
1100 | } |
|
1102 | } | |
1101 |
|
1103 | |||
1102 | void reset_wfp_buffer_addresses( void ) |
|
1104 | void reset_wfp_buffer_addresses( void ) | |
1103 | { |
|
1105 | { | |
1104 | // F0 |
|
1106 | // F0 | |
1105 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->previous->buffer_address; // 0x08 |
|
1107 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->previous->buffer_address; // 0x08 | |
1106 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c |
|
1108 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c | |
1107 | // F1 |
|
1109 | // F1 | |
1108 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->previous->buffer_address; // 0x10 |
|
1110 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->previous->buffer_address; // 0x10 | |
1109 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14 |
|
1111 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14 | |
1110 | // F2 |
|
1112 | // F2 | |
1111 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->previous->buffer_address; // 0x18 |
|
1113 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->previous->buffer_address; // 0x18 | |
1112 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c |
|
1114 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c | |
1113 | // F3 |
|
1115 | // F3 | |
1114 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->previous->buffer_address; // 0x20 |
|
1116 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->previous->buffer_address; // 0x20 | |
1115 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24 |
|
1117 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24 | |
1116 | } |
|
1118 | } | |
1117 |
|
1119 | |||
1118 | void reset_waveform_picker_regs( void ) |
|
1120 | void reset_waveform_picker_regs( void ) | |
1119 | { |
|
1121 | { | |
1120 | /** This function resets the waveform picker module registers. |
|
1122 | /** This function resets the waveform picker module registers. | |
1121 | * |
|
1123 | * | |
1122 | * The registers affected by this function are located at the following offset addresses: |
|
1124 | * The registers affected by this function are located at the following offset addresses: | |
1123 | * - 0x00 data_shaping |
|
1125 | * - 0x00 data_shaping | |
1124 | * - 0x04 run_burst_enable |
|
1126 | * - 0x04 run_burst_enable | |
1125 | * - 0x08 addr_data_f0 |
|
1127 | * - 0x08 addr_data_f0 | |
1126 | * - 0x0C addr_data_f1 |
|
1128 | * - 0x0C addr_data_f1 | |
1127 | * - 0x10 addr_data_f2 |
|
1129 | * - 0x10 addr_data_f2 | |
1128 | * - 0x14 addr_data_f3 |
|
1130 | * - 0x14 addr_data_f3 | |
1129 | * - 0x18 status |
|
1131 | * - 0x18 status | |
1130 | * - 0x1C delta_snapshot |
|
1132 | * - 0x1C delta_snapshot | |
1131 | * - 0x20 delta_f0 |
|
1133 | * - 0x20 delta_f0 | |
1132 | * - 0x24 delta_f0_2 |
|
1134 | * - 0x24 delta_f0_2 | |
1133 | * - 0x28 delta_f1 |
|
1135 | * - 0x28 delta_f1 | |
1134 | * - 0x2c delta_f2 |
|
1136 | * - 0x2c delta_f2 | |
1135 | * - 0x30 nb_data_by_buffer |
|
1137 | * - 0x30 nb_data_by_buffer | |
1136 | * - 0x34 nb_snapshot_param |
|
1138 | * - 0x34 nb_snapshot_param | |
1137 | * - 0x38 start_date |
|
1139 | * - 0x38 start_date | |
1138 | * - 0x3c nb_word_in_buffer |
|
1140 | * - 0x3c nb_word_in_buffer | |
1139 | * |
|
1141 | * | |
1140 | */ |
|
1142 | */ | |
1141 |
|
1143 | |||
1142 | set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW |
|
1144 | set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW | |
1143 |
|
1145 | |||
1144 | reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ] |
|
1146 | reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ] | |
1145 |
|
1147 | |||
1146 | reset_wfp_buffer_addresses(); |
|
1148 | reset_wfp_buffer_addresses(); | |
1147 |
|
1149 | |||
1148 | reset_wfp_status(); // 0x18 |
|
1150 | reset_wfp_status(); // 0x18 | |
1149 |
|
1151 | |||
1150 | set_wfp_delta_snapshot(); // 0x1c *** 300 s => 0x12bff |
|
1152 | set_wfp_delta_snapshot(); // 0x1c *** 300 s => 0x12bff | |
1151 |
|
1153 | |||
1152 | set_wfp_delta_f0_f0_2(); // 0x20, 0x24 |
|
1154 | set_wfp_delta_f0_f0_2(); // 0x20, 0x24 | |
1153 |
|
1155 | |||
1154 | set_wfp_delta_f1(); // 0x28 |
|
1156 | set_wfp_delta_f1(); // 0x28 | |
1155 |
|
1157 | |||
1156 | set_wfp_delta_f2(); // 0x2c |
|
1158 | set_wfp_delta_f2(); // 0x2c | |
1157 |
|
1159 | |||
1158 | DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot) |
|
1160 | DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot) | |
1159 | DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0) |
|
1161 | DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0) | |
1160 | DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2) |
|
1162 | DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2) | |
1161 | DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1) |
|
1163 | DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1) | |
1162 | DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2) |
|
1164 | DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2) | |
1163 | // 2688 = 8 * 336 |
|
1165 | // 2688 = 8 * 336 | |
1164 | waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1 |
|
1166 | waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1 | |
1165 | waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples |
|
1167 | waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples | |
1166 | waveform_picker_regs->start_date = 0x7fffffff; // 0x38 |
|
1168 | waveform_picker_regs->start_date = 0x7fffffff; // 0x38 | |
1167 | // |
|
1169 | // | |
1168 | // coarse time and fine time registers are not initialized, they are volatile |
|
1170 | // coarse time and fine time registers are not initialized, they are volatile | |
1169 | // |
|
1171 | // | |
1170 | waveform_picker_regs->buffer_length = 0x1f8;// buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8 |
|
1172 | waveform_picker_regs->buffer_length = 0x1f8;// buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8 | |
1171 | } |
|
1173 | } | |
1172 |
|
1174 | |||
1173 | void set_wfp_data_shaping( void ) |
|
1175 | void set_wfp_data_shaping( void ) | |
1174 | { |
|
1176 | { | |
1175 | /** This function sets the data_shaping register of the waveform picker module. |
|
1177 | /** This function sets the data_shaping register of the waveform picker module. | |
1176 | * |
|
1178 | * | |
1177 | * The value is read from one field of the parameter_dump_packet structure:\n |
|
1179 | * The value is read from one field of the parameter_dump_packet structure:\n | |
1178 | * bw_sp0_sp1_r0_r1 |
|
1180 | * bw_sp0_sp1_r0_r1 | |
1179 | * |
|
1181 | * | |
1180 | */ |
|
1182 | */ | |
1181 |
|
1183 | |||
1182 | unsigned char data_shaping; |
|
1184 | unsigned char data_shaping; | |
1183 |
|
1185 | |||
1184 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register |
|
1186 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register | |
1185 | // waveform picker : [R1 R0 SP1 SP0 BW] |
|
1187 | // waveform picker : [R1 R0 SP1 SP0 BW] | |
1186 |
|
1188 | |||
1187 | data_shaping = parameter_dump_packet.sy_lfr_common_parameters; |
|
1189 | data_shaping = parameter_dump_packet.sy_lfr_common_parameters; | |
1188 |
|
1190 | |||
1189 | waveform_picker_regs->data_shaping = |
|
1191 | waveform_picker_regs->data_shaping = | |
1190 | ( (data_shaping & 0x20) >> 5 ) // BW |
|
1192 | ( (data_shaping & 0x20) >> 5 ) // BW | |
1191 | + ( (data_shaping & 0x10) >> 3 ) // SP0 |
|
1193 | + ( (data_shaping & 0x10) >> 3 ) // SP0 | |
1192 | + ( (data_shaping & 0x08) >> 1 ) // SP1 |
|
1194 | + ( (data_shaping & 0x08) >> 1 ) // SP1 | |
1193 | + ( (data_shaping & 0x04) ) // R0 |
|
1195 | + ( (data_shaping & 0x04) ) // R0 | |
1194 | + ( (data_shaping & 0x02) << 3 ) // R1 |
|
1196 | + ( (data_shaping & 0x02) << 3 ) // R1 | |
1195 | + ( (data_shaping & 0x01) << 5 ); // R2 |
|
1197 | + ( (data_shaping & 0x01) << 5 ); // R2 | |
1196 | } |
|
1198 | } | |
1197 |
|
1199 | |||
1198 | void set_wfp_burst_enable_register( unsigned char mode ) |
|
1200 | void set_wfp_burst_enable_register( unsigned char mode ) | |
1199 | { |
|
1201 | { | |
1200 | /** This function sets the waveform picker burst_enable register depending on the mode. |
|
1202 | /** This function sets the waveform picker burst_enable register depending on the mode. | |
1201 | * |
|
1203 | * | |
1202 | * @param mode is the LFR mode to launch. |
|
1204 | * @param mode is the LFR mode to launch. | |
1203 | * |
|
1205 | * | |
1204 | * The burst bits shall be before the enable bits. |
|
1206 | * The burst bits shall be before the enable bits. | |
1205 | * |
|
1207 | * | |
1206 | */ |
|
1208 | */ | |
1207 |
|
1209 | |||
1208 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 |
|
1210 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 | |
1209 | // the burst bits shall be set first, before the enable bits |
|
1211 | // the burst bits shall be set first, before the enable bits | |
1210 | switch(mode) { |
|
1212 | switch(mode) { | |
1211 | case(LFR_MODE_NORMAL): |
|
1213 | case(LFR_MODE_NORMAL): | |
1212 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable |
|
1214 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable | |
1213 | waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0 |
|
1215 | waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0 | |
1214 | break; |
|
1216 | break; | |
1215 | case(LFR_MODE_BURST): |
|
1217 | case(LFR_MODE_BURST): | |
1216 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
1218 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled | |
1217 | // waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2 |
|
1219 | // waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2 | |
1218 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 AND f2 |
|
1220 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 AND f2 | |
1219 | break; |
|
1221 | break; | |
1220 | case(LFR_MODE_SBM1): |
|
1222 | case(LFR_MODE_SBM1): | |
1221 | waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled |
|
1223 | waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled | |
1222 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
1224 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 | |
1223 | break; |
|
1225 | break; | |
1224 | case(LFR_MODE_SBM2): |
|
1226 | case(LFR_MODE_SBM2): | |
1225 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
1227 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled | |
1226 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
1228 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 | |
1227 | break; |
|
1229 | break; | |
1228 | default: |
|
1230 | default: | |
1229 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled |
|
1231 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled | |
1230 | break; |
|
1232 | break; | |
1231 | } |
|
1233 | } | |
1232 | } |
|
1234 | } | |
1233 |
|
1235 | |||
1234 | void set_wfp_delta_snapshot( void ) |
|
1236 | void set_wfp_delta_snapshot( void ) | |
1235 | { |
|
1237 | { | |
1236 | /** This function sets the delta_snapshot register of the waveform picker module. |
|
1238 | /** This function sets the delta_snapshot register of the waveform picker module. | |
1237 | * |
|
1239 | * | |
1238 | * The value is read from two (unsigned char) of the parameter_dump_packet structure: |
|
1240 | * The value is read from two (unsigned char) of the parameter_dump_packet structure: | |
1239 | * - sy_lfr_n_swf_p[0] |
|
1241 | * - sy_lfr_n_swf_p[0] | |
1240 | * - sy_lfr_n_swf_p[1] |
|
1242 | * - sy_lfr_n_swf_p[1] | |
1241 | * |
|
1243 | * | |
1242 | */ |
|
1244 | */ | |
1243 |
|
1245 | |||
1244 | unsigned int delta_snapshot; |
|
1246 | unsigned int delta_snapshot; | |
1245 | unsigned int delta_snapshot_in_T2; |
|
1247 | unsigned int delta_snapshot_in_T2; | |
1246 |
|
1248 | |||
1247 | delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256 |
|
1249 | delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256 | |
1248 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; |
|
1250 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; | |
1249 |
|
1251 | |||
1250 | delta_snapshot_in_T2 = delta_snapshot * 256; |
|
1252 | delta_snapshot_in_T2 = delta_snapshot * 256; | |
1251 | waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes |
|
1253 | waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes | |
1252 | } |
|
1254 | } | |
1253 |
|
1255 | |||
1254 | void set_wfp_delta_f0_f0_2( void ) |
|
1256 | void set_wfp_delta_f0_f0_2( void ) | |
1255 | { |
|
1257 | { | |
1256 | unsigned int delta_snapshot; |
|
1258 | unsigned int delta_snapshot; | |
1257 | unsigned int nb_samples_per_snapshot; |
|
1259 | unsigned int nb_samples_per_snapshot; | |
1258 | float delta_f0_in_float; |
|
1260 | float delta_f0_in_float; | |
1259 |
|
1261 | |||
1260 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1262 | delta_snapshot = waveform_picker_regs->delta_snapshot; | |
1261 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1263 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; | |
1262 | delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.; |
|
1264 | delta_f0_in_float =nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.; | |
1263 |
|
1265 | |||
1264 | waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float ); |
|
1266 | waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float ); | |
1265 | waveform_picker_regs->delta_f0_2 = 0x30; // 48 = 11 0000, max 7 bits |
|
1267 | waveform_picker_regs->delta_f0_2 = 0x30; // 48 = 11 0000, max 7 bits | |
1266 | } |
|
1268 | } | |
1267 |
|
1269 | |||
1268 | void set_wfp_delta_f1( void ) |
|
1270 | void set_wfp_delta_f1( void ) | |
1269 | { |
|
1271 | { | |
1270 | unsigned int delta_snapshot; |
|
1272 | unsigned int delta_snapshot; | |
1271 | unsigned int nb_samples_per_snapshot; |
|
1273 | unsigned int nb_samples_per_snapshot; | |
1272 | float delta_f1_in_float; |
|
1274 | float delta_f1_in_float; | |
1273 |
|
1275 | |||
1274 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1276 | delta_snapshot = waveform_picker_regs->delta_snapshot; | |
1275 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1277 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; | |
1276 | delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.; |
|
1278 | delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.; | |
1277 |
|
1279 | |||
1278 | waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float ); |
|
1280 | waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float ); | |
1279 | } |
|
1281 | } | |
1280 |
|
1282 | |||
1281 | void set_wfp_delta_f2() |
|
1283 | void set_wfp_delta_f2() | |
1282 | { |
|
1284 | { | |
1283 | unsigned int delta_snapshot; |
|
1285 | unsigned int delta_snapshot; | |
1284 | unsigned int nb_samples_per_snapshot; |
|
1286 | unsigned int nb_samples_per_snapshot; | |
1285 |
|
1287 | |||
1286 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1288 | delta_snapshot = waveform_picker_regs->delta_snapshot; | |
1287 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1289 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; | |
1288 |
|
1290 | |||
1289 | waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2; |
|
1291 | waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2; | |
1290 | } |
|
1292 | } | |
1291 |
|
1293 | |||
1292 | //***************** |
|
1294 | //***************** | |
1293 | // local parameters |
|
1295 | // local parameters | |
1294 |
|
1296 | |||
1295 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ) |
|
1297 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ) | |
1296 | { |
|
1298 | { | |
1297 | /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument. |
|
1299 | /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument. | |
1298 | * |
|
1300 | * | |
1299 | * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update. |
|
1301 | * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update. | |
1300 | * @param sid is the source identifier of the packet being updated. |
|
1302 | * @param sid is the source identifier of the packet being updated. | |
1301 | * |
|
1303 | * | |
1302 | * REQ-LFR-SRS-5240 / SSS-CP-FS-590 |
|
1304 | * REQ-LFR-SRS-5240 / SSS-CP-FS-590 | |
1303 | * The sequence counters shall wrap around from 2^14 to zero. |
|
1305 | * The sequence counters shall wrap around from 2^14 to zero. | |
1304 | * The sequence counter shall start at zero at startup. |
|
1306 | * The sequence counter shall start at zero at startup. | |
1305 | * |
|
1307 | * | |
1306 | * REQ-LFR-SRS-5239 / SSS-CP-FS-580 |
|
1308 | * REQ-LFR-SRS-5239 / SSS-CP-FS-580 | |
1307 | * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0 |
|
1309 | * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0 | |
1308 | * |
|
1310 | * | |
1309 | */ |
|
1311 | */ | |
1310 |
|
1312 | |||
1311 | unsigned short *sequence_cnt; |
|
1313 | unsigned short *sequence_cnt; | |
1312 | unsigned short segmentation_grouping_flag; |
|
1314 | unsigned short segmentation_grouping_flag; | |
1313 | unsigned short new_packet_sequence_control; |
|
1315 | unsigned short new_packet_sequence_control; | |
1314 | rtems_mode initial_mode_set; |
|
1316 | rtems_mode initial_mode_set; | |
1315 | rtems_mode current_mode_set; |
|
1317 | rtems_mode current_mode_set; | |
1316 | rtems_status_code status; |
|
1318 | rtems_status_code status; | |
1317 |
|
1319 | |||
1318 | //****************************************** |
|
1320 | //****************************************** | |
1319 | // CHANGE THE MODE OF THE CALLING RTEMS TASK |
|
1321 | // CHANGE THE MODE OF THE CALLING RTEMS TASK | |
1320 | status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set ); |
|
1322 | status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set ); | |
1321 |
|
1323 | |||
1322 | if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2) |
|
1324 | if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2) | |
1323 | || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3) |
|
1325 | || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3) | |
1324 | || (sid == SID_BURST_CWF_F2) |
|
1326 | || (sid == SID_BURST_CWF_F2) | |
1325 | || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2) |
|
1327 | || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2) | |
1326 | || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2) |
|
1328 | || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2) | |
1327 | || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2) |
|
1329 | || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2) | |
1328 | || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0) |
|
1330 | || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0) | |
1329 | || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) ) |
|
1331 | || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) ) | |
1330 | { |
|
1332 | { | |
1331 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST; |
|
1333 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST; | |
1332 | } |
|
1334 | } | |
1333 | else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) |
|
1335 | else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) | |
1334 | || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0) |
|
1336 | || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0) | |
1335 | || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0) |
|
1337 | || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0) | |
1336 | || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) ) |
|
1338 | || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) ) | |
1337 | { |
|
1339 | { | |
1338 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2; |
|
1340 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2; | |
1339 | } |
|
1341 | } | |
1340 | else |
|
1342 | else | |
1341 | { |
|
1343 | { | |
1342 | sequence_cnt = (unsigned short *) NULL; |
|
1344 | sequence_cnt = (unsigned short *) NULL; | |
1343 | PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid) |
|
1345 | PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid) | |
1344 | } |
|
1346 | } | |
1345 |
|
1347 | |||
1346 | if (sequence_cnt != NULL) |
|
1348 | if (sequence_cnt != NULL) | |
1347 | { |
|
1349 | { | |
1348 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
1350 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; | |
1349 | *sequence_cnt = (*sequence_cnt) & 0x3fff; |
|
1351 | *sequence_cnt = (*sequence_cnt) & 0x3fff; | |
1350 |
|
1352 | |||
1351 | new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ; |
|
1353 | new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ; | |
1352 |
|
1354 | |||
1353 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); |
|
1355 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); | |
1354 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); |
|
1356 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); | |
1355 |
|
1357 | |||
1356 | // increment the sequence counter |
|
1358 | // increment the sequence counter | |
1357 | if ( *sequence_cnt < SEQ_CNT_MAX) |
|
1359 | if ( *sequence_cnt < SEQ_CNT_MAX) | |
1358 | { |
|
1360 | { | |
1359 | *sequence_cnt = *sequence_cnt + 1; |
|
1361 | *sequence_cnt = *sequence_cnt + 1; | |
1360 | } |
|
1362 | } | |
1361 | else |
|
1363 | else | |
1362 | { |
|
1364 | { | |
1363 | *sequence_cnt = 0; |
|
1365 | *sequence_cnt = 0; | |
1364 | } |
|
1366 | } | |
1365 | } |
|
1367 | } | |
1366 |
|
1368 | |||
1367 | //*********************************** |
|
1369 | //*********************************** | |
1368 | // RESET THE MODE OF THE CALLING TASK |
|
1370 | // RESET THE MODE OF THE CALLING TASK | |
1369 | status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, ¤t_mode_set ); |
|
1371 | status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, ¤t_mode_set ); | |
1370 | } |
|
1372 | } |
General Comments 0
You need to be logged in to leave comments.
Login now