@@ -1,14 +1,14 | |||
|
1 | 1 | cmake_minimum_required (VERSION 2.6) |
|
2 | 2 | project (LFR_FSW) |
|
3 | 3 | |
|
4 | 4 | if(NOT CMAKE_BUILD_TYPE) |
|
5 | 5 | set(CMAKE_BUILD_TYPE "Release" CACHE STRING |
|
6 | 6 | "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE) |
|
7 | 7 | endif(NOT CMAKE_BUILD_TYPE) |
|
8 | 8 | |
|
9 | 9 | set(LFR_BP_SRC ${CMAKE_CURRENT_SOURCE_DIR}/LFR_basic-parameters/basic_parameters.c) |
|
10 | 10 | |
|
11 | 11 | SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/sparc/") |
|
12 | 12 | |
|
13 | 13 | add_subdirectory(src) |
|
14 | add_subdirectory(timegen) | |
|
14 | #add_subdirectory(timegen) |
@@ -1,221 +1,221 | |||
|
1 | 1 | #ifndef GSCMEMORY_HPP_ |
|
2 | 2 | #define GSCMEMORY_HPP_ |
|
3 | 3 | |
|
4 | 4 | #ifndef LEON3 |
|
5 | 5 | #define LEON3 |
|
6 | 6 | #endif |
|
7 | 7 | |
|
8 | 8 | #define REGS_ADDR_PLUGANDPLAY 0xFFFFF000 |
|
9 | 9 | #define ASR16_REG_ADDRESS 0x90400040 // Ancillary State Register 16 = Register protection control register (FT only) |
|
10 | 10 | |
|
11 | 11 | #define DEVICEID_LEON3 0x003 |
|
12 | 12 | #define DEVICEID_LEON3FT 0x053 |
|
13 | 13 | #define VENDORID_GAISLER 0x01 |
|
14 | 14 | |
|
15 | 15 | // CCR |
|
16 | 16 | #define POS_FT 19 |
|
17 | 17 | // |
|
18 | 18 | #define POS_ITE 12 |
|
19 | 19 | #define COUNTER_FIELD_ITE 0x00003000 // 0000 0000 0000 0000 0011 0000 0000 0000 |
|
20 | 20 | #define COUNTER_MASK_ITE 0xffffcfff // 1111 1111 1111 1111 1100 1111 1111 1111 |
|
21 | 21 | #define POS_IDE 10 |
|
22 | 22 | #define COUNTER_FIELD_IDE 0x00000c00 // 0000 0000 0000 0000 0000 1100 0000 0000 |
|
23 | 23 | #define COUNTER_MASK_IDE 0xfffff3ff // 1111 1111 1111 1111 1111 0011 1111 1111 |
|
24 | 24 | // |
|
25 | 25 | #define POS_DTE 8 |
|
26 | 26 | #define COUNTER_FIELD_DTE 0x00000300 // 0000 0000 0000 0000 0000 0011 0000 0000 |
|
27 | 27 | #define COUNTER_MASK_DTE 0xfffffcff // 1111 1111 1111 1111 1111 1100 1111 1111 |
|
28 | 28 | #define POS_DDE 6 |
|
29 | 29 | #define COUNTER_FIELD_DDE 0x000000c0 // 0000 0000 0000 0000 0000 0000 1100 0000 |
|
30 | 30 | #define COUNTER_MASK_DDE 0xffffff3f // 1111 1111 1111 1111 1111 1111 0011 1111 |
|
31 | 31 | |
|
32 | 32 | // ASR16 |
|
33 | 33 | #define POS_FPFTID 30 |
|
34 | 34 | #define POS_FPRF 27 |
|
35 | 35 | #define POS_FDI 16 // FP RF protection enable/disable |
|
36 | 36 | #define POS_IUFTID 14 |
|
37 | 37 | #define POS_IURF 11 |
|
38 | 38 | #define POS_IDI 0 // IU RF protection enable/disable |
|
39 | 39 | |
|
40 | 40 | #define COUNTER_FIELD_FPRF 0x38000000 // 0011 1000 0000 0000 0000 0000 0000 0000 |
|
41 | 41 | #define COUNTER_MASK_FPRF 0xc7ffffff // 1100 0111 1111 1111 1111 1111 1111 1111 |
|
42 | 42 | |
|
43 | 43 | #define COUNTER_FIELD_IURF 0x00003800 // 0000 0000 0000 0000 0011 1000 0000 0000 |
|
44 | 44 | #define COUNTER_MASK_IURF 0xffffc7ff // 1111 1111 1111 1111 1100 0111 1111 1111 |
|
45 | 45 | |
|
46 | 46 | volatile unsigned int *asr16Ptr = (volatile unsigned int *) ASR16_REG_ADDRESS; |
|
47 | 47 | |
|
48 | 48 | static inline void flushCache() |
|
49 | 49 | { |
|
50 | 50 | /** |
|
51 | 51 | * Flush the data cache and the instruction cache. |
|
52 | 52 | * |
|
53 | 53 | * @param void |
|
54 | 54 | * |
|
55 | 55 | * @return void |
|
56 | 56 | */ |
|
57 | 57 | |
|
58 | 58 | asm("flush"); |
|
59 | 59 | } |
|
60 | 60 | |
|
61 | 61 | //*************************** |
|
62 | 62 | // CCR Cache control register |
|
63 | 63 | |
|
64 | 64 | static unsigned int CCR_getValue() |
|
65 | 65 | { |
|
66 | 66 | unsigned int cacheControlRegister = 0; |
|
67 | 67 | __asm__ __volatile__("lda [%%g0] 2, %0" : "=r"(cacheControlRegister) : ); |
|
68 | 68 | return cacheControlRegister; |
|
69 | 69 | } |
|
70 | 70 | |
|
71 | 71 | static void CCR_setValue(unsigned int cacheControlRegister) |
|
72 | 72 | { |
|
73 | 73 | __asm__ __volatile__("sta %0, [%%g0] 2" : : "r"(cacheControlRegister)); |
|
74 | 74 | } |
|
75 | 75 | |
|
76 | 76 | static void CCR_resetCacheControlRegister() |
|
77 | 77 | { |
|
78 | 78 | unsigned int cacheControlRegister; |
|
79 | 79 | cacheControlRegister = 0x00; |
|
80 | 80 | CCR_setValue(cacheControlRegister); |
|
81 | 81 | } |
|
82 | 82 | |
|
83 | 83 | static void CCR_enableInstructionCache() |
|
84 | 84 | { |
|
85 | 85 | // [1:0] Instruction Cache state (ICS) |
|
86 | 86 | // Indicates the current data cache state according to the following: X0 = disabled, 01 = frozen, 11 = enabled. |
|
87 | 87 | unsigned int cacheControlRegister; |
|
88 | 88 | cacheControlRegister = CCR_getValue(); |
|
89 | 89 | cacheControlRegister = (cacheControlRegister | 0x3); |
|
90 | 90 | CCR_setValue(cacheControlRegister); |
|
91 | 91 | } |
|
92 | 92 | |
|
93 | 93 | static void CCR_enableDataCache() |
|
94 | 94 | { |
|
95 | 95 | // [3:2] Data Cache state (DCS) |
|
96 | 96 | // Indicates the current data cache state according to the following: X0 = disabled, 01 = frozen, 11 = enabled. |
|
97 | 97 | unsigned int cacheControlRegister; |
|
98 | 98 | cacheControlRegister = CCR_getValue(); |
|
99 | 99 | cacheControlRegister = (cacheControlRegister | 0xc); |
|
100 | 100 | CCR_setValue(cacheControlRegister); |
|
101 | 101 | } |
|
102 | 102 | |
|
103 | 103 | static void CCR_enableInstructionBurstFetch() |
|
104 | 104 | { |
|
105 | 105 | // [16] Instruction burst fetch (IB). This bit enables burst fill during instruction fetch. |
|
106 | 106 | unsigned int cacheControlRegister; |
|
107 | 107 | cacheControlRegister = CCR_getValue(); |
|
108 | 108 | // set the bit IB to 1 |
|
109 | 109 | cacheControlRegister = (cacheControlRegister | 0x10000); |
|
110 | 110 | CCR_setValue(cacheControlRegister); |
|
111 | 111 | } |
|
112 | 112 | |
|
113 | 113 | void CCR_getInstructionAndDataErrorCounters( unsigned int* instructionErrorCounter, unsigned int* dataErrorCounter ) |
|
114 | 114 | { |
|
115 | 115 | // [13:12] Instruction Tag Errors (ITE) - Number of detected parity errors in the instruction tag cache. |
|
116 | 116 | // Only available if fault-tolerance is enabled (FT field in this register is non-zero). |
|
117 | 117 | // [11:10] Instruction Data Errors (IDE) - Number of detected parity errors in the instruction data cache. |
|
118 | 118 | // Only available if fault-tolerance is enabled (FT field in this register is non-zero). |
|
119 | 119 | |
|
120 | 120 | unsigned int cacheControlRegister; |
|
121 | 121 | unsigned int iTE; |
|
122 | 122 | unsigned int iDE; |
|
123 | 123 | unsigned int dTE; |
|
124 | 124 | unsigned int dDE; |
|
125 | 125 | |
|
126 | 126 | cacheControlRegister = CCR_getValue(); |
|
127 | 127 | iTE = (cacheControlRegister & COUNTER_FIELD_ITE) >> POS_ITE; |
|
128 | 128 | iDE = (cacheControlRegister & COUNTER_FIELD_IDE) >> POS_IDE; |
|
129 | 129 | dTE = (cacheControlRegister & COUNTER_FIELD_DTE) >> POS_DTE; |
|
130 | 130 | dDE = (cacheControlRegister & COUNTER_FIELD_DDE) >> POS_DDE; |
|
131 | 131 | |
|
132 | 132 | *instructionErrorCounter = iTE + iDE; |
|
133 | 133 | *dataErrorCounter = dTE + dDE; |
|
134 | 134 | |
|
135 | 135 | // reset counters |
|
136 | 136 | cacheControlRegister = cacheControlRegister |
|
137 | 137 | & COUNTER_FIELD_ITE |
|
138 | 138 | & COUNTER_FIELD_IDE |
|
139 | 139 | & COUNTER_FIELD_DTE |
|
140 | 140 | & COUNTER_FIELD_DDE; |
|
141 | 141 | |
|
142 | 142 | CCR_setValue(cacheControlRegister); |
|
143 | 143 | } |
|
144 | 144 | |
|
145 | 145 | //******************************************* |
|
146 | 146 | // ASR16 Register protection control register |
|
147 | 147 | |
|
148 | 148 | static void ASR16_resetRegisterProtectionControlRegister() |
|
149 | 149 | { |
|
150 | 150 | *asr16Ptr = 0x00; |
|
151 | 151 | } |
|
152 | 152 | |
|
153 | 153 | void ASR16_get_FPRF_IURF_ErrorCounters( unsigned int* fprfErrorCounter, unsigned int* iurfErrorCounter) |
|
154 | 154 | { |
|
155 | 155 | /** This function is used to retrieve the integer unit register file error counter and the floating point unit |
|
156 | 156 | * register file error counter |
|
157 | 157 | * |
|
158 | 158 | * @return void |
|
159 | 159 | * |
|
160 | 160 | * [29:27] FP RF error counter - Number of detected parity errors in the FP register file. |
|
161 | 161 | * [13:11] IU RF error counter - Number of detected parity errors in the IU register file. |
|
162 | 162 | * |
|
163 | 163 | */ |
|
164 | 164 | |
|
165 | 165 | unsigned int asr16; |
|
166 | 166 | |
|
167 | 167 | asr16 = *asr16Ptr; |
|
168 | 168 | *fprfErrorCounter = ( asr16 & COUNTER_FIELD_FPRF ) >> POS_FPRF; |
|
169 | 169 | *iurfErrorCounter = ( asr16 & COUNTER_FIELD_IURF ) >> POS_IURF; |
|
170 | 170 | |
|
171 | 171 | // reset the counter to 0 |
|
172 | 172 | asr16 = asr16 |
|
173 | 173 | & COUNTER_MASK_FPRF |
|
174 | 174 | & COUNTER_FIELD_IURF; |
|
175 | 175 | |
|
176 | 176 | *asr16Ptr = asr16; |
|
177 | 177 | } |
|
178 | 178 | |
|
179 | 179 | static void faultTolerantScheme() |
|
180 | 180 | { |
|
181 | 181 | // [20:19] FT scheme (FT) - “00” = no FT, “01” = 4-bit checking implemented |
|
182 | 182 | unsigned int cacheControlRegister; |
|
183 | 183 | unsigned int *plugAndPlayRegister; |
|
184 | 184 | unsigned int vendorId; |
|
185 | 185 | unsigned int deviceId; |
|
186 | 186 | |
|
187 | 187 | plugAndPlayRegister = (unsigned int*) REGS_ADDR_PLUGANDPLAY; |
|
188 | 188 | vendorId = ( (*plugAndPlayRegister) & 0xff000000 ) >> 24; |
|
189 | 189 | deviceId = ( (*plugAndPlayRegister) & 0x00fff000 ) >> 12; |
|
190 | 190 | |
|
191 | 191 | cacheControlRegister = CCR_getValue(); |
|
192 | 192 | |
|
193 | 193 | if( (vendorId == VENDORID_GAISLER) & (deviceId ==DEVICEID_LEON3FT) ) |
|
194 | 194 | { |
|
195 | 195 | PRINTF("in faultTolerantScheme *** Leon3FT detected\n"); |
|
196 | 196 | PRINTF2(" *** vendorID = 0x%x, deviceId = 0x%x\n", vendorId, deviceId); |
|
197 | 197 | PRINTF1("ASR16 IU RF protection, bit 0 (IDI) is: 0x%x (0 => protection enabled)\n", |
|
198 | 198 | (*asr16Ptr >> POS_IDI) & 1); |
|
199 | 199 | PRINTF1("ASR16 FP RF protection, bit 16 (FDI) is: 0x%x (0 => protection enabled)\n", |
|
200 | 200 | (*asr16Ptr >> POS_FDI) & 1); |
|
201 | 201 | PRINTF1("ASR16 IU FT ID bits [15:14] is: 0x%x (2 => 8-bit parity without restart)\n", |
|
202 | 202 | (*asr16Ptr >> POS_IUFTID) & 0x3); |
|
203 | 203 | PRINTF1("ASR16 FP FT ID bits [31:30] is: 0x%x (1 => 4-bit parity with restart)\n", |
|
204 | 204 | (*asr16Ptr >> POS_FPFTID) & 0x03); |
|
205 | 205 | PRINTF1("CCR FT bits [20:19] are: 0x%x (1 => 4-bit parity with restart)\n", |
|
206 | 206 | (cacheControlRegister >> POS_FT) & 0x3 ); |
|
207 | 207 | |
|
208 | 208 | // CCR The FFT bits are just read, the FT scheme is set to “01” = 4-bit checking implemented by default |
|
209 | 209 | |
|
210 | 210 | // ASR16 Ancillary State Register configuration (Register protection control register) |
|
211 | 211 | // IU RF protection is set by default, bit 0 IDI = 0 |
|
212 | 212 | // FP RF protection is set by default, bit 16 FDI = 0 |
|
213 | 213 | } |
|
214 | 214 | else |
|
215 | 215 | { |
|
216 |
PRINTF("in faultTolerantScheme *** |
|
|
216 | PRINTF("in faultTolerantScheme *** Leon3FT not detected\n"); | |
|
217 | 217 | PRINTF2(" *** vendorID = 0x%x, deviceId = 0x%x\n", vendorId, deviceId); |
|
218 | 218 | } |
|
219 | 219 | } |
|
220 | 220 | |
|
221 | 221 | #endif /* GSCMEMORY_HPP_ */ |
@@ -1,14 +1,14 | |||
|
1 | 1 | # LOAD FSW USING LINK 1 |
|
2 | 2 | SpwPlugin0.StarDundeeSelectLinkNumber( 1 ) |
|
3 | 3 | |
|
4 |
dsu3plugin0.openFile("/home/pleroy/DEV/DEV_PLE/ |
|
|
4 | dsu3plugin0.openFile("/home/pleroy/DEV/DEV_PLE/build-DEV_PLE-Desktop-Default/src/fsw") | |
|
5 | 5 | #dsu3plugin0.openFile("/opt/LFR/LFR-FSW/2.0.2.3/fsw") |
|
6 | 6 | dsu3plugin0.loadFile() |
|
7 | 7 | |
|
8 | 8 | dsu3plugin0.run() |
|
9 | 9 | |
|
10 | 10 | # START SENDING TIMECODES AT 1 Hz |
|
11 | 11 | #SpwPlugin0.StarDundeeStartTimecodes( 1 ) |
|
12 | 12 | |
|
13 | 13 | # it is possible to change the time code frequency |
|
14 | 14 | #RMAPPlugin0.changeTimecodeFrequency(2) |
@@ -1,8 +1,9 | |||
|
1 | 1 | set(CMAKE_SYSTEM_NAME rtems) |
|
2 | 2 | |
|
3 | 3 | set(CMAKE_C_COMPILER /opt/rtems-4.10/bin/sparc-rtems-gcc) |
|
4 | 4 | set(CMAKE_CXX_COMPILER /opt/rtems-4.10/bin/sparc-rtems-g++) |
|
5 | 5 | set(CMAKE_LINKER /opt/rtems-4.10/bin/sparc-rtems-g++) |
|
6 | 6 | SET(CMAKE_EXE_LINKER_FLAGS "-static") |
|
7 | set(CMAKE_C_FLAGS_RELEASE "-O3") | |
|
7 | 8 | set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") |
|
8 | 9 | include_directories("/opt/rtems-4.10/sparc-rtems/leon3/lib/include") |
@@ -1,105 +1,105 | |||
|
1 | 1 | cmake_minimum_required (VERSION 2.6) |
|
2 |
project ( |
|
|
2 | project (fsw) | |
|
3 | 3 | |
|
4 | 4 | include(sparc-rtems) |
|
5 | 5 | |
|
6 | 6 | include_directories("../header" |
|
7 | 7 | "../header/lfr_common_headers" |
|
8 | 8 | "../header/processing" |
|
9 | 9 | "../LFR_basic-parameters" |
|
10 | 10 | "../src") |
|
11 | 11 | |
|
12 | 12 | set(SOURCES wf_handler.c |
|
13 | 13 | tc_handler.c |
|
14 | 14 | fsw_misc.c |
|
15 | 15 | fsw_init.c |
|
16 | 16 | fsw_globals.c |
|
17 | 17 | fsw_spacewire.c |
|
18 | 18 | tc_load_dump_parameters.c |
|
19 | 19 | tm_lfr_tc_exe.c |
|
20 | 20 | tc_acceptance.c |
|
21 | 21 | processing/fsw_processing.c |
|
22 | 22 | processing/avf0_prc0.c |
|
23 | 23 | processing/avf1_prc1.c |
|
24 | 24 | processing/avf2_prc2.c |
|
25 | 25 | lfr_cpu_usage_report.c |
|
26 | 26 | ${LFR_BP_SRC} |
|
27 | 27 | ../header/wf_handler.h |
|
28 | 28 | ../header/tc_handler.h |
|
29 | 29 | ../header/grlib_regs.h |
|
30 | 30 | ../header/fsw_misc.h |
|
31 | 31 | ../header/fsw_init.h |
|
32 | 32 | ../header/fsw_spacewire.h |
|
33 | 33 | ../header/tc_load_dump_parameters.h |
|
34 | 34 | ../header/tm_lfr_tc_exe.h |
|
35 | 35 | ../header/tc_acceptance.h |
|
36 | 36 | ../header/processing/fsw_processing.h |
|
37 | 37 | ../header/processing/avf0_prc0.h |
|
38 | 38 | ../header/processing/avf1_prc1.h |
|
39 | 39 | ../header/processing/avf2_prc2.h |
|
40 | 40 | ../header/fsw_params_wf_handler.h |
|
41 | 41 | ../header/lfr_cpu_usage_report.h |
|
42 | 42 | ../header/lfr_common_headers/ccsds_types.h |
|
43 | 43 | ../header/lfr_common_headers/fsw_params.h |
|
44 | 44 | ../header/lfr_common_headers/fsw_params_nb_bytes.h |
|
45 | 45 | ../header/lfr_common_headers/fsw_params_processing.h |
|
46 | 46 | ../header/lfr_common_headers/tm_byte_positions.h |
|
47 | 47 | ../LFR_basic-parameters/basic_parameters.h |
|
48 | 48 | ../LFR_basic-parameters/basic_parameters_params.h |
|
49 | 49 | ../header/GscMemoryLPP.hpp |
|
50 | 50 | ) |
|
51 | 51 | |
|
52 | 52 | |
|
53 | 53 | option(FSW_verbose "Enable verbose LFR" ON) |
|
54 | 54 | option(FSW_boot_messages "Enable LFR boot messages" ON) |
|
55 | 55 | option(FSW_debug_messages "Enable LFR debug messages" ON) |
|
56 | 56 | option(FSW_cpu_usage_report "Enable LFR cpu usage report" OFF) |
|
57 | 57 | option(FSW_stack_report "Enable LFR stack report" OFF) |
|
58 | 58 | option(FSW_vhdl_dev "?" OFF) |
|
59 | 59 | option(FSW_lpp_dpu_destid "Set to debug at LPP" ON) |
|
60 | 60 | option(FSW_debug_watchdog "Enable debug watchdog" OFF) |
|
61 | 61 | option(FSW_debug_tch "?" OFF) |
|
62 | 62 | |
|
63 | 63 | set(SW_VERSION_N1 "3" CACHE STRING "Choose N1 FSW Version." FORCE) |
|
64 | 64 | set(SW_VERSION_N2 "1" CACHE STRING "Choose N2 FSW Version." FORCE) |
|
65 | 65 | set(SW_VERSION_N3 "0" CACHE STRING "Choose N3 FSW Version." FORCE) |
|
66 | 66 | set(SW_VERSION_N4 "4" CACHE STRING "Choose N4 FSW Version." FORCE) |
|
67 | 67 | |
|
68 | 68 | |
|
69 | 69 | if(FSW_verbose) |
|
70 | 70 | add_definitions(-DPRINT_MESSAGES_ON_CONSOLE) |
|
71 | 71 | endif() |
|
72 | 72 | if(FSW_boot_messages) |
|
73 | 73 | add_definitions(-DBOOT_MESSAGES) |
|
74 | 74 | endif() |
|
75 | 75 | if(FSW_debug_messages) |
|
76 | 76 | add_definitions(-DDEBUG_MESSAGES) |
|
77 | 77 | endif() |
|
78 | 78 | if(FSW_cpu_usage_report) |
|
79 | 79 | add_definitions(-DPRINT_TASK_STATISTICS) |
|
80 | 80 | endif() |
|
81 | 81 | if(FSW_stack_report) |
|
82 | 82 | add_definitions(-DPRINT_STACK_REPORT) |
|
83 | 83 | endif() |
|
84 | 84 | if(FSW_vhdl_dev) |
|
85 | 85 | add_definitions(-DVHDL_DEV) |
|
86 | 86 | endif() |
|
87 | 87 | if(FSW_lpp_dpu_destid) |
|
88 | 88 | add_definitions(-DLPP_DPU_DESTID) |
|
89 | 89 | endif() |
|
90 | 90 | if(FSW_debug_watchdog) |
|
91 | 91 | add_definitions(-DDEBUG_WATCHDOG) |
|
92 | 92 | endif() |
|
93 | 93 | if(FSW_debug_tch) |
|
94 | 94 | add_definitions(-DDEBUG_TCH) |
|
95 | 95 | endif() |
|
96 | 96 | |
|
97 | 97 | add_definitions(-DMSB_FIRST_TCH) |
|
98 | 98 | |
|
99 | 99 | add_definitions(-DSWVERSION=-1-0) |
|
100 | 100 | add_definitions(-DSW_VERSION_N1=${SW_VERSION_N1}) |
|
101 | 101 | add_definitions(-DSW_VERSION_N2=${SW_VERSION_N2}) |
|
102 | 102 | add_definitions(-DSW_VERSION_N3=${SW_VERSION_N3}) |
|
103 | 103 | add_definitions(-DSW_VERSION_N4=${SW_VERSION_N4}) |
|
104 | 104 | |
|
105 |
add_executable( |
|
|
105 | add_executable(fsw ${SOURCES}) |
@@ -1,939 +1,938 | |||
|
1 | 1 | /** This is the RTEMS initialization module. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * This module contains two very different information: |
|
7 | 7 | * - specific instructions to configure the compilation of the RTEMS executive |
|
8 | 8 | * - functions related to the fligth softwre initialization, especially the INIT RTEMS task |
|
9 | 9 | * |
|
10 | 10 | */ |
|
11 | 11 | |
|
12 | 12 | //************************* |
|
13 | 13 | // GPL reminder to be added |
|
14 | 14 | //************************* |
|
15 | 15 | |
|
16 | 16 | #include <rtems.h> |
|
17 | 17 | |
|
18 | 18 | /* configuration information */ |
|
19 | 19 | |
|
20 | 20 | #define CONFIGURE_INIT |
|
21 | 21 | |
|
22 | 22 | #include <bsp.h> /* for device driver prototypes */ |
|
23 | 23 | |
|
24 | 24 | /* configuration information */ |
|
25 | 25 | |
|
26 | 26 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
27 | 27 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
28 | 28 | |
|
29 | 29 | #define CONFIGURE_MAXIMUM_TASKS 20 |
|
30 | 30 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
|
31 | 31 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) |
|
32 | 32 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 |
|
33 | 33 | #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 |
|
34 | 34 | #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) |
|
35 | 35 | #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT) |
|
36 | 36 | #define CONFIGURE_MAXIMUM_DRIVERS 16 |
|
37 | 37 | #define CONFIGURE_MAXIMUM_PERIODS 5 |
|
38 | 38 | #define CONFIGURE_MAXIMUM_TIMERS 5 // [spiq] [link] [spacewire_reset_link] |
|
39 | 39 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5 |
|
40 | 40 | #ifdef PRINT_STACK_REPORT |
|
41 | 41 | #define CONFIGURE_STACK_CHECKER_ENABLED |
|
42 | 42 | #endif |
|
43 | 43 | |
|
44 | 44 | #include <rtems/confdefs.h> |
|
45 | 45 | |
|
46 | 46 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ |
|
47 | 47 | #ifdef RTEMS_DRVMGR_STARTUP |
|
48 | 48 | #ifdef LEON3 |
|
49 | 49 | /* Add Timer and UART Driver */ |
|
50 | 50 | |
|
51 | 51 | #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
52 | 52 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER |
|
53 | 53 | #endif |
|
54 | 54 | |
|
55 | 55 | #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
56 | 56 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART |
|
57 | 57 | #endif |
|
58 | 58 | |
|
59 | 59 | #endif |
|
60 | 60 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ |
|
61 | 61 | |
|
62 | 62 | #include <drvmgr/drvmgr_confdefs.h> |
|
63 | 63 | #endif |
|
64 | 64 | |
|
65 | 65 | #include "fsw_init.h" |
|
66 | 66 | #include "fsw_config.c" |
|
67 | 67 | #include "GscMemoryLPP.hpp" |
|
68 | 68 | |
|
69 | 69 | void initCache() |
|
70 | 70 | { |
|
71 | 71 | // ASI 2 contains a few control registers that have not been assigned as ancillary state registers. |
|
72 | 72 | // These should only be read and written using 32-bit LDA/STA instructions. |
|
73 | 73 | // All cache registers are accessed through load/store operations to the alternate address space (LDA/STA), using ASI = 2. |
|
74 | 74 | // The table below shows the register addresses: |
|
75 | 75 | // 0x00 Cache control register |
|
76 | 76 | // 0x04 Reserved |
|
77 | 77 | // 0x08 Instruction cache configuration register |
|
78 | 78 | // 0x0C Data cache configuration register |
|
79 | 79 | |
|
80 | 80 | // Cache Control Register Leon3 / Leon3FT |
|
81 | 81 | // 31..30 29 28 27..24 23 22 21 20..19 18 17 16 |
|
82 | 82 | // RFT PS TB DS FD FI FT ST IB |
|
83 | 83 | // 15 14 13..12 11..10 9..8 7..6 5 4 3..2 1..0 |
|
84 | 84 | // IP DP ITE IDE DTE DDE DF IF DCS ICS |
|
85 | 85 | |
|
86 | 86 | unsigned int cacheControlRegister; |
|
87 | 87 | |
|
88 | 88 | CCR_resetCacheControlRegister(); |
|
89 | 89 | ASR16_resetRegisterProtectionControlRegister(); |
|
90 | 90 | |
|
91 | 91 | cacheControlRegister = CCR_getValue(); |
|
92 | 92 | PRINTF1("(0) CCR - Cache Control Register = %x\n", cacheControlRegister); |
|
93 | 93 | PRINTF1("(0) ASR16 = %x\n", *asr16Ptr); |
|
94 | 94 | |
|
95 | 95 | CCR_enableInstructionCache(); // ICS bits |
|
96 | 96 | CCR_enableDataCache(); // DCS bits |
|
97 | 97 | CCR_enableInstructionBurstFetch(); // IB bit |
|
98 | 98 | |
|
99 | 99 | faultTolerantScheme(); |
|
100 | 100 | |
|
101 | 101 | cacheControlRegister = CCR_getValue(); |
|
102 | 102 | PRINTF1("(1) CCR - Cache Control Register = %x\n", cacheControlRegister); |
|
103 | 103 | PRINTF1("(1) ASR16 Register protection control register = %x\n", *asr16Ptr); |
|
104 | 104 | |
|
105 | 105 | PRINTF("\n"); |
|
106 | 106 | } |
|
107 | 107 | |
|
108 | 108 | rtems_task Init( rtems_task_argument ignored ) |
|
109 | 109 | { |
|
110 | 110 | /** This is the RTEMS INIT taks, it is the first task launched by the system. |
|
111 | 111 | * |
|
112 | 112 | * @param unused is the starting argument of the RTEMS task |
|
113 | 113 | * |
|
114 | 114 | * The INIT task create and run all other RTEMS tasks. |
|
115 | 115 | * |
|
116 | 116 | */ |
|
117 | 117 | |
|
118 | 118 | //*********** |
|
119 | 119 | // INIT CACHE |
|
120 | 120 | |
|
121 | 121 | unsigned char *vhdlVersion; |
|
122 | 122 | |
|
123 | 123 | reset_lfr(); |
|
124 | 124 | |
|
125 | 125 | reset_local_time(); |
|
126 | 126 | |
|
127 | 127 | rtems_cpu_usage_reset(); |
|
128 | 128 | |
|
129 | 129 | rtems_status_code status; |
|
130 | 130 | rtems_status_code status_spw; |
|
131 | 131 | rtems_isr_entry old_isr_handler; |
|
132 | 132 | |
|
133 | 133 | // UART settings |
|
134 | 134 | enable_apbuart_transmitter(); |
|
135 | 135 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); |
|
136 | 136 | |
|
137 | 137 | DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") |
|
138 | 138 | |
|
139 | 139 | |
|
140 | 140 | PRINTF("\n\n\n\n\n") |
|
141 | 141 | |
|
142 | 142 | initCache(); |
|
143 | 143 | |
|
144 | 144 | PRINTF("*************************\n") |
|
145 | 145 | PRINTF("** LFR Flight Software **\n") |
|
146 | 146 | |
|
147 | 147 | PRINTF1("** %d-", SW_VERSION_N1) |
|
148 | 148 | PRINTF1("%d-" , SW_VERSION_N2) |
|
149 | 149 | PRINTF1("%d-" , SW_VERSION_N3) |
|
150 | 150 | PRINTF1("%d **\n", SW_VERSION_N4) |
|
151 | 151 | |
|
152 | 152 | vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION); |
|
153 | 153 | PRINTF("** VHDL **\n") |
|
154 | 154 | PRINTF1("** %d.", vhdlVersion[1]) |
|
155 | 155 | PRINTF1("%d." , vhdlVersion[2]) |
|
156 | 156 | PRINTF1("%d **\n", vhdlVersion[3]) |
|
157 | 157 | PRINTF("*************************\n") |
|
158 | 158 | PRINTF("\n\n") |
|
159 | 159 | |
|
160 | 160 | init_parameter_dump(); |
|
161 | 161 | init_kcoefficients_dump(); |
|
162 | 162 | init_local_mode_parameters(); |
|
163 | 163 | init_housekeeping_parameters(); |
|
164 | 164 | init_k_coefficients_prc0(); |
|
165 | 165 | init_k_coefficients_prc1(); |
|
166 | 166 | init_k_coefficients_prc2(); |
|
167 | 167 | pa_bia_status_info = 0x00; |
|
168 | 168 | cp_rpw_sc_rw_f_flags = 0x00; |
|
169 | 169 | cp_rpw_sc_rw1_f1 = 0.0; |
|
170 | 170 | cp_rpw_sc_rw1_f2 = 0.0; |
|
171 | 171 | cp_rpw_sc_rw2_f1 = 0.0; |
|
172 | 172 | cp_rpw_sc_rw2_f2 = 0.0; |
|
173 | 173 | cp_rpw_sc_rw3_f1 = 0.0; |
|
174 | 174 | cp_rpw_sc_rw3_f2 = 0.0; |
|
175 | 175 | cp_rpw_sc_rw4_f1 = 0.0; |
|
176 | 176 | cp_rpw_sc_rw4_f2 = 0.0; |
|
177 | 177 | // initialize filtering parameters |
|
178 | 178 | filterPar.spare_sy_lfr_pas_filter_enabled = DEFAULT_SY_LFR_PAS_FILTER_ENABLED; |
|
179 | 179 | filterPar.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS; |
|
180 | 180 | filterPar.sy_lfr_pas_filter_tbad = DEFAULT_SY_LFR_PAS_FILTER_TBAD; |
|
181 | 181 | filterPar.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET; |
|
182 | 182 | filterPar.sy_lfr_pas_filter_shift = DEFAULT_SY_LFR_PAS_FILTER_SHIFT; |
|
183 | 183 | filterPar.sy_lfr_sc_rw_delta_f = DEFAULT_SY_LFR_SC_RW_DELTA_F; |
|
184 | 184 | update_last_valid_transition_date( DEFAULT_LAST_VALID_TRANSITION_DATE ); |
|
185 | 185 | |
|
186 | 186 | // waveform picker initialization |
|
187 | 187 | WFP_init_rings(); |
|
188 | 188 | LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings |
|
189 | 189 | WFP_reset_current_ring_nodes(); |
|
190 | 190 | reset_waveform_picker_regs(); |
|
191 | 191 | |
|
192 | 192 | // spectral matrices initialization |
|
193 | 193 | SM_init_rings(); // initialize spectral matrices rings |
|
194 | 194 | SM_reset_current_ring_nodes(); |
|
195 | 195 | reset_spectral_matrix_regs(); |
|
196 | 196 | |
|
197 | 197 | // configure calibration |
|
198 | 198 | configureCalibration( false ); // true means interleaved mode, false is for normal mode |
|
199 | 199 | |
|
200 | 200 | updateLFRCurrentMode( LFR_MODE_STANDBY ); |
|
201 | 201 | |
|
202 | 202 | BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode) |
|
203 | 203 | |
|
204 | 204 | create_names(); // create all names |
|
205 | 205 | |
|
206 | 206 | status = create_timecode_timer(); // create the timer used by timecode_irq_handler |
|
207 | 207 | if (status != RTEMS_SUCCESSFUL) |
|
208 | 208 | { |
|
209 | 209 | PRINTF1("in INIT *** ERR in create_timer_timecode, code %d", status) |
|
210 | 210 | } |
|
211 | 211 | |
|
212 | 212 | status = create_message_queues(); // create message queues |
|
213 | 213 | if (status != RTEMS_SUCCESSFUL) |
|
214 | 214 | { |
|
215 | 215 | PRINTF1("in INIT *** ERR in create_message_queues, code %d", status) |
|
216 | 216 | } |
|
217 | 217 | |
|
218 | 218 | status = create_all_tasks(); // create all tasks |
|
219 | 219 | if (status != RTEMS_SUCCESSFUL) |
|
220 | 220 | { |
|
221 | 221 | PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status) |
|
222 | 222 | } |
|
223 | 223 | |
|
224 | 224 | // ************************** |
|
225 | 225 | // <SPACEWIRE INITIALIZATION> |
|
226 | 226 | status_spw = spacewire_open_link(); // (1) open the link |
|
227 | 227 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
228 | 228 | { |
|
229 | 229 | PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw ) |
|
230 | 230 | } |
|
231 | 231 | |
|
232 | 232 | if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link |
|
233 | 233 | { |
|
234 | 234 | status_spw = spacewire_configure_link( fdSPW ); |
|
235 | 235 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
236 | 236 | { |
|
237 | 237 | PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw ) |
|
238 | 238 | } |
|
239 | 239 | } |
|
240 | 240 | |
|
241 | 241 | if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link |
|
242 | 242 | { |
|
243 | 243 | status_spw = spacewire_start_link( fdSPW ); |
|
244 | 244 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
245 | 245 | { |
|
246 | 246 | PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw ) |
|
247 | 247 | } |
|
248 | 248 | } |
|
249 | 249 | // </SPACEWIRE INITIALIZATION> |
|
250 | 250 | // *************************** |
|
251 | 251 | |
|
252 | 252 | status = start_all_tasks(); // start all tasks |
|
253 | 253 | if (status != RTEMS_SUCCESSFUL) |
|
254 | 254 | { |
|
255 | 255 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) |
|
256 | 256 | } |
|
257 | 257 | |
|
258 | 258 | // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization |
|
259 | 259 | status = start_recv_send_tasks(); |
|
260 | 260 | if ( status != RTEMS_SUCCESSFUL ) |
|
261 | 261 | { |
|
262 | 262 | PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status ) |
|
263 | 263 | } |
|
264 | 264 | |
|
265 | 265 | // suspend science tasks, they will be restarted later depending on the mode |
|
266 | 266 | status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY) |
|
267 | 267 | if (status != RTEMS_SUCCESSFUL) |
|
268 | 268 | { |
|
269 | 269 | PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
270 | 270 | } |
|
271 | 271 | |
|
272 | 272 | // configure IRQ handling for the waveform picker unit |
|
273 | 273 | status = rtems_interrupt_catch( waveforms_isr, |
|
274 | 274 | IRQ_SPARC_WAVEFORM_PICKER, |
|
275 | 275 | &old_isr_handler) ; |
|
276 | 276 | // configure IRQ handling for the spectral matrices unit |
|
277 | 277 | status = rtems_interrupt_catch( spectral_matrices_isr, |
|
278 | 278 | IRQ_SPARC_SPECTRAL_MATRIX, |
|
279 | 279 | &old_isr_handler) ; |
|
280 | 280 | |
|
281 | 281 | // if the spacewire link is not up then send an event to the SPIQ task for link recovery |
|
282 | 282 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
283 | 283 | { |
|
284 | 284 | status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ); |
|
285 | 285 | if ( status != RTEMS_SUCCESSFUL ) { |
|
286 | 286 | PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status ) |
|
287 | 287 | } |
|
288 | 288 | } |
|
289 | 289 | |
|
290 | 290 | BOOT_PRINTF("delete INIT\n") |
|
291 | 291 | |
|
292 | 292 | set_hk_lfr_sc_potential_flag( true ); |
|
293 | 293 | |
|
294 | 294 | // start the timer to detect a missing spacewire timecode |
|
295 | 295 | // the timeout is larger because the spw IP needs to receive several valid timecodes before generating a tickout |
|
296 | 296 | // if a tickout is generated, the timer is restarted |
|
297 | 297 | status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT_INIT, timecode_timer_routine, NULL ); |
|
298 | 298 | |
|
299 | 299 | grspw_timecode_callback = &timecode_irq_handler; |
|
300 | 300 | |
|
301 | 301 | status = rtems_task_delete(RTEMS_SELF); |
|
302 | 302 | |
|
303 | 303 | } |
|
304 | 304 | |
|
305 | 305 | void init_local_mode_parameters( void ) |
|
306 | 306 | { |
|
307 | 307 | /** This function initialize the param_local global variable with default values. |
|
308 | 308 | * |
|
309 | 309 | */ |
|
310 | 310 | |
|
311 | 311 | unsigned int i; |
|
312 | 312 | |
|
313 | 313 | // LOCAL PARAMETERS |
|
314 | 314 | |
|
315 | 315 | BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) |
|
316 | 316 | BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) |
|
317 | BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX) | |
|
318 | 317 | |
|
319 | 318 | // init sequence counters |
|
320 | 319 | |
|
321 | 320 | for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++) |
|
322 | 321 | { |
|
323 | 322 | sequenceCounters_TC_EXE[i] = 0x00; |
|
324 | 323 | sequenceCounters_TM_DUMP[i] = 0x00; |
|
325 | 324 | } |
|
326 | 325 | sequenceCounters_SCIENCE_NORMAL_BURST = 0x00; |
|
327 | 326 | sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00; |
|
328 | 327 | sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
329 | 328 | } |
|
330 | 329 | |
|
331 | 330 | void reset_local_time( void ) |
|
332 | 331 | { |
|
333 | 332 | time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000 |
|
334 | 333 | } |
|
335 | 334 | |
|
336 | 335 | void create_names( void ) // create all names for tasks and queues |
|
337 | 336 | { |
|
338 | 337 | /** This function creates all RTEMS names used in the software for tasks and queues. |
|
339 | 338 | * |
|
340 | 339 | * @return RTEMS directive status codes: |
|
341 | 340 | * - RTEMS_SUCCESSFUL - successful completion |
|
342 | 341 | * |
|
343 | 342 | */ |
|
344 | 343 | |
|
345 | 344 | // task names |
|
346 | 345 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); |
|
347 | 346 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); |
|
348 | 347 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); |
|
349 | 348 | Task_name[TASKID_LOAD] = rtems_build_name( 'L', 'O', 'A', 'D' ); |
|
350 | 349 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); |
|
351 | 350 | Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' ); |
|
352 | 351 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); |
|
353 | 352 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); |
|
354 | 353 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
355 | 354 | Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' ); |
|
356 | 355 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); |
|
357 | 356 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); |
|
358 | 357 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); |
|
359 | 358 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); |
|
360 | 359 | Task_name[TASKID_LINK] = rtems_build_name( 'L', 'I', 'N', 'K' ); |
|
361 | 360 | Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' ); |
|
362 | 361 | Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' ); |
|
363 | 362 | Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' ); |
|
364 | 363 | Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' ); |
|
365 | 364 | |
|
366 | 365 | // rate monotonic period names |
|
367 | 366 | name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
368 | 367 | |
|
369 | 368 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
370 | 369 | misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
371 | 370 | misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' ); |
|
372 | 371 | misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' ); |
|
373 | 372 | misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' ); |
|
374 | 373 | |
|
375 | 374 | timecode_timer_name = rtems_build_name( 'S', 'P', 'T', 'C' ); |
|
376 | 375 | } |
|
377 | 376 | |
|
378 | 377 | int create_all_tasks( void ) // create all tasks which run in the software |
|
379 | 378 | { |
|
380 | 379 | /** This function creates all RTEMS tasks used in the software. |
|
381 | 380 | * |
|
382 | 381 | * @return RTEMS directive status codes: |
|
383 | 382 | * - RTEMS_SUCCESSFUL - task created successfully |
|
384 | 383 | * - RTEMS_INVALID_ADDRESS - id is NULL |
|
385 | 384 | * - RTEMS_INVALID_NAME - invalid task name |
|
386 | 385 | * - RTEMS_INVALID_PRIORITY - invalid task priority |
|
387 | 386 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured |
|
388 | 387 | * - RTEMS_TOO_MANY - too many tasks created |
|
389 | 388 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context |
|
390 | 389 | * - RTEMS_TOO_MANY - too many global objects |
|
391 | 390 | * |
|
392 | 391 | */ |
|
393 | 392 | |
|
394 | 393 | rtems_status_code status; |
|
395 | 394 | |
|
396 | 395 | //********** |
|
397 | 396 | // SPACEWIRE |
|
398 | 397 | // RECV |
|
399 | 398 | status = rtems_task_create( |
|
400 | 399 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, |
|
401 | 400 | RTEMS_DEFAULT_MODES, |
|
402 | 401 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] |
|
403 | 402 | ); |
|
404 | 403 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
405 | 404 | { |
|
406 | 405 | status = rtems_task_create( |
|
407 | 406 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
408 | 407 | RTEMS_DEFAULT_MODES, |
|
409 | 408 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND] |
|
410 | 409 | ); |
|
411 | 410 | } |
|
412 | 411 | if (status == RTEMS_SUCCESSFUL) // LINK |
|
413 | 412 | { |
|
414 | 413 | status = rtems_task_create( |
|
415 | 414 | Task_name[TASKID_LINK], TASK_PRIORITY_LINK, RTEMS_MINIMUM_STACK_SIZE, |
|
416 | 415 | RTEMS_DEFAULT_MODES, |
|
417 | 416 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LINK] |
|
418 | 417 | ); |
|
419 | 418 | } |
|
420 | 419 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
421 | 420 | { |
|
422 | 421 | status = rtems_task_create( |
|
423 | 422 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, |
|
424 | 423 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
425 | 424 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] |
|
426 | 425 | ); |
|
427 | 426 | } |
|
428 | 427 | if (status == RTEMS_SUCCESSFUL) // SPIQ |
|
429 | 428 | { |
|
430 | 429 | status = rtems_task_create( |
|
431 | 430 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, |
|
432 | 431 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
433 | 432 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] |
|
434 | 433 | ); |
|
435 | 434 | } |
|
436 | 435 | |
|
437 | 436 | //****************** |
|
438 | 437 | // SPECTRAL MATRICES |
|
439 | 438 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
440 | 439 | { |
|
441 | 440 | status = rtems_task_create( |
|
442 | 441 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, |
|
443 | 442 | RTEMS_DEFAULT_MODES, |
|
444 | 443 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] |
|
445 | 444 | ); |
|
446 | 445 | } |
|
447 | 446 | if (status == RTEMS_SUCCESSFUL) // PRC0 |
|
448 | 447 | { |
|
449 | 448 | status = rtems_task_create( |
|
450 | 449 | Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
451 | 450 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
452 | 451 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0] |
|
453 | 452 | ); |
|
454 | 453 | } |
|
455 | 454 | if (status == RTEMS_SUCCESSFUL) // AVF1 |
|
456 | 455 | { |
|
457 | 456 | status = rtems_task_create( |
|
458 | 457 | Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE, |
|
459 | 458 | RTEMS_DEFAULT_MODES, |
|
460 | 459 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1] |
|
461 | 460 | ); |
|
462 | 461 | } |
|
463 | 462 | if (status == RTEMS_SUCCESSFUL) // PRC1 |
|
464 | 463 | { |
|
465 | 464 | status = rtems_task_create( |
|
466 | 465 | Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
467 | 466 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
468 | 467 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1] |
|
469 | 468 | ); |
|
470 | 469 | } |
|
471 | 470 | if (status == RTEMS_SUCCESSFUL) // AVF2 |
|
472 | 471 | { |
|
473 | 472 | status = rtems_task_create( |
|
474 | 473 | Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE, |
|
475 | 474 | RTEMS_DEFAULT_MODES, |
|
476 | 475 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2] |
|
477 | 476 | ); |
|
478 | 477 | } |
|
479 | 478 | if (status == RTEMS_SUCCESSFUL) // PRC2 |
|
480 | 479 | { |
|
481 | 480 | status = rtems_task_create( |
|
482 | 481 | Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
483 | 482 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
484 | 483 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2] |
|
485 | 484 | ); |
|
486 | 485 | } |
|
487 | 486 | |
|
488 | 487 | //**************** |
|
489 | 488 | // WAVEFORM PICKER |
|
490 | 489 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
491 | 490 | { |
|
492 | 491 | status = rtems_task_create( |
|
493 | 492 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, |
|
494 | 493 | RTEMS_DEFAULT_MODES, |
|
495 | 494 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] |
|
496 | 495 | ); |
|
497 | 496 | } |
|
498 | 497 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
499 | 498 | { |
|
500 | 499 | status = rtems_task_create( |
|
501 | 500 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, |
|
502 | 501 | RTEMS_DEFAULT_MODES, |
|
503 | 502 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3] |
|
504 | 503 | ); |
|
505 | 504 | } |
|
506 | 505 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
507 | 506 | { |
|
508 | 507 | status = rtems_task_create( |
|
509 | 508 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, |
|
510 | 509 | RTEMS_DEFAULT_MODES, |
|
511 | 510 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2] |
|
512 | 511 | ); |
|
513 | 512 | } |
|
514 | 513 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
515 | 514 | { |
|
516 | 515 | status = rtems_task_create( |
|
517 | 516 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, |
|
518 | 517 | RTEMS_DEFAULT_MODES, |
|
519 | 518 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1] |
|
520 | 519 | ); |
|
521 | 520 | } |
|
522 | 521 | if (status == RTEMS_SUCCESSFUL) // SWBD |
|
523 | 522 | { |
|
524 | 523 | status = rtems_task_create( |
|
525 | 524 | Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE, |
|
526 | 525 | RTEMS_DEFAULT_MODES, |
|
527 | 526 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD] |
|
528 | 527 | ); |
|
529 | 528 | } |
|
530 | 529 | |
|
531 | 530 | //***** |
|
532 | 531 | // MISC |
|
533 | 532 | if (status == RTEMS_SUCCESSFUL) // LOAD |
|
534 | 533 | { |
|
535 | 534 | status = rtems_task_create( |
|
536 | 535 | Task_name[TASKID_LOAD], TASK_PRIORITY_LOAD, RTEMS_MINIMUM_STACK_SIZE, |
|
537 | 536 | RTEMS_DEFAULT_MODES, |
|
538 | 537 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LOAD] |
|
539 | 538 | ); |
|
540 | 539 | } |
|
541 | 540 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
542 | 541 | { |
|
543 | 542 | status = rtems_task_create( |
|
544 | 543 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, |
|
545 | 544 | RTEMS_DEFAULT_MODES, |
|
546 | 545 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] |
|
547 | 546 | ); |
|
548 | 547 | } |
|
549 | 548 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
550 | 549 | { |
|
551 | 550 | status = rtems_task_create( |
|
552 | 551 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, |
|
553 | 552 | RTEMS_DEFAULT_MODES, |
|
554 | 553 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS] |
|
555 | 554 | ); |
|
556 | 555 | } |
|
557 | 556 | |
|
558 | 557 | return status; |
|
559 | 558 | } |
|
560 | 559 | |
|
561 | 560 | int start_recv_send_tasks( void ) |
|
562 | 561 | { |
|
563 | 562 | rtems_status_code status; |
|
564 | 563 | |
|
565 | 564 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); |
|
566 | 565 | if (status!=RTEMS_SUCCESSFUL) { |
|
567 | 566 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") |
|
568 | 567 | } |
|
569 | 568 | |
|
570 | 569 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
571 | 570 | { |
|
572 | 571 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); |
|
573 | 572 | if (status!=RTEMS_SUCCESSFUL) { |
|
574 | 573 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") |
|
575 | 574 | } |
|
576 | 575 | } |
|
577 | 576 | |
|
578 | 577 | return status; |
|
579 | 578 | } |
|
580 | 579 | |
|
581 | 580 | int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS |
|
582 | 581 | { |
|
583 | 582 | /** This function starts all RTEMS tasks used in the software. |
|
584 | 583 | * |
|
585 | 584 | * @return RTEMS directive status codes: |
|
586 | 585 | * - RTEMS_SUCCESSFUL - ask started successfully |
|
587 | 586 | * - RTEMS_INVALID_ADDRESS - invalid task entry point |
|
588 | 587 | * - RTEMS_INVALID_ID - invalid task id |
|
589 | 588 | * - RTEMS_INCORRECT_STATE - task not in the dormant state |
|
590 | 589 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task |
|
591 | 590 | * |
|
592 | 591 | */ |
|
593 | 592 | // starts all the tasks fot eh flight software |
|
594 | 593 | |
|
595 | 594 | rtems_status_code status; |
|
596 | 595 | |
|
597 | 596 | //********** |
|
598 | 597 | // SPACEWIRE |
|
599 | 598 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); |
|
600 | 599 | if (status!=RTEMS_SUCCESSFUL) { |
|
601 | 600 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") |
|
602 | 601 | } |
|
603 | 602 | |
|
604 | 603 | if (status == RTEMS_SUCCESSFUL) // LINK |
|
605 | 604 | { |
|
606 | 605 | status = rtems_task_start( Task_id[TASKID_LINK], link_task, 1 ); |
|
607 | 606 | if (status!=RTEMS_SUCCESSFUL) { |
|
608 | 607 | BOOT_PRINTF("in INIT *** Error starting TASK_LINK\n") |
|
609 | 608 | } |
|
610 | 609 | } |
|
611 | 610 | |
|
612 | 611 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
613 | 612 | { |
|
614 | 613 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); |
|
615 | 614 | if (status!=RTEMS_SUCCESSFUL) { |
|
616 | 615 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") |
|
617 | 616 | } |
|
618 | 617 | } |
|
619 | 618 | |
|
620 | 619 | //****************** |
|
621 | 620 | // SPECTRAL MATRICES |
|
622 | 621 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
623 | 622 | { |
|
624 | 623 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY ); |
|
625 | 624 | if (status!=RTEMS_SUCCESSFUL) { |
|
626 | 625 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") |
|
627 | 626 | } |
|
628 | 627 | } |
|
629 | 628 | if (status == RTEMS_SUCCESSFUL) // PRC0 |
|
630 | 629 | { |
|
631 | 630 | status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY ); |
|
632 | 631 | if (status!=RTEMS_SUCCESSFUL) { |
|
633 | 632 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n") |
|
634 | 633 | } |
|
635 | 634 | } |
|
636 | 635 | if (status == RTEMS_SUCCESSFUL) // AVF1 |
|
637 | 636 | { |
|
638 | 637 | status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY ); |
|
639 | 638 | if (status!=RTEMS_SUCCESSFUL) { |
|
640 | 639 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n") |
|
641 | 640 | } |
|
642 | 641 | } |
|
643 | 642 | if (status == RTEMS_SUCCESSFUL) // PRC1 |
|
644 | 643 | { |
|
645 | 644 | status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY ); |
|
646 | 645 | if (status!=RTEMS_SUCCESSFUL) { |
|
647 | 646 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n") |
|
648 | 647 | } |
|
649 | 648 | } |
|
650 | 649 | if (status == RTEMS_SUCCESSFUL) // AVF2 |
|
651 | 650 | { |
|
652 | 651 | status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 ); |
|
653 | 652 | if (status!=RTEMS_SUCCESSFUL) { |
|
654 | 653 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n") |
|
655 | 654 | } |
|
656 | 655 | } |
|
657 | 656 | if (status == RTEMS_SUCCESSFUL) // PRC2 |
|
658 | 657 | { |
|
659 | 658 | status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 ); |
|
660 | 659 | if (status!=RTEMS_SUCCESSFUL) { |
|
661 | 660 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n") |
|
662 | 661 | } |
|
663 | 662 | } |
|
664 | 663 | |
|
665 | 664 | //**************** |
|
666 | 665 | // WAVEFORM PICKER |
|
667 | 666 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
668 | 667 | { |
|
669 | 668 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); |
|
670 | 669 | if (status!=RTEMS_SUCCESSFUL) { |
|
671 | 670 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") |
|
672 | 671 | } |
|
673 | 672 | } |
|
674 | 673 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
675 | 674 | { |
|
676 | 675 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); |
|
677 | 676 | if (status!=RTEMS_SUCCESSFUL) { |
|
678 | 677 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") |
|
679 | 678 | } |
|
680 | 679 | } |
|
681 | 680 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
682 | 681 | { |
|
683 | 682 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); |
|
684 | 683 | if (status!=RTEMS_SUCCESSFUL) { |
|
685 | 684 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") |
|
686 | 685 | } |
|
687 | 686 | } |
|
688 | 687 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
689 | 688 | { |
|
690 | 689 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); |
|
691 | 690 | if (status!=RTEMS_SUCCESSFUL) { |
|
692 | 691 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") |
|
693 | 692 | } |
|
694 | 693 | } |
|
695 | 694 | if (status == RTEMS_SUCCESSFUL) // SWBD |
|
696 | 695 | { |
|
697 | 696 | status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 ); |
|
698 | 697 | if (status!=RTEMS_SUCCESSFUL) { |
|
699 | 698 | BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n") |
|
700 | 699 | } |
|
701 | 700 | } |
|
702 | 701 | |
|
703 | 702 | //***** |
|
704 | 703 | // MISC |
|
705 | 704 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
706 | 705 | { |
|
707 | 706 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); |
|
708 | 707 | if (status!=RTEMS_SUCCESSFUL) { |
|
709 | 708 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") |
|
710 | 709 | } |
|
711 | 710 | } |
|
712 | 711 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
713 | 712 | { |
|
714 | 713 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); |
|
715 | 714 | if (status!=RTEMS_SUCCESSFUL) { |
|
716 | 715 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") |
|
717 | 716 | } |
|
718 | 717 | } |
|
719 | 718 | if (status == RTEMS_SUCCESSFUL) // LOAD |
|
720 | 719 | { |
|
721 | 720 | status = rtems_task_start( Task_id[TASKID_LOAD], load_task, 1 ); |
|
722 | 721 | if (status!=RTEMS_SUCCESSFUL) { |
|
723 | 722 | BOOT_PRINTF("in INIT *** Error starting TASK_LOAD\n") |
|
724 | 723 | } |
|
725 | 724 | } |
|
726 | 725 | |
|
727 | 726 | return status; |
|
728 | 727 | } |
|
729 | 728 | |
|
730 | 729 | rtems_status_code create_message_queues( void ) // create the two message queues used in the software |
|
731 | 730 | { |
|
732 | 731 | rtems_status_code status_recv; |
|
733 | 732 | rtems_status_code status_send; |
|
734 | 733 | rtems_status_code status_q_p0; |
|
735 | 734 | rtems_status_code status_q_p1; |
|
736 | 735 | rtems_status_code status_q_p2; |
|
737 | 736 | rtems_status_code ret; |
|
738 | 737 | rtems_id queue_id; |
|
739 | 738 | |
|
740 | 739 | //**************************************** |
|
741 | 740 | // create the queue for handling valid TCs |
|
742 | 741 | status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV], |
|
743 | 742 | MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE, |
|
744 | 743 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
745 | 744 | if ( status_recv != RTEMS_SUCCESSFUL ) { |
|
746 | 745 | PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv) |
|
747 | 746 | } |
|
748 | 747 | |
|
749 | 748 | //************************************************ |
|
750 | 749 | // create the queue for handling TM packet sending |
|
751 | 750 | status_send = rtems_message_queue_create( misc_name[QUEUE_SEND], |
|
752 | 751 | MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND, |
|
753 | 752 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
754 | 753 | if ( status_send != RTEMS_SUCCESSFUL ) { |
|
755 | 754 | PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send) |
|
756 | 755 | } |
|
757 | 756 | |
|
758 | 757 | //***************************************************************************** |
|
759 | 758 | // create the queue for handling averaged spectral matrices for processing @ f0 |
|
760 | 759 | status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0], |
|
761 | 760 | MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0, |
|
762 | 761 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
763 | 762 | if ( status_q_p0 != RTEMS_SUCCESSFUL ) { |
|
764 | 763 | PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0) |
|
765 | 764 | } |
|
766 | 765 | |
|
767 | 766 | //***************************************************************************** |
|
768 | 767 | // create the queue for handling averaged spectral matrices for processing @ f1 |
|
769 | 768 | status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1], |
|
770 | 769 | MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1, |
|
771 | 770 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
772 | 771 | if ( status_q_p1 != RTEMS_SUCCESSFUL ) { |
|
773 | 772 | PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1) |
|
774 | 773 | } |
|
775 | 774 | |
|
776 | 775 | //***************************************************************************** |
|
777 | 776 | // create the queue for handling averaged spectral matrices for processing @ f2 |
|
778 | 777 | status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2], |
|
779 | 778 | MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2, |
|
780 | 779 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
781 | 780 | if ( status_q_p2 != RTEMS_SUCCESSFUL ) { |
|
782 | 781 | PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2) |
|
783 | 782 | } |
|
784 | 783 | |
|
785 | 784 | if ( status_recv != RTEMS_SUCCESSFUL ) |
|
786 | 785 | { |
|
787 | 786 | ret = status_recv; |
|
788 | 787 | } |
|
789 | 788 | else if( status_send != RTEMS_SUCCESSFUL ) |
|
790 | 789 | { |
|
791 | 790 | ret = status_send; |
|
792 | 791 | } |
|
793 | 792 | else if( status_q_p0 != RTEMS_SUCCESSFUL ) |
|
794 | 793 | { |
|
795 | 794 | ret = status_q_p0; |
|
796 | 795 | } |
|
797 | 796 | else if( status_q_p1 != RTEMS_SUCCESSFUL ) |
|
798 | 797 | { |
|
799 | 798 | ret = status_q_p1; |
|
800 | 799 | } |
|
801 | 800 | else |
|
802 | 801 | { |
|
803 | 802 | ret = status_q_p2; |
|
804 | 803 | } |
|
805 | 804 | |
|
806 | 805 | return ret; |
|
807 | 806 | } |
|
808 | 807 | |
|
809 | 808 | rtems_status_code create_timecode_timer( void ) |
|
810 | 809 | { |
|
811 | 810 | rtems_status_code status; |
|
812 | 811 | |
|
813 | 812 | status = rtems_timer_create( timecode_timer_name, &timecode_timer_id ); |
|
814 | 813 | |
|
815 | 814 | if ( status != RTEMS_SUCCESSFUL ) |
|
816 | 815 | { |
|
817 | 816 | PRINTF1("in create_timer_timecode *** ERR creating SPTC timer, %d\n", status) |
|
818 | 817 | } |
|
819 | 818 | else |
|
820 | 819 | { |
|
821 | 820 | PRINTF("in create_timer_timecode *** OK creating SPTC timer\n") |
|
822 | 821 | } |
|
823 | 822 | |
|
824 | 823 | return status; |
|
825 | 824 | } |
|
826 | 825 | |
|
827 | 826 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ) |
|
828 | 827 | { |
|
829 | 828 | rtems_status_code status; |
|
830 | 829 | rtems_name queue_name; |
|
831 | 830 | |
|
832 | 831 | queue_name = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
833 | 832 | |
|
834 | 833 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
835 | 834 | |
|
836 | 835 | return status; |
|
837 | 836 | } |
|
838 | 837 | |
|
839 | 838 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ) |
|
840 | 839 | { |
|
841 | 840 | rtems_status_code status; |
|
842 | 841 | rtems_name queue_name; |
|
843 | 842 | |
|
844 | 843 | queue_name = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
845 | 844 | |
|
846 | 845 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
847 | 846 | |
|
848 | 847 | return status; |
|
849 | 848 | } |
|
850 | 849 | |
|
851 | 850 | rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id ) |
|
852 | 851 | { |
|
853 | 852 | rtems_status_code status; |
|
854 | 853 | rtems_name queue_name; |
|
855 | 854 | |
|
856 | 855 | queue_name = rtems_build_name( 'Q', '_', 'P', '0' ); |
|
857 | 856 | |
|
858 | 857 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
859 | 858 | |
|
860 | 859 | return status; |
|
861 | 860 | } |
|
862 | 861 | |
|
863 | 862 | rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ) |
|
864 | 863 | { |
|
865 | 864 | rtems_status_code status; |
|
866 | 865 | rtems_name queue_name; |
|
867 | 866 | |
|
868 | 867 | queue_name = rtems_build_name( 'Q', '_', 'P', '1' ); |
|
869 | 868 | |
|
870 | 869 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
871 | 870 | |
|
872 | 871 | return status; |
|
873 | 872 | } |
|
874 | 873 | |
|
875 | 874 | rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ) |
|
876 | 875 | { |
|
877 | 876 | rtems_status_code status; |
|
878 | 877 | rtems_name queue_name; |
|
879 | 878 | |
|
880 | 879 | queue_name = rtems_build_name( 'Q', '_', 'P', '2' ); |
|
881 | 880 | |
|
882 | 881 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
883 | 882 | |
|
884 | 883 | return status; |
|
885 | 884 | } |
|
886 | 885 | |
|
887 | 886 | void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max ) |
|
888 | 887 | { |
|
889 | 888 | u_int32_t count; |
|
890 | 889 | rtems_status_code status; |
|
891 | 890 | |
|
892 | 891 | status = rtems_message_queue_get_number_pending( queue_id, &count ); |
|
893 | 892 | |
|
894 | 893 | count = count + 1; |
|
895 | 894 | |
|
896 | 895 | if (status != RTEMS_SUCCESSFUL) |
|
897 | 896 | { |
|
898 | 897 | PRINTF1("in update_queue_max_count *** ERR = %d\n", status) |
|
899 | 898 | } |
|
900 | 899 | else |
|
901 | 900 | { |
|
902 | 901 | if (count > *fifo_size_max) |
|
903 | 902 | { |
|
904 | 903 | *fifo_size_max = count; |
|
905 | 904 | } |
|
906 | 905 | } |
|
907 | 906 | } |
|
908 | 907 | |
|
909 | 908 | void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize ) |
|
910 | 909 | { |
|
911 | 910 | unsigned char i; |
|
912 | 911 | |
|
913 | 912 | //*************** |
|
914 | 913 | // BUFFER ADDRESS |
|
915 | 914 | for(i=0; i<nbNodes; i++) |
|
916 | 915 | { |
|
917 | 916 | ring[i].coarseTime = 0xffffffff; |
|
918 | 917 | ring[i].fineTime = 0xffffffff; |
|
919 | 918 | ring[i].sid = 0x00; |
|
920 | 919 | ring[i].status = 0x00; |
|
921 | 920 | ring[i].buffer_address = (int) &buffer[ i * bufferSize ]; |
|
922 | 921 | } |
|
923 | 922 | |
|
924 | 923 | //***** |
|
925 | 924 | // NEXT |
|
926 | 925 | ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ]; |
|
927 | 926 | for(i=0; i<nbNodes-1; i++) |
|
928 | 927 | { |
|
929 | 928 | ring[i].next = (ring_node*) &ring[ i + 1 ]; |
|
930 | 929 | } |
|
931 | 930 | |
|
932 | 931 | //********* |
|
933 | 932 | // PREVIOUS |
|
934 | 933 | ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ]; |
|
935 | 934 | for(i=1; i<nbNodes; i++) |
|
936 | 935 | { |
|
937 | 936 | ring[i].previous = (ring_node*) &ring[ i - 1 ]; |
|
938 | 937 | } |
|
939 | 938 | } |
@@ -1,1628 +1,1628 | |||
|
1 | 1 | /** Functions to load and dump parameters in the LFR registers. |
|
2 | 2 | * |
|
3 | 3 | * @file |
|
4 | 4 | * @author P. LEROY |
|
5 | 5 | * |
|
6 | 6 | * A group of functions to handle TC related to parameter loading and dumping.\n |
|
7 | 7 | * TC_LFR_LOAD_COMMON_PAR\n |
|
8 | 8 | * TC_LFR_LOAD_NORMAL_PAR\n |
|
9 | 9 | * TC_LFR_LOAD_BURST_PAR\n |
|
10 | 10 | * TC_LFR_LOAD_SBM1_PAR\n |
|
11 | 11 | * TC_LFR_LOAD_SBM2_PAR\n |
|
12 | 12 | * |
|
13 | 13 | */ |
|
14 | 14 | |
|
15 | 15 | #include "tc_load_dump_parameters.h" |
|
16 | 16 | |
|
17 | 17 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_1; |
|
18 | 18 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_2; |
|
19 | 19 | ring_node kcoefficient_node_1; |
|
20 | 20 | ring_node kcoefficient_node_2; |
|
21 | 21 | |
|
22 | 22 | int action_load_common_par(ccsdsTelecommandPacket_t *TC) |
|
23 | 23 | { |
|
24 | 24 | /** This function updates the LFR registers with the incoming common parameters. |
|
25 | 25 | * |
|
26 | 26 | * @param TC points to the TeleCommand packet that is being processed |
|
27 | 27 | * |
|
28 | 28 | * |
|
29 | 29 | */ |
|
30 | 30 | |
|
31 | 31 | parameter_dump_packet.sy_lfr_common_parameters_spare = TC->dataAndCRC[0]; |
|
32 | 32 | parameter_dump_packet.sy_lfr_common_parameters = TC->dataAndCRC[1]; |
|
33 | 33 | set_wfp_data_shaping( ); |
|
34 | 34 | return LFR_SUCCESSFUL; |
|
35 | 35 | } |
|
36 | 36 | |
|
37 | 37 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
38 | 38 | { |
|
39 | 39 | /** This function updates the LFR registers with the incoming normal parameters. |
|
40 | 40 | * |
|
41 | 41 | * @param TC points to the TeleCommand packet that is being processed |
|
42 | 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 | 46 | int result; |
|
47 | 47 | int flag; |
|
48 | 48 | rtems_status_code status; |
|
49 | 49 | |
|
50 | 50 | flag = LFR_SUCCESSFUL; |
|
51 | 51 | |
|
52 | 52 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || |
|
53 | 53 | (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) { |
|
54 | 54 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
55 | 55 | flag = LFR_DEFAULT; |
|
56 | 56 | } |
|
57 | 57 | |
|
58 | 58 | // CHECK THE PARAMETERS SET CONSISTENCY |
|
59 | 59 | if (flag == LFR_SUCCESSFUL) |
|
60 | 60 | { |
|
61 | 61 | flag = check_normal_par_consistency( TC, queue_id ); |
|
62 | 62 | } |
|
63 | 63 | |
|
64 | 64 | // SET THE PARAMETERS IF THEY ARE CONSISTENT |
|
65 | 65 | if (flag == LFR_SUCCESSFUL) |
|
66 | 66 | { |
|
67 | 67 | result = set_sy_lfr_n_swf_l( TC ); |
|
68 | 68 | result = set_sy_lfr_n_swf_p( TC ); |
|
69 | 69 | result = set_sy_lfr_n_bp_p0( TC ); |
|
70 | 70 | result = set_sy_lfr_n_bp_p1( TC ); |
|
71 | 71 | result = set_sy_lfr_n_asm_p( TC ); |
|
72 | 72 | result = set_sy_lfr_n_cwf_long_f3( TC ); |
|
73 | 73 | } |
|
74 | 74 | |
|
75 | 75 | return flag; |
|
76 | 76 | } |
|
77 | 77 | |
|
78 | 78 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
79 | 79 | { |
|
80 | 80 | /** This function updates the LFR registers with the incoming burst parameters. |
|
81 | 81 | * |
|
82 | 82 | * @param TC points to the TeleCommand packet that is being processed |
|
83 | 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 | 87 | int flag; |
|
88 | 88 | rtems_status_code status; |
|
89 | 89 | unsigned char sy_lfr_b_bp_p0; |
|
90 | 90 | unsigned char sy_lfr_b_bp_p1; |
|
91 | 91 | float aux; |
|
92 | 92 | |
|
93 | 93 | flag = LFR_SUCCESSFUL; |
|
94 | 94 | |
|
95 | 95 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
96 | 96 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
97 | 97 | flag = LFR_DEFAULT; |
|
98 | 98 | } |
|
99 | 99 | |
|
100 | 100 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
101 | 101 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
102 | 102 | |
|
103 | 103 | // sy_lfr_b_bp_p0 shall not be lower than its default value |
|
104 | 104 | if (flag == LFR_SUCCESSFUL) |
|
105 | 105 | { |
|
106 | 106 | if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 ) |
|
107 | 107 | { |
|
108 | 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 | 109 | flag = WRONG_APP_DATA; |
|
110 | 110 | } |
|
111 | 111 | } |
|
112 | 112 | // sy_lfr_b_bp_p1 shall not be lower than its default value |
|
113 | 113 | if (flag == LFR_SUCCESSFUL) |
|
114 | 114 | { |
|
115 | 115 | if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 ) |
|
116 | 116 | { |
|
117 | 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 | 118 | flag = WRONG_APP_DATA; |
|
119 | 119 | } |
|
120 | 120 | } |
|
121 | 121 | //**************************************************************** |
|
122 | 122 | // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1 |
|
123 | 123 | if (flag == LFR_SUCCESSFUL) |
|
124 | 124 | { |
|
125 | 125 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
126 | 126 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
127 | 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 | 128 | if (aux > FLOAT_EQUAL_ZERO) |
|
129 | 129 | { |
|
130 | 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 | 131 | flag = LFR_DEFAULT; |
|
132 | 132 | } |
|
133 | 133 | } |
|
134 | 134 | |
|
135 | 135 | // SET THE PARAMETERS |
|
136 | 136 | if (flag == LFR_SUCCESSFUL) |
|
137 | 137 | { |
|
138 | 138 | flag = set_sy_lfr_b_bp_p0( TC ); |
|
139 | 139 | flag = set_sy_lfr_b_bp_p1( TC ); |
|
140 | 140 | } |
|
141 | 141 | |
|
142 | 142 | return flag; |
|
143 | 143 | } |
|
144 | 144 | |
|
145 | 145 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
146 | 146 | { |
|
147 | 147 | /** This function updates the LFR registers with the incoming sbm1 parameters. |
|
148 | 148 | * |
|
149 | 149 | * @param TC points to the TeleCommand packet that is being processed |
|
150 | 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 | 154 | int flag; |
|
155 | 155 | rtems_status_code status; |
|
156 | 156 | unsigned char sy_lfr_s1_bp_p0; |
|
157 | 157 | unsigned char sy_lfr_s1_bp_p1; |
|
158 | 158 | float aux; |
|
159 | 159 | |
|
160 | 160 | flag = LFR_SUCCESSFUL; |
|
161 | 161 | |
|
162 | 162 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
163 | 163 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
164 | 164 | flag = LFR_DEFAULT; |
|
165 | 165 | } |
|
166 | 166 | |
|
167 | 167 | sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
168 | 168 | sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
169 | 169 | |
|
170 | 170 | // sy_lfr_s1_bp_p0 |
|
171 | 171 | if (flag == LFR_SUCCESSFUL) |
|
172 | 172 | { |
|
173 | 173 | if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 ) |
|
174 | 174 | { |
|
175 | 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 | 176 | flag = WRONG_APP_DATA; |
|
177 | 177 | } |
|
178 | 178 | } |
|
179 | 179 | // sy_lfr_s1_bp_p1 |
|
180 | 180 | if (flag == LFR_SUCCESSFUL) |
|
181 | 181 | { |
|
182 | 182 | if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 ) |
|
183 | 183 | { |
|
184 | 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 | 185 | flag = WRONG_APP_DATA; |
|
186 | 186 | } |
|
187 | 187 | } |
|
188 | 188 | //****************************************************************** |
|
189 | 189 | // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1 |
|
190 | 190 | if (flag == LFR_SUCCESSFUL) |
|
191 | 191 | { |
|
192 | 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 | 193 | if (aux > FLOAT_EQUAL_ZERO) |
|
194 | 194 | { |
|
195 | 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 | 196 | flag = LFR_DEFAULT; |
|
197 | 197 | } |
|
198 | 198 | } |
|
199 | 199 | |
|
200 | 200 | // SET THE PARAMETERS |
|
201 | 201 | if (flag == LFR_SUCCESSFUL) |
|
202 | 202 | { |
|
203 | 203 | flag = set_sy_lfr_s1_bp_p0( TC ); |
|
204 | 204 | flag = set_sy_lfr_s1_bp_p1( TC ); |
|
205 | 205 | } |
|
206 | 206 | |
|
207 | 207 | return flag; |
|
208 | 208 | } |
|
209 | 209 | |
|
210 | 210 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
211 | 211 | { |
|
212 | 212 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
213 | 213 | * |
|
214 | 214 | * @param TC points to the TeleCommand packet that is being processed |
|
215 | 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 | 219 | int flag; |
|
220 | 220 | rtems_status_code status; |
|
221 | 221 | unsigned char sy_lfr_s2_bp_p0; |
|
222 | 222 | unsigned char sy_lfr_s2_bp_p1; |
|
223 | 223 | float aux; |
|
224 | 224 | |
|
225 | 225 | flag = LFR_SUCCESSFUL; |
|
226 | 226 | |
|
227 | 227 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
228 | 228 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
229 | 229 | flag = LFR_DEFAULT; |
|
230 | 230 | } |
|
231 | 231 | |
|
232 | 232 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
233 | 233 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
234 | 234 | |
|
235 | 235 | // sy_lfr_s2_bp_p0 |
|
236 | 236 | if (flag == LFR_SUCCESSFUL) |
|
237 | 237 | { |
|
238 | 238 | if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 ) |
|
239 | 239 | { |
|
240 | 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 | 241 | flag = WRONG_APP_DATA; |
|
242 | 242 | } |
|
243 | 243 | } |
|
244 | 244 | // sy_lfr_s2_bp_p1 |
|
245 | 245 | if (flag == LFR_SUCCESSFUL) |
|
246 | 246 | { |
|
247 | 247 | if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 ) |
|
248 | 248 | { |
|
249 | 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 | 250 | flag = WRONG_APP_DATA; |
|
251 | 251 | } |
|
252 | 252 | } |
|
253 | 253 | //****************************************************************** |
|
254 | 254 | // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1 |
|
255 | 255 | if (flag == LFR_SUCCESSFUL) |
|
256 | 256 | { |
|
257 | 257 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
258 | 258 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
259 | 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 | 260 | if (aux > FLOAT_EQUAL_ZERO) |
|
261 | 261 | { |
|
262 | 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 | 263 | flag = LFR_DEFAULT; |
|
264 | 264 | } |
|
265 | 265 | } |
|
266 | 266 | |
|
267 | 267 | // SET THE PARAMETERS |
|
268 | 268 | if (flag == LFR_SUCCESSFUL) |
|
269 | 269 | { |
|
270 | 270 | flag = set_sy_lfr_s2_bp_p0( TC ); |
|
271 | 271 | flag = set_sy_lfr_s2_bp_p1( TC ); |
|
272 | 272 | } |
|
273 | 273 | |
|
274 | 274 | return flag; |
|
275 | 275 | } |
|
276 | 276 | |
|
277 | 277 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
278 | 278 | { |
|
279 | 279 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
280 | 280 | * |
|
281 | 281 | * @param TC points to the TeleCommand packet that is being processed |
|
282 | 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 | 286 | int flag; |
|
287 | 287 | |
|
288 | 288 | flag = LFR_DEFAULT; |
|
289 | 289 | |
|
290 | 290 | flag = set_sy_lfr_kcoeff( TC, queue_id ); |
|
291 | 291 | |
|
292 | 292 | return flag; |
|
293 | 293 | } |
|
294 | 294 | |
|
295 | 295 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
296 | 296 | { |
|
297 | 297 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
298 | 298 | * |
|
299 | 299 | * @param TC points to the TeleCommand packet that is being processed |
|
300 | 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 | 304 | int flag; |
|
305 | 305 | |
|
306 | 306 | flag = LFR_DEFAULT; |
|
307 | 307 | |
|
308 | 308 | flag = set_sy_lfr_fbins( TC ); |
|
309 | 309 | |
|
310 | 310 | return flag; |
|
311 | 311 | } |
|
312 | 312 | |
|
313 | 313 | int action_load_filter_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
314 | 314 | { |
|
315 | 315 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
316 | 316 | * |
|
317 | 317 | * @param TC points to the TeleCommand packet that is being processed |
|
318 | 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 | 322 | int flag; |
|
323 | 323 | |
|
324 | 324 | flag = LFR_DEFAULT; |
|
325 | 325 | |
|
326 | 326 | flag = check_sy_lfr_filter_parameters( TC, queue_id ); |
|
327 | 327 | |
|
328 | 328 | if (flag == LFR_SUCCESSFUL) |
|
329 | 329 | { |
|
330 | 330 | parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ]; |
|
331 | 331 | parameter_dump_packet.sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ]; |
|
332 | 332 | parameter_dump_packet.sy_lfr_pas_filter_tbad[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 0 ]; |
|
333 | 333 | parameter_dump_packet.sy_lfr_pas_filter_tbad[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 1 ]; |
|
334 | 334 | parameter_dump_packet.sy_lfr_pas_filter_tbad[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 2 ]; |
|
335 | 335 | parameter_dump_packet.sy_lfr_pas_filter_tbad[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD + 3 ]; |
|
336 | 336 | parameter_dump_packet.sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ]; |
|
337 | 337 | parameter_dump_packet.sy_lfr_pas_filter_shift[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 0 ]; |
|
338 | 338 | parameter_dump_packet.sy_lfr_pas_filter_shift[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 1 ]; |
|
339 | 339 | parameter_dump_packet.sy_lfr_pas_filter_shift[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 2 ]; |
|
340 | 340 | parameter_dump_packet.sy_lfr_pas_filter_shift[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT + 3 ]; |
|
341 | 341 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 0 ]; |
|
342 | 342 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 1 ]; |
|
343 | 343 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[2] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 2 ]; |
|
344 | 344 | parameter_dump_packet.sy_lfr_sc_rw_delta_f[3] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F + 3 ]; |
|
345 | 345 | |
|
346 | 346 | //**************************** |
|
347 | 347 | // store PAS filter parameters |
|
348 | 348 | // sy_lfr_pas_filter_enabled |
|
349 | 349 | filterPar.spare_sy_lfr_pas_filter_enabled = parameter_dump_packet.spare_sy_lfr_pas_filter_enabled; |
|
350 | 350 | set_sy_lfr_pas_filter_enabled( parameter_dump_packet.spare_sy_lfr_pas_filter_enabled & 0x01 ); |
|
351 | 351 | // sy_lfr_pas_filter_modulus |
|
352 | 352 | filterPar.sy_lfr_pas_filter_modulus = parameter_dump_packet.sy_lfr_pas_filter_modulus; |
|
353 | 353 | // sy_lfr_pas_filter_tbad |
|
354 | 354 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_tbad, |
|
355 | 355 | parameter_dump_packet.sy_lfr_pas_filter_tbad ); |
|
356 | 356 | // sy_lfr_pas_filter_offset |
|
357 | 357 | filterPar.sy_lfr_pas_filter_offset = parameter_dump_packet.sy_lfr_pas_filter_offset; |
|
358 | 358 | // sy_lfr_pas_filter_shift |
|
359 | 359 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_pas_filter_shift, |
|
360 | 360 | parameter_dump_packet.sy_lfr_pas_filter_shift ); |
|
361 | 361 | |
|
362 | 362 | //**************************************************** |
|
363 | 363 | // store the parameter sy_lfr_sc_rw_delta_f as a float |
|
364 | 364 | copyFloatByChar( (unsigned char*) &filterPar.sy_lfr_sc_rw_delta_f, |
|
365 | 365 | parameter_dump_packet.sy_lfr_sc_rw_delta_f ); |
|
366 | 366 | } |
|
367 | 367 | |
|
368 | 368 | return flag; |
|
369 | 369 | } |
|
370 | 370 | |
|
371 | 371 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
372 | 372 | { |
|
373 | 373 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
374 | 374 | * |
|
375 | 375 | * @param TC points to the TeleCommand packet that is being processed |
|
376 | 376 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
377 | 377 | * |
|
378 | 378 | */ |
|
379 | 379 | |
|
380 | 380 | unsigned int address; |
|
381 | 381 | rtems_status_code status; |
|
382 | 382 | unsigned int freq; |
|
383 | 383 | unsigned int bin; |
|
384 | 384 | unsigned int coeff; |
|
385 | 385 | unsigned char *kCoeffPtr; |
|
386 | 386 | unsigned char *kCoeffDumpPtr; |
|
387 | 387 | |
|
388 | 388 | // for each sy_lfr_kcoeff_frequency there is 32 kcoeff |
|
389 | 389 | // F0 => 11 bins |
|
390 | 390 | // F1 => 13 bins |
|
391 | 391 | // F2 => 12 bins |
|
392 | 392 | // 36 bins to dump in two packets (30 bins max per packet) |
|
393 | 393 | |
|
394 | 394 | //********* |
|
395 | 395 | // PACKET 1 |
|
396 | 396 | // 11 F0 bins, 13 F1 bins and 6 F2 bins |
|
397 | 397 | kcoefficients_dump_1.destinationID = TC->sourceID; |
|
398 | 398 | increment_seq_counter_destination_id_dump( kcoefficients_dump_1.packetSequenceControl, TC->sourceID ); |
|
399 | 399 | for( freq=0; |
|
400 | 400 | freq<NB_BINS_COMPRESSED_SM_F0; |
|
401 | 401 | freq++ ) |
|
402 | 402 | { |
|
403 | 403 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq; |
|
404 | 404 | bin = freq; |
|
405 | 405 | // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm); |
|
406 | 406 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
407 | 407 | { |
|
408 | 408 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
409 | 409 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
410 | 410 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
411 | 411 | } |
|
412 | 412 | } |
|
413 | 413 | for( freq=NB_BINS_COMPRESSED_SM_F0; |
|
414 | 414 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
415 | 415 | freq++ ) |
|
416 | 416 | { |
|
417 | 417 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; |
|
418 | 418 | bin = freq - NB_BINS_COMPRESSED_SM_F0; |
|
419 | 419 | // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm); |
|
420 | 420 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
421 | 421 | { |
|
422 | 422 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
423 | 423 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
424 | 424 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
425 | 425 | } |
|
426 | 426 | } |
|
427 | 427 | for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
428 | 428 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6); |
|
429 | 429 | freq++ ) |
|
430 | 430 | { |
|
431 | 431 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; |
|
432 | 432 | bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
433 | 433 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); |
|
434 | 434 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
435 | 435 | { |
|
436 | 436 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
437 | 437 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
438 | 438 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
439 | 439 | } |
|
440 | 440 | } |
|
441 | 441 | kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
442 | 442 | kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
443 | 443 | kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
444 | 444 | kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
445 | 445 | kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
446 | 446 | kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
447 | 447 | // SEND DATA |
|
448 | 448 | kcoefficient_node_1.status = 1; |
|
449 | 449 | address = (unsigned int) &kcoefficient_node_1; |
|
450 | 450 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); |
|
451 | 451 | if (status != RTEMS_SUCCESSFUL) { |
|
452 | 452 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status) |
|
453 | 453 | } |
|
454 | 454 | |
|
455 | 455 | //******** |
|
456 | 456 | // PACKET 2 |
|
457 | 457 | // 6 F2 bins |
|
458 | 458 | kcoefficients_dump_2.destinationID = TC->sourceID; |
|
459 | 459 | increment_seq_counter_destination_id_dump( kcoefficients_dump_2.packetSequenceControl, TC->sourceID ); |
|
460 | 460 | for( freq=0; freq<6; freq++ ) |
|
461 | 461 | { |
|
462 | 462 | kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq; |
|
463 | 463 | bin = freq + 6; |
|
464 | 464 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); |
|
465 | 465 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
466 | 466 | { |
|
467 | 467 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
468 | 468 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
469 | 469 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
470 | 470 | } |
|
471 | 471 | } |
|
472 | 472 | kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
473 | 473 | kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
474 | 474 | kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
475 | 475 | kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
476 | 476 | kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
477 | 477 | kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
478 | 478 | // SEND DATA |
|
479 | 479 | kcoefficient_node_2.status = 1; |
|
480 | 480 | address = (unsigned int) &kcoefficient_node_2; |
|
481 | 481 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); |
|
482 | 482 | if (status != RTEMS_SUCCESSFUL) { |
|
483 | 483 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status) |
|
484 | 484 | } |
|
485 | 485 | |
|
486 | 486 | return status; |
|
487 | 487 | } |
|
488 | 488 | |
|
489 | 489 | int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
490 | 490 | { |
|
491 | 491 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. |
|
492 | 492 | * |
|
493 | 493 | * @param queue_id is the id of the queue which handles TM related to this execution step. |
|
494 | 494 | * |
|
495 | 495 | * @return RTEMS directive status codes: |
|
496 | 496 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
497 | 497 | * - RTEMS_INVALID_ID - invalid queue id |
|
498 | 498 | * - RTEMS_INVALID_SIZE - invalid message size |
|
499 | 499 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
500 | 500 | * - RTEMS_UNSATISFIED - out of message buffers |
|
501 | 501 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
502 | 502 | * |
|
503 | 503 | */ |
|
504 | 504 | |
|
505 | 505 | int status; |
|
506 | 506 | |
|
507 | 507 | increment_seq_counter_destination_id_dump( parameter_dump_packet.packetSequenceControl, TC->sourceID ); |
|
508 | 508 | parameter_dump_packet.destinationID = TC->sourceID; |
|
509 | 509 | |
|
510 | 510 | // UPDATE TIME |
|
511 | 511 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
512 | 512 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
513 | 513 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
514 | 514 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
515 | 515 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
516 | 516 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
517 | 517 | // SEND DATA |
|
518 | 518 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, |
|
519 | 519 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
520 | 520 | if (status != RTEMS_SUCCESSFUL) { |
|
521 | 521 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) |
|
522 | 522 | } |
|
523 | 523 | |
|
524 | 524 | return status; |
|
525 | 525 | } |
|
526 | 526 | |
|
527 | 527 | //*********************** |
|
528 | 528 | // NORMAL MODE PARAMETERS |
|
529 | 529 | |
|
530 | 530 | int check_normal_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
531 | 531 | { |
|
532 | 532 | unsigned char msb; |
|
533 | 533 | unsigned char lsb; |
|
534 | 534 | int flag; |
|
535 | 535 | float aux; |
|
536 | 536 | rtems_status_code status; |
|
537 | 537 | |
|
538 | 538 | unsigned int sy_lfr_n_swf_l; |
|
539 | 539 | unsigned int sy_lfr_n_swf_p; |
|
540 | 540 | unsigned int sy_lfr_n_asm_p; |
|
541 | 541 | unsigned char sy_lfr_n_bp_p0; |
|
542 | 542 | unsigned char sy_lfr_n_bp_p1; |
|
543 | 543 | unsigned char sy_lfr_n_cwf_long_f3; |
|
544 | 544 | |
|
545 | 545 | flag = LFR_SUCCESSFUL; |
|
546 | 546 | |
|
547 | 547 | //*************** |
|
548 | 548 | // get parameters |
|
549 | 549 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
550 | 550 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
551 | 551 | sy_lfr_n_swf_l = msb * 256 + lsb; |
|
552 | 552 | |
|
553 | 553 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
554 | 554 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
555 | 555 | sy_lfr_n_swf_p = msb * 256 + lsb; |
|
556 | 556 | |
|
557 | 557 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
558 | 558 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
559 | 559 | sy_lfr_n_asm_p = msb * 256 + lsb; |
|
560 | 560 | |
|
561 | 561 | sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
562 | 562 | |
|
563 | 563 | sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
564 | 564 | |
|
565 | 565 | sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
566 | 566 | |
|
567 | 567 | //****************** |
|
568 | 568 | // check consistency |
|
569 | 569 | // sy_lfr_n_swf_l |
|
570 | 570 | if (sy_lfr_n_swf_l != 2048) |
|
571 | 571 | { |
|
572 | 572 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l ); |
|
573 | 573 | flag = WRONG_APP_DATA; |
|
574 | 574 | } |
|
575 | 575 | // sy_lfr_n_swf_p |
|
576 | 576 | if (flag == LFR_SUCCESSFUL) |
|
577 | 577 | { |
|
578 | 578 | if ( sy_lfr_n_swf_p < 22 ) |
|
579 | 579 | { |
|
580 | 580 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p ); |
|
581 | 581 | flag = WRONG_APP_DATA; |
|
582 | 582 | } |
|
583 | 583 | } |
|
584 | 584 | // sy_lfr_n_bp_p0 |
|
585 | 585 | if (flag == LFR_SUCCESSFUL) |
|
586 | 586 | { |
|
587 | 587 | if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0) |
|
588 | 588 | { |
|
589 | 589 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 ); |
|
590 | 590 | flag = WRONG_APP_DATA; |
|
591 | 591 | } |
|
592 | 592 | } |
|
593 | 593 | // sy_lfr_n_asm_p |
|
594 | 594 | if (flag == LFR_SUCCESSFUL) |
|
595 | 595 | { |
|
596 | 596 | if (sy_lfr_n_asm_p == 0) |
|
597 | 597 | { |
|
598 | 598 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); |
|
599 | 599 | flag = WRONG_APP_DATA; |
|
600 | 600 | } |
|
601 | 601 | } |
|
602 | 602 | // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0 |
|
603 | 603 | if (flag == LFR_SUCCESSFUL) |
|
604 | 604 | { |
|
605 | 605 | aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0); |
|
606 | 606 | if (aux > FLOAT_EQUAL_ZERO) |
|
607 | 607 | { |
|
608 | 608 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); |
|
609 | 609 | flag = WRONG_APP_DATA; |
|
610 | 610 | } |
|
611 | 611 | } |
|
612 | 612 | // sy_lfr_n_bp_p1 |
|
613 | 613 | if (flag == LFR_SUCCESSFUL) |
|
614 | 614 | { |
|
615 | 615 | if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1) |
|
616 | 616 | { |
|
617 | 617 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); |
|
618 | 618 | flag = WRONG_APP_DATA; |
|
619 | 619 | } |
|
620 | 620 | } |
|
621 | 621 | // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0 |
|
622 | 622 | if (flag == LFR_SUCCESSFUL) |
|
623 | 623 | { |
|
624 | 624 | aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0); |
|
625 | 625 | if (aux > FLOAT_EQUAL_ZERO) |
|
626 | 626 | { |
|
627 | 627 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); |
|
628 | 628 | flag = LFR_DEFAULT; |
|
629 | 629 | } |
|
630 | 630 | } |
|
631 | 631 | // sy_lfr_n_cwf_long_f3 |
|
632 | 632 | |
|
633 | 633 | return flag; |
|
634 | 634 | } |
|
635 | 635 | |
|
636 | 636 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ) |
|
637 | 637 | { |
|
638 | 638 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). |
|
639 | 639 | * |
|
640 | 640 | * @param TC points to the TeleCommand packet that is being processed |
|
641 | 641 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
642 | 642 | * |
|
643 | 643 | */ |
|
644 | 644 | |
|
645 | 645 | int result; |
|
646 | 646 | |
|
647 | 647 | result = LFR_SUCCESSFUL; |
|
648 | 648 | |
|
649 | 649 | parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
650 | 650 | parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
651 | 651 | |
|
652 | 652 | return result; |
|
653 | 653 | } |
|
654 | 654 | |
|
655 | 655 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC ) |
|
656 | 656 | { |
|
657 | 657 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). |
|
658 | 658 | * |
|
659 | 659 | * @param TC points to the TeleCommand packet that is being processed |
|
660 | 660 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
661 | 661 | * |
|
662 | 662 | */ |
|
663 | 663 | |
|
664 | 664 | int result; |
|
665 | 665 | |
|
666 | 666 | result = LFR_SUCCESSFUL; |
|
667 | 667 | |
|
668 | 668 | parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
669 | 669 | parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
670 | 670 | |
|
671 | 671 | return result; |
|
672 | 672 | } |
|
673 | 673 | |
|
674 | 674 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ) |
|
675 | 675 | { |
|
676 | 676 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). |
|
677 | 677 | * |
|
678 | 678 | * @param TC points to the TeleCommand packet that is being processed |
|
679 | 679 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
680 | 680 | * |
|
681 | 681 | */ |
|
682 | 682 | |
|
683 | 683 | int result; |
|
684 | 684 | |
|
685 | 685 | result = LFR_SUCCESSFUL; |
|
686 | 686 | |
|
687 | 687 | parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
688 | 688 | parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
689 | 689 | |
|
690 | 690 | return result; |
|
691 | 691 | } |
|
692 | 692 | |
|
693 | 693 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
694 | 694 | { |
|
695 | 695 | /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0). |
|
696 | 696 | * |
|
697 | 697 | * @param TC points to the TeleCommand packet that is being processed |
|
698 | 698 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
699 | 699 | * |
|
700 | 700 | */ |
|
701 | 701 | |
|
702 | 702 | int status; |
|
703 | 703 | |
|
704 | 704 | status = LFR_SUCCESSFUL; |
|
705 | 705 | |
|
706 | 706 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
707 | 707 | |
|
708 | 708 | return status; |
|
709 | 709 | } |
|
710 | 710 | |
|
711 | 711 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC ) |
|
712 | 712 | { |
|
713 | 713 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). |
|
714 | 714 | * |
|
715 | 715 | * @param TC points to the TeleCommand packet that is being processed |
|
716 | 716 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
717 | 717 | * |
|
718 | 718 | */ |
|
719 | 719 | |
|
720 | 720 | int status; |
|
721 | 721 | |
|
722 | 722 | status = LFR_SUCCESSFUL; |
|
723 | 723 | |
|
724 | 724 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
725 | 725 | |
|
726 | 726 | return status; |
|
727 | 727 | } |
|
728 | 728 | |
|
729 | 729 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC ) |
|
730 | 730 | { |
|
731 | 731 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. |
|
732 | 732 | * |
|
733 | 733 | * @param TC points to the TeleCommand packet that is being processed |
|
734 | 734 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
735 | 735 | * |
|
736 | 736 | */ |
|
737 | 737 | |
|
738 | 738 | int status; |
|
739 | 739 | |
|
740 | 740 | status = LFR_SUCCESSFUL; |
|
741 | 741 | |
|
742 | 742 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
743 | 743 | |
|
744 | 744 | return status; |
|
745 | 745 | } |
|
746 | 746 | |
|
747 | 747 | //********************** |
|
748 | 748 | // BURST MODE PARAMETERS |
|
749 | 749 | int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC) |
|
750 | 750 | { |
|
751 | 751 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0). |
|
752 | 752 | * |
|
753 | 753 | * @param TC points to the TeleCommand packet that is being processed |
|
754 | 754 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
755 | 755 | * |
|
756 | 756 | */ |
|
757 | 757 | |
|
758 | 758 | int status; |
|
759 | 759 | |
|
760 | 760 | status = LFR_SUCCESSFUL; |
|
761 | 761 | |
|
762 | 762 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
763 | 763 | |
|
764 | 764 | return status; |
|
765 | 765 | } |
|
766 | 766 | |
|
767 | 767 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
768 | 768 | { |
|
769 | 769 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1). |
|
770 | 770 | * |
|
771 | 771 | * @param TC points to the TeleCommand packet that is being processed |
|
772 | 772 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
773 | 773 | * |
|
774 | 774 | */ |
|
775 | 775 | |
|
776 | 776 | int status; |
|
777 | 777 | |
|
778 | 778 | status = LFR_SUCCESSFUL; |
|
779 | 779 | |
|
780 | 780 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
781 | 781 | |
|
782 | 782 | return status; |
|
783 | 783 | } |
|
784 | 784 | |
|
785 | 785 | //********************* |
|
786 | 786 | // SBM1 MODE PARAMETERS |
|
787 | 787 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
788 | 788 | { |
|
789 | 789 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0). |
|
790 | 790 | * |
|
791 | 791 | * @param TC points to the TeleCommand packet that is being processed |
|
792 | 792 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
793 | 793 | * |
|
794 | 794 | */ |
|
795 | 795 | |
|
796 | 796 | int status; |
|
797 | 797 | |
|
798 | 798 | status = LFR_SUCCESSFUL; |
|
799 | 799 | |
|
800 | 800 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
801 | 801 | |
|
802 | 802 | return status; |
|
803 | 803 | } |
|
804 | 804 | |
|
805 | 805 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
806 | 806 | { |
|
807 | 807 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1). |
|
808 | 808 | * |
|
809 | 809 | * @param TC points to the TeleCommand packet that is being processed |
|
810 | 810 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
811 | 811 | * |
|
812 | 812 | */ |
|
813 | 813 | |
|
814 | 814 | int status; |
|
815 | 815 | |
|
816 | 816 | status = LFR_SUCCESSFUL; |
|
817 | 817 | |
|
818 | 818 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
819 | 819 | |
|
820 | 820 | return status; |
|
821 | 821 | } |
|
822 | 822 | |
|
823 | 823 | //********************* |
|
824 | 824 | // SBM2 MODE PARAMETERS |
|
825 | 825 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
826 | 826 | { |
|
827 | 827 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0). |
|
828 | 828 | * |
|
829 | 829 | * @param TC points to the TeleCommand packet that is being processed |
|
830 | 830 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
831 | 831 | * |
|
832 | 832 | */ |
|
833 | 833 | |
|
834 | 834 | int status; |
|
835 | 835 | |
|
836 | 836 | status = LFR_SUCCESSFUL; |
|
837 | 837 | |
|
838 | 838 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
839 | 839 | |
|
840 | 840 | return status; |
|
841 | 841 | } |
|
842 | 842 | |
|
843 | 843 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
844 | 844 | { |
|
845 | 845 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1). |
|
846 | 846 | * |
|
847 | 847 | * @param TC points to the TeleCommand packet that is being processed |
|
848 | 848 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
849 | 849 | * |
|
850 | 850 | */ |
|
851 | 851 | |
|
852 | 852 | int status; |
|
853 | 853 | |
|
854 | 854 | status = LFR_SUCCESSFUL; |
|
855 | 855 | |
|
856 | 856 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
857 | 857 | |
|
858 | 858 | return status; |
|
859 | 859 | } |
|
860 | 860 | |
|
861 | 861 | //******************* |
|
862 | 862 | // TC_LFR_UPDATE_INFO |
|
863 | 863 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) |
|
864 | 864 | { |
|
865 | 865 | unsigned int status; |
|
866 | 866 | |
|
867 | 867 | if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) |
|
868 | 868 | || (mode == LFR_MODE_BURST) |
|
869 | 869 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) |
|
870 | 870 | { |
|
871 | 871 | status = LFR_SUCCESSFUL; |
|
872 | 872 | } |
|
873 | 873 | else |
|
874 | 874 | { |
|
875 | 875 | status = LFR_DEFAULT; |
|
876 | 876 | } |
|
877 | 877 | |
|
878 | 878 | return status; |
|
879 | 879 | } |
|
880 | 880 | |
|
881 | 881 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ) |
|
882 | 882 | { |
|
883 | 883 | unsigned int status; |
|
884 | 884 | |
|
885 | 885 | if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) |
|
886 | 886 | || (mode == TDS_MODE_BURST) |
|
887 | 887 | || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) |
|
888 | 888 | || (mode == TDS_MODE_LFM)) |
|
889 | 889 | { |
|
890 | 890 | status = LFR_SUCCESSFUL; |
|
891 | 891 | } |
|
892 | 892 | else |
|
893 | 893 | { |
|
894 | 894 | status = LFR_DEFAULT; |
|
895 | 895 | } |
|
896 | 896 | |
|
897 | 897 | return status; |
|
898 | 898 | } |
|
899 | 899 | |
|
900 | 900 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ) |
|
901 | 901 | { |
|
902 | 902 | unsigned int status; |
|
903 | 903 | |
|
904 | 904 | if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) |
|
905 | 905 | || (mode == THR_MODE_BURST)) |
|
906 | 906 | { |
|
907 | 907 | status = LFR_SUCCESSFUL; |
|
908 | 908 | } |
|
909 | 909 | else |
|
910 | 910 | { |
|
911 | 911 | status = LFR_DEFAULT; |
|
912 | 912 | } |
|
913 | 913 | |
|
914 | 914 | return status; |
|
915 | 915 | } |
|
916 | 916 | |
|
917 | 917 | void getReactionWheelsFrequencies( ccsdsTelecommandPacket_t *TC ) |
|
918 | 918 | { |
|
919 | 919 | /** This function get the reaction wheels frequencies in the incoming TC_LFR_UPDATE_INFO and copy the values locally. |
|
920 | 920 | * |
|
921 | 921 | * @param TC points to the TeleCommand packet that is being processed |
|
922 | 922 | * |
|
923 | 923 | */ |
|
924 | 924 | |
|
925 | 925 | unsigned char * bytePosPtr; // pointer to the beginning of the incoming TC packet |
|
926 | 926 | |
|
927 | 927 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
928 | 928 | |
|
929 | 929 | // cp_rpw_sc_rw1_f1 |
|
930 | 930 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw1_f1, |
|
931 | 931 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F1 ] ); |
|
932 | 932 | |
|
933 | 933 | // cp_rpw_sc_rw1_f2 |
|
934 | 934 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw1_f2, |
|
935 | 935 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW1_F2 ] ); |
|
936 | 936 | |
|
937 | 937 | // cp_rpw_sc_rw2_f1 |
|
938 | 938 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw2_f1, |
|
939 | 939 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F1 ] ); |
|
940 | 940 | |
|
941 | 941 | // cp_rpw_sc_rw2_f2 |
|
942 | 942 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw2_f2, |
|
943 | 943 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW2_F2 ] ); |
|
944 | 944 | |
|
945 | 945 | // cp_rpw_sc_rw3_f1 |
|
946 | 946 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw3_f1, |
|
947 | 947 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F1 ] ); |
|
948 | 948 | |
|
949 | 949 | // cp_rpw_sc_rw3_f2 |
|
950 | 950 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw3_f2, |
|
951 | 951 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW3_F2 ] ); |
|
952 | 952 | |
|
953 | 953 | // cp_rpw_sc_rw4_f1 |
|
954 | 954 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw4_f1, |
|
955 | 955 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F1 ] ); |
|
956 | 956 | |
|
957 | 957 | // cp_rpw_sc_rw4_f2 |
|
958 | 958 | copyFloatByChar( (unsigned char*) &cp_rpw_sc_rw4_f2, |
|
959 | 959 | (unsigned char*) &bytePosPtr[ BYTE_POS_UPDATE_INFO_CP_RPW_SC_RW4_F2 ] ); |
|
960 | 960 | } |
|
961 | 961 | |
|
962 | 962 | void setFBinMask( unsigned char *fbins_mask, float rw_f, unsigned char deltaFreq, unsigned char flag ) |
|
963 | 963 | { |
|
964 | 964 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. |
|
965 | 965 | * |
|
966 | 966 | * @param fbins_mask |
|
967 | 967 | * @param rw_f is the reaction wheel frequency to filter |
|
968 | 968 | * @param delta_f is the frequency step between the frequency bins, it depends on the frequency channel |
|
969 | 969 | * @param flag [true] filtering enabled [false] filtering disabled |
|
970 | 970 | * |
|
971 | 971 | * @return void |
|
972 | 972 | * |
|
973 | 973 | */ |
|
974 | 974 | |
|
975 | 975 | float f_RW_min; |
|
976 | 976 | float f_RW_MAX; |
|
977 | 977 | float fi_min; |
|
978 | 978 | float fi_MAX; |
|
979 | 979 | float fi; |
|
980 | 980 | float deltaBelow; |
|
981 | 981 | float deltaAbove; |
|
982 | 982 | int binBelow; |
|
983 | 983 | int binAbove; |
|
984 | 984 | int closestBin; |
|
985 | 985 | unsigned int whichByte; |
|
986 | 986 | int selectedByte; |
|
987 | 987 | int bin; |
|
988 | 988 | int binToRemove[3]; |
|
989 | 989 | int k; |
|
990 | 990 | |
|
991 | 991 | whichByte = 0; |
|
992 | 992 | bin = 0; |
|
993 | 993 | |
|
994 | 994 | binToRemove[0] = -1; |
|
995 | 995 | binToRemove[1] = -1; |
|
996 | 996 | binToRemove[2] = -1; |
|
997 | 997 | |
|
998 | 998 | // compute the frequency range to filter [ rw_f - delta_f/2; rw_f + delta_f/2 ] |
|
999 | 999 | f_RW_min = rw_f - filterPar.sy_lfr_sc_rw_delta_f / 2.; |
|
1000 | 1000 | f_RW_MAX = rw_f + filterPar.sy_lfr_sc_rw_delta_f / 2.; |
|
1001 | 1001 | |
|
1002 | 1002 | // compute the index of the frequency bin immediately below rw_f |
|
1003 | 1003 | binBelow = (int) ( floor( ((double) rw_f) / ((double) deltaFreq)) ); |
|
1004 | 1004 | deltaBelow = rw_f - binBelow * deltaFreq; |
|
1005 | 1005 | |
|
1006 | 1006 | // compute the index of the frequency bin immediately above rw_f |
|
1007 | 1007 | binAbove = (int) ( ceil( ((double) rw_f) / ((double) deltaFreq)) ); |
|
1008 | 1008 | deltaAbove = binAbove * deltaFreq - rw_f; |
|
1009 | 1009 | |
|
1010 | 1010 | // search the closest bin |
|
1011 | 1011 | if (deltaAbove > deltaBelow) |
|
1012 | 1012 | { |
|
1013 | 1013 | closestBin = binBelow; |
|
1014 | 1014 | } |
|
1015 | 1015 | else |
|
1016 | 1016 | { |
|
1017 | 1017 | closestBin = binAbove; |
|
1018 | 1018 | } |
|
1019 | 1019 | |
|
1020 | 1020 | // compute the fi interval [fi - Delta_f * 0.285, fi + Delta_f * 0.285] |
|
1021 | 1021 | fi = closestBin * deltaFreq; |
|
1022 | 1022 | |
|
1023 | 1023 | fi_min = fi - (deltaFreq * 0.285); |
|
1024 | 1024 | if ( fi_min < 0 ) |
|
1025 | 1025 | { |
|
1026 | 1026 | fi_min = 0; |
|
1027 | 1027 | } |
|
1028 | 1028 | else if ( fi_min > (deltaFreq*127) ) |
|
1029 | 1029 | { |
|
1030 | 1030 | fi_min = -1; |
|
1031 | 1031 | } |
|
1032 | 1032 | |
|
1033 | 1033 | fi_MAX = fi + (deltaFreq * 0.285); |
|
1034 | 1034 | if ( fi_MAX > (deltaFreq*127) ) |
|
1035 | 1035 | { |
|
1036 | 1036 | fi_MAX = -1; |
|
1037 | 1037 | } |
|
1038 | 1038 | |
|
1039 | 1039 | // 1. IF [ f_RW_min, f_RW_MAX] is included in [ fi_min; fi_MAX ] |
|
1040 | 1040 | // => remove f_(i), f_(i-1) and f_(i+1) |
|
1041 | 1041 | if ( ( f_RW_min > fi_min ) && ( f_RW_MAX < fi_MAX ) ) |
|
1042 | 1042 | { |
|
1043 | 1043 | binToRemove[0] = closestBin - 1; |
|
1044 | 1044 | binToRemove[1] = closestBin; |
|
1045 | 1045 | binToRemove[2] = closestBin + 1; |
|
1046 | 1046 | } |
|
1047 | 1047 | // 2. ELSE |
|
1048 | 1048 | // => remove the two f_(i) which are around f_RW |
|
1049 | 1049 | else |
|
1050 | 1050 | { |
|
1051 | 1051 | binToRemove[0] = binBelow; |
|
1052 | 1052 | binToRemove[1] = binAbove; |
|
1053 | 1053 | binToRemove[2] = -1; |
|
1054 | 1054 | } |
|
1055 | 1055 | |
|
1056 | 1056 | for (k = 0; k <= 3; k++) |
|
1057 | 1057 | { |
|
1058 | 1058 | bin = binToRemove[k]; |
|
1059 | 1059 | if ( (bin >= 0) && (bin <= 127) ) |
|
1060 | 1060 | { |
|
1061 | 1061 | if (flag == 1) |
|
1062 | 1062 | { |
|
1063 | 1063 | whichByte = (bin >> 3); // division by 8 |
|
1064 | 1064 | selectedByte = ( 1 << (bin - (whichByte * 8)) ); |
|
1065 | 1065 | fbins_mask[15 - whichByte] = fbins_mask[15 - whichByte] & ((unsigned char) (~selectedByte)); // bytes are ordered MSB first in the packets |
|
1066 | 1066 | } |
|
1067 | 1067 | } |
|
1068 | 1068 | } |
|
1069 | 1069 | } |
|
1070 | 1070 | |
|
1071 | 1071 | void build_sy_lfr_rw_mask( unsigned int channel ) |
|
1072 | 1072 | { |
|
1073 | 1073 | unsigned char local_rw_fbins_mask[16]; |
|
1074 | 1074 | unsigned char *maskPtr; |
|
1075 | 1075 | double deltaF; |
|
1076 | 1076 | unsigned k; |
|
1077 | 1077 | |
|
1078 | 1078 | k = 0; |
|
1079 | 1079 | |
|
1080 | 1080 | maskPtr = NULL; |
|
1081 | 1081 | deltaF = 1.; |
|
1082 | 1082 | |
|
1083 | 1083 | switch (channel) |
|
1084 | 1084 | { |
|
1085 | 1085 | case 0: |
|
1086 | 1086 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f0_word1; |
|
1087 | 1087 | deltaF = 96.; |
|
1088 | 1088 | break; |
|
1089 | 1089 | case 1: |
|
1090 | 1090 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f1_word1; |
|
1091 | 1091 | deltaF = 16.; |
|
1092 | 1092 | break; |
|
1093 | 1093 | case 2: |
|
1094 | 1094 | maskPtr = parameter_dump_packet.sy_lfr_rw_mask_f2_word1; |
|
1095 | 1095 | deltaF = 1.; |
|
1096 | 1096 | break; |
|
1097 | 1097 | default: |
|
1098 | 1098 | break; |
|
1099 | 1099 | } |
|
1100 | 1100 | |
|
1101 | 1101 | for (k = 0; k < 16; k++) |
|
1102 | 1102 | { |
|
1103 | 1103 | local_rw_fbins_mask[k] = 0xff; |
|
1104 | 1104 | } |
|
1105 | 1105 | |
|
1106 | 1106 | // RW1 F1 |
|
1107 | 1107 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x80) >> 7 ); // [1000 0000] |
|
1108 | 1108 | |
|
1109 | 1109 | // RW1 F2 |
|
1110 | 1110 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw1_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x40) >> 6 ); // [0100 0000] |
|
1111 | 1111 | |
|
1112 | 1112 | // RW2 F1 |
|
1113 | 1113 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x20) >> 5 ); // [0010 0000] |
|
1114 | 1114 | |
|
1115 | 1115 | // RW2 F2 |
|
1116 | 1116 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw2_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x10) >> 4 ); // [0001 0000] |
|
1117 | 1117 | |
|
1118 | 1118 | // RW3 F1 |
|
1119 | 1119 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x08) >> 3 ); // [0000 1000] |
|
1120 | 1120 | |
|
1121 | 1121 | // RW3 F2 |
|
1122 | 1122 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw3_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x04) >> 2 ); // [0000 0100] |
|
1123 | 1123 | |
|
1124 | 1124 | // RW4 F1 |
|
1125 | 1125 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw4_f1, deltaF, (cp_rpw_sc_rw_f_flags & 0x02) >> 1 ); // [0000 0010] |
|
1126 | 1126 | |
|
1127 | 1127 | // RW4 F2 |
|
1128 | 1128 | setFBinMask( local_rw_fbins_mask, cp_rpw_sc_rw4_f2, deltaF, (cp_rpw_sc_rw_f_flags & 0x01) ); // [0000 0001] |
|
1129 | 1129 | |
|
1130 | 1130 | // update the value of the fbins related to reaction wheels frequency filtering |
|
1131 | 1131 | if (maskPtr != NULL) |
|
1132 | 1132 | { |
|
1133 | 1133 | for (k = 0; k < 16; k++) |
|
1134 | 1134 | { |
|
1135 | 1135 | maskPtr[k] = local_rw_fbins_mask[k]; |
|
1136 | 1136 | } |
|
1137 | 1137 | } |
|
1138 | 1138 | } |
|
1139 | 1139 | |
|
1140 | 1140 | void build_sy_lfr_rw_masks( void ) |
|
1141 | 1141 | { |
|
1142 | 1142 | build_sy_lfr_rw_mask( 0 ); |
|
1143 | 1143 | build_sy_lfr_rw_mask( 1 ); |
|
1144 | 1144 | build_sy_lfr_rw_mask( 2 ); |
|
1145 | 1145 | |
|
1146 | 1146 | merge_fbins_masks(); |
|
1147 | 1147 | } |
|
1148 | 1148 | |
|
1149 | 1149 | void merge_fbins_masks( void ) |
|
1150 | 1150 | { |
|
1151 | 1151 | unsigned char k; |
|
1152 | 1152 | |
|
1153 | 1153 | unsigned char *fbins_f0; |
|
1154 | 1154 | unsigned char *fbins_f1; |
|
1155 | 1155 | unsigned char *fbins_f2; |
|
1156 | 1156 | unsigned char *rw_mask_f0; |
|
1157 | 1157 | unsigned char *rw_mask_f1; |
|
1158 | 1158 | unsigned char *rw_mask_f2; |
|
1159 | 1159 | |
|
1160 | 1160 | fbins_f0 = parameter_dump_packet.sy_lfr_fbins_f0_word1; |
|
1161 | 1161 | fbins_f1 = parameter_dump_packet.sy_lfr_fbins_f1_word1; |
|
1162 | 1162 | fbins_f2 = parameter_dump_packet.sy_lfr_fbins_f2_word1; |
|
1163 | 1163 | rw_mask_f0 = parameter_dump_packet.sy_lfr_rw_mask_f0_word1; |
|
1164 | 1164 | rw_mask_f1 = parameter_dump_packet.sy_lfr_rw_mask_f1_word1; |
|
1165 | 1165 | rw_mask_f2 = parameter_dump_packet.sy_lfr_rw_mask_f2_word1; |
|
1166 | 1166 | |
|
1167 | 1167 | for( k=0; k < 16; k++ ) |
|
1168 | 1168 | { |
|
1169 | 1169 | fbins_masks.merged_fbins_mask_f0[k] = fbins_f0[k] & rw_mask_f0[k]; |
|
1170 | 1170 | fbins_masks.merged_fbins_mask_f1[k] = fbins_f1[k] & rw_mask_f1[k]; |
|
1171 | 1171 | fbins_masks.merged_fbins_mask_f2[k] = fbins_f2[k] & rw_mask_f2[k]; |
|
1172 | 1172 | } |
|
1173 | 1173 | } |
|
1174 | 1174 | |
|
1175 | 1175 | //*********** |
|
1176 | 1176 | // FBINS MASK |
|
1177 | 1177 | |
|
1178 | 1178 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ) |
|
1179 | 1179 | { |
|
1180 | 1180 | int status; |
|
1181 | 1181 | unsigned int k; |
|
1182 | 1182 | unsigned char *fbins_mask_dump; |
|
1183 | 1183 | unsigned char *fbins_mask_TC; |
|
1184 | 1184 | |
|
1185 | 1185 | status = LFR_SUCCESSFUL; |
|
1186 | 1186 | |
|
1187 | 1187 | fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1; |
|
1188 | 1188 | fbins_mask_TC = TC->dataAndCRC; |
|
1189 | 1189 | |
|
1190 | 1190 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) |
|
1191 | 1191 | { |
|
1192 | 1192 | fbins_mask_dump[k] = fbins_mask_TC[k]; |
|
1193 | 1193 | } |
|
1194 | 1194 | |
|
1195 | 1195 | return status; |
|
1196 | 1196 | } |
|
1197 | 1197 | |
|
1198 | 1198 | //*************************** |
|
1199 | 1199 | // TC_LFR_LOAD_PAS_FILTER_PAR |
|
1200 | 1200 | |
|
1201 | 1201 | int check_sy_lfr_filter_parameters( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
1202 | 1202 | { |
|
1203 | 1203 | int flag; |
|
1204 | 1204 | rtems_status_code status; |
|
1205 | 1205 | |
|
1206 | 1206 | unsigned char sy_lfr_pas_filter_enabled; |
|
1207 | 1207 | unsigned char sy_lfr_pas_filter_modulus; |
|
1208 | 1208 | float sy_lfr_pas_filter_tbad; |
|
1209 | 1209 | unsigned char sy_lfr_pas_filter_offset; |
|
1210 | 1210 | float sy_lfr_pas_filter_shift; |
|
1211 | 1211 | float sy_lfr_sc_rw_delta_f; |
|
1212 | 1212 | char *parPtr; |
|
1213 | 1213 | |
|
1214 | 1214 | flag = LFR_SUCCESSFUL; |
|
1215 | 1215 | sy_lfr_pas_filter_tbad = 0.0; |
|
1216 | 1216 | sy_lfr_pas_filter_shift = 0.0; |
|
1217 | 1217 | sy_lfr_sc_rw_delta_f = 0.0; |
|
1218 | 1218 | parPtr = NULL; |
|
1219 | 1219 | |
|
1220 | 1220 | //*************** |
|
1221 | 1221 | // get parameters |
|
1222 | 1222 | sy_lfr_pas_filter_enabled = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_ENABLED ] & 0x01; // [0000 0001] |
|
1223 | 1223 | sy_lfr_pas_filter_modulus = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS ]; |
|
1224 | 1224 | copyFloatByChar( |
|
1225 | 1225 | (unsigned char*) &sy_lfr_pas_filter_tbad, |
|
1226 | 1226 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD ] |
|
1227 | 1227 | ); |
|
1228 | 1228 | sy_lfr_pas_filter_offset = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET ]; |
|
1229 | 1229 | copyFloatByChar( |
|
1230 | 1230 | (unsigned char*) &sy_lfr_pas_filter_shift, |
|
1231 | 1231 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT ] |
|
1232 | 1232 | ); |
|
1233 | 1233 | copyFloatByChar( |
|
1234 | 1234 | (unsigned char*) &sy_lfr_sc_rw_delta_f, |
|
1235 | 1235 | (unsigned char*) &TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_SC_RW_DELTA_F ] |
|
1236 | 1236 | ); |
|
1237 | 1237 | |
|
1238 | 1238 | //****************** |
|
1239 | 1239 | // CHECK CONSISTENCY |
|
1240 | 1240 | |
|
1241 | 1241 | //************************** |
|
1242 | 1242 | // sy_lfr_pas_filter_enabled |
|
1243 | 1243 | // nothing to check, value is 0 or 1 |
|
1244 | 1244 | |
|
1245 | 1245 | //************************** |
|
1246 | 1246 | // sy_lfr_pas_filter_modulus |
|
1247 | 1247 | if ( (sy_lfr_pas_filter_modulus < 4) || (sy_lfr_pas_filter_modulus > 8) ) |
|
1248 | 1248 | { |
|
1249 | 1249 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_MODULUS+10, sy_lfr_pas_filter_modulus ); |
|
1250 | 1250 | flag = WRONG_APP_DATA; |
|
1251 | 1251 | } |
|
1252 | 1252 | |
|
1253 | 1253 | //*********************** |
|
1254 | 1254 | // sy_lfr_pas_filter_tbad |
|
1255 | 1255 | if ( (sy_lfr_pas_filter_tbad < 0.0) || (sy_lfr_pas_filter_tbad > 4.0) ) |
|
1256 | 1256 | { |
|
1257 | 1257 | parPtr = (char*) &sy_lfr_pas_filter_tbad; |
|
1258 | 1258 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_TBAD+10, parPtr[3] ); |
|
1259 | 1259 | flag = WRONG_APP_DATA; |
|
1260 | 1260 | } |
|
1261 | 1261 | |
|
1262 | 1262 | //************************* |
|
1263 | 1263 | // sy_lfr_pas_filter_offset |
|
1264 | 1264 | if (flag == LFR_SUCCESSFUL) |
|
1265 | 1265 | { |
|
1266 | 1266 | if ( (sy_lfr_pas_filter_offset < 0) || (sy_lfr_pas_filter_offset > 7) ) |
|
1267 | 1267 | { |
|
1268 | 1268 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_OFFSET+10, sy_lfr_pas_filter_offset ); |
|
1269 | 1269 | flag = WRONG_APP_DATA; |
|
1270 | 1270 | } |
|
1271 | 1271 | } |
|
1272 | 1272 | |
|
1273 | 1273 | //************************ |
|
1274 | 1274 | // sy_lfr_pas_filter_shift |
|
1275 | 1275 | if ( (sy_lfr_pas_filter_shift < 0.0) || (sy_lfr_pas_filter_shift > 1.0) ) |
|
1276 | 1276 | { |
|
1277 | 1277 | parPtr = (char*) &sy_lfr_pas_filter_shift; |
|
1278 | 1278 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_PAS_FILTER_SHIFT+10, parPtr[3] ); |
|
1279 | 1279 | flag = WRONG_APP_DATA; |
|
1280 | 1280 | } |
|
1281 | 1281 | |
|
1282 | 1282 | //********************* |
|
1283 | 1283 | // sy_lfr_sc_rw_delta_f |
|
1284 | 1284 | // nothing to check, no default value in the ICD |
|
1285 | 1285 | |
|
1286 | 1286 | return flag; |
|
1287 | 1287 | } |
|
1288 | 1288 | |
|
1289 | 1289 | //************** |
|
1290 | 1290 | // KCOEFFICIENTS |
|
1291 | 1291 | int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id ) |
|
1292 | 1292 | { |
|
1293 | 1293 | unsigned int kcoeff; |
|
1294 | 1294 | unsigned short sy_lfr_kcoeff_frequency; |
|
1295 | 1295 | unsigned short bin; |
|
1296 | 1296 | unsigned short *freqPtr; |
|
1297 | 1297 | float *kcoeffPtr_norm; |
|
1298 | 1298 | float *kcoeffPtr_sbm; |
|
1299 | 1299 | int status; |
|
1300 | 1300 | unsigned char *kcoeffLoadPtr; |
|
1301 | 1301 | unsigned char *kcoeffNormPtr; |
|
1302 | 1302 | unsigned char *kcoeffSbmPtr_a; |
|
1303 | 1303 | unsigned char *kcoeffSbmPtr_b; |
|
1304 | 1304 | |
|
1305 | 1305 | status = LFR_SUCCESSFUL; |
|
1306 | 1306 | |
|
1307 | 1307 | kcoeffPtr_norm = NULL; |
|
1308 | 1308 | kcoeffPtr_sbm = NULL; |
|
1309 | 1309 | bin = 0; |
|
1310 | 1310 | |
|
1311 | 1311 | freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY]; |
|
1312 | 1312 | sy_lfr_kcoeff_frequency = *freqPtr; |
|
1313 | 1313 | |
|
1314 | 1314 | if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM ) |
|
1315 | 1315 | { |
|
1316 | 1316 | PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency) |
|
1317 | 1317 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1, |
|
1318 | 1318 | TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB |
|
1319 | 1319 | status = LFR_DEFAULT; |
|
1320 | 1320 | } |
|
1321 | 1321 | else |
|
1322 | 1322 | { |
|
1323 | 1323 | if ( ( sy_lfr_kcoeff_frequency >= 0 ) |
|
1324 | 1324 | && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) ) |
|
1325 | 1325 | { |
|
1326 | 1326 | kcoeffPtr_norm = k_coeff_intercalib_f0_norm; |
|
1327 | 1327 | kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm; |
|
1328 | 1328 | bin = sy_lfr_kcoeff_frequency; |
|
1329 | 1329 | } |
|
1330 | 1330 | else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 ) |
|
1331 | 1331 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) ) |
|
1332 | 1332 | { |
|
1333 | 1333 | kcoeffPtr_norm = k_coeff_intercalib_f1_norm; |
|
1334 | 1334 | kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm; |
|
1335 | 1335 | bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0; |
|
1336 | 1336 | } |
|
1337 | 1337 | else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) |
|
1338 | 1338 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) ) |
|
1339 | 1339 | { |
|
1340 | 1340 | kcoeffPtr_norm = k_coeff_intercalib_f2; |
|
1341 | 1341 | kcoeffPtr_sbm = NULL; |
|
1342 | 1342 | bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); |
|
1343 | 1343 | } |
|
1344 | 1344 | } |
|
1345 | 1345 | |
|
1346 | 1346 | if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products |
|
1347 | 1347 | { |
|
1348 | 1348 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
1349 | 1349 | { |
|
1350 | 1350 | // destination |
|
1351 | 1351 | kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ]; |
|
1352 | 1352 | // source |
|
1353 | 1353 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; |
|
1354 | 1354 | // copy source to destination |
|
1355 | 1355 | copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr ); |
|
1356 | 1356 | } |
|
1357 | 1357 | } |
|
1358 | 1358 | |
|
1359 | 1359 | if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products |
|
1360 | 1360 | { |
|
1361 | 1361 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
1362 | 1362 | { |
|
1363 | 1363 | // destination |
|
1364 | 1364 | kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ]; |
|
1365 | 1365 | kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ]; |
|
1366 | 1366 | // source |
|
1367 | 1367 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; |
|
1368 | 1368 | // copy source to destination |
|
1369 | 1369 | copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr ); |
|
1370 | 1370 | copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr ); |
|
1371 | 1371 | } |
|
1372 | 1372 | } |
|
1373 | 1373 | |
|
1374 | 1374 | // print_k_coeff(); |
|
1375 | 1375 | |
|
1376 | 1376 | return status; |
|
1377 | 1377 | } |
|
1378 | 1378 | |
|
1379 | 1379 | void copyFloatByChar( unsigned char *destination, unsigned char *source ) |
|
1380 | 1380 | { |
|
1381 | 1381 | destination[0] = source[0]; |
|
1382 | 1382 | destination[1] = source[1]; |
|
1383 | 1383 | destination[2] = source[2]; |
|
1384 | 1384 | destination[3] = source[3]; |
|
1385 | 1385 | } |
|
1386 | 1386 | |
|
1387 | 1387 | void floatToChar( float value, unsigned char* ptr) |
|
1388 | 1388 | { |
|
1389 | 1389 | unsigned char* valuePtr; |
|
1390 | 1390 | |
|
1391 | 1391 | valuePtr = (unsigned char*) &value; |
|
1392 | 1392 | ptr[0] = valuePtr[0]; |
|
1393 |
ptr[1] = valuePtr[ |
|
|
1394 |
ptr[2] = valuePtr[ |
|
|
1395 |
ptr[3] = valuePtr[ |
|
|
1393 | ptr[1] = valuePtr[1]; | |
|
1394 | ptr[2] = valuePtr[2]; | |
|
1395 | ptr[3] = valuePtr[3]; | |
|
1396 | 1396 | } |
|
1397 | 1397 | |
|
1398 | 1398 | //********** |
|
1399 | 1399 | // init dump |
|
1400 | 1400 | |
|
1401 | 1401 | void init_parameter_dump( void ) |
|
1402 | 1402 | { |
|
1403 | 1403 | /** This function initialize the parameter_dump_packet global variable with default values. |
|
1404 | 1404 | * |
|
1405 | 1405 | */ |
|
1406 | 1406 | |
|
1407 | 1407 | unsigned int k; |
|
1408 | 1408 | |
|
1409 | 1409 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
1410 | 1410 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
1411 | 1411 | parameter_dump_packet.reserved = CCSDS_RESERVED; |
|
1412 | 1412 | parameter_dump_packet.userApplication = CCSDS_USER_APP; |
|
1413 | 1413 | parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8); |
|
1414 | 1414 | parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; |
|
1415 | 1415 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
1416 | 1416 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
1417 | 1417 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8); |
|
1418 | 1418 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; |
|
1419 | 1419 | // DATA FIELD HEADER |
|
1420 | 1420 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
1421 | 1421 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; |
|
1422 | 1422 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; |
|
1423 | 1423 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
1424 | 1424 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
1425 | 1425 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
1426 | 1426 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
1427 | 1427 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
1428 | 1428 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
1429 | 1429 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
1430 | 1430 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; |
|
1431 | 1431 | |
|
1432 | 1432 | //****************** |
|
1433 | 1433 | // COMMON PARAMETERS |
|
1434 | 1434 | parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0; |
|
1435 | 1435 | parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1; |
|
1436 | 1436 | |
|
1437 | 1437 | //****************** |
|
1438 | 1438 | // NORMAL PARAMETERS |
|
1439 | 1439 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8); |
|
1440 | 1440 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L ); |
|
1441 | 1441 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8); |
|
1442 | 1442 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P ); |
|
1443 | 1443 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8); |
|
1444 | 1444 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P ); |
|
1445 | 1445 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0; |
|
1446 | 1446 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1; |
|
1447 | 1447 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3; |
|
1448 | 1448 | |
|
1449 | 1449 | //***************** |
|
1450 | 1450 | // BURST PARAMETERS |
|
1451 | 1451 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; |
|
1452 | 1452 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; |
|
1453 | 1453 | |
|
1454 | 1454 | //**************** |
|
1455 | 1455 | // SBM1 PARAMETERS |
|
1456 | 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 |
|
1457 | 1457 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; |
|
1458 | 1458 | |
|
1459 | 1459 | //**************** |
|
1460 | 1460 | // SBM2 PARAMETERS |
|
1461 | 1461 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; |
|
1462 | 1462 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; |
|
1463 | 1463 | |
|
1464 | 1464 | //************ |
|
1465 | 1465 | // FBINS MASKS |
|
1466 | 1466 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) |
|
1467 | 1467 | { |
|
1468 | 1468 | parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff; |
|
1469 | 1469 | } |
|
1470 | 1470 | |
|
1471 | 1471 | // PAS FILTER PARAMETERS |
|
1472 | 1472 | parameter_dump_packet.pa_rpw_spare8_2 = 0x00; |
|
1473 | 1473 | parameter_dump_packet.spare_sy_lfr_pas_filter_enabled = 0x00; |
|
1474 | 1474 | parameter_dump_packet.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS; |
|
1475 | 1475 | floatToChar( DEFAULT_SY_LFR_PAS_FILTER_TBAD, parameter_dump_packet.sy_lfr_pas_filter_tbad ); |
|
1476 | 1476 | parameter_dump_packet.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET; |
|
1477 | 1477 | floatToChar( DEFAULT_SY_LFR_PAS_FILTER_SHIFT, parameter_dump_packet.sy_lfr_pas_filter_shift ); |
|
1478 | 1478 | floatToChar( DEFAULT_SY_LFR_SC_RW_DELTA_F, parameter_dump_packet.sy_lfr_sc_rw_delta_f ); |
|
1479 | 1479 | |
|
1480 | 1480 | // LFR_RW_MASK |
|
1481 | 1481 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) |
|
1482 | 1482 | { |
|
1483 | 1483 | parameter_dump_packet.sy_lfr_rw_mask_f0_word1[k] = 0xff; |
|
1484 | 1484 | } |
|
1485 | 1485 | } |
|
1486 | 1486 | |
|
1487 | 1487 | void init_kcoefficients_dump( void ) |
|
1488 | 1488 | { |
|
1489 | 1489 | init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 ); |
|
1490 | 1490 | init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 ); |
|
1491 | 1491 | |
|
1492 | 1492 | kcoefficient_node_1.previous = NULL; |
|
1493 | 1493 | kcoefficient_node_1.next = NULL; |
|
1494 | 1494 | kcoefficient_node_1.sid = TM_CODE_K_DUMP; |
|
1495 | 1495 | kcoefficient_node_1.coarseTime = 0x00; |
|
1496 | 1496 | kcoefficient_node_1.fineTime = 0x00; |
|
1497 | 1497 | kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1; |
|
1498 | 1498 | kcoefficient_node_1.status = 0x00; |
|
1499 | 1499 | |
|
1500 | 1500 | kcoefficient_node_2.previous = NULL; |
|
1501 | 1501 | kcoefficient_node_2.next = NULL; |
|
1502 | 1502 | kcoefficient_node_2.sid = TM_CODE_K_DUMP; |
|
1503 | 1503 | kcoefficient_node_2.coarseTime = 0x00; |
|
1504 | 1504 | kcoefficient_node_2.fineTime = 0x00; |
|
1505 | 1505 | kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2; |
|
1506 | 1506 | kcoefficient_node_2.status = 0x00; |
|
1507 | 1507 | } |
|
1508 | 1508 | |
|
1509 | 1509 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ) |
|
1510 | 1510 | { |
|
1511 | 1511 | unsigned int k; |
|
1512 | 1512 | unsigned int packetLength; |
|
1513 | 1513 | |
|
1514 | 1514 | packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header |
|
1515 | 1515 | |
|
1516 | 1516 | kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
1517 | 1517 | kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
1518 | 1518 | kcoefficients_dump->reserved = CCSDS_RESERVED; |
|
1519 | 1519 | kcoefficients_dump->userApplication = CCSDS_USER_APP; |
|
1520 | 1520 | kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);; |
|
1521 | 1521 | kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;; |
|
1522 | 1522 | kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
1523 | 1523 | kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
1524 | 1524 | kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8); |
|
1525 | 1525 | kcoefficients_dump->packetLength[1] = (unsigned char) packetLength; |
|
1526 | 1526 | // DATA FIELD HEADER |
|
1527 | 1527 | kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
1528 | 1528 | kcoefficients_dump->serviceType = TM_TYPE_K_DUMP; |
|
1529 | 1529 | kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP; |
|
1530 | 1530 | kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND; |
|
1531 | 1531 | kcoefficients_dump->time[0] = 0x00; |
|
1532 | 1532 | kcoefficients_dump->time[1] = 0x00; |
|
1533 | 1533 | kcoefficients_dump->time[2] = 0x00; |
|
1534 | 1534 | kcoefficients_dump->time[3] = 0x00; |
|
1535 | 1535 | kcoefficients_dump->time[4] = 0x00; |
|
1536 | 1536 | kcoefficients_dump->time[5] = 0x00; |
|
1537 | 1537 | kcoefficients_dump->sid = SID_K_DUMP; |
|
1538 | 1538 | |
|
1539 | 1539 | kcoefficients_dump->pkt_cnt = 2; |
|
1540 | 1540 | kcoefficients_dump->pkt_nr = pkt_nr; |
|
1541 | 1541 | kcoefficients_dump->blk_nr = blk_nr; |
|
1542 | 1542 | |
|
1543 | 1543 | //****************** |
|
1544 | 1544 | // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR] |
|
1545 | 1545 | // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900) |
|
1546 | 1546 | for (k=0; k<3900; k++) |
|
1547 | 1547 | { |
|
1548 | 1548 | kcoefficients_dump->kcoeff_blks[k] = 0x00; |
|
1549 | 1549 | } |
|
1550 | 1550 | } |
|
1551 | 1551 | |
|
1552 | 1552 | void increment_seq_counter_destination_id_dump( unsigned char *packet_sequence_control, unsigned char destination_id ) |
|
1553 | 1553 | { |
|
1554 | 1554 | /** This function increment the packet sequence control parameter of a TC, depending on its destination ID. |
|
1555 | 1555 | * |
|
1556 | 1556 | * @param packet_sequence_control points to the packet sequence control which will be incremented |
|
1557 | 1557 | * @param destination_id is the destination ID of the TM, there is one counter by destination ID |
|
1558 | 1558 | * |
|
1559 | 1559 | * If the destination ID is not known, a dedicated counter is incremented. |
|
1560 | 1560 | * |
|
1561 | 1561 | */ |
|
1562 | 1562 | |
|
1563 | 1563 | unsigned short sequence_cnt; |
|
1564 | 1564 | unsigned short segmentation_grouping_flag; |
|
1565 | 1565 | unsigned short new_packet_sequence_control; |
|
1566 | 1566 | unsigned char i; |
|
1567 | 1567 | |
|
1568 | 1568 | switch (destination_id) |
|
1569 | 1569 | { |
|
1570 | 1570 | case SID_TC_GROUND: |
|
1571 | 1571 | i = GROUND; |
|
1572 | 1572 | break; |
|
1573 | 1573 | case SID_TC_MISSION_TIMELINE: |
|
1574 | 1574 | i = MISSION_TIMELINE; |
|
1575 | 1575 | break; |
|
1576 | 1576 | case SID_TC_TC_SEQUENCES: |
|
1577 | 1577 | i = TC_SEQUENCES; |
|
1578 | 1578 | break; |
|
1579 | 1579 | case SID_TC_RECOVERY_ACTION_CMD: |
|
1580 | 1580 | i = RECOVERY_ACTION_CMD; |
|
1581 | 1581 | break; |
|
1582 | 1582 | case SID_TC_BACKUP_MISSION_TIMELINE: |
|
1583 | 1583 | i = BACKUP_MISSION_TIMELINE; |
|
1584 | 1584 | break; |
|
1585 | 1585 | case SID_TC_DIRECT_CMD: |
|
1586 | 1586 | i = DIRECT_CMD; |
|
1587 | 1587 | break; |
|
1588 | 1588 | case SID_TC_SPARE_GRD_SRC1: |
|
1589 | 1589 | i = SPARE_GRD_SRC1; |
|
1590 | 1590 | break; |
|
1591 | 1591 | case SID_TC_SPARE_GRD_SRC2: |
|
1592 | 1592 | i = SPARE_GRD_SRC2; |
|
1593 | 1593 | break; |
|
1594 | 1594 | case SID_TC_OBCP: |
|
1595 | 1595 | i = OBCP; |
|
1596 | 1596 | break; |
|
1597 | 1597 | case SID_TC_SYSTEM_CONTROL: |
|
1598 | 1598 | i = SYSTEM_CONTROL; |
|
1599 | 1599 | break; |
|
1600 | 1600 | case SID_TC_AOCS: |
|
1601 | 1601 | i = AOCS; |
|
1602 | 1602 | break; |
|
1603 | 1603 | case SID_TC_RPW_INTERNAL: |
|
1604 | 1604 | i = RPW_INTERNAL; |
|
1605 | 1605 | break; |
|
1606 | 1606 | default: |
|
1607 | 1607 | i = GROUND; |
|
1608 | 1608 | break; |
|
1609 | 1609 | } |
|
1610 | 1610 | |
|
1611 | 1611 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
1612 | 1612 | sequence_cnt = sequenceCounters_TM_DUMP[ i ] & 0x3fff; |
|
1613 | 1613 | |
|
1614 | 1614 | new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ; |
|
1615 | 1615 | |
|
1616 | 1616 | packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8); |
|
1617 | 1617 | packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control ); |
|
1618 | 1618 | |
|
1619 | 1619 | // increment the sequence counter |
|
1620 | 1620 | if ( sequenceCounters_TM_DUMP[ i ] < SEQ_CNT_MAX ) |
|
1621 | 1621 | { |
|
1622 | 1622 | sequenceCounters_TM_DUMP[ i ] = sequenceCounters_TM_DUMP[ i ] + 1; |
|
1623 | 1623 | } |
|
1624 | 1624 | else |
|
1625 | 1625 | { |
|
1626 | 1626 | sequenceCounters_TM_DUMP[ i ] = 0; |
|
1627 | 1627 | } |
|
1628 | 1628 | } |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now