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