##// END OF EJS Templates
Last commit before release 0-13...
paul -
r35:ca106d3b5c2f default
parent child
Show More
@@ -0,0 +1,32
1 #ifndef FSW_SPACEWIRE_H_INCLUDED
2 #define FSW_SPACEWIRE_H_INCLUDED
3
4 #include <rtems.h>
5
6 #include <grspw.h>
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <fcntl.h>
11
12 #include "fsw_params.h"
13 #include "ccsds_types.h"
14 #include "fsw_misc.h"
15
16 extern spw_stats spacewire_stats;
17 extern spw_stats spacewire_stats_backup;
18
19 // RTEMS TASK
20 rtems_task spiq_task(rtems_task_argument argument);
21
22 int spacewire_configure_link( void );
23 int spacewire_wait_for_link(void);
24 void spacewire_set_NP(unsigned char val, unsigned int regAddr); // No Port force
25 void spacewire_set_RE(unsigned char val, unsigned int regAddr); // RMAP Enable
26 void spacewire_compute_stats_offsets();
27
28 void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc);
29
30 void (*grspw_timecode_callback) (void *pDev, void *regs, int minor, unsigned int tc);
31
32 #endif // FSW_SPACEWIRE_H_INCLUDED
@@ -0,0 +1,200
1 #include "fsw_spacewire.h"
2
3 char *lstates[6] = {"Error-reset",
4 "Error-wait",
5 "Ready",
6 "Started",
7 "Connecting",
8 "Run"
9 };
10
11 // RTEMS TASK
12 rtems_task spiq_task(rtems_task_argument unused)
13 {
14 rtems_event_set event_out;
15 rtems_status_code status;
16 unsigned char lfrMode;
17
18 while(true){
19 BOOT_PRINTF("in SPIQ *** Waiting for SPW_LINKERR_EVENT\n")
20 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
21
22 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; // get the current mode
23
24 status = spacewire_wait_for_link();
25
26 if (status != RTEMS_SUCCESSFUL)
27 {
28 //****************
29 // STOP THE SYSTEM
30 spacewire_compute_stats_offsets();
31 stop_current_mode();
32 if (rtems_task_suspend(Task_id[TASKID_RECV])!=RTEMS_SUCCESSFUL) { // suspend RECV task
33 PRINTF("in SPIQ *** Error suspending RECV Task\n")
34 }
35 if (rtems_task_suspend(Task_id[TASKID_HOUS])!=RTEMS_SUCCESSFUL) { // suspend HOUS task
36 PRINTF("in SPIQ *** Error suspending HOUS Task\n")
37 }
38
39 //***************************
40 // RESTART THE SPACEWIRE LINK
41 spacewire_configure_link();
42
43 //*******************
44 // RESTART THE SYSTEM
45 //ioctl(fdSPW, SPACEWIRE_IOCTRL_CLR_STATISTICS); // clear statistics
46 status = rtems_task_restart( Task_id[TASKID_HOUS], 1 );
47 if (status != RTEMS_SUCCESSFUL) {
48 PRINTF1("in SPIQ *** Error restarting HOUS Task *** code %d\n", status)
49 }
50 status = rtems_task_restart(Task_id[TASKID_RECV], 1);
51 if ( status != RTEMS_SUCCESSFUL) {
52 PRINTF("in SPIQ *** Error restarting RECV Task\n")
53 }
54 enter_mode(lfrMode, NULL); // enter the mode that was running before the SpaceWire interruption
55 }
56 }
57 }
58
59 int spacewire_configure_link( void )
60 {
61 rtems_status_code status;
62
63 close(fdSPW); // close the device if it is already open
64 BOOT_PRINTF("OK *** in configure_spw_link *** try to open "GRSPW_DEVICE_NAME"\n")
65 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
66 if ( fdSPW<0 ) {
67 PRINTF("ERR *** in configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
68 }
69
70 while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, -1) != RTEMS_SUCCESSFUL){
71 PRINTF(".")
72 fflush( stdout );
73 close( fdSPW ); // close the device
74 fdSPW = open( GRSPW_DEVICE_NAME, O_RDWR ); // open the device. the open call reset the hardware
75 if (fdSPW<0) {
76 PRINTF("ERR *** In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
77 }
78 rtems_task_wake_after(100);
79 }
80
81 BOOT_PRINTF("OK *** In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n")
82
83 spacewire_set_NP(1, REGS_ADDR_GRSPW); // [N]o [P]ort force
84 spacewire_set_RE(1, REGS_ADDR_GRSPW); // [R]MAP [E]nable, the dedicated call seems to break the no port force configuration
85
86 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
87 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
88 //
89 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
90 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
91 //
92 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
93 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
94 //
95 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
96 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
97 //
98 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks
99 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n")
100 //
101 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 0); // transmission blocks on full
102 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
103 //
104 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); // [Time Rx : Time Tx : Link error : Tick-out IRQ]
105 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
106
107 BOOT_PRINTF("OK *** in configure_spw_link *** "GRSPW_DEVICE_NAME" configured successfully\n")
108
109 return RTEMS_SUCCESSFUL;
110 }
111
112 int spacewire_wait_for_link(void)
113 {
114 unsigned int i;
115 int linkStatus;
116 rtems_status_code status = RTEMS_UNSATISFIED;
117
118 for(i = 0; i< 10; i++){
119 PRINTF(".")
120 fflush( stdout );
121 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
122 PRINTF1("in spacewire_wait_for_link *** link status is: %s\n", lstates[linkStatus])
123 if ( linkStatus == 5) {
124 PRINTF("in spacewire_wait_for_link *** link is running\n")
125 status = RTEMS_SUCCESSFUL;
126 break;
127 }
128 rtems_task_wake_after(100);
129 }
130
131 return status;
132 }
133
134 void spacewire_set_NP(unsigned char val, unsigned int regAddr) // [N]o [P]ort force
135 {
136 unsigned int *spwptr = (unsigned int*) regAddr;
137
138 if (val == 1) {
139 *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit
140 }
141 if (val== 0) {
142 *spwptr = *spwptr & 0xffdfffff;
143 }
144 }
145
146 void spacewire_set_RE(unsigned char val, unsigned int regAddr) // [R]MAP [E]nable
147 {
148 unsigned int *spwptr = (unsigned int*) regAddr;
149
150 if (val == 1)
151 {
152 *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit
153 }
154 if (val== 0)
155 {
156 *spwptr = *spwptr & 0xfffdffff;
157 }
158 }
159
160 void spacewire_compute_stats_offsets()
161 {
162 spw_stats spacewire_stats_grspw;
163 rtems_status_code status;
164
165 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
166
167 spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received
168 + spacewire_stats.packets_received;
169 spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent
170 + spacewire_stats.packets_sent;
171 spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err
172 + spacewire_stats.parity_err;
173 spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err
174 + spacewire_stats.disconnect_err;
175 spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err
176 + spacewire_stats.escape_err;
177 spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err
178 + spacewire_stats.credit_err;
179 spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err
180 + spacewire_stats.write_sync_err;
181 spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err
182 + spacewire_stats.rx_rmap_header_crc_err;
183 spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err
184 + spacewire_stats.rx_rmap_data_crc_err;
185 spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep
186 + spacewire_stats.early_ep;
187 spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address
188 + spacewire_stats.invalid_address;
189 spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err
190 + spacewire_stats.rx_eep_err;
191 spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated
192 + spacewire_stats.rx_truncated;
193 }
194
195 void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc)
196 {
197 //if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 ) != RTEMS_SUCCESSFUL) {
198 // printf("In timecode_irq_handler *** Error sending event to DUMB\n");
199 //}
200 }
@@ -1,233 +1,233
1 #############################################################################
1 #############################################################################
2 # Makefile for building: bin/fsw
2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Fri Oct 4 15:16:59 2013
3 # Generated by qmake (2.01a) (Qt 4.8.5) on: Tue Oct 8 10:15:40 2013
4 # Project: fsw-qt.pro
4 # Project: fsw-qt.pro
5 # Template: app
5 # Template: app
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
7 #############################################################################
7 #############################################################################
8
8
9 ####### Compiler, tools and options
9 ####### Compiler, tools and options
10
10
11 CC = sparc-rtems-gcc
11 CC = sparc-rtems-gcc
12 CXX = sparc-rtems-g++
12 CXX = sparc-rtems-g++
13 DEFINES = -DSW_VERSION_N1=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=13 -DPRINT_MESSAGES_ON_CONSOLE -DPRINT_TASK_STATISTICS -DPRINT_STACK_REPORT
13 DEFINES = -DSW_VERSION_N1=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=13 -DPRINT_MESSAGES_ON_CONSOLE
14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header
16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header
17 LINK = sparc-rtems-g++
17 LINK = sparc-rtems-g++
18 LFLAGS =
18 LFLAGS =
19 LIBS = $(SUBLIBS)
19 LIBS = $(SUBLIBS)
20 AR = sparc-rtems-ar rcs
20 AR = sparc-rtems-ar rcs
21 RANLIB =
21 RANLIB =
22 QMAKE = /usr/bin/qmake-qt4
22 QMAKE = /usr/bin/qmake-qt4
23 TAR = tar -cf
23 TAR = tar -cf
24 COMPRESS = gzip -9f
24 COMPRESS = gzip -9f
25 COPY = cp -f
25 COPY = cp -f
26 SED = sed
26 SED = sed
27 COPY_FILE = $(COPY)
27 COPY_FILE = $(COPY)
28 COPY_DIR = $(COPY) -r
28 COPY_DIR = $(COPY) -r
29 STRIP = sparc-rtems-strip
29 STRIP = sparc-rtems-strip
30 INSTALL_FILE = install -m 644 -p
30 INSTALL_FILE = install -m 644 -p
31 INSTALL_DIR = $(COPY_DIR)
31 INSTALL_DIR = $(COPY_DIR)
32 INSTALL_PROGRAM = install -m 755 -p
32 INSTALL_PROGRAM = install -m 755 -p
33 DEL_FILE = rm -f
33 DEL_FILE = rm -f
34 SYMLINK = ln -f -s
34 SYMLINK = ln -f -s
35 DEL_DIR = rmdir
35 DEL_DIR = rmdir
36 MOVE = mv -f
36 MOVE = mv -f
37 CHK_DIR_EXISTS= test -d
37 CHK_DIR_EXISTS= test -d
38 MKDIR = mkdir -p
38 MKDIR = mkdir -p
39
39
40 ####### Output directory
40 ####### Output directory
41
41
42 OBJECTS_DIR = obj/
42 OBJECTS_DIR = obj/
43
43
44 ####### Files
44 ####### Files
45
45
46 SOURCES = ../src/wf_handler.c \
46 SOURCES = ../src/wf_handler.c \
47 ../src/tc_handler.c \
47 ../src/tc_handler.c \
48 ../src/fsw_processing.c \
48 ../src/fsw_processing.c \
49 ../src/fsw_misc.c \
49 ../src/fsw_misc.c \
50 ../src/fsw_init.c \
50 ../src/fsw_init.c \
51 ../src/fsw_globals.c \
51 ../src/fsw_globals.c \
52 ../src/fsw_spacewire.c
52 ../src/fsw_spacewire.c
53 OBJECTS = obj/wf_handler.o \
53 OBJECTS = obj/wf_handler.o \
54 obj/tc_handler.o \
54 obj/tc_handler.o \
55 obj/fsw_processing.o \
55 obj/fsw_processing.o \
56 obj/fsw_misc.o \
56 obj/fsw_misc.o \
57 obj/fsw_init.o \
57 obj/fsw_init.o \
58 obj/fsw_globals.o \
58 obj/fsw_globals.o \
59 obj/fsw_spacewire.o
59 obj/fsw_spacewire.o
60 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
60 DIST = /usr/lib64/qt4/mkspecs/common/unix.conf \
61 /usr/lib64/qt4/mkspecs/common/linux.conf \
61 /usr/lib64/qt4/mkspecs/common/linux.conf \
62 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
62 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
63 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
63 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
64 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
64 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
65 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
65 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
66 /usr/lib64/qt4/mkspecs/qconfig.pri \
66 /usr/lib64/qt4/mkspecs/qconfig.pri \
67 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
67 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
68 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
68 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
69 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
69 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
70 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
70 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
71 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
71 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
72 sparc.pri \
72 sparc.pri \
73 /usr/lib64/qt4/mkspecs/features/release.prf \
73 /usr/lib64/qt4/mkspecs/features/release.prf \
74 /usr/lib64/qt4/mkspecs/features/default_post.prf \
74 /usr/lib64/qt4/mkspecs/features/default_post.prf \
75 /usr/lib64/qt4/mkspecs/features/shared.prf \
75 /usr/lib64/qt4/mkspecs/features/shared.prf \
76 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
76 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
77 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
77 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
78 /usr/lib64/qt4/mkspecs/features/resources.prf \
78 /usr/lib64/qt4/mkspecs/features/resources.prf \
79 /usr/lib64/qt4/mkspecs/features/uic.prf \
79 /usr/lib64/qt4/mkspecs/features/uic.prf \
80 /usr/lib64/qt4/mkspecs/features/yacc.prf \
80 /usr/lib64/qt4/mkspecs/features/yacc.prf \
81 /usr/lib64/qt4/mkspecs/features/lex.prf \
81 /usr/lib64/qt4/mkspecs/features/lex.prf \
82 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
82 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
83 fsw-qt.pro
83 fsw-qt.pro
84 QMAKE_TARGET = fsw
84 QMAKE_TARGET = fsw
85 DESTDIR = bin/
85 DESTDIR = bin/
86 TARGET = bin/fsw
86 TARGET = bin/fsw
87
87
88 first: all
88 first: all
89 ####### Implicit rules
89 ####### Implicit rules
90
90
91 .SUFFIXES: .o .c .cpp .cc .cxx .C
91 .SUFFIXES: .o .c .cpp .cc .cxx .C
92
92
93 .cpp.o:
93 .cpp.o:
94 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
94 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
95
95
96 .cc.o:
96 .cc.o:
97 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
97 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
98
98
99 .cxx.o:
99 .cxx.o:
100 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
100 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
101
101
102 .C.o:
102 .C.o:
103 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
103 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
104
104
105 .c.o:
105 .c.o:
106 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
106 $(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
107
107
108 ####### Build rules
108 ####### Build rules
109
109
110 all: Makefile $(TARGET)
110 all: Makefile $(TARGET)
111
111
112 $(TARGET): $(OBJECTS)
112 $(TARGET): $(OBJECTS)
113 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
113 @$(CHK_DIR_EXISTS) bin/ || $(MKDIR) bin/
114 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
114 $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
115
115
116 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
116 Makefile: fsw-qt.pro /usr/lib64/qt4/mkspecs/linux-g++/qmake.conf /usr/lib64/qt4/mkspecs/common/unix.conf \
117 /usr/lib64/qt4/mkspecs/common/linux.conf \
117 /usr/lib64/qt4/mkspecs/common/linux.conf \
118 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
118 /usr/lib64/qt4/mkspecs/common/gcc-base.conf \
119 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
119 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf \
120 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
120 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
121 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
121 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
122 /usr/lib64/qt4/mkspecs/qconfig.pri \
122 /usr/lib64/qt4/mkspecs/qconfig.pri \
123 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
123 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
124 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
124 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
125 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
125 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
126 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
126 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
127 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
127 /usr/lib64/qt4/mkspecs/features/default_pre.prf \
128 sparc.pri \
128 sparc.pri \
129 /usr/lib64/qt4/mkspecs/features/release.prf \
129 /usr/lib64/qt4/mkspecs/features/release.prf \
130 /usr/lib64/qt4/mkspecs/features/default_post.prf \
130 /usr/lib64/qt4/mkspecs/features/default_post.prf \
131 /usr/lib64/qt4/mkspecs/features/shared.prf \
131 /usr/lib64/qt4/mkspecs/features/shared.prf \
132 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
132 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf \
133 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
133 /usr/lib64/qt4/mkspecs/features/warn_on.prf \
134 /usr/lib64/qt4/mkspecs/features/resources.prf \
134 /usr/lib64/qt4/mkspecs/features/resources.prf \
135 /usr/lib64/qt4/mkspecs/features/uic.prf \
135 /usr/lib64/qt4/mkspecs/features/uic.prf \
136 /usr/lib64/qt4/mkspecs/features/yacc.prf \
136 /usr/lib64/qt4/mkspecs/features/yacc.prf \
137 /usr/lib64/qt4/mkspecs/features/lex.prf \
137 /usr/lib64/qt4/mkspecs/features/lex.prf \
138 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
138 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf
139 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
139 $(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
140 /usr/lib64/qt4/mkspecs/common/unix.conf:
140 /usr/lib64/qt4/mkspecs/common/unix.conf:
141 /usr/lib64/qt4/mkspecs/common/linux.conf:
141 /usr/lib64/qt4/mkspecs/common/linux.conf:
142 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
142 /usr/lib64/qt4/mkspecs/common/gcc-base.conf:
143 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
143 /usr/lib64/qt4/mkspecs/common/gcc-base-unix.conf:
144 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
144 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
145 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
145 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
146 /usr/lib64/qt4/mkspecs/qconfig.pri:
146 /usr/lib64/qt4/mkspecs/qconfig.pri:
147 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
147 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
148 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
148 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
149 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
149 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
150 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
150 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
151 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
151 /usr/lib64/qt4/mkspecs/features/default_pre.prf:
152 sparc.pri:
152 sparc.pri:
153 /usr/lib64/qt4/mkspecs/features/release.prf:
153 /usr/lib64/qt4/mkspecs/features/release.prf:
154 /usr/lib64/qt4/mkspecs/features/default_post.prf:
154 /usr/lib64/qt4/mkspecs/features/default_post.prf:
155 /usr/lib64/qt4/mkspecs/features/shared.prf:
155 /usr/lib64/qt4/mkspecs/features/shared.prf:
156 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
156 /usr/lib64/qt4/mkspecs/features/unix/gdb_dwarf_index.prf:
157 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
157 /usr/lib64/qt4/mkspecs/features/warn_on.prf:
158 /usr/lib64/qt4/mkspecs/features/resources.prf:
158 /usr/lib64/qt4/mkspecs/features/resources.prf:
159 /usr/lib64/qt4/mkspecs/features/uic.prf:
159 /usr/lib64/qt4/mkspecs/features/uic.prf:
160 /usr/lib64/qt4/mkspecs/features/yacc.prf:
160 /usr/lib64/qt4/mkspecs/features/yacc.prf:
161 /usr/lib64/qt4/mkspecs/features/lex.prf:
161 /usr/lib64/qt4/mkspecs/features/lex.prf:
162 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
162 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf:
163 qmake: FORCE
163 qmake: FORCE
164 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
164 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
165
165
166 dist:
166 dist:
167 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
167 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
168 $(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
168 $(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
169
169
170
170
171 clean:compiler_clean
171 clean:compiler_clean
172 -$(DEL_FILE) $(OBJECTS)
172 -$(DEL_FILE) $(OBJECTS)
173 -$(DEL_FILE) *~ core *.core
173 -$(DEL_FILE) *~ core *.core
174
174
175
175
176 ####### Sub-libraries
176 ####### Sub-libraries
177
177
178 distclean: clean
178 distclean: clean
179 -$(DEL_FILE) $(TARGET)
179 -$(DEL_FILE) $(TARGET)
180 -$(DEL_FILE) Makefile
180 -$(DEL_FILE) Makefile
181
181
182
182
183 grmon:
183 grmon:
184 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
184 cd bin && C:/opt/grmon-eval-2.0.29b/win32/bin/grmon.exe -uart COM4 -u
185
185
186 check: first
186 check: first
187
187
188 compiler_rcc_make_all:
188 compiler_rcc_make_all:
189 compiler_rcc_clean:
189 compiler_rcc_clean:
190 compiler_uic_make_all:
190 compiler_uic_make_all:
191 compiler_uic_clean:
191 compiler_uic_clean:
192 compiler_image_collection_make_all: qmake_image_collection.cpp
192 compiler_image_collection_make_all: qmake_image_collection.cpp
193 compiler_image_collection_clean:
193 compiler_image_collection_clean:
194 -$(DEL_FILE) qmake_image_collection.cpp
194 -$(DEL_FILE) qmake_image_collection.cpp
195 compiler_yacc_decl_make_all:
195 compiler_yacc_decl_make_all:
196 compiler_yacc_decl_clean:
196 compiler_yacc_decl_clean:
197 compiler_yacc_impl_make_all:
197 compiler_yacc_impl_make_all:
198 compiler_yacc_impl_clean:
198 compiler_yacc_impl_clean:
199 compiler_lex_make_all:
199 compiler_lex_make_all:
200 compiler_lex_clean:
200 compiler_lex_clean:
201 compiler_clean:
201 compiler_clean:
202
202
203 ####### Compile
203 ####### Compile
204
204
205 obj/wf_handler.o: ../src/wf_handler.c
205 obj/wf_handler.o: ../src/wf_handler.c
206 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
206 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/wf_handler.o ../src/wf_handler.c
207
207
208 obj/tc_handler.o: ../src/tc_handler.c
208 obj/tc_handler.o: ../src/tc_handler.c
209 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
209 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/tc_handler.o ../src/tc_handler.c
210
210
211 obj/fsw_processing.o: ../src/fsw_processing.c
211 obj/fsw_processing.o: ../src/fsw_processing.c
212 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c
212 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_processing.o ../src/fsw_processing.c
213
213
214 obj/fsw_misc.o: ../src/fsw_misc.c
214 obj/fsw_misc.o: ../src/fsw_misc.c
215 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
215 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_misc.o ../src/fsw_misc.c
216
216
217 obj/fsw_init.o: ../src/fsw_init.c
217 obj/fsw_init.o: ../src/fsw_init.c
218 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
218 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_init.o ../src/fsw_init.c
219
219
220 obj/fsw_globals.o: ../src/fsw_globals.c
220 obj/fsw_globals.o: ../src/fsw_globals.c
221 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
221 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_globals.o ../src/fsw_globals.c
222
222
223 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
223 obj/fsw_spacewire.o: ../src/fsw_spacewire.c
224 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
224 $(CC) -c $(CFLAGS) $(INCPATH) -o obj/fsw_spacewire.o ../src/fsw_spacewire.c
225
225
226 ####### Install
226 ####### Install
227
227
228 install: FORCE
228 install: FORCE
229
229
230 uninstall: FORCE
230 uninstall: FORCE
231
231
232 FORCE:
232 FORCE:
233
233
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -1,58 +1,62
1 TEMPLATE = app
1 TEMPLATE = app
2 # CONFIG += console v8 sim
2 # CONFIG += console v8 sim
3 # CONFIG options = verbose *** cpu_usage_report *** gsa *** stack_report
3 # CONFIG options = verbose *** boot_messages *** debug_messages *** cpu_usage_report *** stack_report *** gsa
4 CONFIG += console verbose stack_report cpu_usage_report
4 CONFIG += console verbose
5 CONFIG -= qt
5 CONFIG -= qt
6
6
7 include(./sparc.pri)
7 include(./sparc.pri)
8
8
9 # flight software version
9 # flight software version
10 SWVERSION=-0-13
10 SWVERSION=-0-13
11 DEFINES += SW_VERSION_N1=0
11 DEFINES += SW_VERSION_N1=0
12 DEFINES += SW_VERSION_N2=0
12 DEFINES += SW_VERSION_N2=0
13 DEFINES += SW_VERSION_N3=0
13 DEFINES += SW_VERSION_N3=0
14 DEFINES += SW_VERSION_N4=13
14 DEFINES += SW_VERSION_N4=13
15
15
16 contains( CONFIG, verbose ) {
16 contains( CONFIG, verbose ) {
17 DEFINES += PRINT_MESSAGES_ON_CONSOLE
17 DEFINES += PRINT_MESSAGES_ON_CONSOLE
18 }
18 }
19
19
20 contains( CONFIG, cpu_usage_report ) {
20 contains( CONFIG, cpu_usage_report ) {
21 DEFINES += PRINT_TASK_STATISTICS
21 DEFINES += PRINT_TASK_STATISTICS
22 }
22 }
23
23
24 contains( CONFIG, stack_report ) {
24 contains( CONFIG, stack_report ) {
25 DEFINES += PRINT_STACK_REPORT
25 DEFINES += PRINT_STACK_REPORT
26 }
26 }
27
27
28 contains( CONFIG, boot_messages ) {
29 DEFINES += BOOT_MESSAGES
30 }
31
28 TARGET = fsw
32 TARGET = fsw
29 contains( CONFIG, gsa ) {
33 contains( CONFIG, gsa ) {
30 DEFINES += GSA
34 DEFINES += GSA
31 TARGET = fsw-gsa
35 TARGET = fsw-gsa
32 }
36 }
33
37
34 INCLUDEPATH += \
38 INCLUDEPATH += \
35 ../src \
39 ../src \
36 ../header
40 ../header
37
41
38 SOURCES += \
42 SOURCES += \
39 ../src/wf_handler.c \
43 ../src/wf_handler.c \
40 ../src/tc_handler.c \
44 ../src/tc_handler.c \
41 ../src/fsw_processing.c \
45 ../src/fsw_processing.c \
42 ../src/fsw_misc.c \
46 ../src/fsw_misc.c \
43 ../src/fsw_init.c \
47 ../src/fsw_init.c \
44 ../src/fsw_globals.c \
48 ../src/fsw_globals.c \
45 ../src/fsw_spacewire.c
49 ../src/fsw_spacewire.c
46
50
47 HEADERS += \
51 HEADERS += \
48 ../header/wf_handler.h \
52 ../header/wf_handler.h \
49 ../header/tc_handler.h \
53 ../header/tc_handler.h \
50 ../header/grlib_regs.h \
54 ../header/grlib_regs.h \
51 ../header/fsw_processing.h \
55 ../header/fsw_processing.h \
52 ../header/fsw_params.h \
56 ../header/fsw_params.h \
53 ../header/fsw_misc.h \
57 ../header/fsw_misc.h \
54 ../header/fsw_init.h \
58 ../header/fsw_init.h \
55 ../header/ccsds_types.h \
59 ../header/ccsds_types.h \
56 ../header/fsw_params_processing.h \
60 ../header/fsw_params_processing.h \
57 ../header/fsw_spacewire.h
61 ../header/fsw_spacewire.h
58
62
@@ -1,257 +1,257
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE QtCreatorProject>
2 <!DOCTYPE QtCreatorProject>
3 <!-- Written by QtCreator 2.8.0, 2013-10-04T15:45:21. -->
3 <!-- Written by QtCreator 2.8.0, 2013-10-08T06:59:51. -->
4 <qtcreator>
4 <qtcreator>
5 <data>
5 <data>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
7 <value type="int">0</value>
7 <value type="int">0</value>
8 </data>
8 </data>
9 <data>
9 <data>
10 <variable>ProjectExplorer.Project.EditorSettings</variable>
10 <variable>ProjectExplorer.Project.EditorSettings</variable>
11 <valuemap type="QVariantMap">
11 <valuemap type="QVariantMap">
12 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
12 <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
13 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
13 <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
14 <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
14 <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
15 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
15 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
16 <value type="QString" key="language">Cpp</value>
16 <value type="QString" key="language">Cpp</value>
17 <valuemap type="QVariantMap" key="value">
17 <valuemap type="QVariantMap" key="value">
18 <value type="QString" key="CurrentPreferences">CppGlobal</value>
18 <value type="QString" key="CurrentPreferences">CppGlobal</value>
19 </valuemap>
19 </valuemap>
20 </valuemap>
20 </valuemap>
21 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
21 <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
22 <value type="QString" key="language">QmlJS</value>
22 <value type="QString" key="language">QmlJS</value>
23 <valuemap type="QVariantMap" key="value">
23 <valuemap type="QVariantMap" key="value">
24 <value type="QString" key="CurrentPreferences">QmlJSGlobal</value>
24 <value type="QString" key="CurrentPreferences">QmlJSGlobal</value>
25 </valuemap>
25 </valuemap>
26 </valuemap>
26 </valuemap>
27 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
27 <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
28 <value type="QByteArray" key="EditorConfiguration.Codec">System</value>
28 <value type="QByteArray" key="EditorConfiguration.Codec">System</value>
29 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
29 <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
30 <value type="int" key="EditorConfiguration.IndentSize">4</value>
30 <value type="int" key="EditorConfiguration.IndentSize">4</value>
31 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
31 <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
32 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
32 <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
33 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
33 <value type="int" key="EditorConfiguration.PaddingMode">1</value>
34 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
34 <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
35 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
35 <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
36 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
36 <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
37 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
37 <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
38 <value type="int" key="EditorConfiguration.TabSize">8</value>
38 <value type="int" key="EditorConfiguration.TabSize">8</value>
39 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
39 <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
40 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
40 <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
41 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
41 <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
42 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
42 <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
43 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
43 <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
44 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
44 <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
45 </valuemap>
45 </valuemap>
46 </data>
46 </data>
47 <data>
47 <data>
48 <variable>ProjectExplorer.Project.PluginSettings</variable>
48 <variable>ProjectExplorer.Project.PluginSettings</variable>
49 <valuemap type="QVariantMap"/>
49 <valuemap type="QVariantMap"/>
50 </data>
50 </data>
51 <data>
51 <data>
52 <variable>ProjectExplorer.Project.Target.0</variable>
52 <variable>ProjectExplorer.Project.Target.0</variable>
53 <valuemap type="QVariantMap">
53 <valuemap type="QVariantMap">
54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
54 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
55 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop-Qt 4.8.2 in PATH (System)</value>
56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
56 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{5289e843-9ef2-45ce-88c6-ad27d8e08def}</value>
57 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
57 <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
58 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
58 <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
59 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
59 <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
60 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
60 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
61 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
61 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
62 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
62 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
63 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
63 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
64 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
64 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
65 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
65 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
66 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
66 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
67 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
67 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
68 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
68 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
69 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
69 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
70 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
70 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
71 </valuemap>
71 </valuemap>
72 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
72 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
73 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
73 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
74 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
74 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
75 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
75 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
76 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
76 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
77 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
77 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
78 <value type="QString">-w</value>
78 <value type="QString">-w</value>
79 <value type="QString">-r</value>
79 <value type="QString">-r</value>
80 </valuelist>
80 </valuelist>
81 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
81 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
82 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w </value>
82 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w </value>
83 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
83 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
84 </valuemap>
84 </valuemap>
85 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
85 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
86 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
86 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
87 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
88 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
88 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
89 </valuemap>
89 </valuemap>
90 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
90 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
91 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
91 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
92 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
92 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
93 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
93 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
94 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
95 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
96 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
96 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
97 <value type="QString">-w</value>
97 <value type="QString">-w</value>
98 <value type="QString">-r</value>
98 <value type="QString">-r</value>
99 </valuelist>
99 </valuelist>
100 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
100 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
101 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w clean</value>
101 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w clean</value>
102 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
102 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
103 </valuemap>
103 </valuemap>
104 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
104 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
105 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
105 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
106 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
106 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
107 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
107 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
108 </valuemap>
108 </valuemap>
109 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
109 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
110 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
110 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
111 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
111 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
112 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Release</value>
112 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Release</value>
113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
113 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
114 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
115 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
115 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
116 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
116 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
117 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
117 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
118 </valuemap>
118 </valuemap>
119 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
119 <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
120 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
120 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
121 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
121 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
122 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
122 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
123 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
124 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
124 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
125 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
125 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
126 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
126 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
127 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
127 <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
128 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
128 <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
129 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
129 <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
130 </valuemap>
130 </valuemap>
131 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
131 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
132 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
132 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
133 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
133 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
134 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
134 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
135 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
135 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
136 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
136 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
137 <value type="QString">-w</value>
137 <value type="QString">-w</value>
138 <value type="QString">-r</value>
138 <value type="QString">-r</value>
139 </valuelist>
139 </valuelist>
140 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
140 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
141 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w </value>
141 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w </value>
142 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
142 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
143 </valuemap>
143 </valuemap>
144 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
144 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
145 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
145 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
146 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
146 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
147 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
147 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
148 </valuemap>
148 </valuemap>
149 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
149 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
150 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
150 <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
151 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
151 <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
152 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
152 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
153 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
153 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
154 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
154 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
155 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
155 <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
156 <value type="QString">-w</value>
156 <value type="QString">-w</value>
157 <value type="QString">-r</value>
157 <value type="QString">-r</value>
158 </valuelist>
158 </valuelist>
159 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
159 <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
160 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w clean</value>
160 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">-r -w clean</value>
161 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
161 <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
162 </valuemap>
162 </valuemap>
163 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
163 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
164 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
164 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
165 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
165 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
166 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
166 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
167 </valuemap>
167 </valuemap>
168 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
168 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
169 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
169 <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
170 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
170 <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
171 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Debug</value>
171 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.2 in PATH (System) Debug</value>
172 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
172 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
173 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
173 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
174 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
174 <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
175 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
175 <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/opt/DEV_PLE/FSW-qt</value>
176 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
176 <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">false</value>
177 </valuemap>
177 </valuemap>
178 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
178 <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
179 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
179 <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
180 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
180 <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
181 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
181 <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
182 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
182 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
183 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
183 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
184 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
184 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
185 </valuemap>
185 </valuemap>
186 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
186 <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
187 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">No deployment</value>
187 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">No deployment</value>
188 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
188 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
189 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
189 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
190 </valuemap>
190 </valuemap>
191 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
191 <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
192 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
192 <valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
193 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
193 <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
194 <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
194 <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
195 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
195 <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
196 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
196 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
197 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
197 <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
198 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
198 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
199 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
199 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
200 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
200 <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
201 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
201 <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
202 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
202 <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
203 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
203 <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
204 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
204 <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
205 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
205 <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
206 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
206 <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
207 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
207 <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
208 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
208 <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
209 <value type="int">0</value>
209 <value type="int">0</value>
210 <value type="int">1</value>
210 <value type="int">1</value>
211 <value type="int">2</value>
211 <value type="int">2</value>
212 <value type="int">3</value>
212 <value type="int">3</value>
213 <value type="int">4</value>
213 <value type="int">4</value>
214 <value type="int">5</value>
214 <value type="int">5</value>
215 <value type="int">6</value>
215 <value type="int">6</value>
216 <value type="int">7</value>
216 <value type="int">7</value>
217 <value type="int">8</value>
217 <value type="int">8</value>
218 <value type="int">9</value>
218 <value type="int">9</value>
219 <value type="int">10</value>
219 <value type="int">10</value>
220 <value type="int">11</value>
220 <value type="int">11</value>
221 <value type="int">12</value>
221 <value type="int">12</value>
222 <value type="int">13</value>
222 <value type="int">13</value>
223 <value type="int">14</value>
223 <value type="int">14</value>
224 </valuelist>
224 </valuelist>
225 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
225 <value type="int" key="PE.EnvironmentAspect.Base">2</value>
226 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
226 <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
227 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
227 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">fsw-qt</value>
228 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
228 <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
229 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
229 <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/opt/DEV_PLE/FSW-qt/fsw-qt.pro</value>
230 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
230 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
231 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
231 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">fsw-qt.pro</value>
232 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
232 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
233 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
233 <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">true</value>
234 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
234 <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
235 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
235 <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
236 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
236 <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
237 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
237 <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
238 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
238 <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
239 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
239 <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
240 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
240 <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
241 </valuemap>
241 </valuemap>
242 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
242 <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
243 </valuemap>
243 </valuemap>
244 </data>
244 </data>
245 <data>
245 <data>
246 <variable>ProjectExplorer.Project.TargetCount</variable>
246 <variable>ProjectExplorer.Project.TargetCount</variable>
247 <value type="int">1</value>
247 <value type="int">1</value>
248 </data>
248 </data>
249 <data>
249 <data>
250 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
250 <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
251 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
251 <value type="QByteArray">{2e58a81f-9962-4bba-ae6b-760177f0656c}</value>
252 </data>
252 </data>
253 <data>
253 <data>
254 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
254 <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
255 <value type="int">14</value>
255 <value type="int">14</value>
256 </data>
256 </data>
257 </qtcreator>
257 </qtcreator>
@@ -1,59 +1,59
1 #ifndef FSW_RTEMS_H_INCLUDED
1 #ifndef FSW_RTEMS_H_INCLUDED
2 #define FSW_RTEMS_H_INCLUDED
2 #define FSW_RTEMS_H_INCLUDED
3
3
4 #include <errno.h>
4 #include <errno.h>
5 #include <fcntl.h>
5 #include <fcntl.h>
6 #include <stdio.h>
6 #include <stdio.h>
7 #include <stdlib.h>
7 #include <stdlib.h>
8
8
9 #include <grspw.h>
9 #include <grspw.h>
10 #include <apbuart.h>
10 #include <apbuart.h>
11
11
12 #include "fsw_params.h"
12 #include "fsw_params.h"
13 #include "fsw_misc.h"
13 #include "fsw_misc.h"
14 #include "fsw_processing.h"
14 #include "fsw_processing.h"
15 #include "tc_handler.h"
15 #include "tc_handler.h"
16 #include "wf_handler.h"
16 #include "wf_handler.h"
17 #include "grlib_regs.h"
17 #include "grlib_regs.h"
18 #include "ccsds_types.h"
18 #include "ccsds_types.h"
19
19
20 #include "fsw_spacewire.h"
20 #include "fsw_spacewire.h"
21
21
22 extern int sched_yield( void );
22 extern rtems_name misc_name[5];
23 extern int errno;
23 extern rtems_id misc_id[5];
24 extern rtems_id Task_id[ ]; /* array of task ids */
24 extern rtems_name Task_name[20]; /* array of task names */
25 extern rtems_name Task_name[ ]; /* array of task names */
25 extern rtems_id Task_id[20]; /* array of task ids */
26 extern rtems_name misc_id[ ];
27 extern rtems_name misc_name[ ]; /* array of miscellaneous names for rtems objects */
28 extern unsigned int maxCount;
26 extern unsigned int maxCount;
29 extern int fdSPW; // grspw file descriptor
27 extern int fdSPW; // grspw file descriptor
30 extern int fdUART; // uart file descriptor
28 extern int fdUART; // uart file descriptor
31 extern unsigned char lfrCurrentMode;
29 extern unsigned char lfrCurrentMode;
32
30
33 // MODE PARAMETERS
31 // MODE PARAMETERS
34 extern struct param_local_str param_local;
32 extern struct param_local_str param_local;
35 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
33 extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
36 extern unsigned short sequenceCounters[SEQ_CNT_NB_PID][SEQ_CNT_NB_CAT][SEQ_CNT_NB_DEST_ID];
34 extern unsigned short sequenceCounters[SEQ_CNT_NB_PID][SEQ_CNT_NB_CAT][SEQ_CNT_NB_DEST_ID];
37
35
38 // RTEMS TASKS
36 // RTEMS TASKS
39 rtems_task Init( rtems_task_argument argument); /* forward declaration needed */
37 rtems_task Init( rtems_task_argument argument); /* forward declaration needed */
40 rtems_task recv_task(rtems_task_argument argument);
38 rtems_task recv_task(rtems_task_argument argument);
41 rtems_task stat_task(rtems_task_argument argument);
39 rtems_task stat_task(rtems_task_argument argument);
42 rtems_task wfrm_task(rtems_task_argument argument);
40 rtems_task wfrm_task(rtems_task_argument argument);
43
41
44 // OTHER functions
42 // OTHER functions
45 int create_names( void );
43 int create_names( void );
46 int create_all_tasks( void );
44 int create_all_tasks( void );
47 int start_all_tasks( void );
45 int start_all_tasks( void );
48 //
46 rtems_status_code create_message_queues( void );
49 int create_message_queues( void );
50 //
47 //
51 void init_parameter_dump( void );
48 void init_parameter_dump( void );
52 void init_local_mode_parameters( void );
49 void init_local_mode_parameters( void );
53 void init_housekeeping_parameters( void );
50 void init_housekeeping_parameters( void );
54
51
55 extern int rtems_cpu_usage_report( void );
52 extern int rtems_cpu_usage_report( void );
56 extern int rtems_cpu_usage_reset( void );
53 extern int rtems_cpu_usage_reset( void );
57 extern void rtems_stack_checker_report_usage( void );
54 extern void rtems_stack_checker_report_usage( void );
58
55
56 extern int sched_yield( void );
57 extern int errno;
58
59 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
59 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
@@ -1,34 +1,36
1 #ifndef FSW_MISC_H_INCLUDED
1 #ifndef FSW_MISC_H_INCLUDED
2 #define FSW_MISC_H_INCLUDED
2 #define FSW_MISC_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <stdio.h>
5 #include <stdio.h>
6
6
7 #include <grspw.h>
7 #include <grspw.h>
8
8
9 #include "fsw_init.h"
9 #include "fsw_init.h"
10 #include "fsw_params.h"
10 #include "fsw_params.h"
11 #include "grlib_regs.h"
11 #include "grlib_regs.h"
12 #include "ccsds_types.h"
12 #include "ccsds_types.h"
13
13
14 rtems_name HK_name; // name of the HK rate monotonic
14 rtems_name HK_name; // name of the HK rate monotonic
15 rtems_id HK_id; // id of the HK rate monotonic period
15 rtems_id HK_id; // id of the HK rate monotonic period
16 extern Packet_TM_LFR_HK_t housekeeping_packet;
16 extern Packet_TM_LFR_HK_t housekeeping_packet;
17
17
18 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
18 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
19 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
19 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
20 int timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer );
20 int timer_start( gptimer_regs_t *gptimer_regs, unsigned char timer );
21 int timer_stop( gptimer_regs_t *gptimer_regs, unsigned char timer );
21 int timer_stop( gptimer_regs_t *gptimer_regs, unsigned char timer );
22 int timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider);
22 int timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider);
23 void update_spacewire_statistics();
23 void update_spacewire_statistics();
24
24
25 // SERIAL LINK
25 // SERIAL LINK
26 int send_console_outputs_on_apbuart_port( void );
26 int send_console_outputs_on_apbuart_port( void );
27 int set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value);
27 int set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value);
28
28
29 // RTEMS TASKS
29 // RTEMS TASKS
30 rtems_task stat_task(rtems_task_argument argument);
30 rtems_task stat_task(rtems_task_argument argument);
31 rtems_task hous_task(rtems_task_argument argument);
31 rtems_task hous_task(rtems_task_argument argument);
32 rtems_task send_task(rtems_task_argument argument);
32 rtems_task send_task(rtems_task_argument argument);
33
33
34 rtems_id get_pkts_queue_id( void );
35
34 #endif // FSW_MISC_H_INCLUDED
36 #endif // FSW_MISC_H_INCLUDED
@@ -1,199 +1,219
1 #ifndef FSW_RTEMS_CONFIG_H_INCLUDED
1 #ifndef FSW_RTEMS_CONFIG_H_INCLUDED
2 #define FSW_RTEMS_CONFIG_H_INCLUDED
2 #define FSW_RTEMS_CONFIG_H_INCLUDED
3
3
4 #include <fsw_params_processing.h>
4 #include <fsw_params_processing.h>
5
5
6 #define GRSPW_DEVICE_NAME "/dev/grspw0"
6 #define GRSPW_DEVICE_NAME "/dev/grspw0"
7 #define UART_DEVICE_NAME "/dev/console"
7 #define UART_DEVICE_NAME "/dev/console"
8
8
9 //************************
9 //************************
10 // flight software version
10 // flight software version
11 // this parameters is handled by the Qt project options
11 // this parameters is handled by the Qt project options
12
12
13 //**********
13 //**********
14 // LFR MODES
14 // LFR MODES
15 #define LFR_MODE_STANDBY 0
15 #define LFR_MODE_STANDBY 0
16 #define LFR_MODE_NORMAL 1
16 #define LFR_MODE_NORMAL 1
17 #define LFR_MODE_BURST 2
17 #define LFR_MODE_BURST 2
18 #define LFR_MODE_SBM1 3
18 #define LFR_MODE_SBM1 3
19 #define LFR_MODE_SBM2 4
19 #define LFR_MODE_SBM2 4
20 #define LFR_MODE_NORMAL_CWF_F3 5
20 #define LFR_MODE_NORMAL_CWF_F3 5
21
21
22 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
22 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
23 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
23 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
24 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
24 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
25 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
25 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
26 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
26 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
27 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
27 #define RTEMS_EVENT_MODE_SBM2_WFRM RTEMS_EVENT_5
28
28
29 //****************************
29 //****************************
30 // LFR DEFAULT MODE PARAMETERS
30 // LFR DEFAULT MODE PARAMETERS
31 // COMMON
31 // COMMON
32 #define DEFAULT_SY_LFR_COMMON0 0x00
32 #define DEFAULT_SY_LFR_COMMON0 0x00
33 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
33 #define DEFAULT_SY_LFR_COMMON1 0x10 // default value 0 0 0 1 0 0 0 0
34 // NORM
34 // NORM
35 #define DEFAULT_SY_LFR_N_SWF_L 2048 // nb sample
35 #define DEFAULT_SY_LFR_N_SWF_L 2048 // nb sample
36 #define DEFAULT_SY_LFR_N_SWF_P 16 // sec
36 #define DEFAULT_SY_LFR_N_SWF_P 16 // sec
37 #define DEFAULT_SY_LFR_N_ASM_P 16 // sec
37 #define DEFAULT_SY_LFR_N_ASM_P 16 // sec
38 #define DEFAULT_SY_LFR_N_BP_P0 4 // sec
38 #define DEFAULT_SY_LFR_N_BP_P0 4 // sec
39 #define DEFAULT_SY_LFR_N_BP_P1 20 // sec
39 #define DEFAULT_SY_LFR_N_BP_P1 20 // sec
40 #define MIN_DELTA_SNAPSHOT 16 // sec
40 #define MIN_DELTA_SNAPSHOT 16 // sec
41 // BURST
41 // BURST
42 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
42 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
43 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
43 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
44 // SBM1
44 // SBM1
45 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
45 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
46 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
46 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
47 // SBM2
47 // SBM2
48 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
48 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
49 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
49 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
50 // ADDITIONAL PARAMETERS
50 // ADDITIONAL PARAMETERS
51 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
51 #define TIME_BETWEEN_TWO_SWF_PACKETS 30 // nb x 10 ms => 300 ms
52 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
52 #define TIME_BETWEEN_TWO_CWF3_PACKETS 1000 // nb x 10 ms => 10 s
53 //
53 //
54 //****************************
54 //****************************
55
55
56 //*****************************
56 //*****************************
57 // APB REGISTERS BASE ADDRESSES
57 // APB REGISTERS BASE ADDRESSES
58 #define REGS_ADDR_APBUART 0x80000100
58 #define REGS_ADDR_APBUART 0x80000100
59 #define REGS_ADDR_GPTIMER 0x80000300
59 #define REGS_ADDR_GPTIMER 0x80000300
60 #define REGS_ADDR_GRSPW 0x80000500
60 #define REGS_ADDR_GRSPW 0x80000500
61 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
61 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
62 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
62 #define REGS_ADDR_SPECTRAL_MATRIX 0x80000f00
63
63
64 #ifdef GSA
64 #ifdef GSA
65 #else
65 #else
66 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f20
66 #define REGS_ADDR_WAVEFORM_PICKER 0x80000f20
67 #endif
67 #endif
68
68
69 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
69 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
70 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50)
70 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 (0x50)
71
71
72 //**********
72 //**********
73 // IRQ LINES
73 // IRQ LINES
74 #define IRQ_SM 9
74 #define IRQ_SM 9
75 #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels
75 #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels
76 #define IRQ_WF 10
76 #define IRQ_WF 10
77 #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels
77 #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels
78 #define IRQ_TIME1 12
78 #define IRQ_TIME1 12
79 #define IRQ_SPARC_TIME1 0x1c // see sparcv8.pdf p.76 for interrupt levels
79 #define IRQ_SPARC_TIME1 0x1c // see sparcv8.pdf p.76 for interrupt levels
80 #define IRQ_TIME2 13
80 #define IRQ_TIME2 13
81 #define IRQ_SPARC_TIME2 0x1d // see sparcv8.pdf p.76 for interrupt levels
81 #define IRQ_SPARC_TIME2 0x1d // see sparcv8.pdf p.76 for interrupt levels
82 #define IRQ_WAVEFORM_PICKER 14
82 #define IRQ_WAVEFORM_PICKER 14
83 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
83 #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels
84 #define IRQ_SPECTRAL_MATRIX 6
84 #define IRQ_SPECTRAL_MATRIX 6
85 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
85 #define IRQ_SPARC_SPECTRAL_MATRIX 0x16 // see sparcv8.pdf p.76 for interrupt levels
86
86
87 //*****
87 //*****
88 // TIME
88 // TIME
89 #define CLKDIV_SM_SIMULATOR (10000 - 1) // 10 ms
89 #define CLKDIV_SM_SIMULATOR (10000 - 1) // 10 ms
90 #define CLKDIV_WF_SIMULATOR (10000000 - 1) // 10 000 000 * 1 us = 10 s
90 #define CLKDIV_WF_SIMULATOR (10000000 - 1) // 10 000 000 * 1 us = 10 s
91 #define TIMER_SM_SIMULATOR 1
91 #define TIMER_SM_SIMULATOR 1
92 #define TIMER_WF_SIMULATOR 2
92 #define TIMER_WF_SIMULATOR 2
93 #define HK_PERIOD 100 // 100 * 10ms => 1sec
93 #define HK_PERIOD 100 // 100 * 10ms => 1sec
94
94
95 //**********
95 //**********
96 // LPP CODES
96 // LPP CODES
97 #define LFR_SUCCESSFUL 0
97 #define LFR_SUCCESSFUL 0
98 #define LFR_DEFAULT 1
98 #define LFR_DEFAULT 1
99
99
100 //******
100 //******
101 // RTEMS
101 // RTEMS
102 #define TASKID_RECV 1
102 #define TASKID_RECV 1
103 #define TASKID_ACTN 2
103 #define TASKID_ACTN 2
104 #define TASKID_SPIQ 3
104 #define TASKID_SPIQ 3
105 #define TASKID_SMIQ 4
105 #define TASKID_SMIQ 4
106 #define TASKID_STAT 5
106 #define TASKID_STAT 5
107 #define TASKID_AVF0 6
107 #define TASKID_AVF0 6
108 #define TASKID_BPF0 7
108 #define TASKID_BPF0 7
109 #define TASKID_WFRM 8
109 #define TASKID_WFRM 8
110 #define TASKID_DUMB 9
110 #define TASKID_DUMB 9
111 #define TASKID_HOUS 10
111 #define TASKID_HOUS 10
112 #define TASKID_MATR 11
112 #define TASKID_MATR 11
113 #define TASKID_CWF3 12
113 #define TASKID_CWF3 12
114 #define TASKID_CWF2 13
114 #define TASKID_CWF2 13
115 #define TASKID_CWF1 14
115 #define TASKID_CWF1 14
116 #define TASKID_SEND 15
116 #define TASKID_SEND 15
117
117
118 #define TASK_PRIORITY_SPIQ 5
118 #define TASK_PRIORITY_SPIQ 5
119 #define TASK_PRIORITY_SMIQ 10
119 #define TASK_PRIORITY_SMIQ 10
120 //
120 //
121 #define TASK_PRIORITY_SEND 30
121 #define TASK_PRIORITY_RECV 20
122 //
122 #define TASK_PRIORITY_ACTN 30
123 #define TASK_PRIORITY_RECV 40
124 #define TASK_PRIORITY_ACTN 40
125 //
123 //
126 #define TASK_PRIORITY_HOUS 40
124 #define TASK_PRIORITY_HOUS 40
127 #define TASK_PRIORITY_CWF1 40
125 #define TASK_PRIORITY_CWF1 40
128 #define TASK_PRIORITY_CWF2 40
126 #define TASK_PRIORITY_CWF2 40
129 #define TASK_PRIORITY_WFRM 40
127 #define TASK_PRIORITY_WFRM 40
130 #define TASK_PRIORITY_CWF3 40
128 #define TASK_PRIORITY_CWF3 40
131 //
129 //
130 #define TASK_PRIORITY_SEND 40
131 //
132 #define TASK_PRIORITY_AVF0 60
132 #define TASK_PRIORITY_AVF0 60
133 #define TASK_PRIORITY_BPF0 60
133 #define TASK_PRIORITY_BPF0 60
134 #define TASK_PRIORITY_MATR 100
134 #define TASK_PRIORITY_MATR 100
135 #define TASK_PRIORITY_STAT 200
135 #define TASK_PRIORITY_STAT 200
136 #define TASK_PRIORITY_DUMB 200
136 #define TASK_PRIORITY_DUMB 200
137
137
138 #define ACTION_MSG_QUEUE_COUNT 10
138 #define ACTION_MSG_QUEUE_COUNT 10
139 #define ACTION_MSG_PKTS_COUNT 50
139 #define ACTION_MSG_PKTS_COUNT 50
140 #define ACTION_MSG_PKTS_SIZE 24 // hlen *hdr dlen *data sent options
140 #define ACTION_MSG_PKTS_SIZE 24 // hlen *hdr dlen *data sent options
141
141
142 #define QUEUE_QUEU 0
142 #define QUEUE_QUEU 0
143 #define QUEUE_PKTS 1
143 #define QUEUE_PKTS 1
144
144
145 //*******
145 //*******
146 // MACROS
146 // MACROS
147 #ifdef PRINT_MESSAGES_ON_CONSOLE
147 #ifdef PRINT_MESSAGES_ON_CONSOLE
148 #define PRINTF(x) printf(x);
148 #define PRINTF(x) printf(x);
149 #define PRINTF1(x,y) printf(x,y);
149 #define PRINTF1(x,y) printf(x,y);
150 #define PRINTF2(x,y,z) printf(x,y,z);
150 #define PRINTF2(x,y,z) printf(x,y,z);
151 #else
151 #else
152 #define PRINTF(x) ;
152 #define PRINTF(x) ;
153 #define PRINTF1(x,y) ;
153 #define PRINTF1(x,y) ;
154 #define PRINTF2(x,y,z) ;
154 #define PRINTF2(x,y,z) ;
155 #endif
155 #endif
156
156
157 #ifdef BOOT_MESSAGES
158 #define BOOT_PRINTF(x) printf(x);
159 #define BOOT_PRINTF1(x,y) printf(x,y);
160 #define BOOT_PRINTF2(x,y,z) printf(x,y,z);
161 #else
162 #define BOOT_PRINTF(x) ;
163 #define BOOT_PRINTF1(x,y) ;
164 #define BOOT_PRINTF2(x,y,z) ;
165 #endif
166
167 #ifdef DEBUG_MESSAGES
168 #define DEBUG_PRINTF(x) printf(x);
169 #define DEBUG_PRINTF1(x,y) printf(x,y);
170 #define DEBUG_PRINTF2(x,y,z) printf(x,y,z);
171 #else
172 #define DEBUG_PRINTF(x) ;
173 #define DEBUG_PRINTF1(x,y) ;
174 #define DEBUG_PRINTF2(x,y,z) ;
175 #endif
176
157 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
177 #define CPU_USAGE_REPORT_PERIOD 6 // * 10 s = period
158
178
159 #define NB_SAMPLES_PER_SNAPSHOT 2048
179 #define NB_SAMPLES_PER_SNAPSHOT 2048
160 #define TIME_OFFSET 2
180 #define TIME_OFFSET 2
161 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
181 #define WAVEFORM_EXTENDED_HEADER_OFFSET 22
162 #define NB_BYTES_SWF_BLK 2 * 6
182 #define NB_BYTES_SWF_BLK (2 * 6)
163 #define NB_WORDS_SWF_BLK 3
183 #define NB_WORDS_SWF_BLK 3
164
184
165 //******************
185 //******************
166 // SEQUENCE COUNTERS
186 // SEQUENCE COUNTERS
167 #define SEQ_CNT_NB_PID 2
187 #define SEQ_CNT_NB_PID 2
168 #define SEQ_CNT_NB_CAT 4
188 #define SEQ_CNT_NB_CAT 4
169 #define SEQ_CNT_NB_DEST_ID 11
189 #define SEQ_CNT_NB_DEST_ID 11
170 // pid
190 // pid
171 #define SEQ_CNT_PID_76 0
191 #define SEQ_CNT_PID_76 0
172 #define SEQ_CNT_PID_79 1
192 #define SEQ_CNT_PID_79 1
173 //cat
193 //cat
174 #define SEQ_CNT_CAT_1 0
194 #define SEQ_CNT_CAT_1 0
175 #define SEQ_CNT_CAT_4 1
195 #define SEQ_CNT_CAT_4 1
176 #define SEQ_CNT_CAT_9 2
196 #define SEQ_CNT_CAT_9 2
177 #define SEQ_CNT_CAT_12 3
197 #define SEQ_CNT_CAT_12 3
178 // destination id
198 // destination id
179 #define SEQ_CNT_DST_ID_GROUND 0
199 #define SEQ_CNT_DST_ID_GROUND 0
180 #define SEQ_CNT_DST_ID_MISSION_TIMELINE 1
200 #define SEQ_CNT_DST_ID_MISSION_TIMELINE 1
181 #define SEQ_CNT_DST_ID_TC_SEQUENCES 2
201 #define SEQ_CNT_DST_ID_TC_SEQUENCES 2
182 #define SEQ_CNT_DST_ID_RECOVERY_ACTION_CMD 3
202 #define SEQ_CNT_DST_ID_RECOVERY_ACTION_CMD 3
183 #define SEQ_CNT_DST_ID_BACKUP_MISSION_TIMELINE 4
203 #define SEQ_CNT_DST_ID_BACKUP_MISSION_TIMELINE 4
184 #define SEQ_CNT_DST_ID_DIRECT_CMD 5
204 #define SEQ_CNT_DST_ID_DIRECT_CMD 5
185 #define SEQ_CNT_DST_ID_SPARE_GRD_SRC1 6
205 #define SEQ_CNT_DST_ID_SPARE_GRD_SRC1 6
186 #define SEQ_CNT_DST_ID_SPARE_GRD_SRC2 7
206 #define SEQ_CNT_DST_ID_SPARE_GRD_SRC2 7
187 #define SEQ_CNT_DST_ID_OBCP 8
207 #define SEQ_CNT_DST_ID_OBCP 8
188 #define SEQ_CNT_DST_ID_SYSTEM_CONTROL 9
208 #define SEQ_CNT_DST_ID_SYSTEM_CONTROL 9
189 #define SEQ_CNT_DST_ID_AOCS 10
209 #define SEQ_CNT_DST_ID_AOCS 10
190
210
191 struct param_local_str{
211 struct param_local_str{
192 unsigned int local_sbm1_nb_cwf_sent;
212 unsigned int local_sbm1_nb_cwf_sent;
193 unsigned int local_sbm1_nb_cwf_max;
213 unsigned int local_sbm1_nb_cwf_max;
194 unsigned int local_sbm2_nb_cwf_sent;
214 unsigned int local_sbm2_nb_cwf_sent;
195 unsigned int local_sbm2_nb_cwf_max;
215 unsigned int local_sbm2_nb_cwf_max;
196 unsigned int local_nb_interrupt_f0_MAX;
216 unsigned int local_nb_interrupt_f0_MAX;
197 };
217 };
198
218
199 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
219 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
@@ -1,70 +1,68
1 #ifndef FSW_RTEMS_PROCESSING_H_INCLUDED
1 #ifndef FSW_RTEMS_PROCESSING_H_INCLUDED
2 #define FSW_RTEMS_PROCESSING_H_INCLUDED
2 #define FSW_RTEMS_PROCESSING_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <grspw.h>
5 #include <grspw.h>
6 #include <leon.h>
6 #include <leon.h>
7
7
8 #include <fsw_init.h>
8 #include <fsw_init.h>
9 #include <fsw_params.h>
9 #include <fsw_params.h>
10 #include <grlib_regs.h>
10 #include <grlib_regs.h>
11 #include <ccsds_types.h>
11 #include <ccsds_types.h>
12
12
13 #include <stdio.h>
13 #include <stdio.h>
14 #include <stdlib.h>
14 #include <stdlib.h>
15
15
16 extern volatile int spec_mat_f0_0[ ];
16 extern volatile int spec_mat_f0_0[ ];
17 extern volatile int spec_mat_f0_1[ ];
17 extern volatile int spec_mat_f0_1[ ];
18 extern volatile int spec_mat_f0_a[ ];
18 extern volatile int spec_mat_f0_a[ ];
19 extern volatile int spec_mat_f0_b[ ];
19 extern volatile int spec_mat_f0_b[ ];
20 extern volatile int spec_mat_f0_c[ ];
20 extern volatile int spec_mat_f0_c[ ];
21 extern volatile int spec_mat_f0_d[ ];
21 extern volatile int spec_mat_f0_d[ ];
22 extern volatile int spec_mat_f0_e[ ];
22 extern volatile int spec_mat_f0_e[ ];
23 extern volatile int spec_mat_f0_f[ ];
23 extern volatile int spec_mat_f0_f[ ];
24 extern volatile int spec_mat_f0_g[ ];
24 extern volatile int spec_mat_f0_g[ ];
25 extern volatile int spec_mat_f0_h[ ];
25 extern volatile int spec_mat_f0_h[ ];
26
26
27 extern volatile int spec_mat_f1[ ];
27 extern volatile int spec_mat_f1[ ];
28 extern volatile int spec_mat_f2[ ];
28 extern volatile int spec_mat_f2[ ];
29
29
30 extern volatile int spec_mat_f1_bis[ ];
30 extern volatile int spec_mat_f1_bis[ ];
31 extern volatile int spec_mat_f2_bis[ ];
31 extern volatile int spec_mat_f2_bis[ ];
32 extern volatile int spec_mat_f0_0_bis[ ];
32 extern volatile int spec_mat_f0_0_bis[ ];
33 extern volatile int spec_mat_f0_1_bis[ ];
33 extern volatile int spec_mat_f0_1_bis[ ];
34
34
35 extern rtems_id Task_id[ ]; /* array of task ids */
36
37 // parameters
35 // parameters
38 extern struct param_local_str param_local;
36 extern struct param_local_str param_local;
39
37
40 // registers
38 // registers
41 extern time_management_regs_t *time_management_regs;
39 extern time_management_regs_t *time_management_regs;
42 extern spectral_matrix_regs_t *spectral_matrix_regs;
40 extern spectral_matrix_regs_t *spectral_matrix_regs;
43
41
44 // ISR
42 // ISR
45 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
43 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
46 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
44 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector );
47
45
48 // RTEMS TASKS
46 // RTEMS TASKS
49 rtems_task spw_bppr_task(rtems_task_argument argument);
47 rtems_task spw_bppr_task(rtems_task_argument argument);
50 rtems_task avf0_task(rtems_task_argument argument);
48 rtems_task avf0_task(rtems_task_argument argument);
51 rtems_task bpf0_task(rtems_task_argument argument);
49 rtems_task bpf0_task(rtems_task_argument argument);
52 rtems_task smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator
50 rtems_task smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator
53 rtems_task matr_task(rtems_task_argument argument);
51 rtems_task matr_task(rtems_task_argument argument);
54
52
55 rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument);
53 rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument);
56
54
57 void matrix_average(volatile int *spec_mat, volatile float *averaged_spec_mat);
55 void matrix_average(volatile int *spec_mat, volatile float *averaged_spec_mat);
58 void matrix_compression(volatile float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat);
56 void matrix_compression(volatile float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat);
59 void matrix_reset(volatile float *averaged_spec_mat);
57 void matrix_reset(volatile float *averaged_spec_mat);
60 void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1);
58 void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1);
61 void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat);
59 void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat);
62 //
60 //
63 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header);
61 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header);
64 void send_spectral_matrix(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
62 void send_spectral_matrix(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
65 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send);
63 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id);
66 void convert_averaged_spectral_matrix(volatile float *input_matrix, char *output_matrix);
64 void convert_averaged_spectral_matrix(volatile float *input_matrix, char *output_matrix);
67 void fill_averaged_spectral_matrix();
65 void fill_averaged_spectral_matrix();
68 void reset_spectral_matrix_regs();
66 void reset_spectral_matrix_regs();
69
67
70 #endif // FSW_RTEMS_PROCESSING_H_INCLUDED
68 #endif // FSW_RTEMS_PROCESSING_H_INCLUDED
@@ -1,87 +1,87
1 #ifndef TC_HANDLER_H_INCLUDED
1 #ifndef TC_HANDLER_H_INCLUDED
2 #define TC_HANDLER_H_INCLUDED
2 #define TC_HANDLER_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <bsp.h> // for the LEON_Unmask_interrupt function
5 #include <bsp.h> // for the LEON_Unmask_interrupt function
6 #include <stdio.h>
6 #include <stdio.h>
7 #include <unistd.h> // for the read call
7 #include <unistd.h> // for the read call
8 #include <sys/ioctl.h> // for the ioctl call
8 #include <sys/ioctl.h> // for the ioctl call
9 #include <ccsds_types.h>
9 #include <ccsds_types.h>
10 #include <grspw.h>
10 #include <grspw.h>
11
11
12 #include "fsw_init.h"
12 #include "fsw_init.h"
13 #include "fsw_misc.h"
13 #include "fsw_misc.h"
14
14
15 // MODE PARAMETERS
15 // MODE PARAMETERS
16 extern struct param_sbm1_str param_sbm1;
16 extern struct param_sbm1_str param_sbm1;
17 extern struct param_sbm2_str param_sbm2;
17 extern struct param_sbm2_str param_sbm2;
18 extern time_management_regs_t *time_management_regs;
18 extern time_management_regs_t *time_management_regs;
19 extern waveform_picker_regs_t *waveform_picker_regs;
19 extern waveform_picker_regs_t *waveform_picker_regs;
20 extern gptimer_regs_t *gptimer_regs;
20 extern gptimer_regs_t *gptimer_regs;
21
21
22 //****
22 //****
23 // ISR
23 // ISR
24 rtems_isr commutation_isr1( rtems_vector_number vector );
24 rtems_isr commutation_isr1( rtems_vector_number vector );
25 rtems_isr commutation_isr2( rtems_vector_number vector );
25 rtems_isr commutation_isr2( rtems_vector_number vector );
26
26
27 //**********************
27 //**********************
28 // GENERAL USE FUNCTIONS
28 // GENERAL USE FUNCTIONS
29 unsigned int Crc_opt( unsigned char D, unsigned int Chk);
29 unsigned int Crc_opt( unsigned char D, unsigned int Chk);
30 void initLookUpTableForCRC( void );
30 void initLookUpTableForCRC( void );
31 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData);
31 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData);
32 void updateLFRCurrentMode();
32 void updateLFRCurrentMode();
33
33
34 //*********************
34 //*********************
35 // ACCEPTANCE FUNCTIONS
35 // ACCEPTANCE FUNCTIONS
36 int TC_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV);
36 int TC_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV, rtems_id queue_id);
37 unsigned char TC_parser(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV);
37 unsigned char TC_parser(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV);
38
38
39 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
39 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
40 TMHeader_t *TMHeader, unsigned char tc_sid);
40 TMHeader_t *TMHeader, unsigned char tc_sid);
41
41
42 //***********
42 //***********
43 // RTEMS TASK
43 // RTEMS TASK
44 rtems_task recv_task( rtems_task_argument unused );
44 rtems_task recv_task( rtems_task_argument unused );
45 rtems_task actn_task( rtems_task_argument unused );
45 rtems_task actn_task( rtems_task_argument unused );
46 rtems_task dumb_task( rtems_task_argument unused );
46 rtems_task dumb_task( rtems_task_argument unused );
47
47
48 //***********
48 //***********
49 // TC ACTIONS
49 // TC ACTIONS
50 int action_reset(ccsdsTelecommandPacket_t *TC);
50 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
51 int action_load_common_par(ccsdsTelecommandPacket_t *TC);
51 int action_load_common_par(ccsdsTelecommandPacket_t *TC);
52 int action_load_normal_par(ccsdsTelecommandPacket_t *TC);
52 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
53 int action_load_burst_par(ccsdsTelecommandPacket_t *TC);
53 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
54 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC);
54 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
55 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC);
55 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
56 int action_dump_par(ccsdsTelecommandPacket_t *TC);
56 int action_dump_par(ccsdsTelecommandPacket_t *TC);
57 int action_enter_mode(ccsdsTelecommandPacket_t *TC);
57 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
58 int action_update_info(ccsdsTelecommandPacket_t *TC);
58 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
59 int action_enable_calibration(ccsdsTelecommandPacket_t *TC);
59 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
60 int action_disable_calibration(ccsdsTelecommandPacket_t *TC);
60 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
61 int action_update_time(ccsdsTelecommandPacket_t *TC);
61 int action_update_time(ccsdsTelecommandPacket_t *TC);
62
62
63 // mode transition
63 // mode transition
64 int transition_validation(unsigned char requestedMode);
64 int transition_validation(unsigned char requestedMode);
65 int stop_current_mode();
65 int stop_current_mode();
66 int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC);
66 int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC);
67 int enter_standby_mode();
67 int enter_standby_mode();
68 int enter_normal_mode();
68 int enter_normal_mode();
69 int enter_burst_mode();
69 int enter_burst_mode();
70 int enter_sbm1_mode();
70 int enter_sbm1_mode();
71 int enter_sbm2_mode();
71 int enter_sbm2_mode();
72 int restart_science_tasks();
72 int restart_science_tasks();
73 int suspend_science_tasks();
73 int suspend_science_tasks();
74
74
75 // other functions
75 // other functions
76 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC);
76 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC);
77 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC);
77 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC);
78 void close_action(ccsdsTelecommandPacket_t *TC, int result);
78 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id);
79 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC);
79 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
80 int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC);
80 int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
81 int send_tm_lfr_tc_exe_not_implemented(ccsdsTelecommandPacket_t *TC);
81 int send_tm_lfr_tc_exe_not_implemented(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
82 int send_tm_lfr_tc_exe_error(ccsdsTelecommandPacket_t *TC);
82 int send_tm_lfr_tc_exe_error(ccsdsTelecommandPacket_t *TC, rtems_id queue_id);
83
83
84 #endif // TC_HANDLER_H_INCLUDED
84 #endif // TC_HANDLER_H_INCLUDED
85
85
86
86
87
87
@@ -1,71 +1,70
1 #ifndef WF_HANDLER_H_INCLUDED
1 #ifndef WF_HANDLER_H_INCLUDED
2 #define WF_HANDLER_H_INCLUDED
2 #define WF_HANDLER_H_INCLUDED
3
3
4 #include <rtems.h>
4 #include <rtems.h>
5 #include <grspw.h>
5 #include <grspw.h>
6
6
7 #include <stdio.h>
7 #include <stdio.h>
8 #include <math.h>
8 #include <math.h>
9
9
10 #include "fsw_params.h"
10 #include "fsw_params.h"
11 #include "grlib_regs.h"
11 #include "grlib_regs.h"
12 #include "ccsds_types.h"
12 #include "ccsds_types.h"
13 #include "fsw_init.h"
13 #include "fsw_init.h"
14
14
15 #define pi 3.1415
15 #define pi 3.1415
16
16
17 //#include <sys/ioctl.h>
17 //#include <sys/ioctl.h>
18
18
19 extern rtems_id Task_id[]; /* array of task ids */
20 extern int fdSPW;
19 extern int fdSPW;
21 extern volatile int wf_snap_f0[ ];
20 extern volatile int wf_snap_f0[ ];
22 //
21 //
23 extern volatile int wf_snap_f1[ ];
22 extern volatile int wf_snap_f1[ ];
24 extern volatile int wf_snap_f1_bis[ ];
23 extern volatile int wf_snap_f1_bis[ ];
25 extern volatile int wf_snap_f1_norm[ ];
24 extern volatile int wf_snap_f1_norm[ ];
26 //
25 //
27 extern volatile int wf_snap_f2[ ];
26 extern volatile int wf_snap_f2[ ];
28 extern volatile int wf_snap_f2_bis[ ];
27 extern volatile int wf_snap_f2_bis[ ];
29 extern volatile int wf_snap_f2_norm[ ];
28 extern volatile int wf_snap_f2_norm[ ];
30 //
29 //
31 extern volatile int wf_cont_f3[ ];
30 extern volatile int wf_cont_f3[ ];
32 extern volatile int wf_cont_f3_bis[ ];
31 extern volatile int wf_cont_f3_bis[ ];
33 extern waveform_picker_regs_t *waveform_picker_regs;
32 extern waveform_picker_regs_t *waveform_picker_regs;
34
33
35 rtems_isr waveforms_isr( rtems_vector_number vector );
34 rtems_isr waveforms_isr( rtems_vector_number vector );
36 rtems_isr waveforms_simulator_isr( rtems_vector_number vector );
35 rtems_isr waveforms_simulator_isr( rtems_vector_number vector );
37 rtems_task wfrm_task(rtems_task_argument argument);
36 rtems_task wfrm_task(rtems_task_argument argument);
38 rtems_task cwf3_task(rtems_task_argument argument);
37 rtems_task cwf3_task(rtems_task_argument argument);
39 rtems_task cwf2_task(rtems_task_argument argument);
38 rtems_task cwf2_task(rtems_task_argument argument);
40 rtems_task cwf1_task(rtems_task_argument argument);
39 rtems_task cwf1_task(rtems_task_argument argument);
41
40
42 //******************
41 //******************
43 // general functions
42 // general functions
44 void init_waveforms( void );
43 void init_waveforms( void );
45 //
44 //
46 int init_header_snapshot_wf_table(unsigned int sid , Header_TM_LFR_SCIENCE_SWF_t *headerSWF);
45 int init_header_snapshot_wf_table(unsigned int sid , Header_TM_LFR_SCIENCE_SWF_t *headerSWF);
47 int init_header_continuous_wf_table(unsigned int sid , Header_TM_LFR_SCIENCE_CWF_t *headerCWF);
46 int init_header_continuous_wf_table(unsigned int sid , Header_TM_LFR_SCIENCE_CWF_t *headerCWF);
48 //
47 //
49 void reset_waveforms( void );
48 void reset_waveforms( void );
50
49
51 int send_waveform_SWF(volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF);
50 int send_waveform_SWF(volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id);
52 int send_waveform_CWF(volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF);
51 int send_waveform_CWF(volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id);
53
52
54 //**************
53 //**************
55 // wfp registers
54 // wfp registers
56 void set_wfp_data_shaping();
55 void set_wfp_data_shaping();
57 char set_wfp_delta_snapshot();
56 char set_wfp_delta_snapshot();
58 void set_wfp_burst_enable_register( unsigned char mode);
57 void set_wfp_burst_enable_register( unsigned char mode);
59 void reset_wfp_burst_enable();
58 void reset_wfp_burst_enable();
60 void reset_wfp_status();
59 void reset_wfp_status();
61 void reset_waveform_picker_regs();
60 void reset_waveform_picker_regs();
62
61
63 //*****************
62 //*****************
64 // local parameters
63 // local parameters
65 void set_local_sbm1_nb_cwf_max();
64 void set_local_sbm1_nb_cwf_max();
66 void set_local_sbm2_nb_cwf_max();
65 void set_local_sbm2_nb_cwf_max();
67 void set_local_nb_interrupt_f0_MAX();
66 void set_local_nb_interrupt_f0_MAX();
68 void reset_local_sbm1_nb_cwf_sent();
67 void reset_local_sbm1_nb_cwf_sent();
69 void reset_local_sbm2_nb_cwf_sent();
68 void reset_local_sbm2_nb_cwf_sent();
70
69
71 #endif // WF_HANDLER_H_INCLUDED
70 #endif // WF_HANDLER_H_INCLUDED
@@ -1,72 +1,72
1 //#include <fsw_processing.h>
1 //#include <fsw_processing.h>
2 #include <rtems.h>
2 #include <rtems.h>
3 #include <grspw.h>
3 #include <grspw.h>
4 #include <ccsds_types.h>
4 #include <ccsds_types.h>
5 #include <grlib_regs.h>
5 #include <grlib_regs.h>
6 #include <fsw_params.h>
6 #include <fsw_params.h>
7
7
8 // RTEMS GLOBAL VARIABLES
8 // RTEMS GLOBAL VARIABLES
9 rtems_name misc_name[5];
9 rtems_name misc_name[5];
10 rtems_name misc_id[5];
10 rtems_id misc_id[5];
11 rtems_id Task_id[20]; /* array of task ids */
11 rtems_name Task_name[20]; /* array of task names */
12 rtems_name Task_name[20]; /* array of task names */
12 rtems_id Task_id[20]; /* array of task ids */
13 unsigned int maxCount;
13 unsigned int maxCount;
14 int fdSPW = 0;
14 int fdSPW = 0;
15 int fdUART = 0;
15 int fdUART = 0;
16 unsigned char lfrCurrentMode;
16 unsigned char lfrCurrentMode;
17
17
18 // APB CONFIGURATION REGISTERS
18 // APB CONFIGURATION REGISTERS
19 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
19 time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT;
20 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
20 gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
21 #ifdef GSA
21 #ifdef GSA
22 #else
22 #else
23 waveform_picker_regs_t *waveform_picker_regs = (waveform_picker_regs_t*) REGS_ADDR_WAVEFORM_PICKER;
23 waveform_picker_regs_t *waveform_picker_regs = (waveform_picker_regs_t*) REGS_ADDR_WAVEFORM_PICKER;
24 #endif
24 #endif
25 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
25 spectral_matrix_regs_t *spectral_matrix_regs = (spectral_matrix_regs_t*) REGS_ADDR_SPECTRAL_MATRIX;
26
26
27 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes
27 // WAVEFORMS GLOBAL VARIABLES // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes
28 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
28 volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
29 //
29 //
30 volatile int wf_snap_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
30 volatile int wf_snap_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
31 volatile int wf_snap_f1_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
31 volatile int wf_snap_f1_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
32 volatile int wf_snap_f1_norm[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
32 volatile int wf_snap_f1_norm[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
33 //
33 //
34 volatile int wf_snap_f2[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
34 volatile int wf_snap_f2[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
35 volatile int wf_snap_f2_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
35 volatile int wf_snap_f2_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
36 volatile int wf_snap_f2_norm[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
36 volatile int wf_snap_f2_norm[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
37 //
37 //
38 volatile int wf_cont_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
38 volatile int wf_cont_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
39 volatile int wf_cont_f3_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
39 volatile int wf_cont_f3_bis[ NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + TIME_OFFSET];
40
40
41 // SPECTRAL MATRICES GLOBAL VARIABLES
41 // SPECTRAL MATRICES GLOBAL VARIABLES
42 volatile int spec_mat_f0_0[ SM_HEADER + TOTAL_SIZE_SM ];
42 volatile int spec_mat_f0_0[ SM_HEADER + TOTAL_SIZE_SM ];
43 volatile int spec_mat_f0_1[ SM_HEADER + TOTAL_SIZE_SM ];
43 volatile int spec_mat_f0_1[ SM_HEADER + TOTAL_SIZE_SM ];
44 volatile int spec_mat_f0_a[ SM_HEADER + TOTAL_SIZE_SM ];
44 volatile int spec_mat_f0_a[ SM_HEADER + TOTAL_SIZE_SM ];
45 volatile int spec_mat_f0_b[ SM_HEADER + TOTAL_SIZE_SM ];
45 volatile int spec_mat_f0_b[ SM_HEADER + TOTAL_SIZE_SM ];
46 volatile int spec_mat_f0_c[ SM_HEADER + TOTAL_SIZE_SM ];
46 volatile int spec_mat_f0_c[ SM_HEADER + TOTAL_SIZE_SM ];
47 volatile int spec_mat_f0_d[ SM_HEADER + TOTAL_SIZE_SM ];
47 volatile int spec_mat_f0_d[ SM_HEADER + TOTAL_SIZE_SM ];
48 volatile int spec_mat_f0_e[ SM_HEADER + TOTAL_SIZE_SM ];
48 volatile int spec_mat_f0_e[ SM_HEADER + TOTAL_SIZE_SM ];
49 volatile int spec_mat_f0_f[ SM_HEADER + TOTAL_SIZE_SM ];
49 volatile int spec_mat_f0_f[ SM_HEADER + TOTAL_SIZE_SM ];
50 volatile int spec_mat_f0_g[ SM_HEADER + TOTAL_SIZE_SM ];
50 volatile int spec_mat_f0_g[ SM_HEADER + TOTAL_SIZE_SM ];
51 volatile int spec_mat_f0_h[ SM_HEADER + TOTAL_SIZE_SM ];
51 volatile int spec_mat_f0_h[ SM_HEADER + TOTAL_SIZE_SM ];
52 volatile int spec_mat_f0_0_bis[ SM_HEADER + TOTAL_SIZE_SM ];
52 volatile int spec_mat_f0_0_bis[ SM_HEADER + TOTAL_SIZE_SM ];
53 volatile int spec_mat_f0_1_bis[ SM_HEADER + TOTAL_SIZE_SM ];
53 volatile int spec_mat_f0_1_bis[ SM_HEADER + TOTAL_SIZE_SM ];
54 //
54 //
55 volatile int spec_mat_f1[ SM_HEADER + TOTAL_SIZE_SM ];
55 volatile int spec_mat_f1[ SM_HEADER + TOTAL_SIZE_SM ];
56 volatile int spec_mat_f1_bis[ SM_HEADER + TOTAL_SIZE_SM ];
56 volatile int spec_mat_f1_bis[ SM_HEADER + TOTAL_SIZE_SM ];
57 //
57 //
58 volatile int spec_mat_f2[ SM_HEADER + TOTAL_SIZE_SM ];
58 volatile int spec_mat_f2[ SM_HEADER + TOTAL_SIZE_SM ];
59 volatile int spec_mat_f2_bis[ SM_HEADER + TOTAL_SIZE_SM ];
59 volatile int spec_mat_f2_bis[ SM_HEADER + TOTAL_SIZE_SM ];
60
60
61 // MODE PARAMETERS
61 // MODE PARAMETERS
62 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
62 Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet;
63 struct param_local_str param_local;
63 struct param_local_str param_local;
64
64
65 // HK PACKETS
65 // HK PACKETS
66 Packet_TM_LFR_HK_t housekeeping_packet;
66 Packet_TM_LFR_HK_t housekeeping_packet;
67 // sequence counters are incremented by APID (PID + CAT) and destination ID
67 // sequence counters are incremented by APID (PID + CAT) and destination ID
68 unsigned short sequenceCounters[SEQ_CNT_NB_PID][SEQ_CNT_NB_CAT][SEQ_CNT_NB_DEST_ID];
68 unsigned short sequenceCounters[SEQ_CNT_NB_PID][SEQ_CNT_NB_CAT][SEQ_CNT_NB_DEST_ID];
69 spw_stats spacewire_stats;
69 spw_stats spacewire_stats;
70 spw_stats spacewire_stats_backup;
70 spw_stats spacewire_stats_backup;
71
71
72
72
@@ -1,451 +1,455
1 //*************************
1 //*************************
2 // GPL reminder to be added
2 // GPL reminder to be added
3 //*************************
3 //*************************
4
4
5 #include <rtems.h>
5 #include <rtems.h>
6
6
7 /* configuration information */
7 /* configuration information */
8
8
9 #define CONFIGURE_INIT
9 #define CONFIGURE_INIT
10
10
11 #include <bsp.h> /* for device driver prototypes */
11 #include <bsp.h> /* for device driver prototypes */
12
12
13 /* configuration information */
13 /* configuration information */
14
14
15 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
15 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
16 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
16 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
17
17
18 #define CONFIGURE_MAXIMUM_TASKS 20
18 #define CONFIGURE_MAXIMUM_TASKS 20
19 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
19 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
20 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
20 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
21 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
21 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
22 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
22 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
23 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
23 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
24 #define CONFIGURE_MAXIMUM_DRIVERS 16
24 #define CONFIGURE_MAXIMUM_DRIVERS 16
25 #define CONFIGURE_MAXIMUM_PERIODS 5
25 #define CONFIGURE_MAXIMUM_PERIODS 5
26 #define CONFIGURE_MAXIMUM_TIMERS 5
26 #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s)
27 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2
27 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 2
28 #ifdef PRINT_STACK_REPORT
28 #ifdef PRINT_STACK_REPORT
29 #define CONFIGURE_STACK_CHECKER_ENABLED
29 #define CONFIGURE_STACK_CHECKER_ENABLED
30 #endif
30 #endif
31
31
32 #include <rtems/confdefs.h>
32 #include <rtems/confdefs.h>
33
33
34 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
34 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
35 #ifdef RTEMS_DRVMGR_STARTUP
35 #ifdef RTEMS_DRVMGR_STARTUP
36 #ifdef LEON3
36 #ifdef LEON3
37 /* Add Timer and UART Driver */
37 /* Add Timer and UART Driver */
38 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
38 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
39 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
39 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
40 #endif
40 #endif
41 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
41 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
42 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
42 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
43 #endif
43 #endif
44 #endif
44 #endif
45 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
45 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
46 #include <drvmgr/drvmgr_confdefs.h>
46 #include <drvmgr/drvmgr_confdefs.h>
47 #endif
47 #endif
48
48
49 #include <fsw_init.h>
49 #include <fsw_init.h>
50 #include <fsw_config.c>
50 #include <fsw_config.c>
51
51
52 rtems_task Init( rtems_task_argument ignored )
52 rtems_task Init( rtems_task_argument ignored )
53 {
53 {
54 rtems_status_code status;
54 rtems_status_code status;
55 rtems_isr_entry old_isr_handler;
55 rtems_isr_entry old_isr_handler;
56
56
57 PRINTF("\n\n\n\n\n")
57 BOOT_PRINTF("\n\n\n\n\n")
58 PRINTF("***************************\n")
58 BOOT_PRINTF("***************************\n")
59 PRINTF("** START Flight Software **\n")
59 BOOT_PRINTF("** START Flight Software **\n")
60 PRINTF("***************************\n")
60 BOOT_PRINTF("***************************\n")
61 PRINTF("\n\n")
61 BOOT_PRINTF("\n\n")
62
62
63 //send_console_outputs_on_apbuart_port();
63 //send_console_outputs_on_apbuart_port();
64 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
64 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
65
65
66 initLookUpTableForCRC(); // in tc_handler.h
66 initLookUpTableForCRC(); // in tc_handler.h
67 init_parameter_dump();
67 init_parameter_dump();
68 init_local_mode_parameters();
68 init_local_mode_parameters();
69 init_housekeeping_parameters();
69 init_housekeeping_parameters();
70
70
71 create_names(); // create all names
71 create_names(); // create all names
72
72
73 create_message_queues();
73 create_message_queues();
74
74
75 create_all_tasks(); // create all tasks
75 create_all_tasks(); // create all tasks
76
76
77 start_all_tasks(); // start all tasks
77 start_all_tasks(); // start all tasks
78
78
79 stop_current_mode(); // go in STANDBY mode
79 stop_current_mode(); // go in STANDBY mode
80
80
81 grspw_timecode_callback = &timecode_irq_handler;
81 grspw_timecode_callback = &timecode_irq_handler;
82
82
83 spacewire_configure_link();
83 spacewire_configure_link();
84
84
85 #ifdef GSA
85 #ifdef GSA
86 // mask IRQ lines
86 // mask IRQ lines
87 LEON_Mask_interrupt( IRQ_SM );
87 LEON_Mask_interrupt( IRQ_SM );
88 LEON_Mask_interrupt( IRQ_WF );
88 LEON_Mask_interrupt( IRQ_WF );
89 // Spectral Matrices simulator
89 // Spectral Matrices simulator
90 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
90 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
91 IRQ_SPARC_SM, spectral_matrices_isr );
91 IRQ_SPARC_SM, spectral_matrices_isr );
92 // WaveForms
92 // WaveForms
93 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
93 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
94 IRQ_SPARC_WF, waveforms_simulator_isr );
94 IRQ_SPARC_WF, waveforms_simulator_isr );
95 #else
95 #else
96 // mask IRQ lines
96 // mask IRQ lines
97 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER );
97 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER );
98 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX );
98 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX );
99 // reset configuration registers
99 // reset configuration registers
100 reset_waveform_picker_regs();
100 reset_waveform_picker_regs();
101 reset_spectral_matrix_regs();
101 reset_spectral_matrix_regs();
102 // configure IRQ handling for the waveform picker unit
102 // configure IRQ handling for the waveform picker unit
103 status = rtems_interrupt_catch( waveforms_isr,
103 status = rtems_interrupt_catch( waveforms_isr,
104 IRQ_SPARC_WAVEFORM_PICKER,
104 IRQ_SPARC_WAVEFORM_PICKER,
105 &old_isr_handler) ;
105 &old_isr_handler) ;
106 // configure IRQ handling for the spectral matrix unit
106 // configure IRQ handling for the spectral matrix unit
107 // status = rtems_interrupt_catch( spectral_matrices_isr,
107 // status = rtems_interrupt_catch( spectral_matrices_isr,
108 // IRQ_SPARC_SPECTRAL_MATRIX,
108 // IRQ_SPARC_SPECTRAL_MATRIX,
109 // &old_isr_handler) ;
109 // &old_isr_handler) ;
110 // Spectral Matrices simulator
110 // Spectral Matrices simulator
111 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
111 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
112 IRQ_SPARC_SM, spectral_matrices_isr_simu );
112 IRQ_SPARC_SM, spectral_matrices_isr_simu );
113 #endif
113 #endif
114
114
115 PRINTF("delete INIT\n")
115 BOOT_PRINTF("delete INIT\n")
116
116
117 status = rtems_task_delete(RTEMS_SELF);
117 status = rtems_task_delete(RTEMS_SELF);
118
118
119 }
119 }
120
120
121 void init_parameter_dump( void )
121 void init_parameter_dump( void )
122 {
122 {
123 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
123 parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
124 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
124 parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
125 parameter_dump_packet.reserved = CCSDS_RESERVED;
125 parameter_dump_packet.reserved = CCSDS_RESERVED;
126 parameter_dump_packet.userApplication = CCSDS_USER_APP;
126 parameter_dump_packet.userApplication = CCSDS_USER_APP;
127 parameter_dump_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_PARAMETER_DUMP >> 8);
127 parameter_dump_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_PARAMETER_DUMP >> 8);
128 parameter_dump_packet.packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP;
128 parameter_dump_packet.packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP;
129 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
129 parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
130 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
130 parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
131 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
131 parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8);
132 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
132 parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP;
133 // DATA FIELD HEADER
133 // DATA FIELD HEADER
134 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
134 parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2;
135 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
135 parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP;
136 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
136 parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP;
137 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
137 parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND;
138 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
138 parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
139 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
139 parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
140 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
140 parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
141 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
141 parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
142 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
142 parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
143 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
143 parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
144 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
144 parameter_dump_packet.sid = SID_PARAMETER_DUMP;
145
145
146 //******************
146 //******************
147 // COMMON PARAMETERS
147 // COMMON PARAMETERS
148 parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0;
148 parameter_dump_packet.unused0 = DEFAULT_SY_LFR_COMMON0;
149 parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1;
149 parameter_dump_packet.bw_sp0_sp1_r0_r1 = DEFAULT_SY_LFR_COMMON1;
150
150
151 //******************
151 //******************
152 // NORMAL PARAMETERS
152 // NORMAL PARAMETERS
153 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_L >> 8);
153 parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_L >> 8);
154 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_L );
154 parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_L );
155 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_P >> 8);
155 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_P >> 8);
156 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_P );
156 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DEFAULT_SY_LFR_N_SWF_P );
157 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DEFAULT_SY_LFR_N_ASM_P >> 8);
157 parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DEFAULT_SY_LFR_N_ASM_P >> 8);
158 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DEFAULT_SY_LFR_N_ASM_P );
158 parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DEFAULT_SY_LFR_N_ASM_P );
159 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DEFAULT_SY_LFR_N_BP_P0;
159 parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DEFAULT_SY_LFR_N_BP_P0;
160 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DEFAULT_SY_LFR_N_BP_P1;
160 parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DEFAULT_SY_LFR_N_BP_P1;
161
161
162 //*****************
162 //*****************
163 // BURST PARAMETERS
163 // BURST PARAMETERS
164 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
164 parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0;
165 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
165 parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1;
166
166
167 //****************
167 //****************
168 // SBM1 PARAMETERS
168 // SBM1 PARAMETERS
169 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
169 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
170 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
170 parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1;
171
171
172 //****************
172 //****************
173 // SBM2 PARAMETERS
173 // SBM2 PARAMETERS
174 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
174 parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0;
175 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
175 parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1;
176 }
176 }
177
177
178 void init_local_mode_parameters( void )
178 void init_local_mode_parameters( void )
179 {
179 {
180 // LOCAL PARAMETERS
180 // LOCAL PARAMETERS
181 set_local_sbm1_nb_cwf_max();
181 set_local_sbm1_nb_cwf_max();
182 set_local_sbm2_nb_cwf_max();
182 set_local_sbm2_nb_cwf_max();
183 set_local_nb_interrupt_f0_MAX();
183 set_local_nb_interrupt_f0_MAX();
184
184
185 PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
185 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
186 PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
186 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
187 PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
187 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
188
188
189 reset_local_sbm1_nb_cwf_sent();
189 reset_local_sbm1_nb_cwf_sent();
190 reset_local_sbm2_nb_cwf_sent();
190 reset_local_sbm2_nb_cwf_sent();
191 }
191 }
192
192
193 void init_housekeeping_parameters( void )
193 void init_housekeeping_parameters( void )
194 {
194 {
195 unsigned int i = 0;
195 unsigned int i = 0;
196 unsigned int j = 0;
196 unsigned int j = 0;
197 unsigned int k = 0;
197 unsigned int k = 0;
198 char *parameters;
198 char *parameters;
199
199
200 parameters = (char*) &housekeeping_packet.lfr_status_word;
200 parameters = (char*) &housekeeping_packet.lfr_status_word;
201 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
201 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
202 {
202 {
203 parameters[i] = 0x00;
203 parameters[i] = 0x00;
204 }
204 }
205 // init status word
205 // init status word
206 housekeeping_packet.lfr_status_word[0] = 0x00;
206 housekeeping_packet.lfr_status_word[0] = 0x00;
207 housekeeping_packet.lfr_status_word[1] = 0x00;
207 housekeeping_packet.lfr_status_word[1] = 0x00;
208 // init software version
208 // init software version
209 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
209 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
210 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
210 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
211 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
211 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
212 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
212 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
213 // init sequence counters
213 // init sequence counters
214 for (i = 0; i<SEQ_CNT_NB_PID; i++)
214 for (i = 0; i<SEQ_CNT_NB_PID; i++)
215 {
215 {
216 for(j = 0; j<SEQ_CNT_NB_CAT; j++)
216 for(j = 0; j<SEQ_CNT_NB_CAT; j++)
217 {
217 {
218 for(k = 0; k<SEQ_CNT_NB_DEST_ID; k++)
218 for(k = 0; k<SEQ_CNT_NB_DEST_ID; k++)
219 {
219 {
220 sequenceCounters[i][j][k] = 0x00;
220 sequenceCounters[i][j][k] = 0x00;
221 }
221 }
222 }
222 }
223 }
223 }
224 updateLFRCurrentMode();
224 updateLFRCurrentMode();
225 }
225 }
226
226
227 int create_names( void )
227 int create_names( void )
228 {
228 {
229 // task names
229 // task names
230 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
230 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
231 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
231 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
232 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
232 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
233 Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' );
233 Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' );
234 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
234 Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' );
235 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
235 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
236 Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' );
236 Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' );
237 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
237 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
238 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
238 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
239 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
239 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
240 Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' );
240 Task_name[TASKID_MATR] = rtems_build_name( 'M', 'A', 'T', 'R' );
241 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
241 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
242 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
242 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
243 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
243 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
244 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
244 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
245
245
246 // rate monotonic period name
246 // rate monotonic period name
247 HK_name = rtems_build_name( 'H', 'O', 'U', 'S' );
247 HK_name = rtems_build_name( 'H', 'O', 'U', 'S' );
248
248
249 misc_name[QUEUE_QUEU] = rtems_build_name( 'Q', 'U', 'E', 'U' );
249 misc_name[QUEUE_QUEU] = rtems_build_name( 'Q', 'U', 'E', 'U' );
250 misc_name[QUEUE_PKTS] = rtems_build_name( 'P', 'K', 'T', 'S' );
250 misc_name[QUEUE_PKTS] = rtems_build_name( 'P', 'K', 'T', 'S' );
251
251
252 return 0;
252 return 0;
253 }
253 }
254
254
255 int create_all_tasks( void )
255 int create_all_tasks( void )
256 {
256 {
257 rtems_status_code status;
257 rtems_status_code status;
258
258
259 // RECV
259 // RECV
260 status = rtems_task_create(
260 status = rtems_task_create(
261 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
261 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
262 RTEMS_DEFAULT_MODES,
262 RTEMS_DEFAULT_MODES,
263 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
263 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
264 );
264 );
265 // ACTN
265 // ACTN
266 status = rtems_task_create(
266 status = rtems_task_create(
267 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
267 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
268 RTEMS_DEFAULT_MODES,
268 RTEMS_DEFAULT_MODES,
269 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
269 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
270 );
270 );
271 // SPIQ
271 // SPIQ
272 status = rtems_task_create(
272 status = rtems_task_create(
273 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
273 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
274 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
274 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
275 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
275 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
276 );
276 );
277 // SMIQ
277 // SMIQ
278 status = rtems_task_create(
278 status = rtems_task_create(
279 Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE,
279 Task_name[TASKID_SMIQ], TASK_PRIORITY_SMIQ, RTEMS_MINIMUM_STACK_SIZE,
280 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
280 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
281 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
281 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SMIQ]
282 );
282 );
283 // STAT
283 // STAT
284 status = rtems_task_create(
284 status = rtems_task_create(
285 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
285 Task_name[TASKID_STAT], TASK_PRIORITY_STAT, RTEMS_MINIMUM_STACK_SIZE,
286 RTEMS_DEFAULT_MODES,
286 RTEMS_DEFAULT_MODES,
287 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
287 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_STAT]
288 );
288 );
289 // AVF0
289 // AVF0
290 status = rtems_task_create(
290 status = rtems_task_create(
291 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
291 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
292 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
292 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
293 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
293 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
294 );
294 );
295 // BPF0
295 // BPF0
296 status = rtems_task_create(
296 status = rtems_task_create(
297 Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE,
297 Task_name[TASKID_BPF0], TASK_PRIORITY_BPF0, RTEMS_MINIMUM_STACK_SIZE,
298 RTEMS_DEFAULT_MODES,
298 RTEMS_DEFAULT_MODES,
299 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0]
299 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0]
300 );
300 );
301 // WFRM
301 // WFRM
302 status = rtems_task_create(
302 status = rtems_task_create(
303 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
303 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
304 RTEMS_DEFAULT_MODES,
304 RTEMS_DEFAULT_MODES,
305 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
305 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
306 );
306 );
307 // DUMB
307 // DUMB
308 status = rtems_task_create(
308 status = rtems_task_create(
309 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
309 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
310 RTEMS_DEFAULT_MODES,
310 RTEMS_DEFAULT_MODES,
311 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
311 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
312 );
312 );
313 // HOUS
313 // HOUS
314 status = rtems_task_create(
314 status = rtems_task_create(
315 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
315 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
316 RTEMS_DEFAULT_MODES,
316 RTEMS_DEFAULT_MODES,
317 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
317 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
318 );
318 );
319 // MATR
319 // MATR
320 status = rtems_task_create(
320 status = rtems_task_create(
321 Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE,
321 Task_name[TASKID_MATR], TASK_PRIORITY_MATR, RTEMS_MINIMUM_STACK_SIZE,
322 RTEMS_DEFAULT_MODES,
322 RTEMS_DEFAULT_MODES,
323 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR]
323 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_MATR]
324 );
324 );
325 // CWF3
325 // CWF3
326 status = rtems_task_create(
326 status = rtems_task_create(
327 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
327 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
328 RTEMS_DEFAULT_MODES,
328 RTEMS_DEFAULT_MODES,
329 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF3]
329 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF3]
330 );
330 );
331 // CWF2
331 // CWF2
332 status = rtems_task_create(
332 status = rtems_task_create(
333 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
333 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
334 RTEMS_DEFAULT_MODES,
334 RTEMS_DEFAULT_MODES,
335 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF2]
335 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF2]
336 );
336 );
337 // CWF1
337 // CWF1
338 status = rtems_task_create(
338 status = rtems_task_create(
339 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
339 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
340 RTEMS_DEFAULT_MODES,
340 RTEMS_DEFAULT_MODES,
341 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF1]
341 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_CWF1]
342 );
342 );
343 // SEND
343 // SEND
344 status = rtems_task_create(
344 status = rtems_task_create(
345 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
345 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE,
346 RTEMS_DEFAULT_MODES,
346 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
347 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
347 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SEND]
348 );
348 );
349
349
350 return 0;
350 return 0;
351 }
351 }
352
352
353 int start_all_tasks( void )
353 int start_all_tasks( void )
354 {
354 {
355 rtems_status_code status;
355 rtems_status_code status;
356
356
357 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
357 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
358 if (status!=RTEMS_SUCCESSFUL) {
358 if (status!=RTEMS_SUCCESSFUL) {
359 PRINTF("in INIT *** Error starting TASK_SPIQ\n")
359 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
360 }
361
362 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
363 if (status!=RTEMS_SUCCESSFUL) {
364 PRINTF("in INIT *** Error starting TASK_RECV\n")
365 }
366
367 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
368 if (status!=RTEMS_SUCCESSFUL) {
369 PRINTF("in INIT *** Error starting TASK_ACTN\n")
370 }
360 }
371
361
372 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
362 status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 );
373 if (status!=RTEMS_SUCCESSFUL) {
363 if (status!=RTEMS_SUCCESSFUL) {
374 PRINTF("in INIT *** Error starting TASK_BPPR\n")
364 BOOT_PRINTF("in INIT *** Error starting TASK_BPPR\n")
365 }
366
367 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
368 if (status!=RTEMS_SUCCESSFUL) {
369 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
370 }
371
372 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
373 if (status!=RTEMS_SUCCESSFUL) {
374 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
375 }
376
377 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
378 if (status!=RTEMS_SUCCESSFUL) {
379 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
375 }
380 }
376
381
377 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
382 status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 );
378 if (status!=RTEMS_SUCCESSFUL) {
383 if (status!=RTEMS_SUCCESSFUL) {
379 PRINTF("in INIT *** Error starting TASK_STAT\n")
384 BOOT_PRINTF("in INIT *** Error starting TASK_STAT\n")
380 }
385 }
381
386
382 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
387 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 );
383 if (status!=RTEMS_SUCCESSFUL) {
388 if (status!=RTEMS_SUCCESSFUL) {
384 PRINTF("in INIT *** Error starting TASK_AVF0\n")
389 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
385 }
390 }
386
391
387 status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 );
392 status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 );
388 if (status!=RTEMS_SUCCESSFUL) {
393 if (status!=RTEMS_SUCCESSFUL) {
389 PRINTF("in INIT *** Error starting TASK_BPF0\n")
394 BOOT_PRINTF("in INIT *** Error starting TASK_BPF0\n")
390 }
395 }
391
396
392 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
397 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
393 if (status!=RTEMS_SUCCESSFUL) {
398 if (status!=RTEMS_SUCCESSFUL) {
394 PRINTF("in INIT *** Error starting TASK_WFRM\n")
399 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
395 }
400 }
396
401
397 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
402 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
398 if (status!=RTEMS_SUCCESSFUL) {
403 if (status!=RTEMS_SUCCESSFUL) {
399 PRINTF("in INIT *** Error starting TASK_DUMB\n")
404 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
400 }
405 }
401
406
402 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
407 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
403 if (status!=RTEMS_SUCCESSFUL) {
408 if (status!=RTEMS_SUCCESSFUL) {
404 PRINTF("in INIT *** Error starting TASK_HOUS\n")
409 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
405 }
410 }
406
411
407 status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 );
412 status = rtems_task_start( Task_id[TASKID_MATR], matr_task, 1 );
408 if (status!=RTEMS_SUCCESSFUL) {
413 if (status!=RTEMS_SUCCESSFUL) {
409 PRINTF("in INIT *** Error starting TASK_MATR\n")
414 BOOT_PRINTF("in INIT *** Error starting TASK_MATR\n")
410 }
415 }
411
416
412 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
417 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
413 if (status!=RTEMS_SUCCESSFUL) {
418 if (status!=RTEMS_SUCCESSFUL) {
414 PRINTF("in INIT *** Error starting TASK_CWF3\n")
419 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
415 }
420 }
416
421
417 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
422 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
418 if (status!=RTEMS_SUCCESSFUL) {
423 if (status!=RTEMS_SUCCESSFUL) {
419 PRINTF("in INIT *** Error starting TASK_CWF2\n")
424 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
420 }
425 }
421
426
422 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
427 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
423 if (status!=RTEMS_SUCCESSFUL) {
428 if (status!=RTEMS_SUCCESSFUL) {
424 PRINTF("in INIT *** Error starting TASK_CWF1\n")
429 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
425 }
426 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
427 if (status!=RTEMS_SUCCESSFUL) {
428 PRINTF("in INIT *** Error starting TASK_SEND\n")
429 }
430 }
430
431
431 return 0;
432 return 0;
432 }
433 }
433
434
434 int create_message_queues( void )
435 rtems_status_code create_message_queues( void )
435 {
436 {
436 rtems_status_code status;
437 rtems_status_code status;
438 rtems_status_code ret;
439 rtems_id queue_id;
440
441 ret = rtems_message_queue_create( misc_name[QUEUE_PKTS], ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_SIZE,
442 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
443 if (ret != RTEMS_SUCCESSFUL) {
444 BOOT_PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", ret)
445 }
437
446
438 status = rtems_message_queue_create( misc_name[QUEUE_QUEU], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
447 status = rtems_message_queue_create( misc_name[QUEUE_QUEU], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
439 RTEMS_FIFO | RTEMS_LOCAL, &misc_id[QUEUE_QUEU] );
448 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
440 if (status!=RTEMS_SUCCESSFUL) {
449 if (status != RTEMS_SUCCESSFUL) {
441 PRINTF("in create_message_queues *** ERR creating QUEU\n")
450 ret = status;
451 BOOT_PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", ret)
442 }
452 }
443
453
444 status = rtems_message_queue_create( misc_name[QUEUE_PKTS], ACTION_MSG_PKTS_COUNT, ACTION_MSG_PKTS_SIZE,
454 return ret;
445 RTEMS_FIFO | RTEMS_LOCAL, &misc_id[QUEUE_PKTS] );
446 if (status!=RTEMS_SUCCESSFUL) {
447 PRINTF("in create_message_queues *** ERR creating PKTS\n")
448 }
449
450 return 0;
451 }
455 }
@@ -1,276 +1,313
1 #include <fsw_misc.h>
1 #include <fsw_misc.h>
2 #include <fsw_params.h>
2 #include <fsw_params.h>
3
3
4 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
4 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
5 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
5 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
6 { // configure the timer for the waveforms simulation
6 { // configure the timer for the waveforms simulation
7 rtems_status_code status;
7 rtems_status_code status;
8 rtems_isr_entry old_isr_handler;
8 rtems_isr_entry old_isr_handler;
9
9
10 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
10 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
11 if (status==RTEMS_SUCCESSFUL)
11 if (status!=RTEMS_SUCCESSFUL)
12 {
12 {
13 PRINTF("In configure_timer *** rtems_interrupt_catch successfullly configured\n")
13 PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n")
14 }
14 }
15
15
16 timer_set_clock_divider( gptimer_regs, timer, clock_divider);
16 timer_set_clock_divider( gptimer_regs, timer, clock_divider);
17
17
18 return 1;
18 return 1;
19 }
19 }
20
20
21 int timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer)
21 int timer_start(gptimer_regs_t *gptimer_regs, unsigned char timer)
22 {
22 {
23 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
23 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
24 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
24 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
25 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
25 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
26 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
26 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
27 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
27 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
28
28
29 return 1;
29 return 1;
30 }
30 }
31
31
32 int timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer)
32 int timer_stop(gptimer_regs_t *gptimer_regs, unsigned char timer)
33 {
33 {
34 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer
34 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer
35 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable
35 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable
36 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
36 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
37
37
38 return 1;
38 return 1;
39 }
39 }
40
40
41 int timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider)
41 int timer_set_clock_divider(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider)
42 {
42 {
43 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
43 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
44
44
45 return 1;
45 return 1;
46 }
46 }
47
47
48 void update_spacewire_statistics()
48 void update_spacewire_statistics()
49 {
49 {
50 rtems_status_code status;
50 rtems_status_code status;
51 spw_stats spacewire_stats_grspw;
51 spw_stats spacewire_stats_grspw;
52
52
53 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
53 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
54
54
55 spacewire_stats.packets_received = spacewire_stats_backup.packets_received
55 spacewire_stats.packets_received = spacewire_stats_backup.packets_received
56 + spacewire_stats_grspw.packets_received;
56 + spacewire_stats_grspw.packets_received;
57 spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent
57 spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent
58 + spacewire_stats_grspw.packets_sent;
58 + spacewire_stats_grspw.packets_sent;
59 spacewire_stats.parity_err = spacewire_stats_backup.parity_err
59 spacewire_stats.parity_err = spacewire_stats_backup.parity_err
60 + spacewire_stats_grspw.parity_err;
60 + spacewire_stats_grspw.parity_err;
61 spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err
61 spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err
62 + spacewire_stats_grspw.disconnect_err;
62 + spacewire_stats_grspw.disconnect_err;
63 spacewire_stats.escape_err = spacewire_stats_backup.escape_err
63 spacewire_stats.escape_err = spacewire_stats_backup.escape_err
64 + spacewire_stats_grspw.escape_err;
64 + spacewire_stats_grspw.escape_err;
65 spacewire_stats.credit_err = spacewire_stats_backup.credit_err
65 spacewire_stats.credit_err = spacewire_stats_backup.credit_err
66 + spacewire_stats_grspw.credit_err;
66 + spacewire_stats_grspw.credit_err;
67 spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err
67 spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err
68 + spacewire_stats_grspw.write_sync_err;
68 + spacewire_stats_grspw.write_sync_err;
69 spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err
69 spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err
70 + spacewire_stats_grspw.rx_rmap_header_crc_err;
70 + spacewire_stats_grspw.rx_rmap_header_crc_err;
71 spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err
71 spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err
72 + spacewire_stats_grspw.rx_rmap_data_crc_err;
72 + spacewire_stats_grspw.rx_rmap_data_crc_err;
73 spacewire_stats.early_ep = spacewire_stats_backup.early_ep
73 spacewire_stats.early_ep = spacewire_stats_backup.early_ep
74 + spacewire_stats_grspw.early_ep;
74 + spacewire_stats_grspw.early_ep;
75 spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address
75 spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address
76 + spacewire_stats_grspw.invalid_address;
76 + spacewire_stats_grspw.invalid_address;
77 spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err
77 spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err
78 + spacewire_stats_grspw.rx_eep_err;
78 + spacewire_stats_grspw.rx_eep_err;
79 spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated
79 spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated
80 + spacewire_stats_grspw.rx_truncated;
80 + spacewire_stats_grspw.rx_truncated;
81 //spacewire_stats.tx_link_err;
81 //spacewire_stats.tx_link_err;
82
82
83 //****************************
83 //****************************
84 // DPU_SPACEWIRE_IF_STATISTICS
84 // DPU_SPACEWIRE_IF_STATISTICS
85 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8);
85 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8);
86 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received);
86 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received);
87 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8);
87 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8);
88 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent);
88 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent);
89 //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt;
89 //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt;
90 //housekeeping_packet.hk_lfr_dpu_spw_last_timc;
90 //housekeeping_packet.hk_lfr_dpu_spw_last_timc;
91
91
92 //******************************************
92 //******************************************
93 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
93 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
94 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err;
94 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err;
95 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err;
95 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err;
96 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err;
96 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err;
97 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err;
97 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err;
98 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err;
98 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err;
99 // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb;
99 // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb;
100 // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb;
100 // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb;
101 housekeeping_packet.hk_lfr_dpu_spw_header_crc = (unsigned char) spacewire_stats.rx_rmap_header_crc_err;
101 housekeeping_packet.hk_lfr_dpu_spw_header_crc = (unsigned char) spacewire_stats.rx_rmap_header_crc_err;
102 housekeeping_packet.hk_lfr_dpu_spw_data_crc = (unsigned char) spacewire_stats.rx_rmap_data_crc_err;
102 housekeeping_packet.hk_lfr_dpu_spw_data_crc = (unsigned char) spacewire_stats.rx_rmap_data_crc_err;
103
103
104 //*********************************************
104 //*********************************************
105 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
105 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
106 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
106 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
107 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
107 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
108 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
108 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
109 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
109 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
110
110
111 }
111 }
112
112
113 int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port
113 int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port
114 {
114 {
115 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
115 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
116
116
117 apbuart_regs->ctrl = apbuart_regs->ctrl & APBUART_CTRL_REG_MASK_DB;
117 apbuart_regs->ctrl = apbuart_regs->ctrl & APBUART_CTRL_REG_MASK_DB;
118 PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
118 PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
119
119
120 return 0;
120 return 0;
121 }
121 }
122
122
123 int set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
123 int set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
124 {
124 {
125 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
125 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
126
126
127 apbuart_regs->scaler = value;
127 apbuart_regs->scaler = value;
128 PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
128 BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value)
129
129
130 return 0;
130 return 0;
131 }
131 }
132
132
133 //************
133 //************
134 // RTEMS TASKS
134 // RTEMS TASKS
135
135
136 rtems_task stat_task(rtems_task_argument argument)
136 rtems_task stat_task(rtems_task_argument argument)
137 {
137 {
138 int i;
138 int i;
139 int j;
139 int j;
140 i = 0;
140 i = 0;
141 j = 0;
141 j = 0;
142 PRINTF("in STAT *** \n")
142 BOOT_PRINTF("in STAT *** \n")
143 while(1){
143 while(1){
144 rtems_task_wake_after(1000);
144 rtems_task_wake_after(1000);
145 PRINTF1("%d\n", j)
145 PRINTF1("%d\n", j)
146 if (i == CPU_USAGE_REPORT_PERIOD) {
146 if (i == CPU_USAGE_REPORT_PERIOD) {
147 // #ifdef PRINT_TASK_STATISTICS
147 // #ifdef PRINT_TASK_STATISTICS
148 // rtems_cpu_usage_report();
148 // rtems_cpu_usage_report();
149 // rtems_cpu_usage_reset();
149 // rtems_cpu_usage_reset();
150 // #endif
150 // #endif
151 i = 0;
151 i = 0;
152 }
152 }
153 else i++;
153 else i++;
154 j++;
154 j++;
155 }
155 }
156 }
156 }
157
157
158 rtems_task hous_task(rtems_task_argument argument)
158 rtems_task hous_task(rtems_task_argument argument)
159 {
159 {
160 rtems_status_code status;
160 rtems_status_code status;
161 spw_ioctl_pkt_send spw_ioctl_send;
161 spw_ioctl_pkt_send spw_ioctl_send;
162 rtems_id queue_id;
162
163
163 spw_ioctl_send.hlen = 0;
164 spw_ioctl_send.hlen = 0;
164 spw_ioctl_send.hdr = NULL;
165 spw_ioctl_send.hdr = NULL;
165 spw_ioctl_send.dlen = PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
166 spw_ioctl_send.dlen = PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES;
166 spw_ioctl_send.data = (char*) &housekeeping_packet;
167 spw_ioctl_send.data = (char*) &housekeeping_packet;
167 spw_ioctl_send.options = 0;
168 spw_ioctl_send.options = 0;
168
169
169 PRINTF("in HOUS ***\n")
170 status = rtems_message_queue_ident( misc_name[QUEUE_PKTS], 0, &queue_id );
171 if (status != RTEMS_SUCCESSFUL)
172 {
173 PRINTF1("in HOUS *** ERR %d\n", status)
174 }
175
176 BOOT_PRINTF("in HOUS ***\n")
170
177
171 if (rtems_rate_monotonic_ident( HK_name, &HK_id) != RTEMS_SUCCESSFUL) {
178 if (rtems_rate_monotonic_ident( HK_name, &HK_id) != RTEMS_SUCCESSFUL) {
172 status = rtems_rate_monotonic_create( HK_name, &HK_id );
179 status = rtems_rate_monotonic_create( HK_name, &HK_id );
173 if( status != RTEMS_SUCCESSFUL ) {
180 if( status != RTEMS_SUCCESSFUL ) {
174 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
181 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
175 }
182 }
176 }
183 }
177
184
178 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
185 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
179 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
186 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
180 housekeeping_packet.reserved = DEFAULT_RESERVED;
187 housekeeping_packet.reserved = DEFAULT_RESERVED;
181 housekeeping_packet.userApplication = CCSDS_USER_APP;
188 housekeeping_packet.userApplication = CCSDS_USER_APP;
182 housekeeping_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_HK >> 8);
189 housekeeping_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_HK >> 8);
183 housekeeping_packet.packetID[1] = (unsigned char) (TM_PACKET_ID_HK);
190 housekeeping_packet.packetID[1] = (unsigned char) (TM_PACKET_ID_HK);
184 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
191 housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
185 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
192 housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
186 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
193 housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8);
187 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
194 housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK );
188 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
195 housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
189 housekeeping_packet.serviceType = TM_TYPE_HK;
196 housekeeping_packet.serviceType = TM_TYPE_HK;
190 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
197 housekeeping_packet.serviceSubType = TM_SUBTYPE_HK;
191 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
198 housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND;
192
199
193 status = rtems_rate_monotonic_cancel(HK_id);
200 status = rtems_rate_monotonic_cancel(HK_id);
194 if( status != RTEMS_SUCCESSFUL ) {
201 if( status != RTEMS_SUCCESSFUL ) {
195 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
202 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
196 }
203 }
197 else {
204 else {
198 PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
205 DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
199 }
206 }
200
207
201 while(1){ // launch the rate monotonic task
208 while(1){ // launch the rate monotonic task
202 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
209 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
203 if ( status != RTEMS_SUCCESSFUL ) {
210 if ( status != RTEMS_SUCCESSFUL ) {
204 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_period *** code %d\n", status);
211 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_period *** code %d\n", status);
205 }
212 }
206 else {
213 else {
207 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
214 housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
208 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
215 housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
209 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
216 housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
210 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
217 housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time);
211 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
218 housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8);
212 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
219 housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time);
213 housekeeping_packet.sid = SID_HK;
220 housekeeping_packet.sid = SID_HK;
214
221
215 update_spacewire_statistics();
222 update_spacewire_statistics();
216
223
217 // SEND PACKET
224 // SEND PACKET
218 status = rtems_message_queue_send( misc_id[QUEUE_PKTS], &spw_ioctl_send, sizeof(spw_ioctl_send));
225 status = rtems_message_queue_send( queue_id, &spw_ioctl_send, ACTION_MSG_PKTS_SIZE);
219 if (status != RTEMS_SUCCESSFUL) {
226 if (status != RTEMS_SUCCESSFUL) {
220 PRINTF1("in HOUS *** ERR %d\n", (int) status)
227 PRINTF1("in HOUS *** ERR %d\n", status)
221 }
228 }
222 }
229 }
223 }
230 }
224
231
225 PRINTF("in HOUS *** deleting task\n")
232 PRINTF("in HOUS *** deleting task\n")
226
233
227 status = rtems_task_delete( RTEMS_SELF ); // should not return
234 status = rtems_task_delete( RTEMS_SELF ); // should not return
228 printf( "rtems_task_delete returned with status of %d.\n", status );
235 printf( "rtems_task_delete returned with status of %d.\n", status );
229 exit( 1 );
236 exit( 1 );
230 }
237 }
231
238
232 rtems_task send_task( rtems_task_argument argument)
239 rtems_task send_task( rtems_task_argument argument)
233 {
240 {
234 rtems_status_code status; // RTEMS status code
241 rtems_status_code status; // RTEMS status code
235 spw_ioctl_pkt_send spw_ioctl_send; // incoming spw_ioctl_pkt_send structure
242 spw_ioctl_pkt_send spw_ioctl_send; // incoming spw_ioctl_pkt_send structure
236 size_t size; // size of the incoming TC packet
243 size_t size; // size of the incoming TC packet
237 u_int32_t count;
244 u_int32_t count;
245 rtems_id queue_id;
238
246
239 PRINTF("in SEND *** \n")
247 status = rtems_message_queue_ident( misc_name[QUEUE_PKTS], 0, &queue_id );
248 if (status != RTEMS_SUCCESSFUL)
249 {
250 PRINTF1("in SEND *** ERR getting queue id, %d\n", status)
251 }
252
253 BOOT_PRINTF("in SEND *** \n")
240
254
241 while(1)
255 while(1)
242 {
256 {
243 status = rtems_message_queue_receive(misc_id[QUEUE_PKTS], (char*) &spw_ioctl_send, &size,
257 status = rtems_message_queue_receive( queue_id, (char*) &spw_ioctl_send, &size,
244 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
258 RTEMS_WAIT, RTEMS_NO_TIMEOUT );
259
245 if (status!=RTEMS_SUCCESSFUL)
260 if (status!=RTEMS_SUCCESSFUL)
246 {
261 {
247 PRINTF1("in SEND *** (1) ERR = %d \n", status)
262 PRINTF1("in SEND *** (1) ERR = %d\n", status)
248 }
263 }
249 else
264 else
250 {
265 {
251 status = write_spw(&spw_ioctl_send);
266 if (spw_ioctl_send.hlen == 0)
252 if (status != RTEMS_SUCCESSFUL) {
267 {
253 PRINTF("in SEND *** TRAFFIC JAM\n")
268 status = write( fdSPW, spw_ioctl_send.data, spw_ioctl_send.dlen );
269 if (status == -1){
270 PRINTF2("in SEND *** (2.a) ERR = %d, dlen = %d\n", status, spw_ioctl_send.dlen)
271 }
272 }
273 else
274 {
275 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
276 if (status == -1){
277 PRINTF2("in SEND *** (2.b) ERR = %d, dlen = %d\n", status, spw_ioctl_send.dlen)
278 PRINTF1(" hlen = %d\n", spw_ioctl_send.hlen)
279 }
254 }
280 }
255 }
281 }
256
282
257 status = rtems_message_queue_get_number_pending( misc_id[QUEUE_PKTS], &count );
283 status = rtems_message_queue_get_number_pending( queue_id, &count );
258 if (status != RTEMS_SUCCESSFUL)
284 if (status != RTEMS_SUCCESSFUL)
259 {
285 {
260 PRINTF1("in SEND *** (2) ERR = %d \n", status)
286 PRINTF1("in SEND *** (3) ERR = %d\n", status)
261 }
287 }
262 else
288 else
263 {
289 {
264 if (count > maxCount)
290 if (count > maxCount)
265 {
291 {
266 maxCount = count;
292 maxCount = count;
267 }
293 }
268 }
294 }
269 }
295 }
270 }
296 }
271
297
298 rtems_id get_pkts_queue_id( void )
299 {
300 rtems_id queue_id;
301 rtems_status_code status;
302
303 status = rtems_message_queue_ident( misc_name[QUEUE_PKTS], 0, &queue_id );
304 if (status != RTEMS_SUCCESSFUL)
305 {
306 PRINTF1("in get_pkts_queue_id *** ERR %d\n", status)
307 }
308 return queue_id;
309 }
272
310
273
311
274
312
275
313
276
@@ -1,690 +1,688
1 #include <fsw_processing.h>
1 #include <fsw_processing.h>
2 #include <math.h>
2 #include <math.h>
3
3
4 #include <fsw_processing_globals.c>
4 #include <fsw_processing_globals.c>
5
5
6 unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_SM_F0 * 9 ];
6 unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_SM_F0 * 9 ];
7 BP1_t data_BP1[ NB_BINS_COMPRESSED_SM_F0 ];
7 BP1_t data_BP1[ NB_BINS_COMPRESSED_SM_F0 ];
8 float averaged_spec_mat_f0[ TOTAL_SIZE_SM ];
8 float averaged_spec_mat_f0[ TOTAL_SIZE_SM ];
9 char averaged_spec_mat_f0_char[ TOTAL_SIZE_SM * 2 ];
9 char averaged_spec_mat_f0_char[ TOTAL_SIZE_SM * 2 ];
10 float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ];
10 float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ];
11
11
12 //***********************************************************
12 //***********************************************************
13 // Interrupt Service Routine for spectral matrices processing
13 // Interrupt Service Routine for spectral matrices processing
14 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
14 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
15 {
15 {
16 unsigned char status;
16 unsigned char status;
17 unsigned char i;
17 unsigned char i;
18
18
19 status = spectral_matrix_regs->status; //[f2 f1 f0_1 f0_0]
19 status = spectral_matrix_regs->status; //[f2 f1 f0_1 f0_0]
20 for (i=0; i<4; i++)
20 for (i=0; i<4; i++)
21 {
21 {
22 if ( ( (status >> i) & 0x01) == 1) // (1) buffer rotation
22 if ( ( (status >> i) & 0x01) == 1) // (1) buffer rotation
23 {
23 {
24 switch(i)
24 switch(i)
25 {
25 {
26 case 0:
26 case 0:
27 if (spectral_matrix_regs->matrixF0_Address0 == (int) spec_mat_f0_0)
27 if (spectral_matrix_regs->matrixF0_Address0 == (int) spec_mat_f0_0)
28 {
28 {
29 spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0_bis;
29 spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0_bis;
30 }
30 }
31 else
31 else
32 {
32 {
33 spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0;
33 spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0;
34 }
34 }
35 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe;
35 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe;
36 break;
36 break;
37 case 1:
37 case 1:
38 if (spectral_matrix_regs->matrixFO_Address1 == (int) spec_mat_f0_1)
38 if (spectral_matrix_regs->matrixFO_Address1 == (int) spec_mat_f0_1)
39 {
39 {
40 spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1_bis;
40 spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1_bis;
41 }
41 }
42 else
42 else
43 {
43 {
44 spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1;
44 spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1;
45 }
45 }
46 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd;
46 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd;
47 break;
47 break;
48 case 2:
48 case 2:
49 if (spectral_matrix_regs->matrixF1_Address == (int) spec_mat_f1)
49 if (spectral_matrix_regs->matrixF1_Address == (int) spec_mat_f1)
50 {
50 {
51 spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1_bis;
51 spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1_bis;
52 }
52 }
53 else
53 else
54 {
54 {
55 spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1;
55 spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1;
56 }
56 }
57 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffb;
57 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffb;
58 break;
58 break;
59 case 3:
59 case 3:
60 if (spectral_matrix_regs->matrixF2_Address == (int) spec_mat_f2)
60 if (spectral_matrix_regs->matrixF2_Address == (int) spec_mat_f2)
61 {
61 {
62 spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2_bis;
62 spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2_bis;
63 }
63 }
64 else
64 else
65 {
65 {
66 spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2;
66 spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2;
67 }
67 }
68 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff7;
68 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffff7;
69 break;
69 break;
70 default:
70 default:
71 break;
71 break;
72 }
72 }
73 }
73 }
74 }
74 }
75
75
76 // reset error codes to 0
76 // reset error codes to 0
77 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // [1100 1111]
77 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xffffffcf; // [1100 1111]
78
78
79 if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
79 if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
80 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_4 );
80 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_4 );
81 }
81 }
82 }
82 }
83
83
84 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
84 rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector )
85 {
85 {
86 if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
86 if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
87 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_4 );
87 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_4 );
88 }
88 }
89 }
89 }
90
90
91 //************
91 //************
92 // RTEMS TASKS
92 // RTEMS TASKS
93
93
94 rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
94 rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
95 {
95 {
96 rtems_event_set event_out;
96 rtems_event_set event_out;
97 unsigned int nb_interrupt_f0 = 0;
97 unsigned int nb_interrupt_f0 = 0;
98
98
99 PRINTF("in SMIQ *** \n")
99 BOOT_PRINTF("in SMIQ *** \n")
100
100
101 while(1){
101 while(1){
102 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
102 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
103 nb_interrupt_f0 = nb_interrupt_f0 + 1;
103 nb_interrupt_f0 = nb_interrupt_f0 + 1;
104 if (nb_interrupt_f0 == NB_SM_TO_RECEIVE_BEFORE_AVF0 ){
104 if (nb_interrupt_f0 == NB_SM_TO_RECEIVE_BEFORE_AVF0 ){
105 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
105 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
106 {
106 {
107 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
107 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
108 }
108 }
109 nb_interrupt_f0 = 0;
109 nb_interrupt_f0 = 0;
110 }
110 }
111 }
111 }
112 }
112 }
113
113
114 //rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
114 //rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
115 //{
115 //{
116 // rtems_event_set event_out;
116 // rtems_event_set event_out;
117 // unsigned int nb_interrupt_f0 = 0;
117 // unsigned int nb_interrupt_f0 = 0;
118
118
119 // PRINTF("in SMIQ *** \n")
119 // PRINTF("in SMIQ *** \n")
120
120
121 // while(1){
121 // while(1){
122 // rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
122 // rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
123 // nb_interrupt_f0 = nb_interrupt_f0 + 1;
123 // nb_interrupt_f0 = nb_interrupt_f0 + 1;
124 // if (nb_interrupt_f0 == param_local.local_nb_interrupt_f0_MAX ){
124 // if (nb_interrupt_f0 == param_local.local_nb_interrupt_f0_MAX ){
125 // if (rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
125 // if (rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
126 // {
126 // {
127 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
127 // rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
128 // }
128 // }
129 // nb_interrupt_f0 = 0;
129 // nb_interrupt_f0 = 0;
130 // }
130 // }
131 // }
131 // }
132 //}
132 //}
133
133
134 rtems_task spw_bppr_task(rtems_task_argument argument)
134 rtems_task spw_bppr_task(rtems_task_argument argument)
135 {
135 {
136 rtems_status_code status;
136 rtems_status_code status;
137 rtems_event_set event_out;
137 rtems_event_set event_out;
138 static int Nb_average_f0 = 0;
138 static int Nb_average_f0 = 0;
139 //static int nb_average_f1 = 0;
139 //static int nb_average_f1 = 0;
140 //static int nb_average_f2 = 0;
140 //static int nb_average_f2 = 0;
141
141
142 printf("in BPPR ***\n");
142 BOOT_PRINTF("in BPPR ***\n");
143
143
144 while(true){ // wait for an event to begin with the processing
144 while(true){ // wait for an event to begin with the processing
145 status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out);
145 status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out);
146 if (status == RTEMS_SUCCESSFUL) {
146 if (status == RTEMS_SUCCESSFUL) {
147 if ((spectral_matrix_regs->status & 0x00000001)==1) {
147 if ((spectral_matrix_regs->status & 0x00000001)==1) {
148 matrix_average(spec_mat_f0_0, averaged_spec_mat_f0);
148 matrix_average(spec_mat_f0_0, averaged_spec_mat_f0);
149 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe;
149 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffe;
150 //printf("f0_a\n");
150 //printf("f0_a\n");
151 Nb_average_f0++;
151 Nb_average_f0++;
152 }
152 }
153 if (((spectral_matrix_regs->status>>1) & 0x00000001)==1) {
153 if (((spectral_matrix_regs->status>>1) & 0x00000001)==1) {
154 matrix_average(spec_mat_f0_1, compressed_spec_mat_f0);
154 matrix_average(spec_mat_f0_1, compressed_spec_mat_f0);
155 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd;
155 spectral_matrix_regs->status = spectral_matrix_regs->status & 0xfffffffd;
156 //printf("f0_b\n");
156 //printf("f0_b\n");
157 Nb_average_f0++;
157 Nb_average_f0++;
158 }
158 }
159 if (Nb_average_f0 == NB_AVERAGE_NORMAL_f0) {
159 if (Nb_average_f0 == NB_AVERAGE_NORMAL_f0) {
160 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
160 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
161 //printf("f0 compressed\n");
161 //printf("f0 compressed\n");
162 Nb_average_f0 = 0;
162 Nb_average_f0 = 0;
163 matrix_reset(averaged_spec_mat_f0);
163 matrix_reset(averaged_spec_mat_f0);
164 }
164 }
165 }
165 }
166 }
166 }
167 }
167 }
168
168
169 rtems_task avf0_task(rtems_task_argument argument)
169 rtems_task avf0_task(rtems_task_argument argument)
170 {
170 {
171 int i;
171 int i;
172 static int nb_average;
172 static int nb_average;
173 rtems_event_set event_out;
173 rtems_event_set event_out;
174 rtems_status_code status;
174 rtems_status_code status;
175
175
176 nb_average = 0;
176 nb_average = 0;
177
177
178 PRINTF("in AVFO *** \n")
178 BOOT_PRINTF("in AVFO *** \n")
179
179
180 while(1){
180 while(1){
181 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
181 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
182 for(i=0; i<TOTAL_SIZE_SM; i++){
182 for(i=0; i<TOTAL_SIZE_SM; i++){
183 averaged_spec_mat_f0[i] = averaged_spec_mat_f0[i] + spec_mat_f0_a[i]
183 averaged_spec_mat_f0[i] = averaged_spec_mat_f0[i] + spec_mat_f0_a[i]
184 + spec_mat_f0_b[i]
184 + spec_mat_f0_b[i]
185 + spec_mat_f0_c[i]
185 + spec_mat_f0_c[i]
186 + spec_mat_f0_d[i]
186 + spec_mat_f0_d[i]
187 + spec_mat_f0_e[i]
187 + spec_mat_f0_e[i]
188 + spec_mat_f0_f[i]
188 + spec_mat_f0_f[i]
189 + spec_mat_f0_g[i]
189 + spec_mat_f0_g[i]
190 + spec_mat_f0_h[i];
190 + spec_mat_f0_h[i];
191 }
191 }
192 nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0;
192 nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0;
193 if (nb_average == NB_AVERAGE_NORMAL_f0) {
193 if (nb_average == NB_AVERAGE_NORMAL_f0) {
194 nb_average = 0;
194 nb_average = 0;
195 status = rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0
195 status = rtems_event_send( Task_id[TASKID_MATR], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0
196 if (status != RTEMS_SUCCESSFUL) {
196 if (status != RTEMS_SUCCESSFUL) {
197 printf("in AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
197 printf("in AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
198 }
198 }
199 }
199 }
200 }
200 }
201 }
201 }
202
202
203 rtems_task bpf0_task(rtems_task_argument argument)
203 rtems_task bpf0_task(rtems_task_argument argument)
204 {
204 {
205 rtems_event_set event_out;
205 rtems_event_set event_out;
206
206
207 PRINTF("in BPFO *** \n")
207 BOOT_PRINTF("in BPFO *** \n")
208
208
209 while(1){
209 while(1){
210 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
210 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
211 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
211 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
212 BP1_set(compressed_spec_mat_f0, NB_BINS_COMPRESSED_SM_F0, LFR_BP1_F0);
212 BP1_set(compressed_spec_mat_f0, NB_BINS_COMPRESSED_SM_F0, LFR_BP1_F0);
213 //PRINTF("IN TASK BPF0 *** Matrix compressed, parameters calculated\n")
213 //PRINTF("IN TASK BPF0 *** Matrix compressed, parameters calculated\n")
214 }
214 }
215 }
215 }
216
216
217 rtems_task matr_task(rtems_task_argument argument)
217 rtems_task matr_task(rtems_task_argument argument)
218 {
218 {
219 spw_ioctl_pkt_send spw_ioctl_send_ASM;
219 spw_ioctl_pkt_send spw_ioctl_send_ASM;
220 rtems_event_set event_out;
220 rtems_event_set event_out;
221 rtems_status_code status;
222 rtems_id queue_id;
221 Header_TM_LFR_SCIENCE_ASM_t headerASM;
223 Header_TM_LFR_SCIENCE_ASM_t headerASM;
222
224
223 init_header_asm( &headerASM );
225 init_header_asm( &headerASM );
224
226
225 PRINTF("in MATR *** \n")
227 status = rtems_message_queue_ident( misc_name[QUEUE_PKTS], 0, &queue_id );
228 if (status != RTEMS_SUCCESSFUL)
229 {
230 PRINTF1("in MATR *** ERR getting queue id, %d\n", status)
231 }
232
233 BOOT_PRINTF("in MATR *** \n")
226
234
227 fill_averaged_spectral_matrix( );
235 fill_averaged_spectral_matrix( );
228
236
229 while(1){
237 while(1){
230 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
238 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
231
239
232 #ifdef GSA
240 #ifdef GSA
233 #else
241 #else
234 fill_averaged_spectral_matrix( );
242 fill_averaged_spectral_matrix( );
235 #endif
243 #endif
236 convert_averaged_spectral_matrix( averaged_spec_mat_f0, averaged_spec_mat_f0_char);
244 convert_averaged_spectral_matrix( averaged_spec_mat_f0, averaged_spec_mat_f0_char);
237
245
238 send_spectral_matrix( &headerASM, averaged_spec_mat_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM);
246 send_spectral_matrix( &headerASM, averaged_spec_mat_f0_char, SID_NORM_ASM_F0, &spw_ioctl_send_ASM, queue_id);
239 }
247 }
240 }
248 }
241
249
242 //*****************************
250 //*****************************
243 // Spectral matrices processing
251 // Spectral matrices processing
244 void matrix_average(volatile int *spec_mat, volatile float *averaged_spec_mat)
252 void matrix_average(volatile int *spec_mat, volatile float *averaged_spec_mat)
245 {
253 {
246 int i;
254 int i;
247 for(i=0; i<TOTAL_SIZE_SM; i++){
255 for(i=0; i<TOTAL_SIZE_SM; i++){
248 averaged_spec_mat[i] = averaged_spec_mat[i] + spec_mat_f0_0[i]
256 averaged_spec_mat[i] = averaged_spec_mat[i] + spec_mat_f0_0[i]
249 + spec_mat_f0_1[i]
257 + spec_mat_f0_1[i]
250 + spec_mat_f0_c[i]
258 + spec_mat_f0_c[i]
251 + spec_mat_f0_d[i]
259 + spec_mat_f0_d[i]
252 + spec_mat_f0_e[i]
260 + spec_mat_f0_e[i]
253 + spec_mat_f0_f[i]
261 + spec_mat_f0_f[i]
254 + spec_mat_f0_g[i]
262 + spec_mat_f0_g[i]
255 + spec_mat_f0_h[i];
263 + spec_mat_f0_h[i];
256 }
264 }
257 }
265 }
258
266
259 void matrix_reset(volatile float *averaged_spec_mat)
267 void matrix_reset(volatile float *averaged_spec_mat)
260 {
268 {
261 // int i;
269 // int i;
262 // for(i=0; i<TOTAL_SIZE_SM; i++){
270 // for(i=0; i<TOTAL_SIZE_SM; i++){
263 // averaged_spec_mat_f0[i] = 0;
271 // averaged_spec_mat_f0[i] = 0;
264 // }
272 // }
265 }
273 }
266
274
267 void matrix_compression(volatile float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat)
275 void matrix_compression(volatile float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat)
268 {
276 {
269 int i;
277 int i;
270 int j;
278 int j;
271 switch (fChannel){
279 switch (fChannel){
272 case 0:
280 case 0:
273 for(i=0;i<NB_BINS_COMPRESSED_SM_F0;i++){
281 for(i=0;i<NB_BINS_COMPRESSED_SM_F0;i++){
274 j = 17 + (i * 8);
282 j = 17 + (i * 8);
275 compressed_spec_mat[i] = (averaged_spec_mat[j]
283 compressed_spec_mat[i] = (averaged_spec_mat[j]
276 + averaged_spec_mat[j+1]
284 + averaged_spec_mat[j+1]
277 + averaged_spec_mat[j+2]
285 + averaged_spec_mat[j+2]
278 + averaged_spec_mat[j+3]
286 + averaged_spec_mat[j+3]
279 + averaged_spec_mat[j+4]
287 + averaged_spec_mat[j+4]
280 + averaged_spec_mat[j+5]
288 + averaged_spec_mat[j+5]
281 + averaged_spec_mat[j+6]
289 + averaged_spec_mat[j+6]
282 + averaged_spec_mat[j+7])/(8*NB_AVERAGE_NORMAL_f0);
290 + averaged_spec_mat[j+7])/(8*NB_AVERAGE_NORMAL_f0);
283 }
291 }
284 break;
292 break;
285 case 1:
293 case 1:
286 // case fChannel = f1 to be completed later
294 // case fChannel = f1 to be completed later
287 break;
295 break;
288 case 2:
296 case 2:
289 // case fChannel = f1 to be completed later
297 // case fChannel = f1 to be completed later
290 break;
298 break;
291 default:
299 default:
292 break;
300 break;
293 }
301 }
294 }
302 }
295
303
296 void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){
304 void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){
297 int i;
305 int i;
298 int j;
306 int j;
299 unsigned char tmp_u_char;
307 unsigned char tmp_u_char;
300 unsigned char * pt_char = NULL;
308 unsigned char * pt_char = NULL;
301 float PSDB, PSDE;
309 float PSDB, PSDE;
302 float NVEC_V0;
310 float NVEC_V0;
303 float NVEC_V1;
311 float NVEC_V1;
304 float NVEC_V2;
312 float NVEC_V2;
305 //float significand;
313 //float significand;
306 //int exponent;
314 //int exponent;
307 float aux;
315 float aux;
308 float tr_SB_SB;
316 float tr_SB_SB;
309 float tmp;
317 float tmp;
310 float sx_re;
318 float sx_re;
311 float sx_im;
319 float sx_im;
312 float nebx_re = 0;
320 float nebx_re = 0;
313 float nebx_im = 0;
321 float nebx_im = 0;
314 float ny = 0;
322 float ny = 0;
315 float nz = 0;
323 float nz = 0;
316 float bx_bx_star = 0;
324 float bx_bx_star = 0;
317 for(i=0; i<nb_bins_compressed_spec_mat; i++){
325 for(i=0; i<nb_bins_compressed_spec_mat; i++){
318 //==============================================
326 //==============================================
319 // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits
327 // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits
320 PSDB = compressed_spec_mat[i*30] // S11
328 PSDB = compressed_spec_mat[i*30] // S11
321 + compressed_spec_mat[(i*30) + 10] // S22
329 + compressed_spec_mat[(i*30) + 10] // S22
322 + compressed_spec_mat[(i*30) + 18]; // S33
330 + compressed_spec_mat[(i*30) + 18]; // S33
323 //significand = frexp(PSDB, &exponent);
331 //significand = frexp(PSDB, &exponent);
324 pt_char = (unsigned char*) &PSDB;
332 pt_char = (unsigned char*) &PSDB;
325 LFR_BP1[(i*9) + 2] = pt_char[0]; // bits 31 downto 24 of the float
333 LFR_BP1[(i*9) + 2] = pt_char[0]; // bits 31 downto 24 of the float
326 LFR_BP1[(i*9) + 3] = pt_char[1]; // bits 23 downto 16 of the float
334 LFR_BP1[(i*9) + 3] = pt_char[1]; // bits 23 downto 16 of the float
327 //==============================================
335 //==============================================
328 // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits
336 // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits
329 PSDE = compressed_spec_mat[(i*30) + 24] * K44_pe // S44
337 PSDE = compressed_spec_mat[(i*30) + 24] * K44_pe // S44
330 + compressed_spec_mat[(i*30) + 28] * K55_pe // S55
338 + compressed_spec_mat[(i*30) + 28] * K55_pe // S55
331 + compressed_spec_mat[(i*30) + 26] * K45_pe_re // S45
339 + compressed_spec_mat[(i*30) + 26] * K45_pe_re // S45
332 - compressed_spec_mat[(i*30) + 27] * K45_pe_im; // S45
340 - compressed_spec_mat[(i*30) + 27] * K45_pe_im; // S45
333 pt_char = (unsigned char*) &PSDE;
341 pt_char = (unsigned char*) &PSDE;
334 LFR_BP1[(i*9) + 0] = pt_char[0]; // bits 31 downto 24 of the float
342 LFR_BP1[(i*9) + 0] = pt_char[0]; // bits 31 downto 24 of the float
335 LFR_BP1[(i*9) + 1] = pt_char[1]; // bits 23 downto 16 of the float
343 LFR_BP1[(i*9) + 1] = pt_char[1]; // bits 23 downto 16 of the float
336 //==============================================================================
344 //==============================================================================
337 // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
345 // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
338 // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
346 // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
339 // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits
347 // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits
340 tmp = sqrt(
348 tmp = sqrt(
341 compressed_spec_mat[(i*30) + 3]*compressed_spec_mat[(i*30) + 3] //Im S12
349 compressed_spec_mat[(i*30) + 3]*compressed_spec_mat[(i*30) + 3] //Im S12
342 +compressed_spec_mat[(i*30) + 5]*compressed_spec_mat[(i*30) + 5] //Im S13
350 +compressed_spec_mat[(i*30) + 5]*compressed_spec_mat[(i*30) + 5] //Im S13
343 +compressed_spec_mat[(i*30) + 13]*compressed_spec_mat[(i*30) + 13] //Im S23
351 +compressed_spec_mat[(i*30) + 13]*compressed_spec_mat[(i*30) + 13] //Im S23
344 );
352 );
345 NVEC_V0 = compressed_spec_mat[(i*30) + 13] / tmp; // Im S23
353 NVEC_V0 = compressed_spec_mat[(i*30) + 13] / tmp; // Im S23
346 NVEC_V1 = -compressed_spec_mat[(i*30) + 5] / tmp; // Im S13
354 NVEC_V1 = -compressed_spec_mat[(i*30) + 5] / tmp; // Im S13
347 NVEC_V2 = compressed_spec_mat[(i*30) + 3] / tmp; // Im S12
355 NVEC_V2 = compressed_spec_mat[(i*30) + 3] / tmp; // Im S12
348 LFR_BP1[(i*9) + 4] = (char) (NVEC_V0*127);
356 LFR_BP1[(i*9) + 4] = (char) (NVEC_V0*127);
349 LFR_BP1[(i*9) + 5] = (char) (NVEC_V1*127);
357 LFR_BP1[(i*9) + 5] = (char) (NVEC_V1*127);
350 pt_char = (unsigned char*) &NVEC_V2;
358 pt_char = (unsigned char*) &NVEC_V2;
351 LFR_BP1[(i*9) + 6] = pt_char[0] & 0x80; // extract the sign of NVEC_V2
359 LFR_BP1[(i*9) + 6] = pt_char[0] & 0x80; // extract the sign of NVEC_V2
352 //=======================================================
360 //=======================================================
353 // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits
361 // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits
354 aux = 2*tmp / PSDB; // compute the ellipticity
362 aux = 2*tmp / PSDB; // compute the ellipticity
355 tmp_u_char = (unsigned char) (aux*(16-1)); // convert the ellipticity
363 tmp_u_char = (unsigned char) (aux*(16-1)); // convert the ellipticity
356 LFR_BP1[i*9+6] = LFR_BP1[i*9+6] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char
364 LFR_BP1[i*9+6] = LFR_BP1[i*9+6] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char
357 //==============================================================
365 //==============================================================
358 // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits
366 // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits
359 for(j = 0; j<NB_VALUES_PER_SM;j++){
367 for(j = 0; j<NB_VALUES_PER_SM;j++){
360 tr_SB_SB = compressed_spec_mat[i*30] * compressed_spec_mat[i*30]
368 tr_SB_SB = compressed_spec_mat[i*30] * compressed_spec_mat[i*30]
361 + compressed_spec_mat[(i*30) + 10] * compressed_spec_mat[(i*30) + 10]
369 + compressed_spec_mat[(i*30) + 10] * compressed_spec_mat[(i*30) + 10]
362 + compressed_spec_mat[(i*30) + 18] * compressed_spec_mat[(i*30) + 18]
370 + compressed_spec_mat[(i*30) + 18] * compressed_spec_mat[(i*30) + 18]
363 + 2 * compressed_spec_mat[(i*30) + 2] * compressed_spec_mat[(i*30) + 2]
371 + 2 * compressed_spec_mat[(i*30) + 2] * compressed_spec_mat[(i*30) + 2]
364 + 2 * compressed_spec_mat[(i*30) + 3] * compressed_spec_mat[(i*30) + 3]
372 + 2 * compressed_spec_mat[(i*30) + 3] * compressed_spec_mat[(i*30) + 3]
365 + 2 * compressed_spec_mat[(i*30) + 4] * compressed_spec_mat[(i*30) + 4]
373 + 2 * compressed_spec_mat[(i*30) + 4] * compressed_spec_mat[(i*30) + 4]
366 + 2 * compressed_spec_mat[(i*30) + 5] * compressed_spec_mat[(i*30) + 5]
374 + 2 * compressed_spec_mat[(i*30) + 5] * compressed_spec_mat[(i*30) + 5]
367 + 2 * compressed_spec_mat[(i*30) + 12] * compressed_spec_mat[(i*30) + 12]
375 + 2 * compressed_spec_mat[(i*30) + 12] * compressed_spec_mat[(i*30) + 12]
368 + 2 * compressed_spec_mat[(i*30) + 13] * compressed_spec_mat[(i*30) + 13];
376 + 2 * compressed_spec_mat[(i*30) + 13] * compressed_spec_mat[(i*30) + 13];
369 }
377 }
370 aux = PSDB*PSDB;
378 aux = PSDB*PSDB;
371 tmp = sqrt( abs( ( 3*tr_SB_SB - aux ) / ( 2 * aux ) ) );
379 tmp = sqrt( abs( ( 3*tr_SB_SB - aux ) / ( 2 * aux ) ) );
372 tmp_u_char = (unsigned char) (NVEC_V0*(8-1));
380 tmp_u_char = (unsigned char) (NVEC_V0*(8-1));
373 LFR_BP1[(i*9) + 6] = LFR_BP1[(i*9) + 6] | (tmp_u_char & 0x07); // keeps 3 bits of the resulting unsigned char
381 LFR_BP1[(i*9) + 6] = LFR_BP1[(i*9) + 6] | (tmp_u_char & 0x07); // keeps 3 bits of the resulting unsigned char
374 //=======================================================================================
382 //=======================================================================================
375 // BP1 x-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1)
383 // BP1 x-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1)
376 sx_re = compressed_spec_mat[(i*30) + 20] * K34_sx_re
384 sx_re = compressed_spec_mat[(i*30) + 20] * K34_sx_re
377 + compressed_spec_mat[(i*30) + 6] * K14_sx_re
385 + compressed_spec_mat[(i*30) + 6] * K14_sx_re
378 + compressed_spec_mat[(i*30) + 8] * K15_sx_re
386 + compressed_spec_mat[(i*30) + 8] * K15_sx_re
379 + compressed_spec_mat[(i*30) + 14] * K24_sx_re
387 + compressed_spec_mat[(i*30) + 14] * K24_sx_re
380 + compressed_spec_mat[(i*30) + 16] * K25_sx_re
388 + compressed_spec_mat[(i*30) + 16] * K25_sx_re
381 + compressed_spec_mat[(i*30) + 22] * K35_sx_re;
389 + compressed_spec_mat[(i*30) + 22] * K35_sx_re;
382 sx_im = compressed_spec_mat[(i*30) + 21] * K34_sx_im
390 sx_im = compressed_spec_mat[(i*30) + 21] * K34_sx_im
383 + compressed_spec_mat[(i*30) + 7] * K14_sx_im
391 + compressed_spec_mat[(i*30) + 7] * K14_sx_im
384 + compressed_spec_mat[(i*30) + 9] * K15_sx_im
392 + compressed_spec_mat[(i*30) + 9] * K15_sx_im
385 + compressed_spec_mat[(i*30) + 15] * K24_sx_im
393 + compressed_spec_mat[(i*30) + 15] * K24_sx_im
386 + compressed_spec_mat[(i*30) + 17] * K25_sx_im
394 + compressed_spec_mat[(i*30) + 17] * K25_sx_im
387 + compressed_spec_mat[(i*30) + 23] * K35_sx_im;
395 + compressed_spec_mat[(i*30) + 23] * K35_sx_im;
388 LFR_BP1[(i*9) + 7] = ((unsigned char) (sx_re * 128)) & 0x7f; // cf DOC for the compression
396 LFR_BP1[(i*9) + 7] = ((unsigned char) (sx_re * 128)) & 0x7f; // cf DOC for the compression
389 if ( abs(sx_re) > abs(sx_im) ) {
397 if ( abs(sx_re) > abs(sx_im) ) {
390 LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] | (0x80); // extract the sector of sx
398 LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] | (0x80); // extract the sector of sx
391 }
399 }
392 else {
400 else {
393 LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] & (0x7f); // extract the sector of sx
401 LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] & (0x7f); // extract the sector of sx
394 }
402 }
395 //======================================================================
403 //======================================================================
396 // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1)
404 // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1)
397 ny = sin(Alpha_M)*NVEC_V1 + cos(Alpha_M)*NVEC_V2;
405 ny = sin(Alpha_M)*NVEC_V1 + cos(Alpha_M)*NVEC_V2;
398 nz = NVEC_V0;
406 nz = NVEC_V0;
399 bx_bx_star = cos(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+10] // re S22
407 bx_bx_star = cos(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+10] // re S22
400 + sin(Alpha_M) * sin(Alpha_M) * compressed_spec_mat[i*30+18] // re S33
408 + sin(Alpha_M) * sin(Alpha_M) * compressed_spec_mat[i*30+18] // re S33
401 - 2 * sin(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+12]; // re S23
409 - 2 * sin(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+12]; // re S23
402 nebx_re = ny * (compressed_spec_mat[(i*30) + 14] * K24_ny_re
410 nebx_re = ny * (compressed_spec_mat[(i*30) + 14] * K24_ny_re
403 +compressed_spec_mat[(i*30) + 16] * K25_ny_re
411 +compressed_spec_mat[(i*30) + 16] * K25_ny_re
404 +compressed_spec_mat[(i*30) + 20] * K34_ny_re
412 +compressed_spec_mat[(i*30) + 20] * K34_ny_re
405 +compressed_spec_mat[(i*30) + 22] * K35_ny_re)
413 +compressed_spec_mat[(i*30) + 22] * K35_ny_re)
406 + nz * (compressed_spec_mat[(i*30) + 14] * K24_nz_re
414 + nz * (compressed_spec_mat[(i*30) + 14] * K24_nz_re
407 +compressed_spec_mat[(i*30) + 16] * K25_nz_re
415 +compressed_spec_mat[(i*30) + 16] * K25_nz_re
408 +compressed_spec_mat[(i*30) + 20] * K34_nz_re
416 +compressed_spec_mat[(i*30) + 20] * K34_nz_re
409 +compressed_spec_mat[(i*30) + 22] * K35_nz_re);
417 +compressed_spec_mat[(i*30) + 22] * K35_nz_re);
410 nebx_im = ny * (compressed_spec_mat[(i*30) + 15]*K24_ny_re
418 nebx_im = ny * (compressed_spec_mat[(i*30) + 15]*K24_ny_re
411 +compressed_spec_mat[(i*30) + 17] * K25_ny_re
419 +compressed_spec_mat[(i*30) + 17] * K25_ny_re
412 +compressed_spec_mat[(i*30) + 21] * K34_ny_re
420 +compressed_spec_mat[(i*30) + 21] * K34_ny_re
413 +compressed_spec_mat[(i*30) + 23] * K35_ny_re)
421 +compressed_spec_mat[(i*30) + 23] * K35_ny_re)
414 + nz * (compressed_spec_mat[(i*30) + 15] * K24_nz_im
422 + nz * (compressed_spec_mat[(i*30) + 15] * K24_nz_im
415 +compressed_spec_mat[(i*30) + 17] * K25_nz_im
423 +compressed_spec_mat[(i*30) + 17] * K25_nz_im
416 +compressed_spec_mat[(i*30) + 21] * K34_nz_im
424 +compressed_spec_mat[(i*30) + 21] * K34_nz_im
417 +compressed_spec_mat[(i*30) + 23] * K35_nz_im);
425 +compressed_spec_mat[(i*30) + 23] * K35_nz_im);
418 tmp = nebx_re / bx_bx_star;
426 tmp = nebx_re / bx_bx_star;
419 LFR_BP1[(i*9) + 8] = ((unsigned char) (tmp * 128)) & 0x7f; // cf DOC for the compression
427 LFR_BP1[(i*9) + 8] = ((unsigned char) (tmp * 128)) & 0x7f; // cf DOC for the compression
420 if ( abs(nebx_re) > abs(nebx_im) ) {
428 if ( abs(nebx_re) > abs(nebx_im) ) {
421 LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] | (0x80); // extract the sector of nebx
429 LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] | (0x80); // extract the sector of nebx
422 }
430 }
423 else {
431 else {
424 LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] & (0x7f); // extract the sector of nebx
432 LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] & (0x7f); // extract the sector of nebx
425 }
433 }
426 }
434 }
427
435
428 }
436 }
429
437
430 void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){
438 void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){
431 // BP2 autocorrelation
439 // BP2 autocorrelation
432 int i;
440 int i;
433 int aux = 0;
441 int aux = 0;
434
442
435 for(i = 0; i<nb_bins_compressed_spec_mat; i++){
443 for(i = 0; i<nb_bins_compressed_spec_mat; i++){
436 // S12
444 // S12
437 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 10]);
445 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 10]);
438 compressed_spec_mat[(i*30) + 2] = compressed_spec_mat[(i*30) + 2] / aux;
446 compressed_spec_mat[(i*30) + 2] = compressed_spec_mat[(i*30) + 2] / aux;
439 compressed_spec_mat[(i*30) + 3] = compressed_spec_mat[(i*30) + 3] / aux;
447 compressed_spec_mat[(i*30) + 3] = compressed_spec_mat[(i*30) + 3] / aux;
440 // S13
448 // S13
441 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 18]);
449 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 18]);
442 compressed_spec_mat[(i*30) + 4] = compressed_spec_mat[(i*30) + 4] / aux;
450 compressed_spec_mat[(i*30) + 4] = compressed_spec_mat[(i*30) + 4] / aux;
443 compressed_spec_mat[(i*30) + 5] = compressed_spec_mat[(i*30) + 5] / aux;
451 compressed_spec_mat[(i*30) + 5] = compressed_spec_mat[(i*30) + 5] / aux;
444 // S23
452 // S23
445 aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[(i*30) + 18]);
453 aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[(i*30) + 18]);
446 compressed_spec_mat[(i*30) + 12] = compressed_spec_mat[(i*30) + 12] / aux;
454 compressed_spec_mat[(i*30) + 12] = compressed_spec_mat[(i*30) + 12] / aux;
447 compressed_spec_mat[(i*30) + 13] = compressed_spec_mat[(i*30) + 13] / aux;
455 compressed_spec_mat[(i*30) + 13] = compressed_spec_mat[(i*30) + 13] / aux;
448 // S45
456 // S45
449 aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[(i*30) + 28]);
457 aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[(i*30) + 28]);
450 compressed_spec_mat[(i*30) + 26] = compressed_spec_mat[(i*30) + 26] / aux;
458 compressed_spec_mat[(i*30) + 26] = compressed_spec_mat[(i*30) + 26] / aux;
451 compressed_spec_mat[(i*30) + 27] = compressed_spec_mat[(i*30) + 27] / aux;
459 compressed_spec_mat[(i*30) + 27] = compressed_spec_mat[(i*30) + 27] / aux;
452 // S14
460 // S14
453 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) +24]);
461 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) +24]);
454 compressed_spec_mat[(i*30) + 6] = compressed_spec_mat[(i*30) + 6] / aux;
462 compressed_spec_mat[(i*30) + 6] = compressed_spec_mat[(i*30) + 6] / aux;
455 compressed_spec_mat[(i*30) + 7] = compressed_spec_mat[(i*30) + 7] / aux;
463 compressed_spec_mat[(i*30) + 7] = compressed_spec_mat[(i*30) + 7] / aux;
456 // S15
464 // S15
457 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 28]);
465 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 28]);
458 compressed_spec_mat[(i*30) + 8] = compressed_spec_mat[(i*30) + 8] / aux;
466 compressed_spec_mat[(i*30) + 8] = compressed_spec_mat[(i*30) + 8] / aux;
459 compressed_spec_mat[(i*30) + 9] = compressed_spec_mat[(i*30) + 9] / aux;
467 compressed_spec_mat[(i*30) + 9] = compressed_spec_mat[(i*30) + 9] / aux;
460 // S24
468 // S24
461 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 24]);
469 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 24]);
462 compressed_spec_mat[(i*30) + 14] = compressed_spec_mat[(i*30) + 14] / aux;
470 compressed_spec_mat[(i*30) + 14] = compressed_spec_mat[(i*30) + 14] / aux;
463 compressed_spec_mat[(i*30) + 15] = compressed_spec_mat[(i*30) + 15] / aux;
471 compressed_spec_mat[(i*30) + 15] = compressed_spec_mat[(i*30) + 15] / aux;
464 // S25
472 // S25
465 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 28]);
473 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 28]);
466 compressed_spec_mat[(i*30) + 16] = compressed_spec_mat[(i*30) + 16] / aux;
474 compressed_spec_mat[(i*30) + 16] = compressed_spec_mat[(i*30) + 16] / aux;
467 compressed_spec_mat[(i*30) + 17] = compressed_spec_mat[(i*30) + 17] / aux;
475 compressed_spec_mat[(i*30) + 17] = compressed_spec_mat[(i*30) + 17] / aux;
468 // S34
476 // S34
469 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 24]);
477 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 24]);
470 compressed_spec_mat[(i*30) + 20] = compressed_spec_mat[(i*30) + 20] / aux;
478 compressed_spec_mat[(i*30) + 20] = compressed_spec_mat[(i*30) + 20] / aux;
471 compressed_spec_mat[(i*30) + 21] = compressed_spec_mat[(i*30) + 21] / aux;
479 compressed_spec_mat[(i*30) + 21] = compressed_spec_mat[(i*30) + 21] / aux;
472 // S35
480 // S35
473 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 28]);
481 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 28]);
474 compressed_spec_mat[(i*30) + 22] = compressed_spec_mat[(i*30) + 22] / aux;
482 compressed_spec_mat[(i*30) + 22] = compressed_spec_mat[(i*30) + 22] / aux;
475 compressed_spec_mat[(i*30) + 23] = compressed_spec_mat[(i*30) + 23] / aux;
483 compressed_spec_mat[(i*30) + 23] = compressed_spec_mat[(i*30) + 23] / aux;
476 }
484 }
477 }
485 }
478
486
479 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header)
487 void init_header_asm( Header_TM_LFR_SCIENCE_ASM_t *header)
480 {
488 {
481 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
489 header->targetLogicalAddress = CCSDS_DESTINATION_ID;
482 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
490 header->protocolIdentifier = CCSDS_PROTOCOLE_ID;
483 header->reserved = 0x00;
491 header->reserved = 0x00;
484 header->userApplication = CCSDS_USER_APP;
492 header->userApplication = CCSDS_USER_APP;
485 header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
493 header->packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
486 header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
494 header->packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
487 header->packetSequenceControl[0] = 0xc0;
495 header->packetSequenceControl[0] = 0xc0;
488 header->packetSequenceControl[1] = 0x00;
496 header->packetSequenceControl[1] = 0x00;
489 header->packetLength[0] = 0x00;
497 header->packetLength[0] = 0x00;
490 header->packetLength[1] = 0x00;
498 header->packetLength[1] = 0x00;
491 // DATA FIELD HEADER
499 // DATA FIELD HEADER
492 header->spare1_pusVersion_spare2 = 0x10;
500 header->spare1_pusVersion_spare2 = 0x10;
493 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
501 header->serviceType = TM_TYPE_LFR_SCIENCE; // service type
494 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
502 header->serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
495 header->destinationID = TM_DESTINATION_ID_GROUND;
503 header->destinationID = TM_DESTINATION_ID_GROUND;
496 // AUXILIARY DATA HEADER
504 // AUXILIARY DATA HEADER
497 header->sid = 0x00;
505 header->sid = 0x00;
498 header->biaStatusInfo = 0x00;
506 header->biaStatusInfo = 0x00;
499 header->cntASM = 0x00;
507 header->cntASM = 0x00;
500 header->nrASM = 0x00;
508 header->nrASM = 0x00;
501 header->time[0] = 0x00;
509 header->time[0] = 0x00;
502 header->time[0] = 0x00;
510 header->time[0] = 0x00;
503 header->time[0] = 0x00;
511 header->time[0] = 0x00;
504 header->time[0] = 0x00;
512 header->time[0] = 0x00;
505 header->time[0] = 0x00;
513 header->time[0] = 0x00;
506 header->time[0] = 0x00;
514 header->time[0] = 0x00;
507 header->blkNr[0] = 0x00; // BLK_NR MSB
515 header->blkNr[0] = 0x00; // BLK_NR MSB
508 header->blkNr[1] = 0x00; // BLK_NR LSB
516 header->blkNr[1] = 0x00; // BLK_NR LSB
509 }
517 }
510
518
511 void send_spectral_matrix(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
519 void send_spectral_matrix(Header_TM_LFR_SCIENCE_ASM_t *header, char *spectral_matrix,
512 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send)
520 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send, rtems_id queue_id)
513 {
521 {
514 unsigned int i;
522 unsigned int i;
515 unsigned int length = 0;
523 unsigned int length = 0;
516 rtems_status_code status;
524 rtems_status_code status;
517
525
518 header->sid = (unsigned char) sid;
526 header->sid = (unsigned char) sid;
519
527
520 for (i=0; i<2; i++)
528 for (i=0; i<2; i++)
521 {
529 {
522 // BUILD THE DATA
530 // BUILD THE DATA
523 spw_ioctl_send->dlen = TOTAL_SIZE_SM;
531 spw_ioctl_send->dlen = TOTAL_SIZE_SM;
524 spw_ioctl_send->data = &spectral_matrix[ i * TOTAL_SIZE_SM];
532 spw_ioctl_send->data = &spectral_matrix[ i * TOTAL_SIZE_SM];
525 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
533 spw_ioctl_send->hlen = HEADER_LENGTH_TM_LFR_SCIENCE_ASM + CCSDS_PROTOCOLE_EXTRA_BYTES;
526 spw_ioctl_send->hdr = (char *) header;
534 spw_ioctl_send->hdr = (char *) header;
527 spw_ioctl_send->options = 0;
535 spw_ioctl_send->options = 0;
528
536
529 // BUILD THE HEADER
537 // BUILD THE HEADER
530 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM;
538 length = PACKET_LENGTH_TM_LFR_SCIENCE_ASM;
531 header->packetLength[0] = (unsigned char) (length>>8);
539 header->packetLength[0] = (unsigned char) (length>>8);
532 header->packetLength[1] = (unsigned char) (length);
540 header->packetLength[1] = (unsigned char) (length);
533 header->sid = (unsigned char) sid; // SID
541 header->sid = (unsigned char) sid; // SID
534 header->cntASM = 2;
542 header->cntASM = 2;
535 header->nrASM = (unsigned char) (i+1);
543 header->nrASM = (unsigned char) (i+1);
536 header->blkNr[0] =(unsigned char) ( (NB_BINS_PER_SM/2) >> 8 ); // BLK_NR MSB
544 header->blkNr[0] =(unsigned char) ( (NB_BINS_PER_SM/2) >> 8 ); // BLK_NR MSB
537 header->blkNr[1] = (unsigned char) (NB_BINS_PER_SM/2); // BLK_NR LSB
545 header->blkNr[1] = (unsigned char) (NB_BINS_PER_SM/2); // BLK_NR LSB
538 // SET PACKET TIME
546 // SET PACKET TIME
539 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
547 header->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
540 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
548 header->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
541 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
549 header->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
542 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
550 header->time[3] = (unsigned char) (time_management_regs->coarse_time);
543 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
551 header->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
544 header->time[5] = (unsigned char) (time_management_regs->fine_time);
552 header->time[5] = (unsigned char) (time_management_regs->fine_time);
545 header->acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
553 header->acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
546 header->acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
554 header->acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
547 header->acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
555 header->acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
548 header->acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
556 header->acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
549 header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
557 header->acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
550 header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
558 header->acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
551 // SEND PACKET
559 // SEND PACKET
552 status = write_spw(spw_ioctl_send);
560 status = rtems_message_queue_send( queue_id, spw_ioctl_send, ACTION_MSG_PKTS_SIZE);
553 if (status != RTEMS_SUCCESSFUL) {
561 if (status != RTEMS_SUCCESSFUL) {
554 while (true) {
562 printf("in send_spectral_matrix *** ERR %d\n", (int) status);
555 if (status != RTEMS_SUCCESSFUL) {
556 status = write_spw(spw_ioctl_send);
557 //PRINTF1("%d", i)
558 sched_yield();
559 }
560 else {
561 //PRINTF("\n")
562 break;
563 }
564 }
565 }
563 }
566 }
564 }
567 }
565 }
568
566
569 void convert_averaged_spectral_matrix( volatile float *input_matrix, char *output_matrix)
567 void convert_averaged_spectral_matrix( volatile float *input_matrix, char *output_matrix)
570 {
568 {
571 unsigned int i;
569 unsigned int i;
572 unsigned int j;
570 unsigned int j;
573 char * pt_char_input;
571 char * pt_char_input;
574 char * pt_char_output;
572 char * pt_char_output;
575
573
576 pt_char_input = NULL;
574 pt_char_input = NULL;
577 pt_char_output = NULL;
575 pt_char_output = NULL;
578
576
579 for( i=0; i<NB_BINS_PER_SM; i++)
577 for( i=0; i<NB_BINS_PER_SM; i++)
580 {
578 {
581 for ( j=0; j<NB_VALUES_PER_SM; j++)
579 for ( j=0; j<NB_VALUES_PER_SM; j++)
582 {
580 {
583 pt_char_input = (char*) &input_matrix[ (i*NB_VALUES_PER_SM) + j ];
581 pt_char_input = (char*) &input_matrix[ (i*NB_VALUES_PER_SM) + j ];
584 pt_char_output = (char*) &output_matrix[ 2 * ( (i*NB_VALUES_PER_SM) + j ) ];
582 pt_char_output = (char*) &output_matrix[ 2 * ( (i*NB_VALUES_PER_SM) + j ) ];
585 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
583 pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float
586 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
584 pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float
587 }
585 }
588 }
586 }
589 }
587 }
590
588
591 void fill_averaged_spectral_matrix( )
589 void fill_averaged_spectral_matrix( )
592 {
590 {
593
591
594 #ifdef GSA
592 #ifdef GSA
595 float offset = 10.;
593 float offset = 10.;
596 float coeff = 100000.;
594 float coeff = 100000.;
597
595
598 averaged_spec_mat_f0[ 0 + 25 * 0 ] = 0. + offset;
596 averaged_spec_mat_f0[ 0 + 25 * 0 ] = 0. + offset;
599 averaged_spec_mat_f0[ 0 + 25 * 1 ] = 1. + offset;
597 averaged_spec_mat_f0[ 0 + 25 * 1 ] = 1. + offset;
600 averaged_spec_mat_f0[ 0 + 25 * 2 ] = 2. + offset;
598 averaged_spec_mat_f0[ 0 + 25 * 2 ] = 2. + offset;
601 averaged_spec_mat_f0[ 0 + 25 * 3 ] = 3. + offset;
599 averaged_spec_mat_f0[ 0 + 25 * 3 ] = 3. + offset;
602 averaged_spec_mat_f0[ 0 + 25 * 4 ] = 4. + offset;
600 averaged_spec_mat_f0[ 0 + 25 * 4 ] = 4. + offset;
603 averaged_spec_mat_f0[ 0 + 25 * 5 ] = 5. + offset;
601 averaged_spec_mat_f0[ 0 + 25 * 5 ] = 5. + offset;
604 averaged_spec_mat_f0[ 0 + 25 * 6 ] = 6. + offset;
602 averaged_spec_mat_f0[ 0 + 25 * 6 ] = 6. + offset;
605 averaged_spec_mat_f0[ 0 + 25 * 7 ] = 7. + offset;
603 averaged_spec_mat_f0[ 0 + 25 * 7 ] = 7. + offset;
606 averaged_spec_mat_f0[ 0 + 25 * 8 ] = 8. + offset;
604 averaged_spec_mat_f0[ 0 + 25 * 8 ] = 8. + offset;
607 averaged_spec_mat_f0[ 0 + 25 * 9 ] = 9. + offset;
605 averaged_spec_mat_f0[ 0 + 25 * 9 ] = 9. + offset;
608 averaged_spec_mat_f0[ 0 + 25 * 10 ] = 10. + offset;
606 averaged_spec_mat_f0[ 0 + 25 * 10 ] = 10. + offset;
609 averaged_spec_mat_f0[ 0 + 25 * 11 ] = 11. + offset;
607 averaged_spec_mat_f0[ 0 + 25 * 11 ] = 11. + offset;
610 averaged_spec_mat_f0[ 0 + 25 * 12 ] = 12. + offset;
608 averaged_spec_mat_f0[ 0 + 25 * 12 ] = 12. + offset;
611 averaged_spec_mat_f0[ 0 + 25 * 13 ] = 13. + offset;
609 averaged_spec_mat_f0[ 0 + 25 * 13 ] = 13. + offset;
612 averaged_spec_mat_f0[ 0 + 25 * 14 ] = 14. + offset;
610 averaged_spec_mat_f0[ 0 + 25 * 14 ] = 14. + offset;
613 averaged_spec_mat_f0[ 9 + 25 * 0 ] = -(0. + offset)* coeff;
611 averaged_spec_mat_f0[ 9 + 25 * 0 ] = -(0. + offset)* coeff;
614 averaged_spec_mat_f0[ 9 + 25 * 1 ] = -(1. + offset)* coeff;
612 averaged_spec_mat_f0[ 9 + 25 * 1 ] = -(1. + offset)* coeff;
615 averaged_spec_mat_f0[ 9 + 25 * 2 ] = -(2. + offset)* coeff;
613 averaged_spec_mat_f0[ 9 + 25 * 2 ] = -(2. + offset)* coeff;
616 averaged_spec_mat_f0[ 9 + 25 * 3 ] = -(3. + offset)* coeff;
614 averaged_spec_mat_f0[ 9 + 25 * 3 ] = -(3. + offset)* coeff;
617 averaged_spec_mat_f0[ 9 + 25 * 4 ] = -(4. + offset)* coeff;
615 averaged_spec_mat_f0[ 9 + 25 * 4 ] = -(4. + offset)* coeff;
618 averaged_spec_mat_f0[ 9 + 25 * 5 ] = -(5. + offset)* coeff;
616 averaged_spec_mat_f0[ 9 + 25 * 5 ] = -(5. + offset)* coeff;
619 averaged_spec_mat_f0[ 9 + 25 * 6 ] = -(6. + offset)* coeff;
617 averaged_spec_mat_f0[ 9 + 25 * 6 ] = -(6. + offset)* coeff;
620 averaged_spec_mat_f0[ 9 + 25 * 7 ] = -(7. + offset)* coeff;
618 averaged_spec_mat_f0[ 9 + 25 * 7 ] = -(7. + offset)* coeff;
621 averaged_spec_mat_f0[ 9 + 25 * 8 ] = -(8. + offset)* coeff;
619 averaged_spec_mat_f0[ 9 + 25 * 8 ] = -(8. + offset)* coeff;
622 averaged_spec_mat_f0[ 9 + 25 * 9 ] = -(9. + offset)* coeff;
620 averaged_spec_mat_f0[ 9 + 25 * 9 ] = -(9. + offset)* coeff;
623 averaged_spec_mat_f0[ 9 + 25 * 10 ] = -(10. + offset)* coeff;
621 averaged_spec_mat_f0[ 9 + 25 * 10 ] = -(10. + offset)* coeff;
624 averaged_spec_mat_f0[ 9 + 25 * 11 ] = -(11. + offset)* coeff;
622 averaged_spec_mat_f0[ 9 + 25 * 11 ] = -(11. + offset)* coeff;
625 averaged_spec_mat_f0[ 9 + 25 * 12 ] = -(12. + offset)* coeff;
623 averaged_spec_mat_f0[ 9 + 25 * 12 ] = -(12. + offset)* coeff;
626 averaged_spec_mat_f0[ 9 + 25 * 13 ] = -(13. + offset)* coeff;
624 averaged_spec_mat_f0[ 9 + 25 * 13 ] = -(13. + offset)* coeff;
627 averaged_spec_mat_f0[ 9 + 25 * 14 ] = -(14. + offset)* coeff;
625 averaged_spec_mat_f0[ 9 + 25 * 14 ] = -(14. + offset)* coeff;
628 offset = 10000000;
626 offset = 10000000;
629 averaged_spec_mat_f0[ 16 + 25 * 0 ] = (0. + offset)* coeff;
627 averaged_spec_mat_f0[ 16 + 25 * 0 ] = (0. + offset)* coeff;
630 averaged_spec_mat_f0[ 16 + 25 * 1 ] = (1. + offset)* coeff;
628 averaged_spec_mat_f0[ 16 + 25 * 1 ] = (1. + offset)* coeff;
631 averaged_spec_mat_f0[ 16 + 25 * 2 ] = (2. + offset)* coeff;
629 averaged_spec_mat_f0[ 16 + 25 * 2 ] = (2. + offset)* coeff;
632 averaged_spec_mat_f0[ 16 + 25 * 3 ] = (3. + offset)* coeff;
630 averaged_spec_mat_f0[ 16 + 25 * 3 ] = (3. + offset)* coeff;
633 averaged_spec_mat_f0[ 16 + 25 * 4 ] = (4. + offset)* coeff;
631 averaged_spec_mat_f0[ 16 + 25 * 4 ] = (4. + offset)* coeff;
634 averaged_spec_mat_f0[ 16 + 25 * 5 ] = (5. + offset)* coeff;
632 averaged_spec_mat_f0[ 16 + 25 * 5 ] = (5. + offset)* coeff;
635 averaged_spec_mat_f0[ 16 + 25 * 6 ] = (6. + offset)* coeff;
633 averaged_spec_mat_f0[ 16 + 25 * 6 ] = (6. + offset)* coeff;
636 averaged_spec_mat_f0[ 16 + 25 * 7 ] = (7. + offset)* coeff;
634 averaged_spec_mat_f0[ 16 + 25 * 7 ] = (7. + offset)* coeff;
637 averaged_spec_mat_f0[ 16 + 25 * 8 ] = (8. + offset)* coeff;
635 averaged_spec_mat_f0[ 16 + 25 * 8 ] = (8. + offset)* coeff;
638 averaged_spec_mat_f0[ 16 + 25 * 9 ] = (9. + offset)* coeff;
636 averaged_spec_mat_f0[ 16 + 25 * 9 ] = (9. + offset)* coeff;
639 averaged_spec_mat_f0[ 16 + 25 * 10 ] = (10. + offset)* coeff;
637 averaged_spec_mat_f0[ 16 + 25 * 10 ] = (10. + offset)* coeff;
640 averaged_spec_mat_f0[ 16 + 25 * 11 ] = (11. + offset)* coeff;
638 averaged_spec_mat_f0[ 16 + 25 * 11 ] = (11. + offset)* coeff;
641 averaged_spec_mat_f0[ 16 + 25 * 12 ] = (12. + offset)* coeff;
639 averaged_spec_mat_f0[ 16 + 25 * 12 ] = (12. + offset)* coeff;
642 averaged_spec_mat_f0[ 16 + 25 * 13 ] = (13. + offset)* coeff;
640 averaged_spec_mat_f0[ 16 + 25 * 13 ] = (13. + offset)* coeff;
643 averaged_spec_mat_f0[ 16 + 25 * 14 ] = (14. + offset)* coeff;
641 averaged_spec_mat_f0[ 16 + 25 * 14 ] = (14. + offset)* coeff;
644
642
645 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 0 ] = averaged_spec_mat_f0[ 0 ];
643 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 0 ] = averaged_spec_mat_f0[ 0 ];
646 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 1 ] = averaged_spec_mat_f0[ 1 ];
644 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 1 ] = averaged_spec_mat_f0[ 1 ];
647 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 2 ] = averaged_spec_mat_f0[ 2 ];
645 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 2 ] = averaged_spec_mat_f0[ 2 ];
648 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 3 ] = averaged_spec_mat_f0[ 3 ];
646 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 3 ] = averaged_spec_mat_f0[ 3 ];
649 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 4 ] = averaged_spec_mat_f0[ 4 ];
647 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 4 ] = averaged_spec_mat_f0[ 4 ];
650 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 5 ] = averaged_spec_mat_f0[ 5 ];
648 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 5 ] = averaged_spec_mat_f0[ 5 ];
651 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 6 ] = averaged_spec_mat_f0[ 6 ];
649 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 6 ] = averaged_spec_mat_f0[ 6 ];
652 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 7 ] = averaged_spec_mat_f0[ 7 ];
650 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 7 ] = averaged_spec_mat_f0[ 7 ];
653 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 8 ] = averaged_spec_mat_f0[ 8 ];
651 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 8 ] = averaged_spec_mat_f0[ 8 ];
654 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 9 ] = averaged_spec_mat_f0[ 9 ];
652 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 9 ] = averaged_spec_mat_f0[ 9 ];
655 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 10 ] = averaged_spec_mat_f0[ 10 ];
653 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 10 ] = averaged_spec_mat_f0[ 10 ];
656 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 11 ] = averaged_spec_mat_f0[ 11 ];
654 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 11 ] = averaged_spec_mat_f0[ 11 ];
657 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 12 ] = averaged_spec_mat_f0[ 12 ];
655 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 12 ] = averaged_spec_mat_f0[ 12 ];
658 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 13 ] = averaged_spec_mat_f0[ 13 ];
656 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 13 ] = averaged_spec_mat_f0[ 13 ];
659 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 14 ] = averaged_spec_mat_f0[ 14 ];
657 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 14 ] = averaged_spec_mat_f0[ 14 ];
660 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 15 ] = averaged_spec_mat_f0[ 15 ];
658 averaged_spec_mat_f0[ (TOTAL_SIZE_SM/2) + 15 ] = averaged_spec_mat_f0[ 15 ];
661 #else
659 #else
662 unsigned int i;
660 unsigned int i;
663
661
664 for(i=0; i<TOTAL_SIZE_SM; i++)
662 for(i=0; i<TOTAL_SIZE_SM; i++)
665 {
663 {
666 if (spectral_matrix_regs->matrixF0_Address0 == (int) spec_mat_f0_0)
664 if (spectral_matrix_regs->matrixF0_Address0 == (int) spec_mat_f0_0)
667 averaged_spec_mat_f0[i] = (float) spec_mat_f0_0_bis[ SM_HEADER + i ];
665 averaged_spec_mat_f0[i] = (float) spec_mat_f0_0_bis[ SM_HEADER + i ];
668 else
666 else
669 averaged_spec_mat_f0[i] = (float) spec_mat_f0_0[ SM_HEADER + i ];
667 averaged_spec_mat_f0[i] = (float) spec_mat_f0_0[ SM_HEADER + i ];
670 }
668 }
671 #endif
669 #endif
672 }
670 }
673
671
674 void reset_spectral_matrix_regs()
672 void reset_spectral_matrix_regs()
675 {
673 {
676 #ifdef GSA
674 #ifdef GSA
677 #else
675 #else
678 spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0;
676 spectral_matrix_regs->matrixF0_Address0 = (int) spec_mat_f0_0;
679 spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1;
677 spectral_matrix_regs->matrixFO_Address1 = (int) spec_mat_f0_1;
680 spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1;
678 spectral_matrix_regs->matrixF1_Address = (int) spec_mat_f1;
681 spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2;
679 spectral_matrix_regs->matrixF2_Address = (int) spec_mat_f2;
682 #endif
680 #endif
683 }
681 }
684
682
685 //******************
683 //******************
686 // general functions
684 // general functions
687
685
688
686
689
687
690
688
@@ -1,1340 +1,1414
1 #include <tc_handler.h>
1 #include <tc_handler.h>
2 #include <fsw_params.h>
2 #include <fsw_params.h>
3
3
4 char *DumbMessages[6] = {"in DUMB *** default", // RTEMS_EVENT_0
4 char *DumbMessages[6] = {"in DUMB *** default", // RTEMS_EVENT_0
5 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
5 "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1
6 "in DUMB *** waveforms_isr", // RTEMS_EVENT_2
6 "in DUMB *** waveforms_isr", // RTEMS_EVENT_2
7 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
7 "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3
8 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
8 "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4
9 "in DUMB *** waveforms_simulator_isr" // RTEMS_EVENT_5
9 "in DUMB *** waveforms_simulator_isr" // RTEMS_EVENT_5
10 };
10 };
11
11
12 unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field
12 unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field
13 unsigned char currentTC_COMPUTED_CRC[2];
13 unsigned char currentTC_COMPUTED_CRC[2];
14 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
14 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
15 unsigned int currentTM_length;
15 unsigned int currentTM_length;
16 unsigned char currentTC_processedFlag;
16 unsigned char currentTC_processedFlag;
17
17
18 unsigned int lookUpTableForCRC[256];
18 unsigned int lookUpTableForCRC[256];
19
19
20 //**********************
20 //**********************
21 // GENERAL USE FUNCTIONS
21 // GENERAL USE FUNCTIONS
22 unsigned int Crc_opt( unsigned char D, unsigned int Chk)
22 unsigned int Crc_opt( unsigned char D, unsigned int Chk)
23 {
23 {
24 return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]);
24 return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]);
25 }
25 }
26
26
27 void initLookUpTableForCRC( void )
27 void initLookUpTableForCRC( void )
28 {
28 {
29 unsigned int i;
29 unsigned int i;
30 unsigned int tmp;
30 unsigned int tmp;
31
31
32 for (i=0; i<256; i++)
32 for (i=0; i<256; i++)
33 {
33 {
34 tmp = 0;
34 tmp = 0;
35 if((i & 1) != 0) {
35 if((i & 1) != 0) {
36 tmp = tmp ^ 0x1021;
36 tmp = tmp ^ 0x1021;
37 }
37 }
38 if((i & 2) != 0) {
38 if((i & 2) != 0) {
39 tmp = tmp ^ 0x2042;
39 tmp = tmp ^ 0x2042;
40 }
40 }
41 if((i & 4) != 0) {
41 if((i & 4) != 0) {
42 tmp = tmp ^ 0x4084;
42 tmp = tmp ^ 0x4084;
43 }
43 }
44 if((i & 8) != 0) {
44 if((i & 8) != 0) {
45 tmp = tmp ^ 0x8108;
45 tmp = tmp ^ 0x8108;
46 }
46 }
47 if((i & 16) != 0) {
47 if((i & 16) != 0) {
48 tmp = tmp ^ 0x1231;
48 tmp = tmp ^ 0x1231;
49 }
49 }
50 if((i & 32) != 0) {
50 if((i & 32) != 0) {
51 tmp = tmp ^ 0x2462;
51 tmp = tmp ^ 0x2462;
52 }
52 }
53 if((i & 64) != 0) {
53 if((i & 64) != 0) {
54 tmp = tmp ^ 0x48c4;
54 tmp = tmp ^ 0x48c4;
55 }
55 }
56 if((i & 128) != 0) {
56 if((i & 128) != 0) {
57 tmp = tmp ^ 0x9188;
57 tmp = tmp ^ 0x9188;
58 }
58 }
59 lookUpTableForCRC[i] = tmp;
59 lookUpTableForCRC[i] = tmp;
60 }
60 }
61 }
61 }
62
62
63 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData)
63 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData)
64 {
64 {
65 unsigned int Chk;
65 unsigned int Chk;
66 int j;
66 int j;
67 Chk = 0xffff; // reset the syndrom to all ones
67 Chk = 0xffff; // reset the syndrom to all ones
68 for (j=0; j<sizeOfData; j++) {
68 for (j=0; j<sizeOfData; j++) {
69 Chk = Crc_opt(data[j], Chk);
69 Chk = Crc_opt(data[j], Chk);
70 }
70 }
71 crcAsTwoBytes[0] = (unsigned char) (Chk >> 8);
71 crcAsTwoBytes[0] = (unsigned char) (Chk >> 8);
72 crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff);
72 crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff);
73 }
73 }
74
74
75 void updateLFRCurrentMode()
75 void updateLFRCurrentMode()
76 {
76 {
77 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
77 lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
78 }
78 }
79
79
80 //*********************
80 //*********************
81 // ACCEPTANCE FUNCTIONS
81 // ACCEPTANCE FUNCTIONS
82 int TC_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv)
82 int TC_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv, rtems_id queue_id)
83 {
83 {
84 int ret = 0;
84 int ret = 0;
85 rtems_status_code status;
85 rtems_status_code status;
86 Packet_TM_LFR_TC_EXE_CORRUPTED_t packet;
86 Packet_TM_LFR_TC_EXE_CORRUPTED_t packet;
87 unsigned int parserCode = 0;
87 unsigned int parserCode = 0;
88 unsigned char computed_CRC[2];
88 unsigned char computed_CRC[2];
89 unsigned int packetLength;
89 unsigned int packetLength;
90
90
91 GetCRCAsTwoBytes( (unsigned char*) TC->packetID, computed_CRC, tc_len_recv + 5 );
91 GetCRCAsTwoBytes( (unsigned char*) TC->packetID, computed_CRC, tc_len_recv + 5 );
92 parserCode = TC_parser( TC, tc_len_recv ) ;
92 parserCode = TC_parser( TC, tc_len_recv ) ;
93 if ( (parserCode == ILLEGAL_APID) | (parserCode == WRONG_LEN_PACKET) | (parserCode == INCOR_CHECKSUM)
93 if ( (parserCode == ILLEGAL_APID) | (parserCode == WRONG_LEN_PACKET) | (parserCode == INCOR_CHECKSUM)
94 | (parserCode == ILL_TYPE) | (parserCode == ILL_SUBTYPE) | (parserCode == WRONG_APP_DATA) )
94 | (parserCode == ILL_TYPE) | (parserCode == ILL_SUBTYPE) | (parserCode == WRONG_APP_DATA) )
95 { // generate TM_LFR_TC_EXE_CORRUPTED
95 { // generate TM_LFR_TC_EXE_CORRUPTED
96 packetLength = (TC->packetLength[0] * 256) + TC->packetLength[1];
96 packetLength = (TC->packetLength[0] * 256) + TC->packetLength[1];
97 packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
97 packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
98 packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
98 packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
99 packet.reserved = DEFAULT_RESERVED;
99 packet.reserved = DEFAULT_RESERVED;
100 packet.userApplication = CCSDS_USER_APP;
100 packet.userApplication = CCSDS_USER_APP;
101 // PACKET HEADER
101 // PACKET HEADER
102 packet.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
102 packet.packetID[0] = (unsigned char) (TM_PACKET_ID_TC_EXE >> 8);
103 packet.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
103 packet.packetID[1] = (unsigned char) (TM_PACKET_ID_TC_EXE );
104 packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
104 packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE;
105 packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
105 packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
106 packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED >> 8);
106 packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED >> 8);
107 packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED );
107 packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_EXE_CORRUPTED );
108 // DATA FIELD HEADER
108 // DATA FIELD HEADER
109 packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
109 packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
110 packet.serviceType = TM_TYPE_TC_EXE;
110 packet.serviceType = TM_TYPE_TC_EXE;
111 packet.serviceSubType = TM_SUBTYPE_EXE_NOK;
111 packet.serviceSubType = TM_SUBTYPE_EXE_NOK;
112 packet.destinationID = TM_DESTINATION_ID_GROUND;
112 packet.destinationID = TM_DESTINATION_ID_GROUND;
113 packet.time[0] = (time_management_regs->coarse_time>>24 );
113 packet.time[0] = (time_management_regs->coarse_time>>24 );
114 packet.time[1] = (time_management_regs->coarse_time>>16 );
114 packet.time[1] = (time_management_regs->coarse_time>>16 );
115 packet.time[2] = (time_management_regs->coarse_time>>8 );
115 packet.time[2] = (time_management_regs->coarse_time>>8 );
116 packet.time[3] = (time_management_regs->coarse_time );
116 packet.time[3] = (time_management_regs->coarse_time );
117 packet.time[4] = (time_management_regs->fine_time>>8 );
117 packet.time[4] = (time_management_regs->fine_time>>8 );
118 packet.time[5] = (time_management_regs->fine_time );
118 packet.time[5] = (time_management_regs->fine_time );
119 //
119 //
120 packet.tc_failure_code[0] = (unsigned char) (FAILURE_CODE_CORRUPTED >> 8);
120 packet.tc_failure_code[0] = (unsigned char) (FAILURE_CODE_CORRUPTED >> 8);
121 packet.tc_failure_code[1] = (unsigned char) (FAILURE_CODE_CORRUPTED );
121 packet.tc_failure_code[1] = (unsigned char) (FAILURE_CODE_CORRUPTED );
122 packet.telecommand_pkt_id[0] = TC->packetID[0];
122 packet.telecommand_pkt_id[0] = TC->packetID[0];
123 packet.telecommand_pkt_id[1] = TC->packetID[1];
123 packet.telecommand_pkt_id[1] = TC->packetID[1];
124 packet.pkt_seq_control[0] = TC->packetSequenceControl[0];
124 packet.pkt_seq_control[0] = TC->packetSequenceControl[0];
125 packet.pkt_seq_control[0] = TC->packetSequenceControl[1];
125 packet.pkt_seq_control[0] = TC->packetSequenceControl[1];
126 packet.tc_service = TC->serviceType;
126 packet.tc_service = TC->serviceType;
127 packet.tc_subtype = TC->serviceSubType;
127 packet.tc_subtype = TC->serviceSubType;
128 packet.pkt_len_rcv_value[0] = TC->packetLength[0];
128 packet.pkt_len_rcv_value[0] = TC->packetLength[0];
129 packet.pkt_len_rcv_value[1] = TC->packetLength[1];
129 packet.pkt_len_rcv_value[1] = TC->packetLength[1];
130 packet.pkt_datafieldsize_cnt[0] = currentTC_LEN_RCV[0];
130 packet.pkt_datafieldsize_cnt[0] = currentTC_LEN_RCV[0];
131 packet.pkt_datafieldsize_cnt[1] = currentTC_LEN_RCV[1];
131 packet.pkt_datafieldsize_cnt[1] = currentTC_LEN_RCV[1];
132 packet.rcv_crc[0] = TC->dataAndCRC[packetLength];
132 packet.rcv_crc[0] = TC->dataAndCRC[packetLength];
133 packet.rcv_crc[1] = TC->dataAndCRC[packetLength];
133 packet.rcv_crc[1] = TC->dataAndCRC[packetLength];
134 packet.computed_crc[0] = computed_CRC[0];
134 packet.computed_crc[0] = computed_CRC[0];
135 packet.computed_crc[1] = computed_CRC[1];
135 packet.computed_crc[1] = computed_CRC[1];
136 // SEND PACKET
136 // SEND PACKET
137 status = write( fdSPW, (char *) &packet, PACKET_LENGTH_TC_EXE_CORRUPTED + CCSDS_TC_TM_PACKET_OFFSET + 4);
137 status = write( fdSPW, (char *) &packet, PACKET_LENGTH_TC_EXE_CORRUPTED + CCSDS_TC_TM_PACKET_OFFSET + 4);
138 }
138 }
139 else { // send valid TC to the action launcher
139 else { // send valid TC to the action launcher
140 status = rtems_message_queue_send( misc_id[QUEUE_QUEU], TC, tc_len_recv + CCSDS_TC_TM_PACKET_OFFSET + 3);
140 status = rtems_message_queue_send( queue_id, TC, tc_len_recv + CCSDS_TC_TM_PACKET_OFFSET + 3);
141 ret = -1;
141 ret = -1;
142 }
142 }
143 return ret;
143 return ret;
144 }
144 }
145
145
146 unsigned char TC_parser(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV)
146 unsigned char TC_parser(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV)
147 {
147 {
148 unsigned char ret = 0;
148 unsigned char ret = 0;
149 unsigned char pid = 0;
149 unsigned char pid = 0;
150 unsigned char category = 0;
150 unsigned char category = 0;
151 unsigned int length = 0;
151 unsigned int length = 0;
152 unsigned char packetType = 0;
152 unsigned char packetType = 0;
153 unsigned char packetSubtype = 0;
153 unsigned char packetSubtype = 0;
154 unsigned char * CCSDSContent = NULL;
154 unsigned char * CCSDSContent = NULL;
155
155
156 // APID check *** APID on 2 bytes
156 // APID check *** APID on 2 bytes
157 pid = ((TMPacket->packetID[0] & 0x07)<<4) + ( (TMPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx
157 pid = ((TMPacket->packetID[0] & 0x07)<<4) + ( (TMPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx
158 category = (TMPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210
158 category = (TMPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210
159 length = (TMPacket->packetLength[0] * 256) + TMPacket->packetLength[1];
159 length = (TMPacket->packetLength[0] * 256) + TMPacket->packetLength[1];
160 packetType = TMPacket->serviceType;
160 packetType = TMPacket->serviceType;
161 packetSubtype = TMPacket->serviceSubType;
161 packetSubtype = TMPacket->serviceSubType;
162
162
163 if ( pid != CCSDS_PROCESS_ID ) {
163 if ( pid != CCSDS_PROCESS_ID ) {
164 ret = ILLEGAL_APID;
164 ret = ILLEGAL_APID;
165 }
165 }
166 else if ( category != CCSDS_PACKET_CATEGORY ) {
166 else if ( category != CCSDS_PACKET_CATEGORY ) {
167 ret = ILLEGAL_APID;
167 ret = ILLEGAL_APID;
168 }
168 }
169 else if (length != TC_LEN_RCV ) { // packet length check
169 else if (length != TC_LEN_RCV ) { // packet length check
170 ret = WRONG_LEN_PACKET; // LEN RCV != SIZE FIELD
170 ret = WRONG_LEN_PACKET; // LEN RCV != SIZE FIELD
171 }
171 }
172 else if ( length >= CCSDS_TC_PKT_MAX_SIZE ) {
172 else if ( length >= CCSDS_TC_PKT_MAX_SIZE ) {
173 ret = WRONG_LEN_PACKET; // check that the packet does not exceed the MAX size
173 ret = WRONG_LEN_PACKET; // check that the packet does not exceed the MAX size
174 }
174 }
175 else if ( packetType == TC_TYPE_GEN ){ // service type, subtype and packet length check
175 else if ( packetType == TC_TYPE_GEN ){ // service type, subtype and packet length check
176 switch(packetSubtype){ //subtype, autorized values are 3, 20, 21, 24, 27, 28, 30, 40, 50, 60, 61
176 switch(packetSubtype){ //subtype, autorized values are 3, 20, 21, 24, 27, 28, 30, 40, 50, 60, 61
177 case TC_SUBTYPE_RESET:
177 case TC_SUBTYPE_RESET:
178 if (length!=(TC_LEN_RESET-CCSDS_TC_TM_PACKET_OFFSET)) {
178 if (length!=(TC_LEN_RESET-CCSDS_TC_TM_PACKET_OFFSET)) {
179 ret = WRONG_LEN_PACKET;
179 ret = WRONG_LEN_PACKET;
180 }
180 }
181 else {
181 else {
182 ret = CCSDS_TM_VALID;
182 ret = CCSDS_TM_VALID;
183 }
183 }
184 break;
184 break;
185 case TC_SUBTYPE_LOAD_COMM:
185 case TC_SUBTYPE_LOAD_COMM:
186 if (length!=(TC_LEN_LOAD_COMM-CCSDS_TC_TM_PACKET_OFFSET)) {
186 if (length!=(TC_LEN_LOAD_COMM-CCSDS_TC_TM_PACKET_OFFSET)) {
187 ret = WRONG_LEN_PACKET;
187 ret = WRONG_LEN_PACKET;
188 }
188 }
189 else {
189 else {
190 ret = CCSDS_TM_VALID;
190 ret = CCSDS_TM_VALID;
191 }
191 }
192 break;
192 break;
193 case TC_SUBTYPE_LOAD_NORM:
193 case TC_SUBTYPE_LOAD_NORM:
194 if (length!=(TC_LEN_LOAD_NORM-CCSDS_TC_TM_PACKET_OFFSET)) {
194 if (length!=(TC_LEN_LOAD_NORM-CCSDS_TC_TM_PACKET_OFFSET)) {
195 ret = WRONG_LEN_PACKET;
195 ret = WRONG_LEN_PACKET;
196 }
196 }
197 else {
197 else {
198 ret = CCSDS_TM_VALID;
198 ret = CCSDS_TM_VALID;
199 }
199 }
200 break;
200 break;
201 case TC_SUBTYPE_LOAD_BURST:
201 case TC_SUBTYPE_LOAD_BURST:
202 if (length!=(TC_LEN_LOAD_BURST-CCSDS_TC_TM_PACKET_OFFSET)) {
202 if (length!=(TC_LEN_LOAD_BURST-CCSDS_TC_TM_PACKET_OFFSET)) {
203 ret = WRONG_LEN_PACKET;
203 ret = WRONG_LEN_PACKET;
204 }
204 }
205 else {
205 else {
206 ret = CCSDS_TM_VALID;
206 ret = CCSDS_TM_VALID;
207 }
207 }
208 break;
208 break;
209 case TC_SUBTYPE_LOAD_SBM1:
209 case TC_SUBTYPE_LOAD_SBM1:
210 if (length!=(TC_LEN_LOAD_SBM1-CCSDS_TC_TM_PACKET_OFFSET)) {
210 if (length!=(TC_LEN_LOAD_SBM1-CCSDS_TC_TM_PACKET_OFFSET)) {
211 ret = WRONG_LEN_PACKET;
211 ret = WRONG_LEN_PACKET;
212 }
212 }
213 else {
213 else {
214 ret = CCSDS_TM_VALID;
214 ret = CCSDS_TM_VALID;
215 }
215 }
216 break;
216 break;
217 case TC_SUBTYPE_LOAD_SBM2:
217 case TC_SUBTYPE_LOAD_SBM2:
218 if (length!=(TC_LEN_LOAD_SBM2-CCSDS_TC_TM_PACKET_OFFSET)) {
218 if (length!=(TC_LEN_LOAD_SBM2-CCSDS_TC_TM_PACKET_OFFSET)) {
219 ret = WRONG_LEN_PACKET;
219 ret = WRONG_LEN_PACKET;
220 }
220 }
221 else {
221 else {
222 ret = CCSDS_TM_VALID;
222 ret = CCSDS_TM_VALID;
223 }
223 }
224 break;
224 break;
225 case TC_SUBTYPE_DUMP:
225 case TC_SUBTYPE_DUMP:
226 if (length!=(TC_LEN_DUMP-CCSDS_TC_TM_PACKET_OFFSET)) {
226 if (length!=(TC_LEN_DUMP-CCSDS_TC_TM_PACKET_OFFSET)) {
227 ret = WRONG_LEN_PACKET;
227 ret = WRONG_LEN_PACKET;
228 }
228 }
229 else {
229 else {
230 ret = CCSDS_TM_VALID;
230 ret = CCSDS_TM_VALID;
231 }
231 }
232 break;
232 break;
233 case TC_SUBTYPE_ENTER:
233 case TC_SUBTYPE_ENTER:
234 if (length!=(TC_LEN_ENTER-CCSDS_TC_TM_PACKET_OFFSET)) {
234 if (length!=(TC_LEN_ENTER-CCSDS_TC_TM_PACKET_OFFSET)) {
235 ret = WRONG_LEN_PACKET;
235 ret = WRONG_LEN_PACKET;
236 }
236 }
237 else {
237 else {
238 ret = CCSDS_TM_VALID;
238 ret = CCSDS_TM_VALID;
239 }
239 }
240 break;
240 break;
241 case TC_SUBTYPE_UPDT_INFO:
241 case TC_SUBTYPE_UPDT_INFO:
242 if (length!=(TC_LEN_UPDT_INFO-CCSDS_TC_TM_PACKET_OFFSET)) {
242 if (length!=(TC_LEN_UPDT_INFO-CCSDS_TC_TM_PACKET_OFFSET)) {
243 ret = WRONG_LEN_PACKET;
243 ret = WRONG_LEN_PACKET;
244 }
244 }
245 else {
245 else {
246 ret = CCSDS_TM_VALID;
246 ret = CCSDS_TM_VALID;
247 }
247 }
248 break;
248 break;
249 case TC_SUBTYPE_EN_CAL:
249 case TC_SUBTYPE_EN_CAL:
250 if (length!=(TC_LEN_EN_CAL-CCSDS_TC_TM_PACKET_OFFSET)) {
250 if (length!=(TC_LEN_EN_CAL-CCSDS_TC_TM_PACKET_OFFSET)) {
251 ret = WRONG_LEN_PACKET;
251 ret = WRONG_LEN_PACKET;
252 }
252 }
253 else {
253 else {
254 ret = CCSDS_TM_VALID;
254 ret = CCSDS_TM_VALID;
255 }
255 }
256 break;
256 break;
257 case TC_SUBTYPE_DIS_CAL:
257 case TC_SUBTYPE_DIS_CAL:
258 if (length!=(TC_LEN_DIS_CAL-CCSDS_TC_TM_PACKET_OFFSET)) {
258 if (length!=(TC_LEN_DIS_CAL-CCSDS_TC_TM_PACKET_OFFSET)) {
259 ret = WRONG_LEN_PACKET;
259 ret = WRONG_LEN_PACKET;
260 }
260 }
261 else {
261 else {
262 ret = CCSDS_TM_VALID;
262 ret = CCSDS_TM_VALID;
263 }
263 }
264 break;
264 break;
265 default:
265 default:
266 ret = ILL_SUBTYPE;
266 ret = ILL_SUBTYPE;
267 break;
267 break;
268 }
268 }
269 }
269 }
270 else if ( packetType == TC_TYPE_TIME ){
270 else if ( packetType == TC_TYPE_TIME ){
271 if (packetSubtype!=TC_SUBTYPE_UPDT_TIME) {
271 if (packetSubtype!=TC_SUBTYPE_UPDT_TIME) {
272 ret = ILL_SUBTYPE;
272 ret = ILL_SUBTYPE;
273 }
273 }
274 else if (length!=(TC_LEN_UPDT_TIME-CCSDS_TC_TM_PACKET_OFFSET)) {
274 else if (length!=(TC_LEN_UPDT_TIME-CCSDS_TC_TM_PACKET_OFFSET)) {
275 ret = WRONG_LEN_PACKET;
275 ret = WRONG_LEN_PACKET;
276 }
276 }
277 else {
277 else {
278 ret = CCSDS_TM_VALID;
278 ret = CCSDS_TM_VALID;
279 }
279 }
280 }
280 }
281 else {
281 else {
282 ret = ILL_TYPE;
282 ret = ILL_TYPE;
283 }
283 }
284
284
285 // source ID check // Source ID not documented in the ICD
285 // source ID check // Source ID not documented in the ICD
286
286
287 // packet error control, CRC check
287 // packet error control, CRC check
288 if ( ret == CCSDS_TM_VALID ) {
288 if ( ret == CCSDS_TM_VALID ) {
289 CCSDSContent = (unsigned char*) TMPacket->packetID;
289 CCSDSContent = (unsigned char*) TMPacket->packetID;
290 GetCRCAsTwoBytes(CCSDSContent, currentTC_COMPUTED_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC
290 GetCRCAsTwoBytes(CCSDSContent, currentTC_COMPUTED_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC
291 if (currentTC_COMPUTED_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) {
291 if (currentTC_COMPUTED_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) {
292 ret = INCOR_CHECKSUM;
292 ret = INCOR_CHECKSUM;
293 }
293 }
294 else if (currentTC_COMPUTED_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) {
294 else if (currentTC_COMPUTED_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) {
295 ret = INCOR_CHECKSUM;
295 ret = INCOR_CHECKSUM;
296 }
296 }
297 else {
297 else {
298 ret = CCSDS_TM_VALID;
298 ret = CCSDS_TM_VALID;
299 }
299 }
300 }
300 }
301
301
302 return ret;
302 return ret;
303 }
303 }
304
304
305 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
305 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
306 TMHeader_t *TMHeader, unsigned char tc_sid)
306 TMHeader_t *TMHeader, unsigned char tc_sid)
307 {
307 {
308 TMHeader->targetLogicalAddress = CCSDS_DESTINATION_ID;
308 TMHeader->targetLogicalAddress = CCSDS_DESTINATION_ID;
309 TMHeader->protocolIdentifier = CCSDS_PROTOCOLE_ID;
309 TMHeader->protocolIdentifier = CCSDS_PROTOCOLE_ID;
310 TMHeader->reserved = 0x00;
310 TMHeader->reserved = 0x00;
311 TMHeader->userApplication = 0x00;
311 TMHeader->userApplication = 0x00;
312 TMHeader->packetID[0] = 0x0c;
312 TMHeader->packetID[0] = 0x0c;
313 TMHeader->packetSequenceControl[0] = 0xc0;
313 TMHeader->packetSequenceControl[0] = 0xc0;
314 TMHeader->packetSequenceControl[1] = 0x00;
314 TMHeader->packetSequenceControl[1] = 0x00;
315 TMHeader->packetLength[0] = (unsigned char) (packetLength>>8);
315 TMHeader->packetLength[0] = (unsigned char) (packetLength>>8);
316 TMHeader->packetLength[1] = (unsigned char) packetLength;
316 TMHeader->packetLength[1] = (unsigned char) packetLength;
317 TMHeader->spare1_pusVersion_spare2 = 0x10;
317 TMHeader->spare1_pusVersion_spare2 = 0x10;
318 TMHeader->destinationID = TM_DESTINATION_ID_GROUND; // default destination id
318 TMHeader->destinationID = TM_DESTINATION_ID_GROUND; // default destination id
319 switch (tm_type){
319 switch (tm_type){
320 case(TM_LFR_TC_EXE_OK):
320 case(TM_LFR_TC_EXE_OK):
321 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_TC_EXE;
321 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_TC_EXE;
322 TMHeader->serviceType = TM_TYPE_TC_EXE; // type
322 TMHeader->serviceType = TM_TYPE_TC_EXE; // type
323 TMHeader->serviceSubType = TM_SUBTYPE_EXE_OK; // subtype
323 TMHeader->serviceSubType = TM_SUBTYPE_EXE_OK; // subtype
324 TMHeader->destinationID = tc_sid; // destination id
324 TMHeader->destinationID = tc_sid; // destination id
325 break;
325 break;
326 case(TM_LFR_TC_EXE_ERR):
326 case(TM_LFR_TC_EXE_ERR):
327 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_TC_EXE;
327 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_TC_EXE;
328 TMHeader->serviceType = TM_TYPE_TC_EXE; // type
328 TMHeader->serviceType = TM_TYPE_TC_EXE; // type
329 TMHeader->serviceSubType = TM_SUBTYPE_EXE_NOK; // subtype
329 TMHeader->serviceSubType = TM_SUBTYPE_EXE_NOK; // subtype
330 TMHeader->destinationID = tc_sid;
330 TMHeader->destinationID = tc_sid;
331 break;
331 break;
332 case(TM_LFR_HK):
332 case(TM_LFR_HK):
333 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_HK;
333 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_HK;
334 TMHeader->serviceType = TM_TYPE_HK; // type
334 TMHeader->serviceType = TM_TYPE_HK; // type
335 TMHeader->serviceSubType = TM_SUBTYPE_HK; // subtype
335 TMHeader->serviceSubType = TM_SUBTYPE_HK; // subtype
336 break;
336 break;
337 case(TM_LFR_SCI):
337 case(TM_LFR_SCI):
338 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_SCIENCE_NORMAL_BURST;
338 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_SCIENCE_NORMAL_BURST;
339 TMHeader->serviceType = TM_TYPE_LFR_SCIENCE; // type
339 TMHeader->serviceType = TM_TYPE_LFR_SCIENCE; // type
340 TMHeader->serviceSubType = TM_SUBTYPE_SCIENCE; // subtype
340 TMHeader->serviceSubType = TM_SUBTYPE_SCIENCE; // subtype
341 break;
341 break;
342 case(TM_LFR_SCI_SBM):
342 case(TM_LFR_SCI_SBM):
343 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_SCIENCE_SBM1_SBM2;
343 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_SCIENCE_SBM1_SBM2;
344 TMHeader->serviceType = TM_TYPE_LFR_SCIENCE; // type
344 TMHeader->serviceType = TM_TYPE_LFR_SCIENCE; // type
345 TMHeader->serviceSubType = TM_SUBTYPE_SCIENCE; // subtype
345 TMHeader->serviceSubType = TM_SUBTYPE_SCIENCE; // subtype
346 break;
346 break;
347 case(TM_LFR_PAR_DUMP):
347 case(TM_LFR_PAR_DUMP):
348 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP;
348 TMHeader->packetID[1] = (unsigned char) TM_PACKET_ID_PARAMETER_DUMP;
349 TMHeader->serviceType = TM_TYPE_HK; // type
349 TMHeader->serviceType = TM_TYPE_HK; // type
350 TMHeader->serviceSubType = TM_SUBTYPE_HK; // subtype
350 TMHeader->serviceSubType = TM_SUBTYPE_HK; // subtype
351 break;
351 break;
352 default:
352 default:
353 return 0;
353 return 0;
354 }
354 }
355 TMHeader->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
355 TMHeader->time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
356 TMHeader->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
356 TMHeader->time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
357 TMHeader->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
357 TMHeader->time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
358 TMHeader->time[3] = (unsigned char) (time_management_regs->coarse_time);
358 TMHeader->time[3] = (unsigned char) (time_management_regs->coarse_time);
359 TMHeader->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
359 TMHeader->time[4] = (unsigned char) (time_management_regs->fine_time>>8);
360 TMHeader->time[5] = (unsigned char) (time_management_regs->fine_time);
360 TMHeader->time[5] = (unsigned char) (time_management_regs->fine_time);
361
361
362 return LFR_SUCCESSFUL;
362 return LFR_SUCCESSFUL;
363 }
363 }
364
364
365 //***********
365 //***********
366 // RTEMS TASK
366 // RTEMS TASK
367 rtems_task recv_task( rtems_task_argument unused )
367 rtems_task recv_task( rtems_task_argument unused )
368 {
368 {
369 int len = 0;
369 int len = 0;
370 unsigned int i = 0;
370 unsigned int i = 0;
371 unsigned int data_length = 0;
371 unsigned int data_length = 0;
372 ccsdsTelecommandPacket_t currentTC;
372 ccsdsTelecommandPacket_t currentTC;
373 char data[100];
373 char data[100];
374 rtems_status_code status;
375 rtems_id queue_id;
374
376
375 for(i=0; i<100; i++) data[i] = 0;
377 for(i=0; i<100; i++) data[i] = 0;
376
378
377 PRINTF("in RECV *** \n")
379 status = rtems_message_queue_ident( misc_name[QUEUE_QUEU], 0, &queue_id );
380 if (status != RTEMS_SUCCESSFUL)
381 {
382 PRINTF1("in RECV *** ERR getting queue id, %d\n", status)
383 }
384
385 BOOT_PRINTF("in RECV *** \n")
378
386
379 while(1)
387 while(1)
380 {
388 {
381 len = read(fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE); // the call to read is blocking
389 len = read(fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE); // the call to read is blocking
382 if (len == -1){ // error during the read call
390 if (len == -1){ // error during the read call
383 PRINTF("In RECV *** last read call returned -1\n")
391 PRINTF("In RECV *** last read call returned -1\n")
384 //if (rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ) != RTEMS_SUCCESSFUL) {
392 //if (rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ) != RTEMS_SUCCESSFUL) {
385 // PRINTF("IN RECV *** Error: rtems_event_send SPW_LINKERR_EVENT\n")
393 // PRINTF("IN RECV *** Error: rtems_event_send SPW_LINKERR_EVENT\n")
386 //}
394 //}
387 //if (rtems_task_suspend(RTEMS_SELF) != RTEMS_SUCCESSFUL) {
395 //if (rtems_task_suspend(RTEMS_SELF) != RTEMS_SUCCESSFUL) {
388 // PRINTF("In RECV *** Error: rtems_task_suspend(RTEMS_SELF)\n")
396 // PRINTF("In RECV *** Error: rtems_task_suspend(RTEMS_SELF)\n")
389 //}
397 //}
390 }
398 }
391 else {
399 else {
392 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
400 if ( (len+1) < CCSDS_TC_PKT_MIN_SIZE ) {
393 PRINTF("In RECV *** packet lenght too short\n")
401 PRINTF("In RECV *** packet lenght too short\n")
394 }
402 }
395 else {
403 else {
396 currentTC_LEN_RCV[0] = 0x00;
404 currentTC_LEN_RCV[0] = 0x00;
397 currentTC_LEN_RCV[1] = (unsigned char) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // build the corresponding packet size field
405 currentTC_LEN_RCV[1] = (unsigned char) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // build the corresponding packet size field
398 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
406 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes
399 // CHECK THE TC AND BUILD THE APPROPRIATE TM
407 // CHECK THE TC AND BUILD THE APPROPRIATE TM
400 data_length = TC_acceptance(&currentTC, currentTC_LEN_RCV_AsUnsignedInt);
408 data_length = TC_acceptance(&currentTC, currentTC_LEN_RCV_AsUnsignedInt, queue_id);
401 if (data_length!=-1)
409 if (data_length!=-1)
402 {
410 {
403 }
411 }
404 }
412 }
405 }
413 }
406 }
414 }
407 }
415 }
408
416
409 rtems_task actn_task( rtems_task_argument unused )
417 rtems_task actn_task( rtems_task_argument unused )
410 {
418 {
411 int result;
419 int result;
412 rtems_status_code status; // RTEMS status code
420 rtems_status_code status; // RTEMS status code
413 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
421 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
414 size_t size; // size of the incoming TC packet
422 size_t size; // size of the incoming TC packet
415 unsigned char subtype; // subtype of the current TC packet
423 unsigned char subtype; // subtype of the current TC packet
424 rtems_id queue_rcv_id;
425 rtems_id queue_snd_id;
426
427 status = rtems_message_queue_ident( misc_name[QUEUE_QUEU], 0, &queue_rcv_id );
428 if (status != RTEMS_SUCCESSFUL)
429 {
430 PRINTF1("in ACTN *** ERR getting queue_rcv_id %d\n", status)
431 }
432
433 status = rtems_message_queue_ident( misc_name[QUEUE_PKTS], 0, &queue_snd_id );
434 if (status != RTEMS_SUCCESSFUL)
435 {
436 PRINTF1("in ACTN *** ERR getting queue_snd_id %d\n", status)
437 }
416
438
417 result = LFR_SUCCESSFUL;
439 result = LFR_SUCCESSFUL;
418 subtype = 0; // subtype of the current TC packet
440 subtype = 0; // subtype of the current TC packet
419
441
420 PRINTF("in ACTN *** \n")
442 BOOT_PRINTF("in ACTN *** \n")
421
443
422 while(1)
444 while(1)
423 {
445 {
424 status = rtems_message_queue_receive(misc_id[QUEUE_QUEU], (char*) &TC, &size,
446 status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size,
425 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
447 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
426 if (status!=RTEMS_SUCCESSFUL) PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
448 if (status!=RTEMS_SUCCESSFUL) PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status)
427 else
449 else
428 {
450 {
429 subtype = TC.serviceSubType;
451 subtype = TC.serviceSubType;
430 switch(subtype)
452 switch(subtype)
431 {
453 {
432 case TC_SUBTYPE_RESET:
454 case TC_SUBTYPE_RESET:
433 result = action_reset( &TC );
455 result = action_reset( &TC, queue_snd_id );
434 close_action( &TC, result );
456 close_action( &TC, result, queue_snd_id );
435 break;
457 break;
436 //
458 //
437 case TC_SUBTYPE_LOAD_COMM:
459 case TC_SUBTYPE_LOAD_COMM:
438 result = action_load_common_par( &TC );
460 result = action_load_common_par( &TC );
439 close_action( &TC, result );
461 close_action( &TC, result, queue_snd_id );
440 break;
462 break;
441 //
463 //
442 case TC_SUBTYPE_LOAD_NORM:
464 case TC_SUBTYPE_LOAD_NORM:
443 result = action_load_normal_par( &TC );
465 result = action_load_normal_par( &TC, queue_snd_id );
444 close_action( &TC, result );
466 close_action( &TC, result, queue_snd_id );
445 break;
467 break;
446 //
468 //
447 case TC_SUBTYPE_LOAD_BURST:
469 case TC_SUBTYPE_LOAD_BURST:
448 result = action_load_burst_par( &TC );
470 result = action_load_burst_par( &TC, queue_snd_id );
449 close_action( &TC, result );
471 close_action( &TC, result, queue_snd_id );
450 break;
472 break;
451 //
473 //
452 case TC_SUBTYPE_LOAD_SBM1:
474 case TC_SUBTYPE_LOAD_SBM1:
453 result = action_load_sbm1_par( &TC );
475 result = action_load_sbm1_par( &TC, queue_snd_id );
454 close_action( &TC, result );
476 close_action( &TC, result, queue_snd_id );
455 break;
477 break;
456 //
478 //
457 case TC_SUBTYPE_LOAD_SBM2:
479 case TC_SUBTYPE_LOAD_SBM2:
458 result = action_load_sbm2_par( &TC );
480 result = action_load_sbm2_par( &TC, queue_snd_id );
459 close_action( &TC, result );
481 close_action( &TC, result, queue_snd_id );
460 break;
482 break;
461 //
483 //
462 case TC_SUBTYPE_DUMP:
484 case TC_SUBTYPE_DUMP:
463 result = action_dump_par( &TC );
485 result = action_dump_par( &TC );
464 close_action( &TC, result );
486 close_action( &TC, result, queue_snd_id );
465 break;
487 break;
466 //
488 //
467 case TC_SUBTYPE_ENTER:
489 case TC_SUBTYPE_ENTER:
468 result = action_enter_mode( &TC );
490 result = action_enter_mode( &TC, queue_snd_id );
469 close_action( &TC, result );
491 close_action( &TC, result, queue_snd_id );
470 break;
492 break;
471 //
493 //
472 case TC_SUBTYPE_UPDT_INFO:
494 case TC_SUBTYPE_UPDT_INFO:
473 result = action_update_info( &TC );
495 result = action_update_info( &TC, queue_snd_id );
474 close_action( &TC, result );
496 close_action( &TC, result, queue_snd_id );
475 break;
497 break;
476 //
498 //
477 case TC_SUBTYPE_EN_CAL:
499 case TC_SUBTYPE_EN_CAL:
478 result = action_enable_calibration( &TC );
500 result = action_enable_calibration( &TC, queue_snd_id );
479 close_action( &TC, result );
501 close_action( &TC, result, queue_snd_id );
480 break;
502 break;
481 //
503 //
482 case TC_SUBTYPE_DIS_CAL:
504 case TC_SUBTYPE_DIS_CAL:
483 result = action_disable_calibration( &TC );
505 result = action_disable_calibration( &TC, queue_snd_id );
484 close_action( &TC, result );
506 close_action( &TC, result, queue_snd_id );
485 break;
507 break;
486 //
508 //
487 case TC_SUBTYPE_UPDT_TIME:
509 case TC_SUBTYPE_UPDT_TIME:
488 result = action_update_time( &TC );
510 result = action_update_time( &TC );
489 close_action( &TC, result );
511 close_action( &TC, result, queue_snd_id );
490 break;
512 break;
491 //
513 //
492 default:
514 default:
493 break;
515 break;
494 }
516 }
495 }
517 }
496 }
518 }
497 }
519 }
498
520
499 rtems_task dumb_task( rtems_task_argument unused )
521 rtems_task dumb_task( rtems_task_argument unused )
500 {
522 {
501 unsigned int i;
523 unsigned int i;
502 unsigned int intEventOut;
524 unsigned int intEventOut;
503 unsigned int coarse_time = 0;
525 unsigned int coarse_time = 0;
504 unsigned int fine_time = 0;
526 unsigned int fine_time = 0;
505 rtems_event_set event_out;
527 rtems_event_set event_out;
506
528
507 PRINTF("in DUMB *** \n")
529 BOOT_PRINTF("in DUMB *** \n")
508
530
509 while(1){
531 while(1){
510 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | RTEMS_EVENT_4 | RTEMS_EVENT_5,
532 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | RTEMS_EVENT_4 | RTEMS_EVENT_5,
511 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
533 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
512 intEventOut = (unsigned int) event_out;
534 intEventOut = (unsigned int) event_out;
513 for ( i=0; i<32; i++)
535 for ( i=0; i<32; i++)
514 {
536 {
515 if ( ((intEventOut >> i) & 0x0001) != 0)
537 if ( ((intEventOut >> i) & 0x0001) != 0)
516 {
538 {
517 coarse_time = time_management_regs->coarse_time;
539 coarse_time = time_management_regs->coarse_time;
518 fine_time = time_management_regs->fine_time;
540 fine_time = time_management_regs->fine_time;
519 printf("in DUMB *** time = coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
541 printf("in DUMB *** time = coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[i]);
520 }
542 }
521 }
543 }
522 }
544 }
523 }
545 }
524
546
525 //***********
547 //***********
526 // TC ACTIONS
548 // TC ACTIONS
527
549
528 int action_reset(ccsdsTelecommandPacket_t *TC)
550 int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
529 {
551 {
530 send_tm_lfr_tc_exe_not_implemented( TC );
552 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
531 return LFR_DEFAULT;
553 return LFR_DEFAULT;
532 }
554 }
533
555
534 int action_load_common_par(ccsdsTelecommandPacket_t *TC)
556 int action_load_common_par(ccsdsTelecommandPacket_t *TC)
535 {
557 {
536 parameter_dump_packet.unused0 = TC->dataAndCRC[0];
558 parameter_dump_packet.unused0 = TC->dataAndCRC[0];
537 parameter_dump_packet.bw_sp0_sp1_r0_r1 = TC->dataAndCRC[1];
559 parameter_dump_packet.bw_sp0_sp1_r0_r1 = TC->dataAndCRC[1];
538
560
539 set_wfp_data_shaping(parameter_dump_packet.bw_sp0_sp1_r0_r1);
561 set_wfp_data_shaping(parameter_dump_packet.bw_sp0_sp1_r0_r1);
540
562
541 return LFR_SUCCESSFUL;
563 return LFR_SUCCESSFUL;
542 }
564 }
543
565
544 int action_load_normal_par(ccsdsTelecommandPacket_t *TC)
566 int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
545 {
567 {
546 int result;
568 int result;
547 unsigned int tmp;
569 unsigned int tmp;
548
570
549 result = LFR_SUCCESSFUL;
571 result = LFR_SUCCESSFUL;
550
572
551 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
573 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
552 send_tm_lfr_tc_exe_not_executable( TC );
574 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
553 result = LFR_DEFAULT;
575 result = LFR_DEFAULT;
554 }
576 }
555 else {
577 else {
556 // sy_lfr_n_swf_l
578 // sy_lfr_n_swf_l
557 parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[0];
579 parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[0];
558 parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[1];
580 parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[1];
559
581
560 // sy_lfr_n_swf_p
582 // sy_lfr_n_swf_p
561 tmp = (unsigned int ) floor(
583 tmp = (unsigned int ) floor(
562 (TC->dataAndCRC[2] * 256
584 (TC->dataAndCRC[2] * 256
563 + TC->dataAndCRC[3])/8
585 + TC->dataAndCRC[3])/8
564 ) * 8;
586 ) * 8;
565 if ( (tmp < 16) || (tmp>65528) )
587 if ( (tmp < 16) || (tmp>65528) )
566 {
588 {
567 result = LFR_DEFAULT;
589 result = LFR_DEFAULT;
568 }
590 }
569 else
591 else
570 {
592 {
571 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8);
593 parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (tmp >> 8);
572 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp );
594 parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (tmp );
573 }
595 }
574
596
575 // sy_lfr_n_asm_p
597 // sy_lfr_n_asm_p
576 parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[4];
598 parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[4];
577 parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[5];
599 parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[5];
578
600
579 // sy_lfr_n_bp_p0
601 // sy_lfr_n_bp_p0
580 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[6];
602 parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[6];
581
603
582 // sy_lfr_n_bp_p1
604 // sy_lfr_n_bp_p1
583 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[7];
605 parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[7];
584 }
606 }
585
607
586 return result;
608 return result;
587 }
609 }
588
610
589 int action_load_burst_par(ccsdsTelecommandPacket_t *TC)
611 int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
590 {
612 {
591 int result;
613 int result;
592 unsigned char lfrMode;
614 unsigned char lfrMode;
593
615
594 result = LFR_DEFAULT;
616 result = LFR_DEFAULT;
595 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
617 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
596
618
597 if ( lfrMode == LFR_MODE_BURST ) {
619 if ( lfrMode == LFR_MODE_BURST ) {
598 send_tm_lfr_tc_exe_not_executable( TC );
620 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
599 result = LFR_DEFAULT;
621 result = LFR_DEFAULT;
600 }
622 }
601 else {
623 else {
602 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[0];
624 parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[0];
603 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[1];
625 parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[1];
604
626
605 result = LFR_SUCCESSFUL;
627 result = LFR_SUCCESSFUL;
606 }
628 }
607
629
608 return result;
630 return result;
609 }
631 }
610
632
611 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC)
633 int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
612 {
634 {
613 int result;
635 int result;
614 unsigned char lfrMode;
636 unsigned char lfrMode;
615
637
616 result = LFR_DEFAULT;
638 result = LFR_DEFAULT;
617 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
639 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
618
640
619 if ( lfrMode == LFR_MODE_SBM1 ) {
641 if ( lfrMode == LFR_MODE_SBM1 ) {
620 send_tm_lfr_tc_exe_not_executable( TC );
642 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
621 result = LFR_DEFAULT;
643 result = LFR_DEFAULT;
622 }
644 }
623 else {
645 else {
624 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[0];
646 parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[0];
625 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[1];
647 parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[1];
626
648
627 result = LFR_SUCCESSFUL;
649 result = LFR_SUCCESSFUL;
628 }
650 }
629
651
630 return result;
652 return result;
631 }
653 }
632
654
633 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC)
655 int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
634 {
656 {
635 int result;
657 int result;
636 unsigned char lfrMode;
658 unsigned char lfrMode;
637
659
638 result = LFR_DEFAULT;
660 result = LFR_DEFAULT;
639 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
661 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
640
662
641 if ( lfrMode == LFR_MODE_SBM2 ) {
663 if ( lfrMode == LFR_MODE_SBM2 ) {
642 send_tm_lfr_tc_exe_not_executable( TC );
664 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
643 result = LFR_DEFAULT;
665 result = LFR_DEFAULT;
644 }
666 }
645 else {
667 else {
646 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[0];
668 parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[0];
647 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[1];
669 parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[1];
648
670
649 result = LFR_SUCCESSFUL;
671 result = LFR_SUCCESSFUL;
650 }
672 }
651
673
652 return result;
674 return result;
653 }
675 }
654
676
655 int action_dump_par(ccsdsTelecommandPacket_t *TC)
677 int action_dump_par(ccsdsTelecommandPacket_t *TC)
656 {
678 {
657 int status;
679 int status;
658 // send parameter dump packet
680 // send parameter dump packet
659 status = write(fdSPW, (char *) &parameter_dump_packet,
681 status = write(fdSPW, (char *) &parameter_dump_packet,
660 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + 4);
682 PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + 4);
661 if (status == -1)
683 if (status == -1)
662 {
684 {
663 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
685 PRINTF1("in action_dump *** ERR sending packet, code %d", status)
664 status = RTEMS_UNSATISFIED;
686 status = RTEMS_UNSATISFIED;
665 }
687 }
666 else
688 else
667 {
689 {
668 status = RTEMS_SUCCESSFUL;
690 status = RTEMS_SUCCESSFUL;
669 }
691 }
670
692
671 return status;
693 return status;
672 }
694 }
673
695
674 int action_enter_mode(ccsdsTelecommandPacket_t *TC)
696 int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
675 {
697 {
676 rtems_status_code status;
698 rtems_status_code status;
677 unsigned char requestedMode;
699 unsigned char requestedMode;
678
700
679 requestedMode = TC->dataAndCRC[1];
701 requestedMode = TC->dataAndCRC[1];
680
702
681 printf("try to enter mode %d\n", requestedMode);
703 printf("try to enter mode %d\n", requestedMode);
682
704
683 #ifdef PRINT_TASK_STATISTICS
705 #ifdef PRINT_TASK_STATISTICS
684 if (requestedMode != LFR_MODE_STANDBY)
706 if (requestedMode != LFR_MODE_STANDBY)
685 {
707 {
686 rtems_cpu_usage_reset();
708 rtems_cpu_usage_reset();
687 maxCount = 0;
709 maxCount = 0;
688 }
710 }
689 #endif
711 #endif
690
712
691 status = transition_validation(requestedMode);
713 status = transition_validation(requestedMode);
692
714
693 if ( status == LFR_SUCCESSFUL ) {
715 if ( status == LFR_SUCCESSFUL ) {
694 if ( lfrCurrentMode != LFR_MODE_STANDBY)
716 if ( lfrCurrentMode != LFR_MODE_STANDBY)
695 {
717 {
696 status = stop_current_mode();
718 status = stop_current_mode();
697 }
719 }
698 if (status != RTEMS_SUCCESSFUL)
720 if (status != RTEMS_SUCCESSFUL)
699 {
721 {
700 PRINTF("ERR *** in action_enter *** stop_current_mode\n")
722 PRINTF("ERR *** in action_enter *** stop_current_mode\n")
701 }
723 }
702 status = enter_mode(requestedMode, TC);
724 status = enter_mode(requestedMode, TC);
703 }
725 }
704 else
726 else
705 {
727 {
706 PRINTF("ERR *** in action_enter *** transition rejected\n")
728 PRINTF("ERR *** in action_enter *** transition rejected\n")
707 send_tm_lfr_tc_exe_not_executable( TC );
729 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
708 }
730 }
709
731
710 return status;
732 return status;
711 }
733 }
712
734
713 int action_update_info(ccsdsTelecommandPacket_t *TC) {
735 int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) {
714 unsigned int val;
736 unsigned int val;
715 int result;
737 int result;
716 unsigned char lfrMode;
738 unsigned char lfrMode;
717
739
718 result = LFR_DEFAULT;
740 result = LFR_DEFAULT;
719 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
741 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
720
742
721 if ( (lfrMode == LFR_MODE_STANDBY) ) {
743 if ( (lfrMode == LFR_MODE_STANDBY) ) {
722 send_tm_lfr_tc_exe_not_implemented( TC );
744 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
723 result = LFR_DEFAULT;
745 result = LFR_DEFAULT;
724 }
746 }
725 else {
747 else {
726 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
748 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
727 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
749 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
728 val++;
750 val++;
729 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
751 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
730 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
752 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
731 result = LFR_SUCCESSFUL;
753 result = LFR_SUCCESSFUL;
732 }
754 }
733
755
734 return result;
756 return result;
735 }
757 }
736
758
737 int action_enable_calibration(ccsdsTelecommandPacket_t *TC)
759 int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
738 {
760 {
739 int result;
761 int result;
740 unsigned char lfrMode;
762 unsigned char lfrMode;
741
763
742 result = LFR_DEFAULT;
764 result = LFR_DEFAULT;
743 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
765 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
744
766
745 if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_BURST) | (lfrMode == LFR_MODE_SBM2) ) {
767 if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_BURST) | (lfrMode == LFR_MODE_SBM2) ) {
746 send_tm_lfr_tc_exe_not_executable( TC );
768 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
747 result = LFR_DEFAULT;
769 result = LFR_DEFAULT;
748 }
770 }
749 else {
771 else {
750 send_tm_lfr_tc_exe_not_implemented( TC );
772 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
751 result = LFR_DEFAULT;
773 result = LFR_DEFAULT;
752 }
774 }
753 return result;
775 return result;
754 }
776 }
755
777
756 int action_disable_calibration(ccsdsTelecommandPacket_t *TC)
778 int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
757 {
779 {
758 int result;
780 int result;
759 unsigned char lfrMode;
781 unsigned char lfrMode;
760
782
761 result = LFR_DEFAULT;
783 result = LFR_DEFAULT;
762 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
784 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
763
785
764 if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_BURST) | (lfrMode == LFR_MODE_SBM2) ) {
786 if ( (lfrMode == LFR_MODE_STANDBY) | (lfrMode == LFR_MODE_BURST) | (lfrMode == LFR_MODE_SBM2) ) {
765 send_tm_lfr_tc_exe_not_executable( TC );
787 send_tm_lfr_tc_exe_not_executable( TC, queue_id );
766 result = LFR_DEFAULT;
788 result = LFR_DEFAULT;
767 }
789 }
768 else {
790 else {
769 send_tm_lfr_tc_exe_not_implemented( TC );
791 send_tm_lfr_tc_exe_not_implemented( TC, queue_id );
770 result = LFR_DEFAULT;
792 result = LFR_DEFAULT;
771 }
793 }
772 return result;
794 return result;
773 }
795 }
774
796
775 int action_update_time(ccsdsTelecommandPacket_t *TC)
797 int action_update_time(ccsdsTelecommandPacket_t *TC)
776 {
798 {
777 unsigned int val;
799 unsigned int val;
778
800
779 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
801 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
780 + (TC->dataAndCRC[1] << 16)
802 + (TC->dataAndCRC[1] << 16)
781 + (TC->dataAndCRC[2] << 8)
803 + (TC->dataAndCRC[2] << 8)
782 + TC->dataAndCRC[3];
804 + TC->dataAndCRC[3];
783 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
805 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
784 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
806 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
785 val++;
807 val++;
786 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
808 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
787 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
809 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
788 time_management_regs->ctrl = time_management_regs->ctrl | 1;
810 time_management_regs->ctrl = time_management_regs->ctrl | 1;
789
811
790 return LFR_SUCCESSFUL;
812 return LFR_SUCCESSFUL;
791 }
813 }
792
814
793 //*******************
815 //*******************
794 // ENTERING THE MODES
816 // ENTERING THE MODES
795
817
796 int transition_validation(unsigned char requestedMode)
818 int transition_validation(unsigned char requestedMode)
797 {
819 {
798 int status;
820 int status;
799
821
800 switch (requestedMode)
822 switch (requestedMode)
801 {
823 {
802 case LFR_MODE_STANDBY:
824 case LFR_MODE_STANDBY:
803 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
825 if ( lfrCurrentMode == LFR_MODE_STANDBY ) {
804 status = LFR_DEFAULT;
826 status = LFR_DEFAULT;
805 }
827 }
806 else
828 else
807 {
829 {
808 status = LFR_SUCCESSFUL;
830 status = LFR_SUCCESSFUL;
809 }
831 }
810 break;
832 break;
811 case LFR_MODE_NORMAL:
833 case LFR_MODE_NORMAL:
812 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
834 if ( lfrCurrentMode == LFR_MODE_NORMAL ) {
813 status = LFR_DEFAULT;
835 status = LFR_DEFAULT;
814 }
836 }
815 else {
837 else {
816 status = LFR_SUCCESSFUL;
838 status = LFR_SUCCESSFUL;
817 }
839 }
818 break;
840 break;
819 case LFR_MODE_BURST:
841 case LFR_MODE_BURST:
820 if ( lfrCurrentMode == LFR_MODE_BURST ) {
842 if ( lfrCurrentMode == LFR_MODE_BURST ) {
821 status = LFR_DEFAULT;
843 status = LFR_DEFAULT;
822 }
844 }
823 else {
845 else {
824 status = LFR_SUCCESSFUL;
846 status = LFR_SUCCESSFUL;
825 }
847 }
826 break;
848 break;
827 case LFR_MODE_SBM1:
849 case LFR_MODE_SBM1:
828 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
850 if ( lfrCurrentMode == LFR_MODE_SBM1 ) {
829 status = LFR_DEFAULT;
851 status = LFR_DEFAULT;
830 }
852 }
831 else {
853 else {
832 status = LFR_SUCCESSFUL;
854 status = LFR_SUCCESSFUL;
833 }
855 }
834 break;
856 break;
835 case LFR_MODE_SBM2:
857 case LFR_MODE_SBM2:
836 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
858 if ( lfrCurrentMode == LFR_MODE_SBM2 ) {
837 status = LFR_DEFAULT;
859 status = LFR_DEFAULT;
838 }
860 }
839 else {
861 else {
840 status = LFR_SUCCESSFUL;
862 status = LFR_SUCCESSFUL;
841 }
863 }
842 break;
864 break;
843 default:
865 default:
844 status = LFR_DEFAULT;
866 status = LFR_DEFAULT;
845 break;
867 break;
846 }
868 }
847
869
848 return status;
870 return status;
849 }
871 }
850
872
851 int stop_current_mode()
873 int stop_current_mode()
852 {
874 {
853 rtems_status_code status;
875 rtems_status_code status;
854 unsigned char lfrMode;
855
876
856 status = RTEMS_SUCCESSFUL;
877 status = RTEMS_SUCCESSFUL;
857 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; // get the current mode
858
878
859 // mask all IRQ lines related to signal processing
879 // mask all IRQ lines related to signal processing
860 LEON_Mask_interrupt( IRQ_SM ); // mask spectral matrices interrupt (coming from the timer VHDL IP)
880 LEON_Mask_interrupt( IRQ_SM ); // mask spectral matrices interrupt (coming from the timer VHDL IP)
861 LEON_Clear_interrupt( IRQ_SM ); // clear spectral matrices interrupt (coming from the timer VHDL IP)
881 LEON_Clear_interrupt( IRQ_SM ); // clear spectral matrices interrupt (coming from the timer VHDL IP)
862
882
863 #ifdef GSA
883 #ifdef GSA
864 LEON_Mask_interrupt( IRQ_WF ); // mask waveform interrupt (coming from the timer VHDL IP)
884 LEON_Mask_interrupt( IRQ_WF ); // mask waveform interrupt (coming from the timer VHDL IP)
865 LEON_Clear_interrupt( IRQ_WF ); // clear waveform interrupt (coming from the timer VHDL IP)
885 LEON_Clear_interrupt( IRQ_WF ); // clear waveform interrupt (coming from the timer VHDL IP)
866 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR );
886 timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR );
867 #else
887 #else
868 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
888 LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt
869 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
889 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
870 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt
890 LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // mask spectral matrix interrupt
871 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
891 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt
872 LEON_Mask_interrupt( IRQ_SM );
892 LEON_Mask_interrupt( IRQ_SM ); // for SM simulation
893 LEON_Clear_interrupt( IRQ_SM ); // for SM simulation
873 #endif
894 #endif
874 //**********************
895 //**********************
875 // suspend several tasks
896 // suspend several tasks
876 if (lfrMode != LFR_MODE_STANDBY) {
897 if (lfrCurrentMode != LFR_MODE_STANDBY) {
877 suspend_science_tasks();
898 suspend_science_tasks();
878 }
899 }
879
900
880 if (status != RTEMS_SUCCESSFUL)
901 if (status != RTEMS_SUCCESSFUL)
881 {
902 {
882 PRINTF("ERR *** in stop_current_mode *** suspending tasks\n")
903 PRINTF("ERR *** in stop_current_mode *** suspending tasks\n")
883 }
904 }
884
905
885 //*************************
906 //*************************
886 // initialize the registers
907 // initialize the registers
887 #ifdef GSA
908 #ifdef GSA
888 #else
909 #else
889 reset_wfp_burst_enable(); // reset burst and enable bits
910 reset_wfp_burst_enable(); // reset burst and enable bits
890 reset_wfp_status(); // reset all the status bits
911 reset_wfp_status(); // reset all the status bits
891 #endif
912 #endif
892
913
893 return status;
914 return status;
894 }
915 }
895
916
896 int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC )
917 int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC )
897 {
918 {
898 rtems_status_code status;
919 rtems_status_code status;
899
920
900 status = RTEMS_UNSATISFIED;
921 status = RTEMS_UNSATISFIED;
901
922
902 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d);
923 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((mode << 4) + 0x0d);
903 lfrCurrentMode = mode;
924 lfrCurrentMode = mode;
904
925
905 switch(mode){
926 switch(mode){
906 case LFR_MODE_STANDBY:
927 case LFR_MODE_STANDBY:
907 status = enter_standby_mode( TC );
928 status = enter_standby_mode( TC );
908 break;
929 break;
909 case LFR_MODE_NORMAL:
930 case LFR_MODE_NORMAL:
910 status = enter_normal_mode( TC );
931 status = enter_normal_mode( TC );
911 break;
932 break;
912 case LFR_MODE_BURST:
933 case LFR_MODE_BURST:
913 status = enter_burst_mode( TC );
934 status = enter_burst_mode( TC );
914 break;
935 break;
915 case LFR_MODE_SBM1:
936 case LFR_MODE_SBM1:
916 status = enter_sbm1_mode( TC );
937 status = enter_sbm1_mode( TC );
917 break;
938 break;
918 case LFR_MODE_SBM2:
939 case LFR_MODE_SBM2:
919 status = enter_sbm2_mode( TC );
940 status = enter_sbm2_mode( TC );
920 break;
941 break;
921 default:
942 default:
922 status = RTEMS_UNSATISFIED;
943 status = RTEMS_UNSATISFIED;
923 }
944 }
924
945
925 if (status != RTEMS_SUCCESSFUL)
946 if (status != RTEMS_SUCCESSFUL)
926 {
947 {
927 PRINTF("in enter_mode *** ERR\n")
948 PRINTF("in enter_mode *** ERR\n")
928 status = RTEMS_UNSATISFIED;
949 status = RTEMS_UNSATISFIED;
929 }
950 }
930
951
931 return status;
952 return status;
932 }
953 }
933
954
934 int enter_standby_mode()
955 int enter_standby_mode()
935 {
956 {
936 reset_waveform_picker_regs();
957 reset_waveform_picker_regs();
937
958
938 PRINTF1("maxCount = %d\n", maxCount)
959 PRINTF1("maxCount = %d\n", maxCount)
939
960
940 #ifdef PRINT_TASK_STATISTICS
961 #ifdef PRINT_TASK_STATISTICS
941 rtems_cpu_usage_report();
962 rtems_cpu_usage_report();
942 #endif
963 #endif
943
964
944 #ifdef PRINT_STACK_REPORT
965 #ifdef PRINT_STACK_REPORT
945 rtems_stack_checker_report_usage();
966 rtems_stack_checker_report_usage();
946 #endif
967 #endif
947
968
948 return LFR_SUCCESSFUL;
969 return LFR_SUCCESSFUL;
949 }
970 }
950
971
951 int enter_normal_mode()
972 int enter_normal_mode()
952 {
973 {
953 rtems_status_code status;
974 rtems_status_code status;
954
975
955 status = restart_science_tasks();
976 status = restart_science_tasks();
956
977
957 #ifdef GSA
978 #ifdef GSA
958 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR );
979 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR );
959 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
980 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
960 LEON_Clear_interrupt( IRQ_WF );
981 LEON_Clear_interrupt( IRQ_WF );
961 LEON_Unmask_interrupt( IRQ_WF );
982 LEON_Unmask_interrupt( IRQ_WF );
962 //
983 //
963 set_local_nb_interrupt_f0_MAX();
984 set_local_nb_interrupt_f0_MAX();
964 LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
985 LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
965 LEON_Unmask_interrupt( IRQ_SM );
986 LEON_Unmask_interrupt( IRQ_SM );
966 #else
987 #else
967 //****************
988 //****************
968 // waveform picker
989 // waveform picker
969 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
990 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
970 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
991 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
971 reset_waveform_picker_regs();
992 reset_waveform_picker_regs();
972 set_wfp_burst_enable_register(LFR_MODE_NORMAL);
993 set_wfp_burst_enable_register(LFR_MODE_NORMAL);
973 //****************
994 //****************
974 // spectral matrix
995 // spectral matrix
975 set_local_nb_interrupt_f0_MAX();
996 // set_local_nb_interrupt_f0_MAX();
976 LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
997 // LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
977 LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
998 // LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX );
978 spectral_matrix_regs->config = 0x01;
999 // spectral_matrix_regs->config = 0x01;
979 spectral_matrix_regs->status = 0x00;
1000 // spectral_matrix_regs->status = 0x00;
980 #endif
1001 #endif
981
1002
982 return status;
1003 return status;
983 }
1004 }
984
1005
985 int enter_burst_mode()
1006 int enter_burst_mode()
986 {
1007 {
987 rtems_status_code status;
1008 rtems_status_code status;
988 unsigned char lfrMode;
989
990 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
991
1009
992 status = restart_science_tasks();
1010 status = restart_science_tasks();
993
1011
994 #ifdef GSA
1012 #ifdef GSA
995 LEON_Unmask_interrupt( IRQ_SM );
1013 LEON_Unmask_interrupt( IRQ_SM );
996 #else
1014 #else
997 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
1015 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
998 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
1016 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
999 reset_waveform_picker_regs();
1017 reset_waveform_picker_regs();
1000 set_wfp_burst_enable_register(LFR_MODE_BURST);
1018 set_wfp_burst_enable_register(LFR_MODE_BURST);
1001 #endif
1019 #endif
1002
1020
1003 return status;
1021 return status;
1004 }
1022 }
1005
1023
1006 int enter_sbm1_mode()
1024 int enter_sbm1_mode()
1007 {
1025 {
1008 rtems_status_code status;
1026 rtems_status_code status;
1009
1027
1010 status = restart_science_tasks();
1028 status = restart_science_tasks();
1011
1029
1012 set_local_sbm1_nb_cwf_max();
1030 set_local_sbm1_nb_cwf_max();
1013
1031
1014 reset_local_sbm1_nb_cwf_sent();
1032 reset_local_sbm1_nb_cwf_sent();
1015
1033
1016 #ifdef GSA
1034 #ifdef GSA
1017 LEON_Unmask_interrupt( IRQ_SM );
1035 LEON_Unmask_interrupt( IRQ_SM );
1018 #else
1036 #else
1019 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
1037 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
1020 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
1038 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
1021 reset_waveform_picker_regs();
1039 reset_waveform_picker_regs();
1022 set_wfp_burst_enable_register(LFR_MODE_SBM1);
1040 set_wfp_burst_enable_register(LFR_MODE_SBM1);
1023 // SM simulation
1041 // SM simulation
1024 timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
1042 // timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR );
1025 LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
1043 // LEON_Clear_interrupt( IRQ_SM ); // the IRQ_SM seems to be incompatible with the IRQ_WF on the xilinx board
1026 LEON_Unmask_interrupt( IRQ_SM );
1044 // LEON_Unmask_interrupt( IRQ_SM );
1027 #endif
1045 #endif
1028
1046
1029 return status;
1047 return status;
1030 }
1048 }
1031
1049
1032 int enter_sbm2_mode()
1050 int enter_sbm2_mode()
1033 {
1051 {
1034 rtems_status_code status;
1052 rtems_status_code status;
1035
1053
1036 status = restart_science_tasks();
1054 status = restart_science_tasks();
1037
1055
1038 set_local_sbm2_nb_cwf_max();
1056 set_local_sbm2_nb_cwf_max();
1039
1057
1040 reset_local_sbm2_nb_cwf_sent();
1058 reset_local_sbm2_nb_cwf_sent();
1041
1059
1042 #ifdef GSA
1060 #ifdef GSA
1043 LEON_Unmask_interrupt( IRQ_SM );
1061 LEON_Unmask_interrupt( IRQ_SM );
1044 #else
1062 #else
1045 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
1063 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
1046 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
1064 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
1047 reset_waveform_picker_regs();
1065 reset_waveform_picker_regs();
1048 set_wfp_burst_enable_register(LFR_MODE_SBM2);
1066 set_wfp_burst_enable_register(LFR_MODE_SBM2);
1049 #endif
1067 #endif
1050
1068
1051 return status;
1069 return status;
1052 }
1070 }
1053
1071
1054 int restart_science_tasks()
1072 int restart_science_tasks()
1055 {
1073 {
1056 rtems_status_code status[6];
1074 rtems_status_code status[6];
1057 rtems_status_code ret;
1075 rtems_status_code ret;
1058
1076
1059 ret = RTEMS_SUCCESSFUL;
1077 ret = RTEMS_SUCCESSFUL;
1060
1078
1061 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 );
1079 status[0] = rtems_task_restart( Task_id[TASKID_AVF0], 1 );
1080 if (status[0] != RTEMS_SUCCESSFUL)
1081 {
1082 PRINTF1("in restart_science_task *** 0 ERR %d\n", status[0])
1083 }
1084
1062 status[1] = rtems_task_restart( Task_id[TASKID_BPF0],1 );
1085 status[1] = rtems_task_restart( Task_id[TASKID_BPF0],1 );
1086 if (status[1] != RTEMS_SUCCESSFUL)
1087 {
1088 PRINTF1("in restart_science_task *** 1 ERR %d\n", status[1])
1089 }
1090
1063 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
1091 status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 );
1092 if (status[2] != RTEMS_SUCCESSFUL)
1093 {
1094 PRINTF1("in restart_science_task *** 2 ERR %d\n", status[2])
1095 }
1096
1064 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
1097 status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 );
1098 if (status[3] != RTEMS_SUCCESSFUL)
1099 {
1100 PRINTF1("in restart_science_task *** 3 ERR %d\n", status[3])
1101 }
1102
1065 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
1103 status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 );
1104 if (status[4] != RTEMS_SUCCESSFUL)
1105 {
1106 PRINTF1("in restart_science_task *** 4 ERR %d\n", status[4])
1107 }
1108
1066 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
1109 status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 );
1110 if (status[5] != RTEMS_SUCCESSFUL)
1111 {
1112 PRINTF1("in restart_science_task *** 5 ERR %d\n", status[5])
1113 }
1067
1114
1068 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
1115 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
1069 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
1116 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
1070 {
1117 {
1071 ret = RTEMS_UNSATISFIED;
1118 ret = RTEMS_UNSATISFIED;
1072 PRINTF("in restart_science_tasks *** ERR\n")
1073 }
1119 }
1074
1120
1075 return ret;
1121 return ret;
1076 }
1122 }
1077
1123
1078 int suspend_science_tasks()
1124 int suspend_science_tasks()
1079 {
1125 {
1080 rtems_status_code status[6];
1126 rtems_status_code status[6];
1081 rtems_status_code ret;
1127 rtems_status_code ret;
1082
1128
1083 ret = RTEMS_SUCCESSFUL;
1129 ret = RTEMS_SUCCESSFUL;
1084
1130
1085 status[0] = rtems_task_suspend( Task_id[TASKID_AVF0] );
1131 status[0] = rtems_task_suspend( Task_id[TASKID_AVF0] );
1132 if (status[0] != RTEMS_SUCCESSFUL)
1133 {
1134 PRINTF1("in suspend_science_task *** 0 ERR %d\n", status[0])
1135 }
1136
1086 status[1] = rtems_task_suspend( Task_id[TASKID_BPF0] );
1137 status[1] = rtems_task_suspend( Task_id[TASKID_BPF0] );
1138 if (status[1] != RTEMS_SUCCESSFUL)
1139 {
1140 PRINTF1("in suspend_science_task *** 1 ERR %d\n", status[1])
1141 }
1142
1087 status[2] = rtems_task_suspend( Task_id[TASKID_WFRM] );
1143 status[2] = rtems_task_suspend( Task_id[TASKID_WFRM] );
1144 if (status[2] != RTEMS_SUCCESSFUL)
1145 {
1146 PRINTF1("in suspend_science_task *** 2 ERR %d\n", status[2])
1147 }
1148
1088 status[3] = rtems_task_suspend( Task_id[TASKID_CWF3] );
1149 status[3] = rtems_task_suspend( Task_id[TASKID_CWF3] );
1150 if (status[3] != RTEMS_SUCCESSFUL)
1151 {
1152 PRINTF1("in suspend_science_task *** 3 ERR %d\n", status[3])
1153 }
1154
1089 status[4] = rtems_task_suspend( Task_id[TASKID_CWF2] );
1155 status[4] = rtems_task_suspend( Task_id[TASKID_CWF2] );
1156 if (status[4] != RTEMS_SUCCESSFUL)
1157 {
1158 PRINTF1("in suspend_science_task *** 4 ERR %d\n", status[4])
1159 }
1160
1090 status[5] = rtems_task_suspend( Task_id[TASKID_CWF1] );
1161 status[5] = rtems_task_suspend( Task_id[TASKID_CWF1] );
1162 if (status[5] != RTEMS_SUCCESSFUL)
1163 {
1164 PRINTF1("in suspend_science_task *** 5 ERR %d\n", status[5])
1165 }
1091
1166
1092 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
1167 if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || (status[2] != RTEMS_SUCCESSFUL) ||
1093 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
1168 (status[3] != RTEMS_SUCCESSFUL) || (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) )
1094 {
1169 {
1095 ret = RTEMS_UNSATISFIED;
1170 ret = RTEMS_UNSATISFIED;
1096 PRINTF("in suspend_science_tasks *** ERR\n")
1097 }
1171 }
1098
1172
1099 return ret;
1173 return ret;
1100 }
1174 }
1101
1175
1102 //****************
1176 //****************
1103 // CLOSING ACTIONS
1177 // CLOSING ACTIONS
1104
1178
1105 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC)
1179 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
1106 {
1180 {
1107 int ret;
1181 int ret;
1108 rtems_status_code status;
1182 rtems_status_code status;
1109 TMHeader_t TM_header;
1183 TMHeader_t TM_header;
1110 char data[4];
1184 char data[4];
1111 spw_ioctl_pkt_send spw_ioctl_send;
1185 spw_ioctl_pkt_send spw_ioctl_send;
1112
1186
1113 ret = LFR_SUCCESSFUL;
1187 ret = LFR_SUCCESSFUL;
1114
1188
1115 TM_build_header( TM_LFR_TC_EXE_OK, PACKET_LENGTH_TC_EXE_SUCCESS,
1189 TM_build_header( TM_LFR_TC_EXE_OK, PACKET_LENGTH_TC_EXE_SUCCESS,
1116 &TM_header,
1190 &TM_header,
1117 TC->sourceID); // TC source ID
1191 TC->sourceID); // TC source ID
1118
1192
1119 data[0] = TC->packetID[0];
1193 data[0] = TC->packetID[0];
1120 data[1] = TC->packetID[1];
1194 data[1] = TC->packetID[1];
1121 data[2] = TC->packetSequenceControl[0];
1195 data[2] = TC->packetSequenceControl[0];
1122 data[3] = TC->packetSequenceControl[1];
1196 data[3] = TC->packetSequenceControl[1];
1123
1197
1124 // filling the structure for the spacewire transmission
1198 // filling the structure for the spacewire transmission
1125 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
1199 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
1126 spw_ioctl_send.hdr = (char*) &TM_header;
1200 spw_ioctl_send.hdr = (char*) &TM_header;
1127 spw_ioctl_send.dlen = 4;
1201 spw_ioctl_send.dlen = 4;
1128 spw_ioctl_send.data = data;
1202 spw_ioctl_send.data = data;
1129 spw_ioctl_send.options = 0;
1203 spw_ioctl_send.options = 0;
1130
1204
1131 // SEND DATA
1205 // SEND DATA
1132 //status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1206 //status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1133 status = rtems_message_queue_urgent( misc_id[QUEUE_PKTS], &spw_ioctl_send, sizeof(spw_ioctl_send));
1207 status = rtems_message_queue_urgent( queue_id, &spw_ioctl_send, sizeof(spw_ioctl_send));
1134 if (status != RTEMS_SUCCESSFUL) {
1208 if (status != RTEMS_SUCCESSFUL) {
1135 PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n")
1209 PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n")
1136 ret = LFR_DEFAULT;
1210 ret = LFR_DEFAULT;
1137 }
1211 }
1138
1212
1139 return ret;
1213 return ret;
1140 }
1214 }
1141
1215
1142 int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC)
1216 int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
1143 {
1217 {
1144 int ret;
1218 int ret;
1145 rtems_status_code status;
1219 rtems_status_code status;
1146 TMHeader_t TM_header;
1220 TMHeader_t TM_header;
1147 char data[10];
1221 char data[10];
1148 spw_ioctl_pkt_send spw_ioctl_send;
1222 spw_ioctl_pkt_send spw_ioctl_send;
1149
1223
1150 ret = LFR_SUCCESSFUL;
1224 ret = LFR_SUCCESSFUL;
1151
1225
1152 TM_build_header( TM_LFR_TC_EXE_ERR, PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE,
1226 TM_build_header( TM_LFR_TC_EXE_ERR, PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE,
1153 &TM_header,
1227 &TM_header,
1154 TC->sourceID); // TC source ID
1228 TC->sourceID); // TC source ID
1155
1229
1156 data[0] = (char) (FAILURE_CODE_NOT_EXECUTABLE >> 8);
1230 data[0] = (char) (FAILURE_CODE_NOT_EXECUTABLE >> 8);
1157 data[1] = (char) FAILURE_CODE_NOT_EXECUTABLE;
1231 data[1] = (char) FAILURE_CODE_NOT_EXECUTABLE;
1158 data[2] = TC->packetID[0];
1232 data[2] = TC->packetID[0];
1159 data[3] = TC->packetID[1];
1233 data[3] = TC->packetID[1];
1160 data[4] = TC->packetSequenceControl[0];
1234 data[4] = TC->packetSequenceControl[0];
1161 data[5] = TC->packetSequenceControl[1];
1235 data[5] = TC->packetSequenceControl[1];
1162 data[6] = TC->serviceType; // type of the rejected TC
1236 data[6] = TC->serviceType; // type of the rejected TC
1163 data[7] = TC->serviceSubType; // subtype of the rejected TC
1237 data[7] = TC->serviceSubType; // subtype of the rejected TC
1164 data[8] = housekeeping_packet.lfr_status_word[0];
1238 data[8] = housekeeping_packet.lfr_status_word[0];
1165 data[6] = housekeeping_packet.lfr_status_word[1];
1239 data[6] = housekeeping_packet.lfr_status_word[1];
1166
1240
1167 // filling the structure for the spacewire transmission
1241 // filling the structure for the spacewire transmission
1168 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
1242 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
1169 spw_ioctl_send.hdr = (char*) &TM_header;
1243 spw_ioctl_send.hdr = (char*) &TM_header;
1170 spw_ioctl_send.dlen = 10;
1244 spw_ioctl_send.dlen = 10;
1171 spw_ioctl_send.data = data;
1245 spw_ioctl_send.data = data;
1172 spw_ioctl_send.options = 0;
1246 spw_ioctl_send.options = 0;
1173
1247
1174 // SEND DATA
1248 // SEND DATA
1175 //status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1249 //status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1176 status = rtems_message_queue_urgent( misc_id[QUEUE_PKTS], &spw_ioctl_send, sizeof(spw_ioctl_send));
1250 status = rtems_message_queue_urgent( queue_id, &spw_ioctl_send, sizeof(spw_ioctl_send));
1177 if (status != RTEMS_SUCCESSFUL) {
1251 if (status != RTEMS_SUCCESSFUL) {
1178 PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n")
1252 PRINTF("in send_tm_lfr_tc_exe_success *** ERR\n")
1179 ret = LFR_DEFAULT;
1253 ret = LFR_DEFAULT;
1180 }
1254 }
1181
1255
1182 return LFR_SUCCESSFUL;
1256 return LFR_SUCCESSFUL;
1183 }
1257 }
1184
1258
1185 int send_tm_lfr_tc_exe_not_implemented(ccsdsTelecommandPacket_t *TC)
1259 int send_tm_lfr_tc_exe_not_implemented(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
1186 {
1260 {
1187 int ret;
1261 int ret;
1188 rtems_status_code status;
1262 rtems_status_code status;
1189 TMHeader_t TM_header;
1263 TMHeader_t TM_header;
1190 char data[8];
1264 char data[8];
1191 spw_ioctl_pkt_send spw_ioctl_send;
1265 spw_ioctl_pkt_send spw_ioctl_send;
1192
1266
1193 ret = LFR_SUCCESSFUL;
1267 ret = LFR_SUCCESSFUL;
1194
1268
1195 TM_build_header( TM_LFR_TC_EXE_ERR, PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED,
1269 TM_build_header( TM_LFR_TC_EXE_ERR, PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED,
1196 &TM_header,
1270 &TM_header,
1197 TC->sourceID); // TC source ID
1271 TC->sourceID); // TC source ID
1198
1272
1199 data[0] = (char) (FAILURE_CODE_NOT_IMPLEMENTED >> 8);
1273 data[0] = (char) (FAILURE_CODE_NOT_IMPLEMENTED >> 8);
1200 data[1] = (char) FAILURE_CODE_NOT_IMPLEMENTED;
1274 data[1] = (char) FAILURE_CODE_NOT_IMPLEMENTED;
1201 data[2] = TC->packetID[0];
1275 data[2] = TC->packetID[0];
1202 data[3] = TC->packetID[1];
1276 data[3] = TC->packetID[1];
1203 data[4] = TC->packetSequenceControl[0];
1277 data[4] = TC->packetSequenceControl[0];
1204 data[5] = TC->packetSequenceControl[1];
1278 data[5] = TC->packetSequenceControl[1];
1205 data[6] = TC->serviceType; // type of the rejected TC
1279 data[6] = TC->serviceType; // type of the rejected TC
1206 data[7] = TC->serviceSubType; // subtype of the rejected TC
1280 data[7] = TC->serviceSubType; // subtype of the rejected TC
1207
1281
1208 // filling the structure for the spacewire transmission
1282 // filling the structure for the spacewire transmission
1209 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
1283 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
1210 spw_ioctl_send.hdr = (char*) &TM_header;
1284 spw_ioctl_send.hdr = (char*) &TM_header;
1211 spw_ioctl_send.dlen = 8;
1285 spw_ioctl_send.dlen = 8;
1212 spw_ioctl_send.data = data;
1286 spw_ioctl_send.data = data;
1213 spw_ioctl_send.options = 0;
1287 spw_ioctl_send.options = 0;
1214
1288
1215 // SEND DATA
1289 // SEND DATA
1216 //status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1290 //status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1217 status = rtems_message_queue_urgent( misc_id[QUEUE_PKTS], &spw_ioctl_send, sizeof(spw_ioctl_send));
1291 status = rtems_message_queue_urgent( queue_id, &spw_ioctl_send, sizeof(spw_ioctl_send));
1218 if (status != RTEMS_SUCCESSFUL) {
1292 if (status != RTEMS_SUCCESSFUL) {
1219 PRINTF("in send_tm_lfr_tc_exe_not_implemented *** ERR\n")
1293 PRINTF("in send_tm_lfr_tc_exe_not_implemented *** ERR\n")
1220 ret = LFR_DEFAULT;
1294 ret = LFR_DEFAULT;
1221 }
1295 }
1222
1296
1223 return LFR_SUCCESSFUL;
1297 return LFR_SUCCESSFUL;
1224 }
1298 }
1225
1299
1226 int send_tm_lfr_tc_exe_error(ccsdsTelecommandPacket_t *TC)
1300 int send_tm_lfr_tc_exe_error(ccsdsTelecommandPacket_t *TC, rtems_id queue_id)
1227 {
1301 {
1228 int ret;
1302 int ret;
1229 rtems_status_code status;
1303 rtems_status_code status;
1230 TMHeader_t TM_header;
1304 TMHeader_t TM_header;
1231 char data[8];
1305 char data[8];
1232 spw_ioctl_pkt_send spw_ioctl_send;
1306 spw_ioctl_pkt_send spw_ioctl_send;
1233
1307
1234 TM_build_header( TM_LFR_TC_EXE_ERR, PACKET_LENGTH_TC_EXE_ERROR,
1308 TM_build_header( TM_LFR_TC_EXE_ERR, PACKET_LENGTH_TC_EXE_ERROR,
1235 &TM_header,
1309 &TM_header,
1236 TC->sourceID); // TC source ID
1310 TC->sourceID); // TC source ID
1237
1311
1238 data[0] = (char) (FAILURE_CODE_ERROR >> 8);
1312 data[0] = (char) (FAILURE_CODE_ERROR >> 8);
1239 data[1] = (char) FAILURE_CODE_ERROR;
1313 data[1] = (char) FAILURE_CODE_ERROR;
1240 data[2] = TC->packetID[0];
1314 data[2] = TC->packetID[0];
1241 data[3] = TC->packetID[1];
1315 data[3] = TC->packetID[1];
1242 data[4] = TC->packetSequenceControl[0];
1316 data[4] = TC->packetSequenceControl[0];
1243 data[5] = TC->packetSequenceControl[1];
1317 data[5] = TC->packetSequenceControl[1];
1244 data[6] = TC->serviceType; // type of the rejected TC
1318 data[6] = TC->serviceType; // type of the rejected TC
1245 data[7] = TC->serviceSubType; // subtype of the rejected TC
1319 data[7] = TC->serviceSubType; // subtype of the rejected TC
1246
1320
1247 // filling the structure for the spacewire transmission
1321 // filling the structure for the spacewire transmission
1248 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
1322 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
1249 spw_ioctl_send.hdr = (char*) &TM_header;
1323 spw_ioctl_send.hdr = (char*) &TM_header;
1250 spw_ioctl_send.dlen = 8;
1324 spw_ioctl_send.dlen = 8;
1251 spw_ioctl_send.data = data;
1325 spw_ioctl_send.data = data;
1252 spw_ioctl_send.options = 0;
1326 spw_ioctl_send.options = 0;
1253
1327
1254 // SEND DATA
1328 // SEND DATA
1255 //status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1329 //status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, &spw_ioctl_send );
1256 status = rtems_message_queue_urgent( misc_id[QUEUE_PKTS], &spw_ioctl_send, sizeof(spw_ioctl_send));
1330 status = rtems_message_queue_urgent( queue_id, &spw_ioctl_send, sizeof(spw_ioctl_send));
1257 if (status != RTEMS_SUCCESSFUL) {
1331 if (status != RTEMS_SUCCESSFUL) {
1258 PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n")
1332 PRINTF("in send_tm_lfr_tc_exe_error *** ERR\n")
1259 ret = LFR_DEFAULT;
1333 ret = LFR_DEFAULT;
1260 }
1334 }
1261
1335
1262 return LFR_SUCCESSFUL;
1336 return LFR_SUCCESSFUL;
1263 }
1337 }
1264
1338
1265 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC)
1339 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC)
1266 {
1340 {
1267 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
1341 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
1268 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
1342 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
1269 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
1343 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
1270 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
1344 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType;
1271 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
1345 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
1272 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
1346 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType;
1273 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1347 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1274 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1348 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1275 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1349 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1276 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
1350 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
1277 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1351 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1278 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
1352 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
1279 }
1353 }
1280
1354
1281 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC)
1355 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC)
1282 {
1356 {
1283 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
1357 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
1284 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
1358 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
1285 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
1359 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
1286 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
1360 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType;
1287 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
1361 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
1288 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
1362 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType;
1289 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1363 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
1290 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1364 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
1291 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1365 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
1292 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
1366 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
1293 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1367 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
1294 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
1368 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
1295 }
1369 }
1296
1370
1297 void close_action(ccsdsTelecommandPacket_t *TC, int result)
1371 void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id)
1298 {
1372 {
1299 unsigned int val = 0;
1373 unsigned int val = 0;
1300 if (result == LFR_SUCCESSFUL)
1374 if (result == LFR_SUCCESSFUL)
1301 {
1375 {
1302 if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) )
1376 if ( !( (TC->serviceType==TC_TYPE_TIME) && (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) )
1303 {
1377 {
1304 send_tm_lfr_tc_exe_success( TC );
1378 send_tm_lfr_tc_exe_success( TC, queue_id );
1305 }
1379 }
1306 update_last_TC_exe( TC );
1380 update_last_TC_exe( TC );
1307 val = housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1];
1381 val = housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1];
1308 val++;
1382 val++;
1309 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
1383 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
1310 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1] = (unsigned char) (val);
1384 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1] = (unsigned char) (val);
1311 }
1385 }
1312 else
1386 else
1313 {
1387 {
1314 update_last_TC_rej( TC );
1388 update_last_TC_rej( TC );
1315 val = housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1];
1389 val = housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1];
1316 val++;
1390 val++;
1317 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
1391 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
1318 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1] = (unsigned char) (val);
1392 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1] = (unsigned char) (val);
1319 }
1393 }
1320 }
1394 }
1321
1395
1322 //***************************
1396 //***************************
1323 // Interrupt Service Routines
1397 // Interrupt Service Routines
1324 rtems_isr commutation_isr1( rtems_vector_number vector )
1398 rtems_isr commutation_isr1( rtems_vector_number vector )
1325 {
1399 {
1326 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1400 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1327 printf("In commutation_isr1 *** Error sending event to DUMB\n");
1401 printf("In commutation_isr1 *** Error sending event to DUMB\n");
1328 }
1402 }
1329 }
1403 }
1330
1404
1331 rtems_isr commutation_isr2( rtems_vector_number vector )
1405 rtems_isr commutation_isr2( rtems_vector_number vector )
1332 {
1406 {
1333 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1407 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
1334 printf("In commutation_isr2 *** Error sending event to DUMB\n");
1408 printf("In commutation_isr2 *** Error sending event to DUMB\n");
1335 }
1409 }
1336 }
1410 }
1337
1411
1338
1412
1339
1413
1340
1414
@@ -1,814 +1,841
1 #include <wf_handler.h>
1 #include <wf_handler.h>
2
2
3 // SWF
3 // SWF
4 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
4 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F0[7];
5 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
5 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F1[7];
6 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
6 Header_TM_LFR_SCIENCE_SWF_t headerSWF_F2[7];
7 // CWF
7 // CWF
8 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[7];
8 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F1[7];
9 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[7];
9 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_BURST[7];
10 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[7];
10 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F2_SBM2[7];
11 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[7];
11 Header_TM_LFR_SCIENCE_CWF_t headerCWF_F3[7];
12
12
13 unsigned char doubleSendCWF1 = 0;
13 unsigned char doubleSendCWF1 = 0;
14 unsigned char doubleSendCWF2 = 0;
14 unsigned char doubleSendCWF2 = 0;
15
15
16 rtems_isr waveforms_isr( rtems_vector_number vector )
16 rtems_isr waveforms_isr( rtems_vector_number vector )
17 {
17 {
18
18
19 #ifdef GSA
19 #ifdef GSA
20 #else
20 #else
21 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
21 if ( (lfrCurrentMode == LFR_MODE_NORMAL)
22 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
22 || (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) )
23 { // in modes other than STANDBY and BURST, send the CWF_F3 data
23 { // in modes other than STANDBY and BURST, send the CWF_F3 data
24 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
24 if ((waveform_picker_regs->status & 0x08) == 0x08){ // [1000] f3 is full
25 // (1) change the receiving buffer for the waveform picker
25 // (1) change the receiving buffer for the waveform picker
26 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
26 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
27 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_bis);
27 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3_bis);
28 }
28 }
29 else {
29 else {
30 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3);
30 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3);
31 }
31 }
32 // (2) send an event for the waveforms transmission
32 // (2) send an event for the waveforms transmission
33 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
33 if (rtems_event_send( Task_id[TASKID_CWF3], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
34 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
34 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
35 }
35 }
36 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
36 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffff777; // reset f3 bits to 0, [1111 0111 0111 0111]
37 }
37 }
38 }
38 }
39 #endif
39 #endif
40
40
41 switch(lfrCurrentMode)
41 switch(lfrCurrentMode)
42 {
42 {
43 //********
43 //********
44 // STANDBY
44 // STANDBY
45 case(LFR_MODE_STANDBY):
45 case(LFR_MODE_STANDBY):
46 break;
46 break;
47
47
48 //******
48 //******
49 // NORMAL
49 // NORMAL
50 case(LFR_MODE_NORMAL):
50 case(LFR_MODE_NORMAL):
51 #ifdef GSA
51 #ifdef GSA
52 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
52 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
53 #else
53 #else
54 if ( (waveform_picker_regs->status & 0x7) == 0x7 ){ // [0111] f2 f1 and f0 are full
54 if ( (waveform_picker_regs->burst_enable & 0x7) == 0x0 ){ // if no channel is enable
55 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
55 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
56 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
56 }
57 else {
58 if ( (waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full
59 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable & 0x08;
60 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
61 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
62 }
63 waveform_picker_regs->status = waveform_picker_regs->status & 0x00;
64 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x07; // [0111] enable f2 f1 f0
57 }
65 }
58 }
66 }
59 waveform_picker_regs->status = waveform_picker_regs->status & 0xf888; // [1111 1000 1000 1000] f2, f1, f0 bits =0
60 #endif
67 #endif
61 break;
68 break;
62
69
63 //******
70 //******
64 // BURST
71 // BURST
65 case(LFR_MODE_BURST):
72 case(LFR_MODE_BURST):
66 #ifdef GSA
73 #ifdef GSA
67 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
74 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
68 #else
75 #else
69 if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
76 if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
70 // (1) change the receiving buffer for the waveform picker
77 // (1) change the receiving buffer for the waveform picker
71 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
78 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
72 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
79 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
73 }
80 }
74 else {
81 else {
75 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
82 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
76 }
83 }
77 // (2) send an event for the waveforms transmission
84 // (2) send an event for the waveforms transmission
78 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
85 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_BURST ) != RTEMS_SUCCESSFUL) {
79 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
86 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
80 }
87 }
81 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
88 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bits = 0
82 }
89 }
83 #endif
90 #endif
84 break;
91 break;
85
92
86 //*****
93 //*****
87 // SBM1
94 // SBM1
88 case(LFR_MODE_SBM1):
95 case(LFR_MODE_SBM1):
89 #ifdef GSA
96 #ifdef GSA
90 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
97 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
91 #else
98 #else
92 if ((waveform_picker_regs->status & 0x02) == 0x02){ // [0010] check the f1 full bit
99 if ((waveform_picker_regs->status & 0x02) == 0x02){ // [0010] check the f1 full bit
93 // (1) change the receiving buffer for the waveform picker
100 // (1) change the receiving buffer for the waveform picker
94 if ( param_local.local_sbm1_nb_cwf_sent == (param_local.local_sbm1_nb_cwf_max-1) )
101 if ( param_local.local_sbm1_nb_cwf_sent == (param_local.local_sbm1_nb_cwf_max-1) )
95 {
102 {
96 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_norm);
103 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_norm);
97 }
104 }
98 else if ( waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1_norm )
105 else if ( waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1_norm )
99 {
106 {
100 doubleSendCWF1 = 1;
107 doubleSendCWF1 = 1;
101 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
108 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
102 }
109 }
103 else if ( waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1 ) {
110 else if ( waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1 ) {
104 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_bis);
111 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_bis);
105 }
112 }
106 else {
113 else {
107 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
114 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
108 }
115 }
109 // (2) send an event for the waveforms transmission
116 // (2) send an event for the waveforms transmission
110 if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) {
117 if (rtems_event_send( Task_id[TASKID_CWF1], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) {
111 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
118 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
112 }
119 }
113 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0
120 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffddd; // [1111 1101 1101 1101] f1 bit = 0
114 }
121 }
115 if ( ( (waveform_picker_regs->status & 0x05) == 0x05 ) ) { // [0101] check the f2 and f0 full bit
122 if ( ( (waveform_picker_regs->status & 0x05) == 0x05 ) ) { // [0101] check the f2 and f0 full bit
116 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
123 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
117 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
124 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
118 }
125 }
119 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0
126 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2 and f0 bits = 0
120 reset_local_sbm1_nb_cwf_sent();
127 reset_local_sbm1_nb_cwf_sent();
121 }
128 }
122
129
123 #endif
130 #endif
124 break;
131 break;
125
132
126 //*****
133 //*****
127 // SBM2
134 // SBM2
128 case(LFR_MODE_SBM2):
135 case(LFR_MODE_SBM2):
129 #ifdef GSA
136 #ifdef GSA
130 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
137 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
131 #else
138 #else
132 if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
139 if ((waveform_picker_regs->status & 0x04) == 0x04){ // [0100] check the f2 full bit
133 // (1) change the receiving buffer for the waveform picker
140 // (1) change the receiving buffer for the waveform picker
134 if ( param_local.local_sbm2_nb_cwf_sent == (param_local.local_sbm2_nb_cwf_max-1) )
141 if ( param_local.local_sbm2_nb_cwf_sent == (param_local.local_sbm2_nb_cwf_max-1) )
135 {
142 {
136 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_norm);
143 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_norm);
137 }
144 }
138 else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2_norm ) {
145 else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2_norm ) {
139 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
146 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
140 doubleSendCWF2 = 1;
147 doubleSendCWF2 = 1;
141 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2_WFRM ) != RTEMS_SUCCESSFUL) {
148 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2_WFRM ) != RTEMS_SUCCESSFUL) {
142 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
149 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
143 }
150 }
144 reset_local_sbm2_nb_cwf_sent();
151 reset_local_sbm2_nb_cwf_sent();
145 }
152 }
146 else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2 ) {
153 else if ( waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2 ) {
147 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
154 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2_bis);
148 }
155 }
149 else {
156 else {
150 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
157 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2);
151 }
158 }
152 // (2) send an event for the waveforms transmission
159 // (2) send an event for the waveforms transmission
153 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
160 if (rtems_event_send( Task_id[TASKID_CWF2], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
154 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
161 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
155 }
162 }
156 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
163 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffbbb; // [1111 1011 1011 1011] f2 bit = 0
157 }
164 }
158 if ( ( (waveform_picker_regs->status & 0x03) == 0x03 ) ) { // [0011] f3 f2 f1 f0, f1 and f0 are full
165 if ( ( (waveform_picker_regs->status & 0x03) == 0x03 ) ) { // [0011] f3 f2 f1 f0, f1 and f0 are full
159 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
166 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM2 ) != RTEMS_SUCCESSFUL) {
160 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
167 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
161 }
168 }
162 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
169 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
163 }
170 }
164 #endif
171 #endif
165 break;
172 break;
166
173
167 //********
174 //********
168 // DEFAULT
175 // DEFAULT
169 default:
176 default:
170 break;
177 break;
171 }
178 }
172 }
179 }
173
180
174 rtems_isr waveforms_simulator_isr( rtems_vector_number vector )
181 rtems_isr waveforms_simulator_isr( rtems_vector_number vector )
175 {
182 {
176 unsigned char lfrMode;
183 unsigned char lfrMode;
177 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
184 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
178
185
179 switch(lfrMode) {
186 switch(lfrMode) {
180 case (LFR_MODE_STANDBY):
187 case (LFR_MODE_STANDBY):
181 break;
188 break;
182 case (LFR_MODE_NORMAL):
189 case (LFR_MODE_NORMAL):
183 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
190 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
184 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_5 );
191 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_5 );
185 }
192 }
186 break;
193 break;
187 case (LFR_MODE_BURST):
194 case (LFR_MODE_BURST):
188 break;
195 break;
189 case (LFR_MODE_SBM1):
196 case (LFR_MODE_SBM1):
190 break;
197 break;
191 case (LFR_MODE_SBM2):
198 case (LFR_MODE_SBM2):
192 break;
199 break;
193 }
200 }
194 }
201 }
195
202
196 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
203 rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
197 {
204 {
198 rtems_event_set event_out;
205 rtems_event_set event_out;
206 rtems_id queue_id;
207 rtems_status_code status;
199
208
200 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
209 init_header_snapshot_wf_table( SID_NORM_SWF_F0, headerSWF_F0 );
201 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
210 init_header_snapshot_wf_table( SID_NORM_SWF_F1, headerSWF_F1 );
202 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
211 init_header_snapshot_wf_table( SID_NORM_SWF_F2, headerSWF_F2 );
203
212
204 init_waveforms();
213 init_waveforms();
205
214
206 PRINTF("in WFRM ***\n")
215 status = rtems_message_queue_ident( misc_name[QUEUE_PKTS], 0, &queue_id );
216 if (status != RTEMS_SUCCESSFUL)
217 {
218 PRINTF1("in WFRM *** ERR getting queue id, %d\n", status)
219 }
220
221 BOOT_PRINTF("in WFRM ***\n")
207
222
208 while(1){
223 while(1){
209 // wait for an RTEMS_EVENT
224 // wait for an RTEMS_EVENT
210 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
225 rtems_event_receive(RTEMS_EVENT_MODE_NORMAL | RTEMS_EVENT_MODE_SBM1
211 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
226 | RTEMS_EVENT_MODE_SBM2 | RTEMS_EVENT_MODE_SBM2_WFRM,
212 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
227 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
213
228
214 switch( event_out) {
229 if (event_out == RTEMS_EVENT_MODE_NORMAL)
215
230 {
216 case RTEMS_EVENT_MODE_NORMAL:
231 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
217 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0);
232 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
218 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1);
233 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
219 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2);
220 #ifdef GSA
234 #ifdef GSA
221 waveform_picker_regs->status = waveform_picker_regs->status & 0xf888; // [1111 1000 1000 1000] f2, f1, f0 bits =0
235 waveform_picker_regs->status = waveform_picker_regs->status & 0xf888; // [1111 1000 1000 1000] f2, f1, f0 bits =0
222 #endif
236 #endif
223 break;
237 }
224
238 else if (event_out == RTEMS_EVENT_MODE_SBM1)
225 case RTEMS_EVENT_MODE_SBM1:
239 {
226 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0);
240 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
227 send_waveform_SWF(wf_snap_f1_norm, SID_NORM_SWF_F1, headerSWF_F1);
241 send_waveform_SWF(wf_snap_f1_norm, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
228 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2);
242 send_waveform_SWF(wf_snap_f2, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
229 #ifdef GSA
243 #ifdef GSA
230 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2, f0 bits = 0
244 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffaaa; // [1111 1010 1010 1010] f2, f0 bits = 0
231 #endif
245 #endif
232 break;
246 }
233
247 else if (event_out == RTEMS_EVENT_MODE_SBM2)
234 case RTEMS_EVENT_MODE_SBM2:
248 {
235 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0);
249 send_waveform_SWF(wf_snap_f0, SID_NORM_SWF_F0, headerSWF_F0, queue_id);
236 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1);
250 send_waveform_SWF(wf_snap_f1, SID_NORM_SWF_F1, headerSWF_F1, queue_id);
237 #ifdef GSA
251 #ifdef GSA
238 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
252 waveform_picker_regs->status = waveform_picker_regs->status & 0xfffffccc; // [1111 1100 1100 1100] f1, f0 bits = 0
239 #endif
253 #endif
240 break;
254 }
255 else if (event_out == RTEMS_EVENT_MODE_SBM2_WFRM)
256 {
257 send_waveform_SWF(wf_snap_f2_norm, SID_NORM_SWF_F2, headerSWF_F2, queue_id);
258 }
259 else
260 {
261 PRINTF("in WFRM *** unexpected event")
262 }
241
263
242 case RTEMS_EVENT_MODE_SBM2_WFRM:
243 send_waveform_SWF(wf_snap_f2_norm, SID_NORM_SWF_F2, headerSWF_F2);
244 break;
245
246 default:
247 break;
248 }
249
264
250 #ifdef GSA
265 #ifdef GSA
251 // irq processed, reset the related register of the timer unit
266 // irq processed, reset the related register of the timer unit
252 gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl = gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl | 0x00000010;
267 gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl = gptimer_regs->timer[TIMER_WF_SIMULATOR].ctrl | 0x00000010;
253 // clear the interruption
268 // clear the interruption
254 LEON_Unmask_interrupt( IRQ_WF );
269 LEON_Unmask_interrupt( IRQ_WF );
255 #endif
270 #endif
256 }
271 }
257 }
272 }
258
273
259 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
274 rtems_task cwf3_task(rtems_task_argument argument) //used with the waveform picker VHDL IP
260 {
275 {
261 rtems_event_set event_out;
276 rtems_event_set event_out;
277 rtems_id queue_id;
262
278
263 init_header_continuous_wf_table( SID_NORM_CWF_F3, headerCWF_F3 );
279 init_header_continuous_wf_table( SID_NORM_CWF_F3, headerCWF_F3 );
264
280
265 PRINTF("in CWF3 ***\n")
281 queue_id = get_pkts_queue_id();
282
283 BOOT_PRINTF("in CWF3 ***\n")
266
284
267 while(1){
285 while(1){
268 // wait for an RTEMS_EVENT
286 // wait for an RTEMS_EVENT
269 rtems_event_receive( RTEMS_EVENT_0,
287 rtems_event_receive( RTEMS_EVENT_0,
270 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
288 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
271 PRINTF("send CWF F3 \n")
289 PRINTF("send CWF F3 \n")
272 #ifdef GSA
290 #ifdef GSA
273 #else
291 #else
274 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
292 if (waveform_picker_regs->addr_data_f3 == (int) wf_cont_f3) {
275 send_waveform_CWF( wf_cont_f3_bis, SID_NORM_CWF_F3, headerCWF_F3 );
293 send_waveform_CWF( wf_cont_f3_bis, SID_NORM_CWF_F3, headerCWF_F3, queue_id );
276 }
294 }
277 else {
295 else {
278 send_waveform_CWF( wf_cont_f3, SID_NORM_CWF_F3, headerCWF_F3 );
296 send_waveform_CWF( wf_cont_f3, SID_NORM_CWF_F3, headerCWF_F3, queue_id );
279 }
297 }
280 #endif
298 #endif
281 }
299 }
282 }
300 }
283
301
284 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
302 rtems_task cwf2_task(rtems_task_argument argument) // ONLY USED IN BURST AND SBM2
285 {
303 {
286 rtems_event_set event_out;
304 rtems_event_set event_out;
305 rtems_id queue_id;
287
306
288 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
307 init_header_continuous_wf_table( SID_BURST_CWF_F2, headerCWF_F2_BURST );
289 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
308 init_header_continuous_wf_table( SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
290
309
291 PRINTF("in CWF2 ***\n")
310 queue_id = get_pkts_queue_id();
311
312 BOOT_PRINTF("in CWF2 ***\n")
292
313
293 while(1){
314 while(1){
294 // wait for an RTEMS_EVENT
315 // wait for an RTEMS_EVENT
295 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
316 rtems_event_receive( RTEMS_EVENT_MODE_BURST | RTEMS_EVENT_MODE_SBM2,
296 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
317 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
297 if (event_out == RTEMS_EVENT_MODE_BURST)
318 if (event_out == RTEMS_EVENT_MODE_BURST)
298 {
319 {
299 // F2
320 // F2
300 #ifdef GSA
321 #ifdef GSA
301 #else
322 #else
302 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
323 if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
303 send_waveform_CWF( wf_snap_f2_bis, SID_BURST_CWF_F2, headerCWF_F2_BURST );
324 send_waveform_CWF( wf_snap_f2_bis, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
304 }
325 }
305 else {
326 else {
306 send_waveform_CWF( wf_snap_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST );
327 send_waveform_CWF( wf_snap_f2, SID_BURST_CWF_F2, headerCWF_F2_BURST, queue_id );
307 }
328 }
308 #endif
329 #endif
309 }
330 }
310 else if (event_out == RTEMS_EVENT_MODE_SBM2)
331 else if (event_out == RTEMS_EVENT_MODE_SBM2)
311 {
332 {
312 #ifdef GSA
333 #ifdef GSA
313 #else
334 #else
314 if (doubleSendCWF2 == 1)
335 if (doubleSendCWF2 == 1)
315 {
336 {
316 doubleSendCWF2 = 0;
337 doubleSendCWF2 = 0;
317 send_waveform_CWF( wf_snap_f2_norm, SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
338 send_waveform_CWF( wf_snap_f2_norm, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
318 }
339 }
319 else if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
340 else if (waveform_picker_regs->addr_data_f2 == (int) wf_snap_f2) {
320 send_waveform_CWF( wf_snap_f2_bis, SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
341 send_waveform_CWF( wf_snap_f2_bis, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
321 }
342 }
322 else {
343 else {
323 send_waveform_CWF( wf_snap_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2 );
344 send_waveform_CWF( wf_snap_f2, SID_SBM2_CWF_F2, headerCWF_F2_SBM2, queue_id );
324 }
345 }
325 param_local.local_sbm2_nb_cwf_sent ++;
346 param_local.local_sbm2_nb_cwf_sent ++;
326 #endif
347 #endif
327 }
348 }
328 else
349 else
329 {
350 {
330 PRINTF1("in CWF2 *** ERR mode = %d\n", lfrCurrentMode)
351 PRINTF1("in CWF2 *** ERR mode = %d\n", lfrCurrentMode)
331 }
352 }
332 }
353 }
333 }
354 }
334
355
335 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
356 rtems_task cwf1_task(rtems_task_argument argument) // ONLY USED IN SBM1
336 {
357 {
337 rtems_event_set event_out;
358 rtems_event_set event_out;
359 rtems_id queue_id;
338
360
339 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
361 init_header_continuous_wf_table( SID_SBM1_CWF_F1, headerCWF_F1 );
340
362
341 PRINTF("in CWF1 ***\n")
363 queue_id = get_pkts_queue_id();
364
365 BOOT_PRINTF("in CWF1 ***\n")
342
366
343 while(1){
367 while(1){
344 // wait for an RTEMS_EVENT
368 // wait for an RTEMS_EVENT
345 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
369 rtems_event_receive( RTEMS_EVENT_MODE_SBM1,
346 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
370 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
347 if (event_out == RTEMS_EVENT_MODE_SBM1)
371 if (event_out == RTEMS_EVENT_MODE_SBM1)
348 {
372 {
349 #ifdef GSA
373 #ifdef GSA
350 #else
374 #else
351 if (doubleSendCWF1 == 1)
375 if (doubleSendCWF1 == 1)
352 {
376 {
353 doubleSendCWF1 = 0;
377 doubleSendCWF1 = 0;
354 send_waveform_CWF( wf_snap_f1_norm, SID_SBM1_CWF_F1, headerCWF_F1 );
378 send_waveform_CWF( wf_snap_f1_norm, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
355 }
379 }
356 else if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
380 else if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
357 send_waveform_CWF( wf_snap_f1_bis, SID_SBM1_CWF_F1, headerCWF_F1 );
381 send_waveform_CWF( wf_snap_f1_bis, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
358 }
382 }
359 else {
383 else {
360 send_waveform_CWF( wf_snap_f1, SID_SBM1_CWF_F1, headerCWF_F1);
384 send_waveform_CWF( wf_snap_f1, SID_SBM1_CWF_F1, headerCWF_F1, queue_id );
361 }
385 }
362 param_local.local_sbm1_nb_cwf_sent ++;
386 param_local.local_sbm1_nb_cwf_sent ++;
363 #endif
387 #endif
364 }
388 }
365 else
389 else
366 {
390 {
367 PRINTF1("in CWF1 *** ERR mode = %d\n", lfrCurrentMode)
391 PRINTF1("in CWF1 *** ERR mode = %d\n", lfrCurrentMode)
368 }
392 }
369 }
393 }
370 }
394 }
371
395
372 //******************
396 //******************
373 // general functions
397 // general functions
374 void init_waveforms( void )
398 void init_waveforms( void )
375 {
399 {
376 int i = 0;
400 int i = 0;
377
401
378 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
402 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
379 {
403 {
380 //***
404 //***
381 // F0
405 // F0
382 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
406 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; //
383 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
407 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; //
384 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
408 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; //
385
409
386 //***
410 //***
387 // F1
411 // F1
388 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
412 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x22221111;
389 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
413 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x44443333;
390 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
414 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
391
415
392 //***
416 //***
393 // F2
417 // F2
394 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
418 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x44443333;
395 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
419 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111;
396 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
420 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000;
397
421
398 //***
422 //***
399 // F3
423 // F3
400 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
424 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1;
401 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
425 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2;
402 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
426 //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000;
403 }
427 }
404 }
428 }
405
429
406 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
430 int init_header_snapshot_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF)
407 {
431 {
408 unsigned char i;
432 unsigned char i;
409
433
410 for (i=0; i<7; i++)
434 for (i=0; i<7; i++)
411 {
435 {
412 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
436 headerSWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
413 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
437 headerSWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
414 headerSWF[ i ].reserved = DEFAULT_RESERVED;
438 headerSWF[ i ].reserved = DEFAULT_RESERVED;
415 headerSWF[ i ].userApplication = CCSDS_USER_APP;
439 headerSWF[ i ].userApplication = CCSDS_USER_APP;
416 headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
440 headerSWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
417 headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
441 headerSWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
418 if (i == 0)
442 if (i == 0)
419 {
443 {
420 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
444 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
421 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
445 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
422 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
446 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
423 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
447 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
424 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
448 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
425 }
449 }
426 else if (i == 6)
450 else if (i == 6)
427 {
451 {
428 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
452 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
429 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_8 >> 8);
453 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_8 >> 8);
430 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_8 );
454 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_8 );
431 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
455 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
432 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
456 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
433 }
457 }
434 else
458 else
435 {
459 {
436 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
460 headerSWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
437 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
461 headerSWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_SWF_340 >> 8);
438 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
462 headerSWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_SWF_340 );
439 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
463 headerSWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
440 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
464 headerSWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
441 }
465 }
442 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
466 headerSWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
443 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
467 headerSWF[ i ].pktCnt = DEFAULT_PKTCNT; // PKT_CNT
444 headerSWF[ i ].pktNr = i+1; // PKT_NR
468 headerSWF[ i ].pktNr = i+1; // PKT_NR
445 // DATA FIELD HEADER
469 // DATA FIELD HEADER
446 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
470 headerSWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
447 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
471 headerSWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
448 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
472 headerSWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
449 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
473 headerSWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
450 // AUXILIARY DATA HEADER
474 // AUXILIARY DATA HEADER
451 headerSWF[ i ].sid = sid;
475 headerSWF[ i ].sid = sid;
452 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
476 headerSWF[ i ].hkBIA = DEFAULT_HKBIA;
453 headerSWF[ i ].time[0] = 0x00;
477 headerSWF[ i ].time[0] = 0x00;
454 headerSWF[ i ].time[0] = 0x00;
478 headerSWF[ i ].time[0] = 0x00;
455 headerSWF[ i ].time[0] = 0x00;
479 headerSWF[ i ].time[0] = 0x00;
456 headerSWF[ i ].time[0] = 0x00;
480 headerSWF[ i ].time[0] = 0x00;
457 headerSWF[ i ].time[0] = 0x00;
481 headerSWF[ i ].time[0] = 0x00;
458 headerSWF[ i ].time[0] = 0x00;
482 headerSWF[ i ].time[0] = 0x00;
459 }
483 }
460 return LFR_SUCCESSFUL;
484 return LFR_SUCCESSFUL;
461 }
485 }
462
486
463 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
487 int init_header_continuous_wf_table( unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF )
464 {
488 {
465 unsigned int i;
489 unsigned int i;
466
490
467 for (i=0; i<7; i++)
491 for (i=0; i<7; i++)
468 {
492 {
469 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
493 headerCWF[ i ].targetLogicalAddress = CCSDS_DESTINATION_ID;
470 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
494 headerCWF[ i ].protocolIdentifier = CCSDS_PROTOCOLE_ID;
471 headerCWF[ i ].reserved = DEFAULT_RESERVED;
495 headerCWF[ i ].reserved = DEFAULT_RESERVED;
472 headerCWF[ i ].userApplication = CCSDS_USER_APP;
496 headerCWF[ i ].userApplication = CCSDS_USER_APP;
473 if (SID_SBM1_CWF_F1 || SID_SBM2_CWF_F2)
497 if (SID_SBM1_CWF_F1 || SID_SBM2_CWF_F2)
474 {
498 {
475 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
499 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2 >> 8);
476 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
500 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_SBM1_SBM2);
477 }
501 }
478 else
502 else
479 {
503 {
480 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
504 headerCWF[ i ].packetID[0] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST >> 8);
481 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
505 headerCWF[ i ].packetID[1] = (unsigned char) (TM_PACKET_ID_SCIENCE_NORMAL_BURST);
482 }
506 }
483 if (i == 0)
507 if (i == 0)
484 {
508 {
485 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
509 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_FIRST;
486 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
510 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
487 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
511 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
488 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
512 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
489 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
513 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
490 }
514 }
491 else if (i == 6)
515 else if (i == 6)
492 {
516 {
493 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
517 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_LAST;
494 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_8 >> 8);
518 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_8 >> 8);
495 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_8 );
519 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_8 );
496 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
520 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_8 >> 8);
497 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
521 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_8 );
498 }
522 }
499 else
523 else
500 {
524 {
501 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
525 headerCWF[ i ].packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_CONTINUATION;
502 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
526 headerCWF[ i ].packetLength[0] = (unsigned char) (TM_LEN_SCI_CWF_340 >> 8);
503 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
527 headerCWF[ i ].packetLength[1] = (unsigned char) (TM_LEN_SCI_CWF_340 );
504 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
528 headerCWF[ i ].blkNr[0] = (unsigned char) (BLK_NR_340 >> 8);
505 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
529 headerCWF[ i ].blkNr[1] = (unsigned char) (BLK_NR_340 );
506 }
530 }
507 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
531 headerCWF[ i ].packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT;
508 // PKT_CNT
532 // PKT_CNT
509 // PKT_NR
533 // PKT_NR
510 // DATA FIELD HEADER
534 // DATA FIELD HEADER
511 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
535 headerCWF[ i ].spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2;
512 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
536 headerCWF[ i ].serviceType = TM_TYPE_LFR_SCIENCE; // service type
513 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
537 headerCWF[ i ].serviceSubType = TM_SUBTYPE_LFR_SCIENCE; // service subtype
514 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
538 headerCWF[ i ].destinationID = TM_DESTINATION_ID_GROUND;
515 // AUXILIARY DATA HEADER
539 // AUXILIARY DATA HEADER
516 headerCWF[ i ].sid = sid;
540 headerCWF[ i ].sid = sid;
517 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
541 headerCWF[ i ].hkBIA = DEFAULT_HKBIA;
518 headerCWF[ i ].time[0] = 0x00;
542 headerCWF[ i ].time[0] = 0x00;
519 headerCWF[ i ].time[0] = 0x00;
543 headerCWF[ i ].time[0] = 0x00;
520 headerCWF[ i ].time[0] = 0x00;
544 headerCWF[ i ].time[0] = 0x00;
521 headerCWF[ i ].time[0] = 0x00;
545 headerCWF[ i ].time[0] = 0x00;
522 headerCWF[ i ].time[0] = 0x00;
546 headerCWF[ i ].time[0] = 0x00;
523 headerCWF[ i ].time[0] = 0x00;
547 headerCWF[ i ].time[0] = 0x00;
524 }
548 }
525 return LFR_SUCCESSFUL;
549 return LFR_SUCCESSFUL;
526 }
550 }
527
551
528 void reset_waveforms( void )
552 void reset_waveforms( void )
529 {
553 {
530 int i = 0;
554 int i = 0;
531
555
532 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
556 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
533 {
557 {
534 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x10002000;
558 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x10002000;
535 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
559 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
536 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
560 wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
537
561
538 //***
562 //***
539 // F1
563 // F1
540 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x1000f000;
564 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x1000f000;
541 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0xf0001000;
565 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0xf0001000;
542 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
566 wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000;
543
567
544 //***
568 //***
545 // F2
569 // F2
546 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x40008000;
570 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x40008000;
547 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
571 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000;
548 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x10002000;
572 wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x10002000;
549
573
550 //***
574 //***
551 // F3
575 // F3
552 /*wf_cont_f3[ i* NB_WORDS_SWF_BLK + 0 ] = build_value( i, i ); // v and 1
576 /*wf_cont_f3[ i* NB_WORDS_SWF_BLK + 0 ] = build_value( i, i ); // v and 1
553 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 1 ] = build_value( i, i ); // e2 and b1
577 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 1 ] = build_value( i, i ); // e2 and b1
554 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 2 ] = build_value( i, i ); // b2 and b3*/
578 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 2 ] = build_value( i, i ); // b2 and b3*/
555 }
579 }
556 }
580 }
557
581
558 int send_waveform_SWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_SWF_t *headerSWF )
582 int send_waveform_SWF( volatile int *waveform, unsigned int sid,
583 Header_TM_LFR_SCIENCE_SWF_t *headerSWF, rtems_id queue_id )
559 {
584 {
560 unsigned int i;
585 unsigned int i;
561 int ret;
586 int ret;
562 rtems_status_code status;
587 rtems_status_code status;
563 spw_ioctl_pkt_send spw_ioctl_send_SWF;
588 spw_ioctl_pkt_send spw_ioctl_send_SWF;
564
589
565 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
590 spw_ioctl_send_SWF.hlen = TM_HEADER_LEN + 4 + 12; // + 4 is for the protocole extra header, + 12 is for the auxiliary header
566 spw_ioctl_send_SWF.options = 0;
591 spw_ioctl_send_SWF.options = 0;
567
592
568 ret = LFR_DEFAULT;
593 ret = LFR_DEFAULT;
569
594
570 for (i=0; i<7; i++) // send waveform
595 for (i=0; i<7; i++) // send waveform
571 {
596 {
572 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
597 spw_ioctl_send_SWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
573 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
598 spw_ioctl_send_SWF.hdr = (char*) &headerSWF[ i ];
574 // BUILD THE DATA
599 // BUILD THE DATA
575 if (i==6) {
600 if (i==6) {
576 spw_ioctl_send_SWF.dlen = 8 * NB_BYTES_SWF_BLK;
601 spw_ioctl_send_SWF.dlen = 8 * NB_BYTES_SWF_BLK;
577 }
602 }
578 else {
603 else {
579 spw_ioctl_send_SWF.dlen = 340 * NB_BYTES_SWF_BLK;
604 spw_ioctl_send_SWF.dlen = 340 * NB_BYTES_SWF_BLK;
580 }
605 }
581 // SET PACKET TIME
606 // SET PACKET TIME
582 headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
607 headerSWF[ i ].time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
583 headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
608 headerSWF[ i ].time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
584 headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
609 headerSWF[ i ].time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
585 headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
610 headerSWF[ i ].time[3] = (unsigned char) (time_management_regs->coarse_time);
586 headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
611 headerSWF[ i ].time[4] = (unsigned char) (time_management_regs->fine_time>>8);
587 headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
612 headerSWF[ i ].time[5] = (unsigned char) (time_management_regs->fine_time);
588 headerSWF[ i ].acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
613 headerSWF[ i ].acquisitionTime[0] = (unsigned char) (time_management_regs->coarse_time>>24);
589 headerSWF[ i ].acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
614 headerSWF[ i ].acquisitionTime[1] = (unsigned char) (time_management_regs->coarse_time>>16);
590 headerSWF[ i ].acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
615 headerSWF[ i ].acquisitionTime[2] = (unsigned char) (time_management_regs->coarse_time>>8);
591 headerSWF[ i ].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
616 headerSWF[ i ].acquisitionTime[3] = (unsigned char) (time_management_regs->coarse_time);
592 headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
617 headerSWF[ i ].acquisitionTime[4] = (unsigned char) (time_management_regs->fine_time>>8);
593 headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
618 headerSWF[ i ].acquisitionTime[5] = (unsigned char) (time_management_regs->fine_time);
594 // SEND PACKET
619 // SEND PACKET
595 status = rtems_message_queue_send( misc_id[QUEUE_PKTS], &spw_ioctl_send_SWF, ACTION_MSG_PKTS_SIZE);
620 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_SWF, ACTION_MSG_PKTS_SIZE);
596 if (status != RTEMS_SUCCESSFUL) {
621 if (status != RTEMS_SUCCESSFUL) {
597 printf("%d-%d, ERR %d\n", sid, i, (int) status);
622 printf("%d-%d, ERR %d\n", sid, i, (int) status);
598 ret = LFR_DEFAULT;
623 ret = LFR_DEFAULT;
599 }
624 }
600 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
625 rtems_task_wake_after(TIME_BETWEEN_TWO_SWF_PACKETS); // 300 ms between each packet => 7 * 3 = 21 packets => 6.3 seconds
601 }
626 }
602
627
603 return ret;
628 return ret;
604 }
629 }
605
630
606 int send_waveform_CWF( volatile int *waveform, unsigned int sid, Header_TM_LFR_SCIENCE_CWF_t *headerCWF)
631 int send_waveform_CWF(volatile int *waveform, unsigned int sid,
632 Header_TM_LFR_SCIENCE_CWF_t *headerCWF, rtems_id queue_id)
607 {
633 {
608 unsigned int i;
634 unsigned int i;
609 int ret;
635 int ret;
610 rtems_status_code status;
636 rtems_status_code status;
611 spw_ioctl_pkt_send spw_ioctl_send_CWF;
637 spw_ioctl_pkt_send spw_ioctl_send_CWF;
612
638
613 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
639 spw_ioctl_send_CWF.hlen = TM_HEADER_LEN + 4 + 10; // + 4 is for the protocole extra header, + 10 is for the auxiliary header
614 spw_ioctl_send_CWF.options = 0;
640 spw_ioctl_send_CWF.options = 0;
615
641
616 ret = LFR_DEFAULT;
642 ret = LFR_DEFAULT;
617
643
618 for (i=0; i<7; i++) // send waveform
644 for (i=0; i<7; i++) // send waveform
619 {
645 {
620 int coarseTime = 0x00;
646 int coarseTime = 0x00;
621 int fineTime = 0x00;
647 int fineTime = 0x00;
622 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
648 spw_ioctl_send_CWF.data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ];
623 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
649 spw_ioctl_send_CWF.hdr = (char*) &headerCWF[ i ];
624 // BUILD THE DATA
650 // BUILD THE DATA
625 if (i==6) {
651 if (i==6) {
626 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_SWF_BLK;
652 spw_ioctl_send_CWF.dlen = 8 * NB_BYTES_SWF_BLK;
627 }
653 }
628 else {
654 else {
629 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_SWF_BLK;
655 spw_ioctl_send_CWF.dlen = 340 * NB_BYTES_SWF_BLK;
630 }
656 }
631 // SET PACKET TIME
657 // SET PACKET TIME
632 coarseTime = time_management_regs->coarse_time;
658 coarseTime = time_management_regs->coarse_time;
633 fineTime = time_management_regs->fine_time;
659 fineTime = time_management_regs->fine_time;
634 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
660 headerCWF[ i ].time[0] = (unsigned char) (coarseTime>>24);
635 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
661 headerCWF[ i ].time[1] = (unsigned char) (coarseTime>>16);
636 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
662 headerCWF[ i ].time[2] = (unsigned char) (coarseTime>>8);
637 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
663 headerCWF[ i ].time[3] = (unsigned char) (coarseTime);
638 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
664 headerCWF[ i ].time[4] = (unsigned char) (fineTime>>8);
639 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
665 headerCWF[ i ].time[5] = (unsigned char) (fineTime);
640 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
666 headerCWF[ i ].acquisitionTime[0] = (unsigned char) (coarseTime>>24);
641 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
667 headerCWF[ i ].acquisitionTime[1] = (unsigned char) (coarseTime>>16);
642 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
668 headerCWF[ i ].acquisitionTime[2] = (unsigned char) (coarseTime>>8);
643 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
669 headerCWF[ i ].acquisitionTime[3] = (unsigned char) (coarseTime);
644 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
670 headerCWF[ i ].acquisitionTime[4] = (unsigned char) (fineTime>>8);
645 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
671 headerCWF[ i ].acquisitionTime[5] = (unsigned char) (fineTime);
646 // SEND PACKET
672 // SEND PACKET
647 if (sid == SID_NORM_CWF_F3)
673 if (sid == SID_NORM_CWF_F3)
648 {
674 {
649 status = rtems_message_queue_send( misc_id[QUEUE_PKTS], &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
675 status = rtems_message_queue_send( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
650 if (status != RTEMS_SUCCESSFUL) {
676 if (status != RTEMS_SUCCESSFUL) {
651 printf("%d-%d, ERR %d\n", sid, i, (int) status);
677 printf("%d-%d, ERR %d\n", sid, i, (int) status);
652 ret = LFR_DEFAULT;
678 ret = LFR_DEFAULT;
653 }
679 }
654 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
680 rtems_task_wake_after(TIME_BETWEEN_TWO_CWF3_PACKETS);
655 }
681 }
656 else
682 else
657 {
683 {
658 status = rtems_message_queue_urgent( misc_id[QUEUE_PKTS], &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
684 status = rtems_message_queue_urgent( queue_id, &spw_ioctl_send_CWF, sizeof(spw_ioctl_send_CWF));
659 if (status != RTEMS_SUCCESSFUL) {
685 if (status != RTEMS_SUCCESSFUL) {
660 printf("%d-%d, ERR %d\n", sid, i, (int) status);
686 printf("%d-%d, ERR %d\n", sid, i, (int) status);
661 ret = LFR_DEFAULT;
687 ret = LFR_DEFAULT;
662 }
688 }
663 }
689 }
664 }
690 }
665
691
666 return ret;
692 return ret;
667 }
693 }
668
694
669 //**************
695 //**************
670 // wfp registers
696 // wfp registers
671 void set_wfp_data_shaping()
697 void set_wfp_data_shaping()
672 {
698 {
673 unsigned char data_shaping;
699 unsigned char data_shaping;
674
700
675 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
701 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
676 // waveform picker : [R1 R0 SP1 SP0 BW]
702 // waveform picker : [R1 R0 SP1 SP0 BW]
677
703
678 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
704 data_shaping = parameter_dump_packet.bw_sp0_sp1_r0_r1;
679
705
680 #ifdef GSA
706 #ifdef GSA
681 #else
707 #else
682 waveform_picker_regs->data_shaping =
708 waveform_picker_regs->data_shaping =
683 ( (data_shaping & 0x10) >> 4 ) // BW
709 ( (data_shaping & 0x10) >> 4 ) // BW
684 + ( (data_shaping & 0x08) >> 2 ) // SP0
710 + ( (data_shaping & 0x08) >> 2 ) // SP0
685 + ( (data_shaping & 0x04) ) // SP1
711 + ( (data_shaping & 0x04) ) // SP1
686 + ( (data_shaping & 0x02) << 2 ) // R0
712 + ( (data_shaping & 0x02) << 2 ) // R0
687 + ( (data_shaping & 0x01) << 4 ); // R1
713 + ( (data_shaping & 0x01) << 4 ); // R1
688 #endif
714 #endif
689 }
715 }
690
716
691 char set_wfp_delta_snapshot()
717 char set_wfp_delta_snapshot()
692 {
718 {
693 char ret;
719 char ret;
694 unsigned int delta_snapshot;
720 unsigned int delta_snapshot;
695 ret = LFR_DEFAULT;
721 ret = LFR_DEFAULT;
696
722
697 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
723 delta_snapshot = parameter_dump_packet.sy_lfr_n_swf_p[0]*256
698 + parameter_dump_packet.sy_lfr_n_swf_p[1];
724 + parameter_dump_packet.sy_lfr_n_swf_p[1];
699
725
700 #ifdef GSA
726 #ifdef GSA
701 #else
727 #else
702 unsigned char aux = 0;
728 unsigned char aux = 0;
703 if ( delta_snapshot < MIN_DELTA_SNAPSHOT )
729 if ( delta_snapshot < MIN_DELTA_SNAPSHOT )
704 {
730 {
705 aux = MIN_DELTA_SNAPSHOT;
731 aux = MIN_DELTA_SNAPSHOT;
706 ret = LFR_DEFAULT;
732 ret = LFR_DEFAULT;
707 }
733 }
708 else
734 else
709 {
735 {
710 aux = delta_snapshot ;
736 aux = delta_snapshot ;
711 ret = LFR_SUCCESSFUL;
737 ret = LFR_SUCCESSFUL;
712 }
738 }
713 waveform_picker_regs->delta_snapshot = aux; // max 2 bytes
739 waveform_picker_regs->delta_snapshot = aux; // max 2 bytes
714 #endif
740 #endif
715
741
716 return ret;
742 return ret;
717 }
743 }
718
744
719 void set_wfp_burst_enable_register( unsigned char mode)
745 void set_wfp_burst_enable_register( unsigned char mode)
720 {
746 {
721 #ifdef GSA
747 #ifdef GSA
722 #else
748 #else
723 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
749 // [0000 0000] burst f2, f1, f0 enable f3 f2 f1 f0
724 // the burst bits shall be set first, before the enable bits
750 // the burst bits shall be set first, before the enable bits
725 switch(mode) {
751 switch(mode) {
726 case(LFR_MODE_NORMAL):
752 case(LFR_MODE_NORMAL):
753 waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enable
727 waveform_picker_regs->burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
754 waveform_picker_regs->burst_enable = 0x0f; // [0000 1111] enable f3 f2 f1 f0
728 break;
755 break;
729 case(LFR_MODE_BURST):
756 case(LFR_MODE_BURST):
730 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled
757 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled
731 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x04; // [0100] enable f2
758 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x04; // [0100] enable f2
732 break;
759 break;
733 case(LFR_MODE_SBM1):
760 case(LFR_MODE_SBM1):
734 waveform_picker_regs->burst_enable = 0x20; // [0010 0000] f1 burst enabled
761 waveform_picker_regs->burst_enable = 0x20; // [0010 0000] f1 burst enabled
735 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
762 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
736 break;
763 break;
737 case(LFR_MODE_SBM2):
764 case(LFR_MODE_SBM2):
738 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled
765 waveform_picker_regs->burst_enable = 0x40; // [0100 0000] f2 burst enabled
739 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
766 waveform_picker_regs->burst_enable = waveform_picker_regs->burst_enable | 0x0f; // [1111] enable f3 f2 f1 f0
740 break;
767 break;
741 default:
768 default:
742 waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
769 waveform_picker_regs->burst_enable = 0x00; // [0000 0000] no burst enabled, no waveform enabled
743 break;
770 break;
744 }
771 }
745 #endif
772 #endif
746 }
773 }
747
774
748 void reset_wfp_burst_enable()
775 void reset_wfp_burst_enable()
749 {
776 {
750 #ifdef GSA
777 #ifdef GSA
751 #else
778 #else
752 waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
779 waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
753 #endif
780 #endif
754 }
781 }
755
782
756 void reset_wfp_status()
783 void reset_wfp_status()
757 {
784 {
758 #ifdef GSA
785 #ifdef GSA
759 #else
786 #else
760 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
787 waveform_picker_regs->status = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
761 #endif
788 #endif
762 }
789 }
763
790
764 void reset_waveform_picker_regs()
791 void reset_waveform_picker_regs()
765 {
792 {
766 #ifdef GSA
793 #ifdef GSA
767 #else
794 #else
768 set_wfp_data_shaping();
795 set_wfp_data_shaping();
769 reset_wfp_burst_enable();
796 reset_wfp_burst_enable();
770 waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); //
797 waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); //
771 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); //
798 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); //
772 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); //
799 waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); //
773 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); //
800 waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); //
774 set_wfp_delta_snapshot(); // time in seconds between two snapshots
801 set_wfp_delta_snapshot(); // time in seconds between two snapshots
775 waveform_picker_regs->delta_f2_f1 = 0xffff; // 0x16800 => 92160 (max 4 bytes)
802 waveform_picker_regs->delta_f2_f1 = 0xffff; // 0x16800 => 92160 (max 4 bytes)
776 waveform_picker_regs->delta_f2_f0 = 0x17c00; // 97 280 (max 5 bytes)
803 waveform_picker_regs->delta_f2_f0 = 0x17c00; // 97 280 (max 5 bytes)
777 waveform_picker_regs->nb_burst_available = 0x180; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets)
804 waveform_picker_regs->nb_burst_available = 0x180; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets)
778 waveform_picker_regs->nb_snapshot_param = 0x7ff; // max 3 octets, 2048 - 1
805 waveform_picker_regs->nb_snapshot_param = 0x7ff; // max 3 octets, 2048 - 1
779 waveform_picker_regs->status = 0x00; //
806 waveform_picker_regs->status = 0x00; //
780 #endif
807 #endif
781 }
808 }
782
809
783 //*****************
810 //*****************
784 // local parameters
811 // local parameters
785 void set_local_sbm1_nb_cwf_max()
812 void set_local_sbm1_nb_cwf_max()
786 {
813 {
787 // (2 snapshots of 2048 points per seconds) * (period of the NORM snashots) - 8 s (duration of the f2 snapshot)
814 // (2 snapshots of 2048 points per seconds) * (period of the NORM snashots) - 8 s (duration of the f2 snapshot)
788 param_local.local_sbm1_nb_cwf_max = 2 *
815 param_local.local_sbm1_nb_cwf_max = 2 *
789 (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
816 (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
790 + parameter_dump_packet.sy_lfr_n_swf_p[1]) - 8; // 16 CWF1 parts during 1 SWF2
817 + parameter_dump_packet.sy_lfr_n_swf_p[1]) - 8; // 16 CWF1 parts during 1 SWF2
791 }
818 }
792
819
793 void set_local_sbm2_nb_cwf_max()
820 void set_local_sbm2_nb_cwf_max()
794 {
821 {
795 // (period of the NORM snashots) / (8 seconds per snapshot at f2 = 256 Hz)
822 // (period of the NORM snashots) / (8 seconds per snapshot at f2 = 256 Hz)
796 param_local.local_sbm2_nb_cwf_max = (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
823 param_local.local_sbm2_nb_cwf_max = (parameter_dump_packet.sy_lfr_n_swf_p[0] * 256
797 + parameter_dump_packet.sy_lfr_n_swf_p[1]) / 8;
824 + parameter_dump_packet.sy_lfr_n_swf_p[1]) / 8;
798 }
825 }
799
826
800 void set_local_nb_interrupt_f0_MAX()
827 void set_local_nb_interrupt_f0_MAX()
801 {
828 {
802 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
829 param_local.local_nb_interrupt_f0_MAX = ( (parameter_dump_packet.sy_lfr_n_asm_p[0]) * 256
803 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
830 + parameter_dump_packet.sy_lfr_n_asm_p[1] ) * 100;
804 }
831 }
805
832
806 void reset_local_sbm1_nb_cwf_sent()
833 void reset_local_sbm1_nb_cwf_sent()
807 {
834 {
808 param_local.local_sbm1_nb_cwf_sent = 0;
835 param_local.local_sbm1_nb_cwf_sent = 0;
809 }
836 }
810
837
811 void reset_local_sbm2_nb_cwf_sent()
838 void reset_local_sbm2_nb_cwf_sent()
812 {
839 {
813 param_local.local_sbm2_nb_cwf_sent = 0;
840 param_local.local_sbm2_nb_cwf_sent = 0;
814 }
841 }
General Comments 0
You need to be logged in to leave comments. Login now