##// END OF EJS Templates
3.1.0.2...
paul -
r293:e6dce572ae0e R3_plus draft
parent child
Show More
@@ -1,2 +1,2
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
2 2450d4935652a4d0370245cc7fc60a4c51e6fc9b header/lfr_common_headers
2 c378fa14eadd80b3b873ca7c8f9f387893c07692 header/lfr_common_headers
@@ -1,123 +1,123
1 TEMPLATE = app
1 TEMPLATE = app
2 # CONFIG += console v8 sim
2 # CONFIG += console v8 sim
3 # CONFIG options =
3 # CONFIG options =
4 # verbose
4 # verbose
5 # boot_messages
5 # boot_messages
6 # debug_messages
6 # debug_messages
7 # cpu_usage_report
7 # cpu_usage_report
8 # stack_report
8 # stack_report
9 # vhdl_dev
9 # vhdl_dev
10 # debug_tch
10 # debug_tch
11 # lpp_dpu_destid /!\ REMOVE BEFORE DELIVERY TO LESIA /!\
11 # lpp_dpu_destid /!\ REMOVE BEFORE DELIVERY TO LESIA /!\
12 # debug_watchdog
12 # debug_watchdog
13 CONFIG += console verbose lpp_dpu_destid cpu_usage_report
13 CONFIG += console verbose lpp_dpu_destid cpu_usage_report
14 CONFIG -= qt
14 CONFIG -= qt
15
15
16 include(./sparc.pri)
16 include(./sparc.pri)
17
17
18 # flight software version
18 # flight software version
19 SWVERSION=-1-0
19 SWVERSION=-1-0
20 DEFINES += SW_VERSION_N1=3 # major
20 DEFINES += SW_VERSION_N1=3 # major
21 DEFINES += SW_VERSION_N2=1 # minor
21 DEFINES += SW_VERSION_N2=1 # minor
22 DEFINES += SW_VERSION_N3=0 # patch
22 DEFINES += SW_VERSION_N3=0 # patch
23 DEFINES += SW_VERSION_N4=1 # internal
23 DEFINES += SW_VERSION_N4=2 # internal
24
24
25 # <GCOV>
25 # <GCOV>
26 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
26 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
27 #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc
27 #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc
28 # </GCOV>
28 # </GCOV>
29
29
30 # <CHANGE BEFORE FLIGHT>
30 # <CHANGE BEFORE FLIGHT>
31 contains( CONFIG, lpp_dpu_destid ) {
31 contains( CONFIG, lpp_dpu_destid ) {
32 DEFINES += LPP_DPU_DESTID
32 DEFINES += LPP_DPU_DESTID
33 }
33 }
34 # </CHANGE BEFORE FLIGHT>
34 # </CHANGE BEFORE FLIGHT>
35
35
36 contains( CONFIG, debug_tch ) {
36 contains( CONFIG, debug_tch ) {
37 DEFINES += DEBUG_TCH
37 DEFINES += DEBUG_TCH
38 }
38 }
39 DEFINES += MSB_FIRST_TCH
39 DEFINES += MSB_FIRST_TCH
40
40
41 contains( CONFIG, vhdl_dev ) {
41 contains( CONFIG, vhdl_dev ) {
42 DEFINES += VHDL_DEV
42 DEFINES += VHDL_DEV
43 }
43 }
44
44
45 contains( CONFIG, verbose ) {
45 contains( CONFIG, verbose ) {
46 DEFINES += PRINT_MESSAGES_ON_CONSOLE
46 DEFINES += PRINT_MESSAGES_ON_CONSOLE
47 }
47 }
48
48
49 contains( CONFIG, debug_messages ) {
49 contains( CONFIG, debug_messages ) {
50 DEFINES += DEBUG_MESSAGES
50 DEFINES += DEBUG_MESSAGES
51 }
51 }
52
52
53 contains( CONFIG, cpu_usage_report ) {
53 contains( CONFIG, cpu_usage_report ) {
54 DEFINES += PRINT_TASK_STATISTICS
54 DEFINES += PRINT_TASK_STATISTICS
55 }
55 }
56
56
57 contains( CONFIG, stack_report ) {
57 contains( CONFIG, stack_report ) {
58 DEFINES += PRINT_STACK_REPORT
58 DEFINES += PRINT_STACK_REPORT
59 }
59 }
60
60
61 contains( CONFIG, boot_messages ) {
61 contains( CONFIG, boot_messages ) {
62 DEFINES += BOOT_MESSAGES
62 DEFINES += BOOT_MESSAGES
63 }
63 }
64
64
65 contains( CONFIG, debug_watchdog ) {
65 contains( CONFIG, debug_watchdog ) {
66 DEFINES += DEBUG_WATCHDOG
66 DEFINES += DEBUG_WATCHDOG
67 }
67 }
68
68
69 #doxygen.target = doxygen
69 #doxygen.target = doxygen
70 #doxygen.commands = doxygen ../doc/Doxyfile
70 #doxygen.commands = doxygen ../doc/Doxyfile
71 #QMAKE_EXTRA_TARGETS += doxygen
71 #QMAKE_EXTRA_TARGETS += doxygen
72
72
73 TARGET = fsw
73 TARGET = fsw
74
74
75 INCLUDEPATH += \
75 INCLUDEPATH += \
76 $${PWD}/../src \
76 $${PWD}/../src \
77 $${PWD}/../header \
77 $${PWD}/../header \
78 $${PWD}/../header/lfr_common_headers \
78 $${PWD}/../header/lfr_common_headers \
79 $${PWD}/../header/processing \
79 $${PWD}/../header/processing \
80 $${PWD}/../LFR_basic-parameters
80 $${PWD}/../LFR_basic-parameters
81
81
82 SOURCES += \
82 SOURCES += \
83 ../src/wf_handler.c \
83 ../src/wf_handler.c \
84 ../src/tc_handler.c \
84 ../src/tc_handler.c \
85 ../src/fsw_misc.c \
85 ../src/fsw_misc.c \
86 ../src/fsw_init.c \
86 ../src/fsw_init.c \
87 ../src/fsw_globals.c \
87 ../src/fsw_globals.c \
88 ../src/fsw_spacewire.c \
88 ../src/fsw_spacewire.c \
89 ../src/tc_load_dump_parameters.c \
89 ../src/tc_load_dump_parameters.c \
90 ../src/tm_lfr_tc_exe.c \
90 ../src/tm_lfr_tc_exe.c \
91 ../src/tc_acceptance.c \
91 ../src/tc_acceptance.c \
92 ../src/processing/fsw_processing.c \
92 ../src/processing/fsw_processing.c \
93 ../src/processing/avf0_prc0.c \
93 ../src/processing/avf0_prc0.c \
94 ../src/processing/avf1_prc1.c \
94 ../src/processing/avf1_prc1.c \
95 ../src/processing/avf2_prc2.c \
95 ../src/processing/avf2_prc2.c \
96 ../src/lfr_cpu_usage_report.c \
96 ../src/lfr_cpu_usage_report.c \
97 ../LFR_basic-parameters/basic_parameters.c
97 ../LFR_basic-parameters/basic_parameters.c
98
98
99 HEADERS += \
99 HEADERS += \
100 ../header/wf_handler.h \
100 ../header/wf_handler.h \
101 ../header/tc_handler.h \
101 ../header/tc_handler.h \
102 ../header/grlib_regs.h \
102 ../header/grlib_regs.h \
103 ../header/fsw_misc.h \
103 ../header/fsw_misc.h \
104 ../header/fsw_init.h \
104 ../header/fsw_init.h \
105 ../header/fsw_spacewire.h \
105 ../header/fsw_spacewire.h \
106 ../header/tc_load_dump_parameters.h \
106 ../header/tc_load_dump_parameters.h \
107 ../header/tm_lfr_tc_exe.h \
107 ../header/tm_lfr_tc_exe.h \
108 ../header/tc_acceptance.h \
108 ../header/tc_acceptance.h \
109 ../header/processing/fsw_processing.h \
109 ../header/processing/fsw_processing.h \
110 ../header/processing/avf0_prc0.h \
110 ../header/processing/avf0_prc0.h \
111 ../header/processing/avf1_prc1.h \
111 ../header/processing/avf1_prc1.h \
112 ../header/processing/avf2_prc2.h \
112 ../header/processing/avf2_prc2.h \
113 ../header/fsw_params_wf_handler.h \
113 ../header/fsw_params_wf_handler.h \
114 ../header/lfr_cpu_usage_report.h \
114 ../header/lfr_cpu_usage_report.h \
115 ../header/lfr_common_headers/ccsds_types.h \
115 ../header/lfr_common_headers/ccsds_types.h \
116 ../header/lfr_common_headers/fsw_params.h \
116 ../header/lfr_common_headers/fsw_params.h \
117 ../header/lfr_common_headers/fsw_params_nb_bytes.h \
117 ../header/lfr_common_headers/fsw_params_nb_bytes.h \
118 ../header/lfr_common_headers/fsw_params_processing.h \
118 ../header/lfr_common_headers/fsw_params_processing.h \
119 ../header/lfr_common_headers/tm_byte_positions.h \
119 ../header/lfr_common_headers/tm_byte_positions.h \
120 ../LFR_basic-parameters/basic_parameters.h \
120 ../LFR_basic-parameters/basic_parameters.h \
121 ../LFR_basic-parameters/basic_parameters_params.h \
121 ../LFR_basic-parameters/basic_parameters_params.h \
122 ../header/GscMemoryLPP.hpp
122 ../header/GscMemoryLPP.hpp
123
123
@@ -1,64 +1,64
1 #ifndef FSW_INIT_H_INCLUDED
1 #ifndef FSW_INIT_H_INCLUDED
2 #define FSW_INIT_H_INCLUDED
2 #define FSW_INIT_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <leon.h>
5 #include <leon.h>
6
6
7 #include "fsw_params.h"
7 #include "fsw_params.h"
8 #include "fsw_misc.h"
8 #include "fsw_misc.h"
9 #include "fsw_processing.h"
9 #include "fsw_processing.h"
10
10
11 #include "tc_handler.h"
11 #include "tc_handler.h"
12 #include "wf_handler.h"
12 #include "wf_handler.h"
13 #include "fsw_spacewire.h"
13 #include "fsw_spacewire.h"
14
14
15 #include "avf0_prc0.h"
15 #include "avf0_prc0.h"
16 #include "avf1_prc1.h"
16 #include "avf1_prc1.h"
17 #include "avf2_prc2.h"
17 #include "avf2_prc2.h"
18
18
19 extern rtems_name Task_name[20]; /* array of task names */
19 extern rtems_name Task_name[20]; /* array of task names */
20 extern rtems_id Task_id[20]; /* array of task ids */
20 extern rtems_id Task_id[20]; /* array of task ids */
21 extern rtems_name timecode_timer_name;
21 extern rtems_name timecode_timer_name;
22 extern rtems_id timecode_timer_id;
22 extern rtems_id timecode_timer_id;
23 extern unsigned char pa_bia_status_info;
23 extern unsigned char pa_bia_status_info;
24 extern unsigned char cp_rpw_sc_rw_f_flags;
24 extern unsigned char cp_rpw_sc_rw_f_flags;
25 extern float cp_rpw_sc_rw1_f1;
25 extern float cp_rpw_sc_rw1_f1;
26 extern float cp_rpw_sc_rw1_f2;
26 extern float cp_rpw_sc_rw1_f2;
27 extern float cp_rpw_sc_rw2_f1;
27 extern float cp_rpw_sc_rw2_f1;
28 extern float cp_rpw_sc_rw2_f2;
28 extern float cp_rpw_sc_rw2_f2;
29 extern float cp_rpw_sc_rw3_f1;
29 extern float cp_rpw_sc_rw3_f1;
30 extern float cp_rpw_sc_rw3_f2;
30 extern float cp_rpw_sc_rw3_f2;
31 extern float cp_rpw_sc_rw4_f1;
31 extern float cp_rpw_sc_rw4_f1;
32 extern float cp_rpw_sc_rw4_f2;
32 extern float cp_rpw_sc_rw4_f2;
33 extern float sy_lfr_sc_rw_delta_f;
33 extern filterPar_t filterPar;
34
34
35 // RTEMS TASKS
35 // RTEMS TASKS
36 rtems_task Init( rtems_task_argument argument);
36 rtems_task Init( rtems_task_argument argument);
37
37
38 // OTHER functions
38 // OTHER functions
39 void create_names( void );
39 void create_names( void );
40 int create_all_tasks( void );
40 int create_all_tasks( void );
41 int start_all_tasks( void );
41 int start_all_tasks( void );
42 //
42 //
43 rtems_status_code create_message_queues( void );
43 rtems_status_code create_message_queues( void );
44 rtems_status_code create_timecode_timer( void );
44 rtems_status_code create_timecode_timer( void );
45 rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
45 rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
46 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
46 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id );
47 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
47 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id );
48 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
48 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id );
49 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
49 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id );
50 void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max );
50 void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max );
51 void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize );
51 void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize );
52 //
52 //
53 int start_recv_send_tasks( void );
53 int start_recv_send_tasks( void );
54 //
54 //
55 void init_local_mode_parameters( void );
55 void init_local_mode_parameters( void );
56 void reset_local_time( void );
56 void reset_local_time( void );
57
57
58 extern void rtems_cpu_usage_report( void );
58 extern void rtems_cpu_usage_report( void );
59 extern void rtems_cpu_usage_reset( void );
59 extern void rtems_cpu_usage_reset( void );
60 extern void rtems_stack_checker_report_usage( void );
60 extern void rtems_stack_checker_report_usage( void );
61
61
62 extern int sched_yield( void );
62 extern int sched_yield( void );
63
63
64 #endif // FSW_INIT_H_INCLUDED
64 #endif // FSW_INIT_H_INCLUDED
@@ -1,96 +1,98
1 /** Global variables of the LFR flight software.
1 /** Global variables of the LFR flight software.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * Among global variables, there are:
6 * Among global variables, there are:
7 * - RTEMS names and id.
7 * - RTEMS names and id.
8 * - APB configuration registers.
8 * - APB configuration registers.
9 * - waveforms global buffers, used by the waveform picker hardware module to store data.
9 * - waveforms global buffers, used by the waveform picker hardware module to store data.
10 * - spectral matrices buffesr, used by the hardware module to store data.
10 * - spectral matrices buffesr, used by the hardware module to store data.
11 * - variable related to LFR modes parameters.
11 * - variable related to LFR modes parameters.
12 * - the global HK packet buffer.
12 * - the global HK packet buffer.
13 * - the global dump parameter buffer.
13 * - the global dump parameter buffer.
14 *
14 *
15 */
15 */
16
16
17 #include <rtems.h>
17 #include <rtems.h>
18 #include <grspw.h>
18 #include <grspw.h>
19
19
20 #include "ccsds_types.h"
20 #include "ccsds_types.h"
21 #include "grlib_regs.h"
21 #include "grlib_regs.h"
22 #include "fsw_params.h"
22 #include "fsw_params.h"
23 #include "fsw_params_wf_handler.h"
23 #include "fsw_params_wf_handler.h"
24
24
25 // RTEMS GLOBAL VARIABLES
25 // RTEMS GLOBAL VARIABLES
26 rtems_name misc_name[5];
26 rtems_name misc_name[5];
27 rtems_name Task_name[20]; /* array of task names */
27 rtems_name Task_name[20]; /* array of task names */
28 rtems_id Task_id[20]; /* array of task ids */
28 rtems_id Task_id[20]; /* array of task ids */
29 rtems_name timecode_timer_name;
29 rtems_name timecode_timer_name;
30 rtems_id timecode_timer_id;
30 rtems_id timecode_timer_id;
31 int fdSPW = 0;
31 int fdSPW = 0;
32 int fdUART = 0;
32 int fdUART = 0;
33 unsigned char lfrCurrentMode;
33 unsigned char lfrCurrentMode;
34 unsigned char pa_bia_status_info;
34 unsigned char pa_bia_status_info;
35 unsigned char thisIsAnASMRestart = 0;
35 unsigned char thisIsAnASMRestart = 0;
36 unsigned char oneTcLfrUpdateTimeReceived = 0;
36 unsigned char oneTcLfrUpdateTimeReceived = 0;
37
37
38 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584
38 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes = 24584
39 // 97 * 256 = 24832 => delta = 248 bytes = 62 words
39 // 97 * 256 = 24832 => delta = 248 bytes = 62 words
40 // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264
40 // WAVEFORMS GLOBAL VARIABLES // 2688 * 3 * 4 + 2 * 4 = 32256 + 8 bytes = 32264
41 // 127 * 256 = 32512 => delta = 248 bytes = 62 words
41 // 127 * 256 = 32512 => delta = 248 bytes = 62 words
42 // F0 F1 F2 F3
42 // F0 F1 F2 F3
43 volatile int wf_buffer_f0[ NB_RING_NODES_F0 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
43 volatile int wf_buffer_f0[ NB_RING_NODES_F0 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
44 volatile int wf_buffer_f1[ NB_RING_NODES_F1 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
44 volatile int wf_buffer_f1[ NB_RING_NODES_F1 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
45 volatile int wf_buffer_f2[ NB_RING_NODES_F2 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
45 volatile int wf_buffer_f2[ NB_RING_NODES_F2 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
46 volatile int wf_buffer_f3[ NB_RING_NODES_F3 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
46 volatile int wf_buffer_f3[ NB_RING_NODES_F3 * WFRM_BUFFER ] __attribute__((aligned(0x100)));
47
47
48 //***********************************
48 //***********************************
49 // SPECTRAL MATRICES GLOBAL VARIABLES
49 // SPECTRAL MATRICES GLOBAL VARIABLES
50
50
51 // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00
51 // alignment constraints for the spectral matrices buffers => the first data after the time (8 bytes) shall be aligned on 0x00
52 volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
52 volatile int sm_f0[ NB_RING_NODES_SM_F0 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
53 volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
53 volatile int sm_f1[ NB_RING_NODES_SM_F1 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
54 volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
54 volatile int sm_f2[ NB_RING_NODES_SM_F2 * TOTAL_SIZE_SM ] __attribute__((aligned(0x100)));
55
55
56 // APB CONFIGURATION REGISTERS
56 // APB CONFIGURATION REGISTERS
57 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
57 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
58 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
58 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
59 waveform_picker_regs_0_1_18_t *waveform_picker_regs = (waveform_picker_regs_0_1_18_t*) REGS_ADDR_WAVEFORM_PICKER;
59 waveform_picker_regs_0_1_18_t *waveform_picker_regs = (waveform_picker_regs_0_1_18_t*) REGS_ADDR_WAVEFORM_PICKER;
60 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
60 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
61
61
62 // MODE PARAMETERS
62 // MODE PARAMETERS
63 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
63 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
64 struct param_local_str param_local;
64 struct param_local_str param_local;
65 unsigned int lastValidEnterModeTime;
65 unsigned int lastValidEnterModeTime;
66
66
67 // HK PACKETS
67 // HK PACKETS
68 Packet_TM_LFR_HK_t housekeeping_packet;
68 Packet_TM_LFR_HK_t housekeeping_packet;
69 unsigned char cp_rpw_sc_rw_f_flags;
69 unsigned char cp_rpw_sc_rw_f_flags;
70 // message queues occupancy
70 // message queues occupancy
71 unsigned char hk_lfr_q_sd_fifo_size_max;
71 unsigned char hk_lfr_q_sd_fifo_size_max;
72 unsigned char hk_lfr_q_rv_fifo_size_max;
72 unsigned char hk_lfr_q_rv_fifo_size_max;
73 unsigned char hk_lfr_q_p0_fifo_size_max;
73 unsigned char hk_lfr_q_p0_fifo_size_max;
74 unsigned char hk_lfr_q_p1_fifo_size_max;
74 unsigned char hk_lfr_q_p1_fifo_size_max;
75 unsigned char hk_lfr_q_p2_fifo_size_max;
75 unsigned char hk_lfr_q_p2_fifo_size_max;
76 // sequence counters are incremented by APID (PID + CAT) and destination ID
76 // sequence counters are incremented by APID (PID + CAT) and destination ID
77 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
77 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
78 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
78 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
79 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
79 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
80 unsigned short sequenceCounters_TM_DUMP[SEQ_CNT_NB_DEST_ID];
80 unsigned short sequenceCounters_TM_DUMP[SEQ_CNT_NB_DEST_ID];
81 unsigned short sequenceCounterHK;
81 unsigned short sequenceCounterHK;
82 spw_stats grspw_stats;
82 spw_stats grspw_stats;
83
83
84 // TC_LFR_UPDATE_INFO
84 // TC_LFR_UPDATE_INFO
85 float cp_rpw_sc_rw1_f1;
85 float cp_rpw_sc_rw1_f1;
86 float cp_rpw_sc_rw1_f2;
86 float cp_rpw_sc_rw1_f2;
87 float cp_rpw_sc_rw2_f1;
87 float cp_rpw_sc_rw2_f1;
88 float cp_rpw_sc_rw2_f2;
88 float cp_rpw_sc_rw2_f2;
89 float cp_rpw_sc_rw3_f1;
89 float cp_rpw_sc_rw3_f1;
90 float cp_rpw_sc_rw3_f2;
90 float cp_rpw_sc_rw3_f2;
91 float cp_rpw_sc_rw4_f1;
91 float cp_rpw_sc_rw4_f1;
92 float cp_rpw_sc_rw4_f2;
92 float cp_rpw_sc_rw4_f2;
93 float sy_lfr_sc_rw_delta_f;
93
94 // TC_LFR_LOAD_FILTER_PAR
95 filterPar_t filterPar;
94
96
95 fbins_masks_t fbins_masks;
97 fbins_masks_t fbins_masks;
96 unsigned int acquisitionDurations[3] = {ACQUISITION_DURATION_F0, ACQUISITION_DURATION_F1, ACQUISITION_DURATION_F2};
98 unsigned int acquisitionDurations[3] = {ACQUISITION_DURATION_F0, ACQUISITION_DURATION_F1, ACQUISITION_DURATION_F2};
@@ -1,928 +1,934
1 /** This is the RTEMS initialization module.
1 /** This is the RTEMS initialization module.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * This module contains two very different information:
6 * This module contains two very different information:
7 * - specific instructions to configure the compilation of the RTEMS executive
7 * - specific instructions to configure the compilation of the RTEMS executive
8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
9 *
9 *
10 */
10 */
11
11
12 //*************************
12 //*************************
13 // GPL reminder to be added
13 // GPL reminder to be added
14 //*************************
14 //*************************
15
15
16 #include <rtems.h>
16 #include <rtems.h>
17
17
18 /* configuration information */
18 /* configuration information */
19
19
20 #define CONFIGURE_INIT
20 #define CONFIGURE_INIT
21
21
22 #include <bsp.h> /* for device driver prototypes */
22 #include <bsp.h> /* for device driver prototypes */
23
23
24 /* configuration information */
24 /* configuration information */
25
25
26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
28
28
29 #define CONFIGURE_MAXIMUM_TASKS 20
29 #define CONFIGURE_MAXIMUM_TASKS 20
30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
35 #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
35 #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
36 #define CONFIGURE_MAXIMUM_DRIVERS 16
36 #define CONFIGURE_MAXIMUM_DRIVERS 16
37 #define CONFIGURE_MAXIMUM_PERIODS 5
37 #define CONFIGURE_MAXIMUM_PERIODS 5
38 #define CONFIGURE_MAXIMUM_TIMERS 5 // [spiq] [link] [spacewire_reset_link]
38 #define CONFIGURE_MAXIMUM_TIMERS 5 // [spiq] [link] [spacewire_reset_link]
39 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
39 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
40 #ifdef PRINT_STACK_REPORT
40 #ifdef PRINT_STACK_REPORT
41 #define CONFIGURE_STACK_CHECKER_ENABLED
41 #define CONFIGURE_STACK_CHECKER_ENABLED
42 #endif
42 #endif
43
43
44 #include <rtems/confdefs.h>
44 #include <rtems/confdefs.h>
45
45
46 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
46 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
47 #ifdef RTEMS_DRVMGR_STARTUP
47 #ifdef RTEMS_DRVMGR_STARTUP
48 #ifdef LEON3
48 #ifdef LEON3
49 /* Add Timer and UART Driver */
49 /* Add Timer and UART Driver */
50 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
50 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
51 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
51 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
52 #endif
52 #endif
53 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
53 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
54 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
54 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
55 #endif
55 #endif
56 #endif
56 #endif
57 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
57 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
58 #include <drvmgr/drvmgr_confdefs.h>
58 #include <drvmgr/drvmgr_confdefs.h>
59 #endif
59 #endif
60
60
61 #include "fsw_init.h"
61 #include "fsw_init.h"
62 #include "fsw_config.c"
62 #include "fsw_config.c"
63 #include "GscMemoryLPP.hpp"
63 #include "GscMemoryLPP.hpp"
64
64
65 void initCache()
65 void initCache()
66 {
66 {
67 // ASI 2 contains a few control registers that have not been assigned as ancillary state registers.
67 // ASI 2 contains a few control registers that have not been assigned as ancillary state registers.
68 // These should only be read and written using 32-bit LDA/STA instructions.
68 // These should only be read and written using 32-bit LDA/STA instructions.
69 // All cache registers are accessed through load/store operations to the alternate address space (LDA/STA), using ASI = 2.
69 // All cache registers are accessed through load/store operations to the alternate address space (LDA/STA), using ASI = 2.
70 // The table below shows the register addresses:
70 // The table below shows the register addresses:
71 // 0x00 Cache control register
71 // 0x00 Cache control register
72 // 0x04 Reserved
72 // 0x04 Reserved
73 // 0x08 Instruction cache configuration register
73 // 0x08 Instruction cache configuration register
74 // 0x0C Data cache configuration register
74 // 0x0C Data cache configuration register
75
75
76 // Cache Control Register Leon3 / Leon3FT
76 // Cache Control Register Leon3 / Leon3FT
77 // 31..30 29 28 27..24 23 22 21 20..19 18 17 16
77 // 31..30 29 28 27..24 23 22 21 20..19 18 17 16
78 // RFT PS TB DS FD FI FT ST IB
78 // RFT PS TB DS FD FI FT ST IB
79 // 15 14 13..12 11..10 9..8 7..6 5 4 3..2 1..0
79 // 15 14 13..12 11..10 9..8 7..6 5 4 3..2 1..0
80 // IP DP ITE IDE DTE DDE DF IF DCS ICS
80 // IP DP ITE IDE DTE DDE DF IF DCS ICS
81
81
82 unsigned int cacheControlRegister;
82 unsigned int cacheControlRegister;
83
83
84 CCR_resetCacheControlRegister();
84 CCR_resetCacheControlRegister();
85 ASR16_resetRegisterProtectionControlRegister();
85 ASR16_resetRegisterProtectionControlRegister();
86
86
87 cacheControlRegister = CCR_getValue();
87 cacheControlRegister = CCR_getValue();
88 PRINTF1("(0) CCR - Cache Control Register = %x\n", cacheControlRegister);
88 PRINTF1("(0) CCR - Cache Control Register = %x\n", cacheControlRegister);
89 PRINTF1("(0) ASR16 = %x\n", *asr16Ptr);
89 PRINTF1("(0) ASR16 = %x\n", *asr16Ptr);
90
90
91 CCR_enableInstructionCache(); // ICS bits
91 CCR_enableInstructionCache(); // ICS bits
92 CCR_enableDataCache(); // DCS bits
92 CCR_enableDataCache(); // DCS bits
93 CCR_enableInstructionBurstFetch(); // IB bit
93 CCR_enableInstructionBurstFetch(); // IB bit
94
94
95 faultTolerantScheme();
95 faultTolerantScheme();
96
96
97 cacheControlRegister = CCR_getValue();
97 cacheControlRegister = CCR_getValue();
98 PRINTF1("(1) CCR - Cache Control Register = %x\n", cacheControlRegister);
98 PRINTF1("(1) CCR - Cache Control Register = %x\n", cacheControlRegister);
99 PRINTF1("(1) ASR16 Register protection control register = %x\n", *asr16Ptr);
99 PRINTF1("(1) ASR16 Register protection control register = %x\n", *asr16Ptr);
100
100
101 PRINTF("\n");
101 PRINTF("\n");
102 }
102 }
103
103
104 rtems_task Init( rtems_task_argument ignored )
104 rtems_task Init( rtems_task_argument ignored )
105 {
105 {
106 /** This is the RTEMS INIT taks, it is the first task launched by the system.
106 /** This is the RTEMS INIT taks, it is the first task launched by the system.
107 *
107 *
108 * @param unused is the starting argument of the RTEMS task
108 * @param unused is the starting argument of the RTEMS task
109 *
109 *
110 * The INIT task create and run all other RTEMS tasks.
110 * The INIT task create and run all other RTEMS tasks.
111 *
111 *
112 */
112 */
113
113
114 //***********
114 //***********
115 // INIT CACHE
115 // INIT CACHE
116
116
117 unsigned char *vhdlVersion;
117 unsigned char *vhdlVersion;
118
118
119 reset_lfr();
119 reset_lfr();
120
120
121 reset_local_time();
121 reset_local_time();
122
122
123 rtems_cpu_usage_reset();
123 rtems_cpu_usage_reset();
124
124
125 rtems_status_code status;
125 rtems_status_code status;
126 rtems_status_code status_spw;
126 rtems_status_code status_spw;
127 rtems_isr_entry old_isr_handler;
127 rtems_isr_entry old_isr_handler;
128
128
129 // UART settings
129 // UART settings
130 enable_apbuart_transmitter();
130 enable_apbuart_transmitter();
131 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
131 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
132
132
133 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
133 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
134
134
135
135
136 PRINTF("\n\n\n\n\n")
136 PRINTF("\n\n\n\n\n")
137
137
138 initCache();
138 initCache();
139
139
140 PRINTF("*************************\n")
140 PRINTF("*************************\n")
141 PRINTF("** LFR Flight Software **\n")
141 PRINTF("** LFR Flight Software **\n")
142 PRINTF1("** %d.", SW_VERSION_N1)
142 PRINTF1("** %d.", SW_VERSION_N1)
143 PRINTF1("%d." , SW_VERSION_N2)
143 PRINTF1("%d." , SW_VERSION_N2)
144 PRINTF1("%d." , SW_VERSION_N3)
144 PRINTF1("%d." , SW_VERSION_N3)
145 PRINTF1("%d **\n", SW_VERSION_N4)
145 PRINTF1("%d **\n", SW_VERSION_N4)
146
146
147 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
147 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
148 PRINTF("** VHDL **\n")
148 PRINTF("** VHDL **\n")
149 PRINTF1("** %d.", vhdlVersion[1])
149 PRINTF1("** %d.", vhdlVersion[1])
150 PRINTF1("%d." , vhdlVersion[2])
150 PRINTF1("%d." , vhdlVersion[2])
151 PRINTF1("%d **\n", vhdlVersion[3])
151 PRINTF1("%d **\n", vhdlVersion[3])
152 PRINTF("*************************\n")
152 PRINTF("*************************\n")
153 PRINTF("\n\n")
153 PRINTF("\n\n")
154
154
155 init_parameter_dump();
155 init_parameter_dump();
156 init_kcoefficients_dump();
156 init_kcoefficients_dump();
157 init_local_mode_parameters();
157 init_local_mode_parameters();
158 init_housekeeping_parameters();
158 init_housekeeping_parameters();
159 init_k_coefficients_prc0();
159 init_k_coefficients_prc0();
160 init_k_coefficients_prc1();
160 init_k_coefficients_prc1();
161 init_k_coefficients_prc2();
161 init_k_coefficients_prc2();
162 pa_bia_status_info = 0x00;
162 pa_bia_status_info = 0x00;
163 cp_rpw_sc_rw_f_flags = 0x00;
163 cp_rpw_sc_rw_f_flags = 0x00;
164 cp_rpw_sc_rw1_f1 = 0.0;
164 cp_rpw_sc_rw1_f1 = 0.0;
165 cp_rpw_sc_rw1_f2 = 0.0;
165 cp_rpw_sc_rw1_f2 = 0.0;
166 cp_rpw_sc_rw2_f1 = 0.0;
166 cp_rpw_sc_rw2_f1 = 0.0;
167 cp_rpw_sc_rw2_f2 = 0.0;
167 cp_rpw_sc_rw2_f2 = 0.0;
168 cp_rpw_sc_rw3_f1 = 0.0;
168 cp_rpw_sc_rw3_f1 = 0.0;
169 cp_rpw_sc_rw3_f2 = 0.0;
169 cp_rpw_sc_rw3_f2 = 0.0;
170 cp_rpw_sc_rw4_f1 = 0.0;
170 cp_rpw_sc_rw4_f1 = 0.0;
171 cp_rpw_sc_rw4_f2 = 0.0;
171 cp_rpw_sc_rw4_f2 = 0.0;
172 sy_lfr_sc_rw_delta_f = 0.0;
172 // initialize filtering parameters
173 filterPar.spare_sy_lfr_pas_filter_enabled = DEFAULT_SY_LFR_PAS_FILTER_ENABLED;
174 filterPar.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
175 filterPar.sy_lfr_pas_filter_tbad = DEFAULT_SY_LFR_PAS_FILTER_TBAD;
176 filterPar.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
177 filterPar.sy_lfr_pas_filter_shift = DEFAULT_SY_LFR_PAS_FILTER_SHIFT;
178 filterPar.sy_lfr_sc_rw_delta_f = DEFAULT_SY_LFR_SC_RW_DELTA_F;
173 update_last_valid_transition_date( DEFAULT_LAST_VALID_TRANSITION_DATE );
179 update_last_valid_transition_date( DEFAULT_LAST_VALID_TRANSITION_DATE );
174
180
175 // waveform picker initialization
181 // waveform picker initialization
176 WFP_init_rings();
182 WFP_init_rings();
177 LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings
183 LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings
178 WFP_reset_current_ring_nodes();
184 WFP_reset_current_ring_nodes();
179 reset_waveform_picker_regs();
185 reset_waveform_picker_regs();
180
186
181 // spectral matrices initialization
187 // spectral matrices initialization
182 SM_init_rings(); // initialize spectral matrices rings
188 SM_init_rings(); // initialize spectral matrices rings
183 SM_reset_current_ring_nodes();
189 SM_reset_current_ring_nodes();
184 reset_spectral_matrix_regs();
190 reset_spectral_matrix_regs();
185
191
186 // configure calibration
192 // configure calibration
187 configureCalibration( false ); // true means interleaved mode, false is for normal mode
193 configureCalibration( false ); // true means interleaved mode, false is for normal mode
188
194
189 updateLFRCurrentMode( LFR_MODE_STANDBY );
195 updateLFRCurrentMode( LFR_MODE_STANDBY );
190
196
191 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
197 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
192
198
193 create_names(); // create all names
199 create_names(); // create all names
194
200
195 status = create_timecode_timer(); // create the timer used by timecode_irq_handler
201 status = create_timecode_timer(); // create the timer used by timecode_irq_handler
196 if (status != RTEMS_SUCCESSFUL)
202 if (status != RTEMS_SUCCESSFUL)
197 {
203 {
198 PRINTF1("in INIT *** ERR in create_timer_timecode, code %d", status)
204 PRINTF1("in INIT *** ERR in create_timer_timecode, code %d", status)
199 }
205 }
200
206
201 status = create_message_queues(); // create message queues
207 status = create_message_queues(); // create message queues
202 if (status != RTEMS_SUCCESSFUL)
208 if (status != RTEMS_SUCCESSFUL)
203 {
209 {
204 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
210 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
205 }
211 }
206
212
207 status = create_all_tasks(); // create all tasks
213 status = create_all_tasks(); // create all tasks
208 if (status != RTEMS_SUCCESSFUL)
214 if (status != RTEMS_SUCCESSFUL)
209 {
215 {
210 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
216 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
211 }
217 }
212
218
213 // **************************
219 // **************************
214 // <SPACEWIRE INITIALIZATION>
220 // <SPACEWIRE INITIALIZATION>
215 status_spw = spacewire_open_link(); // (1) open the link
221 status_spw = spacewire_open_link(); // (1) open the link
216 if ( status_spw != RTEMS_SUCCESSFUL )
222 if ( status_spw != RTEMS_SUCCESSFUL )
217 {
223 {
218 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
224 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
219 }
225 }
220
226
221 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
227 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
222 {
228 {
223 status_spw = spacewire_configure_link( fdSPW );
229 status_spw = spacewire_configure_link( fdSPW );
224 if ( status_spw != RTEMS_SUCCESSFUL )
230 if ( status_spw != RTEMS_SUCCESSFUL )
225 {
231 {
226 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
232 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
227 }
233 }
228 }
234 }
229
235
230 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
236 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
231 {
237 {
232 status_spw = spacewire_start_link( fdSPW );
238 status_spw = spacewire_start_link( fdSPW );
233 if ( status_spw != RTEMS_SUCCESSFUL )
239 if ( status_spw != RTEMS_SUCCESSFUL )
234 {
240 {
235 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
241 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
236 }
242 }
237 }
243 }
238 // </SPACEWIRE INITIALIZATION>
244 // </SPACEWIRE INITIALIZATION>
239 // ***************************
245 // ***************************
240
246
241 status = start_all_tasks(); // start all tasks
247 status = start_all_tasks(); // start all tasks
242 if (status != RTEMS_SUCCESSFUL)
248 if (status != RTEMS_SUCCESSFUL)
243 {
249 {
244 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
250 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
245 }
251 }
246
252
247 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
253 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
248 status = start_recv_send_tasks();
254 status = start_recv_send_tasks();
249 if ( status != RTEMS_SUCCESSFUL )
255 if ( status != RTEMS_SUCCESSFUL )
250 {
256 {
251 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
257 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
252 }
258 }
253
259
254 // suspend science tasks, they will be restarted later depending on the mode
260 // suspend science tasks, they will be restarted later depending on the mode
255 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
261 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
256 if (status != RTEMS_SUCCESSFUL)
262 if (status != RTEMS_SUCCESSFUL)
257 {
263 {
258 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
264 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
259 }
265 }
260
266
261 // configure IRQ handling for the waveform picker unit
267 // configure IRQ handling for the waveform picker unit
262 status = rtems_interrupt_catch( waveforms_isr,
268 status = rtems_interrupt_catch( waveforms_isr,
263 IRQ_SPARC_WAVEFORM_PICKER,
269 IRQ_SPARC_WAVEFORM_PICKER,
264 &old_isr_handler) ;
270 &old_isr_handler) ;
265 // configure IRQ handling for the spectral matrices unit
271 // configure IRQ handling for the spectral matrices unit
266 status = rtems_interrupt_catch( spectral_matrices_isr,
272 status = rtems_interrupt_catch( spectral_matrices_isr,
267 IRQ_SPARC_SPECTRAL_MATRIX,
273 IRQ_SPARC_SPECTRAL_MATRIX,
268 &old_isr_handler) ;
274 &old_isr_handler) ;
269
275
270 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
276 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
271 if ( status_spw != RTEMS_SUCCESSFUL )
277 if ( status_spw != RTEMS_SUCCESSFUL )
272 {
278 {
273 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
279 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
274 if ( status != RTEMS_SUCCESSFUL ) {
280 if ( status != RTEMS_SUCCESSFUL ) {
275 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
281 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
276 }
282 }
277 }
283 }
278
284
279 BOOT_PRINTF("delete INIT\n")
285 BOOT_PRINTF("delete INIT\n")
280
286
281 set_hk_lfr_sc_potential_flag( true );
287 set_hk_lfr_sc_potential_flag( true );
282
288
283 // start the timer to detect a missing spacewire timecode
289 // start the timer to detect a missing spacewire timecode
284 // the timeout is larger because the spw IP needs to receive several valid timecodes before generating a tickout
290 // the timeout is larger because the spw IP needs to receive several valid timecodes before generating a tickout
285 // if a tickout is generated, the timer is restarted
291 // if a tickout is generated, the timer is restarted
286 status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT_INIT, timecode_timer_routine, NULL );
292 status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT_INIT, timecode_timer_routine, NULL );
287
293
288 grspw_timecode_callback = &timecode_irq_handler;
294 grspw_timecode_callback = &timecode_irq_handler;
289
295
290 status = rtems_task_delete(RTEMS_SELF);
296 status = rtems_task_delete(RTEMS_SELF);
291
297
292 }
298 }
293
299
294 void init_local_mode_parameters( void )
300 void init_local_mode_parameters( void )
295 {
301 {
296 /** This function initialize the param_local global variable with default values.
302 /** This function initialize the param_local global variable with default values.
297 *
303 *
298 */
304 */
299
305
300 unsigned int i;
306 unsigned int i;
301
307
302 // LOCAL PARAMETERS
308 // LOCAL PARAMETERS
303
309
304 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
310 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
305 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
311 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
306 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
312 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
307
313
308 // init sequence counters
314 // init sequence counters
309
315
310 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
316 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
311 {
317 {
312 sequenceCounters_TC_EXE[i] = 0x00;
318 sequenceCounters_TC_EXE[i] = 0x00;
313 sequenceCounters_TM_DUMP[i] = 0x00;
319 sequenceCounters_TM_DUMP[i] = 0x00;
314 }
320 }
315 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
321 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
316 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
322 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
317 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
323 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
318 }
324 }
319
325
320 void reset_local_time( void )
326 void reset_local_time( void )
321 {
327 {
322 time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000
328 time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000
323 }
329 }
324
330
325 void create_names( void ) // create all names for tasks and queues
331 void create_names( void ) // create all names for tasks and queues
326 {
332 {
327 /** This function creates all RTEMS names used in the software for tasks and queues.
333 /** This function creates all RTEMS names used in the software for tasks and queues.
328 *
334 *
329 * @return RTEMS directive status codes:
335 * @return RTEMS directive status codes:
330 * - RTEMS_SUCCESSFUL - successful completion
336 * - RTEMS_SUCCESSFUL - successful completion
331 *
337 *
332 */
338 */
333
339
334 // task names
340 // task names
335 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
341 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
336 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
342 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
337 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
343 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
338 Task_name[TASKID_LOAD] = rtems_build_name( 'L', 'O', 'A', 'D' );
344 Task_name[TASKID_LOAD] = rtems_build_name( 'L', 'O', 'A', 'D' );
339 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
345 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
340 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
346 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
341 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
347 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
342 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
348 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
343 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
349 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
344 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
350 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
345 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
351 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
346 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
352 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
347 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
353 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
348 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
354 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
349 Task_name[TASKID_LINK] = rtems_build_name( 'L', 'I', 'N', 'K' );
355 Task_name[TASKID_LINK] = rtems_build_name( 'L', 'I', 'N', 'K' );
350 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
356 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
351 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
357 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
352 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
358 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
353 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
359 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
354
360
355 // rate monotonic period names
361 // rate monotonic period names
356 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
362 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
357
363
358 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
364 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
359 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
365 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
360 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
366 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
361 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
367 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
362 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
368 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
363
369
364 timecode_timer_name = rtems_build_name( 'S', 'P', 'T', 'C' );
370 timecode_timer_name = rtems_build_name( 'S', 'P', 'T', 'C' );
365 }
371 }
366
372
367 int create_all_tasks( void ) // create all tasks which run in the software
373 int create_all_tasks( void ) // create all tasks which run in the software
368 {
374 {
369 /** This function creates all RTEMS tasks used in the software.
375 /** This function creates all RTEMS tasks used in the software.
370 *
376 *
371 * @return RTEMS directive status codes:
377 * @return RTEMS directive status codes:
372 * - RTEMS_SUCCESSFUL - task created successfully
378 * - RTEMS_SUCCESSFUL - task created successfully
373 * - RTEMS_INVALID_ADDRESS - id is NULL
379 * - RTEMS_INVALID_ADDRESS - id is NULL
374 * - RTEMS_INVALID_NAME - invalid task name
380 * - RTEMS_INVALID_NAME - invalid task name
375 * - RTEMS_INVALID_PRIORITY - invalid task priority
381 * - RTEMS_INVALID_PRIORITY - invalid task priority
376 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
382 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
377 * - RTEMS_TOO_MANY - too many tasks created
383 * - RTEMS_TOO_MANY - too many tasks created
378 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
384 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
379 * - RTEMS_TOO_MANY - too many global objects
385 * - RTEMS_TOO_MANY - too many global objects
380 *
386 *
381 */
387 */
382
388
383 rtems_status_code status;
389 rtems_status_code status;
384
390
385 //**********
391 //**********
386 // SPACEWIRE
392 // SPACEWIRE
387 // RECV
393 // RECV
388 status = rtems_task_create(
394 status = rtems_task_create(
389 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
395 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
390 RTEMS_DEFAULT_MODES,
396 RTEMS_DEFAULT_MODES,
391 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
397 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
392 );
398 );
393 if (status == RTEMS_SUCCESSFUL) // SEND
399 if (status == RTEMS_SUCCESSFUL) // SEND
394 {
400 {
395 status = rtems_task_create(
401 status = rtems_task_create(
396 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2,
402 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2,
397 RTEMS_DEFAULT_MODES,
403 RTEMS_DEFAULT_MODES,
398 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND]
404 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND]
399 );
405 );
400 }
406 }
401 if (status == RTEMS_SUCCESSFUL) // LINK
407 if (status == RTEMS_SUCCESSFUL) // LINK
402 {
408 {
403 status = rtems_task_create(
409 status = rtems_task_create(
404 Task_name[TASKID_LINK], TASK_PRIORITY_LINK, RTEMS_MINIMUM_STACK_SIZE,
410 Task_name[TASKID_LINK], TASK_PRIORITY_LINK, RTEMS_MINIMUM_STACK_SIZE,
405 RTEMS_DEFAULT_MODES,
411 RTEMS_DEFAULT_MODES,
406 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LINK]
412 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LINK]
407 );
413 );
408 }
414 }
409 if (status == RTEMS_SUCCESSFUL) // ACTN
415 if (status == RTEMS_SUCCESSFUL) // ACTN
410 {
416 {
411 status = rtems_task_create(
417 status = rtems_task_create(
412 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
418 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
413 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
419 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
414 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
420 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
415 );
421 );
416 }
422 }
417 if (status == RTEMS_SUCCESSFUL) // SPIQ
423 if (status == RTEMS_SUCCESSFUL) // SPIQ
418 {
424 {
419 status = rtems_task_create(
425 status = rtems_task_create(
420 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
426 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
421 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
427 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
422 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
428 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
423 );
429 );
424 }
430 }
425
431
426 //******************
432 //******************
427 // SPECTRAL MATRICES
433 // SPECTRAL MATRICES
428 if (status == RTEMS_SUCCESSFUL) // AVF0
434 if (status == RTEMS_SUCCESSFUL) // AVF0
429 {
435 {
430 status = rtems_task_create(
436 status = rtems_task_create(
431 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
437 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
432 RTEMS_DEFAULT_MODES,
438 RTEMS_DEFAULT_MODES,
433 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
439 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
434 );
440 );
435 }
441 }
436 if (status == RTEMS_SUCCESSFUL) // PRC0
442 if (status == RTEMS_SUCCESSFUL) // PRC0
437 {
443 {
438 status = rtems_task_create(
444 status = rtems_task_create(
439 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
445 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
440 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
446 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
441 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
447 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
442 );
448 );
443 }
449 }
444 if (status == RTEMS_SUCCESSFUL) // AVF1
450 if (status == RTEMS_SUCCESSFUL) // AVF1
445 {
451 {
446 status = rtems_task_create(
452 status = rtems_task_create(
447 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
453 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
448 RTEMS_DEFAULT_MODES,
454 RTEMS_DEFAULT_MODES,
449 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
455 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
450 );
456 );
451 }
457 }
452 if (status == RTEMS_SUCCESSFUL) // PRC1
458 if (status == RTEMS_SUCCESSFUL) // PRC1
453 {
459 {
454 status = rtems_task_create(
460 status = rtems_task_create(
455 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
461 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
456 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
462 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
457 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
463 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
458 );
464 );
459 }
465 }
460 if (status == RTEMS_SUCCESSFUL) // AVF2
466 if (status == RTEMS_SUCCESSFUL) // AVF2
461 {
467 {
462 status = rtems_task_create(
468 status = rtems_task_create(
463 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
469 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
464 RTEMS_DEFAULT_MODES,
470 RTEMS_DEFAULT_MODES,
465 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
471 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
466 );
472 );
467 }
473 }
468 if (status == RTEMS_SUCCESSFUL) // PRC2
474 if (status == RTEMS_SUCCESSFUL) // PRC2
469 {
475 {
470 status = rtems_task_create(
476 status = rtems_task_create(
471 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
477 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
472 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
478 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
473 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
479 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
474 );
480 );
475 }
481 }
476
482
477 //****************
483 //****************
478 // WAVEFORM PICKER
484 // WAVEFORM PICKER
479 if (status == RTEMS_SUCCESSFUL) // WFRM
485 if (status == RTEMS_SUCCESSFUL) // WFRM
480 {
486 {
481 status = rtems_task_create(
487 status = rtems_task_create(
482 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
488 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
483 RTEMS_DEFAULT_MODES,
489 RTEMS_DEFAULT_MODES,
484 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
490 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
485 );
491 );
486 }
492 }
487 if (status == RTEMS_SUCCESSFUL) // CWF3
493 if (status == RTEMS_SUCCESSFUL) // CWF3
488 {
494 {
489 status = rtems_task_create(
495 status = rtems_task_create(
490 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
496 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
491 RTEMS_DEFAULT_MODES,
497 RTEMS_DEFAULT_MODES,
492 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
498 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
493 );
499 );
494 }
500 }
495 if (status == RTEMS_SUCCESSFUL) // CWF2
501 if (status == RTEMS_SUCCESSFUL) // CWF2
496 {
502 {
497 status = rtems_task_create(
503 status = rtems_task_create(
498 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
504 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
499 RTEMS_DEFAULT_MODES,
505 RTEMS_DEFAULT_MODES,
500 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
506 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
501 );
507 );
502 }
508 }
503 if (status == RTEMS_SUCCESSFUL) // CWF1
509 if (status == RTEMS_SUCCESSFUL) // CWF1
504 {
510 {
505 status = rtems_task_create(
511 status = rtems_task_create(
506 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
512 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
507 RTEMS_DEFAULT_MODES,
513 RTEMS_DEFAULT_MODES,
508 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
514 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
509 );
515 );
510 }
516 }
511 if (status == RTEMS_SUCCESSFUL) // SWBD
517 if (status == RTEMS_SUCCESSFUL) // SWBD
512 {
518 {
513 status = rtems_task_create(
519 status = rtems_task_create(
514 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
520 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
515 RTEMS_DEFAULT_MODES,
521 RTEMS_DEFAULT_MODES,
516 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
522 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
517 );
523 );
518 }
524 }
519
525
520 //*****
526 //*****
521 // MISC
527 // MISC
522 if (status == RTEMS_SUCCESSFUL) // LOAD
528 if (status == RTEMS_SUCCESSFUL) // LOAD
523 {
529 {
524 status = rtems_task_create(
530 status = rtems_task_create(
525 Task_name[TASKID_LOAD], TASK_PRIORITY_LOAD, RTEMS_MINIMUM_STACK_SIZE,
531 Task_name[TASKID_LOAD], TASK_PRIORITY_LOAD, RTEMS_MINIMUM_STACK_SIZE,
526 RTEMS_DEFAULT_MODES,
532 RTEMS_DEFAULT_MODES,
527 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LOAD]
533 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LOAD]
528 );
534 );
529 }
535 }
530 if (status == RTEMS_SUCCESSFUL) // DUMB
536 if (status == RTEMS_SUCCESSFUL) // DUMB
531 {
537 {
532 status = rtems_task_create(
538 status = rtems_task_create(
533 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
539 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
534 RTEMS_DEFAULT_MODES,
540 RTEMS_DEFAULT_MODES,
535 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
541 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
536 );
542 );
537 }
543 }
538 if (status == RTEMS_SUCCESSFUL) // HOUS
544 if (status == RTEMS_SUCCESSFUL) // HOUS
539 {
545 {
540 status = rtems_task_create(
546 status = rtems_task_create(
541 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
547 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
542 RTEMS_DEFAULT_MODES,
548 RTEMS_DEFAULT_MODES,
543 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS]
549 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS]
544 );
550 );
545 }
551 }
546
552
547 return status;
553 return status;
548 }
554 }
549
555
550 int start_recv_send_tasks( void )
556 int start_recv_send_tasks( void )
551 {
557 {
552 rtems_status_code status;
558 rtems_status_code status;
553
559
554 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
560 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
555 if (status!=RTEMS_SUCCESSFUL) {
561 if (status!=RTEMS_SUCCESSFUL) {
556 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
562 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
557 }
563 }
558
564
559 if (status == RTEMS_SUCCESSFUL) // SEND
565 if (status == RTEMS_SUCCESSFUL) // SEND
560 {
566 {
561 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
567 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
562 if (status!=RTEMS_SUCCESSFUL) {
568 if (status!=RTEMS_SUCCESSFUL) {
563 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
569 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
564 }
570 }
565 }
571 }
566
572
567 return status;
573 return status;
568 }
574 }
569
575
570 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
576 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
571 {
577 {
572 /** This function starts all RTEMS tasks used in the software.
578 /** This function starts all RTEMS tasks used in the software.
573 *
579 *
574 * @return RTEMS directive status codes:
580 * @return RTEMS directive status codes:
575 * - RTEMS_SUCCESSFUL - ask started successfully
581 * - RTEMS_SUCCESSFUL - ask started successfully
576 * - RTEMS_INVALID_ADDRESS - invalid task entry point
582 * - RTEMS_INVALID_ADDRESS - invalid task entry point
577 * - RTEMS_INVALID_ID - invalid task id
583 * - RTEMS_INVALID_ID - invalid task id
578 * - RTEMS_INCORRECT_STATE - task not in the dormant state
584 * - RTEMS_INCORRECT_STATE - task not in the dormant state
579 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
585 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
580 *
586 *
581 */
587 */
582 // starts all the tasks fot eh flight software
588 // starts all the tasks fot eh flight software
583
589
584 rtems_status_code status;
590 rtems_status_code status;
585
591
586 //**********
592 //**********
587 // SPACEWIRE
593 // SPACEWIRE
588 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
594 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
589 if (status!=RTEMS_SUCCESSFUL) {
595 if (status!=RTEMS_SUCCESSFUL) {
590 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
596 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
591 }
597 }
592
598
593 if (status == RTEMS_SUCCESSFUL) // LINK
599 if (status == RTEMS_SUCCESSFUL) // LINK
594 {
600 {
595 status = rtems_task_start( Task_id[TASKID_LINK], link_task, 1 );
601 status = rtems_task_start( Task_id[TASKID_LINK], link_task, 1 );
596 if (status!=RTEMS_SUCCESSFUL) {
602 if (status!=RTEMS_SUCCESSFUL) {
597 BOOT_PRINTF("in INIT *** Error starting TASK_LINK\n")
603 BOOT_PRINTF("in INIT *** Error starting TASK_LINK\n")
598 }
604 }
599 }
605 }
600
606
601 if (status == RTEMS_SUCCESSFUL) // ACTN
607 if (status == RTEMS_SUCCESSFUL) // ACTN
602 {
608 {
603 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
609 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
604 if (status!=RTEMS_SUCCESSFUL) {
610 if (status!=RTEMS_SUCCESSFUL) {
605 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
611 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
606 }
612 }
607 }
613 }
608
614
609 //******************
615 //******************
610 // SPECTRAL MATRICES
616 // SPECTRAL MATRICES
611 if (status == RTEMS_SUCCESSFUL) // AVF0
617 if (status == RTEMS_SUCCESSFUL) // AVF0
612 {
618 {
613 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
619 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
614 if (status!=RTEMS_SUCCESSFUL) {
620 if (status!=RTEMS_SUCCESSFUL) {
615 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
621 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
616 }
622 }
617 }
623 }
618 if (status == RTEMS_SUCCESSFUL) // PRC0
624 if (status == RTEMS_SUCCESSFUL) // PRC0
619 {
625 {
620 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
626 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
621 if (status!=RTEMS_SUCCESSFUL) {
627 if (status!=RTEMS_SUCCESSFUL) {
622 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
628 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
623 }
629 }
624 }
630 }
625 if (status == RTEMS_SUCCESSFUL) // AVF1
631 if (status == RTEMS_SUCCESSFUL) // AVF1
626 {
632 {
627 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
633 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
628 if (status!=RTEMS_SUCCESSFUL) {
634 if (status!=RTEMS_SUCCESSFUL) {
629 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
635 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
630 }
636 }
631 }
637 }
632 if (status == RTEMS_SUCCESSFUL) // PRC1
638 if (status == RTEMS_SUCCESSFUL) // PRC1
633 {
639 {
634 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
640 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
635 if (status!=RTEMS_SUCCESSFUL) {
641 if (status!=RTEMS_SUCCESSFUL) {
636 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
642 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
637 }
643 }
638 }
644 }
639 if (status == RTEMS_SUCCESSFUL) // AVF2
645 if (status == RTEMS_SUCCESSFUL) // AVF2
640 {
646 {
641 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
647 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
642 if (status!=RTEMS_SUCCESSFUL) {
648 if (status!=RTEMS_SUCCESSFUL) {
643 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
649 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
644 }
650 }
645 }
651 }
646 if (status == RTEMS_SUCCESSFUL) // PRC2
652 if (status == RTEMS_SUCCESSFUL) // PRC2
647 {
653 {
648 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
654 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
649 if (status!=RTEMS_SUCCESSFUL) {
655 if (status!=RTEMS_SUCCESSFUL) {
650 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
656 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
651 }
657 }
652 }
658 }
653
659
654 //****************
660 //****************
655 // WAVEFORM PICKER
661 // WAVEFORM PICKER
656 if (status == RTEMS_SUCCESSFUL) // WFRM
662 if (status == RTEMS_SUCCESSFUL) // WFRM
657 {
663 {
658 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
664 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
659 if (status!=RTEMS_SUCCESSFUL) {
665 if (status!=RTEMS_SUCCESSFUL) {
660 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
666 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
661 }
667 }
662 }
668 }
663 if (status == RTEMS_SUCCESSFUL) // CWF3
669 if (status == RTEMS_SUCCESSFUL) // CWF3
664 {
670 {
665 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
671 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
666 if (status!=RTEMS_SUCCESSFUL) {
672 if (status!=RTEMS_SUCCESSFUL) {
667 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
673 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
668 }
674 }
669 }
675 }
670 if (status == RTEMS_SUCCESSFUL) // CWF2
676 if (status == RTEMS_SUCCESSFUL) // CWF2
671 {
677 {
672 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
678 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
673 if (status!=RTEMS_SUCCESSFUL) {
679 if (status!=RTEMS_SUCCESSFUL) {
674 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
680 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
675 }
681 }
676 }
682 }
677 if (status == RTEMS_SUCCESSFUL) // CWF1
683 if (status == RTEMS_SUCCESSFUL) // CWF1
678 {
684 {
679 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
685 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
680 if (status!=RTEMS_SUCCESSFUL) {
686 if (status!=RTEMS_SUCCESSFUL) {
681 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
687 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
682 }
688 }
683 }
689 }
684 if (status == RTEMS_SUCCESSFUL) // SWBD
690 if (status == RTEMS_SUCCESSFUL) // SWBD
685 {
691 {
686 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
692 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
687 if (status!=RTEMS_SUCCESSFUL) {
693 if (status!=RTEMS_SUCCESSFUL) {
688 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
694 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
689 }
695 }
690 }
696 }
691
697
692 //*****
698 //*****
693 // MISC
699 // MISC
694 if (status == RTEMS_SUCCESSFUL) // HOUS
700 if (status == RTEMS_SUCCESSFUL) // HOUS
695 {
701 {
696 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
702 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
697 if (status!=RTEMS_SUCCESSFUL) {
703 if (status!=RTEMS_SUCCESSFUL) {
698 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
704 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
699 }
705 }
700 }
706 }
701 if (status == RTEMS_SUCCESSFUL) // DUMB
707 if (status == RTEMS_SUCCESSFUL) // DUMB
702 {
708 {
703 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
709 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
704 if (status!=RTEMS_SUCCESSFUL) {
710 if (status!=RTEMS_SUCCESSFUL) {
705 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
711 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
706 }
712 }
707 }
713 }
708 if (status == RTEMS_SUCCESSFUL) // LOAD
714 if (status == RTEMS_SUCCESSFUL) // LOAD
709 {
715 {
710 status = rtems_task_start( Task_id[TASKID_LOAD], load_task, 1 );
716 status = rtems_task_start( Task_id[TASKID_LOAD], load_task, 1 );
711 if (status!=RTEMS_SUCCESSFUL) {
717 if (status!=RTEMS_SUCCESSFUL) {
712 BOOT_PRINTF("in INIT *** Error starting TASK_LOAD\n")
718 BOOT_PRINTF("in INIT *** Error starting TASK_LOAD\n")
713 }
719 }
714 }
720 }
715
721
716 return status;
722 return status;
717 }
723 }
718
724
719 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
725 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
720 {
726 {
721 rtems_status_code status_recv;
727 rtems_status_code status_recv;
722 rtems_status_code status_send;
728 rtems_status_code status_send;
723 rtems_status_code status_q_p0;
729 rtems_status_code status_q_p0;
724 rtems_status_code status_q_p1;
730 rtems_status_code status_q_p1;
725 rtems_status_code status_q_p2;
731 rtems_status_code status_q_p2;
726 rtems_status_code ret;
732 rtems_status_code ret;
727 rtems_id queue_id;
733 rtems_id queue_id;
728
734
729 //****************************************
735 //****************************************
730 // create the queue for handling valid TCs
736 // create the queue for handling valid TCs
731 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
737 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
732 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
738 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
733 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
739 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
734 if ( status_recv != RTEMS_SUCCESSFUL ) {
740 if ( status_recv != RTEMS_SUCCESSFUL ) {
735 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
741 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
736 }
742 }
737
743
738 //************************************************
744 //************************************************
739 // create the queue for handling TM packet sending
745 // create the queue for handling TM packet sending
740 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
746 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
741 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
747 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
742 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
748 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
743 if ( status_send != RTEMS_SUCCESSFUL ) {
749 if ( status_send != RTEMS_SUCCESSFUL ) {
744 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
750 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
745 }
751 }
746
752
747 //*****************************************************************************
753 //*****************************************************************************
748 // create the queue for handling averaged spectral matrices for processing @ f0
754 // create the queue for handling averaged spectral matrices for processing @ f0
749 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
755 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
750 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
756 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
751 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
757 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
752 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
758 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
753 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
759 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
754 }
760 }
755
761
756 //*****************************************************************************
762 //*****************************************************************************
757 // create the queue for handling averaged spectral matrices for processing @ f1
763 // create the queue for handling averaged spectral matrices for processing @ f1
758 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
764 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
759 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
765 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
760 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
766 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
761 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
767 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
762 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
768 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
763 }
769 }
764
770
765 //*****************************************************************************
771 //*****************************************************************************
766 // create the queue for handling averaged spectral matrices for processing @ f2
772 // create the queue for handling averaged spectral matrices for processing @ f2
767 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
773 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
768 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
774 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
769 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
775 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
770 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
776 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
771 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
777 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
772 }
778 }
773
779
774 if ( status_recv != RTEMS_SUCCESSFUL )
780 if ( status_recv != RTEMS_SUCCESSFUL )
775 {
781 {
776 ret = status_recv;
782 ret = status_recv;
777 }
783 }
778 else if( status_send != RTEMS_SUCCESSFUL )
784 else if( status_send != RTEMS_SUCCESSFUL )
779 {
785 {
780 ret = status_send;
786 ret = status_send;
781 }
787 }
782 else if( status_q_p0 != RTEMS_SUCCESSFUL )
788 else if( status_q_p0 != RTEMS_SUCCESSFUL )
783 {
789 {
784 ret = status_q_p0;
790 ret = status_q_p0;
785 }
791 }
786 else if( status_q_p1 != RTEMS_SUCCESSFUL )
792 else if( status_q_p1 != RTEMS_SUCCESSFUL )
787 {
793 {
788 ret = status_q_p1;
794 ret = status_q_p1;
789 }
795 }
790 else
796 else
791 {
797 {
792 ret = status_q_p2;
798 ret = status_q_p2;
793 }
799 }
794
800
795 return ret;
801 return ret;
796 }
802 }
797
803
798 rtems_status_code create_timecode_timer( void )
804 rtems_status_code create_timecode_timer( void )
799 {
805 {
800 rtems_status_code status;
806 rtems_status_code status;
801
807
802 status = rtems_timer_create( timecode_timer_name, &timecode_timer_id );
808 status = rtems_timer_create( timecode_timer_name, &timecode_timer_id );
803
809
804 if ( status != RTEMS_SUCCESSFUL )
810 if ( status != RTEMS_SUCCESSFUL )
805 {
811 {
806 PRINTF1("in create_timer_timecode *** ERR creating SPTC timer, %d\n", status)
812 PRINTF1("in create_timer_timecode *** ERR creating SPTC timer, %d\n", status)
807 }
813 }
808 else
814 else
809 {
815 {
810 PRINTF("in create_timer_timecode *** OK creating SPTC timer\n")
816 PRINTF("in create_timer_timecode *** OK creating SPTC timer\n")
811 }
817 }
812
818
813 return status;
819 return status;
814 }
820 }
815
821
816 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
822 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
817 {
823 {
818 rtems_status_code status;
824 rtems_status_code status;
819 rtems_name queue_name;
825 rtems_name queue_name;
820
826
821 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
827 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
822
828
823 status = rtems_message_queue_ident( queue_name, 0, queue_id );
829 status = rtems_message_queue_ident( queue_name, 0, queue_id );
824
830
825 return status;
831 return status;
826 }
832 }
827
833
828 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
834 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
829 {
835 {
830 rtems_status_code status;
836 rtems_status_code status;
831 rtems_name queue_name;
837 rtems_name queue_name;
832
838
833 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
839 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
834
840
835 status = rtems_message_queue_ident( queue_name, 0, queue_id );
841 status = rtems_message_queue_ident( queue_name, 0, queue_id );
836
842
837 return status;
843 return status;
838 }
844 }
839
845
840 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
846 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
841 {
847 {
842 rtems_status_code status;
848 rtems_status_code status;
843 rtems_name queue_name;
849 rtems_name queue_name;
844
850
845 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
851 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
846
852
847 status = rtems_message_queue_ident( queue_name, 0, queue_id );
853 status = rtems_message_queue_ident( queue_name, 0, queue_id );
848
854
849 return status;
855 return status;
850 }
856 }
851
857
852 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
858 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
853 {
859 {
854 rtems_status_code status;
860 rtems_status_code status;
855 rtems_name queue_name;
861 rtems_name queue_name;
856
862
857 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
863 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
858
864
859 status = rtems_message_queue_ident( queue_name, 0, queue_id );
865 status = rtems_message_queue_ident( queue_name, 0, queue_id );
860
866
861 return status;
867 return status;
862 }
868 }
863
869
864 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
870 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
865 {
871 {
866 rtems_status_code status;
872 rtems_status_code status;
867 rtems_name queue_name;
873 rtems_name queue_name;
868
874
869 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
875 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
870
876
871 status = rtems_message_queue_ident( queue_name, 0, queue_id );
877 status = rtems_message_queue_ident( queue_name, 0, queue_id );
872
878
873 return status;
879 return status;
874 }
880 }
875
881
876 void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max )
882 void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max )
877 {
883 {
878 u_int32_t count;
884 u_int32_t count;
879 rtems_status_code status;
885 rtems_status_code status;
880
886
881 status = rtems_message_queue_get_number_pending( queue_id, &count );
887 status = rtems_message_queue_get_number_pending( queue_id, &count );
882
888
883 count = count + 1;
889 count = count + 1;
884
890
885 if (status != RTEMS_SUCCESSFUL)
891 if (status != RTEMS_SUCCESSFUL)
886 {
892 {
887 PRINTF1("in update_queue_max_count *** ERR = %d\n", status)
893 PRINTF1("in update_queue_max_count *** ERR = %d\n", status)
888 }
894 }
889 else
895 else
890 {
896 {
891 if (count > *fifo_size_max)
897 if (count > *fifo_size_max)
892 {
898 {
893 *fifo_size_max = count;
899 *fifo_size_max = count;
894 }
900 }
895 }
901 }
896 }
902 }
897
903
898 void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize )
904 void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize )
899 {
905 {
900 unsigned char i;
906 unsigned char i;
901
907
902 //***************
908 //***************
903 // BUFFER ADDRESS
909 // BUFFER ADDRESS
904 for(i=0; i<nbNodes; i++)
910 for(i=0; i<nbNodes; i++)
905 {
911 {
906 ring[i].coarseTime = 0xffffffff;
912 ring[i].coarseTime = 0xffffffff;
907 ring[i].fineTime = 0xffffffff;
913 ring[i].fineTime = 0xffffffff;
908 ring[i].sid = 0x00;
914 ring[i].sid = 0x00;
909 ring[i].status = 0x00;
915 ring[i].status = 0x00;
910 ring[i].buffer_address = (int) &buffer[ i * bufferSize ];
916 ring[i].buffer_address = (int) &buffer[ i * bufferSize ];
911 }
917 }
912
918
913 //*****
919 //*****
914 // NEXT
920 // NEXT
915 ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ];
921 ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ];
916 for(i=0; i<nbNodes-1; i++)
922 for(i=0; i<nbNodes-1; i++)
917 {
923 {
918 ring[i].next = (ring_node*) &ring[ i + 1 ];
924 ring[i].next = (ring_node*) &ring[ i + 1 ];
919 }
925 }
920
926
921 //*********
927 //*********
922 // PREVIOUS
928 // PREVIOUS
923 ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ];
929 ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ];
924 for(i=1; i<nbNodes; i++)
930 for(i=1; i<nbNodes; i++)
925 {
931 {
926 ring[i].previous = (ring_node*) &ring[ i - 1 ];
932 ring[i].previous = (ring_node*) &ring[ i - 1 ];
927 }
933 }
928 }
934 }
@@ -1,795 +1,786
1 /** Functions related to data processing.
1 /** Functions related to data processing.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
6 * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation.
7 *
7 *
8 */
8 */
9
9
10 #include "fsw_processing.h"
10 #include "fsw_processing.h"
11 #include "fsw_processing_globals.c"
11 #include "fsw_processing_globals.c"
12 #include "fsw_init.h"
12 #include "fsw_init.h"
13
13
14 unsigned int nb_sm_f0;
14 unsigned int nb_sm_f0;
15 unsigned int nb_sm_f0_aux_f1;
15 unsigned int nb_sm_f0_aux_f1;
16 unsigned int nb_sm_f1;
16 unsigned int nb_sm_f1;
17 unsigned int nb_sm_f0_aux_f2;
17 unsigned int nb_sm_f0_aux_f2;
18
18
19 typedef enum restartState_t
19 typedef enum restartState_t
20 {
20 {
21 WAIT_FOR_F2,
21 WAIT_FOR_F2,
22 WAIT_FOR_F1,
22 WAIT_FOR_F1,
23 WAIT_FOR_F0
23 WAIT_FOR_F0
24 } restartState;
24 } restartState;
25
25
26 //************************
26 //************************
27 // spectral matrices rings
27 // spectral matrices rings
28 ring_node sm_ring_f0[ NB_RING_NODES_SM_F0 ];
28 ring_node sm_ring_f0[ NB_RING_NODES_SM_F0 ];
29 ring_node sm_ring_f1[ NB_RING_NODES_SM_F1 ];
29 ring_node sm_ring_f1[ NB_RING_NODES_SM_F1 ];
30 ring_node sm_ring_f2[ NB_RING_NODES_SM_F2 ];
30 ring_node sm_ring_f2[ NB_RING_NODES_SM_F2 ];
31 ring_node *current_ring_node_sm_f0;
31 ring_node *current_ring_node_sm_f0;
32 ring_node *current_ring_node_sm_f1;
32 ring_node *current_ring_node_sm_f1;
33 ring_node *current_ring_node_sm_f2;
33 ring_node *current_ring_node_sm_f2;
34 ring_node *ring_node_for_averaging_sm_f0;
34 ring_node *ring_node_for_averaging_sm_f0;
35 ring_node *ring_node_for_averaging_sm_f1;
35 ring_node *ring_node_for_averaging_sm_f1;
36 ring_node *ring_node_for_averaging_sm_f2;
36 ring_node *ring_node_for_averaging_sm_f2;
37
37
38 //
38 //
39 ring_node * getRingNodeForAveraging( unsigned char frequencyChannel)
39 ring_node * getRingNodeForAveraging( unsigned char frequencyChannel)
40 {
40 {
41 ring_node *node;
41 ring_node *node;
42
42
43 node = NULL;
43 node = NULL;
44 switch ( frequencyChannel ) {
44 switch ( frequencyChannel ) {
45 case 0:
45 case 0:
46 node = ring_node_for_averaging_sm_f0;
46 node = ring_node_for_averaging_sm_f0;
47 break;
47 break;
48 case 1:
48 case 1:
49 node = ring_node_for_averaging_sm_f1;
49 node = ring_node_for_averaging_sm_f1;
50 break;
50 break;
51 case 2:
51 case 2:
52 node = ring_node_for_averaging_sm_f2;
52 node = ring_node_for_averaging_sm_f2;
53 break;
53 break;
54 default:
54 default:
55 break;
55 break;
56 }
56 }
57
57
58 return node;
58 return node;
59 }
59 }
60
60
61 //***********************************************************
61 //***********************************************************
62 // Interrupt Service Routine for spectral matrices processing
62 // Interrupt Service Routine for spectral matrices processing
63
63
64 void spectral_matrices_isr_f0( int statusReg )
64 void spectral_matrices_isr_f0( int statusReg )
65 {
65 {
66 unsigned char status;
66 unsigned char status;
67 rtems_status_code status_code;
67 rtems_status_code status_code;
68 ring_node *full_ring_node;
68 ring_node *full_ring_node;
69
69
70 status = (unsigned char) (statusReg & 0x03); // [0011] get the status_ready_matrix_f0_x bits
70 status = (unsigned char) (statusReg & 0x03); // [0011] get the status_ready_matrix_f0_x bits
71
71
72 switch(status)
72 switch(status)
73 {
73 {
74 case 0:
74 case 0:
75 break;
75 break;
76 case 3:
76 case 3:
77 // UNEXPECTED VALUE
77 // UNEXPECTED VALUE
78 spectral_matrix_regs->status = 0x03; // [0011]
78 spectral_matrix_regs->status = 0x03; // [0011]
79 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
79 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
80 break;
80 break;
81 case 1:
81 case 1:
82 full_ring_node = current_ring_node_sm_f0->previous;
82 full_ring_node = current_ring_node_sm_f0->previous;
83 full_ring_node->coarseTime = spectral_matrix_regs->f0_0_coarse_time;
83 full_ring_node->coarseTime = spectral_matrix_regs->f0_0_coarse_time;
84 full_ring_node->fineTime = spectral_matrix_regs->f0_0_fine_time;
84 full_ring_node->fineTime = spectral_matrix_regs->f0_0_fine_time;
85 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
85 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
86 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
86 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address;
87 // if there are enough ring nodes ready, wake up an AVFx task
87 // if there are enough ring nodes ready, wake up an AVFx task
88 nb_sm_f0 = nb_sm_f0 + 1;
88 nb_sm_f0 = nb_sm_f0 + 1;
89 if (nb_sm_f0 == NB_SM_BEFORE_AVF0)
89 if (nb_sm_f0 == NB_SM_BEFORE_AVF0)
90 {
90 {
91 ring_node_for_averaging_sm_f0 = full_ring_node;
91 ring_node_for_averaging_sm_f0 = full_ring_node;
92 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
92 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
93 {
93 {
94 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
94 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
95 }
95 }
96 nb_sm_f0 = 0;
96 nb_sm_f0 = 0;
97 }
97 }
98 spectral_matrix_regs->status = 0x01; // [0000 0001]
98 spectral_matrix_regs->status = 0x01; // [0000 0001]
99 break;
99 break;
100 case 2:
100 case 2:
101 full_ring_node = current_ring_node_sm_f0->previous;
101 full_ring_node = current_ring_node_sm_f0->previous;
102 full_ring_node->coarseTime = spectral_matrix_regs->f0_1_coarse_time;
102 full_ring_node->coarseTime = spectral_matrix_regs->f0_1_coarse_time;
103 full_ring_node->fineTime = spectral_matrix_regs->f0_1_fine_time;
103 full_ring_node->fineTime = spectral_matrix_regs->f0_1_fine_time;
104 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
104 current_ring_node_sm_f0 = current_ring_node_sm_f0->next;
105 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
105 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
106 // if there are enough ring nodes ready, wake up an AVFx task
106 // if there are enough ring nodes ready, wake up an AVFx task
107 nb_sm_f0 = nb_sm_f0 + 1;
107 nb_sm_f0 = nb_sm_f0 + 1;
108 if (nb_sm_f0 == NB_SM_BEFORE_AVF0)
108 if (nb_sm_f0 == NB_SM_BEFORE_AVF0)
109 {
109 {
110 ring_node_for_averaging_sm_f0 = full_ring_node;
110 ring_node_for_averaging_sm_f0 = full_ring_node;
111 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
111 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
112 {
112 {
113 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
113 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
114 }
114 }
115 nb_sm_f0 = 0;
115 nb_sm_f0 = 0;
116 }
116 }
117 spectral_matrix_regs->status = 0x02; // [0000 0010]
117 spectral_matrix_regs->status = 0x02; // [0000 0010]
118 break;
118 break;
119 }
119 }
120 }
120 }
121
121
122 void spectral_matrices_isr_f1( int statusReg )
122 void spectral_matrices_isr_f1( int statusReg )
123 {
123 {
124 rtems_status_code status_code;
124 rtems_status_code status_code;
125 unsigned char status;
125 unsigned char status;
126 ring_node *full_ring_node;
126 ring_node *full_ring_node;
127
127
128 status = (unsigned char) ((statusReg & 0x0c) >> 2); // [1100] get the status_ready_matrix_f1_x bits
128 status = (unsigned char) ((statusReg & 0x0c) >> 2); // [1100] get the status_ready_matrix_f1_x bits
129
129
130 switch(status)
130 switch(status)
131 {
131 {
132 case 0:
132 case 0:
133 break;
133 break;
134 case 3:
134 case 3:
135 // UNEXPECTED VALUE
135 // UNEXPECTED VALUE
136 spectral_matrix_regs->status = 0xc0; // [1100]
136 spectral_matrix_regs->status = 0xc0; // [1100]
137 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
137 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
138 break;
138 break;
139 case 1:
139 case 1:
140 full_ring_node = current_ring_node_sm_f1->previous;
140 full_ring_node = current_ring_node_sm_f1->previous;
141 full_ring_node->coarseTime = spectral_matrix_regs->f1_0_coarse_time;
141 full_ring_node->coarseTime = spectral_matrix_regs->f1_0_coarse_time;
142 full_ring_node->fineTime = spectral_matrix_regs->f1_0_fine_time;
142 full_ring_node->fineTime = spectral_matrix_regs->f1_0_fine_time;
143 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
143 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
144 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
144 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address;
145 // if there are enough ring nodes ready, wake up an AVFx task
145 // if there are enough ring nodes ready, wake up an AVFx task
146 nb_sm_f1 = nb_sm_f1 + 1;
146 nb_sm_f1 = nb_sm_f1 + 1;
147 if (nb_sm_f1 == NB_SM_BEFORE_AVF1)
147 if (nb_sm_f1 == NB_SM_BEFORE_AVF1)
148 {
148 {
149 ring_node_for_averaging_sm_f1 = full_ring_node;
149 ring_node_for_averaging_sm_f1 = full_ring_node;
150 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
150 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
151 {
151 {
152 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
152 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
153 }
153 }
154 nb_sm_f1 = 0;
154 nb_sm_f1 = 0;
155 }
155 }
156 spectral_matrix_regs->status = 0x04; // [0000 0100]
156 spectral_matrix_regs->status = 0x04; // [0000 0100]
157 break;
157 break;
158 case 2:
158 case 2:
159 full_ring_node = current_ring_node_sm_f1->previous;
159 full_ring_node = current_ring_node_sm_f1->previous;
160 full_ring_node->coarseTime = spectral_matrix_regs->f1_1_coarse_time;
160 full_ring_node->coarseTime = spectral_matrix_regs->f1_1_coarse_time;
161 full_ring_node->fineTime = spectral_matrix_regs->f1_1_fine_time;
161 full_ring_node->fineTime = spectral_matrix_regs->f1_1_fine_time;
162 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
162 current_ring_node_sm_f1 = current_ring_node_sm_f1->next;
163 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
163 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
164 // if there are enough ring nodes ready, wake up an AVFx task
164 // if there are enough ring nodes ready, wake up an AVFx task
165 nb_sm_f1 = nb_sm_f1 + 1;
165 nb_sm_f1 = nb_sm_f1 + 1;
166 if (nb_sm_f1 == NB_SM_BEFORE_AVF1)
166 if (nb_sm_f1 == NB_SM_BEFORE_AVF1)
167 {
167 {
168 ring_node_for_averaging_sm_f1 = full_ring_node;
168 ring_node_for_averaging_sm_f1 = full_ring_node;
169 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
169 if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
170 {
170 {
171 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
171 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
172 }
172 }
173 nb_sm_f1 = 0;
173 nb_sm_f1 = 0;
174 }
174 }
175 spectral_matrix_regs->status = 0x08; // [1000 0000]
175 spectral_matrix_regs->status = 0x08; // [1000 0000]
176 break;
176 break;
177 }
177 }
178 }
178 }
179
179
180 void spectral_matrices_isr_f2( int statusReg )
180 void spectral_matrices_isr_f2( int statusReg )
181 {
181 {
182 unsigned char status;
182 unsigned char status;
183 rtems_status_code status_code;
183 rtems_status_code status_code;
184
184
185 status = (unsigned char) ((statusReg & 0x30) >> 4); // [0011 0000] get the status_ready_matrix_f2_x bits
185 status = (unsigned char) ((statusReg & 0x30) >> 4); // [0011 0000] get the status_ready_matrix_f2_x bits
186
186
187 switch(status)
187 switch(status)
188 {
188 {
189 case 0:
189 case 0:
190 break;
190 break;
191 case 3:
191 case 3:
192 // UNEXPECTED VALUE
192 // UNEXPECTED VALUE
193 spectral_matrix_regs->status = 0x30; // [0011 0000]
193 spectral_matrix_regs->status = 0x30; // [0011 0000]
194 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
194 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 );
195 break;
195 break;
196 case 1:
196 case 1:
197 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous;
197 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous;
198 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
198 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
199 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time;
199 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time;
200 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time;
200 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time;
201 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
201 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address;
202 spectral_matrix_regs->status = 0x10; // [0001 0000]
202 spectral_matrix_regs->status = 0x10; // [0001 0000]
203 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
203 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
204 {
204 {
205 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
205 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
206 }
206 }
207 break;
207 break;
208 case 2:
208 case 2:
209 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous;
209 ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous;
210 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
210 current_ring_node_sm_f2 = current_ring_node_sm_f2->next;
211 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time;
211 ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time;
212 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time;
212 ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time;
213 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
213 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
214 spectral_matrix_regs->status = 0x20; // [0010 0000]
214 spectral_matrix_regs->status = 0x20; // [0010 0000]
215 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
215 if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
216 {
216 {
217 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
217 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
218 }
218 }
219 break;
219 break;
220 }
220 }
221 }
221 }
222
222
223 void spectral_matrix_isr_error_handler( int statusReg )
223 void spectral_matrix_isr_error_handler( int statusReg )
224 {
224 {
225 // STATUS REGISTER
225 // STATUS REGISTER
226 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
226 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
227 // 10 9 8
227 // 10 9 8
228 // buffer_full ** [bad_component_err] ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
228 // buffer_full ** [bad_component_err] ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
229 // 7 6 5 4 3 2 1 0
229 // 7 6 5 4 3 2 1 0
230 // [bad_component_err] not defined in the last version of the VHDL code
230 // [bad_component_err] not defined in the last version of the VHDL code
231
231
232 rtems_status_code status_code;
232 rtems_status_code status_code;
233
233
234 //***************************************************
234 //***************************************************
235 // the ASM status register is copied in the HK packet
235 // the ASM status register is copied in the HK packet
236 housekeeping_packet.hk_lfr_vhdl_aa_sm = (unsigned char) (statusReg & 0x780 >> 7); // [0111 1000 0000]
236 housekeeping_packet.hk_lfr_vhdl_aa_sm = (unsigned char) (statusReg & 0x780 >> 7); // [0111 1000 0000]
237
237
238 if (statusReg & 0x7c0) // [0111 1100 0000]
238 if (statusReg & 0x7c0) // [0111 1100 0000]
239 {
239 {
240 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
240 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 );
241 }
241 }
242
242
243 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x7c0;
243 spectral_matrix_regs->status = spectral_matrix_regs->status & 0x7c0;
244
244
245 }
245 }
246
246
247 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
247 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
248 {
248 {
249 // STATUS REGISTER
249 // STATUS REGISTER
250 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
250 // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0)
251 // 10 9 8
251 // 10 9 8
252 // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
252 // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0
253 // 7 6 5 4 3 2 1 0
253 // 7 6 5 4 3 2 1 0
254
254
255 int statusReg;
255 int statusReg;
256
256
257 static restartState state = WAIT_FOR_F2;
257 static restartState state = WAIT_FOR_F2;
258
258
259 statusReg = spectral_matrix_regs->status;
259 statusReg = spectral_matrix_regs->status;
260
260
261 if (thisIsAnASMRestart == 0)
261 if (thisIsAnASMRestart == 0)
262 { // this is not a restart sequence, process incoming matrices normally
262 { // this is not a restart sequence, process incoming matrices normally
263 spectral_matrices_isr_f0( statusReg );
263 spectral_matrices_isr_f0( statusReg );
264
264
265 spectral_matrices_isr_f1( statusReg );
265 spectral_matrices_isr_f1( statusReg );
266
266
267 spectral_matrices_isr_f2( statusReg );
267 spectral_matrices_isr_f2( statusReg );
268 }
268 }
269 else
269 else
270 { // a restart sequence has to be launched
270 { // a restart sequence has to be launched
271 switch (state) {
271 switch (state) {
272 case WAIT_FOR_F2:
272 case WAIT_FOR_F2:
273 if ((statusReg & 0x30) != 0x00) // [0011 0000] check the status_ready_matrix_f2_x bits
273 if ((statusReg & 0x30) != 0x00) // [0011 0000] check the status_ready_matrix_f2_x bits
274 {
274 {
275 state = WAIT_FOR_F1;
275 state = WAIT_FOR_F1;
276 }
276 }
277 break;
277 break;
278 case WAIT_FOR_F1:
278 case WAIT_FOR_F1:
279 if ((statusReg & 0x0c) != 0x00) // [0000 1100] check the status_ready_matrix_f1_x bits
279 if ((statusReg & 0x0c) != 0x00) // [0000 1100] check the status_ready_matrix_f1_x bits
280 {
280 {
281 state = WAIT_FOR_F0;
281 state = WAIT_FOR_F0;
282 }
282 }
283 break;
283 break;
284 case WAIT_FOR_F0:
284 case WAIT_FOR_F0:
285 if ((statusReg & 0x03) != 0x00) // [0000 0011] check the status_ready_matrix_f0_x bits
285 if ((statusReg & 0x03) != 0x00) // [0000 0011] check the status_ready_matrix_f0_x bits
286 {
286 {
287 state = WAIT_FOR_F2;
287 state = WAIT_FOR_F2;
288 thisIsAnASMRestart = 0;
288 thisIsAnASMRestart = 0;
289 }
289 }
290 break;
290 break;
291 default:
291 default:
292 break;
292 break;
293 }
293 }
294 reset_sm_status();
294 reset_sm_status();
295 }
295 }
296
296
297 spectral_matrix_isr_error_handler( statusReg );
297 spectral_matrix_isr_error_handler( statusReg );
298
298
299 }
299 }
300
300
301 //******************
301 //******************
302 // Spectral Matrices
302 // Spectral Matrices
303
303
304 void reset_nb_sm( void )
304 void reset_nb_sm( void )
305 {
305 {
306 nb_sm_f0 = 0;
306 nb_sm_f0 = 0;
307 nb_sm_f0_aux_f1 = 0;
307 nb_sm_f0_aux_f1 = 0;
308 nb_sm_f0_aux_f2 = 0;
308 nb_sm_f0_aux_f2 = 0;
309
309
310 nb_sm_f1 = 0;
310 nb_sm_f1 = 0;
311 }
311 }
312
312
313 void SM_init_rings( void )
313 void SM_init_rings( void )
314 {
314 {
315 init_ring( sm_ring_f0, NB_RING_NODES_SM_F0, sm_f0, TOTAL_SIZE_SM );
315 init_ring( sm_ring_f0, NB_RING_NODES_SM_F0, sm_f0, TOTAL_SIZE_SM );
316 init_ring( sm_ring_f1, NB_RING_NODES_SM_F1, sm_f1, TOTAL_SIZE_SM );
316 init_ring( sm_ring_f1, NB_RING_NODES_SM_F1, sm_f1, TOTAL_SIZE_SM );
317 init_ring( sm_ring_f2, NB_RING_NODES_SM_F2, sm_f2, TOTAL_SIZE_SM );
317 init_ring( sm_ring_f2, NB_RING_NODES_SM_F2, sm_f2, TOTAL_SIZE_SM );
318
318
319 DEBUG_PRINTF1("sm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
319 DEBUG_PRINTF1("sm_ring_f0 @%x\n", (unsigned int) sm_ring_f0)
320 DEBUG_PRINTF1("sm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
320 DEBUG_PRINTF1("sm_ring_f1 @%x\n", (unsigned int) sm_ring_f1)
321 DEBUG_PRINTF1("sm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
321 DEBUG_PRINTF1("sm_ring_f2 @%x\n", (unsigned int) sm_ring_f2)
322 DEBUG_PRINTF1("sm_f0 @%x\n", (unsigned int) sm_f0)
322 DEBUG_PRINTF1("sm_f0 @%x\n", (unsigned int) sm_f0)
323 DEBUG_PRINTF1("sm_f1 @%x\n", (unsigned int) sm_f1)
323 DEBUG_PRINTF1("sm_f1 @%x\n", (unsigned int) sm_f1)
324 DEBUG_PRINTF1("sm_f2 @%x\n", (unsigned int) sm_f2)
324 DEBUG_PRINTF1("sm_f2 @%x\n", (unsigned int) sm_f2)
325 }
325 }
326
326
327 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
327 void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes )
328 {
328 {
329 unsigned char i;
329 unsigned char i;
330
330
331 ring[ nbNodes - 1 ].next
331 ring[ nbNodes - 1 ].next
332 = (ring_node_asm*) &ring[ 0 ];
332 = (ring_node_asm*) &ring[ 0 ];
333
333
334 for(i=0; i<nbNodes-1; i++)
334 for(i=0; i<nbNodes-1; i++)
335 {
335 {
336 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
336 ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ];
337 }
337 }
338 }
338 }
339
339
340 void SM_reset_current_ring_nodes( void )
340 void SM_reset_current_ring_nodes( void )
341 {
341 {
342 current_ring_node_sm_f0 = sm_ring_f0[0].next;
342 current_ring_node_sm_f0 = sm_ring_f0[0].next;
343 current_ring_node_sm_f1 = sm_ring_f1[0].next;
343 current_ring_node_sm_f1 = sm_ring_f1[0].next;
344 current_ring_node_sm_f2 = sm_ring_f2[0].next;
344 current_ring_node_sm_f2 = sm_ring_f2[0].next;
345
345
346 ring_node_for_averaging_sm_f0 = NULL;
346 ring_node_for_averaging_sm_f0 = NULL;
347 ring_node_for_averaging_sm_f1 = NULL;
347 ring_node_for_averaging_sm_f1 = NULL;
348 ring_node_for_averaging_sm_f2 = NULL;
348 ring_node_for_averaging_sm_f2 = NULL;
349 }
349 }
350
350
351 //*****************
351 //*****************
352 // Basic Parameters
352 // Basic Parameters
353
353
354 void BP_init_header( bp_packet *packet,
354 void BP_init_header( bp_packet *packet,
355 unsigned int apid, unsigned char sid,
355 unsigned int apid, unsigned char sid,
356 unsigned int packetLength, unsigned char blkNr )
356 unsigned int packetLength, unsigned char blkNr )
357 {
357 {
358 packet->targetLogicalAddress = CCSDS_DESTINATION_ID;
358 packet->targetLogicalAddress = CCSDS_DESTINATION_ID;
359 packet->protocolIdentifier = CCSDS_PROTOCOLE_ID;
359 packet->protocolIdentifier = CCSDS_PROTOCOLE_ID;
360 packet->reserved = 0x00;
360 packet->reserved = 0x00;
361 packet->userApplication = CCSDS_USER_APP;
361 packet->userApplication = CCSDS_USER_APP;
362 packet->packetID[0] = (unsigned char) (apid >> 8);
362 packet->packetID[0] = (unsigned char) (apid >> 8);
363 packet->packetID[1] = (unsigned char) (apid);
363 packet->packetID[1] = (unsigned char) (apid);
364 packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
364 packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
365 packet->packetSequenceControl[1] = 0x00;
365 packet->packetSequenceControl[1] = 0x00;
366 packet->packetLength[0] = (unsigned char) (packetLength >> 8);
366 packet->packetLength[0] = (unsigned char) (packetLength >> 8);
367 packet->packetLength[1] = (unsigned char) (packetLength);
367 packet->packetLength[1] = (unsigned char) (packetLength);
368 // DATA FIELD HEADER
368 // DATA FIELD HEADER
369 packet->spare1_pusVersion_spare2 = 0x10;
369 packet->spare1_pusVersion_spare2 = 0x10;
370 packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type
370 packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type
371 packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype
371 packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype
372 packet->destinationID = TM_DESTINATION_ID_GROUND;
372 packet->destinationID = TM_DESTINATION_ID_GROUND;
373 packet->time[0] = 0x00;
373 packet->time[0] = 0x00;
374 packet->time[1] = 0x00;
374 packet->time[1] = 0x00;
375 packet->time[2] = 0x00;
375 packet->time[2] = 0x00;
376 packet->time[3] = 0x00;
376 packet->time[3] = 0x00;
377 packet->time[4] = 0x00;
377 packet->time[4] = 0x00;
378 packet->time[5] = 0x00;
378 packet->time[5] = 0x00;
379 // AUXILIARY DATA HEADER
379 // AUXILIARY DATA HEADER
380 packet->sid = sid;
380 packet->sid = sid;
381 packet->pa_bia_status_info = 0x00;
381 packet->pa_bia_status_info = 0x00;
382 packet->sy_lfr_common_parameters_spare = 0x00;
382 packet->sy_lfr_common_parameters_spare = 0x00;
383 packet->sy_lfr_common_parameters = 0x00;
383 packet->sy_lfr_common_parameters = 0x00;
384 packet->acquisitionTime[0] = 0x00;
384 packet->acquisitionTime[0] = 0x00;
385 packet->acquisitionTime[1] = 0x00;
385 packet->acquisitionTime[1] = 0x00;
386 packet->acquisitionTime[2] = 0x00;
386 packet->acquisitionTime[2] = 0x00;
387 packet->acquisitionTime[3] = 0x00;
387 packet->acquisitionTime[3] = 0x00;
388 packet->acquisitionTime[4] = 0x00;
388 packet->acquisitionTime[4] = 0x00;
389 packet->acquisitionTime[5] = 0x00;
389 packet->acquisitionTime[5] = 0x00;
390 packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
390 packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
391 packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
391 packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
392 }
392 }
393
393
394 void BP_init_header_with_spare( bp_packet_with_spare *packet,
394 void BP_init_header_with_spare( bp_packet_with_spare *packet,
395 unsigned int apid, unsigned char sid,
395 unsigned int apid, unsigned char sid,
396 unsigned int packetLength , unsigned char blkNr)
396 unsigned int packetLength , unsigned char blkNr)
397 {
397 {
398 packet->targetLogicalAddress = CCSDS_DESTINATION_ID;
398 packet->targetLogicalAddress = CCSDS_DESTINATION_ID;
399 packet->protocolIdentifier = CCSDS_PROTOCOLE_ID;
399 packet->protocolIdentifier = CCSDS_PROTOCOLE_ID;
400 packet->reserved = 0x00;
400 packet->reserved = 0x00;
401 packet->userApplication = CCSDS_USER_APP;
401 packet->userApplication = CCSDS_USER_APP;
402 packet->packetID[0] = (unsigned char) (apid >> 8);
402 packet->packetID[0] = (unsigned char) (apid >> 8);
403 packet->packetID[1] = (unsigned char) (apid);
403 packet->packetID[1] = (unsigned char) (apid);
404 packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
404 packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
405 packet->packetSequenceControl[1] = 0x00;
405 packet->packetSequenceControl[1] = 0x00;
406 packet->packetLength[0] = (unsigned char) (packetLength >> 8);
406 packet->packetLength[0] = (unsigned char) (packetLength >> 8);
407 packet->packetLength[1] = (unsigned char) (packetLength);
407 packet->packetLength[1] = (unsigned char) (packetLength);
408 // DATA FIELD HEADER
408 // DATA FIELD HEADER
409 packet->spare1_pusVersion_spare2 = 0x10;
409 packet->spare1_pusVersion_spare2 = 0x10;
410 packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type
410 packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type
411 packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype
411 packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype
412 packet->destinationID = TM_DESTINATION_ID_GROUND;
412 packet->destinationID = TM_DESTINATION_ID_GROUND;
413 // AUXILIARY DATA HEADER
413 // AUXILIARY DATA HEADER
414 packet->sid = sid;
414 packet->sid = sid;
415 packet->pa_bia_status_info = 0x00;
415 packet->pa_bia_status_info = 0x00;
416 packet->sy_lfr_common_parameters_spare = 0x00;
416 packet->sy_lfr_common_parameters_spare = 0x00;
417 packet->sy_lfr_common_parameters = 0x00;
417 packet->sy_lfr_common_parameters = 0x00;
418 packet->time[0] = 0x00;
418 packet->time[0] = 0x00;
419 packet->time[0] = 0x00;
419 packet->time[0] = 0x00;
420 packet->time[0] = 0x00;
420 packet->time[0] = 0x00;
421 packet->time[0] = 0x00;
421 packet->time[0] = 0x00;
422 packet->time[0] = 0x00;
422 packet->time[0] = 0x00;
423 packet->time[0] = 0x00;
423 packet->time[0] = 0x00;
424 packet->source_data_spare = 0x00;
424 packet->source_data_spare = 0x00;
425 packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
425 packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB
426 packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
426 packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB
427 }
427 }
428
428
429 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
429 void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
430 {
430 {
431 rtems_status_code status;
431 rtems_status_code status;
432
432
433 // SEND PACKET
433 // SEND PACKET
434 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
434 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
435 if (status != RTEMS_SUCCESSFUL)
435 if (status != RTEMS_SUCCESSFUL)
436 {
436 {
437 PRINTF1("ERR *** in BP_send *** ERR %d\n", (int) status)
437 PRINTF1("ERR *** in BP_send *** ERR %d\n", (int) status)
438 }
438 }
439 }
439 }
440
440
441 void BP_send_s1_s2(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
441 void BP_send_s1_s2(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid )
442 {
442 {
443 /** This function is used to send the BP paquets when needed.
443 /** This function is used to send the BP paquets when needed.
444 *
444 *
445 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
445 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
446 *
446 *
447 * @return void
447 * @return void
448 *
448 *
449 * SBM1 and SBM2 paquets are sent depending on the type of the LFR mode transition.
449 * SBM1 and SBM2 paquets are sent depending on the type of the LFR mode transition.
450 * BURST paquets are sent everytime.
450 * BURST paquets are sent everytime.
451 *
451 *
452 */
452 */
453
453
454 rtems_status_code status;
454 rtems_status_code status;
455
455
456 // SEND PACKET
456 // SEND PACKET
457 // before lastValidTransitionDate, the data are drops even if they are ready
457 // before lastValidTransitionDate, the data are drops even if they are ready
458 // this guarantees that no SBM packets will be received before the requested enter mode time
458 // this guarantees that no SBM packets will be received before the requested enter mode time
459 if ( time_management_regs->coarse_time >= lastValidEnterModeTime)
459 if ( time_management_regs->coarse_time >= lastValidEnterModeTime)
460 {
460 {
461 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
461 status = rtems_message_queue_send( queue_id, data, nbBytesToSend);
462 if (status != RTEMS_SUCCESSFUL)
462 if (status != RTEMS_SUCCESSFUL)
463 {
463 {
464 PRINTF1("ERR *** in BP_send *** ERR %d\n", (int) status)
464 PRINTF1("ERR *** in BP_send *** ERR %d\n", (int) status)
465 }
465 }
466 }
466 }
467 }
467 }
468
468
469 //******************
469 //******************
470 // general functions
470 // general functions
471
471
472 void reset_sm_status( void )
472 void reset_sm_status( void )
473 {
473 {
474 // error
474 // error
475 // 10 --------------- 9 ---------------- 8 ---------------- 7 ---------
475 // 10 --------------- 9 ---------------- 8 ---------------- 7 ---------
476 // input_fif0_write_2 input_fifo_write_1 input_fifo_write_0 buffer_full
476 // input_fif0_write_2 input_fifo_write_1 input_fifo_write_0 buffer_full
477 // ---------- 5 -- 4 -- 3 -- 2 -- 1 -- 0 --
477 // ---------- 5 -- 4 -- 3 -- 2 -- 1 -- 0 --
478 // ready bits f2_1 f2_0 f1_1 f1_1 f0_1 f0_0
478 // ready bits f2_1 f2_0 f1_1 f1_1 f0_1 f0_0
479
479
480 spectral_matrix_regs->status = 0x7ff; // [0111 1111 1111]
480 spectral_matrix_regs->status = 0x7ff; // [0111 1111 1111]
481 }
481 }
482
482
483 void reset_spectral_matrix_regs( void )
483 void reset_spectral_matrix_regs( void )
484 {
484 {
485 /** This function resets the spectral matrices module registers.
485 /** This function resets the spectral matrices module registers.
486 *
486 *
487 * The registers affected by this function are located at the following offset addresses:
487 * The registers affected by this function are located at the following offset addresses:
488 *
488 *
489 * - 0x00 config
489 * - 0x00 config
490 * - 0x04 status
490 * - 0x04 status
491 * - 0x08 matrixF0_Address0
491 * - 0x08 matrixF0_Address0
492 * - 0x10 matrixFO_Address1
492 * - 0x10 matrixFO_Address1
493 * - 0x14 matrixF1_Address
493 * - 0x14 matrixF1_Address
494 * - 0x18 matrixF2_Address
494 * - 0x18 matrixF2_Address
495 *
495 *
496 */
496 */
497
497
498 set_sm_irq_onError( 0 );
498 set_sm_irq_onError( 0 );
499
499
500 set_sm_irq_onNewMatrix( 0 );
500 set_sm_irq_onNewMatrix( 0 );
501
501
502 reset_sm_status();
502 reset_sm_status();
503
503
504 // F1
504 // F1
505 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
505 spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address;
506 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
506 spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address;
507 // F2
507 // F2
508 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address;
508 spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address;
509 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
509 spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address;
510 // F3
510 // F3
511 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address;
511 spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address;
512 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
512 spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address;
513
513
514 spectral_matrix_regs->matrix_length = 0xc8; // 25 * 128 / 16 = 200 = 0xc8
514 spectral_matrix_regs->matrix_length = 0xc8; // 25 * 128 / 16 = 200 = 0xc8
515 }
515 }
516
516
517 void set_time( unsigned char *time, unsigned char * timeInBuffer )
517 void set_time( unsigned char *time, unsigned char * timeInBuffer )
518 {
518 {
519 time[0] = timeInBuffer[0];
519 time[0] = timeInBuffer[0];
520 time[1] = timeInBuffer[1];
520 time[1] = timeInBuffer[1];
521 time[2] = timeInBuffer[2];
521 time[2] = timeInBuffer[2];
522 time[3] = timeInBuffer[3];
522 time[3] = timeInBuffer[3];
523 time[4] = timeInBuffer[6];
523 time[4] = timeInBuffer[6];
524 time[5] = timeInBuffer[7];
524 time[5] = timeInBuffer[7];
525 }
525 }
526
526
527 unsigned long long int get_acquisition_time( unsigned char *timePtr )
527 unsigned long long int get_acquisition_time( unsigned char *timePtr )
528 {
528 {
529 unsigned long long int acquisitionTimeAslong;
529 unsigned long long int acquisitionTimeAslong;
530 acquisitionTimeAslong = 0x00;
530 acquisitionTimeAslong = 0x00;
531 acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
531 acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit
532 + ( (unsigned long long int) timePtr[1] << 32 )
532 + ( (unsigned long long int) timePtr[1] << 32 )
533 + ( (unsigned long long int) timePtr[2] << 24 )
533 + ( (unsigned long long int) timePtr[2] << 24 )
534 + ( (unsigned long long int) timePtr[3] << 16 )
534 + ( (unsigned long long int) timePtr[3] << 16 )
535 + ( (unsigned long long int) timePtr[6] << 8 )
535 + ( (unsigned long long int) timePtr[6] << 8 )
536 + ( (unsigned long long int) timePtr[7] );
536 + ( (unsigned long long int) timePtr[7] );
537 return acquisitionTimeAslong;
537 return acquisitionTimeAslong;
538 }
538 }
539
539
540 unsigned char getSID( rtems_event_set event )
540 unsigned char getSID( rtems_event_set event )
541 {
541 {
542 unsigned char sid;
542 unsigned char sid;
543
543
544 rtems_event_set eventSetBURST;
544 rtems_event_set eventSetBURST;
545 rtems_event_set eventSetSBM;
545 rtems_event_set eventSetSBM;
546
546
547 //******
547 //******
548 // BURST
548 // BURST
549 eventSetBURST = RTEMS_EVENT_BURST_BP1_F0
549 eventSetBURST = RTEMS_EVENT_BURST_BP1_F0
550 | RTEMS_EVENT_BURST_BP1_F1
550 | RTEMS_EVENT_BURST_BP1_F1
551 | RTEMS_EVENT_BURST_BP2_F0
551 | RTEMS_EVENT_BURST_BP2_F0
552 | RTEMS_EVENT_BURST_BP2_F1;
552 | RTEMS_EVENT_BURST_BP2_F1;
553
553
554 //****
554 //****
555 // SBM
555 // SBM
556 eventSetSBM = RTEMS_EVENT_SBM_BP1_F0
556 eventSetSBM = RTEMS_EVENT_SBM_BP1_F0
557 | RTEMS_EVENT_SBM_BP1_F1
557 | RTEMS_EVENT_SBM_BP1_F1
558 | RTEMS_EVENT_SBM_BP2_F0
558 | RTEMS_EVENT_SBM_BP2_F0
559 | RTEMS_EVENT_SBM_BP2_F1;
559 | RTEMS_EVENT_SBM_BP2_F1;
560
560
561 if (event & eventSetBURST)
561 if (event & eventSetBURST)
562 {
562 {
563 sid = SID_BURST_BP1_F0;
563 sid = SID_BURST_BP1_F0;
564 }
564 }
565 else if (event & eventSetSBM)
565 else if (event & eventSetSBM)
566 {
566 {
567 sid = SID_SBM1_BP1_F0;
567 sid = SID_SBM1_BP1_F0;
568 }
568 }
569 else
569 else
570 {
570 {
571 sid = 0;
571 sid = 0;
572 }
572 }
573
573
574 return sid;
574 return sid;
575 }
575 }
576
576
577 void extractReImVectors( float *inputASM, float *outputASM, unsigned int asmComponent )
577 void extractReImVectors( float *inputASM, float *outputASM, unsigned int asmComponent )
578 {
578 {
579 unsigned int i;
579 unsigned int i;
580 float re;
580 float re;
581 float im;
581 float im;
582
582
583 for (i=0; i<NB_BINS_PER_SM; i++){
583 for (i=0; i<NB_BINS_PER_SM; i++){
584 re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 ];
584 re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 ];
585 im = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 + 1];
585 im = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 + 1];
586 outputASM[ (asmComponent *NB_BINS_PER_SM) + i] = re;
586 outputASM[ (asmComponent *NB_BINS_PER_SM) + i] = re;
587 outputASM[ (asmComponent+1)*NB_BINS_PER_SM + i] = im;
587 outputASM[ (asmComponent+1)*NB_BINS_PER_SM + i] = im;
588 }
588 }
589 }
589 }
590
590
591 void copyReVectors( float *inputASM, float *outputASM, unsigned int asmComponent )
591 void copyReVectors( float *inputASM, float *outputASM, unsigned int asmComponent )
592 {
592 {
593 unsigned int i;
593 unsigned int i;
594 float re;
594 float re;
595
595
596 for (i=0; i<NB_BINS_PER_SM; i++){
596 for (i=0; i<NB_BINS_PER_SM; i++){
597 re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i];
597 re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i];
598 outputASM[ (asmComponent*NB_BINS_PER_SM) + i] = re;
598 outputASM[ (asmComponent*NB_BINS_PER_SM) + i] = re;
599 }
599 }
600 }
600 }
601
601
602 void ASM_patch( float *inputASM, float *outputASM )
602 void ASM_patch( float *inputASM, float *outputASM )
603 {
603 {
604 extractReImVectors( inputASM, outputASM, 1); // b1b2
604 extractReImVectors( inputASM, outputASM, 1); // b1b2
605 extractReImVectors( inputASM, outputASM, 3 ); // b1b3
605 extractReImVectors( inputASM, outputASM, 3 ); // b1b3
606 extractReImVectors( inputASM, outputASM, 5 ); // b1e1
606 extractReImVectors( inputASM, outputASM, 5 ); // b1e1
607 extractReImVectors( inputASM, outputASM, 7 ); // b1e2
607 extractReImVectors( inputASM, outputASM, 7 ); // b1e2
608 extractReImVectors( inputASM, outputASM, 10 ); // b2b3
608 extractReImVectors( inputASM, outputASM, 10 ); // b2b3
609 extractReImVectors( inputASM, outputASM, 12 ); // b2e1
609 extractReImVectors( inputASM, outputASM, 12 ); // b2e1
610 extractReImVectors( inputASM, outputASM, 14 ); // b2e2
610 extractReImVectors( inputASM, outputASM, 14 ); // b2e2
611 extractReImVectors( inputASM, outputASM, 17 ); // b3e1
611 extractReImVectors( inputASM, outputASM, 17 ); // b3e1
612 extractReImVectors( inputASM, outputASM, 19 ); // b3e2
612 extractReImVectors( inputASM, outputASM, 19 ); // b3e2
613 extractReImVectors( inputASM, outputASM, 22 ); // e1e2
613 extractReImVectors( inputASM, outputASM, 22 ); // e1e2
614
614
615 copyReVectors(inputASM, outputASM, 0 ); // b1b1
615 copyReVectors(inputASM, outputASM, 0 ); // b1b1
616 copyReVectors(inputASM, outputASM, 9 ); // b2b2
616 copyReVectors(inputASM, outputASM, 9 ); // b2b2
617 copyReVectors(inputASM, outputASM, 16); // b3b3
617 copyReVectors(inputASM, outputASM, 16); // b3b3
618 copyReVectors(inputASM, outputASM, 21); // e1e1
618 copyReVectors(inputASM, outputASM, 21); // e1e1
619 copyReVectors(inputASM, outputASM, 24); // e2e2
619 copyReVectors(inputASM, outputASM, 24); // e2e2
620 }
620 }
621
621
622 void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
622 void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat , float divider,
623 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage,
623 unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage,
624 unsigned char ASMIndexStart,
624 unsigned char ASMIndexStart,
625 unsigned char channel )
625 unsigned char channel )
626 {
626 {
627 //*************
627 //*************
628 // input format
628 // input format
629 // component0[0 .. 127] component1[0 .. 127] .. component24[0 .. 127]
629 // component0[0 .. 127] component1[0 .. 127] .. component24[0 .. 127]
630 //**************
630 //**************
631 // output format
631 // output format
632 // matr0[0 .. 24] matr1[0 .. 24] .. matr127[0 .. 24]
632 // matr0[0 .. 24] matr1[0 .. 24] .. matr127[0 .. 24]
633 //************
633 //************
634 // compression
634 // compression
635 // matr0[0 .. 24] matr1[0 .. 24] .. matr11[0 .. 24] => f0 NORM
635 // matr0[0 .. 24] matr1[0 .. 24] .. matr11[0 .. 24] => f0 NORM
636 // matr0[0 .. 24] matr1[0 .. 24] .. matr22[0 .. 24] => f0 BURST, SBM
636 // matr0[0 .. 24] matr1[0 .. 24] .. matr22[0 .. 24] => f0 BURST, SBM
637
637
638 int frequencyBin;
638 int frequencyBin;
639 int asmComponent;
639 int asmComponent;
640 int offsetASM;
640 int offsetASM;
641 int offsetCompressed;
641 int offsetCompressed;
642 int offsetFBin;
642 int offsetFBin;
643 int fBinMask;
643 int fBinMask;
644 int k;
644 int k;
645
645
646 // BUILD DATA
646 // BUILD DATA
647 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
647 for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++)
648 {
648 {
649 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
649 for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ )
650 {
650 {
651 offsetCompressed = // NO TIME OFFSET
651 offsetCompressed = // NO TIME OFFSET
652 frequencyBin * NB_VALUES_PER_SM
652 frequencyBin * NB_VALUES_PER_SM
653 + asmComponent;
653 + asmComponent;
654 offsetASM = // NO TIME OFFSET
654 offsetASM = // NO TIME OFFSET
655 asmComponent * NB_BINS_PER_SM
655 asmComponent * NB_BINS_PER_SM
656 + ASMIndexStart
656 + ASMIndexStart
657 + frequencyBin * nbBinsToAverage;
657 + frequencyBin * nbBinsToAverage;
658 offsetFBin = ASMIndexStart
658 offsetFBin = ASMIndexStart
659 + frequencyBin * nbBinsToAverage;
659 + frequencyBin * nbBinsToAverage;
660 compressed_spec_mat[ offsetCompressed ] = 0;
660 compressed_spec_mat[ offsetCompressed ] = 0;
661 for ( k = 0; k < nbBinsToAverage; k++ )
661 for ( k = 0; k < nbBinsToAverage; k++ )
662 {
662 {
663 fBinMask = getFBinMask( offsetFBin + k, channel );
663 fBinMask = getFBinMask( offsetFBin + k, channel );
664 compressed_spec_mat[offsetCompressed ] =
664 compressed_spec_mat[offsetCompressed ] =
665 ( compressed_spec_mat[ offsetCompressed ]
665 ( compressed_spec_mat[ offsetCompressed ]
666 + averaged_spec_mat[ offsetASM + k ] * fBinMask );
666 + averaged_spec_mat[ offsetASM + k ] * fBinMask );
667 }
667 }
668 compressed_spec_mat[ offsetCompressed ] =
668 compressed_spec_mat[ offsetCompressed ] =
669 (divider != 0.) ? compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage) : 0.0;
669 (divider != 0.) ? compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage) : 0.0;
670 }
670 }
671 }
671 }
672
672
673 }
673 }
674
674
675 int getFBinMask( int index, unsigned char channel )
675 int getFBinMask( int index, unsigned char channel )
676 {
676 {
677 unsigned int indexInChar;
677 unsigned int indexInChar;
678 unsigned int indexInTheChar;
678 unsigned int indexInTheChar;
679 int fbin;
679 int fbin;
680 unsigned char *sy_lfr_fbins_fx_word1;
680 unsigned char *sy_lfr_fbins_fx_word1;
681
681
682 sy_lfr_fbins_fx_word1 = parameter_dump_packet.sy_lfr_fbins_f0_word1;
682 sy_lfr_fbins_fx_word1 = parameter_dump_packet.sy_lfr_fbins_f0_word1;
683
683
684 switch(channel)
684 switch(channel)
685 {
685 {
686 case 0:
686 case 0:
687 sy_lfr_fbins_fx_word1 = fbins_masks.merged_fbins_mask_f0;
687 sy_lfr_fbins_fx_word1 = fbins_masks.merged_fbins_mask_f0;
688 break;
688 break;
689 case 1:
689 case 1:
690 sy_lfr_fbins_fx_word1 = fbins_masks.merged_fbins_mask_f1;
690 sy_lfr_fbins_fx_word1 = fbins_masks.merged_fbins_mask_f1;
691 break;
691 break;
692 case 2:
692 case 2:
693 sy_lfr_fbins_fx_word1 = fbins_masks.merged_fbins_mask_f2;
693 sy_lfr_fbins_fx_word1 = fbins_masks.merged_fbins_mask_f2;
694 break;
694 break;
695 default:
695 default:
696 PRINTF("ERR *** in getFBinMask, wrong frequency channel")
696 PRINTF("ERR *** in getFBinMask, wrong frequency channel")
697 }
697 }
698
698
699 indexInChar = index >> 3;
699 indexInChar = index >> 3;
700 indexInTheChar = index - indexInChar * 8;
700 indexInTheChar = index - indexInChar * 8;
701
701
702 fbin = (int) ((sy_lfr_fbins_fx_word1[ NB_BYTES_PER_FREQ_MASK - 1 - indexInChar] >> indexInTheChar) & 0x1);
702 fbin = (int) ((sy_lfr_fbins_fx_word1[ NB_BYTES_PER_FREQ_MASK - 1 - indexInChar] >> indexInTheChar) & 0x1);
703
703
704 return fbin;
704 return fbin;
705 }
705 }
706
706
707 unsigned char acquisitionTimeIsValid( unsigned int coarseTime, unsigned int fineTime, unsigned char channel)
707 unsigned char acquisitionTimeIsValid( unsigned int coarseTime, unsigned int fineTime, unsigned char channel)
708 {
708 {
709 u_int64_t acquisitionTime;
709 u_int64_t acquisitionTime;
710 u_int64_t timecodeReference;
710 u_int64_t timecodeReference;
711 u_int64_t offsetInFineTime;
711 u_int64_t offsetInFineTime;
712 u_int64_t shiftInFineTime;
712 u_int64_t shiftInFineTime;
713 u_int64_t tBadInFineTime;
713 u_int64_t tBadInFineTime;
714 u_int64_t acquisitionTimeRangeMin;
714 u_int64_t acquisitionTimeRangeMin;
715 u_int64_t acquisitionTimeRangeMax;
715 u_int64_t acquisitionTimeRangeMax;
716 unsigned char pasFilteringIsEnabled;
716 unsigned char pasFilteringIsEnabled;
717 unsigned char ret;
717 unsigned char ret;
718
718
719 pasFilteringIsEnabled = (parameter_dump_packet.spare_sy_lfr_pas_filter_enabled & 0x01); // [0000 0001]
719 pasFilteringIsEnabled = (filterPar.spare_sy_lfr_pas_filter_enabled & 0x01); // [0000 0001]
720 ret = 1;
720 ret = 1;
721
721
722 //***************************
723 // <FOR TESTING PURPOSE ONLY>
724 unsigned char sy_lfr_pas_filter_modulus = 4;
725 unsigned char sy_lfr_pas_filter_offset = 1;
726 float sy_lfr_pas_filter_shift = 0.5;
727 float sy_lfr_pas_filter_tbad = 1.0;
728 // </FOR TESTING PURPOSE ONLY>
729 //****************************
730
731 // compute acquisition time from caoarseTime and fineTime
722 // compute acquisition time from caoarseTime and fineTime
732 acquisitionTime = ( ((u_int64_t)coarseTime) << 16 )
723 acquisitionTime = ( ((u_int64_t)coarseTime) << 16 )
733 + (u_int64_t) fineTime;
724 + (u_int64_t) fineTime;
734
725
735 // compute the timecode reference
726 // compute the timecode reference
736 timecodeReference = (u_int64_t) (floor( ((double) coarseTime) / ((double) sy_lfr_pas_filter_modulus) )
727 timecodeReference = (u_int64_t) (floor( ((double) coarseTime) / ((double) filterPar.sy_lfr_pas_filter_modulus) )
737 * ((double) sy_lfr_pas_filter_modulus)) * 65536;
728 * ((double) filterPar.sy_lfr_pas_filter_modulus)) * 65536;
738
729
739 // compute the acquitionTime range
730 // compute the acquitionTime range
740 offsetInFineTime = ((double) sy_lfr_pas_filter_offset) * 65536;
731 offsetInFineTime = ((double) filterPar.sy_lfr_pas_filter_offset) * 65536;
741 shiftInFineTime = ((double) sy_lfr_pas_filter_shift) * 65536;
732 shiftInFineTime = ((double) filterPar.sy_lfr_pas_filter_shift) * 65536;
742 tBadInFineTime = ((double) sy_lfr_pas_filter_tbad) * 65536;
733 tBadInFineTime = ((double) filterPar.sy_lfr_pas_filter_tbad) * 65536;
743
734
744 acquisitionTimeRangeMin =
735 acquisitionTimeRangeMin =
745 timecodeReference
736 timecodeReference
746 + offsetInFineTime
737 + offsetInFineTime
747 + shiftInFineTime
738 + shiftInFineTime
748 - acquisitionDurations[channel];
739 - acquisitionDurations[channel];
749 acquisitionTimeRangeMax =
740 acquisitionTimeRangeMax =
750 timecodeReference
741 timecodeReference
751 + offsetInFineTime
742 + offsetInFineTime
752 + shiftInFineTime
743 + shiftInFineTime
753 + tBadInFineTime;
744 + tBadInFineTime;
754
745
755 if ( (acquisitionTime >= acquisitionTimeRangeMin)
746 if ( (acquisitionTime >= acquisitionTimeRangeMin)
756 && (acquisitionTime <= acquisitionTimeRangeMax)
747 && (acquisitionTime <= acquisitionTimeRangeMax)
757 && (pasFilteringIsEnabled == 1) )
748 && (pasFilteringIsEnabled == 1) )
758 {
749 {
759 ret = 0; // the acquisition time is INSIDE the range, the matrix shall be ignored
750 ret = 0; // the acquisition time is INSIDE the range, the matrix shall be ignored
760 }
751 }
761 else
752 else
762 {
753 {
763 ret = 1; // the acquisition time is OUTSIDE the range, the matrix can be used for the averaging
754 ret = 1; // the acquisition time is OUTSIDE the range, the matrix can be used for the averaging
764 }
755 }
765
756
766 // printf("coarseTime = %x, fineTime = %x\n",
757 // printf("coarseTime = %x, fineTime = %x\n",
767 // coarseTime,
758 // coarseTime,
768 // fineTime);
759 // fineTime);
769
760
770 // printf("[ret = %d] *** acquisitionTime = %f, Reference = %f",
761 // printf("[ret = %d] *** acquisitionTime = %f, Reference = %f",
771 // ret,
762 // ret,
772 // acquisitionTime / 65536.,
763 // acquisitionTime / 65536.,
773 // timecodeReference / 65536.);
764 // timecodeReference / 65536.);
774
765
775 // printf(", Min = %f, Max = %f\n",
766 // printf(", Min = %f, Max = %f\n",
776 // acquisitionTimeRangeMin / 65536.,
767 // acquisitionTimeRangeMin / 65536.,
777 // acquisitionTimeRangeMax / 65536.);
768 // acquisitionTimeRangeMax / 65536.);
778
769
779 return ret;
770 return ret;
780 }
771 }
781
772
782 void init_kcoeff_sbm_from_kcoeff_norm(float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm)
773 void init_kcoeff_sbm_from_kcoeff_norm(float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm)
783 {
774 {
784 unsigned char bin;
775 unsigned char bin;
785 unsigned char kcoeff;
776 unsigned char kcoeff;
786
777
787 for (bin=0; bin<nb_bins_norm; bin++)
778 for (bin=0; bin<nb_bins_norm; bin++)
788 {
779 {
789 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
780 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
790 {
781 {
791 output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ];
782 output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ];
792 output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 + 1 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ];
783 output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 + 1 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ];
793 }
784 }
794 }
785 }
795 }
786 }
@@ -1,1524 +1,1540
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_normal_par_consistency( TC, queue_id );
61 flag = check_normal_par_consistency( TC, queue_id );
62 }
62 }
63
63
64 // SET THE PARAMETERS IF THEY ARE CONSISTENT
64 // SET THE PARAMETERS IF THEY ARE CONSISTENT
65 if (flag == LFR_SUCCESSFUL)
65 if (flag == LFR_SUCCESSFUL)
66 {
66 {
67 result = set_sy_lfr_n_swf_l( TC );
67 result = set_sy_lfr_n_swf_l( TC );
68 result = set_sy_lfr_n_swf_p( TC );
68 result = set_sy_lfr_n_swf_p( TC );
69 result = set_sy_lfr_n_bp_p0( TC );
69 result = set_sy_lfr_n_bp_p0( TC );
70 result = set_sy_lfr_n_bp_p1( TC );
70 result = set_sy_lfr_n_bp_p1( TC );
71 result = set_sy_lfr_n_asm_p( TC );
71 result = set_sy_lfr_n_asm_p( TC );
72 result = set_sy_lfr_n_cwf_long_f3( TC );
72 result = set_sy_lfr_n_cwf_long_f3( TC );
73 }
73 }
74
74
75 return flag;
75 return flag;
76 }
76 }
77
77
78 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
78 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
79 {
79 {
80 /** This function updates the LFR registers with the incoming burst parameters.
80 /** This function updates the LFR registers with the incoming burst parameters.
81 *
81 *
82 * @param TC points to the TeleCommand packet that is being processed
82 * @param TC points to the TeleCommand packet that is being processed
83 * @param queue_id is the id of the queue which handles TM related to this execution step
83 * @param queue_id is the id of the queue which handles TM related to this execution step
84 *
84 *
85 */
85 */
86
86
87 int flag;
87 int flag;
88 rtems_status_code status;
88 rtems_status_code status;
89 unsigned char sy_lfr_b_bp_p0;
89 unsigned char sy_lfr_b_bp_p0;
90 unsigned char sy_lfr_b_bp_p1;
90 unsigned char sy_lfr_b_bp_p1;
91 float aux;
91 float aux;
92
92
93 flag = LFR_SUCCESSFUL;
93 flag = LFR_SUCCESSFUL;
94
94
95 if ( lfrCurrentMode == LFR_MODE_BURST ) {
95 if ( lfrCurrentMode == LFR_MODE_BURST ) {
96 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
96 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
97 flag = LFR_DEFAULT;
97 flag = LFR_DEFAULT;
98 }
98 }
99
99
100 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
100 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
101 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
101 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
102
102
103 // sy_lfr_b_bp_p0 shall not be lower than its default value
103 // sy_lfr_b_bp_p0 shall not be lower than its default value
104 if (flag == LFR_SUCCESSFUL)
104 if (flag == LFR_SUCCESSFUL)
105 {
105 {
106 if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 )
106 if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 )
107 {
107 {
108 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
108 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
109 flag = WRONG_APP_DATA;
109 flag = WRONG_APP_DATA;
110 }
110 }
111 }
111 }
112 // sy_lfr_b_bp_p1 shall not be lower than its default value
112 // sy_lfr_b_bp_p1 shall not be lower than its default value
113 if (flag == LFR_SUCCESSFUL)
113 if (flag == LFR_SUCCESSFUL)
114 {
114 {
115 if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 )
115 if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 )
116 {
116 {
117 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, sy_lfr_b_bp_p1 );
117 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, sy_lfr_b_bp_p1 );
118 flag = WRONG_APP_DATA;
118 flag = WRONG_APP_DATA;
119 }
119 }
120 }
120 }
121 //****************************************************************
121 //****************************************************************
122 // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1
122 // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1
123 if (flag == LFR_SUCCESSFUL)
123 if (flag == LFR_SUCCESSFUL)
124 {
124 {
125 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
125 sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
126 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
126 sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
127 aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0);
127 aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0);
128 if (aux > FLOAT_EQUAL_ZERO)
128 if (aux > FLOAT_EQUAL_ZERO)
129 {
129 {
130 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
130 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 );
131 flag = LFR_DEFAULT;
131 flag = LFR_DEFAULT;
132 }
132 }
133 }
133 }
134
134
135 // SET THE PARAMETERS
135 // SET THE PARAMETERS
136 if (flag == LFR_SUCCESSFUL)
136 if (flag == LFR_SUCCESSFUL)
137 {
137 {
138 flag = set_sy_lfr_b_bp_p0( TC );
138 flag = set_sy_lfr_b_bp_p0( TC );
139 flag = set_sy_lfr_b_bp_p1( TC );
139 flag = set_sy_lfr_b_bp_p1( TC );
140 }
140 }
141
141
142 return flag;
142 return flag;
143 }
143 }
144
144
145 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
145 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
146 {
146 {
147 /** This function updates the LFR registers with the incoming sbm1 parameters.
147 /** This function updates the LFR registers with the incoming sbm1 parameters.
148 *
148 *
149 * @param TC points to the TeleCommand packet that is being processed
149 * @param TC points to the TeleCommand packet that is being processed
150 * @param queue_id is the id of the queue which handles TM related to this execution step
150 * @param queue_id is the id of the queue which handles TM related to this execution step
151 *
151 *
152 */
152 */
153
153
154 int flag;
154 int flag;
155 rtems_status_code status;
155 rtems_status_code status;
156 unsigned char sy_lfr_s1_bp_p0;
156 unsigned char sy_lfr_s1_bp_p0;
157 unsigned char sy_lfr_s1_bp_p1;
157 unsigned char sy_lfr_s1_bp_p1;
158 float aux;
158 float aux;
159
159
160 flag = LFR_SUCCESSFUL;
160 flag = LFR_SUCCESSFUL;
161
161
162 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
162 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
163 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
163 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
164 flag = LFR_DEFAULT;
164 flag = LFR_DEFAULT;
165 }
165 }
166
166
167 sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
167 sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
168 sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
168 sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
169
169
170 // sy_lfr_s1_bp_p0
170 // sy_lfr_s1_bp_p0
171 if (flag == LFR_SUCCESSFUL)
171 if (flag == LFR_SUCCESSFUL)
172 {
172 {
173 if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 )
173 if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 )
174 {
174 {
175 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
175 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
176 flag = WRONG_APP_DATA;
176 flag = WRONG_APP_DATA;
177 }
177 }
178 }
178 }
179 // sy_lfr_s1_bp_p1
179 // sy_lfr_s1_bp_p1
180 if (flag == LFR_SUCCESSFUL)
180 if (flag == LFR_SUCCESSFUL)
181 {
181 {
182 if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 )
182 if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 )
183 {
183 {
184 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, sy_lfr_s1_bp_p1 );
184 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, sy_lfr_s1_bp_p1 );
185 flag = WRONG_APP_DATA;
185 flag = WRONG_APP_DATA;
186 }
186 }
187 }
187 }
188 //******************************************************************
188 //******************************************************************
189 // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1
189 // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1
190 if (flag == LFR_SUCCESSFUL)
190 if (flag == LFR_SUCCESSFUL)
191 {
191 {
192 aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25));
192 aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25));
193 if (aux > FLOAT_EQUAL_ZERO)
193 if (aux > FLOAT_EQUAL_ZERO)
194 {
194 {
195 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
195 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 );
196 flag = LFR_DEFAULT;
196 flag = LFR_DEFAULT;
197 }
197 }
198 }
198 }
199
199
200 // SET THE PARAMETERS
200 // SET THE PARAMETERS
201 if (flag == LFR_SUCCESSFUL)
201 if (flag == LFR_SUCCESSFUL)
202 {
202 {
203 flag = set_sy_lfr_s1_bp_p0( TC );
203 flag = set_sy_lfr_s1_bp_p0( TC );
204 flag = set_sy_lfr_s1_bp_p1( TC );
204 flag = set_sy_lfr_s1_bp_p1( TC );
205 }
205 }
206
206
207 return flag;
207 return flag;
208 }
208 }
209
209
210 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
210 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
211 {
211 {
212 /** This function updates the LFR registers with the incoming sbm2 parameters.
212 /** This function updates the LFR registers with the incoming sbm2 parameters.
213 *
213 *
214 * @param TC points to the TeleCommand packet that is being processed
214 * @param TC points to the TeleCommand packet that is being processed
215 * @param queue_id is the id of the queue which handles TM related to this execution step
215 * @param queue_id is the id of the queue which handles TM related to this execution step
216 *
216 *
217 */
217 */
218
218
219 int flag;
219 int flag;
220 rtems_status_code status;
220 rtems_status_code status;
221 unsigned char sy_lfr_s2_bp_p0;
221 unsigned char sy_lfr_s2_bp_p0;
222 unsigned char sy_lfr_s2_bp_p1;
222 unsigned char sy_lfr_s2_bp_p1;
223 float aux;
223 float aux;
224
224
225 flag = LFR_SUCCESSFUL;
225 flag = LFR_SUCCESSFUL;
226
226
227 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
227 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
228 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
228 status = send_tm_lfr_tc_exe_not_executable( TC, queue_id );
229 flag = LFR_DEFAULT;
229 flag = LFR_DEFAULT;
230 }
230 }
231
231
232 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
232 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
233 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
233 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
234
234
235 // sy_lfr_s2_bp_p0
235 // sy_lfr_s2_bp_p0
236 if (flag == LFR_SUCCESSFUL)
236 if (flag == LFR_SUCCESSFUL)
237 {
237 {
238 if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 )
238 if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 )
239 {
239 {
240 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
240 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
241 flag = WRONG_APP_DATA;
241 flag = WRONG_APP_DATA;
242 }
242 }
243 }
243 }
244 // sy_lfr_s2_bp_p1
244 // sy_lfr_s2_bp_p1
245 if (flag == LFR_SUCCESSFUL)
245 if (flag == LFR_SUCCESSFUL)
246 {
246 {
247 if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 )
247 if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 )
248 {
248 {
249 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, sy_lfr_s2_bp_p1 );
249 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, sy_lfr_s2_bp_p1 );
250 flag = WRONG_APP_DATA;
250 flag = WRONG_APP_DATA;
251 }
251 }
252 }
252 }
253 //******************************************************************
253 //******************************************************************
254 // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1
254 // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1
255 if (flag == LFR_SUCCESSFUL)
255 if (flag == LFR_SUCCESSFUL)
256 {
256 {
257 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
257 sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
258 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
258 sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
259 aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0);
259 aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0);
260 if (aux > FLOAT_EQUAL_ZERO)
260 if (aux > FLOAT_EQUAL_ZERO)
261 {
261 {
262 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
262 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 );
263 flag = LFR_DEFAULT;
263 flag = LFR_DEFAULT;
264 }
264 }
265 }
265 }
266
266
267 // SET THE PARAMETERS
267 // SET THE PARAMETERS
268 if (flag == LFR_SUCCESSFUL)
268 if (flag == LFR_SUCCESSFUL)
269 {
269 {
270 flag = set_sy_lfr_s2_bp_p0( TC );
270 flag = set_sy_lfr_s2_bp_p0( TC );
271 flag = set_sy_lfr_s2_bp_p1( TC );
271 flag = set_sy_lfr_s2_bp_p1( TC );
272 }
272 }
273
273
274 return flag;
274 return flag;
275 }
275 }
276
276
277 int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
277 int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
278 {
278 {
279 /** This function updates the LFR registers with the incoming sbm2 parameters.
279 /** This function updates the LFR registers with the incoming sbm2 parameters.
280 *
280 *
281 * @param TC points to the TeleCommand packet that is being processed
281 * @param TC points to the TeleCommand packet that is being processed
282 * @param queue_id is the id of the queue which handles TM related to this execution step
282 * @param queue_id is the id of the queue which handles TM related to this execution step
283 *
283 *
284 */
284 */
285
285
286 int flag;
286 int flag;
287
287
288 flag = LFR_DEFAULT;
288 flag = LFR_DEFAULT;
289
289
290 flag = set_sy_lfr_kcoeff( TC, queue_id );
290 flag = set_sy_lfr_kcoeff( TC, queue_id );
291
291
292 return flag;
292 return flag;
293 }
293 }
294
294
295 int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
295 int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
296 {
296 {
297 /** This function updates the LFR registers with the incoming sbm2 parameters.
297 /** This function updates the LFR registers with the incoming sbm2 parameters.
298 *
298 *
299 * @param TC points to the TeleCommand packet that is being processed
299 * @param TC points to the TeleCommand packet that is being processed
300 * @param queue_id is the id of the queue which handles TM related to this execution step
300 * @param queue_id is the id of the queue which handles TM related to this execution step
301 *
301 *
302 */
302 */
303
303
304 int flag;
304 int flag;
305
305
306 flag = LFR_DEFAULT;
306 flag = LFR_DEFAULT;
307
307
308 flag = set_sy_lfr_fbins( TC );
308 flag = set_sy_lfr_fbins( TC );
309
309
310 return flag;
310 return flag;
311 }
311 }
312
312
313 int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
313 int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
314 {
314 {
315 /** This function updates the LFR registers with the incoming sbm2 parameters.
315 /** This function updates the LFR registers with the incoming sbm2 parameters.
316 *
316 *
317 * @param TC points to the TeleCommand packet that is being processed
317 * @param TC points to the TeleCommand packet that is being processed
318 * @param queue_id is the id of the queue which handles TM related to this execution step
318 * @param queue_id is the id of the queue which handles TM related to this execution step
319 *
319 *
320 */
320 */
321
321
322 int flag;
322 int flag;
323
323
324 flag = LFR_DEFAULT;
324 flag = LFR_DEFAULT;
325
325
326 flag = check_sy_lfr_filter_parameters( TC, queue_id );
326 flag = check_sy_lfr_filter_parameters( TC, queue_id );
327
327
328 if (flag == LFR_SUCCESSFUL)
328 if (flag == LFR_SUCCESSFUL)
329 {
329 {
330 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ];
330 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ];
331 parameter_dump_packet.sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
331 parameter_dump_packet.sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
332 parameter_dump_packet.sy_lfr_pas_filter_tbad[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 0 ];
332 parameter_dump_packet.sy_lfr_pas_filter_tbad[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 0 ];
333 parameter_dump_packet.sy_lfr_pas_filter_tbad[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 1 ];
333 parameter_dump_packet.sy_lfr_pas_filter_tbad[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 1 ];
334 parameter_dump_packet.sy_lfr_pas_filter_tbad[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 2 ];
334 parameter_dump_packet.sy_lfr_pas_filter_tbad[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 2 ];
335 parameter_dump_packet.sy_lfr_pas_filter_tbad[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 3 ];
335 parameter_dump_packet.sy_lfr_pas_filter_tbad[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 3 ];
336 parameter_dump_packet.sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
336 parameter_dump_packet.sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
337 parameter_dump_packet.sy_lfr_pas_filter_shift[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 0 ];
337 parameter_dump_packet.sy_lfr_pas_filter_shift[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 0 ];
338 parameter_dump_packet.sy_lfr_pas_filter_shift[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 1 ];
338 parameter_dump_packet.sy_lfr_pas_filter_shift[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 1 ];
339 parameter_dump_packet.sy_lfr_pas_filter_shift[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 2 ];
339 parameter_dump_packet.sy_lfr_pas_filter_shift[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 2 ];
340 parameter_dump_packet.sy_lfr_pas_filter_shift[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 3 ];
340 parameter_dump_packet.sy_lfr_pas_filter_shift[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 3 ];
341 parameter_dump_packet.sy_lfr_sc_rw_delta_f[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 0 ];
341 parameter_dump_packet.sy_lfr_sc_rw_delta_f[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 0 ];
342 parameter_dump_packet.sy_lfr_sc_rw_delta_f[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 1 ];
342 parameter_dump_packet.sy_lfr_sc_rw_delta_f[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 1 ];
343 parameter_dump_packet.sy_lfr_sc_rw_delta_f[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 2 ];
343 parameter_dump_packet.sy_lfr_sc_rw_delta_f[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 2 ];
344 parameter_dump_packet.sy_lfr_sc_rw_delta_f[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 3 ];
344 parameter_dump_packet.sy_lfr_sc_rw_delta_f[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 3 ];
345
345
346 //****************************
347 // store PAS filter parameters
348 // sy_lfr_pas_filter_enabled
349 filterPar.spare_sy_lfr_pas_filter_enabled = parameter_dump_packet.spare_sy_lfr_pas_filter_enabled;
350 // sy_lfr_pas_filter_modulus
351 filterPar.sy_lfr_pas_filter_modulus = parameter_dump_packet.sy_lfr_pas_filter_modulus;
352 // sy_lfr_pas_filter_tbad
353 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_tbad,
354 parameter_dump_packet.sy_lfr_pas_filter_tbad );
355 // sy_lfr_pas_filter_offset
356 filterPar.sy_lfr_pas_filter_offset = parameter_dump_packet.sy_lfr_pas_filter_offset;
357 // sy_lfr_pas_filter_shift
358 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_shift,
359 parameter_dump_packet.sy_lfr_pas_filter_shift );
360
361 //****************************************************
346 // store the parameter sy_lfr_sc_rw_delta_f as a float
362 // store the parameter sy_lfr_sc_rw_delta_f as a float
347 copyFloatByChar( (unsigned char*) &sy_lfr_sc_rw_delta_f,
363 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_sc_rw_delta_f,
348 (unsigned char*) &parameter_dump_packet.sy_lfr_sc_rw_delta_f[0] );
364 parameter_dump_packet.sy_lfr_sc_rw_delta_f );
349 }
365 }
350
366
351 return flag;
367 return flag;
352 }
368 }
353
369
354 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
370 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
355 {
371 {
356 /** This function updates the LFR registers with the incoming sbm2 parameters.
372 /** This function updates the LFR registers with the incoming sbm2 parameters.
357 *
373 *
358 * @param TC points to the TeleCommand packet that is being processed
374 * @param TC points to the TeleCommand packet that is being processed
359 * @param queue_id is the id of the queue which handles TM related to this execution step
375 * @param queue_id is the id of the queue which handles TM related to this execution step
360 *
376 *
361 */
377 */
362
378
363 unsigned int address;
379 unsigned int address;
364 rtems_status_code status;
380 rtems_status_code status;
365 unsigned int freq;
381 unsigned int freq;
366 unsigned int bin;
382 unsigned int bin;
367 unsigned int coeff;
383 unsigned int coeff;
368 unsigned char *kCoeffPtr;
384 unsigned char *kCoeffPtr;
369 unsigned char *kCoeffDumpPtr;
385 unsigned char *kCoeffDumpPtr;
370
386
371 // for each sy_lfr_kcoeff_frequency there is 32 kcoeff
387 // for each sy_lfr_kcoeff_frequency there is 32 kcoeff
372 // F0 => 11 bins
388 // F0 => 11 bins
373 // F1 => 13 bins
389 // F1 => 13 bins
374 // F2 => 12 bins
390 // F2 => 12 bins
375 // 36 bins to dump in two packets (30 bins max per packet)
391 // 36 bins to dump in two packets (30 bins max per packet)
376
392
377 //*********
393 //*********
378 // PACKET 1
394 // PACKET 1
379 // 11 F0 bins, 13 F1 bins and 6 F2 bins
395 // 11 F0 bins, 13 F1 bins and 6 F2 bins
380 kcoefficients_dump_1.destinationID = TC->sourceID;
396 kcoefficients_dump_1.destinationID = TC->sourceID;
381 increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID );
397 increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID );
382 for( freq=0;
398 for( freq=0;
383 freq<NB_BINS_COMPRESSED_SM_F0;
399 freq<NB_BINS_COMPRESSED_SM_F0;
384 freq++ )
400 freq++ )
385 {
401 {
386 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq;
402 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq;
387 bin = freq;
403 bin = freq;
388 // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm);
404 // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm);
389 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
405 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
390 {
406 {
391 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
407 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_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
408 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
393 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
409 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
394 }
410 }
395 }
411 }
396 for( freq=NB_BINS_COMPRESSED_SM_F0;
412 for( freq=NB_BINS_COMPRESSED_SM_F0;
397 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
413 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
398 freq++ )
414 freq++ )
399 {
415 {
400 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
416 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
401 bin = freq - NB_BINS_COMPRESSED_SM_F0;
417 bin = freq - NB_BINS_COMPRESSED_SM_F0;
402 // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm);
418 // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm);
403 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
419 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
404 {
420 {
405 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
421 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
406 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
422 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
407 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
423 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
408 }
424 }
409 }
425 }
410 for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
426 for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
411 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6);
427 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6);
412 freq++ )
428 freq++ )
413 {
429 {
414 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
430 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
415 bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
431 bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
416 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
432 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
417 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
433 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
418 {
434 {
419 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
435 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
420 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
436 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
421 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
437 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
422 }
438 }
423 }
439 }
424 kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
440 kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
425 kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
441 kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
426 kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
442 kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
427 kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time);
443 kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time);
428 kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
444 kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
429 kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time);
445 kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time);
430 // SEND DATA
446 // SEND DATA
431 kcoefficient_node_1.status = 1;
447 kcoefficient_node_1.status = 1;
432 address = (unsigned int) &kcoefficient_node_1;
448 address = (unsigned int) &kcoefficient_node_1;
433 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
449 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
434 if (status != RTEMS_SUCCESSFUL) {
450 if (status != RTEMS_SUCCESSFUL) {
435 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status)
451 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status)
436 }
452 }
437
453
438 //********
454 //********
439 // PACKET 2
455 // PACKET 2
440 // 6 F2 bins
456 // 6 F2 bins
441 kcoefficients_dump_2.destinationID = TC->sourceID;
457 kcoefficients_dump_2.destinationID = TC->sourceID;
442 increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID );
458 increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID );
443 for( freq=0; freq<6; freq++ )
459 for( freq=0; freq<6; freq++ )
444 {
460 {
445 kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq;
461 kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq;
446 bin = freq + 6;
462 bin = freq + 6;
447 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
463 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
448 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
464 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
449 {
465 {
450 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
466 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
451 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
467 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
452 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
468 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
453 }
469 }
454 }
470 }
455 kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
471 kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
456 kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
472 kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
457 kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
473 kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
458 kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time);
474 kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time);
459 kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
475 kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
460 kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time);
476 kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time);
461 // SEND DATA
477 // SEND DATA
462 kcoefficient_node_2.status = 1;
478 kcoefficient_node_2.status = 1;
463 address = (unsigned int) &kcoefficient_node_2;
479 address = (unsigned int) &kcoefficient_node_2;
464 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
480 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
465 if (status != RTEMS_SUCCESSFUL) {
481 if (status != RTEMS_SUCCESSFUL) {
466 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status)
482 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status)
467 }
483 }
468
484
469 return status;
485 return status;
470 }
486 }
471
487
472 int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
488 int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
473 {
489 {
474 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
490 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
475 *
491 *
476 * @param queue_id is the id of the queue which handles TM related to this execution step.
492 * @param queue_id is the id of the queue which handles TM related to this execution step.
477 *
493 *
478 * @return RTEMS directive status codes:
494 * @return RTEMS directive status codes:
479 * - RTEMS_SUCCESSFUL - message sent successfully
495 * - RTEMS_SUCCESSFUL - message sent successfully
480 * - RTEMS_INVALID_ID - invalid queue id
496 * - RTEMS_INVALID_ID - invalid queue id
481 * - RTEMS_INVALID_SIZE - invalid message size
497 * - RTEMS_INVALID_SIZE - invalid message size
482 * - RTEMS_INVALID_ADDRESS - buffer is NULL
498 * - RTEMS_INVALID_ADDRESS - buffer is NULL
483 * - RTEMS_UNSATISFIED - out of message buffers
499 * - RTEMS_UNSATISFIED - out of message buffers
484 * - RTEMS_TOO_MANY - queue s limit has been reached
500 * - RTEMS_TOO_MANY - queue s limit has been reached
485 *
501 *
486 */
502 */
487
503
488 int status;
504 int status;
489
505
490 increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID );
506 increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID );
491 parameter_dump_packet.destinationID = TC->sourceID;
507 parameter_dump_packet.destinationID = TC->sourceID;
492
508
493 // UPDATE TIME
509 // UPDATE TIME
494 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
510 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
495 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
511 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
496 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
512 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
497 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
513 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
498 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
514 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
499 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
515 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
500 // SEND DATA
516 // SEND DATA
501 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
517 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
502 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
518 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
503 if (status != RTEMS_SUCCESSFUL) {
519 if (status != RTEMS_SUCCESSFUL) {
504 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
520 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
505 }
521 }
506
522
507 return status;
523 return status;
508 }
524 }
509
525
510 //***********************
526 //***********************
511 // NORMAL MODE PARAMETERS
527 // NORMAL MODE PARAMETERS
512
528
513 int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
529 int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
514 {
530 {
515 unsigned char msb;
531 unsigned char msb;
516 unsigned char lsb;
532 unsigned char lsb;
517 int flag;
533 int flag;
518 float aux;
534 float aux;
519 rtems_status_code status;
535 rtems_status_code status;
520
536
521 unsigned int sy_lfr_n_swf_l;
537 unsigned int sy_lfr_n_swf_l;
522 unsigned int sy_lfr_n_swf_p;
538 unsigned int sy_lfr_n_swf_p;
523 unsigned int sy_lfr_n_asm_p;
539 unsigned int sy_lfr_n_asm_p;
524 unsigned char sy_lfr_n_bp_p0;
540 unsigned char sy_lfr_n_bp_p0;
525 unsigned char sy_lfr_n_bp_p1;
541 unsigned char sy_lfr_n_bp_p1;
526 unsigned char sy_lfr_n_cwf_long_f3;
542 unsigned char sy_lfr_n_cwf_long_f3;
527
543
528 flag = LFR_SUCCESSFUL;
544 flag = LFR_SUCCESSFUL;
529
545
530 //***************
546 //***************
531 // get parameters
547 // get parameters
532 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
548 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
533 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
549 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
534 sy_lfr_n_swf_l = msb * 256 + lsb;
550 sy_lfr_n_swf_l = msb * 256 + lsb;
535
551
536 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
552 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
537 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
553 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
538 sy_lfr_n_swf_p = msb * 256 + lsb;
554 sy_lfr_n_swf_p = msb * 256 + lsb;
539
555
540 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
556 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
541 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
557 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
542 sy_lfr_n_asm_p = msb * 256 + lsb;
558 sy_lfr_n_asm_p = msb * 256 + lsb;
543
559
544 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
560 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
545
561
546 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
562 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
547
563
548 sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
564 sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
549
565
550 //******************
566 //******************
551 // check consistency
567 // check consistency
552 // sy_lfr_n_swf_l
568 // sy_lfr_n_swf_l
553 if (sy_lfr_n_swf_l != 2048)
569 if (sy_lfr_n_swf_l != 2048)
554 {
570 {
555 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l );
571 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l );
556 flag = WRONG_APP_DATA;
572 flag = WRONG_APP_DATA;
557 }
573 }
558 // sy_lfr_n_swf_p
574 // sy_lfr_n_swf_p
559 if (flag == LFR_SUCCESSFUL)
575 if (flag == LFR_SUCCESSFUL)
560 {
576 {
561 if ( sy_lfr_n_swf_p < 22 )
577 if ( sy_lfr_n_swf_p < 22 )
562 {
578 {
563 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p );
579 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p );
564 flag = WRONG_APP_DATA;
580 flag = WRONG_APP_DATA;
565 }
581 }
566 }
582 }
567 // sy_lfr_n_bp_p0
583 // sy_lfr_n_bp_p0
568 if (flag == LFR_SUCCESSFUL)
584 if (flag == LFR_SUCCESSFUL)
569 {
585 {
570 if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0)
586 if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0)
571 {
587 {
572 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 );
588 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 );
573 flag = WRONG_APP_DATA;
589 flag = WRONG_APP_DATA;
574 }
590 }
575 }
591 }
576 // sy_lfr_n_asm_p
592 // sy_lfr_n_asm_p
577 if (flag == LFR_SUCCESSFUL)
593 if (flag == LFR_SUCCESSFUL)
578 {
594 {
579 if (sy_lfr_n_asm_p == 0)
595 if (sy_lfr_n_asm_p == 0)
580 {
596 {
581 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
597 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
582 flag = WRONG_APP_DATA;
598 flag = WRONG_APP_DATA;
583 }
599 }
584 }
600 }
585 // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0
601 // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0
586 if (flag == LFR_SUCCESSFUL)
602 if (flag == LFR_SUCCESSFUL)
587 {
603 {
588 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
604 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
589 if (aux > FLOAT_EQUAL_ZERO)
605 if (aux > FLOAT_EQUAL_ZERO)
590 {
606 {
591 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
607 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
592 flag = WRONG_APP_DATA;
608 flag = WRONG_APP_DATA;
593 }
609 }
594 }
610 }
595 // sy_lfr_n_bp_p1
611 // sy_lfr_n_bp_p1
596 if (flag == LFR_SUCCESSFUL)
612 if (flag == LFR_SUCCESSFUL)
597 {
613 {
598 if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1)
614 if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1)
599 {
615 {
600 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
616 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
601 flag = WRONG_APP_DATA;
617 flag = WRONG_APP_DATA;
602 }
618 }
603 }
619 }
604 // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0
620 // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0
605 if (flag == LFR_SUCCESSFUL)
621 if (flag == LFR_SUCCESSFUL)
606 {
622 {
607 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
623 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
608 if (aux > FLOAT_EQUAL_ZERO)
624 if (aux > FLOAT_EQUAL_ZERO)
609 {
625 {
610 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
626 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
611 flag = LFR_DEFAULT;
627 flag = LFR_DEFAULT;
612 }
628 }
613 }
629 }
614 // sy_lfr_n_cwf_long_f3
630 // sy_lfr_n_cwf_long_f3
615
631
616 return flag;
632 return flag;
617 }
633 }
618
634
619 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC )
635 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC )
620 {
636 {
621 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
637 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
622 *
638 *
623 * @param TC points to the TeleCommand packet that is being processed
639 * @param TC points to the TeleCommand packet that is being processed
624 * @param queue_id is the id of the queue which handles TM related to this execution step
640 * @param queue_id is the id of the queue which handles TM related to this execution step
625 *
641 *
626 */
642 */
627
643
628 int result;
644 int result;
629
645
630 result = LFR_SUCCESSFUL;
646 result = LFR_SUCCESSFUL;
631
647
632 parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
648 parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
633 parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
649 parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
634
650
635 return result;
651 return result;
636 }
652 }
637
653
638 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC )
654 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC )
639 {
655 {
640 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
656 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
641 *
657 *
642 * @param TC points to the TeleCommand packet that is being processed
658 * @param TC points to the TeleCommand packet that is being processed
643 * @param queue_id is the id of the queue which handles TM related to this execution step
659 * @param queue_id is the id of the queue which handles TM related to this execution step
644 *
660 *
645 */
661 */
646
662
647 int result;
663 int result;
648
664
649 result = LFR_SUCCESSFUL;
665 result = LFR_SUCCESSFUL;
650
666
651 parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
667 parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
652 parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
668 parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
653
669
654 return result;
670 return result;
655 }
671 }
656
672
657 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC )
673 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC )
658 {
674 {
659 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
675 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
660 *
676 *
661 * @param TC points to the TeleCommand packet that is being processed
677 * @param TC points to the TeleCommand packet that is being processed
662 * @param queue_id is the id of the queue which handles TM related to this execution step
678 * @param queue_id is the id of the queue which handles TM related to this execution step
663 *
679 *
664 */
680 */
665
681
666 int result;
682 int result;
667
683
668 result = LFR_SUCCESSFUL;
684 result = LFR_SUCCESSFUL;
669
685
670 parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
686 parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
671 parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
687 parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
672
688
673 return result;
689 return result;
674 }
690 }
675
691
676 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC )
692 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC )
677 {
693 {
678 /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0).
694 /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0).
679 *
695 *
680 * @param TC points to the TeleCommand packet that is being processed
696 * @param TC points to the TeleCommand packet that is being processed
681 * @param queue_id is the id of the queue which handles TM related to this execution step
697 * @param queue_id is the id of the queue which handles TM related to this execution step
682 *
698 *
683 */
699 */
684
700
685 int status;
701 int status;
686
702
687 status = LFR_SUCCESSFUL;
703 status = LFR_SUCCESSFUL;
688
704
689 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
705 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
690
706
691 return status;
707 return status;
692 }
708 }
693
709
694 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC )
710 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC )
695 {
711 {
696 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
712 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
697 *
713 *
698 * @param TC points to the TeleCommand packet that is being processed
714 * @param TC points to the TeleCommand packet that is being processed
699 * @param queue_id is the id of the queue which handles TM related to this execution step
715 * @param queue_id is the id of the queue which handles TM related to this execution step
700 *
716 *
701 */
717 */
702
718
703 int status;
719 int status;
704
720
705 status = LFR_SUCCESSFUL;
721 status = LFR_SUCCESSFUL;
706
722
707 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
723 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
708
724
709 return status;
725 return status;
710 }
726 }
711
727
712 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC )
728 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC )
713 {
729 {
714 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
730 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
715 *
731 *
716 * @param TC points to the TeleCommand packet that is being processed
732 * @param TC points to the TeleCommand packet that is being processed
717 * @param queue_id is the id of the queue which handles TM related to this execution step
733 * @param queue_id is the id of the queue which handles TM related to this execution step
718 *
734 *
719 */
735 */
720
736
721 int status;
737 int status;
722
738
723 status = LFR_SUCCESSFUL;
739 status = LFR_SUCCESSFUL;
724
740
725 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
741 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
726
742
727 return status;
743 return status;
728 }
744 }
729
745
730 //**********************
746 //**********************
731 // BURST MODE PARAMETERS
747 // BURST MODE PARAMETERS
732 int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC)
748 int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC)
733 {
749 {
734 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0).
750 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0).
735 *
751 *
736 * @param TC points to the TeleCommand packet that is being processed
752 * @param TC points to the TeleCommand packet that is being processed
737 * @param queue_id is the id of the queue which handles TM related to this execution step
753 * @param queue_id is the id of the queue which handles TM related to this execution step
738 *
754 *
739 */
755 */
740
756
741 int status;
757 int status;
742
758
743 status = LFR_SUCCESSFUL;
759 status = LFR_SUCCESSFUL;
744
760
745 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
761 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
746
762
747 return status;
763 return status;
748 }
764 }
749
765
750 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC )
766 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC )
751 {
767 {
752 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1).
768 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1).
753 *
769 *
754 * @param TC points to the TeleCommand packet that is being processed
770 * @param TC points to the TeleCommand packet that is being processed
755 * @param queue_id is the id of the queue which handles TM related to this execution step
771 * @param queue_id is the id of the queue which handles TM related to this execution step
756 *
772 *
757 */
773 */
758
774
759 int status;
775 int status;
760
776
761 status = LFR_SUCCESSFUL;
777 status = LFR_SUCCESSFUL;
762
778
763 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
779 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
764
780
765 return status;
781 return status;
766 }
782 }
767
783
768 //*********************
784 //*********************
769 // SBM1 MODE PARAMETERS
785 // SBM1 MODE PARAMETERS
770 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC )
786 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC )
771 {
787 {
772 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0).
788 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0).
773 *
789 *
774 * @param TC points to the TeleCommand packet that is being processed
790 * @param TC points to the TeleCommand packet that is being processed
775 * @param queue_id is the id of the queue which handles TM related to this execution step
791 * @param queue_id is the id of the queue which handles TM related to this execution step
776 *
792 *
777 */
793 */
778
794
779 int status;
795 int status;
780
796
781 status = LFR_SUCCESSFUL;
797 status = LFR_SUCCESSFUL;
782
798
783 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
799 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
784
800
785 return status;
801 return status;
786 }
802 }
787
803
788 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC )
804 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC )
789 {
805 {
790 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1).
806 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1).
791 *
807 *
792 * @param TC points to the TeleCommand packet that is being processed
808 * @param TC points to the TeleCommand packet that is being processed
793 * @param queue_id is the id of the queue which handles TM related to this execution step
809 * @param queue_id is the id of the queue which handles TM related to this execution step
794 *
810 *
795 */
811 */
796
812
797 int status;
813 int status;
798
814
799 status = LFR_SUCCESSFUL;
815 status = LFR_SUCCESSFUL;
800
816
801 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
817 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
802
818
803 return status;
819 return status;
804 }
820 }
805
821
806 //*********************
822 //*********************
807 // SBM2 MODE PARAMETERS
823 // SBM2 MODE PARAMETERS
808 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC )
824 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC )
809 {
825 {
810 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0).
826 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0).
811 *
827 *
812 * @param TC points to the TeleCommand packet that is being processed
828 * @param TC points to the TeleCommand packet that is being processed
813 * @param queue_id is the id of the queue which handles TM related to this execution step
829 * @param queue_id is the id of the queue which handles TM related to this execution step
814 *
830 *
815 */
831 */
816
832
817 int status;
833 int status;
818
834
819 status = LFR_SUCCESSFUL;
835 status = LFR_SUCCESSFUL;
820
836
821 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
837 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
822
838
823 return status;
839 return status;
824 }
840 }
825
841
826 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC )
842 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC )
827 {
843 {
828 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1).
844 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1).
829 *
845 *
830 * @param TC points to the TeleCommand packet that is being processed
846 * @param TC points to the TeleCommand packet that is being processed
831 * @param queue_id is the id of the queue which handles TM related to this execution step
847 * @param queue_id is the id of the queue which handles TM related to this execution step
832 *
848 *
833 */
849 */
834
850
835 int status;
851 int status;
836
852
837 status = LFR_SUCCESSFUL;
853 status = LFR_SUCCESSFUL;
838
854
839 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
855 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
840
856
841 return status;
857 return status;
842 }
858 }
843
859
844 //*******************
860 //*******************
845 // TC_LFR_UPDATE_INFO
861 // TC_LFR_UPDATE_INFO
846 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
862 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
847 {
863 {
848 unsigned int status;
864 unsigned int status;
849
865
850 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
866 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
851 || (mode == LFR_MODE_BURST)
867 || (mode == LFR_MODE_BURST)
852 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
868 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
853 {
869 {
854 status = LFR_SUCCESSFUL;
870 status = LFR_SUCCESSFUL;
855 }
871 }
856 else
872 else
857 {
873 {
858 status = LFR_DEFAULT;
874 status = LFR_DEFAULT;
859 }
875 }
860
876
861 return status;
877 return status;
862 }
878 }
863
879
864 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
880 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
865 {
881 {
866 unsigned int status;
882 unsigned int status;
867
883
868 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
884 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
869 || (mode == TDS_MODE_BURST)
885 || (mode == TDS_MODE_BURST)
870 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
886 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
871 || (mode == TDS_MODE_LFM))
887 || (mode == TDS_MODE_LFM))
872 {
888 {
873 status = LFR_SUCCESSFUL;
889 status = LFR_SUCCESSFUL;
874 }
890 }
875 else
891 else
876 {
892 {
877 status = LFR_DEFAULT;
893 status = LFR_DEFAULT;
878 }
894 }
879
895
880 return status;
896 return status;
881 }
897 }
882
898
883 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
899 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
884 {
900 {
885 unsigned int status;
901 unsigned int status;
886
902
887 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
903 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
888 || (mode == THR_MODE_BURST))
904 || (mode == THR_MODE_BURST))
889 {
905 {
890 status = LFR_SUCCESSFUL;
906 status = LFR_SUCCESSFUL;
891 }
907 }
892 else
908 else
893 {
909 {
894 status = LFR_DEFAULT;
910 status = LFR_DEFAULT;
895 }
911 }
896
912
897 return status;
913 return status;
898 }
914 }
899
915
900 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC )
916 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC )
901 {
917 {
902 /** This function get the reaction wheels frequencies in the incoming TC_LFR_UPDATE_INFO and copy the values locally.
918 /** This function get the reaction wheels frequencies in the incoming TC_LFR_UPDATE_INFO and copy the values locally.
903 *
919 *
904 * @param TC points to the TeleCommand packet that is being processed
920 * @param TC points to the TeleCommand packet that is being processed
905 *
921 *
906 */
922 */
907
923
908 unsigned char * bytePosPtr; // pointer to the beginning of the incoming TC packet
924 unsigned char * bytePosPtr; // pointer to the beginning of the incoming TC packet
909
925
910 bytePosPtr = (unsigned char *) &TC->packetID;
926 bytePosPtr = (unsigned char *) &TC->packetID;
911
927
912 // cp_rpw_sc_rw1_f1
928 // cp_rpw_sc_rw1_f1
913 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw1_f1,
929 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw1_f1,
914 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1 ] );
930 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1 ] );
915
931
916 // cp_rpw_sc_rw1_f2
932 // cp_rpw_sc_rw1_f2
917 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw1_f2,
933 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw1_f2,
918 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2 ] );
934 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2 ] );
919
935
920 // cp_rpw_sc_rw2_f1
936 // cp_rpw_sc_rw2_f1
921 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw2_f1,
937 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw2_f1,
922 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1 ] );
938 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1 ] );
923
939
924 // cp_rpw_sc_rw2_f2
940 // cp_rpw_sc_rw2_f2
925 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw2_f2,
941 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw2_f2,
926 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2 ] );
942 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2 ] );
927
943
928 // cp_rpw_sc_rw3_f1
944 // cp_rpw_sc_rw3_f1
929 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw3_f1,
945 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw3_f1,
930 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1 ] );
946 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1 ] );
931
947
932 // cp_rpw_sc_rw3_f2
948 // cp_rpw_sc_rw3_f2
933 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw3_f2,
949 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw3_f2,
934 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2 ] );
950 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2 ] );
935
951
936 // cp_rpw_sc_rw4_f1
952 // cp_rpw_sc_rw4_f1
937 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw4_f1,
953 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw4_f1,
938 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1 ] );
954 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1 ] );
939
955
940 // cp_rpw_sc_rw4_f2
956 // cp_rpw_sc_rw4_f2
941 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw4_f2,
957 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw4_f2,
942 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2 ] );
958 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2 ] );
943 }
959 }
944
960
945 void setFBinMask( unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, unsigned char flag )
961 void setFBinMask( unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, unsigned char flag )
946 {
962 {
947 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
963 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
948 *
964 *
949 * @param fbins_mask
965 * @param fbins_mask
950 * @param rw_f is the reaction wheel frequency to filter
966 * @param rw_f is the reaction wheel frequency to filter
951 * @param delta_f is the frequency step between the frequency bins, it depends on the frequency channel
967 * @param delta_f is the frequency step between the frequency bins, it depends on the frequency channel
952 * @param flag [true] filtering enabled [false] filtering disabled
968 * @param flag [true] filtering enabled [false] filtering disabled
953 *
969 *
954 * @return void
970 * @return void
955 *
971 *
956 */
972 */
957
973
958 float fmin;
974 float fmin;
959 float fMAX;
975 float fMAX;
960 int binBelow;
976 int binBelow;
961 int binAbove;
977 int binAbove;
962 unsigned int whichByte;
978 unsigned int whichByte;
963 unsigned char selectedByte;
979 unsigned char selectedByte;
964 int bin;
980 int bin;
965
981
966 whichByte = 0;
982 whichByte = 0;
967 bin = 0;
983 bin = 0;
968
984
969 // compute the frequency range to filter [ rw_f - delta_f/2; rw_f + delta_f/2 ]
985 // compute the frequency range to filter [ rw_f - delta_f/2; rw_f + delta_f/2 ]
970 fmin = rw_f - sy_lfr_sc_rw_delta_f / 2.;
986 fmin = rw_f - filterPar.sy_lfr_sc_rw_delta_f / 2.;
971 fMAX = rw_f + sy_lfr_sc_rw_delta_f / 2.;
987 fMAX = rw_f + filterPar.sy_lfr_sc_rw_delta_f / 2.;
972
988
973 // compute the index of the frequency bin immediately below fmin
989 // compute the index of the frequency bin immediately below fmin
974 binBelow = (int) ( floor( ((double) fmin) / ((double) deltaFreq)) );
990 binBelow = (int) ( floor( ((double) fmin) / ((double) deltaFreq)) );
975
991
976 // compute the index of the frequency bin immediately above fMAX
992 // compute the index of the frequency bin immediately above fMAX
977 binAbove = (int) ( floor( ((double) fMAX) / ((double) deltaFreq)) );
993 binAbove = (int) ( floor( ((double) fMAX) / ((double) deltaFreq)) );
978
994
979 for (bin = binBelow; bin <= binAbove; bin++)
995 for (bin = binBelow; bin <= binAbove; bin++)
980 {
996 {
981 if ( (bin >= 0) && (bin<=127) )
997 if ( (bin >= 0) && (bin<=127) )
982 {
998 {
983 if (flag == 1)
999 if (flag == 1)
984 {
1000 {
985 whichByte = bin >> 3; // division by 8
1001 whichByte = bin >> 3; // division by 8
986 selectedByte = (unsigned char) ( 1 << (bin - (whichByte * 8)) );
1002 selectedByte = (unsigned char) ( 1 << (bin - (whichByte * 8)) );
987 fbins_mask[whichByte] = fbins_mask[whichByte] & (~selectedByte);
1003 fbins_mask[whichByte] = fbins_mask[whichByte] & (~selectedByte);
988 }
1004 }
989 }
1005 }
990 }
1006 }
991 }
1007 }
992
1008
993 void build_sy_lfr_rw_mask( unsigned int channel )
1009 void build_sy_lfr_rw_mask( unsigned int channel )
994 {
1010 {
995 unsigned char local_rw_fbins_mask[16];
1011 unsigned char local_rw_fbins_mask[16];
996 unsigned char *maskPtr;
1012 unsigned char *maskPtr;
997 double deltaF;
1013 double deltaF;
998 unsigned k;
1014 unsigned k;
999
1015
1000 k = 0;
1016 k = 0;
1001
1017
1002 maskPtr = NULL;
1018 maskPtr = NULL;
1003 deltaF = 1.;
1019 deltaF = 1.;
1004
1020
1005 switch (channel)
1021 switch (channel)
1006 {
1022 {
1007 case 0:
1023 case 0:
1008 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f0_word1;
1024 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f0_word1;
1009 deltaF = 96.;
1025 deltaF = 96.;
1010 break;
1026 break;
1011 case 1:
1027 case 1:
1012 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f1_word1;
1028 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f1_word1;
1013 deltaF = 16.;
1029 deltaF = 16.;
1014 break;
1030 break;
1015 case 2:
1031 case 2:
1016 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f2_word1;
1032 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f2_word1;
1017 deltaF = 1.;
1033 deltaF = 1.;
1018 break;
1034 break;
1019 default:
1035 default:
1020 break;
1036 break;
1021 }
1037 }
1022
1038
1023 for (k = 0; k < 16; k++)
1039 for (k = 0; k < 16; k++)
1024 {
1040 {
1025 local_rw_fbins_mask[k] = 0xff;
1041 local_rw_fbins_mask[k] = 0xff;
1026 }
1042 }
1027
1043
1028 // RW1 F1
1044 // RW1 F1
1029 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x80) >> 7 ); // [1000 0000]
1045 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x80) >> 7 ); // [1000 0000]
1030
1046
1031 // RW1 F2
1047 // RW1 F2
1032 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x40) >> 6 ); // [0100 0000]
1048 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x40) >> 6 ); // [0100 0000]
1033
1049
1034 // RW2 F1
1050 // RW2 F1
1035 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x20) >> 5 ); // [0010 0000]
1051 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x20) >> 5 ); // [0010 0000]
1036
1052
1037 // RW2 F2
1053 // RW2 F2
1038 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x10) >> 4 ); // [0001 0000]
1054 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x10) >> 4 ); // [0001 0000]
1039
1055
1040 // RW3 F1
1056 // RW3 F1
1041 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x08) >> 3 ); // [0000 1000]
1057 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x08) >> 3 ); // [0000 1000]
1042
1058
1043 // RW3 F2
1059 // RW3 F2
1044 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x04) >> 2 ); // [0000 0100]
1060 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x04) >> 2 ); // [0000 0100]
1045
1061
1046 // RW4 F1
1062 // RW4 F1
1047 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw4_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x02) >> 1 ); // [0000 0010]
1063 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw4_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x02) >> 1 ); // [0000 0010]
1048
1064
1049 // RW4 F2
1065 // RW4 F2
1050 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x01) ); // [0000 0001]
1066 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x01) ); // [0000 0001]
1051
1067
1052 // update the value of the fbins related to reaction wheels frequency filtering
1068 // update the value of the fbins related to reaction wheels frequency filtering
1053 if (maskPtr != NULL)
1069 if (maskPtr != NULL)
1054 {
1070 {
1055 for (k = 0; k < 16; k++)
1071 for (k = 0; k < 16; k++)
1056 {
1072 {
1057 maskPtr[k] = local_rw_fbins_mask[k];
1073 maskPtr[k] = local_rw_fbins_mask[k];
1058 }
1074 }
1059 }
1075 }
1060 }
1076 }
1061
1077
1062 void build_sy_lfr_rw_masks( void )
1078 void build_sy_lfr_rw_masks( void )
1063 {
1079 {
1064 build_sy_lfr_rw_mask( 0 );
1080 build_sy_lfr_rw_mask( 0 );
1065 build_sy_lfr_rw_mask( 1 );
1081 build_sy_lfr_rw_mask( 1 );
1066 build_sy_lfr_rw_mask( 2 );
1082 build_sy_lfr_rw_mask( 2 );
1067
1083
1068 merge_fbins_masks();
1084 merge_fbins_masks();
1069 }
1085 }
1070
1086
1071 void merge_fbins_masks( void )
1087 void merge_fbins_masks( void )
1072 {
1088 {
1073 unsigned char k;
1089 unsigned char k;
1074
1090
1075 unsigned char *fbins_f0;
1091 unsigned char *fbins_f0;
1076 unsigned char *fbins_f1;
1092 unsigned char *fbins_f1;
1077 unsigned char *fbins_f2;
1093 unsigned char *fbins_f2;
1078 unsigned char *rw_mask_f0;
1094 unsigned char *rw_mask_f0;
1079 unsigned char *rw_mask_f1;
1095 unsigned char *rw_mask_f1;
1080 unsigned char *rw_mask_f2;
1096 unsigned char *rw_mask_f2;
1081
1097
1082 fbins_f0 = parameter_dump_packet.sy_lfr_fbins_f0_word1;
1098 fbins_f0 = parameter_dump_packet.sy_lfr_fbins_f0_word1;
1083 fbins_f1 = parameter_dump_packet.sy_lfr_fbins_f1_word1;
1099 fbins_f1 = parameter_dump_packet.sy_lfr_fbins_f1_word1;
1084 fbins_f2 = parameter_dump_packet.sy_lfr_fbins_f2_word1;
1100 fbins_f2 = parameter_dump_packet.sy_lfr_fbins_f2_word1;
1085 rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask_f0_word1;
1101 rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask_f0_word1;
1086 rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask_f1_word1;
1102 rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask_f1_word1;
1087 rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask_f2_word1;
1103 rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask_f2_word1;
1088
1104
1089 for( k=0; k < 16; k++ )
1105 for( k=0; k < 16; k++ )
1090 {
1106 {
1091 fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k];
1107 fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k];
1092 fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k];
1108 fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k];
1093 fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k];
1109 fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k];
1094 }
1110 }
1095 }
1111 }
1096
1112
1097 //***********
1113 //***********
1098 // FBINS MASK
1114 // FBINS MASK
1099
1115
1100 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC )
1116 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC )
1101 {
1117 {
1102 int status;
1118 int status;
1103 unsigned int k;
1119 unsigned int k;
1104 unsigned char *fbins_mask_dump;
1120 unsigned char *fbins_mask_dump;
1105 unsigned char *fbins_mask_TC;
1121 unsigned char *fbins_mask_TC;
1106
1122
1107 status = LFR_SUCCESSFUL;
1123 status = LFR_SUCCESSFUL;
1108
1124
1109 fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1;
1125 fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1;
1110 fbins_mask_TC = TC->dataAndCRC;
1126 fbins_mask_TC = TC->dataAndCRC;
1111
1127
1112 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1128 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1113 {
1129 {
1114 fbins_mask_dump[k] = fbins_mask_TC[k];
1130 fbins_mask_dump[k] = fbins_mask_TC[k];
1115 }
1131 }
1116
1132
1117 return status;
1133 return status;
1118 }
1134 }
1119
1135
1120 //***************************
1136 //***************************
1121 // TC_LFR_LOAD_PAS_FILTER_PAR
1137 // TC_LFR_LOAD_PAS_FILTER_PAR
1122
1138
1123 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
1139 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
1124 {
1140 {
1125 int flag;
1141 int flag;
1126 rtems_status_code status;
1142 rtems_status_code status;
1127
1143
1128 unsigned char sy_lfr_pas_filter_enabled;
1144 unsigned char sy_lfr_pas_filter_enabled;
1129 unsigned char sy_lfr_pas_filter_modulus;
1145 unsigned char sy_lfr_pas_filter_modulus;
1130 float sy_lfr_pas_filter_tbad;
1146 float sy_lfr_pas_filter_tbad;
1131 unsigned char sy_lfr_pas_filter_offset;
1147 unsigned char sy_lfr_pas_filter_offset;
1132 float sy_lfr_pas_filter_shift;
1148 float sy_lfr_pas_filter_shift;
1133 float sy_lfr_sc_rw_delta_f;
1149 float sy_lfr_sc_rw_delta_f;
1134 char *parPtr;
1150 char *parPtr;
1135
1151
1136 flag = LFR_SUCCESSFUL;
1152 flag = LFR_SUCCESSFUL;
1137 sy_lfr_pas_filter_tbad = 0.0;
1153 sy_lfr_pas_filter_tbad = 0.0;
1138 sy_lfr_pas_filter_shift = 0.0;
1154 sy_lfr_pas_filter_shift = 0.0;
1139 sy_lfr_sc_rw_delta_f = 0.0;
1155 sy_lfr_sc_rw_delta_f = 0.0;
1140 parPtr = NULL;
1156 parPtr = NULL;
1141
1157
1142 //***************
1158 //***************
1143 // get parameters
1159 // get parameters
1144 sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & 0x01; // [0000 0001]
1160 sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & 0x01; // [0000 0001]
1145 sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
1161 sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
1146 copyFloatByChar(
1162 copyFloatByChar(
1147 (unsigned char*) &sy_lfr_pas_filter_tbad,
1163 (unsigned char*) &sy_lfr_pas_filter_tbad,
1148 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ]
1164 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ]
1149 );
1165 );
1150 sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
1166 sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
1151 copyFloatByChar(
1167 copyFloatByChar(
1152 (unsigned char*) &sy_lfr_pas_filter_shift,
1168 (unsigned char*) &sy_lfr_pas_filter_shift,
1153 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ]
1169 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ]
1154 );
1170 );
1155 copyFloatByChar(
1171 copyFloatByChar(
1156 (unsigned char*) &sy_lfr_sc_rw_delta_f,
1172 (unsigned char*) &sy_lfr_sc_rw_delta_f,
1157 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ]
1173 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ]
1158 );
1174 );
1159
1175
1160 //******************
1176 //******************
1161 // CHECK CONSISTENCY
1177 // CHECK CONSISTENCY
1162
1178
1163 //**************************
1179 //**************************
1164 // sy_lfr_pas_filter_enabled
1180 // sy_lfr_pas_filter_enabled
1165 // nothing to check, value is 0 or 1
1181 // nothing to check, value is 0 or 1
1166
1182
1167 //**************************
1183 //**************************
1168 // sy_lfr_pas_filter_modulus
1184 // sy_lfr_pas_filter_modulus
1169 if ( (sy_lfr_pas_filter_modulus < 4) || (sy_lfr_pas_filter_modulus > 8) )
1185 if ( (sy_lfr_pas_filter_modulus < 4) || (sy_lfr_pas_filter_modulus > 8) )
1170 {
1186 {
1171 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS+10, sy_lfr_pas_filter_modulus );
1187 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS+10, sy_lfr_pas_filter_modulus );
1172 flag = WRONG_APP_DATA;
1188 flag = WRONG_APP_DATA;
1173 }
1189 }
1174
1190
1175 //***********************
1191 //***********************
1176 // sy_lfr_pas_filter_tbad
1192 // sy_lfr_pas_filter_tbad
1177 if ( (sy_lfr_pas_filter_tbad < 0.0) || (sy_lfr_pas_filter_tbad > 4.0) )
1193 if ( (sy_lfr_pas_filter_tbad < 0.0) || (sy_lfr_pas_filter_tbad > 4.0) )
1178 {
1194 {
1179 parPtr = (char*) &sy_lfr_pas_filter_tbad;
1195 parPtr = (char*) &sy_lfr_pas_filter_tbad;
1180 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD+10, parPtr[3] );
1196 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD+10, parPtr[3] );
1181 flag = WRONG_APP_DATA;
1197 flag = WRONG_APP_DATA;
1182 }
1198 }
1183
1199
1184 //*************************
1200 //*************************
1185 // sy_lfr_pas_filter_offset
1201 // sy_lfr_pas_filter_offset
1186 if (flag == LFR_SUCCESSFUL)
1202 if (flag == LFR_SUCCESSFUL)
1187 {
1203 {
1188 if ( (sy_lfr_pas_filter_offset < 0) || (sy_lfr_pas_filter_offset > 7) )
1204 if ( (sy_lfr_pas_filter_offset < 0) || (sy_lfr_pas_filter_offset > 7) )
1189 {
1205 {
1190 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET+10, sy_lfr_pas_filter_offset );
1206 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET+10, sy_lfr_pas_filter_offset );
1191 flag = WRONG_APP_DATA;
1207 flag = WRONG_APP_DATA;
1192 }
1208 }
1193 }
1209 }
1194
1210
1195 //************************
1211 //************************
1196 // sy_lfr_pas_filter_shift
1212 // sy_lfr_pas_filter_shift
1197 if ( (sy_lfr_pas_filter_shift < 0.0) || (sy_lfr_pas_filter_shift > 1.0) )
1213 if ( (sy_lfr_pas_filter_shift < 0.0) || (sy_lfr_pas_filter_shift > 1.0) )
1198 {
1214 {
1199 parPtr = (char*) &sy_lfr_pas_filter_shift;
1215 parPtr = (char*) &sy_lfr_pas_filter_shift;
1200 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT+10, parPtr[3] );
1216 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT+10, parPtr[3] );
1201 flag = WRONG_APP_DATA;
1217 flag = WRONG_APP_DATA;
1202 }
1218 }
1203
1219
1204 //*********************
1220 //*********************
1205 // sy_lfr_sc_rw_delta_f
1221 // sy_lfr_sc_rw_delta_f
1206 // nothing to check, no default value in the ICD
1222 // nothing to check, no default value in the ICD
1207
1223
1208 return flag;
1224 return flag;
1209 }
1225 }
1210
1226
1211 //**************
1227 //**************
1212 // KCOEFFICIENTS
1228 // KCOEFFICIENTS
1213 int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id )
1229 int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id )
1214 {
1230 {
1215 unsigned int kcoeff;
1231 unsigned int kcoeff;
1216 unsigned short sy_lfr_kcoeff_frequency;
1232 unsigned short sy_lfr_kcoeff_frequency;
1217 unsigned short bin;
1233 unsigned short bin;
1218 unsigned short *freqPtr;
1234 unsigned short *freqPtr;
1219 float *kcoeffPtr_norm;
1235 float *kcoeffPtr_norm;
1220 float *kcoeffPtr_sbm;
1236 float *kcoeffPtr_sbm;
1221 int status;
1237 int status;
1222 unsigned char *kcoeffLoadPtr;
1238 unsigned char *kcoeffLoadPtr;
1223 unsigned char *kcoeffNormPtr;
1239 unsigned char *kcoeffNormPtr;
1224 unsigned char *kcoeffSbmPtr_a;
1240 unsigned char *kcoeffSbmPtr_a;
1225 unsigned char *kcoeffSbmPtr_b;
1241 unsigned char *kcoeffSbmPtr_b;
1226
1242
1227 status = LFR_SUCCESSFUL;
1243 status = LFR_SUCCESSFUL;
1228
1244
1229 kcoeffPtr_norm = NULL;
1245 kcoeffPtr_norm = NULL;
1230 kcoeffPtr_sbm = NULL;
1246 kcoeffPtr_sbm = NULL;
1231 bin = 0;
1247 bin = 0;
1232
1248
1233 freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY];
1249 freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY];
1234 sy_lfr_kcoeff_frequency = *freqPtr;
1250 sy_lfr_kcoeff_frequency = *freqPtr;
1235
1251
1236 if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM )
1252 if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM )
1237 {
1253 {
1238 PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency)
1254 PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency)
1239 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1,
1255 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1,
1240 TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB
1256 TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB
1241 status = LFR_DEFAULT;
1257 status = LFR_DEFAULT;
1242 }
1258 }
1243 else
1259 else
1244 {
1260 {
1245 if ( ( sy_lfr_kcoeff_frequency >= 0 )
1261 if ( ( sy_lfr_kcoeff_frequency >= 0 )
1246 && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) )
1262 && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) )
1247 {
1263 {
1248 kcoeffPtr_norm = k_coeff_intercalib_f0_norm;
1264 kcoeffPtr_norm = k_coeff_intercalib_f0_norm;
1249 kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm;
1265 kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm;
1250 bin = sy_lfr_kcoeff_frequency;
1266 bin = sy_lfr_kcoeff_frequency;
1251 }
1267 }
1252 else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 )
1268 else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 )
1253 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) )
1269 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) )
1254 {
1270 {
1255 kcoeffPtr_norm = k_coeff_intercalib_f1_norm;
1271 kcoeffPtr_norm = k_coeff_intercalib_f1_norm;
1256 kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm;
1272 kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm;
1257 bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0;
1273 bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0;
1258 }
1274 }
1259 else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) )
1275 else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) )
1260 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) )
1276 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) )
1261 {
1277 {
1262 kcoeffPtr_norm = k_coeff_intercalib_f2;
1278 kcoeffPtr_norm = k_coeff_intercalib_f2;
1263 kcoeffPtr_sbm = NULL;
1279 kcoeffPtr_sbm = NULL;
1264 bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1);
1280 bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1);
1265 }
1281 }
1266 }
1282 }
1267
1283
1268 if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products
1284 if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products
1269 {
1285 {
1270 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1286 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1271 {
1287 {
1272 // destination
1288 // destination
1273 kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ];
1289 kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ];
1274 // source
1290 // source
1275 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
1291 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
1276 // copy source to destination
1292 // copy source to destination
1277 copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr );
1293 copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr );
1278 }
1294 }
1279 }
1295 }
1280
1296
1281 if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products
1297 if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products
1282 {
1298 {
1283 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1299 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1284 {
1300 {
1285 // destination
1301 // destination
1286 kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ];
1302 kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ];
1287 kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ];
1303 kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ];
1288 // source
1304 // source
1289 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
1305 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
1290 // copy source to destination
1306 // copy source to destination
1291 copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr );
1307 copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr );
1292 copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr );
1308 copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr );
1293 }
1309 }
1294 }
1310 }
1295
1311
1296 // print_k_coeff();
1312 // print_k_coeff();
1297
1313
1298 return status;
1314 return status;
1299 }
1315 }
1300
1316
1301 void copyFloatByChar( unsigned char *destination, unsigned char *source )
1317 void copyFloatByChar( unsigned char *destination, unsigned char *source )
1302 {
1318 {
1303 destination[0] = source[0];
1319 destination[0] = source[0];
1304 destination[1] = source[1];
1320 destination[1] = source[1];
1305 destination[2] = source[2];
1321 destination[2] = source[2];
1306 destination[3] = source[3];
1322 destination[3] = source[3];
1307 }
1323 }
1308
1324
1309 //**********
1325 //**********
1310 // init dump
1326 // init dump
1311
1327
1312 void init_parameter_dump( void )
1328 void init_parameter_dump( void )
1313 {
1329 {
1314 /** This function initialize the parameter_dump_packet global variable with default values.
1330 /** This function initialize the parameter_dump_packet global variable with default values.
1315 *
1331 *
1316 */
1332 */
1317
1333
1318 unsigned int k;
1334 unsigned int k;
1319
1335
1320 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
1336 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
1321 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1337 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1322 parameter_dump_packet.reserved = CCSDS_RESERVED;
1338 parameter_dump_packet.reserved = CCSDS_RESERVED;
1323 parameter_dump_packet.userApplication = CCSDS_USER_APP;
1339 parameter_dump_packet.userApplication = CCSDS_USER_APP;
1324 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
1340 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
1325 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1341 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1326 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1342 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1327 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1343 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1328 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
1344 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
1329 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
1345 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
1330 // DATA FIELD HEADER
1346 // DATA FIELD HEADER
1331 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1347 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1332 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
1348 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
1333 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
1349 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
1334 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
1350 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
1335 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1351 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1336 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1352 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1337 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1353 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1338 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
1354 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
1339 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1355 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1340 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
1356 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
1341 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
1357 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
1342
1358
1343 //******************
1359 //******************
1344 // COMMON PARAMETERS
1360 // COMMON PARAMETERS
1345 parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0;
1361 parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0;
1346 parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1;
1362 parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1;
1347
1363
1348 //******************
1364 //******************
1349 // NORMAL PARAMETERS
1365 // NORMAL PARAMETERS
1350 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8);
1366 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8);
1351 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L );
1367 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L );
1352 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8);
1368 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8);
1353 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P );
1369 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P );
1354 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8);
1370 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8);
1355 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P );
1371 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P );
1356 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0;
1372 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0;
1357 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1;
1373 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1;
1358 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3;
1374 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3;
1359
1375
1360 //*****************
1376 //*****************
1361 // BURST PARAMETERS
1377 // BURST PARAMETERS
1362 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
1378 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
1363 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
1379 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
1364
1380
1365 //****************
1381 //****************
1366 // SBM1 PARAMETERS
1382 // SBM1 PARAMETERS
1367 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
1383 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
1368 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
1384 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
1369
1385
1370 //****************
1386 //****************
1371 // SBM2 PARAMETERS
1387 // SBM2 PARAMETERS
1372 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
1388 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
1373 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
1389 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
1374
1390
1375 //************
1391 //************
1376 // FBINS MASKS
1392 // FBINS MASKS
1377 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1393 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1378 {
1394 {
1379 parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff;
1395 parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff;
1380 }
1396 }
1381 }
1397 }
1382
1398
1383 void init_kcoefficients_dump( void )
1399 void init_kcoefficients_dump( void )
1384 {
1400 {
1385 init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 );
1401 init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 );
1386 init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 );
1402 init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 );
1387
1403
1388 kcoefficient_node_1.previous = NULL;
1404 kcoefficient_node_1.previous = NULL;
1389 kcoefficient_node_1.next = NULL;
1405 kcoefficient_node_1.next = NULL;
1390 kcoefficient_node_1.sid = TM_CODE_K_DUMP;
1406 kcoefficient_node_1.sid = TM_CODE_K_DUMP;
1391 kcoefficient_node_1.coarseTime = 0x00;
1407 kcoefficient_node_1.coarseTime = 0x00;
1392 kcoefficient_node_1.fineTime = 0x00;
1408 kcoefficient_node_1.fineTime = 0x00;
1393 kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1;
1409 kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1;
1394 kcoefficient_node_1.status = 0x00;
1410 kcoefficient_node_1.status = 0x00;
1395
1411
1396 kcoefficient_node_2.previous = NULL;
1412 kcoefficient_node_2.previous = NULL;
1397 kcoefficient_node_2.next = NULL;
1413 kcoefficient_node_2.next = NULL;
1398 kcoefficient_node_2.sid = TM_CODE_K_DUMP;
1414 kcoefficient_node_2.sid = TM_CODE_K_DUMP;
1399 kcoefficient_node_2.coarseTime = 0x00;
1415 kcoefficient_node_2.coarseTime = 0x00;
1400 kcoefficient_node_2.fineTime = 0x00;
1416 kcoefficient_node_2.fineTime = 0x00;
1401 kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2;
1417 kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2;
1402 kcoefficient_node_2.status = 0x00;
1418 kcoefficient_node_2.status = 0x00;
1403 }
1419 }
1404
1420
1405 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr )
1421 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr )
1406 {
1422 {
1407 unsigned int k;
1423 unsigned int k;
1408 unsigned int packetLength;
1424 unsigned int packetLength;
1409
1425
1410 packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header
1426 packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header
1411
1427
1412 kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID;
1428 kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID;
1413 kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID;
1429 kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID;
1414 kcoefficients_dump->reserved = CCSDS_RESERVED;
1430 kcoefficients_dump->reserved = CCSDS_RESERVED;
1415 kcoefficients_dump->userApplication = CCSDS_USER_APP;
1431 kcoefficients_dump->userApplication = CCSDS_USER_APP;
1416 kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);;
1432 kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);;
1417 kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;;
1433 kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;;
1418 kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1434 kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1419 kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1435 kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1420 kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8);
1436 kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8);
1421 kcoefficients_dump->packetLength[1] = (unsigned char) packetLength;
1437 kcoefficients_dump->packetLength[1] = (unsigned char) packetLength;
1422 // DATA FIELD HEADER
1438 // DATA FIELD HEADER
1423 kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1439 kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1424 kcoefficients_dump->serviceType = TM_TYPE_K_DUMP;
1440 kcoefficients_dump->serviceType = TM_TYPE_K_DUMP;
1425 kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP;
1441 kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP;
1426 kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND;
1442 kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND;
1427 kcoefficients_dump->time[0] = 0x00;
1443 kcoefficients_dump->time[0] = 0x00;
1428 kcoefficients_dump->time[1] = 0x00;
1444 kcoefficients_dump->time[1] = 0x00;
1429 kcoefficients_dump->time[2] = 0x00;
1445 kcoefficients_dump->time[2] = 0x00;
1430 kcoefficients_dump->time[3] = 0x00;
1446 kcoefficients_dump->time[3] = 0x00;
1431 kcoefficients_dump->time[4] = 0x00;
1447 kcoefficients_dump->time[4] = 0x00;
1432 kcoefficients_dump->time[5] = 0x00;
1448 kcoefficients_dump->time[5] = 0x00;
1433 kcoefficients_dump->sid = SID_K_DUMP;
1449 kcoefficients_dump->sid = SID_K_DUMP;
1434
1450
1435 kcoefficients_dump->pkt_cnt = 2;
1451 kcoefficients_dump->pkt_cnt = 2;
1436 kcoefficients_dump->pkt_nr = pkt_nr;
1452 kcoefficients_dump->pkt_nr = pkt_nr;
1437 kcoefficients_dump->blk_nr = blk_nr;
1453 kcoefficients_dump->blk_nr = blk_nr;
1438
1454
1439 //******************
1455 //******************
1440 // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR]
1456 // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR]
1441 // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900)
1457 // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900)
1442 for (k=0; k<3900; k++)
1458 for (k=0; k<3900; k++)
1443 {
1459 {
1444 kcoefficients_dump->kcoeff_blks[k] = 0x00;
1460 kcoefficients_dump->kcoeff_blks[k] = 0x00;
1445 }
1461 }
1446 }
1462 }
1447
1463
1448 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id )
1464 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id )
1449 {
1465 {
1450 /** This function increment the packet sequence control parameter of a TC, depending on its destination ID.
1466 /** This function increment the packet sequence control parameter of a TC, depending on its destination ID.
1451 *
1467 *
1452 * @param packet_sequence_control points to the packet sequence control which will be incremented
1468 * @param packet_sequence_control points to the packet sequence control which will be incremented
1453 * @param destination_id is the destination ID of the TM, there is one counter by destination ID
1469 * @param destination_id is the destination ID of the TM, there is one counter by destination ID
1454 *
1470 *
1455 * If the destination ID is not known, a dedicated counter is incremented.
1471 * If the destination ID is not known, a dedicated counter is incremented.
1456 *
1472 *
1457 */
1473 */
1458
1474
1459 unsigned short sequence_cnt;
1475 unsigned short sequence_cnt;
1460 unsigned short segmentation_grouping_flag;
1476 unsigned short segmentation_grouping_flag;
1461 unsigned short new_packet_sequence_control;
1477 unsigned short new_packet_sequence_control;
1462 unsigned char i;
1478 unsigned char i;
1463
1479
1464 switch (destination_id)
1480 switch (destination_id)
1465 {
1481 {
1466 case SID_TC_GROUND:
1482 case SID_TC_GROUND:
1467 i = GROUND;
1483 i = GROUND;
1468 break;
1484 break;
1469 case SID_TC_MISSION_TIMELINE:
1485 case SID_TC_MISSION_TIMELINE:
1470 i = MISSION_TIMELINE;
1486 i = MISSION_TIMELINE;
1471 break;
1487 break;
1472 case SID_TC_TC_SEQUENCES:
1488 case SID_TC_TC_SEQUENCES:
1473 i = TC_SEQUENCES;
1489 i = TC_SEQUENCES;
1474 break;
1490 break;
1475 case SID_TC_RECOVERY_ACTION_CMD:
1491 case SID_TC_RECOVERY_ACTION_CMD:
1476 i = RECOVERY_ACTION_CMD;
1492 i = RECOVERY_ACTION_CMD;
1477 break;
1493 break;
1478 case SID_TC_BACKUP_MISSION_TIMELINE:
1494 case SID_TC_BACKUP_MISSION_TIMELINE:
1479 i = BACKUP_MISSION_TIMELINE;
1495 i = BACKUP_MISSION_TIMELINE;
1480 break;
1496 break;
1481 case SID_TC_DIRECT_CMD:
1497 case SID_TC_DIRECT_CMD:
1482 i = DIRECT_CMD;
1498 i = DIRECT_CMD;
1483 break;
1499 break;
1484 case SID_TC_SPARE_GRD_SRC1:
1500 case SID_TC_SPARE_GRD_SRC1:
1485 i = SPARE_GRD_SRC1;
1501 i = SPARE_GRD_SRC1;
1486 break;
1502 break;
1487 case SID_TC_SPARE_GRD_SRC2:
1503 case SID_TC_SPARE_GRD_SRC2:
1488 i = SPARE_GRD_SRC2;
1504 i = SPARE_GRD_SRC2;
1489 break;
1505 break;
1490 case SID_TC_OBCP:
1506 case SID_TC_OBCP:
1491 i = OBCP;
1507 i = OBCP;
1492 break;
1508 break;
1493 case SID_TC_SYSTEM_CONTROL:
1509 case SID_TC_SYSTEM_CONTROL:
1494 i = SYSTEM_CONTROL;
1510 i = SYSTEM_CONTROL;
1495 break;
1511 break;
1496 case SID_TC_AOCS:
1512 case SID_TC_AOCS:
1497 i = AOCS;
1513 i = AOCS;
1498 break;
1514 break;
1499 case SID_TC_RPW_INTERNAL:
1515 case SID_TC_RPW_INTERNAL:
1500 i = RPW_INTERNAL;
1516 i = RPW_INTERNAL;
1501 break;
1517 break;
1502 default:
1518 default:
1503 i = GROUND;
1519 i = GROUND;
1504 break;
1520 break;
1505 }
1521 }
1506
1522
1507 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1523 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1508 sequence_cnt = sequenceCounters_TM_DUMP[ i ] & 0x3fff;
1524 sequence_cnt = sequenceCounters_TM_DUMP[ i ] & 0x3fff;
1509
1525
1510 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
1526 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
1511
1527
1512 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1528 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1513 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1529 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1514
1530
1515 // increment the sequence counter
1531 // increment the sequence counter
1516 if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX )
1532 if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX )
1517 {
1533 {
1518 sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1;
1534 sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1;
1519 }
1535 }
1520 else
1536 else
1521 {
1537 {
1522 sequenceCounters_TM_DUMP[ i ] = 0;
1538 sequenceCounters_TM_DUMP[ i ] = 0;
1523 }
1539 }
1524 }
1540 }
General Comments 0
You need to be logged in to leave comments. Login now