##// END OF EJS Templates
Minor updates to use the time management VHDL module
paul@pc-solar1.lab-lpp.local -
r12:334ab051262f default
parent child
Show More
@@ -1,46 +1,46
1 1 <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2 2 <CodeBlocks_layout_file>
3 3 <ActiveTarget name="Debug" />
4 <File name="../header/ccsds_types.h" open="1" top="0" tabpos="3">
4 <File name="../header/ccsds_types.h" open="0" top="0" tabpos="3">
5 5 <Cursor position="3403" topLine="101" />
6 6 </File>
7 7 <File name="../header/fsw_init.h" open="0" top="0" tabpos="3">
8 <Cursor position="899" topLine="0" />
8 <Cursor position="378" topLine="0" />
9 9 </File>
10 10 <File name="../header/fsw_misc.h" open="0" top="0" tabpos="0">
11 11 <Cursor position="114" topLine="0" />
12 12 </File>
13 <File name="../header/fsw_params.h" open="0" top="0" tabpos="0">
14 <Cursor position="2405" topLine="52" />
13 <File name="../header/fsw_params.h" open="0" top="0" tabpos="2">
14 <Cursor position="1358" topLine="31" />
15 15 </File>
16 16 <File name="../header/fsw_processing.h" open="0" top="0" tabpos="0">
17 <Cursor position="576" topLine="0" />
17 <Cursor position="628" topLine="7" />
18 18 </File>
19 <File name="../header/grlib_regs.h" open="0" top="0" tabpos="0">
20 <Cursor position="1072" topLine="0" />
19 <File name="../header/grlib_regs.h" open="0" top="0" tabpos="4">
20 <Cursor position="1153" topLine="11" />
21 21 </File>
22 22 <File name="../header/tc_handler.h" open="0" top="0" tabpos="4">
23 <Cursor position="481" topLine="0" />
23 <Cursor position="624" topLine="2" />
24 24 </File>
25 25 <File name="../header/wf_handler.h" open="0" top="0" tabpos="0">
26 <Cursor position="212" topLine="0" />
26 <Cursor position="318" topLine="0" />
27 27 </File>
28 <File name="../src/fsw_globals.c" open="0" top="0" tabpos="4">
29 <Cursor position="1531" topLine="1" />
28 <File name="../src/fsw_globals.c" open="0" top="0" tabpos="3">
29 <Cursor position="378" topLine="1" />
30 30 </File>
31 31 <File name="../src/fsw_init.c" open="1" top="0" tabpos="1">
32 <Cursor position="9387" topLine="83" />
32 <Cursor position="2303" topLine="54" />
33 33 </File>
34 <File name="../src/fsw_misc.c" open="0" top="0" tabpos="0">
35 <Cursor position="20" topLine="0" />
34 <File name="../src/fsw_misc.c" open="0" top="0" tabpos="2">
35 <Cursor position="475" topLine="0" />
36 36 </File>
37 <File name="../src/fsw_processing.c" open="0" top="0" tabpos="3">
38 <Cursor position="1797" topLine="73" />
37 <File name="../src/fsw_processing.c" open="0" top="0" tabpos="0">
38 <Cursor position="1696" topLine="59" />
39 39 </File>
40 40 <File name="../src/tc_handler.c" open="1" top="1" tabpos="2">
41 <Cursor position="10603" topLine="21" />
41 <Cursor position="17607" topLine="36" />
42 42 </File>
43 <File name="../src/wf_handler.c" open="0" top="0" tabpos="0">
44 <Cursor position="542" topLine="0" />
43 <File name="../src/wf_handler.c" open="0" top="0" tabpos="4">
44 <Cursor position="1660" topLine="24" />
45 45 </File>
46 46 </CodeBlocks_layout_file>
1 NO CONTENT: modified file, binary diff hidden
@@ -1,92 +1,100
1 1 #ifndef FSW_RTEMS_CONFIG_H_INCLUDED
2 2 #define FSW_RTEMS_CONFIG_H_INCLUDED
3 3
4 4 #define GRSPW_DEVICE_NAME "/dev/grspw0"
5 5 #define UART_DEVICE_NAME "/dev/console"
6 6
7 7 //**********
8 8 // LFR MODES
9 9 #define LFR_MODE_STANDBY 0
10 10 #define LFR_MODE_NORMAL 1
11 11 #define LFR_MODE_BURST 2
12 12 #define LFR_MODE_SBM1 3
13 13 #define LFR_MODE_SBM2 4
14 14
15 15 //*****************************
16 16 // APB REGISTERS BASE ADDRESSES
17 17 #define REGS_ADDR_APBUART 0x80000100
18 18 #define REGS_ADDR_GPTIMER 0x80000300
19 19 #define REGS_ADDR_GRSPW 0x80000500
20 20 #define REGS_ADDR_TIME_MANAGEMENT 0x80000600
21 21 #define REGS_ADDR_SPECTRAL_MATRICES 0x80000700
22 22
23 23 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
24
24
25 //**********
26 // IRQ LINES
25 27 #define IRQ_SM 9
26 28 #define IRQ_SPARC_SM 0x19 // see sparcv8.pdf p.76 for interrupt levels
27 29 #define IRQ_WF 10
28 30 #define IRQ_SPARC_WF 0x1a // see sparcv8.pdf p.76 for interrupt levels
31 #define IRQ_TIME1 12
32 #define IRQ_SPARC_TIME1 0x1c // see sparcv8.pdf p.76 for interrupt levels
33 #define IRQ_TIME2 13
34 #define IRQ_SPARC_TIME2 0x1d // see sparcv8.pdf p.76 for interrupt levels
29 35
30 36 #define CLKDIV_SM_SIMULATOR 9999
31 37 #define CLKDIV_WF_SIMULATOR 9999999
32 38 #define TIMER_SM_SIMULATOR 1
33 39 #define TIMER_WF_SIMULATOR 2
34 40
35 41 //******
36 42 // RTEMS
37 43 #define TASKID_RECV 1
38 44 #define TASKID_ACTN 1
39 45 #define TASKID_SPIQ 3
40 46 #define TASKID_SMIQ 4
41 47 #define TASKID_STAT 5
42 48 #define TASKID_AVF0 6
43 49 #define TASKID_BPF0 7
44 50 #define TASKID_WFRM 8
51 #define TASKID_DUMB 9
45 52
46 53 #define ACTION_MSG_QUEUE_COUNT 10
47 54
48 55 //*******
49 56 // MACROS
57 //#define PRINT_TASK_STATISTICS
50 58 #define PRINT_MESSAGES_ON_CONSOLE // enable or disable the printf instructions
51 59 #ifdef PRINT_MESSAGES_ON_CONSOLE
52 60 #define PRINTF(x) printf(x);
53 61 #define PRINTF1(x,y) printf(x,y);
54 62 #define PRINTF2(x,y,z) printf(x,y,z);
55 63 #else
56 64 #define PRINTF(x) ;
57 65 #define PRINTF1(x,y) ;
58 66 #define PRINTF2(x,y,z) ;
59 67 #endif
60 68
61 69 #define NB_SAMPLES_PER_SNAPSHOT 2048
62 70 #define NB_BYTES_SWF_BLK 2 * 6
63 71
64 72 struct param_norm_str{
65 73 unsigned int sy_lfr_n_swf_l; // length of the snapshots
66 74 unsigned int sy_lfr_n_swf_p; // time between two snapshots
67 75 unsigned int sy_lfr_n_asm_p; // time between two asm
68 76 unsigned char sy_lfr_n_bp_p0; // timebetween two products BP1 set
69 77 unsigned char sy_lfr_n_bp_p1; // time between two products BP2 set
70 78 };
71 79
72 80 struct param_burst_str{
73 81 unsigned char sy_lfr_b_bp_p0; // timebetween two products BP1 set
74 82 unsigned char sy_lfr_b_bp_p1; // time between two products BP2 set
75 83 };
76 84
77 85 struct param_sbm1_str{
78 86 unsigned char sy_lfr_s1_bp_p0; // timebetween two products BP1 set
79 87 unsigned char sy_lfr_s1_bp_p1; // time between two products BP2 set
80 88 };
81 89
82 90 struct param_sbm2_str{
83 91 unsigned char sy_lfr_s2_bp_p0; // timebetween two products BP1 set
84 92 unsigned char sy_lfr_s2_bp_p1; // time between two products BP2 set
85 93 };
86 94
87 95 extern volatile int wf_snap_f0[ ]; // 24576 bytes
88 96 extern volatile int wf_snap_f1[ ]; // 24576 bytes
89 97 extern volatile int wf_snap_f2[ ]; // 24576 bytes
90 98 extern volatile int wf_cont_f3[ ]; // 24576 bytes
91 99
92 100 #endif // FSW_RTEMS_CONFIG_H_INCLUDED
@@ -1,63 +1,69
1 1 #ifndef TC_HANDLER_H_INCLUDED
2 2 #define TC_HANDLER_H_INCLUDED
3 3
4 4 #include <rtems.h>
5 5 #include <bsp.h> // for the LEON_Unmask_interrupt function
6 6 #include <stdio.h>
7 7 #include <unistd.h> // for the read call
8 8 #include <sys/ioctl.h> // for the ioctl call
9 9 #include <ccsds_types.h>
10 10 #include <grspw.h>
11 11 #include <fsw_init.h>
12 12
13 13 extern int fdSPW;
14 14 extern rtems_name misc_name[ ];
15 15 extern rtems_name misc_id[ ];
16 16 extern rtems_id Task_id[ ]; // array of task ids
17 17 // MODE PARAMETERS
18 18 extern struct param_norm_str param_norm;
19 19 extern struct param_sbm1_str param_sbm1;
20 20 extern struct param_sbm2_str param_sbm2;
21 21 extern time_management_regs_t *time_management_regs;
22 22 extern unsigned char param_common[];
23 23
24 24 unsigned char currentTC_LEN_RCV[2]; // SHALL be equal to the current TC packet estimated packet length field
25 25 unsigned char currentTC_COMPUTED_CRC[2];
26 26 unsigned int currentTC_LEN_RCV_AsUnsignedInt;
27 27 unsigned int currentTM_length;
28 28 unsigned char currentTC_processedFlag;
29 29
30 //****
31 // ISR
32 rtems_isr commutation_isr1( rtems_vector_number vector );
33 rtems_isr commutation_isr2( rtems_vector_number vector );
34
30 35 //**********************
31 36 // GENERAL USE FUNCTIONS
32 37 unsigned int lookUpTableForCRC[256];
33 38 void initLookUpTableForCRC();
34 39 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData);
35 40
36 41 //*********************
37 42 // ACCEPTANCE FUNCTIONS
38 43 unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int tc_len_recv);
39 44
40 45 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
41 46 unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader);
42 47 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC);
43 48 int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int TC_LEN_RCV);
44 49
45 50 //***********
46 51 // RTEMS TASK
47 52 rtems_task recv_task( rtems_task_argument unused );
48 53 rtems_task actn_task( rtems_task_argument unused );
54 rtems_task dumb_task( rtems_task_argument unused );
49 55 int create_message_queue();
50 56
51 57 //***********
52 58 // TC ACTIONS
53 59 int action_default(ccsdsTelecommandPacket_t *TC);
54 60 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC);
55 61 //
56 62 int action_load_norm(ccsdsTelecommandPacket_t *TC);
57 63 int action_enter(ccsdsTelecommandPacket_t *TC);
58 64 int action_updt_time(ccsdsTelecommandPacket_t *TC);
59 65
60 66 #endif // TC_HANDLER_H_INCLUDED
61 67
62 68
63 69
@@ -1,272 +1,299
1 1 //*************************
2 2 // GPL reminder to be added
3 3 //*************************
4 4
5 5 #include <rtems.h>
6 6
7 7 /* configuration information */
8 8
9 9 #define CONFIGURE_INIT
10 10
11 11 #include <bsp.h> /* for device driver prototypes */
12 12
13 13 /* configuration information */
14 14
15 15 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
16 16 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
17 17
18 18 #define CONFIGURE_MAXIMUM_TASKS 10
19 19 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
20 20 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
21 21 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
22 22 #define CONFIGURE_INIT_TASK_PRIORITY 100
23 23 #define CONFIGURE_MAXIMUM_DRIVERS 16
24 24 #define CONFIGURE_MAXIMUM_PERIODS 1
25 25 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1
26 26
27 27 #include <rtems/confdefs.h>
28 28
29 29 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
30 30 #ifdef RTEMS_DRVMGR_STARTUP
31 31 #ifdef LEON3
32 32 /* Add Timer and UART Driver */
33 33 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
34 34 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
35 35 #endif
36 36 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
37 37 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
38 38 #endif
39 39 #endif
40 40 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
41 41 #include <drvmgr/drvmgr_confdefs.h>
42 42 #endif
43 43
44 44 #include <fsw_init.h>
45 45 #include <fsw_config.c>
46 46
47 47 char *link_status(int status);
48 48
49 49 char *lstates[6] = {"Error-reset",
50 50 "Error-wait",
51 51 "Ready",
52 52 "Started",
53 53 "Connecting",
54 54 "Run"
55 55 };
56 56
57 57 rtems_task Init( rtems_task_argument ignored )
58 58 {
59 rtems_status_code status;
59 rtems_status_code status;
60 rtems_isr_entry old_isr_handler;
60 61
61 62 //send_console_outputs_on_serial_port();
62 63
63 64 initLookUpTableForCRC(); // in tc_handler.h
64 65 init_default_mode_parameters();
65 66 create_message_queue();
66 67 create_all_tasks();
67 68 start_all_tasks();
68 69
69 70 configure_spw_link();
70 71 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
71 72 IRQ_SPARC_SM, spectral_matrices_isr );
72 73 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
73 74 IRQ_SPARC_WF, waveforms_isr );
75
76 // irq handling of the time management unit
77 /*status = rtems_interrupt_catch( commutation_isr1,
78 IRQ_SPARC_TIME1,
79 &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
80 if (status==RTEMS_SUCCESSFUL)
81 PRINTF("commutation_isr1 *** rtems_interrupt_catch successfullly configured\n")
82
83 status = rtems_interrupt_catch( commutation_isr2,
84 IRQ_SPARC_TIME2,
85 &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
86 if (status==RTEMS_SUCCESSFUL)
87 PRINTF("commutation_isr2 *** rtems_interrupt_catch successfullly configured\n")
88
89 LEON_Unmask_interrupt( IRQ_TIME1 );
90 LEON_Unmask_interrupt( IRQ_TIME2 );*/
74 91
75 92 status = rtems_task_delete(RTEMS_SELF);
76 93 }
77 94
78 95 rtems_task spiq_task(rtems_task_argument unused)
79 96 {
80 97 rtems_event_set event_out;
81 98 struct grspw_regs_str *grspw_regs;
82 99 grspw_regs = (struct grspw_regs_str *) REGS_ADDR_GRSPW;
83 100
84 101 while(1){
85 102 PRINTF("In SPIQ *** Waiting for SPW_LINKERR_EVENT\n")
86 103 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
87 104
88 105 if (rtems_task_suspend(Task_id[1])!=RTEMS_SUCCESSFUL) // suspend RECV task
89 106 PRINTF("In SPIQ *** Error suspending RECV Task\n")
90 107
91 108 configure_spw_link();
92 109
93 110 if (rtems_task_restart(Task_id[1], 1)!=RTEMS_SUCCESSFUL) // restart RECV task
94 111 PRINTF("In SPIQ *** Error resume RECV Task\n")
95 112 }
96 113 }
97 114
98 115 void init_default_mode_parameters()
99 116 {
100 117 // COMMON PARAMETERS
101 118 param_common[0] = 0x00;
102 119 param_common[1] = 0x10; // default value 0 0 0 1 0 0 0 0
103 120 // NORMAL MODE
104 121 param_norm.sy_lfr_n_swf_l = 2048; // nb sample
105 122 param_norm.sy_lfr_n_swf_p = 300; // sec
106 123 param_norm.sy_lfr_n_asm_p = 3600; // sec
107 124 param_norm.sy_lfr_n_bp_p0 = 4; // sec
108 125 param_norm.sy_lfr_n_bp_p1 = 20; // sec
109 126 // BURST MODE
110 127 param_burst.sy_lfr_b_bp_p0 = 1; // sec
111 128 param_burst.sy_lfr_b_bp_p1 = 5; // sec
112 129 // SBM1 MODE
113 130 param_sbm1.sy_lfr_s1_bp_p0 = 1; // sec
114 131 param_sbm1.sy_lfr_s1_bp_p1 = 1; // sec
115 132 // SBM2 MODE
116 133 param_sbm2.sy_lfr_s2_bp_p0 = 1; // sec
117 134 param_sbm2.sy_lfr_s2_bp_p0 = 5; // sec
118 135 }
119 136
120 137 int create_all_tasks()
121 138 {
122 139 rtems_status_code status;
123 140
124 141 Task_name[1] = rtems_build_name( 'R', 'E', 'C', 'V' );
125 142 Task_name[2] = rtems_build_name( 'A', 'C', 'T', 'N' );
126 143 Task_name[3] = rtems_build_name( 'S', 'P', 'I', 'Q' );
127 144 Task_name[4] = rtems_build_name( 'S', 'M', 'I', 'Q' );
128 145 Task_name[5] = rtems_build_name( 'S', 'T', 'A', 'T' );
129 146 Task_name[6] = rtems_build_name( 'A', 'V', 'F', '0' );
130 147 Task_name[7] = rtems_build_name( 'B', 'P', 'F', '0' );
131 Task_name[8] = rtems_build_name( 'W', 'F', 'R', 'M' );
148 Task_name[8] = rtems_build_name( 'W', 'F', 'R', 'M' );
149 //Task_name[9] = rtems_build_name( 'D', 'U', 'M', 'B' );
132 150
133 151 // RECV
134 152 status = rtems_task_create(
135 153 Task_name[1], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
136 154 RTEMS_DEFAULT_MODES,
137 155 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[1]
138 156 );
139 157 // ACTN
140 158 status = rtems_task_create(
141 159 Task_name[2], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
142 160 RTEMS_DEFAULT_MODES,
143 161 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[2]
144 162 );
145 163 // SPIQ
146 164 status = rtems_task_create(
147 165 Task_name[3], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
148 166 RTEMS_DEFAULT_MODES,
149 167 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[3]
150 168 );
151 169 // SMIQ
152 170 status = rtems_task_create(
153 171 Task_name[4], 10, RTEMS_MINIMUM_STACK_SIZE * 2,
154 172 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
155 173 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[4]
156 174 );
157 175 // STAT
158 176 status = rtems_task_create(
159 Task_name[5], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
177 Task_name[5], 150, RTEMS_MINIMUM_STACK_SIZE * 2,
160 178 RTEMS_DEFAULT_MODES,
161 179 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[5]
162 180 );
163 181 // AVF0
164 182 status = rtems_task_create(
165 183 Task_name[6], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
166 184 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
167 185 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[6]
168 186 );
169 187 // BPF0
170 188 status = rtems_task_create(
171 189 Task_name[7], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
172 190 RTEMS_DEFAULT_MODES,
173 191 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[7]
174 192 );
175 193 // WFRM
176 194 status = rtems_task_create(
177 195 Task_name[8], 100, RTEMS_MINIMUM_STACK_SIZE * 2,
178 196 RTEMS_DEFAULT_MODES,
179 197 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[8]
180 198 );
199 // DUMB
200 /*status = rtems_task_create(
201 Task_name[9], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
202 RTEMS_DEFAULT_MODES,
203 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[9]
204 );*/
181 205
182 206 return 0;
183 207 }
184 208
185 209 int start_all_tasks()
186 210 {
187 211 rtems_status_code status;
188 212
189 213 status = rtems_task_start( Task_id[3], spiq_task, 1 );
190 214 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_SPIQ\n")
191 215
192 216 status = rtems_task_start( Task_id[1], recv_task, 1 );
193 217 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_RECV\n")
194 218
195 219 status = rtems_task_start( Task_id[2], actn_task, 1 );
196 220 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_ACTN\n")
197 221
198 222 status = rtems_task_start( Task_id[4], smiq_task, 1 );
199 223 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPPR\n")
200 224
201 225 status = rtems_task_start( Task_id[5], stat_task, 1 );
202 226 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_STAT\n")
203 227
204 228 status = rtems_task_start( Task_id[6], avf0_task, 1 );
205 229 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_AVF0\n")
206 230
207 231 status = rtems_task_start( Task_id[7], bpf0_task, 1 );
208 232 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_BPF0\n")
209 233
210 234 status = rtems_task_start( Task_id[8], wfrm_task, 1 );
211 235 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_WFRM\n")
212 236
237 /*status = rtems_task_start( Task_id[9], dumb_task, 1 );
238 if (status!=RTEMS_SUCCESSFUL) PRINTF("In INIT *** Error starting TASK_DUMB\n")*/
239
213 240 return 0;
214 241 }
215 242
216 243 int configure_spw_link()
217 244 {
218 245 rtems_status_code status;
219 246
220 247 close(fdSPW); // close the device if it is already open
221 248 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
222 249 if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
223 250 while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, 0) != RTEMS_SUCCESSFUL){
224 251 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" not started, retry\n")
225 252 close(fdSPW); // close the device
226 253 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
227 254 if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
228 255 rtems_task_wake_after(100);
229 256 }
230 257
231 258 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n")
232 259
233 260 // sets a few parameters of the link
234 261 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RMAPEN, 1); // sets the RMAP enable bit
235 262 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RMAPEN\n")
236 263 //
237 264 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
238 265 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
239 266 //
240 267 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[3]); // sets the task ID to which an event is sent when a
241 268 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
242 269 //
243 270 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 1); // automatic link-disabling due to link-error interrupts
244 271 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
245 272 //
246 273 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
247 274 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
248 275
249 276 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // sets the link-error interrupt bit
250 277 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
251 278 //
252 279 //status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DESTKEY, CCSDS_DESTINATION_ID); // sets the destination key
253 280 //if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
254 281 //
255 282 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" configured successfully\n")
256 283
257 284 return RTEMS_SUCCESSFUL;
258 285 }
259 286
260 287 char *link_status(int status){
261 288 return lstates[status];
262 289 }
263 290
264 291 rtems_status_code write_spw(spw_ioctl_pkt_send* spw_ioctl_send)
265 292 {
266 293 rtems_status_code status;
267 294 status = ioctl( fdSPW, SPACEWIRE_IOCTRL_SEND, spw_ioctl_send );
268 295 if (status!=RTEMS_SUCCESSFUL) printf("In write_spw *** Error SPACEWIRE_IOCTRL_SEND\n");
269 296 return status;
270 297 }
271 298
272 299
@@ -1,73 +1,75
1 1 #include <fsw_misc.h>
2 2 #include <fsw_params.h>
3 3
4 4 extern rtems_id Task_id[]; /* array of task ids */
5 5 extern int fdSPW;
6 6
7 7 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
8 8 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
9 9 { // configure the timer for the waveforms simulation
10 10 rtems_status_code status;
11 11 rtems_isr_entry old_isr_handler;
12 12
13 13 status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
14 14 //if (status==RTEMS_SUCCESSFUL) PRINTF("In configure_timer_for_wf_simulation *** rtems_interrupt_catch successfullly configured\n")
15 15
16 16 gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz
17 17 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any
18 18 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register
19 19 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer
20 20 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart
21 21 gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable
22 22
23 23 return 1;
24 24 }
25 25
26 26 void print_statistics(spw_stats *stats)
27 27 {
28 28 //printf(" ******** STATISTICS ******** \n");
29 29 printf("Transmit link errors: %i\n", stats->tx_link_err);
30 30 printf("Receiver RMAP header CRC errors: %i\n", stats->rx_rmap_header_crc_err);
31 31 printf("Receiver RMAP data CRC errors: %i\n", stats->rx_rmap_data_crc_err);
32 32 printf("Receiver EEP errors: %i\n", stats->rx_eep_err);
33 33 printf("Receiver truncation errors: %i\n", stats->rx_truncated);
34 34 printf("Parity errors: %i\n", stats->parity_err);
35 35 printf("Escape errors: %i\n", stats->escape_err);
36 36 printf("Credit errors: %i\n", stats->credit_err);
37 37 printf("Disconnect errors: %i\n", stats->disconnect_err);
38 38 printf("Write synchronization errors: %i\n", stats->write_sync_err);
39 39 printf("Early EOP/EEP: %i\n", stats->early_ep);
40 40 printf("Invalid Node Address: %i\n", stats->invalid_address);
41 41 printf("Packets transmitted: %i\n", stats->packets_sent);
42 42 printf("Packets received: %i\n", stats->packets_received);
43 43 }
44 44
45 45 int send_console_outputs_on_serial_port() // Send the console outputs on the serial port
46 46 {
47 47 struct apbuart_regs_str *apbuart_regs;
48 48
49 49 apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART;
50 50 apbuart_regs->ctrl = apbuart_regs->ctrl & APBUART_CTRL_REG_MASK_DB;
51 51 PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
52 52
53 53 return 0;
54 54 }
55 55
56 56 rtems_task stat_task(rtems_task_argument argument)
57 57 {
58 58 int i;
59 59 i = 0;
60 60 PRINTF("In STAT *** \n")
61 61 while(1){
62 62 rtems_task_wake_after(1000);
63 63 PRINTF1("%d\n", i)
64 if (i == 2) {
64 if (i == 2) {
65 #ifdef PRINT_TASK_STATISTICS
65 66 rtems_cpu_usage_report();
66 rtems_cpu_usage_reset();
67 rtems_cpu_usage_reset();
68 #endif
67 69 i = 0;
68 70 }
69 71 else i++;
70 72 }
71 73 }
72 74
73 75
@@ -1,427 +1,447
1 1 #include <fsw_processing.h>
2 2 #include <math.h>
3 #include <stdio.h>
3 #include <stdio.h>
4 #include <stdlib.h>
4 5 #include <leon.h>
6
7 // TOTAL = 32 coefficients * 4 = 128 octets * 3 * 12 = 4608 octets
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;
5 44
6 float k14_re = 1;
7 float k14_im = 1;
8 float k14_bis_re = 1;
9 float k14_bis_im = 1;
10 float k14_tris_re = 1;
11 float k14_tris_im = 1;
12 float k15_re = 1;
13 float k15_im = 1;
14 float k15_bis_re = 1;
15 float k15_bis_im = 1;
16 float k24_re = 1;
17 float k24_im = 1;
18 float k24_bis_re = 1;
19 float k24_bis_im = 1;
20 float k24_tris_re = 1;
21 float k24_tris_im = 1;
22 float k25_re = 1;
23 float k25_im = 1;
24 float k25_bis_re = 1;
25 float k25_bis_im = 1;
26 float k34_re = 1;
27 float k34_im = 1;
28 float k44 = 1;
29 float k55 = 1;
30 float k45_re = 1;
31 float k45_im = 1;
32 45 float alpha_M = M_PI/4;
33 46
34 47 extern volatile int spec_mat_f0_a[ ];
35 48 extern volatile int spec_mat_f0_b[ ];
36 49 extern volatile int spec_mat_f0_c[ ];
37 50 extern volatile int spec_mat_f0_d[ ];
38 51 extern volatile int spec_mat_f0_e[ ];
39 52 extern volatile int spec_mat_f0_f[ ];
40 53 extern volatile int spec_mat_f0_g[ ];
41 54 extern volatile int spec_mat_f0_h[ ];
42 55 extern float averaged_spec_mat_f0[ ];
43 56 extern float compressed_spec_mat_f0[ ];
44 57 extern unsigned char LFR_BP1_F0[ ];
45 58
46 59 extern BP1_t data_BP1[ ];
47 60
48 61 extern rtems_id Task_id[ ]; /* array of task ids */
49 62
50 63 spectral_matrices_regs_t *spectral_matrices_regs;
51 64
52 65 // Interrupt Service Routine for spectral matrices processing
53 66 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
54 67 {
55 68 if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
56 69 printf("In spectral_matrices_isr *** Error sending event to AVF0\n");
57 70 }
58 71
59 72 rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
60 73 {
61 74 rtems_event_set event_out;
62 75 gptimer_regs_t *gptimer_regs;
63 76 gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
64 77 unsigned char nb_interrupt_f0 = 0;
65 78
66 79 PRINTF("In SMIQ *** \n")
67 80
68 81 while(1){
69 82 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
70 83 nb_interrupt_f0 = nb_interrupt_f0 + 1;
71 84 if (nb_interrupt_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) ){
72 85 if (rtems_event_send( Task_id[6], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
73 86 printf("In smiq_task *** Error sending event to AVF0\n");
74 87 nb_interrupt_f0 = 0;
75 88 }
76 89 gptimer_regs->timer[1].ctrl = gptimer_regs->timer[1].ctrl | 0x00000010;
77 90 }
78 91 }
79 92
80 93 rtems_task spw_bppr_task(rtems_task_argument argument)
81 94 {
82 95 rtems_status_code status;
83 96 rtems_event_set event_out;
84 97 static int nb_average_f0 = 0;
85 98 //static int nb_average_f1 = 0;
86 99 //static int nb_average_f2 = 0;
87 100
88 101 while(1)
89 102
90 103 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES;
91 104 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
92 105 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
93 106
94 107 printf("In BPPR ***\n");
95 108
96 109 while(1){ // wait for an event to begin with the processing
97 110 status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out);
98 111 if (status == RTEMS_SUCCESSFUL){
99 112 if ((spectral_matrices_regs->ctrl & 0x00000001)==1){
100 113 matrix_average(spec_mat_f0_a, averaged_spec_mat_f0);
101 114 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe;
102 115 //printf("f0_a\n");
103 116 nb_average_f0++;
104 117 }
105 118 if (((spectral_matrices_regs->ctrl>>1) & 0x00000001)==1){
106 119 matrix_average(spec_mat_f0_b, compressed_spec_mat_f0);
107 120 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffd;
108 121 //printf("f0_b\n");
109 122 nb_average_f0++;
110 123 }
111 124 if (nb_average_f0 == NB_AVERAGE_NORMAL_f0){
112 125 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
113 126 //printf("f0 compressed\n");
114 127 nb_average_f0 = 0;
115 128 matrix_reset(averaged_spec_mat_f0);
116 129 }
117 130 }
118 131 }
119 132 }
120 133
121 134 void matrix_average(volatile int *spec_mat, float *averaged_spec_mat)
122 135 {
123 136 int i;
124 137 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
125 138 averaged_spec_mat[i] = averaged_spec_mat[i] + spec_mat_f0_a[i]
126 139 + spec_mat_f0_b[i]
127 140 + spec_mat_f0_c[i]
128 141 + spec_mat_f0_d[i]
129 142 + spec_mat_f0_e[i]
130 143 + spec_mat_f0_f[i]
131 144 + spec_mat_f0_g[i]
132 145 + spec_mat_f0_h[i];
133 146 }
134 147 }
135 148
136 149 void matrix_reset(float *averaged_spec_mat)
137 150 {
138 151 int i;
139 152 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
140 153 averaged_spec_mat_f0[i] = 0;
141 154 }
142 155 }
143 156
144 157 void matrix_compression(float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat)
145 158 {
146 159 int i, j;
147 160 switch (fChannel){
148 161 case 0:
149 162 for(i=0;i<NB_BINS_COMPRESSED_MATRIX_f0;i++){
150 163 j = 17 + i * 8;
151 164 compressed_spec_mat[i] = (averaged_spec_mat[j]
152 165 + averaged_spec_mat[j+1]
153 166 + averaged_spec_mat[j+2]
154 167 + averaged_spec_mat[j+3]
155 168 + averaged_spec_mat[j+4]
156 169 + averaged_spec_mat[j+5]
157 170 + averaged_spec_mat[j+6]
158 171 + averaged_spec_mat[j+7])/(8*NB_AVERAGE_NORMAL_f0);
159 172 }
160 173 break;
161 174 case 1:
162 175 // case fChannel = f1 tp be completed later
163 176 break;
164 177 case 2:
165 178 // case fChannel = f1 tp be completed later
166 179 break;
167 180 default:
168 181 break;
169 182 }
170 183 }
171 184
172 185 void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1){
173 186 int i, j;
174 187 unsigned char tmp_u_char;
175 188 unsigned char * pt_char;
176 189 float PSDB, PSDE;
177 190 float NVEC_V0, NVEC_V1, NVEC_V2;
178 float significand;
179 int exponent;
191 //float significand;
192 //int exponent;
180 193 float aux, tr_SB_SB, tmp;
181 float e_cross_b_re, e_cross_b_im;
182 float n_cross_e_scal_b_re = 0, n_cross_e_scal_b_im = 0;
183 float nx = 0, ny = 0;
184 float bz_bz_star = 0;
194 float sx_re, sx_im;
195 float nebx_re = 0, nebx_im = 0;
196 float ny = 0, nz = 0;
197 float bx_bx_star = 0;
185 198 for(i=0; i<nb_bins_compressed_spec_mat; i++){
186 199 //==============================================
187 200 // BP1 PSD == B PAR_LFR_SC_BP1_PE_FL0 == 16 bits
188 201 PSDB = compressed_spec_mat[i*30] // S11
189 202 + compressed_spec_mat[i*30+10] // S22
190 203 + compressed_spec_mat[i*30+18]; // S33
191 significand = frexp(PSDB, &exponent);
204 //significand = frexp(PSDB, &exponent);
192 205 pt_char = (unsigned char*) &PSDB;
193 LFR_BP1[i*9+8] = pt_char[0]; // bits 31 downto 24 of the float
194 LFR_BP1[i*9+7] = pt_char[1]; // bits 23 downto 16 of the float
206 LFR_BP1[i*9+2] = pt_char[0]; // bits 31 downto 24 of the float
207 LFR_BP1[i*9+3] = pt_char[1]; // bits 23 downto 16 of the float
195 208 //==============================================
196 209 // BP1 PSD == E PAR_LFR_SC_BP1_PB_FL0 == 16 bits
197 PSDE = compressed_spec_mat[i*30+24] * k44 // S44
198 + compressed_spec_mat[i*30+28] * k55 // S55
199 + compressed_spec_mat[i*30+26] * k45_re // S45
200 - compressed_spec_mat[i*30+27] * k45_im; // S45
210 PSDE = compressed_spec_mat[i*30+24] * k44_pe // S44
211 + compressed_spec_mat[i*30+28] * k55_pe // S55
212 + compressed_spec_mat[i*30+26] * k45_pe_re // S45
213 - compressed_spec_mat[i*30+27] * k45_pe_im; // S45
201 214 pt_char = (unsigned char*) &PSDE;
202 LFR_BP1[i*9+6] = pt_char[0]; // bits 31 downto 24 of the float
203 LFR_BP1[i*9+5] = pt_char[1]; // bits 23 downto 16 of the float
215 LFR_BP1[i*9+0] = pt_char[0]; // bits 31 downto 24 of the float
216 LFR_BP1[i*9+1] = pt_char[1]; // bits 23 downto 16 of the float
204 217 //==============================================================================
205 218 // BP1 normal wave vector == PAR_LFR_SC_BP1_NVEC_V0_F0 == 8 bits
206 219 // == PAR_LFR_SC_BP1_NVEC_V1_F0 == 8 bits
207 220 // == PAR_LFR_SC_BP1_NVEC_V2_F0 == 1 bits
208 221 tmp = sqrt(
209 222 compressed_spec_mat[i*30+3]*compressed_spec_mat[i*30+3] //Im S12
210 223 +compressed_spec_mat[i*30+5]*compressed_spec_mat[i*30+5] //Im S13
211 +compressed_spec_mat[i*30+5]*compressed_spec_mat[i*30+13] //Im S23
224 +compressed_spec_mat[i*30+13]*compressed_spec_mat[i*30+13] //Im S23
212 225 );
213 226 NVEC_V0 = compressed_spec_mat[i*30+13] / tmp; // Im S23
214 227 NVEC_V1 = -compressed_spec_mat[i*30+5] / tmp; // Im S13
215 NVEC_V2 = compressed_spec_mat[i*30+1] / tmp; // Im S12
216 LFR_BP1[i*9+4] = (char) (NVEC_V0*256);
217 LFR_BP1[i*9+3] = (char) (NVEC_V1*256);
228 NVEC_V2 = compressed_spec_mat[i*30+3] / tmp; // Im S12
229 LFR_BP1[i*9+4] = (char) (NVEC_V0*127);
230 LFR_BP1[i*9+5] = (char) (NVEC_V1*127);
218 231 pt_char = (unsigned char*) &NVEC_V2;
219 LFR_BP1[i*9+2] = pt_char[0] & 0x80; // extract the sign of NVEC_V2
232 LFR_BP1[i*9+6] = pt_char[0] & 0x80; // extract the sign of NVEC_V2
220 233 //=======================================================
221 234 // BP1 ellipticity == PAR_LFR_SC_BP1_ELLIP_F0 == 4 bits
222 235 aux = 2*tmp / PSDB; // compute the ellipticity
223 236 tmp_u_char = (unsigned char) (aux*(16-1)); // convert the ellipticity
224 LFR_BP1[i*9+2] = LFR_BP1[i*9+2] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char
237 LFR_BP1[i*9+6] = LFR_BP1[i*9+6] | ((tmp_u_char&0x0f)<<3); // keeps 4 bits of the resulting unsigned char
225 238 //==============================================================
226 239 // BP1 degree of polarization == PAR_LFR_SC_BP1_DOP_F0 == 3 bits
227 240 for(j = 0; j<NB_VALUES_PER_spec_mat;j++){
228 tr_SB_SB = compressed_spec_mat[i*30]*compressed_spec_mat[i*30]
229 + compressed_spec_mat[i*30+10]*compressed_spec_mat[i*30+10]
230 + compressed_spec_mat[i*30+18]*compressed_spec_mat[i*30+18]
231 + 2 * compressed_spec_mat[i*30+2]*compressed_spec_mat[i*30+2]
232 + 2 * compressed_spec_mat[i*30+3]*compressed_spec_mat[i*30+3]
233 + 2 * compressed_spec_mat[i*30+4]*compressed_spec_mat[i*30+4]
234 + 2 * compressed_spec_mat[i*30+5]*compressed_spec_mat[i*30+5]
235 + 2 * compressed_spec_mat[i*30+12]*compressed_spec_mat[i*30+12]
236 + 2 * compressed_spec_mat[i*30+13]*compressed_spec_mat[i*30+13];
241 tr_SB_SB = compressed_spec_mat[i*30] * compressed_spec_mat[i*30]
242 + compressed_spec_mat[i*30+10] * compressed_spec_mat[i*30+10]
243 + compressed_spec_mat[i*30+18] * compressed_spec_mat[i*30+18]
244 + 2 * compressed_spec_mat[i*30+2] * compressed_spec_mat[i*30+2]
245 + 2 * compressed_spec_mat[i*30+3] * compressed_spec_mat[i*30+3]
246 + 2 * compressed_spec_mat[i*30+4] * compressed_spec_mat[i*30+4]
247 + 2 * compressed_spec_mat[i*30+5] * compressed_spec_mat[i*30+5]
248 + 2 * compressed_spec_mat[i*30+12] * compressed_spec_mat[i*30+12]
249 + 2 * compressed_spec_mat[i*30+13] * compressed_spec_mat[i*30+13];
237 250 }
238 251 aux = PSDB*PSDB;
239 tmp = ( 3*tr_SB_SB - aux ) / ( 2 * aux );
252 tmp = sqrt( abs( ( 3*tr_SB_SB - aux ) / ( 2 * aux ) ) );
240 253 tmp_u_char = (unsigned char) (NVEC_V0*(8-1));
241 LFR_BP1[i*9+2] = LFR_BP1[i*9+2] | ((tmp_u_char&0x07)); // keeps 3 bits of the resulting unsigned char
254 LFR_BP1[i*9+6] = LFR_BP1[i*9+6] | (tmp_u_char & 0x07); // keeps 3 bits of the resulting unsigned char
242 255 //=======================================================================================
243 // BP1 z-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1)
244 e_cross_b_re = compressed_spec_mat[i*30+20]*k34_re
245 + compressed_spec_mat[i*30+6]*k14_re
246 + compressed_spec_mat[i*30+8]*k15_re
247 + compressed_spec_mat[i*30+14]*k24_re
248 + compressed_spec_mat[i*30+16]*k25_re;
249 e_cross_b_im = compressed_spec_mat[i*30+21]*k34_im
250 + compressed_spec_mat[i*30+7]*k14_im
251 + compressed_spec_mat[i*30+9]*k15_im
252 + compressed_spec_mat[i*30+15]*k24_im
253 + compressed_spec_mat[i*30+17]*k25_im;
254 tmp = e_cross_b_re / PSDE; // compute ReaSz
255 LFR_BP1[i*9+1] = ((unsigned char) (tmp * 128)) & 0x7f; // is it always positive?
256 tmp = e_cross_b_re * e_cross_b_im;
257 pt_char = (unsigned char*) &tmp;
258 LFR_BP1[i*9+1] = LFR_BP1[i*9+1] | (pt_char[0] & 0x80); // extract the sign of ArgSz
256 // BP1 x-component of the normalized Poynting flux == PAR_LFR_SC_BP1_SZ_F0 == 8 bits (7+1)
257 sx_re = compressed_spec_mat[i*30+20] * k34_sx_re
258 + compressed_spec_mat[i*30+6] * k14_sx_re
259 + compressed_spec_mat[i*30+8] * k15_sx_re
260 + compressed_spec_mat[i*30+14] * k24_sx_re
261 + compressed_spec_mat[i*30+16] * k25_sx_re
262 + compressed_spec_mat[i*30+22] * k35_sx_re;
263 sx_im = compressed_spec_mat[i*30+21] * k34_sx_im
264 + compressed_spec_mat[i*30+7] * k14_sx_im
265 + compressed_spec_mat[i*30+9] * k15_sx_im
266 + compressed_spec_mat[i*30+15] * k24_sx_im
267 + compressed_spec_mat[i*30+17] * k25_sx_im
268 + compressed_spec_mat[i*30+23] * k35_sx_im;
269 LFR_BP1[i*9+7] = ((unsigned char) (sx_re * 128)) & 0x7f; // cf DOC for the compression
270 if ( abs(sx_re) > abs(sx_im) )
271 LFR_BP1[i*9+7] = LFR_BP1[i*9+1] | (0x80); // extract the sector of sx
272 else
273 LFR_BP1[i*9+7] = LFR_BP1[i*9+1] & (0x7f); // extract the sector of sx
259 274 //======================================================================
260 275 // BP1 phase velocity estimator == PAR_LFR_SC_BP1_VPHI_F0 == 8 bits (7+1)
261 nx = -sin(alpha_M)*NVEC_V0 - cos(alpha_M)*NVEC_V1;
262 ny = NVEC_V2;
263 bz_bz_star = cos(alpha_M) * cos(alpha_M) * compressed_spec_mat[i*30] // re S11
264 + sin(alpha_M) * sin(alpha_M) * compressed_spec_mat[i*30+10] // re S22
265 - 2 * sin(alpha_M) * cos(alpha_M) * compressed_spec_mat[i*30+2]; // re S12
266 n_cross_e_scal_b_re = nx * (compressed_spec_mat[i*30+8]*k15_bis_re
267 +compressed_spec_mat[i*30+6]*k14_bis_re
268 +compressed_spec_mat[i*30+16]*k25_bis_re
269 +compressed_spec_mat[i*30+14]*k24_bis_re)
270 + ny * (compressed_spec_mat[i*30+6]*k14_tris_re
271 +compressed_spec_mat[i*30+14]*k24_tris_re);
272 n_cross_e_scal_b_im = nx * (compressed_spec_mat[i*30+8]*k15_bis_im
273 +compressed_spec_mat[i*30+6]*k14_bis_im
274 +compressed_spec_mat[i*30+16]*k25_bis_im
275 +compressed_spec_mat[i*30+14]*k24_bis_im)
276 + ny * (compressed_spec_mat[i*30+6]*k14_tris_im
277 +compressed_spec_mat[i*30+14]*k24_tris_im);
278 tmp = n_cross_e_scal_b_re / bz_bz_star;
279 LFR_BP1[i*9+0] = ((unsigned char) (tmp * 128)) & 0x7f; // is it always positive?
280 tmp = n_cross_e_scal_b_re * n_cross_e_scal_b_im;
281 pt_char = (unsigned char*) &tmp;
282 LFR_BP1[i*9+1] = LFR_BP1[i*9+0] | (pt_char[0] & 0x80); // extract the sign of ArgV
276 ny = sin(alpha_M)*NVEC_V1 + cos(alpha_M)*NVEC_V2;
277 nz = NVEC_V0;
278 bx_bx_star = cos(alpha_M) * cos(alpha_M) * compressed_spec_mat[i*30+10] // re S22
279 + sin(alpha_M) * sin(alpha_M) * compressed_spec_mat[i*30+18] // re S33
280 - 2 * sin(alpha_M) * cos(alpha_M) * compressed_spec_mat[i*30+12]; // re S23
281 nebx_re = ny * (compressed_spec_mat[i*30+14] * k24_ny_re
282 +compressed_spec_mat[i*30+16] * k25_ny_re
283 +compressed_spec_mat[i*30+20] * k34_ny_re
284 +compressed_spec_mat[i*30+22] * k35_ny_re)
285 + nz * (compressed_spec_mat[i*30+14] * k24_nz_re
286 +compressed_spec_mat[i*30+16] * k25_nz_re
287 +compressed_spec_mat[i*30+20] * k34_nz_re
288 +compressed_spec_mat[i*30+22] * k35_nz_re);
289 nebx_im = ny * (compressed_spec_mat[i*30+15]*k24_ny_re
290 +compressed_spec_mat[i*30+17] * k25_ny_re
291 +compressed_spec_mat[i*30+21] * k34_ny_re
292 +compressed_spec_mat[i*30+23] * k35_ny_re)
293 + nz * (compressed_spec_mat[i*30+15] * k24_nz_im
294 +compressed_spec_mat[i*30+17] * k25_nz_im
295 +compressed_spec_mat[i*30+21] * k34_nz_im
296 +compressed_spec_mat[i*30+23] * k35_nz_im);
297 tmp = nebx_re / bx_bx_star;
298 LFR_BP1[i*9+8] = ((unsigned char) (tmp * 128)) & 0x7f; // cf DOC for the compression
299 if ( abs(nebx_re) > abs(nebx_im) )
300 LFR_BP1[i*9+8] = LFR_BP1[i*9+8] | (0x80); // extract the sector of nebx
301 else
302 LFR_BP1[i*9+8] = LFR_BP1[i*9+8] & (0x7f); // extract the sector of nebx
283 303 }
284 304
285 305 }
286 306
287 307 void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat){
288 308 // BP2 autocorrelation
289 309 int i, aux = 0;
290 310 for(i = 0; i<nb_bins_compressed_spec_mat; i++){
291 311 // S12
292 312 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+10]);
293 313 compressed_spec_mat[i*30+2] = compressed_spec_mat[i*30+2] / aux;
294 314 compressed_spec_mat[i*30+3] = compressed_spec_mat[i*30+3] / aux;
295 315 // S13
296 316 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+18]);
297 317 compressed_spec_mat[i*30+4] = compressed_spec_mat[i*30+4] / aux;
298 318 compressed_spec_mat[i*30+5] = compressed_spec_mat[i*30+5] / aux;
299 319 // S23
300 320 aux = sqrt(compressed_spec_mat[i*30+12]*compressed_spec_mat[i*30+18]);
301 321 compressed_spec_mat[i*30+12] = compressed_spec_mat[i*30+12] / aux;
302 322 compressed_spec_mat[i*30+13] = compressed_spec_mat[i*30+13] / aux;
303 323 // S45
304 324 aux = sqrt(compressed_spec_mat[i*30+24]*compressed_spec_mat[i*30+28]);
305 325 compressed_spec_mat[i*30+26] = compressed_spec_mat[i*30+26] / aux;
306 326 compressed_spec_mat[i*30+27] = compressed_spec_mat[i*30+27] / aux;
307 327 // S14
308 328 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+24]);
309 329 compressed_spec_mat[i*30+6] = compressed_spec_mat[i*30+6] / aux;
310 330 compressed_spec_mat[i*30+7] = compressed_spec_mat[i*30+7] / aux;
311 331 // S15
312 332 aux = sqrt(compressed_spec_mat[i*30]*compressed_spec_mat[i*30+28]);
313 333 compressed_spec_mat[i*30+8] = compressed_spec_mat[i*30+8] / aux;
314 334 compressed_spec_mat[i*30+9] = compressed_spec_mat[i*30+9] / aux;
315 335 // S24
316 336 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[i*30+24]);
317 337 compressed_spec_mat[i*30+14] = compressed_spec_mat[i*30+14] / aux;
318 338 compressed_spec_mat[i*30+15] = compressed_spec_mat[i*30+15] / aux;
319 339 // S25
320 340 aux = sqrt(compressed_spec_mat[i*10]*compressed_spec_mat[i*30+28]);
321 341 compressed_spec_mat[i*30+16] = compressed_spec_mat[i*30+16] / aux;
322 342 compressed_spec_mat[i*30+17] = compressed_spec_mat[i*30+17] / aux;
323 343 // S34
324 344 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[i*30+24]);
325 345 compressed_spec_mat[i*30+20] = compressed_spec_mat[i*30+20] / aux;
326 346 compressed_spec_mat[i*30+21] = compressed_spec_mat[i*30+21] / aux;
327 347 // S35
328 348 aux = sqrt(compressed_spec_mat[i*18]*compressed_spec_mat[i*30+28]);
329 349 compressed_spec_mat[i*30+22] = compressed_spec_mat[i*30+22] / aux;
330 350 compressed_spec_mat[i*30+23] = compressed_spec_mat[i*30+23] / aux;
331 351 }
332 352 }
333 353
334 354 rtems_task avf0_task(rtems_task_argument argument){
335 355 int i;
336 356 static int nb_average;
337 357 rtems_event_set event_out;
338 358 rtems_status_code status;
339 359
340 360 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES;
341 361 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
342 362 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
343 363
344 364 nb_average = 0;
345 365
346 366 PRINTF("In AVFO *** \n")
347 367
348 368 while(1){
349 369 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
350 370 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
351 371 averaged_spec_mat_f0[i] = averaged_spec_mat_f0[i] + spec_mat_f0_a[i]
352 372 + spec_mat_f0_b[i]
353 373 + spec_mat_f0_c[i]
354 374 + spec_mat_f0_d[i]
355 375 + spec_mat_f0_e[i]
356 376 + spec_mat_f0_f[i]
357 377 + spec_mat_f0_g[i]
358 378 + spec_mat_f0_h[i];
359 379 }
360 380 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe; // reset the appropriate bit in the register
361 381 nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0;
362 382 if (nb_average == NB_AVERAGE_NORMAL_f0) {
363 383 nb_average = 0;
364 384 status = rtems_event_send( Task_id[7], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0
365 385 if (status != RTEMS_SUCCESSFUL) printf("IN TASK AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
366 386 }
367 387 }
368 388 }
369 389
370 390 rtems_task bpf0_task(rtems_task_argument argument){
371 391 rtems_event_set event_out;
372 392
373 393 PRINTF("In BPFO *** \n")
374 394
375 395 while(1){
376 396 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
377 397 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
378 398 BP1_set(compressed_spec_mat_f0, NB_BINS_COMPRESSED_MATRIX_f0, LFR_BP1_F0);
379 399 //PRINTF("IN TASK BPF0 *** Matrix compressed, parameters calculated\n")
380 400 }
381 401 }
382 402
383 403 //*******
384 404 // UNUSED
385 405 rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument)
386 406 {/*
387 407 rtems_status_code status;
388 408 //static int nb_average_f1 = 0;
389 409 //static int nb_average_f2 = 0;
390 410
391 411 rtems_name name;
392 412 rtems_id period;
393 413 name = rtems_build_name( 'P', 'E', 'R', 'D' );
394 414 status = rtems_rate_monotonic_create( name, &period );
395 415 if( status != RTEMS_SUCCESSFUL ) {
396 416 printf( "rtems_rate_monotonic_create failed with status of %d\n", status );
397 417 //exit( 1 );
398 418 }
399 419
400 420 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES;
401 421 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
402 422 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
403 423
404 424 printf("In BPPR BIS ***\n");
405 425
406 426 while(1){ // launch the rate monotonic task
407 427 if ( rtems_rate_monotonic_period( period, 8 ) == RTEMS_TIMEOUT ){
408 428 printf("TIMEOUT\n");
409 429 //break;
410 430 }
411 431 status = rtems_event_send( Task_id[6], RTEMS_EVENT_0 ); // sending an event to the task 6, AVF0
412 432 if (status != RTEMS_SUCCESSFUL) printf("IN TASK BPPR BIS *** Error sending RTEMS_EVENT_0 to AVF0, code %d\n", status);
413 433 }
414 434
415 435 status = rtems_rate_monotonic_delete( period );
416 436 if ( status != RTEMS_SUCCESSFUL ) {
417 437 printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status );
418 438 //exit( 1 );
419 439 }
420 440 status = rtems_task_delete( RTEMS_SELF ); // should not return
421 441 printf( "rtems_task_delete returned with status of %d.\n", status );
422 442 //exit( 1 );*/
423 443 }
424 444
425 445
426 446
427 447
@@ -1,489 +1,520
1 1 #include <tc_handler.h>
2 2 #include <fsw_params.h>
3 3
4 4 char *errorCCSDSMsg[8] = { "ILLEGAL_APID 0",
5 5 "WRONG_LEN_PACKET 1",
6 6 "INCOR_CHECKSUM 2",
7 7 "ILL_TYPE 3",
8 8 "ILL_SUBTYPE 4",
9 9 "WRONG_APP_DATA 5",
10 10 "WRONG_CMD_CODE 6",
11 11 "CCSDS_TM_VALID 7"
12 12 };
13 13
14 14 //**********************
15 15 // GENERAL USE FUNCTIONS
16 16 unsigned int Crc_opt( unsigned char D, unsigned int Chk)
17 17 {
18 18 return(((Chk << 8) & 0xff00)^lookUpTableForCRC [(((Chk >> 8)^D) & 0x00ff)]);
19 19 }
20 20
21 21 void initLookUpTableForCRC()
22 22 {
23 23 unsigned int i, tmp;
24 24 for (i=0; i<256; i++)
25 25 {
26 26 tmp = 0;
27 27 if((i & 1) != 0) tmp = tmp ^ 0x1021;
28 28 if((i & 2) != 0) tmp = tmp ^ 0x2042;
29 29 if((i & 4) != 0) tmp = tmp ^ 0x4084;
30 30 if((i & 8) != 0) tmp = tmp ^ 0x8108;
31 31 if((i & 16) != 0) tmp = tmp ^ 0x1231;
32 32 if((i & 32) != 0) tmp = tmp ^ 0x2462;
33 33 if((i & 64) != 0) tmp = tmp ^ 0x48c4;
34 34 if((i & 128) != 0) tmp = tmp ^ 0x9188;
35 35 lookUpTableForCRC[i] = tmp;
36 36 }
37 37 }
38 38
39 39 void GetCRCAsTwoBytes(unsigned char* data, unsigned char* crcAsTwoBytes, unsigned int sizeOfData)
40 40 {
41 41 unsigned int Chk;
42 42 int j;
43 43 Chk = 0xffff; // reset the syndrom to all ones
44 44 for (j=0; j<sizeOfData; j++) {
45 45 Chk = Crc_opt(data[j], Chk);
46 46 }
47 47 crcAsTwoBytes[0] = (unsigned char) (Chk >> 8);
48 48 crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff);
49 49 }
50 50
51 51
52 52 //*********************
53 53 // ACCEPTANCE FUNCTIONS
54 54 int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv)
55 55 {
56 56 rtems_status_code status;
57 57 spw_ioctl_pkt_send spw_ioctl_send;
58 58 TMHeader_t TM_header;
59 59 unsigned int code = 0;
60 60 unsigned char computed_CRC[2];
61 61 char data[ TM_LEN_EXE_CORR + CCSDS_TC_TM_PACKET_OFFSET - TM_HEADER_LEN ];
62 62
63 63 GetCRCAsTwoBytes( (unsigned char*) TC->packetID, computed_CRC, tc_len_recv + 5 );
64 64 code = acceptTM( TC, tc_len_recv ) ;
65 65 if ( (code == 0) | (code == 1) | (code == 2)
66 66 | (code == 3) | (code == 4) | (code == 5) )
67 67 { // generate TM_LFR_TC_EXE_CORRUPTED
68 68 // BUILD HEADER
69 69 TM_build_header( TM_LFR_TC_EXE_ERR, TM_LEN_EXE_CORR, 0, 0, &TM_header);
70 70 // BUILD DATA
71 71 TM_build_data( TC, data, SID_EXE_CORR, computed_CRC);
72 72 // PREPARE TM SENDING
73 73 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
74 74 spw_ioctl_send.hdr = (char*) &TM_header;
75 75 spw_ioctl_send.dlen = 16;
76 76 spw_ioctl_send.data = data;
77 77 // SEND PACKET
78 78 write_spw(&spw_ioctl_send);
79 79 }
80 80 else { // send valid TC to the action launcher
81 81 status = rtems_message_queue_send( misc_id[0], TC, tc_len_recv + CCSDS_TC_TM_PACKET_OFFSET + 3);
82 82 return -1;
83 83 }
84 84 return -1;
85 85 }
86 86
87 87 unsigned char acceptTM(ccsdsTelecommandPacket_t * TMPacket, unsigned int TC_LEN_RCV)
88 88 {
89 89 unsigned char pid = 0;
90 90 unsigned char category = 0;
91 91 unsigned int length = 0;
92 92 unsigned char packetType = 0;
93 93 unsigned char packetSubtype = 0;
94 94 unsigned char * CCSDSContent;
95 95
96 96 // APID check *** APID on 2 bytes
97 97 pid = ((TMPacket->packetID[0] & 0x07)<<4) + ( (TMPacket->packetID[1]>>4) & 0x0f ); // PID = 11 *** 7 bits xxxxx210 7654xxxx
98 98 category = (TMPacket->packetID[1] & 0x0f); // PACKET_CATEGORY = 12 *** 4 bits xxxxxxxx xxxx3210
99 99 if (pid!=CCSDS_PROCESS_ID) return ILLEGAL_APID;
100 100 if (category!=CCSDS_PACKET_CATEGORY) return ILLEGAL_APID;
101 101
102 102 // packet length check
103 103 length = TMPacket->packetLength[0] * 256 + TMPacket->packetLength[1];
104 104 if (length != TC_LEN_RCV ) return WRONG_LEN_PACKET; // LEN RCV != SIZE FIELD
105 105 if (length >= CCSDS_TC_PKT_MAX_SIZE) return WRONG_LEN_PACKET; // check that the packet does not exceed the MAX size
106 106
107 107 packetType = TMPacket->dataFieldHeader[1];
108 108 packetSubtype = TMPacket->dataFieldHeader[2];
109 109 // service type, subtype and packet length check
110 110 if (packetType == 181){
111 111 switch(packetSubtype){ //subtype, autorized values are 3, 20, 21, 24, 27, 28, 30, 40, 50, 60, 61
112 112 case 3:
113 113 if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
114 114 break;
115 115 case 20:
116 116 if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
117 117 break;
118 118 case 21:
119 119 if (length!=(20-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
120 120 break;
121 121 case 24:
122 122 if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
123 123 break;
124 124 case 27:
125 125 if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
126 126 break;
127 127 case 28:
128 128 if (length!=(14-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
129 129 break;
130 130 case 30:
131 131 if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
132 132 break;
133 133 case 40:
134 134 if (length!=(20-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
135 135 break;
136 136 case 50:
137 137 if (length!=(50-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
138 138 break;
139 139 case 60:
140 140 if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
141 141 break;
142 142 case 61:
143 143 if (length!=(12-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
144 144 break;
145 145 default:
146 146 return ILL_SUBTYPE;
147 147 break;
148 148 }
149 149 }
150 150 else if (packetType == 9){
151 151 if (packetSubtype!=129) return ILL_SUBTYPE;
152 152 if (length!=(18-CCSDS_TC_TM_PACKET_OFFSET)) return WRONG_LEN_PACKET;
153 153 }
154 154 else return ILL_TYPE;
155 155
156 156 // source ID check // Source ID not documented in the ICD
157 157
158 158 // packet error control, CRC check
159 159 CCSDSContent = (unsigned char*) TMPacket->packetID;
160 160 GetCRCAsTwoBytes(CCSDSContent, currentTC_COMPUTED_CRC, length + CCSDS_TC_TM_PACKET_OFFSET - 2); // 2 CRC bytes removed from the calculation of the CRC
161 161 if (currentTC_COMPUTED_CRC[0] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -2]) return INCOR_CHECKSUM;
162 162 if (currentTC_COMPUTED_CRC[1] != CCSDSContent[length + CCSDS_TC_TM_PACKET_OFFSET -1]) return INCOR_CHECKSUM;
163 163
164 164 return CCSDS_TM_VALID;
165 165 }
166 166
167 167 unsigned char TM_build_header( enum TM_TYPE tm_type, unsigned int packetLength,
168 168 unsigned int coarseTime, unsigned int fineTime, TMHeader_t *TMHeader)
169 169 {
170 170 TMHeader->targetLogicalAddress = CCSDS_DESTINATION_ID;
171 171 TMHeader->protocolIdentifier = 0x02;
172 172 TMHeader->reserved = 0x00;
173 173 TMHeader->userApplication = 0x00;
174 174 TMHeader->packetID[0] = 0x0c;
175 175 TMHeader->packetSequenceControl[0] = 0xc0;
176 176 TMHeader->packetSequenceControl[1] = 0x00;
177 177 TMHeader->packetLength[0] = (unsigned char) (packetLength>>8);
178 178 TMHeader->packetLength[1] = (unsigned char) packetLength;
179 179 TMHeader->dataFieldHeader[0] = 0x10;
180 180 TMHeader->dataFieldHeader[3] = CCSDS_DESTINATION_ID;
181 181 switch (tm_type){
182 182 case(TM_LFR_TC_EXE_OK):
183 183 TMHeader->packetID[1] = 0xc1;
184 184 TMHeader->dataFieldHeader[1] = 1; // type
185 185 TMHeader->dataFieldHeader[2] = 7; // subtype
186 186 break;
187 187 case(TM_LFR_TC_EXE_ERR):
188 188 TMHeader->packetID[1] = 0xc1;
189 189 TMHeader->dataFieldHeader[1] = 1; // type
190 190 TMHeader->dataFieldHeader[2] = 8; // subtype
191 191 break;
192 192 case(TM_LFR_HK):
193 193 TMHeader->packetID[1] = 0xc4;
194 194 TMHeader->dataFieldHeader[1] = 3; // type
195 195 TMHeader->dataFieldHeader[2] = 25; // subtype
196 196 break;
197 197 case(TM_LFR_SCI):
198 198 TMHeader->packetID[1] = 0xcc;
199 199 TMHeader->dataFieldHeader[1] = 21; // type
200 200 TMHeader->dataFieldHeader[2] = 3; // subtype
201 201 break;
202 202 case(TM_LFR_SCI_SBM):
203 203 TMHeader->packetID[1] = 0xfc;
204 204 TMHeader->dataFieldHeader[1] = 21; // type
205 205 TMHeader->dataFieldHeader[2] = 3; // subtype
206 206 break;
207 207 case(TM_LFR_PAR_DUMP):
208 208 TMHeader->packetID[1] = 0xc9;
209 209 TMHeader->dataFieldHeader[1] = 181; // type
210 210 TMHeader->dataFieldHeader[2] = 31; // subtype
211 211 break;
212 212 default:
213 213 return 0;
214 214 }
215 215 TMHeader->dataFieldHeader[4] = (unsigned char) (time_management_regs->coarse_time>>24);
216 216 TMHeader->dataFieldHeader[5] = (unsigned char) (time_management_regs->coarse_time>>16);
217 217 TMHeader->dataFieldHeader[6] = (unsigned char) (time_management_regs->coarse_time>>8);
218 218 TMHeader->dataFieldHeader[7] = (unsigned char) (time_management_regs->coarse_time);
219 219 TMHeader->dataFieldHeader[8] = (unsigned char) (time_management_regs->fine_time>>8);
220 220 TMHeader->dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time);
221 221 return 1;
222 222 }
223 223
224 224 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC)
225 225 {
226 226 unsigned int packetLength;
227 227 packetLength = TC->packetLength[0] * 256 + TC->packetLength[1];
228 228 switch (SID){
229 229 case (SID_NOT_EXE):
230 230 break;
231 231 case (SID_NOT_IMP):
232 232 data[0] = 0x9c;
233 233 data[1] = 0x42;
234 234 data[2] = TC->packetID[0];
235 235 data[3] = TC->packetID[1];
236 236 data[4] = TC->packetSequenceControl[0];
237 237 data[5] = TC->packetSequenceControl[1];
238 238 data[6] = TC->dataFieldHeader[1]; // type
239 239 data[7] = TC->dataFieldHeader[2]; // subtype
240 240 break;
241 241 case (SID_EXE_ERR):
242 242 break;
243 243 case (SID_EXE_CORR):
244 244 data[0] = 0x9c;
245 245 data[1] = 0x45;
246 246 data[2] = TC->packetID[0];
247 247 data[3] = TC->packetID[1];
248 248 data[4] = TC->packetSequenceControl[0];
249 249 data[5] = TC->packetSequenceControl[1];
250 250 data[6] = TC->dataFieldHeader[1]; // type
251 251 data[7] = TC->dataFieldHeader[2]; // subtype
252 252 data[8] = currentTC_LEN_RCV[0];
253 253 data[9] = currentTC_LEN_RCV[1];
254 254 data[10] = TC->packetLength[0];
255 255 data[11] = TC->packetLength[1];
256 256 data[12] = TC->dataAndCRC[packetLength];
257 257 data[13] = TC->dataAndCRC[packetLength+1];
258 258 data[14] = computed_CRC[0];
259 259 data[15] = computed_CRC[1];
260 260 break;
261 261 default:
262 262 return 0;
263 263 }
264 264 return 1;
265 265 }
266 266
267 267 //***********
268 268 // RTEMS TASK
269 269 rtems_task recv_task( rtems_task_argument unused )
270 270 {
271 271 int len = 0;
272 272 unsigned int i = 0;
273 273 unsigned int data_length = 0;
274 274 ccsdsTelecommandPacket_t currentTC;
275 275 char data[100];
276 276
277 277 for(i=0; i<100; i++) data[i] = 0;
278 278
279 279 PRINTF("In RECV *** \n")
280 280
281 281 while(1)
282 282 {
283 283 len = read(fdSPW, (char*) &currentTC, CCSDS_TC_PKT_MAX_SIZE); // the call to read is blocking
284 284 if (len == -1){ // error during the read call
285 285 PRINTF("In RECV *** last read call returned -1\n")
286 286 if (rtems_event_send( Task_id[3], SPW_LINKERR_EVENT ) != RTEMS_SUCCESSFUL)
287 287 PRINTF("IN RECV *** Error: rtems_event_send SPW_LINKERR_EVENT\n")
288 288 if (rtems_task_suspend(RTEMS_SELF) != RTEMS_SUCCESSFUL)
289 289 PRINTF("In RECV *** Error: rtems_task_suspend(RTEMS_SELF)\n")
290 290 }
291 291 else {
292 //PRINTF1("In RECV *** Got Message of length %d\n", len)
292 PRINTF1("In RECV *** Got Message of length %d\n", len)
293 293 currentTC_LEN_RCV[0] = 0x00;
294 294 currentTC_LEN_RCV[1] = (unsigned char) len - CCSDS_TC_TM_PACKET_OFFSET - 3; // build the corresponding packet size field
295 295 currentTC_LEN_RCV_AsUnsignedInt = (unsigned int) len - CCSDS_TC_TM_PACKET_OFFSET - 3; // => -3 is for Prot ID, Reserved and User App bytes
296 296 // CHECK THE TC AND BUILD THE APPROPRIATE TM
297 297 data_length = TC_checker(&currentTC, currentTC_LEN_RCV_AsUnsignedInt);
298 298 if (data_length!=-1)
299 299 {
300 300 }
301 301 }
302 302 }
303 303 }
304 304
305 305 rtems_task actn_task( rtems_task_argument unused )
306 306 {
307 307 int result = 0;
308 308 rtems_status_code status; // RTEMS status code
309 309 ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task
310 310 size_t size; // size of the incoming TC packet
311 311 unsigned char subtype = 0; // subtype of the current TC packet
312 312
313 313 PRINTF("In ACTN *** \n")
314 314
315 315 while(1)
316 316 {
317 317 status = rtems_message_queue_receive(misc_id[0], (char*) &TC, &size,
318 318 RTEMS_WAIT, RTEMS_NO_TIMEOUT);
319 319 if (status!=RTEMS_SUCCESSFUL) PRINTF1("in task ACTN *** error receiving a message, code %d \n", status)
320 320 else
321 321 {
322 322 subtype = TC.dataFieldHeader[2];
323 323 switch(subtype)
324 324 {
325 325 case TC_SUBTYPE_RESET:
326 326 result = action_default( &TC );
327 327 break;
328 328 //
329 329 case TC_SUBTYPE_LOAD_COMM:
330 330 result = action_default( &TC );
331 331 break;
332 332 //
333 333 case TC_SUBTYPE_LOAD_NORM:
334 334 result = action_load_norm( &TC );
335 335 send_tm_lfr_tc_exe_success( &TC );
336 336 break;
337 337 //
338 338 case TC_SUBTYPE_LOAD_BURST:
339 339 result = action_default( &TC );
340 340 break;
341 341 //
342 342 case TC_SUBTYPE_LOAD_SBM1:
343 343 result = action_default( &TC );
344 344 break;
345 345 //
346 346 case TC_SUBTYPE_LOAD_SBM2:
347 347 result = action_default( &TC );
348 348 break;
349 349 //
350 350 case TC_SUBTYPE_DUMP:
351 351 result = action_default( &TC );
352 352 break;
353 353 //
354 354 case TC_SUBTYPE_ENTER:
355 355 result = action_enter( &TC );
356 356 send_tm_lfr_tc_exe_success( &TC );
357 357 break;
358 358 //
359 359 case TC_SUBTYPE_UPDT_INFO:
360 360 result = action_default( &TC );
361 361 break;
362 362 //
363 363 case TC_SUBTYPE_EN_CAL:
364 364 result = action_default( &TC );
365 365 break;
366 366 //
367 367 case TC_SUBTYPE_DIS_CAL:
368 368 result = action_default( &TC );
369 369 break;
370 370 //
371 371 case TC_SUBTYPE_UPDT_TIME:
372 372 result = action_updt_time( &TC );
373 373 send_tm_lfr_tc_exe_success( &TC );
374 374 break;
375 375 //
376 376 default:
377 377 break;
378 378 }
379 379 }
380 380 }
381 381 }
382 382
383 383 int create_message_queue()
384 384 {
385 385 rtems_status_code status;
386 386 misc_name[0] = rtems_build_name( 'Q', 'U', 'E', 'U' );
387 387 status = rtems_message_queue_create( misc_name[0], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
388 388 RTEMS_FIFO | RTEMS_LOCAL, &misc_id[0] );
389 389 if (status!=RTEMS_SUCCESSFUL) PRINTF("in create_message_queue *** error creating message queue\n")
390 390
391 391 return 0;
392 392 }
393 393
394 394 //***********
395 395 // TC ACTIONS
396 396 int action_default(ccsdsTelecommandPacket_t *TC)
397 397 {
398 398 char data[100]; // buffer for the generic TM packet
399 399 TMHeader_t TM_header; // TM header
400 400 spw_ioctl_pkt_send spw_ioctl_send; // structure to send the TM packet if any
401 401 // BUILD HEADER
402 402 TM_build_header( TM_LFR_TC_EXE_ERR, TM_LEN_NOT_IMP, 0, 0, &TM_header);
403 403 // BUILD DATA
404 404 TM_build_data( TC, data, SID_NOT_IMP, NULL);
405 405 // filling the strture for the spcawire transmission
406 406 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
407 407 spw_ioctl_send.hdr = (char*) &TM_header;
408 408 spw_ioctl_send.dlen = 8;
409 409 spw_ioctl_send.data = data;
410 410 // SEND DATA
411 411 write_spw(&spw_ioctl_send);
412 412
413 413 return 0;
414 414 }
415 415
416 416 int action_enter(ccsdsTelecommandPacket_t *TC)
417 417 {
418 418 unsigned char lfr_mode = TC->dataAndCRC[1];
419 419 printf("enter mode %d\n", lfr_mode);
420 420 switch(lfr_mode)
421 421 {
422 422 case(LFR_MODE_STANDBY):
423 423 LEON_Mask_interrupt( IRQ_WF );
424 424 LEON_Mask_interrupt( IRQ_SM );
425 425 break;
426 426 case(LFR_MODE_NORMAL):
427 427 LEON_Unmask_interrupt( IRQ_WF );
428 428 LEON_Unmask_interrupt( IRQ_SM );
429 429 break;
430 430 case(LFR_MODE_BURST):
431 431 break;
432 432 case(LFR_MODE_SBM1):
433 433 break;
434 434 case(LFR_MODE_SBM2):
435 435 break;
436 436 }
437 437 return 0;
438 438 }
439 439
440 440 int action_load_norm(ccsdsTelecommandPacket_t *TC)
441 441 {
442 442 param_norm.sy_lfr_n_swf_l = TC->dataAndCRC[0] * 256 + TC->dataAndCRC[1];
443 443 param_norm.sy_lfr_n_swf_p = TC->dataAndCRC[2] * 256 + TC->dataAndCRC[3];
444 444 param_norm.sy_lfr_n_asm_p = TC->dataAndCRC[4] * 256 + TC->dataAndCRC[5];
445 445 param_norm.sy_lfr_n_bp_p0 = TC->dataAndCRC[6];
446 446 param_norm.sy_lfr_n_bp_p1 = TC->dataAndCRC[7];
447 447 /*printf("sy_lfr_n_ => swf_l %d, swf_p %d, asm_p %d, bsp_p0 %d, bsp_p1 %d\n",
448 448 param_norm.sy_lfr_n_swf_l, param_norm.sy_lfr_n_swf_p,
449 449 param_norm.sy_lfr_n_asm_p, param_norm.sy_lfr_n_bp_p0, param_norm.sy_lfr_n_bp_p1);*/
450 450 return 0;
451 451 }
452 452
453 453 int action_updt_time(ccsdsTelecommandPacket_t *TC)
454 454 {
455 455 time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24)
456 456 + (TC->dataAndCRC[1] << 16)
457 457 + (TC->dataAndCRC[2] << 8)
458 458 + TC->dataAndCRC[3];
459 time_management_regs->ctrl = time_management_regs->ctrl | 1;
459 //time_management_regs->ctrl = time_management_regs->ctrl | 1;
460 460 return 0;
461 461 }
462 462
463 463 int send_tm_lfr_tc_exe_success(ccsdsTelecommandPacket_t *TC)
464 464 {
465 465 TMHeader_t TM_header;
466 466 char data[4];
467 467 spw_ioctl_pkt_send spw_ioctl_send;
468 468
469 469 TM_build_header( TM_LFR_TC_EXE_OK, TM_LEN_EXE,
470 470 time_management_regs->coarse_time, time_management_regs->fine_time, &TM_header);
471 471
472 472 data[0] = TC->packetID[0];
473 473 data[1] = TC->packetID[1];
474 474 data[2] = TC->packetSequenceControl[0];
475 475 data[3] = TC->packetSequenceControl[1];
476 476
477 477 // filling the structure for the spacewire transmission
478 478 spw_ioctl_send.hlen = TM_HEADER_LEN + 3; // + 4 is for the protocole extra header
479 479 spw_ioctl_send.hdr = (char*) &TM_header;
480 480 spw_ioctl_send.dlen = 3;
481 481 spw_ioctl_send.data = data;
482 482
483 483 // SEND DATA
484 484 write_spw(&spw_ioctl_send);
485 485
486 486 return 0;
487 487 }
488 488
489 //***************************
490 // Interrupt Service Routines
491 rtems_isr commutation_isr1( rtems_vector_number vector )
492 {
493 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
494 printf("In spectral_matrices_isr *** Error sending event to DUMB\n");
495 }
489 496
497 rtems_isr commutation_isr2( rtems_vector_number vector )
498 {
499 if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
500 printf("In spectral_matrices_isr *** Error sending event to DUMB\n");
501 }
502
503 rtems_task dumb_task( rtems_task_argument unused )
504 {
505 unsigned int coarse_time;
506 unsigned int fine_time;
507 rtems_event_set event_out;
508
509 PRINTF("In DUMB *** \n")
510
511 while(1){
512 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
513 coarse_time = time_management_regs->coarse_time;
514 fine_time = time_management_regs->fine_time;
515 printf("commutation_isr*, coarse time = %x, fine time = %x\n", coarse_time, fine_time);
516 }
517 }
518
519
520
@@ -1,115 +1,115
1 1 #include <wf_handler.h>
2 2
3 3 rtems_isr waveforms_isr( rtems_vector_number vector )
4 4 {
5 5 if (rtems_event_send( Task_id[TASKID_WFRM], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
6 6 printf("In spectral_matrices_isr *** Error sending event to WFRM\n");
7 7 }
8 8
9 9 rtems_task wfrm_task(rtems_task_argument argument)
10 10 {
11 11 unsigned int length;
12 12 unsigned int i = 0;
13 13 spw_ioctl_pkt_send spw_ioctl_send;
14 14 rtems_event_set event_out;
15 15 gptimer_regs_t *gptimer_regs;
16 16 gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
17 17 ExtendedTMHeader_t header;
18 18
19 19 header.targetLogicalAddress = CCSDS_DESTINATION_ID;
20 20 header.protocolIdentifier = CCSDS_PROTOCOLE_ID;
21 21 header.reserved = 0x00;
22 22 header.userApplication = CCSDS_USER_APP;
23 23 header.packetID[0] = 0x0c;
24 24 header.packetID[1] = 0xcc;
25 25 header.packetSequenceControl[0] = 0x00;
26 26 header.packetSequenceControl[1] = 0x00;
27 27 header.packetLength[0] = 0x00;
28 28 header.packetLength[1] = 0x00;
29 29 header.dataFieldHeader[0] = 0x10;
30 30 header.dataFieldHeader[1] = 0x15; // service type
31 31 header.dataFieldHeader[2] = 0x03; // service subtype
32 32 header.dataFieldHeader[3] = CCSDS_DESTINATION_ID;
33 header.dataFieldHeader[4] = 0xaa;
34 header.dataFieldHeader[5] = 0xbb;
35 header.dataFieldHeader[6] = 0xcc;
36 header.dataFieldHeader[7] = 0xdd;
37 header.dataFieldHeader[8] = 0xee;
38 header.dataFieldHeader[9] = 0xff;
39 33
40 34 header.auxiliaryHeader[0] = 0x00;
41 35 header.auxiliaryHeader[1] = 0x1f;
42 36 header.auxiliaryHeader[2] = 0x07; // PKT_CNT
43 37 header.auxiliaryHeader[3] = 0x00; // PKT_NR
44 38 header.auxiliaryHeader[4] = 0x00; // BLK_NR MSB
45 39 header.auxiliaryHeader[5] = 0x00; // BLK_NR LSB
46 40
47 41 // BUILD THE PACKET HEADER
48 42 spw_ioctl_send.hlen = TM_HEADER_LEN + 4 + 6; // + 4 is for the protocole extra header, + 6 is for the auxiliary header
49 43 spw_ioctl_send.hdr = (char*) &header;
50 44
51 45 PRINTF("In WFRM *** \n")
52 46
53 47 while(1){
54 48 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
49 header.dataFieldHeader[4] = (unsigned char) (time_management_regs->coarse_time>>24);
50 header.dataFieldHeader[5] = (unsigned char) (time_management_regs->coarse_time>>16);
51 header.dataFieldHeader[6] = (unsigned char) (time_management_regs->coarse_time>>8);
52 header.dataFieldHeader[7] = (unsigned char) (time_management_regs->coarse_time);
53 header.dataFieldHeader[8] = (unsigned char) (time_management_regs->fine_time>>8);
54 header.dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time);
55 55 for (i=0; i<7; i++) // send F0
56 56 {
57 57 // BUILD THE DATA
58 58 if (i==6) {
59 59 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
60 60 length = TM_LEN_SCI_NORM_SWF_340;
61 61 }
62 62 else {
63 63 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
64 64 length = TM_LEN_SCI_NORM_SWF_8;
65 65 }
66 66 spw_ioctl_send.data = (char*) &wf_snap_f0[i * 340 * NB_BYTES_SWF_BLK];
67 67 // BUILD THE HEADER
68 68 header.packetLength[0] = (unsigned char) (length>>8);
69 69 header.packetLength[1] = (unsigned char) (length);
70 70 header.auxiliaryHeader[0] = SID_NORM_SWF_F0; // SID
71 71 // SEND PACKET
72 72 write_spw(&spw_ioctl_send);
73 73 }
74 74 for (i=0; i<7; i++) // send F1
75 75 {
76 76 // BUILD THE DATA
77 77 if (i==6) {
78 78 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
79 79 length = TM_LEN_SCI_NORM_SWF_340;
80 80 }
81 81 else {
82 82 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
83 83 length = TM_LEN_SCI_NORM_SWF_8;
84 84 }
85 85 spw_ioctl_send.data = (char*) &wf_snap_f1[i * 340 * NB_BYTES_SWF_BLK];
86 86 // BUILD THE HEADER
87 87 header.packetLength[0] = (unsigned char) (length>>8);
88 88 header.packetLength[1] = (unsigned char) (length);
89 89 header.auxiliaryHeader[0] = SID_NORM_SWF_F1; // SID
90 90 // SEND PACKET
91 91 write_spw(&spw_ioctl_send);
92 92 }
93 93 for (i=0; i<7; i++) // send F0
94 94 {
95 95 // BUILD THE DATA
96 96 if (i==6) {
97 97 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
98 98 length = TM_LEN_SCI_NORM_SWF_340;
99 99 }
100 100 else {
101 101 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
102 102 length = TM_LEN_SCI_NORM_SWF_8;
103 103 }
104 104 spw_ioctl_send.data = (char*) &wf_snap_f2[i * 340 * NB_BYTES_SWF_BLK];
105 105 // BUILD THE HEADER
106 106 header.packetLength[0] = (unsigned char) (length>>8);
107 107 header.packetLength[1] = (unsigned char) (length);
108 108 header.auxiliaryHeader[0] = SID_NORM_SWF_F2; // SID
109 109 // SEND PACKET
110 110 write_spw(&spw_ioctl_send);
111 111 }
112 112 // irq processed, reset the related register of the timer unit
113 113 gptimer_regs->timer[2].ctrl = gptimer_regs->timer[2].ctrl | 0x00000010;
114 114 }
115 115 }
General Comments 0
You need to be logged in to leave comments. Login now