##// 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
3 # Generated by qmake (2.01a) (Qt 4.8.4) on: Tue Jun 18 14:00:55 2013
2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.4) on: Fri Jun 28 07:59:21 2013
4 4 # Project: fsw-qt.pro
5 5 # Template: app
6 6 # Command: /usr/bin/qmake-qt4 -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
@@ -10,7 +10,7
10 10
11 11 CC = sparc-rtems-gcc
12 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 14 CFLAGS = -pipe -O3 -Wall $(DEFINES)
15 15 CXXFLAGS = -pipe -O3 -Wall $(DEFINES)
16 16 INCPATH = -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I../src -I../header
@@ -78,9 +78,9 DIST = /usr/lib64/qt4/mkspecs/c
78 78 /usr/lib64/qt4/mkspecs/features/lex.prf \
79 79 /usr/lib64/qt4/mkspecs/features/include_source_dir.prf \
80 80 fsw-qt.pro
81 QMAKE_TARGET = fsw-gsa
81 QMAKE_TARGET = fsw
82 82 DESTDIR = bin/
83 TARGET = bin/fsw-gsa
83 TARGET = bin/fsw
84 84
85 85 first: all
86 86 ####### Implicit rules
@@ -159,8 +159,8 qmake: FORCE
159 159 @$(QMAKE) -spec /usr/lib64/qt4/mkspecs/linux-g++ -o Makefile fsw-qt.pro
160 160
161 161 dist:
162 @$(CHK_DIR_EXISTS) obj/fsw-gsa1.0.0 || $(MKDIR) obj/fsw-gsa1.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
162 @$(CHK_DIR_EXISTS) obj/fsw1.0.0 || $(MKDIR) obj/fsw1.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 166 clean:compiler_clean
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
@@ -1,7 +1,7
1 1 TEMPLATE = app
2 2 # CONFIG += console v8 sim
3 3 # CONFIG options = verbose *** cpu_usage_report *** gsa
4 CONFIG += console verbose gsa
4 CONFIG += console verbose
5 5 CONFIG -= qt
6 6
7 7 include(./sparc.pri)
@@ -1,6 +1,6
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 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 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -10,11 +10,34
10 10 #define CCSDS_PROCESS_ID 76
11 11 #define CCSDS_PACKET_CATEGORY 12
12 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 40 #define CCSDS_DESTINATION_ID 0x01
16 #define CCSDS_DESTINATION_ID_DPU 0x01
17 //
18 41 #define CCSDS_PROTOCOLE_ID 0x02
19 42 #define CCSDS_USER_APP 0x00
20 43
@@ -64,8 +87,9
64 87 #define TC_LEN_UPDT_TIME 18
65 88
66 89 // TM TYPES
90 #define TM_TYPE_TC_EXE 1
91 #define TM_TYPE_HK 3
67 92 #define TM_TYPE_LFR_SCIENCE 21
68 #define TM_TYPE_HK 3
69 93
70 94 // TM SUBTYPES
71 95 #define TM_SUBTYPE_EXE_OK 7
@@ -111,22 +135,26
111 135 #define SID_SBM1_BP2_F1 33
112 136
113 137 // LENGTH (BYTES)
138 #define LENGTH_TM_LFR_TC_EXE_MAX 32
114 139 #define LENGTH_TM_LFR_HK 126
115 #define LENGTH_TM_LFR_TC_EXE_MAX 32
116 #define LENGTH_TM_LFR_SCIENCE_NORMAL_WF_MAX 4102
117 //
118 #define TM_LEN_EXE 20 - CCSDS_TC_TM_PACKET_OFFSET
119 #define TM_LEN_NOT_EXE 26 - CCSDS_TC_TM_PACKET_OFFSET
120 #define TM_LEN_NOT_IMP 24 - CCSDS_TC_TM_PACKET_OFFSET
121 #define TM_LEN_EXE_ERR 24 - CCSDS_TC_TM_PACKET_OFFSET
122 #define TM_LEN_EXE_CORR 32 - CCSDS_TC_TM_PACKET_OFFSET
140 // PACKET_LENGTH
141 #define PACKET_LENGTH_TC_EXE_SUCCESS 20 - CCSDS_TC_TM_PACKET_OFFSET
142 #define PACKET_LENGTH_TC_EXE_INCONSISTENT 26 - CCSDS_TC_TM_PACKET_OFFSET
143 #define PACKET_LENGTH_TC_EXE_NOT_EXECUTABLE 26 - CCSDS_TC_TM_PACKET_OFFSET
144 #define PACKET_LENGTH_TC_EXE_NOT_IMPLEMENTED 24 - CCSDS_TC_TM_PACKET_OFFSET
145 #define PACKET_LENGTH_TC_EXE_ERROR 24 - CCSDS_TC_TM_PACKET_OFFSET
146 #define PACKET_LENGTH_TC_EXE_CORRUPTED 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 149 #define TM_HEADER_LEN 16
124 150
125 151 #define LEN_TM_LFR_HK 126 + 4
126 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
129 #define TM_LEN_SCI_NORM_SWF_8 8 * 12 + 6 + 10 - 1
154 #define TM_LEN_SCI_SWF_340 340 * 12 + 10 + 12 - 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 159 enum TM_TYPE{
132 160 TM_LFR_TC_EXE_OK,
@@ -146,7 +174,12 struct TMHeader_str
146 174 volatile unsigned char packetID[2];
147 175 volatile unsigned char packetSequenceControl[2];
148 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 184 typedef struct TMHeader_str TMHeader_t;
152 185
@@ -159,12 +192,17 struct Packet_TM_LFR_TC_EXE_str
159 192 volatile unsigned char packetID[2];
160 193 volatile unsigned char packetSequenceControl[2];
161 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 201 volatile unsigned char data[LENGTH_TM_LFR_TC_EXE_MAX - 10 + 1];
164 202 };
165 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 207 volatile unsigned char targetLogicalAddress;
170 208 volatile unsigned char protocolIdentifier;
@@ -173,13 +211,23 struct Packet_TM_LFR_SCIENCE_NORMAL_WF_s
173 211 volatile unsigned char packetID[2];
174 212 volatile unsigned char packetSequenceControl[2];
175 213 volatile unsigned char packetLength[2];
176 volatile unsigned char dataFieldHeader[10];
177 volatile unsigned char auxiliaryHeader[6];
178 volatile unsigned char data[LENGTH_TM_LFR_SCIENCE_NORMAL_WF_MAX - 10 + 1];
214 // DATA FIELD HEADER
215 volatile unsigned char spare1_pusVersion_spare2;
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 232 volatile unsigned char targetLogicalAddress;
185 233 volatile unsigned char protocolIdentifier;
@@ -188,10 +236,19 struct ExtendedTMHeader_str
188 236 volatile unsigned char packetID[2];
189 237 volatile unsigned char packetSequenceControl[2];
190 238 volatile unsigned char packetLength[2];
191 volatile unsigned char dataFieldHeader[10];
192 volatile unsigned char auxiliaryHeader[6];
239 // DATA FIELD HEADER
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 253 struct ccsdsTelecommandPacket_str
197 254 {
@@ -202,7 +259,11 struct ccsdsTelecommandPacket_str
202 259 volatile unsigned char packetID[2];
203 260 volatile unsigned char packetSequenceControl[2];
204 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 267 volatile unsigned char dataAndCRC[CCSDS_TC_PKT_MAX_SIZE-10];
207 268 };
208 269 typedef struct ccsdsTelecommandPacket_str ccsdsTelecommandPacket_t;
@@ -28,6 +28,7 extern int fdUART; // uart file descrip
28 28 void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc);
29 29
30 30 // MODE PARAMETERS
31 extern struct param_local_str param_local;
31 32 extern struct param_common_str param_common;
32 33 extern struct param_norm_str param_norm;
33 34 extern struct param_burst_str param_burst;
@@ -51,9 +52,11 int create_message_queue( void );
51 52 void init_default_mode_parameters( void );
52 53 void init_housekeeping_parameters( void );
53 54
54 int configure_spw_link( void );
55 void configure_spacewire_set_NP(unsigned char val, unsigned int regAddr); // No Port force
56 void configure_spacewire_set_RE(unsigned char val, unsigned int regAddr); // RMAP Enable
55 int spacewire_configure_link( void );
56 int spacewire_try_to_start(void);
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 61 extern int rtems_cpu_usage_report( void );
59 62 extern int rtems_cpu_usage_reset( void );
@@ -12,10 +12,12
12 12
13 13 rtems_name HK_name; // name of the HK rate monotonic
14 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 18 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
17 19 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
18 void print_statistics(spw_stats *stats);
20 void update_spacewire_statistics();
19 21
20 22 // SERIAL LINK
21 23 int send_console_outputs_on_serial_port( void );
@@ -22,6 +22,24
22 22 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
23 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 44 // APB REGISTERS BASE ADDRESSES
27 45 #define REGS_ADDR_APBUART 0x80000100
@@ -119,6 +137,13
119 137 #define SEQ_CNT_DST_ID_SYSTEM_CONTROL 9
120 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 147 struct param_common_str{
123 148 unsigned char sy_lfr_common0;
124 149 unsigned char sy_lfr_common1;
@@ -36,12 +36,12 void GetCRCAsTwoBytes(unsigned char* dat
36 36
37 37 //*********************
38 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 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 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 47 // RTEMS TASK
@@ -53,22 +53,33 int create_message_queue( void );
53 53 //***********
54 54 // TC ACTIONS
55 55 int action_default(ccsdsTelecommandPacket_t *TC);
56 int action_default_alt(ccsdsTelecommandPacket_t *TC);
57 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC);
58 //
56 int action_enter(ccsdsTelecommandPacket_t *TC);
57 int action_updt_info(ccsdsTelecommandPacket_t *TC);
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 63 int stop_current_mode();
60 int enter_normal_mode();
61 int enter_burst_mode();
62 int enter_sbm1_mode();
63 int enter_sbm2_mode();
64 int enter_mode(unsigned char mode, ccsdsTelecommandPacket_t *TC);
65 int enter_standby_mode(ccsdsTelecommandPacket_t *TC);
66 int enter_normal_mode(ccsdsTelecommandPacket_t *TC);
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 71 int action_load_comm(ccsdsTelecommandPacket_t *TC);
65 72 int action_load_norm(ccsdsTelecommandPacket_t *TC);
66 int action_enter(ccsdsTelecommandPacket_t *TC);
67 int action_updt_time(ccsdsTelecommandPacket_t *TC);
68 //
73 int action_load_burst(ccsdsTelecommandPacket_t *TC);
74 int action_load_sbm1(ccsdsTelecommandPacket_t *TC);
75 int action_load_sbm2(ccsdsTelecommandPacket_t *TC);
76 // other functions
69 77 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC);
70 78 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC);
71 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 84 #endif // TC_HANDLER_H_INCLUDED
74 85
@@ -31,10 +31,25 rtems_task wfrm_task(rtems_task_argument
31 31 //******************
32 32 // general functions
33 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 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);
36 void init_waveform_picker_regs();
37 void set_data_shaping_parameters(unsigned char parameters);
37 void send_waveform_norm(Header_TM_LFR_SCIENCE_SWF_t *header, spw_ioctl_pkt_send *spw_ioctl_send);
38 void send_waveform_burst(Header_TM_LFR_SCIENCE_CWF_t *header, spw_ioctl_pkt_send *spw_ioctl_send);
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 53 int build_value(int value1, int value0);
39 54
40 55 #endif // WF_HANDLER_H_INCLUDED
@@ -2,12 +2,12
2 2
3 3 // GRSPW0 resources
4 4 struct drvmgr_key grlib_grspw_0n1_res[] = {
5 {"txBdCnt", KEY_TYPE_INT, {(unsigned int)10}},
6 {"rxBdCnt", KEY_TYPE_INT, {(unsigned int)10}},
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
9 {"rxPktSize", KEY_TYPE_INT, {(unsigned int)248+4}},
10 KEY_EMPTY
5 {"txBdCnt", KEY_TYPE_INT, {(unsigned int)10}},
6 {"rxBdCnt", KEY_TYPE_INT, {(unsigned int)10}},
7 {"txDataSize", KEY_TYPE_INT, {(unsigned int)4096}},
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}},
10 KEY_EMPTY
11 11 };
12 12
13 13 #if 0
@@ -50,6 +50,6 struct drvmgr_bus_res grlib_drv_resource
50 50 // {DRIVER_AMBAPP_GAISLER_APBUART_ID, 1, &grlib_drv_res_apbuart1[0]},
51 51 RES_EMPTY /* Mark end of device resource array */
52 52 }
53 };
54
53 };
55 54
55
@@ -1,5 +1,6
1 1 #include <fsw_processing.h>
2 2 #include <rtems.h>
3 #include <grspw.h>
3 4 #include <ccsds_types.h>
4 5
5 6 // RTEMS GLOBAL VARIABLES
@@ -39,6 +40,7 float averaged_spec_mat_f0[ TOTAL_SIZE_S
39 40 float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ];
40 41
41 42 // MODE PARAMETERS
43 struct param_local_str param_local;
42 44 struct param_common_str param_common;
43 45 struct param_norm_str param_norm;
44 46 struct param_burst_str param_burst;
@@ -47,7 +49,10 struct param_sbm2_str param_sbm2;
47 49
48 50 // HK PACKETS
49 51 Packet_TM_LFR_HK_t housekeeping_packet;
52 // sequence counters are incremented by APID (PID + CAT) and destination ID
50 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 57 // BASIC PARAMETERS GLOBAL VARIABLES
53 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 79 grspw_timecode_callback = &timecode_irq_handler;
80 80
81 configure_spw_link();
81 spacewire_configure_link();
82 82
83 83 //****************************
84 84 // Spectral Matrices simulator
@@ -94,7 +94,7 rtems_task Init( rtems_task_argument ign
94 94 IRQ_SPARC_WF, waveforms_simulator_isr );
95 95 #else
96 96 // configure the registers of the waveform picker
97 init_waveform_picker_regs();
97 reset_wfp_regs();
98 98 // configure the waveform picker interrupt service routine
99 99 status = rtems_interrupt_catch( waveforms_isr,
100 100 IRQ_SPARC_WAVEFORM_PICKER,
@@ -137,11 +137,18 rtems_task spiq_task(rtems_task_argument
137 137 {
138 138 rtems_event_set event_out;
139 139 rtems_status_code status;
140 unsigned char lfrMode;
140 141
141 142 while(true){
142 143 PRINTF("in SPIQ *** Waiting for SPW_LINKERR_EVENT\n")
143 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 152 if (rtems_task_suspend(Task_id[TASKID_RECV])!=RTEMS_SUCCESSFUL) { // suspend RECV task
146 153 PRINTF("in SPIQ *** Error suspending RECV Task\n")
147 154 }
@@ -149,16 +156,24 rtems_task spiq_task(rtems_task_argument
149 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 169 status = rtems_task_restart( Task_id[TASKID_HOUS], 1 );
155 if (status!=RTEMS_SUCCESSFUL) {
170 if (status != RTEMS_SUCCESSFUL) {
156 171 PRINTF1("in SPIQ *** Error restarting HOUS Task *** code %d\n", status)
157 172 }
158
159 if (rtems_task_restart(Task_id[TASKID_RECV], 1)!=RTEMS_SUCCESSFUL) { // restart RECV task
173 if (rtems_task_restart(Task_id[TASKID_RECV], 1) != RTEMS_SUCCESSFUL) { // restart RECV task
160 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 182 // COMMON PARAMETERS
168 183 param_common.sy_lfr_common0 = 0x00;
169 184 param_common.sy_lfr_common1 = 0x10; // default value 0 0 0 1 0 0 0 0
185
170 186 // NORMAL MODE
171 param_norm.sy_lfr_n_swf_l = 2048; // nb sample
172 param_norm.sy_lfr_n_swf_p = 300; // sec
173 param_norm.sy_lfr_n_asm_p = 3600; // sec
174 param_norm.sy_lfr_n_bp_p0 = 4; // sec
175 param_norm.sy_lfr_n_bp_p1 = 20; // sec
187 param_norm.sy_lfr_n_swf_l = DEFAULT_SY_LFR_N_SWF_L; // nb sample
188 param_norm.sy_lfr_n_swf_p = DEFAULT_SY_LFR_N_SWF_P; // sec
189 param_norm.sy_lfr_n_asm_p = DEFAULT_SY_LFR_N_ASM_P; // sec
190 param_norm.sy_lfr_n_bp_p0 = DEFAULT_SY_LFR_N_BP_P0; // sec
191 param_norm.sy_lfr_n_bp_p1 = DEFAULT_SY_LFR_N_BP_P1; // sec
192
176 193 // BURST MODE
177 param_burst.sy_lfr_b_bp_p0 = 1; // sec
178 param_burst.sy_lfr_b_bp_p1 = 5; // sec
194 param_burst.sy_lfr_b_bp_p0 = DEFAULT_SY_LFR_B_BP_P0; // sec
195 param_burst.sy_lfr_b_bp_p1 = DEFAULT_SY_LFR_B_BP_P1; // sec
196
179 197 // SBM1 MODE
180 param_sbm1.sy_lfr_s1_bp_p0 = 1; // sec
181 param_sbm1.sy_lfr_s1_bp_p1 = 1; // sec
198 param_sbm1.sy_lfr_s1_bp_p0 = DEFAULT_SY_LFR_S1_BP_P0; // sec
199 param_sbm1.sy_lfr_s1_bp_p1 = DEFAULT_SY_LFR_B_BP_P1; // sec
200
182 201 // SBM2 MODE
183 param_sbm2.sy_lfr_s2_bp_p0 = 1; // sec
184 param_sbm2.sy_lfr_s2_bp_p0 = 5; // sec
202 param_sbm2.sy_lfr_s2_bp_p0 = DEFAULT_SY_LFR_S2_BP_P0; // 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 218 void init_housekeeping_parameters(void)
@@ -249,7 +280,7 int create_all_tasks( void )
249 280 );
250 281 // ACTN
251 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 284 RTEMS_DEFAULT_MODES,
254 285 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_ACTN]
255 286 );
@@ -285,7 +316,7 int create_all_tasks( void )
285 316 );
286 317 // WFRM
287 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 320 RTEMS_DEFAULT_MODES,
290 321 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
291 322 );
@@ -362,40 +393,48 int start_all_tasks( void )
362 393 return 0;
363 394 }
364 395
365 int configure_spw_link( void )
396 int spacewire_configure_link( void )
366 397 {
367 398 rtems_status_code status;
368 399
369 400 close(fdSPW); // close the device if it is already open
370 401 PRINTF("OK *** in configure_spw_link *** try to open "GRSPW_DEVICE_NAME"\n")
371 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")
373 while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, 0) != RTEMS_SUCCESSFUL){
403 if ( fdSPW<0 ) {
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 408 PRINTF(".")
375 fflush(stdout);
376 close(fdSPW); // close the device
377 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")
409 fflush( stdout );
410 close( fdSPW ); // close the device
411 fdSPW = open( GRSPW_DEVICE_NAME, O_RDWR ); // open the device. the open call reset the hardware
412 if (fdSPW<0) {
413 PRINTF("ERR *** In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
414 }
379 415 rtems_task_wake_after(100);
380 416 }
381 417
382 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
385 configure_spacewire_set_RE(1, REGS_ADDR_GRSPW); // the dedicated call seems to break the no port force configuration
420 spacewire_set_NP(1, REGS_ADDR_GRSPW); // No Port force
421 spacewire_set_RE(1, REGS_ADDR_GRSPW); // the dedicated call seems to break the no port force configuration
386 422
387 423 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
388 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
391 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
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
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 430 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
395 431 //
396 432 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
397 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 438 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 0); // transmission blocks on full
400 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 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 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 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;
528 spacewire_stats_backup.rx_truncated = spacewire_stats_grspw.rx_truncated
529 + spacewire_stats.rx_truncated;
530 }
531
436 532 rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send)
437 533 {
438 534 rtems_status_code status;
439 535 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
536 if (status != RTEMS_SUCCESSFUL){
537 //PRINTF1("ERR *** in write_spw *** write operation failed with code: %d\n", status)
538 }
440 539 return status;
441 540 }
442 541
@@ -446,4 +545,3 void timecode_irq_handler(void *pDev, vo
446 545 printf("In timecode_irq_handler *** Error sending event to DUMB\n");
447 546 }
448 547 }
449
@@ -26,23 +26,69 int configure_timer(gptimer_regs_t *gpti
26 26 return 1;
27 27 }
28 28
29 void print_statistics(spw_stats *stats)
29 void update_spacewire_statistics()
30 30 {
31 //printf(" ******** STATISTICS ******** \n");
32 printf("Transmit link errors: %i\n", stats->tx_link_err);
33 printf("Receiver RMAP header CRC errors: %i\n", stats->rx_rmap_header_crc_err);
34 printf("Receiver RMAP data CRC errors: %i\n", stats->rx_rmap_data_crc_err);
35 printf("Receiver EEP errors: %i\n", stats->rx_eep_err);
36 printf("Receiver truncation errors: %i\n", stats->rx_truncated);
37 printf("Parity errors: %i\n", stats->parity_err);
38 printf("Escape errors: %i\n", stats->escape_err);
39 printf("Credit errors: %i\n", stats->credit_err);
40 printf("Disconnect errors: %i\n", stats->disconnect_err);
41 printf("Write synchronization errors: %i\n", stats->write_sync_err);
42 printf("Early EOP/EEP: %i\n", stats->early_ep);
43 printf("Invalid Node Address: %i\n", stats->invalid_address);
44 printf("Packets transmitted: %i\n", stats->packets_sent);
45 printf("Packets received: %i\n", stats->packets_received);
31 rtems_status_code status;
32 spw_stats spacewire_stats_grspw;
33
34 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_GET_STATISTICS, &spacewire_stats_grspw );
35
36 spacewire_stats.packets_received = spacewire_stats_backup.packets_received
37 + spacewire_stats_grspw.packets_received;
38 spacewire_stats.packets_sent = spacewire_stats_backup.packets_sent
39 + spacewire_stats_grspw.packets_sent;
40 spacewire_stats.parity_err = spacewire_stats_backup.parity_err
41 + spacewire_stats_grspw.parity_err;
42 spacewire_stats.disconnect_err = spacewire_stats_backup.disconnect_err
43 + spacewire_stats_grspw.disconnect_err;
44 spacewire_stats.escape_err = spacewire_stats_backup.escape_err
45 + spacewire_stats_grspw.escape_err;
46 spacewire_stats.credit_err = spacewire_stats_backup.credit_err
47 + spacewire_stats_grspw.credit_err;
48 spacewire_stats.write_sync_err = spacewire_stats_backup.write_sync_err
49 + spacewire_stats_grspw.write_sync_err;
50 spacewire_stats.rx_rmap_header_crc_err = spacewire_stats_backup.rx_rmap_header_crc_err
51 + spacewire_stats_grspw.rx_rmap_header_crc_err;
52 spacewire_stats.rx_rmap_data_crc_err = spacewire_stats_backup.rx_rmap_data_crc_err
53 + spacewire_stats_grspw.rx_rmap_data_crc_err;
54 spacewire_stats.early_ep = spacewire_stats_backup.early_ep
55 + spacewire_stats_grspw.early_ep;
56 spacewire_stats.invalid_address = spacewire_stats_backup.invalid_address
57 + spacewire_stats_grspw.invalid_address;
58 spacewire_stats.rx_eep_err = spacewire_stats_backup.rx_eep_err
59 + spacewire_stats_grspw.rx_eep_err;
60 spacewire_stats.rx_truncated = spacewire_stats_backup.rx_truncated
61 + spacewire_stats_grspw.rx_truncated;
62 //spacewire_stats.tx_link_err;
63
64 //****************************
65 // DPU_SPACEWIRE_IF_STATISTICS
66 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[0] = (unsigned char) (spacewire_stats.packets_received >> 8);
67 housekeeping_packet.hk_lfr_dpu_spw_pkt_rcv_cnt[1] = (unsigned char) (spacewire_stats.packets_received);
68 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[0] = (unsigned char) (spacewire_stats.packets_sent >> 8);
69 housekeeping_packet.hk_lfr_dpu_spw_pkt_sent_cnt[1] = (unsigned char) (spacewire_stats.packets_sent);
70 //housekeeping_packet.hk_lfr_dpu_spw_tick_out_cnt;
71 //housekeeping_packet.hk_lfr_dpu_spw_last_timc;
72
73 //******************************************
74 // ERROR COUNTERS / SPACEWIRE / LOW SEVERITY
75 housekeeping_packet.hk_lfr_dpu_spw_parity = (unsigned char) spacewire_stats.parity_err;
76 housekeeping_packet.hk_lfr_dpu_spw_disconnect = (unsigned char) spacewire_stats.disconnect_err;
77 housekeeping_packet.hk_lfr_dpu_spw_escape = (unsigned char) spacewire_stats.escape_err;
78 housekeeping_packet.hk_lfr_dpu_spw_credit = (unsigned char) spacewire_stats.credit_err;
79 housekeeping_packet.hk_lfr_dpu_spw_write_sync = (unsigned char) spacewire_stats.write_sync_err;
80 // housekeeping_packet.hk_lfr_dpu_spw_rx_ahb;
81 // housekeeping_packet.hk_lfr_dpu_spw_tx_ahb;
82 housekeeping_packet.hk_lfr_dpu_spw_header_crc = (unsigned char) spacewire_stats.rx_rmap_header_crc_err;
83 housekeeping_packet.hk_lfr_dpu_spw_data_crc = (unsigned char) spacewire_stats.rx_rmap_data_crc_err;
84
85 //*********************************************
86 // ERROR COUNTERS / SPACEWIRE / MEDIUM SEVERITY
87 housekeeping_packet.hk_lfr_dpu_spw_early_eop = (unsigned char) spacewire_stats.early_ep;
88 housekeeping_packet.hk_lfr_dpu_spw_invalid_addr = (unsigned char) spacewire_stats.invalid_address;
89 housekeeping_packet.hk_lfr_dpu_spw_eep = (unsigned char) spacewire_stats.rx_eep_err;
90 housekeeping_packet.hk_lfr_dpu_spw_rx_too_big = (unsigned char) spacewire_stats.rx_truncated;
91
46 92 }
47 93
48 94 int send_console_outputs_on_serial_port( void ) // Send the console outputs on the serial port
@@ -105,11 +151,11 rtems_task hous_task(rtems_task_argument
105 151 }
106 152
107 153 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
108 housekeeping_packet.protocolIdentifier = 0x02;
154 housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID;
109 155 housekeeping_packet.reserved = 0x00;
110 156 housekeeping_packet.userApplication = 0x00;
111 housekeeping_packet.packetID[0] = 0x0c;
112 housekeeping_packet.packetID[1] = 0xc4;
157 housekeeping_packet.packetID[0] = (unsigned char) (TM_PACKET_ID_HK >> 8);
158 housekeeping_packet.packetID[1] = (unsigned char) (TM_PACKET_ID_HK);
113 159 housekeeping_packet.packetSequenceControl[0] = 0xc0;
114 160 housekeeping_packet.packetSequenceControl[1] = 0x00;
115 161 housekeeping_packet.packetLength[0] = 0x00;
@@ -117,31 +163,34 rtems_task hous_task(rtems_task_argument
117 163 housekeeping_packet.dataFieldHeader[0] = 0x10;
118 164 housekeeping_packet.dataFieldHeader[1] = TM_TYPE_HK;
119 165 housekeeping_packet.dataFieldHeader[2] = TM_SUBTYPE_HK;
120 housekeeping_packet.dataFieldHeader[3] = CCSDS_DESTINATION_ID_GROUND;
166 housekeeping_packet.dataFieldHeader[3] = TM_DESTINATION_ID_GROUND;
121 167
122 168 status = rtems_rate_monotonic_cancel(HK_id);
123 if( status != RTEMS_SUCCESSFUL )
124 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
125 else
126 PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
169 if( status != RTEMS_SUCCESSFUL ) {
170 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
171 }
172 else {
173 PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
174 }
127 175
128 176 while(1){ // launch the rate monotonic task
129 177 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
130 if ( status != RTEMS_SUCCESSFUL ){
178 if ( status != RTEMS_SUCCESSFUL ) {
131 179 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_period *** code %d\n", status);
132 180 }
133 else
134 {
181 else {
135 182 housekeeping_packet.dataFieldHeader[4] = (unsigned char) (time_management_regs->coarse_time>>24);
136 183 housekeeping_packet.dataFieldHeader[5] = (unsigned char) (time_management_regs->coarse_time>>16);
137 184 housekeeping_packet.dataFieldHeader[6] = (unsigned char) (time_management_regs->coarse_time>>8);
138 185 housekeeping_packet.dataFieldHeader[7] = (unsigned char) (time_management_regs->coarse_time);
139 186 housekeeping_packet.dataFieldHeader[8] = (unsigned char) (time_management_regs->fine_time>>8);
140 187 housekeeping_packet.dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time);
141 housekeeping_packet.sid = CCSDS_DESTINATION_ID_DPU;
188 housekeeping_packet.sid = SID_HK;
189
190 update_spacewire_statistics();
191
142 192 result = write ( fdSPW, &housekeeping_packet, LEN_TM_LFR_HK);
143 if (result==-1)
144 {
193 if (result==-1) {
145 194 PRINTF("ERR *** in HOUS *** HK send\n");
146 195 }
147 196 }
This diff has been collapsed as it changes many lines, (606 lines changed) Show them Hide them
@@ -3,359 +3,361
3 3
4 4 #include <fsw_processing_globals.c>
5 5
6 //***********************************************************
7 // Interrupt Service Routine for spectral matrices processing
8 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
9 {
6 //***********************************************************
7 // Interrupt Service Routine for spectral matrices processing
8 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
9 {
10 10 if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
11 printf("in spectral_matrices_isr *** Error sending event to AVF0\n");
12 }
11 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_4 );
12 }
13 13 }
14 14
15 15 //************
16 16 // RTEMS TASKS
17 17 rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
18 {
18 {
19 19 rtems_event_set event_out;
20 unsigned char nb_interrupt_f0 = 0;
20 unsigned char nb_interrupt_f0 = 0;
21 21
22 22 PRINTF("in SMIQ *** \n")
23
24 while(1){
23
24 while(1){
25 25 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
26 26 nb_interrupt_f0 = nb_interrupt_f0 + 1;
27 27 if (nb_interrupt_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) ){
28 28 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
29 printf("in SMIQ *** Error sending event to AVF0\n");
29 {
30 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 );
31 }
30 32 nb_interrupt_f0 = 0;
31 33 }
32 34 }
33 35 }
34
35 rtems_task spw_bppr_task(rtems_task_argument argument)
36 {
37 rtems_status_code status;
38 rtems_event_set event_out;