@@ -1,124 +1,124 | |||||
1 | TEMPLATE = app |
|
1 | TEMPLATE = app | |
2 | # CONFIG += console v8 sim |
|
2 | # CONFIG += console v8 sim | |
3 | # CONFIG options = |
|
3 | # CONFIG options = | |
4 | # verbose |
|
4 | # verbose | |
5 | # boot_messages |
|
5 | # boot_messages | |
6 | # debug_messages |
|
6 | # debug_messages | |
7 | # cpu_usage_report |
|
7 | # cpu_usage_report | |
8 | # stack_report |
|
8 | # stack_report | |
9 | # vhdl_dev |
|
9 | # vhdl_dev | |
10 | # debug_tch |
|
10 | # debug_tch | |
11 | # lpp_dpu_destid REMOVE BEFORE DELIVERY TO LESIA |
|
11 | # lpp_dpu_destid /!\ REMOVE BEFORE DELIVERY TO LESIA /!\ | |
12 | # debug_watchdog |
|
12 | # debug_watchdog | |
13 | CONFIG += console verbose lpp_dpu_destid |
|
13 | CONFIG += console verbose lpp_dpu_destid | |
14 | CONFIG -= qt |
|
14 | CONFIG -= qt | |
15 |
|
15 | |||
16 | include(./sparc.pri) |
|
16 | include(./sparc.pri) | |
17 |
|
17 | |||
18 | # flight software version |
|
18 | # flight software version | |
19 | SWVERSION=-1-0 |
|
19 | SWVERSION=-1-0 | |
20 | DEFINES += SW_VERSION_N1=3 # major |
|
20 | DEFINES += SW_VERSION_N1=3 # major | |
21 | DEFINES += SW_VERSION_N2=0 # minor |
|
21 | DEFINES += SW_VERSION_N2=0 # minor | |
22 | DEFINES += SW_VERSION_N3=0 # patch |
|
22 | DEFINES += SW_VERSION_N3=0 # patch | |
23 | DEFINES += SW_VERSION_N4=14 # internal |
|
23 | DEFINES += SW_VERSION_N4=14 # internal | |
24 |
|
24 | |||
25 | # <GCOV> |
|
25 | # <GCOV> | |
26 | #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage |
|
26 | #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage | |
27 | #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc |
|
27 | #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc | |
28 | # </GCOV> |
|
28 | # </GCOV> | |
29 |
|
29 | |||
30 | # <CHANGE BEFORE FLIGHT> |
|
30 | # <CHANGE BEFORE FLIGHT> | |
31 | contains( CONFIG, lpp_dpu_destid ) { |
|
31 | contains( CONFIG, lpp_dpu_destid ) { | |
32 | DEFINES += LPP_DPU_DESTID |
|
32 | DEFINES += LPP_DPU_DESTID | |
33 | } |
|
33 | } | |
34 | # </CHANGE BEFORE FLIGHT> |
|
34 | # </CHANGE BEFORE FLIGHT> | |
35 |
|
35 | |||
36 | contains( CONFIG, debug_tch ) { |
|
36 | contains( CONFIG, debug_tch ) { | |
37 | DEFINES += DEBUG_TCH |
|
37 | DEFINES += DEBUG_TCH | |
38 | } |
|
38 | } | |
39 | DEFINES += MSB_FIRST_TCH |
|
39 | DEFINES += MSB_FIRST_TCH | |
40 |
|
40 | |||
41 | contains( CONFIG, vhdl_dev ) { |
|
41 | contains( CONFIG, vhdl_dev ) { | |
42 | DEFINES += VHDL_DEV |
|
42 | DEFINES += VHDL_DEV | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | contains( CONFIG, verbose ) { |
|
45 | contains( CONFIG, verbose ) { | |
46 | DEFINES += PRINT_MESSAGES_ON_CONSOLE |
|
46 | DEFINES += PRINT_MESSAGES_ON_CONSOLE | |
47 | } |
|
47 | } | |
48 |
|
48 | |||
49 | contains( CONFIG, debug_messages ) { |
|
49 | contains( CONFIG, debug_messages ) { | |
50 | DEFINES += DEBUG_MESSAGES |
|
50 | DEFINES += DEBUG_MESSAGES | |
51 | } |
|
51 | } | |
52 |
|
52 | |||
53 | contains( CONFIG, cpu_usage_report ) { |
|
53 | contains( CONFIG, cpu_usage_report ) { | |
54 | DEFINES += PRINT_TASK_STATISTICS |
|
54 | DEFINES += PRINT_TASK_STATISTICS | |
55 | } |
|
55 | } | |
56 |
|
56 | |||
57 | contains( CONFIG, stack_report ) { |
|
57 | contains( CONFIG, stack_report ) { | |
58 | DEFINES += PRINT_STACK_REPORT |
|
58 | DEFINES += PRINT_STACK_REPORT | |
59 | } |
|
59 | } | |
60 |
|
60 | |||
61 | contains( CONFIG, boot_messages ) { |
|
61 | contains( CONFIG, boot_messages ) { | |
62 | DEFINES += BOOT_MESSAGES |
|
62 | DEFINES += BOOT_MESSAGES | |
63 | } |
|
63 | } | |
64 |
|
64 | |||
65 | contains( CONFIG, debug_watchdog ) { |
|
65 | contains( CONFIG, debug_watchdog ) { | |
66 | DEFINES += DEBUG_WATCHDOG |
|
66 | DEFINES += DEBUG_WATCHDOG | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 | #doxygen.target = doxygen |
|
69 | #doxygen.target = doxygen | |
70 | #doxygen.commands = doxygen ../doc/Doxyfile |
|
70 | #doxygen.commands = doxygen ../doc/Doxyfile | |
71 | #QMAKE_EXTRA_TARGETS += doxygen |
|
71 | #QMAKE_EXTRA_TARGETS += doxygen | |
72 |
|
72 | |||
73 | TARGET = fsw |
|
73 | TARGET = fsw | |
74 |
|
74 | |||
75 | INCLUDEPATH += \ |
|
75 | INCLUDEPATH += \ | |
76 | $${PWD}/../src \ |
|
76 | $${PWD}/../src \ | |
77 | $${PWD}/../header \ |
|
77 | $${PWD}/../header \ | |
78 | $${PWD}/../header/lfr_common_headers \ |
|
78 | $${PWD}/../header/lfr_common_headers \ | |
79 | $${PWD}/../header/processing \ |
|
79 | $${PWD}/../header/processing \ | |
80 | $${PWD}/../LFR_basic-parameters |
|
80 | $${PWD}/../LFR_basic-parameters | |
81 |
|
81 | |||
82 | SOURCES += \ |
|
82 | SOURCES += \ | |
83 | ../src/wf_handler.c \ |
|
83 | ../src/wf_handler.c \ | |
84 | ../src/tc_handler.c \ |
|
84 | ../src/tc_handler.c \ | |
85 | ../src/fsw_misc.c \ |
|
85 | ../src/fsw_misc.c \ | |
86 | ../src/fsw_init.c \ |
|
86 | ../src/fsw_init.c \ | |
87 | ../src/fsw_globals.c \ |
|
87 | ../src/fsw_globals.c \ | |
88 | ../src/fsw_spacewire.c \ |
|
88 | ../src/fsw_spacewire.c \ | |
89 | ../src/tc_load_dump_parameters.c \ |
|
89 | ../src/tc_load_dump_parameters.c \ | |
90 | ../src/tm_lfr_tc_exe.c \ |
|
90 | ../src/tm_lfr_tc_exe.c \ | |
91 | ../src/tc_acceptance.c \ |
|
91 | ../src/tc_acceptance.c \ | |
92 | ../src/processing/fsw_processing.c \ |
|
92 | ../src/processing/fsw_processing.c \ | |
93 | ../src/processing/avf0_prc0.c \ |
|
93 | ../src/processing/avf0_prc0.c \ | |
94 | ../src/processing/avf1_prc1.c \ |
|
94 | ../src/processing/avf1_prc1.c \ | |
95 | ../src/processing/avf2_prc2.c \ |
|
95 | ../src/processing/avf2_prc2.c \ | |
96 | ../src/lfr_cpu_usage_report.c \ |
|
96 | ../src/lfr_cpu_usage_report.c \ | |
97 | ../LFR_basic-parameters/basic_parameters.c |
|
97 | ../LFR_basic-parameters/basic_parameters.c | |
98 |
|
98 | |||
99 | HEADERS += \ |
|
99 | HEADERS += \ | |
100 | ../header/wf_handler.h \ |
|
100 | ../header/wf_handler.h \ | |
101 | ../header/tc_handler.h \ |
|
101 | ../header/tc_handler.h \ | |
102 | ../header/grlib_regs.h \ |
|
102 | ../header/grlib_regs.h \ | |
103 | ../header/fsw_misc.h \ |
|
103 | ../header/fsw_misc.h \ | |
104 | ../header/fsw_init.h \ |
|
104 | ../header/fsw_init.h \ | |
105 | ../header/fsw_spacewire.h \ |
|
105 | ../header/fsw_spacewire.h \ | |
106 | ../header/tc_load_dump_parameters.h \ |
|
106 | ../header/tc_load_dump_parameters.h \ | |
107 | ../header/tm_lfr_tc_exe.h \ |
|
107 | ../header/tm_lfr_tc_exe.h \ | |
108 | ../header/tc_acceptance.h \ |
|
108 | ../header/tc_acceptance.h \ | |
109 | ../header/processing/fsw_processing.h \ |
|
109 | ../header/processing/fsw_processing.h \ | |
110 | ../header/processing/avf0_prc0.h \ |
|
110 | ../header/processing/avf0_prc0.h \ | |
111 | ../header/processing/avf1_prc1.h \ |
|
111 | ../header/processing/avf1_prc1.h \ | |
112 | ../header/processing/avf2_prc2.h \ |
|
112 | ../header/processing/avf2_prc2.h \ | |
113 | ../header/fsw_params_wf_handler.h \ |
|
113 | ../header/fsw_params_wf_handler.h \ | |
114 | ../header/lfr_cpu_usage_report.h \ |
|
114 | ../header/lfr_cpu_usage_report.h \ | |
115 | ../header/lfr_common_headers/ccsds_types.h \ |
|
115 | ../header/lfr_common_headers/ccsds_types.h \ | |
116 | ../header/lfr_common_headers/fsw_params.h \ |
|
116 | ../header/lfr_common_headers/fsw_params.h \ | |
117 | ../header/lfr_common_headers/fsw_params_nb_bytes.h \ |
|
117 | ../header/lfr_common_headers/fsw_params_nb_bytes.h \ | |
118 | ../header/lfr_common_headers/fsw_params_processing.h \ |
|
118 | ../header/lfr_common_headers/fsw_params_processing.h \ | |
119 | ../header/lfr_common_headers/TC_types.h \ |
|
119 | ../header/lfr_common_headers/TC_types.h \ | |
120 | ../header/lfr_common_headers/tm_byte_positions.h \ |
|
120 | ../header/lfr_common_headers/tm_byte_positions.h \ | |
121 | ../LFR_basic-parameters/basic_parameters.h \ |
|
121 | ../LFR_basic-parameters/basic_parameters.h \ | |
122 | ../LFR_basic-parameters/basic_parameters_params.h \ |
|
122 | ../LFR_basic-parameters/basic_parameters_params.h \ | |
123 | ../header/GscMemoryLPP.hpp |
|
123 | ../header/GscMemoryLPP.hpp | |
124 |
|
124 |
@@ -1,1606 +1,1606 | |||||
1 | /** Functions and tasks related to TeleCommand handling. |
|
1 | /** Functions and tasks related to TeleCommand handling. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle TeleCommands:\n |
|
6 | * A group of functions to handle TeleCommands:\n | |
7 | * action launching\n |
|
7 | * action launching\n | |
8 | * TC parsing\n |
|
8 | * TC parsing\n | |
9 | * ... |
|
9 | * ... | |
10 | * |
|
10 | * | |
11 | */ |
|
11 | */ | |
12 |
|
12 | |||
13 | #include "tc_handler.h" |
|
13 | #include "tc_handler.h" | |
14 | #include "math.h" |
|
14 | #include "math.h" | |
15 |
|
15 | |||
16 | //*********** |
|
16 | //*********** | |
17 | // RTEMS TASK |
|
17 | // RTEMS TASK | |
18 |
|
18 | |||
19 | rtems_task actn_task( rtems_task_argument unused ) |
|
19 | rtems_task actn_task( rtems_task_argument unused ) | |
20 | { |
|
20 | { | |
21 | /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands. |
|
21 | /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands. | |
22 | * |
|
22 | * | |
23 | * @param unused is the starting argument of the RTEMS task |
|
23 | * @param unused is the starting argument of the RTEMS task | |
24 | * |
|
24 | * | |
25 | * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending |
|
25 | * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending | |
26 | * on the incoming TeleCommand. |
|
26 | * on the incoming TeleCommand. | |
27 | * |
|
27 | * | |
28 | */ |
|
28 | */ | |
29 |
|
29 | |||
30 | int result; |
|
30 | int result; | |
31 | rtems_status_code status; // RTEMS status code |
|
31 | rtems_status_code status; // RTEMS status code | |
32 | ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task |
|
32 | ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task | |
33 | size_t size; // size of the incoming TC packet |
|
33 | size_t size; // size of the incoming TC packet | |
34 | unsigned char subtype; // subtype of the current TC packet |
|
34 | unsigned char subtype; // subtype of the current TC packet | |
35 | unsigned char time[6]; |
|
35 | unsigned char time[6]; | |
36 | rtems_id queue_rcv_id; |
|
36 | rtems_id queue_rcv_id; | |
37 | rtems_id queue_snd_id; |
|
37 | rtems_id queue_snd_id; | |
38 |
|
38 | |||
39 | status = get_message_queue_id_recv( &queue_rcv_id ); |
|
39 | status = get_message_queue_id_recv( &queue_rcv_id ); | |
40 | if (status != RTEMS_SUCCESSFUL) |
|
40 | if (status != RTEMS_SUCCESSFUL) | |
41 | { |
|
41 | { | |
42 | PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status) |
|
42 | PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status) | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | status = get_message_queue_id_send( &queue_snd_id ); |
|
45 | status = get_message_queue_id_send( &queue_snd_id ); | |
46 | if (status != RTEMS_SUCCESSFUL) |
|
46 | if (status != RTEMS_SUCCESSFUL) | |
47 | { |
|
47 | { | |
48 | PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status) |
|
48 | PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status) | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
51 | result = LFR_SUCCESSFUL; |
|
51 | result = LFR_SUCCESSFUL; | |
52 | subtype = 0; // subtype of the current TC packet |
|
52 | subtype = 0; // subtype of the current TC packet | |
53 |
|
53 | |||
54 | BOOT_PRINTF("in ACTN *** \n") |
|
54 | BOOT_PRINTF("in ACTN *** \n") | |
55 |
|
55 | |||
56 | while(1) |
|
56 | while(1) | |
57 | { |
|
57 | { | |
58 | status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size, |
|
58 | status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size, | |
59 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); |
|
59 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); | |
60 | getTime( time ); // set time to the current time |
|
60 | getTime( time ); // set time to the current time | |
61 | if (status!=RTEMS_SUCCESSFUL) |
|
61 | if (status!=RTEMS_SUCCESSFUL) | |
62 | { |
|
62 | { | |
63 | PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) |
|
63 | PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) | |
64 | } |
|
64 | } | |
65 | else |
|
65 | else | |
66 | { |
|
66 | { | |
67 | subtype = TC.serviceSubType; |
|
67 | subtype = TC.serviceSubType; | |
68 | switch(subtype) |
|
68 | switch(subtype) | |
69 | { |
|
69 | { | |
70 | case TC_SUBTYPE_RESET: |
|
70 | case TC_SUBTYPE_RESET: | |
71 | result = action_reset( &TC, queue_snd_id, time ); |
|
71 | result = action_reset( &TC, queue_snd_id, time ); | |
72 | close_action( &TC, result, queue_snd_id ); |
|
72 | close_action( &TC, result, queue_snd_id ); | |
73 | break; |
|
73 | break; | |
74 | case TC_SUBTYPE_LOAD_COMM: |
|
74 | case TC_SUBTYPE_LOAD_COMM: | |
75 | result = action_load_common_par( &TC ); |
|
75 | result = action_load_common_par( &TC ); | |
76 | close_action( &TC, result, queue_snd_id ); |
|
76 | close_action( &TC, result, queue_snd_id ); | |
77 | break; |
|
77 | break; | |
78 | case TC_SUBTYPE_LOAD_NORM: |
|
78 | case TC_SUBTYPE_LOAD_NORM: | |
79 | result = action_load_normal_par( &TC, queue_snd_id, time ); |
|
79 | result = action_load_normal_par( &TC, queue_snd_id, time ); | |
80 | close_action( &TC, result, queue_snd_id ); |
|
80 | close_action( &TC, result, queue_snd_id ); | |
81 | break; |
|
81 | break; | |
82 | case TC_SUBTYPE_LOAD_BURST: |
|
82 | case TC_SUBTYPE_LOAD_BURST: | |
83 | result = action_load_burst_par( &TC, queue_snd_id, time ); |
|
83 | result = action_load_burst_par( &TC, queue_snd_id, time ); | |
84 | close_action( &TC, result, queue_snd_id ); |
|
84 | close_action( &TC, result, queue_snd_id ); | |
85 | break; |
|
85 | break; | |
86 | case TC_SUBTYPE_LOAD_SBM1: |
|
86 | case TC_SUBTYPE_LOAD_SBM1: | |
87 | result = action_load_sbm1_par( &TC, queue_snd_id, time ); |
|
87 | result = action_load_sbm1_par( &TC, queue_snd_id, time ); | |
88 | close_action( &TC, result, queue_snd_id ); |
|
88 | close_action( &TC, result, queue_snd_id ); | |
89 | break; |
|
89 | break; | |
90 | case TC_SUBTYPE_LOAD_SBM2: |
|
90 | case TC_SUBTYPE_LOAD_SBM2: | |
91 | result = action_load_sbm2_par( &TC, queue_snd_id, time ); |
|
91 | result = action_load_sbm2_par( &TC, queue_snd_id, time ); | |
92 | close_action( &TC, result, queue_snd_id ); |
|
92 | close_action( &TC, result, queue_snd_id ); | |
93 | break; |
|
93 | break; | |
94 | case TC_SUBTYPE_DUMP: |
|
94 | case TC_SUBTYPE_DUMP: | |
95 | result = action_dump_par( &TC, queue_snd_id ); |
|
95 | result = action_dump_par( &TC, queue_snd_id ); | |
96 | close_action( &TC, result, queue_snd_id ); |
|
96 | close_action( &TC, result, queue_snd_id ); | |
97 | break; |
|
97 | break; | |
98 | case TC_SUBTYPE_ENTER: |
|
98 | case TC_SUBTYPE_ENTER: | |
99 | result = action_enter_mode( &TC, queue_snd_id ); |
|
99 | result = action_enter_mode( &TC, queue_snd_id ); | |
100 | close_action( &TC, result, queue_snd_id ); |
|
100 | close_action( &TC, result, queue_snd_id ); | |
101 | break; |
|
101 | break; | |
102 | case TC_SUBTYPE_UPDT_INFO: |
|
102 | case TC_SUBTYPE_UPDT_INFO: | |
103 | result = action_update_info( &TC, queue_snd_id ); |
|
103 | result = action_update_info( &TC, queue_snd_id ); | |
104 | close_action( &TC, result, queue_snd_id ); |
|
104 | close_action( &TC, result, queue_snd_id ); | |
105 | break; |
|
105 | break; | |
106 | case TC_SUBTYPE_EN_CAL: |
|
106 | case TC_SUBTYPE_EN_CAL: | |
107 | result = action_enable_calibration( &TC, queue_snd_id, time ); |
|
107 | result = action_enable_calibration( &TC, queue_snd_id, time ); | |
108 | close_action( &TC, result, queue_snd_id ); |
|
108 | close_action( &TC, result, queue_snd_id ); | |
109 | break; |
|
109 | break; | |
110 | case TC_SUBTYPE_DIS_CAL: |
|
110 | case TC_SUBTYPE_DIS_CAL: | |
111 | result = action_disable_calibration( &TC, queue_snd_id, time ); |
|
111 | result = action_disable_calibration( &TC, queue_snd_id, time ); | |
112 | close_action( &TC, result, queue_snd_id ); |
|
112 | close_action( &TC, result, queue_snd_id ); | |
113 | break; |
|
113 | break; | |
114 | case TC_SUBTYPE_LOAD_K: |
|
114 | case TC_SUBTYPE_LOAD_K: | |
115 | result = action_load_kcoefficients( &TC, queue_snd_id, time ); |
|
115 | result = action_load_kcoefficients( &TC, queue_snd_id, time ); | |
116 | close_action( &TC, result, queue_snd_id ); |
|
116 | close_action( &TC, result, queue_snd_id ); | |
117 | break; |
|
117 | break; | |
118 | case TC_SUBTYPE_DUMP_K: |
|
118 | case TC_SUBTYPE_DUMP_K: | |
119 | result = action_dump_kcoefficients( &TC, queue_snd_id, time ); |
|
119 | result = action_dump_kcoefficients( &TC, queue_snd_id, time ); | |
120 | close_action( &TC, result, queue_snd_id ); |
|
120 | close_action( &TC, result, queue_snd_id ); | |
121 | break; |
|
121 | break; | |
122 | case TC_SUBTYPE_LOAD_FBINS: |
|
122 | case TC_SUBTYPE_LOAD_FBINS: | |
123 | result = action_load_fbins_mask( &TC, queue_snd_id, time ); |
|
123 | result = action_load_fbins_mask( &TC, queue_snd_id, time ); | |
124 | close_action( &TC, result, queue_snd_id ); |
|
124 | close_action( &TC, result, queue_snd_id ); | |
125 | break; |
|
125 | break; | |
126 | case TC_SUBTYPE_UPDT_TIME: |
|
126 | case TC_SUBTYPE_UPDT_TIME: | |
127 | result = action_update_time( &TC ); |
|
127 | result = action_update_time( &TC ); | |
128 | close_action( &TC, result, queue_snd_id ); |
|
128 | close_action( &TC, result, queue_snd_id ); | |
129 | break; |
|
129 | break; | |
130 | default: |
|
130 | default: | |
131 | break; |
|
131 | break; | |
132 | } |
|
132 | } | |
133 | } |
|
133 | } | |
134 | } |
|
134 | } | |
135 | } |
|
135 | } | |
136 |
|
136 | |||
137 | //*********** |
|
137 | //*********** | |
138 | // TC ACTIONS |
|
138 | // TC ACTIONS | |
139 |
|
139 | |||
140 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
140 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
141 | { |
|
141 | { | |
142 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. |
|
142 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. | |
143 | * |
|
143 | * | |
144 | * @param TC points to the TeleCommand packet that is being processed |
|
144 | * @param TC points to the TeleCommand packet that is being processed | |
145 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
145 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
146 | * |
|
146 | * | |
147 | */ |
|
147 | */ | |
148 |
|
148 | |||
149 | PRINTF("this is the end!!!\n") |
|
149 | PRINTF("this is the end!!!\n") | |
150 | exit(0); |
|
150 | exit(0); | |
151 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
151 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); | |
152 | return LFR_DEFAULT; |
|
152 | return LFR_DEFAULT; | |
153 | } |
|
153 | } | |
154 |
|
154 | |||
155 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
155 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
156 | { |
|
156 | { | |
157 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. |
|
157 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. | |
158 | * |
|
158 | * | |
159 | * @param TC points to the TeleCommand packet that is being processed |
|
159 | * @param TC points to the TeleCommand packet that is being processed | |
160 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
160 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
161 | * |
|
161 | * | |
162 | */ |
|
162 | */ | |
163 |
|
163 | |||
164 | rtems_status_code status; |
|
164 | rtems_status_code status; | |
165 | unsigned char requestedMode; |
|
165 | unsigned char requestedMode; | |
166 | unsigned int *transitionCoarseTime_ptr; |
|
166 | unsigned int *transitionCoarseTime_ptr; | |
167 | unsigned int transitionCoarseTime; |
|
167 | unsigned int transitionCoarseTime; | |
168 | unsigned char * bytePosPtr; |
|
168 | unsigned char * bytePosPtr; | |
169 |
|
169 | |||
170 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
170 | bytePosPtr = (unsigned char *) &TC->packetID; | |
171 |
|
171 | |||
172 | requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ]; |
|
172 | requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ]; | |
173 | transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] ); |
|
173 | transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] ); | |
174 | transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff; |
|
174 | transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff; | |
175 |
|
175 | |||
176 | status = check_mode_value( requestedMode ); |
|
176 | status = check_mode_value( requestedMode ); | |
177 |
|
177 | |||
178 | if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent |
|
178 | if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent | |
179 | { |
|
179 | { | |
180 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode ); |
|
180 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode ); | |
181 | } |
|
181 | } | |
182 |
|
182 | |||
183 | else // the mode value is valid, check the transition |
|
183 | else // the mode value is valid, check the transition | |
184 | { |
|
184 | { | |
185 | status = check_mode_transition(requestedMode); |
|
185 | status = check_mode_transition(requestedMode); | |
186 | if (status != LFR_SUCCESSFUL) |
|
186 | if (status != LFR_SUCCESSFUL) | |
187 | { |
|
187 | { | |
188 | PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n") |
|
188 | PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n") | |
189 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
189 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
190 | } |
|
190 | } | |
191 | } |
|
191 | } | |
192 |
|
192 | |||
193 | if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date |
|
193 | if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date | |
194 | { |
|
194 | { | |
195 | status = check_transition_date( transitionCoarseTime ); |
|
195 | status = check_transition_date( transitionCoarseTime ); | |
196 | if (status != LFR_SUCCESSFUL) |
|
196 | if (status != LFR_SUCCESSFUL) | |
197 | { |
|
197 | { | |
198 | PRINTF("ERR *** in action_enter_mode *** check_transition_date\n"); |
|
198 | PRINTF("ERR *** in action_enter_mode *** check_transition_date\n"); | |
199 | send_tm_lfr_tc_exe_not_executable(TC, queue_id ); |
|
199 | send_tm_lfr_tc_exe_not_executable(TC, queue_id ); | |
200 | } |
|
200 | } | |
201 | } |
|
201 | } | |
202 |
|
202 | |||
203 | if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode |
|
203 | if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode | |
204 | { |
|
204 | { | |
205 | PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); |
|
205 | PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); | |
206 |
|
206 | |||
207 | update_last_valid_transition_date( transitionCoarseTime ); |
|
207 | update_last_valid_transition_date( transitionCoarseTime ); | |
208 |
|
208 | |||
209 | switch(requestedMode) |
|
209 | switch(requestedMode) | |
210 | { |
|
210 | { | |
211 | case LFR_MODE_STANDBY: |
|
211 | case LFR_MODE_STANDBY: | |
212 | status = enter_mode_standby(); |
|
212 | status = enter_mode_standby(); | |
213 | break; |
|
213 | break; | |
214 | case LFR_MODE_NORMAL: |
|
214 | case LFR_MODE_NORMAL: | |
215 | status = enter_mode_normal( transitionCoarseTime ); |
|
215 | status = enter_mode_normal( transitionCoarseTime ); | |
216 | break; |
|
216 | break; | |
217 | case LFR_MODE_BURST: |
|
217 | case LFR_MODE_BURST: | |
218 | status = enter_mode_burst( transitionCoarseTime ); |
|
218 | status = enter_mode_burst( transitionCoarseTime ); | |
219 | break; |
|
219 | break; | |
220 | case LFR_MODE_SBM1: |
|
220 | case LFR_MODE_SBM1: | |
221 | status = enter_mode_sbm1( transitionCoarseTime ); |
|
221 | status = enter_mode_sbm1( transitionCoarseTime ); | |
222 | break; |
|
222 | break; | |
223 | case LFR_MODE_SBM2: |
|
223 | case LFR_MODE_SBM2: | |
224 | status = enter_mode_sbm2( transitionCoarseTime ); |
|
224 | status = enter_mode_sbm2( transitionCoarseTime ); | |
225 | break; |
|
225 | break; | |
226 | default: |
|
226 | default: | |
227 | break; |
|
227 | break; | |
228 | } |
|
228 | } | |
229 | } |
|
229 | } | |
230 |
|
230 | |||
231 | return status; |
|
231 | return status; | |
232 | } |
|
232 | } | |
233 |
|
233 | |||
234 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
234 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
235 | { |
|
235 | { | |
236 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. |
|
236 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. | |
237 | * |
|
237 | * | |
238 | * @param TC points to the TeleCommand packet that is being processed |
|
238 | * @param TC points to the TeleCommand packet that is being processed | |
239 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
239 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
240 | * |
|
240 | * | |
241 | * @return LFR directive status code: |
|
241 | * @return LFR directive status code: | |
242 | * - LFR_DEFAULT |
|
242 | * - LFR_DEFAULT | |
243 | * - LFR_SUCCESSFUL |
|
243 | * - LFR_SUCCESSFUL | |
244 | * |
|
244 | * | |
245 | */ |
|
245 | */ | |
246 |
|
246 | |||
247 | unsigned int val; |
|
247 | unsigned int val; | |
248 | int result; |
|
248 | int result; | |
249 | unsigned int status; |
|
249 | unsigned int status; | |
250 | unsigned char mode; |
|
250 | unsigned char mode; | |
251 | unsigned char * bytePosPtr; |
|
251 | unsigned char * bytePosPtr; | |
252 |
|
252 | |||
253 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
253 | bytePosPtr = (unsigned char *) &TC->packetID; | |
254 |
|
254 | |||
255 | // check LFR mode |
|
255 | // check LFR mode | |
256 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1; |
|
256 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1; | |
257 | status = check_update_info_hk_lfr_mode( mode ); |
|
257 | status = check_update_info_hk_lfr_mode( mode ); | |
258 | if (status == LFR_SUCCESSFUL) // check TDS mode |
|
258 | if (status == LFR_SUCCESSFUL) // check TDS mode | |
259 | { |
|
259 | { | |
260 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4; |
|
260 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4; | |
261 | status = check_update_info_hk_tds_mode( mode ); |
|
261 | status = check_update_info_hk_tds_mode( mode ); | |
262 | } |
|
262 | } | |
263 | if (status == LFR_SUCCESSFUL) // check THR mode |
|
263 | if (status == LFR_SUCCESSFUL) // check THR mode | |
264 | { |
|
264 | { | |
265 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f); |
|
265 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f); | |
266 | status = check_update_info_hk_thr_mode( mode ); |
|
266 | status = check_update_info_hk_thr_mode( mode ); | |
267 | } |
|
267 | } | |
268 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful |
|
268 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful | |
269 | { |
|
269 | { | |
270 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 |
|
270 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 | |
271 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; |
|
271 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; | |
272 | val++; |
|
272 | val++; | |
273 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); |
|
273 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); | |
274 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); |
|
274 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); | |
275 | } |
|
275 | } | |
276 |
|
276 | |||
277 | // pa_bia_status_info |
|
277 | // pa_bia_status_info | |
278 | // => pa_bia_mode_mux_set 3 bits |
|
278 | // => pa_bia_mode_mux_set 3 bits | |
279 | // => pa_bia_mode_hv_enabled 1 bit |
|
279 | // => pa_bia_mode_hv_enabled 1 bit | |
280 | // => pa_bia_mode_bias1_enabled 1 bit |
|
280 | // => pa_bia_mode_bias1_enabled 1 bit | |
281 | // => pa_bia_mode_bias2_enabled 1 bit |
|
281 | // => pa_bia_mode_bias2_enabled 1 bit | |
282 | // => pa_bia_mode_bias3_enabled 1 bit |
|
282 | // => pa_bia_mode_bias3_enabled 1 bit | |
283 | // => pa_bia_on_off (cp_dpu_bias_on_off) |
|
283 | // => pa_bia_on_off (cp_dpu_bias_on_off) | |
284 | pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & 0xfe; // [1111 1110] |
|
284 | pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & 0xfe; // [1111 1110] | |
285 | pa_bia_status_info = pa_bia_status_info |
|
285 | pa_bia_status_info = pa_bia_status_info | |
286 | | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1); |
|
286 | | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1); | |
287 |
|
287 | |||
288 | result = status; |
|
288 | result = status; | |
289 |
|
289 | |||
290 | return result; |
|
290 | return result; | |
291 | } |
|
291 | } | |
292 |
|
292 | |||
293 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
293 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
294 | { |
|
294 | { | |
295 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. |
|
295 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. | |
296 | * |
|
296 | * | |
297 | * @param TC points to the TeleCommand packet that is being processed |
|
297 | * @param TC points to the TeleCommand packet that is being processed | |
298 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
298 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
299 | * |
|
299 | * | |
300 | */ |
|
300 | */ | |
301 |
|
301 | |||
302 | int result; |
|
302 | int result; | |
303 |
|
303 | |||
304 | result = LFR_DEFAULT; |
|
304 | result = LFR_DEFAULT; | |
305 |
|
305 | |||
306 | setCalibration( true ); |
|
306 | setCalibration( true ); | |
307 |
|
307 | |||
308 | result = LFR_SUCCESSFUL; |
|
308 | result = LFR_SUCCESSFUL; | |
309 |
|
309 | |||
310 | return result; |
|
310 | return result; | |
311 | } |
|
311 | } | |
312 |
|
312 | |||
313 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
313 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
314 | { |
|
314 | { | |
315 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. |
|
315 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. | |
316 | * |
|
316 | * | |
317 | * @param TC points to the TeleCommand packet that is being processed |
|
317 | * @param TC points to the TeleCommand packet that is being processed | |
318 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
318 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
319 | * |
|
319 | * | |
320 | */ |
|
320 | */ | |
321 |
|
321 | |||
322 | int result; |
|
322 | int result; | |
323 |
|
323 | |||
324 | result = LFR_DEFAULT; |
|
324 | result = LFR_DEFAULT; | |
325 |
|
325 | |||
326 | setCalibration( false ); |
|
326 | setCalibration( false ); | |
327 |
|
327 | |||
328 | result = LFR_SUCCESSFUL; |
|
328 | result = LFR_SUCCESSFUL; | |
329 |
|
329 | |||
330 | return result; |
|
330 | return result; | |
331 | } |
|
331 | } | |
332 |
|
332 | |||
333 | int action_update_time(ccsdsTelecommandPacket_t *TC) |
|
333 | int action_update_time(ccsdsTelecommandPacket_t *TC) | |
334 | { |
|
334 | { | |
335 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. |
|
335 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. | |
336 | * |
|
336 | * | |
337 | * @param TC points to the TeleCommand packet that is being processed |
|
337 | * @param TC points to the TeleCommand packet that is being processed | |
338 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
338 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
339 | * |
|
339 | * | |
340 | * @return LFR_SUCCESSFUL |
|
340 | * @return LFR_SUCCESSFUL | |
341 | * |
|
341 | * | |
342 | */ |
|
342 | */ | |
343 |
|
343 | |||
344 | unsigned int val; |
|
344 | unsigned int val; | |
345 |
|
345 | |||
346 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) |
|
346 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) | |
347 | + (TC->dataAndCRC[1] << 16) |
|
347 | + (TC->dataAndCRC[1] << 16) | |
348 | + (TC->dataAndCRC[2] << 8) |
|
348 | + (TC->dataAndCRC[2] << 8) | |
349 | + TC->dataAndCRC[3]; |
|
349 | + TC->dataAndCRC[3]; | |
350 |
|
350 | |||
351 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 |
|
351 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 | |
352 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; |
|
352 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; | |
353 | val++; |
|
353 | val++; | |
354 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); |
|
354 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); | |
355 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); |
|
355 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); | |
356 |
|
356 | |||
357 | return LFR_SUCCESSFUL; |
|
357 | return LFR_SUCCESSFUL; | |
358 | } |
|
358 | } | |
359 |
|
359 | |||
360 | //******************* |
|
360 | //******************* | |
361 | // ENTERING THE MODES |
|
361 | // ENTERING THE MODES | |
362 | int check_mode_value( unsigned char requestedMode ) |
|
362 | int check_mode_value( unsigned char requestedMode ) | |
363 | { |
|
363 | { | |
364 | int status; |
|
364 | int status; | |
365 |
|
365 | |||
366 | if ( (requestedMode != LFR_MODE_STANDBY) |
|
366 | if ( (requestedMode != LFR_MODE_STANDBY) | |
367 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) |
|
367 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) | |
368 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) |
|
368 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) | |
369 | { |
|
369 | { | |
370 | status = LFR_DEFAULT; |
|
370 | status = LFR_DEFAULT; | |
371 | } |
|
371 | } | |
372 | else |
|
372 | else | |
373 | { |
|
373 | { | |
374 | status = LFR_SUCCESSFUL; |
|
374 | status = LFR_SUCCESSFUL; | |
375 | } |
|
375 | } | |
376 |
|
376 | |||
377 | return status; |
|
377 | return status; | |
378 | } |
|
378 | } | |
379 |
|
379 | |||
380 | int check_mode_transition( unsigned char requestedMode ) |
|
380 | int check_mode_transition( unsigned char requestedMode ) | |
381 | { |
|
381 | { | |
382 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. |
|
382 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. | |
383 | * |
|
383 | * | |
384 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE |
|
384 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE | |
385 | * |
|
385 | * | |
386 | * @return LFR directive status codes: |
|
386 | * @return LFR directive status codes: | |
387 | * - LFR_SUCCESSFUL - the transition is authorized |
|
387 | * - LFR_SUCCESSFUL - the transition is authorized | |
388 | * - LFR_DEFAULT - the transition is not authorized |
|
388 | * - LFR_DEFAULT - the transition is not authorized | |
389 | * |
|
389 | * | |
390 | */ |
|
390 | */ | |
391 |
|
391 | |||
392 | int status; |
|
392 | int status; | |
393 |
|
393 | |||
394 | switch (requestedMode) |
|
394 | switch (requestedMode) | |
395 | { |
|
395 | { | |
396 | case LFR_MODE_STANDBY: |
|
396 | case LFR_MODE_STANDBY: | |
397 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { |
|
397 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { | |
398 | status = LFR_DEFAULT; |
|
398 | status = LFR_DEFAULT; | |
399 | } |
|
399 | } | |
400 | else |
|
400 | else | |
401 | { |
|
401 | { | |
402 | status = LFR_SUCCESSFUL; |
|
402 | status = LFR_SUCCESSFUL; | |
403 | } |
|
403 | } | |
404 | break; |
|
404 | break; | |
405 | case LFR_MODE_NORMAL: |
|
405 | case LFR_MODE_NORMAL: | |
406 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { |
|
406 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { | |
407 | status = LFR_DEFAULT; |
|
407 | status = LFR_DEFAULT; | |
408 | } |
|
408 | } | |
409 | else { |
|
409 | else { | |
410 | status = LFR_SUCCESSFUL; |
|
410 | status = LFR_SUCCESSFUL; | |
411 | } |
|
411 | } | |
412 | break; |
|
412 | break; | |
413 | case LFR_MODE_BURST: |
|
413 | case LFR_MODE_BURST: | |
414 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
414 | if ( lfrCurrentMode == LFR_MODE_BURST ) { | |
415 | status = LFR_DEFAULT; |
|
415 | status = LFR_DEFAULT; | |
416 | } |
|
416 | } | |
417 | else { |
|
417 | else { | |
418 | status = LFR_SUCCESSFUL; |
|
418 | status = LFR_SUCCESSFUL; | |
419 | } |
|
419 | } | |
420 | break; |
|
420 | break; | |
421 | case LFR_MODE_SBM1: |
|
421 | case LFR_MODE_SBM1: | |
422 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
422 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { | |
423 | status = LFR_DEFAULT; |
|
423 | status = LFR_DEFAULT; | |
424 | } |
|
424 | } | |
425 | else { |
|
425 | else { | |
426 | status = LFR_SUCCESSFUL; |
|
426 | status = LFR_SUCCESSFUL; | |
427 | } |
|
427 | } | |
428 | break; |
|
428 | break; | |
429 | case LFR_MODE_SBM2: |
|
429 | case LFR_MODE_SBM2: | |
430 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
430 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { | |
431 | status = LFR_DEFAULT; |
|
431 | status = LFR_DEFAULT; | |
432 | } |
|
432 | } | |
433 | else { |
|
433 | else { | |
434 | status = LFR_SUCCESSFUL; |
|
434 | status = LFR_SUCCESSFUL; | |
435 | } |
|
435 | } | |
436 | break; |
|
436 | break; | |
437 | default: |
|
437 | default: | |
438 | status = LFR_DEFAULT; |
|
438 | status = LFR_DEFAULT; | |
439 | break; |
|
439 | break; | |
440 | } |
|
440 | } | |
441 |
|
441 | |||
442 | return status; |
|
442 | return status; | |
443 | } |
|
443 | } | |
444 |
|
444 | |||
445 | void update_last_valid_transition_date( unsigned int transitionCoarseTime ) |
|
445 | void update_last_valid_transition_date( unsigned int transitionCoarseTime ) | |
446 | { |
|
446 | { | |
447 | lastValidEnterModeTime = transitionCoarseTime; |
|
447 | lastValidEnterModeTime = transitionCoarseTime; | |
448 | PRINTF1("lastValidEnterModeTime = %x\n", transitionCoarseTime); |
|
448 | PRINTF1("lastValidEnterModeTime = 0x%x\n", transitionCoarseTime); | |
449 | } |
|
449 | } | |
450 |
|
450 | |||
451 | int check_transition_date( unsigned int transitionCoarseTime ) |
|
451 | int check_transition_date( unsigned int transitionCoarseTime ) | |
452 | { |
|
452 | { | |
453 | int status; |
|
453 | int status; | |
454 | unsigned int localCoarseTime; |
|
454 | unsigned int localCoarseTime; | |
455 | unsigned int deltaCoarseTime; |
|
455 | unsigned int deltaCoarseTime; | |
456 |
|
456 | |||
457 | status = LFR_SUCCESSFUL; |
|
457 | status = LFR_SUCCESSFUL; | |
458 |
|
458 | |||
459 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition |
|
459 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition | |
460 | { |
|
460 | { | |
461 | status = LFR_SUCCESSFUL; |
|
461 | status = LFR_SUCCESSFUL; | |
462 | } |
|
462 | } | |
463 | else |
|
463 | else | |
464 | { |
|
464 | { | |
465 | localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; |
|
465 | localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; | |
466 |
|
466 | |||
467 | PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime); |
|
467 | PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime); | |
468 |
|
468 | |||
469 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 |
|
469 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 | |
470 | { |
|
470 | { | |
471 | status = LFR_DEFAULT; |
|
471 | status = LFR_DEFAULT; | |
472 | PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n"); |
|
472 | PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n"); | |
473 | } |
|
473 | } | |
474 |
|
474 | |||
475 | if (status == LFR_SUCCESSFUL) |
|
475 | if (status == LFR_SUCCESSFUL) | |
476 | { |
|
476 | { | |
477 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; |
|
477 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; | |
478 | if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323 |
|
478 | if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323 | |
479 | { |
|
479 | { | |
480 | status = LFR_DEFAULT; |
|
480 | status = LFR_DEFAULT; | |
481 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) |
|
481 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) | |
482 | } |
|
482 | } | |
483 | } |
|
483 | } | |
484 | } |
|
484 | } | |
485 |
|
485 | |||
486 | return status; |
|
486 | return status; | |
487 | } |
|
487 | } | |
488 |
|
488 | |||
489 | int restart_asm_activities( unsigned char lfrRequestedMode ) |
|
489 | int restart_asm_activities( unsigned char lfrRequestedMode ) | |
490 | { |
|
490 | { | |
491 | rtems_status_code status; |
|
491 | rtems_status_code status; | |
492 |
|
492 | |||
493 | status = stop_spectral_matrices(); |
|
493 | status = stop_spectral_matrices(); | |
494 |
|
494 | |||
495 | status = restart_asm_tasks( lfrRequestedMode ); |
|
495 | status = restart_asm_tasks( lfrRequestedMode ); | |
496 |
|
496 | |||
497 | launch_spectral_matrix(); |
|
497 | launch_spectral_matrix(); | |
498 |
|
498 | |||
499 | return status; |
|
499 | return status; | |
500 | } |
|
500 | } | |
501 |
|
501 | |||
502 | int stop_spectral_matrices( void ) |
|
502 | int stop_spectral_matrices( void ) | |
503 | { |
|
503 | { | |
504 | /** This function stops and restarts the current mode average spectral matrices activities. |
|
504 | /** This function stops and restarts the current mode average spectral matrices activities. | |
505 | * |
|
505 | * | |
506 | * @return RTEMS directive status codes: |
|
506 | * @return RTEMS directive status codes: | |
507 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
507 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
508 | * - RTEMS_INVALID_ID - task id invalid |
|
508 | * - RTEMS_INVALID_ID - task id invalid | |
509 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
509 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
510 | * |
|
510 | * | |
511 | */ |
|
511 | */ | |
512 |
|
512 | |||
513 | rtems_status_code status; |
|
513 | rtems_status_code status; | |
514 |
|
514 | |||
515 | status = RTEMS_SUCCESSFUL; |
|
515 | status = RTEMS_SUCCESSFUL; | |
516 |
|
516 | |||
517 | // (1) mask interruptions |
|
517 | // (1) mask interruptions | |
518 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
518 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
519 |
|
519 | |||
520 | // (2) reset spectral matrices registers |
|
520 | // (2) reset spectral matrices registers | |
521 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices |
|
521 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices | |
522 | reset_sm_status(); |
|
522 | reset_sm_status(); | |
523 |
|
523 | |||
524 | // (3) clear interruptions |
|
524 | // (3) clear interruptions | |
525 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
525 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
526 |
|
526 | |||
527 | // suspend several tasks |
|
527 | // suspend several tasks | |
528 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
528 | if (lfrCurrentMode != LFR_MODE_STANDBY) { | |
529 | status = suspend_asm_tasks(); |
|
529 | status = suspend_asm_tasks(); | |
530 | } |
|
530 | } | |
531 |
|
531 | |||
532 | if (status != RTEMS_SUCCESSFUL) |
|
532 | if (status != RTEMS_SUCCESSFUL) | |
533 | { |
|
533 | { | |
534 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
534 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) | |
535 | } |
|
535 | } | |
536 |
|
536 | |||
537 | return status; |
|
537 | return status; | |
538 | } |
|
538 | } | |
539 |
|
539 | |||
540 | int stop_current_mode( void ) |
|
540 | int stop_current_mode( void ) | |
541 | { |
|
541 | { | |
542 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. |
|
542 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. | |
543 | * |
|
543 | * | |
544 | * @return RTEMS directive status codes: |
|
544 | * @return RTEMS directive status codes: | |
545 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
545 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
546 | * - RTEMS_INVALID_ID - task id invalid |
|
546 | * - RTEMS_INVALID_ID - task id invalid | |
547 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
547 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
548 | * |
|
548 | * | |
549 | */ |
|
549 | */ | |
550 |
|
550 | |||
551 | rtems_status_code status; |
|
551 | rtems_status_code status; | |
552 |
|
552 | |||
553 | status = RTEMS_SUCCESSFUL; |
|
553 | status = RTEMS_SUCCESSFUL; | |
554 |
|
554 | |||
555 | // (1) mask interruptions |
|
555 | // (1) mask interruptions | |
556 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt |
|
556 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt | |
557 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
557 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
558 |
|
558 | |||
559 | // (2) reset waveform picker registers |
|
559 | // (2) reset waveform picker registers | |
560 | reset_wfp_burst_enable(); // reset burst and enable bits |
|
560 | reset_wfp_burst_enable(); // reset burst and enable bits | |
561 | reset_wfp_status(); // reset all the status bits |
|
561 | reset_wfp_status(); // reset all the status bits | |
562 |
|
562 | |||
563 | // (3) reset spectral matrices registers |
|
563 | // (3) reset spectral matrices registers | |
564 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices |
|
564 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices | |
565 | reset_sm_status(); |
|
565 | reset_sm_status(); | |
566 |
|
566 | |||
567 | // reset lfr VHDL module |
|
567 | // reset lfr VHDL module | |
568 | reset_lfr(); |
|
568 | reset_lfr(); | |
569 |
|
569 | |||
570 | reset_extractSWF(); // reset the extractSWF flag to false |
|
570 | reset_extractSWF(); // reset the extractSWF flag to false | |
571 |
|
571 | |||
572 | // (4) clear interruptions |
|
572 | // (4) clear interruptions | |
573 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt |
|
573 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt | |
574 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
574 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
575 |
|
575 | |||
576 | // suspend several tasks |
|
576 | // suspend several tasks | |
577 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
577 | if (lfrCurrentMode != LFR_MODE_STANDBY) { | |
578 | status = suspend_science_tasks(); |
|
578 | status = suspend_science_tasks(); | |
579 | } |
|
579 | } | |
580 |
|
580 | |||
581 | if (status != RTEMS_SUCCESSFUL) |
|
581 | if (status != RTEMS_SUCCESSFUL) | |
582 | { |
|
582 | { | |
583 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
583 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) | |
584 | } |
|
584 | } | |
585 |
|
585 | |||
586 | return status; |
|
586 | return status; | |
587 | } |
|
587 | } | |
588 |
|
588 | |||
589 | int enter_mode_standby( void ) |
|
589 | int enter_mode_standby( void ) | |
590 | { |
|
590 | { | |
591 | /** This function is used to put LFR in the STANDBY mode. |
|
591 | /** This function is used to put LFR in the STANDBY mode. | |
592 | * |
|
592 | * | |
593 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE |
|
593 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |
594 | * |
|
594 | * | |
595 | * @return RTEMS directive status codes: |
|
595 | * @return RTEMS directive status codes: | |
596 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
596 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
597 | * - RTEMS_INVALID_ID - task id invalid |
|
597 | * - RTEMS_INVALID_ID - task id invalid | |
598 | * - RTEMS_INCORRECT_STATE - task never started |
|
598 | * - RTEMS_INCORRECT_STATE - task never started | |
599 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
599 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
600 | * |
|
600 | * | |
601 | * The STANDBY mode does not depends on a specific transition date, the effect of the TC_LFR_ENTER_MODE |
|
601 | * The STANDBY mode does not depends on a specific transition date, the effect of the TC_LFR_ENTER_MODE | |
602 | * is immediate. |
|
602 | * is immediate. | |
603 | * |
|
603 | * | |
604 | */ |
|
604 | */ | |
605 |
|
605 | |||
606 | int status; |
|
606 | int status; | |
607 |
|
607 | |||
608 | status = stop_current_mode(); // STOP THE CURRENT MODE |
|
608 | status = stop_current_mode(); // STOP THE CURRENT MODE | |
609 |
|
609 | |||
610 | #ifdef PRINT_TASK_STATISTICS |
|
610 | #ifdef PRINT_TASK_STATISTICS | |
611 | rtems_cpu_usage_report(); |
|
611 | rtems_cpu_usage_report(); | |
612 | #endif |
|
612 | #endif | |
613 |
|
613 | |||
614 | #ifdef PRINT_STACK_REPORT |
|
614 | #ifdef PRINT_STACK_REPORT | |
615 | PRINTF("stack report selected\n") |
|
615 | PRINTF("stack report selected\n") | |
616 | rtems_stack_checker_report_usage(); |
|
616 | rtems_stack_checker_report_usage(); | |
617 | #endif |
|
617 | #endif | |
618 |
|
618 | |||
619 | return status; |
|
619 | return status; | |
620 | } |
|
620 | } | |
621 |
|
621 | |||
622 | int enter_mode_normal( unsigned int transitionCoarseTime ) |
|
622 | int enter_mode_normal( unsigned int transitionCoarseTime ) | |
623 | { |
|
623 | { | |
624 | /** This function is used to start the NORMAL mode. |
|
624 | /** This function is used to start the NORMAL mode. | |
625 | * |
|
625 | * | |
626 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE |
|
626 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |
627 | * |
|
627 | * | |
628 | * @return RTEMS directive status codes: |
|
628 | * @return RTEMS directive status codes: | |
629 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
629 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
630 | * - RTEMS_INVALID_ID - task id invalid |
|
630 | * - RTEMS_INVALID_ID - task id invalid | |
631 | * - RTEMS_INCORRECT_STATE - task never started |
|
631 | * - RTEMS_INCORRECT_STATE - task never started | |
632 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
632 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
633 | * |
|
633 | * | |
634 | * The way the NORMAL mode is started depends on the LFR current mode. If LFR is in SBM1 or SBM2, |
|
634 | * The way the NORMAL mode is started depends on the LFR current mode. If LFR is in SBM1 or SBM2, | |
635 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. |
|
635 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. | |
636 | * |
|
636 | * | |
637 | */ |
|
637 | */ | |
638 |
|
638 | |||
639 | int status; |
|
639 | int status; | |
640 |
|
640 | |||
641 | #ifdef PRINT_TASK_STATISTICS |
|
641 | #ifdef PRINT_TASK_STATISTICS | |
642 | rtems_cpu_usage_reset(); |
|
642 | rtems_cpu_usage_reset(); | |
643 | #endif |
|
643 | #endif | |
644 |
|
644 | |||
645 | status = RTEMS_UNSATISFIED; |
|
645 | status = RTEMS_UNSATISFIED; | |
646 |
|
646 | |||
647 | switch( lfrCurrentMode ) |
|
647 | switch( lfrCurrentMode ) | |
648 | { |
|
648 | { | |
649 | case LFR_MODE_STANDBY: |
|
649 | case LFR_MODE_STANDBY: | |
650 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart science tasks |
|
650 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart science tasks | |
651 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
651 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
652 | { |
|
652 | { | |
653 | launch_spectral_matrix( ); |
|
653 | launch_spectral_matrix( ); | |
654 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); |
|
654 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); | |
655 | } |
|
655 | } | |
656 | break; |
|
656 | break; | |
657 | case LFR_MODE_BURST: |
|
657 | case LFR_MODE_BURST: | |
658 | status = stop_current_mode(); // stop the current mode |
|
658 | status = stop_current_mode(); // stop the current mode | |
659 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart the science tasks |
|
659 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart the science tasks | |
660 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
660 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
661 | { |
|
661 | { | |
662 | launch_spectral_matrix( ); |
|
662 | launch_spectral_matrix( ); | |
663 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); |
|
663 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); | |
664 | } |
|
664 | } | |
665 | break; |
|
665 | break; | |
666 | case LFR_MODE_SBM1: |
|
666 | case LFR_MODE_SBM1: | |
667 | restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters |
|
667 | restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters | |
668 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
668 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
669 | break; |
|
669 | break; | |
670 | case LFR_MODE_SBM2: |
|
670 | case LFR_MODE_SBM2: | |
671 | restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters |
|
671 | restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters | |
672 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
672 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
673 | break; |
|
673 | break; | |
674 | default: |
|
674 | default: | |
675 | break; |
|
675 | break; | |
676 | } |
|
676 | } | |
677 |
|
677 | |||
678 | if (status != RTEMS_SUCCESSFUL) |
|
678 | if (status != RTEMS_SUCCESSFUL) | |
679 | { |
|
679 | { | |
680 | PRINTF1("ERR *** in enter_mode_normal *** status = %d\n", status) |
|
680 | PRINTF1("ERR *** in enter_mode_normal *** status = %d\n", status) | |
681 | status = RTEMS_UNSATISFIED; |
|
681 | status = RTEMS_UNSATISFIED; | |
682 | } |
|
682 | } | |
683 |
|
683 | |||
684 | return status; |
|
684 | return status; | |
685 | } |
|
685 | } | |
686 |
|
686 | |||
687 | int enter_mode_burst( unsigned int transitionCoarseTime ) |
|
687 | int enter_mode_burst( unsigned int transitionCoarseTime ) | |
688 | { |
|
688 | { | |
689 | /** This function is used to start the BURST mode. |
|
689 | /** This function is used to start the BURST mode. | |
690 | * |
|
690 | * | |
691 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE |
|
691 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |
692 | * |
|
692 | * | |
693 | * @return RTEMS directive status codes: |
|
693 | * @return RTEMS directive status codes: | |
694 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
694 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
695 | * - RTEMS_INVALID_ID - task id invalid |
|
695 | * - RTEMS_INVALID_ID - task id invalid | |
696 | * - RTEMS_INCORRECT_STATE - task never started |
|
696 | * - RTEMS_INCORRECT_STATE - task never started | |
697 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
697 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
698 | * |
|
698 | * | |
699 | * The way the BURST mode is started does not depend on the LFR current mode. |
|
699 | * The way the BURST mode is started does not depend on the LFR current mode. | |
700 | * |
|
700 | * | |
701 | */ |
|
701 | */ | |
702 |
|
702 | |||
703 |
|
703 | |||
704 | int status; |
|
704 | int status; | |
705 |
|
705 | |||
706 | #ifdef PRINT_TASK_STATISTICS |
|
706 | #ifdef PRINT_TASK_STATISTICS | |
707 | rtems_cpu_usage_reset(); |
|
707 | rtems_cpu_usage_reset(); | |
708 | #endif |
|
708 | #endif | |
709 |
|
709 | |||
710 | status = stop_current_mode(); // stop the current mode |
|
710 | status = stop_current_mode(); // stop the current mode | |
711 | status = restart_science_tasks( LFR_MODE_BURST ); // restart the science tasks |
|
711 | status = restart_science_tasks( LFR_MODE_BURST ); // restart the science tasks | |
712 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
712 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
713 | { |
|
713 | { | |
714 | launch_spectral_matrix( ); |
|
714 | launch_spectral_matrix( ); | |
715 | launch_waveform_picker( LFR_MODE_BURST, transitionCoarseTime ); |
|
715 | launch_waveform_picker( LFR_MODE_BURST, transitionCoarseTime ); | |
716 | } |
|
716 | } | |
717 |
|
717 | |||
718 | if (status != RTEMS_SUCCESSFUL) |
|
718 | if (status != RTEMS_SUCCESSFUL) | |
719 | { |
|
719 | { | |
720 | PRINTF1("ERR *** in enter_mode_burst *** status = %d\n", status) |
|
720 | PRINTF1("ERR *** in enter_mode_burst *** status = %d\n", status) | |
721 | status = RTEMS_UNSATISFIED; |
|
721 | status = RTEMS_UNSATISFIED; | |
722 | } |
|
722 | } | |
723 |
|
723 | |||
724 | return status; |
|
724 | return status; | |
725 | } |
|
725 | } | |
726 |
|
726 | |||
727 | int enter_mode_sbm1( unsigned int transitionCoarseTime ) |
|
727 | int enter_mode_sbm1( unsigned int transitionCoarseTime ) | |
728 | { |
|
728 | { | |
729 | /** This function is used to start the SBM1 mode. |
|
729 | /** This function is used to start the SBM1 mode. | |
730 | * |
|
730 | * | |
731 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE |
|
731 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |
732 | * |
|
732 | * | |
733 | * @return RTEMS directive status codes: |
|
733 | * @return RTEMS directive status codes: | |
734 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
734 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
735 | * - RTEMS_INVALID_ID - task id invalid |
|
735 | * - RTEMS_INVALID_ID - task id invalid | |
736 | * - RTEMS_INCORRECT_STATE - task never started |
|
736 | * - RTEMS_INCORRECT_STATE - task never started | |
737 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
737 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
738 | * |
|
738 | * | |
739 | * The way the SBM1 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM2, |
|
739 | * The way the SBM1 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM2, | |
740 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other |
|
740 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other | |
741 | * cases, the acquisition is completely restarted. |
|
741 | * cases, the acquisition is completely restarted. | |
742 | * |
|
742 | * | |
743 | */ |
|
743 | */ | |
744 |
|
744 | |||
745 | int status; |
|
745 | int status; | |
746 |
|
746 | |||
747 | #ifdef PRINT_TASK_STATISTICS |
|
747 | #ifdef PRINT_TASK_STATISTICS | |
748 | rtems_cpu_usage_reset(); |
|
748 | rtems_cpu_usage_reset(); | |
749 | #endif |
|
749 | #endif | |
750 |
|
750 | |||
751 | status = RTEMS_UNSATISFIED; |
|
751 | status = RTEMS_UNSATISFIED; | |
752 |
|
752 | |||
753 | switch( lfrCurrentMode ) |
|
753 | switch( lfrCurrentMode ) | |
754 | { |
|
754 | { | |
755 | case LFR_MODE_STANDBY: |
|
755 | case LFR_MODE_STANDBY: | |
756 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart science tasks |
|
756 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart science tasks | |
757 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
757 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
758 | { |
|
758 | { | |
759 | launch_spectral_matrix( ); |
|
759 | launch_spectral_matrix( ); | |
760 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); |
|
760 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); | |
761 | } |
|
761 | } | |
762 | break; |
|
762 | break; | |
763 | case LFR_MODE_NORMAL: // lfrCurrentMode will be updated after the execution of close_action |
|
763 | case LFR_MODE_NORMAL: // lfrCurrentMode will be updated after the execution of close_action | |
764 | restart_asm_activities( LFR_MODE_SBM1 ); |
|
764 | restart_asm_activities( LFR_MODE_SBM1 ); | |
765 | status = LFR_SUCCESSFUL; |
|
765 | status = LFR_SUCCESSFUL; | |
766 | break; |
|
766 | break; | |
767 | case LFR_MODE_BURST: |
|
767 | case LFR_MODE_BURST: | |
768 | status = stop_current_mode(); // stop the current mode |
|
768 | status = stop_current_mode(); // stop the current mode | |
769 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart the science tasks |
|
769 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart the science tasks | |
770 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
770 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
771 | { |
|
771 | { | |
772 | launch_spectral_matrix( ); |
|
772 | launch_spectral_matrix( ); | |
773 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); |
|
773 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); | |
774 | } |
|
774 | } | |
775 | break; |
|
775 | break; | |
776 | case LFR_MODE_SBM2: |
|
776 | case LFR_MODE_SBM2: | |
777 | restart_asm_activities( LFR_MODE_SBM1 ); |
|
777 | restart_asm_activities( LFR_MODE_SBM1 ); | |
778 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
778 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
779 | break; |
|
779 | break; | |
780 | default: |
|
780 | default: | |
781 | break; |
|
781 | break; | |
782 | } |
|
782 | } | |
783 |
|
783 | |||
784 | if (status != RTEMS_SUCCESSFUL) |
|
784 | if (status != RTEMS_SUCCESSFUL) | |
785 | { |
|
785 | { | |
786 | PRINTF1("ERR *** in enter_mode_sbm1 *** status = %d\n", status) |
|
786 | PRINTF1("ERR *** in enter_mode_sbm1 *** status = %d\n", status) | |
787 | status = RTEMS_UNSATISFIED; |
|
787 | status = RTEMS_UNSATISFIED; | |
788 | } |
|
788 | } | |
789 |
|
789 | |||
790 | return status; |
|
790 | return status; | |
791 | } |
|
791 | } | |
792 |
|
792 | |||
793 | int enter_mode_sbm2( unsigned int transitionCoarseTime ) |
|
793 | int enter_mode_sbm2( unsigned int transitionCoarseTime ) | |
794 | { |
|
794 | { | |
795 | /** This function is used to start the SBM2 mode. |
|
795 | /** This function is used to start the SBM2 mode. | |
796 | * |
|
796 | * | |
797 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE |
|
797 | * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE | |
798 | * |
|
798 | * | |
799 | * @return RTEMS directive status codes: |
|
799 | * @return RTEMS directive status codes: | |
800 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
800 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
801 | * - RTEMS_INVALID_ID - task id invalid |
|
801 | * - RTEMS_INVALID_ID - task id invalid | |
802 | * - RTEMS_INCORRECT_STATE - task never started |
|
802 | * - RTEMS_INCORRECT_STATE - task never started | |
803 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
803 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
804 | * |
|
804 | * | |
805 | * The way the SBM2 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM1, |
|
805 | * The way the SBM2 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM1, | |
806 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other |
|
806 | * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other | |
807 | * cases, the acquisition is completely restarted. |
|
807 | * cases, the acquisition is completely restarted. | |
808 | * |
|
808 | * | |
809 | */ |
|
809 | */ | |
810 |
|
810 | |||
811 | int status; |
|
811 | int status; | |
812 |
|
812 | |||
813 | #ifdef PRINT_TASK_STATISTICS |
|
813 | #ifdef PRINT_TASK_STATISTICS | |
814 | rtems_cpu_usage_reset(); |
|
814 | rtems_cpu_usage_reset(); | |
815 | #endif |
|
815 | #endif | |
816 |
|
816 | |||
817 | status = RTEMS_UNSATISFIED; |
|
817 | status = RTEMS_UNSATISFIED; | |
818 |
|
818 | |||
819 | switch( lfrCurrentMode ) |
|
819 | switch( lfrCurrentMode ) | |
820 | { |
|
820 | { | |
821 | case LFR_MODE_STANDBY: |
|
821 | case LFR_MODE_STANDBY: | |
822 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart science tasks |
|
822 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart science tasks | |
823 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
823 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
824 | { |
|
824 | { | |
825 | launch_spectral_matrix( ); |
|
825 | launch_spectral_matrix( ); | |
826 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); |
|
826 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); | |
827 | } |
|
827 | } | |
828 | break; |
|
828 | break; | |
829 | case LFR_MODE_NORMAL: |
|
829 | case LFR_MODE_NORMAL: | |
830 | restart_asm_activities( LFR_MODE_SBM2 ); |
|
830 | restart_asm_activities( LFR_MODE_SBM2 ); | |
831 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
831 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
832 | break; |
|
832 | break; | |
833 | case LFR_MODE_BURST: |
|
833 | case LFR_MODE_BURST: | |
834 | status = stop_current_mode(); // stop the current mode |
|
834 | status = stop_current_mode(); // stop the current mode | |
835 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart the science tasks |
|
835 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart the science tasks | |
836 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
836 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
837 | { |
|
837 | { | |
838 | launch_spectral_matrix( ); |
|
838 | launch_spectral_matrix( ); | |
839 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); |
|
839 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); | |
840 | } |
|
840 | } | |
841 | break; |
|
841 | break; | |
842 | case LFR_MODE_SBM1: |
|
842 | case LFR_MODE_SBM1: | |
843 | restart_asm_activities( LFR_MODE_SBM2 ); |
|
843 | restart_asm_activities( LFR_MODE_SBM2 ); | |
844 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
844 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
845 | break; |
|
845 | break; | |
846 | default: |
|
846 | default: | |
847 | break; |
|
847 | break; | |
848 | } |
|
848 | } | |
849 |
|
849 | |||
850 | if (status != RTEMS_SUCCESSFUL) |
|
850 | if (status != RTEMS_SUCCESSFUL) | |
851 | { |
|
851 | { | |
852 | PRINTF1("ERR *** in enter_mode_sbm2 *** status = %d\n", status) |
|
852 | PRINTF1("ERR *** in enter_mode_sbm2 *** status = %d\n", status) | |
853 | status = RTEMS_UNSATISFIED; |
|
853 | status = RTEMS_UNSATISFIED; | |
854 | } |
|
854 | } | |
855 |
|
855 | |||
856 | return status; |
|
856 | return status; | |
857 | } |
|
857 | } | |
858 |
|
858 | |||
859 | int restart_science_tasks( unsigned char lfrRequestedMode ) |
|
859 | int restart_science_tasks( unsigned char lfrRequestedMode ) | |
860 | { |
|
860 | { | |
861 | /** This function is used to restart all science tasks. |
|
861 | /** This function is used to restart all science tasks. | |
862 | * |
|
862 | * | |
863 | * @return RTEMS directive status codes: |
|
863 | * @return RTEMS directive status codes: | |
864 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
864 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
865 | * - RTEMS_INVALID_ID - task id invalid |
|
865 | * - RTEMS_INVALID_ID - task id invalid | |
866 | * - RTEMS_INCORRECT_STATE - task never started |
|
866 | * - RTEMS_INCORRECT_STATE - task never started | |
867 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
867 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
868 | * |
|
868 | * | |
869 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 |
|
869 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 | |
870 | * |
|
870 | * | |
871 | */ |
|
871 | */ | |
872 |
|
872 | |||
873 | rtems_status_code status[10]; |
|
873 | rtems_status_code status[10]; | |
874 | rtems_status_code ret; |
|
874 | rtems_status_code ret; | |
875 |
|
875 | |||
876 | ret = RTEMS_SUCCESSFUL; |
|
876 | ret = RTEMS_SUCCESSFUL; | |
877 |
|
877 | |||
878 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); |
|
878 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); | |
879 | if (status[0] != RTEMS_SUCCESSFUL) |
|
879 | if (status[0] != RTEMS_SUCCESSFUL) | |
880 | { |
|
880 | { | |
881 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) |
|
881 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) | |
882 | } |
|
882 | } | |
883 |
|
883 | |||
884 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); |
|
884 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); | |
885 | if (status[1] != RTEMS_SUCCESSFUL) |
|
885 | if (status[1] != RTEMS_SUCCESSFUL) | |
886 | { |
|
886 | { | |
887 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) |
|
887 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) | |
888 | } |
|
888 | } | |
889 |
|
889 | |||
890 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); |
|
890 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); | |
891 | if (status[2] != RTEMS_SUCCESSFUL) |
|
891 | if (status[2] != RTEMS_SUCCESSFUL) | |
892 | { |
|
892 | { | |
893 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2]) |
|
893 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2]) | |
894 | } |
|
894 | } | |
895 |
|
895 | |||
896 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); |
|
896 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); | |
897 | if (status[3] != RTEMS_SUCCESSFUL) |
|
897 | if (status[3] != RTEMS_SUCCESSFUL) | |
898 | { |
|
898 | { | |
899 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3]) |
|
899 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3]) | |
900 | } |
|
900 | } | |
901 |
|
901 | |||
902 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); |
|
902 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); | |
903 | if (status[4] != RTEMS_SUCCESSFUL) |
|
903 | if (status[4] != RTEMS_SUCCESSFUL) | |
904 | { |
|
904 | { | |
905 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4]) |
|
905 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4]) | |
906 | } |
|
906 | } | |
907 |
|
907 | |||
908 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); |
|
908 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); | |
909 | if (status[5] != RTEMS_SUCCESSFUL) |
|
909 | if (status[5] != RTEMS_SUCCESSFUL) | |
910 | { |
|
910 | { | |
911 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5]) |
|
911 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5]) | |
912 | } |
|
912 | } | |
913 |
|
913 | |||
914 | status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); |
|
914 | status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); | |
915 | if (status[6] != RTEMS_SUCCESSFUL) |
|
915 | if (status[6] != RTEMS_SUCCESSFUL) | |
916 | { |
|
916 | { | |
917 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6]) |
|
917 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6]) | |
918 | } |
|
918 | } | |
919 |
|
919 | |||
920 | status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); |
|
920 | status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); | |
921 | if (status[7] != RTEMS_SUCCESSFUL) |
|
921 | if (status[7] != RTEMS_SUCCESSFUL) | |
922 | { |
|
922 | { | |
923 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7]) |
|
923 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7]) | |
924 | } |
|
924 | } | |
925 |
|
925 | |||
926 | status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); |
|
926 | status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); | |
927 | if (status[8] != RTEMS_SUCCESSFUL) |
|
927 | if (status[8] != RTEMS_SUCCESSFUL) | |
928 | { |
|
928 | { | |
929 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8]) |
|
929 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8]) | |
930 | } |
|
930 | } | |
931 |
|
931 | |||
932 | status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); |
|
932 | status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); | |
933 | if (status[9] != RTEMS_SUCCESSFUL) |
|
933 | if (status[9] != RTEMS_SUCCESSFUL) | |
934 | { |
|
934 | { | |
935 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9]) |
|
935 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9]) | |
936 | } |
|
936 | } | |
937 |
|
937 | |||
938 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || |
|
938 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || | |
939 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || |
|
939 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || | |
940 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) || |
|
940 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) || | |
941 | (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) || |
|
941 | (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) || | |
942 | (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) ) |
|
942 | (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) ) | |
943 | { |
|
943 | { | |
944 | ret = RTEMS_UNSATISFIED; |
|
944 | ret = RTEMS_UNSATISFIED; | |
945 | } |
|
945 | } | |
946 |
|
946 | |||
947 | return ret; |
|
947 | return ret; | |
948 | } |
|
948 | } | |
949 |
|
949 | |||
950 | int restart_asm_tasks( unsigned char lfrRequestedMode ) |
|
950 | int restart_asm_tasks( unsigned char lfrRequestedMode ) | |
951 | { |
|
951 | { | |
952 | /** This function is used to restart average spectral matrices tasks. |
|
952 | /** This function is used to restart average spectral matrices tasks. | |
953 | * |
|
953 | * | |
954 | * @return RTEMS directive status codes: |
|
954 | * @return RTEMS directive status codes: | |
955 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
955 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
956 | * - RTEMS_INVALID_ID - task id invalid |
|
956 | * - RTEMS_INVALID_ID - task id invalid | |
957 | * - RTEMS_INCORRECT_STATE - task never started |
|
957 | * - RTEMS_INCORRECT_STATE - task never started | |
958 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
958 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
959 | * |
|
959 | * | |
960 | * ASM tasks are AVF0, PRC0, AVF1, PRC1, AVF2 and PRC2 |
|
960 | * ASM tasks are AVF0, PRC0, AVF1, PRC1, AVF2 and PRC2 | |
961 | * |
|
961 | * | |
962 | */ |
|
962 | */ | |
963 |
|
963 | |||
964 | rtems_status_code status[6]; |
|
964 | rtems_status_code status[6]; | |
965 | rtems_status_code ret; |
|
965 | rtems_status_code ret; | |
966 |
|
966 | |||
967 | ret = RTEMS_SUCCESSFUL; |
|
967 | ret = RTEMS_SUCCESSFUL; | |
968 |
|
968 | |||
969 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); |
|
969 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); | |
970 | if (status[0] != RTEMS_SUCCESSFUL) |
|
970 | if (status[0] != RTEMS_SUCCESSFUL) | |
971 | { |
|
971 | { | |
972 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) |
|
972 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) | |
973 | } |
|
973 | } | |
974 |
|
974 | |||
975 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); |
|
975 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); | |
976 | if (status[1] != RTEMS_SUCCESSFUL) |
|
976 | if (status[1] != RTEMS_SUCCESSFUL) | |
977 | { |
|
977 | { | |
978 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) |
|
978 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) | |
979 | } |
|
979 | } | |
980 |
|
980 | |||
981 | status[2] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); |
|
981 | status[2] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); | |
982 | if (status[2] != RTEMS_SUCCESSFUL) |
|
982 | if (status[2] != RTEMS_SUCCESSFUL) | |
983 | { |
|
983 | { | |
984 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[2]) |
|
984 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[2]) | |
985 | } |
|
985 | } | |
986 |
|
986 | |||
987 | status[3] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); |
|
987 | status[3] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); | |
988 | if (status[3] != RTEMS_SUCCESSFUL) |
|
988 | if (status[3] != RTEMS_SUCCESSFUL) | |
989 | { |
|
989 | { | |
990 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[3]) |
|
990 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[3]) | |
991 | } |
|
991 | } | |
992 |
|
992 | |||
993 | status[4] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); |
|
993 | status[4] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); | |
994 | if (status[4] != RTEMS_SUCCESSFUL) |
|
994 | if (status[4] != RTEMS_SUCCESSFUL) | |
995 | { |
|
995 | { | |
996 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[4]) |
|
996 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[4]) | |
997 | } |
|
997 | } | |
998 |
|
998 | |||
999 | status[5] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); |
|
999 | status[5] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); | |
1000 | if (status[5] != RTEMS_SUCCESSFUL) |
|
1000 | if (status[5] != RTEMS_SUCCESSFUL) | |
1001 | { |
|
1001 | { | |
1002 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[5]) |
|
1002 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[5]) | |
1003 | } |
|
1003 | } | |
1004 |
|
1004 | |||
1005 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || |
|
1005 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || | |
1006 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || |
|
1006 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || | |
1007 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ) |
|
1007 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ) | |
1008 | { |
|
1008 | { | |
1009 | ret = RTEMS_UNSATISFIED; |
|
1009 | ret = RTEMS_UNSATISFIED; | |
1010 | } |
|
1010 | } | |
1011 |
|
1011 | |||
1012 | return ret; |
|
1012 | return ret; | |
1013 | } |
|
1013 | } | |
1014 |
|
1014 | |||
1015 | int suspend_science_tasks( void ) |
|
1015 | int suspend_science_tasks( void ) | |
1016 | { |
|
1016 | { | |
1017 | /** This function suspends the science tasks. |
|
1017 | /** This function suspends the science tasks. | |
1018 | * |
|
1018 | * | |
1019 | * @return RTEMS directive status codes: |
|
1019 | * @return RTEMS directive status codes: | |
1020 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
1020 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
1021 | * - RTEMS_INVALID_ID - task id invalid |
|
1021 | * - RTEMS_INVALID_ID - task id invalid | |
1022 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
1022 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
1023 | * |
|
1023 | * | |
1024 | */ |
|
1024 | */ | |
1025 |
|
1025 | |||
1026 | rtems_status_code status; |
|
1026 | rtems_status_code status; | |
1027 |
|
1027 | |||
1028 | PRINTF("in suspend_science_tasks\n") |
|
1028 | PRINTF("in suspend_science_tasks\n") | |
1029 |
|
1029 | |||
1030 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 |
|
1030 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 | |
1031 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1031 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1032 | { |
|
1032 | { | |
1033 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
1033 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) | |
1034 | } |
|
1034 | } | |
1035 | else |
|
1035 | else | |
1036 | { |
|
1036 | { | |
1037 | status = RTEMS_SUCCESSFUL; |
|
1037 | status = RTEMS_SUCCESSFUL; | |
1038 | } |
|
1038 | } | |
1039 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 |
|
1039 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 | |
1040 | { |
|
1040 | { | |
1041 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); |
|
1041 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); | |
1042 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1042 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1043 | { |
|
1043 | { | |
1044 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) |
|
1044 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) | |
1045 | } |
|
1045 | } | |
1046 | else |
|
1046 | else | |
1047 | { |
|
1047 | { | |
1048 | status = RTEMS_SUCCESSFUL; |
|
1048 | status = RTEMS_SUCCESSFUL; | |
1049 | } |
|
1049 | } | |
1050 | } |
|
1050 | } | |
1051 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 |
|
1051 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 | |
1052 | { |
|
1052 | { | |
1053 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); |
|
1053 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); | |
1054 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1054 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1055 | { |
|
1055 | { | |
1056 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) |
|
1056 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) | |
1057 | } |
|
1057 | } | |
1058 | else |
|
1058 | else | |
1059 | { |
|
1059 | { | |
1060 | status = RTEMS_SUCCESSFUL; |
|
1060 | status = RTEMS_SUCCESSFUL; | |
1061 | } |
|
1061 | } | |
1062 | } |
|
1062 | } | |
1063 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 |
|
1063 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 | |
1064 | { |
|
1064 | { | |
1065 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); |
|
1065 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); | |
1066 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1066 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1067 | { |
|
1067 | { | |
1068 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) |
|
1068 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) | |
1069 | } |
|
1069 | } | |
1070 | else |
|
1070 | else | |
1071 | { |
|
1071 | { | |
1072 | status = RTEMS_SUCCESSFUL; |
|
1072 | status = RTEMS_SUCCESSFUL; | |
1073 | } |
|
1073 | } | |
1074 | } |
|
1074 | } | |
1075 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 |
|
1075 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 | |
1076 | { |
|
1076 | { | |
1077 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); |
|
1077 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); | |
1078 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1078 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1079 | { |
|
1079 | { | |
1080 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) |
|
1080 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) | |
1081 | } |
|
1081 | } | |
1082 | else |
|
1082 | else | |
1083 | { |
|
1083 | { | |
1084 | status = RTEMS_SUCCESSFUL; |
|
1084 | status = RTEMS_SUCCESSFUL; | |
1085 | } |
|
1085 | } | |
1086 | } |
|
1086 | } | |
1087 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 |
|
1087 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 | |
1088 | { |
|
1088 | { | |
1089 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); |
|
1089 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); | |
1090 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1090 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1091 | { |
|
1091 | { | |
1092 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) |
|
1092 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) | |
1093 | } |
|
1093 | } | |
1094 | else |
|
1094 | else | |
1095 | { |
|
1095 | { | |
1096 | status = RTEMS_SUCCESSFUL; |
|
1096 | status = RTEMS_SUCCESSFUL; | |
1097 | } |
|
1097 | } | |
1098 | } |
|
1098 | } | |
1099 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM |
|
1099 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM | |
1100 | { |
|
1100 | { | |
1101 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); |
|
1101 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); | |
1102 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1102 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1103 | { |
|
1103 | { | |
1104 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) |
|
1104 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) | |
1105 | } |
|
1105 | } | |
1106 | else |
|
1106 | else | |
1107 | { |
|
1107 | { | |
1108 | status = RTEMS_SUCCESSFUL; |
|
1108 | status = RTEMS_SUCCESSFUL; | |
1109 | } |
|
1109 | } | |
1110 | } |
|
1110 | } | |
1111 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 |
|
1111 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 | |
1112 | { |
|
1112 | { | |
1113 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); |
|
1113 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); | |
1114 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1114 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1115 | { |
|
1115 | { | |
1116 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) |
|
1116 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) | |
1117 | } |
|
1117 | } | |
1118 | else |
|
1118 | else | |
1119 | { |
|
1119 | { | |
1120 | status = RTEMS_SUCCESSFUL; |
|
1120 | status = RTEMS_SUCCESSFUL; | |
1121 | } |
|
1121 | } | |
1122 | } |
|
1122 | } | |
1123 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 |
|
1123 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 | |
1124 | { |
|
1124 | { | |
1125 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); |
|
1125 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); | |
1126 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1126 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1127 | { |
|
1127 | { | |
1128 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) |
|
1128 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) | |
1129 | } |
|
1129 | } | |
1130 | else |
|
1130 | else | |
1131 | { |
|
1131 | { | |
1132 | status = RTEMS_SUCCESSFUL; |
|
1132 | status = RTEMS_SUCCESSFUL; | |
1133 | } |
|
1133 | } | |
1134 | } |
|
1134 | } | |
1135 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 |
|
1135 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 | |
1136 | { |
|
1136 | { | |
1137 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); |
|
1137 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); | |
1138 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1138 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1139 | { |
|
1139 | { | |
1140 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) |
|
1140 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) | |
1141 | } |
|
1141 | } | |
1142 | else |
|
1142 | else | |
1143 | { |
|
1143 | { | |
1144 | status = RTEMS_SUCCESSFUL; |
|
1144 | status = RTEMS_SUCCESSFUL; | |
1145 | } |
|
1145 | } | |
1146 | } |
|
1146 | } | |
1147 |
|
1147 | |||
1148 | return status; |
|
1148 | return status; | |
1149 | } |
|
1149 | } | |
1150 |
|
1150 | |||
1151 | int suspend_asm_tasks( void ) |
|
1151 | int suspend_asm_tasks( void ) | |
1152 | { |
|
1152 | { | |
1153 | /** This function suspends the science tasks. |
|
1153 | /** This function suspends the science tasks. | |
1154 | * |
|
1154 | * | |
1155 | * @return RTEMS directive status codes: |
|
1155 | * @return RTEMS directive status codes: | |
1156 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
1156 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
1157 | * - RTEMS_INVALID_ID - task id invalid |
|
1157 | * - RTEMS_INVALID_ID - task id invalid | |
1158 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
1158 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
1159 | * |
|
1159 | * | |
1160 | */ |
|
1160 | */ | |
1161 |
|
1161 | |||
1162 | rtems_status_code status; |
|
1162 | rtems_status_code status; | |
1163 |
|
1163 | |||
1164 | PRINTF("in suspend_science_tasks\n") |
|
1164 | PRINTF("in suspend_science_tasks\n") | |
1165 |
|
1165 | |||
1166 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 |
|
1166 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 | |
1167 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1167 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1168 | { |
|
1168 | { | |
1169 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
1169 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) | |
1170 | } |
|
1170 | } | |
1171 | else |
|
1171 | else | |
1172 | { |
|
1172 | { | |
1173 | status = RTEMS_SUCCESSFUL; |
|
1173 | status = RTEMS_SUCCESSFUL; | |
1174 | } |
|
1174 | } | |
1175 |
|
1175 | |||
1176 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 |
|
1176 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 | |
1177 | { |
|
1177 | { | |
1178 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); |
|
1178 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); | |
1179 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1179 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1180 | { |
|
1180 | { | |
1181 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) |
|
1181 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) | |
1182 | } |
|
1182 | } | |
1183 | else |
|
1183 | else | |
1184 | { |
|
1184 | { | |
1185 | status = RTEMS_SUCCESSFUL; |
|
1185 | status = RTEMS_SUCCESSFUL; | |
1186 | } |
|
1186 | } | |
1187 | } |
|
1187 | } | |
1188 |
|
1188 | |||
1189 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 |
|
1189 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 | |
1190 | { |
|
1190 | { | |
1191 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); |
|
1191 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); | |
1192 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1192 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1193 | { |
|
1193 | { | |
1194 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) |
|
1194 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) | |
1195 | } |
|
1195 | } | |
1196 | else |
|
1196 | else | |
1197 | { |
|
1197 | { | |
1198 | status = RTEMS_SUCCESSFUL; |
|
1198 | status = RTEMS_SUCCESSFUL; | |
1199 | } |
|
1199 | } | |
1200 | } |
|
1200 | } | |
1201 |
|
1201 | |||
1202 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 |
|
1202 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 | |
1203 | { |
|
1203 | { | |
1204 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); |
|
1204 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); | |
1205 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1205 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1206 | { |
|
1206 | { | |
1207 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) |
|
1207 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) | |
1208 | } |
|
1208 | } | |
1209 | else |
|
1209 | else | |
1210 | { |
|
1210 | { | |
1211 | status = RTEMS_SUCCESSFUL; |
|
1211 | status = RTEMS_SUCCESSFUL; | |
1212 | } |
|
1212 | } | |
1213 | } |
|
1213 | } | |
1214 |
|
1214 | |||
1215 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 |
|
1215 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 | |
1216 | { |
|
1216 | { | |
1217 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); |
|
1217 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); | |
1218 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1218 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1219 | { |
|
1219 | { | |
1220 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) |
|
1220 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) | |
1221 | } |
|
1221 | } | |
1222 | else |
|
1222 | else | |
1223 | { |
|
1223 | { | |
1224 | status = RTEMS_SUCCESSFUL; |
|
1224 | status = RTEMS_SUCCESSFUL; | |
1225 | } |
|
1225 | } | |
1226 | } |
|
1226 | } | |
1227 |
|
1227 | |||
1228 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 |
|
1228 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 | |
1229 | { |
|
1229 | { | |
1230 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); |
|
1230 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); | |
1231 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1231 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1232 | { |
|
1232 | { | |
1233 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) |
|
1233 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) | |
1234 | } |
|
1234 | } | |
1235 | else |
|
1235 | else | |
1236 | { |
|
1236 | { | |
1237 | status = RTEMS_SUCCESSFUL; |
|
1237 | status = RTEMS_SUCCESSFUL; | |
1238 | } |
|
1238 | } | |
1239 | } |
|
1239 | } | |
1240 |
|
1240 | |||
1241 | return status; |
|
1241 | return status; | |
1242 | } |
|
1242 | } | |
1243 |
|
1243 | |||
1244 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) |
|
1244 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) | |
1245 | { |
|
1245 | { | |
1246 | WFP_reset_current_ring_nodes(); |
|
1246 | WFP_reset_current_ring_nodes(); | |
1247 |
|
1247 | |||
1248 | reset_waveform_picker_regs(); |
|
1248 | reset_waveform_picker_regs(); | |
1249 |
|
1249 | |||
1250 | set_wfp_burst_enable_register( mode ); |
|
1250 | set_wfp_burst_enable_register( mode ); | |
1251 |
|
1251 | |||
1252 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
1252 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); | |
1253 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
1253 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); | |
1254 |
|
1254 | |||
1255 | if (transitionCoarseTime == 0) |
|
1255 | if (transitionCoarseTime == 0) | |
1256 | { |
|
1256 | { | |
1257 | // instant transition means transition on the next valid date |
|
1257 | // instant transition means transition on the next valid date | |
1258 | // this is mandatory to have a good snapshot period a a good correction of the snapshot period |
|
1258 | // this is mandatory to have a good snapshot period a a good correction of the snapshot period | |
1259 | waveform_picker_regs->start_date = time_management_regs->coarse_time + 1; |
|
1259 | waveform_picker_regs->start_date = time_management_regs->coarse_time + 1; | |
1260 | } |
|
1260 | } | |
1261 | else |
|
1261 | else | |
1262 | { |
|
1262 | { | |
1263 | waveform_picker_regs->start_date = transitionCoarseTime; |
|
1263 | waveform_picker_regs->start_date = transitionCoarseTime; | |
1264 | } |
|
1264 | } | |
1265 |
|
1265 | |||
1266 | } |
|
1266 | } | |
1267 |
|
1267 | |||
1268 | void launch_spectral_matrix( void ) |
|
1268 | void launch_spectral_matrix( void ) | |
1269 | { |
|
1269 | { | |
1270 | SM_reset_current_ring_nodes(); |
|
1270 | SM_reset_current_ring_nodes(); | |
1271 |
|
1271 | |||
1272 | reset_spectral_matrix_regs(); |
|
1272 | reset_spectral_matrix_regs(); | |
1273 |
|
1273 | |||
1274 | reset_nb_sm(); |
|
1274 | reset_nb_sm(); | |
1275 |
|
1275 | |||
1276 | set_sm_irq_onNewMatrix( 1 ); |
|
1276 | set_sm_irq_onNewMatrix( 1 ); | |
1277 |
|
1277 | |||
1278 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
1278 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); | |
1279 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
1279 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); | |
1280 |
|
1280 | |||
1281 | } |
|
1281 | } | |
1282 |
|
1282 | |||
1283 | void set_sm_irq_onNewMatrix( unsigned char value ) |
|
1283 | void set_sm_irq_onNewMatrix( unsigned char value ) | |
1284 | { |
|
1284 | { | |
1285 | if (value == 1) |
|
1285 | if (value == 1) | |
1286 | { |
|
1286 | { | |
1287 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; |
|
1287 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; | |
1288 | } |
|
1288 | } | |
1289 | else |
|
1289 | else | |
1290 | { |
|
1290 | { | |
1291 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 |
|
1291 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 | |
1292 | } |
|
1292 | } | |
1293 | } |
|
1293 | } | |
1294 |
|
1294 | |||
1295 | void set_sm_irq_onError( unsigned char value ) |
|
1295 | void set_sm_irq_onError( unsigned char value ) | |
1296 | { |
|
1296 | { | |
1297 | if (value == 1) |
|
1297 | if (value == 1) | |
1298 | { |
|
1298 | { | |
1299 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02; |
|
1299 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02; | |
1300 | } |
|
1300 | } | |
1301 | else |
|
1301 | else | |
1302 | { |
|
1302 | { | |
1303 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101 |
|
1303 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101 | |
1304 | } |
|
1304 | } | |
1305 | } |
|
1305 | } | |
1306 |
|
1306 | |||
1307 | //***************************** |
|
1307 | //***************************** | |
1308 | // CONFIGURE CALIBRATION SIGNAL |
|
1308 | // CONFIGURE CALIBRATION SIGNAL | |
1309 | void setCalibrationPrescaler( unsigned int prescaler ) |
|
1309 | void setCalibrationPrescaler( unsigned int prescaler ) | |
1310 | { |
|
1310 | { | |
1311 | // prescaling of the master clock (25 MHz) |
|
1311 | // prescaling of the master clock (25 MHz) | |
1312 | // master clock is divided by 2^prescaler |
|
1312 | // master clock is divided by 2^prescaler | |
1313 | time_management_regs->calPrescaler = prescaler; |
|
1313 | time_management_regs->calPrescaler = prescaler; | |
1314 | } |
|
1314 | } | |
1315 |
|
1315 | |||
1316 | void setCalibrationDivisor( unsigned int divisionFactor ) |
|
1316 | void setCalibrationDivisor( unsigned int divisionFactor ) | |
1317 | { |
|
1317 | { | |
1318 | // division of the prescaled clock by the division factor |
|
1318 | // division of the prescaled clock by the division factor | |
1319 | time_management_regs->calDivisor = divisionFactor; |
|
1319 | time_management_regs->calDivisor = divisionFactor; | |
1320 | } |
|
1320 | } | |
1321 |
|
1321 | |||
1322 | void setCalibrationData( void ){ |
|
1322 | void setCalibrationData( void ){ | |
1323 | unsigned int k; |
|
1323 | unsigned int k; | |
1324 | unsigned short data; |
|
1324 | unsigned short data; | |
1325 | float val; |
|
1325 | float val; | |
1326 | float f0; |
|
1326 | float f0; | |
1327 | float f1; |
|
1327 | float f1; | |
1328 | float fs; |
|
1328 | float fs; | |
1329 | float Ts; |
|
1329 | float Ts; | |
1330 | float scaleFactor; |
|
1330 | float scaleFactor; | |
1331 |
|
1331 | |||
1332 | f0 = 625; |
|
1332 | f0 = 625; | |
1333 | f1 = 10000; |
|
1333 | f1 = 10000; | |
1334 | fs = 160256.410; |
|
1334 | fs = 160256.410; | |
1335 | Ts = 1. / fs; |
|
1335 | Ts = 1. / fs; | |
1336 | scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV |
|
1336 | scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV | |
1337 |
|
1337 | |||
1338 | time_management_regs->calDataPtr = 0x00; |
|
1338 | time_management_regs->calDataPtr = 0x00; | |
1339 |
|
1339 | |||
1340 | // build the signal for the SCM calibration |
|
1340 | // build the signal for the SCM calibration | |
1341 | for (k=0; k<256; k++) |
|
1341 | for (k=0; k<256; k++) | |
1342 | { |
|
1342 | { | |
1343 | val = sin( 2 * pi * f0 * k * Ts ) |
|
1343 | val = sin( 2 * pi * f0 * k * Ts ) | |
1344 | + sin( 2 * pi * f1 * k * Ts ); |
|
1344 | + sin( 2 * pi * f1 * k * Ts ); | |
1345 | data = (unsigned short) ((val * scaleFactor) + 2048); |
|
1345 | data = (unsigned short) ((val * scaleFactor) + 2048); | |
1346 | time_management_regs->calData = data & 0xfff; |
|
1346 | time_management_regs->calData = data & 0xfff; | |
1347 | } |
|
1347 | } | |
1348 | } |
|
1348 | } | |
1349 |
|
1349 | |||
1350 | void setCalibrationDataInterleaved( void ){ |
|
1350 | void setCalibrationDataInterleaved( void ){ | |
1351 | unsigned int k; |
|
1351 | unsigned int k; | |
1352 | float val; |
|
1352 | float val; | |
1353 | float f0; |
|
1353 | float f0; | |
1354 | float f1; |
|
1354 | float f1; | |
1355 | float fs; |
|
1355 | float fs; | |
1356 | float Ts; |
|
1356 | float Ts; | |
1357 | unsigned short data[384]; |
|
1357 | unsigned short data[384]; | |
1358 | unsigned char *dataPtr; |
|
1358 | unsigned char *dataPtr; | |
1359 |
|
1359 | |||
1360 | f0 = 625; |
|
1360 | f0 = 625; | |
1361 | f1 = 10000; |
|
1361 | f1 = 10000; | |
1362 | fs = 240384.615; |
|
1362 | fs = 240384.615; | |
1363 | Ts = 1. / fs; |
|
1363 | Ts = 1. / fs; | |
1364 |
|
1364 | |||
1365 | time_management_regs->calDataPtr = 0x00; |
|
1365 | time_management_regs->calDataPtr = 0x00; | |
1366 |
|
1366 | |||
1367 | // build the signal for the SCM calibration |
|
1367 | // build the signal for the SCM calibration | |
1368 | for (k=0; k<384; k++) |
|
1368 | for (k=0; k<384; k++) | |
1369 | { |
|
1369 | { | |
1370 | val = sin( 2 * pi * f0 * k * Ts ) |
|
1370 | val = sin( 2 * pi * f0 * k * Ts ) | |
1371 | + sin( 2 * pi * f1 * k * Ts ); |
|
1371 | + sin( 2 * pi * f1 * k * Ts ); | |
1372 | data[k] = (unsigned short) (val * 512 + 2048); |
|
1372 | data[k] = (unsigned short) (val * 512 + 2048); | |
1373 | } |
|
1373 | } | |
1374 |
|
1374 | |||
1375 | // write the signal in interleaved mode |
|
1375 | // write the signal in interleaved mode | |
1376 | for (k=0; k<128; k++) |
|
1376 | for (k=0; k<128; k++) | |
1377 | { |
|
1377 | { | |
1378 | dataPtr = (unsigned char*) &data[k*3 + 2]; |
|
1378 | dataPtr = (unsigned char*) &data[k*3 + 2]; | |
1379 | time_management_regs->calData = (data[k*3] & 0xfff) |
|
1379 | time_management_regs->calData = (data[k*3] & 0xfff) | |
1380 | + ( (dataPtr[0] & 0x3f) << 12); |
|
1380 | + ( (dataPtr[0] & 0x3f) << 12); | |
1381 | time_management_regs->calData = (data[k*3 + 1] & 0xfff) |
|
1381 | time_management_regs->calData = (data[k*3 + 1] & 0xfff) | |
1382 | + ( (dataPtr[1] & 0x3f) << 12); |
|
1382 | + ( (dataPtr[1] & 0x3f) << 12); | |
1383 | } |
|
1383 | } | |
1384 | } |
|
1384 | } | |
1385 |
|
1385 | |||
1386 | void setCalibrationReload( bool state) |
|
1386 | void setCalibrationReload( bool state) | |
1387 | { |
|
1387 | { | |
1388 | if (state == true) |
|
1388 | if (state == true) | |
1389 | { |
|
1389 | { | |
1390 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000] |
|
1390 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000] | |
1391 | } |
|
1391 | } | |
1392 | else |
|
1392 | else | |
1393 | { |
|
1393 | { | |
1394 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111] |
|
1394 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111] | |
1395 | } |
|
1395 | } | |
1396 | } |
|
1396 | } | |
1397 |
|
1397 | |||
1398 | void setCalibrationEnable( bool state ) |
|
1398 | void setCalibrationEnable( bool state ) | |
1399 | { |
|
1399 | { | |
1400 | // this bit drives the multiplexer |
|
1400 | // this bit drives the multiplexer | |
1401 | if (state == true) |
|
1401 | if (state == true) | |
1402 | { |
|
1402 | { | |
1403 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000] |
|
1403 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000] | |
1404 | } |
|
1404 | } | |
1405 | else |
|
1405 | else | |
1406 | { |
|
1406 | { | |
1407 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111] |
|
1407 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111] | |
1408 | } |
|
1408 | } | |
1409 | } |
|
1409 | } | |
1410 |
|
1410 | |||
1411 | void setCalibrationInterleaved( bool state ) |
|
1411 | void setCalibrationInterleaved( bool state ) | |
1412 | { |
|
1412 | { | |
1413 | // this bit drives the multiplexer |
|
1413 | // this bit drives the multiplexer | |
1414 | if (state == true) |
|
1414 | if (state == true) | |
1415 | { |
|
1415 | { | |
1416 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000] |
|
1416 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000] | |
1417 | } |
|
1417 | } | |
1418 | else |
|
1418 | else | |
1419 | { |
|
1419 | { | |
1420 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111] |
|
1420 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111] | |
1421 | } |
|
1421 | } | |
1422 | } |
|
1422 | } | |
1423 |
|
1423 | |||
1424 | void setCalibration( bool state ) |
|
1424 | void setCalibration( bool state ) | |
1425 | { |
|
1425 | { | |
1426 | if (state == true) |
|
1426 | if (state == true) | |
1427 | { |
|
1427 | { | |
1428 | setCalibrationEnable( true ); |
|
1428 | setCalibrationEnable( true ); | |
1429 | setCalibrationReload( false ); |
|
1429 | setCalibrationReload( false ); | |
1430 | set_hk_lfr_calib_enable( true ); |
|
1430 | set_hk_lfr_calib_enable( true ); | |
1431 | } |
|
1431 | } | |
1432 | else |
|
1432 | else | |
1433 | { |
|
1433 | { | |
1434 | setCalibrationEnable( false ); |
|
1434 | setCalibrationEnable( false ); | |
1435 | setCalibrationReload( true ); |
|
1435 | setCalibrationReload( true ); | |
1436 | set_hk_lfr_calib_enable( false ); |
|
1436 | set_hk_lfr_calib_enable( false ); | |
1437 | } |
|
1437 | } | |
1438 | } |
|
1438 | } | |
1439 |
|
1439 | |||
1440 | void configureCalibration( bool interleaved ) |
|
1440 | void configureCalibration( bool interleaved ) | |
1441 | { |
|
1441 | { | |
1442 | setCalibration( false ); |
|
1442 | setCalibration( false ); | |
1443 | if ( interleaved == true ) |
|
1443 | if ( interleaved == true ) | |
1444 | { |
|
1444 | { | |
1445 | setCalibrationInterleaved( true ); |
|
1445 | setCalibrationInterleaved( true ); | |
1446 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 |
|
1446 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 | |
1447 | setCalibrationDivisor( 26 ); // => 240 384 |
|
1447 | setCalibrationDivisor( 26 ); // => 240 384 | |
1448 | setCalibrationDataInterleaved(); |
|
1448 | setCalibrationDataInterleaved(); | |
1449 | } |
|
1449 | } | |
1450 | else |
|
1450 | else | |
1451 | { |
|
1451 | { | |
1452 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 |
|
1452 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 | |
1453 | setCalibrationDivisor( 38 ); // => 160 256 (39 - 1) |
|
1453 | setCalibrationDivisor( 38 ); // => 160 256 (39 - 1) | |
1454 | setCalibrationData(); |
|
1454 | setCalibrationData(); | |
1455 | } |
|
1455 | } | |
1456 | } |
|
1456 | } | |
1457 |
|
1457 | |||
1458 | //**************** |
|
1458 | //**************** | |
1459 | // CLOSING ACTIONS |
|
1459 | // CLOSING ACTIONS | |
1460 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
1460 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) | |
1461 | { |
|
1461 | { | |
1462 | /** This function is used to update the HK packets statistics after a successful TC execution. |
|
1462 | /** This function is used to update the HK packets statistics after a successful TC execution. | |
1463 | * |
|
1463 | * | |
1464 | * @param TC points to the TC being processed |
|
1464 | * @param TC points to the TC being processed | |
1465 | * @param time is the time used to date the TC execution |
|
1465 | * @param time is the time used to date the TC execution | |
1466 | * |
|
1466 | * | |
1467 | */ |
|
1467 | */ | |
1468 |
|
1468 | |||
1469 | unsigned int val; |
|
1469 | unsigned int val; | |
1470 |
|
1470 | |||
1471 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; |
|
1471 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; | |
1472 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; |
|
1472 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; | |
1473 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; |
|
1473 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; | |
1474 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; |
|
1474 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; | |
1475 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; |
|
1475 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; | |
1476 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; |
|
1476 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; | |
1477 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; |
|
1477 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; | |
1478 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; |
|
1478 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; | |
1479 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; |
|
1479 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; | |
1480 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; |
|
1480 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; | |
1481 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; |
|
1481 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; | |
1482 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; |
|
1482 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; | |
1483 |
|
1483 | |||
1484 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; |
|
1484 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; | |
1485 | val++; |
|
1485 | val++; | |
1486 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); |
|
1486 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); | |
1487 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); |
|
1487 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); | |
1488 | } |
|
1488 | } | |
1489 |
|
1489 | |||
1490 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
1490 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) | |
1491 | { |
|
1491 | { | |
1492 | /** This function is used to update the HK packets statistics after a TC rejection. |
|
1492 | /** This function is used to update the HK packets statistics after a TC rejection. | |
1493 | * |
|
1493 | * | |
1494 | * @param TC points to the TC being processed |
|
1494 | * @param TC points to the TC being processed | |
1495 | * @param time is the time used to date the TC rejection |
|
1495 | * @param time is the time used to date the TC rejection | |
1496 | * |
|
1496 | * | |
1497 | */ |
|
1497 | */ | |
1498 |
|
1498 | |||
1499 | unsigned int val; |
|
1499 | unsigned int val; | |
1500 |
|
1500 | |||
1501 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; |
|
1501 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; | |
1502 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; |
|
1502 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; | |
1503 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; |
|
1503 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; | |
1504 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; |
|
1504 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; | |
1505 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; |
|
1505 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; | |
1506 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; |
|
1506 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; | |
1507 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; |
|
1507 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; | |
1508 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; |
|
1508 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; | |
1509 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; |
|
1509 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; | |
1510 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; |
|
1510 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; | |
1511 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; |
|
1511 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; | |
1512 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; |
|
1512 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; | |
1513 |
|
1513 | |||
1514 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; |
|
1514 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; | |
1515 | val++; |
|
1515 | val++; | |
1516 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); |
|
1516 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); | |
1517 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); |
|
1517 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); | |
1518 | } |
|
1518 | } | |
1519 |
|
1519 | |||
1520 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) |
|
1520 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) | |
1521 | { |
|
1521 | { | |
1522 | /** This function is the last step of the TC execution workflow. |
|
1522 | /** This function is the last step of the TC execution workflow. | |
1523 | * |
|
1523 | * | |
1524 | * @param TC points to the TC being processed |
|
1524 | * @param TC points to the TC being processed | |
1525 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) |
|
1525 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) | |
1526 | * @param queue_id is the id of the RTEMS message queue used to send TM packets |
|
1526 | * @param queue_id is the id of the RTEMS message queue used to send TM packets | |
1527 | * @param time is the time used to date the TC execution |
|
1527 | * @param time is the time used to date the TC execution | |
1528 | * |
|
1528 | * | |
1529 | */ |
|
1529 | */ | |
1530 |
|
1530 | |||
1531 | unsigned char requestedMode; |
|
1531 | unsigned char requestedMode; | |
1532 |
|
1532 | |||
1533 | if (result == LFR_SUCCESSFUL) |
|
1533 | if (result == LFR_SUCCESSFUL) | |
1534 | { |
|
1534 | { | |
1535 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
1535 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) | |
1536 | & |
|
1536 | & | |
1537 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
1537 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) | |
1538 | ) |
|
1538 | ) | |
1539 | { |
|
1539 | { | |
1540 | send_tm_lfr_tc_exe_success( TC, queue_id ); |
|
1540 | send_tm_lfr_tc_exe_success( TC, queue_id ); | |
1541 | } |
|
1541 | } | |
1542 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) |
|
1542 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) | |
1543 | { |
|
1543 | { | |
1544 | //********************************** |
|
1544 | //********************************** | |
1545 | // UPDATE THE LFRMODE LOCAL VARIABLE |
|
1545 | // UPDATE THE LFRMODE LOCAL VARIABLE | |
1546 | requestedMode = TC->dataAndCRC[1]; |
|
1546 | requestedMode = TC->dataAndCRC[1]; | |
1547 | updateLFRCurrentMode( requestedMode ); |
|
1547 | updateLFRCurrentMode( requestedMode ); | |
1548 | } |
|
1548 | } | |
1549 | } |
|
1549 | } | |
1550 | else if (result == LFR_EXE_ERROR) |
|
1550 | else if (result == LFR_EXE_ERROR) | |
1551 | { |
|
1551 | { | |
1552 | send_tm_lfr_tc_exe_error( TC, queue_id ); |
|
1552 | send_tm_lfr_tc_exe_error( TC, queue_id ); | |
1553 | } |
|
1553 | } | |
1554 | } |
|
1554 | } | |
1555 |
|
1555 | |||
1556 | //*************************** |
|
1556 | //*************************** | |
1557 | // Interrupt Service Routines |
|
1557 | // Interrupt Service Routines | |
1558 | rtems_isr commutation_isr1( rtems_vector_number vector ) |
|
1558 | rtems_isr commutation_isr1( rtems_vector_number vector ) | |
1559 | { |
|
1559 | { | |
1560 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1560 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
1561 | PRINTF("In commutation_isr1 *** Error sending event to DUMB\n") |
|
1561 | PRINTF("In commutation_isr1 *** Error sending event to DUMB\n") | |
1562 | } |
|
1562 | } | |
1563 | } |
|
1563 | } | |
1564 |
|
1564 | |||
1565 | rtems_isr commutation_isr2( rtems_vector_number vector ) |
|
1565 | rtems_isr commutation_isr2( rtems_vector_number vector ) | |
1566 | { |
|
1566 | { | |
1567 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1567 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
1568 | PRINTF("In commutation_isr2 *** Error sending event to DUMB\n") |
|
1568 | PRINTF("In commutation_isr2 *** Error sending event to DUMB\n") | |
1569 | } |
|
1569 | } | |
1570 | } |
|
1570 | } | |
1571 |
|
1571 | |||
1572 | //**************** |
|
1572 | //**************** | |
1573 | // OTHER FUNCTIONS |
|
1573 | // OTHER FUNCTIONS | |
1574 | void updateLFRCurrentMode( unsigned char requestedMode ) |
|
1574 | void updateLFRCurrentMode( unsigned char requestedMode ) | |
1575 | { |
|
1575 | { | |
1576 | /** This function updates the value of the global variable lfrCurrentMode. |
|
1576 | /** This function updates the value of the global variable lfrCurrentMode. | |
1577 | * |
|
1577 | * | |
1578 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. |
|
1578 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. | |
1579 | * |
|
1579 | * | |
1580 | */ |
|
1580 | */ | |
1581 |
|
1581 | |||
1582 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure |
|
1582 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure | |
1583 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d); |
|
1583 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d); | |
1584 | lfrCurrentMode = requestedMode; |
|
1584 | lfrCurrentMode = requestedMode; | |
1585 | } |
|
1585 | } | |
1586 |
|
1586 | |||
1587 | void set_lfr_soft_reset( unsigned char value ) |
|
1587 | void set_lfr_soft_reset( unsigned char value ) | |
1588 | { |
|
1588 | { | |
1589 | if (value == 1) |
|
1589 | if (value == 1) | |
1590 | { |
|
1590 | { | |
1591 | time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100] |
|
1591 | time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100] | |
1592 | } |
|
1592 | } | |
1593 | else |
|
1593 | else | |
1594 | { |
|
1594 | { | |
1595 | time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011] |
|
1595 | time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011] | |
1596 | } |
|
1596 | } | |
1597 | } |
|
1597 | } | |
1598 |
|
1598 | |||
1599 | void reset_lfr( void ) |
|
1599 | void reset_lfr( void ) | |
1600 | { |
|
1600 | { | |
1601 | set_lfr_soft_reset( 1 ); |
|
1601 | set_lfr_soft_reset( 1 ); | |
1602 |
|
1602 | |||
1603 | set_lfr_soft_reset( 0 ); |
|
1603 | set_lfr_soft_reset( 0 ); | |
1604 |
|
1604 | |||
1605 | set_hk_lfr_sc_potential_flag( true ); |
|
1605 | set_hk_lfr_sc_potential_flag( true ); | |
1606 | } |
|
1606 | } |
General Comments 0
You need to be logged in to leave comments.
Login now