##// END OF EJS Templates
compliance with ICD 4.3...
paul -
r299:7f467c56a168 R3_plus draft
parent child
Show More
@@ -1,2 +1,2
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
2 94f0f2fccbcb8030d9437ffbb69ee0eefaaea188 header/lfr_common_headers
2 5cf0bac6095ff491d937622f8253c6f05095cb39 header/lfr_common_headers
@@ -1,125 +1,133
1 TEMPLATE = app
1 TEMPLATE = app
2 CONFIG += console
3 CONFIG -= app_bundle
4 CONFIG -= qt
5
6 include(sparc.pri)
7
8 INCLUDEPATH += ./
9
10 OBJECTS_DIR=obj
11 DESTDIR=bin
12
2 # CONFIG += console v8 sim
13 # CONFIG += console v8 sim
3 # CONFIG options =
14 # CONFIG options =
4 # verbose
15 # verbose
5 # boot_messages
16 # boot_messages
6 # debug_messages
17 # debug_messages
7 # cpu_usage_report
18 # cpu_usage_report
8 # stack_report
19 # stack_report
9 # vhdl_dev
20 # vhdl_dev
10 # debug_tch
21 # debug_tch
11 # lpp_dpu_destid /!\ REMOVE BEFORE DELIVERY TO LESIA /!\
22 # lpp_dpu_destid /!\ REMOVE BEFORE DELIVERY TO LESIA /!\
12 # debug_watchdog
23 # debug_watchdog
13 CONFIG += console verbose lpp_dpu_destid cpu_usage_report
24 CONFIG += console verbose lpp_dpu_destid cpu_usage_report
14 CONFIG -= qt
15
16 include(./sparc.pri)
17
25
18 INCLUDEPATH += /opt/rtems-4.10/sparc-rtems/leon3/lib/include
26 INCLUDEPATH += /opt/rtems-4.10/sparc-rtems/leon3/lib/include
19
27
20 # flight software version
28 # flight software version
21 SWVERSION=-1-0
29 SWVERSION=-1-0
22 DEFINES += SW_VERSION_N1=3 # major
30 DEFINES += SW_VERSION_N1=3 # major
23 DEFINES += SW_VERSION_N2=1 # minor
31 DEFINES += SW_VERSION_N2=1 # minor
24 DEFINES += SW_VERSION_N3=0 # patch
32 DEFINES += SW_VERSION_N3=0 # patch
25 DEFINES += SW_VERSION_N4=4 # internal
33 DEFINES += SW_VERSION_N4=4 # internal
26
34
27 # <GCOV>
35 # <GCOV>
28 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
36 #QMAKE_CFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
29 #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc
37 #LIBS += -lgcov /opt/GCOV/01A/lib/overload.o -lc
30 # </GCOV>
38 # </GCOV>
31
39
32 # <CHANGE BEFORE FLIGHT>
40 # <CHANGE BEFORE FLIGHT>
33 contains( CONFIG, lpp_dpu_destid ) {
41 contains( CONFIG, lpp_dpu_destid ) {
34 DEFINES += LPP_DPU_DESTID
42 DEFINES += LPP_DPU_DESTID
35 }
43 }
36 # </CHANGE BEFORE FLIGHT>
44 # </CHANGE BEFORE FLIGHT>
37
45
38 contains( CONFIG, debug_tch ) {
46 contains( CONFIG, debug_tch ) {
39 DEFINES += DEBUG_TCH
47 DEFINES += DEBUG_TCH
40 }
48 }
41 DEFINES += MSB_FIRST_TCH
49 DEFINES += MSB_FIRST_TCH
42
50
43 contains( CONFIG, vhdl_dev ) {
51 contains( CONFIG, vhdl_dev ) {
44 DEFINES += VHDL_DEV
52 DEFINES += VHDL_DEV
45 }
53 }
46
54
47 contains( CONFIG, verbose ) {
55 contains( CONFIG, verbose ) {
48 DEFINES += PRINT_MESSAGES_ON_CONSOLE
56 DEFINES += PRINT_MESSAGES_ON_CONSOLE
49 }
57 }
50
58
51 contains( CONFIG, debug_messages ) {
59 contains( CONFIG, debug_messages ) {
52 DEFINES += DEBUG_MESSAGES
60 DEFINES += DEBUG_MESSAGES
53 }
61 }
54
62
55 contains( CONFIG, cpu_usage_report ) {
63 contains( CONFIG, cpu_usage_report ) {
56 DEFINES += PRINT_TASK_STATISTICS
64 DEFINES += PRINT_TASK_STATISTICS
57 }
65 }
58
66
59 contains( CONFIG, stack_report ) {
67 contains( CONFIG, stack_report ) {
60 DEFINES += PRINT_STACK_REPORT
68 DEFINES += PRINT_STACK_REPORT
61 }
69 }
62
70
63 contains( CONFIG, boot_messages ) {
71 contains( CONFIG, boot_messages ) {
64 DEFINES += BOOT_MESSAGES
72 DEFINES += BOOT_MESSAGES
65 }
73 }
66
74
67 contains( CONFIG, debug_watchdog ) {
75 contains( CONFIG, debug_watchdog ) {
68 DEFINES += DEBUG_WATCHDOG
76 DEFINES += DEBUG_WATCHDOG
69 }
77 }
70
78
71 #doxygen.target = doxygen
79 #doxygen.target = doxygen
72 #doxygen.commands = doxygen ../doc/Doxyfile
80 #doxygen.commands = doxygen ../doc/Doxyfile
73 #QMAKE_EXTRA_TARGETS += doxygen
81 #QMAKE_EXTRA_TARGETS += doxygen
74
82
75 TARGET = fsw
83 TARGET = fsw
76
84
77 INCLUDEPATH += \
85 INCLUDEPATH += \
78 $${PWD}/../src \
86 $${PWD}/../src \
79 $${PWD}/../header \
87 $${PWD}/../header \
80 $${PWD}/../header/lfr_common_headers \
88 $${PWD}/../header/lfr_common_headers \
81 $${PWD}/../header/processing \
89 $${PWD}/../header/processing \
82 $${PWD}/../LFR_basic-parameters
90 $${PWD}/../LFR_basic-parameters
83
91
84 SOURCES += \
92 SOURCES += \
85 ../src/wf_handler.c \
93 ../src/wf_handler.c \
86 ../src/tc_handler.c \
94 ../src/tc_handler.c \
87 ../src/fsw_misc.c \
95 ../src/fsw_misc.c \
88 ../src/fsw_init.c \
96 ../src/fsw_init.c \
89 ../src/fsw_globals.c \
97 ../src/fsw_globals.c \
90 ../src/fsw_spacewire.c \
98 ../src/fsw_spacewire.c \
91 ../src/tc_load_dump_parameters.c \
99 ../src/tc_load_dump_parameters.c \
92 ../src/tm_lfr_tc_exe.c \
100 ../src/tm_lfr_tc_exe.c \
93 ../src/tc_acceptance.c \
101 ../src/tc_acceptance.c \
94 ../src/processing/fsw_processing.c \
102 ../src/processing/fsw_processing.c \
95 ../src/processing/avf0_prc0.c \
103 ../src/processing/avf0_prc0.c \
96 ../src/processing/avf1_prc1.c \
104 ../src/processing/avf1_prc1.c \
97 ../src/processing/avf2_prc2.c \
105 ../src/processing/avf2_prc2.c \
98 ../src/lfr_cpu_usage_report.c \
106 ../src/lfr_cpu_usage_report.c \
99 ../LFR_basic-parameters/basic_parameters.c
107 ../LFR_basic-parameters/basic_parameters.c
100
108
101 HEADERS += \
109 HEADERS += \
102 ../header/wf_handler.h \
110 ../header/wf_handler.h \
103 ../header/tc_handler.h \
111 ../header/tc_handler.h \
104 ../header/grlib_regs.h \
112 ../header/grlib_regs.h \
105 ../header/fsw_misc.h \
113 ../header/fsw_misc.h \
106 ../header/fsw_init.h \
114 ../header/fsw_init.h \
107 ../header/fsw_spacewire.h \
115 ../header/fsw_spacewire.h \
108 ../header/tc_load_dump_parameters.h \
116 ../header/tc_load_dump_parameters.h \
109 ../header/tm_lfr_tc_exe.h \
117 ../header/tm_lfr_tc_exe.h \
110 ../header/tc_acceptance.h \
118 ../header/tc_acceptance.h \
111 ../header/processing/fsw_processing.h \
119 ../header/processing/fsw_processing.h \
112 ../header/processing/avf0_prc0.h \
120 ../header/processing/avf0_prc0.h \
113 ../header/processing/avf1_prc1.h \
121 ../header/processing/avf1_prc1.h \
114 ../header/processing/avf2_prc2.h \
122 ../header/processing/avf2_prc2.h \
115 ../header/fsw_params_wf_handler.h \
123 ../header/fsw_params_wf_handler.h \
116 ../header/lfr_cpu_usage_report.h \
124 ../header/lfr_cpu_usage_report.h \
117 ../header/lfr_common_headers/ccsds_types.h \
125 ../header/lfr_common_headers/ccsds_types.h \
118 ../header/lfr_common_headers/fsw_params.h \
126 ../header/lfr_common_headers/fsw_params.h \
119 ../header/lfr_common_headers/fsw_params_nb_bytes.h \
127 ../header/lfr_common_headers/fsw_params_nb_bytes.h \
120 ../header/lfr_common_headers/fsw_params_processing.h \
128 ../header/lfr_common_headers/fsw_params_processing.h \
121 ../header/lfr_common_headers/tm_byte_positions.h \
129 ../header/lfr_common_headers/tm_byte_positions.h \
122 ../LFR_basic-parameters/basic_parameters.h \
130 ../LFR_basic-parameters/basic_parameters.h \
123 ../LFR_basic-parameters/basic_parameters_params.h \
131 ../LFR_basic-parameters/basic_parameters_params.h \
124 ../header/GscMemoryLPP.hpp
132 ../header/GscMemoryLPP.hpp
125
133
@@ -1,99 +1,69
1 CONFIG += console
1
2 CONFIG -= qt
3 QMAKE_CC=sparc-rtems-gcc
2 QMAKE_CC=sparc-rtems-gcc
4 message(C compiler forced to: $$QMAKE_CC)
3 message(C compiler forced to: $$QMAKE_CC)
5 QMAKE_CXX=sparc-rtems-g++
4 QMAKE_CXX=sparc-rtems-g++
6 message(C++ compiler forced to: $$QMAKE_CXX)
5 message(C++ compiler forced to: $$QMAKE_CXX)
7 QMAKE_AR=sparc-rtems-ar rcs
6 QMAKE_AR=sparc-rtems-ar rcs
8 message(Archiver forced to: $$QMAKE_AR)
7 message(Archiver forced to: $$QMAKE_AR)
9 QMAKE_LINK=sparc-rtems-g++
8 QMAKE_LINK=sparc-rtems-g++
10 message(Linker forced to: $$QMAKE_LINK)
9 message(Linker forced to: $$QMAKE_LINK)
11 QMAKE_LINK_SHLIB=sparc-rtems-g++
10 QMAKE_LINK_SHLIB=sparc-rtems-g++
12 QMAKE_OBJCOPY= sparc-rtems-objcopy
11 QMAKE_OBJCOPY= sparc-rtems-objcopy
13 QMAKE_STRIP=sparc-rtems-strip
12 QMAKE_STRIP=sparc-rtems-strip
14 QMAKE_GDB=sparc-rtems-gdb
13 QMAKE_GDB=sparc-rtems-gdb
15
14
16 #INCLUDEPATH += /opt/rtems-4.10
15 QMAKE_CFLAGS_APP=""
17 INCLUDEPATH += /opt/rtems-4.10/sparc-rtems/leon3/lib/include
16 QMAKE_CXXFLAGS_APP=""
18
17 QMAKE_CFLAGS=
19 QMAKE_CFLAGS_DEBUG= -g
18 QMAKE_CFLAGS_DEBUG= -g
20 QMAKE_CFLAGS_RELEASE=""
19 QMAKE_CFLAGS_RELEASE=""
21 QMAKE_CXXFLAGS_DEBUG= -g
20 QMAKE_CXXFLAGS_DEBUG= -g
22 QMAKE_CXXFLAGS_RELEASE=""
21 QMAKE_CXXFLAGS_RELEASE=""
23 QMAKE_LFLAGS_RELEASE=""
22 QMAKE_LFLAGS_RELEASE=
24 QMAKE_LFLAGS_DEBUG= -g
23 QMAKE_LFLAGS_DEBUG= -g
25 QMAKE_CXXFLAGS_DEPS =
24 QMAKE_CXXFLAGS_DEPS =
26 QMAKE_CXXFLAGS_WARN_ON = -Wall
25 QMAKE_CXXFLAGS_WARN_ON = -Wall
27 QMAKE_CXXFLAGS_WARN_OFF = -w
26 QMAKE_CXXFLAGS_WARN_OFF = -w
28 QMAKE_CXXFLAGS_RELEASE =
27 QMAKE_CXXFLAGS_RELEASE =
29 QMAKE_CXXFLAGS_DEBUG =
28 QMAKE_CXXFLAGS_DEBUG =
30 QMAKE_CXXFLAGS_YACC =
29 QMAKE_CXXFLAGS_YACC =
31 QMAKE_CXXFLAGS_THREAD =
30 QMAKE_CXXFLAGS_THREAD =
32 QMAKE_CXXFLAGS_RTTI_ON =
31 QMAKE_CXXFLAGS_RTTI_ON =
33 QMAKE_CXXFLAGS_RTTI_OFF =
32 QMAKE_CXXFLAGS_RTTI_OFF =
34 QMAKE_CXXFLAGS_EXCEPTIONS_ON =
33 QMAKE_CXXFLAGS_EXCEPTIONS_ON =
35 QMAKE_CXXFLAGS_EXCEPTIONS_OFF =
34 QMAKE_CXXFLAGS_EXCEPTIONS_OFF =
36 QMAKE_CFLAGS_WARN_ON = -Wall
35 QMAKE_CFLAGS_WARN_ON = -Wall
37 QMAKE_CFLAGS_WARN_OFF = -w
36 QMAKE_CFLAGS_WARN_OFF = -w
38 QMAKE_CFLAGS_RELEASE =
37 QMAKE_CFLAGS_RELEASE =
39 QMAKE_CFLAGS_YACC =
38 QMAKE_CFLAGS_YACC =
40 QMAKE_LFLAGS_EXCEPTIONS_ON =
39 QMAKE_LFLAGS_EXCEPTIONS_ON =
41 QMAKE_LFLAGS_EXCEPTIONS_OFF =
40 QMAKE_LFLAGS_EXCEPTIONS_OFF =
42 QMAKE_LFLAGS_RELEASE = -Xlinker -Map=output.map
43 QMAKE_LFLAGS_CONSOLE =
41 QMAKE_LFLAGS_CONSOLE =
44 QMAKE_LFLAGS_WINDOWS =
42 QMAKE_LFLAGS_WINDOWS =
45 QMAKE_LFLAGS_DLL =
43 QMAKE_LFLAGS_DLL =
46 QMAKE_INCDIR_QT =
44 QMAKE_INCDIR_QT =
47 QMAKE_INCDIR =
45 QMAKE_INCDIR =
48 QMAKE_CFLAGS_SHLIB =
46 QMAKE_CFLAGS_SHLIB =
49 QMAKE_CFLAGS_STATIC_LIB =
47 QMAKE_CFLAGS_STATIC_LIB =
50 QMAKE_CXXFLAGS_SHLIB =
48 QMAKE_CXXFLAGS_SHLIB =
51 QMAKE_CXXFLAGS_STATIC_LIB =
49 QMAKE_CXXFLAGS_STATIC_LIB =
52 QMAKE_LIBS=""
50 QMAKE_LIBS=""
53 INCLUDEPATH=""
51 INCLUDEPATH=""
54 DEFINES=""
52 DEFINES=""
55
53
56 contains( TEMPLATE, app ) {
57 OBJECTS_DIR=obj
58 DESTDIR=bin
59 }
60
61 #QMAKE_CFLAGS_RELEASE += -O0
62 #QMAKE_CFLAGS_DEBUG += -O0
63 #QMAKE_CXXFLAGS_RELEASE += -O0
64 #QMAKE_CXXFLAGS_DEBUG += -O0
65
54
66 QMAKE_CFLAGS_RELEASE += -O3
55 QMAKE_CFLAGS_RELEASE += -O3
67 QMAKE_CFLAGS_DEBUG += -O3
56 QMAKE_CFLAGS_DEBUG += -O3
68 QMAKE_CXXFLAGS_RELEASE += -O3
57 QMAKE_CXXFLAGS_RELEASE += -O3
69 QMAKE_CXXFLAGS_DEBUG += -O3
58 QMAKE_CXXFLAGS_DEBUG += -O3
70
59
71 #QMAKE_CFLAGS_RELEASE += -O3 -std=c99
60 #QMAKE_CFLAGS_RELEASE += -O0
72 #QMAKE_CFLAGS_DEBUG += -O3 -std=c99
61 #QMAKE_CFLAGS_DEBUG += -O0
73 #QMAKE_CXXFLAGS_RELEASE += -O3 -std=c99
62 #QMAKE_CXXFLAGS_RELEASE += -O0
74 #QMAKE_CXXFLAGS_DEBUG += -O3 -std=c99
63 #QMAKE_CXXFLAGS_DEBUG += -O0
75
76 contains( TEMPLATE, app ) {
77 grmon.target = grmon
78 grmon.commands = cd $$DESTDIR && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
79 QMAKE_EXTRA_TARGETS += grmon
80 }
81
82
83
84
64
85
65
86
66 #QMAKE_CFLAGS_RELEASE+= -O3 -std=c99
87
67 #QMAKE_CFLAGS_DEBUG+= -O3 -std=c99
88
68 #QMAKE_CXXFLAGS_RELEASE+= -O3 -std=c99
89
69 #QMAKE_CXXFLAGS_DEBUG+= -O3 -std=c99
90
91
92
93
94
95
96
97
98
99
@@ -1,64 +1,59
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[]; /* array of task names */
19 extern rtems_name Task_name[]; /* array of task names */
20 extern rtems_id Task_id[]; /* array of task ids */
20 extern rtems_id Task_id[]; /* 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_rw1_rw2_f_flags;
25 extern float cp_rpw_sc_rw1_f1;
25 extern unsigned char cp_rpw_sc_rw3_rw4_f_flags;
26 extern float cp_rpw_sc_rw1_f2;
26
27 extern float cp_rpw_sc_rw2_f1;
28 extern float cp_rpw_sc_rw2_f2;
29 extern float cp_rpw_sc_rw3_f1;
30 extern float cp_rpw_sc_rw3_f2;
31 extern float cp_rpw_sc_rw4_f1;
32 extern float cp_rpw_sc_rw4_f2;
33 extern filterPar_t filterPar;
27 extern filterPar_t filterPar;
28 extern rw_f_t rw_f;
34
29
35 // RTEMS TASKS
30 // RTEMS TASKS
36 rtems_task Init( rtems_task_argument argument);
31 rtems_task Init( rtems_task_argument argument);
37
32
38 // OTHER functions
33 // OTHER functions
39 void create_names( void );
34 void create_names( void );
40 int create_all_tasks( void );
35 int create_all_tasks( void );
41 int start_all_tasks( void );
36 int start_all_tasks( void );
42 //
37 //
43 rtems_status_code create_message_queues( void );
38 rtems_status_code create_message_queues( void );
44 rtems_status_code create_timecode_timer( void );
39 rtems_status_code create_timecode_timer( void );
45 rtems_status_code get_message_queue_id_send( rtems_id *queue_id );
40 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 );
41 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 );
42 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 );
43 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 );
44 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 );
45 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 );
46 void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize );
52 //
47 //
53 int start_recv_send_tasks( void );
48 int start_recv_send_tasks( void );
54 //
49 //
55 void init_local_mode_parameters( void );
50 void init_local_mode_parameters( void );
56 void reset_local_time( void );
51 void reset_local_time( void );
57
52
58 extern void rtems_cpu_usage_report( void );
53 extern void rtems_cpu_usage_report( void );
59 extern void rtems_cpu_usage_reset( void );
54 extern void rtems_cpu_usage_reset( void );
60 extern void rtems_stack_checker_report_usage( void );
55 extern void rtems_stack_checker_report_usage( void );
61
56
62 extern int sched_yield( void );
57 extern int sched_yield( void );
63
58
64 #endif // FSW_INIT_H_INCLUDED
59 #endif // FSW_INIT_H_INCLUDED
@@ -1,83 +1,85
1 #ifndef TC_LOAD_DUMP_PARAMETERS_H
1 #ifndef TC_LOAD_DUMP_PARAMETERS_H
2 #define TC_LOAD_DUMP_PARAMETERS_H
2 #define TC_LOAD_DUMP_PARAMETERS_H
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <stdio.h>
5 #include <stdio.h>
6
6
7 #include "fsw_params.h"
7 #include "fsw_params.h"
8 #include "wf_handler.h"
8 #include "wf_handler.h"
9 #include "tm_lfr_tc_exe.h"
9 #include "tm_lfr_tc_exe.h"
10 #include "fsw_misc.h"
10 #include "fsw_misc.h"
11 #include "basic_parameters_params.h"
11 #include "basic_parameters_params.h"
12 #include "avf0_prc0.h"
12 #include "avf0_prc0.h"
13
13
14 #define FLOAT_EQUAL_ZERO 0.001
14 #define FLOAT_EQUAL_ZERO 0.001
15
15
16 extern unsigned short sequenceCounterParameterDump;
16 extern unsigned short sequenceCounterParameterDump;
17 extern unsigned short sequenceCounters_TM_DUMP[];
17 extern unsigned short sequenceCounters_TM_DUMP[];
18 extern float k_coeff_intercalib_f0_norm[ ];
18 extern float k_coeff_intercalib_f0_norm[ ];
19 extern float k_coeff_intercalib_f0_sbm[ ];
19 extern float k_coeff_intercalib_f0_sbm[ ];
20 extern float k_coeff_intercalib_f1_norm[ ];
20 extern float k_coeff_intercalib_f1_norm[ ];
21 extern float k_coeff_intercalib_f1_sbm[ ];
21 extern float k_coeff_intercalib_f1_sbm[ ];
22 extern float k_coeff_intercalib_f2[ ];
22 extern float k_coeff_intercalib_f2[ ];
23 extern fbins_masks_t fbins_masks;
23 extern fbins_masks_t fbins_masks;
24
24
25 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
25 int action_load_common_par( ccsdsTelecommandPacket_t *TC );
26 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
26 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
27 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
27 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
28 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
28 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
29 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
29 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time);
30 int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
30 int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
31 int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
31 int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
32 int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
32 int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
33 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
33 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time);
34 int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
34 int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
35
35
36 // NORMAL
36 // NORMAL
37 int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
37 int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
38 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC );
38 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC );
39 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC );
39 int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC );
40 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC );
40 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC );
41 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC );
41 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC );
42 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC );
42 int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC );
43 int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC );
43 int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC );
44
44
45 // BURST
45 // BURST
46 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC );
46 int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC );
47 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC );
47 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC );
48
48
49 // SBM1
49 // SBM1
50 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC );
50 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC );
51 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC );
51 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC );
52
52
53 // SBM2
53 // SBM2
54 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC );
54 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC );
55 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC );
55 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC );
56
56
57 // TC_LFR_UPDATE_INFO
57 // TC_LFR_UPDATE_INFO
58 unsigned int check_update_info_hk_lfr_mode( unsigned char mode );
58 unsigned int check_update_info_hk_lfr_mode( unsigned char mode );
59 unsigned int check_update_info_hk_tds_mode( unsigned char mode );
59 unsigned int check_update_info_hk_tds_mode( unsigned char mode );
60 unsigned int check_update_info_hk_thr_mode( unsigned char mode );
60 unsigned int check_update_info_hk_thr_mode( unsigned char mode );
61 void set_hk_lfr_sc_rw_f_flag( unsigned char wheel, unsigned char freq, float value );
62 void set_hk_lfr_sc_rw_f_flags( void );
61 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC );
63 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC );
62 void setFBinMask(unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, unsigned char flag );
64 void setFBinMask(unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, unsigned char flag );
63 void build_sy_lfr_rw_mask( unsigned int channel );
65 void build_sy_lfr_rw_mask( unsigned int channel );
64 void build_sy_lfr_rw_masks();
66 void build_sy_lfr_rw_masks();
65 void merge_fbins_masks( void );
67 void merge_fbins_masks( void );
66
68
67 // FBINS_MASK
69 // FBINS_MASK
68 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC );
70 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC );
69
71
70 // TC_LFR_LOAD_PARS_FILTER_PAR
72 // TC_LFR_LOAD_PARS_FILTER_PAR
71 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
73 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id );
72
74
73 // KCOEFFICIENTS
75 // KCOEFFICIENTS
74 int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id);
76 int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id);
75 void copyFloatByChar( unsigned char *destination, unsigned char *source );
77 void copyFloatByChar( unsigned char *destination, unsigned char *source );
76 void floatToChar( float value, unsigned char* ptr);
78 void floatToChar( float value, unsigned char* ptr);
77
79
78 void init_parameter_dump( void );
80 void init_parameter_dump( void );
79 void init_kcoefficients_dump( void );
81 void init_kcoefficients_dump( void );
80 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr );
82 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr );
81 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id );
83 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id );
82
84
83 #endif // TC_LOAD_DUMP_PARAMETERS_H
85 #endif // TC_LOAD_DUMP_PARAMETERS_H
@@ -1,14 +1,14
1 # LOAD FSW USING LINK 1
1 # LOAD FSW USING LINK 1
2 SpwPlugin0.StarDundeeSelectLinkNumber( 1 )
2 SpwPlugin0.StarDundeeSelectLinkNumber( 1 )
3
3
4 dsu3plugin0.openFile("/opt/DEV_PLE/FSW-qt/bin/fsw")
4 dsu3plugin0.openFile("/home/pleroy/DEV/DEV_PLE/FSW-qt/bin/fsw")
5 #dsu3plugin0.openFile("/opt/LFR/LFR-FSW/2.0.2.3/fsw")
5 #dsu3plugin0.openFile("/opt/LFR/LFR-FSW/2.0.2.3/fsw")
6 dsu3plugin0.loadFile()
6 dsu3plugin0.loadFile()
7
7
8 dsu3plugin0.run()
8 dsu3plugin0.run()
9
9
10 # START SENDING TIMECODES AT 1 Hz
10 # START SENDING TIMECODES AT 1 Hz
11 #SpwPlugin0.StarDundeeStartTimecodes( 1 )
11 #SpwPlugin0.StarDundeeStartTimecodes( 1 )
12
12
13 # it is possible to change the time code frequency
13 # it is possible to change the time code frequency
14 #RMAPPlugin0.changeTimecodeFrequency(2)
14 #RMAPPlugin0.changeTimecodeFrequency(2)
@@ -1,98 +1,92
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_rw1_rw2_f_flags;
70 unsigned char cp_rpw_sc_rw3_rw4_f_flags;
70 // message queues occupancy
71 // message queues occupancy
71 unsigned char hk_lfr_q_sd_fifo_size_max;
72 unsigned char hk_lfr_q_sd_fifo_size_max;
72 unsigned char hk_lfr_q_rv_fifo_size_max;
73 unsigned char hk_lfr_q_rv_fifo_size_max;
73 unsigned char hk_lfr_q_p0_fifo_size_max;
74 unsigned char hk_lfr_q_p0_fifo_size_max;
74 unsigned char hk_lfr_q_p1_fifo_size_max;
75 unsigned char hk_lfr_q_p1_fifo_size_max;
75 unsigned char hk_lfr_q_p2_fifo_size_max;
76 unsigned char hk_lfr_q_p2_fifo_size_max;
76 // sequence counters are incremented by APID (PID + CAT) and destination ID
77 // sequence counters are incremented by APID (PID + CAT) and destination ID
77 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
78 unsigned short sequenceCounters_SCIENCE_NORMAL_BURST;
78 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
79 unsigned short sequenceCounters_SCIENCE_SBM1_SBM2;
79 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
80 unsigned short sequenceCounters_TC_EXE[SEQ_CNT_NB_DEST_ID];
80 unsigned short sequenceCounters_TM_DUMP[SEQ_CNT_NB_DEST_ID];
81 unsigned short sequenceCounters_TM_DUMP[SEQ_CNT_NB_DEST_ID];
81 unsigned short sequenceCounterHK;
82 unsigned short sequenceCounterHK;
82 spw_stats grspw_stats;
83 spw_stats grspw_stats;
83
84
84 // TC_LFR_UPDATE_INFO
85 // TC_LFR_UPDATE_INFO
85 float cp_rpw_sc_rw1_f1;
86 rw_f_t rw_f;
86 float cp_rpw_sc_rw1_f2;
87 float cp_rpw_sc_rw2_f1;
88 float cp_rpw_sc_rw2_f2;
89 float cp_rpw_sc_rw3_f1;
90 float cp_rpw_sc_rw3_f2;
91 float cp_rpw_sc_rw4_f1;
92 float cp_rpw_sc_rw4_f2;
93
87
94 // TC_LFR_LOAD_FILTER_PAR
88 // TC_LFR_LOAD_FILTER_PAR
95 filterPar_t filterPar;
89 filterPar_t filterPar;
96
90
97 fbins_masks_t fbins_masks;
91 fbins_masks_t fbins_masks;
98 unsigned int acquisitionDurations[3] = {ACQUISITION_DURATION_F0, ACQUISITION_DURATION_F1, ACQUISITION_DURATION_F2};
92 unsigned int acquisitionDurations[3] = {ACQUISITION_DURATION_F0, ACQUISITION_DURATION_F1, ACQUISITION_DURATION_F2};
@@ -1,955 +1,968
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 21 // number of tasks concurrently active including INIT
29 #define CONFIGURE_MAXIMUM_TASKS 21 // number of tasks concurrently active including INIT
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 // [hous] [load] [avgv]
37 #define CONFIGURE_MAXIMUM_PERIODS 5 // [hous] [load] [avgv]
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
50
51 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
51 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
52 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
52 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
53 #endif
53 #endif
54
54
55 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
55 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
57 #endif
57 #endif
58
58
59 #endif
59 #endif
60 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
60 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
61
61
62 #include <drvmgr/drvmgr_confdefs.h>
62 #include <drvmgr/drvmgr_confdefs.h>
63 #endif
63 #endif
64
64
65 #include "fsw_init.h"
65 #include "fsw_init.h"
66 #include "fsw_config.c"
66 #include "fsw_config.c"
67 #include "GscMemoryLPP.hpp"
67 #include "GscMemoryLPP.hpp"
68
68
69 void initCache()
69 void initCache()
70 {
70 {
71 // ASI 2 contains a few control registers that have not been assigned as ancillary state registers.
71 // ASI 2 contains a few control registers that have not been assigned as ancillary state registers.
72 // These should only be read and written using 32-bit LDA/STA instructions.
72 // These should only be read and written using 32-bit LDA/STA instructions.
73 // All cache registers are accessed through load/store operations to the alternate address space (LDA/STA), using ASI = 2.
73 // All cache registers are accessed through load/store operations to the alternate address space (LDA/STA), using ASI = 2.
74 // The table below shows the register addresses:
74 // The table below shows the register addresses:
75 // 0x00 Cache control register
75 // 0x00 Cache control register
76 // 0x04 Reserved
76 // 0x04 Reserved
77 // 0x08 Instruction cache configuration register
77 // 0x08 Instruction cache configuration register
78 // 0x0C Data cache configuration register
78 // 0x0C Data cache configuration register
79
79
80 // Cache Control Register Leon3 / Leon3FT
80 // Cache Control Register Leon3 / Leon3FT
81 // 31..30 29 28 27..24 23 22 21 20..19 18 17 16
81 // 31..30 29 28 27..24 23 22 21 20..19 18 17 16
82 // RFT PS TB DS FD FI FT ST IB
82 // RFT PS TB DS FD FI FT ST IB
83 // 15 14 13..12 11..10 9..8 7..6 5 4 3..2 1..0
83 // 15 14 13..12 11..10 9..8 7..6 5 4 3..2 1..0
84 // IP DP ITE IDE DTE DDE DF IF DCS ICS
84 // IP DP ITE IDE DTE DDE DF IF DCS ICS
85
85
86 unsigned int cacheControlRegister;
86 unsigned int cacheControlRegister;
87
87
88 CCR_resetCacheControlRegister();
88 CCR_resetCacheControlRegister();
89 ASR16_resetRegisterProtectionControlRegister();
89 ASR16_resetRegisterProtectionControlRegister();
90
90
91 cacheControlRegister = CCR_getValue();
91 cacheControlRegister = CCR_getValue();
92 PRINTF1("(0) CCR - Cache Control Register = %x\n", cacheControlRegister);
92 PRINTF1("(0) CCR - Cache Control Register = %x\n", cacheControlRegister);
93 PRINTF1("(0) ASR16 = %x\n", *asr16Ptr);
93 PRINTF1("(0) ASR16 = %x\n", *asr16Ptr);
94
94
95 CCR_enableInstructionCache(); // ICS bits
95 CCR_enableInstructionCache(); // ICS bits
96 CCR_enableDataCache(); // DCS bits
96 CCR_enableDataCache(); // DCS bits
97 CCR_enableInstructionBurstFetch(); // IB bit
97 CCR_enableInstructionBurstFetch(); // IB bit
98
98
99 faultTolerantScheme();
99 faultTolerantScheme();
100
100
101 cacheControlRegister = CCR_getValue();
101 cacheControlRegister = CCR_getValue();
102 PRINTF1("(1) CCR - Cache Control Register = %x\n", cacheControlRegister);
102 PRINTF1("(1) CCR - Cache Control Register = %x\n", cacheControlRegister);
103 PRINTF1("(1) ASR16 Register protection control register = %x\n", *asr16Ptr);
103 PRINTF1("(1) ASR16 Register protection control register = %x\n", *asr16Ptr);
104
104
105 PRINTF("\n");
105 PRINTF("\n");
106 }
106 }
107
107
108 rtems_task Init( rtems_task_argument ignored )
108 rtems_task Init( rtems_task_argument ignored )
109 {
109 {
110 /** This is the RTEMS INIT taks, it is the first task launched by the system.
110 /** This is the RTEMS INIT taks, it is the first task launched by the system.
111 *
111 *
112 * @param unused is the starting argument of the RTEMS task
112 * @param unused is the starting argument of the RTEMS task
113 *
113 *
114 * The INIT task create and run all other RTEMS tasks.
114 * The INIT task create and run all other RTEMS tasks.
115 *
115 *
116 */
116 */
117
117
118 //***********
118 //***********
119 // INIT CACHE
119 // INIT CACHE
120
120
121 unsigned char *vhdlVersion;
121 unsigned char *vhdlVersion;
122
122
123 reset_lfr();
123 reset_lfr();
124
124
125 reset_local_time();
125 reset_local_time();
126
126
127 rtems_cpu_usage_reset();
127 rtems_cpu_usage_reset();
128
128
129 rtems_status_code status;
129 rtems_status_code status;
130 rtems_status_code status_spw;
130 rtems_status_code status_spw;
131 rtems_isr_entry old_isr_handler;
131 rtems_isr_entry old_isr_handler;
132
132
133 // UART settings
133 // UART settings
134 enable_apbuart_transmitter();
134 enable_apbuart_transmitter();
135 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
135 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
136
136
137 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
137 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
138
138
139
139
140 PRINTF("\n\n\n\n\n")
140 PRINTF("\n\n\n\n\n")
141
141
142 initCache();
142 initCache();
143
143
144 PRINTF("*************************\n")
144 PRINTF("*************************\n")
145 PRINTF("** LFR Flight Software **\n")
145 PRINTF("** LFR Flight Software **\n")
146 PRINTF1("** %d-", SW_VERSION_N1)
146 PRINTF1("** %d-", SW_VERSION_N1)
147 PRINTF1("%d-" , SW_VERSION_N2)
147 PRINTF1("%d-" , SW_VERSION_N2)
148 PRINTF1("%d-" , SW_VERSION_N3)
148 PRINTF1("%d-" , SW_VERSION_N3)
149 PRINTF1("%d **\n", SW_VERSION_N4)
149 PRINTF1("%d **\n", SW_VERSION_N4)
150
150
151 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
151 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
152 PRINTF("** VHDL **\n")
152 PRINTF("** VHDL **\n")
153 PRINTF1("** %d.", vhdlVersion[1])
153 PRINTF1("** %d.", vhdlVersion[1])
154 PRINTF1("%d." , vhdlVersion[2])
154 PRINTF1("%d." , vhdlVersion[2])
155 PRINTF1("%d **\n", vhdlVersion[3])
155 PRINTF1("%d **\n", vhdlVersion[3])
156 PRINTF("*************************\n")
156 PRINTF("*************************\n")
157 PRINTF("\n\n")
157 PRINTF("\n\n")
158
158
159 init_parameter_dump();
159 init_parameter_dump();
160 init_kcoefficients_dump();
160 init_kcoefficients_dump();
161 init_local_mode_parameters();
161 init_local_mode_parameters();
162 init_housekeeping_parameters();
162 init_housekeeping_parameters();
163 init_k_coefficients_prc0();
163 init_k_coefficients_prc0();
164 init_k_coefficients_prc1();
164 init_k_coefficients_prc1();
165 init_k_coefficients_prc2();
165 init_k_coefficients_prc2();
166 pa_bia_status_info = 0x00;
166 pa_bia_status_info = 0x00;
167 cp_rpw_sc_rw_f_flags = 0x00;
167
168 cp_rpw_sc_rw1_f1 = 0.0;
168 // initialize all reaction wheels frequencies to NaN
169 cp_rpw_sc_rw1_f2 = 0.0;
169 rw_f.cp_rpw_sc_rw1_f1 = NAN;
170 cp_rpw_sc_rw2_f1 = 0.0;
170 rw_f.cp_rpw_sc_rw1_f2 = NAN;
171 cp_rpw_sc_rw2_f2 = 0.0;
171 rw_f.cp_rpw_sc_rw1_f3 = NAN;
172 cp_rpw_sc_rw3_f1 = 0.0;
172 rw_f.cp_rpw_sc_rw1_f4 = NAN;
173 cp_rpw_sc_rw3_f2 = 0.0;
173 rw_f.cp_rpw_sc_rw2_f1 = NAN;
174 cp_rpw_sc_rw4_f1 = 0.0;
174 rw_f.cp_rpw_sc_rw2_f2 = NAN;
175 cp_rpw_sc_rw4_f2 = 0.0;
175 rw_f.cp_rpw_sc_rw2_f3 = NAN;
176 rw_f.cp_rpw_sc_rw2_f4 = NAN;
177 rw_f.cp_rpw_sc_rw3_f1 = NAN;
178 rw_f.cp_rpw_sc_rw3_f2 = NAN;
179 rw_f.cp_rpw_sc_rw3_f3 = NAN;
180 rw_f.cp_rpw_sc_rw3_f4 = NAN;
181 rw_f.cp_rpw_sc_rw4_f1 = NAN;
182 rw_f.cp_rpw_sc_rw4_f2 = NAN;
183 rw_f.cp_rpw_sc_rw4_f3 = NAN;
184 rw_f.cp_rpw_sc_rw4_f4 = NAN;
185
186 cp_rpw_sc_rw1_rw2_f_flags = 0x00;
187 cp_rpw_sc_rw3_rw4_f_flags = 0x00;
188
176 // initialize filtering parameters
189 // initialize filtering parameters
177 filterPar.spare_sy_lfr_pas_filter_enabled = DEFAULT_SY_LFR_PAS_FILTER_ENABLED;
190 filterPar.spare_sy_lfr_pas_filter_enabled = DEFAULT_SY_LFR_PAS_FILTER_ENABLED;
178 filterPar.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
191 filterPar.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
179 filterPar.sy_lfr_pas_filter_tbad = DEFAULT_SY_LFR_PAS_FILTER_TBAD;
192 filterPar.sy_lfr_pas_filter_tbad = DEFAULT_SY_LFR_PAS_FILTER_TBAD;
180 filterPar.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
193 filterPar.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
181 filterPar.sy_lfr_pas_filter_shift = DEFAULT_SY_LFR_PAS_FILTER_SHIFT;
194 filterPar.sy_lfr_pas_filter_shift = DEFAULT_SY_LFR_PAS_FILTER_SHIFT;
182 filterPar.sy_lfr_sc_rw_delta_f = DEFAULT_SY_LFR_SC_RW_DELTA_F;
195 filterPar.sy_lfr_sc_rw_delta_f = DEFAULT_SY_LFR_SC_RW_DELTA_F;
183 update_last_valid_transition_date( DEFAULT_LAST_VALID_TRANSITION_DATE );
196 update_last_valid_transition_date( DEFAULT_LAST_VALID_TRANSITION_DATE );
184
197
185 // waveform picker initialization
198 // waveform picker initialization
186 WFP_init_rings();
199 WFP_init_rings();
187 LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings
200 LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings
188 WFP_reset_current_ring_nodes();
201 WFP_reset_current_ring_nodes();
189 reset_waveform_picker_regs();
202 reset_waveform_picker_regs();
190
203
191 // spectral matrices initialization
204 // spectral matrices initialization
192 SM_init_rings(); // initialize spectral matrices rings
205 SM_init_rings(); // initialize spectral matrices rings
193 SM_reset_current_ring_nodes();
206 SM_reset_current_ring_nodes();
194 reset_spectral_matrix_regs();
207 reset_spectral_matrix_regs();
195
208
196 // configure calibration
209 // configure calibration
197 configureCalibration( false ); // true means interleaved mode, false is for normal mode
210 configureCalibration( false ); // true means interleaved mode, false is for normal mode
198
211
199 updateLFRCurrentMode( LFR_MODE_STANDBY );
212 updateLFRCurrentMode( LFR_MODE_STANDBY );
200
213
201 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
214 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
202
215
203 create_names(); // create all names
216 create_names(); // create all names
204
217
205 status = create_timecode_timer(); // create the timer used by timecode_irq_handler
218 status = create_timecode_timer(); // create the timer used by timecode_irq_handler
206 if (status != RTEMS_SUCCESSFUL)
219 if (status != RTEMS_SUCCESSFUL)
207 {
220 {
208 PRINTF1("in INIT *** ERR in create_timer_timecode, code %d", status)
221 PRINTF1("in INIT *** ERR in create_timer_timecode, code %d", status)
209 }
222 }
210
223
211 status = create_message_queues(); // create message queues
224 status = create_message_queues(); // create message queues
212 if (status != RTEMS_SUCCESSFUL)
225 if (status != RTEMS_SUCCESSFUL)
213 {
226 {
214 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
227 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
215 }
228 }
216
229
217 status = create_all_tasks(); // create all tasks
230 status = create_all_tasks(); // create all tasks
218 if (status != RTEMS_SUCCESSFUL)
231 if (status != RTEMS_SUCCESSFUL)
219 {
232 {
220 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
233 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
221 }
234 }
222
235
223 // **************************
236 // **************************
224 // <SPACEWIRE INITIALIZATION>
237 // <SPACEWIRE INITIALIZATION>
225 status_spw = spacewire_open_link(); // (1) open the link
238 status_spw = spacewire_open_link(); // (1) open the link
226 if ( status_spw != RTEMS_SUCCESSFUL )
239 if ( status_spw != RTEMS_SUCCESSFUL )
227 {
240 {
228 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
241 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
229 }
242 }
230
243
231 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
244 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
232 {
245 {
233 status_spw = spacewire_configure_link( fdSPW );
246 status_spw = spacewire_configure_link( fdSPW );
234 if ( status_spw != RTEMS_SUCCESSFUL )
247 if ( status_spw != RTEMS_SUCCESSFUL )
235 {
248 {
236 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
249 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
237 }
250 }
238 }
251 }
239
252
240 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
253 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
241 {
254 {
242 status_spw = spacewire_start_link( fdSPW );
255 status_spw = spacewire_start_link( fdSPW );
243 if ( status_spw != RTEMS_SUCCESSFUL )
256 if ( status_spw != RTEMS_SUCCESSFUL )
244 {
257 {
245 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
258 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
246 }
259 }
247 }
260 }
248 // </SPACEWIRE INITIALIZATION>
261 // </SPACEWIRE INITIALIZATION>
249 // ***************************
262 // ***************************
250
263
251 status = start_all_tasks(); // start all tasks
264 status = start_all_tasks(); // start all tasks
252 if (status != RTEMS_SUCCESSFUL)
265 if (status != RTEMS_SUCCESSFUL)
253 {
266 {
254 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
267 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
255 }
268 }
256
269
257 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
270 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
258 status = start_recv_send_tasks();
271 status = start_recv_send_tasks();
259 if ( status != RTEMS_SUCCESSFUL )
272 if ( status != RTEMS_SUCCESSFUL )
260 {
273 {
261 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
274 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
262 }
275 }
263
276
264 // suspend science tasks, they will be restarted later depending on the mode
277 // suspend science tasks, they will be restarted later depending on the mode
265 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
278 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
266 if (status != RTEMS_SUCCESSFUL)
279 if (status != RTEMS_SUCCESSFUL)
267 {
280 {
268 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
281 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
269 }
282 }
270
283
271 // configure IRQ handling for the waveform picker unit
284 // configure IRQ handling for the waveform picker unit
272 status = rtems_interrupt_catch( waveforms_isr,
285 status = rtems_interrupt_catch( waveforms_isr,
273 IRQ_SPARC_WAVEFORM_PICKER,
286 IRQ_SPARC_WAVEFORM_PICKER,
274 &old_isr_handler) ;
287 &old_isr_handler) ;
275 // configure IRQ handling for the spectral matrices unit
288 // configure IRQ handling for the spectral matrices unit
276 status = rtems_interrupt_catch( spectral_matrices_isr,
289 status = rtems_interrupt_catch( spectral_matrices_isr,
277 IRQ_SPARC_SPECTRAL_MATRIX,
290 IRQ_SPARC_SPECTRAL_MATRIX,
278 &old_isr_handler) ;
291 &old_isr_handler) ;
279
292
280 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
293 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
281 if ( status_spw != RTEMS_SUCCESSFUL )
294 if ( status_spw != RTEMS_SUCCESSFUL )
282 {
295 {
283 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
296 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
284 if ( status != RTEMS_SUCCESSFUL ) {
297 if ( status != RTEMS_SUCCESSFUL ) {
285 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
298 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
286 }
299 }
287 }
300 }
288
301
289 BOOT_PRINTF("delete INIT\n")
302 BOOT_PRINTF("delete INIT\n")
290
303
291 set_hk_lfr_sc_potential_flag( true );
304 set_hk_lfr_sc_potential_flag( true );
292
305
293 // start the timer to detect a missing spacewire timecode
306 // start the timer to detect a missing spacewire timecode
294 // the timeout is larger because the spw IP needs to receive several valid timecodes before generating a tickout
307 // the timeout is larger because the spw IP needs to receive several valid timecodes before generating a tickout
295 // if a tickout is generated, the timer is restarted
308 // if a tickout is generated, the timer is restarted
296 status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT_INIT, timecode_timer_routine, NULL );
309 status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT_INIT, timecode_timer_routine, NULL );
297
310
298 grspw_timecode_callback = &timecode_irq_handler;
311 grspw_timecode_callback = &timecode_irq_handler;
299
312
300 status = rtems_task_delete(RTEMS_SELF);
313 status = rtems_task_delete(RTEMS_SELF);
301
314
302 }
315 }
303
316
304 void init_local_mode_parameters( void )
317 void init_local_mode_parameters( void )
305 {
318 {
306 /** This function initialize the param_local global variable with default values.
319 /** This function initialize the param_local global variable with default values.
307 *
320 *
308 */
321 */
309
322
310 unsigned int i;
323 unsigned int i;
311
324
312 // LOCAL PARAMETERS
325 // LOCAL PARAMETERS
313
326
314 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
327 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
315 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
328 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
316 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
329 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
317
330
318 // init sequence counters
331 // init sequence counters
319
332
320 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
333 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
321 {
334 {
322 sequenceCounters_TC_EXE[i] = 0x00;
335 sequenceCounters_TC_EXE[i] = 0x00;
323 sequenceCounters_TM_DUMP[i] = 0x00;
336 sequenceCounters_TM_DUMP[i] = 0x00;
324 }
337 }
325 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
338 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
326 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
339 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
327 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
340 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
328 }
341 }
329
342
330 void reset_local_time( void )
343 void reset_local_time( void )
331 {
344 {
332 time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000
345 time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000
333 }
346 }
334
347
335 void create_names( void ) // create all names for tasks and queues
348 void create_names( void ) // create all names for tasks and queues
336 {
349 {
337 /** This function creates all RTEMS names used in the software for tasks and queues.
350 /** This function creates all RTEMS names used in the software for tasks and queues.
338 *
351 *
339 * @return RTEMS directive status codes:
352 * @return RTEMS directive status codes:
340 * - RTEMS_SUCCESSFUL - successful completion
353 * - RTEMS_SUCCESSFUL - successful completion
341 *
354 *
342 */
355 */
343
356
344 // task names
357 // task names
345 Task_name[TASKID_AVGV] = rtems_build_name( 'A', 'V', 'G', 'V' );
358 Task_name[TASKID_AVGV] = rtems_build_name( 'A', 'V', 'G', 'V' );
346 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
359 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
347 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
360 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
348 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
361 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
349 Task_name[TASKID_LOAD] = rtems_build_name( 'L', 'O', 'A', 'D' );
362 Task_name[TASKID_LOAD] = rtems_build_name( 'L', 'O', 'A', 'D' );
350 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
363 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
351 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
364 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
352 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
365 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
353 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
366 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
354 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
367 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
355 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
368 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
356 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
369 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
357 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
370 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
358 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
371 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
359 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
372 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
360 Task_name[TASKID_LINK] = rtems_build_name( 'L', 'I', 'N', 'K' );
373 Task_name[TASKID_LINK] = rtems_build_name( 'L', 'I', 'N', 'K' );
361 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
374 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
362 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
375 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
363 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
376 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
364 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
377 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
365
378
366 // rate monotonic period names
379 // rate monotonic period names
367 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
380 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
368 name_avgv_rate_monotonic = rtems_build_name( 'A', 'V', 'G', 'V' );
381 name_avgv_rate_monotonic = rtems_build_name( 'A', 'V', 'G', 'V' );
369
382
370 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
383 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
371 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
384 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
372 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
385 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
373 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
386 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
374 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
387 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
375
388
376 timecode_timer_name = rtems_build_name( 'S', 'P', 'T', 'C' );
389 timecode_timer_name = rtems_build_name( 'S', 'P', 'T', 'C' );
377 }
390 }
378
391
379 int create_all_tasks( void ) // create all tasks which run in the software
392 int create_all_tasks( void ) // create all tasks which run in the software
380 {
393 {
381 /** This function creates all RTEMS tasks used in the software.
394 /** This function creates all RTEMS tasks used in the software.
382 *
395 *
383 * @return RTEMS directive status codes:
396 * @return RTEMS directive status codes:
384 * - RTEMS_SUCCESSFUL - task created successfully
397 * - RTEMS_SUCCESSFUL - task created successfully
385 * - RTEMS_INVALID_ADDRESS - id is NULL
398 * - RTEMS_INVALID_ADDRESS - id is NULL
386 * - RTEMS_INVALID_NAME - invalid task name
399 * - RTEMS_INVALID_NAME - invalid task name
387 * - RTEMS_INVALID_PRIORITY - invalid task priority
400 * - RTEMS_INVALID_PRIORITY - invalid task priority
388 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
401 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
389 * - RTEMS_TOO_MANY - too many tasks created
402 * - RTEMS_TOO_MANY - too many tasks created
390 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
403 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
391 * - RTEMS_TOO_MANY - too many global objects
404 * - RTEMS_TOO_MANY - too many global objects
392 *
405 *
393 */
406 */
394
407
395 rtems_status_code status;
408 rtems_status_code status;
396
409
397 //**********
410 //**********
398 // SPACEWIRE
411 // SPACEWIRE
399 // RECV
412 // RECV
400 status = rtems_task_create(
413 status = rtems_task_create(
401 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
414 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
402 RTEMS_DEFAULT_MODES,
415 RTEMS_DEFAULT_MODES,
403 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
416 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
404 );
417 );
405 if (status == RTEMS_SUCCESSFUL) // SEND
418 if (status == RTEMS_SUCCESSFUL) // SEND
406 {
419 {
407 status = rtems_task_create(
420 status = rtems_task_create(
408 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2,
421 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2,
409 RTEMS_DEFAULT_MODES,
422 RTEMS_DEFAULT_MODES,
410 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND]
423 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND]
411 );
424 );
412 }
425 }
413 if (status == RTEMS_SUCCESSFUL) // LINK
426 if (status == RTEMS_SUCCESSFUL) // LINK
414 {
427 {
415 status = rtems_task_create(
428 status = rtems_task_create(
416 Task_name[TASKID_LINK], TASK_PRIORITY_LINK, RTEMS_MINIMUM_STACK_SIZE,
429 Task_name[TASKID_LINK], TASK_PRIORITY_LINK, RTEMS_MINIMUM_STACK_SIZE,
417 RTEMS_DEFAULT_MODES,
430 RTEMS_DEFAULT_MODES,
418 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LINK]
431 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LINK]
419 );
432 );
420 }
433 }
421 if (status == RTEMS_SUCCESSFUL) // ACTN
434 if (status == RTEMS_SUCCESSFUL) // ACTN
422 {
435 {
423 status = rtems_task_create(
436 status = rtems_task_create(
424 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
437 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
425 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
438 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
426 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
439 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
427 );
440 );
428 }
441 }
429 if (status == RTEMS_SUCCESSFUL) // SPIQ
442 if (status == RTEMS_SUCCESSFUL) // SPIQ
430 {
443 {
431 status = rtems_task_create(
444 status = rtems_task_create(
432 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
445 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
433 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
446 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
434 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
447 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
435 );
448 );
436 }
449 }
437
450
438 //******************
451 //******************
439 // SPECTRAL MATRICES
452 // SPECTRAL MATRICES
440 if (status == RTEMS_SUCCESSFUL) // AVF0
453 if (status == RTEMS_SUCCESSFUL) // AVF0
441 {
454 {
442 status = rtems_task_create(
455 status = rtems_task_create(
443 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
456 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
444 RTEMS_DEFAULT_MODES,
457 RTEMS_DEFAULT_MODES,
445 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
458 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
446 );
459 );
447 }
460 }
448 if (status == RTEMS_SUCCESSFUL) // PRC0
461 if (status == RTEMS_SUCCESSFUL) // PRC0
449 {
462 {
450 status = rtems_task_create(
463 status = rtems_task_create(
451 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
464 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
452 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
465 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
453 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
466 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
454 );
467 );
455 }
468 }
456 if (status == RTEMS_SUCCESSFUL) // AVF1
469 if (status == RTEMS_SUCCESSFUL) // AVF1
457 {
470 {
458 status = rtems_task_create(
471 status = rtems_task_create(
459 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
472 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
460 RTEMS_DEFAULT_MODES,
473 RTEMS_DEFAULT_MODES,
461 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
474 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
462 );
475 );
463 }
476 }
464 if (status == RTEMS_SUCCESSFUL) // PRC1
477 if (status == RTEMS_SUCCESSFUL) // PRC1
465 {
478 {
466 status = rtems_task_create(
479 status = rtems_task_create(
467 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
480 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
468 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
481 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
469 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
482 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
470 );
483 );
471 }
484 }
472 if (status == RTEMS_SUCCESSFUL) // AVF2
485 if (status == RTEMS_SUCCESSFUL) // AVF2
473 {
486 {
474 status = rtems_task_create(
487 status = rtems_task_create(
475 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
488 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
476 RTEMS_DEFAULT_MODES,
489 RTEMS_DEFAULT_MODES,
477 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
490 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
478 );
491 );
479 }
492 }
480 if (status == RTEMS_SUCCESSFUL) // PRC2
493 if (status == RTEMS_SUCCESSFUL) // PRC2
481 {
494 {
482 status = rtems_task_create(
495 status = rtems_task_create(
483 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
496 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
484 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
497 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
485 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
498 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
486 );
499 );
487 }
500 }
488
501
489 //****************
502 //****************
490 // WAVEFORM PICKER
503 // WAVEFORM PICKER
491 if (status == RTEMS_SUCCESSFUL) // WFRM
504 if (status == RTEMS_SUCCESSFUL) // WFRM
492 {
505 {
493 status = rtems_task_create(
506 status = rtems_task_create(
494 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
507 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
495 RTEMS_DEFAULT_MODES,
508 RTEMS_DEFAULT_MODES,
496 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
509 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
497 );
510 );
498 }
511 }
499 if (status == RTEMS_SUCCESSFUL) // CWF3
512 if (status == RTEMS_SUCCESSFUL) // CWF3
500 {
513 {
501 status = rtems_task_create(
514 status = rtems_task_create(
502 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
515 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
503 RTEMS_DEFAULT_MODES,
516 RTEMS_DEFAULT_MODES,
504 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
517 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
505 );
518 );
506 }
519 }
507 if (status == RTEMS_SUCCESSFUL) // CWF2
520 if (status == RTEMS_SUCCESSFUL) // CWF2
508 {
521 {
509 status = rtems_task_create(
522 status = rtems_task_create(
510 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
523 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
511 RTEMS_DEFAULT_MODES,
524 RTEMS_DEFAULT_MODES,
512 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
525 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
513 );
526 );
514 }
527 }
515 if (status == RTEMS_SUCCESSFUL) // CWF1
528 if (status == RTEMS_SUCCESSFUL) // CWF1
516 {
529 {
517 status = rtems_task_create(
530 status = rtems_task_create(
518 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
531 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
519 RTEMS_DEFAULT_MODES,
532 RTEMS_DEFAULT_MODES,
520 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
533 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
521 );
534 );
522 }
535 }
523 if (status == RTEMS_SUCCESSFUL) // SWBD
536 if (status == RTEMS_SUCCESSFUL) // SWBD
524 {
537 {
525 status = rtems_task_create(
538 status = rtems_task_create(
526 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
539 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
527 RTEMS_DEFAULT_MODES,
540 RTEMS_DEFAULT_MODES,
528 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
541 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
529 );
542 );
530 }
543 }
531
544
532 //*****
545 //*****
533 // MISC
546 // MISC
534 if (status == RTEMS_SUCCESSFUL) // LOAD
547 if (status == RTEMS_SUCCESSFUL) // LOAD
535 {
548 {
536 status = rtems_task_create(
549 status = rtems_task_create(
537 Task_name[TASKID_LOAD], TASK_PRIORITY_LOAD, RTEMS_MINIMUM_STACK_SIZE,
550 Task_name[TASKID_LOAD], TASK_PRIORITY_LOAD, RTEMS_MINIMUM_STACK_SIZE,
538 RTEMS_DEFAULT_MODES,
551 RTEMS_DEFAULT_MODES,
539 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LOAD]
552 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LOAD]
540 );
553 );
541 }
554 }
542 if (status == RTEMS_SUCCESSFUL) // DUMB
555 if (status == RTEMS_SUCCESSFUL) // DUMB
543 {
556 {
544 status = rtems_task_create(
557 status = rtems_task_create(
545 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
558 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
546 RTEMS_DEFAULT_MODES,
559 RTEMS_DEFAULT_MODES,
547 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
560 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
548 );
561 );
549 }
562 }
550 if (status == RTEMS_SUCCESSFUL) // HOUS
563 if (status == RTEMS_SUCCESSFUL) // HOUS
551 {
564 {
552 status = rtems_task_create(
565 status = rtems_task_create(
553 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
566 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
554 RTEMS_DEFAULT_MODES,
567 RTEMS_DEFAULT_MODES,
555 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS]
568 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS]
556 );
569 );
557 }
570 }
558 if (status == RTEMS_SUCCESSFUL) // AVGV
571 if (status == RTEMS_SUCCESSFUL) // AVGV
559 {
572 {
560 status = rtems_task_create(
573 status = rtems_task_create(
561 Task_name[TASKID_AVGV], TASK_PRIORITY_AVGV, RTEMS_MINIMUM_STACK_SIZE,
574 Task_name[TASKID_AVGV], TASK_PRIORITY_AVGV, RTEMS_MINIMUM_STACK_SIZE,
562 RTEMS_DEFAULT_MODES,
575 RTEMS_DEFAULT_MODES,
563 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVGV]
576 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVGV]
564 );
577 );
565 }
578 }
566
579
567 return status;
580 return status;
568 }
581 }
569
582
570 int start_recv_send_tasks( void )
583 int start_recv_send_tasks( void )
571 {
584 {
572 rtems_status_code status;
585 rtems_status_code status;
573
586
574 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
587 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
575 if (status!=RTEMS_SUCCESSFUL) {
588 if (status!=RTEMS_SUCCESSFUL) {
576 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
589 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
577 }
590 }
578
591
579 if (status == RTEMS_SUCCESSFUL) // SEND
592 if (status == RTEMS_SUCCESSFUL) // SEND
580 {
593 {
581 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
594 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
582 if (status!=RTEMS_SUCCESSFUL) {
595 if (status!=RTEMS_SUCCESSFUL) {
583 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
596 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
584 }
597 }
585 }
598 }
586
599
587 return status;
600 return status;
588 }
601 }
589
602
590 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
603 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
591 {
604 {
592 /** This function starts all RTEMS tasks used in the software.
605 /** This function starts all RTEMS tasks used in the software.
593 *
606 *
594 * @return RTEMS directive status codes:
607 * @return RTEMS directive status codes:
595 * - RTEMS_SUCCESSFUL - ask started successfully
608 * - RTEMS_SUCCESSFUL - ask started successfully
596 * - RTEMS_INVALID_ADDRESS - invalid task entry point
609 * - RTEMS_INVALID_ADDRESS - invalid task entry point
597 * - RTEMS_INVALID_ID - invalid task id
610 * - RTEMS_INVALID_ID - invalid task id
598 * - RTEMS_INCORRECT_STATE - task not in the dormant state
611 * - RTEMS_INCORRECT_STATE - task not in the dormant state
599 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
612 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
600 *
613 *
601 */
614 */
602 // starts all the tasks fot eh flight software
615 // starts all the tasks fot eh flight software
603
616
604 rtems_status_code status;
617 rtems_status_code status;
605
618
606 //**********
619 //**********
607 // SPACEWIRE
620 // SPACEWIRE
608 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
621 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
609 if (status!=RTEMS_SUCCESSFUL) {
622 if (status!=RTEMS_SUCCESSFUL) {
610 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
623 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
611 }
624 }
612
625
613 if (status == RTEMS_SUCCESSFUL) // LINK
626 if (status == RTEMS_SUCCESSFUL) // LINK
614 {
627 {
615 status = rtems_task_start( Task_id[TASKID_LINK], link_task, 1 );
628 status = rtems_task_start( Task_id[TASKID_LINK], link_task, 1 );
616 if (status!=RTEMS_SUCCESSFUL) {
629 if (status!=RTEMS_SUCCESSFUL) {
617 BOOT_PRINTF("in INIT *** Error starting TASK_LINK\n")
630 BOOT_PRINTF("in INIT *** Error starting TASK_LINK\n")
618 }
631 }
619 }
632 }
620
633
621 if (status == RTEMS_SUCCESSFUL) // ACTN
634 if (status == RTEMS_SUCCESSFUL) // ACTN
622 {
635 {
623 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
636 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
624 if (status!=RTEMS_SUCCESSFUL) {
637 if (status!=RTEMS_SUCCESSFUL) {
625 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
638 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
626 }
639 }
627 }
640 }
628
641
629 //******************
642 //******************
630 // SPECTRAL MATRICES
643 // SPECTRAL MATRICES
631 if (status == RTEMS_SUCCESSFUL) // AVF0
644 if (status == RTEMS_SUCCESSFUL) // AVF0
632 {
645 {
633 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
646 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
634 if (status!=RTEMS_SUCCESSFUL) {
647 if (status!=RTEMS_SUCCESSFUL) {
635 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
648 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
636 }
649 }
637 }
650 }
638 if (status == RTEMS_SUCCESSFUL) // PRC0
651 if (status == RTEMS_SUCCESSFUL) // PRC0
639 {
652 {
640 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
653 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
641 if (status!=RTEMS_SUCCESSFUL) {
654 if (status!=RTEMS_SUCCESSFUL) {
642 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
655 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
643 }
656 }
644 }
657 }
645 if (status == RTEMS_SUCCESSFUL) // AVF1
658 if (status == RTEMS_SUCCESSFUL) // AVF1
646 {
659 {
647 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
660 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
648 if (status!=RTEMS_SUCCESSFUL) {
661 if (status!=RTEMS_SUCCESSFUL) {
649 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
662 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
650 }
663 }
651 }
664 }
652 if (status == RTEMS_SUCCESSFUL) // PRC1
665 if (status == RTEMS_SUCCESSFUL) // PRC1
653 {
666 {
654 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
667 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
655 if (status!=RTEMS_SUCCESSFUL) {
668 if (status!=RTEMS_SUCCESSFUL) {
656 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
669 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
657 }
670 }
658 }
671 }
659 if (status == RTEMS_SUCCESSFUL) // AVF2
672 if (status == RTEMS_SUCCESSFUL) // AVF2
660 {
673 {
661 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
674 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
662 if (status!=RTEMS_SUCCESSFUL) {
675 if (status!=RTEMS_SUCCESSFUL) {
663 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
676 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
664 }
677 }
665 }
678 }
666 if (status == RTEMS_SUCCESSFUL) // PRC2
679 if (status == RTEMS_SUCCESSFUL) // PRC2
667 {
680 {
668 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
681 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
669 if (status!=RTEMS_SUCCESSFUL) {
682 if (status!=RTEMS_SUCCESSFUL) {
670 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
683 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
671 }
684 }
672 }
685 }
673
686
674 //****************
687 //****************
675 // WAVEFORM PICKER
688 // WAVEFORM PICKER
676 if (status == RTEMS_SUCCESSFUL) // WFRM
689 if (status == RTEMS_SUCCESSFUL) // WFRM
677 {
690 {
678 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
691 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
679 if (status!=RTEMS_SUCCESSFUL) {
692 if (status!=RTEMS_SUCCESSFUL) {
680 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
693 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
681 }
694 }
682 }
695 }
683 if (status == RTEMS_SUCCESSFUL) // CWF3
696 if (status == RTEMS_SUCCESSFUL) // CWF3
684 {
697 {
685 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
698 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
686 if (status!=RTEMS_SUCCESSFUL) {
699 if (status!=RTEMS_SUCCESSFUL) {
687 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
700 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
688 }
701 }
689 }
702 }
690 if (status == RTEMS_SUCCESSFUL) // CWF2
703 if (status == RTEMS_SUCCESSFUL) // CWF2
691 {
704 {
692 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
705 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
693 if (status!=RTEMS_SUCCESSFUL) {
706 if (status!=RTEMS_SUCCESSFUL) {
694 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
707 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
695 }
708 }
696 }
709 }
697 if (status == RTEMS_SUCCESSFUL) // CWF1
710 if (status == RTEMS_SUCCESSFUL) // CWF1
698 {
711 {
699 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
712 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
700 if (status!=RTEMS_SUCCESSFUL) {
713 if (status!=RTEMS_SUCCESSFUL) {
701 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
714 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
702 }
715 }
703 }
716 }
704 if (status == RTEMS_SUCCESSFUL) // SWBD
717 if (status == RTEMS_SUCCESSFUL) // SWBD
705 {
718 {
706 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
719 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
707 if (status!=RTEMS_SUCCESSFUL) {
720 if (status!=RTEMS_SUCCESSFUL) {
708 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
721 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
709 }
722 }
710 }
723 }
711
724
712 //*****
725 //*****
713 // MISC
726 // MISC
714 if (status == RTEMS_SUCCESSFUL) // HOUS
727 if (status == RTEMS_SUCCESSFUL) // HOUS
715 {
728 {
716 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
729 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
717 if (status!=RTEMS_SUCCESSFUL) {
730 if (status!=RTEMS_SUCCESSFUL) {
718 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
731 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
719 }
732 }
720 }
733 }
721 if (status == RTEMS_SUCCESSFUL) // AVGV
734 if (status == RTEMS_SUCCESSFUL) // AVGV
722 {
735 {
723 status = rtems_task_start( Task_id[TASKID_AVGV], avgv_task, 1 );
736 status = rtems_task_start( Task_id[TASKID_AVGV], avgv_task, 1 );
724 if (status!=RTEMS_SUCCESSFUL) {
737 if (status!=RTEMS_SUCCESSFUL) {
725 BOOT_PRINTF("in INIT *** Error starting TASK_AVGV\n")
738 BOOT_PRINTF("in INIT *** Error starting TASK_AVGV\n")
726 }
739 }
727 }
740 }
728 if (status == RTEMS_SUCCESSFUL) // DUMB
741 if (status == RTEMS_SUCCESSFUL) // DUMB
729 {
742 {
730 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
743 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
731 if (status!=RTEMS_SUCCESSFUL) {
744 if (status!=RTEMS_SUCCESSFUL) {
732 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
745 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
733 }
746 }
734 }
747 }
735 if (status == RTEMS_SUCCESSFUL) // LOAD
748 if (status == RTEMS_SUCCESSFUL) // LOAD
736 {
749 {
737 status = rtems_task_start( Task_id[TASKID_LOAD], load_task, 1 );
750 status = rtems_task_start( Task_id[TASKID_LOAD], load_task, 1 );
738 if (status!=RTEMS_SUCCESSFUL) {
751 if (status!=RTEMS_SUCCESSFUL) {
739 BOOT_PRINTF("in INIT *** Error starting TASK_LOAD\n")
752 BOOT_PRINTF("in INIT *** Error starting TASK_LOAD\n")
740 }
753 }
741 }
754 }
742
755
743 return status;
756 return status;
744 }
757 }
745
758
746 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
759 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
747 {
760 {
748 rtems_status_code status_recv;
761 rtems_status_code status_recv;
749 rtems_status_code status_send;
762 rtems_status_code status_send;
750 rtems_status_code status_q_p0;
763 rtems_status_code status_q_p0;
751 rtems_status_code status_q_p1;
764 rtems_status_code status_q_p1;
752 rtems_status_code status_q_p2;
765 rtems_status_code status_q_p2;
753 rtems_status_code ret;
766 rtems_status_code ret;
754 rtems_id queue_id;
767 rtems_id queue_id;
755
768
756 //****************************************
769 //****************************************
757 // create the queue for handling valid TCs
770 // create the queue for handling valid TCs
758 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
771 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
759 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
772 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
760 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
773 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
761 if ( status_recv != RTEMS_SUCCESSFUL ) {
774 if ( status_recv != RTEMS_SUCCESSFUL ) {
762 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
775 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
763 }
776 }
764
777
765 //************************************************
778 //************************************************
766 // create the queue for handling TM packet sending
779 // create the queue for handling TM packet sending
767 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
780 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
768 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
781 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
769 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
782 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
770 if ( status_send != RTEMS_SUCCESSFUL ) {
783 if ( status_send != RTEMS_SUCCESSFUL ) {
771 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
784 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
772 }
785 }
773
786
774 //*****************************************************************************
787 //*****************************************************************************
775 // create the queue for handling averaged spectral matrices for processing @ f0
788 // create the queue for handling averaged spectral matrices for processing @ f0
776 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
789 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
777 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
790 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
778 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
791 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
779 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
792 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
780 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
793 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
781 }
794 }
782
795
783 //*****************************************************************************
796 //*****************************************************************************
784 // create the queue for handling averaged spectral matrices for processing @ f1
797 // create the queue for handling averaged spectral matrices for processing @ f1
785 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
798 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
786 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
799 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
787 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
800 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
788 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
801 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
789 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
802 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
790 }
803 }
791
804
792 //*****************************************************************************
805 //*****************************************************************************
793 // create the queue for handling averaged spectral matrices for processing @ f2
806 // create the queue for handling averaged spectral matrices for processing @ f2
794 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
807 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
795 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
808 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
796 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
809 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
797 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
810 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
798 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
811 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
799 }
812 }
800
813
801 if ( status_recv != RTEMS_SUCCESSFUL )
814 if ( status_recv != RTEMS_SUCCESSFUL )
802 {
815 {
803 ret = status_recv;
816 ret = status_recv;
804 }
817 }
805 else if( status_send != RTEMS_SUCCESSFUL )
818 else if( status_send != RTEMS_SUCCESSFUL )
806 {
819 {
807 ret = status_send;
820 ret = status_send;
808 }
821 }
809 else if( status_q_p0 != RTEMS_SUCCESSFUL )
822 else if( status_q_p0 != RTEMS_SUCCESSFUL )
810 {
823 {
811 ret = status_q_p0;
824 ret = status_q_p0;
812 }
825 }
813 else if( status_q_p1 != RTEMS_SUCCESSFUL )
826 else if( status_q_p1 != RTEMS_SUCCESSFUL )
814 {
827 {
815 ret = status_q_p1;
828 ret = status_q_p1;
816 }
829 }
817 else
830 else
818 {
831 {
819 ret = status_q_p2;
832 ret = status_q_p2;
820 }
833 }
821
834
822 return ret;
835 return ret;
823 }
836 }
824
837
825 rtems_status_code create_timecode_timer( void )
838 rtems_status_code create_timecode_timer( void )
826 {
839 {
827 rtems_status_code status;
840 rtems_status_code status;
828
841
829 status = rtems_timer_create( timecode_timer_name, &timecode_timer_id );
842 status = rtems_timer_create( timecode_timer_name, &timecode_timer_id );
830
843
831 if ( status != RTEMS_SUCCESSFUL )
844 if ( status != RTEMS_SUCCESSFUL )
832 {
845 {
833 PRINTF1("in create_timer_timecode *** ERR creating SPTC timer, %d\n", status)
846 PRINTF1("in create_timer_timecode *** ERR creating SPTC timer, %d\n", status)
834 }
847 }
835 else
848 else
836 {
849 {
837 PRINTF("in create_timer_timecode *** OK creating SPTC timer\n")
850 PRINTF("in create_timer_timecode *** OK creating SPTC timer\n")
838 }
851 }
839
852
840 return status;
853 return status;
841 }
854 }
842
855
843 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
856 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
844 {
857 {
845 rtems_status_code status;
858 rtems_status_code status;
846 rtems_name queue_name;
859 rtems_name queue_name;
847
860
848 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
861 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
849
862
850 status = rtems_message_queue_ident( queue_name, 0, queue_id );
863 status = rtems_message_queue_ident( queue_name, 0, queue_id );
851
864
852 return status;
865 return status;
853 }
866 }
854
867
855 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
868 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
856 {
869 {
857 rtems_status_code status;
870 rtems_status_code status;
858 rtems_name queue_name;
871 rtems_name queue_name;
859
872
860 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
873 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
861
874
862 status = rtems_message_queue_ident( queue_name, 0, queue_id );
875 status = rtems_message_queue_ident( queue_name, 0, queue_id );
863
876
864 return status;
877 return status;
865 }
878 }
866
879
867 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
880 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
868 {
881 {
869 rtems_status_code status;
882 rtems_status_code status;
870 rtems_name queue_name;
883 rtems_name queue_name;
871
884
872 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
885 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
873
886
874 status = rtems_message_queue_ident( queue_name, 0, queue_id );
887 status = rtems_message_queue_ident( queue_name, 0, queue_id );
875
888
876 return status;
889 return status;
877 }
890 }
878
891
879 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
892 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
880 {
893 {
881 rtems_status_code status;
894 rtems_status_code status;
882 rtems_name queue_name;
895 rtems_name queue_name;
883
896
884 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
897 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
885
898
886 status = rtems_message_queue_ident( queue_name, 0, queue_id );
899 status = rtems_message_queue_ident( queue_name, 0, queue_id );
887
900
888 return status;
901 return status;
889 }
902 }
890
903
891 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
904 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
892 {
905 {
893 rtems_status_code status;
906 rtems_status_code status;
894 rtems_name queue_name;
907 rtems_name queue_name;
895
908
896 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
909 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
897
910
898 status = rtems_message_queue_ident( queue_name, 0, queue_id );
911 status = rtems_message_queue_ident( queue_name, 0, queue_id );
899
912
900 return status;
913 return status;
901 }
914 }
902
915
903 void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max )
916 void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max )
904 {
917 {
905 u_int32_t count;
918 u_int32_t count;
906 rtems_status_code status;
919 rtems_status_code status;
907
920
908 status = rtems_message_queue_get_number_pending( queue_id, &count );
921 status = rtems_message_queue_get_number_pending( queue_id, &count );
909
922
910 count = count + 1;
923 count = count + 1;
911
924
912 if (status != RTEMS_SUCCESSFUL)
925 if (status != RTEMS_SUCCESSFUL)
913 {
926 {
914 PRINTF1("in update_queue_max_count *** ERR = %d\n", status)
927 PRINTF1("in update_queue_max_count *** ERR = %d\n", status)
915 }
928 }
916 else
929 else
917 {
930 {
918 if (count > *fifo_size_max)
931 if (count > *fifo_size_max)
919 {
932 {
920 *fifo_size_max = count;
933 *fifo_size_max = count;
921 }
934 }
922 }
935 }
923 }
936 }
924
937
925 void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize )
938 void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize )
926 {
939 {
927 unsigned char i;
940 unsigned char i;
928
941
929 //***************
942 //***************
930 // BUFFER ADDRESS
943 // BUFFER ADDRESS
931 for(i=0; i<nbNodes; i++)
944 for(i=0; i<nbNodes; i++)
932 {
945 {
933 ring[i].coarseTime = 0xffffffff;
946 ring[i].coarseTime = 0xffffffff;
934 ring[i].fineTime = 0xffffffff;
947 ring[i].fineTime = 0xffffffff;
935 ring[i].sid = 0x00;
948 ring[i].sid = 0x00;
936 ring[i].status = 0x00;
949 ring[i].status = 0x00;
937 ring[i].buffer_address = (int) &buffer[ i * bufferSize ];
950 ring[i].buffer_address = (int) &buffer[ i * bufferSize ];
938 }
951 }
939
952
940 //*****
953 //*****
941 // NEXT
954 // NEXT
942 ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ];
955 ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ];
943 for(i=0; i<nbNodes-1; i++)
956 for(i=0; i<nbNodes-1; i++)
944 {
957 {
945 ring[i].next = (ring_node*) &ring[ i + 1 ];
958 ring[i].next = (ring_node*) &ring[ i + 1 ];
946 }
959 }
947
960
948 //*********
961 //*********
949 // PREVIOUS
962 // PREVIOUS
950 ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ];
963 ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ];
951 for(i=1; i<nbNodes; i++)
964 for(i=1; i<nbNodes; i++)
952 {
965 {
953 ring[i].previous = (ring_node*) &ring[ i - 1 ];
966 ring[i].previous = (ring_node*) &ring[ i - 1 ];
954 }
967 }
955 }
968 }
@@ -1,898 +1,913
1 /** General usage functions and RTEMS tasks.
1 /** General usage functions and RTEMS tasks.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 */
6 */
7
7
8 #include "fsw_misc.h"
8 #include "fsw_misc.h"
9
9
10 int16_t hk_lfr_sc_v_f3_as_int16;
11 int16_t hk_lfr_sc_e1_f3_as_int16;
12 int16_t hk_lfr_sc_e2_f3_as_int16;
13
10 void timer_configure(unsigned char timer, unsigned int clock_divider,
14 void timer_configure(unsigned char timer, unsigned int clock_divider,
11 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
15 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
12 {
16 {
13 /** This function configures a GPTIMER timer instantiated in the VHDL design.
17 /** This function configures a GPTIMER timer instantiated in the VHDL design.
14 *
18 *
15 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
19 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
16 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
20 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
17 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
21 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
18 * @param interrupt_level is the interrupt level that the timer drives.
22 * @param interrupt_level is the interrupt level that the timer drives.
19 * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer.
23 * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer.
20 *
24 *
21 * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76
25 * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76
22 *
26 *
23 */
27 */
24
28
25 rtems_status_code status;
29 rtems_status_code status;
26 rtems_isr_entry old_isr_handler;
30 rtems_isr_entry old_isr_handler;
27
31
28 gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register
32 gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register
29
33
30 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
34 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
31 if (status!=RTEMS_SUCCESSFUL)
35 if (status!=RTEMS_SUCCESSFUL)
32 {
36 {
33 PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n")
37 PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n")
34 }
38 }
35
39
36 timer_set_clock_divider( timer, clock_divider);
40 timer_set_clock_divider( timer, clock_divider);
37 }
41 }
38
42
39 void timer_start(unsigned char timer)
43 void timer_start(unsigned char timer)
40 {
44 {
41 /** This function starts a GPTIMER timer.
45 /** This function starts a GPTIMER timer.
42 *
46 *
43 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
47 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
44 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
48 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
45 *
49 *
46 */
50 */
47
51
48 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
52 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
49 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
53 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
50 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
54 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
51 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
55 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
52 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
56 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
53 }
57 }
54
58
55 void timer_stop(unsigned char timer)
59 void timer_stop(unsigned char timer)
56 {
60 {
57 /** This function stops a GPTIMER timer.
61 /** This function stops a GPTIMER timer.
58 *
62 *
59 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
63 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
60 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
64 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
61 *
65 *
62 */
66 */
63
67
64 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer
68 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer
65 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable
69 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable
66 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
70 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
67 }
71 }
68
72
69 void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider)
73 void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider)
70 {
74 {
71 /** This function sets the clock divider of a GPTIMER timer.
75 /** This function sets the clock divider of a GPTIMER timer.
72 *
76 *
73 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
77 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
74 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
78 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
75 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
79 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
76 *
80 *
77 */
81 */
78
82
79 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
83 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
80 }
84 }
81
85
82 // WATCHDOG
86 // WATCHDOG
83
87
84 rtems_isr watchdog_isr( rtems_vector_number vector )
88 rtems_isr watchdog_isr( rtems_vector_number vector )
85 {
89 {
86 rtems_status_code status_code;
90 rtems_status_code status_code;
87
91
88 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_12 );
92 status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_12 );
89
93
90 PRINTF("watchdog_isr *** this is the end, exit(0)\n");
94 PRINTF("watchdog_isr *** this is the end, exit(0)\n");
91
95
92 exit(0);
96 exit(0);
93 }
97 }
94
98
95 void watchdog_configure(void)
99 void watchdog_configure(void)
96 {
100 {
97 /** This function configure the watchdog.
101 /** This function configure the watchdog.
98 *
102 *
99 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
103 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
100 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
104 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
101 *
105 *
102 * The watchdog is a timer provided by the GPTIMER IP core of the GRLIB.
106 * The watchdog is a timer provided by the GPTIMER IP core of the GRLIB.
103 *
107 *
104 */
108 */
105
109
106 LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt during configuration
110 LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt during configuration
107
111
108 timer_configure( TIMER_WATCHDOG, CLKDIV_WATCHDOG, IRQ_SPARC_GPTIMER_WATCHDOG, watchdog_isr );
112 timer_configure( TIMER_WATCHDOG, CLKDIV_WATCHDOG, IRQ_SPARC_GPTIMER_WATCHDOG, watchdog_isr );
109
113
110 LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt
114 LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt
111 }
115 }
112
116
113 void watchdog_stop(void)
117 void watchdog_stop(void)
114 {
118 {
115 LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt line
119 LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt line
116 timer_stop( TIMER_WATCHDOG );
120 timer_stop( TIMER_WATCHDOG );
117 LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt
121 LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt
118 }
122 }
119
123
120 void watchdog_reload(void)
124 void watchdog_reload(void)
121 {
125 {
122 /** This function reloads the watchdog timer counter with the timer reload value.
126 /** This function reloads the watchdog timer counter with the timer reload value.
123 *
127 *
124 * @param void
128 * @param void
125 *
129 *
126 * @return void
130 * @return void
127 *
131 *
128 */
132 */
129
133
130 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000004; // LD load value from the reload register
134 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000004; // LD load value from the reload register
131 }
135 }
132
136
133 void watchdog_start(void)
137 void watchdog_start(void)
134 {
138 {
135 /** This function starts the watchdog timer.
139 /** This function starts the watchdog timer.
136 *
140 *
137 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
141 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
138 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
142 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
139 *
143 *
140 */
144 */
141
145
142 LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG );
146 LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG );
143
147
144 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000010; // clear pending IRQ if any
148 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000010; // clear pending IRQ if any
145 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000004; // LD load value from the reload register
149 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000004; // LD load value from the reload register
146 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000001; // EN enable the timer
150 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000001; // EN enable the timer
147 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000008; // IE interrupt enable
151 gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000008; // IE interrupt enable
148
152
149 LEON_Unmask_interrupt( IRQ_GPTIMER_WATCHDOG );
153 LEON_Unmask_interrupt( IRQ_GPTIMER_WATCHDOG );
150
154
151 }
155 }
152
156
153 int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register
157 int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register
154 {
158 {
155 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
159 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
156
160
157 apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE;
161 apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE;
158
162
159 return 0;
163 return 0;
160 }
164 }
161
165
162 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
166 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
163 {
167 {
164 /** This function sets the scaler reload register of the apbuart module
168 /** This function sets the scaler reload register of the apbuart module
165 *
169 *
166 * @param regs is the address of the apbuart registers in memory
170 * @param regs is the address of the apbuart registers in memory
167 * @param value is the value that will be stored in the scaler register
171 * @param value is the value that will be stored in the scaler register
168 *
172 *
169 * The value shall be set by the software to get data on the serial interface.
173 * The value shall be set by the software to get data on the serial interface.
170 *
174 *
171 */
175 */
172
176
173 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
177 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
174
178
175 apbuart_regs->scaler = value;
179 apbuart_regs->scaler = value;
176
180
177 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
181 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
178 }
182 }
179
183
180 //************
184 //************
181 // RTEMS TASKS
185 // RTEMS TASKS
182
186
183 rtems_task load_task(rtems_task_argument argument)
187 rtems_task load_task(rtems_task_argument argument)
184 {
188 {
185 BOOT_PRINTF("in LOAD *** \n")
189 BOOT_PRINTF("in LOAD *** \n")
186
190
187 rtems_status_code status;
191 rtems_status_code status;
188 unsigned int i;
192 unsigned int i;
189 unsigned int j;
193 unsigned int j;
190 rtems_name name_watchdog_rate_monotonic; // name of the watchdog rate monotonic
194 rtems_name name_watchdog_rate_monotonic; // name of the watchdog rate monotonic
191 rtems_id watchdog_period_id; // id of the watchdog rate monotonic period
195 rtems_id watchdog_period_id; // id of the watchdog rate monotonic period
192
196
193 name_watchdog_rate_monotonic = rtems_build_name( 'L', 'O', 'A', 'D' );
197 name_watchdog_rate_monotonic = rtems_build_name( 'L', 'O', 'A', 'D' );
194
198
195 status = rtems_rate_monotonic_create( name_watchdog_rate_monotonic, &watchdog_period_id );
199 status = rtems_rate_monotonic_create( name_watchdog_rate_monotonic, &watchdog_period_id );
196 if( status != RTEMS_SUCCESSFUL ) {
200 if( status != RTEMS_SUCCESSFUL ) {
197 PRINTF1( "in LOAD *** rtems_rate_monotonic_create failed with status of %d\n", status )
201 PRINTF1( "in LOAD *** rtems_rate_monotonic_create failed with status of %d\n", status )
198 }
202 }
199
203
200 i = 0;
204 i = 0;
201 j = 0;
205 j = 0;
202
206
203 watchdog_configure();
207 watchdog_configure();
204
208
205 watchdog_start();
209 watchdog_start();
206
210
207 set_sy_lfr_watchdog_enabled( true );
211 set_sy_lfr_watchdog_enabled( true );
208
212
209 while(1){
213 while(1){
210 status = rtems_rate_monotonic_period( watchdog_period_id, WATCHDOG_PERIOD );
214 status = rtems_rate_monotonic_period( watchdog_period_id, WATCHDOG_PERIOD );
211 watchdog_reload();
215 watchdog_reload();
212 i = i + 1;
216 i = i + 1;
213 if ( i == 10 )
217 if ( i == 10 )
214 {
218 {
215 i = 0;
219 i = 0;
216 j = j + 1;
220 j = j + 1;
217 PRINTF1("%d\n", j)
221 PRINTF1("%d\n", j)
218 }
222 }
219 #ifdef DEBUG_WATCHDOG
223 #ifdef DEBUG_WATCHDOG
220 if (j == 3 )
224 if (j == 3 )
221 {
225 {
222 status = rtems_task_delete(RTEMS_SELF);
226 status = rtems_task_delete(RTEMS_SELF);
223 }
227 }
224 #endif
228 #endif
225 }
229 }
226 }
230 }
227
231
228 rtems_task hous_task(rtems_task_argument argument)
232 rtems_task hous_task(rtems_task_argument argument)
229 {
233 {
230 rtems_status_code status;
234 rtems_status_code status;
231 rtems_status_code spare_status;
235 rtems_status_code spare_status;
232 rtems_id queue_id;
236 rtems_id queue_id;
233 rtems_rate_monotonic_period_status period_status;
237 rtems_rate_monotonic_period_status period_status;
234
238
235 status = get_message_queue_id_send( &queue_id );
239 status = get_message_queue_id_send( &queue_id );
236 if (status != RTEMS_SUCCESSFUL)
240 if (status != RTEMS_SUCCESSFUL)
237 {
241 {
238 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
242 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
239 }
243 }
240
244
241 BOOT_PRINTF("in HOUS ***\n");
245 BOOT_PRINTF("in HOUS ***\n");
242
246
243 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
247 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
244 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
248 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
245 if( status != RTEMS_SUCCESSFUL ) {
249 if( status != RTEMS_SUCCESSFUL ) {
246 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status );
250 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status );
247 }
251 }
248 }
252 }
249
253
250 status = rtems_rate_monotonic_cancel(HK_id);
254 status = rtems_rate_monotonic_cancel(HK_id);
251 if( status != RTEMS_SUCCESSFUL ) {
255 if( status != RTEMS_SUCCESSFUL ) {
252 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status );
256 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status );
253 }
257 }
254 else {
258 else {
255 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n");
259 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n");
256 }
260 }
257
261
258 // startup phase
262 // startup phase
259 status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks );
263 status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks );
260 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
264 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
261 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
265 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
262 while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway
266 while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway
263 {
267 {
264 if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization
268 if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization
265 {
269 {
266 break; // break if LFR is synchronized
270 break; // break if LFR is synchronized
267 }
271 }
268 else
272 else
269 {
273 {
270 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
274 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
271 // sched_yield();
275 // sched_yield();
272 status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms
276 status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms
273 }
277 }
274 }
278 }
275 status = rtems_rate_monotonic_cancel(HK_id);
279 status = rtems_rate_monotonic_cancel(HK_id);
276 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
280 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
277
281
278 set_hk_lfr_reset_cause( POWER_ON );
282 set_hk_lfr_reset_cause( POWER_ON );
279
283
280 while(1){ // launch the rate monotonic task
284 while(1){ // launch the rate monotonic task
281 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
285 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
282 if ( status != RTEMS_SUCCESSFUL ) {
286 if ( status != RTEMS_SUCCESSFUL ) {
283 PRINTF1( "in HOUS *** ERR period: %d\n", status);
287 PRINTF1( "in HOUS *** ERR period: %d\n", status);
284 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
288 spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
285 }
289 }
286 else {
290 else {
287 housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8);
291 housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8);
288 housekeeping_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterHK );
292 housekeeping_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterHK );
289 increment_seq_counter( &sequenceCounterHK );
293 increment_seq_counter( &sequenceCounterHK );
290
294
291 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
295 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
292 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
296 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
293 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
297 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
294 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
298 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
295 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
299 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
296 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
300 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
297
301
298 spacewire_update_hk_lfr_link_state( &housekeeping_packet.lfr_status_word[0] );
302 spacewire_update_hk_lfr_link_state( &housekeeping_packet.lfr_status_word[0] );
299
303
300 spacewire_read_statistics();
304 spacewire_read_statistics();
301
305
302 update_hk_with_grspw_stats();
306 update_hk_with_grspw_stats();
303
307
304 set_hk_lfr_time_not_synchro();
308 set_hk_lfr_time_not_synchro();
305
309
306 housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max;
310 housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max;
307 housekeeping_packet.hk_lfr_q_rv_fifo_size_max = hk_lfr_q_rv_fifo_size_max;
311 housekeeping_packet.hk_lfr_q_rv_fifo_size_max = hk_lfr_q_rv_fifo_size_max;
308 housekeeping_packet.hk_lfr_q_p0_fifo_size_max = hk_lfr_q_p0_fifo_size_max;
312 housekeeping_packet.hk_lfr_q_p0_fifo_size_max = hk_lfr_q_p0_fifo_size_max;
309 housekeeping_packet.hk_lfr_q_p1_fifo_size_max = hk_lfr_q_p1_fifo_size_max;
313 housekeeping_packet.hk_lfr_q_p1_fifo_size_max = hk_lfr_q_p1_fifo_size_max;
310 housekeeping_packet.hk_lfr_q_p2_fifo_size_max = hk_lfr_q_p2_fifo_size_max;
314 housekeeping_packet.hk_lfr_q_p2_fifo_size_max = hk_lfr_q_p2_fifo_size_max;
311
315
312 housekeeping_packet.sy_lfr_common_parameters_spare = parameter_dump_packet.sy_lfr_common_parameters_spare;
316 housekeeping_packet.sy_lfr_common_parameters_spare = parameter_dump_packet.sy_lfr_common_parameters_spare;
313 housekeeping_packet.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
317 housekeeping_packet.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters;
314 get_temperatures( housekeeping_packet.hk_lfr_temp_scm );
318 get_temperatures( housekeeping_packet.hk_lfr_temp_scm );
315 get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 );
319 get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 );
316 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
320 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
317
321
318 hk_lfr_le_me_he_update();
322 hk_lfr_le_me_he_update();
319
323
320 housekeeping_packet.hk_lfr_sc_rw_f_flags = cp_rpw_sc_rw_f_flags;
324 housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = cp_rpw_sc_rw1_rw2_f_flags;
325 housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = cp_rpw_sc_rw3_rw4_f_flags;
321
326
322 // SEND PACKET
327 // SEND PACKET
323 status = rtems_message_queue_send( queue_id, &housekeeping_packet,
328 status = rtems_message_queue_send( queue_id, &housekeeping_packet,
324 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
329 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
325 if (status != RTEMS_SUCCESSFUL) {
330 if (status != RTEMS_SUCCESSFUL) {
326 PRINTF1("in HOUS *** ERR send: %d\n", status)
331 PRINTF1("in HOUS *** ERR send: %d\n", status)
327 }
332 }
328 }
333 }
329 }
334 }
330
335
331 PRINTF("in HOUS *** deleting task\n")
336 PRINTF("in HOUS *** deleting task\n")
332
337
333 status = rtems_task_delete( RTEMS_SELF ); // should not return
338 status = rtems_task_delete( RTEMS_SELF ); // should not return
334
339
335 return;
340 return;
336 }
341 }
337
342
338 rtems_task avgv_task(rtems_task_argument argument)
343 rtems_task avgv_task(rtems_task_argument argument)
339 {
344 {
340 #define MOVING_AVERAGE 16
345 #define MOVING_AVERAGE 16
341 rtems_status_code status;
346 rtems_status_code status;
342 unsigned int v[MOVING_AVERAGE];
347 unsigned int v[MOVING_AVERAGE];
343 unsigned int e1[MOVING_AVERAGE];
348 unsigned int e1[MOVING_AVERAGE];
344 unsigned int e2[MOVING_AVERAGE];
349 unsigned int e2[MOVING_AVERAGE];
345 float average_v;
350 float average_v;
346 float average_e1;
351 float average_e1;
347 float average_e2;
352 float average_e2;
353 float newValue_v;
354 float newValue_e1;
355 float newValue_e2;
348 unsigned char k;
356 unsigned char k;
349 unsigned char indexOfOldValue;
357 unsigned char indexOfOldValue;
350
358
351 BOOT_PRINTF("in AVGV ***\n");
359 BOOT_PRINTF("in AVGV ***\n");
352
360
353 if (rtems_rate_monotonic_ident( name_avgv_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
361 if (rtems_rate_monotonic_ident( name_avgv_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
354 status = rtems_rate_monotonic_create( name_avgv_rate_monotonic, &AVGV_id );
362 status = rtems_rate_monotonic_create( name_avgv_rate_monotonic, &AVGV_id );
355 if( status != RTEMS_SUCCESSFUL ) {
363 if( status != RTEMS_SUCCESSFUL ) {
356 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status );
364 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status );
357 }
365 }
358 }
366 }
359
367
360 status = rtems_rate_monotonic_cancel(AVGV_id);
368 status = rtems_rate_monotonic_cancel(AVGV_id);
361 if( status != RTEMS_SUCCESSFUL ) {
369 if( status != RTEMS_SUCCESSFUL ) {
362 PRINTF1( "ERR *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id) ***code: %d\n", status );
370 PRINTF1( "ERR *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id) ***code: %d\n", status );
363 }
371 }
364 else {
372 else {
365 DEBUG_PRINTF("OK *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id)\n");
373 DEBUG_PRINTF("OK *** in AVGV *** rtems_rate_monotonic_cancel(AVGV_id)\n");
366 }
374 }
367
375
368 // initialize values
376 // initialize values
369 k = 0;
377 k = 0;
370 indexOfOldValue = MOVING_AVERAGE - 1;
378 indexOfOldValue = MOVING_AVERAGE - 1;
371 for (k = 0; k < MOVING_AVERAGE; k++)
379 for (k = 0; k < MOVING_AVERAGE; k++)
372 {
380 {
373 v[k] = 0;
381 v[k] = 0;
374 e1[k] = 0;
382 e1[k] = 0;
375 e2[k] = 0;
383 e2[k] = 0;
376 average_v = 0.;
384 average_v = 0.;
377 average_e1 = 0.;
385 average_e1 = 0.;
378 average_e2 = 0.;
386 average_e2 = 0.;
387 newValue_v = 0.;
388 newValue_e1 = 0.;
389 newValue_e2 = 0.;
379 }
390 }
380
391
381 k = 0;
392 k = 0;
382
393
383 while(1){ // launch the rate monotonic task
394 while(1){ // launch the rate monotonic task
384 status = rtems_rate_monotonic_period( AVGV_id, AVGV_PERIOD );
395 status = rtems_rate_monotonic_period( AVGV_id, AVGV_PERIOD );
385 if ( status != RTEMS_SUCCESSFUL ) {
396 if ( status != RTEMS_SUCCESSFUL ) {
386 PRINTF1( "in AVGV *** ERR period: %d\n", status);
397 PRINTF1( "in AVGV *** ERR period: %d\n", status);
387 }
398 }
388 else {
399 else {
389 // store new value in buffer
400 // get new values
390 v[k] = waveform_picker_regs->v;
401 newValue_v = waveform_picker_regs->v;
391 e1[k] = waveform_picker_regs->e1;
402 newValue_e1 = waveform_picker_regs->e1;
392 e2[k] = waveform_picker_regs->e2;
403 newValue_e2 = waveform_picker_regs->e2;
393 if (k == (MOVING_AVERAGE - 1))
404
394 {
405 // compute the moving average
395 indexOfOldValue = 0;
406 average_v = average_v + newValue_v - v[k];
396 }
407 average_e1 = average_e1 + newValue_e1 - e1[k];
397 else
408 average_e2 = average_e2 + newValue_e2 - e2[k];
398 {
409
399 indexOfOldValue = k + 1;
410 // store new values in buffers
400 }
411 v[k] = newValue_v;
401 average_v = average_v + v[k] - v[indexOfOldValue];
412 e1[k] = newValue_e1;
402 average_e1 = average_e1 + e1[k] - e1[indexOfOldValue];
413 e2[k] = newValue_e2;
403 average_e2 = average_e2 + e2[k] - e2[indexOfOldValue];
404 }
414 }
405 if (k == (MOVING_AVERAGE-1))
415 if (k == (MOVING_AVERAGE-1))
406 {
416 {
407 k = 0;
417 k = 0;
408 printf("tick\n");
418 printf("tick\n");
409 }
419 }
410 else
420 else
411 {
421 {
412 k++;
422 k++;
413 }
423 }
414 }
424 }
415
425
416 PRINTF("in AVGV *** deleting task\n")
426 //update int16 values
427 hk_lfr_sc_v_f3_as_int16 = (int16_t) (average_v / ((float) MOVING_AVERAGE) );
428 hk_lfr_sc_e1_f3_as_int16 = (int16_t) (average_e1 / ((float) MOVING_AVERAGE) );
429 hk_lfr_sc_e2_f3_as_int16 = (int16_t) (average_e2 / ((float) MOVING_AVERAGE) );
417
430
418 status = rtems_task_delete( RTEMS_SELF ); // should not return
431 PRINTF("in AVGV *** deleting task\n");
432
433 status = rtems_task_delete( RTEMS_SELF ); // should not return
419
434
420 return;
435 return;
421 }
436 }
422
437
423 rtems_task dumb_task( rtems_task_argument unused )
438 rtems_task dumb_task( rtems_task_argument unused )
424 {
439 {
425 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
440 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
426 *
441 *
427 * @param unused is the starting argument of the RTEMS task
442 * @param unused is the starting argument of the RTEMS task
428 *
443 *
429 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
444 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
430 *
445 *
431 */
446 */
432
447
433 unsigned int i;
448 unsigned int i;
434 unsigned int intEventOut;
449 unsigned int intEventOut;
435 unsigned int coarse_time = 0;
450 unsigned int coarse_time = 0;
436 unsigned int fine_time = 0;
451 unsigned int fine_time = 0;
437 rtems_event_set event_out;
452 rtems_event_set event_out;
438
453
439 char *DumbMessages[15] = {"in DUMB *** default", // RTEMS_EVENT_0
454 char *DumbMessages[15] = {"in DUMB *** default", // RTEMS_EVENT_0
440 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
455 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
441 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
456 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
442 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
457 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
443 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
458 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
444 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
459 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
445 "VHDL SM *** two buffers f0 ready", // RTEMS_EVENT_6
460 "VHDL SM *** two buffers f0 ready", // RTEMS_EVENT_6
446 "ready for dump", // RTEMS_EVENT_7
461 "ready for dump", // RTEMS_EVENT_7
447 "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8
462 "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8
448 "tick", // RTEMS_EVENT_9
463 "tick", // RTEMS_EVENT_9
449 "VHDL ERR *** waveform picker", // RTEMS_EVENT_10
464 "VHDL ERR *** waveform picker", // RTEMS_EVENT_10
450 "VHDL ERR *** unexpected ready matrix values", // RTEMS_EVENT_11
465 "VHDL ERR *** unexpected ready matrix values", // RTEMS_EVENT_11
451 "WATCHDOG timer", // RTEMS_EVENT_12
466 "WATCHDOG timer", // RTEMS_EVENT_12
452 "TIMECODE timer", // RTEMS_EVENT_13
467 "TIMECODE timer", // RTEMS_EVENT_13
453 "TIMECODE ISR" // RTEMS_EVENT_14
468 "TIMECODE ISR" // RTEMS_EVENT_14
454 };
469 };
455
470
456 BOOT_PRINTF("in DUMB *** \n")
471 BOOT_PRINTF("in DUMB *** \n")
457
472
458 while(1){
473 while(1){
459 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
474 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
460 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
475 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
461 | RTEMS_EVENT_8 | RTEMS_EVENT_9 | RTEMS_EVENT_12 | RTEMS_EVENT_13
476 | RTEMS_EVENT_8 | RTEMS_EVENT_9 | RTEMS_EVENT_12 | RTEMS_EVENT_13
462 | RTEMS_EVENT_14,
477 | RTEMS_EVENT_14,
463 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
478 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
464 intEventOut = (unsigned int) event_out;
479 intEventOut = (unsigned int) event_out;
465 for ( i=0; i<32; i++)
480 for ( i=0; i<32; i++)
466 {
481 {
467 if ( ((intEventOut >> i) & 0x0001) != 0)
482 if ( ((intEventOut >> i) & 0x0001) != 0)
468 {
483 {
469 coarse_time = time_management_regs->coarse_time;
484 coarse_time = time_management_regs->coarse_time;
470 fine_time = time_management_regs->fine_time;
485 fine_time = time_management_regs->fine_time;
471 if (i==12)
486 if (i==12)
472 {
487 {
473 PRINTF1("%s\n", DumbMessages[12])
488 PRINTF1("%s\n", DumbMessages[12])
474 }
489 }
475 if (i==13)
490 if (i==13)
476 {
491 {
477 PRINTF1("%s\n", DumbMessages[13])
492 PRINTF1("%s\n", DumbMessages[13])
478 }
493 }
479 if (i==14)
494 if (i==14)
480 {
495 {
481 PRINTF1("%s\n", DumbMessages[1])
496 PRINTF1("%s\n", DumbMessages[1])
482 }
497 }
483 }
498 }
484 }
499 }
485 }
500 }
486 }
501 }
487
502
488 //*****************************
503 //*****************************
489 // init housekeeping parameters
504 // init housekeeping parameters
490
505
491 void init_housekeeping_parameters( void )
506 void init_housekeeping_parameters( void )
492 {
507 {
493 /** This function initialize the housekeeping_packet global variable with default values.
508 /** This function initialize the housekeeping_packet global variable with default values.
494 *
509 *
495 */
510 */
496
511
497 unsigned int i = 0;
512 unsigned int i = 0;
498 unsigned char *parameters;
513 unsigned char *parameters;
499 unsigned char sizeOfHK;
514 unsigned char sizeOfHK;
500
515
501 sizeOfHK = sizeof( Packet_TM_LFR_HK_t );
516 sizeOfHK = sizeof( Packet_TM_LFR_HK_t );
502
517
503 parameters = (unsigned char*) &housekeeping_packet;
518 parameters = (unsigned char*) &housekeeping_packet;
504
519
505 for(i = 0; i< sizeOfHK; i++)
520 for(i = 0; i< sizeOfHK; i++)
506 {
521 {
507 parameters[i] = 0x00;
522 parameters[i] = 0x00;
508 }
523 }
509
524
510 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
525 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
511 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
526 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
512 housekeeping_packet.reserved = DEFAULT_RESERVED;
527 housekeeping_packet.reserved = DEFAULT_RESERVED;
513 housekeeping_packet.userApplication = CCSDS_USER_APP;
528 housekeeping_packet.userApplication = CCSDS_USER_APP;
514 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
529 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
515 housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK);
530 housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK);
516 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
531 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
517 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
532 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
518 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
533 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
519 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
534 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
520 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
535 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
521 housekeeping_packet.serviceType = TM_TYPE_HK;
536 housekeeping_packet.serviceType = TM_TYPE_HK;
522 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
537 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
523 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
538 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
524 housekeeping_packet.sid = SID_HK;
539 housekeeping_packet.sid = SID_HK;
525
540
526 // init status word
541 // init status word
527 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
542 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
528 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
543 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
529 // init software version
544 // init software version
530 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
545 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
531 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
546 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
532 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
547 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
533 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
548 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
534 // init fpga version
549 // init fpga version
535 parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
550 parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
536 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
551 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
537 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
552 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
538 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
553 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
539
554
540 housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND;
555 housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND;
541 housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV;
556 housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV;
542 housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0;
557 housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0;
543 housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1;
558 housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1;
544 housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2;
559 housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2;
545 }
560 }
546
561
547 void increment_seq_counter( unsigned short *packetSequenceControl )
562 void increment_seq_counter( unsigned short *packetSequenceControl )
548 {
563 {
549 /** This function increment the sequence counter passes in argument.
564 /** This function increment the sequence counter passes in argument.
550 *
565 *
551 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
566 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
552 *
567 *
553 */
568 */
554
569
555 unsigned short segmentation_grouping_flag;
570 unsigned short segmentation_grouping_flag;
556 unsigned short sequence_cnt;
571 unsigned short sequence_cnt;
557
572
558 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
573 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
559 sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111]
574 sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111]
560
575
561 if ( sequence_cnt < SEQ_CNT_MAX)
576 if ( sequence_cnt < SEQ_CNT_MAX)
562 {
577 {
563 sequence_cnt = sequence_cnt + 1;
578 sequence_cnt = sequence_cnt + 1;
564 }
579 }
565 else
580 else
566 {
581 {
567 sequence_cnt = 0;
582 sequence_cnt = 0;
568 }
583 }
569
584
570 *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ;
585 *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ;
571 }
586 }
572
587
573 void getTime( unsigned char *time)
588 void getTime( unsigned char *time)
574 {
589 {
575 /** This function write the current local time in the time buffer passed in argument.
590 /** This function write the current local time in the time buffer passed in argument.
576 *
591 *
577 */
592 */
578
593
579 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
594 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
580 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
595 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
581 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
596 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
582 time[3] = (unsigned char) (time_management_regs->coarse_time);
597 time[3] = (unsigned char) (time_management_regs->coarse_time);
583 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
598 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
584 time[5] = (unsigned char) (time_management_regs->fine_time);
599 time[5] = (unsigned char) (time_management_regs->fine_time);
585 }
600 }
586
601
587 unsigned long long int getTimeAsUnsignedLongLongInt( )
602 unsigned long long int getTimeAsUnsignedLongLongInt( )
588 {
603 {
589 /** This function write the current local time in the time buffer passed in argument.
604 /** This function write the current local time in the time buffer passed in argument.
590 *
605 *
591 */
606 */
592 unsigned long long int time;
607 unsigned long long int time;
593
608
594 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
609 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
595 + time_management_regs->fine_time;
610 + time_management_regs->fine_time;
596
611
597 return time;
612 return time;
598 }
613 }
599
614
600 void send_dumb_hk( void )
615 void send_dumb_hk( void )
601 {
616 {
602 Packet_TM_LFR_HK_t dummy_hk_packet;
617 Packet_TM_LFR_HK_t dummy_hk_packet;
603 unsigned char *parameters;
618 unsigned char *parameters;
604 unsigned int i;
619 unsigned int i;
605 rtems_id queue_id;
620 rtems_id queue_id;
606
621
607 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
622 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
608 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
623 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
609 dummy_hk_packet.reserved = DEFAULT_RESERVED;
624 dummy_hk_packet.reserved = DEFAULT_RESERVED;
610 dummy_hk_packet.userApplication = CCSDS_USER_APP;
625 dummy_hk_packet.userApplication = CCSDS_USER_APP;
611 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
626 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
612 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
627 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
613 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
628 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
614 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
629 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
615 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
630 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
616 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
631 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
617 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
632 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
618 dummy_hk_packet.serviceType = TM_TYPE_HK;
633 dummy_hk_packet.serviceType = TM_TYPE_HK;
619 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
634 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
620 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
635 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
621 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
636 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
622 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
637 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
623 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
638 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
624 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
639 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
625 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
640 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
626 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
641 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
627 dummy_hk_packet.sid = SID_HK;
642 dummy_hk_packet.sid = SID_HK;
628
643
629 // init status word
644 // init status word
630 dummy_hk_packet.lfr_status_word[0] = 0xff;
645 dummy_hk_packet.lfr_status_word[0] = 0xff;
631 dummy_hk_packet.lfr_status_word[1] = 0xff;
646 dummy_hk_packet.lfr_status_word[1] = 0xff;
632 // init software version
647 // init software version
633 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
648 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
634 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
649 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
635 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
650 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
636 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
651 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
637 // init fpga version
652 // init fpga version
638 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
653 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
639 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
654 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
640 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
655 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
641 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
656 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
642
657
643 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
658 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
644
659
645 for (i=0; i<100; i++)
660 for (i=0; i<100; i++)
646 {
661 {
647 parameters[i] = 0xff;
662 parameters[i] = 0xff;
648 }
663 }
649
664
650 get_message_queue_id_send( &queue_id );
665 get_message_queue_id_send( &queue_id );
651
666
652 rtems_message_queue_send( queue_id, &dummy_hk_packet,
667 rtems_message_queue_send( queue_id, &dummy_hk_packet,
653 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
668 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
654 }
669 }
655
670
656 void get_temperatures( unsigned char *temperatures )
671 void get_temperatures( unsigned char *temperatures )
657 {
672 {
658 unsigned char* temp_scm_ptr;
673 unsigned char* temp_scm_ptr;
659 unsigned char* temp_pcb_ptr;
674 unsigned char* temp_pcb_ptr;
660 unsigned char* temp_fpga_ptr;
675 unsigned char* temp_fpga_ptr;
661
676
662 // SEL1 SEL0
677 // SEL1 SEL0
663 // 0 0 => PCB
678 // 0 0 => PCB
664 // 0 1 => FPGA
679 // 0 1 => FPGA
665 // 1 0 => SCM
680 // 1 0 => SCM
666
681
667 temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm;
682 temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm;
668 temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb;
683 temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb;
669 temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga;
684 temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga;
670
685
671 temperatures[0] = temp_scm_ptr[2];
686 temperatures[0] = temp_scm_ptr[2];
672 temperatures[1] = temp_scm_ptr[3];
687 temperatures[1] = temp_scm_ptr[3];
673 temperatures[2] = temp_pcb_ptr[2];
688 temperatures[2] = temp_pcb_ptr[2];
674 temperatures[3] = temp_pcb_ptr[3];
689 temperatures[3] = temp_pcb_ptr[3];
675 temperatures[4] = temp_fpga_ptr[2];
690 temperatures[4] = temp_fpga_ptr[2];
676 temperatures[5] = temp_fpga_ptr[3];
691 temperatures[5] = temp_fpga_ptr[3];
677 }
692 }
678
693
679 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
694 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
680 {
695 {
681 unsigned char* v_ptr;
696 unsigned char* v_ptr;
682 unsigned char* e1_ptr;
697 unsigned char* e1_ptr;
683 unsigned char* e2_ptr;
698 unsigned char* e2_ptr;
684
699
685 v_ptr = (unsigned char *) &waveform_picker_regs->v;
700 v_ptr = (unsigned char *) &hk_lfr_sc_v_f3_as_int16;
686 e1_ptr = (unsigned char *) &waveform_picker_regs->e1;
701 e1_ptr = (unsigned char *) &hk_lfr_sc_e1_f3_as_int16;
687 e2_ptr = (unsigned char *) &waveform_picker_regs->e2;
702 e2_ptr = (unsigned char *) &hk_lfr_sc_e2_f3_as_int16;
688
703
689 spacecraft_potential[0] = v_ptr[2];
704 spacecraft_potential[0] = v_ptr[0];
690 spacecraft_potential[1] = v_ptr[3];
705 spacecraft_potential[1] = v_ptr[1];
691 spacecraft_potential[2] = e1_ptr[2];
706 spacecraft_potential[2] = e1_ptr[0];
692 spacecraft_potential[3] = e1_ptr[3];
707 spacecraft_potential[3] = e1_ptr[1];
693 spacecraft_potential[4] = e2_ptr[2];
708 spacecraft_potential[4] = e2_ptr[0];
694 spacecraft_potential[5] = e2_ptr[3];
709 spacecraft_potential[5] = e2_ptr[1];
695 }
710 }
696
711
697 void get_cpu_load( unsigned char *resource_statistics )
712 void get_cpu_load( unsigned char *resource_statistics )
698 {
713 {
699 unsigned char cpu_load;
714 unsigned char cpu_load;
700
715
701 cpu_load = lfr_rtems_cpu_usage_report();
716 cpu_load = lfr_rtems_cpu_usage_report();
702
717
703 // HK_LFR_CPU_LOAD
718 // HK_LFR_CPU_LOAD
704 resource_statistics[0] = cpu_load;
719 resource_statistics[0] = cpu_load;
705
720
706 // HK_LFR_CPU_LOAD_MAX
721 // HK_LFR_CPU_LOAD_MAX
707 if (cpu_load > resource_statistics[1])
722 if (cpu_load > resource_statistics[1])
708 {
723 {
709 resource_statistics[1] = cpu_load;
724 resource_statistics[1] = cpu_load;
710 }
725 }
711
726
712 // CPU_LOAD_AVE
727 // CPU_LOAD_AVE
713 resource_statistics[2] = 0;
728 resource_statistics[2] = 0;
714
729
715 #ifndef PRINT_TASK_STATISTICS
730 #ifndef PRINT_TASK_STATISTICS
716 rtems_cpu_usage_reset();
731 rtems_cpu_usage_reset();
717 #endif
732 #endif
718
733
719 }
734 }
720
735
721 void set_hk_lfr_sc_potential_flag( bool state )
736 void set_hk_lfr_sc_potential_flag( bool state )
722 {
737 {
723 if (state == true)
738 if (state == true)
724 {
739 {
725 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x40; // [0100 0000]
740 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x40; // [0100 0000]
726 }
741 }
727 else
742 else
728 {
743 {
729 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xbf; // [1011 1111]
744 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xbf; // [1011 1111]
730 }
745 }
731 }
746 }
732
747
733 void set_sy_lfr_pas_filter_enabled( bool state )
748 void set_sy_lfr_pas_filter_enabled( bool state )
734 {
749 {
735 if (state == true)
750 if (state == true)
736 {
751 {
737 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x20; // [0010 0000]
752 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x20; // [0010 0000]
738 }
753 }
739 else
754 else
740 {
755 {
741 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xdf; // [1101 1111]
756 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xdf; // [1101 1111]
742 }
757 }
743 }
758 }
744
759
745 void set_sy_lfr_watchdog_enabled( bool state )
760 void set_sy_lfr_watchdog_enabled( bool state )
746 {
761 {
747 if (state == true)
762 if (state == true)
748 {
763 {
749 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x10; // [0001 0000]
764 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x10; // [0001 0000]
750 }
765 }
751 else
766 else
752 {
767 {
753 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xef; // [1110 1111]
768 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xef; // [1110 1111]
754 }
769 }
755 }
770 }
756
771
757 void set_hk_lfr_calib_enable( bool state )
772 void set_hk_lfr_calib_enable( bool state )
758 {
773 {
759 if (state == true)
774 if (state == true)
760 {
775 {
761 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x08; // [0000 1000]
776 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x08; // [0000 1000]
762 }
777 }
763 else
778 else
764 {
779 {
765 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf7; // [1111 0111]
780 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf7; // [1111 0111]
766 }
781 }
767 }
782 }
768
783
769 void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause )
784 void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause )
770 {
785 {
771 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf8; // [1111 1000]
786 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf8; // [1111 1000]
772
787
773 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1]
788 housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1]
774 | (lfr_reset_cause & 0x07 ); // [0000 0111]
789 | (lfr_reset_cause & 0x07 ); // [0000 0111]
775
790
776 }
791 }
777
792
778 void hk_lfr_le_me_he_update()
793 void hk_lfr_le_me_he_update()
779 {
794 {
780 unsigned int hk_lfr_le_cnt;
795 unsigned int hk_lfr_le_cnt;
781 unsigned int hk_lfr_me_cnt;
796 unsigned int hk_lfr_me_cnt;
782 unsigned int hk_lfr_he_cnt;
797 unsigned int hk_lfr_he_cnt;
783 unsigned int current_hk_lfr_le_cnt;
798 unsigned int current_hk_lfr_le_cnt;
784 unsigned int current_hk_lfr_me_cnt;
799 unsigned int current_hk_lfr_me_cnt;
785 unsigned int current_hk_lfr_he_cnt;
800 unsigned int current_hk_lfr_he_cnt;
786
801
787 hk_lfr_le_cnt = 0;
802 hk_lfr_le_cnt = 0;
788 hk_lfr_me_cnt = 0;
803 hk_lfr_me_cnt = 0;
789 hk_lfr_he_cnt = 0;
804 hk_lfr_he_cnt = 0;
790 current_hk_lfr_le_cnt = ((unsigned int) housekeeping_packet.hk_lfr_le_cnt[0]) * 256 + housekeeping_packet.hk_lfr_le_cnt[1];
805 current_hk_lfr_le_cnt = ((unsigned int) housekeeping_packet.hk_lfr_le_cnt[0]) * 256 + housekeeping_packet.hk_lfr_le_cnt[1];
791 current_hk_lfr_me_cnt = ((unsigned int) housekeeping_packet.hk_lfr_me_cnt[0]) * 256 + housekeeping_packet.hk_lfr_me_cnt[1];
806 current_hk_lfr_me_cnt = ((unsigned int) housekeeping_packet.hk_lfr_me_cnt[0]) * 256 + housekeeping_packet.hk_lfr_me_cnt[1];
792 current_hk_lfr_he_cnt = ((unsigned int) housekeeping_packet.hk_lfr_he_cnt[0]) * 256 + housekeeping_packet.hk_lfr_he_cnt[1];
807 current_hk_lfr_he_cnt = ((unsigned int) housekeeping_packet.hk_lfr_he_cnt[0]) * 256 + housekeeping_packet.hk_lfr_he_cnt[1];
793
808
794 //update the low severity error counter
809 //update the low severity error counter
795 hk_lfr_le_cnt =
810 hk_lfr_le_cnt =
796 current_hk_lfr_le_cnt
811 current_hk_lfr_le_cnt
797 + housekeeping_packet.hk_lfr_dpu_spw_parity
812 + housekeeping_packet.hk_lfr_dpu_spw_parity
798 + housekeeping_packet.hk_lfr_dpu_spw_disconnect
813 + housekeeping_packet.hk_lfr_dpu_spw_disconnect
799 + housekeeping_packet.hk_lfr_dpu_spw_escape
814 + housekeeping_packet.hk_lfr_dpu_spw_escape
800 + housekeeping_packet.hk_lfr_dpu_spw_credit
815 + housekeeping_packet.hk_lfr_dpu_spw_credit
801 + housekeeping_packet.hk_lfr_dpu_spw_write_sync
816 + housekeeping_packet.hk_lfr_dpu_spw_write_sync
802 + housekeeping_packet.hk_lfr_timecode_erroneous
817 + housekeeping_packet.hk_lfr_timecode_erroneous
803 + housekeeping_packet.hk_lfr_timecode_missing
818 + housekeeping_packet.hk_lfr_timecode_missing
804 + housekeeping_packet.hk_lfr_timecode_invalid
819 + housekeeping_packet.hk_lfr_timecode_invalid
805 + housekeeping_packet.hk_lfr_time_timecode_it
820 + housekeeping_packet.hk_lfr_time_timecode_it
806 + housekeeping_packet.hk_lfr_time_not_synchro
821 + housekeeping_packet.hk_lfr_time_not_synchro
807 + housekeeping_packet.hk_lfr_time_timecode_ctr
822 + housekeeping_packet.hk_lfr_time_timecode_ctr
808 + housekeeping_packet.hk_lfr_ahb_correctable;
823 + housekeeping_packet.hk_lfr_ahb_correctable;
809 // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver
824 // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb => not handled by the grspw driver
810 // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver
825 // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb => not handled by the grspw driver
811
826
812 //update the medium severity error counter
827 //update the medium severity error counter
813 hk_lfr_me_cnt =
828 hk_lfr_me_cnt =
814 current_hk_lfr_me_cnt
829 current_hk_lfr_me_cnt
815 + housekeeping_packet.hk_lfr_dpu_spw_early_eop
830 + housekeeping_packet.hk_lfr_dpu_spw_early_eop
816 + housekeeping_packet.hk_lfr_dpu_spw_invalid_addr
831 + housekeeping_packet.hk_lfr_dpu_spw_invalid_addr
817 + housekeeping_packet.hk_lfr_dpu_spw_eep
832 + housekeeping_packet.hk_lfr_dpu_spw_eep
818 + housekeeping_packet.hk_lfr_dpu_spw_rx_too_big;
833 + housekeeping_packet.hk_lfr_dpu_spw_rx_too_big;
819
834
820 //update the high severity error counter
835 //update the high severity error counter
821 hk_lfr_he_cnt = 0;
836 hk_lfr_he_cnt = 0;
822
837
823 // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers
838 // update housekeeping packet counters, convert unsigned int numbers in 2 bytes numbers
824 // LE
839 // LE
825 housekeeping_packet.hk_lfr_le_cnt[0] = (unsigned char) ((hk_lfr_le_cnt & 0xff00) >> 8);
840 housekeeping_packet.hk_lfr_le_cnt[0] = (unsigned char) ((hk_lfr_le_cnt & 0xff00) >> 8);
826 housekeeping_packet.hk_lfr_le_cnt[1] = (unsigned char) (hk_lfr_le_cnt & 0x00ff);
841 housekeeping_packet.hk_lfr_le_cnt[1] = (unsigned char) (hk_lfr_le_cnt & 0x00ff);
827 // ME
842 // ME
828 housekeeping_packet.hk_lfr_me_cnt[0] = (unsigned char) ((hk_lfr_me_cnt & 0xff00) >> 8);
843 housekeeping_packet.hk_lfr_me_cnt[0] = (unsigned char) ((hk_lfr_me_cnt & 0xff00) >> 8);
829 housekeeping_packet.hk_lfr_me_cnt[1] = (unsigned char) (hk_lfr_me_cnt & 0x00ff);
844 housekeeping_packet.hk_lfr_me_cnt[1] = (unsigned char) (hk_lfr_me_cnt & 0x00ff);
830 // HE
845 // HE
831 housekeeping_packet.hk_lfr_he_cnt[0] = (unsigned char) ((hk_lfr_he_cnt & 0xff00) >> 8);
846 housekeeping_packet.hk_lfr_he_cnt[0] = (unsigned char) ((hk_lfr_he_cnt & 0xff00) >> 8);
832 housekeeping_packet.hk_lfr_he_cnt[1] = (unsigned char) (hk_lfr_he_cnt & 0x00ff);
847 housekeeping_packet.hk_lfr_he_cnt[1] = (unsigned char) (hk_lfr_he_cnt & 0x00ff);
833
848
834 }
849 }
835
850
836 void set_hk_lfr_time_not_synchro()
851 void set_hk_lfr_time_not_synchro()
837 {
852 {
838 static unsigned char synchroLost = 1;
853 static unsigned char synchroLost = 1;
839 int synchronizationBit;
854 int synchronizationBit;
840
855
841 // get the synchronization bit
856 // get the synchronization bit
842 synchronizationBit = (time_management_regs->coarse_time & 0x80000000) >> 31; // 1000 0000 0000 0000
857 synchronizationBit = (time_management_regs->coarse_time & 0x80000000) >> 31; // 1000 0000 0000 0000
843
858
844 switch (synchronizationBit)
859 switch (synchronizationBit)
845 {
860 {
846 case 0:
861 case 0:
847 if (synchroLost == 1)
862 if (synchroLost == 1)
848 {
863 {
849 synchroLost = 0;
864 synchroLost = 0;
850 }
865 }
851 break;
866 break;
852 case 1:
867 case 1:
853 if (synchroLost == 0 )
868 if (synchroLost == 0 )
854 {
869 {
855 synchroLost = 1;
870 synchroLost = 1;
856 increase_unsigned_char_counter(&housekeeping_packet.hk_lfr_time_not_synchro);
871 increase_unsigned_char_counter(&housekeeping_packet.hk_lfr_time_not_synchro);
857 update_hk_lfr_last_er_fields( RID_LE_LFR_TIME, CODE_NOT_SYNCHRO );
872 update_hk_lfr_last_er_fields( RID_LE_LFR_TIME, CODE_NOT_SYNCHRO );
858 }
873 }
859 break;
874 break;
860 default:
875 default:
861 PRINTF1("in hk_lfr_time_not_synchro *** unexpected value for synchronizationBit = %d\n", synchronizationBit);
876 PRINTF1("in hk_lfr_time_not_synchro *** unexpected value for synchronizationBit = %d\n", synchronizationBit);
862 break;
877 break;
863 }
878 }
864
879
865 }
880 }
866
881
867 void set_hk_lfr_ahb_correctable() // CRITICITY L
882 void set_hk_lfr_ahb_correctable() // CRITICITY L
868 {
883 {
869 /** This function builds the error counter hk_lfr_ahb_correctable using the statistics provided
884 /** This function builds the error counter hk_lfr_ahb_correctable using the statistics provided
870 * by the Cache Control Register (ASI 2, offset 0) and in the Register Protection Control Register (ASR16) on the
885 * by the Cache Control Register (ASI 2, offset 0) and in the Register Protection Control Register (ASR16) on the
871 * detected errors in the cache, in the integer unit and in the floating point unit.
886 * detected errors in the cache, in the integer unit and in the floating point unit.
872 *
887 *
873 * @param void
888 * @param void
874 *
889 *
875 * @return void
890 * @return void
876 *
891 *
877 * All errors are summed to set the value of the hk_lfr_ahb_correctable counter.
892 * All errors are summed to set the value of the hk_lfr_ahb_correctable counter.
878 *
893 *
879 */
894 */
880
895
881 unsigned int ahb_correctable;
896 unsigned int ahb_correctable;
882 unsigned int instructionErrorCounter;
897 unsigned int instructionErrorCounter;
883 unsigned int dataErrorCounter;
898 unsigned int dataErrorCounter;
884 unsigned int fprfErrorCounter;
899 unsigned int fprfErrorCounter;
885 unsigned int iurfErrorCounter;
900 unsigned int iurfErrorCounter;
886
901
887 CCR_getInstructionAndDataErrorCounters( &instructionErrorCounter, &dataErrorCounter);
902 CCR_getInstructionAndDataErrorCounters( &instructionErrorCounter, &dataErrorCounter);
888 ASR16_get_FPRF_IURF_ErrorCounters( &fprfErrorCounter, &iurfErrorCounter);
903 ASR16_get_FPRF_IURF_ErrorCounters( &fprfErrorCounter, &iurfErrorCounter);
889
904
890 ahb_correctable = instructionErrorCounter
905 ahb_correctable = instructionErrorCounter
891 + dataErrorCounter
906 + dataErrorCounter
892 + fprfErrorCounter
907 + fprfErrorCounter
893 + iurfErrorCounter
908 + iurfErrorCounter
894 + housekeeping_packet.hk_lfr_ahb_correctable;
909 + housekeeping_packet.hk_lfr_ahb_correctable;
895
910
896 housekeeping_packet.hk_lfr_ahb_correctable = (unsigned char) (ahb_correctable & 0xff); // [1111 1111]
911 housekeeping_packet.hk_lfr_ahb_correctable = (unsigned char) (ahb_correctable & 0xff); // [1111 1111]
897
912
898 }
913 }
@@ -1,1641 +1,1642
1 /** Functions and tasks related to TeleCommand handling.
1 /** Functions and tasks related to TeleCommand handling.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * A group of functions to handle TeleCommands:\n
6 * A group of functions to handle TeleCommands:\n
7 * action launching\n
7 * action launching\n
8 * TC parsing\n
8 * TC parsing\n
9 * ...
9 * ...
10 *
10 *
11 */
11 */
12
12
13 #include "tc_handler.h"
13 #include "tc_handler.h"
14 #include "math.h"
14 #include "math.h"
15
15
16 //***********
16 //***********
17 // RTEMS TASK
17 // RTEMS TASK
18
18
19 rtems_task actn_task( rtems_task_argument unused )
19 rtems_task actn_task( rtems_task_argument unused )
20 {
20 {
21 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
21 /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands.
22 *
22 *
23 * @param unused is the starting argument of the RTEMS task
23 * @param unused is the starting argument of the RTEMS task
24 *
24 *
25 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
25 * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending
26 * on the incoming TeleCommand.
26 * on the incoming TeleCommand.
27 *
27 *
28 */
28 */
29
29
30 int result;
30 int result;
31 rtems_status_code status; // RTEMS status code
31 rtems_status_code status; // RTEMS status code
32 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
32 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
33 size_t size; // size of the incoming TC packet
33 size_t size; // size of the incoming TC packet
34 unsigned char subtype; // subtype of the current TC packet
34 unsigned char subtype; // subtype of the current TC packet
35 unsigned char time[6];
35 unsigned char time[6];
36 rtems_id queue_rcv_id;
36 rtems_id queue_rcv_id;
37 rtems_id queue_snd_id;
37 rtems_id queue_snd_id;
38
38
39 status = get_message_queue_id_recv( &queue_rcv_id );
39 status = get_message_queue_id_recv( &queue_rcv_id );
40 if (status != RTEMS_SUCCESSFUL)
40 if (status != RTEMS_SUCCESSFUL)
41 {
41 {
42 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
42 PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status)
43 }
43 }
44
44
45 status = get_message_queue_id_send( &queue_snd_id );
45 status = get_message_queue_id_send( &queue_snd_id );
46 if (status != RTEMS_SUCCESSFUL)
46 if (status != RTEMS_SUCCESSFUL)
47 {
47 {
48 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
48 PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status)
49 }
49 }
50
50
51 result = LFR_SUCCESSFUL;
51 result = LFR_SUCCESSFUL;
52 subtype = 0; // subtype of the current TC packet
52 subtype = 0; // subtype of the current TC packet
53
53
54 BOOT_PRINTF("in ACTN *** \n");
54 BOOT_PRINTF("in ACTN *** \n");
55
55
56 while(1)
56 while(1)
57 {
57 {
58 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
58 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
59 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
59 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
60 getTime( time ); // set time to the current time
60 getTime( time ); // set time to the current time
61 if (status!=RTEMS_SUCCESSFUL)
61 if (status!=RTEMS_SUCCESSFUL)
62 {
62 {
63 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
63 PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
64 }
64 }
65 else
65 else
66 {
66 {
67 subtype = TC.serviceSubType;
67 subtype = TC.serviceSubType;
68 switch(subtype)
68 switch(subtype)
69 {
69 {
70 case TC_SUBTYPE_RESET:
70 case TC_SUBTYPE_RESET:
71 result = action_reset( &TC, queue_snd_id, time );
71 result = action_reset( &TC, queue_snd_id, time );
72 close_action( &TC, result, queue_snd_id );
72 close_action( &TC, result, queue_snd_id );
73 break;
73 break;
74 case TC_SUBTYPE_LOAD_COMM:
74 case TC_SUBTYPE_LOAD_COMM:
75 result = action_load_common_par( &TC );
75 result = action_load_common_par( &TC );
76 close_action( &TC, result, queue_snd_id );
76 close_action( &TC, result, queue_snd_id );
77 break;
77 break;
78 case TC_SUBTYPE_LOAD_NORM:
78 case TC_SUBTYPE_LOAD_NORM:
79 result = action_load_normal_par( &TC, queue_snd_id, time );
79 result = action_load_normal_par( &TC, queue_snd_id, time );
80 close_action( &TC, result, queue_snd_id );
80 close_action( &TC, result, queue_snd_id );
81 break;
81 break;
82 case TC_SUBTYPE_LOAD_BURST:
82 case TC_SUBTYPE_LOAD_BURST:
83 result = action_load_burst_par( &TC, queue_snd_id, time );
83 result = action_load_burst_par( &TC, queue_snd_id, time );
84 close_action( &TC, result, queue_snd_id );
84 close_action( &TC, result, queue_snd_id );
85 break;
85 break;
86 case TC_SUBTYPE_LOAD_SBM1:
86 case TC_SUBTYPE_LOAD_SBM1:
87 result = action_load_sbm1_par( &TC, queue_snd_id, time );
87 result = action_load_sbm1_par( &TC, queue_snd_id, time );
88 close_action( &TC, result, queue_snd_id );
88 close_action( &TC, result, queue_snd_id );
89 break;
89 break;
90 case TC_SUBTYPE_LOAD_SBM2:
90 case TC_SUBTYPE_LOAD_SBM2:
91 result = action_load_sbm2_par( &TC, queue_snd_id, time );
91 result = action_load_sbm2_par( &TC, queue_snd_id, time );
92 close_action( &TC, result, queue_snd_id );
92 close_action( &TC, result, queue_snd_id );
93 break;
93 break;
94 case TC_SUBTYPE_DUMP:
94 case TC_SUBTYPE_DUMP:
95 result = action_dump_par( &TC, queue_snd_id );
95 result = action_dump_par( &TC, queue_snd_id );
96 close_action( &TC, result, queue_snd_id );
96 close_action( &TC, result, queue_snd_id );
97 break;
97 break;
98 case TC_SUBTYPE_ENTER:
98 case TC_SUBTYPE_ENTER:
99 result = action_enter_mode( &TC, queue_snd_id );
99 result = action_enter_mode( &TC, queue_snd_id );
100 close_action( &TC, result, queue_snd_id );
100 close_action( &TC, result, queue_snd_id );
101 break;
101 break;
102 case TC_SUBTYPE_UPDT_INFO:
102 case TC_SUBTYPE_UPDT_INFO:
103 result = action_update_info( &TC, queue_snd_id );
103 result = action_update_info( &TC, queue_snd_id );
104 close_action( &TC, result, queue_snd_id );
104 close_action( &TC, result, queue_snd_id );
105 break;
105 break;
106 case TC_SUBTYPE_EN_CAL:
106 case TC_SUBTYPE_EN_CAL:
107 result = action_enable_calibration( &TC, queue_snd_id, time );
107 result = action_enable_calibration( &TC, queue_snd_id, time );
108 close_action( &TC, result, queue_snd_id );
108 close_action( &TC, result, queue_snd_id );
109 break;
109 break;
110 case TC_SUBTYPE_DIS_CAL:
110 case TC_SUBTYPE_DIS_CAL:
111 result = action_disable_calibration( &TC, queue_snd_id, time );
111 result = action_disable_calibration( &TC, queue_snd_id, time );
112 close_action( &TC, result, queue_snd_id );
112 close_action( &TC, result, queue_snd_id );
113 break;
113 break;
114 case TC_SUBTYPE_LOAD_K:
114 case TC_SUBTYPE_LOAD_K:
115 result = action_load_kcoefficients( &TC, queue_snd_id, time );
115 result = action_load_kcoefficients( &TC, queue_snd_id, time );
116 close_action( &TC, result, queue_snd_id );
116 close_action( &TC, result, queue_snd_id );
117 break;
117 break;
118 case TC_SUBTYPE_DUMP_K:
118 case TC_SUBTYPE_DUMP_K:
119 result = action_dump_kcoefficients( &TC, queue_snd_id, time );
119 result = action_dump_kcoefficients( &TC, queue_snd_id, time );
120 close_action( &TC, result, queue_snd_id );
120 close_action( &TC, result, queue_snd_id );
121 break;
121 break;
122 case TC_SUBTYPE_LOAD_FBINS:
122 case TC_SUBTYPE_LOAD_FBINS:
123 result = action_load_fbins_mask( &TC, queue_snd_id, time );
123 result = action_load_fbins_mask( &TC, queue_snd_id, time );
124 close_action( &TC, result, queue_snd_id );
124 close_action( &TC, result, queue_snd_id );
125 break;
125 break;
126 case TC_SUBTYPE_LOAD_FILTER_PAR:
126 case TC_SUBTYPE_LOAD_FILTER_PAR:
127 result = action_load_filter_par( &TC, queue_snd_id, time );
127 result = action_load_filter_par( &TC, queue_snd_id, time );
128 close_action( &TC, result, queue_snd_id );
128 close_action( &TC, result, queue_snd_id );
129 break;
129 break;
130 case TC_SUBTYPE_UPDT_TIME:
130 case TC_SUBTYPE_UPDT_TIME:
131 result = action_update_time( &TC );
131 result = action_update_time( &TC );
132 close_action( &TC, result, queue_snd_id );
132 close_action( &TC, result, queue_snd_id );
133 break;
133 break;
134 default:
134 default:
135 break;
135 break;
136 }
136 }
137 }
137 }
138 }
138 }
139 }
139 }
140
140
141 //***********
141 //***********
142 // TC ACTIONS
142 // TC ACTIONS
143
143
144 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
144 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
145 {
145 {
146 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
146 /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received.
147 *
147 *
148 * @param TC points to the TeleCommand packet that is being processed
148 * @param TC points to the TeleCommand packet that is being processed
149 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
149 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
150 *
150 *
151 */
151 */
152
152
153 PRINTF("this is the end!!!\n");
153 PRINTF("this is the end!!!\n");
154 exit(0);
154 exit(0);
155
155
156 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
156 send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time );
157
157
158 return LFR_DEFAULT;
158 return LFR_DEFAULT;
159 }
159 }
160
160
161 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
161 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
162 {
162 {
163 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
163 /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received.
164 *
164 *
165 * @param TC points to the TeleCommand packet that is being processed
165 * @param TC points to the TeleCommand packet that is being processed
166 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
166 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
167 *
167 *
168 */
168 */
169
169
170 rtems_status_code status;
170 rtems_status_code status;
171 unsigned char requestedMode;
171 unsigned char requestedMode;
172 unsigned int *transitionCoarseTime_ptr;
172 unsigned int *transitionCoarseTime_ptr;
173 unsigned int transitionCoarseTime;
173 unsigned int transitionCoarseTime;
174 unsigned char * bytePosPtr;
174 unsigned char * bytePosPtr;
175
175
176 bytePosPtr = (unsigned char *) &TC->packetID;
176 bytePosPtr = (unsigned char *) &TC->packetID;
177
177
178 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
178 requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ];
179 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
179 transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] );
180 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
180 transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff;
181
181
182 status = check_mode_value( requestedMode );
182 status = check_mode_value( requestedMode );
183
183
184 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
184 if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent
185 {
185 {
186 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
186 send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode );
187 }
187 }
188
188
189 else // the mode value is valid, check the transition
189 else // the mode value is valid, check the transition
190 {
190 {
191 status = check_mode_transition(requestedMode);
191 status = check_mode_transition(requestedMode);
192 if (status != LFR_SUCCESSFUL)
192 if (status != LFR_SUCCESSFUL)
193 {
193 {
194 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
194 PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n")
195 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
195 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
196 }
196 }
197 }
197 }
198
198
199 if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date
199 if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date
200 {
200 {
201 status = check_transition_date( transitionCoarseTime );
201 status = check_transition_date( transitionCoarseTime );
202 if (status != LFR_SUCCESSFUL)
202 if (status != LFR_SUCCESSFUL)
203 {
203 {
204 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n");
204 PRINTF("ERR *** in action_enter_mode *** check_transition_date\n");
205 send_tm_lfr_tc_exe_not_executable(TC, queue_id );
205 send_tm_lfr_tc_exe_not_executable(TC, queue_id );
206 }
206 }
207 }
207 }
208
208
209 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
209 if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode
210 {
210 {
211 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
211 PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode);
212
212
213 switch(requestedMode)
213 switch(requestedMode)
214 {
214 {
215 case LFR_MODE_STANDBY:
215 case LFR_MODE_STANDBY:
216 status = enter_mode_standby();
216 status = enter_mode_standby();
217 break;
217 break;
218 case LFR_MODE_NORMAL:
218 case LFR_MODE_NORMAL:
219 status = enter_mode_normal( transitionCoarseTime );
219 status = enter_mode_normal( transitionCoarseTime );
220 break;
220 break;
221 case LFR_MODE_BURST:
221 case LFR_MODE_BURST:
222 status = enter_mode_burst( transitionCoarseTime );
222 status = enter_mode_burst( transitionCoarseTime );
223 break;
223 break;
224 case LFR_MODE_SBM1:
224 case LFR_MODE_SBM1:
225 status = enter_mode_sbm1( transitionCoarseTime );
225 status = enter_mode_sbm1( transitionCoarseTime );
226 break;
226 break;
227 case LFR_MODE_SBM2:
227 case LFR_MODE_SBM2:
228 status = enter_mode_sbm2( transitionCoarseTime );
228 status = enter_mode_sbm2( transitionCoarseTime );
229 break;
229 break;
230 default:
230 default:
231 break;
231 break;
232 }
232 }
233
233
234 if (status != RTEMS_SUCCESSFUL)
234 if (status != RTEMS_SUCCESSFUL)
235 {
235 {
236 status = LFR_EXE_ERROR;
236 status = LFR_EXE_ERROR;
237 }
237 }
238 }
238 }
239
239
240 return status;
240 return status;
241 }
241 }
242
242
243 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
243 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
244 {
244 {
245 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
245 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
246 *
246 *
247 * @param TC points to the TeleCommand packet that is being processed
247 * @param TC points to the TeleCommand packet that is being processed
248 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
248 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
249 *
249 *
250 * @return LFR directive status code:
250 * @return LFR directive status code:
251 * - LFR_DEFAULT
251 * - LFR_DEFAULT
252 * - LFR_SUCCESSFUL
252 * - LFR_SUCCESSFUL
253 *
253 *
254 */
254 */
255
255
256 unsigned int val;
256 unsigned int val;
257 int result;
257 int result;
258 unsigned int status;
258 unsigned int status;
259 unsigned char mode;
259 unsigned char mode;
260 unsigned char * bytePosPtr;
260 unsigned char * bytePosPtr;
261
261
262 bytePosPtr = (unsigned char *) &TC->packetID;
262 bytePosPtr = (unsigned char *) &TC->packetID;
263
263
264 // check LFR mode
264 // check LFR mode
265 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
265 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1;
266 status = check_update_info_hk_lfr_mode( mode );
266 status = check_update_info_hk_lfr_mode( mode );
267 if (status == LFR_SUCCESSFUL) // check TDS mode
267 if (status == LFR_SUCCESSFUL) // check TDS mode
268 {
268 {
269 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
269 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4;
270 status = check_update_info_hk_tds_mode( mode );
270 status = check_update_info_hk_tds_mode( mode );
271 }
271 }
272 if (status == LFR_SUCCESSFUL) // check THR mode
272 if (status == LFR_SUCCESSFUL) // check THR mode
273 {
273 {
274 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
274 mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f);
275 status = check_update_info_hk_thr_mode( mode );
275 status = check_update_info_hk_thr_mode( mode );
276 }
276 }
277 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
277 if (status == LFR_SUCCESSFUL) // if the parameter check is successful
278 {
278 {
279 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
279 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
280 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
280 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
281 val++;
281 val++;
282 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
282 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
283 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
283 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
284 }
284 }
285
285
286 // pa_bia_status_info
286 // pa_bia_status_info
287 // => pa_bia_mode_mux_set 3 bits
287 // => pa_bia_mode_mux_set 3 bits
288 // => pa_bia_mode_hv_enabled 1 bit
288 // => pa_bia_mode_hv_enabled 1 bit
289 // => pa_bia_mode_bias1_enabled 1 bit
289 // => pa_bia_mode_bias1_enabled 1 bit
290 // => pa_bia_mode_bias2_enabled 1 bit
290 // => pa_bia_mode_bias2_enabled 1 bit
291 // => pa_bia_mode_bias3_enabled 1 bit
291 // => pa_bia_mode_bias3_enabled 1 bit
292 // => pa_bia_on_off (cp_dpu_bias_on_off)
292 // => pa_bia_on_off (cp_dpu_bias_on_off)
293 pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & 0xfe; // [1111 1110]
293 pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & 0xfe; // [1111 1110]
294 pa_bia_status_info = pa_bia_status_info
294 pa_bia_status_info = pa_bia_status_info
295 | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1);
295 | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1);
296
296
297 // REACTION_WHEELS_FREQUENCY, copy the incoming parameters in the local variable (to be copied in HK packets)
297 // REACTION_WHEELS_FREQUENCY, copy the incoming parameters in the local variable (to be copied in HK packets)
298 cp_rpw_sc_rw_f_flags = bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW_F_FLAGS ];
298 //cp_rpw_sc_rw_f_flags = bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW_F_FLAGS ];
299 getReactionWheelsFrequencies( TC );
299 getReactionWheelsFrequencies( TC );
300 set_hk_lfr_sc_rw_f_flags();
300 build_sy_lfr_rw_masks();
301 build_sy_lfr_rw_masks();
301
302
302 result = status;
303 result = status;
303
304
304 return result;
305 return result;
305 }
306 }
306
307
307 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
308 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
308 {
309 {
309 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
310 /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received.
310 *
311 *
311 * @param TC points to the TeleCommand packet that is being processed
312 * @param TC points to the TeleCommand packet that is being processed
312 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
313 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
313 *
314 *
314 */
315 */
315
316
316 int result;
317 int result;
317
318
318 result = LFR_DEFAULT;
319 result = LFR_DEFAULT;
319
320
320 setCalibration( true );
321 setCalibration( true );
321
322
322 result = LFR_SUCCESSFUL;
323 result = LFR_SUCCESSFUL;
323
324
324 return result;
325 return result;
325 }
326 }
326
327
327 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
328 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
328 {
329 {
329 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
330 /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received.
330 *
331 *
331 * @param TC points to the TeleCommand packet that is being processed
332 * @param TC points to the TeleCommand packet that is being processed
332 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
333 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
333 *
334 *
334 */
335 */
335
336
336 int result;
337 int result;
337
338
338 result = LFR_DEFAULT;
339 result = LFR_DEFAULT;
339
340
340 setCalibration( false );
341 setCalibration( false );
341
342
342 result = LFR_SUCCESSFUL;
343 result = LFR_SUCCESSFUL;
343
344
344 return result;
345 return result;
345 }
346 }
346
347
347 int action_update_time(ccsdsTelecommandPacket_t *TC)
348 int action_update_time(ccsdsTelecommandPacket_t *TC)
348 {
349 {
349 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
350 /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received.
350 *
351 *
351 * @param TC points to the TeleCommand packet that is being processed
352 * @param TC points to the TeleCommand packet that is being processed
352 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
353 * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver
353 *
354 *
354 * @return LFR_SUCCESSFUL
355 * @return LFR_SUCCESSFUL
355 *
356 *
356 */
357 */
357
358
358 unsigned int val;
359 unsigned int val;
359
360
360 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
361 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
361 + (TC->dataAndCRC[1] << 16)
362 + (TC->dataAndCRC[1] << 16)
362 + (TC->dataAndCRC[2] << 8)
363 + (TC->dataAndCRC[2] << 8)
363 + TC->dataAndCRC[3];
364 + TC->dataAndCRC[3];
364
365
365 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
366 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
366 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
367 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
367 val++;
368 val++;
368 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
369 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
369 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
370 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
370
371
371 oneTcLfrUpdateTimeReceived = 1;
372 oneTcLfrUpdateTimeReceived = 1;
372
373
373 return LFR_SUCCESSFUL;
374 return LFR_SUCCESSFUL;
374 }
375 }
375
376
376 //*******************
377 //*******************
377 // ENTERING THE MODES
378 // ENTERING THE MODES
378 int check_mode_value( unsigned char requestedMode )
379 int check_mode_value( unsigned char requestedMode )
379 {
380 {
380 int status;
381 int status;
381
382
382 if ( (requestedMode != LFR_MODE_STANDBY)
383 if ( (requestedMode != LFR_MODE_STANDBY)
383 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
384 && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST)
384 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
385 && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) )
385 {
386 {
386 status = LFR_DEFAULT;
387 status = LFR_DEFAULT;
387 }
388 }
388 else
389 else
389 {
390 {
390 status = LFR_SUCCESSFUL;
391 status = LFR_SUCCESSFUL;
391 }
392 }
392
393
393 return status;
394 return status;
394 }
395 }
395
396
396 int check_mode_transition( unsigned char requestedMode )
397 int check_mode_transition( unsigned char requestedMode )
397 {
398 {
398 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
399 /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE.
399 *
400 *
400 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
401 * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE
401 *
402 *
402 * @return LFR directive status codes:
403 * @return LFR directive status codes:
403 * - LFR_SUCCESSFUL - the transition is authorized
404 * - LFR_SUCCESSFUL - the transition is authorized
404 * - LFR_DEFAULT - the transition is not authorized
405 * - LFR_DEFAULT - the transition is not authorized
405 *
406 *
406 */
407 */
407
408
408 int status;
409 int status;
409
410
410 switch (requestedMode)
411 switch (requestedMode)
411 {
412 {
412 case LFR_MODE_STANDBY:
413 case LFR_MODE_STANDBY:
413 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
414 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
414 status = LFR_DEFAULT;
415 status = LFR_DEFAULT;
415 }
416 }
416 else
417 else
417 {
418 {
418 status = LFR_SUCCESSFUL;
419 status = LFR_SUCCESSFUL;
419 }
420 }
420 break;
421 break;
421 case LFR_MODE_NORMAL:
422 case LFR_MODE_NORMAL:
422 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
423 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
423 status = LFR_DEFAULT;
424 status = LFR_DEFAULT;
424 }
425 }
425 else {
426 else {
426 status = LFR_SUCCESSFUL;
427 status = LFR_SUCCESSFUL;
427 }
428 }
428 break;
429 break;
429 case LFR_MODE_BURST:
430 case LFR_MODE_BURST:
430 if ( lfrCurrentMode == LFR_MODE_BURST ) {
431 if ( lfrCurrentMode == LFR_MODE_BURST ) {
431 status = LFR_DEFAULT;
432 status = LFR_DEFAULT;
432 }
433 }
433 else {
434 else {
434 status = LFR_SUCCESSFUL;
435 status = LFR_SUCCESSFUL;
435 }
436 }
436 break;
437 break;
437 case LFR_MODE_SBM1:
438 case LFR_MODE_SBM1:
438 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
439 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
439 status = LFR_DEFAULT;
440 status = LFR_DEFAULT;
440 }
441 }
441 else {
442 else {
442 status = LFR_SUCCESSFUL;
443 status = LFR_SUCCESSFUL;
443 }
444 }
444 break;
445 break;
445 case LFR_MODE_SBM2:
446 case LFR_MODE_SBM2:
446 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
447 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
447 status = LFR_DEFAULT;
448 status = LFR_DEFAULT;
448 }
449 }
449 else {
450 else {
450 status = LFR_SUCCESSFUL;
451 status = LFR_SUCCESSFUL;
451 }
452 }
452 break;
453 break;
453 default:
454 default:
454 status = LFR_DEFAULT;
455 status = LFR_DEFAULT;
455 break;
456 break;
456 }
457 }
457
458
458 return status;
459 return status;
459 }
460 }
460
461
461 void update_last_valid_transition_date( unsigned int transitionCoarseTime )
462 void update_last_valid_transition_date( unsigned int transitionCoarseTime )
462 {
463 {
463 if (transitionCoarseTime == 0)
464 if (transitionCoarseTime == 0)
464 {
465 {
465 lastValidEnterModeTime = time_management_regs->coarse_time + 1;
466 lastValidEnterModeTime = time_management_regs->coarse_time + 1;
466 PRINTF1("lastValidEnterModeTime = 0x%x (transitionCoarseTime = 0 => coarse_time+1)\n", lastValidEnterModeTime);
467 PRINTF1("lastValidEnterModeTime = 0x%x (transitionCoarseTime = 0 => coarse_time+1)\n", lastValidEnterModeTime);
467 }
468 }
468 else
469 else
469 {
470 {
470 lastValidEnterModeTime = transitionCoarseTime;
471 lastValidEnterModeTime = transitionCoarseTime;
471 PRINTF1("lastValidEnterModeTime = 0x%x\n", transitionCoarseTime);
472 PRINTF1("lastValidEnterModeTime = 0x%x\n", transitionCoarseTime);
472 }
473 }
473 }
474 }
474
475
475 int check_transition_date( unsigned int transitionCoarseTime )
476 int check_transition_date( unsigned int transitionCoarseTime )
476 {
477 {
477 int status;
478 int status;
478 unsigned int localCoarseTime;
479 unsigned int localCoarseTime;
479 unsigned int deltaCoarseTime;
480 unsigned int deltaCoarseTime;
480
481
481 status = LFR_SUCCESSFUL;
482 status = LFR_SUCCESSFUL;
482
483
483 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
484 if (transitionCoarseTime == 0) // transition time = 0 means an instant transition
484 {
485 {
485 status = LFR_SUCCESSFUL;
486 status = LFR_SUCCESSFUL;
486 }
487 }
487 else
488 else
488 {
489 {
489 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
490 localCoarseTime = time_management_regs->coarse_time & 0x7fffffff;
490
491
491 PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime);
492 PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime);
492
493
493 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
494 if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322
494 {
495 {
495 status = LFR_DEFAULT;
496 status = LFR_DEFAULT;
496 PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n");
497 PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n");
497 }
498 }
498
499
499 if (status == LFR_SUCCESSFUL)
500 if (status == LFR_SUCCESSFUL)
500 {
501 {
501 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
502 deltaCoarseTime = transitionCoarseTime - localCoarseTime;
502 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
503 if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323
503 {
504 {
504 status = LFR_DEFAULT;
505 status = LFR_DEFAULT;
505 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
506 PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime)
506 }
507 }
507 }
508 }
508 }
509 }
509
510
510 return status;
511 return status;
511 }
512 }
512
513
513 int restart_asm_activities( unsigned char lfrRequestedMode )
514 int restart_asm_activities( unsigned char lfrRequestedMode )
514 {
515 {
515 rtems_status_code status;
516 rtems_status_code status;
516
517
517 status = stop_spectral_matrices();
518 status = stop_spectral_matrices();
518
519
519 thisIsAnASMRestart = 1;
520 thisIsAnASMRestart = 1;
520
521
521 status = restart_asm_tasks( lfrRequestedMode );
522 status = restart_asm_tasks( lfrRequestedMode );
522
523
523 launch_spectral_matrix();
524 launch_spectral_matrix();
524
525
525 return status;
526 return status;
526 }
527 }
527
528
528 int stop_spectral_matrices( void )
529 int stop_spectral_matrices( void )
529 {
530 {
530 /** This function stops and restarts the current mode average spectral matrices activities.
531 /** This function stops and restarts the current mode average spectral matrices activities.
531 *
532 *
532 * @return RTEMS directive status codes:
533 * @return RTEMS directive status codes:
533 * - RTEMS_SUCCESSFUL - task restarted successfully
534 * - RTEMS_SUCCESSFUL - task restarted successfully
534 * - RTEMS_INVALID_ID - task id invalid
535 * - RTEMS_INVALID_ID - task id invalid
535 * - RTEMS_ALREADY_SUSPENDED - task already suspended
536 * - RTEMS_ALREADY_SUSPENDED - task already suspended
536 *
537 *
537 */
538 */
538
539
539 rtems_status_code status;
540 rtems_status_code status;
540
541
541 status = RTEMS_SUCCESSFUL;
542 status = RTEMS_SUCCESSFUL;
542
543
543 // (1) mask interruptions
544 // (1) mask interruptions
544 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt
545 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt
545
546
546 // (2) reset spectral matrices registers
547 // (2) reset spectral matrices registers
547 set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices
548 set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices
548 reset_sm_status();
549 reset_sm_status();
549
550
550 // (3) clear interruptions
551 // (3) clear interruptions
551 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
552 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
552
553
553 // suspend several tasks
554 // suspend several tasks
554 if (lfrCurrentMode != LFR_MODE_STANDBY) {
555 if (lfrCurrentMode != LFR_MODE_STANDBY) {
555 status = suspend_asm_tasks();
556 status = suspend_asm_tasks();
556 }
557 }
557
558
558 if (status != RTEMS_SUCCESSFUL)
559 if (status != RTEMS_SUCCESSFUL)
559 {
560 {
560 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
561 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
561 }
562 }
562
563
563 return status;
564 return status;
564 }
565 }
565
566
566 int stop_current_mode( void )
567 int stop_current_mode( void )
567 {
568 {
568 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
569 /** This function stops the current mode by masking interrupt lines and suspending science tasks.
569 *
570 *
570 * @return RTEMS directive status codes:
571 * @return RTEMS directive status codes:
571 * - RTEMS_SUCCESSFUL - task restarted successfully
572 * - RTEMS_SUCCESSFUL - task restarted successfully
572 * - RTEMS_INVALID_ID - task id invalid
573 * - RTEMS_INVALID_ID - task id invalid
573 * - RTEMS_ALREADY_SUSPENDED - task already suspended
574 * - RTEMS_ALREADY_SUSPENDED - task already suspended
574 *
575 *
575 */
576 */
576
577
577 rtems_status_code status;
578 rtems_status_code status;
578
579
579 status = RTEMS_SUCCESSFUL;
580 status = RTEMS_SUCCESSFUL;
580
581
581 // (1) mask interruptions
582 // (1) mask interruptions
582 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
583 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
583 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
584 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
584
585
585 // (2) reset waveform picker registers
586 // (2) reset waveform picker registers
586 reset_wfp_burst_enable(); // reset burst and enable bits
587 reset_wfp_burst_enable(); // reset burst and enable bits
587 reset_wfp_status(); // reset all the status bits
588 reset_wfp_status(); // reset all the status bits
588
589
589 // (3) reset spectral matrices registers
590 // (3) reset spectral matrices registers
590 set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices
591 set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices
591 reset_sm_status();
592 reset_sm_status();
592
593
593 // reset lfr VHDL module
594 // reset lfr VHDL module
594 reset_lfr();
595 reset_lfr();
595
596
596 reset_extractSWF(); // reset the extractSWF flag to false
597 reset_extractSWF(); // reset the extractSWF flag to false
597
598
598 // (4) clear interruptions
599 // (4) clear interruptions
599 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
600 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
600 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
601 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
601
602
602 // suspend several tasks
603 // suspend several tasks
603 if (lfrCurrentMode != LFR_MODE_STANDBY) {
604 if (lfrCurrentMode != LFR_MODE_STANDBY) {
604 status = suspend_science_tasks();
605 status = suspend_science_tasks();
605 }
606 }
606
607
607 if (status != RTEMS_SUCCESSFUL)
608 if (status != RTEMS_SUCCESSFUL)
608 {
609 {
609 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
610 PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status)
610 }
611 }
611
612
612 return status;
613 return status;
613 }
614 }
614
615
615 int enter_mode_standby( void )
616 int enter_mode_standby( void )
616 {
617 {
617 /** This function is used to put LFR in the STANDBY mode.
618 /** This function is used to put LFR in the STANDBY mode.
618 *
619 *
619 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
620 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
620 *
621 *
621 * @return RTEMS directive status codes:
622 * @return RTEMS directive status codes:
622 * - RTEMS_SUCCESSFUL - task restarted successfully
623 * - RTEMS_SUCCESSFUL - task restarted successfully
623 * - RTEMS_INVALID_ID - task id invalid
624 * - RTEMS_INVALID_ID - task id invalid
624 * - RTEMS_INCORRECT_STATE - task never started
625 * - RTEMS_INCORRECT_STATE - task never started
625 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
626 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
626 *
627 *
627 * The STANDBY mode does not depends on a specific transition date, the effect of the TC_LFR_ENTER_MODE
628 * The STANDBY mode does not depends on a specific transition date, the effect of the TC_LFR_ENTER_MODE
628 * is immediate.
629 * is immediate.
629 *
630 *
630 */
631 */
631
632
632 int status;
633 int status;
633
634
634 status = stop_current_mode(); // STOP THE CURRENT MODE
635 status = stop_current_mode(); // STOP THE CURRENT MODE
635
636
636 #ifdef PRINT_TASK_STATISTICS
637 #ifdef PRINT_TASK_STATISTICS
637 rtems_cpu_usage_report();
638 rtems_cpu_usage_report();
638 #endif
639 #endif
639
640
640 #ifdef PRINT_STACK_REPORT
641 #ifdef PRINT_STACK_REPORT
641 PRINTF("stack report selected\n")
642 PRINTF("stack report selected\n")
642 rtems_stack_checker_report_usage();
643 rtems_stack_checker_report_usage();
643 #endif
644 #endif
644
645
645 return status;
646 return status;
646 }
647 }
647
648
648 int enter_mode_normal( unsigned int transitionCoarseTime )
649 int enter_mode_normal( unsigned int transitionCoarseTime )
649 {
650 {
650 /** This function is used to start the NORMAL mode.
651 /** This function is used to start the NORMAL mode.
651 *
652 *
652 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
653 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
653 *
654 *
654 * @return RTEMS directive status codes:
655 * @return RTEMS directive status codes:
655 * - RTEMS_SUCCESSFUL - task restarted successfully
656 * - RTEMS_SUCCESSFUL - task restarted successfully
656 * - RTEMS_INVALID_ID - task id invalid
657 * - RTEMS_INVALID_ID - task id invalid
657 * - RTEMS_INCORRECT_STATE - task never started
658 * - RTEMS_INCORRECT_STATE - task never started
658 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
659 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
659 *
660 *
660 * The way the NORMAL mode is started depends on the LFR current mode. If LFR is in SBM1 or SBM2,
661 * The way the NORMAL mode is started depends on the LFR current mode. If LFR is in SBM1 or SBM2,
661 * the snapshots are not restarted, only ASM, BP and CWF data generation are affected.
662 * the snapshots are not restarted, only ASM, BP and CWF data generation are affected.
662 *
663 *
663 */
664 */
664
665
665 int status;
666 int status;
666
667
667 #ifdef PRINT_TASK_STATISTICS
668 #ifdef PRINT_TASK_STATISTICS
668 rtems_cpu_usage_reset();
669 rtems_cpu_usage_reset();
669 #endif
670 #endif
670
671
671 status = RTEMS_UNSATISFIED;
672 status = RTEMS_UNSATISFIED;
672
673
673 switch( lfrCurrentMode )
674 switch( lfrCurrentMode )
674 {
675 {
675 case LFR_MODE_STANDBY:
676 case LFR_MODE_STANDBY:
676 status = restart_science_tasks( LFR_MODE_NORMAL ); // restart science tasks
677 status = restart_science_tasks( LFR_MODE_NORMAL ); // restart science tasks
677 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
678 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
678 {
679 {
679 launch_spectral_matrix( );
680 launch_spectral_matrix( );
680 launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime );
681 launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime );
681 }
682 }
682 break;
683 break;
683 case LFR_MODE_BURST:
684 case LFR_MODE_BURST:
684 status = stop_current_mode(); // stop the current mode
685 status = stop_current_mode(); // stop the current mode
685 status = restart_science_tasks( LFR_MODE_NORMAL ); // restart the science tasks
686 status = restart_science_tasks( LFR_MODE_NORMAL ); // restart the science tasks
686 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
687 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
687 {
688 {
688 launch_spectral_matrix( );
689 launch_spectral_matrix( );
689 launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime );
690 launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime );
690 }
691 }
691 break;
692 break;
692 case LFR_MODE_SBM1:
693 case LFR_MODE_SBM1:
693 status = restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters
694 status = restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters
694 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
695 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
695 update_last_valid_transition_date( transitionCoarseTime );
696 update_last_valid_transition_date( transitionCoarseTime );
696 break;
697 break;
697 case LFR_MODE_SBM2:
698 case LFR_MODE_SBM2:
698 status = restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters
699 status = restart_asm_activities( LFR_MODE_NORMAL ); // this is necessary to restart ASM tasks to update the parameters
699 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
700 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
700 update_last_valid_transition_date( transitionCoarseTime );
701 update_last_valid_transition_date( transitionCoarseTime );
701 break;
702 break;
702 default:
703 default:
703 break;
704 break;
704 }
705 }
705
706
706 if (status != RTEMS_SUCCESSFUL)
707 if (status != RTEMS_SUCCESSFUL)
707 {
708 {
708 PRINTF1("ERR *** in enter_mode_normal *** status = %d\n", status)
709 PRINTF1("ERR *** in enter_mode_normal *** status = %d\n", status)
709 status = RTEMS_UNSATISFIED;
710 status = RTEMS_UNSATISFIED;
710 }
711 }
711
712
712 return status;
713 return status;
713 }
714 }
714
715
715 int enter_mode_burst( unsigned int transitionCoarseTime )
716 int enter_mode_burst( unsigned int transitionCoarseTime )
716 {
717 {
717 /** This function is used to start the BURST mode.
718 /** This function is used to start the BURST mode.
718 *
719 *
719 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
720 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
720 *
721 *
721 * @return RTEMS directive status codes:
722 * @return RTEMS directive status codes:
722 * - RTEMS_SUCCESSFUL - task restarted successfully
723 * - RTEMS_SUCCESSFUL - task restarted successfully
723 * - RTEMS_INVALID_ID - task id invalid
724 * - RTEMS_INVALID_ID - task id invalid
724 * - RTEMS_INCORRECT_STATE - task never started
725 * - RTEMS_INCORRECT_STATE - task never started
725 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
726 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
726 *
727 *
727 * The way the BURST mode is started does not depend on the LFR current mode.
728 * The way the BURST mode is started does not depend on the LFR current mode.
728 *
729 *
729 */
730 */
730
731
731
732
732 int status;
733 int status;
733
734
734 #ifdef PRINT_TASK_STATISTICS
735 #ifdef PRINT_TASK_STATISTICS
735 rtems_cpu_usage_reset();
736 rtems_cpu_usage_reset();
736 #endif
737 #endif
737
738
738 status = stop_current_mode(); // stop the current mode
739 status = stop_current_mode(); // stop the current mode
739 status = restart_science_tasks( LFR_MODE_BURST ); // restart the science tasks
740 status = restart_science_tasks( LFR_MODE_BURST ); // restart the science tasks
740 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
741 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
741 {
742 {
742 launch_spectral_matrix( );
743 launch_spectral_matrix( );
743 launch_waveform_picker( LFR_MODE_BURST, transitionCoarseTime );
744 launch_waveform_picker( LFR_MODE_BURST, transitionCoarseTime );
744 }
745 }
745
746
746 if (status != RTEMS_SUCCESSFUL)
747 if (status != RTEMS_SUCCESSFUL)
747 {
748 {
748 PRINTF1("ERR *** in enter_mode_burst *** status = %d\n", status)
749 PRINTF1("ERR *** in enter_mode_burst *** status = %d\n", status)
749 status = RTEMS_UNSATISFIED;
750 status = RTEMS_UNSATISFIED;
750 }
751 }
751
752
752 return status;
753 return status;
753 }
754 }
754
755
755 int enter_mode_sbm1( unsigned int transitionCoarseTime )
756 int enter_mode_sbm1( unsigned int transitionCoarseTime )
756 {
757 {
757 /** This function is used to start the SBM1 mode.
758 /** This function is used to start the SBM1 mode.
758 *
759 *
759 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
760 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
760 *
761 *
761 * @return RTEMS directive status codes:
762 * @return RTEMS directive status codes:
762 * - RTEMS_SUCCESSFUL - task restarted successfully
763 * - RTEMS_SUCCESSFUL - task restarted successfully
763 * - RTEMS_INVALID_ID - task id invalid
764 * - RTEMS_INVALID_ID - task id invalid
764 * - RTEMS_INCORRECT_STATE - task never started
765 * - RTEMS_INCORRECT_STATE - task never started
765 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
766 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
766 *
767 *
767 * The way the SBM1 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM2,
768 * The way the SBM1 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM2,
768 * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other
769 * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other
769 * cases, the acquisition is completely restarted.
770 * cases, the acquisition is completely restarted.
770 *
771 *
771 */
772 */
772
773
773 int status;
774 int status;
774
775
775 #ifdef PRINT_TASK_STATISTICS
776 #ifdef PRINT_TASK_STATISTICS
776 rtems_cpu_usage_reset();
777 rtems_cpu_usage_reset();
777 #endif
778 #endif
778
779
779 status = RTEMS_UNSATISFIED;
780 status = RTEMS_UNSATISFIED;
780
781
781 switch( lfrCurrentMode )
782 switch( lfrCurrentMode )
782 {
783 {
783 case LFR_MODE_STANDBY:
784 case LFR_MODE_STANDBY:
784 status = restart_science_tasks( LFR_MODE_SBM1 ); // restart science tasks
785 status = restart_science_tasks( LFR_MODE_SBM1 ); // restart science tasks
785 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
786 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
786 {
787 {
787 launch_spectral_matrix( );
788 launch_spectral_matrix( );
788 launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime );
789 launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime );
789 }
790 }
790 break;
791 break;
791 case LFR_MODE_NORMAL: // lfrCurrentMode will be updated after the execution of close_action
792 case LFR_MODE_NORMAL: // lfrCurrentMode will be updated after the execution of close_action
792 status = restart_asm_activities( LFR_MODE_SBM1 );
793 status = restart_asm_activities( LFR_MODE_SBM1 );
793 status = LFR_SUCCESSFUL;
794 status = LFR_SUCCESSFUL;
794 update_last_valid_transition_date( transitionCoarseTime );
795 update_last_valid_transition_date( transitionCoarseTime );
795 break;
796 break;
796 case LFR_MODE_BURST:
797 case LFR_MODE_BURST:
797 status = stop_current_mode(); // stop the current mode
798 status = stop_current_mode(); // stop the current mode
798 status = restart_science_tasks( LFR_MODE_SBM1 ); // restart the science tasks
799 status = restart_science_tasks( LFR_MODE_SBM1 ); // restart the science tasks
799 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
800 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
800 {
801 {
801 launch_spectral_matrix( );
802 launch_spectral_matrix( );
802 launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime );
803 launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime );
803 }
804 }
804 break;
805 break;
805 case LFR_MODE_SBM2:
806 case LFR_MODE_SBM2:
806 status = restart_asm_activities( LFR_MODE_SBM1 );
807 status = restart_asm_activities( LFR_MODE_SBM1 );
807 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
808 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
808 update_last_valid_transition_date( transitionCoarseTime );
809 update_last_valid_transition_date( transitionCoarseTime );
809 break;
810 break;
810 default:
811 default:
811 break;
812 break;
812 }
813 }
813
814
814 if (status != RTEMS_SUCCESSFUL)
815 if (status != RTEMS_SUCCESSFUL)
815 {
816 {
816 PRINTF1("ERR *** in enter_mode_sbm1 *** status = %d\n", status);
817 PRINTF1("ERR *** in enter_mode_sbm1 *** status = %d\n", status);
817 status = RTEMS_UNSATISFIED;
818 status = RTEMS_UNSATISFIED;
818 }
819 }
819
820
820 return status;
821 return status;
821 }
822 }
822
823
823 int enter_mode_sbm2( unsigned int transitionCoarseTime )
824 int enter_mode_sbm2( unsigned int transitionCoarseTime )
824 {
825 {
825 /** This function is used to start the SBM2 mode.
826 /** This function is used to start the SBM2 mode.
826 *
827 *
827 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
828 * @param transitionCoarseTime is the requested transition time contained in the TC_LFR_ENTER_MODE
828 *
829 *
829 * @return RTEMS directive status codes:
830 * @return RTEMS directive status codes:
830 * - RTEMS_SUCCESSFUL - task restarted successfully
831 * - RTEMS_SUCCESSFUL - task restarted successfully
831 * - RTEMS_INVALID_ID - task id invalid
832 * - RTEMS_INVALID_ID - task id invalid
832 * - RTEMS_INCORRECT_STATE - task never started
833 * - RTEMS_INCORRECT_STATE - task never started
833 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
834 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
834 *
835 *
835 * The way the SBM2 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM1,
836 * The way the SBM2 mode is started depends on the LFR current mode. If LFR is in NORMAL or SBM1,
836 * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other
837 * the snapshots are not restarted, only ASM, BP and CWF data generation are affected. In other
837 * cases, the acquisition is completely restarted.
838 * cases, the acquisition is completely restarted.
838 *
839 *
839 */
840 */
840
841
841 int status;
842 int status;
842
843
843 #ifdef PRINT_TASK_STATISTICS
844 #ifdef PRINT_TASK_STATISTICS
844 rtems_cpu_usage_reset();
845 rtems_cpu_usage_reset();
845 #endif
846 #endif
846
847
847 status = RTEMS_UNSATISFIED;
848 status = RTEMS_UNSATISFIED;
848
849
849 switch( lfrCurrentMode )
850 switch( lfrCurrentMode )
850 {
851 {
851 case LFR_MODE_STANDBY:
852 case LFR_MODE_STANDBY:
852 status = restart_science_tasks( LFR_MODE_SBM2 ); // restart science tasks
853 status = restart_science_tasks( LFR_MODE_SBM2 ); // restart science tasks
853 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
854 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
854 {
855 {
855 launch_spectral_matrix( );
856 launch_spectral_matrix( );
856 launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime );
857 launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime );
857 }
858 }
858 break;
859 break;
859 case LFR_MODE_NORMAL:
860 case LFR_MODE_NORMAL:
860 status = restart_asm_activities( LFR_MODE_SBM2 );
861 status = restart_asm_activities( LFR_MODE_SBM2 );
861 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
862 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
862 update_last_valid_transition_date( transitionCoarseTime );
863 update_last_valid_transition_date( transitionCoarseTime );
863 break;
864 break;
864 case LFR_MODE_BURST:
865 case LFR_MODE_BURST:
865 status = stop_current_mode(); // stop the current mode
866 status = stop_current_mode(); // stop the current mode
866 status = restart_science_tasks( LFR_MODE_SBM2 ); // restart the science tasks
867 status = restart_science_tasks( LFR_MODE_SBM2 ); // restart the science tasks
867 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
868 if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules
868 {
869 {
869 launch_spectral_matrix( );
870 launch_spectral_matrix( );
870 launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime );
871 launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime );
871 }
872 }
872 break;
873 break;
873 case LFR_MODE_SBM1:
874 case LFR_MODE_SBM1:
874 status = restart_asm_activities( LFR_MODE_SBM2 );
875 status = restart_asm_activities( LFR_MODE_SBM2 );
875 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
876 status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action
876 update_last_valid_transition_date( transitionCoarseTime );
877 update_last_valid_transition_date( transitionCoarseTime );
877 break;
878 break;
878 default:
879 default:
879 break;
880 break;
880 }
881 }
881
882
882 if (status != RTEMS_SUCCESSFUL)
883 if (status != RTEMS_SUCCESSFUL)
883 {
884 {
884 PRINTF1("ERR *** in enter_mode_sbm2 *** status = %d\n", status)
885 PRINTF1("ERR *** in enter_mode_sbm2 *** status = %d\n", status)
885 status = RTEMS_UNSATISFIED;
886 status = RTEMS_UNSATISFIED;
886 }
887 }
887
888
888 return status;
889 return status;
889 }
890 }
890
891
891 int restart_science_tasks( unsigned char lfrRequestedMode )
892 int restart_science_tasks( unsigned char lfrRequestedMode )
892 {
893 {
893 /** This function is used to restart all science tasks.
894 /** This function is used to restart all science tasks.
894 *
895 *
895 * @return RTEMS directive status codes:
896 * @return RTEMS directive status codes:
896 * - RTEMS_SUCCESSFUL - task restarted successfully
897 * - RTEMS_SUCCESSFUL - task restarted successfully
897 * - RTEMS_INVALID_ID - task id invalid
898 * - RTEMS_INVALID_ID - task id invalid
898 * - RTEMS_INCORRECT_STATE - task never started
899 * - RTEMS_INCORRECT_STATE - task never started
899 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
900 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
900 *
901 *
901 * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1
902 * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1
902 *
903 *
903 */
904 */
904
905
905 rtems_status_code status[10];
906 rtems_status_code status[10];
906 rtems_status_code ret;
907 rtems_status_code ret;
907
908
908 ret = RTEMS_SUCCESSFUL;
909 ret = RTEMS_SUCCESSFUL;
909
910
910 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
911 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
911 if (status[0] != RTEMS_SUCCESSFUL)
912 if (status[0] != RTEMS_SUCCESSFUL)
912 {
913 {
913 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
914 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
914 }
915 }
915
916
916 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
917 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
917 if (status[1] != RTEMS_SUCCESSFUL)
918 if (status[1] != RTEMS_SUCCESSFUL)
918 {
919 {
919 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
920 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
920 }
921 }
921
922
922 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
923 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
923 if (status[2] != RTEMS_SUCCESSFUL)
924 if (status[2] != RTEMS_SUCCESSFUL)
924 {
925 {
925 PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2])
926 PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2])
926 }
927 }
927
928
928 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
929 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
929 if (status[3] != RTEMS_SUCCESSFUL)
930 if (status[3] != RTEMS_SUCCESSFUL)
930 {
931 {
931 PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3])
932 PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3])
932 }
933 }
933
934
934 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
935 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
935 if (status[4] != RTEMS_SUCCESSFUL)
936 if (status[4] != RTEMS_SUCCESSFUL)
936 {
937 {
937 PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4])
938 PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4])
938 }
939 }
939
940
940 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
941 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
941 if (status[5] != RTEMS_SUCCESSFUL)
942 if (status[5] != RTEMS_SUCCESSFUL)
942 {
943 {
943 PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5])
944 PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5])
944 }
945 }
945
946
946 status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
947 status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
947 if (status[6] != RTEMS_SUCCESSFUL)
948 if (status[6] != RTEMS_SUCCESSFUL)
948 {
949 {
949 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6])
950 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6])
950 }
951 }
951
952
952 status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
953 status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
953 if (status[7] != RTEMS_SUCCESSFUL)
954 if (status[7] != RTEMS_SUCCESSFUL)
954 {
955 {
955 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7])
956 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7])
956 }
957 }
957
958
958 status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
959 status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
959 if (status[8] != RTEMS_SUCCESSFUL)
960 if (status[8] != RTEMS_SUCCESSFUL)
960 {
961 {
961 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8])
962 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8])
962 }
963 }
963
964
964 status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
965 status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
965 if (status[9] != RTEMS_SUCCESSFUL)
966 if (status[9] != RTEMS_SUCCESSFUL)
966 {
967 {
967 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9])
968 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9])
968 }
969 }
969
970
970 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
971 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
971 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
972 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
972 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ||
973 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ||
973 (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) ||
974 (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) ||
974 (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) )
975 (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) )
975 {
976 {
976 ret = RTEMS_UNSATISFIED;
977 ret = RTEMS_UNSATISFIED;
977 }
978 }
978
979
979 return ret;
980 return ret;
980 }
981 }
981
982
982 int restart_asm_tasks( unsigned char lfrRequestedMode )
983 int restart_asm_tasks( unsigned char lfrRequestedMode )
983 {
984 {
984 /** This function is used to restart average spectral matrices tasks.
985 /** This function is used to restart average spectral matrices tasks.
985 *
986 *
986 * @return RTEMS directive status codes:
987 * @return RTEMS directive status codes:
987 * - RTEMS_SUCCESSFUL - task restarted successfully
988 * - RTEMS_SUCCESSFUL - task restarted successfully
988 * - RTEMS_INVALID_ID - task id invalid
989 * - RTEMS_INVALID_ID - task id invalid
989 * - RTEMS_INCORRECT_STATE - task never started
990 * - RTEMS_INCORRECT_STATE - task never started
990 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
991 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task
991 *
992 *
992 * ASM tasks are AVF0, PRC0, AVF1, PRC1, AVF2 and PRC2
993 * ASM tasks are AVF0, PRC0, AVF1, PRC1, AVF2 and PRC2
993 *
994 *
994 */
995 */
995
996
996 rtems_status_code status[6];
997 rtems_status_code status[6];
997 rtems_status_code ret;
998 rtems_status_code ret;
998
999
999 ret = RTEMS_SUCCESSFUL;
1000 ret = RTEMS_SUCCESSFUL;
1000
1001
1001 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
1002 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode );
1002 if (status[0] != RTEMS_SUCCESSFUL)
1003 if (status[0] != RTEMS_SUCCESSFUL)
1003 {
1004 {
1004 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
1005 PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0])
1005 }
1006 }
1006
1007
1007 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
1008 status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode );
1008 if (status[1] != RTEMS_SUCCESSFUL)
1009 if (status[1] != RTEMS_SUCCESSFUL)
1009 {
1010 {
1010 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
1011 PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1])
1011 }
1012 }
1012
1013
1013 status[2] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
1014 status[2] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode );
1014 if (status[2] != RTEMS_SUCCESSFUL)
1015 if (status[2] != RTEMS_SUCCESSFUL)
1015 {
1016 {
1016 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[2])
1017 PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[2])
1017 }
1018 }
1018
1019
1019 status[3] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
1020 status[3] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode );
1020 if (status[3] != RTEMS_SUCCESSFUL)
1021 if (status[3] != RTEMS_SUCCESSFUL)
1021 {
1022 {
1022 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[3])
1023 PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[3])
1023 }
1024 }
1024
1025
1025 status[4] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
1026 status[4] = rtems_task_restart( Task_id[TASKID_AVF2], 1 );
1026 if (status[4] != RTEMS_SUCCESSFUL)
1027 if (status[4] != RTEMS_SUCCESSFUL)
1027 {
1028 {
1028 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[4])
1029 PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[4])
1029 }
1030 }
1030
1031
1031 status[5] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
1032 status[5] = rtems_task_restart( Task_id[TASKID_PRC2], 1 );
1032 if (status[5] != RTEMS_SUCCESSFUL)
1033 if (status[5] != RTEMS_SUCCESSFUL)
1033 {
1034 {
1034 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[5])
1035 PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[5])
1035 }
1036 }
1036
1037
1037 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
1038 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) ||
1038 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
1039 (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) ||
1039 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
1040 (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
1040 {
1041 {
1041 ret = RTEMS_UNSATISFIED;
1042 ret = RTEMS_UNSATISFIED;
1042 }
1043 }
1043
1044
1044 return ret;
1045 return ret;
1045 }
1046 }
1046
1047
1047 int suspend_science_tasks( void )
1048 int suspend_science_tasks( void )
1048 {
1049 {
1049 /** This function suspends the science tasks.
1050 /** This function suspends the science tasks.
1050 *
1051 *
1051 * @return RTEMS directive status codes:
1052 * @return RTEMS directive status codes:
1052 * - RTEMS_SUCCESSFUL - task restarted successfully
1053 * - RTEMS_SUCCESSFUL - task restarted successfully
1053 * - RTEMS_INVALID_ID - task id invalid
1054 * - RTEMS_INVALID_ID - task id invalid
1054 * - RTEMS_ALREADY_SUSPENDED - task already suspended
1055 * - RTEMS_ALREADY_SUSPENDED - task already suspended
1055 *
1056 *
1056 */
1057 */
1057
1058
1058 rtems_status_code status;
1059 rtems_status_code status;
1059
1060
1060 PRINTF("in suspend_science_tasks\n")
1061 PRINTF("in suspend_science_tasks\n")
1061
1062
1062 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
1063 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
1063 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1064 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1064 {
1065 {
1065 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
1066 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
1066 }
1067 }
1067 else
1068 else
1068 {
1069 {
1069 status = RTEMS_SUCCESSFUL;
1070 status = RTEMS_SUCCESSFUL;
1070 }
1071 }
1071 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
1072 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
1072 {
1073 {
1073 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
1074 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
1074 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1075 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1075 {
1076 {
1076 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
1077 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
1077 }
1078 }
1078 else
1079 else
1079 {
1080 {
1080 status = RTEMS_SUCCESSFUL;
1081 status = RTEMS_SUCCESSFUL;
1081 }
1082 }
1082 }
1083 }
1083 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
1084 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
1084 {
1085 {
1085 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
1086 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
1086 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1087 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1087 {
1088 {
1088 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
1089 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
1089 }
1090 }
1090 else
1091 else
1091 {
1092 {
1092 status = RTEMS_SUCCESSFUL;
1093 status = RTEMS_SUCCESSFUL;
1093 }
1094 }
1094 }
1095 }
1095 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
1096 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
1096 {
1097 {
1097 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
1098 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
1098 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1099 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1099 {
1100 {
1100 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
1101 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
1101 }
1102 }
1102 else
1103 else
1103 {
1104 {
1104 status = RTEMS_SUCCESSFUL;
1105 status = RTEMS_SUCCESSFUL;
1105 }
1106 }
1106 }
1107 }
1107 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
1108 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
1108 {
1109 {
1109 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
1110 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
1110 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1111 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1111 {
1112 {
1112 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
1113 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
1113 }
1114 }
1114 else
1115 else
1115 {
1116 {
1116 status = RTEMS_SUCCESSFUL;
1117 status = RTEMS_SUCCESSFUL;
1117 }
1118 }
1118 }
1119 }
1119 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
1120 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
1120 {
1121 {
1121 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
1122 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
1122 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1123 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1123 {
1124 {
1124 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
1125 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
1125 }
1126 }
1126 else
1127 else
1127 {
1128 {
1128 status = RTEMS_SUCCESSFUL;
1129 status = RTEMS_SUCCESSFUL;
1129 }
1130 }
1130 }
1131 }
1131 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
1132 if (status == RTEMS_SUCCESSFUL) // suspend WFRM
1132 {
1133 {
1133 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
1134 status = rtems_task_suspend( Task_id[TASKID_WFRM] );
1134 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1135 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1135 {
1136 {
1136 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
1137 PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status)
1137 }
1138 }
1138 else
1139 else
1139 {
1140 {
1140 status = RTEMS_SUCCESSFUL;
1141 status = RTEMS_SUCCESSFUL;
1141 }
1142 }
1142 }
1143 }
1143 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
1144 if (status == RTEMS_SUCCESSFUL) // suspend CWF3
1144 {
1145 {
1145 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
1146 status = rtems_task_suspend( Task_id[TASKID_CWF3] );
1146 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1147 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1147 {
1148 {
1148 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
1149 PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status)
1149 }
1150 }
1150 else
1151 else
1151 {
1152 {
1152 status = RTEMS_SUCCESSFUL;
1153 status = RTEMS_SUCCESSFUL;
1153 }
1154 }
1154 }
1155 }
1155 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
1156 if (status == RTEMS_SUCCESSFUL) // suspend CWF2
1156 {
1157 {
1157 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
1158 status = rtems_task_suspend( Task_id[TASKID_CWF2] );
1158 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1159 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1159 {
1160 {
1160 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
1161 PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status)
1161 }
1162 }
1162 else
1163 else
1163 {
1164 {
1164 status = RTEMS_SUCCESSFUL;
1165 status = RTEMS_SUCCESSFUL;
1165 }
1166 }
1166 }
1167 }
1167 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
1168 if (status == RTEMS_SUCCESSFUL) // suspend CWF1
1168 {
1169 {
1169 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
1170 status = rtems_task_suspend( Task_id[TASKID_CWF1] );
1170 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1171 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1171 {
1172 {
1172 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
1173 PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status)
1173 }
1174 }
1174 else
1175 else
1175 {
1176 {
1176 status = RTEMS_SUCCESSFUL;
1177 status = RTEMS_SUCCESSFUL;
1177 }
1178 }
1178 }
1179 }
1179
1180
1180 return status;
1181 return status;
1181 }
1182 }
1182
1183
1183 int suspend_asm_tasks( void )
1184 int suspend_asm_tasks( void )
1184 {
1185 {
1185 /** This function suspends the science tasks.
1186 /** This function suspends the science tasks.
1186 *
1187 *
1187 * @return RTEMS directive status codes:
1188 * @return RTEMS directive status codes:
1188 * - RTEMS_SUCCESSFUL - task restarted successfully
1189 * - RTEMS_SUCCESSFUL - task restarted successfully
1189 * - RTEMS_INVALID_ID - task id invalid
1190 * - RTEMS_INVALID_ID - task id invalid
1190 * - RTEMS_ALREADY_SUSPENDED - task already suspended
1191 * - RTEMS_ALREADY_SUSPENDED - task already suspended
1191 *
1192 *
1192 */
1193 */
1193
1194
1194 rtems_status_code status;
1195 rtems_status_code status;
1195
1196
1196 PRINTF("in suspend_science_tasks\n")
1197 PRINTF("in suspend_science_tasks\n")
1197
1198
1198 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
1199 status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0
1199 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1200 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1200 {
1201 {
1201 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
1202 PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status)
1202 }
1203 }
1203 else
1204 else
1204 {
1205 {
1205 status = RTEMS_SUCCESSFUL;
1206 status = RTEMS_SUCCESSFUL;
1206 }
1207 }
1207
1208
1208 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
1209 if (status == RTEMS_SUCCESSFUL) // suspend PRC0
1209 {
1210 {
1210 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
1211 status = rtems_task_suspend( Task_id[TASKID_PRC0] );
1211 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1212 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1212 {
1213 {
1213 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
1214 PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status)
1214 }
1215 }
1215 else
1216 else
1216 {
1217 {
1217 status = RTEMS_SUCCESSFUL;
1218 status = RTEMS_SUCCESSFUL;
1218 }
1219 }
1219 }
1220 }
1220
1221
1221 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
1222 if (status == RTEMS_SUCCESSFUL) // suspend AVF1
1222 {
1223 {
1223 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
1224 status = rtems_task_suspend( Task_id[TASKID_AVF1] );
1224 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1225 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1225 {
1226 {
1226 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
1227 PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status)
1227 }
1228 }
1228 else
1229 else
1229 {
1230 {
1230 status = RTEMS_SUCCESSFUL;
1231 status = RTEMS_SUCCESSFUL;
1231 }
1232 }
1232 }
1233 }
1233
1234
1234 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
1235 if (status == RTEMS_SUCCESSFUL) // suspend PRC1
1235 {
1236 {
1236 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
1237 status = rtems_task_suspend( Task_id[TASKID_PRC1] );
1237 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1238 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1238 {
1239 {
1239 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
1240 PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status)
1240 }
1241 }
1241 else
1242 else
1242 {
1243 {
1243 status = RTEMS_SUCCESSFUL;
1244 status = RTEMS_SUCCESSFUL;
1244 }
1245 }
1245 }
1246 }
1246
1247
1247 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
1248 if (status == RTEMS_SUCCESSFUL) // suspend AVF2
1248 {
1249 {
1249 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
1250 status = rtems_task_suspend( Task_id[TASKID_AVF2] );
1250 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1251 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1251 {
1252 {
1252 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
1253 PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status)
1253 }
1254 }
1254 else
1255 else
1255 {
1256 {
1256 status = RTEMS_SUCCESSFUL;
1257 status = RTEMS_SUCCESSFUL;
1257 }
1258 }
1258 }
1259 }
1259
1260
1260 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
1261 if (status == RTEMS_SUCCESSFUL) // suspend PRC2
1261 {
1262 {
1262 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
1263 status = rtems_task_suspend( Task_id[TASKID_PRC2] );
1263 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1264 if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED))
1264 {
1265 {
1265 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
1266 PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status)
1266 }
1267 }
1267 else
1268 else
1268 {
1269 {
1269 status = RTEMS_SUCCESSFUL;
1270 status = RTEMS_SUCCESSFUL;
1270 }
1271 }
1271 }
1272 }
1272
1273
1273 return status;
1274 return status;
1274 }
1275 }
1275
1276
1276 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
1277 void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime )
1277 {
1278 {
1278
1279
1279 WFP_reset_current_ring_nodes();
1280 WFP_reset_current_ring_nodes();
1280
1281
1281 reset_waveform_picker_regs();
1282 reset_waveform_picker_regs();
1282
1283
1283 set_wfp_burst_enable_register( mode );
1284 set_wfp_burst_enable_register( mode );
1284
1285
1285 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
1286 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
1286 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
1287 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
1287
1288
1288 if (transitionCoarseTime == 0)
1289 if (transitionCoarseTime == 0)
1289 {
1290 {
1290 // instant transition means transition on the next valid date
1291 // instant transition means transition on the next valid date
1291 // this is mandatory to have a good snapshot period and a good correction of the snapshot period
1292 // this is mandatory to have a good snapshot period and a good correction of the snapshot period
1292 waveform_picker_regs->start_date = time_management_regs->coarse_time + 1;
1293 waveform_picker_regs->start_date = time_management_regs->coarse_time + 1;
1293 }
1294 }
1294 else
1295 else
1295 {
1296 {
1296 waveform_picker_regs->start_date = transitionCoarseTime;
1297 waveform_picker_regs->start_date = transitionCoarseTime;
1297 }
1298 }
1298
1299
1299 update_last_valid_transition_date(waveform_picker_regs->start_date);
1300 update_last_valid_transition_date(waveform_picker_regs->start_date);
1300
1301
1301 }
1302 }
1302
1303
1303 void launch_spectral_matrix( void )
1304 void launch_spectral_matrix( void )
1304 {
1305 {
1305 SM_reset_current_ring_nodes();
1306 SM_reset_current_ring_nodes();
1306
1307
1307 reset_spectral_matrix_regs();
1308 reset_spectral_matrix_regs();
1308
1309
1309 reset_nb_sm();
1310 reset_nb_sm();
1310
1311
1311 set_sm_irq_onNewMatrix( 1 );
1312 set_sm_irq_onNewMatrix( 1 );
1312
1313
1313 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
1314 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX );
1314 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
1315 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
1315
1316
1316 }
1317 }
1317
1318
1318 void set_sm_irq_onNewMatrix( unsigned char value )
1319 void set_sm_irq_onNewMatrix( unsigned char value )
1319 {
1320 {
1320 if (value == 1)
1321 if (value == 1)
1321 {
1322 {
1322 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
1323 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01;
1323 }
1324 }
1324 else
1325 else
1325 {
1326 {
1326 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
1327 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110
1327 }
1328 }
1328 }
1329 }
1329
1330
1330 void set_sm_irq_onError( unsigned char value )
1331 void set_sm_irq_onError( unsigned char value )
1331 {
1332 {
1332 if (value == 1)
1333 if (value == 1)
1333 {
1334 {
1334 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02;
1335 spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02;
1335 }
1336 }
1336 else
1337 else
1337 {
1338 {
1338 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101
1339 spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101
1339 }
1340 }
1340 }
1341 }
1341
1342
1342 //*****************************
1343 //*****************************
1343 // CONFIGURE CALIBRATION SIGNAL
1344 // CONFIGURE CALIBRATION SIGNAL
1344 void setCalibrationPrescaler( unsigned int prescaler )
1345 void setCalibrationPrescaler( unsigned int prescaler )
1345 {
1346 {
1346 // prescaling of the master clock (25 MHz)
1347 // prescaling of the master clock (25 MHz)
1347 // master clock is divided by 2^prescaler
1348 // master clock is divided by 2^prescaler
1348 time_management_regs->calPrescaler = prescaler;
1349 time_management_regs->calPrescaler = prescaler;
1349 }
1350 }
1350
1351
1351 void setCalibrationDivisor( unsigned int divisionFactor )
1352 void setCalibrationDivisor( unsigned int divisionFactor )
1352 {
1353 {
1353 // division of the prescaled clock by the division factor
1354 // division of the prescaled clock by the division factor
1354 time_management_regs->calDivisor = divisionFactor;
1355 time_management_regs->calDivisor = divisionFactor;
1355 }
1356 }
1356
1357
1357 void setCalibrationData( void ){
1358 void setCalibrationData( void ){
1358 unsigned int k;
1359 unsigned int k;
1359 unsigned short data;
1360 unsigned short data;
1360 float val;
1361 float val;
1361 float f0;
1362 float f0;
1362 float f1;
1363 float f1;
1363 float fs;
1364 float fs;
1364 float Ts;
1365 float Ts;
1365 float scaleFactor;
1366 float scaleFactor;
1366
1367
1367 f0 = 625;
1368 f0 = 625;
1368 f1 = 10000;
1369 f1 = 10000;
1369 fs = 160256.410;
1370 fs = 160256.410;
1370 Ts = 1. / fs;
1371 Ts = 1. / fs;
1371 scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV
1372 scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV
1372
1373
1373 time_management_regs->calDataPtr = 0x00;
1374 time_management_regs->calDataPtr = 0x00;
1374
1375
1375 // build the signal for the SCM calibration
1376 // build the signal for the SCM calibration
1376 for (k=0; k<256; k++)
1377 for (k=0; k<256; k++)
1377 {
1378 {
1378 val = sin( 2 * pi * f0 * k * Ts )
1379 val = sin( 2 * pi * f0 * k * Ts )
1379 + sin( 2 * pi * f1 * k * Ts );
1380 + sin( 2 * pi * f1 * k * Ts );
1380 data = (unsigned short) ((val * scaleFactor) + 2048);
1381 data = (unsigned short) ((val * scaleFactor) + 2048);
1381 time_management_regs->calData = data & 0xfff;
1382 time_management_regs->calData = data & 0xfff;
1382 }
1383 }
1383 }
1384 }
1384
1385
1385 void setCalibrationDataInterleaved( void ){
1386 void setCalibrationDataInterleaved( void ){
1386 unsigned int k;
1387 unsigned int k;
1387 float val;
1388 float val;
1388 float f0;
1389 float f0;
1389 float f1;
1390 float f1;
1390 float fs;
1391 float fs;
1391 float Ts;
1392 float Ts;
1392 unsigned short data[384];
1393 unsigned short data[384];
1393 unsigned char *dataPtr;
1394 unsigned char *dataPtr;
1394
1395
1395 f0 = 625;
1396 f0 = 625;
1396 f1 = 10000;
1397 f1 = 10000;
1397 fs = 240384.615;
1398 fs = 240384.615;
1398 Ts = 1. / fs;
1399 Ts = 1. / fs;
1399
1400
1400 time_management_regs->calDataPtr = 0x00;
1401 time_management_regs->calDataPtr = 0x00;
1401
1402
1402 // build the signal for the SCM calibration
1403 // build the signal for the SCM calibration
1403 for (k=0; k<384; k++)
1404 for (k=0; k<384; k++)
1404 {
1405 {
1405 val = sin( 2 * pi * f0 * k * Ts )
1406 val = sin( 2 * pi * f0 * k * Ts )
1406 + sin( 2 * pi * f1 * k * Ts );
1407 + sin( 2 * pi * f1 * k * Ts );
1407 data[k] = (unsigned short) (val * 512 + 2048);
1408 data[k] = (unsigned short) (val * 512 + 2048);
1408 }
1409 }
1409
1410
1410 // write the signal in interleaved mode
1411 // write the signal in interleaved mode
1411 for (k=0; k<128; k++)
1412 for (k=0; k<128; k++)
1412 {
1413 {
1413 dataPtr = (unsigned char*) &data[k*3 + 2];
1414 dataPtr = (unsigned char*) &data[k*3 + 2];
1414 time_management_regs->calData = (data[k*3] & 0xfff)
1415 time_management_regs->calData = (data[k*3] & 0xfff)
1415 + ( (dataPtr[0] & 0x3f) << 12);
1416 + ( (dataPtr[0] & 0x3f) << 12);
1416 time_management_regs->calData = (data[k*3 + 1] & 0xfff)
1417 time_management_regs->calData = (data[k*3 + 1] & 0xfff)
1417 + ( (dataPtr[1] & 0x3f) << 12);
1418 + ( (dataPtr[1] & 0x3f) << 12);
1418 }
1419 }
1419 }
1420 }
1420
1421
1421 void setCalibrationReload( bool state)
1422 void setCalibrationReload( bool state)
1422 {
1423 {
1423 if (state == true)
1424 if (state == true)
1424 {
1425 {
1425 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000]
1426 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000]
1426 }
1427 }
1427 else
1428 else
1428 {
1429 {
1429 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111]
1430 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111]
1430 }
1431 }
1431 }
1432 }
1432
1433
1433 void setCalibrationEnable( bool state )
1434 void setCalibrationEnable( bool state )
1434 {
1435 {
1435 // this bit drives the multiplexer
1436 // this bit drives the multiplexer
1436 if (state == true)
1437 if (state == true)
1437 {
1438 {
1438 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000]
1439 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000]
1439 }
1440 }
1440 else
1441 else
1441 {
1442 {
1442 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111]
1443 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111]
1443 }
1444 }
1444 }
1445 }
1445
1446
1446 void setCalibrationInterleaved( bool state )
1447 void setCalibrationInterleaved( bool state )
1447 {
1448 {
1448 // this bit drives the multiplexer
1449 // this bit drives the multiplexer
1449 if (state == true)
1450 if (state == true)
1450 {
1451 {
1451 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000]
1452 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000]
1452 }
1453 }
1453 else
1454 else
1454 {
1455 {
1455 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111]
1456 time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111]
1456 }
1457 }
1457 }
1458 }
1458
1459
1459 void setCalibration( bool state )
1460 void setCalibration( bool state )
1460 {
1461 {
1461 if (state == true)
1462 if (state == true)
1462 {
1463 {
1463 setCalibrationEnable( true );
1464 setCalibrationEnable( true );
1464 setCalibrationReload( false );
1465 setCalibrationReload( false );
1465 set_hk_lfr_calib_enable( true );
1466 set_hk_lfr_calib_enable( true );
1466 }
1467 }
1467 else
1468 else
1468 {
1469 {
1469 setCalibrationEnable( false );
1470 setCalibrationEnable( false );
1470 setCalibrationReload( true );
1471 setCalibrationReload( true );
1471 set_hk_lfr_calib_enable( false );
1472 set_hk_lfr_calib_enable( false );
1472 }
1473 }
1473 }
1474 }
1474
1475
1475 void configureCalibration( bool interleaved )
1476 void configureCalibration( bool interleaved )
1476 {
1477 {
1477 setCalibration( false );
1478 setCalibration( false );
1478 if ( interleaved == true )
1479 if ( interleaved == true )
1479 {
1480 {
1480 setCalibrationInterleaved( true );
1481 setCalibrationInterleaved( true );
1481 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1482 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1482 setCalibrationDivisor( 26 ); // => 240 384
1483 setCalibrationDivisor( 26 ); // => 240 384
1483 setCalibrationDataInterleaved();
1484 setCalibrationDataInterleaved();
1484 }
1485 }
1485 else
1486 else
1486 {
1487 {
1487 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1488 setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000
1488 setCalibrationDivisor( 38 ); // => 160 256 (39 - 1)
1489 setCalibrationDivisor( 38 ); // => 160 256 (39 - 1)
1489 setCalibrationData();
1490 setCalibrationData();
1490 }
1491 }
1491 }
1492 }
1492
1493
1493 //****************
1494 //****************
1494 // CLOSING ACTIONS
1495 // CLOSING ACTIONS
1495 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
1496 void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time )
1496 {
1497 {
1497 /** This function is used to update the HK packets statistics after a successful TC execution.
1498 /** This function is used to update the HK packets statistics after a successful TC execution.
1498 *
1499 *
1499 * @param TC points to the TC being processed
1500 * @param TC points to the TC being processed
1500 * @param time is the time used to date the TC execution
1501 * @param time is the time used to date the TC execution
1501 *
1502 *
1502 */
1503 */
1503
1504
1504 unsigned int val;
1505 unsigned int val;
1505
1506
1506 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
1507 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
1507 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
1508 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
1508 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
1509 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
1509 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
1510 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
1510 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
1511 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
1511 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
1512 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
1512 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
1513 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0];
1513 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
1514 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1];
1514 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
1515 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2];
1515 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
1516 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3];
1516 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
1517 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4];
1517 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
1518 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5];
1518
1519
1519 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
1520 val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1];
1520 val++;
1521 val++;
1521 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
1522 housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8);
1522 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
1523 housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val);
1523 }
1524 }
1524
1525
1525 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
1526 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time )
1526 {
1527 {
1527 /** This function is used to update the HK packets statistics after a TC rejection.
1528 /** This function is used to update the HK packets statistics after a TC rejection.
1528 *
1529 *
1529 * @param TC points to the TC being processed
1530 * @param TC points to the TC being processed
1530 * @param time is the time used to date the TC rejection
1531 * @param time is the time used to date the TC rejection
1531 *
1532 *
1532 */
1533 */
1533
1534
1534 unsigned int val;
1535 unsigned int val;
1535
1536
1536 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
1537 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
1537 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
1538 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
1538 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
1539 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
1539 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
1540 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
1540 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
1541 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
1541 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
1542 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
1542 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
1543 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0];
1543 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
1544 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1];
1544 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
1545 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2];
1545 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
1546 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3];
1546 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
1547 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4];
1547 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
1548 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5];
1548
1549
1549 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
1550 val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1];
1550 val++;
1551 val++;
1551 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
1552 housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8);
1552 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
1553 housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val);
1553 }
1554 }
1554
1555
1555 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
1556 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id )
1556 {
1557 {
1557 /** This function is the last step of the TC execution workflow.
1558 /** This function is the last step of the TC execution workflow.
1558 *
1559 *
1559 * @param TC points to the TC being processed
1560 * @param TC points to the TC being processed
1560 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
1561 * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT)
1561 * @param queue_id is the id of the RTEMS message queue used to send TM packets
1562 * @param queue_id is the id of the RTEMS message queue used to send TM packets
1562 * @param time is the time used to date the TC execution
1563 * @param time is the time used to date the TC execution
1563 *
1564 *
1564 */
1565 */
1565
1566
1566 unsigned char requestedMode;
1567 unsigned char requestedMode;
1567
1568
1568 if (result == LFR_SUCCESSFUL)
1569 if (result == LFR_SUCCESSFUL)
1569 {
1570 {
1570 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
1571 if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) )
1571 &
1572 &
1572 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
1573 !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO))
1573 )
1574 )
1574 {
1575 {
1575 send_tm_lfr_tc_exe_success( TC, queue_id );
1576 send_tm_lfr_tc_exe_success( TC, queue_id );
1576 }
1577 }
1577 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
1578 if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) )
1578 {
1579 {
1579 //**********************************
1580 //**********************************
1580 // UPDATE THE LFRMODE LOCAL VARIABLE
1581 // UPDATE THE LFRMODE LOCAL VARIABLE
1581 requestedMode = TC->dataAndCRC[1];
1582 requestedMode = TC->dataAndCRC[1];
1582 updateLFRCurrentMode( requestedMode );
1583 updateLFRCurrentMode( requestedMode );
1583 }
1584 }
1584 }
1585 }
1585 else if (result == LFR_EXE_ERROR)
1586 else if (result == LFR_EXE_ERROR)
1586 {
1587 {
1587 send_tm_lfr_tc_exe_error( TC, queue_id );
1588 send_tm_lfr_tc_exe_error( TC, queue_id );
1588 }
1589 }
1589 }
1590 }
1590
1591
1591 //***************************
1592 //***************************
1592 // Interrupt Service Routines
1593 // Interrupt Service Routines
1593 rtems_isr commutation_isr1( rtems_vector_number vector )
1594 rtems_isr commutation_isr1( rtems_vector_number vector )
1594 {
1595 {
1595 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1596 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1596 PRINTF("In commutation_isr1 *** Error sending event to DUMB\n")
1597 PRINTF("In commutation_isr1 *** Error sending event to DUMB\n")
1597 }
1598 }
1598 }
1599 }
1599
1600
1600 rtems_isr commutation_isr2( rtems_vector_number vector )
1601 rtems_isr commutation_isr2( rtems_vector_number vector )
1601 {
1602 {
1602 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1603 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1603 PRINTF("In commutation_isr2 *** Error sending event to DUMB\n")
1604 PRINTF("In commutation_isr2 *** Error sending event to DUMB\n")
1604 }
1605 }
1605 }
1606 }
1606
1607
1607 //****************
1608 //****************
1608 // OTHER FUNCTIONS
1609 // OTHER FUNCTIONS
1609 void updateLFRCurrentMode( unsigned char requestedMode )
1610 void updateLFRCurrentMode( unsigned char requestedMode )
1610 {
1611 {
1611 /** This function updates the value of the global variable lfrCurrentMode.
1612 /** This function updates the value of the global variable lfrCurrentMode.
1612 *
1613 *
1613 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
1614 * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running.
1614 *
1615 *
1615 */
1616 */
1616
1617
1617 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
1618 // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure
1618 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
1619 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d);
1619 lfrCurrentMode = requestedMode;
1620 lfrCurrentMode = requestedMode;
1620 }
1621 }
1621
1622
1622 void set_lfr_soft_reset( unsigned char value )
1623 void set_lfr_soft_reset( unsigned char value )
1623 {
1624 {
1624 if (value == 1)
1625 if (value == 1)
1625 {
1626 {
1626 time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100]
1627 time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100]
1627 }
1628 }
1628 else
1629 else
1629 {
1630 {
1630 time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011]
1631 time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011]
1631 }
1632 }
1632 }
1633 }
1633
1634
1634 void reset_lfr( void )
1635 void reset_lfr( void )
1635 {
1636 {
1636 set_lfr_soft_reset( 1 );
1637 set_lfr_soft_reset( 1 );
1637
1638
1638 set_lfr_soft_reset( 0 );
1639 set_lfr_soft_reset( 0 );
1639
1640
1640 set_hk_lfr_sc_potential_flag( true );
1641 set_hk_lfr_sc_potential_flag( true );
1641 }
1642 }
@@ -1,1628 +1,1753
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 unsigned char k;
323
324
324 flag = LFR_DEFAULT;
325 flag = LFR_DEFAULT;
326 k = 0;
325
327
326 flag = check_sy_lfr_filter_parameters( TC, queue_id );
328 flag = check_sy_lfr_filter_parameters( TC, queue_id );
327
329
328 if (flag == LFR_SUCCESSFUL)
330 if (flag == LFR_SUCCESSFUL)
329 {
331 {
330 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ];
332 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 ];
333 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 ];
334 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 ];
335 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 ];
336 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 ];
337 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 ];
338 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 ];
339 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 ];
340 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 ];
341 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 ];
342 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 ];
343 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 ];
344 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 ];
345 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 ];
346 parameter_dump_packet.sy_lfr_sc_rw_delta_f[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 3 ];
345
347
346 //****************************
348 //****************************
347 // store PAS filter parameters
349 // store PAS filter parameters
348 // sy_lfr_pas_filter_enabled
350 // sy_lfr_pas_filter_enabled
349 filterPar.spare_sy_lfr_pas_filter_enabled = parameter_dump_packet.spare_sy_lfr_pas_filter_enabled;
351 filterPar.spare_sy_lfr_pas_filter_enabled = parameter_dump_packet.spare_sy_lfr_pas_filter_enabled;
350 set_sy_lfr_pas_filter_enabled( parameter_dump_packet.spare_sy_lfr_pas_filter_enabled & 0x01 );
352 set_sy_lfr_pas_filter_enabled( parameter_dump_packet.spare_sy_lfr_pas_filter_enabled & 0x01 );
351 // sy_lfr_pas_filter_modulus
353 // sy_lfr_pas_filter_modulus
352 filterPar.sy_lfr_pas_filter_modulus = parameter_dump_packet.sy_lfr_pas_filter_modulus;
354 filterPar.sy_lfr_pas_filter_modulus = parameter_dump_packet.sy_lfr_pas_filter_modulus;
353 // sy_lfr_pas_filter_tbad
355 // sy_lfr_pas_filter_tbad
354 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_tbad,
356 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_tbad,
355 parameter_dump_packet.sy_lfr_pas_filter_tbad );
357 parameter_dump_packet.sy_lfr_pas_filter_tbad );
356 // sy_lfr_pas_filter_offset
358 // sy_lfr_pas_filter_offset
357 filterPar.sy_lfr_pas_filter_offset = parameter_dump_packet.sy_lfr_pas_filter_offset;
359 filterPar.sy_lfr_pas_filter_offset = parameter_dump_packet.sy_lfr_pas_filter_offset;
358 // sy_lfr_pas_filter_shift
360 // sy_lfr_pas_filter_shift
359 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_shift,
361 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_shift,
360 parameter_dump_packet.sy_lfr_pas_filter_shift );
362 parameter_dump_packet.sy_lfr_pas_filter_shift );
361
363
362 //****************************************************
364 //****************************************************
363 // store the parameter sy_lfr_sc_rw_delta_f as a float
365 // store the parameter sy_lfr_sc_rw_delta_f as a float
364 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_sc_rw_delta_f,
366 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_sc_rw_delta_f,
365 parameter_dump_packet.sy_lfr_sc_rw_delta_f );
367 parameter_dump_packet.sy_lfr_sc_rw_delta_f );
368
369 // copy rw.._k.. from the incoming TC to the local parameter_dump_packet
370 for (k = 0; k < NB_RW_K_COEFFS * NB_BYTES_PER_RW_K_COEFF; k++)
371 {
372 parameter_dump_packet.sy_lfr_rw1_k1[k] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_RW1_K1 + k ];
373 }
374
375 //***********************************************
376 // store the parameter sy_lfr_rw.._k.. as a float
377 // rw1_k
378 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k1, parameter_dump_packet.sy_lfr_rw1_k1 );
379 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k2, parameter_dump_packet.sy_lfr_rw1_k2 );
380 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k3, parameter_dump_packet.sy_lfr_rw1_k3 );
381 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw1_k4, parameter_dump_packet.sy_lfr_rw1_k4 );
382 // rw2_k
383 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k1, parameter_dump_packet.sy_lfr_rw2_k1 );
384 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k2, parameter_dump_packet.sy_lfr_rw2_k2 );
385 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k3, parameter_dump_packet.sy_lfr_rw2_k3 );
386 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw2_k4, parameter_dump_packet.sy_lfr_rw2_k4 );
387 // rw3_k
388 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k1, parameter_dump_packet.sy_lfr_rw3_k1 );
389 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k2, parameter_dump_packet.sy_lfr_rw3_k2 );
390 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k3, parameter_dump_packet.sy_lfr_rw3_k3 );
391 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw3_k4, parameter_dump_packet.sy_lfr_rw3_k4 );
392 // rw4_k
393 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k1, parameter_dump_packet.sy_lfr_rw4_k1 );
394 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k2, parameter_dump_packet.sy_lfr_rw4_k2 );
395 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k3, parameter_dump_packet.sy_lfr_rw4_k3 );
396 copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_rw4_k4, parameter_dump_packet.sy_lfr_rw4_k4 );
397
366 }
398 }
367
399
368 return flag;
400 return flag;
369 }
401 }
370
402
371 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
403 int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time)
372 {
404 {
373 /** This function updates the LFR registers with the incoming sbm2 parameters.
405 /** This function updates the LFR registers with the incoming sbm2 parameters.
374 *
406 *
375 * @param TC points to the TeleCommand packet that is being processed
407 * @param TC points to the TeleCommand packet that is being processed
376 * @param queue_id is the id of the queue which handles TM related to this execution step
408 * @param queue_id is the id of the queue which handles TM related to this execution step
377 *
409 *
378 */
410 */
379
411
380 unsigned int address;
412 unsigned int address;
381 rtems_status_code status;
413 rtems_status_code status;
382 unsigned int freq;
414 unsigned int freq;
383 unsigned int bin;
415 unsigned int bin;
384 unsigned int coeff;
416 unsigned int coeff;
385 unsigned char *kCoeffPtr;
417 unsigned char *kCoeffPtr;
386 unsigned char *kCoeffDumpPtr;
418 unsigned char *kCoeffDumpPtr;
387
419
388 // for each sy_lfr_kcoeff_frequency there is 32 kcoeff
420 // for each sy_lfr_kcoeff_frequency there is 32 kcoeff
389 // F0 => 11 bins
421 // F0 => 11 bins
390 // F1 => 13 bins
422 // F1 => 13 bins
391 // F2 => 12 bins
423 // F2 => 12 bins
392 // 36 bins to dump in two packets (30 bins max per packet)
424 // 36 bins to dump in two packets (30 bins max per packet)
393
425
394 //*********
426 //*********
395 // PACKET 1
427 // PACKET 1
396 // 11 F0 bins, 13 F1 bins and 6 F2 bins
428 // 11 F0 bins, 13 F1 bins and 6 F2 bins
397 kcoefficients_dump_1.destinationID = TC->sourceID;
429 kcoefficients_dump_1.destinationID = TC->sourceID;
398 increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID );
430 increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID );
399 for( freq=0;
431 for( freq=0;
400 freq<NB_BINS_COMPRESSED_SM_F0;
432 freq<NB_BINS_COMPRESSED_SM_F0;
401 freq++ )
433 freq++ )
402 {
434 {
403 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq;
435 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq;
404 bin = freq;
436 bin = freq;
405 // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm);
437 // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm);
406 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
438 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
407 {
439 {
408 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
440 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
409 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
441 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
410 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
442 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
411 }
443 }
412 }
444 }
413 for( freq=NB_BINS_COMPRESSED_SM_F0;
445 for( freq=NB_BINS_COMPRESSED_SM_F0;
414 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
446 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
415 freq++ )
447 freq++ )
416 {
448 {
417 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
449 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
418 bin = freq - NB_BINS_COMPRESSED_SM_F0;
450 bin = freq - NB_BINS_COMPRESSED_SM_F0;
419 // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm);
451 // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm);
420 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
452 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
421 {
453 {
422 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
454 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
423 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
455 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
424 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
456 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
425 }
457 }
426 }
458 }
427 for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
459 for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
428 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6);
460 freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6);
429 freq++ )
461 freq++ )
430 {
462 {
431 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
463 kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq;
432 bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
464 bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1);
433 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
465 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
434 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
466 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
435 {
467 {
436 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
468 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
437 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
469 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
438 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
470 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
439 }
471 }
440 }
472 }
441 kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
473 kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
442 kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
474 kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
443 kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
475 kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
444 kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time);
476 kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time);
445 kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
477 kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
446 kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time);
478 kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time);
447 // SEND DATA
479 // SEND DATA
448 kcoefficient_node_1.status = 1;
480 kcoefficient_node_1.status = 1;
449 address = (unsigned int) &kcoefficient_node_1;
481 address = (unsigned int) &kcoefficient_node_1;
450 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
482 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
451 if (status != RTEMS_SUCCESSFUL) {
483 if (status != RTEMS_SUCCESSFUL) {
452 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status)
484 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status)
453 }
485 }
454
486
455 //********
487 //********
456 // PACKET 2
488 // PACKET 2
457 // 6 F2 bins
489 // 6 F2 bins
458 kcoefficients_dump_2.destinationID = TC->sourceID;
490 kcoefficients_dump_2.destinationID = TC->sourceID;
459 increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID );
491 increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID );
460 for( freq=0; freq<6; freq++ )
492 for( freq=0; freq<6; freq++ )
461 {
493 {
462 kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq;
494 kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq;
463 bin = freq + 6;
495 bin = freq + 6;
464 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
496 // printKCoefficients( freq, bin, k_coeff_intercalib_f2);
465 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
497 for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ )
466 {
498 {
467 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
499 kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency
468 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
500 kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ];
469 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
501 copyFloatByChar( kCoeffDumpPtr, kCoeffPtr );
470 }
502 }
471 }
503 }
472 kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
504 kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
473 kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
505 kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
474 kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
506 kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
475 kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time);
507 kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time);
476 kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
508 kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
477 kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time);
509 kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time);
478 // SEND DATA
510 // SEND DATA
479 kcoefficient_node_2.status = 1;
511 kcoefficient_node_2.status = 1;
480 address = (unsigned int) &kcoefficient_node_2;
512 address = (unsigned int) &kcoefficient_node_2;
481 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
513 status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) );
482 if (status != RTEMS_SUCCESSFUL) {
514 if (status != RTEMS_SUCCESSFUL) {
483 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status)
515 PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status)
484 }
516 }
485
517
486 return status;
518 return status;
487 }
519 }
488
520
489 int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
521 int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
490 {
522 {
491 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
523 /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue.
492 *
524 *
493 * @param queue_id is the id of the queue which handles TM related to this execution step.
525 * @param queue_id is the id of the queue which handles TM related to this execution step.
494 *
526 *
495 * @return RTEMS directive status codes:
527 * @return RTEMS directive status codes:
496 * - RTEMS_SUCCESSFUL - message sent successfully
528 * - RTEMS_SUCCESSFUL - message sent successfully
497 * - RTEMS_INVALID_ID - invalid queue id
529 * - RTEMS_INVALID_ID - invalid queue id
498 * - RTEMS_INVALID_SIZE - invalid message size
530 * - RTEMS_INVALID_SIZE - invalid message size
499 * - RTEMS_INVALID_ADDRESS - buffer is NULL
531 * - RTEMS_INVALID_ADDRESS - buffer is NULL
500 * - RTEMS_UNSATISFIED - out of message buffers
532 * - RTEMS_UNSATISFIED - out of message buffers
501 * - RTEMS_TOO_MANY - queue s limit has been reached
533 * - RTEMS_TOO_MANY - queue s limit has been reached
502 *
534 *
503 */
535 */
504
536
505 int status;
537 int status;
506
538
507 increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID );
539 increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID );
508 parameter_dump_packet.destinationID = TC->sourceID;
540 parameter_dump_packet.destinationID = TC->sourceID;
509
541
510 // UPDATE TIME
542 // UPDATE TIME
511 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
543 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
512 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
544 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
513 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
545 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
514 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
546 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
515 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
547 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
516 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
548 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
517 // SEND DATA
549 // SEND DATA
518 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
550 status = rtems_message_queue_send( queue_id, &parameter_dump_packet,
519 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
551 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
520 if (status != RTEMS_SUCCESSFUL) {
552 if (status != RTEMS_SUCCESSFUL) {
521 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
553 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
522 }
554 }
523
555
524 return status;
556 return status;
525 }
557 }
526
558
527 //***********************
559 //***********************
528 // NORMAL MODE PARAMETERS
560 // NORMAL MODE PARAMETERS
529
561
530 int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
562 int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
531 {
563 {
532 unsigned char msb;
564 unsigned char msb;
533 unsigned char lsb;
565 unsigned char lsb;
534 int flag;
566 int flag;
535 float aux;
567 float aux;
536 rtems_status_code status;
568 rtems_status_code status;
537
569
538 unsigned int sy_lfr_n_swf_l;
570 unsigned int sy_lfr_n_swf_l;
539 unsigned int sy_lfr_n_swf_p;
571 unsigned int sy_lfr_n_swf_p;
540 unsigned int sy_lfr_n_asm_p;
572 unsigned int sy_lfr_n_asm_p;
541 unsigned char sy_lfr_n_bp_p0;
573 unsigned char sy_lfr_n_bp_p0;
542 unsigned char sy_lfr_n_bp_p1;
574 unsigned char sy_lfr_n_bp_p1;
543 unsigned char sy_lfr_n_cwf_long_f3;
575 unsigned char sy_lfr_n_cwf_long_f3;
544
576
545 flag = LFR_SUCCESSFUL;
577 flag = LFR_SUCCESSFUL;
546
578
547 //***************
579 //***************
548 // get parameters
580 // get parameters
549 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
581 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
550 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
582 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
551 sy_lfr_n_swf_l = msb * 256 + lsb;
583 sy_lfr_n_swf_l = msb * 256 + lsb;
552
584
553 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
585 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
554 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
586 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
555 sy_lfr_n_swf_p = msb * 256 + lsb;
587 sy_lfr_n_swf_p = msb * 256 + lsb;
556
588
557 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
589 msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
558 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
590 lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
559 sy_lfr_n_asm_p = msb * 256 + lsb;
591 sy_lfr_n_asm_p = msb * 256 + lsb;
560
592
561 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
593 sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
562
594
563 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
595 sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
564
596
565 sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
597 sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
566
598
567 //******************
599 //******************
568 // check consistency
600 // check consistency
569 // sy_lfr_n_swf_l
601 // sy_lfr_n_swf_l
570 if (sy_lfr_n_swf_l != 2048)
602 if (sy_lfr_n_swf_l != 2048)
571 {
603 {
572 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l );
604 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l );
573 flag = WRONG_APP_DATA;
605 flag = WRONG_APP_DATA;
574 }
606 }
575 // sy_lfr_n_swf_p
607 // sy_lfr_n_swf_p
576 if (flag == LFR_SUCCESSFUL)
608 if (flag == LFR_SUCCESSFUL)
577 {
609 {
578 if ( sy_lfr_n_swf_p < 22 )
610 if ( sy_lfr_n_swf_p < 22 )
579 {
611 {
580 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p );
612 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p );
581 flag = WRONG_APP_DATA;
613 flag = WRONG_APP_DATA;
582 }
614 }
583 }
615 }
584 // sy_lfr_n_bp_p0
616 // sy_lfr_n_bp_p0
585 if (flag == LFR_SUCCESSFUL)
617 if (flag == LFR_SUCCESSFUL)
586 {
618 {
587 if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0)
619 if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0)
588 {
620 {
589 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 );
621 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 );
590 flag = WRONG_APP_DATA;
622 flag = WRONG_APP_DATA;
591 }
623 }
592 }
624 }
593 // sy_lfr_n_asm_p
625 // sy_lfr_n_asm_p
594 if (flag == LFR_SUCCESSFUL)
626 if (flag == LFR_SUCCESSFUL)
595 {
627 {
596 if (sy_lfr_n_asm_p == 0)
628 if (sy_lfr_n_asm_p == 0)
597 {
629 {
598 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
630 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
599 flag = WRONG_APP_DATA;
631 flag = WRONG_APP_DATA;
600 }
632 }
601 }
633 }
602 // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0
634 // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0
603 if (flag == LFR_SUCCESSFUL)
635 if (flag == LFR_SUCCESSFUL)
604 {
636 {
605 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
637 aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0);
606 if (aux > FLOAT_EQUAL_ZERO)
638 if (aux > FLOAT_EQUAL_ZERO)
607 {
639 {
608 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
640 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p );
609 flag = WRONG_APP_DATA;
641 flag = WRONG_APP_DATA;
610 }
642 }
611 }
643 }
612 // sy_lfr_n_bp_p1
644 // sy_lfr_n_bp_p1
613 if (flag == LFR_SUCCESSFUL)
645 if (flag == LFR_SUCCESSFUL)
614 {
646 {
615 if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1)
647 if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1)
616 {
648 {
617 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
649 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
618 flag = WRONG_APP_DATA;
650 flag = WRONG_APP_DATA;
619 }
651 }
620 }
652 }
621 // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0
653 // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0
622 if (flag == LFR_SUCCESSFUL)
654 if (flag == LFR_SUCCESSFUL)
623 {
655 {
624 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
656 aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0);
625 if (aux > FLOAT_EQUAL_ZERO)
657 if (aux > FLOAT_EQUAL_ZERO)
626 {
658 {
627 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
659 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 );
628 flag = LFR_DEFAULT;
660 flag = LFR_DEFAULT;
629 }
661 }
630 }
662 }
631 // sy_lfr_n_cwf_long_f3
663 // sy_lfr_n_cwf_long_f3
632
664
633 return flag;
665 return flag;
634 }
666 }
635
667
636 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC )
668 int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC )
637 {
669 {
638 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
670 /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l).
639 *
671 *
640 * @param TC points to the TeleCommand packet that is being processed
672 * @param TC points to the TeleCommand packet that is being processed
641 * @param queue_id is the id of the queue which handles TM related to this execution step
673 * @param queue_id is the id of the queue which handles TM related to this execution step
642 *
674 *
643 */
675 */
644
676
645 int result;
677 int result;
646
678
647 result = LFR_SUCCESSFUL;
679 result = LFR_SUCCESSFUL;
648
680
649 parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
681 parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ];
650 parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
682 parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ];
651
683
652 return result;
684 return result;
653 }
685 }
654
686
655 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC )
687 int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC )
656 {
688 {
657 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
689 /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p).
658 *
690 *
659 * @param TC points to the TeleCommand packet that is being processed
691 * @param TC points to the TeleCommand packet that is being processed
660 * @param queue_id is the id of the queue which handles TM related to this execution step
692 * @param queue_id is the id of the queue which handles TM related to this execution step
661 *
693 *
662 */
694 */
663
695
664 int result;
696 int result;
665
697
666 result = LFR_SUCCESSFUL;
698 result = LFR_SUCCESSFUL;
667
699
668 parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
700 parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ];
669 parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
701 parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ];
670
702
671 return result;
703 return result;
672 }
704 }
673
705
674 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC )
706 int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC )
675 {
707 {
676 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
708 /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P).
677 *
709 *
678 * @param TC points to the TeleCommand packet that is being processed
710 * @param TC points to the TeleCommand packet that is being processed
679 * @param queue_id is the id of the queue which handles TM related to this execution step
711 * @param queue_id is the id of the queue which handles TM related to this execution step
680 *
712 *
681 */
713 */
682
714
683 int result;
715 int result;
684
716
685 result = LFR_SUCCESSFUL;
717 result = LFR_SUCCESSFUL;
686
718
687 parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
719 parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ];
688 parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
720 parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ];
689
721
690 return result;
722 return result;
691 }
723 }
692
724
693 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC )
725 int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC )
694 {
726 {
695 /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0).
727 /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0).
696 *
728 *
697 * @param TC points to the TeleCommand packet that is being processed
729 * @param TC points to the TeleCommand packet that is being processed
698 * @param queue_id is the id of the queue which handles TM related to this execution step
730 * @param queue_id is the id of the queue which handles TM related to this execution step
699 *
731 *
700 */
732 */
701
733
702 int status;
734 int status;
703
735
704 status = LFR_SUCCESSFUL;
736 status = LFR_SUCCESSFUL;
705
737
706 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
738 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ];
707
739
708 return status;
740 return status;
709 }
741 }
710
742
711 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC )
743 int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC )
712 {
744 {
713 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
745 /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1).
714 *
746 *
715 * @param TC points to the TeleCommand packet that is being processed
747 * @param TC points to the TeleCommand packet that is being processed
716 * @param queue_id is the id of the queue which handles TM related to this execution step
748 * @param queue_id is the id of the queue which handles TM related to this execution step
717 *
749 *
718 */
750 */
719
751
720 int status;
752 int status;
721
753
722 status = LFR_SUCCESSFUL;
754 status = LFR_SUCCESSFUL;
723
755
724 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
756 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ];
725
757
726 return status;
758 return status;
727 }
759 }
728
760
729 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC )
761 int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC )
730 {
762 {
731 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
763 /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets.
732 *
764 *
733 * @param TC points to the TeleCommand packet that is being processed
765 * @param TC points to the TeleCommand packet that is being processed
734 * @param queue_id is the id of the queue which handles TM related to this execution step
766 * @param queue_id is the id of the queue which handles TM related to this execution step
735 *
767 *
736 */
768 */
737
769
738 int status;
770 int status;
739
771
740 status = LFR_SUCCESSFUL;
772 status = LFR_SUCCESSFUL;
741
773
742 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
774 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ];
743
775
744 return status;
776 return status;
745 }
777 }
746
778
747 //**********************
779 //**********************
748 // BURST MODE PARAMETERS
780 // BURST MODE PARAMETERS
749 int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC)
781 int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC)
750 {
782 {
751 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0).
783 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0).
752 *
784 *
753 * @param TC points to the TeleCommand packet that is being processed
785 * @param TC points to the TeleCommand packet that is being processed
754 * @param queue_id is the id of the queue which handles TM related to this execution step
786 * @param queue_id is the id of the queue which handles TM related to this execution step
755 *
787 *
756 */
788 */
757
789
758 int status;
790 int status;
759
791
760 status = LFR_SUCCESSFUL;
792 status = LFR_SUCCESSFUL;
761
793
762 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
794 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ];
763
795
764 return status;
796 return status;
765 }
797 }
766
798
767 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC )
799 int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC )
768 {
800 {
769 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1).
801 /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1).
770 *
802 *
771 * @param TC points to the TeleCommand packet that is being processed
803 * @param TC points to the TeleCommand packet that is being processed
772 * @param queue_id is the id of the queue which handles TM related to this execution step
804 * @param queue_id is the id of the queue which handles TM related to this execution step
773 *
805 *
774 */
806 */
775
807
776 int status;
808 int status;
777
809
778 status = LFR_SUCCESSFUL;
810 status = LFR_SUCCESSFUL;
779
811
780 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
812 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ];
781
813
782 return status;
814 return status;
783 }
815 }
784
816
785 //*********************
817 //*********************
786 // SBM1 MODE PARAMETERS
818 // SBM1 MODE PARAMETERS
787 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC )
819 int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC )
788 {
820 {
789 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0).
821 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0).
790 *
822 *
791 * @param TC points to the TeleCommand packet that is being processed
823 * @param TC points to the TeleCommand packet that is being processed
792 * @param queue_id is the id of the queue which handles TM related to this execution step
824 * @param queue_id is the id of the queue which handles TM related to this execution step
793 *
825 *
794 */
826 */
795
827
796 int status;
828 int status;
797
829
798 status = LFR_SUCCESSFUL;
830 status = LFR_SUCCESSFUL;
799
831
800 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
832 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ];
801
833
802 return status;
834 return status;
803 }
835 }
804
836
805 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC )
837 int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC )
806 {
838 {
807 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1).
839 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1).
808 *
840 *
809 * @param TC points to the TeleCommand packet that is being processed
841 * @param TC points to the TeleCommand packet that is being processed
810 * @param queue_id is the id of the queue which handles TM related to this execution step
842 * @param queue_id is the id of the queue which handles TM related to this execution step
811 *
843 *
812 */
844 */
813
845
814 int status;
846 int status;
815
847
816 status = LFR_SUCCESSFUL;
848 status = LFR_SUCCESSFUL;
817
849
818 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
850 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ];
819
851
820 return status;
852 return status;
821 }
853 }
822
854
823 //*********************
855 //*********************
824 // SBM2 MODE PARAMETERS
856 // SBM2 MODE PARAMETERS
825 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC )
857 int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC )
826 {
858 {
827 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0).
859 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0).
828 *
860 *
829 * @param TC points to the TeleCommand packet that is being processed
861 * @param TC points to the TeleCommand packet that is being processed
830 * @param queue_id is the id of the queue which handles TM related to this execution step
862 * @param queue_id is the id of the queue which handles TM related to this execution step
831 *
863 *
832 */
864 */
833
865
834 int status;
866 int status;
835
867
836 status = LFR_SUCCESSFUL;
868 status = LFR_SUCCESSFUL;
837
869
838 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
870 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ];
839
871
840 return status;
872 return status;
841 }
873 }
842
874
843 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC )
875 int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC )
844 {
876 {
845 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1).
877 /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1).
846 *
878 *
847 * @param TC points to the TeleCommand packet that is being processed
879 * @param TC points to the TeleCommand packet that is being processed
848 * @param queue_id is the id of the queue which handles TM related to this execution step
880 * @param queue_id is the id of the queue which handles TM related to this execution step
849 *
881 *
850 */
882 */
851
883
852 int status;
884 int status;
853
885
854 status = LFR_SUCCESSFUL;
886 status = LFR_SUCCESSFUL;
855
887
856 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
888 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ];
857
889
858 return status;
890 return status;
859 }
891 }
860
892
861 //*******************
893 //*******************
862 // TC_LFR_UPDATE_INFO
894 // TC_LFR_UPDATE_INFO
863 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
895 unsigned int check_update_info_hk_lfr_mode( unsigned char mode )
864 {
896 {
865 unsigned int status;
897 unsigned int status;
866
898
867 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
899 if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL)
868 || (mode == LFR_MODE_BURST)
900 || (mode == LFR_MODE_BURST)
869 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
901 || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2))
870 {
902 {
871 status = LFR_SUCCESSFUL;
903 status = LFR_SUCCESSFUL;
872 }
904 }
873 else
905 else
874 {
906 {
875 status = LFR_DEFAULT;
907 status = LFR_DEFAULT;
876 }
908 }
877
909
878 return status;
910 return status;
879 }
911 }
880
912
881 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
913 unsigned int check_update_info_hk_tds_mode( unsigned char mode )
882 {
914 {
883 unsigned int status;
915 unsigned int status;
884
916
885 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
917 if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL)
886 || (mode == TDS_MODE_BURST)
918 || (mode == TDS_MODE_BURST)
887 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
919 || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2)
888 || (mode == TDS_MODE_LFM))
920 || (mode == TDS_MODE_LFM))
889 {
921 {
890 status = LFR_SUCCESSFUL;
922 status = LFR_SUCCESSFUL;
891 }
923 }
892 else
924 else
893 {
925 {
894 status = LFR_DEFAULT;
926 status = LFR_DEFAULT;
895 }
927 }
896
928
897 return status;
929 return status;
898 }
930 }
899
931
900 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
932 unsigned int check_update_info_hk_thr_mode( unsigned char mode )
901 {
933 {
902 unsigned int status;
934 unsigned int status;
903
935
904 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
936 if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL)
905 || (mode == THR_MODE_BURST))
937 || (mode == THR_MODE_BURST))
906 {
938 {
907 status = LFR_SUCCESSFUL;
939 status = LFR_SUCCESSFUL;
908 }
940 }
909 else
941 else
910 {
942 {
911 status = LFR_DEFAULT;
943 status = LFR_DEFAULT;
912 }
944 }
913
945
914 return status;
946 return status;
915 }
947 }
916
948
949 void set_hk_lfr_sc_rw_f_flag( unsigned char wheel, unsigned char freq, float value )
950 {
951 unsigned char flag;
952 unsigned char flagPosInByte;
953 unsigned char newFlag;
954 unsigned char flagMask;
955
956 // if the frequency value is not a number, the flag is set to 0 and the frequency RWx_Fy is not filtered
957 if (isnan(value))
958 {
959 flag = 0;
960 }
961 else
962 {
963 flag = 1;
964 }
965
966 switch(wheel)
967 {
968 case 1:
969 flagPosInByte = 8 - freq;
970 flagMask = ~(1 << flagPosInByte);
971 newFlag = flag << flagPosInByte;
972 housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = (housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags & flagMask) | newFlag;
973 break;
974 case 2:
975 flagPosInByte = 4 - freq;
976 flagMask = ~(1 << flagPosInByte);
977 newFlag = flag << flagPosInByte;
978 housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags = (housekeeping_packet.hk_lfr_sc_rw1_rw2_f_flags & flagMask) | newFlag;
979 break;
980 case 3:
981 flagPosInByte = 8 - freq;
982 flagMask = ~(1 << flagPosInByte);
983 newFlag = flag << flagPosInByte;
984 housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = (housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags & flagMask) | newFlag;
985 break;
986 case 4:
987 flagPosInByte = 4 - freq;
988 flagMask = ~(1 << flagPosInByte);
989 newFlag = flag << flagPosInByte;
990 housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags = (housekeeping_packet.hk_lfr_sc_rw3_rw4_f_flags & flagMask) | newFlag;
991 break;
992 default:
993 break;
994 }
995 }
996
997 void set_hk_lfr_sc_rw_f_flags( void )
998 {
999 // RW1
1000 set_hk_lfr_sc_rw_f_flag( 1, 1, rw_f.cp_rpw_sc_rw1_f1 );
1001 set_hk_lfr_sc_rw_f_flag( 1, 2, rw_f.cp_rpw_sc_rw1_f2 );
1002 set_hk_lfr_sc_rw_f_flag( 1, 3, rw_f.cp_rpw_sc_rw1_f3 );
1003 set_hk_lfr_sc_rw_f_flag( 1, 4, rw_f.cp_rpw_sc_rw1_f4 );
1004
1005 // RW2
1006 set_hk_lfr_sc_rw_f_flag( 2, 1, rw_f.cp_rpw_sc_rw2_f1 );
1007 set_hk_lfr_sc_rw_f_flag( 2, 2, rw_f.cp_rpw_sc_rw2_f2 );
1008 set_hk_lfr_sc_rw_f_flag( 2, 3, rw_f.cp_rpw_sc_rw2_f3 );
1009 set_hk_lfr_sc_rw_f_flag( 2, 4, rw_f.cp_rpw_sc_rw2_f4 );
1010
1011 // RW3
1012 set_hk_lfr_sc_rw_f_flag( 3, 1, rw_f.cp_rpw_sc_rw3_f1 );
1013 set_hk_lfr_sc_rw_f_flag( 3, 2, rw_f.cp_rpw_sc_rw3_f2 );
1014 set_hk_lfr_sc_rw_f_flag( 3, 3, rw_f.cp_rpw_sc_rw3_f3 );
1015 set_hk_lfr_sc_rw_f_flag( 3, 4, rw_f.cp_rpw_sc_rw3_f4 );
1016
1017 // RW4
1018 set_hk_lfr_sc_rw_f_flag( 4, 1, rw_f.cp_rpw_sc_rw4_f1 );
1019 set_hk_lfr_sc_rw_f_flag( 4, 2, rw_f.cp_rpw_sc_rw4_f2 );
1020 set_hk_lfr_sc_rw_f_flag( 4, 3, rw_f.cp_rpw_sc_rw4_f3 );
1021 set_hk_lfr_sc_rw_f_flag( 4, 4, rw_f.cp_rpw_sc_rw4_f4 );
1022 }
1023
917 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC )
1024 void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC )
918 {
1025 {
919 /** This function get the reaction wheels frequencies in the incoming TC_LFR_UPDATE_INFO and copy the values locally.
1026 /** This function get the reaction wheels frequencies in the incoming TC_LFR_UPDATE_INFO and copy the values locally.
920 *
1027 *
921 * @param TC points to the TeleCommand packet that is being processed
1028 * @param TC points to the TeleCommand packet that is being processed
922 *
1029 *
923 */
1030 */
924
1031
925 unsigned char * bytePosPtr; // pointer to the beginning of the incoming TC packet
1032 unsigned char * bytePosPtr; // pointer to the beginning of the incoming TC packet
926
1033
927 bytePosPtr = (unsigned char *) &TC->packetID;
1034 bytePosPtr = (unsigned char *) &TC->packetID;
928
1035
929 // cp_rpw_sc_rw1_f1
1036 // rw1_f
930 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw1_f1,
1037 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1 ] );
931 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1 ] );
1038 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2 ] );
932
1039 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F3 ] );
933 // cp_rpw_sc_rw1_f2
1040 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw1_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F4 ] );
934 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw1_f2,
935 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2 ] );
936
1041
937 // cp_rpw_sc_rw2_f1
1042 // rw2_f
938 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw2_f1,
1043 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1 ] );
939 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1 ] );
1044 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2 ] );
940
1045 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F3 ] );
941 // cp_rpw_sc_rw2_f2
1046 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw2_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F4 ] );
942 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw2_f2,
943 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2 ] );
944
1047
945 // cp_rpw_sc_rw3_f1
1048 // rw3_f
946 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw3_f1,
1049 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1 ] );
947 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1 ] );
1050 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2 ] );
948
1051 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F3 ] );
949 // cp_rpw_sc_rw3_f2
1052 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw3_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F4 ] );
950 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw3_f2,
951 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2 ] );
952
1053
953 // cp_rpw_sc_rw4_f1
1054 // rw4_f
954 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw4_f1,
1055 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f1, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1 ] );
955 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1 ] );
1056 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f2, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2 ] );
1057 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f3, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F3 ] );
1058 copyFloatByChar( (unsigned char*) &rw_f.cp_rpw_sc_rw4_f4, (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F4 ] );
956
1059
957 // cp_rpw_sc_rw4_f2
1060 // test each reaction wheel frequency value. NaN means that the frequency is not filtered
958 copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw4_f2,
1061
959 (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2 ] );
1062
960 }
1063 }
961
1064
962 void setFBinMask( unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, unsigned char flag )
1065 void setFBinMask( unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, unsigned char flag )
963 {
1066 {
964 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
1067 /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received.
965 *
1068 *
966 * @param fbins_mask
1069 * @param fbins_mask
967 * @param rw_f is the reaction wheel frequency to filter
1070 * @param rw_f is the reaction wheel frequency to filter
968 * @param delta_f is the frequency step between the frequency bins, it depends on the frequency channel
1071 * @param delta_f is the frequency step between the frequency bins, it depends on the frequency channel
969 * @param flag [true] filtering enabled [false] filtering disabled
1072 * @param flag [true] filtering enabled [false] filtering disabled
970 *
1073 *
971 * @return void
1074 * @return void
972 *
1075 *
973 */
1076 */
974
1077
975 float f_RW_min;
1078 float f_RW_min;
976 float f_RW_MAX;
1079 float f_RW_MAX;
977 float fi_min;
1080 float fi_min;
978 float fi_MAX;
1081 float fi_MAX;
979 float fi;
1082 float fi;
980 float deltaBelow;
1083 float deltaBelow;
981 float deltaAbove;
1084 float deltaAbove;
982 int binBelow;
1085 int binBelow;
983 int binAbove;
1086 int binAbove;
984 int closestBin;
1087 int closestBin;
985 unsigned int whichByte;
1088 unsigned int whichByte;
986 int selectedByte;
1089 int selectedByte;
987 int bin;
1090 int bin;
988 int binToRemove[3];
1091 int binToRemove[3];
989 int k;
1092 int k;
990
1093
991 whichByte = 0;
1094 whichByte = 0;
992 bin = 0;
1095 bin = 0;
993
1096
994 binToRemove[0] = -1;
1097 binToRemove[0] = -1;
995 binToRemove[1] = -1;
1098 binToRemove[1] = -1;
996 binToRemove[2] = -1;
1099 binToRemove[2] = -1;
997
1100
998 // compute the frequency range to filter [ rw_f - delta_f/2; rw_f + delta_f/2 ]
1101 // compute the frequency range to filter [ rw_f - delta_f/2; rw_f + delta_f/2 ]
999 f_RW_min = rw_f - filterPar.sy_lfr_sc_rw_delta_f / 2.;
1102 f_RW_min = rw_f - filterPar.sy_lfr_sc_rw_delta_f / 2.;
1000 f_RW_MAX = rw_f + filterPar.sy_lfr_sc_rw_delta_f / 2.;
1103 f_RW_MAX = rw_f + filterPar.sy_lfr_sc_rw_delta_f / 2.;
1001
1104
1002 // compute the index of the frequency bin immediately below rw_f
1105 // compute the index of the frequency bin immediately below rw_f
1003 binBelow = (int) ( floor( ((double) rw_f) / ((double) deltaFreq)) );
1106 binBelow = (int) ( floor( ((double) rw_f) / ((double) deltaFreq)) );
1004 deltaBelow = rw_f - binBelow * deltaFreq;
1107 deltaBelow = rw_f - binBelow * deltaFreq;
1005
1108
1006 // compute the index of the frequency bin immediately above rw_f
1109 // compute the index of the frequency bin immediately above rw_f
1007 binAbove = (int) ( ceil( ((double) rw_f) / ((double) deltaFreq)) );
1110 binAbove = (int) ( ceil( ((double) rw_f) / ((double) deltaFreq)) );
1008 deltaAbove = binAbove * deltaFreq - rw_f;
1111 deltaAbove = binAbove * deltaFreq - rw_f;
1009
1112
1010 // search the closest bin
1113 // search the closest bin
1011 if (deltaAbove > deltaBelow)
1114 if (deltaAbove > deltaBelow)
1012 {
1115 {
1013 closestBin = binBelow;
1116 closestBin = binBelow;
1014 }
1117 }
1015 else
1118 else
1016 {
1119 {
1017 closestBin = binAbove;
1120 closestBin = binAbove;
1018 }
1121 }
1019
1122
1020 // compute the fi interval [fi - Delta_f * 0.285, fi + Delta_f * 0.285]
1123 // compute the fi interval [fi - Delta_f * 0.285, fi + Delta_f * 0.285]
1021 fi = closestBin * deltaFreq;
1124 fi = closestBin * deltaFreq;
1022
1125
1023 fi_min = fi - (deltaFreq * 0.285);
1126 fi_min = fi - (deltaFreq * 0.285);
1024 if ( fi_min < 0 )
1127 if ( fi_min < 0 )
1025 {
1128 {
1026 fi_min = 0;
1129 fi_min = 0;
1027 }
1130 }
1028 else if ( fi_min > (deltaFreq*127) )
1131 else if ( fi_min > (deltaFreq*127) )
1029 {
1132 {
1030 fi_min = -1;
1133 fi_min = -1;
1031 }
1134 }
1032
1135
1033 fi_MAX = fi + (deltaFreq * 0.285);
1136 fi_MAX = fi + (deltaFreq * 0.285);
1034 if ( fi_MAX > (deltaFreq*127) )
1137 if ( fi_MAX > (deltaFreq*127) )
1035 {
1138 {
1036 fi_MAX = -1;
1139 fi_MAX = -1;
1037 }
1140 }
1038
1141
1039 // 1. IF [ f_RW_min, f_RW_MAX] is included in [ fi_min; fi_MAX ]
1142 // 1. IF [ f_RW_min, f_RW_MAX] is included in [ fi_min; fi_MAX ]
1040 // => remove f_(i), f_(i-1) and f_(i+1)
1143 // => remove f_(i), f_(i-1) and f_(i+1)
1041 if ( ( f_RW_min > fi_min ) && ( f_RW_MAX < fi_MAX ) )
1144 if ( ( f_RW_min > fi_min ) && ( f_RW_MAX < fi_MAX ) )
1042 {
1145 {
1043 binToRemove[0] = closestBin - 1;
1146 binToRemove[0] = closestBin - 1;
1044 binToRemove[1] = closestBin;
1147 binToRemove[1] = closestBin;
1045 binToRemove[2] = closestBin + 1;
1148 binToRemove[2] = closestBin + 1;
1046 }
1149 }
1047 // 2. ELSE
1150 // 2. ELSE
1048 // => remove the two f_(i) which are around f_RW
1151 // => remove the two f_(i) which are around f_RW
1049 else
1152 else
1050 {
1153 {
1051 binToRemove[0] = binBelow;
1154 binToRemove[0] = binBelow;
1052 binToRemove[1] = binAbove;
1155 binToRemove[1] = binAbove;
1053 binToRemove[2] = -1;
1156 binToRemove[2] = -1;
1054 }
1157 }
1055
1158
1056 for (k = 0; k <= 3; k++)
1159 for (k = 0; k <= 3; k++)
1057 {
1160 {
1058 bin = binToRemove[k];
1161 bin = binToRemove[k];
1059 if ( (bin >= 0) && (bin <= 127) )
1162 if ( (bin >= 0) && (bin <= 127) )
1060 {
1163 {
1061 if (flag == 1)
1164 if (flag == 1)
1062 {
1165 {
1063 whichByte = (bin >> 3); // division by 8
1166 whichByte = (bin >> 3); // division by 8
1064 selectedByte = ( 1 << (bin - (whichByte * 8)) );
1167 selectedByte = ( 1 << (bin - (whichByte * 8)) );
1065 fbins_mask[15 - whichByte] = fbins_mask[15 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets
1168 fbins_mask[15 - whichByte] = fbins_mask[15 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets
1066 }
1169 }
1067 }
1170 }
1068 }
1171 }
1069 }
1172 }
1070
1173
1071 void build_sy_lfr_rw_mask( unsigned int channel )
1174 void build_sy_lfr_rw_mask( unsigned int channel )
1072 {
1175 {
1073 unsigned char local_rw_fbins_mask[16];
1176 unsigned char local_rw_fbins_mask[16];
1074 unsigned char *maskPtr;
1177 unsigned char *maskPtr;
1075 double deltaF;
1178 double deltaF;
1076 unsigned k;
1179 unsigned k;
1077
1180
1078 k = 0;
1181 k = 0;
1079
1182
1080 maskPtr = NULL;
1183 maskPtr = NULL;
1081 deltaF = 1.;
1184 deltaF = 1.;
1082
1185
1083 switch (channel)
1186 switch (channel)
1084 {
1187 {
1085 case 0:
1188 case 0:
1086 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f0_word1;
1189 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f0_word1;
1087 deltaF = 96.;
1190 deltaF = 96.;
1088 break;
1191 break;
1089 case 1:
1192 case 1:
1090 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f1_word1;
1193 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f1_word1;
1091 deltaF = 16.;
1194 deltaF = 16.;
1092 break;
1195 break;
1093 case 2:
1196 case 2:
1094 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f2_word1;
1197 maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f2_word1;
1095 deltaF = 1.;
1198 deltaF = 1.;
1096 break;
1199 break;
1097 default:
1200 default:
1098 break;
1201 break;
1099 }
1202 }
1100
1203
1101 for (k = 0; k < 16; k++)
1204 for (k = 0; k < 16; k++)
1102 {
1205 {
1103 local_rw_fbins_mask[k] = 0xff;
1206 local_rw_fbins_mask[k] = 0xff;
1104 }
1207 }
1105
1208
1106 // RW1 F1
1209 // RW1
1107 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x80) >> 7 ); // [1000 0000]
1210 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f1, deltaF, (cp_rpw_sc_rw1_rw2_f_flags & 0x80) >> 7 ); // [1000 0000]
1108
1211 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f2, deltaF, (cp_rpw_sc_rw1_rw2_f_flags & 0x40) >> 6 ); // [0100 0000]
1109 // RW1 F2
1212 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f1, deltaF, (cp_rpw_sc_rw1_rw2_f_flags & 0x20) >> 5 ); // [0010 0000]
1110 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x40) >> 6 ); // [0100 0000]
1213 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw1_f2, deltaF, (cp_rpw_sc_rw1_rw2_f_flags & 0x10) >> 4 ); // [0001 0000]
1111
1214
1112 // RW2 F1
1215 // RW2
1113 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x20) >> 5 ); // [0010 0000]
1216 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f1, deltaF, (cp_rpw_sc_rw1_rw2_f_flags & 0x08) >> 3 ); // [0000 1000]
1114
1217 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f2, deltaF, (cp_rpw_sc_rw1_rw2_f_flags & 0x04) >> 2 ); // [0000 0100]
1115 // RW2 F2
1218 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f1, deltaF, (cp_rpw_sc_rw1_rw2_f_flags & 0x02) >> 1 ); // [0000 0010]
1116 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x10) >> 4 ); // [0001 0000]
1219 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw2_f2, deltaF, (cp_rpw_sc_rw1_rw2_f_flags & 0x01) ); // [0000 0001]
1117
1220
1118 // RW3 F1
1221 // RW3
1119 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x08) >> 3 ); // [0000 1000]
1222 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f1, deltaF, (cp_rpw_sc_rw3_rw4_f_flags & 0x80) >> 7 ); // [1000 0000]
1120
1223 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f2, deltaF, (cp_rpw_sc_rw3_rw4_f_flags & 0x40) >> 6 ); // [0100 0000]
1121 // RW3 F2
1224 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f1, deltaF, (cp_rpw_sc_rw3_rw4_f_flags & 0x20) >> 5 ); // [0010 0000]
1122 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x04) >> 2 ); // [0000 0100]
1225 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw3_f2, deltaF, (cp_rpw_sc_rw3_rw4_f_flags & 0x10) >> 4 ); // [0001 0000]
1123
1226
1124 // RW4 F1
1227 // RW4
1125 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw4_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x02) >> 1 ); // [0000 0010]
1228 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f1, deltaF, (cp_rpw_sc_rw3_rw4_f_flags & 0x08) >> 3 ); // [0000 1000]
1126
1229 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f2, deltaF, (cp_rpw_sc_rw3_rw4_f_flags & 0x04) >> 2 ); // [0000 0100]
1127 // RW4 F2
1230 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f1, deltaF, (cp_rpw_sc_rw3_rw4_f_flags & 0x02) >> 1 ); // [0000 0010]
1128 setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw4_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x01) ); // [0000 0001]
1231 setFBinMask( local_rw_fbins_mask, rw_f.cp_rpw_sc_rw4_f2, deltaF, (cp_rpw_sc_rw3_rw4_f_flags & 0x03) ); // [0000 0001]
1129
1232
1130 // update the value of the fbins related to reaction wheels frequency filtering
1233 // update the value of the fbins related to reaction wheels frequency filtering
1131 if (maskPtr != NULL)
1234 if (maskPtr != NULL)
1132 {
1235 {
1133 for (k = 0; k < 16; k++)
1236 for (k = 0; k < 16; k++)
1134 {
1237 {
1135 maskPtr[k] = local_rw_fbins_mask[k];
1238 maskPtr[k] = local_rw_fbins_mask[k];
1136 }
1239 }
1137 }
1240 }
1138 }
1241 }
1139
1242
1140 void build_sy_lfr_rw_masks( void )
1243 void build_sy_lfr_rw_masks( void )
1141 {
1244 {
1142 build_sy_lfr_rw_mask( 0 );
1245 build_sy_lfr_rw_mask( 0 );
1143 build_sy_lfr_rw_mask( 1 );
1246 build_sy_lfr_rw_mask( 1 );
1144 build_sy_lfr_rw_mask( 2 );
1247 build_sy_lfr_rw_mask( 2 );
1145
1248
1146 merge_fbins_masks();
1249 merge_fbins_masks();
1147 }
1250 }
1148
1251
1149 void merge_fbins_masks( void )
1252 void merge_fbins_masks( void )
1150 {
1253 {
1151 unsigned char k;
1254 unsigned char k;
1152
1255
1153 unsigned char *fbins_f0;
1256 unsigned char *fbins_f0;
1154 unsigned char *fbins_f1;
1257 unsigned char *fbins_f1;
1155 unsigned char *fbins_f2;
1258 unsigned char *fbins_f2;
1156 unsigned char *rw_mask_f0;
1259 unsigned char *rw_mask_f0;
1157 unsigned char *rw_mask_f1;
1260 unsigned char *rw_mask_f1;
1158 unsigned char *rw_mask_f2;
1261 unsigned char *rw_mask_f2;
1159
1262
1160 fbins_f0 = parameter_dump_packet.sy_lfr_fbins_f0_word1;
1263 fbins_f0 = parameter_dump_packet.sy_lfr_fbins_f0_word1;
1161 fbins_f1 = parameter_dump_packet.sy_lfr_fbins_f1_word1;
1264 fbins_f1 = parameter_dump_packet.sy_lfr_fbins_f1_word1;
1162 fbins_f2 = parameter_dump_packet.sy_lfr_fbins_f2_word1;
1265 fbins_f2 = parameter_dump_packet.sy_lfr_fbins_f2_word1;
1163 rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask_f0_word1;
1266 rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask_f0_word1;
1164 rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask_f1_word1;
1267 rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask_f1_word1;
1165 rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask_f2_word1;
1268 rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask_f2_word1;
1166
1269
1167 for( k=0; k < 16; k++ )
1270 for( k=0; k < 16; k++ )
1168 {
1271 {
1169 fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k];
1272 fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k];
1170 fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k];
1273 fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k];
1171 fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k];
1274 fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k];
1172 }
1275 }
1173 }
1276 }
1174
1277
1175 //***********
1278 //***********
1176 // FBINS MASK
1279 // FBINS MASK
1177
1280
1178 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC )
1281 int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC )
1179 {
1282 {
1180 int status;
1283 int status;
1181 unsigned int k;
1284 unsigned int k;
1182 unsigned char *fbins_mask_dump;
1285 unsigned char *fbins_mask_dump;
1183 unsigned char *fbins_mask_TC;
1286 unsigned char *fbins_mask_TC;
1184
1287
1185 status = LFR_SUCCESSFUL;
1288 status = LFR_SUCCESSFUL;
1186
1289
1187 fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1;
1290 fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1;
1188 fbins_mask_TC = TC->dataAndCRC;
1291 fbins_mask_TC = TC->dataAndCRC;
1189
1292
1190 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1293 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1191 {
1294 {
1192 fbins_mask_dump[k] = fbins_mask_TC[k];
1295 fbins_mask_dump[k] = fbins_mask_TC[k];
1193 }
1296 }
1194
1297
1195 return status;
1298 return status;
1196 }
1299 }
1197
1300
1198 //***************************
1301 //***************************
1199 // TC_LFR_LOAD_PAS_FILTER_PAR
1302 // TC_LFR_LOAD_PAS_FILTER_PAR
1200
1303
1201 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
1304 int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id )
1202 {
1305 {
1203 int flag;
1306 int flag;
1204 rtems_status_code status;
1307 rtems_status_code status;
1205
1308
1206 unsigned char sy_lfr_pas_filter_enabled;
1309 unsigned char sy_lfr_pas_filter_enabled;
1207 unsigned char sy_lfr_pas_filter_modulus;
1310 unsigned char sy_lfr_pas_filter_modulus;
1208 float sy_lfr_pas_filter_tbad;
1311 float sy_lfr_pas_filter_tbad;
1209 unsigned char sy_lfr_pas_filter_offset;
1312 unsigned char sy_lfr_pas_filter_offset;
1210 float sy_lfr_pas_filter_shift;
1313 float sy_lfr_pas_filter_shift;
1211 float sy_lfr_sc_rw_delta_f;
1314 float sy_lfr_sc_rw_delta_f;
1212 char *parPtr;
1315 char *parPtr;
1213
1316
1214 flag = LFR_SUCCESSFUL;
1317 flag = LFR_SUCCESSFUL;
1215 sy_lfr_pas_filter_tbad = 0.0;
1318 sy_lfr_pas_filter_tbad = 0.0;
1216 sy_lfr_pas_filter_shift = 0.0;
1319 sy_lfr_pas_filter_shift = 0.0;
1217 sy_lfr_sc_rw_delta_f = 0.0;
1320 sy_lfr_sc_rw_delta_f = 0.0;
1218 parPtr = NULL;
1321 parPtr = NULL;
1219
1322
1220 //***************
1323 //***************
1221 // get parameters
1324 // get parameters
1222 sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & 0x01; // [0000 0001]
1325 sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & 0x01; // [0000 0001]
1223 sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
1326 sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ];
1224 copyFloatByChar(
1327 copyFloatByChar(
1225 (unsigned char*) &sy_lfr_pas_filter_tbad,
1328 (unsigned char*) &sy_lfr_pas_filter_tbad,
1226 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ]
1329 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ]
1227 );
1330 );
1228 sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
1331 sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ];
1229 copyFloatByChar(
1332 copyFloatByChar(
1230 (unsigned char*) &sy_lfr_pas_filter_shift,
1333 (unsigned char*) &sy_lfr_pas_filter_shift,
1231 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ]
1334 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ]
1232 );
1335 );
1233 copyFloatByChar(
1336 copyFloatByChar(
1234 (unsigned char*) &sy_lfr_sc_rw_delta_f,
1337 (unsigned char*) &sy_lfr_sc_rw_delta_f,
1235 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ]
1338 (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ]
1236 );
1339 );
1237
1340
1238 //******************
1341 //******************
1239 // CHECK CONSISTENCY
1342 // CHECK CONSISTENCY
1240
1343
1241 //**************************
1344 //**************************
1242 // sy_lfr_pas_filter_enabled
1345 // sy_lfr_pas_filter_enabled
1243 // nothing to check, value is 0 or 1
1346 // nothing to check, value is 0 or 1
1244
1347
1245 //**************************
1348 //**************************
1246 // sy_lfr_pas_filter_modulus
1349 // sy_lfr_pas_filter_modulus
1247 if ( (sy_lfr_pas_filter_modulus < 4) || (sy_lfr_pas_filter_modulus > 8) )
1350 if ( (sy_lfr_pas_filter_modulus < 4) || (sy_lfr_pas_filter_modulus > 8) )
1248 {
1351 {
1249 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS+10, sy_lfr_pas_filter_modulus );
1352 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS+10, sy_lfr_pas_filter_modulus );
1250 flag = WRONG_APP_DATA;
1353 flag = WRONG_APP_DATA;
1251 }
1354 }
1252
1355
1253 //***********************
1356 //***********************
1254 // sy_lfr_pas_filter_tbad
1357 // sy_lfr_pas_filter_tbad
1255 if ( (sy_lfr_pas_filter_tbad < 0.0) || (sy_lfr_pas_filter_tbad > 4.0) )
1358 if ( (sy_lfr_pas_filter_tbad < 0.0) || (sy_lfr_pas_filter_tbad > 4.0) )
1256 {
1359 {
1257 parPtr = (char*) &sy_lfr_pas_filter_tbad;
1360 parPtr = (char*) &sy_lfr_pas_filter_tbad;
1258 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD+10, parPtr[3] );
1361 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD+10, parPtr[3] );
1259 flag = WRONG_APP_DATA;
1362 flag = WRONG_APP_DATA;
1260 }
1363 }
1261
1364
1262 //*************************
1365 //*************************
1263 // sy_lfr_pas_filter_offset
1366 // sy_lfr_pas_filter_offset
1264 if (flag == LFR_SUCCESSFUL)
1367 if (flag == LFR_SUCCESSFUL)
1265 {
1368 {
1266 if ( (sy_lfr_pas_filter_offset < 0) || (sy_lfr_pas_filter_offset > 7) )
1369 if ( (sy_lfr_pas_filter_offset < 0) || (sy_lfr_pas_filter_offset > 7) )
1267 {
1370 {
1268 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET+10, sy_lfr_pas_filter_offset );
1371 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET+10, sy_lfr_pas_filter_offset );
1269 flag = WRONG_APP_DATA;
1372 flag = WRONG_APP_DATA;
1270 }
1373 }
1271 }
1374 }
1272
1375
1273 //************************
1376 //************************
1274 // sy_lfr_pas_filter_shift
1377 // sy_lfr_pas_filter_shift
1275 if ( (sy_lfr_pas_filter_shift < 0.0) || (sy_lfr_pas_filter_shift > 1.0) )
1378 if ( (sy_lfr_pas_filter_shift < 0.0) || (sy_lfr_pas_filter_shift > 1.0) )
1276 {
1379 {
1277 parPtr = (char*) &sy_lfr_pas_filter_shift;
1380 parPtr = (char*) &sy_lfr_pas_filter_shift;
1278 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT+10, parPtr[3] );
1381 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT+10, parPtr[3] );
1279 flag = WRONG_APP_DATA;
1382 flag = WRONG_APP_DATA;
1280 }
1383 }
1281
1384
1282 //*********************
1385 //*********************
1283 // sy_lfr_sc_rw_delta_f
1386 // sy_lfr_sc_rw_delta_f
1284 // nothing to check, no default value in the ICD
1387 // nothing to check, no default value in the ICD
1285
1388
1286 return flag;
1389 return flag;
1287 }
1390 }
1288
1391
1289 //**************
1392 //**************
1290 // KCOEFFICIENTS
1393 // KCOEFFICIENTS
1291 int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id )
1394 int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id )
1292 {
1395 {
1293 unsigned int kcoeff;
1396 unsigned int kcoeff;
1294 unsigned short sy_lfr_kcoeff_frequency;
1397 unsigned short sy_lfr_kcoeff_frequency;
1295 unsigned short bin;
1398 unsigned short bin;
1296 unsigned short *freqPtr;
1399 unsigned short *freqPtr;
1297 float *kcoeffPtr_norm;
1400 float *kcoeffPtr_norm;
1298 float *kcoeffPtr_sbm;
1401 float *kcoeffPtr_sbm;
1299 int status;
1402 int status;
1300 unsigned char *kcoeffLoadPtr;
1403 unsigned char *kcoeffLoadPtr;
1301 unsigned char *kcoeffNormPtr;
1404 unsigned char *kcoeffNormPtr;
1302 unsigned char *kcoeffSbmPtr_a;
1405 unsigned char *kcoeffSbmPtr_a;
1303 unsigned char *kcoeffSbmPtr_b;
1406 unsigned char *kcoeffSbmPtr_b;
1304
1407
1305 status = LFR_SUCCESSFUL;
1408 status = LFR_SUCCESSFUL;
1306
1409
1307 kcoeffPtr_norm = NULL;
1410 kcoeffPtr_norm = NULL;
1308 kcoeffPtr_sbm = NULL;
1411 kcoeffPtr_sbm = NULL;
1309 bin = 0;
1412 bin = 0;
1310
1413
1311 freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY];
1414 freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY];
1312 sy_lfr_kcoeff_frequency = *freqPtr;
1415 sy_lfr_kcoeff_frequency = *freqPtr;
1313
1416
1314 if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM )
1417 if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM )
1315 {
1418 {
1316 PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency)
1419 PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency)
1317 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1,
1420 status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1,
1318 TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB
1421 TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB
1319 status = LFR_DEFAULT;
1422 status = LFR_DEFAULT;
1320 }
1423 }
1321 else
1424 else
1322 {
1425 {
1323 if ( ( sy_lfr_kcoeff_frequency >= 0 )
1426 if ( ( sy_lfr_kcoeff_frequency >= 0 )
1324 && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) )
1427 && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) )
1325 {
1428 {
1326 kcoeffPtr_norm = k_coeff_intercalib_f0_norm;
1429 kcoeffPtr_norm = k_coeff_intercalib_f0_norm;
1327 kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm;
1430 kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm;
1328 bin = sy_lfr_kcoeff_frequency;
1431 bin = sy_lfr_kcoeff_frequency;
1329 }
1432 }
1330 else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 )
1433 else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 )
1331 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) )
1434 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) )
1332 {
1435 {
1333 kcoeffPtr_norm = k_coeff_intercalib_f1_norm;
1436 kcoeffPtr_norm = k_coeff_intercalib_f1_norm;
1334 kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm;
1437 kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm;
1335 bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0;
1438 bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0;
1336 }
1439 }
1337 else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) )
1440 else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) )
1338 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) )
1441 && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) )
1339 {
1442 {
1340 kcoeffPtr_norm = k_coeff_intercalib_f2;
1443 kcoeffPtr_norm = k_coeff_intercalib_f2;
1341 kcoeffPtr_sbm = NULL;
1444 kcoeffPtr_sbm = NULL;
1342 bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1);
1445 bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1);
1343 }
1446 }
1344 }
1447 }
1345
1448
1346 if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products
1449 if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products
1347 {
1450 {
1348 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1451 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1349 {
1452 {
1350 // destination
1453 // destination
1351 kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ];
1454 kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ];
1352 // source
1455 // source
1353 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
1456 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
1354 // copy source to destination
1457 // copy source to destination
1355 copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr );
1458 copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr );
1356 }
1459 }
1357 }
1460 }
1358
1461
1359 if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products
1462 if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products
1360 {
1463 {
1361 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1464 for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++)
1362 {
1465 {
1363 // destination
1466 // destination
1364 kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ];
1467 kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ];
1365 kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ];
1468 kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ];
1366 // source
1469 // source
1367 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
1470 kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff];
1368 // copy source to destination
1471 // copy source to destination
1369 copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr );
1472 copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr );
1370 copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr );
1473 copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr );
1371 }
1474 }
1372 }
1475 }
1373
1476
1374 // print_k_coeff();
1477 // print_k_coeff();
1375
1478
1376 return status;
1479 return status;
1377 }
1480 }
1378
1481
1379 void copyFloatByChar( unsigned char *destination, unsigned char *source )
1482 void copyFloatByChar( unsigned char *destination, unsigned char *source )
1380 {
1483 {
1381 destination[0] = source[0];
1484 destination[0] = source[0];
1382 destination[1] = source[1];
1485 destination[1] = source[1];
1383 destination[2] = source[2];
1486 destination[2] = source[2];
1384 destination[3] = source[3];
1487 destination[3] = source[3];
1385 }
1488 }
1386
1489
1387 void floatToChar( float value, unsigned char* ptr)
1490 void floatToChar( float value, unsigned char* ptr)
1388 {
1491 {
1389 unsigned char* valuePtr;
1492 unsigned char* valuePtr;
1390
1493
1391 valuePtr = (unsigned char*) &value;
1494 valuePtr = (unsigned char*) &value;
1392 ptr[0] = valuePtr[0];
1495 ptr[0] = valuePtr[0];
1393 ptr[1] = valuePtr[0];
1496 ptr[1] = valuePtr[0];
1394 ptr[2] = valuePtr[0];
1497 ptr[2] = valuePtr[0];
1395 ptr[3] = valuePtr[0];
1498 ptr[3] = valuePtr[0];
1396 }
1499 }
1397
1500
1398 //**********
1501 //**********
1399 // init dump
1502 // init dump
1400
1503
1401 void init_parameter_dump( void )
1504 void init_parameter_dump( void )
1402 {
1505 {
1403 /** This function initialize the parameter_dump_packet global variable with default values.
1506 /** This function initialize the parameter_dump_packet global variable with default values.
1404 *
1507 *
1405 */
1508 */
1406
1509
1407 unsigned int k;
1510 unsigned int k;
1408
1511
1409 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
1512 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
1410 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1513 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
1411 parameter_dump_packet.reserved = CCSDS_RESERVED;
1514 parameter_dump_packet.reserved = CCSDS_RESERVED;
1412 parameter_dump_packet.userApplication = CCSDS_USER_APP;
1515 parameter_dump_packet.userApplication = CCSDS_USER_APP;
1413 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
1516 parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);
1414 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1517 parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;
1415 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1518 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1416 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1519 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1417 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
1520 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
1418 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
1521 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
1419 // DATA FIELD HEADER
1522 // DATA FIELD HEADER
1420 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1523 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1421 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
1524 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
1422 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
1525 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
1423 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
1526 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
1424 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1527 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1425 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1528 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1426 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1529 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1427 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
1530 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
1428 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1531 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1429 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
1532 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
1430 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
1533 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
1431
1534
1432 //******************
1535 //******************
1433 // COMMON PARAMETERS
1536 // COMMON PARAMETERS
1434 parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0;
1537 parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0;
1435 parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1;
1538 parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1;
1436
1539
1437 //******************
1540 //******************
1438 // NORMAL PARAMETERS
1541 // NORMAL PARAMETERS
1439 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8);
1542 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8);
1440 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L );
1543 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L );
1441 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8);
1544 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8);
1442 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P );
1545 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P );
1443 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8);
1546 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8);
1444 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P );
1547 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P );
1445 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0;
1548 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0;
1446 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1;
1549 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1;
1447 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3;
1550 parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3;
1448
1551
1449 //*****************
1552 //*****************
1450 // BURST PARAMETERS
1553 // BURST PARAMETERS
1451 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
1554 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
1452 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
1555 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
1453
1556
1454 //****************
1557 //****************
1455 // SBM1 PARAMETERS
1558 // SBM1 PARAMETERS
1456 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
1559 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
1457 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
1560 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
1458
1561
1459 //****************
1562 //****************
1460 // SBM2 PARAMETERS
1563 // SBM2 PARAMETERS
1461 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
1564 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
1462 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
1565 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
1463
1566
1464 //************
1567 //************
1465 // FBINS MASKS
1568 // FBINS MASKS
1466 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1569 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1467 {
1570 {
1468 parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff;
1571 parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff;
1469 }
1572 }
1470
1573
1471 // PAS FILTER PARAMETERS
1574 //******************
1575 // FILTER PARAMETERS
1472 parameter_dump_packet.pa_rpw_spare8_2 = 0x00;
1576 parameter_dump_packet.pa_rpw_spare8_2 = 0x00;
1473 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = 0x00;
1577 parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = 0x00;
1474 parameter_dump_packet.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
1578 parameter_dump_packet.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
1475 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_TBAD, parameter_dump_packet.sy_lfr_pas_filter_tbad );
1579 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_TBAD, parameter_dump_packet.sy_lfr_pas_filter_tbad );
1476 parameter_dump_packet.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
1580 parameter_dump_packet.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
1477 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_SHIFT, parameter_dump_packet.sy_lfr_pas_filter_shift );
1581 floatToChar( DEFAULT_SY_LFR_PAS_FILTER_SHIFT, parameter_dump_packet.sy_lfr_pas_filter_shift );
1478 floatToChar( DEFAULT_SY_LFR_SC_RW_DELTA_F, parameter_dump_packet.sy_lfr_sc_rw_delta_f );
1582 floatToChar( DEFAULT_SY_LFR_SC_RW_DELTA_F, parameter_dump_packet.sy_lfr_sc_rw_delta_f );
1479
1583
1584 // RW1_K
1585 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw1_k1);
1586 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw1_k2);
1587 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw1_k3);
1588 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw1_k4);
1589 // RW2_K
1590 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw2_k1);
1591 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw2_k2);
1592 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw2_k3);
1593 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw2_k4);
1594 // RW3_K
1595 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw3_k1);
1596 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw3_k2);
1597 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw3_k3);
1598 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw3_k4);
1599 // RW4_K
1600 floatToChar( DEFAULT_SY_LFR_RW_K1, parameter_dump_packet.sy_lfr_rw4_k1);
1601 floatToChar( DEFAULT_SY_LFR_RW_K2, parameter_dump_packet.sy_lfr_rw4_k2);
1602 floatToChar( DEFAULT_SY_LFR_RW_K3, parameter_dump_packet.sy_lfr_rw4_k3);
1603 floatToChar( DEFAULT_SY_LFR_RW_K4, parameter_dump_packet.sy_lfr_rw4_k4);
1604
1480 // LFR_RW_MASK
1605 // LFR_RW_MASK
1481 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1606 for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++)
1482 {
1607 {
1483 parameter_dump_packet.sy_lfr_rw_mask_f0_word1[k] = 0xff;
1608 parameter_dump_packet.sy_lfr_rw_mask_f0_word1[k] = 0xff;
1484 }
1609 }
1485 }
1610 }
1486
1611
1487 void init_kcoefficients_dump( void )
1612 void init_kcoefficients_dump( void )
1488 {
1613 {
1489 init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 );
1614 init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 );
1490 init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 );
1615 init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 );
1491
1616
1492 kcoefficient_node_1.previous = NULL;
1617 kcoefficient_node_1.previous = NULL;
1493 kcoefficient_node_1.next = NULL;
1618 kcoefficient_node_1.next = NULL;
1494 kcoefficient_node_1.sid = TM_CODE_K_DUMP;
1619 kcoefficient_node_1.sid = TM_CODE_K_DUMP;
1495 kcoefficient_node_1.coarseTime = 0x00;
1620 kcoefficient_node_1.coarseTime = 0x00;
1496 kcoefficient_node_1.fineTime = 0x00;
1621 kcoefficient_node_1.fineTime = 0x00;
1497 kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1;
1622 kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1;
1498 kcoefficient_node_1.status = 0x00;
1623 kcoefficient_node_1.status = 0x00;
1499
1624
1500 kcoefficient_node_2.previous = NULL;
1625 kcoefficient_node_2.previous = NULL;
1501 kcoefficient_node_2.next = NULL;
1626 kcoefficient_node_2.next = NULL;
1502 kcoefficient_node_2.sid = TM_CODE_K_DUMP;
1627 kcoefficient_node_2.sid = TM_CODE_K_DUMP;
1503 kcoefficient_node_2.coarseTime = 0x00;
1628 kcoefficient_node_2.coarseTime = 0x00;
1504 kcoefficient_node_2.fineTime = 0x00;
1629 kcoefficient_node_2.fineTime = 0x00;
1505 kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2;
1630 kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2;
1506 kcoefficient_node_2.status = 0x00;
1631 kcoefficient_node_2.status = 0x00;
1507 }
1632 }
1508
1633
1509 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr )
1634 void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr )
1510 {
1635 {
1511 unsigned int k;
1636 unsigned int k;
1512 unsigned int packetLength;
1637 unsigned int packetLength;
1513
1638
1514 packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header
1639 packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header
1515
1640
1516 kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID;
1641 kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID;
1517 kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID;
1642 kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID;
1518 kcoefficients_dump->reserved = CCSDS_RESERVED;
1643 kcoefficients_dump->reserved = CCSDS_RESERVED;
1519 kcoefficients_dump->userApplication = CCSDS_USER_APP;
1644 kcoefficients_dump->userApplication = CCSDS_USER_APP;
1520 kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);;
1645 kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);;
1521 kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;;
1646 kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;;
1522 kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1647 kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
1523 kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1648 kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
1524 kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8);
1649 kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8);
1525 kcoefficients_dump->packetLength[1] = (unsigned char) packetLength;
1650 kcoefficients_dump->packetLength[1] = (unsigned char) packetLength;
1526 // DATA FIELD HEADER
1651 // DATA FIELD HEADER
1527 kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1652 kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
1528 kcoefficients_dump->serviceType = TM_TYPE_K_DUMP;
1653 kcoefficients_dump->serviceType = TM_TYPE_K_DUMP;
1529 kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP;
1654 kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP;
1530 kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND;
1655 kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND;
1531 kcoefficients_dump->time[0] = 0x00;
1656 kcoefficients_dump->time[0] = 0x00;
1532 kcoefficients_dump->time[1] = 0x00;
1657 kcoefficients_dump->time[1] = 0x00;
1533 kcoefficients_dump->time[2] = 0x00;
1658 kcoefficients_dump->time[2] = 0x00;
1534 kcoefficients_dump->time[3] = 0x00;
1659 kcoefficients_dump->time[3] = 0x00;
1535 kcoefficients_dump->time[4] = 0x00;
1660 kcoefficients_dump->time[4] = 0x00;
1536 kcoefficients_dump->time[5] = 0x00;
1661 kcoefficients_dump->time[5] = 0x00;
1537 kcoefficients_dump->sid = SID_K_DUMP;
1662 kcoefficients_dump->sid = SID_K_DUMP;
1538
1663
1539 kcoefficients_dump->pkt_cnt = 2;
1664 kcoefficients_dump->pkt_cnt = 2;
1540 kcoefficients_dump->pkt_nr = pkt_nr;
1665 kcoefficients_dump->pkt_nr = pkt_nr;
1541 kcoefficients_dump->blk_nr = blk_nr;
1666 kcoefficients_dump->blk_nr = blk_nr;
1542
1667
1543 //******************
1668 //******************
1544 // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR]
1669 // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR]
1545 // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900)
1670 // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900)
1546 for (k=0; k<3900; k++)
1671 for (k=0; k<3900; k++)
1547 {
1672 {
1548 kcoefficients_dump->kcoeff_blks[k] = 0x00;
1673 kcoefficients_dump->kcoeff_blks[k] = 0x00;
1549 }
1674 }
1550 }
1675 }
1551
1676
1552 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id )
1677 void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id )
1553 {
1678 {
1554 /** This function increment the packet sequence control parameter of a TC, depending on its destination ID.
1679 /** This function increment the packet sequence control parameter of a TC, depending on its destination ID.
1555 *
1680 *
1556 * @param packet_sequence_control points to the packet sequence control which will be incremented
1681 * @param packet_sequence_control points to the packet sequence control which will be incremented
1557 * @param destination_id is the destination ID of the TM, there is one counter by destination ID
1682 * @param destination_id is the destination ID of the TM, there is one counter by destination ID
1558 *
1683 *
1559 * If the destination ID is not known, a dedicated counter is incremented.
1684 * If the destination ID is not known, a dedicated counter is incremented.
1560 *
1685 *
1561 */
1686 */
1562
1687
1563 unsigned short sequence_cnt;
1688 unsigned short sequence_cnt;
1564 unsigned short segmentation_grouping_flag;
1689 unsigned short segmentation_grouping_flag;
1565 unsigned short new_packet_sequence_control;
1690 unsigned short new_packet_sequence_control;
1566 unsigned char i;
1691 unsigned char i;
1567
1692
1568 switch (destination_id)
1693 switch (destination_id)
1569 {
1694 {
1570 case SID_TC_GROUND:
1695 case SID_TC_GROUND:
1571 i = GROUND;
1696 i = GROUND;
1572 break;
1697 break;
1573 case SID_TC_MISSION_TIMELINE:
1698 case SID_TC_MISSION_TIMELINE:
1574 i = MISSION_TIMELINE;
1699 i = MISSION_TIMELINE;
1575 break;
1700 break;
1576 case SID_TC_TC_SEQUENCES:
1701 case SID_TC_TC_SEQUENCES:
1577 i = TC_SEQUENCES;
1702 i = TC_SEQUENCES;
1578 break;
1703 break;
1579 case SID_TC_RECOVERY_ACTION_CMD:
1704 case SID_TC_RECOVERY_ACTION_CMD:
1580 i = RECOVERY_ACTION_CMD;
1705 i = RECOVERY_ACTION_CMD;
1581 break;
1706 break;
1582 case SID_TC_BACKUP_MISSION_TIMELINE:
1707 case SID_TC_BACKUP_MISSION_TIMELINE:
1583 i = BACKUP_MISSION_TIMELINE;
1708 i = BACKUP_MISSION_TIMELINE;
1584 break;
1709 break;
1585 case SID_TC_DIRECT_CMD:
1710 case SID_TC_DIRECT_CMD:
1586 i = DIRECT_CMD;
1711 i = DIRECT_CMD;
1587 break;
1712 break;
1588 case SID_TC_SPARE_GRD_SRC1:
1713 case SID_TC_SPARE_GRD_SRC1:
1589 i = SPARE_GRD_SRC1;
1714 i = SPARE_GRD_SRC1;
1590 break;
1715 break;
1591 case SID_TC_SPARE_GRD_SRC2:
1716 case SID_TC_SPARE_GRD_SRC2:
1592 i = SPARE_GRD_SRC2;
1717 i = SPARE_GRD_SRC2;
1593 break;
1718 break;
1594 case SID_TC_OBCP:
1719 case SID_TC_OBCP:
1595 i = OBCP;
1720 i = OBCP;
1596 break;
1721 break;
1597 case SID_TC_SYSTEM_CONTROL:
1722 case SID_TC_SYSTEM_CONTROL:
1598 i = SYSTEM_CONTROL;
1723 i = SYSTEM_CONTROL;
1599 break;
1724 break;
1600 case SID_TC_AOCS:
1725 case SID_TC_AOCS:
1601 i = AOCS;
1726 i = AOCS;
1602 break;
1727 break;
1603 case SID_TC_RPW_INTERNAL:
1728 case SID_TC_RPW_INTERNAL:
1604 i = RPW_INTERNAL;
1729 i = RPW_INTERNAL;
1605 break;
1730 break;
1606 default:
1731 default:
1607 i = GROUND;
1732 i = GROUND;
1608 break;
1733 break;
1609 }
1734 }
1610
1735
1611 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1736 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
1612 sequence_cnt = sequenceCounters_TM_DUMP[ i ] & 0x3fff;
1737 sequence_cnt = sequenceCounters_TM_DUMP[ i ] & 0x3fff;
1613
1738
1614 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
1739 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
1615
1740
1616 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1741 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
1617 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1742 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
1618
1743
1619 // increment the sequence counter
1744 // increment the sequence counter
1620 if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX )
1745 if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX )
1621 {
1746 {
1622 sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1;
1747 sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1;
1623 }
1748 }
1624 else
1749 else
1625 {
1750 {
1626 sequenceCounters_TM_DUMP[ i ] = 0;
1751 sequenceCounters_TM_DUMP[ i ] = 0;
1627 }
1752 }
1628 }
1753 }
General Comments 0
You need to be logged in to leave comments. Login now