##// END OF EJS Templates
Bug 104
paul -
r144:9cb6e909f6ec VHDLib206
parent child
Show More
@@ -1,273 +1,273
1 1 #############################################################################
2 2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Tue Jun 10 20:58:59 2014
3 # Generated by qmake (2.01a) (Qt 4.8.6) on: Thu Jun 12 08:10:29 2014
4 4 # Project: fsw-qt.pro
5 5 # Template: app
6 6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
7 7 #############################################################################
8 8
9 9 ####### Compiler, tools and options
10 10
11 11 CC = sparc-rtems-gcc
12 12 CXX = sparc-rtems-g++
13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=8 -DPRINT_MESSAGES_ON_CONSOLE
13 DEFINES = -DSW_VERSION_N1=1 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=9 -DPRINT_MESSAGES_ON_CONSOLE
14 14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header -I../header/processing -I../src/LFR_basic-parameters
17 17 LINK = sparc-rtems-g++
18 18 LFLAGS =
19 19 LIBS = $(SUBLIBS)
20 20 AR = sparc-rtems-ar rcs
21 21 RANLIB =
22 22 QMAKE = /usr/bin/qmake-qt4
23 23 TAR = tar -cf
24 24 COMPRESS = gzip -9f
25 25 COPY = cp -f
26 26 SED = sed
27 27 COPY_FILE = $(COPY)
28 28 COPY_DIR = $(COPY) -r
29 29 STRIP = sparc-rtems-strip
30 30 INSTALL_FILE = install -m 644 -p
31 31 INSTALL_DIR = $(COPY_DIR)
32 32 INSTALL_PROGRAM = install -m 755 -p
33 33 DEL_FILE = rm -f
34 34 SYMLINK = ln -f -s
35 35 DEL_DIR = rmdir
36 36 MOVE = mv -f
37 37 CHK_DIR_EXISTS= test -d
38 38 MKDIR = mkdir -p
39 39
40 40 ####### Output directory
41 41
42 42 OBJECTS_DIR = obj/
43 43
44 44 ####### Files
45 45
46 46 SOURCES = ../src/wf_handler.c \
47 47 ../src/tc_handler.c \
48 48 ../src/fsw_misc.c \
49 49 ../src/fsw_init.c \
50 50 ../src/fsw_globals.c \
51 51 ../src/fsw_spacewire.c \
52 52 ../src/tc_load_dump_parameters.c \
53 53 ../src/tm_lfr_tc_exe.c \
54 54 ../src/tc_acceptance.c \
55 55 ../src/processing/fsw_processing.c \
56 56 ../src/processing/avf0_prc0.c \
57 57 ../src/processing/avf1_prc1.c \
58 58 ../src/processing/avf2_prc2.c \
59 59 ../src/lfr_cpu_usage_report.c \
60 60 ../src/LFR_basic-parameters/basic_parameters.c
61 61 OBJECTS = obj/wf_handler.o \
62 62 obj/tc_handler.o \
63 63 obj/fsw_misc.o \
64 64 obj/fsw_init.o \
65 65 obj/fsw_globals.o \
66 66 obj/fsw_spacewire.o \
67 67 obj/tc_load_dump_parameters.o \
68 68 obj/tm_lfr_tc_exe.o \
69 69 obj/tc_acceptance.o \
70 70 obj/fsw_processing.o \
71 71 obj/avf0_prc0.o \
72 72 obj/avf1_prc1.o \
73 73 obj/avf2_prc2.o \
74 74 obj/lfr_cpu_usage_report.o \
75 75 obj/basic_parameters.o
76 76 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
77 77 /usr/lib64/qt4/mkspecs/common/linux.conf \
78 78 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
79 79 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
80 80 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
81 81 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
82 82 /usr/lib64/qt4/mkspecs/qconfig.pri \
83 83 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
84 84 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
85 85 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
86 86 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
87 87 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
88 88 sparc.pri \
89 89 /usr/lib64/qt4/mkspecs/features/release.prf \
90 90 /usr/lib64/qt4/mkspecs/features/default_post.prf \
91 91 /usr/lib64/qt4/mkspecs/features/shared.prf \
92 92 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
93 93 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
94 94 /usr/lib64/qt4/mkspecs/features/resources.prf \
95 95 /usr/lib64/qt4/mkspecs/features/uic.prf \
96 96 /usr/lib64/qt4/mkspecs/features/yacc.prf \
97 97 /usr/lib64/qt4/mkspecs/features/lex.prf \
98 98 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
99 99 fsw-qt.pro
100 100 QMAKE_TARGET = fsw
101 101 DESTDIR = bin/
102 102 TARGET = bin/fsw
103 103
104 104 first: all
105 105 ####### Implicit rules
106 106
107 107 .SUFFIXES: .o .c .cpp .cc .cxx .C
108 108
109 109 .cpp.o:
110 110 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
111 111
112 112 .cc.o:
113 113 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
114 114
115 115 .cxx.o:
116 116 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
117 117
118 118 .C.o:
119 119 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
120 120
121 121 .c.o:
122 122 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
123 123
124 124 ####### Build rules
125 125
126 126 all: Makefile $(TARGET)
127 127
128 128 $(TARGET): $(OBJECTS)
129 129 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
130 130 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
131 131
132 132 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
133 133 /usr/lib64/qt4/mkspecs/common/linux.conf \
134 134 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
135 135 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
136 136 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
137 137 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
138 138 /usr/lib64/qt4/mkspecs/qconfig.pri \
139 139 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
140 140 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
141 141 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
142 142 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
143 143 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
144 144 sparc.pri \
145 145 /usr/lib64/qt4/mkspecs/features/release.prf \
146 146 /usr/lib64/qt4/mkspecs/features/default_post.prf \
147 147 /usr/lib64/qt4/mkspecs/features/shared.prf \
148 148 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
149 149 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
150 150 /usr/lib64/qt4/mkspecs/features/resources.prf \
151 151 /usr/lib64/qt4/mkspecs/features/uic.prf \
152 152 /usr/lib64/qt4/mkspecs/features/yacc.prf \
153 153 /usr/lib64/qt4/mkspecs/features/lex.prf \
154 154 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
155 155 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
156 156 /usr/lib64/qt4/mkspecs/common/unix.conf:
157 157 /usr/lib64/qt4/mkspecs/common/linux.conf:
158 158 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
159 159 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
160 160 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
161 161 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
162 162 /usr/lib64/qt4/mkspecs/qconfig.pri:
163 163 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
164 164 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
165 165 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
166 166 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
167 167 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
168 168 sparc.pri:
169 169 /usr/lib64/qt4/mkspecs/features/release.prf:
170 170 /usr/lib64/qt4/mkspecs/features/default_post.prf:
171 171 /usr/lib64/qt4/mkspecs/features/shared.prf:
172 172 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
173 173 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
174 174 /usr/lib64/qt4/mkspecs/features/resources.prf:
175 175 /usr/lib64/qt4/mkspecs/features/uic.prf:
176 176 /usr/lib64/qt4/mkspecs/features/yacc.prf:
177 177 /usr/lib64/qt4/mkspecs/features/lex.prf:
178 178 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
179 179 qmake: FORCE
180 180 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
181 181
182 182 dist:
183 183 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
184 184 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw1.0.0/ && (cd `dirname obj/fsw1.0.0` && $(TAR) fsw1.0.0.tar fsw1.0.0 && $(COMPRESS) fsw1.0.0.tar) && $(MOVE) `dirname obj/fsw1.0.0`/fsw1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw1.0.0
185 185
186 186
187 187 clean:compiler_clean
188 188 -$(DEL_FILE) $(OBJECTS)
189 189 -$(DEL_FILE) *~ core *.core
190 190
191 191
192 192 ####### Sub-libraries
193 193
194 194 distclean: clean
195 195 -$(DEL_FILE) $(TARGET)
196 196 -$(DEL_FILE) Makefile
197 197
198 198
199 199 grmon:
200 200 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
201 201
202 202 check: first
203 203
204 204 compiler_rcc_make_all:
205 205 compiler_rcc_clean:
206 206 compiler_uic_make_all:
207 207 compiler_uic_clean:
208 208 compiler_image_collection_make_all: qmake_image_collection.cpp
209 209 compiler_image_collection_clean:
210 210 -$(DEL_FILE) qmake_image_collection.cpp
211 211 compiler_yacc_decl_make_all:
212 212 compiler_yacc_decl_clean:
213 213 compiler_yacc_impl_make_all:
214 214 compiler_yacc_impl_clean:
215 215 compiler_lex_make_all:
216 216 compiler_lex_clean:
217 217 compiler_clean:
218 218
219 219 ####### Compile
220 220
221 221 obj/wf_handler.o: ../src/wf_handler.c
222 222 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
223 223
224 224 obj/tc_handler.o: ../src/tc_handler.c
225 225 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
226 226
227 227 obj/fsw_misc.o: ../src/fsw_misc.c
228 228 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
229 229
230 230 obj/fsw_init.o: ../src/fsw_init.c ../src/fsw_config.c
231 231 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
232 232
233 233 obj/fsw_globals.o: ../src/fsw_globals.c
234 234 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
235 235
236 236 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
237 237 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
238 238
239 239 obj/tc_load_dump_parameters.o: ../src/tc_load_dump_parameters.c
240 240 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_load_dump_parameters.o ../src/tc_load_dump_parameters.c
241 241
242 242 obj/tm_lfr_tc_exe.o: ../src/tm_lfr_tc_exe.c
243 243 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tm_lfr_tc_exe.o ../src/tm_lfr_tc_exe.c
244 244
245 245 obj/tc_acceptance.o: ../src/tc_acceptance.c
246 246 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_acceptance.o ../src/tc_acceptance.c
247 247
248 248 obj/fsw_processing.o: ../src/processing/fsw_processing.c
249 249 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/processing/fsw_processing.c
250 250
251 251 obj/avf0_prc0.o: ../src/processing/avf0_prc0.c
252 252 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf0_prc0.o ../src/processing/avf0_prc0.c
253 253
254 254 obj/avf1_prc1.o: ../src/processing/avf1_prc1.c
255 255 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf1_prc1.o ../src/processing/avf1_prc1.c
256 256
257 257 obj/avf2_prc2.o: ../src/processing/avf2_prc2.c
258 258 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/avf2_prc2.o ../src/processing/avf2_prc2.c
259 259
260 260 obj/lfr_cpu_usage_report.o: ../src/lfr_cpu_usage_report.c
261 261 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/lfr_cpu_usage_report.o ../src/lfr_cpu_usage_report.c
262 262
263 263 obj/basic_parameters.o: ../src/LFR_basic-parameters/basic_parameters.c
264 264 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/basic_parameters.o ../src/LFR_basic-parameters/basic_parameters.c
265 265
266 266 ####### Install
267 267
268 268 install: FORCE
269 269
270 270 uninstall: FORCE
271 271
272 272 FORCE:
273 273
@@ -1,250 +1,251
1 1 #ifndef FSW_PARAMS_H_INCLUDED
2 2 #define FSW_PARAMS_H_INCLUDED
3 3
4 4 #include "grlib_regs.h"
5 5 #include "fsw_params_processing.h"
6 6 #include "fsw_params_nb_bytes.h"
7 7 #include "tm_byte_positions.h"
8 8 #include "ccsds_types.h"
9 9
10 10 #define GRSPW_DEVICE_NAME "/dev/grspw0"
11 11 #define UART_DEVICE_NAME "/dev/console"
12 12
13 13 typedef struct ring_node
14 14 {
15 15 struct ring_node *previous;
16 16 int buffer_address;
17 17 struct ring_node *next;
18 18 unsigned int status;
19 19 } ring_node;
20 20
21 21 //************************
22 22 // flight software version
23 23 // this parameters is handled by the Qt project options
24 24
25 25 #define NB_PACKETS_PER_GROUP_OF_CWF 8 // 8 packets containing 336 blk
26 26 #define NB_PACKETS_PER_GROUP_OF_CWF_LIGHT 4 // 4 packets containing 672 blk
27 27 #define NB_SAMPLES_PER_SNAPSHOT 2688 // 336 * 8 = 672 * 4 = 2688
28 28 #define TIME_OFFSET 2
29 29 #define TIME_OFFSET_IN_BYTES 8
30 30 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
31 31 #define NB_BYTES_SWF_BLK (2 * 6)
32 32 #define NB_WORDS_SWF_BLK 3
33 33 #define NB_BYTES_CWF3_LIGHT_BLK 6
34 34 #define WFRM_INDEX_OF_LAST_PACKET 6 // waveforms are transmitted in groups of 2048 blocks, 6 packets of 340 and 1 of 8
35 35 #define NB_RING_NODES_F0 3 // AT LEAST 3
36 36 #define NB_RING_NODES_F1 5 // AT LEAST 3
37 37 #define NB_RING_NODES_F2 5 // AT LEAST 3
38 38 #define NB_RING_NODES_F3 3 // AT LEAST 3
39 39
40 40 //**********
41 41 // LFR MODES
42 42 #define LFR_MODE_STANDBY 0
43 43 #define LFR_MODE_NORMAL 1
44 44 #define LFR_MODE_BURST 2
45 45 #define LFR_MODE_SBM1 3
46 46 #define LFR_MODE_SBM2 4
47 47
48 48 #define TDS_MODE_LFM 5
49 49 #define TDS_MODE_STANDBY 0
50 50 #define TDS_MODE_NORMAL 1
51 51 #define TDS_MODE_BURST 2
52 52 #define TDS_MODE_SBM1 3
53 53 #define TDS_MODE_SBM2 4
54 54
55 55 #define THR_MODE_STANDBY 0
56 56 #define THR_MODE_NORMAL 1
57 57 #define THR_MODE_BURST 2
58 58
59 59 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
60 60 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
61 61 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
62 62 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
63 63 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
64 64 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
65 65 #define RTEMS_EVENT_NORM_BP1_F0 RTEMS_EVENT_6
66 66 #define RTEMS_EVENT_NORM_BP2_F0 RTEMS_EVENT_7
67 67 #define RTEMS_EVENT_NORM_ASM_F0 RTEMS_EVENT_8 // ASM only in NORM mode
68 68 #define RTEMS_EVENT_NORM_BP1_F1 RTEMS_EVENT_9
69 69 #define RTEMS_EVENT_NORM_BP2_F1 RTEMS_EVENT_10
70 70 #define RTEMS_EVENT_NORM_ASM_F1 RTEMS_EVENT_11 // ASM only in NORM mode
71 71 #define RTEMS_EVENT_NORM_BP1_F2 RTEMS_EVENT_12
72 72 #define RTEMS_EVENT_NORM_BP2_F2 RTEMS_EVENT_13
73 73 #define RTEMS_EVENT_NORM_ASM_F2 RTEMS_EVENT_14 // ASM only in NORM mode
74 74 #define RTEMS_EVENT_BURST_SBM_BP1_F0 RTEMS_EVENT_15
75 75 #define RTEMS_EVENT_BURST_SBM_BP2_F0 RTEMS_EVENT_16
76 76 #define RTEMS_EVENT_BURST_SBM_BP1_F1 RTEMS_EVENT_17
77 77 #define RTEMS_EVENT_BURST_SBM_BP2_F1 RTEMS_EVENT_18
78 78
79 79 //****************************
80 80 // LFR DEFAULT MODE PARAMETERS
81 81 // COMMON
82 82 #define DEFAULT_SY_LFR_COMMON0 0x00
83 83 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
84 84 // NORM
85 85 #define SY_LFR_N_SWF_L 2048 // nb sample
86 86 #define SY_LFR_N_SWF_P 300 // sec
87 87 #define SY_LFR_N_ASM_P 3600 // sec
88 88 #define SY_LFR_N_BP_P0 4 // sec
89 89 #define SY_LFR_N_BP_P1 20 // sec
90 90 #define SY_LFR_N_CWF_LONG_F3 0 // 0 => production of light continuous waveforms at f3
91 91 #define MIN_DELTA_SNAPSHOT 16 // sec
92 92 // BURST
93 93 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
94 94 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
95 95 // SBM1
96 96 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
97 97 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
98 98 // SBM2
99 99 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
100 100 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
101 101 // ADDITIONAL PARAMETERS
102 102 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
103 103 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
104 104 // STATUS WORD
105 105 #define DEFAULT_STATUS_WORD_BYTE0 0x0d // [0000] [1] [101] mode 4 bits / SPW enabled 1 bit / state is run 3 bits
106 106 #define DEFAULT_STATUS_WORD_BYTE1 0x00
107 107 //
108 108 #define SY_LFR_DPU_CONNECT_TIMEOUT 100 // 100 * 10 ms = 1 s
109 109 #define SY_LFR_DPU_CONNECT_ATTEMPT 3
110 110 //****************************
111 111
112 112 //*****************************
113 113 // APB REGISTERS BASE ADDRESSES
114 114 #define REGS_ADDR_APBUART 0x80000100
115 115 #define REGS_ADDR_GPTIMER 0x80000300
116 116 #define REGS_ADDR_GRSPW 0x80000500
117 117 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
118 118 #define REGS_ADDR_GRGPIO 0x80000b00
119 119
120 120 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
121 121 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f50
122 #define REGS_ADDR_VHDL_VERSION 0x80000ff0
122 123
123 124 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
124 125 #define APBUART_CTRL_REG_MASK_TE 0x00000002
125 126 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50)
126 127
127 128 //**********
128 129 // IRQ LINES
129 130 #define IRQ_SM_SIMULATOR 9
130 131 #define IRQ_SPARC_SM_SIMULATOR 0x19 // see sparcv8.pdf p.76 for interrupt levels
131 132 #define IRQ_WAVEFORM_PICKER 14
132 133 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
133 134 #define IRQ_SPECTRAL_MATRIX 6
134 135 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
135 136
136 137 //*****
137 138 // TIME
138 139 #define CLKDIV_SM_SIMULATOR (10416 - 1) // 10 ms => nominal is 1/96 = 0.010416667, 10417 - 1 = 10416
139 140 #define TIMER_SM_SIMULATOR 1
140 141 #define HK_PERIOD 100 // 100 * 10ms => 1s
141 142 #define SY_LFR_TIME_SYN_TIMEOUT_in_ms 2000
142 143 #define SY_LFR_TIME_SYN_TIMEOUT_in_ticks 200 // 200 * 10 ms = 2 s
143 144
144 145 //**********
145 146 // LPP CODES
146 147 #define LFR_SUCCESSFUL 0
147 148 #define LFR_DEFAULT 1
148 149 #define LFR_EXE_ERROR 2
149 150
150 151 //******
151 152 // RTEMS
152 153 #define TASKID_RECV 1
153 154 #define TASKID_ACTN 2
154 155 #define TASKID_SPIQ 3
155 156 #define TASKID_STAT 4
156 157 #define TASKID_AVF0 5
157 158 #define TASKID_SWBD 6
158 159 #define TASKID_WFRM 7
159 160 #define TASKID_DUMB 8
160 161 #define TASKID_HOUS 9
161 162 #define TASKID_PRC0 10
162 163 #define TASKID_CWF3 11
163 164 #define TASKID_CWF2 12
164 165 #define TASKID_CWF1 13
165 166 #define TASKID_SEND 14
166 167 #define TASKID_WTDG 15
167 168 #define TASKID_AVF1 16
168 169 #define TASKID_PRC1 17
169 170 #define TASKID_AVF2 18
170 171 #define TASKID_PRC2 19
171 172
172 173 #define TASK_PRIORITY_SPIQ 5
173 174 #define TASK_PRIORITY_WTDG 20
174 175 #define TASK_PRIORITY_HOUS 30
175 176 #define TASK_PRIORITY_CWF1 35 // CWF1 and CWF2 are never running together
176 177 #define TASK_PRIORITY_CWF2 35 //
177 178 #define TASK_PRIORITY_SWBD 37 // SWBD has a lower priority than WFRM, this is to extract the snapshot before sending it
178 179 #define TASK_PRIORITY_WFRM 40
179 180 #define TASK_PRIORITY_CWF3 40 // there is a printf in this function, be careful with its priority wrt CWF1
180 181 #define TASK_PRIORITY_SEND 45
181 182 #define TASK_PRIORITY_RECV 50
182 183 #define TASK_PRIORITY_ACTN 50
183 184 #define TASK_PRIORITY_AVF0 60
184 185 #define TASK_PRIORITY_AVF1 70
185 186 #define TASK_PRIORITY_PRC0 100
186 187 #define TASK_PRIORITY_PRC1 100
187 188 #define TASK_PRIORITY_AVF2 110
188 189 #define TASK_PRIORITY_PRC2 110
189 190 #define TASK_PRIORITY_STAT 200
190 191 #define TASK_PRIORITY_DUMB 200
191 192
192 193 #define MSG_QUEUE_COUNT_RECV 10
193 194 #define MSG_QUEUE_COUNT_SEND 50
194 195 #define MSG_QUEUE_COUNT_PRC0 10
195 196 #define MSG_QUEUE_COUNT_PRC1 10
196 197 #define MSG_QUEUE_COUNT_PRC2 5
197 198 #define MSG_QUEUE_SIZE_SEND 810 // 806 + 4 => TM_LFR_SCIENCE_BURST_BP2_F1
198 199 #define ACTION_MSG_SPW_IOCTL_SEND_SIZE 24 // hlen *hdr dlen *data sent options
199 200 #define MSG_QUEUE_SIZE_PRC0 20 // two pointers and one rtems_event + 2 integers
200 201 #define MSG_QUEUE_SIZE_PRC1 20 // two pointers and one rtems_event + 2 integers
201 202 #define MSG_QUEUE_SIZE_PRC2 20 // two pointers and one rtems_event + 2 integers
202 203
203 204 #define QUEUE_RECV 0
204 205 #define QUEUE_SEND 1
205 206 #define QUEUE_PRC0 2
206 207 #define QUEUE_PRC1 3
207 208 #define QUEUE_PRC2 4
208 209
209 210 //*******
210 211 // MACROS
211 212 #ifdef PRINT_MESSAGES_ON_CONSOLE
212 213 #define PRINTF(x) printf(x);
213 214 #define PRINTF1(x,y) printf(x,y);
214 215 #define PRINTF2(x,y,z) printf(x,y,z);
215 216 #else
216 217 #define PRINTF(x) ;
217 218 #define PRINTF1(x,y) ;
218 219 #define PRINTF2(x,y,z) ;
219 220 #endif
220 221
221 222 #ifdef BOOT_MESSAGES
222 223 #define BOOT_PRINTF(x) printf(x);
223 224 #define BOOT_PRINTF1(x,y) printf(x,y);
224 225 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
225 226 #else
226 227 #define BOOT_PRINTF(x) ;
227 228 #define BOOT_PRINTF1(x,y) ;
228 229 #define BOOT_PRINTF2(x,y,z) ;
229 230 #endif
230 231
231 232 #ifdef DEBUG_MESSAGES
232 233 #define DEBUG_PRINTF(x) printf(x);
233 234 #define DEBUG_PRINTF1(x,y) printf(x,y);
234 235 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
235 236 #else
236 237 #define DEBUG_PRINTF(x) ;
237 238 #define DEBUG_PRINTF1(x,y) ;
238 239 #define DEBUG_PRINTF2(x,y,z) ;
239 240 #endif
240 241
241 242 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
242 243
243 244 struct param_local_str{
244 245 unsigned int local_sbm1_nb_cwf_sent;
245 246 unsigned int local_sbm1_nb_cwf_max;
246 247 unsigned int local_sbm2_nb_cwf_sent;
247 248 unsigned int local_sbm2_nb_cwf_max;
248 249 };
249 250
250 251 #endif // FSW_PARAMS_H_INCLUDED
@@ -1,772 +1,780
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 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
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 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
51 51 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
52 52 #endif
53 53 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
54 54 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
55 55 #endif
56 56 #endif
57 57 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
58 58 #include <drvmgr/drvmgr_confdefs.h>
59 59 #endif
60 60
61 61 #include "fsw_init.h"
62 62 #include "fsw_config.c"
63 63
64 64 rtems_task Init( rtems_task_argument ignored )
65 65 {
66 66 /** This is the RTEMS INIT taks, it the first task launched by the system.
67 67 *
68 68 * @param unused is the starting argument of the RTEMS task
69 69 *
70 70 * The INIT task create and run all other RTEMS tasks.
71 71 *
72 72 */
73 73
74 unsigned char *vhdlVersion;
75
74 76 reset_local_time();
75 77
76 78 rtems_cpu_usage_reset();
77 79
78 80 rtems_status_code status;
79 81 rtems_status_code status_spw;
80 82 rtems_isr_entry old_isr_handler;
81 83
82 84 // UART settings
83 85 send_console_outputs_on_apbuart_port();
84 86 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
85 87 enable_apbuart_transmitter();
86 88 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
87 89
88 90 PRINTF("\n\n\n\n\n")
89 91 PRINTF("*************************\n")
90 92 PRINTF("** LFR Flight Software **\n")
91 93 PRINTF1("** %d.", SW_VERSION_N1)
92 94 PRINTF1("%d." , SW_VERSION_N2)
93 95 PRINTF1("%d." , SW_VERSION_N3)
94 96 PRINTF1("%d **\n", SW_VERSION_N4)
97
98 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
99 PRINTF("** VHDL **\n")
100 PRINTF1("** %d.", vhdlVersion[1])
101 PRINTF1("%d." , vhdlVersion[2])
102 PRINTF1("%d **\n", vhdlVersion[3])
95 103 PRINTF("*************************\n")
96 104 PRINTF("\n\n")
97 105
98 106 init_parameter_dump();
99 107 init_local_mode_parameters();
100 108 init_housekeeping_parameters();
101 109
102 110 // waveform picker initialization
103 111 WFP_init_rings(); // initialize the waveform rings
104 112 WFP_reset_current_ring_nodes();
105 113 reset_waveform_picker_regs();
106 114
107 115 // spectral matrices initialization
108 116 SM_init_rings(); // initialize spectral matrices rings
109 117 SM_reset_current_ring_nodes();
110 118 reset_spectral_matrix_regs();
111 119
112 120 updateLFRCurrentMode();
113 121
114 122 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
115 123
116 124 create_names(); // create all names
117 125
118 126 status = create_message_queues(); // create message queues
119 127 if (status != RTEMS_SUCCESSFUL)
120 128 {
121 129 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
122 130 }
123 131
124 132 status = create_all_tasks(); // create all tasks
125 133 if (status != RTEMS_SUCCESSFUL)
126 134 {
127 135 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
128 136 }
129 137
130 138 // **************************
131 139 // <SPACEWIRE INITIALIZATION>
132 140 grspw_timecode_callback = &timecode_irq_handler;
133 141
134 142 status_spw = spacewire_open_link(); // (1) open the link
135 143 if ( status_spw != RTEMS_SUCCESSFUL )
136 144 {
137 145 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
138 146 }
139 147
140 148 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
141 149 {
142 150 status_spw = spacewire_configure_link( fdSPW );
143 151 if ( status_spw != RTEMS_SUCCESSFUL )
144 152 {
145 153 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
146 154 }
147 155 }
148 156
149 157 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
150 158 {
151 159 status_spw = spacewire_start_link( fdSPW );
152 160 if ( status_spw != RTEMS_SUCCESSFUL )
153 161 {
154 162 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
155 163 }
156 164 }
157 165 // </SPACEWIRE INITIALIZATION>
158 166 // ***************************
159 167
160 168 status = start_all_tasks(); // start all tasks
161 169 if (status != RTEMS_SUCCESSFUL)
162 170 {
163 171 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
164 172 }
165 173
166 174 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
167 175 status = start_recv_send_tasks();
168 176 if ( status != RTEMS_SUCCESSFUL )
169 177 {
170 178 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
171 179 }
172 180
173 181 // suspend science tasks, they will be restarted later depending on the mode
174 182 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
175 183 if (status != RTEMS_SUCCESSFUL)
176 184 {
177 185 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
178 186 }
179 187
180 188 //******************************
181 189 // <SPECTRAL MATRICES SIMULATOR>
182 190 LEON_Mask_interrupt( IRQ_SM_SIMULATOR );
183 191 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
184 192 IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu );
185 193 // </SPECTRAL MATRICES SIMULATOR>
186 194 //*******************************
187 195
188 196 // configure IRQ handling for the waveform picker unit
189 197 status = rtems_interrupt_catch( waveforms_isr,
190 198 IRQ_SPARC_WAVEFORM_PICKER,
191 199 &old_isr_handler) ;
192 200 // configure IRQ handling for the spectral matrices unit
193 201 status = rtems_interrupt_catch( spectral_matrices_isr,
194 202 IRQ_SPARC_SPECTRAL_MATRIX,
195 203 &old_isr_handler) ;
196 204
197 205 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
198 206 if ( status_spw != RTEMS_SUCCESSFUL )
199 207 {
200 208 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
201 209 if ( status != RTEMS_SUCCESSFUL ) {
202 210 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
203 211 }
204 212 }
205 213
206 214 BOOT_PRINTF("delete INIT\n")
207 215
208 216 send_dumb_hk();
209 217
210 218 status = rtems_task_delete(RTEMS_SELF);
211 219
212 220 }
213 221
214 222 void init_local_mode_parameters( void )
215 223 {
216 224 /** This function initialize the param_local global variable with default values.
217 225 *
218 226 */
219 227
220 228 unsigned int i;
221 229
222 230 // LOCAL PARAMETERS
223 231
224 232 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
225 233 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
226 234 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
227 235
228 236 // init sequence counters
229 237
230 238 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
231 239 {
232 240 sequenceCounters_TC_EXE[i] = 0x00;
233 241 }
234 242 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
235 243 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
236 244 }
237 245
238 246 void reset_local_time( void )
239 247 {
240 248 time_management_regs->ctrl = 0x02; // software reset, coarse time = 0x80000000
241 249 }
242 250
243 251 void create_names( void ) // create all names for tasks and queues
244 252 {
245 253 /** This function creates all RTEMS names used in the software for tasks and queues.
246 254 *
247 255 * @return RTEMS directive status codes:
248 256 * - RTEMS_SUCCESSFUL - successful completion
249 257 *
250 258 */
251 259
252 260 // task names
253 261 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
254 262 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
255 263 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
256 264 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
257 265 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
258 266 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
259 267 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
260 268 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
261 269 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
262 270 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
263 271 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
264 272 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
265 273 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
266 274 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
267 275 Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' );
268 276 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
269 277 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
270 278 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
271 279 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
272 280
273 281 // rate monotonic period names
274 282 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
275 283
276 284 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
277 285 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
278 286 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
279 287 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
280 288 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
281 289 }
282 290
283 291 int create_all_tasks( void ) // create all tasks which run in the software
284 292 {
285 293 /** This function creates all RTEMS tasks used in the software.
286 294 *
287 295 * @return RTEMS directive status codes:
288 296 * - RTEMS_SUCCESSFUL - task created successfully
289 297 * - RTEMS_INVALID_ADDRESS - id is NULL
290 298 * - RTEMS_INVALID_NAME - invalid task name
291 299 * - RTEMS_INVALID_PRIORITY - invalid task priority
292 300 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
293 301 * - RTEMS_TOO_MANY - too many tasks created
294 302 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
295 303 * - RTEMS_TOO_MANY - too many global objects
296 304 *
297 305 */
298 306
299 307 rtems_status_code status;
300 308
301 309 //**********
302 310 // SPACEWIRE
303 311 // RECV
304 312 status = rtems_task_create(
305 313 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
306 314 RTEMS_DEFAULT_MODES,
307 315 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
308 316 );
309 317 if (status == RTEMS_SUCCESSFUL) // SEND
310 318 {
311 319 status = rtems_task_create(
312 320 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
313 321 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
314 322 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
315 323 );
316 324 }
317 325 if (status == RTEMS_SUCCESSFUL) // WTDG
318 326 {
319 327 status = rtems_task_create(
320 328 Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE,
321 329 RTEMS_DEFAULT_MODES,
322 330 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG]
323 331 );
324 332 }
325 333 if (status == RTEMS_SUCCESSFUL) // ACTN
326 334 {
327 335 status = rtems_task_create(
328 336 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
329 337 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
330 338 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
331 339 );
332 340 }
333 341 if (status == RTEMS_SUCCESSFUL) // SPIQ
334 342 {
335 343 status = rtems_task_create(
336 344 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
337 345 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
338 346 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
339 347 );
340 348 }
341 349
342 350 //******************
343 351 // SPECTRAL MATRICES
344 352 if (status == RTEMS_SUCCESSFUL) // AVF0
345 353 {
346 354 status = rtems_task_create(
347 355 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
348 356 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
349 357 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
350 358 );
351 359 }
352 360 if (status == RTEMS_SUCCESSFUL) // PRC0
353 361 {
354 362 status = rtems_task_create(
355 363 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
356 364 RTEMS_DEFAULT_MODES,
357 365 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
358 366 );
359 367 }
360 368 if (status == RTEMS_SUCCESSFUL) // AVF1
361 369 {
362 370 status = rtems_task_create(
363 371 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
364 372 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
365 373 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
366 374 );
367 375 }
368 376 if (status == RTEMS_SUCCESSFUL) // PRC1
369 377 {
370 378 status = rtems_task_create(
371 379 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
372 380 RTEMS_DEFAULT_MODES,
373 381 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
374 382 );
375 383 }
376 384 if (status == RTEMS_SUCCESSFUL) // AVF2
377 385 {
378 386 status = rtems_task_create(
379 387 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
380 388 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
381 389 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
382 390 );
383 391 }
384 392 if (status == RTEMS_SUCCESSFUL) // PRC2
385 393 {
386 394 status = rtems_task_create(
387 395 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
388 396 RTEMS_DEFAULT_MODES,
389 397 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
390 398 );
391 399 }
392 400
393 401 //****************
394 402 // WAVEFORM PICKER
395 403 if (status == RTEMS_SUCCESSFUL) // WFRM
396 404 {
397 405 status = rtems_task_create(
398 406 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
399 407 RTEMS_DEFAULT_MODES,
400 408 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
401 409 );
402 410 }
403 411 if (status == RTEMS_SUCCESSFUL) // CWF3
404 412 {
405 413 status = rtems_task_create(
406 414 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
407 415 RTEMS_DEFAULT_MODES,
408 416 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
409 417 );
410 418 }
411 419 if (status == RTEMS_SUCCESSFUL) // CWF2
412 420 {
413 421 status = rtems_task_create(
414 422 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
415 423 RTEMS_DEFAULT_MODES,
416 424 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
417 425 );
418 426 }
419 427 if (status == RTEMS_SUCCESSFUL) // CWF1
420 428 {
421 429 status = rtems_task_create(
422 430 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
423 431 RTEMS_DEFAULT_MODES,
424 432 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
425 433 );
426 434 }
427 435 if (status == RTEMS_SUCCESSFUL) // SWBD
428 436 {
429 437 status = rtems_task_create(
430 438 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
431 439 RTEMS_DEFAULT_MODES,
432 440 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
433 441 );
434 442 }
435 443
436 444 //*****
437 445 // MISC
438 446 if (status == RTEMS_SUCCESSFUL) // STAT
439 447 {
440 448 status = rtems_task_create(
441 449 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
442 450 RTEMS_DEFAULT_MODES,
443 451 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
444 452 );
445 453 }
446 454 if (status == RTEMS_SUCCESSFUL) // DUMB
447 455 {
448 456 status = rtems_task_create(
449 457 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
450 458 RTEMS_DEFAULT_MODES,
451 459 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
452 460 );
453 461 }
454 462 if (status == RTEMS_SUCCESSFUL) // HOUS
455 463 {
456 464 status = rtems_task_create(
457 465 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
458 466 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
459 467 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
460 468 );
461 469 }
462 470
463 471 return status;
464 472 }
465 473
466 474 int start_recv_send_tasks( void )
467 475 {
468 476 rtems_status_code status;
469 477
470 478 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
471 479 if (status!=RTEMS_SUCCESSFUL) {
472 480 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
473 481 }
474 482
475 483 if (status == RTEMS_SUCCESSFUL) // SEND
476 484 {
477 485 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
478 486 if (status!=RTEMS_SUCCESSFUL) {
479 487 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
480 488 }
481 489 }
482 490
483 491 return status;
484 492 }
485 493
486 494 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
487 495 {
488 496 /** This function starts all RTEMS tasks used in the software.
489 497 *
490 498 * @return RTEMS directive status codes:
491 499 * - RTEMS_SUCCESSFUL - ask started successfully
492 500 * - RTEMS_INVALID_ADDRESS - invalid task entry point
493 501 * - RTEMS_INVALID_ID - invalid task id
494 502 * - RTEMS_INCORRECT_STATE - task not in the dormant state
495 503 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
496 504 *
497 505 */
498 506 // starts all the tasks fot eh flight software
499 507
500 508 rtems_status_code status;
501 509
502 510 //**********
503 511 // SPACEWIRE
504 512 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
505 513 if (status!=RTEMS_SUCCESSFUL) {
506 514 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
507 515 }
508 516
509 517 if (status == RTEMS_SUCCESSFUL) // WTDG
510 518 {
511 519 status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 );
512 520 if (status!=RTEMS_SUCCESSFUL) {
513 521 BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n")
514 522 }
515 523 }
516 524
517 525 if (status == RTEMS_SUCCESSFUL) // ACTN
518 526 {
519 527 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
520 528 if (status!=RTEMS_SUCCESSFUL) {
521 529 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
522 530 }
523 531 }
524 532
525 533 //******************
526 534 // SPECTRAL MATRICES
527 535 if (status == RTEMS_SUCCESSFUL) // AVF0
528 536 {
529 537 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
530 538 if (status!=RTEMS_SUCCESSFUL) {
531 539 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
532 540 }
533 541 }
534 542 if (status == RTEMS_SUCCESSFUL) // PRC0
535 543 {
536 544 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
537 545 if (status!=RTEMS_SUCCESSFUL) {
538 546 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
539 547 }
540 548 }
541 549 if (status == RTEMS_SUCCESSFUL) // AVF1
542 550 {
543 551 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
544 552 if (status!=RTEMS_SUCCESSFUL) {
545 553 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
546 554 }
547 555 }
548 556 if (status == RTEMS_SUCCESSFUL) // PRC1
549 557 {
550 558 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
551 559 if (status!=RTEMS_SUCCESSFUL) {
552 560 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
553 561 }
554 562 }
555 563 if (status == RTEMS_SUCCESSFUL) // AVF2
556 564 {
557 565 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
558 566 if (status!=RTEMS_SUCCESSFUL) {
559 567 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
560 568 }
561 569 }
562 570 if (status == RTEMS_SUCCESSFUL) // PRC2
563 571 {
564 572 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
565 573 if (status!=RTEMS_SUCCESSFUL) {
566 574 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
567 575 }
568 576 }
569 577
570 578 //****************
571 579 // WAVEFORM PICKER
572 580 if (status == RTEMS_SUCCESSFUL) // WFRM
573 581 {
574 582 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
575 583 if (status!=RTEMS_SUCCESSFUL) {
576 584 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
577 585 }
578 586 }
579 587 if (status == RTEMS_SUCCESSFUL) // CWF3
580 588 {
581 589 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
582 590 if (status!=RTEMS_SUCCESSFUL) {
583 591 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
584 592 }
585 593 }
586 594 if (status == RTEMS_SUCCESSFUL) // CWF2
587 595 {
588 596 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
589 597 if (status!=RTEMS_SUCCESSFUL) {
590 598 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
591 599 }
592 600 }
593 601 if (status == RTEMS_SUCCESSFUL) // CWF1
594 602 {
595 603 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
596 604 if (status!=RTEMS_SUCCESSFUL) {
597 605 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
598 606 }
599 607 }
600 608 if (status == RTEMS_SUCCESSFUL) // SWBD
601 609 {
602 610 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
603 611 if (status!=RTEMS_SUCCESSFUL) {
604 612 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
605 613 }
606 614 }
607 615
608 616 //*****
609 617 // MISC
610 618 if (status == RTEMS_SUCCESSFUL) // HOUS
611 619 {
612 620 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
613 621 if (status!=RTEMS_SUCCESSFUL) {
614 622 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
615 623 }
616 624 }
617 625 if (status == RTEMS_SUCCESSFUL) // DUMB
618 626 {
619 627 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
620 628 if (status!=RTEMS_SUCCESSFUL) {
621 629 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
622 630 }
623 631 }
624 632 if (status == RTEMS_SUCCESSFUL) // STAT
625 633 {
626 634 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
627 635 if (status!=RTEMS_SUCCESSFUL) {
628 636 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
629 637 }
630 638 }
631 639
632 640 return status;
633 641 }
634 642
635 643 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
636 644 {
637 645 rtems_status_code status_recv;
638 646 rtems_status_code status_send;
639 647 rtems_status_code status_q_p0;
640 648 rtems_status_code status_q_p1;
641 649 rtems_status_code status_q_p2;
642 650 rtems_status_code ret;
643 651 rtems_id queue_id;
644 652
645 653 //****************************************
646 654 // create the queue for handling valid TCs
647 655 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
648 656 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
649 657 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
650 658 if ( status_recv != RTEMS_SUCCESSFUL ) {
651 659 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
652 660 }
653 661
654 662 //************************************************
655 663 // create the queue for handling TM packet sending
656 664 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
657 665 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
658 666 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
659 667 if ( status_send != RTEMS_SUCCESSFUL ) {
660 668 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
661 669 }
662 670
663 671 //*****************************************************************************
664 672 // create the queue for handling averaged spectral matrices for processing @ f0
665 673 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
666 674 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
667 675 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
668 676 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
669 677 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
670 678 }
671 679
672 680 //*****************************************************************************
673 681 // create the queue for handling averaged spectral matrices for processing @ f1
674 682 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
675 683 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
676 684 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
677 685 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
678 686 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
679 687 }
680 688
681 689 //*****************************************************************************
682 690 // create the queue for handling averaged spectral matrices for processing @ f2
683 691 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
684 692 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
685 693 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
686 694 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
687 695 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
688 696 }
689 697
690 698 if ( status_recv != RTEMS_SUCCESSFUL )
691 699 {
692 700 ret = status_recv;
693 701 }
694 702 else if( status_send != RTEMS_SUCCESSFUL )
695 703 {
696 704 ret = status_send;
697 705 }
698 706 else if( status_q_p0 != RTEMS_SUCCESSFUL )
699 707 {
700 708 ret = status_q_p0;
701 709 }
702 710 else if( status_q_p1 != RTEMS_SUCCESSFUL )
703 711 {
704 712 ret = status_q_p1;
705 713 }
706 714 else
707 715 {
708 716 ret = status_q_p2;
709 717 }
710 718
711 719 return ret;
712 720 }
713 721
714 722 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
715 723 {
716 724 rtems_status_code status;
717 725 rtems_name queue_name;
718 726
719 727 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
720 728
721 729 status = rtems_message_queue_ident( queue_name, 0, queue_id );
722 730
723 731 return status;
724 732 }
725 733
726 734 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
727 735 {
728 736 rtems_status_code status;
729 737 rtems_name queue_name;
730 738
731 739 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
732 740
733 741 status = rtems_message_queue_ident( queue_name, 0, queue_id );
734 742
735 743 return status;
736 744 }
737 745
738 746 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
739 747 {
740 748 rtems_status_code status;
741 749 rtems_name queue_name;
742 750
743 751 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
744 752
745 753 status = rtems_message_queue_ident( queue_name, 0, queue_id );
746 754
747 755 return status;
748 756 }
749 757
750 758 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
751 759 {
752 760 rtems_status_code status;
753 761 rtems_name queue_name;
754 762
755 763 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
756 764
757 765 status = rtems_message_queue_ident( queue_name, 0, queue_id );
758 766
759 767 return status;
760 768 }
761 769
762 770 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
763 771 {
764 772 rtems_status_code status;
765 773 rtems_name queue_name;
766 774
767 775 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
768 776
769 777 status = rtems_message_queue_ident( queue_name, 0, queue_id );
770 778
771 779 return status;
772 780 }
@@ -1,586 +1,586
1 1 /** General usage functions and RTEMS tasks.
2 2 *
3 3 * @file
4 4 * @author P. LEROY
5 5 *
6 6 */
7 7
8 8 #include "fsw_misc.h"
9 9
10 10 void configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
11 11 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
12 12 {
13 13 /** This function configures a GPTIMER timer instantiated in the VHDL design.
14 14 *
15 15 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
16 16 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
17 17 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
18 18 * @param interrupt_level is the interrupt level that the timer drives.
19 19 * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer.
20 20 *
21 21 * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76
22 22 *
23 23 */
24 24
25 25 rtems_status_code status;
26 26 rtems_isr_entry old_isr_handler;
27 27
28 28 gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register
29 29
30 30 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
31 31 if (status!=RTEMS_SUCCESSFUL)
32 32 {
33 33 PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n")
34 34 }
35 35
36 36 timer_set_clock_divider( gptimer_regs, timer, clock_divider);
37 37 }
38 38
39 39 void timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer)
40 40 {
41 41 /** This function starts a GPTIMER timer.
42 42 *
43 43 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
44 44 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
45 45 *
46 46 */
47 47
48 48 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
49 49 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
50 50 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
51 51 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
52 52 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
53 53 }
54 54
55 55 void timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer)
56 56 {
57 57 /** This function stops a GPTIMER timer.
58 58 *
59 59 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
60 60 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
61 61 *
62 62 */
63 63
64 64 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer
65 65 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable
66 66 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
67 67 }
68 68
69 69 void timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider)
70 70 {
71 71 /** This function sets the clock divider of a GPTIMER timer.
72 72 *
73 73 * @param gptimer_regs points to the APB registers of the GPTIMER IP core.
74 74 * @param timer is the number of the timer in the IP core (several timers can be instantiated).
75 75 * @param clock_divider is the divider of the 1 MHz clock that will be configured.
76 76 *
77 77 */
78 78
79 79 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
80 80 }
81 81
82 82 int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port
83 83 {
84 84 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
85 85
86 86 apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE;
87 87
88 88 return 0;
89 89 }
90 90
91 91 int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register
92 92 {
93 93 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
94 94
95 95 apbuart_regs->ctrl = apbuart_regs->ctrl | APBUART_CTRL_REG_MASK_TE;
96 96
97 97 return 0;
98 98 }
99 99
100 100 void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
101 101 {
102 102 /** This function sets the scaler reload register of the apbuart module
103 103 *
104 104 * @param regs is the address of the apbuart registers in memory
105 105 * @param value is the value that will be stored in the scaler register
106 106 *
107 107 * The value shall be set by the software to get data on the serial interface.
108 108 *
109 109 */
110 110
111 111 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
112 112
113 113 apbuart_regs->scaler = value;
114 114 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
115 115 }
116 116
117 117 //************
118 118 // RTEMS TASKS
119 119
120 120 rtems_task stat_task(rtems_task_argument argument)
121 121 {
122 122 int i;
123 123 int j;
124 124 i = 0;
125 125 j = 0;
126 126 BOOT_PRINTF("in STAT *** \n")
127 127 while(1){
128 128 rtems_task_wake_after(1000);
129 129 PRINTF1("%d\n", j)
130 130 if (i == CPU_USAGE_REPORT_PERIOD) {
131 131 // #ifdef PRINT_TASK_STATISTICS
132 132 // rtems_cpu_usage_report();
133 133 // rtems_cpu_usage_reset();
134 134 // #endif
135 135 i = 0;
136 136 }
137 137 else i++;
138 138 j++;
139 139 }
140 140 }
141 141
142 142 rtems_task hous_task(rtems_task_argument argument)
143 143 {
144 144 rtems_status_code status;
145 145 rtems_id queue_id;
146 146 rtems_rate_monotonic_period_status period_status;
147 147
148 148 status = get_message_queue_id_send( &queue_id );
149 149 if (status != RTEMS_SUCCESSFUL)
150 150 {
151 151 PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status)
152 152 }
153 153
154 154 BOOT_PRINTF("in HOUS ***\n")
155 155
156 156 if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) {
157 157 status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id );
158 158 if( status != RTEMS_SUCCESSFUL ) {
159 159 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
160 160 }
161 161 }
162 162
163 163 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
164 164 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
165 165 housekeeping_packet.reserved = DEFAULT_RESERVED;
166 166 housekeeping_packet.userApplication = CCSDS_USER_APP;
167 167 housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
168 168 housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK);
169 169 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
170 170 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
171 171 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
172 172 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
173 173 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
174 174 housekeeping_packet.serviceType = TM_TYPE_HK;
175 175 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
176 176 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
177 177 housekeeping_packet.sid = SID_HK;
178 178
179 179 status = rtems_rate_monotonic_cancel(HK_id);
180 180 if( status != RTEMS_SUCCESSFUL ) {
181 181 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
182 182 }
183 183 else {
184 184 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
185 185 }
186 186
187 187 // startup phase
188 188 status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks );
189 189 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
190 190 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
191 191 while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway
192 192 {
193 193 if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization
194 194 {
195 195 break; // break if LFR is synchronized
196 196 }
197 197 else
198 198 {
199 199 status = rtems_rate_monotonic_get_status( HK_id, &period_status );
200 200 // sched_yield();
201 201 status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms
202 202 }
203 203 }
204 204 status = rtems_rate_monotonic_cancel(HK_id);
205 205 DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state)
206 206
207 207 while(1){ // launch the rate monotonic task
208 208 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
209 209 if ( status != RTEMS_SUCCESSFUL ) {
210 210 PRINTF1( "in HOUS *** ERR period: %d\n", status);
211 211 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 );
212 212 }
213 213 else {
214 214 increment_seq_counter( housekeeping_packet.packetSequenceControl );
215 215 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
216 216 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
217 217 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
218 218 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
219 219 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
220 220 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
221 221
222 222 spacewire_update_statistics();
223 223
224 224 get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 );
225 225 get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load );
226 226
227 227 // SEND PACKET
228 228 status = rtems_message_queue_urgent( queue_id, &housekeeping_packet,
229 229 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
230 230 if (status != RTEMS_SUCCESSFUL) {
231 231 PRINTF1("in HOUS *** ERR send: %d\n", status)
232 232 }
233 233 }
234 234 }
235 235
236 236 PRINTF("in HOUS *** deleting task\n")
237 237
238 238 status = rtems_task_delete( RTEMS_SELF ); // should not return
239 239 printf( "rtems_task_delete returned with status of %d.\n", status );
240 240 return;
241 241 }
242 242
243 243 rtems_task dumb_task( rtems_task_argument unused )
244 244 {
245 245 /** This RTEMS taks is used to print messages without affecting the general behaviour of the software.
246 246 *
247 247 * @param unused is the starting argument of the RTEMS task
248 248 *
249 249 * The DUMB taks waits for RTEMS events and print messages depending on the incoming events.
250 250 *
251 251 */
252 252
253 253 unsigned int i;
254 254 unsigned int intEventOut;
255 255 unsigned int coarse_time = 0;
256 256 unsigned int fine_time = 0;
257 257 rtems_event_set event_out;
258 258
259 259 char *DumbMessages[10] = {"in DUMB *** default", // RTEMS_EVENT_0
260 260 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
261 261 "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2
262 262 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
263 263 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
264 264 "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5
265 265 "ERR HK", // RTEMS_EVENT_6
266 266 "ready for dump", // RTEMS_EVENT_7
267 267 "in DUMB *** spectral_matrices_isr", // RTEMS_EVENT_8
268 268 "tick" // RTEMS_EVENT_9
269 269 };
270 270
271 271 BOOT_PRINTF("in DUMB *** \n")
272 272
273 273 while(1){
274 274 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3
275 275 | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7
276 276 | RTEMS_EVENT_8 | RTEMS_EVENT_9,
277 277 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
278 278 intEventOut = (unsigned int) event_out;
279 279 for ( i=0; i<32; i++)
280 280 {
281 281 if ( ((intEventOut >> i) & 0x0001) != 0)
282 282 {
283 283 coarse_time = time_management_regs->coarse_time;
284 284 fine_time = time_management_regs->fine_time;
285 285 printf("in DUMB *** coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
286 286 if (i==8)
287 287 {
288 288 PRINTF1("status = %x\n", spectral_matrix_regs->status)
289 289 }
290 290 }
291 291 }
292 292 }
293 293 }
294 294
295 295 //*****************************
296 296 // init housekeeping parameters
297 297
298 298 void init_housekeeping_parameters( void )
299 299 {
300 300 /** This function initialize the housekeeping_packet global variable with default values.
301 301 *
302 302 */
303 303
304 304 unsigned int i = 0;
305 305 unsigned char *parameters;
306 306
307 307 parameters = (unsigned char*) &housekeeping_packet.lfr_status_word;
308 308 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
309 309 {
310 310 parameters[i] = 0x00;
311 311 }
312 312 // init status word
313 313 housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0;
314 314 housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1;
315 315 // init software version
316 316 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
317 317 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
318 318 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
319 319 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
320 320 // init fpga version
321 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
321 parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
322 322 housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1
323 323 housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2
324 324 housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3
325 325 }
326 326
327 327 void increment_seq_counter( unsigned char *packet_sequence_control)
328 328 {
329 329 /** This function increment the sequence counter psased in argument.
330 330 *
331 331 * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0.
332 332 *
333 333 */
334 334
335 335 unsigned short sequence_cnt;
336 336 unsigned short segmentation_grouping_flag;
337 337 unsigned short new_packet_sequence_control;
338 338
339 339 segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6
340 340 sequence_cnt = (unsigned short) (
341 341 ( (packet_sequence_control[0] & 0x3f) << 8 ) // keep bits 5 downto 0
342 342 + packet_sequence_control[1]
343 343 );
344 344
345 345 new_packet_sequence_control = segmentation_grouping_flag | sequence_cnt ;
346 346
347 347 packet_sequence_control[0] = (unsigned char) (new_packet_sequence_control >> 8);
348 348 packet_sequence_control[1] = (unsigned char) (new_packet_sequence_control );
349 349
350 350 if ( sequence_cnt < SEQ_CNT_MAX)
351 351 {
352 352 sequence_cnt = sequence_cnt + 1;
353 353 }
354 354 else
355 355 {
356 356 sequence_cnt = 0;
357 357 }
358 358 }
359 359
360 360 void getTime( unsigned char *time)
361 361 {
362 362 /** This function write the current local time in the time buffer passed in argument.
363 363 *
364 364 */
365 365
366 366 time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
367 367 time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
368 368 time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
369 369 time[3] = (unsigned char) (time_management_regs->coarse_time);
370 370 time[4] = (unsigned char) (time_management_regs->fine_time>>8);
371 371 time[5] = (unsigned char) (time_management_regs->fine_time);
372 372 }
373 373
374 374 unsigned long long int getTimeAsUnsignedLongLongInt( )
375 375 {
376 376 /** This function write the current local time in the time buffer passed in argument.
377 377 *
378 378 */
379 379 unsigned long long int time;
380 380
381 381 time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 )
382 382 + time_management_regs->fine_time;
383 383
384 384 return time;
385 385 }
386 386
387 387 void send_dumb_hk( void )
388 388 {
389 389 Packet_TM_LFR_HK_t dummy_hk_packet;
390 390 unsigned char *parameters;
391 391 unsigned int i;
392 392 rtems_id queue_id;
393 393
394 394 dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
395 395 dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
396 396 dummy_hk_packet.reserved = DEFAULT_RESERVED;
397 397 dummy_hk_packet.userApplication = CCSDS_USER_APP;
398 398 dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8);
399 399 dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK);
400 400 dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
401 401 dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
402 402 dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
403 403 dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
404 404 dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
405 405 dummy_hk_packet.serviceType = TM_TYPE_HK;
406 406 dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK;
407 407 dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND;
408 408 dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
409 409 dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
410 410 dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
411 411 dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
412 412 dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
413 413 dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
414 414 dummy_hk_packet.sid = SID_HK;
415 415
416 416 // init status word
417 417 dummy_hk_packet.lfr_status_word[0] = 0xff;
418 418 dummy_hk_packet.lfr_status_word[1] = 0xff;
419 419 // init software version
420 420 dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1;
421 421 dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2;
422 422 dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3;
423 423 dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4;
424 424 // init fpga version
425 425 parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0);
426 426 dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1
427 427 dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2
428 428 dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3
429 429
430 430 parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load;
431 431
432 432 for (i=0; i<100; i++)
433 433 {
434 434 parameters[i] = 0xff;
435 435 }
436 436
437 437 get_message_queue_id_send( &queue_id );
438 438
439 439 rtems_message_queue_urgent( queue_id, &dummy_hk_packet,
440 440 PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES);
441 441 }
442 442
443 443 void get_v_e1_e2_f3_old( unsigned char *spacecraft_potential )
444 444 {
445 445 unsigned int coarseTime;
446 446 unsigned int acquisitionTime;
447 447 unsigned int deltaT = 0;
448 448 unsigned char *bufferPtr;
449 449
450 450 unsigned int offset_in_samples;
451 451 unsigned int offset_in_bytes;
452 452 unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
453 453
454 454 if (lfrCurrentMode == LFR_MODE_STANDBY)
455 455 {
456 456 spacecraft_potential[0] = 0x00;
457 457 spacecraft_potential[1] = 0x00;
458 458 spacecraft_potential[2] = 0x00;
459 459 spacecraft_potential[3] = 0x00;
460 460 spacecraft_potential[4] = 0x00;
461 461 spacecraft_potential[5] = 0x00;
462 462 }
463 463 else
464 464 {
465 465 coarseTime = time_management_regs->coarse_time & 0x7fffffff;
466 466 bufferPtr = (unsigned char*) current_ring_node_f3->buffer_address;
467 467 acquisitionTime = (unsigned int) ( ( bufferPtr[2] & 0x7f ) << 24 )
468 468 + (unsigned int) ( bufferPtr[3] << 16 )
469 469 + (unsigned int) ( bufferPtr[0] << 8 )
470 470 + (unsigned int) ( bufferPtr[1] );
471 471 if ( coarseTime > acquisitionTime )
472 472 {
473 473 deltaT = coarseTime - acquisitionTime;
474 474 offset_in_samples = (deltaT-1) * f3 ;
475 475 }
476 476 else if( coarseTime == acquisitionTime )
477 477 {
478 478 bufferPtr = (unsigned char*) current_ring_node_f3->previous->buffer_address; // pick up v e1 and e2 in the previous f3 buffer
479 479 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT-1;
480 480 }
481 481 else
482 482 {
483 483 offset_in_samples = 0;
484 484 PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime)
485 485 }
486 486
487 487 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
488 488 {
489 489 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
490 490 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
491 491 }
492 492 offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4;
493 493 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
494 494 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
495 495 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
496 496 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
497 497 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
498 498 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
499 499 }
500 500 }
501 501
502 502 void get_v_e1_e2_f3( unsigned char *spacecraft_potential )
503 503 {
504 504 unsigned int coarseTime;
505 505 unsigned int acquisitionTime;
506 506 unsigned int deltaT = 0;
507 507 unsigned char *bufferPtr;
508 508
509 509 unsigned int offset_in_samples;
510 510 unsigned int offset_in_bytes;
511 511 unsigned char f3 = 16; // v, e1 and e2 will be picked up each second, f3 = 16 Hz
512 512
513 513 if (lfrCurrentMode == LFR_MODE_STANDBY)
514 514 {
515 515 spacecraft_potential[0] = 0x00;
516 516 spacecraft_potential[1] = 0x00;
517 517 spacecraft_potential[2] = 0x00;
518 518 spacecraft_potential[3] = 0x00;
519 519 spacecraft_potential[4] = 0x00;
520 520 spacecraft_potential[5] = 0x00;
521 521 }
522 522 else
523 523 {
524 524 coarseTime = time_management_regs->coarse_time & 0x7fffffff;
525 525 bufferPtr = (unsigned char*) current_ring_node_f3->buffer_address;
526 526 acquisitionTime = (unsigned int) ( ( bufferPtr[0] & 0x7f ) << 24 )
527 527 + (unsigned int) ( bufferPtr[1] << 16 )
528 528 + (unsigned int) ( bufferPtr[2] << 8 )
529 529 + (unsigned int) ( bufferPtr[3] );
530 530 if ( coarseTime > acquisitionTime )
531 531 {
532 532 deltaT = coarseTime - acquisitionTime;
533 533 offset_in_samples = (deltaT-1) * f3 ;
534 534 }
535 535 else if( coarseTime == acquisitionTime )
536 536 {
537 537 bufferPtr = (unsigned char*) current_ring_node_f3->previous->buffer_address; // pick up v e1 and e2 in the previous f3 buffer
538 538 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT-1;
539 539 }
540 540 else
541 541 {
542 542 offset_in_samples = 0;
543 543 PRINTF2("ERR *** in get_v_e1_e2_f3 *** coarseTime = %x, acquisitionTime = %x\n", coarseTime, acquisitionTime)
544 544 }
545 545
546 546 if ( offset_in_samples > (NB_SAMPLES_PER_SNAPSHOT - 1) )
547 547 {
548 548 PRINTF1("ERR *** in get_v_e1_e2_f3 *** trying to read out of the buffer, counter = %d\n", offset_in_samples)
549 549 offset_in_samples = NB_SAMPLES_PER_SNAPSHOT -1;
550 550 }
551 551 offset_in_bytes = TIME_OFFSET_IN_BYTES + offset_in_samples * NB_WORDS_SWF_BLK * 4;
552 552 spacecraft_potential[0] = bufferPtr[ offset_in_bytes + 0];
553 553 spacecraft_potential[1] = bufferPtr[ offset_in_bytes + 1];
554 554 spacecraft_potential[2] = bufferPtr[ offset_in_bytes + 2];
555 555 spacecraft_potential[3] = bufferPtr[ offset_in_bytes + 3];
556 556 spacecraft_potential[4] = bufferPtr[ offset_in_bytes + 4];
557 557 spacecraft_potential[5] = bufferPtr[ offset_in_bytes + 5];
558 558 }
559 559 }
560 560
561 561 void get_cpu_load( unsigned char *resource_statistics )
562 562 {
563 563 unsigned char cpu_load;
564 564
565 565 cpu_load = lfr_rtems_cpu_usage_report();
566 566
567 567 // HK_LFR_CPU_LOAD
568 568 resource_statistics[0] = cpu_load;
569 569
570 570 // HK_LFR_CPU_LOAD_MAX
571 571 if (cpu_load > resource_statistics[1])
572 572 {
573 573 resource_statistics[1] = cpu_load;
574 574 }
575 575
576 576 // CPU_LOAD_AVE
577 577 resource_statistics[2] = 0;
578 578
579 579 #ifndef PRINT_TASK_STATISTICS
580 580 rtems_cpu_usage_reset();
581 581 #endif
582 582
583 583 }
584 584
585 585
586 586
General Comments 0
You need to be logged in to leave comments. Login now