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