@@ -1,113 +1,113 | |||||
1 | TEMPLATE = app |
|
1 | TEMPLATE = app | |
2 | # CONFIG += console v8 sim |
|
2 | # CONFIG += console v8 sim | |
3 | # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch |
|
3 | # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** vhdl_dev *** debug_tch | |
4 | # lpp_dpu_destid |
|
4 | # lpp_dpu_destid | |
5 | CONFIG += console verbose lpp_dpu_destid |
|
5 | CONFIG += console verbose lpp_dpu_destid | |
6 | CONFIG -= qt |
|
6 | CONFIG -= qt | |
7 |
|
7 | |||
8 | include(./sparc.pri) |
|
8 | include(./sparc.pri) | |
9 |
|
9 | |||
10 | # flight software version |
|
10 | # flight software version | |
11 | SWVERSION=-1-0 |
|
11 | SWVERSION=-1-0 | |
12 | DEFINES += SW_VERSION_N1=3 # major |
|
12 | DEFINES += SW_VERSION_N1=3 # major | |
13 | DEFINES += SW_VERSION_N2=0 # minor |
|
13 | DEFINES += SW_VERSION_N2=0 # minor | |
14 | DEFINES += SW_VERSION_N3=0 # patch |
|
14 | DEFINES += SW_VERSION_N3=0 # patch | |
15 |
DEFINES += SW_VERSION_N4= |
|
15 | DEFINES += SW_VERSION_N4=9 # internal | |
16 |
|
16 | |||
17 | # <GCOV> |
|
17 | # <GCOV> | |
18 | #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage |
|
18 | #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage | |
19 | #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc |
|
19 | #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc | |
20 | #LIBS += -lgcov /opt/GCOV/HOWTO_gcov_for_lfr_test/01A/lib/overload.o -lc |
|
20 | #LIBS += -lgcov /opt/GCOV/HOWTO_gcov_for_lfr_test/01A/lib/overload.o -lc | |
21 | # </GCOV> |
|
21 | # </GCOV> | |
22 |
|
22 | |||
23 | # <CHANGE BEFORE FLIGHT> |
|
23 | # <CHANGE BEFORE FLIGHT> | |
24 | contains( CONFIG, lpp_dpu_destid ) { |
|
24 | contains( CONFIG, lpp_dpu_destid ) { | |
25 | DEFINES += LPP_DPU_DESTID |
|
25 | DEFINES += LPP_DPU_DESTID | |
26 | } |
|
26 | } | |
27 | # </CHANGE BEFORE FLIGHT> |
|
27 | # </CHANGE BEFORE FLIGHT> | |
28 |
|
28 | |||
29 | contains( CONFIG, debug_tch ) { |
|
29 | contains( CONFIG, debug_tch ) { | |
30 | DEFINES += DEBUG_TCH |
|
30 | DEFINES += DEBUG_TCH | |
31 | } |
|
31 | } | |
32 | DEFINES += MSB_FIRST_TCH |
|
32 | DEFINES += MSB_FIRST_TCH | |
33 |
|
33 | |||
34 | contains( CONFIG, vhdl_dev ) { |
|
34 | contains( CONFIG, vhdl_dev ) { | |
35 | DEFINES += VHDL_DEV |
|
35 | DEFINES += VHDL_DEV | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 | contains( CONFIG, verbose ) { |
|
38 | contains( CONFIG, verbose ) { | |
39 | DEFINES += PRINT_MESSAGES_ON_CONSOLE |
|
39 | DEFINES += PRINT_MESSAGES_ON_CONSOLE | |
40 | } |
|
40 | } | |
41 |
|
41 | |||
42 | contains( CONFIG, debug_messages ) { |
|
42 | contains( CONFIG, debug_messages ) { | |
43 | DEFINES += DEBUG_MESSAGES |
|
43 | DEFINES += DEBUG_MESSAGES | |
44 | } |
|
44 | } | |
45 |
|
45 | |||
46 | contains( CONFIG, cpu_usage_report ) { |
|
46 | contains( CONFIG, cpu_usage_report ) { | |
47 | DEFINES += PRINT_TASK_STATISTICS |
|
47 | DEFINES += PRINT_TASK_STATISTICS | |
48 | } |
|
48 | } | |
49 |
|
49 | |||
50 | contains( CONFIG, stack_report ) { |
|
50 | contains( CONFIG, stack_report ) { | |
51 | DEFINES += PRINT_STACK_REPORT |
|
51 | DEFINES += PRINT_STACK_REPORT | |
52 | } |
|
52 | } | |
53 |
|
53 | |||
54 | contains( CONFIG, boot_messages ) { |
|
54 | contains( CONFIG, boot_messages ) { | |
55 | DEFINES += BOOT_MESSAGES |
|
55 | DEFINES += BOOT_MESSAGES | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | #doxygen.target = doxygen |
|
58 | #doxygen.target = doxygen | |
59 | #doxygen.commands = doxygen ../doc/Doxyfile |
|
59 | #doxygen.commands = doxygen ../doc/Doxyfile | |
60 | #QMAKE_EXTRA_TARGETS += doxygen |
|
60 | #QMAKE_EXTRA_TARGETS += doxygen | |
61 |
|
61 | |||
62 | TARGET = fsw |
|
62 | TARGET = fsw | |
63 |
|
63 | |||
64 | INCLUDEPATH += \ |
|
64 | INCLUDEPATH += \ | |
65 | $${PWD}/../src \ |
|
65 | $${PWD}/../src \ | |
66 | $${PWD}/../header \ |
|
66 | $${PWD}/../header \ | |
67 | $${PWD}/../header/lfr_common_headers \ |
|
67 | $${PWD}/../header/lfr_common_headers \ | |
68 | $${PWD}/../header/processing \ |
|
68 | $${PWD}/../header/processing \ | |
69 | $${PWD}/../LFR_basic-parameters |
|
69 | $${PWD}/../LFR_basic-parameters | |
70 |
|
70 | |||
71 | SOURCES += \ |
|
71 | SOURCES += \ | |
72 | ../src/wf_handler.c \ |
|
72 | ../src/wf_handler.c \ | |
73 | ../src/tc_handler.c \ |
|
73 | ../src/tc_handler.c \ | |
74 | ../src/fsw_misc.c \ |
|
74 | ../src/fsw_misc.c \ | |
75 | ../src/fsw_init.c \ |
|
75 | ../src/fsw_init.c \ | |
76 | ../src/fsw_globals.c \ |
|
76 | ../src/fsw_globals.c \ | |
77 | ../src/fsw_spacewire.c \ |
|
77 | ../src/fsw_spacewire.c \ | |
78 | ../src/tc_load_dump_parameters.c \ |
|
78 | ../src/tc_load_dump_parameters.c \ | |
79 | ../src/tm_lfr_tc_exe.c \ |
|
79 | ../src/tm_lfr_tc_exe.c \ | |
80 | ../src/tc_acceptance.c \ |
|
80 | ../src/tc_acceptance.c \ | |
81 | ../src/processing/fsw_processing.c \ |
|
81 | ../src/processing/fsw_processing.c \ | |
82 | ../src/processing/avf0_prc0.c \ |
|
82 | ../src/processing/avf0_prc0.c \ | |
83 | ../src/processing/avf1_prc1.c \ |
|
83 | ../src/processing/avf1_prc1.c \ | |
84 | ../src/processing/avf2_prc2.c \ |
|
84 | ../src/processing/avf2_prc2.c \ | |
85 | ../src/lfr_cpu_usage_report.c \ |
|
85 | ../src/lfr_cpu_usage_report.c \ | |
86 | ../LFR_basic-parameters/basic_parameters.c |
|
86 | ../LFR_basic-parameters/basic_parameters.c | |
87 |
|
87 | |||
88 | HEADERS += \ |
|
88 | HEADERS += \ | |
89 | ../header/wf_handler.h \ |
|
89 | ../header/wf_handler.h \ | |
90 | ../header/tc_handler.h \ |
|
90 | ../header/tc_handler.h \ | |
91 | ../header/grlib_regs.h \ |
|
91 | ../header/grlib_regs.h \ | |
92 | ../header/fsw_misc.h \ |
|
92 | ../header/fsw_misc.h \ | |
93 | ../header/fsw_init.h \ |
|
93 | ../header/fsw_init.h \ | |
94 | ../header/fsw_spacewire.h \ |
|
94 | ../header/fsw_spacewire.h \ | |
95 | ../header/tc_load_dump_parameters.h \ |
|
95 | ../header/tc_load_dump_parameters.h \ | |
96 | ../header/tm_lfr_tc_exe.h \ |
|
96 | ../header/tm_lfr_tc_exe.h \ | |
97 | ../header/tc_acceptance.h \ |
|
97 | ../header/tc_acceptance.h \ | |
98 | ../header/processing/fsw_processing.h \ |
|
98 | ../header/processing/fsw_processing.h \ | |
99 | ../header/processing/avf0_prc0.h \ |
|
99 | ../header/processing/avf0_prc0.h \ | |
100 | ../header/processing/avf1_prc1.h \ |
|
100 | ../header/processing/avf1_prc1.h \ | |
101 | ../header/processing/avf2_prc2.h \ |
|
101 | ../header/processing/avf2_prc2.h \ | |
102 | ../header/fsw_params_wf_handler.h \ |
|
102 | ../header/fsw_params_wf_handler.h \ | |
103 | ../header/lfr_cpu_usage_report.h \ |
|
103 | ../header/lfr_cpu_usage_report.h \ | |
104 | ../header/lfr_common_headers/ccsds_types.h \ |
|
104 | ../header/lfr_common_headers/ccsds_types.h \ | |
105 | ../header/lfr_common_headers/fsw_params.h \ |
|
105 | ../header/lfr_common_headers/fsw_params.h \ | |
106 | ../header/lfr_common_headers/fsw_params_nb_bytes.h \ |
|
106 | ../header/lfr_common_headers/fsw_params_nb_bytes.h \ | |
107 | ../header/lfr_common_headers/fsw_params_processing.h \ |
|
107 | ../header/lfr_common_headers/fsw_params_processing.h \ | |
108 | ../header/lfr_common_headers/TC_types.h \ |
|
108 | ../header/lfr_common_headers/TC_types.h \ | |
109 | ../header/lfr_common_headers/tm_byte_positions.h \ |
|
109 | ../header/lfr_common_headers/tm_byte_positions.h \ | |
110 | ../LFR_basic-parameters/basic_parameters.h \ |
|
110 | ../LFR_basic-parameters/basic_parameters.h \ | |
111 | ../LFR_basic-parameters/basic_parameters_params.h \ |
|
111 | ../LFR_basic-parameters/basic_parameters_params.h \ | |
112 | ../header/GscMemoryLPP.hpp |
|
112 | ../header/GscMemoryLPP.hpp | |
113 |
|
113 |
@@ -1,1169 +1,1169 | |||||
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( queue_snd_id ); |
|
95 | result = action_dump_par( queue_snd_id ); | |
96 | close_action( &TC, result, queue_snd_id ); |
|
96 | close_action( &TC, result, queue_snd_id ); | |
97 | break; |
|
97 | break; | |
98 | case TC_SUBTYPE_ENTER: |
|
98 | case TC_SUBTYPE_ENTER: | |
99 | result = action_enter_mode( &TC, queue_snd_id ); |
|
99 | result = action_enter_mode( &TC, queue_snd_id ); | |
100 | close_action( &TC, result, queue_snd_id ); |
|
100 | close_action( &TC, result, queue_snd_id ); | |
101 | break; |
|
101 | break; | |
102 | case TC_SUBTYPE_UPDT_INFO: |
|
102 | case TC_SUBTYPE_UPDT_INFO: | |
103 | result = action_update_info( &TC, queue_snd_id ); |
|
103 | result = action_update_info( &TC, queue_snd_id ); | |
104 | close_action( &TC, result, queue_snd_id ); |
|
104 | close_action( &TC, result, queue_snd_id ); | |
105 | break; |
|
105 | break; | |
106 | case TC_SUBTYPE_EN_CAL: |
|
106 | case TC_SUBTYPE_EN_CAL: | |
107 | result = action_enable_calibration( &TC, queue_snd_id, time ); |
|
107 | result = action_enable_calibration( &TC, queue_snd_id, time ); | |
108 | close_action( &TC, result, queue_snd_id ); |
|
108 | close_action( &TC, result, queue_snd_id ); | |
109 | break; |
|
109 | break; | |
110 | case TC_SUBTYPE_DIS_CAL: |
|
110 | case TC_SUBTYPE_DIS_CAL: | |
111 | result = action_disable_calibration( &TC, queue_snd_id, time ); |
|
111 | result = action_disable_calibration( &TC, queue_snd_id, time ); | |
112 | close_action( &TC, result, queue_snd_id ); |
|
112 | close_action( &TC, result, queue_snd_id ); | |
113 | break; |
|
113 | break; | |
114 | case TC_SUBTYPE_LOAD_K: |
|
114 | case TC_SUBTYPE_LOAD_K: | |
115 | result = action_load_kcoefficients( &TC, queue_snd_id, time ); |
|
115 | result = action_load_kcoefficients( &TC, queue_snd_id, time ); | |
116 | close_action( &TC, result, queue_snd_id ); |
|
116 | close_action( &TC, result, queue_snd_id ); | |
117 | break; |
|
117 | break; | |
118 | case TC_SUBTYPE_DUMP_K: |
|
118 | case TC_SUBTYPE_DUMP_K: | |
119 | result = action_dump_kcoefficients( &TC, queue_snd_id, time ); |
|
119 | result = action_dump_kcoefficients( &TC, queue_snd_id, time ); | |
120 | close_action( &TC, result, queue_snd_id ); |
|
120 | close_action( &TC, result, queue_snd_id ); | |
121 | break; |
|
121 | break; | |
122 | case TC_SUBTYPE_LOAD_FBINS: |
|
122 | case TC_SUBTYPE_LOAD_FBINS: | |
123 | result = action_load_fbins_mask( &TC, queue_snd_id, time ); |
|
123 | result = action_load_fbins_mask( &TC, queue_snd_id, time ); | |
124 | close_action( &TC, result, queue_snd_id ); |
|
124 | close_action( &TC, result, queue_snd_id ); | |
125 | break; |
|
125 | break; | |
126 | case TC_SUBTYPE_UPDT_TIME: |
|
126 | case TC_SUBTYPE_UPDT_TIME: | |
127 | result = action_update_time( &TC ); |
|
127 | result = action_update_time( &TC ); | |
128 | close_action( &TC, result, queue_snd_id ); |
|
128 | close_action( &TC, result, queue_snd_id ); | |
129 | break; |
|
129 | break; | |
130 | default: |
|
130 | default: | |
131 | break; |
|
131 | break; | |
132 | } |
|
132 | } | |
133 | } |
|
133 | } | |
134 | } |
|
134 | } | |
135 | } |
|
135 | } | |
136 |
|
136 | |||
137 | //*********** |
|
137 | //*********** | |
138 | // TC ACTIONS |
|
138 | // TC ACTIONS | |
139 |
|
139 | |||
140 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
140 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
141 | { |
|
141 | { | |
142 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. |
|
142 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. | |
143 | * |
|
143 | * | |
144 | * @param TC points to the TeleCommand packet that is being processed |
|
144 | * @param TC points to the TeleCommand packet that is being processed | |
145 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
145 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
146 | * |
|
146 | * | |
147 | */ |
|
147 | */ | |
148 |
|
148 | |||
149 | printf("this is the end!!!\n"); |
|
149 | printf("this is the end!!!\n"); | |
150 | exit(0); |
|
150 | exit(0); | |
151 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
151 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); | |
152 | return LFR_DEFAULT; |
|
152 | return LFR_DEFAULT; | |
153 | } |
|
153 | } | |
154 |
|
154 | |||
155 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
155 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
156 | { |
|
156 | { | |
157 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. |
|
157 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. | |
158 | * |
|
158 | * | |
159 | * @param TC points to the TeleCommand packet that is being processed |
|
159 | * @param TC points to the TeleCommand packet that is being processed | |
160 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
160 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
161 | * |
|
161 | * | |
162 | */ |
|
162 | */ | |
163 |
|
163 | |||
164 | rtems_status_code status; |
|
164 | rtems_status_code status; | |
165 | unsigned char requestedMode; |
|
165 | unsigned char requestedMode; | |
166 | unsigned int *transitionCoarseTime_ptr; |
|
166 | unsigned int *transitionCoarseTime_ptr; | |
167 | unsigned int transitionCoarseTime; |
|
167 | unsigned int transitionCoarseTime; | |
168 | unsigned char * bytePosPtr; |
|
168 | unsigned char * bytePosPtr; | |
169 |
|
169 | |||
170 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
170 | bytePosPtr = (unsigned char *) &TC->packetID; | |
171 |
|
171 | |||
172 | requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ]; |
|
172 | requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ]; | |
173 | transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] ); |
|
173 | transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] ); | |
174 | transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff; |
|
174 | transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff; | |
175 |
|
175 | |||
176 | status = check_mode_value( requestedMode ); |
|
176 | status = check_mode_value( requestedMode ); | |
177 |
|
177 | |||
178 | if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent |
|
178 | if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent | |
179 | { |
|
179 | { | |
180 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode ); |
|
180 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode ); | |
181 | } |
|
181 | } | |
182 | else // the mode value is valid, check the transition |
|
182 | else // the mode value is valid, check the transition | |
183 | { |
|
183 | { | |
184 | status = check_mode_transition(requestedMode); |
|
184 | status = check_mode_transition(requestedMode); | |
185 | if (status != LFR_SUCCESSFUL) |
|
185 | if (status != LFR_SUCCESSFUL) | |
186 | { |
|
186 | { | |
187 | PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n") |
|
187 | PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n") | |
188 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
188 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
189 | } |
|
189 | } | |
190 | } |
|
190 | } | |
191 |
|
191 | |||
192 | if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date |
|
192 | if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date | |
193 | { |
|
193 | { | |
194 | status = check_transition_date( transitionCoarseTime ); |
|
194 | status = check_transition_date( transitionCoarseTime ); | |
195 | if (status != LFR_SUCCESSFUL) |
|
195 | if (status != LFR_SUCCESSFUL) | |
196 | { |
|
196 | { | |
197 | PRINTF("ERR *** in action_enter_mode *** check_transition_date\n") |
|
197 | PRINTF("ERR *** in action_enter_mode *** check_transition_date\n") | |
198 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, |
|
198 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, | |
199 | BYTE_POS_CP_LFR_ENTER_MODE_TIME, |
|
199 | BYTE_POS_CP_LFR_ENTER_MODE_TIME, | |
200 | bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] ); |
|
200 | bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] ); | |
201 | } |
|
201 | } | |
202 | } |
|
202 | } | |
203 |
|
203 | |||
204 | if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode |
|
204 | if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode | |
205 | { |
|
205 | { | |
206 | PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); |
|
206 | PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); | |
207 | status = enter_mode( requestedMode, transitionCoarseTime ); |
|
207 | status = enter_mode( requestedMode, transitionCoarseTime ); | |
208 | } |
|
208 | } | |
209 |
|
209 | |||
210 | return status; |
|
210 | return status; | |
211 | } |
|
211 | } | |
212 |
|
212 | |||
213 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
213 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
214 | { |
|
214 | { | |
215 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. |
|
215 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. | |
216 | * |
|
216 | * | |
217 | * @param TC points to the TeleCommand packet that is being processed |
|
217 | * @param TC points to the TeleCommand packet that is being processed | |
218 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
218 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
219 | * |
|
219 | * | |
220 | * @return LFR directive status code: |
|
220 | * @return LFR directive status code: | |
221 | * - LFR_DEFAULT |
|
221 | * - LFR_DEFAULT | |
222 | * - LFR_SUCCESSFUL |
|
222 | * - LFR_SUCCESSFUL | |
223 | * |
|
223 | * | |
224 | */ |
|
224 | */ | |
225 |
|
225 | |||
226 | unsigned int val; |
|
226 | unsigned int val; | |
227 | int result; |
|
227 | int result; | |
228 | unsigned int status; |
|
228 | unsigned int status; | |
229 | unsigned char mode; |
|
229 | unsigned char mode; | |
230 | unsigned char * bytePosPtr; |
|
230 | unsigned char * bytePosPtr; | |
231 |
|
231 | |||
232 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
232 | bytePosPtr = (unsigned char *) &TC->packetID; | |
233 |
|
233 | |||
234 | // check LFR mode |
|
234 | // check LFR mode | |
235 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1; |
|
235 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1; | |
236 | status = check_update_info_hk_lfr_mode( mode ); |
|
236 | status = check_update_info_hk_lfr_mode( mode ); | |
237 | if (status == LFR_SUCCESSFUL) // check TDS mode |
|
237 | if (status == LFR_SUCCESSFUL) // check TDS mode | |
238 | { |
|
238 | { | |
239 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4; |
|
239 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4; | |
240 | status = check_update_info_hk_tds_mode( mode ); |
|
240 | status = check_update_info_hk_tds_mode( mode ); | |
241 | } |
|
241 | } | |
242 | if (status == LFR_SUCCESSFUL) // check THR mode |
|
242 | if (status == LFR_SUCCESSFUL) // check THR mode | |
243 | { |
|
243 | { | |
244 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f); |
|
244 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f); | |
245 | status = check_update_info_hk_thr_mode( mode ); |
|
245 | status = check_update_info_hk_thr_mode( mode ); | |
246 | } |
|
246 | } | |
247 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful |
|
247 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful | |
248 | { |
|
248 | { | |
249 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 |
|
249 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 | |
250 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; |
|
250 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; | |
251 | val++; |
|
251 | val++; | |
252 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); |
|
252 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); | |
253 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); |
|
253 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); | |
254 | } |
|
254 | } | |
255 |
|
255 | |||
256 | result = status; |
|
256 | result = status; | |
257 |
|
257 | |||
258 | return result; |
|
258 | return result; | |
259 | } |
|
259 | } | |
260 |
|
260 | |||
261 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
261 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
262 | { |
|
262 | { | |
263 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. |
|
263 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. | |
264 | * |
|
264 | * | |
265 | * @param TC points to the TeleCommand packet that is being processed |
|
265 | * @param TC points to the TeleCommand packet that is being processed | |
266 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
266 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
267 | * |
|
267 | * | |
268 | */ |
|
268 | */ | |
269 |
|
269 | |||
270 | int result; |
|
270 | int result; | |
271 |
|
271 | |||
272 | result = LFR_DEFAULT; |
|
272 | result = LFR_DEFAULT; | |
273 |
|
273 | |||
274 | setCalibration( true ); |
|
274 | setCalibration( true ); | |
275 |
|
275 | |||
276 | result = LFR_SUCCESSFUL; |
|
276 | result = LFR_SUCCESSFUL; | |
277 |
|
277 | |||
278 | return result; |
|
278 | return result; | |
279 | } |
|
279 | } | |
280 |
|
280 | |||
281 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
281 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
282 | { |
|
282 | { | |
283 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. |
|
283 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. | |
284 | * |
|
284 | * | |
285 | * @param TC points to the TeleCommand packet that is being processed |
|
285 | * @param TC points to the TeleCommand packet that is being processed | |
286 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
286 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
287 | * |
|
287 | * | |
288 | */ |
|
288 | */ | |
289 |
|
289 | |||
290 | int result; |
|
290 | int result; | |
291 |
|
291 | |||
292 | result = LFR_DEFAULT; |
|
292 | result = LFR_DEFAULT; | |
293 |
|
293 | |||
294 | setCalibration( false ); |
|
294 | setCalibration( false ); | |
295 |
|
295 | |||
296 | result = LFR_SUCCESSFUL; |
|
296 | result = LFR_SUCCESSFUL; | |
297 |
|
297 | |||
298 | return result; |
|
298 | return result; | |
299 | } |
|
299 | } | |
300 |
|
300 | |||
301 | int action_update_time(ccsdsTelecommandPacket_t *TC) |
|
301 | int action_update_time(ccsdsTelecommandPacket_t *TC) | |
302 | { |
|
302 | { | |
303 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. |
|
303 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. | |
304 | * |
|
304 | * | |
305 | * @param TC points to the TeleCommand packet that is being processed |
|
305 | * @param TC points to the TeleCommand packet that is being processed | |
306 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
306 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
307 | * |
|
307 | * | |
308 | * @return LFR_SUCCESSFUL |
|
308 | * @return LFR_SUCCESSFUL | |
309 | * |
|
309 | * | |
310 | */ |
|
310 | */ | |
311 |
|
311 | |||
312 | unsigned int val; |
|
312 | unsigned int val; | |
313 |
|
313 | |||
314 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) |
|
314 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) | |
315 | + (TC->dataAndCRC[1] << 16) |
|
315 | + (TC->dataAndCRC[1] << 16) | |
316 | + (TC->dataAndCRC[2] << 8) |
|
316 | + (TC->dataAndCRC[2] << 8) | |
317 | + TC->dataAndCRC[3]; |
|
317 | + TC->dataAndCRC[3]; | |
318 |
|
318 | |||
319 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 |
|
319 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 | |
320 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; |
|
320 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; | |
321 | val++; |
|
321 | val++; | |
322 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); |
|
322 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); | |
323 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); |
|
323 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); | |
324 |
|
324 | |||
325 | return LFR_SUCCESSFUL; |
|
325 | return LFR_SUCCESSFUL; | |
326 | } |
|
326 | } | |
327 |
|
327 | |||
328 | //******************* |
|
328 | //******************* | |
329 | // ENTERING THE MODES |
|
329 | // ENTERING THE MODES | |
330 | int check_mode_value( unsigned char requestedMode ) |
|
330 | int check_mode_value( unsigned char requestedMode ) | |
331 | { |
|
331 | { | |
332 | int status; |
|
332 | int status; | |
333 |
|
333 | |||
334 | if ( (requestedMode != LFR_MODE_STANDBY) |
|
334 | if ( (requestedMode != LFR_MODE_STANDBY) | |
335 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) |
|
335 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) | |
336 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) |
|
336 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) | |
337 | { |
|
337 | { | |
338 | status = LFR_DEFAULT; |
|
338 | status = LFR_DEFAULT; | |
339 | } |
|
339 | } | |
340 | else |
|
340 | else | |
341 | { |
|
341 | { | |
342 | status = LFR_SUCCESSFUL; |
|
342 | status = LFR_SUCCESSFUL; | |
343 | } |
|
343 | } | |
344 |
|
344 | |||
345 | return status; |
|
345 | return status; | |
346 | } |
|
346 | } | |
347 |
|
347 | |||
348 | int check_mode_transition( unsigned char requestedMode ) |
|
348 | int check_mode_transition( unsigned char requestedMode ) | |
349 | { |
|
349 | { | |
350 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. |
|
350 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. | |
351 | * |
|
351 | * | |
352 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE |
|
352 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE | |
353 | * |
|
353 | * | |
354 | * @return LFR directive status codes: |
|
354 | * @return LFR directive status codes: | |
355 | * - LFR_SUCCESSFUL - the transition is authorized |
|
355 | * - LFR_SUCCESSFUL - the transition is authorized | |
356 | * - LFR_DEFAULT - the transition is not authorized |
|
356 | * - LFR_DEFAULT - the transition is not authorized | |
357 | * |
|
357 | * | |
358 | */ |
|
358 | */ | |
359 |
|
359 | |||
360 | int status; |
|
360 | int status; | |
361 |
|
361 | |||
362 | switch (requestedMode) |
|
362 | switch (requestedMode) | |
363 | { |
|
363 | { | |
364 | case LFR_MODE_STANDBY: |
|
364 | case LFR_MODE_STANDBY: | |
365 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { |
|
365 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { | |
366 | status = LFR_DEFAULT; |
|
366 | status = LFR_DEFAULT; | |
367 | } |
|
367 | } | |
368 | else |
|
368 | else | |
369 | { |
|
369 | { | |
370 | status = LFR_SUCCESSFUL; |
|
370 | status = LFR_SUCCESSFUL; | |
371 | } |
|
371 | } | |
372 | break; |
|
372 | break; | |
373 | case LFR_MODE_NORMAL: |
|
373 | case LFR_MODE_NORMAL: | |
374 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { |
|
374 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { | |
375 | status = LFR_DEFAULT; |
|
375 | status = LFR_DEFAULT; | |
376 | } |
|
376 | } | |
377 | else { |
|
377 | else { | |
378 | status = LFR_SUCCESSFUL; |
|
378 | status = LFR_SUCCESSFUL; | |
379 | } |
|
379 | } | |
380 | break; |
|
380 | break; | |
381 | case LFR_MODE_BURST: |
|
381 | case LFR_MODE_BURST: | |
382 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
382 | if ( lfrCurrentMode == LFR_MODE_BURST ) { | |
383 | status = LFR_DEFAULT; |
|
383 | status = LFR_DEFAULT; | |
384 | } |
|
384 | } | |
385 | else { |
|
385 | else { | |
386 | status = LFR_SUCCESSFUL; |
|
386 | status = LFR_SUCCESSFUL; | |
387 | } |
|
387 | } | |
388 | break; |
|
388 | break; | |
389 | case LFR_MODE_SBM1: |
|
389 | case LFR_MODE_SBM1: | |
390 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
390 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { | |
391 | status = LFR_DEFAULT; |
|
391 | status = LFR_DEFAULT; | |
392 | } |
|
392 | } | |
393 | else { |
|
393 | else { | |
394 | status = LFR_SUCCESSFUL; |
|
394 | status = LFR_SUCCESSFUL; | |
395 | } |
|
395 | } | |
396 | break; |
|
396 | break; | |
397 | case LFR_MODE_SBM2: |
|
397 | case LFR_MODE_SBM2: | |
398 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
398 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { | |
399 | status = LFR_DEFAULT; |
|
399 | status = LFR_DEFAULT; | |
400 | } |
|
400 | } | |
401 | else { |
|
401 | else { | |
402 | status = LFR_SUCCESSFUL; |
|
402 | status = LFR_SUCCESSFUL; | |
403 | } |
|
403 | } | |
404 | break; |
|
404 | break; | |
405 | default: |
|
405 | default: | |
406 | status = LFR_DEFAULT; |
|
406 | status = LFR_DEFAULT; | |
407 | break; |
|
407 | break; | |
408 | } |
|
408 | } | |
409 |
|
409 | |||
410 | return status; |
|
410 | return status; | |
411 | } |
|
411 | } | |
412 |
|
412 | |||
413 | int check_transition_date( unsigned int transitionCoarseTime ) |
|
413 | int check_transition_date( unsigned int transitionCoarseTime ) | |
414 | { |
|
414 | { | |
415 | int status; |
|
415 | int status; | |
416 | unsigned int localCoarseTime; |
|
416 | unsigned int localCoarseTime; | |
417 | unsigned int deltaCoarseTime; |
|
417 | unsigned int deltaCoarseTime; | |
418 |
|
418 | |||
419 | status = LFR_SUCCESSFUL; |
|
419 | status = LFR_SUCCESSFUL; | |
420 |
|
420 | |||
421 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition |
|
421 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition | |
422 | { |
|
422 | { | |
423 | status = LFR_SUCCESSFUL; |
|
423 | status = LFR_SUCCESSFUL; | |
424 | } |
|
424 | } | |
425 | else |
|
425 | else | |
426 | { |
|
426 | { | |
427 | localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; |
|
427 | localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; | |
428 |
|
428 | |||
429 | PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime) |
|
429 | PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime) | |
430 |
|
430 | |||
431 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 |
|
431 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 | |
432 | { |
|
432 | { | |
433 | status = LFR_DEFAULT; |
|
433 | status = LFR_DEFAULT; | |
434 | PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n") |
|
434 | PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n") | |
435 | } |
|
435 | } | |
436 |
|
436 | |||
437 | if (status == LFR_SUCCESSFUL) |
|
437 | if (status == LFR_SUCCESSFUL) | |
438 | { |
|
438 | { | |
439 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; |
|
439 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; | |
440 | if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323 |
|
440 | if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323 | |
441 | { |
|
441 | { | |
442 | status = LFR_DEFAULT; |
|
442 | status = LFR_DEFAULT; | |
443 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) |
|
443 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) | |
444 | } |
|
444 | } | |
445 | } |
|
445 | } | |
446 | } |
|
446 | } | |
447 |
|
447 | |||
448 | return status; |
|
448 | return status; | |
449 | } |
|
449 | } | |
450 |
|
450 | |||
451 | int stop_current_mode( void ) |
|
451 | int stop_current_mode( void ) | |
452 | { |
|
452 | { | |
453 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. |
|
453 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. | |
454 | * |
|
454 | * | |
455 | * @return RTEMS directive status codes: |
|
455 | * @return RTEMS directive status codes: | |
456 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
456 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
457 | * - RTEMS_INVALID_ID - task id invalid |
|
457 | * - RTEMS_INVALID_ID - task id invalid | |
458 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
458 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
459 | * |
|
459 | * | |
460 | */ |
|
460 | */ | |
461 |
|
461 | |||
462 | rtems_status_code status; |
|
462 | rtems_status_code status; | |
463 |
|
463 | |||
464 | status = RTEMS_SUCCESSFUL; |
|
464 | status = RTEMS_SUCCESSFUL; | |
465 |
|
465 | |||
466 | // (1) mask interruptions |
|
466 | // (1) mask interruptions | |
467 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt |
|
467 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt | |
468 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
468 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
469 |
|
469 | |||
470 | // (2) reset waveform picker registers |
|
470 | // (2) reset waveform picker registers | |
471 | reset_wfp_burst_enable(); // reset burst and enable bits |
|
471 | reset_wfp_burst_enable(); // reset burst and enable bits | |
472 | reset_wfp_status(); // reset all the status bits |
|
472 | reset_wfp_status(); // reset all the status bits | |
473 |
|
473 | |||
474 | // (3) reset spectral matrices registers |
|
474 | // (3) reset spectral matrices registers | |
475 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices |
|
475 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices | |
476 | reset_sm_status(); |
|
476 | reset_sm_status(); | |
477 |
|
477 | |||
478 | // reset lfr VHDL module |
|
478 | // reset lfr VHDL module | |
479 | reset_lfr(); |
|
479 | reset_lfr(); | |
480 |
|
480 | |||
481 | reset_extractSWF(); // reset the extractSWF flag to false |
|
481 | reset_extractSWF(); // reset the extractSWF flag to false | |
482 |
|
482 | |||
483 | // (4) clear interruptions |
|
483 | // (4) clear interruptions | |
484 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt |
|
484 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt | |
485 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
485 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
486 |
|
486 | |||
487 | // <Spectral Matrices simulator> |
|
487 | // <Spectral Matrices simulator> | |
488 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator |
|
488 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator | |
489 | timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
489 | timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); | |
490 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator |
|
490 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator | |
491 | // </Spectral Matrices simulator> |
|
491 | // </Spectral Matrices simulator> | |
492 |
|
492 | |||
493 | // suspend several tasks |
|
493 | // suspend several tasks | |
494 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
494 | if (lfrCurrentMode != LFR_MODE_STANDBY) { | |
495 | status = suspend_science_tasks(); |
|
495 | status = suspend_science_tasks(); | |
496 | } |
|
496 | } | |
497 |
|
497 | |||
498 | if (status != RTEMS_SUCCESSFUL) |
|
498 | if (status != RTEMS_SUCCESSFUL) | |
499 | { |
|
499 | { | |
500 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
500 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) | |
501 | } |
|
501 | } | |
502 |
|
502 | |||
503 | return status; |
|
503 | return status; | |
504 | } |
|
504 | } | |
505 |
|
505 | |||
506 | int enter_mode( unsigned char mode, unsigned int transitionCoarseTime ) |
|
506 | int enter_mode( unsigned char mode, unsigned int transitionCoarseTime ) | |
507 | { |
|
507 | { | |
508 | /** This function is launched after a mode transition validation. |
|
508 | /** This function is launched after a mode transition validation. | |
509 | * |
|
509 | * | |
510 | * @param mode is the mode in which LFR will be put. |
|
510 | * @param mode is the mode in which LFR will be put. | |
511 | * |
|
511 | * | |
512 | * @return RTEMS directive status codes: |
|
512 | * @return RTEMS directive status codes: | |
513 | * - RTEMS_SUCCESSFUL - the mode has been entered successfully |
|
513 | * - RTEMS_SUCCESSFUL - the mode has been entered successfully | |
514 | * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully |
|
514 | * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully | |
515 | * |
|
515 | * | |
516 | */ |
|
516 | */ | |
517 |
|
517 | |||
518 | rtems_status_code status; |
|
518 | rtems_status_code status; | |
519 |
|
519 | |||
520 | //********************** |
|
520 | //********************** | |
521 | // STOP THE CURRENT MODE |
|
521 | // STOP THE CURRENT MODE | |
522 | status = stop_current_mode(); |
|
522 | status = stop_current_mode(); | |
523 | if (status != RTEMS_SUCCESSFUL) |
|
523 | if (status != RTEMS_SUCCESSFUL) | |
524 | { |
|
524 | { | |
525 | PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode) |
|
525 | PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode) | |
526 | } |
|
526 | } | |
527 |
|
527 | |||
528 | //************************* |
|
528 | //************************* | |
529 | // ENTER THE REQUESTED MODE |
|
529 | // ENTER THE REQUESTED MODE | |
530 | if (status == RTEMS_SUCCESSFUL) // if the current mode has been successfully stopped |
|
530 | if (status == RTEMS_SUCCESSFUL) // if the current mode has been successfully stopped | |
531 | { |
|
531 | { | |
532 | if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST) |
|
532 | if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST) | |
533 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) ) |
|
533 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) ) | |
534 | { |
|
534 | { | |
535 | #ifdef PRINT_TASK_STATISTICS |
|
535 | #ifdef PRINT_TASK_STATISTICS | |
536 | rtems_cpu_usage_reset(); |
|
536 | rtems_cpu_usage_reset(); | |
537 | #endif |
|
537 | #endif | |
538 | status = restart_science_tasks( mode ); |
|
538 | status = restart_science_tasks( mode ); | |
539 | if (status == RTEMS_SUCCESSFUL) |
|
539 | if (status == RTEMS_SUCCESSFUL) | |
540 | { |
|
540 | { | |
541 | launch_spectral_matrix( ); |
|
541 | launch_spectral_matrix( ); | |
542 | launch_waveform_picker( mode, transitionCoarseTime ); |
|
542 | launch_waveform_picker( mode, transitionCoarseTime ); | |
543 | } |
|
543 | } | |
544 | } |
|
544 | } | |
545 | else if ( mode == LFR_MODE_STANDBY ) |
|
545 | else if ( mode == LFR_MODE_STANDBY ) | |
546 | { |
|
546 | { | |
547 | #ifdef PRINT_TASK_STATISTICS |
|
547 | #ifdef PRINT_TASK_STATISTICS | |
548 | rtems_cpu_usage_report(); |
|
548 | rtems_cpu_usage_report(); | |
549 | #endif |
|
549 | #endif | |
550 |
|
550 | |||
551 | #ifdef PRINT_STACK_REPORT |
|
551 | #ifdef PRINT_STACK_REPORT | |
552 | PRINTF("stack report selected\n") |
|
552 | PRINTF("stack report selected\n") | |
553 | rtems_stack_checker_report_usage(); |
|
553 | rtems_stack_checker_report_usage(); | |
554 | #endif |
|
554 | #endif | |
555 | } |
|
555 | } | |
556 | else |
|
556 | else | |
557 | { |
|
557 | { | |
558 | status = RTEMS_UNSATISFIED; |
|
558 | status = RTEMS_UNSATISFIED; | |
559 | } |
|
559 | } | |
560 | } |
|
560 | } | |
561 |
|
561 | |||
562 | if (status != RTEMS_SUCCESSFUL) |
|
562 | if (status != RTEMS_SUCCESSFUL) | |
563 | { |
|
563 | { | |
564 | PRINTF1("ERR *** in enter_mode *** status = %d\n", status) |
|
564 | PRINTF1("ERR *** in enter_mode *** status = %d\n", status) | |
565 | status = RTEMS_UNSATISFIED; |
|
565 | status = RTEMS_UNSATISFIED; | |
566 | } |
|
566 | } | |
567 |
|
567 | |||
568 | return status; |
|
568 | return status; | |
569 | } |
|
569 | } | |
570 |
|
570 | |||
571 | int restart_science_tasks(unsigned char lfrRequestedMode ) |
|
571 | int restart_science_tasks(unsigned char lfrRequestedMode ) | |
572 | { |
|
572 | { | |
573 | /** This function is used to restart all science tasks. |
|
573 | /** This function is used to restart all science tasks. | |
574 | * |
|
574 | * | |
575 | * @return RTEMS directive status codes: |
|
575 | * @return RTEMS directive status codes: | |
576 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
576 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
577 | * - RTEMS_INVALID_ID - task id invalid |
|
577 | * - RTEMS_INVALID_ID - task id invalid | |
578 | * - RTEMS_INCORRECT_STATE - task never started |
|
578 | * - RTEMS_INCORRECT_STATE - task never started | |
579 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
579 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
580 | * |
|
580 | * | |
581 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 |
|
581 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 | |
582 | * |
|
582 | * | |
583 | */ |
|
583 | */ | |
584 |
|
584 | |||
585 | rtems_status_code status[10]; |
|
585 | rtems_status_code status[10]; | |
586 | rtems_status_code ret; |
|
586 | rtems_status_code ret; | |
587 |
|
587 | |||
588 | ret = RTEMS_SUCCESSFUL; |
|
588 | ret = RTEMS_SUCCESSFUL; | |
589 |
|
589 | |||
590 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); |
|
590 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); | |
591 | if (status[0] != RTEMS_SUCCESSFUL) |
|
591 | if (status[0] != RTEMS_SUCCESSFUL) | |
592 | { |
|
592 | { | |
593 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) |
|
593 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) | |
594 | } |
|
594 | } | |
595 |
|
595 | |||
596 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); |
|
596 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); | |
597 | if (status[1] != RTEMS_SUCCESSFUL) |
|
597 | if (status[1] != RTEMS_SUCCESSFUL) | |
598 | { |
|
598 | { | |
599 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) |
|
599 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) | |
600 | } |
|
600 | } | |
601 |
|
601 | |||
602 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); |
|
602 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); | |
603 | if (status[2] != RTEMS_SUCCESSFUL) |
|
603 | if (status[2] != RTEMS_SUCCESSFUL) | |
604 | { |
|
604 | { | |
605 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2]) |
|
605 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2]) | |
606 | } |
|
606 | } | |
607 |
|
607 | |||
608 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); |
|
608 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); | |
609 | if (status[3] != RTEMS_SUCCESSFUL) |
|
609 | if (status[3] != RTEMS_SUCCESSFUL) | |
610 | { |
|
610 | { | |
611 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3]) |
|
611 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3]) | |
612 | } |
|
612 | } | |
613 |
|
613 | |||
614 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); |
|
614 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); | |
615 | if (status[4] != RTEMS_SUCCESSFUL) |
|
615 | if (status[4] != RTEMS_SUCCESSFUL) | |
616 | { |
|
616 | { | |
617 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4]) |
|
617 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4]) | |
618 | } |
|
618 | } | |
619 |
|
619 | |||
620 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); |
|
620 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); | |
621 | if (status[5] != RTEMS_SUCCESSFUL) |
|
621 | if (status[5] != RTEMS_SUCCESSFUL) | |
622 | { |
|
622 | { | |
623 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5]) |
|
623 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5]) | |
624 | } |
|
624 | } | |
625 |
|
625 | |||
626 | status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); |
|
626 | status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); | |
627 | if (status[6] != RTEMS_SUCCESSFUL) |
|
627 | if (status[6] != RTEMS_SUCCESSFUL) | |
628 | { |
|
628 | { | |
629 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6]) |
|
629 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6]) | |
630 | } |
|
630 | } | |
631 |
|
631 | |||
632 | status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); |
|
632 | status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); | |
633 | if (status[7] != RTEMS_SUCCESSFUL) |
|
633 | if (status[7] != RTEMS_SUCCESSFUL) | |
634 | { |
|
634 | { | |
635 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7]) |
|
635 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7]) | |
636 | } |
|
636 | } | |
637 |
|
637 | |||
638 | status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); |
|
638 | status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); | |
639 | if (status[8] != RTEMS_SUCCESSFUL) |
|
639 | if (status[8] != RTEMS_SUCCESSFUL) | |
640 | { |
|
640 | { | |
641 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8]) |
|
641 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8]) | |
642 | } |
|
642 | } | |
643 |
|
643 | |||
644 | status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); |
|
644 | status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); | |
645 | if (status[9] != RTEMS_SUCCESSFUL) |
|
645 | if (status[9] != RTEMS_SUCCESSFUL) | |
646 | { |
|
646 | { | |
647 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9]) |
|
647 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9]) | |
648 | } |
|
648 | } | |
649 |
|
649 | |||
650 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || |
|
650 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || | |
651 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || |
|
651 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || | |
652 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) || |
|
652 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) || | |
653 | (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) || |
|
653 | (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) || | |
654 | (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) ) |
|
654 | (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) ) | |
655 | { |
|
655 | { | |
656 | ret = RTEMS_UNSATISFIED; |
|
656 | ret = RTEMS_UNSATISFIED; | |
657 | } |
|
657 | } | |
658 |
|
658 | |||
659 | return ret; |
|
659 | return ret; | |
660 | } |
|
660 | } | |
661 |
|
661 | |||
662 | int suspend_science_tasks() |
|
662 | int suspend_science_tasks() | |
663 | { |
|
663 | { | |
664 | /** This function suspends the science tasks. |
|
664 | /** This function suspends the science tasks. | |
665 | * |
|
665 | * | |
666 | * @return RTEMS directive status codes: |
|
666 | * @return RTEMS directive status codes: | |
667 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
667 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
668 | * - RTEMS_INVALID_ID - task id invalid |
|
668 | * - RTEMS_INVALID_ID - task id invalid | |
669 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
669 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
670 | * |
|
670 | * | |
671 | */ |
|
671 | */ | |
672 |
|
672 | |||
673 | rtems_status_code status; |
|
673 | rtems_status_code status; | |
674 |
|
674 | |||
675 | printf("in suspend_science_tasks\n"); |
|
675 | printf("in suspend_science_tasks\n"); | |
676 |
|
676 | |||
677 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 |
|
677 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 | |
678 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
678 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
679 | { |
|
679 | { | |
680 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
680 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) | |
681 | } |
|
681 | } | |
682 | else |
|
682 | else | |
683 | { |
|
683 | { | |
684 | status = RTEMS_SUCCESSFUL; |
|
684 | status = RTEMS_SUCCESSFUL; | |
685 | } |
|
685 | } | |
686 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 |
|
686 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 | |
687 | { |
|
687 | { | |
688 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); |
|
688 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); | |
689 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
689 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
690 | { |
|
690 | { | |
691 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) |
|
691 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) | |
692 | } |
|
692 | } | |
693 | else |
|
693 | else | |
694 | { |
|
694 | { | |
695 | status = RTEMS_SUCCESSFUL; |
|
695 | status = RTEMS_SUCCESSFUL; | |
696 | } |
|
696 | } | |
697 | } |
|
697 | } | |
698 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 |
|
698 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 | |
699 | { |
|
699 | { | |
700 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); |
|
700 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); | |
701 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
701 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
702 | { |
|
702 | { | |
703 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) |
|
703 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) | |
704 | } |
|
704 | } | |
705 | else |
|
705 | else | |
706 | { |
|
706 | { | |
707 | status = RTEMS_SUCCESSFUL; |
|
707 | status = RTEMS_SUCCESSFUL; | |
708 | } |
|
708 | } | |
709 | } |
|
709 | } | |
710 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 |
|
710 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 | |
711 | { |
|
711 | { | |
712 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); |
|
712 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); | |
713 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
713 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
714 | { |
|
714 | { | |
715 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) |
|
715 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) | |
716 | } |
|
716 | } | |
717 | else |
|
717 | else | |
718 | { |
|
718 | { | |
719 | status = RTEMS_SUCCESSFUL; |
|
719 | status = RTEMS_SUCCESSFUL; | |
720 | } |
|
720 | } | |
721 | } |
|
721 | } | |
722 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 |
|
722 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 | |
723 | { |
|
723 | { | |
724 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); |
|
724 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); | |
725 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
725 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
726 | { |
|
726 | { | |
727 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) |
|
727 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) | |
728 | } |
|
728 | } | |
729 | else |
|
729 | else | |
730 | { |
|
730 | { | |
731 | status = RTEMS_SUCCESSFUL; |
|
731 | status = RTEMS_SUCCESSFUL; | |
732 | } |
|
732 | } | |
733 | } |
|
733 | } | |
734 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 |
|
734 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 | |
735 | { |
|
735 | { | |
736 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); |
|
736 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); | |
737 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
737 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
738 | { |
|
738 | { | |
739 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) |
|
739 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) | |
740 | } |
|
740 | } | |
741 | else |
|
741 | else | |
742 | { |
|
742 | { | |
743 | status = RTEMS_SUCCESSFUL; |
|
743 | status = RTEMS_SUCCESSFUL; | |
744 | } |
|
744 | } | |
745 | } |
|
745 | } | |
746 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM |
|
746 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM | |
747 | { |
|
747 | { | |
748 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); |
|
748 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); | |
749 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
749 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
750 | { |
|
750 | { | |
751 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) |
|
751 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) | |
752 | } |
|
752 | } | |
753 | else |
|
753 | else | |
754 | { |
|
754 | { | |
755 | status = RTEMS_SUCCESSFUL; |
|
755 | status = RTEMS_SUCCESSFUL; | |
756 | } |
|
756 | } | |
757 | } |
|
757 | } | |
758 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 |
|
758 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 | |
759 | { |
|
759 | { | |
760 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); |
|
760 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); | |
761 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
761 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
762 | { |
|
762 | { | |
763 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) |
|
763 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) | |
764 | } |
|
764 | } | |
765 | else |
|
765 | else | |
766 | { |
|
766 | { | |
767 | status = RTEMS_SUCCESSFUL; |
|
767 | status = RTEMS_SUCCESSFUL; | |
768 | } |
|
768 | } | |
769 | } |
|
769 | } | |
770 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 |
|
770 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 | |
771 | { |
|
771 | { | |
772 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); |
|
772 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); | |
773 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
773 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
774 | { |
|
774 | { | |
775 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) |
|
775 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) | |
776 | } |
|
776 | } | |
777 | else |
|
777 | else | |
778 | { |
|
778 | { | |
779 | status = RTEMS_SUCCESSFUL; |
|
779 | status = RTEMS_SUCCESSFUL; | |
780 | } |
|
780 | } | |
781 | } |
|
781 | } | |
782 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 |
|
782 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 | |
783 | { |
|
783 | { | |
784 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); |
|
784 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); | |
785 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
785 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
786 | { |
|
786 | { | |
787 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) |
|
787 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) | |
788 | } |
|
788 | } | |
789 | else |
|
789 | else | |
790 | { |
|
790 | { | |
791 | status = RTEMS_SUCCESSFUL; |
|
791 | status = RTEMS_SUCCESSFUL; | |
792 | } |
|
792 | } | |
793 | } |
|
793 | } | |
794 |
|
794 | |||
795 | return status; |
|
795 | return status; | |
796 | } |
|
796 | } | |
797 |
|
797 | |||
798 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) |
|
798 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) | |
799 | { |
|
799 | { | |
800 | WFP_reset_current_ring_nodes(); |
|
800 | WFP_reset_current_ring_nodes(); | |
801 |
|
801 | |||
802 | reset_waveform_picker_regs(); |
|
802 | reset_waveform_picker_regs(); | |
803 |
|
803 | |||
804 | set_wfp_burst_enable_register( mode ); |
|
804 | set_wfp_burst_enable_register( mode ); | |
805 |
|
805 | |||
806 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
806 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); | |
807 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
807 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); | |
808 |
|
808 | |||
809 | if (transitionCoarseTime == 0) |
|
809 | if (transitionCoarseTime == 0) | |
810 | { |
|
810 | { | |
811 | waveform_picker_regs->start_date = time_management_regs->coarse_time; |
|
811 | waveform_picker_regs->start_date = time_management_regs->coarse_time; | |
812 | } |
|
812 | } | |
813 | else |
|
813 | else | |
814 | { |
|
814 | { | |
815 | waveform_picker_regs->start_date = transitionCoarseTime; |
|
815 | waveform_picker_regs->start_date = transitionCoarseTime; | |
816 | } |
|
816 | } | |
817 |
|
817 | |||
818 | } |
|
818 | } | |
819 |
|
819 | |||
820 | void launch_spectral_matrix( void ) |
|
820 | void launch_spectral_matrix( void ) | |
821 | { |
|
821 | { | |
822 | SM_reset_current_ring_nodes(); |
|
822 | SM_reset_current_ring_nodes(); | |
823 |
|
823 | |||
824 | reset_spectral_matrix_regs(); |
|
824 | reset_spectral_matrix_regs(); | |
825 |
|
825 | |||
826 | reset_nb_sm(); |
|
826 | reset_nb_sm(); | |
827 |
|
827 | |||
828 | set_sm_irq_onNewMatrix( 1 ); |
|
828 | set_sm_irq_onNewMatrix( 1 ); | |
829 |
|
829 | |||
830 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
830 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); | |
831 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
831 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); | |
832 |
|
832 | |||
833 | } |
|
833 | } | |
834 |
|
834 | |||
835 | void launch_spectral_matrix_simu( void ) |
|
835 | void launch_spectral_matrix_simu( void ) | |
836 | { |
|
836 | { | |
837 | SM_reset_current_ring_nodes(); |
|
837 | SM_reset_current_ring_nodes(); | |
838 | reset_spectral_matrix_regs(); |
|
838 | reset_spectral_matrix_regs(); | |
839 | reset_nb_sm(); |
|
839 | reset_nb_sm(); | |
840 |
|
840 | |||
841 | // Spectral Matrices simulator |
|
841 | // Spectral Matrices simulator | |
842 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
842 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); | |
843 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); |
|
843 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); | |
844 | LEON_Unmask_interrupt( IRQ_SM_SIMULATOR ); |
|
844 | LEON_Unmask_interrupt( IRQ_SM_SIMULATOR ); | |
845 | } |
|
845 | } | |
846 |
|
846 | |||
847 | void set_sm_irq_onNewMatrix( unsigned char value ) |
|
847 | void set_sm_irq_onNewMatrix( unsigned char value ) | |
848 | { |
|
848 | { | |
849 | if (value == 1) |
|
849 | if (value == 1) | |
850 | { |
|
850 | { | |
851 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; |
|
851 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; | |
852 | } |
|
852 | } | |
853 | else |
|
853 | else | |
854 | { |
|
854 | { | |
855 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 |
|
855 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 | |
856 | } |
|
856 | } | |
857 | } |
|
857 | } | |
858 |
|
858 | |||
859 | void set_sm_irq_onError( unsigned char value ) |
|
859 | void set_sm_irq_onError( unsigned char value ) | |
860 | { |
|
860 | { | |
861 | if (value == 1) |
|
861 | if (value == 1) | |
862 | { |
|
862 | { | |
863 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02; |
|
863 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02; | |
864 | } |
|
864 | } | |
865 | else |
|
865 | else | |
866 | { |
|
866 | { | |
867 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101 |
|
867 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101 | |
868 | } |
|
868 | } | |
869 | } |
|
869 | } | |
870 |
|
870 | |||
871 | //***************************** |
|
871 | //***************************** | |
872 | // CONFIGURE CALIBRATION SIGNAL |
|
872 | // CONFIGURE CALIBRATION SIGNAL | |
873 | void setCalibrationPrescaler( unsigned int prescaler ) |
|
873 | void setCalibrationPrescaler( unsigned int prescaler ) | |
874 | { |
|
874 | { | |
875 | // prescaling of the master clock (25 MHz) |
|
875 | // prescaling of the master clock (25 MHz) | |
876 | // master clock is divided by 2^prescaler |
|
876 | // master clock is divided by 2^prescaler | |
877 | time_management_regs->calPrescaler = prescaler; |
|
877 | time_management_regs->calPrescaler = prescaler; | |
878 | } |
|
878 | } | |
879 |
|
879 | |||
880 | void setCalibrationDivisor( unsigned int divisionFactor ) |
|
880 | void setCalibrationDivisor( unsigned int divisionFactor ) | |
881 | { |
|
881 | { | |
882 | // division of the prescaled clock by the division factor |
|
882 | // division of the prescaled clock by the division factor | |
883 | time_management_regs->calDivisor = divisionFactor; |
|
883 | time_management_regs->calDivisor = divisionFactor; | |
884 | } |
|
884 | } | |
885 |
|
885 | |||
886 | void setCalibrationData( void ){ |
|
886 | void setCalibrationData( void ){ | |
887 | unsigned int k; |
|
887 | unsigned int k; | |
888 | unsigned short data; |
|
888 | unsigned short data; | |
889 | float val; |
|
889 | float val; | |
890 | float f0; |
|
890 | float f0; | |
891 | float f1; |
|
891 | float f1; | |
892 | float fs; |
|
892 | float fs; | |
893 | float Ts; |
|
893 | float Ts; | |
894 | float scaleFactor; |
|
894 | float scaleFactor; | |
895 |
|
895 | |||
896 | f0 = 625; |
|
896 | f0 = 625; | |
897 | f1 = 10000; |
|
897 | f1 = 10000; | |
898 | fs = 160256.410; |
|
898 | fs = 160256.410; | |
899 | Ts = 1. / fs; |
|
899 | Ts = 1. / fs; | |
900 |
scaleFactor = 0. |
|
900 | scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV | |
901 |
|
901 | |||
902 | time_management_regs->calDataPtr = 0x00; |
|
902 | time_management_regs->calDataPtr = 0x00; | |
903 |
|
903 | |||
904 | // build the signal for the SCM calibration |
|
904 | // build the signal for the SCM calibration | |
905 | for (k=0; k<256; k++) |
|
905 | for (k=0; k<256; k++) | |
906 | { |
|
906 | { | |
907 | val = sin( 2 * pi * f0 * k * Ts ) |
|
907 | val = sin( 2 * pi * f0 * k * Ts ) | |
908 | + sin( 2 * pi * f1 * k * Ts ); |
|
908 | + sin( 2 * pi * f1 * k * Ts ); | |
909 | data = (unsigned short) ((val * scaleFactor) + 2048); |
|
909 | data = (unsigned short) ((val * scaleFactor) + 2048); | |
910 | time_management_regs->calData = data & 0xfff; |
|
910 | time_management_regs->calData = data & 0xfff; | |
911 | } |
|
911 | } | |
912 | } |
|
912 | } | |
913 |
|
913 | |||
914 | void setCalibrationDataInterleaved( void ){ |
|
914 | void setCalibrationDataInterleaved( void ){ | |
915 | unsigned int k; |
|
915 | unsigned int k; | |
916 | float val; |
|
916 | float val; | |
917 | float f0; |
|
917 | float f0; | |
918 | float f1; |
|
918 | float f1; | |
919 | float fs; |
|
919 | float fs; | |
920 | float Ts; |
|
920 | float Ts; | |
921 | unsigned short data[384]; |
|
921 | unsigned short data[384]; | |
922 | unsigned char *dataPtr; |
|
922 | unsigned char *dataPtr; | |
923 |
|
923 | |||
924 | f0 = 625; |
|
924 | f0 = 625; | |
925 | f1 = 10000; |
|
925 | f1 = 10000; | |
926 | fs = 240384.615; |
|
926 | fs = 240384.615; | |
927 | Ts = 1. / fs; |
|
927 | Ts = 1. / fs; | |
928 |
|
928 | |||
929 | time_management_regs->calDataPtr = 0x00; |
|
929 | time_management_regs->calDataPtr = 0x00; | |
930 |
|
930 | |||
931 | // build the signal for the SCM calibration |
|
931 | // build the signal for the SCM calibration | |
932 | for (k=0; k<384; k++) |
|
932 | for (k=0; k<384; k++) | |
933 | { |
|
933 | { | |
934 | val = sin( 2 * pi * f0 * k * Ts ) |
|
934 | val = sin( 2 * pi * f0 * k * Ts ) | |
935 | + sin( 2 * pi * f1 * k * Ts ); |
|
935 | + sin( 2 * pi * f1 * k * Ts ); | |
936 | data[k] = (unsigned short) (val * 512 + 2048); |
|
936 | data[k] = (unsigned short) (val * 512 + 2048); | |
937 | } |
|
937 | } | |
938 |
|
938 | |||
939 | // write the signal in interleaved mode |
|
939 | // write the signal in interleaved mode | |
940 | for (k=0; k<128; k++) |
|
940 | for (k=0; k<128; k++) | |
941 | { |
|
941 | { | |
942 | dataPtr = (unsigned char*) &data[k*3 + 2]; |
|
942 | dataPtr = (unsigned char*) &data[k*3 + 2]; | |
943 | time_management_regs->calData = (data[k*3] & 0xfff) |
|
943 | time_management_regs->calData = (data[k*3] & 0xfff) | |
944 | + ( (dataPtr[0] & 0x3f) << 12); |
|
944 | + ( (dataPtr[0] & 0x3f) << 12); | |
945 | time_management_regs->calData = (data[k*3 + 1] & 0xfff) |
|
945 | time_management_regs->calData = (data[k*3 + 1] & 0xfff) | |
946 | + ( (dataPtr[1] & 0x3f) << 12); |
|
946 | + ( (dataPtr[1] & 0x3f) << 12); | |
947 | } |
|
947 | } | |
948 | } |
|
948 | } | |
949 |
|
949 | |||
950 | void setCalibrationReload( bool state) |
|
950 | void setCalibrationReload( bool state) | |
951 | { |
|
951 | { | |
952 | if (state == true) |
|
952 | if (state == true) | |
953 | { |
|
953 | { | |
954 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000] |
|
954 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000] | |
955 | } |
|
955 | } | |
956 | else |
|
956 | else | |
957 | { |
|
957 | { | |
958 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111] |
|
958 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111] | |
959 | } |
|
959 | } | |
960 | } |
|
960 | } | |
961 |
|
961 | |||
962 | void setCalibrationEnable( bool state ) |
|
962 | void setCalibrationEnable( bool state ) | |
963 | { |
|
963 | { | |
964 | // this bit drives the multiplexer |
|
964 | // this bit drives the multiplexer | |
965 | if (state == true) |
|
965 | if (state == true) | |
966 | { |
|
966 | { | |
967 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000] |
|
967 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000] | |
968 | } |
|
968 | } | |
969 | else |
|
969 | else | |
970 | { |
|
970 | { | |
971 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111] |
|
971 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111] | |
972 | } |
|
972 | } | |
973 | } |
|
973 | } | |
974 |
|
974 | |||
975 | void setCalibrationInterleaved( bool state ) |
|
975 | void setCalibrationInterleaved( bool state ) | |
976 | { |
|
976 | { | |
977 | // this bit drives the multiplexer |
|
977 | // this bit drives the multiplexer | |
978 | if (state == true) |
|
978 | if (state == true) | |
979 | { |
|
979 | { | |
980 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000] |
|
980 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000] | |
981 | } |
|
981 | } | |
982 | else |
|
982 | else | |
983 | { |
|
983 | { | |
984 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111] |
|
984 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111] | |
985 | } |
|
985 | } | |
986 | } |
|
986 | } | |
987 |
|
987 | |||
988 | void setCalibration( bool state ) |
|
988 | void setCalibration( bool state ) | |
989 | { |
|
989 | { | |
990 | if (state == true) |
|
990 | if (state == true) | |
991 | { |
|
991 | { | |
992 | setCalibrationEnable( true ); |
|
992 | setCalibrationEnable( true ); | |
993 | setCalibrationReload( false ); |
|
993 | setCalibrationReload( false ); | |
994 | set_hk_lfr_calib_enable( true ); |
|
994 | set_hk_lfr_calib_enable( true ); | |
995 | } |
|
995 | } | |
996 | else |
|
996 | else | |
997 | { |
|
997 | { | |
998 | setCalibrationEnable( false ); |
|
998 | setCalibrationEnable( false ); | |
999 | setCalibrationReload( true ); |
|
999 | setCalibrationReload( true ); | |
1000 | set_hk_lfr_calib_enable( false ); |
|
1000 | set_hk_lfr_calib_enable( false ); | |
1001 | } |
|
1001 | } | |
1002 | } |
|
1002 | } | |
1003 |
|
1003 | |||
1004 | void configureCalibration( bool interleaved ) |
|
1004 | void configureCalibration( bool interleaved ) | |
1005 | { |
|
1005 | { | |
1006 | setCalibration( false ); |
|
1006 | setCalibration( false ); | |
1007 | if ( interleaved == true ) |
|
1007 | if ( interleaved == true ) | |
1008 | { |
|
1008 | { | |
1009 | setCalibrationInterleaved( true ); |
|
1009 | setCalibrationInterleaved( true ); | |
1010 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 |
|
1010 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 | |
1011 | setCalibrationDivisor( 26 ); // => 240 384 |
|
1011 | setCalibrationDivisor( 26 ); // => 240 384 | |
1012 | setCalibrationDataInterleaved(); |
|
1012 | setCalibrationDataInterleaved(); | |
1013 | } |
|
1013 | } | |
1014 | else |
|
1014 | else | |
1015 | { |
|
1015 | { | |
1016 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 |
|
1016 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 | |
1017 | setCalibrationDivisor( 38 ); // => 160 256 (39 - 1) |
|
1017 | setCalibrationDivisor( 38 ); // => 160 256 (39 - 1) | |
1018 | setCalibrationData(); |
|
1018 | setCalibrationData(); | |
1019 | } |
|
1019 | } | |
1020 | } |
|
1020 | } | |
1021 |
|
1021 | |||
1022 | //**************** |
|
1022 | //**************** | |
1023 | // CLOSING ACTIONS |
|
1023 | // CLOSING ACTIONS | |
1024 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
1024 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) | |
1025 | { |
|
1025 | { | |
1026 | /** This function is used to update the HK packets statistics after a successful TC execution. |
|
1026 | /** This function is used to update the HK packets statistics after a successful TC execution. | |
1027 | * |
|
1027 | * | |
1028 | * @param TC points to the TC being processed |
|
1028 | * @param TC points to the TC being processed | |
1029 | * @param time is the time used to date the TC execution |
|
1029 | * @param time is the time used to date the TC execution | |
1030 | * |
|
1030 | * | |
1031 | */ |
|
1031 | */ | |
1032 |
|
1032 | |||
1033 | unsigned int val; |
|
1033 | unsigned int val; | |
1034 |
|
1034 | |||
1035 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; |
|
1035 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; | |
1036 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; |
|
1036 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; | |
1037 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; |
|
1037 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; | |
1038 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; |
|
1038 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; | |
1039 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; |
|
1039 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; | |
1040 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; |
|
1040 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; | |
1041 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; |
|
1041 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; | |
1042 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; |
|
1042 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; | |
1043 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; |
|
1043 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; | |
1044 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; |
|
1044 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; | |
1045 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; |
|
1045 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; | |
1046 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; |
|
1046 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; | |
1047 |
|
1047 | |||
1048 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; |
|
1048 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; | |
1049 | val++; |
|
1049 | val++; | |
1050 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); |
|
1050 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); | |
1051 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); |
|
1051 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); | |
1052 | } |
|
1052 | } | |
1053 |
|
1053 | |||
1054 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
1054 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) | |
1055 | { |
|
1055 | { | |
1056 | /** This function is used to update the HK packets statistics after a TC rejection. |
|
1056 | /** This function is used to update the HK packets statistics after a TC rejection. | |
1057 | * |
|
1057 | * | |
1058 | * @param TC points to the TC being processed |
|
1058 | * @param TC points to the TC being processed | |
1059 | * @param time is the time used to date the TC rejection |
|
1059 | * @param time is the time used to date the TC rejection | |
1060 | * |
|
1060 | * | |
1061 | */ |
|
1061 | */ | |
1062 |
|
1062 | |||
1063 | unsigned int val; |
|
1063 | unsigned int val; | |
1064 |
|
1064 | |||
1065 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; |
|
1065 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; | |
1066 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; |
|
1066 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; | |
1067 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; |
|
1067 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; | |
1068 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; |
|
1068 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; | |
1069 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; |
|
1069 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; | |
1070 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; |
|
1070 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; | |
1071 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; |
|
1071 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; | |
1072 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; |
|
1072 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; | |
1073 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; |
|
1073 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; | |
1074 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; |
|
1074 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; | |
1075 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; |
|
1075 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; | |
1076 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; |
|
1076 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; | |
1077 |
|
1077 | |||
1078 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; |
|
1078 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; | |
1079 | val++; |
|
1079 | val++; | |
1080 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); |
|
1080 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); | |
1081 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); |
|
1081 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); | |
1082 | } |
|
1082 | } | |
1083 |
|
1083 | |||
1084 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) |
|
1084 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) | |
1085 | { |
|
1085 | { | |
1086 | /** This function is the last step of the TC execution workflow. |
|
1086 | /** This function is the last step of the TC execution workflow. | |
1087 | * |
|
1087 | * | |
1088 | * @param TC points to the TC being processed |
|
1088 | * @param TC points to the TC being processed | |
1089 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) |
|
1089 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) | |
1090 | * @param queue_id is the id of the RTEMS message queue used to send TM packets |
|
1090 | * @param queue_id is the id of the RTEMS message queue used to send TM packets | |
1091 | * @param time is the time used to date the TC execution |
|
1091 | * @param time is the time used to date the TC execution | |
1092 | * |
|
1092 | * | |
1093 | */ |
|
1093 | */ | |
1094 |
|
1094 | |||
1095 | unsigned char requestedMode; |
|
1095 | unsigned char requestedMode; | |
1096 |
|
1096 | |||
1097 | if (result == LFR_SUCCESSFUL) |
|
1097 | if (result == LFR_SUCCESSFUL) | |
1098 | { |
|
1098 | { | |
1099 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
1099 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) | |
1100 | & |
|
1100 | & | |
1101 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
1101 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) | |
1102 | ) |
|
1102 | ) | |
1103 | { |
|
1103 | { | |
1104 | send_tm_lfr_tc_exe_success( TC, queue_id ); |
|
1104 | send_tm_lfr_tc_exe_success( TC, queue_id ); | |
1105 | } |
|
1105 | } | |
1106 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) |
|
1106 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) | |
1107 | { |
|
1107 | { | |
1108 | //********************************** |
|
1108 | //********************************** | |
1109 | // UPDATE THE LFRMODE LOCAL VARIABLE |
|
1109 | // UPDATE THE LFRMODE LOCAL VARIABLE | |
1110 | requestedMode = TC->dataAndCRC[1]; |
|
1110 | requestedMode = TC->dataAndCRC[1]; | |
1111 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d); |
|
1111 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d); | |
1112 | updateLFRCurrentMode(); |
|
1112 | updateLFRCurrentMode(); | |
1113 | } |
|
1113 | } | |
1114 | } |
|
1114 | } | |
1115 | else if (result == LFR_EXE_ERROR) |
|
1115 | else if (result == LFR_EXE_ERROR) | |
1116 | { |
|
1116 | { | |
1117 | send_tm_lfr_tc_exe_error( TC, queue_id ); |
|
1117 | send_tm_lfr_tc_exe_error( TC, queue_id ); | |
1118 | } |
|
1118 | } | |
1119 | } |
|
1119 | } | |
1120 |
|
1120 | |||
1121 | //*************************** |
|
1121 | //*************************** | |
1122 | // Interrupt Service Routines |
|
1122 | // Interrupt Service Routines | |
1123 | rtems_isr commutation_isr1( rtems_vector_number vector ) |
|
1123 | rtems_isr commutation_isr1( rtems_vector_number vector ) | |
1124 | { |
|
1124 | { | |
1125 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1125 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
1126 | printf("In commutation_isr1 *** Error sending event to DUMB\n"); |
|
1126 | printf("In commutation_isr1 *** Error sending event to DUMB\n"); | |
1127 | } |
|
1127 | } | |
1128 | } |
|
1128 | } | |
1129 |
|
1129 | |||
1130 | rtems_isr commutation_isr2( rtems_vector_number vector ) |
|
1130 | rtems_isr commutation_isr2( rtems_vector_number vector ) | |
1131 | { |
|
1131 | { | |
1132 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1132 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
1133 | printf("In commutation_isr2 *** Error sending event to DUMB\n"); |
|
1133 | printf("In commutation_isr2 *** Error sending event to DUMB\n"); | |
1134 | } |
|
1134 | } | |
1135 | } |
|
1135 | } | |
1136 |
|
1136 | |||
1137 | //**************** |
|
1137 | //**************** | |
1138 | // OTHER FUNCTIONS |
|
1138 | // OTHER FUNCTIONS | |
1139 | void updateLFRCurrentMode() |
|
1139 | void updateLFRCurrentMode() | |
1140 | { |
|
1140 | { | |
1141 | /** This function updates the value of the global variable lfrCurrentMode. |
|
1141 | /** This function updates the value of the global variable lfrCurrentMode. | |
1142 | * |
|
1142 | * | |
1143 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. |
|
1143 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. | |
1144 | * |
|
1144 | * | |
1145 | */ |
|
1145 | */ | |
1146 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure |
|
1146 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure | |
1147 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
1147 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
1148 | } |
|
1148 | } | |
1149 |
|
1149 | |||
1150 | void set_lfr_soft_reset( unsigned char value ) |
|
1150 | void set_lfr_soft_reset( unsigned char value ) | |
1151 | { |
|
1151 | { | |
1152 | if (value == 1) |
|
1152 | if (value == 1) | |
1153 | { |
|
1153 | { | |
1154 | time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100] |
|
1154 | time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100] | |
1155 | } |
|
1155 | } | |
1156 | else |
|
1156 | else | |
1157 | { |
|
1157 | { | |
1158 | time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011] |
|
1158 | time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011] | |
1159 | } |
|
1159 | } | |
1160 | } |
|
1160 | } | |
1161 |
|
1161 | |||
1162 | void reset_lfr( void ) |
|
1162 | void reset_lfr( void ) | |
1163 | { |
|
1163 | { | |
1164 | set_lfr_soft_reset( 1 ); |
|
1164 | set_lfr_soft_reset( 1 ); | |
1165 |
|
1165 | |||
1166 | set_lfr_soft_reset( 0 ); |
|
1166 | set_lfr_soft_reset( 0 ); | |
1167 |
|
1167 | |||
1168 | set_hk_lfr_sc_potential_flag( true ); |
|
1168 | set_hk_lfr_sc_potential_flag( true ); | |
1169 | } |
|
1169 | } |
General Comments 0
You need to be logged in to leave comments.
Login now