@@ -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 |
|
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,86 | |||||
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; |
|
33 | extern unsigned short sequenceCounters_SCIENCE_NORMAL_BURST; | |
37 | extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2; |
|
34 | extern unsigned short sequenceCounters_SCIENCE_SBM1_SBM2; | |
|
35 | extern unsigned short sequenceCounters_TC_EXE[]; | |||
38 |
|
36 | |||
39 | extern rtems_name misc_name[5]; |
|
37 | extern rtems_name misc_name[5]; | |
40 | extern rtems_name Task_name[20]; /* array of task ids */ |
|
38 | extern rtems_name Task_name[20]; /* array of task ids */ | |
41 | extern rtems_id Task_id[20]; /* array of task ids */ |
|
39 | extern rtems_id Task_id[20]; /* array of task ids */ | |
42 |
|
40 | |||
43 | extern unsigned char lfrCurrentMode; |
|
41 | extern unsigned char lfrCurrentMode; | |
44 |
|
42 | |||
45 | rtems_isr waveforms_isr( rtems_vector_number vector ); |
|
43 | rtems_isr waveforms_isr( rtems_vector_number vector ); | |
46 | rtems_isr waveforms_simulator_isr( rtems_vector_number vector ); |
|
44 | rtems_isr waveforms_simulator_isr( rtems_vector_number vector ); | |
47 | rtems_task wfrm_task( rtems_task_argument argument ); |
|
45 | rtems_task wfrm_task( rtems_task_argument argument ); | |
48 | rtems_task cwf3_task( rtems_task_argument argument ); |
|
46 | rtems_task cwf3_task( rtems_task_argument argument ); | |
49 | rtems_task cwf2_task( rtems_task_argument argument ); |
|
47 | rtems_task cwf2_task( rtems_task_argument argument ); | |
50 | rtems_task cwf1_task( rtems_task_argument argument ); |
|
48 | rtems_task cwf1_task( rtems_task_argument argument ); | |
51 |
|
49 | |||
52 | //****************** |
|
50 | //****************** | |
53 | // general functions |
|
51 | // general functions | |
54 | void init_waveforms( void ); |
|
52 | void init_waveforms( void ); | |
55 | // |
|
53 | // | |
56 | int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF ); |
|
54 | 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 ); |
|
55 | 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 ); |
|
56 | int init_header_continuous_wf3_light_table( Header_TM_LFR_SCIENCE_CWF_t *headerCWF ); | |
59 | // |
|
57 | // | |
60 | void reset_waveforms( void ); |
|
58 | void reset_waveforms( void ); | |
61 | // |
|
59 | // | |
62 | int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id ); |
|
60 | 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 ); |
|
61 | 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 ); |
|
62 | 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 ); |
|
63 | int send_waveform_CWF3_light( volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id ); | |
66 | // |
|
64 | // | |
67 | rtems_id get_pkts_queue_id( void ); |
|
65 | rtems_id get_pkts_queue_id( void ); | |
68 |
|
66 | |||
69 | //************** |
|
67 | //************** | |
70 | // wfp registers |
|
68 | // wfp registers | |
71 | void set_wfp_data_shaping(); |
|
69 | void set_wfp_data_shaping(); | |
72 | char set_wfp_delta_snapshot(); |
|
70 | char set_wfp_delta_snapshot(); | |
73 | void set_wfp_burst_enable_register( unsigned char mode); |
|
71 | void set_wfp_burst_enable_register( unsigned char mode); | |
74 | void reset_wfp_burst_enable(); |
|
72 | void reset_wfp_run_burst_enable(); | |
75 | void reset_wfp_status(); |
|
73 | void reset_wfp_status(); | |
76 | void reset_waveform_picker_regs(); |
|
74 | void reset_new_waveform_picker_regs(); | |
77 |
|
75 | |||
78 | //***************** |
|
76 | //***************** | |
79 | // local parameters |
|
77 | // local parameters | |
80 | void set_local_sbm1_nb_cwf_max(); |
|
78 | void set_local_sbm1_nb_cwf_max(); | |
81 | void set_local_sbm2_nb_cwf_max(); |
|
79 | void set_local_sbm2_nb_cwf_max(); | |
82 | void set_local_nb_interrupt_f0_MAX(); |
|
80 | void set_local_nb_interrupt_f0_MAX(); | |
83 | void reset_local_sbm1_nb_cwf_sent(); |
|
81 | void reset_local_sbm1_nb_cwf_sent(); | |
84 | void reset_local_sbm2_nb_cwf_sent(); |
|
82 | void reset_local_sbm2_nb_cwf_sent(); | |
85 |
|
83 | |||
86 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ); |
|
84 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ); | |
87 |
|
85 | |||
88 | #endif // WF_HANDLER_H_INCLUDED |
|
86 | #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,91 | |||||
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_SCIENCE_NORMAL_BURST; | |
87 | unsigned short sequenceCounters_SCIENCE_SBM1_SBM2; |
|
86 | unsigned short sequenceCounters_SCIENCE_SBM1_SBM2; | |
88 | unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID]; |
|
87 | unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID]; | |
89 | spw_stats spacewire_stats; |
|
88 | spw_stats spacewire_stats; | |
90 | spw_stats spacewire_stats_backup; |
|
89 | spw_stats spacewire_stats_backup; | |
91 |
|
90 | |||
92 |
|
91 |
@@ -1,586 +1,582 | |||||
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 | unsigned int i; |
|
199 | unsigned int i; | |
200 |
|
||||
201 | // LOCAL PARAMETERS |
|
200 | // LOCAL PARAMETERS | |
202 | set_local_sbm1_nb_cwf_max(); |
|
201 | set_local_sbm1_nb_cwf_max(); | |
203 | set_local_sbm2_nb_cwf_max(); |
|
202 | set_local_sbm2_nb_cwf_max(); | |
204 | set_local_nb_interrupt_f0_MAX(); |
|
203 | set_local_nb_interrupt_f0_MAX(); | |
205 |
|
||||
206 | BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) |
|
204 | 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) |
|
205 | 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) |
|
206 | BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX) | |
209 |
|
||||
210 | reset_local_sbm1_nb_cwf_sent(); |
|
207 | reset_local_sbm1_nb_cwf_sent(); | |
211 | reset_local_sbm2_nb_cwf_sent(); |
|
208 | reset_local_sbm2_nb_cwf_sent(); | |
212 |
|
||||
213 | // init sequence counters |
|
209 | // init sequence counters | |
214 |
|
||||
215 | for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++) |
|
210 | for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++) | |
216 | { |
|
211 | { | |
217 |
|
|
212 | sequenceCounters_TC_EXE[i] = 0x00; | |
218 | } |
|
213 | } | |
219 | sequenceCounters_SCIENCE_NORMAL_BURST = 0x00; |
|
214 | sequenceCounters_SCIENCE_NORMAL_BURST = 0x00; | |
220 | sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00; |
|
215 | sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00; | |
221 | } |
|
216 | } | |
222 |
|
217 | |||
223 | void create_names( void ) // create all names for tasks and queues |
|
218 | void create_names( void ) // create all names for tasks and queues | |
224 | { |
|
219 | { | |
225 | /** This function creates all RTEMS names used in the software for tasks and queues. |
|
220 | /** This function creates all RTEMS names used in the software for tasks and queues. | |
226 | * |
|
221 | * | |
227 | * @return RTEMS directive status codes: |
|
222 | * @return RTEMS directive status codes: | |
228 | * - RTEMS_SUCCESSFUL - successful completion |
|
223 | * - RTEMS_SUCCESSFUL - successful completion | |
229 | * |
|
224 | * | |
230 | */ |
|
225 | */ | |
231 |
|
226 | |||
232 | // task names |
|
227 | // task names | |
233 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); |
|
228 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); | |
234 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); |
|
229 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); | |
235 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); |
|
230 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); | |
236 | Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' ); |
|
231 | Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' ); | |
237 | Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' ); |
|
232 | Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' ); | |
238 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); |
|
233 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); | |
239 | Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' ); |
|
234 | Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' ); | |
240 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); |
|
235 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); | |
241 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); |
|
236 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); | |
242 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
237 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); | |
243 | Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' ); |
|
238 | Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' ); | |
244 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); |
|
239 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); | |
245 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); |
|
240 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); | |
246 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); |
|
241 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); | |
247 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); |
|
242 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); | |
248 | Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' ); |
|
243 | Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' ); | |
249 |
|
244 | |||
250 | // rate monotonic period names |
|
245 | // rate monotonic period names | |
251 | name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
246 | name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' ); | |
252 |
|
247 | |||
253 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
248 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); | |
254 | misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
249 | misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); | |
255 | } |
|
250 | } | |
256 |
|
251 | |||
257 | int create_all_tasks( void ) // create all tasks which run in the software |
|
252 | int create_all_tasks( void ) // create all tasks which run in the software | |
258 | { |
|
253 | { | |
259 | /** This function creates all RTEMS tasks used in the software. |
|
254 | /** This function creates all RTEMS tasks used in the software. | |
260 | * |
|
255 | * | |
261 | * @return RTEMS directive status codes: |
|
256 | * @return RTEMS directive status codes: | |
262 | * - RTEMS_SUCCESSFUL - task created successfully |
|
257 | * - RTEMS_SUCCESSFUL - task created successfully | |
263 | * - RTEMS_INVALID_ADDRESS - id is NULL |
|
258 | * - RTEMS_INVALID_ADDRESS - id is NULL | |
264 | * - RTEMS_INVALID_NAME - invalid task name |
|
259 | * - RTEMS_INVALID_NAME - invalid task name | |
265 | * - RTEMS_INVALID_PRIORITY - invalid task priority |
|
260 | * - RTEMS_INVALID_PRIORITY - invalid task priority | |
266 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured |
|
261 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured | |
267 | * - RTEMS_TOO_MANY - too many tasks created |
|
262 | * - RTEMS_TOO_MANY - too many tasks created | |
268 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context |
|
263 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context | |
269 | * - RTEMS_TOO_MANY - too many global objects |
|
264 | * - RTEMS_TOO_MANY - too many global objects | |
270 | * |
|
265 | * | |
271 | */ |
|
266 | */ | |
272 |
|
267 | |||
273 | rtems_status_code status; |
|
268 | rtems_status_code status; | |
274 |
|
269 | |||
275 | // RECV |
|
270 | // RECV | |
276 | status = rtems_task_create( |
|
271 | status = rtems_task_create( | |
277 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, |
|
272 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, | |
278 | RTEMS_DEFAULT_MODES, |
|
273 | RTEMS_DEFAULT_MODES, | |
279 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] |
|
274 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] | |
280 | ); |
|
275 | ); | |
281 |
|
276 | |||
282 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
277 | if (status == RTEMS_SUCCESSFUL) // ACTN | |
283 | { |
|
278 | { | |
284 | status = rtems_task_create( |
|
279 | status = rtems_task_create( | |
285 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, |
|
280 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, | |
286 | RTEMS_DEFAULT_MODES, |
|
281 | RTEMS_DEFAULT_MODES, | |
287 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] |
|
282 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] | |
288 | ); |
|
283 | ); | |
289 | } |
|
284 | } | |
290 | if (status == RTEMS_SUCCESSFUL) // SPIQ |
|
285 | if (status == RTEMS_SUCCESSFUL) // SPIQ | |
291 | { |
|
286 | { | |
292 | status = rtems_task_create( |
|
287 | status = rtems_task_create( | |
293 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, |
|
288 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, | |
294 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
289 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
295 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] |
|
290 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] | |
296 | ); |
|
291 | ); | |
297 | } |
|
292 | } | |
298 | if (status == RTEMS_SUCCESSFUL) // SMIQ |
|
293 | if (status == RTEMS_SUCCESSFUL) // SMIQ | |
299 | { |
|
294 | { | |
300 | status = rtems_task_create( |
|
295 | status = rtems_task_create( | |
301 | Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE, |
|
296 | Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE, | |
302 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
297 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
303 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ] |
|
298 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ] | |
304 | ); |
|
299 | ); | |
305 | } |
|
300 | } | |
306 | if (status == RTEMS_SUCCESSFUL) // STAT |
|
301 | if (status == RTEMS_SUCCESSFUL) // STAT | |
307 | { |
|
302 | { | |
308 | status = rtems_task_create( |
|
303 | status = rtems_task_create( | |
309 | Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE, |
|
304 | Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE, | |
310 | RTEMS_DEFAULT_MODES, |
|
305 | RTEMS_DEFAULT_MODES, | |
311 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT] |
|
306 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT] | |
312 | ); |
|
307 | ); | |
313 | } |
|
308 | } | |
314 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
309 | if (status == RTEMS_SUCCESSFUL) // AVF0 | |
315 | { |
|
310 | { | |
316 | status = rtems_task_create( |
|
311 | status = rtems_task_create( | |
317 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, |
|
312 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, | |
318 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
313 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
319 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] |
|
314 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] | |
320 | ); |
|
315 | ); | |
321 | } |
|
316 | } | |
322 | if (status == RTEMS_SUCCESSFUL) // BPF0 |
|
317 | if (status == RTEMS_SUCCESSFUL) // BPF0 | |
323 | { |
|
318 | { | |
324 | status = rtems_task_create( |
|
319 | status = rtems_task_create( | |
325 | Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE, |
|
320 | Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE, | |
326 | RTEMS_DEFAULT_MODES, |
|
321 | RTEMS_DEFAULT_MODES, | |
327 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0] |
|
322 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0] | |
328 | ); |
|
323 | ); | |
329 | } |
|
324 | } | |
330 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
325 | if (status == RTEMS_SUCCESSFUL) // WFRM | |
331 | { |
|
326 | { | |
332 | status = rtems_task_create( |
|
327 | status = rtems_task_create( | |
333 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, |
|
328 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, | |
334 | RTEMS_DEFAULT_MODES, |
|
329 | RTEMS_DEFAULT_MODES, | |
335 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] |
|
330 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] | |
336 | ); |
|
331 | ); | |
337 | } |
|
332 | } | |
338 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
333 | if (status == RTEMS_SUCCESSFUL) // DUMB | |
339 | { |
|
334 | { | |
340 | status = rtems_task_create( |
|
335 | status = rtems_task_create( | |
341 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, |
|
336 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, | |
342 | RTEMS_DEFAULT_MODES, |
|
337 | RTEMS_DEFAULT_MODES, | |
343 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] |
|
338 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] | |
344 | ); |
|
339 | ); | |
345 | } |
|
340 | } | |
346 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
341 | if (status == RTEMS_SUCCESSFUL) // HOUS | |
347 | { |
|
342 | { | |
348 | status = rtems_task_create( |
|
343 | status = rtems_task_create( | |
349 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, |
|
344 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, | |
350 |
RTEMS_DEFAULT_MODES |
|
345 | RTEMS_DEFAULT_MODES, | |
351 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS] |
|
346 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS] | |
352 | ); |
|
347 | ); | |
353 | } |
|
348 | } | |
354 | if (status == RTEMS_SUCCESSFUL) // MATR |
|
349 | if (status == RTEMS_SUCCESSFUL) // MATR | |
355 | { |
|
350 | { | |
356 | status = rtems_task_create( |
|
351 | status = rtems_task_create( | |
357 | Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE, |
|
352 | Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE, | |
358 | RTEMS_DEFAULT_MODES, |
|
353 | RTEMS_DEFAULT_MODES, | |
359 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR] |
|
354 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR] | |
360 | ); |
|
355 | ); | |
361 | } |
|
356 | } | |
362 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
357 | if (status == RTEMS_SUCCESSFUL) // CWF3 | |
363 | { |
|
358 | { | |
364 | status = rtems_task_create( |
|
359 | status = rtems_task_create( | |
365 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, |
|
360 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, | |
366 | RTEMS_DEFAULT_MODES, |
|
361 | RTEMS_DEFAULT_MODES, | |
367 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF3] |
|
362 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF3] | |
368 | ); |
|
363 | ); | |
369 | } |
|
364 | } | |
370 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
365 | if (status == RTEMS_SUCCESSFUL) // CWF2 | |
371 | { |
|
366 | { | |
372 | status = rtems_task_create( |
|
367 | status = rtems_task_create( | |
373 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, |
|
368 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, | |
374 | RTEMS_DEFAULT_MODES, |
|
369 | RTEMS_DEFAULT_MODES, | |
375 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF2] |
|
370 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF2] | |
376 | ); |
|
371 | ); | |
377 | } |
|
372 | } | |
378 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
373 | if (status == RTEMS_SUCCESSFUL) // CWF1 | |
379 | { |
|
374 | { | |
380 | status = rtems_task_create( |
|
375 | status = rtems_task_create( | |
381 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, |
|
376 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, | |
382 | RTEMS_DEFAULT_MODES, |
|
377 | RTEMS_DEFAULT_MODES, | |
383 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF1] |
|
378 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF1] | |
384 | ); |
|
379 | ); | |
385 | } |
|
380 | } | |
386 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
381 | if (status == RTEMS_SUCCESSFUL) // SEND | |
387 | { |
|
382 | { | |
388 | status = rtems_task_create( |
|
383 | status = rtems_task_create( | |
389 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE, |
|
384 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE, | |
390 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
385 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
391 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND] |
|
386 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND] | |
392 | ); |
|
387 | ); | |
393 | } |
|
388 | } | |
394 | if (status == RTEMS_SUCCESSFUL) // WTDG |
|
389 | if (status == RTEMS_SUCCESSFUL) // WTDG | |
395 | { |
|
390 | { | |
396 | status = rtems_task_create( |
|
391 | status = rtems_task_create( | |
397 | Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE, |
|
392 | Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE, | |
398 | RTEMS_DEFAULT_MODES, |
|
393 | RTEMS_DEFAULT_MODES, | |
399 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG] |
|
394 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG] | |
400 | ); |
|
395 | ); | |
401 | } |
|
396 | } | |
402 |
|
397 | |||
403 | return status; |
|
398 | return status; | |
404 | } |
|
399 | } | |
405 |
|
400 | |||
406 | int start_recv_send_tasks( void ) |
|
401 | int start_recv_send_tasks( void ) | |
407 | { |
|
402 | { | |
408 | rtems_status_code status; |
|
403 | rtems_status_code status; | |
409 |
|
404 | |||
410 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); |
|
405 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); | |
411 | if (status!=RTEMS_SUCCESSFUL) { |
|
406 | if (status!=RTEMS_SUCCESSFUL) { | |
412 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") |
|
407 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") | |
413 | } |
|
408 | } | |
414 |
|
409 | |||
415 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
410 | if (status == RTEMS_SUCCESSFUL) // SEND | |
416 | { |
|
411 | { | |
417 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); |
|
412 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); | |
418 | if (status!=RTEMS_SUCCESSFUL) { |
|
413 | if (status!=RTEMS_SUCCESSFUL) { | |
419 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") |
|
414 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") | |
420 | } |
|
415 | } | |
421 | } |
|
416 | } | |
422 |
|
417 | |||
423 | return status; |
|
418 | return status; | |
424 | } |
|
419 | } | |
425 |
|
420 | |||
426 | int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS |
|
421 | int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS | |
427 | { |
|
422 | { | |
428 | /** This function starts all RTEMS tasks used in the software. |
|
423 | /** This function starts all RTEMS tasks used in the software. | |
429 | * |
|
424 | * | |
430 | * @return RTEMS directive status codes: |
|
425 | * @return RTEMS directive status codes: | |
431 | * - RTEMS_SUCCESSFUL - ask started successfully |
|
426 | * - RTEMS_SUCCESSFUL - ask started successfully | |
432 | * - RTEMS_INVALID_ADDRESS - invalid task entry point |
|
427 | * - RTEMS_INVALID_ADDRESS - invalid task entry point | |
433 | * - RTEMS_INVALID_ID - invalid task id |
|
428 | * - RTEMS_INVALID_ID - invalid task id | |
434 | * - RTEMS_INCORRECT_STATE - task not in the dormant state |
|
429 | * - RTEMS_INCORRECT_STATE - task not in the dormant state | |
435 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task |
|
430 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task | |
436 | * |
|
431 | * | |
437 | */ |
|
432 | */ | |
438 | // starts all the tasks fot eh flight software |
|
433 | // starts all the tasks fot eh flight software | |
439 |
|
434 | |||
440 | rtems_status_code status; |
|
435 | rtems_status_code status; | |
441 |
|
436 | |||
442 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); |
|
437 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); | |
443 | if (status!=RTEMS_SUCCESSFUL) { |
|
438 | if (status!=RTEMS_SUCCESSFUL) { | |
444 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") |
|
439 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") | |
445 | } |
|
440 | } | |
446 |
|
441 | |||
447 | if (status == RTEMS_SUCCESSFUL) // WTDG |
|
442 | if (status == RTEMS_SUCCESSFUL) // WTDG | |
448 | { |
|
443 | { | |
449 | status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 ); |
|
444 | status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 ); | |
450 | if (status!=RTEMS_SUCCESSFUL) { |
|
445 | if (status!=RTEMS_SUCCESSFUL) { | |
451 | BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n") |
|
446 | BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n") | |
452 | } |
|
447 | } | |
453 | } |
|
448 | } | |
454 |
|
449 | |||
455 | if (status == RTEMS_SUCCESSFUL) // SMIQ |
|
450 | if (status == RTEMS_SUCCESSFUL) // SMIQ | |
456 | { |
|
451 | { | |
457 | status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 ); |
|
452 | status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 ); | |
458 | if (status!=RTEMS_SUCCESSFUL) { |
|
453 | if (status!=RTEMS_SUCCESSFUL) { | |
459 | BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n") |
|
454 | BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n") | |
460 | } |
|
455 | } | |
461 | } |
|
456 | } | |
462 |
|
457 | |||
463 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
458 | if (status == RTEMS_SUCCESSFUL) // ACTN | |
464 | { |
|
459 | { | |
465 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); |
|
460 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); | |
466 | if (status!=RTEMS_SUCCESSFUL) { |
|
461 | if (status!=RTEMS_SUCCESSFUL) { | |
467 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") |
|
462 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") | |
468 | } |
|
463 | } | |
469 | } |
|
464 | } | |
470 |
|
465 | |||
471 | if (status == RTEMS_SUCCESSFUL) // STAT |
|
466 | if (status == RTEMS_SUCCESSFUL) // STAT | |
472 | { |
|
467 | { | |
473 | status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 ); |
|
468 | status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 ); | |
474 | if (status!=RTEMS_SUCCESSFUL) { |
|
469 | if (status!=RTEMS_SUCCESSFUL) { | |
475 | BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n") |
|
470 | BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n") | |
476 | } |
|
471 | } | |
477 | } |
|
472 | } | |
478 |
|
473 | |||
479 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
474 | if (status == RTEMS_SUCCESSFUL) // AVF0 | |
480 | { |
|
475 | { | |
481 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 ); |
|
476 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 ); | |
482 | if (status!=RTEMS_SUCCESSFUL) { |
|
477 | if (status!=RTEMS_SUCCESSFUL) { | |
483 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") |
|
478 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") | |
484 | } |
|
479 | } | |
485 | } |
|
480 | } | |
486 |
|
481 | |||
487 | if (status == RTEMS_SUCCESSFUL) // BPF0 |
|
482 | if (status == RTEMS_SUCCESSFUL) // BPF0 | |
488 | { |
|
483 | { | |
489 | status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 ); |
|
484 | status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 ); | |
490 | if (status!=RTEMS_SUCCESSFUL) { |
|
485 | if (status!=RTEMS_SUCCESSFUL) { | |
491 | BOOT_PRINTF("in INIT *** Error starting TASK_BPF0\n") |
|
486 | BOOT_PRINTF("in INIT *** Error starting TASK_BPF0\n") | |
492 | } |
|
487 | } | |
493 | } |
|
488 | } | |
494 |
|
489 | |||
495 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
490 | if (status == RTEMS_SUCCESSFUL) // WFRM | |
496 | { |
|
491 | { | |
497 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); |
|
492 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); | |
498 | if (status!=RTEMS_SUCCESSFUL) { |
|
493 | if (status!=RTEMS_SUCCESSFUL) { | |
499 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") |
|
494 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") | |
500 | } |
|
495 | } | |
501 | } |
|
496 | } | |
502 |
|
497 | |||
503 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
498 | if (status == RTEMS_SUCCESSFUL) // DUMB | |
504 | { |
|
499 | { | |
505 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); |
|
500 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); | |
506 | if (status!=RTEMS_SUCCESSFUL) { |
|
501 | if (status!=RTEMS_SUCCESSFUL) { | |
507 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") |
|
502 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") | |
508 | } |
|
503 | } | |
509 | } |
|
504 | } | |
510 |
|
505 | |||
511 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
506 | if (status == RTEMS_SUCCESSFUL) // HOUS | |
512 | { |
|
507 | { | |
513 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); |
|
508 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); | |
514 | if (status!=RTEMS_SUCCESSFUL) { |
|
509 | if (status!=RTEMS_SUCCESSFUL) { | |
515 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") |
|
510 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") | |
516 | } |
|
511 | } | |
517 | } |
|
512 | } | |
518 |
|
513 | |||
519 | if (status == RTEMS_SUCCESSFUL) // MATR |
|
514 | if (status == RTEMS_SUCCESSFUL) // MATR | |
520 | { |
|
515 | { | |
521 | status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 ); |
|
516 | status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 ); | |
522 | if (status!=RTEMS_SUCCESSFUL) { |
|
517 | if (status!=RTEMS_SUCCESSFUL) { | |
523 | BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n") |
|
518 | BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n") | |
524 | } |
|
519 | } | |
525 | } |
|
520 | } | |
526 |
|
521 | |||
527 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
522 | if (status == RTEMS_SUCCESSFUL) // CWF3 | |
528 | { |
|
523 | { | |
529 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); |
|
524 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); | |
530 | if (status!=RTEMS_SUCCESSFUL) { |
|
525 | if (status!=RTEMS_SUCCESSFUL) { | |
531 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") |
|
526 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") | |
532 | } |
|
527 | } | |
533 | } |
|
528 | } | |
534 |
|
529 | |||
535 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
530 | if (status == RTEMS_SUCCESSFUL) // CWF2 | |
536 | { |
|
531 | { | |
537 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); |
|
532 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); | |
538 | if (status!=RTEMS_SUCCESSFUL) { |
|
533 | if (status!=RTEMS_SUCCESSFUL) { | |
539 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") |
|
534 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") | |
540 | } |
|
535 | } | |
541 | } |
|
536 | } | |
542 |
|
537 | |||
543 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
538 | if (status == RTEMS_SUCCESSFUL) // CWF1 | |
544 | { |
|
539 | { | |
545 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); |
|
540 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); | |
546 | if (status!=RTEMS_SUCCESSFUL) { |
|
541 | if (status!=RTEMS_SUCCESSFUL) { | |
547 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") |
|
542 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") | |
548 | } |
|
543 | } | |
549 | } |
|
544 | } | |
550 | return status; |
|
545 | return status; | |
551 | } |
|
546 | } | |
552 |
|
547 | |||
553 | rtems_status_code create_message_queues( void ) // create the two message queues used in the software |
|
548 | rtems_status_code create_message_queues( void ) // create the two message queues used in the software | |
554 | { |
|
549 | { | |
555 | rtems_status_code status_recv; |
|
550 | rtems_status_code status_recv; | |
556 | rtems_status_code status_send; |
|
551 | rtems_status_code status_send; | |
557 | rtems_status_code ret; |
|
552 | rtems_status_code ret; | |
558 | rtems_id queue_id; |
|
553 | rtems_id queue_id; | |
559 |
|
554 | |||
560 | // create the queue for handling valid TCs |
|
555 | // create the queue for handling valid TCs | |
561 | status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV], |
|
556 | status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV], | |
562 | ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE, |
|
557 | ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE, | |
563 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
558 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
564 | if ( status_recv != RTEMS_SUCCESSFUL ) { |
|
559 | if ( status_recv != RTEMS_SUCCESSFUL ) { | |
565 | PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv) |
|
560 | PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv) | |
566 | } |
|
561 | } | |
567 |
|
562 | |||
568 | // create the queue for handling TM packet sending |
|
563 | // create the queue for handling TM packet sending | |
569 | status_send = rtems_message_queue_create( misc_name[QUEUE_SEND], |
|
564 | status_send = rtems_message_queue_create( misc_name[QUEUE_SEND], | |
570 | ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_MAX_SIZE, |
|
565 | ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_MAX_SIZE, | |
571 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
566 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
572 | if ( status_send != RTEMS_SUCCESSFUL ) { |
|
567 | if ( status_send != RTEMS_SUCCESSFUL ) { | |
573 | PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send) |
|
568 | PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send) | |
574 | } |
|
569 | } | |
575 |
|
570 | |||
576 | if ( status_recv != RTEMS_SUCCESSFUL ) |
|
571 | if ( status_recv != RTEMS_SUCCESSFUL ) | |
577 | { |
|
572 | { | |
578 | ret = status_recv; |
|
573 | ret = status_recv; | |
579 | } |
|
574 | } | |
580 | else |
|
575 | else | |
581 | { |
|
576 | { | |
582 | ret = status_send; |
|
577 | ret = status_send; | |
583 | } |
|
578 | } | |
584 |
|
579 | |||
585 | return ret; |
|
580 | return ret; | |
586 | } |
|
581 | } | |
|
582 |
@@ -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,1225 | |||||
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 |
|
738 | // SET PACKET SEQUENCE COUNTER | |
736 | increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid ); |
|
739 | increment_seq_counter_source_id( headerSWF[ i ].packetSequenceControl, sid ); | |
737 | // SET PACKET TIME |
|
740 | // SET PACKET TIME | |
738 | headerSWF[ i ].acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
741 | 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); |
|
742 | 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); |
|
743 | headerSWF[ i ].acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
741 | headerSWF[ i ].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time); |
|
744 | headerSWF[ i ].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time); | |
742 | headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
745 | headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
743 | headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time); |
|
746 | headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time); | |
744 | headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
747 | 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); |
|
748 | 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); |
|
749 | headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
747 | headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
750 | headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time); | |
748 | headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
751 | headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
749 | headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time); |
|
752 | headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time); | |
750 | // SEND PACKET |
|
753 | // SEND PACKET | |
751 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE); |
|
754 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_SPW_IOCTL_SEND_SIZE); | |
752 | if (status != RTEMS_SUCCESSFUL) { |
|
755 | if (status != RTEMS_SUCCESSFUL) { | |
753 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
756 | printf("%d-%d, ERR %d\n", sid, i, (int) status); | |
754 | ret = LFR_DEFAULT; |
|
757 | ret = LFR_DEFAULT; | |
755 | } |
|
758 | } | |
756 | rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds |
|
759 | rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds | |
757 | } |
|
760 | } | |
758 |
|
761 | |||
759 | return ret; |
|
762 | return ret; | |
760 | } |
|
763 | } | |
761 |
|
764 | |||
762 | int send_waveform_CWF(volatile int *waveform, unsigned int sid, |
|
765 | int send_waveform_CWF(volatile int *waveform, unsigned int sid, | |
763 | Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) |
|
766 | Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) | |
764 | { |
|
767 | { | |
765 | /** This function sends CWF CCSDS packets (F2, F1 or F0). |
|
768 | /** This function sends CWF CCSDS packets (F2, F1 or F0). | |
766 | * |
|
769 | * | |
767 | * @param waveform points to the buffer containing the data that will be send. |
|
770 | * @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. |
|
771 | * @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. |
|
772 | * @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 |
|
773 | * @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. |
|
774 | * contain information to setup the transmission of the data packets. | |
772 | * |
|
775 | * | |
773 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. |
|
776 | * One group of 2048 samples is sent as 7 consecutive packets, 6 packets containing 340 blocks and 8 packets containing 8 blocks. | |
774 | * |
|
777 | * | |
775 | */ |
|
778 | */ | |
776 |
|
779 | |||
777 | unsigned int i; |
|
780 | unsigned int i; | |
778 | int ret; |
|
781 | int ret; | |
779 | rtems_status_code status; |
|
782 | rtems_status_code status; | |
780 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
783 | spw_ioctl_pkt_send spw_ioctl_send_CWF; | |
781 |
|
784 | |||
782 | spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header |
|
785 | 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; |
|
786 | spw_ioctl_send_CWF.options = 0; | |
784 |
|
787 | |||
785 | ret = LFR_DEFAULT; |
|
788 | ret = LFR_DEFAULT; | |
786 |
|
789 | |||
787 | for (i=0; i<7; i++) // send waveform |
|
790 | for (i=0; i<7; i++) // send waveform | |
788 | { |
|
791 | { | |
789 | int coarseTime = 0x00; |
|
792 | int coarseTime = 0x00; | |
790 | int fineTime = 0x00; |
|
793 | int fineTime = 0x00; | |
791 | spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ]; |
|
794 | spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ]; | |
792 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; |
|
795 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; | |
793 | // BUILD THE DATA |
|
796 | // BUILD THE DATA | |
794 | if (i==6) { |
|
797 | if (i==6) { | |
795 | spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_SWF_BLK; |
|
798 | spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_SWF_BLK; | |
796 | } |
|
799 | } | |
797 | else { |
|
800 | else { | |
798 | spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_SWF_BLK; |
|
801 | spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_SWF_BLK; | |
799 | } |
|
802 | } | |
800 | // SET PACKET SEQUENCE COUNTER |
|
803 | // SET PACKET SEQUENCE COUNTER | |
801 | increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid ); |
|
804 | increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, sid ); | |
802 | // SET PACKET TIME |
|
805 | // SET PACKET TIME | |
803 | coarseTime = time_management_regs->coarse_time; |
|
806 | coarseTime = time_management_regs->coarse_time; | |
804 | fineTime = time_management_regs->fine_time; |
|
807 | fineTime = time_management_regs->fine_time; | |
805 | headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24); |
|
808 | headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24); | |
806 | headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16); |
|
809 | headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16); | |
807 | headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8); |
|
810 | headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8); | |
808 | headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime); |
|
811 | headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime); | |
809 | headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8); |
|
812 | headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8); | |
810 | headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime); |
|
813 | headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime); | |
811 | headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24); |
|
814 | headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24); | |
812 | headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16); |
|
815 | headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16); | |
813 | headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8); |
|
816 | headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8); | |
814 | headerCWF[ i ].time[3] = (unsigned char) (coarseTime); |
|
817 | headerCWF[ i ].time[3] = (unsigned char) (coarseTime); | |
815 | headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8); |
|
818 | headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8); | |
816 | headerCWF[ i ].time[5] = (unsigned char) (fineTime); |
|
819 | headerCWF[ i ].time[5] = (unsigned char) (fineTime); | |
817 | // SEND PACKET |
|
820 | // SEND PACKET | |
818 | if (sid == SID_NORM_CWF_F3) |
|
821 | if (sid == SID_NORM_CWF_F3) | |
819 | { |
|
822 | { | |
820 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
823 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); | |
821 | if (status != RTEMS_SUCCESSFUL) { |
|
824 | if (status != RTEMS_SUCCESSFUL) { | |
822 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
825 | printf("%d-%d, ERR %d\n", sid, i, (int) status); | |
823 | ret = LFR_DEFAULT; |
|
826 | ret = LFR_DEFAULT; | |
824 | } |
|
827 | } | |
825 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); |
|
828 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); | |
826 | } |
|
829 | } | |
827 | else |
|
830 | else | |
828 | { |
|
831 | { | |
829 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
832 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); | |
830 | if (status != RTEMS_SUCCESSFUL) { |
|
833 | if (status != RTEMS_SUCCESSFUL) { | |
831 | printf("%d-%d, ERR %d\n", sid, i, (int) status); |
|
834 | printf("%d-%d, ERR %d\n", sid, i, (int) status); | |
832 | ret = LFR_DEFAULT; |
|
835 | ret = LFR_DEFAULT; | |
833 | } |
|
836 | } | |
834 | } |
|
837 | } | |
835 | } |
|
838 | } | |
836 |
|
839 | |||
837 | return ret; |
|
840 | return ret; | |
838 | } |
|
841 | } | |
839 |
|
842 | |||
840 | int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) |
|
843 | int send_waveform_CWF3_light(volatile int *waveform, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id) | |
841 | { |
|
844 | { | |
842 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. |
|
845 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. | |
843 | * |
|
846 | * | |
844 | * @param waveform points to the buffer containing the data that will be send. |
|
847 | * @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. |
|
848 | * @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 |
|
849 | * @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. |
|
850 | * contain information to setup the transmission of the data packets. | |
848 | * |
|
851 | * | |
849 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer |
|
852 | * 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. |
|
853 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. | |
851 | * |
|
854 | * | |
852 | */ |
|
855 | */ | |
853 |
|
856 | |||
854 | unsigned int i; |
|
857 | unsigned int i; | |
855 | int ret; |
|
858 | int ret; | |
856 | rtems_status_code status; |
|
859 | rtems_status_code status; | |
857 | spw_ioctl_pkt_send spw_ioctl_send_CWF; |
|
860 | spw_ioctl_pkt_send spw_ioctl_send_CWF; | |
858 | char *sample; |
|
861 | char *sample; | |
859 |
|
862 | |||
860 | spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header |
|
863 | 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; |
|
864 | spw_ioctl_send_CWF.options = 0; | |
862 |
|
865 | |||
863 | ret = LFR_DEFAULT; |
|
866 | ret = LFR_DEFAULT; | |
864 |
|
867 | |||
865 | //********************** |
|
868 | //********************** | |
866 | // BUILD CWF3_light DATA |
|
869 | // BUILD CWF3_light DATA | |
867 | for ( i=0; i< 2048; i++) |
|
870 | for ( i=0; i< 2048; i++) | |
868 | { |
|
871 | { | |
869 | sample = (char*) &waveform[ i * NB_WORDS_SWF_BLK ]; |
|
872 | sample = (char*) &waveform[ i * NB_WORDS_SWF_BLK ]; | |
870 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ]; |
|
873 | 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 ]; |
|
874 | 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 ]; |
|
875 | 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 ]; |
|
876 | 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 ]; |
|
877 | 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 ]; |
|
878 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ]; | |
876 | } |
|
879 | } | |
877 |
|
880 | |||
878 | //********************* |
|
881 | //********************* | |
879 | // SEND CWF3_light DATA |
|
882 | // SEND CWF3_light DATA | |
880 |
|
883 | |||
881 | for (i=0; i<7; i++) // send waveform |
|
884 | for (i=0; i<7; i++) // send waveform | |
882 | { |
|
885 | { | |
883 | int coarseTime = 0x00; |
|
886 | int coarseTime = 0x00; | |
884 | int fineTime = 0x00; |
|
887 | int fineTime = 0x00; | |
885 | spw_ioctl_send_CWF.data = (char*) &wf_cont_f3_light[ (i * 340 * NB_BYTES_CWF3_LIGHT_BLK) ]; |
|
888 | 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 ]; |
|
889 | spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ]; | |
887 | // BUILD THE DATA |
|
890 | // BUILD THE DATA | |
888 | if ( i == WFRM_INDEX_OF_LAST_PACKET ) { |
|
891 | if ( i == WFRM_INDEX_OF_LAST_PACKET ) { | |
889 | spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_CWF3_LIGHT_BLK; |
|
892 | spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_CWF3_LIGHT_BLK; | |
890 | } |
|
893 | } | |
891 | else { |
|
894 | else { | |
892 | spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_CWF3_LIGHT_BLK; |
|
895 | spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_CWF3_LIGHT_BLK; | |
893 | } |
|
896 | } | |
894 | // SET PACKET SEQUENCE COUNTER |
|
897 | // SET PACKET SEQUENCE COUNTER | |
895 | increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 ); |
|
898 | increment_seq_counter_source_id( headerCWF[ i ].packetSequenceControl, SID_NORM_CWF_F3 ); | |
896 | // SET PACKET TIME |
|
899 | // SET PACKET TIME | |
897 | coarseTime = time_management_regs->coarse_time; |
|
900 | coarseTime = time_management_regs->coarse_time; | |
898 | fineTime = time_management_regs->fine_time; |
|
901 | fineTime = time_management_regs->fine_time; | |
899 | headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24); |
|
902 | headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24); | |
900 | headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16); |
|
903 | headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16); | |
901 | headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8); |
|
904 | headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8); | |
902 | headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime); |
|
905 | headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime); | |
903 | headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8); |
|
906 | headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8); | |
904 | headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime); |
|
907 | headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime); | |
905 | headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24); |
|
908 | headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24); | |
906 | headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16); |
|
909 | headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16); | |
907 | headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8); |
|
910 | headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8); | |
908 | headerCWF[ i ].time[3] = (unsigned char) (coarseTime); |
|
911 | headerCWF[ i ].time[3] = (unsigned char) (coarseTime); | |
909 | headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8); |
|
912 | headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8); | |
910 | headerCWF[ i ].time[5] = (unsigned char) (fineTime); |
|
913 | headerCWF[ i ].time[5] = (unsigned char) (fineTime); | |
911 | // SEND PACKET |
|
914 | // SEND PACKET | |
912 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); |
|
915 | status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF)); | |
913 | if (status != RTEMS_SUCCESSFUL) { |
|
916 | if (status != RTEMS_SUCCESSFUL) { | |
914 | printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status); |
|
917 | printf("%d-%d, ERR %d\n", SID_NORM_CWF_F3, i, (int) status); | |
915 | ret = LFR_DEFAULT; |
|
918 | ret = LFR_DEFAULT; | |
916 | } |
|
919 | } | |
917 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); |
|
920 | rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS); | |
918 | } |
|
921 | } | |
919 |
|
922 | |||
920 | return ret; |
|
923 | return ret; | |
921 | } |
|
924 | } | |
922 |
|
925 | |||
923 |
|
926 | |||
924 | //************** |
|
927 | //************** | |
925 | // wfp registers |
|
928 | // wfp registers | |
926 | void set_wfp_data_shaping() |
|
929 | void set_wfp_data_shaping() | |
927 | { |
|
930 | { | |
928 | /** This function sets the data_shaping register of the waveform picker module. |
|
931 | /** This function sets the data_shaping register of the waveform picker module. | |
929 | * |
|
932 | * | |
930 | * The value is read from one field of the parameter_dump_packet structure:\n |
|
933 | * The value is read from one field of the parameter_dump_packet structure:\n | |
931 | * bw_sp0_sp1_r0_r1 |
|
934 | * bw_sp0_sp1_r0_r1 | |
932 | * |
|
935 | * | |
933 | */ |
|
936 | */ | |
934 |
|
937 | |||
935 | unsigned char data_shaping; |
|
938 | unsigned char data_shaping; | |
936 |
|
939 | |||
937 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register |
|
940 | // 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] |
|
941 | // waveform picker : [R1 R0 SP1 SP0 BW] | |
939 |
|
942 | |||
940 | data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1; |
|
943 | data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1; | |
941 |
|
944 | |||
942 | #ifdef GSA |
|
945 | #ifdef GSA | |
943 | #else |
|
946 | #else | |
944 | waveform_picker_regs->data_shaping = |
|
947 | new_waveform_picker_regs->data_shaping = | |
945 | ( (data_shaping & 0x10) >> 4 ) // BW |
|
948 | ( (data_shaping & 0x10) >> 4 ) // BW | |
946 | + ( (data_shaping & 0x08) >> 2 ) // SP0 |
|
949 | + ( (data_shaping & 0x08) >> 2 ) // SP0 | |
947 | + ( (data_shaping & 0x04) ) // SP1 |
|
950 | + ( (data_shaping & 0x04) ) // SP1 | |
948 | + ( (data_shaping & 0x02) << 2 ) // R0 |
|
951 | + ( (data_shaping & 0x02) << 2 ) // R0 | |
949 | + ( (data_shaping & 0x01) << 4 ); // R1 |
|
952 | + ( (data_shaping & 0x01) << 4 ); // R1 | |
950 | #endif |
|
953 | #endif | |
951 | } |
|
954 | } | |
952 |
|
955 | |||
953 | char set_wfp_delta_snapshot() |
|
956 | char set_wfp_delta_snapshot() | |
954 | { |
|
957 | { | |
955 | /** This function sets the delta_snapshot register of the waveform picker module. |
|
958 | /** This function sets the delta_snapshot register of the waveform picker module. | |
956 | * |
|
959 | * | |
957 | * The value is read from two (unsigned char) of the parameter_dump_packet structure: |
|
960 | * The value is read from two (unsigned char) of the parameter_dump_packet structure: | |
958 | * - sy_lfr_n_swf_p[0] |
|
961 | * - sy_lfr_n_swf_p[0] | |
959 | * - sy_lfr_n_swf_p[1] |
|
962 | * - sy_lfr_n_swf_p[1] | |
960 | * |
|
963 | * | |
961 | */ |
|
964 | */ | |
962 |
|
965 | |||
963 | char ret; |
|
966 | char ret; | |
964 | unsigned int delta_snapshot; |
|
967 | unsigned int delta_snapshot; | |
965 | unsigned int aux; |
|
968 | unsigned int aux; | |
966 |
|
969 | |||
967 | aux = 0; |
|
970 | aux = 0; | |
968 | ret = LFR_DEFAULT; |
|
971 | ret = LFR_DEFAULT; | |
969 |
|
972 | |||
970 | delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256 |
|
973 | delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256 | |
971 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; |
|
974 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; | |
972 |
|
975 | |||
973 | #ifdef GSA |
|
976 | #ifdef GSA | |
974 | #else |
|
977 | #else | |
975 | if ( delta_snapshot < MIN_DELTA_SNAPSHOT ) |
|
978 | if ( delta_snapshot < MIN_DELTA_SNAPSHOT ) | |
976 | { |
|
979 | { | |
977 | aux = MIN_DELTA_SNAPSHOT; |
|
980 | aux = MIN_DELTA_SNAPSHOT; | |
978 | ret = LFR_DEFAULT; |
|
981 | ret = LFR_DEFAULT; | |
979 | } |
|
982 | } | |
980 | else |
|
983 | else | |
981 | { |
|
984 | { | |
982 | aux = delta_snapshot ; |
|
985 | aux = delta_snapshot ; | |
983 | ret = LFR_SUCCESSFUL; |
|
986 | ret = LFR_SUCCESSFUL; | |
984 | } |
|
987 | } | |
985 | waveform_picker_regs->delta_snapshot = aux - 1; // max 2 bytes |
|
988 | new_waveform_picker_regs->delta_snapshot = aux - 1; // max 2 bytes | |
986 | #endif |
|
989 | #endif | |
987 |
|
990 | |||
988 | return ret; |
|
991 | return ret; | |
989 | } |
|
992 | } | |
990 |
|
993 | |||
991 | void set_wfp_burst_enable_register( unsigned char mode) |
|
994 | void set_wfp_burst_enable_register( unsigned char mode) | |
992 | { |
|
995 | { | |
993 | /** This function sets the waveform picker burst_enable register depending on the mode. |
|
996 | /** This function sets the waveform picker burst_enable register depending on the mode. | |
994 | * |
|
997 | * | |
995 | * @param mode is the LFR mode to launch. |
|
998 | * @param mode is the LFR mode to launch. | |
996 | * |
|
999 | * | |
997 | * The burst bits shall be before the enable bits. |
|
1000 | * The burst bits shall be before the enable bits. | |
998 | * |
|
1001 | * | |
999 | */ |
|
1002 | */ | |
1000 |
|
1003 | |||
1001 | #ifdef GSA |
|
1004 | #ifdef GSA | |
1002 | #else |
|
1005 | #else | |
1003 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 |
|
1006 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 | |
1004 | // the burst bits shall be set first, before the enable bits |
|
1007 | // the burst bits shall be set first, before the enable bits | |
1005 | switch(mode) { |
|
1008 | switch(mode) { | |
1006 | case(LFR_MODE_NORMAL): |
|
1009 | case(LFR_MODE_NORMAL): | |
1007 | waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enable |
|
1010 | 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 |
|
1011 | // new_waveform_picker_regs->run_burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0 | |
|
1012 | new_waveform_picker_regs->run_burst_enable = 0x07; // [0000 0111] enable f2 f1 f0 | |||
1009 | break; |
|
1013 | break; | |
1010 | case(LFR_MODE_BURST): |
|
1014 | case(LFR_MODE_BURST): | |
1011 | waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
1015 | 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 |
|
1016 | new_waveform_picker_regs->run_burst_enable = new_waveform_picker_regs->run_burst_enable | 0x04; // [0100] enable f2 | |
1013 | break; |
|
1017 | break; | |
1014 | case(LFR_MODE_SBM1): |
|
1018 | case(LFR_MODE_SBM1): | |
1015 | waveform_picker_regs->burst_enable = 0x20; // [0010 0000] f1 burst enabled |
|
1019 | 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 |
|
1020 | new_waveform_picker_regs->run_burst_enable = new_waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 | |
1017 | break; |
|
1021 | break; | |
1018 | case(LFR_MODE_SBM2): |
|
1022 | case(LFR_MODE_SBM2): | |
1019 | waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
1023 | 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 |
|
1024 | new_waveform_picker_regs->run_burst_enable = new_waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 | |
1021 | break; |
|
1025 | break; | |
1022 | default: |
|
1026 | default: | |
1023 | waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled |
|
1027 | new_waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled | |
1024 | break; |
|
1028 | break; | |
1025 | } |
|
1029 | } | |
1026 | #endif |
|
1030 | #endif | |
1027 | } |
|
1031 | } | |
1028 |
|
1032 | |||
1029 | void reset_wfp_burst_enable() |
|
1033 | void reset_wfp_run_burst_enable() | |
1030 | { |
|
1034 | { | |
1031 | /** This function resets the waveform picker burst_enable register. |
|
1035 | /** This function resets the waveform picker burst_enable register. | |
1032 | * |
|
1036 | * | |
1033 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. |
|
1037 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. | |
1034 | * |
|
1038 | * | |
1035 | */ |
|
1039 | */ | |
1036 |
|
1040 | |||
1037 | #ifdef GSA |
|
1041 | #ifdef GSA | |
1038 | #else |
|
1042 | #else | |
1039 | waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 |
|
1043 | new_waveform_picker_regs->run_burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 | |
1040 | #endif |
|
1044 | #endif | |
1041 | } |
|
1045 | } | |
1042 |
|
1046 | |||
1043 | void reset_wfp_status() |
|
1047 | void reset_wfp_status() | |
1044 | { |
|
1048 | { | |
1045 | /** This function resets the waveform picker status register. |
|
1049 | /** This function resets the waveform picker status register. | |
1046 | * |
|
1050 | * | |
1047 | * All status bits are set to 0 [new_err full_err full]. |
|
1051 | * All status bits are set to 0 [new_err full_err full]. | |
1048 | * |
|
1052 | * | |
1049 | */ |
|
1053 | */ | |
1050 |
|
1054 | |||
1051 | #ifdef GSA |
|
1055 | #ifdef GSA | |
1052 | #else |
|
1056 | #else | |
1053 | waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 |
|
1057 | new_waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 | |
1054 | #endif |
|
1058 | #endif | |
1055 | } |
|
1059 | } | |
1056 |
|
1060 | |||
1057 | void reset_waveform_picker_regs() |
|
1061 | void reset_new_waveform_picker_regs() | |
1058 | { |
|
1062 | { | |
1059 | /** This function resets the waveform picker module registers. |
|
1063 | /** This function resets the waveform picker module registers. | |
1060 |
|
|
1064 | * | |
1061 |
|
|
1065 | * The registers affected by this function are located at the following offset addresses: | |
1062 |
|
|
1066 | * - 0x00 data_shaping | |
1063 |
|
|
1067 | * - 0x04 run_burst_enable | |
1064 |
|
|
1068 | * - 0x08 addr_data_f0 | |
1065 |
|
|
1069 | * - 0x0C addr_data_f1 | |
1066 |
|
|
1070 | * - 0x10 addr_data_f2 | |
1067 |
|
|
1071 | * - 0x14 addr_data_f3 | |
1068 |
|
|
1072 | * - 0x18 status | |
1069 |
|
|
1073 | * - 0x1C delta_snapshot | |
1070 |
|
|
1074 | * - 0x20 delta_f0 | |
1071 |
|
|
1075 | * - 0x24 delta_f0_2 | |
1072 |
|
|
1076 | * - 0x28 delta_f1 | |
1073 | * - 0x2C nb_snapshot |
|
1077 | * - 0x2c delta_f2 | |
|
1078 | * - 0x30 nb_data_by_buffer | |||
|
1079 | * - 0x34 nb_snapshot_param | |||
|
1080 | * - 0x38 start_date | |||
1074 |
|
|
1081 | * | |
1075 |
|
|
1082 | */ | |
1076 |
|
1083 | |||
1077 | #ifdef GSA |
|
1084 | new_waveform_picker_regs->data_shaping = 0x01; // 0x00 *** R1 R0 SP1 SP0 BW | |
1078 | #else |
|
1085 | new_waveform_picker_regs->run_burst_enable = 0x00; // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ] | |
1079 | reset_wfp_burst_enable(); |
|
1086 | new_waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); // 0x08 | |
1080 | reset_wfp_status(); |
|
1087 | new_waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); // 0x0c | |
1081 | // set buffer addresses |
|
1088 | new_waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); // 0x10 | |
1082 |
waveform_picker_regs->addr_data_f |
|
1089 | new_waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); // 0x14 | |
1083 | waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); // |
|
1090 | new_waveform_picker_regs->status = 0x00; // 0x18 | |
1084 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); // |
|
1091 | // new_waveform_picker_regs->delta_snapshot = 0x12800; // 0x1c 296 * 256 = 75776 | |
1085 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); // |
|
1092 | new_waveform_picker_regs->delta_snapshot = 0x1000; // 0x1c 16 * 256 = 4096 | |
1086 | // set other parameters |
|
1093 | new_waveform_picker_regs->delta_f0 = 0x3f5; // 0x20 *** 1013 | |
1087 | set_wfp_data_shaping(); |
|
1094 | new_waveform_picker_regs->delta_f0_2 = 0x7; // 0x24 *** 7 | |
1088 | set_wfp_delta_snapshot(); // time in seconds between two snapshots |
|
1095 | new_waveform_picker_regs->delta_f1 = 0x3c0; // 0x28 *** 960 | |
1089 |
waveform_picker_regs->delta_f2 |
|
1096 | // new_waveform_picker_regs->delta_f2 = 0x12200; // 0x2c *** 74240 | |
1090 |
waveform_picker_regs->delta_f2 |
|
1097 | new_waveform_picker_regs->delta_f2 = 0xc00; // 0x2c *** 12 * 256 = 2048 | |
1091 | waveform_picker_regs->nb_burst_available = 0x180; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets) |
|
1098 | new_waveform_picker_regs->nb_data_by_buffer = 0x1802; // 0x30 *** 2048 * 3 + 2 | |
1092 |
waveform_picker_regs-> |
|
1099 | new_waveform_picker_regs->snapshot_param = 0x7ff; // 0x34 *** 2048 -1 | |
1093 | #endif |
|
1100 | new_waveform_picker_regs->start_date = 0x00; // 0x38 | |
1094 | } |
|
1101 | } | |
1095 |
|
1102 | |||
1096 | //***************** |
|
1103 | //***************** | |
1097 | // local parameters |
|
1104 | // local parameters | |
1098 | void set_local_sbm1_nb_cwf_max() |
|
1105 | void set_local_sbm1_nb_cwf_max() | |
1099 | { |
|
1106 | { | |
1100 | /** This function sets the value of the sbm1_nb_cwf_max local parameter. |
|
1107 | /** This function sets the value of the sbm1_nb_cwf_max local parameter. | |
1101 | * |
|
1108 | * | |
1102 | * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n |
|
1109 | * 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 |
|
1110 | * 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) |
|
1111 | * (2 snapshots of 2048 points per seconds) * (period of the NORM snashots) - 8 s (duration of the f2 snapshot) | |
1105 | * |
|
1112 | * | |
1106 | */ |
|
1113 | */ | |
1107 | param_local.local_sbm1_nb_cwf_max = 2 * |
|
1114 | param_local.local_sbm1_nb_cwf_max = 2 * | |
1108 | (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256 |
|
1115 | (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 |
|
1116 | + parameter_dump_packet.sy_lfr_n_swf_p[1]) - 8; // 16 CWF1 parts during 1 SWF2 | |
1110 | } |
|
1117 | } | |
1111 |
|
1118 | |||
1112 | void set_local_sbm2_nb_cwf_max() |
|
1119 | void set_local_sbm2_nb_cwf_max() | |
1113 | { |
|
1120 | { | |
1114 | /** This function sets the value of the sbm1_nb_cwf_max local parameter. |
|
1121 | /** This function sets the value of the sbm1_nb_cwf_max local parameter. | |
1115 | * |
|
1122 | * | |
1116 | * The sbm1_nb_cwf_max parameter counts the number of CWF_F1 records that have been sent.\n |
|
1123 | * 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 |
|
1124 | * 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) |
|
1125 | * (period of the NORM snashots) / (8 seconds per snapshot at f2 = 256 Hz) | |
1119 | * |
|
1126 | * | |
1120 | */ |
|
1127 | */ | |
1121 |
|
1128 | |||
1122 | param_local.local_sbm2_nb_cwf_max = (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256 |
|
1129 | 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; |
|
1130 | + parameter_dump_packet.sy_lfr_n_swf_p[1]) / 8; | |
1124 | } |
|
1131 | } | |
1125 |
|
1132 | |||
1126 | void set_local_nb_interrupt_f0_MAX() |
|
1133 | void set_local_nb_interrupt_f0_MAX() | |
1127 | { |
|
1134 | { | |
1128 | /** This function sets the value of the nb_interrupt_f0_MAX local parameter. |
|
1135 | /** This function sets the value of the nb_interrupt_f0_MAX local parameter. | |
1129 | * |
|
1136 | * | |
1130 | * This parameter is used for the SM validation only.\n |
|
1137 | * 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 |
|
1138 | * The software waits param_local.local_nb_interrupt_f0_MAX interruptions from the spectral matrices | |
1132 | * module before launching a basic processing. |
|
1139 | * module before launching a basic processing. | |
1133 | * |
|
1140 | * | |
1134 | */ |
|
1141 | */ | |
1135 |
|
1142 | |||
1136 | param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256 |
|
1143 | 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; |
|
1144 | + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100; | |
1138 | } |
|
1145 | } | |
1139 |
|
1146 | |||
1140 | void reset_local_sbm1_nb_cwf_sent() |
|
1147 | void reset_local_sbm1_nb_cwf_sent() | |
1141 | { |
|
1148 | { | |
1142 | /** This function resets the value of the sbm1_nb_cwf_sent local parameter. |
|
1149 | /** This function resets the value of the sbm1_nb_cwf_sent local parameter. | |
1143 | * |
|
1150 | * | |
1144 | * The sbm1_nb_cwf_sent parameter counts the number of CWF_F1 records that have been sent.\n |
|
1151 | * 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. |
|
1152 | * This parameter is used to send CWF_F1 data as normal data when the SBM1 is active. | |
1146 | * |
|
1153 | * | |
1147 | */ |
|
1154 | */ | |
1148 |
|
1155 | |||
1149 | param_local.local_sbm1_nb_cwf_sent = 0; |
|
1156 | param_local.local_sbm1_nb_cwf_sent = 0; | |
1150 | } |
|
1157 | } | |
1151 |
|
1158 | |||
1152 | void reset_local_sbm2_nb_cwf_sent() |
|
1159 | void reset_local_sbm2_nb_cwf_sent() | |
1153 | { |
|
1160 | { | |
1154 | /** This function resets the value of the sbm2_nb_cwf_sent local parameter. |
|
1161 | /** This function resets the value of the sbm2_nb_cwf_sent local parameter. | |
1155 | * |
|
1162 | * | |
1156 | * The sbm2_nb_cwf_sent parameter counts the number of CWF_F2 records that have been sent.\n |
|
1163 | * 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. |
|
1164 | * This parameter is used to send CWF_F2 data as normal data when the SBM2 mode is active. | |
1158 | * |
|
1165 | * | |
1159 | */ |
|
1166 | */ | |
1160 |
|
1167 | |||
1161 | param_local.local_sbm2_nb_cwf_sent = 0; |
|
1168 | param_local.local_sbm2_nb_cwf_sent = 0; | |
1162 | } |
|
1169 | } | |
1163 |
|
1170 | |||
1164 | rtems_id get_pkts_queue_id( void ) |
|
1171 | rtems_id get_pkts_queue_id( void ) | |
1165 | { |
|
1172 | { | |
1166 | rtems_id queue_id; |
|
1173 | rtems_id queue_id; | |
1167 | rtems_status_code status; |
|
1174 | rtems_status_code status; | |
1168 | rtems_name queue_send_name; |
|
1175 | rtems_name queue_send_name; | |
1169 |
|
1176 | |||
1170 | queue_send_name = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
1177 | queue_send_name = rtems_build_name( 'Q', '_', 'S', 'D' ); | |
1171 |
|
1178 | |||
1172 | status = rtems_message_queue_ident( queue_send_name, 0, &queue_id ); |
|
1179 | status = rtems_message_queue_ident( queue_send_name, 0, &queue_id ); | |
1173 | if (status != RTEMS_SUCCESSFUL) |
|
1180 | if (status != RTEMS_SUCCESSFUL) | |
1174 | { |
|
1181 | { | |
1175 | PRINTF1("in get_pkts_queue_id *** ERR %d\n", status) |
|
1182 | PRINTF1("in get_pkts_queue_id *** ERR %d\n", status) | |
1176 | } |
|
1183 | } | |
1177 | return queue_id; |
|
1184 | return queue_id; | |
1178 | } |
|
1185 | } | |
1179 |
|
1186 | |||
1180 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ) |
|
1187 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ) | |
1181 | { |
|
1188 | { | |
1182 | unsigned short *sequence_cnt; |
|
1189 | unsigned short *sequence_cnt; | |
1183 | unsigned short segmentation_grouping_flag; |
|
1190 | unsigned short segmentation_grouping_flag; | |
1184 | unsigned short new_packet_sequence_control; |
|
1191 | unsigned short new_packet_sequence_control; | |
1185 |
|
1192 | |||
1186 |
if ( (sid ==SID_NORM_SWF_F0) |
|
1193 | if ( (sid ==SID_NORM_SWF_F0) || (sid ==SID_NORM_SWF_F1) || (sid ==SID_NORM_SWF_F2) | |
1187 |
|
|
1194 | || (sid ==SID_NORM_CWF_F3) || (sid ==SID_BURST_CWF_F2) ) | |
1188 | { |
|
1195 | { | |
1189 | sequence_cnt = &sequenceCounters_SCIENCE_NORMAL_BURST; |
|
1196 | sequence_cnt = &sequenceCounters_SCIENCE_NORMAL_BURST; | |
1190 | } |
|
1197 | } | |
1191 | else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) ) |
|
1198 | else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) ) | |
1192 | { |
|
1199 | { | |
1193 | sequence_cnt = &sequenceCounters_SCIENCE_SBM1_SBM2; |
|
1200 | sequence_cnt = &sequenceCounters_SCIENCE_SBM1_SBM2; | |
1194 | } |
|
1201 | } | |
1195 | else |
|
1202 | else | |
1196 | { |
|
1203 | { | |
1197 | sequence_cnt = &sequenceCounters_TC_EXE[ UNKNOWN ]; |
|
1204 | sequence_cnt = &sequenceCounters_TC_EXE[ UNKNOWN ]; | |
1198 | PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid) |
|
1205 | PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid) | |
1199 | } |
|
1206 | } | |
1200 |
|
1207 | |||
1201 |
segmentation_grouping_flag |
|
1208 | segmentation_grouping_flag = (packet_sequence_control[ 0 ] & 0xc0) << 8; | |
1202 |
*sequence_cnt |
|
1209 | *sequence_cnt = (*sequence_cnt) & 0x3fff; | |
1203 |
|
1210 | |||
1204 | new_packet_sequence_control = segmentation_grouping_flag | *sequence_cnt ; |
|
1211 | new_packet_sequence_control = segmentation_grouping_flag | *sequence_cnt ; | |
1205 |
|
1212 | |||
1206 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); |
|
1213 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); | |
1207 |
packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control |
|
1214 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); | |
1208 |
|
1215 | |||
1209 |
// increment the se |
|
1216 | // increment the sequence counter for the next packet | |
1210 | if ( *sequence_cnt < SEQ_CNT_MAX) |
|
1217 | if ( *sequence_cnt < SEQ_CNT_MAX) | |
1211 | { |
|
1218 | { | |
1212 | *sequence_cnt = *sequence_cnt + 1; |
|
1219 | *sequence_cnt = *sequence_cnt + 1; | |
1213 | } |
|
1220 | } | |
1214 | else |
|
1221 | else | |
1215 | { |
|
1222 | { | |
1216 | *sequence_cnt = 0; |
|
1223 | *sequence_cnt = 0; | |
1217 | } |
|
1224 | } | |
1218 |
|
||||
1219 | } |
|
1225 | } |
General Comments 0
You need to be logged in to leave comments.
Login now