@@ -1,71 +1,71 | |||||
1 | #ifndef TC_LOAD_DUMP_PARAMETERS_H |
|
1 | #ifndef TC_LOAD_DUMP_PARAMETERS_H | |
2 | #define TC_LOAD_DUMP_PARAMETERS_H |
|
2 | #define TC_LOAD_DUMP_PARAMETERS_H | |
3 |
|
3 | |||
4 | #include <rtems.h> |
|
4 | #include <rtems.h> | |
5 | #include <stdio.h> |
|
5 | #include <stdio.h> | |
6 |
|
6 | |||
7 | #include "fsw_params.h" |
|
7 | #include "fsw_params.h" | |
8 | #include "wf_handler.h" |
|
8 | #include "wf_handler.h" | |
9 | #include "tm_lfr_tc_exe.h" |
|
9 | #include "tm_lfr_tc_exe.h" | |
10 | #include "fsw_misc.h" |
|
10 | #include "fsw_misc.h" | |
11 | #include "basic_parameters_params.h" |
|
11 | #include "basic_parameters_params.h" | |
12 | #include "avf0_prc0.h" |
|
12 | #include "avf0_prc0.h" | |
13 |
|
13 | |||
14 | #define FLOAT_EQUAL_ZERO 0.001 |
|
14 | #define FLOAT_EQUAL_ZERO 0.001 | |
15 |
|
15 | |||
16 | extern unsigned short sequenceCounterParameterDump; |
|
16 | extern unsigned short sequenceCounterParameterDump; | |
17 | extern float k_coeff_intercalib_f0_norm[ ]; |
|
17 | extern float k_coeff_intercalib_f0_norm[ ]; | |
18 | extern float k_coeff_intercalib_f0_sbm[ ]; |
|
18 | extern float k_coeff_intercalib_f0_sbm[ ]; | |
19 | extern float k_coeff_intercalib_f1_norm[ ]; |
|
19 | extern float k_coeff_intercalib_f1_norm[ ]; | |
20 | extern float k_coeff_intercalib_f1_sbm[ ]; |
|
20 | extern float k_coeff_intercalib_f1_sbm[ ]; | |
21 | extern float k_coeff_intercalib_f2[ ]; |
|
21 | extern float k_coeff_intercalib_f2[ ]; | |
22 |
|
22 | |||
23 | int action_load_common_par( ccsdsTelecommandPacket_t *TC ); |
|
23 | int action_load_common_par( ccsdsTelecommandPacket_t *TC ); | |
24 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
24 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
25 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
25 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
26 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
26 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
27 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); |
|
27 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id , unsigned char *time); | |
28 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
28 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
29 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
29 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
30 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); |
|
30 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time); | |
31 | int action_dump_par(rtems_id queue_id ); |
|
31 | int action_dump_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
32 |
|
32 | |||
33 | // NORMAL |
|
33 | // NORMAL | |
34 | int check_common_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); |
|
34 | int check_common_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ); | |
35 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ); |
|
35 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ); | |
36 | int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC ); |
|
36 | int set_sy_lfr_n_swf_p( ccsdsTelecommandPacket_t *TC ); | |
37 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ); |
|
37 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ); | |
38 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
38 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
39 | int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
39 | int set_sy_lfr_n_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
40 | int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC ); |
|
40 | int set_sy_lfr_n_cwf_long_f3( ccsdsTelecommandPacket_t *TC ); | |
41 |
|
41 | |||
42 | // BURST |
|
42 | // BURST | |
43 | int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
43 | int set_sy_lfr_b_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
44 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
44 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
45 |
|
45 | |||
46 | // SBM1 |
|
46 | // SBM1 | |
47 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
47 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
48 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
48 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
49 |
|
49 | |||
50 | // SBM2 |
|
50 | // SBM2 | |
51 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ); |
|
51 | int set_sy_lfr_s2_bp_p0( ccsdsTelecommandPacket_t *TC ); | |
52 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ); |
|
52 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ); | |
53 |
|
53 | |||
54 | // TC_LFR_UPDATE_INFO |
|
54 | // TC_LFR_UPDATE_INFO | |
55 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ); |
|
55 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ); | |
56 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ); |
|
56 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ); | |
57 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ); |
|
57 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ); | |
58 |
|
58 | |||
59 | // FBINS_MASK |
|
59 | // FBINS_MASK | |
60 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ); |
|
60 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ); | |
61 |
|
61 | |||
62 | // KCOEFFICIENTS |
|
62 | // KCOEFFICIENTS | |
63 | int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id); |
|
63 | int set_sy_lfr_kcoeff(ccsdsTelecommandPacket_t *TC , rtems_id queue_id); | |
64 | void copyFloatByChar( unsigned char *destination, unsigned char *source ); |
|
64 | void copyFloatByChar( unsigned char *destination, unsigned char *source ); | |
65 |
|
65 | |||
66 | void init_parameter_dump( void ); |
|
66 | void init_parameter_dump( void ); | |
67 | void init_kcoefficients_dump( void ); |
|
67 | void init_kcoefficients_dump( void ); | |
68 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ); |
|
68 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ); | |
69 | void print_k_coeff(); |
|
69 | void print_k_coeff(); | |
70 |
|
70 | |||
71 | #endif // TC_LOAD_DUMP_PARAMETERS_H |
|
71 | #endif // TC_LOAD_DUMP_PARAMETERS_H |
@@ -1,1169 +1,1169 | |||||
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( 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 | status = enter_mode( requestedMode, transitionCoarseTime ); |
|
207 | status = enter_mode( requestedMode, transitionCoarseTime ); | |
208 | } |
|
208 | } | |
209 |
|
209 | |||
210 | return status; |
|
210 | return status; | |
211 | } |
|
211 | } | |
212 |
|
212 | |||
213 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) |
|
213 | int action_update_info(ccsdsTelecommandPacket_t *TC, rtems_id queue_id) | |
214 | { |
|
214 | { | |
215 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. |
|
215 | /** This function executes specific actions when a TC_LFR_UPDATE_INFO TeleCommand has been received. | |
216 | * |
|
216 | * | |
217 | * @param TC points to the TeleCommand packet that is being processed |
|
217 | * @param TC points to the TeleCommand packet that is being processed | |
218 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
218 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
219 | * |
|
219 | * | |
220 | * @return LFR directive status code: |
|
220 | * @return LFR directive status code: | |
221 | * - LFR_DEFAULT |
|
221 | * - LFR_DEFAULT | |
222 | * - LFR_SUCCESSFUL |
|
222 | * - LFR_SUCCESSFUL | |
223 | * |
|
223 | * | |
224 | */ |
|
224 | */ | |
225 |
|
225 | |||
226 | unsigned int val; |
|
226 | unsigned int val; | |
227 | int result; |
|
227 | int result; | |
228 | unsigned int status; |
|
228 | unsigned int status; | |
229 | unsigned char mode; |
|
229 | unsigned char mode; | |
230 | unsigned char * bytePosPtr; |
|
230 | unsigned char * bytePosPtr; | |
231 |
|
231 | |||
232 | bytePosPtr = (unsigned char *) &TC->packetID; |
|
232 | bytePosPtr = (unsigned char *) &TC->packetID; | |
233 |
|
233 | |||
234 | // check LFR mode |
|
234 | // check LFR mode | |
235 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1; |
|
235 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET5 ] & 0x1e) >> 1; | |
236 | status = check_update_info_hk_lfr_mode( mode ); |
|
236 | status = check_update_info_hk_lfr_mode( mode ); | |
237 | if (status == LFR_SUCCESSFUL) // check TDS mode |
|
237 | if (status == LFR_SUCCESSFUL) // check TDS mode | |
238 | { |
|
238 | { | |
239 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4; |
|
239 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0xf0) >> 4; | |
240 | status = check_update_info_hk_tds_mode( mode ); |
|
240 | status = check_update_info_hk_tds_mode( mode ); | |
241 | } |
|
241 | } | |
242 | if (status == LFR_SUCCESSFUL) // check THR mode |
|
242 | if (status == LFR_SUCCESSFUL) // check THR mode | |
243 | { |
|
243 | { | |
244 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f); |
|
244 | mode = (bytePosPtr[ BYTE_POS_UPDATE_INFO_PARAMETERS_SET6 ] & 0x0f); | |
245 | status = check_update_info_hk_thr_mode( mode ); |
|
245 | status = check_update_info_hk_thr_mode( mode ); | |
246 | } |
|
246 | } | |
247 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful |
|
247 | if (status == LFR_SUCCESSFUL) // if the parameter check is successful | |
248 | { |
|
248 | { | |
249 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 |
|
249 | val = housekeeping_packet.hk_lfr_update_info_tc_cnt[0] * 256 | |
250 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; |
|
250 | + housekeeping_packet.hk_lfr_update_info_tc_cnt[1]; | |
251 | val++; |
|
251 | val++; | |
252 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); |
|
252 | housekeeping_packet.hk_lfr_update_info_tc_cnt[0] = (unsigned char) (val >> 8); | |
253 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); |
|
253 | housekeeping_packet.hk_lfr_update_info_tc_cnt[1] = (unsigned char) (val); | |
254 | } |
|
254 | } | |
255 |
|
255 | |||
256 | result = status; |
|
256 | result = status; | |
257 |
|
257 | |||
258 | return result; |
|
258 | return result; | |
259 | } |
|
259 | } | |
260 |
|
260 | |||
261 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
261 | int action_enable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
262 | { |
|
262 | { | |
263 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. |
|
263 | /** This function executes specific actions when a TC_LFR_ENABLE_CALIBRATION TeleCommand has been received. | |
264 | * |
|
264 | * | |
265 | * @param TC points to the TeleCommand packet that is being processed |
|
265 | * @param TC points to the TeleCommand packet that is being processed | |
266 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
266 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
267 | * |
|
267 | * | |
268 | */ |
|
268 | */ | |
269 |
|
269 | |||
270 | int result; |
|
270 | int result; | |
271 |
|
271 | |||
272 | result = LFR_DEFAULT; |
|
272 | result = LFR_DEFAULT; | |
273 |
|
273 | |||
274 | setCalibration( true ); |
|
274 | setCalibration( true ); | |
275 |
|
275 | |||
276 | result = LFR_SUCCESSFUL; |
|
276 | result = LFR_SUCCESSFUL; | |
277 |
|
277 | |||
278 | return result; |
|
278 | return result; | |
279 | } |
|
279 | } | |
280 |
|
280 | |||
281 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
281 | int action_disable_calibration(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
282 | { |
|
282 | { | |
283 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. |
|
283 | /** This function executes specific actions when a TC_LFR_DISABLE_CALIBRATION TeleCommand has been received. | |
284 | * |
|
284 | * | |
285 | * @param TC points to the TeleCommand packet that is being processed |
|
285 | * @param TC points to the TeleCommand packet that is being processed | |
286 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
286 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
287 | * |
|
287 | * | |
288 | */ |
|
288 | */ | |
289 |
|
289 | |||
290 | int result; |
|
290 | int result; | |
291 |
|
291 | |||
292 | result = LFR_DEFAULT; |
|
292 | result = LFR_DEFAULT; | |
293 |
|
293 | |||
294 | setCalibration( false ); |
|
294 | setCalibration( false ); | |
295 |
|
295 | |||
296 | result = LFR_SUCCESSFUL; |
|
296 | result = LFR_SUCCESSFUL; | |
297 |
|
297 | |||
298 | return result; |
|
298 | return result; | |
299 | } |
|
299 | } | |
300 |
|
300 | |||
301 | int action_update_time(ccsdsTelecommandPacket_t *TC) |
|
301 | int action_update_time(ccsdsTelecommandPacket_t *TC) | |
302 | { |
|
302 | { | |
303 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. |
|
303 | /** This function executes specific actions when a TC_LFR_UPDATE_TIME TeleCommand has been received. | |
304 | * |
|
304 | * | |
305 | * @param TC points to the TeleCommand packet that is being processed |
|
305 | * @param TC points to the TeleCommand packet that is being processed | |
306 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver |
|
306 | * @param queue_id is the id of the queue which handles TM transmission by the SpaceWire driver | |
307 | * |
|
307 | * | |
308 | * @return LFR_SUCCESSFUL |
|
308 | * @return LFR_SUCCESSFUL | |
309 | * |
|
309 | * | |
310 | */ |
|
310 | */ | |
311 |
|
311 | |||
312 | unsigned int val; |
|
312 | unsigned int val; | |
313 |
|
313 | |||
314 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) |
|
314 | time_management_regs->coarse_time_load = (TC->dataAndCRC[0] << 24) | |
315 | + (TC->dataAndCRC[1] << 16) |
|
315 | + (TC->dataAndCRC[1] << 16) | |
316 | + (TC->dataAndCRC[2] << 8) |
|
316 | + (TC->dataAndCRC[2] << 8) | |
317 | + TC->dataAndCRC[3]; |
|
317 | + TC->dataAndCRC[3]; | |
318 |
|
318 | |||
319 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 |
|
319 | val = housekeeping_packet.hk_lfr_update_time_tc_cnt[0] * 256 | |
320 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; |
|
320 | + housekeeping_packet.hk_lfr_update_time_tc_cnt[1]; | |
321 | val++; |
|
321 | val++; | |
322 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); |
|
322 | housekeeping_packet.hk_lfr_update_time_tc_cnt[0] = (unsigned char) (val >> 8); | |
323 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); |
|
323 | housekeeping_packet.hk_lfr_update_time_tc_cnt[1] = (unsigned char) (val); | |
324 |
|
324 | |||
325 | return LFR_SUCCESSFUL; |
|
325 | return LFR_SUCCESSFUL; | |
326 | } |
|
326 | } | |
327 |
|
327 | |||
328 | //******************* |
|
328 | //******************* | |
329 | // ENTERING THE MODES |
|
329 | // ENTERING THE MODES | |
330 | int check_mode_value( unsigned char requestedMode ) |
|
330 | int check_mode_value( unsigned char requestedMode ) | |
331 | { |
|
331 | { | |
332 | int status; |
|
332 | int status; | |
333 |
|
333 | |||
334 | if ( (requestedMode != LFR_MODE_STANDBY) |
|
334 | if ( (requestedMode != LFR_MODE_STANDBY) | |
335 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) |
|
335 | && (requestedMode != LFR_MODE_NORMAL) && (requestedMode != LFR_MODE_BURST) | |
336 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) |
|
336 | && (requestedMode != LFR_MODE_SBM1) && (requestedMode != LFR_MODE_SBM2) ) | |
337 | { |
|
337 | { | |
338 | status = LFR_DEFAULT; |
|
338 | status = LFR_DEFAULT; | |
339 | } |
|
339 | } | |
340 | else |
|
340 | else | |
341 | { |
|
341 | { | |
342 | status = LFR_SUCCESSFUL; |
|
342 | status = LFR_SUCCESSFUL; | |
343 | } |
|
343 | } | |
344 |
|
344 | |||
345 | return status; |
|
345 | return status; | |
346 | } |
|
346 | } | |
347 |
|
347 | |||
348 | int check_mode_transition( unsigned char requestedMode ) |
|
348 | int check_mode_transition( unsigned char requestedMode ) | |
349 | { |
|
349 | { | |
350 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. |
|
350 | /** This function checks the validity of the transition requested by the TC_LFR_ENTER_MODE. | |
351 | * |
|
351 | * | |
352 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE |
|
352 | * @param requestedMode is the mode requested by the TC_LFR_ENTER_MODE | |
353 | * |
|
353 | * | |
354 | * @return LFR directive status codes: |
|
354 | * @return LFR directive status codes: | |
355 | * - LFR_SUCCESSFUL - the transition is authorized |
|
355 | * - LFR_SUCCESSFUL - the transition is authorized | |
356 | * - LFR_DEFAULT - the transition is not authorized |
|
356 | * - LFR_DEFAULT - the transition is not authorized | |
357 | * |
|
357 | * | |
358 | */ |
|
358 | */ | |
359 |
|
359 | |||
360 | int status; |
|
360 | int status; | |
361 |
|
361 | |||
362 | switch (requestedMode) |
|
362 | switch (requestedMode) | |
363 | { |
|
363 | { | |
364 | case LFR_MODE_STANDBY: |
|
364 | case LFR_MODE_STANDBY: | |
365 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { |
|
365 | if ( lfrCurrentMode == LFR_MODE_STANDBY ) { | |
366 | status = LFR_DEFAULT; |
|
366 | status = LFR_DEFAULT; | |
367 | } |
|
367 | } | |
368 | else |
|
368 | else | |
369 | { |
|
369 | { | |
370 | status = LFR_SUCCESSFUL; |
|
370 | status = LFR_SUCCESSFUL; | |
371 | } |
|
371 | } | |
372 | break; |
|
372 | break; | |
373 | case LFR_MODE_NORMAL: |
|
373 | case LFR_MODE_NORMAL: | |
374 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { |
|
374 | if ( lfrCurrentMode == LFR_MODE_NORMAL ) { | |
375 | status = LFR_DEFAULT; |
|
375 | status = LFR_DEFAULT; | |
376 | } |
|
376 | } | |
377 | else { |
|
377 | else { | |
378 | status = LFR_SUCCESSFUL; |
|
378 | status = LFR_SUCCESSFUL; | |
379 | } |
|
379 | } | |
380 | break; |
|
380 | break; | |
381 | case LFR_MODE_BURST: |
|
381 | case LFR_MODE_BURST: | |
382 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
382 | if ( lfrCurrentMode == LFR_MODE_BURST ) { | |
383 | status = LFR_DEFAULT; |
|
383 | status = LFR_DEFAULT; | |
384 | } |
|
384 | } | |
385 | else { |
|
385 | else { | |
386 | status = LFR_SUCCESSFUL; |
|
386 | status = LFR_SUCCESSFUL; | |
387 | } |
|
387 | } | |
388 | break; |
|
388 | break; | |
389 | case LFR_MODE_SBM1: |
|
389 | case LFR_MODE_SBM1: | |
390 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
390 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { | |
391 | status = LFR_DEFAULT; |
|
391 | status = LFR_DEFAULT; | |
392 | } |
|
392 | } | |
393 | else { |
|
393 | else { | |
394 | status = LFR_SUCCESSFUL; |
|
394 | status = LFR_SUCCESSFUL; | |
395 | } |
|
395 | } | |
396 | break; |
|
396 | break; | |
397 | case LFR_MODE_SBM2: |
|
397 | case LFR_MODE_SBM2: | |
398 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
398 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { | |
399 | status = LFR_DEFAULT; |
|
399 | status = LFR_DEFAULT; | |
400 | } |
|
400 | } | |
401 | else { |
|
401 | else { | |
402 | status = LFR_SUCCESSFUL; |
|
402 | status = LFR_SUCCESSFUL; | |
403 | } |
|
403 | } | |
404 | break; |
|
404 | break; | |
405 | default: |
|
405 | default: | |
406 | status = LFR_DEFAULT; |
|
406 | status = LFR_DEFAULT; | |
407 | break; |
|
407 | break; | |
408 | } |
|
408 | } | |
409 |
|
409 | |||
410 | return status; |
|
410 | return status; | |
411 | } |
|
411 | } | |
412 |
|
412 | |||
413 | int check_transition_date( unsigned int transitionCoarseTime ) |
|
413 | int check_transition_date( unsigned int transitionCoarseTime ) | |
414 | { |
|
414 | { | |
415 | int status; |
|
415 | int status; | |
416 | unsigned int localCoarseTime; |
|
416 | unsigned int localCoarseTime; | |
417 | unsigned int deltaCoarseTime; |
|
417 | unsigned int deltaCoarseTime; | |
418 |
|
418 | |||
419 | status = LFR_SUCCESSFUL; |
|
419 | status = LFR_SUCCESSFUL; | |
420 |
|
420 | |||
421 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition |
|
421 | if (transitionCoarseTime == 0) // transition time = 0 means an instant transition | |
422 | { |
|
422 | { | |
423 | status = LFR_SUCCESSFUL; |
|
423 | status = LFR_SUCCESSFUL; | |
424 | } |
|
424 | } | |
425 | else |
|
425 | else | |
426 | { |
|
426 | { | |
427 | localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; |
|
427 | localCoarseTime = time_management_regs->coarse_time & 0x7fffffff; | |
428 |
|
428 | |||
429 | PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime) |
|
429 | PRINTF2("localTime = %x, transitionTime = %x\n", localCoarseTime, transitionCoarseTime) | |
430 |
|
430 | |||
431 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 |
|
431 | if ( transitionCoarseTime <= localCoarseTime ) // SSS-CP-EQS-322 | |
432 | { |
|
432 | { | |
433 | status = LFR_DEFAULT; |
|
433 | status = LFR_DEFAULT; | |
434 | PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n") |
|
434 | PRINTF("ERR *** in check_transition_date *** transitionCoarseTime <= localCoarseTime\n") | |
435 | } |
|
435 | } | |
436 |
|
436 | |||
437 | if (status == LFR_SUCCESSFUL) |
|
437 | if (status == LFR_SUCCESSFUL) | |
438 | { |
|
438 | { | |
439 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; |
|
439 | deltaCoarseTime = transitionCoarseTime - localCoarseTime; | |
440 | if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323 |
|
440 | if ( deltaCoarseTime > 3 ) // SSS-CP-EQS-323 | |
441 | { |
|
441 | { | |
442 | status = LFR_DEFAULT; |
|
442 | status = LFR_DEFAULT; | |
443 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) |
|
443 | PRINTF1("ERR *** in check_transition_date *** deltaCoarseTime = %x\n", deltaCoarseTime) | |
444 | } |
|
444 | } | |
445 | } |
|
445 | } | |
446 | } |
|
446 | } | |
447 |
|
447 | |||
448 | return status; |
|
448 | return status; | |
449 | } |
|
449 | } | |
450 |
|
450 | |||
451 | int stop_current_mode( void ) |
|
451 | int stop_current_mode( void ) | |
452 | { |
|
452 | { | |
453 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. |
|
453 | /** This function stops the current mode by masking interrupt lines and suspending science tasks. | |
454 | * |
|
454 | * | |
455 | * @return RTEMS directive status codes: |
|
455 | * @return RTEMS directive status codes: | |
456 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
456 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
457 | * - RTEMS_INVALID_ID - task id invalid |
|
457 | * - RTEMS_INVALID_ID - task id invalid | |
458 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
458 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
459 | * |
|
459 | * | |
460 | */ |
|
460 | */ | |
461 |
|
461 | |||
462 | rtems_status_code status; |
|
462 | rtems_status_code status; | |
463 |
|
463 | |||
464 | status = RTEMS_SUCCESSFUL; |
|
464 | status = RTEMS_SUCCESSFUL; | |
465 |
|
465 | |||
466 | // (1) mask interruptions |
|
466 | // (1) mask interruptions | |
467 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt |
|
467 | LEON_Mask_interrupt( IRQ_WAVEFORM_PICKER ); // mask waveform picker interrupt | |
468 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
468 | LEON_Mask_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
469 |
|
469 | |||
470 | // (2) reset waveform picker registers |
|
470 | // (2) reset waveform picker registers | |
471 | reset_wfp_burst_enable(); // reset burst and enable bits |
|
471 | reset_wfp_burst_enable(); // reset burst and enable bits | |
472 | reset_wfp_status(); // reset all the status bits |
|
472 | reset_wfp_status(); // reset all the status bits | |
473 |
|
473 | |||
474 | // (3) reset spectral matrices registers |
|
474 | // (3) reset spectral matrices registers | |
475 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices |
|
475 | set_sm_irq_onNewMatrix( 0 ); // stop the spectral matrices | |
476 | reset_sm_status(); |
|
476 | reset_sm_status(); | |
477 |
|
477 | |||
478 | // reset lfr VHDL module |
|
478 | // reset lfr VHDL module | |
479 | reset_lfr(); |
|
479 | reset_lfr(); | |
480 |
|
480 | |||
481 | reset_extractSWF(); // reset the extractSWF flag to false |
|
481 | reset_extractSWF(); // reset the extractSWF flag to false | |
482 |
|
482 | |||
483 | // (4) clear interruptions |
|
483 | // (4) clear interruptions | |
484 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt |
|
484 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); // clear waveform picker interrupt | |
485 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt |
|
485 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); // clear spectral matrix interrupt | |
486 |
|
486 | |||
487 | // <Spectral Matrices simulator> |
|
487 | // <Spectral Matrices simulator> | |
488 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator |
|
488 | LEON_Mask_interrupt( IRQ_SM_SIMULATOR ); // mask spectral matrix interrupt simulator | |
489 | timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
489 | timer_stop( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); | |
490 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator |
|
490 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); // clear spectral matrix interrupt simulator | |
491 | // </Spectral Matrices simulator> |
|
491 | // </Spectral Matrices simulator> | |
492 |
|
492 | |||
493 | // suspend several tasks |
|
493 | // suspend several tasks | |
494 | if (lfrCurrentMode != LFR_MODE_STANDBY) { |
|
494 | if (lfrCurrentMode != LFR_MODE_STANDBY) { | |
495 | status = suspend_science_tasks(); |
|
495 | status = suspend_science_tasks(); | |
496 | } |
|
496 | } | |
497 |
|
497 | |||
498 | if (status != RTEMS_SUCCESSFUL) |
|
498 | if (status != RTEMS_SUCCESSFUL) | |
499 | { |
|
499 | { | |
500 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) |
|
500 | PRINTF1("in stop_current_mode *** in suspend_science_tasks *** ERR code: %d\n", status) | |
501 | } |
|
501 | } | |
502 |
|
502 | |||
503 | return status; |
|
503 | return status; | |
504 | } |
|
504 | } | |
505 |
|
505 | |||
506 | int enter_mode( unsigned char mode, unsigned int transitionCoarseTime ) |
|
506 | int enter_mode( unsigned char mode, unsigned int transitionCoarseTime ) | |
507 | { |
|
507 | { | |
508 | /** This function is launched after a mode transition validation. |
|
508 | /** This function is launched after a mode transition validation. | |
509 | * |
|
509 | * | |
510 | * @param mode is the mode in which LFR will be put. |
|
510 | * @param mode is the mode in which LFR will be put. | |
511 | * |
|
511 | * | |
512 | * @return RTEMS directive status codes: |
|
512 | * @return RTEMS directive status codes: | |
513 | * - RTEMS_SUCCESSFUL - the mode has been entered successfully |
|
513 | * - RTEMS_SUCCESSFUL - the mode has been entered successfully | |
514 | * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully |
|
514 | * - RTEMS_NOT_SATISFIED - the mode has not been entered successfully | |
515 | * |
|
515 | * | |
516 | */ |
|
516 | */ | |
517 |
|
517 | |||
518 | rtems_status_code status; |
|
518 | rtems_status_code status; | |
519 |
|
519 | |||
520 | //********************** |
|
520 | //********************** | |
521 | // STOP THE CURRENT MODE |
|
521 | // STOP THE CURRENT MODE | |
522 | status = stop_current_mode(); |
|
522 | status = stop_current_mode(); | |
523 | if (status != RTEMS_SUCCESSFUL) |
|
523 | if (status != RTEMS_SUCCESSFUL) | |
524 | { |
|
524 | { | |
525 | PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode) |
|
525 | PRINTF1("ERR *** in enter_mode *** stop_current_mode with mode = %d\n", mode) | |
526 | } |
|
526 | } | |
527 |
|
527 | |||
528 | //************************* |
|
528 | //************************* | |
529 | // ENTER THE REQUESTED MODE |
|
529 | // ENTER THE REQUESTED MODE | |
530 | if (status == RTEMS_SUCCESSFUL) // if the current mode has been successfully stopped |
|
530 | if (status == RTEMS_SUCCESSFUL) // if the current mode has been successfully stopped | |
531 | { |
|
531 | { | |
532 | if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST) |
|
532 | if ( (mode == LFR_MODE_NORMAL) || (mode == LFR_MODE_BURST) | |
533 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) ) |
|
533 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2) ) | |
534 | { |
|
534 | { | |
535 | #ifdef PRINT_TASK_STATISTICS |
|
535 | #ifdef PRINT_TASK_STATISTICS | |
536 | rtems_cpu_usage_reset(); |
|
536 | rtems_cpu_usage_reset(); | |
537 | #endif |
|
537 | #endif | |
538 | status = restart_science_tasks( mode ); |
|
538 | status = restart_science_tasks( mode ); | |
539 | if (status == RTEMS_SUCCESSFUL) |
|
539 | if (status == RTEMS_SUCCESSFUL) | |
540 | { |
|
540 | { | |
541 | launch_spectral_matrix( ); |
|
541 | launch_spectral_matrix( ); | |
542 | launch_waveform_picker( mode, transitionCoarseTime ); |
|
542 | launch_waveform_picker( mode, transitionCoarseTime ); | |
543 | } |
|
543 | } | |
544 | } |
|
544 | } | |
545 | else if ( mode == LFR_MODE_STANDBY ) |
|
545 | else if ( mode == LFR_MODE_STANDBY ) | |
546 | { |
|
546 | { | |
547 | #ifdef PRINT_TASK_STATISTICS |
|
547 | #ifdef PRINT_TASK_STATISTICS | |
548 | rtems_cpu_usage_report(); |
|
548 | rtems_cpu_usage_report(); | |
549 | #endif |
|
549 | #endif | |
550 |
|
550 | |||
551 | #ifdef PRINT_STACK_REPORT |
|
551 | #ifdef PRINT_STACK_REPORT | |
552 | PRINTF("stack report selected\n") |
|
552 | PRINTF("stack report selected\n") | |
553 | rtems_stack_checker_report_usage(); |
|
553 | rtems_stack_checker_report_usage(); | |
554 | #endif |
|
554 | #endif | |
555 | } |
|
555 | } | |
556 | else |
|
556 | else | |
557 | { |
|
557 | { | |
558 | status = RTEMS_UNSATISFIED; |
|
558 | status = RTEMS_UNSATISFIED; | |
559 | } |
|
559 | } | |
560 | } |
|
560 | } | |
561 |
|
561 | |||
562 | if (status != RTEMS_SUCCESSFUL) |
|
562 | if (status != RTEMS_SUCCESSFUL) | |
563 | { |
|
563 | { | |
564 | PRINTF1("ERR *** in enter_mode *** status = %d\n", status) |
|
564 | PRINTF1("ERR *** in enter_mode *** status = %d\n", status) | |
565 | status = RTEMS_UNSATISFIED; |
|
565 | status = RTEMS_UNSATISFIED; | |
566 | } |
|
566 | } | |
567 |
|
567 | |||
568 | return status; |
|
568 | return status; | |
569 | } |
|
569 | } | |
570 |
|
570 | |||
571 | int restart_science_tasks(unsigned char lfrRequestedMode ) |
|
571 | int restart_science_tasks(unsigned char lfrRequestedMode ) | |
572 | { |
|
572 | { | |
573 | /** This function is used to restart all science tasks. |
|
573 | /** This function is used to restart all science tasks. | |
574 | * |
|
574 | * | |
575 | * @return RTEMS directive status codes: |
|
575 | * @return RTEMS directive status codes: | |
576 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
576 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
577 | * - RTEMS_INVALID_ID - task id invalid |
|
577 | * - RTEMS_INVALID_ID - task id invalid | |
578 | * - RTEMS_INCORRECT_STATE - task never started |
|
578 | * - RTEMS_INCORRECT_STATE - task never started | |
579 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task |
|
579 | * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot restart remote task | |
580 | * |
|
580 | * | |
581 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 |
|
581 | * Science tasks are AVF0, PRC0, WFRM, CWF3, CW2, CWF1 | |
582 | * |
|
582 | * | |
583 | */ |
|
583 | */ | |
584 |
|
584 | |||
585 | rtems_status_code status[10]; |
|
585 | rtems_status_code status[10]; | |
586 | rtems_status_code ret; |
|
586 | rtems_status_code ret; | |
587 |
|
587 | |||
588 | ret = RTEMS_SUCCESSFUL; |
|
588 | ret = RTEMS_SUCCESSFUL; | |
589 |
|
589 | |||
590 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); |
|
590 | status[0] = rtems_task_restart( Task_id[TASKID_AVF0], lfrRequestedMode ); | |
591 | if (status[0] != RTEMS_SUCCESSFUL) |
|
591 | if (status[0] != RTEMS_SUCCESSFUL) | |
592 | { |
|
592 | { | |
593 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) |
|
593 | PRINTF1("in restart_science_task *** AVF0 ERR %d\n", status[0]) | |
594 | } |
|
594 | } | |
595 |
|
595 | |||
596 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); |
|
596 | status[1] = rtems_task_restart( Task_id[TASKID_PRC0], lfrRequestedMode ); | |
597 | if (status[1] != RTEMS_SUCCESSFUL) |
|
597 | if (status[1] != RTEMS_SUCCESSFUL) | |
598 | { |
|
598 | { | |
599 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) |
|
599 | PRINTF1("in restart_science_task *** PRC0 ERR %d\n", status[1]) | |
600 | } |
|
600 | } | |
601 |
|
601 | |||
602 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); |
|
602 | status[2] = rtems_task_restart( Task_id[TASKID_WFRM],1 ); | |
603 | if (status[2] != RTEMS_SUCCESSFUL) |
|
603 | if (status[2] != RTEMS_SUCCESSFUL) | |
604 | { |
|
604 | { | |
605 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2]) |
|
605 | PRINTF1("in restart_science_task *** WFRM ERR %d\n", status[2]) | |
606 | } |
|
606 | } | |
607 |
|
607 | |||
608 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); |
|
608 | status[3] = rtems_task_restart( Task_id[TASKID_CWF3],1 ); | |
609 | if (status[3] != RTEMS_SUCCESSFUL) |
|
609 | if (status[3] != RTEMS_SUCCESSFUL) | |
610 | { |
|
610 | { | |
611 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3]) |
|
611 | PRINTF1("in restart_science_task *** CWF3 ERR %d\n", status[3]) | |
612 | } |
|
612 | } | |
613 |
|
613 | |||
614 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); |
|
614 | status[4] = rtems_task_restart( Task_id[TASKID_CWF2],1 ); | |
615 | if (status[4] != RTEMS_SUCCESSFUL) |
|
615 | if (status[4] != RTEMS_SUCCESSFUL) | |
616 | { |
|
616 | { | |
617 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4]) |
|
617 | PRINTF1("in restart_science_task *** CWF2 ERR %d\n", status[4]) | |
618 | } |
|
618 | } | |
619 |
|
619 | |||
620 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); |
|
620 | status[5] = rtems_task_restart( Task_id[TASKID_CWF1],1 ); | |
621 | if (status[5] != RTEMS_SUCCESSFUL) |
|
621 | if (status[5] != RTEMS_SUCCESSFUL) | |
622 | { |
|
622 | { | |
623 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5]) |
|
623 | PRINTF1("in restart_science_task *** CWF1 ERR %d\n", status[5]) | |
624 | } |
|
624 | } | |
625 |
|
625 | |||
626 | status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); |
|
626 | status[6] = rtems_task_restart( Task_id[TASKID_AVF1], lfrRequestedMode ); | |
627 | if (status[6] != RTEMS_SUCCESSFUL) |
|
627 | if (status[6] != RTEMS_SUCCESSFUL) | |
628 | { |
|
628 | { | |
629 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6]) |
|
629 | PRINTF1("in restart_science_task *** AVF1 ERR %d\n", status[6]) | |
630 | } |
|
630 | } | |
631 |
|
631 | |||
632 | status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); |
|
632 | status[7] = rtems_task_restart( Task_id[TASKID_PRC1],lfrRequestedMode ); | |
633 | if (status[7] != RTEMS_SUCCESSFUL) |
|
633 | if (status[7] != RTEMS_SUCCESSFUL) | |
634 | { |
|
634 | { | |
635 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7]) |
|
635 | PRINTF1("in restart_science_task *** PRC1 ERR %d\n", status[7]) | |
636 | } |
|
636 | } | |
637 |
|
637 | |||
638 | status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); |
|
638 | status[8] = rtems_task_restart( Task_id[TASKID_AVF2], 1 ); | |
639 | if (status[8] != RTEMS_SUCCESSFUL) |
|
639 | if (status[8] != RTEMS_SUCCESSFUL) | |
640 | { |
|
640 | { | |
641 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8]) |
|
641 | PRINTF1("in restart_science_task *** AVF2 ERR %d\n", status[8]) | |
642 | } |
|
642 | } | |
643 |
|
643 | |||
644 | status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); |
|
644 | status[9] = rtems_task_restart( Task_id[TASKID_PRC2], 1 ); | |
645 | if (status[9] != RTEMS_SUCCESSFUL) |
|
645 | if (status[9] != RTEMS_SUCCESSFUL) | |
646 | { |
|
646 | { | |
647 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9]) |
|
647 | PRINTF1("in restart_science_task *** PRC2 ERR %d\n", status[9]) | |
648 | } |
|
648 | } | |
649 |
|
649 | |||
650 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || |
|
650 | if ( (status[0] != RTEMS_SUCCESSFUL) || (status[1] != RTEMS_SUCCESSFUL) || | |
651 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || |
|
651 | (status[2] != RTEMS_SUCCESSFUL) || (status[3] != RTEMS_SUCCESSFUL) || | |
652 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) || |
|
652 | (status[4] != RTEMS_SUCCESSFUL) || (status[5] != RTEMS_SUCCESSFUL) || | |
653 | (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) || |
|
653 | (status[6] != RTEMS_SUCCESSFUL) || (status[7] != RTEMS_SUCCESSFUL) || | |
654 | (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) ) |
|
654 | (status[8] != RTEMS_SUCCESSFUL) || (status[9] != RTEMS_SUCCESSFUL) ) | |
655 | { |
|
655 | { | |
656 | ret = RTEMS_UNSATISFIED; |
|
656 | ret = RTEMS_UNSATISFIED; | |
657 | } |
|
657 | } | |
658 |
|
658 | |||
659 | return ret; |
|
659 | return ret; | |
660 | } |
|
660 | } | |
661 |
|
661 | |||
662 | int suspend_science_tasks() |
|
662 | int suspend_science_tasks() | |
663 | { |
|
663 | { | |
664 | /** This function suspends the science tasks. |
|
664 | /** This function suspends the science tasks. | |
665 | * |
|
665 | * | |
666 | * @return RTEMS directive status codes: |
|
666 | * @return RTEMS directive status codes: | |
667 | * - RTEMS_SUCCESSFUL - task restarted successfully |
|
667 | * - RTEMS_SUCCESSFUL - task restarted successfully | |
668 | * - RTEMS_INVALID_ID - task id invalid |
|
668 | * - RTEMS_INVALID_ID - task id invalid | |
669 | * - RTEMS_ALREADY_SUSPENDED - task already suspended |
|
669 | * - RTEMS_ALREADY_SUSPENDED - task already suspended | |
670 | * |
|
670 | * | |
671 | */ |
|
671 | */ | |
672 |
|
672 | |||
673 | rtems_status_code status; |
|
673 | rtems_status_code status; | |
674 |
|
674 | |||
675 | printf("in suspend_science_tasks\n"); |
|
675 | printf("in suspend_science_tasks\n"); | |
676 |
|
676 | |||
677 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 |
|
677 | status = rtems_task_suspend( Task_id[TASKID_AVF0] ); // suspend AVF0 | |
678 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
678 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
679 | { |
|
679 | { | |
680 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) |
|
680 | PRINTF1("in suspend_science_task *** AVF0 ERR %d\n", status) | |
681 | } |
|
681 | } | |
682 | else |
|
682 | else | |
683 | { |
|
683 | { | |
684 | status = RTEMS_SUCCESSFUL; |
|
684 | status = RTEMS_SUCCESSFUL; | |
685 | } |
|
685 | } | |
686 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 |
|
686 | if (status == RTEMS_SUCCESSFUL) // suspend PRC0 | |
687 | { |
|
687 | { | |
688 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); |
|
688 | status = rtems_task_suspend( Task_id[TASKID_PRC0] ); | |
689 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
689 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
690 | { |
|
690 | { | |
691 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) |
|
691 | PRINTF1("in suspend_science_task *** PRC0 ERR %d\n", status) | |
692 | } |
|
692 | } | |
693 | else |
|
693 | else | |
694 | { |
|
694 | { | |
695 | status = RTEMS_SUCCESSFUL; |
|
695 | status = RTEMS_SUCCESSFUL; | |
696 | } |
|
696 | } | |
697 | } |
|
697 | } | |
698 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 |
|
698 | if (status == RTEMS_SUCCESSFUL) // suspend AVF1 | |
699 | { |
|
699 | { | |
700 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); |
|
700 | status = rtems_task_suspend( Task_id[TASKID_AVF1] ); | |
701 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
701 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
702 | { |
|
702 | { | |
703 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) |
|
703 | PRINTF1("in suspend_science_task *** AVF1 ERR %d\n", status) | |
704 | } |
|
704 | } | |
705 | else |
|
705 | else | |
706 | { |
|
706 | { | |
707 | status = RTEMS_SUCCESSFUL; |
|
707 | status = RTEMS_SUCCESSFUL; | |
708 | } |
|
708 | } | |
709 | } |
|
709 | } | |
710 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 |
|
710 | if (status == RTEMS_SUCCESSFUL) // suspend PRC1 | |
711 | { |
|
711 | { | |
712 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); |
|
712 | status = rtems_task_suspend( Task_id[TASKID_PRC1] ); | |
713 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
713 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
714 | { |
|
714 | { | |
715 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) |
|
715 | PRINTF1("in suspend_science_task *** PRC1 ERR %d\n", status) | |
716 | } |
|
716 | } | |
717 | else |
|
717 | else | |
718 | { |
|
718 | { | |
719 | status = RTEMS_SUCCESSFUL; |
|
719 | status = RTEMS_SUCCESSFUL; | |
720 | } |
|
720 | } | |
721 | } |
|
721 | } | |
722 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 |
|
722 | if (status == RTEMS_SUCCESSFUL) // suspend AVF2 | |
723 | { |
|
723 | { | |
724 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); |
|
724 | status = rtems_task_suspend( Task_id[TASKID_AVF2] ); | |
725 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
725 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
726 | { |
|
726 | { | |
727 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) |
|
727 | PRINTF1("in suspend_science_task *** AVF2 ERR %d\n", status) | |
728 | } |
|
728 | } | |
729 | else |
|
729 | else | |
730 | { |
|
730 | { | |
731 | status = RTEMS_SUCCESSFUL; |
|
731 | status = RTEMS_SUCCESSFUL; | |
732 | } |
|
732 | } | |
733 | } |
|
733 | } | |
734 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 |
|
734 | if (status == RTEMS_SUCCESSFUL) // suspend PRC2 | |
735 | { |
|
735 | { | |
736 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); |
|
736 | status = rtems_task_suspend( Task_id[TASKID_PRC2] ); | |
737 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
737 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
738 | { |
|
738 | { | |
739 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) |
|
739 | PRINTF1("in suspend_science_task *** PRC2 ERR %d\n", status) | |
740 | } |
|
740 | } | |
741 | else |
|
741 | else | |
742 | { |
|
742 | { | |
743 | status = RTEMS_SUCCESSFUL; |
|
743 | status = RTEMS_SUCCESSFUL; | |
744 | } |
|
744 | } | |
745 | } |
|
745 | } | |
746 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM |
|
746 | if (status == RTEMS_SUCCESSFUL) // suspend WFRM | |
747 | { |
|
747 | { | |
748 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); |
|
748 | status = rtems_task_suspend( Task_id[TASKID_WFRM] ); | |
749 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
749 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
750 | { |
|
750 | { | |
751 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) |
|
751 | PRINTF1("in suspend_science_task *** WFRM ERR %d\n", status) | |
752 | } |
|
752 | } | |
753 | else |
|
753 | else | |
754 | { |
|
754 | { | |
755 | status = RTEMS_SUCCESSFUL; |
|
755 | status = RTEMS_SUCCESSFUL; | |
756 | } |
|
756 | } | |
757 | } |
|
757 | } | |
758 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 |
|
758 | if (status == RTEMS_SUCCESSFUL) // suspend CWF3 | |
759 | { |
|
759 | { | |
760 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); |
|
760 | status = rtems_task_suspend( Task_id[TASKID_CWF3] ); | |
761 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
761 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
762 | { |
|
762 | { | |
763 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) |
|
763 | PRINTF1("in suspend_science_task *** CWF3 ERR %d\n", status) | |
764 | } |
|
764 | } | |
765 | else |
|
765 | else | |
766 | { |
|
766 | { | |
767 | status = RTEMS_SUCCESSFUL; |
|
767 | status = RTEMS_SUCCESSFUL; | |
768 | } |
|
768 | } | |
769 | } |
|
769 | } | |
770 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 |
|
770 | if (status == RTEMS_SUCCESSFUL) // suspend CWF2 | |
771 | { |
|
771 | { | |
772 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); |
|
772 | status = rtems_task_suspend( Task_id[TASKID_CWF2] ); | |
773 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
773 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
774 | { |
|
774 | { | |
775 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) |
|
775 | PRINTF1("in suspend_science_task *** CWF2 ERR %d\n", status) | |
776 | } |
|
776 | } | |
777 | else |
|
777 | else | |
778 | { |
|
778 | { | |
779 | status = RTEMS_SUCCESSFUL; |
|
779 | status = RTEMS_SUCCESSFUL; | |
780 | } |
|
780 | } | |
781 | } |
|
781 | } | |
782 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 |
|
782 | if (status == RTEMS_SUCCESSFUL) // suspend CWF1 | |
783 | { |
|
783 | { | |
784 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); |
|
784 | status = rtems_task_suspend( Task_id[TASKID_CWF1] ); | |
785 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) |
|
785 | if ((status != RTEMS_SUCCESSFUL) && (status != RTEMS_ALREADY_SUSPENDED)) | |
786 | { |
|
786 | { | |
787 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) |
|
787 | PRINTF1("in suspend_science_task *** CWF1 ERR %d\n", status) | |
788 | } |
|
788 | } | |
789 | else |
|
789 | else | |
790 | { |
|
790 | { | |
791 | status = RTEMS_SUCCESSFUL; |
|
791 | status = RTEMS_SUCCESSFUL; | |
792 | } |
|
792 | } | |
793 | } |
|
793 | } | |
794 |
|
794 | |||
795 | return status; |
|
795 | return status; | |
796 | } |
|
796 | } | |
797 |
|
797 | |||
798 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) |
|
798 | void launch_waveform_picker( unsigned char mode, unsigned int transitionCoarseTime ) | |
799 | { |
|
799 | { | |
800 | WFP_reset_current_ring_nodes(); |
|
800 | WFP_reset_current_ring_nodes(); | |
801 |
|
801 | |||
802 | reset_waveform_picker_regs(); |
|
802 | reset_waveform_picker_regs(); | |
803 |
|
803 | |||
804 | set_wfp_burst_enable_register( mode ); |
|
804 | set_wfp_burst_enable_register( mode ); | |
805 |
|
805 | |||
806 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); |
|
806 | LEON_Clear_interrupt( IRQ_WAVEFORM_PICKER ); | |
807 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); |
|
807 | LEON_Unmask_interrupt( IRQ_WAVEFORM_PICKER ); | |
808 |
|
808 | |||
809 | if (transitionCoarseTime == 0) |
|
809 | if (transitionCoarseTime == 0) | |
810 | { |
|
810 | { | |
811 | waveform_picker_regs->start_date = time_management_regs->coarse_time; |
|
811 | waveform_picker_regs->start_date = time_management_regs->coarse_time; | |
812 | } |
|
812 | } | |
813 | else |
|
813 | else | |
814 | { |
|
814 | { | |
815 | waveform_picker_regs->start_date = transitionCoarseTime; |
|
815 | waveform_picker_regs->start_date = transitionCoarseTime; | |
816 | } |
|
816 | } | |
817 |
|
817 | |||
818 | } |
|
818 | } | |
819 |
|
819 | |||
820 | void launch_spectral_matrix( void ) |
|
820 | void launch_spectral_matrix( void ) | |
821 | { |
|
821 | { | |
822 | SM_reset_current_ring_nodes(); |
|
822 | SM_reset_current_ring_nodes(); | |
823 |
|
823 | |||
824 | reset_spectral_matrix_regs(); |
|
824 | reset_spectral_matrix_regs(); | |
825 |
|
825 | |||
826 | reset_nb_sm(); |
|
826 | reset_nb_sm(); | |
827 |
|
827 | |||
828 | set_sm_irq_onNewMatrix( 1 ); |
|
828 | set_sm_irq_onNewMatrix( 1 ); | |
829 |
|
829 | |||
830 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
830 | LEON_Clear_interrupt( IRQ_SPECTRAL_MATRIX ); | |
831 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); |
|
831 | LEON_Unmask_interrupt( IRQ_SPECTRAL_MATRIX ); | |
832 |
|
832 | |||
833 | } |
|
833 | } | |
834 |
|
834 | |||
835 | void launch_spectral_matrix_simu( void ) |
|
835 | void launch_spectral_matrix_simu( void ) | |
836 | { |
|
836 | { | |
837 | SM_reset_current_ring_nodes(); |
|
837 | SM_reset_current_ring_nodes(); | |
838 | reset_spectral_matrix_regs(); |
|
838 | reset_spectral_matrix_regs(); | |
839 | reset_nb_sm(); |
|
839 | reset_nb_sm(); | |
840 |
|
840 | |||
841 | // Spectral Matrices simulator |
|
841 | // Spectral Matrices simulator | |
842 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); |
|
842 | timer_start( (gptimer_regs_t*) REGS_ADDR_GPTIMER, TIMER_SM_SIMULATOR ); | |
843 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); |
|
843 | LEON_Clear_interrupt( IRQ_SM_SIMULATOR ); | |
844 | LEON_Unmask_interrupt( IRQ_SM_SIMULATOR ); |
|
844 | LEON_Unmask_interrupt( IRQ_SM_SIMULATOR ); | |
845 | } |
|
845 | } | |
846 |
|
846 | |||
847 | void set_sm_irq_onNewMatrix( unsigned char value ) |
|
847 | void set_sm_irq_onNewMatrix( unsigned char value ) | |
848 | { |
|
848 | { | |
849 | if (value == 1) |
|
849 | if (value == 1) | |
850 | { |
|
850 | { | |
851 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; |
|
851 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x01; | |
852 | } |
|
852 | } | |
853 | else |
|
853 | else | |
854 | { |
|
854 | { | |
855 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 |
|
855 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffe; // 1110 | |
856 | } |
|
856 | } | |
857 | } |
|
857 | } | |
858 |
|
858 | |||
859 | void set_sm_irq_onError( unsigned char value ) |
|
859 | void set_sm_irq_onError( unsigned char value ) | |
860 | { |
|
860 | { | |
861 | if (value == 1) |
|
861 | if (value == 1) | |
862 | { |
|
862 | { | |
863 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02; |
|
863 | spectral_matrix_regs->config = spectral_matrix_regs->config | 0x02; | |
864 | } |
|
864 | } | |
865 | else |
|
865 | else | |
866 | { |
|
866 | { | |
867 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101 |
|
867 | spectral_matrix_regs->config = spectral_matrix_regs->config & 0xfffffffd; // 1101 | |
868 | } |
|
868 | } | |
869 | } |
|
869 | } | |
870 |
|
870 | |||
871 | //***************************** |
|
871 | //***************************** | |
872 | // CONFIGURE CALIBRATION SIGNAL |
|
872 | // CONFIGURE CALIBRATION SIGNAL | |
873 | void setCalibrationPrescaler( unsigned int prescaler ) |
|
873 | void setCalibrationPrescaler( unsigned int prescaler ) | |
874 | { |
|
874 | { | |
875 | // prescaling of the master clock (25 MHz) |
|
875 | // prescaling of the master clock (25 MHz) | |
876 | // master clock is divided by 2^prescaler |
|
876 | // master clock is divided by 2^prescaler | |
877 | time_management_regs->calPrescaler = prescaler; |
|
877 | time_management_regs->calPrescaler = prescaler; | |
878 | } |
|
878 | } | |
879 |
|
879 | |||
880 | void setCalibrationDivisor( unsigned int divisionFactor ) |
|
880 | void setCalibrationDivisor( unsigned int divisionFactor ) | |
881 | { |
|
881 | { | |
882 | // division of the prescaled clock by the division factor |
|
882 | // division of the prescaled clock by the division factor | |
883 | time_management_regs->calDivisor = divisionFactor; |
|
883 | time_management_regs->calDivisor = divisionFactor; | |
884 | } |
|
884 | } | |
885 |
|
885 | |||
886 | void setCalibrationData( void ){ |
|
886 | void setCalibrationData( void ){ | |
887 | unsigned int k; |
|
887 | unsigned int k; | |
888 | unsigned short data; |
|
888 | unsigned short data; | |
889 | float val; |
|
889 | float val; | |
890 | float f0; |
|
890 | float f0; | |
891 | float f1; |
|
891 | float f1; | |
892 | float fs; |
|
892 | float fs; | |
893 | float Ts; |
|
893 | float Ts; | |
894 | float scaleFactor; |
|
894 | float scaleFactor; | |
895 |
|
895 | |||
896 | f0 = 625; |
|
896 | f0 = 625; | |
897 | f1 = 10000; |
|
897 | f1 = 10000; | |
898 | fs = 160256.410; |
|
898 | fs = 160256.410; | |
899 | Ts = 1. / fs; |
|
899 | Ts = 1. / fs; | |
900 | scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV |
|
900 | scaleFactor = 0.250 / 0.000654; // 191, 500 mVpp, 2 sinus waves => 500 mVpp each, amplitude = 250 mV | |
901 |
|
901 | |||
902 | time_management_regs->calDataPtr = 0x00; |
|
902 | time_management_regs->calDataPtr = 0x00; | |
903 |
|
903 | |||
904 | // build the signal for the SCM calibration |
|
904 | // build the signal for the SCM calibration | |
905 | for (k=0; k<256; k++) |
|
905 | for (k=0; k<256; k++) | |
906 | { |
|
906 | { | |
907 | val = sin( 2 * pi * f0 * k * Ts ) |
|
907 | val = sin( 2 * pi * f0 * k * Ts ) | |
908 | + sin( 2 * pi * f1 * k * Ts ); |
|
908 | + sin( 2 * pi * f1 * k * Ts ); | |
909 | data = (unsigned short) ((val * scaleFactor) + 2048); |
|
909 | data = (unsigned short) ((val * scaleFactor) + 2048); | |
910 | time_management_regs->calData = data & 0xfff; |
|
910 | time_management_regs->calData = data & 0xfff; | |
911 | } |
|
911 | } | |
912 | } |
|
912 | } | |
913 |
|
913 | |||
914 | void setCalibrationDataInterleaved( void ){ |
|
914 | void setCalibrationDataInterleaved( void ){ | |
915 | unsigned int k; |
|
915 | unsigned int k; | |
916 | float val; |
|
916 | float val; | |
917 | float f0; |
|
917 | float f0; | |
918 | float f1; |
|
918 | float f1; | |
919 | float fs; |
|
919 | float fs; | |
920 | float Ts; |
|
920 | float Ts; | |
921 | unsigned short data[384]; |
|
921 | unsigned short data[384]; | |
922 | unsigned char *dataPtr; |
|
922 | unsigned char *dataPtr; | |
923 |
|
923 | |||
924 | f0 = 625; |
|
924 | f0 = 625; | |
925 | f1 = 10000; |
|
925 | f1 = 10000; | |
926 | fs = 240384.615; |
|
926 | fs = 240384.615; | |
927 | Ts = 1. / fs; |
|
927 | Ts = 1. / fs; | |
928 |
|
928 | |||
929 | time_management_regs->calDataPtr = 0x00; |
|
929 | time_management_regs->calDataPtr = 0x00; | |
930 |
|
930 | |||
931 | // build the signal for the SCM calibration |
|
931 | // build the signal for the SCM calibration | |
932 | for (k=0; k<384; k++) |
|
932 | for (k=0; k<384; k++) | |
933 | { |
|
933 | { | |
934 | val = sin( 2 * pi * f0 * k * Ts ) |
|
934 | val = sin( 2 * pi * f0 * k * Ts ) | |
935 | + sin( 2 * pi * f1 * k * Ts ); |
|
935 | + sin( 2 * pi * f1 * k * Ts ); | |
936 | data[k] = (unsigned short) (val * 512 + 2048); |
|
936 | data[k] = (unsigned short) (val * 512 + 2048); | |
937 | } |
|
937 | } | |
938 |
|
938 | |||
939 | // write the signal in interleaved mode |
|
939 | // write the signal in interleaved mode | |
940 | for (k=0; k<128; k++) |
|
940 | for (k=0; k<128; k++) | |
941 | { |
|
941 | { | |
942 | dataPtr = (unsigned char*) &data[k*3 + 2]; |
|
942 | dataPtr = (unsigned char*) &data[k*3 + 2]; | |
943 | time_management_regs->calData = (data[k*3] & 0xfff) |
|
943 | time_management_regs->calData = (data[k*3] & 0xfff) | |
944 | + ( (dataPtr[0] & 0x3f) << 12); |
|
944 | + ( (dataPtr[0] & 0x3f) << 12); | |
945 | time_management_regs->calData = (data[k*3 + 1] & 0xfff) |
|
945 | time_management_regs->calData = (data[k*3 + 1] & 0xfff) | |
946 | + ( (dataPtr[1] & 0x3f) << 12); |
|
946 | + ( (dataPtr[1] & 0x3f) << 12); | |
947 | } |
|
947 | } | |
948 | } |
|
948 | } | |
949 |
|
949 | |||
950 | void setCalibrationReload( bool state) |
|
950 | void setCalibrationReload( bool state) | |
951 | { |
|
951 | { | |
952 | if (state == true) |
|
952 | if (state == true) | |
953 | { |
|
953 | { | |
954 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000] |
|
954 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000010; // [0001 0000] | |
955 | } |
|
955 | } | |
956 | else |
|
956 | else | |
957 | { |
|
957 | { | |
958 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111] |
|
958 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffef; // [1110 1111] | |
959 | } |
|
959 | } | |
960 | } |
|
960 | } | |
961 |
|
961 | |||
962 | void setCalibrationEnable( bool state ) |
|
962 | void setCalibrationEnable( bool state ) | |
963 | { |
|
963 | { | |
964 | // this bit drives the multiplexer |
|
964 | // this bit drives the multiplexer | |
965 | if (state == true) |
|
965 | if (state == true) | |
966 | { |
|
966 | { | |
967 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000] |
|
967 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000040; // [0100 0000] | |
968 | } |
|
968 | } | |
969 | else |
|
969 | else | |
970 | { |
|
970 | { | |
971 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111] |
|
971 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffbf; // [1011 1111] | |
972 | } |
|
972 | } | |
973 | } |
|
973 | } | |
974 |
|
974 | |||
975 | void setCalibrationInterleaved( bool state ) |
|
975 | void setCalibrationInterleaved( bool state ) | |
976 | { |
|
976 | { | |
977 | // this bit drives the multiplexer |
|
977 | // this bit drives the multiplexer | |
978 | if (state == true) |
|
978 | if (state == true) | |
979 | { |
|
979 | { | |
980 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000] |
|
980 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl | 0x00000020; // [0010 0000] | |
981 | } |
|
981 | } | |
982 | else |
|
982 | else | |
983 | { |
|
983 | { | |
984 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111] |
|
984 | time_management_regs->calDACCtrl = time_management_regs->calDACCtrl & 0xffffffdf; // [1101 1111] | |
985 | } |
|
985 | } | |
986 | } |
|
986 | } | |
987 |
|
987 | |||
988 | void setCalibration( bool state ) |
|
988 | void setCalibration( bool state ) | |
989 | { |
|
989 | { | |
990 | if (state == true) |
|
990 | if (state == true) | |
991 | { |
|
991 | { | |
992 | setCalibrationEnable( true ); |
|
992 | setCalibrationEnable( true ); | |
993 | setCalibrationReload( false ); |
|
993 | setCalibrationReload( false ); | |
994 | set_hk_lfr_calib_enable( true ); |
|
994 | set_hk_lfr_calib_enable( true ); | |
995 | } |
|
995 | } | |
996 | else |
|
996 | else | |
997 | { |
|
997 | { | |
998 | setCalibrationEnable( false ); |
|
998 | setCalibrationEnable( false ); | |
999 | setCalibrationReload( true ); |
|
999 | setCalibrationReload( true ); | |
1000 | set_hk_lfr_calib_enable( false ); |
|
1000 | set_hk_lfr_calib_enable( false ); | |
1001 | } |
|
1001 | } | |
1002 | } |
|
1002 | } | |
1003 |
|
1003 | |||
1004 | void configureCalibration( bool interleaved ) |
|
1004 | void configureCalibration( bool interleaved ) | |
1005 | { |
|
1005 | { | |
1006 | setCalibration( false ); |
|
1006 | setCalibration( false ); | |
1007 | if ( interleaved == true ) |
|
1007 | if ( interleaved == true ) | |
1008 | { |
|
1008 | { | |
1009 | setCalibrationInterleaved( true ); |
|
1009 | setCalibrationInterleaved( true ); | |
1010 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 |
|
1010 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 | |
1011 | setCalibrationDivisor( 26 ); // => 240 384 |
|
1011 | setCalibrationDivisor( 26 ); // => 240 384 | |
1012 | setCalibrationDataInterleaved(); |
|
1012 | setCalibrationDataInterleaved(); | |
1013 | } |
|
1013 | } | |
1014 | else |
|
1014 | else | |
1015 | { |
|
1015 | { | |
1016 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 |
|
1016 | setCalibrationPrescaler( 0 ); // 25 MHz => 25 000 000 | |
1017 | setCalibrationDivisor( 38 ); // => 160 256 (39 - 1) |
|
1017 | setCalibrationDivisor( 38 ); // => 160 256 (39 - 1) | |
1018 | setCalibrationData(); |
|
1018 | setCalibrationData(); | |
1019 | } |
|
1019 | } | |
1020 | } |
|
1020 | } | |
1021 |
|
1021 | |||
1022 | //**************** |
|
1022 | //**************** | |
1023 | // CLOSING ACTIONS |
|
1023 | // CLOSING ACTIONS | |
1024 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
1024 | void update_last_TC_exe( ccsdsTelecommandPacket_t *TC, unsigned char * time ) | |
1025 | { |
|
1025 | { | |
1026 | /** This function is used to update the HK packets statistics after a successful TC execution. |
|
1026 | /** This function is used to update the HK packets statistics after a successful TC execution. | |
1027 | * |
|
1027 | * | |
1028 | * @param TC points to the TC being processed |
|
1028 | * @param TC points to the TC being processed | |
1029 | * @param time is the time used to date the TC execution |
|
1029 | * @param time is the time used to date the TC execution | |
1030 | * |
|
1030 | * | |
1031 | */ |
|
1031 | */ | |
1032 |
|
1032 | |||
1033 | unsigned int val; |
|
1033 | unsigned int val; | |
1034 |
|
1034 | |||
1035 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; |
|
1035 | housekeeping_packet.hk_lfr_last_exe_tc_id[0] = TC->packetID[0]; | |
1036 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; |
|
1036 | housekeeping_packet.hk_lfr_last_exe_tc_id[1] = TC->packetID[1]; | |
1037 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; |
|
1037 | housekeeping_packet.hk_lfr_last_exe_tc_type[0] = 0x00; | |
1038 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; |
|
1038 | housekeeping_packet.hk_lfr_last_exe_tc_type[1] = TC->serviceType; | |
1039 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; |
|
1039 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[0] = 0x00; | |
1040 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; |
|
1040 | housekeeping_packet.hk_lfr_last_exe_tc_subtype[1] = TC->serviceSubType; | |
1041 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; |
|
1041 | housekeeping_packet.hk_lfr_last_exe_tc_time[0] = time[0]; | |
1042 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; |
|
1042 | housekeeping_packet.hk_lfr_last_exe_tc_time[1] = time[1]; | |
1043 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; |
|
1043 | housekeeping_packet.hk_lfr_last_exe_tc_time[2] = time[2]; | |
1044 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; |
|
1044 | housekeeping_packet.hk_lfr_last_exe_tc_time[3] = time[3]; | |
1045 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; |
|
1045 | housekeeping_packet.hk_lfr_last_exe_tc_time[4] = time[4]; | |
1046 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; |
|
1046 | housekeeping_packet.hk_lfr_last_exe_tc_time[5] = time[5]; | |
1047 |
|
1047 | |||
1048 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; |
|
1048 | val = housekeeping_packet.hk_lfr_exe_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_exe_tc_cnt[1]; | |
1049 | val++; |
|
1049 | val++; | |
1050 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); |
|
1050 | housekeeping_packet.hk_lfr_exe_tc_cnt[0] = (unsigned char) (val >> 8); | |
1051 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); |
|
1051 | housekeeping_packet.hk_lfr_exe_tc_cnt[1] = (unsigned char) (val); | |
1052 | } |
|
1052 | } | |
1053 |
|
1053 | |||
1054 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) |
|
1054 | void update_last_TC_rej(ccsdsTelecommandPacket_t *TC, unsigned char * time ) | |
1055 | { |
|
1055 | { | |
1056 | /** This function is used to update the HK packets statistics after a TC rejection. |
|
1056 | /** This function is used to update the HK packets statistics after a TC rejection. | |
1057 | * |
|
1057 | * | |
1058 | * @param TC points to the TC being processed |
|
1058 | * @param TC points to the TC being processed | |
1059 | * @param time is the time used to date the TC rejection |
|
1059 | * @param time is the time used to date the TC rejection | |
1060 | * |
|
1060 | * | |
1061 | */ |
|
1061 | */ | |
1062 |
|
1062 | |||
1063 | unsigned int val; |
|
1063 | unsigned int val; | |
1064 |
|
1064 | |||
1065 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; |
|
1065 | housekeeping_packet.hk_lfr_last_rej_tc_id[0] = TC->packetID[0]; | |
1066 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; |
|
1066 | housekeeping_packet.hk_lfr_last_rej_tc_id[1] = TC->packetID[1]; | |
1067 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; |
|
1067 | housekeeping_packet.hk_lfr_last_rej_tc_type[0] = 0x00; | |
1068 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; |
|
1068 | housekeeping_packet.hk_lfr_last_rej_tc_type[1] = TC->serviceType; | |
1069 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; |
|
1069 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[0] = 0x00; | |
1070 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; |
|
1070 | housekeeping_packet.hk_lfr_last_rej_tc_subtype[1] = TC->serviceSubType; | |
1071 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; |
|
1071 | housekeeping_packet.hk_lfr_last_rej_tc_time[0] = time[0]; | |
1072 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; |
|
1072 | housekeeping_packet.hk_lfr_last_rej_tc_time[1] = time[1]; | |
1073 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; |
|
1073 | housekeeping_packet.hk_lfr_last_rej_tc_time[2] = time[2]; | |
1074 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; |
|
1074 | housekeeping_packet.hk_lfr_last_rej_tc_time[3] = time[3]; | |
1075 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; |
|
1075 | housekeeping_packet.hk_lfr_last_rej_tc_time[4] = time[4]; | |
1076 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; |
|
1076 | housekeeping_packet.hk_lfr_last_rej_tc_time[5] = time[5]; | |
1077 |
|
1077 | |||
1078 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; |
|
1078 | val = housekeeping_packet.hk_lfr_rej_tc_cnt[0] * 256 + housekeeping_packet.hk_lfr_rej_tc_cnt[1]; | |
1079 | val++; |
|
1079 | val++; | |
1080 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); |
|
1080 | housekeeping_packet.hk_lfr_rej_tc_cnt[0] = (unsigned char) (val >> 8); | |
1081 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); |
|
1081 | housekeeping_packet.hk_lfr_rej_tc_cnt[1] = (unsigned char) (val); | |
1082 | } |
|
1082 | } | |
1083 |
|
1083 | |||
1084 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) |
|
1084 | void close_action(ccsdsTelecommandPacket_t *TC, int result, rtems_id queue_id ) | |
1085 | { |
|
1085 | { | |
1086 | /** This function is the last step of the TC execution workflow. |
|
1086 | /** This function is the last step of the TC execution workflow. | |
1087 | * |
|
1087 | * | |
1088 | * @param TC points to the TC being processed |
|
1088 | * @param TC points to the TC being processed | |
1089 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) |
|
1089 | * @param result is the result of the TC execution (LFR_SUCCESSFUL / LFR_DEFAULT) | |
1090 | * @param queue_id is the id of the RTEMS message queue used to send TM packets |
|
1090 | * @param queue_id is the id of the RTEMS message queue used to send TM packets | |
1091 | * @param time is the time used to date the TC execution |
|
1091 | * @param time is the time used to date the TC execution | |
1092 | * |
|
1092 | * | |
1093 | */ |
|
1093 | */ | |
1094 |
|
1094 | |||
1095 | unsigned char requestedMode; |
|
1095 | unsigned char requestedMode; | |
1096 |
|
1096 | |||
1097 | if (result == LFR_SUCCESSFUL) |
|
1097 | if (result == LFR_SUCCESSFUL) | |
1098 | { |
|
1098 | { | |
1099 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) |
|
1099 | if ( !( (TC->serviceType==TC_TYPE_TIME) & (TC->serviceSubType==TC_SUBTYPE_UPDT_TIME) ) | |
1100 | & |
|
1100 | & | |
1101 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) |
|
1101 | !( (TC->serviceType==TC_TYPE_GEN) & (TC->serviceSubType==TC_SUBTYPE_UPDT_INFO)) | |
1102 | ) |
|
1102 | ) | |
1103 | { |
|
1103 | { | |
1104 | send_tm_lfr_tc_exe_success( TC, queue_id ); |
|
1104 | send_tm_lfr_tc_exe_success( TC, queue_id ); | |
1105 | } |
|
1105 | } | |
1106 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) |
|
1106 | if ( (TC->serviceType == TC_TYPE_GEN) & (TC->serviceSubType == TC_SUBTYPE_ENTER) ) | |
1107 | { |
|
1107 | { | |
1108 | //********************************** |
|
1108 | //********************************** | |
1109 | // UPDATE THE LFRMODE LOCAL VARIABLE |
|
1109 | // UPDATE THE LFRMODE LOCAL VARIABLE | |
1110 | requestedMode = TC->dataAndCRC[1]; |
|
1110 | requestedMode = TC->dataAndCRC[1]; | |
1111 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d); |
|
1111 | housekeeping_packet.lfr_status_word[0] = (unsigned char) ((requestedMode << 4) + 0x0d); | |
1112 | updateLFRCurrentMode(); |
|
1112 | updateLFRCurrentMode(); | |
1113 | } |
|
1113 | } | |
1114 | } |
|
1114 | } | |
1115 | else if (result == LFR_EXE_ERROR) |
|
1115 | else if (result == LFR_EXE_ERROR) | |
1116 | { |
|
1116 | { | |
1117 | send_tm_lfr_tc_exe_error( TC, queue_id ); |
|
1117 | send_tm_lfr_tc_exe_error( TC, queue_id ); | |
1118 | } |
|
1118 | } | |
1119 | } |
|
1119 | } | |
1120 |
|
1120 | |||
1121 | //*************************** |
|
1121 | //*************************** | |
1122 | // Interrupt Service Routines |
|
1122 | // Interrupt Service Routines | |
1123 | rtems_isr commutation_isr1( rtems_vector_number vector ) |
|
1123 | rtems_isr commutation_isr1( rtems_vector_number vector ) | |
1124 | { |
|
1124 | { | |
1125 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1125 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
1126 | printf("In commutation_isr1 *** Error sending event to DUMB\n"); |
|
1126 | printf("In commutation_isr1 *** Error sending event to DUMB\n"); | |
1127 | } |
|
1127 | } | |
1128 | } |
|
1128 | } | |
1129 |
|
1129 | |||
1130 | rtems_isr commutation_isr2( rtems_vector_number vector ) |
|
1130 | rtems_isr commutation_isr2( rtems_vector_number vector ) | |
1131 | { |
|
1131 | { | |
1132 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { |
|
1132 | if (rtems_event_send( Task_id[TASKID_DUMB], RTEMS_EVENT_0 ) != RTEMS_SUCCESSFUL) { | |
1133 | printf("In commutation_isr2 *** Error sending event to DUMB\n"); |
|
1133 | printf("In commutation_isr2 *** Error sending event to DUMB\n"); | |
1134 | } |
|
1134 | } | |
1135 | } |
|
1135 | } | |
1136 |
|
1136 | |||
1137 | //**************** |
|
1137 | //**************** | |
1138 | // OTHER FUNCTIONS |
|
1138 | // OTHER FUNCTIONS | |
1139 | void updateLFRCurrentMode() |
|
1139 | void updateLFRCurrentMode() | |
1140 | { |
|
1140 | { | |
1141 | /** This function updates the value of the global variable lfrCurrentMode. |
|
1141 | /** This function updates the value of the global variable lfrCurrentMode. | |
1142 | * |
|
1142 | * | |
1143 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. |
|
1143 | * lfrCurrentMode is a parameter used by several functions to know in which mode LFR is running. | |
1144 | * |
|
1144 | * | |
1145 | */ |
|
1145 | */ | |
1146 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure |
|
1146 | // update the local value of lfrCurrentMode with the value contained in the housekeeping_packet structure | |
1147 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; |
|
1147 | lfrCurrentMode = (housekeeping_packet.lfr_status_word[0] & 0xf0) >> 4; | |
1148 | } |
|
1148 | } | |
1149 |
|
1149 | |||
1150 | void set_lfr_soft_reset( unsigned char value ) |
|
1150 | void set_lfr_soft_reset( unsigned char value ) | |
1151 | { |
|
1151 | { | |
1152 | if (value == 1) |
|
1152 | if (value == 1) | |
1153 | { |
|
1153 | { | |
1154 | time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100] |
|
1154 | time_management_regs->ctrl = time_management_regs->ctrl | 0x00000004; // [0100] | |
1155 | } |
|
1155 | } | |
1156 | else |
|
1156 | else | |
1157 | { |
|
1157 | { | |
1158 | time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011] |
|
1158 | time_management_regs->ctrl = time_management_regs->ctrl & 0xfffffffb; // [1011] | |
1159 | } |
|
1159 | } | |
1160 | } |
|
1160 | } | |
1161 |
|
1161 | |||
1162 | void reset_lfr( void ) |
|
1162 | void reset_lfr( void ) | |
1163 | { |
|
1163 | { | |
1164 | set_lfr_soft_reset( 1 ); |
|
1164 | set_lfr_soft_reset( 1 ); | |
1165 |
|
1165 | |||
1166 | set_lfr_soft_reset( 0 ); |
|
1166 | set_lfr_soft_reset( 0 ); | |
1167 |
|
1167 | |||
1168 | set_hk_lfr_sc_potential_flag( true ); |
|
1168 | set_hk_lfr_sc_potential_flag( true ); | |
1169 | } |
|
1169 | } |
@@ -1,1174 +1,1175 | |||||
1 | /** Functions to load and dump parameters in the LFR registers. |
|
1 | /** Functions to load and dump parameters in the LFR registers. | |
2 | * |
|
2 | * | |
3 | * @file |
|
3 | * @file | |
4 | * @author P. LEROY |
|
4 | * @author P. LEROY | |
5 | * |
|
5 | * | |
6 | * A group of functions to handle TC related to parameter loading and dumping.\n |
|
6 | * A group of functions to handle TC related to parameter loading and dumping.\n | |
7 | * TC_LFR_LOAD_COMMON_PAR\n |
|
7 | * TC_LFR_LOAD_COMMON_PAR\n | |
8 | * TC_LFR_LOAD_NORMAL_PAR\n |
|
8 | * TC_LFR_LOAD_NORMAL_PAR\n | |
9 | * TC_LFR_LOAD_BURST_PAR\n |
|
9 | * TC_LFR_LOAD_BURST_PAR\n | |
10 | * TC_LFR_LOAD_SBM1_PAR\n |
|
10 | * TC_LFR_LOAD_SBM1_PAR\n | |
11 | * TC_LFR_LOAD_SBM2_PAR\n |
|
11 | * TC_LFR_LOAD_SBM2_PAR\n | |
12 | * |
|
12 | * | |
13 | */ |
|
13 | */ | |
14 |
|
14 | |||
15 | #include "tc_load_dump_parameters.h" |
|
15 | #include "tc_load_dump_parameters.h" | |
16 |
|
16 | |||
17 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_1; |
|
17 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_1; | |
18 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_2; |
|
18 | Packet_TM_LFR_KCOEFFICIENTS_DUMP_t kcoefficients_dump_2; | |
19 | ring_node kcoefficient_node_1; |
|
19 | ring_node kcoefficient_node_1; | |
20 | ring_node kcoefficient_node_2; |
|
20 | ring_node kcoefficient_node_2; | |
21 |
|
21 | |||
22 | int action_load_common_par(ccsdsTelecommandPacket_t *TC) |
|
22 | int action_load_common_par(ccsdsTelecommandPacket_t *TC) | |
23 | { |
|
23 | { | |
24 | /** This function updates the LFR registers with the incoming common parameters. |
|
24 | /** This function updates the LFR registers with the incoming common parameters. | |
25 | * |
|
25 | * | |
26 | * @param TC points to the TeleCommand packet that is being processed |
|
26 | * @param TC points to the TeleCommand packet that is being processed | |
27 | * |
|
27 | * | |
28 | * |
|
28 | * | |
29 | */ |
|
29 | */ | |
30 |
|
30 | |||
31 | parameter_dump_packet.sy_lfr_common_parameters_spare = TC->dataAndCRC[0]; |
|
31 | parameter_dump_packet.sy_lfr_common_parameters_spare = TC->dataAndCRC[0]; | |
32 | parameter_dump_packet.sy_lfr_common_parameters = TC->dataAndCRC[1]; |
|
32 | parameter_dump_packet.sy_lfr_common_parameters = TC->dataAndCRC[1]; | |
33 | set_wfp_data_shaping( ); |
|
33 | set_wfp_data_shaping( ); | |
34 | return LFR_SUCCESSFUL; |
|
34 | return LFR_SUCCESSFUL; | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
37 | int action_load_normal_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
38 | { |
|
38 | { | |
39 | /** This function updates the LFR registers with the incoming normal parameters. |
|
39 | /** This function updates the LFR registers with the incoming normal parameters. | |
40 | * |
|
40 | * | |
41 | * @param TC points to the TeleCommand packet that is being processed |
|
41 | * @param TC points to the TeleCommand packet that is being processed | |
42 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
42 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
43 | * |
|
43 | * | |
44 | */ |
|
44 | */ | |
45 |
|
45 | |||
46 | int result; |
|
46 | int result; | |
47 | int flag; |
|
47 | int flag; | |
48 | rtems_status_code status; |
|
48 | rtems_status_code status; | |
49 |
|
49 | |||
50 | flag = LFR_SUCCESSFUL; |
|
50 | flag = LFR_SUCCESSFUL; | |
51 |
|
51 | |||
52 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || |
|
52 | if ( (lfrCurrentMode == LFR_MODE_NORMAL) || | |
53 | (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) { |
|
53 | (lfrCurrentMode == LFR_MODE_SBM1) || (lfrCurrentMode == LFR_MODE_SBM2) ) { | |
54 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
54 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
55 | flag = LFR_DEFAULT; |
|
55 | flag = LFR_DEFAULT; | |
56 | } |
|
56 | } | |
57 |
|
57 | |||
58 | // CHECK THE PARAMETERS SET CONSISTENCY |
|
58 | // CHECK THE PARAMETERS SET CONSISTENCY | |
59 | if (flag == LFR_SUCCESSFUL) |
|
59 | if (flag == LFR_SUCCESSFUL) | |
60 | { |
|
60 | { | |
61 | flag = check_common_par_consistency( TC, queue_id ); |
|
61 | flag = check_common_par_consistency( TC, queue_id ); | |
62 | } |
|
62 | } | |
63 |
|
63 | |||
64 | // SET THE PARAMETERS IF THEY ARE CONSISTENT |
|
64 | // SET THE PARAMETERS IF THEY ARE CONSISTENT | |
65 | if (flag == LFR_SUCCESSFUL) |
|
65 | if (flag == LFR_SUCCESSFUL) | |
66 | { |
|
66 | { | |
67 | result = set_sy_lfr_n_swf_l( TC ); |
|
67 | result = set_sy_lfr_n_swf_l( TC ); | |
68 | result = set_sy_lfr_n_swf_p( TC ); |
|
68 | result = set_sy_lfr_n_swf_p( TC ); | |
69 | result = set_sy_lfr_n_bp_p0( TC ); |
|
69 | result = set_sy_lfr_n_bp_p0( TC ); | |
70 | result = set_sy_lfr_n_bp_p1( TC ); |
|
70 | result = set_sy_lfr_n_bp_p1( TC ); | |
71 | result = set_sy_lfr_n_asm_p( TC ); |
|
71 | result = set_sy_lfr_n_asm_p( TC ); | |
72 | result = set_sy_lfr_n_cwf_long_f3( TC ); |
|
72 | result = set_sy_lfr_n_cwf_long_f3( TC ); | |
73 | } |
|
73 | } | |
74 |
|
74 | |||
75 | return flag; |
|
75 | return flag; | |
76 | } |
|
76 | } | |
77 |
|
77 | |||
78 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
78 | int action_load_burst_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
79 | { |
|
79 | { | |
80 | /** This function updates the LFR registers with the incoming burst parameters. |
|
80 | /** This function updates the LFR registers with the incoming burst parameters. | |
81 | * |
|
81 | * | |
82 | * @param TC points to the TeleCommand packet that is being processed |
|
82 | * @param TC points to the TeleCommand packet that is being processed | |
83 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
83 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
84 | * |
|
84 | * | |
85 | */ |
|
85 | */ | |
86 |
|
86 | |||
87 | int flag; |
|
87 | int flag; | |
88 | rtems_status_code status; |
|
88 | rtems_status_code status; | |
89 | unsigned char sy_lfr_b_bp_p0; |
|
89 | unsigned char sy_lfr_b_bp_p0; | |
90 | unsigned char sy_lfr_b_bp_p1; |
|
90 | unsigned char sy_lfr_b_bp_p1; | |
91 | float aux; |
|
91 | float aux; | |
92 |
|
92 | |||
93 | flag = LFR_SUCCESSFUL; |
|
93 | flag = LFR_SUCCESSFUL; | |
94 |
|
94 | |||
95 | if ( lfrCurrentMode == LFR_MODE_BURST ) { |
|
95 | if ( lfrCurrentMode == LFR_MODE_BURST ) { | |
96 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
96 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
97 | flag = LFR_DEFAULT; |
|
97 | flag = LFR_DEFAULT; | |
98 | } |
|
98 | } | |
99 |
|
99 | |||
100 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
100 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; | |
101 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
101 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; | |
102 |
|
102 | |||
103 | // sy_lfr_b_bp_p0 |
|
103 | // sy_lfr_b_bp_p0 | |
104 | if (flag == LFR_SUCCESSFUL) |
|
104 | if (flag == LFR_SUCCESSFUL) | |
105 | { |
|
105 | { | |
106 | if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 ) |
|
106 | if (sy_lfr_b_bp_p0 < DEFAULT_SY_LFR_B_BP_P0 ) | |
107 | { |
|
107 | { | |
108 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 ); |
|
108 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 ); | |
109 | flag = WRONG_APP_DATA; |
|
109 | flag = WRONG_APP_DATA; | |
110 | } |
|
110 | } | |
111 | } |
|
111 | } | |
112 | // sy_lfr_b_bp_p1 |
|
112 | // sy_lfr_b_bp_p1 | |
113 | if (flag == LFR_SUCCESSFUL) |
|
113 | if (flag == LFR_SUCCESSFUL) | |
114 | { |
|
114 | { | |
115 | if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 ) |
|
115 | if (sy_lfr_b_bp_p1 < DEFAULT_SY_LFR_B_BP_P1 ) | |
116 | { |
|
116 | { | |
117 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, sy_lfr_b_bp_p1 ); |
|
117 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P1+10, sy_lfr_b_bp_p1 ); | |
118 | flag = WRONG_APP_DATA; |
|
118 | flag = WRONG_APP_DATA; | |
119 | } |
|
119 | } | |
120 | } |
|
120 | } | |
121 | //**************************************************************** |
|
121 | //**************************************************************** | |
122 | // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1 |
|
122 | // check the consistency between sy_lfr_b_bp_p0 and sy_lfr_b_bp_p1 | |
123 | if (flag == LFR_SUCCESSFUL) |
|
123 | if (flag == LFR_SUCCESSFUL) | |
124 | { |
|
124 | { | |
125 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
125 | sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; | |
126 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
126 | sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; | |
127 | aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0); |
|
127 | aux = ( (float ) sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0 ) - floor(sy_lfr_b_bp_p1 / sy_lfr_b_bp_p0); | |
128 | if (aux > FLOAT_EQUAL_ZERO) |
|
128 | if (aux > FLOAT_EQUAL_ZERO) | |
129 | { |
|
129 | { | |
130 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 ); |
|
130 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_B_BP_P0+10, sy_lfr_b_bp_p0 ); | |
131 | flag = LFR_DEFAULT; |
|
131 | flag = LFR_DEFAULT; | |
132 | } |
|
132 | } | |
133 | } |
|
133 | } | |
134 |
|
134 | |||
135 | // SET HTE PARAMETERS |
|
135 | // SET HTE PARAMETERS | |
136 | if (flag == LFR_SUCCESSFUL) |
|
136 | if (flag == LFR_SUCCESSFUL) | |
137 | { |
|
137 | { | |
138 | flag = set_sy_lfr_b_bp_p0( TC ); |
|
138 | flag = set_sy_lfr_b_bp_p0( TC ); | |
139 | flag = set_sy_lfr_b_bp_p1( TC ); |
|
139 | flag = set_sy_lfr_b_bp_p1( TC ); | |
140 | } |
|
140 | } | |
141 |
|
141 | |||
142 | return flag; |
|
142 | return flag; | |
143 | } |
|
143 | } | |
144 |
|
144 | |||
145 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
145 | int action_load_sbm1_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
146 | { |
|
146 | { | |
147 | /** This function updates the LFR registers with the incoming sbm1 parameters. |
|
147 | /** This function updates the LFR registers with the incoming sbm1 parameters. | |
148 | * |
|
148 | * | |
149 | * @param TC points to the TeleCommand packet that is being processed |
|
149 | * @param TC points to the TeleCommand packet that is being processed | |
150 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
150 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
151 | * |
|
151 | * | |
152 | */ |
|
152 | */ | |
153 |
|
153 | |||
154 | int flag; |
|
154 | int flag; | |
155 | rtems_status_code status; |
|
155 | rtems_status_code status; | |
156 | unsigned char sy_lfr_s1_bp_p0; |
|
156 | unsigned char sy_lfr_s1_bp_p0; | |
157 | unsigned char sy_lfr_s1_bp_p1; |
|
157 | unsigned char sy_lfr_s1_bp_p1; | |
158 | float aux; |
|
158 | float aux; | |
159 |
|
159 | |||
160 | flag = LFR_SUCCESSFUL; |
|
160 | flag = LFR_SUCCESSFUL; | |
161 |
|
161 | |||
162 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { |
|
162 | if ( lfrCurrentMode == LFR_MODE_SBM1 ) { | |
163 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
163 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
164 | flag = LFR_DEFAULT; |
|
164 | flag = LFR_DEFAULT; | |
165 | } |
|
165 | } | |
166 |
|
166 | |||
167 | sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
167 | sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; | |
168 | sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
168 | sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; | |
169 |
|
169 | |||
170 | // sy_lfr_s1_bp_p0 |
|
170 | // sy_lfr_s1_bp_p0 | |
171 | if (flag == LFR_SUCCESSFUL) |
|
171 | if (flag == LFR_SUCCESSFUL) | |
172 | { |
|
172 | { | |
173 | if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 ) |
|
173 | if (sy_lfr_s1_bp_p0 < DEFAULT_SY_LFR_S1_BP_P0 ) | |
174 | { |
|
174 | { | |
175 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 ); |
|
175 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 ); | |
176 | flag = WRONG_APP_DATA; |
|
176 | flag = WRONG_APP_DATA; | |
177 | } |
|
177 | } | |
178 | } |
|
178 | } | |
179 | // sy_lfr_s1_bp_p1 |
|
179 | // sy_lfr_s1_bp_p1 | |
180 | if (flag == LFR_SUCCESSFUL) |
|
180 | if (flag == LFR_SUCCESSFUL) | |
181 | { |
|
181 | { | |
182 | if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 ) |
|
182 | if (sy_lfr_s1_bp_p1 < DEFAULT_SY_LFR_S1_BP_P1 ) | |
183 | { |
|
183 | { | |
184 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, sy_lfr_s1_bp_p1 ); |
|
184 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P1+10, sy_lfr_s1_bp_p1 ); | |
185 | flag = WRONG_APP_DATA; |
|
185 | flag = WRONG_APP_DATA; | |
186 | } |
|
186 | } | |
187 | } |
|
187 | } | |
188 | //****************************************************************** |
|
188 | //****************************************************************** | |
189 | // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1 |
|
189 | // check the consistency between sy_lfr_s1_bp_p0 and sy_lfr_s1_bp_p1 | |
190 | if (flag == LFR_SUCCESSFUL) |
|
190 | if (flag == LFR_SUCCESSFUL) | |
191 | { |
|
191 | { | |
192 | aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25)); |
|
192 | aux = ( (float ) sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25) ) - floor(sy_lfr_s1_bp_p1 / (sy_lfr_s1_bp_p0*0.25)); | |
193 | if (aux > FLOAT_EQUAL_ZERO) |
|
193 | if (aux > FLOAT_EQUAL_ZERO) | |
194 | { |
|
194 | { | |
195 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 ); |
|
195 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S1_BP_P0+10, sy_lfr_s1_bp_p0 ); | |
196 | flag = LFR_DEFAULT; |
|
196 | flag = LFR_DEFAULT; | |
197 | } |
|
197 | } | |
198 | } |
|
198 | } | |
199 |
|
199 | |||
200 | // SET THE PARAMETERS |
|
200 | // SET THE PARAMETERS | |
201 | if (flag == LFR_SUCCESSFUL) |
|
201 | if (flag == LFR_SUCCESSFUL) | |
202 | { |
|
202 | { | |
203 | flag = set_sy_lfr_s1_bp_p0( TC ); |
|
203 | flag = set_sy_lfr_s1_bp_p0( TC ); | |
204 | flag = set_sy_lfr_s1_bp_p1( TC ); |
|
204 | flag = set_sy_lfr_s1_bp_p1( TC ); | |
205 | } |
|
205 | } | |
206 |
|
206 | |||
207 | return flag; |
|
207 | return flag; | |
208 | } |
|
208 | } | |
209 |
|
209 | |||
210 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
210 | int action_load_sbm2_par(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
211 | { |
|
211 | { | |
212 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
212 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
213 | * |
|
213 | * | |
214 | * @param TC points to the TeleCommand packet that is being processed |
|
214 | * @param TC points to the TeleCommand packet that is being processed | |
215 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
215 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
216 | * |
|
216 | * | |
217 | */ |
|
217 | */ | |
218 |
|
218 | |||
219 | int flag; |
|
219 | int flag; | |
220 | rtems_status_code status; |
|
220 | rtems_status_code status; | |
221 | unsigned char sy_lfr_s2_bp_p0; |
|
221 | unsigned char sy_lfr_s2_bp_p0; | |
222 | unsigned char sy_lfr_s2_bp_p1; |
|
222 | unsigned char sy_lfr_s2_bp_p1; | |
223 | float aux; |
|
223 | float aux; | |
224 |
|
224 | |||
225 | flag = LFR_SUCCESSFUL; |
|
225 | flag = LFR_SUCCESSFUL; | |
226 |
|
226 | |||
227 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { |
|
227 | if ( lfrCurrentMode == LFR_MODE_SBM2 ) { | |
228 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); |
|
228 | status = send_tm_lfr_tc_exe_not_executable( TC, queue_id ); | |
229 | flag = LFR_DEFAULT; |
|
229 | flag = LFR_DEFAULT; | |
230 | } |
|
230 | } | |
231 |
|
231 | |||
232 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
232 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; | |
233 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
233 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; | |
234 |
|
234 | |||
235 | // sy_lfr_s2_bp_p0 |
|
235 | // sy_lfr_s2_bp_p0 | |
236 | if (flag == LFR_SUCCESSFUL) |
|
236 | if (flag == LFR_SUCCESSFUL) | |
237 | { |
|
237 | { | |
238 | if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 ) |
|
238 | if (sy_lfr_s2_bp_p0 < DEFAULT_SY_LFR_S2_BP_P0 ) | |
239 | { |
|
239 | { | |
240 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 ); |
|
240 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 ); | |
241 | flag = WRONG_APP_DATA; |
|
241 | flag = WRONG_APP_DATA; | |
242 | } |
|
242 | } | |
243 | } |
|
243 | } | |
244 | // sy_lfr_s2_bp_p1 |
|
244 | // sy_lfr_s2_bp_p1 | |
245 | if (flag == LFR_SUCCESSFUL) |
|
245 | if (flag == LFR_SUCCESSFUL) | |
246 | { |
|
246 | { | |
247 | if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 ) |
|
247 | if (sy_lfr_s2_bp_p1 < DEFAULT_SY_LFR_S2_BP_P1 ) | |
248 | { |
|
248 | { | |
249 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, sy_lfr_s2_bp_p1 ); |
|
249 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P1+10, sy_lfr_s2_bp_p1 ); | |
250 | flag = WRONG_APP_DATA; |
|
250 | flag = WRONG_APP_DATA; | |
251 | } |
|
251 | } | |
252 | } |
|
252 | } | |
253 | //****************************************************************** |
|
253 | //****************************************************************** | |
254 | // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1 |
|
254 | // check the consistency between sy_lfr_s2_bp_p0 and sy_lfr_s2_bp_p1 | |
255 | if (flag == LFR_SUCCESSFUL) |
|
255 | if (flag == LFR_SUCCESSFUL) | |
256 | { |
|
256 | { | |
257 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
257 | sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; | |
258 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
258 | sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; | |
259 | aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0); |
|
259 | aux = ( (float ) sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0 ) - floor(sy_lfr_s2_bp_p1 / sy_lfr_s2_bp_p0); | |
260 | if (aux > FLOAT_EQUAL_ZERO) |
|
260 | if (aux > FLOAT_EQUAL_ZERO) | |
261 | { |
|
261 | { | |
262 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 ); |
|
262 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_S2_BP_P0+10, sy_lfr_s2_bp_p0 ); | |
263 | flag = LFR_DEFAULT; |
|
263 | flag = LFR_DEFAULT; | |
264 | } |
|
264 | } | |
265 | } |
|
265 | } | |
266 |
|
266 | |||
267 | // SET THE PARAMETERS |
|
267 | // SET THE PARAMETERS | |
268 | if (flag == LFR_SUCCESSFUL) |
|
268 | if (flag == LFR_SUCCESSFUL) | |
269 | { |
|
269 | { | |
270 | flag = set_sy_lfr_s2_bp_p0( TC ); |
|
270 | flag = set_sy_lfr_s2_bp_p0( TC ); | |
271 | flag = set_sy_lfr_s2_bp_p1( TC ); |
|
271 | flag = set_sy_lfr_s2_bp_p1( TC ); | |
272 | } |
|
272 | } | |
273 |
|
273 | |||
274 | return flag; |
|
274 | return flag; | |
275 | } |
|
275 | } | |
276 |
|
276 | |||
277 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
277 | int action_load_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
278 | { |
|
278 | { | |
279 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
279 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
280 | * |
|
280 | * | |
281 | * @param TC points to the TeleCommand packet that is being processed |
|
281 | * @param TC points to the TeleCommand packet that is being processed | |
282 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
282 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
283 | * |
|
283 | * | |
284 | */ |
|
284 | */ | |
285 |
|
285 | |||
286 | int flag; |
|
286 | int flag; | |
287 |
|
287 | |||
288 | flag = LFR_DEFAULT; |
|
288 | flag = LFR_DEFAULT; | |
289 |
|
289 | |||
290 | flag = set_sy_lfr_kcoeff( TC, queue_id ); |
|
290 | flag = set_sy_lfr_kcoeff( TC, queue_id ); | |
291 |
|
291 | |||
292 | return flag; |
|
292 | return flag; | |
293 | } |
|
293 | } | |
294 |
|
294 | |||
295 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
295 | int action_load_fbins_mask(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
296 | { |
|
296 | { | |
297 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
297 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
298 | * |
|
298 | * | |
299 | * @param TC points to the TeleCommand packet that is being processed |
|
299 | * @param TC points to the TeleCommand packet that is being processed | |
300 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
300 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
301 | * |
|
301 | * | |
302 | */ |
|
302 | */ | |
303 |
|
303 | |||
304 | int flag; |
|
304 | int flag; | |
305 |
|
305 | |||
306 | flag = LFR_DEFAULT; |
|
306 | flag = LFR_DEFAULT; | |
307 |
|
307 | |||
308 | flag = set_sy_lfr_fbins( TC ); |
|
308 | flag = set_sy_lfr_fbins( TC ); | |
309 |
|
309 | |||
310 | return flag; |
|
310 | return flag; | |
311 | } |
|
311 | } | |
312 |
|
312 | |||
313 | void printKCoefficients(unsigned int freq, unsigned int bin, float *k_coeff) |
|
313 | void printKCoefficients(unsigned int freq, unsigned int bin, float *k_coeff) | |
314 | { |
|
314 | { | |
315 | printf("freq = %d *** bin = %d *** (0) %f *** (1) %f *** (2) %f *** (3) %f *** (4) %f\n", |
|
315 | printf("freq = %d *** bin = %d *** (0) %f *** (1) %f *** (2) %f *** (3) %f *** (4) %f\n", | |
316 | freq, |
|
316 | freq, | |
317 | bin, |
|
317 | bin, | |
318 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 0 ], |
|
318 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 0 ], | |
319 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 1 ], |
|
319 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 1 ], | |
320 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 2 ], |
|
320 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 2 ], | |
321 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 3 ], |
|
321 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 3 ], | |
322 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 4 ]); |
|
322 | k_coeff[ (bin*NB_K_COEFF_PER_BIN) + 4 ]); | |
323 | } |
|
323 | } | |
324 |
|
324 | |||
325 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) |
|
325 | int action_dump_kcoefficients(ccsdsTelecommandPacket_t *TC, rtems_id queue_id, unsigned char *time) | |
326 | { |
|
326 | { | |
327 | /** This function updates the LFR registers with the incoming sbm2 parameters. |
|
327 | /** This function updates the LFR registers with the incoming sbm2 parameters. | |
328 | * |
|
328 | * | |
329 | * @param TC points to the TeleCommand packet that is being processed |
|
329 | * @param TC points to the TeleCommand packet that is being processed | |
330 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
330 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
331 | * |
|
331 | * | |
332 | */ |
|
332 | */ | |
333 |
|
333 | |||
334 | unsigned int address; |
|
334 | unsigned int address; | |
335 | rtems_status_code status; |
|
335 | rtems_status_code status; | |
336 | unsigned int freq; |
|
336 | unsigned int freq; | |
337 | unsigned int bin; |
|
337 | unsigned int bin; | |
338 | unsigned int coeff; |
|
338 | unsigned int coeff; | |
339 | unsigned char *kCoeffPtr; |
|
339 | unsigned char *kCoeffPtr; | |
340 | unsigned char *kCoeffDumpPtr; |
|
340 | unsigned char *kCoeffDumpPtr; | |
341 |
|
341 | |||
342 | // for each sy_lfr_kcoeff_frequency there is 32 kcoeff |
|
342 | // for each sy_lfr_kcoeff_frequency there is 32 kcoeff | |
343 | // F0 => 11 bins |
|
343 | // F0 => 11 bins | |
344 | // F1 => 13 bins |
|
344 | // F1 => 13 bins | |
345 | // F2 => 12 bins |
|
345 | // F2 => 12 bins | |
346 | // 36 bins to dump in two packets (30 bins max per packet) |
|
346 | // 36 bins to dump in two packets (30 bins max per packet) | |
347 |
|
347 | |||
348 | //********* |
|
348 | //********* | |
349 | // PACKET 1 |
|
349 | // PACKET 1 | |
350 | // 11 F0 bins, 13 F1 bins and 6 F2 bins |
|
350 | // 11 F0 bins, 13 F1 bins and 6 F2 bins | |
351 | kcoefficients_dump_1.packetSequenceControl[0] = (unsigned char) (sequenceCounterParameterDump >> 8); |
|
351 | kcoefficients_dump_1.packetSequenceControl[0] = (unsigned char) (sequenceCounterParameterDump >> 8); | |
352 | kcoefficients_dump_1.packetSequenceControl[1] = (unsigned char) (sequenceCounterParameterDump ); |
|
352 | kcoefficients_dump_1.packetSequenceControl[1] = (unsigned char) (sequenceCounterParameterDump ); | |
353 | kcoefficients_dump_1.destinationID = TC->sourceID; |
|
353 | kcoefficients_dump_1.destinationID = TC->sourceID; | |
354 | increment_seq_counter( &sequenceCounterParameterDump ); |
|
354 | increment_seq_counter( &sequenceCounterParameterDump ); | |
355 | for( freq=0; |
|
355 | for( freq=0; | |
356 | freq<NB_BINS_COMPRESSED_SM_F0; |
|
356 | freq<NB_BINS_COMPRESSED_SM_F0; | |
357 | freq++ ) |
|
357 | freq++ ) | |
358 | { |
|
358 | { | |
359 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq; |
|
359 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1] = freq; | |
360 | bin = freq; |
|
360 | bin = freq; | |
361 | // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm); |
|
361 | // printKCoefficients( freq, bin, k_coeff_intercalib_f0_norm); | |
362 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
362 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
363 | { |
|
363 | { | |
364 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
364 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency | |
365 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
365 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f0_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
366 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
366 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
367 | } |
|
367 | } | |
368 | } |
|
368 | } | |
369 | for( freq=NB_BINS_COMPRESSED_SM_F0; |
|
369 | for( freq=NB_BINS_COMPRESSED_SM_F0; | |
370 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
370 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); | |
371 | freq++ ) |
|
371 | freq++ ) | |
372 | { |
|
372 | { | |
373 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; |
|
373 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; | |
374 | bin = freq - NB_BINS_COMPRESSED_SM_F0; |
|
374 | bin = freq - NB_BINS_COMPRESSED_SM_F0; | |
375 | // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm); |
|
375 | // printKCoefficients( freq, bin, k_coeff_intercalib_f1_norm); | |
376 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
376 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
377 | { |
|
377 | { | |
378 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
378 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency | |
379 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
379 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f1_norm[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
380 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
380 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
381 | } |
|
381 | } | |
382 | } |
|
382 | } | |
383 | for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
383 | for( freq=(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); | |
384 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6); |
|
384 | freq<(NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1+6); | |
385 | freq++ ) |
|
385 | freq++ ) | |
386 | { |
|
386 | { | |
387 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; |
|
387 | kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = freq; | |
388 | bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); |
|
388 | bin = freq - (NB_BINS_COMPRESSED_SM_F0+NB_BINS_COMPRESSED_SM_F1); | |
389 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); |
|
389 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); | |
390 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
390 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
391 | { |
|
391 | { | |
392 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
392 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_1.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency | |
393 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
393 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
394 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
394 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
395 | } |
|
395 | } | |
396 | } |
|
396 | } | |
397 | kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
397 | kcoefficients_dump_1.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
398 | kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
398 | kcoefficients_dump_1.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
399 | kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
399 | kcoefficients_dump_1.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
400 | kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
400 | kcoefficients_dump_1.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
401 | kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
401 | kcoefficients_dump_1.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
402 | kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
402 | kcoefficients_dump_1.time[5] = (unsigned char) (time_management_regs->fine_time); | |
403 | // SEND DATA |
|
403 | // SEND DATA | |
404 | kcoefficient_node_1.status = 1; |
|
404 | kcoefficient_node_1.status = 1; | |
405 | address = (unsigned int) &kcoefficient_node_1; |
|
405 | address = (unsigned int) &kcoefficient_node_1; | |
406 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); |
|
406 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); | |
407 | if (status != RTEMS_SUCCESSFUL) { |
|
407 | if (status != RTEMS_SUCCESSFUL) { | |
408 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status) |
|
408 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 1 , code %d", status) | |
409 | } |
|
409 | } | |
410 |
|
410 | |||
411 | //******** |
|
411 | //******** | |
412 | // PACKET 2 |
|
412 | // PACKET 2 | |
413 | // 6 F2 bins |
|
413 | // 6 F2 bins | |
414 | kcoefficients_dump_2.packetSequenceControl[0] = (unsigned char) (sequenceCounterParameterDump >> 8); |
|
414 | kcoefficients_dump_2.packetSequenceControl[0] = (unsigned char) (sequenceCounterParameterDump >> 8); | |
415 | kcoefficients_dump_2.packetSequenceControl[1] = (unsigned char) (sequenceCounterParameterDump ); |
|
415 | kcoefficients_dump_2.packetSequenceControl[1] = (unsigned char) (sequenceCounterParameterDump ); | |
416 | kcoefficients_dump_2.destinationID = TC->sourceID; |
|
416 | kcoefficients_dump_2.destinationID = TC->sourceID; | |
417 | increment_seq_counter( &sequenceCounterParameterDump ); |
|
417 | increment_seq_counter( &sequenceCounterParameterDump ); | |
418 | for( freq=0; freq<6; freq++ ) |
|
418 | for( freq=0; freq<6; freq++ ) | |
419 | { |
|
419 | { | |
420 | kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq; |
|
420 | kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + 1 ] = NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + 6 + freq; | |
421 | bin = freq + 6; |
|
421 | bin = freq + 6; | |
422 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); |
|
422 | // printKCoefficients( freq, bin, k_coeff_intercalib_f2); | |
423 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) |
|
423 | for ( coeff=0; coeff<NB_K_COEFF_PER_BIN; coeff++ ) | |
424 | { |
|
424 | { | |
425 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency |
|
425 | kCoeffDumpPtr = (unsigned char*) &kcoefficients_dump_2.kcoeff_blks[ freq*KCOEFF_BLK_SIZE + coeff*NB_BYTES_PER_FLOAT + 2 ]; // 2 for the kcoeff_frequency | |
426 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; |
|
426 | kCoeffPtr = (unsigned char*) &k_coeff_intercalib_f2[ (bin*NB_K_COEFF_PER_BIN) + coeff ]; | |
427 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); |
|
427 | copyFloatByChar( kCoeffDumpPtr, kCoeffPtr ); | |
428 | } |
|
428 | } | |
429 | } |
|
429 | } | |
430 | kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
430 | kcoefficients_dump_2.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
431 | kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
431 | kcoefficients_dump_2.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
432 | kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
432 | kcoefficients_dump_2.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
433 | kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
433 | kcoefficients_dump_2.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
434 | kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
434 | kcoefficients_dump_2.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
435 | kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
435 | kcoefficients_dump_2.time[5] = (unsigned char) (time_management_regs->fine_time); | |
436 | // SEND DATA |
|
436 | // SEND DATA | |
437 | kcoefficient_node_2.status = 1; |
|
437 | kcoefficient_node_2.status = 1; | |
438 | address = (unsigned int) &kcoefficient_node_2; |
|
438 | address = (unsigned int) &kcoefficient_node_2; | |
439 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); |
|
439 | status = rtems_message_queue_send( queue_id, &address, sizeof( ring_node* ) ); | |
440 | if (status != RTEMS_SUCCESSFUL) { |
|
440 | if (status != RTEMS_SUCCESSFUL) { | |
441 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status) |
|
441 | PRINTF1("in action_dump_kcoefficients *** ERR sending packet 2, code %d", status) | |
442 | } |
|
442 | } | |
443 |
|
443 | |||
444 | return status; |
|
444 | return status; | |
445 | } |
|
445 | } | |
446 |
|
446 | |||
447 | int action_dump_par( rtems_id queue_id ) |
|
447 | int action_dump_par( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
448 | { |
|
448 | { | |
449 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. |
|
449 | /** This function dumps the LFR parameters by sending the appropriate TM packet to the dedicated RTEMS message queue. | |
450 | * |
|
450 | * | |
451 | * @param queue_id is the id of the queue which handles TM related to this execution step. |
|
451 | * @param queue_id is the id of the queue which handles TM related to this execution step. | |
452 | * |
|
452 | * | |
453 | * @return RTEMS directive status codes: |
|
453 | * @return RTEMS directive status codes: | |
454 | * - RTEMS_SUCCESSFUL - message sent successfully |
|
454 | * - RTEMS_SUCCESSFUL - message sent successfully | |
455 | * - RTEMS_INVALID_ID - invalid queue id |
|
455 | * - RTEMS_INVALID_ID - invalid queue id | |
456 | * - RTEMS_INVALID_SIZE - invalid message size |
|
456 | * - RTEMS_INVALID_SIZE - invalid message size | |
457 | * - RTEMS_INVALID_ADDRESS - buffer is NULL |
|
457 | * - RTEMS_INVALID_ADDRESS - buffer is NULL | |
458 | * - RTEMS_UNSATISFIED - out of message buffers |
|
458 | * - RTEMS_UNSATISFIED - out of message buffers | |
459 | * - RTEMS_TOO_MANY - queue s limit has been reached |
|
459 | * - RTEMS_TOO_MANY - queue s limit has been reached | |
460 | * |
|
460 | * | |
461 | */ |
|
461 | */ | |
462 |
|
462 | |||
463 | int status; |
|
463 | int status; | |
464 |
|
464 | |||
465 | // UPDATE TIME |
|
465 | // UPDATE TIME | |
466 | parameter_dump_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterParameterDump >> 8); |
|
466 | parameter_dump_packet.packetSequenceControl[0] = (unsigned char) (sequenceCounterParameterDump >> 8); | |
467 | parameter_dump_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterParameterDump ); |
|
467 | parameter_dump_packet.packetSequenceControl[1] = (unsigned char) (sequenceCounterParameterDump ); | |
468 | increment_seq_counter( &sequenceCounterParameterDump ); |
|
468 | increment_seq_counter( &sequenceCounterParameterDump ); | |
|
469 | parameter_dump_packet.destinationID = TC->sourceID; | |||
469 |
|
470 | |||
470 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
471 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
471 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
472 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
472 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
473 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
473 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
474 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
474 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
475 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
475 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
476 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); | |
476 | // SEND DATA |
|
477 | // SEND DATA | |
477 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, |
|
478 | status = rtems_message_queue_send( queue_id, ¶meter_dump_packet, | |
478 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); |
|
479 | PACKET_LENGTH_PARAMETER_DUMP + CCSDS_TC_TM_PACKET_OFFSET + CCSDS_PROTOCOLE_EXTRA_BYTES); | |
479 | if (status != RTEMS_SUCCESSFUL) { |
|
480 | if (status != RTEMS_SUCCESSFUL) { | |
480 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) |
|
481 | PRINTF1("in action_dump *** ERR sending packet, code %d", status) | |
481 | } |
|
482 | } | |
482 |
|
483 | |||
483 | return status; |
|
484 | return status; | |
484 | } |
|
485 | } | |
485 |
|
486 | |||
486 | //*********************** |
|
487 | //*********************** | |
487 | // NORMAL MODE PARAMETERS |
|
488 | // NORMAL MODE PARAMETERS | |
488 |
|
489 | |||
489 | int check_common_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) |
|
490 | int check_common_par_consistency( ccsdsTelecommandPacket_t *TC, rtems_id queue_id ) | |
490 | { |
|
491 | { | |
491 | unsigned char msb; |
|
492 | unsigned char msb; | |
492 | unsigned char lsb; |
|
493 | unsigned char lsb; | |
493 | int flag; |
|
494 | int flag; | |
494 | float aux; |
|
495 | float aux; | |
495 | rtems_status_code status; |
|
496 | rtems_status_code status; | |
496 |
|
497 | |||
497 | unsigned int sy_lfr_n_swf_l; |
|
498 | unsigned int sy_lfr_n_swf_l; | |
498 | unsigned int sy_lfr_n_swf_p; |
|
499 | unsigned int sy_lfr_n_swf_p; | |
499 | unsigned int sy_lfr_n_asm_p; |
|
500 | unsigned int sy_lfr_n_asm_p; | |
500 | unsigned char sy_lfr_n_bp_p0; |
|
501 | unsigned char sy_lfr_n_bp_p0; | |
501 | unsigned char sy_lfr_n_bp_p1; |
|
502 | unsigned char sy_lfr_n_bp_p1; | |
502 | unsigned char sy_lfr_n_cwf_long_f3; |
|
503 | unsigned char sy_lfr_n_cwf_long_f3; | |
503 |
|
504 | |||
504 | flag = LFR_SUCCESSFUL; |
|
505 | flag = LFR_SUCCESSFUL; | |
505 |
|
506 | |||
506 | //*************** |
|
507 | //*************** | |
507 | // get parameters |
|
508 | // get parameters | |
508 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
509 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; | |
509 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
510 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; | |
510 | sy_lfr_n_swf_l = msb * 256 + lsb; |
|
511 | sy_lfr_n_swf_l = msb * 256 + lsb; | |
511 |
|
512 | |||
512 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
513 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; | |
513 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
514 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; | |
514 | sy_lfr_n_swf_p = msb * 256 + lsb; |
|
515 | sy_lfr_n_swf_p = msb * 256 + lsb; | |
515 |
|
516 | |||
516 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
517 | msb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; | |
517 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
518 | lsb = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; | |
518 | sy_lfr_n_asm_p = msb * 256 + lsb; |
|
519 | sy_lfr_n_asm_p = msb * 256 + lsb; | |
519 |
|
520 | |||
520 | sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
521 | sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; | |
521 |
|
522 | |||
522 | sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
523 | sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; | |
523 |
|
524 | |||
524 | sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
525 | sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; | |
525 |
|
526 | |||
526 | //****************** |
|
527 | //****************** | |
527 | // check consistency |
|
528 | // check consistency | |
528 | // sy_lfr_n_swf_l |
|
529 | // sy_lfr_n_swf_l | |
529 | if (sy_lfr_n_swf_l != 2048) |
|
530 | if (sy_lfr_n_swf_l != 2048) | |
530 | { |
|
531 | { | |
531 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l ); |
|
532 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_L+10, sy_lfr_n_swf_l ); | |
532 | flag = WRONG_APP_DATA; |
|
533 | flag = WRONG_APP_DATA; | |
533 | } |
|
534 | } | |
534 | // sy_lfr_n_swf_p |
|
535 | // sy_lfr_n_swf_p | |
535 | if (flag == LFR_SUCCESSFUL) |
|
536 | if (flag == LFR_SUCCESSFUL) | |
536 | { |
|
537 | { | |
537 | if ( sy_lfr_n_swf_p < 16 ) |
|
538 | if ( sy_lfr_n_swf_p < 16 ) | |
538 | { |
|
539 | { | |
539 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p ); |
|
540 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_SWF_P+10, sy_lfr_n_swf_p ); | |
540 | flag = WRONG_APP_DATA; |
|
541 | flag = WRONG_APP_DATA; | |
541 | } |
|
542 | } | |
542 | } |
|
543 | } | |
543 | // sy_lfr_n_bp_p0 |
|
544 | // sy_lfr_n_bp_p0 | |
544 | if (flag == LFR_SUCCESSFUL) |
|
545 | if (flag == LFR_SUCCESSFUL) | |
545 | { |
|
546 | { | |
546 | if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0) |
|
547 | if (sy_lfr_n_bp_p0 < DFLT_SY_LFR_N_BP_P0) | |
547 | { |
|
548 | { | |
548 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 ); |
|
549 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P0+10, sy_lfr_n_bp_p0 ); | |
549 | flag = WRONG_APP_DATA; |
|
550 | flag = WRONG_APP_DATA; | |
550 | } |
|
551 | } | |
551 | } |
|
552 | } | |
552 | // sy_lfr_n_asm_p |
|
553 | // sy_lfr_n_asm_p | |
553 | if (flag == LFR_SUCCESSFUL) |
|
554 | if (flag == LFR_SUCCESSFUL) | |
554 | { |
|
555 | { | |
555 | if (sy_lfr_n_asm_p == 0) |
|
556 | if (sy_lfr_n_asm_p == 0) | |
556 | { |
|
557 | { | |
557 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); |
|
558 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); | |
558 | flag = WRONG_APP_DATA; |
|
559 | flag = WRONG_APP_DATA; | |
559 | } |
|
560 | } | |
560 | } |
|
561 | } | |
561 | // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0 |
|
562 | // sy_lfr_n_asm_p shall be a whole multiple of sy_lfr_n_bp_p0 | |
562 | if (flag == LFR_SUCCESSFUL) |
|
563 | if (flag == LFR_SUCCESSFUL) | |
563 | { |
|
564 | { | |
564 | aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0); |
|
565 | aux = ( (float ) sy_lfr_n_asm_p / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_asm_p / sy_lfr_n_bp_p0); | |
565 | if (aux > FLOAT_EQUAL_ZERO) |
|
566 | if (aux > FLOAT_EQUAL_ZERO) | |
566 | { |
|
567 | { | |
567 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); |
|
568 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_ASM_P+10, sy_lfr_n_asm_p ); | |
568 | flag = WRONG_APP_DATA; |
|
569 | flag = WRONG_APP_DATA; | |
569 | } |
|
570 | } | |
570 | } |
|
571 | } | |
571 | // sy_lfr_n_bp_p1 |
|
572 | // sy_lfr_n_bp_p1 | |
572 | if (flag == LFR_SUCCESSFUL) |
|
573 | if (flag == LFR_SUCCESSFUL) | |
573 | { |
|
574 | { | |
574 | if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1) |
|
575 | if (sy_lfr_n_bp_p1 < DFLT_SY_LFR_N_BP_P1) | |
575 | { |
|
576 | { | |
576 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); |
|
577 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); | |
577 | flag = WRONG_APP_DATA; |
|
578 | flag = WRONG_APP_DATA; | |
578 | } |
|
579 | } | |
579 | } |
|
580 | } | |
580 | // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0 |
|
581 | // sy_lfr_n_bp_p1 shall be a whole multiple of sy_lfr_n_bp_p0 | |
581 | if (flag == LFR_SUCCESSFUL) |
|
582 | if (flag == LFR_SUCCESSFUL) | |
582 | { |
|
583 | { | |
583 | aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0); |
|
584 | aux = ( (float ) sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0 ) - floor(sy_lfr_n_bp_p1 / sy_lfr_n_bp_p0); | |
584 | if (aux > FLOAT_EQUAL_ZERO) |
|
585 | if (aux > FLOAT_EQUAL_ZERO) | |
585 | { |
|
586 | { | |
586 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); |
|
587 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_N_BP_P1+10, sy_lfr_n_bp_p1 ); | |
587 | flag = LFR_DEFAULT; |
|
588 | flag = LFR_DEFAULT; | |
588 | } |
|
589 | } | |
589 | } |
|
590 | } | |
590 | // sy_lfr_n_cwf_long_f3 |
|
591 | // sy_lfr_n_cwf_long_f3 | |
591 |
|
592 | |||
592 | return flag; |
|
593 | return flag; | |
593 | } |
|
594 | } | |
594 |
|
595 | |||
595 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ) |
|
596 | int set_sy_lfr_n_swf_l( ccsdsTelecommandPacket_t *TC ) | |
596 | { |
|
597 | { | |
597 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). |
|
598 | /** This function sets the number of points of a snapshot (sy_lfr_n_swf_l). | |
598 | * |
|
599 | * | |
599 | * @param TC points to the TeleCommand packet that is being processed |
|
600 | * @param TC points to the TeleCommand packet that is being processed | |
600 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
601 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
601 | * |
|
602 | * | |
602 | */ |
|
603 | */ | |
603 |
|
604 | |||
604 | int result; |
|
605 | int result; | |
605 |
|
606 | |||
606 | result = LFR_SUCCESSFUL; |
|
607 | result = LFR_SUCCESSFUL; | |
607 |
|
608 | |||
608 | parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; |
|
609 | parameter_dump_packet.sy_lfr_n_swf_l[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L ]; | |
609 | parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; |
|
610 | parameter_dump_packet.sy_lfr_n_swf_l[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_L+1 ]; | |
610 |
|
611 | |||
611 | return result; |
|
612 | return result; | |
612 | } |
|
613 | } | |
613 |
|
614 | |||
614 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC ) |
|
615 | int set_sy_lfr_n_swf_p(ccsdsTelecommandPacket_t *TC ) | |
615 | { |
|
616 | { | |
616 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). |
|
617 | /** This function sets the time between two snapshots, in s (sy_lfr_n_swf_p). | |
617 | * |
|
618 | * | |
618 | * @param TC points to the TeleCommand packet that is being processed |
|
619 | * @param TC points to the TeleCommand packet that is being processed | |
619 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
620 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
620 | * |
|
621 | * | |
621 | */ |
|
622 | */ | |
622 |
|
623 | |||
623 | int result; |
|
624 | int result; | |
624 |
|
625 | |||
625 | result = LFR_SUCCESSFUL; |
|
626 | result = LFR_SUCCESSFUL; | |
626 |
|
627 | |||
627 | parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; |
|
628 | parameter_dump_packet.sy_lfr_n_swf_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P ]; | |
628 | parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; |
|
629 | parameter_dump_packet.sy_lfr_n_swf_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_SWF_P+1 ]; | |
629 |
|
630 | |||
630 | return result; |
|
631 | return result; | |
631 | } |
|
632 | } | |
632 |
|
633 | |||
633 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ) |
|
634 | int set_sy_lfr_n_asm_p( ccsdsTelecommandPacket_t *TC ) | |
634 | { |
|
635 | { | |
635 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). |
|
636 | /** This function sets the time between two full spectral matrices transmission, in s (SY_LFR_N_ASM_P). | |
636 | * |
|
637 | * | |
637 | * @param TC points to the TeleCommand packet that is being processed |
|
638 | * @param TC points to the TeleCommand packet that is being processed | |
638 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
639 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
639 | * |
|
640 | * | |
640 | */ |
|
641 | */ | |
641 |
|
642 | |||
642 | int result; |
|
643 | int result; | |
643 |
|
644 | |||
644 | result = LFR_SUCCESSFUL; |
|
645 | result = LFR_SUCCESSFUL; | |
645 |
|
646 | |||
646 | parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; |
|
647 | parameter_dump_packet.sy_lfr_n_asm_p[0] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P ]; | |
647 | parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; |
|
648 | parameter_dump_packet.sy_lfr_n_asm_p[1] = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_ASM_P+1 ]; | |
648 |
|
649 | |||
649 | return result; |
|
650 | return result; | |
650 | } |
|
651 | } | |
651 |
|
652 | |||
652 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
653 | int set_sy_lfr_n_bp_p0( ccsdsTelecommandPacket_t *TC ) | |
653 | { |
|
654 | { | |
654 | /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0). |
|
655 | /** This function sets the time between two basic parameter sets, in s (DFLT_SY_LFR_N_BP_P0). | |
655 | * |
|
656 | * | |
656 | * @param TC points to the TeleCommand packet that is being processed |
|
657 | * @param TC points to the TeleCommand packet that is being processed | |
657 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
658 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
658 | * |
|
659 | * | |
659 | */ |
|
660 | */ | |
660 |
|
661 | |||
661 | int status; |
|
662 | int status; | |
662 |
|
663 | |||
663 | status = LFR_SUCCESSFUL; |
|
664 | status = LFR_SUCCESSFUL; | |
664 |
|
665 | |||
665 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; |
|
666 | parameter_dump_packet.sy_lfr_n_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P0 ]; | |
666 |
|
667 | |||
667 | return status; |
|
668 | return status; | |
668 | } |
|
669 | } | |
669 |
|
670 | |||
670 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC ) |
|
671 | int set_sy_lfr_n_bp_p1(ccsdsTelecommandPacket_t *TC ) | |
671 | { |
|
672 | { | |
672 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). |
|
673 | /** This function sets the time between two basic parameter sets (autocorrelation + crosscorrelation), in s (sy_lfr_n_bp_p1). | |
673 | * |
|
674 | * | |
674 | * @param TC points to the TeleCommand packet that is being processed |
|
675 | * @param TC points to the TeleCommand packet that is being processed | |
675 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
676 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
676 | * |
|
677 | * | |
677 | */ |
|
678 | */ | |
678 |
|
679 | |||
679 | int status; |
|
680 | int status; | |
680 |
|
681 | |||
681 | status = LFR_SUCCESSFUL; |
|
682 | status = LFR_SUCCESSFUL; | |
682 |
|
683 | |||
683 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; |
|
684 | parameter_dump_packet.sy_lfr_n_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_BP_P1 ]; | |
684 |
|
685 | |||
685 | return status; |
|
686 | return status; | |
686 | } |
|
687 | } | |
687 |
|
688 | |||
688 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC ) |
|
689 | int set_sy_lfr_n_cwf_long_f3(ccsdsTelecommandPacket_t *TC ) | |
689 | { |
|
690 | { | |
690 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. |
|
691 | /** This function allows to switch from CWF_F3 packets to CWF_LONG_F3 packets. | |
691 | * |
|
692 | * | |
692 | * @param TC points to the TeleCommand packet that is being processed |
|
693 | * @param TC points to the TeleCommand packet that is being processed | |
693 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
694 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
694 | * |
|
695 | * | |
695 | */ |
|
696 | */ | |
696 |
|
697 | |||
697 | int status; |
|
698 | int status; | |
698 |
|
699 | |||
699 | status = LFR_SUCCESSFUL; |
|
700 | status = LFR_SUCCESSFUL; | |
700 |
|
701 | |||
701 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; |
|
702 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_N_CWF_LONG_F3 ]; | |
702 |
|
703 | |||
703 | return status; |
|
704 | return status; | |
704 | } |
|
705 | } | |
705 |
|
706 | |||
706 | //********************** |
|
707 | //********************** | |
707 | // BURST MODE PARAMETERS |
|
708 | // BURST MODE PARAMETERS | |
708 | int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC) |
|
709 | int set_sy_lfr_b_bp_p0(ccsdsTelecommandPacket_t *TC) | |
709 | { |
|
710 | { | |
710 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0). |
|
711 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P0). | |
711 | * |
|
712 | * | |
712 | * @param TC points to the TeleCommand packet that is being processed |
|
713 | * @param TC points to the TeleCommand packet that is being processed | |
713 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
714 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
714 | * |
|
715 | * | |
715 | */ |
|
716 | */ | |
716 |
|
717 | |||
717 | int status; |
|
718 | int status; | |
718 |
|
719 | |||
719 | status = LFR_SUCCESSFUL; |
|
720 | status = LFR_SUCCESSFUL; | |
720 |
|
721 | |||
721 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; |
|
722 | parameter_dump_packet.sy_lfr_b_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P0 ]; | |
722 |
|
723 | |||
723 | return status; |
|
724 | return status; | |
724 | } |
|
725 | } | |
725 |
|
726 | |||
726 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
727 | int set_sy_lfr_b_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
727 | { |
|
728 | { | |
728 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1). |
|
729 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_B_BP_P1). | |
729 | * |
|
730 | * | |
730 | * @param TC points to the TeleCommand packet that is being processed |
|
731 | * @param TC points to the TeleCommand packet that is being processed | |
731 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
732 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
732 | * |
|
733 | * | |
733 | */ |
|
734 | */ | |
734 |
|
735 | |||
735 | int status; |
|
736 | int status; | |
736 |
|
737 | |||
737 | status = LFR_SUCCESSFUL; |
|
738 | status = LFR_SUCCESSFUL; | |
738 |
|
739 | |||
739 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; |
|
740 | parameter_dump_packet.sy_lfr_b_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_B_BP_P1 ]; | |
740 |
|
741 | |||
741 | return status; |
|
742 | return status; | |
742 | } |
|
743 | } | |
743 |
|
744 | |||
744 | //********************* |
|
745 | //********************* | |
745 | // SBM1 MODE PARAMETERS |
|
746 | // SBM1 MODE PARAMETERS | |
746 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ) |
|
747 | int set_sy_lfr_s1_bp_p0( ccsdsTelecommandPacket_t *TC ) | |
747 | { |
|
748 | { | |
748 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0). |
|
749 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P0). | |
749 | * |
|
750 | * | |
750 | * @param TC points to the TeleCommand packet that is being processed |
|
751 | * @param TC points to the TeleCommand packet that is being processed | |
751 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
752 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
752 | * |
|
753 | * | |
753 | */ |
|
754 | */ | |
754 |
|
755 | |||
755 | int status; |
|
756 | int status; | |
756 |
|
757 | |||
757 | status = LFR_SUCCESSFUL; |
|
758 | status = LFR_SUCCESSFUL; | |
758 |
|
759 | |||
759 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; |
|
760 | parameter_dump_packet.sy_lfr_s1_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P0 ]; | |
760 |
|
761 | |||
761 | return status; |
|
762 | return status; | |
762 | } |
|
763 | } | |
763 |
|
764 | |||
764 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
765 | int set_sy_lfr_s1_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
765 | { |
|
766 | { | |
766 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1). |
|
767 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S1_BP_P1). | |
767 | * |
|
768 | * | |
768 | * @param TC points to the TeleCommand packet that is being processed |
|
769 | * @param TC points to the TeleCommand packet that is being processed | |
769 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
770 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
770 | * |
|
771 | * | |
771 | */ |
|
772 | */ | |
772 |
|
773 | |||
773 | int status; |
|
774 | int status; | |
774 |
|
775 | |||
775 | status = LFR_SUCCESSFUL; |
|
776 | status = LFR_SUCCESSFUL; | |
776 |
|
777 | |||
777 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; |
|
778 | parameter_dump_packet.sy_lfr_s1_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S1_BP_P1 ]; | |
778 |
|
779 | |||
779 | return status; |
|
780 | return status; | |
780 | } |
|
781 | } | |
781 |
|
782 | |||
782 | //********************* |
|
783 | //********************* | |
783 | // SBM2 MODE PARAMETERS |
|
784 | // SBM2 MODE PARAMETERS | |
784 | int set_sy_lfr_s2_bp_p0(ccsdsTelecommandPacket_t *TC) |
|
785 | int set_sy_lfr_s2_bp_p0(ccsdsTelecommandPacket_t *TC) | |
785 | { |
|
786 | { | |
786 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0). |
|
787 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P0). | |
787 | * |
|
788 | * | |
788 | * @param TC points to the TeleCommand packet that is being processed |
|
789 | * @param TC points to the TeleCommand packet that is being processed | |
789 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
790 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
790 | * |
|
791 | * | |
791 | */ |
|
792 | */ | |
792 |
|
793 | |||
793 | int status; |
|
794 | int status; | |
794 |
|
795 | |||
795 | status = LFR_SUCCESSFUL; |
|
796 | status = LFR_SUCCESSFUL; | |
796 |
|
797 | |||
797 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; |
|
798 | parameter_dump_packet.sy_lfr_s2_bp_p0 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P0 ]; | |
798 |
|
799 | |||
799 | return status; |
|
800 | return status; | |
800 | } |
|
801 | } | |
801 |
|
802 | |||
802 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ) |
|
803 | int set_sy_lfr_s2_bp_p1( ccsdsTelecommandPacket_t *TC ) | |
803 | { |
|
804 | { | |
804 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1). |
|
805 | /** This function sets the time between two basic parameter sets, in s (SY_LFR_S2_BP_P1). | |
805 | * |
|
806 | * | |
806 | * @param TC points to the TeleCommand packet that is being processed |
|
807 | * @param TC points to the TeleCommand packet that is being processed | |
807 | * @param queue_id is the id of the queue which handles TM related to this execution step |
|
808 | * @param queue_id is the id of the queue which handles TM related to this execution step | |
808 | * |
|
809 | * | |
809 | */ |
|
810 | */ | |
810 |
|
811 | |||
811 | int status; |
|
812 | int status; | |
812 |
|
813 | |||
813 | status = LFR_SUCCESSFUL; |
|
814 | status = LFR_SUCCESSFUL; | |
814 |
|
815 | |||
815 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; |
|
816 | parameter_dump_packet.sy_lfr_s2_bp_p1 = TC->dataAndCRC[ DATAFIELD_POS_SY_LFR_S2_BP_P1 ]; | |
816 |
|
817 | |||
817 | return status; |
|
818 | return status; | |
818 | } |
|
819 | } | |
819 |
|
820 | |||
820 | //******************* |
|
821 | //******************* | |
821 | // TC_LFR_UPDATE_INFO |
|
822 | // TC_LFR_UPDATE_INFO | |
822 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) |
|
823 | unsigned int check_update_info_hk_lfr_mode( unsigned char mode ) | |
823 | { |
|
824 | { | |
824 | unsigned int status; |
|
825 | unsigned int status; | |
825 |
|
826 | |||
826 | if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) |
|
827 | if ( (mode == LFR_MODE_STANDBY) || (mode == LFR_MODE_NORMAL) | |
827 | || (mode == LFR_MODE_BURST) |
|
828 | || (mode == LFR_MODE_BURST) | |
828 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) |
|
829 | || (mode == LFR_MODE_SBM1) || (mode == LFR_MODE_SBM2)) | |
829 | { |
|
830 | { | |
830 | status = LFR_SUCCESSFUL; |
|
831 | status = LFR_SUCCESSFUL; | |
831 | } |
|
832 | } | |
832 | else |
|
833 | else | |
833 | { |
|
834 | { | |
834 | status = LFR_DEFAULT; |
|
835 | status = LFR_DEFAULT; | |
835 | } |
|
836 | } | |
836 |
|
837 | |||
837 | return status; |
|
838 | return status; | |
838 | } |
|
839 | } | |
839 |
|
840 | |||
840 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ) |
|
841 | unsigned int check_update_info_hk_tds_mode( unsigned char mode ) | |
841 | { |
|
842 | { | |
842 | unsigned int status; |
|
843 | unsigned int status; | |
843 |
|
844 | |||
844 | if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) |
|
845 | if ( (mode == TDS_MODE_STANDBY) || (mode == TDS_MODE_NORMAL) | |
845 | || (mode == TDS_MODE_BURST) |
|
846 | || (mode == TDS_MODE_BURST) | |
846 | || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) |
|
847 | || (mode == TDS_MODE_SBM1) || (mode == TDS_MODE_SBM2) | |
847 | || (mode == TDS_MODE_LFM)) |
|
848 | || (mode == TDS_MODE_LFM)) | |
848 | { |
|
849 | { | |
849 | status = LFR_SUCCESSFUL; |
|
850 | status = LFR_SUCCESSFUL; | |
850 | } |
|
851 | } | |
851 | else |
|
852 | else | |
852 | { |
|
853 | { | |
853 | status = LFR_DEFAULT; |
|
854 | status = LFR_DEFAULT; | |
854 | } |
|
855 | } | |
855 |
|
856 | |||
856 | return status; |
|
857 | return status; | |
857 | } |
|
858 | } | |
858 |
|
859 | |||
859 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ) |
|
860 | unsigned int check_update_info_hk_thr_mode( unsigned char mode ) | |
860 | { |
|
861 | { | |
861 | unsigned int status; |
|
862 | unsigned int status; | |
862 |
|
863 | |||
863 | if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) |
|
864 | if ( (mode == THR_MODE_STANDBY) || (mode == THR_MODE_NORMAL) | |
864 | || (mode == THR_MODE_BURST)) |
|
865 | || (mode == THR_MODE_BURST)) | |
865 | { |
|
866 | { | |
866 | status = LFR_SUCCESSFUL; |
|
867 | status = LFR_SUCCESSFUL; | |
867 | } |
|
868 | } | |
868 | else |
|
869 | else | |
869 | { |
|
870 | { | |
870 | status = LFR_DEFAULT; |
|
871 | status = LFR_DEFAULT; | |
871 | } |
|
872 | } | |
872 |
|
873 | |||
873 | return status; |
|
874 | return status; | |
874 | } |
|
875 | } | |
875 |
|
876 | |||
876 | //*********** |
|
877 | //*********** | |
877 | // FBINS MASK |
|
878 | // FBINS MASK | |
878 |
|
879 | |||
879 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ) |
|
880 | int set_sy_lfr_fbins( ccsdsTelecommandPacket_t *TC ) | |
880 | { |
|
881 | { | |
881 | int status; |
|
882 | int status; | |
882 | unsigned int k; |
|
883 | unsigned int k; | |
883 | unsigned char *fbins_mask_dump; |
|
884 | unsigned char *fbins_mask_dump; | |
884 | unsigned char *fbins_mask_TC; |
|
885 | unsigned char *fbins_mask_TC; | |
885 |
|
886 | |||
886 | status = LFR_SUCCESSFUL; |
|
887 | status = LFR_SUCCESSFUL; | |
887 |
|
888 | |||
888 | fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1; |
|
889 | fbins_mask_dump = parameter_dump_packet.sy_lfr_fbins_f0_word1; | |
889 | fbins_mask_TC = TC->dataAndCRC; |
|
890 | fbins_mask_TC = TC->dataAndCRC; | |
890 |
|
891 | |||
891 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) |
|
892 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) | |
892 | { |
|
893 | { | |
893 | fbins_mask_dump[k] = fbins_mask_TC[k]; |
|
894 | fbins_mask_dump[k] = fbins_mask_TC[k]; | |
894 | } |
|
895 | } | |
895 | for (k=0; k < NB_FBINS_MASKS; k++) |
|
896 | for (k=0; k < NB_FBINS_MASKS; k++) | |
896 | { |
|
897 | { | |
897 | unsigned char *auxPtr; |
|
898 | unsigned char *auxPtr; | |
898 | auxPtr = ¶meter_dump_packet.sy_lfr_fbins_f0_word1[k*NB_BYTES_PER_FBINS_MASK]; |
|
899 | auxPtr = ¶meter_dump_packet.sy_lfr_fbins_f0_word1[k*NB_BYTES_PER_FBINS_MASK]; | |
899 | printf("%x %x %x %x\n", auxPtr[0], auxPtr[1], auxPtr[2], auxPtr[3]); |
|
900 | printf("%x %x %x %x\n", auxPtr[0], auxPtr[1], auxPtr[2], auxPtr[3]); | |
900 | } |
|
901 | } | |
901 |
|
902 | |||
902 |
|
903 | |||
903 | return status; |
|
904 | return status; | |
904 | } |
|
905 | } | |
905 |
|
906 | |||
906 | //************** |
|
907 | //************** | |
907 | // KCOEFFICIENTS |
|
908 | // KCOEFFICIENTS | |
908 | int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id ) |
|
909 | int set_sy_lfr_kcoeff( ccsdsTelecommandPacket_t *TC,rtems_id queue_id ) | |
909 | { |
|
910 | { | |
910 | unsigned int kcoeff; |
|
911 | unsigned int kcoeff; | |
911 | unsigned short sy_lfr_kcoeff_frequency; |
|
912 | unsigned short sy_lfr_kcoeff_frequency; | |
912 | unsigned short bin; |
|
913 | unsigned short bin; | |
913 | unsigned short *freqPtr; |
|
914 | unsigned short *freqPtr; | |
914 | float *kcoeffPtr_norm; |
|
915 | float *kcoeffPtr_norm; | |
915 | float *kcoeffPtr_sbm; |
|
916 | float *kcoeffPtr_sbm; | |
916 | int status; |
|
917 | int status; | |
917 | unsigned char *kcoeffLoadPtr; |
|
918 | unsigned char *kcoeffLoadPtr; | |
918 | unsigned char *kcoeffNormPtr; |
|
919 | unsigned char *kcoeffNormPtr; | |
919 | unsigned char *kcoeffSbmPtr_a; |
|
920 | unsigned char *kcoeffSbmPtr_a; | |
920 | unsigned char *kcoeffSbmPtr_b; |
|
921 | unsigned char *kcoeffSbmPtr_b; | |
921 |
|
922 | |||
922 | status = LFR_SUCCESSFUL; |
|
923 | status = LFR_SUCCESSFUL; | |
923 |
|
924 | |||
924 | kcoeffPtr_norm = NULL; |
|
925 | kcoeffPtr_norm = NULL; | |
925 | kcoeffPtr_sbm = NULL; |
|
926 | kcoeffPtr_sbm = NULL; | |
926 | bin = 0; |
|
927 | bin = 0; | |
927 |
|
928 | |||
928 | freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY]; |
|
929 | freqPtr = (unsigned short *) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY]; | |
929 | sy_lfr_kcoeff_frequency = *freqPtr; |
|
930 | sy_lfr_kcoeff_frequency = *freqPtr; | |
930 |
|
931 | |||
931 | if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM ) |
|
932 | if ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM ) | |
932 | { |
|
933 | { | |
933 | PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency) |
|
934 | PRINTF1("ERR *** in set_sy_lfr_kcoeff_frequency *** sy_lfr_kcoeff_frequency = %d\n", sy_lfr_kcoeff_frequency) | |
934 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1, |
|
935 | status = send_tm_lfr_tc_exe_inconsistent( TC, queue_id, DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 10 + 1, | |
935 | TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB |
|
936 | TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_FREQUENCY + 1] ); // +1 to get the LSB instead of the MSB | |
936 | status = LFR_DEFAULT; |
|
937 | status = LFR_DEFAULT; | |
937 | } |
|
938 | } | |
938 | else |
|
939 | else | |
939 | { |
|
940 | { | |
940 | if ( ( sy_lfr_kcoeff_frequency >= 0 ) |
|
941 | if ( ( sy_lfr_kcoeff_frequency >= 0 ) | |
941 | && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) ) |
|
942 | && ( sy_lfr_kcoeff_frequency < NB_BINS_COMPRESSED_SM_F0 ) ) | |
942 | { |
|
943 | { | |
943 | kcoeffPtr_norm = k_coeff_intercalib_f0_norm; |
|
944 | kcoeffPtr_norm = k_coeff_intercalib_f0_norm; | |
944 | kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm; |
|
945 | kcoeffPtr_sbm = k_coeff_intercalib_f0_sbm; | |
945 | bin = sy_lfr_kcoeff_frequency; |
|
946 | bin = sy_lfr_kcoeff_frequency; | |
946 | } |
|
947 | } | |
947 | else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 ) |
|
948 | else if ( ( sy_lfr_kcoeff_frequency >= NB_BINS_COMPRESSED_SM_F0 ) | |
948 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) ) |
|
949 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) ) | |
949 | { |
|
950 | { | |
950 | kcoeffPtr_norm = k_coeff_intercalib_f1_norm; |
|
951 | kcoeffPtr_norm = k_coeff_intercalib_f1_norm; | |
951 | kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm; |
|
952 | kcoeffPtr_sbm = k_coeff_intercalib_f1_sbm; | |
952 | bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0; |
|
953 | bin = sy_lfr_kcoeff_frequency - NB_BINS_COMPRESSED_SM_F0; | |
953 | } |
|
954 | } | |
954 | else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) |
|
955 | else if ( ( sy_lfr_kcoeff_frequency >= (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1) ) | |
955 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) ) |
|
956 | && ( sy_lfr_kcoeff_frequency < (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1 + NB_BINS_COMPRESSED_SM_F2) ) ) | |
956 | { |
|
957 | { | |
957 | kcoeffPtr_norm = k_coeff_intercalib_f2; |
|
958 | kcoeffPtr_norm = k_coeff_intercalib_f2; | |
958 | kcoeffPtr_sbm = NULL; |
|
959 | kcoeffPtr_sbm = NULL; | |
959 | bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); |
|
960 | bin = sy_lfr_kcoeff_frequency - (NB_BINS_COMPRESSED_SM_F0 + NB_BINS_COMPRESSED_SM_F1); | |
960 | } |
|
961 | } | |
961 | } |
|
962 | } | |
962 |
|
963 | |||
963 | printf("in set_sy_lfr_kcoeff *** freq = %d, bin = %d\n", sy_lfr_kcoeff_frequency, bin); |
|
964 | printf("in set_sy_lfr_kcoeff *** freq = %d, bin = %d\n", sy_lfr_kcoeff_frequency, bin); | |
964 |
|
965 | |||
965 | if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products |
|
966 | if (kcoeffPtr_norm != NULL ) // update K coefficient for NORMAL data products | |
966 | { |
|
967 | { | |
967 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
968 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) | |
968 | { |
|
969 | { | |
969 | // destination |
|
970 | // destination | |
970 | kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ]; |
|
971 | kcoeffNormPtr = (unsigned char*) &kcoeffPtr_norm[ (bin * NB_K_COEFF_PER_BIN) + kcoeff ]; | |
971 | // source |
|
972 | // source | |
972 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; |
|
973 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; | |
973 | // copy source to destination |
|
974 | // copy source to destination | |
974 | copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr ); |
|
975 | copyFloatByChar( kcoeffNormPtr, kcoeffLoadPtr ); | |
975 | } |
|
976 | } | |
976 | } |
|
977 | } | |
977 |
|
978 | |||
978 | if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products |
|
979 | if (kcoeffPtr_sbm != NULL ) // update K coefficient for SBM data products | |
979 | { |
|
980 | { | |
980 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
981 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) | |
981 | { |
|
982 | { | |
982 | // destination |
|
983 | // destination | |
983 | kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ]; |
|
984 | kcoeffSbmPtr_a= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 ]; | |
984 | kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ]; |
|
985 | kcoeffSbmPtr_b= (unsigned char*) &kcoeffPtr_sbm[ ( (bin * NB_K_COEFF_PER_BIN) + kcoeff) * 2 + 1 ]; | |
985 | // source |
|
986 | // source | |
986 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; |
|
987 | kcoeffLoadPtr = (unsigned char*) &TC->dataAndCRC[DATAFIELD_POS_SY_LFR_KCOEFF_1 + NB_BYTES_PER_FLOAT * kcoeff]; | |
987 | // copy source to destination |
|
988 | // copy source to destination | |
988 | copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr ); |
|
989 | copyFloatByChar( kcoeffSbmPtr_a, kcoeffLoadPtr ); | |
989 | copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr ); |
|
990 | copyFloatByChar( kcoeffSbmPtr_b, kcoeffLoadPtr ); | |
990 | } |
|
991 | } | |
991 | } |
|
992 | } | |
992 |
|
993 | |||
993 | // print_k_coeff(); |
|
994 | // print_k_coeff(); | |
994 |
|
995 | |||
995 | return status; |
|
996 | return status; | |
996 | } |
|
997 | } | |
997 |
|
998 | |||
998 | void copyFloatByChar( unsigned char *destination, unsigned char *source ) |
|
999 | void copyFloatByChar( unsigned char *destination, unsigned char *source ) | |
999 | { |
|
1000 | { | |
1000 | destination[0] = source[0]; |
|
1001 | destination[0] = source[0]; | |
1001 | destination[1] = source[1]; |
|
1002 | destination[1] = source[1]; | |
1002 | destination[2] = source[2]; |
|
1003 | destination[2] = source[2]; | |
1003 | destination[3] = source[3]; |
|
1004 | destination[3] = source[3]; | |
1004 | } |
|
1005 | } | |
1005 |
|
1006 | |||
1006 | //********** |
|
1007 | //********** | |
1007 | // init dump |
|
1008 | // init dump | |
1008 |
|
1009 | |||
1009 | void init_parameter_dump( void ) |
|
1010 | void init_parameter_dump( void ) | |
1010 | { |
|
1011 | { | |
1011 | /** This function initialize the parameter_dump_packet global variable with default values. |
|
1012 | /** This function initialize the parameter_dump_packet global variable with default values. | |
1012 | * |
|
1013 | * | |
1013 | */ |
|
1014 | */ | |
1014 |
|
1015 | |||
1015 | unsigned int k; |
|
1016 | unsigned int k; | |
1016 |
|
1017 | |||
1017 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
1018 | parameter_dump_packet.targetLogicalAddress = CCSDS_DESTINATION_ID; | |
1018 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
1019 | parameter_dump_packet.protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
1019 | parameter_dump_packet.reserved = CCSDS_RESERVED; |
|
1020 | parameter_dump_packet.reserved = CCSDS_RESERVED; | |
1020 | parameter_dump_packet.userApplication = CCSDS_USER_APP; |
|
1021 | parameter_dump_packet.userApplication = CCSDS_USER_APP; | |
1021 | parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8); |
|
1022 | parameter_dump_packet.packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8); | |
1022 | parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; |
|
1023 | parameter_dump_packet.packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP; | |
1023 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
1024 | parameter_dump_packet.packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
1024 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
1025 | parameter_dump_packet.packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
1025 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8); |
|
1026 | parameter_dump_packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_PARAMETER_DUMP >> 8); | |
1026 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; |
|
1027 | parameter_dump_packet.packetLength[1] = (unsigned char) PACKET_LENGTH_PARAMETER_DUMP; | |
1027 | // DATA FIELD HEADER |
|
1028 | // DATA FIELD HEADER | |
1028 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
1029 | parameter_dump_packet.spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; | |
1029 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; |
|
1030 | parameter_dump_packet.serviceType = TM_TYPE_PARAMETER_DUMP; | |
1030 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; |
|
1031 | parameter_dump_packet.serviceSubType = TM_SUBTYPE_PARAMETER_DUMP; | |
1031 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; |
|
1032 | parameter_dump_packet.destinationID = TM_DESTINATION_ID_GROUND; | |
1032 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); |
|
1033 | parameter_dump_packet.time[0] = (unsigned char) (time_management_regs->coarse_time>>24); | |
1033 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); |
|
1034 | parameter_dump_packet.time[1] = (unsigned char) (time_management_regs->coarse_time>>16); | |
1034 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); |
|
1035 | parameter_dump_packet.time[2] = (unsigned char) (time_management_regs->coarse_time>>8); | |
1035 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); |
|
1036 | parameter_dump_packet.time[3] = (unsigned char) (time_management_regs->coarse_time); | |
1036 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); |
|
1037 | parameter_dump_packet.time[4] = (unsigned char) (time_management_regs->fine_time>>8); | |
1037 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); |
|
1038 | parameter_dump_packet.time[5] = (unsigned char) (time_management_regs->fine_time); | |
1038 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; |
|
1039 | parameter_dump_packet.sid = SID_PARAMETER_DUMP; | |
1039 |
|
1040 | |||
1040 | //****************** |
|
1041 | //****************** | |
1041 | // COMMON PARAMETERS |
|
1042 | // COMMON PARAMETERS | |
1042 | parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0; |
|
1043 | parameter_dump_packet.sy_lfr_common_parameters_spare = DEFAULT_SY_LFR_COMMON0; | |
1043 | parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1; |
|
1044 | parameter_dump_packet.sy_lfr_common_parameters = DEFAULT_SY_LFR_COMMON1; | |
1044 |
|
1045 | |||
1045 | //****************** |
|
1046 | //****************** | |
1046 | // NORMAL PARAMETERS |
|
1047 | // NORMAL PARAMETERS | |
1047 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8); |
|
1048 | parameter_dump_packet.sy_lfr_n_swf_l[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_L >> 8); | |
1048 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L ); |
|
1049 | parameter_dump_packet.sy_lfr_n_swf_l[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_L ); | |
1049 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8); |
|
1050 | parameter_dump_packet.sy_lfr_n_swf_p[0] = (unsigned char) (DFLT_SY_LFR_N_SWF_P >> 8); | |
1050 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P ); |
|
1051 | parameter_dump_packet.sy_lfr_n_swf_p[1] = (unsigned char) (DFLT_SY_LFR_N_SWF_P ); | |
1051 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8); |
|
1052 | parameter_dump_packet.sy_lfr_n_asm_p[0] = (unsigned char) (DFLT_SY_LFR_N_ASM_P >> 8); | |
1052 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P ); |
|
1053 | parameter_dump_packet.sy_lfr_n_asm_p[1] = (unsigned char) (DFLT_SY_LFR_N_ASM_P ); | |
1053 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0; |
|
1054 | parameter_dump_packet.sy_lfr_n_bp_p0 = (unsigned char) DFLT_SY_LFR_N_BP_P0; | |
1054 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1; |
|
1055 | parameter_dump_packet.sy_lfr_n_bp_p1 = (unsigned char) DFLT_SY_LFR_N_BP_P1; | |
1055 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3; |
|
1056 | parameter_dump_packet.sy_lfr_n_cwf_long_f3 = (unsigned char) DFLT_SY_LFR_N_CWF_LONG_F3; | |
1056 |
|
1057 | |||
1057 | //***************** |
|
1058 | //***************** | |
1058 | // BURST PARAMETERS |
|
1059 | // BURST PARAMETERS | |
1059 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; |
|
1060 | parameter_dump_packet.sy_lfr_b_bp_p0 = (unsigned char) DEFAULT_SY_LFR_B_BP_P0; | |
1060 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; |
|
1061 | parameter_dump_packet.sy_lfr_b_bp_p1 = (unsigned char) DEFAULT_SY_LFR_B_BP_P1; | |
1061 |
|
1062 | |||
1062 | //**************** |
|
1063 | //**************** | |
1063 | // SBM1 PARAMETERS |
|
1064 | // SBM1 PARAMETERS | |
1064 | parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period |
|
1065 | parameter_dump_packet.sy_lfr_s1_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P0; // min value is 0.25 s for the period | |
1065 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; |
|
1066 | parameter_dump_packet.sy_lfr_s1_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S1_BP_P1; | |
1066 |
|
1067 | |||
1067 | //**************** |
|
1068 | //**************** | |
1068 | // SBM2 PARAMETERS |
|
1069 | // SBM2 PARAMETERS | |
1069 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; |
|
1070 | parameter_dump_packet.sy_lfr_s2_bp_p0 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P0; | |
1070 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; |
|
1071 | parameter_dump_packet.sy_lfr_s2_bp_p1 = (unsigned char) DEFAULT_SY_LFR_S2_BP_P1; | |
1071 |
|
1072 | |||
1072 | //************ |
|
1073 | //************ | |
1073 | // FBINS MASKS |
|
1074 | // FBINS MASKS | |
1074 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) |
|
1075 | for (k=0; k < NB_FBINS_MASKS * NB_BYTES_PER_FBINS_MASK; k++) | |
1075 | { |
|
1076 | { | |
1076 | parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff; |
|
1077 | parameter_dump_packet.sy_lfr_fbins_f0_word1[k] = 0xff; | |
1077 | } |
|
1078 | } | |
1078 | } |
|
1079 | } | |
1079 |
|
1080 | |||
1080 | void init_kcoefficients_dump( void ) |
|
1081 | void init_kcoefficients_dump( void ) | |
1081 | { |
|
1082 | { | |
1082 | init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 ); |
|
1083 | init_kcoefficients_dump_packet( &kcoefficients_dump_1, 1, 30 ); | |
1083 | init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 ); |
|
1084 | init_kcoefficients_dump_packet( &kcoefficients_dump_2, 2, 6 ); | |
1084 |
|
1085 | |||
1085 | kcoefficient_node_1.previous = NULL; |
|
1086 | kcoefficient_node_1.previous = NULL; | |
1086 | kcoefficient_node_1.next = NULL; |
|
1087 | kcoefficient_node_1.next = NULL; | |
1087 | kcoefficient_node_1.sid = TM_CODE_K_DUMP; |
|
1088 | kcoefficient_node_1.sid = TM_CODE_K_DUMP; | |
1088 | kcoefficient_node_1.coarseTime = 0x00; |
|
1089 | kcoefficient_node_1.coarseTime = 0x00; | |
1089 | kcoefficient_node_1.fineTime = 0x00; |
|
1090 | kcoefficient_node_1.fineTime = 0x00; | |
1090 | kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1; |
|
1091 | kcoefficient_node_1.buffer_address = (int) &kcoefficients_dump_1; | |
1091 | kcoefficient_node_1.status = 0x00; |
|
1092 | kcoefficient_node_1.status = 0x00; | |
1092 |
|
1093 | |||
1093 | kcoefficient_node_2.previous = NULL; |
|
1094 | kcoefficient_node_2.previous = NULL; | |
1094 | kcoefficient_node_2.next = NULL; |
|
1095 | kcoefficient_node_2.next = NULL; | |
1095 | kcoefficient_node_2.sid = TM_CODE_K_DUMP; |
|
1096 | kcoefficient_node_2.sid = TM_CODE_K_DUMP; | |
1096 | kcoefficient_node_2.coarseTime = 0x00; |
|
1097 | kcoefficient_node_2.coarseTime = 0x00; | |
1097 | kcoefficient_node_2.fineTime = 0x00; |
|
1098 | kcoefficient_node_2.fineTime = 0x00; | |
1098 | kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2; |
|
1099 | kcoefficient_node_2.buffer_address = (int) &kcoefficients_dump_2; | |
1099 | kcoefficient_node_2.status = 0x00; |
|
1100 | kcoefficient_node_2.status = 0x00; | |
1100 | } |
|
1101 | } | |
1101 |
|
1102 | |||
1102 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ) |
|
1103 | void init_kcoefficients_dump_packet( Packet_TM_LFR_KCOEFFICIENTS_DUMP_t *kcoefficients_dump, unsigned char pkt_nr, unsigned char blk_nr ) | |
1103 | { |
|
1104 | { | |
1104 | unsigned int k; |
|
1105 | unsigned int k; | |
1105 | unsigned int packetLength; |
|
1106 | unsigned int packetLength; | |
1106 |
|
1107 | |||
1107 | packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header |
|
1108 | packetLength = blk_nr * 130 + 20 - CCSDS_TC_TM_PACKET_OFFSET; // 4 bytes for the CCSDS header | |
1108 |
|
1109 | |||
1109 | kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID; |
|
1110 | kcoefficients_dump->targetLogicalAddress = CCSDS_DESTINATION_ID; | |
1110 | kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID; |
|
1111 | kcoefficients_dump->protocolIdentifier = CCSDS_PROTOCOLE_ID; | |
1111 | kcoefficients_dump->reserved = CCSDS_RESERVED; |
|
1112 | kcoefficients_dump->reserved = CCSDS_RESERVED; | |
1112 | kcoefficients_dump->userApplication = CCSDS_USER_APP; |
|
1113 | kcoefficients_dump->userApplication = CCSDS_USER_APP; | |
1113 | kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);; |
|
1114 | kcoefficients_dump->packetID[0] = (unsigned char) (APID_TM_PARAMETER_DUMP >> 8);; | |
1114 | kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;; |
|
1115 | kcoefficients_dump->packetID[1] = (unsigned char) APID_TM_PARAMETER_DUMP;; | |
1115 | kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; |
|
1116 | kcoefficients_dump->packetSequenceControl[0] = TM_PACKET_SEQ_CTRL_STANDALONE; | |
1116 | kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; |
|
1117 | kcoefficients_dump->packetSequenceControl[1] = TM_PACKET_SEQ_CNT_DEFAULT; | |
1117 | kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8); |
|
1118 | kcoefficients_dump->packetLength[0] = (unsigned char) (packetLength >> 8); | |
1118 | kcoefficients_dump->packetLength[1] = (unsigned char) packetLength; |
|
1119 | kcoefficients_dump->packetLength[1] = (unsigned char) packetLength; | |
1119 | // DATA FIELD HEADER |
|
1120 | // DATA FIELD HEADER | |
1120 | kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; |
|
1121 | kcoefficients_dump->spare1_pusVersion_spare2 = SPARE1_PUSVERSION_SPARE2; | |
1121 | kcoefficients_dump->serviceType = TM_TYPE_K_DUMP; |
|
1122 | kcoefficients_dump->serviceType = TM_TYPE_K_DUMP; | |
1122 | kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP; |
|
1123 | kcoefficients_dump->serviceSubType = TM_SUBTYPE_K_DUMP; | |
1123 | kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND; |
|
1124 | kcoefficients_dump->destinationID= TM_DESTINATION_ID_GROUND; | |
1124 | kcoefficients_dump->time[0] = 0x00; |
|
1125 | kcoefficients_dump->time[0] = 0x00; | |
1125 | kcoefficients_dump->time[1] = 0x00; |
|
1126 | kcoefficients_dump->time[1] = 0x00; | |
1126 | kcoefficients_dump->time[2] = 0x00; |
|
1127 | kcoefficients_dump->time[2] = 0x00; | |
1127 | kcoefficients_dump->time[3] = 0x00; |
|
1128 | kcoefficients_dump->time[3] = 0x00; | |
1128 | kcoefficients_dump->time[4] = 0x00; |
|
1129 | kcoefficients_dump->time[4] = 0x00; | |
1129 | kcoefficients_dump->time[5] = 0x00; |
|
1130 | kcoefficients_dump->time[5] = 0x00; | |
1130 | kcoefficients_dump->sid = SID_K_DUMP; |
|
1131 | kcoefficients_dump->sid = SID_K_DUMP; | |
1131 |
|
1132 | |||
1132 | kcoefficients_dump->pkt_cnt = 2; |
|
1133 | kcoefficients_dump->pkt_cnt = 2; | |
1133 | kcoefficients_dump->pkt_nr = pkt_nr; |
|
1134 | kcoefficients_dump->pkt_nr = pkt_nr; | |
1134 | kcoefficients_dump->blk_nr = blk_nr; |
|
1135 | kcoefficients_dump->blk_nr = blk_nr; | |
1135 |
|
1136 | |||
1136 | //****************** |
|
1137 | //****************** | |
1137 | // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR] |
|
1138 | // SOURCE DATA repeated N times with N in [0 .. PA_LFR_KCOEFF_BLK_NR] | |
1138 | // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900) |
|
1139 | // one blk is 2 + 4 * 32 = 130 bytes, 30 blks max in one packet (30 * 130 = 3900) | |
1139 | for (k=0; k<3900; k++) |
|
1140 | for (k=0; k<3900; k++) | |
1140 | { |
|
1141 | { | |
1141 | kcoefficients_dump->kcoeff_blks[k] = 0x00; |
|
1142 | kcoefficients_dump->kcoeff_blks[k] = 0x00; | |
1142 | } |
|
1143 | } | |
1143 | } |
|
1144 | } | |
1144 |
|
1145 | |||
1145 | void print_k_coeff() |
|
1146 | void print_k_coeff() | |
1146 | { |
|
1147 | { | |
1147 | unsigned int kcoeff; |
|
1148 | unsigned int kcoeff; | |
1148 | unsigned int bin; |
|
1149 | unsigned int bin; | |
1149 |
|
1150 | |||
1150 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
1151 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) | |
1151 | { |
|
1152 | { | |
1152 | printf("kcoeff = %d *** ", kcoeff); |
|
1153 | printf("kcoeff = %d *** ", kcoeff); | |
1153 | for (bin=0; bin<NB_BINS_COMPRESSED_SM_F0; bin++) |
|
1154 | for (bin=0; bin<NB_BINS_COMPRESSED_SM_F0; bin++) | |
1154 | { |
|
1155 | { | |
1155 | printf( "%f ", k_coeff_intercalib_f0_norm[bin*NB_K_COEFF_PER_BIN+kcoeff] ); |
|
1156 | printf( "%f ", k_coeff_intercalib_f0_norm[bin*NB_K_COEFF_PER_BIN+kcoeff] ); | |
1156 | } |
|
1157 | } | |
1157 | printf("\n"); |
|
1158 | printf("\n"); | |
1158 | } |
|
1159 | } | |
1159 |
|
1160 | |||
1160 | printf("\n"); |
|
1161 | printf("\n"); | |
1161 |
|
1162 | |||
1162 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) |
|
1163 | for (kcoeff=0; kcoeff<NB_K_COEFF_PER_BIN; kcoeff++) | |
1163 | { |
|
1164 | { | |
1164 | printf("kcoeff = %d *** ", kcoeff); |
|
1165 | printf("kcoeff = %d *** ", kcoeff); | |
1165 | for (bin=0; bin<NB_BINS_COMPRESSED_SM_F0; bin++) |
|
1166 | for (bin=0; bin<NB_BINS_COMPRESSED_SM_F0; bin++) | |
1166 | { |
|
1167 | { | |
1167 | printf( "[%f, %f] ", |
|
1168 | printf( "[%f, %f] ", | |
1168 | k_coeff_intercalib_f0_sbm[(bin*NB_K_COEFF_PER_BIN )*2 + kcoeff], |
|
1169 | k_coeff_intercalib_f0_sbm[(bin*NB_K_COEFF_PER_BIN )*2 + kcoeff], | |
1169 | k_coeff_intercalib_f0_sbm[(bin*NB_K_COEFF_PER_BIN+1)*2 + kcoeff]); |
|
1170 | k_coeff_intercalib_f0_sbm[(bin*NB_K_COEFF_PER_BIN+1)*2 + kcoeff]); | |
1170 | } |
|
1171 | } | |
1171 | printf("\n"); |
|
1172 | printf("\n"); | |
1172 | } |
|
1173 | } | |
1173 | } |
|
1174 | } | |
1174 |
|
1175 |
General Comments 0
You need to be logged in to leave comments.
Login now