##// END OF EJS Templates
fsw-0-20
paul -
r58:95058e78e811 default
parent child
Show More
@@ -1,211 +1,211
1 #ifndef FSW_PARAMS_H_INCLUDED
1 #ifndef FSW_PARAMS_H_INCLUDED
2 #define FSW_PARAMS_H_INCLUDED
2 #define FSW_PARAMS_H_INCLUDED
3
3
4 #include "grlib_regs.h"
4 #include "grlib_regs.h"
5 #include "fsw_params_processing.h"
5 #include "fsw_params_processing.h"
6 #include "tm_byte_positions.h"
6 #include "tm_byte_positions.h"
7 #include "ccsds_types.h"
7 #include "ccsds_types.h"
8
8
9 #define GRSPW_DEVICE_NAME "/dev/grspw0"
9 #define GRSPW_DEVICE_NAME "/dev/grspw0"
10 #define UART_DEVICE_NAME "/dev/console"
10 #define UART_DEVICE_NAME "/dev/console"
11
11
12 //************************
12 //************************
13 // flight software version
13 // flight software version
14 // this parameters is handled by the Qt project options
14 // this parameters is handled by the Qt project options
15
15
16 //**********
16 //**********
17 // LFR MODES
17 // LFR MODES
18 #define LFR_MODE_STANDBY 0
18 #define LFR_MODE_STANDBY 0
19 #define LFR_MODE_NORMAL 1
19 #define LFR_MODE_NORMAL 1
20 #define LFR_MODE_BURST 2
20 #define LFR_MODE_BURST 2
21 #define LFR_MODE_SBM1 3
21 #define LFR_MODE_SBM1 3
22 #define LFR_MODE_SBM2 4
22 #define LFR_MODE_SBM2 4
23 #define LFR_MODE_NORMAL_CWF_F3 5
23 #define LFR_MODE_NORMAL_CWF_F3 5
24
24
25 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
25 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
26 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
26 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
27 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
27 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
28 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
28 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
29 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
29 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
30 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
30 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
31
31
32 //****************************
32 //****************************
33 // LFR DEFAULT MODE PARAMETERS
33 // LFR DEFAULT MODE PARAMETERS
34 // COMMON
34 // COMMON
35 #define DEFAULT_SY_LFR_COMMON0 0x00
35 #define DEFAULT_SY_LFR_COMMON0 0x00
36 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
36 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
37 // NORM
37 // NORM
38 #define SY_LFR_N_SWF_L 2048 // nb sample
38 #define SY_LFR_N_SWF_L 2048 // nb sample
39 #define SY_LFR_N_SWF_P 300 // sec
39 #define SY_LFR_N_SWF_P 296 // sec
40 #define SY_LFR_N_ASM_P 3600 // sec
40 #define SY_LFR_N_ASM_P 3600 // sec
41 #define SY_LFR_N_BP_P0 4 // sec
41 #define SY_LFR_N_BP_P0 4 // sec
42 #define SY_LFR_N_BP_P1 20 // sec
42 #define SY_LFR_N_BP_P1 20 // sec
43 #define MIN_DELTA_SNAPSHOT 16 // sec
43 #define MIN_DELTA_SNAPSHOT 16 // sec
44 // BURST
44 // BURST
45 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
45 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
46 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
46 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
47 // SBM1
47 // SBM1
48 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
48 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
49 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
49 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
50 // SBM2
50 // SBM2
51 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
51 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
52 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
52 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
53 // ADDITIONAL PARAMETERS
53 // ADDITIONAL PARAMETERS
54 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
54 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
55 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
55 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
56 // STATUS WORD
56 // STATUS WORD
57 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
57 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
58 #define DEFAULT_STATUS_WORD_BYTE1 0x00
58 #define DEFAULT_STATUS_WORD_BYTE1 0x00
59 //
59 //
60 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
60 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
61 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
61 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
62 //****************************
62 //****************************
63
63
64 //*****************************
64 //*****************************
65 // APB REGISTERS BASE ADDRESSES
65 // APB REGISTERS BASE ADDRESSES
66 #define REGS_ADDR_APBUART 0x80000100
66 #define REGS_ADDR_APBUART 0x80000100
67 #define REGS_ADDR_GPTIMER 0x80000300
67 #define REGS_ADDR_GPTIMER 0x80000300
68 #define REGS_ADDR_GRSPW 0x80000500
68 #define REGS_ADDR_GRSPW 0x80000500
69 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
69 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
70 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
70 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
71
71
72 #ifdef GSA
72 #ifdef GSA
73 #else
73 #else
74 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f20
74 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f20
75 #endif
75 #endif
76
76
77 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
77 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
78 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50)
78 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50)
79
79
80 //**********
80 //**********
81 // IRQ LINES
81 // IRQ LINES
82 #define IRQ_SM 9
82 #define IRQ_SM 9
83 #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels
83 #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels
84 #define IRQ_WF 10
84 #define IRQ_WF 10
85 #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels
85 #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels
86 #define IRQ_TIME1 12
86 #define IRQ_TIME1 12
87 #define IRQ_SPARC_TIME1 0x1c // see sparcv8.pdf p.76 for interrupt levels
87 #define IRQ_SPARC_TIME1 0x1c // see sparcv8.pdf p.76 for interrupt levels
88 #define IRQ_TIME2 13
88 #define IRQ_TIME2 13
89 #define IRQ_SPARC_TIME2 0x1d // see sparcv8.pdf p.76 for interrupt levels
89 #define IRQ_SPARC_TIME2 0x1d // see sparcv8.pdf p.76 for interrupt levels
90 #define IRQ_WAVEFORM_PICKER 14
90 #define IRQ_WAVEFORM_PICKER 14
91 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
91 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
92 #define IRQ_SPECTRAL_MATRIX 6
92 #define IRQ_SPECTRAL_MATRIX 6
93 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
93 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
94
94
95 //*****
95 //*****
96 // TIME
96 // TIME
97 #define CLKDIV_SM_SIMULATOR (10000 - 1) // 10 ms
97 #define CLKDIV_SM_SIMULATOR (10000 - 1) // 10 ms
98 #define CLKDIV_WF_SIMULATOR (10000000 - 1) // 10 000 000 * 1 us = 10 s
98 #define CLKDIV_WF_SIMULATOR (10000000 - 1) // 10 000 000 * 1 us = 10 s
99 #define TIMER_SM_SIMULATOR 1
99 #define TIMER_SM_SIMULATOR 1
100 #define TIMER_WF_SIMULATOR 2
100 #define TIMER_WF_SIMULATOR 2
101 #define HK_PERIOD 100 // 100 * 10ms => 1sec
101 #define HK_PERIOD 100 // 100 * 10ms => 1sec
102
102
103 //**********
103 //**********
104 // LPP CODES
104 // LPP CODES
105 #define LFR_SUCCESSFUL 0
105 #define LFR_SUCCESSFUL 0
106 #define LFR_DEFAULT 1
106 #define LFR_DEFAULT 1
107
107
108 //******
108 //******
109 // RTEMS
109 // RTEMS
110 #define TASKID_RECV 1
110 #define TASKID_RECV 1
111 #define TASKID_ACTN 2
111 #define TASKID_ACTN 2
112 #define TASKID_SPIQ 3
112 #define TASKID_SPIQ 3
113 #define TASKID_SMIQ 4
113 #define TASKID_SMIQ 4
114 #define TASKID_STAT 5
114 #define TASKID_STAT 5
115 #define TASKID_AVF0 6
115 #define TASKID_AVF0 6
116 #define TASKID_BPF0 7
116 #define TASKID_BPF0 7
117 #define TASKID_WFRM 8
117 #define TASKID_WFRM 8
118 #define TASKID_DUMB 9
118 #define TASKID_DUMB 9
119 #define TASKID_HOUS 10
119 #define TASKID_HOUS 10
120 #define TASKID_MATR 11
120 #define TASKID_MATR 11
121 #define TASKID_CWF3 12
121 #define TASKID_CWF3 12
122 #define TASKID_CWF2 13
122 #define TASKID_CWF2 13
123 #define TASKID_CWF1 14
123 #define TASKID_CWF1 14
124 #define TASKID_SEND 15
124 #define TASKID_SEND 15
125 #define TASKID_WTDG 16
125 #define TASKID_WTDG 16
126
126
127 #define TASK_PRIORITY_SPIQ 5
127 #define TASK_PRIORITY_SPIQ 5
128 #define TASK_PRIORITY_SMIQ 10
128 #define TASK_PRIORITY_SMIQ 10
129 //
129 //
130 #define TASK_PRIORITY_WTDG 20
130 #define TASK_PRIORITY_WTDG 20
131 //
131 //
132 #define TASK_PRIORITY_HOUS 30
132 #define TASK_PRIORITY_HOUS 30
133 //
133 //
134 #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together
134 #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together
135 #define TASK_PRIORITY_CWF2 35 //
135 #define TASK_PRIORITY_CWF2 35 //
136 //
136 //
137 #define TASK_PRIORITY_WFRM 40
137 #define TASK_PRIORITY_WFRM 40
138 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1
138 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1
139 //
139 //
140 #define TASK_PRIORITY_SEND 45
140 #define TASK_PRIORITY_SEND 45
141 //
141 //
142 #define TASK_PRIORITY_RECV 50
142 #define TASK_PRIORITY_RECV 50
143 #define TASK_PRIORITY_ACTN 50
143 #define TASK_PRIORITY_ACTN 50
144 //
144 //
145 #define TASK_PRIORITY_AVF0 60
145 #define TASK_PRIORITY_AVF0 60
146 #define TASK_PRIORITY_BPF0 60
146 #define TASK_PRIORITY_BPF0 60
147 #define TASK_PRIORITY_MATR 100
147 #define TASK_PRIORITY_MATR 100
148 #define TASK_PRIORITY_STAT 200
148 #define TASK_PRIORITY_STAT 200
149 #define TASK_PRIORITY_DUMB 200
149 #define TASK_PRIORITY_DUMB 200
150
150
151 #define SEMQ_PRIORITY_CEILING 30
151 #define SEMQ_PRIORITY_CEILING 30
152
152
153 #define ACTION_MSG_QUEUE_COUNT 10
153 #define ACTION_MSG_QUEUE_COUNT 10
154 #define ACTION_MSG_PKTS_COUNT 50
154 #define ACTION_MSG_PKTS_COUNT 50
155 #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
155 #define ACTION_MSG_PKTS_MAX_SIZE (PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES)
156 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
156 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
157
157
158 #define QUEUE_RECV 0
158 #define QUEUE_RECV 0
159 #define QUEUE_SEND 1
159 #define QUEUE_SEND 1
160
160
161 //*******
161 //*******
162 // MACROS
162 // MACROS
163 #ifdef PRINT_MESSAGES_ON_CONSOLE
163 #ifdef PRINT_MESSAGES_ON_CONSOLE
164 #define PRINTF(x) printf(x);
164 #define PRINTF(x) printf(x);
165 #define PRINTF1(x,y) printf(x,y);
165 #define PRINTF1(x,y) printf(x,y);
166 #define PRINTF2(x,y,z) printf(x,y,z);
166 #define PRINTF2(x,y,z) printf(x,y,z);
167 #else
167 #else
168 #define PRINTF(x) ;
168 #define PRINTF(x) ;
169 #define PRINTF1(x,y) ;
169 #define PRINTF1(x,y) ;
170 #define PRINTF2(x,y,z) ;
170 #define PRINTF2(x,y,z) ;
171 #endif
171 #endif
172
172
173 #ifdef BOOT_MESSAGES
173 #ifdef BOOT_MESSAGES
174 #define BOOT_PRINTF(x) printf(x);
174 #define BOOT_PRINTF(x) printf(x);
175 #define BOOT_PRINTF1(x,y) printf(x,y);
175 #define BOOT_PRINTF1(x,y) printf(x,y);
176 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
176 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
177 #else
177 #else
178 #define BOOT_PRINTF(x) ;
178 #define BOOT_PRINTF(x) ;
179 #define BOOT_PRINTF1(x,y) ;
179 #define BOOT_PRINTF1(x,y) ;
180 #define BOOT_PRINTF2(x,y,z) ;
180 #define BOOT_PRINTF2(x,y,z) ;
181 #endif
181 #endif
182
182
183 #ifdef DEBUG_MESSAGES
183 #ifdef DEBUG_MESSAGES
184 #define DEBUG_PRINTF(x) printf(x);
184 #define DEBUG_PRINTF(x) printf(x);
185 #define DEBUG_PRINTF1(x,y) printf(x,y);
185 #define DEBUG_PRINTF1(x,y) printf(x,y);
186 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
186 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
187 #else
187 #else
188 #define DEBUG_PRINTF(x) ;
188 #define DEBUG_PRINTF(x) ;
189 #define DEBUG_PRINTF1(x,y) ;
189 #define DEBUG_PRINTF1(x,y) ;
190 #define DEBUG_PRINTF2(x,y,z) ;
190 #define DEBUG_PRINTF2(x,y,z) ;
191 #endif
191 #endif
192
192
193 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
193 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
194
194
195 #define NB_SAMPLES_PER_SNAPSHOT 2048
195 #define NB_SAMPLES_PER_SNAPSHOT 2048
196 #define TIME_OFFSET 2
196 #define TIME_OFFSET 2
197 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
197 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
198 #define NB_BYTES_SWF_BLK (2 * 6)
198 #define NB_BYTES_SWF_BLK (2 * 6)
199 #define NB_WORDS_SWF_BLK 3
199 #define NB_WORDS_SWF_BLK 3
200 #define NB_BYTES_CWF3_LIGHT_BLK 6
200 #define NB_BYTES_CWF3_LIGHT_BLK 6
201 #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8
201 #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8
202
202
203 struct param_local_str{
203 struct param_local_str{
204 unsigned int local_sbm1_nb_cwf_sent;
204 unsigned int local_sbm1_nb_cwf_sent;
205 unsigned int local_sbm1_nb_cwf_max;
205 unsigned int local_sbm1_nb_cwf_max;
206 unsigned int local_sbm2_nb_cwf_sent;
206 unsigned int local_sbm2_nb_cwf_sent;
207 unsigned int local_sbm2_nb_cwf_max;
207 unsigned int local_sbm2_nb_cwf_max;
208 unsigned int local_nb_interrupt_f0_MAX;
208 unsigned int local_nb_interrupt_f0_MAX;
209 };
209 };
210
210
211 #endif // FSW_PARAMS_H_INCLUDED
211 #endif // FSW_PARAMS_H_INCLUDED
@@ -1,586 +1,586
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_MAXIMUM_DRIVERS 16
35 #define CONFIGURE_MAXIMUM_DRIVERS 16
36 #define CONFIGURE_MAXIMUM_PERIODS 5
36 #define CONFIGURE_MAXIMUM_PERIODS 5
37 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
37 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
38 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2
38 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2
39 #ifdef PRINT_STACK_REPORT
39 #ifdef PRINT_STACK_REPORT
40 #define CONFIGURE_STACK_CHECKER_ENABLED
40 #define CONFIGURE_STACK_CHECKER_ENABLED
41 #endif
41 #endif
42
42
43 #include <rtems/confdefs.h>
43 #include <rtems/confdefs.h>
44
44
45 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
45 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
46 #ifdef RTEMS_DRVMGR_STARTUP
46 #ifdef RTEMS_DRVMGR_STARTUP
47 #ifdef LEON3
47 #ifdef LEON3
48 /* Add Timer and UART Driver */
48 /* Add Timer and UART Driver */
49 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
49 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
50 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
50 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
51 #endif
51 #endif
52 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
52 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
53 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
53 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
54 #endif
54 #endif
55 #endif
55 #endif
56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
57 #include <drvmgr/drvmgr_confdefs.h>
57 #include <drvmgr/drvmgr_confdefs.h>
58 #endif
58 #endif
59
59
60 #include "fsw_init.h"
60 #include "fsw_init.h"
61 #include "fsw_config.c"
61 #include "fsw_config.c"
62
62
63 rtems_task Init( rtems_task_argument ignored )
63 rtems_task Init( rtems_task_argument ignored )
64 {
64 {
65 /** This is the RTEMS INIT taks, it the first task launched by the system.
65 /** This is the RTEMS INIT taks, it the first task launched by the system.
66 *
66 *
67 * @param unused is the starting argument of the RTEMS task
67 * @param unused is the starting argument of the RTEMS task
68 *
68 *
69 * The INIT task create and run all other RTEMS tasks.
69 * The INIT task create and run all other RTEMS tasks.
70 *
70 *
71 */
71 */
72
72
73
73
74 rtems_status_code status;
74 rtems_status_code status;
75 rtems_status_code status_spw;
75 rtems_status_code status_spw;
76 rtems_isr_entry old_isr_handler;
76 rtems_isr_entry old_isr_handler;
77
77
78 BOOT_PRINTF("\n\n\n\n\n")
78 BOOT_PRINTF("\n\n\n\n\n")
79 BOOT_PRINTF("***************************\n")
79 BOOT_PRINTF("***************************\n")
80 BOOT_PRINTF("** START Flight Software **\n")
80 BOOT_PRINTF("** START Flight Software **\n")
81 BOOT_PRINTF("***************************\n")
81 BOOT_PRINTF("***************************\n")
82 BOOT_PRINTF("\n\n")
82 BOOT_PRINTF("\n\n")
83
83
84 //send_console_outputs_on_apbuart_port();
84 //send_console_outputs_on_apbuart_port();
85 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
85 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
86
86
87 reset_wfp_burst_enable(); // stop the waveform picker if it was running
87 reset_wfp_burst_enable(); // stop the waveform picker if it was running
88
88
89 init_parameter_dump();
89 init_parameter_dump();
90 init_local_mode_parameters();
90 init_local_mode_parameters();
91 init_housekeeping_parameters();
91 init_housekeeping_parameters();
92
92
93 updateLFRCurrentMode();
93 updateLFRCurrentMode();
94
94
95 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
95 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
96
96
97 create_names(); // create all names
97 create_names(); // create all names
98
98
99 status = create_message_queues(); // create message queues
99 status = create_message_queues(); // create message queues
100 if (status != RTEMS_SUCCESSFUL)
100 if (status != RTEMS_SUCCESSFUL)
101 {
101 {
102 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
102 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
103 }
103 }
104
104
105 status = create_all_tasks(); // create all tasks
105 status = create_all_tasks(); // create all tasks
106 if (status != RTEMS_SUCCESSFUL)
106 if (status != RTEMS_SUCCESSFUL)
107 {
107 {
108 PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status)
108 PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status)
109 }
109 }
110
110
111 // **************************
111 // **************************
112 // <SPACEWIRE INITIALIZATION>
112 // <SPACEWIRE INITIALIZATION>
113 grspw_timecode_callback = &timecode_irq_handler;
113 grspw_timecode_callback = &timecode_irq_handler;
114
114
115 status_spw = spacewire_open_link(); // (1) open the link
115 status_spw = spacewire_open_link(); // (1) open the link
116 if ( status_spw != RTEMS_SUCCESSFUL )
116 if ( status_spw != RTEMS_SUCCESSFUL )
117 {
117 {
118 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
118 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
119 }
119 }
120
120
121 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
121 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
122 {
122 {
123 status_spw = spacewire_configure_link( fdSPW );
123 status_spw = spacewire_configure_link( fdSPW );
124 if ( status_spw != RTEMS_SUCCESSFUL )
124 if ( status_spw != RTEMS_SUCCESSFUL )
125 {
125 {
126 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
126 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
127 }
127 }
128 }
128 }
129
129
130 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
130 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
131 {
131 {
132 status_spw = spacewire_start_link( fdSPW );
132 status_spw = spacewire_start_link( fdSPW );
133 if ( status_spw != RTEMS_SUCCESSFUL )
133 if ( status_spw != RTEMS_SUCCESSFUL )
134 {
134 {
135 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
135 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
136 }
136 }
137 }
137 }
138 // </SPACEWIRE INITIALIZATION>
138 // </SPACEWIRE INITIALIZATION>
139 // ***************************
139 // ***************************
140
140
141 status = start_all_tasks(); // start all tasks
141 status = start_all_tasks(); // start all tasks
142 if (status != RTEMS_SUCCESSFUL)
142 if (status != RTEMS_SUCCESSFUL)
143 {
143 {
144 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
144 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
145 }
145 }
146
146
147 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
147 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
148 status = start_recv_send_tasks();
148 status = start_recv_send_tasks();
149 if ( status != RTEMS_SUCCESSFUL )
149 if ( status != RTEMS_SUCCESSFUL )
150 {
150 {
151 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
151 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
152 }
152 }
153
153
154 // suspend science tasks. they will be restarted later depending on the mode
154 // suspend science tasks. they will be restarted later depending on the mode
155 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
155 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
156 if (status != RTEMS_SUCCESSFUL)
156 if (status != RTEMS_SUCCESSFUL)
157 {
157 {
158 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
158 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
159 }
159 }
160
160
161 #ifdef GSA
161 #ifdef GSA
162 // mask IRQ lines
162 // mask IRQ lines
163 LEON_Mask_interrupt( IRQ_SM );
163 LEON_Mask_interrupt( IRQ_SM );
164 LEON_Mask_interrupt( IRQ_WF );
164 LEON_Mask_interrupt( IRQ_WF );
165 // Spectral Matrices simulator
165 // Spectral Matrices simulator
166 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
166 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
167 IRQ_SPARC_SM, spectral_matrices_isr );
167 IRQ_SPARC_SM, spectral_matrices_isr );
168 // WaveForms
168 // WaveForms
169 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
169 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
170 IRQ_SPARC_WF, waveforms_simulator_isr );
170 IRQ_SPARC_WF, waveforms_simulator_isr );
171 #else
171 #else
172 // configure IRQ handling for the waveform picker unit
172 // configure IRQ handling for the waveform picker unit
173 status = rtems_interrupt_catch( waveforms_isr,
173 status = rtems_interrupt_catch( waveforms_isr,
174 IRQ_SPARC_WAVEFORM_PICKER,
174 IRQ_SPARC_WAVEFORM_PICKER,
175 &old_isr_handler) ;
175 &old_isr_handler) ;
176 #endif
176 #endif
177
177
178 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
178 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
179 if ( status_spw != RTEMS_SUCCESSFUL )
179 if ( status_spw != RTEMS_SUCCESSFUL )
180 {
180 {
181 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
181 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
182 if ( status != RTEMS_SUCCESSFUL ) {
182 if ( status != RTEMS_SUCCESSFUL ) {
183 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
183 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
184 }
184 }
185 }
185 }
186
186
187 BOOT_PRINTF("delete INIT\n")
187 BOOT_PRINTF("delete INIT\n")
188
188
189 status = rtems_task_delete(RTEMS_SELF);
189 status = rtems_task_delete(RTEMS_SELF);
190
190
191 }
191 }
192
192
193 void init_local_mode_parameters( void )
193 void init_local_mode_parameters( void )
194 {
194 {
195 /** This function initialize the param_local global variable with default values.
195 /** This function initialize the param_local global variable with default values.
196 *
196 *
197 */
197 */
198
198
199 unsigned int i;
199 unsigned int i;
200
200
201 // LOCAL PARAMETERS
201 // LOCAL PARAMETERS
202 set_local_sbm1_nb_cwf_max();
202 set_local_sbm1_nb_cwf_max();
203 set_local_sbm2_nb_cwf_max();
203 set_local_sbm2_nb_cwf_max();
204 set_local_nb_interrupt_f0_MAX();
204 set_local_nb_interrupt_f0_MAX();
205
205
206 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
206 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
207 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
207 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
208 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
208 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
209
209
210 reset_local_sbm1_nb_cwf_sent();
210 reset_local_sbm1_nb_cwf_sent();
211 reset_local_sbm2_nb_cwf_sent();
211 reset_local_sbm2_nb_cwf_sent();
212
212
213 // init sequence counters
213 // init sequence counters
214
214
215 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
215 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
216 {
216 {
217 sequenceCounters_TC_EXE[i] = 0x00;
217 sequenceCounters_TC_EXE[i] = 0x00;
218 }
218 }
219 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
219 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
220 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
220 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
221 }
221 }
222
222
223 void create_names( void ) // create all names for tasks and queues
223 void create_names( void ) // create all names for tasks and queues
224 {
224 {
225 /** This function creates all RTEMS names used in the software for tasks and queues.
225 /** This function creates all RTEMS names used in the software for tasks and queues.
226 *
226 *
227 * @return RTEMS directive status codes:
227 * @return RTEMS directive status codes:
228 * - RTEMS_SUCCESSFUL - successful completion
228 * - RTEMS_SUCCESSFUL - successful completion
229 *
229 *
230 */
230 */
231
231
232 // task names
232 // task names
233 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
233 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
234 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
234 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
235 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
235 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
236 Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' );
236 Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' );
237 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
237 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
238 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
238 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
239 Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' );
239 Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' );
240 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
240 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
241 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
241 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
242 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
242 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
243 Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' );
243 Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' );
244 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
244 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
245 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
245 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
246 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
246 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
247 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
247 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
248 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
248 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
249
249
250 // rate monotonic period names
250 // rate monotonic period names
251 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
251 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
252
252
253 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
253 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
254 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
254 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
255 }
255 }
256
256
257 int create_all_tasks( void ) // create all tasks which run in the software
257 int create_all_tasks( void ) // create all tasks which run in the software
258 {
258 {
259 /** This function creates all RTEMS tasks used in the software.
259 /** This function creates all RTEMS tasks used in the software.
260 *
260 *
261 * @return RTEMS directive status codes:
261 * @return RTEMS directive status codes:
262 * - RTEMS_SUCCESSFUL - task created successfully
262 * - RTEMS_SUCCESSFUL - task created successfully
263 * - RTEMS_INVALID_ADDRESS - id is NULL
263 * - RTEMS_INVALID_ADDRESS - id is NULL
264 * - RTEMS_INVALID_NAME - invalid task name
264 * - RTEMS_INVALID_NAME - invalid task name
265 * - RTEMS_INVALID_PRIORITY - invalid task priority
265 * - RTEMS_INVALID_PRIORITY - invalid task priority
266 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
266 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
267 * - RTEMS_TOO_MANY - too many tasks created
267 * - RTEMS_TOO_MANY - too many tasks created
268 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
268 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
269 * - RTEMS_TOO_MANY - too many global objects
269 * - RTEMS_TOO_MANY - too many global objects
270 *
270 *
271 */
271 */
272
272
273 rtems_status_code status;
273 rtems_status_code status;
274
274
275 // RECV
275 // RECV
276 status = rtems_task_create(
276 status = rtems_task_create(
277 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
277 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
278 RTEMS_DEFAULT_MODES,
278 RTEMS_DEFAULT_MODES,
279 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
279 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
280 );
280 );
281
281
282 if (status == RTEMS_SUCCESSFUL) // ACTN
282 if (status == RTEMS_SUCCESSFUL) // ACTN
283 {
283 {
284 status = rtems_task_create(
284 status = rtems_task_create(
285 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
285 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
286 RTEMS_DEFAULT_MODES,
286 RTEMS_DEFAULT_MODES,
287 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
287 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
288 );
288 );
289 }
289 }
290 if (status == RTEMS_SUCCESSFUL) // SPIQ
290 if (status == RTEMS_SUCCESSFUL) // SPIQ
291 {
291 {
292 status = rtems_task_create(
292 status = rtems_task_create(
293 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
293 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
294 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
294 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
295 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
295 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
296 );
296 );
297 }
297 }
298 if (status == RTEMS_SUCCESSFUL) // SMIQ
298 if (status == RTEMS_SUCCESSFUL) // SMIQ
299 {
299 {
300 status = rtems_task_create(
300 status = rtems_task_create(
301 Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE,
301 Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE,
302 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
302 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
303 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
303 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
304 );
304 );
305 }
305 }
306 if (status == RTEMS_SUCCESSFUL) // STAT
306 if (status == RTEMS_SUCCESSFUL) // STAT
307 {
307 {
308 status = rtems_task_create(
308 status = rtems_task_create(
309 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
309 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
310 RTEMS_DEFAULT_MODES,
310 RTEMS_DEFAULT_MODES,
311 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
311 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
312 );
312 );
313 }
313 }
314 if (status == RTEMS_SUCCESSFUL) // AVF0
314 if (status == RTEMS_SUCCESSFUL) // AVF0
315 {
315 {
316 status = rtems_task_create(
316 status = rtems_task_create(
317 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
317 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
318 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
318 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
319 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
319 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
320 );
320 );
321 }
321 }
322 if (status == RTEMS_SUCCESSFUL) // BPF0
322 if (status == RTEMS_SUCCESSFUL) // BPF0
323 {
323 {
324 status = rtems_task_create(
324 status = rtems_task_create(
325 Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE,
325 Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE,
326 RTEMS_DEFAULT_MODES,
326 RTEMS_DEFAULT_MODES,
327 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0]
327 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0]
328 );
328 );
329 }
329 }
330 if (status == RTEMS_SUCCESSFUL) // WFRM
330 if (status == RTEMS_SUCCESSFUL) // WFRM
331 {
331 {
332 status = rtems_task_create(
332 status = rtems_task_create(
333 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
333 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
334 RTEMS_DEFAULT_MODES,
334 RTEMS_DEFAULT_MODES,
335 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
335 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
336 );
336 );
337 }
337 }
338 if (status == RTEMS_SUCCESSFUL) // DUMB
338 if (status == RTEMS_SUCCESSFUL) // DUMB
339 {
339 {
340 status = rtems_task_create(
340 status = rtems_task_create(
341 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
341 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
342 RTEMS_DEFAULT_MODES,
342 RTEMS_DEFAULT_MODES,
343 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
343 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
344 );
344 );
345 }
345 }
346 if (status == RTEMS_SUCCESSFUL) // HOUS
346 if (status == RTEMS_SUCCESSFUL) // HOUS
347 {
347 {
348 status = rtems_task_create(
348 status = rtems_task_create(
349 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
349 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
350 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
350 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
351 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
351 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
352 );
352 );
353 }
353 }
354 if (status == RTEMS_SUCCESSFUL) // MATR
354 if (status == RTEMS_SUCCESSFUL) // MATR
355 {
355 {
356 status = rtems_task_create(
356 status = rtems_task_create(
357 Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE,
357 Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE,
358 RTEMS_DEFAULT_MODES,
358 RTEMS_DEFAULT_MODES,
359 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR]
359 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR]
360 );
360 );
361 }
361 }
362 if (status == RTEMS_SUCCESSFUL) // CWF3
362 if (status == RTEMS_SUCCESSFUL) // CWF3
363 {
363 {
364 status = rtems_task_create(
364 status = rtems_task_create(
365 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
365 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
366 RTEMS_DEFAULT_MODES,
366 RTEMS_DEFAULT_MODES,
367 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF3]
367 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF3]
368 );
368 );
369 }
369 }
370 if (status == RTEMS_SUCCESSFUL) // CWF2
370 if (status == RTEMS_SUCCESSFUL) // CWF2
371 {
371 {
372 status = rtems_task_create(
372 status = rtems_task_create(
373 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
373 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
374 RTEMS_DEFAULT_MODES,
374 RTEMS_DEFAULT_MODES,
375 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF2]
375 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF2]
376 );
376 );
377 }
377 }
378 if (status == RTEMS_SUCCESSFUL) // CWF1
378 if (status == RTEMS_SUCCESSFUL) // CWF1
379 {
379 {
380 status = rtems_task_create(
380 status = rtems_task_create(
381 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
381 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
382 RTEMS_DEFAULT_MODES,
382 RTEMS_DEFAULT_MODES,
383 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF1]
383 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF1]
384 );
384 );
385 }
385 }
386 if (status == RTEMS_SUCCESSFUL) // SEND
386 if (status == RTEMS_SUCCESSFUL) // SEND
387 {
387 {
388 status = rtems_task_create(
388 status = rtems_task_create(
389 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
389 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
390 RTEMS_DEFAULT_MODES,
390 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
391 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
391 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
392 );
392 );
393 }
393 }
394 if (status == RTEMS_SUCCESSFUL) // WTDG
394 if (status == RTEMS_SUCCESSFUL) // WTDG
395 {
395 {
396 status = rtems_task_create(
396 status = rtems_task_create(
397 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
397 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
398 RTEMS_DEFAULT_MODES,
398 RTEMS_DEFAULT_MODES,
399 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
399 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
400 );
400 );
401 }
401 }
402
402
403 return status;
403 return status;
404 }
404 }
405
405
406 int start_recv_send_tasks( void )
406 int start_recv_send_tasks( void )
407 {
407 {
408 rtems_status_code status;
408 rtems_status_code status;
409
409
410 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
410 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
411 if (status!=RTEMS_SUCCESSFUL) {
411 if (status!=RTEMS_SUCCESSFUL) {
412 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
412 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
413 }
413 }
414
414
415 if (status == RTEMS_SUCCESSFUL) // SEND
415 if (status == RTEMS_SUCCESSFUL) // SEND
416 {
416 {
417 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
417 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
418 if (status!=RTEMS_SUCCESSFUL) {
418 if (status!=RTEMS_SUCCESSFUL) {
419 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
419 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
420 }
420 }
421 }
421 }
422
422
423 return status;
423 return status;
424 }
424 }
425
425
426 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
426 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
427 {
427 {
428 /** This function starts all RTEMS tasks used in the software.
428 /** This function starts all RTEMS tasks used in the software.
429 *
429 *
430 * @return RTEMS directive status codes:
430 * @return RTEMS directive status codes:
431 * - RTEMS_SUCCESSFUL - ask started successfully
431 * - RTEMS_SUCCESSFUL - ask started successfully
432 * - RTEMS_INVALID_ADDRESS - invalid task entry point
432 * - RTEMS_INVALID_ADDRESS - invalid task entry point
433 * - RTEMS_INVALID_ID - invalid task id
433 * - RTEMS_INVALID_ID - invalid task id
434 * - RTEMS_INCORRECT_STATE - task not in the dormant state
434 * - RTEMS_INCORRECT_STATE - task not in the dormant state
435 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
435 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
436 *
436 *
437 */
437 */
438 // starts all the tasks fot eh flight software
438 // starts all the tasks fot eh flight software
439
439
440 rtems_status_code status;
440 rtems_status_code status;
441
441
442 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
442 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
443 if (status!=RTEMS_SUCCESSFUL) {
443 if (status!=RTEMS_SUCCESSFUL) {
444 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
444 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
445 }
445 }
446
446
447 if (status == RTEMS_SUCCESSFUL) // WTDG
447 if (status == RTEMS_SUCCESSFUL) // WTDG
448 {
448 {
449 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
449 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
450 if (status!=RTEMS_SUCCESSFUL) {
450 if (status!=RTEMS_SUCCESSFUL) {
451 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
451 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
452 }
452 }
453 }
453 }
454
454
455 if (status == RTEMS_SUCCESSFUL) // SMIQ
455 if (status == RTEMS_SUCCESSFUL) // SMIQ
456 {
456 {
457 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
457 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
458 if (status!=RTEMS_SUCCESSFUL) {
458 if (status!=RTEMS_SUCCESSFUL) {
459 BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n")
459 BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n")
460 }
460 }
461 }
461 }
462
462
463 if (status == RTEMS_SUCCESSFUL) // ACTN
463 if (status == RTEMS_SUCCESSFUL) // ACTN
464 {
464 {
465 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
465 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
466 if (status!=RTEMS_SUCCESSFUL) {
466 if (status!=RTEMS_SUCCESSFUL) {
467 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
467 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
468 }
468 }
469 }
469 }
470
470
471 if (status == RTEMS_SUCCESSFUL) // STAT
471 if (status == RTEMS_SUCCESSFUL) // STAT
472 {
472 {
473 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
473 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
474 if (status!=RTEMS_SUCCESSFUL) {
474 if (status!=RTEMS_SUCCESSFUL) {
475 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
475 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
476 }
476 }
477 }
477 }
478
478
479 if (status == RTEMS_SUCCESSFUL) // AVF0
479 if (status == RTEMS_SUCCESSFUL) // AVF0
480 {
480 {
481 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
481 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
482 if (status!=RTEMS_SUCCESSFUL) {
482 if (status!=RTEMS_SUCCESSFUL) {
483 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
483 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
484 }
484 }
485 }
485 }
486
486
487 if (status == RTEMS_SUCCESSFUL) // BPF0
487 if (status == RTEMS_SUCCESSFUL) // BPF0
488 {
488 {
489 status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 );
489 status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 );
490 if (status!=RTEMS_SUCCESSFUL) {
490 if (status!=RTEMS_SUCCESSFUL) {
491 BOOT_PRINTF("in INIT *** Error starting TASK_BPF0\n")
491 BOOT_PRINTF("in INIT *** Error starting TASK_BPF0\n")
492 }
492 }
493 }
493 }
494
494
495 if (status == RTEMS_SUCCESSFUL) // WFRM
495 if (status == RTEMS_SUCCESSFUL) // WFRM
496 {
496 {
497 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
497 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
498 if (status!=RTEMS_SUCCESSFUL) {
498 if (status!=RTEMS_SUCCESSFUL) {
499 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
499 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
500 }
500 }
501 }
501 }
502
502
503 if (status == RTEMS_SUCCESSFUL) // DUMB
503 if (status == RTEMS_SUCCESSFUL) // DUMB
504 {
504 {
505 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
505 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
506 if (status!=RTEMS_SUCCESSFUL) {
506 if (status!=RTEMS_SUCCESSFUL) {
507 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
507 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
508 }
508 }
509 }
509 }
510
510
511 if (status == RTEMS_SUCCESSFUL) // HOUS
511 if (status == RTEMS_SUCCESSFUL) // HOUS
512 {
512 {
513 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
513 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
514 if (status!=RTEMS_SUCCESSFUL) {
514 if (status!=RTEMS_SUCCESSFUL) {
515 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
515 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
516 }
516 }
517 }
517 }
518
518
519 if (status == RTEMS_SUCCESSFUL) // MATR
519 if (status == RTEMS_SUCCESSFUL) // MATR
520 {
520 {
521 status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 );
521 status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 );
522 if (status!=RTEMS_SUCCESSFUL) {
522 if (status!=RTEMS_SUCCESSFUL) {
523 BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n")
523 BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n")
524 }
524 }
525 }
525 }
526
526
527 if (status == RTEMS_SUCCESSFUL) // CWF3
527 if (status == RTEMS_SUCCESSFUL) // CWF3
528 {
528 {
529 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
529 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
530 if (status!=RTEMS_SUCCESSFUL) {
530 if (status!=RTEMS_SUCCESSFUL) {
531 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
531 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
532 }
532 }
533 }
533 }
534
534
535 if (status == RTEMS_SUCCESSFUL) // CWF2
535 if (status == RTEMS_SUCCESSFUL) // CWF2
536 {
536 {
537 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
537 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
538 if (status!=RTEMS_SUCCESSFUL) {
538 if (status!=RTEMS_SUCCESSFUL) {
539 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
539 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
540 }
540 }
541 }
541 }
542
542
543 if (status == RTEMS_SUCCESSFUL) // CWF1
543 if (status == RTEMS_SUCCESSFUL) // CWF1
544 {
544 {
545 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
545 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
546 if (status!=RTEMS_SUCCESSFUL) {
546 if (status!=RTEMS_SUCCESSFUL) {
547 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
547 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
548 }
548 }
549 }
549 }
550 return status;
550 return status;
551 }
551 }
552
552
553 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
553 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
554 {
554 {
555 rtems_status_code status_recv;
555 rtems_status_code status_recv;
556 rtems_status_code status_send;
556 rtems_status_code status_send;
557 rtems_status_code ret;
557 rtems_status_code ret;
558 rtems_id queue_id;
558 rtems_id queue_id;
559
559
560 // create the queue for handling valid TCs
560 // create the queue for handling valid TCs
561 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
561 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
562 ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
562 ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
563 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
563 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
564 if ( status_recv != RTEMS_SUCCESSFUL ) {
564 if ( status_recv != RTEMS_SUCCESSFUL ) {
565 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
565 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
566 }
566 }
567
567
568 // create the queue for handling TM packet sending
568 // create the queue for handling TM packet sending
569 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
569 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
570 ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_MAX_SIZE,
570 ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_MAX_SIZE,
571 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
571 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
572 if ( status_send != RTEMS_SUCCESSFUL ) {
572 if ( status_send != RTEMS_SUCCESSFUL ) {
573 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
573 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
574 }
574 }
575
575
576 if ( status_recv != RTEMS_SUCCESSFUL )
576 if ( status_recv != RTEMS_SUCCESSFUL )
577 {
577 {
578 ret = status_recv;
578 ret = status_recv;
579 }
579 }
580 else
580 else
581 {
581 {
582 ret = status_send;
582 ret = status_send;
583 }
583 }
584
584
585 return ret;
585 return ret;
586 }
586 }
@@ -1,623 +1,612
1 /** Functions related to the SpaceWire interface.
1 /** Functions related to the SpaceWire interface.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle SpaceWire transmissions:
6 * A group of functions to handle SpaceWire transmissions:
7 * - configuration of the SpaceWire link
7 * - configuration of the SpaceWire link
8 * - SpaceWire related interruption requests processing
8 * - SpaceWire related interruption requests processing
9 * - transmission of TeleMetry packets by a dedicated RTEMS task
9 * - transmission of TeleMetry packets by a dedicated RTEMS task
10 * - reception of TeleCommands by a dedicated RTEMS task
10 * - reception of TeleCommands by a dedicated RTEMS task
11 *
11 *
12 */
12 */
13
13
14 #include "fsw_spacewire.h"
14 #include "fsw_spacewire.h"
15
15
16 char *lstates[6] = {"Error-reset",
16 char *lstates[6] = {"Error-reset",
17 "Error-wait",
17 "Error-wait",
18 "Ready",
18 "Ready",
19 "Started",
19 "Started",
20 "Connecting",
20 "Connecting",
21 "Run"
21 "Run"
22 };
22 };
23
23
24 rtems_name semq_name;
24 rtems_name semq_name;
25 rtems_id semq_id;
25 rtems_id semq_id;
26
26
27 //***********
27 //***********
28 // RTEMS TASK
28 // RTEMS TASK
29 rtems_task spiq_task(rtems_task_argument unused)
29 rtems_task spiq_task(rtems_task_argument unused)
30 {
30 {
31 /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver.
31 /** This RTEMS task is awaken by an rtems_event sent by the interruption subroutine of the SpaceWire driver.
32 *
32 *
33 * @param unused is the starting argument of the RTEMS task
33 * @param unused is the starting argument of the RTEMS task
34 *
34 *
35 */
35 */
36
36
37 rtems_event_set event_out;
37 rtems_event_set event_out;
38 rtems_status_code status;
38 rtems_status_code status;
39 int linkStatus;
39 int linkStatus;
40
40
41 BOOT_PRINTF("in SPIQ *** \n")
41 BOOT_PRINTF("in SPIQ *** \n")
42
42
43 while(true){
43 while(true){
44 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
44 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
45 PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n")
45 PRINTF("in SPIQ *** got SPW_LINKERR_EVENT\n")
46
46
47 // [0] SUSPEND RECV AND SEND TASKS
47 // [0] SUSPEND RECV AND SEND TASKS
48 rtems_task_suspend( Task_id[ TASKID_RECV ] );
48 rtems_task_suspend( Task_id[ TASKID_RECV ] );
49 rtems_task_suspend( Task_id[ TASKID_SEND ] );
49 rtems_task_suspend( Task_id[ TASKID_SEND ] );
50
50
51 // [1] CHECK THE LINK
51 // [1] CHECK THE LINK
52 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1)
52 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (1)
53 if ( linkStatus != 5) {
53 if ( linkStatus != 5) {
54 PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus)
54 PRINTF1("in SPIQ *** linkStatus %d, wait...\n", linkStatus)
55 rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms
55 rtems_task_wake_after( SY_LFR_DPU_CONNECT_TIMEOUT ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 1000 ms
56 }
56 }
57
57
58 // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT
58 // [2] RECHECK THE LINK AFTER SY_LFR_DPU_CONNECT_TIMEOUT
59 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2)
59 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status (2)
60 if ( linkStatus != 5 ) // [2.a] not in run state, reset the link
60 if ( linkStatus != 5 ) // [2.a] not in run state, reset the link
61 {
61 {
62 spacewire_compute_stats_offsets();
62 spacewire_compute_stats_offsets();
63 status = spacewire_reset_link( );
63 status = spacewire_reset_link( );
64 }
64 }
65 else // [2.b] in run state, start the link
65 else // [2.b] in run state, start the link
66 {
66 {
67 status = spacewire_stop_start_link( fdSPW ); // start the link
67 status = spacewire_stop_start_link( fdSPW ); // start the link
68 if ( status != RTEMS_SUCCESSFUL)
68 if ( status != RTEMS_SUCCESSFUL)
69 {
69 {
70 PRINTF1("in SPIQ *** ERR spacewire_start_link %d\n", status)
70 PRINTF1("in SPIQ *** ERR spacewire_start_link %d\n", status)
71 }
71 }
72 }
72 }
73
73
74 // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS
74 // [3] COMPLETE RECOVERY ACTION AFTER SY_LFR_DPU_CONNECT_ATTEMPTS
75 if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully
75 if ( status == RTEMS_SUCCESSFUL ) // [3.a] the link is in run state and has been started successfully
76 {
76 {
77 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
77 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
78 if ( status != RTEMS_SUCCESSFUL ) {
78 if ( status != RTEMS_SUCCESSFUL ) {
79 PRINTF("in SPIQ *** ERR resuming SEND Task\n")
79 PRINTF("in SPIQ *** ERR resuming SEND Task\n")
80 }
80 }
81 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
81 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
82 if ( status != RTEMS_SUCCESSFUL ) {
82 if ( status != RTEMS_SUCCESSFUL ) {
83 PRINTF("in SPIQ *** ERR resuming RECV Task\n")
83 PRINTF("in SPIQ *** ERR resuming RECV Task\n")
84 }
84 }
85 }
85 }
86 else // [3.b] the link is not in run state, go in STANDBY mode
86 else // [3.b] the link is not in run state, go in STANDBY mode
87 {
87 {
88 status = stop_current_mode();
88 status = stop_current_mode();
89 if ( status != RTEMS_SUCCESSFUL ) {
89 if ( status != RTEMS_SUCCESSFUL ) {
90 PRINTF1("in SPIQ *** ERR stop_current_mode *** code %d\n", status)
90 PRINTF1("in SPIQ *** ERR stop_current_mode *** code %d\n", status)
91 }
91 }
92 status = enter_standby_mode();
92 status = enter_standby_mode();
93 if ( status != RTEMS_SUCCESSFUL ) {
93 if ( status != RTEMS_SUCCESSFUL ) {
94 PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status)
94 PRINTF1("in SPIQ *** ERR enter_standby_mode *** code %d\n", status)
95 }
95 }
96 // wake the WTDG task up to wait for the link recovery
96 // wake the WTDG task up to wait for the link recovery
97 status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 );
97 status = rtems_event_send ( Task_id[TASKID_WTDG], RTEMS_EVENT_0 );
98 rtems_task_suspend( RTEMS_SELF );
98 rtems_task_suspend( RTEMS_SELF );
99 }
99 }
100 }
100 }
101 }
101 }
102
102
103 rtems_task recv_task( rtems_task_argument unused )
103 rtems_task recv_task( rtems_task_argument unused )
104 {
104 {
105 /** This RTEMS task is dedicated to the reception of incoming TeleCommands.
105 /** This RTEMS task is dedicated to the reception of incoming TeleCommands.
106 *
106 *
107 * @param unused is the starting argument of the RTEMS task
107 * @param unused is the starting argument of the RTEMS task
108 *
108 *
109 * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked:
109 * The RECV task blocks on a call to the read system call, waiting for incoming SpaceWire data. When unblocked:
110 * 1. It reads the incoming data.
110 * 1. It reads the incoming data.
111 * 2. Launches the acceptance procedure.
111 * 2. Launches the acceptance procedure.
112 * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue.
112 * 3. If the Telecommand is valid, sends it to a dedicated RTEMS message queue.
113 *
113 *
114 */
114 */
115
115
116 int len;
116 int len;
117 ccsdsTelecommandPacket_t currentTC;
117 ccsdsTelecommandPacket_t currentTC;
118 unsigned char computed_CRC[ 2 ];
118 unsigned char computed_CRC[ 2 ];
119 unsigned char currentTC_LEN_RCV[ 2 ];
119 unsigned char currentTC_LEN_RCV[ 2 ];
120 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
120 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
121 unsigned int parserCode;
121 unsigned int parserCode;
122 rtems_status_code status;
122 rtems_status_code status;
123 rtems_id queue_recv_id;
123 rtems_id queue_recv_id;
124 rtems_id queue_send_id;
124 rtems_id queue_send_id;
125
125
126 initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes
126 initLookUpTableForCRC(); // the table is used to compute Cyclic Redundancy Codes
127
127
128 status = rtems_message_queue_ident( misc_name[QUEUE_RECV], 0, &queue_recv_id );
128 status = rtems_message_queue_ident( misc_name[QUEUE_RECV], 0, &queue_recv_id );
129 if (status != RTEMS_SUCCESSFUL)
129 if (status != RTEMS_SUCCESSFUL)
130 {
130 {
131 PRINTF1("in RECV *** ERR getting QUEUE_RECV id, %d\n", status)
131 PRINTF1("in RECV *** ERR getting QUEUE_RECV id, %d\n", status)
132 }
132 }
133
133
134 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_send_id );
134 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_send_id );
135 if (status != RTEMS_SUCCESSFUL)
135 if (status != RTEMS_SUCCESSFUL)
136 {
136 {
137 PRINTF1("in RECV *** ERR getting QUEUE_SEND id, %d\n", status)
137 PRINTF1("in RECV *** ERR getting QUEUE_SEND id, %d\n", status)
138 }
138 }
139
139
140 BOOT_PRINTF("in RECV *** \n")
140 BOOT_PRINTF("in RECV *** \n")
141
141
142 while(1)
142 while(1)
143 {
143 {
144 len = read( fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking
144 len = read( fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE ); // the call to read is blocking
145 if (len == -1){ // error during the read call
145 if (len == -1){ // error during the read call
146 PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno)
146 PRINTF1("in RECV *** last read call returned -1, ERRNO %d\n", errno)
147 }
147 }
148 else {
148 else {
149 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
149 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
150 PRINTF("in RECV *** packet lenght too short\n")
150 PRINTF("in RECV *** packet lenght too short\n")
151 }
151 }
152 else {
152 else {
153 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
153 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
154 currentTC_LEN_RCV[ 0 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt >> 8);
154 currentTC_LEN_RCV[ 0 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt >> 8);
155 currentTC_LEN_RCV[ 1 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt );
155 currentTC_LEN_RCV[ 1 ] = (unsigned char) (currentTC_LEN_RCV_AsUnsignedInt );
156 // CHECK THE TC
156 // CHECK THE TC
157 parserCode = tc_parser( &currentTC, currentTC_LEN_RCV_AsUnsignedInt, computed_CRC ) ;
157 parserCode = tc_parser( &currentTC, currentTC_LEN_RCV_AsUnsignedInt, computed_CRC ) ;
158 if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT)
158 if ( (parserCode == ILLEGAL_APID) || (parserCode == WRONG_LEN_PKT)
159 || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE)
159 || (parserCode == INCOR_CHECKSUM) || (parserCode == ILL_TYPE)
160 || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA)
160 || (parserCode == ILL_SUBTYPE) || (parserCode == WRONG_APP_DATA)
161 || (parserCode == WRONG_SRC_ID) )
161 || (parserCode == WRONG_SRC_ID) )
162 { // send TM_LFR_TC_EXE_CORRUPTED
162 { // send TM_LFR_TC_EXE_CORRUPTED
163 if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) )
163 if ( !( (currentTC.serviceType==TC_TYPE_TIME) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_TIME) )
164 &&
164 &&
165 !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO))
165 !( (currentTC.serviceType==TC_TYPE_GEN) && (currentTC.serviceSubType==TC_SUBTYPE_UPDT_INFO))
166 )
166 )
167 {
167 {
168 send_tm_lfr_tc_exe_corrupted( &currentTC, queue_send_id, computed_CRC, currentTC_LEN_RCV );
168 send_tm_lfr_tc_exe_corrupted( &currentTC, queue_send_id, computed_CRC, currentTC_LEN_RCV );
169 }
169 }
170 }
170 }
171 else
171 else
172 { // send valid TC to the action launcher
172 { // send valid TC to the action launcher
173 status = rtems_message_queue_send( queue_recv_id, &currentTC,
173 status = rtems_message_queue_send( queue_recv_id, &currentTC,
174 currentTC_LEN_RCV_AsUnsignedInt + CCSDS_TC_TM_PACKET_OFFSET + 3);
174 currentTC_LEN_RCV_AsUnsignedInt + CCSDS_TC_TM_PACKET_OFFSET + 3);
175 }
175 }
176 }
176 }
177 }
177 }
178 }
178 }
179 }
179 }
180
180
181 rtems_task send_task( rtems_task_argument argument)
181 rtems_task send_task( rtems_task_argument argument)
182 {
182 {
183 /** This RTEMS task is dedicated to the transmission of TeleMetry packets.
183 /** This RTEMS task is dedicated to the transmission of TeleMetry packets.
184 *
184 *
185 * @param unused is the starting argument of the RTEMS task
185 * @param unused is the starting argument of the RTEMS task
186 *
186 *
187 * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives:
187 * The SEND task waits for a message to become available in the dedicated RTEMS queue. When a message arrives:
188 * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call.
188 * - if the first byte is equal to CCSDS_DESTINATION_ID, the message is sent as is using the write system call.
189 * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After
189 * - if the first byte is not equal to CCSDS_DESTINATION_ID, the message is handled as a spw_ioctl_pkt_send. After
190 * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the
190 * analyzis, the packet is sent either using the write system call or using the ioctl call SPACEWIRE_IOCTRL_SEND, depending on the
191 * data it contains.
191 * data it contains.
192 *
192 *
193 */
193 */
194
194
195 rtems_status_code status; // RTEMS status code
195 rtems_status_code status; // RTEMS status code
196 char incomingData[ACTION_MSG_PKTS_MAX_SIZE]; // incoming data buffer
196 char incomingData[ACTION_MSG_PKTS_MAX_SIZE]; // incoming data buffer
197 spw_ioctl_pkt_send *spw_ioctl_send;
197 spw_ioctl_pkt_send *spw_ioctl_send;
198 size_t size; // size of the incoming TC packet
198 size_t size; // size of the incoming TC packet
199 u_int32_t count;
199 u_int32_t count;
200 rtems_id queue_id;
200 rtems_id queue_id;
201
201
202 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_id );
202 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_id );
203 if (status != RTEMS_SUCCESSFUL)
203 if (status != RTEMS_SUCCESSFUL)
204 {
204 {
205 PRINTF1("in SEND *** ERR getting queue id, %d\n", status)
205 PRINTF1("in SEND *** ERR getting queue id, %d\n", status)
206 }
206 }
207
207
208 BOOT_PRINTF("in SEND *** \n")
208 BOOT_PRINTF("in SEND *** \n")
209
209
210 while(1)
210 while(1)
211 {
211 {
212 status = rtems_message_queue_receive( queue_id, incomingData, &size,
212 status = rtems_message_queue_receive( queue_id, incomingData, &size,
213 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
213 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
214
214
215 if (status!=RTEMS_SUCCESSFUL)
215 if (status!=RTEMS_SUCCESSFUL)
216 {
216 {
217 PRINTF1("in SEND *** (1) ERR = %d\n", status)
217 PRINTF1("in SEND *** (1) ERR = %d\n", status)
218 }
218 }
219 else
219 else
220 {
220 {
221 if ( incomingData[0] == CCSDS_DESTINATION_ID) // the incoming message is a ccsds packet
221 if ( incomingData[0] == CCSDS_DESTINATION_ID) // the incoming message is a ccsds packet
222 {
222 {
223 status = write( fdSPW, incomingData, size );
223 status = write( fdSPW, incomingData, size );
224 if (status == -1){
224 if (status == -1){
225 PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size)
225 PRINTF2("in SEND *** (2.a) ERRNO = %d, size = %d\n", errno, size)
226 }
226 }
227 }
227 }
228 else // the incoming message is a spw_ioctl_pkt_send structure
228 else // the incoming message is a spw_ioctl_pkt_send structure
229 {
229 {
230 spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData;
230 spw_ioctl_send = (spw_ioctl_pkt_send*) incomingData;
231 if (spw_ioctl_send->hlen == 0)
231 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
232 {
232 if (status == -1){
233 status = write( fdSPW, spw_ioctl_send->data, spw_ioctl_send->dlen );
233 PRINTF2("in SEND *** (2.b) ERRNO = %d, RTEMS = %d\n", errno, status)
234 if (status == -1){
235 PRINTF2("in SEND *** (2.b) ERRNO = %d, dlen = %d\n", errno, spw_ioctl_send->dlen)
236 }
237 }
238 else
239 {
240 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
241 if (status == -1){
242 PRINTF2("in SEND *** (2.c) ERRNO = %d, dlen = %d\n", errno, spw_ioctl_send->dlen)
243 PRINTF1(" hlen = %d\n", spw_ioctl_send->hlen)
244 }
245 }
234 }
246 }
235 }
247 }
236 }
248
237
249 status = rtems_message_queue_get_number_pending( queue_id, &count );
238 status = rtems_message_queue_get_number_pending( queue_id, &count );
250 if (status != RTEMS_SUCCESSFUL)
239 if (status != RTEMS_SUCCESSFUL)
251 {
240 {
252 PRINTF1("in SEND *** (3) ERR = %d\n", status)
241 PRINTF1("in SEND *** (3) ERR = %d\n", status)
253 }
242 }
254 else
243 else
255 {
244 {
256 if (count > maxCount)
245 if (count > maxCount)
257 {
246 {
258 maxCount = count;
247 maxCount = count;
259 }
248 }
260 }
249 }
261 }
250 }
262 }
251 }
263
252
264 rtems_task wtdg_task( rtems_task_argument argument )
253 rtems_task wtdg_task( rtems_task_argument argument )
265 {
254 {
266 rtems_event_set event_out;
255 rtems_event_set event_out;
267 rtems_status_code status;
256 rtems_status_code status;
268 int linkStatus;
257 int linkStatus;
269
258
270 BOOT_PRINTF("in WTDG ***\n")
259 BOOT_PRINTF("in WTDG ***\n")
271
260
272 while(1)
261 while(1)
273 {
262 {
274 // wait for an RTEMS_EVENT
263 // wait for an RTEMS_EVENT
275 rtems_event_receive( RTEMS_EVENT_0,
264 rtems_event_receive( RTEMS_EVENT_0,
276 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
265 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
277 PRINTF("in WTDG *** wait for the link\n")
266 PRINTF("in WTDG *** wait for the link\n")
278 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
267 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
279 while( linkStatus != 5) // wait for the link
268 while( linkStatus != 5) // wait for the link
280 {
269 {
281 rtems_task_wake_after( 10 );
270 rtems_task_wake_after( 10 );
282 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
271 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
283 }
272 }
284
273
285 status = spacewire_stop_start_link( fdSPW );
274 status = spacewire_stop_start_link( fdSPW );
286
275
287 if (status != RTEMS_SUCCESSFUL)
276 if (status != RTEMS_SUCCESSFUL)
288 {
277 {
289 PRINTF1("in WTDG *** ERR link not started %d\n", status)
278 PRINTF1("in WTDG *** ERR link not started %d\n", status)
290 }
279 }
291 else
280 else
292 {
281 {
293 PRINTF("in WTDG *** OK link started\n")
282 PRINTF("in WTDG *** OK link started\n")
294 }
283 }
295
284
296 // restart the SPIQ task
285 // restart the SPIQ task
297 status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 );
286 status = rtems_task_restart( Task_id[TASKID_SPIQ], 1 );
298 if ( status != RTEMS_SUCCESSFUL ) {
287 if ( status != RTEMS_SUCCESSFUL ) {
299 PRINTF("in SPIQ *** ERR restarting SPIQ Task\n")
288 PRINTF("in SPIQ *** ERR restarting SPIQ Task\n")
300 }
289 }
301
290
302 // restart RECV and SEND
291 // restart RECV and SEND
303 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
292 status = rtems_task_restart( Task_id[ TASKID_SEND ], 1 );
304 if ( status != RTEMS_SUCCESSFUL ) {
293 if ( status != RTEMS_SUCCESSFUL ) {
305 PRINTF("in SPIQ *** ERR restarting SEND Task\n")
294 PRINTF("in SPIQ *** ERR restarting SEND Task\n")
306 }
295 }
307 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
296 status = rtems_task_restart( Task_id[ TASKID_RECV ], 1 );
308 if ( status != RTEMS_SUCCESSFUL ) {
297 if ( status != RTEMS_SUCCESSFUL ) {
309 PRINTF("in SPIQ *** ERR restarting RECV Task\n")
298 PRINTF("in SPIQ *** ERR restarting RECV Task\n")
310 }
299 }
311 }
300 }
312 }
301 }
313
302
314 //****************
303 //****************
315 // OTHER FUNCTIONS
304 // OTHER FUNCTIONS
316 int spacewire_open_link( void )
305 int spacewire_open_link( void )
317 {
306 {
318 /** This function opens the SpaceWire link.
307 /** This function opens the SpaceWire link.
319 *
308 *
320 * @return a valid file descriptor in case of success, -1 in case of a failure
309 * @return a valid file descriptor in case of success, -1 in case of a failure
321 *
310 *
322 */
311 */
323 rtems_status_code status;
312 rtems_status_code status;
324
313
325 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware
314 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call resets the hardware
326 if ( fdSPW < 0 ) {
315 if ( fdSPW < 0 ) {
327 PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno)
316 PRINTF1("ERR *** in configure_spw_link *** error opening "GRSPW_DEVICE_NAME" with ERR %d\n", errno)
328 }
317 }
329 else
318 else
330 {
319 {
331 status = RTEMS_SUCCESSFUL;
320 status = RTEMS_SUCCESSFUL;
332 }
321 }
333
322
334 return status;
323 return status;
335 }
324 }
336
325
337 int spacewire_start_link( int fd )
326 int spacewire_start_link( int fd )
338 {
327 {
339 rtems_status_code status;
328 rtems_status_code status;
340
329
341 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
330 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
342 // -1 default hardcoded driver timeout
331 // -1 default hardcoded driver timeout
343
332
344 return status;
333 return status;
345 }
334 }
346
335
347 int spacewire_stop_start_link( int fd )
336 int spacewire_stop_start_link( int fd )
348 {
337 {
349 rtems_status_code status;
338 rtems_status_code status;
350
339
351 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0
340 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_STOP); // start fails if link pDev->running != 0
352 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
341 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_START, -1); // returns successfuly if the link is started
353 // -1 default hardcoded driver timeout
342 // -1 default hardcoded driver timeout
354
343
355 return status;
344 return status;
356 }
345 }
357
346
358 int spacewire_configure_link( int fd )
347 int spacewire_configure_link( int fd )
359 {
348 {
360 /** This function configures the SpaceWire link.
349 /** This function configures the SpaceWire link.
361 *
350 *
362 * @return GR-RTEMS-DRIVER directive status codes:
351 * @return GR-RTEMS-DRIVER directive status codes:
363 * - 22 EINVAL - Null pointer or an out of range value was given as the argument.
352 * - 22 EINVAL - Null pointer or an out of range value was given as the argument.
364 * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode.
353 * - 16 EBUSY - Only used for SEND. Returned when no descriptors are avialble in non-blocking mode.
365 * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used.
354 * - 88 ENOSYS - Returned for SET_DESTKEY if RMAP command handler is not available or if a non-implemented call is used.
366 * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up.
355 * - 116 ETIMEDOUT - REturned for SET_PACKET_SIZE and START if the link could not be brought up.
367 * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers.
356 * - 12 ENOMEM - Returned for SET_PACKETSIZE if it was unable to allocate the new buffers.
368 * - 5 EIO - Error when writing to grswp hardware registers.
357 * - 5 EIO - Error when writing to grswp hardware registers.
369 * - 2 ENOENT - No such file or directory
358 * - 2 ENOENT - No such file or directory
370 */
359 */
371
360
372 rtems_status_code status;
361 rtems_status_code status;
373
362
374 spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force
363 spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force
375 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
364 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
376
365
377 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
366 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
378 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
367 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
379 //
368 //
380 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
369 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
381 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
370 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
382 //
371 //
383 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
372 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
384 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
373 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
385 //
374 //
386 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
375 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
387 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
376 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
388 //
377 //
389 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks
378 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks
390 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n")
379 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n")
391 //
380 //
392 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available
381 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // transmission blocks when no transmission descriptor is available
393 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
382 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
394 //
383 //
395 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ]
384 status = ioctl(fd, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ]
396 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
385 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
397
386
398 return status;
387 return status;
399 }
388 }
400
389
401 int spacewire_reset_link( void )
390 int spacewire_reset_link( void )
402 {
391 {
403 /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver.
392 /** This function is executed by the SPIQ rtems_task wehn it has been awaken by an interruption raised by the SpaceWire driver.
404 *
393 *
405 * @return RTEMS directive status code:
394 * @return RTEMS directive status code:
406 * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s.
395 * - RTEMS_UNSATISFIED is returned is the link is not in the running state after 10 s.
407 * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout.
396 * - RTEMS_SUCCESSFUL is returned if the link is up before the timeout.
408 *
397 *
409 */
398 */
410
399
411 rtems_status_code status_spw;
400 rtems_status_code status_spw;
412 int i;
401 int i;
413
402
414 for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ )
403 for ( i=0; i<SY_LFR_DPU_CONNECT_ATTEMPT; i++ )
415 {
404 {
416 PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i);
405 PRINTF1("in spacewire_reset_link *** link recovery, try %d\n", i);
417
406
418 // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM
407 // CLOSING THE DRIVER AT THIS POINT WILL MAKE THE SEND TASK BLOCK THE SYSTEM
419
408
420 status_spw = spacewire_stop_start_link( fdSPW );
409 status_spw = spacewire_stop_start_link( fdSPW );
421 if ( status_spw != RTEMS_SUCCESSFUL )
410 if ( status_spw != RTEMS_SUCCESSFUL )
422 {
411 {
423 PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw)
412 PRINTF1("in spacewire_reset_link *** ERR spacewire_start_link code %d\n", status_spw)
424 }
413 }
425
414
426 if ( status_spw == RTEMS_SUCCESSFUL)
415 if ( status_spw == RTEMS_SUCCESSFUL)
427 {
416 {
428 break;
417 break;
429 }
418 }
430 }
419 }
431
420
432 return status_spw;
421 return status_spw;
433 }
422 }
434
423
435 void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force
424 void spacewire_set_NP( unsigned char val, unsigned int regAddr ) // [N]o [P]ort force
436 {
425 {
437 /** This function sets the [N]o [P]ort force bit of the GRSPW control register.
426 /** This function sets the [N]o [P]ort force bit of the GRSPW control register.
438 *
427 *
439 * @param val is the value, 0 or 1, used to set the value of the NP bit.
428 * @param val is the value, 0 or 1, used to set the value of the NP bit.
440 * @param regAddr is the address of the GRSPW control register.
429 * @param regAddr is the address of the GRSPW control register.
441 *
430 *
442 * NP is the bit 20 of the GRSPW control register.
431 * NP is the bit 20 of the GRSPW control register.
443 *
432 *
444 */
433 */
445
434
446 unsigned int *spwptr = (unsigned int*) regAddr;
435 unsigned int *spwptr = (unsigned int*) regAddr;
447
436
448 if (val == 1) {
437 if (val == 1) {
449 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
438 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
450 }
439 }
451 if (val== 0) {
440 if (val== 0) {
452 *spwptr = *spwptr & 0xffdfffff;
441 *spwptr = *spwptr & 0xffdfffff;
453 }
442 }
454 }
443 }
455
444
456 void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable
445 void spacewire_set_RE( unsigned char val, unsigned int regAddr ) // [R]MAP [E]nable
457 {
446 {
458 /** This function sets the [R]MAP [E]nable bit of the GRSPW control register.
447 /** This function sets the [R]MAP [E]nable bit of the GRSPW control register.
459 *
448 *
460 * @param val is the value, 0 or 1, used to set the value of the RE bit.
449 * @param val is the value, 0 or 1, used to set the value of the RE bit.
461 * @param regAddr is the address of the GRSPW control register.
450 * @param regAddr is the address of the GRSPW control register.
462 *
451 *
463 * RE is the bit 16 of the GRSPW control register.
452 * RE is the bit 16 of the GRSPW control register.
464 *
453 *
465 */
454 */
466
455
467 unsigned int *spwptr = (unsigned int*) regAddr;
456 unsigned int *spwptr = (unsigned int*) regAddr;
468
457
469 if (val == 1)
458 if (val == 1)
470 {
459 {
471 *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit
460 *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit
472 }
461 }
473 if (val== 0)
462 if (val== 0)
474 {
463 {
475 *spwptr = *spwptr & 0xfffdffff;
464 *spwptr = *spwptr & 0xfffdffff;
476 }
465 }
477 }
466 }
478
467
479 void spacewire_compute_stats_offsets( void )
468 void spacewire_compute_stats_offsets( void )
480 {
469 {
481 /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising.
470 /** This function computes the SpaceWire statistics offsets in case of a SpaceWire related interruption raising.
482 *
471 *
483 * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics
472 * The offsets keep a record of the statistics in case of a reset of the statistics. They are added to the current statistics
484 * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it
473 * to keep the counters consistent even after a reset of the SpaceWire driver (the counter are set to zero by the driver when it
485 * during the open systel call).
474 * during the open systel call).
486 *
475 *
487 */
476 */
488
477
489 spw_stats spacewire_stats_grspw;
478 spw_stats spacewire_stats_grspw;
490 rtems_status_code status;
479 rtems_status_code status;
491
480
492 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
481 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
493
482
494 spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received
483 spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received
495 + spacewire_stats.packets_received;
484 + spacewire_stats.packets_received;
496 spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent
485 spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent
497 + spacewire_stats.packets_sent;
486 + spacewire_stats.packets_sent;
498 spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err
487 spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err
499 + spacewire_stats.parity_err;
488 + spacewire_stats.parity_err;
500 spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err
489 spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err
501 + spacewire_stats.disconnect_err;
490 + spacewire_stats.disconnect_err;
502 spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err
491 spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err
503 + spacewire_stats.escape_err;
492 + spacewire_stats.escape_err;
504 spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err
493 spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err
505 + spacewire_stats.credit_err;
494 + spacewire_stats.credit_err;
506 spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err
495 spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err
507 + spacewire_stats.write_sync_err;
496 + spacewire_stats.write_sync_err;
508 spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err
497 spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err
509 + spacewire_stats.rx_rmap_header_crc_err;
498 + spacewire_stats.rx_rmap_header_crc_err;
510 spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err
499 spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err
511 + spacewire_stats.rx_rmap_data_crc_err;
500 + spacewire_stats.rx_rmap_data_crc_err;
512 spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep
501 spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep
513 + spacewire_stats.early_ep;
502 + spacewire_stats.early_ep;
514 spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address
503 spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address
515 + spacewire_stats.invalid_address;
504 + spacewire_stats.invalid_address;
516 spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err
505 spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err
517 + spacewire_stats.rx_eep_err;
506 + spacewire_stats.rx_eep_err;
518 spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated
507 spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated
519 + spacewire_stats.rx_truncated;
508 + spacewire_stats.rx_truncated;
520 }
509 }
521
510
522 void spacewire_update_statistics( void )
511 void spacewire_update_statistics( void )
523 {
512 {
524 rtems_status_code status;
513 rtems_status_code status;
525 spw_stats spacewire_stats_grspw;
514 spw_stats spacewire_stats_grspw;
526
515
527 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
516 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
528
517
529 spacewire_stats.packets_received = spacewire_stats_backup.packets_received
518 spacewire_stats.packets_received = spacewire_stats_backup.packets_received
530 + spacewire_stats_grspw.packets_received;
519 + spacewire_stats_grspw.packets_received;
531 spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent
520 spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent
532 + spacewire_stats_grspw.packets_sent;
521 + spacewire_stats_grspw.packets_sent;
533 spacewire_stats.parity_err = spacewire_stats_backup.parity_err
522 spacewire_stats.parity_err = spacewire_stats_backup.parity_err
534 + spacewire_stats_grspw.parity_err;
523 + spacewire_stats_grspw.parity_err;
535 spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err
524 spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err
536 + spacewire_stats_grspw.disconnect_err;
525 + spacewire_stats_grspw.disconnect_err;
537 spacewire_stats.escape_err = spacewire_stats_backup.escape_err
526 spacewire_stats.escape_err = spacewire_stats_backup.escape_err
538 + spacewire_stats_grspw.escape_err;
527 + spacewire_stats_grspw.escape_err;
539 spacewire_stats.credit_err = spacewire_stats_backup.credit_err
528 spacewire_stats.credit_err = spacewire_stats_backup.credit_err
540 + spacewire_stats_grspw.credit_err;
529 + spacewire_stats_grspw.credit_err;
541 spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err
530 spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err
542 + spacewire_stats_grspw.write_sync_err;
531 + spacewire_stats_grspw.write_sync_err;
543 spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err
532 spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err
544 + spacewire_stats_grspw.rx_rmap_header_crc_err;
533 + spacewire_stats_grspw.rx_rmap_header_crc_err;
545 spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err
534 spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err
546 + spacewire_stats_grspw.rx_rmap_data_crc_err;
535 + spacewire_stats_grspw.rx_rmap_data_crc_err;
547 spacewire_stats.early_ep = spacewire_stats_backup.early_ep
536 spacewire_stats.early_ep = spacewire_stats_backup.early_ep
548 + spacewire_stats_grspw.early_ep;
537 + spacewire_stats_grspw.early_ep;
549 spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address
538 spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address
550 + spacewire_stats_grspw.invalid_address;
539 + spacewire_stats_grspw.invalid_address;
551 spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err
540 spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err
552 + spacewire_stats_grspw.rx_eep_err;
541 + spacewire_stats_grspw.rx_eep_err;
553 spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated
542 spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated
554 + spacewire_stats_grspw.rx_truncated;
543 + spacewire_stats_grspw.rx_truncated;
555 //spacewire_stats.tx_link_err;
544 //spacewire_stats.tx_link_err;
556
545
557 //****************************
546 //****************************
558 // DPU_SPACEWIRE_IF_STATISTICS
547 // DPU_SPACEWIRE_IF_STATISTICS
559 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8);
548 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8);
560 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received);
549 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received);
561 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8);
550 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8);
562 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent);
551 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent);
563 //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt;
552 //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt;
564 //housekeeping_packet.hk_lfr_dpu_spw_last_timc;
553 //housekeeping_packet.hk_lfr_dpu_spw_last_timc;
565
554
566 //******************************************
555 //******************************************
567 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
556 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
568 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err;
557 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err;
569 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err;
558 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err;
570 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err;
559 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err;
571 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err;
560 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err;
572 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err;
561 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err;
573 // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb;
562 // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb;
574 // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb;
563 // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb;
575 housekeeping_packet.hk_lfr_dpu_spw_header_crc = (unsigned char) spacewire_stats.rx_rmap_header_crc_err;
564 housekeeping_packet.hk_lfr_dpu_spw_header_crc = (unsigned char) spacewire_stats.rx_rmap_header_crc_err;
576 housekeeping_packet.hk_lfr_dpu_spw_data_crc = (unsigned char) spacewire_stats.rx_rmap_data_crc_err;
565 housekeeping_packet.hk_lfr_dpu_spw_data_crc = (unsigned char) spacewire_stats.rx_rmap_data_crc_err;
577
566
578 //*********************************************
567 //*********************************************
579 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
568 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
580 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
569 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
581 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
570 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
582 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
571 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
583 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
572 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
584
573
585 }
574 }
586
575
587 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc )
576 void timecode_irq_handler( void *pDev, void *regs, int minor, unsigned int tc )
588 {
577 {
589 //if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 ) != RTEMS_SUCCESSFUL) {
578 //if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 ) != RTEMS_SUCCESSFUL) {
590 // printf("In timecode_irq_handler *** Error sending event to DUMB\n");
579 // printf("In timecode_irq_handler *** Error sending event to DUMB\n");
591 //}
580 //}
592 }
581 }
593
582
594 rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data )
583 rtems_timer_service_routine user_routine( rtems_id timer_id, void *user_data )
595 {
584 {
596 int linkStatus;
585 int linkStatus;
597 rtems_status_code status;
586 rtems_status_code status;
598
587
599 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
588 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
600
589
601 if ( linkStatus == 5) {
590 if ( linkStatus == 5) {
602 PRINTF("in spacewire_reset_link *** link is running\n")
591 PRINTF("in spacewire_reset_link *** link is running\n")
603 status = RTEMS_SUCCESSFUL;
592 status = RTEMS_SUCCESSFUL;
604 }
593 }
605 }
594 }
606
595
607 rtems_status_code rtems_message_queue_send_lfr( rtems_id id, const void *buffer, size_t size )
596 rtems_status_code rtems_message_queue_send_lfr( rtems_id id, const void *buffer, size_t size )
608 {
597 {
609 rtems_status_code status;
598 rtems_status_code status;
610 rtems_mode previous_mode_set;
599 rtems_mode previous_mode_set;
611
600
612 // set the preemption OFF
601 // set the preemption OFF
613 status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &previous_mode_set );
602 status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &previous_mode_set );
614
603
615 // use the message queue
604 // use the message queue
616 status = rtems_message_queue_send_lfr( id, buffer, size );
605 status = rtems_message_queue_send_lfr( id, buffer, size );
617
606
618 // set the preemption ON
607 // set the preemption ON
619 status = rtems_task_mode( RTEMS_PREEMPT , RTEMS_PREEMPT_MASK, &previous_mode_set );
608 status = rtems_task_mode( RTEMS_PREEMPT , RTEMS_PREEMPT_MASK, &previous_mode_set );
620
609
621 return status;
610 return status;
622 }
611 }
623
612
@@ -1,449 +1,449
1 /** Functions to load and dump parameters in the LFR registers.
1 /** Functions to load and dump parameters in the LFR registers.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle TC related to parameter loading and dumping.\n
6 * A group of functions to handle TC related to parameter loading and dumping.\n
7 * TC_LFR_LOAD_COMMON_PAR\n
7 * TC_LFR_LOAD_COMMON_PAR\n
8 * TC_LFR_LOAD_NORMAL_PAR\n
8 * TC_LFR_LOAD_NORMAL_PAR\n
9 * TC_LFR_LOAD_BURST_PAR\n
9 * TC_LFR_LOAD_BURST_PAR\n
10 * TC_LFR_LOAD_SBM1_PAR\n
10 * TC_LFR_LOAD_SBM1_PAR\n
11 * TC_LFR_LOAD_SBM2_PAR\n
11 * TC_LFR_LOAD_SBM2_PAR\n
12 *
12 *
13 */
13 */
14
14
15 #include "tc_load_dump_parameters.h"
15 #include "tc_load_dump_parameters.h"
16
16
17 int action_load_common_par(ccsdsTelecommandPacket_t *TC)
17 int action_load_common_par(ccsdsTelecommandPacket_t *TC)
18 {
18 {
19 /** This function updates the LFR registers with the incoming common parameters.
19 /** This function updates the LFR registers with the incoming common parameters.
20 *
20 *
21 * @param TC points to the TeleCommand packet that is being processed
21 * @param TC points to the TeleCommand packet that is being processed
22 *
22 *
23 *
23 *
24 */
24 */
25
25
26 parameter_dump_packet.unused0 = TC->dataAndCRC[0];
26 parameter_dump_packet.unused0 = TC->dataAndCRC[0];
27 parameter_dump_packet.bw_sp0_sp1_r0_r1 = TC->dataAndCRC[1];
27 parameter_dump_packet.bw_sp0_sp1_r0_r1 = TC->dataAndCRC[1];
28 set_wfp_data_shaping(parameter_dump_packet.bw_sp0_sp1_r0_r1);
28 set_wfp_data_shaping(parameter_dump_packet.bw_sp0_sp1_r0_r1);
29 return LFR_SUCCESSFUL;
29 return LFR_SUCCESSFUL;
30 }
30 }
31
31
32 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
32 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
33 {
33 {
34 /** This function updates the LFR registers with the incoming normal parameters.
34 /** This function updates the LFR registers with the incoming normal parameters.
35 *
35 *
36 * @param TC points to the TeleCommand packet that is being processed
36 * @param TC points to the TeleCommand packet that is being processed
37 * @param queue_id is the id of the queue which handles TM related to this execution step
37 * @param queue_id is the id of the queue which handles TM related to this execution step
38 *
38 *
39 */
39 */
40
40
41 int result;
41 int result;
42 int flag;
42 int flag;
43
43
44 flag = LFR_SUCCESSFUL;
44 flag = LFR_SUCCESSFUL;
45 result = LFR_SUCCESSFUL;
46
45
47 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
46 if ( (lfrCurrentMode == LFR_MODE_NORMAL) ||
47 (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) {
48 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
48 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
49 flag = LFR_DEFAULT;
49 flag = LFR_DEFAULT;
50 }
50 }
51
51
52 //***************
52 //***************
53 // sy_lfr_n_swf_l
53 // sy_lfr_n_swf_l
54 if (flag == LFR_SUCCESSFUL)
54 if (flag == LFR_SUCCESSFUL)
55 {
55 {
56 result = set_sy_lfr_n_swf_l( TC, queue_id );
56 result = set_sy_lfr_n_swf_l( TC, queue_id );
57 if (result != LFR_SUCCESSFUL)
57 if (result != LFR_SUCCESSFUL)
58 {
58 {
59 flag = LFR_DEFAULT;
59 flag = LFR_DEFAULT;
60 }
60 }
61 }
61 }
62
62
63 //***************
63 //***************
64 // sy_lfr_n_swf_p
64 // sy_lfr_n_swf_p
65 if (flag == LFR_SUCCESSFUL)
65 if (flag == LFR_SUCCESSFUL)
66 {
66 {
67 result = set_sy_lfr_n_swf_p( TC, queue_id );
67 result = set_sy_lfr_n_swf_p( TC, queue_id );
68 if (result != LFR_SUCCESSFUL)
68 if (result != LFR_SUCCESSFUL)
69 {
69 {
70 flag = LFR_DEFAULT;
70 flag = LFR_DEFAULT;
71 }
71 }
72 }
72 }
73
73
74 //***************
74 //***************
75 // SY_LFR_N_ASM_P
75 // SY_LFR_N_ASM_P
76 if (flag == LFR_SUCCESSFUL)
76 if (flag == LFR_SUCCESSFUL)
77 {
77 {
78 result = set_sy_lfr_n_asm_p( TC, queue_id );
78 result = set_sy_lfr_n_asm_p( TC, queue_id );
79 if (result != LFR_SUCCESSFUL)
79 if (result != LFR_SUCCESSFUL)
80 {
80 {
81 flag = LFR_DEFAULT;
81 flag = LFR_DEFAULT;
82 }
82 }
83 }
83 }
84
84
85 //***************
85 //***************
86 // SY_LFR_N_BP_P0
86 // SY_LFR_N_BP_P0
87 if (flag == LFR_SUCCESSFUL)
87 if (flag == LFR_SUCCESSFUL)
88 {
88 {
89 result = set_sy_lfr_n_bp_p0( TC, queue_id );
89 result = set_sy_lfr_n_bp_p0( TC, queue_id );
90 if (result != LFR_SUCCESSFUL)
90 if (result != LFR_SUCCESSFUL)
91 {
91 {
92 flag = LFR_DEFAULT;
92 flag = LFR_DEFAULT;
93 }
93 }
94 }
94 }
95
95
96 //***************
96 //***************
97 // sy_lfr_n_bp_p1
97 // sy_lfr_n_bp_p1
98 if (flag == LFR_SUCCESSFUL)
98 if (flag == LFR_SUCCESSFUL)
99 {
99 {
100 result = set_sy_lfr_n_bp_p1( TC, queue_id );
100 result = set_sy_lfr_n_bp_p1( TC, queue_id );
101 if (result != LFR_SUCCESSFUL)
101 if (result != LFR_SUCCESSFUL)
102 {
102 {
103 flag = LFR_DEFAULT;
103 flag = LFR_DEFAULT;
104 }
104 }
105 }
105 }
106
106
107 return result;
107 return flag;
108 }
108 }
109
109
110 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
110 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
111 {
111 {
112 /** This function updates the LFR registers with the incoming burst parameters.
112 /** This function updates the LFR registers with the incoming burst parameters.
113 *
113 *
114 * @param TC points to the TeleCommand packet that is being processed
114 * @param TC points to the TeleCommand packet that is being processed
115 * @param queue_id is the id of the queue which handles TM related to this execution step
115 * @param queue_id is the id of the queue which handles TM related to this execution step
116 *
116 *
117 */
117 */
118
118
119 int result;
119 int result;
120 unsigned char lfrMode;
120 unsigned char lfrMode;
121
121
122 result = LFR_DEFAULT;
122 result = LFR_DEFAULT;
123 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
123 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
124
124
125 if ( lfrMode == LFR_MODE_BURST ) {
125 if ( lfrMode == LFR_MODE_BURST ) {
126 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
126 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
127 result = LFR_DEFAULT;
127 result = LFR_DEFAULT;
128 }
128 }
129 else {
129 else {
130 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[0];
130 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[0];
131 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[1];
131 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[1];
132
132
133 result = LFR_SUCCESSFUL;
133 result = LFR_SUCCESSFUL;
134 }
134 }
135
135
136 return result;
136 return result;
137 }
137 }
138
138
139 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
139 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
140 {
140 {
141 /** This function updates the LFR registers with the incoming sbm1 parameters.
141 /** This function updates the LFR registers with the incoming sbm1 parameters.
142 *
142 *
143 * @param TC points to the TeleCommand packet that is being processed
143 * @param TC points to the TeleCommand packet that is being processed
144 * @param queue_id is the id of the queue which handles TM related to this execution step
144 * @param queue_id is the id of the queue which handles TM related to this execution step
145 *
145 *
146 */
146 */
147 int result;
147 int result;
148 unsigned char lfrMode;
148 unsigned char lfrMode;
149
149
150 result = LFR_DEFAULT;
150 result = LFR_DEFAULT;
151 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
151 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
152
152
153 if ( (lfrMode == LFR_MODE_SBM1) || (lfrMode == LFR_MODE_SBM2) ) {
153 if ( (lfrMode == LFR_MODE_SBM1) || (lfrMode == LFR_MODE_SBM2) ) {
154 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
154 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
155 result = LFR_DEFAULT;
155 result = LFR_DEFAULT;
156 }
156 }
157 else {
157 else {
158 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[0];
158 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[0];
159 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[1];
159 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[1];
160
160
161 result = LFR_SUCCESSFUL;
161 result = LFR_SUCCESSFUL;
162 }
162 }
163
163
164 return result;
164 return result;
165 }
165 }
166
166
167 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
167 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
168 {
168 {
169 /** This function updates the LFR registers with the incoming sbm2 parameters.
169 /** This function updates the LFR registers with the incoming sbm2 parameters.
170 *
170 *
171 * @param TC points to the TeleCommand packet that is being processed
171 * @param TC points to the TeleCommand packet that is being processed
172 * @param queue_id is the id of the queue which handles TM related to this execution step
172 * @param queue_id is the id of the queue which handles TM related to this execution step
173 *
173 *
174 */
174 */
175
175
176 int result;
176 int result;
177 unsigned char lfrMode;
177 unsigned char lfrMode;
178
178
179 result = LFR_DEFAULT;
179 result = LFR_DEFAULT;
180 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
180 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
181
181
182 if ( (lfrMode == LFR_MODE_SBM2) || (lfrMode == LFR_MODE_SBM2) ) {
182 if ( (lfrMode == LFR_MODE_SBM2) || (lfrMode == LFR_MODE_SBM2) ) {
183 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
183 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
184 result = LFR_DEFAULT;
184 result = LFR_DEFAULT;
185 }
185 }
186 else {
186 else {
187 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[0];
187 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[0];
188 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[1];
188 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[1];
189
189
190 result = LFR_SUCCESSFUL;
190 result = LFR_SUCCESSFUL;
191 }
191 }
192
192
193 return result;
193 return result;
194 }
194 }
195
195
196 int action_dump_par( rtems_id queue_id )
196 int action_dump_par( rtems_id queue_id )
197 {
197 {
198 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
198 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
199 *
199 *
200 * @param queue_id is the id of the queue which handles TM related to this execution step.
200 * @param queue_id is the id of the queue which handles TM related to this execution step.
201 *
201 *
202 * @return RTEMS directive status codes:
202 * @return RTEMS directive status codes:
203 * - RTEMS_SUCCESSFUL - message sent successfully
203 * - RTEMS_SUCCESSFUL - message sent successfully
204 * - RTEMS_INVALID_ID - invalid queue id
204 * - RTEMS_INVALID_ID - invalid queue id
205 * - RTEMS_INVALID_SIZE - invalid message size
205 * - RTEMS_INVALID_SIZE - invalid message size
206 * - RTEMS_INVALID_ADDRESS - buffer is NULL
206 * - RTEMS_INVALID_ADDRESS - buffer is NULL
207 * - RTEMS_UNSATISFIED - out of message buffers
207 * - RTEMS_UNSATISFIED - out of message buffers
208 * - RTEMS_TOO_MANY - queue s limit has been reached
208 * - RTEMS_TOO_MANY - queue s limit has been reached
209 *
209 *
210 */
210 */
211
211
212 int status;
212 int status;
213
213
214 // UPDATE TIME
214 // UPDATE TIME
215 increment_seq_counter( parameter_dump_packet.packetSequenceControl );
215 increment_seq_counter( parameter_dump_packet.packetSequenceControl );
216 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
216 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
217 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
217 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
218 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
218 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
219 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
219 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
220 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
220 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
221 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
221 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
222 // SEND DATA
222 // SEND DATA
223 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
223 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
224 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
224 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
225 if (status != RTEMS_SUCCESSFUL) {
225 if (status != RTEMS_SUCCESSFUL) {
226 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
226 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
227 }
227 }
228
228
229 return status;
229 return status;
230 }
230 }
231
231
232 //***********************
232 //***********************
233 // NORMAL MODE PARAMETERS
233 // NORMAL MODE PARAMETERS
234
234
235 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
235 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
236 {
236 {
237 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
237 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
238 *
238 *
239 * @param TC points to the TeleCommand packet that is being processed
239 * @param TC points to the TeleCommand packet that is being processed
240 * @param queue_id is the id of the queue which handles TM related to this execution step
240 * @param queue_id is the id of the queue which handles TM related to this execution step
241 *
241 *
242 */
242 */
243
243
244 unsigned int tmp;
244 unsigned int tmp;
245 int result;
245 int result;
246 unsigned char msb;
246 unsigned char msb;
247 unsigned char lsb;
247 unsigned char lsb;
248
248
249 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L ];
249 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L ];
250 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L+1 ];
250 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_L+1 ];
251
251
252 tmp = ( unsigned int ) floor(
252 tmp = ( unsigned int ) floor(
253 ( ( msb*256 ) + lsb ) / 16
253 ( ( msb*256 ) + lsb ) / 16
254 ) * 16;
254 ) * 16;
255
255
256 if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16
256 if ( (tmp < 16) || (tmp > 2048) ) // the snapshot period is a multiple of 16
257 { // 2048 is the maximum limit due to the size of the buffers
257 { // 2048 is the maximum limit due to the size of the buffers
258 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_L+10, lsb );
258 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_L+10, lsb );
259 result = WRONG_APP_DATA;
259 result = WRONG_APP_DATA;
260 }
260 }
261 else if (tmp != 2048)
261 else if (tmp != 2048)
262 {
262 {
263 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
263 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
264 result = FUNCT_NOT_IMPL;
264 result = FUNCT_NOT_IMPL;
265 }
265 }
266 else
266 else
267 {
267 {
268 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (tmp >> 8);
268 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (tmp >> 8);
269 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (tmp );
269 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (tmp );
270 result = LFR_SUCCESSFUL;
270 result = LFR_SUCCESSFUL;
271 }
271 }
272
272
273 return result;
273 return result;
274 }
274 }
275
275
276 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
276 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
277 {
277 {
278 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
278 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
279 *
279 *
280 * @param TC points to the TeleCommand packet that is being processed
280 * @param TC points to the TeleCommand packet that is being processed
281 * @param queue_id is the id of the queue which handles TM related to this execution step
281 * @param queue_id is the id of the queue which handles TM related to this execution step
282 *
282 *
283 */
283 */
284
284
285 unsigned int tmp;
285 unsigned int tmp;
286 int result;
286 int result;
287 unsigned char msb;
287 unsigned char msb;
288 unsigned char lsb;
288 unsigned char lsb;
289
289
290 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P ];
290 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P ];
291 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P+1 ];
291 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_SWF_P+1 ];
292
292
293 tmp = ( unsigned int ) floor(
293 tmp = ( unsigned int ) floor(
294 ( ( msb*256 ) + lsb ) / 8
294 ( ( msb*256 ) + lsb ) / 8
295 ) * 8;
295 ) * 8;
296
296
297 if ( (tmp < 16) || (tmp > 65528) )
297 if ( (tmp < 16) || (tmp > 65528) )
298 {
298 {
299 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_P+10, lsb );
299 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_SY_LFR_N_SWF_P+10, lsb );
300 result = WRONG_APP_DATA;
300 result = WRONG_APP_DATA;
301 }
301 }
302 else
302 else
303 {
303 {
304 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8);
304 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8);
305 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp );
305 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp );
306 result = LFR_SUCCESSFUL;
306 result = LFR_SUCCESSFUL;
307 }
307 }
308
308
309 return result;
309 return result;
310 }
310 }
311
311
312 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
312 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
313 {
313 {
314 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
314 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
315 *
315 *
316 * @param TC points to the TeleCommand packet that is being processed
316 * @param TC points to the TeleCommand packet that is being processed
317 * @param queue_id is the id of the queue which handles TM related to this execution step
317 * @param queue_id is the id of the queue which handles TM related to this execution step
318 *
318 *
319 */
319 */
320
320
321 int result;
321 int result;
322 unsigned char msb;
322 unsigned char msb;
323 unsigned char lsb;
323 unsigned char lsb;
324
324
325 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P ];
325 msb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P ];
326 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P+1 ];
326 lsb = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_ASM_P+1 ];
327
327
328 parameter_dump_packet.sy_lfr_n_asm_p[0] = msb;
328 parameter_dump_packet.sy_lfr_n_asm_p[0] = msb;
329 parameter_dump_packet.sy_lfr_n_asm_p[1] = lsb;
329 parameter_dump_packet.sy_lfr_n_asm_p[1] = lsb;
330 result = LFR_SUCCESSFUL;
330 result = LFR_SUCCESSFUL;
331
331
332 return result;
332 return result;
333 }
333 }
334
334
335 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
335 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
336 {
336 {
337 /** This function sets the time between two basic parameter sets, in s (SY_LFR_N_BP_P0).
337 /** This function sets the time between two basic parameter sets, in s (SY_LFR_N_BP_P0).
338 *
338 *
339 * @param TC points to the TeleCommand packet that is being processed
339 * @param TC points to the TeleCommand packet that is being processed
340 * @param queue_id is the id of the queue which handles TM related to this execution step
340 * @param queue_id is the id of the queue which handles TM related to this execution step
341 *
341 *
342 */
342 */
343
343
344 int status;
344 int status;
345
345
346 status = LFR_SUCCESSFUL;
346 status = LFR_SUCCESSFUL;
347
347
348 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P0 ];
348 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P0 ];
349
349
350 return status;
350 return status;
351 }
351 }
352
352
353 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
353 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
354 {
354 {
355 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
355 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
356 *
356 *
357 * @param TC points to the TeleCommand packet that is being processed
357 * @param TC points to the TeleCommand packet that is being processed
358 * @param queue_id is the id of the queue which handles TM related to this execution step
358 * @param queue_id is the id of the queue which handles TM related to this execution step
359 *
359 *
360 */
360 */
361
361
362 int status;
362 int status;
363
363
364 status = LFR_SUCCESSFUL;
364 status = LFR_SUCCESSFUL;
365
365
366 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P1 ];
366 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ BYTE_POS_SY_LFR_N_BP_P1 ];
367
367
368 return status;
368 return status;
369 }
369 }
370
370
371 //**********************
371 //**********************
372 // BURST MODE PARAMETERS
372 // BURST MODE PARAMETERS
373
373
374 //*********************
374 //*********************
375 // SBM1 MODE PARAMETERS
375 // SBM1 MODE PARAMETERS
376
376
377 //*********************
377 //*********************
378 // SBM2 MODE PARAMETERS
378 // SBM2 MODE PARAMETERS
379
379
380 //**********
380 //**********
381 // init dump
381 // init dump
382
382
383 void init_parameter_dump( void )
383 void init_parameter_dump( void )
384 {
384 {
385 /** This function initialize the parameter_dump_packet global variable with default values.
385 /** This function initialize the parameter_dump_packet global variable with default values.
386 *
386 *
387 */
387 */
388
388
389 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
389 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
390 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
390 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
391 parameter_dump_packet.reserved = CCSDS_RESERVED;
391 parameter_dump_packet.reserved = CCSDS_RESERVED;
392 parameter_dump_packet.userApplication = CCSDS_USER_APP;
392 parameter_dump_packet.userApplication = CCSDS_USER_APP;
393 parameter_dump_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_PARAMETER_DUMP >> 8);
393 parameter_dump_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_PARAMETER_DUMP >> 8);
394 parameter_dump_packet.packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP;
394 parameter_dump_packet.packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP;
395 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
395 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
396 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
396 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
397 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
397 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
398 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
398 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
399 // DATA FIELD HEADER
399 // DATA FIELD HEADER
400 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
400 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
401 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
401 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
402 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
402 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
403 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
403 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
404 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
404 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
405 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
405 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
406 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
406 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
407 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
407 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
408 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
408 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
409 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
409 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
410 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
410 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
411
411
412 //******************
412 //******************
413 // COMMON PARAMETERS
413 // COMMON PARAMETERS
414 parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0;
414 parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0;
415 parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1;
415 parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1;
416
416
417 //******************
417 //******************
418 // NORMAL PARAMETERS
418 // NORMAL PARAMETERS
419 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (SY_LFR_N_SWF_L >> 8);
419 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (SY_LFR_N_SWF_L >> 8);
420 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (SY_LFR_N_SWF_L );
420 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (SY_LFR_N_SWF_L );
421 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (SY_LFR_N_SWF_P >> 8);
421 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (SY_LFR_N_SWF_P >> 8);
422 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (SY_LFR_N_SWF_P );
422 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (SY_LFR_N_SWF_P );
423 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (SY_LFR_N_ASM_P >> 8);
423 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (SY_LFR_N_ASM_P >> 8);
424 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P );
424 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (SY_LFR_N_ASM_P );
425 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0;
425 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) SY_LFR_N_BP_P0;
426 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1;
426 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) SY_LFR_N_BP_P1;
427
427
428 //*****************
428 //*****************
429 // BURST PARAMETERS
429 // BURST PARAMETERS
430 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
430 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
431 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
431 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
432
432
433 //****************
433 //****************
434 // SBM1 PARAMETERS
434 // SBM1 PARAMETERS
435 parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period
435 parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period
436 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
436 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
437
437
438 //****************
438 //****************
439 // SBM2 PARAMETERS
439 // SBM2 PARAMETERS
440 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
440 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
441 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
441 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
442 }
442 }
443
443
444
444
445
445
446
446
447
447
448
448
449
449
@@ -1,1219 +1,1219
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 // SWF
12 // SWF
13 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
13 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
14 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
14 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
16 // CWF
16 // CWF
17 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[7];
17 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[7];
18 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[7];
18 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[7];
19 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[7];
19 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[7];
20 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[7];
20 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[7];
21 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[7];
21 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[7];
22
22
23 unsigned char doubleSendCWF1 = 0;
23 unsigned char doubleSendCWF1 = 0;
24 unsigned char doubleSendCWF2 = 0;
24 unsigned char doubleSendCWF2 = 0;
25
25
26 rtems_isr waveforms_isr( rtems_vector_number vector )
26 rtems_isr waveforms_isr( rtems_vector_number vector )
27 {
27 {
28 /** This is the interrupt sub routine called by the waveform picker core.
28 /** This is the interrupt sub routine called by the waveform picker core.
29 *
29 *
30 * This ISR launch different actions depending mainly on two pieces of information:
30 * This ISR launch different actions depending mainly on two pieces of information:
31 * 1. the values read in the registers of the waveform picker.
31 * 1. the values read in the registers of the waveform picker.
32 * 2. the current LFR mode.
32 * 2. the current LFR mode.
33 *
33 *
34 */
34 */
35
35
36 #ifdef GSA
36 #ifdef GSA
37 #else
37 #else
38 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
38 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
39 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
39 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
40 { // in modes other than STANDBY and BURST, send the CWF_F3 data
40 { // in modes other than STANDBY and BURST, send the CWF_F3 data
41 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
41 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
42 // (1) change the receiving buffer for the waveform picker
42 // (1) change the receiving buffer for the waveform picker
43 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
43 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
44 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_bis);
44 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_bis);
45 }
45 }
46 else {
46 else {
47 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3);
47 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3);
48 }
48 }
49 // (2) send an event for the waveforms transmission
49 // (2) send an event for the waveforms transmission
50 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
50 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
51 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
51 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
52 }
52 }
53 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
53 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
54 }
54 }
55 }
55 }
56 #endif
56 #endif
57
57
58 switch(lfrCurrentMode)
58 switch(lfrCurrentMode)
59 {
59 {
60 //********
60 //********
61 // STANDBY
61 // STANDBY
62 case(LFR_MODE_STANDBY):
62 case(LFR_MODE_STANDBY):
63 break;
63 break;
64
64
65 //******
65 //******
66 // NORMAL
66 // NORMAL
67 case(LFR_MODE_NORMAL):
67 case(LFR_MODE_NORMAL):
68 #ifdef GSA
68 #ifdef GSA
69 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
69 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
70 #else
70 #else
71 if ( (waveform_picker_regs->burst_enable & 0x7) == 0x0 ){ // if no channel is enable
71 if ( (waveform_picker_regs->burst_enable & 0x7) == 0x0 ){ // if no channel is enable
72 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
72 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
73 }
73 }
74 else {
74 else {
75 if ( (waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full
75 if ( (waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full
76 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable & 0x08;
76 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable & 0x08;
77 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
77 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
78 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
78 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
79 }
79 }
80 // waveform_picker_regs->status = waveform_picker_regs->status & 0x00;
80 // waveform_picker_regs->status = waveform_picker_regs->status & 0x00;
81 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888;
81 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888;
82 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x07; // [0111] enable f2 f1 f0
82 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x07; // [0111] enable f2 f1 f0
83 }
83 }
84 }
84 }
85 #endif
85 #endif
86 break;
86 break;
87
87
88 //******
88 //******
89 // BURST
89 // BURST
90 case(LFR_MODE_BURST):
90 case(LFR_MODE_BURST):
91 #ifdef GSA
91 #ifdef GSA
92 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
92 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
93 #else
93 #else
94 if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
94 if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
95 // (1) change the receiving buffer for the waveform picker
95 // (1) change the receiving buffer for the waveform picker
96 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
96 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
97 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
97 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
98 }
98 }
99 else {
99 else {
100 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
100 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
101 }
101 }
102 // (2) send an event for the waveforms transmission
102 // (2) send an event for the waveforms transmission
103 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
103 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
104 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
104 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
105 }
105 }
106 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
106 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
107 }
107 }
108 #endif
108 #endif
109 break;
109 break;
110
110
111 //*****
111 //*****
112 // SBM1
112 // SBM1
113 case(LFR_MODE_SBM1):
113 case(LFR_MODE_SBM1):
114 #ifdef GSA
114 #ifdef GSA
115 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
115 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
116 #else
116 #else
117 if ((waveform_picker_regs->status & 0x02) == 0x02){ // [0010] check the f1 full bit
117 if ((waveform_picker_regs->status & 0x02) == 0x02){ // [0010] check the f1 full bit
118 // (1) change the receiving buffer for the waveform picker
118 // (1) change the receiving buffer for the waveform picker
119 if ( param_local.local_sbm1_nb_cwf_sent == (param_local.local_sbm1_nb_cwf_max-1) )
119 if ( param_local.local_sbm1_nb_cwf_sent == (param_local.local_sbm1_nb_cwf_max-1) )
120 {
120 {
121 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_norm);
121 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_norm);
122 }
122 }
123 else if ( waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1_norm )
123 else if ( waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1_norm )
124 {
124 {
125 doubleSendCWF1 = 1;
125 doubleSendCWF1 = 1;
126 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
126 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
127 }
127 }
128 else if ( waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1 ) {
128 else if ( waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1 ) {
129 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_bis);
129 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_bis);
130 }
130 }
131 else {
131 else {
132 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
132 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
133 }
133 }
134 // (2) send an event for the waveforms transmission
134 // (2) send an event for the waveforms transmission
135 if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) {
135 if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) {
136 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
136 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
137 }
137 }
138 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0
138 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0
139 }
139 }
140 if ( ( (waveform_picker_regs->status & 0x05) == 0x05 ) ) { // [0101] check the f2 and f0 full bit
140 if ( ( (waveform_picker_regs->status & 0x05) == 0x05 ) ) { // [0101] check the f2 and f0 full bit
141 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
141 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
142 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
142 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
143 }
143 }
144 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0
144 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0
145 reset_local_sbm1_nb_cwf_sent();
145 reset_local_sbm1_nb_cwf_sent();
146 }
146 }
147
147
148 #endif
148 #endif
149 break;
149 break;
150
150
151 //*****
151 //*****
152 // SBM2
152 // SBM2
153 case(LFR_MODE_SBM2):
153 case(LFR_MODE_SBM2):
154 #ifdef GSA
154 #ifdef GSA
155 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
155 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
156 #else
156 #else
157 if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
157 if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
158 // (1) change the receiving buffer for the waveform picker
158 // (1) change the receiving buffer for the waveform picker
159 if ( param_local.local_sbm2_nb_cwf_sent == (param_local.local_sbm2_nb_cwf_max-1) )
159 if ( param_local.local_sbm2_nb_cwf_sent == (param_local.local_sbm2_nb_cwf_max-1) )
160 {
160 {
161 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_norm);
161 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_norm);
162 }
162 }
163 else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2_norm ) {
163 else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2_norm ) {
164 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
164 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
165 doubleSendCWF2 = 1;
165 doubleSendCWF2 = 1;
166 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2_WFRM ) != RTEMS_SUCCESSFUL) {
166 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2_WFRM ) != RTEMS_SUCCESSFUL) {
167 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
167 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
168 }
168 }
169 reset_local_sbm2_nb_cwf_sent();
169 reset_local_sbm2_nb_cwf_sent();
170 }
170 }
171 else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2 ) {
171 else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2 ) {
172 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
172 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
173 }
173 }
174 else {
174 else {
175 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
175 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
176 }
176 }
177 // (2) send an event for the waveforms transmission
177 // (2) send an event for the waveforms transmission
178 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
178 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
179 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
179 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
180 }
180 }
181 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
181 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
182 }
182 }
183 if ( ( (waveform_picker_regs->status & 0x03) == 0x03 ) ) { // [0011] f3 f2 f1 f0, f1 and f0 are full
183 if ( ( (waveform_picker_regs->status & 0x03) == 0x03 ) ) { // [0011] f3 f2 f1 f0, f1 and f0 are full
184 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
184 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
185 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
185 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
186 }
186 }
187 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
187 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
188 }
188 }
189 #endif
189 #endif
190 break;
190 break;
191
191
192 //********
192 //********
193 // DEFAULT
193 // DEFAULT
194 default:
194 default:
195 break;
195 break;
196 }
196 }
197 }
197 }
198
198
199 rtems_isr waveforms_simulator_isr( rtems_vector_number vector )
199 rtems_isr waveforms_simulator_isr( rtems_vector_number vector )
200 {
200 {
201 /** This is the interrupt sub routine called by the waveform picker simulator.
201 /** This is the interrupt sub routine called by the waveform picker simulator.
202 *
202 *
203 * This ISR is for debug purpose only.
203 * This ISR is for debug purpose only.
204 *
204 *
205 */
205 */
206
206
207 unsigned char lfrMode;
207 unsigned char lfrMode;
208 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
208 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
209
209
210 switch(lfrMode) {
210 switch(lfrMode) {
211 case (LFR_MODE_STANDBY):
211 case (LFR_MODE_STANDBY):
212 break;
212 break;
213 case (LFR_MODE_NORMAL):
213 case (LFR_MODE_NORMAL):
214 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
214 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
215 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_5 );
215 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_5 );
216 }
216 }
217 break;
217 break;
218 case (LFR_MODE_BURST):
218 case (LFR_MODE_BURST):
219 break;
219 break;
220 case (LFR_MODE_SBM1):
220 case (LFR_MODE_SBM1):
221 break;
221 break;
222 case (LFR_MODE_SBM2):
222 case (LFR_MODE_SBM2):
223 break;
223 break;
224 }
224 }
225 }
225 }
226
226
227 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
227 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
228 {
228 {
229 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
229 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
230 *
230 *
231 * @param unused is the starting argument of the RTEMS task
231 * @param unused is the starting argument of the RTEMS task
232 *
232 *
233 * The following data packets are sent by this task:
233 * The following data packets are sent by this task:
234 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
234 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
235 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
235 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
236 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
236 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
237 *
237 *
238 */
238 */
239
239
240 rtems_event_set event_out;
240 rtems_event_set event_out;
241 rtems_id queue_id;
241 rtems_id queue_id;
242
242
243 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
243 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
244 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
244 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
245 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
245 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
246
246
247 init_waveforms();
247 init_waveforms();
248
248
249 queue_id = get_pkts_queue_id();
249 queue_id = get_pkts_queue_id();
250
250
251 BOOT_PRINTF("in WFRM ***\n")
251 BOOT_PRINTF("in WFRM ***\n")
252
252
253 while(1){
253 while(1){
254 // wait for an RTEMS_EVENT
254 // wait for an RTEMS_EVENT
255 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
255 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
256 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
256 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
257 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
257 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
258
258
259 if (event_out == RTEMS_EVENT_MODE_NORMAL)
259 if (event_out == RTEMS_EVENT_MODE_NORMAL)
260 {
260 {
261 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
261 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
262 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
262 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
263 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
263 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
264 #ifdef GSA
264 #ifdef GSA
265 waveform_picker_regs->status = waveform_picker_regs->status & 0xf888; // [1111 1000 1000 1000] f2, f1, f0 bits =0
265 waveform_picker_regs->status = waveform_picker_regs->status & 0xf888; // [1111 1000 1000 1000] f2, f1, f0 bits =0
266 #endif
266 #endif
267 }
267 }
268 else if (event_out == RTEMS_EVENT_MODE_SBM1)
268 else if (event_out == RTEMS_EVENT_MODE_SBM1)
269 {
269 {
270 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
270 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
271 send_waveform_SWF(wf_snap_f1_norm, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
271 send_waveform_SWF(wf_snap_f1_norm, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
272 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
272 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
273 #ifdef GSA
273 #ifdef GSA
274 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2, f0 bits = 0
274 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2, f0 bits = 0
275 #endif
275 #endif
276 }
276 }
277 else if (event_out == RTEMS_EVENT_MODE_SBM2)
277 else if (event_out == RTEMS_EVENT_MODE_SBM2)
278 {
278 {
279 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
279 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
280 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
280 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
281 #ifdef GSA
281 #ifdef GSA
282 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
282 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
283 #endif
283 #endif
284 }
284 }
285 else if (event_out == RTEMS_EVENT_MODE_SBM2_WFRM)
285 else if (event_out == RTEMS_EVENT_MODE_SBM2_WFRM)
286 {
286 {
287 send_waveform_SWF(wf_snap_f2_norm, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
287 send_waveform_SWF(wf_snap_f2_norm, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
288 }
288 }
289 else
289 else
290 {
290 {
291 PRINTF("in WFRM *** unexpected event")
291 PRINTF("in WFRM *** unexpected event")
292 }
292 }
293
293
294
294
295 #ifdef GSA
295 #ifdef GSA
296 // irq processed, reset the related register of the timer unit
296 // irq processed, reset the related register of the timer unit
297 gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl = gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl | 0x00000010;
297 gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl = gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl | 0x00000010;
298 // clear the interruption
298 // clear the interruption
299 LEON_Unmask_interrupt( IRQ_WF );
299 LEON_Unmask_interrupt( IRQ_WF );
300 #endif
300 #endif
301 }
301 }
302 }
302 }
303
303
304 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
304 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
305 {
305 {
306 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
306 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
307 *
307 *
308 * @param unused is the starting argument of the RTEMS task
308 * @param unused is the starting argument of the RTEMS task
309 *
309 *
310 * The following data packet is sent by this task:
310 * The following data packet is sent by this task:
311 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
311 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
312 *
312 *
313 */
313 */
314
314
315 rtems_event_set event_out;
315 rtems_event_set event_out;
316 rtems_id queue_id;
316 rtems_id queue_id;
317
317
318 init_header_continuous_wf_table( SID_NORM_CWF_F3, headerCWF_F3 );
318 init_header_continuous_wf_table( SID_NORM_CWF_F3, headerCWF_F3 );
319 init_header_continuous_wf3_light_table( headerCWF_F3_light );
319 init_header_continuous_wf3_light_table( headerCWF_F3_light );
320
320
321 queue_id = get_pkts_queue_id();
321 queue_id = get_pkts_queue_id();
322
322
323 BOOT_PRINTF("in CWF3 ***\n")
323 BOOT_PRINTF("in CWF3 ***\n")
324
324
325 while(1){
325 while(1){
326 // wait for an RTEMS_EVENT
326 // wait for an RTEMS_EVENT
327 rtems_event_receive( RTEMS_EVENT_0,
327 rtems_event_receive( RTEMS_EVENT_0,
328 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
328 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
329 PRINTF("send CWF F3 \n")
329 PRINTF("send CWF F3 \n")
330 #ifdef GSA
330 #ifdef GSA
331 #else
331 #else
332 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
332 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
333 send_waveform_CWF3_light( wf_cont_f3_bis, headerCWF_F3_light, queue_id );
333 send_waveform_CWF3_light( wf_cont_f3_bis, headerCWF_F3_light, queue_id );
334 }
334 }
335 else {
335 else {
336 send_waveform_CWF3_light( wf_cont_f3, headerCWF_F3_light, queue_id );
336 send_waveform_CWF3_light( wf_cont_f3, headerCWF_F3_light, queue_id );
337 }
337 }
338 #endif
338 #endif
339 }
339 }
340 }
340 }
341
341
342 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
342 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
343 {
343 {
344 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
344 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
345 *
345 *
346 * @param unused is the starting argument of the RTEMS task
346 * @param unused is the starting argument of the RTEMS task
347 *
347 *
348 * The following data packet is sent by this function:
348 * The following data packet is sent by this function:
349 * - TM_LFR_SCIENCE_BURST_CWF_F2
349 * - TM_LFR_SCIENCE_BURST_CWF_F2
350 * - TM_LFR_SCIENCE_SBM2_CWF_F2
350 * - TM_LFR_SCIENCE_SBM2_CWF_F2
351 *
351 *
352 */
352 */
353
353
354 rtems_event_set event_out;
354 rtems_event_set event_out;
355 rtems_id queue_id;
355 rtems_id queue_id;
356
356
357 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
357 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
358 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
358 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
359
359
360 queue_id = get_pkts_queue_id();
360 queue_id = get_pkts_queue_id();
361
361
362 BOOT_PRINTF("in CWF2 ***\n")
362 BOOT_PRINTF("in CWF2 ***\n")
363
363
364 while(1){
364 while(1){
365 // wait for an RTEMS_EVENT
365 // wait for an RTEMS_EVENT
366 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
366 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
367 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
367 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
368
368
369 if (event_out == RTEMS_EVENT_MODE_BURST)
369 if (event_out == RTEMS_EVENT_MODE_BURST)
370 {
370 {
371 // F2
371 // F2
372 #ifdef GSA
372 #ifdef GSA
373 #else
373 #else
374 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
374 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
375 send_waveform_CWF( wf_snap_f2_bis, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
375 send_waveform_CWF( wf_snap_f2_bis, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
376 }
376 }
377 else {
377 else {
378 send_waveform_CWF( wf_snap_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
378 send_waveform_CWF( wf_snap_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
379 }
379 }
380 #endif
380 #endif
381 }
381 }
382
382
383 else if (event_out == RTEMS_EVENT_MODE_SBM2)
383 else if (event_out == RTEMS_EVENT_MODE_SBM2)
384 {
384 {
385 #ifdef GSA
385 #ifdef GSA
386 #else
386 #else
387 if (doubleSendCWF2 == 1)
387 if (doubleSendCWF2 == 1)
388 {
388 {
389 doubleSendCWF2 = 0;
389 doubleSendCWF2 = 0;
390 send_waveform_CWF( wf_snap_f2_norm, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
390 send_waveform_CWF( wf_snap_f2_norm, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
391 }
391 }
392 else if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
392 else if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
393 send_waveform_CWF( wf_snap_f2_bis, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
393 send_waveform_CWF( wf_snap_f2_bis, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
394 }
394 }
395 else {
395 else {
396 send_waveform_CWF( wf_snap_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
396 send_waveform_CWF( wf_snap_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
397 }
397 }
398 param_local.local_sbm2_nb_cwf_sent ++;
398 param_local.local_sbm2_nb_cwf_sent ++;
399 #endif
399 #endif
400 }
400 }
401 else
401 else
402 {
402 {
403 PRINTF1("in CWF2 *** ERR mode = %d\n", lfrCurrentMode)
403 PRINTF1("in CWF2 *** ERR mode = %d\n", lfrCurrentMode)
404 }
404 }
405 }
405 }
406 }
406 }
407
407
408 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
408 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
409 {
409 {
410 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
410 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
411 *
411 *
412 * @param unused is the starting argument of the RTEMS task
412 * @param unused is the starting argument of the RTEMS task
413 *
413 *
414 * The following data packet is sent by this function:
414 * The following data packet is sent by this function:
415 * - TM_LFR_SCIENCE_SBM1_CWF_F1
415 * - TM_LFR_SCIENCE_SBM1_CWF_F1
416 *
416 *
417 */
417 */
418
418
419 rtems_event_set event_out;
419 rtems_event_set event_out;
420 rtems_id queue_id;
420 rtems_id queue_id;
421
421
422 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
422 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
423
423
424 queue_id = get_pkts_queue_id();
424 queue_id = get_pkts_queue_id();
425
425
426 BOOT_PRINTF("in CWF1 ***\n")
426 BOOT_PRINTF("in CWF1 ***\n")
427
427
428 while(1){
428 while(1){
429 // wait for an RTEMS_EVENT
429 // wait for an RTEMS_EVENT
430 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
430 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
431 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
431 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
432 if (event_out == RTEMS_EVENT_MODE_SBM1)
432 if (event_out == RTEMS_EVENT_MODE_SBM1)
433 {
433 {
434 #ifdef GSA
434 #ifdef GSA
435 #else
435 #else
436 if (doubleSendCWF1 == 1)
436 if (doubleSendCWF1 == 1)
437 {
437 {
438 doubleSendCWF1 = 0;
438 doubleSendCWF1 = 0;
439 send_waveform_CWF( wf_snap_f1_norm, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
439 send_waveform_CWF( wf_snap_f1_norm, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
440 }
440 }
441 else if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
441 else if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
442 send_waveform_CWF( wf_snap_f1_bis, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
442 send_waveform_CWF( wf_snap_f1_bis, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
443 }
443 }
444 else {
444 else {
445 send_waveform_CWF( wf_snap_f1, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
445 send_waveform_CWF( wf_snap_f1, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
446 }
446 }
447 param_local.local_sbm1_nb_cwf_sent ++;
447 param_local.local_sbm1_nb_cwf_sent ++;
448 #endif
448 #endif
449 }
449 }
450 else
450 else
451 {
451 {
452 PRINTF1("in CWF1 *** ERR mode = %d\n", lfrCurrentMode)
452 PRINTF1("in CWF1 *** ERR mode = %d\n", lfrCurrentMode)
453 }
453 }
454 }
454 }
455 }
455 }
456
456
457 //******************
457 //******************
458 // general functions
458 // general functions
459 void init_waveforms( void )
459 void init_waveforms( void )
460 {
460 {
461 int i = 0;
461 int i = 0;
462
462
463 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
463 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
464 {
464 {
465 //***
465 //***
466 // F0
466 // F0
467 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
467 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
468 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
468 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
469 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
469 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
470
470
471 //***
471 //***
472 // F1
472 // F1
473 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
473 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
474 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
474 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
475 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
475 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
476
476
477 //***
477 //***
478 // F2
478 // F2
479 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
479 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
480 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
480 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
481 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
481 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
482
482
483 //***
483 //***
484 // F3
484 // F3
485 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
485 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
486 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
486 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
487 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
487 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
488 }
488 }
489 }
489 }
490
490
491 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
491 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
492 {
492 {
493 unsigned char i;
493 unsigned char i;
494
494
495 for (i=0; i<7; i++)
495 for (i=0; i<7; i++)
496 {
496 {
497 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
497 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
498 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
498 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
499 headerSWF[ i ].reserved = DEFAULT_RESERVED;
499 headerSWF[ i ].reserved = DEFAULT_RESERVED;
500 headerSWF[ i ].userApplication = CCSDS_USER_APP;
500 headerSWF[ i ].userApplication = CCSDS_USER_APP;
501 headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
501 headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
502 headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
502 headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
503 if (i == 0)
503 if (i == 0)
504 {
504 {
505 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
505 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
506 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
506 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
507 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
507 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
508 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
508 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
509 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
509 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
510 }
510 }
511 else if (i == 6)
511 else if (i == 6)
512 {
512 {
513 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
513 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
514 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_8 >> 8);
514 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_8 >> 8);
515 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_8 );
515 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_8 );
516 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
516 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
517 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
517 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
518 }
518 }
519 else
519 else
520 {
520 {
521 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
521 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
522 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
522 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
523 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
523 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
524 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
524 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
525 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
525 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
526 }
526 }
527 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
527 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
528 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
528 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
529 headerSWF[ i ].pktNr = i+1; // PKT_NR
529 headerSWF[ i ].pktNr = i+1; // PKT_NR
530 // DATA FIELD HEADER
530 // DATA FIELD HEADER
531 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
531 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
532 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
532 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
533 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
533 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
534 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
534 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
535 // AUXILIARY DATA HEADER
535 // AUXILIARY DATA HEADER
536 headerSWF[ i ].time[0] = 0x00;
536 headerSWF[ i ].time[0] = 0x00;
537 headerSWF[ i ].time[0] = 0x00;
537 headerSWF[ i ].time[0] = 0x00;
538 headerSWF[ i ].time[0] = 0x00;
538 headerSWF[ i ].time[0] = 0x00;
539 headerSWF[ i ].time[0] = 0x00;
539 headerSWF[ i ].time[0] = 0x00;
540 headerSWF[ i ].time[0] = 0x00;
540 headerSWF[ i ].time[0] = 0x00;
541 headerSWF[ i ].time[0] = 0x00;
541 headerSWF[ i ].time[0] = 0x00;
542 headerSWF[ i ].sid = sid;
542 headerSWF[ i ].sid = sid;
543 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
543 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
544 }
544 }
545 return LFR_SUCCESSFUL;
545 return LFR_SUCCESSFUL;
546 }
546 }
547
547
548 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
548 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
549 {
549 {
550 unsigned int i;
550 unsigned int i;
551
551
552 for (i=0; i<7; i++)
552 for (i=0; i<7; i++)
553 {
553 {
554 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
554 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
555 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
555 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
556 headerCWF[ i ].reserved = DEFAULT_RESERVED;
556 headerCWF[ i ].reserved = DEFAULT_RESERVED;
557 headerCWF[ i ].userApplication = CCSDS_USER_APP;
557 headerCWF[ i ].userApplication = CCSDS_USER_APP;
558 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
558 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
559 {
559 {
560 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
560 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
561 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
561 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
562 }
562 }
563 else
563 else
564 {
564 {
565 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
565 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
566 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
566 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
567 }
567 }
568 if (i == 0)
568 if (i == 0)
569 {
569 {
570 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
570 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
571 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
571 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
572 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
572 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
573 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
573 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
574 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
574 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
575 }
575 }
576 else if (i == 6)
576 else if (i == 6)
577 {
577 {
578 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
578 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
579 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_8 >> 8);
579 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_8 >> 8);
580 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_8 );
580 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_8 );
581 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
581 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
582 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
582 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
583 }
583 }
584 else
584 else
585 {
585 {
586 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
586 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
587 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
587 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
588 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
588 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
589 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
589 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
590 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
590 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
591 }
591 }
592 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
592 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
593 // PKT_CNT
593 // PKT_CNT
594 // PKT_NR
594 // PKT_NR
595 // DATA FIELD HEADER
595 // DATA FIELD HEADER
596 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
596 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
597 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
597 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
598 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
598 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
599 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
599 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
600 // AUXILIARY DATA HEADER
600 // AUXILIARY DATA HEADER
601 headerCWF[ i ].sid = sid;
601 headerCWF[ i ].sid = sid;
602 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
602 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
603 headerCWF[ i ].time[0] = 0x00;
603 headerCWF[ i ].time[0] = 0x00;
604 headerCWF[ i ].time[0] = 0x00;
604 headerCWF[ i ].time[0] = 0x00;
605 headerCWF[ i ].time[0] = 0x00;
605 headerCWF[ i ].time[0] = 0x00;
606 headerCWF[ i ].time[0] = 0x00;
606 headerCWF[ i ].time[0] = 0x00;
607 headerCWF[ i ].time[0] = 0x00;
607 headerCWF[ i ].time[0] = 0x00;
608 headerCWF[ i ].time[0] = 0x00;
608 headerCWF[ i ].time[0] = 0x00;
609 }
609 }
610 return LFR_SUCCESSFUL;
610 return LFR_SUCCESSFUL;
611 }
611 }
612
612
613 int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
613 int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
614 {
614 {
615 unsigned int i;
615 unsigned int i;
616
616
617 for (i=0; i<7; i++)
617 for (i=0; i<7; i++)
618 {
618 {
619 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
619 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
620 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
620 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
621 headerCWF[ i ].reserved = DEFAULT_RESERVED;
621 headerCWF[ i ].reserved = DEFAULT_RESERVED;
622 headerCWF[ i ].userApplication = CCSDS_USER_APP;
622 headerCWF[ i ].userApplication = CCSDS_USER_APP;
623
623
624 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
624 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
625 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
625 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
626 if (i == 0)
626 if (i == 0)
627 {
627 {
628 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
628 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
629 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
629 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
630 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
630 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
631 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
631 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
632 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
632 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
633 }
633 }
634 else if (i == 6)
634 else if (i == 6)
635 {
635 {
636 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
636 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
637 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 >> 8);
637 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 >> 8);
638 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 );
638 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 );
639 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
639 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
640 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
640 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
641 }
641 }
642 else
642 else
643 {
643 {
644 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
644 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
645 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
645 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
646 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
646 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
647 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
647 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
648 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
648 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
649 }
649 }
650 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
650 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
651 // DATA FIELD HEADER
651 // DATA FIELD HEADER
652 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
652 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
653 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
653 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
654 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
654 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
655 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
655 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
656 // AUXILIARY DATA HEADER
656 // AUXILIARY DATA HEADER
657 headerCWF[ i ].sid = SID_NORM_CWF_F3;
657 headerCWF[ i ].sid = SID_NORM_CWF_F3;
658 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
658 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
659 headerCWF[ i ].time[0] = 0x00;
659 headerCWF[ i ].time[0] = 0x00;
660 headerCWF[ i ].time[0] = 0x00;
660 headerCWF[ i ].time[0] = 0x00;
661 headerCWF[ i ].time[0] = 0x00;
661 headerCWF[ i ].time[0] = 0x00;
662 headerCWF[ i ].time[0] = 0x00;
662 headerCWF[ i ].time[0] = 0x00;
663 headerCWF[ i ].time[0] = 0x00;
663 headerCWF[ i ].time[0] = 0x00;
664 headerCWF[ i ].time[0] = 0x00;
664 headerCWF[ i ].time[0] = 0x00;
665 }
665 }
666 return LFR_SUCCESSFUL;
666 return LFR_SUCCESSFUL;
667 }
667 }
668
668
669 void reset_waveforms( void )
669 void reset_waveforms( void )
670 {
670 {
671 int i = 0;
671 int i = 0;
672
672
673 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
673 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
674 {
674 {
675 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x10002000;
675 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x10002000;
676 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
676 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
677 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
677 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
678
678
679 //***
679 //***
680 // F1
680 // F1
681 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x1000f000;
681 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x1000f000;
682 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0xf0001000;
682 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0xf0001000;
683 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
683 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
684
684
685 //***
685 //***
686 // F2
686 // F2
687 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x40008000;
687 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x40008000;
688 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
688 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
689 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x10002000;
689 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x10002000;
690
690
691 //***
691 //***
692 // F3
692 // F3
693 /*wf_cont_f3[ i* NB_WORDS_SWF_BLK + 0 ] = build_value( i, i ); // v and 1
693 /*wf_cont_f3[ i* NB_WORDS_SWF_BLK + 0 ] = build_value( i, i ); // v and 1
694 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 1 ] = build_value( i, i ); // e2 and b1
694 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 1 ] = build_value( i, i ); // e2 and b1
695 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 2 ] = build_value( i, i ); // b2 and b3*/
695 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 2 ] = build_value( i, i ); // b2 and b3*/
696 }
696 }
697 }
697 }
698
698
699 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
699 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
700 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
700 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
701 {
701 {
702 /** This function sends SWF CCSDS packets (F2, F1 or F0).
702 /** This function sends SWF CCSDS packets (F2, F1 or F0).
703 *
703 *
704 * @param waveform points to the buffer containing the data that will be send.
704 * @param waveform points to the buffer containing the data that will be send.
705 * @param sid is the source identifier of the data that will be sent.
705 * @param sid is the source identifier of the data that will be sent.
706 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
706 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
707 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
707 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
708 * contain information to setup the transmission of the data packets.
708 * contain information to setup the transmission of the data packets.
709 *
709 *
710 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
710 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
711 *
711 *
712 */
712 */
713
713
714 unsigned int i;
714 unsigned int i;
715 int ret;
715 int ret;
716 rtems_status_code status;
716 rtems_status_code status;
717 spw_ioctl_pkt_send spw_ioctl_send_SWF;
717 spw_ioctl_pkt_send spw_ioctl_send_SWF;
718
718
719 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
719 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
720 spw_ioctl_send_SWF.options = 0;
720 spw_ioctl_send_SWF.options = 0;
721
721
722 ret = LFR_DEFAULT;
722 ret = LFR_DEFAULT;
723
723
724 for (i=0; i<7; i++) // send waveform
724 for (i=0; i<7; i++) // send waveform
725 {
725 {
726 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
726 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
727 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
727 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
728 // BUILD THE DATA
728 // BUILD THE DATA
729 if (i==6) {
729 if (i==6) {
730 spw_ioctl_send_SWF.dlen = 8 * NB_BYTES_SWF_BLK;
730 spw_ioctl_send_SWF.dlen = 8 * NB_BYTES_SWF_BLK;
731 }
731 }
732 else {
732 else {
733 spw_ioctl_send_SWF.dlen = 340 * NB_BYTES_SWF_BLK;
733 spw_ioctl_send_SWF.dlen = 340 * NB_BYTES_SWF_BLK;
734 }
734 }
735 // SET PACKET SEQUENCE COUNTER
735 // SET PACKET SEQUENCE COUNTER
736 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
736 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
737 // SET PACKET TIME
737 // SET PACKET TIME
738 headerSWF[ i ].acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
738 headerSWF[ i ].acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
739 headerSWF[ i ].acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
739 headerSWF[ i ].acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
740 headerSWF[ i ].acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
740 headerSWF[ i ].acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
741 headerSWF[ i ].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
741 headerSWF[ i ].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
742 headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
742 headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
743 headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
743 headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
744 headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
744 headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
745 headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
745 headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
746 headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
746 headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
747 headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
747 headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
748 headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
748 headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
749 headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
749 headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
750 // SEND PACKET
750 // SEND PACKET
751 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
751 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
752 if (status != RTEMS_SUCCESSFUL) {
752 if (status != RTEMS_SUCCESSFUL) {
753 printf("%d-%d, ERR %d\n", sid, i, (int) status);
753 printf("%d-%d, ERR %d\n", sid, i, (int) status);
754 ret = LFR_DEFAULT;
754 ret = LFR_DEFAULT;
755 }
755 }
756 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
756 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
757 }
757 }
758
758
759 return ret;
759 return ret;
760 }
760 }
761
761
762 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
762 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
763 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
763 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
764 {
764 {
765 /** This function sends CWF CCSDS packets (F2, F1 or F0).
765 /** This function sends CWF CCSDS packets (F2, F1 or F0).
766 *
766 *
767 * @param waveform points to the buffer containing the data that will be send.
767 * @param waveform points to the buffer containing the data that will be send.
768 * @param sid is the source identifier of the data that will be sent.
768 * @param sid is the source identifier of the data that will be sent.
769 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
769 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
770 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
770 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
771 * contain information to setup the transmission of the data packets.
771 * contain information to setup the transmission of the data packets.
772 *
772 *
773 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
773 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
774 *
774 *
775 */
775 */
776
776
777 unsigned int i;
777 unsigned int i;
778 int ret;
778 int ret;
779 rtems_status_code status;
779 rtems_status_code status;
780 spw_ioctl_pkt_send spw_ioctl_send_CWF;
780 spw_ioctl_pkt_send spw_ioctl_send_CWF;
781
781
782 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
782 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
783 spw_ioctl_send_CWF.options = 0;
783 spw_ioctl_send_CWF.options = 0;
784
784
785 ret = LFR_DEFAULT;
785 ret = LFR_DEFAULT;
786
786
787 for (i=0; i<7; i++) // send waveform
787 for (i=0; i<7; i++) // send waveform
788 {
788 {
789 int coarseTime = 0x00;
789 int coarseTime = 0x00;
790 int fineTime = 0x00;
790 int fineTime = 0x00;
791 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
791 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
792 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
792 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
793 // BUILD THE DATA
793 // BUILD THE DATA
794 if (i==6) {
794 if (i==6) {
795 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_SWF_BLK;
795 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_SWF_BLK;
796 }
796 }
797 else {
797 else {
798 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_SWF_BLK;
798 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_SWF_BLK;
799 }
799 }
800 // SET PACKET SEQUENCE COUNTER
800 // SET PACKET SEQUENCE COUNTER
801 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
801 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
802 // SET PACKET TIME
802 // SET PACKET TIME
803 coarseTime = time_management_regs->coarse_time;
803 coarseTime = time_management_regs->coarse_time;
804 fineTime = time_management_regs->fine_time;
804 fineTime = time_management_regs->fine_time;
805 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
805 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
806 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
806 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
807 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
807 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
808 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
808 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
809 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
809 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
810 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
810 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
811 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
811 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
812 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
812 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
813 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
813 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
814 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
814 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
815 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
815 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
816 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
816 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
817 // SEND PACKET
817 // SEND PACKET
818 if (sid == SID_NORM_CWF_F3)
818 if (sid == SID_NORM_CWF_F3)
819 {
819 {
820 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
820 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
821 if (status != RTEMS_SUCCESSFUL) {
821 if (status != RTEMS_SUCCESSFUL) {
822 printf("%d-%d, ERR %d\n", sid, i, (int) status);
822 printf("%d-%d, ERR %d\n", sid, i, (int) status);
823 ret = LFR_DEFAULT;
823 ret = LFR_DEFAULT;
824 }
824 }
825 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
825 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
826 }
826 }
827 else
827 else
828 {
828 {
829 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
829 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
830 if (status != RTEMS_SUCCESSFUL) {
830 if (status != RTEMS_SUCCESSFUL) {
831 printf("%d-%d, ERR %d\n", sid, i, (int) status);
831 printf("%d-%d, ERR %d\n", sid, i, (int) status);
832 ret = LFR_DEFAULT;
832 ret = LFR_DEFAULT;
833 }
833 }
834 }
834 }
835 }
835 }
836
836
837 return ret;
837 return ret;
838 }
838 }
839
839
840 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
840 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
841 {
841 {
842 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
842 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
843 *
843 *
844 * @param waveform points to the buffer containing the data that will be send.
844 * @param waveform points to the buffer containing the data that will be send.
845 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
845 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
846 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
846 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
847 * contain information to setup the transmission of the data packets.
847 * contain information to setup the transmission of the data packets.
848 *
848 *
849 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
849 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
850 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
850 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
851 *
851 *
852 */
852 */
853
853
854 unsigned int i;
854 unsigned int i;
855 int ret;
855 int ret;
856 rtems_status_code status;
856 rtems_status_code status;
857 spw_ioctl_pkt_send spw_ioctl_send_CWF;
857 spw_ioctl_pkt_send spw_ioctl_send_CWF;
858 char *sample;
858 char *sample;
859
859
860 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
860 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
861 spw_ioctl_send_CWF.options = 0;
861 spw_ioctl_send_CWF.options = 0;
862
862
863 ret = LFR_DEFAULT;
863 ret = LFR_DEFAULT;
864
864
865 //**********************
865 //**********************
866 // BUILD CWF3_light DATA
866 // BUILD CWF3_light DATA
867 for ( i=0; i< 2048; i++)
867 for ( i=0; i< 2048; i++)
868 {
868 {
869 sample = (char*) &waveform[ i * NB_WORDS_SWF_BLK ];
869 sample = (char*) &waveform[ i * NB_WORDS_SWF_BLK ];
870 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ];
870 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ];
871 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ];
871 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ];
872 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ];
872 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ];
873 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ];
873 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ];
874 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ];
874 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ];
875 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ];
875 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ];
876 }
876 }
877
877
878 //*********************
878 //*********************
879 // SEND CWF3_light DATA
879 // SEND CWF3_light DATA
880
880
881 for (i=0; i<7; i++) // send waveform
881 for (i=0; i<7; i++) // send waveform
882 {
882 {
883 int coarseTime = 0x00;
883 int coarseTime = 0x00;
884 int fineTime = 0x00;
884 int fineTime = 0x00;
885 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * 340 * NB_BYTES_CWF3_LIGHT_BLK) ];
885 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * 340 * NB_BYTES_CWF3_LIGHT_BLK) ];
886 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
886 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
887 // BUILD THE DATA
887 // BUILD THE DATA
888 if ( i == WFRM_INDEX_OF_LAST_PACKET ) {
888 if ( i == WFRM_INDEX_OF_LAST_PACKET ) {
889 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_CWF3_LIGHT_BLK;
889 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_CWF3_LIGHT_BLK;
890 }
890 }
891 else {
891 else {
892 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_CWF3_LIGHT_BLK;
892 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_CWF3_LIGHT_BLK;
893 }
893 }
894 // SET PACKET SEQUENCE COUNTER
894 // SET PACKET SEQUENCE COUNTER
895 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
895 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
896 // SET PACKET TIME
896 // SET PACKET TIME
897 coarseTime = time_management_regs->coarse_time;
897 coarseTime = time_management_regs->coarse_time;
898 fineTime = time_management_regs->fine_time;
898 fineTime = time_management_regs->fine_time;
899 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
899 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
900 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
900 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
901 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
901 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
902 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
902 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
903 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
903 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
904 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
904 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
905 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
905 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
906 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
906 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
907 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
907 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
908 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
908 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
909 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
909 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
910 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
910 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
911 // SEND PACKET
911 // SEND PACKET
912 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
912 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
913 if (status != RTEMS_SUCCESSFUL) {
913 if (status != RTEMS_SUCCESSFUL) {
914 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
914 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
915 ret = LFR_DEFAULT;
915 ret = LFR_DEFAULT;
916 }
916 }
917 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
917 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
918 }
918 }
919
919
920 return ret;
920 return ret;
921 }
921 }
922
922
923
923
924 //**************
924 //**************
925 // wfp registers
925 // wfp registers
926 void set_wfp_data_shaping()
926 void set_wfp_data_shaping()
927 {
927 {
928 /** This function sets the data_shaping register of the waveform picker module.
928 /** This function sets the data_shaping register of the waveform picker module.
929 *
929 *
930 * The value is read from one field of the parameter_dump_packet structure:\n
930 * The value is read from one field of the parameter_dump_packet structure:\n
931 * bw_sp0_sp1_r0_r1
931 * bw_sp0_sp1_r0_r1
932 *
932 *
933 */
933 */
934
934
935 unsigned char data_shaping;
935 unsigned char data_shaping;
936
936
937 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
937 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
938 // waveform picker : [R1 R0 SP1 SP0 BW]
938 // waveform picker : [R1 R0 SP1 SP0 BW]
939
939
940 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
940 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
941
941
942 #ifdef GSA
942 #ifdef GSA
943 #else
943 #else
944 waveform_picker_regs->data_shaping =
944 waveform_picker_regs->data_shaping =
945 ( (data_shaping & 0x10) >> 4 ) // BW
945 ( (data_shaping & 0x10) >> 4 ) // BW
946 + ( (data_shaping & 0x08) >> 2 ) // SP0
946 + ( (data_shaping & 0x08) >> 2 ) // SP0
947 + ( (data_shaping & 0x04) ) // SP1
947 + ( (data_shaping & 0x04) ) // SP1
948 + ( (data_shaping & 0x02) << 2 ) // R0
948 + ( (data_shaping & 0x02) << 2 ) // R0
949 + ( (data_shaping & 0x01) << 4 ); // R1
949 + ( (data_shaping & 0x01) << 4 ); // R1
950 #endif
950 #endif
951 }
951 }
952
952
953 char set_wfp_delta_snapshot()
953 char set_wfp_delta_snapshot()
954 {
954 {
955 /** This function sets the delta_snapshot register of the waveform picker module.
955 /** This function sets the delta_snapshot register of the waveform picker module.
956 *
956 *
957 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
957 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
958 * - sy_lfr_n_swf_p[0]
958 * - sy_lfr_n_swf_p[0]
959 * - sy_lfr_n_swf_p[1]
959 * - sy_lfr_n_swf_p[1]
960 *
960 *
961 */
961 */
962
962
963 char ret;
963 char ret;
964 unsigned int delta_snapshot;
964 unsigned int delta_snapshot;
965 unsigned int aux;
965 unsigned int aux;
966
966
967 aux = 0;
967 aux = 0;
968 ret = LFR_DEFAULT;
968 ret = LFR_DEFAULT;
969
969
970 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
970 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
971 + parameter_dump_packet.sy_lfr_n_swf_p[1];
971 + parameter_dump_packet.sy_lfr_n_swf_p[1];
972
972
973 #ifdef GSA
973 #ifdef GSA
974 #else
974 #else
975 if ( delta_snapshot < MIN_DELTA_SNAPSHOT )
975 if ( delta_snapshot < MIN_DELTA_SNAPSHOT )
976 {
976 {
977 aux = MIN_DELTA_SNAPSHOT;
977 aux = MIN_DELTA_SNAPSHOT;
978 ret = LFR_DEFAULT;
978 ret = LFR_DEFAULT;
979 }
979 }
980 else
980 else
981 {
981 {
982 aux = delta_snapshot ;
982 aux = delta_snapshot ;
983 ret = LFR_SUCCESSFUL;
983 ret = LFR_SUCCESSFUL;
984 }
984 }
985 waveform_picker_regs->delta_snapshot = aux - 1; // max 2 bytes
985 waveform_picker_regs->delta_snapshot = aux - 1; // max 2 bytes
986 #endif
986 #endif
987
987
988 return ret;
988 return ret;
989 }
989 }
990
990
991 void set_wfp_burst_enable_register( unsigned char mode)
991 void set_wfp_burst_enable_register( unsigned char mode)
992 {
992 {
993 /** This function sets the waveform picker burst_enable register depending on the mode.
993 /** This function sets the waveform picker burst_enable register depending on the mode.
994 *
994 *
995 * @param mode is the LFR mode to launch.
995 * @param mode is the LFR mode to launch.
996 *
996 *
997 * The burst bits shall be before the enable bits.
997 * The burst bits shall be before the enable bits.
998 *
998 *
999 */
999 */
1000
1000
1001 #ifdef GSA
1001 #ifdef GSA
1002 #else
1002 #else
1003 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1003 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1004 // the burst bits shall be set first, before the enable bits
1004 // the burst bits shall be set first, before the enable bits
1005 switch(mode) {
1005 switch(mode) {
1006 case(LFR_MODE_NORMAL):
1006 case(LFR_MODE_NORMAL):
1007 waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enable
1007 waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enable
1008 waveform_picker_regs->burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1008 waveform_picker_regs->burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1009 break;
1009 break;
1010 case(LFR_MODE_BURST):
1010 case(LFR_MODE_BURST):
1011 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled
1011 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled
1012 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x04; // [0100] enable f2
1012 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x04; // [0100] enable f2
1013 break;
1013 break;
1014 case(LFR_MODE_SBM1):
1014 case(LFR_MODE_SBM1):
1015 waveform_picker_regs->burst_enable = 0x20; // [0010 0000] f1 burst enabled
1015 waveform_picker_regs->burst_enable = 0x20; // [0010 0000] f1 burst enabled
1016 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1016 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1017 break;
1017 break;
1018 case(LFR_MODE_SBM2):
1018 case(LFR_MODE_SBM2):
1019 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled
1019 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled
1020 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1020 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1021 break;
1021 break;
1022 default:
1022 default:
1023 waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1023 waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1024 break;
1024 break;
1025 }
1025 }
1026 #endif
1026 #endif
1027 }
1027 }
1028
1028
1029 void reset_wfp_burst_enable()
1029 void reset_wfp_burst_enable()
1030 {
1030 {
1031 /** This function resets the waveform picker burst_enable register.
1031 /** This function resets the waveform picker burst_enable register.
1032 *
1032 *
1033 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1033 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1034 *
1034 *
1035 */
1035 */
1036
1036
1037 #ifdef GSA
1037 #ifdef GSA
1038 #else
1038 #else
1039 waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1039 waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1040 #endif
1040 #endif
1041 }
1041 }
1042
1042
1043 void reset_wfp_status()
1043 void reset_wfp_status()
1044 {
1044 {
1045 /** This function resets the waveform picker status register.
1045 /** This function resets the waveform picker status register.
1046 *
1046 *
1047 * All status bits are set to 0 [new_err full_err full].
1047 * All status bits are set to 0 [new_err full_err full].
1048 *
1048 *
1049 */
1049 */
1050
1050
1051 #ifdef GSA
1051 #ifdef GSA
1052 #else
1052 #else
1053 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1053 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1054 #endif
1054 #endif
1055 }
1055 }
1056
1056
1057 void reset_waveform_picker_regs()
1057 void reset_waveform_picker_regs()
1058 {
1058 {
1059 /** This function resets the waveform picker module registers.
1059 /** This function resets the waveform picker module registers.
1060 *
1060 *
1061 * The registers affected by this function are located at the following offset addresses:
1061 * The registers affected by this function are located at the following offset addresses:
1062 * - 0x00 data_shaping
1062 * - 0x00 data_shaping
1063 * - 0x04 burst_enable
1063 * - 0x04 burst_enable
1064 * - 0x08 addr_data_f0
1064 * - 0x08 addr_data_f0
1065 * - 0x0C addr_data_f1
1065 * - 0x0C addr_data_f1
1066 * - 0x10 addr_data_f2
1066 * - 0x10 addr_data_f2
1067 * - 0x14 addr_data_f3
1067 * - 0x14 addr_data_f3
1068 * - 0x18 status
1068 * - 0x18 status
1069 * - 0x1C delta_snapshot
1069 * - 0x1C delta_snapshot
1070 * - 0x20 delta_f2_f1
1070 * - 0x20 delta_f2_f1
1071 * - 0x24 delta_f2_f0
1071 * - 0x24 delta_f2_f0
1072 * - 0x28 nb_burst
1072 * - 0x28 nb_burst
1073 * - 0x2C nb_snapshot
1073 * - 0x2C nb_snapshot
1074 *
1074 *
1075 */
1075 */
1076
1076
1077 #ifdef GSA
1077 #ifdef GSA
1078 #else
1078 #else
1079 reset_wfp_burst_enable();
1079 reset_wfp_burst_enable();
1080 reset_wfp_status();
1080 reset_wfp_status();
1081 // set buffer addresses
1081 // set buffer addresses
1082 waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); //
1082 waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); //
1083 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); //
1083 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); //
1084 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); //
1084 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); //
1085 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); //
1085 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); //
1086 // set other parameters
1086 // set other parameters
1087 set_wfp_data_shaping();
1087 set_wfp_data_shaping();
1088 set_wfp_delta_snapshot(); // time in seconds between two snapshots
1088 set_wfp_delta_snapshot(); // time in seconds between two snapshots
1089 waveform_picker_regs->delta_f2_f1 = 0xffff; // 0x16800 => 92160 (max 4 bytes)
1089 waveform_picker_regs->delta_f2_f1 = 0xffff; // 0x16800 => 92160 (max 4 bytes)
1090 waveform_picker_regs->delta_f2_f0 = 0x17c00; // 97 280 (max 5 bytes)
1090 waveform_picker_regs->delta_f2_f0 = 0x17c00; // 97 280 (max 5 bytes)
1091 waveform_picker_regs->nb_burst_available = 0x180; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets)
1091 waveform_picker_regs->nb_burst_available = 0x180; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets)
1092 waveform_picker_regs->nb_snapshot_param = 0x7ff; // max 3 octets, 2048 - 1
1092 waveform_picker_regs->nb_snapshot_param = 0x7ff; // max 3 octets, 2048 - 1
1093 #endif
1093 #endif
1094 }
1094 }
1095
1095
1096 //*****************
1096 //*****************
1097 // local parameters
1097 // local parameters
1098 void set_local_sbm1_nb_cwf_max()
1098 void set_local_sbm1_nb_cwf_max()
1099 {
1099 {
1100 /** This function sets the value of the sbm1_nb_cwf_max local parameter.
1100 /** This function sets the value of the sbm1_nb_cwf_max local parameter.
1101 *
1101 *
1102 * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n
1102 * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n
1103 * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.\n\n
1103 * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.\n\n
1104 * (2 snapshots of 2048 points per seconds) * (period of the NORM snashots) - 8 s (duration of the f2 snapshot)
1104 * (2 snapshots of 2048 points per seconds) * (period of the NORM snashots) - 8 s (duration of the f2 snapshot)
1105 *
1105 *
1106 */
1106 */
1107 param_local.local_sbm1_nb_cwf_max = 2 *
1107 param_local.local_sbm1_nb_cwf_max = 2 *
1108 (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
1108 (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
1109 + parameter_dump_packet.sy_lfr_n_swf_p[1]) - 8; // 16 CWF1 parts during 1 SWF2
1109 + parameter_dump_packet.sy_lfr_n_swf_p[1]) - 8; // 16 CWF1 parts during 1 SWF2
1110 }
1110 }
1111
1111
1112 void set_local_sbm2_nb_cwf_max()
1112 void set_local_sbm2_nb_cwf_max()
1113 {
1113 {
1114 /** This function sets the value of the sbm1_nb_cwf_max local parameter.
1114 /** This function sets the value of the sbm1_nb_cwf_max local parameter.
1115 *
1115 *
1116 * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n
1116 * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n
1117 * This parameter is used to send CWF_F2 data as normal data when the SBM2 is active.\n\n
1117 * This parameter is used to send CWF_F2 data as normal data when the SBM2 is active.\n\n
1118 * (period of the NORM snashots) / (8 seconds per snapshot at f2 = 256 Hz)
1118 * (period of the NORM snashots) / (8 seconds per snapshot at f2 = 256 Hz)
1119 *
1119 *
1120 */
1120 */
1121
1121
1122 param_local.local_sbm2_nb_cwf_max = (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
1122 param_local.local_sbm2_nb_cwf_max = (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
1123 + parameter_dump_packet.sy_lfr_n_swf_p[1]) / 8;
1123 + parameter_dump_packet.sy_lfr_n_swf_p[1]) / 8;
1124 }
1124 }
1125
1125
1126 void set_local_nb_interrupt_f0_MAX()
1126 void set_local_nb_interrupt_f0_MAX()
1127 {
1127 {
1128 /** This function sets the value of the nb_interrupt_f0_MAX local parameter.
1128 /** This function sets the value of the nb_interrupt_f0_MAX local parameter.
1129 *
1129 *
1130 * This parameter is used for the SM validation only.\n
1130 * This parameter is used for the SM validation only.\n
1131 * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices
1131 * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices
1132 * module before launching a basic processing.
1132 * module before launching a basic processing.
1133 *
1133 *
1134 */
1134 */
1135
1135
1136 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
1136 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
1137 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
1137 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
1138 }
1138 }
1139
1139
1140 void reset_local_sbm1_nb_cwf_sent()
1140 void reset_local_sbm1_nb_cwf_sent()
1141 {
1141 {
1142 /** This function resets the value of the sbm1_nb_cwf_sent local parameter.
1142 /** This function resets the value of the sbm1_nb_cwf_sent local parameter.
1143 *
1143 *
1144 * The sbm1_nb_cwf_sent parameter counts the number of CWF_F1 records that have been sent.\n
1144 * The sbm1_nb_cwf_sent parameter counts the number of CWF_F1 records that have been sent.\n
1145 * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.
1145 * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.
1146 *
1146 *
1147 */
1147 */
1148
1148
1149 param_local.local_sbm1_nb_cwf_sent = 0;
1149 param_local.local_sbm1_nb_cwf_sent = 0;
1150 }
1150 }
1151
1151
1152 void reset_local_sbm2_nb_cwf_sent()
1152 void reset_local_sbm2_nb_cwf_sent()
1153 {
1153 {
1154 /** This function resets the value of the sbm2_nb_cwf_sent local parameter.
1154 /** This function resets the value of the sbm2_nb_cwf_sent local parameter.
1155 *
1155 *
1156 * The sbm2_nb_cwf_sent parameter counts the number of CWF_F2 records that have been sent.\n
1156 * The sbm2_nb_cwf_sent parameter counts the number of CWF_F2 records that have been sent.\n
1157 * This parameter is used to send CWF_F2 data as normal data when the SBM2 mode is active.
1157 * This parameter is used to send CWF_F2 data as normal data when the SBM2 mode is active.
1158 *
1158 *
1159 */
1159 */
1160
1160
1161 param_local.local_sbm2_nb_cwf_sent = 0;
1161 param_local.local_sbm2_nb_cwf_sent = 0;
1162 }
1162 }
1163
1163
1164 rtems_id get_pkts_queue_id( void )
1164 rtems_id get_pkts_queue_id( void )
1165 {
1165 {
1166 rtems_id queue_id;
1166 rtems_id queue_id;
1167 rtems_status_code status;
1167 rtems_status_code status;
1168 rtems_name queue_send_name;
1168 rtems_name queue_send_name;
1169
1169
1170 queue_send_name = rtems_build_name( 'Q', '_', 'S', 'D' );
1170 queue_send_name = rtems_build_name( 'Q', '_', 'S', 'D' );
1171
1171
1172 status = rtems_message_queue_ident( queue_send_name, 0, &queue_id );
1172 status = rtems_message_queue_ident( queue_send_name, 0, &queue_id );
1173 if (status != RTEMS_SUCCESSFUL)
1173 if (status != RTEMS_SUCCESSFUL)
1174 {
1174 {
1175 PRINTF1("in get_pkts_queue_id *** ERR %d\n", status)
1175 PRINTF1("in get_pkts_queue_id *** ERR %d\n", status)
1176 }
1176 }
1177 return queue_id;
1177 return queue_id;
1178 }
1178 }
1179
1179
1180 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1180 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1181 {
1181 {
1182 unsigned short *sequence_cnt;
1182 unsigned short *sequence_cnt;
1183 unsigned short segmentation_grouping_flag;
1183 unsigned short segmentation_grouping_flag;
1184 unsigned short new_packet_sequence_control;
1184 unsigned short new_packet_sequence_control;
1185
1185
1186 if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2)
1186 if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2)
1187 || (sid ==SID_BURST_CWF_F2) )
1187 || (sid ==SID_NORM_CWF_F3) || (sid ==SID_BURST_CWF_F2) )
1188 {
1188 {
1189 sequence_cnt = &sequenceCounters_SCIENCE_NORMAL_BURST;
1189 sequence_cnt = &sequenceCounters_SCIENCE_NORMAL_BURST;
1190 }
1190 }
1191 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) )
1191 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) )
1192 {
1192 {
1193 sequence_cnt = &sequenceCounters_SCIENCE_SBM1_SBM2;
1193 sequence_cnt = &sequenceCounters_SCIENCE_SBM1_SBM2;
1194 }
1194 }
1195 else
1195 else
1196 {
1196 {
1197 sequence_cnt = &sequenceCounters_TC_EXE[ UNKNOWN ];
1197 sequence_cnt = &sequenceCounters_TC_EXE[ UNKNOWN ];
1198 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1198 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1199 }
1199 }
1200
1200
1201 segmentation_grouping_flag = (packet_sequence_control[ 0 ] & 0xc0) << 8;
1201 segmentation_grouping_flag = (packet_sequence_control[ 0 ] & 0xc0) << 8;
1202 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1202 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1203
1203
1204 new_packet_sequence_control = segmentation_grouping_flag | *sequence_cnt ;
1204 new_packet_sequence_control = segmentation_grouping_flag | *sequence_cnt ;
1205
1205
1206 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1206 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1207 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1207 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1208
1208
1209 // increment the seuqence counter for the next packet
1209 // increment the seuqence counter for the next packet
1210 if ( *sequence_cnt < SEQ_CNT_MAX)
1210 if ( *sequence_cnt < SEQ_CNT_MAX)
1211 {
1211 {
1212 *sequence_cnt = *sequence_cnt + 1;
1212 *sequence_cnt = *sequence_cnt + 1;
1213 }
1213 }
1214 else
1214 else
1215 {
1215 {
1216 *sequence_cnt = 0;
1216 *sequence_cnt = 0;
1217 }
1217 }
1218
1218
1219 }
1219 }
General Comments 0
You need to be logged in to leave comments. Login now