##// END OF EJS Templates
Merge with nov2013
paul -
r62:749301bb778a merge default
parent child
Show More
@@ -1,93 +1,77
1 1 #ifndef GRLIB_REGS_H_INCLUDED
2 2 #define GRLIB_REGS_H_INCLUDED
3 3
4 4 #define NB_GPTIMER 3
5 5
6 6 struct apbuart_regs_str{
7 7 volatile unsigned int data;
8 8 volatile unsigned int status;
9 9 volatile unsigned int ctrl;
10 10 volatile unsigned int scaler;
11 11 volatile unsigned int fifoDebug;
12 12 };
13 13
14 14 struct ahbuart_regs_str{
15 15 volatile unsigned int unused;
16 16 volatile unsigned int status;
17 17 volatile unsigned int ctrl;
18 18 volatile unsigned int scaler;
19 19 };
20 20
21 21 struct timer_regs_str
22 22 {
23 23 volatile unsigned int counter;
24 24 volatile unsigned int reload;
25 25 volatile unsigned int ctrl;
26 26 volatile unsigned int unused;
27 27 };
28 28 typedef struct timer_regs_str timer_regs_t;
29 29
30 30 struct gptimer_regs_str
31 31 {
32 32 volatile unsigned int scaler_value;
33 33 volatile unsigned int scaler_reload;
34 34 volatile unsigned int conf;
35 35 volatile unsigned int unused0;
36 36 timer_regs_t timer[NB_GPTIMER];
37 37 };
38 38 typedef struct gptimer_regs_str gptimer_regs_t;
39 39
40 40 struct time_management_regs_str{
41 41 volatile int ctrl; // bit 0 forces the load of the coarse_time_load value and resets the fine_time
42 42 volatile int coarse_time_load;
43 43 volatile int coarse_time;
44 44 volatile int fine_time;
45 45 };
46 46 typedef struct time_management_regs_str time_management_regs_t;
47 47
48 struct waveform_picker_regs_str{
49 volatile int data_shaping; // 0x00 00 *** R1 R0 SP1 SP0 BW
50 volatile int burst_enable; // 0x04 01 *** burst f2, f1, f0 enable f3, f2, f1, f0
51 volatile int addr_data_f0; // 0x08 10 ***
52 volatile int addr_data_f1; // 0x0c 11 ***
53 volatile int addr_data_f2; // 0x10 100 ***
54 volatile int addr_data_f3; // 0x14 101 ***
55 volatile int status; // 0x18 110 ***
56 volatile int delta_snapshot; // 0x1c 111 ***
57 volatile int delta_f2_f1; // 0x20 0000 ***
58 volatile int delta_f2_f0; // 0x24 0001 ***
59 volatile int nb_burst_available;// 0x28 0010 ***
60 volatile int nb_snapshot_param; // 0x2c 0011 ***
61 };
62 typedef struct waveform_picker_regs_str waveform_picker_regs_t;
63
64 struct waveform_picker_regs_str_alt{
48 struct new_waveform_picker_regs_str{
65 49 volatile int data_shaping; // 0x00 00 *** R1 R0 SP1 SP0 BW
66 50 volatile int run_burst_enable; // 0x04 01 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
67 51 volatile int addr_data_f0; // 0x08
68 52 volatile int addr_data_f1; // 0x0c
69 53 volatile int addr_data_f2; // 0x10
70 54 volatile int addr_data_f3; // 0x14
71 55 volatile int status; // 0x18
72 56 volatile int delta_snapshot; // 0x1c
73 57 volatile int delta_f0; // 0x20
74 58 volatile int delta_f0_2;
75 59 volatile int delta_f1;
76 60 volatile int delta_f2;
77 61 volatile int nb_data_by_buffer;
78 62 volatile int snapshot_param;
79 63 volatile int start_date;
80 64 };
81 typedef struct waveform_picker_regs_str_alt waveform_picker_regs_t_alt;
65 typedef struct new_waveform_picker_regs_str new_waveform_picker_regs_t;
82 66
83 67 struct spectral_matrix_regs_str{
84 68 volatile int config;
85 69 volatile int status;
86 70 volatile int matrixF0_Address0;
87 71 volatile int matrixFO_Address1;
88 72 volatile int matrixF1_Address;
89 73 volatile int matrixF2_Address;
90 74 };
91 75 typedef struct spectral_matrix_regs_str spectral_matrix_regs_t;
92 76
93 77 #endif // GRLIB_REGS_H_INCLUDED
@@ -1,63 +1,63
1 1 #ifndef TC_HANDLER_H_INCLUDED
2 2 #define TC_HANDLER_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <leon.h>
6 6
7 7 #include "tc_load_dump_parameters.h"
8 8 #include "tc_acceptance.h"
9 9 #include "tm_lfr_tc_exe.h"
10 10 #include "wf_handler.h"
11 11
12 12 // MODE PARAMETERS
13 13 extern struct param_sbm1_str param_sbm1;
14 14 extern struct param_sbm2_str param_sbm2;
15 15 extern time_management_regs_t *time_management_regs;
16 extern waveform_picker_regs_t *waveform_picker_regs;
16 extern new_waveform_picker_regs_t *new_waveform_picker_regs;
17 17 extern gptimer_regs_t *gptimer_regs;
18 18 extern rtems_name misc_name[5];
19 19 extern rtems_id Task_id[20]; /* array of task ids */
20 20 extern unsigned char lfrCurrentMode;
21 21 extern unsigned int maxCount;
22 22
23 23
24 24 //****
25 25 // ISR
26 26 rtems_isr commutation_isr1( rtems_vector_number vector );
27 27 rtems_isr commutation_isr2( rtems_vector_number vector );
28 28
29 29 //***********
30 30 // RTEMS TASK
31 31 rtems_task actn_task( rtems_task_argument unused );
32 32
33 33 //***********
34 34 // TC ACTIONS
35 35 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
36 36 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
37 37 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
38 38 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
39 39 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
40 40 int action_update_time(ccsdsTelecommandPacket_t *TC);
41 41
42 42 // mode transition
43 43 int transition_validation(unsigned char requestedMode);
44 44 int stop_current_mode();
45 45 int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC);
46 46 int enter_standby_mode();
47 47 int enter_normal_mode();
48 48 int enter_burst_mode();
49 49 int enter_sbm1_mode();
50 50 int enter_sbm2_mode();
51 51 int restart_science_tasks();
52 52 int suspend_science_tasks();
53 53
54 54 // other functions
55 55 void updateLFRCurrentMode();
56 56 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC);
57 57 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC);
58 58 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id);
59 59
60 60 #endif // TC_HANDLER_H_INCLUDED
61 61
62 62
63 63
@@ -1,88 +1,81
1 1 #ifndef WF_HANDLER_H_INCLUDED
2 2 #define WF_HANDLER_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <grspw.h>
6 6 #include <stdio.h>
7 7 #include <math.h>
8 8
9 9 #include "fsw_params.h"
10 #include "fsw_spacewire.h"
11 #include "fsw_misc.h"
12 10
13 11 #define pi 3.1415
14 12
15 13 extern int fdSPW;
16 14 extern volatile int wf_snap_f0[ ];
17 15 //
18 16 extern volatile int wf_snap_f1[ ];
19 17 extern volatile int wf_snap_f1_bis[ ];
20 18 extern volatile int wf_snap_f1_norm[ ];
21 19 //
22 20 extern volatile int wf_snap_f2[ ];
23 21 extern volatile int wf_snap_f2_bis[ ];
24 22 extern volatile int wf_snap_f2_norm[ ];
25 23 //
26 24 extern volatile int wf_cont_f3[ ];
27 25 extern volatile int wf_cont_f3_bis[ ];
28 26 extern char wf_cont_f3_light[ ];
29 extern waveform_picker_regs_t *waveform_picker_regs;
30 extern waveform_picker_regs_t_alt *waveform_picker_regs_alt;
27 extern new_waveform_picker_regs_t *new_waveform_picker_regs;
31 28 extern time_management_regs_t *time_management_regs;
32 29 extern Packet_TM_LFR_HK_t housekeeping_packet;
33 30 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
34 31 extern struct param_local_str param_local;
35 32
36 extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
37 extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
38
39 33 extern rtems_name misc_name[5];
40 34 extern rtems_name Task_name[20]; /* array of task ids */
41 35 extern rtems_id Task_id[20]; /* array of task ids */
42 36
43 37 extern unsigned char lfrCurrentMode;
44 38
45 39 rtems_isr waveforms_isr( rtems_vector_number vector );
46 40 rtems_isr waveforms_simulator_isr( rtems_vector_number vector );
47 41 rtems_task wfrm_task( rtems_task_argument argument );
48 42 rtems_task cwf3_task( rtems_task_argument argument );
49 43 rtems_task cwf2_task( rtems_task_argument argument );
50 44 rtems_task cwf1_task( rtems_task_argument argument );
51 45
52 46 //******************
53 47 // general functions
54 48 void init_waveforms( void );
55 49 //
56 50 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF );
57 51 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
58 52 int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
59 53 //
60 54 void reset_waveforms( void );
61 55 //
62 56 int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id );
63 57 int send_waveform_CWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
64 58 int send_waveform_CWF3( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
65 59 int send_waveform_CWF3_light( volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
66 60 //
67 61 rtems_id get_pkts_queue_id( void );
68 62
69 63 //**************
70 64 // wfp registers
71 65 void set_wfp_data_shaping();
72 66 char set_wfp_delta_snapshot();
73 67 void set_wfp_burst_enable_register( unsigned char mode);
74 void reset_wfp_burst_enable();
68 void reset_wfp_run_burst_enable();
75 69 void reset_wfp_status();
76 void reset_waveform_picker_regs();
70 void reset_new_waveform_picker_regs();
71 void reset_new_waveform_picker_regs_alt();
77 72
78 73 //*****************
79 74 // local parameters
80 75 void set_local_sbm1_nb_cwf_max();
81 76 void set_local_sbm2_nb_cwf_max();
82 77 void set_local_nb_interrupt_f0_MAX();
83 78 void reset_local_sbm1_nb_cwf_sent();
84 79 void reset_local_sbm2_nb_cwf_sent();
85 80
86 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid );
87
88 81 #endif // WF_HANDLER_H_INCLUDED
@@ -1,55 +1,54
1 1 #include <drvmgr/ambapp_bus.h>
2 2
3 3 // GRSPW0 resources
4 4 struct drvmgr_key grlib_grspw_0n1_res[] = {
5 5 {"txBdCnt", KEY_TYPE_INT, {(unsigned int)50}}, // 7 SWF_F0, 7 SWF_F1, 7 SWF_F2, 7 CWF_F3, 7 CWF_F1 ou 7 CWF_F2
6 6 {"rxBdCnt", KEY_TYPE_INT, {(unsigned int)10}},
7 7 {"txDataSize", KEY_TYPE_INT, {(unsigned int)4096}},
8 8 {"txHdrSize", KEY_TYPE_INT, {(unsigned int)20+12}}, // 12 is for the auxiliary header, when needed
9 9 {"rxPktSize", KEY_TYPE_INT, {(unsigned int)248+4}},
10 10 KEY_EMPTY
11 11 };
12 12
13 13 #if 0
14 14 /* APBUART0 */
15 15 struct drvmgr_key grlib_drv_res_apbuart0[] =
16 16 {
17 17 {"mode", KEY_TYPE_INT, {(unsigned int)1}},
18 18 {"syscon", KEY_TYPE_INT, {(unsigned int)1}},
19 19 KEY_EMPTY
20 20 };
21 21 /* APBUART1 */
22 22 struct drvmgr_key grlib_drv_res_apbuart1[] =
23 23 {
24 24 {"mode", KEY_TYPE_INT, {(unsigned int)1}},
25 25 {"syscon", KEY_TYPE_INT, {(unsigned int)0}},
26 26 KEY_EMPTY
27 27 };
28 28 /* LEON3 System with driver configuration for 2 APBUARTs, the
29 29 * the rest of the AMBA device drivers use their defaults.
30 30 */
31 31
32 32 /* Override default debug UART assignment.
33 33 * 0 = Default APBUART. APBUART[0], but on MP system CPU0=APBUART0,
34 34 * CPU1=APBUART1...
35 35 * 1 = APBUART[0]
36 36 * 2 = APBUART[1]
37 37 * 3 = APBUART[2]
38 38 * ...
39 39 */
40 40 //int debug_uart_index = 2; /* second UART -- APBUART[1] */
41 41 #endif
42 42
43 43 // If RTEMS_DRVMGR_STARTUP is defined we override the "weak defaults" that is defined by the LEON3 BSP.
44 44
45 45 struct drvmgr_bus_res grlib_drv_resources = {
46 46 .next = NULL,
47 47 .resource = {
48 48 {DRIVER_AMBAPP_GAISLER_GRSPW_ID, 0, &grlib_grspw_0n1_res[0]},
49 49 // {DRIVER_AMBAPP_GAISLER_APBUART_ID, 0, &grlib_drv_res_apbuart0[0]},
50 50 // {DRIVER_AMBAPP_GAISLER_APBUART_ID, 1, &grlib_drv_res_apbuart1[0]},
51 51 RES_EMPTY /* Mark end of device resource array */
52 52 }
53 53 };
54 54
55
@@ -1,92 +1,89
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
24 24 // RTEMS GLOBAL VARIABLES
25 25 rtems_name misc_name[5];
26 26 rtems_id misc_id[5];
27 27 rtems_name Task_name[20]; /* array of task names */
28 28 rtems_id Task_id[20]; /* array of task ids */
29 29 unsigned int maxCount;
30 30 int fdSPW = 0;
31 31 int fdUART = 0;
32 32 unsigned char lfrCurrentMode;
33 33
34 34 // APB CONFIGURATION REGISTERS
35 35 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
36 36 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
37 37 #ifdef GSA
38 38 #else
39 waveform_picker_regs_t *waveform_picker_regs = (waveform_picker_regs_t*) REGS_ADDR_WAVEFORM_PICKER;
40 waveform_picker_regs_t_alt *waveform_picker_regs_alt = (waveform_picker_regs_t_alt*) REGS_ADDR_WAVEFORM_PICKER;
39 new_waveform_picker_regs_t *new_waveform_picker_regs = (new_waveform_picker_regs_t*) REGS_ADDR_WAVEFORM_PICKER;
41 40 #endif
42 41 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
43 42
44 43 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes
45 44 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
46 45 //
47 46 volatile int wf_snap_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
48 47 volatile int wf_snap_f1_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
49 48 volatile int wf_snap_f1_norm[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
50 49 //
51 50 volatile int wf_snap_f2[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
52 51 volatile int wf_snap_f2_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
53 52 volatile int wf_snap_f2_norm[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
54 53 //
55 54 volatile int wf_cont_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
56 55 volatile int wf_cont_f3_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
57 56 char wf_cont_f3_light[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_CWF3_LIGHT_BLK ];
58 57
59 58 // SPECTRAL MATRICES GLOBAL VARIABLES
60 59 volatile int spec_mat_f0_0[ SM_HEADER + TOTAL_SIZE_SM ];
61 60 volatile int spec_mat_f0_1[ SM_HEADER + TOTAL_SIZE_SM ];
62 61 volatile int spec_mat_f0_a[ SM_HEADER + TOTAL_SIZE_SM ];
63 62 volatile int spec_mat_f0_b[ SM_HEADER + TOTAL_SIZE_SM ];
64 63 volatile int spec_mat_f0_c[ SM_HEADER + TOTAL_SIZE_SM ];
65 64 volatile int spec_mat_f0_d[ SM_HEADER + TOTAL_SIZE_SM ];
66 65 volatile int spec_mat_f0_e[ SM_HEADER + TOTAL_SIZE_SM ];
67 66 volatile int spec_mat_f0_f[ SM_HEADER + TOTAL_SIZE_SM ];
68 67 volatile int spec_mat_f0_g[ SM_HEADER + TOTAL_SIZE_SM ];
69 68 volatile int spec_mat_f0_h[ SM_HEADER + TOTAL_SIZE_SM ];
70 69 volatile int spec_mat_f0_0_bis[ SM_HEADER + TOTAL_SIZE_SM ];
71 70 volatile int spec_mat_f0_1_bis[ SM_HEADER + TOTAL_SIZE_SM ];
72 71 //
73 72 volatile int spec_mat_f1[ SM_HEADER + TOTAL_SIZE_SM ];
74 73 volatile int spec_mat_f1_bis[ SM_HEADER + TOTAL_SIZE_SM ];
75 74 //
76 75 volatile int spec_mat_f2[ SM_HEADER + TOTAL_SIZE_SM ];
77 76 volatile int spec_mat_f2_bis[ SM_HEADER + TOTAL_SIZE_SM ];
78 77
79 78 // MODE PARAMETERS
80 79 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
81 80 struct param_local_str param_local;
82 81
83 82 // HK PACKETS
84 83 Packet_TM_LFR_HK_t housekeeping_packet;
85 84 // sequence counters are incremented by APID (PID + CAT) and destination ID
86 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
87 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
88 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
85 unsigned short sequenceCounters[SEQ_CNT_NB_PID][SEQ_CNT_NB_CAT][SEQ_CNT_NB_DEST_ID];
89 86 spw_stats spacewire_stats;
90 87 spw_stats spacewire_stats_backup;
91 88
92 89
@@ -1,586 +1,593
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_MAXIMUM_DRIVERS 16
36 36 #define CONFIGURE_MAXIMUM_PERIODS 5
37 37 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
38 38 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2
39 39 #ifdef PRINT_STACK_REPORT
40 40 #define CONFIGURE_STACK_CHECKER_ENABLED
41 41 #endif
42 42
43 43 #include <rtems/confdefs.h>
44 44
45 45 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
46 46 #ifdef RTEMS_DRVMGR_STARTUP
47 47 #ifdef LEON3
48 48 /* Add Timer and UART Driver */
49 49 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
50 50 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
51 51 #endif
52 52 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
53 53 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
54 54 #endif
55 55 #endif
56 56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
57 57 #include <drvmgr/drvmgr_confdefs.h>
58 58 #endif
59 59
60 60 #include "fsw_init.h"
61 61 #include "fsw_config.c"
62 62
63 63 rtems_task Init( rtems_task_argument ignored )
64 64 {
65 65 /** This is the RTEMS INIT taks, it the first task launched by the system.
66 66 *
67 67 * @param unused is the starting argument of the RTEMS task
68 68 *
69 69 * The INIT task create and run all other RTEMS tasks.
70 70 *
71 71 */
72 72
73
74 73 rtems_status_code status;
75 74 rtems_status_code status_spw;
76 75 rtems_isr_entry old_isr_handler;
77 76
78 77 BOOT_PRINTF("\n\n\n\n\n")
79 78 BOOT_PRINTF("***************************\n")
80 79 BOOT_PRINTF("** START Flight Software **\n")
81 80 BOOT_PRINTF("***************************\n")
82 81 BOOT_PRINTF("\n\n")
83 82
84 83 //send_console_outputs_on_apbuart_port();
85 84 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
86 85
87 reset_wfp_burst_enable(); // stop the waveform picker if it was running
86 // waveform picker registers initialization
87 reset_wfp_run_burst_enable();
88 reset_wfp_status();
88 89
89 90 init_parameter_dump();
90 91 init_local_mode_parameters();
91 92 init_housekeeping_parameters();
92 93
93 94 updateLFRCurrentMode();
94 95
95 96 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
96 97
97 98 create_names(); // create all names
98 99
99 100 status = create_message_queues(); // create message queues
100 101 if (status != RTEMS_SUCCESSFUL)
101 102 {
102 103 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
103 104 }
104 105
105 106 status = create_all_tasks(); // create all tasks
106 107 if (status != RTEMS_SUCCESSFUL)
107 108 {
108 109 PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status)
109 110 }
110 111
111 112 // **************************
112 113 // <SPACEWIRE INITIALIZATION>
113 114 grspw_timecode_callback = &timecode_irq_handler;
114 115
115 116 status_spw = spacewire_open_link(); // (1) open the link
116 117 if ( status_spw != RTEMS_SUCCESSFUL )
117 118 {
118 119 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
119 120 }
120 121
121 122 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
122 123 {
123 124 status_spw = spacewire_configure_link( fdSPW );
124 125 if ( status_spw != RTEMS_SUCCESSFUL )
125 126 {
126 127 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
127 128 }
128 129 }
129 130
130 131 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
131 132 {
132 133 status_spw = spacewire_start_link( fdSPW );
133 134 if ( status_spw != RTEMS_SUCCESSFUL )
134 135 {
135 136 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
136 137 }
137 138 }
138 139 // </SPACEWIRE INITIALIZATION>
139 140 // ***************************
140 141
141 142 status = start_all_tasks(); // start all tasks
142 143 if (status != RTEMS_SUCCESSFUL)
143 144 {
144 145 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
145 146 }
146 147
147 148 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
148 149 status = start_recv_send_tasks();
149 150 if ( status != RTEMS_SUCCESSFUL )
150 151 {
151 152 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
152 153 }
153 154
154 155 // suspend science tasks. they will be restarted later depending on the mode
155 156 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
156 157 if (status != RTEMS_SUCCESSFUL)
157 158 {
158 159 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
159 160 }
160 161
161 162 #ifdef GSA
162 163 // mask IRQ lines
163 164 LEON_Mask_interrupt( IRQ_SM );
164 165 LEON_Mask_interrupt( IRQ_WF );
165 166 // Spectral Matrices simulator
166 167 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
167 168 IRQ_SPARC_SM, spectral_matrices_isr );
168 169 // WaveForms
169 170 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
170 171 IRQ_SPARC_WF, waveforms_simulator_isr );
171 172 #else
172 173 // configure IRQ handling for the waveform picker unit
173 174 status = rtems_interrupt_catch( waveforms_isr,
174 175 IRQ_SPARC_WAVEFORM_PICKER,
175 176 &old_isr_handler) ;
176 177 #endif
177 178
178 179 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
179 180 if ( status_spw != RTEMS_SUCCESSFUL )
180 181 {
181 182 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
182 183 if ( status != RTEMS_SUCCESSFUL ) {
183 184 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
184 185 }
185 186 }
186 187
187 188 BOOT_PRINTF("delete INIT\n")
188 189
189 190 status = rtems_task_delete(RTEMS_SELF);
190 191
191 192 }
192 193
193 194 void init_local_mode_parameters( void )
194 195 {
195 196 /** This function initialize the param_local global variable with default values.
196 197 *
197 198 */
198 199
199 200 unsigned int i;
201 unsigned int j;
202 unsigned int k;
200 203
201 204 // LOCAL PARAMETERS
202 205 set_local_sbm1_nb_cwf_max();
203 206 set_local_sbm2_nb_cwf_max();
204 207 set_local_nb_interrupt_f0_MAX();
205 208
206 209 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
207 210 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
208 211 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
209 212
210 213 reset_local_sbm1_nb_cwf_sent();
211 214 reset_local_sbm2_nb_cwf_sent();
212 215
213 216 // init sequence counters
214
215 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
217 for (i = 0; i<SEQ_CNT_NB_PID; i++)
216 218 {
217 sequenceCounters_TC_EXE[i] = 0x00;
219 for(j = 0; j<SEQ_CNT_NB_CAT; j++)
220 {
221 for(k = 0; k<SEQ_CNT_NB_DEST_ID; k++)
222 {
223 sequenceCounters[i][j][k] = 0x00;
224 }
225 }
218 226 }
219 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
220 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
221 227 }
222 228
223 229 void create_names( void ) // create all names for tasks and queues
224 230 {
225 231 /** This function creates all RTEMS names used in the software for tasks and queues.
226 232 *
227 233 * @return RTEMS directive status codes:
228 234 * - RTEMS_SUCCESSFUL - successful completion
229 235 *
230 236 */
231 237
232 238 // task names
233 239 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
234 240 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
235 241 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
236 242 Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' );
237 243 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
238 244 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
239 245 Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' );
240 246 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
241 247 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
242 248 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
243 249 Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' );
244 250 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
245 251 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
246 252 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
247 253 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
248 254 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
249 255
250 256 // rate monotonic period names
251 257 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
252 258
253 259 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
254 260 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
255 261 }
256 262
257 263 int create_all_tasks( void ) // create all tasks which run in the software
258 264 {
259 265 /** This function creates all RTEMS tasks used in the software.
260 266 *
261 267 * @return RTEMS directive status codes:
262 268 * - RTEMS_SUCCESSFUL - task created successfully
263 269 * - RTEMS_INVALID_ADDRESS - id is NULL
264 270 * - RTEMS_INVALID_NAME - invalid task name
265 271 * - RTEMS_INVALID_PRIORITY - invalid task priority
266 272 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
267 273 * - RTEMS_TOO_MANY - too many tasks created
268 274 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
269 275 * - RTEMS_TOO_MANY - too many global objects
270 276 *
271 277 */
272 278
273 279 rtems_status_code status;
274 280
275 281 // RECV
276 282 status = rtems_task_create(
277 283 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
278 284 RTEMS_DEFAULT_MODES,
279 285 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
280 286 );
281 287
282 288 if (status == RTEMS_SUCCESSFUL) // ACTN
283 289 {
284 290 status = rtems_task_create(
285 291 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
286 292 RTEMS_DEFAULT_MODES,
287 293 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
288 294 );
289 295 }
290 296 if (status == RTEMS_SUCCESSFUL) // SPIQ
291 297 {
292 298 status = rtems_task_create(
293 299 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
294 300 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
295 301 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
296 302 );
297 303 }
298 304 if (status == RTEMS_SUCCESSFUL) // SMIQ
299 305 {
300 306 status = rtems_task_create(
301 307 Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE,
302 308 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
303 309 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
304 310 );
305 311 }
306 312 if (status == RTEMS_SUCCESSFUL) // STAT
307 313 {
308 314 status = rtems_task_create(
309 315 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
310 316 RTEMS_DEFAULT_MODES,
311 317 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
312 318 );
313 319 }
314 320 if (status == RTEMS_SUCCESSFUL) // AVF0
315 321 {
316 322 status = rtems_task_create(
317 323 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
318 324 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
319 325 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
320 326 );
321 327 }
322 328 if (status == RTEMS_SUCCESSFUL) // BPF0
323 329 {
324 330 status = rtems_task_create(
325 331 Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE,
326 332 RTEMS_DEFAULT_MODES,
327 333 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0]
328 334 );
329 335 }
330 336 if (status == RTEMS_SUCCESSFUL) // WFRM
331 337 {
332 338 status = rtems_task_create(
333 339 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
334 340 RTEMS_DEFAULT_MODES,
335 341 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
336 342 );
337 343 }
338 344 if (status == RTEMS_SUCCESSFUL) // DUMB
339 345 {
340 346 status = rtems_task_create(
341 347 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
342 348 RTEMS_DEFAULT_MODES,
343 349 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
344 350 );
345 351 }
346 352 if (status == RTEMS_SUCCESSFUL) // HOUS
347 353 {
348 354 status = rtems_task_create(
349 355 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
350 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
356 RTEMS_DEFAULT_MODES,
351 357 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
352 358 );
353 359 }
354 360 if (status == RTEMS_SUCCESSFUL) // MATR
355 361 {
356 362 status = rtems_task_create(
357 363 Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE,
358 364 RTEMS_DEFAULT_MODES,
359 365 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR]
360 366 );
361 367 }
362 368 if (status == RTEMS_SUCCESSFUL) // CWF3
363 369 {
364 370 status = rtems_task_create(
365 371 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
366 372 RTEMS_DEFAULT_MODES,
367 373 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF3]
368 374 );
369 375 }
370 376 if (status == RTEMS_SUCCESSFUL) // CWF2
371 377 {
372 378 status = rtems_task_create(
373 379 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
374 380 RTEMS_DEFAULT_MODES,
375 381 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF2]
376 382 );
377 383 }
378 384 if (status == RTEMS_SUCCESSFUL) // CWF1
379 385 {
380 386 status = rtems_task_create(
381 387 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
382 388 RTEMS_DEFAULT_MODES,
383 389 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF1]
384 390 );
385 391 }
386 392 if (status == RTEMS_SUCCESSFUL) // SEND
387 393 {
388 394 status = rtems_task_create(
389 395 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
390 396 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
391 397 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
392 398 );
393 399 }
394 400 if (status == RTEMS_SUCCESSFUL) // WTDG
395 401 {
396 402 status = rtems_task_create(
397 403 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
398 404 RTEMS_DEFAULT_MODES,
399 405 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
400 406 );
401 407 }
402 408
403 409 return status;
404 410 }
405 411
406 412 int start_recv_send_tasks( void )
407 413 {
408 414 rtems_status_code status;
409 415
410 416 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
411 417 if (status!=RTEMS_SUCCESSFUL) {
412 418 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
413 419 }
414 420
415 421 if (status == RTEMS_SUCCESSFUL) // SEND
416 422 {
417 423 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
418 424 if (status!=RTEMS_SUCCESSFUL) {
419 425 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
420 426 }
421 427 }
422 428
423 429 return status;
424 430 }
425 431
426 432 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
427 433 {
428 434 /** This function starts all RTEMS tasks used in the software.
429 435 *
430 436 * @return RTEMS directive status codes:
431 437 * - RTEMS_SUCCESSFUL - ask started successfully
432 438 * - RTEMS_INVALID_ADDRESS - invalid task entry point
433 439 * - RTEMS_INVALID_ID - invalid task id
434 440 * - RTEMS_INCORRECT_STATE - task not in the dormant state
435 441 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
436 442 *
437 443 */
438 444 // starts all the tasks fot eh flight software
439 445
440 446 rtems_status_code status;
441 447
442 448 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
443 449 if (status!=RTEMS_SUCCESSFUL) {
444 450 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
445 451 }
446 452
447 453 if (status == RTEMS_SUCCESSFUL) // WTDG
448 454 {
449 455 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
450 456 if (status!=RTEMS_SUCCESSFUL) {
451 457 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
452 458 }
453 459 }
454 460
455 461 if (status == RTEMS_SUCCESSFUL) // SMIQ
456 462 {
457 463 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
458 464 if (status!=RTEMS_SUCCESSFUL) {
459 465 BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n")
460 466 }
461 467 }
462 468
463 469 if (status == RTEMS_SUCCESSFUL) // ACTN
464 470 {
465 471 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
466 472 if (status!=RTEMS_SUCCESSFUL) {
467 473 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
468 474 }
469 475 }
470 476
471 477 if (status == RTEMS_SUCCESSFUL) // STAT
472 478 {
473 479 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
474 480 if (status!=RTEMS_SUCCESSFUL) {
475 481 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
476 482 }
477 483 }
478 484
479 485 if (status == RTEMS_SUCCESSFUL) // AVF0
480 486 {
481 487 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
482 488 if (status!=RTEMS_SUCCESSFUL) {
483 489 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
484 490 }
485 491 }
486 492
487 493 if (status == RTEMS_SUCCESSFUL) // BPF0
488 494 {
489 495 status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 );
490 496 if (status!=RTEMS_SUCCESSFUL) {
491 497 BOOT_PRINTF("in INIT *** Error starting TASK_BPF0\n")
492 498 }
493 499 }