##// END OF EJS Templates
Current version with modes NORMAL and SBM1 operational
paul@pc-solar1.lab-lpp.local -
r21:a92d7ea3b165 default
parent child
Show More
@@ -1,6 +1,6
1 1 #############################################################################
2 # Makefile for building: bin/fsw
3 # Generated by qmake (2.01a) (Qt 4.8.4) on: Thu May 23 15:08:17 2013
2 # Makefile for building: bin/fsw$(SW_VERSION)
3 # Generated by qmake (2.01a) (Qt 4.8.4) on: Fri Jun 14 07:50:58 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 = -DPRINT_MESSAGES_ON_CONSOLE
13 DEFINES = -DSW_VERSION_N1=0 -DSW_VERSION_N2=0 -DSW_VERSION_N3=0 -DSW_VERSION_N4=4 -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
@@ -62,7 +62,7 DIST = /usr/lib64/qt4/mkspecs/c
62 62 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
63 63 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
64 64 /usr/lib64/qt4/mkspecs/qconfig.pri \
65 /usr/lib64/qt4/mkspecs/modules/qt_webkit_version.pri \
65 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
66 66 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
67 67 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
68 68 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
@@ -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
81 QMAKE_TARGET = fsw$(SW_VERSION)
82 82 DESTDIR = bin/
83 TARGET = bin/fsw
83 TARGET = bin/fsw$(SW_VERSION)
84 84
85 85 first: all
86 86 ####### Implicit rules
@@ -117,7 +117,7 Makefile: fsw-qt.pro /usr/lib64/qt4/mks
117 117 /usr/lib64/qt4/mkspecs/common/g++-base.conf \
118 118 /usr/lib64/qt4/mkspecs/common/g++-unix.conf \
119 119 /usr/lib64/qt4/mkspecs/qconfig.pri \
120 /usr/lib64/qt4/mkspecs/modules/qt_webkit_version.pri \
120 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri \
121 121 /usr/lib64/qt4/mkspecs/features/qt_functions.prf \
122 122 /usr/lib64/qt4/mkspecs/features/qt_config.prf \
123 123 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf \
@@ -140,7 +140,7 Makefile: fsw-qt.pro /usr/lib64/qt4/mks
140 140 /usr/lib64/qt4/mkspecs/common/g++-base.conf:
141 141 /usr/lib64/qt4/mkspecs/common/g++-unix.conf:
142 142 /usr/lib64/qt4/mkspecs/qconfig.pri:
143 /usr/lib64/qt4/mkspecs/modules/qt_webkit_version.pri:
143 /usr/lib64/qt4/mkspecs/modules/qt_webkit.pri:
144 144 /usr/lib64/qt4/mkspecs/features/qt_functions.prf:
145 145 /usr/lib64/qt4/mkspecs/features/qt_config.prf:
146 146 /usr/lib64/qt4/mkspecs/features/exclusive_builds.prf:
@@ -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/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
162 @$(CHK_DIR_EXISTS) obj/fsw$(SW_VERSION)1.0.0 || $(MKDIR) obj/fsw$(SW_VERSION)1.0.0
163 $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/fsw$(SW_VERSION)1.0.0/ && (cd `dirname obj/fsw$(SW_VERSION)1.0.0` && $(TAR) fsw$(SW_VERSION)1.0.0.tar fsw$(SW_VERSION)1.0.0 && $(COMPRESS) fsw$(SW_VERSION)1.0.0.tar) && $(MOVE) `dirname obj/fsw$(SW_VERSION)1.0.0`/fsw$(SW_VERSION)1.0.0.tar.gz . && $(DEL_FILE) -r obj/fsw$(SW_VERSION)1.0.0
164 164
165 165
166 166 clean:compiler_clean
1 NO CONTENT: modified file, binary diff hidden
@@ -6,6 +6,13 CONFIG -= qt
6 6
7 7 include(./sparc.pri)
8 8
9 # flight software version
10 SW_VERSION=-0-5
11 DEFINES += SW_VERSION_N1=0
12 DEFINES += SW_VERSION_N2=0
13 DEFINES += SW_VERSION_N3=0
14 DEFINES += SW_VERSION_N4=5
15
9 16 contains( CONFIG, verbose ) {
10 17 DEFINES += PRINT_MESSAGES_ON_CONSOLE
11 18 }
@@ -14,10 +21,10 contains( CONFIG, cpu_usage_report ) {
14 21 DEFINES += PRINT_TASK_STATISTICS
15 22 }
16 23
17 TARGET = fsw
24 TARGET = fsw$(SW_VERSION)
18 25 contains( CONFIG, gsa ) {
19 26 DEFINES += GSA
20 TARGET = fsw-gsa
27 TARGET = fsw-gsa$(SW_VERSION)
21 28 }
22 29
23 30 INCLUDEPATH += \
@@ -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-04T15:59:14. -->
3 <!-- Written by Qt Creator 2.4.1, 2013-06-17T15:56:28. -->
4 4 <qtcreator>
5 5 <data>
6 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -20,6 +20,7
20 20
21 21 #define SIZE_TM_LFR_TC_EXE_NOT_IMPLEMENTED 24
22 22 #define SIZE_TM_LFR_TC_EXE_CORRUPTED 32
23 #define SIZE_HK_PARAMETERS 112
23 24
24 25 #define ILLEGAL_APID 0
25 26 #define WRONG_LEN_PACKET 1
@@ -64,6 +65,7
64 65
65 66 // TM TYPES
66 67 #define TM_TYPE_LFR_SCIENCE 21
68 #define TM_TYPE_HK 3
67 69
68 70 // TM SUBTYPES
69 71 #define TM_SUBTYPE_EXE_OK 7
@@ -72,6 +74,7
72 74 #define TM_SUBTYPE_SCIENCE 3
73 75 #define TM_SUBTYPE_LFR_SCIENCE 3
74 76
77 // TM SID
75 78 #define SID_DEFAULT 0
76 79 #define SID_HK 1
77 80 #define SID_EXE_INC 5
@@ -147,20 +150,6 struct TMHeader_str
147 150 };
148 151 typedef struct TMHeader_str TMHeader_t;
149 152
150 struct Packet_TM_LFR_HK_str
151 {
152 volatile unsigned char targetLogicalAddress;
153 volatile unsigned char protocolIdentifier;
154 volatile unsigned char reserved;
155 volatile unsigned char userApplication;
156 volatile unsigned char packetID[2];
157 volatile unsigned char packetSequenceControl[2];
158 volatile unsigned char packetLength[2];
159 volatile unsigned char dataFieldHeader[10];
160 volatile unsigned char data[LENGTH_TM_LFR_HK - 10 + 1];
161 };
162 typedef struct Packet_TM_LFR_HK_str Packet_TM_LFR_HK_t;
163
164 153 struct Packet_TM_LFR_TC_EXE_str
165 154 {
166 155 volatile unsigned char targetLogicalAddress;
@@ -218,7 +207,20 struct ccsdsTelecommandPacket_str
218 207 };
219 208 typedef struct ccsdsTelecommandPacket_str ccsdsTelecommandPacket_t;
220 209
221 struct hk_packet_str{
210 struct Packet_TM_LFR_HK_str
211 {
212 volatile unsigned char targetLogicalAddress;
213 volatile unsigned char protocolIdentifier;
214 volatile unsigned char reserved;
215 volatile unsigned char userApplication;
216 volatile unsigned char packetID[2];
217 volatile unsigned char packetSequenceControl[2];
218 volatile unsigned char packetLength[2];
219 volatile unsigned char dataFieldHeader[10];
220 volatile unsigned char sid;
221
222 //**************
223 // HK PARAMETERS
222 224 unsigned char lfr_status_word[2];
223 225 unsigned char lfr_sw_version[4];
224 226 // tc statistics
@@ -300,8 +302,7 struct hk_packet_str{
300 302 unsigned char hk_lfr_cpu_data_exception;
301 303 unsigned char hk_lfr_cpu_div_exception;
302 304 unsigned char hk_lfr_cpu_arith_overflow;
303
304 305 };
305 typedef struct hk_packet_str hk_packet_t;
306 typedef struct Packet_TM_LFR_HK_str Packet_TM_LFR_HK_t;
306 307
307 308 #endif // CCSDS_H_INCLUDED
@@ -1,60 +1,64
1 1 #ifndef FSW_RTEMS_H_INCLUDED
2 #define FSW_RTEMS_H_INCLUDED
3
2 #define FSW_RTEMS_H_INCLUDED
3
4 4 #include <errno.h>
5 5 #include <fcntl.h>
6 6 #include <stdio.h>
7 7 #include <stdlib.h>
8 8
9 9 #include <grspw.h>
10 #include <apbuart.h>
11
12 #include <fsw_params.h>
10 #include <apbuart.h>
11
12 #include <fsw_params.h>
13 13 #include <fsw_misc.h>
14 #include <fsw_processing.h>
15 #include <tc_handler.h>
16 #include <wf_handler.h>
17 #include <grlib_regs.h>
18
14 #include <fsw_processing.h>
15 #include <tc_handler.h>
16 #include <wf_handler.h>
17 #include <grlib_regs.h>
18 #include <ccsds_types.h>
19
19 20 extern int sched_yield( void );
20 extern int errno;
21 extern int errno;
21 22 extern rtems_id Task_id[ ]; /* array of task ids */
22 extern rtems_name Task_name[ ]; /* array of task names */
23 extern rtems_name misc_name[ ]; /* arry of miscellaneous names for rtems objects */
23 extern rtems_name Task_name[ ]; /* array of task names */
24 extern rtems_name misc_name[ ]; /* arry of miscellaneous names for rtems objects */
24 25 extern int fdSPW; // grspw file descriptor
25 extern int fdUART; // uart file descriptor
26
27 void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc);
28
29 // MODE PARAMETERS
30 extern struct param_norm_str param_norm;
31 extern struct param_burst_str param_burst;
32 extern struct param_sbm1_str param_sbm1;
33 extern struct param_sbm2_str param_sbm2;
34 extern unsigned char param_common[];
35
26 extern int fdUART; // uart file descriptor
27
28 void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc);
29
30 // MODE PARAMETERS
31 extern struct param_common_str param_common;
32 extern struct param_norm_str param_norm;
33 extern struct param_burst_str param_burst;
34 extern struct param_sbm1_str param_sbm1;
35 extern struct param_sbm2_str param_sbm2;
36 extern Packet_TM_LFR_HK_t housekeeping_packet;
37 extern unsigned short sequenceCounters[SEQ_CNT_NB_PID][SEQ_CNT_NB_CAT][SEQ_CNT_NB_DEST_ID];
38
36 39 // RTEMS TASKS
37 40 rtems_task Init( rtems_task_argument argument); /* forward declaration needed */
38 41 rtems_task recv_task(rtems_task_argument argument);
39 42 rtems_task spiq_task(rtems_task_argument argument);
40 rtems_task stat_task(rtems_task_argument argument);
41 rtems_task wfrm_task(rtems_task_argument argument);
42 int create_names( void );
43 int create_all_tasks( void );
44 int start_all_tasks( void );
45 int create_message_queue( void );
46
47 // OTHER functions
48 void init_default_mode_parameters( void );
49
50 int configure_spw_link( void );
51 void configure_spacewire_set_NP(unsigned char val, unsigned int regAddr); // No Port force
52 void configure_spacewire_set_RE(unsigned char val, unsigned int regAddr); // RMAP Enable
43 rtems_task stat_task(rtems_task_argument argument);
44 rtems_task wfrm_task(rtems_task_argument argument);
45 int create_names( void );
46 int create_all_tasks( void );
47 int start_all_tasks( void );
48 int create_message_queue( void );
49
50 // OTHER functions
51 void init_default_mode_parameters( void );
52 void init_housekeeping_parameters( void );
53
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
53 57
54 58 extern int rtems_cpu_usage_report( void );
55 extern int rtems_cpu_usage_reset( void );
56
57 rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send);
58 void (*grspw_timecode_callback) (void *pDev, void *regs, int minor, unsigned int tc);
59
60 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
59 extern int rtems_cpu_usage_reset( void );
60
61 rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send);
62 void (*grspw_timecode_callback) (void *pDev, void *regs, int minor, unsigned int tc);
63
64 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
@@ -4,6 +4,10
4 4 #define GRSPW_DEVICE_NAME "/dev/grspw0"
5 5 #define UART_DEVICE_NAME "/dev/console"
6 6
7 //************************
8 // flight software version
9 // this parameters is handled by the Qt project options
10
7 11 //**********
8 12 // LFR MODES
9 13 #define LFR_MODE_STANDBY 0
@@ -12,6 +16,12
12 16 #define LFR_MODE_SBM1 3
13 17 #define LFR_MODE_SBM2 4
14 18
19 #define RTEMS_EVENT_MODE_STANDBY RTEMS_EVENT_0
20 #define RTEMS_EVENT_MODE_NORMAL RTEMS_EVENT_1
21 #define RTEMS_EVENT_MODE_BURST RTEMS_EVENT_2
22 #define RTEMS_EVENT_MODE_SBM1 RTEMS_EVENT_3
23 #define RTEMS_EVENT_MODE_SBM2 RTEMS_EVENT_4
24
15 25 //*****************************
16 26 // APB REGISTERS BASE ADDRESSES
17 27 #define REGS_ADDR_APBUART 0x80000100
@@ -45,6 +55,11
45 55 #define TIMER_WF_SIMULATOR 2
46 56 #define HK_PERIOD 100 // 100 * 10ms => 1sec
47 57
58 //**********
59 // LPP CODES
60 #define LFR_SUCCESSFUL 0
61 #define LFR_DEFAULT 1
62
48 63 //******
49 64 // RTEMS
50 65 #define TASKID_RECV 1
@@ -78,6 +93,37
78 93 #define NB_BYTES_SWF_BLK 2 * 6
79 94 #define NB_WORDS_SWF_BLK 3
80 95
96 //******************
97 // SEQUENCE COUNTERS
98 #define SEQ_CNT_NB_PID 2
99 #define SEQ_CNT_NB_CAT 4
100 #define SEQ_CNT_NB_DEST_ID 11
101 // pid
102 #define SEQ_CNT_PID_76 0
103 #define SEQ_CNT_PID_79 1
104 //cat
105 #define SEQ_CNT_CAT_1 0
106 #define SEQ_CNT_CAT_4 1
107 #define SEQ_CNT_CAT_9 2
108 #define SEQ_CNT_CAT_12 3
109 // destination id
110 #define SEQ_CNT_DST_ID_GROUND 0
111 #define SEQ_CNT_DST_ID_MISSION_TIMELINE 1
112 #define SEQ_CNT_DST_ID_TC_SEQUENCES 2
113 #define SEQ_CNT_DST_ID_RECOVERY_ACTION_CMD 3
114 #define SEQ_CNT_DST_ID_BACKUP_MISSION_TIMELINE 4
115 #define SEQ_CNT_DST_ID_DIRECT_CMD 5
116 #define SEQ_CNT_DST_ID_SPARE_GRD_SRC1 6
117 #define SEQ_CNT_DST_ID_SPARE_GRD_SRC2 7
118 #define SEQ_CNT_DST_ID_OBCP 8
119 #define SEQ_CNT_DST_ID_SYSTEM_CONTROL 9
120 #define SEQ_CNT_DST_ID_AOCS 10
121
122 struct param_common_str{
123 unsigned char sy_lfr_common0;
124 unsigned char sy_lfr_common1;
125 };
126
81 127 struct param_norm_str{
82 128 unsigned int sy_lfr_n_swf_l; // length of the snapshots
83 129 unsigned int sy_lfr_n_swf_p; // time between two snapshots
@@ -15,13 +15,14 extern rtems_name misc_name[ ];
15 15 extern rtems_name misc_id[ ];
16 16 extern rtems_id Task_id[ ]; // array of task ids
17 17 // MODE PARAMETERS
18 extern struct param_common_str param_common;
18 19 extern struct param_norm_str param_norm;
19 20 extern struct param_sbm1_str param_sbm1;
20 21 extern struct param_sbm2_str param_sbm2;
22 extern Packet_TM_LFR_HK_t housekeeping_packet;
21 23 extern time_management_regs_t *time_management_regs;
22 24 extern waveform_picker_regs_t *waveform_picker_regs;
23 25 extern gptimer_regs_t *gptimer_regs;
24 extern unsigned char param_common[];
25 26
26 27 //****
27 28 // ISR
@@ -58,10 +59,15 int send_tm_lfr_tc_exe_success(ccsdsTele
58 59 int stop_current_mode();
59 60 int enter_normal_mode();
60 61 int enter_sbm1_mode();
62 int action_load_comm(ccsdsTelecommandPacket_t *TC);
61 63 int action_load_norm(ccsdsTelecommandPacket_t *TC);
62 64 int action_enter(ccsdsTelecommandPacket_t *TC);
63 65 int action_updt_time(ccsdsTelecommandPacket_t *TC);
64 66 //
67 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC);
68 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC);
69 void close_action(ccsdsTelecommandPacket_t *TC, int result);
70 //
65 71 rtems_status_code restart_if_needed(rtems_id id);
66 72 rtems_status_code suspend_if_needed(rtems_id id);
67 73
@@ -24,6 +24,7 extern volatile int wf_cont_f3[ ];
24 24 extern waveform_picker_regs_t *waveform_picker_regs;
25 25
26 26 rtems_isr waveforms_isr( rtems_vector_number vector );
27 rtems_isr waveforms_isr_alternative( rtems_vector_number vector );
27 28 rtems_isr waveforms_simulator_isr( rtems_vector_number vector );
28 29 rtems_task wfrm_task(rtems_task_argument argument);
29 30
@@ -33,6 +34,7 void init_waveforms( void );
33 34 void reset_waveforms( void );
34 35 void send_waveform( ExtendedTMHeader_t *header, volatile int *waveform, unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send);
35 36 void init_waveform_picker_regs();
37 void set_data_shaping_parameters(unsigned char parameters);
36 38 int build_value(int value1, int value0);
37 39
38 40 #endif // WF_HANDLER_H_INCLUDED
@@ -38,15 +38,15 float averaged_spec_mat_f0[ TOTAL_SIZE_S
38 38 float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ];
39 39
40 40 // MODE PARAMETERS
41 struct param_common_str param_common;
41 42 struct param_norm_str param_norm;
42 43 struct param_burst_str param_burst;
43 44 struct param_sbm1_str param_sbm1;
44 45 struct param_sbm2_str param_sbm2;
45 unsigned char param_common[2];
46 46
47 47 // HK PACKETS
48 48 Packet_TM_LFR_HK_t housekeeping_packet;
49 hk_packet_t housekeeping_parameters;
49 unsigned short sequenceCounters[SEQ_CNT_NB_PID][SEQ_CNT_NB_CAT][SEQ_CNT_NB_DEST_ID];
50 50
51 51 // BASIC PARAMETERS GLOBAL VARIABLES
52 52 unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_MATRIX_f0 * 9 ];
@@ -68,6 +68,7 rtems_task Init( rtems_task_argument ign
68 68
69 69 initLookUpTableForCRC(); // in tc_handler.h
70 70 init_default_mode_parameters();
71 init_housekeeping_parameters();
71 72 create_message_queue();
72 73
73 74 create_names();
@@ -160,11 +161,11 rtems_task spiq_task(rtems_task_argument
160 161 }
161 162 }
162 163
163 void init_default_mode_parameters()
164 void init_default_mode_parameters(void)
164 165 {
165 166 // COMMON PARAMETERS
166 param_common[0] = 0x00;
167 param_common[1] = 0x10; // default value 0 0 0 1 0 0 0 0
167 param_common.sy_lfr_common0 = 0x00;
168 param_common.sy_lfr_common1 = 0x10; // default value 0 0 0 1 0 0 0 0
168 169 // NORMAL MODE
169 170 param_norm.sy_lfr_n_swf_l = 2048; // nb sample
170 171 param_norm.sy_lfr_n_swf_p = 300; // sec
@@ -182,6 +183,39 void init_default_mode_parameters()
182 183 param_sbm2.sy_lfr_s2_bp_p0 = 5; // sec
183 184 }
184 185
186 void init_housekeeping_parameters(void)
187 {
188 unsigned int i = 0;
189 unsigned int j = 0;
190 unsigned int k = 0;
191 char *parameters;
192
193 parameters = (char*) &housekeeping_packet.lfr_status_word;
194 for(i = 0; i< SIZE_HK_PARAMETERS; i++)
195 {
196 parameters[i] = 0x00;
197 }
198 // init status word
199 housekeeping_packet.lfr_status_word[0] = 0x00;
200 housekeeping_packet.lfr_status_word[1] = 0x00;
201 // init software version
202 housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1;
203 housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2;
204 housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3;
205 housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4;
206 // init sequence counters
207 for (i = 0; i<SEQ_CNT_NB_PID; i++)
208 {
209 for(j = 0; j<SEQ_CNT_NB_CAT; j++)
210 {
211 for(k = 0; k<SEQ_CNT_NB_DEST_ID; k++)
212 {
213 sequenceCounters[i][j][k] = 0x00;
214 }
215 }
216 }
217 }
218
185 219 int create_names( void )
186 220 {
187 221 // task names
@@ -10,10 +10,10 extern Packet_TM_LFR_HK_t housekeeping_p
10 10 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
11 11 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
12 12 { // configure the timer for the waveforms simulation
13 rtems_status_code status;
13 rtems_status_code status;
14 14 rtems_isr_entry old_isr_handler;
15 15
16 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
16 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
17 17 //if (status==RTEMS_SUCCESSFUL) PRINTF("In configure_timer_for_wf_simulation *** rtems_interrupt_catch successfullly configured\n")
18 18
19 19 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
@@ -26,31 +26,31 int configure_timer(gptimer_regs_t *gpti
26 26 return 1;
27 27 }
28 28
29 void print_statistics(spw_stats *stats)
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);
29 void print_statistics(spw_stats *stats)
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);
46 46 }
47 47
48 48 int send_console_outputs_on_serial_port( void ) // Send the console outputs on the serial port
49 49 {
50 50 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
51
52 apbuart_regs->ctrl = apbuart_regs->ctrl & APBUART_CTRL_REG_MASK_DB;
53 PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
51
52 apbuart_regs->ctrl = apbuart_regs->ctrl & APBUART_CTRL_REG_MASK_DB;
53 PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
54 54
55 55 return 0;
56 56 }
@@ -58,9 +58,9 int send_console_outputs_on_serial_port(
58 58 int set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
59 59 {
60 60 struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs;
61
62 apbuart_regs->scaler = value;
63 PRINTF1("OK *** COM port scaler reload register set to %x\n", value)
61
62 apbuart_regs->scaler = value;
63 PRINTF1("OK *** COM port scaler reload register set to %x\n", value)
64 64
65 65 return 0;
66 66 }
@@ -69,66 +69,66 int set_apbuart_scaler_reload_register(u
69 69 // RTEMS TASKS
70 70
71 71 rtems_task stat_task(rtems_task_argument argument)
72 {
72 {
73 73 int i;
74 int j;
74 int j;
75 75 i = 0;
76 j = 0;
77 PRINTF("in STAT *** \n")
78 while(1){
79 rtems_task_wake_after(1000);
80 PRINTF1("%d\n", j)
76 j = 0;
77 PRINTF("in STAT *** \n")
78 while(1){
79 rtems_task_wake_after(1000);
80 PRINTF1("%d\n", j)
81 81 if (i == 2) {
82 #ifdef PRINT_TASK_STATISTICS
83 rtems_cpu_usage_report();
82 #ifdef PRINT_TASK_STATISTICS
83 rtems_cpu_usage_report();
84 84 rtems_cpu_usage_reset();
85 85 #endif
86 i = 0;
87 }
86 i = 0;
87 }
88 88 else i++;
89 j++;
90 }
89 j++;
90 }
91 91 }
92
93 rtems_task hous_task(rtems_task_argument argument)
92
93 rtems_task hous_task(rtems_task_argument argument)
94 94 {
95 95 int result;
96 96 rtems_status_code status;
97
97
98 98 PRINTF("in HOUS ***\n")
99 99
100 if (rtems_rate_monotonic_ident( HK_name, &HK_id)!=RTEMS_SUCCESSFUL) {
101 status = rtems_rate_monotonic_create( HK_name, &HK_id );
100 if (rtems_rate_monotonic_ident( HK_name, &HK_id) != RTEMS_SUCCESSFUL) {
101 status = rtems_rate_monotonic_create( HK_name, &HK_id );
102 102 if( status != RTEMS_SUCCESSFUL ) {
103 103 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
104 104 }
105 105 }
106 106
107 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
108 housekeeping_packet.protocolIdentifier = 0x02;
109 housekeeping_packet.reserved = 0x00;
110 housekeeping_packet.userApplication = 0x00;
107 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
108 housekeeping_packet.protocolIdentifier = 0x02;
109 housekeeping_packet.reserved = 0x00;
110 housekeeping_packet.userApplication = 0x00;
111 111 housekeeping_packet.packetID[0] = 0x0c;
112 housekeeping_packet.packetID[1] = 0xc4;
112 housekeeping_packet.packetID[1] = 0xc4;
113 113 housekeeping_packet.packetSequenceControl[0] = 0xc0;
114 housekeeping_packet.packetSequenceControl[1] = 0x00;
114 housekeeping_packet.packetSequenceControl[1] = 0x00;
115 115 housekeeping_packet.packetLength[0] = 0x00;
116 housekeeping_packet.packetLength[1] = 0x77;
116 housekeeping_packet.packetLength[1] = 0x77;
117 117 housekeeping_packet.dataFieldHeader[0] = 0x10;
118 housekeeping_packet.dataFieldHeader[1] = 0x03;
119 housekeeping_packet.dataFieldHeader[2] = 0x19;
120 housekeeping_packet.dataFieldHeader[3] = 0x00;
118 housekeeping_packet.dataFieldHeader[1] = TM_TYPE_HK;
119 housekeeping_packet.dataFieldHeader[2] = TM_SUBTYPE_HK;
120 housekeeping_packet.dataFieldHeader[3] = CCSDS_DESTINATION_ID_GROUND;
121 121
122 122 status = rtems_rate_monotonic_cancel(HK_id);
123 123 if( status != RTEMS_SUCCESSFUL )
124 124 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
125 125 else
126 126 PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
127
127
128 128 while(1){ // launch the rate monotonic task
129 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
129 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
130 130 if ( status != RTEMS_SUCCESSFUL ){
131 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_period *** code %d\n", status);
131 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_period *** code %d\n", status);
132 132 }
133 133 else
134 134 {
@@ -138,19 +138,19 rtems_task hous_task(rtems_task_argument
138 138 housekeeping_packet.dataFieldHeader[7] = (unsigned char) (time_management_regs->coarse_time);
139 139 housekeeping_packet.dataFieldHeader[8] = (unsigned char) (time_management_regs->fine_time>>8);
140 140 housekeeping_packet.dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time);
141 housekeeping_packet.data[0] = CCSDS_DESTINATION_ID_DPU;
141 housekeeping_packet.sid = CCSDS_DESTINATION_ID_DPU;
142 142 result = write ( fdSPW, &housekeeping_packet, LEN_TM_LFR_HK);
143 143 if (result==-1)
144 144 {
145 145 PRINTF("ERR *** in HOUS *** HK send\n");
146 146 }
147 }
148 }
147 }
148 }
149 149
150 150 PRINTF("in HOUS *** deleting task\n")
151
152 status = rtems_task_delete( RTEMS_SELF ); // should not return
153 printf( "rtems_task_delete returned with status of %d.\n", status );
154 exit( 1 );
151
152 status = rtems_task_delete( RTEMS_SELF ); // should not return
153 printf( "rtems_task_delete returned with status of %d.\n", status );
154 exit( 1 );
155 155 }
156 156
@@ -1,9 +1,9
1 1 #include <tc_handler.h>
2 2 #include <fsw_params.h>
3 3
4 char *DumbMessages[5] = {"default",
5 "timecode_irq_handler",
6 "waveforms_isr",
4 char *DumbMessages[5] = {"in DUMB *** default",
5 "in DUMB *** timecode_irq_handler",
6 "in DUMB *** waveforms_isr",
7 7 "",
8 8 ""
9 9 };
@@ -485,6 +485,7 rtems_task recv_task( rtems_task_argumen
485 485 rtems_task actn_task( rtems_task_argument unused )
486 486 {
487 487 int result = 0;
488 unsigned int val;
488 489 rtems_status_code status; // RTEMS status code
489 490 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
490 491 size_t size; // size of the incoming TC packet
@@ -507,37 +508,47 rtems_task actn_task( rtems_task_argumen
507 508 break;
508 509 //
509 510 case TC_SUBTYPE_LOAD_COMM:
510 result = action_default( &TC );
511 result = action_load_comm( &TC );
512 close_action( &TC, result );
511 513 break;
512 514 //
513 515 case TC_SUBTYPE_LOAD_NORM:
514 516 result = action_load_norm( &TC );
515 send_tm_lfr_tc_exe_success( &TC );
517 close_action( &TC, result );
516 518 break;
517 519 //
518 520 case TC_SUBTYPE_LOAD_BURST:
519 521 result = action_default( &TC );
522 close_action( &TC, result );
520 523 break;
521 524 //
522 525 case TC_SUBTYPE_LOAD_SBM1:
523 526 result = action_default( &TC );
527 close_action( &TC, result );
524 528 break;
525 529 //
526 530 case TC_SUBTYPE_LOAD_SBM2:
527 531 result = action_default( &TC );
532 close_action( &TC, result );
528 533 break;
529 534 //
530 535 case TC_SUBTYPE_DUMP:
531 536 result = action_default( &TC );
537 close_action( &TC, result );
532 538 break;
533 539 //
534 540 case TC_SUBTYPE_ENTER:
535 541 result = action_enter( &TC );
536 send_tm_lfr_tc_exe_success( &TC );
542 close_action( &TC, result );
537 543 break;
538 544 //
539 545 case TC_SUBTYPE_UPDT_INFO:
540 546 result = action_default( &TC );
547 val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256
548 + housekeeping_packet.hk_lfr_update_info_tc_cnt[1];
549 val++;
550 housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8);
551 housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val);
541 552 break;
542 553 //
543 554 case TC_SUBTYPE_EN_CAL:
@@ -550,7 +561,11 rtems_task actn_task( rtems_task_argumen
550 561 //
551 562 case TC_SUBTYPE_UPDT_TIME:
552 563 result = action_updt_time( &TC );
553 send_tm_lfr_tc_exe_success( &TC );
564 val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256
565 + housekeeping_packet.hk_lfr_update_time_tc_cnt[1];
566 val++;
567 housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8);
568 housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val);
554 569 break;
555 570 //
556 571 default:
@@ -571,7 +586,8 rtems_task dumb_task( rtems_task_argumen
571 586 PRINTF("in DUMB *** \n")
572 587
573 588 while(1){
574 rtems_event_receive(RTEMS_EVENT_1, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
589 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | RTEMS_EVENT_4,
590 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT
575 591 indice = 0;
576 592 shiftedIndice = (unsigned int) event_out;
577 593 while(!(shiftedIndice & 0x0001))
@@ -609,11 +625,12 int action_default(ccsdsTelecommandPacke
609 625 PRINTF("ERR *** in action_default *** send TM packet\n");
610 626 }
611 627
612 return 0;
628 return LFR_DEFAULT;
613 629 }
614 630
615 631 int action_enter(ccsdsTelecommandPacket_t *TC)
616 632 {
633 rtems_status_code status;
617 634 unsigned char lfr_mode = TC->dataAndCRC[1];
618 635 printf("enter mode %d\n", lfr_mode);
619 636 switch(lfr_mode)
@@ -621,46 +638,72 int action_enter(ccsdsTelecommandPacket_
621 638 //********
622 639 // STANDBY
623 640 case(LFR_MODE_STANDBY):
624 stop_current_mode();
641 status = stop_current_mode();
642 if (status != RTEMS_SUCCESSFUL)
643 {
644 PRINTF("in action_enter *** error going back to STANDBY mode\n")
645 }
646 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((LFR_MODE_STANDBY << 4) + 0x0d);
625 647 break;
626 648
627 649 //******
628 650 // NORMAL
629 651 case(LFR_MODE_NORMAL):
630 stop_current_mode();
631 enter_normal_mode();
652 status = stop_current_mode();
653 status = enter_normal_mode();
654 if (status == RTEMS_SUCCESSFUL)
655 {
656 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((LFR_MODE_NORMAL << 4) + 0x0d);
657 }
632 658 break;
633 659
634 660 //******
635 661 // BURST
636 662 case(LFR_MODE_BURST):
637 stop_current_mode();
663 status = stop_current_mode();
664 if (status == RTEMS_SUCCESSFUL)
665 {
666 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((LFR_MODE_BURST << 4) + 0x0d);
667 }
638 668 break;
639 669
640 670 //*****
641 671 // SBM1
642 672 case(LFR_MODE_SBM1):
643 stop_current_mode();
644 enter_sbm1_mode();
673 status = stop_current_mode();
674 status = enter_sbm1_mode();
675 if (status == RTEMS_SUCCESSFUL)
676 {
677 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((LFR_MODE_SBM1 << 4) + 0x0d);
678 }
645 679 break;
646 680
647 681 //*****
648 682 // SBM2
649 683 case(LFR_MODE_SBM2):
650 stop_current_mode();
684 status = stop_current_mode();
685 if (status == RTEMS_SUCCESSFUL)
686 {
687 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((LFR_MODE_SBM2 << 4) + 0x0d);
688 }
651 689 break;
652 690
653 691 //********
654 692 // DEFAULT
655 693 default:
656 stop_current_mode();
694 status = stop_current_mode();
695 if (status == RTEMS_SUCCESSFUL)
696 {
697 housekeeping_packet.lfr_status_word[0] = (unsigned char) ((LFR_MODE_STANDBY << 4) + 0x0d);
698 }
657 699 break;
658 700 }
659 return 0;
701 return status;
660 702 }
661 703
662 704 int stop_current_mode()
663 705 {
706 rtems_status_code status;
664 707 // mask all IRQ lines related to signal processing
665 708 LEON_Mask_interrupt( IRQ_WF ); // mask waveform interrupt (coming from the timer VHDL IP)
666 709 LEON_Mask_interrupt( IRQ_SM ); // mask spectral matrices interrupt (coming from the timer VHDL IP)
@@ -672,22 +715,31 int stop_current_mode()
672 715 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt
673 716
674 717 // suspend several tasks
675 suspend_if_needed( Task_id[TASKID_AVF0] );
676 suspend_if_needed( Task_id[TASKID_BPF0] );
677 suspend_if_needed( Task_id[TASKID_WFRM] );
718 status = suspend_if_needed( Task_id[TASKID_AVF0] );
719 if (status == RTEMS_SUCCESSFUL) {
720 status = suspend_if_needed( Task_id[TASKID_BPF0] );
721 if (status == RTEMS_SUCCESSFUL) {
722 status = suspend_if_needed( Task_id[TASKID_WFRM] );
723 }
724 }
678 725
679 726 // initialize the registers
680 727 waveform_picker_regs->burst_enable = 0x00; // initialize
681 728
682 return 0;
729 return status;
683 730 }
684 731
685 732 int enter_normal_mode()
686 733 {
734 rtems_status_code status;
687 735
688 restart_if_needed( Task_id[TASKID_AVF0] );
689 restart_if_needed( Task_id[TASKID_BPF0] );
690 restart_if_needed( Task_id[TASKID_WFRM] );
736 status = restart_if_needed( Task_id[TASKID_AVF0] );
737 if (status == RTEMS_SUCCESSFUL) {
738 status = restart_if_needed( Task_id[TASKID_BPF0] );
739 if (status == RTEMS_SUCCESSFUL) {
740 status = restart_if_needed( Task_id[TASKID_WFRM] );
741 }
742 }
691 743
692 744 #ifdef GSA
693 745 LEON_Unmask_interrupt( IRQ_WF );
@@ -695,17 +747,24 int enter_normal_mode()
695 747 LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER );
696 748 LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER );
697 749 waveform_picker_regs->burst_enable = 0x07;
750 waveform_picker_regs->addr_data_f1 = (int) wf_snap_f1;
698 751 waveform_picker_regs->status = 0x00;
699 752 #endif
700 753 LEON_Unmask_interrupt( IRQ_SM );
701 return 0;
754
755 return status;
702 756 }
703 757
704 758 int enter_sbm1_mode()
705 759 {
706 restart_if_needed( Task_id[TASKID_AVF0] );
707 restart_if_needed( Task_id[TASKID_BPF0] );
708 restart_if_needed( Task_id[TASKID_WFRM] );
760 rtems_status_code status;
761 status = restart_if_needed( Task_id[TASKID_AVF0] );
762 if (status == RTEMS_SUCCESSFUL) {
763 status = restart_if_needed( Task_id[TASKID_BPF0] );
764 if (status == RTEMS_SUCCESSFUL) {
765 status = restart_if_needed( Task_id[TASKID_WFRM] );
766 }
767 }
709 768
710 769 #ifdef GSA
711 770 #else
@@ -716,7 +775,7 int enter_sbm1_mode()
716 775 waveform_picker_regs->status = 0x00;
717 776 #endif
718 777 //LEON_Unmask_interrupt( IRQ_SM );
719 return 0;
778 return status;
720 779 }
721 780
722 781 int action_load_norm(ccsdsTelecommandPacket_t *TC)
@@ -726,10 +785,18 int action_load_norm(ccsdsTelecommandPac
726 785 param_norm.sy_lfr_n_asm_p = (TC->dataAndCRC[4] * 256) + TC->dataAndCRC[5];
727 786 param_norm.sy_lfr_n_bp_p0 = TC->dataAndCRC[6];
728 787 param_norm.sy_lfr_n_bp_p1 = TC->dataAndCRC[7];
729 /*printf("sy_lfr_n_ => swf_l %d, swf_p %d, asm_p %d, bsp_p0 %d, bsp_p1 %d\n",
730 param_norm.sy_lfr_n_swf_l, param_norm.sy_lfr_n_swf_p,
731 param_norm.sy_lfr_n_asm_p, param_norm.sy_lfr_n_bp_p0, param_norm.sy_lfr_n_bp_p1);*/
732 return 0;
788
789 return LFR_SUCCESSFUL;
790 }
791
792 int action_load_comm(ccsdsTelecommandPacket_t *TC)
793 {
794 param_common.sy_lfr_common0 = TC->dataAndCRC[0];
795 param_common.sy_lfr_common1 = TC->dataAndCRC[1];
796
797 set_data_shaping_parameters(param_common.sy_lfr_common1);
798
799 return LFR_SUCCESSFUL;
733 800 }
734 801
735 802 int action_updt_time(ccsdsTelecommandPacket_t *TC)
@@ -800,6 +867,60 rtems_status_code suspend_if_needed(rtem
800 867 return status;
801 868 }
802 869
870 void update_last_TC_exe(ccsdsTelecommandPacket_t *TC)
871 {
872 housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0];
873 housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1];
874 housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00;
875 housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->dataFieldHeader[1];
876 housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00;
877 housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->dataFieldHeader[2];
878 housekeeping_packet.hk_lfr_last_exe_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
879 housekeeping_packet.hk_lfr_last_exe_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
880 housekeeping_packet.hk_lfr_last_exe_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
881 housekeeping_packet.hk_lfr_last_exe_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
882 housekeeping_packet.hk_lfr_last_exe_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
883 housekeeping_packet.hk_lfr_last_exe_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
884 }
885
886 void update_last_TC_rej(ccsdsTelecommandPacket_t *TC)
887 {
888 housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0];
889 housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1];
890 housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00;
891 housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->dataFieldHeader[1];
892 housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00;
893 housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->dataFieldHeader[2];
894 housekeeping_packet.hk_lfr_last_rej_tc_time[0] = (unsigned char) (time_management_regs->coarse_time>>24);
895 housekeeping_packet.hk_lfr_last_rej_tc_time[1] = (unsigned char) (time_management_regs->coarse_time>>16);
896 housekeeping_packet.hk_lfr_last_rej_tc_time[2] = (unsigned char) (time_management_regs->coarse_time>>8);
897 housekeeping_packet.hk_lfr_last_rej_tc_time[3] = (unsigned char) (time_management_regs->coarse_time);
898 housekeeping_packet.hk_lfr_last_rej_tc_time[4] = (unsigned char) (time_management_regs->fine_time>>8);
899 housekeeping_packet.hk_lfr_last_rej_tc_time[5] = (unsigned char) (time_management_regs->fine_time);
900 }
901
902 void close_action(ccsdsTelecommandPacket_t *TC, int result)
903 {
904 unsigned int val = 0;
905 if (result == LFR_SUCCESSFUL)
906 {
907 send_tm_lfr_tc_exe_success( TC );
908 update_last_TC_exe( TC );
909 val = housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1];
910 val++;
911 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
912 housekeeping_packet.hk_dpu_exe_tc_lfr_cnt[1] = (unsigned char) (val);
913 }
914 else
915 {
916 update_last_TC_rej( TC );
917 val = housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] * 256 + housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1];
918 val++;
919 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[0] = (unsigned char) (val >> 8);
920 housekeeping_packet.hk_dpu_rej_tc_lfr_cnt[1] = (unsigned char) (val);
921 }
922 }
923
803 924 //***************************
804 925 // Interrupt Service Routines
805 926 rtems_isr commutation_isr1( rtems_vector_number vector )
@@ -1,10 +1,7
1 1 #include <wf_handler.h>
2 2
3 rtems_isr waveforms_isr( rtems_vector_number vector )
3 rtems_isr waveforms_isr_alternative( rtems_vector_number vector )
4 4 {
5 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ) != RTEMS_SUCCESSFUL) {
6 printf("In waveforms_isr *** Error sending event to WFRM\n");
7 }
8 5 if (waveform_picker_regs->burst_enable == 0x22) {
9 6 if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
10 7 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_bis);
@@ -12,8 +9,8 rtems_isr waveforms_isr( rtems_vector_nu
12 9 else {
13 10 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
14 11 }
15 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
16 printf("In waveforms_isr *** Error sending event to WFRM\n");
12 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_2 ) != RTEMS_SUCCESSFUL) {
13 //rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
17 14 }
18 15 }
19 16 waveform_picker_regs->status = 0x00;
@@ -32,6 +29,81 rtems_isr waveforms_isr( rtems_vector_nu
32 29 }*/
33 30 }
34 31
32 rtems_isr waveforms_isr( rtems_vector_number vector )
33 {
34 unsigned char lfrMode;
35 lfrMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4;
36
37 switch(lfrMode)
38 {
39 //********
40 // STANDBY
41 case(LFR_MODE_STANDBY):
42 break;
43
44 //******
45 // NORMAL
46 case(LFR_MODE_NORMAL):
47 #ifdef GSA
48 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
49 #else
50 if ( (waveform_picker_regs->burst_enable & 0x7) == 0x0 ){// if no channel is enable
51 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ) != RTEMS_SUCCESSFUL) {
52 PRINTF("in waveform_isr *** Error sending event to DUMB\n");
53 }
54 }
55 else {
56 if ( (waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full
57 waveform_picker_regs->burst_enable = 0x00;
58 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_NORMAL ) != RTEMS_SUCCESSFUL) {
59 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ) != RTEMS_SUCCESSFUL) {
60 PRINTF("in waveform_isr *** Error sending event to DUMB\n");
61 }
62 }
63 }
64 }
65 #endif
66 break;
67
68 //******
69 // BURST
70 case(LFR_MODE_BURST):
71 break;
72
73 //*****
74 // SBM1
75 case(LFR_MODE_SBM1):
76 #ifdef GSA
77 PRINTF("in waveform_isr *** unexpected waveform picker interruption\n")
78 #else
79 if (waveform_picker_regs->burst_enable == 0x22) {
80 if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
81 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1_bis);
82 }
83 else {
84 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1);
85 }
86 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_MODE_SBM1 ) != RTEMS_SUCCESSFUL) {
87 PRINTF("in waveforms_isr *** Error sending event to WFRM\n")
88 rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 );
89 }
90 }
91 waveform_picker_regs->status = 0x00;
92 #endif
93 break;
94
95 //*****
96 // SBM2
97 case(LFR_MODE_SBM2):
98 break;
99
100 //********
101 // DEFAULT
102 default:
103 break;
104 }
105 }
106
35 107 rtems_isr waveforms_simulator_isr( rtems_vector_number vector )
36 108 {
37 109 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) {
@@ -76,9 +148,9 rtems_task wfrm_task(rtems_task_argument
76 148 PRINTF("in WFRM ***\n")
77 149
78 150 while(1){
79
80 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
81 PRINTF("in WFRM *** send wfrm\n")
151 // wait for an RTEMS_EVENT
152 rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | RTEMS_EVENT_4,
153 RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out);
82 154 header.dataFieldHeader[4] = (unsigned char) (time_management_regs->coarse_time>>24);
83 155 header.dataFieldHeader[5] = (unsigned char) (time_management_regs->coarse_time>>16);
84 156 header.dataFieldHeader[6] = (unsigned char) (time_management_regs->coarse_time>>8);
@@ -86,29 +158,48 rtems_task wfrm_task(rtems_task_argument
86 158 header.dataFieldHeader[8] = (unsigned char) (time_management_regs->fine_time>>8);
87 159 header.dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time);
88 160
89 //***************
90 // send snapshots
91 // F0
92 //send_waveform( &header, wf_snap_f0, SID_NORM_SWF_F0, &spw_ioctl_send);
93 // F1
94 if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
95 send_waveform( &header, wf_snap_f1_bis, SID_NORM_SWF_F1, &spw_ioctl_send);
96 }
97 else {
98 send_waveform( &header, wf_snap_f1, SID_NORM_SWF_F1, &spw_ioctl_send);
161 switch(event_out)
162 {
163 //********
164 // STANDBY
165 case(RTEMS_EVENT_MODE_STANDBY):
166 break;
167
168 //*******
169 // NORMAL
170 case(RTEMS_EVENT_MODE_NORMAL):
171 //***************
172 // send snapshots
173 // F0
174 send_waveform( &header, wf_snap_f0, SID_NORM_SWF_F0, &spw_ioctl_send);
175 // F1
176 send_waveform( &header, wf_snap_f1, SID_NORM_SWF_F1, &spw_ioctl_send);
177 // F2
178 send_waveform( &header, wf_snap_f2, SID_NORM_SWF_F2, &spw_ioctl_send);
179 #ifdef GSA
180 // irq processed, reset the related register of the timer unit
181 gptimer_regs->timer[2].ctrl = gptimer_regs->timer[2].ctrl | 0x00000010;
182 #else
183 // irq processed, reset the related register of the waveform picker
184 waveform_picker_regs->status = 0x00;
185 waveform_picker_regs->burst_enable = 0x07;
186 #endif
187 break;
188
189 //*****
190 // SBM1
191 case(RTEMS_EVENT_MODE_SBM1):
192 // F1
193 if (waveform_picker_regs->addr_data_f1 == (int) wf_snap_f1) {
194 send_waveform( &header, wf_snap_f1_bis, SID_NORM_SWF_F1, &spw_ioctl_send);
195 }
196 else {
197 send_waveform( &header, wf_snap_f1, SID_NORM_SWF_F1, &spw_ioctl_send);
198 }
199 break;
200 default:
201 break;
99 202 }
100 // F2
101 //send_waveform( &header, wf_snap_f2, SID_NORM_SWF_F2, &spw_ioctl_send);
102
103 #ifdef GSA
104 // irq processed, reset the related register of the timer unit
105 gptimer_regs->timer[2].ctrl = gptimer_regs->timer[2].ctrl | 0x00000010;
106 #else
107 // irq processed, reset the related register of the waveform picker
108 //waveform_picker_regs->status = 0x00;
109 //waveform_picker_regs->burst_enable = 0x07;
110 #endif
111
112 203 }
113 204 }
114 205
@@ -290,8 +381,8 int build_value(int value1, int value0)
290 381 }
291 382
292 383 void init_waveform_picker_regs()
293 { // 1 1 0 0 0 BW = 0 => BIAS_WORKS
294 waveform_picker_regs->data_shaping = 0x18; // R1 R0 SP1 SP0 BW
384 {
385 set_data_shaping_parameters(param_common.sy_lfr_common1);
295 386 waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0
296 387 waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); //
297 388 waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); //
@@ -310,3 +401,14 void init_waveform_picker_regs()
310 401 //waveform_picker_regs->nb_snapshot_param = 0xff; // max 3 octets, 256 - 1
311 402 }
312 403
404 void set_data_shaping_parameters(unsigned char parameters)
405 {
406 // get the parameters for the data shaping [BW SP0 SP1 R0 R1] in sy_lfr_common1 and configure the register
407 // waveform picker : [R1 R0 SP1 SP0 BW]
408 waveform_picker_regs->data_shaping =
409 ( (parameters & 0x10) >> 4 ) // BW
410 + ( (parameters & 0x08) >> 2 ) // SP0
411 + ( (parameters & 0x04) ) // SP1
412 + ( (parameters & 0x02) << 2 ) // R0
413 + ( (parameters & 0x01) << 4 ); // R1
414 }
General Comments 0
You need to be logged in to leave comments. Login now