##// END OF EJS Templates
Merge with nov2013
paul -
r62:749301bb778a merge default
parent child
Show More
@@ -1,93 +1,77
1 #ifndef GRLIB_REGS_H_INCLUDED
1 #ifndef GRLIB_REGS_H_INCLUDED
2 #define GRLIB_REGS_H_INCLUDED
2 #define GRLIB_REGS_H_INCLUDED
3
3
4 #define NB_GPTIMER 3
4 #define NB_GPTIMER 3
5
5
6 struct apbuart_regs_str{
6 struct apbuart_regs_str{
7 volatile unsigned int data;
7 volatile unsigned int data;
8 volatile unsigned int status;
8 volatile unsigned int status;
9 volatile unsigned int ctrl;
9 volatile unsigned int ctrl;
10 volatile unsigned int scaler;
10 volatile unsigned int scaler;
11 volatile unsigned int fifoDebug;
11 volatile unsigned int fifoDebug;
12 };
12 };
13
13
14 struct ahbuart_regs_str{
14 struct ahbuart_regs_str{
15 volatile unsigned int unused;
15 volatile unsigned int unused;
16 volatile unsigned int status;
16 volatile unsigned int status;
17 volatile unsigned int ctrl;
17 volatile unsigned int ctrl;
18 volatile unsigned int scaler;
18 volatile unsigned int scaler;
19 };
19 };
20
20
21 struct timer_regs_str
21 struct timer_regs_str
22 {
22 {
23 volatile unsigned int counter;
23 volatile unsigned int counter;
24 volatile unsigned int reload;
24 volatile unsigned int reload;
25 volatile unsigned int ctrl;
25 volatile unsigned int ctrl;
26 volatile unsigned int unused;
26 volatile unsigned int unused;
27 };
27 };
28 typedef struct timer_regs_str timer_regs_t;
28 typedef struct timer_regs_str timer_regs_t;
29
29
30 struct gptimer_regs_str
30 struct gptimer_regs_str
31 {
31 {
32 volatile unsigned int scaler_value;
32 volatile unsigned int scaler_value;
33 volatile unsigned int scaler_reload;
33 volatile unsigned int scaler_reload;
34 volatile unsigned int conf;
34 volatile unsigned int conf;
35 volatile unsigned int unused0;
35 volatile unsigned int unused0;
36 timer_regs_t timer[NB_GPTIMER];
36 timer_regs_t timer[NB_GPTIMER];
37 };
37 };
38 typedef struct gptimer_regs_str gptimer_regs_t;
38 typedef struct gptimer_regs_str gptimer_regs_t;
39
39
40 struct time_management_regs_str{
40 struct time_management_regs_str{
41 volatile int ctrl; // bit 0 forces the load of the coarse_time_load value and resets the fine_time
41 volatile int ctrl; // bit 0 forces the load of the coarse_time_load value and resets the fine_time
42 volatile int coarse_time_load;
42 volatile int coarse_time_load;
43 volatile int coarse_time;
43 volatile int coarse_time;
44 volatile int fine_time;
44 volatile int fine_time;
45 };
45 };
46 typedef struct time_management_regs_str time_management_regs_t;
46 typedef struct time_management_regs_str time_management_regs_t;
47
47
48 struct waveform_picker_regs_str{
48 struct new_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{
65 volatile int data_shaping; // 0x00 00 *** R1 R0 SP1 SP0 BW
49 volatile int data_shaping; // 0x00 00 *** R1 R0 SP1 SP0 BW
66 volatile int run_burst_enable; // 0x04 01 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
50 volatile int run_burst_enable; // 0x04 01 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
67 volatile int addr_data_f0; // 0x08
51 volatile int addr_data_f0; // 0x08
68 volatile int addr_data_f1; // 0x0c
52 volatile int addr_data_f1; // 0x0c
69 volatile int addr_data_f2; // 0x10
53 volatile int addr_data_f2; // 0x10
70 volatile int addr_data_f3; // 0x14
54 volatile int addr_data_f3; // 0x14
71 volatile int status; // 0x18
55 volatile int status; // 0x18
72 volatile int delta_snapshot; // 0x1c
56 volatile int delta_snapshot; // 0x1c
73 volatile int delta_f0; // 0x20
57 volatile int delta_f0; // 0x20
74 volatile int delta_f0_2;
58 volatile int delta_f0_2;
75 volatile int delta_f1;
59 volatile int delta_f1;
76 volatile int delta_f2;
60 volatile int delta_f2;
77 volatile int nb_data_by_buffer;
61 volatile int nb_data_by_buffer;
78 volatile int snapshot_param;
62 volatile int snapshot_param;
79 volatile int start_date;
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 struct spectral_matrix_regs_str{
67 struct spectral_matrix_regs_str{
84 volatile int config;
68 volatile int config;
85 volatile int status;
69 volatile int status;
86 volatile int matrixF0_Address0;
70 volatile int matrixF0_Address0;
87 volatile int matrixFO_Address1;
71 volatile int matrixFO_Address1;
88 volatile int matrixF1_Address;
72 volatile int matrixF1_Address;
89 volatile int matrixF2_Address;
73 volatile int matrixF2_Address;
90 };
74 };
91 typedef struct spectral_matrix_regs_str spectral_matrix_regs_t;
75 typedef struct spectral_matrix_regs_str spectral_matrix_regs_t;
92
76
93 #endif // GRLIB_REGS_H_INCLUDED
77 #endif // GRLIB_REGS_H_INCLUDED
@@ -1,63 +1,63
1 #ifndef TC_HANDLER_H_INCLUDED
1 #ifndef TC_HANDLER_H_INCLUDED
2 #define TC_HANDLER_H_INCLUDED
2 #define TC_HANDLER_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <leon.h>
5 #include <leon.h>
6
6
7 #include "tc_load_dump_parameters.h"
7 #include "tc_load_dump_parameters.h"
8 #include "tc_acceptance.h"
8 #include "tc_acceptance.h"
9 #include "tm_lfr_tc_exe.h"
9 #include "tm_lfr_tc_exe.h"
10 #include "wf_handler.h"
10 #include "wf_handler.h"
11
11
12 // MODE PARAMETERS
12 // MODE PARAMETERS
13 extern struct param_sbm1_str param_sbm1;
13 extern struct param_sbm1_str param_sbm1;
14 extern struct param_sbm2_str param_sbm2;
14 extern struct param_sbm2_str param_sbm2;
15 extern time_management_regs_t *time_management_regs;
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 extern gptimer_regs_t *gptimer_regs;
17 extern gptimer_regs_t *gptimer_regs;
18 extern rtems_name misc_name[5];
18 extern rtems_name misc_name[5];
19 extern rtems_id Task_id[20]; /* array of task ids */
19 extern rtems_id Task_id[20]; /* array of task ids */
20 extern unsigned char lfrCurrentMode;
20 extern unsigned char lfrCurrentMode;
21 extern unsigned int maxCount;
21 extern unsigned int maxCount;
22
22
23
23
24 //****
24 //****
25 // ISR
25 // ISR
26 rtems_isr commutation_isr1( rtems_vector_number vector );
26 rtems_isr commutation_isr1( rtems_vector_number vector );
27 rtems_isr commutation_isr2( rtems_vector_number vector );
27 rtems_isr commutation_isr2( rtems_vector_number vector );
28
28
29 //***********
29 //***********
30 // RTEMS TASK
30 // RTEMS TASK
31 rtems_task actn_task( rtems_task_argument unused );
31 rtems_task actn_task( rtems_task_argument unused );
32
32
33 //***********
33 //***********
34 // TC ACTIONS
34 // TC ACTIONS
35 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
35 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
36 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
36 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
37 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
37 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
38 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
38 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
39 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
39 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
40 int action_update_time(ccsdsTelecommandPacket_t *TC);
40 int action_update_time(ccsdsTelecommandPacket_t *TC);
41
41
42 // mode transition
42 // mode transition
43 int transition_validation(unsigned char requestedMode);
43 int transition_validation(unsigned char requestedMode);
44 int stop_current_mode();
44 int stop_current_mode();
45 int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC);
45 int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC);
46 int enter_standby_mode();
46 int enter_standby_mode();
47 int enter_normal_mode();
47 int enter_normal_mode();
48 int enter_burst_mode();
48 int enter_burst_mode();
49 int enter_sbm1_mode();
49 int enter_sbm1_mode();
50 int enter_sbm2_mode();
50 int enter_sbm2_mode();
51 int restart_science_tasks();
51 int restart_science_tasks();
52 int suspend_science_tasks();
52 int suspend_science_tasks();
53
53
54 // other functions
54 // other functions
55 void updateLFRCurrentMode();
55 void updateLFRCurrentMode();
56 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC);
56 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC);
57 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC);
57 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC);
58 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id);
58 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id);
59
59
60 #endif // TC_HANDLER_H_INCLUDED
60 #endif // TC_HANDLER_H_INCLUDED
61
61
62
62
63
63
@@ -1,88 +1,81
1 #ifndef WF_HANDLER_H_INCLUDED
1 #ifndef WF_HANDLER_H_INCLUDED
2 #define WF_HANDLER_H_INCLUDED
2 #define WF_HANDLER_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <grspw.h>
5 #include <grspw.h>
6 #include <stdio.h>
6 #include <stdio.h>
7 #include <math.h>
7 #include <math.h>
8
8
9 #include "fsw_params.h"
9 #include "fsw_params.h"
10 #include "fsw_spacewire.h"
11 #include "fsw_misc.h"
12
10
13 #define pi 3.1415
11 #define pi 3.1415
14
12
15 extern int fdSPW;
13 extern int fdSPW;
16 extern volatile int wf_snap_f0[ ];
14 extern volatile int wf_snap_f0[ ];
17 //
15 //
18 extern volatile int wf_snap_f1[ ];
16 extern volatile int wf_snap_f1[ ];
19 extern volatile int wf_snap_f1_bis[ ];
17 extern volatile int wf_snap_f1_bis[ ];
20 extern volatile int wf_snap_f1_norm[ ];
18 extern volatile int wf_snap_f1_norm[ ];
21 //
19 //
22 extern volatile int wf_snap_f2[ ];
20 extern volatile int wf_snap_f2[ ];
23 extern volatile int wf_snap_f2_bis[ ];
21 extern volatile int wf_snap_f2_bis[ ];
24 extern volatile int wf_snap_f2_norm[ ];
22 extern volatile int wf_snap_f2_norm[ ];
25 //
23 //
26 extern volatile int wf_cont_f3[ ];
24 extern volatile int wf_cont_f3[ ];
27 extern volatile int wf_cont_f3_bis[ ];
25 extern volatile int wf_cont_f3_bis[ ];
28 extern char wf_cont_f3_light[ ];
26 extern char wf_cont_f3_light[ ];
29 extern waveform_picker_regs_t *waveform_picker_regs;
27 extern new_waveform_picker_regs_t *new_waveform_picker_regs;
30 extern waveform_picker_regs_t_alt *waveform_picker_regs_alt;
31 extern time_management_regs_t *time_management_regs;
28 extern time_management_regs_t *time_management_regs;
32 extern Packet_TM_LFR_HK_t housekeeping_packet;
29 extern Packet_TM_LFR_HK_t housekeeping_packet;
33 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
30 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
34 extern struct param_local_str param_local;
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 extern rtems_name misc_name[5];
33 extern rtems_name misc_name[5];
40 extern rtems_name Task_name[20]; /* array of task ids */
34 extern rtems_name Task_name[20]; /* array of task ids */
41 extern rtems_id Task_id[20]; /* array of task ids */
35 extern rtems_id Task_id[20]; /* array of task ids */
42
36
43 extern unsigned char lfrCurrentMode;
37 extern unsigned char lfrCurrentMode;
44
38
45 rtems_isr waveforms_isr( rtems_vector_number vector );
39 rtems_isr waveforms_isr( rtems_vector_number vector );
46 rtems_isr waveforms_simulator_isr( rtems_vector_number vector );
40 rtems_isr waveforms_simulator_isr( rtems_vector_number vector );
47 rtems_task wfrm_task( rtems_task_argument argument );
41 rtems_task wfrm_task( rtems_task_argument argument );
48 rtems_task cwf3_task( rtems_task_argument argument );
42 rtems_task cwf3_task( rtems_task_argument argument );
49 rtems_task cwf2_task( rtems_task_argument argument );
43 rtems_task cwf2_task( rtems_task_argument argument );
50 rtems_task cwf1_task( rtems_task_argument argument );
44 rtems_task cwf1_task( rtems_task_argument argument );
51
45
52 //******************
46 //******************
53 // general functions
47 // general functions
54 void init_waveforms( void );
48 void init_waveforms( void );
55 //
49 //
56 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF );
50 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF );
57 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
51 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
58 int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
52 int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF );
59 //
53 //
60 void reset_waveforms( void );
54 void reset_waveforms( void );
61 //
55 //
62 int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id );
56 int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id );
63 int send_waveform_CWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
57 int send_waveform_CWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
64 int send_waveform_CWF3( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
58 int send_waveform_CWF3( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
65 int send_waveform_CWF3_light( volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
59 int send_waveform_CWF3_light( volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id );
66 //
60 //
67 rtems_id get_pkts_queue_id( void );
61 rtems_id get_pkts_queue_id( void );
68
62
69 //**************
63 //**************
70 // wfp registers
64 // wfp registers
71 void set_wfp_data_shaping();
65 void set_wfp_data_shaping();
72 char set_wfp_delta_snapshot();
66 char set_wfp_delta_snapshot();
73 void set_wfp_burst_enable_register( unsigned char mode);
67 void set_wfp_burst_enable_register( unsigned char mode);
74 void reset_wfp_burst_enable();
68 void reset_wfp_run_burst_enable();
75 void reset_wfp_status();
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 // local parameters
74 // local parameters
80 void set_local_sbm1_nb_cwf_max();
75 void set_local_sbm1_nb_cwf_max();
81 void set_local_sbm2_nb_cwf_max();
76 void set_local_sbm2_nb_cwf_max();
82 void set_local_nb_interrupt_f0_MAX();
77 void set_local_nb_interrupt_f0_MAX();
83 void reset_local_sbm1_nb_cwf_sent();
78 void reset_local_sbm1_nb_cwf_sent();
84 void reset_local_sbm2_nb_cwf_sent();
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 #endif // WF_HANDLER_H_INCLUDED
81 #endif // WF_HANDLER_H_INCLUDED
@@ -1,55 +1,54
1 #include <drvmgr/ambapp_bus.h>
1 #include <drvmgr/ambapp_bus.h>
2
2
3 // GRSPW0 resources
3 // GRSPW0 resources
4 struct drvmgr_key grlib_grspw_0n1_res[] = {
4 struct drvmgr_key grlib_grspw_0n1_res[] = {
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
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 {"rxBdCnt", KEY_TYPE_INT, {(unsigned int)10}},
6 {"rxBdCnt", KEY_TYPE_INT, {(unsigned int)10}},
7 {"txDataSize", KEY_TYPE_INT, {(unsigned int)4096}},
7 {"txDataSize", KEY_TYPE_INT, {(unsigned int)4096}},
8 {"txHdrSize", KEY_TYPE_INT, {(unsigned int)20+12}}, // 12 is for the auxiliary header, when needed
8 {"txHdrSize", KEY_TYPE_INT, {(unsigned int)20+12}}, // 12 is for the auxiliary header, when needed
9 {"rxPktSize", KEY_TYPE_INT, {(unsigned int)248+4}},
9 {"rxPktSize", KEY_TYPE_INT, {(unsigned int)248+4}},
10 KEY_EMPTY
10 KEY_EMPTY
11 };
11 };
12
12
13 #if 0
13 #if 0
14 /* APBUART0 */
14 /* APBUART0 */
15 struct drvmgr_key grlib_drv_res_apbuart0[] =
15 struct drvmgr_key grlib_drv_res_apbuart0[] =
16 {
16 {
17 {"mode", KEY_TYPE_INT, {(unsigned int)1}},
17 {"mode", KEY_TYPE_INT, {(unsigned int)1}},
18 {"syscon", KEY_TYPE_INT, {(unsigned int)1}},
18 {"syscon", KEY_TYPE_INT, {(unsigned int)1}},
19 KEY_EMPTY
19 KEY_EMPTY
20 };
20 };
21 /* APBUART1 */
21 /* APBUART1 */
22 struct drvmgr_key grlib_drv_res_apbuart1[] =
22 struct drvmgr_key grlib_drv_res_apbuart1[] =
23 {
23 {
24 {"mode", KEY_TYPE_INT, {(unsigned int)1}},
24 {"mode", KEY_TYPE_INT, {(unsigned int)1}},
25 {"syscon", KEY_TYPE_INT, {(unsigned int)0}},
25 {"syscon", KEY_TYPE_INT, {(unsigned int)0}},
26 KEY_EMPTY
26 KEY_EMPTY
27 };
27 };
28 /* LEON3 System with driver configuration for 2 APBUARTs, the
28 /* LEON3 System with driver configuration for 2 APBUARTs, the
29 * the rest of the AMBA device drivers use their defaults.
29 * the rest of the AMBA device drivers use their defaults.
30 */
30 */
31
31
32 /* Override default debug UART assignment.
32 /* Override default debug UART assignment.
33 * 0 = Default APBUART. APBUART[0], but on MP system CPU0=APBUART0,
33 * 0 = Default APBUART. APBUART[0], but on MP system CPU0=APBUART0,
34 * CPU1=APBUART1...
34 * CPU1=APBUART1...
35 * 1 = APBUART[0]
35 * 1 = APBUART[0]
36 * 2 = APBUART[1]
36 * 2 = APBUART[1]
37 * 3 = APBUART[2]
37 * 3 = APBUART[2]
38 * ...
38 * ...
39 */
39 */
40 //int debug_uart_index = 2; /* second UART -- APBUART[1] */
40 //int debug_uart_index = 2; /* second UART -- APBUART[1] */
41 #endif
41 #endif
42
42
43 // If RTEMS_DRVMGR_STARTUP is defined we override the "weak defaults" that is defined by the LEON3 BSP.
43 // If RTEMS_DRVMGR_STARTUP is defined we override the "weak defaults" that is defined by the LEON3 BSP.
44
44
45 struct drvmgr_bus_res grlib_drv_resources = {
45 struct drvmgr_bus_res grlib_drv_resources = {
46 .next = NULL,
46 .next = NULL,
47 .resource = {
47 .resource = {
48 {DRIVER_AMBAPP_GAISLER_GRSPW_ID, 0, &grlib_grspw_0n1_res[0]},
48 {DRIVER_AMBAPP_GAISLER_GRSPW_ID, 0, &grlib_grspw_0n1_res[0]},
49 // {DRIVER_AMBAPP_GAISLER_APBUART_ID, 0, &grlib_drv_res_apbuart0[0]},
49 // {DRIVER_AMBAPP_GAISLER_APBUART_ID, 0, &grlib_drv_res_apbuart0[0]},
50 // {DRIVER_AMBAPP_GAISLER_APBUART_ID, 1, &grlib_drv_res_apbuart1[0]},
50 // {DRIVER_AMBAPP_GAISLER_APBUART_ID, 1, &grlib_drv_res_apbuart1[0]},
51 RES_EMPTY /* Mark end of device resource array */
51 RES_EMPTY /* Mark end of device resource array */
52 }
52 }
53 };
53 };
54
54
55
@@ -1,92 +1,89
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
23
24 // RTEMS GLOBAL VARIABLES
24 // RTEMS GLOBAL VARIABLES
25 rtems_name misc_name[5];
25 rtems_name misc_name[5];
26 rtems_id misc_id[5];
26 rtems_id misc_id[5];
27 rtems_name Task_name[20]; /* array of task names */
27 rtems_name Task_name[20]; /* array of task names */
28 rtems_id Task_id[20]; /* array of task ids */
28 rtems_id Task_id[20]; /* array of task ids */
29 unsigned int maxCount;
29 unsigned int maxCount;
30 int fdSPW = 0;
30 int fdSPW = 0;
31 int fdUART = 0;
31 int fdUART = 0;
32 unsigned char lfrCurrentMode;
32 unsigned char lfrCurrentMode;
33
33
34 // APB CONFIGURATION REGISTERS
34 // APB CONFIGURATION REGISTERS
35 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
35 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
36 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
36 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
37 #ifdef GSA
37 #ifdef GSA
38 #else
38 #else
39 waveform_picker_regs_t *waveform_picker_regs = (waveform_picker_regs_t*) REGS_ADDR_WAVEFORM_PICKER;
39 new_waveform_picker_regs_t *new_waveform_picker_regs = (new_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;
41 #endif
40 #endif
42 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
41 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
43
42
44 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes
43 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes
45 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
44 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
46 //
45 //
47 volatile int wf_snap_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
46 volatile int wf_snap_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
48 volatile int wf_snap_f1_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
47 volatile int wf_snap_f1_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
49 volatile int wf_snap_f1_norm[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
48 volatile int wf_snap_f1_norm[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
50 //
49 //
51 volatile int wf_snap_f2[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
50 volatile int wf_snap_f2[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
52 volatile int wf_snap_f2_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
51 volatile int wf_snap_f2_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
53 volatile int wf_snap_f2_norm[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
52 volatile int wf_snap_f2_norm[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
54 //
53 //
55 volatile int wf_cont_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
54 volatile int wf_cont_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
56 volatile int wf_cont_f3_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
55 volatile int wf_cont_f3_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET ];
57 char wf_cont_f3_light[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_CWF3_LIGHT_BLK ];
56 char wf_cont_f3_light[ NB_SAMPLES_PER_SNAPSHOT * NB_BYTES_CWF3_LIGHT_BLK ];
58
57
59 // SPECTRAL MATRICES GLOBAL VARIABLES
58 // SPECTRAL MATRICES GLOBAL VARIABLES
60 volatile int spec_mat_f0_0[ SM_HEADER + TOTAL_SIZE_SM ];
59 volatile int spec_mat_f0_0[ SM_HEADER + TOTAL_SIZE_SM ];
61 volatile int spec_mat_f0_1[ SM_HEADER + TOTAL_SIZE_SM ];
60 volatile int spec_mat_f0_1[ SM_HEADER + TOTAL_SIZE_SM ];
62 volatile int spec_mat_f0_a[ SM_HEADER + TOTAL_SIZE_SM ];
61 volatile int spec_mat_f0_a[ SM_HEADER + TOTAL_SIZE_SM ];
63 volatile int spec_mat_f0_b[ SM_HEADER + TOTAL_SIZE_SM ];
62 volatile int spec_mat_f0_b[ SM_HEADER + TOTAL_SIZE_SM ];
64 volatile int spec_mat_f0_c[ SM_HEADER + TOTAL_SIZE_SM ];
63 volatile int spec_mat_f0_c[ SM_HEADER + TOTAL_SIZE_SM ];
65 volatile int spec_mat_f0_d[ SM_HEADER + TOTAL_SIZE_SM ];
64 volatile int spec_mat_f0_d[ SM_HEADER + TOTAL_SIZE_SM ];
66 volatile int spec_mat_f0_e[ SM_HEADER + TOTAL_SIZE_SM ];
65 volatile int spec_mat_f0_e[ SM_HEADER + TOTAL_SIZE_SM ];
67 volatile int spec_mat_f0_f[ SM_HEADER + TOTAL_SIZE_SM ];
66 volatile int spec_mat_f0_f[ SM_HEADER + TOTAL_SIZE_SM ];
68 volatile int spec_mat_f0_g[ SM_HEADER + TOTAL_SIZE_SM ];
67 volatile int spec_mat_f0_g[ SM_HEADER + TOTAL_SIZE_SM ];
69 volatile int spec_mat_f0_h[ SM_HEADER + TOTAL_SIZE_SM ];
68 volatile int spec_mat_f0_h[ SM_HEADER + TOTAL_SIZE_SM ];
70 volatile int spec_mat_f0_0_bis[ SM_HEADER + TOTAL_SIZE_SM ];
69 volatile int spec_mat_f0_0_bis[ SM_HEADER + TOTAL_SIZE_SM ];
71 volatile int spec_mat_f0_1_bis[ SM_HEADER + TOTAL_SIZE_SM ];
70 volatile int spec_mat_f0_1_bis[ SM_HEADER + TOTAL_SIZE_SM ];
72 //
71 //
73 volatile int spec_mat_f1[ SM_HEADER + TOTAL_SIZE_SM ];
72 volatile int spec_mat_f1[ SM_HEADER + TOTAL_SIZE_SM ];
74 volatile int spec_mat_f1_bis[ SM_HEADER + TOTAL_SIZE_SM ];
73 volatile int spec_mat_f1_bis[ SM_HEADER + TOTAL_SIZE_SM ];
75 //
74 //
76 volatile int spec_mat_f2[ SM_HEADER + TOTAL_SIZE_SM ];
75 volatile int spec_mat_f2[ SM_HEADER + TOTAL_SIZE_SM ];
77 volatile int spec_mat_f2_bis[ SM_HEADER + TOTAL_SIZE_SM ];
76 volatile int spec_mat_f2_bis[ SM_HEADER + TOTAL_SIZE_SM ];
78
77
79 // MODE PARAMETERS
78 // MODE PARAMETERS
80 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
79 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
81 struct param_local_str param_local;
80 struct param_local_str param_local;
82
81
83 // HK PACKETS
82 // HK PACKETS
84 Packet_TM_LFR_HK_t housekeeping_packet;
83 Packet_TM_LFR_HK_t housekeeping_packet;
85 // sequence counters are incremented by APID (PID + CAT) and destination ID
84 // sequence counters are incremented by APID (PID + CAT) and destination ID
86 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
85 unsigned short sequenceCounters[SEQ_CNT_NB_PID][SEQ_CNT_NB_CAT][SEQ_CNT_NB_DEST_ID];
87 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
88 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
89 spw_stats spacewire_stats;
86 spw_stats spacewire_stats;
90 spw_stats spacewire_stats_backup;
87 spw_stats spacewire_stats_backup;
91
88
92
89
@@ -1,586 +1,593
1 /** This is the RTEMS initialization module.
1 /** This is the RTEMS initialization module.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * This module contains two very different information:
6 * This module contains two very different information:
7 * - specific instructions to configure the compilation of the RTEMS executive
7 * - specific instructions to configure the compilation of the RTEMS executive
8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
9 *
9 *
10 */
10 */
11
11
12 //*************************
12 //*************************
13 // GPL reminder to be added
13 // GPL reminder to be added
14 //*************************
14 //*************************
15
15
16 #include <rtems.h>
16 #include <rtems.h>
17
17
18 /* configuration information */
18 /* configuration information */
19
19
20 #define CONFIGURE_INIT
20 #define CONFIGURE_INIT
21
21
22 #include <bsp.h> /* for device driver prototypes */
22 #include <bsp.h> /* for device driver prototypes */
23
23
24 /* configuration information */
24 /* configuration information */
25
25
26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
28
28
29 #define CONFIGURE_MAXIMUM_TASKS 20
29 #define CONFIGURE_MAXIMUM_TASKS 20
30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
35 #define CONFIGURE_MAXIMUM_DRIVERS 16
35 #define CONFIGURE_MAXIMUM_DRIVERS 16
36 #define CONFIGURE_MAXIMUM_PERIODS 5
36 #define CONFIGURE_MAXIMUM_PERIODS 5
37 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
37 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
38 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2
38 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2
39 #ifdef PRINT_STACK_REPORT
39 #ifdef PRINT_STACK_REPORT
40 #define CONFIGURE_STACK_CHECKER_ENABLED
40 #define CONFIGURE_STACK_CHECKER_ENABLED
41 #endif
41 #endif
42
42
43 #include <rtems/confdefs.h>
43 #include <rtems/confdefs.h>
44
44
45 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
45 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
46 #ifdef RTEMS_DRVMGR_STARTUP
46 #ifdef RTEMS_DRVMGR_STARTUP
47 #ifdef LEON3
47 #ifdef LEON3
48 /* Add Timer and UART Driver */
48 /* Add Timer and UART Driver */
49 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
49 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
50 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
50 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
51 #endif
51 #endif
52 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
52 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
53 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
53 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
54 #endif
54 #endif
55 #endif
55 #endif
56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
57 #include <drvmgr/drvmgr_confdefs.h>
57 #include <drvmgr/drvmgr_confdefs.h>
58 #endif
58 #endif
59
59
60 #include "fsw_init.h"
60 #include "fsw_init.h"
61 #include "fsw_config.c"
61 #include "fsw_config.c"
62
62
63 rtems_task Init( rtems_task_argument ignored )
63 rtems_task Init( rtems_task_argument ignored )
64 {
64 {
65 /** This is the RTEMS INIT taks, it the first task launched by the system.
65 /** This is the RTEMS INIT taks, it the first task launched by the system.
66 *
66 *
67 * @param unused is the starting argument of the RTEMS task
67 * @param unused is the starting argument of the RTEMS task
68 *
68 *
69 * The INIT task create and run all other RTEMS tasks.
69 * The INIT task create and run all other RTEMS tasks.
70 *
70 *
71 */
71 */
72
72
73
74 rtems_status_code status;
73 rtems_status_code status;
75 rtems_status_code status_spw;
74 rtems_status_code status_spw;
76 rtems_isr_entry old_isr_handler;
75 rtems_isr_entry old_isr_handler;
77
76
78 BOOT_PRINTF("\n\n\n\n\n")
77 BOOT_PRINTF("\n\n\n\n\n")
79 BOOT_PRINTF("***************************\n")
78 BOOT_PRINTF("***************************\n")
80 BOOT_PRINTF("** START Flight Software **\n")
79 BOOT_PRINTF("** START Flight Software **\n")
81 BOOT_PRINTF("***************************\n")
80 BOOT_PRINTF("***************************\n")
82 BOOT_PRINTF("\n\n")
81 BOOT_PRINTF("\n\n")
83
82
84 //send_console_outputs_on_apbuart_port();
83 //send_console_outputs_on_apbuart_port();
85 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
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 init_parameter_dump();
90 init_parameter_dump();
90 init_local_mode_parameters();
91 init_local_mode_parameters();
91 init_housekeeping_parameters();
92 init_housekeeping_parameters();
92
93
93 updateLFRCurrentMode();
94 updateLFRCurrentMode();
94
95
95 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
96 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
96
97
97 create_names(); // create all names
98 create_names(); // create all names
98
99
99 status = create_message_queues(); // create message queues
100 status = create_message_queues(); // create message queues
100 if (status != RTEMS_SUCCESSFUL)
101 if (status != RTEMS_SUCCESSFUL)
101 {
102 {
102 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
103 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
103 }
104 }
104
105
105 status = create_all_tasks(); // create all tasks
106 status = create_all_tasks(); // create all tasks
106 if (status != RTEMS_SUCCESSFUL)
107 if (status != RTEMS_SUCCESSFUL)
107 {
108 {
108 PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status)
109 PRINTF1("in INIT *** ERR in create_all_tasks, code %d", status)
109 }
110 }
110
111
111 // **************************
112 // **************************
112 // <SPACEWIRE INITIALIZATION>
113 // <SPACEWIRE INITIALIZATION>
113 grspw_timecode_callback = &timecode_irq_handler;
114 grspw_timecode_callback = &timecode_irq_handler;
114
115
115 status_spw = spacewire_open_link(); // (1) open the link
116 status_spw = spacewire_open_link(); // (1) open the link
116 if ( status_spw != RTEMS_SUCCESSFUL )
117 if ( status_spw != RTEMS_SUCCESSFUL )
117 {
118 {
118 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
119 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
119 }
120 }
120
121
121 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
122 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
122 {
123 {
123 status_spw = spacewire_configure_link( fdSPW );
124 status_spw = spacewire_configure_link( fdSPW );
124 if ( status_spw != RTEMS_SUCCESSFUL )
125 if ( status_spw != RTEMS_SUCCESSFUL )
125 {
126 {
126 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
127 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
127 }
128 }
128 }
129 }
129
130
130 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
131 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
131 {
132 {
132 status_spw = spacewire_start_link( fdSPW );
133 status_spw = spacewire_start_link( fdSPW );
133 if ( status_spw != RTEMS_SUCCESSFUL )
134 if ( status_spw != RTEMS_SUCCESSFUL )
134 {
135 {
135 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
136 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
136 }
137 }
137 }
138 }
138 // </SPACEWIRE INITIALIZATION>
139 // </SPACEWIRE INITIALIZATION>
139 // ***************************
140 // ***************************
140
141
141 status = start_all_tasks(); // start all tasks
142 status = start_all_tasks(); // start all tasks
142 if (status != RTEMS_SUCCESSFUL)
143 if (status != RTEMS_SUCCESSFUL)
143 {
144 {
144 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
145 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
145 }
146 }
146
147
147 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
148 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
148 status = start_recv_send_tasks();
149 status = start_recv_send_tasks();
149 if ( status != RTEMS_SUCCESSFUL )
150 if ( status != RTEMS_SUCCESSFUL )
150 {
151 {
151 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
152 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
152 }
153 }
153
154
154 // suspend science tasks. they will be restarted later depending on the mode
155 // suspend science tasks. they will be restarted later depending on the mode
155 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
156 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
156 if (status != RTEMS_SUCCESSFUL)
157 if (status != RTEMS_SUCCESSFUL)
157 {
158 {
158 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
159 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
159 }
160 }
160
161
161 #ifdef GSA
162 #ifdef GSA
162 // mask IRQ lines
163 // mask IRQ lines
163 LEON_Mask_interrupt( IRQ_SM );
164 LEON_Mask_interrupt( IRQ_SM );
164 LEON_Mask_interrupt( IRQ_WF );
165 LEON_Mask_interrupt( IRQ_WF );
165 // Spectral Matrices simulator
166 // Spectral Matrices simulator
166 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
167 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
167 IRQ_SPARC_SM, spectral_matrices_isr );
168 IRQ_SPARC_SM, spectral_matrices_isr );
168 // WaveForms
169 // WaveForms
169 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
170 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
170 IRQ_SPARC_WF, waveforms_simulator_isr );
171 IRQ_SPARC_WF, waveforms_simulator_isr );
171 #else
172 #else
172 // configure IRQ handling for the waveform picker unit
173 // configure IRQ handling for the waveform picker unit
173 status = rtems_interrupt_catch( waveforms_isr,
174 status = rtems_interrupt_catch( waveforms_isr,
174 IRQ_SPARC_WAVEFORM_PICKER,
175 IRQ_SPARC_WAVEFORM_PICKER,
175 &old_isr_handler) ;
176 &old_isr_handler) ;
176 #endif
177 #endif
177
178
178 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
179 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
179 if ( status_spw != RTEMS_SUCCESSFUL )
180 if ( status_spw != RTEMS_SUCCESSFUL )
180 {
181 {
181 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
182 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
182 if ( status != RTEMS_SUCCESSFUL ) {
183 if ( status != RTEMS_SUCCESSFUL ) {
183 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
184 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
184 }
185 }
185 }
186 }
186
187
187 BOOT_PRINTF("delete INIT\n")
188 BOOT_PRINTF("delete INIT\n")
188
189
189 status = rtems_task_delete(RTEMS_SELF);
190 status = rtems_task_delete(RTEMS_SELF);
190
191
191 }
192 }
192
193
193 void init_local_mode_parameters( void )
194 void init_local_mode_parameters( void )
194 {
195 {
195 /** This function initialize the param_local global variable with default values.
196 /** This function initialize the param_local global variable with default values.
196 *
197 *
197 */
198 */
198
199
199 unsigned int i;
200 unsigned int i;
201 unsigned int j;
202 unsigned int k;
200
203
201 // LOCAL PARAMETERS
204 // LOCAL PARAMETERS
202 set_local_sbm1_nb_cwf_max();
205 set_local_sbm1_nb_cwf_max();
203 set_local_sbm2_nb_cwf_max();
206 set_local_sbm2_nb_cwf_max();
204 set_local_nb_interrupt_f0_MAX();
207 set_local_nb_interrupt_f0_MAX();
205
208
206 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
209 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
207 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
210 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
208 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
211 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
209
212
210 reset_local_sbm1_nb_cwf_sent();
213 reset_local_sbm1_nb_cwf_sent();
211 reset_local_sbm2_nb_cwf_sent();
214 reset_local_sbm2_nb_cwf_sent();
212
215
213 // init sequence counters
216 // init sequence counters
214
217 for (i = 0; i<SEQ_CNT_NB_PID; i++)
215 for(i<