@@ -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= |
|
23 | DEFINES += SW_VERSION_N4=20 # 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,72 +1,72 | |||||
1 | #ifndef TC_LOAD_DUMP_PARAMETERS_H |
|
1 | #ifndef TC_LOAD_DUMP_PARAMETERS_H | |
2 | #define TC_LOAD_DUMP_PARAMETERS_H |
|
2 | #define TC_LOAD_DUMP_PARAMETERS_H | |
3 |
|
3 | |||
4 | #include <rtems.h> |
|
4 | #include <rtems.h> | |
5 | #include <stdio.h> |
|
5 | #include <stdio.h> | |
6 |
|
6 | |||
7 | #include "fsw_params.h" |
|
7 | #include "fsw_params.h" | |
8 | #include "wf_handler.h" |
|
8 | #include "wf_handler.h" | |
9 | #include "tm_lfr_tc_exe.h" |
|
9 | #include "tm_lfr_tc_exe.h" | |
10 | #include "fsw_misc.h" |
|
10 | #include "fsw_misc.h" | |
11 | #include "basic_parameters_params.h" |
|
11 | #include "basic_parameters_params.h" | |
12 | #include "avf0_prc0.h" |
|
12 | #include "avf0_prc0.h" | |
13 |
|
13 | |||
14 | #define FLOAT_EQUAL_ZERO 0.001 |
|
14 | #define FLOAT_EQUAL_ZERO 0.001 | |
15 |
|
15 | |||
16 | extern unsigned short sequenceCounterParameterDump; |
|
16 | extern unsigned short sequenceCounterParameterDump; | |
17 | extern unsigned short sequenceCounters_TM_DUMP[]; |
|
17 | extern unsigned short sequenceCounters_TM_DUMP[]; | |
18 | extern float k_coeff_intercalib_f0_norm[ ]; |
|
18 | extern float k_coeff_intercalib_f0_norm[ ]; | |
19 | extern float k_coeff_intercalib_f0_sbm[ ]; |
|
19 | extern float k_coeff_intercalib_f0_sbm[ ]; | |
20 | extern float k_coeff_intercalib_f1_norm[ ]; |
|
20 | extern float k_coeff_intercalib_f1_norm[ ]; | |
21 | extern float k_coeff_intercalib_f1_sbm[ ]; |
|
21 | extern float k_coeff_intercalib_f1_sbm[ ]; | |
22 | extern float k_coeff_intercalib_f2[ ]; |
|
22 | extern float k_coeff_intercalib_f2[ ]; | |
23 |
|
23 | |||
24 | int action_load_common_par( ccsdsTelecommandPacket_t *TC ); |
|
24 | int action_load_common_par( ccsdsTelecommandPacket_t *TC ); | |
25 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
25 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
26 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
26 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
27 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
27 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
28 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
28 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
29 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
29 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
30 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
30 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
31 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
31 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
32 | int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
32 | int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
33 |
|
33 | |||
34 | // NORMAL |
|
34 | // NORMAL | |
35 |
int check_ |
|
35 | int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
36 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ); |
|
36 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ); | |
37 | int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC ); |
|
37 | int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC ); | |
38 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ); |
|
38 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ); | |
39 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
39 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
40 | int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
40 | int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
41 | int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC ); |
|
41 | int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC ); | |
42 |
|
42 | |||
43 | // BURST |
|
43 | // BURST | |
44 | int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
44 | int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
45 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
45 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
46 |
|
46 | |||
47 | // SBM1 |
|
47 | // SBM1 | |
48 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
48 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
49 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
49 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
50 |
|
50 | |||
51 | // SBM2 |
|
51 | // SBM2 | |
52 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
52 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
53 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
53 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
54 |
|
54 | |||
55 | // TC_LFR_UPDATE_INFO |
|
55 | // TC_LFR_UPDATE_INFO | |
56 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ); |
|
56 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ); | |
57 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ); |
|
57 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ); | |
58 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ); |
|
58 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ); | |
59 |
|
59 | |||
60 | // FBINS_MASK |
|
60 | // FBINS_MASK | |
61 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ); |
|
61 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ); | |
62 |
|
62 | |||
63 | // KCOEFFICIENTS |
|
63 | // KCOEFFICIENTS | |
64 | int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id); |
|
64 | int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id); | |
65 | void copyFloatByChar( unsigned char *destination, unsigned char *source ); |
|
65 | void copyFloatByChar( unsigned char *destination, unsigned char *source ); | |
66 |
|
66 | |||
67 | void init_parameter_dump( void ); |
|
67 | void init_parameter_dump( void ); | |
68 | void init_kcoefficients_dump( void ); |
|
68 | void init_kcoefficients_dump( void ); | |
69 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ); |
|
69 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ); | |
70 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ); |
|
70 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ); | |
71 |
|
71 | |||
72 | #endif // TC_LOAD_DUMP_PARAMETERS_H |
|
72 | #endif // TC_LOAD_DUMP_PARAMETERS_H |
@@ -1,1201 +1,1201 | |||||
1 | /** Functions to load and dump parameters in the LFR registers. |
|
1 | /** Functions to load and dump parameters in the LFR registers. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle TC related to parameter loading and dumping.\n |
|
6 | * A group of functions to handle TC related to parameter loading and dumping.\n | |
7 | * TC_LFR_LOAD_COMMON_PAR\n |
|
7 | * TC_LFR_LOAD_COMMON_PAR\n | |
8 | * TC_LFR_LOAD_NORMAL_PAR\n |
|
8 | * TC_LFR_LOAD_NORMAL_PAR\n | |
9 | * TC_LFR_LOAD_BURST_PAR\n |
|
9 | * TC_LFR_LOAD_BURST_PAR\n | |
10 | * TC_LFR_LOAD_SBM1_PAR\n |
|
10 | * TC_LFR_LOAD_SBM1_PAR\n | |
11 | * TC_LFR_LOAD_SBM2_PAR\n |
|
11 | * TC_LFR_LOAD_SBM2_PAR\n | |
12 | * |
|
12 | * | |
13 | */ |
|
13 | */ | |
14 |
|
14 | |||
15 | #include "tc_load_dump_parameters.h" |
|
15 | #include "tc_load_dump_parameters.h" | |
16 |
|
16 | |||
17 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_1; |
|
17 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_1; | |
18 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_2; |
|
18 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_2; | |
19 | ring_node kcoefficient_node_1; |
|
19 | ring_node kcoefficient_node_1; | |
20 | ring_node kcoefficient_node_2; |
|
20 | ring_node kcoefficient_node_2; | |
21 |
|
21 | |||
22 | int action_load_common_par(ccsdsTelecommandPacket_t *TC) |
|
22 | int action_load_common_par(ccsdsTelecommandPacket_t *TC) | |
23 | { |
|
23 | { | |
24 | /** This function updates the LFR registers with the incoming common parameters. |
|
24 | /** This function updates the LFR registers with the incoming common parameters. | |
25 | * |
|
25 | * | |
26 | * @param TC points to the TeleCommand packet that is being processed |
|
26 | * @param TC points to the TeleCommand packet that is being processed | |
27 | * |
|
27 | * | |
28 | * |
|
28 | * | |
29 | */ |
|
29 | */ | |
30 |
|
30 | |||
31 | parameter_dump_packet.sy_lfr_common_parameters_spare = TC->dataAndCRC[0]; |
|
31 | parameter_dump_packet.sy_lfr_common_parameters_spare = TC->dataAndCRC[0]; | |
32 | parameter_dump_packet.sy_lfr_common_parameters = TC->dataAndCRC[1]; |
|
32 | parameter_dump_packet.sy_lfr_common_parameters = TC->dataAndCRC[1]; | |
33 | set_wfp_data_shaping( ); |
|
33 | set_wfp_data_shaping( ); | |
34 | return LFR_SUCCESSFUL; |
|
34 | return LFR_SUCCESSFUL; | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
37 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
38 | { |
|
38 | { | |
39 | /** This function updates the LFR registers with the incoming normal parameters. |
|
39 | /** This function updates the LFR registers with the incoming normal parameters. | |
40 | * |
|
40 | * | |
41 | * @param TC points to the TeleCommand packet that is being processed |
|
41 | * @param TC points to the TeleCommand packet that is being processed | |
42 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
42 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
43 | * |
|
43 | * | |
44 | */ |
|
44 | */ | |
45 |
|
45 | |||
46 | int result; |
|
46 | int result; | |
47 | int flag; |
|
47 | int flag; | |
48 | rtems_status_code status; |
|
48 | rtems_status_code status; | |
49 |
|
49 | |||
50 | flag = LFR_SUCCESSFUL; |
|
50 | flag = LFR_SUCCESSFUL; | |
51 |
|
51 | |||
52 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || |
|
52 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || | |
53 | (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) { |
|
53 | (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) { | |
54 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
54 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
55 | flag = LFR_DEFAULT; |
|
55 | flag = LFR_DEFAULT; | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | // CHECK THE PARAMETERS SET CONSISTENCY |
|
58 | // CHECK THE PARAMETERS SET CONSISTENCY | |
59 | if (flag == LFR_SUCCESSFUL) |
|
59 | if (flag == LFR_SUCCESSFUL) | |
60 | { |
|
60 | { | |
61 |
flag = check_ |
|
61 | flag = check_normal_par_consistency( TC, queue_id ); | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | // SET THE PARAMETERS IF THEY ARE CONSISTENT |
|
64 | // SET THE PARAMETERS IF THEY ARE CONSISTENT | |
65 | if (flag == LFR_SUCCESSFUL) |
|
65 | if (flag == LFR_SUCCESSFUL) | |
66 | { |
|
66 | { | |
67 | result = set_sy_lfr_n_swf_l( TC ); |
|
67 | result = set_sy_lfr_n_swf_l( TC ); | |
68 | result = set_sy_lfr_n_swf_p( TC ); |
|
68 | result = set_sy_lfr_n_swf_p( TC ); | |
69 | result = set_sy_lfr_n_bp_p0( TC ); |
|
69 | result = set_sy_lfr_n_bp_p0( TC ); | |
70 | result = set_sy_lfr_n_bp_p1( TC ); |
|
70 | result = set_sy_lfr_n_bp_p1( TC ); | |
71 | result = set_sy_lfr_n_asm_p( TC ); |
|
71 | result = set_sy_lfr_n_asm_p( TC ); | |
72 | result = set_sy_lfr_n_cwf_long_f3( TC ); |
|
72 | result = set_sy_lfr_n_cwf_long_f3( TC ); | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | return flag; |
|
75 | return flag; | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
78 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
79 | { |
|
79 | { | |
80 | /** This function updates the LFR registers with the incoming burst parameters. |
|
80 | /** This function updates the LFR registers with the incoming burst parameters. | |
81 | * |
|
81 | * | |
82 | * @param TC points to the TeleCommand packet that is being processed |
|
82 | * @param TC points to the TeleCommand packet that is being processed | |
83 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
83 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
84 | * |
|
84 | * | |
85 | */ |
|
85 | */ | |
86 |
|
86 | |||
87 | int flag; |
|
87 | int flag; | |
88 | rtems_status_code status; |
|
88 | rtems_status_code status; | |
89 | unsigned char sy_lfr_b_bp_p0; |
|
89 | unsigned char sy_lfr_b_bp_p0; | |
90 | unsigned char sy_lfr_b_bp_p1; |
|
90 | unsigned char sy_lfr_b_bp_p1; | |
91 | float aux; |
|
91 | float aux; | |
92 |
|
92 | |||
93 | flag = LFR_SUCCESSFUL; |
|
93 | flag = LFR_SUCCESSFUL; | |
94 |
|
94 | |||
95 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
95 | if ( lfrCurrentMode == LFR_MODE_BURST ) { | |
96 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
96 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
97 | flag = LFR_DEFAULT; |
|
97 | flag = LFR_DEFAULT; | |
98 | } |
|
98 | } | |
99 |
|
99 | |||
100 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
100 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; | |
101 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
101 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; | |
102 |
|
102 | |||
103 | // sy_lfr_b_bp_p0 shall not be lower than its default value |
|
103 | // sy_lfr_b_bp_p0 shall not be lower than its default value | |
104 | if (flag == LFR_SUCCESSFUL) |
|
104 | if (flag == LFR_SUCCESSFUL) | |
105 | { |
|
105 | { | |
106 | if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 ) |
|
106 | if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 ) | |
107 | { |
|
107 | { | |
108 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 ); |
|
108 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 ); | |
109 | flag = WRONG_APP_DATA; |
|
109 | flag = WRONG_APP_DATA; | |
110 | } |
|
110 | } | |
111 | } |
|
111 | } | |
112 | // sy_lfr_b_bp_p1 shall not be lower than its default value |
|
112 | // sy_lfr_b_bp_p1 shall not be lower than its default value | |
113 | if (flag == LFR_SUCCESSFUL) |
|
113 | if (flag == LFR_SUCCESSFUL) | |
114 | { |
|
114 | { | |
115 | if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 ) |
|
115 | if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 ) | |
116 | { |
|
116 | { | |
117 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, sy_lfr_b_bp_p1 ); |
|
117 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, sy_lfr_b_bp_p1 ); | |
118 | flag = WRONG_APP_DATA; |
|
118 | flag = WRONG_APP_DATA; | |
119 | } |
|
119 | } | |
120 | } |
|
120 | } | |
121 | //**************************************************************** |
|
121 | //**************************************************************** | |
122 | // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1 |
|
122 | // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1 | |
123 | if (flag == LFR_SUCCESSFUL) |
|
123 | if (flag == LFR_SUCCESSFUL) | |
124 | { |
|
124 | { | |
125 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
125 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; | |
126 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
126 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; | |
127 | aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0); |
|
127 | aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0); | |
128 | if (aux > FLOAT_EQUAL_ZERO) |
|
128 | if (aux > FLOAT_EQUAL_ZERO) | |
129 | { |
|
129 | { | |
130 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 ); |
|
130 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 ); | |
131 | flag = LFR_DEFAULT; |
|
131 | flag = LFR_DEFAULT; | |
132 | } |
|
132 | } | |
133 | } |
|
133 | } | |
134 |
|
134 | |||
135 | // SET THE PARAMETERS |
|
135 | // SET THE PARAMETERS | |
136 | if (flag == LFR_SUCCESSFUL) |
|
136 | if (flag == LFR_SUCCESSFUL) | |
137 | { |
|
137 | { | |
138 | flag = set_sy_lfr_b_bp_p0( TC ); |
|
138 | flag = set_sy_lfr_b_bp_p0( TC ); | |
139 | flag = set_sy_lfr_b_bp_p1( TC ); |
|
139 | flag = set_sy_lfr_b_bp_p1( TC ); | |
140 | } |
|
140 | } | |
141 |
|
141 | |||
142 | return flag; |
|
142 | return flag; | |
143 | } |
|
143 | } | |
144 |
|
144 | |||
145 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
145 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
146 | { |
|
146 | { | |
147 | /** This function updates the LFR registers with the incoming sbm1 parameters. |
|
147 | /** This function updates the LFR registers with the incoming sbm1 parameters. | |
148 | * |
|
148 | * | |
149 | * @param TC points to the TeleCommand packet that is being processed |
|
149 | * @param TC points to the TeleCommand packet that is being processed | |
150 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
150 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
151 | * |
|
151 | * | |
152 | */ |
|
152 | */ | |
153 |
|
153 | |||
154 | int flag; |
|
154 | int flag; | |
155 | rtems_status_code status; |
|
155 | rtems_status_code status; | |
156 | unsigned char sy_lfr_s1_bp_p0; |
|
156 | unsigned char sy_lfr_s1_bp_p0; | |
157 | unsigned char sy_lfr_s1_bp_p1; |
|
157 | unsigned char sy_lfr_s1_bp_p1; | |
158 | float aux; |
|
158 | float aux; | |
159 |
|
159 | |||
160 | flag = LFR_SUCCESSFUL; |
|
160 | flag = LFR_SUCCESSFUL; | |
161 |
|
161 | |||
162 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
162 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { | |
163 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
163 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
164 | flag = LFR_DEFAULT; |
|
164 | flag = LFR_DEFAULT; | |
165 | } |
|
165 | } | |
166 |
|
166 | |||
167 | sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
167 | sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; | |
168 | sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
168 | sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; | |
169 |
|
169 | |||
170 | // sy_lfr_s1_bp_p0 |
|
170 | // sy_lfr_s1_bp_p0 | |
171 | if (flag == LFR_SUCCESSFUL) |
|
171 | if (flag == LFR_SUCCESSFUL) | |
172 | { |
|
172 | { | |
173 | if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 ) |
|
173 | if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 ) | |
174 | { |
|
174 | { | |
175 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 ); |
|
175 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 ); | |
176 | flag = WRONG_APP_DATA; |
|
176 | flag = WRONG_APP_DATA; | |
177 | } |
|
177 | } | |
178 | } |
|
178 | } | |
179 | // sy_lfr_s1_bp_p1 |
|
179 | // sy_lfr_s1_bp_p1 | |
180 | if (flag == LFR_SUCCESSFUL) |
|
180 | if (flag == LFR_SUCCESSFUL) | |
181 | { |
|
181 | { | |
182 | if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 ) |
|
182 | if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 ) | |
183 | { |
|
183 | { | |
184 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, sy_lfr_s1_bp_p1 ); |
|
184 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, sy_lfr_s1_bp_p1 ); | |
185 | flag = WRONG_APP_DATA; |
|
185 | flag = WRONG_APP_DATA; | |
186 | } |
|
186 | } | |
187 | } |
|
187 | } | |
188 | //****************************************************************** |
|
188 | //****************************************************************** | |
189 | // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1 |
|
189 | // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1 | |
190 | if (flag == LFR_SUCCESSFUL) |
|
190 | if (flag == LFR_SUCCESSFUL) | |
191 | { |
|
191 | { | |
192 | aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25)); |
|
192 | aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25)); | |
193 | if (aux > FLOAT_EQUAL_ZERO) |
|
193 | if (aux > FLOAT_EQUAL_ZERO) | |
194 | { |
|
194 | { | |
195 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 ); |
|
195 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 ); | |
196 | flag = LFR_DEFAULT; |
|
196 | flag = LFR_DEFAULT; | |
197 | } |
|
197 | } | |
198 | } |
|
198 | } | |
199 |
|
199 | |||
200 | // SET THE PARAMETERS |
|
200 | // SET THE PARAMETERS | |
201 | if (flag == LFR_SUCCESSFUL) |
|
201 | if (flag == LFR_SUCCESSFUL) | |
202 | { |
|
202 | { | |
203 | flag = set_sy_lfr_s1_bp_p0( TC ); |
|
203 | flag = set_sy_lfr_s1_bp_p0( TC ); | |
204 | flag = set_sy_lfr_s1_bp_p1( TC ); |
|
204 | flag = set_sy_lfr_s1_bp_p1( TC ); | |
205 | } |
|
205 | } | |
206 |
|
206 | |||
207 | return flag; |
|
207 | return flag; | |
208 | } |
|
208 | } | |
209 |
|
209 | |||
210 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
210 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
211 | { |
|
211 | { | |
212 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
212 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
213 | * |
|
213 | * | |
214 | * @param TC points to the TeleCommand packet that is being processed |
|
214 | * @param TC points to the TeleCommand packet that is being processed | |
215 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
215 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
216 | * |
|
216 | * | |
217 | */ |
|
217 | */ | |
218 |
|
218 | |||
219 | int flag; |
|
219 | int flag; | |
220 | rtems_status_code status; |
|
220 | rtems_status_code status; | |
221 | unsigned char sy_lfr_s2_bp_p0; |
|
221 | unsigned char sy_lfr_s2_bp_p0; | |
222 | unsigned char sy_lfr_s2_bp_p1; |
|
222 | unsigned char sy_lfr_s2_bp_p1; | |
223 | float aux; |
|
223 | float aux; | |
224 |
|
224 | |||
225 | flag = LFR_SUCCESSFUL; |
|
225 | flag = LFR_SUCCESSFUL; | |
226 |
|
226 | |||
227 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
227 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { | |
228 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
228 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
229 | flag = LFR_DEFAULT; |
|
229 | flag = LFR_DEFAULT; | |
230 | } |
|
230 | } | |
231 |
|
231 | |||
232 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
232 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; | |
233 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
233 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; | |
234 |
|
234 | |||
235 | // sy_lfr_s2_bp_p0 |
|
235 | // sy_lfr_s2_bp_p0 | |
236 | if (flag == LFR_SUCCESSFUL) |
|
236 | if (flag == LFR_SUCCESSFUL) | |
237 | { |
|
237 | { | |
238 | if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 ) |
|
238 | if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 ) | |
239 | { |
|
239 | { | |
240 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 ); |
|
240 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 ); | |
241 | flag = WRONG_APP_DATA; |
|
241 | flag = WRONG_APP_DATA; | |
242 | } |
|
242 | } | |
243 | } |
|
243 | } | |
244 | // sy_lfr_s2_bp_p1 |
|
244 | // sy_lfr_s2_bp_p1 | |
245 | if (flag == LFR_SUCCESSFUL) |
|
245 | if (flag == LFR_SUCCESSFUL) | |
246 | { |
|
246 | { | |
247 | if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 ) |
|
247 | if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 ) | |
248 | { |
|
248 | { | |
249 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, sy_lfr_s2_bp_p1 ); |
|
249 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, sy_lfr_s2_bp_p1 ); | |
250 | flag = WRONG_APP_DATA; |
|
250 | flag = WRONG_APP_DATA; | |
251 | } |
|
251 | } | |
252 | } |
|
252 | } | |
253 | //****************************************************************** |
|
253 | //****************************************************************** | |
254 | // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1 |
|
254 | // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1 | |
255 | if (flag == LFR_SUCCESSFUL) |
|
255 | if (flag == LFR_SUCCESSFUL) | |
256 | { |
|
256 | { | |
257 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
257 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; | |
258 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
258 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; | |
259 | aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0); |
|
259 | aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0); | |
260 | if (aux > FLOAT_EQUAL_ZERO) |
|
260 | if (aux > FLOAT_EQUAL_ZERO) | |
261 | { |
|
261 | { | |
262 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 ); |
|
262 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 ); | |
263 | flag = LFR_DEFAULT; |
|
263 | flag = LFR_DEFAULT; | |
264 | } |
|
264 | } | |
265 | } |
|
265 | } | |
266 |
|
266 | |||
267 | // SET THE PARAMETERS |
|
267 | // SET THE PARAMETERS | |
268 | if (flag == LFR_SUCCESSFUL) |
|
268 | if (flag == LFR_SUCCESSFUL) | |
269 | { |
|
269 | { | |
270 | flag = set_sy_lfr_s2_bp_p0( TC ); |
|
270 | flag = set_sy_lfr_s2_bp_p0( TC ); | |
271 | flag = set_sy_lfr_s2_bp_p1( TC ); |
|
271 | flag = set_sy_lfr_s2_bp_p1( TC ); | |
272 | } |
|
272 | } | |
273 |
|
273 | |||
274 | return flag; |
|
274 | return flag; | |
275 | } |
|
275 | } | |
276 |
|
276 | |||
277 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
277 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
278 | { |
|
278 | { | |
279 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
279 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
280 | * |
|
280 | * | |
281 | * @param TC points to the TeleCommand packet that is being processed |
|
281 | * @param TC points to the TeleCommand packet that is being processed | |
282 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
282 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
283 | * |
|
283 | * | |
284 | */ |
|
284 | */ | |
285 |
|
285 | |||
286 | int flag; |
|
286 | int flag; | |
287 |
|
287 | |||
288 | flag = LFR_DEFAULT; |
|
288 | flag = LFR_DEFAULT; | |
289 |
|
289 | |||
290 | flag = set_sy_lfr_kcoeff( TC, queue_id ); |
|
290 | flag = set_sy_lfr_kcoeff( TC, queue_id ); | |
291 |
|
291 | |||
292 | return flag; |
|
292 | return flag; | |
293 | } |
|
293 | } | |
294 |
|
294 | |||
295 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
295 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
296 | { |
|
296 | { | |
297 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
297 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
298 | * |
|
298 | * | |
299 | * @param TC points to the TeleCommand packet that is being processed |
|
299 | * @param TC points to the TeleCommand packet that is being processed | |
300 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
300 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
301 | * |
|
301 | * | |
302 | */ |
|
302 | */ | |
303 |
|
303 | |||
304 | int flag; |
|
304 | int flag; | |
305 |
|
305 | |||
306 | flag = LFR_DEFAULT; |
|
306 | flag = LFR_DEFAULT; | |
307 |
|
307 | |||
308 | flag = set_sy_lfr_fbins( TC ); |
|
308 | flag = set_sy_lfr_fbins( TC ); | |
309 |
|
309 | |||
310 | return flag; |
|
310 | return flag; | |
311 | } |
|
311 | } | |
312 |
|
312 | |||
313 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
313 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
314 | { |
|
314 | { | |
315 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
315 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
316 | * |
|
316 | * | |
317 | * @param TC points to the TeleCommand packet that is being processed |
|
317 | * @param TC points to the TeleCommand packet that is being processed | |
318 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
318 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
319 | * |
|
319 | * | |
320 | */ |
|
320 | */ | |
321 |
|
321 | |||
322 | unsigned int address; |
|
322 | unsigned int address; | |
323 | rtems_status_code status; |
|
323 | rtems_status_code status; | |
324 | unsigned int freq; |
|
324 | unsigned int freq; | |
325 | unsigned int bin; |
|
325 | unsigned int bin; | |
326 | unsigned int coeff; |
|
326 | unsigned int coeff; | |
327 | unsigned char *kCoeffPtr; |
|
327 | unsigned char *kCoeffPtr; | |
328 | unsigned char *kCoeffDumpPtr; |
|
328 | unsigned char *kCoeffDumpPtr; | |
329 |
|
329 | |||
330 | // for each sy_lfr_kcoeff_frequency there is 32 kcoeff |
|
330 | // for each sy_lfr_kcoeff_frequency there is 32 kcoeff | |
331 | // F0 => 11 bins |
|
331 | // F0 => 11 bins | |
332 | // F1 => 13 bins |
|
332 | // F1 => 13 bins | |
333 | // F2 => 12 bins |
|
333 | // F2 => 12 bins | |
334 | // 36 bins to dump in two packets (30 bins max per packet) |
|
334 | // 36 bins to dump in two packets (30 bins max per packet) | |
335 |
|
335 | |||
336 | //********* |
|
336 | //********* | |
337 | // PACKET 1 |
|
337 | // PACKET 1 | |
338 | // 11 F0 bins, 13 F1 bins and 6 F2 bins |
|
338 | // 11 F0 bins, 13 F1 bins and 6 F2 bins | |
339 | kcoefficients_dump_1.destinationID = TC->sourceID; |
|
339 | kcoefficients_dump_1.destinationID = TC->sourceID; | |
340 | increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID ); |
|
340 | increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID ); | |
341 | for( freq=0; |
|
341 | for( freq=0; | |
342 | freq<NB_BINS_COMPRESSED_SM_F0; |
|
342 | freq<NB_BINS_COMPRESSED_SM_F0; | |
343 | freq++ ) |
|
343 | freq++ ) | |
344 | { |
|
344 | { | |
345 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq; |
|
345 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq; | |
346 | bin = freq; |
|
346 | bin = freq; | |
347 | // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm); |
|
347 | // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm); | |
348 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
348 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
349 | { |
|
349 | { | |
350 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
350 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency | |
351 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
351 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
352 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
352 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
353 | } |
|
353 | } | |
354 | } |
|
354 | } | |
355 | for( freq=NB_BINS_COMPRESSED_SM_F0; |
|
355 | for( freq=NB_BINS_COMPRESSED_SM_F0; | |
356 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
356 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); | |
357 | freq++ ) |
|
357 | freq++ ) | |
358 | { |
|
358 | { | |
359 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; |
|
359 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; | |
360 | bin = freq - NB_BINS_COMPRESSED_SM_F0; |
|
360 | bin = freq - NB_BINS_COMPRESSED_SM_F0; | |
361 | // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm); |
|
361 | // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm); | |
362 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
362 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
363 | { |
|
363 | { | |
364 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
364 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency | |
365 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
365 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
366 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
366 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
367 | } |
|
367 | } | |
368 | } |
|
368 | } | |
369 | for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
369 | for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); | |
370 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6); |
|
370 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6); | |
371 | freq++ ) |
|
371 | freq++ ) | |
372 | { |
|
372 | { | |
373 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; |
|
373 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; | |
374 | bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
374 | bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); | |
375 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); |
|
375 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); | |
376 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
376 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
377 | { |
|
377 | { | |
378 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
378 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency | |
379 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
379 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
380 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
380 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
381 | } |
|
381 | } | |
382 | } |
|
382 | } | |
383 | kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
383 | kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
384 | kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
384 | kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
385 | kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
385 | kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
386 | kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
386 | kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
387 | kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
387 | kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
388 | kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
388 | kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time); | |
389 | // SEND DATA |
|
389 | // SEND DATA | |
390 | kcoefficient_node_1.status = 1; |
|
390 | kcoefficient_node_1.status = 1; | |
391 | address = (unsigned int) &kcoefficient_node_1; |
|
391 | address = (unsigned int) &kcoefficient_node_1; | |
392 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); |
|
392 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); | |
393 | if (status != RTEMS_SUCCESSFUL) { |
|
393 | if (status != RTEMS_SUCCESSFUL) { | |
394 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status) |
|
394 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status) | |
395 | } |
|
395 | } | |
396 |
|
396 | |||
397 | //******** |
|
397 | //******** | |
398 | // PACKET 2 |
|
398 | // PACKET 2 | |
399 | // 6 F2 bins |
|
399 | // 6 F2 bins | |
400 | kcoefficients_dump_2.destinationID = TC->sourceID; |
|
400 | kcoefficients_dump_2.destinationID = TC->sourceID; | |
401 | increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID ); |
|
401 | increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID ); | |
402 | for( freq=0; freq<6; freq++ ) |
|
402 | for( freq=0; freq<6; freq++ ) | |
403 | { |
|
403 | { | |
404 | kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq; |
|
404 | kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq; | |
405 | bin = freq + 6; |
|
405 | bin = freq + 6; | |
406 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); |
|
406 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); | |
407 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
407 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
408 | { |
|
408 | { | |
409 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
409 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency | |
410 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
410 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
411 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
411 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
412 | } |
|
412 | } | |
413 | } |
|
413 | } | |
414 | kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
414 | kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
415 | kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
415 | kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
416 | kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
416 | kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
417 | kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
417 | kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
418 | kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
418 | kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
419 | kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
419 | kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time); | |
420 | // SEND DATA |
|
420 | // SEND DATA | |
421 | kcoefficient_node_2.status = 1; |
|
421 | kcoefficient_node_2.status = 1; | |
422 | address = (unsigned int) &kcoefficient_node_2; |
|
422 | address = (unsigned int) &kcoefficient_node_2; | |
423 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); |
|
423 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); | |
424 | if (status != RTEMS_SUCCESSFUL) { |
|
424 | if (status != RTEMS_SUCCESSFUL) { | |
425 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status) |
|
425 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status) | |
426 | } |
|
426 | } | |
427 |
|
427 | |||
428 | return status; |
|
428 | return status; | |
429 | } |
|
429 | } | |
430 |
|
430 | |||
431 | int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
431 | int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
432 | { |
|
432 | { | |
433 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. |
|
433 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. | |
434 | * |
|
434 | * | |
435 | * @param queue_id is the id of the queue which handles TM related to this execution step. |
|
435 | * @param queue_id is the id of the queue which handles TM related to this execution step. | |
436 | * |
|
436 | * | |
437 | * @return RTEMS directive status codes: |
|
437 | * @return RTEMS directive status codes: | |
438 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
438 | * - RTEMS_SUCCESSFUL - message sent successfully | |
439 | * - RTEMS_INVALID_ID - invalid queue id |
|
439 | * - RTEMS_INVALID_ID - invalid queue id | |
440 | * - RTEMS_INVALID_SIZE - invalid message size |
|
440 | * - RTEMS_INVALID_SIZE - invalid message size | |
441 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
441 | * - RTEMS_INVALID_ADDRESS - buffer is NULL | |
442 | * - RTEMS_UNSATISFIED - out of message buffers |
|
442 | * - RTEMS_UNSATISFIED - out of message buffers | |
443 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
443 | * - RTEMS_TOO_MANY - queue s limit has been reached | |
444 | * |
|
444 | * | |
445 | */ |
|
445 | */ | |
446 |
|
446 | |||
447 | int status; |
|
447 | int status; | |
448 |
|
448 | |||
449 | increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID ); |
|
449 | increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID ); | |
450 | parameter_dump_packet.destinationID = TC->sourceID; |
|
450 | parameter_dump_packet.destinationID = TC->sourceID; | |
451 |
|
451 | |||
452 | // UPDATE TIME |
|
452 | // UPDATE TIME | |
453 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
453 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
454 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
454 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
455 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
455 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
456 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
456 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
457 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
457 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
458 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
458 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); | |
459 | // SEND DATA |
|
459 | // SEND DATA | |
460 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, |
|
460 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, | |
461 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
461 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
462 | if (status != RTEMS_SUCCESSFUL) { |
|
462 | if (status != RTEMS_SUCCESSFUL) { | |
463 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) |
|
463 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) | |
464 | } |
|
464 | } | |
465 |
|
465 | |||
466 | return status; |
|
466 | return status; | |
467 | } |
|
467 | } | |
468 |
|
468 | |||
469 | //*********************** |
|
469 | //*********************** | |
470 | // NORMAL MODE PARAMETERS |
|
470 | // NORMAL MODE PARAMETERS | |
471 |
|
471 | |||
472 |
int check_ |
|
472 | int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
473 | { |
|
473 | { | |
474 | unsigned char msb; |
|
474 | unsigned char msb; | |
475 | unsigned char lsb; |
|
475 | unsigned char lsb; | |
476 | int flag; |
|
476 | int flag; | |
477 | float aux; |
|
477 | float aux; | |
478 | rtems_status_code status; |
|
478 | rtems_status_code status; | |
479 |
|
479 | |||
480 | unsigned int sy_lfr_n_swf_l; |
|
480 | unsigned int sy_lfr_n_swf_l; | |
481 | unsigned int sy_lfr_n_swf_p; |
|
481 | unsigned int sy_lfr_n_swf_p; | |
482 | unsigned int sy_lfr_n_asm_p; |
|
482 | unsigned int sy_lfr_n_asm_p; | |
483 | unsigned char sy_lfr_n_bp_p0; |
|
483 | unsigned char sy_lfr_n_bp_p0; | |
484 | unsigned char sy_lfr_n_bp_p1; |
|
484 | unsigned char sy_lfr_n_bp_p1; | |
485 | unsigned char sy_lfr_n_cwf_long_f3; |
|
485 | unsigned char sy_lfr_n_cwf_long_f3; | |
486 |
|
486 | |||
487 | flag = LFR_SUCCESSFUL; |
|
487 | flag = LFR_SUCCESSFUL; | |
488 |
|
488 | |||
489 | //*************** |
|
489 | //*************** | |
490 | // get parameters |
|
490 | // get parameters | |
491 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
491 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; | |
492 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
492 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; | |
493 | sy_lfr_n_swf_l = msb * 256 + lsb; |
|
493 | sy_lfr_n_swf_l = msb * 256 + lsb; | |
494 |
|
494 | |||
495 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
495 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; | |
496 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
496 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; | |
497 | sy_lfr_n_swf_p = msb * 256 + lsb; |
|
497 | sy_lfr_n_swf_p = msb * 256 + lsb; | |
498 |
|
498 | |||
499 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
499 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; | |
500 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
500 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; | |
501 | sy_lfr_n_asm_p = msb * 256 + lsb; |
|
501 | sy_lfr_n_asm_p = msb * 256 + lsb; | |
502 |
|
502 | |||
503 | sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
503 | sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; | |
504 |
|
504 | |||
505 | sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
505 | sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; | |
506 |
|
506 | |||
507 | sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
507 | sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; | |
508 |
|
508 | |||
509 | //****************** |
|
509 | //****************** | |
510 | // check consistency |
|
510 | // check consistency | |
511 | // sy_lfr_n_swf_l |
|
511 | // sy_lfr_n_swf_l | |
512 | if (sy_lfr_n_swf_l != 2048) |
|
512 | if (sy_lfr_n_swf_l != 2048) | |
513 | { |
|
513 | { | |
514 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l ); |
|
514 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l ); | |
515 | flag = WRONG_APP_DATA; |
|
515 | flag = WRONG_APP_DATA; | |
516 | } |
|
516 | } | |
517 | // sy_lfr_n_swf_p |
|
517 | // sy_lfr_n_swf_p | |
518 | if (flag == LFR_SUCCESSFUL) |
|
518 | if (flag == LFR_SUCCESSFUL) | |
519 | { |
|
519 | { | |
520 |
if ( sy_lfr_n_swf_p < |
|
520 | if ( sy_lfr_n_swf_p < 22 ) | |
521 | { |
|
521 | { | |
522 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p ); |
|
522 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p ); | |
523 | flag = WRONG_APP_DATA; |
|
523 | flag = WRONG_APP_DATA; | |
524 | } |
|
524 | } | |
525 | } |
|
525 | } | |
526 | // sy_lfr_n_bp_p0 |
|
526 | // sy_lfr_n_bp_p0 | |
527 | if (flag == LFR_SUCCESSFUL) |
|
527 | if (flag == LFR_SUCCESSFUL) | |
528 | { |
|
528 | { | |
529 | if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0) |
|
529 | if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0) | |
530 | { |
|
530 | { | |
531 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 ); |
|
531 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 ); | |
532 | flag = WRONG_APP_DATA; |
|
532 | flag = WRONG_APP_DATA; | |
533 | } |
|
533 | } | |
534 | } |
|
534 | } | |
535 | // sy_lfr_n_asm_p |
|
535 | // sy_lfr_n_asm_p | |
536 | if (flag == LFR_SUCCESSFUL) |
|
536 | if (flag == LFR_SUCCESSFUL) | |
537 | { |
|
537 | { | |
538 | if (sy_lfr_n_asm_p == 0) |
|
538 | if (sy_lfr_n_asm_p == 0) | |
539 | { |
|
539 | { | |
540 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); |
|
540 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); | |
541 | flag = WRONG_APP_DATA; |
|
541 | flag = WRONG_APP_DATA; | |
542 | } |
|
542 | } | |
543 | } |
|
543 | } | |
544 | // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0 |
|
544 | // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0 | |
545 | if (flag == LFR_SUCCESSFUL) |
|
545 | if (flag == LFR_SUCCESSFUL) | |
546 | { |
|
546 | { | |
547 | aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0); |
|
547 | aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0); | |
548 | if (aux > FLOAT_EQUAL_ZERO) |
|
548 | if (aux > FLOAT_EQUAL_ZERO) | |
549 | { |
|
549 | { | |
550 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); |
|
550 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); | |
551 | flag = WRONG_APP_DATA; |
|
551 | flag = WRONG_APP_DATA; | |
552 | } |
|
552 | } | |
553 | } |
|
553 | } | |
554 | // sy_lfr_n_bp_p1 |
|
554 | // sy_lfr_n_bp_p1 | |
555 | if (flag == LFR_SUCCESSFUL) |
|
555 | if (flag == LFR_SUCCESSFUL) | |
556 | { |
|
556 | { | |
557 | if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1) |
|
557 | if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1) | |
558 | { |
|
558 | { | |
559 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); |
|
559 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); | |
560 | flag = WRONG_APP_DATA; |
|
560 | flag = WRONG_APP_DATA; | |
561 | } |
|
561 | } | |
562 | } |
|
562 | } | |
563 | // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0 |
|
563 | // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0 | |
564 | if (flag == LFR_SUCCESSFUL) |
|
564 | if (flag == LFR_SUCCESSFUL) | |
565 | { |
|
565 | { | |
566 | aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0); |
|
566 | aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0); | |
567 | if (aux > FLOAT_EQUAL_ZERO) |
|
567 | if (aux > FLOAT_EQUAL_ZERO) | |
568 | { |
|
568 | { | |
569 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); |
|
569 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); | |
570 | flag = LFR_DEFAULT; |
|
570 | flag = LFR_DEFAULT; | |
571 | } |
|
571 | } | |
572 | } |
|
572 | } | |
573 | // sy_lfr_n_cwf_long_f3 |
|
573 | // sy_lfr_n_cwf_long_f3 | |
574 |
|
574 | |||
575 | return flag; |
|
575 | return flag; | |
576 | } |
|
576 | } | |
577 |
|
577 | |||
578 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ) |
|
578 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ) | |
579 | { |
|
579 | { | |
580 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). |
|
580 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). | |
581 | * |
|
581 | * | |
582 | * @param TC points to the TeleCommand packet that is being processed |
|
582 | * @param TC points to the TeleCommand packet that is being processed | |
583 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
583 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
584 | * |
|
584 | * | |
585 | */ |
|
585 | */ | |
586 |
|
586 | |||
587 | int result; |
|
587 | int result; | |
588 |
|
588 | |||
589 | result = LFR_SUCCESSFUL; |
|
589 | result = LFR_SUCCESSFUL; | |
590 |
|
590 | |||
591 | parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
591 | parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; | |
592 | parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
592 | parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; | |
593 |
|
593 | |||
594 | return result; |
|
594 | return result; | |
595 | } |
|
595 | } | |
596 |
|
596 | |||
597 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC ) |
|
597 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC ) | |
598 | { |
|
598 | { | |
599 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). |
|
599 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). | |
600 | * |
|
600 | * | |
601 | * @param TC points to the TeleCommand packet that is being processed |
|
601 | * @param TC points to the TeleCommand packet that is being processed | |
602 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
602 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
603 | * |
|
603 | * | |
604 | */ |
|
604 | */ | |
605 |
|
605 | |||
606 | int result; |
|
606 | int result; | |
607 |
|
607 | |||
608 | result = LFR_SUCCESSFUL; |
|
608 | result = LFR_SUCCESSFUL; | |
609 |
|
609 | |||
610 | parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
610 | parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; | |
611 | parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
611 | parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; | |
612 |
|
612 | |||
613 | return result; |
|
613 | return result; | |
614 | } |
|
614 | } | |
615 |
|
615 | |||
616 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ) |
|
616 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ) | |
617 | { |
|
617 | { | |
618 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). |
|
618 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). | |
619 | * |
|
619 | * | |
620 | * @param TC points to the TeleCommand packet that is being processed |
|
620 | * @param TC points to the TeleCommand packet that is being processed | |
621 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
621 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
622 | * |
|
622 | * | |
623 | */ |
|
623 | */ | |
624 |
|
624 | |||
625 | int result; |
|
625 | int result; | |
626 |
|
626 | |||
627 | result = LFR_SUCCESSFUL; |
|
627 | result = LFR_SUCCESSFUL; | |
628 |
|
628 | |||
629 | parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
629 | parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; | |
630 | parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
630 | parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; | |
631 |
|
631 | |||
632 | return result; |
|
632 | return result; | |
633 | } |
|
633 | } | |
634 |
|
634 | |||
635 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
635 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ) | |
636 | { |
|
636 | { | |
637 | /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0). |
|
637 | /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0). | |
638 | * |
|
638 | * | |
639 | * @param TC points to the TeleCommand packet that is being processed |
|
639 | * @param TC points to the TeleCommand packet that is being processed | |
640 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
640 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
641 | * |
|
641 | * | |
642 | */ |
|
642 | */ | |
643 |
|
643 | |||
644 | int status; |
|
644 | int status; | |
645 |
|
645 | |||
646 | status = LFR_SUCCESSFUL; |
|
646 | status = LFR_SUCCESSFUL; | |
647 |
|
647 | |||
648 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
648 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; | |
649 |
|
649 | |||
650 | return status; |
|
650 | return status; | |
651 | } |
|
651 | } | |
652 |
|
652 | |||
653 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC ) |
|
653 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC ) | |
654 | { |
|
654 | { | |
655 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). |
|
655 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). | |
656 | * |
|
656 | * | |
657 | * @param TC points to the TeleCommand packet that is being processed |
|
657 | * @param TC points to the TeleCommand packet that is being processed | |
658 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
658 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
659 | * |
|
659 | * | |
660 | */ |
|
660 | */ | |
661 |
|
661 | |||
662 | int status; |
|
662 | int status; | |
663 |
|
663 | |||
664 | status = LFR_SUCCESSFUL; |
|
664 | status = LFR_SUCCESSFUL; | |
665 |
|
665 | |||
666 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
666 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; | |
667 |
|
667 | |||
668 | return status; |
|
668 | return status; | |
669 | } |
|
669 | } | |
670 |
|
670 | |||
671 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC ) |
|
671 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC ) | |
672 | { |
|
672 | { | |
673 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. |
|
673 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. | |
674 | * |
|
674 | * | |
675 | * @param TC points to the TeleCommand packet that is being processed |
|
675 | * @param TC points to the TeleCommand packet that is being processed | |
676 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
676 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
677 | * |
|
677 | * | |
678 | */ |
|
678 | */ | |
679 |
|
679 | |||
680 | int status; |
|
680 | int status; | |
681 |
|
681 | |||
682 | status = LFR_SUCCESSFUL; |
|
682 | status = LFR_SUCCESSFUL; | |
683 |
|
683 | |||
684 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
684 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; | |
685 |
|
685 | |||
686 | return status; |
|
686 | return status; | |
687 | } |
|
687 | } | |
688 |
|
688 | |||
689 | //********************** |
|
689 | //********************** | |
690 | // BURST MODE PARAMETERS |
|
690 | // BURST MODE PARAMETERS | |
691 | int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC) |
|
691 | int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC) | |
692 | { |
|
692 | { | |
693 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0). |
|
693 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0). | |
694 | * |
|
694 | * | |
695 | * @param TC points to the TeleCommand packet that is being processed |
|
695 | * @param TC points to the TeleCommand packet that is being processed | |
696 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
696 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
697 | * |
|
697 | * | |
698 | */ |
|
698 | */ | |
699 |
|
699 | |||
700 | int status; |
|
700 | int status; | |
701 |
|
701 | |||
702 | status = LFR_SUCCESSFUL; |
|
702 | status = LFR_SUCCESSFUL; | |
703 |
|
703 | |||
704 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
704 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; | |
705 |
|
705 | |||
706 | return status; |
|
706 | return status; | |
707 | } |
|
707 | } | |
708 |
|
708 | |||
709 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
709 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
710 | { |
|
710 | { | |
711 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1). |
|
711 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1). | |
712 | * |
|
712 | * | |
713 | * @param TC points to the TeleCommand packet that is being processed |
|
713 | * @param TC points to the TeleCommand packet that is being processed | |
714 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
714 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
715 | * |
|
715 | * | |
716 | */ |
|
716 | */ | |
717 |
|
717 | |||
718 | int status; |
|
718 | int status; | |
719 |
|
719 | |||
720 | status = LFR_SUCCESSFUL; |
|
720 | status = LFR_SUCCESSFUL; | |
721 |
|
721 | |||
722 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
722 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; | |
723 |
|
723 | |||
724 | return status; |
|
724 | return status; | |
725 | } |
|
725 | } | |
726 |
|
726 | |||
727 | //********************* |
|
727 | //********************* | |
728 | // SBM1 MODE PARAMETERS |
|
728 | // SBM1 MODE PARAMETERS | |
729 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
729 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ) | |
730 | { |
|
730 | { | |
731 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0). |
|
731 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0). | |
732 | * |
|
732 | * | |
733 | * @param TC points to the TeleCommand packet that is being processed |
|
733 | * @param TC points to the TeleCommand packet that is being processed | |
734 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
734 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
735 | * |
|
735 | * | |
736 | */ |
|
736 | */ | |
737 |
|
737 | |||
738 | int status; |
|
738 | int status; | |
739 |
|
739 | |||
740 | status = LFR_SUCCESSFUL; |
|
740 | status = LFR_SUCCESSFUL; | |
741 |
|
741 | |||
742 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
742 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; | |
743 |
|
743 | |||
744 | return status; |
|
744 | return status; | |
745 | } |
|
745 | } | |
746 |
|
746 | |||
747 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
747 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
748 | { |
|
748 | { | |
749 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1). |
|
749 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1). | |
750 | * |
|
750 | * | |
751 | * @param TC points to the TeleCommand packet that is being processed |
|
751 | * @param TC points to the TeleCommand packet that is being processed | |
752 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
752 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
753 | * |
|
753 | * | |
754 | */ |
|
754 | */ | |
755 |
|
755 | |||
756 | int status; |
|
756 | int status; | |
757 |
|
757 | |||
758 | status = LFR_SUCCESSFUL; |
|
758 | status = LFR_SUCCESSFUL; | |
759 |
|
759 | |||
760 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
760 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; | |
761 |
|
761 | |||
762 | return status; |
|
762 | return status; | |
763 | } |
|
763 | } | |
764 |
|
764 | |||
765 | //********************* |
|
765 | //********************* | |
766 | // SBM2 MODE PARAMETERS |
|
766 | // SBM2 MODE PARAMETERS | |
767 | int set_sy_lfr_s2_bp_p0(ccsdsTelecommandPacket_t *TC) |
|
767 | int set_sy_lfr_s2_bp_p0(ccsdsTelecommandPacket_t *TC) | |
768 | { |
|
768 | { | |
769 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0). |
|
769 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0). | |
770 | * |
|
770 | * | |
771 | * @param TC points to the TeleCommand packet that is being processed |
|
771 | * @param TC points to the TeleCommand packet that is being processed | |
772 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
772 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
773 | * |
|
773 | * | |
774 | */ |
|
774 | */ | |
775 |
|
775 | |||
776 | int status; |
|
776 | int status; | |
777 |
|
777 | |||
778 | status = LFR_SUCCESSFUL; |
|
778 | status = LFR_SUCCESSFUL; | |
779 |
|
779 | |||
780 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
780 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; | |
781 |
|
781 | |||
782 | return status; |
|
782 | return status; | |
783 | } |
|
783 | } | |
784 |
|
784 | |||
785 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
785 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
786 | { |
|
786 | { | |
787 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1). |
|
787 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1). | |
788 | * |
|
788 | * | |
789 | * @param TC points to the TeleCommand packet that is being processed |
|
789 | * @param TC points to the TeleCommand packet that is being processed | |
790 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
790 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
791 | * |
|
791 | * | |
792 | */ |
|
792 | */ | |
793 |
|
793 | |||
794 | int status; |
|
794 | int status; | |
795 |
|
795 | |||
796 | status = LFR_SUCCESSFUL; |
|
796 | status = LFR_SUCCESSFUL; | |
797 |
|
797 | |||
798 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
798 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; | |
799 |
|
799 | |||
800 | return status; |
|
800 | return status; | |
801 | } |
|
801 | } | |
802 |
|
802 | |||
803 | //******************* |
|
803 | //******************* | |
804 | // TC_LFR_UPDATE_INFO |
|
804 | // TC_LFR_UPDATE_INFO | |
805 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) |
|
805 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) | |
806 | { |
|
806 | { | |
807 | unsigned int status; |
|
807 | unsigned int status; | |
808 |
|
808 | |||
809 | if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) |
|
809 | if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) | |
810 | || (mode == LFR_MODE_BURST) |
|
810 | || (mode == LFR_MODE_BURST) | |
811 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) |
|
811 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) | |
812 | { |
|
812 | { | |
813 | status = LFR_SUCCESSFUL; |
|
813 | status = LFR_SUCCESSFUL; | |
814 | } |
|
814 | } | |
815 | else |
|
815 | else | |
816 | { |
|
816 | { | |
817 | status = LFR_DEFAULT; |
|
817 | status = LFR_DEFAULT; | |
818 | } |
|
818 | } | |
819 |
|
819 | |||
820 | return status; |
|
820 | return status; | |
821 | } |
|
821 | } | |
822 |
|
822 | |||
823 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ) |
|
823 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ) | |
824 | { |
|
824 | { | |
825 | unsigned int status; |
|
825 | unsigned int status; | |
826 |
|
826 | |||
827 | if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) |
|
827 | if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) | |
828 | || (mode == TDS_MODE_BURST) |
|
828 | || (mode == TDS_MODE_BURST) | |
829 | || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) |
|
829 | || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) | |
830 | || (mode == TDS_MODE_LFM)) |
|
830 | || (mode == TDS_MODE_LFM)) | |
831 | { |
|
831 | { | |
832 | status = LFR_SUCCESSFUL; |
|
832 | status = LFR_SUCCESSFUL; | |
833 | } |
|
833 | } | |
834 | else |
|
834 | else | |
835 | { |
|
835 | { | |
836 | status = LFR_DEFAULT; |
|
836 | status = LFR_DEFAULT; | |
837 | } |
|
837 | } | |
838 |
|
838 | |||
839 | return status; |
|
839 | return status; | |
840 | } |
|
840 | } | |
841 |
|
841 | |||
842 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ) |
|
842 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ) | |
843 | { |
|
843 | { | |
844 | unsigned int status; |
|
844 | unsigned int status; | |
845 |
|
845 | |||
846 | if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) |
|
846 | if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) | |
847 | || (mode == THR_MODE_BURST)) |
|
847 | || (mode == THR_MODE_BURST)) | |
848 | { |
|
848 | { | |
849 | status = LFR_SUCCESSFUL; |
|
849 | status = LFR_SUCCESSFUL; | |
850 | } |
|
850 | } | |
851 | else |
|
851 | else | |
852 | { |
|
852 | { | |
853 | status = LFR_DEFAULT; |
|
853 | status = LFR_DEFAULT; | |
854 | } |
|
854 | } | |
855 |
|
855 | |||
856 | return status; |
|
856 | return status; | |
857 | } |
|
857 | } | |
858 |
|
858 | |||
859 | //*********** |
|
859 | //*********** | |
860 | // FBINS MASK |
|
860 | // FBINS MASK | |
861 |
|
861 | |||
862 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ) |
|
862 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ) | |
863 | { |
|
863 | { | |
864 | int status; |
|
864 | int status; | |
865 | unsigned int k; |
|
865 | unsigned int k; | |
866 | unsigned char *fbins_mask_dump; |
|
866 | unsigned char *fbins_mask_dump; | |
867 | unsigned char *fbins_mask_TC; |
|
867 | unsigned char *fbins_mask_TC; | |
868 |
|
868 | |||
869 | status = LFR_SUCCESSFUL; |
|
869 | status = LFR_SUCCESSFUL; | |
870 |
|
870 | |||
871 | fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1; |
|
871 | fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1; | |
872 | fbins_mask_TC = TC->dataAndCRC; |
|
872 | fbins_mask_TC = TC->dataAndCRC; | |
873 |
|
873 | |||
874 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) |
|
874 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) | |
875 | { |
|
875 | { | |
876 | fbins_mask_dump[k] = fbins_mask_TC[k]; |
|
876 | fbins_mask_dump[k] = fbins_mask_TC[k]; | |
877 | } |
|
877 | } | |
878 | for (k=0; k < NB_FBINS_MASKS; k++) |
|
878 | for (k=0; k < NB_FBINS_MASKS; k++) | |
879 | { |
|
879 | { | |
880 | unsigned char *auxPtr; |
|
880 | unsigned char *auxPtr; | |
881 | auxPtr = ¶meter_dump_packet.sy_lfr_fbins_f0_word1[k*NB_BYTES_PER_FBINS_MASK]; |
|
881 | auxPtr = ¶meter_dump_packet.sy_lfr_fbins_f0_word1[k*NB_BYTES_PER_FBINS_MASK]; | |
882 | } |
|
882 | } | |
883 |
|
883 | |||
884 |
|
884 | |||
885 | return status; |
|
885 | return status; | |
886 | } |
|
886 | } | |
887 |
|
887 | |||
888 | //************** |
|
888 | //************** | |
889 | // KCOEFFICIENTS |
|
889 | // KCOEFFICIENTS | |
890 | int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id ) |
|
890 | int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id ) | |
891 | { |
|
891 | { | |
892 | unsigned int kcoeff; |
|
892 | unsigned int kcoeff; | |
893 | unsigned short sy_lfr_kcoeff_frequency; |
|
893 | unsigned short sy_lfr_kcoeff_frequency; | |
894 | unsigned short bin; |
|
894 | unsigned short bin; | |
895 | unsigned short *freqPtr; |
|
895 | unsigned short *freqPtr; | |
896 | float *kcoeffPtr_norm; |
|
896 | float *kcoeffPtr_norm; | |
897 | float *kcoeffPtr_sbm; |
|
897 | float *kcoeffPtr_sbm; | |
898 | int status; |
|
898 | int status; | |
899 | unsigned char *kcoeffLoadPtr; |
|
899 | unsigned char *kcoeffLoadPtr; | |
900 | unsigned char *kcoeffNormPtr; |
|
900 | unsigned char *kcoeffNormPtr; | |
901 | unsigned char *kcoeffSbmPtr_a; |
|
901 | unsigned char *kcoeffSbmPtr_a; | |
902 | unsigned char *kcoeffSbmPtr_b; |
|
902 | unsigned char *kcoeffSbmPtr_b; | |
903 |
|
903 | |||
904 | status = LFR_SUCCESSFUL; |
|
904 | status = LFR_SUCCESSFUL; | |
905 |
|
905 | |||
906 | kcoeffPtr_norm = NULL; |
|
906 | kcoeffPtr_norm = NULL; | |
907 | kcoeffPtr_sbm = NULL; |
|
907 | kcoeffPtr_sbm = NULL; | |
908 | bin = 0; |
|
908 | bin = 0; | |
909 |
|
909 | |||
910 | freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY]; |
|
910 | freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY]; | |
911 | sy_lfr_kcoeff_frequency = *freqPtr; |
|
911 | sy_lfr_kcoeff_frequency = *freqPtr; | |
912 |
|
912 | |||
913 | if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM ) |
|
913 | if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM ) | |
914 | { |
|
914 | { | |
915 | PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency) |
|
915 | PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency) | |
916 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1, |
|
916 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1, | |
917 | TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB |
|
917 | TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB | |
918 | status = LFR_DEFAULT; |
|
918 | status = LFR_DEFAULT; | |
919 | } |
|
919 | } | |
920 | else |
|
920 | else | |
921 | { |
|
921 | { | |
922 | if ( ( sy_lfr_kcoeff_frequency >= 0 ) |
|
922 | if ( ( sy_lfr_kcoeff_frequency >= 0 ) | |
923 | && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) ) |
|
923 | && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) ) | |
924 | { |
|
924 | { | |
925 | kcoeffPtr_norm = k_coeff_intercalib_f0_norm; |
|
925 | kcoeffPtr_norm = k_coeff_intercalib_f0_norm; | |
926 | kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm; |
|
926 | kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm; | |
927 | bin = sy_lfr_kcoeff_frequency; |
|
927 | bin = sy_lfr_kcoeff_frequency; | |
928 | } |
|
928 | } | |
929 | else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 ) |
|
929 | else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 ) | |
930 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) ) |
|
930 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) ) | |
931 | { |
|
931 | { | |
932 | kcoeffPtr_norm = k_coeff_intercalib_f1_norm; |
|
932 | kcoeffPtr_norm = k_coeff_intercalib_f1_norm; | |
933 | kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm; |
|
933 | kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm; | |
934 | bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0; |
|
934 | bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0; | |
935 | } |
|
935 | } | |
936 | else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) |
|
936 | else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) | |
937 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) ) |
|
937 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) ) | |
938 | { |
|
938 | { | |
939 | kcoeffPtr_norm = k_coeff_intercalib_f2; |
|
939 | kcoeffPtr_norm = k_coeff_intercalib_f2; | |
940 | kcoeffPtr_sbm = NULL; |
|
940 | kcoeffPtr_sbm = NULL; | |
941 | bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); |
|
941 | bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); | |
942 | } |
|
942 | } | |
943 | } |
|
943 | } | |
944 |
|
944 | |||
945 | if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products |
|
945 | if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products | |
946 | { |
|
946 | { | |
947 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
947 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) | |
948 | { |
|
948 | { | |
949 | // destination |
|
949 | // destination | |
950 | kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ]; |
|
950 | kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ]; | |
951 | // source |
|
951 | // source | |
952 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; |
|
952 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; | |
953 | // copy source to destination |
|
953 | // copy source to destination | |
954 | copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr ); |
|
954 | copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr ); | |
955 | } |
|
955 | } | |
956 | } |
|
956 | } | |
957 |
|
957 | |||
958 | if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products |
|
958 | if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products | |
959 | { |
|
959 | { | |
960 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
960 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) | |
961 | { |
|
961 | { | |
962 | // destination |
|
962 | // destination | |
963 | kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ]; |
|
963 | kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ]; | |
964 | kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ]; |
|
964 | kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ]; | |
965 | // source |
|
965 | // source | |
966 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; |
|
966 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; | |
967 | // copy source to destination |
|
967 | // copy source to destination | |
968 | copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr ); |
|
968 | copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr ); | |
969 | copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr ); |
|
969 | copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr ); | |
970 | } |
|
970 | } | |
971 | } |
|
971 | } | |
972 |
|
972 | |||
973 | // print_k_coeff(); |
|
973 | // print_k_coeff(); | |
974 |
|
974 | |||
975 | return status; |
|
975 | return status; | |
976 | } |
|
976 | } | |
977 |
|
977 | |||
978 | void copyFloatByChar( unsigned char *destination, unsigned char *source ) |
|
978 | void copyFloatByChar( unsigned char *destination, unsigned char *source ) | |
979 | { |
|
979 | { | |
980 | destination[0] = source[0]; |
|
980 | destination[0] = source[0]; | |
981 | destination[1] = source[1]; |
|
981 | destination[1] = source[1]; | |
982 | destination[2] = source[2]; |
|
982 | destination[2] = source[2]; | |
983 | destination[3] = source[3]; |
|
983 | destination[3] = source[3]; | |
984 | } |
|
984 | } | |
985 |
|
985 | |||
986 | //********** |
|
986 | //********** | |
987 | // init dump |
|
987 | // init dump | |
988 |
|
988 | |||
989 | void init_parameter_dump( void ) |
|
989 | void init_parameter_dump( void ) | |
990 | { |
|
990 | { | |
991 | /** This function initialize the parameter_dump_packet global variable with default values. |
|
991 | /** This function initialize the parameter_dump_packet global variable with default values. | |
992 | * |
|
992 | * | |
993 | */ |
|
993 | */ | |
994 |
|
994 | |||
995 | unsigned int k; |
|
995 | unsigned int k; | |
996 |
|
996 | |||
997 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
997 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
998 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
998 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
999 | parameter_dump_packet.reserved = CCSDS_RESERVED; |
|
999 | parameter_dump_packet.reserved = CCSDS_RESERVED; | |
1000 | parameter_dump_packet.userApplication = CCSDS_USER_APP; |
|
1000 | parameter_dump_packet.userApplication = CCSDS_USER_APP; | |
1001 | parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8); |
|
1001 | parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8); | |
1002 | parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; |
|
1002 | parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; | |
1003 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
1003 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
1004 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
1004 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
1005 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8); |
|
1005 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8); | |
1006 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; |
|
1006 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; | |
1007 | // DATA FIELD HEADER |
|
1007 | // DATA FIELD HEADER | |
1008 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
1008 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; | |
1009 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; |
|
1009 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; | |
1010 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; |
|
1010 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; | |
1011 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
1011 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
1012 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
1012 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
1013 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
1013 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
1014 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
1014 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
1015 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
1015 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
1016 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
1016 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
1017 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
1017 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); | |
1018 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; |
|
1018 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; | |
1019 |
|
1019 | |||
1020 | //****************** |
|
1020 | //****************** | |
1021 | // COMMON PARAMETERS |
|
1021 | // COMMON PARAMETERS | |
1022 | parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0; |
|
1022 | parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0; | |
1023 | parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1; |
|
1023 | parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1; | |
1024 |
|
1024 | |||
1025 | //****************** |
|
1025 | //****************** | |
1026 | // NORMAL PARAMETERS |
|
1026 | // NORMAL PARAMETERS | |
1027 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8); |
|
1027 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8); | |
1028 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L ); |
|
1028 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L ); | |
1029 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8); |
|
1029 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8); | |
1030 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P ); |
|
1030 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P ); | |
1031 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8); |
|
1031 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8); | |
1032 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P ); |
|
1032 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P ); | |
1033 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0; |
|
1033 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0; | |
1034 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1; |
|
1034 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1; | |
1035 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3; |
|
1035 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3; | |
1036 |
|
1036 | |||
1037 | //***************** |
|
1037 | //***************** | |
1038 | // BURST PARAMETERS |
|
1038 | // BURST PARAMETERS | |
1039 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; |
|
1039 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; | |
1040 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; |
|
1040 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; | |
1041 |
|
1041 | |||
1042 | //**************** |
|
1042 | //**************** | |
1043 | // SBM1 PARAMETERS |
|
1043 | // SBM1 PARAMETERS | |
1044 | parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period |
|
1044 | parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period | |
1045 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; |
|
1045 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; | |
1046 |
|
1046 | |||
1047 | //**************** |
|
1047 | //**************** | |
1048 | // SBM2 PARAMETERS |
|
1048 | // SBM2 PARAMETERS | |
1049 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; |
|
1049 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; | |
1050 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; |
|
1050 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; | |
1051 |
|
1051 | |||
1052 | //************ |
|
1052 | //************ | |
1053 | // FBINS MASKS |
|
1053 | // FBINS MASKS | |
1054 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) |
|
1054 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) | |
1055 | { |
|
1055 | { | |
1056 | parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff; |
|
1056 | parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff; | |
1057 | } |
|
1057 | } | |
1058 | } |
|
1058 | } | |
1059 |
|
1059 | |||
1060 | void init_kcoefficients_dump( void ) |
|
1060 | void init_kcoefficients_dump( void ) | |
1061 | { |
|
1061 | { | |
1062 | init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 ); |
|
1062 | init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 ); | |
1063 | init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 ); |
|
1063 | init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 ); | |
1064 |
|
1064 | |||
1065 | kcoefficient_node_1.previous = NULL; |
|
1065 | kcoefficient_node_1.previous = NULL; | |
1066 | kcoefficient_node_1.next = NULL; |
|
1066 | kcoefficient_node_1.next = NULL; | |
1067 | kcoefficient_node_1.sid = TM_CODE_K_DUMP; |
|
1067 | kcoefficient_node_1.sid = TM_CODE_K_DUMP; | |
1068 | kcoefficient_node_1.coarseTime = 0x00; |
|
1068 | kcoefficient_node_1.coarseTime = 0x00; | |
1069 | kcoefficient_node_1.fineTime = 0x00; |
|
1069 | kcoefficient_node_1.fineTime = 0x00; | |
1070 | kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1; |
|
1070 | kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1; | |
1071 | kcoefficient_node_1.status = 0x00; |
|
1071 | kcoefficient_node_1.status = 0x00; | |
1072 |
|
1072 | |||
1073 | kcoefficient_node_2.previous = NULL; |
|
1073 | kcoefficient_node_2.previous = NULL; | |
1074 | kcoefficient_node_2.next = NULL; |
|
1074 | kcoefficient_node_2.next = NULL; | |
1075 | kcoefficient_node_2.sid = TM_CODE_K_DUMP; |
|
1075 | kcoefficient_node_2.sid = TM_CODE_K_DUMP; | |
1076 | kcoefficient_node_2.coarseTime = 0x00; |
|
1076 | kcoefficient_node_2.coarseTime = 0x00; | |
1077 | kcoefficient_node_2.fineTime = 0x00; |
|
1077 | kcoefficient_node_2.fineTime = 0x00; | |
1078 | kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2; |
|
1078 | kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2; | |
1079 | kcoefficient_node_2.status = 0x00; |
|
1079 | kcoefficient_node_2.status = 0x00; | |
1080 | } |
|
1080 | } | |
1081 |
|
1081 | |||
1082 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ) |
|
1082 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ) | |
1083 | { |
|
1083 | { | |
1084 | unsigned int k; |
|
1084 | unsigned int k; | |
1085 | unsigned int packetLength; |
|
1085 | unsigned int packetLength; | |
1086 |
|
1086 | |||
1087 | packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header |
|
1087 | packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header | |
1088 |
|
1088 | |||
1089 | kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
1089 | kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
1090 | kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
1090 | kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
1091 | kcoefficients_dump->reserved = CCSDS_RESERVED; |
|
1091 | kcoefficients_dump->reserved = CCSDS_RESERVED; | |
1092 | kcoefficients_dump->userApplication = CCSDS_USER_APP; |
|
1092 | kcoefficients_dump->userApplication = CCSDS_USER_APP; | |
1093 | kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);; |
|
1093 | kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);; | |
1094 | kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;; |
|
1094 | kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;; | |
1095 | kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
1095 | kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
1096 | kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
1096 | kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
1097 | kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8); |
|
1097 | kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8); | |
1098 | kcoefficients_dump->packetLength[1] = (unsigned char) packetLength; |
|
1098 | kcoefficients_dump->packetLength[1] = (unsigned char) packetLength; | |
1099 | // DATA FIELD HEADER |
|
1099 | // DATA FIELD HEADER | |
1100 | kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
1100 | kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; | |
1101 | kcoefficients_dump->serviceType = TM_TYPE_K_DUMP; |
|
1101 | kcoefficients_dump->serviceType = TM_TYPE_K_DUMP; | |
1102 | kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP; |
|
1102 | kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP; | |
1103 | kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND; |
|
1103 | kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND; | |
1104 | kcoefficients_dump->time[0] = 0x00; |
|
1104 | kcoefficients_dump->time[0] = 0x00; | |
1105 | kcoefficients_dump->time[1] = 0x00; |
|
1105 | kcoefficients_dump->time[1] = 0x00; | |
1106 | kcoefficients_dump->time[2] = 0x00; |
|
1106 | kcoefficients_dump->time[2] = 0x00; | |
1107 | kcoefficients_dump->time[3] = 0x00; |
|
1107 | kcoefficients_dump->time[3] = 0x00; | |
1108 | kcoefficients_dump->time[4] = 0x00; |
|
1108 | kcoefficients_dump->time[4] = 0x00; | |
1109 | kcoefficients_dump->time[5] = 0x00; |
|
1109 | kcoefficients_dump->time[5] = 0x00; | |
1110 | kcoefficients_dump->sid = SID_K_DUMP; |
|
1110 | kcoefficients_dump->sid = SID_K_DUMP; | |
1111 |
|
1111 | |||
1112 | kcoefficients_dump->pkt_cnt = 2; |
|
1112 | kcoefficients_dump->pkt_cnt = 2; | |
1113 | kcoefficients_dump->pkt_nr = pkt_nr; |
|
1113 | kcoefficients_dump->pkt_nr = pkt_nr; | |
1114 | kcoefficients_dump->blk_nr = blk_nr; |
|
1114 | kcoefficients_dump->blk_nr = blk_nr; | |
1115 |
|
1115 | |||
1116 | //****************** |
|
1116 | //****************** | |
1117 | // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR] |
|
1117 | // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR] | |
1118 | // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900) |
|
1118 | // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900) | |
1119 | for (k=0; k<3900; k++) |
|
1119 | for (k=0; k<3900; k++) | |
1120 | { |
|
1120 | { | |
1121 | kcoefficients_dump->kcoeff_blks[k] = 0x00; |
|
1121 | kcoefficients_dump->kcoeff_blks[k] = 0x00; | |
1122 | } |
|
1122 | } | |
1123 | } |
|
1123 | } | |
1124 |
|
1124 | |||
1125 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ) |
|
1125 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ) | |
1126 | { |
|
1126 | { | |
1127 | /** This function increment the packet sequence control parameter of a TC, depending on its destination ID. |
|
1127 | /** This function increment the packet sequence control parameter of a TC, depending on its destination ID. | |
1128 | * |
|
1128 | * | |
1129 | * @param packet_sequence_control points to the packet sequence control which will be incremented |
|
1129 | * @param packet_sequence_control points to the packet sequence control which will be incremented | |
1130 | * @param destination_id is the destination ID of the TM, there is one counter by destination ID |
|
1130 | * @param destination_id is the destination ID of the TM, there is one counter by destination ID | |
1131 | * |
|
1131 | * | |
1132 | * If the destination ID is not known, a dedicated counter is incremented. |
|
1132 | * If the destination ID is not known, a dedicated counter is incremented. | |
1133 | * |
|
1133 | * | |
1134 | */ |
|
1134 | */ | |
1135 |
|
1135 | |||
1136 | unsigned short sequence_cnt; |
|
1136 | unsigned short sequence_cnt; | |
1137 | unsigned short segmentation_grouping_flag; |
|
1137 | unsigned short segmentation_grouping_flag; | |
1138 | unsigned short new_packet_sequence_control; |
|
1138 | unsigned short new_packet_sequence_control; | |
1139 | unsigned char i; |
|
1139 | unsigned char i; | |
1140 |
|
1140 | |||
1141 | switch (destination_id) |
|
1141 | switch (destination_id) | |
1142 | { |
|
1142 | { | |
1143 | case SID_TC_GROUND: |
|
1143 | case SID_TC_GROUND: | |
1144 | i = GROUND; |
|
1144 | i = GROUND; | |
1145 | break; |
|
1145 | break; | |
1146 | case SID_TC_MISSION_TIMELINE: |
|
1146 | case SID_TC_MISSION_TIMELINE: | |
1147 | i = MISSION_TIMELINE; |
|
1147 | i = MISSION_TIMELINE; | |
1148 | break; |
|
1148 | break; | |
1149 | case SID_TC_TC_SEQUENCES: |
|
1149 | case SID_TC_TC_SEQUENCES: | |
1150 | i = TC_SEQUENCES; |
|
1150 | i = TC_SEQUENCES; | |
1151 | break; |
|
1151 | break; | |
1152 | case SID_TC_RECOVERY_ACTION_CMD: |
|
1152 | case SID_TC_RECOVERY_ACTION_CMD: | |
1153 | i = RECOVERY_ACTION_CMD; |
|
1153 | i = RECOVERY_ACTION_CMD; | |
1154 | break; |
|
1154 | break; | |
1155 | case SID_TC_BACKUP_MISSION_TIMELINE: |
|
1155 | case SID_TC_BACKUP_MISSION_TIMELINE: | |
1156 | i = BACKUP_MISSION_TIMELINE; |
|
1156 | i = BACKUP_MISSION_TIMELINE; | |
1157 | break; |
|
1157 | break; | |
1158 | case SID_TC_DIRECT_CMD: |
|
1158 | case SID_TC_DIRECT_CMD: | |
1159 | i = DIRECT_CMD; |
|
1159 | i = DIRECT_CMD; | |
1160 | break; |
|
1160 | break; | |
1161 | case SID_TC_SPARE_GRD_SRC1: |
|
1161 | case SID_TC_SPARE_GRD_SRC1: | |
1162 | i = SPARE_GRD_SRC1; |
|
1162 | i = SPARE_GRD_SRC1; | |
1163 | break; |
|
1163 | break; | |
1164 | case SID_TC_SPARE_GRD_SRC2: |
|
1164 | case SID_TC_SPARE_GRD_SRC2: | |
1165 | i = SPARE_GRD_SRC2; |
|
1165 | i = SPARE_GRD_SRC2; | |
1166 | break; |
|
1166 | break; | |
1167 | case SID_TC_OBCP: |
|
1167 | case SID_TC_OBCP: | |
1168 | i = OBCP; |
|
1168 | i = OBCP; | |
1169 | break; |
|
1169 | break; | |
1170 | case SID_TC_SYSTEM_CONTROL: |
|
1170 | case SID_TC_SYSTEM_CONTROL: | |
1171 | i = SYSTEM_CONTROL; |
|
1171 | i = SYSTEM_CONTROL; | |
1172 | break; |
|
1172 | break; | |
1173 | case SID_TC_AOCS: |
|
1173 | case SID_TC_AOCS: | |
1174 | i = AOCS; |
|
1174 | i = AOCS; | |
1175 | break; |
|
1175 | break; | |
1176 | case SID_TC_RPW_INTERNAL: |
|
1176 | case SID_TC_RPW_INTERNAL: | |
1177 | i = RPW_INTERNAL; |
|
1177 | i = RPW_INTERNAL; | |
1178 | break; |
|
1178 | break; | |
1179 | default: |
|
1179 | default: | |
1180 | i = GROUND; |
|
1180 | i = GROUND; | |
1181 | break; |
|
1181 | break; | |
1182 | } |
|
1182 | } | |
1183 |
|
1183 | |||
1184 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
1184 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; | |
1185 | sequence_cnt = sequenceCounters_TM_DUMP[ i ] & 0x3fff; |
|
1185 | sequence_cnt = sequenceCounters_TM_DUMP[ i ] & 0x3fff; | |
1186 |
|
1186 | |||
1187 | new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ; |
|
1187 | new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ; | |
1188 |
|
1188 | |||
1189 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); |
|
1189 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); | |
1190 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); |
|
1190 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); | |
1191 |
|
1191 | |||
1192 | // increment the sequence counter |
|
1192 | // increment the sequence counter | |
1193 | if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX ) |
|
1193 | if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX ) | |
1194 | { |
|
1194 | { | |
1195 | sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1; |
|
1195 | sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1; | |
1196 | } |
|
1196 | } | |
1197 | else |
|
1197 | else | |
1198 | { |
|
1198 | { | |
1199 | sequenceCounters_TM_DUMP[ i ] = 0; |
|
1199 | sequenceCounters_TM_DUMP[ i ] = 0; | |
1200 | } |
|
1200 | } | |
1201 | } |
|
1201 | } |
@@ -1,1310 +1,1310 | |||||
1 | /** Functions and tasks related to waveform packet generation. |
|
1 | /** Functions and tasks related to waveform packet generation. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle waveforms, in snapshot or continuous format.\n |
|
6 | * A group of functions to handle waveforms, in snapshot or continuous format.\n | |
7 | * |
|
7 | * | |
8 | */ |
|
8 | */ | |
9 |
|
9 | |||
10 | #include "wf_handler.h" |
|
10 | #include "wf_handler.h" | |
11 |
|
11 | |||
12 | //*************** |
|
12 | //*************** | |
13 | // waveform rings |
|
13 | // waveform rings | |
14 | // F0 |
|
14 | // F0 | |
15 | ring_node waveform_ring_f0[NB_RING_NODES_F0]; |
|
15 | ring_node waveform_ring_f0[NB_RING_NODES_F0]; | |
16 | ring_node *current_ring_node_f0; |
|
16 | ring_node *current_ring_node_f0; | |
17 | ring_node *ring_node_to_send_swf_f0; |
|
17 | ring_node *ring_node_to_send_swf_f0; | |
18 | // F1 |
|
18 | // F1 | |
19 | ring_node waveform_ring_f1[NB_RING_NODES_F1]; |
|
19 | ring_node waveform_ring_f1[NB_RING_NODES_F1]; | |
20 | ring_node *current_ring_node_f1; |
|
20 | ring_node *current_ring_node_f1; | |
21 | ring_node *ring_node_to_send_swf_f1; |
|
21 | ring_node *ring_node_to_send_swf_f1; | |
22 | ring_node *ring_node_to_send_cwf_f1; |
|
22 | ring_node *ring_node_to_send_cwf_f1; | |
23 | // F2 |
|
23 | // F2 | |
24 | ring_node waveform_ring_f2[NB_RING_NODES_F2]; |
|
24 | ring_node waveform_ring_f2[NB_RING_NODES_F2]; | |
25 | ring_node *current_ring_node_f2; |
|
25 | ring_node *current_ring_node_f2; | |
26 | ring_node *ring_node_to_send_swf_f2; |
|
26 | ring_node *ring_node_to_send_swf_f2; | |
27 | ring_node *ring_node_to_send_cwf_f2; |
|
27 | ring_node *ring_node_to_send_cwf_f2; | |
28 | // F3 |
|
28 | // F3 | |
29 | ring_node waveform_ring_f3[NB_RING_NODES_F3]; |
|
29 | ring_node waveform_ring_f3[NB_RING_NODES_F3]; | |
30 | ring_node *current_ring_node_f3; |
|
30 | ring_node *current_ring_node_f3; | |
31 | ring_node *ring_node_to_send_cwf_f3; |
|
31 | ring_node *ring_node_to_send_cwf_f3; | |
32 | char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK ]; |
|
32 | char wf_cont_f3_light[ (NB_SAMPLES_PER_SNAPSHOT) * NB_BYTES_CWF3_LIGHT_BLK ]; | |
33 |
|
33 | |||
34 | bool extractSWF1 = false; |
|
34 | bool extractSWF1 = false; | |
35 | bool extractSWF2 = false; |
|
35 | bool extractSWF2 = false; | |
36 | bool swf0_ready_flag_f1 = false; |
|
36 | bool swf0_ready_flag_f1 = false; | |
37 | bool swf0_ready_flag_f2 = false; |
|
37 | bool swf0_ready_flag_f2 = false; | |
38 | bool swf1_ready = false; |
|
38 | bool swf1_ready = false; | |
39 | bool swf2_ready = false; |
|
39 | bool swf2_ready = false; | |
40 |
|
40 | |||
41 | int swf1_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ]; |
|
41 | int swf1_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ]; | |
42 | int swf2_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ]; |
|
42 | int swf2_extracted[ (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK) ]; | |
43 | ring_node ring_node_swf1_extracted; |
|
43 | ring_node ring_node_swf1_extracted; | |
44 | ring_node ring_node_swf2_extracted; |
|
44 | ring_node ring_node_swf2_extracted; | |
45 |
|
45 | |||
46 | typedef enum resynchro_state_t |
|
46 | typedef enum resynchro_state_t | |
47 | { |
|
47 | { | |
48 | MEASURE, |
|
48 | MEASURE, | |
49 | CORRECTION |
|
49 | CORRECTION | |
50 | } resynchro_state; |
|
50 | } resynchro_state; | |
51 |
|
51 | |||
52 | //********************* |
|
52 | //********************* | |
53 | // Interrupt SubRoutine |
|
53 | // Interrupt SubRoutine | |
54 |
|
54 | |||
55 | ring_node * getRingNodeToSendCWF( unsigned char frequencyChannel) |
|
55 | ring_node * getRingNodeToSendCWF( unsigned char frequencyChannel) | |
56 | { |
|
56 | { | |
57 | ring_node *node; |
|
57 | ring_node *node; | |
58 |
|
58 | |||
59 | node = NULL; |
|
59 | node = NULL; | |
60 | switch ( frequencyChannel ) { |
|
60 | switch ( frequencyChannel ) { | |
61 | case 1: |
|
61 | case 1: | |
62 | node = ring_node_to_send_cwf_f1; |
|
62 | node = ring_node_to_send_cwf_f1; | |
63 | break; |
|
63 | break; | |
64 | case 2: |
|
64 | case 2: | |
65 | node = ring_node_to_send_cwf_f2; |
|
65 | node = ring_node_to_send_cwf_f2; | |
66 | break; |
|
66 | break; | |
67 | case 3: |
|
67 | case 3: | |
68 | node = ring_node_to_send_cwf_f3; |
|
68 | node = ring_node_to_send_cwf_f3; | |
69 | break; |
|
69 | break; | |
70 | default: |
|
70 | default: | |
71 | break; |
|
71 | break; | |
72 | } |
|
72 | } | |
73 |
|
73 | |||
74 | return node; |
|
74 | return node; | |
75 | } |
|
75 | } | |
76 |
|
76 | |||
77 | ring_node * getRingNodeToSendSWF( unsigned char frequencyChannel) |
|
77 | ring_node * getRingNodeToSendSWF( unsigned char frequencyChannel) | |
78 | { |
|
78 | { | |
79 | ring_node *node; |
|
79 | ring_node *node; | |
80 |
|
80 | |||
81 | node = NULL; |
|
81 | node = NULL; | |
82 | switch ( frequencyChannel ) { |
|
82 | switch ( frequencyChannel ) { | |
83 | case 0: |
|
83 | case 0: | |
84 | node = ring_node_to_send_swf_f0; |
|
84 | node = ring_node_to_send_swf_f0; | |
85 | break; |
|
85 | break; | |
86 | case 1: |
|
86 | case 1: | |
87 | node = ring_node_to_send_swf_f1; |
|
87 | node = ring_node_to_send_swf_f1; | |
88 | break; |
|
88 | break; | |
89 | case 2: |
|
89 | case 2: | |
90 | node = ring_node_to_send_swf_f2; |
|
90 | node = ring_node_to_send_swf_f2; | |
91 | break; |
|
91 | break; | |
92 | default: |
|
92 | default: | |
93 | break; |
|
93 | break; | |
94 | } |
|
94 | } | |
95 |
|
95 | |||
96 | return node; |
|
96 | return node; | |
97 | } |
|
97 | } | |
98 |
|
98 | |||
99 | void reset_extractSWF( void ) |
|
99 | void reset_extractSWF( void ) | |
100 | { |
|
100 | { | |
101 | extractSWF1 = false; |
|
101 | extractSWF1 = false; | |
102 | extractSWF2 = false; |
|
102 | extractSWF2 = false; | |
103 | swf0_ready_flag_f1 = false; |
|
103 | swf0_ready_flag_f1 = false; | |
104 | swf0_ready_flag_f2 = false; |
|
104 | swf0_ready_flag_f2 = false; | |
105 | swf1_ready = false; |
|
105 | swf1_ready = false; | |
106 | swf2_ready = false; |
|
106 | swf2_ready = false; | |
107 | } |
|
107 | } | |
108 |
|
108 | |||
109 | inline void waveforms_isr_f3( void ) |
|
109 | inline void waveforms_isr_f3( void ) | |
110 | { |
|
110 | { | |
111 | rtems_status_code spare_status; |
|
111 | rtems_status_code spare_status; | |
112 |
|
112 | |||
113 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_BURST) // in BURST the data are used to place v, e1 and e2 in the HK packet |
|
113 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || (lfrCurrentMode == LFR_MODE_BURST) // in BURST the data are used to place v, e1 and e2 in the HK packet | |
114 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) |
|
114 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) | |
115 | { // in modes other than STANDBY and BURST, send the CWF_F3 data |
|
115 | { // in modes other than STANDBY and BURST, send the CWF_F3 data | |
116 | //*** |
|
116 | //*** | |
117 | // F3 |
|
117 | // F3 | |
118 | if ( (waveform_picker_regs->status & 0xc0) != 0x00 ) { // [1100 0000] check the f3 full bits |
|
118 | if ( (waveform_picker_regs->status & 0xc0) != 0x00 ) { // [1100 0000] check the f3 full bits | |
119 | ring_node_to_send_cwf_f3 = current_ring_node_f3->previous; |
|
119 | ring_node_to_send_cwf_f3 = current_ring_node_f3->previous; | |
120 | current_ring_node_f3 = current_ring_node_f3->next; |
|
120 | current_ring_node_f3 = current_ring_node_f3->next; | |
121 | if ((waveform_picker_regs->status & 0x40) == 0x40){ // [0100 0000] f3 buffer 0 is full |
|
121 | if ((waveform_picker_regs->status & 0x40) == 0x40){ // [0100 0000] f3 buffer 0 is full | |
122 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time; |
|
122 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_0_coarse_time; | |
123 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time; |
|
123 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_0_fine_time; | |
124 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address; |
|
124 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->buffer_address; | |
125 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00008840; // [1000 1000 0100 0000] |
|
125 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00008840; // [1000 1000 0100 0000] | |
126 | } |
|
126 | } | |
127 | else if ((waveform_picker_regs->status & 0x80) == 0x80){ // [1000 0000] f3 buffer 1 is full |
|
127 | else if ((waveform_picker_regs->status & 0x80) == 0x80){ // [1000 0000] f3 buffer 1 is full | |
128 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time; |
|
128 | ring_node_to_send_cwf_f3->coarseTime = waveform_picker_regs->f3_1_coarse_time; | |
129 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time; |
|
129 | ring_node_to_send_cwf_f3->fineTime = waveform_picker_regs->f3_1_fine_time; | |
130 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; |
|
130 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; | |
131 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00008880; // [1000 1000 1000 0000] |
|
131 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00008880; // [1000 1000 1000 0000] | |
132 | } |
|
132 | } | |
133 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
133 | if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
134 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); |
|
134 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); | |
135 | } |
|
135 | } | |
136 | } |
|
136 | } | |
137 | } |
|
137 | } | |
138 | } |
|
138 | } | |
139 |
|
139 | |||
140 | inline void waveforms_isr_burst( void ) |
|
140 | inline void waveforms_isr_burst( void ) | |
141 | { |
|
141 | { | |
142 | unsigned char status; |
|
142 | unsigned char status; | |
143 | rtems_status_code spare_status; |
|
143 | rtems_status_code spare_status; | |
144 |
|
144 | |||
145 | status = (waveform_picker_regs->status & 0x30) >> 4; // [0011 0000] get the status bits for f2 |
|
145 | status = (waveform_picker_regs->status & 0x30) >> 4; // [0011 0000] get the status bits for f2 | |
146 |
|
146 | |||
147 |
|
147 | |||
148 | switch(status) |
|
148 | switch(status) | |
149 | { |
|
149 | { | |
150 | case 1: |
|
150 | case 1: | |
151 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; |
|
151 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; | |
152 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; |
|
152 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; | |
153 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; |
|
153 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; | |
154 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; |
|
154 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; | |
155 | current_ring_node_f2 = current_ring_node_f2->next; |
|
155 | current_ring_node_f2 = current_ring_node_f2->next; | |
156 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; |
|
156 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; | |
157 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { |
|
157 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { | |
158 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); |
|
158 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); | |
159 | } |
|
159 | } | |
160 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] |
|
160 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] | |
161 | break; |
|
161 | break; | |
162 | case 2: |
|
162 | case 2: | |
163 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; |
|
163 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; | |
164 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; |
|
164 | ring_node_to_send_cwf_f2->sid = SID_BURST_CWF_F2; | |
165 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; |
|
165 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; | |
166 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; |
|
166 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; | |
167 | current_ring_node_f2 = current_ring_node_f2->next; |
|
167 | current_ring_node_f2 = current_ring_node_f2->next; | |
168 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; |
|
168 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; | |
169 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { |
|
169 | if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) { | |
170 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); |
|
170 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ); | |
171 | } |
|
171 | } | |
172 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] |
|
172 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] | |
173 | break; |
|
173 | break; | |
174 | default: |
|
174 | default: | |
175 | break; |
|
175 | break; | |
176 | } |
|
176 | } | |
177 | } |
|
177 | } | |
178 |
|
178 | |||
179 | inline void waveform_isr_normal_sbm1_sbm2( void ) |
|
179 | inline void waveform_isr_normal_sbm1_sbm2( void ) | |
180 | { |
|
180 | { | |
181 | rtems_status_code status; |
|
181 | rtems_status_code status; | |
182 |
|
182 | |||
183 | //*** |
|
183 | //*** | |
184 | // F0 |
|
184 | // F0 | |
185 | if ( (waveform_picker_regs->status & 0x03) != 0x00 ) // [0000 0011] check the f0 full bits |
|
185 | if ( (waveform_picker_regs->status & 0x03) != 0x00 ) // [0000 0011] check the f0 full bits | |
186 | { |
|
186 | { | |
187 | swf0_ready_flag_f1 = true; |
|
187 | swf0_ready_flag_f1 = true; | |
188 | swf0_ready_flag_f2 = true; |
|
188 | swf0_ready_flag_f2 = true; | |
189 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; |
|
189 | ring_node_to_send_swf_f0 = current_ring_node_f0->previous; | |
190 | current_ring_node_f0 = current_ring_node_f0->next; |
|
190 | current_ring_node_f0 = current_ring_node_f0->next; | |
191 | if ( (waveform_picker_regs->status & 0x01) == 0x01) |
|
191 | if ( (waveform_picker_regs->status & 0x01) == 0x01) | |
192 | { |
|
192 | { | |
193 |
|
193 | |||
194 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; |
|
194 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_0_coarse_time; | |
195 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; |
|
195 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_0_fine_time; | |
196 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; |
|
196 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->buffer_address; | |
197 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001] |
|
197 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001101; // [0001 0001 0000 0001] | |
198 | } |
|
198 | } | |
199 | else if ( (waveform_picker_regs->status & 0x02) == 0x02) |
|
199 | else if ( (waveform_picker_regs->status & 0x02) == 0x02) | |
200 | { |
|
200 | { | |
201 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; |
|
201 | ring_node_to_send_swf_f0->coarseTime = waveform_picker_regs->f0_1_coarse_time; | |
202 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; |
|
202 | ring_node_to_send_swf_f0->fineTime = waveform_picker_regs->f0_1_fine_time; | |
203 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; |
|
203 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; | |
204 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010] |
|
204 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00001102; // [0001 0001 0000 0010] | |
205 | } |
|
205 | } | |
206 | // send an event to the WFRM task for resynchro activities |
|
206 | // send an event to the WFRM task for resynchro activities | |
207 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_SWF_RESYNCH ); |
|
207 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_SWF_RESYNCH ); | |
208 | } |
|
208 | } | |
209 |
|
209 | |||
210 | //*** |
|
210 | //*** | |
211 | // F1 |
|
211 | // F1 | |
212 | if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bits |
|
212 | if ( (waveform_picker_regs->status & 0x0c) != 0x00 ) { // [0000 1100] check the f1 full bits | |
213 | // (1) change the receiving buffer for the waveform picker |
|
213 | // (1) change the receiving buffer for the waveform picker | |
214 | ring_node_to_send_cwf_f1 = current_ring_node_f1->previous; |
|
214 | ring_node_to_send_cwf_f1 = current_ring_node_f1->previous; | |
215 | current_ring_node_f1 = current_ring_node_f1->next; |
|
215 | current_ring_node_f1 = current_ring_node_f1->next; | |
216 | if ( (waveform_picker_regs->status & 0x04) == 0x04) |
|
216 | if ( (waveform_picker_regs->status & 0x04) == 0x04) | |
217 | { |
|
217 | { | |
218 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; |
|
218 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_0_coarse_time; | |
219 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; |
|
219 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_0_fine_time; | |
220 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; |
|
220 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->buffer_address; | |
221 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0 |
|
221 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002204; // [0010 0010 0000 0100] f1 bits = 0 | |
222 | } |
|
222 | } | |
223 | else if ( (waveform_picker_regs->status & 0x08) == 0x08) |
|
223 | else if ( (waveform_picker_regs->status & 0x08) == 0x08) | |
224 | { |
|
224 | { | |
225 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; |
|
225 | ring_node_to_send_cwf_f1->coarseTime = waveform_picker_regs->f1_1_coarse_time; | |
226 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; |
|
226 | ring_node_to_send_cwf_f1->fineTime = waveform_picker_regs->f1_1_fine_time; | |
227 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; |
|
227 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; | |
228 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0 |
|
228 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00002208; // [0010 0010 0000 1000] f1 bits = 0 | |
229 | } |
|
229 | } | |
230 | // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed) |
|
230 | // (2) send an event for the the CWF1 task for transmission (and snapshot extraction if needed) | |
231 | status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_NORM_S1_S2 ); |
|
231 | status = rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_NORM_S1_S2 ); | |
232 | } |
|
232 | } | |
233 |
|
233 | |||
234 | //*** |
|
234 | //*** | |
235 | // F2 |
|
235 | // F2 | |
236 | if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bit |
|
236 | if ( (waveform_picker_regs->status & 0x30) != 0x00 ) { // [0011 0000] check the f2 full bit | |
237 | // (1) change the receiving buffer for the waveform picker |
|
237 | // (1) change the receiving buffer for the waveform picker | |
238 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; |
|
238 | ring_node_to_send_cwf_f2 = current_ring_node_f2->previous; | |
239 | ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2; |
|
239 | ring_node_to_send_cwf_f2->sid = SID_SBM2_CWF_F2; | |
240 | current_ring_node_f2 = current_ring_node_f2->next; |
|
240 | current_ring_node_f2 = current_ring_node_f2->next; | |
241 | if ( (waveform_picker_regs->status & 0x10) == 0x10) |
|
241 | if ( (waveform_picker_regs->status & 0x10) == 0x10) | |
242 | { |
|
242 | { | |
243 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; |
|
243 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_0_coarse_time; | |
244 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; |
|
244 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_0_fine_time; | |
245 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; |
|
245 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->buffer_address; | |
246 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] |
|
246 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004410; // [0100 0100 0001 0000] | |
247 | } |
|
247 | } | |
248 | else if ( (waveform_picker_regs->status & 0x20) == 0x20) |
|
248 | else if ( (waveform_picker_regs->status & 0x20) == 0x20) | |
249 | { |
|
249 | { | |
250 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; |
|
250 | ring_node_to_send_cwf_f2->coarseTime = waveform_picker_regs->f2_1_coarse_time; | |
251 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; |
|
251 | ring_node_to_send_cwf_f2->fineTime = waveform_picker_regs->f2_1_fine_time; | |
252 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; |
|
252 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; | |
253 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] |
|
253 | waveform_picker_regs->status = waveform_picker_regs->status & 0x00004420; // [0100 0100 0010 0000] | |
254 | } |
|
254 | } | |
255 | // (2) send an event for the waveforms transmission |
|
255 | // (2) send an event for the waveforms transmission | |
256 | status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_NORM_S1_S2 ); |
|
256 | status = rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_NORM_S1_S2 ); | |
257 | } |
|
257 | } | |
258 | } |
|
258 | } | |
259 |
|
259 | |||
260 | rtems_isr waveforms_isr( rtems_vector_number vector ) |
|
260 | rtems_isr waveforms_isr( rtems_vector_number vector ) | |
261 | { |
|
261 | { | |
262 | /** This is the interrupt sub routine called by the waveform picker core. |
|
262 | /** This is the interrupt sub routine called by the waveform picker core. | |
263 | * |
|
263 | * | |
264 | * This ISR launch different actions depending mainly on two pieces of information: |
|
264 | * This ISR launch different actions depending mainly on two pieces of information: | |
265 | * 1. the values read in the registers of the waveform picker. |
|
265 | * 1. the values read in the registers of the waveform picker. | |
266 | * 2. the current LFR mode. |
|
266 | * 2. the current LFR mode. | |
267 | * |
|
267 | * | |
268 | */ |
|
268 | */ | |
269 |
|
269 | |||
270 | // STATUS |
|
270 | // STATUS | |
271 | // new error error buffer full |
|
271 | // new error error buffer full | |
272 | // 15 14 13 12 11 10 9 8 |
|
272 | // 15 14 13 12 11 10 9 8 | |
273 | // f3 f2 f1 f0 f3 f2 f1 f0 |
|
273 | // f3 f2 f1 f0 f3 f2 f1 f0 | |
274 | // |
|
274 | // | |
275 | // ready buffer |
|
275 | // ready buffer | |
276 | // 7 6 5 4 3 2 1 0 |
|
276 | // 7 6 5 4 3 2 1 0 | |
277 | // f3_1 f3_0 f2_1 f2_0 f1_1 f1_0 f0_1 f0_0 |
|
277 | // f3_1 f3_0 f2_1 f2_0 f1_1 f1_0 f0_1 f0_0 | |
278 |
|
278 | |||
279 | rtems_status_code spare_status; |
|
279 | rtems_status_code spare_status; | |
280 |
|
280 | |||
281 | waveforms_isr_f3(); |
|
281 | waveforms_isr_f3(); | |
282 |
|
282 | |||
283 | //************************************************* |
|
283 | //************************************************* | |
284 | // copy the status bits in the housekeeping packets |
|
284 | // copy the status bits in the housekeeping packets | |
285 | housekeeping_packet.hk_lfr_vhdl_iir_cal = |
|
285 | housekeeping_packet.hk_lfr_vhdl_iir_cal = | |
286 | (unsigned char) ((waveform_picker_regs->status & 0xff00) >> 8); |
|
286 | (unsigned char) ((waveform_picker_regs->status & 0xff00) >> 8); | |
287 |
|
287 | |||
288 | if ( (waveform_picker_regs->status & 0xff00) != 0x00) // [1111 1111 0000 0000] check the error bits |
|
288 | if ( (waveform_picker_regs->status & 0xff00) != 0x00) // [1111 1111 0000 0000] check the error bits | |
289 | { |
|
289 | { | |
290 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 ); |
|
290 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_10 ); | |
291 | } |
|
291 | } | |
292 |
|
292 | |||
293 | switch(lfrCurrentMode) |
|
293 | switch(lfrCurrentMode) | |
294 | { |
|
294 | { | |
295 | //******** |
|
295 | //******** | |
296 | // STANDBY |
|
296 | // STANDBY | |
297 | case LFR_MODE_STANDBY: |
|
297 | case LFR_MODE_STANDBY: | |
298 | break; |
|
298 | break; | |
299 | //************************** |
|
299 | //************************** | |
300 | // LFR NORMAL, SBM1 and SBM2 |
|
300 | // LFR NORMAL, SBM1 and SBM2 | |
301 | case LFR_MODE_NORMAL: |
|
301 | case LFR_MODE_NORMAL: | |
302 | case LFR_MODE_SBM1: |
|
302 | case LFR_MODE_SBM1: | |
303 | case LFR_MODE_SBM2: |
|
303 | case LFR_MODE_SBM2: | |
304 | waveform_isr_normal_sbm1_sbm2(); |
|
304 | waveform_isr_normal_sbm1_sbm2(); | |
305 | break; |
|
305 | break; | |
306 | //****** |
|
306 | //****** | |
307 | // BURST |
|
307 | // BURST | |
308 | case LFR_MODE_BURST: |
|
308 | case LFR_MODE_BURST: | |
309 | waveforms_isr_burst(); |
|
309 | waveforms_isr_burst(); | |
310 | break; |
|
310 | break; | |
311 | //******** |
|
311 | //******** | |
312 | // DEFAULT |
|
312 | // DEFAULT | |
313 | default: |
|
313 | default: | |
314 | break; |
|
314 | break; | |
315 | } |
|
315 | } | |
316 | } |
|
316 | } | |
317 |
|
317 | |||
318 | //************ |
|
318 | //************ | |
319 | // RTEMS TASKS |
|
319 | // RTEMS TASKS | |
320 |
|
320 | |||
321 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
321 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP | |
322 | { |
|
322 | { | |
323 | /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode. |
|
323 | /** This RTEMS task is dedicated to the transmission of snapshots of the NORMAL mode. | |
324 | * |
|
324 | * | |
325 | * @param unused is the starting argument of the RTEMS task |
|
325 | * @param unused is the starting argument of the RTEMS task | |
326 | * |
|
326 | * | |
327 | * The following data packets are sent by this task: |
|
327 | * The following data packets are sent by this task: | |
328 | * - TM_LFR_SCIENCE_NORMAL_SWF_F0 |
|
328 | * - TM_LFR_SCIENCE_NORMAL_SWF_F0 | |
329 | * - TM_LFR_SCIENCE_NORMAL_SWF_F1 |
|
329 | * - TM_LFR_SCIENCE_NORMAL_SWF_F1 | |
330 | * - TM_LFR_SCIENCE_NORMAL_SWF_F2 |
|
330 | * - TM_LFR_SCIENCE_NORMAL_SWF_F2 | |
331 | * |
|
331 | * | |
332 | */ |
|
332 | */ | |
333 |
|
333 | |||
334 | rtems_event_set event_out; |
|
334 | rtems_event_set event_out; | |
335 | rtems_id queue_id; |
|
335 | rtems_id queue_id; | |
336 | rtems_status_code status; |
|
336 | rtems_status_code status; | |
337 | ring_node *ring_node_swf1_extracted_ptr; |
|
337 | ring_node *ring_node_swf1_extracted_ptr; | |
338 | ring_node *ring_node_swf2_extracted_ptr; |
|
338 | ring_node *ring_node_swf2_extracted_ptr; | |
339 |
|
339 | |||
340 | ring_node_swf1_extracted_ptr = (ring_node *) &ring_node_swf1_extracted; |
|
340 | ring_node_swf1_extracted_ptr = (ring_node *) &ring_node_swf1_extracted; | |
341 | ring_node_swf2_extracted_ptr = (ring_node *) &ring_node_swf2_extracted; |
|
341 | ring_node_swf2_extracted_ptr = (ring_node *) &ring_node_swf2_extracted; | |
342 |
|
342 | |||
343 | status = get_message_queue_id_send( &queue_id ); |
|
343 | status = get_message_queue_id_send( &queue_id ); | |
344 | if (status != RTEMS_SUCCESSFUL) |
|
344 | if (status != RTEMS_SUCCESSFUL) | |
345 | { |
|
345 | { | |
346 | PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status); |
|
346 | PRINTF1("in WFRM *** ERR get_message_queue_id_send %d\n", status); | |
347 | } |
|
347 | } | |
348 |
|
348 | |||
349 | BOOT_PRINTF("in WFRM ***\n"); |
|
349 | BOOT_PRINTF("in WFRM ***\n"); | |
350 |
|
350 | |||
351 | while(1){ |
|
351 | while(1){ | |
352 | // wait for an RTEMS_EVENT |
|
352 | // wait for an RTEMS_EVENT | |
353 | rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_SWF_RESYNCH, |
|
353 | rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_SWF_RESYNCH, | |
354 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
354 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
355 |
|
355 | |||
356 | if (event_out == RTEMS_EVENT_MODE_NORMAL) |
|
356 | if (event_out == RTEMS_EVENT_MODE_NORMAL) | |
357 | { |
|
357 | { | |
358 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n"); |
|
358 | DEBUG_PRINTF("WFRM received RTEMS_EVENT_MODE_SBM2\n"); | |
359 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; |
|
359 | ring_node_to_send_swf_f0->sid = SID_NORM_SWF_F0; | |
360 | ring_node_swf1_extracted_ptr->sid = SID_NORM_SWF_F1; |
|
360 | ring_node_swf1_extracted_ptr->sid = SID_NORM_SWF_F1; | |
361 | ring_node_swf2_extracted_ptr->sid = SID_NORM_SWF_F2; |
|
361 | ring_node_swf2_extracted_ptr->sid = SID_NORM_SWF_F2; | |
362 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); |
|
362 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_swf_f0, sizeof( ring_node* ) ); | |
363 | status = rtems_message_queue_send( queue_id, &ring_node_swf1_extracted_ptr, sizeof( ring_node* ) ); |
|
363 | status = rtems_message_queue_send( queue_id, &ring_node_swf1_extracted_ptr, sizeof( ring_node* ) ); | |
364 | status = rtems_message_queue_send( queue_id, &ring_node_swf2_extracted_ptr, sizeof( ring_node* ) ); |
|
364 | status = rtems_message_queue_send( queue_id, &ring_node_swf2_extracted_ptr, sizeof( ring_node* ) ); | |
365 | } |
|
365 | } | |
366 | if (event_out == RTEMS_EVENT_SWF_RESYNCH) |
|
366 | if (event_out == RTEMS_EVENT_SWF_RESYNCH) | |
367 | { |
|
367 | { | |
368 | snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); |
|
368 | snapshot_resynchronization( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); | |
369 | } |
|
369 | } | |
370 | } |
|
370 | } | |
371 | } |
|
371 | } | |
372 |
|
372 | |||
373 | rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP |
|
373 | rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP | |
374 | { |
|
374 | { | |
375 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3. |
|
375 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f3. | |
376 | * |
|
376 | * | |
377 | * @param unused is the starting argument of the RTEMS task |
|
377 | * @param unused is the starting argument of the RTEMS task | |
378 | * |
|
378 | * | |
379 | * The following data packet is sent by this task: |
|
379 | * The following data packet is sent by this task: | |
380 | * - TM_LFR_SCIENCE_NORMAL_CWF_F3 |
|
380 | * - TM_LFR_SCIENCE_NORMAL_CWF_F3 | |
381 | * |
|
381 | * | |
382 | */ |
|
382 | */ | |
383 |
|
383 | |||
384 | rtems_event_set event_out; |
|
384 | rtems_event_set event_out; | |
385 | rtems_id queue_id; |
|
385 | rtems_id queue_id; | |
386 | rtems_status_code status; |
|
386 | rtems_status_code status; | |
387 | ring_node ring_node_cwf3_light; |
|
387 | ring_node ring_node_cwf3_light; | |
388 | ring_node *ring_node_to_send_cwf; |
|
388 | ring_node *ring_node_to_send_cwf; | |
389 |
|
389 | |||
390 | status = get_message_queue_id_send( &queue_id ); |
|
390 | status = get_message_queue_id_send( &queue_id ); | |
391 | if (status != RTEMS_SUCCESSFUL) |
|
391 | if (status != RTEMS_SUCCESSFUL) | |
392 | { |
|
392 | { | |
393 | PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status) |
|
393 | PRINTF1("in CWF3 *** ERR get_message_queue_id_send %d\n", status) | |
394 | } |
|
394 | } | |
395 |
|
395 | |||
396 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; |
|
396 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; | |
397 |
|
397 | |||
398 | // init the ring_node_cwf3_light structure |
|
398 | // init the ring_node_cwf3_light structure | |
399 | ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light; |
|
399 | ring_node_cwf3_light.buffer_address = (int) wf_cont_f3_light; | |
400 | ring_node_cwf3_light.coarseTime = 0x00; |
|
400 | ring_node_cwf3_light.coarseTime = 0x00; | |
401 | ring_node_cwf3_light.fineTime = 0x00; |
|
401 | ring_node_cwf3_light.fineTime = 0x00; | |
402 | ring_node_cwf3_light.next = NULL; |
|
402 | ring_node_cwf3_light.next = NULL; | |
403 | ring_node_cwf3_light.previous = NULL; |
|
403 | ring_node_cwf3_light.previous = NULL; | |
404 | ring_node_cwf3_light.sid = SID_NORM_CWF_F3; |
|
404 | ring_node_cwf3_light.sid = SID_NORM_CWF_F3; | |
405 | ring_node_cwf3_light.status = 0x00; |
|
405 | ring_node_cwf3_light.status = 0x00; | |
406 |
|
406 | |||
407 | BOOT_PRINTF("in CWF3 ***\n") |
|
407 | BOOT_PRINTF("in CWF3 ***\n") | |
408 |
|
408 | |||
409 | while(1){ |
|
409 | while(1){ | |
410 | // wait for an RTEMS_EVENT |
|
410 | // wait for an RTEMS_EVENT | |
411 | rtems_event_receive( RTEMS_EVENT_0, |
|
411 | rtems_event_receive( RTEMS_EVENT_0, | |
412 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
412 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
413 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) |
|
413 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) | |
414 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) ) |
|
414 | || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode==LFR_MODE_SBM2) ) | |
415 | { |
|
415 | { | |
416 | ring_node_to_send_cwf = getRingNodeToSendCWF( 3 ); |
|
416 | ring_node_to_send_cwf = getRingNodeToSendCWF( 3 ); | |
417 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) |
|
417 | if ( (parameter_dump_packet.sy_lfr_n_cwf_long_f3 & 0x01) == 0x01) | |
418 | { |
|
418 | { | |
419 | PRINTF("send CWF_LONG_F3\n") |
|
419 | PRINTF("send CWF_LONG_F3\n") | |
420 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; |
|
420 | ring_node_to_send_cwf_f3->sid = SID_NORM_CWF_LONG_F3; | |
421 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); |
|
421 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); | |
422 | } |
|
422 | } | |
423 | else |
|
423 | else | |
424 | { |
|
424 | { | |
425 | PRINTF("send CWF_F3 (light)\n") |
|
425 | PRINTF("send CWF_F3 (light)\n") | |
426 | send_waveform_CWF3_light( ring_node_to_send_cwf, &ring_node_cwf3_light, queue_id ); |
|
426 | send_waveform_CWF3_light( ring_node_to_send_cwf, &ring_node_cwf3_light, queue_id ); | |
427 | } |
|
427 | } | |
428 |
|
428 | |||
429 | } |
|
429 | } | |
430 | else |
|
430 | else | |
431 | { |
|
431 | { | |
432 | PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode) |
|
432 | PRINTF1("in CWF3 *** lfrCurrentMode is %d, no data will be sent\n", lfrCurrentMode) | |
433 | } |
|
433 | } | |
434 | } |
|
434 | } | |
435 | } |
|
435 | } | |
436 |
|
436 | |||
437 | rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2 |
|
437 | rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2 | |
438 | { |
|
438 | { | |
439 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2. |
|
439 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f2. | |
440 | * |
|
440 | * | |
441 | * @param unused is the starting argument of the RTEMS task |
|
441 | * @param unused is the starting argument of the RTEMS task | |
442 | * |
|
442 | * | |
443 | * The following data packet is sent by this function: |
|
443 | * The following data packet is sent by this function: | |
444 | * - TM_LFR_SCIENCE_BURST_CWF_F2 |
|
444 | * - TM_LFR_SCIENCE_BURST_CWF_F2 | |
445 | * - TM_LFR_SCIENCE_SBM2_CWF_F2 |
|
445 | * - TM_LFR_SCIENCE_SBM2_CWF_F2 | |
446 | * |
|
446 | * | |
447 | */ |
|
447 | */ | |
448 |
|
448 | |||
449 | rtems_event_set event_out; |
|
449 | rtems_event_set event_out; | |
450 | rtems_id queue_id; |
|
450 | rtems_id queue_id; | |
451 | rtems_status_code status; |
|
451 | rtems_status_code status; | |
452 | ring_node *ring_node_to_send; |
|
452 | ring_node *ring_node_to_send; | |
453 | unsigned long long int acquisitionTimeF0_asLong; |
|
453 | unsigned long long int acquisitionTimeF0_asLong; | |
454 |
|
454 | |||
455 | acquisitionTimeF0_asLong = 0x00; |
|
455 | acquisitionTimeF0_asLong = 0x00; | |
456 |
|
456 | |||
457 | status = get_message_queue_id_send( &queue_id ); |
|
457 | status = get_message_queue_id_send( &queue_id ); | |
458 | if (status != RTEMS_SUCCESSFUL) |
|
458 | if (status != RTEMS_SUCCESSFUL) | |
459 | { |
|
459 | { | |
460 | PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status) |
|
460 | PRINTF1("in CWF2 *** ERR get_message_queue_id_send %d\n", status) | |
461 | } |
|
461 | } | |
462 |
|
462 | |||
463 | BOOT_PRINTF("in CWF2 ***\n") |
|
463 | BOOT_PRINTF("in CWF2 ***\n") | |
464 |
|
464 | |||
465 | while(1){ |
|
465 | while(1){ | |
466 | // wait for an RTEMS_EVENT// send the snapshot when built |
|
466 | // wait for an RTEMS_EVENT// send the snapshot when built | |
467 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ); |
|
467 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ); | |
468 | rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2 | RTEMS_EVENT_MODE_BURST, |
|
468 | rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2 | RTEMS_EVENT_MODE_BURST, | |
469 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
469 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
470 | ring_node_to_send = getRingNodeToSendCWF( 2 ); |
|
470 | ring_node_to_send = getRingNodeToSendCWF( 2 ); | |
471 | if (event_out == RTEMS_EVENT_MODE_BURST) |
|
471 | if (event_out == RTEMS_EVENT_MODE_BURST) | |
472 | { |
|
472 | { | |
473 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); |
|
473 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); | |
474 | } |
|
474 | } | |
475 | else if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2) |
|
475 | else if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2) | |
476 | { |
|
476 | { | |
477 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) |
|
477 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) | |
478 | { |
|
478 | { | |
479 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); |
|
479 | status = rtems_message_queue_send( queue_id, &ring_node_to_send, sizeof( ring_node* ) ); | |
480 | } |
|
480 | } | |
481 | // launch snapshot extraction if needed |
|
481 | // launch snapshot extraction if needed | |
482 | if (extractSWF2 == true) |
|
482 | if (extractSWF2 == true) | |
483 | { |
|
483 | { | |
484 | ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2; |
|
484 | ring_node_to_send_swf_f2 = ring_node_to_send_cwf_f2; | |
485 | // extract the snapshot |
|
485 | // extract the snapshot | |
486 | build_snapshot_from_ring( ring_node_to_send_swf_f2, 2, acquisitionTimeF0_asLong, |
|
486 | build_snapshot_from_ring( ring_node_to_send_swf_f2, 2, acquisitionTimeF0_asLong, | |
487 | &ring_node_swf2_extracted, swf2_extracted ); |
|
487 | &ring_node_swf2_extracted, swf2_extracted ); | |
488 | extractSWF2 = false; |
|
488 | extractSWF2 = false; | |
489 | swf2_ready = true; // once the snapshot at f2 is ready the CWF1 task will send an event to WFRM |
|
489 | swf2_ready = true; // once the snapshot at f2 is ready the CWF1 task will send an event to WFRM | |
490 | } |
|
490 | } | |
491 | if (swf0_ready_flag_f2 == true) |
|
491 | if (swf0_ready_flag_f2 == true) | |
492 | { |
|
492 | { | |
493 | extractSWF2 = true; |
|
493 | extractSWF2 = true; | |
494 | // record the acquition time of the f0 snapshot to use to build the snapshot at f2 |
|
494 | // record the acquition time of the f0 snapshot to use to build the snapshot at f2 | |
495 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); |
|
495 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); | |
496 | swf0_ready_flag_f2 = false; |
|
496 | swf0_ready_flag_f2 = false; | |
497 | } |
|
497 | } | |
498 | } |
|
498 | } | |
499 | } |
|
499 | } | |
500 | } |
|
500 | } | |
501 |
|
501 | |||
502 | rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1 |
|
502 | rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1 | |
503 | { |
|
503 | { | |
504 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1. |
|
504 | /** This RTEMS task is dedicated to the transmission of continuous waveforms at f1. | |
505 | * |
|
505 | * | |
506 | * @param unused is the starting argument of the RTEMS task |
|
506 | * @param unused is the starting argument of the RTEMS task | |
507 | * |
|
507 | * | |
508 | * The following data packet is sent by this function: |
|
508 | * The following data packet is sent by this function: | |
509 | * - TM_LFR_SCIENCE_SBM1_CWF_F1 |
|
509 | * - TM_LFR_SCIENCE_SBM1_CWF_F1 | |
510 | * |
|
510 | * | |
511 | */ |
|
511 | */ | |
512 |
|
512 | |||
513 | rtems_event_set event_out; |
|
513 | rtems_event_set event_out; | |
514 | rtems_id queue_id; |
|
514 | rtems_id queue_id; | |
515 | rtems_status_code status; |
|
515 | rtems_status_code status; | |
516 |
|
516 | |||
517 | ring_node *ring_node_to_send_cwf; |
|
517 | ring_node *ring_node_to_send_cwf; | |
518 |
|
518 | |||
519 | status = get_message_queue_id_send( &queue_id ); |
|
519 | status = get_message_queue_id_send( &queue_id ); | |
520 | if (status != RTEMS_SUCCESSFUL) |
|
520 | if (status != RTEMS_SUCCESSFUL) | |
521 | { |
|
521 | { | |
522 | PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status) |
|
522 | PRINTF1("in CWF1 *** ERR get_message_queue_id_send %d\n", status) | |
523 | } |
|
523 | } | |
524 |
|
524 | |||
525 | BOOT_PRINTF("in CWF1 ***\n"); |
|
525 | BOOT_PRINTF("in CWF1 ***\n"); | |
526 |
|
526 | |||
527 | while(1){ |
|
527 | while(1){ | |
528 | // wait for an RTEMS_EVENT |
|
528 | // wait for an RTEMS_EVENT | |
529 | rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2, |
|
529 | rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2, | |
530 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
530 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
531 | ring_node_to_send_cwf = getRingNodeToSendCWF( 1 ); |
|
531 | ring_node_to_send_cwf = getRingNodeToSendCWF( 1 ); | |
532 | ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1; |
|
532 | ring_node_to_send_cwf_f1->sid = SID_SBM1_CWF_F1; | |
533 | if (lfrCurrentMode == LFR_MODE_SBM1) |
|
533 | if (lfrCurrentMode == LFR_MODE_SBM1) | |
534 | { |
|
534 | { | |
535 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); |
|
535 | status = rtems_message_queue_send( queue_id, &ring_node_to_send_cwf, sizeof( ring_node* ) ); | |
536 | if (status != 0) |
|
536 | if (status != 0) | |
537 | { |
|
537 | { | |
538 | PRINTF("cwf sending failed\n") |
|
538 | PRINTF("cwf sending failed\n") | |
539 | } |
|
539 | } | |
540 | } |
|
540 | } | |
541 | // launch snapshot extraction if needed |
|
541 | // launch snapshot extraction if needed | |
542 | if (extractSWF1 == true) |
|
542 | if (extractSWF1 == true) | |
543 | { |
|
543 | { | |
544 | ring_node_to_send_swf_f1 = ring_node_to_send_cwf; |
|
544 | ring_node_to_send_swf_f1 = ring_node_to_send_cwf; | |
545 | // launch the snapshot extraction |
|
545 | // launch the snapshot extraction | |
546 | status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_NORM_S1_S2 ); |
|
546 | status = rtems_event_send( Task_id[TASKID_SWBD], RTEMS_EVENT_MODE_NORM_S1_S2 ); | |
547 | extractSWF1 = false; |
|
547 | extractSWF1 = false; | |
548 | } |
|
548 | } | |
549 | if (swf0_ready_flag_f1 == true) |
|
549 | if (swf0_ready_flag_f1 == true) | |
550 | { |
|
550 | { | |
551 | extractSWF1 = true; |
|
551 | extractSWF1 = true; | |
552 | swf0_ready_flag_f1 = false; // this step shall be executed only one time |
|
552 | swf0_ready_flag_f1 = false; // this step shall be executed only one time | |
553 | } |
|
553 | } | |
554 | if ((swf1_ready == true) && (swf2_ready == true)) // swf_f1 is ready after the extraction |
|
554 | if ((swf1_ready == true) && (swf2_ready == true)) // swf_f1 is ready after the extraction | |
555 | { |
|
555 | { | |
556 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ); |
|
556 | status = rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ); | |
557 | swf1_ready = false; |
|
557 | swf1_ready = false; | |
558 | swf2_ready = false; |
|
558 | swf2_ready = false; | |
559 | } |
|
559 | } | |
560 | } |
|
560 | } | |
561 | } |
|
561 | } | |
562 |
|
562 | |||
563 | rtems_task swbd_task(rtems_task_argument argument) |
|
563 | rtems_task swbd_task(rtems_task_argument argument) | |
564 | { |
|
564 | { | |
565 | /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers. |
|
565 | /** This RTEMS task is dedicated to the building of snapshots from different continuous waveforms buffers. | |
566 | * |
|
566 | * | |
567 | * @param unused is the starting argument of the RTEMS task |
|
567 | * @param unused is the starting argument of the RTEMS task | |
568 | * |
|
568 | * | |
569 | */ |
|
569 | */ | |
570 |
|
570 | |||
571 | rtems_event_set event_out; |
|
571 | rtems_event_set event_out; | |
572 | unsigned long long int acquisitionTimeF0_asLong; |
|
572 | unsigned long long int acquisitionTimeF0_asLong; | |
573 |
|
573 | |||
574 | acquisitionTimeF0_asLong = 0x00; |
|
574 | acquisitionTimeF0_asLong = 0x00; | |
575 |
|
575 | |||
576 | BOOT_PRINTF("in SWBD ***\n") |
|
576 | BOOT_PRINTF("in SWBD ***\n") | |
577 |
|
577 | |||
578 | while(1){ |
|
578 | while(1){ | |
579 | // wait for an RTEMS_EVENT |
|
579 | // wait for an RTEMS_EVENT | |
580 | rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2, |
|
580 | rtems_event_receive( RTEMS_EVENT_MODE_NORM_S1_S2, | |
581 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); |
|
581 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); | |
582 | if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2) |
|
582 | if (event_out == RTEMS_EVENT_MODE_NORM_S1_S2) | |
583 | { |
|
583 | { | |
584 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); |
|
584 | acquisitionTimeF0_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send_swf_f0->coarseTime ); | |
585 | build_snapshot_from_ring( ring_node_to_send_swf_f1, 1, acquisitionTimeF0_asLong, |
|
585 | build_snapshot_from_ring( ring_node_to_send_swf_f1, 1, acquisitionTimeF0_asLong, | |
586 | &ring_node_swf1_extracted, swf1_extracted ); |
|
586 | &ring_node_swf1_extracted, swf1_extracted ); | |
587 | swf1_ready = true; // the snapshot has been extracted and is ready to be sent |
|
587 | swf1_ready = true; // the snapshot has been extracted and is ready to be sent | |
588 | } |
|
588 | } | |
589 | else |
|
589 | else | |
590 | { |
|
590 | { | |
591 | PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out) |
|
591 | PRINTF1("in SWBD *** unexpected rtems event received %x\n", (int) event_out) | |
592 | } |
|
592 | } | |
593 | } |
|
593 | } | |
594 | } |
|
594 | } | |
595 |
|
595 | |||
596 | //****************** |
|
596 | //****************** | |
597 | // general functions |
|
597 | // general functions | |
598 |
|
598 | |||
599 | void WFP_init_rings( void ) |
|
599 | void WFP_init_rings( void ) | |
600 | { |
|
600 | { | |
601 | // F0 RING |
|
601 | // F0 RING | |
602 | init_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_buffer_f0, WFRM_BUFFER ); |
|
602 | init_ring( waveform_ring_f0, NB_RING_NODES_F0, wf_buffer_f0, WFRM_BUFFER ); | |
603 | // F1 RING |
|
603 | // F1 RING | |
604 | init_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_buffer_f1, WFRM_BUFFER ); |
|
604 | init_ring( waveform_ring_f1, NB_RING_NODES_F1, wf_buffer_f1, WFRM_BUFFER ); | |
605 | // F2 RING |
|
605 | // F2 RING | |
606 | init_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_buffer_f2, WFRM_BUFFER ); |
|
606 | init_ring( waveform_ring_f2, NB_RING_NODES_F2, wf_buffer_f2, WFRM_BUFFER ); | |
607 | // F3 RING |
|
607 | // F3 RING | |
608 | init_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_buffer_f3, WFRM_BUFFER ); |
|
608 | init_ring( waveform_ring_f3, NB_RING_NODES_F3, wf_buffer_f3, WFRM_BUFFER ); | |
609 |
|
609 | |||
610 | ring_node_swf1_extracted.buffer_address = (int) swf1_extracted; |
|
610 | ring_node_swf1_extracted.buffer_address = (int) swf1_extracted; | |
611 | ring_node_swf2_extracted.buffer_address = (int) swf2_extracted; |
|
611 | ring_node_swf2_extracted.buffer_address = (int) swf2_extracted; | |
612 |
|
612 | |||
613 | DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0) |
|
613 | DEBUG_PRINTF1("waveform_ring_f0 @%x\n", (unsigned int) waveform_ring_f0) | |
614 | DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1) |
|
614 | DEBUG_PRINTF1("waveform_ring_f1 @%x\n", (unsigned int) waveform_ring_f1) | |
615 | DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2) |
|
615 | DEBUG_PRINTF1("waveform_ring_f2 @%x\n", (unsigned int) waveform_ring_f2) | |
616 | DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3) |
|
616 | DEBUG_PRINTF1("waveform_ring_f3 @%x\n", (unsigned int) waveform_ring_f3) | |
617 | DEBUG_PRINTF1("wf_buffer_f0 @%x\n", (unsigned int) wf_buffer_f0) |
|
617 | DEBUG_PRINTF1("wf_buffer_f0 @%x\n", (unsigned int) wf_buffer_f0) | |
618 | DEBUG_PRINTF1("wf_buffer_f1 @%x\n", (unsigned int) wf_buffer_f1) |
|
618 | DEBUG_PRINTF1("wf_buffer_f1 @%x\n", (unsigned int) wf_buffer_f1) | |
619 | DEBUG_PRINTF1("wf_buffer_f2 @%x\n", (unsigned int) wf_buffer_f2) |
|
619 | DEBUG_PRINTF1("wf_buffer_f2 @%x\n", (unsigned int) wf_buffer_f2) | |
620 | DEBUG_PRINTF1("wf_buffer_f3 @%x\n", (unsigned int) wf_buffer_f3) |
|
620 | DEBUG_PRINTF1("wf_buffer_f3 @%x\n", (unsigned int) wf_buffer_f3) | |
621 |
|
621 | |||
622 | } |
|
622 | } | |
623 |
|
623 | |||
624 | void WFP_reset_current_ring_nodes( void ) |
|
624 | void WFP_reset_current_ring_nodes( void ) | |
625 | { |
|
625 | { | |
626 | current_ring_node_f0 = waveform_ring_f0[0].next; |
|
626 | current_ring_node_f0 = waveform_ring_f0[0].next; | |
627 | current_ring_node_f1 = waveform_ring_f1[0].next; |
|
627 | current_ring_node_f1 = waveform_ring_f1[0].next; | |
628 | current_ring_node_f2 = waveform_ring_f2[0].next; |
|
628 | current_ring_node_f2 = waveform_ring_f2[0].next; | |
629 | current_ring_node_f3 = waveform_ring_f3[0].next; |
|
629 | current_ring_node_f3 = waveform_ring_f3[0].next; | |
630 |
|
630 | |||
631 | ring_node_to_send_swf_f0 = waveform_ring_f0; |
|
631 | ring_node_to_send_swf_f0 = waveform_ring_f0; | |
632 | ring_node_to_send_swf_f1 = waveform_ring_f1; |
|
632 | ring_node_to_send_swf_f1 = waveform_ring_f1; | |
633 | ring_node_to_send_swf_f2 = waveform_ring_f2; |
|
633 | ring_node_to_send_swf_f2 = waveform_ring_f2; | |
634 |
|
634 | |||
635 | ring_node_to_send_cwf_f1 = waveform_ring_f1; |
|
635 | ring_node_to_send_cwf_f1 = waveform_ring_f1; | |
636 | ring_node_to_send_cwf_f2 = waveform_ring_f2; |
|
636 | ring_node_to_send_cwf_f2 = waveform_ring_f2; | |
637 | ring_node_to_send_cwf_f3 = waveform_ring_f3; |
|
637 | ring_node_to_send_cwf_f3 = waveform_ring_f3; | |
638 | } |
|
638 | } | |
639 |
|
639 | |||
640 | int send_waveform_CWF3_light( ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id ) |
|
640 | int send_waveform_CWF3_light( ring_node *ring_node_to_send, ring_node *ring_node_cwf3_light, rtems_id queue_id ) | |
641 | { |
|
641 | { | |
642 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. |
|
642 | /** This function sends CWF_F3 CCSDS packets without the b1, b2 and b3 data. | |
643 | * |
|
643 | * | |
644 | * @param waveform points to the buffer containing the data that will be send. |
|
644 | * @param waveform points to the buffer containing the data that will be send. | |
645 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. |
|
645 | * @param headerCWF points to a table of headers that have been prepared for the data transmission. | |
646 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures |
|
646 | * @param queue_id is the id of the rtems queue to which spw_ioctl_pkt_send structures will be send. The structures | |
647 | * contain information to setup the transmission of the data packets. |
|
647 | * contain information to setup the transmission of the data packets. | |
648 | * |
|
648 | * | |
649 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer |
|
649 | * By default, CWF_F3 packet are send without the b1, b2 and b3 data. This function rebuilds a data buffer | |
650 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. |
|
650 | * from the incoming data and sends it in 7 packets, 6 containing 340 blocks and 1 one containing 8 blocks. | |
651 | * |
|
651 | * | |
652 | */ |
|
652 | */ | |
653 |
|
653 | |||
654 | unsigned int i; |
|
654 | unsigned int i; | |
655 | int ret; |
|
655 | int ret; | |
656 | rtems_status_code status; |
|
656 | rtems_status_code status; | |
657 |
|
657 | |||
658 | char *sample; |
|
658 | char *sample; | |
659 | int *dataPtr; |
|
659 | int *dataPtr; | |
660 |
|
660 | |||
661 | ret = LFR_DEFAULT; |
|
661 | ret = LFR_DEFAULT; | |
662 |
|
662 | |||
663 | dataPtr = (int*) ring_node_to_send->buffer_address; |
|
663 | dataPtr = (int*) ring_node_to_send->buffer_address; | |
664 |
|
664 | |||
665 | ring_node_cwf3_light->coarseTime = ring_node_to_send->coarseTime; |
|
665 | ring_node_cwf3_light->coarseTime = ring_node_to_send->coarseTime; | |
666 | ring_node_cwf3_light->fineTime = ring_node_to_send->fineTime; |
|
666 | ring_node_cwf3_light->fineTime = ring_node_to_send->fineTime; | |
667 |
|
667 | |||
668 | //********************** |
|
668 | //********************** | |
669 | // BUILD CWF3_light DATA |
|
669 | // BUILD CWF3_light DATA | |
670 | for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) |
|
670 | for ( i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) | |
671 | { |
|
671 | { | |
672 | sample = (char*) &dataPtr[ (i * NB_WORDS_SWF_BLK) ]; |
|
672 | sample = (char*) &dataPtr[ (i * NB_WORDS_SWF_BLK) ]; | |
673 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ]; |
|
673 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) ] = sample[ 0 ]; | |
674 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ]; |
|
674 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 1 ] = sample[ 1 ]; | |
675 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ]; |
|
675 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 2 ] = sample[ 2 ]; | |
676 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ]; |
|
676 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 3 ] = sample[ 3 ]; | |
677 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ]; |
|
677 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 4 ] = sample[ 4 ]; | |
678 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ]; |
|
678 | wf_cont_f3_light[ (i * NB_BYTES_CWF3_LIGHT_BLK) + 5 ] = sample[ 5 ]; | |
679 | } |
|
679 | } | |
680 |
|
680 | |||
681 | // SEND PACKET |
|
681 | // SEND PACKET | |
682 | status = rtems_message_queue_send( queue_id, &ring_node_cwf3_light, sizeof( ring_node* ) ); |
|
682 | status = rtems_message_queue_send( queue_id, &ring_node_cwf3_light, sizeof( ring_node* ) ); | |
683 | if (status != RTEMS_SUCCESSFUL) { |
|
683 | if (status != RTEMS_SUCCESSFUL) { | |
684 | ret = LFR_DEFAULT; |
|
684 | ret = LFR_DEFAULT; | |
685 | } |
|
685 | } | |
686 |
|
686 | |||
687 | return ret; |
|
687 | return ret; | |
688 | } |
|
688 | } | |
689 |
|
689 | |||
690 | void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime, |
|
690 | void compute_acquisition_time( unsigned int coarseTime, unsigned int fineTime, | |
691 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime ) |
|
691 | unsigned int sid, unsigned char pa_lfr_pkt_nr, unsigned char * acquisitionTime ) | |
692 | { |
|
692 | { | |
693 | unsigned long long int acquisitionTimeAsLong; |
|
693 | unsigned long long int acquisitionTimeAsLong; | |
694 | unsigned char localAcquisitionTime[6]; |
|
694 | unsigned char localAcquisitionTime[6]; | |
695 | double deltaT; |
|
695 | double deltaT; | |
696 |
|
696 | |||
697 | deltaT = 0.; |
|
697 | deltaT = 0.; | |
698 |
|
698 | |||
699 | localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 24 ); |
|
699 | localAcquisitionTime[0] = (unsigned char) ( coarseTime >> 24 ); | |
700 | localAcquisitionTime[1] = (unsigned char) ( coarseTime >> 16 ); |
|
700 | localAcquisitionTime[1] = (unsigned char) ( coarseTime >> 16 ); | |
701 | localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 8 ); |
|
701 | localAcquisitionTime[2] = (unsigned char) ( coarseTime >> 8 ); | |
702 | localAcquisitionTime[3] = (unsigned char) ( coarseTime ); |
|
702 | localAcquisitionTime[3] = (unsigned char) ( coarseTime ); | |
703 | localAcquisitionTime[4] = (unsigned char) ( fineTime >> 8 ); |
|
703 | localAcquisitionTime[4] = (unsigned char) ( fineTime >> 8 ); | |
704 | localAcquisitionTime[5] = (unsigned char) ( fineTime ); |
|
704 | localAcquisitionTime[5] = (unsigned char) ( fineTime ); | |
705 |
|
705 | |||
706 | acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 ) |
|
706 | acquisitionTimeAsLong = ( (unsigned long long int) localAcquisitionTime[0] << 40 ) | |
707 | + ( (unsigned long long int) localAcquisitionTime[1] << 32 ) |
|
707 | + ( (unsigned long long int) localAcquisitionTime[1] << 32 ) | |
708 | + ( (unsigned long long int) localAcquisitionTime[2] << 24 ) |
|
708 | + ( (unsigned long long int) localAcquisitionTime[2] << 24 ) | |
709 | + ( (unsigned long long int) localAcquisitionTime[3] << 16 ) |
|
709 | + ( (unsigned long long int) localAcquisitionTime[3] << 16 ) | |
710 | + ( (unsigned long long int) localAcquisitionTime[4] << 8 ) |
|
710 | + ( (unsigned long long int) localAcquisitionTime[4] << 8 ) | |
711 | + ( (unsigned long long int) localAcquisitionTime[5] ); |
|
711 | + ( (unsigned long long int) localAcquisitionTime[5] ); | |
712 |
|
712 | |||
713 | switch( sid ) |
|
713 | switch( sid ) | |
714 | { |
|
714 | { | |
715 | case SID_NORM_SWF_F0: |
|
715 | case SID_NORM_SWF_F0: | |
716 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ; |
|
716 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 24576. ; | |
717 | break; |
|
717 | break; | |
718 |
|
718 | |||
719 | case SID_NORM_SWF_F1: |
|
719 | case SID_NORM_SWF_F1: | |
720 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ; |
|
720 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 4096. ; | |
721 | break; |
|
721 | break; | |
722 |
|
722 | |||
723 | case SID_NORM_SWF_F2: |
|
723 | case SID_NORM_SWF_F2: | |
724 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ; |
|
724 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_304 * 65536. / 256. ; | |
725 | break; |
|
725 | break; | |
726 |
|
726 | |||
727 | case SID_SBM1_CWF_F1: |
|
727 | case SID_SBM1_CWF_F1: | |
728 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ; |
|
728 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 4096. ; | |
729 | break; |
|
729 | break; | |
730 |
|
730 | |||
731 | case SID_SBM2_CWF_F2: |
|
731 | case SID_SBM2_CWF_F2: | |
732 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; |
|
732 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; | |
733 | break; |
|
733 | break; | |
734 |
|
734 | |||
735 | case SID_BURST_CWF_F2: |
|
735 | case SID_BURST_CWF_F2: | |
736 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; |
|
736 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 256. ; | |
737 | break; |
|
737 | break; | |
738 |
|
738 | |||
739 | case SID_NORM_CWF_F3: |
|
739 | case SID_NORM_CWF_F3: | |
740 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ; |
|
740 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF_SHORT_F3 * 65536. / 16. ; | |
741 | break; |
|
741 | break; | |
742 |
|
742 | |||
743 | case SID_NORM_CWF_LONG_F3: |
|
743 | case SID_NORM_CWF_LONG_F3: | |
744 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ; |
|
744 | deltaT = ( (double ) (pa_lfr_pkt_nr) ) * BLK_NR_CWF * 65536. / 16. ; | |
745 | break; |
|
745 | break; | |
746 |
|
746 | |||
747 | default: |
|
747 | default: | |
748 | PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d\n", sid) |
|
748 | PRINTF1("in compute_acquisition_time *** ERR unexpected sid %d\n", sid) | |
749 | deltaT = 0.; |
|
749 | deltaT = 0.; | |
750 | break; |
|
750 | break; | |
751 | } |
|
751 | } | |
752 |
|
752 | |||
753 | acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT; |
|
753 | acquisitionTimeAsLong = acquisitionTimeAsLong + (unsigned long long int) deltaT; | |
754 | // |
|
754 | // | |
755 | acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40); |
|
755 | acquisitionTime[0] = (unsigned char) (acquisitionTimeAsLong >> 40); | |
756 | acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32); |
|
756 | acquisitionTime[1] = (unsigned char) (acquisitionTimeAsLong >> 32); | |
757 | acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24); |
|
757 | acquisitionTime[2] = (unsigned char) (acquisitionTimeAsLong >> 24); | |
758 | acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16); |
|
758 | acquisitionTime[3] = (unsigned char) (acquisitionTimeAsLong >> 16); | |
759 | acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 ); |
|
759 | acquisitionTime[4] = (unsigned char) (acquisitionTimeAsLong >> 8 ); | |
760 | acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong ); |
|
760 | acquisitionTime[5] = (unsigned char) (acquisitionTimeAsLong ); | |
761 |
|
761 | |||
762 | } |
|
762 | } | |
763 |
|
763 | |||
764 | void build_snapshot_from_ring( ring_node *ring_node_to_send, |
|
764 | void build_snapshot_from_ring( ring_node *ring_node_to_send, | |
765 | unsigned char frequencyChannel, |
|
765 | unsigned char frequencyChannel, | |
766 | unsigned long long int acquisitionTimeF0_asLong, |
|
766 | unsigned long long int acquisitionTimeF0_asLong, | |
767 | ring_node *ring_node_swf_extracted, |
|
767 | ring_node *ring_node_swf_extracted, | |
768 | int *swf_extracted) |
|
768 | int *swf_extracted) | |
769 | { |
|
769 | { | |
770 | unsigned int i; |
|
770 | unsigned int i; | |
771 | unsigned long long int centerTime_asLong; |
|
771 | unsigned long long int centerTime_asLong; | |
772 | unsigned long long int acquisitionTime_asLong; |
|
772 | unsigned long long int acquisitionTime_asLong; | |
773 | unsigned long long int bufferAcquisitionTime_asLong; |
|
773 | unsigned long long int bufferAcquisitionTime_asLong; | |
774 | unsigned char *ptr1; |
|
774 | unsigned char *ptr1; | |
775 | unsigned char *ptr2; |
|
775 | unsigned char *ptr2; | |
776 | unsigned char *timeCharPtr; |
|
776 | unsigned char *timeCharPtr; | |
777 | unsigned char nb_ring_nodes; |
|
777 | unsigned char nb_ring_nodes; | |
778 | unsigned long long int frequency_asLong; |
|
778 | unsigned long long int frequency_asLong; | |
779 | unsigned long long int nbTicksPerSample_asLong; |
|
779 | unsigned long long int nbTicksPerSample_asLong; | |
780 | unsigned long long int nbSamplesPart1_asLong; |
|
780 | unsigned long long int nbSamplesPart1_asLong; | |
781 | unsigned long long int sampleOffset_asLong; |
|
781 | unsigned long long int sampleOffset_asLong; | |
782 |
|
782 | |||
783 | unsigned int deltaT_F0; |
|
783 | unsigned int deltaT_F0; | |
784 | unsigned int deltaT_F1; |
|
784 | unsigned int deltaT_F1; | |
785 | unsigned long long int deltaT_F2; |
|
785 | unsigned long long int deltaT_F2; | |
786 |
|
786 | |||
787 | deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; |
|
787 | deltaT_F0 = 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; | |
788 | deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384; |
|
788 | deltaT_F1 = 16384; // (2048. / 4096. / 2.) * 65536. = 16384; | |
789 | deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144; |
|
789 | deltaT_F2 = 262144; // (2048. / 256. / 2.) * 65536. = 262144; | |
790 | sampleOffset_asLong = 0x00; |
|
790 | sampleOffset_asLong = 0x00; | |
791 |
|
791 | |||
792 | // (1) get the f0 acquisition time => the value is passed in argument |
|
792 | // (1) get the f0 acquisition time => the value is passed in argument | |
793 |
|
793 | |||
794 | // (2) compute the central reference time |
|
794 | // (2) compute the central reference time | |
795 | centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0; |
|
795 | centerTime_asLong = acquisitionTimeF0_asLong + deltaT_F0; | |
796 |
|
796 | |||
797 | // (3) compute the acquisition time of the current snapshot |
|
797 | // (3) compute the acquisition time of the current snapshot | |
798 | switch(frequencyChannel) |
|
798 | switch(frequencyChannel) | |
799 | { |
|
799 | { | |
800 | case 1: // 1 is for F1 = 4096 Hz |
|
800 | case 1: // 1 is for F1 = 4096 Hz | |
801 | acquisitionTime_asLong = centerTime_asLong - deltaT_F1; |
|
801 | acquisitionTime_asLong = centerTime_asLong - deltaT_F1; | |
802 | nb_ring_nodes = NB_RING_NODES_F1; |
|
802 | nb_ring_nodes = NB_RING_NODES_F1; | |
803 | frequency_asLong = 4096; |
|
803 | frequency_asLong = 4096; | |
804 | nbTicksPerSample_asLong = 16; // 65536 / 4096; |
|
804 | nbTicksPerSample_asLong = 16; // 65536 / 4096; | |
805 | break; |
|
805 | break; | |
806 | case 2: // 2 is for F2 = 256 Hz |
|
806 | case 2: // 2 is for F2 = 256 Hz | |
807 | acquisitionTime_asLong = centerTime_asLong - deltaT_F2; |
|
807 | acquisitionTime_asLong = centerTime_asLong - deltaT_F2; | |
808 | nb_ring_nodes = NB_RING_NODES_F2; |
|
808 | nb_ring_nodes = NB_RING_NODES_F2; | |
809 | frequency_asLong = 256; |
|
809 | frequency_asLong = 256; | |
810 | nbTicksPerSample_asLong = 256; // 65536 / 256; |
|
810 | nbTicksPerSample_asLong = 256; // 65536 / 256; | |
811 | break; |
|
811 | break; | |
812 | default: |
|
812 | default: | |
813 | acquisitionTime_asLong = centerTime_asLong; |
|
813 | acquisitionTime_asLong = centerTime_asLong; | |
814 | frequency_asLong = 256; |
|
814 | frequency_asLong = 256; | |
815 | nbTicksPerSample_asLong = 256; |
|
815 | nbTicksPerSample_asLong = 256; | |
816 | break; |
|
816 | break; | |
817 | } |
|
817 | } | |
818 |
|
818 | |||
819 | //**************************************************************************** |
|
819 | //**************************************************************************** | |
820 | // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong |
|
820 | // (4) search the ring_node with the acquisition time <= acquisitionTime_asLong | |
821 | for (i=0; i<nb_ring_nodes; i++) |
|
821 | for (i=0; i<nb_ring_nodes; i++) | |
822 | { |
|
822 | { | |
823 | //PRINTF1("%d ... ", i); |
|
823 | //PRINTF1("%d ... ", i); | |
824 | bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send->coarseTime ); |
|
824 | bufferAcquisitionTime_asLong = get_acquisition_time( (unsigned char *) &ring_node_to_send->coarseTime ); | |
825 | if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong) |
|
825 | if (bufferAcquisitionTime_asLong <= acquisitionTime_asLong) | |
826 | { |
|
826 | { | |
827 | //PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong); |
|
827 | //PRINTF1("buffer found with acquisition time = %llx\n", bufferAcquisitionTime_asLong); | |
828 | break; |
|
828 | break; | |
829 | } |
|
829 | } | |
830 | ring_node_to_send = ring_node_to_send->previous; |
|
830 | ring_node_to_send = ring_node_to_send->previous; | |
831 | } |
|
831 | } | |
832 |
|
832 | |||
833 | // (5) compute the number of samples to take in the current buffer |
|
833 | // (5) compute the number of samples to take in the current buffer | |
834 | sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16; |
|
834 | sampleOffset_asLong = ((acquisitionTime_asLong - bufferAcquisitionTime_asLong) * frequency_asLong ) >> 16; | |
835 | nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong; |
|
835 | nbSamplesPart1_asLong = NB_SAMPLES_PER_SNAPSHOT - sampleOffset_asLong; | |
836 | //PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong); |
|
836 | //PRINTF2("sampleOffset_asLong = %lld, nbSamplesPart1_asLong = %lld\n", sampleOffset_asLong, nbSamplesPart1_asLong); | |
837 |
|
837 | |||
838 | // (6) compute the final acquisition time |
|
838 | // (6) compute the final acquisition time | |
839 | acquisitionTime_asLong = bufferAcquisitionTime_asLong + |
|
839 | acquisitionTime_asLong = bufferAcquisitionTime_asLong + | |
840 | sampleOffset_asLong * nbTicksPerSample_asLong; |
|
840 | sampleOffset_asLong * nbTicksPerSample_asLong; | |
841 |
|
841 | |||
842 | // (7) copy the acquisition time at the beginning of the extrated snapshot |
|
842 | // (7) copy the acquisition time at the beginning of the extrated snapshot | |
843 | ptr1 = (unsigned char*) &acquisitionTime_asLong; |
|
843 | ptr1 = (unsigned char*) &acquisitionTime_asLong; | |
844 | // fine time |
|
844 | // fine time | |
845 | ptr2 = (unsigned char*) &ring_node_swf_extracted->fineTime; |
|
845 | ptr2 = (unsigned char*) &ring_node_swf_extracted->fineTime; | |
846 | ptr2[2] = ptr1[ 4 + 2 ]; |
|
846 | ptr2[2] = ptr1[ 4 + 2 ]; | |
847 | ptr2[3] = ptr1[ 5 + 2 ]; |
|
847 | ptr2[3] = ptr1[ 5 + 2 ]; | |
848 | // coarse time |
|
848 | // coarse time | |
849 | ptr2 = (unsigned char*) &ring_node_swf_extracted->coarseTime; |
|
849 | ptr2 = (unsigned char*) &ring_node_swf_extracted->coarseTime; | |
850 | ptr2[0] = ptr1[ 0 + 2 ]; |
|
850 | ptr2[0] = ptr1[ 0 + 2 ]; | |
851 | ptr2[1] = ptr1[ 1 + 2 ]; |
|
851 | ptr2[1] = ptr1[ 1 + 2 ]; | |
852 | ptr2[2] = ptr1[ 2 + 2 ]; |
|
852 | ptr2[2] = ptr1[ 2 + 2 ]; | |
853 | ptr2[3] = ptr1[ 3 + 2 ]; |
|
853 | ptr2[3] = ptr1[ 3 + 2 ]; | |
854 |
|
854 | |||
855 | // re set the synchronization bit |
|
855 | // re set the synchronization bit | |
856 | timeCharPtr = (unsigned char*) &ring_node_to_send->coarseTime; |
|
856 | timeCharPtr = (unsigned char*) &ring_node_to_send->coarseTime; | |
857 | ptr2[0] = ptr2[0] | (timeCharPtr[0] & 0x80); // [1000 0000] |
|
857 | ptr2[0] = ptr2[0] | (timeCharPtr[0] & 0x80); // [1000 0000] | |
858 |
|
858 | |||
859 | if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) ) |
|
859 | if ( (nbSamplesPart1_asLong >= NB_SAMPLES_PER_SNAPSHOT) | (nbSamplesPart1_asLong < 0) ) | |
860 | { |
|
860 | { | |
861 | nbSamplesPart1_asLong = 0; |
|
861 | nbSamplesPart1_asLong = 0; | |
862 | } |
|
862 | } | |
863 | // copy the part 1 of the snapshot in the extracted buffer |
|
863 | // copy the part 1 of the snapshot in the extracted buffer | |
864 | for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ ) |
|
864 | for ( i = 0; i < (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i++ ) | |
865 | { |
|
865 | { | |
866 | swf_extracted[i] = |
|
866 | swf_extracted[i] = | |
867 | ((int*) ring_node_to_send->buffer_address)[ i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) ]; |
|
867 | ((int*) ring_node_to_send->buffer_address)[ i + (sampleOffset_asLong * NB_WORDS_SWF_BLK) ]; | |
868 | } |
|
868 | } | |
869 | // copy the part 2 of the snapshot in the extracted buffer |
|
869 | // copy the part 2 of the snapshot in the extracted buffer | |
870 | ring_node_to_send = ring_node_to_send->next; |
|
870 | ring_node_to_send = ring_node_to_send->next; | |
871 | for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ ) |
|
871 | for ( i = (nbSamplesPart1_asLong * NB_WORDS_SWF_BLK); i < (NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK); i++ ) | |
872 | { |
|
872 | { | |
873 | swf_extracted[i] = |
|
873 | swf_extracted[i] = | |
874 | ((int*) ring_node_to_send->buffer_address)[ (i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) ]; |
|
874 | ((int*) ring_node_to_send->buffer_address)[ (i-(nbSamplesPart1_asLong * NB_WORDS_SWF_BLK)) ]; | |
875 | } |
|
875 | } | |
876 | } |
|
876 | } | |
877 |
|
877 | |||
878 | double computeCorrection( unsigned char *timePtr ) |
|
878 | double computeCorrection( unsigned char *timePtr ) | |
879 | { |
|
879 | { | |
880 | unsigned long long int acquisitionTime; |
|
880 | unsigned long long int acquisitionTime; | |
881 | unsigned long long int centerTime; |
|
881 | unsigned long long int centerTime; | |
882 | unsigned long long int previousTick; |
|
882 | unsigned long long int previousTick; | |
883 | unsigned long long int nextTick; |
|
883 | unsigned long long int nextTick; | |
884 | unsigned long long int deltaPreviousTick; |
|
884 | unsigned long long int deltaPreviousTick; | |
885 | unsigned long long int deltaNextTick; |
|
885 | unsigned long long int deltaNextTick; | |
886 | double deltaPrevious_ms; |
|
886 | double deltaPrevious_ms; | |
887 | double deltaNext_ms; |
|
887 | double deltaNext_ms; | |
888 | double correctionInF2; |
|
888 | double correctionInF2; | |
889 |
|
889 | |||
890 | // get acquisition time in fine time ticks |
|
890 | // get acquisition time in fine time ticks | |
891 | acquisitionTime = get_acquisition_time( timePtr ); |
|
891 | acquisitionTime = get_acquisition_time( timePtr ); | |
892 |
|
892 | |||
893 | // compute center time |
|
893 | // compute center time | |
894 | centerTime = acquisitionTime + 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; |
|
894 | centerTime = acquisitionTime + 2731; // (2048. / 24576. / 2.) * 65536. = 2730.667; | |
895 | previousTick = centerTime - (centerTime & 0xffff); |
|
895 | previousTick = centerTime - (centerTime & 0xffff); | |
896 | nextTick = previousTick + 65536; |
|
896 | nextTick = previousTick + 65536; | |
897 |
|
897 | |||
898 | deltaPreviousTick = centerTime - previousTick; |
|
898 | deltaPreviousTick = centerTime - previousTick; | |
899 | deltaNextTick = nextTick - centerTime; |
|
899 | deltaNextTick = nextTick - centerTime; | |
900 |
|
900 | |||
901 | deltaPrevious_ms = ((double) deltaPreviousTick) / 65536. * 1000.; |
|
901 | deltaPrevious_ms = ((double) deltaPreviousTick) / 65536. * 1000.; | |
902 | deltaNext_ms = ((double) deltaNextTick) / 65536. * 1000.; |
|
902 | deltaNext_ms = ((double) deltaNextTick) / 65536. * 1000.; | |
903 |
|
903 | |||
904 | PRINTF2(" delta previous = %.3f ms, delta next = %.2f ms\n", deltaPrevious_ms, deltaNext_ms); |
|
904 | PRINTF2(" delta previous = %.3f ms, delta next = %.2f ms\n", deltaPrevious_ms, deltaNext_ms); | |
905 |
|
905 | |||
906 | // which tick is the closest? |
|
906 | // which tick is the closest? | |
907 | if (deltaPreviousTick > deltaNextTick) |
|
907 | if (deltaPreviousTick > deltaNextTick) | |
908 | { |
|
908 | { | |
909 | // the snapshot center is just before the second => increase delta_snapshot |
|
909 | // the snapshot center is just before the second => increase delta_snapshot | |
910 | correctionInF2 = + (deltaNext_ms * 256. / 1000. ); |
|
910 | correctionInF2 = + (deltaNext_ms * 256. / 1000. ); | |
911 | } |
|
911 | } | |
912 | else |
|
912 | else | |
913 | { |
|
913 | { | |
914 | // the snapshot center is just after the second => decrease delta_snapshot |
|
914 | // the snapshot center is just after the second => decrease delta_snapshot | |
915 | correctionInF2 = - (deltaPrevious_ms * 256. / 1000. ); |
|
915 | correctionInF2 = - (deltaPrevious_ms * 256. / 1000. ); | |
916 | } |
|
916 | } | |
917 |
|
917 | |||
918 | PRINTF1(" correctionInF2 = %.2f\n", correctionInF2); |
|
918 | PRINTF1(" correctionInF2 = %.2f\n", correctionInF2); | |
919 |
|
919 | |||
920 | return correctionInF2; |
|
920 | return correctionInF2; | |
921 | } |
|
921 | } | |
922 |
|
922 | |||
923 | void applyCorrection( double correction ) |
|
923 | void applyCorrection( double correction ) | |
924 | { |
|
924 | { | |
925 | int correctionInt; |
|
925 | int correctionInt; | |
926 |
|
926 | |||
927 | if (correction >= 0.) |
|
927 | if (correction >= 0.) | |
928 | { |
|
928 | { | |
929 | if ( (1. > correction) && (correction > 0.5) ) |
|
929 | if ( (1. > correction) && (correction > 0.5) ) | |
930 | { |
|
930 | { | |
931 | correctionInt = 1; |
|
931 | correctionInt = 1; | |
932 | } |
|
932 | } | |
933 | else |
|
933 | else | |
934 | { |
|
934 | { | |
935 | correctionInt = 2 * floor(correction); |
|
935 | correctionInt = 2 * floor(correction); | |
936 | } |
|
936 | } | |
937 | } |
|
937 | } | |
938 | else |
|
938 | else | |
939 | { |
|
939 | { | |
940 |
if ( ( |
|
940 | if ( (-1. < correction) && (correction < -0.5) ) | |
941 | { |
|
941 | { | |
942 | correctionInt = -1; |
|
942 | correctionInt = -1; | |
943 | } |
|
943 | } | |
944 | else |
|
944 | else | |
945 | { |
|
945 | { | |
946 | correctionInt = 2 * ceil(correction); |
|
946 | correctionInt = 2 * ceil(correction); | |
947 | } |
|
947 | } | |
948 | } |
|
948 | } | |
949 | waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + correctionInt; |
|
949 | waveform_picker_regs->delta_snapshot = waveform_picker_regs->delta_snapshot + correctionInt; | |
950 | } |
|
950 | } | |
951 |
|
951 | |||
952 | void snapshot_resynchronization( unsigned char *timePtr ) |
|
952 | void snapshot_resynchronization( unsigned char *timePtr ) | |
953 | { |
|
953 | { | |
954 | /** This function compute a correction to apply on delta_snapshot. |
|
954 | /** This function compute a correction to apply on delta_snapshot. | |
955 | * |
|
955 | * | |
956 | * |
|
956 | * | |
957 | * @param timePtr is a pointer to the acquisition time of the snapshot being considered. |
|
957 | * @param timePtr is a pointer to the acquisition time of the snapshot being considered. | |
958 | * |
|
958 | * | |
959 | * @return void |
|
959 | * @return void | |
960 | * |
|
960 | * | |
961 | */ |
|
961 | */ | |
962 |
|
962 | |||
963 | static double correction = 0.; |
|
963 | static double correction = 0.; | |
964 | static resynchro_state state = MEASURE; |
|
964 | static resynchro_state state = MEASURE; | |
965 | static unsigned int nbSnapshots = 0; |
|
965 | static unsigned int nbSnapshots = 0; | |
966 |
|
966 | |||
967 | int correctionInt; |
|
967 | int correctionInt; | |
968 |
|
968 | |||
969 | correctionInt = 0; |
|
969 | correctionInt = 0; | |
970 |
|
970 | |||
971 | switch (state) |
|
971 | switch (state) | |
972 | { |
|
972 | { | |
973 |
|
973 | |||
974 | case MEASURE: |
|
974 | case MEASURE: | |
975 | // ******** |
|
975 | // ******** | |
976 | PRINTF1("MEASURE === %d\n", nbSnapshots); |
|
976 | PRINTF1("MEASURE === %d\n", nbSnapshots); | |
977 | state = CORRECTION; |
|
977 | state = CORRECTION; | |
978 | correction = computeCorrection( timePtr ); |
|
978 | correction = computeCorrection( timePtr ); | |
979 | PRINTF1("MEASURE === correction = %.2f\n", correction ); |
|
979 | PRINTF1("MEASURE === correction = %.2f\n", correction ); | |
980 | applyCorrection( correction ); |
|
980 | applyCorrection( correction ); | |
981 | PRINTF1("MEASURE === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot); |
|
981 | PRINTF1("MEASURE === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot); | |
982 | //**** |
|
982 | //**** | |
983 | break; |
|
983 | break; | |
984 |
|
984 | |||
985 | case CORRECTION: |
|
985 | case CORRECTION: | |
986 | //************ |
|
986 | //************ | |
987 | PRINTF1("CORRECTION === %d\n", nbSnapshots); |
|
987 | PRINTF1("CORRECTION === %d\n", nbSnapshots); | |
988 | state = MEASURE; |
|
988 | state = MEASURE; | |
989 | computeCorrection( timePtr ); |
|
989 | computeCorrection( timePtr ); | |
990 | set_wfp_delta_snapshot(); |
|
990 | set_wfp_delta_snapshot(); | |
991 | PRINTF1("CORRECTION === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot); |
|
991 | PRINTF1("CORRECTION === delta_snapshot = %d\n", waveform_picker_regs->delta_snapshot); | |
992 | //**** |
|
992 | //**** | |
993 | break; |
|
993 | break; | |
994 |
|
994 | |||
995 | default: |
|
995 | default: | |
996 | break; |
|
996 | break; | |
997 |
|
997 | |||
998 | } |
|
998 | } | |
999 |
|
999 | |||
1000 | nbSnapshots++; |
|
1000 | nbSnapshots++; | |
1001 | } |
|
1001 | } | |
1002 |
|
1002 | |||
1003 | //************** |
|
1003 | //************** | |
1004 | // wfp registers |
|
1004 | // wfp registers | |
1005 | void reset_wfp_burst_enable( void ) |
|
1005 | void reset_wfp_burst_enable( void ) | |
1006 | { |
|
1006 | { | |
1007 | /** This function resets the waveform picker burst_enable register. |
|
1007 | /** This function resets the waveform picker burst_enable register. | |
1008 | * |
|
1008 | * | |
1009 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. |
|
1009 | * The burst bits [f2 f1 f0] and the enable bits [f3 f2 f1 f0] are set to 0. | |
1010 | * |
|
1010 | * | |
1011 | */ |
|
1011 | */ | |
1012 |
|
1012 | |||
1013 | // [1000 000] burst f2, f1, f0 enable f3, f2, f1, f0 |
|
1013 | // [1000 000] burst f2, f1, f0 enable f3, f2, f1, f0 | |
1014 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable & 0x80; |
|
1014 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable & 0x80; | |
1015 | } |
|
1015 | } | |
1016 |
|
1016 | |||
1017 | void reset_wfp_status( void ) |
|
1017 | void reset_wfp_status( void ) | |
1018 | { |
|
1018 | { | |
1019 | /** This function resets the waveform picker status register. |
|
1019 | /** This function resets the waveform picker status register. | |
1020 | * |
|
1020 | * | |
1021 | * All status bits are set to 0 [new_err full_err full]. |
|
1021 | * All status bits are set to 0 [new_err full_err full]. | |
1022 | * |
|
1022 | * | |
1023 | */ |
|
1023 | */ | |
1024 |
|
1024 | |||
1025 | waveform_picker_regs->status = 0xffff; |
|
1025 | waveform_picker_regs->status = 0xffff; | |
1026 | } |
|
1026 | } | |
1027 |
|
1027 | |||
1028 | void reset_wfp_buffer_addresses( void ) |
|
1028 | void reset_wfp_buffer_addresses( void ) | |
1029 | { |
|
1029 | { | |
1030 | // F0 |
|
1030 | // F0 | |
1031 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->previous->buffer_address; // 0x08 |
|
1031 | waveform_picker_regs->addr_data_f0_0 = current_ring_node_f0->previous->buffer_address; // 0x08 | |
1032 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c |
|
1032 | waveform_picker_regs->addr_data_f0_1 = current_ring_node_f0->buffer_address; // 0x0c | |
1033 | // F1 |
|
1033 | // F1 | |
1034 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->previous->buffer_address; // 0x10 |
|
1034 | waveform_picker_regs->addr_data_f1_0 = current_ring_node_f1->previous->buffer_address; // 0x10 | |
1035 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14 |
|
1035 | waveform_picker_regs->addr_data_f1_1 = current_ring_node_f1->buffer_address; // 0x14 | |
1036 | // F2 |
|
1036 | // F2 | |
1037 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->previous->buffer_address; // 0x18 |
|
1037 | waveform_picker_regs->addr_data_f2_0 = current_ring_node_f2->previous->buffer_address; // 0x18 | |
1038 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c |
|
1038 | waveform_picker_regs->addr_data_f2_1 = current_ring_node_f2->buffer_address; // 0x1c | |
1039 | // F3 |
|
1039 | // F3 | |
1040 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->previous->buffer_address; // 0x20 |
|
1040 | waveform_picker_regs->addr_data_f3_0 = current_ring_node_f3->previous->buffer_address; // 0x20 | |
1041 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24 |
|
1041 | waveform_picker_regs->addr_data_f3_1 = current_ring_node_f3->buffer_address; // 0x24 | |
1042 | } |
|
1042 | } | |
1043 |
|
1043 | |||
1044 | void reset_waveform_picker_regs( void ) |
|
1044 | void reset_waveform_picker_regs( void ) | |
1045 | { |
|
1045 | { | |
1046 | /** This function resets the waveform picker module registers. |
|
1046 | /** This function resets the waveform picker module registers. | |
1047 | * |
|
1047 | * | |
1048 | * The registers affected by this function are located at the following offset addresses: |
|
1048 | * The registers affected by this function are located at the following offset addresses: | |
1049 | * - 0x00 data_shaping |
|
1049 | * - 0x00 data_shaping | |
1050 | * - 0x04 run_burst_enable |
|
1050 | * - 0x04 run_burst_enable | |
1051 | * - 0x08 addr_data_f0 |
|
1051 | * - 0x08 addr_data_f0 | |
1052 | * - 0x0C addr_data_f1 |
|
1052 | * - 0x0C addr_data_f1 | |
1053 | * - 0x10 addr_data_f2 |
|
1053 | * - 0x10 addr_data_f2 | |
1054 | * - 0x14 addr_data_f3 |
|
1054 | * - 0x14 addr_data_f3 | |
1055 | * - 0x18 status |
|
1055 | * - 0x18 status | |
1056 | * - 0x1C delta_snapshot |
|
1056 | * - 0x1C delta_snapshot | |
1057 | * - 0x20 delta_f0 |
|
1057 | * - 0x20 delta_f0 | |
1058 | * - 0x24 delta_f0_2 |
|
1058 | * - 0x24 delta_f0_2 | |
1059 | * - 0x28 delta_f1 (obsolet parameter) |
|
1059 | * - 0x28 delta_f1 (obsolet parameter) | |
1060 | * - 0x2c delta_f2 |
|
1060 | * - 0x2c delta_f2 | |
1061 | * - 0x30 nb_data_by_buffer |
|
1061 | * - 0x30 nb_data_by_buffer | |
1062 | * - 0x34 nb_snapshot_param |
|
1062 | * - 0x34 nb_snapshot_param | |
1063 | * - 0x38 start_date |
|
1063 | * - 0x38 start_date | |
1064 | * - 0x3c nb_word_in_buffer |
|
1064 | * - 0x3c nb_word_in_buffer | |
1065 | * |
|
1065 | * | |
1066 | */ |
|
1066 | */ | |
1067 |
|
1067 | |||
1068 | set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW |
|
1068 | set_wfp_data_shaping(); // 0x00 *** R1 R0 SP1 SP0 BW | |
1069 |
|
1069 | |||
1070 | reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ] |
|
1070 | reset_wfp_burst_enable(); // 0x04 *** [run *** burst f2, f1, f0 *** enable f3, f2, f1, f0 ] | |
1071 |
|
1071 | |||
1072 | reset_wfp_buffer_addresses(); |
|
1072 | reset_wfp_buffer_addresses(); | |
1073 |
|
1073 | |||
1074 | reset_wfp_status(); // 0x18 |
|
1074 | reset_wfp_status(); // 0x18 | |
1075 |
|
1075 | |||
1076 | set_wfp_delta_snapshot(); // 0x1c *** 300 s => 0x12bff |
|
1076 | set_wfp_delta_snapshot(); // 0x1c *** 300 s => 0x12bff | |
1077 |
|
1077 | |||
1078 | set_wfp_delta_f0_f0_2(); // 0x20, 0x24 |
|
1078 | set_wfp_delta_f0_f0_2(); // 0x20, 0x24 | |
1079 |
|
1079 | |||
1080 | //the parameter delta_f1 [0x28] is not used anymore |
|
1080 | //the parameter delta_f1 [0x28] is not used anymore | |
1081 |
|
1081 | |||
1082 | set_wfp_delta_f2(); // 0x2c |
|
1082 | set_wfp_delta_f2(); // 0x2c | |
1083 |
|
1083 | |||
1084 | DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot); |
|
1084 | DEBUG_PRINTF1("delta_snapshot %x\n", waveform_picker_regs->delta_snapshot); | |
1085 | DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0); |
|
1085 | DEBUG_PRINTF1("delta_f0 %x\n", waveform_picker_regs->delta_f0); | |
1086 | DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2); |
|
1086 | DEBUG_PRINTF1("delta_f0_2 %x\n", waveform_picker_regs->delta_f0_2); | |
1087 | DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1); |
|
1087 | DEBUG_PRINTF1("delta_f1 %x\n", waveform_picker_regs->delta_f1); | |
1088 | DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2); |
|
1088 | DEBUG_PRINTF1("delta_f2 %x\n", waveform_picker_regs->delta_f2); | |
1089 | // 2688 = 8 * 336 |
|
1089 | // 2688 = 8 * 336 | |
1090 | waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1 |
|
1090 | waveform_picker_regs->nb_data_by_buffer = 0xa7f; // 0x30 *** 2688 - 1 => nb samples -1 | |
1091 | waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples |
|
1091 | waveform_picker_regs->snapshot_param = 0xa80; // 0x34 *** 2688 => nb samples | |
1092 | waveform_picker_regs->start_date = 0x7fffffff; // 0x38 |
|
1092 | waveform_picker_regs->start_date = 0x7fffffff; // 0x38 | |
1093 | // |
|
1093 | // | |
1094 | // coarse time and fine time registers are not initialized, they are volatile |
|
1094 | // coarse time and fine time registers are not initialized, they are volatile | |
1095 | // |
|
1095 | // | |
1096 | waveform_picker_regs->buffer_length = 0x1f8;// buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8 |
|
1096 | waveform_picker_regs->buffer_length = 0x1f8;// buffer length in burst = 3 * 2688 / 16 = 504 = 0x1f8 | |
1097 | } |
|
1097 | } | |
1098 |
|
1098 | |||
1099 | void set_wfp_data_shaping( void ) |
|
1099 | void set_wfp_data_shaping( void ) | |
1100 | { |
|
1100 | { | |
1101 | /** This function sets the data_shaping register of the waveform picker module. |
|
1101 | /** This function sets the data_shaping register of the waveform picker module. | |
1102 | * |
|
1102 | * | |
1103 | * The value is read from one field of the parameter_dump_packet structure:\n |
|
1103 | * The value is read from one field of the parameter_dump_packet structure:\n | |
1104 | * bw_sp0_sp1_r0_r1 |
|
1104 | * bw_sp0_sp1_r0_r1 | |
1105 | * |
|
1105 | * | |
1106 | */ |
|
1106 | */ | |
1107 |
|
1107 | |||
1108 | unsigned char data_shaping; |
|
1108 | unsigned char data_shaping; | |
1109 |
|
1109 | |||
1110 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register |
|
1110 | // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register | |
1111 | // waveform picker : [R1 R0 SP1 SP0 BW] |
|
1111 | // waveform picker : [R1 R0 SP1 SP0 BW] | |
1112 |
|
1112 | |||
1113 | data_shaping = parameter_dump_packet.sy_lfr_common_parameters; |
|
1113 | data_shaping = parameter_dump_packet.sy_lfr_common_parameters; | |
1114 |
|
1114 | |||
1115 | waveform_picker_regs->data_shaping = |
|
1115 | waveform_picker_regs->data_shaping = | |
1116 | ( (data_shaping & 0x20) >> 5 ) // BW |
|
1116 | ( (data_shaping & 0x20) >> 5 ) // BW | |
1117 | + ( (data_shaping & 0x10) >> 3 ) // SP0 |
|
1117 | + ( (data_shaping & 0x10) >> 3 ) // SP0 | |
1118 | + ( (data_shaping & 0x08) >> 1 ) // SP1 |
|
1118 | + ( (data_shaping & 0x08) >> 1 ) // SP1 | |
1119 | + ( (data_shaping & 0x04) << 1 ) // R0 |
|
1119 | + ( (data_shaping & 0x04) << 1 ) // R0 | |
1120 | + ( (data_shaping & 0x02) << 3 ) // R1 |
|
1120 | + ( (data_shaping & 0x02) << 3 ) // R1 | |
1121 | + ( (data_shaping & 0x01) << 5 ); // R2 |
|
1121 | + ( (data_shaping & 0x01) << 5 ); // R2 | |
1122 | } |
|
1122 | } | |
1123 |
|
1123 | |||
1124 | void set_wfp_burst_enable_register( unsigned char mode ) |
|
1124 | void set_wfp_burst_enable_register( unsigned char mode ) | |
1125 | { |
|
1125 | { | |
1126 | /** This function sets the waveform picker burst_enable register depending on the mode. |
|
1126 | /** This function sets the waveform picker burst_enable register depending on the mode. | |
1127 | * |
|
1127 | * | |
1128 | * @param mode is the LFR mode to launch. |
|
1128 | * @param mode is the LFR mode to launch. | |
1129 | * |
|
1129 | * | |
1130 | * The burst bits shall be before the enable bits. |
|
1130 | * The burst bits shall be before the enable bits. | |
1131 | * |
|
1131 | * | |
1132 | */ |
|
1132 | */ | |
1133 |
|
1133 | |||
1134 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 |
|
1134 | // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0 | |
1135 | // the burst bits shall be set first, before the enable bits |
|
1135 | // the burst bits shall be set first, before the enable bits | |
1136 | switch(mode) { |
|
1136 | switch(mode) { | |
1137 | case LFR_MODE_NORMAL: |
|
1137 | case LFR_MODE_NORMAL: | |
1138 | case LFR_MODE_SBM1: |
|
1138 | case LFR_MODE_SBM1: | |
1139 | case LFR_MODE_SBM2: |
|
1139 | case LFR_MODE_SBM2: | |
1140 | waveform_picker_regs->run_burst_enable = 0x60; // [0110 0000] enable f2 and f1 burst |
|
1140 | waveform_picker_regs->run_burst_enable = 0x60; // [0110 0000] enable f2 and f1 burst | |
1141 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 |
|
1141 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0 | |
1142 | break; |
|
1142 | break; | |
1143 | case LFR_MODE_BURST: |
|
1143 | case LFR_MODE_BURST: | |
1144 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled |
|
1144 | waveform_picker_regs->run_burst_enable = 0x40; // [0100 0000] f2 burst enabled | |
1145 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 and f2 |
|
1145 | waveform_picker_regs->run_burst_enable = waveform_picker_regs->run_burst_enable | 0x0c; // [1100] enable f3 and f2 | |
1146 | break; |
|
1146 | break; | |
1147 | default: |
|
1147 | default: | |
1148 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled |
|
1148 | waveform_picker_regs->run_burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled | |
1149 | break; |
|
1149 | break; | |
1150 | } |
|
1150 | } | |
1151 | } |
|
1151 | } | |
1152 |
|
1152 | |||
1153 | void set_wfp_delta_snapshot( void ) |
|
1153 | void set_wfp_delta_snapshot( void ) | |
1154 | { |
|
1154 | { | |
1155 | /** This function sets the delta_snapshot register of the waveform picker module. |
|
1155 | /** This function sets the delta_snapshot register of the waveform picker module. | |
1156 | * |
|
1156 | * | |
1157 | * The value is read from two (unsigned char) of the parameter_dump_packet structure: |
|
1157 | * The value is read from two (unsigned char) of the parameter_dump_packet structure: | |
1158 | * - sy_lfr_n_swf_p[0] |
|
1158 | * - sy_lfr_n_swf_p[0] | |
1159 | * - sy_lfr_n_swf_p[1] |
|
1159 | * - sy_lfr_n_swf_p[1] | |
1160 | * |
|
1160 | * | |
1161 | */ |
|
1161 | */ | |
1162 |
|
1162 | |||
1163 | unsigned int delta_snapshot; |
|
1163 | unsigned int delta_snapshot; | |
1164 | unsigned int delta_snapshot_in_T2; |
|
1164 | unsigned int delta_snapshot_in_T2; | |
1165 |
|
1165 | |||
1166 | delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256 |
|
1166 | delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256 | |
1167 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; |
|
1167 | + parameter_dump_packet.sy_lfr_n_swf_p[1]; | |
1168 |
|
1168 | |||
1169 | delta_snapshot_in_T2 = delta_snapshot * 256; |
|
1169 | delta_snapshot_in_T2 = delta_snapshot * 256; | |
1170 | waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes |
|
1170 | waveform_picker_regs->delta_snapshot = delta_snapshot_in_T2 - 1; // max 4 bytes | |
1171 | } |
|
1171 | } | |
1172 |
|
1172 | |||
1173 | void set_wfp_delta_f0_f0_2( void ) |
|
1173 | void set_wfp_delta_f0_f0_2( void ) | |
1174 | { |
|
1174 | { | |
1175 | unsigned int delta_snapshot; |
|
1175 | unsigned int delta_snapshot; | |
1176 | unsigned int nb_samples_per_snapshot; |
|
1176 | unsigned int nb_samples_per_snapshot; | |
1177 | float delta_f0_in_float; |
|
1177 | float delta_f0_in_float; | |
1178 |
|
1178 | |||
1179 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1179 | delta_snapshot = waveform_picker_regs->delta_snapshot; | |
1180 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1180 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; | |
1181 | delta_f0_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.; |
|
1181 | delta_f0_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 24576.) * 256.; | |
1182 |
|
1182 | |||
1183 | waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float ); |
|
1183 | waveform_picker_regs->delta_f0 = delta_snapshot - floor( delta_f0_in_float ); | |
1184 | waveform_picker_regs->delta_f0_2 = 0x30; // 48 = 11 0000, max 7 bits |
|
1184 | waveform_picker_regs->delta_f0_2 = 0x30; // 48 = 11 0000, max 7 bits | |
1185 | } |
|
1185 | } | |
1186 |
|
1186 | |||
1187 | void set_wfp_delta_f1( void ) |
|
1187 | void set_wfp_delta_f1( void ) | |
1188 | { |
|
1188 | { | |
1189 | /** Sets the value of the delta_f1 parameter |
|
1189 | /** Sets the value of the delta_f1 parameter | |
1190 | * |
|
1190 | * | |
1191 | * @param void |
|
1191 | * @param void | |
1192 | * |
|
1192 | * | |
1193 | * @return void |
|
1193 | * @return void | |
1194 | * |
|
1194 | * | |
1195 | * delta_f1 is not used, the snapshots are extracted from CWF_F1 waveforms. |
|
1195 | * delta_f1 is not used, the snapshots are extracted from CWF_F1 waveforms. | |
1196 | * |
|
1196 | * | |
1197 | */ |
|
1197 | */ | |
1198 |
|
1198 | |||
1199 | unsigned int delta_snapshot; |
|
1199 | unsigned int delta_snapshot; | |
1200 | unsigned int nb_samples_per_snapshot; |
|
1200 | unsigned int nb_samples_per_snapshot; | |
1201 | float delta_f1_in_float; |
|
1201 | float delta_f1_in_float; | |
1202 |
|
1202 | |||
1203 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1203 | delta_snapshot = waveform_picker_regs->delta_snapshot; | |
1204 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1204 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; | |
1205 | delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.; |
|
1205 | delta_f1_in_float = nb_samples_per_snapshot / 2. * ( 1. / 256. - 1. / 4096.) * 256.; | |
1206 |
|
1206 | |||
1207 | waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float ); |
|
1207 | waveform_picker_regs->delta_f1 = delta_snapshot - floor( delta_f1_in_float ); | |
1208 | } |
|
1208 | } | |
1209 |
|
1209 | |||
1210 | void set_wfp_delta_f2( void ) // parameter not used, only delta_f0 and delta_f0_2 are used |
|
1210 | void set_wfp_delta_f2( void ) // parameter not used, only delta_f0 and delta_f0_2 are used | |
1211 | { |
|
1211 | { | |
1212 | /** Sets the value of the delta_f2 parameter |
|
1212 | /** Sets the value of the delta_f2 parameter | |
1213 | * |
|
1213 | * | |
1214 | * @param void |
|
1214 | * @param void | |
1215 | * |
|
1215 | * | |
1216 | * @return void |
|
1216 | * @return void | |
1217 | * |
|
1217 | * | |
1218 | * delta_f2 is used only for the first snapshot generation, even when the snapshots are extracted from CWF_F2 |
|
1218 | * delta_f2 is used only for the first snapshot generation, even when the snapshots are extracted from CWF_F2 | |
1219 | * waveforms (see lpp_waveform_snapshot_controler.vhd for details). |
|
1219 | * waveforms (see lpp_waveform_snapshot_controler.vhd for details). | |
1220 | * |
|
1220 | * | |
1221 | */ |
|
1221 | */ | |
1222 |
|
1222 | |||
1223 | unsigned int delta_snapshot; |
|
1223 | unsigned int delta_snapshot; | |
1224 | unsigned int nb_samples_per_snapshot; |
|
1224 | unsigned int nb_samples_per_snapshot; | |
1225 |
|
1225 | |||
1226 | delta_snapshot = waveform_picker_regs->delta_snapshot; |
|
1226 | delta_snapshot = waveform_picker_regs->delta_snapshot; | |
1227 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; |
|
1227 | nb_samples_per_snapshot = parameter_dump_packet.sy_lfr_n_swf_l[0] * 256 + parameter_dump_packet.sy_lfr_n_swf_l[1]; | |
1228 |
|
1228 | |||
1229 | waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2 - 1; |
|
1229 | waveform_picker_regs->delta_f2 = delta_snapshot - nb_samples_per_snapshot / 2 - 1; | |
1230 | } |
|
1230 | } | |
1231 |
|
1231 | |||
1232 | //***************** |
|
1232 | //***************** | |
1233 | // local parameters |
|
1233 | // local parameters | |
1234 |
|
1234 | |||
1235 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ) |
|
1235 | void increment_seq_counter_source_id( unsigned char *packet_sequence_control, unsigned int sid ) | |
1236 | { |
|
1236 | { | |
1237 | /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument. |
|
1237 | /** This function increments the parameter "sequence_cnt" depending on the sid passed in argument. | |
1238 | * |
|
1238 | * | |
1239 | * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update. |
|
1239 | * @param packet_sequence_control is a pointer toward the parameter sequence_cnt to update. | |
1240 | * @param sid is the source identifier of the packet being updated. |
|
1240 | * @param sid is the source identifier of the packet being updated. | |
1241 | * |
|
1241 | * | |
1242 | * REQ-LFR-SRS-5240 / SSS-CP-FS-590 |
|
1242 | * REQ-LFR-SRS-5240 / SSS-CP-FS-590 | |
1243 | * The sequence counters shall wrap around from 2^14 to zero. |
|
1243 | * The sequence counters shall wrap around from 2^14 to zero. | |
1244 | * The sequence counter shall start at zero at startup. |
|
1244 | * The sequence counter shall start at zero at startup. | |
1245 | * |
|
1245 | * | |
1246 | * REQ-LFR-SRS-5239 / SSS-CP-FS-580 |
|
1246 | * REQ-LFR-SRS-5239 / SSS-CP-FS-580 | |
1247 | * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0 |
|
1247 | * All TM_LFR_SCIENCE_ packets are sent to ground, i.e. destination id = 0 | |
1248 | * |
|
1248 | * | |
1249 | */ |
|
1249 | */ | |
1250 |
|
1250 | |||
1251 | unsigned short *sequence_cnt; |
|
1251 | unsigned short *sequence_cnt; | |
1252 | unsigned short segmentation_grouping_flag; |
|
1252 | unsigned short segmentation_grouping_flag; | |
1253 | unsigned short new_packet_sequence_control; |
|
1253 | unsigned short new_packet_sequence_control; | |
1254 | rtems_mode initial_mode_set; |
|
1254 | rtems_mode initial_mode_set; | |
1255 | rtems_mode current_mode_set; |
|
1255 | rtems_mode current_mode_set; | |
1256 | rtems_status_code status; |
|
1256 | rtems_status_code status; | |
1257 |
|
1257 | |||
1258 | //****************************************** |
|
1258 | //****************************************** | |
1259 | // CHANGE THE MODE OF THE CALLING RTEMS TASK |
|
1259 | // CHANGE THE MODE OF THE CALLING RTEMS TASK | |
1260 | status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set ); |
|
1260 | status = rtems_task_mode( RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &initial_mode_set ); | |
1261 |
|
1261 | |||
1262 | if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2) |
|
1262 | if ( (sid == SID_NORM_SWF_F0) || (sid == SID_NORM_SWF_F1) || (sid == SID_NORM_SWF_F2) | |
1263 | || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3) |
|
1263 | || (sid == SID_NORM_CWF_F3) || (sid == SID_NORM_CWF_LONG_F3) | |
1264 | || (sid == SID_BURST_CWF_F2) |
|
1264 | || (sid == SID_BURST_CWF_F2) | |
1265 | || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2) |
|
1265 | || (sid == SID_NORM_ASM_F0) || (sid == SID_NORM_ASM_F1) || (sid == SID_NORM_ASM_F2) | |
1266 | || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2) |
|
1266 | || (sid == SID_NORM_BP1_F0) || (sid == SID_NORM_BP1_F1) || (sid == SID_NORM_BP1_F2) | |
1267 | || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2) |
|
1267 | || (sid == SID_NORM_BP2_F0) || (sid == SID_NORM_BP2_F1) || (sid == SID_NORM_BP2_F2) | |
1268 | || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0) |
|
1268 | || (sid == SID_BURST_BP1_F0) || (sid == SID_BURST_BP2_F0) | |
1269 | || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) ) |
|
1269 | || (sid == SID_BURST_BP1_F1) || (sid == SID_BURST_BP2_F1) ) | |
1270 | { |
|
1270 | { | |
1271 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST; |
|
1271 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_NORMAL_BURST; | |
1272 | } |
|
1272 | } | |
1273 | else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) |
|
1273 | else if ( (sid ==SID_SBM1_CWF_F1) || (sid ==SID_SBM2_CWF_F2) | |
1274 | || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0) |
|
1274 | || (sid == SID_SBM1_BP1_F0) || (sid == SID_SBM1_BP2_F0) | |
1275 | || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0) |
|
1275 | || (sid == SID_SBM2_BP1_F0) || (sid == SID_SBM2_BP2_F0) | |
1276 | || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) ) |
|
1276 | || (sid == SID_SBM2_BP1_F1) || (sid == SID_SBM2_BP2_F1) ) | |
1277 | { |
|
1277 | { | |
1278 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2; |
|
1278 | sequence_cnt = (unsigned short *) &sequenceCounters_SCIENCE_SBM1_SBM2; | |
1279 | } |
|
1279 | } | |
1280 | else |
|
1280 | else | |
1281 | { |
|
1281 | { | |
1282 | sequence_cnt = (unsigned short *) NULL; |
|
1282 | sequence_cnt = (unsigned short *) NULL; | |
1283 | PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid) |
|
1283 | PRINTF1("in increment_seq_counter_source_id *** ERR apid_destid %d not known\n", sid) | |
1284 | } |
|
1284 | } | |
1285 |
|
1285 | |||
1286 | if (sequence_cnt != NULL) |
|
1286 | if (sequence_cnt != NULL) | |
1287 | { |
|
1287 | { | |
1288 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
1288 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; | |
1289 | *sequence_cnt = (*sequence_cnt) & 0x3fff; |
|
1289 | *sequence_cnt = (*sequence_cnt) & 0x3fff; | |
1290 |
|
1290 | |||
1291 | new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ; |
|
1291 | new_packet_sequence_control = segmentation_grouping_flag | (*sequence_cnt) ; | |
1292 |
|
1292 | |||
1293 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); |
|
1293 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); | |
1294 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); |
|
1294 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); | |
1295 |
|
1295 | |||
1296 | // increment the sequence counter |
|
1296 | // increment the sequence counter | |
1297 | if ( *sequence_cnt < SEQ_CNT_MAX) |
|
1297 | if ( *sequence_cnt < SEQ_CNT_MAX) | |
1298 | { |
|
1298 | { | |
1299 | *sequence_cnt = *sequence_cnt + 1; |
|
1299 | *sequence_cnt = *sequence_cnt + 1; | |
1300 | } |
|
1300 | } | |
1301 | else |
|
1301 | else | |
1302 | { |
|
1302 | { | |
1303 | *sequence_cnt = 0; |
|
1303 | *sequence_cnt = 0; | |
1304 | } |
|
1304 | } | |
1305 | } |
|
1305 | } | |
1306 |
|
1306 | |||
1307 | //************************************* |
|
1307 | //************************************* | |
1308 | // RESTORE THE MODE OF THE CALLING TASK |
|
1308 | // RESTORE THE MODE OF THE CALLING TASK | |
1309 | status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, ¤t_mode_set ); |
|
1309 | status = rtems_task_mode( initial_mode_set, RTEMS_PREEMPT_MASK, ¤t_mode_set ); | |
1310 | } |
|
1310 | } |
General Comments 0
You need to be logged in to leave comments.
Login now