@@ -1,2 +1,2 | |||||
1 | 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters |
|
1 | 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters | |
2 | e1bf35e31e3c8c1d1448d2e485c71f5f1259615c header/lfr_common_headers |
|
2 | 721463c11a484e6a3439e16c99f8bd27720b9265 header/lfr_common_headers |
@@ -1,69 +1,77 | |||||
1 | #ifndef FSW_MISC_H_INCLUDED |
|
1 | #ifndef FSW_MISC_H_INCLUDED | |
2 | #define FSW_MISC_H_INCLUDED |
|
2 | #define FSW_MISC_H_INCLUDED | |
3 |
|
3 | |||
4 | #include <rtems.h> |
|
4 | #include <rtems.h> | |
5 | #include <stdio.h> |
|
5 | #include <stdio.h> | |
6 | #include <grspw.h> |
|
6 | #include <grspw.h> | |
7 | #include <grlib_regs.h> |
|
7 | #include <grlib_regs.h> | |
8 |
|
8 | |||
9 | #include "fsw_params.h" |
|
9 | #include "fsw_params.h" | |
10 | #include "fsw_spacewire.h" |
|
10 | #include "fsw_spacewire.h" | |
11 | #include "lfr_cpu_usage_report.h" |
|
11 | #include "lfr_cpu_usage_report.h" | |
12 |
|
12 | |||
13 | enum lfr_reset_cause_t{ |
|
13 | enum lfr_reset_cause_t{ | |
14 | UNKNOWN_CAUSE, |
|
14 | UNKNOWN_CAUSE, | |
15 | POWER_ON, |
|
15 | POWER_ON, | |
16 | TC_RESET, |
|
16 | TC_RESET, | |
17 | WATCHDOG, |
|
17 | WATCHDOG, | |
18 | ERROR_RESET, |
|
18 | ERROR_RESET, | |
19 | UNEXP_RESET |
|
19 | UNEXP_RESET | |
20 | }; |
|
20 | }; | |
21 |
|
21 | |||
|
22 | extern gptimer_regs_t *gptimer_regs; | |||
|
23 | ||||
22 | #define LFR_RESET_CAUSE_UNKNOWN_CAUSE 0 |
|
24 | #define LFR_RESET_CAUSE_UNKNOWN_CAUSE 0 | |
23 |
|
25 | |||
24 |
rtems_name name_hk_rate_monotonic; |
|
26 | rtems_name name_hk_rate_monotonic; // name of the HK rate monotonic | |
25 | rtems_id HK_id; // id of the HK rate monotonic period |
|
27 | rtems_id HK_id; // id of the HK rate monotonic period | |
26 |
|
28 | |||
27 |
void configure |
|
29 | void timer_configure( unsigned char timer, unsigned int clock_divider, | |
28 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ); |
|
30 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ); | |
29 |
void timer_start( |
|
31 | void timer_start( unsigned char timer ); | |
30 |
void timer_stop( |
|
32 | void timer_stop( unsigned char timer ); | |
31 |
void timer_set_clock_divider( |
|
33 | void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider); | |
|
34 | ||||
|
35 | // WATCHDOG | |||
|
36 | rtems_isr watchdog_isr( rtems_vector_number vector ); | |||
|
37 | void watchdog_configure(void); | |||
|
38 | void watchdog_stop(void); | |||
|
39 | void watchdog_start(void); | |||
32 |
|
40 | |||
33 | // SERIAL LINK |
|
41 | // SERIAL LINK | |
34 | int send_console_outputs_on_apbuart_port( void ); |
|
42 | int send_console_outputs_on_apbuart_port( void ); | |
35 | int enable_apbuart_transmitter( void ); |
|
43 | int enable_apbuart_transmitter( void ); | |
36 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value); |
|
44 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value); | |
37 |
|
45 | |||
38 | // RTEMS TASKS |
|
46 | // RTEMS TASKS | |
39 |
rtems_task |
|
47 | rtems_task load_task( rtems_task_argument argument ); | |
40 | rtems_task hous_task( rtems_task_argument argument ); |
|
48 | rtems_task hous_task( rtems_task_argument argument ); | |
41 | rtems_task dumb_task( rtems_task_argument unused ); |
|
49 | rtems_task dumb_task( rtems_task_argument unused ); | |
42 |
|
50 | |||
43 | void init_housekeeping_parameters( void ); |
|
51 | void init_housekeeping_parameters( void ); | |
44 | void increment_seq_counter(unsigned short *packetSequenceControl); |
|
52 | void increment_seq_counter(unsigned short *packetSequenceControl); | |
45 | void getTime( unsigned char *time); |
|
53 | void getTime( unsigned char *time); | |
46 | unsigned long long int getTimeAsUnsignedLongLongInt( ); |
|
54 | unsigned long long int getTimeAsUnsignedLongLongInt( ); | |
47 | void send_dumb_hk( void ); |
|
55 | void send_dumb_hk( void ); | |
48 | void get_temperatures( unsigned char *temperatures ); |
|
56 | void get_temperatures( unsigned char *temperatures ); | |
49 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ); |
|
57 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ); | |
50 | void get_cpu_load( unsigned char *resource_statistics ); |
|
58 | void get_cpu_load( unsigned char *resource_statistics ); | |
51 | void set_hk_lfr_sc_potential_flag( bool state ); |
|
59 | void set_hk_lfr_sc_potential_flag( bool state ); | |
52 | void set_hk_lfr_mag_fields_flag( bool state ); |
|
60 | void set_hk_lfr_mag_fields_flag( bool state ); | |
53 | void set_hk_lfr_calib_enable( bool state ); |
|
61 | void set_hk_lfr_calib_enable( bool state ); | |
54 | void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ); |
|
62 | void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ); | |
55 |
|
63 | |||
56 | extern int sched_yield( void ); |
|
64 | extern int sched_yield( void ); | |
57 | extern void rtems_cpu_usage_reset(); |
|
65 | extern void rtems_cpu_usage_reset(); | |
58 | extern ring_node *current_ring_node_f3; |
|
66 | extern ring_node *current_ring_node_f3; | |
59 | extern ring_node *ring_node_to_send_cwf_f3; |
|
67 | extern ring_node *ring_node_to_send_cwf_f3; | |
60 | extern ring_node waveform_ring_f3[]; |
|
68 | extern ring_node waveform_ring_f3[]; | |
61 | extern unsigned short sequenceCounterHK; |
|
69 | extern unsigned short sequenceCounterHK; | |
62 |
|
70 | |||
63 | extern unsigned char hk_lfr_q_sd_fifo_size_max; |
|
71 | extern unsigned char hk_lfr_q_sd_fifo_size_max; | |
64 | extern unsigned char hk_lfr_q_rv_fifo_size_max; |
|
72 | extern unsigned char hk_lfr_q_rv_fifo_size_max; | |
65 | extern unsigned char hk_lfr_q_p0_fifo_size_max; |
|
73 | extern unsigned char hk_lfr_q_p0_fifo_size_max; | |
66 | extern unsigned char hk_lfr_q_p1_fifo_size_max; |
|
74 | extern unsigned char hk_lfr_q_p1_fifo_size_max; | |
67 | extern unsigned char hk_lfr_q_p2_fifo_size_max; |
|
75 | extern unsigned char hk_lfr_q_p2_fifo_size_max; | |
68 |
|
76 | |||
69 | #endif // FSW_MISC_H_INCLUDED |
|
77 | #endif // FSW_MISC_H_INCLUDED |
@@ -1,329 +1,327 | |||||
1 | #ifndef FSW_PROCESSING_H_INCLUDED |
|
1 | #ifndef FSW_PROCESSING_H_INCLUDED | |
2 | #define FSW_PROCESSING_H_INCLUDED |
|
2 | #define FSW_PROCESSING_H_INCLUDED | |
3 |
|
3 | |||
4 | #include <rtems.h> |
|
4 | #include <rtems.h> | |
5 | #include <grspw.h> |
|
5 | #include <grspw.h> | |
6 | #include <math.h> |
|
6 | #include <math.h> | |
7 | #include <stdlib.h> // abs() is in the stdlib |
|
7 | #include <stdlib.h> // abs() is in the stdlib | |
8 | #include <stdio.h> |
|
8 | #include <stdio.h> | |
9 | #include <math.h> |
|
9 | #include <math.h> | |
10 | #include <grlib_regs.h> |
|
10 | #include <grlib_regs.h> | |
11 |
|
11 | |||
12 | #include "fsw_params.h" |
|
12 | #include "fsw_params.h" | |
13 |
|
13 | |||
14 | typedef struct ring_node_asm |
|
14 | typedef struct ring_node_asm | |
15 | { |
|
15 | { | |
16 | struct ring_node_asm *next; |
|
16 | struct ring_node_asm *next; | |
17 | float matrix[ TOTAL_SIZE_SM ]; |
|
17 | float matrix[ TOTAL_SIZE_SM ]; | |
18 | unsigned int status; |
|
18 | unsigned int status; | |
19 | } ring_node_asm; |
|
19 | } ring_node_asm; | |
20 |
|
20 | |||
21 | typedef struct |
|
21 | typedef struct | |
22 | { |
|
22 | { | |
23 | unsigned char targetLogicalAddress; |
|
23 | unsigned char targetLogicalAddress; | |
24 | unsigned char protocolIdentifier; |
|
24 | unsigned char protocolIdentifier; | |
25 | unsigned char reserved; |
|
25 | unsigned char reserved; | |
26 | unsigned char userApplication; |
|
26 | unsigned char userApplication; | |
27 | unsigned char packetID[2]; |
|
27 | unsigned char packetID[2]; | |
28 | unsigned char packetSequenceControl[2]; |
|
28 | unsigned char packetSequenceControl[2]; | |
29 | unsigned char packetLength[2]; |
|
29 | unsigned char packetLength[2]; | |
30 | // DATA FIELD HEADER |
|
30 | // DATA FIELD HEADER | |
31 | unsigned char spare1_pusVersion_spare2; |
|
31 | unsigned char spare1_pusVersion_spare2; | |
32 | unsigned char serviceType; |
|
32 | unsigned char serviceType; | |
33 | unsigned char serviceSubType; |
|
33 | unsigned char serviceSubType; | |
34 | unsigned char destinationID; |
|
34 | unsigned char destinationID; | |
35 | unsigned char time[6]; |
|
35 | unsigned char time[6]; | |
36 | // AUXILIARY HEADER |
|
36 | // AUXILIARY HEADER | |
37 | unsigned char sid; |
|
37 | unsigned char sid; | |
38 | unsigned char biaStatusInfo; |
|
38 | unsigned char biaStatusInfo; | |
39 | unsigned char sy_lfr_common_parameters_spare; |
|
39 | unsigned char sy_lfr_common_parameters_spare; | |
40 | unsigned char sy_lfr_common_parameters; |
|
40 | unsigned char sy_lfr_common_parameters; | |
41 | unsigned char acquisitionTime[6]; |
|
41 | unsigned char acquisitionTime[6]; | |
42 | unsigned char pa_lfr_bp_blk_nr[2]; |
|
42 | unsigned char pa_lfr_bp_blk_nr[2]; | |
43 | // SOURCE DATA |
|
43 | // SOURCE DATA | |
44 | unsigned char data[ 780 ]; // MAX size is 26 bins * 30 Bytes [TM_LFR_SCIENCE_BURST_BP2_F1] |
|
44 | unsigned char data[ 780 ]; // MAX size is 26 bins * 30 Bytes [TM_LFR_SCIENCE_BURST_BP2_F1] | |
45 | } bp_packet; |
|
45 | } bp_packet; | |
46 |
|
46 | |||
47 | typedef struct |
|
47 | typedef struct | |
48 | { |
|
48 | { | |
49 | unsigned char targetLogicalAddress; |
|
49 | unsigned char targetLogicalAddress; | |
50 | unsigned char protocolIdentifier; |
|
50 | unsigned char protocolIdentifier; | |
51 | unsigned char reserved; |
|
51 | unsigned char reserved; | |
52 | unsigned char userApplication; |
|
52 | unsigned char userApplication; | |
53 | unsigned char packetID[2]; |
|
53 | unsigned char packetID[2]; | |
54 | unsigned char packetSequenceControl[2]; |
|
54 | unsigned char packetSequenceControl[2]; | |
55 | unsigned char packetLength[2]; |
|
55 | unsigned char packetLength[2]; | |
56 | // DATA FIELD HEADER |
|
56 | // DATA FIELD HEADER | |
57 | unsigned char spare1_pusVersion_spare2; |
|
57 | unsigned char spare1_pusVersion_spare2; | |
58 | unsigned char serviceType; |
|
58 | unsigned char serviceType; | |
59 | unsigned char serviceSubType; |
|
59 | unsigned char serviceSubType; | |
60 | unsigned char destinationID; |
|
60 | unsigned char destinationID; | |
61 | unsigned char time[6]; |
|
61 | unsigned char time[6]; | |
62 | // AUXILIARY HEADER |
|
62 | // AUXILIARY HEADER | |
63 | unsigned char sid; |
|
63 | unsigned char sid; | |
64 | unsigned char biaStatusInfo; |
|
64 | unsigned char biaStatusInfo; | |
65 | unsigned char sy_lfr_common_parameters_spare; |
|
65 | unsigned char sy_lfr_common_parameters_spare; | |
66 | unsigned char sy_lfr_common_parameters; |
|
66 | unsigned char sy_lfr_common_parameters; | |
67 | unsigned char acquisitionTime[6]; |
|
67 | unsigned char acquisitionTime[6]; | |
68 | unsigned char source_data_spare; |
|
68 | unsigned char source_data_spare; | |
69 | unsigned char pa_lfr_bp_blk_nr[2]; |
|
69 | unsigned char pa_lfr_bp_blk_nr[2]; | |
70 | // SOURCE DATA |
|
70 | // SOURCE DATA | |
71 | unsigned char data[ 143 ]; // 13 bins * 11 Bytes |
|
71 | unsigned char data[ 143 ]; // 13 bins * 11 Bytes | |
72 | } bp_packet_with_spare; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1 |
|
72 | } bp_packet_with_spare; // only for TM_LFR_SCIENCE_NORMAL_BP1_F0 and F1 | |
73 |
|
73 | |||
74 | typedef struct asm_msg |
|
74 | typedef struct asm_msg | |
75 | { |
|
75 | { | |
76 | ring_node_asm *norm; |
|
76 | ring_node_asm *norm; | |
77 | ring_node_asm *burst_sbm; |
|
77 | ring_node_asm *burst_sbm; | |
78 | rtems_event_set event; |
|
78 | rtems_event_set event; | |
79 | unsigned int coarseTimeNORM; |
|
79 | unsigned int coarseTimeNORM; | |
80 | unsigned int fineTimeNORM; |
|
80 | unsigned int fineTimeNORM; | |
81 | unsigned int coarseTimeSBM; |
|
81 | unsigned int coarseTimeSBM; | |
82 | unsigned int fineTimeSBM; |
|
82 | unsigned int fineTimeSBM; | |
83 | } asm_msg; |
|
83 | } asm_msg; | |
84 |
|
84 | |||
85 | extern volatile int sm_f0[ ]; |
|
85 | extern volatile int sm_f0[ ]; | |
86 | extern volatile int sm_f1[ ]; |
|
86 | extern volatile int sm_f1[ ]; | |
87 | extern volatile int sm_f2[ ]; |
|
87 | extern volatile int sm_f2[ ]; | |
88 |
|
88 | |||
89 | // parameters |
|
89 | // parameters | |
90 | extern struct param_local_str param_local; |
|
90 | extern struct param_local_str param_local; | |
91 | extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; |
|
91 | extern Packet_TM_LFR_PARAMETER_DUMP_t parameter_dump_packet; | |
92 |
|
92 | |||
93 | // registers |
|
93 | // registers | |
94 | extern time_management_regs_t *time_management_regs; |
|
94 | extern time_management_regs_t *time_management_regs; | |
95 | extern volatile spectral_matrix_regs_t *spectral_matrix_regs; |
|
95 | extern volatile spectral_matrix_regs_t *spectral_matrix_regs; | |
96 |
|
96 | |||
97 | extern rtems_name misc_name[5]; |
|
97 | extern rtems_name misc_name[5]; | |
98 | extern rtems_id Task_id[20]; /* array of task ids */ |
|
98 | extern rtems_id Task_id[20]; /* array of task ids */ | |
99 |
|
99 | |||
100 | // |
|
|||
101 | ring_node * getRingNodeForAveraging( unsigned char frequencyChannel); |
|
100 | ring_node * getRingNodeForAveraging( unsigned char frequencyChannel); | |
102 | // ISR |
|
101 | // ISR | |
103 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ); |
|
102 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ); | |
104 | rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ); |
|
|||
105 |
|
103 | |||
106 | //****************** |
|
104 | //****************** | |
107 | // Spectral Matrices |
|
105 | // Spectral Matrices | |
108 | void reset_nb_sm( void ); |
|
106 | void reset_nb_sm( void ); | |
109 | // SM |
|
107 | // SM | |
110 | void SM_init_rings( void ); |
|
108 | void SM_init_rings( void ); | |
111 | void SM_reset_current_ring_nodes( void ); |
|
109 | void SM_reset_current_ring_nodes( void ); | |
112 | // ASM |
|
110 | // ASM | |
113 | void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes ); |
|
111 | void ASM_generic_init_ring(ring_node_asm *ring, unsigned char nbNodes ); | |
114 |
|
112 | |||
115 | //***************** |
|
113 | //***************** | |
116 | // Basic Parameters |
|
114 | // Basic Parameters | |
117 |
|
115 | |||
118 | void BP_reset_current_ring_nodes( void ); |
|
116 | void BP_reset_current_ring_nodes( void ); | |
119 | void BP_init_header(bp_packet *packet, |
|
117 | void BP_init_header(bp_packet *packet, | |
120 | unsigned int apid, unsigned char sid, |
|
118 | unsigned int apid, unsigned char sid, | |
121 | unsigned int packetLength , unsigned char blkNr); |
|
119 | unsigned int packetLength , unsigned char blkNr); | |
122 | void BP_init_header_with_spare(bp_packet_with_spare *packet, |
|
120 | void BP_init_header_with_spare(bp_packet_with_spare *packet, | |
123 | unsigned int apid, unsigned char sid, |
|
121 | unsigned int apid, unsigned char sid, | |
124 | unsigned int packetLength, unsigned char blkNr ); |
|
122 | unsigned int packetLength, unsigned char blkNr ); | |
125 | void BP_send( char *data, |
|
123 | void BP_send( char *data, | |
126 | rtems_id queue_id , |
|
124 | rtems_id queue_id , | |
127 | unsigned int nbBytesToSend , unsigned int sid ); |
|
125 | unsigned int nbBytesToSend , unsigned int sid ); | |
128 |
|
126 | |||
129 | //****************** |
|
127 | //****************** | |
130 | // general functions |
|
128 | // general functions | |
131 | void reset_sm_status( void ); |
|
129 | void reset_sm_status( void ); | |
132 | void reset_spectral_matrix_regs( void ); |
|
130 | void reset_spectral_matrix_regs( void ); | |
133 | void set_time(unsigned char *time, unsigned char *timeInBuffer ); |
|
131 | void set_time(unsigned char *time, unsigned char *timeInBuffer ); | |
134 | unsigned long long int get_acquisition_time( unsigned char *timePtr ); |
|
132 | unsigned long long int get_acquisition_time( unsigned char *timePtr ); | |
135 | unsigned char getSID( rtems_event_set event ); |
|
133 | unsigned char getSID( rtems_event_set event ); | |
136 |
|
134 | |||
137 | extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ); |
|
135 | extern rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ); | |
138 | extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ); |
|
136 | extern rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ); | |
139 |
|
137 | |||
140 | //*************************************** |
|
138 | //*************************************** | |
141 | // DEFINITIONS OF STATIC INLINE FUNCTIONS |
|
139 | // DEFINITIONS OF STATIC INLINE FUNCTIONS | |
142 | static inline void SM_average(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, |
|
140 | static inline void SM_average(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, | |
143 | ring_node *ring_node_tab[], |
|
141 | ring_node *ring_node_tab[], | |
144 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, |
|
142 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, | |
145 | asm_msg *msgForMATR ); |
|
143 | asm_msg *msgForMATR ); | |
146 |
|
144 | |||
147 | static inline void SM_average_debug(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, |
|
145 | static inline void SM_average_debug(float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, | |
148 | ring_node *ring_node_tab[], |
|
146 | ring_node *ring_node_tab[], | |
149 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, |
|
147 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, | |
150 | asm_msg *msgForMATR ); |
|
148 | asm_msg *msgForMATR ); | |
151 |
|
149 | |||
152 | void ASM_patch( float *inputASM, float *outputASM ); |
|
150 | void ASM_patch( float *inputASM, float *outputASM ); | |
153 |
|
151 | |||
154 | void extractReImVectors(float *inputASM, float *outputASM, unsigned int asmComponent ); |
|
152 | void extractReImVectors(float *inputASM, float *outputASM, unsigned int asmComponent ); | |
155 |
|
153 | |||
156 | static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized, |
|
154 | static inline void ASM_reorganize_and_divide(float *averaged_spec_mat, float *averaged_spec_mat_reorganized, | |
157 | float divider ); |
|
155 | float divider ); | |
158 |
|
156 | |||
159 | static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat, |
|
157 | static inline void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat, | |
160 | float divider, |
|
158 | float divider, | |
161 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart); |
|
159 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart); | |
162 |
|
160 | |||
163 | static inline void ASM_convert(volatile float *input_matrix, char *output_matrix); |
|
161 | static inline void ASM_convert(volatile float *input_matrix, char *output_matrix); | |
164 |
|
162 | |||
165 | void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, |
|
163 | void SM_average( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, | |
166 | ring_node *ring_node_tab[], |
|
164 | ring_node *ring_node_tab[], | |
167 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, |
|
165 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, | |
168 | asm_msg *msgForMATR ) |
|
166 | asm_msg *msgForMATR ) | |
169 | { |
|
167 | { | |
170 | float sum; |
|
168 | float sum; | |
171 | unsigned int i; |
|
169 | unsigned int i; | |
172 |
|
170 | |||
173 | for(i=0; i<TOTAL_SIZE_SM; i++) |
|
171 | for(i=0; i<TOTAL_SIZE_SM; i++) | |
174 | { |
|
172 | { | |
175 | sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ] |
|
173 | sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ] | |
176 | + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ] |
|
174 | + ( (int *) (ring_node_tab[1]->buffer_address) ) [ i ] | |
177 | + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ] |
|
175 | + ( (int *) (ring_node_tab[2]->buffer_address) ) [ i ] | |
178 | + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ] |
|
176 | + ( (int *) (ring_node_tab[3]->buffer_address) ) [ i ] | |
179 | + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ] |
|
177 | + ( (int *) (ring_node_tab[4]->buffer_address) ) [ i ] | |
180 | + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ] |
|
178 | + ( (int *) (ring_node_tab[5]->buffer_address) ) [ i ] | |
181 | + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ] |
|
179 | + ( (int *) (ring_node_tab[6]->buffer_address) ) [ i ] | |
182 | + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ]; |
|
180 | + ( (int *) (ring_node_tab[7]->buffer_address) ) [ i ]; | |
183 |
|
181 | |||
184 | if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) ) |
|
182 | if ( (nbAverageNORM == 0) && (nbAverageSBM == 0) ) | |
185 | { |
|
183 | { | |
186 | averaged_spec_mat_NORM[ i ] = sum; |
|
184 | averaged_spec_mat_NORM[ i ] = sum; | |
187 | averaged_spec_mat_SBM[ i ] = sum; |
|
185 | averaged_spec_mat_SBM[ i ] = sum; | |
188 | msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime; |
|
186 | msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime; | |
189 | msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime; |
|
187 | msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime; | |
190 | msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime; |
|
188 | msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime; | |
191 | msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime; |
|
189 | msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime; | |
192 | } |
|
190 | } | |
193 | else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) ) |
|
191 | else if ( (nbAverageNORM != 0) && (nbAverageSBM != 0) ) | |
194 | { |
|
192 | { | |
195 | averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum ); |
|
193 | averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum ); | |
196 | averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum ); |
|
194 | averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum ); | |
197 | } |
|
195 | } | |
198 | else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) ) |
|
196 | else if ( (nbAverageNORM != 0) && (nbAverageSBM == 0) ) | |
199 | { |
|
197 | { | |
200 | averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum ); |
|
198 | averaged_spec_mat_NORM[ i ] = ( averaged_spec_mat_NORM[ i ] + sum ); | |
201 | averaged_spec_mat_SBM[ i ] = sum; |
|
199 | averaged_spec_mat_SBM[ i ] = sum; | |
202 | msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime; |
|
200 | msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime; | |
203 | msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime; |
|
201 | msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime; | |
204 | } |
|
202 | } | |
205 | else |
|
203 | else | |
206 | { |
|
204 | { | |
207 | averaged_spec_mat_NORM[ i ] = sum; |
|
205 | averaged_spec_mat_NORM[ i ] = sum; | |
208 | averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum ); |
|
206 | averaged_spec_mat_SBM[ i ] = ( averaged_spec_mat_SBM[ i ] + sum ); | |
209 | msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime; |
|
207 | msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime; | |
210 | msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime; |
|
208 | msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime; | |
211 | // PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM) |
|
209 | // PRINTF2("ERR *** in SM_average *** unexpected parameters %d %d\n", nbAverageNORM, nbAverageSBM) | |
212 | } |
|
210 | } | |
213 | } |
|
211 | } | |
214 | } |
|
212 | } | |
215 |
|
213 | |||
216 | void SM_average_debug( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, |
|
214 | void SM_average_debug( float *averaged_spec_mat_NORM, float *averaged_spec_mat_SBM, | |
217 | ring_node *ring_node_tab[], |
|
215 | ring_node *ring_node_tab[], | |
218 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, |
|
216 | unsigned int nbAverageNORM, unsigned int nbAverageSBM, | |
219 | asm_msg *msgForMATR ) |
|
217 | asm_msg *msgForMATR ) | |
220 | { |
|
218 | { | |
221 | float sum; |
|
219 | float sum; | |
222 | unsigned int i; |
|
220 | unsigned int i; | |
223 |
|
221 | |||
224 | for(i=0; i<TOTAL_SIZE_SM; i++) |
|
222 | for(i=0; i<TOTAL_SIZE_SM; i++) | |
225 | { |
|
223 | { | |
226 | sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]; |
|
224 | sum = ( (int *) (ring_node_tab[0]->buffer_address) ) [ i ]; | |
227 | averaged_spec_mat_NORM[ i ] = sum; |
|
225 | averaged_spec_mat_NORM[ i ] = sum; | |
228 | averaged_spec_mat_SBM[ i ] = sum; |
|
226 | averaged_spec_mat_SBM[ i ] = sum; | |
229 | msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime; |
|
227 | msgForMATR->coarseTimeNORM = ring_node_tab[0]->coarseTime; | |
230 | msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime; |
|
228 | msgForMATR->fineTimeNORM = ring_node_tab[0]->fineTime; | |
231 | msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime; |
|
229 | msgForMATR->coarseTimeSBM = ring_node_tab[0]->coarseTime; | |
232 | msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime; |
|
230 | msgForMATR->fineTimeSBM = ring_node_tab[0]->fineTime; | |
233 | } |
|
231 | } | |
234 | } |
|
232 | } | |
235 |
|
233 | |||
236 | void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider ) |
|
234 | void ASM_reorganize_and_divide( float *averaged_spec_mat, float *averaged_spec_mat_reorganized, float divider ) | |
237 | { |
|
235 | { | |
238 | int frequencyBin; |
|
236 | int frequencyBin; | |
239 | int asmComponent; |
|
237 | int asmComponent; | |
240 | unsigned int offsetASM; |
|
238 | unsigned int offsetASM; | |
241 | unsigned int offsetASMReorganized; |
|
239 | unsigned int offsetASMReorganized; | |
242 |
|
240 | |||
243 | // BUILD DATA |
|
241 | // BUILD DATA | |
244 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) |
|
242 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) | |
245 | { |
|
243 | { | |
246 | for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ ) |
|
244 | for( frequencyBin = 0; frequencyBin < NB_BINS_PER_SM; frequencyBin++ ) | |
247 | { |
|
245 | { | |
248 | offsetASMReorganized = |
|
246 | offsetASMReorganized = | |
249 | frequencyBin * NB_VALUES_PER_SM |
|
247 | frequencyBin * NB_VALUES_PER_SM | |
250 | + asmComponent; |
|
248 | + asmComponent; | |
251 | offsetASM = |
|
249 | offsetASM = | |
252 | asmComponent * NB_BINS_PER_SM |
|
250 | asmComponent * NB_BINS_PER_SM | |
253 | + frequencyBin; |
|
251 | + frequencyBin; | |
254 | averaged_spec_mat_reorganized[offsetASMReorganized ] = |
|
252 | averaged_spec_mat_reorganized[offsetASMReorganized ] = | |
255 | averaged_spec_mat[ offsetASM ] / divider; |
|
253 | averaged_spec_mat[ offsetASM ] / divider; | |
256 | } |
|
254 | } | |
257 | } |
|
255 | } | |
258 | } |
|
256 | } | |
259 |
|
257 | |||
260 | void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider, |
|
258 | void ASM_compress_reorganize_and_divide(float *averaged_spec_mat, float *compressed_spec_mat , float divider, | |
261 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart ) |
|
259 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, unsigned char ASMIndexStart ) | |
262 | { |
|
260 | { | |
263 | int frequencyBin; |
|
261 | int frequencyBin; | |
264 | int asmComponent; |
|
262 | int asmComponent; | |
265 | int offsetASM; |
|
263 | int offsetASM; | |
266 | int offsetCompressed; |
|
264 | int offsetCompressed; | |
267 | int k; |
|
265 | int k; | |
268 |
|
266 | |||
269 | // BUILD DATA |
|
267 | // BUILD DATA | |
270 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) |
|
268 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) | |
271 | { |
|
269 | { | |
272 | for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ ) |
|
270 | for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ ) | |
273 | { |
|
271 | { | |
274 | offsetCompressed = // NO TIME OFFSET |
|
272 | offsetCompressed = // NO TIME OFFSET | |
275 | frequencyBin * NB_VALUES_PER_SM |
|
273 | frequencyBin * NB_VALUES_PER_SM | |
276 | + asmComponent; |
|
274 | + asmComponent; | |
277 | offsetASM = // NO TIME OFFSET |
|
275 | offsetASM = // NO TIME OFFSET | |
278 | asmComponent * NB_BINS_PER_SM |
|
276 | asmComponent * NB_BINS_PER_SM | |
279 | + ASMIndexStart |
|
277 | + ASMIndexStart | |
280 | + frequencyBin * nbBinsToAverage; |
|
278 | + frequencyBin * nbBinsToAverage; | |
281 | compressed_spec_mat[ offsetCompressed ] = 0; |
|
279 | compressed_spec_mat[ offsetCompressed ] = 0; | |
282 | for ( k = 0; k < nbBinsToAverage; k++ ) |
|
280 | for ( k = 0; k < nbBinsToAverage; k++ ) | |
283 | { |
|
281 | { | |
284 | compressed_spec_mat[offsetCompressed ] = |
|
282 | compressed_spec_mat[offsetCompressed ] = | |
285 | ( compressed_spec_mat[ offsetCompressed ] |
|
283 | ( compressed_spec_mat[ offsetCompressed ] | |
286 | + averaged_spec_mat[ offsetASM + k ] ); |
|
284 | + averaged_spec_mat[ offsetASM + k ] ); | |
287 | } |
|
285 | } | |
288 | compressed_spec_mat[ offsetCompressed ] = |
|
286 | compressed_spec_mat[ offsetCompressed ] = | |
289 | compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage); |
|
287 | compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage); | |
290 | } |
|
288 | } | |
291 | } |
|
289 | } | |
292 | } |
|
290 | } | |
293 |
|
291 | |||
294 | void ASM_convert( volatile float *input_matrix, char *output_matrix) |
|
292 | void ASM_convert( volatile float *input_matrix, char *output_matrix) | |
295 | { |
|
293 | { | |
296 | unsigned int frequencyBin; |
|
294 | unsigned int frequencyBin; | |
297 | unsigned int asmComponent; |
|
295 | unsigned int asmComponent; | |
298 | char * pt_char_input; |
|
296 | char * pt_char_input; | |
299 | char * pt_char_output; |
|
297 | char * pt_char_output; | |
300 | unsigned int offsetInput; |
|
298 | unsigned int offsetInput; | |
301 | unsigned int offsetOutput; |
|
299 | unsigned int offsetOutput; | |
302 |
|
300 | |||
303 | pt_char_input = (char*) &input_matrix; |
|
301 | pt_char_input = (char*) &input_matrix; | |
304 | pt_char_output = (char*) &output_matrix; |
|
302 | pt_char_output = (char*) &output_matrix; | |
305 |
|
303 | |||
306 | // convert all other data |
|
304 | // convert all other data | |
307 | for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++) |
|
305 | for( frequencyBin=0; frequencyBin<NB_BINS_PER_SM; frequencyBin++) | |
308 | { |
|
306 | { | |
309 | for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++) |
|
307 | for ( asmComponent=0; asmComponent<NB_VALUES_PER_SM; asmComponent++) | |
310 | { |
|
308 | { | |
311 | offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ; |
|
309 | offsetInput = (frequencyBin*NB_VALUES_PER_SM) + asmComponent ; | |
312 | offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ; |
|
310 | offsetOutput = 2 * ( (frequencyBin*NB_VALUES_PER_SM) + asmComponent ) ; | |
313 | pt_char_input = (char*) &input_matrix [ offsetInput ]; |
|
311 | pt_char_input = (char*) &input_matrix [ offsetInput ]; | |
314 | pt_char_output = (char*) &output_matrix[ offsetOutput ]; |
|
312 | pt_char_output = (char*) &output_matrix[ offsetOutput ]; | |
315 | pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float |
|
313 | pt_char_output[0] = pt_char_input[0]; // bits 31 downto 24 of the float | |
316 | pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float |
|
314 | pt_char_output[1] = pt_char_input[1]; // bits 23 downto 16 of the float | |
317 | } |
|
315 | } | |
318 | } |
|
316 | } | |
319 | } |
|
317 | } | |
320 |
|
318 | |||
321 | void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat, |
|
319 | void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat, | |
322 | float divider, |
|
320 | float divider, | |
323 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart, unsigned char channel); |
|
321 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage , unsigned char ASMIndexStart, unsigned char channel); | |
324 |
|
322 | |||
325 | int getFBinMask(int k, unsigned char channel); |
|
323 | int getFBinMask(int k, unsigned char channel); | |
326 |
|
324 | |||
327 | void init_kcoeff_sbm_from_kcoeff_norm( float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm); |
|
325 | void init_kcoeff_sbm_from_kcoeff_norm( float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm); | |
328 |
|
326 | |||
329 | #endif // FSW_PROCESSING_H_INCLUDED |
|
327 | #endif // FSW_PROCESSING_H_INCLUDED |
@@ -1,872 +1,864 | |||||
1 | /** This is the RTEMS initialization module. |
|
1 | /** This is the RTEMS initialization module. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * This module contains two very different information: |
|
6 | * This module contains two very different information: | |
7 | * - specific instructions to configure the compilation of the RTEMS executive |
|
7 | * - specific instructions to configure the compilation of the RTEMS executive | |
8 | * - functions related to the fligth softwre initialization, especially the INIT RTEMS task |
|
8 | * - functions related to the fligth softwre initialization, especially the INIT RTEMS task | |
9 | * |
|
9 | * | |
10 | */ |
|
10 | */ | |
11 |
|
11 | |||
12 | //************************* |
|
12 | //************************* | |
13 | // GPL reminder to be added |
|
13 | // GPL reminder to be added | |
14 | //************************* |
|
14 | //************************* | |
15 |
|
15 | |||
16 | #include <rtems.h> |
|
16 | #include <rtems.h> | |
17 |
|
17 | |||
18 | /* configuration information */ |
|
18 | /* configuration information */ | |
19 |
|
19 | |||
20 | #define CONFIGURE_INIT |
|
20 | #define CONFIGURE_INIT | |
21 |
|
21 | |||
22 | #include <bsp.h> /* for device driver prototypes */ |
|
22 | #include <bsp.h> /* for device driver prototypes */ | |
23 |
|
23 | |||
24 | /* configuration information */ |
|
24 | /* configuration information */ | |
25 |
|
25 | |||
26 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
26 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER | |
27 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
27 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER | |
28 |
|
28 | |||
29 | #define CONFIGURE_MAXIMUM_TASKS 20 |
|
29 | #define CONFIGURE_MAXIMUM_TASKS 20 | |
30 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
|
30 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE | |
31 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) |
|
31 | #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE) | |
32 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 |
|
32 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32 | |
33 | #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 |
|
33 | #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100 | |
34 | #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) |
|
34 | #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT) | |
35 | #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT) |
|
35 | #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT) | |
36 | #define CONFIGURE_MAXIMUM_DRIVERS 16 |
|
36 | #define CONFIGURE_MAXIMUM_DRIVERS 16 | |
37 | #define CONFIGURE_MAXIMUM_PERIODS 5 |
|
37 | #define CONFIGURE_MAXIMUM_PERIODS 5 | |
38 | #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s) |
|
38 | #define CONFIGURE_MAXIMUM_TIMERS 5 // STAT (1s), send SWF (0.3s), send CWF3 (1s) | |
39 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5 |
|
39 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5 | |
40 | #ifdef PRINT_STACK_REPORT |
|
40 | #ifdef PRINT_STACK_REPORT | |
41 | #define CONFIGURE_STACK_CHECKER_ENABLED |
|
41 | #define CONFIGURE_STACK_CHECKER_ENABLED | |
42 | #endif |
|
42 | #endif | |
43 |
|
43 | |||
44 | #include <rtems/confdefs.h> |
|
44 | #include <rtems/confdefs.h> | |
45 |
|
45 | |||
46 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ |
|
46 | /* If --drvmgr was enabled during the configuration of the RTEMS kernel */ | |
47 | #ifdef RTEMS_DRVMGR_STARTUP |
|
47 | #ifdef RTEMS_DRVMGR_STARTUP | |
48 | #ifdef LEON3 |
|
48 | #ifdef LEON3 | |
49 | /* Add Timer and UART Driver */ |
|
49 | /* Add Timer and UART Driver */ | |
50 | #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
|
50 | #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER | |
51 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER |
|
51 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER | |
52 | #endif |
|
52 | #endif | |
53 | #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
|
53 | #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER | |
54 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART |
|
54 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART | |
55 | #endif |
|
55 | #endif | |
56 | #endif |
|
56 | #endif | |
57 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ |
|
57 | #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */ | |
58 | #include <drvmgr/drvmgr_confdefs.h> |
|
58 | #include <drvmgr/drvmgr_confdefs.h> | |
59 | #endif |
|
59 | #endif | |
60 |
|
60 | |||
61 | #include "fsw_init.h" |
|
61 | #include "fsw_init.h" | |
62 | #include "fsw_config.c" |
|
62 | #include "fsw_config.c" | |
63 | #include "GscMemoryLPP.hpp" |
|
63 | #include "GscMemoryLPP.hpp" | |
64 |
|
64 | |||
65 | void initCache() |
|
65 | void initCache() | |
66 | { |
|
66 | { | |
67 | unsigned int cacheControlRegister; |
|
67 | unsigned int cacheControlRegister; | |
68 |
|
68 | |||
69 | cacheControlRegister = getCacheControlRegister(); |
|
69 | cacheControlRegister = getCacheControlRegister(); | |
70 | PRINTF1("(0) cacheControlRegister = %x\n", cacheControlRegister) |
|
70 | PRINTF1("(0) cacheControlRegister = %x\n", cacheControlRegister) | |
71 |
|
71 | |||
72 | resetCacheControlRegister(); |
|
72 | resetCacheControlRegister(); | |
73 |
|
73 | |||
74 | enableInstructionCache(); |
|
74 | enableInstructionCache(); | |
75 | enableDataCache(); |
|
75 | enableDataCache(); | |
76 | enableInstructionBurstFetch(); |
|
76 | enableInstructionBurstFetch(); | |
77 |
|
77 | |||
78 | cacheControlRegister = getCacheControlRegister(); |
|
78 | cacheControlRegister = getCacheControlRegister(); | |
79 | PRINTF1("(1) cacheControlRegister = %x\n", cacheControlRegister) |
|
79 | PRINTF1("(1) cacheControlRegister = %x\n", cacheControlRegister) | |
80 | } |
|
80 | } | |
81 |
|
81 | |||
82 | rtems_task Init( rtems_task_argument ignored ) |
|
82 | rtems_task Init( rtems_task_argument ignored ) | |
83 | { |
|
83 | { | |
84 | /** This is the RTEMS INIT taks, it is the first task launched by the system. |
|
84 | /** This is the RTEMS INIT taks, it is the first task launched by the system. | |
85 | * |
|
85 | * | |
86 | * @param unused is the starting argument of the RTEMS task |
|
86 | * @param unused is the starting argument of the RTEMS task | |
87 | * |
|
87 | * | |
88 | * The INIT task create and run all other RTEMS tasks. |
|
88 | * The INIT task create and run all other RTEMS tasks. | |
89 | * |
|
89 | * | |
90 | */ |
|
90 | */ | |
91 |
|
91 | |||
92 | //*********** |
|
92 | //*********** | |
93 | // INIT CACHE |
|
93 | // INIT CACHE | |
94 |
|
94 | |||
95 | unsigned char *vhdlVersion; |
|
95 | unsigned char *vhdlVersion; | |
96 |
|
96 | |||
97 | reset_lfr(); |
|
97 | reset_lfr(); | |
98 |
|
98 | |||
99 | reset_local_time(); |
|
99 | reset_local_time(); | |
100 |
|
100 | |||
101 | rtems_cpu_usage_reset(); |
|
101 | rtems_cpu_usage_reset(); | |
102 |
|
102 | |||
103 | rtems_status_code status; |
|
103 | rtems_status_code status; | |
104 | rtems_status_code status_spw; |
|
104 | rtems_status_code status_spw; | |
105 | rtems_isr_entry old_isr_handler; |
|
105 | rtems_isr_entry old_isr_handler; | |
106 |
|
106 | |||
107 | // UART settings |
|
107 | // UART settings | |
108 | send_console_outputs_on_apbuart_port(); |
|
108 | send_console_outputs_on_apbuart_port(); | |
109 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); |
|
109 | set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE); | |
110 | enable_apbuart_transmitter(); |
|
110 | enable_apbuart_transmitter(); | |
111 |
|
111 | |||
112 | DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") |
|
112 | DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n") | |
113 |
|
113 | |||
114 |
|
114 | |||
115 | PRINTF("\n\n\n\n\n") |
|
115 | PRINTF("\n\n\n\n\n") | |
116 |
|
116 | |||
117 | initCache(); |
|
117 | initCache(); | |
118 |
|
118 | |||
119 | PRINTF("*************************\n") |
|
119 | PRINTF("*************************\n") | |
120 | PRINTF("** LFR Flight Software **\n") |
|
120 | PRINTF("** LFR Flight Software **\n") | |
121 | PRINTF1("** %d.", SW_VERSION_N1) |
|
121 | PRINTF1("** %d.", SW_VERSION_N1) | |
122 | PRINTF1("%d." , SW_VERSION_N2) |
|
122 | PRINTF1("%d." , SW_VERSION_N2) | |
123 | PRINTF1("%d." , SW_VERSION_N3) |
|
123 | PRINTF1("%d." , SW_VERSION_N3) | |
124 | PRINTF1("%d **\n", SW_VERSION_N4) |
|
124 | PRINTF1("%d **\n", SW_VERSION_N4) | |
125 |
|
125 | |||
126 | vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION); |
|
126 | vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION); | |
127 | PRINTF("** VHDL **\n") |
|
127 | PRINTF("** VHDL **\n") | |
128 | PRINTF1("** %d.", vhdlVersion[1]) |
|
128 | PRINTF1("** %d.", vhdlVersion[1]) | |
129 | PRINTF1("%d." , vhdlVersion[2]) |
|
129 | PRINTF1("%d." , vhdlVersion[2]) | |
130 | PRINTF1("%d **\n", vhdlVersion[3]) |
|
130 | PRINTF1("%d **\n", vhdlVersion[3]) | |
131 | PRINTF("*************************\n") |
|
131 | PRINTF("*************************\n") | |
132 | PRINTF("\n\n") |
|
132 | PRINTF("\n\n") | |
133 |
|
133 | |||
134 | init_parameter_dump(); |
|
134 | init_parameter_dump(); | |
135 | init_kcoefficients_dump(); |
|
135 | init_kcoefficients_dump(); | |
136 | init_local_mode_parameters(); |
|
136 | init_local_mode_parameters(); | |
137 | init_housekeeping_parameters(); |
|
137 | init_housekeeping_parameters(); | |
138 | init_k_coefficients_prc0(); |
|
138 | init_k_coefficients_prc0(); | |
139 | init_k_coefficients_prc1(); |
|
139 | init_k_coefficients_prc1(); | |
140 | init_k_coefficients_prc2(); |
|
140 | init_k_coefficients_prc2(); | |
141 | pa_bia_status_info = 0x00; |
|
141 | pa_bia_status_info = 0x00; | |
142 |
|
142 | |||
143 | // waveform picker initialization |
|
143 | // waveform picker initialization | |
144 | WFP_init_rings(); // initialize the waveform rings |
|
144 | WFP_init_rings(); LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings | |
145 | WFP_reset_current_ring_nodes(); |
|
145 | WFP_reset_current_ring_nodes(); | |
146 | reset_waveform_picker_regs(); |
|
146 | reset_waveform_picker_regs(); | |
147 |
|
147 | |||
148 | // spectral matrices initialization |
|
148 | // spectral matrices initialization | |
149 | SM_init_rings(); // initialize spectral matrices rings |
|
149 | SM_init_rings(); // initialize spectral matrices rings | |
150 | SM_reset_current_ring_nodes(); |
|
150 | SM_reset_current_ring_nodes(); | |
151 | reset_spectral_matrix_regs(); |
|
151 | reset_spectral_matrix_regs(); | |
152 |
|
152 | |||
153 | // configure calibration |
|
153 | // configure calibration | |
154 | configureCalibration( false ); // true means interleaved mode, false is for normal mode |
|
154 | configureCalibration( false ); // true means interleaved mode, false is for normal mode | |
155 |
|
155 | |||
156 | updateLFRCurrentMode(); |
|
156 | updateLFRCurrentMode(); | |
157 |
|
157 | |||
158 | BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode) |
|
158 | BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode) | |
159 |
|
159 | |||
160 | create_names(); // create all names |
|
160 | create_names(); // create all names | |
161 |
|
161 | |||
162 | status = create_message_queues(); // create message queues |
|
162 | status = create_message_queues(); // create message queues | |
163 | if (status != RTEMS_SUCCESSFUL) |
|
163 | if (status != RTEMS_SUCCESSFUL) | |
164 | { |
|
164 | { | |
165 | PRINTF1("in INIT *** ERR in create_message_queues, code %d", status) |
|
165 | PRINTF1("in INIT *** ERR in create_message_queues, code %d", status) | |
166 | } |
|
166 | } | |
167 |
|
167 | |||
168 | status = create_all_tasks(); // create all tasks |
|
168 | status = create_all_tasks(); // create all tasks | |
169 | if (status != RTEMS_SUCCESSFUL) |
|
169 | if (status != RTEMS_SUCCESSFUL) | |
170 | { |
|
170 | { | |
171 | PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status) |
|
171 | PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status) | |
172 | } |
|
172 | } | |
173 |
|
173 | |||
174 | // ************************** |
|
174 | // ************************** | |
175 | // <SPACEWIRE INITIALIZATION> |
|
175 | // <SPACEWIRE INITIALIZATION> | |
176 | grspw_timecode_callback = &timecode_irq_handler; |
|
176 | grspw_timecode_callback = &timecode_irq_handler; | |
177 |
|
177 | |||
178 | status_spw = spacewire_open_link(); // (1) open the link |
|
178 | status_spw = spacewire_open_link(); // (1) open the link | |
179 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
179 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
180 | { |
|
180 | { | |
181 | PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw ) |
|
181 | PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw ) | |
182 | } |
|
182 | } | |
183 |
|
183 | |||
184 | if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link |
|
184 | if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link | |
185 | { |
|
185 | { | |
186 | status_spw = spacewire_configure_link( fdSPW ); |
|
186 | status_spw = spacewire_configure_link( fdSPW ); | |
187 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
187 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
188 | { |
|
188 | { | |
189 | PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw ) |
|
189 | PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw ) | |
190 | } |
|
190 | } | |
191 | } |
|
191 | } | |
192 |
|
192 | |||
193 | if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link |
|
193 | if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link | |
194 | { |
|
194 | { | |
195 | status_spw = spacewire_start_link( fdSPW ); |
|
195 | status_spw = spacewire_start_link( fdSPW ); | |
196 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
196 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
197 | { |
|
197 | { | |
198 | PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw ) |
|
198 | PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw ) | |
199 | } |
|
199 | } | |
200 | } |
|
200 | } | |
201 | // </SPACEWIRE INITIALIZATION> |
|
201 | // </SPACEWIRE INITIALIZATION> | |
202 | // *************************** |
|
202 | // *************************** | |
203 |
|
203 | |||
204 | status = start_all_tasks(); // start all tasks |
|
204 | status = start_all_tasks(); // start all tasks | |
205 | if (status != RTEMS_SUCCESSFUL) |
|
205 | if (status != RTEMS_SUCCESSFUL) | |
206 | { |
|
206 | { | |
207 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) |
|
207 | PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status) | |
208 | } |
|
208 | } | |
209 |
|
209 | |||
210 | // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization |
|
210 | // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization | |
211 | status = start_recv_send_tasks(); |
|
211 | status = start_recv_send_tasks(); | |
212 | if ( status != RTEMS_SUCCESSFUL ) |
|
212 | if ( status != RTEMS_SUCCESSFUL ) | |
213 | { |
|
213 | { | |
214 | PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status ) |
|
214 | PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status ) | |
215 | } |
|
215 | } | |
216 |
|
216 | |||
217 | // suspend science tasks, they will be restarted later depending on the mode |
|
217 | // suspend science tasks, they will be restarted later depending on the mode | |
218 | status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY) |
|
218 | status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY) | |
219 | if (status != RTEMS_SUCCESSFUL) |
|
219 | if (status != RTEMS_SUCCESSFUL) | |
220 | { |
|
220 | { | |
221 | PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
221 | PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status) | |
222 | } |
|
222 | } | |
223 |
|
223 | |||
224 | //****************************** |
|
|||
225 | // <SPECTRAL MATRICES SIMULATOR> |
|
|||
226 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); |
|
|||
227 | configure_timer((gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR, CLKDIV_SM_SIMULATOR, |
|
|||
228 | IRQ_SPARC_SM_SIMULATOR, spectral_matrices_isr_simu ); |
|
|||
229 | // </SPECTRAL MATRICES SIMULATOR> |
|
|||
230 | //******************************* |
|
|||
231 |
|
||||
232 | // configure IRQ handling for the waveform picker unit |
|
224 | // configure IRQ handling for the waveform picker unit | |
233 | status = rtems_interrupt_catch( waveforms_isr, |
|
225 | status = rtems_interrupt_catch( waveforms_isr, | |
234 | IRQ_SPARC_WAVEFORM_PICKER, |
|
226 | IRQ_SPARC_WAVEFORM_PICKER, | |
235 | &old_isr_handler) ; |
|
227 | &old_isr_handler) ; | |
236 | // configure IRQ handling for the spectral matrices unit |
|
228 | // configure IRQ handling for the spectral matrices unit | |
237 | status = rtems_interrupt_catch( spectral_matrices_isr, |
|
229 | status = rtems_interrupt_catch( spectral_matrices_isr, | |
238 | IRQ_SPARC_SPECTRAL_MATRIX, |
|
230 | IRQ_SPARC_SPECTRAL_MATRIX, | |
239 | &old_isr_handler) ; |
|
231 | &old_isr_handler) ; | |
240 |
|
232 | |||
241 | // if the spacewire link is not up then send an event to the SPIQ task for link recovery |
|
233 | // if the spacewire link is not up then send an event to the SPIQ task for link recovery | |
242 | if ( status_spw != RTEMS_SUCCESSFUL ) |
|
234 | if ( status_spw != RTEMS_SUCCESSFUL ) | |
243 | { |
|
235 | { | |
244 | status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ); |
|
236 | status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT ); | |
245 | if ( status != RTEMS_SUCCESSFUL ) { |
|
237 | if ( status != RTEMS_SUCCESSFUL ) { | |
246 | PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status ) |
|
238 | PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status ) | |
247 | } |
|
239 | } | |
248 | } |
|
240 | } | |
249 |
|
241 | |||
250 | BOOT_PRINTF("delete INIT\n") |
|
242 | BOOT_PRINTF("delete INIT\n") | |
251 |
|
243 | |||
252 | set_hk_lfr_sc_potential_flag( true ); |
|
244 | set_hk_lfr_sc_potential_flag( true ); | |
253 |
|
245 | |||
254 | status = rtems_task_delete(RTEMS_SELF); |
|
246 | status = rtems_task_delete(RTEMS_SELF); | |
255 |
|
247 | |||
256 | } |
|
248 | } | |
257 |
|
249 | |||
258 | void init_local_mode_parameters( void ) |
|
250 | void init_local_mode_parameters( void ) | |
259 | { |
|
251 | { | |
260 | /** This function initialize the param_local global variable with default values. |
|
252 | /** This function initialize the param_local global variable with default values. | |
261 | * |
|
253 | * | |
262 | */ |
|
254 | */ | |
263 |
|
255 | |||
264 | unsigned int i; |
|
256 | unsigned int i; | |
265 |
|
257 | |||
266 | // LOCAL PARAMETERS |
|
258 | // LOCAL PARAMETERS | |
267 |
|
259 | |||
268 | BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) |
|
260 | BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max) | |
269 | BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) |
|
261 | BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max) | |
270 | BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX) |
|
262 | BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX) | |
271 |
|
263 | |||
272 | // init sequence counters |
|
264 | // init sequence counters | |
273 |
|
265 | |||
274 | for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++) |
|
266 | for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++) | |
275 | { |
|
267 | { | |
276 | sequenceCounters_TC_EXE[i] = 0x00; |
|
268 | sequenceCounters_TC_EXE[i] = 0x00; | |
277 | sequenceCounters_TM_DUMP[i] = 0x00; |
|
269 | sequenceCounters_TM_DUMP[i] = 0x00; | |
278 | } |
|
270 | } | |
279 | sequenceCounters_SCIENCE_NORMAL_BURST = 0x00; |
|
271 | sequenceCounters_SCIENCE_NORMAL_BURST = 0x00; | |
280 | sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00; |
|
272 | sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00; | |
281 | sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8; |
|
273 | sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8; | |
282 | } |
|
274 | } | |
283 |
|
275 | |||
284 | void reset_local_time( void ) |
|
276 | void reset_local_time( void ) | |
285 | { |
|
277 | { | |
286 | time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000 |
|
278 | time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000 | |
287 | } |
|
279 | } | |
288 |
|
280 | |||
289 | void create_names( void ) // create all names for tasks and queues |
|
281 | void create_names( void ) // create all names for tasks and queues | |
290 | { |
|
282 | { | |
291 | /** This function creates all RTEMS names used in the software for tasks and queues. |
|
283 | /** This function creates all RTEMS names used in the software for tasks and queues. | |
292 | * |
|
284 | * | |
293 | * @return RTEMS directive status codes: |
|
285 | * @return RTEMS directive status codes: | |
294 | * - RTEMS_SUCCESSFUL - successful completion |
|
286 | * - RTEMS_SUCCESSFUL - successful completion | |
295 | * |
|
287 | * | |
296 | */ |
|
288 | */ | |
297 |
|
289 | |||
298 | // task names |
|
290 | // task names | |
299 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); |
|
291 | Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' ); | |
300 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); |
|
292 | Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' ); | |
301 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); |
|
293 | Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' ); | |
302 |
Task_name[TASKID_ |
|
294 | Task_name[TASKID_LOAD] = rtems_build_name( 'L', 'O', 'A', 'D' ); | |
303 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); |
|
295 | Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' ); | |
304 | Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' ); |
|
296 | Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' ); | |
305 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); |
|
297 | Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' ); | |
306 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); |
|
298 | Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' ); | |
307 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
299 | Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' ); | |
308 | Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' ); |
|
300 | Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' ); | |
309 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); |
|
301 | Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' ); | |
310 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); |
|
302 | Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' ); | |
311 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); |
|
303 | Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' ); | |
312 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); |
|
304 | Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' ); | |
313 | Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' ); |
|
305 | Task_name[TASKID_WTDG] = rtems_build_name( 'W', 'T', 'D', 'G' ); | |
314 | Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' ); |
|
306 | Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' ); | |
315 | Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' ); |
|
307 | Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' ); | |
316 | Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' ); |
|
308 | Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' ); | |
317 | Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' ); |
|
309 | Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' ); | |
318 |
|
310 | |||
319 | // rate monotonic period names |
|
311 | // rate monotonic period names | |
320 | name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' ); |
|
312 | name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' ); | |
321 |
|
313 | |||
322 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
314 | misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' ); | |
323 | misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
315 | misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' ); | |
324 | misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' ); |
|
316 | misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' ); | |
325 | misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' ); |
|
317 | misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' ); | |
326 | misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' ); |
|
318 | misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' ); | |
327 | } |
|
319 | } | |
328 |
|
320 | |||
329 | int create_all_tasks( void ) // create all tasks which run in the software |
|
321 | int create_all_tasks( void ) // create all tasks which run in the software | |
330 | { |
|
322 | { | |
331 | /** This function creates all RTEMS tasks used in the software. |
|
323 | /** This function creates all RTEMS tasks used in the software. | |
332 | * |
|
324 | * | |
333 | * @return RTEMS directive status codes: |
|
325 | * @return RTEMS directive status codes: | |
334 | * - RTEMS_SUCCESSFUL - task created successfully |
|
326 | * - RTEMS_SUCCESSFUL - task created successfully | |
335 | * - RTEMS_INVALID_ADDRESS - id is NULL |
|
327 | * - RTEMS_INVALID_ADDRESS - id is NULL | |
336 | * - RTEMS_INVALID_NAME - invalid task name |
|
328 | * - RTEMS_INVALID_NAME - invalid task name | |
337 | * - RTEMS_INVALID_PRIORITY - invalid task priority |
|
329 | * - RTEMS_INVALID_PRIORITY - invalid task priority | |
338 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured |
|
330 | * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured | |
339 | * - RTEMS_TOO_MANY - too many tasks created |
|
331 | * - RTEMS_TOO_MANY - too many tasks created | |
340 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context |
|
332 | * - RTEMS_UNSATISFIED - not enough memory for stack/FP context | |
341 | * - RTEMS_TOO_MANY - too many global objects |
|
333 | * - RTEMS_TOO_MANY - too many global objects | |
342 | * |
|
334 | * | |
343 | */ |
|
335 | */ | |
344 |
|
336 | |||
345 | rtems_status_code status; |
|
337 | rtems_status_code status; | |
346 |
|
338 | |||
347 | //********** |
|
339 | //********** | |
348 | // SPACEWIRE |
|
340 | // SPACEWIRE | |
349 | // RECV |
|
341 | // RECV | |
350 | status = rtems_task_create( |
|
342 | status = rtems_task_create( | |
351 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, |
|
343 | Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE, | |
352 | RTEMS_DEFAULT_MODES, |
|
344 | RTEMS_DEFAULT_MODES, | |
353 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] |
|
345 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV] | |
354 | ); |
|
346 | ); | |
355 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
347 | if (status == RTEMS_SUCCESSFUL) // SEND | |
356 | { |
|
348 | { | |
357 | status = rtems_task_create( |
|
349 | status = rtems_task_create( | |
358 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
350 | Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2, | |
359 | RTEMS_DEFAULT_MODES, |
|
351 | RTEMS_DEFAULT_MODES, | |
360 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND] |
|
352 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND] | |
361 | ); |
|
353 | ); | |
362 | } |
|
354 | } | |
363 | if (status == RTEMS_SUCCESSFUL) // WTDG |
|
355 | if (status == RTEMS_SUCCESSFUL) // WTDG | |
364 | { |
|
356 | { | |
365 | status = rtems_task_create( |
|
357 | status = rtems_task_create( | |
366 | Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE, |
|
358 | Task_name[TASKID_WTDG], TASK_PRIORITY_WTDG, RTEMS_MINIMUM_STACK_SIZE, | |
367 | RTEMS_DEFAULT_MODES, |
|
359 | RTEMS_DEFAULT_MODES, | |
368 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG] |
|
360 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_WTDG] | |
369 | ); |
|
361 | ); | |
370 | } |
|
362 | } | |
371 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
363 | if (status == RTEMS_SUCCESSFUL) // ACTN | |
372 | { |
|
364 | { | |
373 | status = rtems_task_create( |
|
365 | status = rtems_task_create( | |
374 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, |
|
366 | Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE, | |
375 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
367 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
376 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] |
|
368 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN] | |
377 | ); |
|
369 | ); | |
378 | } |
|
370 | } | |
379 | if (status == RTEMS_SUCCESSFUL) // SPIQ |
|
371 | if (status == RTEMS_SUCCESSFUL) // SPIQ | |
380 | { |
|
372 | { | |
381 | status = rtems_task_create( |
|
373 | status = rtems_task_create( | |
382 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, |
|
374 | Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE, | |
383 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
375 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
384 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] |
|
376 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ] | |
385 | ); |
|
377 | ); | |
386 | } |
|
378 | } | |
387 |
|
379 | |||
388 | //****************** |
|
380 | //****************** | |
389 | // SPECTRAL MATRICES |
|
381 | // SPECTRAL MATRICES | |
390 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
382 | if (status == RTEMS_SUCCESSFUL) // AVF0 | |
391 | { |
|
383 | { | |
392 | status = rtems_task_create( |
|
384 | status = rtems_task_create( | |
393 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, |
|
385 | Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE, | |
394 | RTEMS_DEFAULT_MODES, |
|
386 | RTEMS_DEFAULT_MODES, | |
395 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] |
|
387 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0] | |
396 | ); |
|
388 | ); | |
397 | } |
|
389 | } | |
398 | if (status == RTEMS_SUCCESSFUL) // PRC0 |
|
390 | if (status == RTEMS_SUCCESSFUL) // PRC0 | |
399 | { |
|
391 | { | |
400 | status = rtems_task_create( |
|
392 | status = rtems_task_create( | |
401 | Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
393 | Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2, | |
402 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
394 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
403 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0] |
|
395 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0] | |
404 | ); |
|
396 | ); | |
405 | } |
|
397 | } | |
406 | if (status == RTEMS_SUCCESSFUL) // AVF1 |
|
398 | if (status == RTEMS_SUCCESSFUL) // AVF1 | |
407 | { |
|
399 | { | |
408 | status = rtems_task_create( |
|
400 | status = rtems_task_create( | |
409 | Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE, |
|
401 | Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE, | |
410 | RTEMS_DEFAULT_MODES, |
|
402 | RTEMS_DEFAULT_MODES, | |
411 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1] |
|
403 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1] | |
412 | ); |
|
404 | ); | |
413 | } |
|
405 | } | |
414 | if (status == RTEMS_SUCCESSFUL) // PRC1 |
|
406 | if (status == RTEMS_SUCCESSFUL) // PRC1 | |
415 | { |
|
407 | { | |
416 | status = rtems_task_create( |
|
408 | status = rtems_task_create( | |
417 | Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
409 | Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2, | |
418 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
410 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
419 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1] |
|
411 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1] | |
420 | ); |
|
412 | ); | |
421 | } |
|
413 | } | |
422 | if (status == RTEMS_SUCCESSFUL) // AVF2 |
|
414 | if (status == RTEMS_SUCCESSFUL) // AVF2 | |
423 | { |
|
415 | { | |
424 | status = rtems_task_create( |
|
416 | status = rtems_task_create( | |
425 | Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE, |
|
417 | Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE, | |
426 | RTEMS_DEFAULT_MODES, |
|
418 | RTEMS_DEFAULT_MODES, | |
427 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2] |
|
419 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2] | |
428 | ); |
|
420 | ); | |
429 | } |
|
421 | } | |
430 | if (status == RTEMS_SUCCESSFUL) // PRC2 |
|
422 | if (status == RTEMS_SUCCESSFUL) // PRC2 | |
431 | { |
|
423 | { | |
432 | status = rtems_task_create( |
|
424 | status = rtems_task_create( | |
433 | Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2, |
|
425 | Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2, | |
434 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, |
|
426 | RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT, | |
435 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2] |
|
427 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2] | |
436 | ); |
|
428 | ); | |
437 | } |
|
429 | } | |
438 |
|
430 | |||
439 | //**************** |
|
431 | //**************** | |
440 | // WAVEFORM PICKER |
|
432 | // WAVEFORM PICKER | |
441 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
433 | if (status == RTEMS_SUCCESSFUL) // WFRM | |
442 | { |
|
434 | { | |
443 | status = rtems_task_create( |
|
435 | status = rtems_task_create( | |
444 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, |
|
436 | Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE, | |
445 | RTEMS_DEFAULT_MODES, |
|
437 | RTEMS_DEFAULT_MODES, | |
446 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] |
|
438 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM] | |
447 | ); |
|
439 | ); | |
448 | } |
|
440 | } | |
449 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
441 | if (status == RTEMS_SUCCESSFUL) // CWF3 | |
450 | { |
|
442 | { | |
451 | status = rtems_task_create( |
|
443 | status = rtems_task_create( | |
452 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, |
|
444 | Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE, | |
453 | RTEMS_DEFAULT_MODES, |
|
445 | RTEMS_DEFAULT_MODES, | |
454 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3] |
|
446 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3] | |
455 | ); |
|
447 | ); | |
456 | } |
|
448 | } | |
457 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
449 | if (status == RTEMS_SUCCESSFUL) // CWF2 | |
458 | { |
|
450 | { | |
459 | status = rtems_task_create( |
|
451 | status = rtems_task_create( | |
460 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, |
|
452 | Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE, | |
461 | RTEMS_DEFAULT_MODES, |
|
453 | RTEMS_DEFAULT_MODES, | |
462 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2] |
|
454 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2] | |
463 | ); |
|
455 | ); | |
464 | } |
|
456 | } | |
465 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
457 | if (status == RTEMS_SUCCESSFUL) // CWF1 | |
466 | { |
|
458 | { | |
467 | status = rtems_task_create( |
|
459 | status = rtems_task_create( | |
468 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, |
|
460 | Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE, | |
469 | RTEMS_DEFAULT_MODES, |
|
461 | RTEMS_DEFAULT_MODES, | |
470 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1] |
|
462 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1] | |
471 | ); |
|
463 | ); | |
472 | } |
|
464 | } | |
473 | if (status == RTEMS_SUCCESSFUL) // SWBD |
|
465 | if (status == RTEMS_SUCCESSFUL) // SWBD | |
474 | { |
|
466 | { | |
475 | status = rtems_task_create( |
|
467 | status = rtems_task_create( | |
476 | Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE, |
|
468 | Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE, | |
477 | RTEMS_DEFAULT_MODES, |
|
469 | RTEMS_DEFAULT_MODES, | |
478 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD] |
|
470 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD] | |
479 | ); |
|
471 | ); | |
480 | } |
|
472 | } | |
481 |
|
473 | |||
482 | //***** |
|
474 | //***** | |
483 | // MISC |
|
475 | // MISC | |
484 |
if (status == RTEMS_SUCCESSFUL) // |
|
476 | if (status == RTEMS_SUCCESSFUL) // LOAD | |
485 | { |
|
477 | { | |
486 | status = rtems_task_create( |
|
478 | status = rtems_task_create( | |
487 |
Task_name[TASKID_ |
|
479 | Task_name[TASKID_LOAD], TASK_PRIORITY_LOAD, RTEMS_MINIMUM_STACK_SIZE, | |
488 | RTEMS_DEFAULT_MODES, |
|
480 | RTEMS_DEFAULT_MODES, | |
489 |
RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_ |
|
481 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LOAD] | |
490 | ); |
|
482 | ); | |
491 | } |
|
483 | } | |
492 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
484 | if (status == RTEMS_SUCCESSFUL) // DUMB | |
493 | { |
|
485 | { | |
494 | status = rtems_task_create( |
|
486 | status = rtems_task_create( | |
495 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, |
|
487 | Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE, | |
496 | RTEMS_DEFAULT_MODES, |
|
488 | RTEMS_DEFAULT_MODES, | |
497 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] |
|
489 | RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB] | |
498 | ); |
|
490 | ); | |
499 | } |
|
491 | } | |
500 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
492 | if (status == RTEMS_SUCCESSFUL) // HOUS | |
501 | { |
|
493 | { | |
502 | status = rtems_task_create( |
|
494 | status = rtems_task_create( | |
503 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, |
|
495 | Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE, | |
504 | RTEMS_DEFAULT_MODES, |
|
496 | RTEMS_DEFAULT_MODES, | |
505 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS] |
|
497 | RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS] | |
506 | ); |
|
498 | ); | |
507 | } |
|
499 | } | |
508 |
|
500 | |||
509 | return status; |
|
501 | return status; | |
510 | } |
|
502 | } | |
511 |
|
503 | |||
512 | int start_recv_send_tasks( void ) |
|
504 | int start_recv_send_tasks( void ) | |
513 | { |
|
505 | { | |
514 | rtems_status_code status; |
|
506 | rtems_status_code status; | |
515 |
|
507 | |||
516 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); |
|
508 | status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 ); | |
517 | if (status!=RTEMS_SUCCESSFUL) { |
|
509 | if (status!=RTEMS_SUCCESSFUL) { | |
518 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") |
|
510 | BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n") | |
519 | } |
|
511 | } | |
520 |
|
512 | |||
521 | if (status == RTEMS_SUCCESSFUL) // SEND |
|
513 | if (status == RTEMS_SUCCESSFUL) // SEND | |
522 | { |
|
514 | { | |
523 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); |
|
515 | status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 ); | |
524 | if (status!=RTEMS_SUCCESSFUL) { |
|
516 | if (status!=RTEMS_SUCCESSFUL) { | |
525 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") |
|
517 | BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n") | |
526 | } |
|
518 | } | |
527 | } |
|
519 | } | |
528 |
|
520 | |||
529 | return status; |
|
521 | return status; | |
530 | } |
|
522 | } | |
531 |
|
523 | |||
532 | int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS |
|
524 | int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS | |
533 | { |
|
525 | { | |
534 | /** This function starts all RTEMS tasks used in the software. |
|
526 | /** This function starts all RTEMS tasks used in the software. | |
535 | * |
|
527 | * | |
536 | * @return RTEMS directive status codes: |
|
528 | * @return RTEMS directive status codes: | |
537 | * - RTEMS_SUCCESSFUL - ask started successfully |
|
529 | * - RTEMS_SUCCESSFUL - ask started successfully | |
538 | * - RTEMS_INVALID_ADDRESS - invalid task entry point |
|
530 | * - RTEMS_INVALID_ADDRESS - invalid task entry point | |
539 | * - RTEMS_INVALID_ID - invalid task id |
|
531 | * - RTEMS_INVALID_ID - invalid task id | |
540 | * - RTEMS_INCORRECT_STATE - task not in the dormant state |
|
532 | * - RTEMS_INCORRECT_STATE - task not in the dormant state | |
541 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task |
|
533 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task | |
542 | * |
|
534 | * | |
543 | */ |
|
535 | */ | |
544 | // starts all the tasks fot eh flight software |
|
536 | // starts all the tasks fot eh flight software | |
545 |
|
537 | |||
546 | rtems_status_code status; |
|
538 | rtems_status_code status; | |
547 |
|
539 | |||
548 | //********** |
|
540 | //********** | |
549 | // SPACEWIRE |
|
541 | // SPACEWIRE | |
550 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); |
|
542 | status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 ); | |
551 | if (status!=RTEMS_SUCCESSFUL) { |
|
543 | if (status!=RTEMS_SUCCESSFUL) { | |
552 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") |
|
544 | BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n") | |
553 | } |
|
545 | } | |
554 |
|
546 | |||
555 | if (status == RTEMS_SUCCESSFUL) // WTDG |
|
547 | if (status == RTEMS_SUCCESSFUL) // WTDG | |
556 | { |
|
548 | { | |
557 | status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 ); |
|
549 | status = rtems_task_start( Task_id[TASKID_WTDG], wtdg_task, 1 ); | |
558 | if (status!=RTEMS_SUCCESSFUL) { |
|
550 | if (status!=RTEMS_SUCCESSFUL) { | |
559 | BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n") |
|
551 | BOOT_PRINTF("in INIT *** Error starting TASK_WTDG\n") | |
560 | } |
|
552 | } | |
561 | } |
|
553 | } | |
562 |
|
554 | |||
563 | if (status == RTEMS_SUCCESSFUL) // ACTN |
|
555 | if (status == RTEMS_SUCCESSFUL) // ACTN | |
564 | { |
|
556 | { | |
565 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); |
|
557 | status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 ); | |
566 | if (status!=RTEMS_SUCCESSFUL) { |
|
558 | if (status!=RTEMS_SUCCESSFUL) { | |
567 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") |
|
559 | BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n") | |
568 | } |
|
560 | } | |
569 | } |
|
561 | } | |
570 |
|
562 | |||
571 | //****************** |
|
563 | //****************** | |
572 | // SPECTRAL MATRICES |
|
564 | // SPECTRAL MATRICES | |
573 | if (status == RTEMS_SUCCESSFUL) // AVF0 |
|
565 | if (status == RTEMS_SUCCESSFUL) // AVF0 | |
574 | { |
|
566 | { | |
575 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY ); |
|
567 | status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY ); | |
576 | if (status!=RTEMS_SUCCESSFUL) { |
|
568 | if (status!=RTEMS_SUCCESSFUL) { | |
577 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") |
|
569 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n") | |
578 | } |
|
570 | } | |
579 | } |
|
571 | } | |
580 | if (status == RTEMS_SUCCESSFUL) // PRC0 |
|
572 | if (status == RTEMS_SUCCESSFUL) // PRC0 | |
581 | { |
|
573 | { | |
582 | status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY ); |
|
574 | status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY ); | |
583 | if (status!=RTEMS_SUCCESSFUL) { |
|
575 | if (status!=RTEMS_SUCCESSFUL) { | |
584 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n") |
|
576 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n") | |
585 | } |
|
577 | } | |
586 | } |
|
578 | } | |
587 | if (status == RTEMS_SUCCESSFUL) // AVF1 |
|
579 | if (status == RTEMS_SUCCESSFUL) // AVF1 | |
588 | { |
|
580 | { | |
589 | status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY ); |
|
581 | status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY ); | |
590 | if (status!=RTEMS_SUCCESSFUL) { |
|
582 | if (status!=RTEMS_SUCCESSFUL) { | |
591 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n") |
|
583 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n") | |
592 | } |
|
584 | } | |
593 | } |
|
585 | } | |
594 | if (status == RTEMS_SUCCESSFUL) // PRC1 |
|
586 | if (status == RTEMS_SUCCESSFUL) // PRC1 | |
595 | { |
|
587 | { | |
596 | status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY ); |
|
588 | status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY ); | |
597 | if (status!=RTEMS_SUCCESSFUL) { |
|
589 | if (status!=RTEMS_SUCCESSFUL) { | |
598 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n") |
|
590 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n") | |
599 | } |
|
591 | } | |
600 | } |
|
592 | } | |
601 | if (status == RTEMS_SUCCESSFUL) // AVF2 |
|
593 | if (status == RTEMS_SUCCESSFUL) // AVF2 | |
602 | { |
|
594 | { | |
603 | status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 ); |
|
595 | status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 ); | |
604 | if (status!=RTEMS_SUCCESSFUL) { |
|
596 | if (status!=RTEMS_SUCCESSFUL) { | |
605 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n") |
|
597 | BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n") | |
606 | } |
|
598 | } | |
607 | } |
|
599 | } | |
608 | if (status == RTEMS_SUCCESSFUL) // PRC2 |
|
600 | if (status == RTEMS_SUCCESSFUL) // PRC2 | |
609 | { |
|
601 | { | |
610 | status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 ); |
|
602 | status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 ); | |
611 | if (status!=RTEMS_SUCCESSFUL) { |
|
603 | if (status!=RTEMS_SUCCESSFUL) { | |
612 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n") |
|
604 | BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n") | |
613 | } |
|
605 | } | |
614 | } |
|
606 | } | |
615 |
|
607 | |||
616 | //**************** |
|
608 | //**************** | |
617 | // WAVEFORM PICKER |
|
609 | // WAVEFORM PICKER | |
618 | if (status == RTEMS_SUCCESSFUL) // WFRM |
|
610 | if (status == RTEMS_SUCCESSFUL) // WFRM | |
619 | { |
|
611 | { | |
620 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); |
|
612 | status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 ); | |
621 | if (status!=RTEMS_SUCCESSFUL) { |
|
613 | if (status!=RTEMS_SUCCESSFUL) { | |
622 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") |
|
614 | BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n") | |
623 | } |
|
615 | } | |
624 | } |
|
616 | } | |
625 | if (status == RTEMS_SUCCESSFUL) // CWF3 |
|
617 | if (status == RTEMS_SUCCESSFUL) // CWF3 | |
626 | { |
|
618 | { | |
627 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); |
|
619 | status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 ); | |
628 | if (status!=RTEMS_SUCCESSFUL) { |
|
620 | if (status!=RTEMS_SUCCESSFUL) { | |
629 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") |
|
621 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n") | |
630 | } |
|
622 | } | |
631 | } |
|
623 | } | |
632 | if (status == RTEMS_SUCCESSFUL) // CWF2 |
|
624 | if (status == RTEMS_SUCCESSFUL) // CWF2 | |
633 | { |
|
625 | { | |
634 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); |
|
626 | status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 ); | |
635 | if (status!=RTEMS_SUCCESSFUL) { |
|
627 | if (status!=RTEMS_SUCCESSFUL) { | |
636 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") |
|
628 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n") | |
637 | } |
|
629 | } | |
638 | } |
|
630 | } | |
639 | if (status == RTEMS_SUCCESSFUL) // CWF1 |
|
631 | if (status == RTEMS_SUCCESSFUL) // CWF1 | |
640 | { |
|
632 | { | |
641 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); |
|
633 | status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 ); | |
642 | if (status!=RTEMS_SUCCESSFUL) { |
|
634 | if (status!=RTEMS_SUCCESSFUL) { | |
643 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") |
|
635 | BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n") | |
644 | } |
|
636 | } | |
645 | } |
|
637 | } | |
646 | if (status == RTEMS_SUCCESSFUL) // SWBD |
|
638 | if (status == RTEMS_SUCCESSFUL) // SWBD | |
647 | { |
|
639 | { | |
648 | status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 ); |
|
640 | status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 ); | |
649 | if (status!=RTEMS_SUCCESSFUL) { |
|
641 | if (status!=RTEMS_SUCCESSFUL) { | |
650 | BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n") |
|
642 | BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n") | |
651 | } |
|
643 | } | |
652 | } |
|
644 | } | |
653 |
|
645 | |||
654 | //***** |
|
646 | //***** | |
655 | // MISC |
|
647 | // MISC | |
656 | if (status == RTEMS_SUCCESSFUL) // HOUS |
|
648 | if (status == RTEMS_SUCCESSFUL) // HOUS | |
657 | { |
|
649 | { | |
658 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); |
|
650 | status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 ); | |
659 | if (status!=RTEMS_SUCCESSFUL) { |
|
651 | if (status!=RTEMS_SUCCESSFUL) { | |
660 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") |
|
652 | BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n") | |
661 | } |
|
653 | } | |
662 | } |
|
654 | } | |
663 | if (status == RTEMS_SUCCESSFUL) // DUMB |
|
655 | if (status == RTEMS_SUCCESSFUL) // DUMB | |
664 | { |
|
656 | { | |
665 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); |
|
657 | status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 ); | |
666 | if (status!=RTEMS_SUCCESSFUL) { |
|
658 | if (status!=RTEMS_SUCCESSFUL) { | |
667 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") |
|
659 | BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n") | |
668 | } |
|
660 | } | |
669 | } |
|
661 | } | |
670 |
if (status == RTEMS_SUCCESSFUL) // |
|
662 | if (status == RTEMS_SUCCESSFUL) // LOAD | |
671 | { |
|
663 | { | |
672 |
status = rtems_task_start( Task_id[TASKID_ |
|
664 | status = rtems_task_start( Task_id[TASKID_LOAD], load_task, 1 ); | |
673 | if (status!=RTEMS_SUCCESSFUL) { |
|
665 | if (status!=RTEMS_SUCCESSFUL) { | |
674 |
BOOT_PRINTF("in INIT *** Error starting TASK_ |
|
666 | BOOT_PRINTF("in INIT *** Error starting TASK_LOAD\n") | |
675 | } |
|
667 | } | |
676 | } |
|
668 | } | |
677 |
|
669 | |||
678 | return status; |
|
670 | return status; | |
679 | } |
|
671 | } | |
680 |
|
672 | |||
681 | rtems_status_code create_message_queues( void ) // create the two message queues used in the software |
|
673 | rtems_status_code create_message_queues( void ) // create the two message queues used in the software | |
682 | { |
|
674 | { | |
683 | rtems_status_code status_recv; |
|
675 | rtems_status_code status_recv; | |
684 | rtems_status_code status_send; |
|
676 | rtems_status_code status_send; | |
685 | rtems_status_code status_q_p0; |
|
677 | rtems_status_code status_q_p0; | |
686 | rtems_status_code status_q_p1; |
|
678 | rtems_status_code status_q_p1; | |
687 | rtems_status_code status_q_p2; |
|
679 | rtems_status_code status_q_p2; | |
688 | rtems_status_code ret; |
|
680 | rtems_status_code ret; | |
689 | rtems_id queue_id; |
|
681 | rtems_id queue_id; | |
690 |
|
682 | |||
691 | //**************************************** |
|
683 | //**************************************** | |
692 | // create the queue for handling valid TCs |
|
684 | // create the queue for handling valid TCs | |
693 | status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV], |
|
685 | status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV], | |
694 | MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE, |
|
686 | MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE, | |
695 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
687 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
696 | if ( status_recv != RTEMS_SUCCESSFUL ) { |
|
688 | if ( status_recv != RTEMS_SUCCESSFUL ) { | |
697 | PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv) |
|
689 | PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv) | |
698 | } |
|
690 | } | |
699 |
|
691 | |||
700 | //************************************************ |
|
692 | //************************************************ | |
701 | // create the queue for handling TM packet sending |
|
693 | // create the queue for handling TM packet sending | |
702 | status_send = rtems_message_queue_create( misc_name[QUEUE_SEND], |
|
694 | status_send = rtems_message_queue_create( misc_name[QUEUE_SEND], | |
703 | MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND, |
|
695 | MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND, | |
704 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
696 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
705 | if ( status_send != RTEMS_SUCCESSFUL ) { |
|
697 | if ( status_send != RTEMS_SUCCESSFUL ) { | |
706 | PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send) |
|
698 | PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send) | |
707 | } |
|
699 | } | |
708 |
|
700 | |||
709 | //***************************************************************************** |
|
701 | //***************************************************************************** | |
710 | // create the queue for handling averaged spectral matrices for processing @ f0 |
|
702 | // create the queue for handling averaged spectral matrices for processing @ f0 | |
711 | status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0], |
|
703 | status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0], | |
712 | MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0, |
|
704 | MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0, | |
713 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
705 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
714 | if ( status_q_p0 != RTEMS_SUCCESSFUL ) { |
|
706 | if ( status_q_p0 != RTEMS_SUCCESSFUL ) { | |
715 | PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0) |
|
707 | PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0) | |
716 | } |
|
708 | } | |
717 |
|
709 | |||
718 | //***************************************************************************** |
|
710 | //***************************************************************************** | |
719 | // create the queue for handling averaged spectral matrices for processing @ f1 |
|
711 | // create the queue for handling averaged spectral matrices for processing @ f1 | |
720 | status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1], |
|
712 | status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1], | |
721 | MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1, |
|
713 | MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1, | |
722 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
714 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
723 | if ( status_q_p1 != RTEMS_SUCCESSFUL ) { |
|
715 | if ( status_q_p1 != RTEMS_SUCCESSFUL ) { | |
724 | PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1) |
|
716 | PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1) | |
725 | } |
|
717 | } | |
726 |
|
718 | |||
727 | //***************************************************************************** |
|
719 | //***************************************************************************** | |
728 | // create the queue for handling averaged spectral matrices for processing @ f2 |
|
720 | // create the queue for handling averaged spectral matrices for processing @ f2 | |
729 | status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2], |
|
721 | status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2], | |
730 | MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2, |
|
722 | MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2, | |
731 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); |
|
723 | RTEMS_FIFO | RTEMS_LOCAL, &queue_id ); | |
732 | if ( status_q_p2 != RTEMS_SUCCESSFUL ) { |
|
724 | if ( status_q_p2 != RTEMS_SUCCESSFUL ) { | |
733 | PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2) |
|
725 | PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2) | |
734 | } |
|
726 | } | |
735 |
|
727 | |||
736 | if ( status_recv != RTEMS_SUCCESSFUL ) |
|
728 | if ( status_recv != RTEMS_SUCCESSFUL ) | |
737 | { |
|
729 | { | |
738 | ret = status_recv; |
|
730 | ret = status_recv; | |
739 | } |
|
731 | } | |
740 | else if( status_send != RTEMS_SUCCESSFUL ) |
|
732 | else if( status_send != RTEMS_SUCCESSFUL ) | |
741 | { |
|
733 | { | |
742 | ret = status_send; |
|
734 | ret = status_send; | |
743 | } |
|
735 | } | |
744 | else if( status_q_p0 != RTEMS_SUCCESSFUL ) |
|
736 | else if( status_q_p0 != RTEMS_SUCCESSFUL ) | |
745 | { |
|
737 | { | |
746 | ret = status_q_p0; |
|
738 | ret = status_q_p0; | |
747 | } |
|
739 | } | |
748 | else if( status_q_p1 != RTEMS_SUCCESSFUL ) |
|
740 | else if( status_q_p1 != RTEMS_SUCCESSFUL ) | |
749 | { |
|
741 | { | |
750 | ret = status_q_p1; |
|
742 | ret = status_q_p1; | |
751 | } |
|
743 | } | |
752 | else |
|
744 | else | |
753 | { |
|
745 | { | |
754 | ret = status_q_p2; |
|
746 | ret = status_q_p2; | |
755 | } |
|
747 | } | |
756 |
|
748 | |||
757 | return ret; |
|
749 | return ret; | |
758 | } |
|
750 | } | |
759 |
|
751 | |||
760 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ) |
|
752 | rtems_status_code get_message_queue_id_send( rtems_id *queue_id ) | |
761 | { |
|
753 | { | |
762 | rtems_status_code status; |
|
754 | rtems_status_code status; | |
763 | rtems_name queue_name; |
|
755 | rtems_name queue_name; | |
764 |
|
756 | |||
765 | queue_name = rtems_build_name( 'Q', '_', 'S', 'D' ); |
|
757 | queue_name = rtems_build_name( 'Q', '_', 'S', 'D' ); | |
766 |
|
758 | |||
767 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
759 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
768 |
|
760 | |||
769 | return status; |
|
761 | return status; | |
770 | } |
|
762 | } | |
771 |
|
763 | |||
772 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ) |
|
764 | rtems_status_code get_message_queue_id_recv( rtems_id *queue_id ) | |
773 | { |
|
765 | { | |
774 | rtems_status_code status; |
|
766 | rtems_status_code status; | |
775 | rtems_name queue_name; |
|
767 | rtems_name queue_name; | |
776 |
|
768 | |||
777 | queue_name = rtems_build_name( 'Q', '_', 'R', 'V' ); |
|
769 | queue_name = rtems_build_name( 'Q', '_', 'R', 'V' ); | |
778 |
|
770 | |||
779 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
771 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
780 |
|
772 | |||
781 | return status; |
|
773 | return status; | |
782 | } |
|
774 | } | |
783 |
|
775 | |||
784 | rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id ) |
|
776 | rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id ) | |
785 | { |
|
777 | { | |
786 | rtems_status_code status; |
|
778 | rtems_status_code status; | |
787 | rtems_name queue_name; |
|
779 | rtems_name queue_name; | |
788 |
|
780 | |||
789 | queue_name = rtems_build_name( 'Q', '_', 'P', '0' ); |
|
781 | queue_name = rtems_build_name( 'Q', '_', 'P', '0' ); | |
790 |
|
782 | |||
791 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
783 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
792 |
|
784 | |||
793 | return status; |
|
785 | return status; | |
794 | } |
|
786 | } | |
795 |
|
787 | |||
796 | rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ) |
|
788 | rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id ) | |
797 | { |
|
789 | { | |
798 | rtems_status_code status; |
|
790 | rtems_status_code status; | |
799 | rtems_name queue_name; |
|
791 | rtems_name queue_name; | |
800 |
|
792 | |||
801 | queue_name = rtems_build_name( 'Q', '_', 'P', '1' ); |
|
793 | queue_name = rtems_build_name( 'Q', '_', 'P', '1' ); | |
802 |
|
794 | |||
803 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
795 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
804 |
|
796 | |||
805 | return status; |
|
797 | return status; | |
806 | } |
|
798 | } | |
807 |
|
799 | |||
808 | rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ) |
|
800 | rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id ) | |
809 | { |
|
801 | { | |
810 | rtems_status_code status; |
|
802 | rtems_status_code status; | |
811 | rtems_name queue_name; |
|
803 | rtems_name queue_name; | |
812 |
|
804 | |||
813 | queue_name = rtems_build_name( 'Q', '_', 'P', '2' ); |
|
805 | queue_name = rtems_build_name( 'Q', '_', 'P', '2' ); | |
814 |
|
806 | |||
815 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); |
|
807 | status = rtems_message_queue_ident( queue_name, 0, queue_id ); | |
816 |
|
808 | |||
817 | return status; |
|
809 | return status; | |
818 | } |
|
810 | } | |
819 |
|
811 | |||
820 | void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max ) |
|
812 | void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max ) | |
821 | { |
|
813 | { | |
822 | u_int32_t count; |
|
814 | u_int32_t count; | |
823 | rtems_status_code status; |
|
815 | rtems_status_code status; | |
824 |
|
816 | |||
825 | status = rtems_message_queue_get_number_pending( queue_id, &count ); |
|
817 | status = rtems_message_queue_get_number_pending( queue_id, &count ); | |
826 |
|
818 | |||
827 | count = count + 1; |
|
819 | count = count + 1; | |
828 |
|
820 | |||
829 | if (status != RTEMS_SUCCESSFUL) |
|
821 | if (status != RTEMS_SUCCESSFUL) | |
830 | { |
|
822 | { | |
831 | PRINTF1("in update_queue_max_count *** ERR = %d\n", status) |
|
823 | PRINTF1("in update_queue_max_count *** ERR = %d\n", status) | |
832 | } |
|
824 | } | |
833 | else |
|
825 | else | |
834 | { |
|
826 | { | |
835 | if (count > *fifo_size_max) |
|
827 | if (count > *fifo_size_max) | |
836 | { |
|
828 | { | |
837 | *fifo_size_max = count; |
|
829 | *fifo_size_max = count; | |
838 | } |
|
830 | } | |
839 | } |
|
831 | } | |
840 | } |
|
832 | } | |
841 |
|
833 | |||
842 | void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize ) |
|
834 | void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize ) | |
843 | { |
|
835 | { | |
844 | unsigned char i; |
|
836 | unsigned char i; | |
845 |
|
837 | |||
846 | //*************** |
|
838 | //*************** | |
847 | // BUFFER ADDRESS |
|
839 | // BUFFER ADDRESS | |
848 | for(i=0; i<nbNodes; i++) |
|
840 | for(i=0; i<nbNodes; i++) | |
849 | { |
|
841 | { | |
850 | ring[i].coarseTime = 0xffffffff; |
|
842 | ring[i].coarseTime = 0xffffffff; | |
851 | ring[i].fineTime = 0xffffffff; |
|
843 | ring[i].fineTime = 0xffffffff; | |
852 | ring[i].sid = 0x00; |
|
844 | ring[i].sid = 0x00; | |
853 | ring[i].status = 0x00; |
|
845 | ring[i].status = 0x00; | |
854 | ring[i].buffer_address = (int) &buffer[ i * bufferSize ]; |
|
846 | ring[i].buffer_address = (int) &buffer[ i * bufferSize ]; | |
855 | } |
|
847 | } | |
856 |
|
848 | |||
857 | //***** |
|
849 | //***** | |
858 | // NEXT |
|
850 | // NEXT | |
859 | ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ]; |
|
851 | ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ]; | |
860 | for(i=0; i<nbNodes-1; i++) |
|
852 | for(i=0; i<nbNodes-1; i++) | |
861 | { |
|
853 | { | |
862 | ring[i].next = (ring_node*) &ring[ i + 1 ]; |
|
854 | ring[i].next = (ring_node*) &ring[ i + 1 ]; | |
863 | } |
|
855 | } | |
864 |
|
856 | |||
865 | //********* |
|
857 | //********* | |
866 | // PREVIOUS |
|
858 | // PREVIOUS | |
867 | ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ]; |
|
859 | ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ]; | |
868 | for(i=1; i<nbNodes; i++) |
|
860 | for(i=1; i<nbNodes; i++) | |
869 | { |
|
861 | { | |
870 | ring[i].previous = (ring_node*) &ring[ i - 1 ]; |
|
862 | ring[i].previous = (ring_node*) &ring[ i - 1 ]; | |
871 | } |
|
863 | } | |
872 | } |
|
864 | } |
@@ -1,570 +1,652 | |||||
1 | /** General usage functions and RTEMS tasks. |
|
1 | /** General usage functions and RTEMS tasks. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | */ |
|
6 | */ | |
7 |
|
7 | |||
8 | #include "fsw_misc.h" |
|
8 | #include "fsw_misc.h" | |
9 |
|
9 | |||
10 |
void configure |
|
10 | void timer_configure(unsigned char timer, unsigned int clock_divider, | |
11 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ) |
|
11 | unsigned char interrupt_level, rtems_isr (*timer_isr)() ) | |
12 | { |
|
12 | { | |
13 | /** This function configures a GPTIMER timer instantiated in the VHDL design. |
|
13 | /** This function configures a GPTIMER timer instantiated in the VHDL design. | |
14 | * |
|
14 | * | |
15 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
15 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
16 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
16 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
17 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. |
|
17 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. | |
18 | * @param interrupt_level is the interrupt level that the timer drives. |
|
18 | * @param interrupt_level is the interrupt level that the timer drives. | |
19 | * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer. |
|
19 | * @param timer_isr is the interrupt subroutine that will be attached to the IRQ driven by the timer. | |
20 | * |
|
20 | * | |
21 | * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76 |
|
21 | * Interrupt levels are described in the SPARC documentation sparcv8.pdf p.76 | |
22 | * |
|
22 | * | |
23 | */ |
|
23 | */ | |
24 |
|
24 | |||
25 | rtems_status_code status; |
|
25 | rtems_status_code status; | |
26 | rtems_isr_entry old_isr_handler; |
|
26 | rtems_isr_entry old_isr_handler; | |
27 |
|
27 | |||
28 | gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register |
|
28 | gptimer_regs->timer[timer].ctrl = 0x00; // reset the control register | |
29 |
|
29 | |||
30 | status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels |
|
30 | status = rtems_interrupt_catch( timer_isr, interrupt_level, &old_isr_handler) ; // see sparcv8.pdf p.76 for interrupt levels | |
31 | if (status!=RTEMS_SUCCESSFUL) |
|
31 | if (status!=RTEMS_SUCCESSFUL) | |
32 | { |
|
32 | { | |
33 | PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n") |
|
33 | PRINTF("in configure_timer *** ERR rtems_interrupt_catch\n") | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 |
timer_set_clock_divider( |
|
36 | timer_set_clock_divider( timer, clock_divider); | |
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 |
void timer_start( |
|
39 | void timer_start(unsigned char timer) | |
40 | { |
|
40 | { | |
41 | /** This function starts a GPTIMER timer. |
|
41 | /** This function starts a GPTIMER timer. | |
42 | * |
|
42 | * | |
43 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
43 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
44 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
44 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
45 | * |
|
45 | * | |
46 | */ |
|
46 | */ | |
47 |
|
47 | |||
48 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any |
|
48 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any | |
49 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register |
|
49 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000004; // LD load value from the reload register | |
50 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer |
|
50 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000001; // EN enable the timer | |
51 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart |
|
51 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000002; // RS restart | |
52 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable |
|
52 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000008; // IE interrupt enable | |
53 | } |
|
53 | } | |
54 |
|
54 | |||
55 |
void timer_stop( |
|
55 | void timer_stop(unsigned char timer) | |
56 | { |
|
56 | { | |
57 | /** This function stops a GPTIMER timer. |
|
57 | /** This function stops a GPTIMER timer. | |
58 | * |
|
58 | * | |
59 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
59 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
60 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
60 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
61 | * |
|
61 | * | |
62 | */ |
|
62 | */ | |
63 |
|
63 | |||
64 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer |
|
64 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xfffffffe; // EN enable the timer | |
65 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable |
|
65 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl & 0xffffffef; // IE interrupt enable | |
66 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any |
|
66 | gptimer_regs->timer[timer].ctrl = gptimer_regs->timer[timer].ctrl | 0x00000010; // clear pending IRQ if any | |
67 | } |
|
67 | } | |
68 |
|
68 | |||
69 |
void timer_set_clock_divider( |
|
69 | void timer_set_clock_divider(unsigned char timer, unsigned int clock_divider) | |
70 | { |
|
70 | { | |
71 | /** This function sets the clock divider of a GPTIMER timer. |
|
71 | /** This function sets the clock divider of a GPTIMER timer. | |
72 | * |
|
72 | * | |
73 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. |
|
73 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |
74 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). |
|
74 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |
75 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. |
|
75 | * @param clock_divider is the divider of the 1 MHz clock that will be configured. | |
76 | * |
|
76 | * | |
77 | */ |
|
77 | */ | |
78 |
|
78 | |||
79 | gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz |
|
79 | gptimer_regs->timer[timer].reload = clock_divider; // base clock frequency is 1 MHz | |
80 | } |
|
80 | } | |
81 |
|
81 | |||
|
82 | // WATCHDOG | |||
|
83 | ||||
|
84 | rtems_isr watchdog_isr( rtems_vector_number vector ) | |||
|
85 | { | |||
|
86 | rtems_status_code status_code; | |||
|
87 | ||||
|
88 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_12 ); | |||
|
89 | } | |||
|
90 | ||||
|
91 | void watchdog_configure(void) | |||
|
92 | { | |||
|
93 | /** This function configure the watchdog. | |||
|
94 | * | |||
|
95 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |||
|
96 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |||
|
97 | * | |||
|
98 | * The watchdog is a timer provided by the GPTIMER IP core of the GRLIB. | |||
|
99 | * | |||
|
100 | */ | |||
|
101 | ||||
|
102 | LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt during configuration | |||
|
103 | ||||
|
104 | timer_configure( TIMER_WATCHDOG, CLKDIV_WATCHDOG, IRQ_SPARC_GPTIMER_WATCHDOG, watchdog_isr ); | |||
|
105 | ||||
|
106 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt | |||
|
107 | } | |||
|
108 | ||||
|
109 | void watchdog_stop(void) | |||
|
110 | { | |||
|
111 | LEON_Mask_interrupt( IRQ_GPTIMER_WATCHDOG ); // mask gptimer/watchdog interrupt line | |||
|
112 | timer_stop( TIMER_WATCHDOG ); | |||
|
113 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); // clear gptimer/watchdog interrupt | |||
|
114 | } | |||
|
115 | ||||
|
116 | void watchdog_reload(void) | |||
|
117 | { | |||
|
118 | /** This function reloads the watchdog timer counter with the timer reload value. | |||
|
119 | * | |||
|
120 | * | |||
|
121 | */ | |||
|
122 | ||||
|
123 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000004; // LD load value from the reload register | |||
|
124 | } | |||
|
125 | ||||
|
126 | void watchdog_start(void) | |||
|
127 | { | |||
|
128 | /** This function starts the watchdog timer. | |||
|
129 | * | |||
|
130 | * @param gptimer_regs points to the APB registers of the GPTIMER IP core. | |||
|
131 | * @param timer is the number of the timer in the IP core (several timers can be instantiated). | |||
|
132 | * | |||
|
133 | */ | |||
|
134 | ||||
|
135 | LEON_Clear_interrupt( IRQ_GPTIMER_WATCHDOG ); | |||
|
136 | ||||
|
137 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000010; // clear pending IRQ if any | |||
|
138 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000004; // LD load value from the reload register | |||
|
139 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000001; // EN enable the timer | |||
|
140 | gptimer_regs->timer[TIMER_WATCHDOG].ctrl = gptimer_regs->timer[TIMER_WATCHDOG].ctrl | 0x00000008; // IE interrupt enable | |||
|
141 | ||||
|
142 | LEON_Unmask_interrupt( IRQ_GPTIMER_WATCHDOG ); | |||
|
143 | ||||
|
144 | } | |||
|
145 | ||||
82 | int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port |
|
146 | int send_console_outputs_on_apbuart_port( void ) // Send the console outputs on the apbuart port | |
83 | { |
|
147 | { | |
84 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; |
|
148 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; | |
85 |
|
149 | |||
86 | apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE; |
|
150 | apbuart_regs->ctrl = APBUART_CTRL_REG_MASK_TE; | |
87 |
|
151 | |||
88 | return 0; |
|
152 | return 0; | |
89 | } |
|
153 | } | |
90 |
|
154 | |||
91 | int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register |
|
155 | int enable_apbuart_transmitter( void ) // set the bit 1, TE Transmitter Enable to 1 in the APBUART control register | |
92 | { |
|
156 | { | |
93 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; |
|
157 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) REGS_ADDR_APBUART; | |
94 |
|
158 | |||
95 | apbuart_regs->ctrl = apbuart_regs->ctrl | APBUART_CTRL_REG_MASK_TE; |
|
159 | apbuart_regs->ctrl = apbuart_regs->ctrl | APBUART_CTRL_REG_MASK_TE; | |
96 |
|
160 | |||
97 | return 0; |
|
161 | return 0; | |
98 | } |
|
162 | } | |
99 |
|
163 | |||
100 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value) |
|
164 | void set_apbuart_scaler_reload_register(unsigned int regs, unsigned int value) | |
101 | { |
|
165 | { | |
102 | /** This function sets the scaler reload register of the apbuart module |
|
166 | /** This function sets the scaler reload register of the apbuart module | |
103 | * |
|
167 | * | |
104 | * @param regs is the address of the apbuart registers in memory |
|
168 | * @param regs is the address of the apbuart registers in memory | |
105 | * @param value is the value that will be stored in the scaler register |
|
169 | * @param value is the value that will be stored in the scaler register | |
106 | * |
|
170 | * | |
107 | * The value shall be set by the software to get data on the serial interface. |
|
171 | * The value shall be set by the software to get data on the serial interface. | |
108 | * |
|
172 | * | |
109 | */ |
|
173 | */ | |
110 |
|
174 | |||
111 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs; |
|
175 | struct apbuart_regs_str *apbuart_regs = (struct apbuart_regs_str *) regs; | |
112 |
|
176 | |||
113 | apbuart_regs->scaler = value; |
|
177 | apbuart_regs->scaler = value; | |
114 | BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value) |
|
178 | BOOT_PRINTF1("OK *** apbuart port scaler reload register set to 0x%x\n", value) | |
115 | } |
|
179 | } | |
116 |
|
180 | |||
117 | //************ |
|
181 | //************ | |
118 | // RTEMS TASKS |
|
182 | // RTEMS TASKS | |
119 |
|
183 | |||
120 |
rtems_task |
|
184 | rtems_task load_task(rtems_task_argument argument) | |
121 | { |
|
185 | { | |
122 | int i; |
|
186 | BOOT_PRINTF("in LOAD *** \n") | |
123 | int j; |
|
187 | ||
|
188 | rtems_status_code status; | |||
|
189 | unsigned int i; | |||
|
190 | unsigned int j; | |||
|
191 | rtems_name name_watchdog_rate_monotonic; // name of the watchdog rate monotonic | |||
|
192 | rtems_id watchdog_period_id; // id of the watchdog rate monotonic period | |||
|
193 | ||||
|
194 | name_watchdog_rate_monotonic = rtems_build_name( 'L', 'O', 'A', 'D' ); | |||
|
195 | ||||
|
196 | status = rtems_rate_monotonic_create( name_watchdog_rate_monotonic, &watchdog_period_id ); | |||
|
197 | if( status != RTEMS_SUCCESSFUL ) { | |||
|
198 | PRINTF1( "in LOAD *** rtems_rate_monotonic_create failed with status of %d\n", status ) | |||
|
199 | } | |||
|
200 | ||||
124 | i = 0; |
|
201 | i = 0; | |
125 | j = 0; |
|
202 | j = 0; | |
126 | BOOT_PRINTF("in STAT *** \n") |
|
203 | ||
|
204 | watchdog_configure(); | |||
|
205 | ||||
|
206 | watchdog_start(); | |||
|
207 | ||||
127 | while(1){ |
|
208 | while(1){ | |
128 | rtems_task_wake_after(1000); |
|
209 | status = rtems_rate_monotonic_period( watchdog_period_id, WATCHDOG_PERIOD ); | |
129 | PRINTF1("%d\n", j) |
|
210 | watchdog_reload(); | |
130 | if (i == CPU_USAGE_REPORT_PERIOD) { |
|
211 | i = i + 1; | |
131 | // #ifdef PRINT_TASK_STATISTICS |
|
212 | if ( i == 10 ) | |
132 | // rtems_cpu_usage_report(); |
|
213 | { | |
133 | // rtems_cpu_usage_reset(); |
|
|||
134 | // #endif |
|
|||
135 | i = 0; |
|
214 | i = 0; | |
|
215 | j = j + 1; | |||
|
216 | PRINTF1("%d\n", j) | |||
136 | } |
|
217 | } | |
137 | else i++; |
|
218 | if (j == 3 ) | |
138 |
|
|
219 | { | |
|
220 | status = rtems_task_delete(RTEMS_SELF); | |||
|
221 | } | |||
139 | } |
|
222 | } | |
140 | } |
|
223 | } | |
141 |
|
224 | |||
142 | rtems_task hous_task(rtems_task_argument argument) |
|
225 | rtems_task hous_task(rtems_task_argument argument) | |
143 | { |
|
226 | { | |
144 | rtems_status_code status; |
|
227 | rtems_status_code status; | |
145 | rtems_status_code spare_status; |
|
228 | rtems_status_code spare_status; | |
146 | rtems_id queue_id; |
|
229 | rtems_id queue_id; | |
147 | rtems_rate_monotonic_period_status period_status; |
|
230 | rtems_rate_monotonic_period_status period_status; | |
148 |
|
231 | |||
149 | status = get_message_queue_id_send( &queue_id ); |
|
232 | status = get_message_queue_id_send( &queue_id ); | |
150 | if (status != RTEMS_SUCCESSFUL) |
|
233 | if (status != RTEMS_SUCCESSFUL) | |
151 | { |
|
234 | { | |
152 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) |
|
235 | PRINTF1("in HOUS *** ERR get_message_queue_id_send %d\n", status) | |
153 | } |
|
236 | } | |
154 |
|
237 | |||
155 | BOOT_PRINTF("in HOUS ***\n") |
|
238 | BOOT_PRINTF("in HOUS ***\n") | |
156 |
|
239 | |||
157 | if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) { |
|
240 | if (rtems_rate_monotonic_ident( name_hk_rate_monotonic, &HK_id) != RTEMS_SUCCESSFUL) { | |
158 | status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id ); |
|
241 | status = rtems_rate_monotonic_create( name_hk_rate_monotonic, &HK_id ); | |
159 | if( status != RTEMS_SUCCESSFUL ) { |
|
242 | if( status != RTEMS_SUCCESSFUL ) { | |
160 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ) |
|
243 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ) | |
161 | } |
|
244 | } | |
162 | } |
|
245 | } | |
163 |
|
246 | |||
164 | status = rtems_rate_monotonic_cancel(HK_id); |
|
247 | status = rtems_rate_monotonic_cancel(HK_id); | |
165 | if( status != RTEMS_SUCCESSFUL ) { |
|
248 | if( status != RTEMS_SUCCESSFUL ) { | |
166 | PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status ) |
|
249 | PRINTF1( "ERR *** in HOUS *** rtems_rate_monotonic_cancel(HK_id) ***code: %d\n", status ) | |
167 | } |
|
250 | } | |
168 | else { |
|
251 | else { | |
169 | DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n") |
|
252 | DEBUG_PRINTF("OK *** in HOUS *** rtems_rate_monotonic_cancel(HK_id)\n") | |
170 | } |
|
253 | } | |
171 |
|
254 | |||
172 | // startup phase |
|
255 | // startup phase | |
173 | status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks ); |
|
256 | status = rtems_rate_monotonic_period( HK_id, SY_LFR_TIME_SYN_TIMEOUT_in_ticks ); | |
174 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); |
|
257 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); | |
175 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) |
|
258 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) | |
176 | while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway |
|
259 | while(period_status.state != RATE_MONOTONIC_EXPIRED ) // after SY_LFR_TIME_SYN_TIMEOUT ms, starts HK anyway | |
177 | { |
|
260 | { | |
178 | if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization |
|
261 | if ((time_management_regs->coarse_time & 0x80000000) == 0x00000000) // check time synchronization | |
179 | { |
|
262 | { | |
180 | break; // break if LFR is synchronized |
|
263 | break; // break if LFR is synchronized | |
181 | } |
|
264 | } | |
182 | else |
|
265 | else | |
183 | { |
|
266 | { | |
184 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); |
|
267 | status = rtems_rate_monotonic_get_status( HK_id, &period_status ); | |
185 | // sched_yield(); |
|
268 | // sched_yield(); | |
186 | status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms |
|
269 | status = rtems_task_wake_after( 10 ); // wait SY_LFR_DPU_CONNECT_TIMEOUT 100 ms = 10 * 10 ms | |
187 | } |
|
270 | } | |
188 | } |
|
271 | } | |
189 | status = rtems_rate_monotonic_cancel(HK_id); |
|
272 | status = rtems_rate_monotonic_cancel(HK_id); | |
190 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) |
|
273 | DEBUG_PRINTF1("startup HK, HK_id status = %d\n", period_status.state) | |
191 |
|
274 | |||
192 | set_hk_lfr_reset_cause( POWER_ON ); |
|
275 | set_hk_lfr_reset_cause( POWER_ON ); | |
193 |
|
276 | |||
194 | while(1){ // launch the rate monotonic task |
|
277 | while(1){ // launch the rate monotonic task | |
195 | status = rtems_rate_monotonic_period( HK_id, HK_PERIOD ); |
|
278 | status = rtems_rate_monotonic_period( HK_id, HK_PERIOD ); | |
196 | if ( status != RTEMS_SUCCESSFUL ) { |
|
279 | if ( status != RTEMS_SUCCESSFUL ) { | |
197 | PRINTF1( "in HOUS *** ERR period: %d\n", status); |
|
280 | PRINTF1( "in HOUS *** ERR period: %d\n", status); | |
198 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 ); |
|
281 | spare_status = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_6 ); | |
199 | } |
|
282 | } | |
200 | else { |
|
283 | else { | |
201 | housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8); |
|
284 | housekeeping_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterHK >> 8); | |
202 | housekeeping_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterHK ); |
|
285 | housekeeping_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterHK ); | |
203 | increment_seq_counter( &sequenceCounterHK ); |
|
286 | increment_seq_counter( &sequenceCounterHK ); | |
204 |
|
287 | |||
205 | housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
288 | housekeeping_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
206 | housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
289 | housekeeping_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
207 | housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
290 | housekeeping_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
208 | housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
291 | housekeeping_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
209 | housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
292 | housekeeping_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
210 | housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
293 | housekeeping_packet.time[5] = (unsigned char) (time_management_regs->fine_time); | |
211 |
|
294 | |||
212 | spacewire_update_statistics(); |
|
295 | spacewire_update_statistics(); | |
213 |
|
296 | |||
214 | housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max; |
|
297 | housekeeping_packet.hk_lfr_q_sd_fifo_size_max = hk_lfr_q_sd_fifo_size_max; | |
215 | housekeeping_packet.hk_lfr_q_rv_fifo_size_max = hk_lfr_q_rv_fifo_size_max; |
|
298 | housekeeping_packet.hk_lfr_q_rv_fifo_size_max = hk_lfr_q_rv_fifo_size_max; | |
216 | housekeeping_packet.hk_lfr_q_p0_fifo_size_max = hk_lfr_q_p0_fifo_size_max; |
|
299 | housekeeping_packet.hk_lfr_q_p0_fifo_size_max = hk_lfr_q_p0_fifo_size_max; | |
217 | housekeeping_packet.hk_lfr_q_p1_fifo_size_max = hk_lfr_q_p1_fifo_size_max; |
|
300 | housekeeping_packet.hk_lfr_q_p1_fifo_size_max = hk_lfr_q_p1_fifo_size_max; | |
218 | housekeeping_packet.hk_lfr_q_p2_fifo_size_max = hk_lfr_q_p2_fifo_size_max; |
|
301 | housekeeping_packet.hk_lfr_q_p2_fifo_size_max = hk_lfr_q_p2_fifo_size_max; | |
219 |
|
302 | |||
220 | housekeeping_packet.sy_lfr_common_parameters_spare = parameter_dump_packet.sy_lfr_common_parameters_spare; |
|
303 | housekeeping_packet.sy_lfr_common_parameters_spare = parameter_dump_packet.sy_lfr_common_parameters_spare; | |
221 | housekeeping_packet.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; |
|
304 | housekeeping_packet.sy_lfr_common_parameters = parameter_dump_packet.sy_lfr_common_parameters; | |
222 | get_temperatures( housekeeping_packet.hk_lfr_temp_scm ); |
|
305 | get_temperatures( housekeeping_packet.hk_lfr_temp_scm ); | |
223 | get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 ); |
|
306 | get_v_e1_e2_f3( housekeeping_packet.hk_lfr_sc_v_f3 ); | |
224 | get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load ); |
|
307 | get_cpu_load( (unsigned char *) &housekeeping_packet.hk_lfr_cpu_load ); | |
225 |
|
308 | |||
226 | // SEND PACKET |
|
309 | // SEND PACKET | |
227 | status = rtems_message_queue_send( queue_id, &housekeeping_packet, |
|
310 | status = rtems_message_queue_send( queue_id, &housekeeping_packet, | |
228 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
311 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
229 | if (status != RTEMS_SUCCESSFUL) { |
|
312 | if (status != RTEMS_SUCCESSFUL) { | |
230 | PRINTF1("in HOUS *** ERR send: %d\n", status) |
|
313 | PRINTF1("in HOUS *** ERR send: %d\n", status) | |
231 | } |
|
314 | } | |
232 | } |
|
315 | } | |
233 | } |
|
316 | } | |
234 |
|
317 | |||
235 | PRINTF("in HOUS *** deleting task\n") |
|
318 | PRINTF("in HOUS *** deleting task\n") | |
236 |
|
319 | |||
237 | status = rtems_task_delete( RTEMS_SELF ); // should not return |
|
320 | status = rtems_task_delete( RTEMS_SELF ); // should not return | |
238 |
|
321 | |||
239 | return; |
|
322 | return; | |
240 | } |
|
323 | } | |
241 |
|
324 | |||
242 | rtems_task dumb_task( rtems_task_argument unused ) |
|
325 | rtems_task dumb_task( rtems_task_argument unused ) | |
243 | { |
|
326 | { | |
244 | /** This RTEMS taks is used to print messages without affecting the general behaviour of the software. |
|
327 | /** This RTEMS taks is used to print messages without affecting the general behaviour of the software. | |
245 | * |
|
328 | * | |
246 | * @param unused is the starting argument of the RTEMS task |
|
329 | * @param unused is the starting argument of the RTEMS task | |
247 | * |
|
330 | * | |
248 | * The DUMB taks waits for RTEMS events and print messages depending on the incoming events. |
|
331 | * The DUMB taks waits for RTEMS events and print messages depending on the incoming events. | |
249 | * |
|
332 | * | |
250 | */ |
|
333 | */ | |
251 |
|
334 | |||
252 | unsigned int i; |
|
335 | unsigned int i; | |
253 | unsigned int intEventOut; |
|
336 | unsigned int intEventOut; | |
254 | unsigned int coarse_time = 0; |
|
337 | unsigned int coarse_time = 0; | |
255 | unsigned int fine_time = 0; |
|
338 | unsigned int fine_time = 0; | |
256 | rtems_event_set event_out; |
|
339 | rtems_event_set event_out; | |
257 |
|
340 | |||
258 |
char *DumbMessages[1 |
|
341 | char *DumbMessages[13] = {"in DUMB *** default", // RTEMS_EVENT_0 | |
259 | "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1 |
|
342 | "in DUMB *** timecode_irq_handler", // RTEMS_EVENT_1 | |
260 | "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2 |
|
343 | "in DUMB *** f3 buffer changed", // RTEMS_EVENT_2 | |
261 | "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3 |
|
344 | "in DUMB *** in SMIQ *** Error sending event to AVF0", // RTEMS_EVENT_3 | |
262 | "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4 |
|
345 | "in DUMB *** spectral_matrices_isr *** Error sending event to SMIQ", // RTEMS_EVENT_4 | |
263 | "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5 |
|
346 | "in DUMB *** waveforms_simulator_isr", // RTEMS_EVENT_5 | |
264 | "VHDL SM *** two buffers f0 ready", // RTEMS_EVENT_6 |
|
347 | "VHDL SM *** two buffers f0 ready", // RTEMS_EVENT_6 | |
265 | "ready for dump", // RTEMS_EVENT_7 |
|
348 | "ready for dump", // RTEMS_EVENT_7 | |
266 | "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8 |
|
349 | "VHDL ERR *** spectral matrix", // RTEMS_EVENT_8 | |
267 | "tick", // RTEMS_EVENT_9 |
|
350 | "tick", // RTEMS_EVENT_9 | |
268 | "VHDL ERR *** waveform picker", // RTEMS_EVENT_10 |
|
351 | "VHDL ERR *** waveform picker", // RTEMS_EVENT_10 | |
269 |
"VHDL ERR *** unexpected ready matrix values" |
|
352 | "VHDL ERR *** unexpected ready matrix values", // RTEMS_EVENT_11 | |
|
353 | "WATCHDOG timer" // RTEMS_EVENT_12 | |||
270 | }; |
|
354 | }; | |
271 |
|
355 | |||
272 | BOOT_PRINTF("in DUMB *** \n") |
|
356 | BOOT_PRINTF("in DUMB *** \n") | |
273 |
|
357 | |||
274 | while(1){ |
|
358 | while(1){ | |
275 | rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 |
|
359 | rtems_event_receive(RTEMS_EVENT_0 | RTEMS_EVENT_1 | RTEMS_EVENT_2 | RTEMS_EVENT_3 | |
276 | | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7 |
|
360 | | RTEMS_EVENT_4 | RTEMS_EVENT_5 | RTEMS_EVENT_6 | RTEMS_EVENT_7 | |
277 | | RTEMS_EVENT_8 | RTEMS_EVENT_9, |
|
361 | | RTEMS_EVENT_8 | RTEMS_EVENT_9 | RTEMS_EVENT_12, | |
278 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT |
|
362 | RTEMS_WAIT | RTEMS_EVENT_ANY, RTEMS_NO_TIMEOUT, &event_out); // wait for an RTEMS_EVENT | |
279 | intEventOut = (unsigned int) event_out; |
|
363 | intEventOut = (unsigned int) event_out; | |
280 | for ( i=0; i<32; i++) |
|
364 | for ( i=0; i<32; i++) | |
281 | { |
|
365 | { | |
282 | if ( ((intEventOut >> i) & 0x0001) != 0) |
|
366 | if ( ((intEventOut >> i) & 0x0001) != 0) | |
283 | { |
|
367 | { | |
284 | coarse_time = time_management_regs->coarse_time; |
|
368 | coarse_time = time_management_regs->coarse_time; | |
285 | fine_time = time_management_regs->fine_time; |
|
369 | fine_time = time_management_regs->fine_time; | |
286 |
if (i== |
|
370 | if (i==12) | |
287 | { |
|
371 | { | |
288 | } |
|
372 | PRINTF1("%s\n", DumbMessages[12]) | |
289 | if (i==10) |
|
|||
290 | { |
|
|||
291 | } |
|
373 | } | |
292 | } |
|
374 | } | |
293 | } |
|
375 | } | |
294 | } |
|
376 | } | |
295 | } |
|
377 | } | |
296 |
|
378 | |||
297 | //***************************** |
|
379 | //***************************** | |
298 | // init housekeeping parameters |
|
380 | // init housekeeping parameters | |
299 |
|
381 | |||
300 | void init_housekeeping_parameters( void ) |
|
382 | void init_housekeeping_parameters( void ) | |
301 | { |
|
383 | { | |
302 | /** This function initialize the housekeeping_packet global variable with default values. |
|
384 | /** This function initialize the housekeeping_packet global variable with default values. | |
303 | * |
|
385 | * | |
304 | */ |
|
386 | */ | |
305 |
|
387 | |||
306 | unsigned int i = 0; |
|
388 | unsigned int i = 0; | |
307 | unsigned char *parameters; |
|
389 | unsigned char *parameters; | |
308 | unsigned char sizeOfHK; |
|
390 | unsigned char sizeOfHK; | |
309 |
|
391 | |||
310 | sizeOfHK = sizeof( Packet_TM_LFR_HK_t ); |
|
392 | sizeOfHK = sizeof( Packet_TM_LFR_HK_t ); | |
311 |
|
393 | |||
312 | parameters = (unsigned char*) &housekeeping_packet; |
|
394 | parameters = (unsigned char*) &housekeeping_packet; | |
313 |
|
395 | |||
314 | for(i = 0; i< sizeOfHK; i++) |
|
396 | for(i = 0; i< sizeOfHK; i++) | |
315 | { |
|
397 | { | |
316 | parameters[i] = 0x00; |
|
398 | parameters[i] = 0x00; | |
317 | } |
|
399 | } | |
318 |
|
400 | |||
319 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
401 | housekeeping_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
320 | housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
402 | housekeeping_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
321 | housekeeping_packet.reserved = DEFAULT_RESERVED; |
|
403 | housekeeping_packet.reserved = DEFAULT_RESERVED; | |
322 | housekeeping_packet.userApplication = CCSDS_USER_APP; |
|
404 | housekeeping_packet.userApplication = CCSDS_USER_APP; | |
323 | housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8); |
|
405 | housekeeping_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8); | |
324 | housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK); |
|
406 | housekeeping_packet.packetID[1] = (unsigned char) (APID_TM_HK); | |
325 | housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
407 | housekeeping_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
326 | housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
408 | housekeeping_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
327 | housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); |
|
409 | housekeeping_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); | |
328 | housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); |
|
410 | housekeeping_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); | |
329 | housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
411 | housekeeping_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
330 | housekeeping_packet.serviceType = TM_TYPE_HK; |
|
412 | housekeeping_packet.serviceType = TM_TYPE_HK; | |
331 | housekeeping_packet.serviceSubType = TM_SUBTYPE_HK; |
|
413 | housekeeping_packet.serviceSubType = TM_SUBTYPE_HK; | |
332 | housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
414 | housekeeping_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
333 | housekeeping_packet.sid = SID_HK; |
|
415 | housekeeping_packet.sid = SID_HK; | |
334 |
|
416 | |||
335 | // init status word |
|
417 | // init status word | |
336 | housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0; |
|
418 | housekeeping_packet.lfr_status_word[0] = DEFAULT_STATUS_WORD_BYTE0; | |
337 | housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1; |
|
419 | housekeeping_packet.lfr_status_word[1] = DEFAULT_STATUS_WORD_BYTE1; | |
338 | // init software version |
|
420 | // init software version | |
339 | housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; |
|
421 | housekeeping_packet.lfr_sw_version[0] = SW_VERSION_N1; | |
340 | housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; |
|
422 | housekeeping_packet.lfr_sw_version[1] = SW_VERSION_N2; | |
341 | housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3; |
|
423 | housekeeping_packet.lfr_sw_version[2] = SW_VERSION_N3; | |
342 | housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4; |
|
424 | housekeeping_packet.lfr_sw_version[3] = SW_VERSION_N4; | |
343 | // init fpga version |
|
425 | // init fpga version | |
344 | parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION); |
|
426 | parameters = (unsigned char *) (REGS_ADDR_VHDL_VERSION); | |
345 | housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1 |
|
427 | housekeeping_packet.lfr_fpga_version[0] = parameters[1]; // n1 | |
346 | housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2 |
|
428 | housekeeping_packet.lfr_fpga_version[1] = parameters[2]; // n2 | |
347 | housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3 |
|
429 | housekeeping_packet.lfr_fpga_version[2] = parameters[3]; // n3 | |
348 |
|
430 | |||
349 | housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND; |
|
431 | housekeeping_packet.hk_lfr_q_sd_fifo_size = MSG_QUEUE_COUNT_SEND; | |
350 | housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV; |
|
432 | housekeeping_packet.hk_lfr_q_rv_fifo_size = MSG_QUEUE_COUNT_RECV; | |
351 | housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0; |
|
433 | housekeeping_packet.hk_lfr_q_p0_fifo_size = MSG_QUEUE_COUNT_PRC0; | |
352 | housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1; |
|
434 | housekeeping_packet.hk_lfr_q_p1_fifo_size = MSG_QUEUE_COUNT_PRC1; | |
353 | housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2; |
|
435 | housekeeping_packet.hk_lfr_q_p2_fifo_size = MSG_QUEUE_COUNT_PRC2; | |
354 | } |
|
436 | } | |
355 |
|
437 | |||
356 | void increment_seq_counter( unsigned short *packetSequenceControl ) |
|
438 | void increment_seq_counter( unsigned short *packetSequenceControl ) | |
357 | { |
|
439 | { | |
358 | /** This function increment the sequence counter passes in argument. |
|
440 | /** This function increment the sequence counter passes in argument. | |
359 | * |
|
441 | * | |
360 | * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0. |
|
442 | * The increment does not affect the grouping flag. In case of an overflow, the counter is reset to 0. | |
361 | * |
|
443 | * | |
362 | */ |
|
444 | */ | |
363 |
|
445 | |||
364 | unsigned short segmentation_grouping_flag; |
|
446 | unsigned short segmentation_grouping_flag; | |
365 | unsigned short sequence_cnt; |
|
447 | unsigned short sequence_cnt; | |
366 |
|
448 | |||
367 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6 |
|
449 | segmentation_grouping_flag = TM_PACKET_SEQ_CTRL_STANDALONE << 8; // keep bits 7 downto 6 | |
368 | sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111] |
|
450 | sequence_cnt = (*packetSequenceControl) & 0x3fff; // [0011 1111 1111 1111] | |
369 |
|
451 | |||
370 | if ( sequence_cnt < SEQ_CNT_MAX) |
|
452 | if ( sequence_cnt < SEQ_CNT_MAX) | |
371 | { |
|
453 | { | |
372 | sequence_cnt = sequence_cnt + 1; |
|
454 | sequence_cnt = sequence_cnt + 1; | |
373 | } |
|
455 | } | |
374 | else |
|
456 | else | |
375 | { |
|
457 | { | |
376 | sequence_cnt = 0; |
|
458 | sequence_cnt = 0; | |
377 | } |
|
459 | } | |
378 |
|
460 | |||
379 | *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ; |
|
461 | *packetSequenceControl = segmentation_grouping_flag | sequence_cnt ; | |
380 | } |
|
462 | } | |
381 |
|
463 | |||
382 | void getTime( unsigned char *time) |
|
464 | void getTime( unsigned char *time) | |
383 | { |
|
465 | { | |
384 | /** This function write the current local time in the time buffer passed in argument. |
|
466 | /** This function write the current local time in the time buffer passed in argument. | |
385 | * |
|
467 | * | |
386 | */ |
|
468 | */ | |
387 |
|
469 | |||
388 | time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
470 | time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
389 | time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
471 | time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
390 | time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
472 | time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
391 | time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
473 | time[3] = (unsigned char) (time_management_regs->coarse_time); | |
392 | time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
474 | time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
393 | time[5] = (unsigned char) (time_management_regs->fine_time); |
|
475 | time[5] = (unsigned char) (time_management_regs->fine_time); | |
394 | } |
|
476 | } | |
395 |
|
477 | |||
396 | unsigned long long int getTimeAsUnsignedLongLongInt( ) |
|
478 | unsigned long long int getTimeAsUnsignedLongLongInt( ) | |
397 | { |
|
479 | { | |
398 | /** This function write the current local time in the time buffer passed in argument. |
|
480 | /** This function write the current local time in the time buffer passed in argument. | |
399 | * |
|
481 | * | |
400 | */ |
|
482 | */ | |
401 | unsigned long long int time; |
|
483 | unsigned long long int time; | |
402 |
|
484 | |||
403 | time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 ) |
|
485 | time = ( (unsigned long long int) (time_management_regs->coarse_time & 0x7fffffff) << 16 ) | |
404 | + time_management_regs->fine_time; |
|
486 | + time_management_regs->fine_time; | |
405 |
|
487 | |||
406 | return time; |
|
488 | return time; | |
407 | } |
|
489 | } | |
408 |
|
490 | |||
409 | void send_dumb_hk( void ) |
|
491 | void send_dumb_hk( void ) | |
410 | { |
|
492 | { | |
411 | Packet_TM_LFR_HK_t dummy_hk_packet; |
|
493 | Packet_TM_LFR_HK_t dummy_hk_packet; | |
412 | unsigned char *parameters; |
|
494 | unsigned char *parameters; | |
413 | unsigned int i; |
|
495 | unsigned int i; | |
414 | rtems_id queue_id; |
|
496 | rtems_id queue_id; | |
415 |
|
497 | |||
416 | dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
498 | dummy_hk_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
417 | dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
499 | dummy_hk_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
418 | dummy_hk_packet.reserved = DEFAULT_RESERVED; |
|
500 | dummy_hk_packet.reserved = DEFAULT_RESERVED; | |
419 | dummy_hk_packet.userApplication = CCSDS_USER_APP; |
|
501 | dummy_hk_packet.userApplication = CCSDS_USER_APP; | |
420 | dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8); |
|
502 | dummy_hk_packet.packetID[0] = (unsigned char) (APID_TM_HK >> 8); | |
421 | dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK); |
|
503 | dummy_hk_packet.packetID[1] = (unsigned char) (APID_TM_HK); | |
422 | dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
504 | dummy_hk_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
423 | dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
505 | dummy_hk_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
424 | dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); |
|
506 | dummy_hk_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_HK >> 8); | |
425 | dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); |
|
507 | dummy_hk_packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_HK ); | |
426 | dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; |
|
508 | dummy_hk_packet.spare1_pusVersion_spare2 = DEFAULT_SPARE1_PUSVERSION_SPARE2; | |
427 | dummy_hk_packet.serviceType = TM_TYPE_HK; |
|
509 | dummy_hk_packet.serviceType = TM_TYPE_HK; | |
428 | dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK; |
|
510 | dummy_hk_packet.serviceSubType = TM_SUBTYPE_HK; | |
429 | dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
511 | dummy_hk_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
430 | dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
512 | dummy_hk_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
431 | dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
513 | dummy_hk_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
432 | dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
514 | dummy_hk_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
433 | dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
515 | dummy_hk_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
434 | dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
516 | dummy_hk_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
435 | dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
517 | dummy_hk_packet.time[5] = (unsigned char) (time_management_regs->fine_time); | |
436 | dummy_hk_packet.sid = SID_HK; |
|
518 | dummy_hk_packet.sid = SID_HK; | |
437 |
|
519 | |||
438 | // init status word |
|
520 | // init status word | |
439 | dummy_hk_packet.lfr_status_word[0] = 0xff; |
|
521 | dummy_hk_packet.lfr_status_word[0] = 0xff; | |
440 | dummy_hk_packet.lfr_status_word[1] = 0xff; |
|
522 | dummy_hk_packet.lfr_status_word[1] = 0xff; | |
441 | // init software version |
|
523 | // init software version | |
442 | dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1; |
|
524 | dummy_hk_packet.lfr_sw_version[0] = SW_VERSION_N1; | |
443 | dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2; |
|
525 | dummy_hk_packet.lfr_sw_version[1] = SW_VERSION_N2; | |
444 | dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3; |
|
526 | dummy_hk_packet.lfr_sw_version[2] = SW_VERSION_N3; | |
445 | dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4; |
|
527 | dummy_hk_packet.lfr_sw_version[3] = SW_VERSION_N4; | |
446 | // init fpga version |
|
528 | // init fpga version | |
447 | parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0); |
|
529 | parameters = (unsigned char *) (REGS_ADDR_WAVEFORM_PICKER + 0xb0); | |
448 | dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1 |
|
530 | dummy_hk_packet.lfr_fpga_version[0] = parameters[1]; // n1 | |
449 | dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2 |
|
531 | dummy_hk_packet.lfr_fpga_version[1] = parameters[2]; // n2 | |
450 | dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3 |
|
532 | dummy_hk_packet.lfr_fpga_version[2] = parameters[3]; // n3 | |
451 |
|
533 | |||
452 | parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load; |
|
534 | parameters = (unsigned char *) &dummy_hk_packet.hk_lfr_cpu_load; | |
453 |
|
535 | |||
454 | for (i=0; i<100; i++) |
|
536 | for (i=0; i<100; i++) | |
455 | { |
|
537 | { | |
456 | parameters[i] = 0xff; |
|
538 | parameters[i] = 0xff; | |
457 | } |
|
539 | } | |
458 |
|
540 | |||
459 | get_message_queue_id_send( &queue_id ); |
|
541 | get_message_queue_id_send( &queue_id ); | |
460 |
|
542 | |||
461 | rtems_message_queue_send( queue_id, &dummy_hk_packet, |
|
543 | rtems_message_queue_send( queue_id, &dummy_hk_packet, | |
462 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
544 | PACKET_LENGTH_HK + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
463 | } |
|
545 | } | |
464 |
|
546 | |||
465 | void get_temperatures( unsigned char *temperatures ) |
|
547 | void get_temperatures( unsigned char *temperatures ) | |
466 | { |
|
548 | { | |
467 | unsigned char* temp_scm_ptr; |
|
549 | unsigned char* temp_scm_ptr; | |
468 | unsigned char* temp_pcb_ptr; |
|
550 | unsigned char* temp_pcb_ptr; | |
469 | unsigned char* temp_fpga_ptr; |
|
551 | unsigned char* temp_fpga_ptr; | |
470 |
|
552 | |||
471 | // SEL1 SEL0 |
|
553 | // SEL1 SEL0 | |
472 | // 0 0 => PCB |
|
554 | // 0 0 => PCB | |
473 | // 0 1 => FPGA |
|
555 | // 0 1 => FPGA | |
474 | // 1 0 => SCM |
|
556 | // 1 0 => SCM | |
475 |
|
557 | |||
476 | temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm; |
|
558 | temp_scm_ptr = (unsigned char *) &time_management_regs->temp_scm; | |
477 | temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb; |
|
559 | temp_pcb_ptr = (unsigned char *) &time_management_regs->temp_pcb; | |
478 | temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga; |
|
560 | temp_fpga_ptr = (unsigned char *) &time_management_regs->temp_fpga; | |
479 |
|
561 | |||
480 | temperatures[0] = temp_scm_ptr[2]; |
|
562 | temperatures[0] = temp_scm_ptr[2]; | |
481 | temperatures[1] = temp_scm_ptr[3]; |
|
563 | temperatures[1] = temp_scm_ptr[3]; | |
482 | temperatures[2] = temp_pcb_ptr[2]; |
|
564 | temperatures[2] = temp_pcb_ptr[2]; | |
483 | temperatures[3] = temp_pcb_ptr[3]; |
|
565 | temperatures[3] = temp_pcb_ptr[3]; | |
484 | temperatures[4] = temp_fpga_ptr[2]; |
|
566 | temperatures[4] = temp_fpga_ptr[2]; | |
485 | temperatures[5] = temp_fpga_ptr[3]; |
|
567 | temperatures[5] = temp_fpga_ptr[3]; | |
486 | } |
|
568 | } | |
487 |
|
569 | |||
488 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ) |
|
570 | void get_v_e1_e2_f3( unsigned char *spacecraft_potential ) | |
489 | { |
|
571 | { | |
490 | unsigned char* v_ptr; |
|
572 | unsigned char* v_ptr; | |
491 | unsigned char* e1_ptr; |
|
573 | unsigned char* e1_ptr; | |
492 | unsigned char* e2_ptr; |
|
574 | unsigned char* e2_ptr; | |
493 |
|
575 | |||
494 | v_ptr = (unsigned char *) &waveform_picker_regs->v; |
|
576 | v_ptr = (unsigned char *) &waveform_picker_regs->v; | |
495 | e1_ptr = (unsigned char *) &waveform_picker_regs->e1; |
|
577 | e1_ptr = (unsigned char *) &waveform_picker_regs->e1; | |
496 | e2_ptr = (unsigned char *) &waveform_picker_regs->e2; |
|
578 | e2_ptr = (unsigned char *) &waveform_picker_regs->e2; | |
497 |
|
579 | |||
498 | spacecraft_potential[0] = v_ptr[2]; |
|
580 | spacecraft_potential[0] = v_ptr[2]; | |
499 | spacecraft_potential[1] = v_ptr[3]; |
|
581 | spacecraft_potential[1] = v_ptr[3]; | |
500 | spacecraft_potential[2] = e1_ptr[2]; |
|
582 | spacecraft_potential[2] = e1_ptr[2]; | |
501 | spacecraft_potential[3] = e1_ptr[3]; |
|
583 | spacecraft_potential[3] = e1_ptr[3]; | |
502 | spacecraft_potential[4] = e2_ptr[2]; |
|
584 | spacecraft_potential[4] = e2_ptr[2]; | |
503 | spacecraft_potential[5] = e2_ptr[3]; |
|
585 | spacecraft_potential[5] = e2_ptr[3]; | |
504 | } |
|
586 | } | |
505 |
|
587 | |||
506 | void get_cpu_load( unsigned char *resource_statistics ) |
|
588 | void get_cpu_load( unsigned char *resource_statistics ) | |
507 | { |
|
589 | { | |
508 | unsigned char cpu_load; |
|
590 | unsigned char cpu_load; | |
509 |
|
591 | |||
510 | cpu_load = lfr_rtems_cpu_usage_report(); |
|
592 | cpu_load = lfr_rtems_cpu_usage_report(); | |
511 |
|
593 | |||
512 | // HK_LFR_CPU_LOAD |
|
594 | // HK_LFR_CPU_LOAD | |
513 | resource_statistics[0] = cpu_load; |
|
595 | resource_statistics[0] = cpu_load; | |
514 |
|
596 | |||
515 | // HK_LFR_CPU_LOAD_MAX |
|
597 | // HK_LFR_CPU_LOAD_MAX | |
516 | if (cpu_load > resource_statistics[1]) |
|
598 | if (cpu_load > resource_statistics[1]) | |
517 | { |
|
599 | { | |
518 | resource_statistics[1] = cpu_load; |
|
600 | resource_statistics[1] = cpu_load; | |
519 | } |
|
601 | } | |
520 |
|
602 | |||
521 | // CPU_LOAD_AVE |
|
603 | // CPU_LOAD_AVE | |
522 | resource_statistics[2] = 0; |
|
604 | resource_statistics[2] = 0; | |
523 |
|
605 | |||
524 | #ifndef PRINT_TASK_STATISTICS |
|
606 | #ifndef PRINT_TASK_STATISTICS | |
525 | rtems_cpu_usage_reset(); |
|
607 | rtems_cpu_usage_reset(); | |
526 | #endif |
|
608 | #endif | |
527 |
|
609 | |||
528 | } |
|
610 | } | |
529 |
|
611 | |||
530 | void set_hk_lfr_sc_potential_flag( bool state ) |
|
612 | void set_hk_lfr_sc_potential_flag( bool state ) | |
531 | { |
|
613 | { | |
532 | if (state == true) |
|
614 | if (state == true) | |
533 | { |
|
615 | { | |
534 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x40; // [0100 0000] |
|
616 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x40; // [0100 0000] | |
535 | } |
|
617 | } | |
536 | else |
|
618 | else | |
537 | { |
|
619 | { | |
538 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xbf; // [1011 1111] |
|
620 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xbf; // [1011 1111] | |
539 | } |
|
621 | } | |
540 | } |
|
622 | } | |
541 |
|
623 | |||
542 | void set_hk_lfr_mag_fields_flag( bool state ) |
|
624 | void set_hk_lfr_mag_fields_flag( bool state ) | |
543 | { |
|
625 | { | |
544 | if (state == true) |
|
626 | if (state == true) | |
545 | { |
|
627 | { | |
546 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x20; // [0010 0000] |
|
628 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x20; // [0010 0000] | |
547 | } |
|
629 | } | |
548 | else |
|
630 | else | |
549 | { |
|
631 | { | |
550 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xd7; // [1101 1111] |
|
632 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xd7; // [1101 1111] | |
551 | } |
|
633 | } | |
552 | } |
|
634 | } | |
553 |
|
635 | |||
554 | void set_hk_lfr_calib_enable( bool state ) |
|
636 | void set_hk_lfr_calib_enable( bool state ) | |
555 | { |
|
637 | { | |
556 | if (state == true) |
|
638 | if (state == true) | |
557 | { |
|
639 | { | |
558 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x08; // [0000 1000] |
|
640 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | 0x08; // [0000 1000] | |
559 | } |
|
641 | } | |
560 | else |
|
642 | else | |
561 | { |
|
643 | { | |
562 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf7; // [1111 0111] |
|
644 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] & 0xf7; // [1111 0111] | |
563 | } |
|
645 | } | |
564 | } |
|
646 | } | |
565 |
|
647 | |||
566 | void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ) |
|
648 | void set_hk_lfr_reset_cause( enum lfr_reset_cause_t lfr_reset_cause ) | |
567 | { |
|
649 | { | |
568 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] |
|
650 | housekeeping_packet.lfr_status_word[1] = housekeeping_packet.lfr_status_word[1] | |
569 | | (lfr_reset_cause & 0x07 ); // [0000 0111] |
|
651 | | (lfr_reset_cause & 0x07 ); // [0000 0111] | |
570 | } |
|
652 | } |
@@ -1,689 +1,640 | |||||
1 | /** Functions related to data processing. |
|
1 | /** Functions related to data processing. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. |
|
6 | * These function are related to data processing, i.e. spectral matrices averaging and basic parameters computation. | |
7 | * |
|
7 | * | |
8 | */ |
|
8 | */ | |
9 |
|
9 | |||
10 | #include "fsw_processing.h" |
|
10 | #include "fsw_processing.h" | |
11 | #include "fsw_processing_globals.c" |
|
11 | #include "fsw_processing_globals.c" | |
12 | #include "fsw_init.h" |
|
12 | #include "fsw_init.h" | |
13 |
|
13 | |||
14 | unsigned int nb_sm_f0; |
|
14 | unsigned int nb_sm_f0; | |
15 | unsigned int nb_sm_f0_aux_f1; |
|
15 | unsigned int nb_sm_f0_aux_f1; | |
16 | unsigned int nb_sm_f1; |
|
16 | unsigned int nb_sm_f1; | |
17 | unsigned int nb_sm_f0_aux_f2; |
|
17 | unsigned int nb_sm_f0_aux_f2; | |
18 |
|
18 | |||
19 | //************************ |
|
19 | //************************ | |
20 | // spectral matrices rings |
|
20 | // spectral matrices rings | |
21 | ring_node sm_ring_f0[ NB_RING_NODES_SM_F0 ]; |
|
21 | ring_node sm_ring_f0[ NB_RING_NODES_SM_F0 ]; | |
22 | ring_node sm_ring_f1[ NB_RING_NODES_SM_F1 ]; |
|
22 | ring_node sm_ring_f1[ NB_RING_NODES_SM_F1 ]; | |
23 | ring_node sm_ring_f2[ NB_RING_NODES_SM_F2 ]; |
|
23 | ring_node sm_ring_f2[ NB_RING_NODES_SM_F2 ]; | |
24 | ring_node *current_ring_node_sm_f0; |
|
24 | ring_node *current_ring_node_sm_f0; | |
25 | ring_node *current_ring_node_sm_f1; |
|
25 | ring_node *current_ring_node_sm_f1; | |
26 | ring_node *current_ring_node_sm_f2; |
|
26 | ring_node *current_ring_node_sm_f2; | |
27 | ring_node *ring_node_for_averaging_sm_f0; |
|
27 | ring_node *ring_node_for_averaging_sm_f0; | |
28 | ring_node *ring_node_for_averaging_sm_f1; |
|
28 | ring_node *ring_node_for_averaging_sm_f1; | |
29 | ring_node *ring_node_for_averaging_sm_f2; |
|
29 | ring_node *ring_node_for_averaging_sm_f2; | |
30 |
|
30 | |||
31 | // |
|
31 | // | |
32 | ring_node * getRingNodeForAveraging( unsigned char frequencyChannel) |
|
32 | ring_node * getRingNodeForAveraging( unsigned char frequencyChannel) | |
33 | { |
|
33 | { | |
34 | ring_node *node; |
|
34 | ring_node *node; | |
35 |
|
35 | |||
36 | node = NULL; |
|
36 | node = NULL; | |
37 | switch ( frequencyChannel ) { |
|
37 | switch ( frequencyChannel ) { | |
38 | case 0: |
|
38 | case 0: | |
39 | node = ring_node_for_averaging_sm_f0; |
|
39 | node = ring_node_for_averaging_sm_f0; | |
40 | break; |
|
40 | break; | |
41 | case 1: |
|
41 | case 1: | |
42 | node = ring_node_for_averaging_sm_f1; |
|
42 | node = ring_node_for_averaging_sm_f1; | |
43 | break; |
|
43 | break; | |
44 | case 2: |
|
44 | case 2: | |
45 | node = ring_node_for_averaging_sm_f2; |
|
45 | node = ring_node_for_averaging_sm_f2; | |
46 | break; |
|
46 | break; | |
47 | default: |
|
47 | default: | |
48 | break; |
|
48 | break; | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
51 | return node; |
|
51 | return node; | |
52 | } |
|
52 | } | |
53 |
|
53 | |||
54 | //*********************************************************** |
|
54 | //*********************************************************** | |
55 | // Interrupt Service Routine for spectral matrices processing |
|
55 | // Interrupt Service Routine for spectral matrices processing | |
56 |
|
56 | |||
57 | void spectral_matrices_isr_f0( unsigned char statusReg ) |
|
57 | void spectral_matrices_isr_f0( unsigned char statusReg ) | |
58 | { |
|
58 | { | |
59 | unsigned char status; |
|
59 | unsigned char status; | |
60 | rtems_status_code status_code; |
|
60 | rtems_status_code status_code; | |
61 | ring_node *full_ring_node; |
|
61 | ring_node *full_ring_node; | |
62 |
|
62 | |||
63 | status = statusReg & 0x03; // [0011] get the status_ready_matrix_f0_x bits |
|
63 | status = statusReg & 0x03; // [0011] get the status_ready_matrix_f0_x bits | |
64 |
|
64 | |||
65 | switch(status) |
|
65 | switch(status) | |
66 | { |
|
66 | { | |
67 | case 0: |
|
67 | case 0: | |
68 | break; |
|
68 | break; | |
69 | case 3: |
|
69 | case 3: | |
70 | // UNEXPECTED VALUE |
|
70 | // UNEXPECTED VALUE | |
71 | spectral_matrix_regs->status = 0x03; // [0011] |
|
71 | spectral_matrix_regs->status = 0x03; // [0011] | |
72 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); |
|
72 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); | |
73 | break; |
|
73 | break; | |
74 | case 1: |
|
74 | case 1: | |
75 | full_ring_node = current_ring_node_sm_f0->previous; |
|
75 | full_ring_node = current_ring_node_sm_f0->previous; | |
76 | full_ring_node->coarseTime = spectral_matrix_regs->f0_0_coarse_time; |
|
76 | full_ring_node->coarseTime = spectral_matrix_regs->f0_0_coarse_time; | |
77 | full_ring_node->fineTime = spectral_matrix_regs->f0_0_fine_time; |
|
77 | full_ring_node->fineTime = spectral_matrix_regs->f0_0_fine_time; | |
78 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; |
|
78 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; | |
79 | spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address; |
|
79 | spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->buffer_address; | |
80 | // if there are enough ring nodes ready, wake up an AVFx task |
|
80 | // if there are enough ring nodes ready, wake up an AVFx task | |
81 | nb_sm_f0 = nb_sm_f0 + 1; |
|
81 | nb_sm_f0 = nb_sm_f0 + 1; | |
82 | if (nb_sm_f0 == NB_SM_BEFORE_AVF0) |
|
82 | if (nb_sm_f0 == NB_SM_BEFORE_AVF0) | |
83 | { |
|
83 | { | |
84 | ring_node_for_averaging_sm_f0 = full_ring_node; |
|
84 | ring_node_for_averaging_sm_f0 = full_ring_node; | |
85 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
85 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
86 | { |
|
86 | { | |
87 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
87 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
88 | } |
|
88 | } | |
89 | nb_sm_f0 = 0; |
|
89 | nb_sm_f0 = 0; | |
90 | } |
|
90 | } | |
91 | spectral_matrix_regs->status = 0x01; // [0000 0001] |
|
91 | spectral_matrix_regs->status = 0x01; // [0000 0001] | |
92 | break; |
|
92 | break; | |
93 | case 2: |
|
93 | case 2: | |
94 | full_ring_node = current_ring_node_sm_f0->previous; |
|
94 | full_ring_node = current_ring_node_sm_f0->previous; | |
95 | full_ring_node->coarseTime = spectral_matrix_regs->f0_1_coarse_time; |
|
95 | full_ring_node->coarseTime = spectral_matrix_regs->f0_1_coarse_time; | |
96 | full_ring_node->fineTime = spectral_matrix_regs->f0_1_fine_time; |
|
96 | full_ring_node->fineTime = spectral_matrix_regs->f0_1_fine_time; | |
97 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; |
|
97 | current_ring_node_sm_f0 = current_ring_node_sm_f0->next; | |
98 | spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; |
|
98 | spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; | |
99 | // if there are enough ring nodes ready, wake up an AVFx task |
|
99 | // if there are enough ring nodes ready, wake up an AVFx task | |
100 | nb_sm_f0 = nb_sm_f0 + 1; |
|
100 | nb_sm_f0 = nb_sm_f0 + 1; | |
101 | if (nb_sm_f0 == NB_SM_BEFORE_AVF0) |
|
101 | if (nb_sm_f0 == NB_SM_BEFORE_AVF0) | |
102 | { |
|
102 | { | |
103 | ring_node_for_averaging_sm_f0 = full_ring_node; |
|
103 | ring_node_for_averaging_sm_f0 = full_ring_node; | |
104 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
104 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
105 | { |
|
105 | { | |
106 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
106 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
107 | } |
|
107 | } | |
108 | nb_sm_f0 = 0; |
|
108 | nb_sm_f0 = 0; | |
109 | } |
|
109 | } | |
110 | spectral_matrix_regs->status = 0x02; // [0000 0010] |
|
110 | spectral_matrix_regs->status = 0x02; // [0000 0010] | |
111 | break; |
|
111 | break; | |
112 | } |
|
112 | } | |
113 | } |
|
113 | } | |
114 |
|
114 | |||
115 | void spectral_matrices_isr_f1( unsigned char statusReg ) |
|
115 | void spectral_matrices_isr_f1( unsigned char statusReg ) | |
116 | { |
|
116 | { | |
117 | rtems_status_code status_code; |
|
117 | rtems_status_code status_code; | |
118 | unsigned char status; |
|
118 | unsigned char status; | |
119 | ring_node *full_ring_node; |
|
119 | ring_node *full_ring_node; | |
120 |
|
120 | |||
121 | status = (statusReg & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits |
|
121 | status = (statusReg & 0x0c) >> 2; // [1100] get the status_ready_matrix_f0_x bits | |
122 |
|
122 | |||
123 | switch(status) |
|
123 | switch(status) | |
124 | { |
|
124 | { | |
125 | case 0: |
|
125 | case 0: | |
126 | break; |
|
126 | break; | |
127 | case 3: |
|
127 | case 3: | |
128 | // UNEXPECTED VALUE |
|
128 | // UNEXPECTED VALUE | |
129 | spectral_matrix_regs->status = 0xc0; // [1100] |
|
129 | spectral_matrix_regs->status = 0xc0; // [1100] | |
130 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); |
|
130 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); | |
131 | break; |
|
131 | break; | |
132 | case 1: |
|
132 | case 1: | |
133 | full_ring_node = current_ring_node_sm_f1->previous; |
|
133 | full_ring_node = current_ring_node_sm_f1->previous; | |
134 | full_ring_node->coarseTime = spectral_matrix_regs->f1_0_coarse_time; |
|
134 | full_ring_node->coarseTime = spectral_matrix_regs->f1_0_coarse_time; | |
135 | full_ring_node->fineTime = spectral_matrix_regs->f1_0_fine_time; |
|
135 | full_ring_node->fineTime = spectral_matrix_regs->f1_0_fine_time; | |
136 | current_ring_node_sm_f1 = current_ring_node_sm_f1->next; |
|
136 | current_ring_node_sm_f1 = current_ring_node_sm_f1->next; | |
137 | spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address; |
|
137 | spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->buffer_address; | |
138 | // if there are enough ring nodes ready, wake up an AVFx task |
|
138 | // if there are enough ring nodes ready, wake up an AVFx task | |
139 | nb_sm_f1 = nb_sm_f1 + 1; |
|
139 | nb_sm_f1 = nb_sm_f1 + 1; | |
140 | if (nb_sm_f1 == NB_SM_BEFORE_AVF1) |
|
140 | if (nb_sm_f1 == NB_SM_BEFORE_AVF1) | |
141 | { |
|
141 | { | |
142 | ring_node_for_averaging_sm_f1 = full_ring_node; |
|
142 | ring_node_for_averaging_sm_f1 = full_ring_node; | |
143 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
143 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
144 | { |
|
144 | { | |
145 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
145 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
146 | } |
|
146 | } | |
147 | nb_sm_f1 = 0; |
|
147 | nb_sm_f1 = 0; | |
148 | } |
|
148 | } | |
149 | spectral_matrix_regs->status = 0x04; // [0000 0100] |
|
149 | spectral_matrix_regs->status = 0x04; // [0000 0100] | |
150 | break; |
|
150 | break; | |
151 | case 2: |
|
151 | case 2: | |
152 | full_ring_node = current_ring_node_sm_f1->previous; |
|
152 | full_ring_node = current_ring_node_sm_f1->previous; | |
153 | full_ring_node->coarseTime = spectral_matrix_regs->f1_1_coarse_time; |
|
153 | full_ring_node->coarseTime = spectral_matrix_regs->f1_1_coarse_time; | |
154 | full_ring_node->fineTime = spectral_matrix_regs->f1_1_fine_time; |
|
154 | full_ring_node->fineTime = spectral_matrix_regs->f1_1_fine_time; | |
155 | current_ring_node_sm_f1 = current_ring_node_sm_f1->next; |
|
155 | current_ring_node_sm_f1 = current_ring_node_sm_f1->next; | |
156 | spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; |
|
156 | spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; | |
157 | // if there are enough ring nodes ready, wake up an AVFx task |
|
157 | // if there are enough ring nodes ready, wake up an AVFx task | |
158 | nb_sm_f1 = nb_sm_f1 + 1; |
|
158 | nb_sm_f1 = nb_sm_f1 + 1; | |
159 | if (nb_sm_f1 == NB_SM_BEFORE_AVF1) |
|
159 | if (nb_sm_f1 == NB_SM_BEFORE_AVF1) | |
160 | { |
|
160 | { | |
161 | ring_node_for_averaging_sm_f1 = full_ring_node; |
|
161 | ring_node_for_averaging_sm_f1 = full_ring_node; | |
162 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
162 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
163 | { |
|
163 | { | |
164 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
164 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
165 | } |
|
165 | } | |
166 | nb_sm_f1 = 0; |
|
166 | nb_sm_f1 = 0; | |
167 | } |
|
167 | } | |
168 | spectral_matrix_regs->status = 0x08; // [1000 0000] |
|
168 | spectral_matrix_regs->status = 0x08; // [1000 0000] | |
169 | break; |
|
169 | break; | |
170 | } |
|
170 | } | |
171 | } |
|
171 | } | |
172 |
|
172 | |||
173 | void spectral_matrices_isr_f2( unsigned char statusReg ) |
|
173 | void spectral_matrices_isr_f2( unsigned char statusReg ) | |
174 | { |
|
174 | { | |
175 | unsigned char status; |
|
175 | unsigned char status; | |
176 | rtems_status_code status_code; |
|
176 | rtems_status_code status_code; | |
177 |
|
177 | |||
178 | status = (statusReg & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits |
|
178 | status = (statusReg & 0x30) >> 4; // [0011 0000] get the status_ready_matrix_f0_x bits | |
179 |
|
179 | |||
180 | switch(status) |
|
180 | switch(status) | |
181 | { |
|
181 | { | |
182 | case 0: |
|
182 | case 0: | |
183 | break; |
|
183 | break; | |
184 | case 3: |
|
184 | case 3: | |
185 | // UNEXPECTED VALUE |
|
185 | // UNEXPECTED VALUE | |
186 | spectral_matrix_regs->status = 0x30; // [0011 0000] |
|
186 | spectral_matrix_regs->status = 0x30; // [0011 0000] | |
187 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); |
|
187 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_11 ); | |
188 | break; |
|
188 | break; | |
189 | case 1: |
|
189 | case 1: | |
190 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous; |
|
190 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous; | |
191 | current_ring_node_sm_f2 = current_ring_node_sm_f2->next; |
|
191 | current_ring_node_sm_f2 = current_ring_node_sm_f2->next; | |
192 | ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time; |
|
192 | ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_0_coarse_time; | |
193 | ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time; |
|
193 | ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_0_fine_time; | |
194 | spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address; |
|
194 | spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->buffer_address; | |
195 | spectral_matrix_regs->status = 0x10; // [0001 0000] |
|
195 | spectral_matrix_regs->status = 0x10; // [0001 0000] | |
196 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
196 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
197 | { |
|
197 | { | |
198 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
198 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
199 | } |
|
199 | } | |
200 | break; |
|
200 | break; | |
201 | case 2: |
|
201 | case 2: | |
202 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous; |
|
202 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2->previous; | |
203 | current_ring_node_sm_f2 = current_ring_node_sm_f2->next; |
|
203 | current_ring_node_sm_f2 = current_ring_node_sm_f2->next; | |
204 | ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time; |
|
204 | ring_node_for_averaging_sm_f2->coarseTime = spectral_matrix_regs->f2_1_coarse_time; | |
205 | ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time; |
|
205 | ring_node_for_averaging_sm_f2->fineTime = spectral_matrix_regs->f2_1_fine_time; | |
206 | spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address; |
|
206 | spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address; | |
207 | spectral_matrix_regs->status = 0x20; // [0010 0000] |
|
207 | spectral_matrix_regs->status = 0x20; // [0010 0000] | |
208 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
208 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) | |
209 | { |
|
209 | { | |
210 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
210 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); | |
211 | } |
|
211 | } | |
212 | break; |
|
212 | break; | |
213 | } |
|
213 | } | |
214 | } |
|
214 | } | |
215 |
|
215 | |||
216 | void spectral_matrix_isr_error_handler( unsigned char statusReg ) |
|
216 | void spectral_matrix_isr_error_handler( unsigned char statusReg ) | |
217 | { |
|
217 | { | |
218 | rtems_status_code status_code; |
|
218 | rtems_status_code status_code; | |
219 |
|
219 | |||
220 | if (statusReg & 0x7c0) // [0111 1100 0000] |
|
220 | if (statusReg & 0x7c0) // [0111 1100 0000] | |
221 | { |
|
221 | { | |
222 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 ); |
|
222 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_8 ); | |
223 | } |
|
223 | } | |
224 |
|
224 | |||
225 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0x7c0; |
|
225 | spectral_matrix_regs->status = spectral_matrix_regs->status & 0x7c0; | |
226 | } |
|
226 | } | |
227 |
|
227 | |||
228 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ) |
|
228 | rtems_isr spectral_matrices_isr( rtems_vector_number vector ) | |
229 | { |
|
229 | { | |
230 | // STATUS REGISTER |
|
230 | // STATUS REGISTER | |
231 | // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0) |
|
231 | // input_fifo_write(2) *** input_fifo_write(1) *** input_fifo_write(0) | |
232 | // 10 9 8 |
|
232 | // 10 9 8 | |
233 | // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0 |
|
233 | // buffer_full ** bad_component_err ** f2_1 ** f2_0 ** f1_1 ** f1_0 ** f0_1 ** f0_0 | |
234 | // 7 6 5 4 3 2 1 0 |
|
234 | // 7 6 5 4 3 2 1 0 | |
235 |
|
235 | |||
236 | unsigned char statusReg; |
|
236 | unsigned char statusReg; | |
237 |
|
237 | |||
238 | statusReg = spectral_matrix_regs->status; |
|
238 | statusReg = spectral_matrix_regs->status; | |
239 |
|
239 | |||
240 | spectral_matrices_isr_f0( statusReg ); |
|
240 | spectral_matrices_isr_f0( statusReg ); | |
241 |
|
241 | |||
242 | spectral_matrices_isr_f1( statusReg ); |
|
242 | spectral_matrices_isr_f1( statusReg ); | |
243 |
|
243 | |||
244 | spectral_matrices_isr_f2( statusReg ); |
|
244 | spectral_matrices_isr_f2( statusReg ); | |
245 |
|
245 | |||
246 | spectral_matrix_isr_error_handler( statusReg ); |
|
246 | spectral_matrix_isr_error_handler( statusReg ); | |
247 | } |
|
247 | } | |
248 |
|
248 | |||
249 | rtems_isr spectral_matrices_isr_simu( rtems_vector_number vector ) |
|
|||
250 | { |
|
|||
251 | rtems_status_code status_code; |
|
|||
252 |
|
||||
253 | //*** |
|
|||
254 | // F0 |
|
|||
255 | nb_sm_f0 = nb_sm_f0 + 1; |
|
|||
256 | if (nb_sm_f0 == NB_SM_BEFORE_AVF0 ) |
|
|||
257 | { |
|
|||
258 | ring_node_for_averaging_sm_f0 = current_ring_node_sm_f0; |
|
|||
259 | if (rtems_event_send( Task_id[TASKID_AVF0], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
|||
260 | { |
|
|||
261 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
|||
262 | } |
|
|||
263 | nb_sm_f0 = 0; |
|
|||
264 | } |
|
|||
265 |
|
||||
266 | //*** |
|
|||
267 | // F1 |
|
|||
268 | nb_sm_f0_aux_f1 = nb_sm_f0_aux_f1 + 1; |
|
|||
269 | if (nb_sm_f0_aux_f1 == 6) |
|
|||
270 | { |
|
|||
271 | nb_sm_f0_aux_f1 = 0; |
|
|||
272 | nb_sm_f1 = nb_sm_f1 + 1; |
|
|||
273 | } |
|
|||
274 | if (nb_sm_f1 == NB_SM_BEFORE_AVF1 ) |
|
|||
275 | { |
|
|||
276 | ring_node_for_averaging_sm_f1 = current_ring_node_sm_f1; |
|
|||
277 | if (rtems_event_send( Task_id[TASKID_AVF1], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
|||
278 | { |
|
|||
279 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
|||
280 | } |
|
|||
281 | nb_sm_f1 = 0; |
|
|||
282 | } |
|
|||
283 |
|
||||
284 | //*** |
|
|||
285 | // F2 |
|
|||
286 | nb_sm_f0_aux_f2 = nb_sm_f0_aux_f2 + 1; |
|
|||
287 | if (nb_sm_f0_aux_f2 == 96) |
|
|||
288 | { |
|
|||
289 | nb_sm_f0_aux_f2 = 0; |
|
|||
290 | ring_node_for_averaging_sm_f2 = current_ring_node_sm_f2; |
|
|||
291 | if (rtems_event_send( Task_id[TASKID_AVF2], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) |
|
|||
292 | { |
|
|||
293 | status_code = rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_3 ); |
|
|||
294 | } |
|
|||
295 | } |
|
|||
296 | } |
|
|||
297 |
|
||||
298 | //****************** |
|
249 | //****************** | |
299 | // Spectral Matrices |
|
250 | // Spectral Matrices | |
300 |
|
251 | |||
301 | void reset_nb_sm( void ) |
|
252 | void reset_nb_sm( void ) | |
302 | { |
|
253 | { | |
303 | nb_sm_f0 = 0; |
|
254 | nb_sm_f0 = 0; | |
304 | nb_sm_f0_aux_f1 = 0; |
|
255 | nb_sm_f0_aux_f1 = 0; | |
305 | nb_sm_f0_aux_f2 = 0; |
|
256 | nb_sm_f0_aux_f2 = 0; | |
306 |
|
257 | |||
307 | nb_sm_f1 = 0; |
|
258 | nb_sm_f1 = 0; | |
308 | } |
|
259 | } | |
309 |
|
260 | |||
310 | void SM_init_rings( void ) |
|
261 | void SM_init_rings( void ) | |
311 | { |
|
262 | { | |
312 | init_ring( sm_ring_f0, NB_RING_NODES_SM_F0, sm_f0, TOTAL_SIZE_SM ); |
|
263 | init_ring( sm_ring_f0, NB_RING_NODES_SM_F0, sm_f0, TOTAL_SIZE_SM ); | |
313 | init_ring( sm_ring_f1, NB_RING_NODES_SM_F1, sm_f1, TOTAL_SIZE_SM ); |
|
264 | init_ring( sm_ring_f1, NB_RING_NODES_SM_F1, sm_f1, TOTAL_SIZE_SM ); | |
314 | init_ring( sm_ring_f2, NB_RING_NODES_SM_F2, sm_f2, TOTAL_SIZE_SM ); |
|
265 | init_ring( sm_ring_f2, NB_RING_NODES_SM_F2, sm_f2, TOTAL_SIZE_SM ); | |
315 |
|
266 | |||
316 | DEBUG_PRINTF1("sm_ring_f0 @%x\n", (unsigned int) sm_ring_f0) |
|
267 | DEBUG_PRINTF1("sm_ring_f0 @%x\n", (unsigned int) sm_ring_f0) | |
317 | DEBUG_PRINTF1("sm_ring_f1 @%x\n", (unsigned int) sm_ring_f1) |
|
268 | DEBUG_PRINTF1("sm_ring_f1 @%x\n", (unsigned int) sm_ring_f1) | |
318 | DEBUG_PRINTF1("sm_ring_f2 @%x\n", (unsigned int) sm_ring_f2) |
|
269 | DEBUG_PRINTF1("sm_ring_f2 @%x\n", (unsigned int) sm_ring_f2) | |
319 | DEBUG_PRINTF1("sm_f0 @%x\n", (unsigned int) sm_f0) |
|
270 | DEBUG_PRINTF1("sm_f0 @%x\n", (unsigned int) sm_f0) | |
320 | DEBUG_PRINTF1("sm_f1 @%x\n", (unsigned int) sm_f1) |
|
271 | DEBUG_PRINTF1("sm_f1 @%x\n", (unsigned int) sm_f1) | |
321 | DEBUG_PRINTF1("sm_f2 @%x\n", (unsigned int) sm_f2) |
|
272 | DEBUG_PRINTF1("sm_f2 @%x\n", (unsigned int) sm_f2) | |
322 | } |
|
273 | } | |
323 |
|
274 | |||
324 | void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes ) |
|
275 | void ASM_generic_init_ring( ring_node_asm *ring, unsigned char nbNodes ) | |
325 | { |
|
276 | { | |
326 | unsigned char i; |
|
277 | unsigned char i; | |
327 |
|
278 | |||
328 | ring[ nbNodes - 1 ].next |
|
279 | ring[ nbNodes - 1 ].next | |
329 | = (ring_node_asm*) &ring[ 0 ]; |
|
280 | = (ring_node_asm*) &ring[ 0 ]; | |
330 |
|
281 | |||
331 | for(i=0; i<nbNodes-1; i++) |
|
282 | for(i=0; i<nbNodes-1; i++) | |
332 | { |
|
283 | { | |
333 | ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ]; |
|
284 | ring[ i ].next = (ring_node_asm*) &ring[ i + 1 ]; | |
334 | } |
|
285 | } | |
335 | } |
|
286 | } | |
336 |
|
287 | |||
337 | void SM_reset_current_ring_nodes( void ) |
|
288 | void SM_reset_current_ring_nodes( void ) | |
338 | { |
|
289 | { | |
339 | current_ring_node_sm_f0 = sm_ring_f0[0].next; |
|
290 | current_ring_node_sm_f0 = sm_ring_f0[0].next; | |
340 | current_ring_node_sm_f1 = sm_ring_f1[0].next; |
|
291 | current_ring_node_sm_f1 = sm_ring_f1[0].next; | |
341 | current_ring_node_sm_f2 = sm_ring_f2[0].next; |
|
292 | current_ring_node_sm_f2 = sm_ring_f2[0].next; | |
342 |
|
293 | |||
343 | ring_node_for_averaging_sm_f0 = NULL; |
|
294 | ring_node_for_averaging_sm_f0 = NULL; | |
344 | ring_node_for_averaging_sm_f1 = NULL; |
|
295 | ring_node_for_averaging_sm_f1 = NULL; | |
345 | ring_node_for_averaging_sm_f2 = NULL; |
|
296 | ring_node_for_averaging_sm_f2 = NULL; | |
346 | } |
|
297 | } | |
347 |
|
298 | |||
348 | //***************** |
|
299 | //***************** | |
349 | // Basic Parameters |
|
300 | // Basic Parameters | |
350 |
|
301 | |||
351 | void BP_init_header( bp_packet *packet, |
|
302 | void BP_init_header( bp_packet *packet, | |
352 | unsigned int apid, unsigned char sid, |
|
303 | unsigned int apid, unsigned char sid, | |
353 | unsigned int packetLength, unsigned char blkNr ) |
|
304 | unsigned int packetLength, unsigned char blkNr ) | |
354 | { |
|
305 | { | |
355 | packet->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
306 | packet->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
356 | packet->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
307 | packet->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
357 | packet->reserved = 0x00; |
|
308 | packet->reserved = 0x00; | |
358 | packet->userApplication = CCSDS_USER_APP; |
|
309 | packet->userApplication = CCSDS_USER_APP; | |
359 | packet->packetID[0] = (unsigned char) (apid >> 8); |
|
310 | packet->packetID[0] = (unsigned char) (apid >> 8); | |
360 | packet->packetID[1] = (unsigned char) (apid); |
|
311 | packet->packetID[1] = (unsigned char) (apid); | |
361 | packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
312 | packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
362 | packet->packetSequenceControl[1] = 0x00; |
|
313 | packet->packetSequenceControl[1] = 0x00; | |
363 | packet->packetLength[0] = (unsigned char) (packetLength >> 8); |
|
314 | packet->packetLength[0] = (unsigned char) (packetLength >> 8); | |
364 | packet->packetLength[1] = (unsigned char) (packetLength); |
|
315 | packet->packetLength[1] = (unsigned char) (packetLength); | |
365 | // DATA FIELD HEADER |
|
316 | // DATA FIELD HEADER | |
366 | packet->spare1_pusVersion_spare2 = 0x10; |
|
317 | packet->spare1_pusVersion_spare2 = 0x10; | |
367 | packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
318 | packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
368 | packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype |
|
319 | packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype | |
369 | packet->destinationID = TM_DESTINATION_ID_GROUND; |
|
320 | packet->destinationID = TM_DESTINATION_ID_GROUND; | |
370 | packet->time[0] = 0x00; |
|
321 | packet->time[0] = 0x00; | |
371 | packet->time[1] = 0x00; |
|
322 | packet->time[1] = 0x00; | |
372 | packet->time[2] = 0x00; |
|
323 | packet->time[2] = 0x00; | |
373 | packet->time[3] = 0x00; |
|
324 | packet->time[3] = 0x00; | |
374 | packet->time[4] = 0x00; |
|
325 | packet->time[4] = 0x00; | |
375 | packet->time[5] = 0x00; |
|
326 | packet->time[5] = 0x00; | |
376 | // AUXILIARY DATA HEADER |
|
327 | // AUXILIARY DATA HEADER | |
377 | packet->sid = sid; |
|
328 | packet->sid = sid; | |
378 | packet->biaStatusInfo = 0x00; |
|
329 | packet->biaStatusInfo = 0x00; | |
379 | packet->sy_lfr_common_parameters_spare = 0x00; |
|
330 | packet->sy_lfr_common_parameters_spare = 0x00; | |
380 | packet->sy_lfr_common_parameters = 0x00; |
|
331 | packet->sy_lfr_common_parameters = 0x00; | |
381 | packet->acquisitionTime[0] = 0x00; |
|
332 | packet->acquisitionTime[0] = 0x00; | |
382 | packet->acquisitionTime[1] = 0x00; |
|
333 | packet->acquisitionTime[1] = 0x00; | |
383 | packet->acquisitionTime[2] = 0x00; |
|
334 | packet->acquisitionTime[2] = 0x00; | |
384 | packet->acquisitionTime[3] = 0x00; |
|
335 | packet->acquisitionTime[3] = 0x00; | |
385 | packet->acquisitionTime[4] = 0x00; |
|
336 | packet->acquisitionTime[4] = 0x00; | |
386 | packet->acquisitionTime[5] = 0x00; |
|
337 | packet->acquisitionTime[5] = 0x00; | |
387 | packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB |
|
338 | packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB | |
388 | packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB |
|
339 | packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB | |
389 | } |
|
340 | } | |
390 |
|
341 | |||
391 | void BP_init_header_with_spare( bp_packet_with_spare *packet, |
|
342 | void BP_init_header_with_spare( bp_packet_with_spare *packet, | |
392 | unsigned int apid, unsigned char sid, |
|
343 | unsigned int apid, unsigned char sid, | |
393 | unsigned int packetLength , unsigned char blkNr) |
|
344 | unsigned int packetLength , unsigned char blkNr) | |
394 | { |
|
345 | { | |
395 | packet->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
346 | packet->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
396 | packet->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
347 | packet->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
397 | packet->reserved = 0x00; |
|
348 | packet->reserved = 0x00; | |
398 | packet->userApplication = CCSDS_USER_APP; |
|
349 | packet->userApplication = CCSDS_USER_APP; | |
399 | packet->packetID[0] = (unsigned char) (apid >> 8); |
|
350 | packet->packetID[0] = (unsigned char) (apid >> 8); | |
400 | packet->packetID[1] = (unsigned char) (apid); |
|
351 | packet->packetID[1] = (unsigned char) (apid); | |
401 | packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
352 | packet->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
402 | packet->packetSequenceControl[1] = 0x00; |
|
353 | packet->packetSequenceControl[1] = 0x00; | |
403 | packet->packetLength[0] = (unsigned char) (packetLength >> 8); |
|
354 | packet->packetLength[0] = (unsigned char) (packetLength >> 8); | |
404 | packet->packetLength[1] = (unsigned char) (packetLength); |
|
355 | packet->packetLength[1] = (unsigned char) (packetLength); | |
405 | // DATA FIELD HEADER |
|
356 | // DATA FIELD HEADER | |
406 | packet->spare1_pusVersion_spare2 = 0x10; |
|
357 | packet->spare1_pusVersion_spare2 = 0x10; | |
407 | packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type |
|
358 | packet->serviceType = TM_TYPE_LFR_SCIENCE; // service type | |
408 | packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype |
|
359 | packet->serviceSubType = TM_SUBTYPE_LFR_SCIENCE_3; // service subtype | |
409 | packet->destinationID = TM_DESTINATION_ID_GROUND; |
|
360 | packet->destinationID = TM_DESTINATION_ID_GROUND; | |
410 | // AUXILIARY DATA HEADER |
|
361 | // AUXILIARY DATA HEADER | |
411 | packet->sid = sid; |
|
362 | packet->sid = sid; | |
412 | packet->biaStatusInfo = 0x00; |
|
363 | packet->biaStatusInfo = 0x00; | |
413 | packet->sy_lfr_common_parameters_spare = 0x00; |
|
364 | packet->sy_lfr_common_parameters_spare = 0x00; | |
414 | packet->sy_lfr_common_parameters = 0x00; |
|
365 | packet->sy_lfr_common_parameters = 0x00; | |
415 | packet->time[0] = 0x00; |
|
366 | packet->time[0] = 0x00; | |
416 | packet->time[0] = 0x00; |
|
367 | packet->time[0] = 0x00; | |
417 | packet->time[0] = 0x00; |
|
368 | packet->time[0] = 0x00; | |
418 | packet->time[0] = 0x00; |
|
369 | packet->time[0] = 0x00; | |
419 | packet->time[0] = 0x00; |
|
370 | packet->time[0] = 0x00; | |
420 | packet->time[0] = 0x00; |
|
371 | packet->time[0] = 0x00; | |
421 | packet->source_data_spare = 0x00; |
|
372 | packet->source_data_spare = 0x00; | |
422 | packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB |
|
373 | packet->pa_lfr_bp_blk_nr[0] = 0x00; // BLK_NR MSB | |
423 | packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB |
|
374 | packet->pa_lfr_bp_blk_nr[1] = blkNr; // BLK_NR LSB | |
424 | } |
|
375 | } | |
425 |
|
376 | |||
426 | void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid ) |
|
377 | void BP_send(char *data, rtems_id queue_id, unsigned int nbBytesToSend, unsigned int sid ) | |
427 | { |
|
378 | { | |
428 | rtems_status_code status; |
|
379 | rtems_status_code status; | |
429 |
|
380 | |||
430 | // SEND PACKET |
|
381 | // SEND PACKET | |
431 | status = rtems_message_queue_send( queue_id, data, nbBytesToSend); |
|
382 | status = rtems_message_queue_send( queue_id, data, nbBytesToSend); | |
432 | if (status != RTEMS_SUCCESSFUL) |
|
383 | if (status != RTEMS_SUCCESSFUL) | |
433 | { |
|
384 | { | |
434 | PRINTF1("ERR *** in BP_send *** ERR %d\n", (int) status) |
|
385 | PRINTF1("ERR *** in BP_send *** ERR %d\n", (int) status) | |
435 | } |
|
386 | } | |
436 | } |
|
387 | } | |
437 |
|
388 | |||
438 | //****************** |
|
389 | //****************** | |
439 | // general functions |
|
390 | // general functions | |
440 |
|
391 | |||
441 | void reset_sm_status( void ) |
|
392 | void reset_sm_status( void ) | |
442 | { |
|
393 | { | |
443 | // error |
|
394 | // error | |
444 | // 10 --------------- 9 ---------------- 8 ---------------- 7 --------- |
|
395 | // 10 --------------- 9 ---------------- 8 ---------------- 7 --------- | |
445 | // input_fif0_write_2 input_fifo_write_1 input_fifo_write_0 buffer_full |
|
396 | // input_fif0_write_2 input_fifo_write_1 input_fifo_write_0 buffer_full | |
446 | // ---------- 5 -- 4 -- 3 -- 2 -- 1 -- 0 -- |
|
397 | // ---------- 5 -- 4 -- 3 -- 2 -- 1 -- 0 -- | |
447 | // ready bits f2_1 f2_0 f1_1 f1_1 f0_1 f0_0 |
|
398 | // ready bits f2_1 f2_0 f1_1 f1_1 f0_1 f0_0 | |
448 |
|
399 | |||
449 | spectral_matrix_regs->status = 0x7ff; // [0111 1111 1111] |
|
400 | spectral_matrix_regs->status = 0x7ff; // [0111 1111 1111] | |
450 | } |
|
401 | } | |
451 |
|
402 | |||
452 | void reset_spectral_matrix_regs( void ) |
|
403 | void reset_spectral_matrix_regs( void ) | |
453 | { |
|
404 | { | |
454 | /** This function resets the spectral matrices module registers. |
|
405 | /** This function resets the spectral matrices module registers. | |
455 | * |
|
406 | * | |
456 | * The registers affected by this function are located at the following offset addresses: |
|
407 | * The registers affected by this function are located at the following offset addresses: | |
457 | * |
|
408 | * | |
458 | * - 0x00 config |
|
409 | * - 0x00 config | |
459 | * - 0x04 status |
|
410 | * - 0x04 status | |
460 | * - 0x08 matrixF0_Address0 |
|
411 | * - 0x08 matrixF0_Address0 | |
461 | * - 0x10 matrixFO_Address1 |
|
412 | * - 0x10 matrixFO_Address1 | |
462 | * - 0x14 matrixF1_Address |
|
413 | * - 0x14 matrixF1_Address | |
463 | * - 0x18 matrixF2_Address |
|
414 | * - 0x18 matrixF2_Address | |
464 | * |
|
415 | * | |
465 | */ |
|
416 | */ | |
466 |
|
417 | |||
467 | set_sm_irq_onError( 0 ); |
|
418 | set_sm_irq_onError( 0 ); | |
468 |
|
419 | |||
469 | set_sm_irq_onNewMatrix( 0 ); |
|
420 | set_sm_irq_onNewMatrix( 0 ); | |
470 |
|
421 | |||
471 | reset_sm_status(); |
|
422 | reset_sm_status(); | |
472 |
|
423 | |||
473 | // F1 |
|
424 | // F1 | |
474 | spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address; |
|
425 | spectral_matrix_regs->f0_0_address = current_ring_node_sm_f0->previous->buffer_address; | |
475 | spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; |
|
426 | spectral_matrix_regs->f0_1_address = current_ring_node_sm_f0->buffer_address; | |
476 | // F2 |
|
427 | // F2 | |
477 | spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address; |
|
428 | spectral_matrix_regs->f1_0_address = current_ring_node_sm_f1->previous->buffer_address; | |
478 | spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; |
|
429 | spectral_matrix_regs->f1_1_address = current_ring_node_sm_f1->buffer_address; | |
479 | // F3 |
|
430 | // F3 | |
480 | spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address; |
|
431 | spectral_matrix_regs->f2_0_address = current_ring_node_sm_f2->previous->buffer_address; | |
481 | spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address; |
|
432 | spectral_matrix_regs->f2_1_address = current_ring_node_sm_f2->buffer_address; | |
482 |
|
433 | |||
483 | spectral_matrix_regs->matrix_length = 0xc8; // 25 * 128 / 16 = 200 = 0xc8 |
|
434 | spectral_matrix_regs->matrix_length = 0xc8; // 25 * 128 / 16 = 200 = 0xc8 | |
484 | } |
|
435 | } | |
485 |
|
436 | |||
486 | void set_time( unsigned char *time, unsigned char * timeInBuffer ) |
|
437 | void set_time( unsigned char *time, unsigned char * timeInBuffer ) | |
487 | { |
|
438 | { | |
488 | time[0] = timeInBuffer[0]; |
|
439 | time[0] = timeInBuffer[0]; | |
489 | time[1] = timeInBuffer[1]; |
|
440 | time[1] = timeInBuffer[1]; | |
490 | time[2] = timeInBuffer[2]; |
|
441 | time[2] = timeInBuffer[2]; | |
491 | time[3] = timeInBuffer[3]; |
|
442 | time[3] = timeInBuffer[3]; | |
492 | time[4] = timeInBuffer[6]; |
|
443 | time[4] = timeInBuffer[6]; | |
493 | time[5] = timeInBuffer[7]; |
|
444 | time[5] = timeInBuffer[7]; | |
494 | } |
|
445 | } | |
495 |
|
446 | |||
496 | unsigned long long int get_acquisition_time( unsigned char *timePtr ) |
|
447 | unsigned long long int get_acquisition_time( unsigned char *timePtr ) | |
497 | { |
|
448 | { | |
498 | unsigned long long int acquisitionTimeAslong; |
|
449 | unsigned long long int acquisitionTimeAslong; | |
499 | acquisitionTimeAslong = 0x00; |
|
450 | acquisitionTimeAslong = 0x00; | |
500 | acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit |
|
451 | acquisitionTimeAslong = ( (unsigned long long int) (timePtr[0] & 0x7f) << 40 ) // [0111 1111] mask the synchronization bit | |
501 | + ( (unsigned long long int) timePtr[1] << 32 ) |
|
452 | + ( (unsigned long long int) timePtr[1] << 32 ) | |
502 | + ( (unsigned long long int) timePtr[2] << 24 ) |
|
453 | + ( (unsigned long long int) timePtr[2] << 24 ) | |
503 | + ( (unsigned long long int) timePtr[3] << 16 ) |
|
454 | + ( (unsigned long long int) timePtr[3] << 16 ) | |
504 | + ( (unsigned long long int) timePtr[6] << 8 ) |
|
455 | + ( (unsigned long long int) timePtr[6] << 8 ) | |
505 | + ( (unsigned long long int) timePtr[7] ); |
|
456 | + ( (unsigned long long int) timePtr[7] ); | |
506 | return acquisitionTimeAslong; |
|
457 | return acquisitionTimeAslong; | |
507 | } |
|
458 | } | |
508 |
|
459 | |||
509 | unsigned char getSID( rtems_event_set event ) |
|
460 | unsigned char getSID( rtems_event_set event ) | |
510 | { |
|
461 | { | |
511 | unsigned char sid; |
|
462 | unsigned char sid; | |
512 |
|
463 | |||
513 | rtems_event_set eventSetBURST; |
|
464 | rtems_event_set eventSetBURST; | |
514 | rtems_event_set eventSetSBM; |
|
465 | rtems_event_set eventSetSBM; | |
515 |
|
466 | |||
516 | //****** |
|
467 | //****** | |
517 | // BURST |
|
468 | // BURST | |
518 | eventSetBURST = RTEMS_EVENT_BURST_BP1_F0 |
|
469 | eventSetBURST = RTEMS_EVENT_BURST_BP1_F0 | |
519 | | RTEMS_EVENT_BURST_BP1_F1 |
|
470 | | RTEMS_EVENT_BURST_BP1_F1 | |
520 | | RTEMS_EVENT_BURST_BP2_F0 |
|
471 | | RTEMS_EVENT_BURST_BP2_F0 | |
521 | | RTEMS_EVENT_BURST_BP2_F1; |
|
472 | | RTEMS_EVENT_BURST_BP2_F1; | |
522 |
|
473 | |||
523 | //**** |
|
474 | //**** | |
524 | // SBM |
|
475 | // SBM | |
525 | eventSetSBM = RTEMS_EVENT_SBM_BP1_F0 |
|
476 | eventSetSBM = RTEMS_EVENT_SBM_BP1_F0 | |
526 | | RTEMS_EVENT_SBM_BP1_F1 |
|
477 | | RTEMS_EVENT_SBM_BP1_F1 | |
527 | | RTEMS_EVENT_SBM_BP2_F0 |
|
478 | | RTEMS_EVENT_SBM_BP2_F0 | |
528 | | RTEMS_EVENT_SBM_BP2_F1; |
|
479 | | RTEMS_EVENT_SBM_BP2_F1; | |
529 |
|
480 | |||
530 | if (event & eventSetBURST) |
|
481 | if (event & eventSetBURST) | |
531 | { |
|
482 | { | |
532 | sid = SID_BURST_BP1_F0; |
|
483 | sid = SID_BURST_BP1_F0; | |
533 | } |
|
484 | } | |
534 | else if (event & eventSetSBM) |
|
485 | else if (event & eventSetSBM) | |
535 | { |
|
486 | { | |
536 | sid = SID_SBM1_BP1_F0; |
|
487 | sid = SID_SBM1_BP1_F0; | |
537 | } |
|
488 | } | |
538 | else |
|
489 | else | |
539 | { |
|
490 | { | |
540 | sid = 0; |
|
491 | sid = 0; | |
541 | } |
|
492 | } | |
542 |
|
493 | |||
543 | return sid; |
|
494 | return sid; | |
544 | } |
|
495 | } | |
545 |
|
496 | |||
546 | void extractReImVectors( float *inputASM, float *outputASM, unsigned int asmComponent ) |
|
497 | void extractReImVectors( float *inputASM, float *outputASM, unsigned int asmComponent ) | |
547 | { |
|
498 | { | |
548 | unsigned int i; |
|
499 | unsigned int i; | |
549 | float re; |
|
500 | float re; | |
550 | float im; |
|
501 | float im; | |
551 |
|
502 | |||
552 | for (i=0; i<NB_BINS_PER_SM; i++){ |
|
503 | for (i=0; i<NB_BINS_PER_SM; i++){ | |
553 | re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 ]; |
|
504 | re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 ]; | |
554 | im = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 + 1]; |
|
505 | im = inputASM[ (asmComponent*NB_BINS_PER_SM) + i * 2 + 1]; | |
555 | outputASM[ (asmComponent *NB_BINS_PER_SM) + i] = re; |
|
506 | outputASM[ (asmComponent *NB_BINS_PER_SM) + i] = re; | |
556 | outputASM[ (asmComponent+1)*NB_BINS_PER_SM + i] = im; |
|
507 | outputASM[ (asmComponent+1)*NB_BINS_PER_SM + i] = im; | |
557 | } |
|
508 | } | |
558 | } |
|
509 | } | |
559 |
|
510 | |||
560 | void copyReVectors( float *inputASM, float *outputASM, unsigned int asmComponent ) |
|
511 | void copyReVectors( float *inputASM, float *outputASM, unsigned int asmComponent ) | |
561 | { |
|
512 | { | |
562 | unsigned int i; |
|
513 | unsigned int i; | |
563 | float re; |
|
514 | float re; | |
564 |
|
515 | |||
565 | for (i=0; i<NB_BINS_PER_SM; i++){ |
|
516 | for (i=0; i<NB_BINS_PER_SM; i++){ | |
566 | re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i]; |
|
517 | re = inputASM[ (asmComponent*NB_BINS_PER_SM) + i]; | |
567 | outputASM[ (asmComponent*NB_BINS_PER_SM) + i] = re; |
|
518 | outputASM[ (asmComponent*NB_BINS_PER_SM) + i] = re; | |
568 | } |
|
519 | } | |
569 | } |
|
520 | } | |
570 |
|
521 | |||
571 | void ASM_patch( float *inputASM, float *outputASM ) |
|
522 | void ASM_patch( float *inputASM, float *outputASM ) | |
572 | { |
|
523 | { | |
573 | extractReImVectors( inputASM, outputASM, 1); // b1b2 |
|
524 | extractReImVectors( inputASM, outputASM, 1); // b1b2 | |
574 | extractReImVectors( inputASM, outputASM, 3 ); // b1b3 |
|
525 | extractReImVectors( inputASM, outputASM, 3 ); // b1b3 | |
575 | extractReImVectors( inputASM, outputASM, 5 ); // b1e1 |
|
526 | extractReImVectors( inputASM, outputASM, 5 ); // b1e1 | |
576 | extractReImVectors( inputASM, outputASM, 7 ); // b1e2 |
|
527 | extractReImVectors( inputASM, outputASM, 7 ); // b1e2 | |
577 | extractReImVectors( inputASM, outputASM, 10 ); // b2b3 |
|
528 | extractReImVectors( inputASM, outputASM, 10 ); // b2b3 | |
578 | extractReImVectors( inputASM, outputASM, 12 ); // b2e1 |
|
529 | extractReImVectors( inputASM, outputASM, 12 ); // b2e1 | |
579 | extractReImVectors( inputASM, outputASM, 14 ); // b2e2 |
|
530 | extractReImVectors( inputASM, outputASM, 14 ); // b2e2 | |
580 | extractReImVectors( inputASM, outputASM, 17 ); // b3e1 |
|
531 | extractReImVectors( inputASM, outputASM, 17 ); // b3e1 | |
581 | extractReImVectors( inputASM, outputASM, 19 ); // b3e2 |
|
532 | extractReImVectors( inputASM, outputASM, 19 ); // b3e2 | |
582 | extractReImVectors( inputASM, outputASM, 22 ); // e1e2 |
|
533 | extractReImVectors( inputASM, outputASM, 22 ); // e1e2 | |
583 |
|
534 | |||
584 | copyReVectors(inputASM, outputASM, 0 ); // b1b1 |
|
535 | copyReVectors(inputASM, outputASM, 0 ); // b1b1 | |
585 | copyReVectors(inputASM, outputASM, 9 ); // b2b2 |
|
536 | copyReVectors(inputASM, outputASM, 9 ); // b2b2 | |
586 | copyReVectors(inputASM, outputASM, 16); // b3b3 |
|
537 | copyReVectors(inputASM, outputASM, 16); // b3b3 | |
587 | copyReVectors(inputASM, outputASM, 21); // e1e1 |
|
538 | copyReVectors(inputASM, outputASM, 21); // e1e1 | |
588 | copyReVectors(inputASM, outputASM, 24); // e2e2 |
|
539 | copyReVectors(inputASM, outputASM, 24); // e2e2 | |
589 | } |
|
540 | } | |
590 |
|
541 | |||
591 | void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat , float divider, |
|
542 | void ASM_compress_reorganize_and_divide_mask(float *averaged_spec_mat, float *compressed_spec_mat , float divider, | |
592 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, |
|
543 | unsigned char nbBinsCompressedMatrix, unsigned char nbBinsToAverage, | |
593 | unsigned char ASMIndexStart, |
|
544 | unsigned char ASMIndexStart, | |
594 | unsigned char channel ) |
|
545 | unsigned char channel ) | |
595 | { |
|
546 | { | |
596 | //************* |
|
547 | //************* | |
597 | // input format |
|
548 | // input format | |
598 | // component0[0 .. 127] component1[0 .. 127] .. component24[0 .. 127] |
|
549 | // component0[0 .. 127] component1[0 .. 127] .. component24[0 .. 127] | |
599 | //************** |
|
550 | //************** | |
600 | // output format |
|
551 | // output format | |
601 | // matr0[0 .. 24] matr1[0 .. 24] .. matr127[0 .. 24] |
|
552 | // matr0[0 .. 24] matr1[0 .. 24] .. matr127[0 .. 24] | |
602 | //************ |
|
553 | //************ | |
603 | // compression |
|
554 | // compression | |
604 | // matr0[0 .. 24] matr1[0 .. 24] .. matr11[0 .. 24] => f0 NORM |
|
555 | // matr0[0 .. 24] matr1[0 .. 24] .. matr11[0 .. 24] => f0 NORM | |
605 | // matr0[0 .. 24] matr1[0 .. 24] .. matr22[0 .. 24] => f0 BURST, SBM |
|
556 | // matr0[0 .. 24] matr1[0 .. 24] .. matr22[0 .. 24] => f0 BURST, SBM | |
606 |
|
557 | |||
607 | int frequencyBin; |
|
558 | int frequencyBin; | |
608 | int asmComponent; |
|
559 | int asmComponent; | |
609 | int offsetASM; |
|
560 | int offsetASM; | |
610 | int offsetCompressed; |
|
561 | int offsetCompressed; | |
611 | int offsetFBin; |
|
562 | int offsetFBin; | |
612 | int fBinMask; |
|
563 | int fBinMask; | |
613 | int k; |
|
564 | int k; | |
614 |
|
565 | |||
615 | // BUILD DATA |
|
566 | // BUILD DATA | |
616 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) |
|
567 | for (asmComponent = 0; asmComponent < NB_VALUES_PER_SM; asmComponent++) | |
617 | { |
|
568 | { | |
618 | for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ ) |
|
569 | for( frequencyBin = 0; frequencyBin < nbBinsCompressedMatrix; frequencyBin++ ) | |
619 | { |
|
570 | { | |
620 | offsetCompressed = // NO TIME OFFSET |
|
571 | offsetCompressed = // NO TIME OFFSET | |
621 | frequencyBin * NB_VALUES_PER_SM |
|
572 | frequencyBin * NB_VALUES_PER_SM | |
622 | + asmComponent; |
|
573 | + asmComponent; | |
623 | offsetASM = // NO TIME OFFSET |
|
574 | offsetASM = // NO TIME OFFSET | |
624 | asmComponent * NB_BINS_PER_SM |
|
575 | asmComponent * NB_BINS_PER_SM | |
625 | + ASMIndexStart |
|
576 | + ASMIndexStart | |
626 | + frequencyBin * nbBinsToAverage; |
|
577 | + frequencyBin * nbBinsToAverage; | |
627 | offsetFBin = ASMIndexStart |
|
578 | offsetFBin = ASMIndexStart | |
628 | + frequencyBin * nbBinsToAverage; |
|
579 | + frequencyBin * nbBinsToAverage; | |
629 | compressed_spec_mat[ offsetCompressed ] = 0; |
|
580 | compressed_spec_mat[ offsetCompressed ] = 0; | |
630 | for ( k = 0; k < nbBinsToAverage; k++ ) |
|
581 | for ( k = 0; k < nbBinsToAverage; k++ ) | |
631 | { |
|
582 | { | |
632 | fBinMask = getFBinMask( offsetFBin + k, channel ); |
|
583 | fBinMask = getFBinMask( offsetFBin + k, channel ); | |
633 | compressed_spec_mat[offsetCompressed ] = |
|
584 | compressed_spec_mat[offsetCompressed ] = | |
634 | ( compressed_spec_mat[ offsetCompressed ] |
|
585 | ( compressed_spec_mat[ offsetCompressed ] | |
635 | + averaged_spec_mat[ offsetASM + k ] * fBinMask ); |
|
586 | + averaged_spec_mat[ offsetASM + k ] * fBinMask ); | |
636 | } |
|
587 | } | |
637 | compressed_spec_mat[ offsetCompressed ] = |
|
588 | compressed_spec_mat[ offsetCompressed ] = | |
638 | compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage); |
|
589 | compressed_spec_mat[ offsetCompressed ] / (divider * nbBinsToAverage); | |
639 | } |
|
590 | } | |
640 | } |
|
591 | } | |
641 |
|
592 | |||
642 | } |
|
593 | } | |
643 |
|
594 | |||
644 | int getFBinMask( int index, unsigned char channel ) |
|
595 | int getFBinMask( int index, unsigned char channel ) | |
645 | { |
|
596 | { | |
646 | unsigned int indexInChar; |
|
597 | unsigned int indexInChar; | |
647 | unsigned int indexInTheChar; |
|
598 | unsigned int indexInTheChar; | |
648 | int fbin; |
|
599 | int fbin; | |
649 | unsigned char *sy_lfr_fbins_fx_word1; |
|
600 | unsigned char *sy_lfr_fbins_fx_word1; | |
650 |
|
601 | |||
651 | sy_lfr_fbins_fx_word1 = parameter_dump_packet.sy_lfr_fbins_f0_word1; |
|
602 | sy_lfr_fbins_fx_word1 = parameter_dump_packet.sy_lfr_fbins_f0_word1; | |
652 |
|
603 | |||
653 | switch(channel) |
|
604 | switch(channel) | |
654 | { |
|
605 | { | |
655 | case 0: |
|
606 | case 0: | |
656 | sy_lfr_fbins_fx_word1 = parameter_dump_packet.sy_lfr_fbins_f0_word1; |
|
607 | sy_lfr_fbins_fx_word1 = parameter_dump_packet.sy_lfr_fbins_f0_word1; | |
657 | break; |
|
608 | break; | |
658 | case 1: |
|
609 | case 1: | |
659 | sy_lfr_fbins_fx_word1 = parameter_dump_packet.sy_lfr_fbins_f1_word1; |
|
610 | sy_lfr_fbins_fx_word1 = parameter_dump_packet.sy_lfr_fbins_f1_word1; | |
660 | break; |
|
611 | break; | |
661 | case 2: |
|
612 | case 2: | |
662 | sy_lfr_fbins_fx_word1 = parameter_dump_packet.sy_lfr_fbins_f2_word1; |
|
613 | sy_lfr_fbins_fx_word1 = parameter_dump_packet.sy_lfr_fbins_f2_word1; | |
663 | break; |
|
614 | break; | |
664 | default: |
|
615 | default: | |
665 | PRINTF("ERR *** in getFBinMask, wrong frequency channel") |
|
616 | PRINTF("ERR *** in getFBinMask, wrong frequency channel") | |
666 | } |
|
617 | } | |
667 |
|
618 | |||
668 | indexInChar = index >> 3; |
|
619 | indexInChar = index >> 3; | |
669 | indexInTheChar = index - indexInChar * 8; |
|
620 | indexInTheChar = index - indexInChar * 8; | |
670 |
|
621 | |||
671 | fbin = (int) ((sy_lfr_fbins_fx_word1[ NB_BYTES_PER_FREQ_MASK - 1 - indexInChar] >> indexInTheChar) & 0x1); |
|
622 | fbin = (int) ((sy_lfr_fbins_fx_word1[ NB_BYTES_PER_FREQ_MASK - 1 - indexInChar] >> indexInTheChar) & 0x1); | |
672 |
|
623 | |||
673 | return fbin; |
|
624 | return fbin; | |
674 | } |
|
625 | } | |
675 |
|
626 | |||
676 | void init_kcoeff_sbm_from_kcoeff_norm(float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm) |
|
627 | void init_kcoeff_sbm_from_kcoeff_norm(float *input_kcoeff, float *output_kcoeff, unsigned char nb_bins_norm) | |
677 | { |
|
628 | { | |
678 | unsigned char bin; |
|
629 | unsigned char bin; | |
679 | unsigned char kcoeff; |
|
630 | unsigned char kcoeff; | |
680 |
|
631 | |||
681 | for (bin=0; bin<nb_bins_norm; bin++) |
|
632 | for (bin=0; bin<nb_bins_norm; bin++) | |
682 | { |
|
633 | { | |
683 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
634 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) | |
684 | { |
|
635 | { | |
685 | output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ]; |
|
636 | output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ]; | |
686 | output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 + 1 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ]; |
|
637 | output_kcoeff[ (bin*NB_K_COEFF_PER_BIN + kcoeff)*2 + 1 ] = input_kcoeff[ bin*NB_K_COEFF_PER_BIN + kcoeff ]; | |
687 | } |
|
638 | } | |
688 | } |
|
639 | } | |
689 | } |
|
640 | } |
@@ -1,1525 +1,1519 | |||||
1 | /** Functions and tasks related to TeleCommand handling. |
|
1 | /** Functions and tasks related to TeleCommand handling. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle TeleCommands:\n |
|
6 | * A group of functions to handle TeleCommands:\n | |
7 | * action launching\n |
|
7 | * action launching\n | |
8 | * TC parsing\n |
|
8 | * TC parsing\n | |
9 | * ... |
|
9 | * ... | |
10 | * |
|
10 | * | |
11 | */ |
|
11 | */ | |
12 |
|
12 | |||
13 | #include "tc_handler.h" |
|
13 | #include "tc_handler.h" | |
14 | #include "math.h" |
|
14 | #include "math.h" | |
15 |
|
15 | |||
16 | //*********** |
|
16 | //*********** | |
17 | // RTEMS TASK |
|
17 | // RTEMS TASK | |
18 |
|
18 | |||
19 | rtems_task actn_task( rtems_task_argument unused ) |
|
19 | rtems_task actn_task( rtems_task_argument unused ) | |
20 | { |
|
20 | { | |
21 | /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands. |
|
21 | /** This RTEMS task is responsible for launching actions upton the reception of valid TeleCommands. | |
22 | * |
|
22 | * | |
23 | * @param unused is the starting argument of the RTEMS task |
|
23 | * @param unused is the starting argument of the RTEMS task | |
24 | * |
|
24 | * | |
25 | * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending |
|
25 | * The ACTN task waits for data coming from an RTEMS msesage queue. When data arrives, it launches specific actions depending | |
26 | * on the incoming TeleCommand. |
|
26 | * on the incoming TeleCommand. | |
27 | * |
|
27 | * | |
28 | */ |
|
28 | */ | |
29 |
|
29 | |||
30 | int result; |
|
30 | int result; | |
31 | rtems_status_code status; // RTEMS status code |
|
31 | rtems_status_code status; // RTEMS status code | |
32 | ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task |
|
32 | ccsdsTelecommandPacket_t TC; // TC sent to the ACTN task | |
33 | size_t size; // size of the incoming TC packet |
|
33 | size_t size; // size of the incoming TC packet | |
34 | unsigned char subtype; // subtype of the current TC packet |
|
34 | unsigned char subtype; // subtype of the current TC packet | |
35 | unsigned char time[6]; |
|
35 | unsigned char time[6]; | |
36 | rtems_id queue_rcv_id; |
|
36 | rtems_id queue_rcv_id; | |
37 | rtems_id queue_snd_id; |
|
37 | rtems_id queue_snd_id; | |
38 |
|
38 | |||
39 | status = get_message_queue_id_recv( &queue_rcv_id ); |
|
39 | status = get_message_queue_id_recv( &queue_rcv_id ); | |
40 | if (status != RTEMS_SUCCESSFUL) |
|
40 | if (status != RTEMS_SUCCESSFUL) | |
41 | { |
|
41 | { | |
42 | PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status) |
|
42 | PRINTF1("in ACTN *** ERR get_message_queue_id_recv %d\n", status) | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 | status = get_message_queue_id_send( &queue_snd_id ); |
|
45 | status = get_message_queue_id_send( &queue_snd_id ); | |
46 | if (status != RTEMS_SUCCESSFUL) |
|
46 | if (status != RTEMS_SUCCESSFUL) | |
47 | { |
|
47 | { | |
48 | PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status) |
|
48 | PRINTF1("in ACTN *** ERR get_message_queue_id_send %d\n", status) | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
51 | result = LFR_SUCCESSFUL; |
|
51 | result = LFR_SUCCESSFUL; | |
52 | subtype = 0; // subtype of the current TC packet |
|
52 | subtype = 0; // subtype of the current TC packet | |
53 |
|
53 | |||
54 | BOOT_PRINTF("in ACTN *** \n") |
|
54 | BOOT_PRINTF("in ACTN *** \n") | |
55 |
|
55 | |||
56 | while(1) |
|
56 | while(1) | |
57 | { |
|
57 | { | |
58 | status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size, |
|
58 | status = rtems_message_queue_receive( queue_rcv_id, (char*) &TC, &size, | |
59 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); |
|
59 | RTEMS_WAIT, RTEMS_NO_TIMEOUT); | |
60 | getTime( time ); // set time to the current time |
|
60 | getTime( time ); // set time to the current time | |
61 | if (status!=RTEMS_SUCCESSFUL) |
|
61 | if (status!=RTEMS_SUCCESSFUL) | |
62 | { |
|
62 | { | |
63 | PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) |
|
63 | PRINTF1("ERR *** in task ACTN *** error receiving a message, code %d \n", status) | |
64 | } |
|
64 | } | |
65 | else |
|
65 | else | |
66 | { |
|
66 | { | |
67 | subtype = TC.serviceSubType; |
|
67 | subtype = TC.serviceSubType; | |
68 | switch(subtype) |
|
68 | switch(subtype) | |
69 | { |
|
69 | { | |
70 | case TC_SUBTYPE_RESET: |
|
70 | case TC_SUBTYPE_RESET: | |
71 | result = action_reset( &TC, queue_snd_id, time ); |
|
71 | result = action_reset( &TC, queue_snd_id, time ); | |
72 | close_action( &TC, result, queue_snd_id ); |
|
72 | close_action( &TC, result, queue_snd_id ); | |
73 | break; |
|
73 | break; | |
74 | case TC_SUBTYPE_LOAD_COMM: |
|
74 | case TC_SUBTYPE_LOAD_COMM: | |
75 | result = action_load_common_par( &TC ); |
|
75 | result = action_load_common_par( &TC ); | |
76 | close_action( &TC, result, queue_snd_id ); |
|
76 | close_action( &TC, result, queue_snd_id ); | |
77 | break; |
|
77 | break; | |
78 | case TC_SUBTYPE_LOAD_NORM: |
|
78 | case TC_SUBTYPE_LOAD_NORM: | |
79 | result = action_load_normal_par( &TC, queue_snd_id, time ); |
|
79 | result = action_load_normal_par( &TC, queue_snd_id, time ); | |
80 | close_action( &TC, result, queue_snd_id ); |
|
80 | close_action( &TC, result, queue_snd_id ); | |
81 | break; |
|
81 | break; | |
82 | case TC_SUBTYPE_LOAD_BURST: |
|
82 | case TC_SUBTYPE_LOAD_BURST: | |
83 | result = action_load_burst_par( &TC, queue_snd_id, time ); |
|
83 | result = action_load_burst_par( &TC, queue_snd_id, time ); | |
84 | close_action( &TC, result, queue_snd_id ); |
|
84 | close_action( &TC, result, queue_snd_id ); | |
85 | break; |
|
85 | break; | |
86 | case TC_SUBTYPE_LOAD_SBM1: |
|
86 | case TC_SUBTYPE_LOAD_SBM1: | |
87 | result = action_load_sbm1_par( &TC, queue_snd_id, time ); |
|
87 | result = action_load_sbm1_par( &TC, queue_snd_id, time ); | |
88 | close_action( &TC, result, queue_snd_id ); |
|
88 | close_action( &TC, result, queue_snd_id ); | |
89 | break; |
|
89 | break; | |
90 | case TC_SUBTYPE_LOAD_SBM2: |
|
90 | case TC_SUBTYPE_LOAD_SBM2: | |
91 | result = action_load_sbm2_par( &TC, queue_snd_id, time ); |
|
91 | result = action_load_sbm2_par( &TC, queue_snd_id, time ); | |
92 | close_action( &TC, result, queue_snd_id ); |
|
92 | close_action( &TC, result, queue_snd_id ); | |
93 | break; |
|
93 | break; | |
94 | case TC_SUBTYPE_DUMP: |
|
94 | case TC_SUBTYPE_DUMP: | |
95 | result = action_dump_par( &TC, queue_snd_id ); |
|
95 | result = action_dump_par( &TC, queue_snd_id ); | |
96 | close_action( &TC, result, queue_snd_id ); |
|
96 | close_action( &TC, result, queue_snd_id ); | |
97 | break; |
|
97 | break; | |
98 | case TC_SUBTYPE_ENTER: |
|
98 | case TC_SUBTYPE_ENTER: | |
99 | result = action_enter_mode( &TC, queue_snd_id ); |
|
99 | result = action_enter_mode( &TC, queue_snd_id ); | |
100 | close_action( &TC, result, queue_snd_id ); |
|
100 | close_action( &TC, result, queue_snd_id ); | |
101 | break; |
|
101 | break; | |
102 | case TC_SUBTYPE_UPDT_INFO: |
|
102 | case TC_SUBTYPE_UPDT_INFO: | |
103 | result = action_update_info( &TC, queue_snd_id ); |
|
103 | result = action_update_info( &TC, queue_snd_id ); | |
104 | close_action( &TC, result, queue_snd_id ); |
|
104 | close_action( &TC, result, queue_snd_id ); | |
105 | break; |
|
105 | break; | |
106 | case TC_SUBTYPE_EN_CAL: |
|
106 | case TC_SUBTYPE_EN_CAL: | |
107 | result = action_enable_calibration( &TC, queue_snd_id, time ); |
|
107 | result = action_enable_calibration( &TC, queue_snd_id, time ); | |
108 | close_action( &TC, result, queue_snd_id ); |
|
108 | close_action( &TC, result, queue_snd_id ); | |
109 | break; |
|
109 | break; | |
110 | case TC_SUBTYPE_DIS_CAL: |
|
110 | case TC_SUBTYPE_DIS_CAL: | |
111 | result = action_disable_calibration( &TC, queue_snd_id, time ); |
|
111 | result = action_disable_calibration( &TC, queue_snd_id, time ); | |
112 | close_action( &TC, result, queue_snd_id ); |
|
112 | close_action( &TC, result, queue_snd_id ); | |
113 | break; |
|
113 | break; | |
114 | case TC_SUBTYPE_LOAD_K: |
|
114 | case TC_SUBTYPE_LOAD_K: | |
115 | result = action_load_kcoefficients( &TC, queue_snd_id, time ); |
|
115 | result = action_load_kcoefficients( &TC, queue_snd_id, time ); | |
116 | close_action( &TC, result, queue_snd_id ); |
|
116 | close_action( &TC, result, queue_snd_id ); | |
117 | break; |
|
117 | break; | |
118 | case TC_SUBTYPE_DUMP_K: |
|
118 | case TC_SUBTYPE_DUMP_K: | |
119 | result = action_dump_kcoefficients( &TC, queue_snd_id, time ); |
|
119 | result = action_dump_kcoefficients( &TC, queue_snd_id, time ); | |
120 | close_action( &TC, result, queue_snd_id ); |
|
120 | close_action( &TC, result, queue_snd_id ); | |
121 | break; |
|
121 | break; | |
122 | case TC_SUBTYPE_LOAD_FBINS: |
|
122 | case TC_SUBTYPE_LOAD_FBINS: | |
123 | result = action_load_fbins_mask( &TC, queue_snd_id, time ); |
|
123 | result = action_load_fbins_mask( &TC, queue_snd_id, time ); | |
124 | close_action( &TC, result, queue_snd_id ); |
|
124 | close_action( &TC, result, queue_snd_id ); | |
125 | break; |
|
125 | break; | |
126 | case TC_SUBTYPE_UPDT_TIME: |
|
126 | case TC_SUBTYPE_UPDT_TIME: | |
127 | result = action_update_time( &TC ); |
|
127 | result = action_update_time( &TC ); | |
128 | close_action( &TC, result, queue_snd_id ); |
|
128 | close_action( &TC, result, queue_snd_id ); | |
129 | break; |
|
129 | break; | |
130 | default: |
|
130 | default: | |
131 | break; |
|
131 | break; | |
132 | } |
|
132 | } | |
133 | } |
|
133 | } | |
134 | } |
|
134 | } | |
135 | } |
|
135 | } | |
136 |
|
136 | |||
137 | //*********** |
|
137 | //*********** | |
138 | // TC ACTIONS |
|
138 | // TC ACTIONS | |
139 |
|
139 | |||
140 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
140 | int action_reset(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
141 | { |
|
141 | { | |
142 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. |
|
142 | /** This function executes specific actions when a TC_LFR_RESET TeleCommand has been received. | |
143 | * |
|
143 | * | |
144 | * @param TC points to the TeleCommand packet that is being processed |
|
144 | * @param TC points to the TeleCommand packet that is being processed | |
145 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
145 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
146 | * |
|
146 | * | |
147 | */ |
|
147 | */ | |
148 |
|
148 | |||
149 | PRINTF("this is the end!!!\n") |
|
149 | PRINTF("this is the end!!!\n") | |
150 | exit(0); |
|
150 | exit(0); | |
151 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); |
|
151 | send_tm_lfr_tc_exe_not_implemented( TC, queue_id, time ); | |
152 | return LFR_DEFAULT; |
|
152 | return LFR_DEFAULT; | |
153 | } |
|
153 | } | |
154 |
|
154 | |||
155 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
155 | int action_enter_mode(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
156 | { |
|
156 | { | |
157 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. |
|
157 | /** This function executes specific actions when a TC_LFR_ENTER_MODE TeleCommand has been received. | |
158 | * |
|
158 | * | |
159 | * @param TC points to the TeleCommand packet that is being processed |
|
159 | * @param TC points to the TeleCommand packet that is being processed | |
160 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
160 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
161 | * |
|
161 | * | |
162 | */ |
|
162 | */ | |
163 |
|
163 | |||
164 | rtems_status_code status; |
|
164 | rtems_status_code status; | |
165 | unsigned char requestedMode; |
|
165 | unsigned char requestedMode; | |
166 | unsigned int *transitionCoarseTime_ptr; |
|
166 | unsigned int *transitionCoarseTime_ptr; | |
167 | unsigned int transitionCoarseTime; |
|
167 | unsigned int transitionCoarseTime; | |
168 | unsigned char * bytePosPtr; |
|
168 | unsigned char * bytePosPtr; | |
169 |
|
169 | |||
170 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
170 | bytePosPtr = (unsigned char *) &TC->packetID; | |
171 |
|
171 | |||
172 | requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ]; |
|
172 | requestedMode = bytePosPtr[ BYTE_POS_CP_MODE_LFR_SET ]; | |
173 | transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] ); |
|
173 | transitionCoarseTime_ptr = (unsigned int *) ( &bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME ] ); | |
174 | transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff; |
|
174 | transitionCoarseTime = (*transitionCoarseTime_ptr) & 0x7fffffff; | |
175 |
|
175 | |||
176 | status = check_mode_value( requestedMode ); |
|
176 | status = check_mode_value( requestedMode ); | |
177 |
|
177 | |||
178 | if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent |
|
178 | if ( status != LFR_SUCCESSFUL ) // the mode value is inconsistent | |
179 | { |
|
179 | { | |
180 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode ); |
|
180 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, BYTE_POS_CP_MODE_LFR_SET, requestedMode ); | |
181 | } |
|
181 | } | |
182 | else // the mode value is valid, check the transition |
|
182 | else // the mode value is valid, check the transition | |
183 | { |
|
183 | { | |
184 | status = check_mode_transition(requestedMode); |
|
184 | status = check_mode_transition(requestedMode); | |
185 | if (status != LFR_SUCCESSFUL) |
|
185 | if (status != LFR_SUCCESSFUL) | |
186 | { |
|
186 | { | |
187 | PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n") |
|
187 | PRINTF("ERR *** in action_enter_mode *** check_mode_transition\n") | |
188 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
188 | send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
189 | } |
|
189 | } | |
190 | } |
|
190 | } | |
191 |
|
191 | |||
192 | if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date |
|
192 | if ( status == LFR_SUCCESSFUL ) // the transition is valid, check the date | |
193 | { |
|
193 | { | |
194 | status = check_transition_date( transitionCoarseTime ); |
|
194 | status = check_transition_date( transitionCoarseTime ); | |
195 | if (status != LFR_SUCCESSFUL) |
|
195 | if (status != LFR_SUCCESSFUL) | |
196 | { |
|
196 | { | |
197 | PRINTF("ERR *** in action_enter_mode *** check_transition_date\n") |
|
197 | PRINTF("ERR *** in action_enter_mode *** check_transition_date\n") | |
198 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, |
|
198 | send_tm_lfr_tc_exe_inconsistent( TC, queue_id, | |
199 | BYTE_POS_CP_LFR_ENTER_MODE_TIME, |
|
199 | BYTE_POS_CP_LFR_ENTER_MODE_TIME, | |
200 | bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] ); |
|
200 | bytePosPtr[ BYTE_POS_CP_LFR_ENTER_MODE_TIME + 3 ] ); | |
201 | } |
|
201 | } | |
202 | } |
|
202 | } | |
203 |
|
203 | |||
204 | if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode |
|
204 | if ( status == LFR_SUCCESSFUL ) // the date is valid, enter the mode | |
205 | { |
|
205 | { | |
206 | PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); |
|
206 | PRINTF1("OK *** in action_enter_mode *** enter mode %d\n", requestedMode); | |
207 |
|
207 | |||
208 | switch(requestedMode) |
|
208 | switch(requestedMode) | |
209 | { |
|
209 | { | |
210 | case LFR_MODE_STANDBY: |
|
210 | case LFR_MODE_STANDBY: | |
211 | status = enter_mode_standby(); |
|
211 | status = enter_mode_standby(); | |
212 | break; |
|
212 | break; | |
213 | case LFR_MODE_NORMAL: |
|
213 | case LFR_MODE_NORMAL: | |
214 | status = enter_mode_normal( transitionCoarseTime ); |
|
214 | status = enter_mode_normal( transitionCoarseTime ); | |
215 | break; |
|
215 | break; | |
216 | case LFR_MODE_BURST: |
|
216 | case LFR_MODE_BURST: | |
217 | status = enter_mode_burst( transitionCoarseTime ); |
|
217 | status = enter_mode_burst( transitionCoarseTime ); | |
218 | break; |
|
218 | break; | |
219 | case LFR_MODE_SBM1: |
|
219 | case LFR_MODE_SBM1: | |
220 | status = enter_mode_sbm1( transitionCoarseTime ); |
|
220 | status = enter_mode_sbm1( transitionCoarseTime ); | |
221 | break; |
|
221 | break; | |
222 | case LFR_MODE_SBM2: |
|
222 | case LFR_MODE_SBM2: | |
223 | status = enter_mode_sbm2( transitionCoarseTime ); |
|
223 | status = enter_mode_sbm2( transitionCoarseTime ); | |
224 | break; |
|
224 | break; | |
225 | default: |
|
225 | default: | |
226 | break; |
|
226 | break; | |
227 | } |
|
227 | } | |
228 | } |
|
228 | } | |
229 |
|
229 | |||
230 | return status; |
|
230 | return status; | |
231 | } |
|
231 | } | |
232 |
|
232 | |||
233 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
233 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
234 | { |
|
234 | { | |
235 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. |
|
235 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. | |
236 | * |
|
236 | * | |
237 | * @param TC points to the TeleCommand packet that is being processed |
|
237 | * @param TC points to the TeleCommand packet that is being processed | |
238 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
238 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
239 | * |
|
239 | * | |
240 | * @return LFR directive status code: |
|
240 | * @return LFR directive status code: | |
241 | * - LFR_DEFAULT |
|
241 | * - LFR_DEFAULT | |
242 | * - LFR_SUCCESSFUL |
|
242 | * - LFR_SUCCESSFUL | |
243 | * |
|
243 | * | |
244 | */ |
|
244 | */ | |
245 |
|
245 | |||
246 | unsigned int val; |
|
246 | unsigned int val; | |
247 | int result; |
|
247 | int result; | |
248 | unsigned int status; |
|
248 | unsigned int status; | |
249 | unsigned char mode; |
|
249 | unsigned char mode; | |
250 | unsigned char * bytePosPtr; |
|
250 | unsigned char * bytePosPtr; | |
251 |
|
251 | |||
252 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
252 | bytePosPtr = (unsigned char *) &TC->packetID; | |
253 |
|
253 | |||
254 | // check LFR mode |
|
254 | // check LFR mode | |
255 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1; |
|
255 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1; | |
256 | status = check_update_info_hk_lfr_mode( mode ); |
|
256 | status = check_update_info_hk_lfr_mode( mode ); | |
257 | if (status == LFR_SUCCESSFUL) // check TDS mode |
|
257 | if (status == LFR_SUCCESSFUL) // check TDS mode | |
258 | { |
|
258 | { | |
259 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4; |
|
259 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4; | |
260 | status = check_update_info_hk_tds_mode( mode ); |
|
260 | status = check_update_info_hk_tds_mode( mode ); | |
261 | } |
|
261 | } | |
262 | if (status == LFR_SUCCESSFUL) // check THR mode |
|
262 | if (status == LFR_SUCCESSFUL) // check THR mode | |
263 | { |
|
263 | { | |
264 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f); |
|
264 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f); | |
265 | status = check_update_info_hk_thr_mode( mode ); |
|
265 | status = check_update_info_hk_thr_mode( mode ); | |
266 | } |
|
266 | } | |
267 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful |
|
267 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful | |
268 | { |
|
268 | { | |
269 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 |
|
269 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 | |
270 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; |
|
270 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; | |
271 | val++; |
|
271 | val++; | |
272 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); |
|
272 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); | |
273 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); |
|
273 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); | |
274 | } |
|
274 | } | |
275 |
|
275 | |||
276 | // pa_bia_status_info |
|
276 | // pa_bia_status_info | |
277 | // => pa_bia_mode_mux_set 3 bits |
|
277 | // => pa_bia_mode_mux_set 3 bits | |
278 | // => pa_bia_mode_hv_enabled 1 bit |
|
278 | // => pa_bia_mode_hv_enabled 1 bit | |
279 | // => pa_bia_mode_bias1_enabled 1 bit |
|
279 | // => pa_bia_mode_bias1_enabled 1 bit | |
280 | // => pa_bia_mode_bias2_enabled 1 bit |
|
280 | // => pa_bia_mode_bias2_enabled 1 bit | |
281 | // => pa_bia_mode_bias3_enabled 1 bit |
|
281 | // => pa_bia_mode_bias3_enabled 1 bit | |
282 | // => pa_bia_on_off (cp_dpu_bias_on_off) |
|
282 | // => pa_bia_on_off (cp_dpu_bias_on_off) | |
283 | pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & 0xfe; // [1111 1110] |
|
283 | pa_bia_status_info = bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET2 ] & 0xfe; // [1111 1110] | |
284 | pa_bia_status_info = pa_bia_status_info |
|
284 | pa_bia_status_info = pa_bia_status_info | |
285 | | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1); |
|
285 | | (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET1 ] & 0x1); | |
286 |
|
286 | |||
287 | result = status; |
|
287 | result = status; | |
288 |
|
288 | |||
289 | return result; |
|
289 | return result; | |
290 | } |
|
290 | } | |
291 |
|
291 | |||
292 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
292 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
293 | { |
|
293 | { | |
294 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. |
|
294 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. | |
295 | * |
|
295 | * | |
296 | * @param TC points to the TeleCommand packet that is being processed |
|
296 | * @param TC points to the TeleCommand packet that is being processed | |
297 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
297 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
298 | * |
|
298 | * | |
299 | */ |
|
299 | */ | |
300 |
|
300 | |||
301 | int result; |
|
301 | int result; | |
302 |
|
302 | |||
303 | result = LFR_DEFAULT; |
|
303 | result = LFR_DEFAULT; | |
304 |
|
304 | |||
305 | setCalibration( true ); |
|
305 | setCalibration( true ); | |
306 |
|
306 | |||
307 | result = LFR_SUCCESSFUL; |
|
307 | result = LFR_SUCCESSFUL; | |
308 |
|
308 | |||
309 | return result; |
|
309 | return result; | |
310 | } |
|
310 | } | |
311 |
|
311 | |||
312 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
312 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
313 | { |
|
313 | { | |
314 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. |
|
314 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. | |
315 | * |
|
315 | * | |
316 | * @param TC points to the TeleCommand packet that is being processed |
|
316 | * @param TC points to the TeleCommand packet that is being processed | |
317 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
317 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
318 | * |
|
318 | * | |
319 | */ |
|
319 | */ | |
320 |
|
320 | |||
321 | int result; |
|
321 | int result; | |
322 |
|
322 | |||
323 | result = LFR_DEFAULT; |
|
323 | result = LFR_DEFAULT; | |
324 |
|
324 | |||
325 | setCalibration( false ); |
|
325 | setCalibration( false ); | |
326 |
|
326 | |||
327 | result = LFR_SUCCESSFUL; |
|
327 | result = LFR_SUCCESSFUL; | |
328 |
|
328 | |||
329 | return result; |
|
329 | return result; | |
330 | } |
|
330 | } | |
331 |
|
331 | |||
332 | int action_update_time(ccsdsTelecommandPacket_t *TC) |
|
332 | int action_update_time(ccsdsTelecommandPacket_t *TC) | |
333 | { |
|
333 | { | |
334 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. |
|
334 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. | |
335 | * |
|
335 | * | |
336 | * @param TC points to the TeleCommand packet that is being processed |
|
336 | * @param TC points to the TeleCommand packet that is being processed | |
337 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
337 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
338 | * |
|
338 | * | |
339 | * @return LFR_SUCCESSFUL |
|
339 | * @return LFR_SUCCESSFUL | |
340 | * |
|
340 | * | |
341 | */ |
|
341 | */ | |
342 |
|
342 | |||
343 | unsigned int val; |
|
343 | unsigned int val; | |
344 |
|
344 | |||
345 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) |
|
345 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) | |
346 | + (TC->dataAndCRC[1] << 16) |
|
346 | + (TC->dataAndCRC[1] << 16) | |
347 | + (TC->dataAndCRC[2] << 8) |
|
347 | + (TC->dataAndCRC[2] << 8) | |
348 | + TC->dataAndCRC[3]; |
|
348 | + TC->dataAndCRC[3]; | |
349 |
|
349 | |||
350 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 |
|
350 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 | |
351 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; |
|
351 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; | |
352 | val++; |
|
352 | val++; | |
353 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); |
|
353 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); | |
354 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); |
|
354 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); | |
355 |
|
355 | |||
356 | return LFR_SUCCESSFUL; |
|
356 | return LFR_SUCCESSFUL; | |
357 | } |
|
357 | } | |
358 |
|
358 | |||
359 | //******************* |
|
359 | //******************* | |
360 | // ENTERING THE MODES |
|
360 | // ENTERING THE MODES | |
361 | int check_mode_value( unsigned char requestedMode ) |
|
361 | int check_mode_value( unsigned char requestedMode ) | |
362 | { |
|
362 | { | |
363 | int status; |
|
363 | int status; | |
364 |
|
364 | |||
365 | if ( (requestedMode != LFR_MODE_STANDBY) |
|
365 | if ( (requestedMode != LFR_MODE_STANDBY) | |
366 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) |
|
366 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) | |
367 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) |
|
367 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) | |
368 | { |
|
368 | { | |
369 | status = LFR_DEFAULT; |
|
369 | status = LFR_DEFAULT; | |
370 | } |
|
370 | } | |
371 | else |
|
371 | else | |
372 | { |
|
372 | { | |
373 | status = LFR_SUCCESSFUL; |
|
373 | status = LFR_SUCCESSFUL; | |
374 | } |
|
374 | } | |
375 |
|
375 | |||
376 | return status; |
|
376 | return status; | |
377 | } |
|
377 | } | |
378 |
|
378 | |||
379 | int check_mode_transition( unsigned char requestedMode ) |
|
379 | int check_mode_transition( unsigned char requestedMode ) | |
380 | { |
|
380 | { | |
381 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. |
|
381 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. | |
382 | * |
|
382 | * | |
383 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE |
|
383 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE | |
384 | * |
|
384 | * | |
385 | * @return LFR directive status codes: |
|
385 | * @return LFR directive status codes: | |
386 | * - LFR_SUCCESSFUL - the transition is authorized |
|
386 | * - LFR_SUCCESSFUL - the transition is authorized | |
387 | * - LFR_DEFAULT - the transition is not authorized |
|
387 | * - LFR_DEFAULT - the transition is not authorized | |
388 | * |
|
388 | * | |
389 | */ |
|
389 | */ | |
390 |
|
390 | |||
391 | int status; |
|
391 | int status; | |
392 |
|
392 | |||
393 | switch (requestedMode) |
|
393 | switch (requestedMode) | |
394 | { |
|
394 | { | |
395 | case LFR_MODE_STANDBY: |
|
395 | case LFR_MODE_STANDBY: | |
396 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { |
|
396 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { | |
397 | status = LFR_DEFAULT; |
|
397 | status = LFR_DEFAULT; | |
398 | } |
|
398 | } | |
399 | else |
|
399 | else | |
400 | { |
|
400 | { | |
401 | status = LFR_SUCCESSFUL; |
|
401 | status = LFR_SUCCESSFUL; | |
402 | } |
|
402 | } | |
403 | break; |
|
403 | break; | |
404 | case LFR_MODE_NORMAL: |
|
404 | case LFR_MODE_NORMAL: | |
405 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { |
|
405 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { | |
406 | status = LFR_DEFAULT; |
|
406 | status = LFR_DEFAULT; | |
407 | } |
|
407 | } | |
408 | else { |
|
408 | else { | |
409 | status = LFR_SUCCESSFUL; |
|
409 | status = LFR_SUCCESSFUL; | |
410 | } |
|
410 | } | |
411 | break; |
|
411 | break; | |
412 | case LFR_MODE_BURST: |
|
412 | case LFR_MODE_BURST: | |
413 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
413 | if ( lfrCurrentMode == LFR_MODE_BURST ) { | |
414 | status = LFR_DEFAULT; |
|
414 | status = LFR_DEFAULT; | |
415 | } |
|
415 | } | |
416 | else { |
|
416 | else { | |
417 | status = LFR_SUCCESSFUL; |
|
417 | status = LFR_SUCCESSFUL; | |
418 | } |
|
418 | } | |
419 | break; |
|
419 | break; | |
420 | case LFR_MODE_SBM1: |
|
420 | case LFR_MODE_SBM1: | |
421 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
421 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { | |
422 | status = LFR_DEFAULT; |
|
422 | status = LFR_DEFAULT; | |
423 | } |
|
423 | } | |
424 | else { |
|
424 | else { | |
425 | status = LFR_SUCCESSFUL; |
|
425 | status = LFR_SUCCESSFUL; | |
426 | } |
|
426 | } | |
427 | break; |
|
427 | break; | |
428 | case LFR_MODE_SBM2: |
|
428 | case LFR_MODE_SBM2: | |
429 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
429 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { | |
430 | status = LFR_DEFAULT; |
|
430 | status = LFR_DEFAULT; | |
431 | } |
|
431 | } | |
432 | else { |
|
432 | else { | |
433 | status = LFR_SUCCESSFUL; |
|
433 | status = LFR_SUCCESSFUL; | |
434 | } |
|
434 | } | |
435 | break; |
|
435 | break; | |
436 | default: |
|
436 | default: | |
437 | status = LFR_DEFAULT; |
|
437 | status = LFR_DEFAULT; | |
438 | break; |
|
438 | break; | |
439 | } |
|
439 | } | |
440 |
|
440 | |||
441 | return status; |
|
441 | return status; | |
442 | } |
|
442 | } | |
443 |
|
443 | |||
444 | int check_transition_date( unsigned int transitionCoarseTime ) |
|
444 | int check_transition_date( unsigned int transitionCoarseTime ) | |
445 | { |
|
445 | { | |
446 | int status; |
|
446 | int status; | |
447 | unsigned int localCoarseTime; |
|
447 | unsigned int localCoarseTime; | |
448 | unsigned int deltaCoarseTime; |
|
448 | unsigned int deltaCoarseTime; | |
449 |
|
449 | |||
450 | status = LFR_SUCCESSFUL; |
|
450 | status = LFR_SUCCESSFUL; | |
451 |
|
451 | |||
452 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition |
|
452 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition | |
453 | { |
|
453 | { | |
454 | status = LFR_SUCCESSFUL; |
|
454 | status = LFR_SUCCESSFUL; | |
455 | } |
|
455 | } | |
456 | else |
|
456 | else | |
457 | { |
|
457 | { | |
458 | localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; |
|
458 | localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; | |
459 |
|
459 | |||
460 | PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime) |
|
460 | PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime) | |
461 |
|
461 | |||
462 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 |
|
462 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 | |
463 | { |
|
463 | { | |
464 | status = LFR_DEFAULT; |
|
464 | status = LFR_DEFAULT; | |
465 | PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n") |
|
465 | PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n") | |
466 | } |
|
466 | } | |
467 |
|
467 | |||
468 | if (status == LFR_SUCCESSFUL) |
|
468 | if (status == LFR_SUCCESSFUL) | |
469 | { |
|
469 | { | |
470 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; |
|
470 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; | |
471 | if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323 |
|
471 | if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323 | |
472 | { |
|
472 | { | |
473 | status = LFR_DEFAULT; |
|
473 | status = LFR_DEFAULT; | |
474 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) |
|
474 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) | |
475 | } |
|
475 | } | |
476 | } |
|
476 | } | |
477 | } |
|
477 | } | |
478 |
|
478 | |||
479 | return status; |
|
479 | return status; | |
480 | } |
|
480 | } | |
481 |
|
481 | |||
482 | int restart_asm_activities( unsigned char lfrRequestedMode ) |
|
482 | int restart_asm_activities( unsigned char lfrRequestedMode ) | |
483 | { |
|
483 | { | |
484 | rtems_status_code status; |
|
484 | rtems_status_code status; | |
485 |
|
485 | |||
486 | status = stop_spectral_matrices(); |
|
486 | status = stop_spectral_matrices(); | |
487 |
|
487 | |||
488 | status = restart_asm_tasks( lfrRequestedMode ); |
|
488 | status = restart_asm_tasks( lfrRequestedMode ); | |
489 |
|
489 | |||
490 | launch_spectral_matrix(); |
|
490 | launch_spectral_matrix(); | |
491 |
|
491 | |||
492 | return status; |
|
492 | return status; | |
493 | } |
|
493 | } | |
494 |
|
494 | |||
495 | int stop_spectral_matrices( void ) |
|
495 | int stop_spectral_matrices( void ) | |
496 | { |
|
496 | { | |
497 | /** This function stops and restarts the current mode average spectral matrices activities. |
|
497 | /** This function stops and restarts the current mode average spectral matrices activities. | |
498 | * |
|
498 | * | |
499 | * @return RTEMS directive status codes: |
|
499 | * @return RTEMS directive status codes: | |
500 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
500 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
501 | * - RTEMS_INVALID_ID - task id invalid |
|
501 | * - RTEMS_INVALID_ID - task id invalid | |
502 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
502 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
503 | * |
|
503 | * | |
504 | */ |
|
504 | */ | |
505 |
|
505 | |||
506 | rtems_status_code status; |
|
506 | rtems_status_code status; | |
507 |
|
507 | |||
508 | status = RTEMS_SUCCESSFUL; |
|
508 | status = RTEMS_SUCCESSFUL; | |
509 |
|
509 | |||
510 | // (1) mask interruptions |
|
510 | // (1) mask interruptions | |
511 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
511 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
512 |
|
512 | |||
513 | // (2) reset spectral matrices registers |
|
513 | // (2) reset spectral matrices registers | |
514 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices |
|
514 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices | |
515 | reset_sm_status(); |
|
515 | reset_sm_status(); | |
516 |
|
516 | |||
517 | // (3) clear interruptions |
|
517 | // (3) clear interruptions | |
518 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
518 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
519 |
|
519 | |||
520 | // suspend several tasks |
|
520 | // suspend several tasks | |
521 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
521 | if (lfrCurrentMode != LFR_MODE_STANDBY) { | |
522 | status = suspend_asm_tasks(); |
|
522 | status = suspend_asm_tasks(); | |
523 | } |
|
523 | } | |
524 |
|
524 | |||
525 | if (status != RTEMS_SUCCESSFUL) |
|
525 | if (status != RTEMS_SUCCESSFUL) | |
526 | { |
|
526 | { | |
527 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
527 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) | |
528 | } |
|
528 | } | |
529 |
|
529 | |||
530 | return status; |
|
530 | return status; | |
531 | } |
|
531 | } | |
532 |
|
532 | |||
533 | int stop_current_mode( void ) |
|
533 | int stop_current_mode( void ) | |
534 | { |
|
534 | { | |
535 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. |
|
535 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. | |
536 | * |
|
536 | * | |
537 | * @return RTEMS directive status codes: |
|
537 | * @return RTEMS directive status codes: | |
538 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
538 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
539 | * - RTEMS_INVALID_ID - task id invalid |
|
539 | * - RTEMS_INVALID_ID - task id invalid | |
540 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
540 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
541 | * |
|
541 | * | |
542 | */ |
|
542 | */ | |
543 |
|
543 | |||
544 | rtems_status_code status; |
|
544 | rtems_status_code status; | |
545 |
|
545 | |||
546 | status = RTEMS_SUCCESSFUL; |
|
546 | status = RTEMS_SUCCESSFUL; | |
547 |
|
547 | |||
548 | // (1) mask interruptions |
|
548 | // (1) mask interruptions | |
549 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt |
|
549 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt | |
550 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
550 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
551 |
|
551 | |||
552 | // (2) reset waveform picker registers |
|
552 | // (2) reset waveform picker registers | |
553 | reset_wfp_burst_enable(); // reset burst and enable bits |
|
553 | reset_wfp_burst_enable(); // reset burst and enable bits | |
554 | reset_wfp_status(); // reset all the status bits |
|
554 | reset_wfp_status(); // reset all the status bits | |
555 |
|
555 | |||
556 | // (3) reset spectral matrices registers |
|
556 | // (3) reset spectral matrices registers | |
557 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices |
|
557 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices | |
558 | reset_sm_status(); |
|
558 | reset_sm_status(); | |
559 |
|
559 | |||
560 | // reset lfr VHDL module |
|
560 | // reset lfr VHDL module | |
561 | reset_lfr(); |
|
561 | reset_lfr(); | |
562 |
|
562 | |||
563 | reset_extractSWF(); // reset the extractSWF flag to false |
|
563 | reset_extractSWF(); // reset the extractSWF flag to false | |
564 |
|
564 | |||
565 | // (4) clear interruptions |
|
565 | // (4) clear interruptions | |
566 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt |
|
566 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt | |
567 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
567 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
568 |
|
568 | |||
569 | // <Spectral Matrices simulator> |
|
|||
570 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator |
|
|||
571 | timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
|||
572 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator |
|
|||
573 | // </Spectral Matrices simulator> |
|
|||
574 |
|
||||
575 | // suspend several tasks |
|
569 | // suspend several tasks | |
576 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
570 | if (lfrCurrentMode != LFR_MODE_STANDBY) { | |
577 | status = suspend_science_tasks(); |
|
571 | status = suspend_science_tasks(); | |
578 | } |
|
572 | } | |
579 |
|
573 | |||
580 | if (status != RTEMS_SUCCESSFUL) |
|
574 | if (status != RTEMS_SUCCESSFUL) | |
581 | { |
|
575 | { | |
582 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
576 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) | |
583 | } |
|
577 | } | |
584 |
|
578 | |||
585 | return status; |
|
579 | return status; | |
586 | } |
|
580 | } | |
587 |
|
581 | |||
588 | int enter_mode_standby() |
|
582 | int enter_mode_standby() | |
589 | { |
|
583 | { | |
590 | int status; |
|
584 | int status; | |
591 |
|
585 | |||
592 | status = stop_current_mode(); // STOP THE CURRENT MODE |
|
586 | status = stop_current_mode(); // STOP THE CURRENT MODE | |
593 |
|
587 | |||
594 | #ifdef PRINT_TASK_STATISTICS |
|
588 | #ifdef PRINT_TASK_STATISTICS | |
595 | rtems_cpu_usage_report(); |
|
589 | rtems_cpu_usage_report(); | |
596 | #endif |
|
590 | #endif | |
597 |
|
591 | |||
598 | #ifdef PRINT_STACK_REPORT |
|
592 | #ifdef PRINT_STACK_REPORT | |
599 | PRINTF("stack report selected\n") |
|
593 | PRINTF("stack report selected\n") | |
600 | rtems_stack_checker_report_usage(); |
|
594 | rtems_stack_checker_report_usage(); | |
601 | #endif |
|
595 | #endif | |
602 |
|
596 | |||
603 | return status; |
|
597 | return status; | |
604 | } |
|
598 | } | |
605 |
|
599 | |||
606 | int enter_mode_normal( unsigned int transitionCoarseTime ) |
|
600 | int enter_mode_normal( unsigned int transitionCoarseTime ) | |
607 | { |
|
601 | { | |
608 | int status; |
|
602 | int status; | |
609 |
|
603 | |||
610 | #ifdef PRINT_TASK_STATISTICS |
|
604 | #ifdef PRINT_TASK_STATISTICS | |
611 | rtems_cpu_usage_reset(); |
|
605 | rtems_cpu_usage_reset(); | |
612 | #endif |
|
606 | #endif | |
613 |
|
607 | |||
614 | status = RTEMS_UNSATISFIED; |
|
608 | status = RTEMS_UNSATISFIED; | |
615 |
|
609 | |||
616 | switch( lfrCurrentMode ) |
|
610 | switch( lfrCurrentMode ) | |
617 | { |
|
611 | { | |
618 | case LFR_MODE_STANDBY: |
|
612 | case LFR_MODE_STANDBY: | |
619 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart science tasks |
|
613 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart science tasks | |
620 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
614 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
621 | { |
|
615 | { | |
622 | launch_spectral_matrix( ); |
|
616 | launch_spectral_matrix( ); | |
623 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); |
|
617 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); | |
624 | } |
|
618 | } | |
625 | break; |
|
619 | break; | |
626 | case LFR_MODE_BURST: |
|
620 | case LFR_MODE_BURST: | |
627 | status = stop_current_mode(); // stop the current mode |
|
621 | status = stop_current_mode(); // stop the current mode | |
628 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart the science tasks |
|
622 | status = restart_science_tasks( LFR_MODE_NORMAL ); // restart the science tasks | |
629 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
623 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
630 | { |
|
624 | { | |
631 | launch_spectral_matrix( ); |
|
625 | launch_spectral_matrix( ); | |
632 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); |
|
626 | launch_waveform_picker( LFR_MODE_NORMAL, transitionCoarseTime ); | |
633 | } |
|
627 | } | |
634 | break; |
|
628 | break; | |
635 | case LFR_MODE_SBM1: |
|
629 | case LFR_MODE_SBM1: | |
636 | restart_asm_activities( LFR_MODE_NORMAL ); |
|
630 | restart_asm_activities( LFR_MODE_NORMAL ); | |
637 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
631 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
638 | break; |
|
632 | break; | |
639 | case LFR_MODE_SBM2: |
|
633 | case LFR_MODE_SBM2: | |
640 | restart_asm_activities( LFR_MODE_NORMAL ); |
|
634 | restart_asm_activities( LFR_MODE_NORMAL ); | |
641 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
635 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
642 | break; |
|
636 | break; | |
643 | default: |
|
637 | default: | |
644 | break; |
|
638 | break; | |
645 | } |
|
639 | } | |
646 |
|
640 | |||
647 | if (status != RTEMS_SUCCESSFUL) |
|
641 | if (status != RTEMS_SUCCESSFUL) | |
648 | { |
|
642 | { | |
649 | PRINTF1("ERR *** in enter_mode_normal *** status = %d\n", status) |
|
643 | PRINTF1("ERR *** in enter_mode_normal *** status = %d\n", status) | |
650 | status = RTEMS_UNSATISFIED; |
|
644 | status = RTEMS_UNSATISFIED; | |
651 | } |
|
645 | } | |
652 |
|
646 | |||
653 | return status; |
|
647 | return status; | |
654 | } |
|
648 | } | |
655 |
|
649 | |||
656 | int enter_mode_burst( unsigned int transitionCoarseTime ) |
|
650 | int enter_mode_burst( unsigned int transitionCoarseTime ) | |
657 | { |
|
651 | { | |
658 | int status; |
|
652 | int status; | |
659 |
|
653 | |||
660 | #ifdef PRINT_TASK_STATISTICS |
|
654 | #ifdef PRINT_TASK_STATISTICS | |
661 | rtems_cpu_usage_reset(); |
|
655 | rtems_cpu_usage_reset(); | |
662 | #endif |
|
656 | #endif | |
663 |
|
657 | |||
664 | status = stop_current_mode(); // stop the current mode |
|
658 | status = stop_current_mode(); // stop the current mode | |
665 | status = restart_science_tasks( LFR_MODE_BURST ); // restart the science tasks |
|
659 | status = restart_science_tasks( LFR_MODE_BURST ); // restart the science tasks | |
666 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
660 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
667 | { |
|
661 | { | |
668 | launch_spectral_matrix( ); |
|
662 | launch_spectral_matrix( ); | |
669 | launch_waveform_picker( LFR_MODE_BURST, transitionCoarseTime ); |
|
663 | launch_waveform_picker( LFR_MODE_BURST, transitionCoarseTime ); | |
670 | } |
|
664 | } | |
671 |
|
665 | |||
672 | if (status != RTEMS_SUCCESSFUL) |
|
666 | if (status != RTEMS_SUCCESSFUL) | |
673 | { |
|
667 | { | |
674 | PRINTF1("ERR *** in enter_mode_burst *** status = %d\n", status) |
|
668 | PRINTF1("ERR *** in enter_mode_burst *** status = %d\n", status) | |
675 | status = RTEMS_UNSATISFIED; |
|
669 | status = RTEMS_UNSATISFIED; | |
676 | } |
|
670 | } | |
677 |
|
671 | |||
678 | return status; |
|
672 | return status; | |
679 | } |
|
673 | } | |
680 |
|
674 | |||
681 | int enter_mode_sbm1( unsigned int transitionCoarseTime ) |
|
675 | int enter_mode_sbm1( unsigned int transitionCoarseTime ) | |
682 | { |
|
676 | { | |
683 | int status; |
|
677 | int status; | |
684 |
|
678 | |||
685 | #ifdef PRINT_TASK_STATISTICS |
|
679 | #ifdef PRINT_TASK_STATISTICS | |
686 | rtems_cpu_usage_reset(); |
|
680 | rtems_cpu_usage_reset(); | |
687 | #endif |
|
681 | #endif | |
688 |
|
682 | |||
689 | status = RTEMS_UNSATISFIED; |
|
683 | status = RTEMS_UNSATISFIED; | |
690 |
|
684 | |||
691 | switch( lfrCurrentMode ) |
|
685 | switch( lfrCurrentMode ) | |
692 | { |
|
686 | { | |
693 | case LFR_MODE_STANDBY: |
|
687 | case LFR_MODE_STANDBY: | |
694 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart science tasks |
|
688 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart science tasks | |
695 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
689 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
696 | { |
|
690 | { | |
697 | launch_spectral_matrix( ); |
|
691 | launch_spectral_matrix( ); | |
698 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); |
|
692 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); | |
699 | } |
|
693 | } | |
700 | break; |
|
694 | break; | |
701 | case LFR_MODE_NORMAL: // lfrCurrentMode will be updated after the execution of close_action |
|
695 | case LFR_MODE_NORMAL: // lfrCurrentMode will be updated after the execution of close_action | |
702 | restart_asm_activities( LFR_MODE_SBM1 ); |
|
696 | restart_asm_activities( LFR_MODE_SBM1 ); | |
703 | status = LFR_SUCCESSFUL; |
|
697 | status = LFR_SUCCESSFUL; | |
704 | break; |
|
698 | break; | |
705 | case LFR_MODE_BURST: |
|
699 | case LFR_MODE_BURST: | |
706 | status = stop_current_mode(); // stop the current mode |
|
700 | status = stop_current_mode(); // stop the current mode | |
707 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart the science tasks |
|
701 | status = restart_science_tasks( LFR_MODE_SBM1 ); // restart the science tasks | |
708 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
702 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
709 | { |
|
703 | { | |
710 | launch_spectral_matrix( ); |
|
704 | launch_spectral_matrix( ); | |
711 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); |
|
705 | launch_waveform_picker( LFR_MODE_SBM1, transitionCoarseTime ); | |
712 | } |
|
706 | } | |
713 | break; |
|
707 | break; | |
714 | case LFR_MODE_SBM2: |
|
708 | case LFR_MODE_SBM2: | |
715 | restart_asm_activities( LFR_MODE_SBM1 ); |
|
709 | restart_asm_activities( LFR_MODE_SBM1 ); | |
716 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
710 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
717 | break; |
|
711 | break; | |
718 | default: |
|
712 | default: | |
719 | break; |
|
713 | break; | |
720 | } |
|
714 | } | |
721 |
|
715 | |||
722 | if (status != RTEMS_SUCCESSFUL) |
|
716 | if (status != RTEMS_SUCCESSFUL) | |
723 | { |
|
717 | { | |
724 | PRINTF1("ERR *** in enter_mode_sbm1 *** status = %d\n", status) |
|
718 | PRINTF1("ERR *** in enter_mode_sbm1 *** status = %d\n", status) | |
725 | status = RTEMS_UNSATISFIED; |
|
719 | status = RTEMS_UNSATISFIED; | |
726 | } |
|
720 | } | |
727 |
|
721 | |||
728 | return status; |
|
722 | return status; | |
729 | } |
|
723 | } | |
730 |
|
724 | |||
731 | int enter_mode_sbm2( unsigned int transitionCoarseTime ) |
|
725 | int enter_mode_sbm2( unsigned int transitionCoarseTime ) | |
732 | { |
|
726 | { | |
733 | int status; |
|
727 | int status; | |
734 |
|
728 | |||
735 | #ifdef PRINT_TASK_STATISTICS |
|
729 | #ifdef PRINT_TASK_STATISTICS | |
736 | rtems_cpu_usage_reset(); |
|
730 | rtems_cpu_usage_reset(); | |
737 | #endif |
|
731 | #endif | |
738 |
|
732 | |||
739 | status = RTEMS_UNSATISFIED; |
|
733 | status = RTEMS_UNSATISFIED; | |
740 |
|
734 | |||
741 | switch( lfrCurrentMode ) |
|
735 | switch( lfrCurrentMode ) | |
742 | { |
|
736 | { | |
743 | case LFR_MODE_STANDBY: |
|
737 | case LFR_MODE_STANDBY: | |
744 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart science tasks |
|
738 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart science tasks | |
745 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
739 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
746 | { |
|
740 | { | |
747 | launch_spectral_matrix( ); |
|
741 | launch_spectral_matrix( ); | |
748 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); |
|
742 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); | |
749 | } |
|
743 | } | |
750 | break; |
|
744 | break; | |
751 | case LFR_MODE_NORMAL: |
|
745 | case LFR_MODE_NORMAL: | |
752 | restart_asm_activities( LFR_MODE_SBM2 ); |
|
746 | restart_asm_activities( LFR_MODE_SBM2 ); | |
753 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
747 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
754 | break; |
|
748 | break; | |
755 | case LFR_MODE_BURST: |
|
749 | case LFR_MODE_BURST: | |
756 | status = stop_current_mode(); // stop the current mode |
|
750 | status = stop_current_mode(); // stop the current mode | |
757 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart the science tasks |
|
751 | status = restart_science_tasks( LFR_MODE_SBM2 ); // restart the science tasks | |
758 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules |
|
752 | if (status == RTEMS_SUCCESSFUL) // relaunch spectral_matrix and waveform_picker modules | |
759 | { |
|
753 | { | |
760 | launch_spectral_matrix( ); |
|
754 | launch_spectral_matrix( ); | |
761 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); |
|
755 | launch_waveform_picker( LFR_MODE_SBM2, transitionCoarseTime ); | |
762 | } |
|
756 | } | |
763 | break; |
|
757 | break; | |
764 | case LFR_MODE_SBM1: |
|
758 | case LFR_MODE_SBM1: | |
765 | restart_asm_activities( LFR_MODE_SBM2 ); |
|
759 | restart_asm_activities( LFR_MODE_SBM2 ); | |
766 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action |
|
760 | status = LFR_SUCCESSFUL; // lfrCurrentMode will be updated after the execution of close_action | |
767 | break; |
|
761 | break; | |
768 | default: |
|
762 | default: | |
769 | break; |
|
763 | break; | |
770 | } |
|
764 | } | |
771 |
|
765 | |||
772 | if (status != RTEMS_SUCCESSFUL) |
|
766 | if (status != RTEMS_SUCCESSFUL) | |
773 | { |
|
767 | { | |
774 | PRINTF1("ERR *** in enter_mode_sbm2 *** status = %d\n", status) |
|
768 | PRINTF1("ERR *** in enter_mode_sbm2 *** status = %d\n", status) | |
775 | status = RTEMS_UNSATISFIED; |
|
769 | status = RTEMS_UNSATISFIED; | |
776 | } |
|
770 | } | |
777 |
|
771 | |||
778 | return status; |
|
772 | return status; | |
779 | } |
|
773 | } | |
780 |
|
774 | |||
781 | int restart_science_tasks( unsigned char lfrRequestedMode ) |
|
775 | int restart_science_tasks( unsigned char lfrRequestedMode ) | |
782 | { |
|
776 | { | |
783 | /** This function is used to restart all science tasks. |
|
777 | /** This function is used to restart all science tasks. | |
784 | * |
|
778 | * | |
785 | * @return RTEMS directive status codes: |
|
779 | * @return RTEMS directive status codes: | |
786 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
780 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
787 | * - RTEMS_INVALID_ID - task id invalid |
|
781 | * - RTEMS_INVALID_ID - task id invalid | |
788 | * - RTEMS_INCORRECT_STATE - task never started |
|
782 | * - RTEMS_INCORRECT_STATE - task never started | |
789 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
783 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
790 | * |
|
784 | * | |
791 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 |
|
785 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 | |
792 | * |
|
786 | * | |
793 | */ |
|
787 | */ | |
794 |
|
788 | |||
795 | rtems_status_code status[10]; |
|
789 | rtems_status_code status[10]; | |
796 | rtems_status_code ret; |
|
790 | rtems_status_code ret; | |
797 |
|
791 | |||
798 | ret = RTEMS_SUCCESSFUL; |
|
792 | ret = RTEMS_SUCCESSFUL; | |
799 |
|
793 | |||
800 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); |
|
794 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); | |
801 | if (status[0] != RTEMS_SUCCESSFUL) |
|
795 | if (status[0] != RTEMS_SUCCESSFUL) | |
802 | { |
|
796 | { | |
803 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) |
|
797 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) | |
804 | } |
|
798 | } | |
805 |
|
799 | |||
806 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); |
|
800 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); | |
807 | if (status[1] != RTEMS_SUCCESSFUL) |
|
801 | if (status[1] != RTEMS_SUCCESSFUL) | |
808 | { |
|
802 | { | |
809 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) |
|
803 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) | |
810 | } |
|
804 | } | |
811 |
|
805 | |||
812 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); |
|
806 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); | |
813 | if (status[2] != RTEMS_SUCCESSFUL) |
|
807 | if (status[2] != RTEMS_SUCCESSFUL) | |
814 | { |
|
808 | { | |
815 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2]) |
|
809 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2]) | |
816 | } |
|
810 | } | |
817 |
|
811 | |||
818 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); |
|
812 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); | |
819 | if (status[3] != RTEMS_SUCCESSFUL) |
|
813 | if (status[3] != RTEMS_SUCCESSFUL) | |
820 | { |
|
814 | { | |
821 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3]) |
|
815 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3]) | |
822 | } |
|
816 | } | |
823 |
|
817 | |||
824 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); |
|
818 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); | |
825 | if (status[4] != RTEMS_SUCCESSFUL) |
|
819 | if (status[4] != RTEMS_SUCCESSFUL) | |
826 | { |
|
820 | { | |
827 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4]) |
|
821 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4]) | |
828 | } |
|
822 | } | |
829 |
|
823 | |||
830 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); |
|
824 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); | |
831 | if (status[5] != RTEMS_SUCCESSFUL) |
|
825 | if (status[5] != RTEMS_SUCCESSFUL) | |
832 | { |
|
826 | { | |
833 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5]) |
|
827 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5]) | |
834 | } |
|
828 | } | |
835 |
|
829 | |||
836 | status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); |
|
830 | status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); | |
837 | if (status[6] != RTEMS_SUCCESSFUL) |
|
831 | if (status[6] != RTEMS_SUCCESSFUL) | |
838 | { |
|
832 | { | |
839 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6]) |
|
833 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6]) | |
840 | } |
|
834 | } | |
841 |
|
835 | |||
842 | status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); |
|
836 | status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); | |
843 | if (status[7] != RTEMS_SUCCESSFUL) |
|
837 | if (status[7] != RTEMS_SUCCESSFUL) | |
844 | { |
|
838 | { | |
845 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7]) |
|
839 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7]) | |
846 | } |
|
840 | } | |
847 |
|
841 | |||
848 | status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); |
|
842 | status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); | |
849 | if (status[8] != RTEMS_SUCCESSFUL) |
|
843 | if (status[8] != RTEMS_SUCCESSFUL) | |
850 | { |
|
844 | { | |
851 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8]) |
|
845 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8]) | |
852 | } |
|
846 | } | |
853 |
|
847 | |||
854 | status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); |
|
848 | status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); | |
855 | if (status[9] != RTEMS_SUCCESSFUL) |
|
849 | if (status[9] != RTEMS_SUCCESSFUL) | |
856 | { |
|
850 | { | |
857 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9]) |
|
851 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9]) | |
858 | } |
|
852 | } | |
859 |
|
853 | |||
860 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || |
|
854 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || | |
861 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || |
|
855 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || | |
862 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) || |
|
856 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) || | |
863 | (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) || |
|
857 | (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) || | |
864 | (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) ) |
|
858 | (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) ) | |
865 | { |
|
859 | { | |
866 | ret = RTEMS_UNSATISFIED; |
|
860 | ret = RTEMS_UNSATISFIED; | |
867 | } |
|
861 | } | |
868 |
|
862 | |||
869 | return ret; |
|
863 | return ret; | |
870 | } |
|
864 | } | |
871 |
|
865 | |||
872 | int restart_asm_tasks( unsigned char lfrRequestedMode ) |
|
866 | int restart_asm_tasks( unsigned char lfrRequestedMode ) | |
873 | { |
|
867 | { | |
874 | /** This function is used to restart average spectral matrices tasks. |
|
868 | /** This function is used to restart average spectral matrices tasks. | |
875 | * |
|
869 | * | |
876 | * @return RTEMS directive status codes: |
|
870 | * @return RTEMS directive status codes: | |
877 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
871 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
878 | * - RTEMS_INVALID_ID - task id invalid |
|
872 | * - RTEMS_INVALID_ID - task id invalid | |
879 | * - RTEMS_INCORRECT_STATE - task never started |
|
873 | * - RTEMS_INCORRECT_STATE - task never started | |
880 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
874 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
881 | * |
|
875 | * | |
882 | * ASM tasks are AVF0, PRC0, AVF1, PRC1, AVF2 and PRC2 |
|
876 | * ASM tasks are AVF0, PRC0, AVF1, PRC1, AVF2 and PRC2 | |
883 | * |
|
877 | * | |
884 | */ |
|
878 | */ | |
885 |
|
879 | |||
886 | rtems_status_code status[6]; |
|
880 | rtems_status_code status[6]; | |
887 | rtems_status_code ret; |
|
881 | rtems_status_code ret; | |
888 |
|
882 | |||
889 | ret = RTEMS_SUCCESSFUL; |
|
883 | ret = RTEMS_SUCCESSFUL; | |
890 |
|
884 | |||
891 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); |
|
885 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); | |
892 | if (status[0] != RTEMS_SUCCESSFUL) |
|
886 | if (status[0] != RTEMS_SUCCESSFUL) | |
893 | { |
|
887 | { | |
894 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) |
|
888 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) | |
895 | } |
|
889 | } | |
896 |
|
890 | |||
897 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); |
|
891 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); | |
898 | if (status[1] != RTEMS_SUCCESSFUL) |
|
892 | if (status[1] != RTEMS_SUCCESSFUL) | |
899 | { |
|
893 | { | |
900 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) |
|
894 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) | |
901 | } |
|
895 | } | |
902 |
|
896 | |||
903 | status[2] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); |
|
897 | status[2] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); | |
904 | if (status[2] != RTEMS_SUCCESSFUL) |
|
898 | if (status[2] != RTEMS_SUCCESSFUL) | |
905 | { |
|
899 | { | |
906 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[2]) |
|
900 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[2]) | |
907 | } |
|
901 | } | |
908 |
|
902 | |||
909 | status[3] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); |
|
903 | status[3] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); | |
910 | if (status[3] != RTEMS_SUCCESSFUL) |
|
904 | if (status[3] != RTEMS_SUCCESSFUL) | |
911 | { |
|
905 | { | |
912 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[3]) |
|
906 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[3]) | |
913 | } |
|
907 | } | |
914 |
|
908 | |||
915 | status[4] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); |
|
909 | status[4] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); | |
916 | if (status[4] != RTEMS_SUCCESSFUL) |
|
910 | if (status[4] != RTEMS_SUCCESSFUL) | |
917 | { |
|
911 | { | |
918 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[4]) |
|
912 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[4]) | |
919 | } |
|
913 | } | |
920 |
|
914 | |||
921 | status[5] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); |
|
915 | status[5] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); | |
922 | if (status[5] != RTEMS_SUCCESSFUL) |
|
916 | if (status[5] != RTEMS_SUCCESSFUL) | |
923 | { |
|
917 | { | |
924 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[5]) |
|
918 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[5]) | |
925 | } |
|
919 | } | |
926 |
|
920 | |||
927 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || |
|
921 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || | |
928 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || |
|
922 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || | |
929 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ) |
|
923 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) ) | |
930 | { |
|
924 | { | |
931 | ret = RTEMS_UNSATISFIED; |
|
925 | ret = RTEMS_UNSATISFIED; | |
932 | } |
|
926 | } | |
933 |
|
927 | |||
934 | return ret; |
|
928 | return ret; | |
935 | } |
|
929 | } | |
936 |
|
930 | |||
937 | int suspend_science_tasks( void ) |
|
931 | int suspend_science_tasks( void ) | |
938 | { |
|
932 | { | |
939 | /** This function suspends the science tasks. |
|
933 | /** This function suspends the science tasks. | |
940 | * |
|
934 | * | |
941 | * @return RTEMS directive status codes: |
|
935 | * @return RTEMS directive status codes: | |
942 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
936 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
943 | * - RTEMS_INVALID_ID - task id invalid |
|
937 | * - RTEMS_INVALID_ID - task id invalid | |
944 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
938 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
945 | * |
|
939 | * | |
946 | */ |
|
940 | */ | |
947 |
|
941 | |||
948 | rtems_status_code status; |
|
942 | rtems_status_code status; | |
949 |
|
943 | |||
950 | PRINTF("in suspend_science_tasks\n") |
|
944 | PRINTF("in suspend_science_tasks\n") | |
951 |
|
945 | |||
952 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 |
|
946 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 | |
953 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
947 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
954 | { |
|
948 | { | |
955 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
949 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) | |
956 | } |
|
950 | } | |
957 | else |
|
951 | else | |
958 | { |
|
952 | { | |
959 | status = RTEMS_SUCCESSFUL; |
|
953 | status = RTEMS_SUCCESSFUL; | |
960 | } |
|
954 | } | |
961 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 |
|
955 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 | |
962 | { |
|
956 | { | |
963 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); |
|
957 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); | |
964 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
958 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
965 | { |
|
959 | { | |
966 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) |
|
960 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) | |
967 | } |
|
961 | } | |
968 | else |
|
962 | else | |
969 | { |
|
963 | { | |
970 | status = RTEMS_SUCCESSFUL; |
|
964 | status = RTEMS_SUCCESSFUL; | |
971 | } |
|
965 | } | |
972 | } |
|
966 | } | |
973 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 |
|
967 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 | |
974 | { |
|
968 | { | |
975 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); |
|
969 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); | |
976 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
970 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
977 | { |
|
971 | { | |
978 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) |
|
972 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) | |
979 | } |
|
973 | } | |
980 | else |
|
974 | else | |
981 | { |
|
975 | { | |
982 | status = RTEMS_SUCCESSFUL; |
|
976 | status = RTEMS_SUCCESSFUL; | |
983 | } |
|
977 | } | |
984 | } |
|
978 | } | |
985 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 |
|
979 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 | |
986 | { |
|
980 | { | |
987 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); |
|
981 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); | |
988 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
982 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
989 | { |
|
983 | { | |
990 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) |
|
984 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) | |
991 | } |
|
985 | } | |
992 | else |
|
986 | else | |
993 | { |
|
987 | { | |
994 | status = RTEMS_SUCCESSFUL; |
|
988 | status = RTEMS_SUCCESSFUL; | |
995 | } |
|
989 | } | |
996 | } |
|
990 | } | |
997 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 |
|
991 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 | |
998 | { |
|
992 | { | |
999 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); |
|
993 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); | |
1000 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
994 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1001 | { |
|
995 | { | |
1002 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) |
|
996 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) | |
1003 | } |
|
997 | } | |
1004 | else |
|
998 | else | |
1005 | { |
|
999 | { | |
1006 | status = RTEMS_SUCCESSFUL; |
|
1000 | status = RTEMS_SUCCESSFUL; | |
1007 | } |
|
1001 | } | |
1008 | } |
|
1002 | } | |
1009 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 |
|
1003 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 | |
1010 | { |
|
1004 | { | |
1011 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); |
|
1005 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); | |
1012 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1006 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1013 | { |
|
1007 | { | |
1014 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) |
|
1008 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) | |
1015 | } |
|
1009 | } | |
1016 | else |
|
1010 | else | |
1017 | { |
|
1011 | { | |
1018 | status = RTEMS_SUCCESSFUL; |
|
1012 | status = RTEMS_SUCCESSFUL; | |
1019 | } |
|
1013 | } | |
1020 | } |
|
1014 | } | |
1021 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM |
|
1015 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM | |
1022 | { |
|
1016 | { | |
1023 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); |
|
1017 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); | |
1024 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1018 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1025 | { |
|
1019 | { | |
1026 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) |
|
1020 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) | |
1027 | } |
|
1021 | } | |
1028 | else |
|
1022 | else | |
1029 | { |
|
1023 | { | |
1030 | status = RTEMS_SUCCESSFUL; |
|
1024 | status = RTEMS_SUCCESSFUL; | |
1031 | } |
|
1025 | } | |
1032 | } |
|
1026 | } | |
1033 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 |
|
1027 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 | |
1034 | { |
|
1028 | { | |
1035 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); |
|
1029 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); | |
1036 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1030 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1037 | { |
|
1031 | { | |
1038 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) |
|
1032 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) | |
1039 | } |
|
1033 | } | |
1040 | else |
|
1034 | else | |
1041 | { |
|
1035 | { | |
1042 | status = RTEMS_SUCCESSFUL; |
|
1036 | status = RTEMS_SUCCESSFUL; | |
1043 | } |
|
1037 | } | |
1044 | } |
|
1038 | } | |
1045 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 |
|
1039 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 | |
1046 | { |
|
1040 | { | |
1047 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); |
|
1041 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); | |
1048 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1042 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1049 | { |
|
1043 | { | |
1050 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) |
|
1044 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) | |
1051 | } |
|
1045 | } | |
1052 | else |
|
1046 | else | |
1053 | { |
|
1047 | { | |
1054 | status = RTEMS_SUCCESSFUL; |
|
1048 | status = RTEMS_SUCCESSFUL; | |
1055 | } |
|
1049 | } | |
1056 | } |
|
1050 | } | |
1057 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 |
|
1051 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 | |
1058 | { |
|
1052 | { | |
1059 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); |
|
1053 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); | |
1060 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1054 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1061 | { |
|
1055 | { | |
1062 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) |
|
1056 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) | |
1063 | } |
|
1057 | } | |
1064 | else |
|
1058 | else | |
1065 | { |
|
1059 | { | |
1066 | status = RTEMS_SUCCESSFUL; |
|
1060 | status = RTEMS_SUCCESSFUL; | |
1067 | } |
|
1061 | } | |
1068 | } |
|
1062 | } | |
1069 |
|
1063 | |||
1070 | return status; |
|
1064 | return status; | |
1071 | } |
|
1065 | } | |
1072 |
|
1066 | |||
1073 | int suspend_asm_tasks( void ) |
|
1067 | int suspend_asm_tasks( void ) | |
1074 | { |
|
1068 | { | |
1075 | /** This function suspends the science tasks. |
|
1069 | /** This function suspends the science tasks. | |
1076 | * |
|
1070 | * | |
1077 | * @return RTEMS directive status codes: |
|
1071 | * @return RTEMS directive status codes: | |
1078 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
1072 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
1079 | * - RTEMS_INVALID_ID - task id invalid |
|
1073 | * - RTEMS_INVALID_ID - task id invalid | |
1080 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
1074 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
1081 | * |
|
1075 | * | |
1082 | */ |
|
1076 | */ | |
1083 |
|
1077 | |||
1084 | rtems_status_code status; |
|
1078 | rtems_status_code status; | |
1085 |
|
1079 | |||
1086 | PRINTF("in suspend_science_tasks\n") |
|
1080 | PRINTF("in suspend_science_tasks\n") | |
1087 |
|
1081 | |||
1088 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 |
|
1082 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 | |
1089 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1083 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1090 | { |
|
1084 | { | |
1091 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
1085 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) | |
1092 | } |
|
1086 | } | |
1093 | else |
|
1087 | else | |
1094 | { |
|
1088 | { | |
1095 | status = RTEMS_SUCCESSFUL; |
|
1089 | status = RTEMS_SUCCESSFUL; | |
1096 | } |
|
1090 | } | |
1097 |
|
1091 | |||
1098 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 |
|
1092 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 | |
1099 | { |
|
1093 | { | |
1100 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); |
|
1094 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); | |
1101 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1095 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1102 | { |
|
1096 | { | |
1103 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) |
|
1097 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) | |
1104 | } |
|
1098 | } | |
1105 | else |
|
1099 | else | |
1106 | { |
|
1100 | { | |
1107 | status = RTEMS_SUCCESSFUL; |
|
1101 | status = RTEMS_SUCCESSFUL; | |
1108 | } |
|
1102 | } | |
1109 | } |
|
1103 | } | |
1110 |
|
1104 | |||
1111 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 |
|
1105 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 | |
1112 | { |
|
1106 | { | |
1113 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); |
|
1107 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); | |
1114 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1108 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1115 | { |
|
1109 | { | |
1116 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) |
|
1110 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) | |
1117 | } |
|
1111 | } | |
1118 | else |
|
1112 | else | |
1119 | { |
|
1113 | { | |
1120 | status = RTEMS_SUCCESSFUL; |
|
1114 | status = RTEMS_SUCCESSFUL; | |
1121 | } |
|
1115 | } | |
1122 | } |
|
1116 | } | |
1123 |
|
1117 | |||
1124 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 |
|
1118 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 | |
1125 | { |
|
1119 | { | |
1126 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); |
|
1120 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); | |
1127 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1121 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1128 | { |
|
1122 | { | |
1129 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) |
|
1123 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) | |
1130 | } |
|
1124 | } | |
1131 | else |
|
1125 | else | |
1132 | { |
|
1126 | { | |
1133 | status = RTEMS_SUCCESSFUL; |
|
1127 | status = RTEMS_SUCCESSFUL; | |
1134 | } |
|
1128 | } | |
1135 | } |
|
1129 | } | |
1136 |
|
1130 | |||
1137 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 |
|
1131 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 | |
1138 | { |
|
1132 | { | |
1139 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); |
|
1133 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); | |
1140 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1134 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1141 | { |
|
1135 | { | |
1142 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) |
|
1136 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) | |
1143 | } |
|
1137 | } | |
1144 | else |
|
1138 | else | |
1145 | { |
|
1139 | { | |
1146 | status = RTEMS_SUCCESSFUL; |
|
1140 | status = RTEMS_SUCCESSFUL; | |
1147 | } |
|
1141 | } | |
1148 | } |
|
1142 | } | |
1149 |
|
1143 | |||
1150 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 |
|
1144 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 | |
1151 | { |
|
1145 | { | |
1152 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); |
|
1146 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); | |
1153 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
1147 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
1154 | { |
|
1148 | { | |
1155 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) |
|
1149 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) | |
1156 | } |
|
1150 | } | |
1157 | else |
|
1151 | else | |
1158 | { |
|
1152 | { | |
1159 | status = RTEMS_SUCCESSFUL; |
|
1153 | status = RTEMS_SUCCESSFUL; | |
1160 | } |
|
1154 | } | |
1161 | } |
|
1155 | } | |
1162 |
|
1156 | |||
1163 | return status; |
|
1157 | return status; | |
1164 | } |
|
1158 | } | |
1165 |
|
1159 | |||
1166 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) |
|
1160 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) | |
1167 | { |
|
1161 | { | |
1168 | WFP_reset_current_ring_nodes(); |
|
1162 | WFP_reset_current_ring_nodes(); | |
1169 |
|
1163 | |||
1170 | reset_waveform_picker_regs(); |
|
1164 | reset_waveform_picker_regs(); | |
1171 |
|
1165 | |||
1172 | set_wfp_burst_enable_register( mode ); |
|
1166 | set_wfp_burst_enable_register( mode ); | |
1173 |
|
1167 | |||
1174 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
1168 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); | |
1175 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
1169 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); | |
1176 |
|
1170 | |||
1177 | if (transitionCoarseTime == 0) |
|
1171 | if (transitionCoarseTime == 0) | |
1178 | { |
|
1172 | { | |
1179 | waveform_picker_regs->start_date = time_management_regs->coarse_time; |
|
1173 | waveform_picker_regs->start_date = time_management_regs->coarse_time; | |
1180 | } |
|
1174 | } | |
1181 | else |
|
1175 | else | |
1182 | { |
|
1176 | { | |
1183 | waveform_picker_regs->start_date = transitionCoarseTime; |
|
1177 | waveform_picker_regs->start_date = transitionCoarseTime; | |
1184 | } |
|
1178 | } | |
1185 |
|
1179 | |||
1186 | } |
|
1180 | } | |
1187 |
|
1181 | |||
1188 | void launch_spectral_matrix( void ) |
|
1182 | void launch_spectral_matrix( void ) | |
1189 | { |
|
1183 | { | |
1190 | SM_reset_current_ring_nodes(); |
|
1184 | SM_reset_current_ring_nodes(); | |
1191 |
|
1185 | |||
1192 | reset_spectral_matrix_regs(); |
|
1186 | reset_spectral_matrix_regs(); | |
1193 |
|
1187 | |||
1194 | reset_nb_sm(); |
|
1188 | reset_nb_sm(); | |
1195 |
|
1189 | |||
1196 | set_sm_irq_onNewMatrix( 1 ); |
|
1190 | set_sm_irq_onNewMatrix( 1 ); | |
1197 |
|
1191 | |||
1198 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
1192 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); | |
1199 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
1193 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); | |
1200 |
|
1194 | |||
1201 | } |
|
1195 | } | |
1202 |
|
1196 | |||
1203 | void set_sm_irq_onNewMatrix( unsigned char value ) |
|
1197 | void set_sm_irq_onNewMatrix( unsigned char value ) | |
1204 | { |
|
1198 | { | |
1205 | if (value == 1) |
|
1199 | if (value == 1) | |
1206 | { |
|
1200 | { | |
1207 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; |
|
1201 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; | |
1208 | } |
|
1202 | } | |
1209 | else |
|
1203 | else | |
1210 | { |
|
1204 | { | |
1211 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 |
|
1205 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 | |
1212 | } |
|
1206 | } | |
1213 | } |
|
1207 | } | |
1214 |
|
1208 | |||
1215 | void set_sm_irq_onError( unsigned char value ) |
|
1209 | void set_sm_irq_onError( unsigned char value ) | |
1216 | { |
|
1210 | { | |
1217 | if (value == 1) |
|
1211 | if (value == 1) | |
1218 | { |
|
1212 | { | |
1219 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02; |
|
1213 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02; | |
1220 | } |
|
1214 | } | |
1221 | else |
|
1215 | else | |
1222 | { |
|
1216 | { | |
1223 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101 |
|
1217 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101 | |
1224 | } |
|
1218 | } | |
1225 | } |
|
1219 | } | |
1226 |
|
1220 | |||
1227 | //***************************** |
|
1221 | //***************************** | |
1228 | // CONFIGURE CALIBRATION SIGNAL |
|
1222 | // CONFIGURE CALIBRATION SIGNAL | |
1229 | void setCalibrationPrescaler( unsigned int prescaler ) |
|
1223 | void setCalibrationPrescaler( unsigned int prescaler ) | |
1230 | { |
|
1224 | { | |
1231 | // prescaling of the master clock (25 MHz) |
|
1225 | // prescaling of the master clock (25 MHz) | |
1232 | // master clock is divided by 2^prescaler |
|
1226 | // master clock is divided by 2^prescaler | |
1233 | time_management_regs->calPrescaler = prescaler; |
|
1227 | time_management_regs->calPrescaler = prescaler; | |
1234 | } |
|
1228 | } | |
1235 |
|
1229 | |||
1236 | void setCalibrationDivisor( unsigned int divisionFactor ) |
|
1230 | void setCalibrationDivisor( unsigned int divisionFactor ) | |
1237 | { |
|
1231 | { | |
1238 | // division of the prescaled clock by the division factor |
|
1232 | // division of the prescaled clock by the division factor | |
1239 | time_management_regs->calDivisor = divisionFactor; |
|
1233 | time_management_regs->calDivisor = divisionFactor; | |
1240 | } |
|
1234 | } | |
1241 |
|
1235 | |||
1242 | void setCalibrationData( void ){ |
|
1236 | void setCalibrationData( void ){ | |
1243 | unsigned int k; |
|
1237 | unsigned int k; | |
1244 | unsigned short data; |
|
1238 | unsigned short data; | |
1245 | float val; |
|
1239 | float val; | |
1246 | float f0; |
|
1240 | float f0; | |
1247 | float f1; |
|
1241 | float f1; | |
1248 | float fs; |
|
1242 | float fs; | |
1249 | float Ts; |
|
1243 | float Ts; | |
1250 | float scaleFactor; |
|
1244 | float scaleFactor; | |
1251 |
|
1245 | |||
1252 | f0 = 625; |
|
1246 | f0 = 625; | |
1253 | f1 = 10000; |
|
1247 | f1 = 10000; | |
1254 | fs = 160256.410; |
|
1248 | fs = 160256.410; | |
1255 | Ts = 1. / fs; |
|
1249 | Ts = 1. / fs; | |
1256 | scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV |
|
1250 | scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV | |
1257 |
|
1251 | |||
1258 | time_management_regs->calDataPtr = 0x00; |
|
1252 | time_management_regs->calDataPtr = 0x00; | |
1259 |
|
1253 | |||
1260 | // build the signal for the SCM calibration |
|
1254 | // build the signal for the SCM calibration | |
1261 | for (k=0; k<256; k++) |
|
1255 | for (k=0; k<256; k++) | |
1262 | { |
|
1256 | { | |
1263 | val = sin( 2 * pi * f0 * k * Ts ) |
|
1257 | val = sin( 2 * pi * f0 * k * Ts ) | |
1264 | + sin( 2 * pi * f1 * k * Ts ); |
|
1258 | + sin( 2 * pi * f1 * k * Ts ); | |
1265 | data = (unsigned short) ((val * scaleFactor) + 2048); |
|
1259 | data = (unsigned short) ((val * scaleFactor) + 2048); | |
1266 | time_management_regs->calData = data & 0xfff; |
|
1260 | time_management_regs->calData = data & 0xfff; | |
1267 | } |
|
1261 | } | |
1268 | } |
|
1262 | } | |
1269 |
|
1263 | |||
1270 | void setCalibrationDataInterleaved( void ){ |
|
1264 | void setCalibrationDataInterleaved( void ){ | |
1271 | unsigned int k; |
|
1265 | unsigned int k; | |
1272 | float val; |
|
1266 | float val; | |
1273 | float f0; |
|
1267 | float f0; | |
1274 | float f1; |
|
1268 | float f1; | |
1275 | float fs; |
|
1269 | float fs; | |
1276 | float Ts; |
|
1270 | float Ts; | |
1277 | unsigned short data[384]; |
|
1271 | unsigned short data[384]; | |
1278 | unsigned char *dataPtr; |
|
1272 | unsigned char *dataPtr; | |
1279 |
|
1273 | |||
1280 | f0 = 625; |
|
1274 | f0 = 625; | |
1281 | f1 = 10000; |
|
1275 | f1 = 10000; | |
1282 | fs = 240384.615; |
|
1276 | fs = 240384.615; | |
1283 | Ts = 1. / fs; |
|
1277 | Ts = 1. / fs; | |
1284 |
|
1278 | |||
1285 | time_management_regs->calDataPtr = 0x00; |
|
1279 | time_management_regs->calDataPtr = 0x00; | |
1286 |
|
1280 | |||
1287 | // build the signal for the SCM calibration |
|
1281 | // build the signal for the SCM calibration | |
1288 | for (k=0; k<384; k++) |
|
1282 | for (k=0; k<384; k++) | |
1289 | { |
|
1283 | { | |
1290 | val = sin( 2 * pi * f0 * k * Ts ) |
|
1284 | val = sin( 2 * pi * f0 * k * Ts ) | |
1291 | + sin( 2 * pi * f1 * k * Ts ); |
|
1285 | + sin( 2 * pi * f1 * k * Ts ); | |
1292 | data[k] = (unsigned short) (val * 512 + 2048); |
|
1286 | data[k] = (unsigned short) (val * 512 + 2048); | |
1293 | } |
|
1287 | } | |
1294 |
|
1288 | |||
1295 | // write the signal in interleaved mode |
|
1289 | // write the signal in interleaved mode | |
1296 | for (k=0; k<128; k++) |
|
1290 | for (k=0; k<128; k++) | |
1297 | { |
|
1291 | { | |
1298 | dataPtr = (unsigned char*) &data[k*3 + 2]; |
|
1292 | dataPtr = (unsigned char*) &data[k*3 + 2]; | |
1299 | time_management_regs->calData = (data[k*3] & 0xfff) |
|
1293 | time_management_regs->calData = (data[k*3] & 0xfff) | |
1300 | + ( (dataPtr[0] & 0x3f) << 12); |
|
1294 | + ( (dataPtr[0] & 0x3f) << 12); | |
1301 | time_management_regs->calData = (data[k*3 + 1] & 0xfff) |
|
1295 | time_management_regs->calData = (data[k*3 + 1] & 0xfff) | |
1302 | + ( (dataPtr[1] & 0x3f) << 12); |
|
1296 | + ( (dataPtr[1] & 0x3f) << 12); | |
1303 | } |
|
1297 | } | |
1304 | } |
|
1298 | } | |
1305 |
|
1299 | |||
1306 | void setCalibrationReload( bool state) |
|
1300 | void setCalibrationReload( bool state) | |
1307 | { |
|
1301 | { | |
1308 | if (state == true) |
|
1302 | if (state == true) | |
1309 | { |
|
1303 | { | |
1310 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000] |
|
1304 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000] | |
1311 | } |
|
1305 | } | |
1312 | else |
|
1306 | else | |
1313 | { |
|
1307 | { | |
1314 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111] |
|
1308 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111] | |
1315 | } |
|
1309 | } | |
1316 | } |
|
1310 | } | |
1317 |
|
1311 | |||
1318 | void setCalibrationEnable( bool state ) |
|
1312 | void setCalibrationEnable( bool state ) | |
1319 | { |
|
1313 | { | |
1320 | // this bit drives the multiplexer |
|
1314 | // this bit drives the multiplexer | |
1321 | if (state == true) |
|
1315 | if (state == true) | |
1322 | { |
|
1316 | { | |
1323 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000] |
|
1317 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000] | |
1324 | } |
|
1318 | } | |
1325 | else |
|
1319 | else | |
1326 | { |
|
1320 | { | |
1327 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111] |
|
1321 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111] | |
1328 | } |
|
1322 | } | |
1329 | } |
|
1323 | } | |
1330 |
|
1324 | |||
1331 | void setCalibrationInterleaved( bool state ) |
|
1325 | void setCalibrationInterleaved( bool state ) | |
1332 | { |
|
1326 | { | |
1333 | // this bit drives the multiplexer |
|
1327 | // this bit drives the multiplexer | |
1334 | if (state == true) |
|
1328 | if (state == true) | |
1335 | { |
|
1329 | { | |
1336 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000] |
|
1330 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000] | |
1337 | } |
|
1331 | } | |
1338 | else |
|
1332 | else | |
1339 | { |
|
1333 | { | |
1340 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111] |
|
1334 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111] | |
1341 | } |
|
1335 | } | |
1342 | } |
|
1336 | } | |
1343 |
|
1337 | |||
1344 | void setCalibration( bool state ) |
|
1338 | void setCalibration( bool state ) | |
1345 | { |
|
1339 | { | |
1346 | if (state == true) |
|
1340 | if (state == true) | |
1347 | { |
|
1341 | { | |
1348 | setCalibrationEnable( true ); |
|
1342 | setCalibrationEnable( true ); | |
1349 | setCalibrationReload( false ); |
|
1343 | setCalibrationReload( false ); | |
1350 | set_hk_lfr_calib_enable( true ); |
|
1344 | set_hk_lfr_calib_enable( true ); | |
1351 | } |
|
1345 | } | |
1352 | else |
|
1346 | else | |
1353 | { |
|
1347 | { | |
1354 | setCalibrationEnable( false ); |
|
1348 | setCalibrationEnable( false ); | |
1355 | setCalibrationReload( true ); |
|
1349 | setCalibrationReload( true ); | |
1356 | set_hk_lfr_calib_enable( false ); |
|
1350 | set_hk_lfr_calib_enable( false ); | |
1357 | } |
|
1351 | } | |
1358 | } |
|
1352 | } | |
1359 |
|
1353 | |||
1360 | void configureCalibration( bool interleaved ) |
|
1354 | void configureCalibration( bool interleaved ) | |
1361 | { |
|
1355 | { | |
1362 | setCalibration( false ); |
|
1356 | setCalibration( false ); | |
1363 | if ( interleaved == true ) |
|
1357 | if ( interleaved == true ) | |
1364 | { |
|
1358 | { | |
1365 | setCalibrationInterleaved( true ); |
|
1359 | setCalibrationInterleaved( true ); | |
1366 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 |
|
1360 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 | |
1367 | setCalibrationDivisor( 26 ); // => 240 384 |
|
1361 | setCalibrationDivisor( 26 ); // => 240 384 | |
1368 | setCalibrationDataInterleaved(); |
|
1362 | setCalibrationDataInterleaved(); | |
1369 | } |
|
1363 | } | |
1370 | else |
|
1364 | else | |
1371 | { |
|
1365 | { | |
1372 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 |
|
1366 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 | |
1373 | setCalibrationDivisor( 38 ); // => 160 256 (39 - 1) |
|
1367 | setCalibrationDivisor( 38 ); // => 160 256 (39 - 1) | |
1374 | setCalibrationData(); |
|
1368 | setCalibrationData(); | |
1375 | } |
|
1369 | } | |
1376 | } |
|
1370 | } | |
1377 |
|
1371 | |||
1378 | //**************** |
|
1372 | //**************** | |
1379 | // CLOSING ACTIONS |
|
1373 | // CLOSING ACTIONS | |
1380 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
1374 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) | |
1381 | { |
|
1375 | { | |
1382 | /** This function is used to update the HK packets statistics after a successful TC execution. |
|
1376 | /** This function is used to update the HK packets statistics after a successful TC execution. | |
1383 | * |
|
1377 | * | |
1384 | * @param TC points to the TC being processed |
|
1378 | * @param TC points to the TC being processed | |
1385 | * @param time is the time used to date the TC execution |
|
1379 | * @param time is the time used to date the TC execution | |
1386 | * |
|
1380 | * | |
1387 | */ |
|
1381 | */ | |
1388 |
|
1382 | |||
1389 | unsigned int val; |
|
1383 | unsigned int val; | |
1390 |
|
1384 | |||
1391 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; |
|
1385 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; | |
1392 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; |
|
1386 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; | |
1393 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; |
|
1387 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; | |
1394 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; |
|
1388 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; | |
1395 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; |
|
1389 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; | |
1396 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; |
|
1390 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; | |
1397 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; |
|
1391 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; | |
1398 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; |
|
1392 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; | |
1399 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; |
|
1393 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; | |
1400 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; |
|
1394 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; | |
1401 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; |
|
1395 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; | |
1402 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; |
|
1396 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; | |
1403 |
|
1397 | |||
1404 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; |
|
1398 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; | |
1405 | val++; |
|
1399 | val++; | |
1406 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); |
|
1400 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); | |
1407 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); |
|
1401 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); | |
1408 | } |
|
1402 | } | |
1409 |
|
1403 | |||
1410 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
1404 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) | |
1411 | { |
|
1405 | { | |
1412 | /** This function is used to update the HK packets statistics after a TC rejection. |
|
1406 | /** This function is used to update the HK packets statistics after a TC rejection. | |
1413 | * |
|
1407 | * | |
1414 | * @param TC points to the TC being processed |
|
1408 | * @param TC points to the TC being processed | |
1415 | * @param time is the time used to date the TC rejection |
|
1409 | * @param time is the time used to date the TC rejection | |
1416 | * |
|
1410 | * | |
1417 | */ |
|
1411 | */ | |
1418 |
|
1412 | |||
1419 | unsigned int val; |
|
1413 | unsigned int val; | |
1420 |
|
1414 | |||
1421 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; |
|
1415 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; | |
1422 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; |
|
1416 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; | |
1423 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; |
|
1417 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; | |
1424 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; |
|
1418 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; | |
1425 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; |
|
1419 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; | |
1426 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; |
|
1420 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; | |
1427 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; |
|
1421 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; | |
1428 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; |
|
1422 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; | |
1429 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; |
|
1423 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; | |
1430 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; |
|
1424 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; | |
1431 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; |
|
1425 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; | |
1432 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; |
|
1426 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; | |
1433 |
|
1427 | |||
1434 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; |
|
1428 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; | |
1435 | val++; |
|
1429 | val++; | |
1436 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); |
|
1430 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); | |
1437 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); |
|
1431 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); | |
1438 | } |
|
1432 | } | |
1439 |
|
1433 | |||
1440 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) |
|
1434 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) | |
1441 | { |
|
1435 | { | |
1442 | /** This function is the last step of the TC execution workflow. |
|
1436 | /** This function is the last step of the TC execution workflow. | |
1443 | * |
|
1437 | * | |
1444 | * @param TC points to the TC being processed |
|
1438 | * @param TC points to the TC being processed | |
1445 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) |
|
1439 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) | |
1446 | * @param queue_id is the id of the RTEMS message queue used to send TM packets |
|
1440 | * @param queue_id is the id of the RTEMS message queue used to send TM packets | |
1447 | * @param time is the time used to date the TC execution |
|
1441 | * @param time is the time used to date the TC execution | |
1448 | * |
|
1442 | * | |
1449 | */ |
|
1443 | */ | |
1450 |
|
1444 | |||
1451 | unsigned char requestedMode; |
|
1445 | unsigned char requestedMode; | |
1452 |
|
1446 | |||
1453 | if (result == LFR_SUCCESSFUL) |
|
1447 | if (result == LFR_SUCCESSFUL) | |
1454 | { |
|
1448 | { | |
1455 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
1449 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) | |
1456 | & |
|
1450 | & | |
1457 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
1451 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) | |
1458 | ) |
|
1452 | ) | |
1459 | { |
|
1453 | { | |
1460 | send_tm_lfr_tc_exe_success( TC, queue_id ); |
|
1454 | send_tm_lfr_tc_exe_success( TC, queue_id ); | |
1461 | } |
|
1455 | } | |
1462 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) |
|
1456 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) | |
1463 | { |
|
1457 | { | |
1464 | //********************************** |
|
1458 | //********************************** | |
1465 | // UPDATE THE LFRMODE LOCAL VARIABLE |
|
1459 | // UPDATE THE LFRMODE LOCAL VARIABLE | |
1466 | requestedMode = TC->dataAndCRC[1]; |
|
1460 | requestedMode = TC->dataAndCRC[1]; | |
1467 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d); |
|
1461 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d); | |
1468 | updateLFRCurrentMode(); |
|
1462 | updateLFRCurrentMode(); | |
1469 | } |
|
1463 | } | |
1470 | } |
|
1464 | } | |
1471 | else if (result == LFR_EXE_ERROR) |
|
1465 | else if (result == LFR_EXE_ERROR) | |
1472 | { |
|
1466 | { | |
1473 | send_tm_lfr_tc_exe_error( TC, queue_id ); |
|
1467 | send_tm_lfr_tc_exe_error( TC, queue_id ); | |
1474 | } |
|
1468 | } | |
1475 | } |
|
1469 | } | |
1476 |
|
1470 | |||
1477 | //*************************** |
|
1471 | //*************************** | |
1478 | // Interrupt Service Routines |
|
1472 | // Interrupt Service Routines | |
1479 | rtems_isr commutation_isr1( rtems_vector_number vector ) |
|
1473 | rtems_isr commutation_isr1( rtems_vector_number vector ) | |
1480 | { |
|
1474 | { | |
1481 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1475 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
1482 | PRINTF("In commutation_isr1 *** Error sending event to DUMB\n") |
|
1476 | PRINTF("In commutation_isr1 *** Error sending event to DUMB\n") | |
1483 | } |
|
1477 | } | |
1484 | } |
|
1478 | } | |
1485 |
|
1479 | |||
1486 | rtems_isr commutation_isr2( rtems_vector_number vector ) |
|
1480 | rtems_isr commutation_isr2( rtems_vector_number vector ) | |
1487 | { |
|
1481 | { | |
1488 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1482 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
1489 | PRINTF("In commutation_isr2 *** Error sending event to DUMB\n") |
|
1483 | PRINTF("In commutation_isr2 *** Error sending event to DUMB\n") | |
1490 | } |
|
1484 | } | |
1491 | } |
|
1485 | } | |
1492 |
|
1486 | |||
1493 | //**************** |
|
1487 | //**************** | |
1494 | // OTHER FUNCTIONS |
|
1488 | // OTHER FUNCTIONS | |
1495 | void updateLFRCurrentMode() |
|
1489 | void updateLFRCurrentMode() | |
1496 | { |
|
1490 | { | |
1497 | /** This function updates the value of the global variable lfrCurrentMode. |
|
1491 | /** This function updates the value of the global variable lfrCurrentMode. | |
1498 | * |
|
1492 | * | |
1499 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. |
|
1493 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. | |
1500 | * |
|
1494 | * | |
1501 | */ |
|
1495 | */ | |
1502 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure |
|
1496 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure | |
1503 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
1497 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
1504 | } |
|
1498 | } | |
1505 |
|
1499 | |||
1506 | void set_lfr_soft_reset( unsigned char value ) |
|
1500 | void set_lfr_soft_reset( unsigned char value ) | |
1507 | { |
|
1501 | { | |
1508 | if (value == 1) |
|
1502 | if (value == 1) | |
1509 | { |
|
1503 | { | |
1510 | time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100] |
|
1504 | time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100] | |
1511 | } |
|
1505 | } | |
1512 | else |
|
1506 | else | |
1513 | { |
|
1507 | { | |
1514 | time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011] |
|
1508 | time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011] | |
1515 | } |
|
1509 | } | |
1516 | } |
|
1510 | } | |
1517 |
|
1511 | |||
1518 | void reset_lfr( void ) |
|
1512 | void reset_lfr( void ) | |
1519 | { |
|
1513 | { | |
1520 | set_lfr_soft_reset( 1 ); |
|
1514 | set_lfr_soft_reset( 1 ); | |
1521 |
|
1515 | |||
1522 | set_lfr_soft_reset( 0 ); |
|
1516 | set_lfr_soft_reset( 0 ); | |
1523 |
|
1517 | |||
1524 | set_hk_lfr_sc_potential_flag( true ); |
|
1518 | set_hk_lfr_sc_potential_flag( true ); | |
1525 | } |
|
1519 | } |
General Comments 0
You need to be logged in to leave comments.
Login now