@@ -1,2 +1,2 | |||
|
1 | 1 | 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters |
|
2 |
|
|
|
2 | 058c1234c2defe215d3dd655a7ef65abb33c922d header/lfr_common_headers |
@@ -1,64 +1,59 | |||
|
1 | 1 | #ifndef FSW_INIT_H_INCLUDED |
|
2 | 2 | #define FSW_INIT_H_INCLUDED |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <leon.h> |
|
6 | 6 | |
|
7 | 7 | #include "fsw_params.h" |
|
8 | 8 | #include "fsw_misc.h" |
|
9 | 9 | #include "fsw_processing.h" |
|
10 | 10 | |
|
11 | 11 | #include "tc_handler.h" |
|
12 | 12 | #include "wf_handler.h" |
|
13 | 13 | #include "fsw_spacewire.h" |
|
14 | 14 | |
|
15 | 15 | #include "avf0_prc0.h" |
|
16 | 16 | #include "avf1_prc1.h" |
|
17 | 17 | #include "avf2_prc2.h" |
|
18 | 18 | |
|
19 | 19 | extern rtems_name Task_name[]; /* array of task names */ |
|
20 | 20 | extern rtems_id Task_id[]; /* array of task ids */ |
|
21 | 21 | extern rtems_name timecode_timer_name; |
|
22 | 22 | extern rtems_id timecode_timer_id; |
|
23 | 23 | extern unsigned char pa_bia_status_info; |
|
24 | extern unsigned char cp_rpw_sc_rw_f_flags; | |
|
25 |
extern |
|
|
26 | extern float cp_rpw_sc_rw1_f2; | |
|
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; | |
|
24 | extern unsigned char cp_rpw_sc_rw1_rw2_f_flags; | |
|
25 | extern unsigned char cp_rpw_sc_rw3_rw4_f_flags; | |
|
26 | ||
|
33 | 27 | extern filterPar_t filterPar; |
|
28 | extern rw_f_t rw_f; | |
|
34 | 29 | |
|
35 | 30 | // RTEMS TASKS |
|
36 | 31 | rtems_task Init( rtems_task_argument argument); |
|
37 | 32 | |
|
38 | 33 | // OTHER functions |
|
39 | 34 | void create_names( void ); |
|
40 | 35 | int create_all_tasks( void ); |
|
41 | 36 | int start_all_tasks( void ); |
|
42 | 37 | // |
|
43 | 38 | rtems_status_code create_message_queues( void ); |
|
44 | 39 | rtems_status_code create_timecode_timer( void ); |
|
45 | 40 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ); |
|
46 | 41 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ); |
|
47 | 42 | rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id ); |
|
48 | 43 | rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ); |
|
49 | 44 | rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ); |
|
50 | 45 | void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max ); |
|
51 | 46 | void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize ); |
|
52 | 47 | // |
|
53 | 48 | int start_recv_send_tasks( void ); |
|
54 | 49 | // |
|
55 | 50 | void init_local_mode_parameters( void ); |
|
56 | 51 | void reset_local_time( void ); |
|
57 | 52 | |
|
58 | 53 | extern void rtems_cpu_usage_report( void ); |
|
59 | 54 | extern void rtems_cpu_usage_reset( void ); |
|
60 | 55 | extern void rtems_stack_checker_report_usage( void ); |
|
61 | 56 | |
|
62 | 57 | extern int sched_yield( void ); |
|
63 | 58 | |
|
64 | 59 | #endif // FSW_INIT_H_INCLUDED |
@@ -1,101 +1,117 | |||
|
1 | 1 | #ifndef TC_LOAD_DUMP_PARAMETERS_H |
|
2 | 2 | #define TC_LOAD_DUMP_PARAMETERS_H |
|
3 | 3 | |
|
4 | 4 | #include <rtems.h> |
|
5 | 5 | #include <stdio.h> |
|
6 | 6 | |
|
7 | 7 | #include "fsw_params.h" |
|
8 | 8 | #include "wf_handler.h" |
|
9 | 9 | #include "tm_lfr_tc_exe.h" |
|
10 | 10 | #include "fsw_misc.h" |
|
11 | 11 | #include "basic_parameters_params.h" |
|
12 | 12 | #include "avf0_prc0.h" |
|
13 | 13 | |
|
14 | 14 | #define FLOAT_EQUAL_ZERO 0.001 |
|
15 | 15 | #define NB_BINS_TO_REMOVE 3 |
|
16 | 16 | #define FI_INTERVAL_COEFF 0.285 |
|
17 | 17 | #define BIN_MIN 0 |
|
18 | 18 | #define BIN_MAX 127 |
|
19 | 19 | #define DELTAF_F0 96. |
|
20 | 20 | #define DELTAF_F1 16. |
|
21 | 21 | #define DELTAF_F2 1. |
|
22 | 22 | |
|
23 | 23 | #define BIT_RW1_F1 0x80 |
|
24 | 24 | #define BIT_RW1_F2 0x40 |
|
25 | 25 | #define BIT_RW2_F1 0x20 |
|
26 | 26 | #define BIT_RW2_F2 0x10 |
|
27 | 27 | #define BIT_RW3_F1 0x08 |
|
28 | 28 | #define BIT_RW3_F2 0x04 |
|
29 | 29 | #define BIT_RW4_F1 0x02 |
|
30 | 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 | 46 | #define SBM_KCOEFF_PER_NORM_KCOEFF 2 |
|
33 | 47 | |
|
34 | 48 | extern unsigned short sequenceCounterParameterDump; |
|
35 | 49 | extern unsigned short sequenceCounters_TM_DUMP[]; |
|
36 | 50 | extern float k_coeff_intercalib_f0_norm[ ]; |
|
37 | 51 | extern float k_coeff_intercalib_f0_sbm[ ]; |
|
38 | 52 | extern float k_coeff_intercalib_f1_norm[ ]; |
|
39 | 53 | extern float k_coeff_intercalib_f1_sbm[ ]; |
|
40 | 54 | extern float k_coeff_intercalib_f2[ ]; |
|
41 | 55 | extern fbins_masks_t fbins_masks; |
|
42 | 56 | |
|
43 | 57 | int action_load_common_par( ccsdsTelecommandPacket_t *TC ); |
|
44 | 58 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
45 | 59 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
46 | 60 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
47 | 61 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
48 | 62 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
49 | 63 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
50 | 64 | int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
51 | 65 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
52 | 66 | int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
53 | 67 | |
|
54 | 68 | // NORMAL |
|
55 | 69 | int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
56 | 70 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ); |
|
57 | 71 | int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC ); |
|
58 | 72 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ); |
|
59 | 73 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
60 | 74 | int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
61 | 75 | int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC ); |
|
62 | 76 | |
|
63 | 77 | // BURST |
|
64 | 78 | int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
65 | 79 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
66 | 80 | |
|
67 | 81 | // SBM1 |
|
68 | 82 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
69 | 83 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
70 | 84 | |
|
71 | 85 | // SBM2 |
|
72 | 86 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
73 | 87 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
74 | 88 | |
|
75 | 89 | // TC_LFR_UPDATE_INFO |
|
76 | 90 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ); |
|
77 | 91 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ); |
|
78 | 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 | 95 | void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC ); |
|
80 | 96 | void setFBinMask(unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, unsigned char flag ); |
|
81 | 97 | void build_sy_lfr_rw_mask( unsigned int channel ); |
|
82 | 98 | void build_sy_lfr_rw_masks(); |
|
83 | 99 | void merge_fbins_masks( void ); |
|
84 | 100 | |
|
85 | 101 | // FBINS_MASK |
|
86 | 102 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ); |
|
87 | 103 | |
|
88 | 104 | // TC_LFR_LOAD_PARS_FILTER_PAR |
|
89 | 105 | int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
90 | 106 | |
|
91 | 107 | // KCOEFFICIENTS |
|
92 | 108 | int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id); |
|
93 | 109 | void copyFloatByChar( unsigned char *destination, unsigned char *source ); |
|
94 | 110 | void floatToChar( float value, unsigned char* ptr); |
|
95 | 111 | |
|
96 | 112 | void init_parameter_dump( void ); |
|
97 | 113 | void init_kcoefficients_dump( void ); |
|
98 | 114 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ); |
|
99 | 115 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ); |
|
100 | 116 | |
|
101 | 117 | #endif // TC_LOAD_DUMP_PARAMETERS_H |
@@ -1,106 +1,100 | |||
|
1 | 1 | /** Global variables of the LFR flight software. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * Among global variables, there are: |
|
7 | 7 | * - RTEMS names and id. |
|
8 | 8 | * - APB configuration registers. |
|
9 | 9 | * - waveforms global buffers, used by the waveform picker hardware module to store data. |
|
10 | 10 | * - spectral matrices buffesr, used by the hardware module to store data. |
|
11 | 11 | * - variable related to LFR modes parameters. |
|
12 | 12 | * - the global HK packet buffer. |
|
13 | 13 | * - the global dump parameter buffer. |
|
14 | 14 | * |
|
15 | 15 | */ |
|
16 | 16 | |
|
17 | 17 | #include <rtems.h> |
|
18 | 18 | #include <grspw.h> |
|
19 | 19 | |
|
20 | 20 | #include "ccsds_types.h" |
|
21 | 21 | #include "grlib_regs.h" |
|
22 | 22 | #include "fsw_params.h" |
|
23 | 23 | #include "fsw_params_wf_handler.h" |
|
24 | 24 | |
|
25 | 25 | #define NB_OF_TASKS 20 |
|
26 | 26 | #define NB_OF_MISC_NAMES 5 |
|
27 | 27 | |
|
28 | 28 | // RTEMS GLOBAL VARIABLES |
|
29 | 29 | rtems_name misc_name[NB_OF_MISC_NAMES] = {0}; |
|
30 | 30 | rtems_name Task_name[NB_OF_TASKS] = {0}; /* array of task names */ |
|
31 | 31 | rtems_id Task_id[NB_OF_TASKS] = {0}; /* array of task ids */ |
|
32 | 32 | rtems_name timecode_timer_name = 0; |
|
33 | 33 | rtems_id timecode_timer_id = RTEMS_ID_NONE; |
|
34 | 34 | rtems_name name_hk_rate_monotonic = 0; // name of the HK rate monotonic |
|
35 | 35 | rtems_id HK_id = RTEMS_ID_NONE;// id of the HK rate monotonic period |
|
36 | 36 | rtems_name name_avgv_rate_monotonic = 0; // name of the AVGV rate monotonic |
|
37 | 37 | rtems_id AVGV_id = RTEMS_ID_NONE;// id of the AVGV rate monotonic period |
|
38 | 38 | int fdSPW = 0; |
|
39 | 39 | int fdUART = 0; |
|
40 | 40 | unsigned char lfrCurrentMode = 0; |
|
41 | 41 | unsigned char pa_bia_status_info = 0; |
|
42 | 42 | unsigned char thisIsAnASMRestart = 0; |
|
43 | 43 | unsigned char oneTcLfrUpdateTimeReceived = 0; |
|
44 | 44 | |
|
45 | 45 | // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584 |
|
46 | 46 | // 97 * 256 = 24832 => delta = 248 bytes = 62 words |
|
47 | 47 | // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264 |
|
48 | 48 | // 127 * 256 = 32512 => delta = 248 bytes = 62 words |
|
49 | 49 | // F0 F1 F2 F3 |
|
50 | 50 | volatile int wf_buffer_f0[ NB_RING_NODES_F0 * WFRM_BUFFER ] __attribute__((aligned(0x100))) = {0}; |
|
51 | 51 | volatile int wf_buffer_f1[ NB_RING_NODES_F1 * WFRM_BUFFER ] __attribute__((aligned(0x100))) = {0}; |
|
52 | 52 | volatile int wf_buffer_f2[ NB_RING_NODES_F2 * WFRM_BUFFER ] __attribute__((aligned(0x100))) = {0}; |
|
53 | 53 | volatile int wf_buffer_f3[ NB_RING_NODES_F3 * WFRM_BUFFER ] __attribute__((aligned(0x100))) = {0}; |
|
54 | 54 | |
|
55 | 55 | //*********************************** |
|
56 | 56 | // SPECTRAL MATRICES GLOBAL VARIABLES |
|
57 | 57 | |
|
58 | 58 | // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00 |
|
59 | 59 | volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))) = {0}; |
|
60 | 60 | volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))) = {0}; |
|
61 | 61 | volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100))) = {0}; |
|
62 | 62 | |
|
63 | 63 | // APB CONFIGURATION REGISTERS |
|
64 | 64 | time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT; |
|
65 | 65 | gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER; |
|
66 | 66 | waveform_picker_regs_0_1_18_t *waveform_picker_regs = (waveform_picker_regs_0_1_18_t*) REGS_ADDR_WAVEFORM_PICKER; |
|
67 | 67 | spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX; |
|
68 | 68 | |
|
69 | 69 | // MODE PARAMETERS |
|
70 | 70 | Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet = {0}; |
|
71 | 71 | struct param_local_str param_local = {0}; |
|
72 | 72 | unsigned int lastValidEnterModeTime = {0}; |
|
73 | 73 | |
|
74 | 74 | // HK PACKETS |
|
75 | 75 | Packet_TM_LFR_HK_t housekeeping_packet = {0}; |
|
76 |
unsigned char cp_rpw_sc_rw_f_flags |
|
|
76 | unsigned char cp_rpw_sc_rw1_rw2_f_flags = 0; | |
|
77 | unsigned char cp_rpw_sc_rw3_rw4_f_flags = 0; | |
|
77 | 78 | // message queues occupancy |
|
78 | 79 | unsigned char hk_lfr_q_sd_fifo_size_max = 0; |
|
79 | 80 | unsigned char hk_lfr_q_rv_fifo_size_max = 0; |
|
80 | 81 | unsigned char hk_lfr_q_p0_fifo_size_max = 0; |
|
81 | 82 | unsigned char hk_lfr_q_p1_fifo_size_max = 0; |
|
82 | 83 | unsigned char hk_lfr_q_p2_fifo_size_max = 0; |
|
83 | 84 | // sequence counters are incremented by APID (PID + CAT) and destination ID |
|
84 | 85 | unsigned short sequenceCounters_SCIENCE_NORMAL_BURST = 0; |
|
85 | 86 | unsigned short sequenceCounters_SCIENCE_SBM1_SBM2 = 0; |
|
86 | 87 | unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID] = {0}; |
|
87 | 88 | unsigned short sequenceCounters_TM_DUMP[SEQ_CNT_NB_DEST_ID] = {0}; |
|
88 | 89 | unsigned short sequenceCounterHK = {0}; |
|
89 | 90 | spw_stats grspw_stats = {0}; |
|
90 | 91 | |
|
91 | 92 | // TC_LFR_UPDATE_INFO |
|
92 | float cp_rpw_sc_rw1_f1 = INIT_FLOAT; | |
|
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; | |
|
93 | rw_f_t rw_f; | |
|
100 | 94 | |
|
101 | 95 | // TC_LFR_LOAD_FILTER_PAR |
|
102 | 96 | filterPar_t filterPar = {0}; |
|
103 | 97 | |
|
104 | 98 | fbins_masks_t fbins_masks = {0}; |
|
105 | 99 | unsigned int acquisitionDurations[NB_ACQUISITION_DURATION] |
|
106 | 100 | = {ACQUISITION_DURATION_F0, ACQUISITION_DURATION_F1, ACQUISITION_DURATION_F2}; |
@@ -1,945 +1,959 | |||
|
1 | 1 | /** This is the RTEMS initialization module. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * This module contains two very different information: |
|
7 | 7 | * - specific instructions to configure the compilation of the RTEMS executive |
|
8 | 8 | * - functions related to the fligth softwre initialization, especially the INIT RTEMS task |
|
9 | 9 | * |
|
10 | 10 | */ |
|
11 | 11 | |
|
12 | 12 | //************************* |
|
13 | 13 | // GPL reminder to be added |
|
14 | 14 | //************************* |
|
15 | 15 | |
|
16 | 16 | #include <rtems.h> |
|
17 | 17 | |
|
18 | 18 | /* configuration information */ |
|
19 | 19 | |
|
20 | 20 | #define CONFIGURE_INIT |
|
21 | 21 | |
|
22 | 22 | #include <bsp.h> /* for device driver prototypes */ |
|
23 | 23 | |
|
24 | 24 | /* configuration information */ |
|
25 | 25 | |
|
26 | 26 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
27 | 27 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
28 | 28 | |
|
29 | 29 | #define CONFIGURE_MAXIMUM_TASKS 20 |
|
30 | 30 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
|
31 | 31 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) |
|
32 | 32 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 |
|
33 | 33 | #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 |
|
34 | 34 | #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) |
|
35 | 35 | #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT) |
|
36 | 36 | #define CONFIGURE_MAXIMUM_DRIVERS 16 |
|
37 | 37 | #define CONFIGURE_MAXIMUM_PERIODS 5 |
|
38 | 38 | #define CONFIGURE_MAXIMUM_TIMERS 5 // [spiq] [link] [spacewire_reset_link] |
|
39 | 39 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5 |
|
40 | 40 | #ifdef PRINT_STACK_REPORT |
|
41 | 41 | #define CONFIGURE_STACK_CHECKER_ENABLED |
|
42 | 42 | #endif |
|
43 | 43 | |
|
44 | 44 | #include <rtems/confdefs.h> |
|
45 | 45 | |
|
46 | 46 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ |
|
47 | 47 | #ifdef RTEMS_DRVMGR_STARTUP |
|
48 | 48 | #ifdef LEON3 |
|
49 | 49 | /* Add Timer and UART Driver */ |
|
50 | 50 | |
|
51 | 51 | #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
52 | 52 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER |
|
53 | 53 | #endif |
|
54 | 54 | |
|
55 | 55 | #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
56 | 56 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART |
|
57 | 57 | #endif |
|
58 | 58 | |
|
59 | 59 | #endif |
|
60 | 60 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ |
|
61 | 61 | |
|
62 | 62 | #include <drvmgr/drvmgr_confdefs.h> |
|
63 | 63 | #endif |
|
64 | 64 | |
|
65 | 65 | #include "fsw_init.h" |
|
66 | 66 | #include "fsw_config.c" |
|
67 | 67 | #include "GscMemoryLPP.hpp" |
|
68 | 68 | |
|
69 | 69 | void initCache() |
|
70 | 70 | { |
|
71 | 71 | // ASI 2 contains a few control registers that have not been assigned as ancillary state registers. |
|
72 | 72 | // These should only be read and written using 32-bit LDA/STA instructions. |
|
73 | 73 | // All cache registers are accessed through load/store operations to the alternate address space (LDA/STA), using ASI = 2. |
|
74 | 74 | // The table below shows the register addresses: |
|
75 | 75 | // 0x00 Cache control register |
|
76 | 76 | // 0x04 Reserved |
|
77 | 77 | // 0x08 Instruction cache configuration register |
|
78 | 78 | // 0x0C Data cache configuration register |
|
79 | 79 | |
|
80 | 80 | // Cache Control Register Leon3 / Leon3FT |
|
81 | 81 | // 31..30 29 28 27..24 23 22 21 20..19 18 17 16 |
|
82 | 82 | // RFT PS TB DS FD FI FT ST IB |
|
83 | 83 | // 15 14 13..12 11..10 9..8 7..6 5 4 3..2 1..0 |
|
84 | 84 | // IP DP ITE IDE DTE DDE DF IF DCS ICS |
|
85 | 85 | |
|
86 | 86 | unsigned int cacheControlRegister; |
|
87 | 87 | |
|
88 | 88 | CCR_resetCacheControlRegister(); |
|
89 | 89 | ASR16_resetRegisterProtectionControlRegister(); |
|
90 | 90 | |
|
91 | 91 | cacheControlRegister = CCR_getValue(); |
|
92 | 92 | PRINTF1("(0) CCR - Cache Control Register = %x\n", cacheControlRegister); |
|
93 | 93 | PRINTF1("(0) ASR16 = %x\n", *asr16Ptr); |
|
94 | 94 | |
|
95 | 95 | CCR_enableInstructionCache(); // ICS bits |
|
96 | 96 | CCR_enableDataCache(); // DCS bits |
|
97 | 97 | CCR_enableInstructionBurstFetch(); // IB bit |
|
98 | 98 | |
|
99 | 99 | faultTolerantScheme(); |
|
100 | 100 | |
|
101 | 101 | cacheControlRegister = CCR_getValue(); |
|
102 | 102 | PRINTF1("(1) CCR - Cache Control Register = %x\n", cacheControlRegister); |
|
103 | 103 | PRINTF1("(1) ASR16 Register protection control register = %x\n", *asr16Ptr); |
|
104 | 104 | |
|
105 | 105 | PRINTF("\n"); |
|
106 | 106 | } |
|
107 | 107 | |
|
108 | 108 | rtems_task Init( rtems_task_argument ignored ) |
|
109 | 109 | { |
|
110 | 110 | /** This is the RTEMS INIT taks, it is the first task launched by the system. |
|
111 | 111 | * |
|
112 | 112 | * @param unused is the starting argument of the RTEMS task |
|
113 | 113 | * |
|
114 | 114 | * The INIT task create and run all other RTEMS tasks. |
|
115 | 115 | * |
|
116 | 116 | */ |
|
117 | 117 | |
|
118 | 118 | //*********** |
|
119 | 119 | // INIT CACHE |
|
120 | 120 | |
|
121 | 121 | unsigned char *vhdlVersion; |
|
122 | 122 | |
|
123 | 123 | reset_lfr(); |
|
124 | 124 | |
|
125 | 125 | reset_local_time(); |
|
126 | 126 | |
|
127 | 127 | rtems_cpu_usage_reset(); |
|
128 | 128 | |
|
129 | 129 | rtems_status_code status; |
|
130 | 130 | rtems_status_code status_spw; |
|
131 | 131 | rtems_isr_entry old_isr_handler; |
|
132 | 132 | |
|
133 | 133 | old_isr_handler = NULL; |
|
134 | 134 | |
|
135 | 135 | // UART settings |
|
136 | 136 | enable_apbuart_transmitter(); |
|
137 | 137 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); |
|
138 | 138 | |
|
139 | 139 | DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") |
|
140 | 140 | |
|
141 | 141 | |
|
142 | 142 | PRINTF("\n\n\n\n\n") |
|
143 | 143 | |
|
144 | 144 | initCache(); |
|
145 | 145 | |
|
146 | 146 | PRINTF("*************************\n") |
|
147 | 147 | PRINTF("** LFR Flight Software **\n") |
|
148 | 148 | |
|
149 | 149 | PRINTF1("** %d-", SW_VERSION_N1) |
|
150 | 150 | PRINTF1("%d-" , SW_VERSION_N2) |
|
151 | 151 | PRINTF1("%d-" , SW_VERSION_N3) |
|
152 | 152 | PRINTF1("%d **\n", SW_VERSION_N4) |
|
153 | 153 | |
|
154 | 154 | vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION); |
|
155 | 155 | PRINTF("** VHDL **\n") |
|
156 | 156 | PRINTF1("** %d-", vhdlVersion[1]) |
|
157 | 157 | PRINTF1("%d-" , vhdlVersion[2]) |
|
158 | 158 | PRINTF1("%d **\n", vhdlVersion[3]) |
|
159 | 159 | PRINTF("*************************\n") |
|
160 | 160 | PRINTF("\n\n") |
|
161 | 161 | |
|
162 | 162 | init_parameter_dump(); |
|
163 | 163 | init_kcoefficients_dump(); |
|
164 | 164 | init_local_mode_parameters(); |
|
165 | 165 | init_housekeeping_parameters(); |
|
166 | 166 | init_k_coefficients_prc0(); |
|
167 | 167 | init_k_coefficients_prc1(); |
|
168 | 168 | init_k_coefficients_prc2(); |
|
169 | 169 | pa_bia_status_info = INIT_CHAR; |
|
170 | 170 | cp_rpw_sc_rw_f_flags = INIT_CHAR; |
|
171 | cp_rpw_sc_rw1_f1 = INIT_FLOAT; | |
|
172 | cp_rpw_sc_rw1_f2 = INIT_FLOAT; | |
|
173 |
cp_rpw_sc_rw |
|
|
174 |
cp_rpw_sc_rw |
|
|
175 |
cp_rpw_sc_rw |
|
|
176 |
cp_rpw_sc_rw |
|
|
177 |
cp_rpw_sc_rw |
|
|
178 |
cp_rpw_sc_rw |
|
|
171 | ||
|
172 | // initialize all reaction wheels frequencies to NaN | |
|
173 | rw_f.cp_rpw_sc_rw1_f1 = NAN; | |
|
174 | rw_f.cp_rpw_sc_rw1_f2 = NAN; | |
|
175 | rw_f.cp_rpw_sc_rw1_f3 = NAN; | |
|
176 | rw_f.cp_rpw_sc_rw1_f4 = NAN; | |
|
177 | rw_f.cp_rpw_sc_rw2_f1 = NAN; | |
|
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 | 193 | // initialize filtering parameters |
|
180 | 194 | filterPar.spare_sy_lfr_pas_filter_enabled = DEFAULT_SY_LFR_PAS_FILTER_ENABLED; |
|
181 | 195 | filterPar.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS; |
|
182 | 196 | filterPar.sy_lfr_pas_filter_tbad = DEFAULT_SY_LFR_PAS_FILTER_TBAD; |
|
183 | 197 | filterPar.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET; |
|
184 | 198 | filterPar.sy_lfr_pas_filter_shift = DEFAULT_SY_LFR_PAS_FILTER_SHIFT; |
|
185 | 199 | filterPar.sy_lfr_sc_rw_delta_f = DEFAULT_SY_LFR_SC_RW_DELTA_F; |
|
186 | 200 | update_last_valid_transition_date( DEFAULT_LAST_VALID_TRANSITION_DATE ); |
|
187 | 201 | |
|
188 | 202 | // waveform picker initialization |
|
189 | 203 | WFP_init_rings(); |
|
190 | 204 | LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings |
|
191 | 205 | WFP_reset_current_ring_nodes(); |
|
192 | 206 | reset_waveform_picker_regs(); |
|
193 | 207 | |
|
194 | 208 | // spectral matrices initialization |
|
195 | 209 | SM_init_rings(); // initialize spectral matrices rings |
|
196 | 210 | SM_reset_current_ring_nodes(); |
|
197 | 211 | reset_spectral_matrix_regs(); |
|
198 | 212 | |
|
199 | 213 | // configure calibration |
|
200 | 214 | configureCalibration( false ); // true means interleaved mode, false is for normal mode |
|
201 | 215 | |
|
202 | 216 | updateLFRCurrentMode( LFR_MODE_STANDBY ); |
|
203 | 217 | |
|
204 | 218 | BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode) |
|
205 | 219 | |
|
206 | 220 | create_names(); // create all names |
|
207 | 221 | |
|
208 | 222 | status = create_timecode_timer(); // create the timer used by timecode_irq_handler |
|
209 | 223 | if (status != RTEMS_SUCCESSFUL) |
|
210 | 224 | { |
|
211 | 225 | PRINTF1("in INIT *** ERR in create_timer_timecode, code %d", status) |
|
212 | 226 | } |
|
213 | 227 | |
|
214 | 228 | status = create_message_queues(); // create message queues |
|
215 | 229 | if (status != RTEMS_SUCCESSFUL) |
|
216 | 230 | { |
|
217 | 231 | PRINTF1("in INIT *** ERR in create_message_queues, code %d", status) |
|
218 | 232 | } |
|
219 | 233 | |
|
220 | 234 | status = create_all_tasks(); // create all tasks |
|
221 | 235 | if (status != RTEMS_SUCCESSFUL) |
|
222 | 236 | { |
|
223 | 237 | PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status) |
|
224 | 238 | } |
|
225 | 239 | |
|
226 | 240 | // ************************** |
|
227 | 241 | // <SPACEWIRE INITIALIZATION> |
|
228 | 242 | status_spw = spacewire_open_link(); // (1) open the link |
|
229 | 243 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
230 | 244 | { |
|
231 | 245 | PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw ) |
|
232 | 246 | } |
|
233 | 247 | |
|
234 | 248 | if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link |
|
235 | 249 | { |
|
236 | 250 | status_spw = spacewire_configure_link( fdSPW ); |
|
237 | 251 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
238 | 252 | { |
|
239 | 253 | PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw ) |
|
240 | 254 | } |
|
241 | 255 | } |
|
242 | 256 | |
|
243 | 257 | if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link |
|
244 | 258 | { |
|
245 | 259 | status_spw = spacewire_start_link( fdSPW ); |
|
246 | 260 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
247 | 261 | { |
|
248 | 262 | PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw ) |
|
249 | 263 | } |
|
250 | 264 | } |
|
251 | 265 | // </SPACEWIRE INITIALIZATION> |
|
252 | 266 | // *************************** |
|
253 | 267 | |
|
254 | 268 | status = start_all_tasks(); // start all tasks |
|
255 | 269 | if (status != RTEMS_SUCCESSFUL) |
|
256 | 270 | { |
|
257 | 271 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) |
|
258 | 272 | } |
|
259 | 273 | |
|
260 | 274 | // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization |
|
261 | 275 | status = start_recv_send_tasks(); |
|
262 | 276 | if ( status != RTEMS_SUCCESSFUL ) |
|
263 | 277 | { |
|
264 | 278 | PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status ) |
|
265 | 279 | } |
|
266 | 280 | |
|
267 | 281 | // suspend science tasks, they will be restarted later depending on the mode |
|
268 | 282 | status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY) |
|
269 | 283 | if (status != RTEMS_SUCCESSFUL) |
|
270 | 284 | { |
|
271 | 285 | PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
272 | 286 | } |
|
273 | 287 | |
|
274 | 288 | // configure IRQ handling for the waveform picker unit |
|
275 | 289 | status = rtems_interrupt_catch( waveforms_isr, |
|
276 | 290 | IRQ_SPARC_WAVEFORM_PICKER, |
|
277 | 291 | &old_isr_handler) ; |
|
278 | 292 | // configure IRQ handling for the spectral matrices unit |
|
279 | 293 | status = rtems_interrupt_catch( spectral_matrices_isr, |
|
280 | 294 | IRQ_SPARC_SPECTRAL_MATRIX, |
|
281 | 295 | &old_isr_handler) ; |
|
282 | 296 | |
|
283 | 297 | // if the spacewire link is not up then send an event to the SPIQ task for link recovery |
|
284 | 298 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
285 | 299 | { |
|
286 | 300 | status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ); |
|
287 | 301 | if ( status != RTEMS_SUCCESSFUL ) { |
|
288 | 302 | PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status ) |
|
289 | 303 | } |
|
290 | 304 | } |
|
291 | 305 | |
|
292 | 306 | BOOT_PRINTF("delete INIT\n") |
|
293 | 307 | |
|
294 | 308 | set_hk_lfr_sc_potential_flag( true ); |
|
295 | 309 | |
|
296 | 310 | // start the timer to detect a missing spacewire timecode |
|
297 | 311 | // the timeout is larger because the spw IP needs to receive several valid timecodes before generating a tickout |
|
298 | 312 | // if a tickout is generated, the timer is restarted |
|
299 | 313 | status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT_INIT, timecode_timer_routine, NULL ); |
|
300 | 314 | |
|
301 | 315 | grspw_timecode_callback = &timecode_irq_handler; |
|
302 | 316 | |
|
303 | 317 | status = rtems_task_delete(RTEMS_SELF); |
|
304 | 318 | |
|
305 | 319 | } |
|
306 | 320 | |
|
307 | 321 | void init_local_mode_parameters( void ) |
|
308 | 322 | { |
|
309 | 323 | /** This function initialize the param_local global variable with default values. |
|
310 | 324 | * |
|
311 | 325 | */ |
|
312 | 326 | |
|
313 | 327 | unsigned int i; |
|
314 | 328 | |
|
315 | 329 | // LOCAL PARAMETERS |
|
316 | 330 | |
|
317 | 331 | BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) |
|
318 | 332 | BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) |
|
319 | 333 | |
|
320 | 334 | // init sequence counters |
|
321 | 335 | |
|
322 | 336 | for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++) |
|
323 | 337 | { |
|
324 | 338 | sequenceCounters_TC_EXE[i] = INIT_CHAR; |
|
325 | 339 | sequenceCounters_TM_DUMP[i] = INIT_CHAR; |
|
326 | 340 | } |
|
327 | 341 | sequenceCounters_SCIENCE_NORMAL_BURST = INIT_CHAR; |
|
328 | 342 | sequenceCounters_SCIENCE_SBM1_SBM2 = INIT_CHAR; |
|
329 | 343 | sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << TM_PACKET_SEQ_SHIFT; |
|
330 | 344 | } |
|
331 | 345 | |
|
332 | 346 | void reset_local_time( void ) |
|
333 | 347 | { |
|
334 | 348 | time_management_regs->ctrl = time_management_regs->ctrl | VAL_SOFTWARE_RESET; // [0010] software reset, coarse time = 0x80000000 |
|
335 | 349 | } |
|
336 | 350 | |
|
337 | 351 | void create_names( void ) // create all names for tasks and queues |
|
338 | 352 | { |
|
339 | 353 | /** This function creates all RTEMS names used in the software for tasks and queues. |
|
340 | 354 | * |
|
341 | 355 | * @return RTEMS directive status codes: |
|
342 | 356 | * - RTEMS_SUCCESSFUL - successful completion |
|
343 | 357 | * |
|
344 | 358 | */ |
|
345 | 359 | |
|
346 | 360 | // task names |
|
347 | 361 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); |
|
348 | 362 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); |
|
349 | 363 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); |
|
350 | 364 | Task_name[TASKID_LOAD] = rtems_build_name( 'L', 'O', 'A', 'D' ); |
|
351 | 365 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); |
|
352 | 366 | Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' ); |
|
353 | 367 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); |
|
354 | 368 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); |
|
355 | 369 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
356 | 370 | Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' ); |
|
357 | 371 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); |
|
358 | 372 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); |
|
359 | 373 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); |
|
360 | 374 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); |
|
361 | 375 | Task_name[TASKID_LINK] = rtems_build_name( 'L', 'I', 'N', 'K' ); |
|
362 | 376 | Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' ); |
|
363 | 377 | Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' ); |
|
364 | 378 | Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' ); |
|
365 | 379 | Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' ); |
|
366 | 380 | |
|
367 | 381 | // rate monotonic period names |
|
368 | 382 | name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
369 | 383 | |
|
370 | 384 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
371 | 385 | misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
372 | 386 | misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' ); |
|
373 | 387 | misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' ); |
|
374 | 388 | misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' ); |
|
375 | 389 | |
|
376 | 390 | timecode_timer_name = rtems_build_name( 'S', 'P', 'T', 'C' ); |
|
377 | 391 | } |
|
378 | 392 | |
|
379 | 393 | int create_all_tasks( void ) // create all tasks which run in the software |
|
380 | 394 | { |
|
381 | 395 | /** This function creates all RTEMS tasks used in the software. |
|
382 | 396 | * |
|
383 | 397 | * @return RTEMS directive status codes: |
|
384 | 398 | * - RTEMS_SUCCESSFUL - task created successfully |
|
385 | 399 | * - RTEMS_INVALID_ADDRESS - id is NULL |
|
386 | 400 | * - RTEMS_INVALID_NAME - invalid task name |
|
387 | 401 | * - RTEMS_INVALID_PRIORITY - invalid task priority |
|
388 | 402 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured |
|
389 | 403 | * - RTEMS_TOO_MANY - too many tasks created |
|
390 | 404 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context |
|
391 | 405 | * - RTEMS_TOO_MANY - too many global objects |
|
392 | 406 | * |
|
393 | 407 | */ |
|
394 | 408 | |
|
395 | 409 | rtems_status_code status; |
|
396 | 410 | |
|
397 | 411 | //********** |
|
398 | 412 | // SPACEWIRE |
|
399 | 413 | // RECV |
|
400 | 414 | status = rtems_task_create( |
|
401 | 415 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, |
|
402 | 416 | RTEMS_DEFAULT_MODES, |
|
403 | 417 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] |
|
404 | 418 | ); |
|
405 | 419 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
406 | 420 | { |
|
407 | 421 | status = rtems_task_create( |
|
408 | 422 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT, |
|
409 | 423 | RTEMS_DEFAULT_MODES, |
|
410 | 424 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND] |
|
411 | 425 | ); |
|
412 | 426 | } |
|
413 | 427 | if (status == RTEMS_SUCCESSFUL) // LINK |
|
414 | 428 | { |
|
415 | 429 | status = rtems_task_create( |
|
416 | 430 | Task_name[TASKID_LINK], TASK_PRIORITY_LINK, RTEMS_MINIMUM_STACK_SIZE, |
|
417 | 431 | RTEMS_DEFAULT_MODES, |
|
418 | 432 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LINK] |
|
419 | 433 | ); |
|
420 | 434 | } |
|
421 | 435 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
422 | 436 | { |
|
423 | 437 | status = rtems_task_create( |
|
424 | 438 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, |
|
425 | 439 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
426 | 440 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] |
|
427 | 441 | ); |
|
428 | 442 | } |
|
429 | 443 | if (status == RTEMS_SUCCESSFUL) // SPIQ |
|
430 | 444 | { |
|
431 | 445 | status = rtems_task_create( |
|
432 | 446 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, |
|
433 | 447 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
434 | 448 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] |
|
435 | 449 | ); |
|
436 | 450 | } |
|
437 | 451 | |
|
438 | 452 | //****************** |
|
439 | 453 | // SPECTRAL MATRICES |
|
440 | 454 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
441 | 455 | { |
|
442 | 456 | status = rtems_task_create( |
|
443 | 457 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, |
|
444 | 458 | RTEMS_DEFAULT_MODES, |
|
445 | 459 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] |
|
446 | 460 | ); |
|
447 | 461 | } |
|
448 | 462 | if (status == RTEMS_SUCCESSFUL) // PRC0 |
|
449 | 463 | { |
|
450 | 464 | status = rtems_task_create( |
|
451 | 465 | Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT, |
|
452 | 466 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
453 | 467 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0] |
|
454 | 468 | ); |
|
455 | 469 | } |
|
456 | 470 | if (status == RTEMS_SUCCESSFUL) // AVF1 |
|
457 | 471 | { |
|
458 | 472 | status = rtems_task_create( |
|
459 | 473 | Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE, |
|
460 | 474 | RTEMS_DEFAULT_MODES, |
|
461 | 475 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1] |
|
462 | 476 | ); |
|
463 | 477 | } |
|
464 | 478 | if (status == RTEMS_SUCCESSFUL) // PRC1 |
|
465 | 479 | { |
|
466 | 480 | status = rtems_task_create( |
|
467 | 481 | Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT, |
|
468 | 482 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
469 | 483 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1] |
|
470 | 484 | ); |
|
471 | 485 | } |
|
472 | 486 | if (status == RTEMS_SUCCESSFUL) // AVF2 |
|
473 | 487 | { |
|
474 | 488 | status = rtems_task_create( |
|
475 | 489 | Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE, |
|
476 | 490 | RTEMS_DEFAULT_MODES, |
|
477 | 491 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2] |
|
478 | 492 | ); |
|
479 | 493 | } |
|
480 | 494 | if (status == RTEMS_SUCCESSFUL) // PRC2 |
|
481 | 495 | { |
|
482 | 496 | status = rtems_task_create( |
|
483 | 497 | Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT, |
|
484 | 498 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
485 | 499 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2] |
|
486 | 500 | ); |
|
487 | 501 | } |
|
488 | 502 | |
|
489 | 503 | //**************** |
|
490 | 504 | // WAVEFORM PICKER |
|
491 | 505 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
492 | 506 | { |
|
493 | 507 | status = rtems_task_create( |
|
494 | 508 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, |
|
495 | 509 | RTEMS_DEFAULT_MODES, |
|
496 | 510 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] |
|
497 | 511 | ); |
|
498 | 512 | } |
|
499 | 513 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
500 | 514 | { |
|
501 | 515 | status = rtems_task_create( |
|
502 | 516 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, |
|
503 | 517 | RTEMS_DEFAULT_MODES, |
|
504 | 518 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3] |
|
505 | 519 | ); |
|
506 | 520 | } |
|
507 | 521 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
508 | 522 | { |
|
509 | 523 | status = rtems_task_create( |
|
510 | 524 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, |
|
511 | 525 | RTEMS_DEFAULT_MODES, |
|
512 | 526 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2] |
|
513 | 527 | ); |
|
514 | 528 | } |
|
515 | 529 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
516 | 530 | { |
|
517 | 531 | status = rtems_task_create( |
|
518 | 532 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, |
|
519 | 533 | RTEMS_DEFAULT_MODES, |
|
520 | 534 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1] |
|
521 | 535 | ); |
|
522 | 536 | } |
|
523 | 537 | if (status == RTEMS_SUCCESSFUL) // SWBD |
|
524 | 538 | { |
|
525 | 539 | status = rtems_task_create( |
|
526 | 540 | Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE, |
|
527 | 541 | RTEMS_DEFAULT_MODES, |
|
528 | 542 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD] |
|
529 | 543 | ); |
|
530 | 544 | } |
|
531 | 545 | |
|
532 | 546 | //***** |
|
533 | 547 | // MISC |
|
534 | 548 | if (status == RTEMS_SUCCESSFUL) // LOAD |
|
535 | 549 | { |
|
536 | 550 | status = rtems_task_create( |
|
537 | 551 | Task_name[TASKID_LOAD], TASK_PRIORITY_LOAD, RTEMS_MINIMUM_STACK_SIZE, |
|
538 | 552 | RTEMS_DEFAULT_MODES, |
|
539 | 553 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LOAD] |
|
540 | 554 | ); |
|
541 | 555 | } |
|
542 | 556 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
543 | 557 | { |
|
544 | 558 | status = rtems_task_create( |
|
545 | 559 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, |
|
546 | 560 | RTEMS_DEFAULT_MODES, |
|
547 | 561 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] |
|
548 | 562 | ); |
|
549 | 563 | } |
|
550 | 564 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
551 | 565 | { |
|
552 | 566 | status = rtems_task_create( |
|
553 | 567 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, |
|
554 | 568 | RTEMS_DEFAULT_MODES, |
|
555 | 569 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS] |
|
556 | 570 | ); |
|
557 | 571 | } |
|
558 | 572 | |
|
559 | 573 | return status; |
|
560 | 574 | } |
|
561 | 575 | |
|
562 | 576 | int start_recv_send_tasks( void ) |
|
563 | 577 | { |
|
564 | 578 | rtems_status_code status; |
|
565 | 579 | |
|
566 | 580 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); |
|
567 | 581 | if (status!=RTEMS_SUCCESSFUL) { |
|
568 | 582 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") |
|
569 | 583 | } |
|
570 | 584 | |
|
571 | 585 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
572 | 586 | { |
|
573 | 587 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); |
|
574 | 588 | if (status!=RTEMS_SUCCESSFUL) { |
|
575 | 589 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") |
|
576 | 590 | } |
|
577 | 591 | } |
|
578 | 592 | |
|
579 | 593 | return status; |
|
580 | 594 | } |
|
581 | 595 | |
|
582 | 596 | int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS |
|
583 | 597 | { |
|
584 | 598 | /** This function starts all RTEMS tasks used in the software. |
|
585 | 599 | * |
|
586 | 600 |