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