##// 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);