@@ -2,45 +2,45 | |||||
2 | <CodeBlocks_layout_file> |
|
2 | <CodeBlocks_layout_file> | |
3 | <ActiveTarget name="Debug" /> |
|
3 | <ActiveTarget name="Debug" /> | |
4 | <File name="../header/ccsds_types.h" open="0" top="0" tabpos="3"> |
|
4 | <File name="../header/ccsds_types.h" open="0" top="0" tabpos="3"> | |
5 |
<Cursor position=" |
|
5 | <Cursor position="1196" topLine="121" /> | |
6 | </File> |
|
6 | </File> | |
7 |
<File name="../header/fsw_init.h" open="0" top="0" tabpos=" |
|
7 | <File name="../header/fsw_init.h" open="0" top="0" tabpos="4"> | |
8 |
<Cursor position=" |
|
8 | <Cursor position="232" topLine="0" /> | |
9 | </File> |
|
9 | </File> | |
10 | <File name="../header/fsw_misc.h" open="0" top="0" tabpos="3"> |
|
10 | <File name="../header/fsw_misc.h" open="0" top="0" tabpos="3"> | |
11 |
<Cursor position="2 |
|
11 | <Cursor position="292" topLine="0" /> | |
12 | </File> |
|
12 | </File> | |
13 |
<File name="../header/fsw_params.h" open="0" top="0" tabpos=" |
|
13 | <File name="../header/fsw_params.h" open="0" top="0" tabpos="2"> | |
14 |
<Cursor position="1 |
|
14 | <Cursor position="1815" topLine="53" /> | |
15 | </File> |
|
15 | </File> | |
16 | <File name="../header/fsw_processing.h" open="0" top="0" tabpos="0"> |
|
16 | <File name="../header/fsw_processing.h" open="0" top="0" tabpos="0"> | |
17 |
<Cursor position=" |
|
17 | <Cursor position="576" topLine="0" /> | |
18 | </File> |
|
18 | </File> | |
19 | <File name="../header/grlib_regs.h" open="0" top="0" tabpos="4"> |
|
19 | <File name="../header/grlib_regs.h" open="0" top="0" tabpos="4"> | |
20 |
<Cursor position=" |
|
20 | <Cursor position="1318" topLine="36" /> | |
21 | </File> |
|
21 | </File> | |
22 | <File name="../header/tc_handler.h" open="0" top="0" tabpos="4"> |
|
22 | <File name="../header/tc_handler.h" open="0" top="0" tabpos="4"> | |
23 |
<Cursor position=" |
|
23 | <Cursor position="658" topLine="36" /> | |
24 | </File> |
|
24 | </File> | |
25 |
<File name="../header/wf_handler.h" open="0" top="0" tabpos=" |
|
25 | <File name="../header/wf_handler.h" open="0" top="0" tabpos="3"> | |
26 |
<Cursor position=" |
|
26 | <Cursor position="732" topLine="7" /> | |
27 | </File> |
|
27 | </File> | |
28 |
<File name="../src/fsw_globals.c" open=" |
|
28 | <File name="../src/fsw_globals.c" open="0" top="0" tabpos="5"> | |
29 |
<Cursor position=" |
|
29 | <Cursor position="663" topLine="18" /> | |
30 | </File> |
|
30 | </File> | |
31 |
<File name="../src/fsw_init.c" open=" |
|
31 | <File name="../src/fsw_init.c" open="0" top="0" tabpos="1"> | |
32 |
<Cursor position=" |
|
32 | <Cursor position="3984" topLine="98" /> | |
33 | </File> |
|
33 | </File> | |
34 | <File name="../src/fsw_misc.c" open="0" top="0" tabpos="2"> |
|
34 | <File name="../src/fsw_misc.c" open="0" top="0" tabpos="2"> | |
35 |
<Cursor position=" |
|
35 | <Cursor position="1183" topLine="46" /> | |
36 | </File> |
|
36 | </File> | |
37 | <File name="../src/fsw_processing.c" open="0" top="0" tabpos="4"> |
|
37 | <File name="../src/fsw_processing.c" open="0" top="0" tabpos="4"> | |
38 |
<Cursor position=" |
|
38 | <Cursor position="79" topLine="0" /> | |
39 | </File> |
|
39 | </File> | |
40 |
<File name="../src/tc_handler.c" open="0" top="0" tabpos=" |
|
40 | <File name="../src/tc_handler.c" open="0" top="0" tabpos="3"> | |
41 |
<Cursor position="5 |
|
41 | <Cursor position="22195" topLine="58" /> | |
42 | </File> |
|
42 | </File> | |
43 |
<File name="../src/wf_handler.c" open=" |
|
43 | <File name="../src/wf_handler.c" open="0" top="0" tabpos="2"> | |
44 |
<Cursor position="5 |
|
44 | <Cursor position="5903" topLine="117" /> | |
45 | </File> |
|
45 | </File> | |
46 | </CodeBlocks_layout_file> |
|
46 | </CodeBlocks_layout_file> |
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
@@ -1,117 +1,138 | |||||
1 | #ifndef CCSDS_H_INCLUDED |
|
1 | #ifndef CCSDS_H_INCLUDED | |
2 | #define CCSDS_H_INCLUDED |
|
2 | #define CCSDS_H_INCLUDED | |
3 |
|
3 | |||
4 | #define CCSDS_TELEMETRY_HEADER_LENGTH 16+4 |
|
4 | #define CCSDS_TELEMETRY_HEADER_LENGTH 16+4 | |
5 | #define CCSDS_TM_PKT_MAX_SIZE 4412 |
|
5 | #define CCSDS_TM_PKT_MAX_SIZE 4412 | |
6 | #define CCSDS_TELECOMMAND_HEADER_LENGTH 10+4 |
|
6 | #define CCSDS_TELECOMMAND_HEADER_LENGTH 10+4 | |
7 | #define CCSDS_TC_PKT_MAX_SIZE 50 // size of the TC_LFR_UPDATE_INFO packet |
|
7 | #define CCSDS_TC_PKT_MAX_SIZE 50 // size of the TC_LFR_UPDATE_INFO packet | |
8 | #define CCSDS_TC_TM_PACKET_OFFSET 7 |
|
8 | #define CCSDS_TC_TM_PACKET_OFFSET 7 | |
9 | #define CCSDS_PROCESS_ID 76 |
|
9 | #define CCSDS_PROCESS_ID 76 | |
10 | #define CCSDS_PACKET_CATEGORY 12 |
|
10 | #define CCSDS_PACKET_CATEGORY 12 | |
11 | #define CCSDS_NODE_ADDRESS 0xfe |
|
11 | #define CCSDS_NODE_ADDRESS 0xfe | |
12 | // |
|
12 | // | |
13 | #define CCSDS_DESTINATION_ID_GROUND 0x00 |
|
13 | #define CCSDS_DESTINATION_ID_GROUND 0x00 | |
14 | #define CCSDS_DESTINATION_ID 0x01 |
|
14 | #define CCSDS_DESTINATION_ID 0x01 | |
15 | #define CCSDS_DESTINATION_ID_DPU 0x01 |
|
15 | #define CCSDS_DESTINATION_ID_DPU 0x01 | |
16 | // |
|
16 | // | |
17 | #define CCSDS_PROTOCOLE_ID 0x02 |
|
17 | #define CCSDS_PROTOCOLE_ID 0x02 | |
18 | #define CCSDS_USER_APP 0x00 |
|
18 | #define CCSDS_USER_APP 0x00 | |
19 |
|
19 | |||
20 | #define SIZE_TM_LFR_TC_EXE_NOT_IMPLEMENTED 24 |
|
20 | #define SIZE_TM_LFR_TC_EXE_NOT_IMPLEMENTED 24 | |
21 | #define SIZE_TM_LFR_TC_EXE_CORRUPTED 32 |
|
21 | #define SIZE_TM_LFR_TC_EXE_CORRUPTED 32 | |
22 |
|
22 | |||
23 | #define ILLEGAL_APID 0 |
|
23 | #define ILLEGAL_APID 0 | |
24 | #define WRONG_LEN_PACKET 1 |
|
24 | #define WRONG_LEN_PACKET 1 | |
25 | #define INCOR_CHECKSUM 2 |
|
25 | #define INCOR_CHECKSUM 2 | |
26 | #define ILL_TYPE 3 |
|
26 | #define ILL_TYPE 3 | |
27 | #define ILL_SUBTYPE 4 |
|
27 | #define ILL_SUBTYPE 4 | |
28 | #define WRONG_APP_DATA 5 |
|
28 | #define WRONG_APP_DATA 5 | |
29 | #define WRONG_CMD_CODE 6 |
|
29 | #define WRONG_CMD_CODE 6 | |
30 | #define CCSDS_TM_VALID 7 |
|
30 | #define CCSDS_TM_VALID 7 | |
31 | // |
|
31 | ||
32 | #define TC_NOT_EXE 40000 |
|
32 | // TC TYPES | |
33 | #define WRONG_SRC_ID 40001 |
|
33 | #define TC_TYPE_GEN 181 | |
34 |
#define |
|
34 | #define TC_TYPE_TIME 9 | |
35 | #define FAIL_DETECTED 40003 |
|
35 | ||
36 | #define NOT_ALLOWED 40004 |
|
36 | // TC SUBTYPES | |
37 | #define CORRUPTED 40005 |
|
37 | #define TC_SUBTYPE_RESET 1 | |
38 |
|
38 | #define TC_SUBTYPE_LOAD_COMM 11 | ||
39 | // // TC SUBTYPES |
|
39 | #define TC_SUBTYPE_LOAD_NORM 13 | |
40 |
#define TC_SUBTYPE_ |
|
40 | #define TC_SUBTYPE_LOAD_BURST 19 | |
41 |
#define TC_SUBTYPE_LOAD_ |
|
41 | #define TC_SUBTYPE_LOAD_SBM1 25 | |
42 |
#define TC_SUBTYPE_LOAD_ |
|
42 | #define TC_SUBTYPE_LOAD_SBM2 27 | |
43 |
#define TC_SUBTYPE_ |
|
43 | #define TC_SUBTYPE_DUMP 31 | |
44 |
#define TC_SUBTYPE_ |
|
44 | #define TC_SUBTYPE_ENTER 41 | |
45 |
#define TC_SUBTYPE_ |
|
45 | #define TC_SUBTYPE_UPDT_INFO 51 | |
46 |
#define TC_SUBTYPE_ |
|
46 | #define TC_SUBTYPE_EN_CAL 61 | |
47 |
#define TC_SUBTYPE_ |
|
47 | #define TC_SUBTYPE_DIS_CAL 63 | |
48 |
#define TC_SUBTYPE_UPDT_ |
|
48 | #define TC_SUBTYPE_UPDT_TIME 129 | |
49 | #define TC_SUBTYPE_EN_CAL 60 |
|
49 | ||
50 | #define TC_SUBTYPE_DIS_CAL 61 |
|
50 | // TC LEN | |
51 | #define TC_SUBTYPE_UPDT_TIME 129 |
|
51 | #define TC_LEN_RESET 12 | |
52 |
|
52 | #define TC_LEN_LOAD_COMM 14 | ||
53 | #define SID_DEFAULT 0 |
|
53 | #define TC_LEN_LOAD_NORM 20 | |
54 | #define SID_HK 1 |
|
54 | #define TC_LEN_LOAD_BURST 14 | |
55 | #define SID_EXE_INC 5 |
|
55 | #define TC_LEN_LOAD_SBM1 14 | |
56 | #define SID_NOT_EXE 40000 |
|
56 | #define TC_LEN_LOAD_SBM2 14 | |
57 | #define SID_NOT_IMP 40002 |
|
57 | #define TC_LEN_DUMP 12 | |
58 | #define SID_EXE_ERR 40003 |
|
58 | #define TC_LEN_ENTER 20 | |
59 | #define SID_EXE_CORR 40005 |
|
59 | #define TC_LEN_UPDT_INFO 48 | |
60 |
|
60 | #define TC_LEN_EN_CAL 12 | ||
61 | #define SID_NORM_SWF_F0 3 |
|
61 | #define TC_LEN_DIS_CAL 12 | |
62 | #define SID_NORM_SWF_F1 4 |
|
62 | #define TC_LEN_UPDT_TIME 18 | |
63 | #define SID_NORM_SWF_F2 5 |
|
63 | ||
64 | #define SID_NORM_CWF_F3 1 |
|
64 | // TM TYPES | |
65 | #define SID_BURST_CWF_F2 2 |
|
65 | #define TM_TYPE_LFR_SCIENCE 21 | |
66 | #define SID_SBM1_CWF_F1 24 |
|
66 | ||
67 | #define SID_SBM2_CWF_F2 25 |
|
67 | // TM SUBTYPES | |
68 | #define SID_NORM_ASM_F0 11 |
|
68 | #define TM_SUBTYPE_EXE_OK 7 | |
69 | #define SID_NORM_ASM_F1 12 |
|
69 | #define TM_SUBTYPE_EXE_NOK 8 | |
70 | #define SID_NORM_ASM_F2 13 |
|
70 | #define TM_SUBTYPE_HK 25 | |
71 | #define SID_NORM_BP1_F0 14 |
|
71 | #define TM_SUBTYPE_SCIENCE 3 | |
72 | #define SID_NORM_BP1_F1 15 |
|
72 | #define TM_SUBTYPE_LFR_SCIENCE 3 | |
73 | #define SID_NORM_BP1_F2 16 |
|
73 | ||
74 | #define SID_NORM_BP2_F0 19 |
|
74 | #define SID_DEFAULT 0 | |
75 |
#define SID_ |
|
75 | #define SID_HK 1 | |
76 | #define SID_NORM_BP2_F2 21 |
|
76 | #define SID_EXE_INC 5 | |
77 | #define SID_BURST_BP1_F0 17 |
|
77 | #define SID_NOT_EXE 40000 | |
78 |
#define SID_ |
|
78 | #define SID_NOT_IMP 40002 | |
79 | #define SID_BURST_BP1_F1 18 |
|
79 | #define SID_EXE_ERR 40003 | |
80 | #define SID_BURST_BP2_F1 23 |
|
80 | #define SID_EXE_CORR 40005 | |
81 | #define SID_SBM1_BP1_F0 28 |
|
81 | ||
82 |
#define SID_ |
|
82 | #define SID_NORM_SWF_F0 3 | |
83 |
#define SID_ |
|
83 | #define SID_NORM_SWF_F1 4 | |
84 |
#define SID_ |
|
84 | #define SID_NORM_SWF_F2 5 | |
85 |
#define SID_ |
|
85 | #define SID_NORM_CWF_F3 1 | |
86 |
#define SID_ |
|
86 | #define SID_BURST_CWF_F2 2 | |
87 |
|
87 | #define SID_SBM1_CWF_F1 24 | ||
88 | // LENGTH (BYTES) |
|
88 | #define SID_SBM2_CWF_F2 25 | |
89 | #define LENGTH_TM_LFR_HK 126 |
|
89 | #define SID_NORM_ASM_F0 11 | |
90 | #define LENGTH_TM_LFR_TC_EXE_MAX 32 |
|
90 | #define SID_NORM_ASM_F1 12 | |
91 | #define LENGTH_TM_LFR_SCIENCE_NORMAL_WF_MAX 4102 |
|
91 | #define SID_NORM_ASM_F2 13 | |
92 | // |
|
92 | #define SID_NORM_BP1_F0 14 | |
93 | #define TM_LEN_EXE 20 - CCSDS_TC_TM_PACKET_OFFSET |
|
93 | #define SID_NORM_BP1_F1 15 | |
94 | #define TM_LEN_NOT_EXE 26 - CCSDS_TC_TM_PACKET_OFFSET |
|
94 | #define SID_NORM_BP1_F2 16 | |
95 | #define TM_LEN_NOT_IMP 24 - CCSDS_TC_TM_PACKET_OFFSET |
|
95 | #define SID_NORM_BP2_F0 19 | |
96 | #define TM_LEN_EXE_ERR 24 - CCSDS_TC_TM_PACKET_OFFSET |
|
96 | #define SID_NORM_BP2_F1 20 | |
97 | #define TM_LEN_EXE_CORR 32 - CCSDS_TC_TM_PACKET_OFFSET |
|
97 | #define SID_NORM_BP2_F2 21 | |
98 | #define TM_HEADER_LEN 16 |
|
98 | #define SID_BURST_BP1_F0 17 | |
99 |
|
99 | #define SID_BURST_BP2_F0 22 | ||
100 | #define LEN_TM_LFR_HK 126 + 4 |
|
100 | #define SID_BURST_BP1_F1 18 | |
101 | #define LEN_TM_LFR_TC_EXE_NOT_IMP 24 +4 |
|
101 | #define SID_BURST_BP2_F1 23 | |
102 |
|
102 | #define SID_SBM1_BP1_F0 28 | ||
103 | #define TM_LEN_SCI_NORM_SWF_340 340 * 12 + 6 + 10 - 1 |
|
103 | #define SID_SBM1_BP2_F0 31 | |
104 | #define TM_LEN_SCI_NORM_SWF_8 8 * 12 + 6 + 10 - 1 |
|
104 | #define SID_SBM2_BP1_F0 29 | |
105 |
|
105 | #define SID_SBM2_BP2_F0 32 | ||
106 | enum TM_TYPE{ |
|
106 | #define SID_SBM1_BP1_F1 30 | |
107 | TM_LFR_TC_EXE_OK, |
|
107 | #define SID_SBM1_BP2_F1 33 | |
108 | TM_LFR_TC_EXE_ERR, |
|
108 | ||
109 | TM_LFR_HK, |
|
109 | // LENGTH (BYTES) | |
110 | TM_LFR_SCI, |
|
110 | #define LENGTH_TM_LFR_HK 126 | |
111 | TM_LFR_SCI_SBM, |
|
111 | #define LENGTH_TM_LFR_TC_EXE_MAX 32 | |
112 | TM_LFR_PAR_DUMP |
|
112 | #define LENGTH_TM_LFR_SCIENCE_NORMAL_WF_MAX 4102 | |
|
113 | // | |||
|
114 | #define TM_LEN_EXE 20 - CCSDS_TC_TM_PACKET_OFFSET | |||
|
115 | #define TM_LEN_NOT_EXE 26 - CCSDS_TC_TM_PACKET_OFFSET | |||
|
116 | #define TM_LEN_NOT_IMP 24 - CCSDS_TC_TM_PACKET_OFFSET | |||
|
117 | #define TM_LEN_EXE_ERR 24 - CCSDS_TC_TM_PACKET_OFFSET | |||
|
118 | #define TM_LEN_EXE_CORR 32 - CCSDS_TC_TM_PACKET_OFFSET | |||
|
119 | #define TM_HEADER_LEN 16 | |||
|
120 | ||||
|
121 | #define LEN_TM_LFR_HK 126 + 4 | |||
|
122 | #define LEN_TM_LFR_TC_EXE_NOT_IMP 24 +4 | |||
|
123 | ||||
|
124 | #define TM_LEN_SCI_NORM_SWF_340 340 * 12 + 6 + 10 - 1 | |||
|
125 | #define TM_LEN_SCI_NORM_SWF_8 8 * 12 + 6 + 10 - 1 | |||
|
126 | ||||
|
127 | enum TM_TYPE{ | |||
|
128 | TM_LFR_TC_EXE_OK, | |||
|
129 | TM_LFR_TC_EXE_ERR, | |||
|
130 | TM_LFR_HK, | |||
|
131 | TM_LFR_SCI, | |||
|
132 | TM_LFR_SCI_SBM, | |||
|
133 | TM_LFR_PAR_DUMP | |||
113 | }; |
|
134 | }; | |
114 |
|
135 | |||
115 | struct TMHeader_str |
|
136 | struct TMHeader_str | |
116 | { |
|
137 | { | |
117 | volatile unsigned char targetLogicalAddress; |
|
138 | volatile unsigned char targetLogicalAddress; | |
@@ -123,8 +144,8 struct TMHeader_str | |||||
123 | volatile unsigned char packetLength[2]; |
|
144 | volatile unsigned char packetLength[2]; | |
124 | volatile unsigned char dataFieldHeader[10]; |
|
145 | volatile unsigned char dataFieldHeader[10]; | |
125 | }; |
|
146 | }; | |
126 | typedef struct TMHeader_str TMHeader_t; |
|
147 | typedef struct TMHeader_str TMHeader_t; | |
127 |
|
148 | |||
128 | struct Packet_TM_LFR_HK_str |
|
149 | struct Packet_TM_LFR_HK_str | |
129 | { |
|
150 | { | |
130 | volatile unsigned char targetLogicalAddress; |
|
151 | volatile unsigned char targetLogicalAddress; | |
@@ -134,11 +155,11 struct Packet_TM_LFR_HK_str | |||||
134 | volatile unsigned char packetID[2]; |
|
155 | volatile unsigned char packetID[2]; | |
135 | volatile unsigned char packetSequenceControl[2]; |
|
156 | volatile unsigned char packetSequenceControl[2]; | |
136 | volatile unsigned char packetLength[2]; |
|
157 | volatile unsigned char packetLength[2]; | |
137 | volatile unsigned char dataFieldHeader[10]; |
|
158 | volatile unsigned char dataFieldHeader[10]; | |
138 | volatile unsigned char data[LENGTH_TM_LFR_HK - 10 + 1]; |
|
159 | volatile unsigned char data[LENGTH_TM_LFR_HK - 10 + 1]; | |
139 | }; |
|
160 | }; | |
140 | typedef struct Packet_TM_LFR_HK_str Packet_TM_LFR_HK_t; |
|
161 | typedef struct Packet_TM_LFR_HK_str Packet_TM_LFR_HK_t; | |
141 |
|
162 | |||
142 | struct Packet_TM_LFR_TC_EXE_str |
|
163 | struct Packet_TM_LFR_TC_EXE_str | |
143 | { |
|
164 | { | |
144 | volatile unsigned char targetLogicalAddress; |
|
165 | volatile unsigned char targetLogicalAddress; | |
@@ -148,11 +169,11 struct Packet_TM_LFR_TC_EXE_str | |||||
148 | volatile unsigned char packetID[2]; |
|
169 | volatile unsigned char packetID[2]; | |
149 | volatile unsigned char packetSequenceControl[2]; |
|
170 | volatile unsigned char packetSequenceControl[2]; | |
150 | volatile unsigned char packetLength[2]; |
|
171 | volatile unsigned char packetLength[2]; | |
151 | volatile unsigned char dataFieldHeader[10]; |
|
172 | volatile unsigned char dataFieldHeader[10]; | |
152 | volatile unsigned char data[LENGTH_TM_LFR_TC_EXE_MAX - 10 + 1]; |
|
173 | volatile unsigned char data[LENGTH_TM_LFR_TC_EXE_MAX - 10 + 1]; | |
153 | }; |
|
174 | }; | |
154 | typedef struct Packet_TM_LFR_TC_EXE_str Packet_TM_LFR_TC_EXE_t; |
|
175 | typedef struct Packet_TM_LFR_TC_EXE_str Packet_TM_LFR_TC_EXE_t; | |
155 |
|
176 | |||
156 | struct Packet_TM_LFR_SCIENCE_NORMAL_WF_str |
|
177 | struct Packet_TM_LFR_SCIENCE_NORMAL_WF_str | |
157 | { |
|
178 | { | |
158 | volatile unsigned char targetLogicalAddress; |
|
179 | volatile unsigned char targetLogicalAddress; | |
@@ -162,14 +183,14 struct Packet_TM_LFR_SCIENCE_NORMAL_WF_s | |||||
162 | volatile unsigned char packetID[2]; |
|
183 | volatile unsigned char packetID[2]; | |
163 | volatile unsigned char packetSequenceControl[2]; |
|
184 | volatile unsigned char packetSequenceControl[2]; | |
164 | volatile unsigned char packetLength[2]; |
|
185 | volatile unsigned char packetLength[2]; | |
165 | volatile unsigned char dataFieldHeader[10]; |
|
186 | volatile unsigned char dataFieldHeader[10]; | |
166 | volatile unsigned char auxiliaryHeader[6]; |
|
187 | volatile unsigned char auxiliaryHeader[6]; | |
167 | volatile unsigned char data[LENGTH_TM_LFR_SCIENCE_NORMAL_WF_MAX - 10 + 1]; |
|
188 | volatile unsigned char data[LENGTH_TM_LFR_SCIENCE_NORMAL_WF_MAX - 10 + 1]; | |
168 | }; |
|
189 | }; | |
169 | typedef struct Packet_TM_LFR_SCIENCE_NORMAL_WF_str Packet_TM_LFR_SCIENCE_NORMAL_WF_t; |
|
190 | typedef struct Packet_TM_LFR_SCIENCE_NORMAL_WF_str Packet_TM_LFR_SCIENCE_NORMAL_WF_t; | |
170 |
|
191 | |||
171 | struct ExtendedTMHeader_str |
|
192 | struct ExtendedTMHeader_str | |
172 | { |
|
193 | { | |
173 | volatile unsigned char targetLogicalAddress; |
|
194 | volatile unsigned char targetLogicalAddress; | |
174 | volatile unsigned char protocolIdentifier; |
|
195 | volatile unsigned char protocolIdentifier; | |
175 | volatile unsigned char reserved; |
|
196 | volatile unsigned char reserved; | |
@@ -177,10 +198,10 struct ExtendedTMHeader_str | |||||
177 | volatile unsigned char packetID[2]; |
|
198 | volatile unsigned char packetID[2]; | |
178 | volatile unsigned char packetSequenceControl[2]; |
|
199 | volatile unsigned char packetSequenceControl[2]; | |
179 | volatile unsigned char packetLength[2]; |
|
200 | volatile unsigned char packetLength[2]; | |
180 | volatile unsigned char dataFieldHeader[10]; |
|
201 | volatile unsigned char dataFieldHeader[10]; | |
181 | volatile unsigned char auxiliaryHeader[6]; |
|
202 | volatile unsigned char auxiliaryHeader[6]; | |
182 | }; |
|
203 | }; | |
183 | typedef struct ExtendedTMHeader_str ExtendedTMHeader_t; |
|
204 | typedef struct ExtendedTMHeader_str ExtendedTMHeader_t; | |
184 |
|
205 | |||
185 | struct ccsdsTelecommandPacket_str |
|
206 | struct ccsdsTelecommandPacket_str | |
186 | { |
|
207 | { | |
@@ -191,9 +212,9 struct ccsdsTelecommandPacket_str | |||||
191 | volatile unsigned char packetID[2]; |
|
212 | volatile unsigned char packetID[2]; | |
192 | volatile unsigned char packetSequenceControl[2]; |
|
213 | volatile unsigned char packetSequenceControl[2]; | |
193 | volatile unsigned char packetLength[2]; |
|
214 | volatile unsigned char packetLength[2]; | |
194 | volatile unsigned char dataFieldHeader[4]; |
|
215 | volatile unsigned char dataFieldHeader[4]; | |
195 | volatile unsigned char dataAndCRC[CCSDS_TC_PKT_MAX_SIZE-10]; |
|
216 | volatile unsigned char dataAndCRC[CCSDS_TC_PKT_MAX_SIZE-10]; | |
196 | }; |
|
217 | }; | |
197 | typedef struct ccsdsTelecommandPacket_str ccsdsTelecommandPacket_t; |
|
218 | typedef struct ccsdsTelecommandPacket_str ccsdsTelecommandPacket_t; | |
198 |
|
219 | |||
199 | #endif // CCSDS_H_INCLUDED |
|
220 | #endif // CCSDS_H_INCLUDED |
@@ -16,7 +16,7 | |||||
16 | #include <wf_handler.h> |
|
16 | #include <wf_handler.h> | |
17 | #include <grlib_regs.h> |
|
17 | #include <grlib_regs.h> | |
18 |
|
18 | |||
19 | extern int sched_yield(); |
|
19 | extern int sched_yield( void ); | |
20 | extern int errno; |
|
20 | extern int errno; | |
21 | extern rtems_id Task_id[ ]; /* array of task ids */ |
|
21 | extern rtems_id Task_id[ ]; /* array of task ids */ | |
22 | extern rtems_name Task_name[ ]; /* array of task names */ |
|
22 | extern rtems_name Task_name[ ]; /* array of task names */ | |
@@ -39,21 +39,21 rtems_task recv_task(rtems_task_argument | |||||
39 | rtems_task spiq_task(rtems_task_argument argument); |
|
39 | rtems_task spiq_task(rtems_task_argument argument); | |
40 | rtems_task stat_task(rtems_task_argument argument); |
|
40 | rtems_task stat_task(rtems_task_argument argument); | |
41 | rtems_task wfrm_task(rtems_task_argument argument); |
|
41 | rtems_task wfrm_task(rtems_task_argument argument); | |
42 | int create_names(); |
|
42 | int create_names( void ); | |
43 | int create_all_tasks(); |
|
43 | int create_all_tasks( void ); | |
44 | int start_all_tasks(); |
|
44 | int start_all_tasks( void ); | |
45 | int create_message_queue(); |
|
45 | int create_message_queue( void ); | |
46 |
|
46 | |||
47 | // OTHER functions |
|
47 | // OTHER functions | |
48 | void init_default_mode_parameters(); |
|
48 | void init_default_mode_parameters( void ); | |
49 |
|
49 | |||
50 | int configure_spw_link(); |
|
50 | int configure_spw_link( void ); | |
51 | void configure_spacewire_set_NP(unsigned char val, unsigned int regAddr); // No Port force |
|
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 |
|
52 | void configure_spacewire_set_RE(unsigned char val, unsigned int regAddr); // RMAP Enable | |
53 |
|
53 | |||
54 | extern int rtems_cpu_usage_report(); |
|
54 | extern int rtems_cpu_usage_report( void ); | |
55 | extern int rtems_cpu_usage_reset(); |
|
55 | extern int rtems_cpu_usage_reset( void ); | |
56 | void print_statistics(spw_stats *); |
|
56 | ||
57 | rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send); |
|
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); |
|
58 | void (*grspw_timecode_callback) (void *pDev, void *regs, int minor, unsigned int tc); | |
59 |
|
59 |
@@ -10,15 +10,15 | |||||
10 | #include <grspw.h> |
|
10 | #include <grspw.h> | |
11 | #include <ccsds_types.h> |
|
11 | #include <ccsds_types.h> | |
12 |
|
12 | |||
13 |
rtems_name HK_name; |
|
13 | rtems_name HK_name; // name of the HK rate monotonic | |
14 |
rtems_id HK_id; |
|
14 | rtems_id HK_id; // id of the HK rate monotonic period | |
15 |
|
15 | |||
16 | int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider, |
|
16 | int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider, | |
17 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ); |
|
17 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ); | |
18 | void print_statistics(spw_stats *stats); |
|
18 | void print_statistics(spw_stats *stats); | |
19 |
|
19 | |||
20 | // SERIAL LINK |
|
20 | // SERIAL LINK | |
21 | int send_console_outputs_on_serial_port(); |
|
21 | int send_console_outputs_on_serial_port( void ); | |
22 | int set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value); |
|
22 | int set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value); | |
23 |
|
23 | |||
24 | // RTEMS TASKS |
|
24 | // RTEMS TASKS |
@@ -1,66 +1,67 | |||||
1 | #ifndef FSW_RTEMS_CONFIG_H_INCLUDED |
|
1 | #ifndef FSW_RTEMS_CONFIG_H_INCLUDED | |
2 | #define FSW_RTEMS_CONFIG_H_INCLUDED |
|
2 | #define FSW_RTEMS_CONFIG_H_INCLUDED | |
3 |
|
3 | |||
4 | #define GRSPW_DEVICE_NAME "/dev/grspw0" |
|
4 | #define GRSPW_DEVICE_NAME "/dev/grspw0" | |
5 | #define UART_DEVICE_NAME "/dev/console" |
|
5 | #define UART_DEVICE_NAME "/dev/console" | |
6 |
|
6 | |||
7 | //********** |
|
7 | //********** | |
8 | // LFR MODES |
|
8 | // LFR MODES | |
9 | #define LFR_MODE_STANDBY 0 |
|
9 | #define LFR_MODE_STANDBY 0 | |
10 | #define LFR_MODE_NORMAL 1 |
|
10 | #define LFR_MODE_NORMAL 1 | |
11 | #define LFR_MODE_BURST 2 |
|
11 | #define LFR_MODE_BURST 2 | |
12 | #define LFR_MODE_SBM1 3 |
|
12 | #define LFR_MODE_SBM1 3 | |
13 | #define LFR_MODE_SBM2 4 |
|
13 | #define LFR_MODE_SBM2 4 | |
14 |
|
14 | |||
15 | //***************************** |
|
15 | //***************************** | |
16 | // APB REGISTERS BASE ADDRESSES |
|
16 | // APB REGISTERS BASE ADDRESSES | |
17 | #define REGS_ADDR_APBUART 0x80000100 |
|
17 | #define REGS_ADDR_APBUART 0x80000100 | |
18 | #define REGS_ADDR_GPTIMER 0x80000300 |
|
18 | #define REGS_ADDR_GPTIMER 0x80000300 | |
19 | #define REGS_ADDR_GRSPW 0x80000500 |
|
19 | #define REGS_ADDR_GRSPW 0x80000500 | |
20 | #define REGS_ADDR_TIME_MANAGEMENT 0x80000600 |
|
20 | #define REGS_ADDR_TIME_MANAGEMENT 0x80000600 | |
21 | #define REGS_ADDR_SPECTRAL_MATRICES 0x80000700 |
|
21 | #define REGS_ADDR_SPECTRAL_MATRICES 0x80000700 | |
22 |
|
22 | #define REGS_ADDR_WAVEFORM_PICKER 0x80000f20 | ||
23 | #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff |
|
23 | ||
24 | #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 |
|
24 | #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff | |
25 |
|
25 | #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400 | ||
26 | //********** |
|
26 | ||
|
27 | //********** | |||
27 | // IRQ LINES |
|
28 | // IRQ LINES | |
28 | #define IRQ_SM 9 |
|
29 | #define IRQ_SM 9 | |
29 | #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels |
|
30 | #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels | |
30 | #define IRQ_WF 10 |
|
31 | #define IRQ_WF 10 | |
31 | #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels |
|
32 | #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels | |
32 | #define IRQ_TIME1 12 |
|
33 | #define IRQ_TIME1 12 | |
33 | #define IRQ_SPARC_TIME1 0x1c // see sparcv8.pdf p.76 for interrupt levels |
|
34 | #define IRQ_SPARC_TIME1 0x1c // see sparcv8.pdf p.76 for interrupt levels | |
34 | #define IRQ_TIME2 13 |
|
35 | #define IRQ_TIME2 13 | |
35 | #define IRQ_SPARC_TIME2 0x1d // see sparcv8.pdf p.76 for interrupt levels |
|
36 | #define IRQ_SPARC_TIME2 0x1d // see sparcv8.pdf p.76 for interrupt levels | |
36 |
|
37 | #define IRQ_WAVEFORM_PICKER 14 | ||
37 | //***** |
|
38 | #define IRQ_SPARC_WAVEFORM_PICKER 0x1e // see sparcv8.pdf p.76 for interrupt levels | |
38 | // TIME |
|
39 | ||
39 | #define CLKDIV_SM_SIMULATOR 9999 |
|
40 | //***** | |
40 | #define CLKDIV_WF_SIMULATOR 9999999 |
|
41 | // TIME | |
41 |
#define |
|
42 | #define CLKDIV_SM_SIMULATOR 9999 | |
42 |
#define |
|
43 | #define CLKDIV_WF_SIMULATOR 9999999 | |
43 | #define HK_PERIOD 100 // 100 * 10ms => 1sec |
|
44 | #define TIMER_SM_SIMULATOR 1 | |
44 |
|
45 | #define TIMER_WF_SIMULATOR 2 | ||
45 | //****** |
|
46 | #define HK_PERIOD 100 // 100 * 10ms => 1sec | |
46 | // RTEMS |
|
47 | ||
47 | #define TASKID_RECV 1 |
|
48 | //****** | |
48 | #define TASKID_ACTN 2 |
|
49 | // RTEMS | |
49 |
#define TASKID_ |
|
50 | #define TASKID_RECV 1 | |
50 |
#define TASKID_ |
|
51 | #define TASKID_ACTN 2 | |
51 |
#define TASKID_S |
|
52 | #define TASKID_SPIQ 3 | |
52 |
#define TASKID_ |
|
53 | #define TASKID_SMIQ 4 | |
53 |
#define TASKID_ |
|
54 | #define TASKID_STAT 5 | |
54 |
#define TASKID_ |
|
55 | #define TASKID_AVF0 6 | |
55 |
#define TASKID_ |
|
56 | #define TASKID_BPF0 7 | |
56 |
#define TASKID_ |
|
57 | #define TASKID_WFRM 8 | |
57 |
|
58 | #define TASKID_DUMB 9 | ||
58 | #define ACTION_MSG_QUEUE_COUNT 10 |
|
59 | #define TASKID_HOUS 10 | |
59 |
|
60 | |||
60 | //******* |
|
61 | #define ACTION_MSG_QUEUE_COUNT 10 | |
61 | // MACROS |
|
62 | ||
62 | #define PRINT_TASK_STATISTICS |
|
63 | //******* | |
63 | #define PRINT_MESSAGES_ON_CONSOLE // enable or disable the printf instructions |
|
64 | // MACROS | |
64 | #ifdef PRINT_MESSAGES_ON_CONSOLE |
|
65 | #ifdef PRINT_MESSAGES_ON_CONSOLE | |
65 | #define PRINTF(x) printf(x); |
|
66 | #define PRINTF(x) printf(x); | |
66 | #define PRINTF1(x,y) printf(x,y); |
|
67 | #define PRINTF1(x,y) printf(x,y); | |
@@ -69,38 +70,35 | |||||
69 | #define PRINTF(x) ; |
|
70 | #define PRINTF(x) ; | |
70 | #define PRINTF1(x,y) ; |
|
71 | #define PRINTF1(x,y) ; | |
71 | #define PRINTF2(x,y,z) ; |
|
72 | #define PRINTF2(x,y,z) ; | |
72 | #endif |
|
73 | #endif | |
73 |
|
74 | |||
74 | #define NB_SAMPLES_PER_SNAPSHOT 2048 |
|
75 | #define NB_SAMPLES_PER_SNAPSHOT 2048 | |
75 | #define NB_BYTES_SWF_BLK 2 * 6 |
|
76 | #define TIME_OFFSET 2 | |
76 | #define NB_WORDS_SWF_BLK 3 |
|
77 | #define WAVEFORM_EXTENDED_HEADER_OFFSET 22 | |
77 |
|
78 | #define NB_BYTES_SWF_BLK 2 * 6 | ||
78 | struct param_norm_str{ |
|
79 | #define NB_WORDS_SWF_BLK 3 | |
79 | unsigned int sy_lfr_n_swf_l; // length of the snapshots |
|
80 | ||
80 | unsigned int sy_lfr_n_swf_p; // time between two snapshots |
|
81 | struct param_norm_str{ | |
81 |
unsigned int sy_lfr_n_ |
|
82 | unsigned int sy_lfr_n_swf_l; // length of the snapshots | |
82 |
unsigned |
|
83 | unsigned int sy_lfr_n_swf_p; // time between two snapshots | |
83 |
unsigned |
|
84 | unsigned int sy_lfr_n_asm_p; // time between two asm | |
84 | }; |
|
85 | unsigned char sy_lfr_n_bp_p0; // timebetween two products BP1 set | |
85 |
|
86 | unsigned char sy_lfr_n_bp_p1; // time between two products BP2 set | ||
86 | struct param_burst_str{ |
|
87 | }; | |
87 | unsigned char sy_lfr_b_bp_p0; // timebetween two products BP1 set |
|
88 | ||
88 | unsigned char sy_lfr_b_bp_p1; // time between two products BP2 set |
|
89 | struct param_burst_str{ | |
89 | }; |
|
90 | unsigned char sy_lfr_b_bp_p0; // timebetween two products BP1 set | |
90 |
|
91 | unsigned char sy_lfr_b_bp_p1; // time between two products BP2 set | ||
91 | struct param_sbm1_str{ |
|
92 | }; | |
92 | unsigned char sy_lfr_s1_bp_p0; // timebetween two products BP1 set |
|
93 | ||
93 | unsigned char sy_lfr_s1_bp_p1; // time between two products BP2 set |
|
94 | struct param_sbm1_str{ | |
94 | }; |
|
95 | unsigned char sy_lfr_s1_bp_p0; // timebetween two products BP1 set | |
95 |
|
96 | unsigned char sy_lfr_s1_bp_p1; // time between two products BP2 set | ||
96 | struct param_sbm2_str{ |
|
97 | }; | |
97 | unsigned char sy_lfr_s2_bp_p0; // timebetween two products BP1 set |
|
98 | ||
98 | unsigned char sy_lfr_s2_bp_p1; // time between two products BP2 set |
|
99 | struct param_sbm2_str{ | |
99 | }; |
|
100 | unsigned char sy_lfr_s2_bp_p0; // timebetween two products BP1 set | |
100 |
|
101 | unsigned char sy_lfr_s2_bp_p1; // time between two products BP2 set | ||
101 | extern volatile int wf_snap_f0[ ]; // 24576 bytes |
|
102 | }; | |
102 | extern volatile int wf_snap_f1[ ]; // 24576 bytes |
|
103 | ||
103 | extern volatile int wf_snap_f2[ ]; // 24576 bytes |
|
104 | #endif // FSW_RTEMS_CONFIG_H_INCLUDED | |
104 | extern volatile int wf_cont_f3[ ]; // 24576 bytes |
|
|||
105 |
|
||||
106 | #endif // FSW_RTEMS_CONFIG_H_INCLUDED |
|
@@ -13,7 +13,10 | |||||
13 |
|
13 | |||
14 | #include <rtems.h> |
|
14 | #include <rtems.h> | |
15 | #include <grlib_regs.h> |
|
15 | #include <grlib_regs.h> | |
16 | #include <fsw_params.h> |
|
16 | #include <fsw_params.h> | |
|
17 | #include <stdio.h> | |||
|
18 | #include <stdlib.h> | |||
|
19 | #include <leon.h> | |||
17 |
|
20 | |||
18 | struct BP1_str{ |
|
21 | struct BP1_str{ | |
19 | volatile unsigned char PE[2]; |
|
22 | volatile unsigned char PE[2]; | |
@@ -24,7 +27,25 struct BP1_str{ | |||||
24 | volatile unsigned char SZ; |
|
27 | volatile unsigned char SZ; | |
25 | volatile unsigned char VPHI; |
|
28 | volatile unsigned char VPHI; | |
26 | }; |
|
29 | }; | |
27 | typedef struct BP1_str BP1_t; |
|
30 | typedef struct BP1_str BP1_t; | |
|
31 | ||||
|
32 | extern volatile int spec_mat_f0_a[ ]; | |||
|
33 | extern volatile int spec_mat_f0_b[ ]; | |||
|
34 | extern volatile int spec_mat_f0_c[ ]; | |||
|
35 | extern volatile int spec_mat_f0_d[ ]; | |||
|
36 | extern volatile int spec_mat_f0_e[ ]; | |||
|
37 | extern volatile int spec_mat_f0_f[ ]; | |||
|
38 | extern volatile int spec_mat_f0_g[ ]; | |||
|
39 | extern volatile int spec_mat_f0_h[ ]; | |||
|
40 | extern float averaged_spec_mat_f0[ ]; | |||
|
41 | extern float compressed_spec_mat_f0[ ]; | |||
|
42 | extern unsigned char LFR_BP1_F0[ ]; | |||
|
43 | ||||
|
44 | extern BP1_t data_BP1[ ]; | |||
|
45 | ||||
|
46 | extern rtems_id Task_id[ ]; /* array of task ids */ | |||
|
47 | ||||
|
48 | extern spectral_matrices_regs_t *spectral_matrices_regs; | |||
28 |
|
49 | |||
29 | // ISR |
|
50 | // ISR | |
30 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ); |
|
51 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ); |
@@ -45,4 +45,20 struct time_management_regs_str{ | |||||
45 | }; |
|
45 | }; | |
46 | typedef struct time_management_regs_str time_management_regs_t; |
|
46 | typedef struct time_management_regs_str time_management_regs_t; | |
47 |
|
47 | |||
|
48 | struct waveform_picker_regs_str{ | |||
|
49 | volatile int data_shaping; // 0x00 00 *** R1 R0 SP1 SP0 BW | |||
|
50 | volatile int burst_enable; // 0x04 01 *** burst f2, f1, f0 enable f3, f2, f1, f0 | |||
|
51 | volatile int addr_data_f0; // 0x08 10 *** | |||
|
52 | volatile int addr_data_f1; // 0x0c 11 *** | |||
|
53 | volatile int addr_data_f2; // 0x10 100 *** | |||
|
54 | volatile int addr_data_f3; // 0x14 101 *** | |||
|
55 | volatile int status; // 0x18 110 *** | |||
|
56 | volatile int delta_snapshot; // 0x1c 111 *** | |||
|
57 | volatile int delta_f2_f1; // 0x20 0000 *** | |||
|
58 | volatile int delta_f2_f0; // 0x24 0001 *** | |||
|
59 | volatile int nb_burst_available;// 0x28 0010 *** | |||
|
60 | volatile int nb_snapshot_param; // 0x2c 0011 *** | |||
|
61 | }; | |||
|
62 | typedef struct waveform_picker_regs_str waveform_picker_regs_t; | |||
|
63 | ||||
48 | #endif // GRLIBREGS_H_INCLUDED |
|
64 | #endif // GRLIBREGS_H_INCLUDED |
@@ -1,70 +1,65 | |||||
1 | #ifndef TC_HANDLER_H_INCLUDED |
|
1 | #ifndef TC_HANDLER_H_INCLUDED | |
2 | #define TC_HANDLER_H_INCLUDED |
|
2 | #define TC_HANDLER_H_INCLUDED | |
3 |
|
3 | |||
4 | #include <rtems.h> |
|
4 | #include <rtems.h> | |
5 | #include <bsp.h> // for the LEON_Unmask_interrupt function |
|
5 | #include <bsp.h> // for the LEON_Unmask_interrupt function | |
6 | #include <stdio.h> |
|
6 | #include <stdio.h> | |
7 | #include <unistd.h> // for the read call |
|
7 | #include <unistd.h> // for the read call | |
8 | #include <sys/ioctl.h> // for the ioctl call |
|
8 | #include <sys/ioctl.h> // for the ioctl call | |
9 | #include <ccsds_types.h> |
|
9 | #include <ccsds_types.h> | |
10 | #include <grspw.h> |
|
10 | #include <grspw.h> | |
11 | #include <fsw_init.h> |
|
11 | #include <fsw_init.h> | |
12 |
|
12 | |||
13 | extern int fdSPW; |
|
13 | extern int fdSPW; | |
14 | extern rtems_name misc_name[ ]; |
|
14 | extern rtems_name misc_name[ ]; | |
15 | extern rtems_name misc_id[ ]; |
|
15 | extern rtems_name misc_id[ ]; | |
16 | extern rtems_id Task_id[ ]; // array of task ids |
|
16 | extern rtems_id Task_id[ ]; // array of task ids | |
17 | // MODE PARAMETERS |
|
17 | // MODE PARAMETERS | |
18 | extern struct param_norm_str param_norm; |
|
18 | extern struct param_norm_str param_norm; | |
19 | extern struct param_sbm1_str param_sbm1; |
|
19 | extern struct param_sbm1_str param_sbm1; | |
20 | extern struct param_sbm2_str param_sbm2; |
|
20 | extern struct param_sbm2_str param_sbm2; | |
21 | extern time_management_regs_t *time_management_regs; |
|
21 | extern time_management_regs_t *time_management_regs; | |
22 | extern unsigned char param_common[]; |
|
22 | extern waveform_picker_regs_t *waveform_picker_regs; | |
23 |
|
23 | extern gptimer_regs_t *gptimer_regs; | ||
24 | unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field |
|
24 | extern unsigned char param_common[]; | |
25 | unsigned char currentTC_COMPUTED_CRC[2]; |
|
25 | ||
26 | unsigned int currentTC_LEN_RCV_AsUnsignedInt; |
|
26 | //**** | |
27 | unsigned int currentTM_length; |
|
|||
28 | unsigned char currentTC_processedFlag; |
|
|||
29 |
|
||||
30 | //**** |
|
|||
31 | // ISR |
|
27 | // ISR | |
32 | rtems_isr commutation_isr1( rtems_vector_number vector ); |
|
28 | rtems_isr commutation_isr1( rtems_vector_number vector ); | |
33 | rtems_isr commutation_isr2( rtems_vector_number vector ); |
|
29 | rtems_isr commutation_isr2( rtems_vector_number vector ); | |
34 |
|
30 | |||
35 | //********************** |
|
31 | //********************** | |
36 | // GENERAL USE FUNCTIONS |
|
32 | // GENERAL USE FUNCTIONS | |
37 |
|
|
33 | void initLookUpTableForCRC( void ); | |
38 | void initLookUpTableForCRC(); |
|
34 | void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData); | |
39 | void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData); |
|
35 | ||
40 |
|
36 | //********************* | ||
41 | //********************* |
|
|||
42 | // ACCEPTANCE FUNCTIONS |
|
37 | // ACCEPTANCE FUNCTIONS | |
43 | unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int tc_len_recv); |
|
38 | unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int tc_len_recv); | |
|
39 | ||||
|
40 | unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength, | |||
|
41 | unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader); | |||
|
42 | unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC); | |||
|
43 | int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV); | |||
44 |
|
44 | |||
45 | unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength, |
|
45 | //*********** | |
46 | unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader); |
|
46 | // RTEMS TASK | |
47 | unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC); |
|
47 | rtems_task recv_task( rtems_task_argument unused ); | |
48 | int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV); |
|
48 | rtems_task actn_task( rtems_task_argument unused ); | |
49 |
|
49 | rtems_task dumb_task( rtems_task_argument unused ); | ||
50 | //*********** |
|
50 | int create_message_queue( void ); | |
51 | // RTEMS TASK |
|
51 | ||
52 | rtems_task recv_task( rtems_task_argument unused ); |
|
52 | //*********** | |
53 | rtems_task actn_task( rtems_task_argument unused ); |
|
53 | // TC ACTIONS | |
54 | rtems_task dumb_task( rtems_task_argument unused ); |
|
54 | int action_default(ccsdsTelecommandPacket_t *TC); | |
55 | int create_message_queue(); |
|
55 | int action_default_alt(ccsdsTelecommandPacket_t *TC); | |
56 |
|
56 | int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC); | ||
57 | //*********** |
|
57 | // | |
58 | // TC ACTIONS |
|
58 | int action_load_norm(ccsdsTelecommandPacket_t *TC); | |
59 |
int action_ |
|
59 | int action_enter(ccsdsTelecommandPacket_t *TC); | |
60 |
int action_ |
|
60 | int action_updt_time(ccsdsTelecommandPacket_t *TC); | |
61 | int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC); |
|
|||
62 | // |
|
|||
63 | int action_load_norm(ccsdsTelecommandPacket_t *TC); |
|
|||
64 | int action_enter(ccsdsTelecommandPacket_t *TC); |
|
|||
65 | int action_updt_time(ccsdsTelecommandPacket_t *TC); |
|
|||
66 |
|
61 | |||
67 | #endif // TC_HANDLER_H_INCLUDED |
|
62 | #endif // TC_HANDLER_H_INCLUDED | |
68 |
|
63 | |||
69 |
|
64 | |||
70 |
|
65 |
@@ -8,18 +8,30 | |||||
8 | #include <ccsds_types.h> |
|
8 | #include <ccsds_types.h> | |
9 | #include <stdio.h> |
|
9 | #include <stdio.h> | |
10 | #include <fsw_init.h> |
|
10 | #include <fsw_init.h> | |
|
11 | #include <math.h> | |||
|
12 | ||||
|
13 | #define pi 3.1415 | |||
11 |
|
14 | |||
12 | //#include <sys/ioctl.h> |
|
15 | //#include <sys/ioctl.h> | |
13 |
|
16 | |||
14 | extern rtems_id Task_id[]; /* array of task ids */ |
|
17 | extern rtems_id Task_id[]; /* array of task ids */ | |
15 | extern int fdSPW; |
|
18 | extern int fdSPW; | |
|
19 | extern volatile int wf_snap_f0[ ]; | |||
|
20 | extern volatile int wf_snap_f1[ ]; | |||
|
21 | extern volatile int wf_snap_f2[ ]; | |||
|
22 | extern volatile int wf_cont_f3[ ]; | |||
|
23 | extern waveform_picker_regs_t *waveform_picker_regs; | |||
16 |
|
24 | |||
17 | rtems_isr waveforms_isr( rtems_vector_number vector ); |
|
25 | rtems_isr waveforms_isr( rtems_vector_number vector ); | |
|
26 | rtems_isr waveforms_simulator_isr( rtems_vector_number vector ); | |||
18 | rtems_task wfrm_task(rtems_task_argument argument); |
|
27 | rtems_task wfrm_task(rtems_task_argument argument); | |
19 |
|
28 | |||
20 | //****************** |
|
29 | //****************** | |
21 | // general functions |
|
30 | // general functions | |
22 | void init_waveforms(); |
|
31 | void init_waveforms( void ); | |
23 | int buil_value(int value1, int value0); |
|
32 | void reset_waveforms( void ); | |
|
33 | void send_waveform( ExtendedTMHeader_t *header, volatile int *waveform, unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send); | |||
|
34 | void init_waveform_picker_regs(); | |||
|
35 | int build_value(int value1, int value0); | |||
24 |
|
36 | |||
25 | #endif // WF_HANDLER_H_INCLUDED |
|
37 | #endif // WF_HANDLER_H_INCLUDED |
@@ -5,31 +5,35 | |||||
5 | // RTEMS GLOBAL VARIABLES |
|
5 | // RTEMS GLOBAL VARIABLES | |
6 | rtems_name misc_name[5]; |
|
6 | rtems_name misc_name[5]; | |
7 | rtems_name misc_id[5]; |
|
7 | rtems_name misc_id[5]; | |
8 | rtems_id Task_id[15]; /* array of task ids */ |
|
8 | rtems_id Task_id[15]; /* array of task ids */ | |
9 | rtems_name Task_name[15]; /* array of task names */ |
|
9 | rtems_name Task_name[15]; /* array of task names */ | |
10 | int fdSPW; |
|
10 | int fdSPW = 0; | |
11 | int fdUART; |
|
11 | int fdUART = 0; | |
|
12 | ||||
|
13 | spectral_matrices_regs_t *spectral_matrices_regs = NULL; | |||
12 |
|
14 | |||
13 | // APB CONFIGURATION REGISTERS |
|
15 | // APB CONFIGURATION REGISTERS | |
14 | time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT; |
|
16 | time_management_regs_t *time_management_regs = (time_management_regs_t*) REGS_ADDR_TIME_MANAGEMENT; | |
|
17 | waveform_picker_regs_t *waveform_picker_regs = (waveform_picker_regs_t*) REGS_ADDR_WAVEFORM_PICKER; | |||
|
18 | gptimer_regs_t *gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER; | |||
15 |
|
19 | |||
16 | // WAVEFORMS GLOBAL VARIABLES |
|
20 | // WAVEFORMS GLOBAL VARIABLES | |
17 |
volatile int wf_snap_f0[ NB_SAMPLES_PER_SNAPSHOT * NB_ |
|
21 | volatile int wf_snap_f0[ 2 * NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + 2]; // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes | |
18 |
volatile int wf_snap_f1[ NB_SAMPLES_PER_SNAPSHOT * NB_ |
|
22 | volatile int wf_snap_f1[ 2 * NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + 2]; // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes | |
19 |
volatile int wf_snap_f2[ NB_SAMPLES_PER_SNAPSHOT * NB_ |
|
23 | volatile int wf_snap_f2[ 2 * NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + 2]; // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes | |
20 |
volatile int wf_cont_f3[ NB_SAMPLES_PER_SNAPSHOT * NB_ |
|
24 | volatile int wf_cont_f3[ 2 * NB_SAMPLES_PER_SNAPSHOT * NB_WORDS_SWF_BLK + 2]; // 2048 * 3 * 4 + 2 * 4 = 24576 + 8 bytes | |
21 |
|
25 | |||
22 | // SPECTRAL MATRICES GLOBAL VARIABLES |
|
26 | // SPECTRAL MATRICES GLOBAL VARIABLES | |
23 | volatile int spec_mat_f0_a[ TOTAL_SIZE_SPEC_MAT ]; |
|
27 | volatile int spec_mat_f0_a[ TOTAL_SIZE_SPEC_MAT ]; | |
24 | volatile int spec_mat_f0_b[ TOTAL_SIZE_SPEC_MAT ]; |
|
28 | volatile int spec_mat_f0_b[ TOTAL_SIZE_SPEC_MAT ]; | |
25 | volatile int spec_mat_f0_c[ TOTAL_SIZE_SPEC_MAT ]; |
|
29 | volatile int spec_mat_f0_c[ TOTAL_SIZE_SPEC_MAT ]; | |
26 | volatile int spec_mat_f0_d[ TOTAL_SIZE_SPEC_MAT ]; |
|
30 | volatile int spec_mat_f0_d[ TOTAL_SIZE_SPEC_MAT ]; | |
27 | volatile int spec_mat_f0_e[ TOTAL_SIZE_SPEC_MAT ]; |
|
31 | volatile int spec_mat_f0_e[ TOTAL_SIZE_SPEC_MAT ]; | |
28 | volatile int spec_mat_f0_f[ TOTAL_SIZE_SPEC_MAT ]; |
|
32 | volatile int spec_mat_f0_f[ TOTAL_SIZE_SPEC_MAT ]; | |
29 | volatile int spec_mat_f0_g[ TOTAL_SIZE_SPEC_MAT ]; |
|
33 | volatile int spec_mat_f0_g[ TOTAL_SIZE_SPEC_MAT ]; | |
30 | volatile int spec_mat_f0_h[ TOTAL_SIZE_SPEC_MAT ]; |
|
34 | volatile int spec_mat_f0_h[ TOTAL_SIZE_SPEC_MAT ]; | |
31 | // |
|
35 | // | |
32 | float averaged_spec_mat_f0[ TOTAL_SIZE_SPEC_MAT ]; |
|
36 | float averaged_spec_mat_f0[ TOTAL_SIZE_SPEC_MAT ]; | |
33 | float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ]; |
|
37 | float compressed_spec_mat_f0[ TOTAL_SIZE_COMPRESSED_MATRIX_f0 ]; | |
34 |
|
38 | |||
35 | // MODE PARAMETERS |
|
39 | // MODE PARAMETERS | |
@@ -42,7 +46,7 unsigned char param_common[2]; | |||||
42 | // HK PACKETS |
|
46 | // HK PACKETS | |
43 | Packet_TM_LFR_HK_t housekeeping_packet; |
|
47 | Packet_TM_LFR_HK_t housekeeping_packet; | |
44 |
|
48 | |||
45 | // BASIC PARAMETERS GLOBAL VARIABLES |
|
49 | // BASIC PARAMETERS GLOBAL VARIABLES | |
46 | unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_MATRIX_f0 * 9 ]; |
|
50 | unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_MATRIX_f0 * 9 ]; | |
47 | BP1_t data_BP1[ NB_BINS_COMPRESSED_MATRIX_f0 ]; |
|
51 | BP1_t data_BP1[ NB_BINS_COMPRESSED_MATRIX_f0 ]; | |
48 |
|
52 |
This diff has been collapsed as it changes many lines, (513 lines changed) Show them Hide them | |||||
@@ -2,31 +2,31 | |||||
2 | // GPL reminder to be added |
|
2 | // GPL reminder to be added | |
3 | //************************* |
|
3 | //************************* | |
4 |
|
4 | |||
5 | #include <rtems.h> |
|
5 | #include <rtems.h> | |
|
6 | ||||
|
7 | /* configuration information */ | |||
|
8 | ||||
|
9 | #define CONFIGURE_INIT | |||
6 |
|
10 | |||
7 | /* configuration information */ |
|
|||
8 |
|
||||
9 | #define CONFIGURE_INIT |
|
|||
10 |
|
||||
11 | #include <bsp.h> /* for device driver prototypes */ |
|
11 | #include <bsp.h> /* for device driver prototypes */ | |
12 |
|
12 | |||
13 | /* configuration information */ |
|
13 | /* configuration information */ | |
14 |
|
14 | |||
15 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
15 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER | |
16 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
16 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER | |
17 |
|
17 | |||
18 |
#define CONFIGURE_MAXIMUM_TASKS |
|
18 | #define CONFIGURE_MAXIMUM_TASKS 15 | |
19 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
|
19 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE | |
20 |
#define CONFIGURE_EXTRA_TASK_STACKS |
|
20 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) | |
21 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 |
|
21 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 | |
22 |
#define CONFIGURE_INIT_TASK_PRIORITY |
|
22 | #define CONFIGURE_INIT_TASK_PRIORITY 100 | |
23 | #define CONFIGURE_MAXIMUM_DRIVERS 16 |
|
23 | #define CONFIGURE_MAXIMUM_DRIVERS 16 | |
24 | #define CONFIGURE_MAXIMUM_PERIODS 5 |
|
24 | #define CONFIGURE_MAXIMUM_PERIODS 5 | |
25 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1 |
|
25 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1 | |
26 |
|
26 | |||
27 | #include <rtems/confdefs.h> |
|
27 | #include <rtems/confdefs.h> | |
28 |
|
28 | |||
29 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ |
|
29 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ | |
30 | #ifdef RTEMS_DRVMGR_STARTUP |
|
30 | #ifdef RTEMS_DRVMGR_STARTUP | |
31 | #ifdef LEON3 |
|
31 | #ifdef LEON3 | |
32 | /* Add Timer and UART Driver */ |
|
32 | /* Add Timer and UART Driver */ | |
@@ -37,14 +37,12 | |||||
37 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART |
|
37 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART | |
38 | #endif |
|
38 | #endif | |
39 | #endif |
|
39 | #endif | |
40 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ |
|
40 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ | |
41 | #include <drvmgr/drvmgr_confdefs.h> |
|
41 | #include <drvmgr/drvmgr_confdefs.h> | |
42 | #endif |
|
42 | #endif | |
43 |
|
43 | |||
44 | #include <fsw_init.h> |
|
44 | #include <fsw_init.h> | |
45 | #include <fsw_config.c> |
|
45 | #include <fsw_config.c> | |
46 |
|
||||
47 | char *link_status(int status); |
|
|||
48 |
|
46 | |||
49 | char *lstates[6] = {"Error-reset", |
|
47 | char *lstates[6] = {"Error-reset", | |
50 | "Error-wait", |
|
48 | "Error-wait", | |
@@ -52,139 +50,168 char *lstates[6] = {"Error-reset", | |||||
52 | "Started", |
|
50 | "Started", | |
53 | "Connecting", |
|
51 | "Connecting", | |
54 | "Run" |
|
52 | "Run" | |
55 | }; |
|
53 | }; | |
56 |
|
54 | |||
57 | rtems_task Init( rtems_task_argument ignored ) |
|
55 | rtems_task Init( rtems_task_argument ignored ) | |
58 | { |
|
56 | { | |
59 | rtems_status_code status; |
|
57 | rtems_status_code status; | |
60 | rtems_isr_entry old_isr_handler; |
|
58 | rtems_isr_entry old_isr_handler; | |
61 |
|
59 | |||
62 | PRINTF("\n\n\n\n\n") |
|
60 | PRINTF("\n\n\n\n\n") | |
63 | PRINTF("***************************\n") |
|
61 | PRINTF("***************************\n") | |
64 | PRINTF("** START Flight Software **\n") |
|
62 | PRINTF("** START Flight Software **\n") | |
65 | PRINTF("***************************\n") |
|
63 | PRINTF("***************************\n") | |
66 | PRINTF("\n\n") |
|
64 | PRINTF("\n\n") | |
67 |
|
65 | |||
68 | //send_console_outputs_on_serial_port(); |
|
66 | //send_console_outputs_on_serial_port(); | |
69 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); |
|
67 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); | |
70 |
|
68 | |||
71 | initLookUpTableForCRC(); // in tc_handler.h |
|
69 | initLookUpTableForCRC(); // in tc_handler.h | |
72 | init_default_mode_parameters(); |
|
70 | init_default_mode_parameters(); | |
73 | create_message_queue(); |
|
71 | create_message_queue(); | |
74 |
|
72 | |||
75 | create_names(); |
|
73 | create_names(); | |
76 | create_all_tasks(); |
|
74 | create_all_tasks(); | |
77 | start_all_tasks(); |
|
75 | start_all_tasks(); | |
78 |
|
76 | |||
79 | grspw_timecode_callback = &timecode_irq_handler; |
|
77 | grspw_timecode_callback = &timecode_irq_handler; | |
80 |
|
78 | |||
81 | configure_spw_link(); |
|
79 | configure_spw_link(); | |
82 |
|
80 | |||
83 | init_waveforms(); |
|
81 | //**************************** | |
84 |
|
82 | // Spectral Matrices simulator | ||
85 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR, |
|
83 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR, | |
86 | IRQ_SPARC_SM, spectral_matrices_isr ); |
|
84 | IRQ_SPARC_SM, spectral_matrices_isr ); | |
87 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR, |
|
85 | ||
88 | IRQ_SPARC_WF, waveforms_isr ); |
|
86 | //********** | |
89 |
|
87 | // WAVEFORMS | ||
90 | // irq handling of the time management unit |
|
88 | // simulator | |
91 | status = rtems_interrupt_catch( commutation_isr1, |
|
89 | ||
92 | IRQ_SPARC_TIME1, |
|
90 | #ifdef GSA | |
93 | &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels |
|
91 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR, | |
94 | if (status==RTEMS_SUCCESSFUL) |
|
92 | IRQ_SPARC_WF, waveforms_simulator_isr ); | |
95 | PRINTF("OK *** commutation_isr1 *** rtems_interrupt_catch successfullly configured\n") |
|
93 | #else | |
96 |
|
94 | // configure the registers of the waveform picker | ||
97 | status = rtems_interrupt_catch( commutation_isr2, |
|
95 | init_waveform_picker_regs(); | |
98 | IRQ_SPARC_TIME2, |
|
96 | // configure the waveform picker interrupt service routine | |
99 | &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels |
|
97 | status = rtems_interrupt_catch( waveforms_isr, | |
100 | if (status==RTEMS_SUCCESSFUL) |
|
98 | IRQ_SPARC_WAVEFORM_PICKER, | |
101 | PRINTF("OK *** commutation_isr2 *** rtems_interrupt_catch successfullly configured\n") |
|
99 | &old_isr_handler) ; | |
102 |
|
100 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); | ||
103 | LEON_Unmask_interrupt( IRQ_TIME1 ); |
|
101 | #endif | |
104 | LEON_Unmask_interrupt( IRQ_TIME2 ); |
|
102 | ||
|
103 | //********** | |||
|
104 | ||||
|
105 | //***************************************** | |||
|
106 | // irq handling of the time management unit | |||
|
107 | status = rtems_interrupt_catch( commutation_isr1, | |||
|
108 | IRQ_SPARC_TIME1, | |||
|
109 | &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels | |||
|
110 | if (status==RTEMS_SUCCESSFUL) { | |||
|
111 | PRINTF("OK *** commutation_isr1 *** rtems_interrupt_catch successfullly configured\n") | |||
|
112 | } | |||
|
113 | ||||
|
114 | status = rtems_interrupt_catch( commutation_isr2, | |||
|
115 | IRQ_SPARC_TIME2, | |||
|
116 | &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels | |||
|
117 | if (status==RTEMS_SUCCESSFUL) { | |||
|
118 | PRINTF("OK *** commutation_isr2 *** rtems_interrupt_catch successfullly configured\n") | |||
|
119 | } | |||
|
120 | ||||
|
121 | LEON_Unmask_interrupt( IRQ_TIME1 ); | |||
|
122 | LEON_Unmask_interrupt( IRQ_TIME2 ); | |||
|
123 | ||||
|
124 | #ifdef GSA | |||
|
125 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |||
|
126 | printf("in INIT *** Error sending event to WFRM\n"); | |||
|
127 | } | |||
|
128 | #endif | |||
105 |
|
129 | |||
106 | status = rtems_task_delete(RTEMS_SELF); |
|
130 | status = rtems_task_delete(RTEMS_SELF); | |
|
131 | ||||
107 | } |
|
132 | } | |
108 |
|
133 | |||
109 | rtems_task spiq_task(rtems_task_argument unused) |
|
134 | rtems_task spiq_task(rtems_task_argument unused) | |
110 | { |
|
135 | { | |
111 | rtems_event_set event_out; |
|
136 | rtems_event_set event_out; | |
112 | struct grspw_regs_str *grspw_regs; |
|
137 | rtems_status_code status; | |
113 | grspw_regs = (struct grspw_regs_str *) REGS_ADDR_GRSPW; |
|
|||
114 | rtems_status_code status; |
|
|||
115 |
|
138 | |||
116 |
while( |
|
139 | while(true){ | |
117 | PRINTF("in SPIQ *** Waiting for SPW_LINKERR_EVENT\n") |
|
140 | PRINTF("in SPIQ *** Waiting for SPW_LINKERR_EVENT\n") | |
118 | rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT |
|
141 | rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT | |
119 |
|
142 | |||
120 | if (rtems_task_suspend(Task_id[TASKID_RECV])!=RTEMS_SUCCESSFUL) // suspend RECV task |
|
143 | if (rtems_task_suspend(Task_id[TASKID_RECV])!=RTEMS_SUCCESSFUL) { // suspend RECV task | |
121 | PRINTF("in SPIQ *** Error suspending RECV Task\n") |
|
144 | PRINTF("in SPIQ *** Error suspending RECV Task\n") | |
122 | if (rtems_task_suspend(Task_id[TASKID_HOUS])!=RTEMS_SUCCESSFUL) // suspend HOUS task |
|
145 | } | |
|
146 | if (rtems_task_suspend(Task_id[TASKID_HOUS])!=RTEMS_SUCCESSFUL) { // suspend HOUS task | |||
123 | PRINTF("in SPIQ *** Error suspending HOUS Task\n") |
|
147 | PRINTF("in SPIQ *** Error suspending HOUS Task\n") | |
|
148 | } | |||
124 |
|
149 | |||
125 | configure_spw_link(); |
|
150 | configure_spw_link(); | |
126 |
|
151 | |||
127 | status = rtems_task_restart( Task_id[TASKID_HOUS], 1 ); |
|
152 | status = rtems_task_restart( Task_id[TASKID_HOUS], 1 ); | |
128 | if (status!=RTEMS_SUCCESSFUL) |
|
153 | if (status!=RTEMS_SUCCESSFUL) { | |
129 | PRINTF1("in SPIQ *** Error restarting HOUS Task *** code %d\n", status) |
|
154 | PRINTF1("in SPIQ *** Error restarting HOUS Task *** code %d\n", status) | |
|
155 | } | |||
130 |
|
156 | |||
131 | if (rtems_task_restart(Task_id[TASKID_RECV], 1)!=RTEMS_SUCCESSFUL) // restart RECV task |
|
157 | if (rtems_task_restart(Task_id[TASKID_RECV], 1)!=RTEMS_SUCCESSFUL) { // restart RECV task | |
132 | PRINTF("in SPIQ *** Error restarting RECV Task\n") |
|
158 | PRINTF("in SPIQ *** Error restarting RECV Task\n") | |
|
159 | } | |||
133 | } |
|
160 | } | |
134 | } |
|
161 | } | |
135 |
|
162 | |||
136 | void init_default_mode_parameters() |
|
163 | void init_default_mode_parameters() | |
137 | { |
|
164 | { | |
138 | // COMMON PARAMETERS |
|
165 | // COMMON PARAMETERS | |
139 | param_common[0] = 0x00; |
|
166 | param_common[0] = 0x00; | |
140 | param_common[1] = 0x10; // default value 0 0 0 1 0 0 0 0 |
|
167 | param_common[1] = 0x10; // default value 0 0 0 1 0 0 0 0 | |
141 | // NORMAL MODE |
|
168 | // NORMAL MODE | |
142 | param_norm.sy_lfr_n_swf_l = 2048; // nb sample |
|
169 | param_norm.sy_lfr_n_swf_l = 2048; // nb sample | |
143 | param_norm.sy_lfr_n_swf_p = 300; // sec |
|
170 | param_norm.sy_lfr_n_swf_p = 300; // sec | |
144 | param_norm.sy_lfr_n_asm_p = 3600; // sec |
|
171 | param_norm.sy_lfr_n_asm_p = 3600; // sec | |
145 | param_norm.sy_lfr_n_bp_p0 = 4; // sec |
|
172 | param_norm.sy_lfr_n_bp_p0 = 4; // sec | |
146 | param_norm.sy_lfr_n_bp_p1 = 20; // sec |
|
173 | param_norm.sy_lfr_n_bp_p1 = 20; // sec | |
147 | // BURST MODE |
|
174 | // BURST MODE | |
148 | param_burst.sy_lfr_b_bp_p0 = 1; // sec |
|
175 | param_burst.sy_lfr_b_bp_p0 = 1; // sec | |
149 | param_burst.sy_lfr_b_bp_p1 = 5; // sec |
|
176 | param_burst.sy_lfr_b_bp_p1 = 5; // sec | |
150 | // SBM1 MODE |
|
177 | // SBM1 MODE | |
151 | param_sbm1.sy_lfr_s1_bp_p0 = 1; // sec |
|
178 | param_sbm1.sy_lfr_s1_bp_p0 = 1; // sec | |
152 | param_sbm1.sy_lfr_s1_bp_p1 = 1; // sec |
|
179 | param_sbm1.sy_lfr_s1_bp_p1 = 1; // sec | |
153 | // SBM2 MODE |
|
180 | // SBM2 MODE | |
154 | param_sbm2.sy_lfr_s2_bp_p0 = 1; // sec |
|
181 | param_sbm2.sy_lfr_s2_bp_p0 = 1; // sec | |
155 | param_sbm2.sy_lfr_s2_bp_p0 = 5; // sec |
|
182 | param_sbm2.sy_lfr_s2_bp_p0 = 5; // sec | |
156 | } |
|
183 | } | |
157 |
|
184 | |||
158 | int create_names() |
|
185 | int create_names( void ) | |
159 | { |
|
186 | { | |
160 | // task names |
|
187 | // task names | |
161 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); |
|
188 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); | |
162 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); |
|
189 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); | |
163 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); |
|
190 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); | |
164 | Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' ); |
|
191 | Task_name[TASKID_SMIQ] = rtems_build_name( 'S', 'M', 'I', 'Q' ); | |
165 | Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' ); |
|
192 | Task_name[TASKID_STAT] = rtems_build_name( 'S', 'T', 'A', 'T' ); | |
166 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); |
|
193 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); | |
167 | Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' ); |
|
194 | Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' ); | |
168 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); |
|
195 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); | |
169 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); |
|
196 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); | |
170 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
197 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); | |
171 |
|
198 | |||
172 | // rate monotonic period name |
|
199 | // rate monotonic period name | |
173 | HK_name = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
200 | HK_name = rtems_build_name( 'H', 'O', 'U', 'S' ); | |
174 |
|
201 | |||
175 | return 0; |
|
202 | return 0; | |
176 | } |
|
203 | } | |
177 |
|
204 | |||
178 | int create_all_tasks() |
|
205 | int create_all_tasks( void ) | |
179 | { |
|
206 | { | |
180 | rtems_status_code status; |
|
207 | rtems_status_code status; | |
181 |
|
208 | |||
182 | // RECV |
|
209 | // RECV | |
183 | status = rtems_task_create( |
|
210 | status = rtems_task_create( | |
184 | Task_name[TASKID_RECV], 200, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
211 | Task_name[TASKID_RECV], 200, RTEMS_MINIMUM_STACK_SIZE * 2, | |
185 | RTEMS_DEFAULT_MODES, |
|
212 | RTEMS_DEFAULT_MODES, | |
186 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] |
|
213 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] | |
187 | ); |
|
214 | ); | |
188 | // ACTN |
|
215 | // ACTN | |
189 | status = rtems_task_create( |
|
216 | status = rtems_task_create( | |
190 | Task_name[TASKID_ACTN], 50, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
217 | Task_name[TASKID_ACTN], 50, RTEMS_MINIMUM_STACK_SIZE * 2, | |
@@ -220,76 +247,96 int create_all_tasks() | |||||
220 | Task_name[TASKID_BPF0], 50, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
247 | Task_name[TASKID_BPF0], 50, RTEMS_MINIMUM_STACK_SIZE * 2, | |
221 | RTEMS_DEFAULT_MODES, |
|
248 | RTEMS_DEFAULT_MODES, | |
222 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0] |
|
249 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_BPF0] | |
223 | ); |
|
250 | ); | |
224 | // WFRM |
|
251 | // WFRM | |
225 | status = rtems_task_create( |
|
252 | status = rtems_task_create( | |
226 | Task_name[TASKID_WFRM], 100, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
253 | Task_name[TASKID_WFRM], 100, RTEMS_MINIMUM_STACK_SIZE * 2, | |
227 | RTEMS_DEFAULT_MODES, |
|
254 | RTEMS_DEFAULT_MODES, | |
228 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] |
|
255 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] | |
229 | ); |
|
256 | ); | |
230 | // DUMB |
|
257 | // DUMB | |
231 | status = rtems_task_create( |
|
258 | status = rtems_task_create( | |
232 | Task_name[TASKID_DUMB], 200, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
259 | Task_name[TASKID_DUMB], 200, RTEMS_MINIMUM_STACK_SIZE * 2, | |
233 | RTEMS_DEFAULT_MODES, |
|
260 | RTEMS_DEFAULT_MODES, | |
234 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] |
|
261 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] | |
235 | ); |
|
262 | ); | |
236 | // HOUS |
|
263 | // HOUS | |
237 | status = rtems_task_create( |
|
264 | status = rtems_task_create( | |
238 | Task_name[TASKID_HOUS], 199, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
265 | Task_name[TASKID_HOUS], 199, RTEMS_MINIMUM_STACK_SIZE * 2, | |
239 | RTEMS_DEFAULT_MODES, |
|
266 | RTEMS_DEFAULT_MODES, | |
240 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS] |
|
267 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS] | |
241 | ); |
|
268 | ); | |
242 |
|
||||
243 | return 0; |
|
|||
244 | } |
|
|||
245 |
|
||||
246 | int start_all_tasks() |
|
|||
247 | { |
|
|||
248 | rtems_status_code status; |
|
|||
249 |
|
||||
250 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); |
|
|||
251 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_SPIQ\n") |
|
|||
252 |
|
||||
253 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); |
|
|||
254 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_RECV\n") |
|
|||
255 |
|
||||
256 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); |
|
|||
257 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_ACTN\n") |
|
|||
258 |
|
||||
259 | status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 ); |
|
|||
260 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPPR\n") |
|
|||
261 |
|
269 | |||
262 | status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 ); |
|
270 | return 0; | |
263 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_STAT\n") |
|
271 | } | |
264 |
|
||||
265 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 ); |
|
|||
266 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_AVF0\n") |
|
|||
267 |
|
272 | |||
268 | status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 ); |
|
273 | int start_all_tasks( void ) | |
269 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPF0\n") |
|
|||
270 |
|
||||
271 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); |
|
|||
272 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_WFRM\n") |
|
|||
273 |
|
||||
274 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); |
|
|||
275 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_DUMB\n") |
|
|||
276 |
|
||||
277 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); |
|
|||
278 | if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_HOUS\n") |
|
|||
279 |
|
||||
280 | return 0; |
|
|||
281 | } |
|
|||
282 |
|
||||
283 | int configure_spw_link() |
|
|||
284 | { |
|
274 | { | |
285 | rtems_status_code status; |
|
275 | rtems_status_code status; | |
286 |
|
276 | |||
287 | close(fdSPW); // close the device if it is already open |
|
277 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); | |
|
278 | if (status!=RTEMS_SUCCESSFUL) { | |||
|
279 | PRINTF("In INIT *** Error starting TASK_SPIQ\n") | |||
|
280 | } | |||
|
281 | ||||
|
282 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); | |||
|
283 | if (status!=RTEMS_SUCCESSFUL) { | |||
|
284 | PRINTF("In INIT *** Error starting TASK_RECV\n") | |||
|
285 | } | |||
|
286 | ||||
|
287 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); | |||
|
288 | if (status!=RTEMS_SUCCESSFUL) { | |||
|
289 | PRINTF("In INIT *** Error starting TASK_ACTN\n") | |||
|
290 | } | |||
|
291 | ||||
|
292 | status = rtems_task_start( Task_id[TASKID_SMIQ], smiq_task, 1 ); | |||
|
293 | if (status!=RTEMS_SUCCESSFUL) { | |||
|
294 | PRINTF("In INIT *** Error starting TASK_BPPR\n") | |||
|
295 | } | |||
|
296 | ||||
|
297 | status = rtems_task_start( Task_id[TASKID_STAT], stat_task, 1 ); | |||
|
298 | if (status!=RTEMS_SUCCESSFUL) { | |||
|
299 | PRINTF("In INIT *** Error starting TASK_STAT\n") | |||
|
300 | } | |||
|
301 | ||||
|
302 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, 1 ); | |||
|
303 | if (status!=RTEMS_SUCCESSFUL) { | |||
|
304 | PRINTF("In INIT *** Error starting TASK_AVF0\n") | |||
|
305 | } | |||
|
306 | ||||
|
307 | status = rtems_task_start( Task_id[TASKID_BPF0], bpf0_task, 1 ); | |||
|
308 | if (status!=RTEMS_SUCCESSFUL) { | |||
|
309 | PRINTF("In INIT *** Error starting TASK_BPF0\n") | |||
|
310 | } | |||
|
311 | ||||
|
312 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); | |||
|
313 | if (status!=RTEMS_SUCCESSFUL) { | |||
|
314 | PRINTF("In INIT *** Error starting TASK_WFRM\n") | |||
|
315 | } | |||
|
316 | ||||
|
317 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); | |||
|
318 | if (status!=RTEMS_SUCCESSFUL) { | |||
|
319 | PRINTF("In INIT *** Error starting TASK_DUMB\n") | |||
|
320 | } | |||
|
321 | ||||
|
322 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); | |||
|
323 | if (status!=RTEMS_SUCCESSFUL) { | |||
|
324 | PRINTF("In INIT *** Error starting TASK_HOUS\n") | |||
|
325 | } | |||
|
326 | ||||
|
327 | return 0; | |||
|
328 | } | |||
|
329 | ||||
|
330 | int configure_spw_link( void ) | |||
|
331 | { | |||
|
332 | rtems_status_code status; | |||
|
333 | ||||
|
334 | close(fdSPW); // close the device if it is already open | |||
288 | PRINTF("OK *** in configure_spw_link *** try to open "GRSPW_DEVICE_NAME"\n") |
|
335 | PRINTF("OK *** in configure_spw_link *** try to open "GRSPW_DEVICE_NAME"\n") | |
289 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware |
|
336 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware | |
290 | if (fdSPW<0) PRINTF("ERR *** in configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n") |
|
337 | if (fdSPW<0) PRINTF("ERR *** in configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n") | |
291 | while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, 0) != RTEMS_SUCCESSFUL){ |
|
338 | while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, 0) != RTEMS_SUCCESSFUL){ | |
292 | PRINTF(".") |
|
339 | PRINTF(".") | |
293 | fflush(stdout); |
|
340 | fflush(stdout); | |
294 | close(fdSPW); // close the device |
|
341 | close(fdSPW); // close the device | |
295 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware |
|
342 | fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware | |
@@ -297,77 +344,71 int configure_spw_link() | |||||
297 | rtems_task_wake_after(100); |
|
344 | rtems_task_wake_after(100); | |
298 | } |
|
345 | } | |
299 |
|
346 | |||
300 | PRINTF("OK *** In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n") |
|
347 | PRINTF("OK *** In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n") | |
301 |
|
348 | |||
302 | configure_spacewire_set_NP(1, REGS_ADDR_GRSPW); // No Port force |
|
349 | configure_spacewire_set_NP(1, REGS_ADDR_GRSPW); // No Port force | |
303 | configure_spacewire_set_RE(1, REGS_ADDR_GRSPW); // the dedicated call seems to break the no port force configuration |
|
350 | configure_spacewire_set_RE(1, REGS_ADDR_GRSPW); // the dedicated call seems to break the no port force configuration | |
304 |
|
351 | |||
305 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception |
|
352 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception | |
306 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") |
|
353 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n") | |
307 | // |
|
354 | // | |
308 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a |
|
355 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a | |
309 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs |
|
356 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs | |
310 | // |
|
357 | // | |
311 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 1); // automatic link-disabling due to link-error interrupts |
|
358 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 1); // automatic link-disabling due to link-error interrupts | |
312 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") |
|
359 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n") | |
313 | // |
|
360 | // | |
314 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit |
|
361 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit | |
315 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") |
|
362 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n") | |
316 | // |
|
363 | // | |
317 |
status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, |
|
364 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 0); // transmission blocks on full | |
318 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") |
|
365 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n") | |
319 | // |
|
366 | // | |
320 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); |
|
367 | status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909); | |
321 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") |
|
368 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n") | |
322 |
|
369 | |||
323 | PRINTF("OK *** in configure_spw_link *** "GRSPW_DEVICE_NAME" configured successfully\n") |
|
370 | PRINTF("OK *** in configure_spw_link *** "GRSPW_DEVICE_NAME" configured successfully\n") | |
324 |
|
371 | |||
325 | return RTEMS_SUCCESSFUL; |
|
372 | return RTEMS_SUCCESSFUL; | |
326 | } |
|
373 | } | |
327 |
|
374 | |||
328 | void configure_spacewire_set_NP(unsigned char val, unsigned int regAddr) // No Port force |
|
375 | void configure_spacewire_set_NP(unsigned char val, unsigned int regAddr) // [N]o [P]ort force | |
329 | { |
|
376 | { | |
330 | unsigned int *spwptr; |
|
377 | unsigned int *spwptr = (unsigned int*) regAddr; | |
331 | spwptr = (unsigned int*) regAddr; |
|
378 | ||
332 | if (val == 1) |
|
379 | if (val == 1) { | |
333 | { |
|
380 | *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit | |
334 | *spwptr = *spwptr | 0x00100000; // [NP] set the No port force bit |
|
381 | } | |
335 | } |
|
382 | if (val== 0) { | |
336 | if (val== 0) |
|
383 | *spwptr = *spwptr & 0xffdfffff; | |
337 |
|
|
384 | } | |
338 | *spwptr = *spwptr & 0xffdfffff; |
|
385 | } | |
339 | } |
|
386 | ||
340 | } |
|
387 | void configure_spacewire_set_RE(unsigned char val, unsigned int regAddr) // [R]MAP [E]nable | |
341 |
|
388 | { | ||
342 | void configure_spacewire_set_RE(unsigned char val, unsigned int regAddr) // RMAP Enable |
|
389 | unsigned int *spwptr = (unsigned int*) regAddr; | |
343 | { |
|
|||
344 | unsigned int *spwptr; |
|
|||
345 | spwptr = (unsigned int*) regAddr; |
|
|||
346 | if (val == 1) |
|
|||
347 | { |
|
|||
348 | *spwptr = *spwptr | 0x00010000; // [NP] set the No port force bit |
|
|||
349 | } |
|
|||
350 | if (val== 0) |
|
|||
351 | { |
|
|||
352 | *spwptr = *spwptr & 0xfffdffff; |
|
|||
353 | } |
|
|||
354 | } |
|
|||
355 |
|
390 | |||
356 | char *link_status(int status){ |
|
391 | if (val == 1) | |
357 | return lstates[status]; |
|
392 | { | |
358 | } |
|
393 | *spwptr = *spwptr | 0x00010000; // [RE] set the RMAP Enable bit | |
359 |
|
394 | } | ||
360 | rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send) |
|
395 | if (val== 0) | |
361 | { |
|
396 | { | |
362 | rtems_status_code status; |
|
397 | *spwptr = *spwptr & 0xfffdffff; | |
363 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); |
|
398 | } | |
364 | if (status!=RTEMS_SUCCESSFUL) printf("In write_spw *** Error SPACEWIRE_IOCTRL_SEND\n"); |
|
399 | } | |
365 | return status; |
|
|||
366 | } |
|
|||
367 |
|
||||
368 | void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc) |
|
|||
369 | { |
|
|||
370 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
|||
371 | printf("In timecode_irq_handler *** Error sending event to DUMB\n"); |
|
|||
372 | } |
|
|||
373 |
|
400 | |||
|
401 | rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send) | |||
|
402 | { | |||
|
403 | rtems_status_code status; | |||
|
404 | status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send ); | |||
|
405 | return status; | |||
|
406 | } | |||
|
407 | ||||
|
408 | void timecode_irq_handler(void *pDev, void *regs, int minor, unsigned int tc) | |||
|
409 | { | |||
|
410 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_1 ) != RTEMS_SUCCESSFUL) { | |||
|
411 | printf("In timecode_irq_handler *** Error sending event to DUMB\n"); | |||
|
412 | } | |||
|
413 | } | |||
|
414 |
@@ -45,11 +45,10 void print_statistics(spw_stats *stats) | |||||
45 | printf("Packets received: %i\n", stats->packets_received); |
|
45 | printf("Packets received: %i\n", stats->packets_received); | |
46 | } |
|
46 | } | |
47 |
|
47 | |||
48 | int send_console_outputs_on_serial_port() // Send the console outputs on the serial port |
|
48 | int send_console_outputs_on_serial_port( void ) // Send the console outputs on the serial port | |
49 | { |
|
49 | { | |
50 | struct apbuart_regs_str *apbuart_regs; |
|
50 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; | |
51 |
|
51 | |||
52 | apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; |
|
|||
53 | apbuart_regs->ctrl = apbuart_regs->ctrl & APBUART_CTRL_REG_MASK_DB; |
|
52 | apbuart_regs->ctrl = apbuart_regs->ctrl & APBUART_CTRL_REG_MASK_DB; | |
54 | PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") |
|
53 | PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") | |
55 |
|
54 | |||
@@ -58,9 +57,8 int send_console_outputs_on_serial_port( | |||||
58 |
|
57 | |||
59 | int set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value) |
|
58 | int set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value) | |
60 | { |
|
59 | { | |
61 | struct apbuart_regs_str *apbuart_regs; |
|
60 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs; | |
62 |
|
61 | |||
63 | apbuart_regs = (struct apbuart_regs_str *) regs; |
|
|||
64 | apbuart_regs->scaler = value; |
|
62 | apbuart_regs->scaler = value; | |
65 | PRINTF1("OK *** COM port scaler reload register set to %x\n", value) |
|
63 | PRINTF1("OK *** COM port scaler reload register set to %x\n", value) | |
66 |
|
64 | |||
@@ -94,16 +92,16 rtems_task stat_task(rtems_task_argument | |||||
94 |
|
92 | |||
95 | rtems_task hous_task(rtems_task_argument argument) |
|
93 | rtems_task hous_task(rtems_task_argument argument) | |
96 | { |
|
94 | { | |
|
95 | int result; | |||
|
96 | rtems_status_code status; | |||
|
97 | ||||
97 | PRINTF("in HOUS ***\n") |
|
98 | PRINTF("in HOUS ***\n") | |
98 |
|
99 | |||
99 | int result; |
|
100 | if (rtems_rate_monotonic_ident( HK_name, &HK_id)!=RTEMS_SUCCESSFUL) { | |
100 | rtems_status_code status; |
|
|||
101 |
|
||||
102 | if (rtems_rate_monotonic_ident( HK_name, &HK_id)!=RTEMS_SUCCESSFUL) |
|
|||
103 | { |
|
|||
104 | status = rtems_rate_monotonic_create( HK_name, &HK_id ); |
|
101 | status = rtems_rate_monotonic_create( HK_name, &HK_id ); | |
105 | if( status != RTEMS_SUCCESSFUL ) |
|
102 | if( status != RTEMS_SUCCESSFUL ) { | |
106 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ) |
|
103 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ) | |
|
104 | } | |||
107 | } |
|
105 | } | |
108 |
|
106 | |||
109 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
107 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
@@ -1,73 +1,15 | |||||
1 | #include <fsw_processing.h> |
|
1 | #include <fsw_processing.h> | |
2 | #include <math.h> |
|
2 | #include <math.h> | |
3 | #include <stdio.h> |
|
|||
4 | #include <stdlib.h> |
|
|||
5 | #include <leon.h> |
|
|||
6 |
|
3 | |||
7 | // TOTAL = 32 coefficients * 4 = 128 octets * 3 * 12 = 4608 octets |
|
4 | #include <fsw_processing_globals.c> | |
8 | // SX 12 coefficients |
|
|||
9 | float k14_sx_re = 1; |
|
|||
10 | float k14_sx_im = 1; |
|
|||
11 | float k15_sx_re = 1; |
|
|||
12 | float k15_sx_im = 1; |
|
|||
13 | float k24_sx_re = 1; |
|
|||
14 | float k24_sx_im = 1; |
|
|||
15 | float k25_sx_re = 1; |
|
|||
16 | float k25_sx_im = 1; |
|
|||
17 | float k34_sx_re = 1; |
|
|||
18 | float k34_sx_im = 1; |
|
|||
19 | float k35_sx_re = 1; |
|
|||
20 | float k35_sx_im = 1; |
|
|||
21 | // NY 8 coefficients |
|
|||
22 | float k24_ny_re = 1; |
|
|||
23 | float k24_ny_im = 1; |
|
|||
24 | float k25_ny_re = 1; |
|
|||
25 | float k25_ny_im = 1; |
|
|||
26 | float k34_ny_re = 1; |
|
|||
27 | float k34_ny_im = 1; |
|
|||
28 | float k35_ny_re = 1; |
|
|||
29 | float k35_ny_im = 1; |
|
|||
30 | // NZ 8 coefficients |
|
|||
31 | float k24_nz_re = 1; |
|
|||
32 | float k24_nz_im = 1; |
|
|||
33 | float k25_nz_re = 1; |
|
|||
34 | float k25_nz_im = 1; |
|
|||
35 | float k34_nz_re = 1; |
|
|||
36 | float k34_nz_im = 1; |
|
|||
37 | float k35_nz_re = 1; |
|
|||
38 | float k35_nz_im = 1; |
|
|||
39 | // PE 4 coefficients |
|
|||
40 | float k44_pe = 1; |
|
|||
41 | float k55_pe = 1; |
|
|||
42 | float k45_pe_re = 1; |
|
|||
43 | float k45_pe_im = 1; |
|
|||
44 |
|
||||
45 | float alpha_M = M_PI/4; |
|
|||
46 |
|
||||
47 | extern volatile int spec_mat_f0_a[ ]; |
|
|||
48 | extern volatile int spec_mat_f0_b[ ]; |
|
|||
49 | extern volatile int spec_mat_f0_c[ ]; |
|
|||
50 | extern volatile int spec_mat_f0_d[ ]; |
|
|||
51 | extern volatile int spec_mat_f0_e[ ]; |
|
|||
52 | extern volatile int spec_mat_f0_f[ ]; |
|
|||
53 | extern volatile int spec_mat_f0_g[ ]; |
|
|||
54 | extern volatile int spec_mat_f0_h[ ]; |
|
|||
55 | extern float averaged_spec_mat_f0[ ]; |
|
|||
56 | extern float compressed_spec_mat_f0[ ]; |
|
|||
57 | extern unsigned char LFR_BP1_F0[ ]; |
|
|||
58 |
|
||||
59 | extern BP1_t data_BP1[ ]; |
|
|||
60 |
|
||||
61 | extern rtems_id Task_id[ ]; /* array of task ids */ |
|
|||
62 |
|
||||
63 | spectral_matrices_regs_t *spectral_matrices_regs; |
|
|||
64 |
|
5 | |||
65 | //*********************************************************** |
|
6 | //*********************************************************** | |
66 | // Interrupt Service Routine for spectral matrices processing |
|
7 | // Interrupt Service Routine for spectral matrices processing | |
67 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ) |
|
8 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ) | |
68 | { |
|
9 | { | |
69 | if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
10 | if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
70 | printf("in spectral_matrices_isr *** Error sending event to AVF0\n"); |
|
11 | printf("in spectral_matrices_isr *** Error sending event to AVF0\n"); | |
|
12 | } | |||
71 | } |
|
13 | } | |
72 |
|
14 | |||
73 | //************ |
|
15 | //************ | |
@@ -75,8 +17,6 rtems_isr spectral_matrices_isr( rtems_v | |||||
75 | rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ |
|
17 | rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ | |
76 | { |
|
18 | { | |
77 | rtems_event_set event_out; |
|
19 | rtems_event_set event_out; | |
78 | gptimer_regs_t *gptimer_regs; |
|
|||
79 | gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER; |
|
|||
80 | unsigned char nb_interrupt_f0 = 0; |
|
20 | unsigned char nb_interrupt_f0 = 0; | |
81 |
|
21 | |||
82 | PRINTF("in SMIQ *** \n") |
|
22 | PRINTF("in SMIQ *** \n") | |
@@ -96,37 +36,35 rtems_task spw_bppr_task(rtems_task_argu | |||||
96 | { |
|
36 | { | |
97 | rtems_status_code status; |
|
37 | rtems_status_code status; | |
98 | rtems_event_set event_out; |
|
38 | rtems_event_set event_out; | |
99 |
static int |
|
39 | static int Nb_average_f0 = 0; | |
100 | //static int nb_average_f1 = 0; |
|
40 | //static int nb_average_f1 = 0; | |
101 | //static int nb_average_f2 = 0; |
|
41 | //static int nb_average_f2 = 0; | |
102 |
|
42 | |||
103 | while(1) |
|
|||
104 |
|
||||
105 | spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES; |
|
43 | spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES; | |
106 | spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a; |
|
44 | spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a; | |
107 | spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b; |
|
45 | spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b; | |
108 |
|
46 | |||
109 | printf("in BPPR ***\n"); |
|
47 | printf("in BPPR ***\n"); | |
110 |
|
48 | |||
111 |
while( |
|
49 | while(true){ // wait for an event to begin with the processing | |
112 | status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); |
|
50 | status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); | |
113 | if (status == RTEMS_SUCCESSFUL){ |
|
51 | if (status == RTEMS_SUCCESSFUL) { | |
114 | if ((spectral_matrices_regs->ctrl & 0x00000001)==1){ |
|
52 | if ((spectral_matrices_regs->ctrl & 0x00000001)==1) { | |
115 | matrix_average(spec_mat_f0_a, averaged_spec_mat_f0); |
|
53 | matrix_average(spec_mat_f0_a, averaged_spec_mat_f0); | |
116 | spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe; |
|
54 | spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe; | |
117 | //printf("f0_a\n"); |
|
55 | //printf("f0_a\n"); | |
118 |
|
|
56 | Nb_average_f0++; | |
119 | } |
|
57 | } | |
120 | if (((spectral_matrices_regs->ctrl>>1) & 0x00000001)==1){ |
|
58 | if (((spectral_matrices_regs->ctrl>>1) & 0x00000001)==1) { | |
121 | matrix_average(spec_mat_f0_b, compressed_spec_mat_f0); |
|
59 | matrix_average(spec_mat_f0_b, compressed_spec_mat_f0); | |
122 | spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffd; |
|
60 | spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffd; | |
123 | //printf("f0_b\n"); |
|
61 | //printf("f0_b\n"); | |
124 |
|
|
62 | Nb_average_f0++; | |
125 | } |
|
63 | } | |
126 |
if ( |
|
64 | if (Nb_average_f0 == NB_AVERAGE_NORMAL_f0) { | |
127 | matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0); |
|
65 | matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0); | |
128 | //printf("f0 compressed\n"); |
|
66 | //printf("f0 compressed\n"); | |
129 |
|
|
67 | Nb_average_f0 = 0; | |
130 | matrix_reset(averaged_spec_mat_f0); |
|
68 | matrix_reset(averaged_spec_mat_f0); | |
131 | } |
|
69 | } | |
132 | } |
|
70 | } | |
@@ -164,7 +102,9 rtems_task avf0_task(rtems_task_argument | |||||
164 | if (nb_average == NB_AVERAGE_NORMAL_f0) { |
|
102 | if (nb_average == NB_AVERAGE_NORMAL_f0) { | |
165 | nb_average = 0; |
|
103 | nb_average = 0; | |
166 | status = rtems_event_send( Task_id[7], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0 |
|
104 | status = rtems_event_send( Task_id[7], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0 | |
167 | if (status != RTEMS_SUCCESSFUL) printf("iN TASK AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status); |
|
105 | if (status != RTEMS_SUCCESSFUL) { | |
|
106 | printf("iN TASK AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status); | |||
|
107 | } | |||
168 | } |
|
108 | } | |
169 | } |
|
109 | } | |
170 | } |
|
110 | } | |
@@ -209,11 +149,12 void matrix_reset(float *averaged_spec_m | |||||
209 |
|
149 | |||
210 | void matrix_compression(float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat) |
|
150 | void matrix_compression(float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat) | |
211 | { |
|
151 | { | |
212 |
int i |
|
152 | int i; | |
|
153 | int j; | |||
213 | switch (fChannel){ |
|
154 | switch (fChannel){ | |
214 | case 0: |
|
155 | case 0: | |
215 | for(i=0;i<NB_BINS_COMPRESSED_MATRIX_f0;i++){ |
|
156 | for(i=0;i<NB_BINS_COMPRESSED_MATRIX_f0;i++){ | |
216 | j = 17 + i * 8; |
|
157 | j = 17 + (i * 8); | |
217 | compressed_spec_mat[i] = (averaged_spec_mat[j] |
|
158 | compressed_spec_mat[i] = (averaged_spec_mat[j] | |
218 | + averaged_spec_mat[j+1] |
|
159 | + averaged_spec_mat[j+1] | |
219 | + averaged_spec_mat[j+2] |
|
160 | + averaged_spec_mat[j+2] | |
@@ -236,53 +177,61 void matrix_compression(float *averaged_ | |||||
236 | } |
|
177 | } | |
237 |
|
178 | |||
238 | void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){ |
|
179 | void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){ | |
239 |
int i |
|
180 | int i; | |
|
181 | int j; | |||
240 | unsigned char tmp_u_char; |
|
182 | unsigned char tmp_u_char; | |
241 | unsigned char * pt_char; |
|
183 | unsigned char * pt_char = NULL; | |
242 | float PSDB, PSDE; |
|
184 | float PSDB, PSDE; | |
243 |
float NVEC_V0 |
|
185 | float NVEC_V0; | |
|
186 | float NVEC_V1; | |||
|
187 | float NVEC_V2; | |||
244 | //float significand; |
|
188 | //float significand; | |
245 | //int exponent; |
|
189 | //int exponent; | |
246 |
float aux |
|
190 | float aux; | |
247 |
float |
|
191 | float tr_SB_SB; | |
248 | float nebx_re = 0, nebx_im = 0; |
|
192 | float tmp; | |
249 | float ny = 0, nz = 0; |
|
193 | float sx_re; | |
|
194 | float sx_im; | |||
|
195 | float nebx_re = 0; | |||
|
196 | float nebx_im = 0; | |||
|
197 | float ny = 0; | |||
|
198 | float nz = 0; | |||
250 | float bx_bx_star = 0; |
|
199 | float bx_bx_star = 0; | |
251 | for(i=0; i<nb_bins_compressed_spec_mat; i++){ |
|
200 | for(i=0; i<nb_bins_compressed_spec_mat; i++){ | |
252 | //============================================== |
|
201 | //============================================== | |
253 | // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits |
|
202 | // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits | |
254 | PSDB = compressed_spec_mat[i*30] // S11 |
|
203 | PSDB = compressed_spec_mat[i*30] // S11 | |
255 | + compressed_spec_mat[i*30+10] // S22 |
|
204 | + compressed_spec_mat[(i*30) + 10] // S22 | |
256 | + compressed_spec_mat[i*30+18]; // S33 |
|
205 | + compressed_spec_mat[(i*30) + 18]; // S33 | |
257 | //significand = frexp(PSDB, &exponent); |
|
206 | //significand = frexp(PSDB, &exponent); | |
258 | pt_char = (unsigned char*) &PSDB; |
|
207 | pt_char = (unsigned char*) &PSDB; | |
259 | LFR_BP1[i*9+2] = pt_char[0]; // bits 31 downto 24 of the float |
|
208 | LFR_BP1[(i*9) + 2] = pt_char[0]; // bits 31 downto 24 of the float | |
260 | LFR_BP1[i*9+3] = pt_char[1]; // bits 23 downto 16 of the float |
|
209 | LFR_BP1[(i*9) + 3] = pt_char[1]; // bits 23 downto 16 of the float | |
261 | //============================================== |
|
210 | //============================================== | |
262 | // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits |
|
211 | // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits | |
263 |
PSDE = compressed_spec_mat[i*30+24] * |
|
212 | PSDE = compressed_spec_mat[(i*30) + 24] * K44_pe // S44 | |
264 |
+ compressed_spec_mat[i*30+28] * |
|
213 | + compressed_spec_mat[(i*30) + 28] * K55_pe // S55 | |
265 |
+ compressed_spec_mat[i*30+26] * |
|
214 | + compressed_spec_mat[(i*30) + 26] * K45_pe_re // S45 | |
266 |
- compressed_spec_mat[i*30+27] * |
|
215 | - compressed_spec_mat[(i*30) + 27] * K45_pe_im; // S45 | |
267 | pt_char = (unsigned char*) &PSDE; |
|
216 | pt_char = (unsigned char*) &PSDE; | |
268 | LFR_BP1[i*9+0] = pt_char[0]; // bits 31 downto 24 of the float |
|
217 | LFR_BP1[(i*9) + 0] = pt_char[0]; // bits 31 downto 24 of the float | |
269 | LFR_BP1[i*9+1] = pt_char[1]; // bits 23 downto 16 of the float |
|
218 | LFR_BP1[(i*9) + 1] = pt_char[1]; // bits 23 downto 16 of the float | |
270 | //============================================================================== |
|
219 | //============================================================================== | |
271 | // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits |
|
220 | // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits | |
272 | // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits |
|
221 | // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits | |
273 | // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits |
|
222 | // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits | |
274 | tmp = sqrt( |
|
223 | tmp = sqrt( | |
275 | compressed_spec_mat[i*30+3]*compressed_spec_mat[i*30+3] //Im S12 |
|
224 | compressed_spec_mat[(i*30) + 3]*compressed_spec_mat[(i*30) + 3] //Im S12 | |
276 | +compressed_spec_mat[i*30+5]*compressed_spec_mat[i*30+5] //Im S13 |
|
225 | +compressed_spec_mat[(i*30) + 5]*compressed_spec_mat[(i*30) + 5] //Im S13 | |
277 | +compressed_spec_mat[i*30+13]*compressed_spec_mat[i*30+13] //Im S23 |
|
226 | +compressed_spec_mat[(i*30) + 13]*compressed_spec_mat[(i*30) + 13] //Im S23 | |
278 | ); |
|
227 | ); | |
279 | NVEC_V0 = compressed_spec_mat[i*30+13] / tmp; // Im S23 |
|
228 | NVEC_V0 = compressed_spec_mat[(i*30) + 13] / tmp; // Im S23 | |
280 | NVEC_V1 = -compressed_spec_mat[i*30+5] / tmp; // Im S13 |
|
229 | NVEC_V1 = -compressed_spec_mat[(i*30) + 5] / tmp; // Im S13 | |
281 | NVEC_V2 = compressed_spec_mat[i*30+3] / tmp; // Im S12 |
|
230 | NVEC_V2 = compressed_spec_mat[(i*30) + 3] / tmp; // Im S12 | |
282 | LFR_BP1[i*9+4] = (char) (NVEC_V0*127); |
|
231 | LFR_BP1[(i*9) + 4] = (char) (NVEC_V0*127); | |
283 | LFR_BP1[i*9+5] = (char) (NVEC_V1*127); |
|
232 | LFR_BP1[(i*9) + 5] = (char) (NVEC_V1*127); | |
284 | pt_char = (unsigned char*) &NVEC_V2; |
|
233 | pt_char = (unsigned char*) &NVEC_V2; | |
285 | LFR_BP1[i*9+6] = pt_char[0] & 0x80; // extract the sign of NVEC_V2 |
|
234 | LFR_BP1[(i*9) + 6] = pt_char[0] & 0x80; // extract the sign of NVEC_V2 | |
286 | //======================================================= |
|
235 | //======================================================= | |
287 | // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits |
|
236 | // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits | |
288 | aux = 2*tmp / PSDB; // compute the ellipticity |
|
237 | aux = 2*tmp / PSDB; // compute the ellipticity | |
@@ -292,115 +241,121 void BP1_set(float * compressed_spec_mat | |||||
292 | // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits |
|
241 | // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits | |
293 | for(j = 0; j<NB_VALUES_PER_spec_mat;j++){ |
|
242 | for(j = 0; j<NB_VALUES_PER_spec_mat;j++){ | |
294 | tr_SB_SB = compressed_spec_mat[i*30] * compressed_spec_mat[i*30] |
|
243 | tr_SB_SB = compressed_spec_mat[i*30] * compressed_spec_mat[i*30] | |
295 | + compressed_spec_mat[i*30+10] * compressed_spec_mat[i*30+10] |
|
244 | + compressed_spec_mat[(i*30) + 10] * compressed_spec_mat[(i*30) + 10] | |
296 | + compressed_spec_mat[i*30+18] * compressed_spec_mat[i*30+18] |
|
245 | + compressed_spec_mat[(i*30) + 18] * compressed_spec_mat[(i*30) + 18] | |
297 | + 2 * compressed_spec_mat[i*30+2] * compressed_spec_mat[i*30+2] |
|
246 | + 2 * compressed_spec_mat[(i*30) + 2] * compressed_spec_mat[(i*30) + 2] | |
298 | + 2 * compressed_spec_mat[i*30+3] * compressed_spec_mat[i*30+3] |
|
247 | + 2 * compressed_spec_mat[(i*30) + 3] * compressed_spec_mat[(i*30) + 3] | |
299 | + 2 * compressed_spec_mat[i*30+4] * compressed_spec_mat[i*30+4] |
|
248 | + 2 * compressed_spec_mat[(i*30) + 4] * compressed_spec_mat[(i*30) + 4] | |
300 | + 2 * compressed_spec_mat[i*30+5] * compressed_spec_mat[i*30+5] |
|
249 | + 2 * compressed_spec_mat[(i*30) + 5] * compressed_spec_mat[(i*30) + 5] | |
301 | + 2 * compressed_spec_mat[i*30+12] * compressed_spec_mat[i*30+12] |
|
250 | + 2 * compressed_spec_mat[(i*30) + 12] * compressed_spec_mat[(i*30) + 12] | |
302 | + 2 * compressed_spec_mat[i*30+13] * compressed_spec_mat[i*30+13]; |
|
251 | + 2 * compressed_spec_mat[(i*30) + 13] * compressed_spec_mat[(i*30) + 13]; | |
303 | } |
|
252 | } | |
304 | aux = PSDB*PSDB; |
|
253 | aux = PSDB*PSDB; | |
305 | tmp = sqrt( abs( ( 3*tr_SB_SB - aux ) / ( 2 * aux ) ) ); |
|
254 | tmp = sqrt( abs( ( 3*tr_SB_SB - aux ) / ( 2 * aux ) ) ); | |
306 | tmp_u_char = (unsigned char) (NVEC_V0*(8-1)); |
|
255 | tmp_u_char = (unsigned char) (NVEC_V0*(8-1)); | |
307 | LFR_BP1[i*9+6] = LFR_BP1[i*9+6] | (tmp_u_char & 0x07); // keeps 3 bits of the resulting unsigned char |
|
256 | LFR_BP1[(i*9) + 6] = LFR_BP1[(i*9) + 6] | (tmp_u_char & 0x07); // keeps 3 bits of the resulting unsigned char | |
308 | //======================================================================================= |
|
257 | //======================================================================================= | |
309 | // BP1 x-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1) |
|
258 | // BP1 x-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1) | |
310 |
sx_re = compressed_spec_mat[i*30+20] * |
|
259 | sx_re = compressed_spec_mat[(i*30) + 20] * K34_sx_re | |
311 |
+ compressed_spec_mat[i*30+6] * |
|
260 | + compressed_spec_mat[(i*30) + 6] * K14_sx_re | |
312 |
+ compressed_spec_mat[i*30+8] * |
|
261 | + compressed_spec_mat[(i*30) + 8] * K15_sx_re | |
313 |
+ compressed_spec_mat[i*30+14] * |
|
262 | + compressed_spec_mat[(i*30) + 14] * K24_sx_re | |
314 |
+ compressed_spec_mat[i*30+16] * |
|
263 | + compressed_spec_mat[(i*30) + 16] * K25_sx_re | |
315 |
+ compressed_spec_mat[i*30+22] * |
|
264 | + compressed_spec_mat[(i*30) + 22] * K35_sx_re; | |
316 |
sx_im = compressed_spec_mat[i*30+21] * |
|
265 | sx_im = compressed_spec_mat[(i*30) + 21] * K34_sx_im | |
317 |
+ compressed_spec_mat[i*30+7] * |
|
266 | + compressed_spec_mat[(i*30) + 7] * K14_sx_im | |
318 |
+ compressed_spec_mat[i*30+9] * |
|
267 | + compressed_spec_mat[(i*30) + 9] * K15_sx_im | |
319 |
+ compressed_spec_mat[i*30+15] * |
|
268 | + compressed_spec_mat[(i*30) + 15] * K24_sx_im | |
320 |
+ compressed_spec_mat[i*30+17] * |
|
269 | + compressed_spec_mat[(i*30) + 17] * K25_sx_im | |
321 |
+ compressed_spec_mat[i*30+23] * |
|
270 | + compressed_spec_mat[(i*30) + 23] * K35_sx_im; | |
322 | LFR_BP1[i*9+7] = ((unsigned char) (sx_re * 128)) & 0x7f; // cf DOC for the compression |
|
271 | LFR_BP1[(i*9) + 7] = ((unsigned char) (sx_re * 128)) & 0x7f; // cf DOC for the compression | |
323 | if ( abs(sx_re) > abs(sx_im) ) |
|
272 | if ( abs(sx_re) > abs(sx_im) ) { | |
324 | LFR_BP1[i*9+7] = LFR_BP1[i*9+1] | (0x80); // extract the sector of sx |
|
273 | LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] | (0x80); // extract the sector of sx | |
325 |
|
|
274 | } | |
326 | LFR_BP1[i*9+7] = LFR_BP1[i*9+1] & (0x7f); // extract the sector of sx |
|
275 | else { | |
|
276 | LFR_BP1[(i*9) + 7] = LFR_BP1[(i*9) + 1] & (0x7f); // extract the sector of sx | |||
|
277 | } | |||
327 | //====================================================================== |
|
278 | //====================================================================== | |
328 | // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1) |
|
279 | // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1) | |
329 |
ny = sin( |
|
280 | ny = sin(Alpha_M)*NVEC_V1 + cos(Alpha_M)*NVEC_V2; | |
330 | nz = NVEC_V0; |
|
281 | nz = NVEC_V0; | |
331 |
bx_bx_star = cos( |
|
282 | bx_bx_star = cos(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+10] // re S22 | |
332 |
+ sin( |
|
283 | + sin(Alpha_M) * sin(Alpha_M) * compressed_spec_mat[i*30+18] // re S33 | |
333 |
- 2 * sin( |
|
284 | - 2 * sin(Alpha_M) * cos(Alpha_M) * compressed_spec_mat[i*30+12]; // re S23 | |
334 |
nebx_re = ny * (compressed_spec_mat[i*30+14] * |
|
285 | nebx_re = ny * (compressed_spec_mat[(i*30) + 14] * K24_ny_re | |
335 |
+compressed_spec_mat[i*30+16] * |
|
286 | +compressed_spec_mat[(i*30) + 16] * K25_ny_re | |
336 |
+compressed_spec_mat[i*30+20] * |
|
287 | +compressed_spec_mat[(i*30) + 20] * K34_ny_re | |
337 |
+compressed_spec_mat[i*30+22] * |
|
288 | +compressed_spec_mat[(i*30) + 22] * K35_ny_re) | |
338 |
+ nz * (compressed_spec_mat[i*30+14] * |
|
289 | + nz * (compressed_spec_mat[(i*30) + 14] * K24_nz_re | |
339 |
+compressed_spec_mat[i*30+16] * |
|
290 | +compressed_spec_mat[(i*30) + 16] * K25_nz_re | |
340 |
+compressed_spec_mat[i*30+20] * |
|
291 | +compressed_spec_mat[(i*30) + 20] * K34_nz_re | |
341 |
+compressed_spec_mat[i*30+22] * |
|
292 | +compressed_spec_mat[(i*30) + 22] * K35_nz_re); | |
342 |
nebx_im = ny * (compressed_spec_mat[i*30+15]* |
|
293 | nebx_im = ny * (compressed_spec_mat[(i*30) + 15]*K24_ny_re | |
343 |
+compressed_spec_mat[i*30+17] * |
|
294 | +compressed_spec_mat[(i*30) + 17] * K25_ny_re | |
344 |
+compressed_spec_mat[i*30+21] * |
|
295 | +compressed_spec_mat[(i*30) + 21] * K34_ny_re | |
345 |
+compressed_spec_mat[i*30+23] * |
|
296 | +compressed_spec_mat[(i*30) + 23] * K35_ny_re) | |
346 |
+ nz * (compressed_spec_mat[i*30+15] * |
|
297 | + nz * (compressed_spec_mat[(i*30) + 15] * K24_nz_im | |
347 |
+compressed_spec_mat[i*30+17] * |
|
298 | +compressed_spec_mat[(i*30) + 17] * K25_nz_im | |
348 |
+compressed_spec_mat[i*30+21] * |
|
299 | +compressed_spec_mat[(i*30) + 21] * K34_nz_im | |
349 |
+compressed_spec_mat[i*30+23] * |
|
300 | +compressed_spec_mat[(i*30) + 23] * K35_nz_im); | |
350 | tmp = nebx_re / bx_bx_star; |
|
301 | tmp = nebx_re / bx_bx_star; | |
351 | LFR_BP1[i*9+8] = ((unsigned char) (tmp * 128)) & 0x7f; // cf DOC for the compression |
|
302 | LFR_BP1[(i*9) + 8] = ((unsigned char) (tmp * 128)) & 0x7f; // cf DOC for the compression | |
352 | if ( abs(nebx_re) > abs(nebx_im) ) |
|
303 | if ( abs(nebx_re) > abs(nebx_im) ) { | |
353 | LFR_BP1[i*9+8] = LFR_BP1[i*9+8] | (0x80); // extract the sector of nebx |
|
304 | LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] | (0x80); // extract the sector of nebx | |
354 |
|
|
305 | } | |
355 | LFR_BP1[i*9+8] = LFR_BP1[i*9+8] & (0x7f); // extract the sector of nebx |
|
306 | else { | |
|
307 | LFR_BP1[(i*9) + 8] = LFR_BP1[(i*9) + 8] & (0x7f); // extract the sector of nebx | |||
|
308 | } | |||
356 | } |
|
309 | } | |
357 |
|
310 | |||
358 | } |
|
311 | } | |
359 |
|
312 | |||
360 | void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){ |
|
313 | void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){ | |
361 | // BP2 autocorrelation |
|
314 | // BP2 autocorrelation | |
362 |
int i |
|
315 | int i; | |
|
316 | int aux = 0; | |||
|
317 | ||||
363 | for(i = 0; i<nb_bins_compressed_spec_mat; i++){ |
|
318 | for(i = 0; i<nb_bins_compressed_spec_mat; i++){ | |
364 | // S12 |
|
319 | // S12 | |
365 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+10]); |
|
320 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 10]); | |
366 | compressed_spec_mat[i*30+2] = compressed_spec_mat[i*30+2] / aux; |
|
321 | compressed_spec_mat[(i*30) + 2] = compressed_spec_mat[(i*30) + 2] / aux; | |
367 | compressed_spec_mat[i*30+3] = compressed_spec_mat[i*30+3] / aux; |
|
322 | compressed_spec_mat[(i*30) + 3] = compressed_spec_mat[(i*30) + 3] / aux; | |
368 | // S13 |
|
323 | // S13 | |
369 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+18]); |
|
324 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 18]); | |
370 | compressed_spec_mat[i*30+4] = compressed_spec_mat[i*30+4] / aux; |
|
325 | compressed_spec_mat[(i*30) + 4] = compressed_spec_mat[(i*30) + 4] / aux; | |
371 | compressed_spec_mat[i*30+5] = compressed_spec_mat[i*30+5] / aux; |
|
326 | compressed_spec_mat[(i*30) + 5] = compressed_spec_mat[(i*30) + 5] / aux; | |
372 | // S23 |
|
327 | // S23 | |
373 | aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[i*30+18]); |
|
328 | aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[(i*30) + 18]); | |
374 | compressed_spec_mat[i*30+12] = compressed_spec_mat[i*30+12] / aux; |
|
329 | compressed_spec_mat[(i*30) + 12] = compressed_spec_mat[(i*30) + 12] / aux; | |
375 | compressed_spec_mat[i*30+13] = compressed_spec_mat[i*30+13] / aux; |
|
330 | compressed_spec_mat[(i*30) + 13] = compressed_spec_mat[(i*30) + 13] / aux; | |
376 | // S45 |
|
331 | // S45 | |
377 | aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[i*30+28]); |
|
332 | aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[(i*30) + 28]); | |
378 | compressed_spec_mat[i*30+26] = compressed_spec_mat[i*30+26] / aux; |
|
333 | compressed_spec_mat[(i*30) + 26] = compressed_spec_mat[(i*30) + 26] / aux; | |
379 | compressed_spec_mat[i*30+27] = compressed_spec_mat[i*30+27] / aux; |
|
334 | compressed_spec_mat[(i*30) + 27] = compressed_spec_mat[(i*30) + 27] / aux; | |
380 | // S14 |
|
335 | // S14 | |
381 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+24]); |
|
336 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) +24]); | |
382 | compressed_spec_mat[i*30+6] = compressed_spec_mat[i*30+6] / aux; |
|
337 | compressed_spec_mat[(i*30) + 6] = compressed_spec_mat[(i*30) + 6] / aux; | |
383 | compressed_spec_mat[i*30+7] = compressed_spec_mat[i*30+7] / aux; |
|
338 | compressed_spec_mat[(i*30) + 7] = compressed_spec_mat[(i*30) + 7] / aux; | |
384 | // S15 |
|
339 | // S15 | |
385 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+28]); |
|
340 | aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[(i*30) + 28]); | |
386 | compressed_spec_mat[i*30+8] = compressed_spec_mat[i*30+8] / aux; |
|
341 | compressed_spec_mat[(i*30) + 8] = compressed_spec_mat[(i*30) + 8] / aux; | |
387 | compressed_spec_mat[i*30+9] = compressed_spec_mat[i*30+9] / aux; |
|
342 | compressed_spec_mat[(i*30) + 9] = compressed_spec_mat[(i*30) + 9] / aux; | |
388 | // S24 |
|
343 | // S24 | |
389 | aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[i*30+24]); |
|
344 | aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 24]); | |
390 | compressed_spec_mat[i*30+14] = compressed_spec_mat[i*30+14] / aux; |
|
345 | compressed_spec_mat[(i*30) + 14] = compressed_spec_mat[(i*30) + 14] / aux; | |
391 | compressed_spec_mat[i*30+15] = compressed_spec_mat[i*30+15] / aux; |
|
346 | compressed_spec_mat[(i*30) + 15] = compressed_spec_mat[(i*30) + 15] / aux; | |
392 | // S25 |
|
347 | // S25 | |
393 | aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[i*30+28]); |
|
348 | aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[(i*30) + 28]); | |
394 | compressed_spec_mat[i*30+16] = compressed_spec_mat[i*30+16] / aux; |
|
349 | compressed_spec_mat[(i*30) + 16] = compressed_spec_mat[(i*30) + 16] / aux; | |
395 | compressed_spec_mat[i*30+17] = compressed_spec_mat[i*30+17] / aux; |
|
350 | compressed_spec_mat[(i*30) + 17] = compressed_spec_mat[(i*30) + 17] / aux; | |
396 | // S34 |
|
351 | // S34 | |
397 | aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[i*30+24]); |
|
352 | aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 24]); | |
398 | compressed_spec_mat[i*30+20] = compressed_spec_mat[i*30+20] / aux; |
|
353 | compressed_spec_mat[(i*30) + 20] = compressed_spec_mat[(i*30) + 20] / aux; | |
399 | compressed_spec_mat[i*30+21] = compressed_spec_mat[i*30+21] / aux; |
|
354 | compressed_spec_mat[(i*30) + 21] = compressed_spec_mat[(i*30) + 21] / aux; | |
400 | // S35 |
|
355 | // S35 | |
401 | aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[i*30+28]); |
|
356 | aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[(i*30) + 28]); | |
402 | compressed_spec_mat[i*30+22] = compressed_spec_mat[i*30+22] / aux; |
|
357 | compressed_spec_mat[(i*30) + 22] = compressed_spec_mat[(i*30) + 22] / aux; | |
403 | compressed_spec_mat[i*30+23] = compressed_spec_mat[i*30+23] / aux; |
|
358 | compressed_spec_mat[(i*30) + 23] = compressed_spec_mat[(i*30) + 23] / aux; | |
404 | } |
|
359 | } | |
405 | } |
|
360 | } | |
406 |
|
361 |
@@ -1,15 +1,20 | |||||
1 | #include <tc_handler.h> |
|
1 | #include <tc_handler.h> | |
2 | #include <fsw_params.h> |
|
2 | #include <fsw_params.h> | |
3 |
|
3 | |||
4 | char *errorCCSDSMsg[8] = { "ILLEGAL_APID 0", |
|
4 | char *DumbMessages[5] = {"default", | |
5 | "WRONG_LEN_PACKET 1", |
|
5 | "timecode_irq_handler", | |
6 | "INCOR_CHECKSUM 2", |
|
6 | "waveforms_isr", | |
7 |
|
|
7 | "", | |
8 |
|
|
8 | "" | |
9 | "WRONG_APP_DATA 5", |
|
9 | }; | |
10 | "WRONG_CMD_CODE 6", |
|
10 | ||
11 | "CCSDS_TM_VALID 7" |
|
11 | unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field | |
12 | }; |
|
12 | unsigned char currentTC_COMPUTED_CRC[2]; | |
|
13 | unsigned int currentTC_LEN_RCV_AsUnsignedInt; | |||
|
14 | unsigned int currentTM_length; | |||
|
15 | unsigned char currentTC_processedFlag; | |||
|
16 | ||||
|
17 | unsigned int lookUpTableForCRC[256]; | |||
13 |
|
18 | |||
14 | //********************** |
|
19 | //********************** | |
15 | // GENERAL USE FUNCTIONS |
|
20 | // GENERAL USE FUNCTIONS | |
@@ -18,20 +23,38 unsigned int Crc_opt( unsigned char D, u | |||||
18 | return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]); |
|
23 | return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]); | |
19 | } |
|
24 | } | |
20 |
|
25 | |||
21 | void initLookUpTableForCRC() |
|
26 | void initLookUpTableForCRC( void ) | |
22 | { |
|
27 | { | |
23 |
unsigned int i |
|
28 | unsigned int i; | |
|
29 | unsigned int tmp; | |||
|
30 | ||||
24 | for (i=0; i<256; i++) |
|
31 | for (i=0; i<256; i++) | |
25 | { |
|
32 | { | |
26 | tmp = 0; |
|
33 | tmp = 0; | |
27 |
if((i & 1) != 0) |
|
34 | if((i & 1) != 0) { | |
28 |
|
|
35 | tmp = tmp ^ 0x1021; | |
29 | if((i & 4) != 0) tmp = tmp ^ 0x4084; |
|
36 | } | |
30 |
if((i & |
|
37 | if((i & 2) != 0) { | |
31 |
|
|
38 | tmp = tmp ^ 0x2042; | |
32 | if((i & 32) != 0) tmp = tmp ^ 0x2462; |
|
39 | } | |
33 |
if((i & |
|
40 | if((i & 4) != 0) { | |
34 |
|
|
41 | tmp = tmp ^ 0x4084; | |
|
42 | } | |||
|
43 | if((i & 8) != 0) { | |||
|
44 | tmp = tmp ^ 0x8108; | |||
|
45 | } | |||
|
46 | if((i & 16) != 0) { | |||
|
47 | tmp = tmp ^ 0x1231; | |||
|
48 | } | |||
|
49 | if((i & 32) != 0) { | |||
|
50 | tmp = tmp ^ 0x2462; | |||
|
51 | } | |||
|
52 | if((i & 64) != 0) { | |||
|
53 | tmp = tmp ^ 0x48c4; | |||
|
54 | } | |||
|
55 | if((i & 128) != 0) { | |||
|
56 | tmp = tmp ^ 0x9188; | |||
|
57 | } | |||
35 | lookUpTableForCRC[i] = tmp; |
|
58 | lookUpTableForCRC[i] = tmp; | |
36 | } |
|
59 | } | |
37 | } |
|
60 | } | |
@@ -52,6 +75,7 void GetCRCAsTwoBytes(unsigned char* dat | |||||
52 | // ACCEPTANCE FUNCTIONS |
|
75 | // ACCEPTANCE FUNCTIONS | |
53 | int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv) |
|
76 | int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv) | |
54 | { |
|
77 | { | |
|
78 | int ret = 0; | |||
55 | rtems_status_code status; |
|
79 | rtems_status_code status; | |
56 | spw_ioctl_pkt_send spw_ioctl_send; |
|
80 | spw_ioctl_pkt_send spw_ioctl_send; | |
57 | TMHeader_t TM_header; |
|
81 | TMHeader_t TM_header; | |
@@ -78,97 +102,174 int TC_checker(ccsdsTelecommandPacket_t | |||||
78 | } |
|
102 | } | |
79 | else { // send valid TC to the action launcher |
|
103 | else { // send valid TC to the action launcher | |
80 | status = rtems_message_queue_send( misc_id[0], TC, tc_len_recv + CCSDS_TC_TM_PACKET_OFFSET + 3); |
|
104 | status = rtems_message_queue_send( misc_id[0], TC, tc_len_recv + CCSDS_TC_TM_PACKET_OFFSET + 3); | |
81 |
ret |
|
105 | ret = -1; | |
82 | } |
|
106 | } | |
83 |
return |
|
107 | return ret; | |
84 | } |
|
108 | } | |
85 |
|
109 | |||
86 | unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV) |
|
110 | unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV) | |
87 | { |
|
111 | { | |
88 |
unsigned char |
|
112 | unsigned char ret = 0; | |
89 |
unsigned char |
|
113 | unsigned char pid = 0; | |
|
114 | unsigned char category = 0; | |||
90 | unsigned int length = 0; |
|
115 | unsigned int length = 0; | |
91 | unsigned char packetType = 0; |
|
116 | unsigned char packetType = 0; | |
92 | unsigned char packetSubtype = 0; |
|
117 | unsigned char packetSubtype = 0; | |
93 | unsigned char * CCSDSContent; |
|
118 | unsigned char * CCSDSContent = NULL; | |
94 |
|
||||
95 | // APID check *** APID on 2 bytes |
|
|||
96 | pid = ((TMPacket->packetID[0] & 0x07)<<4) + ( (TMPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx |
|
|||
97 | category = (TMPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210 |
|
|||
98 | if (pid!=CCSDS_PROCESS_ID) return ILLEGAL_APID; |
|
|||
99 | if (category!=CCSDS_PACKET_CATEGORY) return ILLEGAL_APID; |
|
|||
100 |
|
||||
101 | // packet length check |
|
|||
102 | length = TMPacket->packetLength[0] * 256 + TMPacket->packetLength[1]; |
|
|||
103 | if (length != TC_LEN_RCV ) return WRONG_LEN_PACKET; // LEN RCV != SIZE FIELD |
|
|||
104 | if (length >= CCSDS_TC_PKT_MAX_SIZE) return WRONG_LEN_PACKET; // check that the packet does not exceed the MAX size |
|
|||
105 |
|
119 | |||
|
120 | // APID check *** APID on 2 bytes | |||
|
121 | pid = ((TMPacket->packetID[0] & 0x07)<<4) + ( (TMPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx | |||
|
122 | category = (TMPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210 | |||
|
123 | length = (TMPacket->packetLength[0] * 256) + TMPacket->packetLength[1]; | |||
106 | packetType = TMPacket->dataFieldHeader[1]; |
|
124 | packetType = TMPacket->dataFieldHeader[1]; | |
107 | packetSubtype = TMPacket->dataFieldHeader[2]; |
|
125 | packetSubtype = TMPacket->dataFieldHeader[2]; | |
108 | // service type, subtype and packet length check |
|
126 | ||
109 | if (packetType == 181){ |
|
127 | if (pid!=CCSDS_PROCESS_ID) { | |
110 | switch(packetSubtype){ //subtype, autorized values are 3, 20, 21, 24, 27, 28, 30, 40, 50, 60, 61 |
|
128 | ret = ILLEGAL_APID; | |
111 | case 3: |
|
129 | } | |
112 | if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
130 | else if (category!=CCSDS_PACKET_CATEGORY) { | |
113 | break; |
|
131 | ret = ILLEGAL_APID; | |
114 | case 20: |
|
132 | } | |
115 | if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
133 | else if (length != TC_LEN_RCV ) { // packet length check | |
116 | break; |
|
134 | ret = WRONG_LEN_PACKET; // LEN RCV != SIZE FIELD | |
117 | case 21: |
|
135 | } | |
118 | if (length!=(20-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
136 | else if (length >= CCSDS_TC_PKT_MAX_SIZE) { | |
119 | break; |
|
137 | ret = WRONG_LEN_PACKET; // check that the packet does not exceed the MAX size | |
120 | case 24: |
|
|||
121 | if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
|||
122 | break; |
|
|||
123 | case 27: |
|
|||
124 | if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
|||
125 | break; |
|
|||
126 | case 28: |
|
|||
127 | if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
|||
128 | break; |
|
|||
129 | case 30: |
|
|||
130 | if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
|||
131 | break; |
|
|||
132 | case 40: |
|
|||
133 | if (length!=(20-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
|||
134 | break; |
|
|||
135 | case 50: |
|
|||
136 | if (length!=(50-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
|||
137 | break; |
|
|||
138 | case 60: |
|
|||
139 | if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
|||
140 | break; |
|
|||
141 | case 61: |
|
|||
142 | if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
|||
143 | break; |
|
|||
144 | default: |
|
|||
145 | return ILL_SUBTYPE; |
|
|||
146 | break; |
|
|||
147 | } |
|
|||
148 | } |
|
138 | } | |
149 | else if (packetType == 9){ |
|
139 | else if (packetType == TC_TYPE_GEN){ // service type, subtype and packet length check | |
150 | if (packetSubtype!=129) return ILL_SUBTYPE; |
|
140 | switch(packetSubtype){ //subtype, autorized values are 3, 20, 21, 24, 27, 28, 30, 40, 50, 60, 61 | |
151 | if (length!=(18-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET; |
|
141 | case TC_SUBTYPE_RESET: | |
|
142 | if (length!=(TC_LEN_RESET-CCSDS_TC_TM_PACKET_OFFSET)) { | |||
|
143 | ret = WRONG_LEN_PACKET; | |||
|
144 | } | |||
|
145 | else { | |||
|
146 | ret = CCSDS_TM_VALID; | |||
|
147 | } | |||
|
148 | break; | |||
|
149 | case TC_SUBTYPE_LOAD_COMM: | |||
|
150 | if (length!=(TC_LEN_LOAD_COMM-CCSDS_TC_TM_PACKET_OFFSET)) { | |||
|
151 | ret = WRONG_LEN_PACKET; | |||
|
152 | } | |||
|
153 | else { | |||
|
154 | ret = CCSDS_TM_VALID; | |||
|
155 | } | |||
|
156 | break; | |||
|
157 | case TC_SUBTYPE_LOAD_NORM: | |||
|
158 | if (length!=(TC_LEN_LOAD_NORM-CCSDS_TC_TM_PACKET_OFFSET)) { | |||
|
159 | ret = WRONG_LEN_PACKET; | |||
|
160 | } | |||
|
161 | else { | |||
|
162 | ret = CCSDS_TM_VALID; | |||
|
163 | } | |||
|
164 | break; | |||
|
165 | case TC_SUBTYPE_LOAD_BURST: | |||
|
166 | if (length!=(TC_LEN_LOAD_BURST-CCSDS_TC_TM_PACKET_OFFSET)) { | |||
|
167 | ret = WRONG_LEN_PACKET; | |||
|
168 | } | |||
|
169 | else { | |||
|
170 | ret = CCSDS_TM_VALID; | |||
|
171 | } | |||
|
172 | break; | |||
|
173 | case TC_SUBTYPE_LOAD_SBM1: | |||
|
174 | if (length!=(TC_LEN_LOAD_SBM1-CCSDS_TC_TM_PACKET_OFFSET)) { | |||
|
175 | ret = WRONG_LEN_PACKET; | |||
|
176 | } | |||
|
177 | else { | |||
|
178 | ret = CCSDS_TM_VALID; | |||
|
179 | } | |||
|
180 | break; | |||
|
181 | case TC_SUBTYPE_LOAD_SBM2: | |||
|
182 | if (length!=(TC_LEN_LOAD_SBM2-CCSDS_TC_TM_PACKET_OFFSET)) { | |||
|
183 | ret = WRONG_LEN_PACKET; | |||
|
184 | } | |||
|
185 | else { | |||
|
186 | ret = CCSDS_TM_VALID; | |||
|
187 | } | |||
|
188 | break; | |||
|
189 | case TC_SUBTYPE_DUMP: | |||
|
190 | if (length!=(TC_LEN_DUMP-CCSDS_TC_TM_PACKET_OFFSET)) { | |||
|
191 | ret = WRONG_LEN_PACKET; | |||
|
192 | } | |||
|
193 | else { | |||
|
194 | ret = CCSDS_TM_VALID; | |||
|
195 | } | |||
|
196 | break; | |||
|
197 | case TC_SUBTYPE_ENTER: | |||
|
198 | if (length!=(TC_LEN_ENTER-CCSDS_TC_TM_PACKET_OFFSET)) { | |||
|
199 | ret = WRONG_LEN_PACKET; | |||
|
200 | } | |||
|
201 | else { | |||
|
202 | ret = CCSDS_TM_VALID; | |||
|
203 | } | |||
|
204 | break; | |||
|
205 | case TC_SUBTYPE_UPDT_INFO: | |||
|
206 | if (length!=(TC_LEN_UPDT_INFO-CCSDS_TC_TM_PACKET_OFFSET)) { | |||
|
207 | ret = WRONG_LEN_PACKET; | |||
|
208 | } | |||
|
209 | else { | |||
|
210 | ret = CCSDS_TM_VALID; | |||
|
211 | } | |||
|
212 | break; | |||
|
213 | case TC_SUBTYPE_EN_CAL: | |||
|
214 | if (length!=(TC_LEN_EN_CAL-CCSDS_TC_TM_PACKET_OFFSET)) { | |||
|
215 | ret = WRONG_LEN_PACKET; | |||
|
216 | } | |||
|
217 | else { | |||
|
218 | ret = CCSDS_TM_VALID; | |||
|
219 | } | |||
|
220 | break; | |||
|
221 | case TC_SUBTYPE_DIS_CAL: | |||
|
222 | if (length!=(TC_LEN_DIS_CAL-CCSDS_TC_TM_PACKET_OFFSET)) { | |||
|
223 | ret = WRONG_LEN_PACKET; | |||
|
224 | } | |||
|
225 | else { | |||
|
226 | ret = CCSDS_TM_VALID; | |||
|
227 | } | |||
|
228 | break; | |||
|
229 | default: | |||
|
230 | ret = ILL_SUBTYPE; | |||
|
231 | break; | |||
|
232 | } | |||
152 | } |
|
233 | } | |
153 | else return ILL_TYPE; |
|
234 | else if (packetType == TC_TYPE_TIME){ | |
154 |
|
235 | if (packetSubtype!=TC_SUBTYPE_UPDT_TIME) { | ||
155 | // source ID check // Source ID not documented in the ICD |
|
236 | ret = ILL_SUBTYPE; | |
156 |
|
237 | } | ||
|
238 | else if (length!=(TC_LEN_UPDT_TIME-CCSDS_TC_TM_PACKET_OFFSET)) { | |||
|
239 | ret = WRONG_LEN_PACKET; | |||
|
240 | } | |||
|
241 | else { | |||
|
242 | ret = CCSDS_TM_VALID; | |||
|
243 | } | |||
|
244 | } | |||
|
245 | else { | |||
|
246 | ret = ILL_TYPE; | |||
|
247 | } | |||
|
248 | ||||
|
249 | // source ID check // Source ID not documented in the ICD | |||
|
250 | ||||
157 | // packet error control, CRC check |
|
251 | // packet error control, CRC check | |
158 | CCSDSContent = (unsigned char*) TMPacket->packetID; |
|
252 | CCSDSContent = (unsigned char*) TMPacket->packetID; | |
159 | GetCRCAsTwoBytes(CCSDSContent, currentTC_COMPUTED_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC |
|
253 | GetCRCAsTwoBytes(CCSDSContent, currentTC_COMPUTED_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC | |
160 |
if (currentTC_COMPUTED_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) |
|
254 | if (currentTC_COMPUTED_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) { | |
161 | if (currentTC_COMPUTED_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) return INCOR_CHECKSUM; |
|
255 | ret = INCOR_CHECKSUM; | |
162 |
|
256 | } | ||
163 | return CCSDS_TM_VALID; |
|
257 | else if (currentTC_COMPUTED_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) { | |
|
258 | ret = INCOR_CHECKSUM; | |||
|
259 | } | |||
|
260 | else { | |||
|
261 | ret = CCSDS_TM_VALID; | |||
|
262 | } | |||
|
263 | ||||
|
264 | return ret; | |||
164 | } |
|
265 | } | |
165 |
|
266 | |||
166 | unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength, |
|
267 | unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength, | |
167 | unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader) |
|
268 | unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader) | |
168 | { |
|
269 | { | |
169 | TMHeader->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
270 | TMHeader->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
170 | TMHeader->protocolIdentifier = 0x02; |
|
271 | TMHeader->protocolIdentifier = 0x02; | |
171 | TMHeader->reserved = 0x00; |
|
272 | TMHeader->reserved = 0x00; | |
172 | TMHeader->userApplication = 0x00; |
|
273 | TMHeader->userApplication = 0x00; | |
173 | TMHeader->packetID[0] = 0x0c; |
|
274 | TMHeader->packetID[0] = 0x0c; | |
174 | TMHeader->packetSequenceControl[0] = 0xc0; |
|
275 | TMHeader->packetSequenceControl[0] = 0xc0; | |
@@ -224,9 +325,9 unsigned char TM_build_header_bis( enum | |||||
224 | unsigned int coarseTime, unsigned int fineTime, Packet_TM_LFR_TC_EXE_t *packet) |
|
325 | unsigned int coarseTime, unsigned int fineTime, Packet_TM_LFR_TC_EXE_t *packet) | |
225 | { |
|
326 | { | |
226 |
|
327 | |||
227 | packet->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
328 | packet->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
228 | packet->protocolIdentifier = 0x02; |
|
329 | packet->protocolIdentifier = 0x02; | |
229 | packet->reserved = 0x00; |
|
330 | packet->reserved = 0x00; | |
230 | packet->userApplication = 0x00; |
|
331 | packet->userApplication = 0x00; | |
231 | packet->packetID[0] = 0x0c; |
|
332 | packet->packetID[0] = 0x0c; | |
232 | packet->packetSequenceControl[0] = 0xc0; |
|
333 | packet->packetSequenceControl[0] = 0xc0; | |
@@ -281,7 +382,7 unsigned char TM_build_header_bis( enum | |||||
281 | unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC) |
|
382 | unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC) | |
282 | { |
|
383 | { | |
283 | unsigned int packetLength; |
|
384 | unsigned int packetLength; | |
284 | packetLength = TC->packetLength[0] * 256 + TC->packetLength[1]; |
|
385 | packetLength = (TC->packetLength[0] * 256) + TC->packetLength[1]; | |
285 | switch (SID){ |
|
386 | switch (SID){ | |
286 | case (SID_NOT_EXE): |
|
387 | case (SID_NOT_EXE): | |
287 | break; |
|
388 | break; | |
@@ -321,13 +422,15 unsigned char TM_build_data(ccsdsTelecom | |||||
321 | return 1; |
|
422 | return 1; | |
322 | } |
|
423 | } | |
323 |
|
424 | |||
324 | int create_message_queue() |
|
425 | int create_message_queue( void ) | |
325 | { |
|
426 | { | |
326 | rtems_status_code status; |
|
427 | rtems_status_code status; | |
327 | misc_name[0] = rtems_build_name( 'Q', 'U', 'E', 'U' ); |
|
428 | misc_name[0] = rtems_build_name( 'Q', 'U', 'E', 'U' ); | |
328 | status = rtems_message_queue_create( misc_name[0], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE, |
|
429 | status = rtems_message_queue_create( misc_name[0], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE, | |
329 | RTEMS_FIFO | RTEMS_LOCAL, &misc_id[0] ); |
|
430 | RTEMS_FIFO | RTEMS_LOCAL, &misc_id[0] ); | |
330 | if (status!=RTEMS_SUCCESSFUL) PRINTF("in create_message_queue *** error creating message queue\n") |
|
431 | if (status!=RTEMS_SUCCESSFUL) { | |
|
432 | PRINTF("in create_message_queue *** error creating message queue\n") | |||
|
433 | } | |||
331 |
|
434 | |||
332 | return 0; |
|
435 | return 0; | |
333 | } |
|
436 | } | |
@@ -335,39 +438,41 int create_message_queue() | |||||
335 | //*********** |
|
438 | //*********** | |
336 | // RTEMS TASK |
|
439 | // RTEMS TASK | |
337 | rtems_task recv_task( rtems_task_argument unused ) |
|
440 | rtems_task recv_task( rtems_task_argument unused ) | |
338 | { |
|
441 | { | |
339 | int len = 0; |
|
442 | int len = 0; | |
340 | unsigned int i = 0; |
|
443 | unsigned int i = 0; | |
341 | unsigned int data_length = 0; |
|
444 | unsigned int data_length = 0; | |
342 | ccsdsTelecommandPacket_t currentTC; |
|
445 | ccsdsTelecommandPacket_t currentTC; | |
343 | char data[100]; |
|
446 | char data[100]; | |
344 |
|
447 | |||
345 | for(i=0; i<100; i++) data[i] = 0; |
|
448 | for(i=0; i<100; i++) data[i] = 0; | |
346 |
|
449 | |||
347 | PRINTF("in RECV *** \n") |
|
450 | PRINTF("in RECV *** \n") | |
348 |
|
451 | |||
349 | while(1) |
|
452 | while(1) | |
350 | { |
|
453 | { | |
351 | len = read(fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE); // the call to read is blocking |
|
454 | len = read(fdSPW, (char*) ¤tTC, CCSDS_TC_PKT_MAX_SIZE); // the call to read is blocking | |
352 | if (len == -1){ // error during the read call |
|
455 | if (len == -1){ // error during the read call | |
353 | PRINTF("In RECV *** last read call returned -1\n") |
|
456 | PRINTF("In RECV *** last read call returned -1\n") | |
354 | if (rtems_event_send( Task_id[3], SPW_LINKERR_EVENT ) != RTEMS_SUCCESSFUL) |
|
457 | if (rtems_event_send( Task_id[3], SPW_LINKERR_EVENT ) != RTEMS_SUCCESSFUL) { | |
355 | PRINTF("IN RECV *** Error: rtems_event_send SPW_LINKERR_EVENT\n") |
|
458 | PRINTF("IN RECV *** Error: rtems_event_send SPW_LINKERR_EVENT\n") | |
356 | if (rtems_task_suspend(RTEMS_SELF) != RTEMS_SUCCESSFUL) |
|
459 | } | |
357 |
|
|
460 | if (rtems_task_suspend(RTEMS_SELF) != RTEMS_SUCCESSFUL) { | |
|
461 | PRINTF("In RECV *** Error: rtems_task_suspend(RTEMS_SELF)\n") | |||
|
462 | } | |||
358 | } |
|
463 | } | |
359 | else { |
|
464 | else { | |
360 | PRINTF1("Got pck of length %d\n", len+1) |
|
465 | PRINTF1("Got pck of length %d\n", len+1) | |
361 | currentTC_LEN_RCV[0] = 0x00; |
|
466 | currentTC_LEN_RCV[0] = 0x00; | |
362 | currentTC_LEN_RCV[1] = (unsigned char) len - CCSDS_TC_TM_PACKET_OFFSET - 3; // build the corresponding packet size field |
|
467 | currentTC_LEN_RCV[1] = (unsigned char) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // build the corresponding packet size field | |
363 | currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) len - CCSDS_TC_TM_PACKET_OFFSET - 3; // => -3 is for Prot ID, Reserved and User App bytes |
|
468 | currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) (len - CCSDS_TC_TM_PACKET_OFFSET - 3); // => -3 is for Prot ID, Reserved and User App bytes | |
364 | // CHECK THE TC AND BUILD THE APPROPRIATE TM |
|
469 | // CHECK THE TC AND BUILD THE APPROPRIATE TM | |
365 | data_length = TC_checker(¤tTC, currentTC_LEN_RCV_AsUnsignedInt); |
|
470 | data_length = TC_checker(¤tTC, currentTC_LEN_RCV_AsUnsignedInt); | |
366 | if (data_length!=-1) |
|
471 | if (data_length!=-1) | |
367 | { |
|
472 | { | |
368 | } |
|
473 | } | |
369 | } |
|
474 | } | |
370 | } |
|
475 | } | |
371 | } |
|
476 | } | |
372 |
|
477 | |||
373 | rtems_task actn_task( rtems_task_argument unused ) |
|
478 | rtems_task actn_task( rtems_task_argument unused ) | |
@@ -450,17 +555,26 rtems_task actn_task( rtems_task_argumen | |||||
450 |
|
555 | |||
451 | rtems_task dumb_task( rtems_task_argument unused ) |
|
556 | rtems_task dumb_task( rtems_task_argument unused ) | |
452 | { |
|
557 | { | |
453 | unsigned int coarse_time; |
|
558 | unsigned int coarse_time = 0; | |
454 | unsigned int fine_time; |
|
559 | unsigned int fine_time = 0; | |
|
560 | unsigned int indice = 0; | |||
|
561 | unsigned int shiftedIndice = 0; | |||
455 | rtems_event_set event_out; |
|
562 | rtems_event_set event_out; | |
456 |
|
563 | |||
457 | PRINTF("in DUMB *** \n") |
|
564 | PRINTF("in DUMB *** \n") | |
458 |
|
565 | |||
459 | while(1){ |
|
566 | while(1){ | |
460 |
rtems_event_receive(RTEMS_EVENT_ |
|
567 | rtems_event_receive(RTEMS_EVENT_1, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 | |
|
568 | indice = 0; | |||
|
569 | shiftedIndice = (unsigned int) event_out; | |||
|
570 | while(!(shiftedIndice & 0x0001)) | |||
|
571 | { | |||
|
572 | shiftedIndice = shiftedIndice >> 1; | |||
|
573 | indice++; | |||
|
574 | } | |||
461 | coarse_time = time_management_regs->coarse_time; |
|
575 | coarse_time = time_management_regs->coarse_time; | |
462 | fine_time = time_management_regs->fine_time; |
|
576 | fine_time = time_management_regs->fine_time; | |
463 |
printf("in DUMB *** coarse |
|
577 | printf("in DUMB *** time = coarse: %x, fine: %x, %s\n", coarse_time, fine_time, DumbMessages[indice]); | |
464 | } |
|
578 | } | |
465 | } |
|
579 | } | |
466 |
|
580 | |||
@@ -484,8 +598,9 int action_default(ccsdsTelecommandPacke | |||||
484 | packet.data[7] = TC->dataFieldHeader[2]; // subtype |
|
598 | packet.data[7] = TC->dataFieldHeader[2]; // subtype | |
485 |
|
599 | |||
486 | // SEND DATA |
|
600 | // SEND DATA | |
487 | if (write ( fdSPW, &packet, LEN_TM_LFR_TC_EXE_NOT_IMP)==-1) |
|
601 | if (write ( fdSPW, &packet, LEN_TM_LFR_TC_EXE_NOT_IMP)==-1) { | |
488 | PRINTF("ERR *** in action_default *** send TM packet\n"); |
|
602 | PRINTF("ERR *** in action_default *** send TM packet\n"); | |
|
603 | } | |||
489 |
|
604 | |||
490 | return 0; |
|
605 | return 0; | |
491 | } |
|
606 | } | |
@@ -499,10 +614,20 int action_enter(ccsdsTelecommandPacket_ | |||||
499 | case(LFR_MODE_STANDBY): |
|
614 | case(LFR_MODE_STANDBY): | |
500 | LEON_Mask_interrupt( IRQ_WF ); |
|
615 | LEON_Mask_interrupt( IRQ_WF ); | |
501 | LEON_Mask_interrupt( IRQ_SM ); |
|
616 | LEON_Mask_interrupt( IRQ_SM ); | |
|
617 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); | |||
|
618 | waveform_picker_regs->burst_enable = 0x00; | |||
502 | break; |
|
619 | break; | |
503 | case(LFR_MODE_NORMAL): |
|
620 | case(LFR_MODE_NORMAL): | |
|
621 | ||||
|
622 | #ifdef GSA | |||
504 | LEON_Unmask_interrupt( IRQ_WF ); |
|
623 | LEON_Unmask_interrupt( IRQ_WF ); | |
505 | LEON_Unmask_interrupt( IRQ_SM ); |
|
624 | #else | |
|
625 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); | |||
|
626 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); | |||
|
627 | waveform_picker_regs->burst_enable = 0x07; | |||
|
628 | waveform_picker_regs->status = 0x00; | |||
|
629 | #endif | |||
|
630 | ||||
506 | break; |
|
631 | break; | |
507 | case(LFR_MODE_BURST): |
|
632 | case(LFR_MODE_BURST): | |
508 | break; |
|
633 | break; | |
@@ -510,15 +635,17 int action_enter(ccsdsTelecommandPacket_ | |||||
510 | break; |
|
635 | break; | |
511 | case(LFR_MODE_SBM2): |
|
636 | case(LFR_MODE_SBM2): | |
512 | break; |
|
637 | break; | |
|
638 | default: | |||
|
639 | break; | |||
513 | } |
|
640 | } | |
514 | return 0; |
|
641 | return 0; | |
515 | } |
|
642 | } | |
516 |
|
643 | |||
517 | int action_load_norm(ccsdsTelecommandPacket_t *TC) |
|
644 | int action_load_norm(ccsdsTelecommandPacket_t *TC) | |
518 | { |
|
645 | { | |
519 | param_norm.sy_lfr_n_swf_l = TC->dataAndCRC[0] * 256 + TC->dataAndCRC[1]; |
|
646 | param_norm.sy_lfr_n_swf_l = (TC->dataAndCRC[0] * 256) + TC->dataAndCRC[1]; | |
520 | param_norm.sy_lfr_n_swf_p = TC->dataAndCRC[2] * 256 + TC->dataAndCRC[3]; |
|
647 | param_norm.sy_lfr_n_swf_p = (TC->dataAndCRC[2] * 256) + TC->dataAndCRC[3]; | |
521 | param_norm.sy_lfr_n_asm_p = TC->dataAndCRC[4] * 256 + TC->dataAndCRC[5]; |
|
648 | param_norm.sy_lfr_n_asm_p = (TC->dataAndCRC[4] * 256) + TC->dataAndCRC[5]; | |
522 | param_norm.sy_lfr_n_bp_p0 = TC->dataAndCRC[6]; |
|
649 | param_norm.sy_lfr_n_bp_p0 = TC->dataAndCRC[6]; | |
523 | param_norm.sy_lfr_n_bp_p1 = TC->dataAndCRC[7]; |
|
650 | param_norm.sy_lfr_n_bp_p1 = TC->dataAndCRC[7]; | |
524 | /*printf("sy_lfr_n_ => swf_l %d, swf_p %d, asm_p %d, bsp_p0 %d, bsp_p1 %d\n", |
|
651 | /*printf("sy_lfr_n_ => swf_l %d, swf_p %d, asm_p %d, bsp_p0 %d, bsp_p1 %d\n", | |
@@ -567,14 +694,16 int send_tm_lfr_tc_exe_success(ccsdsTele | |||||
567 | // Interrupt Service Routines |
|
694 | // Interrupt Service Routines | |
568 | rtems_isr commutation_isr1( rtems_vector_number vector ) |
|
695 | rtems_isr commutation_isr1( rtems_vector_number vector ) | |
569 | { |
|
696 | { | |
570 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
697 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
571 | printf("In commutation_isr1 *** Error sending event to DUMB\n"); |
|
698 | printf("In commutation_isr1 *** Error sending event to DUMB\n"); | |
|
699 | } | |||
572 | } |
|
700 | } | |
573 |
|
701 | |||
574 | rtems_isr commutation_isr2( rtems_vector_number vector ) |
|
702 | rtems_isr commutation_isr2( rtems_vector_number vector ) | |
575 | { |
|
703 | { | |
576 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
704 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
577 | printf("In commutation_isr2 *** Error sending event to DUMB\n"); |
|
705 | printf("In commutation_isr2 *** Error sending event to DUMB\n"); | |
|
706 | } | |||
578 | } |
|
707 | } | |
579 |
|
708 | |||
580 |
|
709 |
@@ -1,34 +1,48 | |||||
1 | #include <wf_handler.h> |
|
1 | #include <wf_handler.h> | |
2 |
|
2 | |||
3 | rtems_isr waveforms_isr( rtems_vector_number vector ) |
|
3 | rtems_isr waveforms_isr( rtems_vector_number vector ) | |
4 | { |
|
4 | { | |
5 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
5 | if ( (waveform_picker_regs->burst_enable & 0x7) == 0x0 ){// if no channel is enable | |
6 | printf("In waveforms_isr *** Error sending event to WFRM\n"); |
|
6 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_2 ) != RTEMS_SUCCESSFUL) { | |
|
7 | printf("In timecode_irq_handler *** Error sending event to DUMB\n"); | |||
|
8 | } | |||
|
9 | } | |||
|
10 | else { | |||
|
11 | if ( (waveform_picker_regs->status & 0x7) == 0x7 ){ // f2 f1 and f0 are full | |||
|
12 | waveform_picker_regs->burst_enable = 0x00; | |||
|
13 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |||
|
14 | printf("In waveforms_isr *** Error sending event to WFRM\n"); | |||
|
15 | } | |||
|
16 | } | |||
|
17 | } | |||
7 | } |
|
18 | } | |
8 |
|
19 | |||
9 | rtems_task wfrm_task(rtems_task_argument argument) |
|
20 | rtems_isr waveforms_simulator_isr( rtems_vector_number vector ) | |
10 | { |
|
21 | { | |
11 | unsigned int length; |
|
22 | if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
12 | unsigned int i = 0; |
|
23 | printf("In waveforms_isr *** Error sending event to WFRM\n"); | |
|
24 | } | |||
|
25 | } | |||
|
26 | ||||
|
27 | rtems_task wfrm_task(rtems_task_argument argument) //used with the waveform picker VHDL IP | |||
|
28 | { | |||
13 | spw_ioctl_pkt_send spw_ioctl_send; |
|
29 | spw_ioctl_pkt_send spw_ioctl_send; | |
14 | rtems_event_set event_out; |
|
30 | rtems_event_set event_out; | |
15 | gptimer_regs_t *gptimer_regs; |
|
|||
16 | gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER; |
|
|||
17 | ExtendedTMHeader_t header; |
|
31 | ExtendedTMHeader_t header; | |
18 |
|
32 | |||
19 | header.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
33 | header.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
20 | header.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
34 | header.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
21 | header.reserved = 0x00; |
|
35 | header.reserved = 0x00; | |
22 | header.userApplication = CCSDS_USER_APP; |
|
36 | header.userApplication = CCSDS_USER_APP; | |
23 | header.packetID[0] = 0x0c; |
|
37 | header.packetID[0] = 0x0c; | |
24 | header.packetID[1] = 0xcc; |
|
38 | header.packetID[1] = 0xcc; | |
25 | header.packetSequenceControl[0] = 0x00; |
|
39 | header.packetSequenceControl[0] = 0x00; | |
26 | header.packetSequenceControl[1] = 0x00; |
|
40 | header.packetSequenceControl[1] = 0x00; | |
27 | header.packetLength[0] = 0x00; |
|
41 | header.packetLength[0] = 0x00; | |
28 | header.packetLength[1] = 0x00; |
|
42 | header.packetLength[1] = 0x00; | |
29 | header.dataFieldHeader[0] = 0x10; |
|
43 | header.dataFieldHeader[0] = 0x10; | |
30 |
header.dataFieldHeader[1] = |
|
44 | header.dataFieldHeader[1] = TM_TYPE_LFR_SCIENCE; // service type | |
31 |
header.dataFieldHeader[2] = |
|
45 | header.dataFieldHeader[2] = TM_SUBTYPE_LFR_SCIENCE; // service subtype | |
32 | header.dataFieldHeader[3] = CCSDS_DESTINATION_ID_GROUND; |
|
46 | header.dataFieldHeader[3] = CCSDS_DESTINATION_ID_GROUND; | |
33 |
|
47 | |||
34 | header.auxiliaryHeader[0] = 0x00; |
|
48 | header.auxiliaryHeader[0] = 0x00; | |
@@ -36,141 +50,260 rtems_task wfrm_task(rtems_task_argument | |||||
36 | header.auxiliaryHeader[2] = 0x07; // PKT_CNT |
|
50 | header.auxiliaryHeader[2] = 0x07; // PKT_CNT | |
37 | header.auxiliaryHeader[3] = 0x00; // PKT_NR |
|
51 | header.auxiliaryHeader[3] = 0x00; // PKT_NR | |
38 | header.auxiliaryHeader[4] = 0x00; // BLK_NR MSB |
|
52 | header.auxiliaryHeader[4] = 0x00; // BLK_NR MSB | |
39 | header.auxiliaryHeader[5] = 0x00; // BLK_NR LSB |
|
53 | header.auxiliaryHeader[5] = 0x00; // BLK_NR LSB | |
40 |
|
54 | |||
41 | // BUILD THE PACKET HEADER |
|
55 | // BUILD THE PACKET HEADER | |
42 | spw_ioctl_send.hlen = TM_HEADER_LEN + 4 + 6; // + 4 is for the protocole extra header, + 6 is for the auxiliary header |
|
56 | spw_ioctl_send.hlen = TM_HEADER_LEN + 4 + 6; // + 4 is for the protocole extra header, + 6 is for the auxiliary header | |
43 | spw_ioctl_send.hdr = (char*) &header; |
|
57 | spw_ioctl_send.hdr = (char*) &header; | |
44 |
|
58 | |||
45 | PRINTF("in WFRM *** \n") |
|
59 | init_waveforms(); | |
46 |
|
60 | |||
47 | while(1){ |
|
61 | PRINTF("in WFRM ***\n") | |
|
62 | ||||
|
63 | while(1){ | |||
|
64 | ||||
48 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 |
|
65 | rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0 | |
|
66 | PRINTF("in WFRM *** send wfrm\n") | |||
49 | header.dataFieldHeader[4] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
67 | header.dataFieldHeader[4] = (unsigned char) (time_management_regs->coarse_time>>24); | |
50 | header.dataFieldHeader[5] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
68 | header.dataFieldHeader[5] = (unsigned char) (time_management_regs->coarse_time>>16); | |
51 | header.dataFieldHeader[6] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
69 | header.dataFieldHeader[6] = (unsigned char) (time_management_regs->coarse_time>>8); | |
52 | header.dataFieldHeader[7] = (unsigned char) (time_management_regs->coarse_time); |
|
70 | header.dataFieldHeader[7] = (unsigned char) (time_management_regs->coarse_time); | |
53 | header.dataFieldHeader[8] = (unsigned char) (time_management_regs->fine_time>>8); |
|
71 | header.dataFieldHeader[8] = (unsigned char) (time_management_regs->fine_time>>8); | |
54 | header.dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time); |
|
72 | header.dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time); | |
55 | for (i=0; i<7; i++) // send F0 |
|
73 | ||
56 | { |
|
74 | //*************** | |
57 | header.auxiliaryHeader[3] = (unsigned char) i+1; // PKT_NR |
|
75 | // send snapshots | |
58 | // BUILD THE DATA |
|
76 | // F0 | |
59 | if (i==6) { |
|
77 | send_waveform( &header, wf_snap_f0, SID_NORM_SWF_F0, &spw_ioctl_send); | |
60 | spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK; |
|
78 | // F1 | |
61 | length = TM_LEN_SCI_NORM_SWF_8; |
|
79 | send_waveform( &header, wf_snap_f1, SID_NORM_SWF_F1, &spw_ioctl_send); | |
62 | header.auxiliaryHeader[4] = 0x00; // BLK_NR MSB |
|
80 | // F2 | |
63 | header.auxiliaryHeader[5] = 0x08; // BLK_NR LSB |
|
81 | send_waveform( &header, wf_snap_f2, SID_NORM_SWF_F2, &spw_ioctl_send); | |
64 | } |
|
82 | ||
65 | else { |
|
83 | #ifdef GSA | |
66 | spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK; |
|
|||
67 | length = TM_LEN_SCI_NORM_SWF_340; |
|
|||
68 | header.auxiliaryHeader[4] = 0x01; // BLK_NR MSB |
|
|||
69 | header.auxiliaryHeader[5] = 0x54; // BLK_NR LSB |
|
|||
70 | } |
|
|||
71 | spw_ioctl_send.data = (char*) &wf_snap_f0[i * 340 * NB_BYTES_SWF_BLK]; |
|
|||
72 | // BUILD THE HEADER |
|
|||
73 | header.packetLength[0] = (unsigned char) (length>>8); |
|
|||
74 | header.packetLength[1] = (unsigned char) (length); |
|
|||
75 | header.auxiliaryHeader[0] = SID_NORM_SWF_F0; // SID |
|
|||
76 | // SEND PACKET |
|
|||
77 | write_spw(&spw_ioctl_send); |
|
|||
78 | } |
|
|||
79 | for (i=0; i<7; i++) // send F1 |
|
|||
80 | { |
|
|||
81 | header.auxiliaryHeader[3] = (unsigned char) i+1; // PKT_NR |
|
|||
82 | // BUILD THE DATA |
|
|||
83 | if (i==6) { |
|
|||
84 | spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK; |
|
|||
85 | length = TM_LEN_SCI_NORM_SWF_8; |
|
|||
86 | header.auxiliaryHeader[4] = 0x00; // BLK_NR MSB |
|
|||
87 | header.auxiliaryHeader[5] = 0x08; // BLK_NR LSB |
|
|||
88 | } |
|
|||
89 | else { |
|
|||
90 | spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK; |
|
|||
91 | length = TM_LEN_SCI_NORM_SWF_340; |
|
|||
92 | header.auxiliaryHeader[4] = 0x01; // BLK_NR MSB |
|
|||
93 | header.auxiliaryHeader[5] = 0x54; // BLK_NR LSB |
|
|||
94 | } |
|
|||
95 | spw_ioctl_send.data = (char*) &wf_snap_f1[i * 340 * NB_BYTES_SWF_BLK]; |
|
|||
96 | // BUILD THE HEADER |
|
|||
97 | header.packetLength[0] = (unsigned char) (length>>8); |
|
|||
98 | header.packetLength[1] = (unsigned char) (length); |
|
|||
99 | header.auxiliaryHeader[0] = SID_NORM_SWF_F1; // SID |
|
|||
100 | // SEND PACKET |
|
|||
101 | write_spw(&spw_ioctl_send); |
|
|||
102 | } |
|
|||
103 | for (i=0; i<7; i++) // send F2 |
|
|||
104 | { |
|
|||
105 | header.auxiliaryHeader[3] = (unsigned char) i+1; // PKT_NR |
|
|||
106 | // BUILD THE DATA |
|
|||
107 | if (i==6) { |
|
|||
108 | spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK; |
|
|||
109 | length = TM_LEN_SCI_NORM_SWF_8; |
|
|||
110 | header.auxiliaryHeader[4] = 0x00; // BLK_NR MSB |
|
|||
111 | header.auxiliaryHeader[5] = 0x08; // BLK_NR LSB |
|
|||
112 | } |
|
|||
113 | else { |
|
|||
114 | spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK; |
|
|||
115 | length = TM_LEN_SCI_NORM_SWF_340; |
|
|||
116 | header.auxiliaryHeader[4] = 0x01; // BLK_NR MSB |
|
|||
117 | header.auxiliaryHeader[5] = 0x54; // BLK_NR LSB |
|
|||
118 | } |
|
|||
119 | spw_ioctl_send.data = (char*) &wf_snap_f2[i * 340 * NB_BYTES_SWF_BLK]; |
|
|||
120 | // BUILD THE HEADER |
|
|||
121 | header.packetLength[0] = (unsigned char) (length>>8); |
|
|||
122 | header.packetLength[1] = (unsigned char) (length); |
|
|||
123 | header.auxiliaryHeader[0] = SID_NORM_SWF_F2; // SID |
|
|||
124 | // SEND PACKET |
|
|||
125 | write_spw(&spw_ioctl_send); |
|
|||
126 | } |
|
|||
127 | // irq processed, reset the related register of the timer unit |
|
84 | // irq processed, reset the related register of the timer unit | |
128 | gptimer_regs->timer[2].ctrl = gptimer_regs->timer[2].ctrl | 0x00000010; |
|
85 | gptimer_regs->timer[2].ctrl = gptimer_regs->timer[2].ctrl | 0x00000010; | |
|
86 | #else | |||
|
87 | // irq processed, reset the related register of the waveform picker | |||
|
88 | waveform_picker_regs->status = 0x00; | |||
|
89 | waveform_picker_regs->burst_enable = 0x07; | |||
|
90 | #endif | |||
|
91 | ||||
129 | } |
|
92 | } | |
130 | } |
|
93 | } | |
131 |
|
94 | |||
132 | //****************** |
|
95 | //****************** | |
133 | // general functions |
|
96 | // general functions | |
134 | void init_waveforms() |
|
97 | void init_waveforms( void ) | |
|
98 | { | |||
|
99 | int i = 0; | |||
|
100 | int aux1 = 0; | |||
|
101 | int aux2 = 0; | |||
|
102 | int val1 = 0; | |||
|
103 | int val2 = 0; | |||
|
104 | int val3 = 0; | |||
|
105 | int val4 = 0; | |||
|
106 | int amplitude1 = pow(2, 10); | |||
|
107 | static int delta_phi = 0; | |||
|
108 | ||||
|
109 | for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) | |||
|
110 | { | |||
|
111 | aux1 = (int) (amplitude1 * cos((2*pi*i)/2048 + (delta_phi*pi)/180)); | |||
|
112 | aux2 = (int) (amplitude1 * sin((2*pi*i)/2048 + (delta_phi*pi)/180)); | |||
|
113 | val1 = build_value(aux1, aux2); | |||
|
114 | val2 = build_value(i, 2*i); | |||
|
115 | val3 = build_value(-aux1, -aux2); | |||
|
116 | val4 = build_value(-i, -2*i); | |||
|
117 | //*** | |||
|
118 | // F0 | |||
|
119 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = 0x88887777; // | |||
|
120 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = 0x22221111; // | |||
|
121 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0x44443333; // | |||
|
122 | ||||
|
123 | //*** | |||
|
124 | // F1 | |||
|
125 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = val1; | |||
|
126 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = val2; | |||
|
127 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000; | |||
|
128 | ||||
|
129 | //*** | |||
|
130 | // F2 | |||
|
131 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET ] = val1; | |||
|
132 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET ] = val2; | |||
|
133 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET ] = 0xaaaa0000; | |||
|
134 | ||||
|
135 | //*** | |||
|
136 | // F3 | |||
|
137 | //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 0 ] = val1; | |||
|
138 | //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 1 ] = val2; | |||
|
139 | //wf_cont_f3[ (i* NB_WORDS_SWF_BLK) + 2 ] = 0xaaaa0000; | |||
|
140 | } | |||
|
141 | ||||
|
142 | delta_phi = delta_phi + 10; | |||
|
143 | ||||
|
144 | } | |||
|
145 | ||||
|
146 | void init_waveform_header( ExtendedTMHeader_t * header, unsigned int sid ) | |||
|
147 | { | |||
|
148 | ||||
|
149 | header->targetLogicalAddress = CCSDS_DESTINATION_ID; | |||
|
150 | header->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |||
|
151 | header->reserved = 0x00; | |||
|
152 | header->userApplication = CCSDS_USER_APP; | |||
|
153 | header->packetID[0] = 0x0c; | |||
|
154 | header->packetID[1] = 0xcc; | |||
|
155 | header->packetSequenceControl[0] = 0x00; | |||
|
156 | header->packetSequenceControl[1] = 0x00; | |||
|
157 | header->packetLength[0] = 0x00; | |||
|
158 | header->packetLength[1] = 0x00; | |||
|
159 | header->dataFieldHeader[0] = 0x10; | |||
|
160 | header->dataFieldHeader[1] = TM_TYPE_LFR_SCIENCE; // service type | |||
|
161 | header->dataFieldHeader[2] = TM_SUBTYPE_LFR_SCIENCE; // service subtype | |||
|
162 | header->dataFieldHeader[3] = CCSDS_DESTINATION_ID_GROUND; | |||
|
163 | ||||
|
164 | header->auxiliaryHeader[0] = sid; | |||
|
165 | header->auxiliaryHeader[1] = 0x1f; | |||
|
166 | header->auxiliaryHeader[2] = 0x07; // PKT_CNT | |||
|
167 | header->auxiliaryHeader[3] = 0x00; // PKT_NR | |||
|
168 | header->auxiliaryHeader[4] = 0x00; // BLK_NR MSB | |||
|
169 | header->auxiliaryHeader[5] = 0x00; // BLK_NR LSB | |||
|
170 | } | |||
|
171 | ||||
|
172 | void reset_waveforms( void ) | |||
135 | { |
|
173 | { | |
136 | int i = 0; |
|
174 | int i = 0; | |
137 |
|
175 | |||
138 | for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) |
|
176 | for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++) | |
139 | { |
|
177 | { | |
140 |
wf_snap_f0[ i* NB_WORDS_SWF_BLK + 0 ] = |
|
178 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x10002000; | |
141 |
wf_snap_f0[ i* NB_WORDS_SWF_BLK + 1 ] = |
|
179 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000; | |
142 |
wf_snap_f0[ i* NB_WORDS_SWF_BLK + 2 ] = |
|
180 | wf_snap_f0[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000; | |
143 | wf_snap_f1[ i* NB_WORDS_SWF_BLK + 0 ] = buil_value( i, 2*i ); // v and 1 |
|
181 | ||
144 | wf_snap_f1[ i* NB_WORDS_SWF_BLK + 1 ] = buil_value( i, 2*i ); // e2 and b1 |
|
182 | //*** | |
145 | wf_snap_f1[ i* NB_WORDS_SWF_BLK + 2 ] = buil_value( i, 2*i ); // b2 and b3 |
|
183 | // F1 | |
146 |
wf_snap_f |
|
184 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x1000f000; | |
147 |
wf_snap_f |
|
185 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0xf0001000; | |
148 |
wf_snap_f |
|
186 | wf_snap_f1[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x40008000; | |
149 | wf_cont_f3[ i* NB_WORDS_SWF_BLK + 0 ] = buil_value( i, 2*i ); // v and 1 |
|
187 | ||
150 | wf_cont_f3[ i* NB_WORDS_SWF_BLK + 1 ] = buil_value( i, 2*i ); // e2 and b1 |
|
188 | //*** | |
151 | wf_cont_f3[ i* NB_WORDS_SWF_BLK + 2 ] = buil_value( i, 2*i ); // b2 and b3 |
|
189 | // F2 | |
|
190 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 0 + TIME_OFFSET] = 0x40008000; | |||
|
191 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 1 + TIME_OFFSET] = 0x20001000; | |||
|
192 | wf_snap_f2[ (i* NB_WORDS_SWF_BLK) + 2 + TIME_OFFSET] = 0x10002000; | |||
|
193 | ||||
|
194 | //*** | |||
|
195 | // F3 | |||
|
196 | /*wf_cont_f3[ i* NB_WORDS_SWF_BLK + 0 ] = build_value( i, i ); // v and 1 | |||
|
197 | wf_cont_f3[ i* NB_WORDS_SWF_BLK + 1 ] = build_value( i, i ); // e2 and b1 | |||
|
198 | wf_cont_f3[ i* NB_WORDS_SWF_BLK + 2 ] = build_value( i, i ); // b2 and b3*/ | |||
152 | } |
|
199 | } | |
153 | } |
|
200 | } | |
154 |
|
201 | |||
155 | int buil_value(int value1, int value0) |
|
202 | void send_waveform( ExtendedTMHeader_t *header, volatile int *waveform, | |
|
203 | unsigned int sid, spw_ioctl_pkt_send *spw_ioctl_send) | |||
|
204 | { | |||
|
205 | unsigned int i = 0; | |||
|
206 | unsigned int length = 0; | |||
|
207 | rtems_status_code status; | |||
|
208 | ||||
|
209 | for (i=0; i<7; i++) // send waveform | |||
|
210 | { | |||
|
211 | header->auxiliaryHeader[3] = (unsigned char) i+1; // PKT_NR | |||
|
212 | // BUILD THE DATA | |||
|
213 | if (i==6) { | |||
|
214 | spw_ioctl_send->dlen = 8 * NB_BYTES_SWF_BLK; | |||
|
215 | length = TM_LEN_SCI_NORM_SWF_8; | |||
|
216 | header->auxiliaryHeader[4] = 0x00; // BLK_NR MSB | |||
|
217 | header->auxiliaryHeader[5] = 0x08; // BLK_NR LSB | |||
|
218 | } | |||
|
219 | else { | |||
|
220 | spw_ioctl_send->dlen = 340 * NB_BYTES_SWF_BLK; | |||
|
221 | length = TM_LEN_SCI_NORM_SWF_340; | |||
|
222 | header->auxiliaryHeader[4] = 0x01; // BLK_NR MSB | |||
|
223 | header->auxiliaryHeader[5] = 0x54; // BLK_NR LSB | |||
|
224 | } | |||
|
225 | if (sid == SID_NORM_SWF_F0) { | |||
|
226 | spw_ioctl_send->data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) + (1 * TIME_OFFSET) ]; | |||
|
227 | } | |||
|
228 | else if (sid == SID_NORM_SWF_F1) { | |||
|
229 | spw_ioctl_send->data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) + (1 * TIME_OFFSET) ]; | |||
|
230 | } | |||
|
231 | else if (sid == SID_NORM_SWF_F2) { | |||
|
232 | spw_ioctl_send->data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) + (0 * TIME_OFFSET) ]; | |||
|
233 | } | |||
|
234 | else { | |||
|
235 | spw_ioctl_send->data = (char*) &waveform[ (i * 340 * NB_WORDS_SWF_BLK) ]; | |||
|
236 | } | |||
|
237 | // BUILD THE HEADER | |||
|
238 | header->packetLength[0] = (unsigned char) (length>>8); | |||
|
239 | header->packetLength[1] = (unsigned char) (length); | |||
|
240 | header->auxiliaryHeader[0] = sid; // SID | |||
|
241 | // SEND PACKET | |||
|
242 | status = write_spw(spw_ioctl_send); | |||
|
243 | if (status != RTEMS_SUCCESSFUL) { | |||
|
244 | while (true) { | |||
|
245 | if (status != RTEMS_SUCCESSFUL) { | |||
|
246 | status = write_spw(spw_ioctl_send); | |||
|
247 | //PRINTF1("%d", i) | |||
|
248 | sched_yield(); | |||
|
249 | } | |||
|
250 | else { | |||
|
251 | //PRINTF("\n") | |||
|
252 | break; | |||
|
253 | } | |||
|
254 | } | |||
|
255 | } | |||
|
256 | } | |||
|
257 | } | |||
|
258 | ||||
|
259 | int build_value(int value1, int value0) | |||
156 | { |
|
260 | { | |
157 | int aux = 0; |
|
261 | int aux = 0; | |
158 | int aux1 = 0; |
|
262 | int aux1 = 0; | |
159 | int aux0 = 0; |
|
263 | int aux0 = 0; | |
|
264 | int value1_aux = 0; | |||
|
265 | int value0_aux = 0; | |||
|
266 | ||||
|
267 | value1_aux = value1; | |||
|
268 | value0_aux = value0; | |||
|
269 | ||||
160 | //****** |
|
270 | //****** | |
161 | // B3 B2 |
|
271 | // B3 B2 | |
162 | aux1 = ( (int) ( (char) (value1 >> 8) ) << 8 ) |
|
272 | if (value1_aux > 8191) value1_aux = 8191; | |
163 | + ( (int) ( (char) (value1 ) ) ); |
|
273 | if (value1_aux < -8192) value1_aux = -8192; | |
|
274 | aux1 = ( (int) ( ( (unsigned char) (value1_aux / 256 ) ) << 8 ) ) | |||
|
275 | + ( (int) ( (unsigned char) (value1_aux ) ) ); | |||
164 |
|
276 | |||
165 | //****** |
|
277 | //****** | |
166 | // B1 B0 |
|
278 | // B1 B0 | |
167 | aux0 = ( (int) ( (char) (value0 >> 8) ) << 8 ) |
|
279 | if (value0_aux > 8191) value0_aux = 8191; | |
168 | + ( (int) ( (char) (value0 ) ) ); |
|
280 | if (value0_aux < -8192) value0_aux = -8192; | |
|
281 | aux0 = ( (int) ( ( (unsigned char) (value0_aux / 256) ) << 8 ) ) | |||
|
282 | + ( (int) ( (unsigned char) (value0_aux ) ) ); | |||
169 |
|
283 | |||
170 | aux = (aux1 << 16) + aux0; |
|
284 | aux = (aux1 << 16) + aux0; | |
171 |
|
285 | |||
172 | return aux; |
|
286 | return aux; | |
173 | } |
|
287 | } | |
174 |
|
288 | |||
|
289 | void init_waveform_picker_regs() | |||
|
290 | { // 1 1 0 0 0 BW = 0 => BIAS_WORKS | |||
|
291 | waveform_picker_regs->data_shaping = 0x18; // R1 R0 SP1 SP0 BW | |||
|
292 | waveform_picker_regs->burst_enable = 0x00; // burst f2, f1, f0 enable f3, f2, f1, f0 | |||
|
293 | waveform_picker_regs->addr_data_f0 = (int) (wf_snap_f0); // | |||
|
294 | waveform_picker_regs->addr_data_f1 = (int) (wf_snap_f1); // | |||
|
295 | waveform_picker_regs->addr_data_f2 = (int) (wf_snap_f2); // | |||
|
296 | waveform_picker_regs->addr_data_f3 = (int) (wf_cont_f3); // | |||
|
297 | waveform_picker_regs->status = 0x00; // | |||
|
298 | waveform_picker_regs->delta_snapshot = 0x5; // max 2 bytes | |||
|
299 | waveform_picker_regs->delta_f2_f1 = 0xffff; // max 4 bytes | |||
|
300 | waveform_picker_regs->delta_f2_f0 = 0x17c00; // max 5 bytes | |||
|
301 | waveform_picker_regs->nb_burst_available = 0x180; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets) | |||
|
302 | waveform_picker_regs->nb_snapshot_param = 0x7ff; // max 3 octets, 2048 - 1 | |||
|
303 | //waveform_picker_regs->delta_snapshot = 0x2; // max 2 bytes, = period / 2 | |||
|
304 | //waveform_picker_regs->delta_f2_f1 = 0x2d00; // max 4 bytes | |||
|
305 | //waveform_picker_regs->delta_f2_f0 = 0x2f80; // max 5 bytes | |||
|
306 | //waveform_picker_regs->nb_burst_available = 0x30; // max 3 bytes, size of the buffer in burst (1 burst = 16 x 4 octets) | |||
|
307 | //waveform_picker_regs->nb_snapshot_param = 0xff; // max 3 octets, 256 - 1 | |||
|
308 | } | |||
175 |
|
309 | |||
176 |
|
General Comments 0
You need to be logged in to leave comments.
Login now