##// END OF EJS Templates
All modes implemented for the waveforms...
paul@pc-solar1.lab-lpp.local -
r23:af9a6b32a71f default
parent child
Show More
@@ -1,6 +1,6
1 #############################################################################
1 #############################################################################
2 # Makefile for building: bin/fsw-gsa
2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.4) on: Tue Jun 18 14:00:55 2013
3 # Generated by qmake (2.01a) (Qt 4.8.4) on: Fri Jun 28 07:59:21 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
@@ -10,7 +10,7
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=5 -DPRINT_MESSAGES_ON_CONSOLE -DGSA
13 DEFINES = -DSW_VERSION_N1=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=5 -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
@@ -78,9 +78,9 DIST = /usr/lib64/qt4/mkspecs/c
78 /usr/lib64/qt4/mkspecs/features/lex.prf \
78 /usr/lib64/qt4/mkspecs/features/lex.prf \
79 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
79 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
80 fsw-qt.pro
80 fsw-qt.pro
81 QMAKE_TARGET = fsw-gsa
81 QMAKE_TARGET = fsw
82 DESTDIR = bin/
82 DESTDIR = bin/
83 TARGET = bin/fsw-gsa
83 TARGET = bin/fsw
84
84
85 first: all
85 first: all
86 ####### Implicit rules
86 ####### Implicit rules
@@ -159,8 +159,8 qmake: FORCE
159 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
159 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
160
160
161 dist:
161 dist:
162 @$(CHK_DIR_EXISTS) obj/fsw-gsa1.0.0 || $(MKDIR) obj/fsw-gsa1.0.0
162 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.0.0
163 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw-gsa1.0.0/ && (cd `dirname obj/fsw-gsa1.0.0` && $(TAR) fsw-gsa1.0.0.tar fsw-gsa1.0.0 && $(COMPRESS) fsw-gsa1.0.0.tar) && $(MOVE) `dirname obj/fsw-gsa1.0.0`/fsw-gsa1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw-gsa1.0.0
163 $(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
164
164
165
165
166 clean:compiler_clean
166 clean:compiler_clean
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -1,7 +1,7
1 TEMPLATE = app
1 TEMPLATE = app
2 # CONFIG += console v8 sim
2 # CONFIG += console v8 sim
3 # CONFIG options = verbose *** cpu_usage_report *** gsa
3 # CONFIG options = verbose *** cpu_usage_report *** gsa
4 CONFIG += console verbose gsa
4 CONFIG += console verbose
5 CONFIG -= qt
5 CONFIG -= qt
6
6
7 include(./sparc.pri)
7 include(./sparc.pri)
@@ -1,6 +1,6
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 Qt Creator 2.4.1, 2013-06-18T14:38:28. -->
3 <!-- Written by Qt Creator 2.4.1, 2013-06-28T14:26:12. -->
4 <qtcreator>
4 <qtcreator>
5 <data>
5 <data>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -10,11 +10,34
10 #define CCSDS_PROCESS_ID 76
10 #define CCSDS_PROCESS_ID 76
11 #define CCSDS_PACKET_CATEGORY 12
11 #define CCSDS_PACKET_CATEGORY 12
12 #define CCSDS_NODE_ADDRESS 0xfe
12 #define CCSDS_NODE_ADDRESS 0xfe
13
14 // PACKET IDs
15 #define TM_PACKET_ID_TC_EXE 0x0cc1 // PID 76 CAT 1
16 #define TM_PACKET_ID_HK 0x0cc4 // PID 76 CAT 4
17 #define TM_PACKET_ID_PARAMETER_DUMP 0x0cc9 // PID 76 CAT 9
18 #define TM_PACKET_ID_SCIENCE_NORMAL 0x0ccc // PID 76 CAT 12
19 #define TM_PACKET_ID_SCIENCE_BURST_SBM1_SBM2 0x0cfc // PID 79 CAT 12
20
21 // FAILURE CODES
22 #define FAILURE_CODE_INCONSISTENT 5 // 0x00 0x05
23 #define FAILURE_CODE_NOT_EXECUTABLE 40000 // 0x9c 0x40
24 #define FAILURE_CODE_NOT_IMPLEMENTED 40002 // 0x9c 0x42
25 #define FAILURE_CODE_ERROR 40003 // 0x9c 0x43
26 #define FAILURE_CODE_CORRUPTED 40005 // 0x9c 0x45
13 //
27 //
14 #define CCSDS_DESTINATION_ID_GROUND 0x00
28 #define TM_DESTINATION_ID_GROUND 0
29 #define TM_DESTINATION_ID_MISSION_TIMELINE 110
30 #define TM_DESTINATION_ID_TC_SEQUENCES 111
31 #define TM_DESTINATION_ID_RECOVERY_ACTION_COMMAND 112
32 #define TM_DESTINATION_ID_BACKUP_MISSION_TIMELINE 113
33 #define TM_DESTINATION_ID_DIRECT_CMD 120
34 #define TM_DESTINATION_ID_SPARE_GRD_SRC1 121
35 #define TM_DESTINATION_ID_SPARE_GRD_SRC2 122
36 #define TM_DESTINATION_ID_OBCP 15
37 #define TM_DESTINATION_ID_SYSTEM_CONTROL 14
38 #define TM_DESTINATION_ID_AOCS 11
39
15 #define CCSDS_DESTINATION_ID 0x01
40 #define CCSDS_DESTINATION_ID 0x01
16 #define CCSDS_DESTINATION_ID_DPU 0x01
17 //
18 #define CCSDS_PROTOCOLE_ID 0x02
41 #define CCSDS_PROTOCOLE_ID 0x02
19 #define CCSDS_USER_APP 0x00
42 #define CCSDS_USER_APP 0x00
20
43
@@ -64,8 +87,9
64 #define TC_LEN_UPDT_TIME 18
87 #define TC_LEN_UPDT_TIME 18
65
88
66 // TM TYPES
89 // TM TYPES
90 #define TM_TYPE_TC_EXE 1
91 #define TM_TYPE_HK 3
67 #define TM_TYPE_LFR_SCIENCE 21
92 #define TM_TYPE_LFR_SCIENCE 21
68 #define TM_TYPE_HK 3
69
93
70 // TM SUBTYPES
94 // TM SUBTYPES
71 #define TM_SUBTYPE_EXE_OK 7
95 #define TM_SUBTYPE_EXE_OK 7
@@ -111,22 +135,26
111 #define SID_SBM1_BP2_F1 33
135 #define SID_SBM1_BP2_F1 33
112
136
113 // LENGTH (BYTES)
137 // LENGTH (BYTES)
138 #define LENGTH_TM_LFR_TC_EXE_MAX 32
114 #define LENGTH_TM_LFR_HK 126
139 #define LENGTH_TM_LFR_HK 126
115 #define LENGTH_TM_LFR_TC_EXE_MAX 32
140 // PACKET_LENGTH
116 #define LENGTH_TM_LFR_SCIENCE_NORMAL_WF_MAX 4102
141 #define PACKET_LENGTH_TC_EXE_SUCCESS 20 - CCSDS_TC_TM_PACKET_OFFSET
117 //
142 #define PACKET_LENGTH_TC_EXE_INCONSISTENT 26 - CCSDS_TC_TM_PACKET_OFFSET
118 #define TM_LEN_EXE 20 - CCSDS_TC_TM_PACKET_OFFSET
143 #define PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE 26 - CCSDS_TC_TM_PACKET_OFFSET
119 #define TM_LEN_NOT_EXE 26 - CCSDS_TC_TM_PACKET_OFFSET
144 #define PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED 24 - CCSDS_TC_TM_PACKET_OFFSET
120 #define TM_LEN_NOT_IMP 24 - CCSDS_TC_TM_PACKET_OFFSET
145 #define PACKET_LENGTH_TC_EXE_ERROR 24 - CCSDS_TC_TM_PACKET_OFFSET
121 #define TM_LEN_EXE_ERR 24 - CCSDS_TC_TM_PACKET_OFFSET
146 #define PACKET_LENGTH_TC_EXE_CORRUPTED 32 - CCSDS_TC_TM_PACKET_OFFSET
122 #define TM_LEN_EXE_CORR 32 - CCSDS_TC_TM_PACKET_OFFSET
147 #define PACKET_LENGTH_HK 126 - CCSDS_TC_TM_PACKET_OFFSET
148 #define PACKET_LENGTH_PARAMETER_DUMP 28 - CCSDS_TC_TM_PACKET_OFFSET
123 #define TM_HEADER_LEN 16
149 #define TM_HEADER_LEN 16
124
150
125 #define LEN_TM_LFR_HK 126 + 4
151 #define LEN_TM_LFR_HK 126 + 4
126 #define LEN_TM_LFR_TC_EXE_NOT_IMP 24 +4
152 #define LEN_TM_LFR_TC_EXE_NOT_IMP 24 +4
127
153
128 #define TM_LEN_SCI_NORM_SWF_340 340 * 12 + 6 + 10 - 1
154 #define TM_LEN_SCI_SWF_340 340 * 12 + 10 + 12 - 1
129 #define TM_LEN_SCI_NORM_SWF_8 8 * 12 + 6 + 10 - 1
155 #define TM_LEN_SCI_SWF_8 8 * 12 + 10 + 12 - 1
156 #define TM_LEN_SCI_CWF_340 340 * 12 + 10 + 10 - 1
157 #define TM_LEN_SCI_CWF_8 8 * 12 + 10 + 10 - 1
130
158
131 enum TM_TYPE{
159 enum TM_TYPE{
132 TM_LFR_TC_EXE_OK,
160 TM_LFR_TC_EXE_OK,
@@ -146,7 +174,12 struct TMHeader_str
146 volatile unsigned char packetID[2];
174 volatile unsigned char packetID[2];
147 volatile unsigned char packetSequenceControl[2];
175 volatile unsigned char packetSequenceControl[2];
148 volatile unsigned char packetLength[2];
176 volatile unsigned char packetLength[2];
149 volatile unsigned char dataFieldHeader[10];
177 // DATA FIELD HEADER
178 volatile unsigned char spare1_pusVersion_spare2;
179 volatile unsigned char serviceType;
180 volatile unsigned char serviceSubType;
181 volatile unsigned char destinationID;
182 volatile unsigned char time[6];
150 };
183 };
151 typedef struct TMHeader_str TMHeader_t;
184 typedef struct TMHeader_str TMHeader_t;
152
185
@@ -159,12 +192,17 struct Packet_TM_LFR_TC_EXE_str
159 volatile unsigned char packetID[2];
192 volatile unsigned char packetID[2];
160 volatile unsigned char packetSequenceControl[2];
193 volatile unsigned char packetSequenceControl[2];
161 volatile unsigned char packetLength[2];
194 volatile unsigned char packetLength[2];
162 volatile unsigned char dataFieldHeader[10];
195 // DATA FIELD HEADER
196 volatile unsigned char spare1_pusVersion_spare2;
197 volatile unsigned char serviceType;
198 volatile unsigned char serviceSubType;
199 volatile unsigned char destinationID;
200 volatile unsigned char time[6];
163 volatile unsigned char data[LENGTH_TM_LFR_TC_EXE_MAX - 10 + 1];
201 volatile unsigned char data[LENGTH_TM_LFR_TC_EXE_MAX - 10 + 1];
164 };
202 };
165 typedef struct Packet_TM_LFR_TC_EXE_str Packet_TM_LFR_TC_EXE_t;
203 typedef struct Packet_TM_LFR_TC_EXE_str Packet_TM_LFR_TC_EXE_t;
166
204
167 struct Packet_TM_LFR_SCIENCE_NORMAL_WF_str
205 struct Header_TM_LFR_SCIENCE_SWF_str
168 {
206 {
169 volatile unsigned char targetLogicalAddress;
207 volatile unsigned char targetLogicalAddress;
170 volatile unsigned char protocolIdentifier;
208 volatile unsigned char protocolIdentifier;
@@ -173,13 +211,23 struct Packet_TM_LFR_SCIENCE_NORMAL_WF_s
173 volatile unsigned char packetID[2];
211 volatile unsigned char packetID[2];
174 volatile unsigned char packetSequenceControl[2];
212 volatile unsigned char packetSequenceControl[2];
175 volatile unsigned char packetLength[2];
213 volatile unsigned char packetLength[2];
176 volatile unsigned char dataFieldHeader[10];
214 // DATA FIELD HEADER
177 volatile unsigned char auxiliaryHeader[6];
215 volatile unsigned char spare1_pusVersion_spare2;
178 volatile unsigned char data[LENGTH_TM_LFR_SCIENCE_NORMAL_WF_MAX - 10 + 1];
216 volatile unsigned char serviceType;
217 volatile unsigned char serviceSubType;
218 volatile unsigned char destinationID;
219 volatile unsigned char time[6];
220 // AUXILIARY HEADER
221 volatile unsigned char sid;
222 volatile unsigned char hkBIA;
223 volatile unsigned char pktCnt;
224 volatile unsigned char pktNr;
225 volatile unsigned char acquisitionTime[6];
226 volatile unsigned char blkNr[2];
179 };
227 };
180 typedef struct Packet_TM_LFR_SCIENCE_NORMAL_WF_str Packet_TM_LFR_SCIENCE_NORMAL_WF_t;
228 typedef struct Header_TM_LFR_SCIENCE_SWF_str Header_TM_LFR_SCIENCE_SWF_t;
181
229
182 struct ExtendedTMHeader_str
230 struct Header_TM_LFR_SCIENCE_CWF_str
183 {
231 {
184 volatile unsigned char targetLogicalAddress;
232 volatile unsigned char targetLogicalAddress;
185 volatile unsigned char protocolIdentifier;
233 volatile unsigned char protocolIdentifier;
@@ -188,10 +236,19 struct ExtendedTMHeader_str
188 volatile unsigned char packetID[2];
236 volatile unsigned char packetID[2];
189 volatile unsigned char packetSequenceControl[2];
237 volatile unsigned char packetSequenceControl[2];
190 volatile unsigned char packetLength[2];
238 volatile unsigned char packetLength[2];
191 volatile unsigned char dataFieldHeader[10];
239 // DATA FIELD HEADER
192 volatile unsigned char auxiliaryHeader[6];
240 volatile unsigned char spare1_pusVersion_spare2;
241 volatile unsigned char serviceType;
242 volatile unsigned char serviceSubType;
243 volatile unsigned char destinationID;
244 volatile unsigned char time[6];
245 // AUXILIARY DATA HEADER
246 volatile unsigned char sid;
247 volatile unsigned char hkBIA;
248 volatile unsigned char acquisitionTime[6];
249 volatile unsigned char blkNr[2];
193 };
250 };
194 typedef struct ExtendedTMHeader_str ExtendedTMHeader_t;
251 typedef struct Header_TM_LFR_SCIENCE_CWF_str Header_TM_LFR_SCIENCE_CWF_t;
195
252
196 struct ccsdsTelecommandPacket_str
253 struct ccsdsTelecommandPacket_str
197 {
254 {
@@ -202,7 +259,11 struct ccsdsTelecommandPacket_str
202 volatile unsigned char packetID[2];
259 volatile unsigned char packetID[2];
203 volatile unsigned char packetSequenceControl[2];
260 volatile unsigned char packetSequenceControl[2];
204 volatile unsigned char packetLength[2];
261 volatile unsigned char packetLength[2];
205 volatile unsigned char dataFieldHeader[4];
262 // DATA FIELD HEADER
263 volatile unsigned char headerFlag_pusVersion_Ack;
264 volatile unsigned char serviceType;
265 volatile unsigned char serviceSubType;
266 volatile unsigned char sourceID;
206 volatile unsigned char dataAndCRC[CCSDS_TC_PKT_MAX_SIZE-10];
267 volatile unsigned char dataAndCRC[CCSDS_TC_PKT_MAX_SIZE-10];
207 };
268 };
208 typedef struct ccsdsTelecommandPacket_str ccsdsTelecommandPacket_t;
269 typedef struct ccsdsTelecommandPacket_str ccsdsTelecommandPacket_t;
@@ -28,6 +28,7 extern int fdUART; // uart file descrip
28 void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc);
28 void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc);
29
29
30 // MODE PARAMETERS
30 // MODE PARAMETERS
31 extern struct param_local_str param_local;
31 extern struct param_common_str param_common;
32 extern struct param_common_str param_common;
32 extern struct param_norm_str param_norm;
33 extern struct param_norm_str param_norm;
33 extern struct param_burst_str param_burst;
34 extern struct param_burst_str param_burst;
@@ -51,9 +52,11 int create_message_queue( void );
51 void init_default_mode_parameters( void );
52 void init_default_mode_parameters( void );
52 void init_housekeeping_parameters( void );
53 void init_housekeeping_parameters( void );
53
54
54 int configure_spw_link( void );
55 int spacewire_configure_link( void );
55 void configure_spacewire_set_NP(unsigned char val, unsigned int regAddr); // No Port force
56 int spacewire_try_to_start(void);
56 void configure_spacewire_set_RE(unsigned char val, unsigned int regAddr); // RMAP Enable
57 void spacewire_set_NP(unsigned char val, unsigned int regAddr); // No Port force
58 void spacewire_set_RE(unsigned char val, unsigned int regAddr); // RMAP Enable
59 void spacewire_compute_stats_offsets();
57
60
58 extern int rtems_cpu_usage_report( void );
61 extern int rtems_cpu_usage_report( void );
59 extern int rtems_cpu_usage_reset( void );
62 extern int rtems_cpu_usage_reset( void );
@@ -12,10 +12,12
12
12
13 rtems_name HK_name; // name of the HK rate monotonic
13 rtems_name HK_name; // name of the HK rate monotonic
14 rtems_id HK_id; // id of the HK rate monotonic period
14 rtems_id HK_id; // id of the HK rate monotonic period
15 extern spw_stats spacewire_stats;
16 extern spw_stats spacewire_stats_backup;
15
17
16 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,
17 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
19 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
18 void print_statistics(spw_stats *stats);
20 void update_spacewire_statistics();
19
21
20 // SERIAL LINK
22 // SERIAL LINK
21 int send_console_outputs_on_serial_port( void );
23 int send_console_outputs_on_serial_port( void );
@@ -22,6 +22,24
22 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
22 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
23 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
23 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
24
24
25 //****************************
26 // LFR DEFAULT MODE PARAMETERS
27 // NORM
28 #define DEFAULT_SY_LFR_N_SWF_L 2048 // nb sample
29 #define DEFAULT_SY_LFR_N_SWF_P 16 // sec
30 #define DEFAULT_SY_LFR_N_ASM_P 3600 // sec
31 #define DEFAULT_SY_LFR_N_BP_P0 4 // sec
32 #define DEFAULT_SY_LFR_N_BP_P1 20 // sec
33 // BURST
34 #define DEFAULT_SY_LFR_B_BP_P0 1 // sec
35 #define DEFAULT_SY_LFR_B_BP_P1 5 // sec
36 // SBM1
37 #define DEFAULT_SY_LFR_S1_BP_P0 1 // sec
38 #define DEFAULT_SY_LFR_S1_BP_P1 1 // sec
39 // SBM2
40 #define DEFAULT_SY_LFR_S2_BP_P0 1 // sec
41 #define DEFAULT_SY_LFR_S2_BP_P1 5 // sec
42
25 //*****************************
43 //*****************************
26 // APB REGISTERS BASE ADDRESSES
44 // APB REGISTERS BASE ADDRESSES
27 #define REGS_ADDR_APBUART 0x80000100
45 #define REGS_ADDR_APBUART 0x80000100
@@ -119,6 +137,13
119 #define SEQ_CNT_DST_ID_SYSTEM_CONTROL 9
137 #define SEQ_CNT_DST_ID_SYSTEM_CONTROL 9
120 #define SEQ_CNT_DST_ID_AOCS 10
138 #define SEQ_CNT_DST_ID_AOCS 10
121
139
140 struct param_local_str{
141 unsigned int local_sbm1_nb_cwf_sent;
142 unsigned int local_sbm1_nb_cwf_max;
143 unsigned int local_sbm2_nb_cwf_sent;
144 unsigned int local_sbm2_nb_cwf_max;
145 };
146
122 struct param_common_str{
147 struct param_common_str{
123 unsigned char sy_lfr_common0;
148 unsigned char sy_lfr_common0;
124 unsigned char sy_lfr_common1;
149 unsigned char sy_lfr_common1;
@@ -36,12 +36,12 void GetCRCAsTwoBytes(unsigned char* dat
36
36
37 //*********************
37 //*********************
38 // ACCEPTANCE FUNCTIONS
38 // ACCEPTANCE FUNCTIONS
39 unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int tc_len_recv);
39 int TC_acceptance(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV);
40 unsigned char TC_parser(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV);
40
41
41 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
42 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
42 unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader);
43 TMHeader_t *TMHeader, unsigned char tc_sid);
43 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC);
44 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC);
44 int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV);
45
45
46 //***********
46 //***********
47 // RTEMS TASK
47 // RTEMS TASK
@@ -53,22 +53,33 int create_message_queue( void );
53 //***********
53 //***********
54 // TC ACTIONS
54 // TC ACTIONS
55 int action_default(ccsdsTelecommandPacket_t *TC);
55 int action_default(ccsdsTelecommandPacket_t *TC);
56 int action_default_alt(ccsdsTelecommandPacket_t *TC);
56 int action_enter(ccsdsTelecommandPacket_t *TC);
57 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC);
57 int action_updt_info(ccsdsTelecommandPacket_t *TC);
58 //
58 int action_enable_calibration(ccsdsTelecommandPacket_t *TC);
59 int action_disable_calibration(ccsdsTelecommandPacket_t *TC);
60 int action_updt_time(ccsdsTelecommandPacket_t *TC);
61 // mode transition
62 int transition_validation(unsigned char requestedMode);
59 int stop_current_mode();
63 int stop_current_mode();
60 int enter_normal_mode();
64 int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC);
61 int enter_burst_mode();
65 int enter_standby_mode(ccsdsTelecommandPacket_t *TC);
62 int enter_sbm1_mode();
66 int enter_normal_mode(ccsdsTelecommandPacket_t *TC);
63 int enter_sbm2_mode();
67 int enter_burst_mode(ccsdsTelecommandPacket_t *TC);
68 int enter_sbm1_mode(ccsdsTelecommandPacket_t *TC);
69 int enter_sbm2_mode(ccsdsTelecommandPacket_t *TC);
70 // parameters loading
64 int action_load_comm(ccsdsTelecommandPacket_t *TC);
71 int action_load_comm(ccsdsTelecommandPacket_t *TC);
65 int action_load_norm(ccsdsTelecommandPacket_t *TC);
72 int action_load_norm(ccsdsTelecommandPacket_t *TC);
66 int action_enter(ccsdsTelecommandPacket_t *TC);
73 int action_load_burst(ccsdsTelecommandPacket_t *TC);
67 int action_updt_time(ccsdsTelecommandPacket_t *TC);
74 int action_load_sbm1(ccsdsTelecommandPacket_t *TC);
68 //
75 int action_load_sbm2(ccsdsTelecommandPacket_t *TC);
76 // other functions
69 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC);
77 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC);
70 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC);
78 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC);
71 void close_action(ccsdsTelecommandPacket_t *TC, int result);
79 void close_action(ccsdsTelecommandPacket_t *TC, int result);
80 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC);
81 int send_tm_lfr_tc_exe_not_executable(ccsdsTelecommandPacket_t *TC);
82 int send_tm_lfr_tc_exe_not_implemented(ccsdsTelecommandPacket_t *TC);
72
83
73 #endif // TC_HANDLER_H_INCLUDED
84 #endif // TC_HANDLER_H_INCLUDED
74
85
@@ -31,10 +31,25 rtems_task wfrm_task(rtems_task_argument
31 //******************
31 //******************
32 // general functions
32 // general functions
33 void init_waveforms( void );
33 void init_waveforms( void );
34 void init_header_snapshot_wf( Header_TM_LFR_SCIENCE_SWF_t *header );
35 void init_header_continuous_wf( Header_TM_LFR_SCIENCE_CWF_t *header );
34 void reset_waveforms( void );
36 void reset_waveforms( void );
35 void send_waveform( ExtendedTMHeader_t *header, volatile int *waveform, unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send);
37 void send_waveform_norm(Header_TM_LFR_SCIENCE_SWF_t *header, spw_ioctl_pkt_send *spw_ioctl_send);
36 void init_waveform_picker_regs();
38 void send_waveform_burst(Header_TM_LFR_SCIENCE_CWF_t *header, spw_ioctl_pkt_send *spw_ioctl_send);
37 void set_data_shaping_parameters(unsigned char parameters);
39 void send_waveform_sbm1(Header_TM_LFR_SCIENCE_CWF_t *header, spw_ioctl_pkt_send *spw_ioctl_send);
40 void send_waveform_sbm2(Header_TM_LFR_SCIENCE_CWF_t *header, spw_ioctl_pkt_send *spw_ioctl_send);
41 void send_waveform_SWF( Header_TM_LFR_SCIENCE_SWF_t *header, volatile int *waveform,
42 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send);
43 void send_waveform_CWF( Header_TM_LFR_SCIENCE_CWF_t *header, volatile int *waveform,
44 unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send);
45
46 //**************
47 // wfp registers
48 void set_wfp_data_shaping(unsigned char data_shaping);
49 void set_wfp_delta_snapshot(unsigned int delta_snapshot);
50 void reset_wfp_burst_enable();
51 void reset_wfp_regs();
52 //
38 int build_value(int value1, int value0);
53 int build_value(int value1, int value0);
39
54
40 #endif // WF_HANDLER_H_INCLUDED
55 #endif // WF_HANDLER_H_INCLUDED
@@ -2,12 +2,12
2
2
3 // GRSPW0 resources
3 // GRSPW0 resources
4 struct drvmgr_key grlib_grspw_0n1_res[] = {
4 struct drvmgr_key grlib_grspw_0n1_res[] = {
5 {"txBdCnt", KEY_TYPE_INT, {(unsigned int)10}},
5 {"txBdCnt", KEY_TYPE_INT, {(unsigned int)10}},
6 {"rxBdCnt", KEY_TYPE_INT, {(unsigned int)10}},
6 {"rxBdCnt", KEY_TYPE_INT, {(unsigned int)10}},
7 {"txDataSize", KEY_TYPE_INT, {(unsigned int)4096}},
7 {"txDataSize", KEY_TYPE_INT, {(unsigned int)4096}},
8 {"txHdrSize", KEY_TYPE_INT, {(unsigned int)20+6}}, // 6 is for the auxiliary header, when needed
8 {"txHdrSize", KEY_TYPE_INT, {(unsigned int)20+12}}, // 12 is for the auxiliary header, when needed
9 {"rxPktSize", KEY_TYPE_INT, {(unsigned int)248+4}},
9 {"rxPktSize", KEY_TYPE_INT, {(unsigned int)248+4}},
10 KEY_EMPTY
10 KEY_EMPTY
11 };
11 };
12
12
13 #if 0
13 #if 0
@@ -50,6 +50,6 struct drvmgr_bus_res grlib_drv_resource
50 // {DRIVER_AMBAPP_GAISLER_APBUART_ID, 1, &grlib_drv_res_apbuart1[0]},
50 // {DRIVER_AMBAPP_GAISLER_APBUART_ID, 1, &grlib_drv_res_apbuart1[0]},
51 RES_EMPTY /* Mark end of device resource array */
51 RES_EMPTY /* Mark end of device resource array */
52 }
52 }
53 };
53 };
54
55
54
55
@@ -1,5 +1,6
1 #include <fsw_processing.h>
1 #include <fsw_processing.h>
2 #include <rtems.h>
2 #include <rtems.h>
3 #include <grspw.h>
3 #include <ccsds_types.h>
4 #include <ccsds_types.h>
4
5
5 // RTEMS GLOBAL VARIABLES
6 // RTEMS GLOBAL VARIABLES
@@ -39,6 +40,7 float averaged_spec_mat_f0[ TOTAL_SIZE_S
39 float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ];
40 float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ];
40
41
41 // MODE PARAMETERS
42 // MODE PARAMETERS
43 struct param_local_str param_local;
42 struct param_common_str param_common;
44 struct param_common_str param_common;
43 struct param_norm_str param_norm;
45 struct param_norm_str param_norm;
44 struct param_burst_str param_burst;
46 struct param_burst_str param_burst;
@@ -47,7 +49,10 struct param_sbm2_str param_sbm2;
47
49
48 // HK PACKETS
50 // HK PACKETS
49 Packet_TM_LFR_HK_t housekeeping_packet;
51 Packet_TM_LFR_HK_t housekeeping_packet;
52 // sequence counters are incremented by APID (PID + CAT) and destination ID
50 unsigned short sequenceCounters[SEQ_CNT_NB_PID][SEQ_CNT_NB_CAT][SEQ_CNT_NB_DEST_ID];
53 unsigned short sequenceCounters[SEQ_CNT_NB_PID][SEQ_CNT_NB_CAT][SEQ_CNT_NB_DEST_ID];
54 spw_stats spacewire_stats;
55 spw_stats spacewire_stats_backup;
51
56
52 // BASIC PARAMETERS GLOBAL VARIABLES
57 // BASIC PARAMETERS GLOBAL VARIABLES
53 unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_MATRIX_f0 * 9 ];
58 unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_MATRIX_f0 * 9 ];
@@ -78,7 +78,7 rtems_task Init( rtems_task_argument ign
78
78
79 grspw_timecode_callback = &timecode_irq_handler;
79 grspw_timecode_callback = &timecode_irq_handler;
80
80
81 configure_spw_link();
81 spacewire_configure_link();
82
82
83 //****************************
83 //****************************
84 // Spectral Matrices simulator
84 // Spectral Matrices simulator
@@ -94,7 +94,7 rtems_task Init( rtems_task_argument ign
94 IRQ_SPARC_WF, waveforms_simulator_isr );
94 IRQ_SPARC_WF, waveforms_simulator_isr );
95 #else
95 #else
96 // configure the registers of the waveform picker
96 // configure the registers of the waveform picker
97 init_waveform_picker_regs();
97 reset_wfp_regs();
98 // configure the waveform picker interrupt service routine
98 // configure the waveform picker interrupt service routine
99 status = rtems_interrupt_catch( waveforms_isr,
99 status = rtems_interrupt_catch( waveforms_isr,
100 IRQ_SPARC_WAVEFORM_PICKER,
100 IRQ_SPARC_WAVEFORM_PICKER,
@@ -137,11 +137,18 rtems_task spiq_task(rtems_task_argument
137 {
137 {
138 rtems_event_set event_out;
138 rtems_event_set event_out;
139 rtems_status_code status;
139 rtems_status_code status;
140 unsigned char lfrMode;
140
141
141 while(true){
142 while(true){
142 PRINTF("in SPIQ *** Waiting for SPW_LINKERR_EVENT\n")
143 PRINTF("in SPIQ *** Waiting for SPW_LINKERR_EVENT\n")
143 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
144 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
144
145
146 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; // get the current mode
147
148 //****************
149 // STOP THE SYSTEM
150 spacewire_compute_stats_offsets();
151 stop_current_mode();
145 if (rtems_task_suspend(Task_id[TASKID_RECV])!=RTEMS_SUCCESSFUL) { // suspend RECV task
152 if (rtems_task_suspend(Task_id[TASKID_RECV])!=RTEMS_SUCCESSFUL) { // suspend RECV task
146 PRINTF("in SPIQ *** Error suspending RECV Task\n")
153 PRINTF("in SPIQ *** Error suspending RECV Task\n")
147 }
154 }
@@ -149,16 +156,24 rtems_task spiq_task(rtems_task_argument
149 PRINTF("in SPIQ *** Error suspending HOUS Task\n")
156 PRINTF("in SPIQ *** Error suspending HOUS Task\n")
150 }
157 }
151
158
152 configure_spw_link();
159 //***************************
160 // RESTART THE SPACEWIRE LINK
161 status = spacewire_try_to_start();
162 if (status != RTEMS_SUCCESSFUL) {
163 spacewire_configure_link();
164 }
153
165
166 //*******************
167 // RESTART THE SYSTEM
168 //ioctl(fdSPW, SPACEWIRE_IOCTRL_CLR_STATISTICS); // clear statistics
154 status = rtems_task_restart( Task_id[TASKID_HOUS], 1 );
169 status = rtems_task_restart( Task_id[TASKID_HOUS], 1 );
155 if (status!=RTEMS_SUCCESSFUL) {
170 if (status != RTEMS_SUCCESSFUL) {
156 PRINTF1("in SPIQ *** Error restarting HOUS Task *** code %d\n", status)
171 PRINTF1("in SPIQ *** Error restarting HOUS Task *** code %d\n", status)
157 }
172 }
158
173 if (rtems_task_restart(Task_id[TASKID_RECV], 1) != RTEMS_SUCCESSFUL) { // restart RECV task
159 if (rtems_task_restart(Task_id[TASKID_RECV], 1)!=RTEMS_SUCCESSFUL) { // restart RECV task
160 PRINTF("in SPIQ *** Error restarting RECV Task\n")
174 PRINTF("in SPIQ *** Error restarting RECV Task\n")
161 }
175 }
176 //enter_mode(lfrMode, NULL); // enter the mode that was running before the SpaceWire interruption
162 }
177 }
163 }
178 }
164
179
@@ -167,21 +182,37 void init_default_mode_parameters(void)
167 // COMMON PARAMETERS
182 // COMMON PARAMETERS
168 param_common.sy_lfr_common0 = 0x00;
183 param_common.sy_lfr_common0 = 0x00;
169 param_common.sy_lfr_common1 = 0x10; // default value 0 0 0 1 0 0 0 0
184 param_common.sy_lfr_common1 = 0x10; // default value 0 0 0 1 0 0 0 0
185
170 // NORMAL MODE
186 // NORMAL MODE
171 param_norm.sy_lfr_n_swf_l = 2048; // nb sample
187 param_norm.sy_lfr_n_swf_l = DEFAULT_SY_LFR_N_SWF_L; // nb sample
172 param_norm.sy_lfr_n_swf_p = 300; // sec
188 param_norm.sy_lfr_n_swf_p = DEFAULT_SY_LFR_N_SWF_P; // sec
173 param_norm.sy_lfr_n_asm_p = 3600; // sec
189 param_norm.sy_lfr_n_asm_p = DEFAULT_SY_LFR_N_ASM_P; // sec
174 param_norm.sy_lfr_n_bp_p0 = 4; // sec
190 param_norm.sy_lfr_n_bp_p0 = DEFAULT_SY_LFR_N_BP_P0; // sec
175 param_norm.sy_lfr_n_bp_p1 = 20; // sec
191 param_norm.sy_lfr_n_bp_p1 = DEFAULT_SY_LFR_N_BP_P1; // sec
192
176 // BURST MODE
193 // BURST MODE
177 param_burst.sy_lfr_b_bp_p0 = 1; // sec
194 param_burst.sy_lfr_b_bp_p0 = DEFAULT_SY_LFR_B_BP_P0; // sec
178 param_burst.sy_lfr_b_bp_p1 = 5; // sec
195 param_burst.sy_lfr_b_bp_p1 = DEFAULT_SY_LFR_B_BP_P1; // sec
196
179 // SBM1 MODE
197 // SBM1 MODE
180 param_sbm1.sy_lfr_s1_bp_p0 = 1; // sec
198 param_sbm1.sy_lfr_s1_bp_p0 = DEFAULT_SY_LFR_S1_BP_P0; // sec
181 param_sbm1.sy_lfr_s1_bp_p1 = 1; // sec
199 param_sbm1.sy_lfr_s1_bp_p1 = DEFAULT_SY_LFR_B_BP_P1; // sec
200
182 // SBM2 MODE
201 // SBM2 MODE
183 param_sbm2.sy_lfr_s2_bp_p0 = 1; // sec
202 param_sbm2.sy_lfr_s2_bp_p0 = DEFAULT_SY_LFR_S2_BP_P0; // sec
184 param_sbm2.sy_lfr_s2_bp_p0 = 5; // sec
203 param_sbm2.sy_lfr_s2_bp_p1 = DEFAULT_SY_LFR_S2_BP_P1; // sec
204
205 // LOCAL PARAMETERS
206 // (2 snapshots of 2048 points per seconds) * (period of the NORM snashots)
207 param_local.local_sbm1_nb_cwf_max = 2 * param_norm.sy_lfr_n_swf_p;
208 // (period of the NORM snashots) / (8 seconds per snapshot at f2 = 256 Hz)
209 param_local.local_sbm2_nb_cwf_max = param_norm.sy_lfr_n_swf_p / 8;
210
211 PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
212 PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
213
214 param_local.local_sbm1_nb_cwf_sent = 0;
215 param_local.local_sbm2_nb_cwf_sent = 0;
185 }
216 }
186
217
187 void init_housekeeping_parameters(void)
218 void init_housekeeping_parameters(void)
@@ -249,7 +280,7 int create_all_tasks( void )
249 );
280 );
250 // ACTN
281 // ACTN
251 status = rtems_task_create(
282 status = rtems_task_create(
252 Task_name[TASKID_ACTN], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
283 Task_name[TASKID_ACTN], 100, RTEMS_MINIMUM_STACK_SIZE * 2,
253 RTEMS_DEFAULT_MODES,
284 RTEMS_DEFAULT_MODES,
254 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_ACTN]
285 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_ACTN]
255 );
286 );
@@ -285,7 +316,7 int create_all_tasks( void )
285 );
316 );
286 // WFRM
317 // WFRM
287 status = rtems_task_create(
318 status = rtems_task_create(
288 Task_name[TASKID_WFRM], 100, RTEMS_MINIMUM_STACK_SIZE * 2,
319 Task_name[TASKID_WFRM], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
289 RTEMS_DEFAULT_MODES,
320 RTEMS_DEFAULT_MODES,
290 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
321 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
291 );
322 );
@@ -362,40 +393,48 int start_all_tasks( void )
362 return 0;
393 return 0;
363 }
394 }
364
395
365 int configure_spw_link( void )
396 int spacewire_configure_link( void )
366 {
397 {
367 rtems_status_code status;
398 rtems_status_code status;
368
399
369 close(fdSPW); // close the device if it is already open
400 close(fdSPW); // close the device if it is already open
370 PRINTF("OK *** in configure_spw_link *** try to open "GRSPW_DEVICE_NAME"\n")
401 PRINTF("OK *** in configure_spw_link *** try to open "GRSPW_DEVICE_NAME"\n")
371 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
402 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
372 if (fdSPW<0) PRINTF("ERR *** in configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
403 if ( fdSPW<0 ) {
373 while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, 0) != RTEMS_SUCCESSFUL){
404 PRINTF("ERR *** in configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
405 }
406
407 while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, -1) != RTEMS_SUCCESSFUL){
374 PRINTF(".")
408 PRINTF(".")
375 fflush(stdout);
409 fflush( stdout );
376 close(fdSPW); // close the device
410 close( fdSPW ); // close the device
377 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
411 fdSPW = open( GRSPW_DEVICE_NAME, O_RDWR ); // open the device. the open call reset the hardware
378 if (fdSPW<0) PRINTF("ERR *** In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
412 if (fdSPW<0) {
413 PRINTF("ERR *** In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
414 }
379 rtems_task_wake_after(100);
415 rtems_task_wake_after(100);
380 }
416 }
381
417
382 PRINTF("OK *** In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n")
418 PRINTF("OK *** In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n")
383
419
384 configure_spacewire_set_NP(1, REGS_ADDR_GRSPW); // No Port force
420 spacewire_set_NP(1, REGS_ADDR_GRSPW); // No Port force
385 configure_spacewire_set_RE(1, REGS_ADDR_GRSPW); // the dedicated call seems to break the no port force configuration
421 spacewire_set_RE(1, REGS_ADDR_GRSPW); // the dedicated call seems to break the no port force configuration
386
422
387 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
423 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
388 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
424 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
389 //
425 //
390 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
426 //status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
391 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
427 //if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
392 //
428 //
393 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 1); // automatic link-disabling due to link-error interrupts
429 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 0); // automatic link-disabling due to link-error interrupts
394 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
430 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
395 //
431 //
396 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
432 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
397 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
433 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
398 //
434 //
435 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK, 0); // transmission blocks
436 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK\n")
437 //
399 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 0); // transmission blocks on full
438 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 0); // transmission blocks on full
400 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
439 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
401 //
440 //
@@ -407,7 +446,29 int configure_spw_link( void )
407 return RTEMS_SUCCESSFUL;
446 return RTEMS_SUCCESSFUL;
408 }
447 }
409
448
410 void configure_spacewire_set_NP(unsigned char val, unsigned int regAddr) // [N]o [P]ort force
449 int spacewire_try_to_start(void)
450 {
451 unsigned int i;
452 int linkStatus;
453 rtems_status_code status = RTEMS_UNSATISFIED;
454
455 for(i = 0; i< 10; i++){
456 PRINTF(".")
457 fflush( stdout );
458 ioctl(fdSPW, SPACEWIRE_IOCTRL_GET_LINK_STATUS, &linkStatus); // get the link status
459 PRINTF1("in spacewire_try_to_start *** link status is: %s\n", lstates[linkStatus])
460 if ( linkStatus == 5) {
461 PRINTF("in spacewire_try_to_start *** link is running\n")
462 status = RTEMS_SUCCESSFUL;
463 break;
464 }
465 rtems_task_wake_after(100);
466 }
467
468 return status;
469 }
470
471 void spacewire_set_NP(unsigned char val, unsigned int regAddr) // [N]o [P]ort force
411 {
472 {
412 unsigned int *spwptr = (unsigned int*) regAddr;
473 unsigned int *spwptr = (unsigned int*) regAddr;
413
474
@@ -419,7 +480,7 void configure_spacewire_set_NP(unsigned
419 }
480 }
420 }
481 }
421
482
422 void configure_spacewire_set_RE(unsigned char val, unsigned int regAddr) // [R]MAP [E]nable
483 void spacewire_set_RE(unsigned char val, unsigned int regAddr) // [R]MAP [E]nable
423 {
484 {
424 unsigned int *spwptr = (unsigned int*) regAddr;
485 unsigned int *spwptr = (unsigned int*) regAddr;
425
486
@@ -433,10 +494,48 void configure_spacewire_set_RE(unsigned
433 }
494 }
434 }
495 }
435
496
497 void spacewire_compute_stats_offsets()
498 {
499 spw_stats spacewire_stats_grspw;
500 rtems_status_code status;
501
502 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
503
504 spacewire_stats_backup.packets_received = spacewire_stats_grspw.packets_received
505 + spacewire_stats.packets_received;
506 spacewire_stats_backup.packets_sent = spacewire_stats_grspw.packets_sent
507 + spacewire_stats.packets_sent;
508 spacewire_stats_backup.parity_err = spacewire_stats_grspw.parity_err
509 + spacewire_stats.parity_err;
510 spacewire_stats_backup.disconnect_err = spacewire_stats_grspw.disconnect_err
511 + spacewire_stats.disconnect_err;
512 spacewire_stats_backup.escape_err = spacewire_stats_grspw.escape_err
513 + spacewire_stats.escape_err;
514 spacewire_stats_backup.credit_err = spacewire_stats_grspw.credit_err
515 + spacewire_stats.credit_err;
516 spacewire_stats_backup.write_sync_err = spacewire_stats_grspw.write_sync_err
517 + spacewire_stats.write_sync_err;
518 spacewire_stats_backup.rx_rmap_header_crc_err = spacewire_stats_grspw.rx_rmap_header_crc_err
519 + spacewire_stats.rx_rmap_header_crc_err;
520 spacewire_stats_backup.rx_rmap_data_crc_err = spacewire_stats_grspw.rx_rmap_data_crc_err
521 + spacewire_stats.rx_rmap_data_crc_err;
522 spacewire_stats_backup.early_ep = spacewire_stats_grspw.early_ep
523 + spacewire_stats.early_ep;
524 spacewire_stats_backup.invalid_address = spacewire_stats_grspw.invalid_address
525 + spacewire_stats.invalid_address;
526 spacewire_stats_backup.rx_eep_err = spacewire_stats_grspw.rx_eep_err
527 + spacewire_stats.rx_eep_err;