##// END OF EJS Templates
automatic reconnexion of the spacewire link...
paul@pc-solar1.lab-lpp.local -
r17:3a73d9962d4a default
parent child
Show More
@@ -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="384" topLine="87" />
5 <Cursor position="4971" topLine="100" />
6 </File>
6 </File>
7 <File name="../header/fsw_init.h" open="0" top="0" tabpos="6">
7 <File name="../header/fsw_init.h" open="0" top="0" tabpos="6">
8 <Cursor position="1133" topLine="22" />
8 <Cursor position="597" topLine="0" />
9 </File>
9 </File>
10 <File name="../header/fsw_misc.h" open="0" top="0" tabpos="0">
10 <File name="../header/fsw_misc.h" open="0" top="0" tabpos="3">
11 <Cursor position="545" topLine="0" />
11 <Cursor position="279" topLine="0" />
12 </File>
12 </File>
13 <File name="../header/fsw_params.h" open="0" top="0" tabpos="2">
13 <File name="../header/fsw_params.h" open="0" top="0" tabpos="3">
14 <Cursor position="1157" topLine="0" />
14 <Cursor position="1416" topLine="31" />
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="628" topLine="7" />
17 <Cursor position="1216" topLine="5" />
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="1153" topLine="16" />
20 <Cursor position="444" topLine="0" />
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="1380" topLine="35" />
23 <Cursor position="1380" topLine="35" />
24 </File>
24 </File>
25 <File name="../header/wf_handler.h" open="0" top="0" tabpos="0">
25 <File name="../header/wf_handler.h" open="0" top="0" tabpos="0">
26 <Cursor position="341" topLine="0" />
26 <Cursor position="316" topLine="0" />
27 </File>
27 </File>
28 <File name="../src/fsw_globals.c" open="0" top="0" tabpos="5">
28 <File name="../src/fsw_globals.c" open="1" top="0" tabpos="3">
29 <Cursor position="184" topLine="0" />
29 <Cursor position="1246" topLine="6" />
30 </File>
30 </File>
31 <File name="../src/fsw_init.c" open="1" top="0" tabpos="1">
31 <File name="../src/fsw_init.c" open="1" top="1" tabpos="1">
32 <Cursor position="12072" topLine="91" />
32 <Cursor position="2317" topLine="59" />
33 </File>
33 </File>
34 <File name="../src/fsw_misc.c" open="1" top="1" tabpos="2">
34 <File name="../src/fsw_misc.c" open="0" top="0" tabpos="2">
35 <Cursor position="4309" topLine="44" />
35 <Cursor position="6076" topLine="0" />
36 </File>
36 </File>
37 <File name="../src/fsw_processing.c" open="0" top="0" tabpos="0">
37 <File name="../src/fsw_processing.c" open="0" top="0" tabpos="4">
38 <Cursor position="20570" topLine="67" />
38 <Cursor position="19048" topLine="64" />
39 </File>
39 </File>
40 <File name="../src/tc_handler.c" open="0" top="0" tabpos="2">
40 <File name="../src/tc_handler.c" open="0" top="0" tabpos="5">
41 <Cursor position="15292" topLine="0" />
41 <Cursor position="536" topLine="0" />
42 </File>
42 </File>
43 <File name="../src/wf_handler.c" open="0" top="0" tabpos="4">
43 <File name="../src/wf_handler.c" open="1" top="0" tabpos="2">
44 <Cursor position="2540" topLine="42" />
44 <Cursor position="5858" topLine="70" />
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
@@ -9,7 +9,11
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 //
13 #define CCSDS_DESTINATION_ID_GROUND 0x00
12 #define CCSDS_DESTINATION_ID 0x01
14 #define CCSDS_DESTINATION_ID 0x01
15 #define CCSDS_DESTINATION_ID_DPU 0x01
16 //
13 #define CCSDS_PROTOCOLE_ID 0x02
17 #define CCSDS_PROTOCOLE_ID 0x02
14 #define CCSDS_USER_APP 0x00
18 #define CCSDS_USER_APP 0x00
15
19
@@ -47,6 +51,7
47 #define TC_SUBTYPE_UPDT_TIME 129
51 #define TC_SUBTYPE_UPDT_TIME 129
48
52
49 #define SID_DEFAULT 0
53 #define SID_DEFAULT 0
54 #define SID_HK 1
50 #define SID_EXE_INC 5
55 #define SID_EXE_INC 5
51 #define SID_NOT_EXE 40000
56 #define SID_NOT_EXE 40000
52 #define SID_NOT_IMP 40002
57 #define SID_NOT_IMP 40002
@@ -80,12 +85,21
80 #define SID_SBM1_BP1_F1 30
85 #define SID_SBM1_BP1_F1 30
81 #define SID_SBM1_BP2_F1 33
86 #define SID_SBM1_BP2_F1 33
82
87
88 // LENGTH (BYTES)
89 #define LENGTH_TM_LFR_HK 126
90 #define LENGTH_TM_LFR_TC_EXE_MAX 32
91 #define LENGTH_TM_LFR_SCIENCE_NORMAL_WF_MAX 4102
92 //
83 #define TM_LEN_EXE 20 - CCSDS_TC_TM_PACKET_OFFSET
93 #define TM_LEN_EXE 20 - CCSDS_TC_TM_PACKET_OFFSET
84 #define TM_LEN_NOT_EXE 26 - CCSDS_TC_TM_PACKET_OFFSET
94 #define TM_LEN_NOT_EXE 26 - CCSDS_TC_TM_PACKET_OFFSET
85 #define TM_LEN_NOT_IMP 24 - CCSDS_TC_TM_PACKET_OFFSET
95 #define TM_LEN_NOT_IMP 24 - CCSDS_TC_TM_PACKET_OFFSET
86 #define TM_LEN_EXE_ERR 24 - CCSDS_TC_TM_PACKET_OFFSET
96 #define TM_LEN_EXE_ERR 24 - CCSDS_TC_TM_PACKET_OFFSET
87 #define TM_LEN_EXE_CORR 32 - CCSDS_TC_TM_PACKET_OFFSET
97 #define TM_LEN_EXE_CORR 32 - CCSDS_TC_TM_PACKET_OFFSET
88 #define TM_HEADER_LEN 16
98 #define TM_HEADER_LEN 16
99
100 #define LEN_TM_LFR_HK 126 + 4
101 #define LEN_TM_LFR_TC_EXE_NOT_IMP 24 +4
102
89 #define TM_LEN_SCI_NORM_SWF_340 340 * 12 + 6 + 10 - 1
103 #define TM_LEN_SCI_NORM_SWF_340 340 * 12 + 6 + 10 - 1
90 #define TM_LEN_SCI_NORM_SWF_8 8 * 12 + 6 + 10 - 1
104 #define TM_LEN_SCI_NORM_SWF_8 8 * 12 + 6 + 10 - 1
91
105
@@ -111,6 +125,49 struct TMHeader_str
111 };
125 };
112 typedef struct TMHeader_str TMHeader_t;
126 typedef struct TMHeader_str TMHeader_t;
113
127
128 struct Packet_TM_LFR_HK_str
129 {
130 volatile unsigned char targetLogicalAddress;
131 volatile unsigned char protocolIdentifier;
132 volatile unsigned char reserved;
133 volatile unsigned char userApplication;
134 volatile unsigned char packetID[2];
135 volatile unsigned char packetSequenceControl[2];
136 volatile unsigned char packetLength[2];
137 volatile unsigned char dataFieldHeader[10];
138 volatile unsigned char data[LENGTH_TM_LFR_HK - 10 + 1];
139 };
140 typedef struct Packet_TM_LFR_HK_str Packet_TM_LFR_HK_t;
141
142 struct Packet_TM_LFR_TC_EXE_str
143 {
144 volatile unsigned char targetLogicalAddress;
145 volatile unsigned char protocolIdentifier;
146 volatile unsigned char reserved;
147 volatile unsigned char userApplication;
148 volatile unsigned char packetID[2];
149 volatile unsigned char packetSequenceControl[2];
150 volatile unsigned char packetLength[2];
151 volatile unsigned char dataFieldHeader[10];
152 volatile unsigned char data[LENGTH_TM_LFR_TC_EXE_MAX - 10 + 1];
153 };
154 typedef struct Packet_TM_LFR_TC_EXE_str Packet_TM_LFR_TC_EXE_t;
155
156 struct Packet_TM_LFR_SCIENCE_NORMAL_WF_str
157 {
158 volatile unsigned char targetLogicalAddress;
159 volatile unsigned char protocolIdentifier;
160 volatile unsigned char reserved;
161 volatile unsigned char userApplication;
162 volatile unsigned char packetID[2];
163 volatile unsigned char packetSequenceControl[2];
164 volatile unsigned char packetLength[2];
165 volatile unsigned char dataFieldHeader[10];
166 volatile unsigned char auxiliaryHeader[6];
167 volatile unsigned char data[LENGTH_TM_LFR_SCIENCE_NORMAL_WF_MAX - 10 + 1];
168 };
169 typedef struct Packet_TM_LFR_SCIENCE_NORMAL_WF_str Packet_TM_LFR_SCIENCE_NORMAL_WF_t;
170
114 struct ExtendedTMHeader_str
171 struct ExtendedTMHeader_str
115 {
172 {
116 volatile unsigned char targetLogicalAddress;
173 volatile unsigned char targetLogicalAddress;
@@ -39,6 +39,7 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_all_tasks();
43 int create_all_tasks();
43 int start_all_tasks();
44 int start_all_tasks();
44 int create_message_queue();
45 int create_message_queue();
@@ -10,10 +10,18
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; /* name of the HK rate monotonic */
14 rtems_id HK_id; /* id of the HK rate monotonic period */
15
13 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,
14 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
17 unsigned char interrupt_level, rtems_isr (*timer_isr)() );
15 void print_statistics(spw_stats *stats);
18 void print_statistics(spw_stats *stats);
19
20 // SERIAL LINK
16 int send_console_outputs_on_serial_port();
21 int send_console_outputs_on_serial_port();
22 int set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value);
23
24 // RTEMS TASKS
17 rtems_task stat_task(rtems_task_argument argument);
25 rtems_task stat_task(rtems_task_argument argument);
18 rtems_task hous_task(rtems_task_argument argument);
26 rtems_task hous_task(rtems_task_argument argument);
19
27
@@ -21,6 +21,7
21 #define REGS_ADDR_SPECTRAL_MATRICES 0x80000700
21 #define REGS_ADDR_SPECTRAL_MATRICES 0x80000700
22
22
23 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
23 #define APBUART_CTRL_REG_MASK_DB 0xfffff7ff
24 #define APBUART_SCALER_RELOAD_VALUE 0x00000050 // 25 MHz => about 38400
24
25
25 //**********
26 //**********
26 // IRQ LINES
27 // IRQ LINES
@@ -56,12 +57,9
56
57
57 #define ACTION_MSG_QUEUE_COUNT 10
58 #define ACTION_MSG_QUEUE_COUNT 10
58
59
59 // LENGTH (BYTES)
60 #define LENGTH_TM_LFR_HK 126
61
62 //*******
60 //*******
63 // MACROS
61 // MACROS
64 //#define PRINT_TASK_STATISTICS
62 #define PRINT_TASK_STATISTICS
65 #define PRINT_MESSAGES_ON_CONSOLE // enable or disable the printf instructions
63 #define PRINT_MESSAGES_ON_CONSOLE // enable or disable the printf instructions
66 #ifdef PRINT_MESSAGES_ON_CONSOLE
64 #ifdef PRINT_MESSAGES_ON_CONSOLE
67 #define PRINTF(x) printf(x);
65 #define PRINTF(x) printf(x);
@@ -75,6 +73,7
75
73
76 #define NB_SAMPLES_PER_SNAPSHOT 2048
74 #define NB_SAMPLES_PER_SNAPSHOT 2048
77 #define NB_BYTES_SWF_BLK 2 * 6
75 #define NB_BYTES_SWF_BLK 2 * 6
76 #define NB_WORDS_SWF_BLK 3
78
77
79 struct param_norm_str{
78 struct param_norm_str{
80 unsigned int sy_lfr_n_swf_l; // length of the snapshots
79 unsigned int sy_lfr_n_swf_l; // length of the snapshots
@@ -28,17 +28,18 typedef struct BP1_str BP1_t;
28
28
29 // ISR
29 // ISR
30 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
30 rtems_isr spectral_matrices_isr( rtems_vector_number vector );
31
31 // RTEMS TASKS
32 // RTEMS TASKS
32 rtems_task spw_bppr_task(rtems_task_argument argument);
33 rtems_task spw_bppr_task(rtems_task_argument argument);
33 rtems_task avf0_task(rtems_task_argument argument);
34 rtems_task avf0_task(rtems_task_argument argument);
34 rtems_task bpf0_task(rtems_task_argument argument);
35 rtems_task bpf0_task(rtems_task_argument argument);
35 rtems_task smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator
36 rtems_task smiq_task(rtems_task_argument argument); // added to test the spectral matrix simulator
36 //
37
37 rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument);
38 rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument);
38 void matrix_average(volatile int *spec_mat, float *averaged_spec_mat);
39 void matrix_average(volatile int *spec_mat, float *averaged_spec_mat);
39 void matrix_compression(float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat);
40 void matrix_compression(float *averaged_spec_mat, unsigned char fChannel, float *compressed_spec_mat);
40 void matrix_reset(float *averaged_spec_mat);
41 void matrix_reset(float *averaged_spec_mat);
41 void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1);
42 void BP1_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat, unsigned char * LFR_BP1);
42 void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat);
43 void BP2_set(float * compressed_spec_mat, unsigned char nb_bins_compressed_spec_mat);
43
44
44 #endif // FSW_RTEMS_PROCESSING_H_INCLUDED
45 #endif // FSW_RTEMS_PROCESSING_H_INCLUDED
@@ -17,4 +17,9 extern int fdSPW;
17 rtems_isr waveforms_isr( rtems_vector_number vector );
17 rtems_isr waveforms_isr( rtems_vector_number vector );
18 rtems_task wfrm_task(rtems_task_argument argument);
18 rtems_task wfrm_task(rtems_task_argument argument);
19
19
20 //******************
21 // general functions
22 void init_waveforms();
23 int buil_value(int value1, int value0);
24
20 #endif // WF_HANDLER_H_INCLUDED
25 #endif // WF_HANDLER_H_INCLUDED
@@ -40,8 +40,7 struct param_sbm2_str param_sbm2;
40 unsigned char param_common[2];
40 unsigned char param_common[2];
41
41
42 // HK PACKETS
42 // HK PACKETS
43 TMHeader_t housekeeping_header;
43 Packet_TM_LFR_HK_t housekeeping_packet;
44 char housekeeping_data[LENGTH_TM_LFR_HK - 10 + 1];
45
44
46 // BASIC PARAMETERS GLOBAL VARIABLES
45 // BASIC PARAMETERS GLOBAL VARIABLES
47 unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_MATRIX_f0 * 9 ];
46 unsigned char LFR_BP1_F0[ NB_BINS_COMPRESSED_MATRIX_f0 * 9 ];
@@ -21,7 +21,7
21 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
21 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
22 #define CONFIGURE_INIT_TASK_PRIORITY 100
22 #define CONFIGURE_INIT_TASK_PRIORITY 100
23 #define CONFIGURE_MAXIMUM_DRIVERS 16
23 #define CONFIGURE_MAXIMUM_DRIVERS 16
24 #define CONFIGURE_MAXIMUM_PERIODS 1
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>
@@ -59,11 +59,20 rtems_task Init( rtems_task_argument ign
59 rtems_status_code status;
59 rtems_status_code status;
60 rtems_isr_entry old_isr_handler;
60 rtems_isr_entry old_isr_handler;
61
61
62 PRINTF("\n\n\n\n\n")
63 PRINTF("***************************\n")
64 PRINTF("** START Flight Software **\n")
65 PRINTF("***************************\n")
66 PRINTF("\n\n")
67
62 //send_console_outputs_on_serial_port();
68 //send_console_outputs_on_serial_port();
69 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
63
70
64 initLookUpTableForCRC(); // in tc_handler.h
71 initLookUpTableForCRC(); // in tc_handler.h
65 init_default_mode_parameters();
72 init_default_mode_parameters();
66 create_message_queue();
73 create_message_queue();
74
75 create_names();
67 create_all_tasks();
76 create_all_tasks();
68 start_all_tasks();
77 start_all_tasks();
69
78
@@ -71,6 +80,8 rtems_task Init( rtems_task_argument ign
71
80
72 configure_spw_link();
81 configure_spw_link();
73
82
83 init_waveforms();
84
74 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
85 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR,
75 IRQ_SPARC_SM, spectral_matrices_isr );
86 IRQ_SPARC_SM, spectral_matrices_isr );
76 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
87 configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_WF_SIMULATOR, CLKDIV_WF_SIMULATOR,
@@ -81,13 +92,13 rtems_task Init( rtems_task_argument ign
81 IRQ_SPARC_TIME1,
92 IRQ_SPARC_TIME1,
82 &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
93 &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
83 if (status==RTEMS_SUCCESSFUL)
94 if (status==RTEMS_SUCCESSFUL)
84 PRINTF("commutation_isr1 *** rtems_interrupt_catch successfullly configured\n")
95 PRINTF("OK *** commutation_isr1 *** rtems_interrupt_catch successfullly configured\n")
85
96
86 status = rtems_interrupt_catch( commutation_isr2,
97 status = rtems_interrupt_catch( commutation_isr2,
87 IRQ_SPARC_TIME2,
98 IRQ_SPARC_TIME2,
88 &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
99 &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels
89 if (status==RTEMS_SUCCESSFUL)
100 if (status==RTEMS_SUCCESSFUL)
90 PRINTF("commutation_isr2 *** rtems_interrupt_catch successfullly configured\n")
101 PRINTF("OK *** commutation_isr2 *** rtems_interrupt_catch successfullly configured\n")
91
102
92 LEON_Unmask_interrupt( IRQ_TIME1 );
103 LEON_Unmask_interrupt( IRQ_TIME1 );
93 LEON_Unmask_interrupt( IRQ_TIME2 );
104 LEON_Unmask_interrupt( IRQ_TIME2 );
@@ -100,23 +111,25 rtems_task spiq_task(rtems_task_argument
100 rtems_event_set event_out;
111 rtems_event_set event_out;
101 struct grspw_regs_str *grspw_regs;
112 struct grspw_regs_str *grspw_regs;
102 grspw_regs = (struct grspw_regs_str *) REGS_ADDR_GRSPW;
113 grspw_regs = (struct grspw_regs_str *) REGS_ADDR_GRSPW;
114 rtems_status_code status;
103
115
104 while(1){
116 while(1){
105 PRINTF("In SPIQ *** Waiting for SPW_LINKERR_EVENT\n")
117 PRINTF("in SPIQ *** Waiting for SPW_LINKERR_EVENT\n")
106 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
118 rtems_event_receive(SPW_LINKERR_EVENT, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an SPW_LINKERR_EVENT
107
119
108 if (rtems_task_suspend(Task_id[TASKID_RECV])!=RTEMS_SUCCESSFUL) // suspend RECV task
120 if (rtems_task_suspend(Task_id[TASKID_RECV])!=RTEMS_SUCCESSFUL) // suspend RECV task
109 PRINTF("In SPIQ *** Error suspending RECV Task\n")
121 PRINTF("in SPIQ *** Error suspending RECV Task\n")
110 if (rtems_task_suspend(Task_id[TASKID_HOUS])!=RTEMS_SUCCESSFUL) // suspend HOUS task
122 if (rtems_task_suspend(Task_id[TASKID_HOUS])!=RTEMS_SUCCESSFUL) // suspend HOUS task
111 PRINTF("In SPIQ *** Error suspending HOUS Task\n")
123 PRINTF("in SPIQ *** Error suspending HOUS Task\n")
112
124
113 configure_spw_link();
125 configure_spw_link();
126
127 status = rtems_task_restart( Task_id[TASKID_HOUS], 1 );
128 if (status!=RTEMS_SUCCESSFUL)
129 PRINTF1("in SPIQ *** Error restarting HOUS Task *** code %d\n", status)
114
130
115 if (rtems_task_restart(Task_id[TASKID_RECV], 1)!=RTEMS_SUCCESSFUL) // restart RECV task
131 if (rtems_task_restart(Task_id[TASKID_RECV], 1)!=RTEMS_SUCCESSFUL) // restart RECV task
116 PRINTF("In SPIQ *** Error resume RECV Task\n")
132 PRINTF("in SPIQ *** Error restarting RECV Task\n")
117 if (rtems_task_restart(Task_id[TASKID_HOUS], 1)!=RTEMS_SUCCESSFUL) // restart HOUS task
118 PRINTF("In SPIQ *** Error resume HOUS Task\n")
119
120 }
133 }
121 }
134 }
122
135
@@ -142,10 +155,9 void init_default_mode_parameters()
142 param_sbm2.sy_lfr_s2_bp_p0 = 5; // sec
155 param_sbm2.sy_lfr_s2_bp_p0 = 5; // sec
143 }
156 }
144
157
145 int create_all_tasks()
158 int create_names()
146 {
159 {
147 rtems_status_code status;
160 // task names
148
149 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
161 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
150 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
162 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
151 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
163 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
@@ -155,7 +167,17 int create_all_tasks()
155 Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' );
167 Task_name[TASKID_BPF0] = rtems_build_name( 'B', 'P', 'F', '0' );
156 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
168 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
157 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
169 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
158 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
170 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
171
172 // rate monotonic period name
173 HK_name = rtems_build_name( 'H', 'O', 'U', 'S' );
174
175 return 0;
176 }
177
178 int create_all_tasks()
179 {
180 rtems_status_code status;
159
181
160 // RECV
182 // RECV
161 status = rtems_task_create(
183 status = rtems_task_create(
@@ -171,8 +193,8 int create_all_tasks()
171 );
193 );
172 // SPIQ
194 // SPIQ
173 status = rtems_task_create(
195 status = rtems_task_create(
174 Task_name[TASKID_SPIQ], 50, RTEMS_MINIMUM_STACK_SIZE * 2,
196 Task_name[TASKID_SPIQ], 5, RTEMS_MINIMUM_STACK_SIZE * 2,
175 RTEMS_DEFAULT_MODES,
197 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
176 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
198 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
177 );
199 );
178 // SMIQ
200 // SMIQ
@@ -213,7 +235,7 int create_all_tasks()
213 );
235 );
214 // HOUS
236 // HOUS
215 status = rtems_task_create(
237 status = rtems_task_create(
216 Task_name[TASKID_HOUS], 200, RTEMS_MINIMUM_STACK_SIZE * 2,
238 Task_name[TASKID_HOUS], 199, RTEMS_MINIMUM_STACK_SIZE * 2,
217 RTEMS_DEFAULT_MODES,
239 RTEMS_DEFAULT_MODES,
218 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
240 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_HOUS]
219 );
241 );
@@ -262,53 +284,43 int configure_spw_link()
262 {
284 {
263 rtems_status_code status;
285 rtems_status_code status;
264
286
265 close(fdSPW); // close the device if it is already open
287 close(fdSPW); // close the device if it is already open
288 PRINTF("OK *** in configure_spw_link *** try to open "GRSPW_DEVICE_NAME"\n")
266 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
289 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
267 if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
290 if (fdSPW<0) PRINTF("ERR *** in configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
268 while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, 0) != RTEMS_SUCCESSFUL){
291 while(ioctl(fdSPW, SPACEWIRE_IOCTRL_START, 0) != RTEMS_SUCCESSFUL){
269 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" not started, retry\n")
292 PRINTF(".")
293 fflush(stdout);
270 close(fdSPW); // close the device
294 close(fdSPW); // close the device
271 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
295 fdSPW = open(GRSPW_DEVICE_NAME, O_RDWR); // open the device. the open call reset the hardware
272 if (fdSPW<0) PRINTF("In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
296 if (fdSPW<0) PRINTF("ERR *** In configure_spw_link *** Error opening"GRSPW_DEVICE_NAME"\n")
273 rtems_task_wake_after(100);
297 rtems_task_wake_after(100);
274 }
298 }
275
299
276 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n")
300 PRINTF("OK *** In configure_spw_link *** "GRSPW_DEVICE_NAME" opened and started successfully\n")
277
278 // sets a few parameters of the link
279 //status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RMAPEN, 1); // sets the RMAP enable bit
280 //if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RMAPEN\n")
281
301
282 configure_spacewire_set_NP(1, REGS_ADDR_GRSPW); // No Port force
302 configure_spacewire_set_NP(1, REGS_ADDR_GRSPW); // No Port force
283 configure_spacewire_set_RE(1, REGS_ADDR_GRSPW); // the dedicated call seems to break the no port force configuration
303 configure_spacewire_set_RE(1, REGS_ADDR_GRSPW); // the dedicated call seems to break the no port force configuration
284
304
285 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
305 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_RXBLOCK, 1); // sets the blocking mode for reception
286 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
306 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_RXBLOCK\n")
287 //
307 //
288 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_EVENT_ID, Task_id[TASKID_SPIQ]); // sets the task ID to which an event is sent when a
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
289 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
309 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_EVENT_ID\n") // link-error interrupt occurs
290 //
310 //
291 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 1); // automatic link-disabling due to link-error interrupts
311 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DISABLE_ERR, 1); // automatic link-disabling due to link-error interrupts
292 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
312 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_DISABLE_ERR\n")
293 //
313 //
294 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
314 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ, 1); // sets the link-error interrupt bit
295 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
315 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ\n")
296 //
316 //
297 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // sets the link-error interrupt bit
317 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL, 1); // sets the link-error interrupt bit
298 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
318 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL\n")
299 //
300 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_DESTKEY, CCSDS_DESTINATION_ID); // sets the destination key
301 PRINTF1("destination address set to: %d\n", CCSDS_DESTINATION_ID)
302 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_DESTKEY\n")
303 //
304 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_NODEADDR, CCSDS_NODE_ADDRESS); // sets the node address
305 PRINTF1("node address set to: %d\n", CCSDS_NODE_ADDRESS)
306 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_NODEADDR\n")
307 //
319 //
308 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909);
320 status = ioctl(fdSPW, SPACEWIRE_IOCTRL_SET_TCODE_CTRL, 0x0909);
309 if (status!=RTEMS_SUCCESSFUL) PRINTF("In RECV *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
321 if (status!=RTEMS_SUCCESSFUL) PRINTF("in SPIQ *** Error SPACEWIRE_IOCTRL_SET_TCODE_CTRL,\n")
310
322
311 PRINTF("In configure_spw_link *** "GRSPW_DEVICE_NAME" configured successfully\n")
323 PRINTF("OK *** in configure_spw_link *** "GRSPW_DEVICE_NAME" configured successfully\n")
312
324
313 return RTEMS_SUCCESSFUL;
325 return RTEMS_SUCCESSFUL;
314 }
326 }
@@ -5,6 +5,7 extern rtems_id Task_id[]; /* ar
5 extern int fdSPW;
5 extern int fdSPW;
6 extern TMHeader_t housekeeping_header;
6 extern TMHeader_t housekeeping_header;
7 extern char housekeeping_data[];
7 extern char housekeeping_data[];
8 extern Packet_TM_LFR_HK_t housekeeping_packet;
8
9
9 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
10 int configure_timer(gptimer_regs_t *gptimer_regs, unsigned char timer, unsigned int clock_divider,
10 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
11 unsigned char interrupt_level, rtems_isr (*timer_isr)() )
@@ -55,14 +56,30 int send_console_outputs_on_serial_port(
55 return 0;
56 return 0;
56 }
57 }
57
58
59 int set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value)
60 {
61 struct apbuart_regs_str *apbuart_regs;
62
63 apbuart_regs = (struct apbuart_regs_str *) regs;
64 apbuart_regs->scaler = value;
65 PRINTF1("OK *** COM port scaler reload register set to %x\n", value)
66
67 return 0;
68 }
69
70 //************
71 // RTEMS TASKS
72
58 rtems_task stat_task(rtems_task_argument argument)
73 rtems_task stat_task(rtems_task_argument argument)
59 {
74 {
60 int i;
75 int i;
61 i = 0;
76 int j;
62 PRINTF("In STAT *** \n")
77 i = 0;
78 j = 0;
79 PRINTF("in STAT *** \n")
63 while(1){
80 while(1){
64 rtems_task_wake_after(1000);
81 rtems_task_wake_after(1000);
65 PRINTF1("%d\n", i)
82 PRINTF1("%d\n", j)
66 if (i == 2) {
83 if (i == 2) {
67 #ifdef PRINT_TASK_STATISTICS
84 #ifdef PRINT_TASK_STATISTICS
68 rtems_cpu_usage_report();
85 rtems_cpu_usage_report();
@@ -70,67 +87,70 rtems_task stat_task(rtems_task_argument
70 #endif
87 #endif
71 i = 0;
88 i = 0;
72 }
89 }
73 else i++;
90 else i++;
91 j++;
74 }
92 }
75 }
93 }
76
94
77 rtems_task hous_task(rtems_task_argument argument)
95 rtems_task hous_task(rtems_task_argument argument)
78 {
96 {
97 PRINTF("in HOUS ***\n")
98
99 int result;
79 rtems_status_code status;
100 rtems_status_code status;
80
101
81 spw_ioctl_pkt_send spw_ioctl_send;
102 if (rtems_rate_monotonic_ident( HK_name, &HK_id)!=RTEMS_SUCCESSFUL)
103 {
104 status = rtems_rate_monotonic_create( HK_name, &HK_id );
105 if( status != RTEMS_SUCCESSFUL )
106 PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status )
107 }
108
109 housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID;
110 housekeeping_packet.protocolIdentifier = 0x02;
111 housekeeping_packet.reserved = 0x00;
112 housekeeping_packet.userApplication = 0x00;
113 housekeeping_packet.packetID[0] = 0x0c;
114 housekeeping_packet.packetID[1] = 0xc4;
115 housekeeping_packet.packetSequenceControl[0] = 0xc0;
116 housekeeping_packet.packetSequenceControl[1] = 0x00;
117 housekeeping_packet.packetLength[0] = 0x00;
118 housekeeping_packet.packetLength[1] = 0x77;
119 housekeeping_packet.dataFieldHeader[0] = 0x10;
120 housekeeping_packet.dataFieldHeader[1] = 0x03;
121 housekeeping_packet.dataFieldHeader[2] = 0x19;
122 housekeeping_packet.dataFieldHeader[3] = 0x00;
123
124 status = rtems_rate_monotonic_cancel(HK_id);
125 if( status != RTEMS_SUCCESSFUL )
126 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status )
127 else
128 PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n")
82
129
83 rtems_name name;
130 while(1){ // launch the rate monotonic task
84 rtems_id period;
131 status = rtems_rate_monotonic_period( HK_id, HK_PERIOD );
85 name = rtems_build_name( 'H', 'O', 'U', 'S' );
132 if ( status != RTEMS_SUCCESSFUL ){
86 status = rtems_rate_monotonic_create( name, &period );
133 PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_period *** code %d\n", status);
87 if( status != RTEMS_SUCCESSFUL ) {
134 }
88 printf( "rtems_rate_monotonic_create failed with status of %d\n", status );
135 else
89 exit( 1 );
136 {
137 housekeeping_packet.dataFieldHeader[4] = (unsigned char) (time_management_regs->coarse_time>>24);
138 housekeeping_packet.dataFieldHeader[5] = (unsigned char) (time_management_regs->coarse_time>>16);
139 housekeeping_packet.dataFieldHeader[6] = (unsigned char) (time_management_regs->coarse_time>>8);
140 housekeeping_packet.dataFieldHeader[7] = (unsigned char) (time_management_regs->coarse_time);
141 housekeeping_packet.dataFieldHeader[8] = (unsigned char) (time_management_regs->fine_time>>8);
142 housekeeping_packet.dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time);
143 housekeeping_packet.data[0] = CCSDS_DESTINATION_ID_DPU;
144 result = write ( fdSPW, &housekeeping_packet, LEN_TM_LFR_HK);
145 if (result==-1)
146 {
147 PRINTF("ERR *** in HOUS *** HK send\n");
148 }
149 }
90 }
150 }
91
151
92 // filling the structure for the spacewire transmission
152 PRINTF("in HOUS *** deleting task\n")
93 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
94 spw_ioctl_send.hdr = (char*) &housekeeping_header;
95 spw_ioctl_send.dlen = LENGTH_TM_LFR_HK - 10 + 1;
96 spw_ioctl_send.data = housekeeping_data;
97
98 housekeeping_header.targetLogicalAddress = CCSDS_DESTINATION_ID;
99 housekeeping_header.protocolIdentifier = 0x02;
100 housekeeping_header.reserved = 0x00;
101 housekeeping_header.userApplication = 0x00;
102 housekeeping_header.packetID[0] = 0x0c;
103 housekeeping_header.packetID[1] = 0xc4;
104 housekeeping_header.packetSequenceControl[0] = 0xc0;
105 housekeeping_header.packetSequenceControl[1] = 0x00;
106 housekeeping_header.packetLength[0] = 0x00;
107 housekeeping_header.packetLength[1] = 0x77;
108 housekeeping_header.dataFieldHeader[0] = 0x10;
109 housekeeping_header.dataFieldHeader[1] = 0x03;
110 housekeeping_header.dataFieldHeader[2] = 0x19;
111 housekeeping_header.dataFieldHeader[3] = 0x00;
112
153
113 printf("In HOUS ***\n");
114
115 while(1){ // launch the rate monotonic task
116 if ( rtems_rate_monotonic_period( period, HK_PERIOD ) == RTEMS_TIMEOUT ){
117 printf( "ERR *** in hous_task *** RTEMS_TIMEOUT\n" );
118 break;
119 }
120 housekeeping_header.dataFieldHeader[4] = (unsigned char) (time_management_regs->coarse_time>>24);
121 housekeeping_header.dataFieldHeader[5] = (unsigned char) (time_management_regs->coarse_time>>16);
122 housekeeping_header.dataFieldHeader[6] = (unsigned char) (time_management_regs->coarse_time>>8);
123 housekeeping_header.dataFieldHeader[7] = (unsigned char) (time_management_regs->coarse_time);
124 housekeeping_header.dataFieldHeader[8] = (unsigned char) (time_management_regs->fine_time>>8);
125 housekeeping_header.dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time);
126 status = write_spw(&spw_ioctl_send);
127 }
128
129 status = rtems_rate_monotonic_delete( period );
130 if ( status != RTEMS_SUCCESSFUL ) {
131 printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status );
132 exit( 1 );
133 }
134 status = rtems_task_delete( RTEMS_SELF ); // should not return
154 status = rtems_task_delete( RTEMS_SELF ); // should not return
135 printf( "rtems_task_delete returned with status of %d.\n", status );
155 printf( "rtems_task_delete returned with status of %d.\n", status );
136 exit( 1 );
156 exit( 1 );
@@ -61,14 +61,17 extern BP1_t data_BP1[ ];
61 extern rtems_id Task_id[ ]; /* array of task ids */
61 extern rtems_id Task_id[ ]; /* array of task ids */
62
62
63 spectral_matrices_regs_t *spectral_matrices_regs;
63 spectral_matrices_regs_t *spectral_matrices_regs;
64
64
65 //***********************************************************
65 // Interrupt Service Routine for spectral matrices processing
66 // Interrupt Service Routine for spectral matrices processing
66 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
67 rtems_isr spectral_matrices_isr( rtems_vector_number vector )
67 {
68 {
68 if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
69 if (rtems_event_send( Task_id[TASKID_SMIQ], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
69 printf("In spectral_matrices_isr *** Error sending event to AVF0\n");
70 printf("in spectral_matrices_isr *** Error sending event to AVF0\n");
70 }
71 }
71
72
73 //************
74 // RTEMS TASKS
72 rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
75 rtems_task smiq_task(rtems_task_argument argument) // process the Spectral Matrices IRQ
73 {
76 {
74 rtems_event_set event_out;
77 rtems_event_set event_out;
@@ -76,17 +79,16 rtems_task smiq_task(rtems_task_argument
76 gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
79 gptimer_regs = (gptimer_regs_t *) REGS_ADDR_GPTIMER;
77 unsigned char nb_interrupt_f0 = 0;
80 unsigned char nb_interrupt_f0 = 0;
78
81
79 PRINTF("In SMIQ *** \n")
82 PRINTF("in SMIQ *** \n")
80
83
81 while(1){
84 while(1){
82 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
85 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
83 nb_interrupt_f0 = nb_interrupt_f0 + 1;
86 nb_interrupt_f0 = nb_interrupt_f0 + 1;
84 if (nb_interrupt_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) ){
87 if (nb_interrupt_f0 == (NB_SM_TO_RECEIVE_BEFORE_AVF0-1) ){
85 if (rtems_event_send( Task_id[6], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
88 if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL)
86 printf("In smiq_task *** Error sending event to AVF0\n");
89 printf("in SMIQ *** Error sending event to AVF0\n");
87 nb_interrupt_f0 = 0;
90 nb_interrupt_f0 = 0;
88 }
91 }
89 gptimer_regs->timer[1].ctrl = gptimer_regs->timer[1].ctrl | 0x00000010;
90 }
92 }
91 }
93 }
92
94
@@ -104,7 +106,7 rtems_task spw_bppr_task(rtems_task_argu
104 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
106 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
105 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
107 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
106
108
107 printf("In BPPR ***\n");
109 printf("in BPPR ***\n");
108
110
109 while(1){ // wait for an event to begin with the processing
111 while(1){ // wait for an event to begin with the processing
110 status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out);
112 status = rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out);
@@ -131,6 +133,57 rtems_task spw_bppr_task(rtems_task_argu
131 }
133 }
132 }
134 }
133
135
136 rtems_task avf0_task(rtems_task_argument argument){
137 int i;
138 static int nb_average;
139 rtems_event_set event_out;
140 rtems_status_code status;
141
142 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES;
143 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
144 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
145
146 nb_average = 0;
147
148 PRINTF("in AVFO *** \n")
149
150 while(1){
151 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
152 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
153 averaged_spec_mat_f0[i] = averaged_spec_mat_f0[i] + spec_mat_f0_a[i]
154 + spec_mat_f0_b[i]
155 + spec_mat_f0_c[i]
156 + spec_mat_f0_d[i]
157 + spec_mat_f0_e[i]
158 + spec_mat_f0_f[i]
159 + spec_mat_f0_g[i]
160 + spec_mat_f0_h[i];
161 }
162 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe; // reset the appropriate bit in the register
163 nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0;
164 if (nb_average == NB_AVERAGE_NORMAL_f0) {
165 nb_average = 0;
166 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);
168 }
169 }
170 }
171
172 rtems_task bpf0_task(rtems_task_argument argument){
173 rtems_event_set event_out;
174
175 PRINTF("in BPFO *** \n")
176
177 while(1){
178 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
179 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
180 BP1_set(compressed_spec_mat_f0, NB_BINS_COMPRESSED_MATRIX_f0, LFR_BP1_F0);
181 //PRINTF("IN TASK BPF0 *** Matrix compressed, parameters calculated\n")
182 }
183 }
184
185 //*****************************
186 // Spectral matrices processing
134 void matrix_average(volatile int *spec_mat, float *averaged_spec_mat)
187 void matrix_average(volatile int *spec_mat, float *averaged_spec_mat)
135 {
188 {
136 int i;
189 int i;
@@ -172,10 +225,10 void matrix_compression(float *averaged_
172 }
225 }
173 break;
226 break;
174 case 1:
227 case 1:
175 // case fChannel = f1 tp be completed later
228 // case fChannel = f1 to be completed later
176 break;
229 break;
177 case 2:
230 case 2:
178 // case fChannel = f1 tp be completed later
231 // case fChannel = f1 to be completed later
179 break;
232 break;
180 default:
233 default:
181 break;
234 break;
@@ -350,98 +403,4 void BP2_set(float * compressed_spec_mat
350 compressed_spec_mat[i*30+23] = compressed_spec_mat[i*30+23] / aux;
403 compressed_spec_mat[i*30+23] = compressed_spec_mat[i*30+23] / aux;
351 }
404 }
352 }
405 }
353
354 rtems_task avf0_task(rtems_task_argument argument){
355 int i;
356 static int nb_average;
357 rtems_event_set event_out;
358 rtems_status_code status;
359
406
360 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES;
361 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
362 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
363
364 nb_average = 0;
365
366 PRINTF("In AVFO *** \n")
367
368 while(1){
369 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
370 for(i=0; i<TOTAL_SIZE_SPEC_MAT; i++){
371 averaged_spec_mat_f0[i] = averaged_spec_mat_f0[i] + spec_mat_f0_a[i]
372 + spec_mat_f0_b[i]
373 + spec_mat_f0_c[i]
374 + spec_mat_f0_d[i]
375 + spec_mat_f0_e[i]
376 + spec_mat_f0_f[i]
377 + spec_mat_f0_g[i]
378 + spec_mat_f0_h[i];
379 }
380 spectral_matrices_regs->ctrl = spectral_matrices_regs->ctrl & 0xfffffffe; // reset the appropriate bit in the register
381 nb_average = nb_average + NB_SM_TO_RECEIVE_BEFORE_AVF0;
382 if (nb_average == NB_AVERAGE_NORMAL_f0) {
383 nb_average = 0;
384 status = rtems_event_send( Task_id[7], RTEMS_EVENT_0 ); // sending an event to the task 7, BPF0
385 if (status != RTEMS_SUCCESSFUL) printf("IN TASK AVF0 *** Error sending RTEMS_EVENT_0, code %d\n", status);
386 }
387 }
388 }
389
390 rtems_task bpf0_task(rtems_task_argument argument){
391 rtems_event_set event_out;
392
393 PRINTF("In BPFO *** \n")
394
395 while(1){
396 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
397 matrix_compression(averaged_spec_mat_f0, 0, compressed_spec_mat_f0);
398 BP1_set(compressed_spec_mat_f0, NB_BINS_COMPRESSED_MATRIX_f0, LFR_BP1_F0);
399 //PRINTF("IN TASK BPF0 *** Matrix compressed, parameters calculated\n")
400 }
401 }
402
403 //*******
404 // UNUSED
405 rtems_task spw_bppr_task_rate_monotonic(rtems_task_argument argument)
406 {/*
407 rtems_status_code status;
408 //static int nb_average_f1 = 0;
409 //static int nb_average_f2 = 0;
410
411 rtems_name name;
412 rtems_id period;
413 name = rtems_build_name( 'P', 'E', 'R', 'D' );
414 status = rtems_rate_monotonic_create( name, &period );
415 if( status != RTEMS_SUCCESSFUL ) {
416 printf( "rtems_rate_monotonic_create failed with status of %d\n", status );
417 //exit( 1 );
418 }
419
420 spectral_matrices_regs = (struct spectral_matrices_regs_str *) REGS_ADDR_SPECTRAL_MATRICES;
421 spectral_matrices_regs->address0 = (volatile int) spec_mat_f0_a;
422 spectral_matrices_regs->address1 = (volatile int) spec_mat_f0_b;
423
424 printf("In BPPR BIS ***\n");
425
426 while(1){ // launch the rate monotonic task
427 if ( rtems_rate_monotonic_period( period, 8 ) == RTEMS_TIMEOUT ){
428 printf("TIMEOUT\n");
429 //break;
430 }
431 status = rtems_event_send( Task_id[6], RTEMS_EVENT_0 ); // sending an event to the task 6, AVF0
432 if (status != RTEMS_SUCCESSFUL) printf("IN TASK BPPR BIS *** Error sending RTEMS_EVENT_0 to AVF0, code %d\n", status);
433 }
434
435 status = rtems_rate_monotonic_delete( period );
436 if ( status != RTEMS_SUCCESSFUL ) {
437 printf( "rtems_rate_monotonic_delete failed with status of %d.\n", status );
438 //exit( 1 );
439 }
440 status = rtems_task_delete( RTEMS_SELF ); // should not return
441 printf( "rtems_task_delete returned with status of %d.\n", status );
442 //exit( 1 );*/
443 }
444
445
446
447
@@ -48,7 +48,6 void GetCRCAsTwoBytes(unsigned char* dat
48 crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff);
48 crcAsTwoBytes[1] = (unsigned char) (Chk & 0x00ff);
49 }
49 }
50
50
51
52 //*********************
51 //*********************
53 // ACCEPTANCE FUNCTIONS
52 // ACCEPTANCE FUNCTIONS
54 int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv)
53 int TC_checker(ccsdsTelecommandPacket_t *TC, unsigned int tc_len_recv)
@@ -221,6 +220,64 unsigned char TM_build_header( enum TM_T
221 return 1;
220 return 1;
222 }
221 }
223
222
223 unsigned char TM_build_header_bis( enum TM_TYPE tm_type, unsigned int packetLength,
224 unsigned int coarseTime, unsigned int fineTime, Packet_TM_LFR_TC_EXE_t *packet)
225 {
226
227 packet->targetLogicalAddress = CCSDS_DESTINATION_ID;
228 packet->protocolIdentifier = 0x02;
229 packet->reserved = 0x00;
230 packet->userApplication = 0x00;
231 packet->packetID[0] = 0x0c;
232 packet->packetSequenceControl[0] = 0xc0;
233 packet->packetSequenceControl[1] = 0x00;
234 packet->packetLength[0] = (unsigned char) (packetLength>>8);
235 packet->packetLength[1] = (unsigned char) packetLength;
236 packet->dataFieldHeader[0] = 0x10;
237 packet->dataFieldHeader[3] = CCSDS_DESTINATION_ID;
238 switch (tm_type){
239 case(TM_LFR_TC_EXE_OK):
240 packet->packetID[1] = 0xc1;
241 packet->dataFieldHeader[1] = 1; // type
242 packet->dataFieldHeader[2] = 7; // subtype
243 break;
244 case(TM_LFR_TC_EXE_ERR):
245 packet->packetID[1] = 0xc1;
246 packet->dataFieldHeader[1] = 1; // type
247 packet->dataFieldHeader[2] = 8; // subtype
248 break;
249 case(TM_LFR_HK):
250 packet->packetID[1] = 0xc4;
251 packet->dataFieldHeader[1] = 3; // type
252 packet->dataFieldHeader[2] = 25; // subtype
253 break;
254 case(TM_LFR_SCI):
255 packet->packetID[1] = 0xcc;
256 packet->dataFieldHeader[1] = 21; // type
257 packet->dataFieldHeader[2] = 3; // subtype
258 break;
259 case(TM_LFR_SCI_SBM):
260 packet->packetID[1] = 0xfc;
261 packet->dataFieldHeader[1] = 21; // type
262 packet->dataFieldHeader[2] = 3; // subtype
263 break;
264 case(TM_LFR_PAR_DUMP):
265 packet->packetID[1] = 0xc9;
266 packet->dataFieldHeader[1] = 181; // type
267 packet->dataFieldHeader[2] = 31; // subtype
268 break;
269 default:
270 return 0;
271 }
272 packet->dataFieldHeader[4] = (unsigned char) (time_management_regs->coarse_time>>24);
273 packet->dataFieldHeader[5] = (unsigned char) (time_management_regs->coarse_time>>16);
274 packet->dataFieldHeader[6] = (unsigned char) (time_management_regs->coarse_time>>8);
275 packet->dataFieldHeader[7] = (unsigned char) (time_management_regs->coarse_time);
276 packet->dataFieldHeader[8] = (unsigned char) (time_management_regs->fine_time>>8);
277 packet->dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time);
278 return 1;
279 }
280
224 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC)
281 unsigned char TM_build_data(ccsdsTelecommandPacket_t *TC, char* data, unsigned int SID, unsigned char *computed_CRC)
225 {
282 {
226 unsigned int packetLength;
283 unsigned int packetLength;
@@ -264,6 +321,17 unsigned char TM_build_data(ccsdsTelecom
264 return 1;
321 return 1;
265 }
322 }
266
323
324 int create_message_queue()
325 {
326 rtems_status_code status;
327 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,
329 RTEMS_FIFO | RTEMS_LOCAL, &misc_id[0] );
330 if (status!=RTEMS_SUCCESSFUL) PRINTF("in create_message_queue *** error creating message queue\n")
331
332 return 0;
333 }
334
267 //***********
335 //***********
268 // RTEMS TASK
336 // RTEMS TASK
269 rtems_task recv_task( rtems_task_argument unused )
337 rtems_task recv_task( rtems_task_argument unused )
@@ -276,7 +344,7 rtems_task recv_task( rtems_task_argumen
276
344
277 for(i=0; i<100; i++) data[i] = 0;
345 for(i=0; i<100; i++) data[i] = 0;
278
346
279 PRINTF("In RECV *** \n")
347 PRINTF("in RECV *** \n")
280
348
281 while(1)
349 while(1)
282 {
350 {
@@ -310,7 +378,7 rtems_task actn_task( rtems_task_argumen
310 size_t size; // size of the incoming TC packet
378 size_t size; // size of the incoming TC packet
311 unsigned char subtype = 0; // subtype of the current TC packet
379 unsigned char subtype = 0; // subtype of the current TC packet
312
380
313 PRINTF("In ACTN *** \n")
381 PRINTF("in ACTN *** \n")
314
382
315 while(1)
383 while(1)
316 {
384 {
@@ -380,15 +448,20 rtems_task actn_task( rtems_task_argumen
380 }
448 }
381 }
449 }
382
450
383 int create_message_queue()
451 rtems_task dumb_task( rtems_task_argument unused )
384 {
452 {
385 rtems_status_code status;
453 unsigned int coarse_time;
386 misc_name[0] = rtems_build_name( 'Q', 'U', 'E', 'U' );
454 unsigned int fine_time;
387 status = rtems_message_queue_create( misc_name[0], ACTION_MSG_QUEUE_COUNT, CCSDS_TC_PKT_MAX_SIZE,
455 rtems_event_set event_out;
388 RTEMS_FIFO | RTEMS_LOCAL, &misc_id[0] );
456
389 if (status!=RTEMS_SUCCESSFUL) PRINTF("in create_message_queue *** error creating message queue\n")
457 PRINTF("in DUMB *** \n")
390
458
391 return 0;
459 while(1){
460 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
461 coarse_time = time_management_regs->coarse_time;
462 fine_time = time_management_regs->fine_time;
463 printf("in DUMB *** coarse time = %x, fine time = %x\n", coarse_time, fine_time);
464 }
392 }
465 }
393
466
394 //***********
467 //***********
@@ -396,30 +469,23 int create_message_queue()
396
469
397 int action_default(ccsdsTelecommandPacket_t *TC)
470 int action_default(ccsdsTelecommandPacket_t *TC)
398 {
471 {
399 TMHeader_t TM_header;
472 Packet_TM_LFR_TC_EXE_t packet;
400 char data[8];
401 spw_ioctl_pkt_send spw_ioctl_send;
402
473
403 TM_build_header( TM_LFR_TC_EXE_ERR, TM_LEN_NOT_IMP,
474 TM_build_header_bis( TM_LFR_TC_EXE_ERR, TM_LEN_NOT_IMP,
404 time_management_regs->coarse_time, time_management_regs->fine_time, &TM_header);
475 time_management_regs->coarse_time, time_management_regs->fine_time, &packet);
405
476
406 data[0] = 0x9c;
477 packet.data[0] = 0x9c;
407 data[1] = 0x42;
478 packet.data[1] = 0x42;
408 data[2] = TC->packetID[0];
479 packet.data[2] = TC->packetID[0];
409 data[3] = TC->packetID[1];
480 packet.data[3] = TC->packetID[1];
410 data[4] = TC->packetSequenceControl[0];
481 packet.data[4] = TC->packetSequenceControl[0];
411 data[5] = TC->packetSequenceControl[1];
482 packet.data[5] = TC->packetSequenceControl[1];
412 data[6] = TC->dataFieldHeader[1]; // type
483 packet.data[6] = TC->dataFieldHeader[1]; // type
413 data[7] = TC->dataFieldHeader[2]; // subtype
484 packet.data[7] = TC->dataFieldHeader[2]; // subtype
414
415 // filling the structure for the spacewire transmission
416 spw_ioctl_send.hlen = TM_HEADER_LEN + 4; // + 4 is for the protocole extra header
417 spw_ioctl_send.hdr = (char*) &TM_header;
418 spw_ioctl_send.dlen = 8;
419 spw_ioctl_send.data = data;
420
485
421 // SEND DATA
486 // SEND DATA
422 write_spw(&spw_ioctl_send);
487 if (write ( fdSPW, &packet, LEN_TM_LFR_TC_EXE_NOT_IMP)==-1)
488 PRINTF("ERR *** in action_default *** send TM packet\n");
423
489
424 return 0;
490 return 0;
425 }
491 }
@@ -511,21 +577,6 rtems_isr commutation_isr2( rtems_vector
511 printf("In commutation_isr2 *** Error sending event to DUMB\n");
577 printf("In commutation_isr2 *** Error sending event to DUMB\n");
512 }
578 }
513
579
514 rtems_task dumb_task( rtems_task_argument unused )
515 {
516 unsigned int coarse_time;
517 unsigned int fine_time;
518 rtems_event_set event_out;
519
520 PRINTF("In DUMB *** \n")
521
522 while(1){
523 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
524 coarse_time = time_management_regs->coarse_time;
525 fine_time = time_management_regs->fine_time;
526 printf("commutation_isr*, coarse time = %x, fine time = %x\n", coarse_time, fine_time);
527 }
528 }
529
580
530
581
531
582
@@ -29,7 +29,7 rtems_task wfrm_task(rtems_task_argument
29 header.dataFieldHeader[0] = 0x10;
29 header.dataFieldHeader[0] = 0x10;
30 header.dataFieldHeader[1] = 0x15; // service type
30 header.dataFieldHeader[1] = 0x15; // service type
31 header.dataFieldHeader[2] = 0x03; // service subtype
31 header.dataFieldHeader[2] = 0x03; // service subtype
32 header.dataFieldHeader[3] = CCSDS_DESTINATION_ID;
32 header.dataFieldHeader[3] = CCSDS_DESTINATION_ID_GROUND;
33
33
34 header.auxiliaryHeader[0] = 0x00;
34 header.auxiliaryHeader[0] = 0x00;
35 header.auxiliaryHeader[1] = 0x1f;
35 header.auxiliaryHeader[1] = 0x1f;
@@ -42,7 +42,7 rtems_task wfrm_task(rtems_task_argument
42 spw_ioctl_send.hlen = TM_HEADER_LEN + 4 + 6; // + 4 is for the protocole extra header, + 6 is for the auxiliary header
42 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;
43 spw_ioctl_send.hdr = (char*) &header;
44
44
45 PRINTF("In WFRM *** \n")
45 PRINTF("in WFRM *** \n")
46
46
47 while(1){
47 while(1){
48 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
48 rtems_event_receive(RTEMS_EVENT_0, RTEMS_WAIT, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT0
@@ -54,14 +54,19 rtems_task wfrm_task(rtems_task_argument
54 header.dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time);
54 header.dataFieldHeader[9] = (unsigned char) (time_management_regs->fine_time);
55 for (i=0; i<7; i++) // send F0
55 for (i=0; i<7; i++) // send F0
56 {
56 {
57 header.auxiliaryHeader[3] = (unsigned char) i+1; // PKT_NR
57 // BUILD THE DATA
58 // BUILD THE DATA
58 if (i==6) {
59 if (i==6) {
59 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
60 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
60 length = TM_LEN_SCI_NORM_SWF_340;
61 length = TM_LEN_SCI_NORM_SWF_8;
61 }
62 header.auxiliaryHeader[4] = 0x00; // BLK_NR MSB
63 header.auxiliaryHeader[5] = 0x08; // BLK_NR LSB
64 }
62 else {
65 else {
63 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
66 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
64 length = TM_LEN_SCI_NORM_SWF_8;
67 length = TM_LEN_SCI_NORM_SWF_340;
68 header.auxiliaryHeader[4] = 0x01; // BLK_NR MSB
69 header.auxiliaryHeader[5] = 0x54; // BLK_NR LSB
65 }
70 }
66 spw_ioctl_send.data = (char*) &wf_snap_f0[i * 340 * NB_BYTES_SWF_BLK];
71 spw_ioctl_send.data = (char*) &wf_snap_f0[i * 340 * NB_BYTES_SWF_BLK];
67 // BUILD THE HEADER
72 // BUILD THE HEADER
@@ -73,14 +78,19 rtems_task wfrm_task(rtems_task_argument
73 }
78 }
74 for (i=0; i<7; i++) // send F1
79 for (i=0; i<7; i++) // send F1
75 {
80 {
81 header.auxiliaryHeader[3] = (unsigned char) i+1; // PKT_NR
76 // BUILD THE DATA
82 // BUILD THE DATA
77 if (i==6) {
83 if (i==6) {
78 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
84 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
79 length = TM_LEN_SCI_NORM_SWF_340;
85 length = TM_LEN_SCI_NORM_SWF_8;
80 }
86 header.auxiliaryHeader[4] = 0x00; // BLK_NR MSB
87 header.auxiliaryHeader[5] = 0x08; // BLK_NR LSB
88 }
81 else {
89 else {
82 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
90 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
83 length = TM_LEN_SCI_NORM_SWF_8;
91 length = TM_LEN_SCI_NORM_SWF_340;
92 header.auxiliaryHeader[4] = 0x01; // BLK_NR MSB
93 header.auxiliaryHeader[5] = 0x54; // BLK_NR LSB
84 }
94 }
85 spw_ioctl_send.data = (char*) &wf_snap_f1[i * 340 * NB_BYTES_SWF_BLK];
95 spw_ioctl_send.data = (char*) &wf_snap_f1[i * 340 * NB_BYTES_SWF_BLK];
86 // BUILD THE HEADER
96 // BUILD THE HEADER
@@ -90,16 +100,21 rtems_task wfrm_task(rtems_task_argument
90 // SEND PACKET
100 // SEND PACKET
91 write_spw(&spw_ioctl_send);
101 write_spw(&spw_ioctl_send);
92 }
102 }
93 for (i=0; i<7; i++) // send F0
103 for (i=0; i<7; i++) // send F2
94 {
104 {
105 header.auxiliaryHeader[3] = (unsigned char) i+1; // PKT_NR
95 // BUILD THE DATA
106 // BUILD THE DATA
96 if (i==6) {
107 if (i==6) {
97 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
108 spw_ioctl_send.dlen = 8 * NB_BYTES_SWF_BLK;
98 length = TM_LEN_SCI_NORM_SWF_340;
109 length = TM_LEN_SCI_NORM_SWF_8;
99 }
110 header.auxiliaryHeader[4] = 0x00; // BLK_NR MSB
111 header.auxiliaryHeader[5] = 0x08; // BLK_NR LSB
112 }
100 else {
113 else {
101 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
114 spw_ioctl_send.dlen = 340 * NB_BYTES_SWF_BLK;
102 length = TM_LEN_SCI_NORM_SWF_8;
115 length = TM_LEN_SCI_NORM_SWF_340;
116 header.auxiliaryHeader[4] = 0x01; // BLK_NR MSB
117 header.auxiliaryHeader[5] = 0x54; // BLK_NR LSB
103 }
118 }
104 spw_ioctl_send.data = (char*) &wf_snap_f2[i * 340 * NB_BYTES_SWF_BLK];
119 spw_ioctl_send.data = (char*) &wf_snap_f2[i * 340 * NB_BYTES_SWF_BLK];
105 // BUILD THE HEADER
120 // BUILD THE HEADER
@@ -113,3 +128,49 rtems_task wfrm_task(rtems_task_argument
113 gptimer_regs->timer[2].ctrl = gptimer_regs->timer[2].ctrl | 0x00000010;
128 gptimer_regs->timer[2].ctrl = gptimer_regs->timer[2].ctrl | 0x00000010;
114 }
129 }
115 }
130 }
131
132 //******************
133 // general functions
134 void init_waveforms()
135 {
136 int i = 0;
137
138 for (i=0; i< NB_SAMPLES_PER_SNAPSHOT; i++)
139 {
140 wf_snap_f0[ i* NB_WORDS_SWF_BLK + 0 ] = buil_value( i, 2*i ); // v and e1
141 wf_snap_f0[ i* NB_WORDS_SWF_BLK + 1 ] = buil_value( 3*i, 4*i ); // e2 and b1
142 wf_snap_f0[ i* NB_WORDS_SWF_BLK + 2 ] = buil_value( i, 2*i ); // b2 and b3
143 wf_snap_f1[ i* NB_WORDS_SWF_BLK + 0 ] = buil_value( i, 2*i ); // v and 1
144 wf_snap_f1[ i* NB_WORDS_SWF_BLK + 1 ] = buil_value( i, 2*i ); // e2 and b1
145 wf_snap_f1[ i* NB_WORDS_SWF_BLK + 2 ] = buil_value( i, 2*i ); // b2 and b3
146 wf_snap_f2[ i* NB_WORDS_SWF_BLK + 0 ] = buil_value( i, 2*i ); // v and 1
147 wf_snap_f2[ i* NB_WORDS_SWF_BLK + 1 ] = buil_value( i, 2*i ); // e2 and b1
148 wf_snap_f2[ i* NB_WORDS_SWF_BLK + 2 ] = buil_value( i, 2*i ); // b2 and b3
149 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 0 ] = buil_value( i, 2*i ); // v and 1
150 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 1 ] = buil_value( i, 2*i ); // e2 and b1
151 wf_cont_f3[ i* NB_WORDS_SWF_BLK + 2 ] = buil_value( i, 2*i ); // b2 and b3
152 }
153 }
154
155 int buil_value(int value1, int value0)
156 {
157 int aux = 0;
158 int aux1 = 0;
159 int aux0 = 0;
160 //******
161 // B3 B2
162 aux1 = ( (int) ( (char) (value1 >> 8) ) << 8 )
163 + ( (int) ( (char) (value1 ) ) );
164
165 //******
166 // B1 B0
167 aux0 = ( (int) ( (char) (value0 >> 8) ) << 8 )
168 + ( (int) ( (char) (value0 ) ) );
169
170 aux = (aux1 << 16) + aux0;
171
172 return aux;
173 }
174
175
176
General Comments 0
You need to be logged in to leave comments. Login now