##// END OF EJS Templates
compliance with ICD 4.3...
paul -
r328:5023f9ef69f2 R3++ draft
parent child
Show More
@@ -1,2 +1,2
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
2 7c46de6059673d3239fcc7103e16510727f35923 header/lfr_common_headers
2 058c1234c2defe215d3dd655a7ef65abb33c922d header/lfr_common_headers
@@ -1,64 +1,59
1 #ifndef FSW_INIT_H_INCLUDED
1 #ifndef FSW_INIT_H_INCLUDED
2 #define FSW_INIT_H_INCLUDED
2 #define FSW_INIT_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <leon.h>
5 #include <leon.h>
6
6
7 #include "fsw_params.h"
7 #include "fsw_params.h"
8 #include "fsw_misc.h"
8 #include "fsw_misc.h"
9 #include "fsw_processing.h"
9 #include "fsw_processing.h"
10
10
11 #include "tc_handler.h"
11 #include "tc_handler.h"
12 #include "wf_handler.h"
12 #include "wf_handler.h"
13 #include "fsw_spacewire.h"
13 #include "fsw_spacewire.h"
14
14
15 #include "avf0_prc0.h"
15 #include "avf0_prc0.h"
16 #include "avf1_prc1.h"
16 #include "avf1_prc1.h"
17 #include "avf2_prc2.h"
17 #include "avf2_prc2.h"
18
18
19 extern rtems_name Task_name[]; /* array of task names */
19 extern rtems_name Task_name[]; /* array of task names */
20 extern rtems_id Task_id[]; /* array of task ids */
20 extern rtems_id Task_id[]; /* array of task ids */
21 extern rtems_name timecode_timer_name;
21 extern rtems_name timecode_timer_name;
22 extern rtems_id timecode_timer_id;
22 extern rtems_id timecode_timer_id;
23 extern unsigned char pa_bia_status_info;
23 extern unsigned char pa_bia_status_info;
24 extern unsigned char cp_rpw_sc_rw_f_flags;
24 extern unsigned char cp_rpw_sc_rw1_rw2_f_flags;
25 extern float cp_rpw_sc_rw1_f1;
25 extern unsigned char cp_rpw_sc_rw3_rw4_f_flags;
26 extern float cp_rpw_sc_rw1_f2;
26
27 extern float cp_rpw_sc_rw2_f1;
28 extern float cp_rpw_sc_rw2_f2;
29 extern float cp_rpw_sc_rw3_f1;
30 extern float cp_rpw_sc_rw3_f2;
31 extern float cp_rpw_sc_rw4_f1;
32 extern float cp_rpw_sc_rw4_f2;
33 extern filterPar_t filterPar;
27 extern filterPar_t filterPar;
28 extern rw_f_t rw_f;
34
29
35 // RTEMS TASKS
30 // RTEMS TASKS
36 rtems_task Init( rtems_task_argument argument);
31 rtems_task Init( rtems_task_argument argument);
37
32
38 // OTHER functions
33 // OTHER functions
39 void create_names( void );
34 void create_names( void );
40 int create_all_tasks( void );
35 int create_all_tasks( void );
41 int start_all_tasks( void );
36 int start_all_tasks( void );
42 //
37 //
43 rtems_status_code create_message_queues( void );
38 rtems_status_code create_message_queues( void );
44 rtems_status_code create_timecode_timer( void );
39 rtems_status_code create_timecode_timer( void );
45 rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
40 rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
46 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
41 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
47 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
42 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
48 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
43 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
49 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
44 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
50 void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max );
45 void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max );
51 void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize );
46 void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize );
52 //
47 //
53 int start_recv_send_tasks( void );
48 int start_recv_send_tasks( void );
54 //
49 //
55 void init_local_mode_parameters( void );
50 void init_local_mode_parameters( void );
56 void reset_local_time( void );
51 void reset_local_time( void );
57
52
58 extern void rtems_cpu_usage_report( void );
53 extern void rtems_cpu_usage_report( void );
59 extern void rtems_cpu_usage_reset( void );
54 extern void rtems_cpu_usage_reset( void );
60 extern void rtems_stack_checker_report_usage( void );
55 extern void rtems_stack_checker_report_usage( void );
61
56
62 extern int sched_yield( void );
57 extern int sched_yield( void );
63
58
64 #endif // FSW_INIT_H_INCLUDED
59 #endif // FSW_INIT_H_INCLUDED
@@ -1,101 +1,117
1 #ifndef TC_LOAD_DUMP_PARAMETERS_H
1 #ifndef TC_LOAD_DUMP_PARAMETERS_H
2 #define TC_LOAD_DUMP_PARAMETERS_H
2 #define TC_LOAD_DUMP_PARAMETERS_H
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <stdio.h>
5 #include <stdio.h>
6
6
7 #include "fsw_params.h"
7 #include "fsw_params.h"
8 #include "wf_handler.h"
8 #include "wf_handler.h"
9 #include "tm_lfr_tc_exe.h"
9 #include "tm_lfr_tc_exe.h"
10 #include "fsw_misc.h"
10 #include "fsw_misc.h"
11 #include "basic_parameters_params.h"
11 #include "basic_parameters_params.h"
12 #include "avf0_prc0.h"
12 #include "avf0_prc0.h"
13
13
14 #define FLOAT_EQUAL_ZERO 0.001
14 #define FLOAT_EQUAL_ZERO 0.001
15 #define NB_BINS_TO_REMOVE 3
15 #define NB_BINS_TO_REMOVE 3
16 #define FI_INTERVAL_COEFF 0.285
16 #define FI_INTERVAL_COEFF 0.285
17 #define BIN_MIN 0
17 #define BIN_MIN 0
18 #define BIN_MAX 127
18 #define BIN_MAX 127
19 #define DELTAF_F0 96.
19 #define DELTAF_F0 96.
20 #define DELTAF_F1 16.
20 #define DELTAF_F1 16.
21 #define DELTAF_F2 1.
21 #define DELTAF_F2 1.
22
22
23 #define BIT_RW1_F1 0x80
23 #define BIT_RW1_F1 0x80
24 #define BIT_RW1_F2 0x40
24 #define BIT_RW1_F2 0x40
25 #define BIT_RW2_F1 0x20
25 #define BIT_RW2_F1 0x20
26 #define BIT_RW2_F2 0x10
26 #define BIT_RW2_F2 0x10
27 #define BIT_RW3_F1 0x08
27 #define BIT_RW3_F1 0x08
28 #define BIT_RW3_F2 0x04
28 #define BIT_RW3_F2 0x04
29 #define BIT_RW4_F1 0x02
29 #define BIT_RW4_F1 0x02
30 #define BIT_RW4_F2 0x01
30 #define BIT_RW4_F2 0x01
31
31
32 #define WHEEL_1 1
33 #define WHEEL_2 2
34 #define WHEEL_3 3
35 #define WHEEL_4 4
36 #define FREQ_1 1
37 #define FREQ_2 2
38 #define FREQ_3 3
39 #define FREQ_4 4
40 #define FLAG_OFFSET_WHEELS_1_3 8
41 #define FLAG_OFFSET_WHEELS_2_4 4
42
43 #define FLAG_NAN 0 // Not A NUMBER
44 #define FLAG_IAN 1 // Is A Number
45
32 #define SBM_KCOEFF_PER_NORM_KCOEFF 2
46 #define SBM_KCOEFF_PER_NORM_KCOEFF 2
33
47
34 extern unsigned short sequenceCounterParameterDump;
48 extern unsigned short sequenceCounterParameterDump;
35 extern unsigned short sequenceCounters_TM_DUMP[];
49 extern unsigned short sequenceCounters_TM_DUMP[];
36 extern float k_coeff_intercalib_f0_norm[ ];
50 extern float k_coeff_intercalib_f0_norm[ ];
37 extern float k_coeff_intercalib_f0_sbm[ ];
51 extern float k_coeff_intercalib_f0_sbm[ ];
38 extern float k_coeff_intercalib_f1_norm[ ];
52 extern float k_coeff_intercalib_f1_norm[ ];
39 extern float k_coeff_intercalib_f1_sbm[ ];
53 extern float k_coeff_intercalib_f1_sbm[ ];
40 extern float k_coeff_intercalib_f2[ ];
54 extern float k_coeff_intercalib_f2[ ];
41 extern fbins_masks_t fbins_masks;
55 extern fbins_masks_t fbins_masks;
42
56
43 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
57 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
44 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
58 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
45 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
59 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
46 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
60 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
47 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
61 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
48 int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
62 int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
49 int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
63 int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
50 int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
64 int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
51 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
65 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
52 int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
66 int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
53
67
54 // NORMAL
68 // NORMAL
55 int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
69 int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
56 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC );
70 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC );
57 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC );
71 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC );
58 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC );
72 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC );
59 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC );
73 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC );
60 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC );
74 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC );
61 int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC );
75 int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC );
62
76
63 // BURST
77 // BURST
64 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC );
78 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC );
65 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC );
79 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC );
66
80
67 // SBM1
81 // SBM1
68 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC );
82 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC );
69 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC );
83 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC );
70
84
71 // SBM2
85 // SBM2
72 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC );
86 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC );
73 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC );
87 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC );
74
88
75 // TC_LFR_UPDATE_INFO
89 // TC_LFR_UPDATE_INFO
76 unsigned int check_update_info_hk_lfr_mode( unsigned char mode );
90 unsigned int check_update_info_hk_lfr_mode( unsigned char mode );
77 unsigned int check_update_info_hk_tds_mode( unsigned char mode );
91 unsigned int check_update_info_hk_tds_mode( unsigned char mode );
78 unsigned int check_update_info_hk_thr_mode( unsigned char mode );
92 unsigned int check_update_info_hk_thr_mode( unsigned char mode );
93 void set_hk_lfr_sc_rw_f_flag( unsigned char wheel, unsigned char freq, float value );
94 void set_hk_lfr_sc_rw_f_flags( void );
79 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC );
95 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC );
80 void setFBinMask(unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, unsigned char flag );
96 void setFBinMask(unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, unsigned char flag );
81 void build_sy_lfr_rw_mask( unsigned int channel );
97 void build_sy_lfr_rw_mask( unsigned int channel );
82 void build_sy_lfr_rw_masks();
98 void build_sy_lfr_rw_masks();
83 void merge_fbins_masks( void );
99 void merge_fbins_masks( void );
84
100
85 // FBINS_MASK
101 // FBINS_MASK
86 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC );
102 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC );
87
103
88 // TC_LFR_LOAD_PARS_FILTER_PAR
104 // TC_LFR_LOAD_PARS_FILTER_PAR
89 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
105 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
90
106
91 // KCOEFFICIENTS
107 // KCOEFFICIENTS
92 int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id);
108 int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id);
93 void copyFloatByChar( unsigned char *destination, unsigned char *source );
109 void copyFloatByChar( unsigned char *destination, unsigned char *source );
94 void floatToChar( float value, unsigned char* ptr);
110 void floatToChar( float value, unsigned char* ptr);
95
111
96 void init_parameter_dump( void );
112 void init_parameter_dump( void );
97 void init_kcoefficients_dump( void );
113 void init_kcoefficients_dump( void );
98 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr );
114 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr );
99 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id );
115 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id );
100
116
101 #endif // TC_LOAD_DUMP_PARAMETERS_H
117 #endif // TC_LOAD_DUMP_PARAMETERS_H
@@ -1,106 +1,100
1 /** Global variables of the LFR flight software.
1 /** Global variables of the LFR flight software.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * Among global variables, there are:
6 * Among global variables, there are:
7 * - RTEMS names and id.
7 * - RTEMS names and id.
8 * - APB configuration registers.
8 * - APB configuration registers.
9 * - waveforms global buffers, used by the waveform picker hardware module to store data.
9 * - waveforms global buffers, used by the waveform picker hardware module to store data.
10 * - spectral matrices buffesr, used by the hardware module to store data.
10 * - spectral matrices buffesr, used by the hardware module to store data.
11 * - variable related to LFR modes parameters.
11 * - variable related to LFR modes parameters.
12 * - the global HK packet buffer.
12 * - the global HK packet buffer.
13 * - the global dump parameter buffer.
13 * - the global dump parameter buffer.
14 *
14 *
15 */
15 */
16
16
17 #include <rtems.h>
17 #include <rtems.h>
18 #include <grspw.h>
18 #include <grspw.h>
19
19
20 #include "ccsds_types.h"
20 #include "ccsds_types.h"
21 #include "grlib_regs.h"
21 #include "grlib_regs.h"
22 #include "fsw_params.h"
22 #include "fsw_params.h"
23 #include "fsw_params_wf_handler.h"
23 #include "fsw_params_wf_handler.h"
24
24
25 #define NB_OF_TASKS 20
25 #define NB_OF_TASKS 20
26 #define NB_OF_MISC_NAMES 5
26 #define NB_OF_MISC_NAMES 5
27
27
28 // RTEMS GLOBAL VARIABLES
28 // RTEMS GLOBAL VARIABLES
29 rtems_name misc_name[NB_OF_MISC_NAMES] = {0};
29 rtems_name misc_name[NB_OF_MISC_NAMES] = {0};
30 rtems_name Task_name[NB_OF_TASKS] = {0}; /* array of task names */
30 rtems_name Task_name[NB_OF_TASKS] = {0}; /* array of task names */
31 rtems_id Task_id[NB_OF_TASKS] = {0}; /* array of task ids */
31 rtems_id Task_id[NB_OF_TASKS] = {0}; /* array of task ids */
32 rtems_name timecode_timer_name = 0;
32 rtems_name timecode_timer_name = 0;
33 rtems_id timecode_timer_id = RTEMS_ID_NONE;
33 rtems_id timecode_timer_id = RTEMS_ID_NONE;
34 rtems_name name_hk_rate_monotonic = 0; // name of the HK rate monotonic
34 rtems_name name_hk_rate_monotonic = 0; // name of the HK rate monotonic
35 rtems_id HK_id = RTEMS_ID_NONE;// id of the HK rate monotonic period
35 rtems_id HK_id = RTEMS_ID_NONE;// id of the HK rate monotonic period
36 rtems_name name_avgv_rate_monotonic = 0; // name of the AVGV rate monotonic
36 rtems_name name_avgv_rate_monotonic = 0; // name of the AVGV rate monotonic
37 rtems_id AVGV_id = RTEMS_ID_NONE;// id of the AVGV rate monotonic period
37 rtems_id AVGV_id = RTEMS_ID_NONE;// id of the AVGV rate monotonic period
38 int fdSPW = 0;
38 int fdSPW = 0;
39 int fdUART = 0;
39 int fdUART = 0;
40 unsigned char lfrCurrentMode = 0;
40 unsigned char lfrCurrentMode = 0;
41 unsigned char pa_bia_status_info = 0;
41 unsigned char pa_bia_status_info = 0;
42 unsigned char thisIsAnASMRestart = 0;
42 unsigned char thisIsAnASMRestart = 0;
43 unsigned char oneTcLfrUpdateTimeReceived = 0;
43 unsigned char oneTcLfrUpdateTimeReceived = 0;
44
44
45 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584
45 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584
46 // 97 * 256 = 24832 => delta = 248 bytes = 62 words
46 // 97 * 256 = 24832 => delta = 248 bytes = 62 words
47 // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264
47 // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264
48 // 127 * 256 = 32512 => delta = 248 bytes = 62 words
48 // 127 * 256 = 32512 => delta = 248 bytes = 62 words
49 // F0 F1 F2 F3
49 // F0 F1 F2 F3
50 volatile int wf_buffer_f0[ NB_RING_NODES_F0 * WFRM_BUFFER ] __attribute__((aligned(0x100))) = {0};
50 volatile int wf_buffer_f0[ NB_RING_NODES_F0 * WFRM_BUFFER ] __attribute__((aligned(0x100))) = {0};
51 volatile int wf_buffer_f1[ NB_RING_NODES_F1 * WFRM_BUFFER ] __attribute__((aligned(0x100))) = {0};
51 volatile int wf_buffer_f1[ NB_RING_NODES_F1 * WFRM_BUFFER ] __attribute__((aligned(0x100))) = {0};
52 volatile int wf_buffer_f2[ NB_RING_NODES_F2 * WFRM_BUFFER ] __attribute__((aligned(0x100))) = {0};
52 volatile int wf_buffer_f2[ NB_RING_NODES_F2 * WFRM_BUFFER ] __attribute__((aligned(0x100))) = {0};
53 volatile int wf_buffer_f3[ NB_RING_NODES_F3 * WFRM_BUFFER ] __attribute__((aligned(0x100))) = {0};
53 volatile int wf_buffer_f3[ NB_RING_NODES_F3 * WFRM_BUFFER ] __attribute__((aligned(0x100))) = {0};
54
54
55 //***********************************
55 //***********************************
56 // SPECTRAL MATRICES GLOBAL VARIABLES
56 // SPECTRAL MATRICES GLOBAL VARIABLES
57
57
58 // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00
58 // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00
59 volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))) = {0};
59 volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))) = {0};
60 volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))) = {0};
60 volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))) = {0};
61 volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))) = {0};
61 volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))) = {0};
62
62
63 // APB CONFIGURATION REGISTERS
63 // APB CONFIGURATION REGISTERS
64 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
64 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
65 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
65 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
66 waveform_picker_regs_0_1_18_t *waveform_picker_regs = (waveform_picker_regs_0_1_18_t*) REGS_ADDR_WAVEFORM_PICKER;
66 waveform_picker_regs_0_1_18_t *waveform_picker_regs = (waveform_picker_regs_0_1_18_t*) REGS_ADDR_WAVEFORM_PICKER;
67 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
67 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
68
68
69 // MODE PARAMETERS
69 // MODE PARAMETERS
70 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet = {0};
70 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet = {0};
71 struct param_local_str param_local = {0};
71 struct param_local_str param_local = {0};
72 unsigned int lastValidEnterModeTime = {0};
72 unsigned int lastValidEnterModeTime = {0};
73
73
74 // HK PACKETS
74 // HK PACKETS
75 Packet_TM_LFR_HK_t housekeeping_packet = {0};
75 Packet_TM_LFR_HK_t housekeeping_packet = {0};
76 unsigned char cp_rpw_sc_rw_f_flags = 0;
76 unsigned char cp_rpw_sc_rw1_rw2_f_flags = 0;
77 unsigned char cp_rpw_sc_rw3_rw4_f_flags = 0;
77 // message queues occupancy
78 // message queues occupancy
78 unsigned char hk_lfr_q_sd_fifo_size_max = 0;
79 unsigned char hk_lfr_q_sd_fifo_size_max = 0;
79 unsigned char hk_lfr_q_rv_fifo_size_max = 0;
80 unsigned char hk_lfr_q_rv_fifo_size_max = 0;
80 unsigned char hk_lfr_q_p0_fifo_size_max = 0;
81 unsigned char hk_lfr_q_p0_fifo_size_max = 0;
81 unsigned char hk_lfr_q_p1_fifo_size_max = 0;
82 unsigned char hk_lfr_q_p1_fifo_size_max = 0;
82 unsigned char hk_lfr_q_p2_fifo_size_max = 0;
83 unsigned char hk_lfr_q_p2_fifo_size_max = 0;
83 // sequence counters are incremented by APID (PID + CAT) and destination ID
84 // sequence counters are incremented by APID (PID + CAT) and destination ID
84 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST = 0;
85 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST = 0;
85 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2 = 0;
86 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2 = 0;
86 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID] = {0};
87 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID] = {0};
87 unsigned short sequenceCounters_TM_DUMP[SEQ_CNT_NB_DEST_ID] = {0};
88 unsigned short sequenceCounters_TM_DUMP[SEQ_CNT_NB_DEST_ID] = {0};
88 unsigned short sequenceCounterHK = {0};
89 unsigned short sequenceCounterHK = {0};
89 spw_stats grspw_stats = {0};
90 spw_stats grspw_stats = {0};
90
91
91 // TC_LFR_UPDATE_INFO
92 // TC_LFR_UPDATE_INFO
92 float cp_rpw_sc_rw1_f1 = INIT_FLOAT;
93 rw_f_t rw_f;
93 float cp_rpw_sc_rw1_f2 = INIT_FLOAT;
94 float cp_rpw_sc_rw2_f1 = INIT_FLOAT;
95 float cp_rpw_sc_rw2_f2 = INIT_FLOAT;
96 float cp_rpw_sc_rw3_f1 = INIT_FLOAT;
97 float cp_rpw_sc_rw3_f2 = INIT_FLOAT;
98 float cp_rpw_sc_rw4_f1 = INIT_FLOAT;
99 float cp_rpw_sc_rw4_f2 = INIT_FLOAT;
100
94
101 // TC_LFR_LOAD_FILTER_PAR
95 // TC_LFR_LOAD_FILTER_PAR
102 filterPar_t filterPar = {0};
96 filterPar_t filterPar = {0};
103
97
104 fbins_masks_t fbins_masks = {0};
98 fbins_masks_t fbins_masks = {0};
105 unsigned int acquisitionDurations[NB_ACQUISITION_DURATION]
99 unsigned int acquisitionDurations[NB_ACQUISITION_DURATION]
106 = {ACQUISITION_DURATION_F0, ACQUISITION_DURATION_F1, ACQUISITION_DURATION_F2};
100 = {ACQUISITION_DURATION_F0, ACQUISITION_DURATION_F1, ACQUISITION_DURATION_F2};
@@ -1,945 +1,959
1 /** This is the RTEMS initialization module.
1 /** This is the RTEMS initialization module.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * This module contains two very different information:
6 * This module contains two very different information:
7 * - specific instructions to configure the compilation of the RTEMS executive
7 * - specific instructions to configure the compilation of the RTEMS executive
8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
9 *
9 *
10 */
10 */
11
11
12 //*************************
12 //*************************
13 // GPL reminder to be added
13 // GPL reminder to be added
14 //*************************
14 //*************************
15
15
16 #include <rtems.h>
16 #include <rtems.h>
17
17
18 /* configuration information */
18 /* configuration information */
19
19
20 #define CONFIGURE_INIT
20 #define CONFIGURE_INIT
21
21
22 #include <bsp.h> /* for device driver prototypes */
22 #include <bsp.h> /* for device driver prototypes */
23
23
24 /* configuration information */
24 /* configuration information */
25
25
26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
28
28
29 #define CONFIGURE_MAXIMUM_TASKS 20
29 #define CONFIGURE_MAXIMUM_TASKS 20
30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
35 #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
35 #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
36 #define CONFIGURE_MAXIMUM_DRIVERS 16
36 #define CONFIGURE_MAXIMUM_DRIVERS 16
37 #define CONFIGURE_MAXIMUM_PERIODS 5
37 #define CONFIGURE_MAXIMUM_PERIODS 5
38 #define CONFIGURE_MAXIMUM_TIMERS 5 // [spiq] [link] [spacewire_reset_link]
38 #define CONFIGURE_MAXIMUM_TIMERS 5 // [spiq] [link] [spacewire_reset_link]
39 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
39 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
40 #ifdef PRINT_STACK_REPORT
40 #ifdef PRINT_STACK_REPORT
41 #define CONFIGURE_STACK_CHECKER_ENABLED
41 #define CONFIGURE_STACK_CHECKER_ENABLED
42 #endif
42 #endif
43
43
44 #include <rtems/confdefs.h>
44 #include <rtems/confdefs.h>
45
45
46 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
46 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
47 #ifdef RTEMS_DRVMGR_STARTUP
47 #ifdef RTEMS_DRVMGR_STARTUP
48 #ifdef LEON3
48 #ifdef LEON3
49 /* Add Timer and UART Driver */
49 /* Add Timer and UART Driver */
50
50
51 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
51 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
52 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
52 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
53 #endif
53 #endif
54
54
55 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
55 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
57 #endif
57 #endif
58
58
59 #endif
59 #endif
60 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
60 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
61
61
62 #include <drvmgr/drvmgr_confdefs.h>
62 #include <drvmgr/drvmgr_confdefs.h>
63 #endif
63 #endif
64
64
65 #include "fsw_init.h"
65 #include "fsw_init.h"
66 #include "fsw_config.c"
66 #include "fsw_config.c"
67 #include "GscMemoryLPP.hpp"
67 #include "GscMemoryLPP.hpp"
68
68
69 void initCache()
69 void initCache()
70 {
70 {
71 // ASI 2 contains a few control registers that have not been assigned as ancillary state registers.
71 // ASI 2 contains a few control registers that have not been assigned as ancillary state registers.
72 // These should only be read and written using 32-bit LDA/STA instructions.
72 // These should only be read and written using 32-bit LDA/STA instructions.
73 // All cache registers are accessed through load/store operations to the alternate address space (LDA/STA), using ASI = 2.
73 // All cache registers are accessed through load/store operations to the alternate address space (LDA/STA), using ASI = 2.
74 // The table below shows the register addresses:
74 // The table below shows the register addresses:
75 // 0x00 Cache control register
75 // 0x00 Cache control register
76 // 0x04 Reserved
76 // 0x04 Reserved
77 // 0x08 Instruction cache configuration register
77 // 0x08 Instruction cache configuration register
78 // 0x0C Data cache configuration register
78 // 0x0C Data cache configuration register
79
79
80 // Cache Control Register Leon3 / Leon3FT
80 // Cache Control Register Leon3 / Leon3FT
81 // 31..30 29 28 27..24 23 22 21 20..19 18 17 16
81 // 31..30 29 28 27..24 23 22 21 20..19 18 17 16
82 // RFT PS TB DS FD FI FT ST IB
82 // RFT PS TB DS FD FI FT ST IB
83 // 15 14 13..12 11..10 9..8 7..6 5 4 3..2 1..0
83 // 15 14 13..12 11..10 9..8 7..6 5 4 3..2 1..0
84 // IP DP ITE IDE DTE DDE DF IF DCS ICS
84 // IP DP ITE IDE DTE DDE DF IF DCS ICS
85
85
86 unsigned int cacheControlRegister;
86 unsigned int cacheControlRegister;
87
87
88 CCR_resetCacheControlRegister();
88 CCR_resetCacheControlRegister();
89 ASR16_resetRegisterProtectionControlRegister();
89 ASR16_resetRegisterProtectionControlRegister();
90
90
91 cacheControlRegister = CCR_getValue();
91 cacheControlRegister = CCR_getValue();
92 PRINTF1("(0) CCR - Cache Control Register = %x\n", cacheControlRegister);
92 PRINTF1("(0) CCR - Cache Control Register = %x\n", cacheControlRegister);
93 PRINTF1("(0) ASR16 = %x\n", *asr16Ptr);
93 PRINTF1("(0) ASR16 = %x\n", *asr16Ptr);
94
94
95 CCR_enableInstructionCache(); // ICS bits
95 CCR_enableInstructionCache(); // ICS bits
96 CCR_enableDataCache(); // DCS bits
96 CCR_enableDataCache(); // DCS bits
97 CCR_enableInstructionBurstFetch(); // IB bit
97 CCR_enableInstructionBurstFetch(); // IB bit
98
98
99 faultTolerantScheme();
99 faultTolerantScheme();
100
100
101 cacheControlRegister = CCR_getValue();
101 cacheControlRegister = CCR_getValue();
102 PRINTF1("(1) CCR - Cache Control Register = %x\n", cacheControlRegister);
102 PRINTF1("(1) CCR - Cache Control Register = %x\n", cacheControlRegister);
103 PRINTF1("(1) ASR16 Register protection control register = %x\n", *asr16Ptr);
103 PRINTF1("(1) ASR16 Register protection control register = %x\n", *asr16Ptr);
104
104
105 PRINTF("\n");
105 PRINTF("\n");
106 }
106 }
107
107
108 rtems_task Init( rtems_task_argument ignored )
108 rtems_task Init( rtems_task_argument ignored )
109 {
109 {
110 /** This is the RTEMS INIT taks, it is the first task launched by the system.
110 /** This is the RTEMS INIT taks, it is the first task launched by the system.
111 *
111 *
112 * @param unused is the starting argument of the RTEMS task
112 * @param unused is the starting argument of the RTEMS task
113 *
113 *
114 * The INIT task create and run all other RTEMS tasks.
114 * The INIT task create and run all other RTEMS tasks.
115 *
115 *
116 */
116 */
117
117
118 //***********
118 //***********
119 // INIT CACHE
119 // INIT CACHE
120
120
121 unsigned char *vhdlVersion;
121 unsigned char *vhdlVersion;
122
122
123 reset_lfr();
123 reset_lfr();
124
124
125 reset_local_time();
125 reset_local_time();
126
126
127 rtems_cpu_usage_reset();
127 rtems_cpu_usage_reset();
128
128
129 rtems_status_code status;
129 rtems_status_code status;
130 rtems_status_code status_spw;
130 rtems_status_code status_spw;
131 rtems_isr_entry old_isr_handler;
131 rtems_isr_entry old_isr_handler;
132
132
133 old_isr_handler = NULL;
133 old_isr_handler = NULL;
134
134
135 // UART settings
135 // UART settings
136 enable_apbuart_transmitter();
136 enable_apbuart_transmitter();
137 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
137 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
138
138
139 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
139 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
140
140
141
141
142 PRINTF("\n\n\n\n\n")
142 PRINTF("\n\n\n\n\n")
143
143
144 initCache();
144 initCache();
145
145
146 PRINTF("*************************\n")
146 PRINTF("*************************\n")
147 PRINTF("** LFR Flight Software **\n")
147 PRINTF("** LFR Flight Software **\n")
148
148
149 PRINTF1("** %d-", SW_VERSION_N1)
149 PRINTF1("** %d-", SW_VERSION_N1)
150 PRINTF1("%d-" , SW_VERSION_N2)
150 PRINTF1("%d-" , SW_VERSION_N2)
151 PRINTF1("%d-" , SW_VERSION_N3)
151 PRINTF1("%d-" , SW_VERSION_N3)
152 PRINTF1("%d **\n", SW_VERSION_N4)
152 PRINTF1("%d **\n", SW_VERSION_N4)
153
153
154 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
154 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
155 PRINTF("** VHDL **\n")
155 PRINTF("** VHDL **\n")
156 PRINTF1("** %d-", vhdlVersion[1])
156 PRINTF1("** %d-", vhdlVersion[1])
157 PRINTF1("%d-" , vhdlVersion[2])
157 PRINTF1("%d-" , vhdlVersion[2])
158 PRINTF1("%d **\n", vhdlVersion[3])
158 PRINTF1("%d **\n", vhdlVersion[3])
159 PRINTF("*************************\n")
159 PRINTF("*************************\n")
160 PRINTF("\n\n")
160 PRINTF("\n\n")
161
161
162 init_parameter_dump();
162 init_parameter_dump();
163 init_kcoefficients_dump();
163 init_kcoefficients_dump();
164 init_local_mode_parameters();
164 init_local_mode_parameters();
165 init_housekeeping_parameters();
165 init_housekeeping_parameters();
166 init_k_coefficients_prc0();
166 init_k_coefficients_prc0();
167 init_k_coefficients_prc1();
167 init_k_coefficients_prc1();
168 init_k_coefficients_prc2();
168 init_k_coefficients_prc2();
169 pa_bia_status_info = INIT_CHAR;
169 pa_bia_status_info = INIT_CHAR;
170 cp_rpw_sc_rw_f_flags = INIT_CHAR;
170 cp_rpw_sc_rw_f_flags = INIT_CHAR;
171 cp_rpw_sc_rw1_f1 = INIT_FLOAT;
171
172 cp_rpw_sc_rw1_f2 = INIT_FLOAT;
172 // initialize all reaction wheels frequencies to NaN
173 cp_rpw_sc_rw2_f1 = INIT_FLOAT;
173 rw_f.cp_rpw_sc_rw1_f1 = NAN;
174 cp_rpw_sc_rw2_f2 = INIT_FLOAT;
174 rw_f.cp_rpw_sc_rw1_f2 = NAN;
175 cp_rpw_sc_rw3_f1 = INIT_FLOAT;
175 rw_f.cp_rpw_sc_rw1_f3 = NAN;
176 cp_rpw_sc_rw3_f2 = INIT_FLOAT;
176 rw_f.cp_rpw_sc_rw1_f4 = NAN;
177 cp_rpw_sc_rw4_f1 = INIT_FLOAT;
177 rw_f.cp_rpw_sc_rw2_f1 = NAN;
178 cp_rpw_sc_rw4_f2 = INIT_FLOAT;
178 rw_f.cp_rpw_sc_rw2_f2 = NAN;
179 rw_f.cp_rpw_sc_rw2_f3 = NAN;
180 rw_f.cp_rpw_sc_rw2_f4 = NAN;
181 rw_f.cp_rpw_sc_rw3_f1 = NAN;
182 rw_f.cp_rpw_sc_rw3_f2 = NAN;
183 rw_f.cp_rpw_sc_rw3_f3 = NAN;
184 rw_f.cp_rpw_sc_rw3_f4 = NAN;
185 rw_f.cp_rpw_sc_rw4_f1 = NAN;
186 rw_f.cp_rpw_sc_rw4_f2 = NAN;
187 rw_f.cp_rpw_sc_rw4_f3 = NAN;
188 rw_f.cp_rpw_sc_rw4_f4 = NAN;
189
190 cp_rpw_sc_rw1_rw2_f_flags = INIT_CHAR;
191 cp_rpw_sc_rw3_rw4_f_flags = INIT_CHAR;
192
179 // initialize filtering parameters
193 // initialize filtering parameters
180 filterPar.spare_sy_lfr_pas_filter_enabled = DEFAULT_SY_LFR_PAS_FILTER_ENABLED;
194 filterPar.spare_sy_lfr_pas_filter_enabled = DEFAULT_SY_LFR_PAS_FILTER_ENABLED;
181 filterPar.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
195 filterPar.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
182 filterPar.sy_lfr_pas_filter_tbad = DEFAULT_SY_LFR_PAS_FILTER_TBAD;
196 filterPar.sy_lfr_pas_filter_tbad = DEFAULT_SY_LFR_PAS_FILTER_TBAD;
183 filterPar.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
197 filterPar.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
184 filterPar.sy_lfr_pas_filter_shift = DEFAULT_SY_LFR_PAS_FILTER_SHIFT;
198 filterPar.sy_lfr_pas_filter_shift = DEFAULT_SY_LFR_PAS_FILTER_SHIFT;
185 filterPar.sy_lfr_sc_rw_delta_f = DEFAULT_SY_LFR_SC_RW_DELTA_F;
199 filterPar.sy_lfr_sc_rw_delta_f = DEFAULT_SY_LFR_SC_RW_DELTA_F;
186 update_last_valid_transition_date( DEFAULT_LAST_VALID_TRANSITION_DATE );
200 update_last_valid_transition_date( DEFAULT_LAST_VALID_TRANSITION_DATE );
187
201
188 // waveform picker initialization
202 // waveform picker initialization
189 WFP_init_rings();
203 WFP_init_rings();
190 LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings
204 LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings
191 WFP_reset_current_ring_nodes();
205 WFP_reset_current_ring_nodes();
192 reset_waveform_picker_regs();
206 reset_waveform_picker_regs();
193
207
194 // spectral matrices initialization
208 // spectral matrices initialization
195 SM_init_rings(); // initialize spectral matrices rings
209 SM_init_rings(); // initialize spectral matrices rings
196 SM_reset_current_ring_nodes();
210 SM_reset_current_ring_nodes();
197 reset_spectral_matrix_regs();
211 reset_spectral_matrix_regs();
198
212
199 // configure calibration
213 // configure calibration
200 configureCalibration( false ); // true means interleaved mode, false is for normal mode
214 configureCalibration( false ); // true means interleaved mode, false is for normal mode
201
215
202 updateLFRCurrentMode( LFR_MODE_STANDBY );
216 updateLFRCurrentMode( LFR_MODE_STANDBY );
203
217
204 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
218 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
205
219
206 create_names(); // create all names
220 create_names(); // create all names
207
221
208 status = create_timecode_timer(); // create the timer used by timecode_irq_handler
222 status = create_timecode_timer(); // create the timer used by timecode_irq_handler
209 if (status != RTEMS_SUCCESSFUL)
223 if (status != RTEMS_SUCCESSFUL)
210 {
224 {
211 PRINTF1("in INIT *** ERR in create_timer_timecode, code %d", status)
225 PRINTF1("in INIT *** ERR in create_timer_timecode, code %d", status)
212 }
226 }
213
227
214 status = create_message_queues(); // create message queues
228 status = create_message_queues(); // create message queues
215 if (status != RTEMS_SUCCESSFUL)
229 if (status != RTEMS_SUCCESSFUL)
216 {
230 {
217 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
231 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
218 }
232 }
219
233
220 status = create_all_tasks(); // create all tasks
234 status = create_all_tasks(); // create all tasks
221 if (status != RTEMS_SUCCESSFUL)
235 if (status != RTEMS_SUCCESSFUL)
222 {
236 {
223 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
237 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
224 }
238 }
225
239
226 // **************************
240 // **************************
227 // <SPACEWIRE INITIALIZATION>
241 // <SPACEWIRE INITIALIZATION>
228 status_spw = spacewire_open_link(); // (1) open the link
242 status_spw = spacewire_open_link(); // (1) open the link
229 if ( status_spw != RTEMS_SUCCESSFUL )
243 if ( status_spw != RTEMS_SUCCESSFUL )
230 {
244 {
231 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
245 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
232 }
246 }
233
247
234 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
248 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
235 {
249 {
236 status_spw = spacewire_configure_link( fdSPW );
250 status_spw = spacewire_configure_link( fdSPW );
237 if ( status_spw != RTEMS_SUCCESSFUL )
251 if ( status_spw != RTEMS_SUCCESSFUL )
238 {
252 {
239 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
253 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
240 }
254 }
241 }
255 }
242
256
243 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
257 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
244 {
258 {
245 status_spw = spacewire_start_link( fdSPW );
259 status_spw = spacewire_start_link( fdSPW );
246 if ( status_spw != RTEMS_SUCCESSFUL )
260 if ( status_spw != RTEMS_SUCCESSFUL )
247 {
261 {
248 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
262 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
249 }
263 }
250 }
264 }
251 // </SPACEWIRE INITIALIZATION>
265 // </SPACEWIRE INITIALIZATION>
252 // ***************************
266 // ***************************
253
267
254 status = start_all_tasks(); // start all tasks
268 status = start_all_tasks(); // start all tasks
255 if (status != RTEMS_SUCCESSFUL)
269 if (status != RTEMS_SUCCESSFUL)
256 {
270 {
257 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
271 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
258 }
272 }
259
273
260 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
274 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
261 status = start_recv_send_tasks();
275 status = start_recv_send_tasks();
262 if ( status != RTEMS_SUCCESSFUL )
276 if ( status != RTEMS_SUCCESSFUL )
263 {
277 {
264 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
278 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
265 }
279 }
266
280
267 // suspend science tasks, they will be restarted later depending on the mode
281 // suspend science tasks, they will be restarted later depending on the mode
268 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
282 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
269 if (status != RTEMS_SUCCESSFUL)
283 if (status != RTEMS_SUCCESSFUL)
270 {
284 {
271 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
285 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
272 }
286 }
273
287
274 // configure IRQ handling for the waveform picker unit
288 // configure IRQ handling for the waveform picker unit
275 status = rtems_interrupt_catch( waveforms_isr,
289 status = rtems_interrupt_catch( waveforms_isr,
276 IRQ_SPARC_WAVEFORM_PICKER,
290 IRQ_SPARC_WAVEFORM_PICKER,
277 &old_isr_handler) ;
291 &old_isr_handler) ;
278 // configure IRQ handling for the spectral matrices unit
292 // configure IRQ handling for the spectral matrices unit
279 status = rtems_interrupt_catch( spectral_matrices_isr,
293 status = rtems_interrupt_catch( spectral_matrices_isr,
280 IRQ_SPARC_SPECTRAL_MATRIX,
294 IRQ_SPARC_SPECTRAL_MATRIX,
281 &old_isr_handler) ;
295 &old_isr_handler) ;
282
296
283 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
297 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
284 if ( status_spw != RTEMS_SUCCESSFUL )
298 if ( status_spw != RTEMS_SUCCESSFUL )
285 {
299 {
286 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
300 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
287 if ( status != RTEMS_SUCCESSFUL ) {
301 if ( status != RTEMS_SUCCESSFUL ) {
288 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
302 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
289 }
303 }
290 }
304 }
291
305
292 BOOT_PRINTF("delete INIT\n")
306 BOOT_PRINTF("delete INIT\n")
293
307
294 set_hk_lfr_sc_potential_flag( true );
308 set_hk_lfr_sc_potential_flag( true );
295
309
296 // start the timer to detect a missing spacewire timecode
310 // start the timer to detect a missing spacewire timecode
297 // the timeout is larger because the spw IP needs to receive several valid timecodes before generating a tickout
311 // the timeout is larger because the spw IP needs to receive several valid timecodes before generating a tickout
298 // if a tickout is generated, the timer is restarted
312 // if a tickout is generated, the timer is restarted
299 status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT_INIT, timecode_timer_routine, NULL );
313 status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT_INIT, timecode_timer_routine, NULL );
300
314
301 grspw_timecode_callback = &timecode_irq_handler;
315 grspw_timecode_callback = &timecode_irq_handler;
302
316
303 status = rtems_task_delete(RTEMS_SELF);
317 status = rtems_task_delete(RTEMS_SELF);
304
318
305 }