##// 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 = 0; i<SEQ_CNT_NB_DEST_ID; 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 void create_names( void ) // create all names for tasks and queues
229 void create_names( void ) // create all names for tasks and queues
224 {
230 {
225 /** This function creates all RTEMS names used in the software for tasks and queues.
231 /** This function creates all RTEMS names used in the software for tasks and queues.
226 *
232 *
227 * @return RTEMS directive status codes:
233 * @return RTEMS directive status codes:
228 * - RTEMS_SUCCESSFUL - successful completion
234 * - RTEMS_SUCCESSFUL - successful completion
229 *
235 *
230 */
236 */
231
237
232 // task names
238 // task names
233 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
239 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
234 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
240 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
235 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
241 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
236 Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' );
242 Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' );
237 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
243 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
238 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
244 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
239 Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' );
245 Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' );
240 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
246 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
241 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
247 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
242 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
248 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
243 Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' );
249 Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' );
244 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
250 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
245 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
251 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
246 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
252 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
247 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
253 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
248 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
254 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
249
255
250 // rate monotonic period names
256 // rate monotonic period names
251 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
257 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
252
258
253 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
259 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
254 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
260 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
255 }
261 }
256
262
257 int create_all_tasks( void ) // create all tasks which run in the software
263 int create_all_tasks( void ) // create all tasks which run in the software
258 {
264 {
259 /** This function creates all RTEMS tasks used in the software.
265 /** This function creates all RTEMS tasks used in the software.
260 *
266 *
261 * @return RTEMS directive status codes:
267 * @return RTEMS directive status codes:
262 * - RTEMS_SUCCESSFUL - task created successfully
268 * - RTEMS_SUCCESSFUL - task created successfully
263 * - RTEMS_INVALID_ADDRESS - id is NULL
269 * - RTEMS_INVALID_ADDRESS - id is NULL
264 * - RTEMS_INVALID_NAME - invalid task name
270 * - RTEMS_INVALID_NAME - invalid task name
265 * - RTEMS_INVALID_PRIORITY - invalid task priority
271 * - RTEMS_INVALID_PRIORITY - invalid task priority
266 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
272 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
267 * - RTEMS_TOO_MANY - too many tasks created
273 * - RTEMS_TOO_MANY - too many tasks created
268 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
274 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
269 * - RTEMS_TOO_MANY - too many global objects
275 * - RTEMS_TOO_MANY - too many global objects
270 *
276 *
271 */
277 */
272
278
273 rtems_status_code status;
279 rtems_status_code status;
274
280
275 // RECV
281 // RECV
276 status = rtems_task_create(
282 status = rtems_task_create(
277 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
283 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
278 RTEMS_DEFAULT_MODES,
284 RTEMS_DEFAULT_MODES,
279 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
285 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
280 );
286 );
281
287
282 if (status == RTEMS_SUCCESSFUL) // ACTN
288 if (status == RTEMS_SUCCESSFUL) // ACTN
283 {
289 {
284 status = rtems_task_create(
290 status = rtems_task_create(
285 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
291 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
286 RTEMS_DEFAULT_MODES,
292 RTEMS_DEFAULT_MODES,
287 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
293 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
288 );
294 );
289 }
295 }
290 if (status == RTEMS_SUCCESSFUL) // SPIQ
296 if (status == RTEMS_SUCCESSFUL) // SPIQ
291 {
297 {
292 status = rtems_task_create(
298 status = rtems_task_create(
293 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
299 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
294 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
300 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
295 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
301 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
296 );
302 );
297 }
303 }
298 if (status == RTEMS_SUCCESSFUL) // SMIQ
304 if (status == RTEMS_SUCCESSFUL) // SMIQ
299 {
305 {
300 status = rtems_task_create(
306 status = rtems_task_create(
301 Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE,
307 Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE,
302 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
308 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
303 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
309 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
304 );
310 );
305 }
311 }
306 if (status == RTEMS_SUCCESSFUL) // STAT
312 if (status == RTEMS_SUCCESSFUL) // STAT
307 {
313 {
308 status = rtems_task_create(
314 status = rtems_task_create(
309 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
315 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
310 RTEMS_DEFAULT_MODES,
316 RTEMS_DEFAULT_MODES,
311 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
317 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
312 );
318 );
313 }
319 }
314 if (status == RTEMS_SUCCESSFUL) // AVF0
320 if (status == RTEMS_SUCCESSFUL) // AVF0
315 {
321 {
316 status = rtems_task_create(
322 status = rtems_task_create(
317 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
323 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
318 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
324 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
319 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
325 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
320 );
326 );
321 }
327 }
322 if (status == RTEMS_SUCCESSFUL) // BPF0
328 if (status == RTEMS_SUCCESSFUL) // BPF0
323 {
329 {
324 status = rtems_task_create(
330 status = rtems_task_create(
325 Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE,
331 Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE,
326 RTEMS_DEFAULT_MODES,
332 RTEMS_DEFAULT_MODES,
327 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0]
333 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0]
328 );
334 );
329 }
335 }
330 if (status == RTEMS_SUCCESSFUL) // WFRM
336 if (status == RTEMS_SUCCESSFUL) // WFRM
331 {
337 {
332 status = rtems_task_create(
338 status = rtems_task_create(
333 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
339 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
334 RTEMS_DEFAULT_MODES,
340 RTEMS_DEFAULT_MODES,
335 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
341 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
336 );
342 );
337 }
343 }
338 if (status == RTEMS_SUCCESSFUL) // DUMB
344 if (status == RTEMS_SUCCESSFUL) // DUMB
339 {
345 {
340 status = rtems_task_create(
346 status = rtems_task_create(
341 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
347 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
342 RTEMS_DEFAULT_MODES,
348 RTEMS_DEFAULT_MODES,
343 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
349 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
344 );
350 );
345 }
351 }
346 if (status == RTEMS_SUCCESSFUL) // HOUS
352 if (status == RTEMS_SUCCESSFUL) // HOUS
347 {
353 {
348 status = rtems_task_create(
354 status = rtems_task_create(
349 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
355 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
350 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
356 RTEMS_DEFAULT_MODES,
351 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
357 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
352 );
358 );
353 }
359 }
354 if (status == RTEMS_SUCCESSFUL) // MATR
360 if (status == RTEMS_SUCCESSFUL) // MATR
355 {
361 {
356 status = rtems_task_create(
362 status = rtems_task_create(
357 Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE,
363 Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE,
358 RTEMS_DEFAULT_MODES,
364 RTEMS_DEFAULT_MODES,
359 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR]
365 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR]
360 );
366 );
361 }
367 }
362 if (status == RTEMS_SUCCESSFUL) // CWF3
368 if (status == RTEMS_SUCCESSFUL) // CWF3
363 {
369 {
364 status = rtems_task_create(
370 status = rtems_task_create(
365 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
371 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
366 RTEMS_DEFAULT_MODES,
372 RTEMS_DEFAULT_MODES,
367 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF3]
373 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF3]
368 );
374 );
369 }
375 }
370 if (status == RTEMS_SUCCESSFUL) // CWF2
376 if (status == RTEMS_SUCCESSFUL) // CWF2
371 {
377 {
372 status = rtems_task_create(
378 status = rtems_task_create(
373 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
379 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
374 RTEMS_DEFAULT_MODES,
380 RTEMS_DEFAULT_MODES,
375 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF2]
381 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF2]
376 );
382 );
377 }
383 }
378 if (status == RTEMS_SUCCESSFUL) // CWF1
384 if (status == RTEMS_SUCCESSFUL) // CWF1
379 {
385 {
380 status = rtems_task_create(
386 status = rtems_task_create(
381 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
387 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
382 RTEMS_DEFAULT_MODES,
388 RTEMS_DEFAULT_MODES,
383 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF1]
389 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF1]
384 );
390 );
385 }
391 }
386 if (status == RTEMS_SUCCESSFUL) // SEND
392 if (status == RTEMS_SUCCESSFUL) // SEND
387 {
393 {
388 status = rtems_task_create(
394 status = rtems_task_create(
389 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
395 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
390 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
396 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
391 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
397 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
392 );
398 );
393 }
399 }
394 if (status == RTEMS_SUCCESSFUL) // WTDG
400 if (status == RTEMS_SUCCESSFUL) // WTDG
395 {
401 {
396 status = rtems_task_create(
402 status = rtems_task_create(
397 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
403 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
398 RTEMS_DEFAULT_MODES,
404 RTEMS_DEFAULT_MODES,
399 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
405 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
400 );
406 );
401 }
407 }
402
408
403 return status;
409 return status;
404 }
410 }
405
411
406 int start_recv_send_tasks( void )
412 int start_recv_send_tasks( void )
407 {
413 {
408 rtems_status_code status;
414 rtems_status_code status;
409
415
410 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
416 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
411 if (status!=RTEMS_SUCCESSFUL) {
417 if (status!=RTEMS_SUCCESSFUL) {
412 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
418 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
413 }
419 }
414
420
415 if (status == RTEMS_SUCCESSFUL) // SEND
421 if (status == RTEMS_SUCCESSFUL) // SEND
416 {
422 {
417 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
423 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
418 if (status!=RTEMS_SUCCESSFUL) {
424 if (status!=RTEMS_SUCCESSFUL) {
419 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
425 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
420 }
426 }
421 }
427 }
422
428
423 return status;
429 return status;
424 }
430 }
425
431
426 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
432 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
427 {
433 {
428 /** This function starts all RTEMS tasks used in the software.
434 /** This function starts all RTEMS tasks used in the software.
429 *
435 *
430 * @return RTEMS directive status codes:
436 * @return RTEMS directive status codes:
431 * - RTEMS_SUCCESSFUL - ask started successfully
437 * - RTEMS_SUCCESSFUL - ask started successfully
432 * - RTEMS_INVALID_ADDRESS - invalid task entry point
438 * - RTEMS_INVALID_ADDRESS - invalid task entry point
433 * - RTEMS_INVALID_ID - invalid task id
439 * - RTEMS_INVALID_ID - invalid task id
434 * - RTEMS_INCORRECT_STATE - task not in the dormant state
440 * - RTEMS_INCORRECT_STATE - task not in the dormant state
435 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
441 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
436 *
442 *
437 */
443 */
438 // starts all the tasks fot eh flight software
444 // starts all the tasks fot eh flight software
439
445
440 rtems_status_code status;
446 rtems_status_code status;
441
447
442 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
448 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
443 if (status!=RTEMS_SUCCESSFUL) {
449 if (status!=RTEMS_SUCCESSFUL) {
444 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
450 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
445 }
451 }
446
452
447 if (status == RTEMS_SUCCESSFUL) // WTDG
453 if (status == RTEMS_SUCCESSFUL) // WTDG
448 {
454 {
449 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
455 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
450 if (status!=RTEMS_SUCCESSFUL) {
456 if (status!=RTEMS_SUCCESSFUL) {
451 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
457 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
452 }
458 }
453 }
459 }
454
460
455 if (status == RTEMS_SUCCESSFUL) // SMIQ
461 if (status == RTEMS_SUCCESSFUL) // SMIQ
456 {
462 {
457 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
463 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
458 if (status!=RTEMS_SUCCESSFUL) {
464 if (status!=RTEMS_SUCCESSFUL) {
459 BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n")
465 BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n")
460 }
466 }
461 }
467 }
462
468
463 if (status == RTEMS_SUCCESSFUL) // ACTN
469 if (status == RTEMS_SUCCESSFUL) // ACTN
464 {
470 {
465 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
471 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
466 if (status!=RTEMS_SUCCESSFUL) {
472 if (status!=RTEMS_SUCCESSFUL) {
467 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
473 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
468 }
474 }
469 }
475 }
470
476
471 if (status == RTEMS_SUCCESSFUL) // STAT
477 if (status == RTEMS_SUCCESSFUL) // STAT
472 {
478 {
473 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
479 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
474 if (status!=RTEMS_SUCCESSFUL) {
480 if (status!=RTEMS_SUCCESSFUL) {
475 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
481 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
476 }
482 }
477 }
483 }
478
484
479 if (status == RTEMS_SUCCESSFUL) // AVF0
485 if (status == RTEMS_SUCCESSFUL) // AVF0
480 {
486 {
481 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
487 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
482 if (status!=RTEMS_SUCCESSFUL) {
488 if (status!=RTEMS_SUCCESSFUL) {
483 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
489 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
484 }
490 }
485 }
491 }
486
492
487 if (status == RTEMS_SUCCESSFUL) // BPF0
493 if (status == RTEMS_SUCCESSFUL) // BPF0
488 {
494 {
489 status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 );
495 status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 );
490 if (status!=RTEMS_SUCCESSFUL) {
496 if (status!=RTEMS_SUCCESSFUL) {
491 BOOT_PRINTF("in INIT *** Error starting TASK_BPF0\n")
497 BOOT_PRINTF("in INIT *** Error starting TASK_BPF0\n")
492 }
498 }
493 }
499 }
494
500
495 if (status == RTEMS_SUCCESSFUL) // WFRM
501 if (status == RTEMS_SUCCESSFUL) // WFRM
496 {
502 {
497 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
503 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
498 if (status!=RTEMS_SUCCESSFUL) {
504 if (status!=RTEMS_SUCCESSFUL) {
499 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
505 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
500 }
506 }
501 }
507 }
502
508
503 if (status == RTEMS_SUCCESSFUL) // DUMB
509 if (status == RTEMS_SUCCESSFUL) // DUMB
504 {
510 {
505 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
511 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
506 if (status!=RTEMS_SUCCESSFUL) {
512 if (status!=RTEMS_SUCCESSFUL) {
507 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
513 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
508 }
514 }
509 }
515 }
510
516
511 if (status == RTEMS_SUCCESSFUL) // HOUS
517 if (status == RTEMS_SUCCESSFUL) // HOUS
512 {
518 {
513 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
519 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
514 if (status!=RTEMS_SUCCESSFUL) {
520 if (status!=RTEMS_SUCCESSFUL) {
515 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
521 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
516 }
522 }
517 }
523 }
518
524
519 if (status == RTEMS_SUCCESSFUL) // MATR
525 if (status == RTEMS_SUCCESSFUL) // MATR
520 {
526 {
521 status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 );
527 status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 );
522 if (status!=RTEMS_SUCCESSFUL) {
528 if (status!=RTEMS_SUCCESSFUL) {
523 BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n")
529 BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n")
524 }
530 }
525 }
531 }
526
532
527 if (status == RTEMS_SUCCESSFUL) // CWF3
533 if (status == RTEMS_SUCCESSFUL) // CWF3
528 {
534 {
529 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
535 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
530 if (status!=RTEMS_SUCCESSFUL) {
536 if (status!=RTEMS_SUCCESSFUL) {
531 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
537 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
532 }
538 }
533 }
539 }
534
540
535 if (status == RTEMS_SUCCESSFUL) // CWF2
541 if (status == RTEMS_SUCCESSFUL) // CWF2
536 {
542 {
537 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
543 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
538 if (status!=RTEMS_SUCCESSFUL) {
544 if (status!=RTEMS_SUCCESSFUL) {
539 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
545 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
540 }
546 }
541 }
547 }
542
548
543 if (status == RTEMS_SUCCESSFUL) // CWF1
549 if (status == RTEMS_SUCCESSFUL) // CWF1
544 {
550 {
545 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
551 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
546 if (status!=RTEMS_SUCCESSFUL) {
552 if (status!=RTEMS_SUCCESSFUL) {
547 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
553 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
548 }
554 }
549 }
555 }
550 return status;
556 return status;
551 }
557 }
552
558
553 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
559 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
554 {
560 {
555 rtems_status_code status_recv;
561 rtems_status_code status_recv;
556 rtems_status_code status_send;
562 rtems_status_code status_send;
557 rtems_status_code ret;
563 rtems_status_code ret;
558 rtems_id queue_id;
564 rtems_id queue_id;
559
565
560 // create the queue for handling valid TCs
566 // create the queue for handling valid TCs
561 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
567 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
562 ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
568 ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
563 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
569 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
564 if ( status_recv != RTEMS_SUCCESSFUL ) {
570 if ( status_recv != RTEMS_SUCCESSFUL ) {
565 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
571 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
566 }
572 }
567
573
568 // create the queue for handling TM packet sending
574 // create the queue for handling TM packet sending
569 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
575 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
570 ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_MAX_SIZE,
576 ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_MAX_SIZE,
571 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
577 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
572 if ( status_send != RTEMS_SUCCESSFUL ) {
578 if ( status_send != RTEMS_SUCCESSFUL ) {
573 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
579 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
574 }
580 }
575
581
576 if ( status_recv != RTEMS_SUCCESSFUL )
582 if ( status_recv != RTEMS_SUCCESSFUL )
577 {
583 {
578 ret = status_recv;
584 ret = status_recv;
579 }
585 }
580 else
586 else
581 {
587 {
582 ret = status_send;
588 ret = status_send;
583 }
589 }
584
590
585 return ret;
591 return ret;
586 }
592 }
593
@@ -1,768 +1,772
1 /** Functions and tasks related to TeleCommand handling.
1 /** Functions and tasks related to TeleCommand handling.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle TeleCommands:\n
6 * A group of functions to handle TeleCommands:\n
7 * action launching\n
7 * action launching\n
8 * TC parsing\n
8 * TC parsing\n
9 * ...
9 * ...
10 *
10 *
11 */
11 */
12
12
13 #include "tc_handler.h"
13 #include "tc_handler.h"
14
14
15 //***********
15 //***********
16 // RTEMS TASK
16 // RTEMS TASK
17
17
18 rtems_task actn_task( rtems_task_argument unused )
18 rtems_task actn_task( rtems_task_argument unused )
19 {
19 {
20 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
20 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
21 *
21 *
22 * @param unused is the starting argument of the RTEMS task
22 * @param unused is the starting argument of the RTEMS task
23 *
23 *
24 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
24 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
25 * on the incoming TeleCommand.
25 * on the incoming TeleCommand.
26 *
26 *
27 */
27 */
28
28
29 int result;
29 int result;
30 rtems_status_code status; // RTEMS status code
30 rtems_status_code status; // RTEMS status code
31 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
31 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
32 size_t size; // size of the incoming TC packet
32 size_t size; // size of the incoming TC packet
33 unsigned char subtype; // subtype of the current TC packet
33 unsigned char subtype; // subtype of the current TC packet
34 rtems_id queue_rcv_id;
34 rtems_id queue_rcv_id;
35 rtems_id queue_snd_id;
35 rtems_id queue_snd_id;
36
36
37 status = rtems_message_queue_ident( misc_name[QUEUE_RECV], 0, &queue_rcv_id );
37 status = rtems_message_queue_ident( misc_name[QUEUE_RECV], 0, &queue_rcv_id );
38 if (status != RTEMS_SUCCESSFUL)
38 if (status != RTEMS_SUCCESSFUL)
39 {
39 {
40 PRINTF1("in ACTN *** ERR getting queue_rcv_id %d\n", status)
40 PRINTF1("in ACTN *** ERR getting queue_rcv_id %d\n", status)
41 }
41 }
42
42
43 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_snd_id );
43 status = rtems_message_queue_ident( misc_name[QUEUE_SEND], 0, &queue_snd_id );
44 if (status != RTEMS_SUCCESSFUL)
44 if (status != RTEMS_SUCCESSFUL)
45 {
45 {
46 PRINTF1("in ACTN *** ERR getting queue_snd_id %d\n", status)
46 PRINTF1("in ACTN *** ERR getting queue_snd_id %d\n", status)
47 }
47 }
48
48
49 result = LFR_SUCCESSFUL;
49 result = LFR_SUCCESSFUL;
50 subtype = 0; // subtype of the current TC packet
50 subtype = 0; // subtype of the current TC packet
51
51
52 BOOT_PRINTF("in ACTN *** \n")
52 BOOT_PRINTF("in ACTN *** \n")
53
53
54 while(1)
54 while(1)
55 {
55 {
56 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
56 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
57 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
57 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
58 if (status!=RTEMS_SUCCESSFUL) PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
58 if (status!=RTEMS_SUCCESSFUL) PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
59 else
59 else
60 {
60 {
61 subtype = TC.serviceSubType;
61 subtype = TC.serviceSubType;
62 switch(subtype)
62 switch(subtype)
63 {
63 {
64 case TC_SUBTYPE_RESET:
64 case TC_SUBTYPE_RESET:
65 result = action_reset( &TC, queue_snd_id );
65 result = action_reset( &TC, queue_snd_id );
66 close_action( &TC, result, queue_snd_id );
66 close_action( &TC, result, queue_snd_id );
67 break;
67 break;
68 //
68 //
69 case TC_SUBTYPE_LOAD_COMM:
69 case TC_SUBTYPE_LOAD_COMM:
70 result = action_load_common_par( &TC );
70 result = action_load_common_par( &TC );
71 close_action( &TC, result, queue_snd_id );
71 close_action( &TC, result, queue_snd_id );
72 break;
72 break;
73 //
73 //
74 case TC_SUBTYPE_LOAD_NORM:
74 case TC_SUBTYPE_LOAD_NORM:
75 result = action_load_normal_par( &TC, queue_snd_id );
75 result = action_load_normal_par( &TC, queue_snd_id );
76 close_action( &TC, result, queue_snd_id );
76 close_action( &TC, result, queue_snd_id );
77 break;
77 break;
78 //
78 //
79 case TC_SUBTYPE_LOAD_BURST:
79 case TC_SUBTYPE_LOAD_BURST:
80 result = action_load_burst_par( &TC, queue_snd_id );
80 result = action_load_burst_par( &TC, queue_snd_id );
81 close_action( &TC, result, queue_snd_id );
81 close_action( &TC, result, queue_snd_id );
82 break;
82 break;
83 //
83 //
84 case TC_SUBTYPE_LOAD_SBM1:
84 case TC_SUBTYPE_LOAD_SBM1:
85 result = action_load_sbm1_par( &TC, queue_snd_id );
85 result = action_load_sbm1_par( &TC, queue_snd_id );
86 close_action( &TC, result, queue_snd_id );
86 close_action( &TC, result, queue_snd_id );
87 break;
87 break;
88 //
88 //
89 case TC_SUBTYPE_LOAD_SBM2:
89 case TC_SUBTYPE_LOAD_SBM2:
90 result = action_load_sbm2_par( &TC, queue_snd_id );
90 result = action_load_sbm2_par( &TC, queue_snd_id );
91 close_action( &TC, result, queue_snd_id );
91 close_action( &TC, result, queue_snd_id );
92 break;
92 break;
93 //
93 //
94 case TC_SUBTYPE_DUMP:
94 case TC_SUBTYPE_DUMP:
95 result = action_dump_par( queue_snd_id );
95 result = action_dump_par( queue_snd_id );
96 close_action( &TC, result, queue_snd_id );
96 close_action( &TC, result, queue_snd_id );
97 break;
97 break;
98 //
98 //
99 case TC_SUBTYPE_ENTER:
99 case TC_SUBTYPE_ENTER:
100 result = action_enter_mode( &TC, queue_snd_id );
100 result = action_enter_mode( &TC, queue_snd_id );
101 close_action( &TC, result, queue_snd_id );
101 close_action( &TC, result, queue_snd_id );
102 break;
102 break;
103 //
103 //
104 case TC_SUBTYPE_UPDT_INFO:
104 case TC_SUBTYPE_UPDT_INFO:
105 result = action_update_info( &TC, queue_snd_id );
105 result = action_update_info( &TC, queue_snd_id );
106 close_action( &TC, result, queue_snd_id );
106 close_action( &TC, result, queue_snd_id );
107 break;
107 break;
108 //
108 //
109 case TC_SUBTYPE_EN_CAL:
109 case TC_SUBTYPE_EN_CAL:
110 result = action_enable_calibration( &TC, queue_snd_id );
110 result = action_enable_calibration( &TC, queue_snd_id );
111 close_action( &TC, result, queue_snd_id );
111 close_action( &TC, result, queue_snd_id );
112 break;
112 break;
113 //
113 //
114 case TC_SUBTYPE_DIS_CAL:
114 case TC_SUBTYPE_DIS_CAL:
115 result = action_disable_calibration( &TC, queue_snd_id );
115 result = action_disable_calibration( &TC, queue_snd_id );
116 close_action( &TC, result, queue_snd_id );
116 close_action( &TC, result, queue_snd_id );
117 break;
117 break;
118 //
118 //
119 case TC_SUBTYPE_UPDT_TIME:
119 case TC_SUBTYPE_UPDT_TIME:
120 result = action_update_time( &TC );
120 result = action_update_time( &TC );
121 close_action( &TC, result, queue_snd_id );
121 close_action( &TC, result, queue_snd_id );
122 break;
122 break;
123 //
123 //
124 default:
124 default:
125 break;
125 break;
126 }
126 }
127 }
127 }
128 }
128 }
129 }
129 }
130
130
131 //***********
131 //***********
132 // TC ACTIONS
132 // TC ACTIONS
133
133
134 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
134 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
135 {
135 {
136 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
136 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
137 *
137 *
138 * @param TC points to the TeleCommand packet that is being processed
138 * @param TC points to the TeleCommand packet that is being processed
139 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
139 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
140 *
140 *
141 */
141 */
142
142
143 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
143 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
144 return LFR_DEFAULT;
144 return LFR_DEFAULT;
145 }
145 }
146
146
147 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
147 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
148 {
148 {
149 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
149 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
150 *
150 *
151 * @param TC points to the TeleCommand packet that is being processed
151 * @param TC points to the TeleCommand packet that is being processed
152 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
152 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
153 *
153 *
154 */
154 */
155
155
156 rtems_status_code status;
156 rtems_status_code status;
157 unsigned char requestedMode;
157 unsigned char requestedMode;
158
158
159 requestedMode = TC->dataAndCRC[1];
159 requestedMode = TC->dataAndCRC[1];
160
160
161 if ( (requestedMode != LFR_MODE_STANDBY)
161 if ( (requestedMode != LFR_MODE_STANDBY)
162 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
162 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
163 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
163 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
164 {
164 {
165 status = RTEMS_UNSATISFIED;
165 status = RTEMS_UNSATISFIED;
166 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode );
166 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_LFR_MODE, requestedMode );
167 }
167 }
168 else
168 else
169 {
169 {
170 printf("try to enter mode %d\n", requestedMode);
170 printf("try to enter mode %d\n", requestedMode);
171
171
172 #ifdef PRINT_TASK_STATISTICS
172 #ifdef PRINT_TASK_STATISTICS
173 if (requestedMode != LFR_MODE_STANDBY)
173 if (requestedMode != LFR_MODE_STANDBY)
174 {
174 {
175 rtems_cpu_usage_reset();
175 rtems_cpu_usage_reset();
176 maxCount = 0;
176 maxCount = 0;
177 }
177 }
178 #endif
178 #endif
179
179
180 status = transition_validation(requestedMode);
180 status = transition_validation(requestedMode);
181
181
182 if ( status == LFR_SUCCESSFUL ) {
182 if ( status == LFR_SUCCESSFUL ) {
183 if ( lfrCurrentMode != LFR_MODE_STANDBY)
183 if ( lfrCurrentMode != LFR_MODE_STANDBY)
184 {
184 {
185 status = stop_current_mode();
185 status = stop_current_mode();
186 }
186 }
187 if (status != RTEMS_SUCCESSFUL)
187 if (status != RTEMS_SUCCESSFUL)
188 {
188 {
189 PRINTF("ERR *** in action_enter *** stop_current_mode\n")
189 PRINTF("ERR *** in action_enter *** stop_current_mode\n")
190 }
190 }
191 status = enter_mode(requestedMode, TC);
191 status = enter_mode(requestedMode, TC);
192 }
192 }
193 else
193 else
194 {
194 {
195 PRINTF("ERR *** in action_enter *** transition rejected\n")
195 PRINTF("ERR *** in action_enter *** transition rejected\n")
196 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
196 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
197 }
197 }
198 }
198 }
199
199
200 return status;
200 return status;
201 }
201 }
202
202
203 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
203 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
204 {
204 {
205 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
205 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
206 *
206 *
207 * @param TC points to the TeleCommand packet that is being processed
207 * @param TC points to the TeleCommand packet that is being processed
208 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
208 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
209 *
209 *
210 * @return LFR directive status code:
210 * @return LFR directive status code:
211 * - LFR_DEFAULT
211 * - LFR_DEFAULT
212 * - LFR_SUCCESSFUL
212 * - LFR_SUCCESSFUL
213 *
213 *
214 */
214 */
215
215
216 unsigned int val;
216 unsigned int val;
217 int result;
217 int result;
218
218
219 result = LFR_DEFAULT;
219 result = LFR_DEFAULT;
220
220
221 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
221 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
222 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
222 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
223 val++;
223 val++;
224 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
224 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
225 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
225 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
226
226
227 return result;
227 return result;
228 }
228 }
229
229
230 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
230 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
231 {
231 {
232 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
232 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
233 *
233 *
234 * @param TC points to the TeleCommand packet that is being processed
234 * @param TC points to the TeleCommand packet that is being processed
235 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
235 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
236 *
236 *
237 */
237 */
238
238
239 int result;
239 int result;
240 unsigned char lfrMode;
240 unsigned char lfrMode;
241
241
242 result = LFR_DEFAULT;
242 result = LFR_DEFAULT;
243 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
243 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
244
244
245 if ( (lfrMode == LFR_MODE_STANDBY) || (lfrMode == LFR_MODE_BURST) || (lfrMode == LFR_MODE_SBM2) ) {
245 if ( (lfrMode == LFR_MODE_STANDBY) || (lfrMode == LFR_MODE_BURST) || (lfrMode == LFR_MODE_SBM2) ) {
246 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
246 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
247 result = LFR_DEFAULT;
247 result = LFR_DEFAULT;
248 }
248 }
249 else {
249 else {
250 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
250 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
251 result = LFR_DEFAULT;
251 result = LFR_DEFAULT;
252 }
252 }
253 return result;
253 return result;
254 }
254 }
255
255
256 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
256 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
257 {
257 {
258 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
258 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
259 *
259 *
260 * @param TC points to the TeleCommand packet that is being processed
260 * @param TC points to the TeleCommand packet that is being processed
261 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
261 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
262 *
262 *
263 */
263 */
264
264
265 int result;
265 int result;
266 unsigned char lfrMode;
266 unsigned char lfrMode;
267
267
268 result = LFR_DEFAULT;
268 result = LFR_DEFAULT;
269 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
269 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
270
270
271 if ( (lfrMode == LFR_MODE_STANDBY) || (lfrMode == LFR_MODE_BURST) || (lfrMode == LFR_MODE_SBM2) ) {
271 if ( (lfrMode == LFR_MODE_STANDBY) || (lfrMode == LFR_MODE_BURST) || (lfrMode == LFR_MODE_SBM2) ) {
272 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
272 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
273 result = LFR_DEFAULT;
273 result = LFR_DEFAULT;
274 }
274 }
275 else {
275 else {
276 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
276 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
277 result = LFR_DEFAULT;
277 result = LFR_DEFAULT;
278 }
278 }
279 return result;
279 return result;
280 }
280 }
281
281
282 int action_update_time(ccsdsTelecommandPacket_t *TC)
282 int action_update_time(ccsdsTelecommandPacket_t *TC)
283 {
283 {
284 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
284 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
285 *
285 *
286 * @param TC points to the TeleCommand packet that is being processed
286 * @param TC points to the TeleCommand packet that is being processed
287 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
287 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
288 *
288 *
289 * @return LFR_SUCCESSFUL
289 * @return LFR_SUCCESSFUL
290 *
290 *
291 */
291 */
292
292
293 unsigned int val;
293 unsigned int val;
294
294
295 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
295 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
296 + (TC->dataAndCRC[1] << 16)
296 + (TC->dataAndCRC[1] << 16)
297 + (TC->dataAndCRC[2] << 8)
297 + (TC->dataAndCRC[2] << 8)
298 + TC->dataAndCRC[3];
298 + TC->dataAndCRC[3];
299 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
299 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
300 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
300 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
301 val++;
301 val++;
302 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
302 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
303 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
303 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
304 time_management_regs->ctrl = time_management_regs->ctrl | 1;
304 time_management_regs->ctrl = time_management_regs->ctrl | 1;
305
305
306 return LFR_SUCCESSFUL;
306 return LFR_SUCCESSFUL;
307 }
307 }
308
308
309 //*******************
309 //*******************
310 // ENTERING THE MODES
310 // ENTERING THE MODES
311
311
312 int transition_validation(unsigned char requestedMode)
312 int transition_validation(unsigned char requestedMode)
313 {
313 {
314 int status;
314 int status;
315
315
316 switch (requestedMode)
316 switch (requestedMode)
317 {
317 {
318 case LFR_MODE_STANDBY:
318 case LFR_MODE_STANDBY:
319 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
319 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
320 status = LFR_DEFAULT;
320 status = LFR_DEFAULT;
321 }
321 }
322 else
322 else
323 {
323 {
324 status = LFR_SUCCESSFUL;
324 status = LFR_SUCCESSFUL;
325 }
325 }
326 break;
326 break;
327 case LFR_MODE_NORMAL:
327 case LFR_MODE_NORMAL:
328 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
328 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
329 status = LFR_DEFAULT;
329 status = LFR_DEFAULT;
330 }
330 }
331 else {
331 else {
332 status = LFR_SUCCESSFUL;
332 status = LFR_SUCCESSFUL;
333 }
333 }
334 break;
334 break;
335 case LFR_MODE_BURST:
335 case LFR_MODE_BURST:
336 if ( lfrCurrentMode == LFR_MODE_BURST ) {
336 if ( lfrCurrentMode == LFR_MODE_BURST ) {
337 status = LFR_DEFAULT;
337 status = LFR_DEFAULT;
338 }
338 }
339 else {
339 else {
340 status = LFR_SUCCESSFUL;
340 status = LFR_SUCCESSFUL;
341 }
341 }
342 break;
342 break;
343 case LFR_MODE_SBM1:
343 case LFR_MODE_SBM1:
344 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
344 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
345 status = LFR_DEFAULT;
345 status = LFR_DEFAULT;
346 }
346 }
347 else {
347 else {
348 status = LFR_SUCCESSFUL;
348 status = LFR_SUCCESSFUL;
349 }
349 }
350 break;
350 break;
351 case LFR_MODE_SBM2:
351 case LFR_MODE_SBM2:
352 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
352 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
353 status = LFR_DEFAULT;
353 status = LFR_DEFAULT;
354 }
354 }
355 else {
355 else {
356 status = LFR_SUCCESSFUL;
356 status = LFR_SUCCESSFUL;
357 }
357 }
358 break;
358 break;
359 default:
359 default:
360 status = LFR_DEFAULT;
360 status = LFR_DEFAULT;
361 break;
361 break;
362 }
362 }
363
363
364 return status;
364 return status;
365 }
365 }
366
366
367 int stop_current_mode()
367 int stop_current_mode()
368 {
368 {
369 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
369 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
370 *
370 *
371 * @return RTEMS directive status codes:
371 * @return RTEMS directive status codes:
372 * - RTEMS_SUCCESSFUL - task restarted successfully
372 * - RTEMS_SUCCESSFUL - task restarted successfully
373 * - RTEMS_INVALID_ID - task id invalid
373 * - RTEMS_INVALID_ID - task id invalid
374 * - RTEMS_ALREADY_SUSPENDED - task already suspended
374 * - RTEMS_ALREADY_SUSPENDED - task already suspended
375 *
375 *
376 */
376 */
377
377
378 rtems_status_code status;
378 rtems_status_code status;
379
379
380 status = RTEMS_SUCCESSFUL;
380 status = RTEMS_SUCCESSFUL;
381
381
382 #ifdef GSA
382 #ifdef GSA
383 LEON_Mask_interrupt( IRQ_WF ); // mask waveform interrupt (coming from the timer VHDL IP)
383 LEON_Mask_interrupt( IRQ_WF ); // mask waveform interrupt (coming from the timer VHDL IP)
384 LEON_Clear_interrupt( IRQ_WF ); // clear waveform interrupt (coming from the timer VHDL IP)
384 LEON_Clear_interrupt( IRQ_WF ); // clear waveform interrupt (coming from the timer VHDL IP)
385 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR );
385 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR );
386 #else
386 #else
387 // mask interruptions
387 // mask interruptions
388 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
388 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
389 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt
389 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt
390 // reset registers
390 // reset registers
391 reset_wfp_burst_enable(); // reset burst and enable bits
391 reset_wfp_run_burst_enable(); // reset run, burst and enable bits, [r b2 b1 b0 e3 e2 e1 e0]
392 reset_wfp_status(); // reset all the status bits
392 reset_wfp_status(); // reset all the status bits
393 // creal interruptions
393 // creal interruptions
394 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
394 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
395 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectarl matrix interrupt
395 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectarl matrix interrupt
396 #endif
396 #endif
397 //**********************
397 //**********************
398 // suspend several tasks
398 // suspend several tasks
399 if (lfrCurrentMode != LFR_MODE_STANDBY) {
399 if (lfrCurrentMode != LFR_MODE_STANDBY) {
400 status = suspend_science_tasks();
400 status = suspend_science_tasks();
401 }
401 }
402
402
403 if (status != RTEMS_SUCCESSFUL)
403 if (status != RTEMS_SUCCESSFUL)
404 {
404 {
405 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
405 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
406 }
406 }
407
407
408 return status;
408 return status;
409 }
409 }
410
410
411 int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC )
411 int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC )
412 {
412 {
413 rtems_status_code status;
413 rtems_status_code status;
414
414
415 status = RTEMS_UNSATISFIED;
415 status = RTEMS_UNSATISFIED;
416
416
417 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d);
417 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d);
418 updateLFRCurrentMode();
418 updateLFRCurrentMode();
419
419
420 switch(mode){
420 switch(mode){
421 case LFR_MODE_STANDBY:
421 case LFR_MODE_STANDBY:
422 status = enter_standby_mode( );
422 status = enter_standby_mode( );
423 break;
423 break;
424 case LFR_MODE_NORMAL:
424 case LFR_MODE_NORMAL:
425 status = enter_normal_mode( );
425 status = enter_normal_mode( );
426 break;
426 break;
427 case LFR_MODE_BURST:
427 case LFR_MODE_BURST:
428 status = enter_burst_mode( );
428 status = enter_burst_mode( );
429 break;
429 break;
430 case LFR_MODE_SBM1:
430 case LFR_MODE_SBM1:
431 status = enter_sbm1_mode( );
431 status = enter_sbm1_mode( );
432 break;
432 break;
433 case LFR_MODE_SBM2:
433 case LFR_MODE_SBM2:
434 status = enter_sbm2_mode( );
434 status = enter_sbm2_mode( );
435 break;
435 break;
436 default:
436 default:
437 status = RTEMS_UNSATISFIED;
437 status = RTEMS_UNSATISFIED;
438 }
438 }
439
439
440 if (status != RTEMS_SUCCESSFUL)
440 if (status != RTEMS_SUCCESSFUL)
441 {
441 {
442 PRINTF("in enter_mode *** ERR\n")
442 PRINTF("in enter_mode *** ERR\n")
443 status = RTEMS_UNSATISFIED;
443 status = RTEMS_UNSATISFIED;
444 }
444 }
445
445
446 return status;
446 return status;
447 }
447 }
448
448
449 int enter_standby_mode()
449 int enter_standby_mode()
450 {
450 {
451 PRINTF1("maxCount = %d\n", maxCount)
451 PRINTF1("maxCount = %d\n", maxCount)
452
452
453 #ifdef PRINT_TASK_STATISTICS
453 #ifdef PRINT_TASK_STATISTICS
454 rtems_cpu_usage_report();
454 rtems_cpu_usage_report();
455 #endif
455 #endif
456
456
457 #ifdef PRINT_STACK_REPORT
457 #ifdef PRINT_STACK_REPORT
458 rtems_stack_checker_report_usage();
458 rtems_stack_checker_report_usage();
459 #endif
459 #endif
460
460
461 return LFR_SUCCESSFUL;
461 return LFR_SUCCESSFUL;
462 }
462 }
463
463
464 int enter_normal_mode()
464 int enter_normal_mode()
465 {
465 {
466 rtems_status_code status;
466 rtems_status_code status;
467 int startDate;
467
468
468 status = restart_science_tasks();
469 status = restart_science_tasks();
469
470
470 #ifdef GSA
471 #ifdef GSA
471 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR );
472 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR );
472 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
473 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
473 LEON_Clear_interrupt( IRQ_WF );
474 LEON_Clear_interrupt( IRQ_WF );
474 LEON_Unmask_interrupt( IRQ_WF );
475 LEON_Unmask_interrupt( IRQ_WF );
475 //
476 //
476 set_local_nb_interrupt_f0_MAX();
477 set_local_nb_interrupt_f0_MAX();
477 LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
478 LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
478 LEON_Unmask_interrupt( IRQ_SM );
479 LEON_Unmask_interrupt( IRQ_SM );
479 #else
480 #else
480 //****************
481 //****************
481 // waveform picker
482 // waveform picker
482 reset_waveform_picker_regs();
483 reset_new_waveform_picker_regs();
483 set_wfp_burst_enable_register(LFR_MODE_NORMAL);
484 set_wfp_burst_enable_register(LFR_MODE_NORMAL);
484 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
485 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
485 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
486 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
487 startDate = time_management_regs->coarse_time + 2;
488 new_waveform_picker_regs->start_date = startDate;
489 new_waveform_picker_regs->run_burst_enable = new_waveform_picker_regs->run_burst_enable | 0x80; // [1000 0000]
486 //****************
490 //****************
487 // spectral matrix
491 // spectral matrix
488 #endif
492 #endif
489
493
490 return status;
494 return status;
491 }
495 }
492
496
493 int enter_burst_mode()
497 int enter_burst_mode()
494 {
498 {
495 rtems_status_code status;
499 rtems_status_code status;
496
500
497 status = restart_science_tasks();
501 status = restart_science_tasks();
498
502
499 #ifdef GSA
503 #ifdef GSA
500 LEON_Unmask_interrupt( IRQ_SM );
504 LEON_Unmask_interrupt( IRQ_SM );
501 #else
505 #else
502 reset_waveform_picker_regs();
506 reset_new_waveform_picker_regs();
503 set_wfp_burst_enable_register(LFR_MODE_BURST);
507 set_wfp_burst_enable_register(LFR_MODE_BURST);
504 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
508 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
505 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
509 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
506 #endif
510 #endif
507
511
508 return status;
512 return status;
509 }
513 }
510
514
511 int enter_sbm1_mode()
515 int enter_sbm1_mode()
512 {
516 {
513 rtems_status_code status;
517 rtems_status_code status;
514
518
515 status = restart_science_tasks();
519 status = restart_science_tasks();
516
520
517 set_local_sbm1_nb_cwf_max();
521 set_local_sbm1_nb_cwf_max();
518
522
519 reset_local_sbm1_nb_cwf_sent();
523 reset_local_sbm1_nb_cwf_sent();
520
524
521 #ifdef GSA
525 #ifdef GSA
522 LEON_Unmask_interrupt( IRQ_SM );
526 LEON_Unmask_interrupt( IRQ_SM );
523 #else
527 #else
524 reset_waveform_picker_regs();
528 reset_new_waveform_picker_regs();
525 set_wfp_burst_enable_register(LFR_MODE_SBM1);
529 set_wfp_burst_enable_register(LFR_MODE_SBM1);
526 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
530 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
527 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
531 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
528 // SM simulation
532 // SM simulation
529 // timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
533 // timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
530 // LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
534 // LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
531 // LEON_Unmask_interrupt( IRQ_SM );
535 // LEON_Unmask_interrupt( IRQ_SM );
532 #endif
536 #endif
533
537
534 return status;
538 return status;
535 }
539 }
536
540
537 int enter_sbm2_mode()
541 int enter_sbm2_mode()
538 {
542 {
539 rtems_status_code status;
543 rtems_status_code status;
540
544
541 status = restart_science_tasks();
545 status = restart_science_tasks();
542
546
543 set_local_sbm2_nb_cwf_max();
547 set_local_sbm2_nb_cwf_max();
544
548
545 reset_local_sbm2_nb_cwf_sent();
549 reset_local_sbm2_nb_cwf_sent();
546
550
547 #ifdef GSA
551 #ifdef GSA
548 LEON_Unmask_interrupt( IRQ_SM );
552 LEON_Unmask_interrupt( IRQ_SM );
549 #else
553 #else
550 reset_waveform_picker_regs();
554 reset_new_waveform_picker_regs();
551 set_wfp_burst_enable_register(LFR_MODE_SBM2);
555 set_wfp_burst_enable_register(LFR_MODE_SBM2);
552 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
556 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
553 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
557 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
554 #endif
558 #endif
555
559
556 return status;
560 return status;
557 }
561 }
558
562
559 int restart_science_tasks()
563 int restart_science_tasks()
560 {
564 {
561 rtems_status_code status[6];
565 rtems_status_code status[6];
562 rtems_status_code ret;
566 rtems_status_code ret;
563
567
564 ret = RTEMS_SUCCESSFUL;
568 ret = RTEMS_SUCCESSFUL;
565
569
566 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 );
570 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 );
567 if (status[0] != RTEMS_SUCCESSFUL)
571 if (status[0] != RTEMS_SUCCESSFUL)
568 {
572 {
569 PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0])
573 PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0])
570 }
574 }
571
575
572 status[1] = rtems_task_restart( Task_id[TASKID_BPF0],1 );
576 status[1] = rtems_task_restart( Task_id[TASKID_BPF0],1 );
573 if (status[1] != RTEMS_SUCCESSFUL)
577 if (status[1] != RTEMS_SUCCESSFUL)
574 {
578 {
575 PRINTF1("in restart_science_task *** 1 ERR %d\n", status[1])
579 PRINTF1("in restart_science_task *** 1 ERR %d\n", status[1])
576 }
580 }
577
581
578 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
582 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
579 if (status[2] != RTEMS_SUCCESSFUL)
583 if (status[2] != RTEMS_SUCCESSFUL)
580 {
584 {
581 PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2])
585 PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2])
582 }
586 }
583
587
584 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
588 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
585 if (status[3] != RTEMS_SUCCESSFUL)
589 if (status[3] != RTEMS_SUCCESSFUL)
586 {
590 {
587 PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3])
591 PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3])
588 }
592 }
589
593
590 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
594 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
591 if (status[4] != RTEMS_SUCCESSFUL)
595 if (status[4] != RTEMS_SUCCESSFUL)
592 {
596 {
593 PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4])
597 PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4])
594 }
598 }
595
599
596 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
600 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
597 if (status[5] != RTEMS_SUCCESSFUL)
601 if (status[5] != RTEMS_SUCCESSFUL)
598 {
602 {
599 PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5])
603 PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5])
600 }
604 }
601
605
602 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
606 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
603 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
607 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
604 {
608 {
605 ret = RTEMS_UNSATISFIED;
609 ret = RTEMS_UNSATISFIED;
606 }
610 }
607
611
608 return ret;
612 return ret;
609 }
613 }
610
614
611 int suspend_science_tasks()
615 int suspend_science_tasks()
612 {
616 {
613 /** This function suspends the science tasks.
617 /** This function suspends the science tasks.
614 *
618 *
615 * @return RTEMS directive status codes:
619 * @return RTEMS directive status codes:
616 * - RTEMS_SUCCESSFUL - task restarted successfully
620 * - RTEMS_SUCCESSFUL - task restarted successfully
617 * - RTEMS_INVALID_ID - task id invalid
621 * - RTEMS_INVALID_ID - task id invalid
618 * - RTEMS_ALREADY_SUSPENDED - task already suspended
622 * - RTEMS_ALREADY_SUSPENDED - task already suspended
619 *
623 *
620 */
624 */
621
625
622 rtems_status_code status;
626 rtems_status_code status;
623
627
624 status = rtems_task_suspend( Task_id[TASKID_AVF0] );
628 status = rtems_task_suspend( Task_id[TASKID_AVF0] );
625 if (status != RTEMS_SUCCESSFUL)
629 if (status != RTEMS_SUCCESSFUL)
626 {
630 {
627 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
631 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
628 }
632 }
629
633
630 if (status == RTEMS_SUCCESSFUL) // suspend BPF0
634 if (status == RTEMS_SUCCESSFUL) // suspend BPF0
631 {
635 {
632 status = rtems_task_suspend( Task_id[TASKID_BPF0] );
636 status = rtems_task_suspend( Task_id[TASKID_BPF0] );
633 if (status != RTEMS_SUCCESSFUL)
637 if (status != RTEMS_SUCCESSFUL)
634 {
638 {
635 PRINTF1("in suspend_science_task *** BPF0 ERR %d\n", status)
639 PRINTF1("in suspend_science_task *** BPF0 ERR %d\n", status)
636 }
640 }
637 }
641 }
638
642
639 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
643 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
640 {
644 {
641 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
645 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
642 if (status != RTEMS_SUCCESSFUL)
646 if (status != RTEMS_SUCCESSFUL)
643 {
647 {
644 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
648 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
645 }
649 }
646 }
650 }
647
651
648 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
652 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
649 {
653 {
650 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
654 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
651 if (status != RTEMS_SUCCESSFUL)
655 if (status != RTEMS_SUCCESSFUL)
652 {
656 {
653 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
657 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
654 }
658 }
655 }
659 }
656
660
657 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
661 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
658 {
662 {
659 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
663 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
660 if (status != RTEMS_SUCCESSFUL)
664 if (status != RTEMS_SUCCESSFUL)
661 {
665 {
662 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
666 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
663 }
667 }
664 }
668 }
665
669
666 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
670 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
667 {
671 {
668 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
672 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
669 if (status != RTEMS_SUCCESSFUL)
673 if (status != RTEMS_SUCCESSFUL)
670 {
674 {
671 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
675 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
672 }
676 }
673 }
677 }
674
678
675 return status;
679 return status;
676 }
680 }
677
681
678 //****************
682 //****************
679 // CLOSING ACTIONS
683 // CLOSING ACTIONS
680 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC)
684 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC)
681 {
685 {
682 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
686 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
683 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
687 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
684 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
688 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
685 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
689 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
686 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
690 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
687 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
691 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
688 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
692 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
689 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
693 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
690 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
694 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
691 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
695 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
692 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
696 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
693 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
697 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
694 }
698 }
695
699
696 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC)
700 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC)
697 {
701 {
698 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
702 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
699 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
703 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
700 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
704 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
701 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
705 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
702 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
706 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
703 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
707 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
704 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
708 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
705 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
709 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
706 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
710 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
707 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
711 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
708 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
712 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
709 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
713 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
710 }
714 }
711
715
712 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id)
716 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id)
713 {
717 {
714 unsigned int val = 0;
718 unsigned int val = 0;
715 if (result == LFR_SUCCESSFUL)
719 if (result == LFR_SUCCESSFUL)
716 {
720 {
717 if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
721 if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
718 &&
722 &&
719 !( (TC->serviceType==TC_TYPE_GEN) && (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
723 !( (TC->serviceType==TC_TYPE_GEN) && (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
720 )
724 )
721 {
725 {
722 send_tm_lfr_tc_exe_success( TC, queue_id );
726 send_tm_lfr_tc_exe_success( TC, queue_id );
723 }
727 }
724 update_last_TC_exe( TC );
728 update_last_TC_exe( TC );
725 val = housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1];
729 val = housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1];
726 val++;
730 val++;
727 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
731 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
728 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1] = (unsigned char) (val);
732 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1] = (unsigned char) (val);
729 }
733 }
730 else
734 else
731 {
735 {
732 update_last_TC_rej( TC );
736 update_last_TC_rej( TC );
733 val = housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1];
737 val = housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1];
734 val++;
738 val++;
735 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
739 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
736 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1] = (unsigned char) (val);
740 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1] = (unsigned char) (val);
737 }
741 }
738 }
742 }
739
743
740 //***************************
744 //***************************
741 // Interrupt Service Routines
745 // Interrupt Service Routines
742 rtems_isr commutation_isr1( rtems_vector_number vector )
746 rtems_isr commutation_isr1( rtems_vector_number vector )
743 {
747 {
744 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
748 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
745 printf("In commutation_isr1 *** Error sending event to DUMB\n");
749 printf("In commutation_isr1 *** Error sending event to DUMB\n");
746 }
750 }
747 }
751 }
748
752
749 rtems_isr commutation_isr2( rtems_vector_number vector )
753 rtems_isr commutation_isr2( rtems_vector_number vector )
750 {
754 {
751 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
755 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
752 printf("In commutation_isr2 *** Error sending event to DUMB\n");
756 printf("In commutation_isr2 *** Error sending event to DUMB\n");
753 }
757 }
754 }
758 }
755
759
756 //****************
760 //****************
757 // OTHER FUNCTIONS
761 // OTHER FUNCTIONS
758 void updateLFRCurrentMode()
762 void updateLFRCurrentMode()
759 {
763 {
760 /** This function updates the value of the global variable lfrCurrentMode.
764 /** This function updates the value of the global variable lfrCurrentMode.
761 *
765 *
762 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
766 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
763 *
767 *
764 */
768 */
765 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
769 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
766 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
770 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
767 }
771 }
768
772
@@ -1,1219 +1,1177
1 /** Functions and tasks related to waveform packet generation.
1 /** Functions and tasks related to waveform packet generation.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
6 * A group of functions to handle waveforms, in snapshot or continuous format.\n
7 *
7 *
8 */
8 */
9
9
10 #include "wf_handler.h"
10 #include "wf_handler.h"
11
11
12 // SWF
12 // SWF
13 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
13 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
14 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
14 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
15 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
16 // CWF
16 // CWF
17 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[7];
17 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[7];
18 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[7];
18 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[7];
19 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[7];
19 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[7];
20 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[7];
20 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[7];
21 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[7];
21 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3_light[7];
22
22
23 unsigned char doubleSendCWF1 = 0;
23 unsigned char doubleSendCWF1 = 0;
24 unsigned char doubleSendCWF2 = 0;
24 unsigned char doubleSendCWF2 = 0;
25
25
26 rtems_isr waveforms_isr( rtems_vector_number vector )
26 rtems_isr waveforms_isr( rtems_vector_number vector )
27 {
27 {
28 /** This is the interrupt sub routine called by the waveform picker core.
28 /** This is the interrupt sub routine called by the waveform picker core.
29 *
29 *
30 * This ISR launch different actions depending mainly on two pieces of information:
30 * This ISR launch different actions depending mainly on two pieces of information:
31 * 1. the values read in the registers of the waveform picker.
31 * 1. the values read in the registers of the waveform picker.
32 * 2. the current LFR mode.
32 * 2. the current LFR mode.
33 *
33 *
34 */
34 */
35
35
36 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
37 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffff00f; // clear new_err and full_err
38
36 #ifdef GSA
39 #ifdef GSA
37 #else
40 #else
38 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
41 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
39 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
42 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
40 { // in modes other than STANDBY and BURST, send the CWF_F3 data
43 { // in modes other than STANDBY and BURST, send the CWF_F3 data
41 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
44 if ((new_waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
42 // (1) change the receiving buffer for the waveform picker
45 // (1) change the receiving buffer for the waveform picker
43 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
46 if (new_waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
44 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_bis);
47 new_waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_bis);
45 }
48 }
46 else {
49 else {
47 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3);
50 new_waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3);
48 }
51 }
49 // (2) send an event for the waveforms transmission
52 // (2) send an event for the waveforms transmission
50 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
53 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
51 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
54 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
52 }
55 }
53 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
56 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
54 }
57 }
55 }
58 }
56 #endif
59 #endif
57
60
58 switch(lfrCurrentMode)
61 switch(lfrCurrentMode)
59 {
62 {
60 //********
63 //********
61 // STANDBY
64 // STANDBY
62 case(LFR_MODE_STANDBY):
65 case(LFR_MODE_STANDBY):
63 break;
66 break;
64
67
65 //******
68 //******
66 // NORMAL
69 // NORMAL
67 case(LFR_MODE_NORMAL):
70 case(LFR_MODE_NORMAL):
68 #ifdef GSA
71 #ifdef GSA
69 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
72 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
70 #else
73 #else
71 if ( (waveform_picker_regs->burst_enable & 0x7) == 0x0 ){ // if no channel is enable
74 if ( (new_waveform_picker_regs->run_burst_enable & 0x7) == 0x0 ){ // if no channel is enable
72 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
75 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
73 }
76 }
74 else {
77 else {
75 if ( (waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full
78 if ( (new_waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full
76 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable & 0x08;
79 new_waveform_picker_regs->run_burst_enable = new_waveform_picker_regs->run_burst_enable & 0x08;
77 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
80 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
78 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
81 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
79 }
82 }
80 // waveform_picker_regs->status = waveform_picker_regs->status & 0x00;
83 // new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0x00;
81 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff888;
84 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffff888;
82 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x07; // [0111] enable f2 f1 f0
85 new_waveform_picker_regs->run_burst_enable = new_waveform_picker_regs->run_burst_enable | 0x07; // [0111] enable f2 f1 f0
83 }
86 }
84 }
87 }
85 #endif
88 #endif
86 break;
89 break;
87
90
88 //******
91 //******
89 // BURST
92 // BURST
90 case(LFR_MODE_BURST):
93 case(LFR_MODE_BURST):
91 #ifdef GSA
94 #ifdef GSA
92 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
95 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
93 #else
96 #else
94 if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
97 if ((new_waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
95 // (1) change the receiving buffer for the waveform picker
98 // (1) change the receiving buffer for the waveform picker
96 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
99 if (new_waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
97 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
100 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
98 }
101 }
99 else {
102 else {
100 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
103 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
101 }
104 }
102 // (2) send an event for the waveforms transmission
105 // (2) send an event for the waveforms transmission
103 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
106 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
104 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
107 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
105 }
108 }
106 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
109 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
107 }
110 }
108 #endif
111 #endif
109 break;
112 break;
110
113
111 //*****
114 //*****
112 // SBM1
115 // SBM1
113 case(LFR_MODE_SBM1):
116 case(LFR_MODE_SBM1):
114 #ifdef GSA
117 #ifdef GSA
115 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
118 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
116 #else
119 #else
117 if ((waveform_picker_regs->status & 0x02) == 0x02){ // [0010] check the f1 full bit
120 if ((new_waveform_picker_regs->status & 0x02) == 0x02){ // [0010] check the f1 full bit
118 // (1) change the receiving buffer for the waveform picker
121 // (1) change the receiving buffer for the waveform picker
119 if ( param_local.local_sbm1_nb_cwf_sent == (param_local.local_sbm1_nb_cwf_max-1) )
122 if ( param_local.local_sbm1_nb_cwf_sent == (param_local.local_sbm1_nb_cwf_max-1) )
120 {
123 {
121 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_norm);
124 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_norm);
122 }
125 }
123 else if ( waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1_norm )
126 else if ( new_waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1_norm )
124 {
127 {
125 doubleSendCWF1 = 1;
128 doubleSendCWF1 = 1;
126 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
129 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
127 }
130 }
128 else if ( waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1 ) {
131 else if ( new_waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1 ) {
129 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_bis);
132 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_bis);
130 }
133 }
131 else {
134 else {
132 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
135 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
133 }
136 }
134 // (2) send an event for the waveforms transmission
137 // (2) send an event for the waveforms transmission
135 if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) {
138 if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) {
136 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
139 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
137 }
140 }
138 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0
141 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0
139 }
142 }
140 if ( ( (waveform_picker_regs->status & 0x05) == 0x05 ) ) { // [0101] check the f2 and f0 full bit
143 if ( ( (new_waveform_picker_regs->status & 0x05) == 0x05 ) ) { // [0101] check the f2 and f0 full bit
141 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
144 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
142 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
145 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
143 }
146 }
144 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0
147 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0
145 reset_local_sbm1_nb_cwf_sent();
148 reset_local_sbm1_nb_cwf_sent();
146 }
149 }
147
150
148 #endif
151 #endif
149 break;
152 break;
150
153
151 //*****
154 //*****
152 // SBM2
155 // SBM2
153 case(LFR_MODE_SBM2):
156 case(LFR_MODE_SBM2):
154 #ifdef GSA
157 #ifdef GSA
155 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
158 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
156 #else
159 #else
157 if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
160 if ((new_waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
158 // (1) change the receiving buffer for the waveform picker
161 // (1) change the receiving buffer for the waveform picker
159 if ( param_local.local_sbm2_nb_cwf_sent == (param_local.local_sbm2_nb_cwf_max-1) )
162 if ( param_local.local_sbm2_nb_cwf_sent == (param_local.local_sbm2_nb_cwf_max-1) )
160 {
163 {
161 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_norm);
164 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_norm);
162 }
165 }
163 else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2_norm ) {
166 else if ( new_waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2_norm ) {
164 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
167 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
165 doubleSendCWF2 = 1;
168 doubleSendCWF2 = 1;
166 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2_WFRM ) != RTEMS_SUCCESSFUL) {
169 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2_WFRM ) != RTEMS_SUCCESSFUL) {
167 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
170 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
168 }
171 }
169 reset_local_sbm2_nb_cwf_sent();
172 reset_local_sbm2_nb_cwf_sent();
170 }
173 }
171 else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2 ) {
174 else if ( new_waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2 ) {
172 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
175 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
173 }
176 }
174 else {
177 else {
175 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
178 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
176 }
179 }
177 // (2) send an event for the waveforms transmission
180 // (2) send an event for the waveforms transmission
178 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
181 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
179 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
182 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
180 }
183 }
181 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
184 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
182 }
185 }
183 if ( ( (waveform_picker_regs->status & 0x03) == 0x03 ) ) { // [0011] f3 f2 f1 f0, f1 and f0 are full
186 if ( ( (new_waveform_picker_regs->status & 0x03) == 0x03 ) ) { // [0011] f3 f2 f1 f0, f1 and f0 are full
184 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
187 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
185 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
188 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
186 }
189 }
187 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
190 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
188 }
191 }
189 #endif
192 #endif
190 break;
193 break;
191
194
192 //********
195 //********
193 // DEFAULT
196 // DEFAULT
194 default:
197 default:
195 break;
198 break;
196 }
199 }
197 }
200 }
198
201
199 rtems_isr waveforms_simulator_isr( rtems_vector_number vector )
202 rtems_isr waveforms_simulator_isr( rtems_vector_number vector )
200 {
203 {
201 /** This is the interrupt sub routine called by the waveform picker simulator.
204 /** This is the interrupt sub routine called by the waveform picker simulator.
202 *
205 *
203 * This ISR is for debug purpose only.
206 * This ISR is for debug purpose only.
204 *
207 *
205 */
208 */
206
209
207 unsigned char lfrMode;
210 unsigned char lfrMode;
208 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
211 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
209
212
210 switch(lfrMode) {
213 switch(lfrMode) {
211 case (LFR_MODE_STANDBY):
214 case (LFR_MODE_STANDBY):
212 break;
215 break;
213 case (LFR_MODE_NORMAL):
216 case (LFR_MODE_NORMAL):
214 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
217 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
215 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_5 );
218 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_5 );
216 }
219 }
217 break;
220 break;
218 case (LFR_MODE_BURST):
221 case (LFR_MODE_BURST):
219 break;
222 break;
220 case (LFR_MODE_SBM1):
223 case (LFR_MODE_SBM1):
221 break;
224 break;
222 case (LFR_MODE_SBM2):
225 case (LFR_MODE_SBM2):
223 break;
226 break;
224 }
227 }
225 }
228 }
226
229
227 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
230 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
228 {
231 {
229 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
232 /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode.
230 *
233 *
231 * @param unused is the starting argument of the RTEMS task
234 * @param unused is the starting argument of the RTEMS task
232 *
235 *
233 * The following data packets are sent by this task:
236 * The following data packets are sent by this task:
234 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
237 * - TM_LFR_SCIENCE_NORMAL_SWF_F0
235 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
238 * - TM_LFR_SCIENCE_NORMAL_SWF_F1
236 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
239 * - TM_LFR_SCIENCE_NORMAL_SWF_F2
237 *
240 *
238 */
241 */
239
242
240 rtems_event_set event_out;
243 rtems_event_set event_out;
241 rtems_id queue_id;
244 rtems_id queue_id;
242
245
243 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
246 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
244 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
247 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
245 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
248 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
246
249
247 init_waveforms();
250 init_waveforms();
248
251
249 queue_id = get_pkts_queue_id();
252 queue_id = get_pkts_queue_id();
250
253
251 BOOT_PRINTF("in WFRM ***\n")
254 BOOT_PRINTF("in WFRM ***\n")
252
255
253 while(1){
256 while(1){
254 // wait for an RTEMS_EVENT
257 // wait for an RTEMS_EVENT
255 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
258 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
256 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
259 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
257 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
260 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
258
261
259 if (event_out == RTEMS_EVENT_MODE_NORMAL)
262 if (event_out == RTEMS_EVENT_MODE_NORMAL)
260 {
263 {
261 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
264 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
262 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
265 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
263 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
266 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
264 #ifdef GSA
267 #ifdef GSA
265 waveform_picker_regs->status = waveform_picker_regs->status & 0xf888; // [1111 1000 1000 1000] f2, f1, f0 bits =0
268 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xf888; // [1111 1000 1000 1000] f2, f1, f0 bits =0
266 #endif
269 #endif
267 }
270 }
268 else if (event_out == RTEMS_EVENT_MODE_SBM1)
271 else if (event_out == RTEMS_EVENT_MODE_SBM1)
269 {
272 {
270 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
273 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
271 send_waveform_SWF(wf_snap_f1_norm, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
274 send_waveform_SWF(wf_snap_f1_norm, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
272 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
275 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
273 #ifdef GSA
276 #ifdef GSA
274 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2, f0 bits = 0
277 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2, f0 bits = 0
275 #endif
278 #endif
276 }
279 }
277 else if (event_out == RTEMS_EVENT_MODE_SBM2)
280 else if (event_out == RTEMS_EVENT_MODE_SBM2)
278 {
281 {
279 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
282 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
280 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
283 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
281 #ifdef GSA
284 #ifdef GSA
282 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
285 new_waveform_picker_regs->status = new_waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
283 #endif
286 #endif
284 }
287 }
285 else if (event_out == RTEMS_EVENT_MODE_SBM2_WFRM)
288 else if (event_out == RTEMS_EVENT_MODE_SBM2_WFRM)
286 {
289 {
287 send_waveform_SWF(wf_snap_f2_norm, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
290 send_waveform_SWF(wf_snap_f2_norm, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
288 }
291 }
289 else
292 else
290 {
293 {
291 PRINTF("in WFRM *** unexpected event")
294 PRINTF("in WFRM *** unexpected event")
292 }
295 }
293
296
294
297
295 #ifdef GSA
298 #ifdef GSA
296 // irq processed, reset the related register of the timer unit
299 // irq processed, reset the related register of the timer unit
297 gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl = gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl | 0x00000010;
300 gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl = gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl | 0x00000010;
298 // clear the interruption
301 // clear the interruption
299 LEON_Unmask_interrupt( IRQ_WF );
302 LEON_Unmask_interrupt( IRQ_WF );
300 #endif
303 #endif
301 }
304 }
302 }
305 }
303
306
304 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
307 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
305 {
308 {
306 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
309 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3.
307 *
310 *
308 * @param unused is the starting argument of the RTEMS task
311 * @param unused is the starting argument of the RTEMS task
309 *
312 *
310 * The following data packet is sent by this task:
313 * The following data packet is sent by this task:
311 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
314 * - TM_LFR_SCIENCE_NORMAL_CWF_F3
312 *
315 *
313 */
316 */
314
317
315 rtems_event_set event_out;
318 rtems_event_set event_out;
316 rtems_id queue_id;
319 rtems_id queue_id;
317
320
318 init_header_continuous_wf_table( SID_NORM_CWF_F3, headerCWF_F3 );
321 init_header_continuous_wf_table( SID_NORM_CWF_F3, headerCWF_F3 );
319 init_header_continuous_wf3_light_table( headerCWF_F3_light );
322 init_header_continuous_wf3_light_table( headerCWF_F3_light );
320
323
321 queue_id = get_pkts_queue_id();
324 queue_id = get_pkts_queue_id();
322
325
323 BOOT_PRINTF("in CWF3 ***\n")
326 BOOT_PRINTF("in CWF3 ***\n")
324
327
325 while(1){
328 while(1){
326 // wait for an RTEMS_EVENT
329 // wait for an RTEMS_EVENT
327 rtems_event_receive( RTEMS_EVENT_0,
330 rtems_event_receive( RTEMS_EVENT_0,
328 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
331 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
329 PRINTF("send CWF F3 \n")
332 PRINTF("send CWF F3 \n")
330 #ifdef GSA
333 #ifdef GSA
331 #else
334 #else
332 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
335 if (new_waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
333 send_waveform_CWF3_light( wf_cont_f3_bis, headerCWF_F3_light, queue_id );
336 send_waveform_CWF3_light( wf_cont_f3_bis, headerCWF_F3_light, queue_id );
334 }
337 }
335 else {
338 else {
336 send_waveform_CWF3_light( wf_cont_f3, headerCWF_F3_light, queue_id );
339 send_waveform_CWF3_light( wf_cont_f3, headerCWF_F3_light, queue_id );
337 }
340 }
338 #endif
341 #endif
339 }
342 }
340 }
343 }
341
344
342 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
345 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
343 {
346 {
344 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
347 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2.
345 *
348 *
346 * @param unused is the starting argument of the RTEMS task
349 * @param unused is the starting argument of the RTEMS task
347 *
350 *
348 * The following data packet is sent by this function:
351 * The following data packet is sent by this function:
349 * - TM_LFR_SCIENCE_BURST_CWF_F2
352 * - TM_LFR_SCIENCE_BURST_CWF_F2
350 * - TM_LFR_SCIENCE_SBM2_CWF_F2
353 * - TM_LFR_SCIENCE_SBM2_CWF_F2
351 *
354 *
352 */
355 */
353
356
354 rtems_event_set event_out;
357 rtems_event_set event_out;
355 rtems_id queue_id;
358 rtems_id queue_id;
356
359
357 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
360 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
358 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
361 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
359
362
360 queue_id = get_pkts_queue_id();
363 queue_id = get_pkts_queue_id();
361
364
362 BOOT_PRINTF("in CWF2 ***\n")
365 BOOT_PRINTF("in CWF2 ***\n")
363
366
364 while(1){
367 while(1){
365 // wait for an RTEMS_EVENT
368 // wait for an RTEMS_EVENT
366 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
369 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
367 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
370 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
368
371
369 if (event_out == RTEMS_EVENT_MODE_BURST)
372 if (event_out == RTEMS_EVENT_MODE_BURST)
370 {
373 {
371 // F2
374 // F2
372 #ifdef GSA
375 #ifdef GSA
373 #else
376 #else
374 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
377 if (new_waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
375 send_waveform_CWF( wf_snap_f2_bis, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
378 send_waveform_CWF( wf_snap_f2_bis, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
376 }
379 }
377 else {
380 else {
378 send_waveform_CWF( wf_snap_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
381 send_waveform_CWF( wf_snap_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
379 }
382 }
380 #endif
383 #endif
381 }
384 }
382
385
383 else if (event_out == RTEMS_EVENT_MODE_SBM2)
386 else if (event_out == RTEMS_EVENT_MODE_SBM2)
384 {
387 {
385 #ifdef GSA
388 #ifdef GSA
386 #else
389 #else
387 if (doubleSendCWF2 == 1)
390 if (doubleSendCWF2 == 1)
388 {
391 {
389 doubleSendCWF2 = 0;
392 doubleSendCWF2 = 0;
390 send_waveform_CWF( wf_snap_f2_norm, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
393 send_waveform_CWF( wf_snap_f2_norm, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
391 }
394 }
392 else if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
395 else if (new_waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
393 send_waveform_CWF( wf_snap_f2_bis, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
396 send_waveform_CWF( wf_snap_f2_bis, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
394 }
397 }
395 else {
398 else {
396 send_waveform_CWF( wf_snap_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
399 send_waveform_CWF( wf_snap_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
397 }
400 }
398 param_local.local_sbm2_nb_cwf_sent ++;
401 param_local.local_sbm2_nb_cwf_sent ++;
399 #endif
402 #endif
400 }
403 }
401 else
404 else
402 {
405 {
403 PRINTF1("in CWF2 *** ERR mode = %d\n", lfrCurrentMode)
406 PRINTF1("in CWF2 *** ERR mode = %d\n", lfrCurrentMode)
404 }
407 }
405 }
408 }
406 }
409 }
407
410
408 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
411 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
409 {
412 {
410 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
413 /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1.
411 *
414 *
412 * @param unused is the starting argument of the RTEMS task
415 * @param unused is the starting argument of the RTEMS task
413 *
416 *
414 * The following data packet is sent by this function:
417 * The following data packet is sent by this function:
415 * - TM_LFR_SCIENCE_SBM1_CWF_F1
418 * - TM_LFR_SCIENCE_SBM1_CWF_F1
416 *
419 *
417 */
420 */
418
421
419 rtems_event_set event_out;
422 rtems_event_set event_out;
420 rtems_id queue_id;
423 rtems_id queue_id;
421
424
422 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
425 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
423
426
424 queue_id = get_pkts_queue_id();
427 queue_id = get_pkts_queue_id();
425
428
426 BOOT_PRINTF("in CWF1 ***\n")
429 BOOT_PRINTF("in CWF1 ***\n")
427
430
428 while(1){
431 while(1){
429 // wait for an RTEMS_EVENT
432 // wait for an RTEMS_EVENT
430 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
433 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
431 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
434 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
432 if (event_out == RTEMS_EVENT_MODE_SBM1)
435 if (event_out == RTEMS_EVENT_MODE_SBM1)
433 {
436 {
434 #ifdef GSA
437 #ifdef GSA
435 #else
438 #else
436 if (doubleSendCWF1 == 1)
439 if (doubleSendCWF1 == 1)
437 {
440 {
438 doubleSendCWF1 = 0;
441 doubleSendCWF1 = 0;
439 send_waveform_CWF( wf_snap_f1_norm, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
442 send_waveform_CWF( wf_snap_f1_norm, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
440 }
443 }
441 else if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
444 else if (new_waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
442 send_waveform_CWF( wf_snap_f1_bis, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
445 send_waveform_CWF( wf_snap_f1_bis, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
443 }
446 }
444 else {
447 else {
445 send_waveform_CWF( wf_snap_f1, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
448 send_waveform_CWF( wf_snap_f1, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
446 }
449 }
447 param_local.local_sbm1_nb_cwf_sent ++;
450 param_local.local_sbm1_nb_cwf_sent ++;
448 #endif
451 #endif
449 }
452 }
450 else
453 else
451 {
454 {
452 PRINTF1("in CWF1 *** ERR mode = %d\n", lfrCurrentMode)
455 PRINTF1("in CWF1 *** ERR mode = %d\n", lfrCurrentMode)
453 }
456 }
454 }
457 }
455 }
458 }
456
459
457 //******************
460 //******************
458 // general functions
461 // general functions
459 void init_waveforms( void )
462 void init_waveforms( void )
460 {
463 {
461 int i = 0;
464 int i = 0;
462
465
463 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
466 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
464 {
467 {
465 //***
468 //***
466 // F0
469 // F0
467 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
470 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
468 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
471 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
469 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
472 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
470
473
471 //***
474 //***
472 // F1
475 // F1
473 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
476 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
474 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
477 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
475 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
478 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
476
479
477 //***
480 //***
478 // F2
481 // F2
479 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
482 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
480 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
483 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
481 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
484 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
482
485
483 //***
486 //***
484 // F3
487 // F3
485 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
488 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
486 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
489 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
487 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
490 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
488 }
491 }
489 }
492 }
490
493
491 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
494 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
492 {
495 {
493 unsigned char i;
496 unsigned char i;
494
497
495 for (i=0; i<7; i++)
498 for (i=0; i<7; i++)
496 {
499 {
497 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
500 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
498 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
501 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
499 headerSWF[ i ].reserved = DEFAULT_RESERVED;
502 headerSWF[ i ].reserved = DEFAULT_RESERVED;
500 headerSWF[ i ].userApplication = CCSDS_USER_APP;
503 headerSWF[ i ].userApplication = CCSDS_USER_APP;
501 headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
504 headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
502 headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
505 headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
503 if (i == 0)
506 if (i == 0)
504 {
507 {
505 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
508 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
506 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
509 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
507 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
510 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
508 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
511 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
509 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
512 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
510 }
513 }
511 else if (i == 6)
514 else if (i == 6)
512 {
515 {
513 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
516 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
514 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_8 >> 8);
517 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_8 >> 8);
515 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_8 );
518 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_8 );
516 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
519 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
517 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
520 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
518 }
521 }
519 else
522 else
520 {
523 {
521 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
524 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
522 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
525 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
523 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
526 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
524 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
527 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
525 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
528 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
526 }
529 }
527 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
530 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
528 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
531 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
529 headerSWF[ i ].pktNr = i+1; // PKT_NR
532 headerSWF[ i ].pktNr = i+1; // PKT_NR
530 // DATA FIELD HEADER
533 // DATA FIELD HEADER
531 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
534 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
532 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
535 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
533 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
536 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
534 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
537 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
535 // AUXILIARY DATA HEADER
538 // AUXILIARY DATA HEADER
539 headerSWF[ i ].sid = sid;
540 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
536 headerSWF[ i ].time[0] = 0x00;
541 headerSWF[ i ].time[0] = 0x00;
537 headerSWF[ i ].time[0] = 0x00;
542 headerSWF[ i ].time[0] = 0x00;
538 headerSWF[ i ].time[0] = 0x00;
543 headerSWF[ i ].time[0] = 0x00;
539 headerSWF[ i ].time[0] = 0x00;
544 headerSWF[ i ].time[0] = 0x00;
540 headerSWF[ i ].time[0] = 0x00;
545 headerSWF[ i ].time[0] = 0x00;
541 headerSWF[ i ].time[0] = 0x00;
546 headerSWF[ i ].time[0] = 0x00;
542 headerSWF[ i ].sid = sid;
543 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
544 }
547 }
545 return LFR_SUCCESSFUL;
548 return LFR_SUCCESSFUL;
546 }
549 }
547
550
548 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
551 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
549 {
552 {
550 unsigned int i;
553 unsigned int i;
551
554
552 for (i=0; i<7; i++)
555 for (i=0; i<7; i++)
553 {
556 {
554 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
557 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
555 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
558 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
556 headerCWF[ i ].reserved = DEFAULT_RESERVED;
559 headerCWF[ i ].reserved = DEFAULT_RESERVED;
557 headerCWF[ i ].userApplication = CCSDS_USER_APP;
560 headerCWF[ i ].userApplication = CCSDS_USER_APP;
558 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
561 if ( (sid == SID_SBM1_CWF_F1) || (sid == SID_SBM2_CWF_F2) )
559 {
562 {
560 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
563 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
561 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
564 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
562 }
565 }
563 else
566 else
564 {
567 {
565 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
568 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
566 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
569 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
567 }
570 }
568 if (i == 0)
571 if (i == 0)
569 {
572 {
570 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
573 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
571 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
574 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
572 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
575 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
573 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
576 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
574 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
577 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
575 }
578 }
576 else if (i == 6)
579 else if (i == 6)
577 {
580 {
578 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
581 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
579 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_8 >> 8);
582 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_8 >> 8);
580 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_8 );
583 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_8 );
581 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
584 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
582 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
585 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
583 }
586 }
584 else
587 else
585 {
588 {
586 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
589 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
587 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
590 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
588 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
591 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
589 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
592 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
590 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
593 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
591 }
594 }
592 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
595 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
593 // PKT_CNT
596 // PKT_CNT
594 // PKT_NR
597 // PKT_NR
595 // DATA FIELD HEADER
598 // DATA FIELD HEADER
596 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
599 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
597 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
600 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
598 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
601 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
599 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
602 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
600 // AUXILIARY DATA HEADER
603 // AUXILIARY DATA HEADER
601 headerCWF[ i ].sid = sid;
604 headerCWF[ i ].sid = sid;
602 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
605 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
603 headerCWF[ i ].time[0] = 0x00;
606 headerCWF[ i ].time[0] = 0x00;
604 headerCWF[ i ].time[0] = 0x00;
607 headerCWF[ i ].time[0] = 0x00;
605 headerCWF[ i ].time[0] = 0x00;
608 headerCWF[ i ].time[0] = 0x00;
606 headerCWF[ i ].time[0] = 0x00;
609 headerCWF[ i ].time[0] = 0x00;
607 headerCWF[ i ].time[0] = 0x00;
610 headerCWF[ i ].time[0] = 0x00;
608 headerCWF[ i ].time[0] = 0x00;
611 headerCWF[ i ].time[0] = 0x00;
609 }
612 }
610 return LFR_SUCCESSFUL;
613 return LFR_SUCCESSFUL;
611 }
614 }
612
615
613 int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
616 int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
614 {
617 {
615 unsigned int i;
618 unsigned int i;
616
619
617 for (i=0; i<7; i++)
620 for (i=0; i<7; i++)
618 {
621 {
619 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
622 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
620 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
623 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
621 headerCWF[ i ].reserved = DEFAULT_RESERVED;
624 headerCWF[ i ].reserved = DEFAULT_RESERVED;
622 headerCWF[ i ].userApplication = CCSDS_USER_APP;
625 headerCWF[ i ].userApplication = CCSDS_USER_APP;
623
626
624 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
627 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
625 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
628 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
626 if (i == 0)
629 if (i == 0)
627 {
630 {
628 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
631 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
629 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
632 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
630 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
633 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
631 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
634 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
632 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
635 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
633 }
636 }
634 else if (i == 6)
637 else if (i == 6)
635 {
638 {
636 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
639 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
637 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 >> 8);
640 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 >> 8);
638 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 );
641 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_8 );
639 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
642 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
640 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
643 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
641 }
644 }
642 else
645 else
643 {
646 {
644 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
647 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
645 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
648 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 >> 8);
646 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
649 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF3_LIGHT_340 );
647 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
650 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
648 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
651 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
649 }
652 }
650 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
653 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
651 // DATA FIELD HEADER
654 // DATA FIELD HEADER
652 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
655 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
653 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
656 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
654 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
657 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
655 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
658 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
656 // AUXILIARY DATA HEADER
659 // AUXILIARY DATA HEADER
657 headerCWF[ i ].sid = SID_NORM_CWF_F3;
660 headerCWF[ i ].sid = SID_NORM_CWF_F3;
658 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
661 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
659 headerCWF[ i ].time[0] = 0x00;
662 headerCWF[ i ].time[0] = 0x00;
660 headerCWF[ i ].time[0] = 0x00;
663 headerCWF[ i ].time[0] = 0x00;
661 headerCWF[ i ].time[0] = 0x00;
664 headerCWF[ i ].time[0] = 0x00;
662 headerCWF[ i ].time[0] = 0x00;
665 headerCWF[ i ].time[0] = 0x00;
663 headerCWF[ i ].time[0] = 0x00;
666 headerCWF[ i ].time[0] = 0x00;
664 headerCWF[ i ].time[0] = 0x00;
667 headerCWF[ i ].time[0] = 0x00;
665 }
668 }
666 return LFR_SUCCESSFUL;
669 return LFR_SUCCESSFUL;
667 }
670 }
668
671
669 void reset_waveforms( void )
672 void reset_waveforms( void )
670 {
673 {
671 int i = 0;
674 int i = 0;
672
675
673 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
676 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
674 {
677 {
675 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x10002000;
678 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x10002000;
676 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
679 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
677 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
680 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
678
681
679 //***
682 //***
680 // F1
683 // F1
681 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x1000f000;
684 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x1000f000;
682 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0xf0001000;
685 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0xf0001000;
683 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
686 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
684
687
685 //***
688 //***
686 // F2
689 // F2
687 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x40008000;
690 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x40008000;
688 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
691 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
689 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x10002000;
692 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x10002000;
690
693
691 //***
694 //***
692 // F3
695 // F3
693 /*wf_cont_f3[ i* NB_WORDS_SWF_BLK + 0 ] = build_value( i, i ); // v and 1
696 /*wf_cont_f3[ i* NB_WORDS_SWF_BLK + 0 ] = build_value( i, i ); // v and 1
694 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 1 ] = build_value( i, i ); // e2 and b1
697 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 1 ] = build_value( i, i ); // e2 and b1
695 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 2 ] = build_value( i, i ); // b2 and b3*/
698 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 2 ] = build_value( i, i ); // b2 and b3*/
696 }
699 }
697 }
700 }
698
701
699 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
702 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
700 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
703 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
701 {
704 {
702 /** This function sends SWF CCSDS packets (F2, F1 or F0).
705 /** This function sends SWF CCSDS packets (F2, F1 or F0).
703 *
706 *
704 * @param waveform points to the buffer containing the data that will be send.
707 * @param waveform points to the buffer containing the data that will be send.
705 * @param sid is the source identifier of the data that will be sent.
708 * @param sid is the source identifier of the data that will be sent.
706 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
709 * @param headerSWF points to a table of headers that have been prepared for the data transmission.
707 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
710 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
708 * contain information to setup the transmission of the data packets.
711 * contain information to setup the transmission of the data packets.
709 *
712 *
710 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
713 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
711 *
714 *
712 */
715 */
713
716
714 unsigned int i;
717 unsigned int i;
715 int ret;
718 int ret;
716 rtems_status_code status;
719 rtems_status_code status;
717 spw_ioctl_pkt_send spw_ioctl_send_SWF;
720 spw_ioctl_pkt_send spw_ioctl_send_SWF;
718
721
719 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
722 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
720 spw_ioctl_send_SWF.options = 0;
723 spw_ioctl_send_SWF.options = 0;
721
724
722 ret = LFR_DEFAULT;
725 ret = LFR_DEFAULT;
723
726
724 for (i=0; i<7; i++) // send waveform
727 for (i=0; i<7; i++) // send waveform
725 {
728 {
726 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
729 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
727 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
730 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
728 // BUILD THE DATA
731 // BUILD THE DATA
729 if (i==6) {
732 if (i==6) {
730 spw_ioctl_send_SWF.dlen = 8 * NB_BYTES_SWF_BLK;
733 spw_ioctl_send_SWF.dlen = 8 * NB_BYTES_SWF_BLK;
731 }
734 }
732 else {
735 else {
733 spw_ioctl_send_SWF.dlen = 340 * NB_BYTES_SWF_BLK;
736 spw_ioctl_send_SWF.dlen = 340 * NB_BYTES_SWF_BLK;
734 }
737 }
735 // SET PACKET SEQUENCE COUNTER
736 increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid );
737 // SET PACKET TIME
738 // SET PACKET TIME
738 headerSWF[ i ].acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
739 headerSWF[ i ].acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
739 headerSWF[ i ].acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
740 headerSWF[ i ].acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
740 headerSWF[ i ].acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
741 headerSWF[ i ].acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
741 headerSWF[ i ].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
742 headerSWF[ i ].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
742 headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
743 headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
743 headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
744 headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
744 headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
745 headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
745 headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
746 headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
746 headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
747 headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
747 headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
748 headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
748 headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
749 headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
749 headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
750 headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
750 // SEND PACKET
751 // SEND PACKET
751 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
752 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE);
752 if (status != RTEMS_SUCCESSFUL) {
753 if (status != RTEMS_SUCCESSFUL) {
753 printf("%d-%d, ERR %d\n", sid, i, (int) status);
754 printf("%d-%d, ERR %d\n", sid, i, (int) status);
754 ret = LFR_DEFAULT;
755 ret = LFR_DEFAULT;
755 }
756 }
756 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
757 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
757 }
758 }
758
759
759 return ret;
760 return ret;
760 }
761 }
761
762
762 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
763 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
763 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
764 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
764 {
765 {
765 /** This function sends CWF CCSDS packets (F2, F1 or F0).
766 /** This function sends CWF CCSDS packets (F2, F1 or F0).
766 *
767 *
767 * @param waveform points to the buffer containing the data that will be send.
768 * @param waveform points to the buffer containing the data that will be send.
768 * @param sid is the source identifier of the data that will be sent.
769 * @param sid is the source identifier of the data that will be sent.
769 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
770 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
770 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
771 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
771 * contain information to setup the transmission of the data packets.
772 * contain information to setup the transmission of the data packets.
772 *
773 *
773 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
774 * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks.
774 *
775 *
775 */
776 */
776
777
777 unsigned int i;
778 unsigned int i;
778 int ret;
779 int ret;
779 rtems_status_code status;
780 rtems_status_code status;
780 spw_ioctl_pkt_send spw_ioctl_send_CWF;
781 spw_ioctl_pkt_send spw_ioctl_send_CWF;
781
782
782 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
783 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
783 spw_ioctl_send_CWF.options = 0;
784 spw_ioctl_send_CWF.options = 0;
784
785
785 ret = LFR_DEFAULT;
786 ret = LFR_DEFAULT;
786
787
787 for (i=0; i<7; i++) // send waveform
788 for (i=0; i<7; i++) // send waveform
788 {
789 {
789 int coarseTime = 0x00;
790 int coarseTime = 0x00;
790 int fineTime = 0x00;
791 int fineTime = 0x00;
791 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
792 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
792 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
793 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
793 // BUILD THE DATA
794 // BUILD THE DATA
794 if (i==6) {
795 if (i==6) {
795 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_SWF_BLK;
796 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_SWF_BLK;
796 }
797 }
797 else {
798 else {
798 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_SWF_BLK;
799 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_SWF_BLK;
799 }
800 }
800 // SET PACKET SEQUENCE COUNTER
801 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid );
802 // SET PACKET TIME
801 // SET PACKET TIME
803 coarseTime = time_management_regs->coarse_time;
802 coarseTime = time_management_regs->coarse_time;
804 fineTime = time_management_regs->fine_time;
803 fineTime = time_management_regs->fine_time;
805 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
804 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
806 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
805 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
807 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
806 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
808 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
807 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
809 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
808 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
810 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
809 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
811 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
810 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
812 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
811 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
813 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
812 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
814 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
813 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
815 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
814 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
816 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
815 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
817 // SEND PACKET
816 // SEND PACKET
818 if (sid == SID_NORM_CWF_F3)
817 if (sid == SID_NORM_CWF_F3)
819 {
818 {
820 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
819 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
821 if (status != RTEMS_SUCCESSFUL) {
820 if (status != RTEMS_SUCCESSFUL) {
822 printf("%d-%d, ERR %d\n", sid, i, (int) status);
821 printf("%d-%d, ERR %d\n", sid, i, (int) status);
823 ret = LFR_DEFAULT;
822 ret = LFR_DEFAULT;
824 }
823 }
825 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
824 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
826 }
825 }
827 else
826 else
828 {
827 {
829 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
828 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
830 if (status != RTEMS_SUCCESSFUL) {
829 if (status != RTEMS_SUCCESSFUL) {
831 printf("%d-%d, ERR %d\n", sid, i, (int) status);
830 printf("%d-%d, ERR %d\n", sid, i, (int) status);
832 ret = LFR_DEFAULT;
831 ret = LFR_DEFAULT;
833 }
832 }
834 }
833 }
835 }
834 }
836
835
837 return ret;
836 return ret;
838 }
837 }
839
838
840 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
839 int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
841 {
840 {
842 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
841 /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data.
843 *
842 *
844 * @param waveform points to the buffer containing the data that will be send.
843 * @param waveform points to the buffer containing the data that will be send.
845 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
844 * @param headerCWF points to a table of headers that have been prepared for the data transmission.
846 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
845 * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures
847 * contain information to setup the transmission of the data packets.
846 * contain information to setup the transmission of the data packets.
848 *
847 *
849 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
848 * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer
850 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
849 * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks.
851 *
850 *
852 */
851 */
853
852
854 unsigned int i;
853 unsigned int i;
855 int ret;
854 int ret;
856 rtems_status_code status;
855 rtems_status_code status;
857 spw_ioctl_pkt_send spw_ioctl_send_CWF;
856 spw_ioctl_pkt_send spw_ioctl_send_CWF;
858 char *sample;
857 char *sample;
859
858
860 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
859 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
861 spw_ioctl_send_CWF.options = 0;
860 spw_ioctl_send_CWF.options = 0;
862
861
863 ret = LFR_DEFAULT;
862 ret = LFR_DEFAULT;
864
863
865 //**********************
864 //**********************
866 // BUILD CWF3_light DATA
865 // BUILD CWF3_light DATA
867 for ( i=0; i< 2048; i++)
866 for ( i=0; i< 2048; i++)
868 {
867 {
869 sample = (char*) &waveform[ i * NB_WORDS_SWF_BLK ];
868 sample = (char*) &waveform[ i * NB_WORDS_SWF_BLK ];
870 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ];
869 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ];
871 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ];
870 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ];
872 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ];
871 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ];
873 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ];
872 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ];
874 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ];
873 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ];
875 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ];
874 wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ];
876 }
875 }
877
876
878 //*********************
877 //*********************
879 // SEND CWF3_light DATA
878 // SEND CWF3_light DATA
880
879
881 for (i=0; i<7; i++) // send waveform
880 for (i=0; i<7; i++) // send waveform
882 {
881 {
883 int coarseTime = 0x00;
882 int coarseTime = 0x00;
884 int fineTime = 0x00;
883 int fineTime = 0x00;
885 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * 340 * NB_BYTES_CWF3_LIGHT_BLK) ];
884 spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * 340 * NB_BYTES_CWF3_LIGHT_BLK) ];
886 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
885 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
887 // BUILD THE DATA
886 // BUILD THE DATA
888 if ( i == WFRM_INDEX_OF_LAST_PACKET ) {
887 if ( i == WFRM_INDEX_OF_LAST_PACKET ) {
889 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_CWF3_LIGHT_BLK;
888 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_CWF3_LIGHT_BLK;
890 }
889 }
891 else {
890 else {
892 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_CWF3_LIGHT_BLK;
891 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_CWF3_LIGHT_BLK;
893 }
892 }
894 // SET PACKET SEQUENCE COUNTER
895 increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 );
896 // SET PACKET TIME
893 // SET PACKET TIME
897 coarseTime = time_management_regs->coarse_time;
894 coarseTime = time_management_regs->coarse_time;
898 fineTime = time_management_regs->fine_time;
895 fineTime = time_management_regs->fine_time;
899 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
896 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
900 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
897 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
901 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
898 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
902 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
899 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
903 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
900 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
904 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
901 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
905 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
902 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
906 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
903 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
907 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
904 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
908 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
905 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
909 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
906 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
910 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
907 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
911 // SEND PACKET
908 // SEND PACKET
912 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
909 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
913 if (status != RTEMS_SUCCESSFUL) {
910 if (status != RTEMS_SUCCESSFUL) {
914 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
911 printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status);
915 ret = LFR_DEFAULT;
912 ret = LFR_DEFAULT;
916 }
913 }
917 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
914 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
918 }
915 }
919
916
920 return ret;
917 return ret;
921 }
918 }
922
919
923
920
924 //**************
921 //**************
925 // wfp registers
922 // wfp registers
926 void set_wfp_data_shaping()
923 void set_wfp_data_shaping()
927 {
924 {
928 /** This function sets the data_shaping register of the waveform picker module.
925 /** This function sets the data_shaping register of the waveform picker module.
929 *
926 *
930 * The value is read from one field of the parameter_dump_packet structure:\n
927 * The value is read from one field of the parameter_dump_packet structure:\n
931 * bw_sp0_sp1_r0_r1
928 * bw_sp0_sp1_r0_r1
932 *
929 *
933 */
930 */
934
931
935 unsigned char data_shaping;
932 unsigned char data_shaping;
936
933
937 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
934 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
938 // waveform picker : [R1 R0 SP1 SP0 BW]
935 // waveform picker : [R1 R0 SP1 SP0 BW]
939
936
940 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
937 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
941
938
942 #ifdef GSA
939 #ifdef GSA
943 #else
940 #else
944 waveform_picker_regs->data_shaping =
941 new_waveform_picker_regs->data_shaping =
945 ( (data_shaping & 0x10) >> 4 ) // BW
942 ( (data_shaping & 0x10) >> 4 ) // BW
946 + ( (data_shaping & 0x08) >> 2 ) // SP0
943 + ( (data_shaping & 0x08) >> 2 ) // SP0
947 + ( (data_shaping & 0x04) ) // SP1
944 + ( (data_shaping & 0x04) ) // SP1
948 + ( (data_shaping & 0x02) << 2 ) // R0
945 + ( (data_shaping & 0x02) << 2 ) // R0
949 + ( (data_shaping & 0x01) << 4 ); // R1
946 + ( (data_shaping & 0x01) << 4 ); // R1
950 #endif
947 #endif
951 }
948 }
952
949
953 char set_wfp_delta_snapshot()
950 char set_wfp_delta_snapshot()
954 {
951 {
955 /** This function sets the delta_snapshot register of the waveform picker module.
952 /** This function sets the delta_snapshot register of the waveform picker module.
956 *
953 *
957 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
954 * The value is read from two (unsigned char) of the parameter_dump_packet structure:
958 * - sy_lfr_n_swf_p[0]
955 * - sy_lfr_n_swf_p[0]
959 * - sy_lfr_n_swf_p[1]
956 * - sy_lfr_n_swf_p[1]
960 *
957 *
961 */
958 */
962
959
963 char ret;
960 char ret;
964 unsigned int delta_snapshot;
961 unsigned int delta_snapshot;
965 unsigned int aux;
962 unsigned int aux;
966
963
967 aux = 0;
964 aux = 0;
968 ret = LFR_DEFAULT;
965 ret = LFR_DEFAULT;
969
966
970 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
967 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
971 + parameter_dump_packet.sy_lfr_n_swf_p[1];
968 + parameter_dump_packet.sy_lfr_n_swf_p[1];
972
969
973 #ifdef GSA
970 #ifdef GSA
974 #else
971 #else
975 if ( delta_snapshot < MIN_DELTA_SNAPSHOT )
972 if ( delta_snapshot < MIN_DELTA_SNAPSHOT )
976 {
973 {
977 aux = MIN_DELTA_SNAPSHOT;
974 aux = MIN_DELTA_SNAPSHOT;
978 ret = LFR_DEFAULT;
975 ret = LFR_DEFAULT;
979 }
976 }
980 else
977 else
981 {
978 {
982 aux = delta_snapshot ;
979 aux = delta_snapshot ;
983 ret = LFR_SUCCESSFUL;
980 ret = LFR_SUCCESSFUL;
984 }
981 }
985 waveform_picker_regs->delta_snapshot = aux - 1; // max 2 bytes
982 new_waveform_picker_regs->delta_snapshot = aux - 1; // max 2 bytes
986 #endif
983 #endif
987
984
988 return ret;
985 return ret;
989 }
986 }
990
987
991 void set_wfp_burst_enable_register( unsigned char mode)
988 void set_wfp_burst_enable_register( unsigned char mode)
992 {
989 {
993 /** This function sets the waveform picker burst_enable register depending on the mode.
990 /** This function sets the waveform picker burst_enable register depending on the mode.
994 *
991 *
995 * @param mode is the LFR mode to launch.
992 * @param mode is the LFR mode to launch.
996 *
993 *
997 * The burst bits shall be before the enable bits.
994 * The burst bits shall be before the enable bits.
998 *
995 *
999 */
996 */
1000
997
1001 #ifdef GSA
998 #ifdef GSA
1002 #else
999 #else
1003 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1000 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
1004 // the burst bits shall be set first, before the enable bits
1001 // the burst bits shall be set first, before the enable bits
1005 switch(mode) {
1002 switch(mode) {
1006 case(LFR_MODE_NORMAL):
1003 case(LFR_MODE_NORMAL):
1007 waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enable
1004 new_waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enable
1008 waveform_picker_regs->burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1005 // new_waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
1006 new_waveform_picker_regs->run_burst_enable = 0x07; // [0000 0111] enable f2 f1 f0
1009 break;
1007 break;
1010 case(LFR_MODE_BURST):
1008 case(LFR_MODE_BURST):
1011 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled
1009 new_waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1012 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x04; // [0100] enable f2
1010 new_waveform_picker_regs->run_burst_enable = new_waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2
1013 break;
1011 break;
1014 case(LFR_MODE_SBM1):
1012 case(LFR_MODE_SBM1):
1015 waveform_picker_regs->burst_enable = 0x20; // [0010 0000] f1 burst enabled
1013 new_waveform_picker_regs->run_burst_enable = 0x20; // [0010 0000] f1 burst enabled
1016 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1014 new_waveform_picker_regs->run_burst_enable = new_waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1017 break;
1015 break;
1018 case(LFR_MODE_SBM2):
1016 case(LFR_MODE_SBM2):
1019 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled
1017 new_waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled
1020 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1018 new_waveform_picker_regs->run_burst_enable = new_waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
1021 break;
1019 break;
1022 default:
1020 default:
1023 waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1021 new_waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
1024 break;
1022 break;
1025 }
1023 }
1026 #endif
1024 #endif
1027 }
1025 }
1028
1026
1029 void reset_wfp_burst_enable()
1027 void reset_wfp_run_burst_enable()
1030 {
1028 {
1031 /** This function resets the waveform picker burst_enable register.
1029 /** This function resets the waveform picker burst_enable register.
1032 *
1030 *
1033 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1031 * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0.
1034 *
1032 *
1035 */
1033 */
1036
1034
1037 #ifdef GSA
1035 #ifdef GSA
1038 #else
1036 #else
1039 waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1037 new_waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1040 #endif
1038 #endif
1041 }
1039 }
1042
1040
1043 void reset_wfp_status()
1041 void reset_wfp_status()
1044 {
1042 {
1045 /** This function resets the waveform picker status register.
1043 /** This function resets the waveform picker status register.
1046 *
1044 *
1047 * All status bits are set to 0 [new_err full_err full].
1045 * All status bits are set to 0 [new_err full_err full].
1048 *
1046 *
1049 */
1047 */
1050
1048
1051 #ifdef GSA
1049 #ifdef GSA
1052 #else
1050 #else
1053 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1051 new_waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
1054 #endif
1052 #endif
1055 }
1053 }
1056
1054
1057 void reset_waveform_picker_regs()
1055 void reset_new_waveform_picker_regs()
1058 {
1056 {
1059 /** This function resets the waveform picker module registers.
1057 new_waveform_picker_regs->data_shaping = 0x01; // 0x00 *** R1 R0 SP1 SP0 BW
1060 *
1058 new_waveform_picker_regs->run_burst_enable = 0x00; // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1061 * The registers affected by this function are located at the following offset addresses:
1059 new_waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); // 0x08
1062 * - 0x00 data_shaping
1060 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); // 0x0c
1063 * - 0x04 burst_enable
1061 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); // 0x10
1064 * - 0x08 addr_data_f0
1062 new_waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); // 0x14
1065 * - 0x0C addr_data_f1
1063 new_waveform_picker_regs->status = 0x00; // 0x18
1066 * - 0x10 addr_data_f2
1064 // new_waveform_picker_regs->delta_snapshot = 0x12800; // 0x1c 296 * 256 = 75776
1067 * - 0x14 addr_data_f3
1065 new_waveform_picker_regs->delta_snapshot = 0x1000; // 0x1c 16 * 256 = 4096
1068 * - 0x18 status
1066 new_waveform_picker_regs->delta_f0 = 0x3f5; // 0x20 *** 1013
1069 * - 0x1C delta_snapshot
1067 new_waveform_picker_regs->delta_f0_2 = 0x7; // 0x24 *** 7
1070 * - 0x20 delta_f2_f1
1068 new_waveform_picker_regs->delta_f1 = 0x3c0; // 0x28 *** 960
1071 * - 0x24 delta_f2_f0
1069 // new_waveform_picker_regs->delta_f2 = 0x12200; // 0x2c *** 74240
1072 * - 0x28 nb_burst
1070 new_waveform_picker_regs->delta_f2 = 0xc00; // 0x2c *** 12 * 256 = 2048
1073 * - 0x2C nb_snapshot
1071 new_waveform_picker_regs->nb_data_by_buffer = 0x1802; // 0x30 *** 2048 * 3 + 2
1074 *
1072 new_waveform_picker_regs->snapshot_param = 0x7ff; // 0x34 *** 2048 -1
1075 */
1073 new_waveform_picker_regs->start_date = 0x00; // 0x38
1074 }
1076
1075
1077 #ifdef GSA
1076 void reset_new_waveform_picker_regs_alt()
1078 #else
1077 {
1079 reset_wfp_burst_enable();
1078 new_waveform_picker_regs->data_shaping = 0x01; // 0x00 *** R1 R0 SP1 SP0 BW
1080 reset_wfp_status();
1079 new_waveform_picker_regs->run_burst_enable = 0x00; // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ]
1081 // set buffer addresses
1080 new_waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); // 0x08
1082 waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); //
1081 new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); // 0x0c
1083 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); //
1082 new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); // 0x10
1084 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); //
1083 new_waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); // 0x14
1085 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); //
1084 new_waveform_picker_regs->status = 0x00; // 0x18
1086 // set other parameters
1085 new_waveform_picker_regs->delta_snapshot = 0x1000; // 0x1c 16 * 256 = 4096
1087 set_wfp_data_shaping();
1086 new_waveform_picker_regs->delta_f0 = 0x19; // 0x20 *** 1013
1088 set_wfp_delta_snapshot(); // time in seconds between two snapshots
1087 new_waveform_picker_regs->delta_f0_2 = 0x7; // 0x24 *** 7
1089 waveform_picker_regs->delta_f2_f1 = 0xffff; // 0x16800 => 92160 (max 4 bytes)
1088 new_waveform_picker_regs->delta_f1 = 0x19; // 0x28 *** 960
1090 waveform_picker_regs->delta_f2_f0 = 0x17c00; // 97 280 (max 5 bytes)
1089 new_waveform_picker_regs->delta_f2 = 0x400; // 0x2c *** 4 * 256 = 1024
1091 waveform_picker_regs->nb_burst_available = 0x180; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets)
1090 new_waveform_picker_regs->nb_data_by_buffer = 0x32; // 0x30 *** 16 * 3 + 2
1092 waveform_picker_regs->nb_snapshot_param = 0x7ff; // max 3 octets, 2048 - 1
1091 new_waveform_picker_regs->snapshot_param = 0xf; // 0x34 *** 16 -1
1093 #endif
1092 new_waveform_picker_regs->start_date = 0x00; // 0x38
1094 }
1093 }
1095
1094
1096 //*****************
1095 //*****************
1097 // local parameters
1096 // local parameters
1098 void set_local_sbm1_nb_cwf_max()
1097 void set_local_sbm1_nb_cwf_max()
1099 {
1098 {
1100 /** This function sets the value of the sbm1_nb_cwf_max local parameter.
1099 /** This function sets the value of the sbm1_nb_cwf_max local parameter.
1101 *
1100 *
1102 * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n
1101 * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n
1103 * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.\n\n
1102 * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.\n\n
1104 * (2 snapshots of 2048 points per seconds) * (period of the NORM snashots) - 8 s (duration of the f2 snapshot)
1103 * (2 snapshots of 2048 points per seconds) * (period of the NORM snashots) - 8 s (duration of the f2 snapshot)
1105 *
1104 *
1106 */
1105 */
1107 param_local.local_sbm1_nb_cwf_max = 2 *
1106 param_local.local_sbm1_nb_cwf_max = 2 *
1108 (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
1107 (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
1109 + parameter_dump_packet.sy_lfr_n_swf_p[1]) - 8; // 16 CWF1 parts during 1 SWF2
1108 + parameter_dump_packet.sy_lfr_n_swf_p[1]) - 8; // 16 CWF1 parts during 1 SWF2
1110 }
1109 }
1111
1110
1112 void set_local_sbm2_nb_cwf_max()
1111 void set_local_sbm2_nb_cwf_max()
1113 {
1112 {
1114 /** This function sets the value of the sbm1_nb_cwf_max local parameter.
1113 /** This function sets the value of the sbm1_nb_cwf_max local parameter.
1115 *
1114 *
1116 * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n
1115 * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n
1117 * This parameter is used to send CWF_F2 data as normal data when the SBM2 is active.\n\n
1116 * This parameter is used to send CWF_F2 data as normal data when the SBM2 is active.\n\n
1118 * (period of the NORM snashots) / (8 seconds per snapshot at f2 = 256 Hz)
1117 * (period of the NORM snashots) / (8 seconds per snapshot at f2 = 256 Hz)
1119 *
1118 *
1120 */
1119 */
1121
1120
1122 param_local.local_sbm2_nb_cwf_max = (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
1121 param_local.local_sbm2_nb_cwf_max = (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
1123 + parameter_dump_packet.sy_lfr_n_swf_p[1]) / 8;
1122 + parameter_dump_packet.sy_lfr_n_swf_p[1]) / 8;
1124 }
1123 }
1125
1124
1126 void set_local_nb_interrupt_f0_MAX()
1125 void set_local_nb_interrupt_f0_MAX()
1127 {
1126 {
1128 /** This function sets the value of the nb_interrupt_f0_MAX local parameter.
1127 /** This function sets the value of the nb_interrupt_f0_MAX local parameter.
1129 *
1128 *
1130 * This parameter is used for the SM validation only.\n
1129 * This parameter is used for the SM validation only.\n
1131 * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices
1130 * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices
1132 * module before launching a basic processing.
1131 * module before launching a basic processing.
1133 *
1132 *
1134 */
1133 */
1135
1134
1136 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
1135 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
1137 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
1136 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
1138 }
1137 }
1139
1138
1140 void reset_local_sbm1_nb_cwf_sent()
1139 void reset_local_sbm1_nb_cwf_sent()
1141 {
1140 {
1142 /** This function resets the value of the sbm1_nb_cwf_sent local parameter.
1141 /** This function resets the value of the sbm1_nb_cwf_sent local parameter.
1143 *
1142 *
1144 * The sbm1_nb_cwf_sent parameter counts the number of CWF_F1 records that have been sent.\n
1143 * The sbm1_nb_cwf_sent parameter counts the number of CWF_F1 records that have been sent.\n
1145 * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.
1144 * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active.
1146 *
1145 *
1147 */
1146 */
1148
1147
1149 param_local.local_sbm1_nb_cwf_sent = 0;
1148 param_local.local_sbm1_nb_cwf_sent = 0;
1150 }
1149 }
1151
1150
1152 void reset_local_sbm2_nb_cwf_sent()
1151 void reset_local_sbm2_nb_cwf_sent()
1153 {
1152 {
1154 /** This function resets the value of the sbm2_nb_cwf_sent local parameter.
1153 /** This function resets the value of the sbm2_nb_cwf_sent local parameter.
1155 *
1154 *
1156 * The sbm2_nb_cwf_sent parameter counts the number of CWF_F2 records that have been sent.\n
1155 * The sbm2_nb_cwf_sent parameter counts the number of CWF_F2 records that have been sent.\n
1157 * This parameter is used to send CWF_F2 data as normal data when the SBM2 mode is active.
1156 * This parameter is used to send CWF_F2 data as normal data when the SBM2 mode is active.
1158 *
1157 *
1159 */
1158 */
1160
1159
1161 param_local.local_sbm2_nb_cwf_sent = 0;
1160 param_local.local_sbm2_nb_cwf_sent = 0;
1162 }
1161 }
1163
1162
1164 rtems_id get_pkts_queue_id( void )
1163 rtems_id get_pkts_queue_id( void )
1165 {
1164 {
1166 rtems_id queue_id;
1165 rtems_id queue_id;
1167 rtems_status_code status;
1166 rtems_status_code status;
1168 rtems_name queue_send_name;
1167 rtems_name queue_send_name;
1169
1168
1170 queue_send_name = rtems_build_name( 'Q', '_', 'S', 'D' );
1169 queue_send_name = rtems_build_name( 'Q', '_', 'S', 'D' );
1171
1170
1172 status = rtems_message_queue_ident( queue_send_name, 0, &queue_id );
1171 status = rtems_message_queue_ident( queue_send_name, 0, &queue_id );
1173 if (status != RTEMS_SUCCESSFUL)
1172 if (status != RTEMS_SUCCESSFUL)
1174 {
1173 {
1175 PRINTF1("in get_pkts_queue_id *** ERR %d\n", status)
1174 PRINTF1("in get_pkts_queue_id *** ERR %d\n", status)
1176 }
1175 }
1177 return queue_id;
1176 return queue_id;
1178 }
1177 }
1179
1180 void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid )
1181 {
1182 unsigned short *sequence_cnt;
1183 unsigned short segmentation_grouping_flag;
1184 unsigned short new_packet_sequence_control;
1185
1186 if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2)
1187 || (sid ==SID_NORM_CWF_F3) || (sid ==SID_BURST_CWF_F2) )
1188 {
1189 sequence_cnt = &sequenceCounters_SCIENCE_NORMAL_BURST;
1190 }
1191 else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) )
1192 {
1193 sequence_cnt = &sequenceCounters_SCIENCE_SBM1_SBM2;
1194 }
1195 else
1196 {
1197 sequence_cnt = &sequenceCounters_TC_EXE[ UNKNOWN ];
1198 PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid)
1199 }
1200
1201 segmentation_grouping_flag = (packet_sequence_control[ 0 ] & 0xc0) << 8;
1202 *sequence_cnt = (*sequence_cnt) & 0x3fff;
1203
1204 new_packet_sequence_control = segmentation_grouping_flag | *sequence_cnt ;
1205
1206 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1207 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1208
1209 // increment the seuqence counter for the next packet
1210 if ( *sequence_cnt < SEQ_CNT_MAX)
1211 {
1212 *sequence_cnt = *sequence_cnt + 1;
1213 }
1214 else
1215 {
1216 *sequence_cnt = 0;
1217 }
1218
1219 }
General Comments 0
You need to be logged in to leave comments. Login now