@@ -1,2 +1,2 | |||||
1 | 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters |
|
1 | 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters | |
2 | db74b38fe91cd826fa49fa4eb6f93d626637ceb9 header/lfr_common_headers |
|
2 | 1b9238c8848953d545d6ff9c9b8b15d19a597fb6 header/lfr_common_headers |
@@ -1,170 +1,171 | |||||
1 | #ifndef FSW_MISC_H_INCLUDED |
|
1 | #ifndef FSW_MISC_H_INCLUDED | |
2 | #define FSW_MISC_H_INCLUDED |
|
2 | #define FSW_MISC_H_INCLUDED | |
3 |
|
3 | |||
4 | #include <rtems.h> |
|
4 | #include <rtems.h> | |
5 | #include <stdio.h> |
|
5 | #include <stdio.h> | |
6 | #include <grspw.h> |
|
6 | #include <grspw.h> | |
7 | #include <grlib_regs.h> |
|
7 | #include <grlib_regs.h> | |
8 |
|
8 | |||
9 | #include "fsw_params.h" |
|
9 | #include "fsw_params.h" | |
10 | #include "fsw_spacewire.h" |
|
10 | #include "fsw_spacewire.h" | |
11 | #include "lfr_cpu_usage_report.h" |
|
11 | #include "lfr_cpu_usage_report.h" | |
12 |
|
12 | |||
13 | #define LFR_RESET_CAUSE_UNKNOWN_CAUSE 0 |
|
13 | #define LFR_RESET_CAUSE_UNKNOWN_CAUSE 0 | |
14 | #define WATCHDOG_LOOP_PRINTF 10 |
|
14 | #define WATCHDOG_LOOP_PRINTF 10 | |
15 | #define WATCHDOG_LOOP_DEBUG 3 |
|
15 | #define WATCHDOG_LOOP_DEBUG 3 | |
16 |
|
16 | |||
17 | #define DUMB_MESSAGE_NB 15 |
|
17 | #define DUMB_MESSAGE_NB 15 | |
18 | #define NB_RTEMS_EVENTS 32 |
|
18 | #define NB_RTEMS_EVENTS 32 | |
19 | #define EVENT_12 12 |
|
19 | #define EVENT_12 12 | |
20 | #define EVENT_13 13 |
|
20 | #define EVENT_13 13 | |
21 | #define EVENT_14 14 |
|
21 | #define EVENT_14 14 | |
22 | #define DUMB_MESSAGE_0 "in DUMB *** default" |
|
22 | #define DUMB_MESSAGE_0 "in DUMB *** default" | |
23 | #define DUMB_MESSAGE_1 "in DUMB *** timecode_irq_handler" |
|
23 | #define DUMB_MESSAGE_1 "in DUMB *** timecode_irq_handler" | |
24 | #define DUMB_MESSAGE_2 "in DUMB *** f3 buffer changed" |
|
24 | #define DUMB_MESSAGE_2 "in DUMB *** f3 buffer changed" | |
25 | #define DUMB_MESSAGE_3 "in DUMB *** in SMIQ *** Error sending event to AVF0" |
|
25 | #define DUMB_MESSAGE_3 "in DUMB *** in SMIQ *** Error sending event to AVF0" | |
26 | #define DUMB_MESSAGE_4 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ" |
|
26 | #define DUMB_MESSAGE_4 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ" | |
27 | #define DUMB_MESSAGE_5 "in DUMB *** waveforms_simulator_isr" |
|
27 | #define DUMB_MESSAGE_5 "in DUMB *** waveforms_simulator_isr" | |
28 | #define DUMB_MESSAGE_6 "VHDL SM *** two buffers f0 ready" |
|
28 | #define DUMB_MESSAGE_6 "VHDL SM *** two buffers f0 ready" | |
29 | #define DUMB_MESSAGE_7 "ready for dump" |
|
29 | #define DUMB_MESSAGE_7 "ready for dump" | |
30 | #define DUMB_MESSAGE_8 "VHDL ERR *** spectral matrix" |
|
30 | #define DUMB_MESSAGE_8 "VHDL ERR *** spectral matrix" | |
31 | #define DUMB_MESSAGE_9 "tick" |
|
31 | #define DUMB_MESSAGE_9 "tick" | |
32 | #define DUMB_MESSAGE_10 "VHDL ERR *** waveform picker" |
|
32 | #define DUMB_MESSAGE_10 "VHDL ERR *** waveform picker" | |
33 | #define DUMB_MESSAGE_11 "VHDL ERR *** unexpected ready matrix values" |
|
33 | #define DUMB_MESSAGE_11 "VHDL ERR *** unexpected ready matrix values" | |
34 | #define DUMB_MESSAGE_12 "WATCHDOG timer" |
|
34 | #define DUMB_MESSAGE_12 "WATCHDOG timer" | |
35 | #define DUMB_MESSAGE_13 "TIMECODE timer" |
|
35 | #define DUMB_MESSAGE_13 "TIMECODE timer" | |
36 | #define DUMB_MESSAGE_14 "TIMECODE ISR" |
|
36 | #define DUMB_MESSAGE_14 "TIMECODE ISR" | |
37 |
|
37 | |||
38 | enum lfr_reset_cause_t{ |
|
38 | enum lfr_reset_cause_t{ | |
39 | UNKNOWN_CAUSE, |
|
39 | UNKNOWN_CAUSE, | |
40 | POWER_ON, |
|
40 | POWER_ON, | |
41 | TC_RESET, |
|
41 | TC_RESET, | |
42 | WATCHDOG, |
|
42 | WATCHDOG, | |
43 | ERROR_RESET, |
|
43 | ERROR_RESET, | |
44 | UNEXP_RESET |
|
44 | UNEXP_RESET | |
45 | }; |
|
45 | }; | |
46 |
|
46 | |||
47 | typedef struct{ |
|
47 | typedef struct{ | |
48 | unsigned char dpu_spw_parity; |
|
48 | unsigned char dpu_spw_parity; | |
49 | unsigned char dpu_spw_disconnect; |
|
49 | unsigned char dpu_spw_disconnect; | |
50 | unsigned char dpu_spw_escape; |
|
50 | unsigned char dpu_spw_escape; | |
51 | unsigned char dpu_spw_credit; |
|
51 | unsigned char dpu_spw_credit; | |
52 | unsigned char dpu_spw_write_sync; |
|
52 | unsigned char dpu_spw_write_sync; | |
53 | unsigned char timecode_erroneous; |
|
53 | unsigned char timecode_erroneous; | |
54 | unsigned char timecode_missing; |
|
54 | unsigned char timecode_missing; | |
55 | unsigned char timecode_invalid; |
|
55 | unsigned char timecode_invalid; | |
56 | unsigned char time_timecode_it; |
|
56 | unsigned char time_timecode_it; | |
57 | unsigned char time_not_synchro; |
|
57 | unsigned char time_not_synchro; | |
58 | unsigned char time_timecode_ctr; |
|
58 | unsigned char time_timecode_ctr; | |
59 | unsigned char ahb_correctable; |
|
59 | unsigned char ahb_correctable; | |
60 | } hk_lfr_le_t; |
|
60 | } hk_lfr_le_t; | |
61 |
|
61 | |||
62 | typedef struct{ |
|
62 | typedef struct{ | |
63 | unsigned char dpu_spw_early_eop; |
|
63 | unsigned char dpu_spw_early_eop; | |
64 | unsigned char dpu_spw_invalid_addr; |
|
64 | unsigned char dpu_spw_invalid_addr; | |
65 | unsigned char dpu_spw_eep; |
|
65 | unsigned char dpu_spw_eep; | |
66 | unsigned char dpu_spw_rx_too_big; |
|
66 | unsigned char dpu_spw_rx_too_big; | |
67 | } hk_lfr_me_t; |
|
67 | } hk_lfr_me_t; | |
68 |
|
68 | |||
69 | #define B00 196 |
|
69 | #define B00 196 | |
70 | #define B01 196 |
|
70 | #define B01 196 | |
71 | #define B02 0 |
|
71 | #define B02 0 | |
72 | #define B10 131 |
|
72 | #define B10 131 | |
73 | #define B11 -244 |
|
73 | #define B11 -244 | |
74 | #define B12 131 |
|
74 | #define B12 131 | |
75 | #define B20 161 |
|
75 | #define B20 161 | |
76 | #define B21 -314 |
|
76 | #define B21 -314 | |
77 | #define B22 161 |
|
77 | #define B22 161 | |
78 |
|
78 | |||
79 | #define A00 1 |
|
79 | #define A00 1 | |
80 | #define A01 -925 |
|
80 | #define A01 -925 | |
81 | #define A02 0 |
|
81 | #define A02 0 | |
82 | #define A10 1 |
|
82 | #define A10 1 | |
83 | #define A11 -947 |
|
83 | #define A11 -947 | |
84 | #define A12 439 |
|
84 | #define A12 439 | |
85 | #define A20 1 |
|
85 | #define A20 1 | |
86 | #define A21 -993 |
|
86 | #define A21 -993 | |
87 | #define A22 486 |
|
87 | #define A22 486 | |
88 |
|
88 | |||
89 | #define GAIN_B0 12 |
|
89 | #define GAIN_B0 12 | |
90 | #define GAIN_B1 11 |
|
90 | #define GAIN_B1 11 | |
91 | #define GAIN_B2 10 |
|
91 | #define GAIN_B2 10 | |
92 |
|
92 | |||
93 | #define GAIN_A0 10 |
|
93 | #define GAIN_A0 10 | |
94 | #define GAIN_A1 9 |
|
94 | #define GAIN_A1 9 | |
95 | #define GAIN_A2 9 |
|
95 | #define GAIN_A2 9 | |
96 |
|
96 | |||
97 | #define NB_COEFFS 3 |
|
97 | #define NB_COEFFS 3 | |
98 | #define COEFF0 0 |
|
98 | #define COEFF0 0 | |
99 | #define COEFF1 1 |
|
99 | #define COEFF1 1 | |
100 | #define COEFF2 2 |
|
100 | #define COEFF2 2 | |
101 |
|
101 | |||
102 | typedef struct filter_ctx |
|
102 | typedef struct filter_ctx | |
103 | { |
|
103 | { | |
104 | int W[NB_COEFFS][NB_COEFFS]; |
|
104 | int W[NB_COEFFS][NB_COEFFS]; | |
105 | }filter_ctx; |
|
105 | }filter_ctx; | |
106 |
|
106 | |||
107 | extern gptimer_regs_t *gptimer_regs; |
|
107 | extern gptimer_regs_t *gptimer_regs; | |
108 | extern void ASR16_get_FPRF_IURF_ErrorCounters( unsigned int*, unsigned int* ); |
|
108 | extern void ASR16_get_FPRF_IURF_ErrorCounters( unsigned int*, unsigned int* ); | |
109 | extern void CCR_getInstructionAndDataErrorCounters( unsigned int*, unsigned int* ); |
|
109 | extern void CCR_getInstructionAndDataErrorCounters( unsigned int*, unsigned int* ); | |
110 |
|
110 | |||
111 | extern rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic |
|
111 | extern rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic | |
112 | extern rtems_id HK_id;// id of the HK rate monotonic period |
|
112 | extern rtems_id HK_id;// id of the HK rate monotonic period | |
113 | extern rtems_name name_avgv_rate_monotonic; // name of the AVGV rate monotonic |
|
113 | extern rtems_name name_avgv_rate_monotonic; // name of the AVGV rate monotonic | |
114 | extern rtems_id AVGV_id;// id of the AVGV rate monotonic period |
|
114 | extern rtems_id AVGV_id;// id of the AVGV rate monotonic period | |
115 |
|
115 | |||
116 | void timer_configure( unsigned char timer, unsigned int clock_divider, |
|
116 | void timer_configure( unsigned char timer, unsigned int clock_divider, | |
117 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ); |
|
117 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ); | |
118 | void timer_start( unsigned char timer ); |
|
118 | void timer_start( unsigned char timer ); | |
119 | void timer_stop( unsigned char timer ); |
|
119 | void timer_stop( unsigned char timer ); | |
120 | void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider); |
|
120 | void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider); | |
121 |
|
121 | |||
122 | // WATCHDOG |
|
122 | // WATCHDOG | |
123 | rtems_isr watchdog_isr( rtems_vector_number vector ); |
|
123 | rtems_isr watchdog_isr( rtems_vector_number vector ); | |
124 | void watchdog_configure(void); |
|
124 | void watchdog_configure(void); | |
125 | void watchdog_stop(void); |
|
125 | void watchdog_stop(void); | |
126 | void watchdog_reload(void); |
|
126 | void watchdog_reload(void); | |
127 | void watchdog_start(void); |
|
127 | void watchdog_start(void); | |
128 |
|
128 | |||
129 | // SERIAL LINK |
|
129 | // SERIAL LINK | |
130 | int send_console_outputs_on_apbuart_port( void ); |
|
130 | int send_console_outputs_on_apbuart_port( void ); | |
131 | int enable_apbuart_transmitter( void ); |
|
131 | int enable_apbuart_transmitter( void ); | |
132 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value); |
|
132 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value); | |
133 |
|
133 | |||
134 | // RTEMS TASKS |
|
134 | // RTEMS TASKS | |
135 | rtems_task load_task( rtems_task_argument argument ); |
|
135 | rtems_task load_task( rtems_task_argument argument ); | |
136 | rtems_task hous_task( rtems_task_argument argument ); |
|
136 | rtems_task hous_task( rtems_task_argument argument ); | |
137 | rtems_task avgv_task( rtems_task_argument argument ); |
|
137 | rtems_task avgv_task( rtems_task_argument argument ); | |
138 | rtems_task dumb_task( rtems_task_argument unused ); |
|
138 | rtems_task dumb_task( rtems_task_argument unused ); | |
139 | rtems_task scrubbing_task( rtems_task_argument unused ); |
|
139 | rtems_task scrubbing_task( rtems_task_argument unused ); | |
|
140 | rtems_task calibration_sweep_task( rtems_task_argument unused ); | |||
140 |
|
141 | |||
141 | void init_housekeeping_parameters( void ); |
|
142 | void init_housekeeping_parameters( void ); | |
142 | void increment_seq_counter(unsigned short *packetSequenceControl); |
|
143 | void increment_seq_counter(unsigned short *packetSequenceControl); | |
143 | void getTime( unsigned char *time); |
|
144 | void getTime( unsigned char *time); | |
144 | unsigned long long int getTimeAsUnsignedLongLongInt( ); |
|
145 | unsigned long long int getTimeAsUnsignedLongLongInt( ); | |
145 | void send_dumb_hk( void ); |
|
146 | void send_dumb_hk( void ); | |
146 | void get_temperatures( unsigned char *temperatures ); |
|
147 | void get_temperatures( unsigned char *temperatures ); | |
147 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ); |
|
148 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ); | |
148 | void get_cpu_load( unsigned char *resource_statistics ); |
|
149 | void get_cpu_load( unsigned char *resource_statistics ); | |
149 | void set_hk_lfr_sc_potential_flag( bool state ); |
|
150 | void set_hk_lfr_sc_potential_flag( bool state ); | |
150 | void set_sy_lfr_pas_filter_enabled( bool state ); |
|
151 | void set_sy_lfr_pas_filter_enabled( bool state ); | |
151 | void set_sy_lfr_watchdog_enabled( bool state ); |
|
152 | void set_sy_lfr_watchdog_enabled( bool state ); | |
152 | void set_hk_lfr_calib_enable( bool state ); |
|
153 | void set_hk_lfr_calib_enable( bool state ); | |
153 | void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ); |
|
154 | void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ); | |
154 | void hk_lfr_le_me_he_update(); |
|
155 | void hk_lfr_le_me_he_update(); | |
155 | void set_hk_lfr_time_not_synchro(); |
|
156 | void set_hk_lfr_time_not_synchro(); | |
156 |
|
157 | |||
157 | extern int sched_yield( void ); |
|
158 | extern int sched_yield( void ); | |
158 | extern void rtems_cpu_usage_reset(); |
|
159 | extern void rtems_cpu_usage_reset(); | |
159 | extern ring_node *current_ring_node_f3; |
|
160 | extern ring_node *current_ring_node_f3; | |
160 | extern ring_node *ring_node_to_send_cwf_f3; |
|
161 | extern ring_node *ring_node_to_send_cwf_f3; | |
161 | extern ring_node waveform_ring_f3[]; |
|
162 | extern ring_node waveform_ring_f3[]; | |
162 | extern unsigned short sequenceCounterHK; |
|
163 | extern unsigned short sequenceCounterHK; | |
163 |
|
164 | |||
164 | extern unsigned char hk_lfr_q_sd_fifo_size_max; |
|
165 | extern unsigned char hk_lfr_q_sd_fifo_size_max; | |
165 | extern unsigned char hk_lfr_q_rv_fifo_size_max; |
|
166 | extern unsigned char hk_lfr_q_rv_fifo_size_max; | |
166 | extern unsigned char hk_lfr_q_p0_fifo_size_max; |
|
167 | extern unsigned char hk_lfr_q_p0_fifo_size_max; | |
167 | extern unsigned char hk_lfr_q_p1_fifo_size_max; |
|
168 | extern unsigned char hk_lfr_q_p1_fifo_size_max; | |
168 | extern unsigned char hk_lfr_q_p2_fifo_size_max; |
|
169 | extern unsigned char hk_lfr_q_p2_fifo_size_max; | |
169 |
|
170 | |||
170 | #endif // FSW_MISC_H_INCLUDED |
|
171 | #endif // FSW_MISC_H_INCLUDED |
@@ -1,115 +1,117 | |||||
1 | #ifndef TC_HANDLER_H_INCLUDED |
|
1 | #ifndef TC_HANDLER_H_INCLUDED | |
2 | #define TC_HANDLER_H_INCLUDED |
|
2 | #define TC_HANDLER_H_INCLUDED | |
3 |
|
3 | |||
4 | #include <rtems.h> |
|
4 | #include <rtems.h> | |
5 | #include <leon.h> |
|
5 | #include <leon.h> | |
6 |
|
6 | |||
7 | #include "tc_load_dump_parameters.h" |
|
7 | #include "tc_load_dump_parameters.h" | |
8 | #include "tc_acceptance.h" |
|
8 | #include "tc_acceptance.h" | |
9 | #include "tm_lfr_tc_exe.h" |
|
9 | #include "tm_lfr_tc_exe.h" | |
10 | #include "wf_handler.h" |
|
10 | #include "wf_handler.h" | |
11 | #include "fsw_processing.h" |
|
11 | #include "fsw_processing.h" | |
12 |
|
12 | |||
13 | #include "lfr_cpu_usage_report.h" |
|
13 | #include "lfr_cpu_usage_report.h" | |
14 |
|
14 | |||
15 | #define MAX_DELTA_COARSE_TIME 3 |
|
15 | #define MAX_DELTA_COARSE_TIME 3 | |
16 | #define NB_SCIENCE_TASKS 10 |
|
16 | #define NB_SCIENCE_TASKS 10 | |
17 | #define NB_ASM_TASKS 6 |
|
17 | #define NB_ASM_TASKS 6 | |
18 | #define STATUS_0 0 |
|
18 | #define STATUS_0 0 | |
19 | #define STATUS_1 1 |
|
19 | #define STATUS_1 1 | |
20 | #define STATUS_2 2 |
|
20 | #define STATUS_2 2 | |
21 | #define STATUS_3 3 |
|
21 | #define STATUS_3 3 | |
22 | #define STATUS_4 4 |
|
22 | #define STATUS_4 4 | |
23 | #define STATUS_5 5 |
|
23 | #define STATUS_5 5 | |
24 | #define STATUS_6 6 |
|
24 | #define STATUS_6 6 | |
25 | #define STATUS_7 7 |
|
25 | #define STATUS_7 7 | |
26 | #define STATUS_8 8 |
|
26 | #define STATUS_8 8 | |
27 | #define STATUS_9 9 |
|
27 | #define STATUS_9 9 | |
28 |
|
28 | |||
29 | #define CAL_F0 625. |
|
29 | #define CAL_F0 625. | |
30 | #define CAL_F1 10000. |
|
30 | #define CAL_F1 10000. | |
31 | #define CAL_W0 (2. * pi * CAL_F0) |
|
31 | #define CAL_W0 (2. * pi * CAL_F0) | |
32 | #define CAL_W1 (2. * pi * CAL_F1) |
|
32 | #define CAL_W1 (2. * pi * CAL_F1) | |
33 | #define CAL_A0 1. |
|
33 | #define CAL_A0 1. | |
34 | #define CAL_A1 2. |
|
34 | #define CAL_A1 2. | |
35 | #define CAL_FS 160256.410 |
|
35 | #define CAL_FS 160256.410 | |
36 | #define CAL_SCALE_FACTOR (0.250 / 0.000654) // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV |
|
36 | #define CAL_SCALE_FACTOR (0.250 / 0.000654) // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV | |
37 | #define CAL_NB_PTS 256 |
|
37 | #define CAL_NB_PTS 256 | |
38 | #define CAL_DATA_MASK 0xfff |
|
38 | #define CAL_DATA_MASK 0xfff | |
39 | #define CAL_F_DIVISOR 38 // 25 MHz => 160 256 (39 - 1) |
|
39 | #define CAL_F_DIVISOR 38 // 25 MHz => 160 256 (39 - 1) | |
|
40 | #define CAL_F_DIVISOR_MIN 38 | |||
|
41 | #define CAL_F_DIVISOR_MAX (38*2*2*2*2) | |||
40 | // INTERLEAVED MODE |
|
42 | // INTERLEAVED MODE | |
41 | #define CAL_FS_INTER 240384.615 |
|
43 | #define CAL_FS_INTER 240384.615 | |
42 | #define CAL_NB_PTS_INTER 384 |
|
44 | #define CAL_NB_PTS_INTER 384 | |
43 | #define CAL_DATA_MASK_INTER 0x3f |
|
45 | #define CAL_DATA_MASK_INTER 0x3f | |
44 | #define CAL_DATA_SHIFT_INTER 12 |
|
46 | #define CAL_DATA_SHIFT_INTER 12 | |
45 | #define BYTES_FOR_2_SAMPLES 3 // one need 3 bytes = 24 bits to store 3 samples of 12 bits in interleaved mode |
|
47 | #define BYTES_FOR_2_SAMPLES 3 // one need 3 bytes = 24 bits to store 3 samples of 12 bits in interleaved mode | |
46 | #define STEPS_FOR_STORAGE_INTER 128 |
|
48 | #define STEPS_FOR_STORAGE_INTER 128 | |
47 | #define CAL_F_DIVISOR_INTER 26 // 25 MHz => 240 384 |
|
49 | #define CAL_F_DIVISOR_INTER 26 // 25 MHz => 240 384 | |
48 |
|
50 | |||
49 | extern unsigned int lastValidEnterModeTime; |
|
51 | extern unsigned int lastValidEnterModeTime; | |
50 | extern unsigned char oneTcLfrUpdateTimeReceived; |
|
52 | extern unsigned char oneTcLfrUpdateTimeReceived; | |
51 |
|
53 | |||
52 | //**** |
|
54 | //**** | |
53 | // ISR |
|
55 | // ISR | |
54 | rtems_isr commutation_isr1( rtems_vector_number vector ); |
|
56 | rtems_isr commutation_isr1( rtems_vector_number vector ); | |
55 | rtems_isr commutation_isr2( rtems_vector_number vector ); |
|
57 | rtems_isr commutation_isr2( rtems_vector_number vector ); | |
56 |
|
58 | |||
57 | //*********** |
|
59 | //*********** | |
58 | // RTEMS TASK |
|
60 | // RTEMS TASK | |
59 | rtems_task actn_task( rtems_task_argument unused ); |
|
61 | rtems_task actn_task( rtems_task_argument unused ); | |
60 |
|
62 | |||
61 | //*********** |
|
63 | //*********** | |
62 | // TC ACTIONS |
|
64 | // TC ACTIONS | |
63 | int action_reset( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); |
|
65 | int action_reset( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); | |
64 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); |
|
66 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id); | |
65 | int action_update_info( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
67 | int action_update_info( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
66 | int action_enable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); |
|
68 | int action_enable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); | |
67 | int action_disable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); |
|
69 | int action_disable_calibration( ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time ); | |
68 | int action_update_time( ccsdsTelecommandPacket_t *TC); |
|
70 | int action_update_time( ccsdsTelecommandPacket_t *TC); | |
69 |
|
71 | |||
70 | // mode transition |
|
72 | // mode transition | |
71 | int check_mode_value( unsigned char requestedMode ); |
|
73 | int check_mode_value( unsigned char requestedMode ); | |
72 | int check_mode_transition( unsigned char requestedMode ); |
|
74 | int check_mode_transition( unsigned char requestedMode ); | |
73 | void update_last_valid_transition_date( unsigned int transitionCoarseTime ); |
|
75 | void update_last_valid_transition_date( unsigned int transitionCoarseTime ); | |
74 | int check_transition_date( unsigned int transitionCoarseTime ); |
|
76 | int check_transition_date( unsigned int transitionCoarseTime ); | |
75 | int stop_spectral_matrices( void ); |
|
77 | int stop_spectral_matrices( void ); | |
76 | int stop_current_mode( void ); |
|
78 | int stop_current_mode( void ); | |
77 | int enter_mode_standby(void ); |
|
79 | int enter_mode_standby(void ); | |
78 | int enter_mode_normal( unsigned int transitionCoarseTime ); |
|
80 | int enter_mode_normal( unsigned int transitionCoarseTime ); | |
79 | int enter_mode_burst( unsigned int transitionCoarseTime ); |
|
81 | int enter_mode_burst( unsigned int transitionCoarseTime ); | |
80 | int enter_mode_sbm1( unsigned int transitionCoarseTime ); |
|
82 | int enter_mode_sbm1( unsigned int transitionCoarseTime ); | |
81 | int enter_mode_sbm2( unsigned int transitionCoarseTime ); |
|
83 | int enter_mode_sbm2( unsigned int transitionCoarseTime ); | |
82 | int restart_science_tasks( unsigned char lfrRequestedMode ); |
|
84 | int restart_science_tasks( unsigned char lfrRequestedMode ); | |
83 | int restart_asm_tasks(unsigned char lfrRequestedMode ); |
|
85 | int restart_asm_tasks(unsigned char lfrRequestedMode ); | |
84 | int suspend_science_tasks(void); |
|
86 | int suspend_science_tasks(void); | |
85 | int suspend_asm_tasks( void ); |
|
87 | int suspend_asm_tasks( void ); | |
86 | void launch_waveform_picker( unsigned char mode , unsigned int transitionCoarseTime ); |
|
88 | void launch_waveform_picker( unsigned char mode , unsigned int transitionCoarseTime ); | |
87 | void launch_spectral_matrix( void ); |
|
89 | void launch_spectral_matrix( void ); | |
88 | void set_sm_irq_onNewMatrix( unsigned char value ); |
|
90 | void set_sm_irq_onNewMatrix( unsigned char value ); | |
89 | void set_sm_irq_onError( unsigned char value ); |
|
91 | void set_sm_irq_onError( unsigned char value ); | |
90 |
|
92 | |||
91 | // other functions |
|
93 | // other functions | |
92 | void updateLFRCurrentMode(unsigned char requestedMode); |
|
94 | void updateLFRCurrentMode(unsigned char requestedMode); | |
93 | void set_lfr_soft_reset( unsigned char value ); |
|
95 | void set_lfr_soft_reset( unsigned char value ); | |
94 | void reset_lfr( void ); |
|
96 | void reset_lfr( void ); | |
95 | // CALIBRATION |
|
97 | // CALIBRATION | |
96 | void setCalibrationPrescaler( unsigned int prescaler ); |
|
98 | void setCalibrationPrescaler( unsigned int prescaler ); | |
97 | void setCalibrationDivisor( unsigned int divisionFactor ); |
|
99 | void setCalibrationDivisor( unsigned int divisionFactor ); | |
98 | void setCalibrationData( void ); |
|
100 | void setCalibrationData( void ); | |
99 | void setCalibrationReload( bool state); |
|
101 | void setCalibrationReload( bool state); | |
100 | void setCalibrationEnable( bool state ); |
|
102 | void setCalibrationEnable( bool state ); | |
101 | void setCalibrationInterleaved( bool state ); |
|
103 | void setCalibrationInterleaved( bool state ); | |
102 | void setCalibration( bool state ); |
|
104 | void setCalibration( bool state ); | |
103 | void configureCalibration( bool interleaved ); |
|
105 | void configureCalibration( bool interleaved ); | |
104 | // |
|
106 | // | |
105 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time ); |
|
107 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC , unsigned char *time ); | |
106 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time ); |
|
108 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC , unsigned char *time ); | |
107 | void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ); |
|
109 | void close_action( ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ); | |
108 |
|
110 | |||
109 | extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id ); |
|
111 | extern rtems_status_code get_message_queue_id_send( rtems_id *queue_id ); | |
110 | extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ); |
|
112 | extern rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ); | |
111 |
|
113 | |||
112 | #endif // TC_HANDLER_H_INCLUDED |
|
114 | #endif // TC_HANDLER_H_INCLUDED | |
113 |
|
115 | |||
114 |
|
116 | |||
115 |
|
117 |
@@ -1,991 +1,1007 | |||||
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 |
|
18 | |||
19 | /* configuration information */ |
|
19 | /* configuration information */ | |
20 |
|
20 | |||
21 | #define CONFIGURE_INIT |
|
21 | #define CONFIGURE_INIT | |
22 |
|
22 | |||
23 | #include <bsp.h> /* for device driver prototypes */ |
|
23 | #include <bsp.h> /* for device driver prototypes */ | |
24 |
|
24 | |||
25 | /* configuration information */ |
|
25 | /* configuration information */ | |
26 |
|
26 | |||
27 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
27 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER | |
28 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
28 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER | |
29 |
|
29 | |||
30 |
#define CONFIGURE_MAXIMUM_TASKS 2 |
|
30 | #define CONFIGURE_MAXIMUM_TASKS 23 // number of tasks concurrently active including INIT | |
31 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
|
31 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE | |
32 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) |
|
32 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) | |
33 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 |
|
33 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 | |
34 | #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 |
|
34 | #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 | |
35 | #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) |
|
35 | #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) | |
36 | #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT) |
|
36 | #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT) | |
37 | #define CONFIGURE_MAXIMUM_DRIVERS 16 |
|
37 | #define CONFIGURE_MAXIMUM_DRIVERS 16 | |
38 | #define CONFIGURE_MAXIMUM_PERIODS 6 // [hous] [load] [avgv] |
|
38 | #define CONFIGURE_MAXIMUM_PERIODS 6 // [hous] [load] [avgv] | |
39 | #define CONFIGURE_MAXIMUM_TIMERS 6 // [spiq] [link] [spacewire_reset_link] |
|
39 | #define CONFIGURE_MAXIMUM_TIMERS 6 // [spiq] [link] [spacewire_reset_link] | |
40 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5 |
|
40 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5 | |
41 | #ifdef PRINT_STACK_REPORT |
|
41 | #ifdef PRINT_STACK_REPORT | |
42 | #define CONFIGURE_STACK_CHECKER_ENABLED |
|
42 | #define CONFIGURE_STACK_CHECKER_ENABLED | |
43 | #endif |
|
43 | #endif | |
44 |
|
44 | |||
45 | #include <rtems/confdefs.h> |
|
45 | #include <rtems/confdefs.h> | |
46 |
|
46 | |||
47 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ |
|
47 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ | |
48 | #ifdef RTEMS_DRVMGR_STARTUP |
|
48 | #ifdef RTEMS_DRVMGR_STARTUP | |
49 | #ifdef LEON3 |
|
49 | #ifdef LEON3 | |
50 | /* Add Timer and UART Driver */ |
|
50 | /* Add Timer and UART Driver */ | |
51 |
|
51 | |||
52 | #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
52 | #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER | |
53 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER |
|
53 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER | |
54 | #endif |
|
54 | #endif | |
55 |
|
55 | |||
56 | #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
56 | #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER | |
57 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART |
|
57 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART | |
58 | #endif |
|
58 | #endif | |
59 |
|
59 | |||
60 | #endif |
|
60 | #endif | |
61 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ |
|
61 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ | |
62 |
|
62 | |||
63 | #include <drvmgr/drvmgr_confdefs.h> |
|
63 | #include <drvmgr/drvmgr_confdefs.h> | |
64 | #endif |
|
64 | #endif | |
65 |
|
65 | |||
66 | #include "fsw_init.h" |
|
66 | #include "fsw_init.h" | |
67 | #include "fsw_config.c" |
|
67 | #include "fsw_config.c" | |
68 | #include "GscMemoryLPP.hpp" |
|
68 | #include "GscMemoryLPP.hpp" | |
69 |
|
69 | |||
70 | void initCache() |
|
70 | void initCache() | |
71 | { |
|
71 | { | |
72 | // ASI 2 contains a few control registers that have not been assigned as ancillary state registers. |
|
72 | // ASI 2 contains a few control registers that have not been assigned as ancillary state registers. | |
73 | // These should only be read and written using 32-bit LDA/STA instructions. |
|
73 | // These should only be read and written using 32-bit LDA/STA instructions. | |
74 | // All cache registers are accessed through load/store operations to the alternate address space (LDA/STA), using ASI = 2. |
|
74 | // All cache registers are accessed through load/store operations to the alternate address space (LDA/STA), using ASI = 2. | |
75 | // The table below shows the register addresses: |
|
75 | // The table below shows the register addresses: | |
76 | // 0x00 Cache control register |
|
76 | // 0x00 Cache control register | |
77 | // 0x04 Reserved |
|
77 | // 0x04 Reserved | |
78 | // 0x08 Instruction cache configuration register |
|
78 | // 0x08 Instruction cache configuration register | |
79 | // 0x0C Data cache configuration register |
|
79 | // 0x0C Data cache configuration register | |
80 |
|
80 | |||
81 | // Cache Control Register Leon3 / Leon3FT |
|
81 | // Cache Control Register Leon3 / Leon3FT | |
82 | // 31..30 29 28 27..24 23 22 21 20..19 18 17 16 |
|
82 | // 31..30 29 28 27..24 23 22 21 20..19 18 17 16 | |
83 | // RFT PS TB DS FD FI FT ST IB |
|
83 | // RFT PS TB DS FD FI FT ST IB | |
84 | // 15 14 13..12 11..10 9..8 7..6 5 4 3..2 1..0 |
|
84 | // 15 14 13..12 11..10 9..8 7..6 5 4 3..2 1..0 | |
85 | // IP DP ITE IDE DTE DDE DF IF DCS ICS |
|
85 | // IP DP ITE IDE DTE DDE DF IF DCS ICS | |
86 |
|
86 | |||
87 | unsigned int cacheControlRegister; |
|
87 | unsigned int cacheControlRegister; | |
88 |
|
88 | |||
89 | CCR_resetCacheControlRegister(); |
|
89 | CCR_resetCacheControlRegister(); | |
90 | ASR16_resetRegisterProtectionControlRegister(); |
|
90 | ASR16_resetRegisterProtectionControlRegister(); | |
91 |
|
91 | |||
92 | cacheControlRegister = CCR_getValue(); |
|
92 | cacheControlRegister = CCR_getValue(); | |
93 | PRINTF1("(0) CCR - Cache Control Register = %x\n", cacheControlRegister); |
|
93 | PRINTF1("(0) CCR - Cache Control Register = %x\n", cacheControlRegister); | |
94 | PRINTF1("(0) ASR16 = %x\n", *asr16Ptr); |
|
94 | PRINTF1("(0) ASR16 = %x\n", *asr16Ptr); | |
95 |
|
95 | |||
96 | CCR_enableInstructionCache(); // ICS bits |
|
96 | CCR_enableInstructionCache(); // ICS bits | |
97 | CCR_enableDataCache(); // DCS bits |
|
97 | CCR_enableDataCache(); // DCS bits | |
98 | CCR_enableInstructionBurstFetch(); // IB bit |
|
98 | CCR_enableInstructionBurstFetch(); // IB bit | |
99 |
|
99 | |||
100 | faultTolerantScheme(); |
|
100 | faultTolerantScheme(); | |
101 |
|
101 | |||
102 | cacheControlRegister = CCR_getValue(); |
|
102 | cacheControlRegister = CCR_getValue(); | |
103 | PRINTF1("(1) CCR - Cache Control Register = %x\n", cacheControlRegister); |
|
103 | PRINTF1("(1) CCR - Cache Control Register = %x\n", cacheControlRegister); | |
104 | PRINTF1("(1) ASR16 Register protection control register = %x\n", *asr16Ptr); |
|
104 | PRINTF1("(1) ASR16 Register protection control register = %x\n", *asr16Ptr); | |
105 |
|
105 | |||
106 | PRINTF("\n"); |
|
106 | PRINTF("\n"); | |
107 | } |
|
107 | } | |
108 |
|
108 | |||
109 | rtems_task Init( rtems_task_argument ignored ) |
|
109 | rtems_task Init( rtems_task_argument ignored ) | |
110 | { |
|
110 | { | |
111 | /** This is the RTEMS INIT taks, it is the first task launched by the system. |
|
111 | /** This is the RTEMS INIT taks, it is the first task launched by the system. | |
112 | * |
|
112 | * | |
113 | * @param unused is the starting argument of the RTEMS task |
|
113 | * @param unused is the starting argument of the RTEMS task | |
114 | * |
|
114 | * | |
115 | * The INIT task create and run all other RTEMS tasks. |
|
115 | * The INIT task create and run all other RTEMS tasks. | |
116 | * |
|
116 | * | |
117 | */ |
|
117 | */ | |
118 |
|
118 | |||
119 | //*********** |
|
119 | //*********** | |
120 | // INIT CACHE |
|
120 | // INIT CACHE | |
121 |
|
121 | |||
122 | unsigned char *vhdlVersion; |
|
122 | unsigned char *vhdlVersion; | |
123 |
|
123 | |||
124 | reset_lfr(); |
|
124 | reset_lfr(); | |
125 |
|
125 | |||
126 | reset_local_time(); |
|
126 | reset_local_time(); | |
127 |
|
127 | |||
128 | rtems_cpu_usage_reset(); |
|
128 | rtems_cpu_usage_reset(); | |
129 |
|
129 | |||
130 | rtems_status_code status; |
|
130 | rtems_status_code status; | |
131 | rtems_status_code status_spw; |
|
131 | rtems_status_code status_spw; | |
132 | rtems_isr_entry old_isr_handler; |
|
132 | rtems_isr_entry old_isr_handler; | |
133 |
|
133 | |||
134 | old_isr_handler = NULL; |
|
134 | old_isr_handler = NULL; | |
135 |
|
135 | |||
136 | // UART settings |
|
136 | // UART settings | |
137 | enable_apbuart_transmitter(); |
|
137 | enable_apbuart_transmitter(); | |
138 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); |
|
138 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); | |
139 |
|
139 | |||
140 | DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") |
|
140 | DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") | |
141 |
|
141 | |||
142 |
|
142 | |||
143 | PRINTF("\n\n\n\n\n") |
|
143 | PRINTF("\n\n\n\n\n") | |
144 |
|
144 | |||
145 | initCache(); |
|
145 | initCache(); | |
146 |
|
146 | |||
147 | PRINTF("*************************\n") |
|
147 | PRINTF("*************************\n") | |
148 | PRINTF("** LFR Flight Software **\n") |
|
148 | PRINTF("** LFR Flight Software **\n") | |
149 |
|
149 | |||
150 | PRINTF1("** %d-", SW_VERSION_N1) |
|
150 | PRINTF1("** %d-", SW_VERSION_N1) | |
151 | PRINTF1("%d-" , SW_VERSION_N2) |
|
151 | PRINTF1("%d-" , SW_VERSION_N2) | |
152 | PRINTF1("%d-" , SW_VERSION_N3) |
|
152 | PRINTF1("%d-" , SW_VERSION_N3) | |
153 | PRINTF1("%d **\n", SW_VERSION_N4) |
|
153 | PRINTF1("%d **\n", SW_VERSION_N4) | |
154 |
|
154 | |||
155 | vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION); |
|
155 | vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION); | |
156 | PRINTF("** VHDL **\n") |
|
156 | PRINTF("** VHDL **\n") | |
157 | PRINTF1("** %d-", vhdlVersion[1]) |
|
157 | PRINTF1("** %d-", vhdlVersion[1]) | |
158 | PRINTF1("%d-" , vhdlVersion[2]) |
|
158 | PRINTF1("%d-" , vhdlVersion[2]) | |
159 | PRINTF1("%d **\n", vhdlVersion[3]) |
|
159 | PRINTF1("%d **\n", vhdlVersion[3]) | |
160 | PRINTF("*************************\n") |
|
160 | PRINTF("*************************\n") | |
161 | PRINTF("\n\n") |
|
161 | PRINTF("\n\n") | |
162 |
|
162 | |||
163 | init_parameter_dump(); |
|
163 | init_parameter_dump(); | |
164 | init_kcoefficients_dump(); |
|
164 | init_kcoefficients_dump(); | |
165 | init_local_mode_parameters(); |
|
165 | init_local_mode_parameters(); | |
166 | init_housekeeping_parameters(); |
|
166 | init_housekeeping_parameters(); | |
167 | init_k_coefficients_prc0(); |
|
167 | init_k_coefficients_prc0(); | |
168 | init_k_coefficients_prc1(); |
|
168 | init_k_coefficients_prc1(); | |
169 | init_k_coefficients_prc2(); |
|
169 | init_k_coefficients_prc2(); | |
170 | pa_bia_status_info = INIT_CHAR; |
|
170 | pa_bia_status_info = INIT_CHAR; | |
171 |
|
171 | |||
172 | // initialize all reaction wheels frequencies to NaN |
|
172 | // initialize all reaction wheels frequencies to NaN | |
173 | rw_f.cp_rpw_sc_rw1_f1 = NAN; |
|
173 | rw_f.cp_rpw_sc_rw1_f1 = NAN; | |
174 | rw_f.cp_rpw_sc_rw1_f2 = NAN; |
|
174 | rw_f.cp_rpw_sc_rw1_f2 = NAN; | |
175 | rw_f.cp_rpw_sc_rw1_f3 = NAN; |
|
175 | rw_f.cp_rpw_sc_rw1_f3 = NAN; | |
176 | rw_f.cp_rpw_sc_rw1_f4 = NAN; |
|
176 | rw_f.cp_rpw_sc_rw1_f4 = NAN; | |
177 | rw_f.cp_rpw_sc_rw2_f1 = NAN; |
|
177 | rw_f.cp_rpw_sc_rw2_f1 = NAN; | |
178 | rw_f.cp_rpw_sc_rw2_f2 = NAN; |
|
178 | rw_f.cp_rpw_sc_rw2_f2 = NAN; | |
179 | rw_f.cp_rpw_sc_rw2_f3 = NAN; |
|
179 | rw_f.cp_rpw_sc_rw2_f3 = NAN; | |
180 | rw_f.cp_rpw_sc_rw2_f4 = NAN; |
|
180 | rw_f.cp_rpw_sc_rw2_f4 = NAN; | |
181 | rw_f.cp_rpw_sc_rw3_f1 = NAN; |
|
181 | rw_f.cp_rpw_sc_rw3_f1 = NAN; | |
182 | rw_f.cp_rpw_sc_rw3_f2 = NAN; |
|
182 | rw_f.cp_rpw_sc_rw3_f2 = NAN; | |
183 | rw_f.cp_rpw_sc_rw3_f3 = NAN; |
|
183 | rw_f.cp_rpw_sc_rw3_f3 = NAN; | |
184 | rw_f.cp_rpw_sc_rw3_f4 = NAN; |
|
184 | rw_f.cp_rpw_sc_rw3_f4 = NAN; | |
185 | rw_f.cp_rpw_sc_rw4_f1 = NAN; |
|
185 | rw_f.cp_rpw_sc_rw4_f1 = NAN; | |
186 | rw_f.cp_rpw_sc_rw4_f2 = NAN; |
|
186 | rw_f.cp_rpw_sc_rw4_f2 = NAN; | |
187 | rw_f.cp_rpw_sc_rw4_f3 = NAN; |
|
187 | rw_f.cp_rpw_sc_rw4_f3 = NAN; | |
188 | rw_f.cp_rpw_sc_rw4_f4 = NAN; |
|
188 | rw_f.cp_rpw_sc_rw4_f4 = NAN; | |
189 |
|
189 | |||
190 | // initialize filtering parameters |
|
190 | // initialize filtering parameters | |
191 | filterPar.spare_sy_lfr_pas_filter_enabled = DEFAULT_SY_LFR_PAS_FILTER_ENABLED; |
|
191 | filterPar.spare_sy_lfr_pas_filter_enabled = DEFAULT_SY_LFR_PAS_FILTER_ENABLED; | |
192 | filterPar.sy_lfr_sc_rw_delta_f = DEFAULT_SY_LFR_SC_RW_DELTA_F; |
|
192 | filterPar.sy_lfr_sc_rw_delta_f = DEFAULT_SY_LFR_SC_RW_DELTA_F; | |
193 | filterPar.sy_lfr_pas_filter_tbad = DEFAULT_SY_LFR_PAS_FILTER_TBAD; |
|
193 | filterPar.sy_lfr_pas_filter_tbad = DEFAULT_SY_LFR_PAS_FILTER_TBAD; | |
194 | filterPar.sy_lfr_pas_filter_shift = DEFAULT_SY_LFR_PAS_FILTER_SHIFT; |
|
194 | filterPar.sy_lfr_pas_filter_shift = DEFAULT_SY_LFR_PAS_FILTER_SHIFT; | |
195 | filterPar.modulus_in_finetime = DEFAULT_MODULUS; |
|
195 | filterPar.modulus_in_finetime = DEFAULT_MODULUS; | |
196 | filterPar.tbad_in_finetime = DEFAULT_TBAD; |
|
196 | filterPar.tbad_in_finetime = DEFAULT_TBAD; | |
197 | filterPar.offset_in_finetime = DEFAULT_OFFSET; |
|
197 | filterPar.offset_in_finetime = DEFAULT_OFFSET; | |
198 | filterPar.shift_in_finetime = DEFAULT_SHIFT; |
|
198 | filterPar.shift_in_finetime = DEFAULT_SHIFT; | |
199 | update_last_valid_transition_date( DEFAULT_LAST_VALID_TRANSITION_DATE ); |
|
199 | update_last_valid_transition_date( DEFAULT_LAST_VALID_TRANSITION_DATE ); | |
200 |
|
200 | |||
201 | // waveform picker initialization |
|
201 | // waveform picker initialization | |
202 | WFP_init_rings(); |
|
202 | WFP_init_rings(); | |
203 | LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings |
|
203 | LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings | |
204 | WFP_reset_current_ring_nodes(); |
|
204 | WFP_reset_current_ring_nodes(); | |
205 | reset_waveform_picker_regs(); |
|
205 | reset_waveform_picker_regs(); | |
206 |
|
206 | |||
207 | // spectral matrices initialization |
|
207 | // spectral matrices initialization | |
208 | SM_init_rings(); // initialize spectral matrices rings |
|
208 | SM_init_rings(); // initialize spectral matrices rings | |
209 | SM_reset_current_ring_nodes(); |
|
209 | SM_reset_current_ring_nodes(); | |
210 | reset_spectral_matrix_regs(); |
|
210 | reset_spectral_matrix_regs(); | |
211 |
|
211 | |||
212 | // configure calibration |
|
212 | // configure calibration | |
213 | configureCalibration( false ); // true means interleaved mode, false is for normal mode |
|
213 | configureCalibration( false ); // true means interleaved mode, false is for normal mode | |
214 |
|
214 | |||
215 | updateLFRCurrentMode( LFR_MODE_STANDBY ); |
|
215 | updateLFRCurrentMode( LFR_MODE_STANDBY ); | |
216 |
|
216 | |||
217 | BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode) |
|
217 | BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode) | |
218 |
|
218 | |||
219 | create_names(); // create all names |
|
219 | create_names(); // create all names | |
220 |
|
220 | |||
221 | status = create_timecode_timer(); // create the timer used by timecode_irq_handler |
|
221 | status = create_timecode_timer(); // create the timer used by timecode_irq_handler | |
222 | if (status != RTEMS_SUCCESSFUL) |
|
222 | if (status != RTEMS_SUCCESSFUL) | |
223 | { |
|
223 | { | |
224 | PRINTF1("in INIT *** ERR in create_timer_timecode, code %d", status) |
|
224 | PRINTF1("in INIT *** ERR in create_timer_timecode, code %d", status) | |
225 | } |
|
225 | } | |
226 |
|
226 | |||
227 | status = create_message_queues(); // create message queues |
|
227 | status = create_message_queues(); // create message queues | |
228 | if (status != RTEMS_SUCCESSFUL) |
|
228 | if (status != RTEMS_SUCCESSFUL) | |
229 | { |
|
229 | { | |
230 | PRINTF1("in INIT *** ERR in create_message_queues, code %d", status) |
|
230 | PRINTF1("in INIT *** ERR in create_message_queues, code %d", status) | |
231 | } |
|
231 | } | |
232 |
|
232 | |||
233 | status = create_all_tasks(); // create all tasks |
|
233 | status = create_all_tasks(); // create all tasks | |
234 | if (status != RTEMS_SUCCESSFUL) |
|
234 | if (status != RTEMS_SUCCESSFUL) | |
235 | { |
|
235 | { | |
236 | PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status) |
|
236 | PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status) | |
237 | } |
|
237 | } | |
238 |
|
238 | |||
239 | // ************************** |
|
239 | // ************************** | |
240 | // <SPACEWIRE INITIALIZATION> |
|
240 | // <SPACEWIRE INITIALIZATION> | |
241 | status_spw = spacewire_open_link(); // (1) open the link |
|
241 | status_spw = spacewire_open_link(); // (1) open the link | |
242 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
242 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
243 | { |
|
243 | { | |
244 | PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw ) |
|
244 | PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw ) | |
245 | } |
|
245 | } | |
246 |
|
246 | |||
247 | if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link |
|
247 | if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link | |
248 | { |
|
248 | { | |
249 | status_spw = spacewire_configure_link( fdSPW ); |
|
249 | status_spw = spacewire_configure_link( fdSPW ); | |
250 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
250 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
251 | { |
|
251 | { | |
252 | PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw ) |
|
252 | PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw ) | |
253 | } |
|
253 | } | |
254 | } |
|
254 | } | |
255 |
|
255 | |||
256 | if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link |
|
256 | if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link | |
257 | { |
|
257 | { | |
258 | status_spw = spacewire_start_link( fdSPW ); |
|
258 | status_spw = spacewire_start_link( fdSPW ); | |
259 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
259 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
260 | { |
|
260 | { | |
261 | PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw ) |
|
261 | PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw ) | |
262 | } |
|
262 | } | |
263 | } |
|
263 | } | |
264 | // </SPACEWIRE INITIALIZATION> |
|
264 | // </SPACEWIRE INITIALIZATION> | |
265 | // *************************** |
|
265 | // *************************** | |
266 |
|
266 | |||
267 | status = start_all_tasks(); // start all tasks |
|
267 | status = start_all_tasks(); // start all tasks | |
268 | if (status != RTEMS_SUCCESSFUL) |
|
268 | if (status != RTEMS_SUCCESSFUL) | |
269 | { |
|
269 | { | |
270 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) |
|
270 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) | |
271 | } |
|
271 | } | |
272 |
|
272 | |||
273 | // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization |
|
273 | // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization | |
274 | status = start_recv_send_tasks(); |
|
274 | status = start_recv_send_tasks(); | |
275 | if ( status != RTEMS_SUCCESSFUL ) |
|
275 | if ( status != RTEMS_SUCCESSFUL ) | |
276 | { |
|
276 | { | |
277 | PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status ) |
|
277 | PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status ) | |
278 | } |
|
278 | } | |
279 |
|
279 | |||
280 | // suspend science tasks, they will be restarted later depending on the mode |
|
280 | // suspend science tasks, they will be restarted later depending on the mode | |
281 | status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY) |
|
281 | status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY) | |
282 | if (status != RTEMS_SUCCESSFUL) |
|
282 | if (status != RTEMS_SUCCESSFUL) | |
283 | { |
|
283 | { | |
284 | PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
284 | PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status) | |
285 | } |
|
285 | } | |
286 |
|
286 | |||
287 | // configure IRQ handling for the waveform picker unit |
|
287 | // configure IRQ handling for the waveform picker unit | |
288 | status = rtems_interrupt_catch( waveforms_isr, |
|
288 | status = rtems_interrupt_catch( waveforms_isr, | |
289 | IRQ_SPARC_WAVEFORM_PICKER, |
|
289 | IRQ_SPARC_WAVEFORM_PICKER, | |
290 | &old_isr_handler) ; |
|
290 | &old_isr_handler) ; | |
291 | // configure IRQ handling for the spectral matrices unit |
|
291 | // configure IRQ handling for the spectral matrices unit | |
292 | status = rtems_interrupt_catch( spectral_matrices_isr, |
|
292 | status = rtems_interrupt_catch( spectral_matrices_isr, | |
293 | IRQ_SPARC_SPECTRAL_MATRIX, |
|
293 | IRQ_SPARC_SPECTRAL_MATRIX, | |
294 | &old_isr_handler) ; |
|
294 | &old_isr_handler) ; | |
295 |
|
295 | |||
296 | // if the spacewire link is not up then send an event to the SPIQ task for link recovery |
|
296 | // if the spacewire link is not up then send an event to the SPIQ task for link recovery | |
297 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
297 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
298 | { |
|
298 | { | |
299 | status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ); |
|
299 | status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ); | |
300 | if ( status != RTEMS_SUCCESSFUL ) { |
|
300 | if ( status != RTEMS_SUCCESSFUL ) { | |
301 | PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status ) |
|
301 | PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status ) | |
302 | } |
|
302 | } | |
303 | } |
|
303 | } | |
304 |
|
304 | |||
305 | BOOT_PRINTF("delete INIT\n") |
|
305 | BOOT_PRINTF("delete INIT\n") | |
306 |
|
306 | |||
307 | set_hk_lfr_sc_potential_flag( true ); |
|
307 | set_hk_lfr_sc_potential_flag( true ); | |
308 |
|
308 | |||
309 | // start the timer to detect a missing spacewire timecode |
|
309 | // start the timer to detect a missing spacewire timecode | |
310 | // the timeout is larger because the spw IP needs to receive several valid timecodes before generating a tickout |
|
310 | // the timeout is larger because the spw IP needs to receive several valid timecodes before generating a tickout | |
311 | // if a tickout is generated, the timer is restarted |
|
311 | // if a tickout is generated, the timer is restarted | |
312 | status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT_INIT, timecode_timer_routine, NULL ); |
|
312 | status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT_INIT, timecode_timer_routine, NULL ); | |
313 |
|
313 | |||
314 | grspw_timecode_callback = &timecode_irq_handler; |
|
314 | grspw_timecode_callback = &timecode_irq_handler; | |
315 |
|
315 | |||
316 | status = rtems_task_delete(RTEMS_SELF); |
|
316 | status = rtems_task_delete(RTEMS_SELF); | |
317 |
|
317 | |||
318 | } |
|
318 | } | |
319 |
|
319 | |||
320 | void init_local_mode_parameters( void ) |
|
320 | void init_local_mode_parameters( void ) | |
321 | { |
|
321 | { | |
322 | /** This function initialize the param_local global variable with default values. |
|
322 | /** This function initialize the param_local global variable with default values. | |
323 | * |
|
323 | * | |
324 | */ |
|
324 | */ | |
325 |
|
325 | |||
326 | unsigned int i; |
|
326 | unsigned int i; | |
327 |
|
327 | |||
328 | // LOCAL PARAMETERS |
|
328 | // LOCAL PARAMETERS | |
329 |
|
329 | |||
330 | BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) |
|
330 | BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) | |
331 | BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) |
|
331 | BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) | |
332 |
|
332 | |||
333 | // init sequence counters |
|
333 | // init sequence counters | |
334 |
|
334 | |||
335 | for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++) |
|
335 | for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++) | |
336 | { |
|
336 | { | |
337 | sequenceCounters_TC_EXE[i] = INIT_CHAR; |
|
337 | sequenceCounters_TC_EXE[i] = INIT_CHAR; | |
338 | sequenceCounters_TM_DUMP[i] = INIT_CHAR; |
|
338 | sequenceCounters_TM_DUMP[i] = INIT_CHAR; | |
339 | } |
|
339 | } | |
340 | sequenceCounters_SCIENCE_NORMAL_BURST = INIT_CHAR; |
|
340 | sequenceCounters_SCIENCE_NORMAL_BURST = INIT_CHAR; | |
341 | sequenceCounters_SCIENCE_SBM1_SBM2 = INIT_CHAR; |
|
341 | sequenceCounters_SCIENCE_SBM1_SBM2 = INIT_CHAR; | |
342 | sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << TM_PACKET_SEQ_SHIFT; |
|
342 | sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << TM_PACKET_SEQ_SHIFT; | |
343 | } |
|
343 | } | |
344 |
|
344 | |||
345 | void reset_local_time( void ) |
|
345 | void reset_local_time( void ) | |
346 | { |
|
346 | { | |
347 | time_management_regs->ctrl = time_management_regs->ctrl | VAL_SOFTWARE_RESET; // [0010] software reset, coarse time = 0x80000000 |
|
347 | time_management_regs->ctrl = time_management_regs->ctrl | VAL_SOFTWARE_RESET; // [0010] software reset, coarse time = 0x80000000 | |
348 | } |
|
348 | } | |
349 |
|
349 | |||
350 | void create_names( void ) // create all names for tasks and queues |
|
350 | void create_names( void ) // create all names for tasks and queues | |
351 | { |
|
351 | { | |
352 | /** This function creates all RTEMS names used in the software for tasks and queues. |
|
352 | /** This function creates all RTEMS names used in the software for tasks and queues. | |
353 | * |
|
353 | * | |
354 | * @return RTEMS directive status codes: |
|
354 | * @return RTEMS directive status codes: | |
355 | * - RTEMS_SUCCESSFUL - successful completion |
|
355 | * - RTEMS_SUCCESSFUL - successful completion | |
356 | * |
|
356 | * | |
357 | */ |
|
357 | */ | |
358 |
|
358 | |||
359 | // task names |
|
359 | // task names | |
360 | Task_name[TASKID_AVGV] = rtems_build_name( 'A', 'V', 'G', 'V' ); |
|
360 | Task_name[TASKID_AVGV] = rtems_build_name( 'A', 'V', 'G', 'V' ); | |
361 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); |
|
361 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); | |
362 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); |
|
362 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); | |
363 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); |
|
363 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); | |
364 | Task_name[TASKID_LOAD] = rtems_build_name( 'L', 'O', 'A', 'D' ); |
|
364 | Task_name[TASKID_LOAD] = rtems_build_name( 'L', 'O', 'A', 'D' ); | |
365 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); |
|
365 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); | |
366 | Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' ); |
|
366 | Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' ); | |
367 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); |
|
367 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); | |
368 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); |
|
368 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); | |
369 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
369 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); | |
370 | Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' ); |
|
370 | Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' ); | |
371 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); |
|
371 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); | |
372 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); |
|
372 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); | |
373 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); |
|
373 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); | |
374 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); |
|
374 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); | |
375 | Task_name[TASKID_LINK] = rtems_build_name( 'L', 'I', 'N', 'K' ); |
|
375 | Task_name[TASKID_LINK] = rtems_build_name( 'L', 'I', 'N', 'K' ); | |
376 | Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' ); |
|
376 | Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' ); | |
377 | Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' ); |
|
377 | Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' ); | |
378 | Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' ); |
|
378 | Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' ); | |
379 | Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' ); |
|
379 | Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' ); | |
380 | Task_name[TASKID_SCRB] = rtems_build_name( 'S', 'C', 'R', 'B' ); |
|
380 | Task_name[TASKID_SCRB] = rtems_build_name( 'S', 'C', 'R', 'B' ); | |
|
381 | Task_name[TASKID_CALI] = rtems_build_name( 'C', 'A', 'L', 'I' ); | |||
381 |
|
382 | |||
382 | // rate monotonic period names |
|
383 | // rate monotonic period names | |
383 | name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
384 | name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' ); | |
384 | name_avgv_rate_monotonic = rtems_build_name( 'A', 'V', 'G', 'V' ); |
|
385 | name_avgv_rate_monotonic = rtems_build_name( 'A', 'V', 'G', 'V' ); | |
385 |
|
386 | |||
386 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
387 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); | |
387 | misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
388 | misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); | |
388 | misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' ); |
|
389 | misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' ); | |
389 | misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' ); |
|
390 | misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' ); | |
390 | misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' ); |
|
391 | misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' ); | |
391 |
|
392 | |||
392 | timecode_timer_name = rtems_build_name( 'S', 'P', 'T', 'C' ); |
|
393 | timecode_timer_name = rtems_build_name( 'S', 'P', 'T', 'C' ); | |
393 | } |
|
394 | } | |
394 |
|
395 | |||
395 | int create_all_tasks( void ) // create all tasks which run in the software |
|
396 | int create_all_tasks( void ) // create all tasks which run in the software | |
396 | { |
|
397 | { | |
397 | /** This function creates all RTEMS tasks used in the software. |
|
398 | /** This function creates all RTEMS tasks used in the software. | |
398 | * |
|
399 | * | |
399 | * @return RTEMS directive status codes: |
|
400 | * @return RTEMS directive status codes: | |
400 | * - RTEMS_SUCCESSFUL - task created successfully |
|
401 | * - RTEMS_SUCCESSFUL - task created successfully | |
401 | * - RTEMS_INVALID_ADDRESS - id is NULL |
|
402 | * - RTEMS_INVALID_ADDRESS - id is NULL | |
402 | * - RTEMS_INVALID_NAME - invalid task name |
|
403 | * - RTEMS_INVALID_NAME - invalid task name | |
403 | * - RTEMS_INVALID_PRIORITY - invalid task priority |
|
404 | * - RTEMS_INVALID_PRIORITY - invalid task priority | |
404 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured |
|
405 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured | |
405 | * - RTEMS_TOO_MANY - too many tasks created |
|
406 | * - RTEMS_TOO_MANY - too many tasks created | |
406 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context |
|
407 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context | |
407 | * - RTEMS_TOO_MANY - too many global objects |
|
408 | * - RTEMS_TOO_MANY - too many global objects | |
408 | * |
|
409 | * | |
409 | */ |
|
410 | */ | |
410 |
|
411 | |||
411 | rtems_status_code status; |
|
412 | rtems_status_code status; | |
412 |
|
413 | |||
413 | //********** |
|
414 | //********** | |
414 | // SPACEWIRE |
|
415 | // SPACEWIRE | |
415 | // RECV |
|
416 | // RECV | |
416 | status = rtems_task_create( |
|
417 | status = rtems_task_create( | |
417 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, |
|
418 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, | |
418 | RTEMS_DEFAULT_MODES, |
|
419 | RTEMS_DEFAULT_MODES, | |
419 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] |
|
420 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] | |
420 | ); |
|
421 | ); | |
421 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
422 | if (status == RTEMS_SUCCESSFUL) // SEND | |
422 | { |
|
423 | { | |
423 | status = rtems_task_create( |
|
424 | status = rtems_task_create( | |
424 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT, |
|
425 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT, | |
425 | RTEMS_DEFAULT_MODES, |
|
426 | RTEMS_DEFAULT_MODES, | |
426 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND] |
|
427 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND] | |
427 | ); |
|
428 | ); | |
428 | } |
|
429 | } | |
429 | if (status == RTEMS_SUCCESSFUL) // LINK |
|
430 | if (status == RTEMS_SUCCESSFUL) // LINK | |
430 | { |
|
431 | { | |
431 | status = rtems_task_create( |
|
432 | status = rtems_task_create( | |
432 | Task_name[TASKID_LINK], TASK_PRIORITY_LINK, RTEMS_MINIMUM_STACK_SIZE, |
|
433 | Task_name[TASKID_LINK], TASK_PRIORITY_LINK, RTEMS_MINIMUM_STACK_SIZE, | |
433 | RTEMS_DEFAULT_MODES, |
|
434 | RTEMS_DEFAULT_MODES, | |
434 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LINK] |
|
435 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LINK] | |
435 | ); |
|
436 | ); | |
436 | } |
|
437 | } | |
437 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
438 | if (status == RTEMS_SUCCESSFUL) // ACTN | |
438 | { |
|
439 | { | |
439 | status = rtems_task_create( |
|
440 | status = rtems_task_create( | |
440 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, |
|
441 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, | |
441 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
442 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
442 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] |
|
443 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] | |
443 | ); |
|
444 | ); | |
444 | } |
|
445 | } | |
445 | if (status == RTEMS_SUCCESSFUL) // SPIQ |
|
446 | if (status == RTEMS_SUCCESSFUL) // SPIQ | |
446 | { |
|
447 | { | |
447 | status = rtems_task_create( |
|
448 | status = rtems_task_create( | |
448 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, |
|
449 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, | |
449 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
450 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
450 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] |
|
451 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] | |
451 | ); |
|
452 | ); | |
452 | } |
|
453 | } | |
453 |
|
454 | |||
454 | //****************** |
|
455 | //****************** | |
455 | // SPECTRAL MATRICES |
|
456 | // SPECTRAL MATRICES | |
456 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
457 | if (status == RTEMS_SUCCESSFUL) // AVF0 | |
457 | { |
|
458 | { | |
458 | status = rtems_task_create( |
|
459 | status = rtems_task_create( | |
459 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, |
|
460 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, | |
460 | RTEMS_DEFAULT_MODES, |
|
461 | RTEMS_DEFAULT_MODES, | |
461 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] |
|
462 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] | |
462 | ); |
|
463 | ); | |
463 | } |
|
464 | } | |
464 | if (status == RTEMS_SUCCESSFUL) // PRC0 |
|
465 | if (status == RTEMS_SUCCESSFUL) // PRC0 | |
465 | { |
|
466 | { | |
466 | status = rtems_task_create( |
|
467 | status = rtems_task_create( | |
467 | Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT, |
|
468 | Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT, | |
468 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
469 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
469 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0] |
|
470 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0] | |
470 | ); |
|
471 | ); | |
471 | } |
|
472 | } | |
472 | if (status == RTEMS_SUCCESSFUL) // AVF1 |
|
473 | if (status == RTEMS_SUCCESSFUL) // AVF1 | |
473 | { |
|
474 | { | |
474 | status = rtems_task_create( |
|
475 | status = rtems_task_create( | |
475 | Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE, |
|
476 | Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE, | |
476 | RTEMS_DEFAULT_MODES, |
|
477 | RTEMS_DEFAULT_MODES, | |
477 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1] |
|
478 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1] | |
478 | ); |
|
479 | ); | |
479 | } |
|
480 | } | |
480 | if (status == RTEMS_SUCCESSFUL) // PRC1 |
|
481 | if (status == RTEMS_SUCCESSFUL) // PRC1 | |
481 | { |
|
482 | { | |
482 | status = rtems_task_create( |
|
483 | status = rtems_task_create( | |
483 | Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT, |
|
484 | Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT, | |
484 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
485 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
485 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1] |
|
486 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1] | |
486 | ); |
|
487 | ); | |
487 | } |
|
488 | } | |
488 | if (status == RTEMS_SUCCESSFUL) // AVF2 |
|
489 | if (status == RTEMS_SUCCESSFUL) // AVF2 | |
489 | { |
|
490 | { | |
490 | status = rtems_task_create( |
|
491 | status = rtems_task_create( | |
491 | Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE, |
|
492 | Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE, | |
492 | RTEMS_DEFAULT_MODES, |
|
493 | RTEMS_DEFAULT_MODES, | |
493 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2] |
|
494 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2] | |
494 | ); |
|
495 | ); | |
495 | } |
|
496 | } | |
496 | if (status == RTEMS_SUCCESSFUL) // PRC2 |
|
497 | if (status == RTEMS_SUCCESSFUL) // PRC2 | |
497 | { |
|
498 | { | |
498 | status = rtems_task_create( |
|
499 | status = rtems_task_create( | |
499 | Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT, |
|
500 | Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT, | |
500 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
501 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
501 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2] |
|
502 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2] | |
502 | ); |
|
503 | ); | |
503 | } |
|
504 | } | |
504 |
|
505 | |||
505 | //**************** |
|
506 | //**************** | |
506 | // WAVEFORM PICKER |
|
507 | // WAVEFORM PICKER | |
507 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
508 | if (status == RTEMS_SUCCESSFUL) // WFRM | |
508 | { |
|
509 | { | |
509 | status = rtems_task_create( |
|
510 | status = rtems_task_create( | |
510 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, |
|
511 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, | |
511 | RTEMS_DEFAULT_MODES, |
|
512 | RTEMS_DEFAULT_MODES, | |
512 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] |
|
513 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] | |
513 | ); |
|
514 | ); | |
514 | } |
|
515 | } | |
515 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
516 | if (status == RTEMS_SUCCESSFUL) // CWF3 | |
516 | { |
|
517 | { | |
517 | status = rtems_task_create( |
|
518 | status = rtems_task_create( | |
518 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, |
|
519 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, | |
519 | RTEMS_DEFAULT_MODES, |
|
520 | RTEMS_DEFAULT_MODES, | |
520 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3] |
|
521 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3] | |
521 | ); |
|
522 | ); | |
522 | } |
|
523 | } | |
523 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
524 | if (status == RTEMS_SUCCESSFUL) // CWF2 | |
524 | { |
|
525 | { | |
525 | status = rtems_task_create( |
|
526 | status = rtems_task_create( | |
526 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, |
|
527 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, | |
527 | RTEMS_DEFAULT_MODES, |
|
528 | RTEMS_DEFAULT_MODES, | |
528 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2] |
|
529 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2] | |
529 | ); |
|
530 | ); | |
530 | } |
|
531 | } | |
531 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
532 | if (status == RTEMS_SUCCESSFUL) // CWF1 | |
532 | { |
|
533 | { | |
533 | status = rtems_task_create( |
|
534 | status = rtems_task_create( | |
534 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, |
|
535 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, | |
535 | RTEMS_DEFAULT_MODES, |
|
536 | RTEMS_DEFAULT_MODES, | |
536 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1] |
|
537 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1] | |
537 | ); |
|
538 | ); | |
538 | } |
|
539 | } | |
539 | if (status == RTEMS_SUCCESSFUL) // SWBD |
|
540 | if (status == RTEMS_SUCCESSFUL) // SWBD | |
540 | { |
|
541 | { | |
541 | status = rtems_task_create( |
|
542 | status = rtems_task_create( | |
542 | Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE, |
|
543 | Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE, | |
543 | RTEMS_DEFAULT_MODES, |
|
544 | RTEMS_DEFAULT_MODES, | |
544 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD] |
|
545 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD] | |
545 | ); |
|
546 | ); | |
546 | } |
|
547 | } | |
547 |
|
548 | |||
548 | //***** |
|
549 | //***** | |
549 | // MISC |
|
550 | // MISC | |
550 | if (status == RTEMS_SUCCESSFUL) // LOAD |
|
551 | if (status == RTEMS_SUCCESSFUL) // LOAD | |
551 | { |
|
552 | { | |
552 | status = rtems_task_create( |
|
553 | status = rtems_task_create( | |
553 | Task_name[TASKID_LOAD], TASK_PRIORITY_LOAD, RTEMS_MINIMUM_STACK_SIZE, |
|
554 | Task_name[TASKID_LOAD], TASK_PRIORITY_LOAD, RTEMS_MINIMUM_STACK_SIZE, | |
554 | RTEMS_DEFAULT_MODES, |
|
555 | RTEMS_DEFAULT_MODES, | |
555 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LOAD] |
|
556 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LOAD] | |
556 | ); |
|
557 | ); | |
557 | } |
|
558 | } | |
558 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
559 | if (status == RTEMS_SUCCESSFUL) // DUMB | |
559 | { |
|
560 | { | |
560 | status = rtems_task_create( |
|
561 | status = rtems_task_create( | |
561 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, |
|
562 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, | |
562 | RTEMS_DEFAULT_MODES, |
|
563 | RTEMS_DEFAULT_MODES, | |
563 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] |
|
564 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] | |
564 | ); |
|
565 | ); | |
565 | } |
|
566 | } | |
566 | if (status == RTEMS_SUCCESSFUL) // SCRUBBING TASK |
|
567 | if (status == RTEMS_SUCCESSFUL) // SCRUBBING TASK | |
567 | { |
|
568 | { | |
568 | status = rtems_task_create( |
|
569 | status = rtems_task_create( | |
569 | Task_name[TASKID_SCRB], TASK_PRIORITY_SCRB, RTEMS_MINIMUM_STACK_SIZE, |
|
570 | Task_name[TASKID_SCRB], TASK_PRIORITY_SCRB, RTEMS_MINIMUM_STACK_SIZE, | |
570 | RTEMS_DEFAULT_MODES, |
|
571 | RTEMS_DEFAULT_MODES, | |
571 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SCRB] |
|
572 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SCRB] | |
572 | ); |
|
573 | ); | |
573 | } |
|
574 | } | |
574 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
575 | if (status == RTEMS_SUCCESSFUL) // HOUS | |
575 | { |
|
576 | { | |
576 | status = rtems_task_create( |
|
577 | status = rtems_task_create( | |
577 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, |
|
578 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, | |
578 | RTEMS_DEFAULT_MODES, |
|
579 | RTEMS_DEFAULT_MODES, | |
579 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS] |
|
580 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS] | |
580 | ); |
|
581 | ); | |
581 | } |
|
582 | } | |
582 | if (status == RTEMS_SUCCESSFUL) // AVGV |
|
583 | if (status == RTEMS_SUCCESSFUL) // AVGV | |
583 | { |
|
584 | { | |
584 | status = rtems_task_create( |
|
585 | status = rtems_task_create( | |
585 | Task_name[TASKID_AVGV], TASK_PRIORITY_AVGV, RTEMS_MINIMUM_STACK_SIZE, |
|
586 | Task_name[TASKID_AVGV], TASK_PRIORITY_AVGV, RTEMS_MINIMUM_STACK_SIZE, | |
586 | RTEMS_DEFAULT_MODES, |
|
587 | RTEMS_DEFAULT_MODES, | |
587 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVGV] |
|
588 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVGV] | |
588 | ); |
|
589 | ); | |
589 | } |
|
590 | } | |
|
591 | if (status == RTEMS_SUCCESSFUL) // CALI | |||
|
592 | { | |||
|
593 | status = rtems_task_create( | |||
|
594 | Task_name[TASKID_CALI], TASK_PRIORITY_CALI, RTEMS_MINIMUM_STACK_SIZE, | |||
|
595 | RTEMS_DEFAULT_MODES, | |||
|
596 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CALI] | |||
|
597 | ); | |||
|
598 | } | |||
590 |
|
599 | |||
591 | return status; |
|
600 | return status; | |
592 | } |
|
601 | } | |
593 |
|
602 | |||
594 | int start_recv_send_tasks( void ) |
|
603 | int start_recv_send_tasks( void ) | |
595 | { |
|
604 | { | |
596 | rtems_status_code status; |
|
605 | rtems_status_code status; | |
597 |
|
606 | |||
598 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); |
|
607 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); | |
599 | if (status!=RTEMS_SUCCESSFUL) { |
|
608 | if (status!=RTEMS_SUCCESSFUL) { | |
600 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") |
|
609 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") | |
601 | } |
|
610 | } | |
602 |
|
611 | |||
603 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
612 | if (status == RTEMS_SUCCESSFUL) // SEND | |
604 | { |
|
613 | { | |
605 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); |
|
614 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); | |
606 | if (status!=RTEMS_SUCCESSFUL) { |
|
615 | if (status!=RTEMS_SUCCESSFUL) { | |
607 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") |
|
616 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") | |
608 | } |
|
617 | } | |
609 | } |
|
618 | } | |
610 |
|
619 | |||
611 | return status; |
|
620 | return status; | |
612 | } |
|
621 | } | |
613 |
|
622 | |||
614 | int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS |
|
623 | int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS | |
615 | { |
|
624 | { | |
616 | /** This function starts all RTEMS tasks used in the software. |
|
625 | /** This function starts all RTEMS tasks used in the software. | |
617 | * |
|
626 | * | |
618 | * @return RTEMS directive status codes: |
|
627 | * @return RTEMS directive status codes: | |
619 | * - RTEMS_SUCCESSFUL - ask started successfully |
|
628 | * - RTEMS_SUCCESSFUL - ask started successfully | |
620 | * - RTEMS_INVALID_ADDRESS - invalid task entry point |
|
629 | * - RTEMS_INVALID_ADDRESS - invalid task entry point | |
621 | * - RTEMS_INVALID_ID - invalid task id |
|
630 | * - RTEMS_INVALID_ID - invalid task id | |
622 | * - RTEMS_INCORRECT_STATE - task not in the dormant state |
|
631 | * - RTEMS_INCORRECT_STATE - task not in the dormant state | |
623 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task |
|
632 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task | |
624 | * |
|
633 | * | |
625 | */ |
|
634 | */ | |
626 | // starts all the tasks fot eh flight software |
|
635 | // starts all the tasks fot eh flight software | |
627 |
|
636 | |||
628 | rtems_status_code status; |
|
637 | rtems_status_code status; | |
629 |
|
638 | |||
630 | //********** |
|
639 | //********** | |
631 | // SPACEWIRE |
|
640 | // SPACEWIRE | |
632 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); |
|
641 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); | |
633 | if (status!=RTEMS_SUCCESSFUL) { |
|
642 | if (status!=RTEMS_SUCCESSFUL) { | |
634 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") |
|
643 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") | |
635 | } |
|
644 | } | |
636 |
|
645 | |||
637 | if (status == RTEMS_SUCCESSFUL) // LINK |
|
646 | if (status == RTEMS_SUCCESSFUL) // LINK | |
638 | { |
|
647 | { | |
639 | status = rtems_task_start( Task_id[TASKID_LINK], link_task, 1 ); |
|
648 | status = rtems_task_start( Task_id[TASKID_LINK], link_task, 1 ); | |
640 | if (status!=RTEMS_SUCCESSFUL) { |
|
649 | if (status!=RTEMS_SUCCESSFUL) { | |
641 | BOOT_PRINTF("in INIT *** Error starting TASK_LINK\n") |
|
650 | BOOT_PRINTF("in INIT *** Error starting TASK_LINK\n") | |
642 | } |
|
651 | } | |
643 | } |
|
652 | } | |
644 |
|
653 | |||
645 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
654 | if (status == RTEMS_SUCCESSFUL) // ACTN | |
646 | { |
|
655 | { | |
647 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); |
|
656 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); | |
648 | if (status!=RTEMS_SUCCESSFUL) { |
|
657 | if (status!=RTEMS_SUCCESSFUL) { | |
649 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") |
|
658 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") | |
650 | } |
|
659 | } | |
651 | } |
|
660 | } | |
652 |
|
661 | |||
653 | //****************** |
|
662 | //****************** | |
654 | // SPECTRAL MATRICES |
|
663 | // SPECTRAL MATRICES | |
655 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
664 | if (status == RTEMS_SUCCESSFUL) // AVF0 | |
656 | { |
|
665 | { | |
657 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY ); |
|
666 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY ); | |
658 | if (status!=RTEMS_SUCCESSFUL) { |
|
667 | if (status!=RTEMS_SUCCESSFUL) { | |
659 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") |
|
668 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") | |
660 | } |
|
669 | } | |
661 | } |
|
670 | } | |
662 | if (status == RTEMS_SUCCESSFUL) // PRC0 |
|
671 | if (status == RTEMS_SUCCESSFUL) // PRC0 | |
663 | { |
|
672 | { | |
664 | status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY ); |
|
673 | status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY ); | |
665 | if (status!=RTEMS_SUCCESSFUL) { |
|
674 | if (status!=RTEMS_SUCCESSFUL) { | |
666 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n") |
|
675 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n") | |
667 | } |
|
676 | } | |
668 | } |
|
677 | } | |
669 | if (status == RTEMS_SUCCESSFUL) // AVF1 |
|
678 | if (status == RTEMS_SUCCESSFUL) // AVF1 | |
670 | { |
|
679 | { | |
671 | status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY ); |
|
680 | status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY ); | |
672 | if (status!=RTEMS_SUCCESSFUL) { |
|
681 | if (status!=RTEMS_SUCCESSFUL) { | |
673 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n") |
|
682 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n") | |
674 | } |
|
683 | } | |
675 | } |
|
684 | } | |
676 | if (status == RTEMS_SUCCESSFUL) // PRC1 |
|
685 | if (status == RTEMS_SUCCESSFUL) // PRC1 | |
677 | { |
|
686 | { | |
678 | status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY ); |
|
687 | status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY ); | |
679 | if (status!=RTEMS_SUCCESSFUL) { |
|
688 | if (status!=RTEMS_SUCCESSFUL) { | |
680 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n") |
|
689 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n") | |
681 | } |
|
690 | } | |
682 | } |
|
691 | } | |
683 | if (status == RTEMS_SUCCESSFUL) // AVF2 |
|
692 | if (status == RTEMS_SUCCESSFUL) // AVF2 | |
684 | { |
|
693 | { | |
685 | status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 ); |
|
694 | status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 ); | |
686 | if (status!=RTEMS_SUCCESSFUL) { |
|
695 | if (status!=RTEMS_SUCCESSFUL) { | |
687 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n") |
|
696 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n") | |
688 | } |
|
697 | } | |
689 | } |
|
698 | } | |
690 | if (status == RTEMS_SUCCESSFUL) // PRC2 |
|
699 | if (status == RTEMS_SUCCESSFUL) // PRC2 | |
691 | { |
|
700 | { | |
692 | status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 ); |
|
701 | status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 ); | |
693 | if (status!=RTEMS_SUCCESSFUL) { |
|
702 | if (status!=RTEMS_SUCCESSFUL) { | |
694 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n") |
|
703 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n") | |
695 | } |
|
704 | } | |
696 | } |
|
705 | } | |
697 |
|
706 | |||
698 | //**************** |
|
707 | //**************** | |
699 | // WAVEFORM PICKER |
|
708 | // WAVEFORM PICKER | |
700 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
709 | if (status == RTEMS_SUCCESSFUL) // WFRM | |
701 | { |
|
710 | { | |
702 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); |
|
711 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); | |
703 | if (status!=RTEMS_SUCCESSFUL) { |
|
712 | if (status!=RTEMS_SUCCESSFUL) { | |
704 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") |
|
713 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") | |
705 | } |
|
714 | } | |
706 | } |
|
715 | } | |
707 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
716 | if (status == RTEMS_SUCCESSFUL) // CWF3 | |
708 | { |
|
717 | { | |
709 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); |
|
718 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); | |
710 | if (status!=RTEMS_SUCCESSFUL) { |
|
719 | if (status!=RTEMS_SUCCESSFUL) { | |
711 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") |
|
720 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") | |
712 | } |
|
721 | } | |
713 | } |
|
722 | } | |
714 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
723 | if (status == RTEMS_SUCCESSFUL) // CWF2 | |
715 | { |
|
724 | { | |
716 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); |
|
725 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); | |
717 | if (status!=RTEMS_SUCCESSFUL) { |
|
726 | if (status!=RTEMS_SUCCESSFUL) { | |
718 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") |
|
727 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") | |
719 | } |
|
728 | } | |
720 | } |
|
729 | } | |
721 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
730 | if (status == RTEMS_SUCCESSFUL) // CWF1 | |
722 | { |
|
731 | { | |
723 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); |
|
732 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); | |
724 | if (status!=RTEMS_SUCCESSFUL) { |
|
733 | if (status!=RTEMS_SUCCESSFUL) { | |
725 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") |
|
734 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") | |
726 | } |
|
735 | } | |
727 | } |
|
736 | } | |
728 | if (status == RTEMS_SUCCESSFUL) // SWBD |
|
737 | if (status == RTEMS_SUCCESSFUL) // SWBD | |
729 | { |
|
738 | { | |
730 | status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 ); |
|
739 | status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 ); | |
731 | if (status!=RTEMS_SUCCESSFUL) { |
|
740 | if (status!=RTEMS_SUCCESSFUL) { | |
732 | BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n") |
|
741 | BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n") | |
733 | } |
|
742 | } | |
734 | } |
|
743 | } | |
735 |
|
744 | |||
736 | //***** |
|
745 | //***** | |
737 | // MISC |
|
746 | // MISC | |
738 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
747 | if (status == RTEMS_SUCCESSFUL) // HOUS | |
739 | { |
|
748 | { | |
740 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); |
|
749 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); | |
741 | if (status!=RTEMS_SUCCESSFUL) { |
|
750 | if (status!=RTEMS_SUCCESSFUL) { | |
742 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") |
|
751 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") | |
743 | } |
|
752 | } | |
744 | } |
|
753 | } | |
745 | if (status == RTEMS_SUCCESSFUL) // AVGV |
|
754 | if (status == RTEMS_SUCCESSFUL) // AVGV | |
746 | { |
|
755 | { | |
747 | status = rtems_task_start( Task_id[TASKID_AVGV], avgv_task, 1 ); |
|
756 | status = rtems_task_start( Task_id[TASKID_AVGV], avgv_task, 1 ); | |
748 | if (status!=RTEMS_SUCCESSFUL) { |
|
757 | if (status!=RTEMS_SUCCESSFUL) { | |
749 | BOOT_PRINTF("in INIT *** Error starting TASK_AVGV\n") |
|
758 | BOOT_PRINTF("in INIT *** Error starting TASK_AVGV\n") | |
750 | } |
|
759 | } | |
751 | } |
|
760 | } | |
752 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
761 | if (status == RTEMS_SUCCESSFUL) // DUMB | |
753 | { |
|
762 | { | |
754 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); |
|
763 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); | |
755 | if (status!=RTEMS_SUCCESSFUL) { |
|
764 | if (status!=RTEMS_SUCCESSFUL) { | |
756 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") |
|
765 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") | |
757 | } |
|
766 | } | |
758 | } |
|
767 | } | |
759 | if (status == RTEMS_SUCCESSFUL) // SCRUBBING |
|
768 | if (status == RTEMS_SUCCESSFUL) // SCRUBBING | |
760 | { |
|
769 | { | |
761 | status = rtems_task_start( Task_id[TASKID_SCRB], scrubbing_task, 1 ); |
|
770 | status = rtems_task_start( Task_id[TASKID_SCRB], scrubbing_task, 1 ); | |
762 | if (status!=RTEMS_SUCCESSFUL) { |
|
771 | if (status!=RTEMS_SUCCESSFUL) { | |
763 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") |
|
772 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") | |
764 | } |
|
773 | } | |
765 | } |
|
774 | } | |
766 | if (status == RTEMS_SUCCESSFUL) // LOAD |
|
775 | if (status == RTEMS_SUCCESSFUL) // LOAD | |
767 | { |
|
776 | { | |
768 | status = rtems_task_start( Task_id[TASKID_LOAD], load_task, 1 ); |
|
777 | status = rtems_task_start( Task_id[TASKID_LOAD], load_task, 1 ); | |
769 | if (status!=RTEMS_SUCCESSFUL) { |
|
778 | if (status!=RTEMS_SUCCESSFUL) { | |
770 | BOOT_PRINTF("in INIT *** Error starting TASK_LOAD\n") |
|
779 | BOOT_PRINTF("in INIT *** Error starting TASK_LOAD\n") | |
771 | } |
|
780 | } | |
772 | } |
|
781 | } | |
|
782 | if (status == RTEMS_SUCCESSFUL) // CALI | |||
|
783 | { | |||
|
784 | status = rtems_task_start( Task_id[TASKID_CALI], calibration_sweep_task, 1 ); | |||
|
785 | if (status!=RTEMS_SUCCESSFUL) { | |||
|
786 | BOOT_PRINTF("in INIT *** Error starting TASK_LOAD\n") | |||
|
787 | } | |||
|
788 | } | |||
773 |
|
789 | |||
774 | return status; |
|
790 | return status; | |
775 | } |
|
791 | } | |
776 |
|
792 | |||
777 | rtems_status_code create_message_queues( void ) // create the two message queues used in the software |
|
793 | rtems_status_code create_message_queues( void ) // create the two message queues used in the software | |
778 | { |
|
794 | { | |
779 | rtems_status_code status_recv; |
|
795 | rtems_status_code status_recv; | |
780 | rtems_status_code status_send; |
|
796 | rtems_status_code status_send; | |
781 | rtems_status_code status_q_p0; |
|
797 | rtems_status_code status_q_p0; | |
782 | rtems_status_code status_q_p1; |
|
798 | rtems_status_code status_q_p1; | |
783 | rtems_status_code status_q_p2; |
|
799 | rtems_status_code status_q_p2; | |
784 | rtems_status_code ret; |
|
800 | rtems_status_code ret; | |
785 | rtems_id queue_id; |
|
801 | rtems_id queue_id; | |
786 |
|
802 | |||
787 | ret = RTEMS_SUCCESSFUL; |
|
803 | ret = RTEMS_SUCCESSFUL; | |
788 | queue_id = RTEMS_ID_NONE; |
|
804 | queue_id = RTEMS_ID_NONE; | |
789 |
|
805 | |||
790 | //**************************************** |
|
806 | //**************************************** | |
791 | // create the queue for handling valid TCs |
|
807 | // create the queue for handling valid TCs | |
792 | status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV], |
|
808 | status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV], | |
793 | MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE, |
|
809 | MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE, | |
794 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
810 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
795 | if ( status_recv != RTEMS_SUCCESSFUL ) { |
|
811 | if ( status_recv != RTEMS_SUCCESSFUL ) { | |
796 | PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv) |
|
812 | PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv) | |
797 | } |
|
813 | } | |
798 |
|
814 | |||
799 | //************************************************ |
|
815 | //************************************************ | |
800 | // create the queue for handling TM packet sending |
|
816 | // create the queue for handling TM packet sending | |
801 | status_send = rtems_message_queue_create( misc_name[QUEUE_SEND], |
|
817 | status_send = rtems_message_queue_create( misc_name[QUEUE_SEND], | |
802 | MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND, |
|
818 | MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND, | |
803 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
819 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
804 | if ( status_send != RTEMS_SUCCESSFUL ) { |
|
820 | if ( status_send != RTEMS_SUCCESSFUL ) { | |
805 | PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send) |
|
821 | PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send) | |
806 | } |
|
822 | } | |
807 |
|
823 | |||
808 | //***************************************************************************** |
|
824 | //***************************************************************************** | |
809 | // create the queue for handling averaged spectral matrices for processing @ f0 |
|
825 | // create the queue for handling averaged spectral matrices for processing @ f0 | |
810 | status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0], |
|
826 | status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0], | |
811 | MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0, |
|
827 | MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0, | |
812 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
828 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
813 | if ( status_q_p0 != RTEMS_SUCCESSFUL ) { |
|
829 | if ( status_q_p0 != RTEMS_SUCCESSFUL ) { | |
814 | PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0) |
|
830 | PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0) | |
815 | } |
|
831 | } | |
816 |
|
832 | |||
817 | //***************************************************************************** |
|
833 | //***************************************************************************** | |
818 | // create the queue for handling averaged spectral matrices for processing @ f1 |
|
834 | // create the queue for handling averaged spectral matrices for processing @ f1 | |
819 | status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1], |
|
835 | status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1], | |
820 | MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1, |
|
836 | MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1, | |
821 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
837 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
822 | if ( status_q_p1 != RTEMS_SUCCESSFUL ) { |
|
838 | if ( status_q_p1 != RTEMS_SUCCESSFUL ) { | |
823 | PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1) |
|
839 | PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1) | |
824 | } |
|
840 | } | |
825 |
|
841 | |||
826 | //***************************************************************************** |
|
842 | //***************************************************************************** | |
827 | // create the queue for handling averaged spectral matrices for processing @ f2 |
|
843 | // create the queue for handling averaged spectral matrices for processing @ f2 | |
828 | status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2], |
|
844 | status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2], | |
829 | MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2, |
|
845 | MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2, | |
830 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
846 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
831 | if ( status_q_p2 != RTEMS_SUCCESSFUL ) { |
|
847 | if ( status_q_p2 != RTEMS_SUCCESSFUL ) { | |
832 | PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2) |
|
848 | PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2) | |
833 | } |
|
849 | } | |
834 |
|
850 | |||
835 | if ( status_recv != RTEMS_SUCCESSFUL ) |
|
851 | if ( status_recv != RTEMS_SUCCESSFUL ) | |
836 | { |
|
852 | { | |
837 | ret = status_recv; |
|
853 | ret = status_recv; | |
838 | } |
|
854 | } | |
839 | else if( status_send != RTEMS_SUCCESSFUL ) |
|
855 | else if( status_send != RTEMS_SUCCESSFUL ) | |
840 | { |
|
856 | { | |
841 | ret = status_send; |
|
857 | ret = status_send; | |
842 | } |
|
858 | } | |
843 | else if( status_q_p0 != RTEMS_SUCCESSFUL ) |
|
859 | else if( status_q_p0 != RTEMS_SUCCESSFUL ) | |
844 | { |
|
860 | { | |
845 | ret = status_q_p0; |
|
861 | ret = status_q_p0; | |
846 | } |
|
862 | } | |
847 | else if( status_q_p1 != RTEMS_SUCCESSFUL ) |
|
863 | else if( status_q_p1 != RTEMS_SUCCESSFUL ) | |
848 | { |
|
864 | { | |
849 | ret = status_q_p1; |
|
865 | ret = status_q_p1; | |
850 | } |
|
866 | } | |
851 | else |
|
867 | else | |
852 | { |
|
868 | { | |
853 | ret = status_q_p2; |
|
869 | ret = status_q_p2; | |
854 | } |
|
870 | } | |
855 |
|
871 | |||
856 | return ret; |
|
872 | return ret; | |
857 | } |
|
873 | } | |
858 |
|
874 | |||
859 | rtems_status_code create_timecode_timer( void ) |
|
875 | rtems_status_code create_timecode_timer( void ) | |
860 | { |
|
876 | { | |
861 | rtems_status_code status; |
|
877 | rtems_status_code status; | |
862 |
|
878 | |||
863 | status = rtems_timer_create( timecode_timer_name, &timecode_timer_id ); |
|
879 | status = rtems_timer_create( timecode_timer_name, &timecode_timer_id ); | |
864 |
|
880 | |||
865 | if ( status != RTEMS_SUCCESSFUL ) |
|
881 | if ( status != RTEMS_SUCCESSFUL ) | |
866 | { |
|
882 | { | |
867 | PRINTF1("in create_timer_timecode *** ERR creating SPTC timer, %d\n", status) |
|
883 | PRINTF1("in create_timer_timecode *** ERR creating SPTC timer, %d\n", status) | |
868 | } |
|
884 | } | |
869 | else |
|
885 | else | |
870 | { |
|
886 | { | |
871 | PRINTF("in create_timer_timecode *** OK creating SPTC timer\n") |
|
887 | PRINTF("in create_timer_timecode *** OK creating SPTC timer\n") | |
872 | } |
|
888 | } | |
873 |
|
889 | |||
874 | return status; |
|
890 | return status; | |
875 | } |
|
891 | } | |
876 |
|
892 | |||
877 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ) |
|
893 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ) | |
878 | { |
|
894 | { | |
879 | rtems_status_code status; |
|
895 | rtems_status_code status; | |
880 | rtems_name queue_name; |
|
896 | rtems_name queue_name; | |
881 |
|
897 | |||
882 | queue_name = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
898 | queue_name = rtems_build_name( 'Q', '_', 'S', 'D' ); | |
883 |
|
899 | |||
884 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
900 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
885 |
|
901 | |||
886 | return status; |
|
902 | return status; | |
887 | } |
|
903 | } | |
888 |
|
904 | |||
889 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ) |
|
905 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ) | |
890 | { |
|
906 | { | |
891 | rtems_status_code status; |
|
907 | rtems_status_code status; | |
892 | rtems_name queue_name; |
|
908 | rtems_name queue_name; | |
893 |
|
909 | |||
894 | queue_name = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
910 | queue_name = rtems_build_name( 'Q', '_', 'R', 'V' ); | |
895 |
|
911 | |||
896 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
912 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
897 |
|
913 | |||
898 | return status; |
|
914 | return status; | |
899 | } |
|
915 | } | |
900 |
|
916 | |||
901 | rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id ) |
|
917 | rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id ) | |
902 | { |
|
918 | { | |
903 | rtems_status_code status; |
|
919 | rtems_status_code status; | |
904 | rtems_name queue_name; |
|
920 | rtems_name queue_name; | |
905 |
|
921 | |||
906 | queue_name = rtems_build_name( 'Q', '_', 'P', '0' ); |
|
922 | queue_name = rtems_build_name( 'Q', '_', 'P', '0' ); | |
907 |
|
923 | |||
908 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
924 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
909 |
|
925 | |||
910 | return status; |
|
926 | return status; | |
911 | } |
|
927 | } | |
912 |
|
928 | |||
913 | rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ) |
|
929 | rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ) | |
914 | { |
|
930 | { | |
915 | rtems_status_code status; |
|
931 | rtems_status_code status; | |
916 | rtems_name queue_name; |
|
932 | rtems_name queue_name; | |
917 |
|
933 | |||
918 | queue_name = rtems_build_name( 'Q', '_', 'P', '1' ); |
|
934 | queue_name = rtems_build_name( 'Q', '_', 'P', '1' ); | |
919 |
|
935 | |||
920 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
936 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
921 |
|
937 | |||
922 | return status; |
|
938 | return status; | |
923 | } |
|
939 | } | |
924 |
|
940 | |||
925 | rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ) |
|
941 | rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ) | |
926 | { |
|
942 | { | |
927 | rtems_status_code status; |
|
943 | rtems_status_code status; | |
928 | rtems_name queue_name; |
|
944 | rtems_name queue_name; | |
929 |
|
945 | |||
930 | queue_name = rtems_build_name( 'Q', '_', 'P', '2' ); |
|
946 | queue_name = rtems_build_name( 'Q', '_', 'P', '2' ); | |
931 |
|
947 | |||
932 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
948 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
933 |
|
949 | |||
934 | return status; |
|
950 | return status; | |
935 | } |
|
951 | } | |
936 |
|
952 | |||
937 | void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max ) |
|
953 | void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max ) | |
938 | { |
|
954 | { | |
939 | u_int32_t count; |
|
955 | u_int32_t count; | |
940 | rtems_status_code status; |
|
956 | rtems_status_code status; | |
941 |
|
957 | |||
942 | count = 0; |
|
958 | count = 0; | |
943 |
|
959 | |||
944 | status = rtems_message_queue_get_number_pending( queue_id, &count ); |
|
960 | status = rtems_message_queue_get_number_pending( queue_id, &count ); | |
945 |
|
961 | |||
946 | count = count + 1; |
|
962 | count = count + 1; | |
947 |
|
963 | |||
948 | if (status != RTEMS_SUCCESSFUL) |
|
964 | if (status != RTEMS_SUCCESSFUL) | |
949 | { |
|
965 | { | |
950 | PRINTF1("in update_queue_max_count *** ERR = %d\n", status) |
|
966 | PRINTF1("in update_queue_max_count *** ERR = %d\n", status) | |
951 | } |
|
967 | } | |
952 | else |
|
968 | else | |
953 | { |
|
969 | { | |
954 | if (count > *fifo_size_max) |
|
970 | if (count > *fifo_size_max) | |
955 | { |
|
971 | { | |
956 | *fifo_size_max = count; |
|
972 | *fifo_size_max = count; | |
957 | } |
|
973 | } | |
958 | } |
|
974 | } | |
959 | } |
|
975 | } | |
960 |
|
976 | |||
961 | void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize ) |
|
977 | void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize ) | |
962 | { |
|
978 | { | |
963 | unsigned char i; |
|
979 | unsigned char i; | |
964 |
|
980 | |||
965 | //*************** |
|
981 | //*************** | |
966 | // BUFFER ADDRESS |
|
982 | // BUFFER ADDRESS | |
967 | for(i=0; i<nbNodes; i++) |
|
983 | for(i=0; i<nbNodes; i++) | |
968 | { |
|
984 | { | |
969 | ring[i].coarseTime = INT32_ALL_F; |
|
985 | ring[i].coarseTime = INT32_ALL_F; | |
970 | ring[i].fineTime = INT32_ALL_F; |
|
986 | ring[i].fineTime = INT32_ALL_F; | |
971 | ring[i].sid = INIT_CHAR; |
|
987 | ring[i].sid = INIT_CHAR; | |
972 | ring[i].status = INIT_CHAR; |
|
988 | ring[i].status = INIT_CHAR; | |
973 | ring[i].buffer_address = (int) &buffer[ i * bufferSize ]; |
|
989 | ring[i].buffer_address = (int) &buffer[ i * bufferSize ]; | |
974 | } |
|
990 | } | |
975 |
|
991 | |||
976 | //***** |
|
992 | //***** | |
977 | // NEXT |
|
993 | // NEXT | |
978 | ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ]; |
|
994 | ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ]; | |
979 | for(i=0; i<nbNodes-1; i++) |
|
995 | for(i=0; i<nbNodes-1; i++) | |
980 | { |
|
996 | { | |
981 | ring[i].next = (ring_node*) &ring[ i + 1 ]; |
|
997 | ring[i].next = (ring_node*) &ring[ i + 1 ]; | |
982 | } |
|
998 | } | |
983 |
|
999 | |||
984 | //********* |
|
1000 | //********* | |
985 | // PREVIOUS |
|
1001 | // PREVIOUS | |
986 | ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ]; |
|
1002 | ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ]; | |
987 | for(i=1; i<nbNodes; i++) |
|
1003 | for(i=1; i<nbNodes; i++) | |
988 | { |
|
1004 | { | |
989 | ring[i].previous = (ring_node*) &ring[ i - 1 ]; |
|
1005 | ring[i].previous = (ring_node*) &ring[ i - 1 ]; | |
990 | } |
|
1006 | } | |
991 | } |
|
1007 | } |
@@ -1,1057 +1,1095 | |||||
1 | /** General usage functions and RTEMS tasks. |
|
1 | /** General usage functions and RTEMS tasks. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | */ |
|
6 | */ | |
7 |
|
7 | |||
8 | #include "fsw_misc.h" |
|
8 | #include "fsw_misc.h" | |
9 |
|
9 | |||
10 | int16_t hk_lfr_sc_v_f3_as_int16 = 0; |
|
10 | int16_t hk_lfr_sc_v_f3_as_int16 = 0; | |
11 | int16_t hk_lfr_sc_e1_f3_as_int16 = 0; |
|
11 | int16_t hk_lfr_sc_e1_f3_as_int16 = 0; | |
12 | int16_t hk_lfr_sc_e2_f3_as_int16 = 0; |
|
12 | int16_t hk_lfr_sc_e2_f3_as_int16 = 0; | |
13 |
|
13 | |||
14 | void timer_configure(unsigned char timer, unsigned int clock_divider, |
|
14 | void timer_configure(unsigned char timer, unsigned int clock_divider, | |
15 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ) |
|
15 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ) | |
16 | { |
|
16 | { | |
17 | /** This function configures a GPTIMER timer instantiated in the VHDL design. |
|
17 | /** This function configures a GPTIMER timer instantiated in the VHDL design. | |
18 | * |
|
18 | * | |
19 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
19 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
20 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
20 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
21 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. |
|
21 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. | |
22 | * @param interrupt_level is the interrupt level that the timer drives. |
|
22 | * @param interrupt_level is the interrupt level that the timer drives. | |
23 | * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer. |
|
23 | * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer. | |
24 | * |
|
24 | * | |
25 | * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76 |
|
25 | * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76 | |
26 | * |
|
26 | * | |
27 | */ |
|
27 | */ | |
28 |
|
28 | |||
29 | rtems_status_code status; |
|
29 | rtems_status_code status; | |
30 | rtems_isr_entry old_isr_handler; |
|
30 | rtems_isr_entry old_isr_handler; | |
31 |
|
31 | |||
32 | old_isr_handler = NULL; |
|
32 | old_isr_handler = NULL; | |
33 |
|
33 | |||
34 | gptimer_regs->timer[timer].ctrl = INIT_CHAR; // reset the control register |
|
34 | gptimer_regs->timer[timer].ctrl = INIT_CHAR; // reset the control register | |
35 |
|
35 | |||
36 | status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels |
|
36 | status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels | |
37 | if (status!=RTEMS_SUCCESSFUL) |
|
37 | if (status!=RTEMS_SUCCESSFUL) | |
38 | { |
|
38 | { | |
39 | PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n") |
|
39 | PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n") | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | timer_set_clock_divider( timer, clock_divider); |
|
42 | timer_set_clock_divider( timer, clock_divider); | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | void timer_start(unsigned char timer) |
|
45 | void timer_start(unsigned char timer) | |
46 | { |
|
46 | { | |
47 | /** This function starts a GPTIMER timer. |
|
47 | /** This function starts a GPTIMER timer. | |
48 | * |
|
48 | * | |
49 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
49 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
50 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
50 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
51 | * |
|
51 | * | |
52 | */ |
|
52 | */ | |
53 |
|
53 | |||
54 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_CLEAR_IRQ; |
|
54 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_CLEAR_IRQ; | |
55 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_LD; |
|
55 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_LD; | |
56 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_EN; |
|
56 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_EN; | |
57 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_RS; |
|
57 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_RS; | |
58 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_IE; |
|
58 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_IE; | |
59 | } |
|
59 | } | |
60 |
|
60 | |||
61 | void timer_stop(unsigned char timer) |
|
61 | void timer_stop(unsigned char timer) | |
62 | { |
|
62 | { | |
63 | /** This function stops a GPTIMER timer. |
|
63 | /** This function stops a GPTIMER timer. | |
64 | * |
|
64 | * | |
65 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
65 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
66 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
66 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
67 | * |
|
67 | * | |
68 | */ |
|
68 | */ | |
69 |
|
69 | |||
70 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & GPTIMER_EN_MASK; |
|
70 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & GPTIMER_EN_MASK; | |
71 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & GPTIMER_IE_MASK; |
|
71 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & GPTIMER_IE_MASK; | |
72 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_CLEAR_IRQ; |
|
72 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | GPTIMER_CLEAR_IRQ; | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider) |
|
75 | void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider) | |
76 | { |
|
76 | { | |
77 | /** This function sets the clock divider of a GPTIMER timer. |
|
77 | /** This function sets the clock divider of a GPTIMER timer. | |
78 | * |
|
78 | * | |
79 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
79 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
80 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
80 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
81 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. |
|
81 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. | |
82 | * |
|
82 | * | |
83 | */ |
|
83 | */ | |
84 |
|
84 | |||
85 | gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz |
|
85 | gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz | |
86 | } |
|
86 | } | |
87 |
|
87 | |||
88 | // WATCHDOG |
|
88 | // WATCHDOG | |
89 |
|
89 | |||
90 | rtems_isr watchdog_isr( rtems_vector_number vector ) |
|
90 | rtems_isr watchdog_isr( rtems_vector_number vector ) | |
91 | { |
|
91 | { | |
92 | rtems_status_code status_code; |
|
92 | rtems_status_code status_code; | |
93 |
|
93 | |||
94 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_12 ); |
|
94 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_12 ); | |
95 |
|
95 | |||
96 | PRINTF("watchdog_isr *** this is the end, exit(0)\n"); |
|
96 | PRINTF("watchdog_isr *** this is the end, exit(0)\n"); | |
97 |
|
97 | |||
98 | exit(0); |
|
98 | exit(0); | |
99 | } |
|
99 | } | |
100 |
|
100 | |||
101 | void watchdog_configure(void) |
|
101 | void watchdog_configure(void) | |
102 | { |
|
102 | { | |
103 | /** This function configure the watchdog. |
|
103 | /** This function configure the watchdog. | |
104 | * |
|
104 | * | |
105 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
105 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
106 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
106 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
107 | * |
|
107 | * | |
108 | * The watchdog is a timer provided by the GPTIMER IP core of the GRLIB. |
|
108 | * The watchdog is a timer provided by the GPTIMER IP core of the GRLIB. | |
109 | * |
|
109 | * | |
110 | */ |
|
110 | */ | |
111 |
|
111 | |||
112 | LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt during configuration |
|
112 | LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt during configuration | |
113 |
|
113 | |||
114 | timer_configure( TIMER_WATCHDOG, CLKDIV_WATCHDOG, IRQ_SPARC_GPTIMER_WATCHDOG, watchdog_isr ); |
|
114 | timer_configure( TIMER_WATCHDOG, CLKDIV_WATCHDOG, IRQ_SPARC_GPTIMER_WATCHDOG, watchdog_isr ); | |
115 |
|
115 | |||
116 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt |
|
116 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt | |
117 | } |
|
117 | } | |
118 |
|
118 | |||
119 | void watchdog_stop(void) |
|
119 | void watchdog_stop(void) | |
120 | { |
|
120 | { | |
121 | LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt line |
|
121 | LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt line | |
122 | timer_stop( TIMER_WATCHDOG ); |
|
122 | timer_stop( TIMER_WATCHDOG ); | |
123 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt |
|
123 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt | |
124 | } |
|
124 | } | |
125 |
|
125 | |||
126 | void watchdog_reload(void) |
|
126 | void watchdog_reload(void) | |
127 | { |
|
127 | { | |
128 | /** This function reloads the watchdog timer counter with the timer reload value. |
|
128 | /** This function reloads the watchdog timer counter with the timer reload value. | |
129 | * |
|
129 | * | |
130 | * @param void |
|
130 | * @param void | |
131 | * |
|
131 | * | |
132 | * @return void |
|
132 | * @return void | |
133 | * |
|
133 | * | |
134 | */ |
|
134 | */ | |
135 |
|
135 | |||
136 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_LD; |
|
136 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_LD; | |
137 | } |
|
137 | } | |
138 |
|
138 | |||
139 | void watchdog_start(void) |
|
139 | void watchdog_start(void) | |
140 | { |
|
140 | { | |
141 | /** This function starts the watchdog timer. |
|
141 | /** This function starts the watchdog timer. | |
142 | * |
|
142 | * | |
143 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
143 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
144 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
144 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
145 | * |
|
145 | * | |
146 | */ |
|
146 | */ | |
147 |
|
147 | |||
148 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); |
|
148 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); | |
149 |
|
149 | |||
150 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_CLEAR_IRQ; |
|
150 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_CLEAR_IRQ; | |
151 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_LD; |
|
151 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_LD; | |
152 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_EN; |
|
152 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_EN; | |
153 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_IE; |
|
153 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | GPTIMER_IE; | |
154 |
|
154 | |||
155 | LEON_Unmask_interrupt( IRQ_GPTIMER_WATCHDOG ); |
|
155 | LEON_Unmask_interrupt( IRQ_GPTIMER_WATCHDOG ); | |
156 |
|
156 | |||
157 | } |
|
157 | } | |
158 |
|
158 | |||
159 | int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register |
|
159 | int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register | |
160 | { |
|
160 | { | |
161 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; |
|
161 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; | |
162 |
|
162 | |||
163 | apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE; |
|
163 | apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE; | |
164 |
|
164 | |||
165 | return 0; |
|
165 | return 0; | |
166 | } |
|
166 | } | |
167 |
|
167 | |||
168 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value) |
|
168 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value) | |
169 | { |
|
169 | { | |
170 | /** This function sets the scaler reload register of the apbuart module |
|
170 | /** This function sets the scaler reload register of the apbuart module | |
171 | * |
|
171 | * | |
172 | * @param regs is the address of the apbuart registers in memory |
|
172 | * @param regs is the address of the apbuart registers in memory | |
173 | * @param value is the value that will be stored in the scaler register |
|
173 | * @param value is the value that will be stored in the scaler register | |
174 | * |
|
174 | * | |
175 | * The value shall be set by the software to get data on the serial interface. |
|
175 | * The value shall be set by the software to get data on the serial interface. | |
176 | * |
|
176 | * | |
177 | */ |
|
177 | */ | |
178 |
|
178 | |||
179 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs; |
|
179 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs; | |
180 |
|
180 | |||
181 | apbuart_regs->scaler = value; |
|
181 | apbuart_regs->scaler = value; | |
182 |
|
182 | |||
183 | BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value) |
|
183 | BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value) | |
184 | } |
|
184 | } | |
185 |
|
185 | |||
186 | //************ |
|
186 | //************ | |
187 | // RTEMS TASKS |
|
187 | // RTEMS TASKS | |
188 |
|
188 | |||
189 | rtems_task load_task(rtems_task_argument argument) |
|
189 | rtems_task load_task(rtems_task_argument argument) | |
190 | { |
|
190 | { | |
191 | BOOT_PRINTF("in LOAD *** \n") |
|
191 | BOOT_PRINTF("in LOAD *** \n") | |
192 |
|
192 | |||
193 | rtems_status_code status; |
|
193 | rtems_status_code status; | |
194 | unsigned int i; |
|
194 | unsigned int i; | |
195 | unsigned int j; |
|
195 | unsigned int j; | |
196 | rtems_name name_watchdog_rate_monotonic; // name of the watchdog rate monotonic |
|
196 | rtems_name name_watchdog_rate_monotonic; // name of the watchdog rate monotonic | |
197 | rtems_id watchdog_period_id; // id of the watchdog rate monotonic period |
|
197 | rtems_id watchdog_period_id; // id of the watchdog rate monotonic period | |
198 |
|
198 | |||
199 | watchdog_period_id = RTEMS_ID_NONE; |
|
199 | watchdog_period_id = RTEMS_ID_NONE; | |
200 |
|
200 | |||
201 | name_watchdog_rate_monotonic = rtems_build_name( 'L', 'O', 'A', 'D' ); |
|
201 | name_watchdog_rate_monotonic = rtems_build_name( 'L', 'O', 'A', 'D' ); | |
202 |
|
202 | |||
203 | status = rtems_rate_monotonic_create( name_watchdog_rate_monotonic, &watchdog_period_id ); |
|
203 | status = rtems_rate_monotonic_create( name_watchdog_rate_monotonic, &watchdog_period_id ); | |
204 | if( status != RTEMS_SUCCESSFUL ) { |
|
204 | if( status != RTEMS_SUCCESSFUL ) { | |
205 | PRINTF1( "in LOAD *** rtems_rate_monotonic_create failed with status of %d\n", status ) |
|
205 | PRINTF1( "in LOAD *** rtems_rate_monotonic_create failed with status of %d\n", status ) | |
206 | } |
|
206 | } | |
207 |
|
207 | |||
208 | i = 0; |
|
208 | i = 0; | |
209 | j = 0; |
|
209 | j = 0; | |
210 |
|
210 | |||
211 | watchdog_configure(); |
|
211 | watchdog_configure(); | |
212 |
|
212 | |||
213 | watchdog_start(); |
|
213 | watchdog_start(); | |
214 |
|
214 | |||
215 | set_sy_lfr_watchdog_enabled( true ); |
|
215 | set_sy_lfr_watchdog_enabled( true ); | |
216 |
|
216 | |||
217 | while(1){ |
|
217 | while(1){ | |
218 | status = rtems_rate_monotonic_period( watchdog_period_id, WATCHDOG_PERIOD ); |
|
218 | status = rtems_rate_monotonic_period( watchdog_period_id, WATCHDOG_PERIOD ); | |
219 | watchdog_reload(); |
|
219 | watchdog_reload(); | |
220 | i = i + 1; |
|
220 | i = i + 1; | |
221 | if ( i == WATCHDOG_LOOP_PRINTF ) |
|
221 | if ( i == WATCHDOG_LOOP_PRINTF ) | |
222 | { |
|
222 | { | |
223 | i = 0; |
|
223 | i = 0; | |
224 | j = j + 1; |
|
224 | j = j + 1; | |
225 | PRINTF1("%d\n", j) |
|
225 | PRINTF1("%d\n", j) | |
226 | } |
|
226 | } | |
227 | #ifdef DEBUG_WATCHDOG |
|
227 | #ifdef DEBUG_WATCHDOG | |
228 | if (j == WATCHDOG_LOOP_DEBUG ) |
|
228 | if (j == WATCHDOG_LOOP_DEBUG ) | |
229 | { |
|
229 | { | |
230 | status = rtems_task_delete(RTEMS_SELF); |
|
230 | status = rtems_task_delete(RTEMS_SELF); | |
231 | } |
|
231 | } | |
232 | #endif |
|
232 | #endif | |
233 | } |
|
233 | } | |
234 | } |
|
234 | } | |
235 |
|
235 | |||
236 | rtems_task hous_task(rtems_task_argument argument) |
|
236 | rtems_task hous_task(rtems_task_argument argument) | |
237 | { |
|
237 | { | |
238 | rtems_status_code status; |
|
238 | rtems_status_code status; | |
239 | rtems_status_code spare_status; |
|
239 | rtems_status_code spare_status; | |
240 | rtems_id queue_id; |
|
240 | rtems_id queue_id; | |
241 | rtems_rate_monotonic_period_status period_status; |
|
241 | rtems_rate_monotonic_period_status period_status; | |
242 | bool isSynchronized; |
|
242 | bool isSynchronized; | |
243 |
|
243 | |||
244 | queue_id = RTEMS_ID_NONE; |
|
244 | queue_id = RTEMS_ID_NONE; | |
245 | memset(&period_status, 0, sizeof(rtems_rate_monotonic_period_status)); |
|
245 | memset(&period_status, 0, sizeof(rtems_rate_monotonic_period_status)); | |
246 | isSynchronized = false; |
|
246 | isSynchronized = false; | |
247 |
|
247 | |||
248 | status = get_message_queue_id_send( &queue_id ); |
|
248 | status = get_message_queue_id_send( &queue_id ); | |
249 | if (status != RTEMS_SUCCESSFUL) |
|
249 | if (status != RTEMS_SUCCESSFUL) | |
250 | { |
|
250 | { | |
251 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) |
|
251 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) | |
252 | } |
|
252 | } | |
253 |
|
253 | |||
254 | BOOT_PRINTF("in HOUS ***\n"); |
|
254 | BOOT_PRINTF("in HOUS ***\n"); | |
255 |
|
255 | |||
256 | if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) { |
|
256 | if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) { | |
257 | status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id ); |
|
257 | status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id ); | |
258 | if( status != RTEMS_SUCCESSFUL ) { |
|
258 | if( status != RTEMS_SUCCESSFUL ) { | |
259 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ); |
|
259 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ); | |
260 | } |
|
260 | } | |
261 | } |
|
261 | } | |
262 |
|
262 | |||
263 | status = rtems_rate_monotonic_cancel(HK_id); |
|
263 | status = rtems_rate_monotonic_cancel(HK_id); | |
264 | if( status != RTEMS_SUCCESSFUL ) { |
|
264 | if( status != RTEMS_SUCCESSFUL ) { | |
265 | PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status ); |
|
265 | PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status ); | |
266 | } |
|
266 | } | |
267 | else { |
|
267 | else { | |
268 | DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n"); |
|
268 | DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n"); | |
269 | } |
|
269 | } | |
270 |
|
270 | |||
271 | // startup phase |
|
271 | // startup phase | |
272 | status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks ); |
|
272 | status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks ); | |
273 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); |
|
273 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); | |
274 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) |
|
274 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) | |
275 | while( (period_status.state != RATE_MONOTONIC_EXPIRED) |
|
275 | while( (period_status.state != RATE_MONOTONIC_EXPIRED) | |
276 | && (isSynchronized == false) ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway |
|
276 | && (isSynchronized == false) ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway | |
277 | { |
|
277 | { | |
278 | if ((time_management_regs->coarse_time & VAL_LFR_SYNCHRONIZED) == INT32_ALL_0) // check time synchronization |
|
278 | if ((time_management_regs->coarse_time & VAL_LFR_SYNCHRONIZED) == INT32_ALL_0) // check time synchronization | |
279 | { |
|
279 | { | |
280 | isSynchronized = true; |
|
280 | isSynchronized = true; | |
281 | } |
|
281 | } | |
282 | else |
|
282 | else | |
283 | { |
|
283 | { | |
284 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); |
|
284 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); | |
285 |
|
285 | |||
286 | status = rtems_task_wake_after( HK_SYNC_WAIT ); // wait HK_SYNCH_WAIT 100 ms = 10 * 10 ms |
|
286 | status = rtems_task_wake_after( HK_SYNC_WAIT ); // wait HK_SYNCH_WAIT 100 ms = 10 * 10 ms | |
287 | } |
|
287 | } | |
288 | } |
|
288 | } | |
289 | status = rtems_rate_monotonic_cancel(HK_id); |
|
289 | status = rtems_rate_monotonic_cancel(HK_id); | |
290 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) |
|
290 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) | |
291 |
|
291 | |||
292 | set_hk_lfr_reset_cause( POWER_ON ); |
|
292 | set_hk_lfr_reset_cause( POWER_ON ); | |
293 |
|
293 | |||
294 | while(1){ // launch the rate monotonic task |
|
294 | while(1){ // launch the rate monotonic task | |
295 | status = rtems_rate_monotonic_period( HK_id, HK_PERIOD ); |
|
295 | status = rtems_rate_monotonic_period( HK_id, HK_PERIOD ); | |
296 | if ( status != RTEMS_SUCCESSFUL ) { |
|
296 | if ( status != RTEMS_SUCCESSFUL ) { | |
297 | PRINTF1( "in HOUS *** ERR period: %d\n", status); |
|
297 | PRINTF1( "in HOUS *** ERR period: %d\n", status); | |
298 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 ); |
|
298 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 ); | |
299 | } |
|
299 | } | |
300 | else { |
|
300 | else { | |
301 | housekeeping_packet.packetSequenceControl[BYTE_0] = (unsigned char) (sequenceCounterHK >> SHIFT_1_BYTE); |
|
301 | housekeeping_packet.packetSequenceControl[BYTE_0] = (unsigned char) (sequenceCounterHK >> SHIFT_1_BYTE); | |
302 | housekeeping_packet.packetSequenceControl[BYTE_1] = (unsigned char) (sequenceCounterHK ); |
|
302 | housekeeping_packet.packetSequenceControl[BYTE_1] = (unsigned char) (sequenceCounterHK ); | |
303 | increment_seq_counter( &sequenceCounterHK ); |
|
303 | increment_seq_counter( &sequenceCounterHK ); | |
304 |
|
304 | |||
305 | housekeeping_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
305 | housekeeping_packet.time[BYTE_0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
306 | housekeeping_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
306 | housekeeping_packet.time[BYTE_1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
307 | housekeeping_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
307 | housekeeping_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
308 | housekeeping_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
308 | housekeeping_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
309 | housekeeping_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
309 | housekeeping_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
310 | housekeeping_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
310 | housekeeping_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
311 |
|
311 | |||
312 | spacewire_update_hk_lfr_link_state( &housekeeping_packet.lfr_status_word[0] ); |
|
312 | spacewire_update_hk_lfr_link_state( &housekeeping_packet.lfr_status_word[0] ); | |
313 |
|
313 | |||
314 | spacewire_read_statistics(); |
|
314 | spacewire_read_statistics(); | |
315 |
|
315 | |||
316 | update_hk_with_grspw_stats(); |
|
316 | update_hk_with_grspw_stats(); | |
317 |
|
317 | |||
318 | set_hk_lfr_time_not_synchro(); |
|
318 | set_hk_lfr_time_not_synchro(); | |
319 |
|
319 | |||
320 | housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max; |
|
320 | housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max; | |
321 | housekeeping_packet.hk_lfr_q_rv_fifo_size_max = hk_lfr_q_rv_fifo_size_max; |
|
321 | housekeeping_packet.hk_lfr_q_rv_fifo_size_max = hk_lfr_q_rv_fifo_size_max; | |
322 | housekeeping_packet.hk_lfr_q_p0_fifo_size_max = hk_lfr_q_p0_fifo_size_max; |
|
322 | housekeeping_packet.hk_lfr_q_p0_fifo_size_max = hk_lfr_q_p0_fifo_size_max; | |
323 | housekeeping_packet.hk_lfr_q_p1_fifo_size_max = hk_lfr_q_p1_fifo_size_max; |
|
323 | housekeeping_packet.hk_lfr_q_p1_fifo_size_max = hk_lfr_q_p1_fifo_size_max; | |
324 | housekeeping_packet.hk_lfr_q_p2_fifo_size_max = hk_lfr_q_p2_fifo_size_max; |
|
324 | housekeeping_packet.hk_lfr_q_p2_fifo_size_max = hk_lfr_q_p2_fifo_size_max; | |
325 |
|
325 | |||
326 | housekeeping_packet.sy_lfr_common_parameters_spare = parameter_dump_packet.sy_lfr_common_parameters_spare; |
|
326 | housekeeping_packet.sy_lfr_common_parameters_spare = parameter_dump_packet.sy_lfr_common_parameters_spare; | |
327 | housekeeping_packet.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
327 | housekeeping_packet.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
328 | get_temperatures( housekeeping_packet.hk_lfr_temp_scm ); |
|
328 | get_temperatures( housekeeping_packet.hk_lfr_temp_scm ); | |
329 | get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 ); |
|
329 | get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 ); | |
330 | get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load ); |
|
330 | get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load ); | |
331 |
|
331 | |||
332 | hk_lfr_le_me_he_update(); |
|
332 | hk_lfr_le_me_he_update(); | |
333 |
|
333 | |||
334 | // SEND PACKET |
|
334 | // SEND PACKET | |
335 | status = rtems_message_queue_send( queue_id, &housekeeping_packet, |
|
335 | status = rtems_message_queue_send( queue_id, &housekeeping_packet, | |
336 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
336 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
337 | if (status != RTEMS_SUCCESSFUL) { |
|
337 | if (status != RTEMS_SUCCESSFUL) { | |
338 | PRINTF1("in HOUS *** ERR send: %d\n", status) |
|
338 | PRINTF1("in HOUS *** ERR send: %d\n", status) | |
339 | } |
|
339 | } | |
340 | } |
|
340 | } | |
341 | } |
|
341 | } | |
342 |
|
342 | |||
343 | PRINTF("in HOUS *** deleting task\n") |
|
343 | PRINTF("in HOUS *** deleting task\n") | |
344 |
|
344 | |||
345 | status = rtems_task_delete( RTEMS_SELF ); // should not return |
|
345 | status = rtems_task_delete( RTEMS_SELF ); // should not return | |
346 |
|
346 | |||
347 | return; |
|
347 | return; | |
348 | } |
|
348 | } | |
349 |
|
349 | |||
350 | int filter( int x, filter_ctx* ctx ) |
|
350 | int filter( int x, filter_ctx* ctx ) | |
351 | { |
|
351 | { | |
352 | static const int b[NB_COEFFS][NB_COEFFS]={ {B00, B01, B02}, {B10, B11, B12}, {B20, B21, B22} }; |
|
352 | static const int b[NB_COEFFS][NB_COEFFS]={ {B00, B01, B02}, {B10, B11, B12}, {B20, B21, B22} }; | |
353 | static const int a[NB_COEFFS][NB_COEFFS]={ {A00, A01, A02}, {A10, A11, A12}, {A20, A21, A22} }; |
|
353 | static const int a[NB_COEFFS][NB_COEFFS]={ {A00, A01, A02}, {A10, A11, A12}, {A20, A21, A22} }; | |
354 | static const int b_gain[NB_COEFFS]={GAIN_B0, GAIN_B1, GAIN_B2}; |
|
354 | static const int b_gain[NB_COEFFS]={GAIN_B0, GAIN_B1, GAIN_B2}; | |
355 | static const int a_gain[NB_COEFFS]={GAIN_A0, GAIN_A1, GAIN_A2}; |
|
355 | static const int a_gain[NB_COEFFS]={GAIN_A0, GAIN_A1, GAIN_A2}; | |
356 |
|
356 | |||
357 | int_fast32_t W; |
|
357 | int_fast32_t W; | |
358 | int i; |
|
358 | int i; | |
359 |
|
359 | |||
360 | W = INIT_INT; |
|
360 | W = INIT_INT; | |
361 | i = INIT_INT; |
|
361 | i = INIT_INT; | |
362 |
|
362 | |||
363 | //Direct-Form-II |
|
363 | //Direct-Form-II | |
364 | for ( i = 0; i < NB_COEFFS; i++ ) |
|
364 | for ( i = 0; i < NB_COEFFS; i++ ) | |
365 | { |
|
365 | { | |
366 | x = x << a_gain[i]; |
|
366 | x = x << a_gain[i]; | |
367 | W = (x - ( a[i][COEFF1] * ctx->W[i][COEFF0] ) |
|
367 | W = (x - ( a[i][COEFF1] * ctx->W[i][COEFF0] ) | |
368 | - ( a[i][COEFF2] * ctx->W[i][COEFF1] ) ) >> a_gain[i]; |
|
368 | - ( a[i][COEFF2] * ctx->W[i][COEFF1] ) ) >> a_gain[i]; | |
369 | x = ( b[i][COEFF0] * W ) |
|
369 | x = ( b[i][COEFF0] * W ) | |
370 | + ( b[i][COEFF1] * ctx->W[i][COEFF0] ) |
|
370 | + ( b[i][COEFF1] * ctx->W[i][COEFF0] ) | |
371 | + ( b[i][COEFF2] * ctx->W[i][COEFF1] ); |
|
371 | + ( b[i][COEFF2] * ctx->W[i][COEFF1] ); | |
372 | x = x >> b_gain[i]; |
|
372 | x = x >> b_gain[i]; | |
373 | ctx->W[i][1] = ctx->W[i][0]; |
|
373 | ctx->W[i][1] = ctx->W[i][0]; | |
374 | ctx->W[i][0] = W; |
|
374 | ctx->W[i][0] = W; | |
375 | } |
|
375 | } | |
376 | return x; |
|
376 | return x; | |
377 | } |
|
377 | } | |
378 |
|
378 | |||
379 | rtems_task avgv_task(rtems_task_argument argument) |
|
379 | rtems_task avgv_task(rtems_task_argument argument) | |
380 | { |
|
380 | { | |
381 | #define MOVING_AVERAGE 16 |
|
381 | #define MOVING_AVERAGE 16 | |
382 | rtems_status_code status; |
|
382 | rtems_status_code status; | |
383 | static int32_t v[MOVING_AVERAGE] = {0}; |
|
383 | static int32_t v[MOVING_AVERAGE] = {0}; | |
384 | static int32_t e1[MOVING_AVERAGE] = {0}; |
|
384 | static int32_t e1[MOVING_AVERAGE] = {0}; | |
385 | static int32_t e2[MOVING_AVERAGE] = {0}; |
|
385 | static int32_t e2[MOVING_AVERAGE] = {0}; | |
386 | static int old_v = 0; |
|
386 | static int old_v = 0; | |
387 | static int old_e1 = 0; |
|
387 | static int old_e1 = 0; | |
388 | static int old_e2 = 0; |
|
388 | static int old_e2 = 0; | |
389 | int32_t current_v; |
|
389 | int32_t current_v; | |
390 | int32_t current_e1; |
|
390 | int32_t current_e1; | |
391 | int32_t current_e2; |
|
391 | int32_t current_e2; | |
392 | int32_t average_v; |
|
392 | int32_t average_v; | |
393 | int32_t average_e1; |
|
393 | int32_t average_e1; | |
394 | int32_t average_e2; |
|
394 | int32_t average_e2; | |
395 | int32_t newValue_v; |
|
395 | int32_t newValue_v; | |
396 | int32_t newValue_e1; |
|
396 | int32_t newValue_e1; | |
397 | int32_t newValue_e2; |
|
397 | int32_t newValue_e2; | |
398 | unsigned char k; |
|
398 | unsigned char k; | |
399 | unsigned char indexOfOldValue; |
|
399 | unsigned char indexOfOldValue; | |
400 |
|
400 | |||
401 | static filter_ctx ctx_v = { { {0,0,0}, {0,0,0}, {0,0,0} } }; |
|
401 | static filter_ctx ctx_v = { { {0,0,0}, {0,0,0}, {0,0,0} } }; | |
402 | static filter_ctx ctx_e1 = { { {0,0,0}, {0,0,0}, {0,0,0} } }; |
|
402 | static filter_ctx ctx_e1 = { { {0,0,0}, {0,0,0}, {0,0,0} } }; | |
403 | static filter_ctx ctx_e2 = { { {0,0,0}, {0,0,0}, {0,0,0} } }; |
|
403 | static filter_ctx ctx_e2 = { { {0,0,0}, {0,0,0}, {0,0,0} } }; | |
404 |
|
404 | |||
405 | BOOT_PRINTF("in AVGV ***\n"); |
|
405 | BOOT_PRINTF("in AVGV ***\n"); | |
406 |
|
406 | |||
407 | if (rtems_rate_monotonic_ident( name_avgv_rate_monotonic, &AVGV_id) != RTEMS_SUCCESSFUL) { |
|
407 | if (rtems_rate_monotonic_ident( name_avgv_rate_monotonic, &AVGV_id) != RTEMS_SUCCESSFUL) { | |
408 | status = rtems_rate_monotonic_create( name_avgv_rate_monotonic, &AVGV_id ); |
|
408 | status = rtems_rate_monotonic_create( name_avgv_rate_monotonic, &AVGV_id ); | |
409 | if( status != RTEMS_SUCCESSFUL ) { |
|
409 | if( status != RTEMS_SUCCESSFUL ) { | |
410 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ); |
|
410 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ); | |
411 | } |
|
411 | } | |
412 | } |
|
412 | } | |
413 |
|
413 | |||
414 | status = rtems_rate_monotonic_cancel(AVGV_id); |
|
414 | status = rtems_rate_monotonic_cancel(AVGV_id); | |
415 | if( status != RTEMS_SUCCESSFUL ) { |
|
415 | if( status != RTEMS_SUCCESSFUL ) { | |
416 | PRINTF1( "ERR *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id) ***code: %d\n", status ); |
|
416 | PRINTF1( "ERR *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id) ***code: %d\n", status ); | |
417 | } |
|
417 | } | |
418 | else { |
|
418 | else { | |
419 | DEBUG_PRINTF("OK *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id)\n"); |
|
419 | DEBUG_PRINTF("OK *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id)\n"); | |
420 | } |
|
420 | } | |
421 |
|
421 | |||
422 | // initialize values |
|
422 | // initialize values | |
423 | indexOfOldValue = MOVING_AVERAGE - 1; |
|
423 | indexOfOldValue = MOVING_AVERAGE - 1; | |
424 | current_v = 0; |
|
424 | current_v = 0; | |
425 | current_e1 = 0; |
|
425 | current_e1 = 0; | |
426 | current_e2 = 0; |
|
426 | current_e2 = 0; | |
427 | average_v = 0; |
|
427 | average_v = 0; | |
428 | average_e1 = 0; |
|
428 | average_e1 = 0; | |
429 | average_e2 = 0; |
|
429 | average_e2 = 0; | |
430 | newValue_v = 0; |
|
430 | newValue_v = 0; | |
431 | newValue_e1 = 0; |
|
431 | newValue_e1 = 0; | |
432 | newValue_e2 = 0; |
|
432 | newValue_e2 = 0; | |
433 |
|
433 | |||
434 | k = INIT_CHAR; |
|
434 | k = INIT_CHAR; | |
435 |
|
435 | |||
436 | while(1) |
|
436 | while(1) | |
437 | { // launch the rate monotonic task |
|
437 | { // launch the rate monotonic task | |
438 | status = rtems_rate_monotonic_period( AVGV_id, AVGV_PERIOD ); |
|
438 | status = rtems_rate_monotonic_period( AVGV_id, AVGV_PERIOD ); | |
439 | if ( status != RTEMS_SUCCESSFUL ) |
|
439 | if ( status != RTEMS_SUCCESSFUL ) | |
440 | { |
|
440 | { | |
441 | PRINTF1( "in AVGV *** ERR period: %d\n", status); |
|
441 | PRINTF1( "in AVGV *** ERR period: %d\n", status); | |
442 | } |
|
442 | } | |
443 | else |
|
443 | else | |
444 | { |
|
444 | { | |
445 | current_v = waveform_picker_regs->v; |
|
445 | current_v = waveform_picker_regs->v; | |
446 | current_e1 = waveform_picker_regs->e1; |
|
446 | current_e1 = waveform_picker_regs->e1; | |
447 | current_e2 = waveform_picker_regs->e2; |
|
447 | current_e2 = waveform_picker_regs->e2; | |
448 | if ( (current_v != old_v) |
|
448 | if ( (current_v != old_v) | |
449 | || (current_e1 != old_e1) |
|
449 | || (current_e1 != old_e1) | |
450 | || (current_e2 != old_e2)) |
|
450 | || (current_e2 != old_e2)) | |
451 | { |
|
451 | { | |
452 | average_v = filter( current_v, &ctx_v ); |
|
452 | average_v = filter( current_v, &ctx_v ); | |
453 | average_e1 = filter( current_e1, &ctx_e1 ); |
|
453 | average_e1 = filter( current_e1, &ctx_e1 ); | |
454 | average_e2 = filter( current_e2, &ctx_e2 ); |
|
454 | average_e2 = filter( current_e2, &ctx_e2 ); | |
455 |
|
455 | |||
456 | //update int16 values |
|
456 | //update int16 values | |
457 | hk_lfr_sc_v_f3_as_int16 = (int16_t) average_v; |
|
457 | hk_lfr_sc_v_f3_as_int16 = (int16_t) average_v; | |
458 | hk_lfr_sc_e1_f3_as_int16 = (int16_t) average_e1; |
|
458 | hk_lfr_sc_e1_f3_as_int16 = (int16_t) average_e1; | |
459 | hk_lfr_sc_e2_f3_as_int16 = (int16_t) average_e2; |
|
459 | hk_lfr_sc_e2_f3_as_int16 = (int16_t) average_e2; | |
460 | } |
|
460 | } | |
461 | old_v = current_v; |
|
461 | old_v = current_v; | |
462 | old_e1 = current_e1; |
|
462 | old_e1 = current_e1; | |
463 | old_e2 = current_e2; |
|
463 | old_e2 = current_e2; | |
464 | } |
|
464 | } | |
465 | } |
|
465 | } | |
466 |
|
466 | |||
467 | PRINTF("in AVGV *** deleting task\n"); |
|
467 | PRINTF("in AVGV *** deleting task\n"); | |
468 |
|
468 | |||
469 | status = rtems_task_delete( RTEMS_SELF ); // should not return |
|
469 | status = rtems_task_delete( RTEMS_SELF ); // should not return | |
470 |
|
470 | |||
471 | return; |
|
471 | return; | |
472 | } |
|
472 | } | |
473 |
|
473 | |||
474 | rtems_task dumb_task( rtems_task_argument unused ) |
|
474 | rtems_task dumb_task( rtems_task_argument unused ) | |
475 | { |
|
475 | { | |
476 | /** This RTEMS taks is used to print messages without affecting the general behaviour of the software. |
|
476 | /** This RTEMS taks is used to print messages without affecting the general behaviour of the software. | |
477 | * |
|
477 | * | |
478 | * @param unused is the starting argument of the RTEMS task |
|
478 | * @param unused is the starting argument of the RTEMS task | |
479 | * |
|
479 | * | |
480 | * The DUMB taks waits for RTEMS events and print messages depending on the incoming events. |
|
480 | * The DUMB taks waits for RTEMS events and print messages depending on the incoming events. | |
481 | * |
|
481 | * | |
482 | */ |
|
482 | */ | |
483 |
|
483 | |||
484 | unsigned int i; |
|
484 | unsigned int i; | |
485 | unsigned int intEventOut; |
|
485 | unsigned int intEventOut; | |
486 | unsigned int coarse_time = 0; |
|
486 | unsigned int coarse_time = 0; | |
487 | unsigned int fine_time = 0; |
|
487 | unsigned int fine_time = 0; | |
488 | rtems_event_set event_out; |
|
488 | rtems_event_set event_out; | |
489 |
|
489 | |||
490 | event_out = EVENT_SETS_NONE_PENDING; |
|
490 | event_out = EVENT_SETS_NONE_PENDING; | |
491 |
|
491 | |||
492 | BOOT_PRINTF("in DUMB *** \n") |
|
492 | BOOT_PRINTF("in DUMB *** \n") | |
493 |
|
493 | |||
494 | while(1){ |
|
494 | while(1){ | |
495 | rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 |
|
495 | rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | |
496 | | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7 |
|
496 | | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7 | |
497 | | RTEMS_EVENT_8 | RTEMS_EVENT_9 | RTEMS_EVENT_12 | RTEMS_EVENT_13 |
|
497 | | RTEMS_EVENT_8 | RTEMS_EVENT_9 | RTEMS_EVENT_12 | RTEMS_EVENT_13 | |
498 | | RTEMS_EVENT_14, |
|
498 | | RTEMS_EVENT_14, | |
499 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT |
|
499 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT | |
500 | intEventOut = (unsigned int) event_out; |
|
500 | intEventOut = (unsigned int) event_out; | |
501 | for ( i=0; i<NB_RTEMS_EVENTS; i++) |
|
501 | for ( i=0; i<NB_RTEMS_EVENTS; i++) | |
502 | { |
|
502 | { | |
503 | if ( ((intEventOut >> i) & 1) != 0) |
|
503 | if ( ((intEventOut >> i) & 1) != 0) | |
504 | { |
|
504 | { | |
505 | coarse_time = time_management_regs->coarse_time; |
|
505 | coarse_time = time_management_regs->coarse_time; | |
506 | fine_time = time_management_regs->fine_time; |
|
506 | fine_time = time_management_regs->fine_time; | |
507 | if (i==EVENT_12) |
|
507 | if (i==EVENT_12) | |
508 | { |
|
508 | { | |
509 | PRINTF1("%s\n", DUMB_MESSAGE_12) |
|
509 | PRINTF1("%s\n", DUMB_MESSAGE_12) | |
510 | } |
|
510 | } | |
511 | if (i==EVENT_13) |
|
511 | if (i==EVENT_13) | |
512 | { |
|
512 | { | |
513 | PRINTF1("%s\n", DUMB_MESSAGE_13) |
|
513 | PRINTF1("%s\n", DUMB_MESSAGE_13) | |
514 | } |
|
514 | } | |
515 | if (i==EVENT_14) |
|
515 | if (i==EVENT_14) | |
516 | { |
|
516 | { | |
517 | PRINTF1("%s\n", DUMB_MESSAGE_1) |
|
517 | PRINTF1("%s\n", DUMB_MESSAGE_1) | |
518 | } |
|
518 | } | |
519 | } |
|
519 | } | |
520 | } |
|
520 | } | |
521 | } |
|
521 | } | |
522 | } |
|
522 | } | |
523 |
|
523 | |||
524 | rtems_task scrubbing_task( rtems_task_argument unused ) |
|
524 | rtems_task scrubbing_task( rtems_task_argument unused ) | |
525 | { |
|
525 | { | |
526 | /** This RTEMS taks is to avoid entering IDLE task and also scrub memory to increase scubbing frequency. |
|
526 | /** This RTEMS taks is used to avoid entering IDLE task and also scrub memory to increase scubbing frequency. | |
527 | * |
|
527 | * | |
528 | * @param unused is the starting argument of the RTEMS task |
|
528 | * @param unused is the starting argument of the RTEMS task | |
529 | * |
|
529 | * | |
530 | * The scrubbing reads continuously memory when no other tasks are ready. |
|
530 | * The scrubbing reads continuously memory when no other tasks are ready. | |
531 | * |
|
531 | * | |
532 | */ |
|
532 | */ | |
533 |
|
533 | |||
534 | BOOT_PRINTF("in SCRUBBING *** \n"); |
|
534 | BOOT_PRINTF("in SCRUBBING *** \n"); | |
535 | volatile int i=0; |
|
535 | volatile int i=0; | |
536 | volatile float valuef = 1.; |
|
536 | volatile float valuef = 1.; | |
537 | volatile uint32_t* RAM=(uint32_t*)0x40000000; |
|
537 | volatile uint32_t* RAM=(uint32_t*)0x40000000; | |
538 | volatile uint32_t value; |
|
538 | volatile uint32_t value; | |
539 | while(1){ |
|
539 | while(1){ | |
540 | i=(i+1)%(1024*1024); |
|
540 | i=(i+1)%(1024*1024); | |
541 | valuef += 10.f*(float)RAM[i]; |
|
541 | valuef += 10.f*(float)RAM[i]; | |
542 | } |
|
542 | } | |
543 | } |
|
543 | } | |
544 |
|
544 | |||
|
545 | rtems_task calibration_sweep_task( rtems_task_argument unused ) | |||
|
546 | { | |||
|
547 | /** This RTEMS taks is used to change calibration signal smapling frequency between snapshots. | |||
|
548 | * | |||
|
549 | * @param unused is the starting argument of the RTEMS task | |||
|
550 | * | |||
|
551 | * If calibration is enabled, this task will divide by two the calibration signal smapling frequency between snapshots. | |||
|
552 | * When minimum sampling frequency is reach it will jump to maximum sampling frequency to loop indefinitely. | |||
|
553 | * | |||
|
554 | */ | |||
|
555 | rtems_event_set event_out; | |||
|
556 | BOOT_PRINTF("in calibration sweep *** \n"); | |||
|
557 | rtems_interval ticks_per_seconds = rtems_clock_get_ticks_per_second(); | |||
|
558 | while(1){ | |||
|
559 | // Waiting for next F0 snapshot | |||
|
560 | rtems_event_receive(RTEMS_EVENT_CAL_SWEEP_WAKE, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); | |||
|
561 | if(time_management_regs->calDACCtrl & BIT_CAL_ENABLE) | |||
|
562 | { | |||
|
563 | unsigned int delta_snapshot; | |||
|
564 | delta_snapshot = (parameter_dump_packet.sy_lfr_n_swf_p[0] * CONST_256) | |||
|
565 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; | |||
|
566 | // We are woken almost in the center of a snapshot -> let's wait for sy_lfr_n_swf_p / 2 | |||
|
567 | rtems_task_wake_after( ticks_per_seconds * delta_snapshot / 2); | |||
|
568 | if(time_management_regs->calDivisor >= CAL_F_DIVISOR_MAX){ | |||
|
569 | time_management_regs->calDivisor = CAL_F_DIVISOR_MIN; | |||
|
570 | } | |||
|
571 | else{ | |||
|
572 | time_management_regs->calDivisor *= 2; | |||
|
573 | } | |||
|
574 | } | |||
|
575 | ||||
|
576 | ||||
|
577 | ||||
|
578 | } | |||
|
579 | ||||
|
580 | } | |||
|
581 | ||||
|
582 | ||||
545 | //***************************** |
|
583 | //***************************** | |
546 | // init housekeeping parameters |
|
584 | // init housekeeping parameters | |
547 |
|
585 | |||
548 | void init_housekeeping_parameters( void ) |
|
586 | void init_housekeeping_parameters( void ) | |
549 | { |
|
587 | { | |
550 | /** This function initialize the housekeeping_packet global variable with default values. |
|
588 | /** This function initialize the housekeeping_packet global variable with default values. | |
551 | * |
|
589 | * | |
552 | */ |
|
590 | */ | |
553 |
|
591 | |||
554 | unsigned int i = 0; |
|
592 | unsigned int i = 0; | |
555 | unsigned char *parameters; |
|
593 | unsigned char *parameters; | |
556 | unsigned char sizeOfHK; |
|
594 | unsigned char sizeOfHK; | |
557 |
|
595 | |||
558 | sizeOfHK = sizeof( Packet_TM_LFR_HK_t ); |
|
596 | sizeOfHK = sizeof( Packet_TM_LFR_HK_t ); | |
559 |
|
597 | |||
560 | parameters = (unsigned char*) &housekeeping_packet; |
|
598 | parameters = (unsigned char*) &housekeeping_packet; | |
561 |
|
599 | |||
562 | for(i = 0; i< sizeOfHK; i++) |
|
600 | for(i = 0; i< sizeOfHK; i++) | |
563 | { |
|
601 | { | |
564 | parameters[i] = INIT_CHAR; |
|
602 | parameters[i] = INIT_CHAR; | |
565 | } |
|
603 | } | |
566 |
|
604 | |||
567 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
605 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
568 | housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
606 | housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
569 | housekeeping_packet.reserved = DEFAULT_RESERVED; |
|
607 | housekeeping_packet.reserved = DEFAULT_RESERVED; | |
570 | housekeeping_packet.userApplication = CCSDS_USER_APP; |
|
608 | housekeeping_packet.userApplication = CCSDS_USER_APP; | |
571 | housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> SHIFT_1_BYTE); |
|
609 | housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> SHIFT_1_BYTE); | |
572 | housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK); |
|
610 | housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK); | |
573 | housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
611 | housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
574 | housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
612 | housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
575 | housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> SHIFT_1_BYTE); |
|
613 | housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> SHIFT_1_BYTE); | |
576 | housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); |
|
614 | housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); | |
577 | housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
615 | housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
578 | housekeeping_packet.serviceType = TM_TYPE_HK; |
|
616 | housekeeping_packet.serviceType = TM_TYPE_HK; | |
579 | housekeeping_packet.serviceSubType = TM_SUBTYPE_HK; |
|
617 | housekeeping_packet.serviceSubType = TM_SUBTYPE_HK; | |
580 | housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
618 | housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
581 | housekeeping_packet.sid = SID_HK; |
|
619 | housekeeping_packet.sid = SID_HK; | |
582 |
|
620 | |||
583 | // init status word |
|
621 | // init status word | |
584 | housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0; |
|
622 | housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0; | |
585 | housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1; |
|
623 | housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1; | |
586 | // init software version |
|
624 | // init software version | |
587 | housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; |
|
625 | housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; | |
588 | housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; |
|
626 | housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; | |
589 | housekeeping_packet.lfr_sw_version[BYTE_2] = SW_VERSION_N3; |
|
627 | housekeeping_packet.lfr_sw_version[BYTE_2] = SW_VERSION_N3; | |
590 | housekeeping_packet.lfr_sw_version[BYTE_3] = SW_VERSION_N4; |
|
628 | housekeeping_packet.lfr_sw_version[BYTE_3] = SW_VERSION_N4; | |
591 | // init fpga version |
|
629 | // init fpga version | |
592 | parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION); |
|
630 | parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION); | |
593 | housekeeping_packet.lfr_fpga_version[BYTE_0] = parameters[BYTE_1]; // n1 |
|
631 | housekeeping_packet.lfr_fpga_version[BYTE_0] = parameters[BYTE_1]; // n1 | |
594 | housekeeping_packet.lfr_fpga_version[BYTE_1] = parameters[BYTE_2]; // n2 |
|
632 | housekeeping_packet.lfr_fpga_version[BYTE_1] = parameters[BYTE_2]; // n2 | |
595 | housekeeping_packet.lfr_fpga_version[BYTE_2] = parameters[BYTE_3]; // n3 |
|
633 | housekeeping_packet.lfr_fpga_version[BYTE_2] = parameters[BYTE_3]; // n3 | |
596 |
|
634 | |||
597 | housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND; |
|
635 | housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND; | |
598 | housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV; |
|
636 | housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV; | |
599 | housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0; |
|
637 | housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0; | |
600 | housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1; |
|
638 | housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1; | |
601 | housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2; |
|
639 | housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2; | |
602 | } |
|
640 | } | |
603 |
|
641 | |||
604 | void increment_seq_counter( unsigned short *packetSequenceControl ) |
|
642 | void increment_seq_counter( unsigned short *packetSequenceControl ) | |
605 | { |
|
643 | { | |
606 | /** This function increment the sequence counter passes in argument. |
|
644 | /** This function increment the sequence counter passes in argument. | |
607 | * |
|
645 | * | |
608 | * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0. |
|
646 | * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0. | |
609 | * |
|
647 | * | |
610 | */ |
|
648 | */ | |
611 |
|
649 | |||
612 | unsigned short segmentation_grouping_flag; |
|
650 | unsigned short segmentation_grouping_flag; | |
613 | unsigned short sequence_cnt; |
|
651 | unsigned short sequence_cnt; | |
614 |
|
652 | |||
615 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE; // keep bits 7 downto 6 |
|
653 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE; // keep bits 7 downto 6 | |
616 | sequence_cnt = (*packetSequenceControl) & SEQ_CNT_MASK; // [0011 1111 1111 1111] |
|
654 | sequence_cnt = (*packetSequenceControl) & SEQ_CNT_MASK; // [0011 1111 1111 1111] | |
617 |
|
655 | |||
618 | if ( sequence_cnt < SEQ_CNT_MAX) |
|
656 | if ( sequence_cnt < SEQ_CNT_MAX) | |
619 | { |
|
657 | { | |
620 | sequence_cnt = sequence_cnt + 1; |
|
658 | sequence_cnt = sequence_cnt + 1; | |
621 | } |
|
659 | } | |
622 | else |
|
660 | else | |
623 | { |
|
661 | { | |
624 | sequence_cnt = 0; |
|
662 | sequence_cnt = 0; | |
625 | } |
|
663 | } | |
626 |
|
664 | |||
627 | *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ; |
|
665 | *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ; | |
628 | } |
|
666 | } | |
629 |
|
667 | |||
630 | void getTime( unsigned char *time) |
|
668 | void getTime( unsigned char *time) | |
631 | { |
|
669 | { | |
632 | /** This function write the current local time in the time buffer passed in argument. |
|
670 | /** This function write the current local time in the time buffer passed in argument. | |
633 | * |
|
671 | * | |
634 | */ |
|
672 | */ | |
635 |
|
673 | |||
636 | time[0] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_3_BYTES); |
|
674 | time[0] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_3_BYTES); | |
637 | time[1] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_2_BYTES); |
|
675 | time[1] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_2_BYTES); | |
638 | time[2] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_1_BYTE); |
|
676 | time[2] = (unsigned char) (time_management_regs->coarse_time>>SHIFT_1_BYTE); | |
639 | time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
677 | time[3] = (unsigned char) (time_management_regs->coarse_time); | |
640 | time[4] = (unsigned char) (time_management_regs->fine_time>>SHIFT_1_BYTE); |
|
678 | time[4] = (unsigned char) (time_management_regs->fine_time>>SHIFT_1_BYTE); | |
641 | time[5] = (unsigned char) (time_management_regs->fine_time); |
|
679 | time[5] = (unsigned char) (time_management_regs->fine_time); | |
642 | } |
|
680 | } | |
643 |
|
681 | |||
644 | unsigned long long int getTimeAsUnsignedLongLongInt( ) |
|
682 | unsigned long long int getTimeAsUnsignedLongLongInt( ) | |
645 | { |
|
683 | { | |
646 | /** This function write the current local time in the time buffer passed in argument. |
|
684 | /** This function write the current local time in the time buffer passed in argument. | |
647 | * |
|
685 | * | |
648 | */ |
|
686 | */ | |
649 | unsigned long long int time; |
|
687 | unsigned long long int time; | |
650 |
|
688 | |||
651 | time = ( (unsigned long long int) (time_management_regs->coarse_time & COARSE_TIME_MASK) << SHIFT_2_BYTES ) |
|
689 | time = ( (unsigned long long int) (time_management_regs->coarse_time & COARSE_TIME_MASK) << SHIFT_2_BYTES ) | |
652 | + time_management_regs->fine_time; |
|
690 | + time_management_regs->fine_time; | |
653 |
|
691 | |||
654 | return time; |
|
692 | return time; | |
655 | } |
|
693 | } | |
656 |
|
694 | |||
657 | void send_dumb_hk( void ) |
|
695 | void send_dumb_hk( void ) | |
658 | { |
|
696 | { | |
659 | Packet_TM_LFR_HK_t dummy_hk_packet; |
|
697 | Packet_TM_LFR_HK_t dummy_hk_packet; | |
660 | unsigned char *parameters; |
|
698 | unsigned char *parameters; | |
661 | unsigned int i; |
|
699 | unsigned int i; | |
662 | rtems_id queue_id; |
|
700 | rtems_id queue_id; | |
663 |
|
701 | |||
664 | queue_id = RTEMS_ID_NONE; |
|
702 | queue_id = RTEMS_ID_NONE; | |
665 |
|
703 | |||
666 | dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
704 | dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
667 | dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
705 | dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
668 | dummy_hk_packet.reserved = DEFAULT_RESERVED; |
|
706 | dummy_hk_packet.reserved = DEFAULT_RESERVED; | |
669 | dummy_hk_packet.userApplication = CCSDS_USER_APP; |
|
707 | dummy_hk_packet.userApplication = CCSDS_USER_APP; | |
670 | dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> SHIFT_1_BYTE); |
|
708 | dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> SHIFT_1_BYTE); | |
671 | dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK); |
|
709 | dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK); | |
672 | dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
710 | dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
673 | dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
711 | dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
674 | dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> SHIFT_1_BYTE); |
|
712 | dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> SHIFT_1_BYTE); | |
675 | dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); |
|
713 | dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); | |
676 | dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
714 | dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
677 | dummy_hk_packet.serviceType = TM_TYPE_HK; |
|
715 | dummy_hk_packet.serviceType = TM_TYPE_HK; | |
678 | dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK; |
|
716 | dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK; | |
679 | dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
717 | dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
680 | dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); |
|
718 | dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_3_BYTES); | |
681 | dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); |
|
719 | dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_2_BYTES); | |
682 | dummy_hk_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); |
|
720 | dummy_hk_packet.time[BYTE_2] = (unsigned char) (time_management_regs->coarse_time >> SHIFT_1_BYTE); | |
683 | dummy_hk_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); |
|
721 | dummy_hk_packet.time[BYTE_3] = (unsigned char) (time_management_regs->coarse_time); | |
684 | dummy_hk_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); |
|
722 | dummy_hk_packet.time[BYTE_4] = (unsigned char) (time_management_regs->fine_time >> SHIFT_1_BYTE); | |
685 | dummy_hk_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); |
|
723 | dummy_hk_packet.time[BYTE_5] = (unsigned char) (time_management_regs->fine_time); | |
686 | dummy_hk_packet.sid = SID_HK; |
|
724 | dummy_hk_packet.sid = SID_HK; | |
687 |
|
725 | |||
688 | // init status word |
|
726 | // init status word | |
689 | dummy_hk_packet.lfr_status_word[0] = INT8_ALL_F; |
|
727 | dummy_hk_packet.lfr_status_word[0] = INT8_ALL_F; | |
690 | dummy_hk_packet.lfr_status_word[1] = INT8_ALL_F; |
|
728 | dummy_hk_packet.lfr_status_word[1] = INT8_ALL_F; | |
691 | // init software version |
|
729 | // init software version | |
692 | dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1; |
|
730 | dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1; | |
693 | dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2; |
|
731 | dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2; | |
694 | dummy_hk_packet.lfr_sw_version[BYTE_2] = SW_VERSION_N3; |
|
732 | dummy_hk_packet.lfr_sw_version[BYTE_2] = SW_VERSION_N3; | |
695 | dummy_hk_packet.lfr_sw_version[BYTE_3] = SW_VERSION_N4; |
|
733 | dummy_hk_packet.lfr_sw_version[BYTE_3] = SW_VERSION_N4; | |
696 | // init fpga version |
|
734 | // init fpga version | |
697 | parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + APB_OFFSET_VHDL_REV); |
|
735 | parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + APB_OFFSET_VHDL_REV); | |
698 | dummy_hk_packet.lfr_fpga_version[BYTE_0] = parameters[BYTE_1]; // n1 |
|
736 | dummy_hk_packet.lfr_fpga_version[BYTE_0] = parameters[BYTE_1]; // n1 | |
699 | dummy_hk_packet.lfr_fpga_version[BYTE_1] = parameters[BYTE_2]; // n2 |
|
737 | dummy_hk_packet.lfr_fpga_version[BYTE_1] = parameters[BYTE_2]; // n2 | |
700 | dummy_hk_packet.lfr_fpga_version[BYTE_2] = parameters[BYTE_3]; // n3 |
|
738 | dummy_hk_packet.lfr_fpga_version[BYTE_2] = parameters[BYTE_3]; // n3 | |
701 |
|
739 | |||
702 | parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load; |
|
740 | parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load; | |
703 |
|
741 | |||
704 | for (i=0; i<(BYTE_POS_HK_REACTION_WHEELS_FREQUENCY - BYTE_POS_HK_LFR_CPU_LOAD); i++) |
|
742 | for (i=0; i<(BYTE_POS_HK_REACTION_WHEELS_FREQUENCY - BYTE_POS_HK_LFR_CPU_LOAD); i++) | |
705 | { |
|
743 | { | |
706 | parameters[i] = INT8_ALL_F; |
|
744 | parameters[i] = INT8_ALL_F; | |
707 | } |
|
745 | } | |
708 |
|
746 | |||
709 | get_message_queue_id_send( &queue_id ); |
|
747 | get_message_queue_id_send( &queue_id ); | |
710 |
|
748 | |||
711 | rtems_message_queue_send( queue_id, &dummy_hk_packet, |
|
749 | rtems_message_queue_send( queue_id, &dummy_hk_packet, | |
712 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
750 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
713 | } |
|
751 | } | |
714 |
|
752 | |||
715 | void get_temperatures( unsigned char *temperatures ) |
|
753 | void get_temperatures( unsigned char *temperatures ) | |
716 | { |
|
754 | { | |
717 | unsigned char* temp_scm_ptr; |
|
755 | unsigned char* temp_scm_ptr; | |
718 | unsigned char* temp_pcb_ptr; |
|
756 | unsigned char* temp_pcb_ptr; | |
719 | unsigned char* temp_fpga_ptr; |
|
757 | unsigned char* temp_fpga_ptr; | |
720 |
|
758 | |||
721 | // SEL1 SEL0 |
|
759 | // SEL1 SEL0 | |
722 | // 0 0 => PCB |
|
760 | // 0 0 => PCB | |
723 | // 0 1 => FPGA |
|
761 | // 0 1 => FPGA | |
724 | // 1 0 => SCM |
|
762 | // 1 0 => SCM | |
725 |
|
763 | |||
726 | temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm; |
|
764 | temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm; | |
727 | temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb; |
|
765 | temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb; | |
728 | temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga; |
|
766 | temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga; | |
729 |
|
767 | |||
730 | temperatures[ BYTE_0 ] = temp_scm_ptr[ BYTE_2 ]; |
|
768 | temperatures[ BYTE_0 ] = temp_scm_ptr[ BYTE_2 ]; | |
731 | temperatures[ BYTE_1 ] = temp_scm_ptr[ BYTE_3 ]; |
|
769 | temperatures[ BYTE_1 ] = temp_scm_ptr[ BYTE_3 ]; | |
732 | temperatures[ BYTE_2 ] = temp_pcb_ptr[ BYTE_2 ]; |
|
770 | temperatures[ BYTE_2 ] = temp_pcb_ptr[ BYTE_2 ]; | |
733 | temperatures[ BYTE_3 ] = temp_pcb_ptr[ BYTE_3 ]; |
|
771 | temperatures[ BYTE_3 ] = temp_pcb_ptr[ BYTE_3 ]; | |
734 | temperatures[ BYTE_4 ] = temp_fpga_ptr[ BYTE_2 ]; |
|
772 | temperatures[ BYTE_4 ] = temp_fpga_ptr[ BYTE_2 ]; | |
735 | temperatures[ BYTE_5 ] = temp_fpga_ptr[ BYTE_3 ]; |
|
773 | temperatures[ BYTE_5 ] = temp_fpga_ptr[ BYTE_3 ]; | |
736 | } |
|
774 | } | |
737 |
|
775 | |||
738 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ) |
|
776 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ) | |
739 | { |
|
777 | { | |
740 | unsigned char* v_ptr; |
|
778 | unsigned char* v_ptr; | |
741 | unsigned char* e1_ptr; |
|
779 | unsigned char* e1_ptr; | |
742 | unsigned char* e2_ptr; |
|
780 | unsigned char* e2_ptr; | |
743 |
|
781 | |||
744 | v_ptr = (unsigned char *) &hk_lfr_sc_v_f3_as_int16; |
|
782 | v_ptr = (unsigned char *) &hk_lfr_sc_v_f3_as_int16; | |
745 | e1_ptr = (unsigned char *) &hk_lfr_sc_e1_f3_as_int16; |
|
783 | e1_ptr = (unsigned char *) &hk_lfr_sc_e1_f3_as_int16; | |
746 | e2_ptr = (unsigned char *) &hk_lfr_sc_e2_f3_as_int16; |
|
784 | e2_ptr = (unsigned char *) &hk_lfr_sc_e2_f3_as_int16; | |
747 |
|
785 | |||
748 | spacecraft_potential[BYTE_0] = v_ptr[0]; |
|
786 | spacecraft_potential[BYTE_0] = v_ptr[0]; | |
749 | spacecraft_potential[BYTE_1] = v_ptr[1]; |
|
787 | spacecraft_potential[BYTE_1] = v_ptr[1]; | |
750 | spacecraft_potential[BYTE_2] = e1_ptr[0]; |
|
788 | spacecraft_potential[BYTE_2] = e1_ptr[0]; | |
751 | spacecraft_potential[BYTE_3] = e1_ptr[1]; |
|
789 | spacecraft_potential[BYTE_3] = e1_ptr[1]; | |
752 | spacecraft_potential[BYTE_4] = e2_ptr[0]; |
|
790 | spacecraft_potential[BYTE_4] = e2_ptr[0]; | |
753 | spacecraft_potential[BYTE_5] = e2_ptr[1]; |
|
791 | spacecraft_potential[BYTE_5] = e2_ptr[1]; | |
754 | } |
|
792 | } | |
755 |
|
793 | |||
756 | void get_cpu_load( unsigned char *resource_statistics ) |
|
794 | void get_cpu_load( unsigned char *resource_statistics ) | |
757 | { |
|
795 | { | |
758 | unsigned char cpu_load; |
|
796 | unsigned char cpu_load; | |
759 |
|
797 | |||
760 | cpu_load = lfr_rtems_cpu_usage_report(); |
|
798 | cpu_load = lfr_rtems_cpu_usage_report(); | |
761 |
|
799 | |||
762 | // HK_LFR_CPU_LOAD |
|
800 | // HK_LFR_CPU_LOAD | |
763 | resource_statistics[0] = cpu_load; |
|
801 | resource_statistics[0] = cpu_load; | |
764 |
|
802 | |||
765 | // HK_LFR_CPU_LOAD_MAX |
|
803 | // HK_LFR_CPU_LOAD_MAX | |
766 | if (cpu_load > resource_statistics[1]) |
|
804 | if (cpu_load > resource_statistics[1]) | |
767 | { |
|
805 | { | |
768 | resource_statistics[1] = cpu_load; |
|
806 | resource_statistics[1] = cpu_load; | |
769 | } |
|
807 | } | |
770 |
|
808 | |||
771 | // CPU_LOAD_AVE |
|
809 | // CPU_LOAD_AVE | |
772 | resource_statistics[BYTE_2] = 0; |
|
810 | resource_statistics[BYTE_2] = 0; | |
773 |
|
811 | |||
774 | #ifndef PRINT_TASK_STATISTICS |
|
812 | #ifndef PRINT_TASK_STATISTICS | |
775 | rtems_cpu_usage_reset(); |
|
813 | rtems_cpu_usage_reset(); | |
776 | #endif |
|
814 | #endif | |
777 |
|
815 | |||
778 | } |
|
816 | } | |
779 |
|
817 | |||
780 | void set_hk_lfr_sc_potential_flag( bool state ) |
|
818 | void set_hk_lfr_sc_potential_flag( bool state ) | |
781 | { |
|
819 | { | |
782 | if (state == true) |
|
820 | if (state == true) | |
783 | { |
|
821 | { | |
784 | housekeeping_packet.lfr_status_word[1] = |
|
822 | housekeeping_packet.lfr_status_word[1] = | |
785 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_SC_POTENTIAL_FLAG_BIT; // [0100 0000] |
|
823 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_SC_POTENTIAL_FLAG_BIT; // [0100 0000] | |
786 | } |
|
824 | } | |
787 | else |
|
825 | else | |
788 | { |
|
826 | { | |
789 | housekeeping_packet.lfr_status_word[1] = |
|
827 | housekeeping_packet.lfr_status_word[1] = | |
790 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_SC_POTENTIAL_FLAG_MASK; // [1011 1111] |
|
828 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_SC_POTENTIAL_FLAG_MASK; // [1011 1111] | |
791 | } |
|
829 | } | |
792 | } |
|
830 | } | |
793 |
|
831 | |||
794 | void set_sy_lfr_pas_filter_enabled( bool state ) |
|
832 | void set_sy_lfr_pas_filter_enabled( bool state ) | |
795 | { |
|
833 | { | |
796 | if (state == true) |
|
834 | if (state == true) | |
797 | { |
|
835 | { | |
798 | housekeeping_packet.lfr_status_word[1] = |
|
836 | housekeeping_packet.lfr_status_word[1] = | |
799 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_PAS_FILTER_ENABLED_BIT; // [0010 0000] |
|
837 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_PAS_FILTER_ENABLED_BIT; // [0010 0000] | |
800 | } |
|
838 | } | |
801 | else |
|
839 | else | |
802 | { |
|
840 | { | |
803 | housekeeping_packet.lfr_status_word[1] = |
|
841 | housekeeping_packet.lfr_status_word[1] = | |
804 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_PAS_FILTER_ENABLED_MASK; // [1101 1111] |
|
842 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_PAS_FILTER_ENABLED_MASK; // [1101 1111] | |
805 | } |
|
843 | } | |
806 | } |
|
844 | } | |
807 |
|
845 | |||
808 | void set_sy_lfr_watchdog_enabled( bool state ) |
|
846 | void set_sy_lfr_watchdog_enabled( bool state ) | |
809 | { |
|
847 | { | |
810 | if (state == true) |
|
848 | if (state == true) | |
811 | { |
|
849 | { | |
812 | housekeeping_packet.lfr_status_word[1] = |
|
850 | housekeeping_packet.lfr_status_word[1] = | |
813 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_WATCHDOG_BIT; // [0001 0000] |
|
851 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_WATCHDOG_BIT; // [0001 0000] | |
814 | } |
|
852 | } | |
815 | else |
|
853 | else | |
816 | { |
|
854 | { | |
817 | housekeeping_packet.lfr_status_word[1] = |
|
855 | housekeeping_packet.lfr_status_word[1] = | |
818 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_WATCHDOG_MASK; // [1110 1111] |
|
856 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_WATCHDOG_MASK; // [1110 1111] | |
819 | } |
|
857 | } | |
820 | } |
|
858 | } | |
821 |
|
859 | |||
822 | void set_hk_lfr_calib_enable( bool state ) |
|
860 | void set_hk_lfr_calib_enable( bool state ) | |
823 | { |
|
861 | { | |
824 | if (state == true) |
|
862 | if (state == true) | |
825 | { |
|
863 | { | |
826 | housekeeping_packet.lfr_status_word[1] = |
|
864 | housekeeping_packet.lfr_status_word[1] = | |
827 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_CALIB_BIT; // [0000 1000] |
|
865 | housekeeping_packet.lfr_status_word[1] | STATUS_WORD_CALIB_BIT; // [0000 1000] | |
828 | } |
|
866 | } | |
829 | else |
|
867 | else | |
830 | { |
|
868 | { | |
831 | housekeeping_packet.lfr_status_word[1] = |
|
869 | housekeeping_packet.lfr_status_word[1] = | |
832 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_CALIB_MASK; // [1111 0111] |
|
870 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_CALIB_MASK; // [1111 0111] | |
833 | } |
|
871 | } | |
834 | } |
|
872 | } | |
835 |
|
873 | |||
836 | void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ) |
|
874 | void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ) | |
837 | { |
|
875 | { | |
838 | housekeeping_packet.lfr_status_word[1] = |
|
876 | housekeeping_packet.lfr_status_word[1] = | |
839 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_RESET_CAUSE_MASK; // [1111 1000] |
|
877 | housekeeping_packet.lfr_status_word[1] & STATUS_WORD_RESET_CAUSE_MASK; // [1111 1000] | |
840 |
|
878 | |||
841 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] |
|
879 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | |
842 | | (lfr_reset_cause & STATUS_WORD_RESET_CAUSE_BITS ); // [0000 0111] |
|
880 | | (lfr_reset_cause & STATUS_WORD_RESET_CAUSE_BITS ); // [0000 0111] | |
843 |
|
881 | |||
844 | } |
|
882 | } | |
845 |
|
883 | |||
846 | void increment_hk_counter( unsigned char newValue, unsigned char oldValue, unsigned int *counter ) |
|
884 | void increment_hk_counter( unsigned char newValue, unsigned char oldValue, unsigned int *counter ) | |
847 | { |
|
885 | { | |
848 | int delta; |
|
886 | int delta; | |
849 |
|
887 | |||
850 | delta = 0; |
|
888 | delta = 0; | |
851 |
|
889 | |||
852 | if (newValue >= oldValue) |
|
890 | if (newValue >= oldValue) | |
853 | { |
|
891 | { | |
854 | delta = newValue - oldValue; |
|
892 | delta = newValue - oldValue; | |
855 | } |
|
893 | } | |
856 | else |
|
894 | else | |
857 | { |
|
895 | { | |
858 | delta = (CONST_256 - oldValue) + newValue; |
|
896 | delta = (CONST_256 - oldValue) + newValue; | |
859 | } |
|
897 | } | |
860 |
|
898 | |||
861 | *counter = *counter + delta; |
|
899 | *counter = *counter + delta; | |
862 | } |
|
900 | } | |
863 |
|
901 | |||
864 | void hk_lfr_le_update( void ) |
|
902 | void hk_lfr_le_update( void ) | |
865 | { |
|
903 | { | |
866 | static hk_lfr_le_t old_hk_lfr_le = {0}; |
|
904 | static hk_lfr_le_t old_hk_lfr_le = {0}; | |
867 | hk_lfr_le_t new_hk_lfr_le; |
|
905 | hk_lfr_le_t new_hk_lfr_le; | |
868 | unsigned int counter; |
|
906 | unsigned int counter; | |
869 |
|
907 | |||
870 | counter = (((unsigned int) housekeeping_packet.hk_lfr_le_cnt[0]) * CONST_256) + housekeeping_packet.hk_lfr_le_cnt[1]; |
|
908 | counter = (((unsigned int) housekeeping_packet.hk_lfr_le_cnt[0]) * CONST_256) + housekeeping_packet.hk_lfr_le_cnt[1]; | |
871 |
|
909 | |||
872 | // DPU |
|
910 | // DPU | |
873 | new_hk_lfr_le.dpu_spw_parity = housekeeping_packet.hk_lfr_dpu_spw_parity; |
|
911 | new_hk_lfr_le.dpu_spw_parity = housekeeping_packet.hk_lfr_dpu_spw_parity; | |
874 | new_hk_lfr_le.dpu_spw_disconnect= housekeeping_packet.hk_lfr_dpu_spw_disconnect; |
|
912 | new_hk_lfr_le.dpu_spw_disconnect= housekeeping_packet.hk_lfr_dpu_spw_disconnect; | |
875 | new_hk_lfr_le.dpu_spw_escape = housekeeping_packet.hk_lfr_dpu_spw_escape; |
|
913 | new_hk_lfr_le.dpu_spw_escape = housekeeping_packet.hk_lfr_dpu_spw_escape; | |
876 | new_hk_lfr_le.dpu_spw_credit = housekeeping_packet.hk_lfr_dpu_spw_credit; |
|
914 | new_hk_lfr_le.dpu_spw_credit = housekeeping_packet.hk_lfr_dpu_spw_credit; | |
877 | new_hk_lfr_le.dpu_spw_write_sync= housekeeping_packet.hk_lfr_dpu_spw_write_sync; |
|
915 | new_hk_lfr_le.dpu_spw_write_sync= housekeeping_packet.hk_lfr_dpu_spw_write_sync; | |
878 | // TIMECODE |
|
916 | // TIMECODE | |
879 | new_hk_lfr_le.timecode_erroneous= housekeeping_packet.hk_lfr_timecode_erroneous; |
|
917 | new_hk_lfr_le.timecode_erroneous= housekeeping_packet.hk_lfr_timecode_erroneous; | |
880 | new_hk_lfr_le.timecode_missing = housekeeping_packet.hk_lfr_timecode_missing; |
|
918 | new_hk_lfr_le.timecode_missing = housekeeping_packet.hk_lfr_timecode_missing; | |
881 | new_hk_lfr_le.timecode_invalid = housekeeping_packet.hk_lfr_timecode_invalid; |
|
919 | new_hk_lfr_le.timecode_invalid = housekeeping_packet.hk_lfr_timecode_invalid; | |
882 | // TIME |
|
920 | // TIME | |
883 | new_hk_lfr_le.time_timecode_it = housekeeping_packet.hk_lfr_time_timecode_it; |
|
921 | new_hk_lfr_le.time_timecode_it = housekeeping_packet.hk_lfr_time_timecode_it; | |
884 | new_hk_lfr_le.time_not_synchro = housekeeping_packet.hk_lfr_time_not_synchro; |
|
922 | new_hk_lfr_le.time_not_synchro = housekeeping_packet.hk_lfr_time_not_synchro; | |
885 | new_hk_lfr_le.time_timecode_ctr = housekeeping_packet.hk_lfr_time_timecode_ctr; |
|
923 | new_hk_lfr_le.time_timecode_ctr = housekeeping_packet.hk_lfr_time_timecode_ctr; | |
886 | //AHB |
|
924 | //AHB | |
887 | new_hk_lfr_le.ahb_correctable = housekeeping_packet.hk_lfr_ahb_correctable; |
|
925 | new_hk_lfr_le.ahb_correctable = housekeeping_packet.hk_lfr_ahb_correctable; | |
888 | // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver |
|
926 | // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver | |
889 | // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver |
|
927 | // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver | |
890 |
|
928 | |||
891 | // update the le counter |
|
929 | // update the le counter | |
892 | // DPU |
|
930 | // DPU | |
893 | increment_hk_counter( new_hk_lfr_le.dpu_spw_parity, old_hk_lfr_le.dpu_spw_parity, &counter ); |
|
931 | increment_hk_counter( new_hk_lfr_le.dpu_spw_parity, old_hk_lfr_le.dpu_spw_parity, &counter ); | |
894 | increment_hk_counter( new_hk_lfr_le.dpu_spw_disconnect,old_hk_lfr_le.dpu_spw_disconnect, &counter ); |
|
932 | increment_hk_counter( new_hk_lfr_le.dpu_spw_disconnect,old_hk_lfr_le.dpu_spw_disconnect, &counter ); | |
895 | increment_hk_counter( new_hk_lfr_le.dpu_spw_escape, old_hk_lfr_le.dpu_spw_escape, &counter ); |
|
933 | increment_hk_counter( new_hk_lfr_le.dpu_spw_escape, old_hk_lfr_le.dpu_spw_escape, &counter ); | |
896 | increment_hk_counter( new_hk_lfr_le.dpu_spw_credit, old_hk_lfr_le.dpu_spw_credit, &counter ); |
|
934 | increment_hk_counter( new_hk_lfr_le.dpu_spw_credit, old_hk_lfr_le.dpu_spw_credit, &counter ); | |
897 | increment_hk_counter( new_hk_lfr_le.dpu_spw_write_sync,old_hk_lfr_le.dpu_spw_write_sync, &counter ); |
|
935 | increment_hk_counter( new_hk_lfr_le.dpu_spw_write_sync,old_hk_lfr_le.dpu_spw_write_sync, &counter ); | |
898 | // TIMECODE |
|
936 | // TIMECODE | |
899 | increment_hk_counter( new_hk_lfr_le.timecode_erroneous,old_hk_lfr_le.timecode_erroneous, &counter ); |
|
937 | increment_hk_counter( new_hk_lfr_le.timecode_erroneous,old_hk_lfr_le.timecode_erroneous, &counter ); | |
900 | increment_hk_counter( new_hk_lfr_le.timecode_missing, old_hk_lfr_le.timecode_missing, &counter ); |
|
938 | increment_hk_counter( new_hk_lfr_le.timecode_missing, old_hk_lfr_le.timecode_missing, &counter ); | |
901 | increment_hk_counter( new_hk_lfr_le.timecode_invalid, old_hk_lfr_le.timecode_invalid, &counter ); |
|
939 | increment_hk_counter( new_hk_lfr_le.timecode_invalid, old_hk_lfr_le.timecode_invalid, &counter ); | |
902 | // TIME |
|
940 | // TIME | |
903 | increment_hk_counter( new_hk_lfr_le.time_timecode_it, old_hk_lfr_le.time_timecode_it, &counter ); |
|
941 | increment_hk_counter( new_hk_lfr_le.time_timecode_it, old_hk_lfr_le.time_timecode_it, &counter ); | |
904 | increment_hk_counter( new_hk_lfr_le.time_not_synchro, old_hk_lfr_le.time_not_synchro, &counter ); |
|
942 | increment_hk_counter( new_hk_lfr_le.time_not_synchro, old_hk_lfr_le.time_not_synchro, &counter ); | |
905 | increment_hk_counter( new_hk_lfr_le.time_timecode_ctr, old_hk_lfr_le.time_timecode_ctr, &counter ); |
|
943 | increment_hk_counter( new_hk_lfr_le.time_timecode_ctr, old_hk_lfr_le.time_timecode_ctr, &counter ); | |
906 | // AHB |
|
944 | // AHB | |
907 | increment_hk_counter( new_hk_lfr_le.ahb_correctable, old_hk_lfr_le.ahb_correctable, &counter ); |
|
945 | increment_hk_counter( new_hk_lfr_le.ahb_correctable, old_hk_lfr_le.ahb_correctable, &counter ); | |
908 |
|
946 | |||
909 | // DPU |
|
947 | // DPU | |
910 | old_hk_lfr_le.dpu_spw_parity = new_hk_lfr_le.dpu_spw_parity; |
|
948 | old_hk_lfr_le.dpu_spw_parity = new_hk_lfr_le.dpu_spw_parity; | |
911 | old_hk_lfr_le.dpu_spw_disconnect= new_hk_lfr_le.dpu_spw_disconnect; |
|
949 | old_hk_lfr_le.dpu_spw_disconnect= new_hk_lfr_le.dpu_spw_disconnect; | |
912 | old_hk_lfr_le.dpu_spw_escape = new_hk_lfr_le.dpu_spw_escape; |
|
950 | old_hk_lfr_le.dpu_spw_escape = new_hk_lfr_le.dpu_spw_escape; | |
913 | old_hk_lfr_le.dpu_spw_credit = new_hk_lfr_le.dpu_spw_credit; |
|
951 | old_hk_lfr_le.dpu_spw_credit = new_hk_lfr_le.dpu_spw_credit; | |
914 | old_hk_lfr_le.dpu_spw_write_sync= new_hk_lfr_le.dpu_spw_write_sync; |
|
952 | old_hk_lfr_le.dpu_spw_write_sync= new_hk_lfr_le.dpu_spw_write_sync; | |
915 | // TIMECODE |
|
953 | // TIMECODE | |
916 | old_hk_lfr_le.timecode_erroneous= new_hk_lfr_le.timecode_erroneous; |
|
954 | old_hk_lfr_le.timecode_erroneous= new_hk_lfr_le.timecode_erroneous; | |
917 | old_hk_lfr_le.timecode_missing = new_hk_lfr_le.timecode_missing; |
|
955 | old_hk_lfr_le.timecode_missing = new_hk_lfr_le.timecode_missing; | |
918 | old_hk_lfr_le.timecode_invalid = new_hk_lfr_le.timecode_invalid; |
|
956 | old_hk_lfr_le.timecode_invalid = new_hk_lfr_le.timecode_invalid; | |
919 | // TIME |
|
957 | // TIME | |
920 | old_hk_lfr_le.time_timecode_it = new_hk_lfr_le.time_timecode_it; |
|
958 | old_hk_lfr_le.time_timecode_it = new_hk_lfr_le.time_timecode_it; | |
921 | old_hk_lfr_le.time_not_synchro = new_hk_lfr_le.time_not_synchro; |
|
959 | old_hk_lfr_le.time_not_synchro = new_hk_lfr_le.time_not_synchro; | |
922 | old_hk_lfr_le.time_timecode_ctr = new_hk_lfr_le.time_timecode_ctr; |
|
960 | old_hk_lfr_le.time_timecode_ctr = new_hk_lfr_le.time_timecode_ctr; | |
923 | //AHB |
|
961 | //AHB | |
924 | old_hk_lfr_le.ahb_correctable = new_hk_lfr_le.ahb_correctable; |
|
962 | old_hk_lfr_le.ahb_correctable = new_hk_lfr_le.ahb_correctable; | |
925 | // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver |
|
963 | // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver | |
926 | // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver |
|
964 | // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver | |
927 |
|
965 | |||
928 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers |
|
966 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers | |
929 | // LE |
|
967 | // LE | |
930 | housekeeping_packet.hk_lfr_le_cnt[0] = (unsigned char) ((counter & BYTE0_MASK) >> SHIFT_1_BYTE); |
|
968 | housekeeping_packet.hk_lfr_le_cnt[0] = (unsigned char) ((counter & BYTE0_MASK) >> SHIFT_1_BYTE); | |
931 | housekeeping_packet.hk_lfr_le_cnt[1] = (unsigned char) (counter & BYTE1_MASK); |
|
969 | housekeeping_packet.hk_lfr_le_cnt[1] = (unsigned char) (counter & BYTE1_MASK); | |
932 | } |
|
970 | } | |
933 |
|
971 | |||
934 | void hk_lfr_me_update( void ) |
|
972 | void hk_lfr_me_update( void ) | |
935 | { |
|
973 | { | |
936 | static hk_lfr_me_t old_hk_lfr_me = {0}; |
|
974 | static hk_lfr_me_t old_hk_lfr_me = {0}; | |
937 | hk_lfr_me_t new_hk_lfr_me; |
|
975 | hk_lfr_me_t new_hk_lfr_me; | |
938 | unsigned int counter; |
|
976 | unsigned int counter; | |
939 |
|
977 | |||
940 | counter = (((unsigned int) housekeeping_packet.hk_lfr_me_cnt[0]) * CONST_256) + housekeeping_packet.hk_lfr_me_cnt[1]; |
|
978 | counter = (((unsigned int) housekeeping_packet.hk_lfr_me_cnt[0]) * CONST_256) + housekeeping_packet.hk_lfr_me_cnt[1]; | |
941 |
|
979 | |||
942 | // get the current values |
|
980 | // get the current values | |
943 | new_hk_lfr_me.dpu_spw_early_eop = housekeeping_packet.hk_lfr_dpu_spw_early_eop; |
|
981 | new_hk_lfr_me.dpu_spw_early_eop = housekeeping_packet.hk_lfr_dpu_spw_early_eop; | |
944 | new_hk_lfr_me.dpu_spw_invalid_addr = housekeeping_packet.hk_lfr_dpu_spw_invalid_addr; |
|
982 | new_hk_lfr_me.dpu_spw_invalid_addr = housekeeping_packet.hk_lfr_dpu_spw_invalid_addr; | |
945 | new_hk_lfr_me.dpu_spw_eep = housekeeping_packet.hk_lfr_dpu_spw_eep; |
|
983 | new_hk_lfr_me.dpu_spw_eep = housekeeping_packet.hk_lfr_dpu_spw_eep; | |
946 | new_hk_lfr_me.dpu_spw_rx_too_big = housekeeping_packet.hk_lfr_dpu_spw_rx_too_big; |
|
984 | new_hk_lfr_me.dpu_spw_rx_too_big = housekeeping_packet.hk_lfr_dpu_spw_rx_too_big; | |
947 |
|
985 | |||
948 | // update the me counter |
|
986 | // update the me counter | |
949 | increment_hk_counter( new_hk_lfr_me.dpu_spw_early_eop, old_hk_lfr_me.dpu_spw_early_eop, &counter ); |
|
987 | increment_hk_counter( new_hk_lfr_me.dpu_spw_early_eop, old_hk_lfr_me.dpu_spw_early_eop, &counter ); | |
950 | increment_hk_counter( new_hk_lfr_me.dpu_spw_invalid_addr, old_hk_lfr_me.dpu_spw_invalid_addr, &counter ); |
|
988 | increment_hk_counter( new_hk_lfr_me.dpu_spw_invalid_addr, old_hk_lfr_me.dpu_spw_invalid_addr, &counter ); | |
951 | increment_hk_counter( new_hk_lfr_me.dpu_spw_eep, old_hk_lfr_me.dpu_spw_eep, &counter ); |
|
989 | increment_hk_counter( new_hk_lfr_me.dpu_spw_eep, old_hk_lfr_me.dpu_spw_eep, &counter ); | |
952 | increment_hk_counter( new_hk_lfr_me.dpu_spw_rx_too_big, old_hk_lfr_me.dpu_spw_rx_too_big, &counter ); |
|
990 | increment_hk_counter( new_hk_lfr_me.dpu_spw_rx_too_big, old_hk_lfr_me.dpu_spw_rx_too_big, &counter ); | |
953 |
|
991 | |||
954 | // store the counters for the next time |
|
992 | // store the counters for the next time | |
955 | old_hk_lfr_me.dpu_spw_early_eop = new_hk_lfr_me.dpu_spw_early_eop; |
|
993 | old_hk_lfr_me.dpu_spw_early_eop = new_hk_lfr_me.dpu_spw_early_eop; | |
956 | old_hk_lfr_me.dpu_spw_invalid_addr = new_hk_lfr_me.dpu_spw_invalid_addr; |
|
994 | old_hk_lfr_me.dpu_spw_invalid_addr = new_hk_lfr_me.dpu_spw_invalid_addr; | |
957 | old_hk_lfr_me.dpu_spw_eep = new_hk_lfr_me.dpu_spw_eep; |
|
995 | old_hk_lfr_me.dpu_spw_eep = new_hk_lfr_me.dpu_spw_eep; | |
958 | old_hk_lfr_me.dpu_spw_rx_too_big = new_hk_lfr_me.dpu_spw_rx_too_big; |
|
996 | old_hk_lfr_me.dpu_spw_rx_too_big = new_hk_lfr_me.dpu_spw_rx_too_big; | |
959 |
|
997 | |||
960 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers |
|
998 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers | |
961 | // ME |
|
999 | // ME | |
962 | housekeeping_packet.hk_lfr_me_cnt[0] = (unsigned char) ((counter & BYTE0_MASK) >> SHIFT_1_BYTE); |
|
1000 | housekeeping_packet.hk_lfr_me_cnt[0] = (unsigned char) ((counter & BYTE0_MASK) >> SHIFT_1_BYTE); | |
963 | housekeeping_packet.hk_lfr_me_cnt[1] = (unsigned char) (counter & BYTE1_MASK); |
|
1001 | housekeeping_packet.hk_lfr_me_cnt[1] = (unsigned char) (counter & BYTE1_MASK); | |
964 | } |
|
1002 | } | |
965 |
|
1003 | |||
966 | void hk_lfr_le_me_he_update() |
|
1004 | void hk_lfr_le_me_he_update() | |
967 | { |
|
1005 | { | |
968 |
|
1006 | |||
969 | unsigned int hk_lfr_he_cnt; |
|
1007 | unsigned int hk_lfr_he_cnt; | |
970 |
|
1008 | |||
971 | hk_lfr_he_cnt = (((unsigned int) housekeeping_packet.hk_lfr_he_cnt[0]) * 256) + housekeeping_packet.hk_lfr_he_cnt[1]; |
|
1009 | hk_lfr_he_cnt = (((unsigned int) housekeeping_packet.hk_lfr_he_cnt[0]) * 256) + housekeeping_packet.hk_lfr_he_cnt[1]; | |
972 |
|
1010 | |||
973 | //update the low severity error counter |
|
1011 | //update the low severity error counter | |
974 | hk_lfr_le_update( ); |
|
1012 | hk_lfr_le_update( ); | |
975 |
|
1013 | |||
976 | //update the medium severity error counter |
|
1014 | //update the medium severity error counter | |
977 | hk_lfr_me_update(); |
|
1015 | hk_lfr_me_update(); | |
978 |
|
1016 | |||
979 | //update the high severity error counter |
|
1017 | //update the high severity error counter | |
980 | hk_lfr_he_cnt = 0; |
|
1018 | hk_lfr_he_cnt = 0; | |
981 |
|
1019 | |||
982 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers |
|
1020 | // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers | |
983 | // HE |
|
1021 | // HE | |
984 | housekeeping_packet.hk_lfr_he_cnt[0] = (unsigned char) ((hk_lfr_he_cnt & BYTE0_MASK) >> SHIFT_1_BYTE); |
|
1022 | housekeeping_packet.hk_lfr_he_cnt[0] = (unsigned char) ((hk_lfr_he_cnt & BYTE0_MASK) >> SHIFT_1_BYTE); | |
985 | housekeeping_packet.hk_lfr_he_cnt[1] = (unsigned char) (hk_lfr_he_cnt & BYTE1_MASK); |
|
1023 | housekeeping_packet.hk_lfr_he_cnt[1] = (unsigned char) (hk_lfr_he_cnt & BYTE1_MASK); | |
986 |
|
1024 | |||
987 | } |
|
1025 | } | |
988 |
|
1026 | |||
989 | void set_hk_lfr_time_not_synchro() |
|
1027 | void set_hk_lfr_time_not_synchro() | |
990 | { |
|
1028 | { | |
991 | static unsigned char synchroLost = 1; |
|
1029 | static unsigned char synchroLost = 1; | |
992 | int synchronizationBit; |
|
1030 | int synchronizationBit; | |
993 |
|
1031 | |||
994 | // get the synchronization bit |
|
1032 | // get the synchronization bit | |
995 | synchronizationBit = |
|
1033 | synchronizationBit = | |
996 | (time_management_regs->coarse_time & VAL_LFR_SYNCHRONIZED) >> BIT_SYNCHRONIZATION; // 1000 0000 0000 0000 |
|
1034 | (time_management_regs->coarse_time & VAL_LFR_SYNCHRONIZED) >> BIT_SYNCHRONIZATION; // 1000 0000 0000 0000 | |
997 |
|
1035 | |||
998 | switch (synchronizationBit) |
|
1036 | switch (synchronizationBit) | |
999 | { |
|
1037 | { | |
1000 | case 0: |
|
1038 | case 0: | |
1001 | if (synchroLost == 1) |
|
1039 | if (synchroLost == 1) | |
1002 | { |
|
1040 | { | |
1003 | synchroLost = 0; |
|
1041 | synchroLost = 0; | |
1004 | } |
|
1042 | } | |
1005 | break; |
|
1043 | break; | |
1006 | case 1: |
|
1044 | case 1: | |
1007 | if (synchroLost == 0 ) |
|
1045 | if (synchroLost == 0 ) | |
1008 | { |
|
1046 | { | |
1009 | synchroLost = 1; |
|
1047 | synchroLost = 1; | |
1010 | increase_unsigned_char_counter(&housekeeping_packet.hk_lfr_time_not_synchro); |
|
1048 | increase_unsigned_char_counter(&housekeeping_packet.hk_lfr_time_not_synchro); | |
1011 | update_hk_lfr_last_er_fields( RID_LE_LFR_TIME, CODE_NOT_SYNCHRO ); |
|
1049 | update_hk_lfr_last_er_fields( RID_LE_LFR_TIME, CODE_NOT_SYNCHRO ); | |
1012 | } |
|
1050 | } | |
1013 | break; |
|
1051 | break; | |
1014 | default: |
|
1052 | default: | |
1015 | PRINTF1("in hk_lfr_time_not_synchro *** unexpected value for synchronizationBit = %d\n", synchronizationBit); |
|
1053 | PRINTF1("in hk_lfr_time_not_synchro *** unexpected value for synchronizationBit = %d\n", synchronizationBit); | |
1016 | break; |
|
1054 | break; | |
1017 | } |
|
1055 | } | |
1018 |
|
1056 | |||
1019 | } |
|
1057 | } | |
1020 |
|
1058 | |||
1021 | void set_hk_lfr_ahb_correctable() // CRITICITY L |
|
1059 | void set_hk_lfr_ahb_correctable() // CRITICITY L | |
1022 | { |
|
1060 | { | |
1023 | /** This function builds the error counter hk_lfr_ahb_correctable using the statistics provided |
|
1061 | /** This function builds the error counter hk_lfr_ahb_correctable using the statistics provided | |
1024 | * by the Cache Control Register (ASI 2, offset 0) and in the Register Protection Control Register (ASR16) on the |
|
1062 | * by the Cache Control Register (ASI 2, offset 0) and in the Register Protection Control Register (ASR16) on the | |
1025 | * detected errors in the cache, in the integer unit and in the floating point unit. |
|
1063 | * detected errors in the cache, in the integer unit and in the floating point unit. | |
1026 | * |
|
1064 | * | |
1027 | * @param void |
|
1065 | * @param void | |
1028 | * |
|
1066 | * | |
1029 | * @return void |
|
1067 | * @return void | |
1030 | * |
|
1068 | * | |
1031 | * All errors are summed to set the value of the hk_lfr_ahb_correctable counter. |
|
1069 | * All errors are summed to set the value of the hk_lfr_ahb_correctable counter. | |
1032 | * |
|
1070 | * | |
1033 | */ |
|
1071 | */ | |
1034 |
|
1072 | |||
1035 | unsigned int ahb_correctable; |
|
1073 | unsigned int ahb_correctable; | |
1036 | unsigned int instructionErrorCounter; |
|
1074 | unsigned int instructionErrorCounter; | |
1037 | unsigned int dataErrorCounter; |
|
1075 | unsigned int dataErrorCounter; | |
1038 | unsigned int fprfErrorCounter; |
|
1076 | unsigned int fprfErrorCounter; | |
1039 | unsigned int iurfErrorCounter; |
|
1077 | unsigned int iurfErrorCounter; | |
1040 |
|
1078 | |||
1041 | instructionErrorCounter = 0; |
|
1079 | instructionErrorCounter = 0; | |
1042 | dataErrorCounter = 0; |
|
1080 | dataErrorCounter = 0; | |
1043 | fprfErrorCounter = 0; |
|
1081 | fprfErrorCounter = 0; | |
1044 | iurfErrorCounter = 0; |
|
1082 | iurfErrorCounter = 0; | |
1045 |
|
1083 | |||
1046 | CCR_getInstructionAndDataErrorCounters( &instructionErrorCounter, &dataErrorCounter); |
|
1084 | CCR_getInstructionAndDataErrorCounters( &instructionErrorCounter, &dataErrorCounter); | |
1047 | ASR16_get_FPRF_IURF_ErrorCounters( &fprfErrorCounter, &iurfErrorCounter); |
|
1085 | ASR16_get_FPRF_IURF_ErrorCounters( &fprfErrorCounter, &iurfErrorCounter); | |
1048 |
|
1086 | |||
1049 | ahb_correctable = instructionErrorCounter |
|
1087 | ahb_correctable = instructionErrorCounter | |
1050 | + dataErrorCounter |
|
1088 | + dataErrorCounter | |
1051 | + fprfErrorCounter |
|
1089 | + fprfErrorCounter | |
1052 | + iurfErrorCounter |
|
1090 | + iurfErrorCounter | |
1053 | + housekeeping_packet.hk_lfr_ahb_correctable; |
|
1091 | + housekeeping_packet.hk_lfr_ahb_correctable; | |
1054 |
|
1092 | |||
1055 | housekeeping_packet.hk_lfr_ahb_correctable = (unsigned char) (ahb_correctable & INT8_ALL_F); // [1111 1111] |
|
1093 | housekeeping_packet.hk_lfr_ahb_correctable = (unsigned char) (ahb_correctable & INT8_ALL_F); // [1111 1111] | |
1056 |
|
1094 | |||
1057 | } |
|
1095 | } |
@@ -1,1343 +1,1344 | |||||
1 | /** Functions and tasks related to waveform packet generation. |
|
1 | /** Functions and tasks related to waveform packet generation. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle waveforms, in snapshot or continuous format.\n |
|
6 | * A group of functions to handle waveforms, in snapshot or continuous format.\n | |
7 | * |
|
7 | * | |
8 | */ |
|
8 | */ | |
9 |
|
9 | |||
10 | #include "wf_handler.h" |
|
10 | #include "wf_handler.h" | |
11 |
|
11 | |||
12 | //*************** |
|
12 | //*************** | |
13 | // waveform rings |
|
13 | // waveform rings | |
14 | // F0 |
|
14 | // F0 | |
15 | ring_node waveform_ring_f0[NB_RING_NODES_F0]= {0}; |
|
15 | ring_node waveform_ring_f0[NB_RING_NODES_F0]= {0}; | |
16 | ring_node *current_ring_node_f0 = NULL; |
|
16 | ring_node *current_ring_node_f0 = NULL; | |
17 | ring_node *ring_node_to_send_swf_f0 = NULL; |
|
17 | ring_node *ring_node_to_send_swf_f0 = NULL; | |
18 | // F1 |
|
18 | // F1 | |
19 | ring_node waveform_ring_f1[NB_RING_NODES_F1] = {0}; |
|
19 | ring_node waveform_ring_f1[NB_RING_NODES_F1] = {0}; | |
20 | ring_node *current_ring_node_f1 = NULL; |
|
20 | ring_node *current_ring_node_f1 = NULL; | |
21 | ring_node *ring_node_to_send_swf_f1 = NULL; |
|
21 | ring_node *ring_node_to_send_swf_f1 = NULL; | |
22 | ring_node *ring_node_to_send_cwf_f1 = NULL; |
|
22 | ring_node *ring_node_to_send_cwf_f1 = NULL; | |
23 | // F2 |
|
23 | // F2 | |
24 | ring_node waveform_ring_f2[NB_RING_NODES_F2] = {0}; |
|
24 | ring_node waveform_ring_f2[NB_RING_NODES_F2] = {0}; | |
25 | ring_node *current_ring_node_f2 = NULL; |
|
25 | ring_node *current_ring_node_f2 = NULL; | |
26 | ring_node *ring_node_to_send_swf_f2 = NULL; |
|
26 | ring_node *ring_node_to_send_swf_f2 = NULL; | |
27 | ring_node *ring_node_to_send_cwf_f2 = NULL; |
|
27 | ring_node *ring_node_to_send_cwf_f2 = NULL; | |
28 | // F3 |
|
28 | // F3 | |
29 | ring_node waveform_ring_f3[NB_RING_NODES_F3] = {0}; |
|
29 | ring_node waveform_ring_f3[NB_RING_NODES_F3] = {0}; | |
30 | ring_node *current_ring_node_f3 = NULL; |
|
30 | ring_node *current_ring_node_f3 = NULL; | |
31 | ring_node *ring_node_to_send_cwf_f3 = NULL; |
|
31 | ring_node *ring_node_to_send_cwf_f3 = NULL; | |
32 | char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK ] = {0}; |
|
32 | char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK ] = {0}; | |
33 |
|
33 | |||
34 | bool extractSWF1 = false; |
|
34 | bool extractSWF1 = false; | |
35 | bool extractSWF2 = false; |
|
35 | bool extractSWF2 = false; | |
36 | bool swf0_ready_flag_f1 = false; |
|
36 | bool swf0_ready_flag_f1 = false; | |
37 | bool swf0_ready_flag_f2 = false; |
|
37 | bool swf0_ready_flag_f2 = false; | |
38 | bool swf1_ready = false; |
|
38 | bool swf1_ready = false; | |
39 | bool swf2_ready = false; |
|
39 | bool swf2_ready = false; | |
40 |
|
40 | |||
41 | int swf1_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ] = {0}; |
|
41 | int swf1_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ] = {0}; | |
42 | int swf2_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ] = {0}; |
|
42 | int swf2_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ] = {0}; | |
43 | ring_node ring_node_swf1_extracted = {0}; |
|
43 | ring_node ring_node_swf1_extracted = {0}; | |
44 | ring_node ring_node_swf2_extracted = {0}; |
|
44 | ring_node ring_node_swf2_extracted = {0}; | |
45 |
|
45 | |||
46 | typedef enum resynchro_state_t |
|
46 | typedef enum resynchro_state_t | |
47 | { |
|
47 | { | |
48 | MEASURE, |
|
48 | MEASURE, | |
49 | CORRECTION |
|
49 | CORRECTION | |
50 | } resynchro_state; |
|
50 | } resynchro_state; | |
51 |
|
51 | |||
52 | //********************* |
|
52 | //********************* | |
53 | // Interrupt SubRoutine |
|
53 | // Interrupt SubRoutine | |
54 |
|
54 | |||
55 | ring_node * getRingNodeToSendCWF( unsigned char frequencyChannel) |
|
55 | ring_node * getRingNodeToSendCWF( unsigned char frequencyChannel) | |
56 | { |
|
56 | { | |
57 | ring_node *node; |
|
57 | ring_node *node; | |
58 |
|
58 | |||
59 | node = NULL; |
|
59 | node = NULL; | |
60 | switch ( frequencyChannel ) { |
|
60 | switch ( frequencyChannel ) { | |
61 | case CHANNELF1: |
|
61 | case CHANNELF1: | |
62 | node = ring_node_to_send_cwf_f1; |
|
62 | node = ring_node_to_send_cwf_f1; | |
63 | break; |
|
63 | break; | |
64 | case CHANNELF2: |
|
64 | case CHANNELF2: | |
65 | node = ring_node_to_send_cwf_f2; |
|
65 | node = ring_node_to_send_cwf_f2; | |
66 | break; |
|
66 | break; | |
67 | case CHANNELF3: |
|
67 | case CHANNELF3: | |
68 | node = ring_node_to_send_cwf_f3; |
|
68 | node = ring_node_to_send_cwf_f3; | |
69 | break; |
|
69 | break; | |
70 | default: |
|
70 | default: | |
71 | break; |
|
71 | break; | |
72 | } |
|
72 | } | |
73 |
|
73 | |||
74 | return node; |
|
74 | return node; | |
75 | } |
|
75 | } | |
76 |
|
76 | |||
77 | ring_node * getRingNodeToSendSWF( unsigned char frequencyChannel) |
|
77 | ring_node * getRingNodeToSendSWF( unsigned char frequencyChannel) | |
78 | { |
|
78 | { | |
79 | ring_node *node; |
|
79 | ring_node *node; | |
80 |
|
80 | |||
81 | node = NULL; |
|
81 | node = NULL; | |
82 | switch ( frequencyChannel ) { |
|
82 | switch ( frequencyChannel ) { | |
83 | case CHANNELF0: |
|
83 | case CHANNELF0: | |
84 | node = ring_node_to_send_swf_f0; |
|
84 | node = ring_node_to_send_swf_f0; | |
85 | break; |
|
85 | break; | |
86 | case CHANNELF1: |
|
86 | case CHANNELF1: | |
87 | node = ring_node_to_send_swf_f1; |
|
87 | node = ring_node_to_send_swf_f1; | |
88 | break; |
|
88 | break; | |
89 | case CHANNELF2: |
|
89 | case CHANNELF2: | |
90 | node = ring_node_to_send_swf_f2; |
|
90 | node = ring_node_to_send_swf_f2; | |
91 | break; |
|
91 | break; | |
92 | default: |
|
92 | default: | |
93 | break; |
|
93 | break; | |
94 | } |
|
94 | } | |
95 |
|
95 | |||
96 | return node; |
|
96 | return node; | |
97 | } |
|
97 | } | |
98 |
|
98 | |||
99 | void reset_extractSWF( void ) |
|
99 | void reset_extractSWF( void ) | |
100 | { |
|
100 | { | |
101 | extractSWF1 = false; |
|
101 | extractSWF1 = false; | |
102 | extractSWF2 = false; |
|
102 | extractSWF2 = false; | |
103 | swf0_ready_flag_f1 = false; |
|
103 | swf0_ready_flag_f1 = false; | |
104 | swf0_ready_flag_f2 = false; |
|
104 | swf0_ready_flag_f2 = false; | |
105 | swf1_ready = false; |
|
105 | swf1_ready = false; | |
106 | swf2_ready = false; |
|
106 | swf2_ready = false; | |
107 | } |
|
107 | } | |
108 |
|
108 | |||
109 | inline void waveforms_isr_f3( void ) |
|
109 | inline void waveforms_isr_f3( void ) | |
110 | { |
|
110 | { | |
111 | rtems_status_code spare_status; |
|
111 | rtems_status_code spare_status; | |
112 |
|
112 | |||
113 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_BURST) // in BURST the data are used to place v, e1 and e2 in the HK packet |
|
113 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_BURST) // in BURST the data are used to place v, e1 and e2 in the HK packet | |
114 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
114 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
115 | { // in modes other than STANDBY and BURST, send the CWF_F3 data |
|
115 | { // in modes other than STANDBY and BURST, send the CWF_F3 data | |
116 | //*** |
|
116 | //*** | |
117 | // F3 |
|
117 | // F3 | |
118 | if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F3) != INIT_CHAR ) { // [1100 0000] check the f3 full bits |
|
118 | if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F3) != INIT_CHAR ) { // [1100 0000] check the f3 full bits | |
119 | ring_node_to_send_cwf_f3 = current_ring_node_f3->previous; |
|
119 | ring_node_to_send_cwf_f3 = current_ring_node_f3->previous; | |
120 | current_ring_node_f3 = current_ring_node_f3->next; |
|
120 | current_ring_node_f3 = current_ring_node_f3->next; | |
121 | if ((waveform_picker_regs->status & BIT_WFP_BUF_F3_0) == BIT_WFP_BUF_F3_0){ // [0100 0000] f3 buffer 0 is full |
|
121 | if ((waveform_picker_regs->status & BIT_WFP_BUF_F3_0) == BIT_WFP_BUF_F3_0){ // [0100 0000] f3 buffer 0 is full | |
122 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time; |
|
122 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time; | |
123 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time; |
|
123 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time; | |
124 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address; |
|
124 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address; | |
125 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F3_0; // [1000 1000 0100 0000] |
|
125 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F3_0; // [1000 1000 0100 0000] | |
126 | } |
|
126 | } | |
127 | else if ((waveform_picker_regs->status & BIT_WFP_BUF_F3_1) == BIT_WFP_BUF_F3_1){ // [1000 0000] f3 buffer 1 is full |
|
127 | else if ((waveform_picker_regs->status & BIT_WFP_BUF_F3_1) == BIT_WFP_BUF_F3_1){ // [1000 0000] f3 buffer 1 is full | |
128 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time; |
|
128 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time; | |
129 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time; |
|
129 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time; | |
130 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; |
|
130 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; | |
131 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F3_1; // [1000 1000 1000 0000] |
|
131 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F3_1; // [1000 1000 1000 0000] | |
132 | } |
|
132 | } | |
133 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
133 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
134 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); |
|
134 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); | |
135 | } |
|
135 | } | |
136 | } |
|
136 | } | |
137 | } |
|
137 | } | |
138 | } |
|
138 | } | |
139 |
|
139 | |||
140 | inline void waveforms_isr_burst( void ) |
|
140 | inline void waveforms_isr_burst( void ) | |
141 | { |
|
141 | { | |
142 | unsigned char status; |
|
142 | unsigned char status; | |
143 | rtems_status_code spare_status; |
|
143 | rtems_status_code spare_status; | |
144 |
|
144 | |||
145 | status = (waveform_picker_regs->status & BITS_WFP_STATUS_F2) >> SHIFT_WFP_STATUS_F2; // [0011 0000] get the status bits for f2 |
|
145 | status = (waveform_picker_regs->status & BITS_WFP_STATUS_F2) >> SHIFT_WFP_STATUS_F2; // [0011 0000] get the status bits for f2 | |
146 |
|
146 | |||
147 | switch(status) |
|
147 | switch(status) | |
148 | { |
|
148 | { | |
149 | case BIT_WFP_BUFFER_0: |
|
149 | case BIT_WFP_BUFFER_0: | |
150 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; |
|
150 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; | |
151 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; |
|
151 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; | |
152 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; |
|
152 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; | |
153 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; |
|
153 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; | |
154 | current_ring_node_f2 = current_ring_node_f2->next; |
|
154 | current_ring_node_f2 = current_ring_node_f2->next; | |
155 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; |
|
155 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; | |
156 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { |
|
156 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { | |
157 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); |
|
157 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); | |
158 | } |
|
158 | } | |
159 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_0; // [0100 0100 0001 0000] |
|
159 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_0; // [0100 0100 0001 0000] | |
160 | break; |
|
160 | break; | |
161 | case BIT_WFP_BUFFER_1: |
|
161 | case BIT_WFP_BUFFER_1: | |
162 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; |
|
162 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; | |
163 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; |
|
163 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; | |
164 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; |
|
164 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; | |
165 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; |
|
165 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; | |
166 | current_ring_node_f2 = current_ring_node_f2->next; |
|
166 | current_ring_node_f2 = current_ring_node_f2->next; | |
167 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; |
|
167 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; | |
168 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { |
|
168 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { | |
169 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); |
|
169 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); | |
170 | } |
|
170 | } | |
171 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_1; // [0100 0100 0010 0000] |
|
171 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_1; // [0100 0100 0010 0000] | |
172 | break; |
|
172 | break; | |
173 | default: |
|
173 | default: | |
174 | break; |
|
174 | break; | |
175 | } |
|
175 | } | |
176 | } |
|
176 | } | |
177 |
|
177 | |||
178 | inline void waveform_isr_normal_sbm1_sbm2( void ) |
|
178 | inline void waveform_isr_normal_sbm1_sbm2( void ) | |
179 | { |
|
179 | { | |
180 | rtems_status_code status; |
|
180 | rtems_status_code status; | |
181 |
|
181 | |||
182 | //*** |
|
182 | //*** | |
183 | // F0 |
|
183 | // F0 | |
184 | if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F0) != INIT_CHAR ) // [0000 0011] check the f0 full bits |
|
184 | if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F0) != INIT_CHAR ) // [0000 0011] check the f0 full bits | |
185 | { |
|
185 | { | |
186 | swf0_ready_flag_f1 = true; |
|
186 | swf0_ready_flag_f1 = true; | |
187 | swf0_ready_flag_f2 = true; |
|
187 | swf0_ready_flag_f2 = true; | |
188 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; |
|
188 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; | |
189 | current_ring_node_f0 = current_ring_node_f0->next; |
|
189 | current_ring_node_f0 = current_ring_node_f0->next; | |
190 | if ( (waveform_picker_regs->status & BIT_WFP_BUFFER_0) == BIT_WFP_BUFFER_0) |
|
190 | if ( (waveform_picker_regs->status & BIT_WFP_BUFFER_0) == BIT_WFP_BUFFER_0) | |
191 | { |
|
191 | { | |
192 |
|
192 | |||
193 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; |
|
193 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; | |
194 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; |
|
194 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; | |
195 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; |
|
195 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; | |
196 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F0_0; // [0001 0001 0000 0001] |
|
196 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F0_0; // [0001 0001 0000 0001] | |
197 | } |
|
197 | } | |
198 | else if ( (waveform_picker_regs->status & BIT_WFP_BUFFER_1) == BIT_WFP_BUFFER_1) |
|
198 | else if ( (waveform_picker_regs->status & BIT_WFP_BUFFER_1) == BIT_WFP_BUFFER_1) | |
199 | { |
|
199 | { | |
200 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; |
|
200 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; | |
201 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; |
|
201 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; | |
202 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; |
|
202 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; | |
203 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F0_1; // [0001 0001 0000 0010] |
|
203 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F0_1; // [0001 0001 0000 0010] | |
204 | } |
|
204 | } | |
205 | // send an event to the WFRM task for resynchro activities |
|
205 | // send an event to the WFRM task for resynchro activities | |
206 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_SWF_RESYNCH ); |
|
206 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_SWF_RESYNCH ); | |
|
207 | status = rtems_event_send( Task_id[TASKID_CALI], RTEMS_EVENT_CAL_SWEEP_WAKE ); | |||
207 | } |
|
208 | } | |
208 |
|
209 | |||
209 | //*** |
|
210 | //*** | |
210 | // F1 |
|
211 | // F1 | |
211 | if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F1) != INIT_CHAR ) { // [0000 1100] check the f1 full bits |
|
212 | if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F1) != INIT_CHAR ) { // [0000 1100] check the f1 full bits | |
212 | // (1) change the receiving buffer for the waveform picker |
|
213 | // (1) change the receiving buffer for the waveform picker | |
213 | ring_node_to_send_cwf_f1 = current_ring_node_f1->previous; |
|
214 | ring_node_to_send_cwf_f1 = current_ring_node_f1->previous; | |
214 | current_ring_node_f1 = current_ring_node_f1->next; |
|
215 | current_ring_node_f1 = current_ring_node_f1->next; | |
215 | if ( (waveform_picker_regs->status & BIT_WFP_BUF_F1_0) == BIT_WFP_BUF_F1_0) |
|
216 | if ( (waveform_picker_regs->status & BIT_WFP_BUF_F1_0) == BIT_WFP_BUF_F1_0) | |
216 | { |
|
217 | { | |
217 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; |
|
218 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; | |
218 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; |
|
219 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; | |
219 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; |
|
220 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; | |
220 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F1_0; // [0010 0010 0000 0100] f1 bits = 0 |
|
221 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F1_0; // [0010 0010 0000 0100] f1 bits = 0 | |
221 | } |
|
222 | } | |
222 | else if ( (waveform_picker_regs->status & BIT_WFP_BUF_F1_1) == BIT_WFP_BUF_F1_1) |
|
223 | else if ( (waveform_picker_regs->status & BIT_WFP_BUF_F1_1) == BIT_WFP_BUF_F1_1) | |
223 | { |
|
224 | { | |
224 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; |
|
225 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; | |
225 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; |
|
226 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; | |
226 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; |
|
227 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; | |
227 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F1_1; // [0010 0010 0000 1000] f1 bits = 0 |
|
228 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F1_1; // [0010 0010 0000 1000] f1 bits = 0 | |
228 | } |
|
229 | } | |
229 | // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed) |
|
230 | // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed) | |
230 | status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_NORM_S1_S2 ); |
|
231 | status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_NORM_S1_S2 ); | |
231 | } |
|
232 | } | |
232 |
|
233 | |||
233 | //*** |
|
234 | //*** | |
234 | // F2 |
|
235 | // F2 | |
235 | if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F2) != INIT_CHAR ) { // [0011 0000] check the f2 full bit |
|
236 | if ( (waveform_picker_regs->status & BITS_WFP_STATUS_F2) != INIT_CHAR ) { // [0011 0000] check the f2 full bit | |
236 | // (1) change the receiving buffer for the waveform picker |
|
237 | // (1) change the receiving buffer for the waveform picker | |
237 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; |
|
238 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; | |
238 | ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2; |
|
239 | ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2; | |
239 | current_ring_node_f2 = current_ring_node_f2->next; |
|
240 | current_ring_node_f2 = current_ring_node_f2->next; | |
240 | if ( (waveform_picker_regs->status & BIT_WFP_BUF_F2_0) == BIT_WFP_BUF_F2_0) |
|
241 | if ( (waveform_picker_regs->status & BIT_WFP_BUF_F2_0) == BIT_WFP_BUF_F2_0) | |
241 | { |
|
242 | { | |
242 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; |
|
243 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; | |
243 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; |
|
244 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; | |
244 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; |
|
245 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; | |
245 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_0; // [0100 0100 0001 0000] |
|
246 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_0; // [0100 0100 0001 0000] | |
246 | } |
|
247 | } | |
247 | else if ( (waveform_picker_regs->status & BIT_WFP_BUF_F2_1) == BIT_WFP_BUF_F2_1) |
|
248 | else if ( (waveform_picker_regs->status & BIT_WFP_BUF_F2_1) == BIT_WFP_BUF_F2_1) | |
248 | { |
|
249 | { | |
249 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; |
|
250 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; | |
250 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; |
|
251 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; | |
251 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; |
|
252 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; | |
252 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_1; // [0100 0100 0010 0000] |
|
253 | waveform_picker_regs->status = waveform_picker_regs->status & RST_WFP_F2_1; // [0100 0100 0010 0000] | |
253 | } |
|
254 | } | |
254 | // (2) send an event for the waveforms transmission |
|
255 | // (2) send an event for the waveforms transmission | |
255 | status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_NORM_S1_S2 ); |
|
256 | status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_NORM_S1_S2 ); | |
256 | } |
|
257 | } | |
257 | } |
|
258 | } | |
258 |
|
259 | |||
259 | rtems_isr waveforms_isr( rtems_vector_number vector ) |
|
260 | rtems_isr waveforms_isr( rtems_vector_number vector ) | |
260 | { |
|
261 | { | |
261 | /** This is the interrupt sub routine called by the waveform picker core. |
|
262 | /** This is the interrupt sub routine called by the waveform picker core. | |
262 | * |
|
263 | * | |
263 | * This ISR launch different actions depending mainly on two pieces of information: |
|
264 | * This ISR launch different actions depending mainly on two pieces of information: | |
264 | * 1. the values read in the registers of the waveform picker. |
|
265 | * 1. the values read in the registers of the waveform picker. | |
265 | * 2. the current LFR mode. |
|
266 | * 2. the current LFR mode. | |
266 | * |
|
267 | * | |
267 | */ |
|
268 | */ | |
268 |
|
269 | |||
269 | // STATUS |
|
270 | // STATUS | |
270 | // new error error buffer full |
|
271 | // new error error buffer full | |
271 | // 15 14 13 12 11 10 9 8 |
|
272 | // 15 14 13 12 11 10 9 8 | |
272 | // f3 f2 f1 f0 f3 f2 f1 f0 |
|
273 | // f3 f2 f1 f0 f3 f2 f1 f0 | |
273 | // |
|
274 | // | |
274 | // ready buffer |
|
275 | // ready buffer | |
275 | // 7 6 5 4 3 2 1 0 |
|
276 | // 7 6 5 4 3 2 1 0 | |
276 | // f3_1 f3_0 f2_1 f2_0 f1_1 f1_0 f0_1 f0_0 |
|
277 | // f3_1 f3_0 f2_1 f2_0 f1_1 f1_0 f0_1 f0_0 | |
277 |
|
278 | |||
278 | rtems_status_code spare_status; |
|
279 | rtems_status_code spare_status; | |
279 |
|
280 | |||
280 | waveforms_isr_f3(); |
|
281 | waveforms_isr_f3(); | |
281 |
|
282 | |||
282 | //************************************************* |
|
283 | //************************************************* | |
283 | // copy the status bits in the housekeeping packets |
|
284 | // copy the status bits in the housekeeping packets | |
284 | housekeeping_packet.hk_lfr_vhdl_iir_cal = |
|
285 | housekeeping_packet.hk_lfr_vhdl_iir_cal = | |
285 | (unsigned char) ((waveform_picker_regs->status & BYTE0_MASK) >> SHIFT_1_BYTE); |
|
286 | (unsigned char) ((waveform_picker_regs->status & BYTE0_MASK) >> SHIFT_1_BYTE); | |
286 |
|
287 | |||
287 | if ( (waveform_picker_regs->status & BYTE0_MASK) != INIT_CHAR) // [1111 1111 0000 0000] check the error bits |
|
288 | if ( (waveform_picker_regs->status & BYTE0_MASK) != INIT_CHAR) // [1111 1111 0000 0000] check the error bits | |
288 | { |
|
289 | { | |
289 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 ); |
|
290 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 ); | |
290 | } |
|
291 | } | |
291 |
|
292 | |||
292 | switch(lfrCurrentMode) |
|
293 | switch(lfrCurrentMode) | |
293 | { |
|
294 | { | |
294 | //******** |
|
295 | //******** | |
295 | // STANDBY |
|
296 | // STANDBY | |
296 | case LFR_MODE_STANDBY: |
|
297 | case LFR_MODE_STANDBY: | |
297 | break; |
|
298 | break; | |
298 | //************************** |
|
299 | //************************** | |
299 | // LFR NORMAL, SBM1 and SBM2 |
|
300 | // LFR NORMAL, SBM1 and SBM2 | |
300 | case LFR_MODE_NORMAL: |
|
301 | case LFR_MODE_NORMAL: | |
301 | case LFR_MODE_SBM1: |
|
302 | case LFR_MODE_SBM1: | |
302 | case LFR_MODE_SBM2: |
|
303 | case LFR_MODE_SBM2: | |
303 | waveform_isr_normal_sbm1_sbm2(); |
|
304 | waveform_isr_normal_sbm1_sbm2(); | |
304 | break; |
|
305 | break; | |
305 | //****** |
|
306 | //****** | |
306 | // BURST |
|
307 | // BURST | |
307 | case LFR_MODE_BURST: |
|
308 | case LFR_MODE_BURST: | |
308 | waveforms_isr_burst(); |
|
309 | waveforms_isr_burst(); | |
309 | break; |
|
310 | break; | |
310 | //******** |
|
311 | //******** | |
311 | // DEFAULT |
|
312 | // DEFAULT | |
312 | default: |
|
313 | default: | |
313 | break; |
|
314 | break; | |
314 | } |
|
315 | } | |
315 | } |
|
316 | } | |
316 |
|
317 | |||
317 | //************ |
|
318 | //************ | |
318 | // RTEMS TASKS |
|
319 | // RTEMS TASKS | |
319 |
|
320 | |||
320 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
321 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP | |
321 | { |
|
322 | { | |
322 | /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode. |
|
323 | /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode. | |
323 | * |
|
324 | * | |
324 | * @param unused is the starting argument of the RTEMS task |
|
325 | * @param unused is the starting argument of the RTEMS task | |
325 | * |
|
326 | * | |
326 | * The following data packets are sent by this task: |
|
327 | * The following data packets are sent by this task: | |
327 | * - TM_LFR_SCIENCE_NORMAL_SWF_F0 |
|
328 | * - TM_LFR_SCIENCE_NORMAL_SWF_F0 | |
328 | * - TM_LFR_SCIENCE_NORMAL_SWF_F1 |
|
329 | * - TM_LFR_SCIENCE_NORMAL_SWF_F1 | |
329 | * - TM_LFR_SCIENCE_NORMAL_SWF_F2 |
|
330 | * - TM_LFR_SCIENCE_NORMAL_SWF_F2 | |
330 | * |
|
331 | * | |
331 | */ |
|
332 | */ | |
332 |
|
333 | |||
333 | rtems_event_set event_out; |
|
334 | rtems_event_set event_out; | |
334 | rtems_id queue_id; |
|
335 | rtems_id queue_id; | |
335 | rtems_status_code status; |
|
336 | rtems_status_code status; | |
336 | ring_node *ring_node_swf1_extracted_ptr; |
|
337 | ring_node *ring_node_swf1_extracted_ptr; | |
337 | ring_node *ring_node_swf2_extracted_ptr; |
|
338 | ring_node *ring_node_swf2_extracted_ptr; | |
338 |
|
339 | |||
339 | event_out = EVENT_SETS_NONE_PENDING; |
|
340 | event_out = EVENT_SETS_NONE_PENDING; | |
340 | queue_id = RTEMS_ID_NONE; |
|
341 | queue_id = RTEMS_ID_NONE; | |
341 |
|
342 | |||
342 | ring_node_swf1_extracted_ptr = (ring_node *) &ring_node_swf1_extracted; |
|
343 | ring_node_swf1_extracted_ptr = (ring_node *) &ring_node_swf1_extracted; | |
343 | ring_node_swf2_extracted_ptr = (ring_node *) &ring_node_swf2_extracted; |
|
344 | ring_node_swf2_extracted_ptr = (ring_node *) &ring_node_swf2_extracted; | |
344 |
|
345 | |||
345 | status = get_message_queue_id_send( &queue_id ); |
|
346 | status = get_message_queue_id_send( &queue_id ); | |
346 | if (status != RTEMS_SUCCESSFUL) |
|
347 | if (status != RTEMS_SUCCESSFUL) | |
347 | { |
|
348 | { | |
348 | PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status); |
|
349 | PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status); | |
349 | } |
|
350 | } | |
350 |
|
351 | |||
351 | BOOT_PRINTF("in WFRM ***\n"); |
|
352 | BOOT_PRINTF("in WFRM ***\n"); | |
352 |
|
353 | |||
353 | while(1){ |
|
354 | while(1){ | |
354 | // wait for an RTEMS_EVENT |
|
355 | // wait for an RTEMS_EVENT | |
355 | rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_SWF_RESYNCH, |
|
356 | rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_SWF_RESYNCH, | |
356 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
357 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
357 |
|
358 | |||
358 | if (event_out == RTEMS_EVENT_MODE_NORMAL) |
|
359 | if (event_out == RTEMS_EVENT_MODE_NORMAL) | |
359 | { |
|
360 | { | |
360 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n"); |
|
361 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n"); | |
361 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; |
|
362 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; | |
362 | ring_node_swf1_extracted_ptr->sid = SID_NORM_SWF_F1; |
|
363 | ring_node_swf1_extracted_ptr->sid = SID_NORM_SWF_F1; | |
363 | ring_node_swf2_extracted_ptr->sid = SID_NORM_SWF_F2; |
|
364 | ring_node_swf2_extracted_ptr->sid = SID_NORM_SWF_F2; | |
364 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); |
|
365 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); | |
365 | status = rtems_message_queue_send( queue_id, &ring_node_swf1_extracted_ptr, sizeof( ring_node* ) ); |
|
366 | status = rtems_message_queue_send( queue_id, &ring_node_swf1_extracted_ptr, sizeof( ring_node* ) ); | |
366 | status = rtems_message_queue_send( queue_id, &ring_node_swf2_extracted_ptr, sizeof( ring_node* ) ); |
|
367 | status = rtems_message_queue_send( queue_id, &ring_node_swf2_extracted_ptr, sizeof( ring_node* ) ); | |
367 | } |
|
368 | } | |
368 | if (event_out == RTEMS_EVENT_SWF_RESYNCH) |
|
369 | if (event_out == RTEMS_EVENT_SWF_RESYNCH) | |
369 | { |
|
370 | { | |
370 | snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); |
|
371 | snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); | |
371 | } |
|
372 | } | |
372 | } |
|
373 | } | |
373 | } |
|
374 | } | |
374 |
|
375 | |||
375 | rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
376 | rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP | |
376 | { |
|
377 | { | |
377 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3. |
|
378 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3. | |
378 | * |
|
379 | * | |
379 | * @param unused is the starting argument of the RTEMS task |
|
380 | * @param unused is the starting argument of the RTEMS task | |
380 | * |
|
381 | * | |
381 | * The following data packet is sent by this task: |
|
382 | * The following data packet is sent by this task: | |
382 | * - TM_LFR_SCIENCE_NORMAL_CWF_F3 |
|
383 | * - TM_LFR_SCIENCE_NORMAL_CWF_F3 | |
383 | * |
|
384 | * | |
384 | */ |
|
385 | */ | |
385 |
|
386 | |||
386 | rtems_event_set event_out; |
|
387 | rtems_event_set event_out; | |
387 | rtems_id queue_id; |
|
388 | rtems_id queue_id; | |
388 | rtems_status_code status; |
|
389 | rtems_status_code status; | |
389 | ring_node ring_node_cwf3_light; |
|
390 | ring_node ring_node_cwf3_light; | |
390 | ring_node *ring_node_to_send_cwf; |
|
391 | ring_node *ring_node_to_send_cwf; | |
391 |
|
392 | |||
392 | event_out = EVENT_SETS_NONE_PENDING; |
|
393 | event_out = EVENT_SETS_NONE_PENDING; | |
393 | queue_id = RTEMS_ID_NONE; |
|
394 | queue_id = RTEMS_ID_NONE; | |
394 |
|
395 | |||
395 | status = get_message_queue_id_send( &queue_id ); |
|
396 | status = get_message_queue_id_send( &queue_id ); | |
396 | if (status != RTEMS_SUCCESSFUL) |
|
397 | if (status != RTEMS_SUCCESSFUL) | |
397 | { |
|
398 | { | |
398 | PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status) |
|
399 | PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status) | |
399 | } |
|
400 | } | |
400 |
|
401 | |||
401 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; |
|
402 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; | |
402 |
|
403 | |||
403 | // init the ring_node_cwf3_light structure |
|
404 | // init the ring_node_cwf3_light structure | |
404 | ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light; |
|
405 | ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light; | |
405 | ring_node_cwf3_light.coarseTime = INIT_CHAR; |
|
406 | ring_node_cwf3_light.coarseTime = INIT_CHAR; | |
406 | ring_node_cwf3_light.fineTime = INIT_CHAR; |
|
407 | ring_node_cwf3_light.fineTime = INIT_CHAR; | |
407 | ring_node_cwf3_light.next = NULL; |
|
408 | ring_node_cwf3_light.next = NULL; | |
408 | ring_node_cwf3_light.previous = NULL; |
|
409 | ring_node_cwf3_light.previous = NULL; | |
409 | ring_node_cwf3_light.sid = SID_NORM_CWF_F3; |
|
410 | ring_node_cwf3_light.sid = SID_NORM_CWF_F3; | |
410 | ring_node_cwf3_light.status = INIT_CHAR; |
|
411 | ring_node_cwf3_light.status = INIT_CHAR; | |
411 |
|
412 | |||
412 | BOOT_PRINTF("in CWF3 ***\n"); |
|
413 | BOOT_PRINTF("in CWF3 ***\n"); | |
413 |
|
414 | |||
414 | while(1){ |
|
415 | while(1){ | |
415 | // wait for an RTEMS_EVENT |
|
416 | // wait for an RTEMS_EVENT | |
416 | rtems_event_receive( RTEMS_EVENT_0, |
|
417 | rtems_event_receive( RTEMS_EVENT_0, | |
417 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
418 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
418 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
419 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
419 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) ) |
|
420 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) ) | |
420 | { |
|
421 | { | |
421 | ring_node_to_send_cwf = getRingNodeToSendCWF( CHANNELF3 ); |
|
422 | ring_node_to_send_cwf = getRingNodeToSendCWF( CHANNELF3 ); | |
422 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & BIT_CWF_LONG_F3) == BIT_CWF_LONG_F3) |
|
423 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & BIT_CWF_LONG_F3) == BIT_CWF_LONG_F3) | |
423 | { |
|
424 | { | |
424 | PRINTF("send CWF_LONG_F3\n"); |
|
425 | PRINTF("send CWF_LONG_F3\n"); | |
425 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; |
|
426 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; | |
426 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); |
|
427 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); | |
427 | } |
|
428 | } | |
428 | else |
|
429 | else | |
429 | { |
|
430 | { | |
430 | PRINTF("send CWF_F3 (light)\n"); |
|
431 | PRINTF("send CWF_F3 (light)\n"); | |
431 | send_waveform_CWF3_light( ring_node_to_send_cwf, &ring_node_cwf3_light, queue_id ); |
|
432 | send_waveform_CWF3_light( ring_node_to_send_cwf, &ring_node_cwf3_light, queue_id ); | |
432 | } |
|
433 | } | |
433 |
|
434 | |||
434 | } |
|
435 | } | |
435 | else |
|
436 | else | |
436 | { |
|
437 | { | |
437 | PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode) |
|
438 | PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode) | |
438 | } |
|
439 | } | |
439 | } |
|
440 | } | |
440 | } |
|
441 | } | |
441 |
|
442 | |||
442 | rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2 |
|
443 | rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2 | |
443 | { |
|
444 | { | |
444 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2. |
|
445 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2. | |
445 | * |
|
446 | * | |
446 | * @param unused is the starting argument of the RTEMS task |
|
447 | * @param unused is the starting argument of the RTEMS task | |
447 | * |
|
448 | * | |
448 | * The following data packet is sent by this function: |
|
449 | * The following data packet is sent by this function: | |
449 | * - TM_LFR_SCIENCE_BURST_CWF_F2 |
|
450 | * - TM_LFR_SCIENCE_BURST_CWF_F2 | |
450 | * - TM_LFR_SCIENCE_SBM2_CWF_F2 |
|
451 | * - TM_LFR_SCIENCE_SBM2_CWF_F2 | |
451 | * |
|
452 | * | |
452 | */ |
|
453 | */ | |
453 |
|
454 | |||
454 | rtems_event_set event_out; |
|
455 | rtems_event_set event_out; | |
455 | rtems_id queue_id; |
|
456 | rtems_id queue_id; | |
456 | rtems_status_code status; |
|
457 | rtems_status_code status; | |
457 | ring_node *ring_node_to_send; |
|
458 | ring_node *ring_node_to_send; | |
458 | unsigned long long int acquisitionTimeF0_asLong; |
|
459 | unsigned long long int acquisitionTimeF0_asLong; | |
459 |
|
460 | |||
460 | event_out = EVENT_SETS_NONE_PENDING; |
|
461 | event_out = EVENT_SETS_NONE_PENDING; | |
461 | queue_id = RTEMS_ID_NONE; |
|
462 | queue_id = RTEMS_ID_NONE; | |
462 |
|
463 | |||
463 | acquisitionTimeF0_asLong = INIT_CHAR; |
|
464 | acquisitionTimeF0_asLong = INIT_CHAR; | |
464 |
|
465 | |||
465 | status = get_message_queue_id_send( &queue_id ); |
|
466 | status = get_message_queue_id_send( &queue_id ); | |
466 | if (status != RTEMS_SUCCESSFUL) |
|
467 | if (status != RTEMS_SUCCESSFUL) | |
467 | { |
|
468 | { | |
468 | PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status) |
|
469 | PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status) | |
469 | } |
|
470 | } | |
470 |
|
471 | |||
471 | BOOT_PRINTF("in CWF2 ***\n"); |
|
472 | BOOT_PRINTF("in CWF2 ***\n"); | |
472 |
|
473 | |||
473 | while(1){ |
|
474 | while(1){ | |
474 | // wait for an RTEMS_EVENT// send the snapshot when built |
|
475 | // wait for an RTEMS_EVENT// send the snapshot when built | |
475 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ); |
|
476 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ); | |
476 | rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2 | RTEMS_EVENT_MODE_BURST, |
|
477 | rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2 | RTEMS_EVENT_MODE_BURST, | |
477 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
478 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
478 | ring_node_to_send = getRingNodeToSendCWF( CHANNELF2 ); |
|
479 | ring_node_to_send = getRingNodeToSendCWF( CHANNELF2 ); | |
479 | if (event_out == RTEMS_EVENT_MODE_BURST) |
|
480 | if (event_out == RTEMS_EVENT_MODE_BURST) | |
480 | { // data are sent whatever the transition time |
|
481 | { // data are sent whatever the transition time | |
481 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); |
|
482 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); | |
482 | } |
|
483 | } | |
483 | else if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2) |
|
484 | else if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2) | |
484 | { |
|
485 | { | |
485 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) |
|
486 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) | |
486 | { |
|
487 | { | |
487 | // data are sent depending on the transition time |
|
488 | // data are sent depending on the transition time | |
488 | if ( time_management_regs->coarse_time >= lastValidEnterModeTime) |
|
489 | if ( time_management_regs->coarse_time >= lastValidEnterModeTime) | |
489 | { |
|
490 | { | |
490 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); |
|
491 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); | |
491 | } |
|
492 | } | |
492 | } |
|
493 | } | |
493 | // launch snapshot extraction if needed |
|
494 | // launch snapshot extraction if needed | |
494 | if (extractSWF2 == true) |
|
495 | if (extractSWF2 == true) | |
495 | { |
|
496 | { | |
496 | ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2; |
|
497 | ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2; | |
497 | // extract the snapshot |
|
498 | // extract the snapshot | |
498 | build_snapshot_from_ring( ring_node_to_send_swf_f2, CHANNELF2, acquisitionTimeF0_asLong, |
|
499 | build_snapshot_from_ring( ring_node_to_send_swf_f2, CHANNELF2, acquisitionTimeF0_asLong, | |
499 | &ring_node_swf2_extracted, swf2_extracted ); |
|
500 | &ring_node_swf2_extracted, swf2_extracted ); | |
500 | extractSWF2 = false; |
|
501 | extractSWF2 = false; | |
501 | swf2_ready = true; // once the snapshot at f2 is ready the CWF1 task will send an event to WFRM |
|
502 | swf2_ready = true; // once the snapshot at f2 is ready the CWF1 task will send an event to WFRM | |
502 | } |
|
503 | } | |
503 | if (swf0_ready_flag_f2 == true) |
|
504 | if (swf0_ready_flag_f2 == true) | |
504 | { |
|
505 | { | |
505 | extractSWF2 = true; |
|
506 | extractSWF2 = true; | |
506 | // record the acquition time of the f0 snapshot to use to build the snapshot at f2 |
|
507 | // record the acquition time of the f0 snapshot to use to build the snapshot at f2 | |
507 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); |
|
508 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); | |
508 | swf0_ready_flag_f2 = false; |
|
509 | swf0_ready_flag_f2 = false; | |
509 | } |
|
510 | } | |
510 | } |
|
511 | } | |
511 | } |
|
512 | } | |
512 | } |
|
513 | } | |
513 |
|
514 | |||
514 | rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1 |
|
515 | rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1 | |
515 | { |
|
516 | { | |
516 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1. |
|
517 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1. | |
517 | * |
|
518 | * | |
518 | * @param unused is the starting argument of the RTEMS task |
|
519 | * @param unused is the starting argument of the RTEMS task | |
519 | * |
|
520 | * | |
520 | * The following data packet is sent by this function: |
|
521 | * The following data packet is sent by this function: | |
521 | * - TM_LFR_SCIENCE_SBM1_CWF_F1 |
|
522 | * - TM_LFR_SCIENCE_SBM1_CWF_F1 | |
522 | * |
|
523 | * | |
523 | */ |
|
524 | */ | |
524 |
|
525 | |||
525 | rtems_event_set event_out; |
|
526 | rtems_event_set event_out; | |
526 | rtems_id queue_id; |
|
527 | rtems_id queue_id; | |
527 | rtems_status_code status; |
|
528 | rtems_status_code status; | |
528 |
|
529 | |||
529 | ring_node *ring_node_to_send_cwf; |
|
530 | ring_node *ring_node_to_send_cwf; | |
530 |
|
531 | |||
531 | event_out = EVENT_SETS_NONE_PENDING; |
|
532 | event_out = EVENT_SETS_NONE_PENDING; | |
532 | queue_id = RTEMS_ID_NONE; |
|
533 | queue_id = RTEMS_ID_NONE; | |
533 |
|
534 | |||
534 | status = get_message_queue_id_send( &queue_id ); |
|
535 | status = get_message_queue_id_send( &queue_id ); | |
535 | if (status != RTEMS_SUCCESSFUL) |
|
536 | if (status != RTEMS_SUCCESSFUL) | |
536 | { |
|
537 | { | |
537 | PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status) |
|
538 | PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status) | |
538 | } |
|
539 | } | |
539 |
|
540 | |||
540 | BOOT_PRINTF("in CWF1 ***\n"); |
|
541 | BOOT_PRINTF("in CWF1 ***\n"); | |
541 |
|
542 | |||
542 | while(1){ |
|
543 | while(1){ | |
543 | // wait for an RTEMS_EVENT |
|
544 | // wait for an RTEMS_EVENT | |
544 | rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2, |
|
545 | rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2, | |
545 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
546 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
546 | ring_node_to_send_cwf = getRingNodeToSendCWF( 1 ); |
|
547 | ring_node_to_send_cwf = getRingNodeToSendCWF( 1 ); | |
547 | ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1; |
|
548 | ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1; | |
548 | if (lfrCurrentMode == LFR_MODE_SBM1) |
|
549 | if (lfrCurrentMode == LFR_MODE_SBM1) | |
549 | { |
|
550 | { | |
550 | // data are sent depending on the transition time |
|
551 | // data are sent depending on the transition time | |
551 | if ( time_management_regs->coarse_time >= lastValidEnterModeTime ) |
|
552 | if ( time_management_regs->coarse_time >= lastValidEnterModeTime ) | |
552 | { |
|
553 | { | |
553 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); |
|
554 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); | |
554 | } |
|
555 | } | |
555 | } |
|
556 | } | |
556 | // launch snapshot extraction if needed |
|
557 | // launch snapshot extraction if needed | |
557 | if (extractSWF1 == true) |
|
558 | if (extractSWF1 == true) | |
558 | { |
|
559 | { | |
559 | ring_node_to_send_swf_f1 = ring_node_to_send_cwf; |
|
560 | ring_node_to_send_swf_f1 = ring_node_to_send_cwf; | |
560 | // launch the snapshot extraction |
|
561 | // launch the snapshot extraction | |
561 | status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_NORM_S1_S2 ); |
|
562 | status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_NORM_S1_S2 ); | |
562 | extractSWF1 = false; |
|
563 | extractSWF1 = false; | |
563 | } |
|
564 | } | |
564 | if (swf0_ready_flag_f1 == true) |
|
565 | if (swf0_ready_flag_f1 == true) | |
565 | { |
|
566 | { | |
566 | extractSWF1 = true; |
|
567 | extractSWF1 = true; | |
567 | swf0_ready_flag_f1 = false; // this step shall be executed only one time |
|
568 | swf0_ready_flag_f1 = false; // this step shall be executed only one time | |
568 | } |
|
569 | } | |
569 | if ((swf1_ready == true) && (swf2_ready == true)) // swf_f1 is ready after the extraction |
|
570 | if ((swf1_ready == true) && (swf2_ready == true)) // swf_f1 is ready after the extraction | |
570 | { |
|
571 | { | |
571 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ); |
|
572 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ); | |
572 | swf1_ready = false; |
|
573 | swf1_ready = false; | |
573 | swf2_ready = false; |
|
574 | swf2_ready = false; | |
574 | } |
|
575 | } | |
575 | } |
|
576 | } | |
576 | } |
|
577 | } | |
577 |
|
578 | |||
578 | rtems_task swbd_task(rtems_task_argument argument) |
|
579 | rtems_task swbd_task(rtems_task_argument argument) | |
579 | { |
|
580 | { | |
580 | /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers. |
|
581 | /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers. | |
581 | * |
|
582 | * | |
582 | * @param unused is the starting argument of the RTEMS task |
|
583 | * @param unused is the starting argument of the RTEMS task | |
583 | * |
|
584 | * | |
584 | */ |
|
585 | */ | |
585 |
|
586 | |||
586 | rtems_event_set event_out; |
|
587 | rtems_event_set event_out; | |
587 | unsigned long long int acquisitionTimeF0_asLong; |
|
588 | unsigned long long int acquisitionTimeF0_asLong; | |
588 |
|
589 | |||
589 | event_out = EVENT_SETS_NONE_PENDING; |
|
590 | event_out = EVENT_SETS_NONE_PENDING; | |
590 | acquisitionTimeF0_asLong = INIT_CHAR; |
|
591 | acquisitionTimeF0_asLong = INIT_CHAR; | |
591 |
|
592 | |||
592 | BOOT_PRINTF("in SWBD ***\n") |
|
593 | BOOT_PRINTF("in SWBD ***\n") | |
593 |
|
594 | |||
594 | while(1){ |
|
595 | while(1){ | |
595 | // wait for an RTEMS_EVENT |
|
596 | // wait for an RTEMS_EVENT | |
596 | rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2, |
|
597 | rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2, | |
597 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
598 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
598 | if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2) |
|
599 | if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2) | |
599 | { |
|
600 | { | |
600 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); |
|
601 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); | |
601 | build_snapshot_from_ring( ring_node_to_send_swf_f1, CHANNELF1, acquisitionTimeF0_asLong, |
|
602 | build_snapshot_from_ring( ring_node_to_send_swf_f1, CHANNELF1, acquisitionTimeF0_asLong, | |
602 | &ring_node_swf1_extracted, swf1_extracted ); |
|
603 | &ring_node_swf1_extracted, swf1_extracted ); | |
603 | swf1_ready = true; // the snapshot has been extracted and is ready to be sent |
|
604 | swf1_ready = true; // the snapshot has been extracted and is ready to be sent | |
604 | } |
|
605 | } | |
605 | else |
|
606 | else | |
606 | { |
|
607 | { | |
607 | PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out) |
|
608 | PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out) | |
608 | } |
|
609 | } | |
609 | } |
|
610 | } | |
610 | } |
|
611 | } | |
611 |
|
612 | |||
612 | //****************** |
|
613 | //****************** | |
613 | // general functions |
|
614 | // general functions | |
614 |
|
615 | |||
615 | void WFP_init_rings( void ) |
|
616 | void WFP_init_rings( void ) | |
616 | { |
|
617 | { | |
617 | // F0 RING |
|
618 | // F0 RING | |
618 | init_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_buffer_f0, WFRM_BUFFER ); |
|
619 | init_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_buffer_f0, WFRM_BUFFER ); | |
619 | // F1 RING |
|
620 | // F1 RING | |
620 | init_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_buffer_f1, WFRM_BUFFER ); |
|
621 | init_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_buffer_f1, WFRM_BUFFER ); | |
621 | // F2 RING |
|
622 | // F2 RING | |
622 | init_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_buffer_f2, WFRM_BUFFER ); |
|
623 | init_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_buffer_f2, WFRM_BUFFER ); | |
623 | // F3 RING |
|
624 | // F3 RING | |
624 | init_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_buffer_f3, WFRM_BUFFER ); |
|
625 | init_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_buffer_f3, WFRM_BUFFER ); | |
625 |
|
626 | |||
626 | ring_node_swf1_extracted.buffer_address = (int) swf1_extracted; |
|
627 | ring_node_swf1_extracted.buffer_address = (int) swf1_extracted; | |
627 | ring_node_swf2_extracted.buffer_address = (int) swf2_extracted; |
|
628 | ring_node_swf2_extracted.buffer_address = (int) swf2_extracted; | |
628 |
|
629 | |||
629 | DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0) |
|
630 | DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0) | |
630 | DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1) |
|
631 | DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1) | |
631 | DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2) |
|
632 | DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2) | |
632 | DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3) |
|
633 | DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3) | |
633 | DEBUG_PRINTF1("wf_buffer_f0 @%x\n", (unsigned int) wf_buffer_f0) |
|
634 | DEBUG_PRINTF1("wf_buffer_f0 @%x\n", (unsigned int) wf_buffer_f0) | |
634 | DEBUG_PRINTF1("wf_buffer_f1 @%x\n", (unsigned int) wf_buffer_f1) |
|
635 | DEBUG_PRINTF1("wf_buffer_f1 @%x\n", (unsigned int) wf_buffer_f1) | |
635 | DEBUG_PRINTF1("wf_buffer_f2 @%x\n", (unsigned int) wf_buffer_f2) |
|
636 | DEBUG_PRINTF1("wf_buffer_f2 @%x\n", (unsigned int) wf_buffer_f2) | |
636 | DEBUG_PRINTF1("wf_buffer_f3 @%x\n", (unsigned int) wf_buffer_f3) |
|
637 | DEBUG_PRINTF1("wf_buffer_f3 @%x\n", (unsigned int) wf_buffer_f3) | |
637 |
|
638 | |||
638 | } |
|
639 | } | |
639 |
|
640 | |||
640 | void WFP_reset_current_ring_nodes( void ) |
|
641 | void WFP_reset_current_ring_nodes( void ) | |
641 | { |
|
642 | { | |
642 | current_ring_node_f0 = waveform_ring_f0[0].next; |
|
643 | current_ring_node_f0 = waveform_ring_f0[0].next; | |
643 | current_ring_node_f1 = waveform_ring_f1[0].next; |
|
644 | current_ring_node_f1 = waveform_ring_f1[0].next; | |
644 | current_ring_node_f2 = waveform_ring_f2[0].next; |
|
645 | current_ring_node_f2 = waveform_ring_f2[0].next; | |
645 | current_ring_node_f3 = waveform_ring_f3[0].next; |
|
646 | current_ring_node_f3 = waveform_ring_f3[0].next; | |
646 |
|
647 | |||
647 | ring_node_to_send_swf_f0 = waveform_ring_f0; |
|
648 | ring_node_to_send_swf_f0 = waveform_ring_f0; | |
648 | ring_node_to_send_swf_f1 = waveform_ring_f1; |
|
649 | ring_node_to_send_swf_f1 = waveform_ring_f1; | |
649 | ring_node_to_send_swf_f2 = waveform_ring_f2; |
|
650 | ring_node_to_send_swf_f2 = waveform_ring_f2; | |
650 |
|
651 | |||
651 | ring_node_to_send_cwf_f1 = waveform_ring_f1; |
|
652 | ring_node_to_send_cwf_f1 = waveform_ring_f1; | |
652 | ring_node_to_send_cwf_f2 = waveform_ring_f2; |
|
653 | ring_node_to_send_cwf_f2 = waveform_ring_f2; | |
653 | ring_node_to_send_cwf_f3 = waveform_ring_f3; |
|
654 | ring_node_to_send_cwf_f3 = waveform_ring_f3; | |
654 | } |
|
655 | } | |
655 |
|
656 | |||
656 | int send_waveform_CWF3_light( ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id ) |
|
657 | int send_waveform_CWF3_light( ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id ) | |
657 | { |
|
658 | { | |
658 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. |
|
659 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. | |
659 | * |
|
660 | * | |
660 | * @param waveform points to the buffer containing the data that will be send. |
|
661 | * @param waveform points to the buffer containing the data that will be send. | |
661 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
662 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
662 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
663 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
663 | * contain information to setup the transmission of the data packets. |
|
664 | * contain information to setup the transmission of the data packets. | |
664 | * |
|
665 | * | |
665 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer |
|
666 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer | |
666 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. |
|
667 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. | |
667 | * |
|
668 | * | |
668 | */ |
|
669 | */ | |
669 |
|
670 | |||
670 | unsigned int i; |
|
671 | unsigned int i; | |
671 | unsigned int j; |
|
672 | unsigned int j; | |
672 | int ret; |
|
673 | int ret; | |
673 | rtems_status_code status; |
|
674 | rtems_status_code status; | |
674 |
|
675 | |||
675 | char *sample; |
|
676 | char *sample; | |
676 | int *dataPtr; |
|
677 | int *dataPtr; | |
677 |
|
678 | |||
678 | ret = LFR_DEFAULT; |
|
679 | ret = LFR_DEFAULT; | |
679 |
|
680 | |||
680 | dataPtr = (int*) ring_node_to_send->buffer_address; |
|
681 | dataPtr = (int*) ring_node_to_send->buffer_address; | |
681 |
|
682 | |||
682 | ring_node_cwf3_light->coarseTime = ring_node_to_send->coarseTime; |
|
683 | ring_node_cwf3_light->coarseTime = ring_node_to_send->coarseTime; | |
683 | ring_node_cwf3_light->fineTime = ring_node_to_send->fineTime; |
|
684 | ring_node_cwf3_light->fineTime = ring_node_to_send->fineTime; | |
684 |
|
685 | |||
685 | //********************** |
|
686 | //********************** | |
686 | // BUILD CWF3_light DATA |
|
687 | // BUILD CWF3_light DATA | |
687 | for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) |
|
688 | for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) | |
688 | { |
|
689 | { | |
689 | sample = (char*) &dataPtr[ (i * NB_WORDS_SWF_BLK) ]; |
|
690 | sample = (char*) &dataPtr[ (i * NB_WORDS_SWF_BLK) ]; | |
690 | for (j=0; j < CWF_BLK_SIZE; j++) |
|
691 | for (j=0; j < CWF_BLK_SIZE; j++) | |
691 | { |
|
692 | { | |
692 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + j] = sample[ j ]; |
|
693 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + j] = sample[ j ]; | |
693 | } |
|
694 | } | |
694 | } |
|
695 | } | |
695 |
|
696 | |||
696 | // SEND PACKET |
|
697 | // SEND PACKET | |
697 | status = rtems_message_queue_send( queue_id, &ring_node_cwf3_light, sizeof( ring_node* ) ); |
|
698 | status = rtems_message_queue_send( queue_id, &ring_node_cwf3_light, sizeof( ring_node* ) ); | |
698 | if (status != RTEMS_SUCCESSFUL) { |
|
699 | if (status != RTEMS_SUCCESSFUL) { | |
699 | ret = LFR_DEFAULT; |
|
700 | ret = LFR_DEFAULT; | |
700 | } |
|
701 | } | |
701 |
|
702 | |||
702 | return ret; |
|
703 | return ret; | |
703 | } |
|
704 | } | |
704 |
|
705 | |||
705 | void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime, |
|
706 | void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime, | |
706 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime ) |
|
707 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime ) | |
707 | { |
|
708 | { | |
708 | unsigned long long int acquisitionTimeAsLong; |
|
709 | unsigned long long int acquisitionTimeAsLong; | |
709 | unsigned char localAcquisitionTime[BYTES_PER_TIME]; |
|
710 | unsigned char localAcquisitionTime[BYTES_PER_TIME]; | |
710 | double deltaT; |
|
711 | double deltaT; | |
711 |
|
712 | |||
712 | deltaT = INIT_FLOAT; |
|
713 | deltaT = INIT_FLOAT; | |
713 |
|
714 | |||
714 | localAcquisitionTime[BYTE_0] = (unsigned char) ( coarseTime >> SHIFT_3_BYTES ); |
|
715 | localAcquisitionTime[BYTE_0] = (unsigned char) ( coarseTime >> SHIFT_3_BYTES ); | |
715 | localAcquisitionTime[BYTE_1] = (unsigned char) ( coarseTime >> SHIFT_2_BYTES ); |
|
716 | localAcquisitionTime[BYTE_1] = (unsigned char) ( coarseTime >> SHIFT_2_BYTES ); | |
716 | localAcquisitionTime[BYTE_2] = (unsigned char) ( coarseTime >> SHIFT_1_BYTE ); |
|
717 | localAcquisitionTime[BYTE_2] = (unsigned char) ( coarseTime >> SHIFT_1_BYTE ); | |
717 | localAcquisitionTime[BYTE_3] = (unsigned char) ( coarseTime ); |
|
718 | localAcquisitionTime[BYTE_3] = (unsigned char) ( coarseTime ); | |
718 | localAcquisitionTime[BYTE_4] = (unsigned char) ( fineTime >> SHIFT_1_BYTE ); |
|
719 | localAcquisitionTime[BYTE_4] = (unsigned char) ( fineTime >> SHIFT_1_BYTE ); | |
719 | localAcquisitionTime[BYTE_5] = (unsigned char) ( fineTime ); |
|
720 | localAcquisitionTime[BYTE_5] = (unsigned char) ( fineTime ); | |
720 |
|
721 | |||
721 | acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[BYTE_0] << SHIFT_5_BYTES ) |
|
722 | acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[BYTE_0] << SHIFT_5_BYTES ) | |
722 | + ( (unsigned long long int) localAcquisitionTime[BYTE_1] << SHIFT_4_BYTES ) |
|
723 | + ( (unsigned long long int) localAcquisitionTime[BYTE_1] << SHIFT_4_BYTES ) | |
723 | + ( (unsigned long long int) localAcquisitionTime[BYTE_2] << SHIFT_3_BYTES ) |
|
724 | + ( (unsigned long long int) localAcquisitionTime[BYTE_2] << SHIFT_3_BYTES ) | |
724 | + ( (unsigned long long int) localAcquisitionTime[BYTE_3] << SHIFT_2_BYTES ) |
|
725 | + ( (unsigned long long int) localAcquisitionTime[BYTE_3] << SHIFT_2_BYTES ) | |
725 | + ( (unsigned long long int) localAcquisitionTime[BYTE_4] << SHIFT_1_BYTE ) |
|
726 | + ( (unsigned long long int) localAcquisitionTime[BYTE_4] << SHIFT_1_BYTE ) | |
726 | + ( (unsigned long long int) localAcquisitionTime[BYTE_5] ); |
|
727 | + ( (unsigned long long int) localAcquisitionTime[BYTE_5] ); | |
727 |
|
728 | |||
728 | switch( sid ) |
|
729 | switch( sid ) | |
729 | { |
|
730 | { | |
730 | case SID_NORM_SWF_F0: |
|
731 | case SID_NORM_SWF_F0: | |
731 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * T0_IN_FINETIME ; |
|
732 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * T0_IN_FINETIME ; | |
732 | break; |
|
733 | break; | |
733 |
|
734 | |||
734 | case SID_NORM_SWF_F1: |
|
735 | case SID_NORM_SWF_F1: | |
735 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * T1_IN_FINETIME ; |
|
736 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * T1_IN_FINETIME ; | |
736 | break; |
|
737 | break; | |
737 |
|
738 | |||
738 | case SID_NORM_SWF_F2: |
|
739 | case SID_NORM_SWF_F2: | |
739 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * T2_IN_FINETIME ; |
|
740 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * T2_IN_FINETIME ; | |
740 | break; |
|
741 | break; | |
741 |
|
742 | |||
742 | case SID_SBM1_CWF_F1: |
|
743 | case SID_SBM1_CWF_F1: | |
743 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T1_IN_FINETIME ; |
|
744 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T1_IN_FINETIME ; | |
744 | break; |
|
745 | break; | |
745 |
|
746 | |||
746 | case SID_SBM2_CWF_F2: |
|
747 | case SID_SBM2_CWF_F2: | |
747 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T2_IN_FINETIME ; |
|
748 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T2_IN_FINETIME ; | |
748 | break; |
|
749 | break; | |
749 |
|
750 | |||
750 | case SID_BURST_CWF_F2: |
|
751 | case SID_BURST_CWF_F2: | |
751 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T2_IN_FINETIME ; |
|
752 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T2_IN_FINETIME ; | |
752 | break; |
|
753 | break; | |
753 |
|
754 | |||
754 | case SID_NORM_CWF_F3: |
|
755 | case SID_NORM_CWF_F3: | |
755 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * T3_IN_FINETIME ; |
|
756 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * T3_IN_FINETIME ; | |
756 | break; |
|
757 | break; | |
757 |
|
758 | |||
758 | case SID_NORM_CWF_LONG_F3: |
|
759 | case SID_NORM_CWF_LONG_F3: | |
759 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T3_IN_FINETIME ; |
|
760 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * T3_IN_FINETIME ; | |
760 | break; |
|
761 | break; | |
761 |
|
762 | |||
762 | default: |
|
763 | default: | |
763 | PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d\n", sid) |
|
764 | PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d\n", sid) | |
764 | deltaT = 0.; |
|
765 | deltaT = 0.; | |
765 | break; |
|
766 | break; | |
766 | } |
|
767 | } | |
767 |
|
768 | |||
768 | acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT; |
|
769 | acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT; | |
769 | // |
|
770 | // | |
770 | acquisitionTime[BYTE_0] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_5_BYTES); |
|
771 | acquisitionTime[BYTE_0] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_5_BYTES); | |
771 | acquisitionTime[BYTE_1] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_4_BYTES); |
|
772 | acquisitionTime[BYTE_1] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_4_BYTES); | |
772 | acquisitionTime[BYTE_2] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_3_BYTES); |
|
773 | acquisitionTime[BYTE_2] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_3_BYTES); | |
773 | acquisitionTime[BYTE_3] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_2_BYTES); |
|
774 | acquisitionTime[BYTE_3] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_2_BYTES); | |
774 | acquisitionTime[BYTE_4] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_1_BYTE ); |
|
775 | acquisitionTime[BYTE_4] = (unsigned char) (acquisitionTimeAsLong >> SHIFT_1_BYTE ); | |
775 | acquisitionTime[BYTE_5] = (unsigned char) (acquisitionTimeAsLong ); |
|
776 | acquisitionTime[BYTE_5] = (unsigned char) (acquisitionTimeAsLong ); | |
776 |
|
777 | |||
777 | } |
|
778 | } | |
778 |
|
779 | |||
779 | void build_snapshot_from_ring( ring_node *ring_node_to_send, |
|
780 | void build_snapshot_from_ring( ring_node *ring_node_to_send, | |
780 | unsigned char frequencyChannel, |
|
781 | unsigned char frequencyChannel, | |
781 | unsigned long long int acquisitionTimeF0_asLong, |
|
782 | unsigned long long int acquisitionTimeF0_asLong, | |
782 | ring_node *ring_node_swf_extracted, |
|
783 | ring_node *ring_node_swf_extracted, | |
783 | int *swf_extracted) |
|
784 | int *swf_extracted) | |
784 | { |
|
785 | { | |
785 | unsigned int i; |
|
786 | unsigned int i; | |
786 | unsigned int node; |
|
787 | unsigned int node; | |
787 | unsigned long long int centerTime_asLong; |
|
788 | unsigned long long int centerTime_asLong; | |
788 | unsigned long long int acquisitionTime_asLong; |
|
789 | unsigned long long int acquisitionTime_asLong; | |
789 | unsigned long long int bufferAcquisitionTime_asLong; |
|
790 | unsigned long long int bufferAcquisitionTime_asLong; | |
790 | unsigned char *ptr1; |
|
791 | unsigned char *ptr1; | |
791 | unsigned char *ptr2; |
|
792 | unsigned char *ptr2; | |
792 | unsigned char *timeCharPtr; |
|
793 | unsigned char *timeCharPtr; | |
793 | unsigned char nb_ring_nodes; |
|
794 | unsigned char nb_ring_nodes; | |
794 | unsigned long long int frequency_asLong; |
|
795 | unsigned long long int frequency_asLong; | |
795 | unsigned long long int nbTicksPerSample_asLong; |
|
796 | unsigned long long int nbTicksPerSample_asLong; | |
796 | unsigned long long int nbSamplesPart1_asLong; |
|
797 | unsigned long long int nbSamplesPart1_asLong; | |
797 | unsigned long long int sampleOffset_asLong; |
|
798 | unsigned long long int sampleOffset_asLong; | |
798 |
|
799 | |||
799 | unsigned int deltaT_F0; |
|
800 | unsigned int deltaT_F0; | |
800 | unsigned int deltaT_F1; |
|
801 | unsigned int deltaT_F1; | |
801 | unsigned long long int deltaT_F2; |
|
802 | unsigned long long int deltaT_F2; | |
802 |
|
803 | |||
803 | deltaT_F0 = DELTAT_F0; |
|
804 | deltaT_F0 = DELTAT_F0; | |
804 | deltaT_F1 = DELTAT_F1; |
|
805 | deltaT_F1 = DELTAT_F1; | |
805 | deltaT_F2 = DELTAT_F2; |
|
806 | deltaT_F2 = DELTAT_F2; | |
806 | sampleOffset_asLong = INIT_CHAR; |
|
807 | sampleOffset_asLong = INIT_CHAR; | |
807 |
|
808 | |||
808 | // (1) get the f0 acquisition time => the value is passed in argument |
|
809 | // (1) get the f0 acquisition time => the value is passed in argument | |
809 |
|
810 | |||
810 | // (2) compute the central reference time |
|
811 | // (2) compute the central reference time | |
811 | centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0; |
|
812 | centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0; | |
812 | acquisitionTime_asLong = centerTime_asLong; //set to default value (Don_Initialisation_P2) |
|
813 | acquisitionTime_asLong = centerTime_asLong; //set to default value (Don_Initialisation_P2) | |
813 | bufferAcquisitionTime_asLong = centerTime_asLong; //set to default value (Don_Initialisation_P2) |
|
814 | bufferAcquisitionTime_asLong = centerTime_asLong; //set to default value (Don_Initialisation_P2) | |
814 | nbTicksPerSample_asLong = TICKS_PER_T2; //set to default value (Don_Initialisation_P2) |
|
815 | nbTicksPerSample_asLong = TICKS_PER_T2; //set to default value (Don_Initialisation_P2) | |
815 |
|
816 | |||
816 | // (3) compute the acquisition time of the current snapshot |
|
817 | // (3) compute the acquisition time of the current snapshot | |
817 | switch(frequencyChannel) |
|
818 | switch(frequencyChannel) | |
818 | { |
|
819 | { | |
819 | case CHANNELF1: // 1 is for F1 = 4096 Hz |
|
820 | case CHANNELF1: // 1 is for F1 = 4096 Hz | |
820 | acquisitionTime_asLong = centerTime_asLong - deltaT_F1; |
|
821 | acquisitionTime_asLong = centerTime_asLong - deltaT_F1; | |
821 | nb_ring_nodes = NB_RING_NODES_F1; |
|
822 | nb_ring_nodes = NB_RING_NODES_F1; | |
822 | frequency_asLong = FREQ_F1; |
|
823 | frequency_asLong = FREQ_F1; | |
823 | nbTicksPerSample_asLong = TICKS_PER_T1; // 65536 / 4096; |
|
824 | nbTicksPerSample_asLong = TICKS_PER_T1; // 65536 / 4096; | |
824 | break; |
|
825 | break; | |
825 | case CHANNELF2: // 2 is for F2 = 256 Hz |
|
826 | case CHANNELF2: // 2 is for F2 = 256 Hz | |
826 | acquisitionTime_asLong = centerTime_asLong - deltaT_F2; |
|
827 | acquisitionTime_asLong = centerTime_asLong - deltaT_F2; | |
827 | nb_ring_nodes = NB_RING_NODES_F2; |
|
828 | nb_ring_nodes = NB_RING_NODES_F2; | |
828 | frequency_asLong = FREQ_F2; |
|
829 | frequency_asLong = FREQ_F2; | |
829 | nbTicksPerSample_asLong = TICKS_PER_T2; // 65536 / 256; |
|
830 | nbTicksPerSample_asLong = TICKS_PER_T2; // 65536 / 256; | |
830 | break; |
|
831 | break; | |
831 | default: |
|
832 | default: | |
832 | acquisitionTime_asLong = centerTime_asLong; |
|
833 | acquisitionTime_asLong = centerTime_asLong; | |
833 | nb_ring_nodes = 0; |
|
834 | nb_ring_nodes = 0; | |
834 | frequency_asLong = FREQ_F2; |
|
835 | frequency_asLong = FREQ_F2; | |
835 | nbTicksPerSample_asLong = TICKS_PER_T2; |
|
836 | nbTicksPerSample_asLong = TICKS_PER_T2; | |
836 | break; |
|
837 | break; | |
837 | } |
|
838 | } | |
838 |
|
839 | |||
839 | //***************************************************************************** |
|
840 | //***************************************************************************** | |
840 | // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong |
|
841 | // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong | |
841 | node = 0; |
|
842 | node = 0; | |
842 | while ( node < nb_ring_nodes) |
|
843 | while ( node < nb_ring_nodes) | |
843 | { |
|
844 | { | |
844 | //PRINTF1("%d ... ", node); |
|
845 | //PRINTF1("%d ... ", node); | |
845 | bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send->coarseTime ); |
|
846 | bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send->coarseTime ); | |
846 | if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong) |
|
847 | if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong) | |
847 | { |
|
848 | { | |
848 | //PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong); |
|
849 | //PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong); | |
849 | node = nb_ring_nodes; |
|
850 | node = nb_ring_nodes; | |
850 | } |
|
851 | } | |
851 | else |
|
852 | else | |
852 | { |
|
853 | { | |
853 | node = node + 1; |
|
854 | node = node + 1; | |
854 | ring_node_to_send = ring_node_to_send->previous; |
|
855 | ring_node_to_send = ring_node_to_send->previous; | |
855 | } |
|
856 | } | |
856 | } |
|
857 | } | |
857 |
|
858 | |||
858 | // (5) compute the number of samples to take in the current buffer |
|
859 | // (5) compute the number of samples to take in the current buffer | |
859 | sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> SHIFT_2_BYTES; |
|
860 | sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> SHIFT_2_BYTES; | |
860 | nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong; |
|
861 | nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong; | |
861 | //PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong); |
|
862 | //PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong); | |
862 |
|
863 | |||
863 | // (6) compute the final acquisition time |
|
864 | // (6) compute the final acquisition time | |
864 | acquisitionTime_asLong = bufferAcquisitionTime_asLong + |
|
865 | acquisitionTime_asLong = bufferAcquisitionTime_asLong + | |
865 | (sampleOffset_asLong * nbTicksPerSample_asLong); |
|
866 | (sampleOffset_asLong * nbTicksPerSample_asLong); | |
866 |
|
867 | |||
867 | // (7) copy the acquisition time at the beginning of the extrated snapshot |
|
868 | // (7) copy the acquisition time at the beginning of the extrated snapshot | |
868 | ptr1 = (unsigned char*) &acquisitionTime_asLong; |
|
869 | ptr1 = (unsigned char*) &acquisitionTime_asLong; | |
869 | // fine time |
|
870 | // fine time | |
870 | ptr2 = (unsigned char*) &ring_node_swf_extracted->fineTime; |
|
871 | ptr2 = (unsigned char*) &ring_node_swf_extracted->fineTime; | |
871 | ptr2[BYTE_2] = ptr1[ BYTE_4 + OFFSET_2_BYTES ]; |
|
872 | ptr2[BYTE_2] = ptr1[ BYTE_4 + OFFSET_2_BYTES ]; | |
872 | ptr2[BYTE_3] = ptr1[ BYTE_5 + OFFSET_2_BYTES ]; |
|
873 | ptr2[BYTE_3] = ptr1[ BYTE_5 + OFFSET_2_BYTES ]; | |
873 | // coarse time |
|
874 | // coarse time | |
874 | ptr2 = (unsigned char*) &ring_node_swf_extracted->coarseTime; |
|
875 | ptr2 = (unsigned char*) &ring_node_swf_extracted->coarseTime; | |
875 | ptr2[BYTE_0] = ptr1[ BYTE_0 + OFFSET_2_BYTES ]; |
|
876 | ptr2[BYTE_0] = ptr1[ BYTE_0 + OFFSET_2_BYTES ]; | |
876 | ptr2[BYTE_1] = ptr1[ BYTE_1 + OFFSET_2_BYTES ]; |
|
877 | ptr2[BYTE_1] = ptr1[ BYTE_1 + OFFSET_2_BYTES ]; | |
877 | ptr2[BYTE_2] = ptr1[ BYTE_2 + OFFSET_2_BYTES ]; |
|
878 | ptr2[BYTE_2] = ptr1[ BYTE_2 + OFFSET_2_BYTES ]; | |
878 | ptr2[BYTE_3] = ptr1[ BYTE_3 + OFFSET_2_BYTES ]; |
|
879 | ptr2[BYTE_3] = ptr1[ BYTE_3 + OFFSET_2_BYTES ]; | |
879 |
|
880 | |||
880 | // re set the synchronization bit |
|
881 | // re set the synchronization bit | |
881 | timeCharPtr = (unsigned char*) &ring_node_to_send->coarseTime; |
|
882 | timeCharPtr = (unsigned char*) &ring_node_to_send->coarseTime; | |
882 | ptr2[0] = ptr2[0] | (timeCharPtr[0] & SYNC_BIT); // [1000 0000] |
|
883 | ptr2[0] = ptr2[0] | (timeCharPtr[0] & SYNC_BIT); // [1000 0000] | |
883 |
|
884 | |||
884 | if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) ) |
|
885 | if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) ) | |
885 | { |
|
886 | { | |
886 | nbSamplesPart1_asLong = 0; |
|
887 | nbSamplesPart1_asLong = 0; | |
887 | } |
|
888 | } | |
888 | // copy the part 1 of the snapshot in the extracted buffer |
|
889 | // copy the part 1 of the snapshot in the extracted buffer | |
889 | for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ ) |
|
890 | for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ ) | |
890 | { |
|
891 | { | |
891 | swf_extracted[i] = |
|
892 | swf_extracted[i] = | |
892 | ((int*) ring_node_to_send->buffer_address)[ i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) ]; |
|
893 | ((int*) ring_node_to_send->buffer_address)[ i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) ]; | |
893 | } |
|
894 | } | |
894 | // copy the part 2 of the snapshot in the extracted buffer |
|
895 | // copy the part 2 of the snapshot in the extracted buffer | |
895 | ring_node_to_send = ring_node_to_send->next; |
|
896 | ring_node_to_send = ring_node_to_send->next; | |
896 | for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ ) |
|
897 | for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ ) | |
897 | { |
|
898 | { | |
898 | swf_extracted[i] = |
|
899 | swf_extracted[i] = | |
899 | ((int*) ring_node_to_send->buffer_address)[ (i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) ]; |
|
900 | ((int*) ring_node_to_send->buffer_address)[ (i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) ]; | |
900 | } |
|
901 | } | |
901 | } |
|
902 | } | |
902 |
|
903 | |||
903 | double computeCorrection( unsigned char *timePtr ) |
|
904 | double computeCorrection( unsigned char *timePtr ) | |
904 | { |
|
905 | { | |
905 | unsigned long long int acquisitionTime; |
|
906 | unsigned long long int acquisitionTime; | |
906 | unsigned long long int centerTime; |
|
907 | unsigned long long int centerTime; | |
907 | unsigned long long int previousTick; |
|
908 | unsigned long long int previousTick; | |
908 | unsigned long long int nextTick; |
|
909 | unsigned long long int nextTick; | |
909 | unsigned long long int deltaPreviousTick; |
|
910 | unsigned long long int deltaPreviousTick; | |
910 | unsigned long long int deltaNextTick; |
|
911 | unsigned long long int deltaNextTick; | |
911 | double deltaPrevious_ms; |
|
912 | double deltaPrevious_ms; | |
912 | double deltaNext_ms; |
|
913 | double deltaNext_ms; | |
913 | double correctionInF2; |
|
914 | double correctionInF2; | |
914 |
|
915 | |||
915 | correctionInF2 = 0; //set to default value (Don_Initialisation_P2) |
|
916 | correctionInF2 = 0; //set to default value (Don_Initialisation_P2) | |
916 |
|
917 | |||
917 | // get acquisition time in fine time ticks |
|
918 | // get acquisition time in fine time ticks | |
918 | acquisitionTime = get_acquisition_time( timePtr ); |
|
919 | acquisitionTime = get_acquisition_time( timePtr ); | |
919 |
|
920 | |||
920 | // compute center time |
|
921 | // compute center time | |
921 | centerTime = acquisitionTime + DELTAT_F0; // (2048. / 24576. / 2.) * 65536. = 2730.667; |
|
922 | centerTime = acquisitionTime + DELTAT_F0; // (2048. / 24576. / 2.) * 65536. = 2730.667; | |
922 | previousTick = centerTime - (centerTime & INT16_ALL_F); |
|
923 | previousTick = centerTime - (centerTime & INT16_ALL_F); | |
923 | nextTick = previousTick + TICKS_PER_S; |
|
924 | nextTick = previousTick + TICKS_PER_S; | |
924 |
|
925 | |||
925 | deltaPreviousTick = centerTime - previousTick; |
|
926 | deltaPreviousTick = centerTime - previousTick; | |
926 | deltaNextTick = nextTick - centerTime; |
|
927 | deltaNextTick = nextTick - centerTime; | |
927 |
|
928 | |||
928 | deltaPrevious_ms = (((double) deltaPreviousTick) / TICKS_PER_S) * MS_PER_S; |
|
929 | deltaPrevious_ms = (((double) deltaPreviousTick) / TICKS_PER_S) * MS_PER_S; | |
929 | deltaNext_ms = (((double) deltaNextTick) / TICKS_PER_S) * MS_PER_S; |
|
930 | deltaNext_ms = (((double) deltaNextTick) / TICKS_PER_S) * MS_PER_S; | |
930 |
|
931 | |||
931 | PRINTF2(" delta previous = %.3f ms, delta next = %.2f ms\n", deltaPrevious_ms, deltaNext_ms); |
|
932 | PRINTF2(" delta previous = %.3f ms, delta next = %.2f ms\n", deltaPrevious_ms, deltaNext_ms); | |
932 |
|
933 | |||
933 | // which tick is the closest? |
|
934 | // which tick is the closest? | |
934 | if (deltaPreviousTick > deltaNextTick) |
|
935 | if (deltaPreviousTick > deltaNextTick) | |
935 | { |
|
936 | { | |
936 | // the snapshot center is just before the second => increase delta_snapshot |
|
937 | // the snapshot center is just before the second => increase delta_snapshot | |
937 | correctionInF2 = + (deltaNext_ms * FREQ_F2 / MS_PER_S ); |
|
938 | correctionInF2 = + (deltaNext_ms * FREQ_F2 / MS_PER_S ); | |
938 | } |
|
939 | } | |
939 | else |
|
940 | else | |
940 | { |
|
941 | { | |
941 | // the snapshot center is just after the second => decrease delta_snapshot |
|
942 | // the snapshot center is just after the second => decrease delta_snapshot | |
942 | correctionInF2 = - (deltaPrevious_ms * FREQ_F2 / MS_PER_S ); |
|
943 | correctionInF2 = - (deltaPrevious_ms * FREQ_F2 / MS_PER_S ); | |
943 | } |
|
944 | } | |
944 |
|
945 | |||
945 | PRINTF1(" correctionInF2 = %.2f\n", correctionInF2); |
|
946 | PRINTF1(" correctionInF2 = %.2f\n", correctionInF2); | |
946 |
|
947 | |||
947 | return correctionInF2; |
|
948 | return correctionInF2; | |
948 | } |
|
949 | } | |
949 |
|
950 | |||
950 | void applyCorrection( double correction ) |
|
951 | void applyCorrection( double correction ) | |
951 | { |
|
952 | { | |
952 | int correctionInt; |
|
953 | int correctionInt; | |
953 |
|
954 | |||
954 | correctionInt = 0; |
|
955 | correctionInt = 0; | |
955 |
|
956 | |||
956 | if (correction >= 0.) |
|
957 | if (correction >= 0.) | |
957 | { |
|
958 | { | |
958 | if ( (ONE_TICK_CORR_INTERVAL_0_MIN < correction) && (correction < ONE_TICK_CORR_INTERVAL_0_MAX) ) |
|
959 | if ( (ONE_TICK_CORR_INTERVAL_0_MIN < correction) && (correction < ONE_TICK_CORR_INTERVAL_0_MAX) ) | |
959 | { |
|
960 | { | |
960 | correctionInt = ONE_TICK_CORR; |
|
961 | correctionInt = ONE_TICK_CORR; | |
961 | } |
|
962 | } | |
962 | else |
|
963 | else | |
963 | { |
|
964 | { | |
964 | correctionInt = CORR_MULT * floor(correction); |
|
965 | correctionInt = CORR_MULT * floor(correction); | |
965 | } |
|
966 | } | |
966 | } |
|
967 | } | |
967 | else |
|
968 | else | |
968 | { |
|
969 | { | |
969 | if ( (ONE_TICK_CORR_INTERVAL_1_MIN < correction) && (correction < ONE_TICK_CORR_INTERVAL_1_MAX) ) |
|
970 | if ( (ONE_TICK_CORR_INTERVAL_1_MIN < correction) && (correction < ONE_TICK_CORR_INTERVAL_1_MAX) ) | |
970 | { |
|
971 | { | |
971 | correctionInt = -ONE_TICK_CORR; |
|
972 | correctionInt = -ONE_TICK_CORR; | |
972 | } |
|
973 | } | |
973 | else |
|
974 | else | |
974 | { |
|
975 | { | |
975 | correctionInt = CORR_MULT * ceil(correction); |
|
976 | correctionInt = CORR_MULT * ceil(correction); | |
976 | } |
|
977 | } | |
977 | } |
|
978 | } | |
978 | waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + correctionInt; |
|
979 | waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + correctionInt; | |
979 | } |
|
980 | } | |
980 |
|
981 | |||
981 | void snapshot_resynchronization( unsigned char *timePtr ) |
|
982 | void snapshot_resynchronization( unsigned char *timePtr ) | |
982 | { |
|
983 | { | |
983 | /** This function compute a correction to apply on delta_snapshot. |
|
984 | /** This function compute a correction to apply on delta_snapshot. | |
984 | * |
|
985 | * | |
985 | * |
|
986 | * | |
986 | * @param timePtr is a pointer to the acquisition time of the snapshot being considered. |
|
987 | * @param timePtr is a pointer to the acquisition time of the snapshot being considered. | |
987 | * |
|
988 | * | |
988 | * @return void |
|
989 | * @return void | |
989 | * |
|
990 | * | |
990 | */ |
|
991 | */ | |
991 |
|
992 | |||
992 | static double correction = INIT_FLOAT; |
|
993 | static double correction = INIT_FLOAT; | |
993 | static resynchro_state state = MEASURE; |
|
994 | static resynchro_state state = MEASURE; | |
994 | static unsigned int nbSnapshots = 0; |
|
995 | static unsigned int nbSnapshots = 0; | |
995 |
|
996 | |||
996 | int correctionInt; |
|
997 | int correctionInt; | |
997 |
|
998 | |||
998 | correctionInt = 0; |
|
999 | correctionInt = 0; | |
999 |
|
1000 | |||
1000 | switch (state) |
|
1001 | switch (state) | |
1001 | { |
|
1002 | { | |
1002 |
|
1003 | |||
1003 | case MEASURE: |
|
1004 | case MEASURE: | |
1004 | // ******** |
|
1005 | // ******** | |
1005 | PRINTF1("MEASURE === %d\n", nbSnapshots); |
|
1006 | PRINTF1("MEASURE === %d\n", nbSnapshots); | |
1006 | state = CORRECTION; |
|
1007 | state = CORRECTION; | |
1007 | correction = computeCorrection( timePtr ); |
|
1008 | correction = computeCorrection( timePtr ); | |
1008 | PRINTF1("MEASURE === correction = %.2f\n", correction ); |
|
1009 | PRINTF1("MEASURE === correction = %.2f\n", correction ); | |
1009 | applyCorrection( correction ); |
|
1010 | applyCorrection( correction ); | |
1010 | PRINTF1("MEASURE === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot); |
|
1011 | PRINTF1("MEASURE === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot); | |
1011 | //**** |
|
1012 | //**** | |
1012 | break; |
|
1013 | break; | |
1013 |
|
1014 | |||
1014 | case CORRECTION: |
|
1015 | case CORRECTION: | |
1015 | //************ |
|
1016 | //************ | |
1016 | PRINTF1("CORRECTION === %d\n", nbSnapshots); |
|
1017 | PRINTF1("CORRECTION === %d\n", nbSnapshots); | |
1017 | state = MEASURE; |
|
1018 | state = MEASURE; | |
1018 | computeCorrection( timePtr ); |
|
1019 | computeCorrection( timePtr ); | |
1019 | set_wfp_delta_snapshot(); |
|
1020 | set_wfp_delta_snapshot(); | |
1020 | PRINTF1("CORRECTION === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot); |
|
1021 | PRINTF1("CORRECTION === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot); | |
1021 | //**** |
|
1022 | //**** | |
1022 | break; |
|
1023 | break; | |
1023 |
|
1024 | |||
1024 | default: |
|
1025 | default: | |
1025 | break; |
|
1026 | break; | |
1026 |
|
1027 | |||
1027 | } |
|
1028 | } | |
1028 |
|
1029 | |||
1029 | nbSnapshots++; |
|
1030 | nbSnapshots++; | |
1030 | } |
|
1031 | } | |
1031 |
|
1032 | |||
1032 | //************** |
|
1033 | //************** | |
1033 | // wfp registers |
|
1034 | // wfp registers | |
1034 | void reset_wfp_burst_enable( void ) |
|
1035 | void reset_wfp_burst_enable( void ) | |
1035 | { |
|
1036 | { | |
1036 | /** This function resets the waveform picker burst_enable register. |
|
1037 | /** This function resets the waveform picker burst_enable register. | |
1037 | * |
|
1038 | * | |
1038 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. |
|
1039 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. | |
1039 | * |
|
1040 | * | |
1040 | */ |
|
1041 | */ | |
1041 |
|
1042 | |||
1042 | // [1000 000] burst f2, f1, f0 enable f3, f2, f1, f0 |
|
1043 | // [1000 000] burst f2, f1, f0 enable f3, f2, f1, f0 | |
1043 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable & RST_BITS_RUN_BURST_EN; |
|
1044 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable & RST_BITS_RUN_BURST_EN; | |
1044 | } |
|
1045 | } | |
1045 |
|
1046 | |||
1046 | void reset_wfp_status( void ) |
|
1047 | void reset_wfp_status( void ) | |
1047 | { |
|
1048 | { | |
1048 | /** This function resets the waveform picker status register. |
|
1049 | /** This function resets the waveform picker status register. | |
1049 | * |
|
1050 | * | |
1050 | * All status bits are set to 0 [new_err full_err full]. |
|
1051 | * All status bits are set to 0 [new_err full_err full]. | |
1051 | * |
|
1052 | * | |
1052 | */ |
|
1053 | */ | |
1053 |
|
1054 | |||
1054 | waveform_picker_regs->status = INT16_ALL_F; |
|
1055 | waveform_picker_regs->status = INT16_ALL_F; | |
1055 | } |
|
1056 | } | |
1056 |
|
1057 | |||
1057 | void reset_wfp_buffer_addresses( void ) |
|
1058 | void reset_wfp_buffer_addresses( void ) | |
1058 | { |
|
1059 | { | |
1059 | // F0 |
|
1060 | // F0 | |
1060 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->previous->buffer_address; // 0x08 |
|
1061 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->previous->buffer_address; // 0x08 | |
1061 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c |
|
1062 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c | |
1062 | // F1 |
|
1063 | // F1 | |
1063 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->previous->buffer_address; // 0x10 |
|
1064 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->previous->buffer_address; // 0x10 | |
1064 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14 |
|
1065 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14 | |
1065 | // F2 |
|
1066 | // F2 | |
1066 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->previous->buffer_address; // 0x18 |
|
1067 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->previous->buffer_address; // 0x18 | |
1067 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c |
|
1068 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c | |
1068 | // F3 |
|
1069 | // F3 | |
1069 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->previous->buffer_address; // 0x20 |
|
1070 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->previous->buffer_address; // 0x20 | |
1070 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24 |
|
1071 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24 | |
1071 | } |
|
1072 | } | |
1072 |
|
1073 | |||
1073 | void reset_waveform_picker_regs( void ) |
|
1074 | void reset_waveform_picker_regs( void ) | |
1074 | { |
|
1075 | { | |
1075 | /** This function resets the waveform picker module registers. |
|
1076 | /** This function resets the waveform picker module registers. | |
1076 | * |
|
1077 | * | |
1077 | * The registers affected by this function are located at the following offset addresses: |
|
1078 | * The registers affected by this function are located at the following offset addresses: | |
1078 | * - 0x00 data_shaping |
|
1079 | * - 0x00 data_shaping | |
1079 | * - 0x04 run_burst_enable |
|
1080 | * - 0x04 run_burst_enable | |
1080 | * - 0x08 addr_data_f0 |
|
1081 | * - 0x08 addr_data_f0 | |
1081 | * - 0x0C addr_data_f1 |
|
1082 | * - 0x0C addr_data_f1 | |
1082 | * - 0x10 addr_data_f2 |
|
1083 | * - 0x10 addr_data_f2 | |
1083 | * - 0x14 addr_data_f3 |
|
1084 | * - 0x14 addr_data_f3 | |
1084 | * - 0x18 status |
|
1085 | * - 0x18 status | |
1085 | * - 0x1C delta_snapshot |
|
1086 | * - 0x1C delta_snapshot | |
1086 | * - 0x20 delta_f0 |
|
1087 | * - 0x20 delta_f0 | |
1087 | * - 0x24 delta_f0_2 |
|
1088 | * - 0x24 delta_f0_2 | |
1088 | * - 0x28 delta_f1 (obsolet parameter) |
|
1089 | * - 0x28 delta_f1 (obsolet parameter) | |
1089 | * - 0x2c delta_f2 |
|
1090 | * - 0x2c delta_f2 | |
1090 | * - 0x30 nb_data_by_buffer |
|
1091 | * - 0x30 nb_data_by_buffer | |
1091 | * - 0x34 nb_snapshot_param |
|
1092 | * - 0x34 nb_snapshot_param | |
1092 | * - 0x38 start_date |
|
1093 | * - 0x38 start_date | |
1093 | * - 0x3c nb_word_in_buffer |
|
1094 | * - 0x3c nb_word_in_buffer | |
1094 | * |
|
1095 | * | |
1095 | */ |
|
1096 | */ | |
1096 |
|
1097 | |||
1097 | set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW |
|
1098 | set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW | |
1098 |
|
1099 | |||
1099 | reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ] |
|
1100 | reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ] | |
1100 |
|
1101 | |||
1101 | reset_wfp_buffer_addresses(); |
|
1102 | reset_wfp_buffer_addresses(); | |
1102 |
|
1103 | |||
1103 | reset_wfp_status(); // 0x18 |
|
1104 | reset_wfp_status(); // 0x18 | |
1104 |
|
1105 | |||
1105 | set_wfp_delta_snapshot(); // 0x1c *** 300 s => 0x12bff |
|
1106 | set_wfp_delta_snapshot(); // 0x1c *** 300 s => 0x12bff | |
1106 |
|
1107 | |||
1107 | set_wfp_delta_f0_f0_2(); // 0x20, 0x24 |
|
1108 | set_wfp_delta_f0_f0_2(); // 0x20, 0x24 | |
1108 |
|
1109 | |||
1109 | //the parameter delta_f1 [0x28] is not used anymore |
|
1110 | //the parameter delta_f1 [0x28] is not used anymore | |
1110 |
|
1111 | |||
1111 | set_wfp_delta_f2(); // 0x2c |
|
1112 | set_wfp_delta_f2(); // 0x2c | |
1112 |
|
1113 | |||
1113 | DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot); |
|
1114 | DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot); | |
1114 | DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0); |
|
1115 | DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0); | |
1115 | DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2); |
|
1116 | DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2); | |
1116 | DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1); |
|
1117 | DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1); | |
1117 | DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2); |
|
1118 | DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2); | |
1118 | // 2688 = 8 * 336 |
|
1119 | // 2688 = 8 * 336 | |
1119 | waveform_picker_regs->nb_data_by_buffer = DFLT_WFP_NB_DATA_BY_BUFFER; // 0x30 *** 2688 - 1 => nb samples -1 |
|
1120 | waveform_picker_regs->nb_data_by_buffer = DFLT_WFP_NB_DATA_BY_BUFFER; // 0x30 *** 2688 - 1 => nb samples -1 | |
1120 | waveform_picker_regs->snapshot_param = DFLT_WFP_SNAPSHOT_PARAM; // 0x34 *** 2688 => nb samples |
|
1121 | waveform_picker_regs->snapshot_param = DFLT_WFP_SNAPSHOT_PARAM; // 0x34 *** 2688 => nb samples | |
1121 | waveform_picker_regs->start_date = COARSE_TIME_MASK; |
|
1122 | waveform_picker_regs->start_date = COARSE_TIME_MASK; | |
1122 | // |
|
1123 | // | |
1123 | // coarse time and fine time registers are not initialized, they are volatile |
|
1124 | // coarse time and fine time registers are not initialized, they are volatile | |
1124 | // |
|
1125 | // | |
1125 | waveform_picker_regs->buffer_length = DFLT_WFP_BUFFER_LENGTH; // buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8 |
|
1126 | waveform_picker_regs->buffer_length = DFLT_WFP_BUFFER_LENGTH; // buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8 | |
1126 | } |
|
1127 | } | |
1127 |
|
1128 | |||
1128 | void set_wfp_data_shaping( void ) |
|
1129 | void set_wfp_data_shaping( void ) | |
1129 | { |
|
1130 | { | |
1130 | /** This function sets the data_shaping register of the waveform picker module. |
|
1131 | /** This function sets the data_shaping register of the waveform picker module. | |
1131 | * |
|
1132 | * | |
1132 | * The value is read from one field of the parameter_dump_packet structure:\n |
|
1133 | * The value is read from one field of the parameter_dump_packet structure:\n | |
1133 | * bw_sp0_sp1_r0_r1 |
|
1134 | * bw_sp0_sp1_r0_r1 | |
1134 | * |
|
1135 | * | |
1135 | */ |
|
1136 | */ | |
1136 |
|
1137 | |||
1137 | unsigned char data_shaping; |
|
1138 | unsigned char data_shaping; | |
1138 |
|
1139 | |||
1139 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register |
|
1140 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register | |
1140 | // waveform picker : [R1 R0 SP1 SP0 BW] |
|
1141 | // waveform picker : [R1 R0 SP1 SP0 BW] | |
1141 |
|
1142 | |||
1142 | data_shaping = parameter_dump_packet.sy_lfr_common_parameters; |
|
1143 | data_shaping = parameter_dump_packet.sy_lfr_common_parameters; | |
1143 |
|
1144 | |||
1144 | waveform_picker_regs->data_shaping = |
|
1145 | waveform_picker_regs->data_shaping = | |
1145 | ( (data_shaping & BIT_5) >> SHIFT_5_BITS ) // BW |
|
1146 | ( (data_shaping & BIT_5) >> SHIFT_5_BITS ) // BW | |
1146 | + ( (data_shaping & BIT_4) >> SHIFT_3_BITS ) // SP0 |
|
1147 | + ( (data_shaping & BIT_4) >> SHIFT_3_BITS ) // SP0 | |
1147 | + ( (data_shaping & BIT_3) >> 1 ) // SP1 |
|
1148 | + ( (data_shaping & BIT_3) >> 1 ) // SP1 | |
1148 | + ( (data_shaping & BIT_2) << 1 ) // R0 |
|
1149 | + ( (data_shaping & BIT_2) << 1 ) // R0 | |
1149 | + ( (data_shaping & BIT_1) << SHIFT_3_BITS ) // R1 |
|
1150 | + ( (data_shaping & BIT_1) << SHIFT_3_BITS ) // R1 | |
1150 | + ( (data_shaping & BIT_0) << SHIFT_5_BITS ); // R2 |
|
1151 | + ( (data_shaping & BIT_0) << SHIFT_5_BITS ); // R2 | |
1151 | } |
|
1152 | } | |
1152 |
|
1153 | |||
1153 | void set_wfp_burst_enable_register( unsigned char mode ) |
|
1154 | void set_wfp_burst_enable_register( unsigned char mode ) | |
1154 | { |
|
1155 | { | |
1155 | /** This function sets the waveform picker burst_enable register depending on the mode. |
|
1156 | /** This function sets the waveform picker burst_enable register depending on the mode. | |
1156 | * |
|
1157 | * | |
1157 | * @param mode is the LFR mode to launch. |
|
1158 | * @param mode is the LFR mode to launch. | |
1158 | * |
|
1159 | * | |
1159 | * The burst bits shall be before the enable bits. |
|
1160 | * The burst bits shall be before the enable bits. | |
1160 | * |
|
1161 | * | |
1161 | */ |
|
1162 | */ | |
1162 |
|
1163 | |||
1163 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 |
|
1164 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 | |
1164 | // the burst bits shall be set first, before the enable bits |
|
1165 | // the burst bits shall be set first, before the enable bits | |
1165 | switch(mode) { |
|
1166 | switch(mode) { | |
1166 | case LFR_MODE_NORMAL: |
|
1167 | case LFR_MODE_NORMAL: | |
1167 | case LFR_MODE_SBM1: |
|
1168 | case LFR_MODE_SBM1: | |
1168 | case LFR_MODE_SBM2: |
|
1169 | case LFR_MODE_SBM2: | |
1169 | waveform_picker_regs->run_burst_enable = RUN_BURST_ENABLE_SBM2; // [0110 0000] enable f2 and f1 burst |
|
1170 | waveform_picker_regs->run_burst_enable = RUN_BURST_ENABLE_SBM2; // [0110 0000] enable f2 and f1 burst | |
1170 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | BITS_WFP_ENABLE_ALL; // [1111] enable f3 f2 f1 f0 |
|
1171 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | BITS_WFP_ENABLE_ALL; // [1111] enable f3 f2 f1 f0 | |
1171 | break; |
|
1172 | break; | |
1172 | case LFR_MODE_BURST: |
|
1173 | case LFR_MODE_BURST: | |
1173 | waveform_picker_regs->run_burst_enable = RUN_BURST_ENABLE_BURST; // [0100 0000] f2 burst enabled |
|
1174 | waveform_picker_regs->run_burst_enable = RUN_BURST_ENABLE_BURST; // [0100 0000] f2 burst enabled | |
1174 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | BITS_WFP_ENABLE_BURST; // [1100] enable f3 and f2 |
|
1175 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | BITS_WFP_ENABLE_BURST; // [1100] enable f3 and f2 | |
1175 | break; |
|
1176 | break; | |
1176 | default: |
|
1177 | default: | |
1177 | waveform_picker_regs->run_burst_enable = INIT_CHAR; // [0000 0000] no burst enabled, no waveform enabled |
|
1178 | waveform_picker_regs->run_burst_enable = INIT_CHAR; // [0000 0000] no burst enabled, no waveform enabled | |
1178 | break; |
|
1179 | break; | |
1179 | } |
|
1180 | } | |
1180 | } |
|
1181 | } | |
1181 |
|
1182 | |||
1182 | void set_wfp_delta_snapshot( void ) |
|
1183 | void set_wfp_delta_snapshot( void ) | |
1183 | { |
|
1184 | { | |
1184 | /** This function sets the delta_snapshot register of the waveform picker module. |
|
1185 | /** This function sets the delta_snapshot register of the waveform picker module. | |
1185 | * |
|
1186 | * | |
1186 | * The value is read from two (unsigned char) of the parameter_dump_packet structure: |
|
1187 | * The value is read from two (unsigned char) of the parameter_dump_packet structure: | |
1187 | * - sy_lfr_n_swf_p[0] |
|
1188 | * - sy_lfr_n_swf_p[0] | |
1188 | * - sy_lfr_n_swf_p[1] |
|
1189 | * - sy_lfr_n_swf_p[1] | |
1189 | * |
|
1190 | * | |
1190 | */ |
|
1191 | */ | |
1191 |
|
1192 | |||
1192 | unsigned int delta_snapshot; |
|
1193 | unsigned int delta_snapshot; | |
1193 | unsigned int delta_snapshot_in_T2; |
|
1194 | unsigned int delta_snapshot_in_T2; | |
1194 |
|
1195 | |||
1195 | delta_snapshot = (parameter_dump_packet.sy_lfr_n_swf_p[0] * CONST_256) |
|
1196 | delta_snapshot = (parameter_dump_packet.sy_lfr_n_swf_p[0] * CONST_256) | |
1196 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; |
|
1197 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; | |
1197 |
|
1198 | |||
1198 | delta_snapshot_in_T2 = delta_snapshot * FREQ_F2; |
|
1199 | delta_snapshot_in_T2 = delta_snapshot * FREQ_F2; | |
1199 | waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes |
|
1200 | waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes | |
1200 | } |
|
1201 | } | |
1201 |
|
1202 | |||
1202 | void set_wfp_delta_f0_f0_2( void ) |
|
1203 | void set_wfp_delta_f0_f0_2( void ) | |
1203 | { |
|
1204 | { | |
1204 | unsigned int delta_snapshot; |
|
1205 | unsigned int delta_snapshot; | |
1205 | unsigned int nb_samples_per_snapshot; |
|
1206 | unsigned int nb_samples_per_snapshot; | |
1206 | float delta_f0_in_float; |
|
1207 | float delta_f0_in_float; | |
1207 |
|
1208 | |||
1208 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1209 | delta_snapshot = waveform_picker_regs->delta_snapshot; | |
1209 | nb_samples_per_snapshot = (parameter_dump_packet.sy_lfr_n_swf_l[0] * CONST_256) + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1210 | nb_samples_per_snapshot = (parameter_dump_packet.sy_lfr_n_swf_l[0] * CONST_256) + parameter_dump_packet.sy_lfr_n_swf_l[1]; | |
1210 | delta_f0_in_float = (nb_samples_per_snapshot / 2.) * ( (1. / FREQ_F2) - (1. / FREQ_F0) ) * FREQ_F2; |
|
1211 | delta_f0_in_float = (nb_samples_per_snapshot / 2.) * ( (1. / FREQ_F2) - (1. / FREQ_F0) ) * FREQ_F2; | |
1211 |
|
1212 | |||
1212 | waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float ); |
|
1213 | waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float ); | |
1213 | waveform_picker_regs->delta_f0_2 = DFLT_WFP_DELTA_F0_2; |
|
1214 | waveform_picker_regs->delta_f0_2 = DFLT_WFP_DELTA_F0_2; | |
1214 | } |
|
1215 | } | |
1215 |
|
1216 | |||
1216 | void set_wfp_delta_f1( void ) |
|
1217 | void set_wfp_delta_f1( void ) | |
1217 | { |
|
1218 | { | |
1218 | /** Sets the value of the delta_f1 parameter |
|
1219 | /** Sets the value of the delta_f1 parameter | |
1219 | * |
|
1220 | * | |
1220 | * @param void |
|
1221 | * @param void | |
1221 | * |
|
1222 | * | |
1222 | * @return void |
|
1223 | * @return void | |
1223 | * |
|
1224 | * | |
1224 | * delta_f1 is not used, the snapshots are extracted from CWF_F1 waveforms. |
|
1225 | * delta_f1 is not used, the snapshots are extracted from CWF_F1 waveforms. | |
1225 | * |
|
1226 | * | |
1226 | */ |
|
1227 | */ | |
1227 |
|
1228 | |||
1228 | unsigned int delta_snapshot; |
|
1229 | unsigned int delta_snapshot; | |
1229 | unsigned int nb_samples_per_snapshot; |
|
1230 | unsigned int nb_samples_per_snapshot; | |
1230 | float delta_f1_in_float; |
|
1231 | float delta_f1_in_float; | |
1231 |
|
1232 | |||
1232 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1233 | delta_snapshot = waveform_picker_regs->delta_snapshot; | |
1233 | nb_samples_per_snapshot = (parameter_dump_packet.sy_lfr_n_swf_l[0] * CONST_256) + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1234 | nb_samples_per_snapshot = (parameter_dump_packet.sy_lfr_n_swf_l[0] * CONST_256) + parameter_dump_packet.sy_lfr_n_swf_l[1]; | |
1234 | delta_f1_in_float = (nb_samples_per_snapshot / 2.) * ( (1. / FREQ_F2) - (1. / FREQ_F1) ) * FREQ_F2; |
|
1235 | delta_f1_in_float = (nb_samples_per_snapshot / 2.) * ( (1. / FREQ_F2) - (1. / FREQ_F1) ) * FREQ_F2; | |
1235 |
|
1236 | |||
1236 | waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float ); |
|
1237 | waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float ); | |
1237 | } |
|
1238 | } | |
1238 |
|
1239 | |||
1239 | void set_wfp_delta_f2( void ) // parameter not used, only delta_f0 and delta_f0_2 are used |
|
1240 | void set_wfp_delta_f2( void ) // parameter not used, only delta_f0 and delta_f0_2 are used | |
1240 | { |
|
1241 | { | |
1241 | /** Sets the value of the delta_f2 parameter |
|
1242 | /** Sets the value of the delta_f2 parameter | |
1242 | * |
|
1243 | * | |
1243 | * @param void |
|
1244 | * @param void | |
1244 | * |
|
1245 | * | |
1245 | * @return void |
|
1246 | * @return void | |
1246 | * |
|
1247 | * | |
1247 | * delta_f2 is used only for the first snapshot generation, even when the snapshots are extracted from CWF_F2 |
|
1248 | * delta_f2 is used only for the first snapshot generation, even when the snapshots are extracted from CWF_F2 | |
1248 | * waveforms (see lpp_waveform_snapshot_controler.vhd for details). |
|
1249 | * waveforms (see lpp_waveform_snapshot_controler.vhd for details). | |
1249 | * |
|
1250 | * | |
1250 | */ |
|
1251 | */ | |
1251 |
|
1252 | |||
1252 | unsigned int delta_snapshot; |
|
1253 | unsigned int delta_snapshot; | |
1253 | unsigned int nb_samples_per_snapshot; |
|
1254 | unsigned int nb_samples_per_snapshot; | |
1254 |
|
1255 | |||
1255 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1256 | delta_snapshot = waveform_picker_regs->delta_snapshot; | |
1256 | nb_samples_per_snapshot = (parameter_dump_packet.sy_lfr_n_swf_l[0] * CONST_256) + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1257 | nb_samples_per_snapshot = (parameter_dump_packet.sy_lfr_n_swf_l[0] * CONST_256) + parameter_dump_packet.sy_lfr_n_swf_l[1]; | |
1257 |
|
1258 | |||
1258 | waveform_picker_regs->delta_f2 = delta_snapshot - (nb_samples_per_snapshot / 2) - 1; |
|
1259 | waveform_picker_regs->delta_f2 = delta_snapshot - (nb_samples_per_snapshot / 2) - 1; | |
1259 | } |
|
1260 | } | |
1260 |
|
1261 | |||
1261 | //***************** |
|
1262 | //***************** | |
1262 | // local parameters |
|
1263 | // local parameters | |
1263 |
|
1264 | |||
1264 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ) |
|
1265 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ) | |
1265 | { |
|
1266 | { | |
1266 | /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument. |
|
1267 | /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument. | |
1267 | * |
|
1268 | * | |
1268 | * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update. |
|
1269 | * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update. | |
1269 | * @param sid is the source identifier of the packet being updated. |
|
1270 | * @param sid is the source identifier of the packet being updated. | |
1270 | * |
|
1271 | * | |
1271 | * REQ-LFR-SRS-5240 / SSS-CP-FS-590 |
|
1272 | * REQ-LFR-SRS-5240 / SSS-CP-FS-590 | |
1272 | * The sequence counters shall wrap around from 2^14 to zero. |
|
1273 | * The sequence counters shall wrap around from 2^14 to zero. | |
1273 | * The sequence counter shall start at zero at startup. |
|
1274 | * The sequence counter shall start at zero at startup. | |
1274 | * |
|
1275 | * | |
1275 | * REQ-LFR-SRS-5239 / SSS-CP-FS-580 |
|
1276 | * REQ-LFR-SRS-5239 / SSS-CP-FS-580 | |
1276 | * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0 |
|
1277 | * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0 | |
1277 | * |
|
1278 | * | |
1278 | */ |
|
1279 | */ | |
1279 |
|
1280 | |||
1280 | unsigned short *sequence_cnt; |
|
1281 | unsigned short *sequence_cnt; | |
1281 | unsigned short segmentation_grouping_flag; |
|
1282 | unsigned short segmentation_grouping_flag; | |
1282 | unsigned short new_packet_sequence_control; |
|
1283 | unsigned short new_packet_sequence_control; | |
1283 | rtems_mode initial_mode_set; |
|
1284 | rtems_mode initial_mode_set; | |
1284 | rtems_mode current_mode_set; |
|
1285 | rtems_mode current_mode_set; | |
1285 | rtems_status_code status; |
|
1286 | rtems_status_code status; | |
1286 |
|
1287 | |||
1287 | initial_mode_set = RTEMS_DEFAULT_MODES; |
|
1288 | initial_mode_set = RTEMS_DEFAULT_MODES; | |
1288 | current_mode_set = RTEMS_DEFAULT_MODES; |
|
1289 | current_mode_set = RTEMS_DEFAULT_MODES; | |
1289 | sequence_cnt = NULL; |
|
1290 | sequence_cnt = NULL; | |
1290 |
|
1291 | |||
1291 | //****************************************** |
|
1292 | //****************************************** | |
1292 | // CHANGE THE MODE OF THE CALLING RTEMS TASK |
|
1293 | // CHANGE THE MODE OF THE CALLING RTEMS TASK | |
1293 | status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set ); |
|
1294 | status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set ); | |
1294 |
|
1295 | |||
1295 | if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2) |
|
1296 | if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2) | |
1296 | || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3) |
|
1297 | || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3) | |
1297 | || (sid == SID_BURST_CWF_F2) |
|
1298 | || (sid == SID_BURST_CWF_F2) | |
1298 | || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2) |
|
1299 | || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2) | |
1299 | || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2) |
|
1300 | || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2) | |
1300 | || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2) |
|
1301 | || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2) | |
1301 | || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0) |
|
1302 | || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0) | |
1302 | || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) ) |
|
1303 | || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) ) | |
1303 | { |
|
1304 | { | |
1304 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST; |
|
1305 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST; | |
1305 | } |
|
1306 | } | |
1306 | else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) |
|
1307 | else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) | |
1307 | || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0) |
|
1308 | || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0) | |
1308 | || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0) |
|
1309 | || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0) | |
1309 | || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) ) |
|
1310 | || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) ) | |
1310 | { |
|
1311 | { | |
1311 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2; |
|
1312 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2; | |
1312 | } |
|
1313 | } | |
1313 | else |
|
1314 | else | |
1314 | { |
|
1315 | { | |
1315 | sequence_cnt = (unsigned short *) NULL; |
|
1316 | sequence_cnt = (unsigned short *) NULL; | |
1316 | PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid) |
|
1317 | PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid) | |
1317 | } |
|
1318 | } | |
1318 |
|
1319 | |||
1319 | if (sequence_cnt != NULL) |
|
1320 | if (sequence_cnt != NULL) | |
1320 | { |
|
1321 | { | |
1321 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE; |
|
1322 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << SHIFT_1_BYTE; | |
1322 | *sequence_cnt = (*sequence_cnt) & SEQ_CNT_MASK; |
|
1323 | *sequence_cnt = (*sequence_cnt) & SEQ_CNT_MASK; | |
1323 |
|
1324 | |||
1324 | new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ; |
|
1325 | new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ; | |
1325 |
|
1326 | |||
1326 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> SHIFT_1_BYTE); |
|
1327 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> SHIFT_1_BYTE); | |
1327 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); |
|
1328 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); | |
1328 |
|
1329 | |||
1329 | // increment the sequence counter |
|
1330 | // increment the sequence counter | |
1330 | if ( *sequence_cnt < SEQ_CNT_MAX) |
|
1331 | if ( *sequence_cnt < SEQ_CNT_MAX) | |
1331 | { |
|
1332 | { | |
1332 | *sequence_cnt = *sequence_cnt + 1; |
|
1333 | *sequence_cnt = *sequence_cnt + 1; | |
1333 | } |
|
1334 | } | |
1334 | else |
|
1335 | else | |
1335 | { |
|
1336 | { | |
1336 | *sequence_cnt = 0; |
|
1337 | *sequence_cnt = 0; | |
1337 | } |
|
1338 | } | |
1338 | } |
|
1339 | } | |
1339 |
|
1340 | |||
1340 | //************************************* |
|
1341 | //************************************* | |
1341 | // RESTORE THE MODE OF THE CALLING TASK |
|
1342 | // RESTORE THE MODE OF THE CALLING TASK | |
1342 | status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, ¤t_mode_set ); |
|
1343 | status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, ¤t_mode_set ); | |
1343 | } |
|
1344 | } |
General Comments 0
You need to be logged in to leave comments.
Login now